From 1e239818d16eda38a039e8cd83dda73ddc135954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Castre?= Date: Wed, 15 Jan 2014 15:14:24 +0100 Subject: [PATCH 001/240] Durandal: System, ViewEngine, ViewLocator declaration in interface Fix in DurandalEventSubscription: the routeHandler wasn't optional --- durandal/durandal.d.ts | 659 +++++++++++++++++++++-------------------- 1 file changed, 338 insertions(+), 321 deletions(-) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index c2567f62c5..53a71adfca 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -13,193 +13,8 @@ * @requires jquery */ declare module 'durandal/system' { - /** - * Durandal's version. - */ - export var version: string; - - /** - * A noop function. - */ - export var noop: Function; - - /** - * Gets the module id for the specified object. - * @param {object} obj The object whose module id you wish to determine. - * @returns {string} The module id. - */ - export function getModuleId(obj: any): string; - - /** - * Sets the module id for the specified object. - * @param {object} obj The object whose module id you wish to set. - * @param {string} id The id to set for the specified object. - */ - export function setModuleId(obj, id: string): void; - - /** - * Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with `new` and it's result is returned. - * @param {object} module The module to use to get/create the default object for. - * @returns {object} The default object for the module. - */ - export function resolveObject(module: any): any; - - /** - * Gets/Sets whether or not Durandal is in debug mode. - * @param {boolean} [enable] Turns on/off debugging. - * @returns {boolean} Whether or not Durandal is current debugging. - */ - export function debug(enable?: boolean): boolean; - - /** - * Logs data to the console. Pass any number of parameters to be logged. Log output is not processed if the framework is not running in debug mode. - * @param {object} info* The objects to log. - */ - export function log(...msgs: any[]): void; - - /** - * Logs an error. - * @param {string} obj The error to report. - */ - export function error(error: string): void; - - /** - * Logs an error. - * @param {Error} obj The error to report. - */ - export function error(error: Error): void; - - /** - * Asserts a condition by throwing an error if the condition fails. - * @param {boolean} condition The condition to check. - * @param {string} message The message to report in the error if the condition check fails. - */ - export function assert(condition: boolean, message: string): void; - - /** - * Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise. - * @param {function} [action] The action to defer. You will be passed the deferred object as a paramter. - * @returns {JQueryDeferred} The deferred object. - */ - export function defer(action?: (dfd: JQueryDeferred) => void ): JQueryDeferred; - - /** - * Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see [node-uuid](https://github.com/broofa/node-uuid). - * @returns {string} The guid. - */ - export function guid(): string; - - /** - * Uses require.js to obtain a module. This function returns a promise which resolves with the module instance. - * @param {string} moduleId The id of the module to load. - * @returns {JQueryPromise} A promise for the loaded module. - */ - export function acquire(moduleId: string): JQueryPromise; - - /** - * Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array. - * @param {string[]} moduleIds The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. - */ - export function acquire(modules: string[]): JQueryPromise; - - /** - * Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array. - * @param {string} moduleIds* The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. - */ - export function acquire(...moduleIds: string[]): JQueryPromise; - - /** - * Extends the first object with the properties of the following objects. - * @param {object} obj The target object to extend. - * @param {object} extension* Uses to extend the target object. - */ - export function extend(obj: any, ...extensions: any[]): any; - - /** - * Uses a setTimeout to wait the specified milliseconds. - * @param {number} milliseconds The number of milliseconds to wait. - * @returns {JQueryPromise} - */ - export function wait(milliseconds: number): JQueryPromise; - - /** - * Gets all the owned keys of the specified object. - * @param {object} object The object whose owned keys should be returned. - * @returns {string[]} The keys. - */ - export function keys(obj: any): string[]; - - /** - * Determines if the specified object is an html element. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isElement(obj: any): boolean; - - /** - * Determines if the specified object is an array. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isArray(obj: any): boolean; - - /** - * Determines if the specified object is a boolean. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isObject(obj: any): boolean; - - /** - * Determines if the specified object is a promise. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isPromise(obj: any): boolean; - - /** - * Determines if the specified object is a function arguments object. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isArguments(obj: any): boolean; - - /** - * Determines if the specified object is a function. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isFunction(obj: any): boolean; - - /** - * Determines if the specified object is a string. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isString(obj: any): boolean; - - /** - * Determines if the specified object is a number. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isNumber(obj: any): boolean; - - /** - * Determines if the specified object is a date. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isDate(obj: any): boolean; - - /** - * Determines if the specified object is a boolean. - * @param {object} object The object to check. - * @returns {boolean} True if matches the type, false otherwise. - */ - export function isBoolean(obj: any): boolean; + var theModule: DurandalSystemModule; + export = theModule; } /** @@ -208,75 +23,8 @@ declare module 'durandal/system' { * @requires jquery */ declare module 'durandal/viewEngine' { - /** - * The file extension that view source files are expected to have. - * @default .html - */ - export var viewExtension: string; - - /** - * The name of the RequireJS loader plugin used by the viewLocator to obtain the view source. (Use requirejs to map the plugin's full path). - * @default text - */ - export var viewPlugin: string; - - /** - * Determines if the url is a url for a view, according to the view engine. - * @param {string} url The potential view url. - * @returns {boolean} True if the url is a view url, false otherwise. - */ - export function isViewUrl(url: string):boolean; - - /** - * Converts a view url into a view id. - * @param {string} url The url to convert. - * @returns {string} The view id. - */ - export function convertViewUrlToViewId(url: string): string; - - /** - * Converts a view id into a full RequireJS path. - * @param {string} viewId The view id to convert. - * @returns {string} The require path. - */ - export function convertViewIdToRequirePath(viewId: string): string; - - /** - * Parses the view engine recognized markup and returns DOM elements. - * @param {string} markup The markup to parse. - * @returns {HTMLElement[]} The elements. - */ - export function parseMarkup(markup: string):Node[]; - - /** - * Calls `parseMarkup` and then pipes the results through `ensureSingleElement`. - * @param {string} markup The markup to process. - * @returns {HTMLElement} The view. - */ - export function processMarkup(markup: string): HTMLElement; - - /** - * Converts an array of elements into a single element. White space and comments are removed. If a single element does not remain, then the elements are wrapped. - * @param {HTMLElement[]} allElements The elements. - * @returns {HTMLElement} A single element. - */ - export function ensureSingleElement(allElements: Node[]): HTMLElement; - - /** - * Creates the view associated with the view id. - * @param {string} viewId The view id whose view should be created. - * @returns {JQueryPromise} A promise of the view. - */ - export function createView(viewId: string): JQueryPromise; - - /** - * Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development. - * @param {string} viewId The view id whose view should be created. - * @param {string} requirePath The require path that was attempted. - * @param {Error} requirePath The error that was returned from the attempt to locate the default view. - * @returns {Promise} A promise for the fallback view. - */ - export function createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise; + var theModule: DurandalViewEngineModule; + export = theModule; } /** @@ -305,7 +53,7 @@ declare module 'durandal/binder' { * @param {DOMElement} view The view that is about to be bound. * @param {object} instruction The object that carries the binding instructions. */ - export var binding: (data:any, view:HTMLElement, instruction:BindingInstruction) => void; + export var binding: (data: any, view: HTMLElement, instruction: BindingInstruction) => void; /** * Called after every binding operation. Does nothing by default. @@ -335,7 +83,7 @@ declare module 'durandal/binder' { * @param {object} [obj] The data to bind to, causing the creation of a child binding context if present. */ export function bindContext(bindingContext: KnockoutBindingContext, view: HTMLElement, obj?: any): BindingInstruction; - + /** * Binds the view, preserving the existing binding context. Optionally, a new context can be created, parented to the previous context. * @param {object} obj The data to bind to. @@ -358,7 +106,7 @@ declare module 'durandal/activator' { * @property {ActivatorSettings} defaults */ export var defaults: DurandalActivatorSettings; - + /** * Creates a new activator. * @method create @@ -383,62 +131,8 @@ declare module 'durandal/activator' { * @requires viewEngine */ declare module 'durandal/viewLocator' { - /** - * Allows you to set up a convention for mapping module folders to view folders. It is a convenience method that customizes `convertModuleIdToViewId` and `translateViewIdToArea` under the covers. - * @param {string} [modulesPath] A string to match in the path and replace with the viewsPath. If not specified, the match is 'viewmodels'. - * @param {string} [viewsPath] The replacement for the modulesPath. If not specified, the replacement is 'views'. - * @param {string} [areasPath] Partial views are mapped to the "views" folder if not specified. Use this parameter to change their location. - */ - export function useConvention(modulesPath?: string, viewsPath?: string, areasPath?: string): void; - - /** - * Maps an object instance to a view instance. - * @param {object} obj The object to locate the view for. - * @param {string} [area] The area to translate the view to. - * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. - * @returns {Promise} A promise of the view. - */ - export function locateViewForObject(obj: any, area:string, elementsToSearch?: HTMLElement[]): JQueryPromise; - - /** - * Converts a module id into a view id. By default the ids are the same. - * @param {string} moduleId The module id. - * @returns {string} The view id. - */ - export function convertModuleIdToViewId(moduleId: string): string; - - /** - * If no view id can be determined, this function is called to genreate one. By default it attempts to determine the object's type and use that. - * @param {object} obj The object to determine the fallback id for. - * @returns {string} The view id. - */ - export function determineFallbackViewId(obj: any): string; - - /** - * Takes a view id and translates it into a particular area. By default, no translation occurs. - * @param {string} viewId The view id. - * @param {string} area The area to translate the view to. - * @returns {string} The translated view id. - */ - export function translateViewIdToArea(viewId: string, area: string): string; - - /** - * Locates the specified view. - * @param {string|DOMElement} view A view. It will be immediately returned. - * @param {string} [area] The area to translate the view to. - * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. - * @returns {Promise} A promise of the view. - */ - export function locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; - - /** - * Locates the specified view. - * @param {string|DOMElement} viewUrlOrId A view url or view id to locate. - * @param {string} [area] The area to translate the view to. - * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. - * @returns {Promise} A promise of the view. - */ - export function locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + var theModule: DurandalViewLocatorModule; + export = theModule; } /** @@ -608,7 +302,7 @@ declare module 'plugins/dialog' { * @param {string} viewUrl The view url relative to the base url which the view locator will use to find the message box's view. * @static */ - static setViewUrl(url:string):void; + static setViewUrl(url: string): void; } interface DialogContext { @@ -676,7 +370,7 @@ declare module 'plugins/dialog' { * @param {DialogContext} dialogContext The context to add. */ export function addContext(name: string, modalContext: DialogContext): void; - + /** * Gets the dialog model that is associated with the specified object. * @param {object} obj The object for whom to retrieve the dialog. @@ -815,7 +509,7 @@ declare module 'plugins/http' { * @default callback */ export var callbackParam: string; - + /** * Makes an HTTP GET request. * @param {string} url The url to send the get request to. @@ -832,7 +526,7 @@ declare module 'plugins/http' { * @returns {Promise} A promise of the response data. */ export function jsonp(url: string, query?: Object, callbackParam?: string): JQueryPromise; - + /** * Makes an HTTP POST request. * @param {string} url The url to send the post request to. @@ -1093,6 +787,329 @@ declare module 'plugins/router' { export = theModule; } +interface DurandalSystemModule { + /** + * Durandal's version. + */ + version: string; + + /** + * A noop function. + */ + noop: Function; + + /** + * Gets the module id for the specified object. + * @param {object} obj The object whose module id you wish to determine. + * @returns {string} The module id. + */ + getModuleId(obj: any): string; + + /** + * Sets the module id for the specified object. + * @param {object} obj The object whose module id you wish to set. + * @param {string} id The id to set for the specified object. + */ + setModuleId(obj, id: string): void; + + /** + * Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with `new` and it's result is returned. + * @param {object} module The module to use to get/create the default object for. + * @returns {object} The default object for the module. + */ + resolveObject(module: any): any; + + /** + * Gets/Sets whether or not Durandal is in debug mode. + * @param {boolean} [enable] Turns on/off debugging. + * @returns {boolean} Whether or not Durandal is current debugging. + */ + debug(enable?: boolean): boolean; + + /** + * Logs data to the console. Pass any number of parameters to be logged. Log output is not processed if the framework is not running in debug mode. + * @param {object} info* The objects to log. + */ + log(...msgs: any[]): void; + + /** + * Logs an error. + * @param {string} obj The error to report. + */ + error(error: string): void; + + /** + * Logs an error. + * @param {Error} obj The error to report. + */ + error(error: Error): void; + + /** + * Asserts a condition by throwing an error if the condition fails. + * @param {boolean} condition The condition to check. + * @param {string} message The message to report in the error if the condition check fails. + */ + assert(condition: boolean, message: string): void; + + /** + * Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise. + * @param {function} [action] The action to defer. You will be passed the deferred object as a paramter. + * @returns {JQueryDeferred} The deferred object. + */ + defer(action?: (dfd: JQueryDeferred) => void): JQueryDeferred; + + /** + * Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see [node-uuid](https://github.com/broofa/node-uuid). + * @returns {string} The guid. + */ + guid(): string; + + /** + * Uses require.js to obtain a module. This function returns a promise which resolves with the module instance. + * @param {string} moduleId The id of the module to load. + * @returns {JQueryPromise} A promise for the loaded module. + */ + acquire(moduleId: string): JQueryPromise; + + /** + * Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array. + * @param {string[]} moduleIds The ids of the modules to load. + * @returns {JQueryPromise} A promise for the loaded module. + */ + acquire(modules: string[]): JQueryPromise; + + /** + * Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array. + * @param {string} moduleIds* The ids of the modules to load. + * @returns {JQueryPromise} A promise for the loaded module. + */ + acquire(...moduleIds: string[]): JQueryPromise; + + /** + * Extends the first object with the properties of the following objects. + * @param {object} obj The target object to extend. + * @param {object} extension* Uses to extend the target object. + */ + extend(obj: any, ...extensions: any[]): any; + + /** + * Uses a setTimeout to wait the specified milliseconds. + * @param {number} milliseconds The number of milliseconds to wait. + * @returns {JQueryPromise} + */ + wait(milliseconds: number): JQueryPromise; + + /** + * Gets all the owned keys of the specified object. + * @param {object} object The object whose owned keys should be returned. + * @returns {string[]} The keys. + */ + keys(obj: any): string[]; + + /** + * Determines if the specified object is an html element. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isElement(obj: any): boolean; + + /** + * Determines if the specified object is an array. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isArray(obj: any): boolean; + + /** + * Determines if the specified object is a boolean. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isObject(obj: any): boolean; + + /** + * Determines if the specified object is a promise. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isPromise(obj: any): boolean; + + /** + * Determines if the specified object is a function arguments object. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isArguments(obj: any): boolean; + + /** + * Determines if the specified object is a function. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isFunction(obj: any): boolean; + + /** + * Determines if the specified object is a string. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isString(obj: any): boolean; + + /** + * Determines if the specified object is a number. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isNumber(obj: any): boolean; + + /** + * Determines if the specified object is a date. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isDate(obj: any): boolean; + + /** + * Determines if the specified object is a boolean. + * @param {object} object The object to check. + * @returns {boolean} True if matches the type, false otherwise. + */ + isBoolean(obj: any): boolean; +} + +interface DurandalViewEngineModule { + + /** + * The file extension that view source files are expected to have. + * @default .html + */ + viewExtension: string; + + /** + * The name of the RequireJS loader plugin used by the viewLocator to obtain the view source. (Use requirejs to map the plugin's full path). + * @default text + */ + viewPlugin: string; + + /** + * Determines if the url is a url for a view, according to the view engine. + * @param {string} url The potential view url. + * @returns {boolean} True if the url is a view url, false otherwise. + */ + isViewUrl(url: string): boolean; + + /** + * Converts a view url into a view id. + * @param {string} url The url to convert. + * @returns {string} The view id. + */ + convertViewUrlToViewId(url: string): string; + + /** + * Converts a view id into a full RequireJS path. + * @param {string} viewId The view id to convert. + * @returns {string} The require path. + */ + convertViewIdToRequirePath(viewId: string): string; + + /** + * Parses the view engine recognized markup and returns DOM elements. + * @param {string} markup The markup to parse. + * @returns {HTMLElement[]} The elements. + */ + parseMarkup(markup: string): Node[]; + + /** + * Calls `parseMarkup` and then pipes the results through `ensureSingleElement`. + * @param {string} markup The markup to process. + * @returns {HTMLElement} The view. + */ + processMarkup(markup: string): HTMLElement; + + /** + * Converts an array of elements into a single element. White space and comments are removed. If a single element does not remain, then the elements are wrapped. + * @param {HTMLElement[]} allElements The elements. + * @returns {HTMLElement} A single element. + */ + ensureSingleElement(allElements: Node[]): HTMLElement; + + /** + * Creates the view associated with the view id. + * @param {string} viewId The view id whose view should be created. + * @returns {JQueryPromise} A promise of the view. + */ + createView(viewId: string): JQueryPromise; + + /** + * Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development. + * @param {string} viewId The view id whose view should be created. + * @param {string} requirePath The require path that was attempted. + * @param {Error} requirePath The error that was returned from the attempt to locate the default view. + * @returns {Promise} A promise for the fallback view. + */ + createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise; +} + +interface DurandalViewLocatorModule { + + /** + * Allows you to set up a convention for mapping module folders to view folders. It is a convenience method that customizes `convertModuleIdToViewId` and `translateViewIdToArea` under the covers. + * @param {string} [modulesPath] A string to match in the path and replace with the viewsPath. If not specified, the match is 'viewmodels'. + * @param {string} [viewsPath] The replacement for the modulesPath. If not specified, the replacement is 'views'. + * @param {string} [areasPath] Partial views are mapped to the "views" folder if not specified. Use this parameter to change their location. + */ + useConvention(modulesPath?: string, viewsPath?: string, areasPath?: string): void; + + /** + * Maps an object instance to a view instance. + * @param {object} obj The object to locate the view for. + * @param {string} [area] The area to translate the view to. + * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. + * @returns {Promise} A promise of the view. + */ + locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + + /** + * Converts a module id into a view id. By default the ids are the same. + * @param {string} moduleId The module id. + * @returns {string} The view id. + */ + convertModuleIdToViewId(moduleId: string): string; + + /** + * If no view id can be determined, this function is called to genreate one. By default it attempts to determine the object's type and use that. + * @param {object} obj The object to determine the fallback id for. + * @returns {string} The view id. + */ + determineFallbackViewId(obj: any): string; + + /** + * Takes a view id and translates it into a particular area. By default, no translation occurs. + * @param {string} viewId The view id. + * @param {string} area The area to translate the view to. + * @returns {string} The translated view id. + */ + translateViewIdToArea(viewId: string, area: string): string; + + /** + * Locates the specified view. + * @param {string|DOMElement} view A view. It will be immediately returned. + * @param {string} [area] The area to translate the view to. + * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. + * @returns {Promise} A promise of the view. + */ + locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + + /** + * Locates the specified view. + * @param {string|DOMElement} viewUrlOrId A view url or view id to locate. + * @param {string} [area] The area to translate the view to. + * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. + * @returns {Promise} A promise of the view. + */ + locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; +} + interface DurandalEventSubscription { /** * Attaches a callback to the event subscription. @@ -1346,7 +1363,7 @@ interface DurandalHistoryOptions { /** * The function that will be called back when the fragment changes. */ - routeHandler: (fragment: string) => void; + routeHandler?: (fragment: string) => void; /** * The url root used to extract the fragment when using push state. @@ -1384,7 +1401,7 @@ interface DurandalRouteConfiguration { route?: string; routePattern?: RegExp; isActive?: KnockoutComputed; - nav:any; + nav: any; } interface DurandalRouteInstruction { From daca31dc77ac259a1be8a4b0774692ed65e07c22 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 17 Jan 2014 09:27:10 +0000 Subject: [PATCH 002/240] jQuery: added typing for fn --- jquery/jquery-tests.ts | 31 +++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 29 +++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 95fed2635a..1b2fb5d16c 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2316,6 +2316,27 @@ function test_jQuery() { }); } +function test_fn_extend() { + jQuery.fn.extend({ + check: function () { + return this.each(function () { + this.checked = true; + }); + }, + uncheck: function () { + return this.each(function () { + this.checked = false; + }); + } + }); + + // Use the newly created .check() method + //$( "input[type='checkbox']" ).check(); + // The above test cannot be run as no way that I know of in TypeScript to model the augmentation of jQueryStatic with dynamically added methods + // The below would only work at runtime if extend had first been called. + $("input[type='checkbox']")["check"](); +} + function test_jquery() { var a = { what: "A regular JS object" }, b = $('body'); @@ -2422,6 +2443,16 @@ function test_jquery() { jQuery(function ($) { // Your code using failsafe $ alias here... }); + + $(document.body) + .click(function () { + $(document.body).append($("
")); + var n = $("div").length; + $("span").text("There are " + n + " divs." + + "Click to add more."); + }) + // Trigger the click to start + .trigger("click"); } function test_keydown() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 9fc3b1dffb..9b412c5b53 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -778,12 +778,33 @@ interface JQueryStatic { Event: JQueryEventConstructor; - // Internals - error(message: any): JQuery; + /** + * Takes a string and throws an exception containing it. + * + * @param message The message to send out. + */ + error(message: string): JQuery; - // Miscellaneous expr: any; - fn: any; //TODO: Decide how we want to type this + fn: { + /** + * A string containing the jQuery version number. + */ + jquery: string; + + /** + * The number of elements in the jQuery object. + */ + length: number; + + /** + * Merge the contents of an object onto the jQuery prototype to provide new jQuery instance methods. + * + * @param object An object to merge onto the jQuery prototype. + */ + extend(object: any): any; + } + isReady: boolean; // Properties From a0a77855ec546109971c83118a0c9b519e69bedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Bal=C3=A1ssy?= Date: Fri, 17 Jan 2014 12:45:01 +0100 Subject: [PATCH 003/240] Support multiple 'from' states According to https://github.com/jakesgordon/javascript-state-machine: "If an event is allowed from multiple states, and always transitions to the same state, then simply provide an array of states in the from attribute of an event." So the from property can be of type string or string[], so "any" is required here. --- state-machine/state-machine.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/state-machine/state-machine.d.ts b/state-machine/state-machine.d.ts index efecb2e4c3..3415beb7c8 100644 --- a/state-machine/state-machine.d.ts +++ b/state-machine/state-machine.d.ts @@ -11,7 +11,7 @@ interface StateMachineErrorCallback { interface StateMachineEventDef { name: string; - from: string; + from: any; // string or string[] to: string; } @@ -78,4 +78,4 @@ interface StateMachine { transition: StateMachineTransition; } -declare var StateMachine: StateMachineStatic; \ No newline at end of file +declare var StateMachine: StateMachineStatic; From 1ad25afa033112c35d2e1e92ef34d0a7081f0697 Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Fri, 17 Jan 2014 15:32:37 +0100 Subject: [PATCH 004/240] Definition files for angular-translate --- README.md | 1 + angular-translate/angular-translate-tests.ts | 25 ++++++++ angular-translate/angular-translate.d.ts | 63 ++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 angular-translate/angular-translate-tests.ts create mode 100644 angular-translate/angular-translate.d.ts diff --git a/README.md b/README.md index 8760adc871..168c89a8d8 100755 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ List of Definitions * [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/)) * [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) * [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib)) +* [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib)) * [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted)) * [AppFramework](http://app-framework-software.intel.com/) (by [Kyo Ago](https://github.com/kyo-ago)) * [Arbiter](http://arbiterjs.com/) (by [Arash Shakery](https://github.com/arash16)) diff --git a/angular-translate/angular-translate-tests.ts b/angular-translate/angular-translate-tests.ts new file mode 100644 index 0000000000..1977a0f840 --- /dev/null +++ b/angular-translate/angular-translate-tests.ts @@ -0,0 +1,25 @@ +/// + +var app = angular.module('at', ['pascalprecht.translate']); + +app.config(($translateProvider: ng.translate.ITranslateProvider) => { + $translateProvider.translations('en', { + TITLE: 'Hello', + FOO: 'This is a paragraph.', + BUTTON_LANG_EN: 'english', + BUTTON_LANG_DE: 'german' + }); + $translateProvider.translations('de', { + TITLE: 'Hallo', + FOO: 'Dies ist ein Paragraph.', + BUTTON_LANG_EN: 'englisch', + BUTTON_LANG_DE: 'deutsch' + }); + $translateProvider.preferredLanguage('en'); +}); + +app.controller('Ctrl', ($scope: ng.IScope, $translate: ng.translate.ITranslateService) => { + $scope['changeLanguage'] = function (key) { + $translate.uses(key); + }; +}); diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts new file mode 100644 index 0000000000..aac4a74126 --- /dev/null +++ b/angular-translate/angular-translate.d.ts @@ -0,0 +1,63 @@ +// Type definitions for Angular Translate (pascalprecht.translate module) +// Project: https://github.com/PascalPrecht/angular-translate +// Definitions by: Michel Salib +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ng.translate { + interface ITranslationTable { + [key: string]: string; + } + + interface IStorage { + get(name: string): string; + set(name: string, value: string): void; + } + + interface ISTaticFilesLoaderOptions { + prefix: string; + suffix: string; + key?: string; + } + + interface ITranslateService { + (key: string, ...params: string[]): string; + fallbackLanguage(): string; + preferredLanguage(): string; + proposedLanguage(): string; + refresh(lankKey: string): ng.IPromise; + storage(): IStorage; + storageKey(): string; + uses(): string; + uses(key: string): ng.IPromise; + } + + interface ITranslateProvider extends ng.IServiceProvider { + translations(key: string, translationTable: ITranslationTable): ITranslateProvider; + addInterpolation(factory: any): ITranslateProvider; + useMessageFormatInterpolation(): ITranslateProvider; + useInterpolation(factory: string): ITranslateProvider; + preferredLanguage(): string; + preferredLanguage(language: string): ITranslateProvider; + translationNotFoundIndicator(indicator: string): ITranslateProvider; + translationNotFoundIndicatorLeft(): string; + translationNotFoundIndicatorLeft(indicator: string): ITranslateProvider; + translationNotFoundIndicatorRight(): string; + translationNotFoundIndicatorRight(indicator: string): ITranslateProvider; + fallbackLanguage(): string; + fallbackLanguage(language: string): ITranslateProvider; + uses(): string; + uses(key: string): ITranslateProvider; + useUrlLoader(url: string): ITranslateProvider; + useStaticFilesLoader(options: ISTaticFilesLoaderOptions): ITranslateProvider; + useLoader(loaderFactory: string, options: any): ITranslateProvider; + useLocalStorage(): ITranslateProvider; + useCookieStorage(): ITranslateProvider; + useStorage(storageFactory: any): ITranslateProvider; + storagePrefix(): string; + storagePrefix(prefix: string): ITranslateProvider; + useMissingTranslationHandlerLog(): ITranslateProvider; + useMissingTranslationHandler(factory: string): ITranslateProvider; + } +} From eadffeb409c9d9878703073ed31b07d5f5dec4a1 Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Sat, 18 Jan 2014 14:21:31 +0100 Subject: [PATCH 005/240] Update angular-translate-tests.ts --- angular-translate/angular-translate-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-translate/angular-translate-tests.ts b/angular-translate/angular-translate-tests.ts index 1977a0f840..7cb6c89c38 100644 --- a/angular-translate/angular-translate-tests.ts +++ b/angular-translate/angular-translate-tests.ts @@ -19,7 +19,7 @@ app.config(($translateProvider: ng.translate.ITranslateProvider) => { }); app.controller('Ctrl', ($scope: ng.IScope, $translate: ng.translate.ITranslateService) => { - $scope['changeLanguage'] = function (key) { + $scope['changeLanguage'] = function (key: any) { $translate.uses(key); }; }); From af80fa34293d95ef3a1ec18535235fafc6307dd5 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Sat, 18 Jan 2014 23:13:39 -0500 Subject: [PATCH 006/240] (feat): Updated function methods to be generic This allows those method signatures to be passed through, but gain the benefits of things like throttle, memoize. --- lodash/lodash.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 5de99d755a..68ee4f8df1 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2580,10 +2580,10 @@ declare module _ { * @param options.trailing Specify execution on the trailing edge of the timeout. * @return The new debounced function. **/ - debounce( - func: Function, + debounce( + func: T, wait: number, - options?: DebounceSettings): Function; + options?: DebounceSettings): T; } interface LoDashObjectWrapper { @@ -2670,9 +2670,9 @@ declare module _ { * @param resolver Hash function for storing the result of `fn`. * @return Returns the new memoizing function. **/ - memoize( - func: Function, - resolver?: (n: any) => string): Function; + memoize( + func: T, + resolver?: (n: any) => string): T; } //_.once @@ -2684,7 +2684,7 @@ declare module _ { * @param func Function to only execute once. * @return The new restricted function. **/ - once(func: Function): Function; + once(func: T): T; } //_.partial @@ -2733,10 +2733,10 @@ declare module _ { * @param options.trailing Specify execution on the trailing edge of the timeout. * @return The new throttled function. **/ - throttle( - func: any, + throttle( + func: T, wait: number, - options?: ThrottleSettings): Function; + options?: ThrottleSettings): T; } interface ThrottleSettings { @@ -3764,7 +3764,7 @@ declare module _ { **/ times( n: number, - callback: Function, + callback: (num: number) => TResult, context?: any): TResult[]; } From 53a5613482ae9c7d384dc7cc1e691bc4778ae66c Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Sat, 18 Jan 2014 23:13:39 -0500 Subject: [PATCH 007/240] (feat): Updated function methods to be generic This allows those method signatures to be passed through, but gain the benefits of things like throttle, memoize. --- lodash/lodash-tests.disabled.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lodash/lodash-tests.disabled.ts b/lodash/lodash-tests.disabled.ts index 18c3cadd6f..aca0bbdf0b 100644 --- a/lodash/lodash-tests.disabled.ts +++ b/lodash/lodash-tests.disabled.ts @@ -592,6 +592,9 @@ source.addEventListener('message', <_.LoDashObjectWrapper>_(function() 'maxWait': 1000 }), false); +var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5); +returnedThrottled(4); + result = _.defer(function() { console.log('deferred'); }); result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); @@ -608,15 +611,20 @@ var data = { 'curly': { 'name': 'curly', 'age': 60 } }; -var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); +var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); stooge('curly'); stooge['cache']['curly'].name = 'jerome'; stooge('curly'); -var initialize = _.once(function(){ }); -initialize(); +var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5); +returnedMemoize(4); + +var initialize = _.once(function(){ }); initialize(); +initialize();'' +var returnedOnce = _.throttle(function (a) { return a * 5; }, 5); +returnedOnce(4); var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; }; var hi = _.partial(greetPartial, 'hi'); @@ -638,6 +646,9 @@ jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { 'trailing': false })); +var returnedThrottled = _.throttle(function (a) { return a*5; }, 5); +returnedThrottled(4); + var helloWrap = function(name: string) { return 'hello ' + name; }; var helloWrap2 = _.wrap(helloWrap, function(func) { return 'before, ' + func('moe') + ', after'; @@ -950,9 +961,9 @@ class Mage { } var mage = new Mage(); -result = _.times(3, _.partial(_.random, 1, 6)); -result = _.times(3, function(n: number) { mage.castSpell(n); }); -result = _.times(3, function(n: number) { this.cast(n); }, mage); +result = _.times(3, <() => number>_.partial(_.random, 1, 6)); +result = _.times(3, function(n: number) { mage.castSpell(n); }); +result = _.times(3, function(n: number) { this.cast(n); }, mage); result = _.unescape('Moe, Larry & Curly'); From ed8f9cbc42e84c76db3903afef6afe37b349b28a Mon Sep 17 00:00:00 2001 From: s_kimura Date: Sun, 19 Jan 2014 17:10:31 +0900 Subject: [PATCH 008/240] update to SoundJS v0.5.2. --- soundjs/soundjs.d.ts | 57 ++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index d51100279b..922d116675 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SoundJS 0.5.0 +// Type definitions for SoundJS 0.5.2 // Project: http://www.createjs.com/#!/SoundJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -19,45 +19,29 @@ declare module createjs { constructor(); // properties - static BASE_PATH: string; static buildDate: string; - static capabilities: Object; flashReady: boolean; showOutput: boolean; + static swfPath: string; static version: string; // methods create(src: string): SoundInstance; - flashLog(data: string): void; getVolume(): number; - handleErrorEvent(error: string): void; - handleEvent(method: string): void; - handlePreloadEvent(flashId: string, method: string): void; - handleSoundEvent(flashId: string, method: string): void; isPreloadStarted(src: string): boolean; static isSupported(): boolean; - preload(src: string, instance: Object, basePath: string): void; + preload(src: string, instance: Object): void; register(src: string, instances: number): Object; - registerPreloadInstance(flashId: string, instance: any): void; - registerSoundInstance(flashId: string, instance: any): void; removeAllSounds (): void; removeSound(src: string): void; setMute(value: boolean): boolean; setVolume(value: number): boolean; - unregisterPreloadInstance(flashId: string): void; - unregisterSoundInstance(flashId: string, instance: any): void; - toString(): string; } export class HTMLAudioPlugin { constructor(); // properties - static AUDIO_ENDED: string; - static AUDIO_ERROR: string; - static AUDIO_READY: string; - static AUDIO_SEEKED: string; - static AUDIO_STALLED: string; defaultNumChannels: number; enableIOS: boolean; static MAX_INSTANCES: number; @@ -66,18 +50,17 @@ declare module createjs { create(src: string): SoundInstance; isPreloadStarted(src: string): boolean; static isSupported(): boolean; - preload(src: string, instance: Object, basePath: string): void; + preload(src: string, instance: Object): void; register(src: string, instances: number): Object; removeAllSounds(): void; removeSound(src: string): void; - toString(): string; } export class Sound { // properties static activePlugin: Object; + static alternateExtensions: any[]; static defaultInterruptBehavior: string; - static DELIMITER: string; static EXTENSION_MAP: Object; static INTERRUPT_ANY: string; static INTERRUPT_EARLY: string; @@ -102,18 +85,18 @@ declare module createjs { static loadComplete(src: string): boolean; static play(src: string, interrupt?: any, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number): SoundInstance; static registerManifest(manifest: any[], basePath: string): Object; - static registerPlugin(plugin: Object): boolean; static registerPlugins(plugins: any[]): boolean; + static registerSound(src: string, id?: string, data?: number, preload?: boolean, basePath?: string): Object; static registerSound(src: string, id?: string, data?: Object, preload?: boolean, basePath?: string): Object; + static registerSound(src: Object, id?: string, data?: number, preload?: boolean, basePath?: string): Object; static registerSound(src: Object, id?: string, data?: Object, preload?: boolean, basePath?: string): Object; static removeAllSounds(): void; - static removeManifest(manifest: any[]): Object; - static removeSound(src: string): boolean; - static removeSound(src: Object): boolean; + static removeManifest(manifest: any[], basePath: string): Object; + static removeSound(src: string, basePath: string): boolean; + static removeSound(src: Object, basePath: string): boolean; static setMute(value: boolean): boolean; static setVolume(value: number): void; static stop(): void; - static toString(): string; // EventDispatcher mixins static addEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function; @@ -128,16 +111,19 @@ declare module createjs { static off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; static off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; static off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; - static on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function; - static on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function; - static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object; - static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object; + static off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" + static on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + static on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; + static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; static removeAllEventListeners(type?: string): void; static removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void; static removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; - + static removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" + static toString(): string; + static willTrigger(type: string): boolean; } export class SoundInstance extends EventDispatcher { @@ -149,6 +135,7 @@ declare module createjs { panNode: any; playState: string; sourceNode: any; + src: string; uniqueId: any; //HERE string or number volume: number; @@ -191,15 +178,11 @@ declare module createjs { isPreloadStarted(src: string): boolean; static isSupported(): boolean; playEmptySound(): void; + preload(src: string, instance: Object): void; register(src: string, instances: number): Object; removeAllSounds(src: string): void; - /** - * @deprecated - */ - removeFromPreload(src: string): void; removeSound(src: string): void; setMute(value: boolean): boolean; setVolume(value: number): boolean; - toString(): string; } } From 284d2d2fcef4539a4635824f3c7108db4a7cbcd7 Mon Sep 17 00:00:00 2001 From: s_kimura Date: Sun, 19 Jan 2014 17:11:44 +0900 Subject: [PATCH 009/240] update to PreloadJS v0.4.1. --- preloadjs/preloadjs.d.ts | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/preloadjs/preloadjs.d.ts b/preloadjs/preloadjs.d.ts index 418103b54b..f5904fa8c7 100644 --- a/preloadjs/preloadjs.d.ts +++ b/preloadjs/preloadjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for PreloadJS 0.4.0 +// Type definitions for PreloadJS 0.4.1 // Project: http://www.createjs.com/#!/PreloadJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -22,16 +22,15 @@ declare module createjs { progress: number; // methods - buildPath(src: string, basePath?: string, data?: Object): string; + buildPath(src: string, data?: Object): string; close(): void; load(): void; - toString(): string; - } export class LoadQueue extends AbstractLoader { - constructor(useXHR?: boolean, basePath?: string); - + constructor(useXHR?: boolean, basePath?: string, crossOrigin?: string); + constructor(useXHR?: boolean, basePath?: string, crossOrigin?: boolean); + // properties static BINARY: string; static CSS: string; @@ -39,8 +38,9 @@ declare module createjs { static JAVASCRIPT: string; static JSON: string; static JSONP: string; - static LOAD_TIMEOUT: number; + static loadTimeout: number; maintainScriptOrder: boolean; + static MANIFEST: string; next: LoadQueue; static SOUND: string; stopOnError: boolean; @@ -55,8 +55,9 @@ declare module createjs { installPlugin(plugin: any): void; loadFile(file: Object, loadNow?: boolean, basePath?: string): void; loadFile(file: string, loadNow?: boolean, basePath?: string): void; - loadManifest(manifest: Object[], loadNow?: boolean, basePath?: string): void; - loadManifest(manifest: string[], loadNow?: boolean, basePath?: string): void; + loadManifest(manifest: Object, loadNow?: boolean, basePath?: string): void; + loadManifest(manifest: string, loadNow?: boolean, basePath?: string): void; + loadManifest(manifest: any[], loadNow?: boolean, basePath?: string): void; remove(idsOrUrls: string): void; remove(idsOrUrls: any[]): void; removeAll(): void; @@ -71,18 +72,21 @@ declare module createjs { static version: string; } + export class SamplePlugin { + static fileLoadHandler(event: Object): void; + static getPreloadHandlers(): Object; + static preloadHandler(src: string, type: string, id: string, data: any, basePath: string, queue: LoadQueue): any; + } + export class TagLoader extends AbstractLoader { constructor (item: Object); - // properties - _isAudio: boolean; - // methods getResult(): any; } export class XHRLoader extends AbstractLoader { - constructor (item: Object); + constructor (item: Object, crossOrigin?: string); // methods getAllResponseHeaders(): string; From 380322af6bcb943ce7248ef84b3dec2444f6df38 Mon Sep 17 00:00:00 2001 From: s_kimura Date: Sun, 19 Jan 2014 17:05:53 +0900 Subject: [PATCH 010/240] update to EaselJS v0.7.1. --- createjs/createjs.d.ts | 27 +++++---- easeljs/easeljs-tests.ts | 12 ++++ easeljs/easeljs.d.ts | 121 +++++++++++++++++++-------------------- 3 files changed, 86 insertions(+), 74 deletions(-) diff --git a/createjs/createjs.d.ts b/createjs/createjs.d.ts index 20f2a7574f..556a330258 100644 --- a/createjs/createjs.d.ts +++ b/createjs/createjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for EaselJS 0.7.0, TweenJS 0.5.0, SoundJS 0.5.0, PreloadJS 0.4.0 +// Type definitions for EaselJS 0.7.1, TweenJS 0.5.1, SoundJS 0.5.2, PreloadJS 0.4.1 // Project: http://www.createjs.com/#!/EaselJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -23,13 +23,13 @@ declare module createjs { // properties bubbles: boolean; cancelable: boolean; - currentTarget: Object; + currentTarget: any; // It is 'Object' type officially, but 'any' is easier to use. defaultPrevented: boolean; eventPhase: number; immediatePropagationStopped: boolean; propagationStopped: boolean; removed: boolean; - target: Object; + target: any; // It is 'Object' type officially, but 'any' is easier to use. timeStamp: number; type: string; @@ -38,15 +38,15 @@ declare module createjs { delta: number; error: string; id: string; - item: any; - loaded: number; + item: any; + loaded: number; name: string; next: string; - params: any[]; + params: any; paused: boolean; progress: number; - rawResult: Object; - result: Object; + rawResult: any; + result: any; runTime: number; src: string; time: number; @@ -78,16 +78,19 @@ declare module createjs { off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; - on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function; - on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function; - on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object; - on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object; + off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" + on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; + on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; removeAllEventListeners(type?: string): void; removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void; removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" toString(): string; + willTrigger(type: string): boolean; } export function indexOf(array: any[], searchElement: Object): number; diff --git a/easeljs/easeljs-tests.ts b/easeljs/easeljs-tests.ts index 6c083da5cd..ff68b79d65 100644 --- a/easeljs/easeljs-tests.ts +++ b/easeljs/easeljs-tests.ts @@ -53,4 +53,16 @@ function test_graphics() { var myGraphics: createjs.Graphics; myGraphics.beginStroke("#F00").beginFill("#00F").drawRect(20, 20, 100, 50).draw(myContext2D); +} + +function colorMatrixTest() { + var shape = new createjs.Shape().set({ x: 100, y: 100 }); + shape.graphics.beginFill("#ff0000").drawCircle(0, 0, 50); + + var matrix = new createjs.ColorMatrix().adjustHue(180).adjustSaturation(100); + shape.filters = [ + new createjs.ColorMatrixFilter(matrix) + ]; + + shape.cache(-50, -50, 100, 100); } \ No newline at end of file diff --git a/easeljs/easeljs.d.ts b/easeljs/easeljs.d.ts index dd15630832..2c5be3aa34 100644 --- a/easeljs/easeljs.d.ts +++ b/easeljs/easeljs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for EaselJS 0.7.0 +// Type definitions for EaselJS 0.7.1 // Project: http://www.createjs.com/#!/EaselJS // Definitions by: Pedro Ferreira , Chris Smith // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -55,6 +55,8 @@ declare module createjs { // methods clone(): Bitmap; + set(props: Object): Bitmap; + setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Bitmap; } /** @@ -73,6 +75,9 @@ declare module createjs { spriteSheet: SpriteSheet; text: string; + // methods + set(props: Object): BitmapText; + setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): BitmapText; } export class BlurFilter extends Filter { @@ -120,12 +125,8 @@ declare module createjs { clone(): ColorFilter; } - export class ColorMatrix implements Array { - constructor(brightness: number, contrast: number, saturation: number, hue: number); - - static DELTA_INDEX: number[]; - static IDENTITY_MATRIX: number[]; - static LENGTH: number; + export class ColorMatrix { + constructor(brightness?: number, contrast?: number, saturation?: number, hue?: number); // methods adjustBrightness(value: number): ColorMatrix; @@ -135,41 +136,17 @@ declare module createjs { adjustSaturation(value: number): ColorMatrix; clone(): ColorMatrix; concat(...matrix: number[]): ColorMatrix; - copyMatrix(...matrix: ColorMatrix[]): ColorMatrix; + concat(matrix: ColorMatrix): ColorMatrix; + copyMatrix(...matrix: number[]): ColorMatrix; + copyMatrix(matrix: ColorMatrix): ColorMatrix; reset(): ColorMatrix; toArray(): number[]; - - // implements Array interface start - concat(...items: ColorMatrix[]): number[]; - join(separator?: string): string; - pop(): number; - push(...items: number[]): number; - reverse(): number[]; - shift(): number; - slice(start: number, end?: number): number[]; - sort(compareFn?: (a: number, b: number) => number): number[]; - splice(start: number): number[]; - unshift(...items: number[]): number; - indexOf(searchElement: number, fromIndex?: number): number; - - lastIndexOf(searchElement: number, fromIndex?: number): number; - every(callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any): boolean; - some(callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any): boolean; - forEach(callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any): void; - map(callbackfn: (value: number, index: number, array: number[]) => ColorMatrix, thisArg?: any): ColorMatrix[]; - - filter(callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any): number[]; - reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue?: number): number; - reduce(callbackfn: (previousValue: ColorMatrix, currentValue: number, currentIndex: number, array: number[]) => ColorMatrix, initialValue: ColorMatrix): ColorMatrix; - reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue?: number): number; - reduceRight(callbackfn: (previousValue: ColorMatrix, currentValue: number, currentIndex: number, array: number[]) => ColorMatrix, initialValue: ColorMatrix): ColorMatrix; - length: number; - [n: number]: number; - // implements Array interface end + toString(): string; } export class ColorMatrixFilter extends Filter { constructor(matrix: number[]); + constructor(matrix: ColorMatrix); // methods clone(): ColorMatrixFilter; @@ -177,7 +154,7 @@ declare module createjs { export class Command { // methods - constructor(f: any, params: any, path: any); + constructor(f: any, params: any, path?: any); exec(scope: any): void; } @@ -187,6 +164,7 @@ declare module createjs { // properties children: DisplayObject[]; mouseChildren: boolean; + tickChildren: boolean; // methods addChild(...child: DisplayObject[]): DisplayObject; @@ -203,7 +181,9 @@ declare module createjs { removeAllChildren(): void; removeChild(...child: DisplayObject[]): boolean; removeChildAt(...index: number[]): boolean; + set(props: Object): Container; setChildIndex(child: DisplayObject, index: number): void; + setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Container; sortChildren(sortFunction: (a: DisplayObject, b: DisplayObject) => number): void; swapChildren(child1: DisplayObject, child2: DisplayObject): void; swapChildrenAt(index1: number, index2: number): void; @@ -214,7 +194,7 @@ declare module createjs { // properties alpha: number; - cacheCanvas: HTMLCanvasElement; // HTMLCanvasElement or Object + cacheCanvas: any; // HTMLCanvasElement or Object cacheID: number; compositeOperation: string; cursor: string; @@ -238,6 +218,7 @@ declare module createjs { */ snapToPixel: boolean; static suppressCrossDomainErrors: boolean; + tickEnabled: boolean; visible: boolean; x: number; y: number; @@ -274,7 +255,8 @@ declare module createjs { // methods clone(): DisplayObject; // throw error - + set(props: Object): DOMElement; + setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): DOMElement; } @@ -425,6 +407,8 @@ declare module createjs { constructor(type: string, bubbles: boolean, cancelable: boolean, stageX: number, stageY: number, nativeEvent: NativeMouseEvent, pointerID: number, primary: boolean, rawX: number, rawY: number); // properties + localX: number; + localY: number; nativeEvent: NativeMouseEvent; pointerID: number; primary: boolean; @@ -432,7 +416,6 @@ declare module createjs { rawY: number; stageX: number; stageY: number; - target: DisplayObject; // methods clone(): MouseEvent; @@ -442,23 +425,27 @@ declare module createjs { addEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function; addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object; addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object; - on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function; - on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function; - on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object; - on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object; - removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void; - removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; - removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; - removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; + dispatchEvent(eventObj: Object, target?: Object): boolean; + dispatchEvent(eventObj: string, target?: Object): boolean; + dispatchEvent(eventObj: Event, target?: Object): boolean; + hasEventListener(type: string): boolean; off(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void; off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; + off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" + on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; + on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; removeAllEventListeners(type?: string): void; - dispatchEvent(eventObj: string, target?: Object): boolean; - dispatchEvent(eventObj: Object, target?: Object): boolean; - dispatchEvent(eventObj: Event, target?: Object): boolean; - hasEventListener(type: string): boolean; + removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void; + removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; + removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; + removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" + toString(): string; + willTrigger(type: string): boolean; } @@ -555,6 +542,8 @@ declare module createjs { // methods clone(recursive?: boolean): Shape; + set(props: Object): Shape; + setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Shape; } @@ -583,6 +572,8 @@ declare module createjs { gotoAndStop(frameOrAnimation: string): void; gotoAndStop(frameOrAnimation: number): void; play(): void; + set(props: Object): Sprite; + setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Sprite; stop(): void; } @@ -619,6 +610,8 @@ declare module createjs { export class SpriteSheetBuilder extends EventDispatcher { + constructor(); + // properties maxHeight: number; maxWidth: number; @@ -634,9 +627,9 @@ declare module createjs { addMovieClip(source: MovieClip, sourceRect?: Rectangle, scale?: number): void; build(): SpriteSheet; buildAsync(timeSlice?: number): void; - clone(): DisplayObject; // throw error + clone(): void; // throw error stopAsync(): void; - toString(): string; + } @@ -660,7 +653,8 @@ declare module createjs { // properties autoClear: boolean; - canvas: HTMLCanvasElement; + canvas: any; // HTMLCanvasElement or Object + handleEvent: Function; mouseInBounds: boolean; mouseMoveOutside: boolean; mouseX: number; @@ -677,7 +671,6 @@ declare module createjs { clone(): Stage; enableDOMEvents(enable?: boolean): void; enableMouseOver(frequency?: number): void; - handleEvent(evt: Object): void; toDataURL(backgroundColor: string, mimeType: string): string; update(...arg: any[]): void; @@ -703,6 +696,8 @@ declare module createjs { getMeasuredHeight(): number; getMeasuredLineHeight(): number; getMeasuredWidth(): number; + set(props: Object): Text; + setTransform(x?: number, y?: number, scaleX?: number, scaleY?: number, rotation?: number, skewX?: number, skewY?: number, regX?: number, regY?: number): Text; } export class Ticker { @@ -731,7 +726,6 @@ declare module createjs { static setFPS(value: number): void; static setInterval(interval: number): void; static setPaused(value: boolean): void; - static toString(): string; // EventDispatcher mixins static addEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function; @@ -746,16 +740,19 @@ declare module createjs { static off(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; static off(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; static off(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; - static on(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): Function; - static on(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): Function; - static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): Object; - static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): Object; + static off(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" + static on(type: string, listener: (eventObj: Object) => boolean, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + static on(type: string, listener: (eventObj: Object) => void, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Function; + static on(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; + static on(type: string, listener: { handleEvent: (eventObj: Object) => void; }, scope?: Object, once?: boolean, data?: any, useCapture?: boolean): Object; static removeAllEventListeners(type?: string): void; static removeEventListener(type: string, listener: (eventObj: Object) => boolean, useCapture?: boolean): void; static removeEventListener(type: string, listener: (eventObj: Object) => void, useCapture?: boolean): void; static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => boolean; }, useCapture?: boolean): void; static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }, useCapture?: boolean): void; - + static removeEventListener(type: string, listener: Function, useCapture?: boolean): void; // It is necessary for "arguments.callee" + static toString(): string; + static willTrigger(type: string): boolean; } export class TickerEvent { From 6731a49e0447172b1f3ed15fdcec2893e5adac08 Mon Sep 17 00:00:00 2001 From: s_kimura Date: Sun, 19 Jan 2014 17:08:33 +0900 Subject: [PATCH 011/240] update to TweenJS v0.5.1. --- tweenjs/tweenjs.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tweenjs/tweenjs.d.ts b/tweenjs/tweenjs.d.ts index d7896d3491..a53dd8e209 100644 --- a/tweenjs/tweenjs.d.ts +++ b/tweenjs/tweenjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for TweenJS 0.5.0 +// Type definitions for TweenJS 0.5.1 // Project: http://www.createjs.com/#!/TweenJS // Definitions by: Pedro Ferreira , Chris Smith // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -82,7 +82,7 @@ declare module createjs { static priority: any; //methods - static init(tween: Tween, prop: string, value: any): any; + static init(tween: Tween, prop: string, value: any): any; static step(tween: Tween, prop: string, startValue: any, injectProps: Object, endValue: any): void; static install(): void; static tween(tween: Tween, prop: string, value: any, startValues: Object, endValues: Object, ratio: number, wait: boolean, end: boolean): any; @@ -100,8 +100,8 @@ declare module createjs { // methods addLabel(label: string, position: number): void; addTween(...tween: Tween[]): void; - getCurrentLabel(): string; - getLabels(): Object[]; + getCurrentLabel(): string; + getLabels(): Object[]; gotoAndPlay(positionOrLabel: string): void; gotoAndPlay(positionOrLabel: number): void; gotoAndStop(positionOrLabel: string): void; @@ -148,6 +148,7 @@ declare module createjs { setPaused(value: boolean): Tween; setPosition(value: number, actionsMode: number): boolean; static tick(delta: number, paused: boolean): void; + tick(delta: number, paused: boolean): void; tick(delta: number): void; to(props: Object, duration?: number, ease?: (t: number) => number): Tween; wait(duration: number, passive?: boolean): Tween; From fbe21d3831c2056daa839d0c1efa62e322264b11 Mon Sep 17 00:00:00 2001 From: Andrey Kurdyumov Date: Sun, 19 Jan 2014 03:53:13 -0800 Subject: [PATCH 012/240] Update declaration of the Device interface The current version of interface for Device plugin is contains property available. See in the current version. https://github.com/apache/cordova-plugin-device/blob/master/www/device.js --- phonegap/phonegap.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/phonegap/phonegap.d.ts b/phonegap/phonegap.d.ts index f23b473a92..01935142ee 100644 --- a/phonegap/phonegap.d.ts +++ b/phonegap/phonegap.d.ts @@ -257,6 +257,7 @@ interface Contacts { } interface Device { + available: boolean; name: string; cordova: string; platform: string; From 8eacc4ca146c46813642d61a6e4ab94ba4c2bcd8 Mon Sep 17 00:00:00 2001 From: Andrey Kurdyumov Date: Sun, 19 Jan 2014 06:56:23 -0800 Subject: [PATCH 013/240] Added property for query string parameters Property qs for SignalR connection could be used to pass additional parameters to new SignalR persistent/hub connections. It is available since 1.0 and is present in 2.0 version of SignalR --- signalr/signalr.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index 70b03c4ec8..7d1e64b742 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -36,6 +36,7 @@ interface SignalR { logging: boolean; messageId: string; url: string; + qs: any; (url: string, queryString?: any, logging?: boolean): SignalR; hubConnection(url?: string): SignalR; From 351b06d30057560ba25a13fbdde3742da39c81a5 Mon Sep 17 00:00:00 2001 From: s_kimura Date: Mon, 20 Jan 2014 09:40:38 +0900 Subject: [PATCH 014/240] append the author's name in the definition file. --- createjs/createjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/createjs/createjs.d.ts b/createjs/createjs.d.ts index 556a330258..3ebfd11bf5 100644 --- a/createjs/createjs.d.ts +++ b/createjs/createjs.d.ts @@ -1,6 +1,6 @@ // Type definitions for EaselJS 0.7.1, TweenJS 0.5.1, SoundJS 0.5.2, PreloadJS 0.4.1 // Project: http://www.createjs.com/#!/EaselJS -// Definitions by: Pedro Ferreira +// Definitions by: Pedro Ferreira , Chris Smith , Satoru Kimura // Definitions: https://github.com/borisyankov/DefinitelyTyped /* From 80dd267cc2b5bc092cc45f9781e5a32134f915bd Mon Sep 17 00:00:00 2001 From: "T.J. Lawrence" Date: Sun, 19 Jan 2014 23:48:11 -0700 Subject: [PATCH 015/240] Fixed some typings with the chain syntax --- underscore/underscore-tests.ts | 36 ++++++++++++++------------ underscore/underscore.d.ts | 47 ++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 30 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index ae5ab6f7ee..ae641fde52 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -283,24 +283,28 @@ _(['test', 'test']).pick(['test2', 'test2']); //////////////// Chain Tests function chain_tests() { // https://typescript.codeplex.com/workitem/1960 - var list:number[] = _.chain([1, 2, 3, 4, 5, 6, 7, 8]) - .filter(n => n % 2 == 0) - .map(n => n * n) - .value(); - - _([1, 2, 3, 4]) - .chain() - .filter((num: number) => { - return num % 2 == 0; - }).tap(alert) - .map((num: number) => { - return num * num; - }) + var numArray: number[] = _.chain([1, 2, 3, 4, 5, 6, 7, 8]) + .filter(num => num % 2 == 0) + .map(num => num * num) .value(); - _.chain([1, 2, 3, 200]) - .filter(function (num: number) { return num % 2 == 0; }) + var strArray: string[] = _([1, 2, 3, 4]) + .chain() + .filter(num => num % 2 == 0) .tap(alert) - .map(function (num: number) { return num * num }) + .map(num => "string" + num) + .value(); + + var n : number = _.chain([1, 2, 3, 200]) + .filter(num => num % 2 == 0) + .tap(alert) + .map(num => num * num) + .max() + .value(); + + var t2 : number = _([1, 2, 3]).chain() + .map(num=> [num, num + 1]) + .flatten() + .find(num => num % 2 == 0) .value(); } diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 4382f7bea7..53bbdffa4e 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1364,7 +1364,8 @@ interface UnderscoreStatic { * @param obj Object to chain. * @return Wrapped `obj`. **/ - chain(obj: any): _Chain; + chain(obj: T[]): _Chain; + chain(obj: T): _Chain; /** * Extracts the value of a wrapped object. @@ -2194,13 +2195,25 @@ interface _Chain { * Wrapped type `any[]`. * @see _.map **/ - map(iterator: _.ListIterator, context?: any): _Chain; + map(iterator: (value: T, index: number, list: T[]) => TArray[], context?: any): _ChainOfArrays; + //Not sure why this won't work, might be a TypeScript error? map(iterator: _.ListIterator, context?: any): _ChainOfArrays; + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ListIterator, context?: any): _Chain; /** * Wrapped type `any[]`. * @see _.map **/ - map(iterator: _.ObjectIterator, context?: any): _Chain; + map(iterator: (element: T, key: string, list: any) => TArray[], context?: any): _ChainOfArrays; + //Not sure why this won't work, might be a TypeScript error? //map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ObjectIterator, context?: any): _Chain; /** * @see _.map @@ -2243,7 +2256,7 @@ interface _Chain { * Wrapped type `any[]`. * @see _.find **/ - find(iterator: _.ListIterator, context?: any): _Chain; + find(iterator: _.ListIterator, context?: any): _ChainSingle; /** * @see _.find @@ -2271,7 +2284,7 @@ interface _Chain { * Wrapped type `any[]`. * @see _.findWhere **/ - findWhere(properties: U): _Chain; + findWhere(properties: U): _ChainSingle; /** * Wrapped type `any[]`. @@ -2323,43 +2336,43 @@ interface _Chain { * Wrapped type `any[]`. * @see _.pluck **/ - pluck(propertyName: string): _Chain; + pluck(propertyName: string): _Chain; /** * Wrapped type `number[]`. * @see _.max **/ - max(): _Chain; + max(): _ChainSingle; /** * Wrapped type `any[]`. * @see _.max **/ - max(iterator: _.ListIterator, context?: any): _Chain; + max(iterator: _.ListIterator, context?: any): _ChainSingle; /** * Wrapped type `any[]`. * @see _.max **/ - max(iterator?: _.ListIterator, context?: any): _Chain; + max(iterator?: _.ListIterator, context?: any): _ChainSingle; /** * Wrapped type `number[]`. * @see _.min **/ - min(): _Chain; + min(): _ChainSingle; /** * Wrapped type `any[]`. * @see _.min **/ - min(iterator: _.ListIterator, context?: any): _Chain; + min(iterator: _.ListIterator, context?: any): _ChainSingle; /** * Wrapped type `any[]`. * @see _.min **/ - min(iterator?: _.ListIterator, context?: any): _Chain; + min(iterator?: _.ListIterator, context?: any): _ChainSingle; /** * Wrapped type `any[]`. @@ -2518,7 +2531,7 @@ interface _Chain { * Wrapped type `any`. * @see _.flatten **/ - flatten(shallow?: boolean): _Chain; + flatten(shallow?: boolean): _Chain; /** * Wrapped type `any[]`. @@ -2947,7 +2960,13 @@ interface _Chain { * Wrapped type `any`. * @see _.value **/ - value(): TResult; + value(): T[]; +} +interface _ChainSingle { + value(): T; +} +interface _ChainOfArrays extends _Chain { + flatten(): _Chain; } declare var _: UnderscoreStatic; From 7172a17c261d11398945bd94fd53923266f6fd02 Mon Sep 17 00:00:00 2001 From: "T.J. Lawrence" Date: Mon, 20 Jan 2014 08:26:08 -0700 Subject: [PATCH 016/240] Underscore: Used tabs vs spaces for my additions and added explanation in test --- underscore/underscore-tests.ts | 44 +++--- underscore/underscore.d.ts | 252 +++++++++++++++++---------------- 2 files changed, 151 insertions(+), 145 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index ae641fde52..7b5ee0504e 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -283,28 +283,30 @@ _(['test', 'test']).pick(['test2', 'test2']); //////////////// Chain Tests function chain_tests() { // https://typescript.codeplex.com/workitem/1960 - var numArray: number[] = _.chain([1, 2, 3, 4, 5, 6, 7, 8]) - .filter(num => num % 2 == 0) - .map(num => num * num) - .value(); + var numArray: number[] = _.chain([1, 2, 3, 4, 5, 6, 7, 8]) + .filter(num => num % 2 == 0) + .map(num => num * num) + .value(); - var strArray: string[] = _([1, 2, 3, 4]) - .chain() - .filter(num => num % 2 == 0) - .tap(alert) - .map(num => "string" + num) - .value(); + var strArray: string[] = _([1, 2, 3, 4]) + .chain() + .filter(num => num % 2 == 0) + .tap(alert) + .map(num => "string" + num) + .value(); - var n : number = _.chain([1, 2, 3, 200]) - .filter(num => num % 2 == 0) - .tap(alert) - .map(num => num * num) - .max() - .value(); + var n : number = _.chain([1, 2, 3, 200]) + .filter(num => num % 2 == 0) + .tap(alert) + .map(num => num * num) + .max() + .value(); - var t2 : number = _([1, 2, 3]).chain() - .map(num=> [num, num + 1]) - .flatten() - .find(num => num % 2 == 0) - .value(); + //If using alternate definition of map (~ line 2200), .value returns any + // because.map matches _Chain as opposed to _ChainOfArrays , which breaks typing on flatten + var hoverOverValueShouldBeNumberNotAny : number = _([1, 2, 3]).chain() + .map(num=> [num, num + 1]) + .flatten() + .find(num => num % 2 == 0) + .value(); } diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 53bbdffa4e..121aa644e6 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -6,66 +6,66 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module _ { - /** - * underscore.js _.throttle options. - **/ - interface ThrottleSettings { + /** + * underscore.js _.throttle options. + **/ + interface ThrottleSettings { - /** - * If you'd like to disable the leading-edge call, pass this as false. - **/ - leading?: boolean; + /** + * If you'd like to disable the leading-edge call, pass this as false. + **/ + leading?: boolean; - /** - * If you'd like to disable the execution on the trailing-edge, pass false. - **/ - trailing?: boolean; - } + /** + * If you'd like to disable the execution on the trailing-edge, pass false. + **/ + trailing?: boolean; + } - /** - * underscore.js template settings, set templateSettings or pass as an argument - * to 'template()' to overide defaults. - **/ - interface TemplateSettings { - /** - * Default value is '/<%([\s\S]+?)%>/g'. - **/ - evaluate?: RegExp; + /** + * underscore.js template settings, set templateSettings or pass as an argument + * to 'template()' to overide defaults. + **/ + interface TemplateSettings { + /** + * Default value is '/<%([\s\S]+?)%>/g'. + **/ + evaluate?: RegExp; - /** - * Default value is '/<%=([\s\S]+?)%>/g'. - **/ - interpolate?: RegExp; + /** + * Default value is '/<%=([\s\S]+?)%>/g'. + **/ + interpolate?: RegExp; - /** - * Default value is '/<%-([\s\S]+?)%>/g'. - **/ - escape?: RegExp; - } + /** + * Default value is '/<%-([\s\S]+?)%>/g'. + **/ + escape?: RegExp; + } - interface ListIterator { - (value: T, index: number, list: T[]): TResult; - } + interface ListIterator { + (value: T, index: number, list: T[]): TResult; + } - interface ObjectIterator { - (element: T, key: string, list: any): TResult; - } + interface ObjectIterator { + (element: T, key: string, list: any): TResult; + } - interface MemoIterator { - (prev: TResult, curr: T, index: number, list: T[]): TResult; - } + interface MemoIterator { + (prev: TResult, curr: T, index: number, list: T[]): TResult; + } - interface Collection { } + interface Collection { } - // Common interface between Arrays and jQuery objects - interface List extends Collection { - [index: number]: T; - length: number; - } + // Common interface between Arrays and jQuery objects + interface List extends Collection { + [index: number]: T; + length: number; + } - interface Dictionary extends Collection { - [index: string]: T; - } + interface Dictionary extends Collection { + [index: string]: T; + } } interface UnderscoreStatic { @@ -74,10 +74,10 @@ interface UnderscoreStatic { * as the first parameter can be invoked through this function. * @param key First argument to Underscore object functions. **/ - (value: Array): Underscore; - (value: T): Underscore; + (value: Array): Underscore; + (value: T): Underscore; - /* ************* + /* ************* * Collections * ************* */ @@ -285,7 +285,7 @@ interface UnderscoreStatic { * @return The first element in `list` that has all `properties`. **/ findWhere( - list: _.List, + list: _.List, properties: U): T; /** @@ -299,7 +299,7 @@ interface UnderscoreStatic { **/ reject( list: _.Collection, - iterator: _.ListIterator, + iterator: _.ListIterator, context?: any): T[]; /** @@ -312,7 +312,7 @@ interface UnderscoreStatic { **/ every( list: _.Collection, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): boolean; /** @@ -320,7 +320,7 @@ interface UnderscoreStatic { **/ all( list: _.Collection, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): boolean; /** @@ -333,7 +333,7 @@ interface UnderscoreStatic { **/ any( list: _.Collection, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): boolean; /** @@ -341,7 +341,7 @@ interface UnderscoreStatic { **/ some( list: _.Collection, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): boolean; /** @@ -390,7 +390,7 @@ interface UnderscoreStatic { * @param list Finds the maximum value in this list. * @return Maximum value in `list`. **/ - max(list: _.List): number; + max(list: _.List): number; /** * Returns the maximum value in list. If iterator is passed, it will be used on each value to generate @@ -402,7 +402,7 @@ interface UnderscoreStatic { **/ max( list: _.Collection, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): T; /** @@ -410,7 +410,7 @@ interface UnderscoreStatic { * @param list Finds the minimum value in this list. * @return Minimum value in `list`. **/ - min(list: _.List): number; + min(list: _.List): number; /** * Returns the minimum value in list. If iterator is passed, it will be used on each value to generate @@ -422,7 +422,7 @@ interface UnderscoreStatic { **/ min( list: _.Collection, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): T; /** @@ -434,8 +434,8 @@ interface UnderscoreStatic { * @return A sorted copy of `list`. **/ sortBy( - list: _.List, - iterator?: _.ListIterator, + list: _.List, + iterator?: _.ListIterator, context?: any): T[]; /** @@ -443,7 +443,7 @@ interface UnderscoreStatic { * @param iterator Sort iterator for each element within `list`. **/ sortBy( - list: _.List, + list: _.List, iterator: string, context?: any): T[]; @@ -457,36 +457,36 @@ interface UnderscoreStatic { * @return An object with the group names as properties where each property contains the grouped elements from `list`. **/ groupBy( - list: _.List, - iterator?: _.ListIterator, - context?: any): _.Dictionary; + list: _.List, + iterator?: _.ListIterator, + context?: any): _.Dictionary; /** * @see _.groupBy * @param iterator Property on each object to group them by. **/ groupBy( - list: _.List, + list: _.List, iterator: string, - context?: any): _.Dictionary; + context?: any): _.Dictionary; /** * Given a `list`, and an `iterator` function that returns a key for each element in the list (or a property name), * returns an object with an index of each item. Just like _.groupBy, but for when you know your keys are unique. **/ indexBy( - list: _.List, - iterator: _.ListIterator, - context?: any): _.Dictionary; + list: _.List, + iterator: _.ListIterator, + context?: any): _.Dictionary; /** * @see _.indexBy * @param iterator Property on each object to index them by. **/ indexBy( - list: _.List, + list: _.List, iterator: string, - context?: any): _.Dictionary; + context?: any): _.Dictionary; /** * Sorts a list into groups and returns a count for the number of objects in each group. Similar @@ -499,8 +499,8 @@ interface UnderscoreStatic { **/ countBy( list: _.Collection, - iterator?: _.ListIterator, - context?: any): _.Dictionary; + iterator?: _.ListIterator, + context?: any): _.Dictionary; /** * @see _.countBy @@ -509,7 +509,7 @@ interface UnderscoreStatic { countBy( list: _.Collection, iterator: string, - context?: any): _.Dictionary; + context?: any): _.Dictionary; /** * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. @@ -554,38 +554,38 @@ interface UnderscoreStatic { * @param array Retrieves the first element of this array. * @return Returns the first element of `array`. **/ - first(array: _.List): T; + first(array: _.List): T; /** * @see _.first * @param n Return more than one element from `array`. **/ first( - array: _.List, + array: _.List, n: number): T[]; /** * @see _.first **/ - head(array: _.List): T; + head(array: _.List): T; /** * @see _.first **/ head( - array: _.List, + array: _.List, n: number): T[]; /** * @see _.first **/ - take(array: _.List): T; + take(array: _.List): T; /** * @see _.first **/ take( - array: _.List, + array: _.List, n: number): T[]; /** @@ -596,7 +596,7 @@ interface UnderscoreStatic { * @return Returns everything but the last `n` elements of `array`. **/ initial( - array: _.List, + array: _.List, n?: number): T[]; /** @@ -604,14 +604,14 @@ interface UnderscoreStatic { * @param array Retrieves the last element of this array. * @return Returns the last element of `array`. **/ - last(array: _.List): T; + last(array: _.List): T; /** * @see _.last * @param n Return more than one element from `array`. **/ last( - array: _.List, + array: _.List, n: number): T[]; /** @@ -622,21 +622,21 @@ interface UnderscoreStatic { * @return Returns the elements of `array` from `index` to the end of `array`. **/ rest( - array: _.List, + array: _.List, n?: number): T[]; /** * @see _.rest **/ tail( - array: _.List, + array: _.List, n?: number): T[]; /** * @see _.rest **/ drop( - array: _.List, + array: _.List, n?: number): T[]; /** @@ -645,7 +645,7 @@ interface UnderscoreStatic { * @param array Array to compact. * @return Copy of `array` without false values. **/ - compact(array: _.List): T[]; + compact(array: _.List): T[]; /** * Flattens a nested array (the nesting can be to any depth). If you pass shallow, the array will @@ -655,7 +655,7 @@ interface UnderscoreStatic { * @return `array` flattened. **/ flatten( - array: _.List, + array: _.List, shallow?: boolean): any[]; /** @@ -665,7 +665,7 @@ interface UnderscoreStatic { * @return Copy of `array` without `values`. **/ without( - array: _.List, + array: _.List, ...values: T[]): T[]; /** @@ -674,7 +674,7 @@ interface UnderscoreStatic { * @param arrays Array of arrays to compute the union of. * @return The union of elements within `arrays`. **/ - union(...arrays: _.List[]): T[]; + union(...arrays: _.List[]): T[]; /** * Computes the list of values that are the intersection of all the arrays. Each value in the result @@ -682,7 +682,7 @@ interface UnderscoreStatic { * @param arrays Array of arrays to compute the intersection of. * @return The intersection of elements within `arrays`. **/ - intersection(...arrays: _.List[]): T[]; + intersection(...arrays: _.List[]): T[]; /** * Similar to without, but returns the values from array that are not present in the other arrays. @@ -691,8 +691,8 @@ interface UnderscoreStatic { * @return Copy of `array` with only `others` values. **/ difference( - array: _.List, - ...others: _.List[]): T[]; + array: _.List, + ...others: _.List[]): T[]; /** * Produces a duplicate-free version of the array, using === to test object equality. If you know in @@ -705,34 +705,34 @@ interface UnderscoreStatic { * @return Copy of `array` where all elements are unique. **/ uniq( - array: _.List, + array: _.List, isSorted?: boolean, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): T[]; /** * @see _.uniq **/ uniq( - array: _.List, - iterator?: _.ListIterator, + array: _.List, + iterator?: _.ListIterator, context?: any): T[]; /** * @see _.uniq **/ unique( - array: _.List, - iterator?: _.ListIterator, + array: _.List, + iterator?: _.ListIterator, context?: any): T[]; /** * @see _.uniq **/ unique( - array: _.List, + array: _.List, isSorted?: boolean, - iterator?: _.ListIterator, + iterator?: _.ListIterator, context?: any): T[]; @@ -758,8 +758,8 @@ interface UnderscoreStatic { * @return An object containing the `keys` as properties and `values` as the property values. **/ object( - keys: _.List, - values: _.List): TResult; + keys: _.List, + values: _.List): TResult; /** * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a @@ -773,7 +773,7 @@ interface UnderscoreStatic { * @see _.object **/ object( - list: _.List, + list: _.List, values?: any): TResult; /** @@ -787,7 +787,7 @@ interface UnderscoreStatic { * @return The index of `value` within `array`. **/ indexOf( - array: _.List, + array: _.List, value: T, isSorted?: boolean): number; @@ -795,7 +795,7 @@ interface UnderscoreStatic { * @see _indexof **/ indexOf( - array: _.List, + array: _.List, value: T, startFrom: number): number; @@ -808,7 +808,7 @@ interface UnderscoreStatic { * @return The index of the last occurance of `value` within `array`. **/ lastIndexOf( - array: _.List, + array: _.List, value: T, from?: number): number; @@ -822,7 +822,7 @@ interface UnderscoreStatic { * @return The index where `value` should be inserted into `list`. **/ sortedIndex( - list: _.List, + list: _.List, value: T, iterator?: (x: T) => TSort, context?: any): number; @@ -950,7 +950,7 @@ interface UnderscoreStatic { throttle( func: any, wait: number, - options?: _.ThrottleSettings): Function; + options?: _.ThrottleSettings): Function; /** * Creates and returns a new debounced version of the passed function that will postpone its execution @@ -1346,13 +1346,13 @@ interface UnderscoreStatic { * @param settings Settings to use while compiling. * @return Returns the compiled Underscore HTML template. **/ - template(templateString: string, data?: any, settings?: _.TemplateSettings): (...data: any[]) => string; + template(templateString: string, data?: any, settings?: _.TemplateSettings): (...data: any[]) => string; /** * By default, Underscore uses ERB-style template delimiters, change the * following template settings to use alternative delimiters. **/ - templateSettings: _.TemplateSettings; + templateSettings: _.TemplateSettings; /* ********** * Chaining * @@ -1364,8 +1364,8 @@ interface UnderscoreStatic { * @param obj Object to chain. * @return Wrapped `obj`. **/ - chain(obj: T[]): _Chain; - chain(obj: T): _Chain; + chain(obj: T[]): _Chain; + chain(obj: T): _Chain; /** * Extracts the value of a wrapped object. @@ -2195,8 +2195,10 @@ interface _Chain { * Wrapped type `any[]`. * @see _.map **/ - map(iterator: (value: T, index: number, list: T[]) => TArray[], context?: any): _ChainOfArrays; - //Not sure why this won't work, might be a TypeScript error? map(iterator: _.ListIterator, context?: any): _ChainOfArrays; + map(iterator: (value: T, index: number, list: T[]) => TArray[], context?: any): _ChainOfArrays; + //Not sure why this won't work, might be a TypeScript error? + //map(iterator: _.ListIterator, context?: any): _ChainOfArrays; + /** * Wrapped type `any[]`. * @see _.map @@ -2207,8 +2209,10 @@ interface _Chain { * Wrapped type `any[]`. * @see _.map **/ - map(iterator: (element: T, key: string, list: any) => TArray[], context?: any): _ChainOfArrays; - //Not sure why this won't work, might be a TypeScript error? //map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; + map(iterator: (element: T, key: string, list: any) => TArray[], context?: any): _ChainOfArrays; + //Not sure why this won't work, might be a TypeScript error? + //map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; + /** * Wrapped type `any[]`. * @see _.map @@ -2960,13 +2964,13 @@ interface _Chain { * Wrapped type `any`. * @see _.value **/ - value(): T[]; + value(): T[]; } interface _ChainSingle { - value(): T; + value(): T; } interface _ChainOfArrays extends _Chain { - flatten(): _Chain; + flatten(): _Chain; } declare var _: UnderscoreStatic; From 185860602794ae769d94686deb72a25d78cb772f Mon Sep 17 00:00:00 2001 From: Jon Egerton Date: Mon, 20 Jan 2014 16:36:40 +0000 Subject: [PATCH 017/240] Add new "silent" setting to AreYouSureOptions Add new "silent" setting to AreYouSureOptions --- jquery.are-you-sure/jquery.are-you-sure-tests.ts | 3 ++- jquery.are-you-sure/jquery.are-you-sure.d.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.are-you-sure/jquery.are-you-sure-tests.ts b/jquery.are-you-sure/jquery.are-you-sure-tests.ts index 6f8691e05d..89ac4e87a8 100644 --- a/jquery.are-you-sure/jquery.are-you-sure-tests.ts +++ b/jquery.are-you-sure/jquery.are-you-sure-tests.ts @@ -14,5 +14,6 @@ $("test").areYouSure({ message: "Oops - sure you wanna leave?", dirtyClass: "soiled", fieldSelector: "input[type='text']", - change: function () { alert("changed");} + change: function () { alert("changed");}, + silent: true }) \ No newline at end of file diff --git a/jquery.are-you-sure/jquery.are-you-sure.d.ts b/jquery.are-you-sure/jquery.are-you-sure.d.ts index 62cc39c2c8..ea2dc4c7b7 100644 --- a/jquery.are-you-sure/jquery.are-you-sure.d.ts +++ b/jquery.are-you-sure/jquery.are-you-sure.d.ts @@ -19,6 +19,9 @@ interface AreYouSureOptions { /**Jquery selector to use to find input elements*/ fieldSelector?: string; + + /**Make Are-You-Sure "silent" by disabling the warning message*/ + silent: boolean; } interface AreYouSure { From 8166bc0ae34d6b128a2ba0b885a330399f21985e Mon Sep 17 00:00:00 2001 From: Kent Skinner Date: Mon, 20 Jan 2014 11:03:34 -0800 Subject: [PATCH 018/240] Add optional 'message' parameter to chai.expect. As noted at http://chaijs.com/guide/styles/#expect: "Expect also allows you to include arbitrary messages to prepend to any failed assertions that might occur." --- chai/chai.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chai/chai.d.ts b/chai/chai.d.ts index 059e835b84..6774a932fa 100644 --- a/chai/chai.d.ts +++ b/chai/chai.d.ts @@ -6,7 +6,7 @@ declare module chai { - function expect(target: any): Expect; + function expect(target: any, message?: string): Expect; // Provides a way to extend the internals of Chai function use(fn: (chai: any, utils: any) => void); From 7f91e758932a4cc1b396986a83c03e759212ef4c Mon Sep 17 00:00:00 2001 From: craigktreasure Date: Mon, 20 Jan 2014 17:46:56 -0800 Subject: [PATCH 019/240] Full WinJS and WinRT update This contains a complete WinJS type definition with required WinRT type definition update. --- winjs/winjs.d.ts | 8841 ++++++++++++++++++++++++++++++++++++++++++++-- winrt/winrt.d.ts | 92 +- 2 files changed, 8594 insertions(+), 339 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 99a5e33c2b..070c146fae 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -1,335 +1,8510 @@ -/* ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -/// - -declare module WinJS { - function strictProcessing(): void; - - export module Application { - export var onsettings: EventListener; - } - - module Binding { - function as(data: any): any; - function processAll(rootElement?: any, dataContext?: any, skipRoot?: boolean, bindingCache?: any): any; - function define(data: any): any; - function expandProperties(data: any): any; - function converter(method: any): any; - - export var optimizeBindingReferences: boolean; - export var mixin: any; - export var bind: any; - export var oneTime: any; - - export function initializer(customInit: any): any; - export var setAttribute: any; - - class List { - constructor(data?: T[], options?: { binding: boolean; proxy: boolean; }); - public push(item: T): number; - public indexOf(item: T, fromIndex?: number): number; - public splice(start: number, howMany?: number, ...items: T[]): T[]; - public createFiltered(predicate: (x: T) => boolean): List; - public createGrouped(keySelector: (x: T) => string, dataSelector: (x:T) => U, groupSorter?: (left:string, right:string) => number): List; - public createSorted(sorter: (left:T, right:T) => number): List; - public groups: List; - public dataSource: any; - public getAt(index: number): T; - public forEach(callback: (val: T, index: number, array: T[]) => void, thisArg?: any): void; - public every(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - public join(separator: string): string; - public map(callback: (val: T, index: number, array: T[]) => U, thisArg?: any): U[]; - public move(index: number, newIndex: number): void; - public pop(): T; - public reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; - public reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; - public reverse(): void; - public setAt(index: number, newValue: T): void; - public shift(): T; - public slice(begin: number, end: number): List; - public some(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - public sort(sortFunction: (left: T, right: T) => number): void; - public filter(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - public unshift(value: T): number; - public length: number; - public notifyMutated(index: number): void; - } - class Template { - public element: HTMLElement; - public extractChild: boolean; - public processTimeout: number; - public debugBreakOnRender: boolean; - public disableOptimizedProcessing: boolean; - public isDeclarativeControlContainer: boolean; - public bindingInitializer: any; - - constructor(element: HTMLElement, options?: any); - public render: { - (dataContext: any, container?: HTMLElement): WinJS.Promise; - value(href: string, dataContext: any, container?: HTMLElement): WinJS.Promise; - }; - public renderItem(item: any, recycled?: HTMLElement): void; - } - - - } - module Namespace { - var define: any; - var defineWithParent: any; - } - module Class { - function define(constructor: any, instanceMembers: any): any; - function derive(baseClass: any, constructor: any, instanceMembers: any): any; - function mix(constructor: any, ...mixin: any[]): any; - } - function xhr(options: { type?: string; url?: string; user?: string; password?: string; headers?: any; data?: any; responseType?: string; }): WinJS.Promise; - module Application { - interface IOHelper { - exists(filename: string): boolean; - readText(fileName: string, def: string): WinJS.Promise; - readText(fileName: string): WinJS.Promise; - writeText(fileName: string, text: string): WinJS.Promise; - remove(fileName: string): WinJS.Promise; - } - var local: IOHelper; - var roaming: IOHelper; - var onactivated: EventListener; - var sessionState: any; - interface ApplicationActivationEvent extends Event { - detail: any; - setPromise(p: Promise): any; - } - function addEventListener(type: string, listener: EventListener, capture?: boolean): void; - var oncheckpoint: EventListener; - function start(): void; - function stop(): void; - } - class ErrorFromName { - constructor(name: string, message?: string); - } - class Promise implements Windows.Foundation.IPromise { - constructor(init: (c: any, e: any, p: any) => void); - then(success?: (value: T) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; - then(success?: (value: T) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; - then(success?: (value: T) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; - then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; - done(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void; - - cancel(): void; - - static join(values: any[]): Promise; - static timeout(timeout: number): Promise; - static as(): Promise; - static as(obj: U): Promise; - static wrapError(obj: U): Promise; - } - module Navigation { - var history: any; - var canGoBack: boolean; - var canGoForward: boolean; - var location: string; - var state: any; - function addEventListener(type: string, listener: EventListener, capture: boolean): void; - function back(): void; - function forward(): void; - function navigate(location: any, initialState: any): WinJS.Promise; - function navigate(location: any): WinJS.Promise; - function removeEventListener(type: string, listener: EventListener, capture: boolean): void; - var onbeforenavigate: CustomEvent; - var onnavigated: CustomEvent; - var onnavigating: CustomEvent; - } - - export module Resources { - export var processAll: (element?: HTMLElement) => void; - export var getString: (id: string) => { value: string; empty?: boolean; lang?: string; }; - export var addEventListener: (id: string, handler: EventListener, useCapture?: boolean) => void; - } - - module Utilities { - function markSupportedForProcessing(obj: T): T; - function createEventProperties(...events: string[]): any; - - export function addClass(element: HTMLElement, className: string): void; - export function removeClass(element: HTMLElement, className: string): void; - - export function hasClass(element: HTMLElement, className: string): boolean; - - enum Key { - backspace, - tab, - enter, - shift, - ctrl, - alt, - pause, - capsLock, - escape, - space, - pageUp, - pageDown, - end, - home, - leftArrow, - upArrow, - rightArrow, - downArrow, - insert, - deleteKey, - num0, - num1, - num2, - num3, - num4, - num5, - num6, - num7, - num8, - num9, - a, - b, - c, - d, - e, - f, - g, - h, - i, - j, - k, - l, - m, - n, - o, - p, - q, - r, - s, - t, - u, - v, - w, - x, - y, - z, - leftWindows, - rightWindows, - numPad0, - numPad1, - numPad2, - numPad3, - numPad4, - numPad5, - numPad6, - numPad7, - numPad8, - numPad9, - multiply, - add, - subtract, - decimalPoint, - divide, - f1, - f2, - f3, - f4, - f5, - f6, - f7, - f8, - f9, - f10, - f11, - f12, - numLock, - scrollLock, - semicolon, - equal, - comma, - dash, - period, - forwardSlash, - graveAccent, - openBracket, - backSlash, - closeBracket, - singleQuote - } - } - module UI { - var process: any; - var processAll: any; - var ListLayout: any; - var GridLayout: any; - var Pages: any; - var setOptions: any; - - export var Animation: any; - - var DOMEventMixin: any; - - class Flyout { - constructor(element: HTMLElement, options: any); - element: Element; - } - - module Fragments { - var renderCopy: any; - } - - export class HtmlControl { - constructor(element: HTMLElement, options: { uri: string; }); - } - - interface IItem { - data: any; - } - - interface ISelection { - clear(): WinJS.Promise; - count(): number; - getItems(): WinJS.Promise; - } - - class ListView { - element: Element; - elementFromIndex(index: number): Element; - indexOfElement(element: Element): number; - selection: ISelection; - } - - class Menu { - constructor(element: HTMLElement, options: any); - element: Element; - } - - export class MenuCommand { - constructor(element: HTMLElement, options: any); - } - - export class SettingsFlyout { - static populateSettings(e: any): any; - static showSettings(id: string, path: any): any; - } - } - - export function xhr(options: { type: string; url: string; }): WinJS.Promise; // user: string; password: string; headers: any; data: any; responseType: string; -} - +/** + * Defines an Element object. +**/ interface Element { - winControl: any; // TODO: This should be control? -} + winControl: any; // TODO: This should be control? +}/** + * Provides application-level functionality, for example activation, storage, and application events. +**/ +declare module WinJS.Application { + //#region Objects + /** + * The local storage of the application. + **/ + var local: { + //#region Methods + + /** + * Determines whether the specified file exists in the folder. + * @param filename The name of the file. + * @returns A promise that completes with a value of either true (if the file exists) or false. + **/ + exists(filename: string): Promise; + + /** + * Reads the specified file. If the file doesn't exist, the specified default value is returned. + * @param fileName The file to read from. + * @param def The default value to be returned if the file failed to open. + * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. + **/ + readText(fileName: string, def?: string): Promise; + + /** + * Deletes a file from the folder. + * @param fileName The file to be deleted. + * @returns A promise that is fulfilled when the file has been deleted. + **/ + remove(fileName: string): Promise; + + /** + * Writes the specified text to the specified file. + * @param fileName The name of the file. + * @param text The content to be written to the file. + * @returns A promise that completes with a value that is the number of characters written. + **/ + writeText(fileName: string, text: string): Promise; + + //#endregion Methods + + }; + + /** + * The roaming storage of the application. + **/ + var roaming: { + //#region Methods + + /** + * Determines whether the specified file exists in the folder. + * @param filename The name of the file. + * @returns A promise that completes with a value of either true (if the file exists) or false. + **/ + exists(filename: string): Promise; + + /** + * Reads the specified file. If the file doesn't exist, the specified default value is returned. + * @param fileName The file to read from. + * @param def The default value to be returned if the file failed to open. + * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. + **/ + readText(fileName: string, def?: string): Promise; + + /** + * Deletes a file from the folder. + * @param fileName The file to be deleted. + * @returns A promise that is fulfilled when the file has been deleted. + **/ + remove(fileName: string): Promise; + + /** + * Writes the specified text to the specified file. + * @param fileName The name of the file. + * @param text The content to be written to the file. + * @returns A promise that completes with a value that is the number of characters written. + **/ + writeText(fileName: string, text: string): Promise; + + //#endregion Methods + + }; + + /** + * An object used for storing app information that can be used to restore the app's state after it has been suspended and then resumed. Data that can usefully be contained in this object includes the current navigation page or any information the user has added to the input controls on the page. You should not add information about customization (for example colors) or user-defined lists of content. + **/ + var sessionState: Object; + + /** + * The temp storage of the application. + **/ + var temp: { + //#region Methods + + /** + * Determines whether the specified file exists in the folder. + * @param filename The name of the file. + * @returns A promise that completes with a value of either true (if the file exists) or false. + **/ + exists(filename: string): Promise; + + /** + * Reads the specified file. If the file doesn't exist, the specified default value is returned. + * @param fileName The file to read from. + * @param def The default value to be returned if the file failed to open. + * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. + **/ + readText(fileName: string, def?: string): Promise; + + /** + * Deletes a file from the folder. + * @param fileName The file to be deleted. + * @returns A promise that is fulfilled when the file has been deleted. + **/ + remove(fileName: string): Promise; + + /** + * Writes the specified text to the specified file. + * @param fileName The name of the file. + * @param text The text to write. + * @returns A Promise that completes with the number of bytes successfully written to the file. + **/ + writeText(fileName: string, text: string): Promise; + + //#endregion Methods + + }; + + //#endregion Objects + + //#region Methods + + /** + * Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload. + * @param promise The promise that should complete before processing is complete. + **/ + function setPromise(promise: Promise): void; + + //#endregion Methods + + //#region Functions + + /** + * Adds an event listener for application-level events: activated, checkpoint, error, loaded, ready, settings, and unload. + * @param type The type (name) of the event. You can use any of the following:"activated", "checkpoint", "error", "loaded", "ready", "settings", and" unload". + * @param listener The listener to invoke when the event is raised. + * @param capture true to initiate capture, otherwise false. + **/ + function addEventListener(type: string, listener: Function, capture?: boolean): void; + + /** + * Queues a checkpoint event. + **/ + function checkpoint(): void; + + /** + * Queues an event to be processed by the WinJS.Application event queue. + * @param eventRecord The event object is expected to have a type property that is used as the event name when dispatching on the WinJS.Application event queue. The entire object is provided to event listeners in the detail property of the event. + **/ + function queueEvent(eventRecord: Object): void; + + /** + * Removes an event listener from the control. + * @param type The type (name) of the event. + * @param listener The listener to remove. + * @param useCapture Specifies whether or not to initiate capture. + **/ + function removeEventListener(type: string, listener: Function, useCapture?: Object): void; + + /** + * Starts dispatching application events (the activated, checkpoint, error, loaded, ready, settings, and unload events). + **/ + function start(): void; + + /** + * Stops application event processing and resets WinJS.Application to its initial state. All WinJS.Application event listeners (for the activated, checkpoint, error, loaded, ready, settings, and unload events) are removed. + **/ + function stop(): void; + + //#endregion Functions + + //#region Events + + /** + * Occurs when WinRT activation has occurred. The name of this event is "activated" (and also "mainwindowactivated"). This event occurs after the loaded event and before the ready event. + * @param eventInfo An object that contains information about the event. For more information about event arguments, see the WinRT event argument classes: WebUICachedFileUpdaterActivatedEventArgs, WebUICameraSettingsActivatedEventArgs, WebUIContactPickerActivatedEventArgs, WebUIDeviceActivatedEventArgs, WebUIFileActivatedEventArgs, WebUIFileOpenPickerActivatedEventArgs, WebUIFileSavePickerActivatedEventArgs, WebUILaunchActivatedEventArgs, WebUIPrintTaskSettingsActivatedEventArgs, WebUIProtocolActivatedEventArgs, WebUISearchActivatedEventArgs, WebUIShareTargetActivatedEventArgs. + **/ + function onactivated(eventInfo: CustomEvent): void; + + /** + * Occurs when receiving PLM notification or when the checkpoint function is called. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise. + **/ + function oncheckpoint(eventInfo: CustomEvent): void; + + /** + * Occurs when an unhandled error has been raised. + * @param eventInfo An object that contains information about the event. + **/ + function onerror(eventInfo: CustomEvent): void; + + /** + * Occurs after the DOMContentLoaded event, which fires after the page has been parsed but before all the resources are loaded. This event occurs before the activated event and the ready event. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise. + **/ + function onloaded(eventInfo: CustomEvent): void; + + /** + * Occurs when the application is ready. This event occurs after the loaded event and the activated event. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise. + **/ + function onready(eventInfo: CustomEvent): void; + + /** + * Occurs when the settings charm is invoked. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: type, applicationcommands. + **/ + function onsettings(eventInfo: CustomEvent): void; + + /** + * Occurs when the application is about to be unloaded. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise. + **/ + function onunload(eventInfo: CustomEvent): void; + + //#endregion Events + +} +/** + * Provides functionality for data and template binding. +**/ +declare module WinJS.Binding { + //#region Properties + + /** + * Determines whether or not binding should automatically set the ID of an element. This property should be set to true in apps that use WinJS (WinJS) binding. + **/ + var optimizeBindingReferences: boolean; + + //#endregion Properties + + //#region Objects + + /** + * Allows you to add bindable properties dynamically. + **/ + var dynamicObservableMixin: { + //#region Methods + + /** + * Adds a property with change notification to this object, including a ECMAScript5 property definition. + * @param name The name of the property to add. + * @param value This object is returned. + **/ + addProperty(name: string, value: Object): void; + + /** + * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. + * @param name The name of the property to which to bind the action. + * @param action The function to invoke asynchronously when the property may have changed. + * @returns This object is returned. + **/ + bind(name: string, action: Object): Function; + + /** + * Gets a property value by name. + * @param name The name of the property to get. + * @returns The value of the property as an observable object. + **/ + getProperty(name: string): Object; + + /** + * Notifies listeners that a property value was updated. + * @param name The name of the property that is being updated. + * @param newValue The new value for the property. + * @param oldValue The old value for the property. + * @returns A promise that is completed when the notifications are complete. + **/ + notify(name: string, newValue: string, oldValue: string): Promise; + + /** + * Removes a property value. + * @param name The name of the property to remove. + * @returns This object is returned. + **/ + removeProperty(name: string): Object; + + /** + * Updates a property value and notifies any listeners. + * @param name The name of the property to update. + * @param value The new value of the property. + * @returns This object is returned. + **/ + setProperty(name: string, value: Object): Object; + + /** + * Removes one or more listeners from the notification list for a given property. + * @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed. + * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. + * @returns This object is returned. + **/ + unbind(name: string, action: Function): Object; + + /** + * Updates a property value and notifies any listeners. + * @param name The name of the property to update. + * @param value The new value of the property. + * @returns A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed. + **/ + updateProperty(name: string, value: Object): Promise; + + //#endregion Methods + + }; + + /** + * Do not instantiate. A list returned by the createFiltered method. + **/ + class FilteredListProjection { + //#region Methods + + /** + * Returns a key/data pair for the specified index. + * @param index The index of the value to retrieve. + * @returns An object that has two properties: key and data. + **/ + getItem(index: number): IKeyDataPair; + + /** + * Returns the index of the first occurrence of a key in a list. + * @param key The key to locate in the list. + * @returns The index of the first occurrence of a key in a list, or -1 if not found. + **/ + indexOfKey(key: string): number; + + /** + * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. + * @param index The index of the value that was mutated. + **/ + notifyMutated(index: number): void; + + /** + * Replaces the value at the specified index with a new value. + * @param index The index of the value that was replaced. + * @param newValue The new value. + **/ + setAt(index: number, newValue: T): void; + + //#endregion Methods + + //#region Properties + + /** + * The length of the list. Returns an integer value one higher than the highest element defined in an list. + **/ + length: number; + + //#endregion Properties + + } + + /** + * Do not instantiate. A list of groups. + **/ + class GroupsListProjection { + //#region Methods + + /** + * Gets a key/data pair for the specified index. + * @param index The index of the value to retrieve. + * @returns An object that has two properties: key and data. + **/ + getItem(index: number): IKeyDataPair; + + /** + * Gets a key/data pair for the specified key. + * @param key The key of the value to retrieve. + * @returns An object with two properties: key and data. + **/ + getItemFromKey(key: string): IKeyDataPair; + + /** + * Returns the index of the first occurrence of a key in a list. + * @param key The key to locate in the list. + * @returns The index of the first occurrence of a key in a list, or -1 if not found. + **/ + indexOfKey(key: string): number; + + //#endregion Methods + + //#region Properties + + /** + * The length of the list. Returns an integer value one higher than the highest element defined in an list. + **/ + length: number; + + //#endregion Properties + + } + + /** + * Do not instantiate. Sorts the underlying list by group key and within a group respects the position of the item in the underlying list. Returned by createGrouped. + **/ + class GroupedSortedListProjection { + //#region Methods + + /** + * Gets a key/data pair for the specified item key. + * @param key The key of the value to retrieve. + * @returns An object that has two properties: key and data. + **/ + getItem(key: string): IKeyDataPair; + + //#endregion Methods + + //#region Properties + + /** + * Gets a List, which is a projection of the groups that were identified in this list. + **/ + groups: List; + + /** + * Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView. + **/ + dataSource: WinJS.UI.IListDataSource; + + //#endregion Properties + + } + + /** + * Represents a list of objects that can be accessed by index or by a string key. Provides methods to search, sort, filter, and manipulate the data. + **/ + class List { + //#region Constructors + + /** + * Creates a List object. + * @constructor + * @param list The array containing the elements to initalize the list. + * @param options You can set two Boolean options: binding and proxy. If options.binding is true, the list contains the result of calling as on the element values. If options.proxy is true, the list specified as the first parameter is used as the storage for the List. This option should be used with care, because uncoordinated edits to the data storage may result in errors. + **/ + constructor(list?: T[], options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * An item in the list has changed its value. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue. + **/ + onitemchanged(eventInfo: CustomEvent): void; + + /** + * A new item has been inserted into the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + oniteminserted(eventInfo: CustomEvent): void; + + /** + * An item has been mutated. This event occurs as a result of calling the notifyMutated method. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemmutated(eventInfo: CustomEvent): void; + + /** + * An item has been removed from the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemremoved(eventInfo: CustomEvent): void; + + /** + * The list has been refreshed. Any references to items in the list may be incorrect. + * @param eventInfo An object that contains information about the event. The detail property of this object is null. + **/ + onreload(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Adds an event listener. + * @param eventName The event name. + * @param eventCallback The event handler function to associate with this event. + **/ + addEventListener(eventName: string, eventCallback: Function): void; + + /** + * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. + * @param name The name of the property to which to bind the action. + * @param action The function to invoke asynchronously when the property may have changed. + * @returns A reference to this List object. + **/ + bind(name: string, action: Function): List; + + /** + * Returns a new list consisting of a combination of two arrays. + * @param item Additional items to add to the end of the list. + * @returns An array containing the concatenation of the list and any other supplied items. + **/ + concat(...item: T[]): T[]; + + /** + * Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change. + * @param predicate A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @returns A filtered projection over the list. + **/ + createFiltered(predicate: (x: T) => boolean): FilteredListProjection; + + /** + * Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list. + * @param groupKey A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @param groupData A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group. + * @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after). + * @returns A grouped projection over the list. + **/ + createGrouped(groupKey: (x: T) => string, groupData: (x: T) => Object, groupSorter: (left: string, right: string) => number): GroupedSortedListProjection; + + /** + * Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change. + * @param sorter A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @returns A sorted projection over the list. + **/ + createSorted(sorter: (left: T, right: T) => number): SortedListProjection; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Disconnects a WinJS.Binding.List projection from its underlying WinJS.Binding.List. It's only important to call this method when the WinJS.Binding.List projection and the WinJS.Binding.List have different lifetimes. (Call this method on the WinJS.Binding.List projection, not the underlying WinJS.Binding.List.) + **/ + dispose(): void; + + /** + * Checks whether the specified callback function returns true for all elements in a list. + * @param callback A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns true if the callback returns true for all elements in the list. + **/ + every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: Object): boolean; + + /** + * Returns the elements of a list that meet the condition specified in a callback function. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns An array containing the elements that meet the condition specified in the callback function. + **/ + filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: Object): T[]; + + /** + * Calls the specified callback function for each element in a list. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + **/ + forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: Object): void; + + /** + * Gets the value at the specified index. + * @param index The index of the value to get. + * @returns The value at the specified index. + **/ + getAt(index: number): T; + + /** + * Gets a key/data pair for the specified list index. + * @param index The index of value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItem(index: number): IKeyDataPair; + + /** + * Gets a key/data pair for the list item key specified. + * @param key The key of the value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItemFromKey(key: string): IKeyDataPair; + + /** + * Gets the index of the first occurrence of the specified value in a list. + * @param searchElement The value to locate in the list. + * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + * @returns The index of the first occurrence of a value in a list or -1 if not found. + **/ + indexOf(searchElement: Object, fromIndex?: number): number; + + /** + * Gets the index of the first occurrence of a key in a list. + * @param key The key to locate in the list. + * @returns The index of the first occurrence of a key in a list, or -1 if not found. + **/ + indexOfKey(key: string): number; + + /** + * Returns a string consisting of all the elements of a list separated by the specified separator string. + * @param separator A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma. + * @returns The elements of a list separated by the specified separator string. + **/ + join(separator: string): string; + + /** + * Gets the index of the last occurrence of the specified value in a list. + * @param searchElement The value to locate in the list. + * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list. + * @returns The index of the last occurrence of a value in a list, or -1 if not found. + **/ + lastIndexOf(searchElement: T, fromIndex: number): number; + + /** + * Calls the specified callback function on each element of a list, and returns an array that contains the results. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. + * @param thisArg n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns An array containing the result of calling the callback function on each element in the list. + **/ + map(callback: (value: T, index: number, array: T[]) => G, thisArg?: Object): G[]; + + /** + * Moves the value at index to the specified position. + * @param index The original index of the value. + * @param newIndex The index of the value after the move. + **/ + move(index: number, newIndex: number): void; + + /** + * Notifies listeners that a property value was updated. + * @param name The name of the property that is being updated. + * @param newValue The new value for the property. + * @param oldValue The old value for the property. + * @returns A promise that is completed when the notifications are complete. + **/ + notify(name: string, newValue: T, oldValue: T): Promise; + + /** + * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. + * @param index The index of the value that was mutated. + **/ + notifyMutated(index: number): void; + + /** + * Forces the list to send a reload notification to any listeners. + **/ + notifyReload(): void; + + /** + * Removes the last element from a list and returns it. + * @returns The last element from the list. + **/ + pop(): Object; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the end of the list. + * @returns The new length of the list. + **/ + push(value: T): number; + + /** + * Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list. + * @param initiallValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value. + * @returns The return value from the last call to the callback function. + **/ + reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => any, initiallValue?: Object): Object; + + /** + * Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list. + * @param initialValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value. + * @returns The return value from the last call to callback function. + **/ + reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => any, initialValue?: Object): Object; + + /** + * Removes an event listener. + * @param eventName The event name. + * @param eventCallback The event handler function to associate with this event. + **/ + removeEventListener(eventName: string, eventCallback: Function): void; + + /** + * Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. + **/ + reverse(): void; + + /** + * Replaces the value at the specified index with a new value. + * @param index The index of the value that was replaced. + * @param newValue The new value. + **/ + setAt(index: number, newValue: T): void; + + /** + * Removes the first element from a list and returns it. + * @returns The first element from the list. + **/ + shift(): Object; + + /** + * Extracts a section of a list and returns a new list. + * @param begin The index that specifies the beginning of the section. + * @param end The index that specifies the end of the section. + * @returns Returns a section of list. + **/ + slice(begin: number, end: number): List; + + /** + * Checks whether the specified callback function returns true for any element of a list. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list until it returns true, or until the end of the list. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns true if callback returns true for any element in the list. + **/ + some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: Object): boolean; + + /** + * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. + * @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + **/ + sort(sortFunction: (left: T, right: T) => number): void; + + /** + * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the list from which to start removing elements. + * @param howMany The number of elements to remove. + * @param item The elements to insert into the list in place of the deleted elements. + * @returns The deleted elements. + **/ + splice(start: number, howMany?: number, item?: T[]): T[]; + + /** + * Removes one or more listeners from the notification list for a given property. + * @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed. + * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. + * @returns This object is returned. + **/ + unbind(name: string, action?: Function): Object; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the start of the list. + * @returns The new length of the list. + **/ + unshift(value: T): number; + + //#endregion Methods + + //#region Properties + + /** + * Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView. + **/ + dataSource: WinJS.UI.IListDataSource; + + /** + * Gets a List that is a projection of the groups that were identified in this list. This property is available only for GroupsListProjection objects. + **/ + groups: List; + + /** + * Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. + **/ + length: number; + + //#endregion Properties + + } + + /** + * Provides a standard implementation of the bindable contract, as well as a basic storage mechanism that participates in change notification and an asynchronous notification implementation. + **/ + var mixin: { + //#region Methods + + /** + * Adds a property to the object. The property includes change notification and an ECMAScript 5 property definition . + * @param name The name of the property to add. + * @param value The value of the property. + * @returns This object is returned. + **/ + addProperty(name: string, value: Object): Object; + + /** + * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. + * @param name The name of the property to which to bind the action. + * @param action The function to invoke asynchronously when the property may have changed. + * @returns This object is returned. + **/ + bind(name: string, action: Object): Function; + + /** + * Gets a property value by name. + * @param name The name of the property to get. + * @returns The value of the property as an observable object. + **/ + getProperty(name: string): Object; + + /** + * Notifies listeners that a property value was updated. + * @param name The name of the property that is being updated. + * @param newValue The new value for the property. + * @param oldValue The old value for the property. + * @returns A promise that is completed when the notifications are complete. + **/ + notify(name: string, newValue: string, oldValue: string): Promise; + + /** + * Removes a property value. + * @param name The name of the property to remove. + * @returns This object is returned. + **/ + removeProperty(name: string): Object; + + /** + * Updates a property value and notifies any listeners. + * @param name The name of the property to update. + * @param value The new value of the property. + * @returns This object is returned. + **/ + setProperty(name: string, value: Object): Object; + + /** + * Removes one or more listeners from the notification list for a given property. + * @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed. + * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. + * @returns This object is returned. + **/ + unbind(name: string, action: Function): Object; + + /** + * Updates a property value and notifies any listeners. + * @param name The name of the property to update. + * @param value The new value of the property. + * @returns A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed. + **/ + updateProperty(name: string, value: Object): Promise; + + //#endregion Methods + + }; + + /** + * Provides functions that can make an object observable. + **/ + var observableMixin: { + //#region Methods + + /** + * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. + * @param name The name of the property to which to bind the action. + * @param action The function to invoke asynchronously when the property may have changed. + * @returns A reference to this observableMixin object. + **/ + bind(name: string, action: Function): Object; + + /** + * Notifies listeners that a property value was updated. + * @param name The name of the property that is being updated. + * @param newValue The new value for the property. + * @param oldValue The old value for the property. + * @returns A promise that is completed when the notifications are complete. + **/ + notify(name: string, newValue: Object, oldValue: Object): Promise; + + /** + * Removes one or more listeners from the notification list for a given property. + * @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed. + * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. + * @returns This object is returned. + **/ + unbind(name: string, action: Function): Object; + + //#endregion Methods + + }; + + /** + * Do not instantiate. Returned by the createSorted method. + **/ + class SortedListProjection { + //#region Methods + + /** + * Returns a key/data pair for the specified index. + * @param index The index of the value to retrieve. + * @returns An object that has two properties: key and data. + **/ + getItem(index: number): IKeyDataPair; + + /** + * Returns the index of the first occurrence of a key. + * @param key The key to locate in the list. + * @returns The index of the first occurrence of a key in a list, or -1 if not found. + **/ + indexOfKey(key: string): number; + + /** + * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. + * @param index The index of the value that was mutated. + **/ + notifyMutated(index: number): void; + + /** + * Replaces the value at the specified index with a new value. + * @param index The index of the value to be replaced. + * @param newValue The new value. + **/ + setAt(index: number, newValue: T): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the length of the list. Returns an integer value one higher than the highest element defined in a list. + **/ + length: number; + + //#endregion Properties + + } + + /** + * Provides a reusable declarative binding element. + **/ + class Template { + //#region Constructors + + /** + * Creates a template that provides a reusable declarative binding element. + * @constructor + * @param element The DOM element to convert to a template. + * @param options If this parameter is supplied, the template is loaded from the URI and the content of the element parameter is ignored. You can add the following options: href. + **/ + constructor(element: HTMLElement, options?: string); + + //#endregion Constructors + + //#region Methods + + render: { + /** + * Binds values from the specified data context to elements that are descendants of the specified root element that have the declarative binding attributes specified (data-win-bind). + * @param dataContext The object to use for default data binding. + * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. + * @returns A Promise that will be completed after binding has finished. The value is either container or the created DIV. promise that is completed after binding has finished. + **/ + (dataContext: Object, container?: HTMLElement): Promise; + + /** + * Renders a template based on the specified URI (static method). + * @param href The URI from which to load the template. + * @param dataContext The object to use for default data binding. + * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. + * @returns A promise that is completed after binding has finished. The value is either the object in the container parameter or the created DIV. + **/ + value(href: string, dataContext: Object, container?: HTMLElement): Promise; + }; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the default binding initializer for the template. + **/ + bindingInitializer: Object; + + /** + * Gets or sets a value that specifies whether a debug break is inserted into the first rendering of each template. This property only has an effect when the app is in debug mode. + **/ + debugBreakOnRender: boolean; + + /** + * This property is deprecated and might not be available in future versions of the WinJS. Gets or sets a value that specifies whether optimized template processing has been disabled. + **/ + disableOptimizedProcessing: boolean; + + /** + * Gets the DOM element that is used as the template. + **/ + element: HTMLElement; + + /** + * Gets a value that specifies whether templates should be instantiated without the creation of an additional child element. + **/ + extractChild: boolean; + + /** + * Determines whether the Template contains declarative controls that must be processed separately. This property is always true. The controls that belong to a Template object's children are instantiated when a Template instance is rendered. + **/ + isDeclarativeControlContainer: boolean; + + //#endregion Properties + + } + + //#endregion Objects + + //#region Functions + + /** + * Adds a CSS class from the specified path of the source object to a destination object. + * @param source The source object that has the class to copy. + * @param sourceProperties The path on the source object to the source class. + * @param dest The destination object. + **/ + function addClassOneTime(source: Object, sourceProperties: Object[], dest: HTMLElement): void; + + /** + * Returns an observable object. This may be an observable proxy for the specified object, an existing proxy, or the specified object itself if it directly supports observation. + * @param data The object to observe. + * @returns The observable object. + **/ + function as(data: Object): Object; + + /** + * Binds one or properties of a complex, observable object for child values of the object to specific functions. + * @param name The observable object to bind to. + * @param action An object that contains functions to invoke asynchronously when the specified properties in the observable object have changed. + * @returns This object is returned. + **/ + function bind(name: string, action: Object): Object; + + /** + * Creates a default binding initializer for binding between a source property and a destination property with the specified converter function that is executed on the value of the source property. + * @param convert The conversion function that takes the source property and produces a value that is set to the destination property. This function must be accessible from the global namespace. + * @returns The binding initializer. + **/ + function converter(convert: Function): Function; + + /** + * Creates a one-way binding between the source object and the destination object. Warning Do not attempt to bind data to the ID of an HTML element. + * @param source The source object. + * @param sourceProperties The path on the source object to the source property. + * @param dest The destination object. + * @param destProperties The path on the destination object to the destination property. + * @returns An object with a cancel method that is used to coalesce bindings. + **/ + function defaultBind(source: Object, sourceProperties: Object, dest: Object, destProperties: Object): Object; + + /** + * Creates a new constructor function that supports observability with the specified set of properties. + * @param data The object to use as the pattern for defining the set of properties. + * @returns A constructor function with 1 optional argument that is the initial state of the properties. + **/ + function define(data: Object): Object; + + /** + * Wraps the specified object so that all its properties are instrumented for binding. This is meant to be used in conjunction with the binding mixin. + * @param shape The specification for the bindable object. + * @returns An object with a set of properties all of which are wired for binding. + **/ + function expandProperties(shape: Object): Object; + + /** + * Marks a custom initializer function as being compatible with declarative data binding. + * @param customInitializer The custom initializer to be marked as compatible with declarative data binding. + * @returns The input customInitializer. + **/ + function initializer(customInitializer: Function): Function; + + /** + * Notifies listeners that a property value was updated. + * @param name The name of the property that is being updated. + * @param newValue The new value for the property. + * @param oldValue The old value for the property. + * @returns A promise that is completed when the notifications are complete. + **/ + function notify(name: string, newValue: string, oldValue: string): Promise; + + /** + * Sets the destination property to the value of the source property. + * @param source The source object. + * @param sourceProperties The path on the source object to the source property. + * @param dest The destination object. + * @param destProperties The path on the destination object to the destination property. + * @returns An object with a cancel method that is used to coalesce bindings. + **/ + function oneTime(source: Object, sourceProperties: Object, dest: Object, destProperties: Object): Object; + + /** + * Binds the values of an object to the values of a DOM element that has the data-win-bind attribute. If multiple DOM elements are to be bound, you must set the attribute on all of them. See the example below for details. + * @param rootElement Optional. The element at which to start traversing to find elements to bind to. If this parameter is omitted, the entire document is searched. + * @param dataContext The object that contains the values to which the DOM element should be bound. + * @param skipRoot If true, specifies that only the children of rootElement should be bound, otherwise rootElement should be bound as well. + * @param bindingCache The cached binding data. + * @param defaultInitializer The binding initializer to use in the case that one is not specified in a binding expression. If not provided, the behavior is the same as Binding.defaultBind. + * @returns A Promise that completes when every item that contains the data-win-bind attribute has been processed and the update has started. + **/ + function processAll(rootElement?: Element, dataContext?: Object, skipRoot?: boolean, bindingCache?: Object, defaultInitializer?: Function): Promise; + + /** + * Creates a one-way binding between the source object and an attribute on the destination element. + * @param source The source object. + * @param sourceProperties The path on the source object to the source property. + * @param dest The destination object. + * @param destProperties The path on the destination object to the destination property. This must be a single name. + * @returns An object with a cancel() method that is used to coalesce bindings. + **/ + function setAttribute(source: Object, sourceProperties: Object[], dest: Element, destProperties: Object[]): Object; + + /** + * Sets an attribute on the destination element to the value of the source property. + * @param source The source object. + * @param sourceProperties The path on the source object to the source property. + * @param dest The destination object. + * @param destProperties The path on the destination object to the destination property. This must be a single name. + **/ + function setAttributeOneTime(source: Object, sourceProperties: Object[], dest: Element, destProperties: Object[]): void; + + /** + * Returns the original (non-observable) object is returned if the specified object is an observable proxy, + * @param data The object for which to retrieve the original value. + * @returns If the specified object is an observable proxy, the original object is returned, otherwise the same object is returned. + **/ + function unwrap(data: Object): Object; + + //#endregion Functions + + //#region Interfaces + + interface IKeyDataPair { + key: string; + data: T; + } + + //#endregion Interfaces + +} +/** + * Provides helper functions for defining Classes. +**/ +declare module WinJS.Class { + //#region Functions + + /** + * Defines a class using the given constructor and the specified instance members. + * @param constructor A constructor function that is used to instantiate this type. + * @param instanceMembers The set of instance fields, properties, and methods made available on the type. + * @param staticMembers The set of static fields, properties, and methods made available on the type. + * @returns The newly-defined type. + **/ + function define(constructor: Function, instanceMembers?: Object, staticMembers?: any): Object; + + /** + * Creates a sub-class based on the specified baseClass parameter, using prototype inheritance. + * @param baseClass The type to inherit from. + * @param constructor A constructor function that is used to instantiate this type. + * @param instanceMembers The set of instance fields, properties, and methods to be made available on the type. + * @param staticMembers The set of static fields, properties, and methods to be made available on the type. + * @returns The newly-defined type. + **/ + function derive(baseClass: Object, constructor: Function, instanceMembers?: Object, staticMembers?: Object): Object; + + /** + * Defines a class using the given constructor and the union of the set of instance members specified by all the mixin objects. The mixin parameter list is of variable length. For more information, see Adding functionality with WinJS mixins. + * @param constructor A constructor function that will be used to instantiate this class. + * @param mixin An object declaring the set of instance members. The mixin parameter list is of variable length. + * @returns The newly defined class. + **/ + function mix(constructor: Function, ...mixin: any[]): Object; + + //#endregion Functions + +} +/** + * The WinJS namespace provides special Windows Library for JavaScript functionality, including Promise and xhr. +**/ +declare module WinJS { + //#region Properties + + /** + * Can be set to show the results of a validation process. + **/ + var validation: boolean; + + //#endregion Properties + + //#region Objects + + /** + * An error object. + **/ + class ErrorFromName { + //#region Constructors + + /** + * Creates an Error object with the specified name and message properties. + * @constructor + * @param name The name of this error. The name is meant to be consumed programmatically and should not be localized. + * @param message The message for this error. The message is meant to be consumed by humans and should be localized. + **/ + constructor(name: string, message?: string); + + //#endregion Constructors + + } + + /** + * Provides a mechanism to schedule work to be done on a value that has not yet been computed. It is an abstraction for managing interactions with asynchronous APIs. For more information about asynchronous programming, see Asynchronous programming. For more information about promises in JavaScript, see Asynchronous programming in JavaScript. For more information about using promises, see the WinJS Promise sample. + **/ + class Promise implements Windows.Foundation.IPromise { + //#region Constructors + + /** + * A promise provides a mechanism to schedule work to be done on a value that has not yet been computed. It is a convenient abstraction for managing interactions with asynchronous APIs. For more information about asynchronous programming, see Asynchronous programming. For more information about promises in JavaScript, see Asynchronous programming in JavaScript. For more information about using promises, see the WinJS Promise sample. + * @constructor + * @param init The function that is called during construction of the Promise that contains the implementation of the operation that the Promise will represent. This can be synchronous or asynchronous, depending on the nature of the operation. Note that placing code within this function does not automatically run it asynchronously; that must be done explicitly with other asynchronous APIs such as setImmediate, setTimeout, requestAnimationFrame, and the Windows Runtime asynchronous APIs. The init function is given three arguments: completeDispatch, errorDispatch, progressDispatch. This parameter is optional. + * @param onCancel The function to call if a consumer of this promise wants to cancel its undone work. Promises are not required to support cancellation. + **/ + constructor(init?: (completeDispatch: any, errorDispatch: any, progressDispatch: any) => void, onCancel?: Function); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when there is an error in processing a promise. + * @param eventInfo An object that contains information about the event. + **/ + onerror(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Adds an event listener for the promise. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event is raised. + * @param capture true to initiate capture, otherwise false. + **/ + addEventListener(type: string, listener: Function, capture?: boolean): void; + + /** + * Returns a promise that is fulfilled when one of the input promises has been fulfilled. + * @param value An array that contains Promise objects or objects whose property values include Promise objects. + * @returns A promise that on fulfillment yields the value of the input (complete or error). + **/ + static any(value: Promise[]): Promise; + + /** + * Returns a promise. If the object is already a Promise it is returned; otherwise the object is wrapped in a Promise. You can use this function when you need to treat a non-Promise object like a Promise, for example when you are calling a function that expects a promise, but already have the value needed rather than needing to get it asynchronously. + * @param value The value to be treated as a Promise. + * @returns The promise. + **/ + static as(value: U): Promise; + + /** + * Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled"). + **/ + cancel(): void; + + /** + * Raises an event of the specified type and properties. + * @param type The type (name) of the event. + * @param details The set of additional properties to be attached to the event object. + * @returns true if preventDefault was called on the event; otherwise, false. + **/ + dispatchEvent(type: string, details: Object): boolean; + + /** + * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript. + * @param onComplete The function to be called if the promise is fulfilled successfully with a value. The fulfilled value is passed as the single argument. If the value is null, the fulfilled value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while executing the function, the promise returned by then moves into the error state. + * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function is the fulfilled value of the promise returned by then. + * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. + **/ + done(onComplete?: (value: T) => any, onError?: (error: any) => any, onProgress?: (progress: any) => void): void; + + /** + * Determines whether a value fulfills the promise contract. + * @param value A value that may be a promise. + * @returns true if the object conforms to the promise contract (has a then function), otherwise false. + **/ + static is(value: Object): boolean; + + /** + * Creates a Promise that is fulfilled when all the values are fulfilled. + * @param values An object whose members contain values, some of which may be promises. + * @returns A Promise whose value is an object with the same field names as those of the object in the values parameter, where each field value is the fulfilled value of a promise. + **/ + static join(values: Object): Promise; + + /** + * Removes an event listener from the control. + * @param eventType The type (name) of the event. + * @param listener The listener to remove. + * @param capture Specifies whether or not to initiate capture. + **/ + removeEventListener(eventType: string, listener: Function, capture?: boolean): void; + + /** + * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript. + * @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state. + * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function. + * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. + * @returns The promise whose value is the result of executing the onComplete function. + **/ + then(onComplete?: (value: T) => Windows.Foundation.IPromise, onError?: (error: any) => Windows.Foundation.IPromise, onProgress?: (progress: any) => void): Windows.Foundation.IPromise; + + /** + * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript. + * @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state. + * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function. + * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. + * @returns The promise whose value is the result of executing the onComplete function. + **/ + then(onComplete?: (value: T) => Windows.Foundation.IPromise, onError?: (error: any) => U, onProgress?: (progress: any) => void): Windows.Foundation.IPromise; + + /** + * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript. + * @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state. + * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function. + * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. + * @returns The promise whose value is the result of executing the onComplete function. + **/ + then(onComplete?: (value: T) => U, onError?: (error: any) => Windows.Foundation.IPromise, onProgress?: (progress: any) => void): Windows.Foundation.IPromise; + + /** + * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript. + * @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state. + * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. In different cases this object may be of different types, so it is necessary to test the object for the properties you expect. If the error is null, it is forwarded. The value returned from the function becomes the value of the promise returned by the then function. + * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. + * @returns The promise whose value is the result of executing the onComplete function. + **/ + then(onComplete?: (value: T) => U, onError?: (error: any) => U, onProgress?: (progress: any) => void): Windows.Foundation.IPromise; + + /** + * Performs an operation on all the input promises and returns a promise that has the shape of the input and contains the result of the operation that has been performed on each input. + * @param values A set of values (which could be either an array or an object) of which some or all are promises.. + * @param complete The function to be called if the promise is fulfilled with a value. This function takes a single argument, which is the fulfilled value of the promise. + * @param error The function to be called if the promise is fulfilled with an error. This function takes a single argument, which is the error value of the promise. + * @param progress The function to be called if the promise reports progress. This function takes a single argument, which is the data about the progress of the promise. Promises are not required to support progress. + * @returns A Promise that is the result of calling join on the values parameter. + **/ + static thenEach(values: Object, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): Promise; + + /** + * This method has two forms: WinJS.Promise.timeout(timeout) and WinJS.Promise.timeout(timeout, promise). WinJS.Promise.timeout(timeout) creates a promise that is completed asynchronously after the specified timeout, essentially wrapping a call to setTimeout within a promise. WinJS.Promise.timeout(timeout, promise) sets a timeout period for completion of the specified promise, automatically canceling the promise if it is not completed within the timeout period. + * @param timeout The timeout period in milliseconds. If this value is zero or not specified, msSetImmediate is called, otherwise setTimeout is called. + * @param promise Optional. A promise that will be canceled if it doesn't complete within the timeout period. + * @returns If the promise parameter is omitted, returns a promise that will be fulfilled after the timeout period. If the promise paramater is provided, the same promise is returned. + **/ + static timeout(timeout: number, promise?: Promise): Promise; + + /** + * Wraps a non-promise value in a promise. This method is like wrapError, which allows you to produce a Promise in error conditions, in that it allows you to return a Promise in success conditions. + * @param value Some non-promise value to be wrapped in a promise. + * @returns A promise that is successfully fulfilled with the specified value. + **/ + static wrap(value: U): Promise; + + /** + * Wraps a non-promise error value in a promise. You can use this function if you need to pass an error to a function that requires a promise. + * @param error A non-promise error value to be wrapped in a promise. + * @returns A promise that is in an error state with the specified value. + **/ + static wrapError(error: U): Promise; + + //#endregion Methods + + } + + //#endregion Objects + + //#region Functions + + /** + * You can provide an implementation of this method yourself, or use WinJS.Utilities.startLog to create one that logs to the JavaScript console. + * @param message The message to log. + * @param tags The tag or tags to categorize the message (winjs, winjs controls, etc.). + * @param type The type of message (error, warning, info, etc.). + **/ + function log(message: string, tags: string, type: string): void; + + /** + * This method has been deprecated. Strict processing is always on; you don't have to call this method to turn it on. + **/ + function strictProcessing(): void; + + /** + * Wraps calls to XMLHttpRequest in a promise. + * @param options The options that are applied to the XMLHttpRequest object, as follows: type, url, user, password, responseType, headers, data, customRequestInitializer. + * @returns A promise that returns the XMLHttpRequest object when it completes. + **/ + function xhr(options: IXHROptions): Promise; + + //#endregion Functions + + //#region Interfaces + + interface IXHROptions { + type?: string; + url: string; + user?: string; + password?: string; + headers?: any; + data: any; + responseType?: string; + } + + //#endregion Interfaces +} +/** + * Provides helper functions for defining namespaces. For more information, see Organizing your code with WinJS.Namespace. +**/ +declare module WinJS.Namespace { + //#region Functions + + /** + * Defines a new namespace with the specified name. For more information, see Organizing your code with WinJS.Namespace. + * @param name The name of the namespace. This could be a dot-separated name for nested namespaces. + * @param members The members of the new namespace. + * @returns The newly-defined namespace. + **/ + function define(name: string, members: Object): Object; + + /** + * Defines a new namespace with the specified name under the specified parent namespace. For more information, see Organizing your code with WinJS.Namespace. + * @param parentNamespace The parent namespace. + * @param name The name of the new namespace. + * @param members The members of the new namespace. + * @returns The newly-defined namespace. + **/ + function defineWithParent(parentNamespace: Object, name: string, members: Object): Object; + + //#endregion Functions + +} +/** + * Provides functionality for dealing with basic navigation, including the navigation stack. +**/ +declare module WinJS.Navigation { + //#region Properties + + /** + * Determines whether it is possible to navigate backwards. + **/ + var canGoBack: boolean; + + /** + * Determines if it is possible to navigate forwards. + **/ + var canGoForward: boolean; + + /** + * Gets or sets the navigation history. + **/ + var history: Object; + + /** + * Gets or sets the current location. + **/ + var location: string; + + /** + * Gets or sets a user-defined object that represents the state associated with the current location. + **/ + var state: Object; + + //#endregion Properties + + //#region Functions + + /** + * Adds an event listener to the control. + * @param eventType The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + * @param capture If true, specifies that capture should be initiated, otherwise false. + **/ + function addEventListener(eventType: string, listener: Function, capture?: boolean): void; + + /** + * Navigates backwards. + * @param distance The number of entries to go back into the history. + * @returns A promise that is completed with a value that indicates whether or not the navigation was successful. + **/ + function back(distance?: number): Promise; + + /** + * Navigates forwards. + * @param distance The number of entries to go forward. + * @returns A promise that is completed with a value that indicates whether or not the navigation was successful. + **/ + function forward(distance?: number): Promise; + + /** + * Navigates to a location. + * @param location The location to navigate to. Generally the location is a string containing the URL, but it may be anything. + * @param initialState A user-defined object that represents the navigation state that may be accessed through state. + * @returns A promise that is completed with a value that indicates whether or not the navigation was successful (true if successful, otherwise false). + **/ + function navigate(location: Object, initialState?: Object): Promise; + + /** + * Removes an event listener from the control. + * @param eventType The type (name) of the event. + * @param listener The listener to remove. + * @param useCapture Specifies whether or not to initiate capture. + **/ + function removeEventListener(eventType: string, listener: Function, useCapture?: boolean): void; + + //#endregion Functions + + //#region Events + + /** + * Occurs before navigation. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: location, state. + **/ + function onbeforenavigate(eventInfo: CustomEvent): void; + + /** + * Occurs after navigation has taken place. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: location, state. + **/ + function onnavigated(eventInfo: CustomEvent): void; + + /** + * Occurs when navigation is taking place. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: location, state. + **/ + function onnavigating(eventInfo: CustomEvent): void; + + //#endregion Events + +} +/** + * Provides functions for accessing resources and localizing content. +**/ +declare module WinJS.Resources { + //#region Functions + + /** + * Registers an event handler for the specified event. Use this method to register for events that are related to resources, such as when the app's language, scale, or contrast changes. + * @param type The name of the event to handle. + * @param listener The listener (event handler function) to associate with the event. + * @param useCapture Set to true to register the listener for the capturing phase; otherwise, set to false to register the listener for the bubbling phase. + **/ + function addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with the specified additional properties. + * @param type The name of the event to raise. + * @param details The set of additional properties to attach to the event object. + **/ + function dispatchEvent(type: string, details: Object): void; + + /** + * Retrieves the resource string that has the specified resource identifier. + * @param resourceId The resource ID of the string to retrieve. + * @returns An object that can contain these properties: value, empty, lang. + **/ + function getString(resourceId: string): Object; + + /** + * Processes data-win-res attributes on elements and replaces attributes and properties with resource strings. + * @param rootElement The element to process. The element and its child elements will be processed. If an element isn't specified, the entire document is processed. + **/ + function processAll(rootElement?: HTMLElement): void; + + /** + * Removes an event listener that the addEventListener method registered. + * @param type The name of the event that the event listener is registered for. + * @param listener The listener (event handler function) to remove. + * @param useCapture Set to true to remove the capturing phase listener; set to false to remove the bubbling phase listener. + **/ + function removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + //#endregion Functions + + //#region Events + + /** + * Occurs when the user changes the system's language or contrast, or the scale of the display, or when the user changes any of the items in the current context's qualifier values list. For more info about the current context's qualifier values list, see the Remarks section. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.qualifier, detail.changed. + **/ + function oncontextchanged(eventInfo: CustomEvent): void; + + //#endregion Events + +} +/** + * Provides access to the Windows animations. These functions provide developers with the ability to use animations in their custom controls that are consistent with animations used by Windows controls. +**/ +declare module WinJS.UI.Animation { + //#region Functions + + /** + * Creates an object that performs an animation that adds an item or items to a list. + * @param added Element or elements to add to the list. + * @param affected Element or elements affected by the added items. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. + **/ + function createAddToListAnimation(added: Object, affected: Object): IAnimationMethodResponse; + + /** + * Creates an object that performs an animation that adds an item or items to a list of search results. + * @param added Element or elements to add to the list. + * @param affected Element or elements affected by the added items. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. + **/ + function createAddToSearchListAnimation(added: Object, affected: Object): IAnimationMethodResponse; + + /** + * Creates an object that performs an animation that collapses a list. + * @param hidden Element or elements hidden as a result of the collapse. + * @param affected Element or elements affected by the hidden items. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. + **/ + function createCollapseAnimation(hidden: Object, affected: Object): IAnimationMethodResponse; + + /** + * Creates an object that performs an animation that removes an item or items from a list. + * @param deleted Element or elements to delete from the list. + * @param remaining Element or elements affected by the removal of the deleted items. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. + **/ + function createDeleteFromListAnimation(deleted: Object, remaining: Object): IAnimationMethodResponse; + + /** + * Creates an object that performs an animation that removes an item or items from a list of search results. + * @param deleted Element or elements to delete from the list. + * @param remaining Element or elements affected by the removal of the deleted items. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. + **/ + function createDeleteFromSearchListAnimation(deleted: Object, remaining: Object): IAnimationMethodResponse; + + /** + * Creates an object that performs an animation that expands a list. + * @param revealed Element or elements revealed by the expansion. + * @param affected Element or elements affected by the newly revealed items. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. + **/ + function createExpandAnimation(revealed: Object, affected: Object): IAnimationMethodResponse; + + /** + * Creates an object that performs a peek animation. + * @param element Element or elements involved in the peek. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. + **/ + function createPeekAnimation(element: Object): IAnimationMethodResponse; + + /** + * Creates an object that performs an animation that moves an item or items. + * @param element Element or elements involved in the reposition. + * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise object that completes when the animation is finished. + **/ + function createRepositionAnimation(element: Object): IAnimationMethodResponse; + + /** + * Performs an animation that fades an item or items in, fading out existing items that occupy the same space. + * @param incoming Element or elements being faded in. + * @param outgoing Element or elements being replaced. + * @returns An object that completes when the animation has finished. + **/ + function crossFade(incoming: Object, outgoing: Object): Promise; + + /** + * Performs an animation when a dragged object is moved such that dropping it in that position would move other items. The potentially affected items are animated out of the way to show where the object would be dropped. + * @param target Element or elements that the dragged object would cause to be moved if it were dropped. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function dragBetweenEnter(target: Object, offset: Object): Promise; + + /** + * Performs an animation when a dragged object is moved away from items that it had previously involved in a dragBetweenEnter animation. The affected objects are animated back to their original positions. + * @param target Element or elements that the dragged object would no longer cause to be displaced, due to its moving away. This should be the same element or element collection passed as the target parameter in the dragBetweenEnter animation. + * @returns An object that completes when the animation is finished. + **/ + function dragBetweenLeave(target: Object): Promise; + + /** + * Performs an animation when the user finishes dragging an object. + * @param dragSource Element or elements that were dragged. + * @param offset Initial offset from the drop point. The dropped object begins at the offset and animates to its final position at the drop point. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @param affected Element or elements whose position the dropped object affects. Typically, this is all other items in a reorderable list. This should be the same element or element collection passed as the affected parameter in the dragSourceStart animation. + * @returns An object that completes when the animation is finished. + **/ + function dragSourceEnd(dragSource: Object, offset: Object, affected?: Object): Promise; + + /** + * Performs an animation when the user begins to drag an object. + * @param dragSource Element or elements being dragged. + * @param affected Element or elements whose position is affected by the movement of the dragged object. Typically, this is all other items in a reorderable list. + * @returns An object that completes when the animation is finished. + **/ + function dragSourceStart(dragSource: Object, affected?: Object): Promise; + + /** + * Performs an animation that displays one or more elements on a page. + * @param incoming Element or elements that compose the incoming content. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance. + * @returns An object that completes when the animation is finished. + **/ + function enterContent(incoming: Object, offset: Object, options: Object): Promise; + + /** + * Performs an animation that shows a new page of content, either when transitioning between pages in a running app or when displaying the first content in a newly launched app. + * @param element Element or an array of elements that represent the content. If element refers to an array of elements, the elements enter in array order. + * @param offset An initial offset where the element or elements begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function enterPage(element: Object, offset: Object): Promise; + + /** + * Performs an animation that hides one or more elements on a page. + * @param outgoing Element or elements that compose the outgoing content. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function exitContent(outgoing: Object, offset: Object): Promise; + + /** + * Performs an animation that dismisses the current page when transitioning between pages in an app. + * @param outgoing Element or elements that compose the outgoing page. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function exitPage(outgoing: Object, offset: Object): Promise; + + /** + * Performs an animation that fades an item or set of items into view. + * @param shown Element or elements being faded in. + * @returns An object that completes when the animation has finished. Use this object when subsequent actions need this animation to finish before they take place. + **/ + function fadeIn(shown: Object): Promise; + + /** + * Performs an animation that fades an item or set of items out of view. + * @param hidden Element or elements being faded out. + * @returns An object that completes when the animation is finished. + **/ + function fadeOut(hidden: Object): Promise; + + /** + * Performs an animation that hides edge-based user interface (UI). + * @param element Element or elements that are being hidden. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements end the animation just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance. + * @returns An object that completes when the animation is finished. + **/ + function hideEdgeUI(element: Object, offset: Object, options: Object): Promise; + + /** + * Performs an animation that hides a panel. + * @param element Element or elements that are being hidden. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements end the animation just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function hidePanel(element: Object, offset: Object): Promise; + + /** + * Performs an animation that removes pop-up user interface (UI). + * @param element Element or elements that are being hidden. + * @returns An object that completes when the animation is finished. + **/ + function hidePopup(element: Object): Promise; + + /** + * Performs an animation when a pointer is pressed on an object. + * @param element Element or elements on which the pointer is pressed. + * @returns An object that completes when the animation is finished. + **/ + function pointerDown(element: Object): Promise; + + /** + * Performs an animation when a pointer is released. + * @param element Element or elements that the pointer was pressed on. + * @returns An object that completes when the animation is finished. + **/ + function pointerUp(element: Object): Promise; + + /** + * Performs an animation that slides a narrow, edge-based user interface (UI) into view. + * @param element Element or elements that are being shown. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance. + * @returns An object that completes when the animation is finished. + **/ + function showEdgeUI(element: Object, offset: Object, options: Object): Promise; + + /** + * Performs an animation that slides a large panel user interface (UI) into view. + * @param element Element or elements that are being shown. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function showPanel(element: Object, offset: Object): Promise; + + /** + * Performs an animation that displays a pop-up user interface (UI). + * @param element Element or elements that are being shown. + * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function showPopup(element: Object, offset: Object): Promise; + + /** + * Performs a deselection animation in response to a swipe interaction. + * @param deselected Element or elements that become unselected. + * @param selection Element or elements that represent the selection, typically a check mark. + * @returns An object that completes when the animation is finished. + **/ + function swipeDeselect(deselected: Object, selection: Object): Promise; + + /** + * Performs an animation that reveals an item or items in response to a swipe interaction. + * @param target Element or elements being revealed. + * @param offset An initial offset where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function swipeReveal(target: Object, offset: Object): Promise; + + /** + * Performs a selection animation in response to a swipe interaction. + * @param selected Element or elements being selected. + * @param selection Element or elements that show that something is selected, typically a check mark. + * @returns An object that completes when the animation is finished. + **/ + function swipeSelect(selected: Object, selection: Object): Promise; + + /** + * Performs an animation that updates a badge. + * @param incoming Element or elements that comprise the new badge. + * @param offset Initial offsets where incoming animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. + * @returns An object that completes when the animation is finished. + **/ + function updateBadge(incoming: Object, offset: Object): Promise; + + //#endregion Functions + + //#region Interfaces + + interface IAnimationMethodResponse { + execute(): Promise; + } + + //#endregion Interfaces + +} +/** + * Provides controls and objects that manipulate data. +**/ +declare module WinJS.UI { + //#region Enumerations + + /** + * Specifies an icon that appears in an AppBarCommand object. + **/ + enum AppBarIcon { + previous, + next, + play, + pause, + edit, + save, + clear, + delete, + remove, + add, + cancel, + accept, + more, + redo, + undo, + home, + up, + forward, + right, + back, + left, + favorite, + camera, + settings, + video, + sync, + download, + mail, + find, + help, + upload, + emoji, + twopage, + leavechat, + mailforward, + clock, + send, + crop, + rotatecamera, + people, + closepane, + openpane, + world, + flag, + previewlink, + globe, + trim, + attachcamera, + zoomin, + bookmarks, + document, + protecteddocument, + page, + bullets, + comment, + mail2, + contactinfo, + hangup, + viewall, + mappin, + phone, + videochat, + switch, + contact, + rename, + pin, + musicinfo, + go, + keyboard, + dockleft, + dockright, + dockbottom, + remote, + refresh, + rotate, + shuffle, + list, + shop, + selectall, + orientation, + import, + importall, + browsephotos, + webcam, + pictures, + savelocal, + caption, + stop, + showresults, + volume, + repair, + message, + page2, + calendarday, + calendarweek, + calendar, + characters, + mailreplyall, + read, + link, + accounts, + showbcc, + hidebcc, + cut, + attach, + paste, + filter, + copy, + emoji2, + important, + mailreply, + slideshow, + sort, + manage, + allapps, + disconnectdrive, + mapdrive, + newwindow, + openwith, + contactpresence, + priority, + uploadskydrive, + gototoday, + font, + fontcolor, + contact2, + folder, + audio, + placeholder, + view, + setlockscreen, + settile, + cc, + stopslideshow, + permissions, + highlight, + disableupdates, + unfavorite, + unpin, + openlocal, + mute, + italic, + underline, + bold, + movetofolder, + likedislike, + dislike, + like, + alignright, + aligncenter, + alignleft, + zoom, + zoomout, + openfile, + otheruser, + admin, + street, + map, + clearselection, + fontdecrease, + fontincrease, + fontsize, + cellphone, + reshare, + tag, + repeatone, + repeatall, + outlinestar, + solidstar, + calculator, + directions, + target, + library, + phonebook, + memo, + microphone, + postupdate, + backtowindow, + fullscreen, + newfolder, + calendarreply, + unsyncfolder, + reporthacked, + syncfolder, + blockcontact, + switchapps, + addfriend, + touchpointer, + gotostart, + zerobars, + onebar, + twobars, + threebars, + fourbars, + scan, + preview + } + + /** + * Indicates whether the IListDataAdapter was able to provide a count. + **/ + enum CountResult { + /** + * Indicates no count is available. + **/ + unknown + } + + /** + * Indicates that the IListDataAdapter was unable to provide a count. + **/ + enum CountError { + /** + * An attempt to count items timed out. + **/ + noResponse + } + + /** + * Describes the status of an IListDataSource. + **/ + enum DataSourceStatus { + /** + * The IListDataSource is ready. + **/ + ready, + /** + * The IListDataSource is still loading. + **/ + waiting, + /** + * The IListDataSource failed to load. + **/ + failure + } + + /** + * Specifies the type of error that occurred during an edit operation on a IListDataSource or an IListDataAdapter. + **/ + enum EditError { + /** + * The edit operation timed out. + **/ + noResponse, + /** + * The data source cannot be written to. + **/ + notPermitted, + /** + * The item has changed. + **/ + noLongerMeaningful + } + + /** + * Specifies the type of error encountered when retrieving items from an IListDataAdapter. + **/ + enum FetchError { + /** + * The fetch operation timed out. + **/ + noResponse, + /** + * The specified item could not be located. + **/ + doesNotExist + } + + /** + * Specifies how group headers in a ListView respond to the tap interaction. + **/ + enum GroupHeaderTapBehavior { + /** + * The group is invoked. + **/ + invoke, + /** + * Nothing happens. + **/ + none + } + + /** + * Specifies the position of group headers relative to their items in a ListView. + **/ + enum HeaderPosition { + /** + * Group headers appear to the left of items. + **/ + left, + /** + * Group headers appear above items. + **/ + top + } + + /** + * Specifies that type of animation for which a contentanimating event was raised. + **/ + enum ListViewAnimationType { + /** + * The animation plays when the ListView is first displayed. + **/ + entrance, + /** + * The animation plays when the ListView is changing its content. + **/ + contentTransition + } + + /** + * Describes the type of object in a ListView. + **/ + enum ObjectType { + /** + * The object is a group header in the list. + **/ + groupHeader, + /** + * The object is an item in the list. + **/ + item + } + + /** + * Specifies the orientation of a control. + **/ + enum Orientation { + /** + * A horizontal layout. + **/ + horizontal, + /** + * A vertical layout. + **/ + vertical + } + + /** + * Specifies the selection mode of a ListView. + **/ + enum SelectionMode { + /** + * Items cannot be selected. + **/ + none, + /** + * A single item may be selected. + **/ + single, + /** + * Multiple items may be selected. Clicking additional items adds them to the selection. + **/ + multi + } + + /** + * Specifies whether elements are selected when the user performs a swipe interaction. + **/ + enum SwipeBehavior { + /** + * The swipe interaction selects the elements touched by the swipe. + **/ + select, + /** + * The swipe interaction does not change which elements are selected. + **/ + none + } + + /** + * Specifies how items in a ListView respond to the tap interaction. + **/ + enum TapBehavior { + /** + * The item is selected and invoked. + **/ + directSelect, + /** + * The item is selected if was not already selected, and its deselected if it was already selected. + **/ + toggleSelect, + /** + * The item is invoked but not selected. + **/ + invokeOnly, + /** + * Nothing happens. + **/ + none + } + + //#endregion Enumerations + + //#region Interfaces + + /** + * Contains items that were requested from an IListDataAdapter and provides some information about those items. + **/ + interface IFetchResult { + //#region Properties + + /** + * Gets or sets the index of the requested item in the IListDataAdapter object's data source. + **/ + absoluteIndex: number; + + /** + * Gets or sets a value that indicates whether this IFetchResult contains the last items at the end of the IListDataAdapter object's data source. + **/ + atEnd: boolean; + + /** + * Gets or sets a value that indicates whether this IFetchResult contains the first items at the beginning of the IListDataAdapter object's data source. + **/ + atStart: boolean; + + /** + * Gets or sets the items returned by the fetch operation. + **/ + items: T[]; + + /** + * Gets or sets the location of the requested item within the items array. + **/ + offset: number; + + /** + * Gets or sets the number of items in the IListDataAdapter object's underlying data source. + **/ + totalCount: number; + + //#endregion Properties + + } + + /** + * Represents an item in a list. + **/ + interface IItem { + //#region Properties + + /** + * Gets or sets the item's data. + **/ + data: T; + + /** + * Gets the group key for the item. This property is only available for items that belong to a grouped data source. + **/ + groupKey: string; + + /** + * Gets the temporary ID of the item. + **/ + handle: string; + + /** + * Gets the item's index in the IListDataSource. + **/ + index: number; + + /** + * Gets or sets the key the identifies the item. + **/ + key: string; + + //#endregion Properties + + } + + /** + * Provides a mechanism for retrieving IItem objects asynchronously. + **/ + interface IItemPromise { + //#region Events + + /** + * Occurs when there is an error in processing. + * @param eventInfo An object that contains information about the event. + **/ + onerror(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and cancellation is supported, the promise enters the error state with a value of Error("Canceled"). + **/ + cancel(): void; + + /** + * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state. + * @param onComplete The function to be called if the promise is fulfilled successfully with a value. The fulfilled value is passed as the single argument. If the value is null, the fulfilled value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while executing the function, the promise returned by then moves into the error state. + * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function is the fulfilled value of the promise returned by then. + * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. + **/ + done(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: Object) => void): void; + + /** + * Stops change notification tracking for the IItem that fulfills this IItemPromise. + **/ + release(): void; + + /** + * Begins change notification tracking for the IItem that fulfills this IItemPromise. + **/ + retain(): void; + + /** + * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. + * @param onComplete The function to be called if the promise is fulfilled successfully with a value. The value is passed as the single argument. If the value is null, the value is returned. The value returned from the function becomes the fulfilled value of the promise returned by then. If an exception is thrown while this function is being executed, the promise returned by then moves into the error state. + * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function becomes the fulfilled value of the promise returned by then. + * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. + * @returns The promise whose value is the result of executing the complete or error function. + **/ + then(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: Object) => void): IItemPromise; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the temporary ID of the IItem that fulfills this promise. + **/ + handle: string; + + /** + * Gets or sets the index of the IItem contained by this IItemPromise. + **/ + index: number; + + //#endregion Properties + + } + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. Represents a layout for the ListView. + **/ + interface ILayout { + //#region Methods + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param beginScrollPosition The first visible pixel in the ListView. For horizontal layouts, this is the x-coordinate of the pixel. For vertical layouts, this is the y-coordinate. + * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. + * @returns A Promise for the index of the first visible item at the specified point. + **/ + calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): Promise; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param endScrollPosition The last visible pixel in the ListView. For horizontal layouts, this is the x-coordinate of the pixel. For vertical layouts, this is the y-coordinate. + * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. + * @returns A Promise for the index of the last visible item at the specified point. + **/ + calculateLastVisible(endScrollPosition: number, wholeItem: boolean): Promise; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @returns A object that has these properties: animationPromise, newEndIndex. + **/ + endLayout(): Object; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param itemIndex The index of the item. + * @returns A Promise that returns an object with these properties: left, top, contentWidth, contentHeight, totalWidth, totalHeight. + **/ + getItemPosition(itemIndex: number): Promise; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param itemIndex The data source index of the current item. + * @param element The element for the current item. + * @param keyPressed The key that was pressed. This function must check for the arrow keys (leftArrow, upArrow, rightArrow, downArrow), pageDown, and pageUp and determine which item the user navigated to. + * @returns A Promise that contains the index of the next item (This item becomes the current item). + **/ + getKeyboardNavigatedItem(itemIndex: number, element: HTMLElement, keyPressed: WinJS.Utilities.Key): Promise; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @returns A Promise that returns an object that has these properties: beginScrollPosition, endScrollPosition. + **/ + getScrollBarRange(): Promise; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param x The x-coordinate to test. + * @param y The y-coordinate to test. + **/ + hitTest(x: number, y: number): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param elements The elements that represent the items that were added. + **/ + itemsAdded(elements: HTMLElement[]): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + **/ + itemsMoved(): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param elements The elements that represent the items that were removed. + **/ + itemsRemoved(elements: HTMLElement[]): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param groupIndex The index of the group in the group data source. + * @param element The element to render for the group header. + **/ + layoutHeader(groupIndex: number, element: HTMLElement): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param itemIndex The index of the item in the data source. + * @param element The element to render for the item. + **/ + layoutItem(itemIndex: number, element: HTMLElement): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param element The element that represents a header in the data source. + **/ + prepareHeader(element: HTMLElement): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param element An element that represents an item in the data source. + **/ + prepareItem(element: HTMLElement): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param element The element being released. + **/ + releaseItem(element: HTMLElement): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + **/ + reset(): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param site The layout site for the layout. You can use this object to query the hosting ListView for info you might need to lay out items. + **/ + setSite(site: ILayoutSite): void; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + * @param beginScrollPosition The starting pixel of the area to which the items are rendered. + * @param endScrollPosition The last pixel of the area to which the items are rendered. + * @param count The upper bound of the number of items to render. + * @returns A Promise that returns an object that has these properties: beginIndex, endIndex. + **/ + startLayout(beginScrollPosition: number, endScrollPosition: number, count: number): Promise; + + //#endregion Methods + + //#region Properties + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. + **/ + horizontal: boolean; + + //#endregion Properties + + } + + /** + * Represents a layout for the ListView. + **/ + interface ILayout2 { + //#region Methods + + /** + * Called when the ListView finishes a drag operation. + **/ + dragLeave(): void; + + /** + * Called when the ListView initiates a drag operation. + * @param x The x-coordinate of the drag. + * @param y The y-coordinate of the drag. + * @param dragInfo An object that indicates whether the item is selected. + **/ + dragOver(x: number, y: number, dragInfo: number): void; + + /** + * Called when the ListView requests that the ILayout2 execute animations. + **/ + executeAnimations(): void; + + /** + * Determines the next item to receive keyboard focus. + * @param currentItem An object that describes the current item. It has these properties: index, type. + * @param pressedKey The key that was pressed. + * @returns An object that describes the next item that should receive focus. It has these properties: index, type. + **/ + getAdjacent(currentItem: Object, pressedKey: WinJS.Utilities.Key): Object; + + /** + * Gets the item at the specified hit-test coordinates. These coordinates are absolute coordinates (they are not relative to the layout's content area). + * @param x The x-coordinate to test for. + * @param y The y-coordinate to test for. + * @returns An object that describes the item at the hit test coordinates. It has these properties: type, index. + **/ + hitTest(x: number, y: number): Object; + + /** + * Sets the rendering site and specifies whether the layout supports groups. This method is called by the ListView to initialize the layout. + * @param site The rendering site for the layout. + * @param groupsEnabled Set to true if this layout supports groups; set to false if it does not. + **/ + initialize(site: ILayoutSite2, groupsEnabled: boolean): void; + + /** + * Retrieves the indexes of the items in the specified pixel range. + * @param firstPixel The first pixel the range of items falls between. + * @param lastPixel The last pixel the range of items falls between. + **/ + itemsFromRange(firstPixel: number, lastPixel: number): void; + + /** + * Performs a layout pass. + * @param tree A structure representing the layout tree that is returned from the ListView. + * @param changedRange An object that lists the index of the first item in the changed item range. This object has these properties: startIndex. + * @param modifiedItems An object that contains the old and new indexes of the items that have been modified in the tree. + * @param modifiedGroups An object that contains the old and new indexes of the group elements that have been modified in the tree. + * @returns A Promise that executes after layout is complete, or an object that contains two Promise objects: realizedRangeComplete, layoutComplete. + **/ + layout(tree: Object, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): Object; + + /** + * Called when the ListView requests that the ILayout2 set up animations. + **/ + setupAnimations(): void; + + /** + * Releases resources that were obtained during the call to initialize. + **/ + uninitialize(): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the orientation of the layout. + **/ + orientation: any; + + //#endregion Properties + + } + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayoutSite2 interface. Represents a rendering site for an ILayout. + **/ + interface ILayoutSite { + //#region Properties + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. + **/ + animationsDisabled: boolean; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. + **/ + itemSurface: HTMLElement; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. + **/ + rtl: boolean; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. + **/ + scrollbarPos: number; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. + **/ + surface: HTMLElement; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. + **/ + viewport: HTMLElement; + + /** + * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. + **/ + viewportSize: Object; + + //#endregion Properties + + } + + /** + * Represents a rendering site for an ILayout2. + **/ + interface ILayoutSite2 { + //#region Properties + + /** + * Gets the number of groups in the site. + **/ + groupCount: number; + + /** + * Gets the number of items in the site. + **/ + itemCount: Promise; + + /** + * Gets the pixel range of the realization area. + **/ + realizedRange: Object; + + /** + * Gets the tree for use by an object that implements the ILayout2 interface. + **/ + tree: Object; + + /** + * Gets the pixel range of visible items in the site. + **/ + visibleRange: any; + + //#endregion Properties + + } + + /** + * Retrieves items from a IListDataSource, enumerates the contents of a IListDataSource, and can optionally register for change notifications. + **/ + interface IListBinding { + //#region Methods + + /** + * Retrieves the current item. + * @returns An IItemPromise that contains the current item. If the cursor has moved past the start or end of the list, the promise completes with a value of null. If the current item has been moved or deleted, the promise returns an error. + **/ + current(): IItemPromise>; + + /** + * Gets the first item from the IListDataSource and makes it the current item. + * @returns An IItemPromise that contains the requested IItem. If the list is empty, the promise completes with a value of null. + **/ + first(): IItemPromise>; + + /** + * Retrieves the item from the IListDataSource that has the specified description and makes it the current item. + * @param description A domain-specific description, to be interpreted by the IListDataAdapter, that identifies the item to retrieve. + * @returns An IItemPromise that contains the requested IItem object. If the item wasn't found, the promise completes with a value of null. + **/ + fromDescription(description: string): IItemPromise>; + + /** + * Retrieves the item from the IListDataSource that has the specified index and makes it the current item. + * @param index A value greater than or equal to 0 that is the index of the item to retrieve. + * @returns An IItemPromise that contains the requested IItem. If the item wasn't found, the promise completes with a value of null. + **/ + fromIndex(index: number): IItemPromise>; + + /** + * Retrieves the item from the IListDataSource that has the specified key and makes it the current item. + * @param key The key that identifies the item to retrieve. This value must be a non-empty string. + * @param hints Domain-specific information that provides additional information to the IListDataAdapter to improve retrieval time. + * @returns An IItemPromise that contains the requested IItem. If they item couldn't be found, the promise completes with a value of null. + **/ + fromKey(key: string, hints?: Object): IItemPromise>; + + /** + * Makes the specified IItem or IItemPromise the current item. + * @param item The IItem or IItemPromise that will become the current item. + * @returns An IItemPromise that contains the specified item, if it exists. If the specified item is not in the list, the promise completes with a value of null. + **/ + jumpToItem(item: IItem): IItemPromise>; + + /** + * Retrieves the last item in the IListDataSource and makes it the current item. + * @returns An IItemPromise that contains the requested IItem. f the list is empty, the promise completes with a value of null. + **/ + last(): IItemPromise>; + + /** + * Retrieves the item after the current item and makes it the current item. + * @returns An IItemPromise that contains the item after the current item. If the cursor moves past the end of the list, the promise completes with a value of null. + **/ + next(): IItemPromise>; + + /** + * Retrieves the item before the current item and makes it the current item. + * @returns An IItemPromise that contains the item before the current item. If the cursor moves past the start of the list, the promise completes with a value of null. + **/ + previous(): IItemPromise>; + + /** + * Releases resources, stops notifications, and cancels outstanding promises for all tracked items returned by this IListBinding. + **/ + release(): void; + + /** + * Creates a request to stop change notifications for the specified item. The change notifications stop when the number of releaseItem calls matches the number of IIItemPromise.retain calls. + * @param item The IItem or IItemPromise that should stop receiving notifications. + **/ + releaseItem(item: IItem): void; + + //#endregion Methods + + } + + /** + * Accesses data for an IListDataSource. + **/ + interface IListDataAdapter { + //#region Methods + + /** + * Overwrites the data of the specified item. + * @param key The key of the item to overwrite. + * @param newData The new data for the item. + * @param indexHint The index of the item, if known. + * @returns A Promise that returns null or undefined when the operation completes. + **/ + change(key: string, newData: T, indexHint: number): Promise; + + /** + * Gets the number of items in the IListDataAdapter object's data source. + * @returns A Promise that contains the number of items the IListDataAdapter contains, or an approximate value if the actual number is unknown. + **/ + getCount(): Promise; + + /** + * Inserts the specified data after the specified item. + * @param key A key that can be used to retrieve the new data. + * @param data The new data to add to the IListDataAdapter object's data source. + * @param previousKey The key of an item in the IListDataAdapter object's data source. The new data will be inserted after this item. + * @param previousIndexHint The index of the item to insert the new data after, if known. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertAfter(key: string, data: T, previousKey: string, previousIndexHint: number): Promise>; + + /** + * Adds the specified key and data to the end of the IListDataAdapter object's data source. + * @param key A key that can be used to retrieve the new data. + * @param data The new data to add to the IListDataAdapter object's data source. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertAtEnd(key: string, data: T): Promise>; + + /** + * Adds the specified key and data to the beginning of the IListDataAdapter object's data source. + * @param key A key that can be used to retrieve the new data. + * @param data The new data to add to the IListDataAdapter object's data source. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertAtStart(key: string, data: T): Promise>; + + /** + * Inserts the specified data before the specified item. + * @param key A key that can be used to retrieve the new data. + * @param data The new data to add to the IListDataAdapter object's data source. + * @param nextKey The key of an item in the IListDataAdapter object's data source. The new data will be inserted before this item. + * @param nextIndexHint The index of the item to insert the new data before, if known. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertBefore(key: string, data: T, nextKey: string, nextIndexHint: number): Promise>; + + /** + * Retrieves the item that matches the specified description and also retrieves the specified number of items before and after the matched item. + * @param description A description of the item to locate. + * @param countBefore The number of items before the matched item to retrieve. + * @param countAfter The number of items after the matched item to retrieve. + * @returns A Promise that provides an IFetchResult that contains the selected items or a FetchError if an error was encountered. + **/ + itemsFromDescription(description: string, countBefore: number, countAfter: number): Promise>; + + /** + * Retrieves the specified number of items from the end of the IListDataAdapter object's data source. + * @param count The number of items to retrieve. + * @returns A Promise that provides an IFetchResult that contains the selected items or a FetchError if an error was encountered. + **/ + itemsFromEnd(count: number): Promise>; + + /** + * Retrieves the item at the specified index and also retrieves the specified number of items before and after the selected item. + * @param index The index of the item to retrieve. + * @param countBefore The number of items to retrieve from before the selected item. + * @param countAfter The number of items to retrieve from after the selected item. + * @returns A Promise that provides an IFetchResult that contains the selected items or a FetchError if an error was encountered. + **/ + itemsFromIndex(index: number, countBefore: number, countAfter: number): Promise>; + + /** + * Retrieves the item that has the specified key and also retrieves the specified number of items before and after the selected item. + * @param key The key of the item to retrieve. + * @param countBefore The number of items to retrieve from before the selected item. + * @param countAfter The number of items to retrieve from after the selected item. + * @returns A Promise that provides an IFetchResult that contains the selected items or a FetchError if an error was encountered. + **/ + itemsFromKey(key: string, countBefore: number, countAfter: number): Promise>; + + /** + * Retrieves the specified number of items from the beginning of the IListDataAdapter object's data source. + * @param count The number of items to retrieve. + * @returns A Promise that provides an IFetchResult that contains the selected items or a FetchError if an error was encountered. + **/ + itemsFromStart(count: number): Promise>; + + /** + * Returns a string representation of the specified item that can be used for comparisons. + * @param item The item for which to generate a signature. + * @returns The signature representation of the specified item. + **/ + itemSignature(item: IItem): string; + + /** + * Moves the specified item to just after another item. + * @param key A key of the item to move. + * @param previousKey The key of another item. The item to move will be moved to just after this item. + * @param indexHint The index of the item to move, if known. + * @param previousIndexHint The index to move the item after, if known. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + moveAfter(key: string, previousKey: Object, indexHint: string, previousIndexHint: number): Promise>; + + /** + * Moves the specified item to just before another item. + * @param key A key of the item to move. + * @param nextKey The key of another item. The item to move will be moved to just before this item. + * @param indexHint The index of the item to move, if known. + * @param nextIndexHint The index to move the item before, if known. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + moveBefore(key: string, nextKey: Object, indexHint: string, nextIndexHint: number): Promise>; + + /** + * Moves the specified item to the end of the IListDataAdapter object's data source. + * @param key The key for the item to move. + * @param indexHint The index of the item to move, if known. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + moveToEnd(key: string, indexHint: number): Promise>; + + /** + * Moves the specified item to the beginning of the IListDataAdapter object's data source. + * @param key The key for the item to move. + * @param indexHint The index of the item to move, if known. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + moveToStart(key: string, indexHint: number): Promise>; + + /** + * Removes the specified item from the IListDataAdapter object's data source. + * @param key The key of the item to remove. + * @param data The new data for the item. + * @param indexHint The index of the item. + * @returns A Promise that returns null or undefined when the operation completes. + **/ + remove(key: string, data: T, indexHint: number): Promise; + + /** + * Registers a notification handler. The IListDataAdapter uses the handler to notify listening objects when its data changes. + * @param notificationHandler The notification handler that the IListDataAdapter will use to provide change notifications. . + **/ + setNotificationHandler(notificationHandler: IListDataNotificationHandler): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that specifies whether to use an object's identity to determine if an item has changed. + **/ + compareByIdentity: boolean; + + //#endregion Properties + + } + + /** + * Notifies clients when an IListDataAdapter object's data changes. + **/ + interface IListDataNotificationHandler { + //#region Methods + + /** + * Indicates the start of a notification batch. Objects that are listening for notifications should defer making updates until endNotifications is called. + **/ + beginNotifications(): void; + + /** + * Raises a notification that an item in the IListDataAdapter object's data source has changed. + * @param item The item that changed. + **/ + changed(item: IItem): void; + + /** + * Indicates the end of a notification batch. When the beginNotifications method is called, objects listening for notifications should defer making updates until endNotifications is called. + **/ + endNotifications(): void; + + /** + * Raises a notification that an item has been added to the IListDataAdapter object's data source. + * @param newItem The new item added to the IListDataAdapter object's data source. + * @param previousKey The key of the item that now precedes the new item, or null if the item was inserted at the start of the list. If nextKey is provided, this parameter may be null. + * @param nextKey The key of the item that now follows the new item, or null if the item was inserted at the end of the list. If previousKey is provided, this parameter may be null. + * @param index The index of the new item. + **/ + inserted(newItem: IItem, previousKey: string, nextKey: string, index?: number): void; + + /** + * Indicates that all previous data obtained from the IListDataAdapter is invalid and should be refreshed. + * @returns A Promise that completes when the data has been completely refreshed and all change notifications have been sent. + **/ + invalidateAll(): Promise; + + /** + * Raises a notification that an item was moved within the IListDataAdapter object's data source. + * @param item The item that was moved. + * @param previousKey The key of the item that now precedes the new item, or null if the item was moved to the beginning of the list. If nextKey is provided, this parameter may be null. + * @param nextKey The key of the item that now follows the new item, or null if the item was moved to the end of the list. If previousKey is provided, this parameter may be null. + * @param oldIndex The item's original index. + * @param newIndex The item's new index. + **/ + moved(item: IItem, previousKey: string, nextKey: string, oldIndex?: number, newIndex?: number): void; + + /** + * Reloads data from the IListDataAdapter. + **/ + reload(): void; + + /** + * Raises a notification that an item was removed from the IListDataAdapter object's data source. + * @param key The key of the item that was removed. + * @param index The index of the item that was removed. + **/ + removed(key: string, index?: number): void; + + //#endregion Methods + + } + + /** + * Provides access to a data source and enables you to bind, change, add, remove, and move items in that data source. + **/ + interface IListDataSource { + //#region Events + + /** + * Occurs when the status of the IListDataSource changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: status. + **/ + statuschanged(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Notifies the IListDataSource that a sequence of edits is about to begin. The IListDataSource will defer notifications until endEdits is called. + **/ + beginEdits(): void; + + /** + * Overwrites the data of the specified item. + * @param key The key for the item to replace. + * @param newData The new data for the item. + * @returns A Promise that contains the IItem that was updated or an EditError if an error was encountered. + **/ + change(key: string, newData: T): Promise>; + + /** + * Creates an IListBinding that can retrieve items from the IListDataSource, enumerate the contents of the IListDataSource object's data, and optionally register for change notifications. + * @param notificationHandler Enables the IListBinding to register for change notifications for individual items obtained from the IListDataSource. If you omit this parameter, change notifications won't be available. + * @returns The new IListBinding. + **/ + createListBinding(notificationHandler?: IListNotificationHandler): IListBinding; + + /** + * Notifies the IListDataSource that the batch of edits that began with the last beginEdits call has completed. The IListDataSource will submit notifications for any changes that occurred between the beginEdits and endEdits calls as a batch and resume normal change notifications. + **/ + endEdits(): void; + + /** + * Retrieves the number of items in the data source. + * @returns A Promise that provides a Number that is the number of items in the data source. + **/ + getCount(): Promise; + + /** + * Inserts a new item after another item. + * @param key The key that can be used to retrieve the new item, if known. + * @param data The data for the item to add. + * @param previousKey The key for an item in the data source. The new item will be added after this item. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertAfter(key: string, data: T, previousKey: string): Promise>; + + /** + * Adds an item to the end of the data source. + * @param key The key that can be used to retrieve the new item, if known. + * @param data The data for the item to add. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertAtEnd(key: string, data: T): Promise>; + + /** + * Adds an item to the beginning of the data source. + * @param key The key that can be used to retrieve the new item, if known. + * @param data The data for the item to add. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertAtStart(key: string, data: T): Promise>; + + /** + * Inserts an item before another item. + * @param key The key that can be used to retrieve the new item, if known. + * @param data The data for the item to add. + * @param nextKey The key of an item in the data source. The new item will be inserted before this item. + * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. + **/ + insertBefore(key: string, data: T, nextKey: string): Promise>; + + /** + * Indicates that all previous data obtained from the IListDataAdapter is invalid and should be refreshed. + * @returns A Promise that completes when the data has been completely refreshed and all notifications have been sent. + **/ + invalidateAll(): Promise; + + /** + * Retrieves the item that has the specified description. + * @param description Domain-specific information, to be interpreted by the IListDataAdapter, that describes the item to retrieve. + * @returns A Promise that provides an IItem that contains the requested item or a FetchError if an error was encountered. If the item wasn't found, the promise completes with a value of null. + **/ + itemFromDescription(description: Object): Promise>; + + /** + * Retrieves the item at the specified index. + * @param index A value that is greater than or equal to zero that is the index of the item to retrieve. + * @returns A Promise that provides an IItem that contains the requested item or a FetchError if an error was encountered. If the item wasn't found, the promise completes with a value of null. + **/ + itemFromIndex(index: number): Promise>; + + /** + * Retrieves the item with the specified key. + * @param key The key of the item to retrieve. It must be a non-empty string. + * @param description Domain-specific information that IListDataAdapter can use to improve the retrieval time. + * @returns A Promise that provides an IItem that contains the requested item or a FetchError if an error was encountered. If the item was not found, the promise completes with a null value. + **/ + itemFromKey(key: string, description?: Object): Promise>; + + /** + * Moves an item to just after another item. + * @param key The key that identifies the item to move. + * @param previousKey The key of another item in the data source. The item specified by the key parameter will be moved after this item. + * @returns A Promise that contains the IItem that was moved or an EditError if an error was encountered. + **/ + moveAfter(key: string, previousKey: string): Promise>; + + /** + * Moves an item before another item. + * @param key The key that identifies the item to move. + * @param nextKey The key of another item in the data source. The item specified by the key parameter will be moved before this item. + * @returns A Promise that contains the IItem that was moved or an EditError if an error was encountered. + **/ + moveBefore(key: string, nextKey: string): Promise>; + + /** + * Moves an item to the end of the data source. + * @param key The key that identifies the item to move. + * @returns A Promise that contains the IItem that was moved or an EditError if an error was encountered. + **/ + moveToEnd(key: string): Promise>; + + /** + * Moves the specified item to the beginning of the data source. + * @param key The key that identifies the item to move. + * @returns A Promise that contains the IItem that was moved or an EditError if an error was encountered. + **/ + moveToStart(key: string): Promise>; + + /** + * Removes the specified item from the data source. + * @param key The key that identifies the item to remove. + * @returns A Promise that contains nothing if the operation was successful or an EditError if an error was encountered. + **/ + remove(key: string): Promise>; + + //#endregion Methods + + } + + /** + * Used by an IListBinding to provide change notifications when items in a IListDataSource change. + **/ + interface IListNotificationHandler { + //#region Methods + + /** + * Indicates the start of a notification batch. Objects that are listening for notifications should defer making updates until endNotifications is called. + **/ + beginNotifications(): void; + + /** + * Indicates that an item changed. + * @param newItem The updated item. + * @param oldItem The original item. + **/ + changed(newItem: IItem, oldItem: IItem): void; + + /** + * Indicates that the number of items in the IListDataSource has changed. + * @param newCount The updated count. + * @param oldCount The original count. + **/ + countChanged(newCount: number, oldCount: number): void; + + /** + * Indicates the end of a notification batch. When the beginNotifications method is called, objects listening for notifications should defer making updates until endNotifications is called. + **/ + endNotifications(): void; + + /** + * Indicates that the index of an item changed. + * @param handle The temporary ID of the item. + * @param newIndex The new index. + * @param oldIndex The original index. + **/ + indexChanged(handle: string, newIndex: number, oldIndex: number): void; + + /** + * Indicates that an item was added to the IListDataSource. + * @param itemPromise A promise for the new IItem. + * @param previousHandle The temporary ID of the item that precedes the new item. + * @param nextHandle The temporary ID of the item that follows the new item. + **/ + inserted(itemPromise: IItemPromise, previousHandle: string, nextHandle: string): void; + + /** + * Indicates that an IItemPromise was fulfilled and that the item is now available. + * @param item The fulfilled item. + **/ + itemAvailable(item: IItem): void; + + /** + * Indicates that an item was moved. + * @param item A promise for the IItem that was moved. + * @param previousHandle The temporary ID of the item that now precedes the moved item. + * @param nextHandle The temporary ID of the item that now follows the moved item. + **/ + moved(item: IItemPromise, previousHandle: string, nextHandle: string): void; + + /** + * Indicates that an item was removed. + * @param handle The temporary ID of the item that was removed. + * @param mirage true if the item never actually existed; false if the item was actually present in the IListDataSource. + **/ + removed(handle: string, mirage: boolean): void; + + //#endregion Methods + + } + + /** + * Represents a selection of ListView items. + **/ + interface ISelection { + //#region Methods + + /** + * Adds one or more items to the selection. + * @param items The indexes or keys of the items to add. You can provide different types of objects for the items parameter: you can specify an index, a key, or a range of indexes. It can also be an array that contains one or more of these objects. For more info, see the Remarks section. + * @returns A Promise that is fulfilled when the operation completes. + **/ + add(items: Object): Promise; + + /** + * Clears the selection. + * @returns A Promise that is fulfilled when the clear operation completes. + **/ + clear(): Promise; + + /** + * Returns the number of items in the selection. + * @returns The number of items in the selection. + **/ + count(): number; + + /** + * Returns a list of the indexes for the items in the selection. + * @returns The list of indexes for the items in the selection as an array of Number objects. + **/ + getIndices(): number[]; + + /** + * Returns an array that contains the items in the selection. + * @returns A Promise that contains an array of the requested IItem objects. + **/ + getItems(): Promise[]>; + + /** + * Gets an array of the index ranges for the selected items. + * @returns An array that contains an ISelectionRange object for each index range in the selection. + **/ + getRanges(): ISelectionRange[]; + + /** + * Returns a value that indicates whether the selection contains every item in the data source. + * @returns true if the selection contains every item in the data source; otherwise, false. + **/ + isEverything(): boolean; + + /** + * Removes the specified items from the selection. + * @param items The indexes or keys of the items to remove. You can provide different types of objects for the items parameter: you can specify an index, a key, or a range of indexes. It can also be an array that contains one or more of these objects. For more info, see the Remarks section. + * @returns A Promise that is fulfilled when the operation completes. + **/ + remove(items: Object): Promise; + + /** + * Adds all the items in the ListView to the selection. + **/ + selectAll(): void; + + /** + * Clears the current selection and replaces it with the specified items. + * @param items The indexes or keys of the items that make up the selection. You can provide different types of objects for the items parameter: you can specify an index, a key, or a range of indexes. It can also be an array that contains one or more of these objects. For more info, see the Remarks section. + * @returns A Promise that is fulfilled when the operation completes. + **/ + set(items: Object): Promise; + + //#endregion Methods + + } + + /** + * Represents a range of indexes or keys in an ISelection. + **/ + interface ISelectionRange { + //#region Properties + + /** + * Gets or sets the index of the first item in the range. + **/ + firstIndex: number; + + /** + * Gets or sets the key of the first item in the range. + **/ + firstKey: Object; + + /** + * Gets or sets the index of the last item in the range. + **/ + lastIndex: number; + + /** + * Gets or sets of the key of the last item in the range. + **/ + lastKey: Object; + + //#endregion Properties + + } + + /** + * Supports semantic zoom functionality by exposing a control as either the zoomed in or the zoomed out view of the SemanticZoom control. + **/ + interface IZoomableView { + //#region Methods + + /** + * Initiates semantic zoom on the custom control. + **/ + beginZoom(): void; + + /** + * Initializes the semantic zoom state for the custom control. + * @param isZoomedOut True if this is the zoomed out view; otherwise false. + * @param isCurrentView True if this is the current view; otherwise false. + * @param triggerZoom The function that manages semantic zoom behavior. Triggers a zoom in or zoom out if the control is the visible control. + * @param prefetchedPages The number of pages of content to pre-fetch for zooming. This value is dependent on the size of the semantic zoom container. More content can be displayed based on the zoom factor and the size of the container. + **/ + configureForZoom(isZoomedOut: boolean, isCurrentView: boolean, triggerZoom: Function, prefetchedPages: number): void; + + /** + * Terminates semantic zoom on the zoomed in or zoomed out child of the custom control. + * @param isCurrentView True if the control is the visible control; otherwise false. + **/ + endZoom(isCurrentView: boolean): void; + + /** + * Retrieves the current item of the zoomed in or zoomed out child of the custom control. + * @returns An object that represents the selected item. This return value must be a Promise for the following: item, position. + **/ + getCurrentItem(): Promise<{ item: T; position: Utilities.IPosition }>; + + /** + * Retrieves the panning axis of the zoomed-in or zoomed-out child of the custom control. + * @returns Identifies the panning axis of the child control. Implementation specific. + **/ + getPanAxis(): string; + + /** + * Manages pointer input for the custom control. + * @param pointerId The ID of the pointer. + **/ + handlePointer(pointerId: string): void; + + /** + * Positions the specified item within the viewport of the child control when panning or zooming begins. + * @param item The object to position within the viewport of the child control. item can be a number, a string, or an object with any number of properties. + * @param position An object that contains the position data of the item relative to the child control. position must be an object with four number properties: left, top, width, and height. These values specify a rectangle that is typically the bounding box of the current item, though the details are up to the control. The units of the position must be in pixels. And the coordinates must be relative to the top-left of the control viewport (which should occupy the same area as the semantic zoom viewport), except when in RTL mode. In RTL mode, return coordinates relative to the top-right off the control viewport. The rectangle is transformed from the coordinate system of one control to that of the other. + **/ + positionItem(item: T, position: Utilities.IPosition): void; + + /** + * Selects the item closest to the specified screen coordinates. + * @param x The x-coordinate in DIPs relative to the upper-left corner of the SemanticZoom viewport. + * @param y The y-coordinate in DIPs relative to the upper-left corner of the SemanticZoom viewport.. + **/ + setCurrentItem(x: number, y: number): void; + + //#endregion Methods + + } + + //#endregion Interfaces + + //#region Objects + + /** + * Represents an application toolbar for displaying commands. + **/ + class AppBar { + //#region Constructors + + /** + * Creates a new AppBar object. + * @constructor + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new AppBar. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs immediately after the AppBar is hidden. + * @param eventInfo An object that contains information about the event. + **/ + onafterhide(eventInfo: Event): void; + + /** + * Occurs after the AppBar is shown. + * @param eventInfo An object that contains information about the event. + **/ + onaftershow(eventInfo: Event): void; + + /** + * Occurs before the AppBar is hidden. + * @param eventInfo An object that contains information about the event. + **/ + onbeforehide(eventInfo: Event): void; + + /** + * Occurs before a hidden AppBar is shown. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeshow(eventInfo: Event): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this AppBar. Call this method when the AppBar is no longer needed. After calling this method, the AppBar becomes unusable. + **/ + dispose(): void; + + /** + * Returns the AppBarCommand object identified by id. + * @param id The element idenitifier (ID) of the command to be returned. + * @returns The command identified by id. If multiple commands have the same ID, returns an array of all the commands matching the ID. + **/ + getCommandById(id: string): AppBarCommand; + + /** + * Hides the AppBar. + **/ + hide(): void; + + /** + * Hides the specified commands of the AppBar. + * @param commands The commands to hide. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. + **/ + hideCommands(commands: Object[], immediate: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Shows the AppBar if it is not disabled. + **/ + show(): void; + + /** + * Shows the specified commands of the AppBar. + * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. + **/ + showCommands(commands: Object[], immediate: boolean): void; + + /** + * Shows the specified commands of the AppBar while hiding all other commands. + * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. + **/ + showOnlyCommands(commands: Object[], immediate: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Sets the AppBarCommand objects that appear in the app bar. + **/ + commands: AppBarCommand; + + /** + * Gets or sets a value that indicates whether the AppBar is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the AppBar. + **/ + element: HTMLElement; + + /** + * Gets a value that indicates whether the AppBar is hidden or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * Gets or sets the layout of the app bar contents. + **/ + layout: string; + + /** + * Gets or sets a value that specifies whether the AppBar appears at the top or bottom of the main view. + **/ + placement: string; + + /** + * Gets or sets a value that indicates whether the AppBar is sticky (won't light dismiss). If not sticky, the app bar dismisses normally when the user touches outside of the appbar. + **/ + sticky: boolean; + + //#endregion Properties + + } + + /** + * Represents a command to be displayed in an app bar. + **/ + class AppBarCommand { + //#region Constructors + + /** + * Creates a new AppBarCommand object. + * @constructor + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new AppBarCommand. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Releases resources held by this AppBarCommand. Call this method when the AppBarCommand is no longer needed. After calling this method, the AppBarCommand becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that indicates whether the AppBarCommand is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the AppBarCommand. + **/ + element: HTMLElement; + + /** + * Adds an extra CSS class during construction. + **/ + extraClass: string; + + /** + * Gets or sets the HTMLElement with a 'content' type AppBarCommand that should receive focus whenever focus moves by the user pressing HOME or the arrow keys, from the previous AppBarCommand to this AppBarCommand. + **/ + firstElementFocus: any; + + /** + * Gets or sets the Flyout object displayed by this command. The specified flyout is shown when the AppBarCommand's button is invoked. + **/ + flyout: Flyout; + + /** + * Gets or sets a value that indicates whether the AppBarCommand is hiding or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * Gets or sets the icon of the AppBarCommand. + **/ + icon: string; + + /** + * Gets the element identifier (ID) of the command. + **/ + id: string; + + /** + * Gets or sets the label of the command. + **/ + label: string; + + /** + * Gets or sets the HTMLElement with a 'content' type AppBarCommand that should receive focus whenever focus moves by the user pressing END or the arrow keys, from the previous AppBarCommand to this AppBarCommand. + **/ + lastElementFocus: any; + + /** + * Gets or sets the function to be invoked when the command is clicked. + **/ + onclick: Function; + + /** + * Gets the section of the app bar that the command is in. + **/ + section: string; + + /** + * Gets or sets the selected state of a toggle button. + **/ + selected: boolean; + + /** + * Gets or sets the tooltip of the command. + **/ + tooltip: string; + + /** + * Gets the type of the command. + **/ + type: string; + + //#endregion Properties + + } + + /** + * Provides backwards navigation in the form of a button. + **/ + class BackButton { + //#region Constructors + + /** + * Creates a new BackButton. + * @constructor + * @param element The DOM element hosts the new BackButton. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element: Object, options: Object); + + //#endregion Constructors + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this BackButton. Call this method when the BackButton is no longer needed. After calling this method, the BackButton becomes unusable. + **/ + dispose(): void; + + /** + * Checks the current navigation history and updates the value of the control's disabled attribute. + **/ + refresh(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the HTML element that hosts this BackButton. + **/ + element: HTMLElement; + + //#endregion Properties + + } + + /** + * Represents a layout for the ListView in which items are arranged in a grid and items can span multiple grid cells. + **/ + class CellSpanningLayout { + //#region Constructors + + /** + * Creates a new CellSpanningLayout. + * @constructor + * @param options An object that contains one or more property/value pairs to apply to the new CellSpanningLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". + **/ + constructor(options: Object); + + //#endregion Constructors + + //#region Methods + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + dragLeave(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + dragOver(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + executeAnimations(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param currentItem An object that describes the current item. It has these properties: index, type. + * @param pressedKey The key that was pressed. + * @returns An object that describes the next item that should receive focus. It has these properties: index, type. + **/ + getAdjacent(currentItem: Object, pressedKey: WinJS.Utilities.Key): Object; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param x The x-coordinate, or the horizontal position on the screen. + * @param y The y-coordinate, or the vertical position on the screen. + **/ + hitTest(x: number, y: number): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param site The rendering site for the layout. + * @param groupsEnabled Set to true if this layout supports groups; set to false if it does not. + **/ + initialize(site: ILayoutSite2, groupsEnabled: boolean): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param firstPixel The first pixel the range of items falls between. + * @param lastPixel The last pixel the range of items falls between. + **/ + itemsFromRange(firstPixel: number, lastPixel: number): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups + **/ + layout(tree: ILayoutSite2, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + setupAnimations(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + uninitialize(): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the position of group headers relative to their items. + **/ + groupHeaderPosition: WinJS.UI.HeaderPosition; + + /** + * Gets or sets a function that enables cell-spanning and establishes base cell dimensions. + **/ + groupInfo: Function; + + /** + * Gets or sets a function that returns the width and height of an item, as well as whether it should appear in a new column. Setting this function improves performance because the ListView can allocate space for an item without having to measure it first. + **/ + itemInfo: Function; + + /** + * Gets or set the maximum number of rows or columns, depending on the orientation, to display before content begins to wrap. + **/ + maximumRowsOrColumns: number; + + /** + * This API supports the Windows Library for JavaScript infrastructure and is not intended to be used directly from your code. + **/ + numberOfItemsPerItemsBlock: any; + + /** + * Gets the orientation of the CellSpanningLayout. For a CellSpanningLayout, this property always returns Orientation.horizontal. + **/ + orientation: WinJS.UI.Orientation; + + //#endregion Properties + + } + + /** + * Allows users to pick a date value. + **/ + class DatePicker { + //#region Constructors + + /** + * Initializes a new instance of the DatePicker control. + * @constructor + * @param element The DOM element associated with the DatePicker control. + * @param options The set of options to be applied initially to the DatePicker control. The options are the following: calendar, current, datePattern, disabled, maxYear, minYear, monthPattern, yearPattern. + **/ + constructor(element: HTMLElement, options: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when any of the controls are changed by the user. + * @param eventInfo An object that contains information about the event. + **/ + onchange(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Adds an event listener. + * @param type The type (name) of the event. + * @param listener The function that handles the event. + * @param capture If true, specifies that capture should be initiated, otherwise false. + **/ + addEventListener(type: string, listener: Function, capture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this DatePicker. Call this method when the DatePicker is no longer needed. After calling this method, the DatePicker becomes unusable. + **/ + dispose(): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + raiseEvent(type: string, eventProperties: Object): boolean; + + /** + * Removes a listener for the specified event. + * @param type The name of the event for which to remove a listener. + * @param listener The listener. + * @param useCapture Optional. The same value that was passed to addEventListener for this listener. It may be omitted if it was omitted when calling addEventListener. + **/ + removeEventListener(type: string, listener: Function, useCapture?: Object): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the calendar to use. + **/ + calendar: Object; + + /** + * Gets or sets the current date of the DatePicker. You can use either a date string or a Date object to set this property. + **/ + current: Date; + + /** + * Gets or sets the display pattern for the date. The default date pattern is day.integer(2). You can change the date pattern by changing the number of integers displayed. + **/ + datePattern: string; + + /** + * Specifies whether the DatePicker is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element for the DatePicker. + **/ + element: HTMLElement; + + /** + * Gets or sets the maximum Gregorian year available for picking. + **/ + maxYear: number; + + /** + * Gets or sets the minimum Gregorian year available for picking. + **/ + minYear: number; + + /** + * Gets or sets the display pattern for the month. The default month pattern is month.abbreviated. You can change the month pattern to the following values: month.full. The full name of the month. month.abbreviated(n). You can use abbreviated with or without specifying the number of letters in the abbreviation. If you do specify the number of letters, the actual length of the month name that appears may vary. month.solo.full. A representation of the month that is suitable for stand-alone display. You can also use month.solo.abbreviated(n). month.integer(n). You can use integer with or without specifying the number of integers. + **/ + monthPattern: string; + + /** + * Gets or sets the display pattern for the year. The default year pattern is year.full. You can change the year pattern to the following values: year.abbreviated(n). You can use abbreviated with or without specifying the number of letters in the abbreviation. + **/ + yearPattern: string; + + //#endregion Properties + + } + + /** + * Adds event-related methods to the control. + **/ + class DOMEventMixin { + //#region Methods + + /** + * Adds an event listener to the control. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + * @param useCapture true to initiate capture; otherwise, false. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type, adding the specified additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Removes an event listener from the control. + * @param type The type (name) of the event. + * @param listener The listener to remove. + * @param useCapture true to initiate capture; otherwise, false. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Adds the set of declaratively specified options (properties and events) to the specified control. If the name of the options property begins with "on", the property value is a function and the control supports addEventListener. This method calls the addEventListener method on the control. + * @param control The control on which the properties and events are to be applied. + * @param options The set of options that are specified declaratively. + **/ + setOptions(control: Object, options: Object): void; + + //#endregion Methods + + } + + /** + * Displays a collection, such as a set of photos, one item at a time. + **/ + class FlipView { + //#region Constructors + + /** + * Creates a new FlipView. + * @constructor + * @param element The DOM element that hosts the control. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the pageselected event, add a property named "onpageselected" and set its value to the event handler. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when the datasource count changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: source. + **/ + ondatasourcecountchanged(eventInfo: Event): void; + + /** + * Raised when the FlipView flips to a page and its renderer function completes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.source. + **/ + onpagecompleted(eventInfo: CustomEvent): void; + + /** + * Raised when the FlipView flips to a page. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.source. + **/ + onpageselected(eventInfo: CustomEvent): void; + + /** + * Occurs when an item becomes invisible or visible. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.source, detail.visible. + **/ + onpagevisibilitychanged(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. For a list of events, see the FlipView object page. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Returns the number of items in the FlipView control's itemDataSource. + * @returns A Promise that contains the number of items in the list or WinJS.UI.CountResult.unknown if the count is unavailable. + **/ + count(): Promise; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this FlipView. Call this method when the FlipView is no longer needed. After calling this method, the FlipView becomes unusable. + **/ + dispose(): void; + + /** + * Forces the FlipView to update its layout. Use this function when making the FlipView visible again after its style.display property had been set to "none". + **/ + forceLayout(): void; + + /** + * Navigates to the next page. + * @returns true if the FlipView begins navigating to the next page; false if the FlipView is already at the last item or is in the middle of another navigation animation. + **/ + next(): boolean; + + /** + * Navigates to the previous item. + * @returns true if the FlipView begins navigating to the previous page; nfalse if the FlipView is already at the first page or is in the middle of another navigation animation. + **/ + previous(): boolean; + + /** + * Unregisters an event handler for the specified event. + * @param eventName The name of the event. + * @param eventHandler The event handler function to remove. + * @param useCapture Set to true to unregister the event handler for the capturing phase; otherwise, set to false to unregister the event handler for the bubbling phase. + **/ + removeEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Sets custom animations for the FlipView to use when navigating between pages. + * @param animations An object that contains up to three fields, one for each navigation action: next, previous, and jump. Each of those fields must be a function with this signature: function (outgoingPage, incomingPage) Each function must return a WinJS.Promise that completes once the animations are finished. If a field is null or undefined, the FlipView reverts to its default animation for that action. + **/ + setCustomAnimations(animations: Object): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the index of the currently displayed page. + **/ + currentPage: number; + + /** + * Gets the HTML element that hosts this FlipView. + **/ + element: HTMLElement; + + /** + * Gets or sets the data source that provides the FlipView with items to display. The FlipView displays one item at a time, on its own page. + **/ + itemDataSource: IListDataSource; + + /** + * Gets or sets the spacing between each item, in pixels. + **/ + itemSpacing: number; + + /** + * Gets or sets a Template or function that defines the HTML for each item's page. + **/ + itemTemplate: any; + + /** + * Gets or sets the orientation of the FlipView, horizontal or vertical. + **/ + orientation: string; + + //#endregion Properties + + } + + /** + * Displays lightweight UI that is either information, or requires user interaction. Unlike a dialog, a Flyout can be light dismissed by clicking or tapping off of it. + **/ + class Flyout { + //#region Constructors + + /** + * Creates a new Flyout object. + * @constructor + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new Flyout. + **/ + constructor(element: HTMLElement, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Raised immediately after a flyout is fully hidden. + * @param eventInfo An object that contains information about the event. + **/ + onafterhide(eventInfo: Event): void; + + /** + * Raised immediately after a flyout is fully shown. + * @param eventInfo An object that contains information about the event. + **/ + onaftershow(eventInfo: Event): void; + + /** + * Raised just before hiding a flyout. + * @param eventInfo An object that contains information about the event. + **/ + onbeforehide(eventInfo: Event): void; + + /** + * Raised just before showing a flyout. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeshow(eventInfo: Event): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Releases resources held by this object. Call this method when the object is no longer needed. After calling this method, the object becomes unusable. + **/ + dispose(): void; + + /** + * Hides the Flyout, if visible, regardless of other states. + **/ + hide(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Shows the Flyout, if hidden, regardless of other states. + * @param anchor Required. The DOM element to anchor the Flyout. + * @param placement The placement of the Flyout to the anchor: the string literal "top", "bottom", "left", or "right". + * @param alignment For "top" or "bottom" placement, the alignment of the Flyout to the anchor's edge: the string literal "center", "left", or "right". + **/ + show(anchor: HTMLElement, placement: Object, alignment: Object): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the default alignment to be used for this Flyout. + **/ + alignment: Object; + + /** + * Gets or sets the default anchor to be used for this Flyout. + **/ + anchor: HTMLElement; + + /** + * Gets the DOM element that hosts the Flyout. + **/ + element: HTMLElement; + + /** + * Gets a value that indicates whether the Flyout is hidden or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * Gets or sets the default placement to be used for this Flyout. + **/ + placement: Object; + + //#endregion Properties + + } + + /** + * Represents a grid layout for the ListView in which items are arranged in a horizontal grid. + **/ + class GridLayout { + //#region Constructors + + /** + * Creates a new GridLayout object. + * @constructor + * @param options The set of properties and values to apply to the new GridLayout. + **/ + constructor(options?: Object); + + //#endregion Constructors + + //#region Methods + + /** + * This method is no longer supported. + * @param beginScrollPosition + * @param wholeItem + **/ + calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): void; + + /** + * This method is no longer supported. + * @param endScrollPosition + * @param wholeItem + **/ + calculateLastVisible(endScrollPosition: number, wholeItem: boolean): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + dragLeave(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + dragOver(): void; + + /** + * This method is no longer supported. + **/ + endLayout(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + executeAnimations(): void; + + /** + * This method is no longer supported. + * @param itemIndex + **/ + getItemPosition(itemIndex: number): void; + + /** + * This method is no longer supported. + * @param itemIndex + * @param element + * @param keyPressed + **/ + getKeyboardNavigatedItem(itemIndex: number, element: Object, keyPressed: Object): void; + + /** + * This method is no longer supported. + * @param beginScrollPosition + * @param endScrollPosition + **/ + getScrollbarRange(beginScrollPosition: number, endScrollPosition: number): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param x The x-coordinate, or the horizontal position on the screen. + * @param y The y-coordinate, or the vertical position on the screen. + **/ + hitTest(x: number, y: number): void; + + /** + * This method is no longer supported. + **/ + init(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param site The rendering site for the layout. + * @param groupsEnabled Set to true if this layout supports groups; set to false if it does not. + **/ + initialize(site: ILayoutSite2, groupsEnabled: boolean): void; + + /** + * This method is no longer supported. + * @param elements + **/ + itemsAdded(elements: Object): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param firstPixel The first pixel the range of items falls between. + * @param lastPixel The last pixel the range of items falls between. + **/ + itemsFromRange(firstPixel: number, lastPixel: number): void; + + /** + * This method is no longer supported. + **/ + itemsMoved(): void; + + /** + * This method is no longer supported. + * @param elements + **/ + itemsRemoved(elements: Object): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups + **/ + layout(tree: Object, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): void; + + /** + * This method is no longer supported. + * @param groupIndex + * @param element A DOM element. + **/ + layoutHeader(groupIndex: number, element: Object): void; + + /** + * This method is no longer supported. + * @param itemIndex + * @param element A DOM element. + **/ + layoutItem(itemIndex: number, element: Object): void; + + /** + * This method is no longer supported. + * @param element + **/ + prepareHeader(element: HTMLElement): void; + + /** + * This method is no longer supported. + * @param itemIndex + * @param element A DOM element. + **/ + prepareItem(itemIndex: number, element: Object): void; + + /** + * This method is no longer supported. + * @param item + * @param newItem + **/ + releaseItem(item: Object, newItem: Object): void; + + /** + * This method is no longer supported. + **/ + reset(): void; + + /** + * This method is no longer supported. + * @param layoutSite + **/ + setSite(layoutSite: Object): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + setupAnimations(): void; + + /** + * This method is no longer supported. + * @param beginScrollPosition + * @param endScrollPositionScrollPosition + **/ + startLayout(beginScrollPosition: number, endScrollPositionScrollPosition: number): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + uninitialize(): void; + + /** + * This method is no longer supported. + * @param count + **/ + updateBackdrop(count: number): void; + + //#endregion Methods + + //#region Properties + + /** + * This property is no longer supported. Starting with Windows Library for JavaScript 2.0, use the .win-listview.win-container.win-backdrop CSS selector. + **/ + backdropColor: string; + + /** + * This property is no longer supported. Starting with Windows Library for JavaScript 2.0, use the .win-listview.win-container.win-backdrop CSS selector. + **/ + disableBackdrop: boolean; + + /** + * Gets or sets the position of group headers. + **/ + groupHeaderPosition: WinJS.UI.HeaderPosition; + + /** + * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. + **/ + groupInfo: Function; + + /** + * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use the orientation property instead. + **/ + horizontal: boolean; + + /** + * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. + **/ + itemInfo: Function; + + /** + * Gets or set the maximum number of rows or columns, depending on the orientation, to display before content begins to wrap. + **/ + maximumRowsOrColumns: number; + + /** + * This property is no longer supported. Starting with Windows Library for JavaScript 2.0, use the maximumRowsOrColumns property. + **/ + maxRows: number; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + numberOfItemsPerItemsBlock: any; + + /** + * Gets or sets the orientation of the GridLayout. + **/ + orientation: WinJS.UI.Orientation; + + //#endregion Properties + + } + + /** + * Creates a hub navigation pattern consisting of sections that can be navigated to. Each section is defined by a HubSection object. + **/ + class Hub { + //#region Constructors + + /** + * Creates a new Hub control. + * @constructor + * @param element The DOM element that will host the Hub control. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the contentanimating event, add a property named "oncontentanimating" to the options object and set its value to the event handler. + **/ + constructor(element: HTMLElement, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Raised when the Hub is about to play entrance, content transition, insert, or remove animations. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.type, detail.index, detail.section. + **/ + oncontentanimating(eventInfo: CustomEvent): void; + + /** + * Raised when the user clicks on an interactive header. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.index, detail.section. + **/ + onheaderinvoked(eventInfo: CustomEvent): void; + + /** + * Raised when the Hub control's loadingState changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: loadingState. + **/ + onloadingstatechanged(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this Hub. Call this method when the Hub is no longer needed. After calling this method, the Hub becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the DOM element that hosts the Hub control. + **/ + element: HTMLElement; + + /** + * Gets or sets the Template or templating function that creates the DOM elements for each HubSection header. Your HubSection object should provide strings for HubSection.header property. + **/ + headerTemplate: any; + + /** + * Gets or sets the index of the first HubSection at least partially in view. This property is useful for animating the visible content in the Hub. + **/ + indexOfFirstVisible: number; + + /** + * Gets or sets the index of last HubSection at least partially in view. Used for animating the visible content in the Hub. + **/ + indexOfLastVisible: number; + + /** + * Gets a value that indicates whether the hub is still loading or whether loading is complete. The value changes to complete after all the sections and content inside them has loaded. + **/ + loadingState: string; + + /** + * Gets or sets the orientation of sections within the Hub. + **/ + orientation: Orientation; + + /** + * Gets or sets the distance between the start of the Hub and the current viewable area. + **/ + scrollPosition: number; + + /** + * Gets or sets the index of the first visible HubSection. + **/ + sectionOnScreen: any; + + /** + * Gets or sets the List that contains the HubSection objects that belong to this Hub. + **/ + sections: WinJS.Binding.List; + + /** + * This API supports the SemanticZoom infrastructure and is not intended to be used directly from your code. + **/ + zoomableView: any; + + //#endregion Properties + + } + + /** + * Defines a section of a Hub. + **/ + class HubSection { + //#region Constructors + + /** + * Creates a new HubSection. + * @constructor + * @param element The DOM element hosts the new HubSection. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Methods + + /** + * Releases resources held by this HubSection. Call this method when the HubSection is no longer needed. After calling this method, the HubSection becomes unusable. + **/ + dispose(): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the DOM element that hosts the HubSection control's content. + **/ + contentElement: HTMLElement; + + /** + * Gets the DOM element that hosts this HubSection. + **/ + element: HTMLElement; + + /** + * Gets or sets the header for this HubSection. + **/ + header: string; + + /** + * Gets a value that specifies whether the header is static. + **/ + isHeaderStatic: boolean; + + //#endregion Properties + + } + + /** + * Enables you to include an HTML page dynamically. As part of the constructor, you must include an option indicating the URI of the page. + **/ + class HtmlControl { + //#region Methods + + /** + * Initializes a new instance of HtmlControl to define a new page control. + * @param element The element that hosts the HtmlControl. + * @param options The options for configuring the page. The uri option is required in order to specify the source document for the content of the page. Other options are the ones used by the WinJS.Pages.render method. + **/ + HtmlControl(element: HTMLElement, options: Object): void; + + //#endregion Methods + + } + + /** + * Defines an item that can be pressed, swiped, and dragged. + **/ + class ItemContainer { + //#region Constructors + + /** + * Creates a new ItemContainer. + * @constructor + * @param element The DOM element hosts the new ItemContainer. For the ItemContainer to be accessible, this element must have its role attribute set to "list" or "listbox". If tapBehavior is set to none and selectionDisabled is true, then use the "list" role; otherwise, use the "listbox" role. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element: Object, options: Object); + + //#endregion Constructors + + //#region Events + + /** + * Raised when the item is invoked. (You can use the tapBehavior property to specify whether taps and clicks invoke the item.) + * @param eventInfo An object that contains information about the event. + **/ + oninvoked(eventInfo: CustomEvent): void; + + /** + * Raised after the item is selected or deselected. + * @param eventInfo An object that contains information about the event. + **/ + onselectionchanged(eventInfo: CustomEvent): void; + + /** + * Raised just before the current selection changes. + * @param eventInfo An object that contains information about the event. + **/ + onselectionchanging(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this ItemContainer. Call this method when the ItemContainer is no longer needed. After calling this method, the ItemContainer becomes unusable. + **/ + dispose(): void; + + /** + * Forces the ItemContainer to update its layout. Call this function when the reading direction of the app changes after the control has been initialized. + **/ + forceLayout(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that specifies whether the item can be dragged. + **/ + draggable: boolean; + + /** + * Gets the element that hosts this ItemContainer. + **/ + element: HTMLElement; + + /** + * Gets or sets a value that specifies whether the item is selected. + **/ + selected: boolean; + + /** + * Gets or sets a value that specifies whether selection of this item is disabled. + **/ + selectionDisabled: boolean; + + /** + * Gets or sets how the ItemContainer reacts to the swipe gesture. The swipe gesture can select the swiped items or can have no effect on the current selection. + **/ + swipeBehavior: WinJS.UI.SwipeBehavior; + + /** + * Gets or sets the orientation of swipe gestures. + **/ + swipeOrientation: any; + + /** + * Gets or sets how the ItemContainer reacts when the user taps or clicks an item. + **/ + tapBehavior: any; + + //#endregion Properties + + } + + /** + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + class Layout { + } + + /** + * Represents a layout for the ListView in which items are arranged in a vertical list. + **/ + class ListLayout { + //#region Constructors + + /** + * Creates a new ListLayout. + * @constructor + * @param options An object that contains one or more property/value pairs to apply to the new ListLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". + **/ + constructor(options?: Object); + + //#endregion Constructors + + //#region Methods + + /** + * This method is no longer supported. + * @param beginScrollPosition + * @param wholeItem + **/ + calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): void; + + /** + * This method is no longer supported. + * @param endScrollPosition + * @param wholeItem + **/ + calculateLastVisible(endScrollPosition: number, wholeItem: boolean): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + dragLeave(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + dragOver(): void; + + /** + * This method is no longer supported. + **/ + endLayout(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + executeAnimations(): void; + + /** + * This method is no longer supported. + * @param itemIndex + **/ + getItemPosition(itemIndex: number): void; + + /** + * This method is no longer supported. + * @param itemIndex + * @param element + * @param keyPressed + **/ + getKeyboardNavigatedItem(itemIndex: number, element: Object, keyPressed: Object): void; + + /** + * This method is no longer supported. + * @param beginScrollPosition + * @param endScrollPosition + **/ + getScrollbarRange(beginScrollPosition: number, endScrollPosition: number): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param x The x-coordinate, or the horizontal position on the screen. + * @param y The y-coordinate, or the vertical position on the screen. + **/ + hitTest(x: number, y: number): void; + + /** + * This method is no longer supported. + **/ + init(): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + initialize(): void; + + /** + * This method is no longer supported. + * @param elements + **/ + itemsAdded(elements: Object): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param firstPixel + * @param lastPixel + **/ + itemsFromRange(firstPixel: number, lastPixel: number): void; + + /** + * This method is no longer supported. + **/ + itemsMoved(): void; + + /** + * This method is no longer supported. + * @param elements + **/ + itemsRemoved(elements: Object): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups + **/ + layout(tree: Object, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): void; + + /** + * This method is no longer supported. + * @param groupIndex + * @param element A DOM element. + **/ + layoutHeader(groupIndex: number, element: Object): void; + + /** + * This method is no longer supported. + * @param itemIndex + * @param element A DOM element. + **/ + layoutItem(itemIndex: number, element: Object): void; + + /** + * This method is no longer supported. + * @param element + **/ + prepareHeader(element: HTMLElement): void; + + /** + * This method is no longer supported. + * @param itemIndex + * @param element A DOM element. + **/ + prepareItem(itemIndex: number, element: Object): void; + + /** + * This method is no longer supported. + * @param item + * @param newItem + **/ + releaseItem(item: Object, newItem: Object): void; + + /** + * This method is no longer supported. + **/ + reset(): void; + + /** + * This method is no longer supported. + * @param layoutSite + **/ + setSite(layoutSite: Object): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + setupAnimations(): void; + + /** + * This method is no longer supported. + * @param beginScrollPosition + * @param endScrollPositionScrollPosition + **/ + startLayout(beginScrollPosition: number, endScrollPositionScrollPosition: number): void; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + uninitialize(): void; + + /** + * This method is no longer supported. + * @param count + **/ + updateBackdrop(count: number): void; + + //#endregion Methods + + //#region Properties + + /** + * This property is no longer supported. Starting with Windows Library for JavaScript 2.0, use the .win-listview.win-container.win-backdrop CSS selector. + **/ + backdropColor: string; + + /** + * This property is no longer supported. Starting with Windows Library for JavaScript 2.0, use the .win-listview.win-container.win-backdrop CSS selector. + **/ + disableBackdrop: boolean; + + /** + * Gets or sets the position of group headers. + **/ + groupHeaderPosition: WinJS.UI.HeaderPosition; + + /** + * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. + **/ + groupInfo: Function; + + /** + * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use the orientation property instead. + **/ + horizontal: boolean; + + /** + * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. + **/ + itemInfo: Function; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + numberOfItemsPerItemsBlock: any; + + /** + * Gets or sets the orientation of the GridLayout. + **/ + orientation: WinJS.UI.Orientation; + + //#endregion Properties + + } + + /** + * Displays data items in a customizable list or grid. + **/ + class ListView { + //#region Constructors + + /** + * Creates a new ListView. + * @constructor + * @param element The DOM element that hosts the ListView control. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the selectionchanged event, add a property named "onselectionchanged" to the options object and set its value to the event handler. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when the ListView is about to play an entrance or contentTransition animation. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.type, detail.setPromise. + **/ + oncontentanimating(eventInfo: CustomEvent): void; + + /** + * Raised when the user taps or clicks a group header. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.groupHeaderIndex, detail.groupHeaderPromise. + **/ + ongroupheaderinvoked(eventInfo: CustomEvent): void; + + /** + * Raised when the ListView is a drop target and the onitemdragenter has been disabled. This is raised every time the cursor is moved between a new pair of items. If you call preventDefault on this event, then the ListView does not move the items slightly above/below the cursor to provide visual feedback for a drop. + * @param eventInfo An object that contains information about the event. The detail property of this object contains additional information about the event. + **/ + onitemdragbetween(eventInfo: CustomEvent): void; + + /** + * Raised when the user is dragging an item from the ListView and the datasource changes while the user is dragging. + * @param eventInfo An object that contains information about the event. The detail property of this object contains additional information about the event. + **/ + onitemdragchanged(eventInfo: CustomEvent): void; + + /** + * Raised when an item is dropped onto the ListView as the result of a drag operation. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.dataTransfer, detail.index, detail.insertAfterIndex. + **/ + onitemdragdrop(eventInfo: CustomEvent): void; + + /** + * Raised when the user drops an item dragged from a ListView. + * @param eventInfo An object that contains information about the event. + **/ + onitemdragend(eventInfo: CustomEvent): void; + + /** + * Raised when an dragged item enters the bounds of the ListView control. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.dataTransfer. + **/ + onitemdragenter(eventInfo: CustomEvent): void; + + /** + * Raised when a draggable item leaves the bounds of a ListView control. + * @param eventInfo An object that contains information about the event. + **/ + onitemdragleave(eventInfo: CustomEvent): void; + + /** + * Raised when the user begins to drag an item from a ListView control. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.dataTransfer, detail.dragInfo. + **/ + onitemdragstart(eventInfo: CustomEvent): void; + + /** + * Occurs when the user taps or clicks an item. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.itemIndex. + **/ + oniteminvoked(eventInfo: CustomEvent): void; + + /** + * Raised when the focused item changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.oldFocus, detail.oldNewFocus. + **/ + onkeyboardnavigating(eventInfo: CustomEvent): void; + + /** + * Occurs when the ListView control's loadingState changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.scrolling. + **/ + onloadingstatechanged(eventInfo: CustomEvent): void; + + /** + * Occurs after the current selection changes. + * @param eventInfo An object that contains information about the event. The detail property of this object is null. To obtain the selected items, use the ListView.selection property. + **/ + onselectionchanged(eventInfo: CustomEvent): void; + + /** + * Occurs just before the current selection changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.newSelection, detail.preventTapBehavior. + **/ + onselectionchanging(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. See the ListView object page for a list of events. Note that you drop the "on" when specifying the event name for the addEventListener method. For example, instead of specifying "onselectionchange", you specify "selectionchange". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this object. Call this method when the object is no longer needed. After calling this method, the object becomes unusable. + **/ + dispose(): void; + + /** + * Returns the DOM element that represents the item at the specified index. + * @param itemIndex The index of the item. + * @returns The DOM element that represents the item at the specified index. + **/ + elementFromIndex(itemIndex: number): HTMLElement; + + /** + * Makes the item at the specified index visible. If necessary, the ListView will scroll to the item. + * @param itemIndex The index of the item to scroll into view. + **/ + ensureVisible(itemIndex: number): void; + + /** + * Forces the ListView to update its layout. Use this function when making the ListView visible again after its style.display property had been set to "none". + **/ + forceLayout(): void; + + /** + * Returns the index of the item that the specified DOM element displays. + * @param element The DOM element that displays the item. + * @returns The index of the item displayed by element. + **/ + indexOfElement(element: HTMLElement): number; + + /** + * Loads the next set of pages if the ListView control's loadingBehavior is set to "incremental" (otherwise, it does nothing). The number of pages to be loaded is determined by the pagesToLoad property. + **/ + loadMorePages(): void; + + /** + * Repositions all the visible items in the ListView to adjust for items whose sizes have changed. Most apps won’t ever need to call this method. For more info, see the Remarks section. + **/ + recalculateItemPosition(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Triggers the ListView disposal service manually. + **/ + triggerDispose(): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that indicates whether the next set of pages is automatically loaded when the user scrolls beyond the number of pages specified by the pagesToLoadThreshold property. + **/ + automaticallyLoadPages: boolean; + + /** + * Gets or sets an object that indicates which item should have keyboard focus and the focus state of that item. + **/ + currentItem: { index: number; key: string; hasFocus: boolean; showFocus: boolean }; + + /** + * Gets the HTML element that hosts this ListView. + **/ + element: HTMLElement; + + /** + * Gets or sets the data source that contains the groups for the items in the itemDataSource. + **/ + groupDataSource: IListDataSource; + + /** + * Gets or sets how the ListView reacts when the user taps or clicks a group header. + **/ + groupHeaderTapBehavior: GroupHeaderTapBehavior; + + /** + * Gets or sets the Template or function that creates the DOM elements for each group header in the groupDataSource. Each group header can contain multiple elements, but it must have a single root element. + **/ + groupHeaderTemplate: any; + + /** + * Gets or sets the first visible item. + **/ + indexOfFirstVisible: number; + + /** + * Gets the index of the last visible item in the ListView. + **/ + indexOfLastVisible: number; + + /** + * Gets or sets the data source that provides the ListView with items. + **/ + itemDataSource: IListDataSource; + + /** + * Go Gets or sets a value that specifies whether items can be dragged. When this is set to true the ListView provides built in behaviors related to item dragging. + **/ + itemsDraggable: boolean; + + /** + * Gets or sets whether the ListView control's items can be reordered within itself by dragging and dropping. + **/ + itemsReorderable: boolean; + + /** + * Gets or sets the WinJS.Binding.Template or templating function that creates the DOM elements for each item in the itemDataSource. Each item can contain multiple elements, but it must have a single root element. + **/ + itemTemplate: any; + + /** + * Gets or sets an object that controls the layout of the ListView. + **/ + layout: any; + + /** + * Gets or sets a value that specifies how the ListView fetches items and adds and removes them to the DOM. Don't change the value of this property after the ListView has begun loading data. + **/ + loadingBehavior: string; + + /** + * Gets a value that indicates whether the ListView is still loading or whether loading is complete. + **/ + loadingState: string; + + /** + * Gets or sets the maximum number of realized items. + **/ + maxDeferredItemCleanup: number; + + /** + * Gets or sets the number of pages to load when the loadingBehavior property is set to "incremental" and the user scrolls beyond the threshold specified by the pagesToLoadThreshold property. + **/ + pagesToLoad: number; + + /** + * Gets or sets the threshold (in pages) for initiating an incremental load. When the last visible item is within the specified number of pages from the end of the loaded portion of the list, and if automaticallyLoadPages is true and loadingBehavior is set to "incremental", the ListView initiates an incremental load. + **/ + pagesToLoadThreshold: number; + + /** + * Gets or sets the function that is called when the ListView discards or recycles the element representation of a group header. + **/ + resetGroupHeader: (header: Object, element: HTMLElement) => void; + + /** + * Gets or sets the function that is called when an item is removed, an item is changed, or an item falls outside of the realized range of the ListView. + **/ + resetItem: (item: T, element: HTMLElement) => void; + + /** + * Gets or sets the distance, in pixels, of the start of the viewable area within the viewport. + **/ + scrollPosition: number; + + /** + * Gets an ISelection that contains the range of currently selected items. + **/ + selection: ISelection; + + /** + * Gets or sets the selection mode of the ListView. + **/ + selectionMode: SelectionMode; + + /** + * Gets or sets how the ListView reacts to the swipe gesture. The swipe gesture can select the swiped items or can have no effect on the current selection. + **/ + swipeBehavior: WinJS.UI.SwipeBehavior; + + /** + * Gets or sets how the ListView reacts when the user taps or clicks an item. + **/ + tapBehavior: TapBehavior; + + /** + * Gets a ZoomableView that supports semantic zoom functionality. This API supports the SemanticZoom infrastructure and is not intended to be used directly from your code. + **/ + zoomableView: IZoomableView; + + //#endregion Properties + + } + + /** + * Represents a menu flyout for displaying commands. + **/ + class Menu { + //#region Constructors + + /** + * Creates a new Menu object. + * @constructor + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new Menu. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs immediately after the Menu is hidden. + * @param eventInfo An object that contains information about the event. + **/ + onafterhide(eventInfo: Event): void; + + /** + * Occurs after the Menu is shown. + * @param eventInfo An object that contains information about the event. + **/ + onaftershow(eventInfo: Event): void; + + /** + * Occurs before the Menu is hidden. + * @param eventInfo An object that contains information about the event. + **/ + onbeforehide(eventInfo: Event): void; + + /** + * Occurs before a hidden Menu is shown. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeshow(eventInfo: Event): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Releases resources held by this Menu. Call this method when the Menu is no longer needed. After calling this method, the Menu becomes unusable. + **/ + dispose(): void; + + /** + * Returns the MenuCommand object identified by id. + * @param id The element identifier (ID) of the command to be returned. + * @returns The command identified by id. + **/ + getCommandById(id: string): MenuCommand; + + /** + * Hides the Menu. + **/ + hide(): void; + + /** + * Hides the specified commands of the Menu. + * @param commands The commands to hide. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. + **/ + hideCommands(commands: Object[], immediate: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Shows the Menu, if hidden, regardless of other states. + * @param anchor Required. The DOM element to anchor the Menu. + * @param placement The placement of the Menu to the anchor: top, bottom, left, or right. + * @param alignment For top or bottom placement, the alignment of the Menu to the anchor's edge: center, left, or right. + **/ + show(anchor: HTMLElement, placement: Object, alignment: Object): void; + + /** + * Shows the specified commands of the Menu. + * @param commands The commands to show. The array elements may be Menu objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. + **/ + showCommands(commands: Object[], immediate: boolean): void; + + /** + * Shows the specified commands of the Menu while hiding all other commands. + * @param commands The commands to show. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. + **/ + showOnlyCommands(commands: Object[], immediate: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the default alignment to be used for this Menu. + **/ + alignment: Object; + + /** + * Gets or sets the default anchor to be used for this Menu. + **/ + anchor: HTMLElement; + + /** + * Sets the MenuCommand objects that appear in the menu. + **/ + commands: MenuCommand; + + /** + * Gets the DOM element that hosts the Menu. + **/ + element: HTMLElement; + + /** + * Gets a value that indicates whether the Menu is hidden or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * Gets or sets the default placement to be used for this Menu. + **/ + placement: Object; + + //#endregion Properties + + } + + /** + * Represents a command to be displayed in a Menu object. + **/ + class MenuCommand { + //#region Constructors + + /** + * Creates a new MenuCommand object. + * @constructor + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new MenuCommand. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Disposes this control. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that indicates whether the MenuCommand is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the MenuCommand. + **/ + element: HTMLElement; + + /** + * Adds an extra CSS class during construction. + **/ + extraClass: string; + + /** + * Gets or sets the Flyout object displayed by this command. The specified flyout is shown when the MenuCommand's button is invoked. + **/ + flyout: Flyout; + + /** + * Gets a value that indicates whether the MenuCommand is hidden or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * Gets the element identifier (ID) of the command. + **/ + id: string; + + /** + * Gets or sets the label of the command. + **/ + label: string; + + /** + * Gets or sets the function to be invoked when the command is clicked. + **/ + onclick: Function; + + /** + * Gets or sets the selected state of a toggle button. + **/ + selected: boolean; + + /** + * Gets the type of the command. + **/ + type: string; + + //#endregion Properties + + } + + /** + * Displays navigation commands in a toolbar that the user can show or hide. + **/ + class NavBar { + //#region Constructors + + /** + * Creates a new NavBar. + * @constructor + * @param element The DOM element that will host the new NavBar. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs immediately after the NavBar is hidden. + * @param eventInfo An object that contains information about the event. + **/ + onafterhide(eventInfo: Event): void; + + /** + * Raised after the NavBar is shown. + * @param eventInfo An object that contains information about the event. + **/ + onaftershow(eventInfo: Event): void; + + /** + * Raised just before the NavBar is hidden. + * @param eventInfo An object that contains information about the event. + **/ + onbeforehide(eventInfo: Event): void; + + /** + * Occurs before a hidden NavBar is shown. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeshow(eventInfo: Event): void; + + /** + * Occurs after the NavBar has finished processing its child elements. + * @param eventInfo An object that contains information about the event. + **/ + onchildrenprocessed(eventInfo: Event): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this NavBar. Call this method when the NavBar is no longer needed. After calling this method, the NavBar becomes unusable. + **/ + dispose(): void; + + /** + * Hides the NavBar. + **/ + hide(): void; + + /** + * Hides the specified commands of the NavBar. + * @param commands The commands to hide. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. + **/ + hideCommands(commands: Object[], immediate: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Shows the NavBar if it is not disabled. + **/ + show(): void; + + /** + * Shows the specified commands of the NavBar. + * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. + **/ + showCommands(commands: Object[], immediate: boolean): void; + + /** + * Shows the specified commands of the NavBar while hiding all other commands. + * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. + * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. + **/ + showOnlyCommands(commands: Object[], immediate: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + commands: AppBarCommand; + + /** + * Gets or sets a value that indicates whether the NavBar is disabled. + **/ + disabled: boolean; + + /** + * Gets the HTML element that hosts this NavBar. + **/ + element: HTMLElement; + + /** + * Gets a value that indicates whether the NavBar is hidden or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + layout: string; + + /** + * Gets or sets a value that specifies whether the NavBar appears at the top or bottom of the main view. + **/ + placement: string; + + /** + * Gets or sets a value that indicates whether the NavBar is sticky (won't light dismiss). If not sticky, the NavBar dismisses normally when the user touches outside of the NavBar. + **/ + sticky: boolean; + + //#endregion Properties + + } + + /** + * Represents a navigation command in a NavBarContainer. + **/ + class NavBarCommand { + //#region Constructors + + /** + * Creates a new NavBarCommand. + * @constructor + * @param element The DOM element hosts the new NavBarCommand. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this NavBarCommand. Call this method when the NavBarCommand is no longer needed. After calling this method, the NavBarCommand becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the HTML element that hosts this NavBarCommand. + **/ + element: HTMLElement; + + /** + * Gets or sets the command's icon. + **/ + icon: string; + + /** + * Gets or sets the label of the command. + **/ + label: string; + + /** + * Get or sets the location to navigate to when this command is invoked. + **/ + location: Object; + + /** + * Gets or sets a value that specifies whether to show the split tab stop. + **/ + splitButton: boolean; + + /** + * Gets a value that indicates whether the splitButton is open. + **/ + splitOpened: boolean; + + /** + * Gets or sets a user-defined object that represents the state associated with the command's location. + **/ + state: Object; + + /** + * Gets or sets the tooltip of the command. + **/ + tooltip: any; + + //#endregion Properties + + } + + /** + * Contains a group of NavBarCommand objects in a NavBar. + **/ + class NavBarContainer { + //#region Constructors + + /** + * Creates a new NavBarContainer. + * @constructor + * @param element The DOM element hosts the new NavBarContainer. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element: Object, options: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when a child NavBarCommand object's click event fires. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.index, detail.navbarcommand, detail.data. + **/ + oninvoked(eventInfo: CustomEvent): void; + + /** + * Occurs when the split button of a child NavBarCommand is opened or closed. A split button is toggled when the user navigates to another page or opens another split button. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.opened, detail.index, detail.navbarcommand, detail.data. + **/ + onsplittoggle(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this NavBarCommand. Call this method when the NavBarCommand is no longer needed. After calling this method, the NavBarCommand becomes unusable. + **/ + dispose(): void; + + /** + * Forces the NavBarContainer to update its layout. Use this function when making the NavBarContainer visible again after you set its style.display property to "none". + **/ + forceLayout(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the index of the current item. + **/ + currentIndex: number; + + /** + * Gets or sets a WinJS.Binding.List that generates NavBarCommand objects. + **/ + data: WinJS.Binding.List; + + /** + * Gets the HTML element that hosts this NavBarContainer. + **/ + element: HTMLElement; + + /** + * Gets or sets a value that specifies whether NavBarCommand objects in this container use a fixed or dynamic width. + **/ + fixedSize: boolean; + + /** + * Gets or sets a value that specifies whether the NavBarContainer has a horizontal or vertical layout. + **/ + layout: Orientation; + + /** + * Gets or sets a value that specifies how many rows of navigation commands to display on a page. + **/ + maxRows: number; + + /** + * Gets or sets the WinJS.Binding.Template or templating function that creates the DOM elements for each item in the data source. Each item can contain multiple elements, but it must have a single root element. + **/ + template: WinJS.Binding.Template; + + //#endregion Properties + + } + + /** + * Lets the user rate something by clicking an icon that represents a rating. The Rating control can display three types of ratings: an average rating, a tentative rating, and the user's rating. + **/ + class Rating { + //#region Constructors + + /** + * Creates a new Rating. + * @constructor + * @param element The DOM element hosts the new Rating. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Raised when the user finishes interacting with the rating control without committing a tentative rating. + * @param eventInfo An object that contains information about the event. + **/ + oncancel(eventInfo: Event): void; + + /** + * Raised when the user commits a change to the userRating. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tentativeRating. + **/ + onchange(eventInfo: CustomEvent): void; + + /** + * Raised when the user is choosing a new tentative Rating. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tentativeRating. + **/ + onpreviewchange(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Releases resources held by this Rating. Call this method when the Rating is no longer needed. After calling this method, the Rating becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the average rating. + **/ + averageRating: number; + + /** + * Gets or sets whether the control is disabled. When the control is disabled, the user can't specify a new user rating or modify an existing rating. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the Rating. + **/ + element: HTMLElement; + + /** + * Gets or sets whether control lets the user clear the rating. + **/ + enableClear: boolean; + + /** + * Gets or sets the maximum possible rating value. + **/ + maxRating: number; + + /** + * Gets or sets a set of descriptions to show for rating values in the tooltip. + **/ + tooltipStrings: string[]; + + /** + * Gets or sets the user's rating. + **/ + userRating: number; + + //#endregion Properties + + } + + /** + * Generates HTML from a set of data. Use this control to generate lists of items. + **/ + class Repeater { + //#region Constructors + + /** + * Creates a new Repeater control. + * @constructor + * @param options An object that contains one or more property/value pairs to apply to the new Repeater. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". + **/ + constructor(options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Raised after an item in the Repeater control's data source changes and after the corresponding DOM element has been updated. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.index, detail.key, detail.newElement, detail.newItem, detail.newValue, detail.oldElement, detail.oldItem, detail.oldValue, detail.setPromise. + **/ + onitemchanged(eventInfo: CustomEvent): void; + + /** + * Raised after an item in the Repeater control's data source changes but before the corresponding DOM element has been updated. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.index, detail.key, detail.newElement, detail.newItem, detail.newValue, detail.oldElement, detail.oldItem, detail.oldValue, detail.setPromise. + **/ + onitemchanging(eventInfo: CustomEvent): void; + + /** + * Raised after an item has been added to the Repeater control's data source and after the corresponding DOM element has been added. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.value. + **/ + oniteminserted(eventInfo: CustomEvent): void; + + /** + * Raised after an item has been added to the Repeater control's data source but before the corresponding DOM element has been added. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.value. + **/ + oniteminserting(eventInfo: CustomEvent): void; + + /** + * Raised after an item has been moved from one index to another in the Repeater control's data source and after the corresponding DOM element has been moved. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.oldIndex, detail.newIndex. + **/ + onitemmoved(eventInfo: CustomEvent): void; + + /** + * Raised after an item has been moved from one index to another in the Repeater control's data source but before the corresponding DOM element has been moved. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.key, detail.oldIndex, detail.newIndex. + **/ + onitemmoving(eventInfo: CustomEvent): void; + + /** + * Raised after an item has been moved from one index to another in the Repeater control's data source and after the corresponding DOM element has been moved. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.item, detail.setPromise. + **/ + onitemremoved(eventInfo: CustomEvent): void; + + /** + * Raised after an item has been removed from the Repeater control's data source but before the corresponding DOM element has been removed. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElement, detail.index, detail.item, detail.setPromise. + **/ + onitemremoving(eventInfo: CustomEvent): void; + + /** + * Raised when the Repeater has finished loading a new set of data. This event is only fired on construction. This event is only raised when the Repeater is constructed or its data source or template changes. + * @param eventInfo An object that contains information about the event. + **/ + onitemsloaded(eventInfo: CustomEvent): void; + + /** + * Raised after the Repeater control's underlying data has been updated and after the updated HTML has been reloaded. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElements. + **/ + onitemsreloaded(eventInfo: CustomEvent): void; + + /** + * Raised after the Repeater control's underlying data has been updated but before the updated HTML has been reloaded. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.affectedElements, detail.setPromise. + **/ + onitemsreloading(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this Repeater. Call this method when the Repeater is no longer needed. After calling this method, the Repeater becomes unusable. + **/ + dispose(): void; + + /** + * Returns the HTML element for the item at the specified index. + * @param index The index of the item. + * @returns The DOM element for the specified item. + **/ + elementFromIndex(index: number): HTMLElement; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the List that provides the Repeater with items to display. + **/ + data: WinJS.Binding.List; + + /** + * Gets the DOM element that hosts the Repeater. + **/ + element: HTMLElement; + + /** + * Gets the number of items in the Repeater control. + **/ + length: number; + + /** + * Gets or sets a WinJS.Binding.Template or custom rendering function that defines the HTML of each item within the Repeater. + **/ + template: WinJS.Binding.Template; + + //#endregion Properties + + } + + /** + * Enables the user to perform search queries and select suggestions. + **/ + class SearchBox { + //#region Constructors + + /** + * Creates a new SearchBox. + * @constructor + * @param element The DOM element hosts the new SearchBox. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element: Object, options: Object); + + //#endregion Constructors + + //#region Events + + /** + * Raised when the user or the app changes the queryText. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails. + **/ + onquerychanged(eventInfo: CustomEvent): void; + + /** + * Raised awhen the user clicks the search glyph or presses Enter. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails, detail.keyModifiers. + **/ + onquerysubmitted(eventInfo: CustomEvent): void; + + /** + * Raised when the app automatically redirects focus to the search box. This event can only be raised when the focusOnKeyboardInput property is set to true. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.propertyName. + **/ + onreceivingfocusonkeyboardinput(eventInfo: CustomEvent): void; + + /** + * Raised when the user selects a suggested option for the search. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tag, detail.keyModifiers, detail.storageFile. + **/ + onresultsuggestionschosen(eventInfo: CustomEvent): void; + + /** + * Raised when the system requests search suggestions from this app. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.linguisticDetails, detail.queryText, detail.searchSuggestionCollection. + **/ + onsuggestionsrequested(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this SearchBox. Call this method when the SearchBox is no longer needed. After calling this method, the SearchBox becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Specifies whether suggestions based on local files are automatically displayed in the search pane, and defines the criteria that Windows uses to locate and filter these suggestions. + * @param settings The new settings for local content suggestions. + **/ + setLocalContentSuggestionSettings(settings: Windows.ApplicationModel.Search.LocalContentSuggestionSettings): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets whether the first suggestion is chosen when the user presses Enter. + **/ + chooseSuggestionOnEnter: boolean; + + /** + * Gets or sets a value that specifies whether the SearchBox is disabled. If the control is disabled, it won't receive focus. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the SearchBox. + **/ + element: HTMLElement; + + /** + * Gets or sets a value that specifies whether the search box automatically receives focus when the user types into the app window. + **/ + focusOnKeyboardInput: boolean; + + /** + * Gets or sets the placeholder text for the SearchBox. This text is displayed if there is no other text in the input box. + **/ + placeholderText: string; + + /** + * Gets or sets the query text for the SearchBox. + **/ + queryText: string; + + /** + * Gets or sets the search history context. This context is used a secondary key (the app ID is the primary key) for storing search history. + **/ + searchHistoryContext: string; + + /** + * Gets or sets a value that specifies whether search history is disabled. + **/ + searchHistoryDisabled: boolean; + + //#endregion Properties + + } + + /** + * Enables the user to zoom between two different views supplied by two child controls. One child control supplies the zoomed-out view and the other provides the zoomed-in view. + **/ + class SemanticZoom { + //#region Constructors + + /** + * Creates a new SemanticZoom. + * @constructor + * @param element The DOM element that hosts the SemanticZoom. + * @param options An object that contains one or more property/value pairs to apply to the new control. This object can contain these properties: initiallyZoomedOut Boolean, zoomFactor 0.2–0.85. + **/ + constructor(element: HTMLElement, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when the control zooms in or out. + * @param eventInfo An object that contains information about the event. The detail property of this object is true when the control is zoomed out. Otherwise, it's false. + **/ + onzoomchanged(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this SemanticZoom. Call this method when the SemanticZoom is no longer needed. After calling this method, the SemanticZoom becomes unusable. + **/ + dispose(): void; + + /** + * Forces the SemanticZoom to update its layout. Use this function when making the SemanticZoom visible again after its style.display property had been set to "none". + **/ + forceLayout(): void; + + /** + * Unregisters an event handler for the specified event. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the DOM element that hosts the SemanticZoom control. + **/ + element: HTMLElement; + + /** + * Gets or a sets a value that specifies whether to display the SemanticZoom zoom out button. + **/ + enableButton: boolean; + + /** + * Determines whether any controls contained in a SemanticZoom should be processed separately. This property is always true, meaning that the SemanticZoom takes care of processing its own controls. + **/ + isDeclarativeControlContainer: boolean; + + /** + * Gets or sets a value that indicates whether SemanticZoom is locked and zooming between views is disabled. + **/ + locked: boolean; + + /** + * Gets or sets a value that indicates whether the control is zoomed out. + **/ + zoomedOut: boolean; + + /** + * Gets or sets a value that specifies how much the scaling the cross-fade animation performs when the SemanticZoom transitions between views. + **/ + zoomFactor: number; + + //#endregion Properties + + } + + /** + * Provides users with fast, in-context access to settings that affect the current Windows Store app. + **/ + class SettingsFlyout { + //#region Constructors + + /** + * Creates a new SettingsFlyout object. + * @constructor + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new SettingsFlyout. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Raised immediately after the SettingsFlyout is completely hidden. + * @param eventInfo An object that contains information about the event. + **/ + onafterhide(eventInfo: Event): void; + + /** + * Raised immediately after a SettingsFlyout is fully shown. + * @param eventInfo An object that contains information about the event. + **/ + onaftershow(eventInfo: Event): void; + + /** + * Raised just before hiding a SettingsFlyout. + * @param eventInfo An object that contains information about the event. + **/ + onbeforehide(eventInfo: Event): void; + + /** + * Raised just before showing a SettingsFlyout. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeshow(eventInfo: Event): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this SettingsFlyout. Call this method when the SettingsFlyout is no longer needed. After calling this method, the SettingsFlyout becomes unusable. + **/ + dispose(): void; + + /** + * Hides the SettingsFlyout, if visible, regardless of other states. + **/ + hide(): void; + + /** + * Loads a fragment of the SettingsFlyout. Your app calls this when the user invokes a settings command and the WinJS.Application.onsettings event occurs. + * @param e An object that contains information about the event, received from the WinJS.Application.onsettings event. The detail property of this object contains the applicationcommands sub-property that you set to an array of settings commands. You then populate the SettingsFlyout with these commands by a call to populateSettings. + **/ + populateSettings(e: CustomEvent): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Shows the SettingsPane UI, if hidden, regardless of other state. + **/ + show(): void; + + /** + * Show the Settings flyout using the Settings element identifier (ID) and the path of the page that contains the Settings element. + * @param id The ID of the Settings element. + * @param path The path of the page that contains the Settings element. + **/ + showSettings(id: string, path: Object): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the DOM element the SettingsFlyout is attached to. + **/ + element: HTMLElement; + + /** + * Gets whether the SettingsFlyout is hidden. + **/ + hidden: boolean; + + /** + * Gets or sets the settings command Id for the SettingsFlyout control. + **/ + settingsCommandId: string; + + /** + * This property may be unavailable or altered in future versions. Use the CSS width property of the element that has the win-settingsflyout class instead. + **/ + width: string; + + //#endregion Properties + + } + + /** + * A type of IListDataSource that provides read-access to an object that implements the IStorageQueryResultBase interface. A StorageDataSource enables you to query and bind to items in the data source. + **/ + class StorageDataSource { + //#region Methods + + /** + * Draws the thumbnail for the specified item to the specified img element. + * @param item The item to retrieve the thumbnail for. + * @param image The img element that will display the thumbnail. + * @returns A Promise that completes when the full-quality thumbnail is visible. + **/ + loadThumbnail(item: IItem, image: HTMLElement): Promise; + + /** + * Creates a new StorageDataSource object. + * @param query The IStorageQueryResultBase that the StorageDataSource obtains its items from. Instead of IStorageQueryResultBase, you can also pass one of these string values: Music, Pictures, Videos, Documents. + * @param options The set of properties and values to apply to the new StorageDataSource. Properties on this object may include: mode , requestedThumbnailSize , thumbnailOptions , synchronous . + **/ + StorageDataSource(query: Windows.Storage.Search.IStorageQueryResultBase, options: Object): void; + + //#endregion Methods + + } + + /** + * Prevents a DOM sub-tree from receiving tab navigations and focus. + **/ + class TabContainer { + //#region Constructors + + /** + * Creates a new TabContainer. + * @constructor + * @param element The DOM element that hosts the TabContainer control. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties. + **/ + constructor(element: Object, options?: Object); + + //#endregion Constructors + + //#region Methods + + /** + * Releases resources held by this TabContainer. Call this method when the TabContainer is no longer needed. After calling this method, the TabContainer becomes unusable. + **/ + dispose(): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the child DOM element that receives tab focus. + **/ + childFocus: HTMLElement; + + /** + * Gets or sets the tab index of this container. + **/ + tabIndex: any; + + //#endregion Properties + + } + + /** + * Allows users to select time values. + **/ + class TimePicker { + //#region Constructors + + /** + * Initializes a new instance of a TimePicker control. + * @constructor + * @param element The DOM element associated with the TimePicker control. + * @param options The set of options to be applied initially to the TimePicker control. The options are the following: clock. + **/ + constructor(element: HTMLElement, options: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when any of the controls are changed by the user. + * @param eventInfo An object that contains information about the event. + **/ + onchange(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Adds an event listener. + * @param type The type (name) of the event. + * @param listener The function that handles the event. + * @param capture If true, specifies that capture should be initiated, otherwise false. + **/ + addEventListener(type: string, listener: Function, capture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this TimePicker. Call this method when the TimePicker is no longer needed. After calling this method, the TimePicker becomes unusable. + **/ + dispose(): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + raiseEvent(type: string, eventProperties: Object): boolean; + + /** + * Removes a listener for the specified event. + * @param type The name of the event for which to remove a listener. + * @param listener The listener. + * @param useCapture Optional. The same value that was passed to addEventListener for this listener. It may be omitted if it was omitted when calling addEventListener. + **/ + removeEventListener(type: string, listener: Function, useCapture?: Object): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the type of clock to display (12HourClock or 24HourClock). It defaults to the user setting. + **/ + clock: string; + + /** + * Gets or sets the current time of the TimePicker. Note that the date value is always July 15, 2011. + **/ + current: Date; + + /** + * Specifies whether the TimePicker is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element for the TimePicker. + **/ + element: HTMLElement; + + /** + * Gets or sets the display pattern for the hour. The default hour pattern is hour.integer(2). You can change the hour pattern by changing the number of integers displayed. + **/ + hourPattern: string; + + /** + * Gets or sets the minute increment. For example, 15 specifies that the TimePicker minute control should display only the choices 00, 15, 30, 45. + **/ + minuteIncrement: number; + + /** + * Gets or sets the display pattern for the minute. The default minute pattern is minute.integer(2). You can change the minute pattern by changing the number of integers displayed. + **/ + minutePattern: string; + + /** + * Gets or sets the display pattern for the period. The default period pattern is period.abbreviated(2). You can change the period pattern by changing the number of integers displayed. + **/ + periodPattern: string; + + //#endregion Properties + + } + + /** + * A control that lets the user switch an option between two states: on (checked is set to true) and off (checked is set to false). + **/ + class ToggleSwitch { + //#region Constructors + + /** + * Creates a new ToggleSwitch. + * @constructor + * @param element The DOM that hosts the control. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the change event, add a property named "onchange" to the options object and set its value to the event handler. + **/ + constructor(element: Object, options: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when the ToggleSwitch control is flipped to on (checked == true) or off (checked == false). + * @param eventInfo An object that contains information about the event. + **/ + onchange(eventInfo: Event): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Releases resources held by this ToggleSwitch. Call this method when the ToggleSwitch is no longer needed. After calling this method, the ToggleSwitch becomes unusable. + **/ + dispose(): void; + + /** + * Handles the specified event. + * @param event The event. + **/ + handleEvent(event: any): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + raiseEvent(type: string, eventProperties: Object): boolean; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that specifies whether the control is on or off. + **/ + checked: boolean; + + /** + * Gets or sets a value that specifies whether the control is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the ToggleSwitch. + **/ + element: HTMLElement; + + /** + * Gets or sets the text that displays when the ToggleSwitch is off (checked is set to false). + **/ + labelOff: string; + + /** + * Gets or sets the text that displays when the ToggleSwitch is on (checked is set to true). + **/ + labelOn: string; + + /** + * Gets or sets the main text for the ToggleSwitch control. This text is always displayed, regardless of whether the control is switched on or off. + **/ + title: string; + + //#endregion Properties + + } + + /** + * Displays a tooltip that can contain images and formatting. + **/ + class Tooltip { + //#region Events + + /** + * Raised just before the Tooltip is hidden. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeclose(eventInfo: CustomEvent): void; + + /** + * Raised just before the Tooltip appears. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeopen(eventInfo: CustomEvent): void; + + /** + * Raised when the Tooltip is no longer displayed. + * @param eventInfo An object that contains information about the event. + **/ + onclosed(eventInfo: CustomEvent): void; + + /** + * Raised when the Tooltip is shown. + * @param eventInfo An object that contains information about the event. + **/ + onopened(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Adds an event handler for the specified event. + * @param eventName The name of the event to handle. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Hides the Tooltip. + **/ + close(): void; + + /** + * Releases resources held by this Tooltip. Call this method when the Tooltip is no longer needed. After calling this method, the Tooltip becomes unusable. + **/ + dispose(): void; + + /** + * Shows the Tooltip. + * @param type A value that specifies when to show the Tooltip. The default value is "mousedown". + **/ + open(type?: string): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Creates a new Tooltip. + * @param element The DOM element associated that hosts the Tooltip. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the opened event, add a property named "onopened" to the options object and set its value to the event handler. + **/ + Tooltip(element: Object, options: Object): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the HTML element that is the content of the Tooltip. + **/ + contentElement: HTMLElement; + + /** + * Gets the DOM element that hosts the Tooltip control. + **/ + element: HTMLElement; + + /** + * Gets or appends additional CSS classes to apply to the element that hosts the Tooltip. + **/ + extraClass: string; + + /** + * Gets or sets a value that specifies whether the Tooltip is an infotip, a tooltip that contains a lot of info and should be displayed for longer than a typical Tooltip. + **/ + infotip: boolean; + + /** + * Gets or sets the HTML content of the Tooltip. + **/ + innerHTML: string; + + /** + * Gets or sets the position for the Tooltip relative to its target element: top, bottom, left or right. + **/ + placement: string; + + //#endregion Properties + + } + + /** + * Scales a single child element to fill the available space without resizing it. This control reacts to changes in the size of the container as well as changes in size of the child element. For example, a media query may result in a change in aspect ratio. + **/ + class ViewBox { + //#region Methods + + /** + * Adds an event handler for the specified event. + * @param eventName The name of the event to handle. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Releases resources held by this ViewBox. Call this method when the ViewBox is no longer needed. After calling this method, the ViewBox becomes unusable. + **/ + dispose(): void; + + /** + * Forces the ViewBox to update its layout. Use this function when making the ViewBox visible again after its style.display property had been set to "none". + **/ + forceLayout(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Initializes a new instance of the ViewBox control. + * @param element The DOM element that functions as the scaling box. This element fills 100% of the width and height allotted to it. + * @param options The set of options to be applied initially to the ViewBox control. There are currently no options on this control, and any options included in this parameter are ignored. + **/ + ViewBox(element: HTMLElement, options: Object): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the DOM element that functions as the scaling box. + **/ + element: Object; + + //#endregion Properties + + } + + /** + * Serves as the base class for a custom IListDataSource. + **/ + class VirtualizedDataSource { + //#region Constructors + + /** + * Initializes the VirtualizedDataSource base class of a custom data source. + * @constructor + * @param listDataAdapter The object that supplies data to the VirtualizedDataSource. + * @param options An object that can contain properties that specify additional options for the VirtualizedDataSource. It supports these properties: cacheSize. + **/ + constructor(listDataAdapter: IListDataAdapter, options?: Object); + + //#endregion Constructors + + //#region Events + + /** + * Occurs when the status of the VirtualizedDataSource changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: status. + **/ + statuschanged(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. See the VirtualizedDataSource object page for a list of events. Note that you drop the "on" when specifying the event name for the addEventListener method. For example, instead of specifying "onstatuschanged", you specify "statuschanged". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. See the VirtualizedDataSource object page for a list of events. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + } + + //#endregion Objects + + //#region Functions + + /** + * Returns a new IListDataSource that adds group information to the items of another IListDataSource. + * @param listDataSource The data source for the individual items to group. + * @param groupKey A callback function that accepts a single argument: an item in the IListDataSource. The function is called for each item in the list and must return the group key for that item as a string. + * @param groupData A callback function that accepts a single argument: an item in the IListDataSource. The function is called on one IListDataSource item for each group and must return an object that represents the header of that group. + * @param options An object that can contain properties that specify additional options: groupCountEstimate, batchSize. + * @returns An IListDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list. + **/ + function computeDataSourceGroups(listDataSource: IListDataSource, groupKey: Function, groupData: Function, options?: Object): IListDataSource; + + /** + * Used to disables all Animations Library and ListView animations. Calling this function does not guarantee that the animations will be disabled, as the determination is made based on several factors. + **/ + function disableAnimations(): void; + + /** + * Used to enable all Animations Library and ListView animations. Calling this function does not guarantee that the animations will be enabled, as the determination is made based on several factors. + **/ + function enableAnimations(): void; + + /** + * Marks a event handler function as being compatible with declarative processing. + * @param handler The handler to be marked as compatible with declarative processing. + * @returns The handler, marked as compatible with declarative processing. + **/ + function eventHandler(handler: Object): Object; + + /** + * Asynchronously executes a collection of CSS animations on a collection of elements. This is the underlying animation mechanism used by the Animations Library. Apps are encouraged to use the Animations Library to conform with the standard look and feel of the rest of the system, rather than calling this function directly. + * @param element Element or elements to be animated. This parameter can be expressed in several ways: As the special value "undefined", which means that the animation has no target, As a single object, As a JavaScript array (possibly empty), in which each element of the array can be a single element or a JavaScript array of elements., As a NodeList (for example, the result of querySelectorAll), As an HTMLCollection. + * @param animation The animation description or an array of animation descriptions to apply to element. An animation description is a JavaScript object with specific properties, listed below. There are two types of animation descriptions: one for keyframe-based animations and one for explicit animations. These types are distinguished by whether the keyframe property has a defined value. The following properties are required for both types of animation descriptions: property (string), delay (number), duration (number), timing (string). If an animation has a keyframe property with a defined, non-null value, then the animation is a keyframe-based animation. A keyframe-based animation description requires the following property in addition to those mentioned above: keyframe (string). If an animation does not have a keyframe property, or if the value of the property is null or undefined, then the animation is an explicit animation. An explicit animation description requires the following properties in addition to the common properties mentioned above: from, to. The values given in the from and to properties must be valid for the CSS property specified by the property property. For example, if the CSS property is "opacity", then the from and to properties must be numbers between 0 and 1 (inclusive). + * @returns Returns a Promise object that completes when the CSS animation is complete. + **/ + function executeAnimation(element: Object, animation: Object): Promise; + + /** + * Asynchronously executes a collection of CSS transitions on a collection of elements. This is the underlying animation mechanism used by the Animations Library. Apps are encouraged to use the Animations Library to conform with the standard look and feel of the rest of the system, rather than calling this function directly. + * @param element Element or elements on which to perform the transition. This parameter can be expressed in several ways: As the special value "undefined", which means that the transition has no target, As a single object, As a JavaScript array (possibly empty), in which each element of the array can be a single element or a JavaScript array of elements., As a NodeList (for example, the result of querySelectorAll), As an HTMLCollection. + * @param transition The transition description or an array of transition descriptions to apply to element. A transition description is a JavaScript object with these properties: property (string), delay (number), duration (number), timing (string), from (optional), to. The values given in the from and to properties must be valid for the CSS property specified by the property property. For example, if the CSS property is "opacity", then the from and to properties must be numbers between 0 and 1 (inclusive). + * @returns Returns a Promise that completes when the transition is finished. + **/ + function executeTransition(element: Object, transition: Object): Promise; + + /** + * Retrieves the items in the specified index range. + * @param dataSource The data source that contains the items to retrieve. + * @param ranges An array of ISelectionRange objects that have firstIndex and lastIndex values. + * @returns A Promise that contains an array of the requested IItem objects. + **/ + function getItemsFromRanges(dataSource: IListDataSource, ranges: ISelectionRange[]): Promise>; + + /** + * Determines whether the Animations Library and ListView animations will be performed if called. + * @returns Returns true if animations will be performed; otherwise false. + **/ + function isAnimationEnabled(): boolean; + + /** + * Applies declarative control binding to all elements, starting at the specified root element. + * @param rootElement The element at which to start applying the binding. If this parameter is not specified, the binding is applied to the entire document. + **/ + function processAll(rootElement: Element): void; + + /** + * Applies declarative control binding to the specified element. + * @param element The element to bind. + **/ + function process(element: Element): void; + + /** + * Walks the DOM tree from the given element to the root of the document. Whenever a selector scope is encountered, this method performs a lookup within that scope for the specified selector string. The first matching element is returned. + * @param selector The selector string. + * @param element The element to begin walking to the root of the document from. + * @returns The target element, if found. + **/ + function scopedSelect(selector: string, element: HTMLElement): HTMLElement; + + /** + * Given a DOM element and a control, attaches the control to the element. + * @param element Element to associate with the control. + * @param control The control to attach to the element. + **/ + function setControl(element: HTMLElement, control: Object): void; + + /** + * Adds the set of declaratively specified options (properties and events) to the specified control. If name of the options property begins with "on", the property value is a function and the control supports addEventListener. setControl calls addEventListener on the control. + * @param control The control on which the properties and events are to be applied. + * @param options The set of options that are specified declaratively. + **/ + function setOptions(control: Object, options: Object): void; + + //#endregion Functions + +} +/** + * Provides functions to load HTML content programmatically. +**/ +declare module WinJS.UI.Fragments { + //#region Functions + + /** + * Starts loading the fragment at the specified location. The returned promise completes when the fragment is ready to be copied. + * @param href The URI that contains the fragment to be copied. + * @returns A promise that is fulfilled when the fragment has been prepared for copying. + **/ + function cache(href: string): Promise; + + /** + * Removes any cached information about the specified fragment. This method does not unload any scripts or styles that are referenced by the fragment. + * @param href The URI that contains the fragment to be cleared. If no URI is provided, the entire contents of the cache are cleared. + **/ + function clearCache(href: string): void; + + /** + * Loads the contents of the specified URI into the specified element without copying it. + * @param href The URI that contains the fragment to copy. + * @param element Optional. The element to which the fragment is appended. + * @returns A promise that is fulfilled when the fragment has been loaded. If a target element is not specified, the copied fragment is the completed value. The element is not added to the cache. See also rendercopy, where the element is added to the cache. + **/ + function render(href: string, element: HTMLElement): Promise; + + /** + * Loads and copies the contents of the specified URI into the specified element. + * @param href The URI that contains the fragment to copy. + * @param target The element to which the fragment is appended. + * @returns A promise that is fulfilled when the fragment has been loaded. If a target element is not specified, the copied fragment is the completed value. The fragment is added to the cache. See also render, where the element is not added to the cache. + **/ + function renderCopy(href: string, target: HTMLElement): Promise; + + //#endregion Functions + +} +/** + * Provides methods for defining and displaying PageControl objects. +**/ +declare module WinJS.UI.Pages { + //#region Interfaces + + /** + * Provides members for a PageControl. You implement this interface when defining a new PageControl. + **/ + interface IPageControlMembers { + //#region Methods + + /** + * Called if any error occurs during the processing of the page. + * @param err The error that occurred. + * @returns Nothing if the error was handled, or an error promise if the error was not handled. + **/ + error?(err: Object): Promise; + + /** + * Initializes the control before the content of the control is set. Use the processed method for any initialization that should be done after the content of the control has been set. + * @param element The DOM element that will contain all the content for the page. + * @param options The options passed to the constructor of the page. + * @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing. + **/ + init?(element: HTMLElement, options: Object): Promise; + + /** + * Creates DOM objects from the content in the specified URI. This method is called after the PageControl is defined and before the init method is called. + * @param uri The URI from which to create DOM objects. + * @returns A promise whose fulfilled value is the set of unparented DOM objects. + **/ + load?(uri: string): Promise; + + /** + * Initializes the control after the content of the control is set. + * @param element The DOM element that will contain all the content for the page. + * @param options The options that are to be passed to the constructor of the page. + * @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing. + **/ + processed?(element: HTMLElement, options: Object): Promise; + + /** + * Called after all initialization and rendering is complete. At this time, the element is ready for use. + * @param element The DOM element that contains all the content for the page. + * @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl. + * @returns A promise that is fulfilled when the element is ready for use, if asynchronous processing is necessary. If not, returns nothing. + **/ + ready?(element: HTMLElement, options: Object): Promise; + + /** + * Takes the elements returned by the load method and attaches them to the specified element. + * @param element The DOM element to which the loadResult elements are appended. + * @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl. + * @param loadResult A Promise that contains the elements returned from the load method. + **/ + render?(element: HTMLElement, options: Object, loadResult: Promise): void; + + //#endregion Methods + + } + + //#endregion Interfaces + + //#region Objects + + /** + * A modular unit of HTML, CSS, and JavaScript that can be navigated to or used as a custom WinJS control. + **/ + class PageControl { + } + + //#endregion Objects + + //#region Functions + + /** + * Creates a new PageControl from the specified URI that contains the specified members. Multiple calls to this method for the same URI are allowed, and all members will be merged. + * @param uri The URI for the content that defines the page. + * @param members An object that defines the members that the control will have. + * @returns A constructor function that creates the PageControl. + **/ + function define(uri: string, members: IPageControlMembers): PageControl; + + /** + * Gets an already-defined page control for the specified URI, or creates a new one. + * @param uri The URI for the content that defines the page. + * @returns A constructor function that creates the page. + **/ + function get(uri: string): Function; + + /** + * Creates a PageControl from the specified URI and inserts it inside the specified element. + * @param uri The URI for the content that defines the page. + * @param element The DOM element to which the PageControl is appended. + * @param options An object that contains one or more property/value pairs to apply to the new PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl. + * @param parentedPromise A Promise that is fulfilled when the new PageControl is done rendering and its contents becomes the child of element. + * @returns A promise that is fulfilled when rendering is complete, if asynchronous processing is necessary. If not, returns nothing. + **/ + function render(uri: string, element: HTMLElement, options?: Object, parentedPromise?: Promise): Promise; + + //#endregion Functions + +} +/** + * Provides methods for detecting when the user tabs to or from DOM elements. +**/ +declare module WinJS.UI.TrackTabBehavior { + //#region Functions + + /** + * Sets the tab order for the specified element within its container. + * @param element The element to update. + * @param tabIndex The index value of the element within its container. + **/ + function attach(element: HTMLElement, tabIndex: number): void; + + /** + * Removes the tab order information from the specified element. + * @param element The element to remove tab information from. + **/ + function detatch(element: HTMLElement): void; + + //#endregion Functions + +} +/** + * Provides helper functions, for example, functions to add and remove CSS classes. +**/ +declare module WinJS.Utilities { + //#region Enumerations + + /** + * Defines a set of keyboard values. + **/ + enum Key { + /** + * The BACKSPACE key. + **/ + backspace, + /** + * The TAB key. + **/ + tab, + /** + * The ENTER key. + **/ + enter, + /** + * The SHIFT key. + **/ + shift, + /** + * The CTRL key. + **/ + ctrl, + /** + * The ALT key. + **/ + alt, + /** + * The PAUSE key. + **/ + pause, + /** + * The CAPS LOCK key. + **/ + capsLock, + /** + * The ESCAPE key. + **/ + escape, + /** + * The SPACE key. + **/ + space, + /** + * The PAGE UP key. + **/ + pageUp, + /** + * The PAGE DOWN key. + **/ + pageDown, + /** + * The END key. + **/ + end, + /** + * The HOME key. + **/ + home, + /** + * The LEFT ARROW key. + **/ + leftArrow, + /** + * The UP ARROW key. + **/ + upArrow, + /** + * The RIGHT ARROW key. + **/ + rightArrow, + /** + * The DOWN ARROW key. + **/ + downArrow, + /** + * The INSERT key. + **/ + insert, + /** + * The DELETE key. + **/ + deleteKey, + /** + * The 0 key. + **/ + num0, + /** + * The 1 key. + **/ + num1, + /** + * The 2 key. + **/ + num2, + /** + * The 3 key. + **/ + num3, + /** + * The 4 key. + **/ + num4, + /** + * The 5 key. + **/ + num5, + /** + * The 6 key. + **/ + num6, + /** + * The 7 key. + **/ + num7, + /** + * The 8 key. + **/ + num8, + /** + * The 9 key. + **/ + num9, + /** + * The a key. + **/ + a, + /** + * The b key. + **/ + b, + /** + * The c key. + **/ + c, + /** + * The d key. + **/ + d, + /** + * The e key. + **/ + e, + /** + * The f key. + **/ + f, + /** + * The g key. + **/ + g, + /** + * The h key. + **/ + h, + /** + * The i key. + **/ + i, + /** + * The j key. + **/ + j, + /** + * The k key. + **/ + k, + /** + * The l key. + **/ + l, + /** + * The m key. + **/ + m, + /** + * The n key. + **/ + n, + /** + * The o key. + **/ + o, + /** + * The p key. + **/ + p, + /** + * The q key. + **/ + q, + /** + * The r key. + **/ + r, + /** + * The s key. + **/ + s, + /** + * The t key. + **/ + t, + /** + * The u key. + **/ + u, + /** + * The v key. + **/ + v, + /** + * The w key. + **/ + w, + /** + * The x key. + **/ + x, + /** + * The y key. + **/ + y, + /** + * The z key. + **/ + z, + /** + * The left Windows key. + **/ + leftWindows, + /** + * The right Windows key. + **/ + rightWindows, + /** + * The menu key. + **/ + menu, + /** + * The 0 key on the numerical keypad. + **/ + numPad0, + /** + * The 1 key on the numerical keypad. + **/ + numPad1, + /** + * The 2 key on the numerical keypad. + **/ + numPad2, + /** + * The 3 key on the numerical keypad. + **/ + numPad3, + /** + * The 4 key on the numerical keypad. + **/ + numPad4, + /** + * The 5 key on the numerical keypad. + **/ + numPad5, + /** + * The 6 key on the numerical keypad. + **/ + numPad6, + /** + * The 7 key on the numerical keypad. + **/ + numPad7, + /** + * The 8 key on the numerical keypad. + **/ + numPad8, + /** + * The 9 key on the numerical keypad. + **/ + numPad9, + /** + * The multiplication key (*). + **/ + multiply, + /** + * The addition key (+). + **/ + add, + /** + * The subtraction key (-). + **/ + subtract, + /** + * The decimal point key (.) + **/ + decimalPoint, + /** + * The division key (/). + **/ + divide, + /** + * The F1 key. + **/ + F1, + /** + * The F2 key. + **/ + F2, + /** + * The F3 key. + **/ + F3, + /** + * The F4 key. + **/ + F4, + /** + * The F5 key. + **/ + F5, + /** + * The F6 key. + **/ + F6, + /** + * The F7 key. + **/ + F7, + /** + * The F8 key. + **/ + F8, + /** + * The F9 key. + **/ + F9, + /** + * The F10 key. + **/ + F10, + /** + * The F11 key. + **/ + F11, + /** + * The F12 key. + **/ + F12, + /** + * The NUMBER LOCK key. + **/ + numLock, + /** + * The SCROLL LOCK key. + **/ + scrollLock, + /** + * The browser BACK key. + **/ + browserBack, + /** + * The browser FORWARD key. + **/ + browserForward, + /** + * The semicolon key (;). + **/ + semicolon, + /** + * The equals key (=). + **/ + equal, + /** + * The comma key (,). + **/ + comma, + /** + * The dash key (-). + **/ + dash, + /** + * The period key (.). + **/ + period, + /** + * The forward slash key (/). + **/ + forwardSlash, + /** + * The grave accent key (`). + **/ + graveAccent, + /** + * The open bracket key ([). + **/ + openBracket, + /** + * The backslash key (\). + **/ + backSlash, + /** + * The close bracket key (]). + **/ + closeBracket, + /** + * The single quote key ('). + **/ + singleQuote + } + + //#endregion Enumerations + + //#region Objects + + /** + * A mixin that contains event-related functions. + **/ + var eventMixin: { + //#region Methods + + /** + * Adds an event listener to the control. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + * @param useCapture If true, initiates capture, otherwise false. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with the specified additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event. + **/ + dispatchEvent(type: string, eventProperties: Object): boolean; + + /** + * Removes an event listener from the control. + * @param type The type (name) of the event. + * @param listener The listener to remove. + * @param useCapture true if capture is to be initiated, otherwise false. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + //#endregion Methods + + }; + + /** + * Represents the result of a query selector, and provides various operations that perform actions over the elements of the collection. + **/ + class QueryCollection { + //#region Constructors + + /** + * Initializes a new instance of a QueryCollection. + * @constructor + * @param items The items resulting from the query. + **/ + constructor(items: T[]); + + //#endregion Constructors + + //#region Methods + + /** + * Adds the specified class to all the elements in the collection. + * @param name The name of the class to add. + * @returns This QueryCollection object. + **/ + addClass(name: string): QueryCollection; + + /** + * Creates a QueryCollection that contains the children of the specified parent element. + * @param element The parent element. + * @returns The QueryCollection that contains the children of the element. + **/ + children(element: HTMLElement): QueryCollection; + + /** + * Clears the specified style property for all the elements in the collection. + * @param name The name of the style property to be cleared. + * @returns This QueryCollection object. + **/ + clearStyle(name: string): QueryCollection; + + /** + * Creates controls that are attached to the elements in this QueryCollection, if the ctor parameter is a function, or configures the controls that are attached to the elements in this QueryCollection, if the ctor parameter is an object. + * @param ctor If this parameter is a function, it is a constructor function that is used to create controls to attach to the elements. If it is an object, it is the set of options passed to the controls. + * @param options The options passed to the newly-created controls. + * @returns This QueryCollection object. + **/ + control(ctor: any, options?: Object): QueryCollection; + + /** + * Performs an action on each item in the QueryCollection. + * @param callbackFn The action to perform on each item. + * @param thisArg The argument to bind to callbackFn. + * @returns The QueryCollection. + **/ + forEach(callbackFn: (value: T, index: number, array: T[]) => void, thisArg?: Object): QueryCollection; + + /** + * Gets an item from the QueryCollection. + * @param index The index of the item to return. + * @returns A single item from the collection. + **/ + get(index: number): T; + + /** + * Gets an attribute value from the first element in the collection. + * @param name The name of the attribute. + * @returns The value of the attribute. + **/ + getAttribute(name: string): Object; + + /** + * Determines whether the specified class exists on the first element of the collection. + * @param name The name of the class. + * @returns true if the element has the specified class; otherwise, false. + **/ + hasClass(name: string): boolean; + + /** + * Looks up an element by ID and wraps the result in a QueryCollection. + * @param id The ID of the element. + * @returns A QueryCollection that contains the element, if it is found. + **/ + id(id: string): QueryCollection; + + /** + * Adds a set of items to this QueryCollection. + * @param items The items to add to the QueryCollection. This may be an array-like object, a document fragment, or a single item. + **/ + include(items: T): void; + + /** + * Adds a set of items to this QueryCollection. + * @param items The items to add to the QueryCollection. This may be an array-like object, a document fragment, or a single item. + **/ + include(items: T[]): void; + + /** + * Registers the listener for the specified event on all the elements in the collection. + * @param eventType The name of the event. + * @param listener The event handler function to be called when the event occurs. + * @param capture true if capture == true is to be passed to addEventListener; otherwise, false. + **/ + listen(eventType: string, listener: Function, capture?: boolean): void; + + /** + * Executes a query selector on all the elements in the collection and aggregates the result into a QueryCollection. + * @param query The query selector string. + * @returns A QueryCollection object containing the aggregate results of executing the query on all the elements in the collection. + **/ + query(query: any): QueryCollection; + + /** + * Removes the specified class from all the elements in the collection. + * @param name The name of the class to be removed. + * @returns his QueryCollection object. + **/ + removeClass(name: string): QueryCollection; + + /** + * Unregisters the listener for the specified event on all the elements in the collection. + * @param eventType The name of the event. + * @param listener The event handler function. + * @param capture true if capture == true; otherwise, false. + * @returns This QueryCollection object. + **/ + removeEventListener(eventType: string, listener: Function, capture?: boolean): QueryCollection; + + /** + * Sets an attribute value on all the items in the collection. + * @param name The name of the attribute to be set. + * @param value The value of the attribute to be set. + * @returns This QueryCollection object. + **/ + setAttribute(name: string, value: Object): QueryCollection; + + /** + * Sets the specified style property for all the elements in the collection. + * @param name The name of the style property. + * @param value The value for the property. + * @returns This QueryCollection object. + **/ + setStyle(name: string, value: Object): QueryCollection; + + /** + * Renders a template that is bound to the given data and parented to the elements included in the QueryCollection. If the QueryCollection contains multiple elements, the template is rendered multiple times, once at each element in the QueryCollection per item of data passed. + * @param templateElement The DOM element to which the template control is attached. + * @param data The data to render. If the data is an array (or any other object that has a forEach method) then the template is rendered multiple times, once for each item in the collection. + * @param renderDonePromiseCallback If supplied, this function is called each time the template gets rendered, and is passed a promise that is fulfilled when the template rendering is complete. + * @returns The QueryCollection. + **/ + template(templateElement: HTMLElement, data: Object, renderDonePromiseCallback: Function): QueryCollection; + + /** + * Toggles (adds or removes) the specified class on all the elements in the collection. If the class is present, it is removed; if it is absent, it is added. + * @param name The name of the class to be toggled. + * @returns This QueryCollection object. + **/ + toggleClass(name: string): QueryCollection; + + //#endregion Methods + + } + + //#endregion Objects + + //#region Functions + + /** + * Adds the specified class to the specified element. + * @param e The element to which to add the class. + * @param name The name of the class to add. + * @returns The element. + **/ + function addClass(e: HTMLElement, name: string): HTMLElement; + + /** + * Gets a collection of elements that are the direct children of the specified element. + * @param element The parent element. + * @returns The collection of children of the element. + **/ + function children(element: HTMLElement): QueryCollection; + + /** + * Converts a CSS positioning string for the specified element to pixels. + * @param element The element. + * @param value The CSS positioning string. + * @returns The number of pixels. + **/ + function convertToPixels(element: HTMLElement, value: string): number; + + /** + * Creates an object that has one event for each name passed to the function. + * @param events A variable list of property names. + * @returns The object with the specified properties. The names of the properties are prefixed with 'on'. + **/ + function createEventProperties(...events: string[]): Object; + + /** + * Gets the data value associated with the specified element. + * @param element The element. + * @returns The value associated with the element. + **/ + function data(element: HTMLElement): Object; + + /** + * Disposes all first-generation disposable elements that are descendents of the specified element. The specified element itself is not disposed. + * @param element The root element whose sub-tree is to be disposed. + **/ + function disposeSubTree(element: HTMLElement): void; + + /** + * Removes all the child nodes from the specified element. + * @param element The element. + * @returns The element. + **/ + function empty(element: HTMLElement): HTMLElement; + + /** + * Determines whether the specified event occurred within the specified element. + * @param element The element. + * @param event The event. + * @returns true if the event occurred within the element; otherwise, false. + **/ + function eventWithinElement(element: HTMLElement, event: Event): boolean; + + /** + * Adds tags and type to a logging message. + * @param message The message to be formatted. + * @param tag The tag(s) to be applied to the message. Multiple tags should be separated by spaces. + * @param type The type of the message. + * @returns The formatted message. + **/ + function formatLog(message: string, tag: string, type: string): string; + + /** + * Gets the height of the content of the specified element. The content height does not include borders or padding. + * @param element The element. + * @returns The content height of the element. + **/ + function getContentHeight(element: HTMLElement): number; + + /** + * Gets the width of the content of the specified element. The content width does not include borders or padding. + * @param element The element. + * @returns The content width of the element. + **/ + function getContentWidth(element: HTMLElement): number; + + /** + * Gets the leaf-level type or namespace specified by the name parameter. + * @param name The name of the member. + * @param root The root to start in. Defaults to the global object. + * @returns The leaf-level type or namespace in the specified parent namespace. + **/ + function getMember(name: string, root: Object): Object; + + /** + * Gets the position of the specified element. + * @param element The element. + * @returns An object that contains the left, top, width and height properties of the element. + **/ + function getPosition(element: HTMLElement): IPosition; + + /** + * Gets the left coordinate of the specified element relative to the specified parent. + * @param element The element. + * @param parent The parent element. + * @returns The relative left coordinate. + **/ + function getRelativeLeft(element: HTMLElement, parent: HTMLElement): number; + + /** + * Gets the top coordinate of the element relative to the specified parent. + * @param element The element. + * @param parent The parent element. + * @returns The relative top coordinate. + **/ + function getRelativeTop(element: HTMLElement, parent: HTMLElement): number; + + /** + * Gets the height of the element, including its margins. + * @param element The element. + * @returns The height of the element including margins. + **/ + function getTotalHeight(element: HTMLElement): number; + + /** + * Gets the width of the element, including margins. + * @param element The element. + * @returns The width of the element including margins. + **/ + function getTotalWidth(element: HTMLElement): number; + + /** + * Determines whether the specified element has the specified class. + * @param e The element. + * @param name The name of the class. + * @returns true if the element has the class, otherwise false. + **/ + function hasClass(e: HTMLElement, name: string): boolean; + + /** + * Returns a collection with zero or one elements matching the specified id. + * @param id The ID of the element (or elements). + * @returns A collection of elements whose id matches the id parameter. + **/ + function id(id: string): QueryCollection; + + /** + * Calls insertAdjacentHTML on the specified element. + * @param element The element on which insertAdjacentHTML is to be called. + * @param position The position relative to the element at which to insert the HTML. Possible values are: beforebegin, afterbegin, beforeend, afterend. + * @param text The text to insert. + **/ + function insertAdjacentHTML(element: HTMLElement, position: string, text: string): void; + + /** + * Calls insertAdjacentHTML on the specified element in the context of MSApp.execUnsafeLocalFunction. + * @param element The element on which insertAdjacentHTML is to be called. + * @param position The position relative to the element at which to insert the HTML. Possible values are: beforebegin, afterbegin, beforeend, afterend. + * @param text Value to be provided to insertAdjacentHTML. + **/ + function insertAdjacentHTMLUnsafe(element: HTMLElement, position: string, text: string): void; + + /** + * Attaches the default dispose API wrapping the dispose implementation to the specified element. + * @param element The element to mark as disposable. + * @param disposeImpl The function containing the element-specific dispose logic, called by the dispose function that markDisposable attaches. + **/ + function markDisposable(element: HTMLElement, disposeImpl: Function): void; + + /** + * Marks a function as being compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll. + * @param func The function to be marked as compatible with declarative processing. + * @returns The input function, marked as compatible with declarative processing. + **/ + function markSupportedForProcessing(func: Function): Function; + + /** + * Returns a QueryCollection with zero or one elements matching the specified selector query. + * @param query The CSS selector to use. See Selectors for more information. + * @param element Optional. The root element at which to start the query. If this parameter is omitted, the scope of the query is the entire document. + * @returns A QueryCollection with zero or one elements matching the specified selector query. + **/ + function query(query: any, element: HTMLElement): QueryCollection; + + /** + * Ensures that the specified function executes only after the DOMContentLoaded event has fired for the current page. The DOMContentLoaded event occurs after the page has been parsed but before all the resources are loaded. + * @param callback A function that executes after the DOMContentLoaded event has occurred. + * @param async If true, the callback should be executed asynchronously. + * @returns A promise that completes after the DOMContentLoaded event has occurred. + **/ + function ready(callback?: Function, async?: boolean): Promise; + + /** + * Removes the specified class from the specified element. + * @param e The element from which to remove the class. + * @param name The name of the class to remove. + * @returns The element. + **/ + function removeClass(e: HTMLElement, name: string): HTMLElement; + + /** + * Asserts that the value is compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll. If the value is not compatible, and strictProcessing is on, an exception is thrown. All functions that have been declared using WinJS.Class.define, WinJS.Class.derive, WinJS.UI.Pages.define, or WinJS.Binding.converter are automatically marked as supported for declarative processing. Any other function that you use from a declarative context (that is, a context in which an HTML element has a data-win-control or data-win-options attribute) must be marked manually by calling this function. When you mark a function as supported for declarative processing, you are guaranteeing that the code in the function is secure from injection of third-party content. + * @param value The value to be tested for compatibility with declarative processing. If the value is a function it must be marked with a property supportedForProcessing with a value of true when strictProcessing is on. For more information, see WinJS.Utilities.markSupportedForProcessing. + * @returns The input value. + **/ + function requireSupportedForProcessing(value: Object): Object; + + /** + * Sets the innerHTML property of the specified element to the specified text. + * @param element The element on which the innerHTML property is to be set. + * @param text The value to be set to the innerHTML property. + **/ + function setInnerHTML(element: HTMLElement, text: string): void; + + /** + * Sets the innerHTML property of the specified element to the specified text. + * @param element The element on which the innerHTML property is to be set. + * @param text The value to be set to the innerHTML property. + **/ + function setInnerHTMLUnsafe(element: HTMLElement, text: string): void; + + /** + * Sets the outerHTML property of the specified element to the specified text. + * @param element The element on which the outerHTML property is to be set. + * @param text The value to be set to the outerHTML property. + **/ + function setOuterHTML(element: HTMLElement, text: string): void; + + /** + * Sets the outerHTML property of the specified element to the specified text in the context of MSApp.execUnsafeLocalFunction. + * @param element The element on which the outerHTML property is to be set. + * @param text The value to be set to the outerHTML property. + **/ + function setOuterHTMLUnsafe(element: HTMLElement, text: string): void; + + /** + * Configures a logger that writes messages containing the specified tags to the JavaScript console. + * @param options The tags for messages to log. Multiple tags should be separated by spaces. May contain type, tags, excludeTags and action properties. + **/ + function startLog(options: Object): void; + + /** + * Removes the WinJS logger that had previously been set up. + **/ + function stopLog(): void; + + /** + * Toggles (adds or removes) the specified class on the specified element. If the class is present, it is removed; if it is absent, it is added. + * @param e The element on which to toggle the class. + * @param name The name of the class to toggle. + * @returns The element. + **/ + function toggleClass(e: HTMLElement, name: string): HTMLElement; + + //#endregion Functions + + //#region Interfaces + + interface IPosition { + left: number; + top: number; + width: number; + height: number; + } + + //#endregion Interfaces + +} +/** + * Provides functions and objects for scheduling and managing asynchronous tasks. +**/ +declare module WinJS.Utilities.Scheduler { + //#region Enumerations + + /** + * Represents a priority for a job managed by the Scheduler. + **/ + enum Priority { + /** + * A priority higher than the normal priority level. + **/ + aboveNormal, + /** + * A priority less than the normal priority level. + **/ + belowNormal, + /** + * A high priority. + **/ + high, + /** + * The idle priority for work items. + **/ + idle, + /** + * The highest priority. + **/ + max, + /** + * The lowest priority. + **/ + min, + /** + * The normal priority for work items. + **/ + normal + } + + //#endregion Enumerations + + //#region Interfaces + + /** + * Represents a work item that's executed by the Scheduler. + **/ + interface IJob { + //#region Methods + + /** + * Cancels the job. + **/ + cancel(): void; + + /** + * Pauses the job. + **/ + pause(): void; + + /** + * Resumes the job. + **/ + resume(): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets a value that indicates whether the job has successfully completed. + **/ + completed: boolean; + + /** + * Gets the unique numeric identifier assigned to the job. + **/ + id: number; + + /** + * Gets or sets the name of the job. + **/ + name: string; + + /** + * Gets or sets the owner of the job. + **/ + owner: IOwnerToken; + + /** + * Gets or sets the priority of the job. + **/ + priority: Priority; + + //#endregion Properties + + } + + /** + * Provides a control mechanism that allows a job to cooperatively yield. This object is passed to your work function when you schedule it. + **/ + interface IJobInfo { + //#region Methods + + /** + * Uses a Promise to determine how long the scheduler should wait before rescheduling the job after it yields. + * @param promise Once the work item yields, the scheduler will wait for this Promise to complete before rescheduling the job. + **/ + setPromise(promise: Promise): void; + + /** + * Specifies the next unit of work to run once this job yields. + * @param work The next unit of work to run once this job yields. + **/ + setWork(work: Function): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the work item associated with this IJobInfo. + **/ + job: IJob; + + /** + * Gets a value that specifies whether the job should yield. + **/ + shouldYield: boolean; + + //#endregion Properties + + } + + /** + * Represents an object that owns jobs. You can use this object to cancel a set of jobs. + **/ + interface IOwnerToken { + //#region Methods + + /** + * Synchronously cancels the job that this token owns, including paused and blocked jobs. + **/ + cancelAll(): void; + + //#endregion Methods + + } + + //#endregion Interfaces + + //#region Functions + + /** + * Creates and returns a new IOwnerToken which can be set to the owner property of one or more jobs. + * @returns A new IOwnerToken which can be set to the owner property of one or more jobs. + **/ + function createOwnerToken(): IOwnerToken; + + /** + * Runs the specified callback in a high priority context. + * @param callback The callback to run in a high priority callback. + * @returns The return value of the callback. + **/ + function execHigh(callback: () => U): U; + + /** + * Returns a string representation of the scheduler's state for diagnostic purposes. The jobs and drain requests are displayed in the order in which they are currently expected to be processed. The current job and drain request are marked by an asterisk. + * @returns A string representation of the scheduler's state for diagnostic purposes. The jobs and drain requests are displayed in the order in which they are currently expected to be processed. The current job and drain request are marked by an asterisk. + **/ + function retrieveState(): string; + + /** + * Runs jobs in the scheduler without timeslicing until all jobs at the specified priority and higher have executed. + * @param priority The priority to which the scheduler should drain. The default is -15. + * @param name An optional description of the drain request for diagnostics. + * @returns A Promise which completes when the drain has finished. Canceling this Promise cancels the drain request. This Promise will never enter an error state. + **/ + function requestDrain(priority?: Priority, name?: string): Promise; + + /** + * Schedules the specified function to execute asynchronously. + * @param work A function that represents the work item to be scheduled. When called the work item will receive as its first argument an object which allows the work item to ask the scheduler if it should yield cooperatively and if so allows the work item to either provide a function to be run as a continuation or a WinJS.Promise which will when complete provide a function to run as a continuation. Provide these fields for the object: shouldYield, setWork(work), setPromise(promise), job. + * @param priority The priority of the work item. If you don't specify a priority, it defaults to WinJS.Utilities.Scheduler.Priority.normal. + * @param thisArg A "this" instance to be bound to the work item. The default value is null. + * @param name A description of the work item for diagnostics. The default value is an empty string. + * @returns The job instance that represents this work item. + **/ + function schedule(work: (jobInfo: IJobInfo) => void, priority?: Priority, thisArg?: Object, name?: string): IJob; + + /** + * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.aboveNormal priority. + * @param promiseValue The value returned by the completed Promise. + * @param jobName A string that describes the job for diagnostic purposes. + * @returns A Promise that completes within a job of aboveNormal priority. + **/ + function schedulePromiseAboveNormal(promiseValue?: Promise, jobName?: string): Promise; + + /** + * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.belowNormal priority. + * @param promiseValue The value returned by the completed Promise. + * @param jobName A string that describes the job for diagnostic purposes. + * @returns A Promise that completes within a job of belowNormal priority. + **/ + function schedulePromiseBelowNormal(promiseValue?: Promise, jobName?: string): Promise; + + /** + * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.high priority. + * @param promiseValue The value returned by the completed Promise. + * @param jobName A string that describes the job for diagnostic purposes. + * @returns A Promise that completes within a job of high priority. + **/ + function schedulePromiseHigh(promiseValue?: Promise, jobName?: string): Promise; + + /** + * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.Idle priority. + * @param promiseValue The value returned by the completed Promise. + * @param jobName A string that describes the job for diagnostic purposes. + * @returns A Promise that completes within a job of idle priority. + **/ + function schedulePromiseIdle(promiseValue?: Promise, jobName?: string): Promise; + + /** + * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.normal priority. + * @param promiseValue The value returned by the completed Promise. + * @param jobName A string that describes the job for diagnostic purposes. + * @returns A Promise that completes within a job of normal priority. + **/ + function schedulePromiseNormal(promiseValue?: Promise, jobName?: string): Promise; + + //#endregion Functions + +} diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index 881b64ed39..9206c9bd99 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -1768,16 +1768,31 @@ declare module Windows { } export interface IPackage { dependencies: Windows.Foundation.Collections.IVectorView; + description: string; + displayName: string; id: Windows.ApplicationModel.PackageId; installedLocation: Windows.Storage.StorageFolder; + isBundle: boolean; + isDevelopmentMode: boolean; isFramework: boolean; + isResourcePackage: boolean; + logo: Windows.Foundation.Uri; + publisherDisplayName: string; } export class Package implements Windows.ApplicationModel.IPackage { + static current: Windows.ApplicationModel.Package; + dependencies: Windows.Foundation.Collections.IVectorView; + description: string; + displayName: string; id: Windows.ApplicationModel.PackageId; installedLocation: Windows.Storage.StorageFolder; + isBundle: boolean; + isDevelopmentMode: boolean; isFramework: boolean; - static current: Windows.ApplicationModel.Package; + isResourcePackage: boolean; + logo: Windows.Foundation.Uri; + publisherDisplayName: string; } export interface IPackageStatics { current: Windows.ApplicationModel.Package; @@ -11519,13 +11534,78 @@ declare module Windows { snapped, fullScreenPortrait, } - export interface IApplicationViewStatics { - value: Windows.UI.ViewManagement.ApplicationViewState; - tryUnsnap(): boolean; - } + + /** + * Defines an instance of a window (app view) and the information that describes it. + **/ export class ApplicationView { + /** + * Gets the window (app view) for the current app. + **/ + static getForCurrentView(): ApplicationView; + + /** + * Attempts to unsnap a previously snapped app. This call will only succeed when the app is running in the foreground. + **/ + static tryUnsnap(): boolean; + + /** + * Gets the state of the current app view. + **/ static value: Windows.UI.ViewManagement.ApplicationViewState; - static tryUnsnap(): boolean; + + /** + * Indicates whether the app terminates when the last window is closed. + **/ + static terminateAppOnFinalViewClose: boolean; + + /** + * Gets the current orientation of the window (app view) with respect to the display. + **/ + orientation: ApplicationViewOrientation; + + /** + * Gets or sets the displayed title of the window. + **/ + title: string; + + /** + * Gets or sets whether screen capture is enabled for the window (app view). + **/ + isScreenCaptureEnabled: boolean; + + /** + * Gets whether the window (app view) is on the Windows lock screen. + **/ + isOnLockScreen: boolean; + + /** + * Gets whether the window(app view) is full screen or not. + **/ + isFullScreen: boolean; + + /** + * Gets the current ID of the window (app view) . + **/ + id: number; + + /** + * Gets whether the current window (app view) is adjacent to the right edge of the screen. + **/ + adjacentToRightDisplayEdge: boolean; + + /** + * Gets whether the current window (app view) is adjacent to the left edge of the screen. + **/ + adjacentToLeftDisplayEdge: number; + } + + /** + * Defines the set of display orientation modes for a window (app view). + **/ + export enum ApplicationViewOrientation { + landscape, + portrait } export interface IInputPaneVisibilityEventArgs { ensuredFocusedElementInView: boolean; From d182a6e43da2fc57ef28df66c69b614db0ce49f9 Mon Sep 17 00:00:00 2001 From: craigktreasure Date: Mon, 20 Jan 2014 17:50:27 -0800 Subject: [PATCH 020/240] WinJS file heading Re-added license and WinRT reference. --- winjs/winjs.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 070c146fae..625344e111 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -1,4 +1,21 @@ -/** +/* ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +/** * Defines an Element object. **/ interface Element { From 34e2b07e9319c05a18412644619eb0b86a634d6f Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Tue, 21 Jan 2014 19:25:10 +1100 Subject: [PATCH 021/240] es6-promises fix whitespace + argument names consistent with http://promises-aplus.github.io/promises-spec/ --- es6-promises/es6-promises.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/es6-promises/es6-promises.d.ts b/es6-promises/es6-promises.d.ts index a44355233c..a50cd1fc64 100644 --- a/es6-promises/es6-promises.d.ts +++ b/es6-promises/es6-promises.d.ts @@ -5,10 +5,10 @@ interface Thenable { - then(onFulfill: (value: R) => Thenable, onReject: (error: any) => Thenable): Thenable; - then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Thenable; - then(onFulfill: (value: R) => U, onReject: (error: any) => Thenable): Thenable; - then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Thenable; + then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; + then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; } @@ -130,4 +130,4 @@ declare module Promise { * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. */ function race(promises: Promise[]): Promise; -} \ No newline at end of file +} From 2b11fad40b4f87dd81ff4f48f9d1964aa3183aa3 Mon Sep 17 00:00:00 2001 From: dotnetnerd Date: Tue, 21 Jan 2014 13:34:19 +0100 Subject: [PATCH 022/240] Added domready and domdelegate --- domready/ready.d.ts | 1 + ftdomdelegate/delegate.d.ts | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 domready/ready.d.ts create mode 100644 ftdomdelegate/delegate.d.ts diff --git a/domready/ready.d.ts b/domready/ready.d.ts new file mode 100644 index 0000000000..887632b571 --- /dev/null +++ b/domready/ready.d.ts @@ -0,0 +1 @@ +declare function domready(callback: () => any) : void; \ No newline at end of file diff --git a/ftdomdelegate/delegate.d.ts b/ftdomdelegate/delegate.d.ts new file mode 100644 index 0000000000..a73a948a41 --- /dev/null +++ b/ftdomdelegate/delegate.d.ts @@ -0,0 +1,8 @@ +declare class Delegate +{ + constructor(element: HTMLElement); + + on(eventType: string, selector: string, callback : () => any); + + on(eventType: string, callback:() => any); +} \ No newline at end of file From 0d8bdec36ed81a3bbe0214869cbb73c2bb479fdb Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 21 Jan 2014 13:38:58 +0000 Subject: [PATCH 023/240] jQuery: JSDoc Callbacks and tighten up typing --- jquery/jquery-tests.ts | 5 +++ jquery/jquery.d.ts | 98 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 89 insertions(+), 14 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 1b2fb5d16c..6981118e15 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -668,6 +668,11 @@ function test_callbacksFunctions() { callbacks.add(bar); callbacks.fire('world'); callbacks.disable(); + + // Test the disabled state of the list + console.log(callbacks.disabled()); + // Outputs: true + callbacks.empty(); callbacks.fire('hello'); console.log(callbacks.fired()); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 9b412c5b53..d76e918c91 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -158,28 +158,98 @@ interface JQueryAjaxSettings { xhrFields?: { [key: string]: any; }; } -/* - Interface for the jqXHR object -*/ +/** + * Interface for the jqXHR object + */ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { + /** + * The .overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header. As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5). + */ overrideMimeType(mimeType: string): any; abort(statusText?: string): void; } -/* - Interface for the JQuery callback -*/ +/** + * Interface for the JQuery callback + */ interface JQueryCallback { - add(...callbacks: any[]): any; - disable(): any; - empty(): any; - fire(...arguments: any[]): any; + /** + * Add a callback or a collection of callbacks to a callback list. + * + * @param callbacks A function, or array of functions, that are to be added to the callback list. + */ + add(callbacks: Function): JQueryCallback; + /** + * Add a callback or a collection of callbacks to a callback list. + * + * @param callbacks A function, or array of functions, that are to be added to the callback list. + */ + add(callbacks: Function[]): JQueryCallback; + + /** + * Disable a callback list from doing anything more. + */ + disable(): JQueryCallback; + + /** + * Determine if the callbacks list has been disabled. + */ + disabled(): boolean; + + /** + * Remove all of the callbacks from a list. + */ + empty(): JQueryCallback; + + /** + * Call all of the callbacks with the given arguments + * + * @param arguments The argument or list of arguments to pass back to the callback list. + */ + fire(...arguments: any[]): JQueryCallback; + + /** + * Determine if the callbacks have already been called at least once. + */ fired(): boolean; - fireWith(context: any, ...args: any[]): any; - has(callback: any): boolean; - lock(): any; + + /** + * Call all callbacks in a list with the given context and arguments. + * + * @param context A reference to the context in which the callbacks in the list should be fired. + * @param arguments An argument, or array of arguments, to pass to the callbacks in the list. + */ + fireWith(context?: any, ...args: any[]): JQueryCallback; + + /** + * Determine whether a supplied callback is in a list + * + * @param callback The callback to search for. + */ + has(callback: Function): boolean; + + /** + * Lock a callback list in its current state. + */ + lock(): JQueryCallback; + + /** + * Determine if the callbacks list has been locked. + */ locked(): boolean; - remove(...callbacks: any[]): any; + + /** + * Remove a callback or a collection of callbacks from a callback list. + * + * @param callbacks A function, or array of functions, that are to be removed from the callback list. + */ + remove(callbacks: Function): JQueryCallback; + /** + * Remove a callback or a collection of callbacks from a callback list. + * + * @param callbacks A function, or array of functions, that are to be removed from the callback list. + */ + remove(callbacks: Function[]): JQueryCallback; } /* From 43e6ac70211f226af3ffd9025e93fa5cce1aea67 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 21 Jan 2014 13:42:00 +0000 Subject: [PATCH 024/240] jQuery: back --- jquery/jquery.d.ts | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index d76e918c91..6a670863a8 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -856,24 +856,7 @@ interface JQueryStatic { error(message: string): JQuery; expr: any; - fn: { - /** - * A string containing the jQuery version number. - */ - jquery: string; - - /** - * The number of elements in the jQuery object. - */ - length: number; - - /** - * Merge the contents of an object onto the jQuery prototype to provide new jQuery instance methods. - * - * @param object An object to merge onto the jQuery prototype. - */ - extend(object: any): any; - } + fn: any; //TODO: Decide how we want to type this isReady: boolean; From f7819b3f77e68cb240801d39b7a340eb6477b07b Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 21 Jan 2014 14:36:28 +0000 Subject: [PATCH 025/240] jQuery: cater for jQuery.clientSideLogging I haven't looked in detail at this but it looks that jQuery.clientSideLogging is ill-advisedly clobbering ```$.error```. This should probable be addressed at some point. --- jquery/jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 6a670863a8..6be2c08e28 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -853,7 +853,7 @@ interface JQueryStatic { * * @param message The message to send out. */ - error(message: string): JQuery; + error(message: any): JQuery; expr: any; fn: any; //TODO: Decide how we want to type this From 4ab427bb2cf9f6fc0c311e8564461cf6398d05a6 Mon Sep 17 00:00:00 2001 From: dotnetnerd Date: Tue, 21 Jan 2014 16:07:17 +0100 Subject: [PATCH 026/240] Renamed files, added headers and fixed test --- domready/domready.d.ts | 6 ++++++ ftdomdelegate/ftdomdelegate.d.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 domready/domready.d.ts create mode 100644 ftdomdelegate/ftdomdelegate.d.ts diff --git a/domready/domready.d.ts b/domready/domready.d.ts new file mode 100644 index 0000000000..c951f93972 --- /dev/null +++ b/domready/domready.d.ts @@ -0,0 +1,6 @@ +// Type definitions for domready +// Project: https://github.com/ded/domready +// Definitions by: Christian Holm Nielsen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare function domready(callback: () => any) : void; \ No newline at end of file diff --git a/ftdomdelegate/ftdomdelegate.d.ts b/ftdomdelegate/ftdomdelegate.d.ts new file mode 100644 index 0000000000..6dc6c8dbec --- /dev/null +++ b/ftdomdelegate/ftdomdelegate.d.ts @@ -0,0 +1,14 @@ +// Type definitions for ftdomdelegate +// Project: https://github.com/ftlabs/ftdomdelegate +// Definitions by: Christian Holm Nielsen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare class Delegate +{ + constructor(element: HTMLElement); + + on(eventType: string, selector: string, callback : () => any) : void; + + on(eventType: string, callback:() => any) : void; +} \ No newline at end of file From 41fda8197c4bce046ab6273a890c33bcca0b8e49 Mon Sep 17 00:00:00 2001 From: dotnetnerd Date: Tue, 21 Jan 2014 16:08:40 +0100 Subject: [PATCH 027/240] removed files that were renamed --- domready/ready.d.ts | 1 - ftdomdelegate/delegate.d.ts | 8 -------- 2 files changed, 9 deletions(-) delete mode 100644 domready/ready.d.ts delete mode 100644 ftdomdelegate/delegate.d.ts diff --git a/domready/ready.d.ts b/domready/ready.d.ts deleted file mode 100644 index 887632b571..0000000000 --- a/domready/ready.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare function domready(callback: () => any) : void; \ No newline at end of file diff --git a/ftdomdelegate/delegate.d.ts b/ftdomdelegate/delegate.d.ts deleted file mode 100644 index a73a948a41..0000000000 --- a/ftdomdelegate/delegate.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare class Delegate -{ - constructor(element: HTMLElement); - - on(eventType: string, selector: string, callback : () => any); - - on(eventType: string, callback:() => any); -} \ No newline at end of file From a0db190fa3526919f15a1eb410f96c7406f793e4 Mon Sep 17 00:00:00 2001 From: Jon Egerton Date: Tue, 21 Jan 2014 15:24:01 +0000 Subject: [PATCH 028/240] Make silent option on AreYouSureOptions optional Make silent option on AreYouSureOptions optional --- jquery.are-you-sure/jquery.are-you-sure.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.are-you-sure/jquery.are-you-sure.d.ts b/jquery.are-you-sure/jquery.are-you-sure.d.ts index ea2dc4c7b7..81392361ab 100644 --- a/jquery.are-you-sure/jquery.are-you-sure.d.ts +++ b/jquery.are-you-sure/jquery.are-you-sure.d.ts @@ -21,7 +21,7 @@ interface AreYouSureOptions { fieldSelector?: string; /**Make Are-You-Sure "silent" by disabling the warning message*/ - silent: boolean; + silent?: boolean; } interface AreYouSure { From 427c9729fb8780ce4e0b66a7da11f9aa888eee8b Mon Sep 17 00:00:00 2001 From: Sean Clark Hess Date: Tue, 21 Jan 2014 09:45:28 -0700 Subject: [PATCH 029/240] updated rethinkdb. Sequences instead of expressions. Added time. other fixes --- rethinkdb/rethinkdb.d.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index da63550941..002ee824c0 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -26,6 +26,12 @@ declare module "rethinkdb" { export function row(name:string):Expression; export function expr(stuff:any):Expression; + export function now():Time; + + // Control Structures + export function branch(test:Expression, trueBranch:Expression, falseBranch:Expression):Expression; + + export class Cursor { hasNext():boolean; each(cb:(err:Error, row:any)=>void, done?:()=>void); @@ -83,9 +89,9 @@ declare module "rethinkdb" { insert(obj:any[], options?:InsertOptions):Operation; insert(obj:any, options?:InsertOptions):Operation; - get(key:string):Expression; // primary key - getAll(key:string, index?:Index):Selection; // without index defaults to primary key - getAll(...keys:string[]):Selection; + get(key:string):Sequence; // primary key + getAll(key:string, index?:Index):Sequence; // without index defaults to primary key + getAll(...keys:string[]):Sequence; } interface Sequence extends Operation, Writeable { @@ -123,7 +129,7 @@ declare module "rethinkdb" { reduce(r:Reduce, base?:any):Expression; count():Expression; distinct():Sequence; - groupedMapReduce(group:ExpressionFunction, map:ExpressionFunction, reduce:Reduce, base?:any):Expression; + groupedMapReduce(group:ExpressionFunction, map:ExpressionFunction, reduce:Reduce, base?:any):Sequence; groupBy(...aggregators:Aggregator[]):Expression; // TODO: reduction object contains(prop:string):Expression; @@ -178,8 +184,8 @@ declare module "rethinkdb" { interface Index { index: string; - left_bound: string; // 'closed' - right_bound: string; // 'open' + left_bound?: string; // 'closed' + right_bound?: string; // 'open' } interface Expression extends Writeable, Operation { @@ -204,6 +210,10 @@ declare module "rethinkdb" { mul(n:number):Expression; div(n:number):Expression; mod(n:number):Expression; + + hasFields(...fields:string[]):Expression; + + default(value:T):Expression; } interface Operation { @@ -213,6 +223,8 @@ declare module "rethinkdb" { interface Aggregator {} interface Sort {} + interface Time {} + // http://www.rethinkdb.com/api/#js // TODO control structures From 65f91dff3e98981b500302d30500fe98aa1d4ebc Mon Sep 17 00:00:00 2001 From: mattbrooks2010 Date: Tue, 21 Jan 2014 17:05:25 +0000 Subject: [PATCH 030/240] Added missing moment and moment.utc overloads. - Added moment(string, string?, boolean?) overload for specifying date, format and strict parsing flag. - Added moment(string, string?, string?, boolean?) overload for specifying date, format, language and strict parsing flag. - Added moment(string, string[], boolean?) overload for specifying date, multiple formats and strict parsing flag. - Added moment(string, string[], string?, boolean?) overload for specifying date, multiple formats, language and strict parsing flag. - Modified parameter names for moment.utc(...) methods to match those for the similar moment(...) method overloads. - Ensured all moment(...) methods have a moment.utc(...) equivalent. - Added tests for all newly added overloads. - Added missing tests for some existing overloads. --- moment/moment-tests.ts | 16 ++++++++++++++++ moment/moment.d.ts | 36 ++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index e86989eed5..de51252d98 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -21,6 +21,14 @@ var array = [2010, 1, 14, 15, 25, 50, 125]; var day11 = moment(Date.UTC.apply({}, array)); var day12 = moment.unix(1318781876); +moment({ years: 2010, months: 3, days: 5, hours: 15, minutes: 10, seconds: 3, milliseconds: 123 }); +moment("20140101", "YYYYMMDD", true); +moment("20140101", "YYYYMMDD", "en"); +moment("20140101", "YYYYMMDD", "en", true); +moment("20140101", ["YYYYMMDD"], true); +moment("20140101", ["YYYYMMDD"], "en"); +moment("20140101", ["YYYYMMDD"], "en", true); + var a = moment([2012]); var b = moment(a); a.year(2000); @@ -29,8 +37,16 @@ b.year(); // 2012 moment.utc(); moment.utc(12345); moment.utc([12, 34, 56]); +moment.utc({ years: 2010, months: 3, days: 5, hours: 15, minutes: 10, seconds: 3, milliseconds: 123 }); moment.utc("1-2-3"); moment.utc("1-2-3", "3-2-1"); +moment.utc("1-2-3", "3-2-1", true); +moment.utc("1-2-3", "3-2-1", "en"); +moment.utc("1-2-3", "3-2-1", "en", true); +moment.utc("01-01-2014", ["DD-MM-YYYY", "MM-DD-YYYY"]); +moment.utc("01-01-2014", ["DD-MM-YYYY", "MM-DD-YYYY"], true); +moment.utc("01-01-2014", ["DD-MM-YYYY", "MM-DD-YYYY"], "en"); +moment.utc("01-01-2014", ["DD-MM-YYYY", "MM-DD-YYYY"], "en", true); var a2 = moment.utc([2011, 0, 1, 8]); a.hours(); diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 20e921c324..63e73d39a6 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -257,25 +257,29 @@ interface MomentRelativeTime { interface MomentStatic { (): Moment; - (dateObject: Object, language?: string, strict?: boolean): Moment; - (date: number, language?: string, strict?: boolean): Moment; - (date: string, language?: string, strict?: boolean): Moment; - (date: string, format: string, language?: string, strict?: boolean): Moment; - (date: string, formats: string[], language?: string, strict?: boolean): Moment; - (date: Date, language?: string, strict?: boolean): Moment; - (date: number[], language?: string, strict?: boolean): Moment; - (clone: Moment): Moment; + (date: number): Moment; + (date: number[]): Moment; + (date: string, format?: string, strict?: boolean): Moment; + (date: string, format?: string, language?: string, strict?: boolean): Moment; + (date: string, formats: string[], strict?: boolean): Moment; + (date: string, formats: string[], language?: string, strict?: boolean): Moment; + (date: Date): Moment; + (date: Moment): Moment; + (date: Object): Moment; + + utc(): Moment; + utc(date: number): Moment; + utc(date: number[]): Moment; + utc(date: string, format?: string, strict?: boolean): Moment; + utc(date: string, format?: string, language?: string, strict?: boolean): Moment; + utc(date: string, formats: string[], strict?: boolean): Moment; + utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; + utc(date: Date): Moment; + utc(date: Moment): Moment; + utc(date: Object): Moment; unix(timestamp: number): Moment; - utc(): Moment; // current date/time in UTC mode - utc(Number: number): Moment; // milliseconds since the Unix Epoch in UTC mode - utc(array: number[]): Moment; // parse an array of numbers matching Date.UTC() parameters - utc(String: string): Moment; // parse string into UTC mode - utc(String1: string, String2: string): Moment; // parse a string and format into UTC mode - utc(date: Date): Moment; - utc(clone: Moment): Moment; - isMoment(): boolean; isMoment(m: any): boolean; lang(language: string): any; From a6484815f51c7b0a53a5deee1ee0246fe4233e99 Mon Sep 17 00:00:00 2001 From: Sean Clark Hess Date: Tue, 21 Jan 2014 09:52:19 -0700 Subject: [PATCH 031/240] svgjs: added filters and bugfixes --- svgjs/svgjs.d.ts | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/svgjs/svgjs.d.ts b/svgjs/svgjs.d.ts index 6b7a7a6ae1..8a3af1d684 100644 --- a/svgjs/svgjs.d.ts +++ b/svgjs/svgjs.d.ts @@ -38,7 +38,36 @@ declare module svgjs { mask():Mask; // TODO gradients - } + } + + + // https://github.com/wout/svg.filter.js + export interface Filter { + gaussianBlur(values:string):Filter; + colorMatrix(name:string, value:number):Filter; + colorMatrix(name:string, matrix:number[]):Filter; + componentTransfer(components:{rgb?: FilterComponentTransfer; g?: FilterComponentTransfer;}):Filter; + offset(x:number, y:number):Filter; + blend():Filter; + in(source:FilterSource):Filter; + sourceAlpha:FilterSource; + source:FilterSource; + } + + export interface FilterSource { + + } + + + export interface FilterComponentTransfer { + type: string; + tableValues?: string; + slope?: number; + intercept: number; + amplitude: number; + exponent: number; + offset: number; + } export interface Element extends Text, Parent { node:LinkedHTMLElement; @@ -71,6 +100,7 @@ declare module svgjs { remove():void; each(iterator:(i?:number, children?:Element[])=>void, deep?:boolean):void; + filter(adder:(filter:Filter)=>void):Element; transform(t:Transform):Element; @@ -204,6 +234,12 @@ declare module svgjs { export interface RBox extends BBox {} + export interface Attributes { + (name:string, value:any):void; + (obj:Object):void; + (name:string):any; + } + export interface Viewbox { x: number; y: number; From 3e9a7639daa847ebfa5a7ca3f258fae4ece9bfcc Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Tue, 21 Jan 2014 19:01:21 +0100 Subject: [PATCH 032/240] Added filterable widget. --- jquerymobile/jquerymobile.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/jquerymobile/jquerymobile.d.ts b/jquerymobile/jquerymobile.d.ts index d81e439009..ebcaac48fa 100644 --- a/jquerymobile/jquerymobile.d.ts +++ b/jquerymobile/jquerymobile.d.ts @@ -202,6 +202,18 @@ interface ListViewEvents { create?: JQueryMobileEvent; } +interface FilterableOptions { + children?: any; + defaults?: boolean; + disabled?: boolean; + enhanced?: boolean; + filterCallback?: {(index: number, searchValue?: string): boolean; }; + filterPlaceholder?: string; + filterReveal?: boolean; + filterTheme?: string; + input: any; +} + interface NavbarOptions { iconpos: string; } @@ -371,6 +383,7 @@ interface JQueryMobile extends JQueryMobileOptions { checkboxradio: any; selectmenu: any; listview: any; + filterable: any; defaultHomeScroll: number; } @@ -446,6 +459,10 @@ interface JQuery { listview(options: ListViewOptions): JQuery; listview(events: ListViewEvents): JQuery; + filterable(): JQuery; + filterable(command: string): JQuery; + filterable(options: FilterableOptions): JQuery; + navbar(options?: NavbarOptions): JQuery; table(): JQuery; From ec3e680da4391e2fa2743290d7ae868123912ee9 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 22 Jan 2014 13:29:38 +0000 Subject: [PATCH 033/240] jQuery: JSDoc each Removed undocumented overload --- jquery/jquery.d.ts | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 6be2c08e28..14e74bb303 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -863,12 +863,32 @@ interface JQueryStatic { // Properties support: JQuerySupport; - // Utilities + /** + * Check to see if a DOM element is a descendant of another DOM element. + * + * @param container The DOM element that may contain the other element. + * @param contained The DOM element that may be contained by (a descendant of) the other element. + */ contains(container: Element, contained: Element): boolean; + /** + * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. + * + * @param collection The object or array to iterate over. + * @param callback The function that will be executed on every object. + */ + each( + collection: T[], + callback: (indexInArray: number, valueOfElement: T) => any + ): any; + + /** + * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. + * + * @param collection The object or array to iterate over. + * @param callback The function that will be executed on every object. + */ each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any; - each(collection: JQuery, callback: (indexInArray: number, valueOfElement: HTMLElement) => any): any; - each(collection: T[], callback: (indexInArray: number, valueOfElement: T) => any): any; extend(target: any, ...objs: any[]): any; extend(deep: boolean, target: any, ...objs: any[]): any; @@ -2479,8 +2499,12 @@ interface JQuery { wrapInner(wrappingElement: any): JQuery; wrapInner(func: (index: any) => any): JQuery; - // Miscellaneous - each(func: (index: any, elem: Element) => any): JQuery; + /** + * Iterate over a jQuery object, executing a function for each matched element. + * + * @param func A function to execute for each matched element. + */ + each(func: (index: number, elem: Element) => any): JQuery; get(index?: number): any; From f1503e8c69ad588bda3c0b74b3c328588edab9ef Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 22 Jan 2014 13:31:35 +0000 Subject: [PATCH 034/240] jQuery: JSDoc each and contains --- jquery/jquery.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 14e74bb303..3c4220c153 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -888,7 +888,10 @@ interface JQueryStatic { * @param collection The object or array to iterate over. * @param callback The function that will be executed on every object. */ - each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any; + each( + collection: any, + callback: (indexInArray: any, valueOfElement: any) => any + ): any; extend(target: any, ...objs: any[]): any; extend(deep: boolean, target: any, ...objs: any[]): any; From ed65b59f16c6404a16fb1e41ab08355cbd54b011 Mon Sep 17 00:00:00 2001 From: 44ka28ta <44ka28ta@gmail.com> Date: Wed, 22 Jan 2014 22:37:54 +0900 Subject: [PATCH 035/240] fix the return type of google.maps.geometry.encoding.decodePath. --- googlemaps/google.maps.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index 3be446e19d..d3620d2cf3 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -1242,7 +1242,7 @@ declare module google.maps { /***** Geometry Library *****/ export module geometry { export class encoding { - static decodePath(encodedPath: string): LatLng; + static decodePath(encodedPath: string): LatLng[]; static encodePath(path: any[]): string; } From 50dfa2a182a31bad6a16937a00f4137fcaa5bae9 Mon Sep 17 00:00:00 2001 From: beebes Date: Wed, 22 Jan 2014 08:25:25 -0800 Subject: [PATCH 036/240] Add azure mobile services module export So that the module will play nicely with AMD style imports. --- azure-mobile-services-client/AzureMobileServicesClient.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-mobile-services-client/AzureMobileServicesClient.d.ts b/azure-mobile-services-client/AzureMobileServicesClient.d.ts index 0c022f7344..efaecabe13 100644 --- a/azure-mobile-services-client/AzureMobileServicesClient.d.ts +++ b/azure-mobile-services-client/AzureMobileServicesClient.d.ts @@ -91,4 +91,8 @@ declare module Microsoft.WindowsAzure { } } +declare module "WindowsAzure" { + export = WindowsAzure; +} + declare var WindowsAzure: Microsoft.WindowsAzure.WindowsAzureStatic; From c47a3ad39c4d545fec3e341e65146332eb6a2c77 Mon Sep 17 00:00:00 2001 From: craigktreasure Date: Wed, 22 Jan 2014 21:01:34 -0800 Subject: [PATCH 037/240] Lots of small updates Object -> any Other small corrections --- winjs/winjs.d.ts | 576 ++++++++++++++++++++++++----------------------- 1 file changed, 296 insertions(+), 280 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 625344e111..fa31210649 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -109,7 +109,7 @@ declare module WinJS.Application { /** * An object used for storing app information that can be used to restore the app's state after it has been suspended and then resumed. Data that can usefully be contained in this object includes the current navigation page or any information the user has added to the input controls on the page. You should not add information about customization (for example colors) or user-defined lists of content. **/ - var sessionState: Object; + var sessionState: any; /** * The temp storage of the application. @@ -159,7 +159,7 @@ declare module WinJS.Application { * Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload. * @param promise The promise that should complete before processing is complete. **/ - function setPromise(promise: Promise): void; + function setPromise(promise: Promise): void; //#endregion Methods @@ -182,7 +182,7 @@ declare module WinJS.Application { * Queues an event to be processed by the WinJS.Application event queue. * @param eventRecord The event object is expected to have a type property that is used as the event name when dispatching on the WinJS.Application event queue. The entire object is provided to event listeners in the detail property of the event. **/ - function queueEvent(eventRecord: Object): void; + function queueEvent(eventRecord: any): void; /** * Removes an event listener from the control. @@ -190,7 +190,7 @@ declare module WinJS.Application { * @param listener The listener to remove. * @param useCapture Specifies whether or not to initiate capture. **/ - function removeEventListener(type: string, listener: Function, useCapture?: Object): void; + function removeEventListener(type: string, listener: Function, useCapture?: any): void; /** * Starts dispatching application events (the activated, checkpoint, error, loaded, ready, settings, and unload events). @@ -277,7 +277,7 @@ declare module WinJS.Binding { * @param name The name of the property to add. * @param value This object is returned. **/ - addProperty(name: string, value: Object): void; + addProperty(name: string, value: any): void; /** * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. @@ -285,14 +285,14 @@ declare module WinJS.Binding { * @param action The function to invoke asynchronously when the property may have changed. * @returns This object is returned. **/ - bind(name: string, action: Object): Function; + bind(name: string, action: any): Function; /** * Gets a property value by name. * @param name The name of the property to get. * @returns The value of the property as an observable object. **/ - getProperty(name: string): Object; + getProperty(name: string): any; /** * Notifies listeners that a property value was updated. @@ -301,14 +301,14 @@ declare module WinJS.Binding { * @param oldValue The old value for the property. * @returns A promise that is completed when the notifications are complete. **/ - notify(name: string, newValue: string, oldValue: string): Promise; + notify(name: string, newValue: string, oldValue: string): Promise; /** * Removes a property value. * @param name The name of the property to remove. * @returns This object is returned. **/ - removeProperty(name: string): Object; + removeProperty(name: string): any; /** * Updates a property value and notifies any listeners. @@ -316,7 +316,7 @@ declare module WinJS.Binding { * @param value The new value of the property. * @returns This object is returned. **/ - setProperty(name: string, value: Object): Object; + setProperty(name: string, value: any): any; /** * Removes one or more listeners from the notification list for a given property. @@ -324,7 +324,7 @@ declare module WinJS.Binding { * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. * @returns This object is returned. **/ - unbind(name: string, action: Function): Object; + unbind(name: string, action: Function): any; /** * Updates a property value and notifies any listeners. @@ -332,7 +332,7 @@ declare module WinJS.Binding { * @param value The new value of the property. * @returns A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed. **/ - updateProperty(name: string, value: Object): Promise; + updateProperty(name: string, value: any): Promise; //#endregion Methods @@ -467,7 +467,7 @@ declare module WinJS.Binding { * @param list The array containing the elements to initalize the list. * @param options You can set two Boolean options: binding and proxy. If options.binding is true, the list contains the result of calling as on the element values. If options.proxy is true, the list specified as the first parameter is used as the storage for the List. This option should be used with care, because uncoordinated edits to the data storage may result in errors. **/ - constructor(list?: T[], options?: Object); + constructor(list?: T[], options?: any); //#endregion Constructors @@ -543,7 +543,7 @@ declare module WinJS.Binding { * @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after). * @returns A grouped projection over the list. **/ - createGrouped(groupKey: (x: T) => string, groupData: (x: T) => Object, groupSorter: (left: string, right: string) => number): GroupedSortedListProjection; + createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter: (left: string, right: string) => number): GroupedSortedListProjection; /** * Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change. @@ -558,7 +558,7 @@ declare module WinJS.Binding { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Disconnects a WinJS.Binding.List projection from its underlying WinJS.Binding.List. It's only important to call this method when the WinJS.Binding.List projection and the WinJS.Binding.List have different lifetimes. (Call this method on the WinJS.Binding.List projection, not the underlying WinJS.Binding.List.) @@ -571,7 +571,7 @@ declare module WinJS.Binding { * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. * @returns true if the callback returns true for all elements in the list. **/ - every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: Object): boolean; + every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; /** * Returns the elements of a list that meet the condition specified in a callback function. @@ -579,14 +579,14 @@ declare module WinJS.Binding { * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. * @returns An array containing the elements that meet the condition specified in the callback function. **/ - filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: Object): T[]; + filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; /** * Calls the specified callback function for each element in a list. * @param callback A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array. * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. **/ - forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: Object): void; + forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** * Gets the value at the specified index. @@ -615,7 +615,7 @@ declare module WinJS.Binding { * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0. * @returns The index of the first occurrence of a value in a list or -1 if not found. **/ - indexOf(searchElement: Object, fromIndex?: number): number; + indexOf(searchElement: any, fromIndex?: number): number; /** * Gets the index of the first occurrence of a key in a list. @@ -645,7 +645,7 @@ declare module WinJS.Binding { * @param thisArg n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. * @returns An array containing the result of calling the callback function on each element in the list. **/ - map(callback: (value: T, index: number, array: T[]) => G, thisArg?: Object): G[]; + map(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): G[]; /** * Moves the value at index to the specified position. @@ -678,7 +678,7 @@ declare module WinJS.Binding { * Removes the last element from a list and returns it. * @returns The last element from the list. **/ - pop(): Object; + pop(): T; /** * Appends new element(s) to a list, and returns the new length of the list. @@ -693,7 +693,7 @@ declare module WinJS.Binding { * @param initiallValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value. * @returns The return value from the last call to the callback function. **/ - reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => any, initiallValue?: Object): Object; + reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initiallValue?: T): T; /** * Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. @@ -701,7 +701,7 @@ declare module WinJS.Binding { * @param initialValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value. * @returns The return value from the last call to callback function. **/ - reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => any, initialValue?: Object): Object; + reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T): T; /** * Removes an event listener. @@ -726,7 +726,7 @@ declare module WinJS.Binding { * Removes the first element from a list and returns it. * @returns The first element from the list. **/ - shift(): Object; + shift(): T; /** * Extracts a section of a list and returns a new list. @@ -742,7 +742,7 @@ declare module WinJS.Binding { * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. * @returns true if callback returns true for any element in the list. **/ - some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: Object): boolean; + some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; /** * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. @@ -765,7 +765,7 @@ declare module WinJS.Binding { * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. * @returns This object is returned. **/ - unbind(name: string, action?: Function): Object; + unbind(name: string, action?: Function): List; /** * Appends new element(s) to a list, and returns the new length of the list. @@ -809,7 +809,7 @@ declare module WinJS.Binding { * @param value The value of the property. * @returns This object is returned. **/ - addProperty(name: string, value: Object): Object; + addProperty(name: string, value: any): any; /** * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. @@ -817,14 +817,14 @@ declare module WinJS.Binding { * @param action The function to invoke asynchronously when the property may have changed. * @returns This object is returned. **/ - bind(name: string, action: Object): Function; + bind(name: string, action: any): Function; /** * Gets a property value by name. * @param name The name of the property to get. * @returns The value of the property as an observable object. **/ - getProperty(name: string): Object; + getProperty(name: string): any; /** * Notifies listeners that a property value was updated. @@ -833,14 +833,14 @@ declare module WinJS.Binding { * @param oldValue The old value for the property. * @returns A promise that is completed when the notifications are complete. **/ - notify(name: string, newValue: string, oldValue: string): Promise; + notify(name: string, newValue: string, oldValue: string): Promise; /** * Removes a property value. * @param name The name of the property to remove. * @returns This object is returned. **/ - removeProperty(name: string): Object; + removeProperty(name: string): any; /** * Updates a property value and notifies any listeners. @@ -848,7 +848,7 @@ declare module WinJS.Binding { * @param value The new value of the property. * @returns This object is returned. **/ - setProperty(name: string, value: Object): Object; + setProperty(name: string, value: any): any; /** * Removes one or more listeners from the notification list for a given property. @@ -856,7 +856,7 @@ declare module WinJS.Binding { * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. * @returns This object is returned. **/ - unbind(name: string, action: Function): Object; + unbind(name: string, action: Function): any; /** * Updates a property value and notifies any listeners. @@ -864,7 +864,7 @@ declare module WinJS.Binding { * @param value The new value of the property. * @returns A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed. **/ - updateProperty(name: string, value: Object): Promise; + updateProperty(name: string, value: any): Promise; //#endregion Methods @@ -882,7 +882,7 @@ declare module WinJS.Binding { * @param action The function to invoke asynchronously when the property may have changed. * @returns A reference to this observableMixin object. **/ - bind(name: string, action: Function): Object; + bind(name: string, action: Function): any; /** * Notifies listeners that a property value was updated. @@ -891,7 +891,7 @@ declare module WinJS.Binding { * @param oldValue The old value for the property. * @returns A promise that is completed when the notifications are complete. **/ - notify(name: string, newValue: Object, oldValue: Object): Promise; + notify(name: string, newValue: any, oldValue: any): Promise; /** * Removes one or more listeners from the notification list for a given property. @@ -899,7 +899,7 @@ declare module WinJS.Binding { * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. * @returns This object is returned. **/ - unbind(name: string, action: Function): Object; + unbind(name: string, action: Function): any; //#endregion Methods @@ -976,7 +976,7 @@ declare module WinJS.Binding { * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. * @returns A Promise that will be completed after binding has finished. The value is either container or the created DIV. promise that is completed after binding has finished. **/ - (dataContext: Object, container?: HTMLElement): Promise; + (dataContext: any, container?: HTMLElement): Promise; /** * Renders a template based on the specified URI (static method). @@ -985,7 +985,7 @@ declare module WinJS.Binding { * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. * @returns A promise that is completed after binding has finished. The value is either the object in the container parameter or the created DIV. **/ - value(href: string, dataContext: Object, container?: HTMLElement): Promise; + value(href: string, dataContext: any, container?: HTMLElement): Promise; }; //#endregion Methods @@ -995,7 +995,7 @@ declare module WinJS.Binding { /** * Gets or sets the default binding initializer for the template. **/ - bindingInitializer: Object; + bindingInitializer: any; /** * Gets or sets a value that specifies whether a debug break is inserted into the first rendering of each template. This property only has an effect when the app is in debug mode. @@ -1036,22 +1036,22 @@ declare module WinJS.Binding { * @param sourceProperties The path on the source object to the source class. * @param dest The destination object. **/ - function addClassOneTime(source: Object, sourceProperties: Object[], dest: HTMLElement): void; + function addClassOneTime(source: any, sourceProperties: any[], dest: HTMLElement): void; /** * Returns an observable object. This may be an observable proxy for the specified object, an existing proxy, or the specified object itself if it directly supports observation. * @param data The object to observe. * @returns The observable object. **/ - function as(data: Object): Object; + function as(data: U): U; /** - * Binds one or properties of a complex, observable object for child values of the object to specific functions. - * @param name The observable object to bind to. - * @param action An object that contains functions to invoke asynchronously when the specified properties in the observable object have changed. - * @returns This object is returned. + * Binds to one or more properties on the observable object or or on child values of that object. + * @param observable The object to bind to. + * @param bindingDescriptor An object literal containing the binding declarations. Binding declarations take the form: { propertyName: (function | bindingDeclaration), ... }. + * @returns An object that contains at least a "cancel" field, which is a function that removes all bindings associated with this bind request. **/ - function bind(name: string, action: Object): Object; + function bind(observable: any, bindingDescriptor: any): any; /** * Creates a default binding initializer for binding between a source property and a destination property with the specified converter function that is executed on the value of the source property. @@ -1068,21 +1068,21 @@ declare module WinJS.Binding { * @param destProperties The path on the destination object to the destination property. * @returns An object with a cancel method that is used to coalesce bindings. **/ - function defaultBind(source: Object, sourceProperties: Object, dest: Object, destProperties: Object): Object; + function defaultBind(source: any, sourceProperties: any, dest: any, destProperties: any): any; /** * Creates a new constructor function that supports observability with the specified set of properties. * @param data The object to use as the pattern for defining the set of properties. * @returns A constructor function with 1 optional argument that is the initial state of the properties. **/ - function define(data: Object): Object; + function define(data: any): Function; /** * Wraps the specified object so that all its properties are instrumented for binding. This is meant to be used in conjunction with the binding mixin. * @param shape The specification for the bindable object. * @returns An object with a set of properties all of which are wired for binding. **/ - function expandProperties(shape: Object): Object; + function expandProperties(shape: any): any; /** * Marks a custom initializer function as being compatible with declarative data binding. @@ -1098,7 +1098,7 @@ declare module WinJS.Binding { * @param oldValue The old value for the property. * @returns A promise that is completed when the notifications are complete. **/ - function notify(name: string, newValue: string, oldValue: string): Promise; + function notify(name: string, newValue: string, oldValue: string): Promise; /** * Sets the destination property to the value of the source property. @@ -1108,7 +1108,7 @@ declare module WinJS.Binding { * @param destProperties The path on the destination object to the destination property. * @returns An object with a cancel method that is used to coalesce bindings. **/ - function oneTime(source: Object, sourceProperties: Object, dest: Object, destProperties: Object): Object; + function oneTime(source: any, sourceProperties: any, dest: any, destProperties: any): any; /** * Binds the values of an object to the values of a DOM element that has the data-win-bind attribute. If multiple DOM elements are to be bound, you must set the attribute on all of them. See the example below for details. @@ -1119,7 +1119,7 @@ declare module WinJS.Binding { * @param defaultInitializer The binding initializer to use in the case that one is not specified in a binding expression. If not provided, the behavior is the same as Binding.defaultBind. * @returns A Promise that completes when every item that contains the data-win-bind attribute has been processed and the update has started. **/ - function processAll(rootElement?: Element, dataContext?: Object, skipRoot?: boolean, bindingCache?: Object, defaultInitializer?: Function): Promise; + function processAll(rootElement?: Element, dataContext?: any, skipRoot?: boolean, bindingCache?: any, defaultInitializer?: Function): Promise; /** * Creates a one-way binding between the source object and an attribute on the destination element. @@ -1129,7 +1129,7 @@ declare module WinJS.Binding { * @param destProperties The path on the destination object to the destination property. This must be a single name. * @returns An object with a cancel() method that is used to coalesce bindings. **/ - function setAttribute(source: Object, sourceProperties: Object[], dest: Element, destProperties: Object[]): Object; + function setAttribute(source: any, sourceProperties: any[], dest: Element, destProperties: any[]): any; /** * Sets an attribute on the destination element to the value of the source property. @@ -1138,14 +1138,14 @@ declare module WinJS.Binding { * @param dest The destination object. * @param destProperties The path on the destination object to the destination property. This must be a single name. **/ - function setAttributeOneTime(source: Object, sourceProperties: Object[], dest: Element, destProperties: Object[]): void; + function setAttributeOneTime(source: any, sourceProperties: any[], dest: Element, destProperties: any[]): void; /** * Returns the original (non-observable) object is returned if the specified object is an observable proxy, * @param data The object for which to retrieve the original value. * @returns If the specified object is an observable proxy, the original object is returned, otherwise the same object is returned. **/ - function unwrap(data: Object): Object; + function unwrap(data: any): any; //#endregion Functions @@ -1172,7 +1172,7 @@ declare module WinJS.Class { * @param staticMembers The set of static fields, properties, and methods made available on the type. * @returns The newly-defined type. **/ - function define(constructor: Function, instanceMembers?: Object, staticMembers?: any): Object; + function define(constructor: Function, instanceMembers?: any, staticMembers?: any): any; /** * Creates a sub-class based on the specified baseClass parameter, using prototype inheritance. @@ -1182,7 +1182,7 @@ declare module WinJS.Class { * @param staticMembers The set of static fields, properties, and methods to be made available on the type. * @returns The newly-defined type. **/ - function derive(baseClass: Object, constructor: Function, instanceMembers?: Object, staticMembers?: Object): Object; + function derive(baseClass: any, constructor: Function, instanceMembers?: any, staticMembers?: any): any; /** * Defines a class using the given constructor and the union of the set of instance members specified by all the mixin objects. The mixin parameter list is of variable length. For more information, see Adding functionality with WinJS mixins. @@ -1190,7 +1190,7 @@ declare module WinJS.Class { * @param mixin An object declaring the set of instance members. The mixin parameter list is of variable length. * @returns The newly defined class. **/ - function mix(constructor: Function, ...mixin: any[]): Object; + function mix(constructor: Function, ...mixin: any[]): any; //#endregion Functions @@ -1289,7 +1289,7 @@ declare module WinJS { * @param details The set of additional properties to be attached to the event object. * @returns true if preventDefault was called on the event; otherwise, false. **/ - dispatchEvent(type: string, details: Object): boolean; + dispatchEvent(type: string, details: any): boolean; /** * Allows you to specify the work to be done on the fulfillment of the promised value, the error handling to be performed if the promise fails to fulfill a value, and the handling of progress notifications along the way. After the handlers have finished executing, this function throws any error that would have been returned from then as a promise in the error state. For more information about the differences between then and done, see the following topics: Quickstart: using promises in JavaScript How to handle errors when using promises in JavaScript Chaining promises in JavaScript. @@ -1304,14 +1304,14 @@ declare module WinJS { * @param value A value that may be a promise. * @returns true if the object conforms to the promise contract (has a then function), otherwise false. **/ - static is(value: Object): boolean; + static is(value: any): boolean; /** * Creates a Promise that is fulfilled when all the values are fulfilled. * @param values An object whose members contain values, some of which may be promises. * @returns A Promise whose value is an object with the same field names as those of the object in the values parameter, where each field value is the fulfilled value of a promise. **/ - static join(values: Object): Promise; + static join(values: any): Promise; /** * Removes an event listener from the control. @@ -1365,7 +1365,7 @@ declare module WinJS { * @param progress The function to be called if the promise reports progress. This function takes a single argument, which is the data about the progress of the promise. Promises are not required to support progress. * @returns A Promise that is the result of calling join on the values parameter. **/ - static thenEach(values: Object, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): Promise; + static thenEach(values: any, complete?: (value: any) => void, error?: (error: any) => void, progress?: (progress: any) => void): Promise; /** * This method has two forms: WinJS.Promise.timeout(timeout) and WinJS.Promise.timeout(timeout, promise). WinJS.Promise.timeout(timeout) creates a promise that is completed asynchronously after the specified timeout, essentially wrapping a call to setTimeout within a promise. WinJS.Promise.timeout(timeout, promise) sets a timeout period for completion of the specified promise, automatically canceling the promise if it is not completed within the timeout period. @@ -1373,7 +1373,7 @@ declare module WinJS { * @param promise Optional. A promise that will be canceled if it doesn't complete within the timeout period. * @returns If the promise parameter is omitted, returns a promise that will be fulfilled after the timeout period. If the promise paramater is provided, the same promise is returned. **/ - static timeout(timeout: number, promise?: Promise): Promise; + static timeout(timeout: number, promise?: Promise): Promise; /** * Wraps a non-promise value in a promise. This method is like wrapError, which allows you to produce a Promise in error conditions, in that it allows you to return a Promise in success conditions. @@ -1445,7 +1445,7 @@ declare module WinJS.Namespace { * @param members The members of the new namespace. * @returns The newly-defined namespace. **/ - function define(name: string, members: Object): Object; + function define(name?: string, members?: any): any; /** * Defines a new namespace with the specified name under the specified parent namespace. For more information, see Organizing your code with WinJS.Namespace. @@ -1454,7 +1454,7 @@ declare module WinJS.Namespace { * @param members The members of the new namespace. * @returns The newly-defined namespace. **/ - function defineWithParent(parentNamespace: Object, name: string, members: Object): Object; + function defineWithParent(parentNamespace?: any, name?: string, members?: any): any; //#endregion Functions @@ -1478,7 +1478,7 @@ declare module WinJS.Navigation { /** * Gets or sets the navigation history. **/ - var history: Object; + var history: any; /** * Gets or sets the current location. @@ -1488,7 +1488,7 @@ declare module WinJS.Navigation { /** * Gets or sets a user-defined object that represents the state associated with the current location. **/ - var state: Object; + var state: any; //#endregion Properties @@ -1522,7 +1522,7 @@ declare module WinJS.Navigation { * @param initialState A user-defined object that represents the navigation state that may be accessed through state. * @returns A promise that is completed with a value that indicates whether or not the navigation was successful (true if successful, otherwise false). **/ - function navigate(location: Object, initialState?: Object): Promise; + function navigate(location: any, initialState?: any): Promise; /** * Removes an event listener from the control. @@ -1576,14 +1576,14 @@ declare module WinJS.Resources { * @param type The name of the event to raise. * @param details The set of additional properties to attach to the event object. **/ - function dispatchEvent(type: string, details: Object): void; + function dispatchEvent(type: string, details: any): void; /** * Retrieves the resource string that has the specified resource identifier. * @param resourceId The resource ID of the string to retrieve. * @returns An object that can contain these properties: value, empty, lang. **/ - function getString(resourceId: string): Object; + function getString(resourceId: string): { value: string; empty?: boolean; lang?: string; }; /** * Processes data-win-res attributes on elements and replaces attributes and properties with resource strings. @@ -1624,7 +1624,7 @@ declare module WinJS.UI.Animation { * @param affected Element or elements affected by the added items. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ - function createAddToListAnimation(added: Object, affected: Object): IAnimationMethodResponse; + function createAddToListAnimation(added: any, affected: any): IAnimationMethodResponse; /** * Creates an object that performs an animation that adds an item or items to a list of search results. @@ -1632,7 +1632,7 @@ declare module WinJS.UI.Animation { * @param affected Element or elements affected by the added items. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ - function createAddToSearchListAnimation(added: Object, affected: Object): IAnimationMethodResponse; + function createAddToSearchListAnimation(added: any, affected: any): IAnimationMethodResponse; /** * Creates an object that performs an animation that collapses a list. @@ -1640,7 +1640,7 @@ declare module WinJS.UI.Animation { * @param affected Element or elements affected by the hidden items. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ - function createCollapseAnimation(hidden: Object, affected: Object): IAnimationMethodResponse; + function createCollapseAnimation(hidden: any, affected: any): IAnimationMethodResponse; /** * Creates an object that performs an animation that removes an item or items from a list. @@ -1648,7 +1648,7 @@ declare module WinJS.UI.Animation { * @param remaining Element or elements affected by the removal of the deleted items. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ - function createDeleteFromListAnimation(deleted: Object, remaining: Object): IAnimationMethodResponse; + function createDeleteFromListAnimation(deleted: any, remaining: any): IAnimationMethodResponse; /** * Creates an object that performs an animation that removes an item or items from a list of search results. @@ -1656,7 +1656,7 @@ declare module WinJS.UI.Animation { * @param remaining Element or elements affected by the removal of the deleted items. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ - function createDeleteFromSearchListAnimation(deleted: Object, remaining: Object): IAnimationMethodResponse; + function createDeleteFromSearchListAnimation(deleted: any, remaining: any): IAnimationMethodResponse; /** * Creates an object that performs an animation that expands a list. @@ -1664,21 +1664,21 @@ declare module WinJS.UI.Animation { * @param affected Element or elements affected by the newly revealed items. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ - function createExpandAnimation(revealed: Object, affected: Object): IAnimationMethodResponse; + function createExpandAnimation(revealed: any, affected: any): IAnimationMethodResponse; /** * Creates an object that performs a peek animation. * @param element Element or elements involved in the peek. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ - function createPeekAnimation(element: Object): IAnimationMethodResponse; + function createPeekAnimation(element: any): IAnimationMethodResponse; /** * Creates an object that performs an animation that moves an item or items. * @param element Element or elements involved in the reposition. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise object that completes when the animation is finished. **/ - function createRepositionAnimation(element: Object): IAnimationMethodResponse; + function createRepositionAnimation(element: any): IAnimationMethodResponse; /** * Performs an animation that fades an item or items in, fading out existing items that occupy the same space. @@ -1686,7 +1686,7 @@ declare module WinJS.UI.Animation { * @param outgoing Element or elements being replaced. * @returns An object that completes when the animation has finished. **/ - function crossFade(incoming: Object, outgoing: Object): Promise; + function crossFade(incoming: any, outgoing: any): Promise; /** * Performs an animation when a dragged object is moved such that dropping it in that position would move other items. The potentially affected items are animated out of the way to show where the object would be dropped. @@ -1694,14 +1694,14 @@ declare module WinJS.UI.Animation { * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function dragBetweenEnter(target: Object, offset: Object): Promise; + function dragBetweenEnter(target: any, offset: any): Promise; /** * Performs an animation when a dragged object is moved away from items that it had previously involved in a dragBetweenEnter animation. The affected objects are animated back to their original positions. * @param target Element or elements that the dragged object would no longer cause to be displaced, due to its moving away. This should be the same element or element collection passed as the target parameter in the dragBetweenEnter animation. * @returns An object that completes when the animation is finished. **/ - function dragBetweenLeave(target: Object): Promise; + function dragBetweenLeave(target: any): Promise; /** * Performs an animation when the user finishes dragging an object. @@ -1710,7 +1710,7 @@ declare module WinJS.UI.Animation { * @param affected Element or elements whose position the dropped object affects. Typically, this is all other items in a reorderable list. This should be the same element or element collection passed as the affected parameter in the dragSourceStart animation. * @returns An object that completes when the animation is finished. **/ - function dragSourceEnd(dragSource: Object, offset: Object, affected?: Object): Promise; + function dragSourceEnd(dragSource: any, offset: any, affected?: any): Promise; /** * Performs an animation when the user begins to drag an object. @@ -1718,7 +1718,7 @@ declare module WinJS.UI.Animation { * @param affected Element or elements whose position is affected by the movement of the dragged object. Typically, this is all other items in a reorderable list. * @returns An object that completes when the animation is finished. **/ - function dragSourceStart(dragSource: Object, affected?: Object): Promise; + function dragSourceStart(dragSource: any, affected?: any): Promise; /** * Performs an animation that displays one or more elements on a page. @@ -1727,7 +1727,7 @@ declare module WinJS.UI.Animation { * @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance. * @returns An object that completes when the animation is finished. **/ - function enterContent(incoming: Object, offset: Object, options: Object): Promise; + function enterContent(incoming: any, offset: any, options: any): Promise; /** * Performs an animation that shows a new page of content, either when transitioning between pages in a running app or when displaying the first content in a newly launched app. @@ -1735,7 +1735,7 @@ declare module WinJS.UI.Animation { * @param offset An initial offset where the element or elements begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function enterPage(element: Object, offset: Object): Promise; + function enterPage(element: any, offset: any): Promise; /** * Performs an animation that hides one or more elements on a page. @@ -1743,7 +1743,7 @@ declare module WinJS.UI.Animation { * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function exitContent(outgoing: Object, offset: Object): Promise; + function exitContent(outgoing: any, offset: any): Promise; /** * Performs an animation that dismisses the current page when transitioning between pages in an app. @@ -1751,21 +1751,21 @@ declare module WinJS.UI.Animation { * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function exitPage(outgoing: Object, offset: Object): Promise; + function exitPage(outgoing: any, offset: any): Promise; /** * Performs an animation that fades an item or set of items into view. * @param shown Element or elements being faded in. * @returns An object that completes when the animation has finished. Use this object when subsequent actions need this animation to finish before they take place. **/ - function fadeIn(shown: Object): Promise; + function fadeIn(shown: any): Promise; /** * Performs an animation that fades an item or set of items out of view. * @param hidden Element or elements being faded out. * @returns An object that completes when the animation is finished. **/ - function fadeOut(hidden: Object): Promise; + function fadeOut(hidden: any): Promise; /** * Performs an animation that hides edge-based user interface (UI). @@ -1774,7 +1774,7 @@ declare module WinJS.UI.Animation { * @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance. * @returns An object that completes when the animation is finished. **/ - function hideEdgeUI(element: Object, offset: Object, options: Object): Promise; + function hideEdgeUI(element: any, offset: any, options?: any): Promise; /** * Performs an animation that hides a panel. @@ -1782,28 +1782,28 @@ declare module WinJS.UI.Animation { * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements end the animation just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function hidePanel(element: Object, offset: Object): Promise; + function hidePanel(element: any, offset: any): Promise; /** * Performs an animation that removes pop-up user interface (UI). * @param element Element or elements that are being hidden. * @returns An object that completes when the animation is finished. **/ - function hidePopup(element: Object): Promise; + function hidePopup(element: any): Promise; /** * Performs an animation when a pointer is pressed on an object. * @param element Element or elements on which the pointer is pressed. * @returns An object that completes when the animation is finished. **/ - function pointerDown(element: Object): Promise; + function pointerDown(element: any): Promise; /** * Performs an animation when a pointer is released. * @param element Element or elements that the pointer was pressed on. * @returns An object that completes when the animation is finished. **/ - function pointerUp(element: Object): Promise; + function pointerUp(element: any): Promise; /** * Performs an animation that slides a narrow, edge-based user interface (UI) into view. @@ -1812,7 +1812,7 @@ declare module WinJS.UI.Animation { * @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance. * @returns An object that completes when the animation is finished. **/ - function showEdgeUI(element: Object, offset: Object, options: Object): Promise; + function showEdgeUI(element: any, offset: any, options?: any): Promise; /** * Performs an animation that slides a large panel user interface (UI) into view. @@ -1820,7 +1820,7 @@ declare module WinJS.UI.Animation { * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function showPanel(element: Object, offset: Object): Promise; + function showPanel(element: any, offset: any): Promise; /** * Performs an animation that displays a pop-up user interface (UI). @@ -1828,7 +1828,7 @@ declare module WinJS.UI.Animation { * @param offset Initial offsets where the animated objects begin relative to their final position at the end of the animation. Offsets should be the chosen so that the elements begin the animation from just off-screen. Set this parameter to null to use the recommended default offset. Note When the element parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function showPopup(element: Object, offset: Object): Promise; + function showPopup(element: any, offset: any): Promise; /** * Performs a deselection animation in response to a swipe interaction. @@ -1836,7 +1836,7 @@ declare module WinJS.UI.Animation { * @param selection Element or elements that represent the selection, typically a check mark. * @returns An object that completes when the animation is finished. **/ - function swipeDeselect(deselected: Object, selection: Object): Promise; + function swipeDeselect(deselected: any, selection: any): Promise; /** * Performs an animation that reveals an item or items in response to a swipe interaction. @@ -1844,7 +1844,7 @@ declare module WinJS.UI.Animation { * @param offset An initial offset where the animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function swipeReveal(target: Object, offset: Object): Promise; + function swipeReveal(target: any, offset: any): Promise; /** * Performs a selection animation in response to a swipe interaction. @@ -1852,7 +1852,7 @@ declare module WinJS.UI.Animation { * @param selection Element or elements that show that something is selected, typically a check mark. * @returns An object that completes when the animation is finished. **/ - function swipeSelect(selected: Object, selection: Object): Promise; + function swipeSelect(selected: any, selection: any): Promise; /** * Performs an animation that updates a badge. @@ -1860,14 +1860,14 @@ declare module WinJS.UI.Animation { * @param offset Initial offsets where incoming animated objects begin relative to their final position at the end of the animation. Set this parameter to null to use the recommended default offset. Note When the incoming parameter specifies an array of elements, the offset parameter can specify an offset array with each item specified for its corresponding element array item. If the array of offsets is smaller than the array of elements, the last offset is applied to all remaining elements. * @returns An object that completes when the animation is finished. **/ - function updateBadge(incoming: Object, offset: Object): Promise; + function updateBadge(incoming: any, offset: any): Promise; //#endregion Functions //#region Interfaces interface IAnimationMethodResponse { - execute(): Promise; + execute(): Promise; } //#endregion Interfaces @@ -2381,7 +2381,7 @@ declare module WinJS.UI { * @param onError The function to be called if the promise is fulfilled with an error. The error is passed as the single argument. If it is null, the error is forwarded. The value returned from the function is the fulfilled value of the promise returned by then. * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. **/ - done(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: Object) => void): void; + done(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): void; /** * Stops change notification tracking for the IItem that fulfills this IItemPromise. @@ -2400,7 +2400,7 @@ declare module WinJS.UI { * @param onProgress The function to be called if the promise reports progress. Data about the progress is passed as the single argument. Promises are not required to support progress. * @returns The promise whose value is the result of executing the complete or error function. **/ - then(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: Object) => void): IItemPromise; + then(onComplete: (item: T) => void, onError?: (error: Error) => void, onProgress?: (progressData: any) => void): IItemPromise; //#endregion Methods @@ -2432,7 +2432,7 @@ declare module WinJS.UI { * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. * @returns A Promise for the index of the first visible item at the specified point. **/ - calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): Promise; + calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): Promise; /** * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. @@ -2440,20 +2440,20 @@ declare module WinJS.UI { * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. * @returns A Promise for the index of the last visible item at the specified point. **/ - calculateLastVisible(endScrollPosition: number, wholeItem: boolean): Promise; + calculateLastVisible(endScrollPosition: number, wholeItem: boolean): Promise; /** * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. * @returns A object that has these properties: animationPromise, newEndIndex. **/ - endLayout(): Object; + endLayout(): any; /** * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. * @param itemIndex The index of the item. * @returns A Promise that returns an object with these properties: left, top, contentWidth, contentHeight, totalWidth, totalHeight. **/ - getItemPosition(itemIndex: number): Promise; + getItemPosition(itemIndex: number): Promise; /** * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. @@ -2468,7 +2468,7 @@ declare module WinJS.UI { * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. * @returns A Promise that returns an object that has these properties: beginScrollPosition, endScrollPosition. **/ - getScrollBarRange(): Promise; + getScrollBarRange(): Promise; /** * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. @@ -2544,7 +2544,7 @@ declare module WinJS.UI { * @param count The upper bound of the number of items to render. * @returns A Promise that returns an object that has these properties: beginIndex, endIndex. **/ - startLayout(beginScrollPosition: number, endScrollPosition: number, count: number): Promise; + startLayout(beginScrollPosition: number, endScrollPosition: number, count: number): Promise; //#endregion Methods @@ -2589,7 +2589,7 @@ declare module WinJS.UI { * @param pressedKey The key that was pressed. * @returns An object that describes the next item that should receive focus. It has these properties: index, type. **/ - getAdjacent(currentItem: Object, pressedKey: WinJS.Utilities.Key): Object; + getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any; /** * Gets the item at the specified hit-test coordinates. These coordinates are absolute coordinates (they are not relative to the layout's content area). @@ -2597,7 +2597,7 @@ declare module WinJS.UI { * @param y The y-coordinate to test for. * @returns An object that describes the item at the hit test coordinates. It has these properties: type, index. **/ - hitTest(x: number, y: number): Object; + hitTest(x: number, y: number): any; /** * Sets the rendering site and specifies whether the layout supports groups. This method is called by the ListView to initialize the layout. @@ -2621,7 +2621,7 @@ declare module WinJS.UI { * @param modifiedGroups An object that contains the old and new indexes of the group elements that have been modified in the tree. * @returns A Promise that executes after layout is complete, or an object that contains two Promise objects: realizedRangeComplete, layoutComplete. **/ - layout(tree: Object, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): Object; + layout(tree: any, changedRange: any, modifiedItems: any, modifiedGroups: any): any; /** * Called when the ListView requests that the ILayout2 set up animations. @@ -2685,7 +2685,7 @@ declare module WinJS.UI { /** * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use a the ILayoutSite2 interface. **/ - viewportSize: Object; + viewportSize: any; //#endregion Properties @@ -2710,12 +2710,12 @@ declare module WinJS.UI { /** * Gets the pixel range of the realization area. **/ - realizedRange: Object; + realizedRange: any; /** * Gets the tree for use by an object that implements the ILayout2 interface. **/ - tree: Object; + tree: any; /** * Gets the pixel range of visible items in the site. @@ -2764,7 +2764,7 @@ declare module WinJS.UI { * @param hints Domain-specific information that provides additional information to the IListDataAdapter to improve retrieval time. * @returns An IItemPromise that contains the requested IItem. If they item couldn't be found, the promise completes with a value of null. **/ - fromKey(key: string, hints?: Object): IItemPromise>; + fromKey(key: string, hints?: any): IItemPromise>; /** * Makes the specified IItem or IItemPromise the current item. @@ -2919,7 +2919,7 @@ declare module WinJS.UI { * @param previousIndexHint The index to move the item after, if known. * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. **/ - moveAfter(key: string, previousKey: Object, indexHint: string, previousIndexHint: number): Promise>; + moveAfter(key: string, previousKey: any, indexHint: string, previousIndexHint: number): Promise>; /** * Moves the specified item to just before another item. @@ -2929,7 +2929,7 @@ declare module WinJS.UI { * @param nextIndexHint The index to move the item before, if known. * @returns A Promise that contains the IItem that was added or an EditError if an error was encountered. **/ - moveBefore(key: string, nextKey: Object, indexHint: string, nextIndexHint: number): Promise>; + moveBefore(key: string, nextKey: any, indexHint: string, nextIndexHint: number): Promise>; /** * Moves the specified item to the end of the IListDataAdapter object's data source. @@ -3010,7 +3010,7 @@ declare module WinJS.UI { * Indicates that all previous data obtained from the IListDataAdapter is invalid and should be refreshed. * @returns A Promise that completes when the data has been completely refreshed and all change notifications have been sent. **/ - invalidateAll(): Promise; + invalidateAll(): Promise; /** * Raises a notification that an item was moved within the IListDataAdapter object's data source. @@ -3123,14 +3123,14 @@ declare module WinJS.UI { * Indicates that all previous data obtained from the IListDataAdapter is invalid and should be refreshed. * @returns A Promise that completes when the data has been completely refreshed and all notifications have been sent. **/ - invalidateAll(): Promise; + invalidateAll(): Promise; /** * Retrieves the item that has the specified description. * @param description Domain-specific information, to be interpreted by the IListDataAdapter, that describes the item to retrieve. * @returns A Promise that provides an IItem that contains the requested item or a FetchError if an error was encountered. If the item wasn't found, the promise completes with a value of null. **/ - itemFromDescription(description: Object): Promise>; + itemFromDescription(description: any): Promise>; /** * Retrieves the item at the specified index. @@ -3145,7 +3145,7 @@ declare module WinJS.UI { * @param description Domain-specific information that IListDataAdapter can use to improve the retrieval time. * @returns A Promise that provides an IItem that contains the requested item or a FetchError if an error was encountered. If the item was not found, the promise completes with a null value. **/ - itemFromKey(key: string, description?: Object): Promise>; + itemFromKey(key: string, description?: any): Promise>; /** * Moves an item to just after another item. @@ -3270,13 +3270,13 @@ declare module WinJS.UI { * @param items The indexes or keys of the items to add. You can provide different types of objects for the items parameter: you can specify an index, a key, or a range of indexes. It can also be an array that contains one or more of these objects. For more info, see the Remarks section. * @returns A Promise that is fulfilled when the operation completes. **/ - add(items: Object): Promise; + add(items: any): Promise; /** * Clears the selection. * @returns A Promise that is fulfilled when the clear operation completes. **/ - clear(): Promise; + clear(): Promise; /** * Returns the number of items in the selection. @@ -3313,7 +3313,7 @@ declare module WinJS.UI { * @param items The indexes or keys of the items to remove. You can provide different types of objects for the items parameter: you can specify an index, a key, or a range of indexes. It can also be an array that contains one or more of these objects. For more info, see the Remarks section. * @returns A Promise that is fulfilled when the operation completes. **/ - remove(items: Object): Promise; + remove(items: any): Promise; /** * Adds all the items in the ListView to the selection. @@ -3325,7 +3325,7 @@ declare module WinJS.UI { * @param items The indexes or keys of the items that make up the selection. You can provide different types of objects for the items parameter: you can specify an index, a key, or a range of indexes. It can also be an array that contains one or more of these objects. For more info, see the Remarks section. * @returns A Promise that is fulfilled when the operation completes. **/ - set(items: Object): Promise; + set(items: any): Promise; //#endregion Methods @@ -3345,7 +3345,7 @@ declare module WinJS.UI { /** * Gets or sets the key of the first item in the range. **/ - firstKey: Object; + firstKey: any; /** * Gets or sets the index of the last item in the range. @@ -3355,7 +3355,7 @@ declare module WinJS.UI { /** * Gets or sets of the key of the last item in the range. **/ - lastKey: Object; + lastKey: any; //#endregion Properties @@ -3439,7 +3439,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBar. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -3487,7 +3487,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this AppBar. Call this method when the AppBar is no longer needed. After calling this method, the AppBar becomes unusable. @@ -3511,7 +3511,7 @@ declare module WinJS.UI { * @param commands The commands to hide. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: Object[], immediate: boolean): void; + hideCommands(commands: any[], immediate: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -3531,14 +3531,14 @@ declare module WinJS.UI { * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: Object[], immediate: boolean): void; + showCommands(commands: any[], immediate: boolean): void; /** * Shows the specified commands of the AppBar while hiding all other commands. * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: Object[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate: boolean): void; //#endregion Methods @@ -3595,7 +3595,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBarCommand. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -3717,7 +3717,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new BackButton. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: Object, options: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -3737,7 +3737,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this BackButton. Call this method when the BackButton is no longer needed. After calling this method, the BackButton becomes unusable. @@ -3781,7 +3781,7 @@ declare module WinJS.UI { * @constructor * @param options An object that contains one or more property/value pairs to apply to the new CellSpanningLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ - constructor(options: Object); + constructor(options?: any); //#endregion Constructors @@ -3808,7 +3808,7 @@ declare module WinJS.UI { * @param pressedKey The key that was pressed. * @returns An object that describes the next item that should receive focus. It has these properties: index, type. **/ - getAdjacent(currentItem: Object, pressedKey: WinJS.Utilities.Key): Object; + getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -3838,7 +3838,7 @@ declare module WinJS.UI { * @param modifiedItems * @param modifiedGroups **/ - layout(tree: ILayoutSite2, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): void; + layout(tree: ILayoutSite2, changedRange: any, modifiedItems: any, modifiedGroups: any): void; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -3900,7 +3900,7 @@ declare module WinJS.UI { * @param element The DOM element associated with the DatePicker control. * @param options The set of options to be applied initially to the DatePicker control. The options are the following: calendar, current, datePattern, disabled, maxYear, minYear, monthPattern, yearPattern. **/ - constructor(element: HTMLElement, options: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -3930,7 +3930,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this DatePicker. Call this method when the DatePicker is no longer needed. After calling this method, the DatePicker becomes unusable. @@ -3943,7 +3943,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - raiseEvent(type: string, eventProperties: Object): boolean; + raiseEvent(type: string, eventProperties: any): boolean; /** * Removes a listener for the specified event. @@ -3951,7 +3951,7 @@ declare module WinJS.UI { * @param listener The listener. * @param useCapture Optional. The same value that was passed to addEventListener for this listener. It may be omitted if it was omitted when calling addEventListener. **/ - removeEventListener(type: string, listener: Function, useCapture?: Object): void; + removeEventListener(type: string, listener: Function, useCapture?: any): void; //#endregion Methods @@ -3960,7 +3960,7 @@ declare module WinJS.UI { /** * Gets or sets the calendar to use. **/ - calendar: Object; + calendar: any; /** * Gets or sets the current date of the DatePicker. You can use either a date string or a Date object to set this property. @@ -4026,7 +4026,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Removes an event listener from the control. @@ -4041,7 +4041,7 @@ declare module WinJS.UI { * @param control The control on which the properties and events are to be applied. * @param options The set of options that are specified declaratively. **/ - setOptions(control: Object, options: Object): void; + setOptions(control: any, options: any): void; //#endregion Methods @@ -4059,7 +4059,7 @@ declare module WinJS.UI { * @param element The DOM element that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the pageselected event, add a property named "onpageselected" and set its value to the event handler. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -4113,7 +4113,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this FlipView. Call this method when the FlipView is no longer needed. After calling this method, the FlipView becomes unusable. @@ -4149,7 +4149,7 @@ declare module WinJS.UI { * Sets custom animations for the FlipView to use when navigating between pages. * @param animations An object that contains up to three fields, one for each navigation action: next, previous, and jump. Each of those fields must be a function with this signature: function (outgoingPage, incomingPage) Each function must return a WinJS.Promise that completes once the animations are finished. If a field is null or undefined, the FlipView reverts to its default animation for that action. **/ - setCustomAnimations(animations: Object): void; + setCustomAnimations(animations: any): void; //#endregion Methods @@ -4201,7 +4201,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Flyout. **/ - constructor(element: HTMLElement, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -4267,7 +4267,7 @@ declare module WinJS.UI { * @param placement The placement of the Flyout to the anchor: the string literal "top", "bottom", "left", or "right". * @param alignment For "top" or "bottom" placement, the alignment of the Flyout to the anchor's edge: the string literal "center", "left", or "right". **/ - show(anchor: HTMLElement, placement: Object, alignment: Object): void; + show(anchor: HTMLElement, placement: string, alignment: string): void; //#endregion Methods @@ -4276,7 +4276,7 @@ declare module WinJS.UI { /** * Gets or sets the default alignment to be used for this Flyout. **/ - alignment: Object; + alignment: string; /** * Gets or sets the default anchor to be used for this Flyout. @@ -4296,7 +4296,7 @@ declare module WinJS.UI { /** * Gets or sets the default placement to be used for this Flyout. **/ - placement: Object; + placement: string; //#endregion Properties @@ -4313,7 +4313,7 @@ declare module WinJS.UI { * @constructor * @param options The set of properties and values to apply to the new GridLayout. **/ - constructor(options?: Object); + constructor(options?: any); //#endregion Constructors @@ -4365,7 +4365,7 @@ declare module WinJS.UI { * @param element * @param keyPressed **/ - getKeyboardNavigatedItem(itemIndex: number, element: Object, keyPressed: Object): void; + getKeyboardNavigatedItem(itemIndex: number, element: any, keyPressed: any): void; /** * This method is no longer supported. @@ -4397,7 +4397,7 @@ declare module WinJS.UI { * This method is no longer supported. * @param elements **/ - itemsAdded(elements: Object): void; + itemsAdded(elements: any): void; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -4415,7 +4415,7 @@ declare module WinJS.UI { * This method is no longer supported. * @param elements **/ - itemsRemoved(elements: Object): void; + itemsRemoved(elements: any): void; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -4424,21 +4424,21 @@ declare module WinJS.UI { * @param modifiedItems * @param modifiedGroups **/ - layout(tree: Object, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): void; + layout(tree: any, changedRange: any, modifiedItems: any, modifiedGroups: any): void; /** * This method is no longer supported. * @param groupIndex * @param element A DOM element. **/ - layoutHeader(groupIndex: number, element: Object): void; + layoutHeader(groupIndex: number, element: any): void; /** * This method is no longer supported. * @param itemIndex * @param element A DOM element. **/ - layoutItem(itemIndex: number, element: Object): void; + layoutItem(itemIndex: number, element: any): void; /** * This method is no longer supported. @@ -4451,14 +4451,14 @@ declare module WinJS.UI { * @param itemIndex * @param element A DOM element. **/ - prepareItem(itemIndex: number, element: Object): void; + prepareItem(itemIndex: number, element: any): void; /** * This method is no longer supported. * @param item * @param newItem **/ - releaseItem(item: Object, newItem: Object): void; + releaseItem(item: any, newItem: any): void; /** * This method is no longer supported. @@ -4469,7 +4469,7 @@ declare module WinJS.UI { * This method is no longer supported. * @param layoutSite **/ - setSite(layoutSite: Object): void; + setSite(layoutSite: any): void; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -4564,7 +4564,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the Hub control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the contentanimating event, add a property named "oncontentanimating" to the options object and set its value to the event handler. **/ - constructor(element: HTMLElement, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -4606,7 +4606,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this Hub. Call this method when the Hub is no longer needed. After calling this method, the Hub becomes unusable. @@ -4691,7 +4691,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new HubSection. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -4734,16 +4734,17 @@ declare module WinJS.UI { * Enables you to include an HTML page dynamically. As part of the constructor, you must include an option indicating the URI of the page. **/ class HtmlControl { - //#region Methods + //#region Constructors /** * Initializes a new instance of HtmlControl to define a new page control. + * @constructor * @param element The element that hosts the HtmlControl. * @param options The options for configuring the page. The uri option is required in order to specify the source document for the content of the page. Other options are the ones used by the WinJS.Pages.render method. **/ - HtmlControl(element: HTMLElement, options: Object): void; + constructor(element: HTMLElement, options?: any); - //#endregion Methods + //#endregion Constructors } @@ -4759,7 +4760,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new ItemContainer. For the ItemContainer to be accessible, this element must have its role attribute set to "list" or "listbox". If tapBehavior is set to none and selectionDisabled is true, then use the "list" role; otherwise, use the "listbox" role. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: Object, options: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -4801,7 +4802,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this ItemContainer. Call this method when the ItemContainer is no longer needed. After calling this method, the ItemContainer becomes unusable. @@ -4881,7 +4882,7 @@ declare module WinJS.UI { * @constructor * @param options An object that contains one or more property/value pairs to apply to the new ListLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ - constructor(options?: Object); + constructor(options?: any); //#endregion Constructors @@ -4933,7 +4934,7 @@ declare module WinJS.UI { * @param element * @param keyPressed **/ - getKeyboardNavigatedItem(itemIndex: number, element: Object, keyPressed: Object): void; + getKeyboardNavigatedItem(itemIndex: number, element: HTMLElement, keyPressed: any): void; /** * This method is no longer supported. @@ -4963,7 +4964,7 @@ declare module WinJS.UI { * This method is no longer supported. * @param elements **/ - itemsAdded(elements: Object): void; + itemsAdded(elements: any): void; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -4981,7 +4982,7 @@ declare module WinJS.UI { * This method is no longer supported. * @param elements **/ - itemsRemoved(elements: Object): void; + itemsRemoved(elements: any): void; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -4990,21 +4991,21 @@ declare module WinJS.UI { * @param modifiedItems * @param modifiedGroups **/ - layout(tree: Object, changedRange: Object, modifiedItems: Object, modifiedGroups: Object): void; + layout(tree: any, changedRange: any, modifiedItems: any, modifiedGroups: any): void; /** * This method is no longer supported. * @param groupIndex * @param element A DOM element. **/ - layoutHeader(groupIndex: number, element: Object): void; + layoutHeader(groupIndex: number, element: any): void; /** * This method is no longer supported. * @param itemIndex * @param element A DOM element. **/ - layoutItem(itemIndex: number, element: Object): void; + layoutItem(itemIndex: number, element: any): void; /** * This method is no longer supported. @@ -5017,14 +5018,14 @@ declare module WinJS.UI { * @param itemIndex * @param element A DOM element. **/ - prepareItem(itemIndex: number, element: Object): void; + prepareItem(itemIndex: number, element: any): void; /** * This method is no longer supported. * @param item * @param newItem **/ - releaseItem(item: Object, newItem: Object): void; + releaseItem(item: any, newItem: any): void; /** * This method is no longer supported. @@ -5035,7 +5036,7 @@ declare module WinJS.UI { * This method is no longer supported. * @param layoutSite **/ - setSite(layoutSite: Object): void; + setSite(layoutSite: any): void; /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. @@ -5120,7 +5121,7 @@ declare module WinJS.UI { * @param element The DOM element that hosts the ListView control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the selectionchanged event, add a property named "onselectionchanged" to the options object and set its value to the event handler. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -5228,7 +5229,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this object. Call this method when the object is no longer needed. After calling this method, the object becomes unusable. @@ -5380,7 +5381,7 @@ declare module WinJS.UI { /** * Gets or sets the function that is called when the ListView discards or recycles the element representation of a group header. **/ - resetGroupHeader: (header: Object, element: HTMLElement) => void; + resetGroupHeader: (header: any, element: HTMLElement) => void; /** * Gets or sets the function that is called when an item is removed, an item is changed, or an item falls outside of the realized range of the ListView. @@ -5433,7 +5434,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Menu. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -5497,7 +5498,7 @@ declare module WinJS.UI { * @param commands The commands to hide. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: Object[], immediate: boolean): void; + hideCommands(commands: any[], immediate: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -5513,21 +5514,21 @@ declare module WinJS.UI { * @param placement The placement of the Menu to the anchor: top, bottom, left, or right. * @param alignment For top or bottom placement, the alignment of the Menu to the anchor's edge: center, left, or right. **/ - show(anchor: HTMLElement, placement: Object, alignment: Object): void; + show(anchor: HTMLElement, placement: string, alignment: string): void; /** * Shows the specified commands of the Menu. * @param commands The commands to show. The array elements may be Menu objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: Object[], immediate: boolean): void; + showCommands(commands: any[], immediate: boolean): void; /** * Shows the specified commands of the Menu while hiding all other commands. * @param commands The commands to show. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: Object[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate: boolean): void; //#endregion Methods @@ -5536,7 +5537,7 @@ declare module WinJS.UI { /** * Gets or sets the default alignment to be used for this Menu. **/ - alignment: Object; + alignment: string; /** * Gets or sets the default anchor to be used for this Menu. @@ -5561,7 +5562,7 @@ declare module WinJS.UI { /** * Gets or sets the default placement to be used for this Menu. **/ - placement: Object; + placement: string; //#endregion Properties @@ -5579,7 +5580,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new MenuCommand. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -5676,7 +5677,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the new NavBar. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -5730,7 +5731,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this NavBar. Call this method when the NavBar is no longer needed. After calling this method, the NavBar becomes unusable. @@ -5747,7 +5748,7 @@ declare module WinJS.UI { * @param commands The commands to hide. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: Object[], immediate: boolean): void; + hideCommands(commands: any[], immediate: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -5767,14 +5768,14 @@ declare module WinJS.UI { * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: Object[], immediate: boolean): void; + showCommands(commands: any[], immediate: boolean): void; /** * Shows the specified commands of the NavBar while hiding all other commands. * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: Object[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate: boolean): void; //#endregion Methods @@ -5831,7 +5832,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new NavBarCommand. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -5851,7 +5852,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this NavBarCommand. Call this method when the NavBarCommand is no longer needed. After calling this method, the NavBarCommand becomes unusable. @@ -5888,7 +5889,7 @@ declare module WinJS.UI { /** * Get or sets the location to navigate to when this command is invoked. **/ - location: Object; + location: any; /** * Gets or sets a value that specifies whether to show the split tab stop. @@ -5903,7 +5904,7 @@ declare module WinJS.UI { /** * Gets or sets a user-defined object that represents the state associated with the command's location. **/ - state: Object; + state: any; /** * Gets or sets the tooltip of the command. @@ -5926,7 +5927,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new NavBarContainer. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: Object, options: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -5962,7 +5963,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this NavBarCommand. Call this method when the NavBarCommand is no longer needed. After calling this method, the NavBarCommand becomes unusable. @@ -6037,7 +6038,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new Rating. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -6140,7 +6141,7 @@ declare module WinJS.UI { * @constructor * @param options An object that contains one or more property/value pairs to apply to the new Repeater. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ - constructor(options?: Object); + constructor(options?: any); //#endregion Constructors @@ -6230,7 +6231,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this Repeater. Call this method when the Repeater is no longer needed. After calling this method, the Repeater becomes unusable. @@ -6259,7 +6260,7 @@ declare module WinJS.UI { /** * Gets or sets the List that provides the Repeater with items to display. **/ - data: WinJS.Binding.List; + data: WinJS.Binding.List; /** * Gets the DOM element that hosts the Repeater. @@ -6292,7 +6293,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new SearchBox. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: Object, options: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -6346,7 +6347,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this SearchBox. Call this method when the SearchBox is no longer needed. After calling this method, the SearchBox becomes unusable. @@ -6427,7 +6428,7 @@ declare module WinJS.UI { * @param element The DOM element that hosts the SemanticZoom. * @param options An object that contains one or more property/value pairs to apply to the new control. This object can contain these properties: initiallyZoomedOut Boolean, zoomFactor 0.2–0.85. **/ - constructor(element: HTMLElement, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -6457,7 +6458,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this SemanticZoom. Call this method when the SemanticZoom is no longer needed. After calling this method, the SemanticZoom becomes unusable. @@ -6527,7 +6528,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new SettingsFlyout. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -6575,7 +6576,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this SettingsFlyout. Call this method when the SettingsFlyout is no longer needed. After calling this method, the SettingsFlyout becomes unusable. @@ -6611,7 +6612,7 @@ declare module WinJS.UI { * @param id The ID of the Settings element. * @param path The path of the page that contains the Settings element. **/ - showSettings(id: string, path: Object): void; + showSettings(id: string, path: any): void; //#endregion Methods @@ -6645,6 +6646,18 @@ declare module WinJS.UI { * A type of IListDataSource that provides read-access to an object that implements the IStorageQueryResultBase interface. A StorageDataSource enables you to query and bind to items in the data source. **/ class StorageDataSource { + //#region Constructors + + /** + * Creates a new StorageDataSource object. + * @constructor + * @param query The IStorageQueryResultBase that the StorageDataSource obtains its items from. Instead of IStorageQueryResultBase, you can also pass one of these string values: Music, Pictures, Videos, Documents. + * @param options The set of properties and values to apply to the new StorageDataSource. Properties on this object may include: mode , requestedThumbnailSize , thumbnailOptions , synchronous . + **/ + constructor(query: Windows.Storage.Search.IStorageQueryResultBase, options?: any); + + //#endregion Constructors + //#region Methods /** @@ -6655,13 +6668,6 @@ declare module WinJS.UI { **/ loadThumbnail(item: IItem, image: HTMLElement): Promise; - /** - * Creates a new StorageDataSource object. - * @param query The IStorageQueryResultBase that the StorageDataSource obtains its items from. Instead of IStorageQueryResultBase, you can also pass one of these string values: Music, Pictures, Videos, Documents. - * @param options The set of properties and values to apply to the new StorageDataSource. Properties on this object may include: mode , requestedThumbnailSize , thumbnailOptions , synchronous . - **/ - StorageDataSource(query: Windows.Storage.Search.IStorageQueryResultBase, options: Object): void; - //#endregion Methods } @@ -6678,7 +6684,7 @@ declare module WinJS.UI { * @param element The DOM element that hosts the TabContainer control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties. **/ - constructor(element: Object, options?: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -6719,7 +6725,7 @@ declare module WinJS.UI { * @param element The DOM element associated with the TimePicker control. * @param options The set of options to be applied initially to the TimePicker control. The options are the following: clock. **/ - constructor(element: HTMLElement, options: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -6749,7 +6755,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this TimePicker. Call this method when the TimePicker is no longer needed. After calling this method, the TimePicker becomes unusable. @@ -6762,7 +6768,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - raiseEvent(type: string, eventProperties: Object): boolean; + raiseEvent(type: string, eventProperties: any): boolean; /** * Removes a listener for the specified event. @@ -6770,7 +6776,7 @@ declare module WinJS.UI { * @param listener The listener. * @param useCapture Optional. The same value that was passed to addEventListener for this listener. It may be omitted if it was omitted when calling addEventListener. **/ - removeEventListener(type: string, listener: Function, useCapture?: Object): void; + removeEventListener(type: string, listener: Function, useCapture?: any): void; //#endregion Methods @@ -6832,7 +6838,7 @@ declare module WinJS.UI { * @param element The DOM that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the change event, add a property named "onchange" to the options object and set its value to the event handler. **/ - constructor(element: Object, options: Object); + constructor(element: HTMLElement, options?: any); //#endregion Constructors @@ -6862,7 +6868,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Releases resources held by this ToggleSwitch. Call this method when the ToggleSwitch is no longer needed. After calling this method, the ToggleSwitch becomes unusable. @@ -6881,7 +6887,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - raiseEvent(type: string, eventProperties: Object): boolean; + raiseEvent(type: string, eventProperties: any): boolean; /** * Removes an event handler that the addEventListener method registered. @@ -6933,6 +6939,18 @@ declare module WinJS.UI { * Displays a tooltip that can contain images and formatting. **/ class Tooltip { + //#region Constructors + + /** + * Creates a new Tooltip. + * @constructor + * @param element The DOM element associated that hosts the Tooltip. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the opened event, add a property named "onopened" to the options object and set its value to the event handler. + **/ + constructor(element: HTMLElement, options?: any); + + //#endregion Constructors + //#region Events /** @@ -6995,13 +7013,6 @@ declare module WinJS.UI { **/ removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; - /** - * Creates a new Tooltip. - * @param element The DOM element associated that hosts the Tooltip. - * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the opened event, add a property named "onopened" to the options object and set its value to the event handler. - **/ - Tooltip(element: Object, options: Object): void; - //#endregion Methods //#region Properties @@ -7044,6 +7055,18 @@ declare module WinJS.UI { * Scales a single child element to fill the available space without resizing it. This control reacts to changes in the size of the container as well as changes in size of the child element. For example, a media query may result in a change in aspect ratio. **/ class ViewBox { + //#region Constructors + + /** + * Initializes a new instance of the ViewBox control. + * @constructor + * @param element The DOM element that functions as the scaling box. This element fills 100% of the width and height allotted to it. + * @param options The set of options to be applied initially to the ViewBox control. There are currently no options on this control, and any options included in this parameter are ignored. + **/ + constructor(element: HTMLElement, options?: any); + + //#endregion Constructors + //#region Methods /** @@ -7072,13 +7095,6 @@ declare module WinJS.UI { **/ removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; - /** - * Initializes a new instance of the ViewBox control. - * @param element The DOM element that functions as the scaling box. This element fills 100% of the width and height allotted to it. - * @param options The set of options to be applied initially to the ViewBox control. There are currently no options on this control, and any options included in this parameter are ignored. - **/ - ViewBox(element: HTMLElement, options: Object): void; - //#endregion Methods //#region Properties @@ -7086,7 +7102,7 @@ declare module WinJS.UI { /** * Gets the DOM element that functions as the scaling box. **/ - element: Object; + element: HTMLElement; //#endregion Properties @@ -7104,7 +7120,7 @@ declare module WinJS.UI { * @param listDataAdapter The object that supplies data to the VirtualizedDataSource. * @param options An object that can contain properties that specify additional options for the VirtualizedDataSource. It supports these properties: cacheSize. **/ - constructor(listDataAdapter: IListDataAdapter, options?: Object); + constructor(listDataAdapter: IListDataAdapter, options?: any); //#endregion Constructors @@ -7134,7 +7150,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Removes an event handler that the addEventListener method registered. @@ -7160,7 +7176,7 @@ declare module WinJS.UI { * @param options An object that can contain properties that specify additional options: groupCountEstimate, batchSize. * @returns An IListDataSource that contains the items in the original data source and provides additional group information in the form of a "groups" property. The "groups" property returns another IListDataSource that enumerates the different groups in the list. **/ - function computeDataSourceGroups(listDataSource: IListDataSource, groupKey: Function, groupData: Function, options?: Object): IListDataSource; + function computeDataSourceGroups(listDataSource: IListDataSource, groupKey: Function, groupData: Function, options?: any): IListDataSource; /** * Used to disables all Animations Library and ListView animations. Calling this function does not guarantee that the animations will be disabled, as the determination is made based on several factors. @@ -7177,7 +7193,7 @@ declare module WinJS.UI { * @param handler The handler to be marked as compatible with declarative processing. * @returns The handler, marked as compatible with declarative processing. **/ - function eventHandler(handler: Object): Object; + function eventHandler(handler: any): any; /** * Asynchronously executes a collection of CSS animations on a collection of elements. This is the underlying animation mechanism used by the Animations Library. Apps are encouraged to use the Animations Library to conform with the standard look and feel of the rest of the system, rather than calling this function directly. @@ -7185,7 +7201,7 @@ declare module WinJS.UI { * @param animation The animation description or an array of animation descriptions to apply to element. An animation description is a JavaScript object with specific properties, listed below. There are two types of animation descriptions: one for keyframe-based animations and one for explicit animations. These types are distinguished by whether the keyframe property has a defined value. The following properties are required for both types of animation descriptions: property (string), delay (number), duration (number), timing (string). If an animation has a keyframe property with a defined, non-null value, then the animation is a keyframe-based animation. A keyframe-based animation description requires the following property in addition to those mentioned above: keyframe (string). If an animation does not have a keyframe property, or if the value of the property is null or undefined, then the animation is an explicit animation. An explicit animation description requires the following properties in addition to the common properties mentioned above: from, to. The values given in the from and to properties must be valid for the CSS property specified by the property property. For example, if the CSS property is "opacity", then the from and to properties must be numbers between 0 and 1 (inclusive). * @returns Returns a Promise object that completes when the CSS animation is complete. **/ - function executeAnimation(element: Object, animation: Object): Promise; + function executeAnimation(element: HTMLElement, animation: any): Promise; /** * Asynchronously executes a collection of CSS transitions on a collection of elements. This is the underlying animation mechanism used by the Animations Library. Apps are encouraged to use the Animations Library to conform with the standard look and feel of the rest of the system, rather than calling this function directly. @@ -7193,7 +7209,7 @@ declare module WinJS.UI { * @param transition The transition description or an array of transition descriptions to apply to element. A transition description is a JavaScript object with these properties: property (string), delay (number), duration (number), timing (string), from (optional), to. The values given in the from and to properties must be valid for the CSS property specified by the property property. For example, if the CSS property is "opacity", then the from and to properties must be numbers between 0 and 1 (inclusive). * @returns Returns a Promise that completes when the transition is finished. **/ - function executeTransition(element: Object, transition: Object): Promise; + function executeTransition(element: HTMLElement, transition: any): Promise; /** * Retrieves the items in the specified index range. @@ -7213,7 +7229,7 @@ declare module WinJS.UI { * Applies declarative control binding to all elements, starting at the specified root element. * @param rootElement The element at which to start applying the binding. If this parameter is not specified, the binding is applied to the entire document. **/ - function processAll(rootElement: Element): void; + function processAll(rootElement?: Element): void; /** * Applies declarative control binding to the specified element. @@ -7234,14 +7250,14 @@ declare module WinJS.UI { * @param element Element to associate with the control. * @param control The control to attach to the element. **/ - function setControl(element: HTMLElement, control: Object): void; + function setControl(element: HTMLElement, control: any): void; /** * Adds the set of declaratively specified options (properties and events) to the specified control. If name of the options property begins with "on", the property value is a function and the control supports addEventListener. setControl calls addEventListener on the control. * @param control The control on which the properties and events are to be applied. * @param options The set of options that are specified declaratively. **/ - function setOptions(control: Object, options: Object): void; + function setOptions(control: any, options?: any): void; //#endregion Functions @@ -7257,7 +7273,7 @@ declare module WinJS.UI.Fragments { * @param href The URI that contains the fragment to be copied. * @returns A promise that is fulfilled when the fragment has been prepared for copying. **/ - function cache(href: string): Promise; + function cache(href: string): Promise; /** * Removes any cached information about the specified fragment. This method does not unload any scripts or styles that are referenced by the fragment. @@ -7301,7 +7317,7 @@ declare module WinJS.UI.Pages { * @param err The error that occurred. * @returns Nothing if the error was handled, or an error promise if the error was not handled. **/ - error?(err: Object): Promise; + error?(err: any): Promise; /** * Initializes the control before the content of the control is set. Use the processed method for any initialization that should be done after the content of the control has been set. @@ -7309,14 +7325,14 @@ declare module WinJS.UI.Pages { * @param options The options passed to the constructor of the page. * @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing. **/ - init?(element: HTMLElement, options: Object): Promise; + init?(element: HTMLElement, options?: any): Promise; /** * Creates DOM objects from the content in the specified URI. This method is called after the PageControl is defined and before the init method is called. * @param uri The URI from which to create DOM objects. * @returns A promise whose fulfilled value is the set of unparented DOM objects. **/ - load?(uri: string): Promise; + load?(uri: string): Promise; /** * Initializes the control after the content of the control is set. @@ -7324,7 +7340,7 @@ declare module WinJS.UI.Pages { * @param options The options that are to be passed to the constructor of the page. * @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing. **/ - processed?(element: HTMLElement, options: Object): Promise; + processed?(element: HTMLElement, options?: any): Promise; /** * Called after all initialization and rendering is complete. At this time, the element is ready for use. @@ -7332,7 +7348,7 @@ declare module WinJS.UI.Pages { * @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl. * @returns A promise that is fulfilled when the element is ready for use, if asynchronous processing is necessary. If not, returns nothing. **/ - ready?(element: HTMLElement, options: Object): Promise; + ready?(element: HTMLElement, options?: any): Promise; /** * Takes the elements returned by the load method and attaches them to the specified element. @@ -7340,7 +7356,7 @@ declare module WinJS.UI.Pages { * @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl. * @param loadResult A Promise that contains the elements returned from the load method. **/ - render?(element: HTMLElement, options: Object, loadResult: Promise): void; + render?(element: HTMLElement, options: any, loadResult: Promise): void; //#endregion Methods @@ -7383,7 +7399,7 @@ declare module WinJS.UI.Pages { * @param parentedPromise A Promise that is fulfilled when the new PageControl is done rendering and its contents becomes the child of element. * @returns A promise that is fulfilled when rendering is complete, if asynchronous processing is necessary. If not, returns nothing. **/ - function render(uri: string, element: HTMLElement, options?: Object, parentedPromise?: Promise): Promise; + function render(uri: string, element: HTMLElement, options?: any, parentedPromise?: Promise): Promise; //#endregion Functions @@ -7850,7 +7866,7 @@ declare module WinJS.Utilities { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event. **/ - dispatchEvent(type: string, eventProperties: Object): boolean; + dispatchEvent(type: string, eventProperties: any): boolean; /** * Removes an event listener from the control. @@ -7908,7 +7924,7 @@ declare module WinJS.Utilities { * @param options The options passed to the newly-created controls. * @returns This QueryCollection object. **/ - control(ctor: any, options?: Object): QueryCollection; + control(ctor: any, options?: any): QueryCollection; /** * Performs an action on each item in the QueryCollection. @@ -7916,7 +7932,7 @@ declare module WinJS.Utilities { * @param thisArg The argument to bind to callbackFn. * @returns The QueryCollection. **/ - forEach(callbackFn: (value: T, index: number, array: T[]) => void, thisArg?: Object): QueryCollection; + forEach(callbackFn: (value: T, index: number, array: T[]) => void, thisArg?: any): QueryCollection; /** * Gets an item from the QueryCollection. @@ -7930,7 +7946,7 @@ declare module WinJS.Utilities { * @param name The name of the attribute. * @returns The value of the attribute. **/ - getAttribute(name: string): Object; + getAttribute(name: string): any; /** * Determines whether the specified class exists on the first element of the collection. @@ -7995,7 +8011,7 @@ declare module WinJS.Utilities { * @param value The value of the attribute to be set. * @returns This QueryCollection object. **/ - setAttribute(name: string, value: Object): QueryCollection; + setAttribute(name: string, value: any): QueryCollection; /** * Sets the specified style property for all the elements in the collection. @@ -8003,7 +8019,7 @@ declare module WinJS.Utilities { * @param value The value for the property. * @returns This QueryCollection object. **/ - setStyle(name: string, value: Object): QueryCollection; + setStyle(name: string, value: any): QueryCollection; /** * Renders a template that is bound to the given data and parented to the elements included in the QueryCollection. If the QueryCollection contains multiple elements, the template is rendered multiple times, once at each element in the QueryCollection per item of data passed. @@ -8012,7 +8028,7 @@ declare module WinJS.Utilities { * @param renderDonePromiseCallback If supplied, this function is called each time the template gets rendered, and is passed a promise that is fulfilled when the template rendering is complete. * @returns The QueryCollection. **/ - template(templateElement: HTMLElement, data: Object, renderDonePromiseCallback: Function): QueryCollection; + template(templateElement: HTMLElement, data: any, renderDonePromiseCallback: Function): QueryCollection; /** * Toggles (adds or removes) the specified class on all the elements in the collection. If the class is present, it is removed; if it is absent, it is added. @@ -8057,14 +8073,14 @@ declare module WinJS.Utilities { * @param events A variable list of property names. * @returns The object with the specified properties. The names of the properties are prefixed with 'on'. **/ - function createEventProperties(...events: string[]): Object; + function createEventProperties(...events: string[]): any; /** * Gets the data value associated with the specified element. * @param element The element. * @returns The value associated with the element. **/ - function data(element: HTMLElement): Object; + function data(element: HTMLElement): any; /** * Disposes all first-generation disposable elements that are descendents of the specified element. The specified element itself is not disposed. @@ -8116,7 +8132,7 @@ declare module WinJS.Utilities { * @param root The root to start in. Defaults to the global object. * @returns The leaf-level type or namespace in the specified parent namespace. **/ - function getMember(name: string, root: Object): Object; + function getMember(name: string, root?: any): any; /** * Gets the position of the specified element. @@ -8198,7 +8214,7 @@ declare module WinJS.Utilities { * @param func The function to be marked as compatible with declarative processing. * @returns The input function, marked as compatible with declarative processing. **/ - function markSupportedForProcessing(func: Function): Function; + function markSupportedForProcessing(func: U): U; /** * Returns a QueryCollection with zero or one elements matching the specified selector query. @@ -8214,7 +8230,7 @@ declare module WinJS.Utilities { * @param async If true, the callback should be executed asynchronously. * @returns A promise that completes after the DOMContentLoaded event has occurred. **/ - function ready(callback?: Function, async?: boolean): Promise; + function ready(callback?: Function, async?: boolean): Promise; /** * Removes the specified class from the specified element. @@ -8229,7 +8245,7 @@ declare module WinJS.Utilities { * @param value The value to be tested for compatibility with declarative processing. If the value is a function it must be marked with a property supportedForProcessing with a value of true when strictProcessing is on. For more information, see WinJS.Utilities.markSupportedForProcessing. * @returns The input value. **/ - function requireSupportedForProcessing(value: Object): Object; + function requireSupportedForProcessing(value: any): any; /** * Sets the innerHTML property of the specified element to the specified text. @@ -8263,7 +8279,7 @@ declare module WinJS.Utilities { * Configures a logger that writes messages containing the specified tags to the JavaScript console. * @param options The tags for messages to log. Multiple tags should be separated by spaces. May contain type, tags, excludeTags and action properties. **/ - function startLog(options: Object): void; + function startLog(options?: any): void; /** * Removes the WinJS logger that had previously been set up. @@ -8400,7 +8416,7 @@ declare module WinJS.Utilities.Scheduler { * Uses a Promise to determine how long the scheduler should wait before rescheduling the job after it yields. * @param promise Once the work item yields, the scheduler will wait for this Promise to complete before rescheduling the job. **/ - setPromise(promise: Promise): void; + setPromise(promise: Promise): void; /** * Specifies the next unit of work to run once this job yields. @@ -8470,7 +8486,7 @@ declare module WinJS.Utilities.Scheduler { * @param name An optional description of the drain request for diagnostics. * @returns A Promise which completes when the drain has finished. Canceling this Promise cancels the drain request. This Promise will never enter an error state. **/ - function requestDrain(priority?: Priority, name?: string): Promise; + function requestDrain(priority?: Priority, name?: string): Promise; /** * Schedules the specified function to execute asynchronously. @@ -8480,7 +8496,7 @@ declare module WinJS.Utilities.Scheduler { * @param name A description of the work item for diagnostics. The default value is an empty string. * @returns The job instance that represents this work item. **/ - function schedule(work: (jobInfo: IJobInfo) => void, priority?: Priority, thisArg?: Object, name?: string): IJob; + function schedule(work: (jobInfo: IJobInfo) => void, priority?: Priority, thisArg?: any, name?: string): IJob; /** * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.aboveNormal priority. From bde65f741db7b65f08ef1f6a068081f5782f9a85 Mon Sep 17 00:00:00 2001 From: craigktreasure Date: Wed, 22 Jan 2014 21:19:08 -0800 Subject: [PATCH 038/240] Fixed the Page object. Generated pages don't play nicely with the optional options parameter. Made it required. --- winjs/winjs.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index fa31210649..c6a2958cdc 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -7325,7 +7325,7 @@ declare module WinJS.UI.Pages { * @param options The options passed to the constructor of the page. * @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing. **/ - init?(element: HTMLElement, options?: any): Promise; + init?(element: HTMLElement, options: any): Promise; /** * Creates DOM objects from the content in the specified URI. This method is called after the PageControl is defined and before the init method is called. @@ -7340,7 +7340,7 @@ declare module WinJS.UI.Pages { * @param options The options that are to be passed to the constructor of the page. * @returns A promise that is fulfilled when initialization is complete, if asynchronous processing is necessary. If not, returns nothing. **/ - processed?(element: HTMLElement, options?: any): Promise; + processed?(element: HTMLElement, options: any): Promise; /** * Called after all initialization and rendering is complete. At this time, the element is ready for use. @@ -7348,7 +7348,7 @@ declare module WinJS.UI.Pages { * @param options An object that contains one or more property/value pairs to apply to the PageControl. How these property/value pairs are used (or not used) depends on the implementation of that particular PageControl. * @returns A promise that is fulfilled when the element is ready for use, if asynchronous processing is necessary. If not, returns nothing. **/ - ready?(element: HTMLElement, options?: any): Promise; + ready?(element: HTMLElement, options: any): Promise; /** * Takes the elements returned by the load method and attaches them to the specified element. From 1050f83bf3a6cf6cc149be831bdc0455b2d105b4 Mon Sep 17 00:00:00 2001 From: dotnetnerd Date: Thu, 23 Jan 2014 15:14:28 +0100 Subject: [PATCH 039/240] added tests --- domready/domready-tests.ts | 5 +++++ ftdomdelegate/ftdomdelegate-tests.ts | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 domready/domready-tests.ts create mode 100644 ftdomdelegate/ftdomdelegate-tests.ts diff --git a/domready/domready-tests.ts b/domready/domready-tests.ts new file mode 100644 index 0000000000..7b7c40dfb8 --- /dev/null +++ b/domready/domready-tests.ts @@ -0,0 +1,5 @@ +/// + +domready(function () { + // dom is loaded! +}) \ No newline at end of file diff --git a/ftdomdelegate/ftdomdelegate-tests.ts b/ftdomdelegate/ftdomdelegate-tests.ts new file mode 100644 index 0000000000..7850422611 --- /dev/null +++ b/ftdomdelegate/ftdomdelegate-tests.ts @@ -0,0 +1,19 @@ +/// + +function handleButtonClicks(event) { + // Do some things +} + +function handleTouchMove(event) { + // Do some other things +} + +window.addEventListener('load', function() { + var delegate = new Delegate(document.body); + delegate.on('click', 'button', handleButtonClicks); + + // Listen to all touch move + // events that reach the body + delegate.on('touchmove', handleTouchMove); + +}, false); \ No newline at end of file From 9426f5677a424de81629d86447d447135a33eedb Mon Sep 17 00:00:00 2001 From: Sean Clark Hess Date: Thu, 23 Jan 2014 10:19:31 -0700 Subject: [PATCH 040/240] 0.9.5 changes to lodash, rethinkdb, and svgjs --- lodash/lodash.d.ts | 4 ++++ rethinkdb/rethinkdb.d.ts | 18 +++++++++++------- svgjs/svgjs.d.ts | 5 +++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 68ee4f8df1..97aeab757a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3825,3 +3825,7 @@ declare module _ { [index: string]: T; } } + +declare module "lodash" { + export = _; +} diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 002ee824c0..2c65a7cf4d 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -104,8 +104,8 @@ declare module "rethinkdb" { // Join // these return left, right - innerJoin(sequence:Sequence, join:ExpressionFunction):Sequence; - outerJoin(sequence:Sequence, join:ExpressionFunction):Sequence; + innerJoin(sequence:Sequence, join:JoinFunction):Sequence; + outerJoin(sequence:Sequence, join:JoinFunction):Sequence; eqJoin(leftAttribute:string, rightSequence:Sequence, index?:Index):Sequence; eqJoin(leftAttribute:ExpressionFunction, rightSequence:Sequence, index?:Index):Sequence; zip():Sequence; @@ -126,10 +126,10 @@ declare module "rethinkdb" { sample(n:number):Sequence; // Aggregate - reduce(r:Reduce, base?:any):Expression; + reduce(r:ReduceFunction, base?:any):Expression; count():Expression; distinct():Sequence; - groupedMapReduce(group:ExpressionFunction, map:ExpressionFunction, reduce:Reduce, base?:any):Sequence; + groupedMapReduce(group:ExpressionFunction, map:ExpressionFunction, reduce:ReduceFunction, base?:any):Sequence; groupBy(...aggregators:Aggregator[]):Expression; // TODO: reduction object contains(prop:string):Expression; @@ -139,11 +139,15 @@ declare module "rethinkdb" { } interface ExpressionFunction { - (...docs:Expression[]):Expression; + (doc:Expression):Expression; } - interface Reduce { - (acc:any, val:any):any; + interface JoinFunction { + (left:Expression, right:Expression):Expression; + } + + interface ReduceFunction { + (acc:Expression, val:Expression):Expression; } interface InsertOptions { diff --git a/svgjs/svgjs.d.ts b/svgjs/svgjs.d.ts index 8a3af1d684..5ff8303ff8 100644 --- a/svgjs/svgjs.d.ts +++ b/svgjs/svgjs.d.ts @@ -77,9 +77,10 @@ declare module svgjs { animate(duration?:number, ease?:string, delay?:number):Animation; animate(info:{ease?:string; duration?:number; delay?:number}):Animation; - attr(name:string, value:any, namespace?:string):Element; - attr(obj:Object):Element; attr(name:string):any; + attr(obj:Object):Element; + attr(name:string, value:any, namespace?:string):Element; + viewbox():Viewbox; viewbox(x:number, y:number, w:number, h:number):Element; viewbox(obj:Viewbox):Element; From 42f347283f82e02bd7c39047af2ead70dac6e67d Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Thu, 23 Jan 2014 14:44:50 -0500 Subject: [PATCH 041/240] Leaflet: fix default icon constructor This fix allows this code (which worked in an earlier version): var icon = new L.Icon.Default(); --- leaflet/leaflet.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 5462a8afb1..3044970b0c 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -991,9 +991,9 @@ declare module L { export class Default extends Icon { /** - * Creates an icon instance with default options. + * Creates a default icon instance with the given options. */ - constructor(options: IconOptions); + constructor(options?: IconOptions); static imagePath: string; } From 45aa4909630cba1fc8f01d6d4045ba0c60df5c73 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Thu, 23 Jan 2014 15:02:32 -0500 Subject: [PATCH 042/240] Create messenger.d.ts --- messenger/messenger.d.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 messenger/messenger.d.ts diff --git a/messenger/messenger.d.ts b/messenger/messenger.d.ts new file mode 100644 index 0000000000..b874eb356f --- /dev/null +++ b/messenger/messenger.d.ts @@ -0,0 +1,27 @@ +// Type definitions for Messenger.js 1.2.1 +// Project: https://github.com/HubSpot/messenger +// Definitions by: Derek Cicerone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface IMessenger { + (): Messenger; + options: MessengerOptions; +} + +interface Messenger { + post(message: Message): void; + hideAll(): void; +} + +interface Message { + message: string; + hideAfter?: number; + showCloseButton?: boolean; + type?: string; +} + +interface MessengerOptions { + theme?: string; +} + +declare var Messenger: IMessenger; From 6aa70b2cc5d12e24ea895ba699ef74c5eedfd8f2 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Thu, 23 Jan 2014 15:13:41 -0500 Subject: [PATCH 043/240] Add missing error-handling methods * also added the inspect method (https://github.com/cujojs/when/blob/master/docs/api.md#inspect) --- when/when.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/when/when.d.ts b/when/when.d.ts index dbf4050a0f..46a1a12ec7 100644 --- a/when/when.d.ts +++ b/when/when.d.ts @@ -55,11 +55,25 @@ declare module When { } interface Promise { + catch(onRejected?: (reason: any) => Promise): Promise; + catch(onRejected?: (reason: any) => U): Promise; + ensure(onFulfilledOrRejected: Function): Promise; + inspect(): Snapshot; + + otherwise(onRejected?: (reason: any) => Promise): Promise; + otherwise(onRejected?: (reason: any) => U): Promise; + then(onFulfilled: (value: T) => Promise, onRejected?: (reason: any) => Promise, onProgress?: (update: any) => void): Promise; then(onFulfilled: (value: T) => Promise, onRejected?: (reason: any) => U, onProgress?: (update: any) => void): Promise; then(onFulfilled: (value: T) => U, onRejected?: (reason: any) => Promise, onProgress?: (update: any) => void): Promise; then(onFulfilled: (value: T) => U, onRejected?: (reason: any) => U, onProgress?: (update: any) => void): Promise; } + + interface Snapshot { + state: string; + value?: T; + reason?: any; + } } From c400fcb443f0873e4db019c744f8dbf5ec8ba951 Mon Sep 17 00:00:00 2001 From: John Vilk Date: Thu, 23 Jan 2014 16:57:43 -0500 Subject: [PATCH 044/240] Fixing a bug on the 'opts' attribute on the first argument to grunt.util.spawn. The 'opts' property on ISpawnOptions specifies "Additional options for the Node.js child_process spawn method." according to http://gruntjs.com/api/grunt.util#grunt.util.spawn However, the previous typing incorrectly recursively typed this as ISpawnOptions. child_process.spawn takes different arguments from grunt.util.spawn. I have copied in the appropriate typing from node/node.d.ts, as it is not an exported interface type. A quick inspection of the grunt source verifies that this object is passed uninspected to child_process.spawn, so all are potentially relevant. --- gruntjs/gruntjs.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index 99eadf435b..f601ce4fb6 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -1155,7 +1155,13 @@ declare module grunt { /** * Additional options for the Node.js child_process spawn method. */ - opts?: ISpawnOptions + opts?: { + cwd?: string + stdio?: any + custom?: any + env?: any + detached?: boolean + } /** * If this value is set and an error occurs, it will be used as the value From 03eecbb6811e888db40a5afd7f50bea81825a9ec Mon Sep 17 00:00:00 2001 From: Bartvds Date: Fri, 24 Jan 2014 00:19:24 +0100 Subject: [PATCH 045/240] added/fixed headers e-i https://github.com/borisyankov/DefinitelyTyped/issues/1570 --- express-validator/express-validator.d.ts | 5 +++++ fabricjs/fabricjs.d.ts | 1 + filesystem/filesystem.d.ts | 2 +- firebase/firebase.d.ts | 2 +- flight/flight.d.ts | 8 ++++---- google.feeds/google.feed.api.d.ts | 5 +++-- google.visualization/google.visualization.d.ts | 7 ++++++- googlemaps/google.maps.d.ts | 5 +++++ greensock/greensock.d.ts | 6 +++++- highlightjs/highlightjs.d.ts | 11 ++++------- i18next/i18next.d.ts | 7 ++++--- ix.js/ix.d.ts | 1 + ix.js/l2o.d.ts | 3 ++- 13 files changed, 42 insertions(+), 21 deletions(-) diff --git a/express-validator/express-validator.d.ts b/express-validator/express-validator.d.ts index 4799dc0dda..5a1ba31b7e 100644 --- a/express-validator/express-validator.d.ts +++ b/express-validator/express-validator.d.ts @@ -1,3 +1,8 @@ +// Type definitions for express-validator +// Project: https://github.com/ctavan/express-validator +// Definitions by: Nathan Ridley +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped + declare module ExpressValidator { export interface ValidationError { msg: string; diff --git a/fabricjs/fabricjs.d.ts b/fabricjs/fabricjs.d.ts index 0982329ee0..80087caa6c 100644 --- a/fabricjs/fabricjs.d.ts +++ b/fabricjs/fabricjs.d.ts @@ -1,6 +1,7 @@ // Type definitions for FabricJS // Project: http://fabricjs.com/ // Definitions by: Oliver Klemencic +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped /* USAGE diff --git a/filesystem/filesystem.d.ts b/filesystem/filesystem.d.ts index 54cf27b1f6..d3447f162f 100644 --- a/filesystem/filesystem.d.ts +++ b/filesystem/filesystem.d.ts @@ -1,4 +1,4 @@ -// Type Definitions for File API: Directories and System (File System API) +// Type Definitions for File System API // Project: http://www.w3.org/TR/file-system-api/ // Definitions by: Kon // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/firebase/firebase.d.ts b/firebase/firebase.d.ts index 901ad87baa..83f9ca84bf 100644 --- a/firebase/firebase.d.ts +++ b/firebase/firebase.d.ts @@ -1,5 +1,5 @@ // Type definitions for Firebase API -// Project: https://www.firebase.com/docs/javascript/firebase/index.html +// Project: https://www.firebase.com/docs/javascript/firebase // Definitions by: Vincent Botone // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/flight/flight.d.ts b/flight/flight.d.ts index a56981b1ca..e0eab6ada4 100644 --- a/flight/flight.d.ts +++ b/flight/flight.d.ts @@ -1,10 +1,10 @@ -/// - -// Type definitions for Flight 1.1.1 +// Type definitions for Flight 1.1.1 // Project: http://flightjs.github.com/flight/ // Definitions by: Jonathan Hedrén // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Flight { export interface Base { @@ -235,4 +235,4 @@ declare module Flight { } declare var DEBUG: Flight.DebugStatic; -declare var flight: Flight.FlightStatic; \ No newline at end of file +declare var flight: Flight.FlightStatic; diff --git a/google.feeds/google.feed.api.d.ts b/google.feeds/google.feed.api.d.ts index 0db17b3ca0..4db5a2f75a 100644 --- a/google.feeds/google.feed.api.d.ts +++ b/google.feeds/google.feed.api.d.ts @@ -1,6 +1,7 @@ -//Project Google Feed Apis +// Type definitions for Google Feed Apis // Project: https://developers.google.com/feed/ -// Definitions by: https://github.com/RodneyJT +// Definitions by: RodneyJT +// Definitions: https://github.com/borisyankov/DefinitelyTyped declare module google.feeds { export class feed { diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts index a08f739976..d478cf9aa6 100644 --- a/google.visualization/google.visualization.d.ts +++ b/google.visualization/google.visualization.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Google Visualisation Apis +// Project: https://developers.google.com/chart/ +// Definitions by: Dan Ludwig +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module google { function load(visualization: string, version: string, packages: any): void; @@ -468,4 +473,4 @@ declare module google { //#endregion } -} \ No newline at end of file +} diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index 3be446e19d..1ba6839b8e 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Google Geolocation 0.4.8 +// Project: https://developers.google.com/maps/ +// Definitions by: Folia A/S +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* The MIT License diff --git a/greensock/greensock.d.ts b/greensock/greensock.d.ts index ce0a2b6e1d..455b28052a 100644 --- a/greensock/greensock.d.ts +++ b/greensock/greensock.d.ts @@ -1,4 +1,8 @@ -// GreenSock Animation Platform (GSAP) - http://www.greensock.com/get-started-js/ +// Type definitions for GreenSock Animation Platform 1.1 +// Project: http://www.greensock.com/get-started-js/ +// Definitions by: Robert S +// Definitions: https://github.com/borisyankov/DefinitelyTyped + // JavaScript Docs http://api.greensock.com/js/ // Version 1.1 (TypeScript 0.9) diff --git a/highlightjs/highlightjs.d.ts b/highlightjs/highlightjs.d.ts index 04ffde1061..9e3567cdb9 100644 --- a/highlightjs/highlightjs.d.ts +++ b/highlightjs/highlightjs.d.ts @@ -1,10 +1,7 @@ -/* - highlight.js definition by Niklas Mollenhauer - Last Update: 10.09.2013 - Source Code: https://github.com/isagalaev/highlight.js - Project Page: http://softwaremaniacs.org/soft/highlight/en/ -*/ - +// Type definitions for highlight.js +// Project: https://github.com/isagalaev/highlight.js +// Definitions by: Niklas Mollenhauer +// Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "highlight.js" { module hljs diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 5fd6310304..6fabcce447 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -1,11 +1,12 @@ -/// - // Type definitions for i18next (v1.5.10 incl. jQuery) // Project: http://i18next.com -// Sources: https://github.com/jamuhl/i18next/ // Definitions by: Maarten Docter - Blog: http://www.maartendocter.nl // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Sources: https://github.com/jamuhl/i18next/ + +/// + interface IResourceStore { [language: string]: IResourceStoreLanguage; } diff --git a/ix.js/ix.d.ts b/ix.js/ix.d.ts index 8de0366e71..ebd5b160b4 100644 --- a/ix.js/ix.d.ts +++ b/ix.js/ix.d.ts @@ -1,6 +1,7 @@ // Type definitions for IxJS 1.0.6 / ix.js // Project: https://github.com/Reactive-Extensions/IxJS // Definitions by: Igor Oleinikov +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// diff --git a/ix.js/l2o.d.ts b/ix.js/l2o.d.ts index d36cb25304..ed53502226 100644 --- a/ix.js/l2o.d.ts +++ b/ix.js/l2o.d.ts @@ -1,6 +1,7 @@ // Type definitions for IxJS 1.0.6 / l2o.js // Project: https://github.com/Reactive-Extensions/IxJS // Definitions by: Igor Oleinikov +// Definitions: https://github.com/borisyankov/DefinitelyTyped declare module Ix { export interface Disposable { @@ -247,4 +248,4 @@ declare module Ix { } var Enumerable: EnumerableStatic; -} \ No newline at end of file +} From 0efeed5c4520348fd841bc2129ce064b705428b3 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Thu, 23 Jan 2014 23:50:00 +0100 Subject: [PATCH 046/240] added/fixed headers a-d https://github.com/borisyankov/DefinitelyTyped/issues/1570 --- amcharts/AmCharts.d.ts | 9 +++++++-- .../AzureMobileServicesClient.d.ts | 2 +- backbone-relational/backbone-relational.d.ts | 4 ++-- bgiframe/typescript.bgiframe.d.ts | 4 ++-- bootstrap.paginator/bootstrap.paginator.d.ts | 7 ++++++- bootstrap.timepicker/bootstrap.timepicker.d.ts | 7 +++++-- box2d/box2dweb.d.ts | 5 +++++ breeze/breeze.d.ts | 4 +--- codemirror/codemirror.d.ts | 5 +++++ cometd/cometd.d.ts | 1 + cryptojs/cryptojs.d.ts | 3 +-- d3/d3.d.ts | 2 +- dropzone/dropzone.d.ts | 3 ++- durandal/durandal.d.ts | 7 ++++++- 14 files changed, 45 insertions(+), 18 deletions(-) diff --git a/amcharts/AmCharts.d.ts b/amcharts/AmCharts.d.ts index 6004030eaf..3012b2a0ae 100644 --- a/amcharts/AmCharts.d.ts +++ b/amcharts/AmCharts.d.ts @@ -1,4 +1,9 @@ -/// AmCharts object (it's not a class) is create automatically when amcharts.js or amstock.js file is included in a web page. +// Type definitions for amCharts +// Project: http://www.amcharts.com/ +// Definitions by: aleksey-bykov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// AmCharts object (it's not a class) is create automatically when amcharts.js or amstock.js file is included in a web page. declare module AmCharts { /** Set it to true if you have base href set for your page. This will fix rendering problems in Firefox caused by base href. */ @@ -2340,4 +2345,4 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Removes event listener from chart object. */ removeListener(chart: AmChart, type: string, handler: any); } -} \ No newline at end of file +} diff --git a/azure-mobile-services-client/AzureMobileServicesClient.d.ts b/azure-mobile-services-client/AzureMobileServicesClient.d.ts index 0c022f7344..67c7bed727 100644 --- a/azure-mobile-services-client/AzureMobileServicesClient.d.ts +++ b/azure-mobile-services-client/AzureMobileServicesClient.d.ts @@ -1,5 +1,5 @@ // Type definitions for Microsoft.Windows.Azure.MobileService.Web-1.0.0 -// Project: https://.azure-mobile.net/client/MobileServices.Web-1.0.0.min.js +// Project: Microsoft Windows AzureMobile Service // Definitions by: Morosinotto Daniele // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/backbone-relational/backbone-relational.d.ts b/backbone-relational/backbone-relational.d.ts index fca37939e0..56dd2e9e83 100644 --- a/backbone-relational/backbone-relational.d.ts +++ b/backbone-relational/backbone-relational.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Backbone 0.8.5 +// Type definitions for Backbone-relational 0.8.5 // Project: http://backbonerelational.org/ // Definitions by: Eirik Hoem // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -165,4 +165,4 @@ declare module Backbone { } -} \ No newline at end of file +} diff --git a/bgiframe/typescript.bgiframe.d.ts b/bgiframe/typescript.bgiframe.d.ts index 1cb3897472..dfe4a7cc75 100644 --- a/bgiframe/typescript.bgiframe.d.ts +++ b/bgiframe/typescript.bgiframe.d.ts @@ -1,4 +1,4 @@ -// Type definitions for typescript.bgiframe 1.0 +// Type definitions for bgiframe 1.0 // Project: https://github.com/sumegizoltan/BgiFrame // Definitions by: Zoltan Sumegi // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -30,4 +30,4 @@ declare module BgiFrame { getIframe(element: HTMLElement): HTMLElement; prop(n: any): string; } -} \ No newline at end of file +} diff --git a/bootstrap.paginator/bootstrap.paginator.d.ts b/bootstrap.paginator/bootstrap.paginator.d.ts index fa530edd27..e45f1c3cec 100644 --- a/bootstrap.paginator/bootstrap.paginator.d.ts +++ b/bootstrap.paginator/bootstrap.paginator.d.ts @@ -1,3 +1,8 @@ +// Type definitions for bootstrap.paginator +// Project: https://github.com/lyonlai/bootstrap-paginator +// Definitions by: derikwhittaker +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /// interface PaginatorOptions{ @@ -20,4 +25,4 @@ interface PaginatorOptions{ interface JQuery { bootstrapPaginator(): JQuery; bootstrapPaginator(options: PaginatorOptions): JQuery; -} \ No newline at end of file +} diff --git a/bootstrap.timepicker/bootstrap.timepicker.d.ts b/bootstrap.timepicker/bootstrap.timepicker.d.ts index 8685882762..2dd80b8581 100644 --- a/bootstrap.timepicker/bootstrap.timepicker.d.ts +++ b/bootstrap.timepicker/bootstrap.timepicker.d.ts @@ -1,4 +1,7 @@ - +// Type definitions for bootstrap.timepicker +// Project: https://github.com/jdewit/bootstrap-timepicker +// Definitions by: derikwhittaker +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -21,4 +24,4 @@ interface JQuery { timepicker(methodName: string): JQuery; timepicker(methodName: string, params: any): JQuery; timepicker(options: TimeickerOptions): JQuery; -} \ No newline at end of file +} diff --git a/box2d/box2dweb.d.ts b/box2d/box2dweb.d.ts index b5f5579890..0f0576b433 100644 --- a/box2d/box2dweb.d.ts +++ b/box2d/box2dweb.d.ts @@ -1,3 +1,8 @@ +// Type definitions for bootstrap.timepicker +// Project: http://code.google.com/p/box2dweb/ +// Definitions by: jbaldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /** * Box2DWeb-2.1.d.ts Copyright (c) 2012-2013 Josh Baldwin http://github.com/jbaldwin/box2dweb.d.ts * There are a few competing javascript Box2D ports. diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 320f724adb..5a3abd9aa5 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -1,10 +1,8 @@ // Type definitions for Breeze 1.4 // Project: http://www.breezejs.com/ -// Definitions by: Boris Yankov , -// IdeaBlade +// Definitions by: Boris Yankov , IdeaBlade // Definitions: https://github.com/borisyankov/DefinitelyTyped - // Updated Jan 14 2011 - Jay Traband ( www.ideablade.com). // Updated March 27 2013 - John Lantz (www.ideablade.com). // Updated Aug 13 2013 - Steve Schmitt ( www.ideablade.com). diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 97568dbdcb..affee34583 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -1,3 +1,8 @@ +// Type definitions for CodeMirror +// Project: https://github.com/marijnh/CodeMirror +// Definitions by: mihailik +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare function CodeMirror(host: HTMLElement, options?: CodeMirror.EditorConfiguration): CodeMirror.Editor; declare function CodeMirror(callback: (host: HTMLElement) => void , options?: CodeMirror.EditorConfiguration): CodeMirror.Editor; diff --git a/cometd/cometd.d.ts b/cometd/cometd.d.ts index 6002fffb06..592c6c963d 100644 --- a/cometd/cometd.d.ts +++ b/cometd/cometd.d.ts @@ -1,5 +1,6 @@ // Type definitions for CometD 2.5.1 // Project: http://cometd.org +// Definitions by: Derek Cicerone // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module CometD { diff --git a/cryptojs/cryptojs.d.ts b/cryptojs/cryptojs.d.ts index c0773525ce..a12ef69e75 100644 --- a/cryptojs/cryptojs.d.ts +++ b/cryptojs/cryptojs.d.ts @@ -1,7 +1,6 @@ // Type definitions for CryptoJS 3.1.2 // Project: https://code.google.com/p/crypto-js/ -// Definitions by: -// Gia Bảo @ Sân Đình +// Definitions by: Gia Bảo @ Sân Đình // Definitions: https://github.com/borisyankov/DefinitelyTyped declare var CryptoJS: CryptoJS.CryptoJSStatic; diff --git a/d3/d3.d.ts b/d3/d3.d.ts index fe8887b7ed..ec3f94147c 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1,6 +1,6 @@ // Type definitions for d3JS // Project: http://d3js.org/ -// Definitions by: TypeScript samples +// Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module D3 { diff --git a/dropzone/dropzone.d.ts b/dropzone/dropzone.d.ts index f02b59f73f..ac630c9d4a 100644 --- a/dropzone/dropzone.d.ts +++ b/dropzone/dropzone.d.ts @@ -1,5 +1,6 @@ // Type definitions for Dropzone 3.7.1 // Project: http://www.dropzonejs.com/ +// Definitions by: Natan Vivo // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -74,4 +75,4 @@ declare class Dropzone { interface JQuery { dropzone(options: DropzoneOptions): Dropzone; -} \ No newline at end of file +} diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index c2567f62c5..b00508f2f0 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Durandal 2.0.1 +// Project: http://durandaljs.com +// Definitions by: Evan Larsen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /** * Durandal 2.0.1 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved. * Available via the MIT license. @@ -1656,4 +1661,4 @@ interface DurandalRootRouter extends DurandalRouterBase { * Installs the router's custom ko binding handler. */ install(): void; -} \ No newline at end of file +} From 333b89f8d3978aef3d0d8f066fca7ba7d3b1ce82 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Fri, 24 Jan 2014 00:44:14 +0100 Subject: [PATCH 047/240] added/fixed headers j https://github.com/borisyankov/DefinitelyTyped/issues/1570 jsfl: fixed odd encoding in comments --- jasmine/jasmine.d.ts | 2 +- jointjs/jointjs.d.ts | 4 ++-- jquery.address/jquery.address.d.ts | 4 ++-- jquery.colorbox/jquery.colorbox.d.ts | 6 +++--- jquery.gridster/gridster.d.ts | 7 ++++++- jquery.livestampjs/jquery.livestampjs.d.ts | 5 +++-- jquery.menuaim/jquery.menuaim.d.ts | 6 +++++- jquery.sortElements/jquery.sortElement.d.ts | 4 ++-- jquery/jquery.d.ts | 10 +++++----- jsfl/jsfl.d.ts | 19 ++++++++++++------- jsfl/xJSFL.d.ts | 5 +++++ jsoneditoronline/jsoneditoronline.d.ts | 5 +++-- jsplumb/jquery.jsPlumb.d.ts | 8 ++++---- jwplayer/jwplayer.d.ts | 3 ++- 14 files changed, 55 insertions(+), 33 deletions(-) diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index c3e95e4279..6eb0452308 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -1,6 +1,6 @@ // Type definitions for Jasmine 2.0 // Project: http://pivotal.github.com/jasmine/ -// Definitions by: Boris Yankov and Theodore Brown +// Definitions by: Boris Yankov , Theodore Brown // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index 88c67290c4..6dbdece13f 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -1,6 +1,6 @@ // Type definitions for Joint JS 0.6 // Project: http://www.jointjs.com/ -// Definitions by: Aidan Reel with help from David Durman +// Definitions by: Aidan Reel , David Durman // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -112,4 +112,4 @@ declare module joint { function deepMixin(objects: any[]): any; function deepSupplement(objects: any[], defaultIndicator?: any): any; } -} \ No newline at end of file +} diff --git a/jquery.address/jquery.address.d.ts b/jquery.address/jquery.address.d.ts index bd016d5b1e..cb71172457 100644 --- a/jquery.address/jquery.address.d.ts +++ b/jquery.address/jquery.address.d.ts @@ -1,10 +1,10 @@ -/// - // Type definitions for jQuery.Address 1.5 // Project: https://github.com/asual/jquery-address // Definitions by: Martin Duparc <@martinduparc> // Definitions: https://github.com/borisyankov/DefinitelyTyped/ +/// + interface JQueryAddressStatic { (); change(callback: any): void; diff --git a/jquery.colorbox/jquery.colorbox.d.ts b/jquery.colorbox/jquery.colorbox.d.ts index 164d47bb3b..1586af0ca7 100644 --- a/jquery.colorbox/jquery.colorbox.d.ts +++ b/jquery.colorbox/jquery.colorbox.d.ts @@ -1,10 +1,10 @@ -/// - -// Type definitions for jQuery.Colorbox 1.4.15 +// Type definitions for jQuery.Colorbox 1.4.15 // Project: http://www.jacklmoore.com/colorbox/ // Definitions by: Gidon Junge <@gjunge> // Definitions: https://github.com/borisyankov/DefinitelyTyped/ +/// + interface ColorboxResizeSettings { height?: number; innerHeight?: number; diff --git a/jquery.gridster/gridster.d.ts b/jquery.gridster/gridster.d.ts index 968c0f3330..b293dcb2fa 100644 --- a/jquery.gridster/gridster.d.ts +++ b/jquery.gridster/gridster.d.ts @@ -1,4 +1,9 @@ -/* +// Type definitions for jQuery.gridster 0.1.0 +// Project: https://github.com/jbaldwin/gridster +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* gridster-0.1.0.d.ts may be freely distributed under the MIT license. Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/gridster.d.ts diff --git a/jquery.livestampjs/jquery.livestampjs.d.ts b/jquery.livestampjs/jquery.livestampjs.d.ts index d460b888d4..d5a44c4192 100644 --- a/jquery.livestampjs/jquery.livestampjs.d.ts +++ b/jquery.livestampjs/jquery.livestampjs.d.ts @@ -1,9 +1,10 @@ // Type definitions for Livestamp.js -// A simple, unobtrusive jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements using Moment.js. // Project: http://http://mattbradley.github.com/livestampjs/ // Definitions by: Vincent Bortone // Definitions: https://github.com/borisyankov/DefinitelyTyped +// A simple, unobtrusive jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements using Moment.js. + /// /// @@ -24,4 +25,4 @@ interface JQuery { livestamp(moment: Moment): JQuery; livestamp(timestamp: number): JQuery; livestamp(timestamp: string): JQuery; -} \ No newline at end of file +} diff --git a/jquery.menuaim/jquery.menuaim.d.ts b/jquery.menuaim/jquery.menuaim.d.ts index 138adc65dc..54215620af 100644 --- a/jquery.menuaim/jquery.menuaim.d.ts +++ b/jquery.menuaim/jquery.menuaim.d.ts @@ -1,5 +1,9 @@ -/// +// Type definitions for jQuery-menu-aim +// Project: https://github.com/kamens/jQuery-menu-aim +// Definitions by: Robert Fonseca-Ensor +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// interface JQueryMenuAimOptions { /** Function to call when a row is purposefully activated. Use this diff --git a/jquery.sortElements/jquery.sortElement.d.ts b/jquery.sortElements/jquery.sortElement.d.ts index d558e023af..a9768fc972 100644 --- a/jquery.sortElements/jquery.sortElement.d.ts +++ b/jquery.sortElements/jquery.sortElement.d.ts @@ -1,4 +1,4 @@ -// Typescript type definitions for jQuery.sortElements by James Padolsey +// Type definitions for jQuery.sortElements // Project: http://james.padolsey.com/javascript/sorting-elements-with-jquery/ // Definitions by: Tim Bureck // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -7,4 +7,4 @@ interface JQuery { sortElements(comparator:Function, getSortable?:Function):JQuery; -} \ No newline at end of file +} diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 3c4220c153..a170155c65 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1,3 +1,8 @@ +// Typing for the jQuery library 1.10.x / 2.0.x +// Project: http://jquery.com/ +// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton, Diullei Gomes , Tass Iliopoulos , Jason Swearingen, Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use @@ -13,11 +18,6 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -// Typing for the jQuery library, version 1.10.x / 2.0.x -// Project: http://jquery.com/ -// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton, Diullei Gomes , Tass Iliopoulos , Jason Swearingen, Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly -// Definitions: https://github.com/borisyankov/DefinitelyTyped - /** * Interface for the AJAX setting that will configure the AJAX request */ diff --git a/jsfl/jsfl.d.ts b/jsfl/jsfl.d.ts index 94e3d4d80d..a8c9911d27 100644 --- a/jsfl/jsfl.d.ts +++ b/jsfl/jsfl.d.ts @@ -1,3 +1,8 @@ +// Type definitions for JSFL +// Project: https://adobe.com +// Definitions by: soywiz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + interface FlashPoint { x: number; y: number; @@ -169,7 +174,7 @@ interface FlashDocument { /** Exports the currently active profile to an XML */ exportPublishProfile(fileURI: string): void; - /** returns a string that specifies, in XML format, the specified profile. If you dont pass a value for profileName, the current profile is exported. */ + /** returns a string that specifies, in XML format, the specified profile. If you don't pass a value for profileName, the current profile is exported. */ exportPublishProfileString(profileName?: string): string; /** Exports the document in the Flash SWF format. */ @@ -1030,7 +1035,7 @@ interface FlashTimeline { /** Creates a new motion object at a designated start and end frame. */ createMotionObject(startFrameIndex?: number, endFrameIndex?: number): void; - /** Sets the frame.tweenType property to motion for each selected keyframe on the current layer, and converts each frames contents to a single symbol instance if necessary. */ + /** Sets the frame.tweenType property to motion for each selected keyframe on the current layer, and converts each frame's contents to a single symbol instance if necessary. */ createMotionTween(startFrameIndex?: number, endFrameIndex?: number): void; /** Cuts a range of frames on the current layer from the timeline and saves them to the clipboard. */ @@ -1051,13 +1056,13 @@ interface FlashTimeline { /** Finds an array of indexes for the layers with the given name. */ findLayerIndex(name: string): number[]; - /** Retrieves the specified propertys value for the selected frames. */ + /** Retrieves the specified property's value for the selected frames. */ getFrameProperty(property: string, startframeIndex?: number, endFrameIndex?: number): any; /** Returns an XML string that represents the current positions of the horizontal and vertical guide lines for a timeline(View > Guides > Show Guides). */ getGuidelines(): string; - /** Retrieves the specified propertys value for the selected layers. */ + /** Retrieves the specified property's value for the selected layers. */ getLayerProperty(property: string): any; /** Retrieves the currently selected frames in an array. */ @@ -1144,9 +1149,9 @@ interface FlashTimeline { } interface FlashPath { - /// Appends a cubic Bzier curve segment to the path. + /// Appends a cubic Bézier curve segment to the path. addCubicCurve(xAnchor: number, yAnchor: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void; - /// Appends a quadratic Bzier segment to the path. + /// Appends a quadratic Bézier segment to the path. addCurve(xAnchor: number, yAnchor: number, x2: number, y2: number, x3: number, y3: number): void; /// Adds a point to the path. addPoint(x: number, y: number): void; @@ -1396,4 +1401,4 @@ declare var fl: FlashFL; declare var FLfile: FlashFLfile; declare function alert(alertText: string): void; declare function confirm(strAlert: string): boolean; -declare function prompt(promptMsg: string, text?: string): string; \ No newline at end of file +declare function prompt(promptMsg: string, text?: string): string; diff --git a/jsfl/xJSFL.d.ts b/jsfl/xJSFL.d.ts index 7db97360b0..bc3af28c5e 100644 --- a/jsfl/xJSFL.d.ts +++ b/jsfl/xJSFL.d.ts @@ -1,3 +1,8 @@ +// Type definitions for xJSFL +// Project: http://www.xjsfl.com/ +// Definitions by: soywiz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /// interface _xjsfl { diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts index 64ce20bf1a..171fca2d53 100644 --- a/jsoneditoronline/jsoneditoronline.d.ts +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -1,9 +1,10 @@ // Type definitions for JSONEditorOnline -// JSON Editor Online is a tool to easily edit and format JSON online. JSON is displayed in a clear, editable treeview and in formatted plain text. // Project: https://github.com/josdejong/jsoneditoronline // Definitions by: Vincent Bortone // Definitions: https://github.com/borisyankov/DefinitelyTyped +// JSON Editor Online is a tool to easily edit and format JSON online. JSON is displayed in a clear, editable treeview and in formatted plain text. + interface JSONEditorOptions { change?: () => void; history?: boolean; @@ -177,4 +178,4 @@ declare class JSONFormatter { setText(jsonString: string): void; getText(): string; onError(err: string): void; -} \ No newline at end of file +} diff --git a/jsplumb/jquery.jsPlumb.d.ts b/jsplumb/jquery.jsPlumb.d.ts index 6561f2960a..ee657c2c2d 100644 --- a/jsplumb/jquery.jsPlumb.d.ts +++ b/jsplumb/jquery.jsPlumb.d.ts @@ -1,9 +1,9 @@ // Type definitions for jsPlumb 1.3.16 jQuery adapter. // Project: http://jsplumb.org -// https://github.com/sporritt/jsplumb -// https://code.google.com/p/jsplumb -// +// Project: https://github.com/sporritt/jsplumb +// Project: https://code.google.com/p/jsplumb // Definitions by: Steve Shearn +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -104,4 +104,4 @@ interface SelectParams { scope?: string; source: string; target: string; -} \ No newline at end of file +} diff --git a/jwplayer/jwplayer.d.ts b/jwplayer/jwplayer.d.ts index 2540ce9d1a..be4ab4fd36 100644 --- a/jwplayer/jwplayer.d.ts +++ b/jwplayer/jwplayer.d.ts @@ -1,9 +1,10 @@ // Type definitions for JW Player -// JW Player is the leading HTML5 & Flash video player, optimized for mobile and the desktop. Easy enough for beginners, advanced enough for pros. // Project: http://developer.longtailvideo.com/trac/ // Definitions by: Martin Duparc // Definitions: https://github.com/borisyankov/DefinitelyTyped +// JW Player is the leading HTML5 & Flash video player, optimized for mobile and the desktop. Easy enough for beginners, advanced enough for pros. + interface JWPlayer { addButton(icon: string, label: string, handler: () => void, id: string): void; getBuffer(): number; From f9df66c80dbedc8add942c3b8a5d97f877a7013a Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Thu, 23 Jan 2014 19:03:53 -0500 Subject: [PATCH 048/240] Create slick.headerbuttons.d.ts Headerbuttons is a SlickGrid plugin so I put it in the slickgrid directory: https://github.com/mleibman/SlickGrid/blob/master/plugins/slick.headerbuttons.js?source=cc --- slickgrid/slick.headerbuttons.d.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 slickgrid/slick.headerbuttons.d.ts diff --git a/slickgrid/slick.headerbuttons.d.ts b/slickgrid/slick.headerbuttons.d.ts new file mode 100644 index 0000000000..c4d928777f --- /dev/null +++ b/slickgrid/slick.headerbuttons.d.ts @@ -0,0 +1,27 @@ +declare module Slick { + + export interface Column { + header: Header; + } + + export interface Header { + buttons: HeaderButton[]; + } + + export interface HeaderButton { + command?: string; + cssClass?: string; + handler?: Function; + image?: string; + showOnHover?: boolean; + tooltip?: string; + } + + export module Plugins { + + export class HeaderButtons extends Plugin { + constructor(); + public onCommand: Slick.Event; + } + } +} From 6731dd1aec1c17183cf39aeeb7ecb688955d96b5 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Thu, 23 Jan 2014 19:07:01 -0500 Subject: [PATCH 049/240] Create jquery.color.d.ts --- jquery.color/jquery.color.d.ts | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 jquery.color/jquery.color.d.ts diff --git a/jquery.color/jquery.color.d.ts b/jquery.color/jquery.color.d.ts new file mode 100644 index 0000000000..427890a41d --- /dev/null +++ b/jquery.color/jquery.color.d.ts @@ -0,0 +1,64 @@ +// Type definitions for jquery.color.js v2.1.2 +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface JQueryColor { + /** + * Returns the alpha value of this color. + */ + alpha(): number; + + /** + * Returns the hexadecimal representation. + */ + toHexString(): string; + + /** + * Returns a CSS string like "rgba(255, 255, 255, 0.4)". + */ + toRgbaString(): string; + + /** + * The color distance (0.0 - 1.0) of the way between this color and othercolor. + */ + transition(othercolor: JQueryColor, distance: number): JQueryColor; + + /** + * Checks if two colors are equal. + */ + is(otherColor: JQueryColor): boolean; + + /** + * Returns the red component of the color (integer from 0 - 255). + */ + red(): number; + + /** + * Returns the green component of the color (integer from 0 - 255). + */ + green(): number; + + /** + * Returns the blue component of the color (integer from 0 - 255). + */ + blue(): number; +} + +interface HslaColor { + hue?: number; + saturation?: number; + lightness?: number; + alpha?: number; +} + +interface RgbaColor { + red?: number; + green?: number; + blue?: number; + alpha?: number; +} + +interface JQueryStatic { + Color(color: HslaColor): JQueryColor; + Color(color: RgbaColor): JQueryColor; + Color(color: string): JQueryColor; +} From b8e5189925133e00214566dfb9d77420be02f613 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 23 Jan 2014 16:08:20 -0800 Subject: [PATCH 050/240] Changing the context param to be OPTIONAL The compile function returns a template function. The template function takes two parameters, `context` and `options`. These are both optional parameters. This commit fixes `context` to be optional. --- handlebars/handlebars.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlebars/handlebars.d.ts b/handlebars/handlebars.d.ts index 28158031e5..ceff786637 100644 --- a/handlebars/handlebars.d.ts +++ b/handlebars/handlebars.d.ts @@ -16,7 +16,7 @@ interface HandlebarsStatic { parse(input: string): boolean; logger: Logger; log(level: number, obj: any): void; - compile(input: any, options?: any): (context: any, options?: any) => string; + compile(input: any, options?: any): (context?: any, options?: any) => string; Logger: typeof Logger; } From 5d95684e1945233cc59ae9b5254292cc37d39e92 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Fri, 24 Jan 2014 01:19:01 +0100 Subject: [PATCH 051/240] added/fixed headers k-n https://github.com/borisyankov/DefinitelyTyped/issues/1570 --- keyboardjs/keyboardjs.d.ts | 5 +++-- knockback/knockback.d.ts | 9 +++++++-- knockout.editables/ko.editables.d.ts | 9 +++++---- knockout.kogrid/ko-grid.d.ts | 5 +++-- knockout.projections/knockout.projections.d.ts | 1 + knockout.rx/knockout.rx.d.ts | 1 + linq/linq.3.0.3-Beta4.d.ts | 3 ++- linq/linq.jquery.d.ts | 1 + logg/logg.d.ts | 7 ++++++- mapsjs/mapsjs.d.ts | 5 +++++ moment/moment.d.ts | 5 ++--- mongodb/mongodb.d.ts | 9 ++++++--- ng-grid/ng-grid.d.ts | 4 ++-- node-azure/azure.d.ts | 2 +- node/node-0.8.8.d.ts | 4 ++++ node/node.d.ts | 4 ++++ nodemailer/nodemailer.d.ts | 3 ++- 17 files changed, 55 insertions(+), 22 deletions(-) diff --git a/keyboardjs/keyboardjs.d.ts b/keyboardjs/keyboardjs.d.ts index 150f0e3901..dfafd30a8a 100644 --- a/keyboardjs/keyboardjs.d.ts +++ b/keyboardjs/keyboardjs.d.ts @@ -1,9 +1,10 @@ // Type definitions for KeyboardJS -// A JavaScript library for binding keyboard combos without the pain of key codes and key combo conflicts. // Project: https://github.com/RobertWHurst/KeyboardJS // Definitions by: Vincent Bortone // Definitions: https://github.com/borisyankov/DefinitelyTyped +// A JavaScript library for binding keyboard combos without the pain of key codes and key combo conflicts. + interface KeyboardJSSubBinding { clear(): void; } @@ -46,4 +47,4 @@ interface KeyboardJSStatic { }; } -declare var KeyboardJS: KeyboardJSStatic; \ No newline at end of file +declare var KeyboardJS: KeyboardJSStatic; diff --git a/knockback/knockback.d.ts b/knockback/knockback.d.ts index 55657672eb..def3a398da 100644 --- a/knockback/knockback.d.ts +++ b/knockback/knockback.d.ts @@ -1,4 +1,9 @@ -/// +// Type definitions for Knockback.js +// Project: http://kmalakoff.github.io/knockback/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// /// declare module Knockback { @@ -215,4 +220,4 @@ declare module Knockback { } -declare var kb: Knockback.Static; \ No newline at end of file +declare var kb: Knockback.Static; diff --git a/knockout.editables/ko.editables.d.ts b/knockout.editables/ko.editables.d.ts index e072965b21..ca6ca73b0b 100644 --- a/knockout.editables/ko.editables.d.ts +++ b/knockout.editables/ko.editables.d.ts @@ -1,7 +1,8 @@ -/// +// Type definitions for knockout-editables 0.9 +// Project:http://romanych.github.com/ko.editables/ +// Definitions: https://github.com/borisyankov/DefinitelyTyped -// build: ko.editables 0.9 -// http://romanych.github.com/ko.editables/ +/// // bestowed by ko.editable(target) interface KnockoutEditable { @@ -27,4 +28,4 @@ interface KnockoutEditableStatic { // extend ko global interface KnockoutStatic { editable: KnockoutEditableStatic; -} \ No newline at end of file +} diff --git a/knockout.kogrid/ko-grid.d.ts b/knockout.kogrid/ko-grid.d.ts index c8d1b27c1c..2e5f255380 100644 --- a/knockout.kogrid/ko-grid.d.ts +++ b/knockout.kogrid/ko-grid.d.ts @@ -1,6 +1,7 @@ // Type definitions for ko-grid // Project: http://knockout-contrib.github.io/KoGrid/ -// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped +// Definitions by: huer12 +// Definitions: https://github.com/borisyankov/DefinitelyTyped // These are very definitely preliminary. Please feel free to improve. @@ -189,4 +190,4 @@ declare module kg { /** currentPage: the uhm... current page. */ currentPage?: number; } -} \ No newline at end of file +} diff --git a/knockout.projections/knockout.projections.d.ts b/knockout.projections/knockout.projections.d.ts index 5e85308a9d..77f3bf0ec8 100644 --- a/knockout.projections/knockout.projections.d.ts +++ b/knockout.projections/knockout.projections.d.ts @@ -1,6 +1,7 @@ // Type definitions for knockout-projections 1.0.0 // Project: https://github.com/stevesanderson/knockout-projections // Definitions by: John Reilly +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// diff --git a/knockout.rx/knockout.rx.d.ts b/knockout.rx/knockout.rx.d.ts index e9c85a7f80..2822b12f4f 100644 --- a/knockout.rx/knockout.rx.d.ts +++ b/knockout.rx/knockout.rx.d.ts @@ -1,6 +1,7 @@ // Type definitions for knockout.rx 0.1 // Project: https://github.com/Igorbek/knockout.rx // Definitions by: Igor Oleinikov +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// /// diff --git a/linq/linq.3.0.3-Beta4.d.ts b/linq/linq.3.0.3-Beta4.d.ts index 77c95d123f..d75d0982bc 100755 --- a/linq/linq.3.0.3-Beta4.d.ts +++ b/linq/linq.3.0.3-Beta4.d.ts @@ -1,6 +1,7 @@ // Type definitions for linq.js, ver 3.0.3-Beta4 // Project: http://linqjs.codeplex.com/ // Definitions by: neuecc (http://www.codeplex.com/site/users/view/neuecc) +// Definitions: https://github.com/borisyankov/DefinitelyTyped declare module linqjs { interface IEnumerator { @@ -192,4 +193,4 @@ declare module linqjs { } // export definition -declare var Enumerable: linqjs.EnumerableStatic; \ No newline at end of file +declare var Enumerable: linqjs.EnumerableStatic; diff --git a/linq/linq.jquery.d.ts b/linq/linq.jquery.d.ts index 896b53c5ae..c4b874baed 100755 --- a/linq/linq.jquery.d.ts +++ b/linq/linq.jquery.d.ts @@ -1,6 +1,7 @@ // Type definitions for linq.jquery (from linq.js) // Project: http://linqjs.codeplex.com/ // Definitions by: neuecc (http://www.codeplex.com/site/users/view/neuecc) +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// /// diff --git a/logg/logg.d.ts b/logg/logg.d.ts index a520c33df3..57ef3e4a8a 100644 --- a/logg/logg.d.ts +++ b/logg/logg.d.ts @@ -1,3 +1,8 @@ +// Type definitions for logg +// Project: https://github.com/dpup/node-logg +// Definitions by: Bret Little +// Definitions: https://github.com/borisyankov/DefinitelyTyped + interface Logger { setLogLevel: (level: number)=> void; getLogLevel: ()=> number; @@ -29,4 +34,4 @@ declare module "logg" { export var Level : loggingLevels; export var rootLogger: Logger; export var registerWatcher: (watcher: (logRecord: string)=> void)=> void; -} \ No newline at end of file +} diff --git a/mapsjs/mapsjs.d.ts b/mapsjs/mapsjs.d.ts index 29627eae92..46367fc500 100644 --- a/mapsjs/mapsjs.d.ts +++ b/mapsjs/mapsjs.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Mapsjs 9.6.0 +// Project: https://github.com/mapsjs +// Definitions by: Matthew James Davis +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /** * Mapsjs 9.6.0 Copyright (c) 2013 ISC. All Rights Reserved. */ diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 63e73d39a6..4bc63c8075 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -1,11 +1,10 @@ // Type definitions for Moment.js 2.5.0 // Project: https://github.com/timrwood/moment // Definitions by: Michael Lakerveld -// 2.4.0 Aaron King -// 2.5.0 Hiroki Horiuchi +// Definitions by: Aaron King (2.4.0) +// Definitions by: Hiroki Horiuchi (2.5.0) // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped - interface MomentInput { years?: number; y?: number; diff --git a/mongodb/mongodb.d.ts b/mongodb/mongodb.d.ts index 0275e1f878..cc2de59bed 100644 --- a/mongodb/mongodb.d.ts +++ b/mongodb/mongodb.d.ts @@ -1,6 +1,9 @@ -// Project : https://github.com/mongodb/node-mongodb-native -// Documentation : http://mongodb.github.io/node-mongodb-native/ +// Type definitions for MongoDB +// Project: https://github.com/mongodb/node-mongodb-native +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Documentation : http://mongodb.github.io/node-mongodb-native/ /// @@ -413,4 +416,4 @@ declare module "mongodb" { pkFactory?: any; readPreferences?: string; } -} \ No newline at end of file +} diff --git a/ng-grid/ng-grid.d.ts b/ng-grid/ng-grid.d.ts index bd23c047f7..48eec367a3 100644 --- a/ng-grid/ng-grid.d.ts +++ b/ng-grid/ng-grid.d.ts @@ -1,6 +1,6 @@ // Type definitions for ng-grid // Project: http://angular-ui.github.io/ng-grid/ -// Initial definitions by: Ken Smith +// Definitions by: Ken Smith // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped // These are very definitely preliminary. Please feel free to improve. @@ -188,4 +188,4 @@ declare module ngGrid { /** currentPage: the uhm... current page. */ currentPage?: number; } -} \ No newline at end of file +} diff --git a/node-azure/azure.d.ts b/node-azure/azure.d.ts index ed1b246e7f..0f16d9de87 100644 --- a/node-azure/azure.d.ts +++ b/node-azure/azure.d.ts @@ -1,6 +1,6 @@ // Type definitions for Azure SDK for Node - v0.6.10 // Project: https://github.com/WindowsAzure/azure-sdk-for-node -// Definitions by: Andrew Gaspar and Anti Veeranna +// Definitions by: Andrew Gaspar , Anti Veeranna // Definitions: https://github.com/borisyankov/DefinitelyTyped /// diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index f796dfb1c1..39f02a53a6 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -1,3 +1,7 @@ +// Type definitions for Node.js v0.8.8 +// Project: http://nodejs.org/ +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /************************************************ * * * Node.js v0.8.8 API * diff --git a/node/node.d.ts b/node/node.d.ts index b8fff3e275..78c0b3082f 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1,3 +1,7 @@ +// Type definitions for Node.js v0.10.1 +// Project: http://nodejs.org/ +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /************************************************ * * * Node.js v0.10.1 API * diff --git a/nodemailer/nodemailer.d.ts b/nodemailer/nodemailer.d.ts index 38f1804e7e..7d77a58ae5 100644 --- a/nodemailer/nodemailer.d.ts +++ b/nodemailer/nodemailer.d.ts @@ -1,9 +1,10 @@ // Type definitions for Nodemailer -// Nodemailer is an easy to use module to send e-mails with Node.JS (using SMTP or sendmail or Amazon SES) and is unicode friendly . // Project: https://github.com/andris9/Nodemailer // Definitions by: Vincent Bortone // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Nodemailer is an easy to use module to send e-mails with Node.JS (using SMTP or sendmail or Amazon SES) and is unicode friendly . + declare class Transport { static transports: { SMTP: Transport; From 709a0363a003c7c85df5a96d0258cdc3ddfbf17e Mon Sep 17 00:00:00 2001 From: Bartvds Date: Fri, 24 Jan 2014 01:56:27 +0100 Subject: [PATCH 052/240] added/fixed headers o-s https://github.com/borisyankov/DefinitelyTyped/issues/1570 --- parallel/parallel.d.ts | 5 +++++ pdf/pdf.d.ts | 5 +++++ pubsubjs/pubsub.d.ts | 5 ++++- requirejs/require.d.ts | 5 +++++ rx.js/rx.aggregates.d.ts | 8 ++++---- rx.js/rx.async.d.ts | 6 +++--- rx.js/rx.binding.d.ts | 8 ++++---- rx.js/rx.coincidence.d.ts | 8 ++++---- rx.js/rx.d.ts | 2 +- rx.js/rx.joinpatterns.d.ts | 6 +++--- rx.js/rx.jquery.d.ts | 2 +- rx.js/rx.testing.d.ts | 6 +++--- rx.js/rx.time.d.ts | 8 ++++---- rx.js/rx.virtualtime.d.ts | 6 +++--- sammyjs/sammyjs.d.ts | 4 ++-- sharepoint/SharePoint.d.ts | 2 +- siesta/siesta.d.ts | 5 +++++ slickgrid/SlickGrid.d.ts | 5 +++++ state-machine/state-machine.d.ts | 4 ++-- storejs/storejs.d.ts | 5 +++-- sugar/sugar.d.ts | 6 +++++- 21 files changed, 72 insertions(+), 39 deletions(-) diff --git a/parallel/parallel.d.ts b/parallel/parallel.d.ts index 06c8979e46..049ecda7d9 100644 --- a/parallel/parallel.d.ts +++ b/parallel/parallel.d.ts @@ -1,3 +1,8 @@ +// Type definitions for parallel.js +// Project: http://adambom.github.io/parallel.js/ +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* Copyright(c) 2013 Josh Baldwin https://github.com/jbaldwin/parallel.d.ts diff --git a/pdf/pdf.d.ts b/pdf/pdf.d.ts index 6641000bc7..bd66604f40 100644 --- a/pdf/pdf.d.ts +++ b/pdf/pdf.d.ts @@ -1,3 +1,8 @@ +// Type definitions for PDF.js +// Project: https://github.com/mozilla/pdf.js +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/pdf.d.ts diff --git a/pubsubjs/pubsub.d.ts b/pubsubjs/pubsub.d.ts index 68208cdbdb..40158c79b8 100644 --- a/pubsubjs/pubsub.d.ts +++ b/pubsubjs/pubsub.d.ts @@ -1,4 +1,7 @@ // Type definitions for PubSubJS 1.3.5 +// Project: https://github.com/mroderick/PubSubJS +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped declare module PubSubJS { interface Base extends Publish, Subscribe, Unsubscribe { @@ -24,4 +27,4 @@ declare module PubSubJS { } } -declare var PubSub: PubSubJS.Base; \ No newline at end of file +declare var PubSub: PubSubJS.Base; diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index bb58e5143f..e52f8197a1 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -1,3 +1,8 @@ +// Type definitions for RequireJS 2.1.8 +// Project: http://requirejs.org/ +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* require-2.1.8.d.ts may be freely distributed under the MIT license. diff --git a/rx.js/rx.aggregates.d.ts b/rx.js/rx.aggregates.d.ts index 24ed13f1d4..6f8358c8a9 100644 --- a/rx.js/rx.aggregates.d.ts +++ b/rx.js/rx.aggregates.d.ts @@ -1,11 +1,11 @@ -/// - -// Type definitions for RxJS-Aggregates package +// Type definitions for RxJS-Aggregates package // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Rx { export interface Observable { aggregate(accumulator: (acc: T, value: T) => T): Observable; diff --git a/rx.js/rx.async.d.ts b/rx.js/rx.async.d.ts index cdd93b9a86..f6e15c50a3 100644 --- a/rx.js/rx.async.d.ts +++ b/rx.js/rx.async.d.ts @@ -1,11 +1,11 @@ -/// - // Type definitions for RxJS-Async package 2.2.11 // Project: http://rx.codeplex.com/ // Definitions by: zoetrope -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Rx { interface ObservableStatic { start(func: () => T, scheduler?: IScheduler, context?: any): Observable; diff --git a/rx.js/rx.binding.d.ts b/rx.js/rx.binding.d.ts index 22624cc236..8df85f49cf 100644 --- a/rx.js/rx.binding.d.ts +++ b/rx.js/rx.binding.d.ts @@ -1,11 +1,11 @@ -/// - -// Type definitions for RxJS-Binding package +// Type definitions for RxJS-Binding package // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Rx { export interface BehaviorSubject extends Subject { } diff --git a/rx.js/rx.coincidence.d.ts b/rx.js/rx.coincidence.d.ts index 2afa5cfe90..a07a7c80b1 100644 --- a/rx.js/rx.coincidence.d.ts +++ b/rx.js/rx.coincidence.d.ts @@ -1,11 +1,11 @@ -/// - -// Type definitions for RxJS-Coincidence package +// Type definitions for RxJS-Coincidence package // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Rx { interface Observable { diff --git a/rx.js/rx.d.ts b/rx.js/rx.d.ts index f055452e31..8f055b0262 100644 --- a/rx.js/rx.d.ts +++ b/rx.js/rx.d.ts @@ -1,7 +1,7 @@ // Type definitions for RxJS // Project: http://rx.codeplex.com/ // Definitions by: gsino -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module Rx { diff --git a/rx.js/rx.joinpatterns.d.ts b/rx.js/rx.joinpatterns.d.ts index d23264f8e4..9b05e7c179 100644 --- a/rx.js/rx.joinpatterns.d.ts +++ b/rx.js/rx.joinpatterns.d.ts @@ -1,10 +1,10 @@ -/// - -// Type definitions for RxJS-Join package +// Type definitions for RxJS-Join package // Project: http://rx.codeplex.com/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Rx { interface Pattern1 { diff --git a/rx.js/rx.jquery.d.ts b/rx.js/rx.jquery.d.ts index fd9311ee49..746596bae3 100644 --- a/rx.js/rx.jquery.d.ts +++ b/rx.js/rx.jquery.d.ts @@ -1,6 +1,6 @@ // Type definitions for bridging RxJS with jQuery. // Project: https://github.com/Reactive-Extensions/RxJS-jQuery/ -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped /// diff --git a/rx.js/rx.testing.d.ts b/rx.js/rx.testing.d.ts index 8a2dc35e5f..69fcf2c131 100644 --- a/rx.js/rx.testing.d.ts +++ b/rx.js/rx.testing.d.ts @@ -1,11 +1,11 @@ -/// -/// - // Type definitions for RxJS-Testing // Project: https://github.com/Reactive-Extensions/RxJS/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// +/// + declare module Rx { export class TestScheduler extends VirtualTimeScheduler { constructor(); diff --git a/rx.js/rx.time.d.ts b/rx.js/rx.time.d.ts index 2d5f1d14f8..1ee0d4f22f 100644 --- a/rx.js/rx.time.d.ts +++ b/rx.js/rx.time.d.ts @@ -1,11 +1,11 @@ -/// - // Type definitions for RxJS "Aggregates" // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Rx { export interface TimeInterval { @@ -80,4 +80,4 @@ declare module Rx { timeSelector: (state: TState) => number, scheduler?: IScheduler): Observable; } -} \ No newline at end of file +} diff --git a/rx.js/rx.virtualtime.d.ts b/rx.js/rx.virtualtime.d.ts index 293343fda2..376057964e 100644 --- a/rx.js/rx.virtualtime.d.ts +++ b/rx.js/rx.virtualtime.d.ts @@ -1,11 +1,11 @@ -/// - // Type definitions for RxJS-VirtualTime package 2.2 // Project: http://rx.codeplex.com/ // Definitions by: gsino -// Revision by: Igor Oleinikov +// Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Rx { // Virtual IScheduler export /*abstract*/ class VirtualTimeScheduler extends Scheduler { diff --git a/sammyjs/sammyjs.d.ts b/sammyjs/sammyjs.d.ts index b4fd408807..136362fbf9 100644 --- a/sammyjs/sammyjs.d.ts +++ b/sammyjs/sammyjs.d.ts @@ -1,7 +1,7 @@ // Type definitions for Sammy.js // Project: http://sammyjs.org/ // Definitions by: Boris Yankov -// - Updated for TypeScript 0.9.x by: Oisin Grehan +// Definitions by: Oisin Grehan // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -279,4 +279,4 @@ declare module Sammy { interface JQueryStatic { sammy: Sammy.SammyFunc; log: Function; -} \ No newline at end of file +} diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 9f872afafc..1609f4ab0a 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -1,6 +1,6 @@ // Type definitions for sptypescript // Project: http://sptypescript.codeplex.com -// Definitions by: Stanislav Vyshchepan and Andrey Markeev +// Definitions by: Stanislav Vyshchepan , Andrey Markeev // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/siesta/siesta.d.ts b/siesta/siesta.d.ts index aaf6692bf3..f09f3f1274 100644 --- a/siesta/siesta.d.ts +++ b/siesta/siesta.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Siesta +// Project: http://www.bryntum.com/products/siesta/ +// Definitions by: bquarmby +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module Siesta { /** * @abstract diff --git a/slickgrid/SlickGrid.d.ts b/slickgrid/SlickGrid.d.ts index 481e6cb8dc..63fd76c979 100644 --- a/slickgrid/SlickGrid.d.ts +++ b/slickgrid/SlickGrid.d.ts @@ -1,3 +1,8 @@ +// Type definitions for SlickGrid 2.1.0 +// Project: https://github.com/mleibman/SlickGrid +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* SlickGrid-2.1.d.ts may be freely distributed under the MIT license. diff --git a/state-machine/state-machine.d.ts b/state-machine/state-machine.d.ts index 3415beb7c8..0805a1db31 100644 --- a/state-machine/state-machine.d.ts +++ b/state-machine/state-machine.d.ts @@ -1,9 +1,9 @@ // Type definitions for Finite State Machine 2.2 // Project: https://github.com/jakesgordon/javascript-state-machine // Definitions by: Boris Yankov +// Definitions by: Maarten Docter (2013/01/22) +// Definitions by: William Sears (2013/01/25) // Definitions: https://github.com/borisyankov/DefinitelyTyped -// Updated: 2013/01/22 by Maarten Docter -// Updated: 2013/01/25 by William Sears interface StateMachineErrorCallback { (eventName?: string, from?: string, to?: string, args?: any[], errorCode?: number, errorMessage?: string, ex?: Error): void; // NB. errorCode? See: StateMachine.Error diff --git a/storejs/storejs.d.ts b/storejs/storejs.d.ts index 8f1adcb1b4..d80865b2a4 100644 --- a/storejs/storejs.d.ts +++ b/storejs/storejs.d.ts @@ -1,9 +1,10 @@ // Type definitions for store.js -// store.js exposes a simple API for cross browser local storage // Project: https://github.com/marcuswestin/store.js/ // Definitions by: Vincent Bortone // Definitions: https://github.com/borisyankov/DefinitelyTyped +// store.js exposes a simple API for cross browser local storage + interface StoreJSStatic { set(key: string, value: any): any; get(key: string): any; @@ -17,4 +18,4 @@ interface StoreJSStatic { deserialize(value: string): any; } -declare var store: StoreJSStatic; \ No newline at end of file +declare var store: StoreJSStatic; diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index ff2ff8dcc9..876cdeb2cd 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -1,4 +1,8 @@ -/* +// Type definitions for Sugar 1.3.9 +// Project: http://http://sugarjs.com/ +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/* sugar-1.3.9.d.ts may be freely distributed under the MIT license. Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/sugar.d.ts From d436daf4c2b5a80886a9ebff4e15ffffd60cdc52 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Fri, 24 Jan 2014 02:57:12 +0100 Subject: [PATCH 053/240] added/fixed headers t-z https://github.com/borisyankov/DefinitelyTyped/issues/1570 --- teechart/teechart.d.ts | 4 ++++ typeahead/typeahead.d.ts | 2 +- underscore/underscore.d.ts | 5 ++--- unity-webapi/unity-webapi.d.ts | 2 +- urijs/URI.d.ts | 8 +++++--- videojs/videojs.d.ts | 3 ++- webaudioapi/waa-20120802.d.ts | 5 +++-- webaudioapi/waa-nightly.d.ts | 7 ++++--- webaudioapi/waa.d.ts | 2 +- webrtc/MediaStream.d.ts | 9 +++++++-- webrtc/RTCPeerConnection.d.ts | 9 +++++---- when/when.d.ts | 1 + winjs/winjs.d.ts | 5 +++++ winrt/winrt.d.ts | 5 +++++ youtube/youtube.d.ts | 2 +- yui/yui.d.ts | 4 ++-- zepto/zepto.d.ts | 7 ++++++- zeroclipboard/zeroclipboard.d.ts | 2 +- 18 files changed, 56 insertions(+), 26 deletions(-) diff --git a/teechart/teechart.d.ts b/teechart/teechart.d.ts index 27fead7653..2b747b3d9f 100644 --- a/teechart/teechart.d.ts +++ b/teechart/teechart.d.ts @@ -1,3 +1,7 @@ +// Type definitions for TeeChart 1.3 +// Project: http://www.steema.com +// Definitions by: Steema Software +// Definitions: https://github.com/borisyankov/DefinitelyTyped /** * TeeChart(tm) for TypeScript * diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index 8d4050c943..9ee948392c 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Twitter's typeahead.js 0.9.3 +// Type definitions for typeahead.js 0.9.3 // Project: http://twitter.github.io/typeahead.js/ // Definitions by: Ivaylo Gochkov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 121aa644e6..41b634081b 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1,8 +1,7 @@ // Type definitions for Underscore 1.5.2 // Project: http://underscorejs.org/ -// Definitions by: -// Boris Yankov -// Josh Baldwin +// Definitions by: Boris Yankov +// Definitions by: Josh Baldwin // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module _ { diff --git a/unity-webapi/unity-webapi.d.ts b/unity-webapi/unity-webapi.d.ts index 9170a26c19..3adf0c03ee 100644 --- a/unity-webapi/unity-webapi.d.ts +++ b/unity-webapi/unity-webapi.d.ts @@ -1,6 +1,6 @@ // Type definitions for Ubuntu Unity Web API 1.0 // Project: https://launchpad.net/libunity-webapps -// Definitions by: John Vrbanac | https://github.com/jmvrbanac +// Definitions by: John Vrbanac // Definitions: https://github.com/borisyankov/DefinitelyTyped interface External { diff --git a/urijs/URI.d.ts b/urijs/URI.d.ts index 6d6dcb6124..21c7faf982 100644 --- a/urijs/URI.d.ts +++ b/urijs/URI.d.ts @@ -1,6 +1,8 @@ -// URI.js +// Type definitions for URI.js // Project: https://github.com/medialize/URI.js -// Definitions by: https://github.com/RodneyJT +// Definitions by: RodneyJT +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /// interface URIOptions { @@ -181,4 +183,4 @@ declare class URI { interface JQuery { uri(): URI; -} \ No newline at end of file +} diff --git a/videojs/videojs.d.ts b/videojs/videojs.d.ts index 07f080acc2..1c53eefaf9 100644 --- a/videojs/videojs.d.ts +++ b/videojs/videojs.d.ts @@ -1,9 +1,10 @@ // Type definitions for Video.js -// The Video.js API allows you to interact with the video through Javascript, whether the browser is playing the video through HTML5 video, Flash, or any other supported playback technologies. // Project: https://github.com/zencoder/video-js // Definitions by: Vincent Bortone // Definitions: https://github.com/borisyankov/DefinitelyTyped +// The Video.js API allows you to interact with the video through Javascript, whether the browser is playing the video through HTML5 video, Flash, or any other supported playback technologies. + interface VideoJSOptions { techOrder?: string[]; html5?: Object; diff --git a/webaudioapi/waa-20120802.d.ts b/webaudioapi/waa-20120802.d.ts index 489cd4efb2..75100f6493 100644 --- a/webaudioapi/waa-20120802.d.ts +++ b/webaudioapi/waa-20120802.d.ts @@ -1,7 +1,8 @@ -// Type definitions for the Web Audio API, currently only implemented in WebKit browsers -// Conforms to the: http://www.w3.org/TR/2012/WD-webaudio-20120802/ specification +// Type definitions for the Web Audio API // Definitions by: Baruch Berger (https://github.com/bbss) // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Conforms to the: http://www.w3.org/TR/2012/WD-webaudio-20120802/ specification +// Currently only implemented in WebKit browsers interface webkitAudioContext { destination: AudioDestinationNode; diff --git a/webaudioapi/waa-nightly.d.ts b/webaudioapi/waa-nightly.d.ts index b6181e2444..cbb081a546 100644 --- a/webaudioapi/waa-nightly.d.ts +++ b/webaudioapi/waa-nightly.d.ts @@ -1,7 +1,8 @@ -// Type definitions for the Web Audio API, currently only implemented in WebKit browsers (nightly builds) -// Conforms to the: https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html specification +// Type definitions for the Web Audio API // Definitions by: Baruch Berger (https://github.com/bbss) // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Conforms to the: http://www.w3.org/TR/2012/WD-webaudio-20120802/ specification +// Currently only implemented in WebKit browsers (nightly builds) interface webkitAudioContext { @@ -247,4 +248,4 @@ interface MediaStreamAudioSourceNode extends AudioSourceNode { interface MediaStream { -} \ No newline at end of file +} diff --git a/webaudioapi/waa.d.ts b/webaudioapi/waa.d.ts index 6d85293549..17e13ea9b7 100644 --- a/webaudioapi/waa.d.ts +++ b/webaudioapi/waa.d.ts @@ -1,6 +1,6 @@ // Type definitions for the Web Audio API // Project: http://www.w3.org/TR/2012/WD-webaudio-20121213/ -// Definitions by: Baruch Berger (https://github.com/bbss), Kon (http://phyzkit.net/) +// Definitions by: Baruch Berger , Kon // Definitions: https://github.com/borisyankov/DefinitelyTyped /** diff --git a/webrtc/MediaStream.d.ts b/webrtc/MediaStream.d.ts index b1316091a0..54986ea0eb 100644 --- a/webrtc/MediaStream.d.ts +++ b/webrtc/MediaStream.d.ts @@ -1,4 +1,9 @@ -// Type definitions take from http://dev.w3.org/2011/webrtc/editor/getusermedia.html +// Type definitions for WebRTC +// Project: http://dev.w3.org/2011/webrtc/ +// Definitions by: Ken Smith +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html interface MediaStreamConstraints { audio: boolean; @@ -133,4 +138,4 @@ declare var webkitURL: { prototype: WebkitURL; new (): streamURL; createObjectURL(stream: MediaStream): string; -} \ No newline at end of file +} diff --git a/webrtc/RTCPeerConnection.d.ts b/webrtc/RTCPeerConnection.d.ts index e07e3a4173..fbf11c364b 100644 --- a/webrtc/RTCPeerConnection.d.ts +++ b/webrtc/RTCPeerConnection.d.ts @@ -1,10 +1,11 @@ -/// +// Type definitions for WebRTC +// Project: http://dev.w3.org/2011/webrtc/ +// Definitions by: Ken Smith +// Definitions: https://github.com/borisyankov/DefinitelyTyped -// These are TypeScript definitions to support static typing in TypeScript when interacting with WebRtc. // Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html -// These are TypeScript definitions to support static typing in TypeScript when interacting with WebRtc. -// Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html +/// interface RTCConfiguration { iceServers: RTCIceServer[]; diff --git a/when/when.d.ts b/when/when.d.ts index dbf4050a0f..56d8833562 100644 --- a/when/when.d.ts +++ b/when/when.d.ts @@ -1,5 +1,6 @@ // Type definitions for When 2.4.0 // Project: https://github.com/cujojs/when +// Definitions by: Derek Cicerone // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module When { diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 99a5e33c2b..9691e53e8e 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -1,3 +1,8 @@ +// Type definitions for WinJS +// Project: http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx +// Definitions by: TypeScript samples +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index 881b64ed39..c240aa3d09 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -1,3 +1,8 @@ +// Type definitions for WinRT +// Project: http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx +// Definitions by: TypeScript samples +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index b24b130dc2..efb4ba344b 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -1,7 +1,7 @@ // Type definitions for YouTube // Project: https://developers.google.com/youtube/ // Definitions by: Daz Wilkin -// Updated by: Ian Obermiller +// Definitions by: Ian Obermiller // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module YT { diff --git a/yui/yui.d.ts b/yui/yui.d.ts index acc448899b..006cb13e4e 100644 --- a/yui/yui.d.ts +++ b/yui/yui.d.ts @@ -1,7 +1,7 @@ // Type definitions for yui 3.14.0 // Project: https://github.com/yui/yui3/blob/release-3.14.0/src/yui/js -// Definitions by: -// Gia Bảo @ Sân Đình +// Definitions by: Gia Bảo @ Sân Đình +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// diff --git a/zepto/zepto.d.ts b/zepto/zepto.d.ts index 241b317cff..bda50949ac 100644 --- a/zepto/zepto.d.ts +++ b/zepto/zepto.d.ts @@ -1,4 +1,9 @@ -/* +// Type definitions for Zepto 1.0-rc.1 +// Project: http://zeptojs.com/ +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* zepto-1.0rc1.d.ts may be freely distributed under the MIT license. Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/zepto.d.ts diff --git a/zeroclipboard/zeroclipboard.d.ts b/zeroclipboard/zeroclipboard.d.ts index f950487004..847593df8d 100644 --- a/zeroclipboard/zeroclipboard.d.ts +++ b/zeroclipboard/zeroclipboard.d.ts @@ -1,7 +1,7 @@ // Type definitions for ZeroClipboard // Project: https://github.com/jonrohan/ZeroClipboard // Definitions by: Eric J. Smith -// Updated by: Blake Niemyjski +// Definitions by: Blake Niemyjski // Definitions: https://github.com/borisyankov/DefinitelyTyped declare class ZeroClipboard { From 1715dcbb20d7380ea1ee43a2e85a98b97735d947 Mon Sep 17 00:00:00 2001 From: KhodeN Date: Fri, 24 Jan 2014 17:39:45 +1100 Subject: [PATCH 054/240] Update sugar.d.ts. Fix Array.groupBy method fn? - iteration function over result object. It has 3 arguments: groupKey, groupItems, resultObject key in result object always is string --- sugar/sugar.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 876cdeb2cd..2692d42e80 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -2358,16 +2358,14 @@ interface Array { * [{age:35,name:'ken'},{age:15,name:'bob'}].groupBy(function(n) { * return n.age; * }); -> { 35: [{age:35,name:'ken'}], 15: [{age:15,name:'bob'}] } - * todo: return should be : { [key: U]: any } **/ - groupBy(map: string, fn?: (group: T) => void ): { [key: string]: any }; + groupBy(map: string, fn?: (key: string, items: T[]) => void): { [key: string]: T }; /** * @see groupBy * @param map Callback function for each element, returns the key for the group the element should be in. - * todo: return should be : { [key: U]: any } **/ - groupBy(map: (element: T) => U, fn?: (group: T) => void ): { [key: string]: any }; + groupBy(map: (element: T) => U, fn?: (key: string, items: T[]) => void): { [key: string]: T[] }; /** * Groups the array into arrays. From 2c3666e48bd3f4658af39a8f8f9d9763cd513a86 Mon Sep 17 00:00:00 2001 From: dotnetnerd Date: Fri, 24 Jan 2014 09:42:26 +0100 Subject: [PATCH 055/240] Fixed test --- ftdomdelegate/ftdomdelegate-tests.ts | 18 +++++++----------- ftdomdelegate/ftdomdelegate.d.ts | 4 ++-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/ftdomdelegate/ftdomdelegate-tests.ts b/ftdomdelegate/ftdomdelegate-tests.ts index 7850422611..55dc7a737a 100644 --- a/ftdomdelegate/ftdomdelegate-tests.ts +++ b/ftdomdelegate/ftdomdelegate-tests.ts @@ -1,19 +1,15 @@ /// -function handleButtonClicks(event) { - // Do some things -} - -function handleTouchMove(event) { - // Do some other things -} - window.addEventListener('load', function() { var delegate = new Delegate(document.body); - delegate.on('click', 'button', handleButtonClicks); + delegate.on('click', 'button', function(event) { + // Do some things + } +); // Listen to all touch move // events that reach the body - delegate.on('touchmove', handleTouchMove); - + delegate.on('touchmove', function(event) { + // Do some other things + }); }, false); \ No newline at end of file diff --git a/ftdomdelegate/ftdomdelegate.d.ts b/ftdomdelegate/ftdomdelegate.d.ts index 6dc6c8dbec..4413adb1a7 100644 --- a/ftdomdelegate/ftdomdelegate.d.ts +++ b/ftdomdelegate/ftdomdelegate.d.ts @@ -8,7 +8,7 @@ declare class Delegate { constructor(element: HTMLElement); - on(eventType: string, selector: string, callback : () => any) : void; + on(eventType: string, selector: string, callback : (event : any) => any) : void; - on(eventType: string, callback:() => any) : void; + on(eventType: string, callback:(event : any) => any) : void; } \ No newline at end of file From 12ce39de56b0f69a91d34ca856d101391f11bc9d Mon Sep 17 00:00:00 2001 From: KhodeN Date: Fri, 24 Jan 2014 20:04:01 +1100 Subject: [PATCH 056/240] Update angular-translate.d.ts ITranslateProvider.fallbackLanguage can accept array of string (languages) --- angular-translate/angular-translate.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts index aac4a74126..106d0ae252 100644 --- a/angular-translate/angular-translate.d.ts +++ b/angular-translate/angular-translate.d.ts @@ -47,6 +47,7 @@ declare module ng.translate { translationNotFoundIndicatorRight(indicator: string): ITranslateProvider; fallbackLanguage(): string; fallbackLanguage(language: string): ITranslateProvider; + fallbackLanguage(languages: string[]): ITranslateProvider; uses(): string; uses(key: string): ITranslateProvider; useUrlLoader(url: string): ITranslateProvider; From d093411578e14a2cd789a79112bfb29a24da6093 Mon Sep 17 00:00:00 2001 From: dotnetnerd Date: Fri, 24 Jan 2014 12:53:59 +0100 Subject: [PATCH 057/240] Added more annotations --- ftdomdelegate/ftdomdelegate.d.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ftdomdelegate/ftdomdelegate.d.ts b/ftdomdelegate/ftdomdelegate.d.ts index 4413adb1a7..04766bd26e 100644 --- a/ftdomdelegate/ftdomdelegate.d.ts +++ b/ftdomdelegate/ftdomdelegate.d.ts @@ -3,12 +3,20 @@ // Definitions by: Christian Holm Nielsen // Definitions: https://github.com/borisyankov/DefinitelyTyped - declare class Delegate { constructor(element: HTMLElement); - on(eventType: string, selector: string, callback : (event : any) => any) : void; + on(eventType: string, selector: string, handler : (event: Event, targetElement: Element) => void, eventData? : any) : void; - on(eventType: string, callback:(event : any) => any) : void; + on(eventType: string, selector: (element: Element) => boolean, handler : (event: Event, targetElement: Element) => void, eventData? : any) : void; + + on(eventType: string, handler:(event: Event, targetElement: Element) => void, eventData? : any) : void; + + off(eventType? : string, selector? : string, handler? : (event: Event, targetElement: Element) => void) : void; + off(eventType? : string, selector?: (element: Element) => boolean, handler? : (event: Event, targetElement: Element) => void) : void; + + root(element? : Element) : void; + + destroy() : void; } \ No newline at end of file From 1c1a37c1e4a5cb614f64b4c547fd69cbe6ca2828 Mon Sep 17 00:00:00 2001 From: Bartvds Date: Fri, 24 Jan 2014 18:51:21 +0100 Subject: [PATCH 058/240] removed utf-8 BOM marker for consistency --- amcharts/AmCharts.d.ts | 2 +- chai/chai.d.ts | 2 +- expect.js/expect.js.d.ts | 2 +- flight/flight.d.ts | 2 +- gapi.pagespeedonline/gapi.pagespeedonline.d.ts | 2 +- gapi.youtube/gapi.youtube.d.ts | 2 +- ix.js/l2o.d.ts | 2 +- jasmine/jasmine-1.3.d.ts | 2 +- jasmine/jasmine.d.ts | 2 +- jointjs/jointjs.d.ts | 2 +- jquery.colorbox/jquery.colorbox.d.ts | 2 +- jquery.pickadate/jquery.pickadate-tests.ts | 2 +- jquery.pickadate/jquery.pickadate.d.ts | 2 +- jsplumb/jquery.jsPlumb.d.ts | 2 +- knockback/knockback.d.ts | 2 +- knockout.es5/knockout.es5.d.ts | 2 +- node-azure/azure.d.ts | 2 +- node/node-tests.ts | 2 +- openlayers/openlayers.d.ts | 2 +- rx.js/rx.aggregates.d.ts | 2 +- rx.js/rx.binding.d.ts | 2 +- rx.js/rx.coincidence.d.ts | 2 +- rx.js/rx.d.ts | 2 +- rx.js/rx.joinpatterns.d.ts | 2 +- rx.js/rx.jquery.d.ts | 2 +- sharepoint/SharePoint.d.ts | 2 +- sugar/sugar.d.ts | 2 +- webrtc/MediaStream.d.ts | 2 +- webrtc/RTCPeerConnection.d.ts | 2 +- zepto/zepto.d.ts | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/amcharts/AmCharts.d.ts b/amcharts/AmCharts.d.ts index 3012b2a0ae..9b29ef98f7 100644 --- a/amcharts/AmCharts.d.ts +++ b/amcharts/AmCharts.d.ts @@ -1,4 +1,4 @@ -// Type definitions for amCharts +// Type definitions for amCharts // Project: http://www.amcharts.com/ // Definitions by: aleksey-bykov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/chai/chai.d.ts b/chai/chai.d.ts index 6774a932fa..7318744012 100644 --- a/chai/chai.d.ts +++ b/chai/chai.d.ts @@ -1,4 +1,4 @@ -// Type definitions for chai 1.7.2 +// Type definitions for chai 1.7.2 // Project: http://chaijs.com/ // Definitions by: Jed Hunsaker // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped diff --git a/expect.js/expect.js.d.ts b/expect.js/expect.js.d.ts index e19f769b65..64c5871b07 100644 --- a/expect.js/expect.js.d.ts +++ b/expect.js/expect.js.d.ts @@ -1,4 +1,4 @@ -// Type definitions for expect.js 0.2.0 +// Type definitions for expect.js 0.2.0 // Project: https://github.com/LearnBoost/expect.js // Definitions by: Teppei Sato // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped diff --git a/flight/flight.d.ts b/flight/flight.d.ts index e0eab6ada4..19c8528df2 100644 --- a/flight/flight.d.ts +++ b/flight/flight.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Flight 1.1.1 +// Type definitions for Flight 1.1.1 // Project: http://flightjs.github.com/flight/ // Definitions by: Jonathan Hedrén // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/gapi.pagespeedonline/gapi.pagespeedonline.d.ts b/gapi.pagespeedonline/gapi.pagespeedonline.d.ts index 4fe23abd28..44665784e7 100644 --- a/gapi.pagespeedonline/gapi.pagespeedonline.d.ts +++ b/gapi.pagespeedonline/gapi.pagespeedonline.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Page Speed Online Api +// Type definitions for Google Page Speed Online Api // Project: https://developers.google.com/speed/pagespeed/ // Definitions by: Frank M // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/gapi.youtube/gapi.youtube.d.ts b/gapi.youtube/gapi.youtube.d.ts index 3d0930787f..ee554e4398 100644 --- a/gapi.youtube/gapi.youtube.d.ts +++ b/gapi.youtube/gapi.youtube.d.ts @@ -1,4 +1,4 @@ -// Type definitions for YouTube Data API v3 +// Type definitions for YouTube Data API v3 // Project: https://developers.google.com/youtube/v3/ // Definitions by: Frank M // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/ix.js/l2o.d.ts b/ix.js/l2o.d.ts index ed53502226..209c9b6757 100644 --- a/ix.js/l2o.d.ts +++ b/ix.js/l2o.d.ts @@ -1,4 +1,4 @@ -// Type definitions for IxJS 1.0.6 / l2o.js +// Type definitions for IxJS 1.0.6 / l2o.js // Project: https://github.com/Reactive-Extensions/IxJS // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/jasmine/jasmine-1.3.d.ts b/jasmine/jasmine-1.3.d.ts index 59e7d17570..b380959d0c 100644 --- a/jasmine/jasmine-1.3.d.ts +++ b/jasmine/jasmine-1.3.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Jasmine 1.3 +// Type definitions for Jasmine 1.3 // Project: http://pivotal.github.com/jasmine/ // Definitions by: Boris Yankov // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index 6eb0452308..4c01b347bf 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Jasmine 2.0 +// Type definitions for Jasmine 2.0 // Project: http://pivotal.github.com/jasmine/ // Definitions by: Boris Yankov , Theodore Brown // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index 6dbdece13f..f4e0926ea7 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Joint JS 0.6 +// Type definitions for Joint JS 0.6 // Project: http://www.jointjs.com/ // Definitions by: Aidan Reel , David Durman // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/jquery.colorbox/jquery.colorbox.d.ts b/jquery.colorbox/jquery.colorbox.d.ts index 1586af0ca7..d284223462 100644 --- a/jquery.colorbox/jquery.colorbox.d.ts +++ b/jquery.colorbox/jquery.colorbox.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQuery.Colorbox 1.4.15 +// Type definitions for jQuery.Colorbox 1.4.15 // Project: http://www.jacklmoore.com/colorbox/ // Definitions by: Gidon Junge <@gjunge> // Definitions: https://github.com/borisyankov/DefinitelyTyped/ diff --git a/jquery.pickadate/jquery.pickadate-tests.ts b/jquery.pickadate/jquery.pickadate-tests.ts index f99d55ecc3..fde52f3e3e 100644 --- a/jquery.pickadate/jquery.pickadate-tests.ts +++ b/jquery.pickadate/jquery.pickadate-tests.ts @@ -1,4 +1,4 @@ -/// +/// /* * Date picker tests diff --git a/jquery.pickadate/jquery.pickadate.d.ts b/jquery.pickadate/jquery.pickadate.d.ts index 077ae15cde..274f20f909 100644 --- a/jquery.pickadate/jquery.pickadate.d.ts +++ b/jquery.pickadate/jquery.pickadate.d.ts @@ -1,4 +1,4 @@ -// Type definitions for pickadate.js 3.3.0 +// Type definitions for pickadate.js 3.3.0 // Project: https://github.com/amsul/pickadate.js // Definitions by: Theodore Brown // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/jsplumb/jquery.jsPlumb.d.ts b/jsplumb/jquery.jsPlumb.d.ts index ee657c2c2d..aa1bf5d443 100644 --- a/jsplumb/jquery.jsPlumb.d.ts +++ b/jsplumb/jquery.jsPlumb.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jsPlumb 1.3.16 jQuery adapter. +// Type definitions for jsPlumb 1.3.16 jQuery adapter. // Project: http://jsplumb.org // Project: https://github.com/sporritt/jsplumb // Project: https://code.google.com/p/jsplumb diff --git a/knockback/knockback.d.ts b/knockback/knockback.d.ts index def3a398da..50848e6841 100644 --- a/knockback/knockback.d.ts +++ b/knockback/knockback.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Knockback.js +// Type definitions for Knockback.js // Project: http://kmalakoff.github.io/knockback/ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/knockout.es5/knockout.es5.d.ts b/knockout.es5/knockout.es5.d.ts index 868655545e..651d7d40f3 100644 --- a/knockout.es5/knockout.es5.d.ts +++ b/knockout.es5/knockout.es5.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Knockout-ES5 +// Type definitions for Knockout-ES5 // Project: https://github.com/SteveSanderson/knockout-es5 // Definitions by: Sebastián Galiano // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/node-azure/azure.d.ts b/node-azure/azure.d.ts index 0f16d9de87..95ff46c25b 100644 --- a/node-azure/azure.d.ts +++ b/node-azure/azure.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Azure SDK for Node - v0.6.10 +// Type definitions for Azure SDK for Node - v0.6.10 // Project: https://github.com/WindowsAzure/azure-sdk-for-node // Definitions by: Andrew Gaspar , Anti Veeranna // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/node/node-tests.ts b/node/node-tests.ts index 8d67db311e..49b43302b1 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -1,4 +1,4 @@ -/// +/// import assert = require("assert"); import fs = require("fs"); diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index 43ba32473e..6be401f715 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -1,4 +1,4 @@ -// Type definitions for OpenLayers.js 2.10 +// Type definitions for OpenLayers.js 2.10 // Project: https://github.com/openlayers/openlayers // Definitions by: Ilya Bolkhovsky // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.aggregates.d.ts b/rx.js/rx.aggregates.d.ts index 6f8358c8a9..4ba03b4c60 100644 --- a/rx.js/rx.aggregates.d.ts +++ b/rx.js/rx.aggregates.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Aggregates package +// Type definitions for RxJS-Aggregates package // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.binding.d.ts b/rx.js/rx.binding.d.ts index 8df85f49cf..6d0f1db3c1 100644 --- a/rx.js/rx.binding.d.ts +++ b/rx.js/rx.binding.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Binding package +// Type definitions for RxJS-Binding package // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.coincidence.d.ts b/rx.js/rx.coincidence.d.ts index a07a7c80b1..02883ff542 100644 --- a/rx.js/rx.coincidence.d.ts +++ b/rx.js/rx.coincidence.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Coincidence package +// Type definitions for RxJS-Coincidence package // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.d.ts b/rx.js/rx.d.ts index 8f055b0262..51f4dae890 100644 --- a/rx.js/rx.d.ts +++ b/rx.js/rx.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS +// Type definitions for RxJS // Project: http://rx.codeplex.com/ // Definitions by: gsino // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.joinpatterns.d.ts b/rx.js/rx.joinpatterns.d.ts index 9b05e7c179..a1ec9f952d 100644 --- a/rx.js/rx.joinpatterns.d.ts +++ b/rx.js/rx.joinpatterns.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Join package +// Type definitions for RxJS-Join package // Project: http://rx.codeplex.com/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.jquery.d.ts b/rx.js/rx.jquery.d.ts index 746596bae3..f8513cf446 100644 --- a/rx.js/rx.jquery.d.ts +++ b/rx.js/rx.jquery.d.ts @@ -1,4 +1,4 @@ -// Type definitions for bridging RxJS with jQuery. +// Type definitions for bridging RxJS with jQuery. // Project: https://github.com/Reactive-Extensions/RxJS-jQuery/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 1609f4ab0a..b0417fd33b 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sptypescript +// Type definitions for sptypescript // Project: http://sptypescript.codeplex.com // Definitions by: Stanislav Vyshchepan , Andrey Markeev // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 2692d42e80..20b0df69c2 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Sugar 1.3.9 +// Type definitions for Sugar 1.3.9 // Project: http://http://sugarjs.com/ // Definitions by: Josh Baldwin // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/webrtc/MediaStream.d.ts b/webrtc/MediaStream.d.ts index 54986ea0eb..ddf2200be3 100644 --- a/webrtc/MediaStream.d.ts +++ b/webrtc/MediaStream.d.ts @@ -1,4 +1,4 @@ -// Type definitions for WebRTC +// Type definitions for WebRTC // Project: http://dev.w3.org/2011/webrtc/ // Definitions by: Ken Smith // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/webrtc/RTCPeerConnection.d.ts b/webrtc/RTCPeerConnection.d.ts index fbf11c364b..d66ad6cf0f 100644 --- a/webrtc/RTCPeerConnection.d.ts +++ b/webrtc/RTCPeerConnection.d.ts @@ -1,4 +1,4 @@ -// Type definitions for WebRTC +// Type definitions for WebRTC // Project: http://dev.w3.org/2011/webrtc/ // Definitions by: Ken Smith // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/zepto/zepto.d.ts b/zepto/zepto.d.ts index bda50949ac..eb217e5b98 100644 --- a/zepto/zepto.d.ts +++ b/zepto/zepto.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Zepto 1.0-rc.1 +// Type definitions for Zepto 1.0-rc.1 // Project: http://zeptojs.com/ // Definitions by: Josh Baldwin // Definitions: https://github.com/borisyankov/DefinitelyTyped From e45363e3d2db08e60914281532af868639fd380f Mon Sep 17 00:00:00 2001 From: Bartvds Date: Fri, 24 Jan 2014 20:23:13 +0100 Subject: [PATCH 059/240] added/fixed few headers https://github.com/borisyankov/DefinitelyTyped/issues/1570 --- jquery.jnotify/jquery.jnotify.d.ts | 6 +++--- jquery.noty/jquery.noty.d.ts | 5 +++-- jquery/jquery.d.ts | 2 +- pixi/webgl.d.ts | 7 ++++++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/jquery.jnotify/jquery.jnotify.d.ts b/jquery.jnotify/jquery.jnotify.d.ts index 7c9cf05bbb..21a9485d7d 100644 --- a/jquery.jnotify/jquery.jnotify.d.ts +++ b/jquery.jnotify/jquery.jnotify.d.ts @@ -1,8 +1,8 @@ -// Typescript type definitions for jQuery.jNotify 1.0 by Fabio Franzini +// Type definitions for jQuery.jNotify 1.0 // Project: http://jnotify.codeplex.com // Definitions by: James Curran // Definitions: https://github.com/borisyankov/DefinitelyTyped - +// Project by: Fabio Franzini /// @@ -22,4 +22,4 @@ interface JNotifyOptions { interface JQuery { jnotifyInizialize(options?: JNotifyInitOptions); jnotifyAddMessage(options?: JNotifyOptions); -} \ No newline at end of file +} diff --git a/jquery.noty/jquery.noty.d.ts b/jquery.noty/jquery.noty.d.ts index fe548b6e8c..9ec7d85e4f 100644 --- a/jquery.noty/jquery.noty.d.ts +++ b/jquery.noty/jquery.noty.d.ts @@ -1,7 +1,8 @@ -// Typescript type definitions for jQuery.noty v2.0 by Nedim Carter +// Type definitions for jQuery.noty v2.0 // Project: http://needim.github.io/noty/ // Definitions by: Aaron King // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Project by: Nedim Carter /// @@ -64,4 +65,4 @@ declare var noty: { closed: boolean; shown: boolean; -} \ No newline at end of file +} diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index a170155c65..d91443009b 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1,4 +1,4 @@ -// Typing for the jQuery library 1.10.x / 2.0.x +// Type definitions for jQuery 1.10.x / 2.0.x // Project: http://jquery.com/ // Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton, Diullei Gomes , Tass Iliopoulos , Jason Swearingen, Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/pixi/webgl.d.ts b/pixi/webgl.d.ts index 63172ad92e..71538bbf8a 100644 --- a/pixi/webgl.d.ts +++ b/pixi/webgl.d.ts @@ -1,3 +1,8 @@ +// Type definitions for WebGL +// Project: https://www.khronos.org/webgl/ +// Definitions by: xperiments +// Definitions: https://github.com/borisyankov/DefinitelyTyped + interface WebGLContextAttributes { alpha : boolean; depth : boolean; @@ -531,4 +536,4 @@ interface WindowAnimationTiming { //To make WebGL work interface HTMLCanvasElement { getContext(contextId: string, params : {}): WebGLRenderingContext; -} \ No newline at end of file +} From 5263434c20d562f50e912b9cbd11beaac5756a6b Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Fri, 24 Jan 2014 23:49:49 +0100 Subject: [PATCH 060/240] added/fixed few headers https://github.com/borisyankov/DefinitelyTyped/issues/1570 cleaned up some more, mostly urls and typos --- angularjs/angular-resource.d.ts | 1 + angularjs/angular-scenario.d.ts | 4 ++-- azure-mobile-services-client/AzureMobileServicesClient.d.ts | 4 ++-- fullCalendar/fullCalendar.d.ts | 4 ++-- humane/humane.d.ts | 2 +- icheck/icheck.d.ts | 4 ++-- jquery.livestampjs/jquery.livestampjs.d.ts | 2 +- jsplumb/jquery.jsPlumb.d.ts | 4 +--- knockout.editables/ko.editables.d.ts | 1 + leapmotionTS/LeapMotionTS.d.ts | 6 +++--- sugar/sugar.d.ts | 4 ++-- tween.js/tween.js.d.ts | 2 +- webaudioapi/waa-20120802.d.ts | 4 +++- webaudioapi/waa-nightly.d.ts | 4 +++- webaudioapi/waa.d.ts | 2 +- winjs/winjs.d.ts | 2 +- winrt/winrt.d.ts | 2 +- yui/yui.d.ts | 2 +- 18 files changed, 29 insertions(+), 25 deletions(-) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index f3a8870cdc..eebed96c30 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -1,5 +1,6 @@ // Type definitions for Angular JS 1.2 (ngResource module) // Project: http://angularjs.org +// Definitions by: Diego Vilar // Definitions: https://github.com/daptiv/DefinitelyTyped /// diff --git a/angularjs/angular-scenario.d.ts b/angularjs/angular-scenario.d.ts index abd5709db6..e9f99fc394 100644 --- a/angularjs/angular-scenario.d.ts +++ b/angularjs/angular-scenario.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular Scenario Testing -// Project: [http://angularjs.org] -// Definitions by: [RomanoLindano] +// Project: http://angularjs.org +// Definitions by: RomanoLindano // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module ng { diff --git a/azure-mobile-services-client/AzureMobileServicesClient.d.ts b/azure-mobile-services-client/AzureMobileServicesClient.d.ts index 67c7bed727..fa0c4b35ba 100644 --- a/azure-mobile-services-client/AzureMobileServicesClient.d.ts +++ b/azure-mobile-services-client/AzureMobileServicesClient.d.ts @@ -1,5 +1,5 @@ -// Type definitions for Microsoft.Windows.Azure.MobileService.Web-1.0.0 -// Project: Microsoft Windows AzureMobile Service +// Type definitions for Microsoft Windows AzureMobile Service 1.0.0 +// Project: http://www.windowsazure.com/en-us/develop/mobile/ // Definitions by: Morosinotto Daniele // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index ec24c4e7fe..fd1303f69e 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -1,5 +1,5 @@ // Type definitions for FullCalendar 1.6.1 -// Project: http://arshaw.com/fullcalendar/ (http://arshaw.com/fullcalendar/) +// Project: http://arshaw.com/fullcalendar/ // Definitions by: Neil Stalker // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -310,4 +310,4 @@ interface JQuery { interface JQueryStatic { fullCalendar: FullCalendar.Calendar; -} \ No newline at end of file +} diff --git a/humane/humane.d.ts b/humane/humane.d.ts index aa3184db89..06f865636a 100644 --- a/humane/humane.d.ts +++ b/humane/humane.d.ts @@ -1,6 +1,6 @@ // Type definitions for Humane 3.0 // Project: http://wavded.github.com/humane-js/ -// Definitions by: https://github.com/jmvrbanac +// Definitions by: jmvrbanac // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped diff --git a/icheck/icheck.d.ts b/icheck/icheck.d.ts index 750d9e94e4..5df433875e 100644 --- a/icheck/icheck.d.ts +++ b/icheck/icheck.d.ts @@ -1,6 +1,6 @@ // Type definitions for iCheck v0.8 // Project: http://damirfoy.com/iCheck/ -// Definitions by: Dániel Tar https://github.com/qcz +// Definitions by: Dániel Tar // Definitions: https://github.com/borisyankov/DefinitelyTyped interface ICheckOptions { @@ -109,4 +109,4 @@ interface ICheckOptions { interface JQuery { iCheck(options?: ICheckOptions): JQuery; iCheck(command: string, callback?: () => void): void; -} \ No newline at end of file +} diff --git a/jquery.livestampjs/jquery.livestampjs.d.ts b/jquery.livestampjs/jquery.livestampjs.d.ts index d5a44c4192..35453d4f3f 100644 --- a/jquery.livestampjs/jquery.livestampjs.d.ts +++ b/jquery.livestampjs/jquery.livestampjs.d.ts @@ -1,5 +1,5 @@ // Type definitions for Livestamp.js -// Project: http://http://mattbradley.github.com/livestampjs/ +// Project: http://mattbradley.github.com/livestampjs/ // Definitions by: Vincent Bortone // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/jsplumb/jquery.jsPlumb.d.ts b/jsplumb/jquery.jsPlumb.d.ts index aa1bf5d443..ed7bc8452f 100644 --- a/jsplumb/jquery.jsPlumb.d.ts +++ b/jsplumb/jquery.jsPlumb.d.ts @@ -1,7 +1,5 @@ -// Type definitions for jsPlumb 1.3.16 jQuery adapter. +// Type definitions for jsPlumb 1.3.16 jQuery adapter. // Project: http://jsplumb.org -// Project: https://github.com/sporritt/jsplumb -// Project: https://code.google.com/p/jsplumb // Definitions by: Steve Shearn // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/knockout.editables/ko.editables.d.ts b/knockout.editables/ko.editables.d.ts index ca6ca73b0b..b6da1f13f6 100644 --- a/knockout.editables/ko.editables.d.ts +++ b/knockout.editables/ko.editables.d.ts @@ -1,5 +1,6 @@ // Type definitions for knockout-editables 0.9 // Project:http://romanych.github.com/ko.editables/ +// Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped /// diff --git a/leapmotionTS/LeapMotionTS.d.ts b/leapmotionTS/LeapMotionTS.d.ts index dac337976d..411409aeca 100644 --- a/leapmotionTS/LeapMotionTS.d.ts +++ b/leapmotionTS/LeapMotionTS.d.ts @@ -1,5 +1,5 @@ -// Type definitions for Leap Motion TS (SDK version 0.7.9) -// Project: https://github.com/logotype/LeapMotionTS and http://www.leapmotion.com +// Type definitions for Leap Motion TS 0.7.9 +// Project: https://github.com/logotype/LeapMotionTS // Definitions by: Victor Norgren // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -295,4 +295,4 @@ export declare class Vector3 { static forward(): Vector3; static backward(): Vector3; public toString(): string; -} \ No newline at end of file +} diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 20b0df69c2..76ec222b26 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -1,5 +1,5 @@ -// Type definitions for Sugar 1.3.9 -// Project: http://http://sugarjs.com/ +// Type definitions for Sugar 1.3.9 +// Project: http://sugarjs.com/ // Definitions by: Josh Baldwin // Definitions: https://github.com/borisyankov/DefinitelyTyped /* diff --git a/tween.js/tween.js.d.ts b/tween.js/tween.js.d.ts index df5826bd21..0caaed1477 100644 --- a/tween.js/tween.js.d.ts +++ b/tween.js/tween.js.d.ts @@ -1,6 +1,6 @@ // Type definitions for tween.js r12 // Project: https://github.com/sole/tween.js/ -// Definitions by: https://github.com/sunetos and https://github.com/jzarnikov +// Definitions by: sunetos , jzarnikov // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module TWEEN { diff --git a/webaudioapi/waa-20120802.d.ts b/webaudioapi/waa-20120802.d.ts index 75100f6493..64dc658764 100644 --- a/webaudioapi/waa-20120802.d.ts +++ b/webaudioapi/waa-20120802.d.ts @@ -1,6 +1,8 @@ -// Type definitions for the Web Audio API +// Type definitions for Web Audio API +// Project: http://www.w3.org/TR/2012/WD-webaudio-20120802/ // Definitions by: Baruch Berger (https://github.com/bbss) // Definitions: https://github.com/borisyankov/DefinitelyTyped + // Conforms to the: http://www.w3.org/TR/2012/WD-webaudio-20120802/ specification // Currently only implemented in WebKit browsers diff --git a/webaudioapi/waa-nightly.d.ts b/webaudioapi/waa-nightly.d.ts index cbb081a546..79566f9396 100644 --- a/webaudioapi/waa-nightly.d.ts +++ b/webaudioapi/waa-nightly.d.ts @@ -1,6 +1,8 @@ -// Type definitions for the Web Audio API +// Type definitions for Web Audio API (nightly) +// Project: http://www.w3.org/TR/2012/WD-webaudio-20120802/ // Definitions by: Baruch Berger (https://github.com/bbss) // Definitions: https://github.com/borisyankov/DefinitelyTyped + // Conforms to the: http://www.w3.org/TR/2012/WD-webaudio-20120802/ specification // Currently only implemented in WebKit browsers (nightly builds) diff --git a/webaudioapi/waa.d.ts b/webaudioapi/waa.d.ts index 17e13ea9b7..cd53babc0c 100644 --- a/webaudioapi/waa.d.ts +++ b/webaudioapi/waa.d.ts @@ -1,4 +1,4 @@ -// Type definitions for the Web Audio API +// Type definitions for Web Audio API // Project: http://www.w3.org/TR/2012/WD-webaudio-20121213/ // Definitions by: Baruch Berger , Kon // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 9691e53e8e..628d51ccc5 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -1,6 +1,6 @@ // Type definitions for WinJS // Project: http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx -// Definitions by: TypeScript samples +// Definitions by: TypeScript samples // Definitions: https://github.com/borisyankov/DefinitelyTyped /* ***************************************************************************** diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index c240aa3d09..6ec153520d 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -1,6 +1,6 @@ // Type definitions for WinRT // Project: http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx -// Definitions by: TypeScript samples +// Definitions by: TypeScript samples // Definitions: https://github.com/borisyankov/DefinitelyTyped /* ***************************************************************************** diff --git a/yui/yui.d.ts b/yui/yui.d.ts index 006cb13e4e..4172cc123e 100644 --- a/yui/yui.d.ts +++ b/yui/yui.d.ts @@ -1,5 +1,5 @@ // Type definitions for yui 3.14.0 -// Project: https://github.com/yui/yui3/blob/release-3.14.0/src/yui/js +// Project: https://github.com/yui/yui3 // Definitions by: Gia Bảo @ Sân Đình // Definitions: https://github.com/borisyankov/DefinitelyTyped From 4b185848191e70ba5c3f12c94c0b4c6b9686d147 Mon Sep 17 00:00:00 2001 From: craigktreasure Date: Fri, 24 Jan 2014 20:54:12 -0800 Subject: [PATCH 061/240] WinJS.Binding updates from Adam Updated WinRt from @adamhewitt627 as well as his changes for WinJS.Binding. --- winjs/winjs.d.ts | 340 +++++++++++++++++++++++++++-------------------- winrt/winrt.d.ts | 5 + 2 files changed, 202 insertions(+), 143 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index c6a2958cdc..58eb23b354 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -341,7 +341,7 @@ declare module WinJS.Binding { /** * Do not instantiate. A list returned by the createFiltered method. **/ - class FilteredListProjection { + class FilteredListProjection extends ListProjection { //#region Methods /** @@ -387,7 +387,7 @@ declare module WinJS.Binding { /** * Do not instantiate. A list of groups. **/ - class GroupsListProjection { + class GroupsListProjection extends ListBase { //#region Methods /** @@ -427,29 +427,13 @@ declare module WinJS.Binding { /** * Do not instantiate. Sorts the underlying list by group key and within a group respects the position of the item in the underlying list. Returned by createGrouped. **/ - class GroupedSortedListProjection { - //#region Methods - - /** - * Gets a key/data pair for the specified item key. - * @param key The key of the value to retrieve. - * @returns An object that has two properties: key and data. - **/ - getItem(key: string): IKeyDataPair; - - //#endregion Methods - + class GroupedSortedListProjection extends SortedListProjection { //#region Properties /** * Gets a List, which is a projection of the groups that were identified in this list. **/ - groups: List; - - /** - * Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView. - **/ - dataSource: WinJS.UI.IListDataSource; + groups: GroupsListProjection; //#endregion Properties @@ -458,7 +442,7 @@ declare module WinJS.Binding { /** * Represents a list of objects that can be accessed by index or by a string key. Provides methods to search, sort, filter, and manipulate the data. **/ - class List { + class List extends ListBaseWithMutators { //#region Constructors /** @@ -471,6 +455,86 @@ declare module WinJS.Binding { //#endregion Constructors + //#region Methods + + /** + * Gets a key/data pair for the specified list index. + * @param index The index of value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItem(index: number): IKeyDataPair; + + /** + * Gets a key/data pair for the list item key specified. + * @param key The key of the value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItemFromKey(key: string): IKeyDataPair; + + /** + * Gets the index of the first occurrence of a key in a list. + * @param key The key to locate in the list. + * @returns The index of the first occurrence of a key in a list, or -1 if not found. + **/ + indexOfKey(key: string): number; + + /** + * Moves the value at index to the specified position. + * @param index The original index of the value. + * @param newIndex The index of the value after the move. + **/ + move(index: number, newIndex: number): void; + + /** + * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. + * @param index The index of the value that was mutated. + **/ + notifyMutated(index: number): void; + + /** + * Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. + **/ + reverse(): void; + + /** + * Replaces the value at the specified index with a new value. + * @param index The index of the value that was replaced. + * @param newValue The new value. + **/ + setAt(index: number, newValue: T): void; + + /** + * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. + * @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + **/ + sort(sortFunction: (left: T, right: T) => number): void; + + /** + * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the list from which to start removing elements. + * @param howMany The number of elements to remove. + * @param item The elements to insert into the list in place of the deleted elements. + * @returns The deleted elements. + **/ + splice(start: number, howMany?: number, ...item: T[]): T[]; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. + **/ + length: number; + + //#endregion Properties + + } + + /** + * Represents a base class for lists. + **/ + class ListBase { //#region Events /** @@ -485,6 +549,12 @@ declare module WinJS.Binding { **/ oniteminserted(eventInfo: CustomEvent): void; + /** + * An item has been changed locations in the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemmoved(eventInfo: CustomEvent): void; + /** * An item has been mutated. This event occurs as a result of calling the notifyMutated method. * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. @@ -508,19 +578,20 @@ declare module WinJS.Binding { //#region Methods /** - * Adds an event listener. - * @param eventName The event name. - * @param eventCallback The event handler function to associate with this event. + * Adds an event listener to the control. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + * @param useCapture If true, initiates capture, otherwise false. **/ - addEventListener(eventName: string, eventCallback: Function): void; + addEventListener(type: string, listener: Function, useCapture?: boolean): void; /** * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. * @param name The name of the property to which to bind the action. * @param action The function to invoke asynchronously when the property may have changed. - * @returns A reference to this List object. + * @returns A reference to this observableMixin object. **/ - bind(name: string, action: Function): List; + bind(name: string, action: Function): any; /** * Returns a new list consisting of a combination of two arrays. @@ -553,18 +624,13 @@ declare module WinJS.Binding { createSorted(sorter: (left: T, right: T) => number): SortedListProjection; /** - * Raises an event of the specified type and with additional properties. + * Raises an event of the specified type and with the specified additional properties. * @param type The type (name) of the event. * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. - * @returns true if preventDefault was called on the event, otherwise false. + * @returns true if preventDefault was called on the event. **/ dispatchEvent(type: string, eventProperties: any): boolean; - /** - * Disconnects a WinJS.Binding.List projection from its underlying WinJS.Binding.List. It's only important to call this method when the WinJS.Binding.List projection and the WinJS.Binding.List have different lifetimes. (Call this method on the WinJS.Binding.List projection, not the underlying WinJS.Binding.List.) - **/ - dispose(): void; - /** * Checks whether the specified callback function returns true for all elements in a list. * @param callback A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached. @@ -595,34 +661,13 @@ declare module WinJS.Binding { **/ getAt(index: number): T; - /** - * Gets a key/data pair for the specified list index. - * @param index The index of value to retrieve. - * @returns An object with .key and .data properties. - **/ - getItem(index: number): IKeyDataPair; - - /** - * Gets a key/data pair for the list item key specified. - * @param key The key of the value to retrieve. - * @returns An object with .key and .data properties. - **/ - getItemFromKey(key: string): IKeyDataPair; - /** * Gets the index of the first occurrence of the specified value in a list. * @param searchElement The value to locate in the list. * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0. * @returns The index of the first occurrence of a value in a list or -1 if not found. **/ - indexOf(searchElement: any, fromIndex?: number): number; - - /** - * Gets the index of the first occurrence of a key in a list. - * @param key The key to locate in the list. - * @returns The index of the first occurrence of a key in a list, or -1 if not found. - **/ - indexOfKey(key: string): number; + indexOf(searchElement: T, fromIndex?: number): number; /** * Returns a string consisting of all the elements of a list separated by the specified separator string. @@ -647,13 +692,6 @@ declare module WinJS.Binding { **/ map(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): G[]; - /** - * Moves the value at index to the specified position. - * @param index The original index of the value. - * @param newIndex The index of the value after the move. - **/ - move(index: number, newIndex: number): void; - /** * Notifies listeners that a property value was updated. * @param name The name of the property that is being updated. @@ -661,32 +699,13 @@ declare module WinJS.Binding { * @param oldValue The old value for the property. * @returns A promise that is completed when the notifications are complete. **/ - notify(name: string, newValue: T, oldValue: T): Promise; - - /** - * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. - * @param index The index of the value that was mutated. - **/ - notifyMutated(index: number): void; + notify(name: string, newValue: any, oldValue: any): Promise; /** * Forces the list to send a reload notification to any listeners. **/ notifyReload(): void; - /** - * Removes the last element from a list and returns it. - * @returns The last element from the list. - **/ - pop(): T; - - /** - * Appends new element(s) to a list, and returns the new length of the list. - * @param value The element to insert at the end of the list. - * @returns The new length of the list. - **/ - push(value: T): number; - /** * Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list. @@ -704,29 +723,12 @@ declare module WinJS.Binding { reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T): T; /** - * Removes an event listener. - * @param eventName The event name. - * @param eventCallback The event handler function to associate with this event. + * Removes an event listener from the control. + * @param type The type (name) of the event. + * @param listener The listener to remove. + * @param useCapture true if capture is to be initiated, otherwise false. **/ - removeEventListener(eventName: string, eventCallback: Function): void; - - /** - * Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. - **/ - reverse(): void; - - /** - * Replaces the value at the specified index with a new value. - * @param index The index of the value that was replaced. - * @param newValue The new value. - **/ - setAt(index: number, newValue: T): void; - - /** - * Removes the first element from a list and returns it. - * @returns The first element from the list. - **/ - shift(): T; + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; /** * Extracts a section of a list and returns a new list. @@ -734,7 +736,7 @@ declare module WinJS.Binding { * @param end The index that specifies the end of the section. * @returns Returns a section of list. **/ - slice(begin: number, end: number): List; + slice(begin: number, end: number): T[]; /** * Checks whether the specified callback function returns true for any element of a list. @@ -744,35 +746,13 @@ declare module WinJS.Binding { **/ some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - /** - * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. - * @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. - **/ - sort(sortFunction: (left: T, right: T) => number): void; - - /** - * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the list from which to start removing elements. - * @param howMany The number of elements to remove. - * @param item The elements to insert into the list in place of the deleted elements. - * @returns The deleted elements. - **/ - splice(start: number, howMany?: number, item?: T[]): T[]; - /** * Removes one or more listeners from the notification list for a given property. * @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed. * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. * @returns This object is returned. **/ - unbind(name: string, action?: Function): List; - - /** - * Appends new element(s) to a list, and returns the new length of the list. - * @param value The element to insert at the start of the list. - * @returns The new length of the list. - **/ - unshift(value: T): number; + unbind(name: string, action: Function): any; //#endregion Methods @@ -784,17 +764,83 @@ declare module WinJS.Binding { dataSource: WinJS.UI.IListDataSource; /** - * Gets a List that is a projection of the groups that were identified in this list. This property is available only for GroupsListProjection objects. + * Indicates that the object is compatibile with declarative processing. **/ - groups: List; - - /** - * Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. - **/ - length: number; + static supportedForProcessing: boolean; //#endregion Properties + } + /** + * Represents a base class for normal list modifying operations. + **/ + class ListBaseWithMutators extends ListBase { + //#region Methods + + /** + * Removes the last element from a list and returns it. + * @returns The last element from the list. + **/ + pop(): T; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the end of the list. + * @returns The new length of the list. + **/ + push(value: T): number; + + /** + * Removes the first element from a list and returns it. + * @returns The first element from the list. + **/ + shift(): T; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the start of the list. + * @returns The new length of the list. + **/ + unshift(value: T): number; + + //#endregion Methods + } + + /** + * Represents a base class for list projections. + **/ + class ListProjection extends ListBaseWithMutators { + //#region Methods + + /** + * Disconnects a WinJS.Binding.List projection from its underlying WinJS.Binding.List. It's only important to call this method when the WinJS.Binding.List projection and the WinJS.Binding.List have different lifetimes. (Call this method on the WinJS.Binding.List projection, not the underlying WinJS.Binding.List.) + **/ + dispose(): void; + + /** + * Gets a key/data pair for the specified key. + * @param key The key of the value to retrieve. + * @returns An object with two properties: key and data. + **/ + getItemFromKey(key: string): IKeyDataPair; + + /** + * Moves the value at index to position newIndex. + * @param index The original index of the value. + * @param newIndex The index of the value after the move. + **/ + move(index: number, newIndex: number): void; + + /** + * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the list from which to start removing elements. + * @param howMany The number of elements to remove. + * @param item The elements to insert into the list in place of the deleted elements. + * @returns The deleted elements. + **/ + splice(start: number, howMany?: number, ...item: T[]): T[]; + + //#endregion Methods } /** @@ -908,7 +954,7 @@ declare module WinJS.Binding { /** * Do not instantiate. Returned by the createSorted method. **/ - class SortedListProjection { + class SortedListProjection extends ListProjection { //#region Methods /** @@ -1727,7 +1773,7 @@ declare module WinJS.UI.Animation { * @param options Optional. Set this value to { mechanism: "transition" } to play the animation using CSS transitions instead of the default CSS animations. In some cases this can result in improved performance. * @returns An object that completes when the animation is finished. **/ - function enterContent(incoming: any, offset: any, options: any): Promise; + function enterContent(incoming: any, offset: any, options?: any): Promise; /** * Performs an animation that shows a new page of content, either when transitioning between pages in a running app or when displaying the first content in a newly launched app. @@ -6592,7 +6638,7 @@ declare module WinJS.UI { * Loads a fragment of the SettingsFlyout. Your app calls this when the user invokes a settings command and the WinJS.Application.onsettings event occurs. * @param e An object that contains information about the event, received from the WinJS.Application.onsettings event. The detail property of this object contains the applicationcommands sub-property that you set to an array of settings commands. You then populate the SettingsFlyout with these commands by a call to populateSettings. **/ - populateSettings(e: CustomEvent): void; + static populateSettings(e: CustomEvent): void; /** * Removes an event handler that the addEventListener method registered. @@ -6603,16 +6649,21 @@ declare module WinJS.UI { removeEventListener(type: string, listener: Function, useCapture?: boolean): void; /** - * Shows the SettingsPane UI, if hidden, regardless of other state. + * Shows the SettingsPane UI, if hidden. **/ show(): void; + /** + * Shows the SettingsPane UI, if hidden, regardless of other state. + **/ + static show(): void; + /** * Show the Settings flyout using the Settings element identifier (ID) and the path of the page that contains the Settings element. * @param id The ID of the Settings element. * @param path The path of the page that contains the Settings element. **/ - showSettings(id: string, path: any): void; + static showSettings(id: string, path: any): void; //#endregion Methods @@ -7228,14 +7279,17 @@ declare module WinJS.UI { /** * Applies declarative control binding to all elements, starting at the specified root element. * @param rootElement The element at which to start applying the binding. If this parameter is not specified, the binding is applied to the entire document. + * @param skipRoot If true, the elements to be bound skip the specified root element and include only the children. + * @returns A promise that is fulfilled when binding has been applied to all the controls. **/ - function processAll(rootElement?: Element): void; + function processAll(rootElement?: Element, skipRoot?: boolean): Promise; /** * Applies declarative control binding to the specified element. * @param element The element to bind. + * @returns A promise that is fulfilled after the control is activated. The value of the promise is the control that is attached to element. **/ - function process(element: Element): void; + function process(element: Element): Promise; /** * Walks the DOM tree from the given element to the root of the document. Whenever a selector scope is encountered, this method performs a lookup within that scope for the specified selector string. The first matching element is returned. diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index 9206c9bd99..ee14003033 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -14730,5 +14730,10 @@ declare module Windows.Foundation { done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; cancel(): void; + + onerror?(eventInfo: CustomEvent): void; + addEventListener?(type: string, listener: Function, capture?: boolean): void; + dispatchEvent?(type: string, details: any): boolean; + removeEventListener?(eventType: string, listener: Function, capture?: boolean): void; } } From ada58339f467b8935e667ebbbb7ff51a25d638ee Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Sat, 25 Jan 2014 15:11:53 -0500 Subject: [PATCH 062/240] Update slick.headerbuttons.d.ts --- slickgrid/slick.headerbuttons.d.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/slickgrid/slick.headerbuttons.d.ts b/slickgrid/slick.headerbuttons.d.ts index c4d928777f..9ac7f86db3 100644 --- a/slickgrid/slick.headerbuttons.d.ts +++ b/slickgrid/slick.headerbuttons.d.ts @@ -1,6 +1,13 @@ +// Type definitions for SlickGrid HeaderButtons Plugin 2.1.0 +// Project: https://github.com/mleibman/SlickGrid +// Definitions by: Derek Cicerone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + declare module Slick { - export interface Column { + export interface Column { header: Header; } @@ -19,9 +26,9 @@ declare module Slick { export module Plugins { - export class HeaderButtons extends Plugin { + export class HeaderButtons extends Plugin { constructor(); - public onCommand: Slick.Event; + public onCommand: Event; } } } From 2f9a243b117bf31df06ef8a7ea1d634b73512398 Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Sun, 26 Jan 2014 15:32:33 +0000 Subject: [PATCH 063/240] jQuery: JSDoc'd extend/globalEval/grep/inArray --- jquery/jquery.d.ts | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 3c4220c153..69e80ce213 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -893,13 +893,47 @@ interface JQueryStatic { callback: (indexInArray: any, valueOfElement: any) => any ): any; - extend(target: any, ...objs: any[]): any; - extend(deep: boolean, target: any, ...objs: any[]): any; + /** + * Merge the contents of two or more objects together into the first object. + * + * @param target An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument. + * @param object1 An object containing additional properties to merge in. + * @param objectN Additional objects containing properties to merge in. + */ + extend(target: any, object1?: any, ...objectN: any[]): any; + /** + * Merge the contents of two or more objects together into the first object. + * + * @param deep If true, the merge becomes recursive (aka. deep copy). + * @param target The object to extend. It will receive the new properties. + * @param object1 An object containing additional properties to merge in. + * @param objectN Additional objects containing properties to merge in. + */ + extend(deep: boolean, target: any, object1?: any, ...objectN: any[]): any; + /** + * Execute some JavaScript code globally. + * + * @param code The JavaScript code to execute. + */ globalEval(code: string): any; + /** + * Finds the elements of an array which satisfy a filter function. The original array is not affected. + * + * @param array The array to search through. + * @param func The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value. this will be the global window object. + * @param invert If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false. + */ grep(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: boolean): T[]; + /** + * Search for a specified value within an array and return its index (or -1 if not found). + * + * @param value The value to search for. + * @param array An array through which to search. + * @param fromIndex he index of the array at which to begin the search. The default is 0, which will search the whole array. + */ inArray(value: T, array: T[], fromIndex?: number): number; isArray(obj: any): boolean; From bf7966cf6822b9807ea1ebd8df5069101115b4ac Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Sun, 26 Jan 2014 15:55:14 +0000 Subject: [PATCH 064/240] jQuery: all the is's --- jquery/jquery-tests.ts | 2 +- jquery/jquery.d.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 6981118e15..0516fa82c2 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2218,7 +2218,7 @@ function test_isEmptyObject() { jQuery.isEmptyObject({ foo: "bar" }); } -function test_isFuction() { +function test_isFunction() { function stub() { }; var objs: any[] = [ function () { }, diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 69e80ce213..b941077c95 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -936,12 +936,47 @@ interface JQueryStatic { */ inArray(value: T, array: T[], fromIndex?: number): number; + /** + * Determine whether the argument is an array. + * + * @param obj Object to test whether or not it is an array. + */ isArray(obj: any): boolean; + /** + * Check to see if an object is empty (contains no enumerable properties). + * + * @param obj The object that will be checked to see if it's empty. + */ isEmptyObject(obj: any): boolean; + /** + * Determine if the argument passed is a Javascript function object. + * + * @param obj Object to test whether or not it is a function. + */ isFunction(obj: any): boolean; + /** + * Determines whether its argument is a number. + * + * @param obj The value to be tested. + */ isNumeric(value: any): boolean; + /** + * Check to see if an object is a plain object (created using "{}" or "new Object"). + * + * @param obj The object that will be checked to see if it's a plain object. + */ isPlainObject(obj: any): boolean; + /** + * Determine whether the argument is a window. + * + * @param obj Object to test whether or not it is a window. + */ isWindow(obj: any): boolean; + /** + * Check to see if a DOM node is within an XML document (or is an XML document). + * + * @param node he DOM node that will be checked to see if it's in an XML document. + */ isXMLDoc(node: Node): boolean; makeArray(obj: any): any[]; From df1b0f4fc7f3248bf447b257a5cb92b15713b3f5 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 27 Jan 2014 02:35:25 +0100 Subject: [PATCH 065/240] Created definitions for 'semver' https://github.com/isaacs/node-semver --- README.md | 1 + semver/semver-tests.ts | 92 ++++++++++++++++++++++++++++++++++++++++++ semver/semver.d.ts | 75 ++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 semver/semver-tests.ts create mode 100644 semver/semver.d.ts diff --git a/README.md b/README.md index 8183ef1c42..54b15f69d7 100755 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ List of Definitions * [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Semver](https://github.com/isaacs/node-semver) (by [Bart van der Schoor](https://github.com/Bartvds)) * [Sencha Touch](http://www.sencha.com/products/touch/) (by [Brian Kotek](https://github.com/brian428)) * [SharePoint](http://sptypescript.codeplex.com) (by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru) and [Andrey Markeev](http://markeev.com)) * [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/semver/semver-tests.ts b/semver/semver-tests.ts new file mode 100644 index 0000000000..009a47daf2 --- /dev/null +++ b/semver/semver-tests.ts @@ -0,0 +1,92 @@ +/// + +var obj:Object; +var bool:boolean; +var num:number; +var str:string; +var x:any = null; +var arr:any[]; +var exp:RegExp; +var strArr:string[]; +var numArr:string[]; + +var mod:typeof SemverModule; + +var v1:string, v2:string; +var version:string; +var versions:string[]; +var loose:boolean; + +str = mod.valid(str); + +str = mod.valid(str, loose); +//TODO maybe add an enum for release? +str = mod.inc(str, str, loose); + +//Comparison +bool = mod.gt(v1, v2, loose); +bool = mod.gte(v1, v2, loose); +bool = mod.lt(v1, v2, loose); +bool = mod.lte(v1, v2, loose); +bool = mod.eq(v1, v2, loose); +bool = mod.neq(v1, v2, loose); +bool = mod.cmp(v1, x, v2, loose); +num = mod.compare(v1, v2, loose); +num = mod.rcompare(v1, v2, loose); + +//Ranges +str = mod.validRange(str, loose); +str = mod.satisfies(version, str, loose); +str = mod.maxSatisfying(versions, str, loose); +bool = mod.gtr(version, str, loose); +bool = mod.ltr(version, str, loose); +bool = mod.outside(version, str, str, loose); + +var ver = new mod.Semver(str, bool); +str = ver.raw; +bool = ver.loose; +str = ver.format(); +str = ver.inspect(); +str = ver.toString(); + +num = ver.major; +num = ver.minor; +num = ver.patch; +str = ver.version; +strArr = ver.build; +strArr = ver.prerelease; + +num = ver.compare(ver); +num = ver.compareMain(ver); +num = ver.comparePre(ver); +ver = ver.inc(str); + + +var comp = new SemverModule.Comparator(str, bool); +str = comp.raw; +bool = comp.loose; +str = comp.format(); +str = comp.inspect(); +str = comp.toString(); + +ver = comp.semver; +str = comp.operator; +bool = comp.value; +comp.parse(str); +bool = comp.test(ver); + + +var range = new SemverModule.Range(str, bool); +str = range.raw; +bool = range.loose; +str = range.format(); +str = range.inspect(); +str = range.toString(); + +bool = range.test(ver); + +var sets:SemverModule.Comparator[][]; +sets = range.set(); + +var lims:SemverModule.Comparator[]; +lims = range.parseRange(str); diff --git a/semver/semver.d.ts b/semver/semver.d.ts new file mode 100644 index 0000000000..67f536af5c --- /dev/null +++ b/semver/semver.d.ts @@ -0,0 +1,75 @@ +// Type definitions for semver v2.2.1 +// Project: https://github.com/isaacs/node-semver +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module SemverModule { + + function valid(v:string, loose?:boolean):string; // Return the parsed version, or null if it's not valid. + //TODO maybe add an enum for release? + function inc(v:string, release:string, loose?:boolean):string; // Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid. + + //Comparison + function gt(v1:string, v2:string, loose?:boolean):boolean; // v1 > v2 + function gte(v1:string, v2:string, loose?:boolean):boolean; // v1 >= v2 + function lt(v1:string, v2:string, loose?:boolean):boolean; // v1 < v2 + function lte(v1:string, v2:string, loose?:boolean):boolean; // v1 <= v2 + function eq(v1:string, v2:string, loose?:boolean):boolean; // v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings. + function neq(v1:string, v2:string, loose?:boolean):boolean; // v1 != v2 The opposite of eq. + function cmp(v1:string, comparator:any, v2:string, loose?:boolean):boolean; // Pass in a comparison string, and it'll call the corresponding function above. "===" and "!==" do simple string comparison, but are included for completeness. Throws if an invalid comparison string is provided. + function compare(v1:string, v2:string, loose?:boolean):number; // Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort(). + function rcompare(v1:string, v2:string, loose?:boolean):number; // The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort(). + + //Ranges + function validRange(range:string, loose?:boolean):string; // Return the valid range or null if it's not valid + function satisfies(version:string, range:string, loose?:boolean):string; // Return true if the version satisfies the range. + function maxSatisfying(versions:string[], range:string, loose?:boolean):string; // Return the highest version in the list that satisfies the range, or null if none of them do. + function gtr(version:string, range:string, loose?:boolean):boolean; // Return true if version is greater than all the versions possible in the range. + function ltr(version:string, range:string, loose?:boolean):boolean; // Return true if version is less than all the versions possible in the range. + function outside(version:string, range:string, hilo:string, loose?:boolean):boolean; // Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.) + + class SemverBase { + raw:string; + loose:boolean; + format():string; + inspect():string; + toString():string; + } + + class Semver extends SemverBase { + constructor(version:string, loose?:boolean); + + major:number; + minor:number; + patch:number; + version:string; + build:string[]; + prerelease:string[]; + + compare(other:Semver):number; + compareMain(other:Semver):number; + comparePre(other:Semver):number; + inc(release:string):Semver; + } + + class Comparator extends SemverBase { + constructor(comp:string, loose?:boolean); + + semver:Semver; + operator:string; + value:boolean; + parse(comp:string) :void; + test(version:Semver):boolean; + } + + class Range extends SemverBase { + constructor(range:string, loose?:boolean); + + set():Comparator[][]; + parseRange(range:string):Comparator[]; + test(version:Semver):boolean; + } +} +declare module "semver" { +export = SemverModule; +} From 3fff40427e0a47337b33a9ae5ac064f3ecc5c194 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 27 Jan 2014 02:25:04 +0100 Subject: [PATCH 066/240] Created definitions for 'tv4' https://github.com/geraintluff/tv4 --- README.md | 1 + tv4/tv4-tests.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ tv4/tv4.d.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 tv4/tv4-tests.ts create mode 100644 tv4/tv4.d.ts diff --git a/README.md b/README.md index 8183ef1c42..4048c327df 100755 --- a/README.md +++ b/README.md @@ -235,6 +235,7 @@ List of Definitions * [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Swiper](http://www.idangero.us/sliders/swiper) (by [Sebastián Galiano](https://github.com/sgaliano)) * [SwipeView](http://cubiq.org/swipeview) (by [Boris Yankov](https://github.com/borisyankov)) +* [TV4](https://github.com/geraintluff/tv4) (by [Bart van der Schoor](https://github.com/Bartvds)) * [Tags Manager](http://welldonethings.com/tags/manager) (by [Vincent Bortone](https://github.com/vbortone)) * [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com)) * [three.js](http://mrdoob.github.com/three.js/) (by [Kon](http://phyzkit.net/)) diff --git a/tv4/tv4-tests.ts b/tv4/tv4-tests.ts new file mode 100644 index 0000000000..2768d9f5fe --- /dev/null +++ b/tv4/tv4-tests.ts @@ -0,0 +1,43 @@ +/// + +var str:string; +var strArr:string[]; +var bool:boolean; +var num:number; +var obj:any; +var tv4:TV4; +var err:TV4Error; +var errs:TV4Error[]; +var single:TV4SingleResult; +var multi:TV4MultiResult; + +single = tv4.validateResult(obj, obj); +bool = single.valid; +strArr = single.missing; +err = single.error; + +num = err.code; +str = err.message; +str = err.dataPath; +str = err.schemaPath; + +multi = tv4.validateMultiple(obj, obj); +bool = multi.valid; +strArr = multi.missing; +errs = multi.errors; + +bool = tv4.addSchema(str, obj); +obj = tv4.getSchema(str); +obj = tv4.normSchema(str, str); +str = tv4.resolveUrl(str, str); + +tv4 = tv4.freshApi(); +tv4.dropSchemas(); +tv4.reset(); + +strArr = tv4.getMissingUris(/abc/); +strArr = tv4.getSchemaUris(/abc/); +obj = tv4.getSchemaMap()[str]; +num = tv4.errorCodes['bla']; + +num = tv4.errorCodes['MY_NAME']; diff --git a/tv4/tv4.d.ts b/tv4/tv4.d.ts new file mode 100644 index 0000000000..702d3c3bc6 --- /dev/null +++ b/tv4/tv4.d.ts @@ -0,0 +1,47 @@ +// Type definitions for Tiny Validator tv4 1.0.6 +// Project: https://github.com/geraintluff/tv4 +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface TV4ErrorCodes { + [key:string]:number; +} +interface TV4Error { + code:number; + message:string; + dataPath:string; + schemaPath:string; +} +interface TV4SchemaMap { + [uri:string]:any; +} +interface TV4BaseResult { + missing:string[]; + valid:boolean; +} +interface TV4SingleResult extends TV4BaseResult { + error:TV4Error; +} +interface TV4MultiResult extends TV4BaseResult { + errors:TV4Error[]; +} +interface TV4 { + validateResult(data:any, schema:any):TV4SingleResult; + validateMultiple(data:any, schema:any):TV4MultiResult; + + addSchema(uri:string, schema:any):boolean; + getSchema(uri:string):any; + normSchema(schema:any, baseUri:string):any; + resolveUrl(base:string, href:string):string; + freshApi():TV4; + dropSchemas():void; + reset():void; + + getMissingUris(exp?:RegExp):string[]; + getSchemaUris(exp?:RegExp):string[]; + getSchemaMap():TV4SchemaMap; + errorCodes:TV4ErrorCodes; +} +declare module "tv4" { +export = TV4; +} From 74189cca97f90067563d776252a5ac678688018a Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 27 Jan 2014 02:27:00 +0100 Subject: [PATCH 067/240] Created definitions for 'q-io' https://github.com/kriskowal/q-io remaining issues: * not sure about how to export module * describing some overloads is problematic * missing a few definitions for less-used members --- README.md | 2 + q-io/Q-io-tests.ts | 200 +++++++++++++++++++++++++++++++++++ q-io/Q-io.d.ts | 257 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 459 insertions(+) create mode 100644 q-io/Q-io-tests.ts create mode 100644 q-io/Q-io.d.ts diff --git a/README.md b/README.md index 8183ef1c42..8c892eba42 100755 --- a/README.md +++ b/README.md @@ -207,6 +207,8 @@ List of Definitions * [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH)) * [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/)) * [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar) +* [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds)) * [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) * [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo)) * [Rickshaw](http://code.shutterstock.com/rickshaw/) (by [Blake Niemyjski](https://github.com/niemyjski)) diff --git a/q-io/Q-io-tests.ts b/q-io/Q-io-tests.ts new file mode 100644 index 0000000000..f4ac32e9e5 --- /dev/null +++ b/q-io/Q-io-tests.ts @@ -0,0 +1,200 @@ +/// +/// + +var fs:typeof QioFS = require('q-io/fs'); +var http:typeof QioHTTP = require('q-io/http'); + +var bool:boolean; +var num:number; +var x:any; +var path:string; +var buffer:NodeBuffer; +var str:string; +var strArr:string[]; +var source:string; +var target:string; +var type:string; + +var options:any; +var strArrQ:Q.Promise; +var voidQ:Q.Promise; +var anyQ:Q.Promise; +var strQ:Q.Promise; +var boolQ:Q.Promise; +var dateQ:Q.Promise; +var bufferQ:Q.Promise; + +var statsQ:Q.Promise; +var readQ:Q.Promise; +var writeQ:Q.Promise; + +var headers:QioHTTP.Headers; +var reader:Qio.Reader; +var writer:Qio.Writer; +var stream:Qio.Stream; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fs.open(path, options).then((x) => { +}); +//fs.open(path, options):Q.Promise; +//fs.open(path, options):Q.Promise; +//fs.open(path, options):Q.Promise; + +//TODO how to define the multiple return types? use any for now? +anyQ = fs.read(path, options); +//strQ = fs.read(path, options); +//fs.read(path, options):Q.Promise; + +voidQ = fs.write(path, buffer, options); +voidQ = fs.write(path, str, options); + +voidQ = fs.append(path, buffer, options); +voidQ = fs.append(path, str, options); + +voidQ = fs.copy(source, target); +voidQ = fs.copyTree(source, target); + +strArrQ = fs.list(path); +strArrQ = fs.listTree(path, (path, x) => { + return true; +}); +strArrQ = fs.listDirectoryTree(path); + +voidQ = fs.makeDirectory(path, str); +voidQ = fs.makeDirectory(path, num); +voidQ = fs.makeTree(path, str); +voidQ = fs.makeTree(path, num); + +voidQ = fs.remove(path); +voidQ = fs.removeTree(path); + +voidQ = fs.rename(source, target); +voidQ = fs.move(source, target); + +voidQ = fs.link(source, target); + +voidQ = fs.symbolicCopy(source, target, type); +voidQ = fs.symbolicLink(target, str, type); + +voidQ = fs.chown(path, num, num); +voidQ = fs.chmod(path, str); +voidQ = fs.chmod(path, num); + +statsQ = fs.stat(path) +statsQ = fs.statLink(path); +statsQ = fs.statFd(num); + +boolQ = fs.exists(path); + +boolQ = fs.isFile(path); +boolQ = fs.isDirectory(path); +boolQ = fs.isSymbolicLink(path); + +dateQ = fs.lastModified(path); +dateQ = fs.lastAccessed(path); + +strArr = fs.split(path); +str = fs.join(str, str); +str = fs.join(strArr); +str = fs.resolve(str, str); +str = fs.resolve(strArr); +str = fs.normal(str, str); +str = fs.normal(strArr); +str = fs.absolute(path); + +strQ = fs.canonical(path); +strQ = fs.readLink(path); + +bool = fs.contains(str, str); + +strQ = fs.relative(source, target); + +str = fs.relativeFromFile(source, target); +str = fs.relativeFromDirectory(source, target); + +bool = fs.isAbsolute(path); +bool = fs.isRelative(path); +bool = fs.isRoot(path); + +str = fs.root(path); +str = fs.directory(path); +str = fs.base(path, str); +str = fs.extension(path); + +//this should return a q-io/fs-mock MockFS +//fs = fs.reroot(str); +x = fs.toObject(str); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +var request:QioHTTP.Request; +var headers:QioHTTP.Headers; + +str = request.url; +str = request.path; +str = request.scriptName; +str = request.pathInfo; +strArr = request.version; +str = request.method; +str = request.scheme; + +str = request.host; +num = request.port; +str = request.remoteHost; +num = request.remotePort; + +headers = request.headers; +x = request.agent; +x = request.body; +x = request.node; + +str = headers['foo']; + +var response:QioHTTP.Response; +var responseQ:Q.Promise; + +responseQ = http.request(request); +responseQ = http.request(str); + +strQ = http.read(request); +strQ = http.read(str); + +request = http.normalizeRequest(request); +request = http.normalizeRequest(str); +response = http.normalizeResponse(response); + +num = response.status; +headers = response.headers; +reader = response.body; +response.onclose = () => { + +}; +x = response.node; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +strQ = reader.read(str); +bufferQ = reader.read(); +reader.close(); +x = reader.node; +voidQ = reader.forEach((chunk:any) => { + return anyQ; +}); + +writer.write(str); +writer.write(buffer); +writer.flush(); +writer.close(); +x = writer.node; + +strQ = stream.read(str); +bufferQ = stream.read(); +stream.write(str); +stream.write(buffer); +stream.flush(); +stream.close(); +x = stream.node; +voidQ = reader.forEach((chunk:any) => { + return anyQ; +}); diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts new file mode 100644 index 0000000000..9f81500461 --- /dev/null +++ b/q-io/Q-io.d.ts @@ -0,0 +1,257 @@ +// Type definitions for Q-io +// Project:https://github.com/kriskowal/q-io +// Definitions by:Bart van der Schoor +// Definitions:https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +//TODO add support for q-io/http-apps +//TODO add verified support for q-io/fs-mock +//TODO fix Readers/Writers properly +//TODO find solution for overloaded return types (QioFS.open/QioFS.read) +// for some ideas see https://typescript.codeplex.com/discussions/461587#post1105930 + +declare module QioFS { + + //TODO how to define the multiple return types? use any for now? + export function open(path:string, options?:any):Q.Promise; + //export function open(path:string, options?:any):Q.Promise; + //export function open(path:string, options?:any):Q.Promise; + //export function open(path:string, options?:any):Q.Promise; + + //TODO how to define the multiple return types? use any for now? + export function read(path:string, options?:any):Q.Promise; + //export function read(path:string, options?:any):Q.Promise; + //export function read(path:string, options?:any):Q.Promise; + + export function write(path:string, content:NodeBuffer, options?:any):Q.Promise; + export function write(path:string, content:string, options?:any):Q.Promise; + + export function append(path:string, content:NodeBuffer, options?:any):Q.Promise; + export function append(path:string, content:string, options?:any):Q.Promise; + + export function copy(source:string, target:string):Q.Promise; + export function copyTree(source:string, target:string):Q.Promise; + + export function list(path:string):Q.Promise; + export function listTree(path:string, guard?:(path:string, stat:any) => boolean):Q.Promise; + export function listDirectoryTree(path:string):Q.Promise; + + export function makeDirectory(path:string, mode?:string):Q.Promise; + export function makeDirectory(path:string, mode?:number):Q.Promise; + export function makeTree(path:string, mode?:string):Q.Promise; + export function makeTree(path:string, mode?:number):Q.Promise; + + export function remove(path:string):Q.Promise; + export function removeTree(path:string):Q.Promise; + + export function rename(source:string, target:string):Q.Promise; + export function move(source:string, target:string):Q.Promise; + + export function link(source:string, target:any):Q.Promise; + + export function symbolicCopy(source:string, target:string, type:string):Q.Promise; + export function symbolicLink(target:string, link:string, type:string):Q.Promise; + + export function chown(path:string, uid:number, gid:number):Q.Promise; + export function chmod(path:string, mode?:string):Q.Promise; + export function chmod(path:string, mode?:number):Q.Promise; + + export function stat(path:string):Q.Promise; + export function statLink(path:string):Q.Promise; + export function statFd(fd:number):Q.Promise; + + export function exists(path:string):Q.Promise; + + export function isFile(path:string):Q.Promise; + export function isDirectory(path:string):Q.Promise; + export function isSymbolicLink(path:string):Q.Promise; + + export function lastModified(path:string):Q.Promise; + export function lastAccessed(path:string):Q.Promise; + + export function split(path:string):string[]; + export function join(...paths:string[]):string; + export function join(paths:string[]):string; + export function resolve(...path:string[]):string; + export function resolve(paths:string[]):string; + export function normal(...path:string[]):string; + export function normal(paths:string[]):string; + export function absolute(path:string):string; + + export function canonical(path:string):Q.Promise; + export function readLink(path:string):Q.Promise; + + export function contains(parent:string, child:string):boolean; + + export function relative(source:string, target:string):Q.Promise; + + export function relativeFromFile(source:string, target:string):string; + export function relativeFromDirectory(source:string, target:string):string; + + export function isAbsolute(path:string):boolean; + export function isRelative(path:string):boolean; + export function isRoot(path:string):boolean; + + export function root(path:string):string; + export function directory(path:string):string; + export function base(path:string, extension:string):string; + export function extension(path:string):string; + + //this should return a q-io/fs-mock MockFS + export function reroot(path:string):typeof QioFS; + + export function toObject(path:string):{[path:string]:NodeBuffer}; + + //listed but not implemented by Q-io + //export function glob(pattern):Q.Promise; + //export function match(pattern, path:string):Q.Promise; + + //TODO link this to node.js FS module (no lazy clones) + interface Stats { + node:NodeStats; + size:number; + } + interface NodeStats { + isFile():boolean; + isDirectory():boolean; + isBlockDevice():boolean; + isCharacterDevice():boolean; + isSymbolicLink():boolean; + isFIFO():boolean; + isSocket():boolean; + node:NodeStats; + dev:number; + ino:number; + mode:number; + nlink:number; + uid:number; + gid:number; + rdev:number; + size:number; + blksize:number; + blocks:number; + atime:Date; + mtime:Date; + ctime:Date; + } +} + +declare module QioHTTP { + export function request(request:Request):Q.Promise; + export function request(url:string):Q.Promise; + + export function read(request:Request):Q.Promise; + export function read(url:string):Q.Promise; + + export function normalizeRequest(request:Request):Request; + export function normalizeRequest(url:string):Request; + export function normalizeResponse(response:Response):Response; + + interface Request { + url:string; + path:string; + scriptName:string; + pathInfo:string; + version:string[]; + method:string; + scheme:string; + + host:string; + port:number; + remoteHost:string; + remotePort:number; + + headers:Headers; + agent:any; + body:any; + node:any; + } + interface Response { + status:number; + headers:Headers; + body:Qio.Reader + onclose:() => void; + node:any; + } + interface Headers { + [name:string]:any; + [name:string]:any[]; + } + interface Body extends Qio.Stream { + + } + interface Application { + (req:Request):Q.Promise; + } +} + +declare module Qio { + interface ForEachCallback { + (chunk:NodeBuffer):Q.Promise; + (chunk:string):Q.Promise; + } + interface ForEach { + forEach(callback:ForEachCallback):Q.Promise; + } + + interface Reader extends ForEach { + read(charset:string):Q.Promise; + read():Q.Promise; + close():void; + node:ReadableStream; + } + interface Writer { + write(content:string):void; + write(content:NodeBuffer):void; + flush():Q.Promise; + close():void; + destroy():void; + node:WritableStream; + } + + interface Stream { + read(charset:string):Q.Promise; + read():Q.Promise; + write(content:string):void; + write(content:NodeBuffer):void; + flush():Q.Promise; + close():void; + destroy():void; + node:any; + } + + interface BufferReader extends QioBufferReader { + + } +} +interface QioBufferReader { + new ():Qio.Reader; + read(stream:Qio.Reader, charset:string):string; + read(stream:Qio.Reader):NodeBuffer; + join(buffers:NodeBuffer[]):NodeBuffer; +} +interface QioBufferWriter { + (writer:NodeBuffer):Qio.Writer; + Writer:Qio.Writer; +} +interface QioBufferStream { + (buffer:NodeBuffer, encoding:string):Qio.Stream +} + +declare module "q-io/http" { +export = QioHTTP; +} +declare module "q-io/fs" { +export = QioFS; +} +declare module "q-io/reader" { +export = QioBufferReader; +} +declare module "q-io/writer" { +export = QioBufferWriter; +} +declare module "q-io/buffer-stream" { +export = QioBufferStream; +} From dd45f9a19463b6599d5a20abb4a5e06f1a3ec2b4 Mon Sep 17 00:00:00 2001 From: KhodeN Date: Mon, 27 Jan 2014 20:56:50 +1100 Subject: [PATCH 068/240] Update sugar.d.ts update Array.min, Array.max and Array.most methods. They could be called without arguments at all (Argument 'map' is optional). --- sugar/sugar.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 76ec222b26..ca21b3e7c2 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -2551,7 +2551,7 @@ interface Array { * return n['a']; * }); -> {a:3} **/ - max(map: string): T; + max(map?: string): T; /** * @see max @@ -2587,7 +2587,7 @@ interface Array { * return n['a']; * }); -> [{a:2}] **/ - min(map: string): T; + min(map?: string): T; /** * @see min If true return all min values in the array, default = false. @@ -2619,7 +2619,7 @@ interface Array { * return n.age; * }); -> [{age:12,name:'bob'},{age:12,name:'ted'}] **/ - most(map: string): T[]; + most(map?: string): T[]; /** * @see most From c4bc4c01aa3915715a4fab51e4f4835a82551620 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 27 Jan 2014 11:33:59 +0100 Subject: [PATCH 069/240] Created definitions for 'universal-analytics' https://github.com/peaksandpies/universal-analytics --- README.md | 1 + .../universal-analytics-test.ts | 87 +++++++++++++++++ universal-analytics/universal-analytics.d.ts | 94 +++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 universal-analytics/universal-analytics-test.ts create mode 100644 universal-analytics/universal-analytics.d.ts diff --git a/README.md b/README.md index 8183ef1c42..d3ce3ca21f 100755 --- a/README.md +++ b/README.md @@ -248,6 +248,7 @@ List of Definitions * [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Underscore.js (Typed)](http://underscorejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Underscore-ko.js](https://github.com/kamranayub/UnderscoreKO) (by [Maurits Elbers](https://github.com/MagicMau)) +* [universal-analytics](https://github.com/peaksandpies/universal-analytics) (by [Bart van der Schoor](https://github.com/Bartvds)) * [UUID.js](https://github.com/LiosK/UUID.js) (by [Jason Jarrett](https://github.com/staxmanade)) * [Valerie](https://github.com/davewatts/valerie) (by [Howard Richards](https://github.com/conficient)) * [Viewporter](https://github.com/zynga/viewporter) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/universal-analytics/universal-analytics-test.ts b/universal-analytics/universal-analytics-test.ts new file mode 100644 index 0000000000..4249218d95 --- /dev/null +++ b/universal-analytics/universal-analytics-test.ts @@ -0,0 +1,87 @@ +/// + +var ui:UniversalAnalytics; + +var str:string; +var num:number; +var value:any; +var bool:boolean; +var params:Object; +var x:any; + +var client:UniversalAnalytics.Client = ui('UA-123-00'); +client = ui.debug(); +client.send(); + +client = client.pageview(str); +client.pageview(str, (err:any) => {}); +client = client.pageview(params); +client.pageview(params, (err:any) => {}); +client = client.pageview(str, str); +client.pageview(str, str, (err:any) => {}); +client = client.pageview(str, str, str); +client.pageview(str, str, str, (err:any) => {}); + + +client = client.event(str, str); +client.event(str, str, (err:any) => {}); +client = client.event(str, str, str); +client.event(str, str, str, (err:any) => {}); +client = client.event(str, str, str, value); +client.event(str, str, str, value, (err:any) => {}); +client.event(str, str, str, value, params, (err:any) => {}); +client = client.event(params); +client.event(params, (err:any) => {}); + + +client = client.transaction(str); +client.transaction(str, (err:any) => {}); +client = client.transaction(str, num); +client.transaction(str, num, (err:any) => {}); +client = client.transaction(str, num, num); +client.transaction(str, num, num, (err:any) => {}); +client = client.transaction(str, num, num, num); +client.transaction(str, num, num, num, (err:any) => {}); +client = client.transaction(str, num, num, num, str); +client.transaction(str, num, num, num, str, (err:any) => {}); +client = client.transaction(params); +client.transaction(params, (err:any) => {}); + + +client = client.item(num); +client.item(num, (err:any) => {}); +client = client.item(num, num); +client.item(num, num, (err:any) => {}); +client = client.item(num, num, num); +client.item(num, num, num, (err:any) => {}); +client = client.item(num, num, num, str); +client.item(num, num, num, str, (err:any) => {}); +client = client.item(num, num, num, str, str); +client.item(num, num, num, str, str, (err:any) => {}); +client = client.item(num, num, num, str, str, params); +client.item(num, num, num, str, str, params, (err:any) => {}); +client = client.item(params); +client.item(params, (err:any) => {}); + + +client = client.exception(str); +client.exception(str, (err:any) => {}); +client = client.exception(str, bool); +client.exception(str, bool, (err:any) => {}); +client = client.exception(params); +client.exception(params, (err:any) => {}); + + +client = client.timing(str); +client.timing(str, (err:any) => {}); +client = client.timing(str, str); +client.timing(str, str, (err:any) => {}); +client = client.timing(str, str, num); +client.timing(str, str, num, (err:any) => {}); +client = client.timing(str, str, num, str); +client.timing(str, str, num, str, (err:any) => {}); +client = client.timing(params); +client.timing(params, (err:any) => {}); + + +x = client.middleware(str, {}); diff --git a/universal-analytics/universal-analytics.d.ts b/universal-analytics/universal-analytics.d.ts new file mode 100644 index 0000000000..af81eac94b --- /dev/null +++ b/universal-analytics/universal-analytics.d.ts @@ -0,0 +1,94 @@ +// Type definitions for universal-analytics v0.3.2 +// Project: https://github.com/peaksandpies/universal-analytics +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface UniversalAnalytics { + (accountID:string, uuid?:string, opts?:Object):UniversalAnalytics.Client; + debug():UniversalAnalytics.Client; +} + +declare module UniversalAnalytics { + + interface Client { + + send():void; + + pageview(path:string):Client; + pageview(path:string, callback?:(err:any) => void):void; + pageview(params:Object):Client; + pageview(params:Object, callback?:(err:any) => void):void; + pageview(path:string, hostname:string):Client; + pageview(path:string, hostname:string, callback?:(err:any) => void):void; + pageview(path:string, title:string, hostname:string):Client; + pageview(path:string, title:string, hostname:string, callback?:(err:any) => void):void; + + + event(category:string, action:string):Client; + event(category:string, action:string, callback?:(err:any) => void):void; + event(category:string, action:string, label:string):Client; + event(category:string, action:string, label:string, callback?:(err:any) => void):void; + event(category:string, action:string, label:string, value:any):Client; + event(category:string, action:string, label:string, value:any, callback?:(err:any) => void):void; + event(category:string, action:string, label:string, value:any, params:Object, callback?:(err:any) => void):void; + event(params:Object):Client; + event(params:Object, callback:(err:any) => void):void; + + + transaction(id:string):Client; + transaction(id:string, callback:(err:any) => void):void; + transaction(id:string, revenue:number):Client; + transaction(id:string, revenue:number, callback:(err:any) => void):void; + transaction(id:string, revenue:number, shipping:number):Client; + transaction(id:string, revenue:number, shipping:number, callback:(err:any) => void):void; + transaction(id:string, revenue:number, shipping:number, taxping:number):Client; + transaction(id:string, revenue:number, shipping:number, taxping:number, callback:(err:any) => void):void; + transaction(id:string, revenue:number, shipping:number, taxping:number, affiliation:string):Client; + transaction(id:string, revenue:number, shipping:number, taxping:number, affiliation:string, callback:(err:any) => void):void; + transaction(params:Object):Client; + transaction(params:Object, callback:(err:any) => void):void; + + + item(price:number):Client; + item(price:number, callback:(err:any) => void):void; + item(price:number, quantity:number):Client; + item(price:number, quantity:number, callback:(err:any) => void):void; + item(price:number, quantity:number, sku:number):Client; + item(price:number, quantity:number, sku:number, callback:(err:any) => void):void; + item(price:number, quantity:number, sku:number, name:string):Client; + item(price:number, quantity:number, sku:number, name:string, callback:(err:any) => void):void; + item(price:number, quantity:number, sku:number, name:string, variation:string):Client; + item(price:number, quantity:number, sku:number, name:string, variation:string, callback:(err:any) => void):void; + item(price:number, quantity:number, sku:number, name:string, variation:string, params:Object):Client; + item(price:number, quantity:number, sku:number, name:string, variation:string, params:Object, callback:(err:any) => void):void; + item(params:Object):Client; + item(params:Object, callback:(err:any) => void):void; + + + exception(description:string):Client; + exception(description:string, callback:(err:any) => void):void; + exception(description:string, fatal:boolean):Client; + exception(description:string, fatal:boolean, callback:(err:any) => void):void; + exception(params:Object):Client; + exception(params:Object, callback:(err:any) => void):void; + + + timing(category:string):Client; + timing(category:string, callback:(err:any) => void):void; + timing(category:string, variable:string):Client; + timing(category:string, variable:string, callback:(err:any) => void):void; + timing(category:string, variable:string, time:number):Client; + timing(category:string, variable:string, time:number, callback:(err:any) => void):void; + timing(category:string, variable:string, time:number, label:string):Client; + timing(category:string, variable:string, time:number, label:string, callback:(err:any) => void):void; + timing(params:Object):Client; + timing(params:Object, callback:(err:any) => void):void; + + + middleware(accountID:string, options?:any):any; + } +} + +declare module 'universal-analytics' { +export = UniversalAnalytics; +} From d410565fe131cb562f1d24defd5349cc5642550e Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Mon, 27 Jan 2014 10:35:57 +0000 Subject: [PATCH 070/240] Add RequireJS 'errback' signature --- requirejs/require.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index e52f8197a1..a85699c779 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -249,6 +249,12 @@ interface Require { **/ (modules: string[], ready: Function): void; + /** + * @see http://requirejs.org/docs/api.html#errbacks + * @param ready Called when required modules are ready. + **/ + (modules: string[], ready: Function, errback: Function): void; + /** * Generate URLs from require module * @param module Module to URL From 2806d81cae247ca38772cc41a73a70a66e638297 Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Mon, 27 Jan 2014 14:22:51 +0000 Subject: [PATCH 071/240] AngularJS: Added promise hash signature to .all() --- angularjs/angular.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 6a656b00bb..061575166b 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -452,6 +452,7 @@ declare module ng { /////////////////////////////////////////////////////////////////////////// interface IQService { all(promises: IPromise[]): IPromise; + all(promises: {[id: string]: IPromise;}): IPromise<{[id: string]: any}>; defer(): IDeferred; reject(reason?: any): IPromise; when(value: T): IPromise; From 0645d5c6f5a134a85939f08feff05d8a78ea1aa9 Mon Sep 17 00:00:00 2001 From: Michael Cox Date: Mon, 27 Jan 2014 16:52:01 +0000 Subject: [PATCH 072/240] AngularJS: make IDirective.link() arguments optional --- angularjs/angular.d.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 061575166b..f3e7dc0001 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -748,12 +748,14 @@ declare module ng { ) => any; controller?: any; controllerAs?: string; + // A link function with no arguments is perfectly valid; the norm seems + // to be passing the scope, element and attributes. link?: - (scope: IScope, - instanceElement: IAugmentedJQuery, - instanceAttributes: IAttributes, - controller: any, - transclude: ITranscludeFunction + (scope?: IScope, + instanceElement?: IAugmentedJQuery, + instanceAttributes?: IAttributes, + controller?: any, + transclude?: ITranscludeFunction ) => void; name?: string; priority?: number; From 9f9c8091022e6f9b8515a7e38448b27faa3c0246 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Mon, 27 Jan 2014 13:03:20 -0500 Subject: [PATCH 073/240] Additional types for slick.headerbutton.d.ts --- slickgrid/slick.headerbuttons.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/slickgrid/slick.headerbuttons.d.ts b/slickgrid/slick.headerbuttons.d.ts index 9ac7f86db3..ab160ea836 100644 --- a/slickgrid/slick.headerbuttons.d.ts +++ b/slickgrid/slick.headerbuttons.d.ts @@ -24,11 +24,18 @@ declare module Slick { tooltip?: string; } + export interface OnCommandEventData { + grid: Grid; + column: Column; + command: string; + button: HeaderButton; + } + export module Plugins { export class HeaderButtons extends Plugin { constructor(); - public onCommand: Event; + public onCommand: Event>; } } } From def4da160bde7430d5d4f3b4a4e77318c1a9b4d8 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Mon, 27 Jan 2014 14:16:20 -0500 Subject: [PATCH 074/240] Update jquery.color.d.ts --- jquery.color/jquery.color.d.ts | 154 +++++++++++++++++++++++++++------ 1 file changed, 129 insertions(+), 25 deletions(-) diff --git a/jquery.color/jquery.color.d.ts b/jquery.color/jquery.color.d.ts index 427890a41d..8d5000a6c2 100644 --- a/jquery.color/jquery.color.d.ts +++ b/jquery.color/jquery.color.d.ts @@ -1,46 +1,150 @@ // Type definitions for jquery.color.js v2.1.2 +// Project: https://github.com/jquery/jquery-color +// Definitions by: Derek Cicerone // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + interface JQueryColor { - /** - * Returns the alpha value of this color. - */ - alpha(): number; - - /** - * Returns the hexadecimal representation. - */ - toHexString(): string; - - /** - * Returns a CSS string like "rgba(255, 255, 255, 0.4)". - */ - toRgbaString(): string; - - /** - * The color distance (0.0 - 1.0) of the way between this color and othercolor. - */ - transition(othercolor: JQueryColor, distance: number): JQueryColor; - - /** - * Checks if two colors are equal. - */ - is(otherColor: JQueryColor): boolean; - /** * Returns the red component of the color (integer from 0 - 255). */ red(): number; + /** + * Returns a copy of the color object with the red set to val. + */ + red(val: number): JQueryColor; + /** * Returns the green component of the color (integer from 0 - 255). */ green(): number; + /** + * Returns a copy of the color object with the green set to val. + */ + green(val: number): JQueryColor; + /** * Returns the blue component of the color (integer from 0 - 255). */ blue(): number; + + /** + * Returns a copy of the color object with the blue set to val. + */ + blue(val: number): JQueryColor; + + /** + * Returns the alpha value of this color (float from 0.0 - 1.0). + */ + alpha(): number; + + /** + * Returns a copy of the color object with the alpha set to val. + */ + alpha(val: number): JQueryColor; + + /** + * Returns the hue component of the color (integer from 0 - 359). + */ + hue(): number; + + /** + * Returns a copy of the color object with the hue set to val. + */ + hue(val: number): JQueryColor; + + /** + * Returns the saturation component of the color (float from 0.0 - 1.0). + */ + saturation(): number; + + /** + * Returns a copy of the color object with the saturation set to val. + */ + saturation(val: number): JQueryColor; + + /** + * Returns the lightness component of the color (float from 0.0 - 1.0). + */ + lightness(): number; + + /** + * Returns a copy of the color object with the lightness set to val. + */ + lightness(val: number): JQueryColor; + + /** + * Returns a rgba "tuple" [ red, green, blue, alpha ]. + */ + rgba(): number[]; + + /** + * Returns a copy of the color with any defined values set to the new value. + */ + rgba(red: number, green: number, blue: number, alpha?: number): JQueryColor; + + /** + * Returns a copy of the color with any defined values set to the new value. + */ + rgba(val: RgbaColor): JQueryColor; + + /** + * Returns a copy of the color with any defined values set to the new value. + */ + rgba(vals: number[]): JQueryColor; + + /** + * Returns a HSL tuple [ hue, saturation, lightness, alpha ]. + */ + hsla(): number[]; + + /** + * Returns a copy of the color with any defined values set to the new value. + */ + hsla(hue: number, saturation: number, lightness: number, alpha?: number): JQueryColor; + + /** + * Returns a copy of the color with any defined values set to the new value. + */ + hsla(val: HslaColor): JQueryColor; + + /** + * Returns a copy of the color with any defined values set to the new value. + */ + hsla(vals: number[]): JQueryColor; + + /** + * Returns a CSS string "rgba(255, 255, 255, 0.4)". + */ + toRgbaString(): string; + + /** + * Returns a css string "hsla(330, 75%, 25%, 0.4)". + */ + toHslaString(): string; + + /** + * Returns a css string "#abcdef", with "includeAlpha" uses "#rrggbbaa" (alpha *= 255). + */ + toHexString(includeAlpha?: boolean): string; + + /** + * The color distance (0.0 - 1.0) of the way between this color and othercolor. + */ + transition(othercolor: JQueryColor, distance: number): JQueryColor; + + /** + * Will apply this color on top of the other color using alpha blending. + */ + blend(othercolor: JQueryColor): void; + + /** + * Checks if two colors are equal. + */ + is(otherColor: JQueryColor): boolean; } interface HslaColor { From b7e1c8b53ece9f0772f0c1a361df5dcf6cca2f6a Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Mon, 27 Jan 2014 14:16:46 -0500 Subject: [PATCH 075/240] Create jquery.color-tests.ts --- jquery.color/jquery.color-tests.ts | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 jquery.color/jquery.color-tests.ts diff --git a/jquery.color/jquery.color-tests.ts b/jquery.color/jquery.color-tests.ts new file mode 100644 index 0000000000..267ee3b63b --- /dev/null +++ b/jquery.color/jquery.color-tests.ts @@ -0,0 +1,46 @@ +/// +/// + +var color = $.Color("rgba(255, 255, 255, 0.4)"); +var color1 = $.Color({red: 255, green: 255, blue: 255}); +var color2 = $.Color({hue: 359, saturation: 0.5, lightness: 0.5}); + +// getters +var red = color.red(); +var green = color.green(); +var blue = color.blue(); +var alpha = color.alpha(); +var hue = color.hue(); +var saturation = color.saturation(); +var lightness = color.lightness(); + +// setters +var newRed = color.red(20); +var newGreen = color.green(20); +var newBlue = color.blue(20); +var newAlpha = color.alpha(0.5); +var newHue = color.hue(20); +var newSaturation = color.saturation(0.5); +var newLightness = color.lightness(0.5); + +// rgba methods +var rgba = color.rgba(); +var newRgba1 = color.rgba(255, 255, 255, 0.5); +var newRgba2 = color.rgba({red: 255, green: 255, blue: 255}); +var newRgba3 = color.rgba(rgba); + +// hsla methods +var hsla = color.hsla(); +var newHsla1 = color.hsla(359, 0.5, 0.5, 0.5); +var newHsla2 = color.hsla({hue: 359, saturation: 0.5, lightness: 0.5}); +var newHsla3 = color.hsla(hsla); + +// string methods +var rgbaString = color.toRgbaString(); +var hslaString = color.toHslaString(); +var hexString = color.toHexString(); + +// other colors +var transitionedColor = color.transition(newRed, 0.5); +var blendedColor = color.blend(newRed); +var isEqual = color.is(newRed); From 663624b659c901c621225952175e93e23ba46930 Mon Sep 17 00:00:00 2001 From: Anand Prakash Date: Mon, 27 Jan 2014 16:32:12 -0800 Subject: [PATCH 076/240] Changed JQueryAjaxSettings.jsonp to any We can not only pass a string in jsonp to be used as callback function query parameter name but also false to skip including the callback parameter at all. http://api.jquery.com/jQuery.ajax/ --- jquery/jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 8ac14892fd..2b4268da5d 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -99,7 +99,7 @@ interface JQueryAjaxSettings { /** * Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" } */ - jsonp?: string; + jsonp?: any; /** * Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function. */ From 2d4c46b54b67f7acbc9bff110c0e4f3ca213ee3c Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Mon, 27 Jan 2014 21:39:29 -0500 Subject: [PATCH 077/240] Create messenger-tests.ts * this close to the surface area that we use - i don't feel comfortable adding more info without having actual usage --- messenger/messenger-tests.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 messenger/messenger-tests.ts diff --git a/messenger/messenger-tests.ts b/messenger/messenger-tests.ts new file mode 100644 index 0000000000..1f560e6e2d --- /dev/null +++ b/messenger/messenger-tests.ts @@ -0,0 +1,14 @@ +/// + +var message = Messenger().post({ + message: "message", + hideAfter: 5, + showCloseButton: true, + type: "error" +}); +message.update({ + type: "error", + message: "Error calculating position" +}); + +Messenger().hideAll(); From c88f7109834f50966a102e7d49365c65538db6ec Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Mon, 27 Jan 2014 21:40:20 -0500 Subject: [PATCH 078/240] Update messenger.d.ts * adding documentation and missing stuff --- messenger/messenger.d.ts | 96 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/messenger/messenger.d.ts b/messenger/messenger.d.ts index b874eb356f..3aacf2f889 100644 --- a/messenger/messenger.d.ts +++ b/messenger/messenger.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Messenger.js 1.2.1 +// Type definitions for Messenger.js 1.4.0 // Project: https://github.com/HubSpot/messenger // Definitions by: Derek Cicerone // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -9,18 +9,110 @@ interface IMessenger { } interface Messenger { - post(message: Message): void; + /** + * Posts a message. + */ + post(options: MessageOptions): Message; + + /** + * Hides all messages. + */ hideAll(): void; } interface Message { + /** + * Show the message, if it's hidden. + */ + show(): void; + + /** + * Hide the message, if it's hidden. + */ + hide(): void; + + /** + * If the message is associated with an ajax request or is counting down to retry, cancel it. + */ + cancel(): void; + + /** + * Update the message with the provided options. + */ + update(options: MessageOptions): void; +} + +interface MessageOptions { + /** + * The text of the message. + */ message: string; + + /** + * Hide the message after the provided number of seconds. + */ hideAfter?: number; + + /** + * Hide the message if Backbone client-side navigation occurs. + */ + hideOnNavigate?: boolean; + + /** + * A unique id. If supplied, only one message with that ID will be shown at a time. + */ + id?: string; + + /** + * Should a close button be added to the message? + */ showCloseButton?: boolean; + + /** + * Hide the newer message if there is an id collision, as opposed to the older message. + */ + singleton?: boolean; + + /** + * What theme class should be applied to the message? Defaults to the theme set for Messenger in general. + */ + theme?: string; + + /** + * "info", "error" or "success" are understood by the provided themes. You can also pass your own string, and that class will be added. + */ type?: string; } interface MessengerOptions { + + /** + * Extra classes to be appended to the container. + */ + extraClasses?: string; + + /** + * The maximum number of messages to show at once. + */ + maxMessages?: number; + + /** + * Default options for created messages. + */ + messageDefaults?: MessageOptions; + + /** + * Which locations should be tried when inserting the message container into the page. + * The default is ['body']. It accepts a list to allow you to try a variety of places + * when deciding what the optimal location is on any given page. This should generally + * not need to be changed unless you are inserting the messages into the flow of the + * document, rather than using messenger-fixed. + */ + parentLocations?: string[]; + + /** + * What theme are you using? Some themes have associated javascript, specifing this allows that js to run. + */ theme?: string; } From 19b9dc26cd892d553e887646ee2aaa4e43799428 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Mon, 27 Jan 2014 20:38:11 -0800 Subject: [PATCH 079/240] Add a typing for Vega --- vega/vega-tests.ts | 2049 ++++++++++++++++++++++++++++++++++++++++++++ vega/vega.d.ts | 307 +++++++ 2 files changed, 2356 insertions(+) create mode 100644 vega/vega-tests.ts create mode 100644 vega/vega.d.ts diff --git a/vega/vega-tests.ts b/vega/vega-tests.ts new file mode 100644 index 0000000000..2cbf9d7b9a --- /dev/null +++ b/vega/vega-tests.ts @@ -0,0 +1,2049 @@ +/// + +// examples from http://trifacta.github.io/vega/editor/ +var specs: Vega.Spec[] = [ + { + "name": "arc", + "width": 400, + "height": 400, + "data": [ + { + "name": "table", + "values": [12, 23, 47, 6, 52, 19], + "transform": [ + {"type": "pie", "value": "data"} + ] + } + ], + "scales": [ + { + "name": "r", + "type": "sqrt", + "domain": {"data": "table", "field": "data"}, + "range": [20, 100] + } + ], + "marks": [ + { + "type": "arc", + "from": {"data": "table"}, + "properties": { + "enter": { + "x": {"group": "width", "mult": 0.5}, + "y": {"group": "height", "mult": 0.5}, + "startAngle": {"field": "startAngle"}, + "endAngle": {"field": "endAngle"}, + "innerRadius": {"value": 20}, + "outerRadius": {"scale": "r"}, + "stroke": {"value": "#fff"} + }, + "update": { + "fill": {"value": "#ccc"} + }, + "hover": { + "fill": {"value": "pink"} + } + } + } + ] + }, + { + "width": 500, + "height": 200, + "padding": {"top": 10, "left": 30, "bottom": 30, "right": 10}, + "data": [ + { + "name": "table", + "values": [ + {"x": 1, "y": 28}, {"x": 2, "y": 55}, + {"x": 3, "y": 43}, {"x": 4, "y": 91}, + {"x": 5, "y": 81}, {"x": 6, "y": 53}, + {"x": 7, "y": 19}, {"x": 8, "y": 87}, + {"x": 9, "y": 52}, {"x": 10, "y": 48}, + {"x": 11, "y": 24}, {"x": 12, "y": 49}, + {"x": 13, "y": 87}, {"x": 14, "y": 66}, + {"x": 15, "y": 17}, {"x": 16, "y": 27}, + {"x": 17, "y": 68}, {"x": 18, "y": 16}, + {"x": 19, "y": 49}, {"x": 20, "y": 15} + ] + } + ], + "scales": [ + { + "name": "x", + "type": "linear", + "range": "width", + "zero": false, + "domain": {"data": "table", "field": "data.x"} + }, + { + "name": "y", + "type": "linear", + "range": "height", + "nice": true, + "domain": {"data": "table", "field": "data.y"} + } + ], + "axes": [ + {"type": "x", "scale": "x", "ticks": 20}, + {"type": "y", "scale": "y"} + ], + "marks": [ + { + "type": "area", + "from": {"data": "table"}, + "properties": { + "enter": { + "interpolate": {"value": "monotone"}, + "x": {"scale": "x", "field": "data.x"}, + "y": {"scale": "y", "field": "data.y"}, + "y2": {"scale": "y", "value": 0}, + "fill": {"value": "steelblue"} + }, + "update": { + "fillOpacity": {"value": 1} + }, + "hover": { + "fillOpacity": {"value": 0.5} + } + } + } + ] + }, + { + "width": 400, + "height": 200, + "padding": {"top": 10, "left": 30, "bottom": 30, "right": 10}, + "data": [ + { + "name": "table", + "values": [ + {"x": 1, "y": 28}, {"x": 2, "y": 55}, + {"x": 3, "y": 43}, {"x": 4, "y": 91}, + {"x": 5, "y": 81}, {"x": 6, "y": 53}, + {"x": 7, "y": 19}, {"x": 8, "y": 87}, + {"x": 9, "y": 52}, {"x": 10, "y": 48}, + {"x": 11, "y": 24}, {"x": 12, "y": 49}, + {"x": 13, "y": 87}, {"x": 14, "y": 66}, + {"x": 15, "y": 17}, {"x": 16, "y": 27}, + {"x": 17, "y": 68}, {"x": 18, "y": 16}, + {"x": 19, "y": 49}, {"x": 20, "y": 15} + ] + } + ], + "scales": [ + { + "name": "x", + "type": "ordinal", + "range": "width", + "domain": {"data": "table", "field": "data.x"} + }, + { + "name": "y", + "range": "height", + "nice": true, + "domain": {"data": "table", "field": "data.y"} + } + ], + "axes": [ + {"type": "x", "scale": "x"}, + {"type": "y", "scale": "y"} + ], + "marks": [ + { + "type": "rect", + "from": {"data": "table"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.x"}, + "width": {"scale": "x", "band": true, "offset": -1}, + "y": {"scale": "y", "field": "data.y"}, + "y2": {"scale": "y", "value": 0} + }, + "update": { + "fill": {"value": "steelblue"} + }, + "hover": { + "fill": {"value": "red"} + } + } + } + ] + }, + { + "width": 200, + "height": 720, + "data": [ + { + "name": "barley", + "url": "data/barley.json" + }, + { + "name": "variety", + "source": "barley", + "transform": [ + {"type": "facet", "keys": ["data.variety"]}, + {"type": "stats", "value": "data.yield", "median": true}, + {"type": "sort", "by": "-median"} + ] + }, + { + "name": "site", + "source": "barley", + "transform": [ + {"type": "facet", "keys": ["data.site"]}, + {"type": "stats", "value": "data.yield", "median": true}, + {"type": "sort", "by": "-median"} + ] + } + ], + "scales": [ + { + "name": "g", + "type": "ordinal", + "range": "height", + "padding": 0.15, + "domain": {"data": "site", "field": "key"} + }, + { + "name": "x", + "type": "linear", + "nice": true, + "range": "width", + "domain": {"data": "barley", "field": "data.yield"} + }, + { + "name": "c", + "type": "ordinal", + "range": "category10" + } + ], + "axes": [ + {"type": "x", "scale": "x", "offset": -12} + ], + "marks": [ + { + "type": "text", + "from": {"data": "site"}, + "properties": { + "enter": { + "x": {"group": "width", "mult": 0.5}, + "y": {"scale": "g", "field": "key", "offset": -2}, + "fontWeight": {"value": "bold"}, + "text": {"field": "key"}, + "align": {"value": "center"}, + "baseline": {"value": "bottom"}, + "fill": {"value": "#000"} + } + } + }, + { + "type": "group", + "from": {"data": "site"}, + "scales": [ + { + "name": "y", + "type": "ordinal", + "range": "height", + "points": true, + "padding": 1.2, + "domain": {"data": "variety", "field": "key"} + } + ], + "axes": [ + { + "type": "y", + "scale": "y", + "tickSize": 0, + "properties": {"axis": {"stroke": {"value": "transparent"}}} + } + ], + "properties": { + "enter": { + "x": {"value": 0.5}, + "y": {"scale": "g", "field": "key"}, + "height": {"scale": "g", "band": true}, + "width": {"group": "width"}, + "stroke": {"value": "#ccc"} + } + }, + "marks": [ + { + "type": "symbol", + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.yield"}, + "y": {"scale": "y", "field": "data.variety"}, + "size": {"value": 50}, + "stroke": {"scale": "c", "field": "data.year"}, + "strokeWidth": {"value": 2} + } + } + } + ] + } + ] + }, + { + "width": 960, + "height": 500, + "data": [ + { + "name": "unemp", + "url": "data/unemployment.tsv", + "format": {"type": "tsv", "parse": {"rate":"number"}} + }, + { + "name": "counties", + "url": "data/us-10m.json", + "format": {"type": "topojson", "feature": "counties"}, + "transform": [ + {"type": "geopath", "value": "data", "projection": "albersUsa"}, + { + "type": "zip", + "key": "data.id", + "with": "unemp", + "withKey": "data.id", + "as": "value", + "default": null + }, + {"type":"filter", "test":"d.path!=null && d.value!=null"} + ] + } + ], + "scales": [ + { + "name": "color", + "type": "quantize", + "domain": [0, 0.15], + "range": ["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", + "#4292c6", "#2171b5", "#08519c", "#08306b"] + } + ], + "marks": [ + { + "type": "path", + "from": {"data": "counties"}, + "properties": { + "enter": { "path": {"field": "path"} }, + "update": { "fill": {"scale":"color", "field":"value.data.rate"} }, + "hover": { "fill": {"value": "red"} } + } + } + ] + }, + { + "width": 300, + "height": 240, + "data": [ + { + "name": "table", + "url": "data/groups.json" + } + ], + "scales": [ + { + "name": "cat", + "type": "ordinal", + "range": "height", + "padding": 0.2, + "domain": {"data": "table", "field": "data.category"} + }, + { + "name": "val", + "range": "width", + "round": true, + "nice": true, + "domain": {"data": "table", "field": "data.value"} + }, + { + "name": "color", + "type": "ordinal", + "range": "category20" + } + ], + "axes": [ + {"type": "y", "scale": "cat", "tickSize": 0, "tickPadding": 8}, + {"type": "x", "scale": "val"} + ], + "marks": [ + { + "type": "group", + "from": { + "data": "table", + "transform": [{"type":"facet", "keys":["data.category"]}] + }, + "properties": { + "enter": { + "y": {"scale": "cat", "field": "key"}, + "height": {"scale": "cat", "band": true} + } + }, + "scales": [ + { + "name": "pos", + "type": "ordinal", + "range": "height", + "domain": {"field": "data.position"} + } + ], + "marks": [ + { + "type": "rect", + "properties": { + "enter": { + "y": {"scale": "pos", "field": "data.position"}, + "height": {"scale": "pos", "band": true}, + "x": {"scale": "val", "field": "data.value"}, + "x2": {"scale": "val", "value": 0}, + "fill": {"scale": "color", "field": "data.position"} + } + } + }, + { + "type": "text", + "properties": { + "enter": { + "y": {"scale": "pos", "field": "data.position"}, + "dy": {"scale": "pos", "band": true, "mult": 0.5}, + "x": {"scale": "val", "field": "data.value", "offset": -4}, + "fill": {"value": "white"}, + "align": {"value": "right"}, + "baseline": {"value": "middle"}, + "text": {"field": "data.value"} + } + } + } + ] + } + ] + }, + { + "width": 400, + "height": 100, + "padding": {"top": 30, "left": 30, "bottom": 30, "right": 10}, + "data": [ + { + "name": "stats", + "values": [ + {"label": "Category A", "mean": 1, "lo": 0, "hi": 2}, + {"label": "Category B", "mean": 2, "lo": 1.5, "hi": 2.5}, + {"label": "Category C", "mean": 3, "lo": 1.7, "hi": 4.3}, + {"label": "Category D", "mean": 4, "lo": 3, "hi": 5}, + {"label": "Category E", "mean": 5, "lo": 4.1, "hi": 5.9} + ] + } + ], + "scales": [ + { + "name": "y", + "type": "ordinal", + "range": "height", + "domain": {"data": "stats", "field": "index"} + }, + { + "name": "x", + "range": [100, 400], + "nice": true, + "zero": true, + "domain": {"data": "stats", "field": "data.hi"} + } + ], + "axes": [ + {"type": "x", "scale": "x", "ticks": 6} + ], + "marks": [ + { + "type": "text", + "from": {"data": "stats"}, + "properties": { + "enter": { + "x": {"value": 0}, + "y": {"scale": "y", "field": "index"}, + "baseline": {"value": "middle"}, + "fill": {"value": "#000"}, + "text": {"field": "data.label"}, + "font": {"value": "Helvetica Neue"}, + "fontSize": {"value": 13} + } + } + }, + { + "type": "rect", + "from": {"data": "stats"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.lo"}, + "x2": {"scale": "x", "field": "data.hi"}, + "y": {"scale": "y", "field": "index", "offset": -1}, + "height": {"value": 1}, + "fill": {"value": "#888"} + } + } + }, + { + "type": "symbol", + "from": {"data": "stats"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.mean"}, + "y": {"scale": "y", "field": "index"}, + "size": {"value": 40}, + "fill": {"value": "#000"} + } + } + } + ] + }, + { + "name": "force", + "width": 500, + "height": 500, + "padding": {"top":0, "bottom":0, "left":0, "right":0}, + "data": [ + { + "name": "edges", + "url": "data/miserables.json", + "format": {"type": "json", "property": "links"}, + "transform": [ + {"type": "copy", "from": "data", "fields": ["source", "target"]} + ] + }, + { + "name": "nodes", + "url": "data/miserables.json", + "format": {"type": "json", "property": "nodes"}, + "transform": [ + { + "type": "force", + "links": "edges", + "linkDistance": 70, + "charge": -100, + "iterations": 1000 + } + ] + } + ], + "marks": [ + { + "type": "path", + "from": { + "data": "edges", + "transform": [ + {"type": "link", "shape": "line"} + ] + }, + "properties": { + "update": { + "path": {"field": "path"}, + "stroke": {"value": "#ccc"}, + "strokeWidth": {"value": 0.5} + } + } + }, + { + "type": "symbol", + "from": {"data": "nodes"}, + "properties": { + "enter": { + "fillOpacity": {"value": 0.3}, + "stroke": {"value": "steelblue"} + }, + "update": { + "x": {"field": "x"}, + "y": {"field": "y"}, + "fill": {"value": "steelblue"} + }, + "hover": { + "fill": {"value": "#f00"} + } + } + } + ] + }, + { + "name": "image", + "width": 200, + "height": 200, + "padding": {"left":30, "top":10, "bottom":30, "right":10}, + "data": [ + { + "name": "data", + "values": [ + {"x":0.5, "y":0.5, "img":"data/ffox.png"}, + {"x":1.5, "y":1.5, "img":"data/gimp.png"}, + {"x":2.5, "y":2.5, "img":"data/7zip.png"} + ] + } + ], + "scales": [ + {"name": "x", "domain": [0, 3], "range": "width"}, + {"name": "y", "domain": [0, 3], "range": "height"} + ], + "axes": [ + {"type": "x", "scale": "x"}, + {"type": "y", "scale": "y"} + ], + "marks": [ + { + "type": "image", + "from": {"data": "data"}, + "properties": { + "enter": { + "url": {"field": "data.img"}, + "width": {"value": 50}, + "height": {"value": 50}, + "x": {"scale": "x", "field": "data.x"}, + "y": {"scale": "y", "field": "data.y"}, + "align": {"value": "center"}, + "baseline": {"value": "middle"} + }, + "update": { + "opacity": {"value": 1.0} + }, + "hover": { + "opacity": {"value": 0.5} + } + } + } + ] + }, + { + "width": 800, + "height": 500, + "padding": {"left": 15, "right": 65, "top": 10, "bottom": 20}, + "data": [ + { + "name": "jobs", + "url": "data/jobs.json" + }, + { + "name": "series", + "source": "jobs", + "transform": [ + {"type": "facet", "keys": ["data.job", "data.sex"]}, + {"type": "stats", "value": "data.perc"}, + {"type": "stack", "point": "data.year", "height": "data.perc", "order": "reverse"} + ] + }, + { + "name": "stats", + "source": "jobs", + "transform": [ + {"type": "facet", "keys": ["data.year"]}, + {"type": "stats", "value": "data.perc"} + ] + } + ], + "scales": [ + { + "name": "x", + "type": "linear", + "range": "width", + "zero": false, "round": true, + "domain": {"data": "jobs", "field": "data.year"} + }, + { + "name": "y", + "type": "linear", + "range": "height", "round": true, + "domain": {"data": "stats", "field": "sum"} + }, + { + "name": "color", + "type": "ordinal", + "domain": ["men", "women"], + "range": ["#33f", "#f33"] + }, + { + "name": "alpha", + "type": "linear", + "domain": {"data": "series", "field": "sum"}, + "range": [0.4, 0.8] + }, + { + "name": "font", + "type": "sqrt", + "range": [0,24], "round": true, + "domain": {"data": "stats", "field": "sum"} + }, + { + "name": "align", + "type": "quantize", + "range": ["left", "center", "right"], "zero":false, + "domain": [1730, 2130] + }, + { + "name": "offset", + "type": "quantize", + "range": [6, 0, -6], "zero":false, + "domain": [1730, 2130] + } + ], + "axes": [ + {"type": "x", "scale": "x", "format": "d", "ticks": 15, "tickSizeEnd": 0}, + { + "type": "y", "scale": "y", "format": "n", "orient": "right", + "grid": true, "layer": "back", "tickSize": 12, + "properties": { + "axis": {"stroke": {"value":"transparent"}}, + "grid": {"stroke": {"value": "#ccc"}}, + "ticks": {"stroke": {"value": "#ccc"}} + } + } + ], + "marks": [ + { + "type": "group", + "from": {"data": "series"}, + "marks": [ + { + "type": "area", + "properties": { + "update": { + "x": {"scale": "x", "field": "data.year"}, + "y": {"scale": "y", "field": "y"}, + "y2": {"scale": "y", "field": "y2"}, + "fill": {"scale": "color", "field": "data.sex"}, + "fillOpacity": {"scale": "alpha", "group": "sum"} + }, + "hover": { + "fillOpacity": {"value": 0.2} + } + } + } + ] + }, + { + "type": "group", + "from": {"data": "series"}, + "marks": [ + { + "type": "text", + "from": { + "transform": [ + {"type":"slice", "by":"max", "field":"data.perc"} + ] + }, + "interactive": false, + "properties": { + "update": { + "x": {"scale": "x", "field": "data.year"}, + "dx": {"scale": "offset", "field": "data.year"}, + "y": {"scale": "y", "field": "cy"}, + "fill": {"value": "#000"}, + "fillOpacity": {"scale": "font", "field": "data.perc", "mult": 0.15}, + "fontSize": {"scale": "font", "field": "data.perc", "offset": 5}, + "text": {"field": "data.job"}, + "align": {"scale": "align", "field": "data.year"}, + "baseline": {"value": "middle"} + } + } + } + ] + } + ] + }, + { + "name": "lifelines", + "width": 400, + "height": 100, + "data": [ + { + "name": "people", + "values": [ + {"label":"Washington", "born":-7506057600000, "died":-5366196000000, + "enter":-5701424400000, "leave":-5453884800000}, + {"label":"Adams", "born":-7389766800000, "died":-4528285200000, + "enter":-5453884800000, "leave":-5327740800000}, + {"label":"Jefferson", "born":-7154586000000, "died":-4528285200000, + "enter":-5327740800000, "leave":-5075280000000}, + {"label":"Madison", "born":-6904544400000, "died":-4213184400000, + "enter":-5075280000000, "leave":-4822819200000}, + {"label":"Monroe", "born":-6679904400000, "died":-4370518800000, + "enter":-4822819200000, "leave":-4570358400000} + ] + }, + { + "name": "events", + "format": {"type":"json", "parse":{"when":"date"}}, + "values": [ + {"name":"Decl. of Independence", "when":"July 4, 1776"}, + {"name":"U.S. Constitution", "when":"3/4/1789"}, + {"name":"Louisiana Purchase", "when":"April 30, 1803"}, + {"name":"Monroe Doctrine", "when":"Dec 2, 1823"} + ] + } + + ], + "scales": [ + { + "name": "y", + "type": "ordinal", + "range": "height", + "domain": {"data": "people", "field": "data.label"} + }, + { + "name": "x", + "type": "time", + "range": "width", + "round": true, + "nice": "year", + "domain": {"data": "people", "field": ["data.born", "data.died"]} + } + ], + "axes": [ + {"type": "x", "scale": "x"} + ], + "marks": [ + { + "type": "text", + "from": {"data": "events"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.when"}, + "y": {"value": -10}, + "angle": {"value": -25}, + "fill": {"value": "#000"}, + "text": {"field": "data.name"}, + "font": {"value": "Helvetica Neue"}, + "fontSize": {"value": 10} + } + } + }, + { + "type": "rect", + "from": {"data": "events"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.when"}, + "y": {"value": -8}, + "width": {"value": 1}, + "height": {"group": "height", "offset": 8}, + "fill": {"value": "#888"} + } + } + }, + { + "type": "text", + "from": {"data": "people"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.born"}, + "y": {"scale": "y", "field": "data.label", "offset": -3}, + "fill": {"value": "#000"}, + "text": {"field": "data.label"}, + "font": {"value": "Helvetica Neue"}, + "fontSize": {"value": 10} + } + } + }, + { + "type": "rect", + "from": {"data": "people"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.born"}, + "x2": {"scale": "x", "field": "data.died"}, + "y": {"scale": "y", "field": "data.label"}, + "height": {"value": 2}, + "fill": {"value": "#557"} + } + } + }, + { + "type": "rect", + "from": {"data": "people"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.enter"}, + "x2": {"scale": "x", "field": "data.leave"}, + "y": {"scale": "y", "field": "data.label", "offset":-1}, + "height": {"value": 4}, + "fill": {"value": "#e44"} + } + } + } + ] + }, + { + "width": 1920, + "height": 1000, + "viewport": [960, 500], + "data": [ + { + "name": "world", + "url": "data/world-110m.json", + "format": {"type": "topojson", "feature": "countries"} + } + ], + "marks": [ + { + "type": "path", + "from": { + "data": "world", + "transform": [{ + "type": "geopath", + "value": "data", + "projection": "winkel3", + "scale": 300, + "translate": [960, 500] + }] + }, + "properties": { + "enter": { + "stroke": {"value": "#fff"}, + "path": {"field": "path"} + }, + "update": {"fill": {"value": "#ccc"}}, + "hover": {"fill": {"value": "pink"}} + } + } + ] + }, + { + "width": 760, + "height": 260, + "data": [ + { + "name": "temp", + "url": "data/napoleon.json", + "format": {"type": "json", "property": "temp"}, + "transform": [ + {"type": "formula", "field": "lat", "expr": "55"}, + { + "type": "geo", + "lat": "lat", + "lon": "data.lon", + "center": [32.52, 53.3], + "scale": 3000 + } + ] + }, + { + "name": "army", + "url": "data/napoleon.json", + "format": {"type": "json", "property": "army"}, + "transform": [ + { + "type": "geo", + "lat": "data.lat", + "lon": "data.lon", + "center": [32.52, 53.3], + "scale": 3000 + } + ] + }, + { + "name": "cities", + "url": "data/napoleon.json", + "format": {"type": "json", "property": "cities"}, + "transform": [ + { + "type": "geo", + "lat": "data.lat", + "lon": "data.lon", + "center": [32.52, 53.3], + "scale": 3000 + } + ] + } + ], + "scales": [ + { + "name": "color", + "type": "ordinal", + "domain": {"data": "army", "field": "data.dir" }, + "range": ["brown", "black"] + }, + { + "name": "lw", + "type": "linear", "zero": false, + "domain": {"data": "army", "field": "data.size"}, + "range": [1, 50] + } + ], + "marks": [ + { + "type": "group", + "properties": { + "enter": { + "x": {"value": 0}, + "y": {"value": 200}, + "width": {"group": "width"}, + "height": {"value": 60} + } + }, + "scales": [ + { + "name": "y", + "type": "linear", "zero": false, "round": true, + "domain": {"data": "temp", "field": "data.temp"}, + "range": "height" + } + ], + "axes": [ + {"type": "y", "scale": "y", "ticks": 4, "orient": "right", + "grid": true, "layer": "back"} + ], + "marks": [ + { + "type": "rule", + "from": {"data": "temp"}, + "properties": { + "enter": { + "x": {"field": "x"}, + "y1": 0, + "y2": {"scale": "y", "field": "data.temp"}, + "stroke": {"value": "#ccc"} + } + } + }, + { + "type": "line", + "from": {"data": "temp"}, + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"scale": "y", "field": "data.temp"}, + "stroke": {"value": "#000"}, + "strokeWidth": {"value": 2} + } + } + }, + { + "type": "text", + "from": {"data": "temp"}, + "properties": { + "enter": { + "x": {"field": "x", "offset": -2}, + "y": {"scale": "y", "field": "data.temp", "offset": 6}, + "fill": {"value": "#000"}, + "text": {"field": "data.date"}, + "font": {"value": "Georgia"}, + "fontSize": {"value": 10}, + "align": {"value": "center"}, + "baseline": {"value": "top"} + } + } + } + ] + }, + { + "type": "group", + "from": { + "data": "army", + "transform": [ + {"type": "facet", "keys": ["data.group", "data.dir"]} + ] + }, + "marks": [ + { + "type": "group", + "from": { + "transform": [ + {"type": "window", "size": 2, "step": 1} + ] + }, + "marks": [ + { + "type": "line", + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"field": "y"}, + "stroke": {"scale": "color", "field": "data.dir"}, + "strokeWidth": {"scale": "lw", "field": "data.size"}, + "strokeCap": {"value": "round"} + } + } + } + ] + } + ] + }, + { + "type": "symbol", + "from": {"data": "cities"}, + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"field": "y"}, + "size": {"value": 25}, + "fill": {"value": "brown"}, + "stroke": {"value": "#000"} + } + } + }, + { + "type": "text", + "from": {"data": "cities"}, + "properties": { + "enter": { + "x": {"field": "x", "offset": 1}, + "y": {"field": "y", "offset": -4}, + "fill": {"value": "#fff"}, + "fillOpacity": {"value": 0.8}, + "text": {"field": "data.city"}, + "align": {"value": "center"}, + "baseline": {"value": "bottom"}, + "font": {"value": "Georgia"}, + "fontSize": {"value": 9}, + "fontStyle": {"value": "italic"} + } + } + }, + { + "type": "text", + "from": {"data": "cities"}, + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"field": "y", "offset": -5}, + "fill": {"value": "#000"}, + "text": {"field": "data.city"}, + "align": {"value": "center"}, + "baseline": {"value": "bottom"}, + "font": {"value": "Georgia"}, + "fontSize": {"value": 9}, + "fontStyle": {"value": "italic"} + } + } + } + ] + }, + { + "width": 700, + "height": 400, + "data": [ + { + "name": "cars", + "url": "data/cars.json" + }, + { + "name": "fields", + "values": ["cyl", "dsp", "lbs", "hp", "acc", "mpg", "year"] + } + ], + "scales": [ + { + "name": "ord", + "type": "ordinal", + "range": "width", "points": true, + "domain": {"data": "fields", "field": "data"} + }, + { + "name": "cyl", + "range": "height", "zero": false, "nice": true, + "domain": {"data": "cars", "field": "data.cyl"} + }, + { + "name": "dsp", + "range": "height", "zero": false, "nice": true, + "domain": {"data": "cars", "field": "data.dsp"} + }, + { + "name": "lbs", + "range": "height", "zero": false, "nice": true, + "domain": {"data": "cars", "field": "data.lbs"} + }, + { + "name": "hp", + "range": "height", "zero": false, "nice": true, + "domain": {"data": "cars", "field": "data.hp"} + }, + { + "name": "acc", + "range": "height", "zero": false, "nice": true, + "domain": {"data": "cars", "field": "data.acc"} + }, + { + "name": "mpg", + "range": "height", "zero": false, "nice": true, + "domain": {"data": "cars", "field": "data.mpg"} + }, + { + "name": "year", + "range": "height", "zero": false, "nice": true, + "domain": {"data": "cars", "field": "data.year"} + } + ], + "axes": [ + {"type":"y", "scale":"cyl", "offset":{"scale":"ord", "value":"cyl"}}, + {"type":"y", "scale":"dsp", "offset":{"scale":"ord", "value":"dsp"}}, + {"type":"y", "scale":"lbs", "offset":{"scale":"ord", "value":"lbs"}}, + {"type":"y", "scale":"hp", "offset":{"scale":"ord", "value":"hp"}}, + {"type":"y", "scale":"acc", "offset":{"scale":"ord", "value":"acc"}}, + {"type":"y", "scale":"mpg", "offset":{"scale":"ord", "value":"mpg"}}, + {"type":"y", "scale":"year", "offset":{"scale":"ord", "value":"year"}} + ], + "marks": [ + { + "type": "group", + "from": {"data": "cars"}, + "marks": [ + { + "type": "line", + "from": {"data": "fields"}, + "properties": { + "enter": { + "x": {"scale": "ord", "field": "data"}, + "y": {"scale": {"field": "data"}, "group": "data", "field": "data"}, + "stroke": {"value": "steelblue"}, + "strokeWidth": {"value": 1}, + "strokeOpacity": {"value": 0.3} + } + } + } + ] + }, + { + "type": "text", + "from": {"data": "fields"}, + "properties": { + "enter": { + "x": {"scale": "ord", "field": "data", "offset":-8}, + "y": {"group": "height", "offset": 6}, + "fontWeight": {"value": "bold"}, + "fill": {"value": "black"}, + "text": {"field": "data"}, + "align": {"value": "right"}, + "baseline": {"value": "top"} + } + } + } + ] + }, + { + "width": 700, + "height": 400, + "padding": {"top": 0, "left": 0, "bottom": 20, "right": 0}, + "data": [ + { + "name": "pop2000", + "url": "data/population.json", + "transform": [ + {"type": "filter", "test": "d.data.year == 2000"} + ] + } + ], + "scales": [ + { + "name": "g", + "domain": [0, 1], + "range": [340, 10] + }, + { + "name": "y", + "type": "ordinal", + "range": "height", + "reverse": true, + "domain": {"data": "pop2000", "field": "data.age"} + }, + { + "name": "c", + "type": "ordinal", + "domain": [1, 2], + "range": ["#1f77b4", "#e377c2"] + } + ], + "marks": [ + { + "type": "text", + "interactive": false, + "from": { + "data": "pop2000", + "transform": [{"type":"unique", "field":"data.age", "as":"age"}] + }, + "properties": { + "enter": { + "x": {"value": 325}, + "y": {"scale": "y", "field": "age", "offset": 11}, + "text": {"field": "age"}, + "baseline": {"value": "middle"}, + "align": {"value": "center"}, + "fill": {"value": "#000"} + } + } + }, + { + "type": "group", + "from": { + "data": "pop2000", + "transform": [ + {"type":"facet", "keys":["data.sex"]} + ] + }, + "properties": { + "update": { + "x": {"scale": "g", "field": "index"}, + "y": {"value": 0}, + "width": {"value": 300}, + "height": {"group": "height"} + } + }, + "scales": [ + { + "name": "x", + "type": "linear", + "range": "width", + "reverse": {"field": "index"}, + "nice": true, + "domain": {"data": "pop2000", "field": "data.people"} + } + ], + "axes": [ + {"type": "x", "scale": "x", "format": "s"} + ], + "marks": [ + { + "type": "rect", + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.people"}, + "x2": {"scale": "x", "value": 0}, + "y": {"scale": "y", "field": "data.age"}, + "height": {"scale": "y", "band": true, "offset": -1}, + "fillOpacity": {"value": 0.6}, + "fill": {"scale": "c", "field": "data.sex"} + } + } + } + ] + } + ] + }, + { + "width": 200, + "height": 200, + "data": [ + { + "name": "iris", + "url": "data/iris.json" + } + ], + "scales": [ + { + "name": "x", + "nice": true, + "range": "width", + "domain": {"data": "iris", "field": "data.sepalWidth"} + }, + { + "name": "y", + "nice": true, + "range": "height", + "domain": {"data": "iris", "field": "data.petalLength"} + }, + { + "name": "c", + "type": "ordinal", + "domain": {"data": "iris", "field": "data.species"}, + "range": ["#800", "#080", "#008"] + } + ], + "axes": [ + {"type": "x", "scale": "x", "offset": 5, "ticks": 5, "title": "Sepal Width"}, + {"type": "y", "scale": "y", "offset": 5, "ticks": 5, "title": "Petal Length"} + ], + "legends": [ + { + "fill": "c", + "title": "Species", + "offset": 0, + "properties": { + "symbols": { + "fillOpacity": {"value": 0.5}, + "stroke": {"value": "transparent"} + } + } + } + ], + "marks": [ + { + "type": "symbol", + "from": {"data": "iris"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.sepalWidth"}, + "y": {"scale": "y", "field": "data.petalLength"}, + "fill": {"scale": "c", "field": "data.species"}, + "fillOpacity": {"value": 0.5} + }, + "update": { + "size": {"value": 100}, + "stroke": {"value": "transparent"} + }, + "hover": { + "size": {"value": 300}, + "stroke": {"value": "white"} + } + } + } + ] + }, + { + "width": 600, + "height": 600, + "data": [ + { + "name": "iris", + "url": "data/iris.json" + }, + { + "name": "fields", + "values": ["petalLength", "petalWidth", "sepalWidth", "sepalLength"] + } + ], + "scales": [ + { + "name": "gx", + "type": "ordinal", + "range": "width", + "round": true, + "domain": {"data": "fields", "field": "data"} + }, + { + "name": "gy", + "type": "ordinal", + "range": "height", + "round": true, + "domain": {"data": "fields", "field": "data"} + }, + { + "name": "c", + "type": "ordinal", + "domain": {"data": "iris", "field": "data.species"}, + "range": ["#800", "#080", "#008"] + } + ], + "legends": [ + { + "fill": "c", + "title": "Species", + "offset": 10, + "properties": { + "symbols": { + "fillOpacity": {"value": 0.5}, + "stroke": {"value": "transparent"} + } + } + } + ], + "marks": [ + { + "type": "group", + "from": { + "data": "fields", + "transform": [{"type": "cross"}] + }, + "properties": { + "enter": { + "x": {"scale": "gx", "field": "a.data"}, + "y": {"scale": "gy", "field": "b.data"}, + "width": {"scale": "gx", "band": true, "offset":-35}, + "height": {"scale": "gy", "band": true, "offset":-35}, + "stroke": {"value": "#ddd"} + } + }, + "scales": [ + { + "name": "x", + "range": "width", + "zero": false, + "round": true, + "domain": {"data": "iris", "field": {"group": "a.data"}} + }, + { + "name": "y", + "range": "height", + "zero": false, + "round": true, + "domain": {"data": "iris", "field": {"group": "b.data"}} + } + ], + "axes": [ + {"type": "x", "scale": "x", "ticks": 5}, + {"type": "y", "scale": "y", "ticks": 5} + ], + "marks": [ + { + "type": "symbol", + "from": {"data": "iris"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": {"group": "a.data"}}, + "y": {"scale": "y", "field": {"group": "b.data"}}, + "fill": {"scale": "c", "field": "data.species"}, + "fillOpacity": {"value": 0.5} + }, + "update": { + "size": {"value": 36}, + "stroke": {"value": "transparent"} + }, + "hover": { + "size": {"value": 100}, + "stroke": {"value": "white"} + } + } + } + ] + } + ] + }, + { + "width": 500, + "height": 200, + "padding": {"top": 10, "left": 30, "bottom": 30, "right": 10}, + "data": [ + { + "name": "table", + "values": [ + {"x": 0, "y": 28, "c":0}, {"x": 0, "y": 55, "c":1}, + {"x": 1, "y": 43, "c":0}, {"x": 1, "y": 91, "c":1}, + {"x": 2, "y": 81, "c":0}, {"x": 2, "y": 53, "c":1}, + {"x": 3, "y": 19, "c":0}, {"x": 3, "y": 87, "c":1}, + {"x": 4, "y": 52, "c":0}, {"x": 4, "y": 48, "c":1}, + {"x": 5, "y": 24, "c":0}, {"x": 5, "y": 49, "c":1}, + {"x": 6, "y": 87, "c":0}, {"x": 6, "y": 66, "c":1}, + {"x": 7, "y": 17, "c":0}, {"x": 7, "y": 27, "c":1}, + {"x": 8, "y": 68, "c":0}, {"x": 8, "y": 16, "c":1}, + {"x": 9, "y": 49, "c":0}, {"x": 9, "y": 15, "c":1} + ] + }, + { + "name": "stats", + "source": "table", + "transform": [ + {"type": "facet", "keys": ["data.x"]}, + {"type": "stats", "value": "data.y"} + ] + } + ], + "scales": [ + { + "name": "x", + "type": "linear", + "range": "width", + "zero": false, + "domain": {"data": "table", "field": "data.x"} + }, + { + "name": "y", + "type": "linear", + "range": "height", + "nice": true, + "domain": {"data": "stats", "field": "sum"} + }, + { + "name": "color", + "type": "ordinal", + "range": "category10" + } + ], + "axes": [ + {"type": "x", "scale": "x"}, + {"type": "y", "scale": "y"} + ], + "marks": [ + { + "type": "group", + "from": { + "data": "table", + "transform": [ + {"type": "facet", "keys": ["data.c"]}, + {"type": "stack", "point": "data.x", "height": "data.y"} + ] + }, + "marks": [ + { + "type": "area", + "properties": { + "enter": { + "interpolate": {"value": "monotone"}, + "x": {"scale": "x", "field": "data.x"}, + "y": {"scale": "y", "field": "y"}, + "y2": {"scale": "y", "field": "y2"}, + "fill": {"scale": "color", "field": "data.c"} + }, + "update": { + "fillOpacity": {"value": 1} + }, + "hover": { + "fillOpacity": {"value": 0.5} + } + } + } + ] + } + ] + }, + { + "width": 500, + "height": 200, + "padding": {"top": 10, "left": 30, "bottom": 30, "right": 10}, + "data": [ + { + "name": "table", + "values": [ + {"x": 0, "y": 28, "c":0}, {"x": 0, "y": 55, "c":1}, + {"x": 1, "y": 43, "c":0}, {"x": 1, "y": 91, "c":1}, + {"x": 2, "y": 81, "c":0}, {"x": 2, "y": 53, "c":1}, + {"x": 3, "y": 19, "c":0}, {"x": 3, "y": 87, "c":1}, + {"x": 4, "y": 52, "c":0}, {"x": 4, "y": 48, "c":1}, + {"x": 5, "y": 24, "c":0}, {"x": 5, "y": 49, "c":1}, + {"x": 6, "y": 87, "c":0}, {"x": 6, "y": 66, "c":1}, + {"x": 7, "y": 17, "c":0}, {"x": 7, "y": 27, "c":1}, + {"x": 8, "y": 68, "c":0}, {"x": 8, "y": 16, "c":1}, + {"x": 9, "y": 49, "c":0}, {"x": 9, "y": 15, "c":1} + ] + }, + { + "name": "stats", + "source": "table", + "transform": [ + {"type": "facet", "keys": ["data.x"]}, + {"type": "stats", "value": "data.y"} + ] + } + ], + "scales": [ + { + "name": "x", + "type": "ordinal", + "range": "width", + "domain": {"data": "table", "field": "data.x"} + }, + { + "name": "y", + "type": "linear", + "range": "height", + "nice": true, + "domain": {"data": "stats", "field": "sum"} + }, + { + "name": "color", + "type": "ordinal", + "range": "category10" + } + ], + "axes": [ + {"type": "x", "scale": "x"}, + {"type": "y", "scale": "y"} + ], + "marks": [ + { + "type": "group", + "from": { + "data": "table", + "transform": [ + {"type": "facet", "keys": ["data.c"]}, + {"type": "stack", "point": "data.x", "height": "data.y"} + ] + }, + "marks": [ + { + "type": "rect", + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.x"}, + "width": {"scale": "x", "band": true, "offset": -1}, + "y": {"scale": "y", "field": "y"}, + "y2": {"scale": "y", "field": "y2"}, + "fill": {"scale": "color", "field": "data.c"} + }, + "update": { + "fillOpacity": {"value": 1} + }, + "hover": { + "fillOpacity": {"value": 0.5} + } + } + } + ] + } + ] + }, + { + "width": 500, + "height": 200, + "data": [ + { + "name": "stocks", + "url": "data/stocks.csv", + "format": {"type": "csv", "parse": {"price":"number", "date":"date"}} + } + ], + "scales": [ + { + "name": "x", + "type": "time", + "range": "width", + "domain": {"data": "stocks", "field": "data.date"} + }, + { + "name": "y", + "type": "linear", + "range": "height", + "nice": true, + "domain": {"data": "stocks", "field": "data.price"} + }, + { + "name": "color", "type": "ordinal", "range": "category10" + } + ], + "axes": [ + {"type": "x", "scale": "x", "tickSizeEnd": 0}, + {"type": "y", "scale": "y"} + ], + "marks": [ + { + "type": "group", + "from": { + "data": "stocks", + "transform": [{"type": "facet", "keys": ["data.symbol"]}] + }, + "marks": [ + { + "type": "line", + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.date"}, + "y": {"scale": "y", "field": "data.price"}, + "stroke": {"scale": "color", "field": "data.symbol"}, + "strokeWidth": {"value": 2} + } + } + }, + { + "type": "text", + "from": { + "transform": [{"type": "filter", "test": "index==data.length-1"}] + }, + "properties": { + "enter": { + "x": {"scale": "x", "field": "data.date", "offset": 2}, + "y": {"scale": "y", "field": "data.price"}, + "fill": {"scale": "color", "field": "data.symbol"}, + "text": {"field": "data.symbol"}, + "baseline": {"value": "middle"} + } + } + } + ] + } + ] + }, + { + "name": "treemap", + "width": 960, + "height": 500, + "padding": 2.5, + "data": [ + { + "name": "tree", + "url": "data/flare.json", + "format": {"type": "treejson"}, + "transform": [ + {"type": "treemap", "value": "data.size"} + ] + } + ], + "scales": [ + { + "name": "color", + "type": "ordinal", + "range": [ + "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d", + "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476", + "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc", + "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9" + ] + }, + { + "name": "size", + "type": "ordinal", + "domain": [0, 1, 2, 3], + "range": [256, 28, 20, 14] + }, + { + "name": "opacity", + "type": "ordinal", + "domain": [0, 1, 2, 3], + "range": [0.15, 0.5, 0.8, 1.0] + } + ], + "marks": [ + { + "type": "rect", + "from": { + "data": "tree", + "transform": [{"type":"filter", "test":"d.values"}] + }, + "interactive": false, + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"field": "y"}, + "width": {"field": "width"}, + "height": {"field": "height"}, + "fill": {"scale": "color", "field": "data.name"} + } + } + }, + { + "type": "rect", + "from": { + "data": "tree", + "transform": [{"type":"filter", "test":"!d.values"}] + }, + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"field": "y"}, + "width": {"field": "width"}, + "height": {"field": "height"}, + "stroke": {"value": "#fff"} + }, + "update": { + "fill": {"value": "rgba(0,0,0,0)"} + }, + "hover": { + "fill": {"value": "red"} + } + } + }, + { + "type": "text", + "from": { + "data": "tree", + "transform": [{"type":"filter", "test":"d.values"}] + }, + "interactive": false, + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"field": "y"}, + "dx": {"field": "width", "mult": 0.5}, + "dy": {"field": "height", "mult": 0.5}, + "font": {"value": "Helvetica Neue"}, + "fontSize": {"scale": "size", "field": "depth"}, + "align": {"value": "center"}, + "baseline": {"value": "middle"}, + "fill": {"value": "#000"}, + "fillOpacity": {"scale": "opacity", "field": "depth"}, + "text": {"field": "data.name"} + } + } + } + ] + }, + { + "width": 250, + "height": 200, + "data": [ + { + "name": "weather", + "url": "data/weather.json" + } + ], + "scales": [ + { + "name": "x", + "type": "ordinal", + "range": "width", + "padding": 0.1, "round": true, + "domain": {"data": "weather", "field": "index"} + }, + { + "name": "y", + "range": "height", + "nice": true, "zero": false, "round": true, + "domain": { + "data": "weather", + "field": ["data.record.low", "data.record.high"] + } + } + ], + "axes": [ + { "type": "y", "scale": "y", "ticks": 3, "tickSize": 0, + "orient": "right", "grid": true, + "properties": { + "grid": {"stroke": {"value": "white"}, "strokeWidth": {"value": 2}}, + "axis": {"stroke": {"value": "transparent"}} + } + } + ], + "marks": [ + { + "type": "text", + "from": {"data": "weather"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "index"}, + "dx": {"scale": "x", "band": true, "mult": 0.5}, + "y": {"value": 0}, + "fill": {"value": "#000"}, + "text": {"field": "data.day"}, + "align": {"value": "center"}, + "baseline": {"value": "bottom"} + } + } + }, + { + "type": "rect", + "from": {"data": "weather"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "index"}, + "width": {"scale": "x", "band": true, "offset": -1}, + "y": {"scale": "y", "field": "data.record.low"}, + "y2": {"scale": "y", "field": "data.record.high"}, + "fill": {"value": "#ccc"} + } + } + }, + { + "type": "rect", + "from": {"data": "weather"}, + "properties": { + "enter": { + "x": {"scale": "x", "field": "index"}, + "width": {"scale": "x", "band": true, "offset": -1}, + "y": {"scale": "y", "field": "data.normal.low"}, + "y2": {"scale": "y", "field": "data.normal.high"}, + "fill": {"value": "#999"} + } + } + }, + { + "type": "rect", + "from": { + "data": "weather", + "transform": [{"type":"filter", "test":"d.data.actual"}] + }, + "properties": { + "enter": { + "x": {"scale": "x", "field": "index", "offset": 4}, + "width": {"scale": "x", "band": true, "offset": -8}, + "y": {"scale": "y", "field": "data.actual.low"}, + "y2": {"scale": "y", "field": "data.actual.high"}, + "fill": {"value": "#000"} + } + } + }, + { + "type": "rect", + "from": { + "data": "weather", + "transform": [{"type":"filter", "test":"d.data.forecast"}] + }, + "properties": { + "enter": { + "x": {"scale": "x", "field": "index", "offset": 9}, + "width": {"scale": "x", "band": true, "offset": -18}, + "y": {"scale": "y", "field": "data.forecast.low.low"}, + "y2": {"scale": "y", "field": "data.forecast.high.high"}, + "fill": {"value": "#000"} + } + } + }, + { + "type": "rect", + "from": { + "data": "weather", + "transform": [{"type":"filter", "test":"d.data.forecast"}] + }, + "properties": { + "enter": { + "x": {"scale": "x", "field": "index", "offset": 4}, + "width": {"scale": "x", "band": true, "offset": -8}, + "y": {"scale": "y", "field": "data.forecast.low.low"}, + "y2": {"scale": "y", "field": "data.forecast.low.high"}, + "fill": {"value": "#000"} + } + } + }, + { + "type": "rect", + "from": { + "data": "weather", + "transform": [{"type":"filter", "test":"d.data.forecast"}] + }, + "properties": { + "enter": { + "x": {"scale": "x", "field": "index", "offset": 4}, + "width": {"scale": "x", "band": true, "offset": -8}, + "y": {"scale": "y", "field": "data.forecast.high.low"}, + "y2": {"scale": "y", "field": "data.forecast.high.high"}, + "fill": {"value": "#000"} + } + } + } + ] + }, + { + "name": "wordcloud", + "width": 400, + "height": 400, + "padding": {"top":0, "bottom":0, "left":0, "right":0}, + "data": [ + { + "name": "table", + "values": [ + {"text": "poem", "value": 80}, + {"text": "peom", "value": 44}, + {"text": "moep", "value": 40}, + {"text": "meop", "value": 36}, + {"text": "emop", "value": 32}, + {"text": "epom", "value": 28}, + {"text": "opem", "value": 24}, + {"text": "omep", "value": 20}, + {"text": "mope", "value": 56}, + {"text": "mepo", "value": 12}, + {"text": "pemo", "value": 10}, + {"text": "pome", "value": 10} + ], + "transform": [ + { + "type": "wordcloud", + "text": "data.text", + "font": "Helvetica Neue", + "fontSize": "data.value", + "rotate": {"random": [-60,-30,0,30,60]} + } + ] + } + ], + "marks": [ + { + "type": "text", + "from": {"data": "table"}, + "properties": { + "enter": { + "x": {"field": "x"}, + "y": {"field": "y"}, + "angle": {"field": "angle"}, + "align": {"value": "center"}, + "baseline": {"value": "alphabetic"}, + "font": {"field": "font"}, + "fontSize": {"field": "fontSize"}, + "text": {"field": "data.text"} + }, + "update": { + "fill": {"value": "steelblue"} + }, + "hover": { + "fill": {"value": "#f00"} + } + } + } + ] + } +]; + +specs.forEach(spec => { + vg.parse.spec(spec, chart => { + chart({el:"#vis"}).update(); + }); +}); \ No newline at end of file diff --git a/vega/vega.d.ts b/vega/vega.d.ts new file mode 100644 index 0000000000..3e82fc2ca1 --- /dev/null +++ b/vega/vega.d.ts @@ -0,0 +1,307 @@ +// Type definitions for Vega +// Project: http://trifacta.github.io/vega/ +// Definitions by: Tom Crockett +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Vega { + export interface VG { + parse: Parse; + } + + export interface Parse { + spec(url: string, callback: (chart: (args: ViewArgs) => View) => void): void; + spec(spec: Spec, callback: (chart: (args: ViewArgs) => View) => void): void; + data(dataSet: Vega.Data[], callback: () => void): void; + // TODO all the other stuff + } + + export interface ViewArgs { + // TODO docs + el: any; + data?: any; + hover?: boolean; + renderer?: string; + } + + export interface View { + // TODO docs + width(): number; + width(w: number): View; + + height(): number; + height(h: number): View; + + padding(): Padding; + padding(p: Padding): View; + + viewport(): number[]; + viewport(v: number[]): View; + + renderer(r: string): View; + + data(): any; + data(d: any): View; + + initialize(i: any): View; + + render(r?: any[]): View; + + update(options?: UpdateOptions): View; + } + + export interface Padding { + // TODO docs + top: number; + right: number; + bottom: number; + left: number; + } + + export interface UpdateOptions { + // TODO docs + props?: string; + items?: any; + duration?: number; + ease?: string; + } + + export interface Spec { + /** + * A unique name for the visualization specification. + */ + name?: string; + /** + * The total width, in pixels, of the data rectangle. Default is 500 if + * undefined. + */ + width?: number; + /** + * The total height, in pixels, of the data rectangle. Default is 500 if + * undefined. + */ + height?: number; + /** + * The width and height of the on-screen viewport, in pixels. If necessary, + * clipping and scrolling will be applied. + */ + viewport?: number[]; + /** + * [Number | Object | String] + * The internal padding, in pixels, from the edge of the visualization + * canvas to the data rectangle. If an object is provided, it must include + * {top, left, right, bottom} properties. Two string values are also + * acceptable: "auto" (the default) and "strict". Auto-padding computes the + * padding dynamically based on the contents of the visualization. All + * marks, including axes and legends, are used to compute the necessary + * padding. "Strict" auto-padding attempts to adjust the padding such that + * the overall width and height of the visualization is unchanged. This mode + * can cause the visualization's width and height parameters to be adjusted + * such that the total size, including padding, remains constant. Note that + * in some cases strict padding is not possible; for example, if the axis + * labels are much larger than the data rectangle. + */ + padding?: any; + /** + * Definitions of data to visualize. + */ + data: Data[]; + /** + * Scale transform definitions. + */ + scales?: Scale[]; + /** + * Axis definitions. + */ + axes?: Axis[]; + /** + * Legend definitions. + */ + legends?: Legend[]; + /** + * Graphical mark definitions. + */ + marks: Mark[]; + } + + export interface Data { + /** + * A unique name for the data set. + */ + name: string; + /** + * An object that specifies the format for the data file, if loaded from a + * URL. + */ + format?: Data.Format; + /** + * The actual data set to use. The values property allows data to be inlined + * directly within the specification itself. + */ + values?: any; + /** + * The name of another data set to use as the source for this data set. The + * source property is particularly useful in combination with a transform + * pipeline to derive new data. + */ + source?: string; + /** + * A URL from which to load the data set. Use the format property to ensure + * the loaded data is correctly parsed. If the format property is not specified, + * the data is assumed to be in a row-oriented JSON format. + */ + url?: string; + /** + * An array of transforms to perform on the data. Transform operators will be + * run on the default data, as provided by late-binding or as specified by the + * source, values, or url properties. + */ + transform?: Data.Transform[]; + } + + export module Data { + export interface Format { + /** + * The currently supported format types are json (JavaScript Object + * Notation), csv (comma-separated values), tsv (tab-separated values), + * topojson, and treejson. + */ + type?: string; + // TODO: fields for specific formats + } + + export interface Transform { + // TODO + } + } + + export interface Scale { + // TODO docs + + // -- Common scale properties + name?: string; + type?: string; + domain?: any; + domainMin?: any; + domainMax?: any; + range?: any; + rangeMin?: any; + rangeMax?: any; + reverse?: boolean; + round?: boolean; + + // -- Ordinal scale properties + points?: boolean; + padding?: number; + sort?: boolean; + + // -- Time/Quantitative scale properties + clamp?: boolean; + nice?: any; // boolean for quantitative scales, string for time scales + + // -- Quantitative scale properties + exponent?: number; + zero?: boolean; + } + + export interface Axis { + // TODO + } + + export interface Legend { + // TODO + } + + export interface Mark { + // TODO docs + type: string; + name?: string; + description?: string; + from?: Mark.From; + properties?: Mark.PropertySets; + key?: string; + delay?: Mark.ValueRef; + } + + export module Mark { + export interface From { + // TODO docs + data?: string; + transform?: Data.Transform[]; + } + + export interface PropertySets { + // TODO docs + enter?: PropertySet; + exit?: PropertySet; + update?: PropertySet; + hover?: PropertySet; + } + + export interface PropertySet { + // TODO docs + + // -- Shared visual properties + x?: ValueRef; + x2?: ValueRef; + width?: ValueRef; + y?: ValueRef; + y2?: ValueRef; + height?: ValueRef; + opacity?: ValueRef; + fill?: ValueRef; + fillOpacity?: ValueRef; + stroke?: ValueRef; + strokeWidth?: ValueRef; + strokeOpacity?: ValueRef; + strokeDash?: ValueRef; + strokeDashOffset?: ValueRef; + + // -- symbol + size?: ValueRef; + shape?: ValueRef; + + // -- path + path?: ValueRef; + + // -- arc + innerRadius?: ValueRef; + outerRadius?: ValueRef; + startAngle?: ValueRef; + endAngle?: ValueRef; + + // -- area / line + interpolate?: ValueRef; + tension?: ValueRef; + + // -- image / text + align?: ValueRef; + baseline?: ValueRef; + + // -- image + url?: ValueRef; + + // -- text + text?: ValueRef; + dx?: ValueRef; + dy?: ValueRef; + angle?: ValueRef; + font?: ValueRef; + fontSize?: ValueRef; + fontWeight?: ValueRef; + fontStyle?: ValueRef; + } + + export interface ValueRef { + // TODO docs + value?: any; + field?: any; + group?: any; + scale?: any; + mult?: number; + offset?: number; + band?: boolean; + } + } +} + +declare var vg: Vega.VG; \ No newline at end of file From fe5f1af0ac034e9951f267326f6b6c347b565cfa Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 28 Jan 2014 02:20:32 +0100 Subject: [PATCH 080/240] moved universal-analytics .debug() method --- universal-analytics/universal-analytics-test.ts | 2 +- universal-analytics/universal-analytics.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/universal-analytics/universal-analytics-test.ts b/universal-analytics/universal-analytics-test.ts index 4249218d95..90b68d6a27 100644 --- a/universal-analytics/universal-analytics-test.ts +++ b/universal-analytics/universal-analytics-test.ts @@ -10,7 +10,7 @@ var params:Object; var x:any; var client:UniversalAnalytics.Client = ui('UA-123-00'); -client = ui.debug(); +client = client.debug(); client.send(); client = client.pageview(str); diff --git a/universal-analytics/universal-analytics.d.ts b/universal-analytics/universal-analytics.d.ts index af81eac94b..7b08d85293 100644 --- a/universal-analytics/universal-analytics.d.ts +++ b/universal-analytics/universal-analytics.d.ts @@ -5,12 +5,12 @@ interface UniversalAnalytics { (accountID:string, uuid?:string, opts?:Object):UniversalAnalytics.Client; - debug():UniversalAnalytics.Client; } declare module UniversalAnalytics { interface Client { + debug():UniversalAnalytics.Client; send():void; From 8bbf4084f0388a1bf61b4dc12a2562213bb52184 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 11:34:13 +0000 Subject: [PATCH 081/240] (angular-ui-router) Set `toPath` argument to any The `toPath` argument on `IUrlRouterProvider.when` can also be a function that returns a string and an injected function (i.e. any[]). --- angular-ui/angular-ui-router.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index bc3e27c2dd..eec2cfcf34 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -42,9 +42,9 @@ declare module ng.ui { } interface IUrlRouterProvider extends IServiceProvider { - when(whenPath: string, toPath: string): IUrlRouterProvider; - when(whenPath: RegExp, toPath: string): IUrlRouterProvider; - when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider; + when(whenPath: string, toPath: any): IUrlRouterProvider; + when(whenPath: RegExp, toPath: any): IUrlRouterProvider; + when(whenPath: IUrlMatcher, toPath: any): IUrlRouterProvider; otherwise(path: string): IUrlRouterProvider; otherwise(path: Function): IUrlRouterProvider; rule(handler: Function): IUrlRouterProvider; From 8c23d04a5b4a0505df042a82be90f95adff02d87 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 28 Jan 2014 13:05:54 +0000 Subject: [PATCH 082/240] jQuery: JSDoc continues removed unused merge overload / changed parseJSON return type to Object --- jquery/jquery.d.ts | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 2b4268da5d..91602df536 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -979,19 +979,52 @@ interface JQueryStatic { */ isXMLDoc(node: Node): boolean; + /** + * Convert an array-like object into a true JavaScript array. + * + * @param obj Any object to turn into a native Array. + */ makeArray(obj: any): any[]; + /** + * Translate all items in an array or object to new array of items. + * + * @param array The Array to translate. + * @param callback The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object. + */ map(array: T[], callback: (elementOfArray: T, indexInArray: number) => U): U[]; - map(array: any, callback: (elementOfArray: any, indexInArray: any) => any): any; + /** + * Translate all items in an array or object to new array of items. + * + * @param arrayOrObject The Array or Object to translate. + * @param callback The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object. + */ + map(arrayOrObject: any, callback: (value: any, indexOrKey: any) => any): any; + /** + * Merge the contents of two arrays together into the first array. + * + * @param first The first array to merge, the elements of second added. + * @param second The second array to merge into the first, unaltered. + */ merge(first: T[], second: T[]): T[]; - merge(first: T[], second: U[]): any[]; + /** + * An empty function. + */ noop(): any; + /** + * Return a number representing the current time. + */ now(): number; - parseJSON(json: string): any; + /** + * Takes a well-formed JSON string and returns the resulting JavaScript object. + * + * @param json The JSON string to parse. + */ + parseJSON(json: string): Object; /** * Parses a string into an XML document. From 72f432b112f636ff2c2230a2faf13f03eb0cf097 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 28 Jan 2014 13:19:30 +0000 Subject: [PATCH 083/240] jQuery: JSDoc continues --- jquery/jquery.d.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 91602df536..33033106e8 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1033,13 +1033,26 @@ interface JQueryStatic { */ parseXML(data: string): XMLDocument; - queue(element: Element, queueName: string, newQueue: any[]): JQuery; - + /** + * Remove the whitespace from the beginning and end of a string. + * + * @param str Remove the whitespace from the beginning and end of a string. + */ trim(str: string): string; + /** + * Determine the internal JavaScript [[Class]] of an object. + * + * @param obj Object to get the internal JavaScript [[Class]] of. + */ type(obj: any): string; - unique(arr: any[]): any[]; + /** + * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers. + * + * @param array The Array of DOM elements. + */ + unique(array: Element[]): Element[]; /** * Parses a string into an array of DOM nodes. From e65a30bcc8bd5179302f67d3fc8cbb07c2bd3743 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 28 Jan 2014 13:57:58 +0000 Subject: [PATCH 084/240] jQuery: removed undocumented properties --- jquery/jquery-tests.ts | 5 ----- jquery/jquery.d.ts | 4 ---- 2 files changed, 9 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 0516fa82c2..c3fc3032f3 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -448,11 +448,6 @@ function test_toggle() { }); } -function test_easing() { - var result: number = $.easing.linear(3); - var result: number = $.easing.swing(3); -} - function test_append() { $('.inner').append('

Test

'); $('.container').append($('h2')); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 33033106e8..0d26a82533 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1062,10 +1062,6 @@ interface JQueryStatic { * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string */ parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[]; - - Animation(elem: any, properties: any, options: any): any; - - easing: JQueryEasing; } /** From adcb4a09b36a7a04b4564277f9f9b06ce09feaba Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 14:20:21 +0000 Subject: [PATCH 085/240] Explode all combinations --- angular-ui/angular-ui-router.d.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index eec2cfcf34..eb3bca9ac5 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -42,12 +42,20 @@ declare module ng.ui { } interface IUrlRouterProvider extends IServiceProvider { - when(whenPath: string, toPath: any): IUrlRouterProvider; - when(whenPath: RegExp, toPath: any): IUrlRouterProvider; - when(whenPath: IUrlMatcher, toPath: any): IUrlRouterProvider; + when(whenPath: string, toPath: string): IUrlRouterProvider; + when(whenPath: RegExp, toPath: string): IUrlRouterProvider; + when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider; + when(whenPath: string, handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; + when(whenPath: RegExp, handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; + when(whenPath: IUrlMatcher, hanlder: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; + when(whenPath: string, handler: any[]): IUrlRouterProvider; + when(whenPath: RegExp, handler: any[]): IUrlRouterProvider; + when(whenPath: IUrlMatcher, handler: any[]): IUrlRouterProvider; otherwise(path: string): IUrlRouterProvider; - otherwise(path: Function): IUrlRouterProvider; - rule(handler: Function): IUrlRouterProvider; + otherwise(handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; + otherwise(handler: any[]): IUrlRouterProvider; + rule(handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; + rule(handler: any[]): IUrlRouterProvider; } interface IStateOptions { From 8867eb90b8e716520df0d1a0bbceb53d2e52d2ae Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 14:53:09 +0000 Subject: [PATCH 086/240] Add tests --- angular-ui/angular-ui-router-tests.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/angular-ui/angular-ui-router-tests.ts b/angular-ui/angular-ui-router-tests.ts index 38f8b5ca00..f52d35837b 100644 --- a/angular-ui/angular-ui-router-tests.ts +++ b/angular-ui/angular-ui-router-tests.ts @@ -9,11 +9,21 @@ interface MyAppScope extends ng.IScope { myApp.config(( $stateProvider: ng.ui.IStateProvider, - $urlRouterProvider: ng.ui.IUrlRouterProvider) => { - // - // For any unmatched url, redirect to /state1 - $urlRouterProvider.otherwise("/state1"); - // + $urlRouterProvider: ng.ui.IUrlRouterProvider, + $urlMatcherFactory: ng.ui.IUrlMatcherFactory) => { + + var matcher: ng.ui.IUrlMatcher = $urlMatcherFactory.compile("/foo/:bar?param1"); + + $urlRouterProvider + .when('/test', '/list') + .when(/\/test\d/, ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => { + return '/list'; + }) + .when(matcher, ['$injector', '$location', ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => { + return false; + }]) + .otherwise("/state1"); + // Now set up the states $stateProvider .state('state1', { @@ -58,4 +68,4 @@ myApp.config(( "viewB": { template: "route2.viewB" } } }); -}); \ No newline at end of file +}); From f5ad5d5d010e018f7db912a0fe952a0e05dac386 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 15:39:52 +0000 Subject: [PATCH 087/240] Fix tests --- angular-ui/angular-ui-router.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index eb3bca9ac5..da3d92e5ec 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -42,19 +42,19 @@ declare module ng.ui { } interface IUrlRouterProvider extends IServiceProvider { - when(whenPath: string, toPath: string): IUrlRouterProvider; - when(whenPath: RegExp, toPath: string): IUrlRouterProvider; - when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider; - when(whenPath: string, handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; - when(whenPath: RegExp, handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; - when(whenPath: IUrlMatcher, hanlder: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; - when(whenPath: string, handler: any[]): IUrlRouterProvider; + when(whenPath: RegExp, handler: Function): IUrlRouterProvider; when(whenPath: RegExp, handler: any[]): IUrlRouterProvider; + when(whenPath: RegExp, toPath: string): IUrlRouterProvider; + when(whenPath: IUrlMatcher, hanlder: Function): IUrlRouterProvider; when(whenPath: IUrlMatcher, handler: any[]): IUrlRouterProvider; - otherwise(path: string): IUrlRouterProvider; - otherwise(handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; + when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider; + when(whenPath: string, handler: Function): IUrlRouterProvider; + when(whenPath: string, handler: any[]): IUrlRouterProvider; + when(whenPath: string, toPath: string): IUrlRouterProvider; + otherwise(handler: Function): IUrlRouterProvider; otherwise(handler: any[]): IUrlRouterProvider; - rule(handler: ($injector?: ng.auto.IInjectorService, $location?: ng.ILocationService) => any): IUrlRouterProvider; + otherwise(path: string): IUrlRouterProvider; + rule(handler: Function): IUrlRouterProvider; rule(handler: any[]): IUrlRouterProvider; } From 273728dedb148b762e0afb150a2003925dce5cf1 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 15:40:39 +0000 Subject: [PATCH 088/240] More tests for angular-ui-router --- angular-ui/angular-ui-router-tests.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/angular-ui/angular-ui-router-tests.ts b/angular-ui/angular-ui-router-tests.ts index f52d35837b..5a9c4ad6c3 100644 --- a/angular-ui/angular-ui-router-tests.ts +++ b/angular-ui/angular-ui-router-tests.ts @@ -15,14 +15,16 @@ myApp.config(( var matcher: ng.ui.IUrlMatcher = $urlMatcherFactory.compile("/foo/:bar?param1"); $urlRouterProvider - .when('/test', '/list') - .when(/\/test\d/, ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => { - return '/list'; - }) - .when(matcher, ['$injector', '$location', ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => { - return false; - }]) - .otherwise("/state1"); + .when('/test', '/list') + .when('/test', '/list') + .when('/test', '/list') + .when(/\/test\d/, '/list') + .when(/\/test\d/, ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list') + .when(/\/test\d/,['$injector', '$location', ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list']) + .when(matcher, '/list') + .when(matcher, ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list') + .when(matcher, ['$injector', '$location', ($injector: ng.auto.IInjectorService, $location: ng.ILocationService) => '/list']) + .otherwise("/state1"); // Now set up the states $stateProvider From 38c542821532e71ae5fca73b312bd3673fe19b8d Mon Sep 17 00:00:00 2001 From: gscshoyru Date: Tue, 28 Jan 2014 11:48:25 -0500 Subject: [PATCH 089/240] Fix #1632 -- fix typing for extend in lodash.d.ts --- lodash/lodash.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 97aeab757a..06b6d8e335 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2823,12 +2823,22 @@ declare module _ { callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): Result; + /** + * @see _.assign + **/ + extend( + object: T, + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + /** * @see _.assign **/ extend( object: T, s1: S1, + s2: S2, callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): Result; @@ -2839,6 +2849,7 @@ declare module _ { object: T, s1: S1, s2: S2, + s3: S3, callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): Result; From aa19aca4120e8289b5c375a79a8a86799f58bf68 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 17:05:09 +0000 Subject: [PATCH 090/240] (restangular) Add some missing methods Adds - `oneUrl` - `allUrl` - `withHttpConfig` --- restangular/restangular.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index a329b20bfe..bf8dc14eba 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Restangular v1.2.2 - 2014-01-10 +// Type definitions for Restangular v1.2.2 // Project: https://github.com/mgonto/restangular // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -9,7 +9,9 @@ interface Restangular extends RestangularCustom { one(route: string, id?: number): RestangularElement; one(route: string, id?: string): RestangularElement; + oneUrl(route: string, url: string): RestangularElement; all(route: string): RestangularCollection; + allUrl(route: string, url: string): RestangularCollection; copy(fromElement: any): RestangularElement; withConfig(configurer: (RestangularProvider) => any): Restangular; restangularizeElement(parent: any, element: any, route: string, collection?, reqParams?): RestangularElement; @@ -27,6 +29,7 @@ interface RestangularElement extends Restangular { trace(queryParams?, headers?): ng.IPromise; options(queryParams?, headers?): ng.IPromise; patch(queryParams?, headers?): ng.IPromise; + withHttpConfig(httpConfig: ng.IRequestConfig): RestangularElement; getRestangularUrl(): string; } @@ -38,6 +41,7 @@ interface RestangularCollection extends Restangular { options(queryParams?, headers?): ng.IPromise; patch(queryParams?, headers?): ng.IPromise; putElement(idx, params, headers): ng.IPromise; + withHttpConfig(httpConfig: ng.IRequestConfig): RestangularCollection; getRestangularUrl(): string; } From 8d7e7127d7189f82e80f6a9dd010e2f6103857ee Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 17:15:15 +0000 Subject: [PATCH 091/240] Add a test --- restangular/restangular-tests.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/restangular/restangular-tests.ts b/restangular/restangular-tests.ts index 1bb4b01ee7..22473e13e2 100644 --- a/restangular/restangular-tests.ts +++ b/restangular/restangular-tests.ts @@ -136,3 +136,10 @@ function test_config() { }); }); } + +function test_withHttpConfig() { + var $scope; + Restangular.one('accounts', 123).withHttpConfig({timeout: 100}).getList('buildings'); + $scope.account = Restangular.one('accounts', 123); + $scope.account.withHttpConfig({timeout: 100}).put(); +} From 43004ba4ef9b1f334dd17c4f789cb2a9506c352e Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Tue, 28 Jan 2014 17:17:01 +0000 Subject: [PATCH 092/240] Define own all-optional IRequestConfig --- restangular/restangular.d.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index bf8dc14eba..f6ea5b97b1 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -6,6 +6,17 @@ /// +interface RestangularRequestConfig { + params?: any; + headers?: any; + cache?: any; + withCredentials?: boolean; + data?: any; + transformRequest?: any; + transformResponse?: any; + timeout?: any; // number | promise +} + interface Restangular extends RestangularCustom { one(route: string, id?: number): RestangularElement; one(route: string, id?: string): RestangularElement; @@ -29,7 +40,7 @@ interface RestangularElement extends Restangular { trace(queryParams?, headers?): ng.IPromise; options(queryParams?, headers?): ng.IPromise; patch(queryParams?, headers?): ng.IPromise; - withHttpConfig(httpConfig: ng.IRequestConfig): RestangularElement; + withHttpConfig(httpConfig: RestangularRequestConfig): RestangularElement; getRestangularUrl(): string; } @@ -41,7 +52,7 @@ interface RestangularCollection extends Restangular { options(queryParams?, headers?): ng.IPromise; patch(queryParams?, headers?): ng.IPromise; putElement(idx, params, headers): ng.IPromise; - withHttpConfig(httpConfig: ng.IRequestConfig): RestangularCollection; + withHttpConfig(httpConfig: RestangularRequestConfig): RestangularCollection; getRestangularUrl(): string; } From ed7436e785c923326c6083ee763224c02ef963f4 Mon Sep 17 00:00:00 2001 From: gscshoyru Date: Tue, 28 Jan 2014 13:52:46 -0500 Subject: [PATCH 093/240] Add support for non-dictionary objects in isEmpty in lodash.d.ts --- lodash/lodash.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 97aeab757a..dc2dd7206d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3300,6 +3300,11 @@ declare module _ { * @see _.isEmpty **/ isEmpty(value: string): boolean; + + /** + * @see _.isEmpty + **/ + isEmpty(value: any): boolean; } //_.isEqual From 1343b32aa9eda47da17cd869f96ae1e2ac488a89 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Tue, 28 Jan 2014 15:53:12 -0500 Subject: [PATCH 094/240] Create jquery.simulate.d.ts I choose to go with a more relaxed definition (versus specifying the exact options allowed for each event type) because it would have required duplicating event definitions from lib.d.ts (the properties of the events in lib.d.ts are all mandatory whereas they would be optional in this usage). --- jquery.simulate/jquery.simulate.d.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 jquery.simulate/jquery.simulate.d.ts diff --git a/jquery.simulate/jquery.simulate.d.ts b/jquery.simulate/jquery.simulate.d.ts new file mode 100644 index 0000000000..65114ad70f --- /dev/null +++ b/jquery.simulate/jquery.simulate.d.ts @@ -0,0 +1,19 @@ +// Type definitions for jquery.simulate.js +// Project: https://github.com/jquery/jquery-simulate +// Definitions by: Derek Cicerone +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQuery { + + /** + * Simulates an event. + * + * @param type + * the type of event (eg: "mousemove", "keydown", etc...) + * @param options + * the options for the event (these are event-specific) + */ + simulate(type: string, options?: any): void; +} From 72e8f83731596dcf7615e15fd44ce6d630250abe Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Tue, 28 Jan 2014 15:55:25 -0500 Subject: [PATCH 095/240] Create jquery.simulate-tests.ts --- jquery.simulate/jquery.simulate-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 jquery.simulate/jquery.simulate-tests.ts diff --git a/jquery.simulate/jquery.simulate-tests.ts b/jquery.simulate/jquery.simulate-tests.ts new file mode 100644 index 0000000000..ea13d04cdf --- /dev/null +++ b/jquery.simulate/jquery.simulate-tests.ts @@ -0,0 +1,6 @@ +/// + +var $element = $("body"); + +$element.simulate("click"); +$element.simulate("mousewheel", { detail: 50 }); From b94154fb088ddf6b7ebac70e41bf89e8fcd3a1d7 Mon Sep 17 00:00:00 2001 From: Derek Cicerone Date: Tue, 28 Jan 2014 17:22:29 -0500 Subject: [PATCH 096/240] Update jquery.simulate-tests.ts --- jquery.simulate/jquery.simulate-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.simulate/jquery.simulate-tests.ts b/jquery.simulate/jquery.simulate-tests.ts index ea13d04cdf..98de970342 100644 --- a/jquery.simulate/jquery.simulate-tests.ts +++ b/jquery.simulate/jquery.simulate-tests.ts @@ -1,4 +1,4 @@ -/// +/// var $element = $("body"); From 91de50a4af5bc1d792d66fe2ea0991c51502a3cd Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Tue, 28 Jan 2014 22:12:22 -0800 Subject: [PATCH 097/240] Add typing information for axes --- vega/vega.d.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/vega/vega.d.ts b/vega/vega.d.ts index 3e82fc2ca1..29ed1ba15c 100644 --- a/vega/vega.d.ts +++ b/vega/vega.d.ts @@ -204,7 +204,36 @@ declare module Vega { } export interface Axis { - // TODO + // TODO docs + type: string; + scale: string; + orient?: string; + title?: string; + titleOffset?: number; + format?: string; + ticks?: number; + values?: any[]; + subdivide?: number; + tickPadding?: number; + tickSize?: number; + tickSizeMajor?: number; + tickSizeMinor?: number; + tickSizeEnd?: number; + offset?: any; + layer?: string; + grid?: boolean; + properties?: Axis.Properties + } + + export module Axis { + export interface Properties { + majorTicks?: Mark.PropertySet; + minorTicks?: Mark.PropertySet; + grid?: Mark.PropertySet; + labels?: Mark.PropertySet; + title?: Mark.PropertySet; + axis?: Mark.PropertySet; + } } export interface Legend { From 4b45695df5c5c334e214767c6e43de592902b48b Mon Sep 17 00:00:00 2001 From: Shunsuke Shida Date: Thu, 30 Jan 2014 04:13:47 +0900 Subject: [PATCH 098/240] socket.io: Added missing API --- socket.io/socket.io.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/socket.io/socket.io.d.ts b/socket.io/socket.io.d.ts index d1b4a4863c..8d137d7af0 100644 --- a/socket.io/socket.io.d.ts +++ b/socket.io/socket.io.d.ts @@ -23,7 +23,7 @@ interface Socket { in(room: string): Socket; to(room: string): Socket; join(name: string, fn: Function): Socket; - unjoin(name: string, fn: Function): Socket; + leave(name: string, fn: Function): Socket; set(key: string, value: any, fn: Function): Socket; get(key: string, fn: Function): Socket; has(key: string, fn: Function): Socket; From 36a7fe535716c91135395f9b5e9d14ed4f418350 Mon Sep 17 00:00:00 2001 From: Mike Keesey Date: Wed, 29 Jan 2014 15:21:13 -0800 Subject: [PATCH 099/240] Made breeze.d.ts compliant with the --noImplicitAny option. Added some missing return types in the process. --- breeze/breeze.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 5a3abd9aa5..ab0e3c045b 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -138,7 +138,7 @@ declare module breeze { shortName: string; unmappedProperties: DataProperty[]; validators: Validator[]; - addProperty(dataProperty: DataProperty); + addProperty(dataProperty: DataProperty): ComplexType; getProperties(): DataProperty[]; } @@ -643,8 +643,8 @@ declare module breeze { addDataService(dataService: DataService): void; addEntityType(structuralType: IStructuralType): void; exportMetadata(): string; - fetchMetadata(dataService: string, callback?: (data) => void , errorCallback?: breeze.core.ErrorCallback): Q.Promise; - fetchMetadata(dataService: DataService, callback?: (data) => void , errorCallback?: breeze.core.ErrorCallback): Q.Promise; + fetchMetadata(dataService: string, callback?: (data: any) => void , errorCallback?: breeze.core.ErrorCallback): Q.Promise; + fetchMetadata(dataService: DataService, callback?: (data: any) => void , errorCallback?: breeze.core.ErrorCallback): Q.Promise; getDataService(serviceName: string): DataService; getEntityType(entityTypeName: string, okIfNotFound?: boolean): IStructuralType; getEntityTypes(): IStructuralType[]; @@ -653,7 +653,7 @@ declare module breeze { importMetadata(exportedString: string): MetadataStore; isEmpty(): boolean; registerEntityTypeCtor(entityTypeName: string, entityCtor: Function, initializationFn?: (entity: Entity) =>void ): void; - trackUnmappedType(entityCtor: Function, interceptor?: Function); + trackUnmappedType(entityCtor: Function, interceptor?: Function): void; setEntityTypeForResourceName(resourceName: string, entityType: EntityType): void; setEntityTypeForResourceName(resourceName: string, entityTypeName: string): void; getEntityTypeNameForResourceName(resourceName: string): string; @@ -677,7 +677,7 @@ declare module breeze { serverPropertyNameToClient(serverPropertyName: string): string; serverPropertyNameToClient(serverPropertyName: string, property: IProperty): string; - setAsDefault(); + setAsDefault(): NamingConvention; } interface NamingConventionOptions { @@ -846,8 +846,8 @@ declare module breeze { static string(): Validator; static stringLength(context: { maxLength: number; minLength: number; }): Validator; - static register(validator: Validator); - static registerFactory(fn: () => Validator, name: string); + static register(validator: Validator): void; + static registerFactory(fn: () => Validator, name: string): void; validate(value: any, context?: any): ValidationError; getMessage(): string; From 35304a81710f726daf372b42d641d0bd5d51843f Mon Sep 17 00:00:00 2001 From: Mike Keesey Date: Wed, 29 Jan 2014 15:40:35 -0800 Subject: [PATCH 100/240] Made breeze-tests.ts compliant with --noImplicitAny. --- breeze/breeze-tests.ts | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/breeze/breeze-tests.ts b/breeze/breeze-tests.ts index e4ee91f747..3fe45d8bf6 100644 --- a/breeze/breeze-tests.ts +++ b/breeze/breeze-tests.ts @@ -440,7 +440,7 @@ function test_entityState() { function test_entityType() { var myMetadataStore: breeze.MetadataStore; var myEntityType: breeze.EntityType; - var dataProperty1, dataProperty2, navigationProperty1: breeze.DataProperty; + var dataProperty1: breeze.DataProperty, dataProperty2: breeze.DataProperty, navigationProperty1: breeze.DataProperty; var em1: breeze.EntityManager; var entityManager = new breeze.EntityType({ metadataStore: myMetadataStore, @@ -453,7 +453,7 @@ function test_entityType() { myEntityType.addProperty(navigationProperty1); var custType = em1.metadataStore.getEntityType("Customer"); var countryProp = custType.getProperty("Country"); - var valFn = function (v) { + var valFn = function (v: string) { if (v == null) return true; return (v.substring(0,2) === "US"); }; @@ -533,15 +533,20 @@ function test_entityType() { // DayOfWeek.Friday.toString() === "Friday"; //} +interface CustomEntityManager extends breeze.EntityManager +{ + customTag: string; +} + function test_event() { - var myEntityManager: breeze.EntityManager; - var myEntity, person: breeze.Entity; + var myEntityManager: CustomEntityManager; + var myEntity: breeze.Entity, person: breeze.Entity; var salaryEvent = new core.Event("salaryEvent", person); core.Event.enable("propertyChanged", myEntityManager, false); core.Event.enable("propertyChanged", myEntityManager, true); core.Event.enable("propertyChanged", myEntity.entityAspect, false); core.Event.enable("propertyChanged", myEntity.entityAspect, null); - core.Event.enable("validationErrorsChanged", myEntityManager, function (em) { + core.Event.enable("validationErrorsChanged", myEntityManager, function (em: CustomEntityManager) { return em.customTag === "blue"; }); core.Event.isEnabled("propertyChanged", myEntityManager); @@ -694,8 +699,18 @@ function test_validationOptions() { var newOptions = validationOptions.using({ validateOnQuery: true, validateOnSave: false }); } +interface NumericRange +{ + max: number; + min: number; +} + +interface NumericRangeValidatorFunctionContext extends breeze.ValidatorFunctionContext, NumericRange +{ +} + function test_validator() { - var valFn = function (v) { + var valFn = function (v: any) { if (v == null) return true; return ( v.substr(0,2)=== "US"); }; @@ -707,11 +722,11 @@ function test_validator() { var custType = metadataStore.getEntityType("Customer"); var countryProp = custType.getProperty("Country"); countryProp.validators.push(countryValidator); - function isValidZipCode(value) { + function isValidZipCode(value: string) { var re = /^\d{5}([\-]\d{4})?$/; return (re.test(value)); } - var valFn = function (v) { + valFn = function (v: any) { if (v.getProperty("Country") === "USA") { var postalCode = v.getProperty("PostalCode"); return isValidZipCode(postalCode); @@ -723,8 +738,8 @@ function test_validator() { var em1: breeze.EntityManager; var custType = em1.metadataStore.getEntityType("Customer"); custType.validators.push(zipCodeValidator); - var numericRangeValidator = function (context) { - var valFn = function (v, ctx) { + var numericRangeValidator = function (context: NumericRange) { + var valFn = function (v: any, ctx: NumericRangeValidatorFunctionContext) { if (v == null) return true; if (typeof (v) !== "number") return false; if (ctx.min != null && v < ctx.min) return false; @@ -784,7 +799,7 @@ function test_validator() { var errMsg = result.errorMessage; var context = result.context; var sameValidator = result.validator; - var valFn = function (v) { + valFn = function (v: any) { if (v == null) return true; return (v.substr(0,2) === "US"); }; @@ -807,7 +822,7 @@ function test_demo() { function test_corefns() { var o1: Object; - var kvfn = function (p) { return p; } + var kvfn = function (p: any) { return p; } core.objectForEach(o1, kvfn); var o2: Object; From 05ec01901cc2a28783099ce0f7f0d412ca9cf5ee Mon Sep 17 00:00:00 2001 From: John Kurlak Date: Thu, 30 Jan 2014 11:30:35 -0800 Subject: [PATCH 101/240] Added has() method to auto.IInjectorService Angular added the has() method to $injector in version 1.2 (see: https://github.com/angular/angular.js/blob/g3_v1_2/src/auto/injector.js) --- angularjs/angular.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index f3e7dc0001..1654e02ef5 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -821,7 +821,8 @@ declare module ng { interface IInjectorService { annotate(fn: Function): string[]; annotate(inlineAnnotadedFunction: any[]): string[]; - get (name: string): any; + get(name: string): any; + has(name: string): boolean; instantiate(typeConstructor: Function, locals?: any): any; invoke(inlineAnnotadedFunction: any[]): any; invoke(func: Function, context?: any, locals?: any): any; From 722c799832c5b88247b5dce64777247e5ff21d7b Mon Sep 17 00:00:00 2001 From: Dang Tran Date: Thu, 30 Jan 2014 16:03:03 -0800 Subject: [PATCH 102/240] =?UTF-8?q?added=20=E2=80=9CfindWhere=E2=80=9D=20t?= =?UTF-8?q?o=20collections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backbone/backbone.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index aad4cffde2..b3b8856e8e 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -175,6 +175,7 @@ declare module Backbone { sort(options?: Silenceable): Collection; unshift(model: Model, options?: AddOptions): Model; where(properies: any): Model[]; + findWhere(properties: any): Model; _prepareModel(attrs?: any, options?: any): any; _removeReference(model: Model): void; From 4f20894ed57f6cb18eb50ef53fbc38aa5ba9e231 Mon Sep 17 00:00:00 2001 From: John Vilk Date: Thu, 30 Jan 2014 21:18:22 -0500 Subject: [PATCH 103/240] [Node] Fixing WritableStream.write and WritableStream.end. Documentation for WritableStream.write: http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback There's no 'fd' argument; that might have been a typo. You can call `write` in the following ways: * write(data: Buffer) * write(data: Buffer, cb: Function) * write(data: String) * write(data: String, cb: Function) * write(data: String, encoding: String) * write(data: String, encoding: String, cb: Function) The same goes to `end`, except `end` can be called with no arguments, too. --- node/node.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index 78c0b3082f..7c4d035d6a 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -91,11 +91,13 @@ interface EventEmitter { interface WritableStream extends EventEmitter { writable: boolean; - 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; end(): void; - end(str: string, enconding: string): void; - end(buffer: NodeBuffer): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; destroy(): void; destroySoon(): void; } From eda6a18c3dc56712577994c00de4492f9f25598e Mon Sep 17 00:00:00 2001 From: Jacob Eggers Date: Thu, 30 Jan 2014 18:42:48 -0800 Subject: [PATCH 104/240] Breeze: fetchEntityByKey --- breeze/breeze.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index ab0e3c045b..f4f7ff8cea 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -385,7 +385,7 @@ declare module breeze { exportEntities(entities?: Entity[]): string; fetchEntityByKey(typeName: string, keyValue: any, checkLocalCacheFirst?: boolean): Q.Promise; fetchEntityByKey(typeName: string, keyValues: any[], checkLocalCacheFirst?: boolean): Q.Promise; - fetchEntityByKey(entityKey: EntityKey): Q.Promise; + fetchEntityByKey(entityKey: EntityKey, checkLocalCacheFirst?: boolean): Q.Promise; fetchMetadata(callback?: (schema: any) => void , errorCallback?: breeze.core.ErrorCallback): Q.Promise; generateTempKeyValue(entity: Entity): any; getChanges(): Entity[]; From 7ddbd984197e548fc5b9a179284295d66f56a6d9 Mon Sep 17 00:00:00 2001 From: basarat Date: Fri, 31 Jan 2014 23:45:44 +1100 Subject: [PATCH 105/240] angularjs revert marking arguments for link function as optional --- angularjs/angular.d.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index f3e7dc0001..061575166b 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -748,14 +748,12 @@ declare module ng { ) => any; controller?: any; controllerAs?: string; - // A link function with no arguments is perfectly valid; the norm seems - // to be passing the scope, element and attributes. link?: - (scope?: IScope, - instanceElement?: IAugmentedJQuery, - instanceAttributes?: IAttributes, - controller?: any, - transclude?: ITranscludeFunction + (scope: IScope, + instanceElement: IAugmentedJQuery, + instanceAttributes: IAttributes, + controller: any, + transclude: ITranscludeFunction ) => void; name?: string; priority?: number; From 5b07c2c85ed45ac327b88ad68c58a25d0356f427 Mon Sep 17 00:00:00 2001 From: Matt Jibson Date: Fri, 31 Jan 2014 16:37:56 -0500 Subject: [PATCH 106/240] Correct ICustomScope reference --- angularjs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/README.md b/angularjs/README.md index 263e046ea1..510f304f55 100644 --- a/angularjs/README.md +++ b/angularjs/README.md @@ -95,7 +95,7 @@ interface ICustomScope extends ng.IScope { title: string; } -function Controller($scope: ng.ICustomScope) { +function Controller($scope: ICustomScope) { $scope.$broadcast('myEvent'); $scope.title = 'Yabadabadu'; } From 65f47d2f205330d559e14d5577aa05bcdbf8a809 Mon Sep 17 00:00:00 2001 From: Magnus Gustafsson Date: Sun, 2 Feb 2014 00:16:19 +0000 Subject: [PATCH 107/240] Added type definitions for EasyStar.js 0.1.6 --- easystarjs/README.md | 61 ++++++++++++++++++++++++++++++++++ easystarjs/easystarjs-tests.ts | 47 ++++++++++++++++++++++++++ easystarjs/easystarjs.d.ts | 34 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100755 easystarjs/README.md create mode 100755 easystarjs/easystarjs-tests.ts create mode 100755 easystarjs/easystarjs.d.ts diff --git a/easystarjs/README.md b/easystarjs/README.md new file mode 100755 index 0000000000..0f3b110f26 --- /dev/null +++ b/easystarjs/README.md @@ -0,0 +1,61 @@ +easystarjs.d.ts +=========== + +This is a typescript definitions file for EasyStar.js located here: https://github.com/prettymuchbryce/easystarjs +Main site: http://easystarjs.com/ + +Basic Usage +========== + +Import Statements +----------------- + +Reference the easystarjs.d.ts file in your project and include the following import statement + +```typescript +/// + +// Include the following import +import EasyStar = require("easystarjs"); +``` + +See tests for further details on how to use this library. + +Change Log +========== + +1.0 2014/02/02 +--------------- +* First version for EasyStar.js 0.1.6 + + +License +======= + +easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson http://github.com/borundin/easystarjs.d.ts +This definitions file is for EasyStar.js -> + https://github.com/prettymuchbryce/easystarjs + + + +EasyStar.js Copyright (c) 2012-2013 Bryce Neal + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/easystarjs/easystarjs-tests.ts b/easystarjs/easystarjs-tests.ts new file mode 100755 index 0000000000..a63d4ea0f1 --- /dev/null +++ b/easystarjs/easystarjs-tests.ts @@ -0,0 +1,47 @@ +/// + +// For node.js compile using: tsc --module commonjs easystarjs-tests.ts +// then run using: node easystarjs-tests.js +import EasyStar = require('easystarjs'); + +var test = new EasyStar.js(); + +test.setGrid([ + [0, 0, 0, 1, 0], + [0, 0, 0, 1, 0], + [0, 0, 1, 1, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 1, 0] +]); +test.setAcceptableTiles([0]); +test.setIterationsPerCalculation(1000); +test.findPath(2, 0, 4, 4, function (path: EasyStar.Position[]) +{ + if (path == null) + { + console.log("No path found!"); + return; + } + for (var i = 0; i < path.length; i++) + { + var pos = path[i]; + console.log("%d, %d", pos.x, pos.y); + } +}); + +test.calculate(); + +/* +Should log: + +2, 0 +2, 1 +1, 1 +1, 2 +1, 3 +2, 3 +3, 3 +4, 3 +4, 4 + +*/ \ No newline at end of file diff --git a/easystarjs/easystarjs.d.ts b/easystarjs/easystarjs.d.ts new file mode 100755 index 0000000000..7640b1a8b8 --- /dev/null +++ b/easystarjs/easystarjs.d.ts @@ -0,0 +1,34 @@ +// Type definitions for EasyStar.js 0.1.6 +// Project: http://easystarjs.com/ +// Definitions by: Magnus Gustafsson +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/* +easystarjs.d.ts may be freely distributed under the MIT license. +*/ + +declare module "easystarjs" +{ + class js + { + new (): js; + setGrid(grid: number[][]): void; + setAcceptableTiles(tiles: number[]): void; + findPath(startX: number, startY: number, endX: number, endY: number, callback: (path: Position[]) => void): void; + calculate(): void; + setIterationsPerCalculation(iterations: number): void; + avoidAdditionalPoint(x: number, y: number): void; + stopAvoidingAdditionalPoint(x: number, y: number): void; + stopAvoidingAllAdditionalPoints(): void; + enableDiagonals(): void; + disableDiagonals(): void; + setTileCost(tileType: number, multiplicativeCost: number): void; + } + + interface Position + { + x: number; + y: number; + } +} + + \ No newline at end of file From fdee518da72cfe0f2729ed5256437de3ce0111fb Mon Sep 17 00:00:00 2001 From: Magnus Gustafsson Date: Sun, 2 Feb 2014 00:56:27 +0000 Subject: [PATCH 108/240] Removed wrong copy/paste url from README --- easystarjs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easystarjs/README.md b/easystarjs/README.md index 0f3b110f26..4066f9b37e 100755 --- a/easystarjs/README.md +++ b/easystarjs/README.md @@ -32,7 +32,7 @@ Change Log License ======= -easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson http://github.com/borundin/easystarjs.d.ts +easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson This definitions file is for EasyStar.js -> https://github.com/prettymuchbryce/easystarjs From 1689573473e1af0cb73afb57f300ec4d312e8370 Mon Sep 17 00:00:00 2001 From: BillArmstrong Date: Sun, 2 Feb 2014 01:29:02 -0500 Subject: [PATCH 109/240] Add selenium-webdriver and angular-protractor. Added the selenium-webdriver and angular-protractor libraries. --- README.md | 2 + angular-protractor/angular-protractor.d.ts | 868 +++++ .../angular-protractor.tests.ts | 242 ++ selenium-webdriver/selenium-webdriver.d.ts | 3153 +++++++++++++++++ .../selenium-webdriver.tests.ts | 917 +++++ 5 files changed, 5182 insertions(+) create mode 100644 angular-protractor/angular-protractor.d.ts create mode 100644 angular-protractor/angular-protractor.tests.ts create mode 100644 selenium-webdriver/selenium-webdriver.d.ts create mode 100644 selenium-webdriver/selenium-webdriver.tests.ts diff --git a/README.md b/README.md index ab4a8cdaef..6c88b12879 100755 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ List of Definitions * [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/)) * [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) * [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib)) +* [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong)) * [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib)) * [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted)) * [AppFramework](http://app-framework-software.intel.com/) (by [Kyo Ago](https://github.com/kyo-ago)) @@ -221,6 +222,7 @@ List of Definitions * [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Selenium WebDriverJS](https://code.google.com/p/selenium/) (by [Bill Armstrong](https://github.com/BillArmstrong)) * [Semver](https://github.com/isaacs/node-semver) (by [Bart van der Schoor](https://github.com/Bartvds)) * [Sencha Touch](http://www.sencha.com/products/touch/) (by [Brian Kotek](https://github.com/brian428)) * [SharePoint](http://sptypescript.codeplex.com) (by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru) and [Andrey Markeev](http://markeev.com)) diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts new file mode 100644 index 0000000000..f5ec5ece14 --- /dev/null +++ b/angular-protractor/angular-protractor.d.ts @@ -0,0 +1,868 @@ +// Type definitions for Angular Protractor +// Project: https://github.com/angular/protractor +// Definitions by: Bill Armstrong +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module protractor { + //region Wrapped webdriver Items + + class AbstractBuilder extends webdriver.AbstractBuilder {} + class ActionSequence extends webdriver.ActionSequence {} + class Alert extends webdriver.Alert {} + class Builder extends webdriver.Builder {} + class Button extends webdriver.Button {} + class Capabilities extends webdriver.Capabilities {} + class Command extends webdriver.Command {} + class EventEmitter extends webdriver.EventEmitter {} + class FirefoxDomExecutor extends webdriver.FirefoxDomExecutor {} + class Locator extends webdriver.Locator {} + class Session extends webdriver.Session {} + class WebDriver extends webdriver.WebDriver {} + class Browser extends webdriver.Browser {} + class Capability extends webdriver.Capability {} + class CommandName extends webdriver.CommandName {} + class Key extends webdriver.Key {} + class UnhandledAlertError extends webdriver.UnhandledAlertError {} + + class WebElement extends webdriver.WebElement { + /** + * Shortcut for querying the document directly with css. + * + * @param {string} selector a css selector + * @see webdriver.WebElement.findElement + * @return {!protractor.WebElement} + */ + $(selector: string): protractor.WebElement; + + /** + * Shortcut for querying the document directly with css. + * + * @param {string} selector a css selector + * @see webdriver.WebElement.findElements + * @return {!webdriver.promise.Promise} A promise that will be resolved to an + * array of the located {@link webdriver.WebElement}s. + */ + $$(selector: string): webdriver.promise.Promise; + + /** + * Evalates the input as if it were on the scope of the current element. + * @param {string} expression + * + * @return {!webdriver.promise.Promise} A promise that will resolve to the + * evaluated expression. The result will be resolved as in + * {@link webdriver.WebDriver.executeScript}. In summary - primitives will + * be resolved as is, functions will be converted to string, and elements + * will be returned as a WebElement. + */ + evaluate(expression: string): webdriver.promise.Promise; + + /** + * Schedule a command to find a descendant of this element. If the element + * cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will + * be returned by the driver. Unlike other commands, this error cannot be + * suppressed. In other words, scheduling a command to find an element doubles + * as an assert that the element is present on the page. To test whether an + * element is present on the page, use {@code #isElementPresent} instead. + *

+ * The search criteria for find an element may either be a + * {@code webdriver.Locator} object, or a simple JSON object whose sole key + * is one of the accepted locator strategies, as defined by + * {@code webdriver.Locator.Strategy}. For example, the following two + * statements are equivalent: + *

+         * var e1 = element.findElement(By.id('foo'));
+         * var e2 = element.findElement({id:'foo'});
+         * 
+ *

+ * Note that JS locator searches cannot be restricted to a subtree. All such + * searches are delegated to this instance's parent WebDriver. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the element. + * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if + * using a JavaScript locator. Otherwise ignored. + * @return {protractor.WebElement} A WebElement that can be used to issue + * commands against the located element. If the element is not found, the + * element will be invalidated and all scheduled commands aborted. + */ + findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement; + findElement(locator: any, ...var_args: any[]): protractor.WebElement; + } + + module command { + class Command extends webdriver.Command {} + class CommandName extends webdriver.CommandName {} + } + + module error { + class Error extends webdriver.error.Error {} + class ErrorCode extends webdriver.error.ErrorCode {} + } + + module events { + class EventEmitter extends webdriver.EventEmitter {} + } + + module logging { + var Preferences: any; + + class LevelName extends webdriver.logging.LevelName {} + class Type extends webdriver.logging.Type {} + class Level extends webdriver.logging.Level {} + class Entry extends webdriver.logging.Entry {} + + function getLevel(nameOrValue: string): webdriver.logging.Level; + function getLevel(nameOrValue: number): webdriver.logging.Level; + } + + module promise { + class Promise extends webdriver.promise.Promise {} + class Deferred extends webdriver.promise.Deferred {} + class ControlFlow extends webdriver.promise.ControlFlow {} + + /** + * @return {!webdriver.promise.ControlFlow} The currently active control flow. + */ + function controlFlow(): webdriver.promise.ControlFlow; + + /** + * Creates a new control flow. The provided callback will be invoked as the + * first task within the new flow, with the flow as its sole argument. Returns + * a promise that resolves to the callback result. + * @param {function(!webdriver.promise.ControlFlow)} callback The entry point + * to the newly created flow. + * @return {!webdriver.promise.Promise} A promise that resolves to the callback + * result. + */ + function createFlow(callback: (flow: webdriver.promise.ControlFlow) => any): webdriver.promise.Promise; + + /** + * Determines whether a {@code value} should be treated as a promise. + * Any object whose "then" property is a function will be considered a promise. + * + * @param {*} value The value to test. + * @return {boolean} Whether the value is a promise. + */ + function isPromise(value: any): boolean; + + /** + * Creates a promise that will be resolved at a set time in the future. + * @param {number} ms The amount of time, in milliseconds, to wait before + * resolving the promise. + * @return {!webdriver.promise.Promise} The promise. + */ + function delayed(ms: number): webdriver.promise.Promise; + + /** + * Creates a new deferred object. + * @param {Function=} opt_canceller Function to call when cancelling the + * computation of this instance's value. + * @return {!webdriver.promise.Deferred} The new deferred object. + */ + function defer(opt_canceller?: any): webdriver.promise.Deferred; + + /** + * Creates a promise that has been resolved with the given value. + * @param {*=} opt_value The resolved value. + * @return {!webdriver.promise.Promise} The resolved promise. + */ + function fulfilled(opt_value?: any): webdriver.promise.Promise; + + /** + * Creates a promise that has been rejected with the given reason. + * @param {*=} opt_reason The rejection reason; may be any value, but is + * usually an Error or a string. + * @return {!webdriver.promise.Promise} The rejected promise. + */ + function rejected(opt_reason?: any): webdriver.promise.Promise; + + /** + * Wraps a function that is assumed to be a node-style callback as its final + * argument. This callback takes two arguments: an error value (which will be + * null if the call succeeded), and the success value as the second argument. + * If the call fails, the returned promise will be rejected, otherwise it will + * be resolved with the result. + * @param {!Function} fn The function to wrap. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * result of the provided function's callback. + */ + function checkedNodeCall(fn: (error: any, value: any) => any): webdriver.promise.Promise; + + /** + * Registers an observer on a promised {@code value}, returning a new promise + * that will be resolved when the value is. If {@code value} is not a promise, + * then the return promise will be immediately resolved. + * @param {*} value The value to observe. + * @param {Function=} opt_callback The function to call when the value is + * resolved successfully. + * @param {Function=} opt_errback The function to call when the value is + * rejected. + * @return {!webdriver.promise.Promise} A new promise. + */ + function when(value: any, opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise; + + /** + * Invokes the appropriate callback function as soon as a promised + * {@code value} is resolved. This function is similar to + * {@code webdriver.promise.when}, except it does not return a new promise. + * @param {*} value The value to observe. + * @param {Function} callback The function to call when the value is + * resolved successfully. + * @param {Function=} opt_errback The function to call when the value is + * rejected. + */ + function asap(value: any, callback: (value: any) => any, opt_errback?: (error: any) => any): void; + + /** + * Returns a promise that will be resolved with the input value in a + * fully-resolved state. If the value is an array, each element will be fully + * resolved. Likewise, if the value is an object, all keys will be fully + * resolved. In both cases, all nested arrays and objects will also be + * fully resolved. All fields are resolved in place; the returned promise will + * resolve on {@code value} and not a copy. + * + * Warning: This function makes no checks against objects that contain + * cyclical references: + * + * var value = {}; + * value['self'] = value; + * webdriver.promise.fullyResolved(value); // Stack overflow. + * + * @param {*} value The value to fully resolve. + * @return {!webdriver.promise.Promise} A promise for a fully resolved version + * of the input value. + */ + function fullyResolved(value: any): webdriver.promise.Promise; + + /** + * Changes the default flow to use when no others are active. + * @param {!webdriver.promise.ControlFlow} flow The new default flow. + * @throws {Error} If the default flow is not currently active. + */ + function setDefaultFlow(flow: webdriver.promise.ControlFlow): void; + + } + + module process { + + /** + * Queries for a named environment variable. + * @param {string} name The name of the environment variable to look up. + * @param {string=} opt_default The default value if the named variable is not + * defined. + * @return {string} The queried environment variable. + */ + function getEnv(name: string, opt_default?: string): string; + + /** + * @return {boolean} Whether the current process is Node's native process + * object. + */ + function isNative(): boolean; + + /** + * Sets an environment value. If the new value is either null or undefined, the + * environment variable will be cleared. + * @param {string} name The value to set. + * @param {*} value The new value; will be coerced to a string. + */ + function setEnv(name: string, value: any): void; + + } + + //endregion + + interface Element { + (locator: webdriver.Locator): ElementFinder; + all(locator: webdriver.Locator): ElementArrayFinder; + } + + interface ElementFinder { + /** + * Schedules a command to click on this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the click command has completed. + */ + click(): webdriver.promise.Promise; + + /** + * Schedules a command to type a sequence on the DOM element represented by this + * instance. + *

+ * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is + * processed in the keysequence, that key state is toggled until one of the + * following occurs: + *

    + *
  • The modifier key is encountered again in the sequence. At this point the + * state of the key is toggled (along with the appropriate keyup/down events). + *
  • + *
  • The {@code webdriver.Key.NULL} key is encountered in the sequence. When + * this key is encountered, all modifier keys current in the down state are + * released (with accompanying keyup events). The NULL key can be used to + * simulate common keyboard shortcuts: + * + * element.sendKeys("text was", + * webdriver.Key.CONTROL, "a", webdriver.Key.NULL, + * "now text is"); + * // Alternatively: + * element.sendKeys("text was", + * webdriver.Key.chord(webdriver.Key.CONTROL, "a"), + * "now text is"); + *
  • + *
  • The end of the keysequence is encountered. When there are no more keys + * to type, all depressed modifier keys are released (with accompanying keyup + * events). + *
  • + *
+ * Note: On browsers where native keyboard events are not yet + * supported (e.g. Firefox on OS X), key events will be synthesized. Special + * punctionation keys will be synthesized according to a standard QWERTY en-us + * keyboard layout. + * + * @param {...string} var_args The sequence of keys to + * type. All arguments will be joined into a single sequence (var_args is + * permitted for convenience). + * @return {!webdriver.promise.Promise} A promise that will be resolved when all + * keys have been typed. + */ + sendKeys(...var_args: string[]): webdriver.promise.Promise; + + /** + * Schedules a command to query for the tag/node name of this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's tag name. + */ + getTagName(): webdriver.promise.Promise; + + /** + * Schedules a command to query for the computed style of the element + * represented by this instance. If the element inherits the named style from + * its parent, the parent will be queried for its value. Where possible, color + * values will be converted to their hex representation (e.g. #00ff00 instead of + * rgb(0, 255, 0)). + *

+ * Warning: the value returned will be as the browser interprets it, so + * it may be tricky to form a proper assertion. + * + * @param {string} cssStyleProperty The name of the CSS style property to look + * up. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * requested CSS value. + */ + getCssValue(cssStyleProperty: string): webdriver.promise.Promise; + + /** + * Schedules a command to query for the value of the given attribute of the + * element. Will return the current value even if it has been modified after the + * page has been loaded. More exactly, this method will return the value of the + * given attribute, unless that attribute is not present, in which case the + * value of the property with the same name is returned. If neither value is + * set, null is returned. The "style" attribute is converted as best can be to a + * text representation with a trailing semi-colon. The following are deemed to + * be "boolean" attributes and will be returned as thus: + * + *

async, autofocus, autoplay, checked, compact, complete, controls, declare, + * defaultchecked, defaultselected, defer, disabled, draggable, ended, + * formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, + * loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, + * paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, + * selected, spellcheck, truespeed, willvalidate + * + *

Finally, the following commonly mis-capitalized attribute/property names + * are evaluated as expected: + *

    + *
  • "class" + *
  • "readonly" + *
+ * @param {string} attributeName The name of the attribute to query. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * attribute's value. + */ + getAttribute(attributeName: string): webdriver.promise.Promise; + + /** + * Get the visible (i.e. not hidden by CSS) innerText of this element, including + * sub-elements, without any leading or trailing whitespace. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's visible text. + */ + getText(): webdriver.promise.Promise; + + /** + * Schedules a command to compute the size of this element's bounding box, in + * pixels. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's size as a {@code {width:number, height:number}} object. + */ + getSize(): webdriver.promise.Promise; + + /** + * Schedules a command to compute the location of this element in page space. + * @return {!webdriver.promise.Promise} A promise that will be resolved to the + * element's location as a {@code {x:number, y:number}} object. + */ + getLocation(): webdriver.promise.Promise; + + /** + * Schedules a command to query whether the DOM element represented by this + * instance is enabled, as dicted by the {@code disabled} attribute. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether this element is currently enabled. + */ + isEnabled(): webdriver.promise.Promise; + + /** + * Schedules a command to query whether this element is selected. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether this element is currently selected. + */ + isSelected(): webdriver.promise.Promise; + + /** + * Schedules a command to submit the form containing this element (or this + * element if it is a FORM element). This command is a no-op if the element is + * not contained in a form. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the form has been submitted. + */ + submit(): webdriver.promise.Promise; + + /** + * Schedules a command to clear the {@code value} of this element. This command + * has no effect if the underlying DOM element is neither a text INPUT element + * nor a TEXTAREA element. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the element has been cleared. + */ + clear(): webdriver.promise.Promise; + + /** + * Schedules a command to test whether this element is currently displayed. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether this element is currently visible on the page. + */ + isDisplayed(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the outer HTML of this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * the element's outer HTML. + */ + getOuterHtml(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the inner HTML of this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's inner HTML. + */ + getInnerHtml(): webdriver.promise.Promise; + + /** + * Schedules a command to test if there is at least one descendant of this + * element that matches the given search criteria. + * + *

Note that JS locator searches cannot be restricted to a subtree of the + * DOM. All such searches are delegated to this instance's parent WebDriver. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the element. + * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if + * using a JavaScript locator. Otherwise ignored. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether an element could be located on the page. + */ + isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise; + isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedules a command to find all of the descendants of this element that match + * the given search criteria. + *

+ * Note that JS locator searches cannot be restricted to a subtree. All such + * searches are delegated to this instance's parent WebDriver. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the elements. + * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if + * using a JavaScript locator. Otherwise ignored. + * @return {!webdriver.promise.Promise} A promise that will be resolved with an + * array of located {@link webdriver.WebElement}s. + */ + findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise; + findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Shortcut for querying the document directly with css. + * + * @param {string} selector a css selector + * @see webdriver.WebElement.findElement + * @return {!protractor.WebElement} + */ + $(selector: string): protractor.WebElement; + + /** + * Shortcut for querying the document directly with css. + * + * @param {string} selector a css selector + * @see webdriver.WebElement.findElements + * @return {!webdriver.promise.Promise} A promise that will be resolved to an + * array of the located {@link webdriver.WebElement}s. + */ + $$(selector: string): webdriver.promise.Promise; + + /** + * Schedule a command to find a descendant of this element. If the element + * cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will + * be returned by the driver. Unlike other commands, this error cannot be + * suppressed. In other words, scheduling a command to find an element doubles + * as an assert that the element is present on the page. To test whether an + * element is present on the page, use {@code #isElementPresent} instead. + *

+ * The search criteria for find an element may either be a + * {@code webdriver.Locator} object, or a simple JSON object whose sole key + * is one of the accepted locator strategies, as defined by + * {@code webdriver.Locator.Strategy}. For example, the following two + * statements are equivalent: + *

+         * var e1 = element.findElement(By.id('foo'));
+         * var e2 = element.findElement({id:'foo'});
+         * 
+ *

+ * Note that JS locator searches cannot be restricted to a subtree. All such + * searches are delegated to this instance's parent WebDriver. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the element. + * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if + * using a JavaScript locator. Otherwise ignored. + * @return {protractor.WebElement} A WebElement that can be used to issue + * commands against the located element. If the element is not found, the + * element will be invalidated and all scheduled commands aborted. + */ + findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement; + findElement(locator: any, ...var_args: any[]): protractor.WebElement; + + /** + * Evalates the input as if it were on the scope of the current element. + * @param {string} expression + * + * @return {!webdriver.promise.Promise} A promise that will resolve to the + * evaluated expression. The result will be resolved as in + * {@link webdriver.WebDriver.executeScript}. In summary - primitives will + * be resolved as is, functions will be converted to string, and elements + * will be returned as a WebElement. + */ + evaluate(expression: string): webdriver.promise.Promise; + + find(): protractor.WebElement; + + isPresent(): webdriver.promise.Promise; + } + + interface ElementArrayFinder{ + count(): webdriver.promise.Promise; + get(index: number): protractor.WebElement; + first(): protractor.WebElement; + last(): protractor.WebElement; + then(fn: (value: any) => any): webdriver.promise.Promise; + } + + interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy { + /** + * Add a locator to this instance of ProtractorBy. This locator can then be + * used with element(by.()). + * + * @param {string} name + * @param {function|string} script A script to be run in the context of + * the browser. This script will be passed an array of arguments + * that begins with the element scoping the search, and then + * contains any args passed into the locator. It should return + * an array of elements. + */ + addLocator(name: string, script: any): void; + + /** + * Usage: + * {{status}} + * var status = element(by.binding('{{status}}')); + */ + binding(bindingDescriptor: string): webdriver.Locator; + + /** + * Usage: + * + * element(by.select("user")); + */ + select(model: string): webdriver.Locator; + + /** + * Usage: + * + * element(by.selectedOption("user")); + */ + selectedOption(model: string): webdriver.Locator; + + /** + * @DEPRECATED - use 'model' instead. + * Usage: + * + * element(by.input('user')); + */ + input(model: string): webdriver.Locator; + + /** + * Usage: + * + * element(by.model('user')); + */ + model(model: string): webdriver.Locator; + + /** + * Usage: + * + * element(by.textarea("user")); + */ + textarea(model: string): webdriver.Locator; + + /** + * Usage: + *

+ * {{cat.name}} + * {{cat.age}} + *
+ * + * // Returns the DIV for the second cat. + * var secondCat = element(by.repeater("cat in pets").row(2)); + * // Returns the SPAN for the first cat's name. + * var firstCatName = element( + * by.repeater("cat in pets").row(1).column("{{cat.name}}")); + * // Returns a promise that resolves to an array of WebElements from a column + * var ages = element( + * by.repeater("cat in pets").column("{{cat.age}}")); + * // Returns a promise that resolves to an array of WebElements containing + * // all rows of the repeater. + * var rows = element(by.repeater("cat in pets")); + */ + repeater(repeatDescriptor: string): webdriver.Locator; + } + + var By: IProtractorLocatorStrategy; + + class Protractor extends webdriver.WebDriver { + + //region Constructors + + /** + * @param {webdriver.WebDriver} webdriver + * @param {string=} opt_baseUrl A base URL to run get requests against. + * @param {string=body} opt_rootElement Selector element that has an ng-app in + * scope. + * @constructor + */ + constructor(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string); + + //endregion + + //region Properties + + /** + * The wrapped webdriver instance. Use this to interact with pages that do + * not contain Angular (such as a log-in screen). + * + * @type {webdriver.WebDriver} + */ + driver: webdriver.WebDriver; + + /** + * All get methods will be resolved against this base URL. Relative URLs are = + * resolved the way anchor tags resolve. + * + * @type {string} + */ + baseUrl: string; + + /** + * The css selector for an element on which to find Angular. This is usually + * 'body' but if your ng-app is on a subsection of the page it may be + * a subelement. + * + * @type {string} + */ + rootEl: string; + + /** + * If true, Protractor will not attempt to synchronize with the page before + * performing actions. This can be harmful because Protractor will not wait + * until $timeouts and $http calls have been processed, which can cause + * tests to become flaky. This should be used only when necessary, such as + * when a page continuously polls an API using $timeout. + * + * @type {boolean} + */ + ignoreSynchronization: boolean; + + /** + * An object that holds custom test parameters. + * + * @type {Object} + */ + params: any; + + //endregion + + //region Methods + + /** + * Helper function for finding elements. + * + * @type {function(webdriver.Locator): ElementFinder} + */ + element(locator: webdriver.Locator): ElementFinder; + + /** + * Helper function for finding elements by css. + * + * @type {function(string): ElementFinder} + */ + $(cssLocator: string): ElementFinder; + + /** + * Helper function for finding arrays of elements by css. + * + * @type {function(string): ElementArrayFinder} + */ + $$(cssLocator: string): ElementArrayFinder; + + /** + * Instruct webdriver to wait until Angular has finished rendering and has + * no outstanding $http calls before continuing. + * + * @return {!webdriver.promise.Promise} A promise that will resolve to the + * scripts return value. + */ + waitForAngular(): webdriver.promise.Promise; + + /** + * Wrap a webdriver.WebElement with protractor specific functionality. + * + * @param {webdriver.WebElement} element + * @return {protractor.WebElement} the wrapped web element. + */ + wrapWebElement(element: webdriver.WebElement): protractor.WebElement; + + /** + * Add a module to load before Angular whenever Protractor.get is called. + * Modules will be registered after existing modules already on the page, + * so any module registered here will override preexisting modules with the same + * name. + * + * @param {!string} name The name of the module to load or override. + * @param {!string|Function} script The JavaScript to load the module. + */ + addMockModule(name: string, script: string): void; + addMockModule(name: string, script: any): void; + + /** + * Clear the list of registered mock modules. + */ + clearMockModules(): void; + + /** + * Returns the current absolute url from AngularJS. + */ + getLocationAbsUrl(): string; + + /** + * Pauses the test and injects some helper functions into the browser, so that + * debugging may be done in the browser console. + * + * This should be used under node in debug mode, i.e. with + * protractor debug + * + * While in the debugger, commands can be scheduled through webdriver by + * entering the repl: + * debug> repl + * Press Ctrl + C to leave rdebug repl + * > ptor.findElement(protractor.By.input('user').sendKeys('Laura')); + * > ptor.debugger(); + * debug> c + * + * This will run the sendKeys command as the next task, then re-enter the + * debugger. + */ + debugger(): void; + + /** + * Schedule a command to find an element on the page. If the element cannot be + * found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned + * by the driver. Unlike other commands, this error cannot be suppressed. In + * other words, scheduling a command to find an element doubles as an assert + * that the element is present on the page. To test whether an element is + * present on the page, use {@code #isElementPresent} instead. + * + *

The search criteria for find an element may either be a + * {@code webdriver.Locator} object, or a simple JSON object whose sole key + * is one of the accepted locator strategies, as defined by + * {@code webdriver.Locator.Strategy}. For example, the following two statements + * are equivalent: + *

+         * var e1 = driver.findElement(By.id('foo'));
+         * var e2 = driver.findElement({id:'foo'});
+         * 
+ * + *

When running in the browser, a WebDriver cannot manipulate DOM elements + * directly; it may do so only through a {@link webdriver.WebElement} reference. + * This function may be used to generate a WebElement from a DOM element. A + * reference to the DOM element will be stored in a known location and this + * driver will attempt to retrieve it through {@link #executeScript}. If the + * element cannot be found (eg, it belongs to a different document than the + * one this instance is currently focused on), a + * {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned. + * + * @param {!(webdriver.Locator|Object.|Element)} locatorOrElement The + * locator strategy to use when searching for the element, or the actual + * DOM element to be located by the server. + * @param {...} var_args Arguments to pass to {@code #executeScript} if using a + * JavaScript locator. Otherwise ignored. + * @return {!protractor.WebElement} A WebElement that can be used to issue + * commands against the located element. If the element is not found, the + * element will be invalidated and all scheduled commands aborted. + */ + findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement; + findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement; + + //endregion + } + + /** + * Create a new instance of Protractor by wrapping a webdriver instance. + * + * @param {webdriver.WebDriver} webdriver The configured webdriver instance. + * @param {string=} opt_baseUrl A URL to prepend to relative gets. + * @return {Protractor} + */ + function wrapDriver(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string): Protractor; + + /** + * Set a singleton instance of protractor. + * @param {Protractor} ptor + */ + function setInstance(ptor: Protractor): void; + + /** + * Get the singleton instance. + * @return {Protractor} + */ + function getInstance(): Protractor; + +} + +declare var browser: protractor.Protractor; +declare var by: protractor.IProtractorLocatorStrategy; +declare var element: protractor.Element; + +declare module 'protractor' { + export = protractor; +} \ No newline at end of file diff --git a/angular-protractor/angular-protractor.tests.ts b/angular-protractor/angular-protractor.tests.ts new file mode 100644 index 0000000000..2c8e72f07d --- /dev/null +++ b/angular-protractor/angular-protractor.tests.ts @@ -0,0 +1,242 @@ +/// + +function TestWebDriverExports() { + var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder(); + var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder; + + var button: protractor.Button = new protractor.Button(); + var baseButton: webdriver.Button = button; + + var key: string = protractor.Key.ADD; + var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1); + + var driver: protractor.WebDriver = new protractor.Builder(). + withCapabilities(protractor.Capabilities.chrome()). + build(); + var baseDriver: webdriver.WebDriver = driver; + + var action: protractor.ActionSequence = new protractor.ActionSequence(driver); + var baseAction: webdriver.ActionSequence = action; + + var alert: protractor.Alert = new protractor.Alert(driver, 'Message'); + var baseAlert: webdriver.Alert = alert; + + var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert); + var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError; + + var browser: string = protractor.Browser.ANDROID; + + var builder: protractor.Builder = new protractor.Builder(); + var baseBuilder: webdriver.Builder = builder; + + var capability: string = protractor.Capability.BROWSER_NAME; + + var capabilities: protractor.Capabilities = protractor.Capabilities.chrome(); + var baseCapabilities: webdriver.Capabilities = capabilities; + + var commandName: string = protractor.CommandName.CLICK_ELEMENT; + + var command: protractor.Command = new protractor.Command(protractor.CommandName.CLICK); + var baseCommand: webdriver.Command = command; + + var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter(); + var baseEventEmitter: webdriver.EventEmitter = eventEmitter; + + var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor(); + var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor; + + var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise()); + var baseWebElement: webdriver.WebElement = webElement; + + var locator: protractor.Locator = new protractor.Locator('id', 'ABC'); + var baseLocator: webdriver.Locator = locator; + + var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android()); + var baseSession: webdriver.Session = session; + + locator = protractor.By.name('name'); + + // logging module + + var levelName: string = protractor.logging.LevelName.ALL; + var loggingType: string = protractor.logging.Type.CLIENT; + + var level: webdriver.logging.Level = protractor.logging.Level.ALL; + + var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message'); + var baseEntry: webdriver.logging.Entry = entry; + + level = protractor.logging.getLevel('DEBUG'); + + protractor.logging.Preferences = { a: 123 }; + + // promise module + + var promise: protractor.promise.Promise = new protractor.promise.Promise(); + var basePromise: webdriver.promise.Promise = promise; + + var deferred: protractor.promise.Deferred = new protractor.promise.Deferred(); + var baseDeferred: webdriver.promise.Deferred = deferred; + + var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow(); + var baseFlow: webdriver.promise.ControlFlow = flow; + + protractor.promise.asap(promise, function(value: any){ return true; }); + protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; }); + + promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; }); + + flow = protractor.promise.controlFlow(); + + promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { }); + + deferred = protractor.promise.defer(function() {}); + deferred = protractor.promise.defer(function(reason?: any) {}); + + promise = protractor.promise.delayed(123); + + promise = protractor.promise.fulfilled(); + promise = protractor.promise.fulfilled({a: 123}); + + promise = protractor.promise.fullyResolved({a: 123}); + + var isPromise: boolean = protractor.promise.isPromise('ABC'); + + promise = protractor.promise.rejected({a: 123}); + + protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow()); + + promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; }); + + // error module + + var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE; + var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE); + var baseError: webdriver.error.Error = error; + + // process module + + var isNative: boolean = protractor.process.isNative(); + var value: string; + + value = protractor.process.getEnv('name'); + value = protractor.process.getEnv('name', 'default'); + + protractor.process.setEnv('name', 'value'); + protractor.process.setEnv('name', 123); + +} + +function TestProtractor() { + var ptor: protractor.Protractor; + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + ptor = new protractor.Protractor(driver); + ptor = new protractor.Protractor(driver, 'baseUrl'); + ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement'); + ptor = protractor.getInstance(); + protractor.setInstance(ptor); + + ptor = protractor.wrapDriver(driver); + ptor = protractor.wrapDriver(driver, 'baseUrl'); + ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement'); + + ptor = browser; + + driver = ptor.driver; + var baseUrl: string = ptor.baseUrl; + var rootEl: string = ptor.rootEl; + var ignoreSynchronization: boolean = ptor.ignoreSynchronization; + var params: any = ptor.params; + + ptor.debugger(); + + ptor.clearMockModules(); + ptor.addMockModule('name', 'script'); + ptor.addMockModule('name', function() {}); + ptor.waitForAngular(); + + var elementFinder: protractor.ElementFinder; + + elementFinder = ptor.element(by.id('ABC')); + elementFinder = ptor.$('.class'); + + var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class'); + + var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id')); + + var locationAbsUrl: string = ptor.getLocationAbsUrl(); +} + +function TestElement() { + var elementFinder: protractor.ElementFinder = element(by.id('id')); + var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.className('class')); +} + +function TestElementFinder() { + var elementFinder: protractor.ElementFinder = element(by.id('id')); + var promise: webdriver.promise.Promise; + + promise = elementFinder.click(); + promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN); + promise = elementFinder.getTagName(); + promise = elementFinder.getCssValue('display'); + promise = elementFinder.getAttribute('atribute'); + promise = elementFinder.getText(); + promise = elementFinder.getSize(); + promise = elementFinder.getLocation(); + promise = elementFinder.isEnabled(); + promise = elementFinder.isSelected(); + promise = elementFinder.submit(); + promise = elementFinder.clear(); + promise = elementFinder.isDisplayed(); + promise = elementFinder.getOuterHtml(); + promise = elementFinder.getInnerHtml(); + promise = elementFinder.isElementPresent(by.id('id')); + promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3); + promise = elementFinder.findElements(by.className('class')); + promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3); + promise = elementFinder.$$('.class'); + promise = elementFinder.evaluate('expression'); + promise = elementFinder.isPresent(); + + var webElement: webdriver.WebElement; + + webElement = elementFinder.$('.class'); + webElement = elementFinder.findElement(by.id('id')); + webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3); + webElement = elementFinder.find(); +} + +// This function tests the angular specific locator strategies. +function TestLocatorStrategies() { + var ptor: protractor.Protractor = protractor.getInstance(); + var webElement: webdriver.WebElement; + + // Protractor Specific Locators + webElement = ptor.findElement(protractor.By.binding('binding')); + webElement = ptor.findElement(protractor.By.select('select')); + webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions')); + webElement = ptor.findElement(protractor.By.input('input')); + webElement = ptor.findElement(protractor.By.model('model')); + webElement = ptor.findElement(protractor.By.textarea('textarea')); + webElement = ptor.findElement(protractor.By.repeater('repeater')); +} + +// This function tests the methods that were added to the base WebElement class +function TestWebElements() { + var ptor: protractor.Protractor = protractor.getInstance(); + + var webElement: protractor.WebElement; + var promise: webdriver.promise.Promise; + + webElement = ptor.findElement(by.id('id')).$('.class'); + promise = ptor.findElement(by.id('id')).$$('.class'); + promise = ptor.findElement(by.id('id')).evaluate('something'); + + webElement = webElement.findElement(by.id('id')).$('.class'); + promise = webElement.findElement(by.id('id')).$$('.class'); + promise = webElement.findElement(by.id('id')).evaluate('something'); +} \ No newline at end of file diff --git a/selenium-webdriver/selenium-webdriver.d.ts b/selenium-webdriver/selenium-webdriver.d.ts new file mode 100644 index 0000000000..6a185cc21a --- /dev/null +++ b/selenium-webdriver/selenium-webdriver.d.ts @@ -0,0 +1,3153 @@ +// Type definitions for Selenium WebDriverJS +// Project: https://code.google.com/p/selenium/ +// Definitions by: Bill Armstrong +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module webdriver { + + module logging { + + /** + * A hash describing log preferences. + * @typedef {Object.} + */ + var Preferences: any; + + /** + * Log level names from WebDriver's JSON wire protocol. + * @enum {string} + */ + class LevelName { + static ALL: string; + static DEBUG: string; + static INFO: string; + static WARNING: string; + static SEVERE: string; + static OFF: string; + } + + /** + * Common log types. + * @enum {string} + */ + class Type { + /** Logs originating from the browser. */ + static BROWSER: string; + /** Logs from a WebDriver client. */ + static CLIENT: string; + /** Logs from a WebDriver implementation. */ + static DRIVER: string; + /** Logs related to performance. */ + static PERFORMANCE: string; + /** Logs from the remote server. */ + static SERVER: string; + } + + /** + * Logging levels. + * @enum {{value: number, name: webdriver.logging.LevelName}} + */ + class Level { + //region Static Properties + + static ALL: Level; + static DEBUG: Level; + static INFO: Level; + static WARNING: Level; + static SEVERE: Level; + static OFF: Level; + + //endregion + + //region Properties + + value: number; + name: string; + + //endregion + } + + /** + * Converts a level name or value to a {@link webdriver.logging.Level} value. + * If the name/value is not recognized, {@link webdriver.logging.Level.ALL} + * will be returned. + * @param {(number|string)} nameOrValue The log level name, or value, to + * convert . + * @return {!webdriver.logging.Level} The converted level. + */ + function getLevel(nameOrValue: string): webdriver.logging.Level; + function getLevel(nameOrValue: number): webdriver.logging.Level; + + /** + * A single log entry. + */ + class Entry { + + //region Constructors + + /** + * @param {(!webdriver.logging.Level|string)} level The entry level. + * @param {string} message The log message. + * @param {number=} opt_timestamp The time this entry was generated, in + * milliseconds since 0:00:00, January 1, 1970 UTC. If omitted, the + * current time will be used. + * @param {string=} opt_type The log type, if known. + * @constructor + */ + constructor(level: webdriver.logging.Level, message: string, opt_timestamp?:number, opt_type?:string); + constructor(level: string, message: string, opt_timestamp?:number, opt_type?:string); + + //endregion + + //region Public Properties + + /** @type {!webdriver.logging.Level} */ + level: webdriver.logging.Level; + + /** @type {string} */ + message: string; + + /** @type {number} */ + timestamp: number; + + /** @type {string} */ + type: string; + + //endregion + + //region Static Methods + + /** + * Converts a {@link goog.debug.LogRecord} into a + * {@link webdriver.logging.Entry}. + * @param {!goog.debug.LogRecord} logRecord The record to convert. + * @param {string=} opt_type The log type. + * @return {!webdriver.logging.Entry} The converted entry. + */ + static fromClosureLogRecord(logRecord: any, opt_type?:string): webdriver.logging.Entry; + + //endregion + + //region Methods + + /** + * @return {{level: string, message: string, timestamp: number, + * type: string}} The JSON representation of this entry. + */ + toJSON(): webdriver.logging.Level; + + //endregion + } + } + + module promise { + + //region Functions + + /** + * @return {!webdriver.promise.ControlFlow} The currently active control flow. + */ + function controlFlow(): webdriver.promise.ControlFlow; + + /** + * Creates a new control flow. The provided callback will be invoked as the + * first task within the new flow, with the flow as its sole argument. Returns + * a promise that resolves to the callback result. + * @param {function(!webdriver.promise.ControlFlow)} callback The entry point + * to the newly created flow. + * @return {!webdriver.promise.Promise} A promise that resolves to the callback + * result. + */ + function createFlow(callback: (flow: webdriver.promise.ControlFlow) => any): webdriver.promise.Promise; + + /** + * Determines whether a {@code value} should be treated as a promise. + * Any object whose "then" property is a function will be considered a promise. + * + * @param {*} value The value to test. + * @return {boolean} Whether the value is a promise. + */ + function isPromise(value: any): boolean; + + /** + * Creates a promise that will be resolved at a set time in the future. + * @param {number} ms The amount of time, in milliseconds, to wait before + * resolving the promise. + * @return {!webdriver.promise.Promise} The promise. + */ + function delayed(ms: number): webdriver.promise.Promise; + + /** + * Creates a new deferred object. + * @param {Function=} opt_canceller Function to call when cancelling the + * computation of this instance's value. + * @return {!webdriver.promise.Deferred} The new deferred object. + */ + function defer(opt_canceller?: any): webdriver.promise.Deferred; + + /** + * Creates a promise that has been resolved with the given value. + * @param {*=} opt_value The resolved value. + * @return {!webdriver.promise.Promise} The resolved promise. + */ + function fulfilled(opt_value?: any): webdriver.promise.Promise; + + /** + * Creates a promise that has been rejected with the given reason. + * @param {*=} opt_reason The rejection reason; may be any value, but is + * usually an Error or a string. + * @return {!webdriver.promise.Promise} The rejected promise. + */ + function rejected(opt_reason?: any): webdriver.promise.Promise; + + /** + * Wraps a function that is assumed to be a node-style callback as its final + * argument. This callback takes two arguments: an error value (which will be + * null if the call succeeded), and the success value as the second argument. + * If the call fails, the returned promise will be rejected, otherwise it will + * be resolved with the result. + * @param {!Function} fn The function to wrap. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * result of the provided function's callback. + */ + function checkedNodeCall(fn: (error: any, value: any) => any): webdriver.promise.Promise; + + /** + * Registers an observer on a promised {@code value}, returning a new promise + * that will be resolved when the value is. If {@code value} is not a promise, + * then the return promise will be immediately resolved. + * @param {*} value The value to observe. + * @param {Function=} opt_callback The function to call when the value is + * resolved successfully. + * @param {Function=} opt_errback The function to call when the value is + * rejected. + * @return {!webdriver.promise.Promise} A new promise. + */ + function when(value: any, opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise; + + /** + * Invokes the appropriate callback function as soon as a promised + * {@code value} is resolved. This function is similar to + * {@code webdriver.promise.when}, except it does not return a new promise. + * @param {*} value The value to observe. + * @param {Function} callback The function to call when the value is + * resolved successfully. + * @param {Function=} opt_errback The function to call when the value is + * rejected. + */ + function asap(value: any, callback: (value: any) => any, opt_errback?: (error: any) => any): void; + + /** + * Returns a promise that will be resolved with the input value in a + * fully-resolved state. If the value is an array, each element will be fully + * resolved. Likewise, if the value is an object, all keys will be fully + * resolved. In both cases, all nested arrays and objects will also be + * fully resolved. All fields are resolved in place; the returned promise will + * resolve on {@code value} and not a copy. + * + * Warning: This function makes no checks against objects that contain + * cyclical references: + * + * var value = {}; + * value['self'] = value; + * webdriver.promise.fullyResolved(value); // Stack overflow. + * + * @param {*} value The value to fully resolve. + * @return {!webdriver.promise.Promise} A promise for a fully resolved version + * of the input value. + */ + function fullyResolved(value: any): webdriver.promise.Promise; + + /** + * Changes the default flow to use when no others are active. + * @param {!webdriver.promise.ControlFlow} flow The new default flow. + * @throws {Error} If the default flow is not currently active. + */ + function setDefaultFlow(flow: webdriver.promise.ControlFlow): void; + + //endregion + + /** + * Represents the eventual value of a completed operation. Each promise may be + * in one of three states: pending, resolved, or rejected. Each promise starts + * in the pending state and may make a single transition to either a + * fulfilled or failed state. + * + *

This class is based on the Promise/A proposal from CommonJS. Additional + * functions are provided for API compatibility with Dojo Deferred objects. + * + * @see http://wiki.commonjs.org/wiki/Promises/A + */ + class Promise { + + //region Constructors + + /** + * @constructor + * @see http://wiki.commonjs.org/wiki/Promises/A + */ + constructor(); + + //endregion + + //region Methods + + /** + * Cancels the computation of this promise's value, rejecting the promise in the + * process. + * @param {*} reason The reason this promise is being cancelled. If not an + * {@code Error}, one will be created using the value's string + * representation. + */ + cancel(reason: any): void; + + /** @return {boolean} Whether this promise's value is still being computed. */ + isPending(): boolean; + + /** + * Registers listeners for when this instance is resolved. This function most + * overridden by subtypes. + * + * @param {Function=} opt_callback The function to call if this promise is + * successfully resolved. The function should expect a single argument: the + * promise's resolved value. + * @param {Function=} opt_errback The function to call if this promise is + * rejected. The function should expect a single argument: the rejection + * reason. + * @return {!webdriver.promise.Promise} A new promise which will be resolved + * with the result of the invoked callback. + */ + then(opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): Promise; + + /** + * Registers a function to be invoked when this promise is successfully + * resolved. This function is provided for backwards compatibility with the + * Dojo Deferred API. + * + * @param {Function} callback The function to call if this promise is + * successfully resolved. The function should expect a single argument: the + * promise's resolved value. + * @param {!Object=} opt_self The object which |this| should refer to when the + * function is invoked. + * @return {!webdriver.promise.Promise} A new promise which will be resolved + * with the result of the invoked callback. + */ + addCallback(callback: (value: any) => any, opt_self?: any): Promise; + + + /** + * Registers a function to be invoked when this promise is rejected. + * This function is provided for backwards compatibility with the + * Dojo Deferred API. + * + * @param {Function} errback The function to call if this promise is + * rejected. The function should expect a single argument: the rejection + * reason. + * @param {!Object=} opt_self The object which |this| should refer to when the + * function is invoked. + * @return {!webdriver.promise.Promise} A new promise which will be resolved + * with the result of the invoked callback. + */ + addErrback(errback: (error: any) => any, opt_self?: any): Promise; + + /** + * Registers a function to be invoked when this promise is either rejected or + * resolved. This function is provided for backwards compatibility with the + * Dojo Deferred API. + * + * @param {Function} callback The function to call when this promise is + * either resolved or rejected. The function should expect a single + * argument: the resolved value or rejection error. + * @param {!Object=} opt_self The object which |this| should refer to when the + * function is invoked. + * @return {!webdriver.promise.Promise} A new promise which will be resolved + * with the result of the invoked callback. + */ + addBoth(callback : (value: any) => any, opt_self?: any): Promise; + + /** + * An alias for {@code webdriver.promise.Promise.prototype.then} that permits + * the scope of the invoked function to be specified. This function is provided + * for backwards compatibility with the Dojo Deferred API. + * + * @param {Function} callback The function to call if this promise is + * successfully resolved. The function should expect a single argument: the + * promise's resolved value. + * @param {Function} errback The function to call if this promise is + * rejected. The function should expect a single argument: the rejection + * reason. + * @param {!Object=} opt_self The object which |this| should refer to when the + * function is invoked. + * @return {!webdriver.promise.Promise} A new promise which will be resolved + * with the result of the invoked callback. + */ + addCallbacks(callback: (value: any) => any, errback: (error: any) => any, opt_self?: any): Promise; + + //endregion + } + + /** + * Represents a value that will be resolved at some point in the future. This + * class represents the protected "producer" half of a Promise - each Deferred + * has a {@code promise} property that may be returned to consumers for + * registering callbacks, reserving the ability to resolve the deferred to the + * producer. + * + *

If this Deferred is rejected and there are no listeners registered before + * the next turn of the event loop, the rejection will be passed to the + * {@link webdriver.promise.ControlFlow} as an unhandled failure. + * + *

If this Deferred is cancelled, the cancellation reason will be forward to + * the Deferred's canceller function (if provided). The canceller may return a + * truth-y value to override the reason provided for rejection. + * + * @extends {webdriver.promise.Promise} + */ + class Deferred extends Promise { + //region Constructors + + /** + * + * @param {Function=} opt_canceller Function to call when cancelling the + * computation of this instance's value. + * @param {webdriver.promise.ControlFlow=} opt_flow The control flow + * this instance was created under. This should only be provided during + * unit tests. + * @constructor + */ + constructor(opt_canceller?: any, opt_flow?: webdriver.promise.ControlFlow); + + //endregion + + //region Properties + + /** + * The consumer promise for this instance. Provides protected access to the + * callback registering functions. + * @type {!webdriver.promise.Promise} + */ + promise: webdriver.promise.Promise; + + //endregion + + //region Methods + + /** + * Rejects this promise. If the error is itself a promise, this instance will + * be chained to it and be rejected with the error's resolved value. + * @param {*=} opt_error The rejection reason, typically either a + * {@code Error} or a {@code string}. + */ + reject(opt_error?: any): void; + errback(opt_error?: any): void; + + /** + * Resolves this promise with the given value. If the value is itself a + * promise and not a reference to this deferred, this instance will wait for + * it before resolving. + * @param {*=} opt_value The resolved value. + */ + fulfill(opt_value?: any): void; + + /** + * Cancels the computation of this promise's value and flags the promise as a + * rejected value. + * @param {*=} opt_reason The reason for cancelling this promise. + */ + cancel(opt_reason?: any): void; + + /** + * Removes all of the listeners previously registered on this deferred. + * @throws {Error} If this deferred has already been resolved. + */ + removeAll(): void; + + //endregion + } + + interface IControlFlowTimer { + clearInterval: (ms: number) => void; + clearTimeout: (ms: number) => void; + setInterval: (fn: any, ms: number) => number; + setTimeout: (fn: any, ms: number) => number; + } + + /** + * Handles the execution of scheduled tasks, each of which may be an + * asynchronous operation. The control flow will ensure tasks are executed in + * the ordered scheduled, starting each task only once those before it have + * completed. + * + *

Each task scheduled within this flow may return a + * {@link webdriver.promise.Promise} to indicate it is an asynchronous + * operation. The ControlFlow will wait for such promises to be resolved before + * marking the task as completed. + * + *

Tasks and each callback registered on a {@link webdriver.promise.Deferred} + * will be run in their own ControlFlow frame. Any tasks scheduled within a + * frame will have priority over previously scheduled tasks. Furthermore, if + * any of the tasks in the frame fails, the remainder of the tasks in that frame + * will be discarded and the failure will be propagated to the user through the + * callback/task's promised result. + * + *

Each time a ControlFlow empties its task queue, it will fire an + * {@link webdriver.promise.ControlFlow.EventType.IDLE} event. Conversely, + * whenever the flow terminates due to an unhandled error, it will remove all + * remaining tasks in its queue and fire an + * {@link webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION} event. If + * there are no listeners registered with the flow, the error will be + * rethrown to the global error handler. + * + * @extends {webdriver.EventEmitter} + */ + class ControlFlow extends webdriver.EventEmitter { + + //region Constructors + + /** + * @param {webdriver.promise.ControlFlow.Timer=} opt_timer The timer object + * to use. Should only be set for testing. + * @constructor + */ + constructor(opt_timer?: webdriver.promise.IControlFlowTimer); + + //endregion + + //region Properties + + /** + * The timer used by this instance. + * @type {webdriver.promise.ControlFlow.Timer} + */ + timer: webdriver.promise.IControlFlowTimer; + + //endregion + + //region Static Properties + + /** + * The default timer object, which uses the global timer functions. + * @type {webdriver.promise.ControlFlow.Timer} + */ + static defaultTimer: webdriver.promise.IControlFlowTimer; + + /** + * Events that may be emitted by an {@link webdriver.promise.ControlFlow}. + * @enum {string} + */ + static EventType: { + /** Emitted when all tasks have been successfully executed. */ + IDLE: string; + + /** Emitted whenever a new task has been scheduled. */ + SCHEDULE_TASK: string; + + /** + * Emitted whenever a control flow aborts due to an unhandled promise + * rejection. This event will be emitted along with the offending rejection + * reason. Upon emitting this event, the control flow will empty its task + * queue and revert to its initial state. + */ + UNCAUGHT_EXCEPTION: string; + }; + + /** + * How often, in milliseconds, the event loop should run. + * @type {number} + * @const + */ + static EVENT_LOOP_FREQUENCY: number; + + //endregion + + //region Methods + + /** + * Resets this instance, clearing its queue and removing all event listeners. + */ + reset(): void; + + /** + * Returns a summary of the recent task activity for this instance. This + * includes the most recently completed task, as well as any parent tasks. In + * the returned summary, the task at index N is considered a sub-task of the + * task at index N+1. + * @return {!Array.} A summary of this instance's recent task + * activity. + */ + getHistory(): string[]; + + /** Clears this instance's task history. */ + clearHistory(): void; + + /** + * Appends a summary of this instance's recent task history to the given + * error's stack trace. This function will also ensure the error's stack trace + * is in canonical form. + * @param {!(Error|goog.testing.JsUnitException)} e The error to annotate. + * @return {!(Error|goog.testing.JsUnitException)} The annotated error. + */ + annotateError(e: any): any; + + /** + * @return {string} The scheduled tasks still pending with this instance. + */ + getSchedule(): string; + + /** + * Schedules a task for execution. If there is nothing currently in the + * queue, the task will be executed in the next turn of the event loop. + * + * @param {!Function} fn The function to call to start the task. If the + * function returns a {@link webdriver.promise.Promise}, this instance + * will wait for it to be resolved before starting the next task. + * @param {string=} opt_description A description of the task. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * the result of the action. + */ + execute(fn: any, opt_description?: string): webdriver.promise.Promise; + + /** + * Inserts a {@code setTimeout} into the command queue. This is equivalent to + * a thread sleep in a synchronous programming language. + * + * @param {number} ms The timeout delay, in milliseconds. + * @param {string=} opt_description A description to accompany the timeout. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * the result of the action. + */ + timeout(ms: number, opt_description?: string): webdriver.promise.Promise; + + /** + * Schedules a task that shall wait for a condition to hold. Each condition + * function may return any value, but it will always be evaluated as a boolean. + * + *

Condition functions may schedule sub-tasks with this instance, however, + * their execution time will be factored into whether a wait has timed out. + * + *

In the event a condition returns a Promise, the polling loop will wait for + * it to be resolved before evaluating whether the condition has been satisfied. + * The resolution time for a promise is factored into whether a wait has timed + * out. + * + *

If the condition function throws, or returns a rejected promise, the + * wait task will fail. + * + * @param {!Function} condition The condition function to poll. + * @param {number} timeout How long to wait, in milliseconds, for the condition + * to hold before timing out. + * @param {string=} opt_message An optional error message to include if the + * wait times out; defaults to the empty string. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * condition has been satisified. The promise shall be rejected if the wait + * times out waiting for the condition. + */ + wait(condition: any, timeout: number, opt_message?: string): webdriver.promise.Promise; + + /** + * Schedules a task that will wait for another promise to resolve. The resolved + * promise's value will be returned as the task result. + * @param {!webdriver.promise.Promise} promise The promise to wait on. + * @return {!webdriver.promise.Promise} A promise that will resolve when the + * task has completed. + */ + await(promise: webdriver.promise.Promise): webdriver.promise.Promise; + + //endregion + } + } + + module error { + + // NOTE: A class was used instead of an Enum so that it could be extended in Protractor. + class ErrorCode { + static SUCCESS: number; + + static NO_SUCH_ELEMENT: number; + static NO_SUCH_FRAME: number; + static UNKNOWN_COMMAND: number; + static UNSUPPORTED_OPERATION: number; // Alias for UNKNOWN_COMMAND. + static STALE_ELEMENT_REFERENCE: number; + static ELEMENT_NOT_VISIBLE: number; + static INVALID_ELEMENT_STATE: number; + static UNKNOWN_ERROR: number; + static ELEMENT_NOT_SELECTABLE: number; + static JAVASCRIPT_ERROR: number; + static XPATH_LOOKUP_ERROR: number; + static TIMEOUT: number; + static NO_SUCH_WINDOW: number; + static INVALID_COOKIE_DOMAIN: number; + static UNABLE_TO_SET_COOKIE: number; + static MODAL_DIALOG_OPENED: number; + static NO_MODAL_DIALOG_OPEN: number; + static SCRIPT_TIMEOUT: number; + static INVALID_ELEMENT_COORDINATES: number; + static IME_NOT_AVAILABLE: number; + static IME_ENGINE_ACTIVATION_FAILED: number; + static INVALID_SELECTOR_ERROR: number; + static SESSION_NOT_CREATED: number; + static MOVE_TARGET_OUT_OF_BOUNDS: number; + static SQL_DATABASE_ERROR: number; + static INVALID_XPATH_SELECTOR: number; + static INVALID_XPATH_SELECTOR_RETURN_TYPE: number; + // The following error codes are derived straight from HTTP return codes. + static METHOD_NOT_ALLOWED: number; + } + + /** + * Error extension that includes error status codes from the WebDriver wire + * protocol: + * http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes + * + * @extends {Error} + */ + class Error { + + //region Constructors + + /** + * @param {!bot.ErrorCode} code The error's status code. + * @param {string=} opt_message Optional error message. + * @constructor + */ + constructor(code: number, opt_message?: string); + + //endregion + + //region Static Properties + + /** + * Status strings enumerated in the W3C WebDriver working draft. + * @enum {string} + * @see http://www.w3.org/TR/webdriver/#status-codes + */ + static State: { + ELEMENT_NOT_SELECTABLE: string; + ELEMENT_NOT_VISIBLE: string; + IME_ENGINE_ACTIVATION_FAILED: string; + IME_NOT_AVAILABLE: string; + INVALID_COOKIE_DOMAIN: string; + INVALID_ELEMENT_COORDINATES: string; + INVALID_ELEMENT_STATE: string; + INVALID_SELECTOR: string; + JAVASCRIPT_ERROR: string; + MOVE_TARGET_OUT_OF_BOUNDS: string; + NO_SUCH_ALERT: string; + NO_SUCH_DOM: string; + NO_SUCH_ELEMENT: string; + NO_SUCH_FRAME: string; + NO_SUCH_WINDOW: string; + SCRIPT_TIMEOUT: string; + SESSION_NOT_CREATED: string; + STALE_ELEMENT_REFERENCE: string; + SUCCESS: string; + TIMEOUT: string; + UNABLE_TO_SET_COOKIE: string; + UNEXPECTED_ALERT_OPEN: string; + UNKNOWN_COMMAND: string; + UNKNOWN_ERROR: string; + UNSUPPORTED_OPERATION: string; + } + + //endregion + + //region Properties + + /** + * This error's status code. + * @type {!bot.ErrorCode} + */ + code: number; + + /** @type {string} */ + state: string; + + /** @override */ + message: string; + + /** @override */ + name: string; + + /** @override */ + stack: string; + + /** + * Flag used for duck-typing when this code is embedded in a Firefox extension. + * This is required since an Error thrown in one component and then reported + * to another will fail instanceof checks in the second component. + * @type {boolean} + */ + isAutomationError: boolean; + + //endregion + + //region Methods + + /** @return {string} The string representation of this error. */ + toString(): string; + + //endregion + } + } + + module process { + + /** + * Queries for a named environment variable. + * @param {string} name The name of the environment variable to look up. + * @param {string=} opt_default The default value if the named variable is not + * defined. + * @return {string} The queried environment variable. + */ + function getEnv(name: string, opt_default?: string): string; + + /** + * @return {boolean} Whether the current process is Node's native process + * object. + */ + function isNative(): boolean; + + /** + * Sets an environment value. If the new value is either null or undefined, the + * environment variable will be cleared. + * @param {string} name The value to set. + * @param {*} value The new value; will be coerced to a string. + */ + function setEnv(name: string, value: any): void; + + } + + /** + * Creates new {@code webdriver.WebDriver} clients. Upon instantiation, each + * Builder will configure itself based on the following environment variables: + *

+ *
{@code webdriver.AbstractBuilder.SERVER_URL_ENV}
+ *
Defines the remote WebDriver server that should be used for command + * command execution; may be overridden using + * {@code webdriver.AbstractBuilder.prototype.usingServer}.
+ *
+ */ + class AbstractBuilder { + + //region Constructors + + /** + * @constructor + */ + constructor(); + + //endregion + + //region Static Properties + + /** + * Environment variable that defines the URL of the WebDriver server that + * should be used for all new WebDriver clients. This setting may be overridden + * using {@code #usingServer(url)}. + * @type {string} + * @const + * @see webdriver.process.getEnv + */ + static SERVER_URL_ENV: string; + + + /** + * The default URL of the WebDriver server to use if + * {@link webdriver.AbstractBuilder.SERVER_URL_ENV} is not set. + * @type {string} + * @const + */ + static DEFAULT_SERVER_URL: string; + + //endregion + + //region Methods + + /** + * Configures which WebDriver server should be used for new sessions. Overrides + * the value loaded from the {@link webdriver.AbstractBuilder.SERVER_URL_ENV} + * upon creation of this instance. + * @param {string} url URL of the server to use. + * @return {!webdriver.AbstractBuilder} This Builder instance for chain calling. + */ + usingServer(url: string): AbstractBuilder; + + /** + * @return {string} The URL of the WebDriver server this instance is configured + * to use. + */ + getServerUrl(): string; + + /** + * Sets the desired capabilities when requesting a new session. This will + * overwrite any previously set desired capabilities. + * @param {!(Object|webdriver.Capabilities)} capabilities The desired + * capabilities for a new session. + * @return {!webdriver.AbstractBuilder} This Builder instance for chain calling. + */ + withCapabilities(capabilities: webdriver.Capabilities): AbstractBuilder; + withCapabilities(capabilities: any): AbstractBuilder; + + /** + * @return {!webdriver.Capabilities} The current desired capabilities for this + * builder. + */ + getCapabilities(): webdriver.Capabilities; + + /** + * Builds a new {@link webdriver.WebDriver} instance using this builder's + * current configuration. + * @return {!webdriver.WebDriver} A new WebDriver client. + */ + build(): webdriver.WebDriver; + + //endregion + } + + interface ILocation { + x: number; + y: number; + } + + /** + * Enumeration of the buttons used in the advanced interactions API. + * NOTE: A TypeScript enum was not used so that this class could be extended in Protractor. + * @enum {number} + */ + class Button { + static LEFT: number; + static MIDDLE: number; + static RIGHT: number; + } + + /** + * Representations of pressable keys that aren't text. These are stored in + * the Unicode PUA (Private Use Area) code points, 0xE000-0xF8FF. Refer to + * http://www.google.com.au/search?&q=unicode+pua&btnG=Search + * NOTE: A class was used instead of an Enum so that it could be extended in Protractor + * + * @enum {string} + */ + class Key { + static NULL: string; + static CANCEL: string; // ^break + static HELP: string; + static BACK_SPACE: string; + static TAB: string; + static CLEAR: string; + static RETURN: string; + static ENTER: string; + static SHIFT: string; + static CONTROL: string; + static ALT: string; + static PAUSE: string; + static ESCAPE: string; + static SPACE: string; + static PAGE_UP: string; + static PAGE_DOWN: string; + static END: string; + static HOME: string; + static ARROW_LEFT: string; + static LEFT: string; + static ARROW_UP: string; + static UP: string; + static ARROW_RIGHT: string; + static RIGHT: string; + static ARROW_DOWN: string; + static DOWN: string; + static INSERT: string; + static DELETE: string; + static SEMICOLON: string; + static EQUALS: string; + + static NUMPAD0: string; // number pad keys + static NUMPAD1: string; + static NUMPAD2: string; + static NUMPAD3: string; + static NUMPAD4: string; + static NUMPAD5: string; + static NUMPAD6: string; + static NUMPAD7: string; + static NUMPAD8: string; + static NUMPAD9: string; + static MULTIPLY: string; + static ADD: string; + static SEPARATOR: string; + static SUBTRACT: string; + static DECIMAL: string; + static DIVIDE: string; + + static F1: string; // function keys + static F2: string; + static F3: string; + static F4: string; + static F5: string; + static F6: string; + static F7: string; + static F8: string; + static F9: string; + static F10: string; + static F11: string; + static F12: string; + + static COMMAND: string; // Apple command key + static META: string; // alias for Windows key + + /** + * Simulate pressing many keys at once in a "chord". Takes a sequence of + * {@link webdriver.Key}s or strings, appends each of the values to a string, + * and adds the chord termination key ({@link webdriver.Key.NULL}) and returns + * the resultant string. + * + * Note: when the low-level webdriver key handlers see Keys.NULL, active + * modifier keys (CTRL/ALT/SHIFT/etc) release via a keyup event. + * + * @param {...string} var_args The key sequence to concatenate. + * @return {string} The null-terminated key sequence. + * @see http://code.google.com/p/webdriver/issues/detail?id=79 + */ + static chord(...var_args: string[]): string; + } + + /** + * Class for defining sequences of complex user interactions. Each sequence + * will not be executed until {@link #perform} is called. + * + *

Example:


+     *   new webdriver.ActionSequence(driver).
+     *       keyDown(webdriver.Key.SHIFT).
+     *       click(element1).
+     *       click(element2).
+     *       dragAndDrop(element3, element4).
+     *       keyUp(webdriver.Key.SHIFT).
+     *       perform();
+     * 
+ * + */ + class ActionSequence { + + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The driver instance to use. + * @constructor + */ + constructor(driver: webdriver.WebDriver); + + //endregion + + //region Methods + + /** + * Executes this action sequence. + * @return {!webdriver.promise.Promise} A promise that will be resolved once + * this sequence has completed. + */ + perform(): webdriver.promise.Promise; + + /** + * Moves the mouse. The location to move to may be specified in terms of the + * mouse's current location, an offset relative to the top-left corner of an + * element, or an element (in which case the middle of the element is used). + * @param {(!webdriver.WebElement|{x: number, y: number})} location The + * location to drag to, as either another WebElement or an offset in pixels. + * @param {{x: number, y: number}=} opt_offset An optional offset, in pixels. + * Defaults to (0, 0). + * @return {!webdriver.ActionSequence} A self reference. + */ + mouseMove(location: webdriver.WebElement, opt_offset?: ILocation): ActionSequence + mouseMove(location: ILocation): ActionSequence + + /** + * Presses a mouse button. The mouse button will not be released until + * {@link #mouseUp} is called, regardless of whether that call is made in this + * sequence or another. The behavior for out-of-order events (e.g. mouseDown, + * click) is undefined. + * + *

If an element is provided, the mouse will first be moved to the center + * of that element. This is equivalent to: + *

sequence.mouseMove(element).mouseDown()
+ * + *

Warning: this method currently only supports the left mouse button. See + * http://code.google.com/p/selenium/issues/detail?id=4047 + * + * @param {(webdriver.WebElement|webdriver.Button)=} opt_elementOrButton Either + * the element to interact with or the button to click with. + * Defaults to {@link webdriver.Button.LEFT} if neither an element nor + * button is specified. + * @param {webdriver.Button=} opt_button The button to use. Defaults to + * {@link webdriver.Button.LEFT}. Ignored if a button is provided as the + * first argument. + * @return {!webdriver.ActionSequence} A self reference. + */ + mouseDown(opt_elementOrButton?: webdriver.WebElement, opt_button?: number): ActionSequence; + mouseDown(opt_elementOrButton?: number): ActionSequence; + + /** + * Releases a mouse button. Behavior is undefined for calling this function + * without a previous call to {@link #mouseDown}. + * + *

If an element is provided, the mouse will first be moved to the center + * of that element. This is equivalent to: + *

sequence.mouseMove(element).mouseUp()
+ * + *

Warning: this method currently only supports the left mouse button. See + * http://code.google.com/p/selenium/issues/detail?id=4047 + * + * @param {(webdriver.WebElement|webdriver.Button)=} opt_elementOrButton Either + * the element to interact with or the button to click with. + * Defaults to {@link webdriver.Button.LEFT} if neither an element nor + * button is specified. + * @param {webdriver.Button=} opt_button The button to use. Defaults to + * {@link webdriver.Button.LEFT}. Ignored if a button is provided as the + * first argument. + * @return {!webdriver.ActionSequence} A self reference. + */ + mouseUp(opt_elementOrButton?: webdriver.WebElement, opt_button?: number): ActionSequence; + mouseUp(opt_elementOrButton?: number): ActionSequence; + + /** + * Convenience function for performing a "drag and drop" manuever. The target + * element may be moved to the location of another element, or by an offset (in + * pixels). + * @param {!webdriver.WebElement} element The element to drag. + * @param {(!webdriver.WebElement|{x: number, y: number})} location The + * location to drag to, either as another WebElement or an offset in pixels. + * @return {!webdriver.ActionSequence} A self reference. + */ + dragAndDrop(element: webdriver.WebElement, location: webdriver.WebElement): ActionSequence; + dragAndDrop(element: webdriver.WebElement, location: ILocation): ActionSequence; + + /** + * Clicks a mouse button. + * + *

If an element is provided, the mouse will first be moved to the center + * of that element. This is equivalent to: + *

sequence.mouseMove(element).click()
+ * + * @param {(webdriver.WebElement|webdriver.Button)=} opt_elementOrButton Either + * the element to interact with or the button to click with. + * Defaults to {@link webdriver.Button.LEFT} if neither an element nor + * button is specified. + * @param {webdriver.Button=} opt_button The button to use. Defaults to + * {@link webdriver.Button.LEFT}. Ignored if a button is provided as the + * first argument. + * @return {!webdriver.ActionSequence} A self reference. + */ + click(opt_elementOrButton?: webdriver.WebElement, opt_button?: number): ActionSequence; + click(opt_elementOrButton?: number): ActionSequence; + + /** + * Double-clicks a mouse button. + * + *

If an element is provided, the mouse will first be moved to the center of + * that element. This is equivalent to: + *

sequence.mouseMove(element).doubleClick()
+ * + *

Warning: this method currently only supports the left mouse button. See + * http://code.google.com/p/selenium/issues/detail?id=4047 + * + * @param {(webdriver.WebElement|webdriver.Button)=} opt_elementOrButton Either + * the element to interact with or the button to click with. + * Defaults to {@link webdriver.Button.LEFT} if neither an element nor + * button is specified. + * @param {webdriver.Button=} opt_button The button to use. Defaults to + * {@link webdriver.Button.LEFT}. Ignored if a button is provided as the + * first argument. + * @return {!webdriver.ActionSequence} A self reference. + */ + doubleClick(opt_elementOrButton?: webdriver.WebElement, opt_button?: number): ActionSequence; + doubleClick(opt_elementOrButton?: number): ActionSequence; + + /** + * Performs a modifier key press. The modifier key is not released + * until {@link #keyUp} or {@link #sendKeys} is called. The key press will be + * targetted at the currently focused element. + * @param {!webdriver.Key} key The modifier key to push. Must be one of + * {ALT, CONTROL, SHIFT, COMMAND, META}. + * @return {!webdriver.ActionSequence} A self reference. + * @throws {Error} If the key is not a valid modifier key. + */ + keyDown(key: string): ActionSequence; + + /** + * Performs a modifier key release. The release is targetted at the currently + * focused element. + * @param {!webdriver.Key} key The modifier key to release. Must be one of + * {ALT, CONTROL, SHIFT, COMMAND, META}. + * @return {!webdriver.ActionSequence} A self reference. + * @throws {Error} If the key is not a valid modifier key. + */ + keyUp(key: string): ActionSequence; + + /** + * Simulates typing multiple keys. Each modifier key encountered in the + * sequence will not be released until it is encountered again. All key events + * will be targetted at the currently focused element. + * @param {...(string|!webdriver.Key|!Array.<(string|!webdriver.Key)>)} var_args + * The keys to type. + * @return {!webdriver.ActionSequence} A self reference. + * @throws {Error} If the key is not a valid modifier key. + */ + sendKeys(...var_args: any[]): ActionSequence; + + //endregion + } + + /** + * Represents a modal dialog such as {@code alert}, {@code confirm}, or + * {@code prompt}. Provides functions to retrieve the message displayed with + * the alert, accept or dismiss the alert, and set the response text (in the + * case of {@code prompt}). + * @extends {webdriver.promise.Deferred} + */ + class Alert extends webdriver.promise.Deferred { + + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The driver controlling the browser this + * alert is attached to. + * @param {!(string|webdriver.promise.Promise)} text Either the message text + * displayed with this alert, or a promise that will be resolved to said + * text. + * @constructor + */ + constructor(driver: webdriver.WebDriver, text: string); + constructor(driver: webdriver.WebDriver, text: webdriver.promise.Promise); + + //endregion + + //region Methods + + /** + * Retrieves the message text displayed with this alert. For instance, if the + * alert were opened with alert("hello"), then this would return "hello". + * @return {!webdriver.promise.Promise} A promise that will be resolved to the + * text displayed with this alert. + */ + getText(): webdriver.promise.Promise; + + /** + * Accepts this alert. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * this command has completed. + */ + accept(): webdriver.promise.Promise; + + /** + * Dismisses this alert. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * this command has completed. + */ + dismiss(): webdriver.promise.Promise; + + /** + * Sets the response text on this alert. This command will return an error if + * the underlying alert does not support response text (e.g. window.alert and + * window.confirm). + * @param {string} text The text to set. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * this command has completed. + */ + sendKeys(text: string): webdriver.promise.Promise; + + //endregion + + } + + /** + * An error returned to indicate that there is an unhandled modal dialog on the + * current page. + * @extends {bot.Error} + */ + class UnhandledAlertError extends webdriver.error.Error { + //region Constructors + + /** + * @param {string} message The error message. + * @param {!webdriver.Alert} alert The alert handle. + * @constructor + */ + constructor(message: string, alert: webdriver.Alert); + + //endregion + + //region Methods + + /** + * @return {!webdriver.Alert} The open alert. + */ + getAlert(): webdriver.Alert; + + //endregion + } + + /** + * Recognized browser names. + * @enum {string} + */ + class Browser { + static ANDROID: string; + static CHROME: string; + static FIREFOX: string; + static INTERNET_EXPLORER: string; + static IPAD: string; + static IPHONE: string; + static OPERA: string; + static PHANTOM_JS: string; + static SAFARI: string; + static HTMLUNIT: string; + } + + /** + * @extends {webdriver.AbstractBuilder} + */ + class Builder extends AbstractBuilder { + + //region Constructors + + /** + * @constructor + */ + constructor(); + + //endregion + + //region Static Properties + + /** + * Environment variable that defines the session ID of an existing WebDriver + * session to use when creating clients. If set, all new Builder instances will + * default to creating clients that use this session. To create a new session, + * use {@code #useExistingSession(boolean)}. The use of this environment + * variable requires that {@link webdriver.AbstractBuilder.SERVER_URL_ENV} also + * be set. + * @type {string} + * @const + * @see webdriver.process.getEnv + */ + static SESSION_ID_ENV: string; + + //endregion + + //region Methods + + /** + * Configures the builder to create a client that will use an existing WebDriver + * session. + * @param {string} id The existing session ID to use. + * @return {!webdriver.AbstractBuilder} This Builder instance for chain calling. + */ + usingSession(id: string): webdriver.AbstractBuilder; + + /** + * @return {string} The ID of the session, if any, this builder is configured + * to reuse. + */ + getSession(): string; + + /** + * @override + */ + build(): webdriver.WebDriver; + + //endregion + } + + /** + * Common webdriver capability keys. + * @enum {string} + */ + class Capability { + + /** + * Indicates whether a driver should accept all SSL certs by default. This + * capability only applies when requesting a new session. To query whether + * a driver can handle insecure SSL certs, see + * {@link webdriver.Capability.SECURE_SSL}. + */ + static ACCEPT_SSL_CERTS: string; + + + /** + * The browser name. Common browser names are defined in the + * {@link webdriver.Browser} enum. + */ + static BROWSER_NAME: string; + + /** + * Whether the driver is capable of handling modal alerts (e.g. alert, + * confirm, prompt). To define how a driver should handle alerts, + * use {@link webdriver.Capability.UNEXPECTED_ALERT_BEHAVIOR}. + */ + static HANDLES_ALERTS: string; + + /** + * Key for the logging driver logging preferences. + */ + static LOGGING_PREFS: string; + + /** + * Describes the platform the browser is running on. Will be one of + * ANDROID, IOS, LINUX, MAC, UNIX, or WINDOWS. When requesting a + * session, ANY may be used to indicate no platform preference (this is + * semantically equivalent to omitting the platform capability). + */ + static PLATFORM: string; + + /** + * Describes the proxy configuration to use for a new WebDriver session. + */ + static PROXY: string; + + /** Whether the driver supports changing the brower's orientation. */ + static ROTATABLE: string; + + /** + * Whether a driver is only capable of handling secure SSL certs. To request + * that a driver accept insecure SSL certs by default, use + * {@link webdriver.Capability.ACCEPT_SSL_CERTS}. + */ + static SECURE_SSL: string; + + /** Whether the driver supports manipulating the app cache. */ + static SUPPORTS_APPLICATION_CACHE: string; + + /** + * Whether the driver supports controlling the browser's internet + * connectivity. + */ + static SUPPORTS_BROWSER_CONNECTION: string; + + /** Whether the driver supports locating elements with CSS selectors. */ + static SUPPORTS_CSS_SELECTORS: string; + + /** Whether the browser supports JavaScript. */ + static SUPPORTS_JAVASCRIPT: string; + + /** Whether the driver supports controlling the browser's location info. */ + static SUPPORTS_LOCATION_CONTEXT: string; + + /** Whether the driver supports taking screenshots. */ + static TAKES_SCREENSHOT: string; + + /** + * Defines how the driver should handle unexpected alerts. The value should + * be one of "accept", "dismiss", or "ignore. + */ + static UNEXPECTED_ALERT_BEHAVIOR: string; + + /** Defines the browser version. */ + static VERSION: string; + } + + class Capabilities { + //region Constructors + + /** + * @param {(webdriver.Capabilities|Object)=} opt_other Another set of + * capabilities to merge into this instance. + * @constructor + */ + constructor(opt_other?: Capabilities); + constructor(opt_other?: any); + + //endregion + + //region Methods + + /** @return {!Object} The JSON representation of this instance. */ + toJSON(): any; + + /** + * Merges another set of capabilities into this instance. Any duplicates in + * the provided set will override those already set on this instance. + * @param {!(webdriver.Capabilities|Object)} other The capabilities to + * merge into this instance. + * @return {!webdriver.Capabilities} A self reference. + */ + merge(other: Capabilities): Capabilities; + merge(other: any): Capabilities; + + /** + * @param {string} key The capability to set. + * @param {*} value The capability value. Capability values must be JSON + * serializable. Pass {@code null} to unset the capability. + * @return {!webdriver.Capabilities} A self reference. + */ + set(key: string, value: any): Capabilities; + + /** + * @param {string} key The capability to return. + * @return {*} The capability with the given key, or {@code null} if it has + * not been set. + */ + get(key: string): any; + + /** + * @param {string} key The capability to check. + * @return {boolean} Whether the specified capability is set. + */ + has(key: string): boolean; + + //endregion + + //region Static Methods + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for Android. + */ + static android(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for Chrome. + */ + static chrome(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for Firefox. + */ + static firefox(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for + * Internet Explorer. + */ + static ie(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for iPad. + */ + static ipad(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for iPhone. + */ + static iphone(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for Opera. + */ + static opera(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for + * PhantomJS. + */ + static phantomjs(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for Safari. + */ + static safari(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for HTMLUnit. + */ + static htmlunit(): Capabilities; + + /** + * @return {!webdriver.Capabilities} A basic set of capabilities for HTMLUnit + * with enabled Javascript. + */ + static htmlunitwithjs(): Capabilities; + + //endregion + } + + /** + * An enumeration of valid command string. + * NOTE: A Class was used instead of an Enum so that the class could be extended in Protractor. + */ + class CommandName { + static GET_SERVER_STATUS: string; + + static NEW_SESSION: string; + static GET_SESSIONS: string; + static DESCRIBE_SESSION: string; + + static CLOSE: string; + static QUIT: string; + + static GET_CURRENT_URL: string; + static GET: string; + static GO_BACK: string; + static GO_FORWARD: string; + static REFRESH: string; + + static ADD_COOKIE: string; + static GET_COOKIE: string; + static GET_ALL_COOKIES: string; + static DELETE_COOKIE: string; + static DELETE_ALL_COOKIES: string; + + static GET_ACTIVE_ELEMENT: string; + static FIND_ELEMENT: string; + static FIND_ELEMENTS: string; + static FIND_CHILD_ELEMENT: string; + static FIND_CHILD_ELEMENTS: string; + + static CLEAR_ELEMENT: string; + static CLICK_ELEMENT: string; + static SEND_KEYS_TO_ELEMENT: string; + static SUBMIT_ELEMENT: string; + + static GET_CURRENT_WINDOW_HANDLE: string; + static GET_WINDOW_HANDLES: string; + static GET_WINDOW_POSITION: string; + static SET_WINDOW_POSITION: string; + static GET_WINDOW_SIZE: string; + static SET_WINDOW_SIZE: string; + static MAXIMIZE_WINDOW: string; + + static SWITCH_TO_WINDOW: string; + static SWITCH_TO_FRAME: string; + static GET_PAGE_SOURCE: string; + static GET_TITLE: string; + + static EXECUTE_SCRIPT: string; + static EXECUTE_ASYNC_SCRIPT: string; + + static GET_ELEMENT_TEXT: string; + static GET_ELEMENT_TAG_NAME: string; + static IS_ELEMENT_SELECTED: string; + static IS_ELEMENT_ENABLED: string; + static IS_ELEMENT_DISPLAYED: string; + static GET_ELEMENT_LOCATION: string; + static GET_ELEMENT_LOCATION_IN_VIEW: string; + static GET_ELEMENT_SIZE: string; + static GET_ELEMENT_ATTRIBUTE: string; + static GET_ELEMENT_VALUE_OF_CSS_PROPERTY: string; + static ELEMENT_EQUALS: string; + + static SCREENSHOT: string; + static IMPLICITLY_WAIT: string; + static SET_SCRIPT_TIMEOUT: string; + static SET_TIMEOUT: string; + + static ACCEPT_ALERT: string; + static DISMISS_ALERT: string; + static GET_ALERT_TEXT: string; + static SET_ALERT_TEXT: string; + + static EXECUTE_SQL: string; + static GET_LOCATION: string; + static SET_LOCATION: string; + static GET_APP_CACHE: string; + static GET_APP_CACHE_STATUS: string; + static CLEAR_APP_CACHE: string; + static IS_BROWSER_ONLINE: string; + static SET_BROWSER_ONLINE: string; + + static GET_LOCAL_STORAGE_ITEM: string; + static GET_LOCAL_STORAGE_KEYS: string; + static SET_LOCAL_STORAGE_ITEM: string; + static REMOVE_LOCAL_STORAGE_ITEM: string; + static CLEAR_LOCAL_STORAGE: string; + static GET_LOCAL_STORAGE_SIZE: string; + + static GET_SESSION_STORAGE_ITEM: string; + static GET_SESSION_STORAGE_KEYS: string; + static SET_SESSION_STORAGE_ITEM: string; + static REMOVE_SESSION_STORAGE_ITEM: string; + static CLEAR_SESSION_STORAGE: string; + static GET_SESSION_STORAGE_SIZE: string; + + static SET_SCREEN_ORIENTATION: string; + static GET_SCREEN_ORIENTATION: string; + + // These belong to the Advanced user interactions - an element is + // optional for these commands. + static CLICK: string; + static DOUBLE_CLICK: string; + static MOUSE_DOWN: string; + static MOUSE_UP: string; + static MOVE_TO: string; + static SEND_KEYS_TO_ACTIVE_ELEMENT: string; + + // These belong to the Advanced Touch API + static TOUCH_SINGLE_TAP: string; + static TOUCH_DOWN: string; + static TOUCH_UP: string; + static TOUCH_MOVE: string; + static TOUCH_SCROLL: string; + static TOUCH_DOUBLE_TAP: string; + static TOUCH_LONG_PRESS: string; + static TOUCH_FLICK: string; + + static GET_AVAILABLE_LOG_TYPES: string; + static GET_LOG: string; + static GET_SESSION_LOGS: string; + } + + /** + * Describes a command to be executed by the WebDriverJS framework. + * @param {!webdriver.CommandName} name The name of this command. + * @constructor + */ + class Command { + //region Constructors + + /** + * @param {!webdriver.CommandName} name The name of this command. + * @constructor + */ + constructor(name: string); + + //endregion + + //region Methods + + /** + * @return {!webdriver.CommandName} This command's name. + */ + getName(): string; + + /** + * Sets a parameter to send with this command. + * @param {string} name The parameter name. + * @param {*} value The parameter value. + * @return {!webdriver.Command} A self reference. + */ + setParameter(name: string, value: any): webdriver.Command; + + /** + * Sets the parameters for this command. + * @param {!Object.<*>} parameters The command parameters. + * @return {!webdriver.Command} A self reference. + */ + setParameters(parameters: any): webdriver.Command; + + /** + * Returns a named command parameter. + * @param {string} key The parameter key to look up. + * @return {*} The parameter value, or undefined if it has not been set. + */ + getParameter(key: string): any; + + /** + * @return {!Object.<*>} The parameters to send with this command. + */ + getParameters(): any; + + //endregion + } + + /** + * Handles the execution of {@code webdriver.Command} objects. + */ + interface CommandExecutor { + /** + * Executes the given {@code command}. If there is an error executing the + * command, the provided callback will be invoked with the offending error. + * Otherwise, the callback will be invoked with a null Error and non-null + * {@link bot.response.ResponseObject} object. + * @param {!webdriver.Command} command The command to execute. + * @param {function(Error, !bot.response.ResponseObject=)} callback the function + * to invoke when the command response is ready. + */ + execute(command: webdriver.Command, callback: (error: Error, responseObject: any) => any ): void; + } + + /** + * Object that can emit events for others to listen for. This is used instead + * of Closure's event system because it is much more light weight. The API is + * based on Node's EventEmitters. + */ + class EventEmitter { + //region Constructors + + /** + * @constructor + */ + constructor(); + + //endregion + + //region Methods + + /** + * Fires an event and calls all listeners. + * @param {string} type The type of event to emit. + * @param {...*} var_args Any arguments to pass to each listener. + */ + emit(type: string, ...var_args: any[]): void; + + /** + * Returns a mutable list of listeners for a specific type of event. + * @param {string} type The type of event to retrieve the listeners for. + * @return {!Array.<{fn: !Function, oneshot: boolean, + * scope: (Object|undefined)}>} The registered listeners for + * the given event type. + */ + listeners(type: string): Array<{fn: any; oneshot: boolean; scope: any;}>; + + /** + * Registers a listener. + * @param {string} type The type of event to listen for. + * @param {!Function} listenerFn The function to invoke when the event is fired. + * @param {Object=} opt_scope The object in whose scope to invoke the listener. + * @return {!webdriver.EventEmitter} A self reference. + */ + addListener(type: string, listenerFn: any, opt_scope?:any): EventEmitter; + + /** + * Registers a one-time listener which will be called only the first time an + * event is emitted, after which it will be removed. + * @param {string} type The type of event to listen for. + * @param {!Function} listenerFn The function to invoke when the event is fired. + * @param {Object=} opt_scope The object in whose scope to invoke the listener. + * @return {!webdriver.EventEmitter} A self reference. + */ + once(type: string, listenerFn: any, opt_scope?: any): EventEmitter; + + /** + * An alias for {@code #addListener()}. + * @param {string} type The type of event to listen for. + * @param {!Function} listenerFn The function to invoke when the event is fired. + * @param {Object=} opt_scope The object in whose scope to invoke the listener. + * @return {!webdriver.EventEmitter} A self reference. + */ + on(type: string, listenerFn: any, opt_scope?:any): EventEmitter; + + /** + * Removes a previously registered event listener. + * @param {string} type The type of event to unregister. + * @param {!Function} listenerFn The handler function to remove. + * @return {!webdriver.EventEmitter} A self reference. + */ + removeListener(type: string, listenerFn: any): EventEmitter; + + /** + * Removes all listeners for a specific type of event. If no event is + * specified, all listeners across all types will be removed. + * @param {string=} opt_type The type of event to remove listeners from. + * @return {!webdriver.EventEmitter} A self reference. + */ + removeAllListeners(opt_type?: string): EventEmitter; + + //endregion + } + + /** + * @implements {webdriver.CommandExecutor} + */ + class FirefoxDomExecutor implements webdriver.CommandExecutor { + //region Constructors + + /** + * @constructor + */ + constructor(); + + //endregion + + //region Static Methods + + /** + * @return {boolean} Whether the current environment supports the + * FirefoxDomExecutor. + */ + static isAvailable(): boolean; + + //endretion + + //region Methods + + /** @override */ + execute(command: webdriver.Command, callback: (error: Error, responseObject: any) => any ): void; + + //endregion + } + + /** + * Interface for navigating back and forth in the browser history. + */ + class WebDriverNavigation { + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The parent driver. + * @constructor + */ + constructor(driver: webdriver.WebDriver); + + //endregion + + //region Methods + + /** + * Schedules a command to navigate to a new URL. + * @param {string} url The URL to navigate to. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * URL has been loaded. + */ + to(url: string): webdriver.promise.Promise; + + /** + * Schedules a command to move backwards in the browser history. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * navigation event has completed. + */ + back(): webdriver.promise.Promise; + + /** + * Schedules a command to move forwards in the browser history. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * navigation event has completed. + */ + forward(): webdriver.promise.Promise; + + /** + * Schedules a command to refresh the current page. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * navigation event has completed. + */ + refresh(): webdriver.promise.Promise; + + //endregion + } + + /** + * Provides methods for managing browser and driver state. + */ + class WebDriverOptions { + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The parent driver. + * @constructor + */ + constructor(driver: webdriver.WebDriver); + + //endregion + + //region Methods + + /** + * Schedules a command to add a cookie. + * @param {string} name The cookie name. + * @param {string} value The cookie value. + * @param {string=} opt_path The cookie path. + * @param {string=} opt_domain The cookie domain. + * @param {boolean=} opt_isSecure Whether the cookie is secure. + * @param {(number|!Date)=} opt_expiry When the cookie expires. If specified as + * a number, should be in milliseconds since midnight, January 1, 1970 UTC. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * cookie has been added to the page. + */ + addCookie(name: string, value: string, opt_path?: string, opt_domain?: string, opt_isSecure?: boolean, opt_expiry?: number): webdriver.promise.Promise; + addCookie(name: string, value: string, opt_path?: string, opt_domain?: string, opt_isSecure?: boolean, opt_expiry?: Date): webdriver.promise.Promise; + + /** + * Schedules a command to delete all cookies visible to the current page. + * @return {!webdriver.promise.Promise} A promise that will be resolved when all + * cookies have been deleted. + */ + deleteAllCookies(): webdriver.promise.Promise; + + /** + * Schedules a command to delete the cookie with the given name. This command is + * a no-op if there is no cookie with the given name visible to the current + * page. + * @param {string} name The name of the cookie to delete. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * cookie has been deleted. + */ + deleteCookie(name: string): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve all cookies visible to the current page. + * Each cookie will be returned as a JSON object as described by the WebDriver + * wire protocol. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * cookies visible to the current page. + * @see http://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object + */ + getCookies(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the cookie with the given name. Returns null + * if there is no such cookie. The cookie will be returned as a JSON object as + * described by the WebDriver wire protocol. + * @param {string} name The name of the cookie to retrieve. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * named cookie, or {@code null} if there is no such cookie. + * @see http://code.google.com/p/selenium/wiki/JsonWireProtocol#Cookie_JSON_Object + */ + getCookie(name: string): webdriver.promise.Promise; + + /** + * @return {!webdriver.WebDriver.Logs} The interface for managing driver + * logs. + */ + logs(): webdriver.WebDriverLogs; + + /** + * @return {!webdriver.WebDriver.Timeouts} The interface for managing driver + * timeouts. + */ + timeouts(): webdriver.WebDriverTimeouts; + + /** + * @return {!webdriver.WebDriver.Window} The interface for managing the + * current window. + */ + window(): webdriver.WebDriverWindow; + + //endregion + } + + /** + * An interface for managing timeout behavior for WebDriver instances. + */ + class WebDriverTimeouts { + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The parent driver. + * @constructor + */ + constructor(driver: webdriver.WebDriver); + + //endregion + + //region Methods + + /** + * Specifies the amount of time the driver should wait when searching for an + * element if it is not immediately present. + *

+ * When searching for a single element, the driver should poll the page + * until the element has been found, or this timeout expires before failing + * with a {@code bot.ErrorCode.NO_SUCH_ELEMENT} error. When searching + * for multiple elements, the driver should poll the page until at least one + * element has been found or this timeout has expired. + *

+ * Setting the wait timeout to 0 (its default value), disables implicit + * waiting. + *

+ * Increasing the implicit wait timeout should be used judiciously as it + * will have an adverse effect on test run time, especially when used with + * slower location strategies like XPath. + * + * @param {number} ms The amount of time to wait, in milliseconds. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * implicit wait timeout has been set. + */ + implicitlyWait(ms: number): webdriver.promise.Promise; + + /** + * Sets the amount of time to wait, in milliseconds, for an asynchronous script + * to finish execution before returning an error. If the timeout is less than or + * equal to 0, the script will be allowed to run indefinitely. + * + * @param {number} ms The amount of time to wait, in milliseconds. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * script timeout has been set. + */ + setScriptTimeout(ms: number): webdriver.promise.Promise; + + /** + * Sets the amount of time to wait for a page load to complete before returning + * an error. If the timeout is negative, page loads may be indefinite. + * @param {number} ms The amount of time to wait, in milliseconds. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the timeout has been set. + */ + pageLoadTimeout(ms: number): webdriver.promise.Promise; + + //endregion + } + + /** + * An interface for managing the current window. + */ + class WebDriverWindow { + + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The parent driver. + * @constructor + */ + constructor(driver: webdriver.WebDriver); + + //endregion + + //region Methods + + /** + * Retrieves the window's current position, relative to the top left corner of + * the screen. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * window's position in the form of a {x:number, y:number} object literal. + */ + getPosition(): webdriver.promise.Promise; + + /** + * Repositions the current window. + * @param {number} x The desired horizontal position, relative to the left side + * of the screen. + * @param {number} y The desired vertical position, relative to the top of the + * of the screen. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * command has completed. + */ + setPosition(x: number, y: number): webdriver.promise.Promise; + + /** + * Retrieves the window's current size. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * window's size in the form of a {width:number, height:number} object + * literal. + */ + getSize(): webdriver.promise.Promise; + + /** + * Resizes the current window. + * @param {number} width The desired window width. + * @param {number} height The desired window height. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * command has completed. + */ + setSize(width: number, height: number): webdriver.promise.Promise; + + /** + * Maximizes the current window. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * command has completed. + */ + maximize(): webdriver.promise.Promise; + + //endregion + } + + /** + * Interface for managing WebDriver log records. + */ + class WebDriverLogs { + + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The parent driver. + * @constructor + */ + constructor(driver: webdriver.WebDriver); + + //endregion + + //region + + /** + * Fetches available log entries for the given type. + * + *

Note that log buffers are reset after each call, meaning that + * available log entries correspond to those entries not yet returned for a + * given log type. In practice, this means that this call will return the + * available log entries since the last call, or from the start of the + * session. + * + * @param {!webdriver.logging.Type} type The desired log type. + * @return {!webdriver.promise.Promise.>} A + * promise that will resolve to a list of log entries for the specified + * type. + */ + get(type: string): webdriver.promise.Promise; + + /** + * Retrieves the log types available to this driver. + * @return {!webdriver.promise.Promise.>} A + * promise that will resolve to a list of available log types. + */ + getAvailableLogTypes(): webdriver.promise.Promise; + + //endregion + } + + /** + * An interface for changing the focus of the driver to another frame or window. + */ + class WebDriverTargetLocator { + + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The parent driver. + * @constructor + */ + constructor(driver: webdriver.WebDriver); + + //endregion + + //region Methods + + /** + * Schedules a command retrieve the {@code document.activeElement} element on + * the current document, or {@code document.body} if activeElement is not + * available. + * @return {!webdriver.WebElement} The active element. + */ + activeElement(): webdriver.WebElement; + + /** + * Schedules a command to switch focus of all future commands to the first frame + * on the page. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * driver has changed focus to the default content. + */ + defaultContent(): webdriver.promise.Promise; + + /** + * Schedules a command to switch the focus of all future commands to another + * frame on the page. + *

+ * If the frame is specified by a number, the command will switch to the frame + * by its (zero-based) index into the {@code window.frames} collection. + *

+ * If the frame is specified by a string, the command will select the frame by + * its name or ID. To select sub-frames, simply separate the frame names/IDs by + * dots. As an example, "main.child" will select the frame with the name "main" + * and then its child "child". + *

+ * If the specified frame can not be found, the deferred result will errback + * with a {@code bot.ErrorCode.NO_SUCH_FRAME} error. + * @param {string|number} nameOrIndex The frame locator. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * driver has changed focus to the specified frame. + */ + frame(nameOrIndex: string): webdriver.promise.Promise; + frame(nameOrIndex: number): webdriver.promise.Promise; + + /** + * Schedules a command to switch the focus of all future commands to another + * window. Windows may be specified by their {@code window.name} attribute or + * by its handle (as returned by {@code webdriver.WebDriver#getWindowHandles}). + *

+ * If the specificed window can not be found, the deferred result will errback + * with a {@code bot.ErrorCode.NO_SUCH_WINDOW} error. + * @param {string} nameOrHandle The name or window handle of the window to + * switch focus to. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * driver has changed focus to the specified window. + */ + window(nameOrHandle: string): webdriver.promise.Promise; + + /** + * Schedules a command to change focus to the active alert dialog. This command + * will return a {@link bot.ErrorCode.NO_MODAL_DIALOG_OPEN} error if a modal + * dialog is not currently open. + * @return {!webdriver.Alert} The open alert. + */ + alert(): webdriver.Alert; + + //endregion + } + + /** + * Creates a new WebDriver client, which provides control over a browser. + * + * Every WebDriver command returns a {@code webdriver.promise.Promise} that + * represents the result of that command. Callbacks may be registered on this + * object to manipulate the command result or catch an expected error. Any + * commands scheduled with a callback are considered sub-commands and will + * execute before the next command in the current frame. For example: + * + * var message = []; + * driver.call(message.push, message, 'a').then(function() { + * driver.call(message.push, message, 'b'); + * }); + * driver.call(message.push, message, 'c'); + * driver.call(function() { + * alert('message is abc? ' + (message.join('') == 'abc')); + * }); + * + */ + class WebDriver { + //region Constructors + + /** + * @param {!(webdriver.Session|webdriver.promise.Promise)} session Either a + * known session or a promise that will be resolved to a session. + * @param {!webdriver.CommandExecutor} executor The executor to use when + * sending commands to the browser. + * @param {webdriver.promise.ControlFlow=} opt_flow The flow to + * schedule commands through. Defaults to the active flow object. + * @constructor + */ + constructor(session: webdriver.Session, executor: webdriver.CommandExecutor, opt_flow?: webdriver.promise.ControlFlow); + constructor(session: webdriver.promise.Promise, executor: webdriver.CommandExecutor, opt_flow?: webdriver.promise.ControlFlow); + + //endregion + + //region Static Properties + + static Navigation: WebDriverNavigation; + static Options: WebDriverOptions; + static Timeouts: WebDriverTimeouts; + static Window: WebDriverWindow; + static Logs: WebDriverLogs; + static TargetLocator: WebDriverTargetLocator; + + //endregion + + //region StaticMethods + + /** + * Creates a new WebDriver client for an existing session. + * @param {!webdriver.CommandExecutor} executor Command executor to use when + * querying for session details. + * @param {string} sessionId ID of the session to attach to. + * @return {!webdriver.WebDriver} A new client for the specified session. + */ + static attachToSession(executor: webdriver.CommandExecutor, sessionId: string): WebDriver; + + /** + * Creates a new WebDriver session. + * @param {!webdriver.CommandExecutor} executor The executor to create the new + * session with. + * @param {!webdriver.Capabilities} desiredCapabilities The desired + * capabilities for the new session. + * @return {!webdriver.WebDriver} The driver for the newly created session. + */ + static createSession(executor: webdriver.CommandExecutor, desiredCapabilities: webdriver.Capabilities): WebDriver; + + //endregion + + //region Methods + + /** + * @return {!webdriver.promise.ControlFlow} The control flow used by this + * instance. + */ + controlFlow(): webdriver.promise.ControlFlow; + + /** + * Schedules a {@code webdriver.Command} to be executed by this driver's + * {@code webdriver.CommandExecutor}. + * @param {!webdriver.Command} command The command to schedule. + * @param {string} description A description of the command for debugging. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * the command result. + */ + schedule(command: webdriver.Command, description: string): webdriver.promise.Promise; + + /** + * @return {!webdriver.promise.Promise} A promise for this client's session. + */ + getSession(): webdriver.promise.Promise; + + /** + * @return {!webdriver.promise.Promise} A promise that will resolve with the + * this instance's capabilities. + */ + getCapabilities(): webdriver.promise.Promise; + + /** + * Schedules a command to quit the current session. After calling quit, this + * instance will be invalidated and may no longer be used to issue commands + * against the browser. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the command has completed. + */ + quit(): webdriver.promise.Promise; + + /** + * Creates a new action sequence using this driver. The sequence will not be + * scheduled for execution until {@link webdriver.ActionSequence#perform} is + * called. Example: + *


+         *   driver.actions().
+         *       mouseDown(element1).
+         *       mouseMove(element2).
+         *       mouseUp().
+         *       perform();
+         * 
+ * @return {!webdriver.ActionSequence} A new action sequence for this instance. + */ + actions(): webdriver.ActionSequence; + + /** + * Schedules a command to execute JavaScript in the context of the currently + * selected frame or window. The script fragment will be executed as the body + * of an anonymous function. If the script is provided as a function object, + * that function will be converted to a string for injection into the target + * window. + * + * Any arguments provided in addition to the script will be included as script + * arguments and may be referenced using the {@code arguments} object. + * Arguments may be a boolean, number, string, or {@code webdriver.WebElement}. + * Arrays and objects may also be used as script arguments as long as each item + * adheres to the types previously mentioned. + * + * The script may refer to any variables accessible from the current window. + * Furthermore, the script will execute in the window's context, thus + * {@code document} may be used to refer to the current document. Any local + * variables will not be available once the script has finished executing, + * though global variables will persist. + * + * If the script has a return value (i.e. if the script contains a return + * statement), then the following steps will be taken for resolving this + * functions return value: + *
    + *
  • For a HTML element, the value will resolve to a + * {@code webdriver.WebElement}
  • + *
  • Null and undefined return values will resolve to null
  • + *
  • Booleans, numbers, and strings will resolve as is
  • + *
  • Functions will resolve to their string representation
  • + *
  • For arrays and objects, each member item will be converted according to + * the rules above
  • + *
+ * + * @param {!(string|Function)} script The script to execute. + * @param {...*} var_args The arguments to pass to the script. + * @return {!webdriver.promise.Promise} A promise that will resolve to the + * scripts return value. + */ + executeScript(script: string, ...var_args: any[]): webdriver.promise.Promise; + executeScript(script: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedules a command to execute asynchronous JavaScript in the context of the + * currently selected frame or window. The script fragment will be executed as + * the body of an anonymous function. If the script is provided as a function + * object, that function will be converted to a string for injection into the + * target window. + * + * Any arguments provided in addition to the script will be included as script + * arguments and may be referenced using the {@code arguments} object. + * Arguments may be a boolean, number, string, or {@code webdriver.WebElement}. + * Arrays and objects may also be used as script arguments as long as each item + * adheres to the types previously mentioned. + * + * Unlike executing synchronous JavaScript with + * {@code webdriver.WebDriver.prototype.executeScript}, scripts executed with + * this function must explicitly signal they are finished by invoking the + * provided callback. This callback will always be injected into the + * executed function as the last argument, and thus may be referenced with + * {@code arguments[arguments.length - 1]}. The following steps will be taken + * for resolving this functions return value against the first argument to the + * script's callback function: + *
    + *
  • For a HTML element, the value will resolve to a + * {@code webdriver.WebElement}
  • + *
  • Null and undefined return values will resolve to null
  • + *
  • Booleans, numbers, and strings will resolve as is
  • + *
  • Functions will resolve to their string representation
  • + *
  • For arrays and objects, each member item will be converted according to + * the rules above
  • + *
+ * + * Example #1: Performing a sleep that is synchronized with the currently + * selected window: + *
+         * var start = new Date().getTime();
+         * driver.executeAsyncScript(
+         *     'window.setTimeout(arguments[arguments.length - 1], 500);').
+         *     then(function() {
+         *       console.log('Elapsed time: ' + (new Date().getTime() - start) + ' ms');
+         *     });
+         * 
+ * + * Example #2: Synchronizing a test with an AJAX application: + *
+         * var button = driver.findElement(By.id('compose-button'));
+         * button.click();
+         * driver.executeAsyncScript(
+         *     'var callback = arguments[arguments.length - 1];' +
+         *     'mailClient.getComposeWindowWidget().onload(callback);');
+         * driver.switchTo().frame('composeWidget');
+         * driver.findElement(By.id('to')).sendKEys('dog@example.com');
+         * 
+ * + * Example #3: Injecting a XMLHttpRequest and waiting for the result. In this + * example, the inject script is specified with a function literal. When using + * this format, the function is converted to a string for injection, so it + * should not reference any symbols not defined in the scope of the page under + * test. + *
+         * driver.executeAsyncScript(function() {
+         *   var callback = arguments[arguments.length - 1];
+         *   var xhr = new XMLHttpRequest();
+         *   xhr.open("GET", "/resource/data.json", true);
+         *   xhr.onreadystatechange = function() {
+         *     if (xhr.readyState == 4) {
+         *       callback(xhr.resposneText);
+         *     }
+         *   }
+         *   xhr.send('');
+         * }).then(function(str) {
+         *   console.log(JSON.parse(str)['food']);
+         * });
+         * 
+ * + * @param {!(string|Function)} script The script to execute. + * @param {...*} var_args The arguments to pass to the script. + * @return {!webdriver.promise.Promise} A promise that will resolve to the + * scripts return value. + */ + executeAsyncScript(script: string, ...var_args: any[]): webdriver.promise.Promise; + executeAsyncScript(script: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedules a command to execute a custom function. + * @param {!Function} fn The function to execute. + * @param {Object=} opt_scope The object in whose scope to execute the function. + * @param {...*} var_args Any arguments to pass to the function. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * function's result. + */ + call(fn: any, opt_scope?: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedules a command to wait for a condition to hold, as defined by some + * user supplied function. If any errors occur while evaluating the wait, they + * will be allowed to propagate. + * @param {function():boolean|!webdriver.promise.Promise} fn The function to + * evaluate as a wait condition. + * @param {number} timeout How long to wait for the condition to be true. + * @param {string=} opt_message An optional message to use if the wait times + * out. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * wait condition has been satisfied. + */ + wait(fn: () => any, timeout: number, opt_message?: string): webdriver.promise.Promise; + + /** + * Schedules a command to make the driver sleep for the given amount of time. + * @param {number} ms The amount of time, in milliseconds, to sleep. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * sleep has finished. + */ + sleep(ms: number): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve they current window handle. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * current window handle. + */ + getWindowHandle(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the current list of available window handles. + * @return {!webdriver.promise.Promise} A promise that will be resolved with an + * array of window handles. + */ + getAllWindowHandles(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the current page's source. The page source + * returned is a representation of the underlying DOM: do not expect it to be + * formatted or escaped in the same way as the response sent from the web + * server. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * current page source. + */ + getPageSource(): webdriver.promise.Promise; + + /** + * Schedules a command to close the current window. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * this command has completed. + */ + close(): webdriver.promise.Promise; + + /** + * Schedules a command to navigate to the given URL. + * @param {string} url The fully qualified URL to open. + * @return {!webdriver.promise.Promise} A promise that will be resolved when the + * document has finished loading. + */ + get(url: string): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the URL of the current page. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * current URL. + */ + getCurrentUrl(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the current page's title. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * current page's title. + */ + getTitle(): webdriver.promise.Promise; + + /** + * Schedule a command to find an element on the page. If the element cannot be + * found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned + * by the driver. Unlike other commands, this error cannot be suppressed. In + * other words, scheduling a command to find an element doubles as an assert + * that the element is present on the page. To test whether an element is + * present on the page, use {@code #isElementPresent} instead. + * + *

The search criteria for find an element may either be a + * {@code webdriver.Locator} object, or a simple JSON object whose sole key + * is one of the accepted locator strategies, as defined by + * {@code webdriver.Locator.Strategy}. For example, the following two statements + * are equivalent: + *

+         * var e1 = driver.findElement(By.id('foo'));
+         * var e2 = driver.findElement({id:'foo'});
+         * 
+ * + *

When running in the browser, a WebDriver cannot manipulate DOM elements + * directly; it may do so only through a {@link webdriver.WebElement} reference. + * This function may be used to generate a WebElement from a DOM element. A + * reference to the DOM element will be stored in a known location and this + * driver will attempt to retrieve it through {@link #executeScript}. If the + * element cannot be found (eg, it belongs to a different document than the + * one this instance is currently focused on), a + * {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned. + * + * @param {!(webdriver.Locator|Object.|Element)} locatorOrElement The + * locator strategy to use when searching for the element, or the actual + * DOM element to be located by the server. + * @param {...} var_args Arguments to pass to {@code #executeScript} if using a + * JavaScript locator. Otherwise ignored. + * @return {!webdriver.WebElement} A WebElement that can be used to issue + * commands against the located element. If the element is not found, the + * element will be invalidated and all scheduled commands aborted. + */ + findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): webdriver.WebElement; + findElement(locatorOrElement: any, ...var_args: any[]): webdriver.WebElement; + + /** + * Schedules a command to test if an element is present on the page. + * + *

If given a DOM element, this function will check if it belongs to the + * document the driver is currently focused on. Otherwise, the function will + * test if at least one element can be found with the given search criteria. + * + * @param {!(webdriver.Locator|Object.|Element)} locatorOrElement The + * locator strategy to use when searching for the element, or the actual + * DOM element to be located by the server. + * @param {...} var_args Arguments to pass to {@code #executeScript} if using a + * JavaScript locator. Otherwise ignored. + * @return {!webdriver.promise.Promise} A promise that will resolve to whether + * the element is present on the page. + */ + isElementPresent(locatorOrElement: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise; + isElementPresent(locatorOrElement: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedule a command to search for multiple elements on the page. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the element. + * @param {...} var_args Arguments to pass to {@code #executeScript} if using a + * JavaScript locator. Otherwise ignored. + * @return {!webdriver.promise.Promise} A promise that will be resolved to an + * array of the located {@link webdriver.WebElement}s. + */ + findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise; + findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedule a command to take a screenshot. The driver makes a best effort to + * return a screenshot of the following, in order of preference: + *

    + *
  1. Entire page + *
  2. Current window + *
  3. Visible portion of the current frame + *
  4. The screenshot of the entire display containing the browser + *
+ * + * @return {!webdriver.promise.Promise} A promise that will be resolved to the + * screenshot as a base-64 encoded PNG. + */ + takeScreenshot(): webdriver.promise.Promise; + + /** + * @return {!webdriver.WebDriver.Options} The options interface for this + * instance. + */ + manage(): webdriver.WebDriverOptions; + + /** + * @return {!webdriver.WebDriver.Navigation} The navigation interface for this + * instance. + */ + navigate(): webdriver.WebDriverNavigation; + + /** + * @return {!webdriver.WebDriver.TargetLocator} The target locator interface for + * this instance. + */ + switchTo(): webdriver.WebDriverTargetLocator + + //endregion + } + + /** + * Represents a DOM element. WebElements can be found by searching from the + * document root using a {@code webdriver.WebDriver} instance, or by searching + * under another {@code webdriver.WebElement}: + * + * driver.get('http://www.google.com'); + * var searchForm = driver.findElement(By.tagName('form')); + * var searchBox = searchForm.findElement(By.name('q')); + * searchBox.sendKeys('webdriver'); + * + * The WebElement is implemented as a promise for compatibility with the promise + * API. It will always resolve itself when its internal state has been fully + * resolved and commands may be issued against the element. This can be used to + * catch errors when an element cannot be located on the page: + * + * driver.findElement(By.id('not-there')).then(function(element) { + * alert('Found an element that was not expected to be there!'); + * }, function(error) { + * alert('The element was not found, as expected'); + * }); + * + * @extends {webdriver.promise.Deferred} + */ + class WebElement extends webdriver.promise.Deferred { + //region Constructors + + /** + * @param {!webdriver.WebDriver} driver The parent WebDriver instance for this + * element. + * @param {!(string|webdriver.promise.Promise)} id Either the opaque ID for the + * underlying DOM element assigned by the server, or a promise that will + * resolve to that ID or another WebElement. + * @constructor + */ + constructor(driver: webdriver.WebDriver, id: webdriver.promise.Promise); + constructor(driver: webdriver.WebDriver, id: string); + + //endregion + + //region Static Properties + + /** + * The property key used in the wire protocol to indicate that a JSON object + * contains the ID of a WebElement. + * @type {string} + * @const + */ + static ELEMENT_KEY: string; + + //endregion + + //region Methods + + /** + * @return {!webdriver.WebDriver} The parent driver for this instance. + */ + getDriver(): webdriver.WebDriver; + + /** + * @return {!webdriver.promise.Promise} A promise that resolves to this + * element's JSON representation as defined by the WebDriver wire protocol. + * @see http://code.google.com/p/selenium/wiki/JsonWireProtocol + */ + toWireValue(): webdriver.promise.Promise; + + /** + * Schedule a command to find a descendant of this element. If the element + * cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will + * be returned by the driver. Unlike other commands, this error cannot be + * suppressed. In other words, scheduling a command to find an element doubles + * as an assert that the element is present on the page. To test whether an + * element is present on the page, use {@code #isElementPresent} instead. + *

+ * The search criteria for find an element may either be a + * {@code webdriver.Locator} object, or a simple JSON object whose sole key + * is one of the accepted locator strategies, as defined by + * {@code webdriver.Locator.Strategy}. For example, the following two + * statements are equivalent: + *

+         * var e1 = element.findElement(By.id('foo'));
+         * var e2 = element.findElement({id:'foo'});
+         * 
+ *

+ * Note that JS locator searches cannot be restricted to a subtree. All such + * searches are delegated to this instance's parent WebDriver. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the element. + * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if + * using a JavaScript locator. Otherwise ignored. + * @return {webdriver.WebElement} A WebElement that can be used to issue + * commands against the located element. If the element is not found, the + * element will be invalidated and all scheduled commands aborted. + */ + findElement(locator: webdriver.Locator, ...var_args: any[]): WebElement; + findElement(locator: any, ...var_args: any[]): WebElement; + + /** + * Schedules a command to test if there is at least one descendant of this + * element that matches the given search criteria. + * + *

Note that JS locator searches cannot be restricted to a subtree of the + * DOM. All such searches are delegated to this instance's parent WebDriver. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the element. + * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if + * using a JavaScript locator. Otherwise ignored. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether an element could be located on the page. + */ + isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise; + isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedules a command to find all of the descendants of this element that match + * the given search criteria. + *

+ * Note that JS locator searches cannot be restricted to a subtree. All such + * searches are delegated to this instance's parent WebDriver. + * + * @param {webdriver.Locator|Object.} locator The locator + * strategy to use when searching for the elements. + * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if + * using a JavaScript locator. Otherwise ignored. + * @return {!webdriver.promise.Promise} A promise that will be resolved with an + * array of located {@link webdriver.WebElement}s. + */ + findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise; + findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise; + + /** + * Schedules a command to click on this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the click command has completed. + */ + click(): webdriver.promise.Promise; + + /** + * Schedules a command to type a sequence on the DOM element represented by this + * instance. + *

+ * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is + * processed in the keysequence, that key state is toggled until one of the + * following occurs: + *

    + *
  • The modifier key is encountered again in the sequence. At this point the + * state of the key is toggled (along with the appropriate keyup/down events). + *
  • + *
  • The {@code webdriver.Key.NULL} key is encountered in the sequence. When + * this key is encountered, all modifier keys current in the down state are + * released (with accompanying keyup events). The NULL key can be used to + * simulate common keyboard shortcuts: + * + * element.sendKeys("text was", + * webdriver.Key.CONTROL, "a", webdriver.Key.NULL, + * "now text is"); + * // Alternatively: + * element.sendKeys("text was", + * webdriver.Key.chord(webdriver.Key.CONTROL, "a"), + * "now text is"); + *
  • + *
  • The end of the keysequence is encountered. When there are no more keys + * to type, all depressed modifier keys are released (with accompanying keyup + * events). + *
  • + *
+ * Note: On browsers where native keyboard events are not yet + * supported (e.g. Firefox on OS X), key events will be synthesized. Special + * punctionation keys will be synthesized according to a standard QWERTY en-us + * keyboard layout. + * + * @param {...string} var_args The sequence of keys to + * type. All arguments will be joined into a single sequence (var_args is + * permitted for convenience). + * @return {!webdriver.promise.Promise} A promise that will be resolved when all + * keys have been typed. + */ + sendKeys(...var_args: string[]): webdriver.promise.Promise; + + /** + * Schedules a command to query for the tag/node name of this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's tag name. + */ + getTagName(): webdriver.promise.Promise; + + /** + * Schedules a command to query for the computed style of the element + * represented by this instance. If the element inherits the named style from + * its parent, the parent will be queried for its value. Where possible, color + * values will be converted to their hex representation (e.g. #00ff00 instead of + * rgb(0, 255, 0)). + *

+ * Warning: the value returned will be as the browser interprets it, so + * it may be tricky to form a proper assertion. + * + * @param {string} cssStyleProperty The name of the CSS style property to look + * up. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * requested CSS value. + */ + getCssValue(cssStyleProperty: string): webdriver.promise.Promise; + + /** + * Schedules a command to query for the value of the given attribute of the + * element. Will return the current value even if it has been modified after the + * page has been loaded. More exactly, this method will return the value of the + * given attribute, unless that attribute is not present, in which case the + * value of the property with the same name is returned. If neither value is + * set, null is returned. The "style" attribute is converted as best can be to a + * text representation with a trailing semi-colon. The following are deemed to + * be "boolean" attributes and will be returned as thus: + * + *

async, autofocus, autoplay, checked, compact, complete, controls, declare, + * defaultchecked, defaultselected, defer, disabled, draggable, ended, + * formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, + * loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, + * paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, + * selected, spellcheck, truespeed, willvalidate + * + *

Finally, the following commonly mis-capitalized attribute/property names + * are evaluated as expected: + *

    + *
  • "class" + *
  • "readonly" + *
+ * @param {string} attributeName The name of the attribute to query. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * attribute's value. + */ + getAttribute(attributeName: string): webdriver.promise.Promise; + + /** + * Get the visible (i.e. not hidden by CSS) innerText of this element, including + * sub-elements, without any leading or trailing whitespace. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's visible text. + */ + getText(): webdriver.promise.Promise; + + /** + * Schedules a command to compute the size of this element's bounding box, in + * pixels. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's size as a {@code {width:number, height:number}} object. + */ + getSize(): webdriver.promise.Promise; + + /** + * Schedules a command to compute the location of this element in page space. + * @return {!webdriver.promise.Promise} A promise that will be resolved to the + * element's location as a {@code {x:number, y:number}} object. + */ + getLocation(): webdriver.promise.Promise; + + /** + * Schedules a command to query whether the DOM element represented by this + * instance is enabled, as dicted by the {@code disabled} attribute. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether this element is currently enabled. + */ + isEnabled(): webdriver.promise.Promise; + + /** + * Schedules a command to query whether this element is selected. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether this element is currently selected. + */ + isSelected(): webdriver.promise.Promise; + + /** + * Schedules a command to submit the form containing this element (or this + * element if it is a FORM element). This command is a no-op if the element is + * not contained in a form. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the form has been submitted. + */ + submit(): webdriver.promise.Promise; + + /** + * Schedules a command to clear the {@code value} of this element. This command + * has no effect if the underlying DOM element is neither a text INPUT element + * nor a TEXTAREA element. + * @return {!webdriver.promise.Promise} A promise that will be resolved when + * the element has been cleared. + */ + clear(): webdriver.promise.Promise; + + /** + * Schedules a command to test whether this element is currently displayed. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * whether this element is currently visible on the page. + */ + isDisplayed(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the outer HTML of this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved with + * the element's outer HTML. + */ + getOuterHtml(): webdriver.promise.Promise; + + /** + * Schedules a command to retrieve the inner HTML of this element. + * @return {!webdriver.promise.Promise} A promise that will be resolved with the + * element's inner HTML. + */ + getInnerHtml(): webdriver.promise.Promise; + + //endregion + + //region Static Methods + + /** + * Compares to WebElements for equality. + * @param {!webdriver.WebElement} a A WebElement. + * @param {!webdriver.WebElement} b A WebElement. + * @return {!webdriver.promise.Promise} A promise that will be resolved to + * whether the two WebElements are equal. + */ + static equals(a: WebElement, b: WebElement): webdriver.promise.Promise; + + //endregion + } + + interface ILocatorStrategy { + className(value: string): Locator; + 'class name'(value: string): Locator; + css(value: string): Locator; + id(value: string): Locator; + js(value: string): Locator; + linkText(value: string): Locator; + 'link text'(value: string): Locator; + name(value: string): Locator; + partialLinkText(value: string): Locator; + 'partial link text'(value: string): Locator; + tagName(value: string): Locator; + 'tag name'(value: string): Locator; + xpath(value: string): Locator; + } + + var By: ILocatorStrategy; + + /** + * An element locator. + */ + class Locator { + + //region Constructors + + /** + * An element locator. + * @param {string} using The type of strategy to use for this locator. + * @param {string} value The search target of this locator. + * @constructor + */ + constructor(using: string, value: string); + + //endregion + + //region Properties + + /** + * The search strategy to use when searching for an element. + * @type {string} + */ + using: string; + + /** + * The search target for this locator. + * @type {string} + */ + value: string; + + //endregion + + //region Static Properties + + /** + * Factory methods for the supported locator strategies. + * @type {Object.} + */ + static Strategy: ILocatorStrategy; + + //endregion + + //region Methods + + /** @return {string} String representation of this locator. */ + toString(): string; + + //endregion + + //region Static Methods + + /** + * Creates a new Locator from an object whose only property is also a key in + * the {@code webdriver.Locator.Strategy} map. + * @param {Object.} obj The object to convert into a locator. + * @return {webdriver.Locator} The new locator object. + */ + static createFromObj(obj: any): Locator + + /** + * Verifies that a {@code locator} is a valid locator to use for searching for + * elements on the page. + * @param {webdriver.Locator|Object.} locator The locator + * to verify, or a short-hand object that can be converted into a locator + * to verify. + * @return {!webdriver.Locator} The validated locator. + */ + static checkLocator(locator: Locator): Locator; + static checkLocator(obj: any): Locator; + + //endregion + } + + /** + * Contains information about a WebDriver session. + */ + class Session { + + //region Constructors + + /** + * @param {string} id The session ID. + * @param {!(Object|webdriver.Capabilities)} capabilities The session + * capabilities. + * @constructor + */ + constructor(id: string, capabilities: webdriver.Capabilities); + constructor(id: string, capabilities: any); + + //endregion + + //region Methods + + /** + * @return {string} This session's ID. + */ + getId(): string; + + /** + * @return {!webdriver.Capabilities} This session's capabilities. + */ + getCapabilities(): webdriver.Capabilities; + + /** + * Retrieves the value of a specific capability. + * @param {string} key The capability to retrieve. + * @return {*} The capability value. + */ + getCapability(key: string): any; + + /** + * Returns the JSON representation of this object, which is just the string + * session ID. + * @return {string} The JSON representation of this Session. + */ + toJSON(): string; + + //endregion + } +} + +declare module 'selenium-webdriver' { + export = webdriver; +} \ No newline at end of file diff --git a/selenium-webdriver/selenium-webdriver.tests.ts b/selenium-webdriver/selenium-webdriver.tests.ts new file mode 100644 index 0000000000..26913f0dbd --- /dev/null +++ b/selenium-webdriver/selenium-webdriver.tests.ts @@ -0,0 +1,917 @@ +/// + +function TestAbstractBuilder() { + var builder: webdriver.AbstractBuilder = new webdriver.AbstractBuilder(); + var driver: webdriver.WebDriver = builder.build(); + var capabilities: webdriver.Capabilities = builder.getCapabilities(); + url = builder.getServerUrl(); + var otherBuilder: webdriver.AbstractBuilder = builder.usingServer(url); + otherBuilder = builder.withCapabilities(webdriver.Capabilities.android()); + var objCapabilities = {}; + objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.PHANTOM_JS; + otherBuilder = builder.withCapabilities(objCapabilities); + var url: string = webdriver.AbstractBuilder.DEFAULT_SERVER_URL; + var env: string = webdriver.AbstractBuilder.SERVER_URL_ENV; +} + +function TestBuilder() { + var builder: webdriver.Builder = new webdriver.Builder(); + var abstractBuilder: webdriver.AbstractBuilder = builder; + + var driver: webdriver.WebDriver = builder.build(); + var session: string = builder.getSession(); + abstractBuilder = builder.usingSession("ID"); + + var env: string = webdriver.Builder.SESSION_ID_ENV; +} + +function TestActionSequence() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var sequence: webdriver.ActionSequence = new webdriver.ActionSequence(driver); + var element: webdriver.WebElement = new webdriver.WebElement(driver, 'id'); + + // Click + sequence = sequence.click(); + sequence = sequence.click(webdriver.Button.LEFT); + sequence = sequence.click(element); + sequence = sequence.click(element, webdriver.Button.LEFT); + + // DoubleClick + sequence = sequence.doubleClick(); + sequence = sequence.doubleClick(webdriver.Button.LEFT); + sequence = sequence.doubleClick(element); + sequence = sequence.doubleClick(element, webdriver.Button.LEFT); + + // DragAndDrop + sequence = sequence.dragAndDrop(element, element); + sequence = sequence.dragAndDrop(element, {x: 1, y: 2}); + + // KeyDown + sequence = sequence.keyDown(webdriver.Key.ADD); + + // KeyUp + sequence = sequence.keyUp(webdriver.Key.ADD); + + // MouseDown + sequence = sequence.mouseDown(); + sequence = sequence.mouseDown(webdriver.Button.LEFT); + sequence = sequence.mouseDown(element); + sequence = sequence.mouseDown(element, webdriver.Button.LEFT); + + // MouseMove + sequence = sequence.mouseMove(element); + sequence = sequence.mouseMove({x: 1, y: 1}); + sequence = sequence.mouseMove(element, {x: 1, y: 2}); + + // MouseUp + sequence = sequence.mouseUp(); + sequence = sequence.mouseUp(webdriver.Button.LEFT); + sequence = sequence.mouseUp(element); + sequence = sequence.mouseUp(element, webdriver.Button.LEFT); + + // SendKeys + sequence = sequence.sendKeys("A", "B", "C"); + sequence = sequence.sendKeys(["A", "B", "C"]); + + var promise: webdriver.promise.Promise = sequence.perform(); +} + +function TestAlert() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + var promise: webdriver.promise.Promise = new webdriver.promise.Promise(); + + var alert: webdriver.Alert = new webdriver.Alert(driver, 'ABC'); + alert = new webdriver.Alert(driver, promise); + var deferred: webdriver.promise.Deferred = alert; + + promise = alert.accept(); + promise = alert.dismiss(); + promise = alert.getText(); + promise = alert.sendKeys("ABC"); +} + +function TestBrowser() { + var browser: string; + + browser = webdriver.Browser.ANDROID; + browser = webdriver.Browser.CHROME; + browser = webdriver.Browser.FIREFOX; + browser = webdriver.Browser.HTMLUNIT; + browser = webdriver.Browser.INTERNET_EXPLORER; + browser = webdriver.Browser.IPAD; + browser = webdriver.Browser.IPHONE; + browser = webdriver.Browser.OPERA; + browser = webdriver.Browser.PHANTOM_JS; + browser = webdriver.Browser.SAFARI; +} + +function TestButton() { + var button: number; + + button = webdriver.Button.LEFT; + button = webdriver.Button.MIDDLE; + button = webdriver.Button.RIGHT; +} + +function TestCapabilities() { + var capabilities: webdriver.Capabilities = new webdriver.Capabilities(); + capabilities = new webdriver.Capabilities(webdriver.Capabilities.chrome()); + var objCapabilities: any = {}; + objCapabilities[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.PHANTOM_JS; + capabilities = new webdriver.Capabilities(objCapabilities); + + var anything: any = capabilities.get(webdriver.Capability.SECURE_SSL); + var check: boolean = capabilities.has(webdriver.Capability.SECURE_SSL); + capabilities = capabilities.merge(capabilities); + capabilities = capabilities.merge(objCapabilities); + capabilities = capabilities.set(webdriver.Capability.VERSION, { abc: 'def' }); + capabilities = capabilities.set(webdriver.Capability.VERSION, null); + + anything = capabilities.toJSON(); + + capabilities = webdriver.Capabilities.android(); + capabilities = webdriver.Capabilities.chrome(); + capabilities = webdriver.Capabilities.firefox(); + capabilities = webdriver.Capabilities.htmlunit(); + capabilities = webdriver.Capabilities.htmlunitwithjs(); + capabilities = webdriver.Capabilities.ie(); + capabilities = webdriver.Capabilities.ipad(); + capabilities = webdriver.Capabilities.iphone(); + capabilities = webdriver.Capabilities.opera(); + capabilities = webdriver.Capabilities.phantomjs(); + capabilities = webdriver.Capabilities.safari(); +} + +function TestCapability() { + var capability: string; + + capability = webdriver.Capability.ACCEPT_SSL_CERTS; + capability = webdriver.Capability.BROWSER_NAME; + capability = webdriver.Capability.HANDLES_ALERTS; + capability = webdriver.Capability.LOGGING_PREFS; + capability = webdriver.Capability.PLATFORM; + capability = webdriver.Capability.PROXY; + capability = webdriver.Capability.ROTATABLE; + capability = webdriver.Capability.SECURE_SSL; + capability = webdriver.Capability.SUPPORTS_APPLICATION_CACHE; + capability = webdriver.Capability.SUPPORTS_BROWSER_CONNECTION; + capability = webdriver.Capability.SUPPORTS_CSS_SELECTORS; + capability = webdriver.Capability.SUPPORTS_JAVASCRIPT; + capability = webdriver.Capability.SUPPORTS_LOCATION_CONTEXT; + capability = webdriver.Capability.TAKES_SCREENSHOT; + capability = webdriver.Capability.UNEXPECTED_ALERT_BEHAVIOR; + capability = webdriver.Capability.VERSION; +} + +function TestCommand() { + var command: webdriver.Command = new webdriver.Command(webdriver.CommandName.ADD_COOKIE); + + var name: string = command.getName(); + var param: any = command.getParameter("param"); + + var params: any = command.getParameters(); + + command = command.setParameter("param", 123); + command = command.setParameters({ param: 123 }); +} + +function TestCommandExecutor() { + var c: webdriver.CommandExecutor = { execute: function(command: webdriver.Command, callback: (error: Error, obj: any) => any) {} }; +} + +function TestCommandName() { + var command: string; + + command = webdriver.CommandName.ACCEPT_ALERT; + command = webdriver.CommandName.ADD_COOKIE; + command = webdriver.CommandName.CLEAR_APP_CACHE; + command = webdriver.CommandName.CLEAR_ELEMENT; + command = webdriver.CommandName.CLEAR_LOCAL_STORAGE; + command = webdriver.CommandName.CLEAR_SESSION_STORAGE; + command = webdriver.CommandName.CLICK; + command = webdriver.CommandName.CLICK_ELEMENT; + command = webdriver.CommandName.CLOSE; + command = webdriver.CommandName.DELETE_ALL_COOKIES; + command = webdriver.CommandName.DELETE_COOKIE; + command = webdriver.CommandName.DESCRIBE_SESSION; + command = webdriver.CommandName.DISMISS_ALERT; + command = webdriver.CommandName.DOUBLE_CLICK; + command = webdriver.CommandName.ELEMENT_EQUALS; + command = webdriver.CommandName.EXECUTE_ASYNC_SCRIPT; + command = webdriver.CommandName.EXECUTE_SCRIPT; + command = webdriver.CommandName.EXECUTE_SQL; + command = webdriver.CommandName.FIND_CHILD_ELEMENT; + command = webdriver.CommandName.FIND_CHILD_ELEMENTS; + command = webdriver.CommandName.FIND_ELEMENT; + command = webdriver.CommandName.FIND_ELEMENTS; + command = webdriver.CommandName.GET; + command = webdriver.CommandName.GET_ACTIVE_ELEMENT; + command = webdriver.CommandName.GET_ALERT_TEXT; + command = webdriver.CommandName.GET_ALL_COOKIES; + command = webdriver.CommandName.GET_APP_CACHE; + command = webdriver.CommandName.GET_APP_CACHE_STATUS; + command = webdriver.CommandName.GET_AVAILABLE_LOG_TYPES; + command = webdriver.CommandName.GET_COOKIE; + command = webdriver.CommandName.GET_CURRENT_URL; + command = webdriver.CommandName.GET_CURRENT_WINDOW_HANDLE; + command = webdriver.CommandName.GET_ELEMENT_ATTRIBUTE; + command = webdriver.CommandName.GET_ELEMENT_LOCATION; + command = webdriver.CommandName.GET_ELEMENT_LOCATION_IN_VIEW; + command = webdriver.CommandName.GET_ELEMENT_SIZE; + command = webdriver.CommandName.GET_ELEMENT_TAG_NAME; + command = webdriver.CommandName.GET_ELEMENT_TEXT; + command = webdriver.CommandName.GET_ELEMENT_VALUE_OF_CSS_PROPERTY; + command = webdriver.CommandName.GET_LOCAL_STORAGE_ITEM; + command = webdriver.CommandName.GET_LOCAL_STORAGE_KEYS; + command = webdriver.CommandName.GET_LOCAL_STORAGE_SIZE; + command = webdriver.CommandName.GET_LOCATION; + command = webdriver.CommandName.GET_LOG; + command = webdriver.CommandName.GET_PAGE_SOURCE; + command = webdriver.CommandName.GET_SCREEN_ORIENTATION; + command = webdriver.CommandName.GET_SERVER_STATUS; + command = webdriver.CommandName.GET_SESSION_LOGS; + command = webdriver.CommandName.GET_SESSION_STORAGE_ITEM; + command = webdriver.CommandName.GET_SESSION_STORAGE_KEYS; + command = webdriver.CommandName.GET_SESSION_STORAGE_SIZE; + command = webdriver.CommandName.GET_SESSIONS; + command = webdriver.CommandName.GET_TITLE; + command = webdriver.CommandName.GET_WINDOW_HANDLES; + command = webdriver.CommandName.GET_WINDOW_POSITION; + command = webdriver.CommandName.GET_WINDOW_SIZE; + command = webdriver.CommandName.GO_BACK; + command = webdriver.CommandName.GO_FORWARD; + command = webdriver.CommandName.IMPLICITLY_WAIT; + command = webdriver.CommandName.IS_BROWSER_ONLINE; + command = webdriver.CommandName.IS_ELEMENT_DISPLAYED; + command = webdriver.CommandName.IS_ELEMENT_ENABLED; + command = webdriver.CommandName.IS_ELEMENT_SELECTED; + command = webdriver.CommandName.MAXIMIZE_WINDOW; + command = webdriver.CommandName.MOUSE_DOWN; + command = webdriver.CommandName.MOUSE_UP; + command = webdriver.CommandName.MOVE_TO; + command = webdriver.CommandName.NEW_SESSION; + command = webdriver.CommandName.QUIT; + command = webdriver.CommandName.REFRESH; + command = webdriver.CommandName.REMOVE_LOCAL_STORAGE_ITEM; + command = webdriver.CommandName.REMOVE_SESSION_STORAGE_ITEM; + command = webdriver.CommandName.SCREENSHOT; + command = webdriver.CommandName.SEND_KEYS_TO_ACTIVE_ELEMENT; + command = webdriver.CommandName.SEND_KEYS_TO_ELEMENT; + command = webdriver.CommandName.SET_ALERT_TEXT; + command = webdriver.CommandName.SET_BROWSER_ONLINE; + command = webdriver.CommandName.SET_LOCAL_STORAGE_ITEM; + command = webdriver.CommandName.SET_LOCATION; + command = webdriver.CommandName.SET_SCREEN_ORIENTATION; + command = webdriver.CommandName.SET_SCRIPT_TIMEOUT; + command = webdriver.CommandName.SET_SESSION_STORAGE_ITEM; + command = webdriver.CommandName.SET_TIMEOUT; + command = webdriver.CommandName.SET_WINDOW_POSITION; + command = webdriver.CommandName.SET_WINDOW_SIZE; + command = webdriver.CommandName.SUBMIT_ELEMENT; + command = webdriver.CommandName.SWITCH_TO_FRAME; + command = webdriver.CommandName.SWITCH_TO_WINDOW; + command = webdriver.CommandName.TOUCH_DOUBLE_TAP; + command = webdriver.CommandName.TOUCH_DOWN; + command = webdriver.CommandName.TOUCH_FLICK; + command = webdriver.CommandName.TOUCH_LONG_PRESS; + command = webdriver.CommandName.TOUCH_MOVE; + command = webdriver.CommandName.TOUCH_SCROLL; + command = webdriver.CommandName.TOUCH_SINGLE_TAP; + command = webdriver.CommandName.TOUCH_UP; +} + +function TestEventEmitter() { + var emitter: webdriver.EventEmitter = new webdriver.EventEmitter(); + + var callback = function (a: number, b: number, c: number) {}; + + emitter = emitter.addListener('ABC', callback); + + emitter.emit('ABC', 1, 2, 3); + + var listeners = emitter.listeners('ABC'); + var length: number = listeners.length; + var listenerInfo = listeners[0]; + if (listenerInfo.oneshot) { + listenerInfo.fn.apply(listenerInfo.scope, [1, 2, 3]); + } + + emitter = emitter.on('ABC', callback); + + emitter = emitter.once('ABC', callback); + + emitter = emitter.removeListener('ABC', callback); + + emitter.removeAllListeners('ABC'); + emitter.removeAllListeners(); +} + +function TestFirefoxDomExecutor() { + if (webdriver.FirefoxDomExecutor.isAvailable()) { + var executor: webdriver.CommandExecutor = new webdriver.FirefoxDomExecutor(); + var callback = function(error: Error, responseObject: any) {}; + executor.execute(new webdriver.Command(webdriver.CommandName.CLICK), callback); + } +} + +function TestKey() { + var key: string; + + key = webdriver.Key.ADD; + key = webdriver.Key.ALT; + key = webdriver.Key.ARROW_DOWN; + key = webdriver.Key.ARROW_LEFT; + key = webdriver.Key.ARROW_RIGHT; + key = webdriver.Key.ARROW_UP; + key = webdriver.Key.BACK_SPACE; + key = webdriver.Key.CANCEL; + key = webdriver.Key.CLEAR; + key = webdriver.Key.COMMAND; + key = webdriver.Key.CONTROL; + key = webdriver.Key.DECIMAL; + key = webdriver.Key.DELETE; + key = webdriver.Key.DIVIDE; + key = webdriver.Key.DOWN; + key = webdriver.Key.END; + key = webdriver.Key.ENTER; + key = webdriver.Key.EQUALS; + key = webdriver.Key.ESCAPE; + key = webdriver.Key.F1; + key = webdriver.Key.F2; + key = webdriver.Key.F3; + key = webdriver.Key.F4; + key = webdriver.Key.F5; + key = webdriver.Key.F6; + key = webdriver.Key.F7; + key = webdriver.Key.F8; + key = webdriver.Key.F9; + key = webdriver.Key.F10; + key = webdriver.Key.F11; + key = webdriver.Key.F12; + key = webdriver.Key.HELP; + key = webdriver.Key.HOME; + key = webdriver.Key.INSERT; + key = webdriver.Key.LEFT; + key = webdriver.Key.META; + key = webdriver.Key.MULTIPLY; + key = webdriver.Key.NULL; + key = webdriver.Key.NUMPAD0; + key = webdriver.Key.NUMPAD1; + key = webdriver.Key.NUMPAD2; + key = webdriver.Key.NUMPAD3; + key = webdriver.Key.NUMPAD4; + key = webdriver.Key.NUMPAD5; + key = webdriver.Key.NUMPAD6; + key = webdriver.Key.NUMPAD7; + key = webdriver.Key.NUMPAD8; + key = webdriver.Key.NUMPAD9; + key = webdriver.Key.PAGE_DOWN; + key = webdriver.Key.PAGE_UP; + key = webdriver.Key.PAUSE; + key = webdriver.Key.RETURN; + key = webdriver.Key.RIGHT; + key = webdriver.Key.SEMICOLON; + key = webdriver.Key.SEPARATOR; + key = webdriver.Key.SHIFT; + key = webdriver.Key.SPACE; + key = webdriver.Key.SUBTRACT; + key = webdriver.Key.TAB; + key = webdriver.Key.UP; + + key = webdriver.Key.chord(webdriver.Key.NUMPAD0, webdriver.Key.NUMPAD1); +} + +function TestLocator() { + var locator: webdriver.Locator = new webdriver.Locator('id', 'ABC'); + + var locatorStr: string = locator.toString(); + + var using: string = locator.using; + var value: string = locator.value; + + locator = webdriver.Locator.checkLocator(webdriver.Locator.Strategy.id('ABC')); + locator = webdriver.Locator.checkLocator({id: 'ABC'}); + + locator = webdriver.Locator.createFromObj({id: 'ABC'}); + + locator = webdriver.Locator.Strategy.id('ABC'); + + locator = webdriver.By.id('ABC'); +} + +function TestSession() { + var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android()); + var capabilitiesObj: any = {}; + capabilitiesObj[webdriver.Capability.BROWSER_NAME] = webdriver.Browser.ANDROID; + capabilitiesObj[webdriver.Capability.PLATFORM] = 'ANDROID'; + session = new webdriver.Session('ABC', capabilitiesObj); + + var capabilities: webdriver.Capabilities = session.getCapabilities(); + var capability: any = session.getCapability(webdriver.Capability.BROWSER_NAME); + var id: string = session.getId(); + var data: string = session.toJSON(); +} + +function TestUnhandledAlertError() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + var promise: webdriver.promise.Promise = new webdriver.promise.Promise(); + + var alert: webdriver.Alert = new webdriver.Alert(driver, 'ABC'); + var error = new webdriver.UnhandledAlertError('An error', alert); + var baseError: webdriver.error.Error = error; + + alert = error.getAlert(); +} + +function TestWebDriverLogs() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var logs: webdriver.WebDriverLogs = webdriver.WebDriver.Logs; + var promise: webdriver.promise.Promise; + + promise = logs.get(webdriver.logging.Type.BROWSER); + promise = logs.getAvailableLogTypes(); +} + +function TestWebDriverNavigation() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var navigation: webdriver.WebDriverNavigation = webdriver.WebDriver.Navigation; + var promise: webdriver.promise.Promise; + + promise = navigation.back(); + promise = navigation.forward(); + promise = navigation.refresh(); + promise = navigation.to('http://google.com'); +} + +function TestWebDriverOptions() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var options: webdriver.WebDriverOptions = webdriver.WebDriver.Options; + var promise: webdriver.promise.Promise; + + // Add Cookie + promise = options.addCookie('name', 'value'); + promise = options.addCookie('name', 'value', 'path'); + promise = options.addCookie('name', 'value', 'path', 'domain'); + promise = options.addCookie('name', 'value', 'path', 'domain', true); + promise = options.addCookie('name', 'value', 'path', 'domain', true, 123); + promise = options.addCookie('name', 'value', 'path', 'domain', true, Date.now()); + + promise = options.deleteAllCookies(); + promise = options.deleteCookie('name'); + promise = options.getCookie('name'); + promise = options.getCookies(); + + var logs: webdriver.WebDriverLogs = options.logs(); + var timeouts: webdriver.WebDriverTimeouts = options.timeouts(); + var window: webdriver.WebDriverWindow = options.window(); +} + +function TestWebDriverTargetLocator() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var locator: webdriver.WebDriverTargetLocator = webdriver.WebDriver.TargetLocator; + var promise: webdriver.promise.Promise; + + var element: webdriver.WebElement = locator.activeElement(); + var alert: webdriver.Alert = locator.alert(); + promise = locator.defaultContent(); + promise = locator.frame('name'); + promise = locator.frame(1); + promise = locator.window('nameOrHandle'); +} + +function TestWebDriverTimeouts() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var timeouts: webdriver.WebDriverTimeouts = webdriver.WebDriver.Timeouts; + var promise: webdriver.promise.Promise; + + promise = timeouts.implicitlyWait(123); + promise = timeouts.pageLoadTimeout(123); + promise = timeouts.setScriptTimeout(123); +} + +function TestWebDriverWindow() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var window: webdriver.WebDriverWindow = webdriver.WebDriver.Window; + var promise: webdriver.promise.Promise; + + promise = window.getPosition(); + promise = window.getSize(); + promise = window.maximize(); + promise = window.setPosition(12, 34); + promise = window.setSize(12, 34); +} + +function TestWebDriver() { + var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android()); + var promise: webdriver.promise.Promise = new webdriver.promise.Promise(); + var executor: webdriver.CommandExecutor = new webdriver.FirefoxDomExecutor(); + var flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow(); + var driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor); + driver = new webdriver.WebDriver(session, executor, flow); + driver = new webdriver.WebDriver(promise, executor); + driver = new webdriver.WebDriver(promise, executor, flow); + + // Call + var actions: webdriver.ActionSequence = driver.actions(); + promise = driver.call(function(){}); + promise = driver.call(function(){ var d: any = this;}, driver); + promise = driver.call(function(a: number){}, driver, 1); + + promise = driver.close(); + flow = driver.controlFlow(); + + // ExecuteAsyncScript + promise = driver.executeAsyncScript('function(){}'); + promise = driver.executeAsyncScript('function(){}', 1, 2, 3); + promise = driver.executeAsyncScript(function(){}); + promise = driver.executeAsyncScript(function(a: number){}, 1); + + // ExecuteScript + promise = driver.executeScript('function(){}'); + promise = driver.executeScript('function(){}', 1, 2, 3); + promise = driver.executeScript(function(){}); + promise = driver.executeScript(function(a: number){}, 1); + + var element: webdriver.WebElement; + element = driver.findElement(webdriver.By.id('ABC')); + element = driver.findElement({id: 'ABC'}); + element = driver.findElement(webdriver.By.js('function(){}'), 1, 2, 3); + element = driver.findElement({js: 'function(){}'}, 1, 2, 3); + + promise = driver.findElements(webdriver.By.className('ABC')); + promise = driver.findElements({className: 'ABC'}); + promise = driver.findElements(webdriver.By.js('function(){}'), 1, 2, 3); + promise = driver.findElements({js: 'function(){}'}, 1, 2, 3); + + promise = driver.get('http://www.google.com'); + promise = driver.getAllWindowHandles(); + promise = driver.getCapabilities(); + promise = driver.getCurrentUrl(); + promise = driver.getPageSource() + promise = driver.getSession(); + promise = driver.getTitle(); + promise = driver.getWindowHandle(); + + promise = driver.isElementPresent(webdriver.By.className('ABC')); + promise = driver.isElementPresent({className: 'ABC'}); + promise = driver.isElementPresent(webdriver.By.js('function(){}'), 1, 2, 3); + promise = driver.isElementPresent({js: 'function(){}'}, 1, 2, 3); + + var options: webdriver.WebDriverOptions = driver.manage(); + var navigation: webdriver.WebDriverNavigation = driver.navigate(); + var locator: webdriver.WebDriverTargetLocator = driver.switchTo(); + + promise = driver.quit(); + promise = driver.schedule(new webdriver.Command(webdriver.CommandName.CLICK), 'ABC'); + promise = driver.sleep(123); + promise = driver.takeScreenshot(); + + promise = driver.wait(function() { return true; }, 123); + promise = driver.wait(function() { return true; }, 123, 'Message'); + promise = driver.wait(function() { return promise; }, 123); + promise = driver.wait(function() { return promise; }, 123, 'Message'); + + driver = webdriver.WebDriver.attachToSession(executor, 'ABC'); + driver = webdriver.WebDriver.createSession(executor, webdriver.Capabilities.android()); +} + +function TestWebElement() { + var driver: webdriver.WebDriver = new webdriver.Builder(). + withCapabilities(webdriver.Capabilities.chrome()). + build(); + + var element: webdriver.WebElement; + var promise: webdriver.promise.Promise = new webdriver.promise.Promise(); + + element = new webdriver.WebElement(driver, 'ID'); + element = new webdriver.WebElement(driver, promise); + + var deferred: webdriver.promise.Deferred = element; + + promise = element.clear(); + promise = element.click(); + + element = element.findElement(webdriver.By.id('ABC')); + element = element.findElement({id: 'ABC'}); + element = element.findElement(webdriver.By.js('function(){}'), 1, 2, 3); + element = element.findElement({js: 'function(){}'}, 1, 2, 3); + + promise = element.findElements(webdriver.By.className('ABC')); + promise = element.findElements({className: 'ABC'}); + promise = element.findElements(webdriver.By.js('function(){}'), 1, 2, 3); + promise = element.findElements({js: 'function(){}'}, 1, 2, 3); + + promise = element.isElementPresent(webdriver.By.className('ABC')); + promise = element.isElementPresent({className: 'ABC'}); + promise = element.isElementPresent(webdriver.By.js('function(){}'), 1, 2, 3); + promise = element.isElementPresent({js: 'function(){}'}, 1, 2, 3); + + promise = element.getAttribute('class'); + promise = element.getCssValue('display'); + driver = element.getDriver(); + promise = element.getInnerHtml(); + promise = element.getLocation(); + promise = element.getOuterHtml(); + promise = element.getSize(); + promise = element.getTagName(); + promise = element.getText(); + promise = element.isDisplayed(); + promise = element.isEnabled(); + promise = element.isSelected(); + promise = element.sendKeys('A', 'B', 'C'); + promise = element.submit(); + promise = element.toWireValue(); + + promise = webdriver.WebElement.equals(element, new webdriver.WebElement(driver, 'ID2')); + + var key: string = webdriver.WebElement.ELEMENT_KEY; +} + +function TestLogging() { + webdriver.logging.Preferences['name'] = 'ABC'; + var level: webdriver.logging.Level = webdriver.logging.getLevel('OFF'); + level = webdriver.logging.getLevel(1); + + level = webdriver.logging.Level.ALL; + level = webdriver.logging.Level.DEBUG; + level = webdriver.logging.Level.INFO; + level = webdriver.logging.Level.OFF; + level = webdriver.logging.Level.SEVERE; + level = webdriver.logging.Level.WARNING; + + var name: string = level.name; + var value: number = level.value; + + name = webdriver.logging.LevelName.ALL; + name = webdriver.logging.LevelName.DEBUG; + name = webdriver.logging.LevelName.INFO; + name = webdriver.logging.LevelName.OFF; + name = webdriver.logging.LevelName.SEVERE; + name = webdriver.logging.LevelName.WARNING; + + var type: string; + type = webdriver.logging.Type.BROWSER; + type = webdriver.logging.Type.CLIENT; + type = webdriver.logging.Type.DRIVER; + type = webdriver.logging.Type.PERFORMANCE; + type = webdriver.logging.Type.SERVER; +} + +function TestLoggingEntry() { + var entry: webdriver.logging.Entry; + + entry = new webdriver.logging.Entry(webdriver.logging.Level.ALL, 'ABC'); + entry = new webdriver.logging.Entry('ALL', 'ABC'); + entry = new webdriver.logging.Entry(webdriver.logging.Level.ALL, 'ABC', 123); + entry = new webdriver.logging.Entry('ALL', 'ABC', 123); + entry = new webdriver.logging.Entry(webdriver.logging.Level.ALL, 'ABC', 123, webdriver.logging.Type.BROWSER); + entry = new webdriver.logging.Entry('ALL', 'ABC', 123, webdriver.logging.Type.BROWSER); + + var entryObj: any = entry.toJSON(); + + var message: string = entry.message; + var timestamp: number = entry.timestamp; + var type: string = entry.type; + + entry = webdriver.logging.Entry.fromClosureLogRecord({}); + entry = webdriver.logging.Entry.fromClosureLogRecord({}, webdriver.logging.Type.DRIVER); +} + +function TestProcess() { + var isNative: boolean = webdriver.process.isNative(); + var value: string; + + value = webdriver.process.getEnv('name'); + value = webdriver.process.getEnv('name', 'default'); + + webdriver.process.setEnv('name', 'value'); + webdriver.process.setEnv('name', 123); +} + +function TestPromise() { + var promise: webdriver.promise.Promise = new webdriver.promise.Promise(); + + webdriver.promise.asap(promise, function(value: any){ return true; }); + webdriver.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; }); + + promise = webdriver.promise.checkedNodeCall(function(err: any, value: any) { return 123; }); + + var flow: webdriver.promise.ControlFlow = webdriver.promise.controlFlow(); + + promise = webdriver.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { }); + + var deferred: webdriver.promise.Deferred; + deferred = webdriver.promise.defer(function() {}); + deferred = webdriver.promise.defer(function(reason?: any) {}); + + promise = webdriver.promise.delayed(123); + + promise = webdriver.promise.fulfilled(); + promise = webdriver.promise.fulfilled({a: 123}); + + promise = webdriver.promise.fullyResolved({a: 123}); + + var isPromise: boolean = webdriver.promise.isPromise('ABC'); + + promise = webdriver.promise.rejected({a: 123}); + + webdriver.promise.setDefaultFlow(new webdriver.promise.ControlFlow()); + + promise = webdriver.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; }); +} + +function TestControlFlow() { + var flow: webdriver.promise.ControlFlow; + flow = new webdriver.promise.ControlFlow(); + flow = new webdriver.promise.ControlFlow({clearInterval: function(a: number) {}, + clearTimeout: function(a: number) {}, + setInterval: function(a: () => void, b: number) { return 2; }, + setTimeout: function(a: () => void, b: number) { return 2; }}); + + var emitter: webdriver.EventEmitter = flow; + + var eventType: string; + + eventType = webdriver.promise.ControlFlow.EventType.IDLE; + eventType = webdriver.promise.ControlFlow.EventType.SCHEDULE_TASK; + eventType = webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION; + + var e: any = flow.annotateError(new Error('Error')); + + var promise: webdriver.promise.Promise; + + promise = flow.await(promise); + + flow.clearHistory(); + + promise = flow.execute(function() { return promise; }); + promise = flow.execute(function() { return promise; }, 'Description'); + + var history: string[] = flow.getHistory(); + + var schedule: string = flow.getSchedule(); + + flow.reset(); + + promise = flow.timeout(123); + promise = flow.timeout(123, 'Description'); + + promise = flow.wait(function() { return true; }, 123); + promise = flow.wait(function() { return true; }, 123, 'Timeout Message'); + promise = flow.wait(function() { return promise; }, 123, 'Timeout Message'); + + var timer: webdriver.promise.IControlFlowTimer = flow.timer; + + timer = webdriver.promise.ControlFlow.defaultTimer; + var loopFrequency: number = webdriver.promise.ControlFlow.EVENT_LOOP_FREQUENCY; +} + +function TestDeferred() { + var deferred: webdriver.promise.Deferred; + + deferred = new webdriver.promise.Deferred(); + deferred = new webdriver.promise.Deferred(function() {}); + deferred = new webdriver.promise.Deferred(function(reason: any) { }); + deferred = new webdriver.promise.Deferred(function() {}, new webdriver.promise.ControlFlow()); + + var promise: webdriver.promise.Promise = deferred; + + deferred.errback(new Error('Error')); + deferred.errback('Error'); + deferred.fulfill(123); + deferred.reject(new Error('Error')); + deferred.reject('Error'); + deferred.removeAll(); + + promise = deferred.promise; +} + +function TestPromiseClass() { + var promise: webdriver.promise.Promise = new webdriver.promise.Promise(); + + var obj = { + a: 5 + } + + promise = promise.addBoth(function( a: any ) { }); + promise = promise.addBoth(function( a: any ) { return 123; }); + promise = promise.addBoth(function( a: any ) { }, obj); + + promise = promise.addCallback(function( a: any ) { }); + promise = promise.addCallback(function( a: any ) { return 123; }); + promise = promise.addCallback(function( a: any ) { }, obj); + + promise = promise.addErrback(function( e: any ) { }); + promise = promise.addErrback(function( e: any ) { return 123; }); + promise = promise.addErrback(function( e: any ) { }, obj); + + promise.cancel(obj); + + var isPending: boolean = promise.isPending(); + + promise = promise.then(); + promise = promise.then(function( a: any ) { }); + promise = promise.then(function( a: any ) { return 123; }); + promise = promise.then(function( a: any ) {}, function( e: any) {}); + promise = promise.then(function( a: any ) {}, function( e: any) { return 123; }); +} + +function TestErrorCode() { + var errorCode: number; + + errorCode = webdriver.error.ErrorCode.ELEMENT_NOT_SELECTABLE; + errorCode = webdriver.error.ErrorCode.ELEMENT_NOT_VISIBLE; + errorCode = webdriver.error.ErrorCode.IME_ENGINE_ACTIVATION_FAILED; + errorCode = webdriver.error.ErrorCode.IME_NOT_AVAILABLE; + errorCode = webdriver.error.ErrorCode.INVALID_COOKIE_DOMAIN; + errorCode = webdriver.error.ErrorCode.INVALID_ELEMENT_COORDINATES; + errorCode = webdriver.error.ErrorCode.INVALID_ELEMENT_STATE; + errorCode = webdriver.error.ErrorCode.INVALID_SELECTOR_ERROR; + errorCode = webdriver.error.ErrorCode.INVALID_XPATH_SELECTOR; + errorCode = webdriver.error.ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPE; + errorCode = webdriver.error.ErrorCode.JAVASCRIPT_ERROR; + errorCode = webdriver.error.ErrorCode.METHOD_NOT_ALLOWED; + errorCode = webdriver.error.ErrorCode.MODAL_DIALOG_OPENED; + errorCode = webdriver.error.ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS; + errorCode = webdriver.error.ErrorCode.NO_MODAL_DIALOG_OPEN; + errorCode = webdriver.error.ErrorCode.NO_SUCH_ELEMENT; + errorCode = webdriver.error.ErrorCode.NO_SUCH_FRAME; + errorCode = webdriver.error.ErrorCode.NO_SUCH_WINDOW; + errorCode = webdriver.error.ErrorCode.SCRIPT_TIMEOUT; + errorCode = webdriver.error.ErrorCode.SESSION_NOT_CREATED; + errorCode = webdriver.error.ErrorCode.SQL_DATABASE_ERROR; + errorCode = webdriver.error.ErrorCode.STALE_ELEMENT_REFERENCE; + errorCode = webdriver.error.ErrorCode.SUCCESS; + errorCode = webdriver.error.ErrorCode.TIMEOUT; + errorCode = webdriver.error.ErrorCode.UNABLE_TO_SET_COOKIE; + errorCode = webdriver.error.ErrorCode.UNKNOWN_COMMAND; + errorCode = webdriver.error.ErrorCode.UNKNOWN_ERROR; + errorCode = webdriver.error.ErrorCode.UNSUPPORTED_OPERATION; + errorCode = webdriver.error.ErrorCode.XPATH_LOOKUP_ERROR; +} + +function TestError() { + var error: webdriver.error.Error; + + error = new webdriver.error.Error(webdriver.error.ErrorCode.ELEMENT_NOT_SELECTABLE); + error = new webdriver.error.Error(webdriver.error.ErrorCode.ELEMENT_NOT_SELECTABLE, 'Message'); + + var code: number = error.code; + var state: string = error.state; + var message: string = error.message; + var name: string = error.name; + var stack: string = error.stack; + var isAutomationError: boolean = error.isAutomationError; + var errorStr: string = error.toString(); + + state = webdriver.error.Error.State.ELEMENT_NOT_SELECTABLE + state = webdriver.error.Error.State.ELEMENT_NOT_VISIBLE; + state = webdriver.error.Error.State.IME_ENGINE_ACTIVATION_FAILED; + state = webdriver.error.Error.State.IME_NOT_AVAILABLE; + state = webdriver.error.Error.State.INVALID_COOKIE_DOMAIN; + state = webdriver.error.Error.State.INVALID_ELEMENT_COORDINATES; + state = webdriver.error.Error.State.INVALID_ELEMENT_STATE; + state = webdriver.error.Error.State.INVALID_SELECTOR; + state = webdriver.error.Error.State.JAVASCRIPT_ERROR; + state = webdriver.error.Error.State.MOVE_TARGET_OUT_OF_BOUNDS; + state = webdriver.error.Error.State.NO_SUCH_ALERT; + state = webdriver.error.Error.State.NO_SUCH_DOM + state = webdriver.error.Error.State.NO_SUCH_ELEMENT; + state = webdriver.error.Error.State.NO_SUCH_FRAME; + state = webdriver.error.Error.State.NO_SUCH_WINDOW; + state = webdriver.error.Error.State.SCRIPT_TIMEOUT; + state = webdriver.error.Error.State.SESSION_NOT_CREATED; + state = webdriver.error.Error.State.STALE_ELEMENT_REFERENCE; + state = webdriver.error.Error.State.SUCCESS; + state = webdriver.error.Error.State.TIMEOUT; + state = webdriver.error.Error.State.UNABLE_TO_SET_COOKIE; + state = webdriver.error.Error.State.UNEXPECTED_ALERT_OPEN + state = webdriver.error.Error.State.UNKNOWN_COMMAND; + state = webdriver.error.Error.State.UNKNOWN_ERROR; + state = webdriver.error.Error.State.UNSUPPORTED_OPERATION; +} \ No newline at end of file From 5881a426aa38f1dc36d22b21d2271388da42e243 Mon Sep 17 00:00:00 2001 From: BillArmstrong Date: Sun, 2 Feb 2014 09:23:41 -0500 Subject: [PATCH 110/240] Fixed the filename of the test files. The test files did not have the correct filename and were not getting recognized by the test runner. --- .../{angular-protractor.tests.ts => angular-protractor-tests.ts} | 0 .../{selenium-webdriver.tests.ts => selenium-webdriver-tests.ts} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename angular-protractor/{angular-protractor.tests.ts => angular-protractor-tests.ts} (100%) rename selenium-webdriver/{selenium-webdriver.tests.ts => selenium-webdriver-tests.ts} (100%) diff --git a/angular-protractor/angular-protractor.tests.ts b/angular-protractor/angular-protractor-tests.ts similarity index 100% rename from angular-protractor/angular-protractor.tests.ts rename to angular-protractor/angular-protractor-tests.ts diff --git a/selenium-webdriver/selenium-webdriver.tests.ts b/selenium-webdriver/selenium-webdriver-tests.ts similarity index 100% rename from selenium-webdriver/selenium-webdriver.tests.ts rename to selenium-webdriver/selenium-webdriver-tests.ts From 41f71a2853c4bd362b069f0648da5a0662bb8e89 Mon Sep 17 00:00:00 2001 From: BillArmstrong Date: Sun, 2 Feb 2014 19:13:39 -0500 Subject: [PATCH 111/240] Added version numbers to the header comments. --- angular-protractor/angular-protractor.d.ts | 2 +- selenium-webdriver/selenium-webdriver.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts index f5ec5ece14..951ba85de9 100644 --- a/angular-protractor/angular-protractor.d.ts +++ b/angular-protractor/angular-protractor.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular Protractor +// Type definitions for Angular Protractor 0.17.0 // Project: https://github.com/angular/protractor // Definitions by: Bill Armstrong // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/selenium-webdriver/selenium-webdriver.d.ts b/selenium-webdriver/selenium-webdriver.d.ts index 6a185cc21a..9ce5321de5 100644 --- a/selenium-webdriver/selenium-webdriver.d.ts +++ b/selenium-webdriver/selenium-webdriver.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Selenium WebDriverJS +// Type definitions for Selenium WebDriverJS 2.39.0 // Project: https://code.google.com/p/selenium/ // Definitions by: Bill Armstrong // Definitions: https://github.com/borisyankov/DefinitelyTyped From 33735286ede08b854b666e01b25bd9586f8b0352 Mon Sep 17 00:00:00 2001 From: david pichsenmeister Date: Tue, 4 Feb 2014 15:14:35 +0100 Subject: [PATCH 112/240] added typing of mozilla localForage library --- localForage/localForage.d.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 localForage/localForage.d.ts diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts new file mode 100644 index 0000000000..71ccaba3c2 --- /dev/null +++ b/localForage/localForage.d.ts @@ -0,0 +1,26 @@ +// Type definitions for Mozilla's localForage +// Project: https://github.com/mozilla/localforage +// Definitions by: david pichsenmeister +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module lf { + interface ILocalForage { + clear(): void + key(index: number): T + length: number + getItem(key: string, callback: ICallback) + getItem(key: string): IPromise + setItem(key: string, value: T, callback: ICallback) + setItem(key: string, value: T): IPromise + removeItem(key: string, callback: ICallback) + removeItem(key: string): IPromise + } + + interface ICallback { + (data: T): void + } + + interface IPromise { + then(callback: ICallback): void + } +} \ No newline at end of file From 8d7fd62f892706238ea570f4c77e6afb1e60100d Mon Sep 17 00:00:00 2001 From: David Sidlinger Date: Tue, 4 Feb 2014 09:38:31 -0600 Subject: [PATCH 113/240] LoDash*Wrapper.map() returns mapped result type --- lodash/lodash.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 97aeab757a..f51a1b7b42 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1919,27 +1919,27 @@ declare module _ { **/ map( callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + thisArg?: any): LoDashArrayWrapper; /** * @see _.map * @param pluckValue _.pluck style callback **/ map( - pluckValue: string): LoDashArrayWrapper; + pluckValue: string): LoDashArrayWrapper; /** * @see _.map **/ collect( callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + thisArg?: any): LoDashArrayWrapper; /** * @see _.map **/ collect( - pluckValue: string): LoDashArrayWrapper; + pluckValue: string): LoDashArrayWrapper; } interface LoDashObjectWrapper { @@ -1948,14 +1948,14 @@ declare module _ { **/ map( callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + thisArg?: any): LoDashObjectWrapper; /** * @see _.map **/ collect( callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + thisArg?: any): LoDashObjectWrapper; } //_.max From adf04673355fd3c6457ddca6eccc534447aae11a Mon Sep 17 00:00:00 2001 From: Mike Keesey Date: Tue, 4 Feb 2014 16:14:29 -0800 Subject: [PATCH 114/240] Made SignalR compliant with --noImplicitAny --- signalr/signalr-tests.ts | 4 ++-- signalr/signalr.d.ts | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/signalr/signalr-tests.ts b/signalr/signalr-tests.ts index 8a96bf9a12..3ef8cad875 100644 --- a/signalr/signalr-tests.ts +++ b/signalr/signalr-tests.ts @@ -60,7 +60,7 @@ interface MyHubConnection extends HubConnection { }; // My Hubs Server function: server: { - send(message: string); + send(message: string): any; }; } @@ -107,7 +107,7 @@ function test_hubs() { proxy.invoke('send', msg); proxy.invoke('send', msg, room); proxy.invoke('add', 1, 2) - .done(function (result) { + .done(function (result: any) { console.log('The result is ' + result); }); proxy.on('addMessage', function (msg?) { diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index 7d1e64b742..6519f70518 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -1,13 +1,14 @@ // Type definitions for SignalR 1.0 // Project: http://www.asp.net/signalr // Definitions by: Boris Yankov +// Modified by: T. Michael Keesey // Definitions: https://github.com/borisyankov/DefinitelyTyped /// interface HubMethod { - (callback: (data: string) => void ); + (callback: (data: string) => void ): any; } interface SignalREvents { @@ -75,8 +76,8 @@ interface HubProxy { hubName: string; init(connection: HubConnection, hubName: string): void; hasSubscriptions(): boolean; - on(eventName: string, callback: (...msg) => void ): HubProxy; - off(eventName: string, callback: (msg) => void ): HubProxy; + on(eventName: string, callback: (...msg: any[]) => void ): HubProxy; + off(eventName: string, callback: (msg: any) => void ): HubProxy; invoke(methodName: string, ...args: any[]): JQueryDeferred; } @@ -88,18 +89,18 @@ interface HubConnectionSettings { interface HubConnection extends SignalR { //(url?: string, queryString?: any, logging?: boolean): HubConnection; - proxies; - received(callback: (data: { Id; Method; Hub; State; Args; }) => void ): HubConnection; + proxies: any; + received(callback: (data: { Id: any; Method: any; Hub: any; State: any; Args: any; }) => void ): HubConnection; createHubProxy(hubName: string): HubProxy; } interface SignalRfn { - init(url, qs, logging); + init(url: any, qs: any, logging: any): any; } interface ConnectionSettings { - transport?; - callback?; + transport?: any; + callback?: any; waitForPageLoad?: boolean; jsonp?: boolean; } From 16dd1ab76fb4c65e532ca820dd45c875636521b6 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 5 Feb 2014 12:48:22 +0900 Subject: [PATCH 115/240] Removed non-required .tscparams --- breeze/breeze-tests.ts.tscparams | 1 - breeze/breeze.d.ts.tscparams | 1 - es6-promises/es6-promises-tests.ts.tscparams | 1 - jquery.colorpicker/jquery.colorpicker.d.ts.tscparams | 1 - raphael/raphael.d.ts.tscparams | 1 - signalr/signalr-tests.ts.tscparams | 1 - signalr/signalr.d.ts.tscparams | 1 - 7 files changed, 7 deletions(-) delete mode 100644 breeze/breeze-tests.ts.tscparams delete mode 100644 breeze/breeze.d.ts.tscparams delete mode 100644 es6-promises/es6-promises-tests.ts.tscparams delete mode 100644 jquery.colorpicker/jquery.colorpicker.d.ts.tscparams delete mode 100644 raphael/raphael.d.ts.tscparams delete mode 100644 signalr/signalr-tests.ts.tscparams delete mode 100644 signalr/signalr.d.ts.tscparams diff --git a/breeze/breeze-tests.ts.tscparams b/breeze/breeze-tests.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/breeze/breeze-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/breeze/breeze.d.ts.tscparams b/breeze/breeze.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/breeze/breeze.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/es6-promises/es6-promises-tests.ts.tscparams b/es6-promises/es6-promises-tests.ts.tscparams deleted file mode 100644 index 3cc762b550..0000000000 --- a/es6-promises/es6-promises-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" \ No newline at end of file diff --git a/jquery.colorpicker/jquery.colorpicker.d.ts.tscparams b/jquery.colorpicker/jquery.colorpicker.d.ts.tscparams deleted file mode 100644 index 3cc762b550..0000000000 --- a/jquery.colorpicker/jquery.colorpicker.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" \ No newline at end of file diff --git a/raphael/raphael.d.ts.tscparams b/raphael/raphael.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/raphael/raphael.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/signalr/signalr-tests.ts.tscparams b/signalr/signalr-tests.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/signalr/signalr-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/signalr/signalr.d.ts.tscparams b/signalr/signalr.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/signalr/signalr.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" From 267ab03a0ddc1d2cb75980e1019b6b95c808aac1 Mon Sep 17 00:00:00 2001 From: apsk Date: Wed, 5 Feb 2014 20:53:50 +0200 Subject: [PATCH 116/240] Ember: Add Application.Router, Router.map, RouterDSL methods. --- ember/ember.d.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 4657ac5cb3..9bde2eca6c 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -346,6 +346,10 @@ declare module Ember { The call will be delayed until the DOM has become ready. **/ ready: Function; + /** + Application's router. + **/ + Router: Router; } /** This module implements Observer-friendly Array-like behavior. This mixin is picked up by the @@ -1569,8 +1573,13 @@ declare module Ember { static metaForProperty(key: string): {}; static isClass: boolean; static isMethod: boolean; + map(callback: Function): Router; + } + class RouterDSL { + resource(name: string, options?: {}, callback?: Function): void; + resource(name: string, callback: Function): void; + route(name: string, options?: {}): void; } - var RouterDSL: Function; var SHIM_ES5: boolean; var STRINGS: boolean; class Select extends View { @@ -2261,7 +2270,7 @@ declare module Em { class RenderBuffer extends Ember.RenderBuffer { } class Route extends Ember.Route { } class Router extends Ember.Router { } - var RouterDSL: typeof Ember.RouterDSL; + class RouterDSL extends Ember.RouterDSL { } var SHIM_ES5: typeof Ember.SHIM_ES5; var STRINGS: typeof Ember.STRINGS; class Select extends Ember.Select { } From 87ac1b3421e57cb0d7136d6a820d76e1d2aec33d Mon Sep 17 00:00:00 2001 From: John Vilk Date: Wed, 5 Feb 2014 14:28:10 -0500 Subject: [PATCH 117/240] [Node] Updating stream interfaces and removing redundant interfaces. We duplicated the EventEmitter and Stream interfaces in the "event" module, so I removed the redundant interface definitions. I have updated the ReadableStream/WritableStream interfaces in accordance with the current documentation: http://nodejs.org/api/stream.html I added class definitions for Writable/Transform/Duplex/PassThrough in 'event'. These classes are described in the following Node documentation: http://nodejs.org/api/stream.html#stream_api_for_stream_implementors As a result of these changes, I needed to slightly alter other typings to refer to the new interface name. This was unavoidable; I had to rename the `EventEmitter` interface to `NodeEventEmitter` to avoid clashing with the `events.EventEmitter` class that implements `NodeEventEmitter`. --- browser-harness/browser-harness.d.ts | 33 ++--- browserify/browserify.d.ts | 4 +- jake/jake.d.ts | 14 +- msnodesql/msnodesql.d.ts | 2 +- node/node.d.ts | 214 ++++++++++++++++----------- through/through.d.ts | 2 +- 6 files changed, 156 insertions(+), 113 deletions(-) diff --git a/browser-harness/browser-harness.d.ts b/browser-harness/browser-harness.d.ts index 73eda812c5..68dbf8be51 100644 --- a/browser-harness/browser-harness.d.ts +++ b/browser-harness/browser-harness.d.ts @@ -6,28 +6,27 @@ /// declare module "browser-harness" { - import nodeEvents = require("events"); - interface HarnessEvents extends nodeEvents.NodeEventEmitter { - once(event: string, listener: (driver: Driver) => void): nodeEvents.NodeEventEmitter; - once(event: 'ready', listener: (driver: Driver) => void): nodeEvents.NodeEventEmitter; + interface HarnessEvents extends NodeEventEmitter { + once(event: string, listener: (driver: Driver) => void): NodeEventEmitter; + once(event: 'ready', listener: (driver: Driver) => void): NodeEventEmitter; - on(event: string, listener: (driver: Driver) => void): nodeEvents.NodeEventEmitter; - on(event: 'ready', listener: (driver: Driver) => void): nodeEvents.NodeEventEmitter; + on(event: string, listener: (driver: Driver) => void): NodeEventEmitter; + on(event: 'ready', listener: (driver: Driver) => void): NodeEventEmitter; } - interface DriverEvents extends nodeEvents.NodeEventEmitter { - once(event: string, listener: (text: string) => void): nodeEvents.NodeEventEmitter; - once(event: 'console.log', listener: (text: string) => void): nodeEvents.NodeEventEmitter; - once(event: 'console.warn', listener: (text: string) => void): nodeEvents.NodeEventEmitter; - once(event: 'console.error', listener: (text: string) => void): nodeEvents.NodeEventEmitter; - once(event: 'window.onerror', listener: (text: string) => void): nodeEvents.NodeEventEmitter; + interface DriverEvents extends NodeEventEmitter { + once(event: string, listener: (text: string) => void): NodeEventEmitter; + once(event: 'console.log', listener: (text: string) => void): NodeEventEmitter; + once(event: 'console.warn', listener: (text: string) => void): NodeEventEmitter; + once(event: 'console.error', listener: (text: string) => void): NodeEventEmitter; + once(event: 'window.onerror', listener: (text: string) => void): NodeEventEmitter; - on(event: string, listener: (text: string) => void): nodeEvents.NodeEventEmitter; - on(event: 'console.log', listener: (text: string) => void): nodeEvents.NodeEventEmitter; - on(event: 'console.warn', listener: (text: string) => void): nodeEvents.NodeEventEmitter; - on(event: 'console.error', listener: (text: string) => void): nodeEvents.NodeEventEmitter; - on(event: 'window.onerror', listener: (text: string) => void): nodeEvents.NodeEventEmitter; + on(event: string, listener: (text: string) => void): NodeEventEmitter; + on(event: 'console.log', listener: (text: string) => void): NodeEventEmitter; + on(event: 'console.warn', listener: (text: string) => void): NodeEventEmitter; + on(event: 'console.error', listener: (text: string) => void): NodeEventEmitter; + on(event: 'window.onerror', listener: (text: string) => void): NodeEventEmitter; } export interface Driver { diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts index d66bf5a5f4..e725de98c8 100644 --- a/browserify/browserify.d.ts +++ b/browserify/browserify.d.ts @@ -5,7 +5,7 @@ /// -interface BrowserifyObject extends EventEmitter { +interface BrowserifyObject extends NodeEventEmitter { add(file: string): BrowserifyObject; require(file: string, opts?: { expose: string; @@ -31,6 +31,6 @@ declare module "browserify" { entries?: string[]; noParse?: string[]; }): BrowserifyObject; - + export = browserify; } \ No newline at end of file diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 14d488bd3a..c0d567bb78 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -124,7 +124,7 @@ declare module jake{ * @event stderr When the stderr for the child-process recieves data. This streams the stderr data. Passes one arg, the chunk of data. * @event error When a shell-command */ - export interface Exec extends EventEmitter{ + export interface Exec extends NodeEventEmitter { constructor(cmds:string[], callback?:()=>void, opts?:ExecOptions); constructor(cmds:string[], opts?:ExecOptions, callback?:()=>void); constructor(cmds:string, callback?:()=>void, opts?:ExecOptions); @@ -182,7 +182,7 @@ declare module jake{ * * @event complete */ - export class Task implements EventEmitter { + export class Task implements NodeEventEmitter { /** * @name name The name of the Task * @param prereqs Prerequisites to be run before this task @@ -201,11 +201,11 @@ declare module jake{ */ reenable(): void; - addListener(event: string, listener: Function): EventEmitter; - on(event: string, listener: Function): EventEmitter; - once(event: string, listener: Function): EventEmitter; - removeListener(event: string, listener: Function): EventEmitter; - removeAllListeners(event?: string): EventEmitter; + addListener(event: string, listener: Function): NodeEventEmitter; + on(event: string, listener: Function): NodeEventEmitter; + once(event: string, listener: Function): NodeEventEmitter; + removeListener(event: string, listener: Function): NodeEventEmitter; + removeAllListeners(event?: string): NodeEventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; emit(event: string, arg1?: any, arg2?: any): boolean; diff --git a/msnodesql/msnodesql.d.ts b/msnodesql/msnodesql.d.ts index 744db70f24..cadb323dbc 100644 --- a/msnodesql/msnodesql.d.ts +++ b/msnodesql/msnodesql.d.ts @@ -55,5 +55,5 @@ declare module "msnodesql" { close(immediately: boolean, callback?: ErrorCallback); } - interface StreamEvents extends EventEmitter { } + interface StreamEvents extends NodeEventEmitter { } } \ No newline at end of file diff --git a/node/node.d.ts b/node/node.d.ts index 7c4d035d6a..8801de5b2c 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -78,18 +78,31 @@ interface ErrnoException extends Error { syscall?: string; } -interface EventEmitter { - addListener(event: string, listener: Function): EventEmitter; - on(event: string, listener: Function): EventEmitter; - once(event: string, listener: Function): EventEmitter; - removeListener(event: string, listener: Function): EventEmitter; - removeAllListeners(event?: string): EventEmitter; +interface NodeEventEmitter { + addListener(event: string, listener: Function): NodeEventEmitter; + on(event: string, listener: Function): NodeEventEmitter; + once(event: string, listener: Function): NodeEventEmitter; + removeListener(event: string, listener: Function): NodeEventEmitter; + removeAllListeners(event?: string): NodeEventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; } -interface WritableStream extends EventEmitter { +interface ReadableStream extends NodeEventEmitter { + readable: boolean; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: NodeBuffer): void; + wrap(oldStream: ReadableStream): ReadableStream; +} + +interface WritableStream extends NodeEventEmitter { writable: boolean; write(buffer: NodeBuffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; @@ -98,20 +111,11 @@ interface WritableStream extends EventEmitter { end(buffer: NodeBuffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; - destroy(): void; - destroySoon(): void; } -interface ReadableStream extends EventEmitter { - readable: boolean; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - destroy(): void; - pipe(destination: T, options?: { end?: boolean; }): T; -} +interface ReadWriteStream extends ReadableStream, WritableStream { } -interface NodeProcess extends EventEmitter { +interface NodeProcess extends NodeEventEmitter { stdout: WritableStream; stderr: WritableStream; stdin: ReadableStream; @@ -228,17 +232,6 @@ declare module "querystring" { } declare module "events" { - export interface NodeEventEmitter { - addListener(event: string, listener: Function): NodeEventEmitter; - on(event: string, listener: Function): NodeEventEmitter; - once(event: string, listener: Function): NodeEventEmitter; - removeListener(event: string, listener: Function): NodeEventEmitter; - removeAllListeners(event?: string): NodeEventEmitter; - setMaxListeners(n: number): void; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - } - export class EventEmitter implements NodeEventEmitter { static listenerCount(emitter: EventEmitter, event: string): number; @@ -258,14 +251,14 @@ declare module "http" { import net = require("net"); import stream = require("stream"); - export interface Server extends events.NodeEventEmitter { + export interface Server extends NodeEventEmitter { listen(port: number, hostname?: string, backlog?: number, callback?: Function): void; listen(path: string, callback?: Function): void; listen(handle: any, listeningListener?: Function): void; close(cb?: any): void; maxHeadersCount: number; } - export interface ServerRequest extends events.NodeEventEmitter, stream.ReadableStream { + export interface ServerRequest extends NodeEventEmitter, ReadableStream { method: string; url: string; headers: any; @@ -276,7 +269,7 @@ declare module "http" { resume(): void; connection: net.NodeSocket; } - export interface ServerResponse extends events.NodeEventEmitter, stream.WritableStream { + export interface ServerResponse extends NodeEventEmitter, WritableStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; write(buffer: NodeBuffer): boolean; @@ -293,7 +286,7 @@ declare module "http" { addTrailers(headers: any): void; end(data?: any, encoding?: string): void; } - export interface ClientRequest extends events.NodeEventEmitter, stream.WritableStream { + export interface ClientRequest extends NodeEventEmitter, WritableStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; write(buffer: NodeBuffer): boolean; @@ -305,7 +298,7 @@ declare module "http" { setNoDelay(noDelay?: Function): void; setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; } - export interface ClientResponse extends events.NodeEventEmitter, stream.ReadableStream { + export interface ClientResponse extends NodeEventEmitter, ReadableStream { statusCode: number; httpVersion: string; headers: any; @@ -368,13 +361,13 @@ declare module "zlib" { import stream = require("stream"); export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } - export interface Gzip extends stream.ReadWriteStream { } - export interface Gunzip extends stream.ReadWriteStream { } - export interface Deflate extends stream.ReadWriteStream { } - export interface Inflate extends stream.ReadWriteStream { } - export interface DeflateRaw extends stream.ReadWriteStream { } - export interface InflateRaw extends stream.ReadWriteStream { } - export interface Unzip extends stream.ReadWriteStream { } + export interface Gzip extends ReadWriteStream { } + export interface Gunzip extends ReadWriteStream { } + export interface Deflate extends ReadWriteStream { } + export interface Inflate extends ReadWriteStream { } + export interface DeflateRaw extends ReadWriteStream { } + export interface InflateRaw extends ReadWriteStream { } + export interface Unzip extends ReadWriteStream { } export function createGzip(options?: ZlibOptions): Gzip; export function createGunzip(options?: ZlibOptions): Gunzip; @@ -490,8 +483,8 @@ declare module "https" { }; export interface Server extends tls.Server { } export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: events.NodeEventEmitter) =>void ): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: events.NodeEventEmitter) =>void ): http.ClientRequest; + export function request(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; export var globalAgent: NodeAgent; } @@ -514,8 +507,8 @@ declare module "repl" { export interface ReplOptions { prompt?: string; - input?: stream.ReadableStream; - output?: stream.WritableStream; + input?: ReadableStream; + output?: WritableStream; terminal?: boolean; eval?: Function; useColors?: boolean; @@ -523,14 +516,14 @@ declare module "repl" { ignoreUndefined?: boolean; writer?: Function; } - export function start(options: ReplOptions): events.NodeEventEmitter; + export function start(options: ReplOptions): NodeEventEmitter; } declare module "readline" { import events = require("events"); import stream = require("stream"); - export interface ReadLine extends events.NodeEventEmitter { + export interface ReadLine extends NodeEventEmitter { setPrompt(prompt: string, length: number): void; prompt(preserveCursor?: boolean): void; question(query: string, callback: Function): void; @@ -540,8 +533,8 @@ declare module "readline" { write(data: any, key?: any): void; } export interface ReadLineOptions { - input: stream.ReadableStream; - output: stream.WritableStream; + input: ReadableStream; + output: WritableStream; completer?: Function; terminal?: boolean; } @@ -565,10 +558,10 @@ declare module "child_process" { import events = require("events"); import stream = require("stream"); - export interface ChildProcess extends events.NodeEventEmitter { - stdin: stream.WritableStream; - stdout: stream.ReadableStream; - stderr: stream.ReadableStream; + export interface ChildProcess extends NodeEventEmitter { + stdin: WritableStream; + stdout: ReadableStream; + stderr: ReadableStream; pid: number; kill(signal?: string): void; send(message: any, sendHandle: any): void; @@ -658,7 +651,7 @@ declare module "dns" { declare module "net" { import stream = require("stream"); - export interface NodeSocket extends stream.ReadWriteStream { + export interface NodeSocket extends ReadWriteStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; write(buffer: NodeBuffer): boolean; @@ -713,7 +706,7 @@ declare module "dgram" { export function createSocket(type: string, callback?: Function): Socket; - interface Socket extends events.NodeEventEmitter { + interface Socket extends NodeEventEmitter { send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; close(): void; @@ -752,12 +745,12 @@ declare module "fs" { ctime: Date; } - interface FSWatcher extends EventEmitter { + interface FSWatcher extends NodeEventEmitter { close(): void; } - export interface ReadStream extends stream.ReadableStream { } - export interface WriteStream extends stream.WritableStream { } + export interface ReadStream extends ReadableStream { } + export interface WriteStream extends WritableStream { } export function rename(oldPath: string, newPath: string, callback?: (err?: ErrnoException) => void): void; export function renameSync(oldPath: string, newPath: string): void; @@ -946,7 +939,7 @@ declare module "tls" { connections: number; } - export interface ClearTextStream extends stream.ReadWriteStream { + export interface ClearTextStream extends ReadWriteStream { authorized: boolean; authorizationError: Error; getPeerCertificate(): any; @@ -1044,26 +1037,6 @@ declare module "crypto" { declare module "stream" { import events = require("events"); - export interface WritableStream extends events.NodeEventEmitter { - writable: boolean; - write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; - end(): void; - end(str: string, enconding: string): void; - end(buffer: NodeBuffer): void; - destroy(): void; - destroySoon(): void; - } - - export interface ReadableStream extends events.NodeEventEmitter { - readable: boolean; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - destroy(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - } - export interface ReadableOptions { highWaterMark?: number; encoding?: string; @@ -1073,16 +1046,87 @@ declare module "stream" { export class Readable extends events.EventEmitter implements ReadableStream { readable: boolean; constructor(opts?: ReadableOptions); + _read(size: number): void; + read(size?: number): any; setEncoding(encoding: string): void; pause(): void; resume(): void; - destroy(): void; pipe(destination: T, options?: { end?: boolean; }): T; - _read(): void; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: NodeBuffer): void; + wrap(oldStream: ReadableStream): ReadableStream; push(chunk: any, encoding?: string): boolean; } - export interface ReadWriteStream extends ReadableStream, WritableStream { } + export interface WritableOptions { + highWaterMark?: number; + decodeStrings?: boolean; + } + + export class Writable extends events.EventEmitter implements WritableStream { + writable: boolean; + constructor(opts?: WritableOptions); + _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: string, encoding: string, callback: Function): void; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean; + } + + // Note: Duplex extends both Readable and Writable. + export class Duplex extends Readable implements ReadWriteStream { + writable: boolean; + constructor(opts?: DuplexOptions); + _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: string, encoding: string, callback: Function): void; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export interface TransformOptions extends ReadableOptions, WritableOptions {} + + // Note: Transform lacks the _read and _write methods of Readable/Writable. + export class Transform extends events.EventEmitter implements ReadWriteStream { + readable: boolean; + writable: boolean; + constructor(opts?: TransformOptions); + _transform(chunk: NodeBuffer, encoding: string, callback: Function): void; + _transform(chunk: string, encoding: string, callback: Function): void; + _flush(callback: Function): void; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: NodeBuffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + push(chunk: any, encoding?: string): boolean; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export class PassThrough extends Transform {} } declare module "util" { @@ -1147,7 +1191,7 @@ declare module "assert" { export function ifError(value: any): void; } - + export = internal; } @@ -1170,8 +1214,8 @@ declare module "domain" { export class Domain extends events.EventEmitter { run(fn: Function): void; - add(emitter: events.NodeEventEmitter): void; - remove(emitter: events.NodeEventEmitter): void; + add(emitter: NodeEventEmitter): void; + remove(emitter: NodeEventEmitter): void; bind(cb: (err: Error, data: any) => any): any; intercept(cb: (data: any) => any): any; dispose(): void; diff --git a/through/through.d.ts b/through/through.d.ts index 7d2adce5ee..8a617c4241 100644 --- a/through/through.d.ts +++ b/through/through.d.ts @@ -15,7 +15,7 @@ declare module "through" { }): through.ThroughStream; module through { - export interface ThroughStream extends Stream.ReadWriteStream { + export interface ThroughStream extends ReadWriteStream { autoDestroy: boolean; } } From 80cbd12aaeae90ca444161862f5fa979828e91e1 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Wed, 5 Feb 2014 20:32:04 +0100 Subject: [PATCH 118/240] Update SinonJS Definitions to 1.8.1 --- sinon/sinon.d.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/sinon/sinon.d.ts b/sinon/sinon.d.ts index 7d207ef2ac..f9b33c082c 100644 --- a/sinon/sinon.d.ts +++ b/sinon/sinon.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Sinon 1.5 +// Type definitions for Sinon 1.8.1 // Project: http://sinonjs.org/ // Definitions by: William Sears // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped @@ -189,6 +189,19 @@ interface SinonStatic { clock: SinonFakeTimers; } +interface SinonFakeUploadProgress { + eventListeners: { + progress: any[]; + load: any[]; + abort: any[]; + error: any[]; + }; + + addEventListener(event: string, listener: (e: Event) => any): void; + removeEventListener(event: string, listener: (e: Event) => any): void; + dispatchEvent(event: Event): void; +} + interface SinonFakeXMLHttpRequest { // Properties onCreate: (xhr: SinonFakeXMLHttpRequest) => void; @@ -200,7 +213,9 @@ interface SinonFakeXMLHttpRequest { statusText: string; async: boolean; username: string; - password: string; + password: string; + withCredentials: boolean; + upload: SinonFakeUploadProgress; responseXML: Document; getResponseHeader(header: string): string; getAllResponseHeaders(): any; @@ -378,15 +393,17 @@ interface SinonTestWrapper extends SinonSandbox { } interface SinonStatic { - config: SinonTestConfig; - test(fn: (...args: any[]) => any): SinonTestWrapper; - testCase(tests: any): any; + config: SinonTestConfig; + test(fn: (...args: any[]) => any): SinonTestWrapper; + testCase(tests: any): any; } // Utility overridables interface SinonStatic { + createStubInstance: (constructor: any) => SinonStub; format: (obj: any) => string; log: (message: string) => void; + restore(object: any): void; } declare var sinon: SinonStatic; From f1710f41320db8403d62920fab12e2208bb40fe0 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Wed, 5 Feb 2014 21:11:40 +0100 Subject: [PATCH 119/240] Update ShouldJS Definitions to 3.1.2 --- should/should.d.ts | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/should/should.d.ts b/should/should.d.ts index 7241c0389b..b3c37846a2 100644 --- a/should/should.d.ts +++ b/should/should.d.ts @@ -1,6 +1,6 @@ -// Type definitions for should.js 1.2.2 +// Type definitions for should.js 3.1.2 // Project: https://github.com/visionmedia/should.js -// Definitions by: Alex Varju +// Definitions by: Alex Varju and Maxime LUCE (1.3+) // Definitions: https://github.com/borisyankov/DefinitelyTyped interface Object { @@ -9,12 +9,13 @@ interface Object { interface ShouldAssertion { // basic grammar + a: ShouldAssertion; an: ShouldAssertion; - // a: ShouldAssertion; and: ShouldAssertion; be: ShouldAssertion; have: ShouldAssertion; with: ShouldAssertion; + of: ShouldAssertion; not: ShouldAssertion; // validators @@ -23,31 +24,58 @@ interface ShouldAssertion { ok: ShouldAssertion; true: ShouldAssertion; false: ShouldAssertion; + NaN: ShouldAssertion; + Infinity: ShouldAssertion; + Array: ShouldAssertion; + Object: ShouldAssertion; + String: ShouldAssertion; + Boolean: ShouldAssertion; + Number: ShouldAssertion; + Error: ShouldAssertion; + Function: ShouldAssertion; eql(expected: any, description?: string): ShouldAssertion; equal(expected: any, description?: string): ShouldAssertion; within(start: number, finish: number, description?: string): ShouldAssertion; approximately(value: number, delta: number, description?: string): ShouldAssertion; - a(expected: any, description?: string): ShouldAssertion; + type(expected: any, description?: string): ShouldAssertion; instanceof(constructor: Function, description?: string): ShouldAssertion; above(n: number, description?: string): ShouldAssertion; below(n: number, description?: string): ShouldAssertion; + match(other: {}, description?: string): ShouldAssertion; + match(other: (val: any) => any, description?: string): ShouldAssertion; match(regexp: RegExp, description?: string): ShouldAssertion; + match(other: any, description?: string): ShouldAssertion; + matchEach(other: {}, description?: string): ShouldAssertion; + matchEach(other: (val: any) => any, description?: string): ShouldAssertion; + matchEach(regexp: RegExp, description?: string): ShouldAssertion; + matchEach(other: any, description?: string): ShouldAssertion; length(n: number, description?: string): ShouldAssertion; property(name: string, description?: string): ShouldAssertion; property(name: string, val: any, description?: string): ShouldAssertion; + properties(names: string[]): ShouldAssertion; + properties(name: string): ShouldAssertion; + properties(descriptor: any): ShouldAssertion; + properties(...properties: string[]): ShouldAssertion; ownProperty(name: string, description?: string): ShouldAssertion; - include(obj: any, description?: string): ShouldAssertion; - includeEql(obj: any[], description?: string): ShouldAssertion; contain(obj: any): ShouldAssertion; + containEql(obj: any): ShouldAssertion; + containDeep(obj: any): ShouldAssertion; keys(...allKeys: string[]): ShouldAssertion; keys(allKeys: string[]): ShouldAssertion; header(field: string, val?: string): ShouldAssertion; status(code: number): ShouldAssertion; json: ShouldAssertion; html: ShouldAssertion; + startWith(expected: string, message?: any): ShouldAssertion; + endWith(expected: string, message?: any): ShouldAssertion; throw(message?: any): ShouldAssertion; + // deprecated + include(obj: any, description?: string): ShouldAssertion; + includeEql(obj: any[], description?: string): ShouldAssertion; + // aliases + exactly(expected: any, description?: string): ShouldAssertion; instanceOf(constructor: Function, description?: string): ShouldAssertion; throwError(message?: any): ShouldAssertion; lengthOf(n: number, description?: string): ShouldAssertion; @@ -65,6 +93,8 @@ interface ShouldInternal { } interface Internal extends ShouldInternal { + (obj: any): ShouldAssertion; + // node.js's assert functions fail(actual: any, expected: any, message: string, operator: string): void; assert(value: any, message: string): void; @@ -78,8 +108,11 @@ interface Internal extends ShouldInternal { throws(block: any, error?: any, message?: string): void; doesNotThrow(block: any, message?: string): void; ifError(value: any): void; + inspect(value: any, obj: any): any; } declare module "should" { export = Internal; } + +declare var should: Internal; From 1ebbf6506c9d4eb49cca49b790e87ff7f6e54057 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Wed, 5 Feb 2014 21:16:03 +0100 Subject: [PATCH 120/240] Update tests to match breaking changes --- should/should-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/should/should-tests.ts b/should/should-tests.ts index c390aa323c..e88c6f1447 100644 --- a/should/should-tests.ts +++ b/should/should-tests.ts @@ -41,7 +41,7 @@ should.not.exist({}); user.should.have.property('pets').with.lengthOf(4); user.pets.should.have.lengthOf(4); -user.should.be.a('object').and.have.property('name', 'tj'); +user.should.be.of.type('object').and.have.property('name', 'tj'); 'foo'.should.equal('bar'); @@ -89,8 +89,8 @@ args.should.be.arguments; user.age.should.be.within(5, 50); -user.should.be.a('object'); -'test'.should.be.a('string'); +user.should.be.of.type('object'); +'test'.should.be.of.type('string'); user.should.be.an.instanceof(User); ['a'].should.be.an.instanceOf(Array); From 8200340199a42bf736d9e1c5aa6dfa512e5d829a Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Wed, 5 Feb 2014 21:32:39 +0100 Subject: [PATCH 121/240] Update Mocha Definitions to 1.17.1 --- mocha/mocha.d.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts index bf930d3b07..9b55761c6f 100644 --- a/mocha/mocha.d.ts +++ b/mocha/mocha.d.ts @@ -1,4 +1,4 @@ -// Type definitions for mocha 1.9.0 +// Type definitions for mocha 1.17.1 // Project: http://visionmedia.github.io/mocha/ // Definitions by: Kazi Manzur Rashid // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped @@ -46,12 +46,12 @@ interface MochaSetupOptions { grep?: any; } -declare module mocha { - interface Done { - (error?: Error): void; - } +interface MochaDone { + (error?: Error): void; } +declare var mocha: Mocha; + declare var describe : { (description: string, spec: () => void): void; only(description: string, spec: () => void): void; @@ -61,42 +61,42 @@ declare var describe : { declare var it: { (expectation: string, assertion?: () => void): void; - (expectation: string, assertion?: (done: mocha.Done) => void): void; + (expectation: string, assertion?: (done: MochaDone) => void): void; only(expectation: string, assertion?: () => void): void; - only(expectation: string, assertion?: (done: mocha.Done) => void): void; + only(expectation: string, assertion?: (done: MochaDone) => void): void; skip(expectation: string, assertion?: () => void): void; - skip(expectation: string, assertion?: (done: mocha.Done) => void): void; + skip(expectation: string, assertion?: (done: MochaDone) => void): void; timeout(ms: number): void; }; declare function before(action: () => void): void; -declare function before(action: (done: mocha.Done) => void): void; +declare function before(action: (done: MochaDone) => void): void; declare function setup(action: () => void): void; -declare function setup(action: (done: mocha.Done) => void): void; +declare function setup(action: (done: MochaDone) => void): void; declare function after(action: () => void): void; -declare function after(action: (done: mocha.Done) => void): void; +declare function after(action: (done: MochaDone) => void): void; declare function teardown(action: () => void): void; -declare function teardown(action: (done: mocha.Done) => void): void; +declare function teardown(action: (done: MochaDone) => void): void; declare function beforeEach(action: () => void): void; -declare function beforeEach(action: (done: mocha.Done) => void): void; +declare function beforeEach(action: (done: MochaDone) => void): void; declare function suiteSetup(action: () => void): void; -declare function suiteSetup(action: (done: mocha.Done) => void): void; +declare function suiteSetup(action: (done: MochaDone) => void): void; declare function afterEach(action: () => void): void; -declare function afterEach(action: (done: mocha.Done) => void): void; +declare function afterEach(action: (done: MochaDone) => void): void; declare function suiteTeardown(action: () => void): void; -declare function suiteTeardown(action: (done: mocha.Done) => void): void; +declare function suiteTeardown(action: (done: MochaDone) => void): void; From 24287527f2b1dc2e6a6a449dda4fa74003117409 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Wed, 5 Feb 2014 21:34:50 +0100 Subject: [PATCH 122/240] Update Test to remove global var as defined in Definitions --- mocha/mocha-tests.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index 19c869c136..597d9cbe2c 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -1,7 +1,5 @@ /// -var mocha: Mocha; - function test_describe() { describe('something', () => { }); From 47e3a9ff854d8b153d315a7068bbd972e48e9e91 Mon Sep 17 00:00:00 2001 From: Paul Vick Date: Thu, 6 Feb 2014 10:51:54 -0800 Subject: [PATCH 123/240] Fix typo in jake. --- jake/jake.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jake/jake.d.ts b/jake/jake.d.ts index c0d567bb78..349e08e52c 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -174,7 +174,7 @@ declare module jake{ * Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. * @default false */ - asyc?: boolean; + async?: boolean; } /** @@ -225,7 +225,7 @@ declare module jake{ * Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. * @default false */ - asyc?: boolean; + async?: boolean; } export class FileTask{ From 5e8c4eee7caff334ba7e23f66b66f2620de54c11 Mon Sep 17 00:00:00 2001 From: Magnus Gustafsson Date: Thu, 6 Feb 2014 22:57:08 +0000 Subject: [PATCH 124/240] Removed local README file and added contributor to global README --- README.md | 1 + easystarjs/README.md | 61 -------------------------------------------- 2 files changed, 1 insertion(+), 61 deletions(-) delete mode 100755 easystarjs/README.md diff --git a/README.md b/README.md index ab4a8cdaef..5a392b2ac4 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ List of Definitions * [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) * [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) diff --git a/easystarjs/README.md b/easystarjs/README.md deleted file mode 100755 index 4066f9b37e..0000000000 --- a/easystarjs/README.md +++ /dev/null @@ -1,61 +0,0 @@ -easystarjs.d.ts -=========== - -This is a typescript definitions file for EasyStar.js located here: https://github.com/prettymuchbryce/easystarjs -Main site: http://easystarjs.com/ - -Basic Usage -========== - -Import Statements ------------------ - -Reference the easystarjs.d.ts file in your project and include the following import statement - -```typescript -/// - -// Include the following import -import EasyStar = require("easystarjs"); -``` - -See tests for further details on how to use this library. - -Change Log -========== - -1.0 2014/02/02 ---------------- -* First version for EasyStar.js 0.1.6 - - -License -======= - -easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson -This definitions file is for EasyStar.js -> - https://github.com/prettymuchbryce/easystarjs - - - -EasyStar.js Copyright (c) 2012-2013 Bryce Neal - -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file From e4f5bd37381e2dd15efc9c567953bfba54cb0ae5 Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Fri, 7 Feb 2014 11:17:24 +0100 Subject: [PATCH 125/240] Add some definitions to angular scenario --- angularjs/angular-scenario.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-scenario.d.ts b/angularjs/angular-scenario.d.ts index e9f99fc394..ec3efd9f93 100644 --- a/angularjs/angular-scenario.d.ts +++ b/angularjs/angular-scenario.d.ts @@ -3,6 +3,8 @@ // Definitions by: RomanoLindano // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module ng { export interface IAngularStatic { scenario: any; @@ -100,7 +102,11 @@ declare module angularScenario { export interface Element { count(): Future; click(): any; - query(callback: (selectedDOMElements: any[], callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any; + dblclick(): any; + mouseover(): any; + mousedown(): any; + mouseup(): any; + query(callback: (selectedDOMElements: JQuery, callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any; val(): Future; text(): Future; html(): Future; From 0531c60ccdc3241e8a98a8fabcd8fa794b83b731 Mon Sep 17 00:00:00 2001 From: Zsolt Petrik Date: Fri, 7 Feb 2014 13:32:49 +0100 Subject: [PATCH 126/240] Added export as "backbone" module for AMD loading --- backbone/backbone.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index b3b8856e8e..256554774a 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -339,3 +339,7 @@ declare module Backbone { var $: JQueryStatic; } + +declare module "backbone" { + export = Backbone; +} From 5f8252b86c96274dbebf51384ed5957d6b6b9ede Mon Sep 17 00:00:00 2001 From: Sven Date: Mon, 10 Feb 2014 21:01:37 +0100 Subject: [PATCH 127/240] Added getRegion to Marionette.Application --- marionette/marionette.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 52a1bb6ef9..4eb4b0fa4e 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -288,6 +288,7 @@ declare module Marionette { start(options?); addRegions(regions); removeRegion(region: Region); + getRegion(regionName: string): Region; module(moduleNames, moduleDefinition); } From 80f6d4780cfc6f0db8753d8080ad5c0a2dad78e5 Mon Sep 17 00:00:00 2001 From: Sven Date: Mon, 10 Feb 2014 21:02:18 +0100 Subject: [PATCH 128/240] Added AMD support --- marionette/marionette.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 4eb4b0fa4e..b1804485f5 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -307,3 +307,9 @@ declare module Marionette { addDefinition(moduleDefinition, customArgs); } } + +declare module 'backbone.marionette' { + import Backbone = require('backbone'); + + export = Marionette; +} From 5d6afdcd1eac2ff54731f7e1c156567d4bba6573 Mon Sep 17 00:00:00 2001 From: Sven Date: Mon, 10 Feb 2014 21:04:12 +0100 Subject: [PATCH 129/240] Author Tag --- marionette/marionette.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index b1804485f5..dca2915c53 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/marionettejs/ // Definitions by: Zeeshan Hamid // Definitions by: Natan Vivo +// Definitions by: Sven Tschui // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 454666515419b8e0ddb8a0eefa4c50040ed2f904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9nes=20Harmath?= Date: Tue, 11 Feb 2014 01:23:26 +0100 Subject: [PATCH 130/240] Preliminary version of AngularFire definition --- angularfire/angularfire.d.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 angularfire/angularfire.d.ts diff --git a/angularfire/angularfire.d.ts b/angularfire/angularfire.d.ts new file mode 100644 index 0000000000..9a5cefcaea --- /dev/null +++ b/angularfire/angularfire.d.ts @@ -0,0 +1,29 @@ +interface AngularFireService { + (firebase: Firebase): AngularFire; +} + +interface AngularFire { + $add(value: any): void; + $remove(key?: string): void; + $save(key?: string): void; + $child(key: string): AngularFire; + $set(value: any): void; + $getIndex(): number; + $priority: number; + $on(eventType: string, callback: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void; + $off(eventType: string, callback: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void; + $bind($scope: ng.IScope, modelName: string): ng.IPromise; +} + +interface AngularFireAuthService { + (firebase: Firebase): AngularFireAuth; +} + +interface AngularFireAuth { + $getCurrentUser(): ng.IPromise; + $logout(): void; + $createUser(email: string, password: string, noLogin?: boolean): ng.IPromise; + $changePassword(email: string, oldPassword: string, newPassword: string): ng.IPromise; + $removeUser(email: string, password: string): ng.IPromise; + $sendPasswordResetEmail(email: string): ng.IPromise; +} From eb7e941bd8df2f8389cc7fe8f6f373bc452b0e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9nes=20Harmath?= Date: Tue, 11 Feb 2014 01:27:23 +0100 Subject: [PATCH 131/240] Add library reference --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2512630105..317c27f0c8 100755 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ List of Definitions * [Ace Cloud9 Editor](http://ace.ajax.org/) (by [Diullei Gomes](https://github.com/Diullei)) * [Add To Home Screen] (http://cubiq.org/add-to-home-screen) (by [James Wilkins] (http://www.codeplex.com/site/users/view/jamesnw)) * [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/)) +* [AngularFire](https://www.firebase.com/docs/angular/reference.html) (by [Dénes Harmath](https://github.com/thSoft)) * [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) * [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib)) * [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong)) From 1f12c5faaa5cf085a2b91b605d5c8e8e6b54a6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9nes=20Harmath?= Date: Tue, 11 Feb 2014 01:33:29 +0100 Subject: [PATCH 132/240] Provide missing method --- angularfire/angularfire.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angularfire/angularfire.d.ts b/angularfire/angularfire.d.ts index 9a5cefcaea..3cb409fd02 100644 --- a/angularfire/angularfire.d.ts +++ b/angularfire/angularfire.d.ts @@ -21,6 +21,7 @@ interface AngularFireAuthService { interface AngularFireAuth { $getCurrentUser(): ng.IPromise; + $login(provider: string, options?: Object): ng.IPromise; $logout(): void; $createUser(email: string, password: string, noLogin?: boolean): ng.IPromise; $changePassword(email: string, oldPassword: string, newPassword: string): ng.IPromise; From 0aa867fe9aad08e77de3d2038f6fa3995299692c Mon Sep 17 00:00:00 2001 From: scriby Date: Tue, 11 Feb 2014 15:40:08 -0500 Subject: [PATCH 133/240] Add support for app.patch --- express/express.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/express/express.d.ts b/express/express.d.ts index b97888998f..6fc3c0fec2 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -122,6 +122,10 @@ declare module "express" { del(name: string, ...handlers: RequestFunction[]): T; del(name: RegExp, ...handlers: RequestFunction[]): T; + + patch(name: string, ...handlers: RequestFunction[]): T; + + patch(name: RegExp, ...handlers: RequestFunction[]): T; } export class Router implements IRouter { @@ -152,6 +156,10 @@ declare module "express" { del(name: string, ...handlers: RequestFunction[]): Router; del(name: RegExp, ...handlers: RequestFunction[]): Router; + + patch(name: string, ...handlers: RequestFunction[]): Router; + + patch(name: RegExp, ...handlers: RequestFunction[]): Router; } interface Handler { From 13a7504512df7fce4ae29a6c302f13a439bf2d6b Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 12 Feb 2014 12:20:16 +0900 Subject: [PATCH 134/240] Added a new version of TypeScript (59a846d0bb3d532d26d9cc94696d7b7e276e0666) --- .../tests/typescript/0.9.7-59a846/lib.d.ts | 14931 ++++ .../tests/typescript/0.9.7-59a846/tsc | 2 + .../tests/typescript/0.9.7-59a846/tsc.js | 62781 ++++++++++++++++ .../typescript/0.9.7-59a846/typescript.js | 61371 +++++++++++++++ 4 files changed, 139085 insertions(+) create mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts create mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/tsc create mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/tsc.js create mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/typescript.js diff --git a/_infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts b/_infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts new file mode 100644 index 0000000000..94c477fd4a --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts @@ -0,0 +1,14931 @@ +/* ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +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; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +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; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +declare var Function: { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +interface Boolean { +} +declare var Boolean: { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + 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): 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): 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): 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): 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): 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): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + 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): 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): 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): 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): 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): 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): 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. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +declare var Date: { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +interface RegExpExecArray { + [index: number]: string; + length: number; + + index: number; + input: string; + + toString(): string; + toLocaleString(): string; + concat(...items: string[][]): string[]; + join(separator?: string): string; + pop(): string; + push(...items: string[]): number; + reverse(): string[]; + shift(): 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[]; + unshift(...items: string[]): number; + + indexOf(searchElement: string, fromIndex?: number): number; + lastIndexOf(searchElement: string, fromIndex?: number): number; + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; + map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; + filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; + reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; + reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +} + + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + 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. + */ + test(string: string): boolean; + + /** 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; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} +declare var RegExp: { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +interface Error { + name: string; + message: string; +} +declare var Error: { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +interface EvalError extends Error { +} +declare var EvalError: { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +interface RangeError extends Error { +} +declare var RangeError: { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +interface ReferenceError extends Error { +} +declare var ReferenceError: { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +interface SyntaxError extends Error { +} +declare var SyntaxError: { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +interface TypeError extends Error { +} +declare var TypeError: { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +interface URIError extends Error { +} +declare var URIError: { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + + [n: number]: T; +} +declare var Array: { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + + +///////////////////////////// +/// IE10 ECMAScript Extensions +///////////////////////////// + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; +} + +declare var ArrayBuffer: { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; +} + +interface ArrayBufferView { + buffer: ArrayBuffer; + byteOffset: number; + byteLength: number; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; +} +declare var Int8Array: { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Uint8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; +} +declare var Uint8Array: { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 16-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; +} +declare var Int16Array: { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Uint16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; +} +declare var Uint16Array: { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; +} +declare var Int32Array: { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; +} +declare var Uint32Array: { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Float32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Float32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; +} +declare var Float32Array: { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Float64Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Float64Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; +} +declare var Float64Array: { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + BYTES_PER_ELEMENT: number; +} + +/** + * You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer. + */ +interface DataView extends ArrayBufferView { + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; +} +declare var DataView: { + prototype: DataView; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; +} + +///////////////////////////// +/// IE11 ECMAScript Extensions +///////////////////////////// + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): Map; + size: number; +} +declare var Map: { + new (): Map; +} + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): WeakMap; +} +declare var WeakMap: { + new (): WeakMap; +} + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + size: number; +} +declare var Set: { + new (): Set; +} + +declare module Intl { + + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): Collator; + new (locale?: string, options?: NumberFormatOptions): Collator; + (locales?: string[], options?: NumberFormatOptions): Collator; + (locale?: string, options?: NumberFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date: number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): Collator; + new (locale?: string, options?: DateTimeFormatOptions): Collator; + (locales?: string[], options?: DateTimeFormatOptions): Collator; + (locale?: string, options?: DateTimeFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + 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; +} + + +///////////////////////////// +/// IE9 DOM APIs +///////////////////////////// + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface NavigatorID { + appVersion: string; + appName: string; + userAgent: string; + platform: string; +} + +interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the amount of space between cells in a table. + */ + cellSpacing: string; + /** + * Retrieves the tFoot object of the table. + */ + tFoot: HTMLTableSectionElement; + /** + * Sets or retrieves the way the border frame around the table is displayed. + */ + frame: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Sets or retrieves which dividing lines (inner borders) are displayed. + */ + rules: string; + /** + * Sets or retrieves the number of columns in the table. + */ + cols: number; + /** + * Sets or retrieves a description and/or structure of the object. + */ + summary: string; + /** + * Retrieves the caption object of a table. + */ + caption: HTMLTableCaptionElement; + /** + * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. + */ + tBodies: HTMLCollection; + /** + * Retrieves the tHead object of the table. + */ + tHead: HTMLTableSectionElement; + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Retrieves a collection of all cells in the table row or in the entire table. + */ + cells: HTMLCollection; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the amount of space between the border of the cell and the content of the cell. + */ + cellPadding: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Creates an empty tBody element in the table. + */ + createTBody(): HTMLElement; + /** + * Deletes the caption element and its contents from the table. + */ + deleteCaption(): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; + /** + * Deletes the tFoot element and its contents from the table. + */ + deleteTFoot(): void; + /** + * Returns the tHead element object if successful, or null otherwise. + */ + createTHead(): HTMLElement; + /** + * Deletes the tHead element and its contents from the table. + */ + deleteTHead(): void; + /** + * Creates an empty caption element in the table. + */ + createCaption(): HTMLElement; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): Object; + /** + * Creates an empty tFoot element in the table. + */ + createTFoot(): HTMLElement; +} +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new (): HTMLTableElement; +} + +interface TreeWalker { + whatToShow: number; + filter: NodeFilter; + root: Node; + currentNode: Node; + expandEntityReferences: boolean; + previousSibling(): Node; + lastChild(): Node; + nextSibling(): Node; + nextNode(): Node; + parentNode(): Node; + firstChild(): Node; + previousNode(): Node; +} +declare var TreeWalker: { + prototype: TreeWalker; + new (): TreeWalker; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new (): SVGPathSegCurvetoQuadraticRel; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + getEntriesByType(entryType: string): any; + toJSON(): any; + getMeasures(measureName?: string): any; + clearMarks(markName?: string): void; + getMarks(markName?: string): any; + clearResourceTimings(): void; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + getEntriesByName(name: string, entryType?: string): any; + getEntries(): any; + clearMeasures(measureName?: string): void; + setResourceTimingBufferSize(maxSize: number): void; +} +declare var Performance: { + prototype: Performance; + new (): Performance; +} + +interface MSDataBindingTableExtensions { + dataPageSize: number; + nextPage(): void; + firstPage(): void; + refresh(): void; + previousPage(): void; + lastPage(): void; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} +declare var CompositionEvent: { + prototype: CompositionEvent; + new (): CompositionEvent; +} + +interface WindowTimers { + clearTimeout(handle: number): void; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; + clearInterval(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { + orientType: SVGAnimatedEnumeration; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + markerHeight: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + refY: SVGAnimatedLength; + refX: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new (): SVGMarkerElement; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} + +interface CSSStyleDeclaration { + backgroundAttachment: string; + visibility: string; + textAlignLast: string; + borderRightStyle: string; + counterIncrement: string; + orphans: string; + cssText: string; + borderStyle: string; + pointerEvents: string; + borderTopColor: string; + markerEnd: string; + textIndent: string; + listStyleImage: string; + cursor: string; + listStylePosition: string; + wordWrap: string; + borderTopStyle: string; + alignmentBaseline: string; + opacity: string; + direction: string; + strokeMiterlimit: string; + maxWidth: string; + color: string; + clip: string; + borderRightWidth: string; + verticalAlign: string; + overflow: string; + mask: string; + borderLeftStyle: string; + emptyCells: string; + stopOpacity: string; + paddingRight: string; + parentRule: CSSRule; + background: string; + boxSizing: string; + textJustify: string; + height: string; + paddingTop: string; + length: number; + right: string; + baselineShift: string; + borderLeft: string; + widows: string; + lineHeight: string; + left: string; + textUnderlinePosition: string; + glyphOrientationHorizontal: string; + display: string; + textAnchor: string; + cssFloat: string; + strokeDasharray: string; + rubyAlign: string; + fontSizeAdjust: string; + borderLeftColor: string; + backgroundImage: string; + listStyleType: string; + strokeWidth: string; + textOverflow: string; + fillRule: string; + borderBottomColor: string; + zIndex: string; + position: string; + listStyle: string; + msTransformOrigin: string; + dominantBaseline: string; + overflowY: string; + fill: string; + captionSide: string; + borderCollapse: string; + boxShadow: string; + quotes: string; + tableLayout: string; + unicodeBidi: string; + borderBottomWidth: string; + backgroundSize: string; + textDecoration: string; + strokeDashoffset: string; + fontSize: string; + border: string; + pageBreakBefore: string; + borderTopRightRadius: string; + msTransform: string; + borderBottomLeftRadius: string; + textTransform: string; + rubyPosition: string; + strokeLinejoin: string; + clipPath: string; + borderRightColor: string; + fontFamily: string; + clear: string; + content: string; + backgroundClip: string; + marginBottom: string; + counterReset: string; + outlineWidth: string; + marginRight: string; + paddingLeft: string; + borderBottom: string; + wordBreak: string; + marginTop: string; + top: string; + fontWeight: string; + borderRight: string; + width: string; + kerning: string; + pageBreakAfter: string; + borderBottomStyle: string; + fontStretch: string; + padding: string; + strokeOpacity: string; + markerStart: string; + bottom: string; + borderLeftWidth: string; + clipRule: string; + backgroundPosition: string; + backgroundColor: string; + pageBreakInside: string; + backgroundOrigin: string; + strokeLinecap: string; + borderTopWidth: string; + outlineStyle: string; + borderTop: string; + outlineColor: string; + paddingBottom: string; + marginLeft: string; + font: string; + outline: string; + wordSpacing: string; + maxHeight: string; + fillOpacity: string; + letterSpacing: string; + borderSpacing: string; + backgroundRepeat: string; + borderRadius: string; + borderWidth: string; + borderBottomRightRadius: string; + whiteSpace: string; + fontStyle: string; + minWidth: string; + stopColor: string; + borderTopLeftRadius: string; + borderColor: string; + marker: string; + glyphOrientationVertical: string; + markerMid: string; + fontVariant: string; + minHeight: string; + stroke: string; + rubyOverhang: string; + overflowX: string; + textAlign: string; + margin: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + removeProperty(propertyName: string): string; + item(index: number): string; + [index: number]: string; + setProperty(propertyName: string, value: string, priority?: string): void; +} +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new (): CSSStyleDeclaration; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGGElement: { + prototype: SVGGElement; + new (): SVGGElement; +} + +interface MSStyleCSSProperties extends MSCSSProperties { + pixelWidth: number; + posHeight: number; + posLeft: number; + pixelTop: number; + pixelBottom: number; + textDecorationNone: boolean; + pixelLeft: number; + posTop: number; + posBottom: number; + textDecorationOverline: boolean; + posWidth: number; + textDecorationLineThrough: boolean; + pixelHeight: number; + textDecorationBlink: boolean; + posRight: number; + pixelRight: number; + textDecorationUnderline: boolean; +} +declare var MSStyleCSSProperties: { + prototype: MSStyleCSSProperties; + new (): MSStyleCSSProperties; +} + +interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils { +} +declare var Navigator: { + prototype: Navigator; + new (): Navigator; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new (): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGZoomEvent extends UIEvent { + zoomRectScreen: SVGRect; + previousScale: number; + newScale: number; + previousTranslate: SVGPoint; + newTranslate: SVGPoint; +} +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new (): SVGZoomEvent; +} + +interface NodeSelector { + querySelectorAll(selectors: string): NodeList; + querySelector(selectors: string): Element; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new (): HTMLTableDataCellElement; +} + +interface HTMLBaseElement extends HTMLElement { + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Gets or sets the baseline URL on which relative links are based. + */ + href: string; +} +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new (): HTMLBaseElement; +} + +interface ClientRect { + left: number; + width: number; + right: number; + top: number; + bottom: number; + height: number; +} +declare var ClientRect: { + prototype: ClientRect; + new (): ClientRect; +} + +interface PositionErrorCallback { + (error: PositionError): void; +} + +interface DOMImplementation { + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + hasFeature(feature: string, version?: string): boolean; + createHTMLDocument(title: string): Document; +} +declare var DOMImplementation: { + prototype: DOMImplementation; + new (): DOMImplementation; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: { + prototype: SVGUnitTypes; + new (): SVGUnitTypes; + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} + +interface Element extends Node, NodeSelector, ElementTraversal { + scrollTop: number; + clientLeft: number; + scrollLeft: number; + tagName: string; + clientWidth: number; + scrollWidth: number; + clientHeight: number; + clientTop: number; + scrollHeight: number; + getAttribute(name?: string): string; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + getBoundingClientRect(): ClientRect; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + msMatchesSelector(selectors: string): boolean; + hasAttribute(name: string): boolean; + removeAttribute(name?: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + getAttributeNode(name: string): Attr; + fireEvent(eventName: string, eventObj?: any): boolean; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "bdi"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "main"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rp"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "source"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "summary"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: string): NodeList; + getClientRects(): ClientRectList; + setAttributeNode(newAttr: Attr): Attr; + removeAttributeNode(oldAttr: Attr): Attr; + setAttribute(name?: string, value?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; +} +declare var Element: { + prototype: Element; + new (): Element; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new (): HTMLNextIdElement; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new (): SVGPathSegMovetoRel; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLineElement: { + prototype: SVGLineElement; + new (): SVGLineElement; +} + +interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; +} +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new (): HTMLParagraphElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + /** + * Removes an element from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + */ + add(element: HTMLElement, before?: any): void; +} +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new (): HTMLAreasCollection; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGDescElement: { + prototype: SVGDescElement; + new (): SVGDescElement; +} + +interface Node extends EventTarget { + nodeType: number; + previousSibling: Node; + localName: string; + namespaceURI: string; + textContent: string; + parentNode: Node; + nextSibling: Node; + nodeValue: string; + lastChild: Node; + childNodes: NodeList; + nodeName: string; + ownerDocument: Document; + attributes: NamedNodeMap; + firstChild: Node; + prefix: string; + removeChild(oldChild: Node): Node; + appendChild(newChild: Node): Node; + isSupported(feature: string, version: string): boolean; + isEqualNode(arg: Node): boolean; + lookupPrefix(namespaceURI: string): string; + isDefaultNamespace(namespaceURI: string): boolean; + compareDocumentPosition(other: Node): number; + normalize(): void; + isSameNode(other: Node): boolean; + hasAttributes(): boolean; + lookupNamespaceURI(prefix: string): string; + cloneNode(deep?: boolean): Node; + hasChildNodes(): boolean; + replaceChild(newChild: Node, oldChild: Node): Node; + insertBefore(newChild: Node, refChild?: Node): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} +declare var Node: { + prototype: Node; + new (): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new (): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface DOML2DeprecatedListSpaceReduction { + compact: boolean; +} + +interface MSScriptHost { +} +declare var MSScriptHost: { + prototype: MSScriptHost; + new (): MSScriptHost; +} + +interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + clipPathUnits: SVGAnimatedEnumeration; +} +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new (): SVGClipPathElement; +} + +interface MouseEvent extends UIEvent { + toElement: Element; + layerY: number; + fromElement: Element; + which: number; + pageX: number; + offsetY: number; + x: number; + y: number; + metaKey: boolean; + altKey: boolean; + ctrlKey: boolean; + offsetX: number; + screenX: number; + clientY: number; + shiftKey: boolean; + layerX: number; + screenY: number; + relatedTarget: EventTarget; + button: number; + pageY: number; + buttons: number; + clientX: number; + initMouseEvent(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): void; + getModifierState(keyArg: string): boolean; +} +declare var MouseEvent: { + prototype: MouseEvent; + new (): MouseEvent; +} + +interface RangeException { + code: number; + message: string; + toString(): string; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} +declare var RangeException: { + prototype: RangeException; + new (): RangeException; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + y: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + dy: SVGAnimatedLengthList; + x: SVGAnimatedLengthList; + dx: SVGAnimatedLengthList; +} +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new (): SVGTextPositioningElement; +} + +interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + width: number; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + object: string; + form: HTMLFormElement; + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. + */ + declare: boolean; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new (): HTMLAppletElement; +} + +interface TextMetrics { + width: number; +} +declare var TextMetrics: { + prototype: TextMetrics; + new (): TextMetrics; +} + +interface DocumentEvent { + createEvent(eventInterface: string): Event; +} + +interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * The starting number. + */ + start: number; +} +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new (): HTMLOListElement; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new (): SVGPathSegLinetoVerticalRel; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new (): SVGAnimatedString; +} + +interface CDATASection extends Text { +} +declare var CDATASection: { + prototype: CDATASection; + new (): CDATASection; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} +declare var StyleMedia: { + prototype: StyleMedia; + new (): StyleMedia; +} + +interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { + options: HTMLSelectElement; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the number of rows in the list box. + */ + size: number; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the index of the selected option in a select object. + */ + selectedIndex: number; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Retrieves the type of select control based on the value of the MULTIPLE attribute. + */ + type: string; + /** + * Removes an element from the collection. + * @param index Number that specifies the zero-based index of the element to remove from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. + * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. + */ + add(element: HTMLElement, before?: any): void; + /** + * Retrieves a select object or an object from an options collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a select object or an object from an options collection. + * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. + */ + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new (): HTMLSelectElement; +} + +interface TextRange { + boundingLeft: number; + htmlText: string; + offsetLeft: number; + boundingWidth: number; + boundingHeight: number; + boundingTop: number; + text: string; + offsetTop: number; + moveToPoint(x: number, y: number): void; + queryCommandValue(cmdID: string): any; + getBookmark(): string; + move(unit: string, count?: number): number; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(fStart?: boolean): void; + findText(string: string, count?: number, flags?: number): boolean; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + getBoundingClientRect(): ClientRect; + moveToBookmark(bookmark: string): boolean; + isEqual(range: TextRange): boolean; + duplicate(): TextRange; + collapse(start?: boolean): void; + queryCommandText(cmdID: string): string; + select(): void; + pasteHTML(html: string): void; + inRange(range: TextRange): boolean; + moveEnd(unit: string, count?: number): number; + getClientRects(): ClientRectList; + moveStart(unit: string, count?: number): number; + parentElement(): Element; + queryCommandState(cmdID: string): boolean; + compareEndPoints(how: string, sourceRange: TextRange): number; + execCommandShowHelp(cmdID: string): boolean; + moveToElementText(element: Element): void; + expand(Unit: string): boolean; + queryCommandSupported(cmdID: string): boolean; + setEndPoint(how: string, SourceRange: TextRange): void; + queryCommandEnabled(cmdID: string): boolean; +} +declare var TextRange: { + prototype: TextRange; + new (): TextRange; +} + +interface SVGTests { + requiredFeatures: SVGStringList; + requiredExtensions: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new (): HTMLBlockElement; +} + +interface CSSStyleSheet extends StyleSheet { + owningElement: Element; + imports: StyleSheetList; + isAlternate: boolean; + rules: MSCSSRuleList; + isPrefAlternate: boolean; + readOnly: boolean; + cssText: string; + ownerRule: CSSRule; + href: string; + cssRules: CSSRuleList; + id: string; + pages: StyleSheetPageList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + insertRule(rule: string, index?: number): number; + removeRule(lIndex: number): void; + deleteRule(index?: number): void; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + removeImport(lIndex: number): void; +} +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new (): CSSStyleSheet; +} + +interface MSSelection { + type: string; + typeDetail: string; + createRange(): TextRange; + clear(): void; + createRangeCollection(): TextRangeCollection; + empty(): void; +} +declare var MSSelection: { + prototype: MSSelection; + new (): MSSelection; +} + +interface HTMLMetaElement extends HTMLElement { + /** + * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. + */ + httpEquiv: string; + /** + * Sets or retrieves the value specified in the content attribute of the meta object. + */ + name: string; + /** + * Gets or sets meta-information to associate with httpEquiv or name. + */ + content: string; + /** + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + */ + url: string; + /** + * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. + */ + scheme: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; +} +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new (): HTMLMetaElement; +} + +interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { + patternUnits: SVGAnimatedEnumeration; + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + height: SVGAnimatedLength; +} +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new (): SVGPatternElement; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new (): SVGAnimatedAngle; +} + +interface Selection { + isCollapsed: boolean; + anchorNode: Node; + focusNode: Node; + anchorOffset: number; + focusOffset: number; + rangeCount: number; + addRange(range: Range): void; + collapseToEnd(): void; + toString(): string; + selectAllChildren(parentNode: Node): void; + getRangeAt(index: number): Range; + collapse(parentNode: Node, offset: number): void; + removeAllRanges(): void; + collapseToStart(): void; + deleteFromDocument(): void; + removeRange(range: Range): void; +} +declare var Selection: { + prototype: Selection; + new (): Selection; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; +} +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new (): SVGScriptElement; +} + +interface HTMLDDElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new (): HTMLDDElement; +} + +interface MSDataBindingRecordSetReadonlyExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface CSSStyleRule extends CSSRule { + selectorText: string; + style: MSStyleCSSProperties; + readOnly: boolean; +} +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new (): CSSStyleRule; +} + +interface NodeIterator { + whatToShow: number; + filter: NodeFilter; + root: Node; + expandEntityReferences: boolean; + nextNode(): Node; + detach(): void; + previousNode(): Node; +} +declare var NodeIterator: { + prototype: NodeIterator; + new (): NodeIterator; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { + viewTarget: SVGStringList; +} +declare var SVGViewElement: { + prototype: SVGViewElement; + new (): SVGViewElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; +} +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new (): HTMLLinkElement; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getTransformToElement(element: SVGElement): SVGMatrix; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; +} +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new (): HTMLFontElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new (): SVGTitleElement; +} + +interface ControlRangeCollection { + length: number; + queryCommandValue(cmdID: string): any; + remove(index: number): void; + add(item: Element): void; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(varargStart?: any): void; + item(index: number): Element; + [index: number]: Element; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + addElement(item: Element): void; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandEnabled(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + select(): void; +} +declare var ControlRangeCollection: { + prototype: ControlRangeCollection; + new (): ControlRangeCollection; +} + +interface MSNamespaceInfo extends MSEventAttachmentTarget { + urn: string; + onreadystatechange: (ev: Event) => any; + name: string; + readyState: string; + doImport(implementationUrl: string): void; +} +declare var MSNamespaceInfo: { + prototype: MSNamespaceInfo; + new (): MSNamespaceInfo; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new (): SVGAnimatedTransformList; +} + +interface HTMLTableCaptionElement extends HTMLElement { + /** + * Sets or retrieves the alignment of the caption or legend. + */ + align: string; + /** + * Sets or retrieves whether the caption appears at the top or bottom of the table. + */ + vAlign: string; +} +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new (): HTMLTableCaptionElement; +} + +interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; + create(): HTMLOptionElement; +} +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new (): HTMLOptionElement; +} + +interface HTMLMapElement extends HTMLElement { + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves a collection of the area objects defined for the given map object. + */ + areas: HTMLAreasCollection; +} +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new (): HTMLMapElement; +} + +interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { + type: string; +} +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new (): HTMLMenuElement; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new (): MouseWheelEvent; +} + +interface SVGFitToViewBox { + viewBox: SVGAnimatedRect; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface SVGPointList { + numberOfItems: number; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; + getItem(index: number): SVGPoint; + clear(): void; + appendItem(newItem: SVGPoint): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + removeItem(index: number): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; +} +declare var SVGPointList: { + prototype: SVGPointList; + new (): SVGPointList; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new (): SVGAnimatedLengthList; +} + +interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers { + ondragend: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + ondragover: (ev: DragEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + screenX: number; + onmouseover: (ev: MouseEvent) => any; + ondragleave: (ev: DragEvent) => any; + history: History; + pageXOffset: number; + name: string; + onafterprint: (ev: Event) => any; + onpause: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + top: Window; + onmousedown: (ev: MouseEvent) => any; + onseeked: (ev: Event) => any; + opener: Window; + onclick: (ev: MouseEvent) => any; + innerHeight: number; + onwaiting: (ev: Event) => any; + ononline: (ev: Event) => any; + ondurationchange: (ev: Event) => any; + frames: Window; + onblur: (ev: FocusEvent) => any; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + outerWidth: number; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + innerWidth: number; + onoffline: (ev: Event) => any; + length: number; + screen: Screen; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onratechange: (ev: Event) => any; + onstorage: (ev: StorageEvent) => any; + onloadstart: (ev: Event) => any; + ondragenter: (ev: DragEvent) => any; + onsubmit: (ev: Event) => any; + self: Window; + document: Document; + onprogress: (ev: any) => any; + ondblclick: (ev: MouseEvent) => any; + pageYOffset: number; + oncontextmenu: (ev: MouseEvent) => any; + onchange: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onplay: (ev: Event) => any; + onerror: ErrorEventHandler; + onplaying: (ev: Event) => any; + parent: Window; + location: Location; + oncanplaythrough: (ev: Event) => any; + onabort: (ev: UIEvent) => any; + onreadystatechange: (ev: Event) => any; + outerHeight: number; + onkeypress: (ev: KeyboardEvent) => any; + frameElement: Element; + onloadeddata: (ev: Event) => any; + onsuspend: (ev: Event) => any; + window: Window; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onselect: (ev: UIEvent) => any; + navigator: Navigator; + styleMedia: StyleMedia; + ondrop: (ev: DragEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onended: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onunload: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + screenY: number; + onmousewheel: (ev: MouseWheelEvent) => any; + onload: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + oninput: (ev: Event) => any; + performance: Performance; + alert(message?: any): void; + scroll(x?: number, y?: number): void; + focus(): void; + scrollTo(x?: number, y?: number): void; + print(): void; + prompt(message?: string, defaul?: string): string; + toString(): string; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + scrollBy(x?: number, y?: number): void; + confirm(message?: string): boolean; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; + showModalDialog(url?: string, argument?: any, options?: any): any; + blur(): void; + getSelection(): Selection; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +} +declare var Window: { + prototype: Window; + new (): Window; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new (): SVGAnimatedPreserveAspectRatio; +} + +interface MSSiteModeEvent extends Event { + buttonID: number; + actionURL: string; +} +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new (): MSSiteModeEvent; +} + +interface DOML2DeprecatedTextFlowControl { + clear: string; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new (): StyleSheetPageList; +} + +interface MSCSSProperties extends CSSStyleDeclaration { + scrollbarShadowColor: string; + scrollbarHighlightColor: string; + layoutGridChar: string; + layoutGridType: string; + textAutospace: string; + textKashidaSpace: string; + writingMode: string; + scrollbarFaceColor: string; + backgroundPositionY: string; + lineBreak: string; + imeMode: string; + msBlockProgression: string; + layoutGridLine: string; + scrollbarBaseColor: string; + layoutGrid: string; + layoutFlow: string; + textKashida: string; + filter: string; + zoom: string; + scrollbarArrowColor: string; + behavior: string; + backgroundPositionX: string; + accelerator: string; + layoutGridMode: string; + textJustifyTrim: string; + scrollbar3dLightColor: string; + msInterpolationMode: string; + scrollbarTrackColor: string; + scrollbarDarkShadowColor: string; + styleFloat: string; + getAttribute(attributeName: string, flags?: number): any; + setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; + removeAttribute(attributeName: string, flags?: number): boolean; +} +declare var MSCSSProperties: { + prototype: MSCSSProperties; + new (): MSCSSProperties; +} + +interface HTMLCollection extends MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Retrieves an object from various collections. + */ + item(nameOrIndex?: any, optionalIndex?: any): Element; + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element; + [name: number]: Element; +} +declare var HTMLCollection: { + prototype: HTMLCollection; + new (): HTMLCollection; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * The original height of the image resource before sizing. + */ + naturalHeight: number; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * The original width of the image resource before sizing. + */ + naturalWidth: number; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: number; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. + */ + longDesc: string; + /** + * Contains the hypertext reference (HREF) of the URL. + */ + href: string; + /** + * Sets or retrieves whether the image is a server-side image map. + */ + isMap: boolean; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + create(): HTMLImageElement; +} +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new (): HTMLImageElement; +} + +interface HTMLAreaElement extends HTMLElement { + /** + * Sets or retrieves the protocol portion of a URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Sets or retrieves the host name part of the location or URL. + */ + hostname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Sets or retrieves the file name or path specified by the object. + */ + pathname: string; + /** + * Sets or retrieves the hostname and port number of the location or URL. + */ + host: string; + /** + * Sets or retrieves the subsection of the href property that follows the number sign (#). + */ + hash: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or gets whether clicks in this region cause action. + */ + noHref: boolean; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new (): HTMLAreaElement; +} + +interface EventTarget { + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; +} + +interface SVGAngle { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} +declare var SVGAngle: { + prototype: SVGAngle; + new (): SVGAngle; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} + +interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the default or selected value of the control. + */ + value: string; + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets the classification and default behavior of the button. + */ + type: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; +} +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new (): HTMLButtonElement; +} + +interface HTMLSourceElement extends HTMLElement { + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the intended media type of the media source. + */ + media: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; +} +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new (): HTMLSourceElement; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} +declare var CanvasGradient: { + prototype: CanvasGradient; + new (): CanvasGradient; +} + +interface KeyboardEvent extends UIEvent { + location: number; + keyCode: number; + shiftKey: boolean; + which: number; + locale: string; + key: string; + altKey: boolean; + metaKey: boolean; + char: string; + ctrlKey: boolean; + repeat: boolean; + charCode: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new (): KeyboardEvent; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} + +interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions { + /** + * Retrieves the collection of user agents and versions declared in the X-UA-Compatible + */ + compatible: MSCompatibleInfoCollection; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (ev: KeyboardEvent) => any; + + /** + * Gets the implementation object of the current document. + */ + implementation: DOMImplementation; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (ev: Event) => any; + + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollection; + + /** + * Fires when the user presses the F1 key while the browser is the active window. + * @param ev The event. + */ + onhelp: (ev: Event) => any; + + /** + * 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; + + /** + * Gets or sets the character set used to encode the object. + */ + charset: string; + + /** + * Fires for an element just prior to setting focus on that element. + * @param ev The focus event + */ + onfocusin: (ev: FocusEvent) => any; + + + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (ev: Event) => any; + + security: string; + + /** + * Contains the title of the document. + */ + title: string; + + /** + * Retrieves a collection of namespace objects. + */ + namespaces: MSNamespaceInfoCollection; + + /** + * Gets the default character set from the current regional language settings. + */ + defaultCharset: string; + + /** + * Retrieves a collection of all embed objects in the document. + */ + embeds: HTMLCollection; + + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + styleSheets: StyleSheetList; + + /** + * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. + */ + frames: Window; + + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (ev: Event) => any; + + + /** + * Returns a reference to the collection of elements contained by the object. + */ + all: HTMLCollection; + + /** + * Retrieves a collection, in source order, of all form objects in the document. + */ + forms: HTMLCollection; + + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (ev: FocusEvent) => any; + + + /** + * Sets or retrieves a value that indicates the reading order of the object. + */ + dir: string; + + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (ev: Event) => any; + + + /** + * Sets or gets a value that indicates whether the document can be edited. + */ + designMode: string; + + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (ev: Event) => any; + + + /** + * Fires when the activeElement is changed from the current object to another object in the parent document. + * @param ev The UI Event + */ + ondeactivate: (ev: UIEvent) => any; + + + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (ev: Event) => any; + + + /** + * Fires when the data set exposed by a data source object changes. + * @param ev The event. + */ + ondatasetchanged: (ev: MSEventObj) => any; + + + /** + * Fires when rows are about to be deleted from the recordset. + * @param ev The event + */ + onrowsdelete: (ev: MSEventObj) => any; + + Script: MSScriptHost; + + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (ev: Event) => any; + + + /** + * Gets the URL for the document, stripped of any character encoding. + */ + URLUnencoded: string; + + defaultView: Window; + + /** + * Fires when the user is about to make a control selection of the object. + * @param ev The event. + */ + oncontrolselect: (ev: MSEventObj) => any; + + + /** + * Fires on the target element when the user drags the object to a valid drop target. + * @param ev The drag event. + */ + ondragenter: (ev: DragEvent) => any; + + onsubmit: (ev: Event) => any; + + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + inputEncoding: string; + + /** + * Gets the object that has the focus when the parent document has focus. + */ + activeElement: Element; + + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (ev: Event) => any; + + + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + */ + links: HTMLCollection; + + /** + * Retrieves an autogenerated, unique identifier for the object. + */ + uniqueID: string; + + /** + * Sets or gets the URL for the current document. + */ + URL: string; + + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (ev: UIEvent) => any; + + head: HTMLHeadElement; + cookie: string; + xmlEncoding: string; + oncanplaythrough: (ev: Event) => any; + + /** + * Retrieves the document compatibility mode of the document. + */ + documentMode: number; + + characterSet: string; + + /** + * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. + */ + anchors: HTMLCollection; + + onbeforeupdate: (ev: MSEventObj) => any; + + /** + * Fires to indicate that all data is available from the data source object. + * @param ev The event. + */ + ondatasetcomplete: (ev: MSEventObj) => any; + + plugins: HTMLCollection; + + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (ev: Event) => any; + + + /** + * Gets the root svg element in the document hierarchy. + */ + rootElement: SVGSVGElement; + + /** + * Retrieves a value that indicates the current state of the object. + */ + readyState: string; + + /** + * Gets the URL of the location that referred the user to the current page. + */ + referrer: string; + + /** + * Sets or gets the color of all active links in the document. + */ + alinkColor: string; + + /** + * Fires on a databound object when an error occurs while updating the associated data in the data source object. + * @param ev The event. + */ + onerrorupdate: (ev: MSEventObj) => any; + + + /** + * Gets a reference to the container object of the window. + */ + parentWindow: Window; + + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (ev: MouseEvent) => any; + + + /** + * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. + * @param ev The event. + */ + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + + + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (ev: MouseWheelEvent) => any; + + + /** + * Occurs when the volume is changed, or playback is muted or unmuted. + * @param ev The event. + */ + onvolumechange: (ev: Event) => any; + + + /** + * Fires when data changes in the data provider. + * @param ev The event. + */ + oncellchange: (ev: MSEventObj) => any; + + + /** + * Fires just before the data source control changes the current row in the object. + * @param ev The event. + */ + onrowexit: (ev: MSEventObj) => any; + + + /** + * Fires just after new rows are inserted in the current recordset. + * @param ev The event. + */ + onrowsinserted: (ev: MSEventObj) => any; + + + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string; + + msCapsLockWarningOff: boolean; + + /** + * Fires when a property changes on the object. + * @param ev The event. + */ + onpropertychange: (ev: MSEventObj) => any; + + + /** + * Fires on the source object when the user releases the mouse at the close of a drag operation. + * @param ev The event. + */ + ondragend: (ev: DragEvent) => any; + + + /** + * Gets an object representing the document type declaration associated with the current document. + */ + doctype: DocumentType; + + /** + * Fires on the target element continuously while the user drags the object over a valid drop target. + * @param ev The event. + */ + ondragover: (ev: DragEvent) => any; + + + /** + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + */ + bgColor: string; + + /** + * Fires on the source object when the user starts to drag a text selection or selected object. + * @param ev The event. + */ + ondragstart: (ev: DragEvent) => any; + + + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (ev: MouseEvent) => any; + + + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (ev: DragEvent) => any; + + + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (ev: MouseEvent) => any; + + + /** + * Sets or gets the color of the document links. + */ + linkColor: string; + + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (ev: Event) => any; + + + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (ev: MouseEvent) => any; + + + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (ev: MouseEvent) => any; + + + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (ev: Event) => any; + + + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (ev: Event) => any; + + /** + * false (false)[rolls + */ + + /** + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * @param ev The event. + */ + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + + + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollection; + + /** + * Specifies the beginning and end of the document body. + */ + body: HTMLElement; + + /** + * Sets or gets the security domain of the document. + */ + domain: string; + + xmlStandalone: boolean; + + /** + * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. + */ + selection: MSSelection; + + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (ev: Event) => any; + + + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (ev: MouseEvent) => any; + + + /** + * Gets a reference to the root node of the document. + */ + documentElement: HTMLElement; + + /** + * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. + * @param ev The event. + */ + onbeforeeditfocus: (ev: MSEventObj) => any; + + + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (ev: Event) => any; + + + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (ev: any) => any; + + + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (ev: MouseEvent) => any; + + + /** + * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * @param ev The mouse event. + */ + oncontextmenu: (ev: MouseEvent) => any; + + + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (ev: Event) => any; + + media: string; + + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (ev: Event) => any; + + + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (ev: Event) => any; + + onafterupdate: (ev: MSEventObj) => any; + + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (ev: Event) => any; + + + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollection; + + /** + * Contains information about the current URL. + */ + location: Location; + + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (ev: UIEvent) => any; + + + /** + * Fires for the current element with focus immediately after moving focus to another element. + * @param ev The event. + */ + onfocusout: (ev: FocusEvent) => any; + + + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (ev: Event) => any; + + + /** + * Fires when a local DOM Storage area is written to disk. + * @param ev The event. + */ + onstoragecommit: (ev: StorageEvent) => any; + + + /** + * Fires periodically as data arrives from data source objects that asynchronously transmit their data. + * @param ev The event. + */ + ondataavailable: (ev: MSEventObj) => any; + + + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (ev: Event) => any; + + + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + lastModified: string; + + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (ev: KeyboardEvent) => any; + + + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (ev: Event) => any; + + + /** + * Fires immediately before the activeElement is changed from the current object to another object in the parent document. + * @param ev The event. + */ + onbeforedeactivate: (ev: UIEvent) => any; + + + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (ev: UIEvent) => any; + + + onselectstart: (ev: Event) => any; + + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (ev: FocusEvent) => any; + + + /** + * Sets or gets the foreground (text) color of the document. + */ + fgColor: string; + + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (ev: Event) => any; + + + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (ev: UIEvent) => any; + + ondrop: (ev: DragEvent) => any; + + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (ev: Event) => any; + + + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + */ + compatMode: string; + + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (ev: UIEvent) => any; + + + /** + * Fires to indicate that the current row has changed in the data source and new data values are available on the object. + * @param ev The event. + */ + onrowenter: (ev: MSEventObj) => any; + + + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (ev: Event) => any; + + oninput: (ev: Event) => any; + + /** + * Returns the current value of the document, range, or current selection for the given command. + * @param commandId String that specifies a command identifier. + */ + queryCommandValue(commandId: string): string; + + adoptNode(source: Node): Node; + + /** + * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. + * @param commandId String that specifies a command identifier. + */ + queryCommandIndeterm(commandId: string): boolean; + + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + + /** + * Executes a command on the current document, current selection, or the given range. + * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. + * @param showUI Display the user interface, defaults to false. + * @param value Value to assign. + */ + execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + + /** + * Returns the element for the specified x coordinate and the specified y coordinate. + * @param x The x-offset + * @param y The y-offset + */ + elementFromPoint(x: number, y: number): Element; + createCDATASection(data: string): CDATASection; + + /** + * Retrieves the string associated with a command. + * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. + */ + queryCommandText(commandId: string): string; + + /** + * Writes one or more HTML expressions to a document in the specified window. + * @param content Specifies the text and HTML tags to write. + */ + write(...content: string[]): void; + + /** + * Allows updating the print settings for the page. + */ + updateSettings(): void; + + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "a"): HTMLAnchorElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "abbr"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "address"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "area"): HTMLAreaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "article"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "aside"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "audio"): HTMLAudioElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "b"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "base"): HTMLBaseElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "bdi"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "bdo"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "blockquote"): HTMLQuoteElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "body"): HTMLBodyElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "br"): HTMLBRElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "button"): HTMLButtonElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "canvas"): HTMLCanvasElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "caption"): HTMLTableCaptionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "cite"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "code"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "col"): HTMLTableColElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "colgroup"): HTMLTableColElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "datalist"): HTMLDataListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dd"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "del"): HTMLModElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dfn"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "div"): HTMLDivElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dl"): HTMLDListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dt"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "em"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "embed"): HTMLEmbedElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "fieldset"): HTMLFieldSetElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "figcaption"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "figure"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "footer"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "form"): HTMLFormElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h1"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h2"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h3"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h4"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h5"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h6"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "head"): HTMLHeadElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "header"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "hgroup"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "hr"): HTMLHRElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "html"): HTMLHtmlElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "i"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "iframe"): HTMLIFrameElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "img"): HTMLImageElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "input"): HTMLInputElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ins"): HTMLModElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "kbd"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "label"): HTMLLabelElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "legend"): HTMLLegendElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "li"): HTMLLIElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "link"): HTMLLinkElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "main"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "map"): HTMLMapElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "mark"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "menu"): HTMLMenuElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "meta"): HTMLMetaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "nav"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "noscript"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "object"): HTMLObjectElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ol"): HTMLOListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "optgroup"): HTMLOptGroupElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "option"): HTMLOptionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "p"): HTMLParagraphElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "param"): HTMLParamElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "pre"): HTMLPreElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "progress"): HTMLProgressElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "q"): HTMLQuoteElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "rp"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "rt"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ruby"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "s"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "samp"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "script"): HTMLScriptElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "section"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "select"): HTMLSelectElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "small"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "source"): HTMLSourceElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "span"): HTMLSpanElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "strong"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "style"): HTMLStyleElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "sub"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "summary"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "sup"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "table"): HTMLTableElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tbody"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "td"): HTMLTableDataCellElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "textarea"): HTMLTextAreaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tfoot"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "th"): HTMLTableHeaderCellElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "thead"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "title"): HTMLTitleElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tr"): HTMLTableRowElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "track"): HTMLTrackElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "u"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ul"): HTMLUListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "var"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "video"): HTMLVideoElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "wbr"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: string): HTMLElement; + + /** + * Removes mouse capture from the object in the current document. + */ + releaseCapture(): void; + + /** + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * @param content The text and HTML tags to write. + */ + writeln(...content: string[]): void; + createElementNS(namespaceURI: string, qualifiedName: string): Element; + + /** + * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. + * @param url Specifies a MIME type for the document. + * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. + * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. + * @param replace Specifies whether the existing entry for the document is replaced in the history list. + */ + open(url?: string, name?: string, features?: string, replace?: boolean): any; + + /** + * Returns a Boolean value that indicates whether the current command is supported on the current range. + * @param commandId Specifies a command identifier. + */ + queryCommandSupported(commandId: string): boolean; + + /** + * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. + * @param filter A custom NodeFilter function to use. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + + /** + * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. + * @param commandId Specifies a command identifier. + */ + queryCommandEnabled(commandId: string): boolean; + + /** + * Causes the element to receive the focus and executes the code specified by the onfocus event. + */ + focus(): void; + + /** + * Closes an output stream and forces the sent data to display. + */ + close(): void; + + getElementsByClassName(classNames: string): NodeList; + importNode(importedNode: Node, deep: boolean): Node; + + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + */ + createRange(): Range; + + /** + * Fires a specified event on the object. + * @param eventName Specifies the name of the event to fire. + * @param eventObj Object that specifies the event object from which to obtain event object properties. + */ + fireEvent(eventName: string, eventObj?: any): boolean; + + /** + * Creates a comment object with the specified data. + * @param data Sets the comment object's data. + */ + createComment(data: string): Comment; + + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "a"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "abbr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "address"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "area"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "article"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "aside"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "audio"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "b"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "base"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "bdi"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "bdo"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "blockquote"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "body"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "br"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "button"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "canvas"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "caption"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "cite"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "code"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "col"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "colgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "datalist"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dd"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "del"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dfn"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "div"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dl"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dt"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "em"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "embed"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "fieldset"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "figcaption"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "figure"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "footer"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "form"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h1"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h2"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h3"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h4"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h5"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h6"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "head"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "header"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "hgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "hr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "html"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "i"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "iframe"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "img"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "input"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ins"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "kbd"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "label"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "legend"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "li"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "link"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "main"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "map"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "mark"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "menu"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "meta"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "nav"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "noscript"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "object"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ol"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "optgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "option"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "p"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "param"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "pre"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "progress"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "q"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "rp"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "rt"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ruby"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "s"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "samp"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "script"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "section"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "select"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "small"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "source"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "span"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "strong"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "style"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "sub"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "summary"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "sup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "table"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tbody"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "td"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "textarea"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tfoot"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "th"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "thead"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "title"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "track"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "u"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ul"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "var"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "video"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "wbr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: string): NodeList; + + /** + * Creates a new document. + */ + createDocumentFragment(): DocumentFragment; + + /** + * Creates a style sheet for the document. + * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. + * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. + */ + createStyleSheet(href?: string, index?: number): CSSStyleSheet; + + /** + * Gets a collection of objects based on the value of the NAME or ID attribute. + * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. + */ + getElementsByName(elementName: string): NodeList; + + /** + * Returns a Boolean value that indicates the current state of the command. + * @param commandId String that specifies a command identifier. + */ + queryCommandState(commandId: string): boolean; + + /** + * Gets a value indicating whether the object currently has focus. + */ + hasFocus(): boolean; + + /** + * Displays help information for the given command identifier. + * @param commandId Displays help information for the given command identifier. + */ + execCommandShowHelp(commandId: string): boolean; + + /** + * Creates an attribute object with a specified name. + * @param name String that sets the attribute object's name. + */ + createAttribute(name: string): Attr; + + /** + * Creates a text string from the specified value. + * @param data String that specifies the nodeValue property of the text node. + */ + createTextNode(data: string): Text; + + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list + * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; + + /** + * Generates an event object to pass event context information when you use the fireEvent method. + * @param eventObj An object that specifies an existing event object on which to base the new object. + */ + createEventObject(eventObj?: any): MSEventObj; + + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection; + + /** + * Returns a reference to the first object with the specified value of the ID or NAME attribute. + * @param elementId String that specifies the ID value. Case-insensitive. + */ + getElementById(elementId: string): HTMLElement; +} + +declare var Document: { + prototype: Document; + new (): Document; +} + +interface MessageEvent extends Event { + source: Window; + origin: string; + data: any; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} +declare var MessageEvent: { + prototype: MessageEvent; + new (): MessageEvent; +} + +interface SVGElement extends Element { + onmouseover: (ev: MouseEvent) => any; + viewportElement: SVGElement; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + ondblclick: (ev: MouseEvent) => any; + onfocusout: (ev: FocusEvent) => any; + onfocusin: (ev: FocusEvent) => any; + xmlbase: string; + onmousedown: (ev: MouseEvent) => any; + onload: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + ownerSVGElement: SVGSVGElement; + id: string; +} +declare var SVGElement: { + prototype: SVGElement; + new (): SVGElement; +} + +interface HTMLScriptElement extends HTMLElement { + /** + * Sets or retrieves the status of the script. + */ + defer: boolean; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Retrieves the URL to an external file that contains the source code or data. + */ + src: string; + /** + * Sets or retrieves the object that is bound to the event script. + */ + htmlFor: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the MIME type for the associated scripting engine. + */ + type: string; + /** + * Sets or retrieves the event for which the script is written. + */ + event: string; +} +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new (): HTMLScriptElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Retrieves the position of the object in the rows collection for the table. + */ + rowIndex: number; + /** + * Retrieves a collection of all cells in the table row. + */ + cells: HTMLCollection; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Retrieves the position of the object in the collection. + */ + sectionRowIndex: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified cell from the table row, as well as from the cells collection. + * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. + */ + deleteCell(index?: number): void; + /** + * Creates a new cell in the table row, and adds the cell to the cells collection. + * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. + */ + insertCell(index?: number): HTMLElement; +} +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new (): HTMLTableRowElement; +} + +interface CanvasRenderingContext2D { + miterLimit: number; + font: string; + globalCompositeOperation: string; + msFillRule: string; + lineCap: string; + msImageSmoothingEnabled: boolean; + lineDashOffset: number; + shadowColor: string; + lineJoin: string; + shadowOffsetX: number; + lineWidth: number; + canvas: HTMLCanvasElement; + strokeStyle: any; + globalAlpha: number; + shadowOffsetY: number; + fillStyle: any; + shadowBlur: number; + textAlign: string; + textBaseline: string; + restore(): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + save(): void; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + measureText(text: string): TextMetrics; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + rotate(angle: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + translate(x: number, y: number): void; + scale(x: number, y: number): void; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + lineTo(x: number, y: number): void; + getLineDash(): Array; + fill(fillRule?: string): void; + createImageData(imageDataOrSw: any, sh?: number): ImageData; + createPattern(image: HTMLElement, repetition: string): CanvasPattern; + closePath(): void; + rect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + clearRect(x: number, y: number, w: number, h: number): void; + moveTo(x: number, y: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + fillRect(x: number, y: number, w: number, h: number): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + setLineDash(segments: Array): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + beginPath(): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; +} +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new (): CanvasRenderingContext2D; +} + +interface MSCSSRuleList { + length: number; + item(index?: number): CSSStyleRule; + [index: number]: CSSStyleRule; +} +declare var MSCSSRuleList: { + prototype: MSCSSRuleList; + new (): MSCSSRuleList; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new (): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new (): SVGPathSegArcAbs; +} + +interface SVGTransformList { + numberOfItems: number; + getItem(index: number): SVGTransform; + consolidate(): SVGTransform; + clear(): void; + appendItem(newItem: SVGTransform): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + removeItem(index: number): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; +} +declare var SVGTransformList: { + prototype: SVGTransformList; + new (): SVGTransformList; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; +} +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new (): HTMLHtmlElement; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new (): SVGPathSegClosePath; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; +} +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new (): HTMLFrameElement; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new (): SVGAnimatedLength; +} + +interface SVGAnimatedPoints { + points: SVGPointList; + animatedPoints: SVGPointList; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new (): SVGDefsElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new (): HTMLQuoteElement; +} + +interface CSSMediaRule extends CSSRule { + media: MediaList; + cssRules: CSSRuleList; + insertRule(rule: string, index?: number): number; + deleteRule(index?: number): void; +} +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new (): CSSMediaRule; +} + +interface WindowModal { + dialogArguments: any; + returnValue: any; +} + +interface XMLHttpRequest extends EventTarget { + responseBody: any; + status: number; + readyState: number; + responseText: string; + responseXML: Document; + ontimeout: (ev: Event) => any; + statusText: string; + onreadystatechange: (ev: Event) => any; + timeout: number; + onload: (ev: Event) => any; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + create(): XMLHttpRequest; + send(data?: any): void; + abort(): void; + getAllResponseHeaders(): string; + setRequestHeader(header: string, value: string): void; + getResponseHeader(header: string): string; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new (): XMLHttpRequest; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; +} +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new (): HTMLTableHeaderCellElement; +} + +interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { +} +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new (): HTMLDListElement; +} + +interface MSDataBindingExtensions { + dataSrc: string; + dataFormatAs: string; + dataFld: string; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new (): SVGPathSegLinetoHorizontalRel; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + ry: SVGAnimatedLength; + cx: SVGAnimatedLength; + rx: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new (): SVGEllipseElement; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; +} +declare var SVGAElement: { + prototype: SVGAElement; + new (): SVGAElement; +} + +interface SVGStylable { + className: SVGAnimatedString; + style: CSSStyleDeclaration; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface HTMLFrameSetElement extends HTMLElement { + ononline: (ev: Event) => any; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + /** + * Sets or retrieves the frame widths of the object. + */ + cols: string; + /** + * Fires when the object loses the input focus. + */ + onblur: (ev: FocusEvent) => any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Fires when the object receives focus. + */ + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + onerror: (ev: Event) => any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + onresize: (ev: UIEvent) => any; + name: string; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + border: string; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onstorage: (ev: StorageEvent) => any; +} +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new (): HTMLFrameSetElement; +} + +interface Screen { + width: number; + deviceXDPI: number; + fontSmoothingEnabled: boolean; + bufferDepth: number; + logicalXDPI: number; + systemXDPI: number; + availHeight: number; + height: number; + logicalYDPI: number; + systemYDPI: number; + updateInterval: number; + colorDepth: number; + availWidth: number; + deviceYDPI: number; + pixelDepth: number; +} +declare var Screen: { + prototype: Screen; + new (): Screen; +} + +interface Coordinates { + altitudeAccuracy: number; + longitude: number; + latitude: number; + speed: number; + heading: number; + altitude: number; + accuracy: number; +} +declare var Coordinates: { + prototype: Coordinates; + new (): Coordinates; +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorContentUtils { +} + +interface EventListener { + (evt: Event): void; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface DataTransfer { + effectAllowed: string; + dropEffect: string; + clearData(format?: string): boolean; + setData(format: string, data: string): boolean; + getData(format: string): string; +} +declare var DataTransfer: { + prototype: DataTransfer; + new (): DataTransfer; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} +declare var FocusEvent: { + prototype: FocusEvent; + new (): FocusEvent; +} + +interface Range { + startOffset: number; + collapsed: boolean; + endOffset: number; + startContainer: Node; + endContainer: Node; + commonAncestorContainer: Node; + setStart(refNode: Node, offset: number): void; + setEndBefore(refNode: Node): void; + setStartBefore(refNode: Node): void; + selectNode(refNode: Node): void; + detach(): void; + getBoundingClientRect(): ClientRect; + toString(): string; + compareBoundaryPoints(how: number, sourceRange: Range): number; + insertNode(newNode: Node): void; + collapse(toStart: boolean): void; + selectNodeContents(refNode: Node): void; + cloneContents(): DocumentFragment; + setEnd(refNode: Node, offset: number): void; + cloneRange(): Range; + getClientRects(): ClientRectList; + surroundContents(newParent: Node): void; + deleteContents(): void; + setStartAfter(refNode: Node): void; + extractContents(): DocumentFragment; + setEndAfter(refNode: Node): void; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} +declare var Range: { + prototype: Range; + new (): Range; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} + +interface SVGPoint { + y: number; + x: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} +declare var SVGPoint: { + prototype: SVGPoint; + new (): SVGPoint; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new (): MSPluginsCollection; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new (): SVGAnimatedNumberList; +} + +interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { + width: SVGAnimatedLength; + x: SVGAnimatedLength; + contentStyleType: string; + onzoom: (ev: any) => any; + y: SVGAnimatedLength; + viewport: SVGRect; + onerror: (ev: Event) => any; + pixelUnitToMillimeterY: number; + onresize: (ev: UIEvent) => any; + screenPixelToMillimeterY: number; + height: SVGAnimatedLength; + onabort: (ev: UIEvent) => any; + contentScriptType: string; + pixelUnitToMillimeterX: number; + currentTranslate: SVGPoint; + onunload: (ev: Event) => any; + currentScale: number; + onscroll: (ev: UIEvent) => any; + screenPixelToMillimeterX: number; + setCurrentTime(seconds: number): void; + createSVGLength(): SVGLength; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + unpauseAnimations(): void; + createSVGRect(): SVGRect; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + unsuspendRedrawAll(): void; + pauseAnimations(): void; + suspendRedraw(maxWaitMilliseconds: number): number; + deselectAll(): void; + createSVGAngle(): SVGAngle; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + createSVGTransform(): SVGTransform; + unsuspendRedraw(suspendHandleID: number): void; + forceRedraw(): void; + getCurrentTime(): number; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + createSVGMatrix(): SVGMatrix; + createSVGPoint(): SVGPoint; + createSVGNumber(): SVGNumber; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getElementById(elementId: string): Element; +} +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new (): SVGSVGElement; +} + +interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new (): HTMLLabelElement; +} + +interface MSResourceMetadata { + protocol: string; + fileSize: string; + fileUpdatedDate: string; + nameProp: string; + fileCreatedDate: string; + fileModifiedDate: string; + mimeType: string; +} + +interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new (): HTMLLegendElement; +} + +interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new (): HTMLDirectoryElement; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new (): SVGAnimatedInteger; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +} +declare var SVGTextElement: { + prototype: SVGTextElement; + new (): SVGTextElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new (): SVGTSpanElement; +} + +interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * Sets or retrieves the value of a list item. + */ + value: number; +} +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new (): HTMLLIElement; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new (): SVGPathSegLinetoVerticalAbs; +} + +interface MSStorageExtensions { + remainingSpace: number; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + type: string; + title: string; +} +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new (): SVGStyleElement; +} + +interface MSCurrentStyleCSSProperties extends MSCSSProperties { + blockDirection: string; + clipBottom: string; + clipLeft: string; + clipRight: string; + clipTop: string; + hasLayout: string; +} +declare var MSCurrentStyleCSSProperties: { + prototype: MSCurrentStyleCSSProperties; + new (): MSCurrentStyleCSSProperties; +} + +interface MSHTMLCollectionExtensions { + urns(urn: any): Object; + tags(tagName: any): Object; +} + +interface Storage extends MSStorageExtensions { + length: number; + getItem(key: string): any; + [key: string]: any; + setItem(key: string, data: string): void; + clear(): void; + removeItem(key: string): void; + key(index: number): string; + [index: number]: any; +} +declare var Storage: { + prototype: Storage; + new (): Storage; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Sets or retrieves the horizontal margin for the object. + */ + hspace: number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; +} +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new (): HTMLIFrameElement; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new (): TextRangeCollection; +} + +interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + scroll: string; + ononline: (ev: Event) => any; + onblur: (ev: FocusEvent) => any; + noWrap: boolean; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + text: any; + onerror: (ev: Event) => any; + bgProperties: string; + onresize: (ev: UIEvent) => any; + link: any; + aLink: any; + bottomMargin: any; + topMargin: any; + onafterprint: (ev: Event) => any; + vLink: any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + rightMargin: any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + leftMargin: any; + onstorage: (ev: StorageEvent) => any; + createTextRange(): TextRange; +} +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new (): HTMLBodyElement; +} + +interface DocumentType extends Node { + name: string; + notations: NamedNodeMap; + systemId: string; + internalSubset: string; + entities: NamedNodeMap; + publicId: string; +} +declare var DocumentType: { + prototype: DocumentType; + new (): DocumentType; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; +} +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new (): SVGRadialGradientElement; +} + +interface MutationEvent extends Event { + newValue: string; + attrChange: number; + attrName: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} +declare var MutationEvent: { + prototype: MutationEvent; + new (): MutationEvent; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(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, dataTransferArg: DataTransfer): void; +} +declare var DragEvent: { + prototype: DragEvent; + new (): DragEvent; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): Object; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; +} +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new (): HTMLTableSectionElement; +} + +interface DOML2DeprecatedListNumberingAndBulletStyle { + type: string; +} + +interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + status: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + indeterminate: boolean; + readOnly: boolean; + size: number; + loop: number; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. + */ + vrml: string; + /** + * Sets or retrieves a lower resolution image to display. + */ + lowsrc: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves a comma-separated list of content types. + */ + accept: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + defaultChecked: boolean; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Returns the value of the data at the cursor's current position. + */ + value: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + dynsrc: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + checked: boolean; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + start: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Makes the selection equal to the current object. + */ + select(): void; +} +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new (): HTMLInputElement; +} + +interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Contains the protocol of the URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Contains the hostname of a URL. + */ + hostname: string; + /** + * Contains the pathname of the URL. + */ + pathname: string; + Methods: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + protocolLong: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Contains the hostname and port values of the URL. + */ + host: string; + /** + * Contains the anchor portion of the URL including the hash sign (#). + */ + hash: string; + nameProp: string; + urn: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + type: string; + mimeType: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new (): HTMLAnchorElement; +} + +interface HTMLParamElement extends HTMLElement { + /** + * Sets or retrieves the value of an input parameter for an element. + */ + value: string; + /** + * Sets or retrieves the name of an input parameter for an element. + */ + name: string; + /** + * Sets or retrieves the content type of the resource designated by the value attribute. + */ + type: string; + /** + * Sets or retrieves the data type of the value attribute. + */ + valueType: string; +} +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new (): HTMLParamElement; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGImageElement: { + prototype: SVGImageElement; + new (): SVGImageElement; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new (): SVGAnimatedNumber; +} + +interface PerformanceTiming { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + msFirstPaint: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + toJSON(): any; +} +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new (): PerformanceTiming; +} + +interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + /** + * Indicates a citation by rendering text in italic type. + */ + cite: string; +} +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new (): HTMLPreElement; +} + +interface EventException { + code: number; + message: string; + toString(): string; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} +declare var EventException: { + prototype: EventException; + new (): EventException; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} + +interface MSNavigatorDoNotTrack { + msDoNotTrack: string; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface SVGMetadataElement extends SVGElement { +} +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new (): SVGMetadataElement; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new (): SVGPathSegArcRel; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new (): SVGPathSegMovetoAbs; +} + +interface SVGStringList { + numberOfItems: number; + replaceItem(newItem: string, index: number): string; + getItem(index: number): string; + clear(): void; + appendItem(newItem: string): string; + initialize(newItem: string): string; + removeItem(index: number): string; + insertItemBefore(newItem: string, index: number): string; +} +declare var SVGStringList: { + prototype: SVGStringList; + new (): SVGStringList; +} + +interface XDomainRequest { + timeout: number; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onprogress: (ev: any) => any; + ontimeout: (ev: Event) => any; + responseText: string; + contentType: string; + open(method: string, url: string): void; + create(): XDomainRequest; + abort(): void; + send(data?: any): void; +} +declare var XDomainRequest: { + prototype: XDomainRequest; + new (): XDomainRequest; +} + +interface DOML2DeprecatedBackgroundColorStyle { + bgColor: any; +} + +interface ElementTraversal { + childElementCount: number; + previousElementSibling: Element; + lastElementChild: Element; + nextElementSibling: Element; + firstElementChild: Element; +} + +interface SVGLength { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} +declare var SVGLength: { + prototype: SVGLength; + new (): SVGLength; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new (): SVGPolygonElement; +} + +interface HTMLPhraseElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new (): HTMLPhraseElement; +} + +interface NavigatorStorageUtils { +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new (): SVGPathSegCurvetoCubicRel; +} + +interface MSEventObj extends Event { + nextPage: string; + keyCode: number; + toElement: Element; + returnValue: any; + dataFld: string; + y: number; + dataTransfer: DataTransfer; + propertyName: string; + url: string; + offsetX: number; + recordset: Object; + screenX: number; + buttonID: number; + wheelDelta: number; + reason: number; + origin: string; + data: string; + srcFilter: Object; + boundElements: HTMLCollection; + cancelBubble: boolean; + altLeft: boolean; + behaviorCookie: number; + bookmarks: BookmarkCollection; + type: string; + repeat: boolean; + srcElement: Element; + source: Window; + fromElement: Element; + offsetY: number; + x: number; + behaviorPart: number; + qualifier: string; + altKey: boolean; + ctrlKey: boolean; + clientY: number; + shiftKey: boolean; + shiftLeft: boolean; + contentOverflow: boolean; + screenY: number; + ctrlLeft: boolean; + button: number; + srcUrn: string; + clientX: number; + actionURL: string; + getAttribute(strAttributeName: string, lFlags?: number): any; + setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; + removeAttribute(strAttributeName: string, lFlags?: number): boolean; +} +declare var MSEventObj: { + prototype: MSEventObj; + new (): MSEventObj; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + textLength: SVGAnimatedLength; + lengthAdjust: SVGAnimatedEnumeration; + getCharNumAtPosition(point: SVGPoint): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getComputedTextLength(): number; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getEndPositionOfChar(charnum: number): SVGPoint; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new (): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface HTMLCanvasElement extends HTMLElement { + /** + * Gets or sets the width of a canvas element on a document. + */ + width: number; + /** + * Gets or sets the height of a canvas element on a document. + */ + height: number; + /** + * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. + * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. + */ + toDataURL(type?: string, ...args: any[]): string; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @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: { + prototype: HTMLCanvasElement; + new (): HTMLCanvasElement; +} + +interface Location { + hash: string; + protocol: string; + search: string; + href: string; + hostname: string; + port: string; + pathname: string; + host: string; + reload(flag?: boolean): void; + replace(url: string): void; + assign(url: string): void; + toString(): string; +} +declare var Location: { + prototype: Location; + new (): Location; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new (): HTMLTitleElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; +} +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new (): HTMLStyleElement; +} + +interface PerformanceEntry { + name: string; + startTime: number; + duration: number; + entryType: string; +} +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new (): PerformanceEntry; +} + +interface SVGTransform { + type: number; + angle: number; + matrix: SVGMatrix; + setTranslate(tx: number, ty: number): void; + setScale(sx: number, sy: number): void; + setMatrix(matrix: SVGMatrix): void; + setSkewY(angle: number): void; + setRotate(angle: number, cx: number, cy: number): void; + setSkewX(angle: number): void; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} +declare var SVGTransform: { + prototype: SVGTransform; + new (): SVGTransform; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} +declare var UIEvent: { + prototype: UIEvent; + new (): UIEvent; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new (): SVGPathSeg; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} + +interface WheelEvent extends MouseEvent { + deltaZ: number; + deltaX: number; + deltaMode: number; + deltaY: number; + initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} +declare var WheelEvent: { + prototype: WheelEvent; + new (): WheelEvent; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} + +interface MSEventAttachmentTarget { + attachEvent(event: string, listener: EventListener): boolean; + detachEvent(event: string, listener: EventListener): void; +} + +interface SVGNumber { + value: number; +} +declare var SVGNumber: { + prototype: SVGNumber; + new (): SVGNumber; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + getTotalLength(): number; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; +} +declare var SVGPathElement: { + prototype: SVGPathElement; + new (): SVGPathElement; +} + +interface MSCompatibleInfo { + version: string; + userAgent: string; +} +declare var MSCompatibleInfo: { + prototype: MSCompatibleInfo; + new (): MSCompatibleInfo; +} + +interface Text extends CharacterData, MSNodeExtensions { + wholeText: string; + splitText(offset: number): Text; + replaceWholeText(content: string): Text; +} +declare var Text: { + prototype: Text; + new (): Text; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new (): SVGAnimatedRect; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new (): CSSNamespaceRule; +} + +interface SVGPathSegList { + numberOfItems: number; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; + getItem(index: number): SVGPathSeg; + clear(): void; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; +} +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new (): SVGPathSegList; +} + +interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { +} +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new (): HTMLUnknownElement; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new (): HTMLAudioElement; +} + +interface MSImageResourceExtensions { + dynsrc: string; + vrml: string; + lowsrc: string; + start: string; + loop: number; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} +declare var PositionError: { + prototype: PositionError; + new (): PositionError; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves a list of header cells that provide information for the object. + */ + headers: string; + /** + * Retrieves the position of the object in the cells collection of a row. + */ + cellIndex: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the number columns in the table that the object should span. + */ + colSpan: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. + */ + axis: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; + /** + * Sets or retrieves abbreviated text for the object. + */ + abbr: string; + /** + * Sets or retrieves how many rows in a table the cell should span. + */ + rowSpan: number; + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; +} +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new (): HTMLTableCellElement; +} + +interface SVGElementInstance extends EventTarget { + previousSibling: SVGElementInstance; + parentNode: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + childNodes: SVGElementInstanceList; + correspondingUseElement: SVGUseElement; + correspondingElement: SVGElement; + firstChild: SVGElementInstance; +} +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new (): SVGElementInstance; +} + +interface MSNamespaceInfoCollection { + length: number; + add(namespace?: string, urn?: string, implementationUrl?: any): Object; + item(index: any): Object; + [index: string]: Object; +} +declare var MSNamespaceInfoCollection: { + prototype: MSNamespaceInfoCollection; + new (): MSNamespaceInfoCollection; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new (): SVGCircleElement; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} +declare var StyleSheetList: { + prototype: StyleSheetList; + new (): StyleSheetList; +} + +interface CSSImportRule extends CSSRule { + styleSheet: CSSStyleSheet; + href: string; + media: MediaList; +} +declare var CSSImportRule: { + prototype: CSSImportRule; + new (): CSSImportRule; +} + +interface CustomEvent extends Event { + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; +} +declare var CustomEvent: { + prototype: CustomEvent; + new (): CustomEvent; +} + +interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + /** + * Sets or retrieves the font size of the object. + */ + size: number; +} +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new (): HTMLBaseFontElement; +} + +interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves or sets the text in the entry field of the textArea element. + */ + value: string; + /** + * Sets or retrieves the value indicating whether the control is selected. + */ + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: number; + /** + * Sets or retrieves the width of the object. + */ + cols: number; + /** + * Sets or retrieves the value indicated whether the content of the object is read-only. + */ + readOnly: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Retrieves the type of control. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Highlights the input area of a form element. + */ + select(): void; +} +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new (): HTMLTextAreaElement; +} + +interface Geolocation { + clearWatch(watchId: number): void; + getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; + watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; +} +declare var Geolocation: { + prototype: Geolocation; + new (): Geolocation; +} + +interface DOML2DeprecatedMarginStyle { + vspace: number; + hspace: number; +} + +interface MSWindowModeless { + dialogTop: any; + dialogLeft: any; + dialogWidth: any; + dialogHeight: any; + menuArguments: any; +} + +interface DOML2DeprecatedAlignmentStyle { + align: string; +} + +interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { + width: string; + onbounce: (ev: Event) => any; + vspace: number; + trueSpeed: boolean; + scrollAmount: number; + scrollDelay: number; + behavior: string; + height: string; + loop: number; + direction: string; + hspace: number; + onstart: (ev: Event) => any; + onfinish: (ev: Event) => any; + stop(): void; + start(): void; +} +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new (): HTMLMarqueeElement; +} + +interface SVGRect { + y: number; + width: number; + x: number; + height: number; +} +declare var SVGRect: { + prototype: SVGRect; + new (): SVGRect; +} + +interface MSNodeExtensions { + swapNode(otherNode: Node): Node; + removeNode(deep?: boolean): Node; + replaceNode(replacement: Node): Node; +} + +interface History { + length: number; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; +} +declare var History: { + prototype: History; + new (): History; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new (): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new (): SVGPathSegCurvetoQuadraticAbs; +} + +interface TimeRanges { + length: number; + start(index: number): number; + end(index: number): number; +} +declare var TimeRanges: { + prototype: TimeRanges; + new (): TimeRanges; +} + +interface CSSRule { + cssText: string; + parentStyleSheet: CSSStyleSheet; + parentRule: CSSRule; + type: number; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} +declare var CSSRule: { + prototype: CSSRule; + new (): CSSRule; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new (): SVGPathSegLinetoAbs; +} + +interface HTMLModElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLModElement: { + prototype: HTMLModElement; + new (): HTMLModElement; +} + +interface SVGMatrix { + e: number; + c: number; + a: number; + b: number; + d: number; + f: number; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + flipY(): SVGMatrix; + skewY(angle: number): SVGMatrix; + inverse(): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + rotate(angle: number): SVGMatrix; + flipX(): SVGMatrix; + translate(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + skewX(angle: number): SVGMatrix; +} +declare var SVGMatrix: { + prototype: SVGMatrix; + new (): SVGMatrix; +} + +interface MSPopupWindow { + document: Document; + isOpen: boolean; + show(x: number, y: number, w: number, h: number, element?: any): void; + hide(): void; +} +declare var MSPopupWindow: { + prototype: MSPopupWindow; + new (): MSPopupWindow; +} + +interface BeforeUnloadEvent extends Event { + returnValue: string; +} +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new (): BeforeUnloadEvent; +} + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + animatedInstanceRoot: SVGElementInstance; + instanceRoot: SVGElementInstance; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGUseElement: { + prototype: SVGUseElement; + new (): SVGUseElement; +} + +interface Event { + timeStamp: number; + defaultPrevented: boolean; + isTrusted: boolean; + currentTarget: EventTarget; + cancelBubble: boolean; + target: EventTarget; + eventPhase: number; + cancelable: boolean; + type: string; + srcElement: Element; + bubbles: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + stopPropagation(): void; + stopImmediatePropagation(): void; + preventDefault(): void; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} +declare var Event: { + prototype: Event; + new (): Event; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} + +interface ImageData { + width: number; + data: Uint8Array; + height: number; +} +declare var ImageData: { + prototype: ImageData; + new (): ImageData; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves the alignment of the object relative to the display or table. + */ + align: string; + /** + * Sets or retrieves the number of columns in the group. + */ + span: number; +} +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new (): HTMLTableColElement; +} + +interface SVGException { + code: number; + message: string; + toString(): string; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} +declare var SVGException: { + prototype: SVGException; + new (): SVGException; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new (): SVGLinearGradientElement; +} + +interface HTMLTableAlignment { + /** + * Sets or retrieves a value that you can use to implement your own ch functionality for the object. + */ + ch: string; + /** + * Sets or retrieves how text and other content are vertically aligned within the object that contains them. + */ + vAlign: string; + /** + * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. + */ + chOff: string; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new (): SVGAnimatedEnumeration; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new (): HTMLUListElement; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + ry: SVGAnimatedLength; + rx: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGRectElement: { + prototype: SVGRectElement; + new (): SVGRectElement; +} + +interface ErrorEventHandler { + (event: Event, source: string, fileno: number, columnNumber: number): void; + (message: any, uri: string, lineNumber: number, columnNumber?: number): void; +} + +interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new (): HTMLDivElement; +} + +interface DOML2DeprecatedBorderStyle { + border: string; +} + +interface NamedNodeMap { + length: number; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + [index: number]: Attr; + removeNamedItem(name: string): Attr; + getNamedItem(name: string): Attr; + setNamedItem(arg: Attr): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItemNS(arg: Attr): Attr; +} +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new (): NamedNodeMap; +} + +interface MediaList { + length: number; + mediaText: string; + deleteMedium(oldMedium: string): void; + appendMedium(newMedium: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var MediaList: { + prototype: MediaList; + new (): MediaList; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new (): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new (): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGLengthList { + numberOfItems: number; + replaceItem(newItem: SVGLength, index: number): SVGLength; + getItem(index: number): SVGLength; + clear(): void; + appendItem(newItem: SVGLength): SVGLength; + initialize(newItem: SVGLength): SVGLength; + removeItem(index: number): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; +} +declare var SVGLengthList: { + prototype: SVGLengthList; + new (): SVGLengthList; +} + +interface ProcessingInstruction extends Node { + target: string; + data: string; +} +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new (): ProcessingInstruction; +} + +interface MSWindowExtensions { + status: string; + onmouseleave: (ev: MouseEvent) => any; + screenLeft: number; + offscreenBuffering: any; + maxConnectionsPerServer: number; + onmouseenter: (ev: MouseEvent) => any; + clipboardData: DataTransfer; + defaultStatus: string; + clientInformation: Navigator; + closed: boolean; + onhelp: (ev: Event) => any; + external: External; + event: MSEventObj; + onfocusout: (ev: FocusEvent) => any; + screenTop: number; + onfocusin: (ev: FocusEvent) => any; + showModelessDialog(url?: string, argument?: any, options?: any): Window; + navigate(url: string): void; + resizeBy(x?: number, y?: number): void; + item(index: any): any; + resizeTo(x?: number, y?: number): void; + createPopup(arguments?: any): MSPopupWindow; + toStaticHTML(html: string): string; + execScript(code: string, language?: string): any; + msWriteProfilerMark(profilerMarkName: string): void; + moveTo(x?: number, y?: number): void; + moveBy(x?: number, y?: number): void; + showHelp(url: string, helpArg?: any, features?: string): void; +} + +interface MSBehaviorUrnsCollection { + length: number; + item(index: number): string; +} +declare var MSBehaviorUrnsCollection: { + prototype: MSBehaviorUrnsCollection; + new (): MSBehaviorUrnsCollection; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new (): CSSFontFaceRule; +} + +interface DOML2DeprecatedBackgroundStyle { + background: string; +} + +interface TextEvent extends UIEvent { + inputMethod: number; + data: string; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} +declare var TextEvent: { + prototype: TextEvent; + new (): TextEvent; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} + +interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { +} +declare var DocumentFragment: { + prototype: DocumentFragment; + new (): DocumentFragment; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new (): SVGPolylineElement; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface Position { + timestamp: number; + coords: Coordinates; +} +declare var Position: { + prototype: Position; + new (): Position; +} + +interface BookmarkCollection { + length: number; + item(index: number): any; + [index: number]: any; +} +declare var BookmarkCollection: { + prototype: BookmarkCollection; + new (): BookmarkCollection; +} + +interface PerformanceMark extends PerformanceEntry { +} +declare var PerformanceMark: { + prototype: PerformanceMark; + new (): PerformanceMark; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selectorText: string; + selector: string; + style: CSSStyleDeclaration; +} +declare var CSSPageRule: { + prototype: CSSPageRule; + new (): CSSPageRule; +} + +interface HTMLBRElement extends HTMLElement { + /** + * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. + */ + clear: string; +} +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new (): HTMLBRElement; +} + +interface MSNavigatorExtensions { + userLanguage: string; + plugins: MSPluginsCollection; + cookieEnabled: boolean; + appCodeName: string; + cpuClass: string; + appMinorVersion: string; + connectionSpeed: number; + browserLanguage: string; + mimeTypes: MSMimeTypesCollection; + systemLanguage: string; + javaEnabled(): boolean; + taintEnabled(): boolean; +} + +interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { +} +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new (): HTMLSpanElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new (): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; +} +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new (): HTMLHeadingElement; +} + +interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. + */ + acceptCharset: string; + /** + * Sets or retrieves the encoding type for the form. + */ + enctype: string; + /** + * Retrieves a collection, in source order, of all controls in a given form. + */ + elements: HTMLCollection; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves how to send the form data to the server. + */ + method: string; + /** + * Sets or retrieves the MIME encoding for the form. + */ + encoding: string; + /** + * Fires when the user resets a form. + */ + reset(): void; + /** + * Retrieves a form object or an object from an elements collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Fires when a FORM is about to be submitted. + */ + submit(): void; + /** + * Retrieves a form object or an object from an elements collection. + */ + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new (): HTMLFormElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} +declare var SVGZoomAndPan: { + prototype: SVGZoomAndPan; + new (): SVGZoomAndPan; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Gets the earliest possible position, in seconds, that the playback can begin. + */ + initialTime: number; + /** + * Gets TimeRanges for the current media resource that has been played. + */ + played: TimeRanges; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + currentSrc: string; + readyState: any; + /** + * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. + */ + autobuffer: boolean; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + /** + * Gets information about whether the playback has ended or not. + */ + ended: boolean; + /** + * Gets a collection of buffered time ranges. + */ + buffered: TimeRanges; + /** + * Returns an object representing the current error state of the audio or video element. + */ + error: MediaError; + /** + * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + */ + seekable: TimeRanges; + /** + * Gets or sets a value that indicates whether to start playing the media automatically. + */ + autoplay: boolean; + /** + * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + */ + controls: boolean; + /** + * Gets or sets the volume level for audio portions of the media element. + */ + volume: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. + */ + playbackRate: number; + /** + * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + */ + duration: number; + /** + * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + */ + muted: boolean; + /** + * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. + */ + defaultPlaybackRate: number; + /** + * Gets a flag that specifies whether playback is paused. + */ + paused: boolean; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + seeking: boolean; + /** + * Gets or sets the current playback position, in seconds. + */ + currentTime: number; + /** + * Gets or sets the current playback position, in seconds. + */ + preload: string; + /** + * Gets the current network activity for the element. + */ + networkState: number; + /** + * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. + */ + pause(): void; + /** + * Loads and starts playback of a media resource. + */ + play(): void; + /** + * Fires immediately after the client loads the object. + */ + load(): void; + /** + * Returns a string that specifies whether the client can play a given media resource type. + */ + canPlayType(type: string): string; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new (): HTMLMediaElement; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} + +interface ElementCSSInlineStyle { + runtimeStyle: MSStyleCSSProperties; + currentStyle: MSCurrentStyleCSSProperties; + doScroll(component?: any): void; + componentFromPoint(x: number, y: number): string; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} +declare var DOMParser: { + prototype: DOMParser; + new (): DOMParser; +} + +interface MSMimeTypesCollection { + length: number; +} +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new (): MSMimeTypesCollection; +} + +interface StyleSheet { + disabled: boolean; + ownerNode: Node; + parentStyleSheet: StyleSheet; + href: string; + media: MediaList; + type: string; + title: string; +} +declare var StyleSheet: { + prototype: StyleSheet; + new (): StyleSheet; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + startOffset: SVGAnimatedLength; + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new (): SVGTextPathElement; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} + +interface HTMLDTElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new (): HTMLDTElement; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} +declare var NodeList: { + prototype: NodeList; + new (): NodeList; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} +declare var XMLSerializer: { + prototype: XMLSerializer; + new (): XMLSerializer; +} + +interface PerformanceMeasure extends PerformanceEntry { +} +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new (): PerformanceMeasure; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { + spreadMethod: SVGAnimatedEnumeration; + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new (): SVGGradientElement; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} +declare var NodeFilter: { + prototype: NodeFilter; + new (): NodeFilter; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} + +interface SVGNumberList { + numberOfItems: number; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; + getItem(index: number): SVGNumber; + clear(): void; + appendItem(newItem: SVGNumber): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + removeItem(index: number): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; +} +declare var SVGNumberList: { + prototype: SVGNumberList; + new (): SVGNumberList; +} + +interface MediaError { + code: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} +declare var MediaError: { + prototype: MediaError; + new (): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} + +interface HTMLFieldSetElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new (): HTMLFieldSetElement; +} + +interface HTMLBGSoundElement extends HTMLElement { + /** + * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. + */ + balance: any; + /** + * Sets or gets the volume setting for the sound. + */ + volume: any; + /** + * Sets or gets the URL of a sound to play. + */ + src: string; + /** + * Sets or retrieves the number of times a sound or video clip will loop when activated. + */ + loop: number; +} +declare var HTMLBGSoundElement: { + prototype: HTMLBGSoundElement; + new (): HTMLBGSoundElement; +} + +interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { + onmouseleave: (ev: MouseEvent) => any; + onbeforecut: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + onmove: (ev: MSEventObj) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onhelp: (ev: Event) => any; + ondragleave: (ev: DragEvent) => any; + className: string; + onfocusin: (ev: FocusEvent) => any; + onseeked: (ev: Event) => any; + recordNumber: any; + title: string; + parentTextEdit: Element; + outerHTML: string; + ondurationchange: (ev: Event) => any; + offsetHeight: number; + all: HTMLCollection; + onblur: (ev: FocusEvent) => any; + dir: string; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + ondeactivate: (ev: UIEvent) => any; + ondatasetchanged: (ev: MSEventObj) => any; + onrowsdelete: (ev: MSEventObj) => any; + sourceIndex: number; + onloadstart: (ev: Event) => any; + onlosecapture: (ev: MSEventObj) => any; + ondragenter: (ev: DragEvent) => any; + oncontrolselect: (ev: MSEventObj) => any; + onsubmit: (ev: Event) => any; + behaviorUrns: MSBehaviorUrnsCollection; + scopeName: string; + onchange: (ev: Event) => any; + id: string; + onlayoutcomplete: (ev: MSEventObj) => any; + uniqueID: string; + onbeforeactivate: (ev: UIEvent) => any; + oncanplaythrough: (ev: Event) => any; + onbeforeupdate: (ev: MSEventObj) => any; + onfilterchange: (ev: MSEventObj) => any; + offsetParent: Element; + ondatasetcomplete: (ev: MSEventObj) => any; + onsuspend: (ev: Event) => any; + readyState: any; + onmouseenter: (ev: MouseEvent) => any; + innerText: string; + onerrorupdate: (ev: MSEventObj) => any; + onmouseout: (ev: MouseEvent) => any; + parentElement: HTMLElement; + onmousewheel: (ev: MouseWheelEvent) => any; + onvolumechange: (ev: Event) => any; + oncellchange: (ev: MSEventObj) => any; + onrowexit: (ev: MSEventObj) => any; + onrowsinserted: (ev: MSEventObj) => any; + onpropertychange: (ev: MSEventObj) => any; + filters: Object; + children: HTMLCollection; + ondragend: (ev: DragEvent) => any; + onbeforepaste: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + offsetTop: number; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + onbeforecopy: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + innerHTML: string; + onmouseover: (ev: MouseEvent) => any; + lang: string; + uniqueNumber: number; + onpause: (ev: Event) => any; + tagUrn: string; + onmousedown: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + onwaiting: (ev: Event) => any; + onresizestart: (ev: MSEventObj) => any; + offsetLeft: number; + isTextEdit: boolean; + isDisabled: boolean; + onpaste: (ev: DragEvent) => any; + canHaveHTML: boolean; + onmoveend: (ev: MSEventObj) => any; + language: string; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + style: MSStyleCSSProperties; + isContentEditable: boolean; + onbeforeeditfocus: (ev: MSEventObj) => any; + onratechange: (ev: Event) => any; + contentEditable: string; + tabIndex: number; + document: Document; + onprogress: (ev: any) => any; + ondblclick: (ev: MouseEvent) => any; + oncontextmenu: (ev: MouseEvent) => any; + onloadedmetadata: (ev: Event) => any; + onafterupdate: (ev: MSEventObj) => any; + onerror: (ev: Event) => any; + onplay: (ev: Event) => any; + onresizeend: (ev: MSEventObj) => any; + onplaying: (ev: Event) => any; + isMultiLine: boolean; + onfocusout: (ev: FocusEvent) => any; + onabort: (ev: UIEvent) => any; + ondataavailable: (ev: MSEventObj) => any; + hideFocus: boolean; + onreadystatechange: (ev: Event) => any; + onkeypress: (ev: KeyboardEvent) => any; + onloadeddata: (ev: Event) => any; + onbeforedeactivate: (ev: UIEvent) => any; + outerText: string; + disabled: boolean; + onactivate: (ev: UIEvent) => any; + accessKey: string; + onmovestart: (ev: MSEventObj) => any; + onselectstart: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + oncut: (ev: DragEvent) => any; + onselect: (ev: UIEvent) => any; + ondrop: (ev: DragEvent) => any; + offsetWidth: number; + oncopy: (ev: DragEvent) => any; + onended: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + onrowenter: (ev: MSEventObj) => any; + onload: (ev: Event) => any; + canHaveChildren: boolean; + oninput: (ev: Event) => any; + dragDrop(): boolean; + scrollIntoView(top?: boolean): void; + addFilter(filter: Object): void; + setCapture(containerCapture?: boolean): void; + focus(): void; + getAdjacentText(where: string): string; + insertAdjacentText(where: string, text: string): void; + getElementsByClassName(classNames: string): NodeList; + setActive(): void; + removeFilter(filter: Object): void; + blur(): void; + clearAttributes(): void; + releaseCapture(): void; + createControlRange(): ControlRangeCollection; + removeBehavior(cookie: number): boolean; + contains(child: HTMLElement): boolean; + click(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; + replaceAdjacentText(where: string, newText: string): string; + applyElement(apply: Element, where?: string): Element; + addBehavior(bstrUrl: string, factory?: any): number; + insertAdjacentHTML(where: string, html: string): void; +} +declare var HTMLElement: { + prototype: HTMLElement; + new (): HTMLElement; +} + +interface Comment extends CharacterData { + text: string; +} +declare var Comment: { + prototype: Comment; + new (): Comment; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + redirectStart: number; + redirectEnd: number; + domainLookupEnd: number; + responseStart: number; + domainLookupStart: number; + fetchStart: number; + requestStart: number; + connectEnd: number; + connectStart: number; + initiatorType: string; + responseEnd: number; +} +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new (): PerformanceResourceTiming; +} + +interface CanvasPattern { +} +declare var CanvasPattern: { + prototype: CanvasPattern; + new (): CanvasPattern; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. + */ + noShade: boolean; +} +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new (): HTMLHRElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Retrieves the contained object. + */ + object: Object; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL of the file containing the compiled Java class. + */ + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + declare: boolean; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new (): HTMLObjectElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Retrieves the palette used for the embedded document. + */ + palette: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + pluginspage: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the height and width units of the embed object. + */ + units: string; +} +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new (): HTMLEmbedElement; +} + +interface StorageEvent extends Event { + oldValue: any; + newValue: any; + url: string; + storageArea: Storage; + key: string; + initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; +} +declare var StorageEvent: { + prototype: StorageEvent; + new (): StorageEvent; +} + +interface CharacterData extends Node { + length: number; + data: string; + deleteData(offset: number, count: number): void; + replaceData(offset: number, count: number, arg: string): void; + appendData(arg: string): void; + insertData(offset: number, arg: string): void; + substringData(offset: number, count: number): string; +} +declare var CharacterData: { + prototype: CharacterData; + new (): CharacterData; +} + +interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; +} +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new (): HTMLOptGroupElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + prompt: string; +} +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new (): HTMLIsIndexElement; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new (): SVGPathSegLinetoRel; +} + +interface DOMException { + code: number; + message: string; + toString(): string; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} +declare var DOMException: { + prototype: DOMException; + new (): DOMException; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new (): SVGAnimatedBoolean; +} + +interface MSCompatibleInfoCollection { + length: number; + item(index: number): MSCompatibleInfo; +} +declare var MSCompatibleInfoCollection: { + prototype: MSCompatibleInfoCollection; + new (): MSCompatibleInfoCollection; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new (): SVGSwitchElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new (): SVGPreserveAspectRatio; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} + +interface Attr extends Node { + expando: boolean; + specified: boolean; + ownerElement: Element; + value: string; + name: string; +} +declare var Attr: { + prototype: Attr; + new (): Attr; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new (): PerformanceNavigation; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; +} +declare var SVGStopElement: { + prototype: SVGStopElement; + new (): SVGStopElement; +} + +interface PositionCallback { + (position: Position): void; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { +} +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new (): SVGSymbolElement; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new (): SVGElementInstanceList; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} +declare var CSSRuleList: { + prototype: CSSRuleList; + new (): CSSRuleList; +} + +interface MSDataBindingRecordSetExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface LinkStyle { + styleSheet: StyleSheet; + sheet: StyleSheet; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the width of the video element. + */ + width: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoWidth: number; + /** + * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoHeight: number; + /** + * Gets or sets the height of the video element. + */ + height: number; + /** + * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. + */ + poster: string; +} +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new (): HTMLVideoElement; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} +declare var ClientRectList: { + prototype: ClientRectList; + new (): ClientRectList; +} + +interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + maskUnits: SVGAnimatedEnumeration; + maskContentUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new (): SVGMaskElement; +} + +interface External { +} +declare var External: { + prototype: External; + new (): External; +} + +declare var Audio: { new (src?: string): HTMLAudioElement; }; +declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; +declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; + +declare var ondragend: (ev: DragEvent) => any; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare var ondragover: (ev: DragEvent) => any; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare var onreset: (ev: Event) => any; +declare var onmouseup: (ev: MouseEvent) => any; +declare var ondragstart: (ev: DragEvent) => any; +declare var ondrag: (ev: DragEvent) => any; +declare var screenX: number; +declare var onmouseover: (ev: MouseEvent) => any; +declare var ondragleave: (ev: DragEvent) => any; +declare var history: History; +declare var pageXOffset: number; +declare var name: string; +declare var onafterprint: (ev: Event) => any; +declare var onpause: (ev: Event) => any; +declare var onbeforeprint: (ev: Event) => any; +declare var top: Window; +declare var onmousedown: (ev: MouseEvent) => any; +declare var onseeked: (ev: Event) => any; +declare var opener: Window; +declare var onclick: (ev: MouseEvent) => any; +declare var innerHeight: number; +declare var onwaiting: (ev: Event) => any; +declare var ononline: (ev: Event) => any; +declare var ondurationchange: (ev: Event) => any; +declare var frames: Window; +declare var onblur: (ev: FocusEvent) => any; +declare var onemptied: (ev: Event) => any; +declare var onseeking: (ev: Event) => any; +declare var oncanplay: (ev: Event) => any; +declare var outerWidth: number; +declare var onstalled: (ev: Event) => any; +declare var onmousemove: (ev: MouseEvent) => any; +declare var innerWidth: number; +declare var onoffline: (ev: Event) => any; +declare var length: number; +declare var screen: Screen; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare var onratechange: (ev: Event) => any; +declare var onstorage: (ev: StorageEvent) => any; +declare var onloadstart: (ev: Event) => any; +declare var ondragenter: (ev: DragEvent) => any; +declare var onsubmit: (ev: Event) => any; +declare var self: Window; +declare var document: Document; +declare var onprogress: (ev: any) => any; +declare var ondblclick: (ev: MouseEvent) => any; +declare var pageYOffset: number; +declare var oncontextmenu: (ev: MouseEvent) => any; +declare var onchange: (ev: Event) => any; +declare var onloadedmetadata: (ev: Event) => any; +declare var onplay: (ev: Event) => any; +declare var onerror: ErrorEventHandler; +declare var onplaying: (ev: Event) => any; +declare var parent: Window; +declare var location: Location; +declare var oncanplaythrough: (ev: Event) => any; +declare var onabort: (ev: UIEvent) => any; +declare var onreadystatechange: (ev: Event) => any; +declare var outerHeight: number; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare var frameElement: Element; +declare var onloadeddata: (ev: Event) => any; +declare var onsuspend: (ev: Event) => any; +declare var window: Window; +declare var onfocus: (ev: FocusEvent) => any; +declare var onmessage: (ev: MessageEvent) => any; +declare var ontimeupdate: (ev: Event) => any; +declare var onresize: (ev: UIEvent) => any; +declare var onselect: (ev: UIEvent) => any; +declare var navigator: Navigator; +declare var styleMedia: StyleMedia; +declare var ondrop: (ev: DragEvent) => any; +declare var onmouseout: (ev: MouseEvent) => any; +declare var onended: (ev: Event) => any; +declare var onhashchange: (ev: Event) => any; +declare var onunload: (ev: Event) => any; +declare var onscroll: (ev: UIEvent) => any; +declare var screenY: number; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onload: (ev: Event) => any; +declare var onvolumechange: (ev: Event) => any; +declare var oninput: (ev: Event) => any; +declare var performance: Performance; +declare function alert(message?: any): void; +declare function scroll(x?: number, y?: number): void; +declare function focus(): void; +declare function scrollTo(x?: number, y?: number): void; +declare function print(): void; +declare function prompt(message?: string, defaul?: string): string; +declare function toString(): string; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function scrollBy(x?: number, y?: number): void; +declare function confirm(message?: string): boolean; +declare function close(): void; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function showModalDialog(url?: string, argument?: any, options?: any): any; +declare function blur(): void; +declare function getSelection(): Selection; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function attachEvent(event: string, listener: EventListener): boolean; +declare function detachEvent(event: string, listener: EventListener): void; +declare var localStorage: Storage; +declare var status: string; +declare var onmouseleave: (ev: MouseEvent) => any; +declare var screenLeft: number; +declare var offscreenBuffering: any; +declare var maxConnectionsPerServer: number; +declare var onmouseenter: (ev: MouseEvent) => any; +declare var clipboardData: DataTransfer; +declare var defaultStatus: string; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var onhelp: (ev: Event) => any; +declare var external: External; +declare var event: MSEventObj; +declare var onfocusout: (ev: FocusEvent) => any; +declare var screenTop: number; +declare var onfocusin: (ev: FocusEvent) => any; +declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; +declare function navigate(url: string): void; +declare function resizeBy(x?: number, y?: number): void; +declare function item(index: any): any; +declare function resizeTo(x?: number, y?: number): void; +declare function createPopup(arguments?: any): MSPopupWindow; +declare function toStaticHTML(html: string): string; +declare function execScript(code: string, language?: string): any; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function moveTo(x?: number, y?: number): void; +declare function moveBy(x?: number, y?: number): void; +declare function showHelp(url: string, helpArg?: any, features?: string): void; +declare var sessionStorage: Storage; +declare function clearTimeout(handle: number): void; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearInterval(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; + + +///////////////////////////// +/// IE10 DOM APIs +///////////////////////////// + + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface HTMLBodyElement { + onpopstate: (ev: PopStateEvent) => any; +} + +interface MSGestureEvent extends UIEvent { + offsetY: number; + translationY: number; + velocityExpansion: number; + velocityY: number; + velocityAngular: number; + translationX: number; + velocityX: number; + hwTimestamp: number; + offsetX: number; + screenX: number; + rotation: number; + expansion: number; + clientY: number; + screenY: number; + scale: number; + gestureObject: any; + clientX: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} +declare var MSGestureEvent: { + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface HTMLAnchorElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} + +interface HTMLInputElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a FileList object on a file type input object. + */ + files: FileList; + /** + * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. + */ + max: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. + */ + step: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Returns the input field value as a number. + */ + valueAsNumber: number; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Specifies the ID of a pre-defined datalist of options for an input element. + */ + list: HTMLElement; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. + */ + min: string; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Gets or sets a string containing a regular expression that the user's input must match. + */ + pattern: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. + * @param n Value to decrement the value by. + */ + stepDown(n?: number): void; + /** + * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. + * @param n Value to increment the value by. + */ + stepUp(n?: number): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +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; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + filterResX: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + primitiveUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + filterResY: SVGAnimatedInteger; + setFilterRes(filterResX: number, filterResY: number): void; +} + +interface TrackEvent extends Event { + track: any; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} +declare var MSGesture: { + prototype: MSGesture; + new (): MSGesture; +} + +interface TextTrackCue extends EventTarget { + onenter: (ev: Event) => any; + track: TextTrack; + endTime: number; + text: string; + pauseOnExit: boolean; + id: string; + startTime: number; + onexit: (ev: Event) => any; + getCueAsHTML(): DocumentFragment; +} +declare var TextTrackCue: { + prototype: TextTrackCue; + new (): TextTrackCue; +} + +interface MSStreamReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; +} +declare var MSStreamReader: { + prototype: MSStreamReader; + new (): MSStreamReader; +} + +interface DOMTokenList { + length: number; + contains(token: string): boolean; + remove(token: string): void; + toggle(token: string): boolean; + add(token: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} + +interface EventException { + name: string; +} + +interface Performance { + now(): number; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} +declare var SVGFEBlendElement: { + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} + +interface WindowTimers extends WindowTimersExtension { +} + +interface CSSStyleDeclaration { + animationFillMode: string; + floodColor: string; + animationIterationCount: string; + textShadow: string; + backfaceVisibility: string; + msAnimationIterationCount: string; + animationDelay: string; + animationTimingFunction: string; + columnWidth: any; + msScrollSnapX: string; + columnRuleColor: any; + columnRuleWidth: any; + transitionDelay: string; + transition: string; + msFlowFrom: string; + msScrollSnapType: string; + msContentZoomSnapType: string; + msGridColumns: string; + msAnimationName: string; + msGridRowAlign: string; + msContentZoomChaining: string; + msGridColumn: any; + msHyphenateLimitZone: any; + msScrollRails: string; + msAnimationDelay: string; + enableBackground: string; + msWrapThrough: string; + columnRuleStyle: string; + msAnimation: string; + msFlexFlow: string; + msScrollSnapY: string; + msHyphenateLimitLines: any; + msTouchAction: string; + msScrollLimit: string; + animation: string; + transform: string; + filter: string; + colorInterpolationFilters: string; + transitionTimingFunction: string; + msBackfaceVisibility: string; + animationPlayState: string; + transformOrigin: string; + msScrollLimitYMin: any; + msFontFeatureSettings: string; + msContentZoomLimitMin: any; + columnGap: any; + transitionProperty: string; + msAnimationDuration: string; + msAnimationFillMode: string; + msFlexDirection: string; + msTransitionDuration: string; + fontFeatureSettings: string; + breakBefore: string; + msFlexWrap: string; + perspective: string; + msFlowInto: string; + msTransformStyle: string; + msScrollTranslation: string; + msTransitionProperty: string; + msUserSelect: string; + msOverflowStyle: string; + msScrollSnapPointsY: string; + animationDirection: string; + animationDuration: string; + msFlex: string; + msTransitionTimingFunction: string; + animationName: string; + columnRule: string; + msGridColumnSpan: any; + msFlexNegative: string; + columnFill: string; + msGridRow: any; + msFlexOrder: string; + msFlexItemAlign: string; + msFlexPositive: string; + msContentZoomLimitMax: any; + msScrollLimitYMax: any; + msGridColumnAlign: string; + perspectiveOrigin: string; + lightingColor: string; + columns: string; + msScrollChaining: string; + msHyphenateLimitChars: string; + msTouchSelect: string; + floodOpacity: string; + msAnimationDirection: string; + msAnimationPlayState: string; + columnSpan: string; + msContentZooming: string; + msPerspective: string; + msFlexPack: string; + msScrollSnapPointsX: string; + msContentZoomSnapPoints: string; + msGridRowSpan: any; + msContentZoomSnap: string; + msScrollLimitXMin: any; + breakInside: string; + msHighContrastAdjust: string; + msFlexLinePack: string; + msGridRows: string; + transitionDuration: string; + msHyphens: string; + breakAfter: string; + msTransition: string; + msPerspectiveOrigin: string; + msContentZoomLimit: string; + msScrollLimitXMax: any; + msFlexAlign: string; + msWrapMargin: any; + columnCount: any; + msAnimationTimingFunction: string; + msTransitionDelay: string; + transformStyle: string; + msWrapFlow: string; + msFlexPreferredSize: string; +} + +interface MessageChannel { + port2: MessagePort; + port1: MessagePort; +} +declare var MessageChannel: { + prototype: MessageChannel; + new (): MessageChannel; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} + +interface Navigator extends MSFileSaver { + msMaxTouchPoints: number; + msPointerEnabled: boolean; + msManipulationViewsEnabled: boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; +} + +interface TransitionEvent extends Event { + propertyName: string; + elapsedTime: number; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +interface DOMError { + name: string; + toString(): string; +} + +interface CloseEvent extends Event { + wasClean: boolean; + reason: string; + code: number; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +interface WebSocket extends EventTarget { + protocol: string; + readyState: number; + bufferedAmount: number; + onopen: (ev: Event) => any; + extensions: string; + onmessage: (ev: any) => any; + onclose: (ev: CloseEvent) => any; + onerror: (ev: ErrorEvent) => any; + binaryType: string; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} +declare var WebSocket: { + prototype: WebSocket; + new (url: string): WebSocket; + new (url: string, prototcol: string): WebSocket; + new (url: string, prototcol: string[]): WebSocket; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} + +interface SVGFEPointLightElement extends SVGElement { + y: SVGAnimatedNumber; + x: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} + +interface ProgressEvent extends Event { + loaded: number; + lengthComputable: boolean; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + name: string; + transaction: IDBTransaction; + keyPath: string; + count(key?: any): IDBRequest; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + put(value: any, key?: any): IDBRequest; + openCursor(range?: any, direction?: string): IDBRequest; + deleteIndex(indexName: string): void; + index(name: string): IDBIndex; + get(key: any): IDBRequest; + delete(key: any): IDBRequest; +} + +interface HTMLCanvasElement { + /** + * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. + */ + msToBlob(): Blob; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + stdDeviationX: SVGAnimatedNumber; + in1: SVGAnimatedString; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + result: SVGAnimatedString; +} + +interface Element { + msRegionOverflow: string; + onmspointerdown: (ev: any) => any; + onmsgotpointercapture: (ev: any) => any; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + onmslostpointercapture: (ev: any) => any; + onmspointerover: (ev: any) => any; + msContentZoomFactor: number; + onmspointerup: (ev: any) => any; + msGetRegionContent(): MSRangeCollection; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} + +interface IDBIndex { + unique: boolean; + name: string; + keyPath: string; + objectStore: IDBObjectStore; + count(key?: any): IDBRequest; + getKey(key: any): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + get(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} + +interface WheelEvent { + getCurrentPoint(element: Element): void; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} + +interface IDBCursor { + source: any; + direction: string; + key: any; + primaryKey: any; + advance(count: number): void; + delete(): IDBRequest; + continue(key?: any): void; + update(value: any): IDBRequest; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} + +interface URL { + revokeObjectURL(url: string): void; + createObjectURL(object: any, options?: ObjectURLOptions): string; +} +declare var URL: URL; + +interface RangeException { + name: string; +} + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} + +interface HTMLTextAreaElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface XMLHttpRequestEventTarget extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: any) => any; + ontimeout: (ev: any) => any; + onabort: (ev: any) => any; + onloadstart: (ev: any) => any; + onloadend: (ev: ProgressEvent) => any; +} + +interface IDBEnvironment { + msIndexedDB: IDBFactory; + indexedDB: IDBFactory; +} + +interface AudioTrackList extends EventTarget { + length: number; + onchange: (ev: any) => any; + onaddtrack: (ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + [index: number]: AudioTrack; +} + +interface MSBaseReader extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + readyState: number; + onabort: (ev: any) => any; + onloadend: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: any) => any; + onloadstart: (ev: any) => any; + result: any; + abort(): void; + LOADING: number; + EMPTY: number; + DONE: number; +} + +interface History { + state: any; + replaceState(statedata: any, title: string, url?: string): void; + pushState(statedata: any, title: string, url?: string): void; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} +declare var SVGFEMorphologyElement: { + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} + +interface HTMLSelectElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface CSSRule { + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} +//declare var CSSRule: { +// KEYFRAMES_RULE: number; +// KEYFRAME_RULE: number; +// VIEWPORT_RULE: number; +//} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} + +interface WindowTimersExtension { + msSetImmediate(expression: any, ...args: any[]): number; + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + setImmediate(expression: any, ...args: any[]): number; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + scale: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} +declare var SVGFEDisplacementMapElement: { + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + tableValues: SVGAnimatedNumberList; + slope: SVGAnimatedNumber; + type: SVGAnimatedEnumeration; + exponent: SVGAnimatedNumber; + amplitude: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} +declare var SVGComponentTransferFunctionElement: { + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} + +interface SVGException { + name: string; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} + +interface IDBKeyRange { + upper: any; + upperOpen: boolean; + lower: any; + lowerOpen: boolean; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface WindowConsole { + console: Console; +} + +interface IDBTransaction extends EventTarget { + oncomplete: (ev: Event) => any; + db: IDBDatabase; + mode: string; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: any) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; +} + +interface AudioTrack { + kind: string; + language: string; + id: string; + label: string; + enabled: boolean; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + orderY: SVGAnimatedInteger; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + kernelMatrix: SVGAnimatedNumberList; + edgeMode: SVGAnimatedEnumeration; + kernelUnitLengthX: SVGAnimatedNumber; + bias: SVGAnimatedNumber; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + divisor: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} +declare var SVGFEConvolveMatrixElement: { + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} + +interface TextTrackCueList { + length: number; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; + getCueById(id: string): TextTrackCue; +} + +interface CSSKeyframesRule extends CSSRule { + name: string; + cssRules: CSSRuleList; + findRule(rule: string): CSSKeyframeRule; + deleteRule(rule: string): void; + appendRule(rule: string): void; +} + +interface Window extends WindowBase64, IDBEnvironment, WindowConsole { + onmspointerdown: (ev: any) => any; + animationStartTime: number; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + msAnimationStartTime: number; + applicationCache: ApplicationCache; + onmsinertiastart: (ev: any) => any; + onmspointerover: (ev: any) => any; + onpopstate: (ev: PopStateEvent) => any; + onmspointerup: (ev: any) => any; + msCancelRequestAnimationFrame(handle: number): void; + matchMedia(mediaQuery: string): MediaQueryList; + cancelAnimationFrame(handle: number): void; + msIsStaticHTML(html: string): boolean; + msMatchMedia(mediaQuery: string): MediaQueryList; + requestAnimationFrame(callback: FrameRequestCallback): number; + msRequestAnimationFrame(callback: FrameRequestCallback): number; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + type: SVGAnimatedEnumeration; + baseFrequencyY: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + seed: SVGAnimatedNumber; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} +declare var SVGFETurbulenceElement: { + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} + +interface TextTrackList { + length: number; + item(index: number): TextTrack; + [index: number]: TextTrack; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} +declare var SVGFEColorMatrixElement: { + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} + +interface Console { + info(message?: any, ...optionalParams: any[]): void; + profile(reportName?: string): void; + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + clear(): void; + dir(value?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; + error(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + profileEnd(): void; +} + +interface SVGFESpotLightElement extends SVGElement { + pointsAtY: SVGAnimatedNumber; + y: SVGAnimatedNumber; + limitingConeAngle: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + z: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; +} + +interface HTMLImageElement { + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; +} + +interface WindowBase64 { + btoa(rawString: string): string; + atob(encodedString: string): string; +} + +interface IDBDatabase extends EventTarget { + version: string; + name: string; + objectStoreNames: DOMStringList; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: any) => any; + createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + close(): void; + transaction(storeNames: any, mode?: string): IDBTransaction; + deleteObjectStore(name: string): void; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} + +interface HTMLButtonElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface IDBOpenDBRequest extends IDBRequest { + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + onblocked: (ev: Event) => any; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. + */ + value: number; + /** + * Defines the maximum, or "done" value for a progress element. + */ + max: number; + /** + * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). + */ + position: number; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} + +interface MSLaunchUriCallback { + (): void; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + dx: SVGAnimatedNumber; +} + +interface HTMLFormElement { + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Designates a form that is not validated when submitted. + */ + noValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; +} + +interface MSUnsafeFunctionCallback { + (): any; +} + +interface Document { + onmspointerdown: (ev: any) => any; + msHidden: boolean; + msVisibilityState: string; + onmsgesturedoubletap: (ev: any) => any; + visibilityState: string; + onmsmanipulationstatechanged: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmscontentzoom: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + msCSSOMElementFloatMetrics: boolean; + onmspointerover: (ev: any) => any; + hidden: boolean; + onmspointerup: (ev: any) => any; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + clear(): void; +} + +interface MessageEvent extends Event { + ports: any; +} + +interface HTMLScriptElement { + async: boolean; +} + +interface HTMLMediaElement { + /** + * Specifies the purpose of the audio or video media, such as background audio or alerts. + */ + msAudioCategory: string; + /** + * Specifies whether or not to enable low-latency playback on the media element. + */ + msRealTime: boolean; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + textTracks: TextTrackList; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + audioTracks: AudioTrackList; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Specifies the output device id that the audio will be sent to. + */ + msAudioDeviceType: string; + /** + * Clears all effects from the media pipeline. + */ + msClearEffects(): void; + /** + * Specifies the media protection manager for a given media pipeline. + */ + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + /** + * Inserts the specified audio effect into media pipeline. + */ + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; +} + +interface TextTrack extends EventTarget { + language: string; + mode: any; + readyState: number; + activeCues: TextTrackCueList; + cues: TextTrackCueList; + oncuechange: (ev: Event) => any; + kind: string; + onload: (ev: any) => any; + onerror: (ev: ErrorEvent) => any; + label: string; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} +declare var TextTrack: { + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} + +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} + +interface IDBRequest extends EventTarget { + source: any; + onsuccess: (ev: Event) => any; + error: DOMError; + transaction: IDBTransaction; + onerror: (ev: ErrorEvent) => any; + readyState: string; + result: any; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: any) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; +} + +interface FileReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; +} +declare var FileReader: { + prototype: FileReader; + new (): FileReader; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface Blob { + type: string; + size: number; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; + msClose(): void; +} +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface ApplicationCache extends EventTarget { + status: number; + ondownloading: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onupdateready: (ev: Event) => any; + oncached: (ev: Event) => any; + onobsolete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + onchecking: (ev: Event) => any; + onnoupdate: (ev: Event) => any; + swapCache(): void; + abort(): void; + update(): void; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} +declare var ApplicationCache: { + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} + +interface FrameRequestCallback { + (time: number): void; +} + +interface XMLHttpRequest { + response: any; + withCredentials: boolean; + onprogress: (ev: ProgressEvent) => any; + onabort: (ev: any) => any; + responseType: string; + onloadend: (ev: ProgressEvent) => any; + upload: XMLHttpRequestEventTarget; + onerror: (ev: ErrorEvent) => any; + onloadstart: (ev: any) => any; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSStream { + type: string; + msDetachStream(): any; + msClose(): void; +} + +interface MediaError { + msExtendedCode: number; +} + +interface HTMLFieldSetElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new (): MSBlobBuilder; +} + +interface HTMLElement { + onmscontentzoom: (ev: any) => any; + oncuechange: (ev: Event) => any; + spellcheck: boolean; + classList: DOMTokenList; + onmsmanipulationstatechanged: (ev: any) => any; + draggable: boolean; +} + +interface DataTransfer { + types: DOMStringList; + files: FileList; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} + +interface IDBFactory { + open(name: string, version?: number): IDBOpenDBRequest; + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; +} + +interface Range { + createContextualFragment(fragment: string): DocumentFragment; +} + +interface HTMLObjectElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface MSPointerEvent 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; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} +declare var MSPointerEvent: { + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} + +interface DOMException { + name: string; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} +//declare var DOMException: { +// INVALID_NODE_TYPE_ERR: number; +// DATA_CLONE_ERR: number; +// TIMEOUT_ERR: number; +//} + +interface MSManipulationEvent extends UIEvent { + lastState: number; + currentState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} +declare var MSManipulationEvent: { + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} + +interface FormData { + append(name: any, value: any, blobName?: string): void; +} +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollection; +} + +interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface AbstractWorker extends EventTarget { + onerror: (ev: ErrorEvent) => any; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + in2: SVGAnimatedString; + k2: SVGAnimatedNumber; + k1: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + in1: SVGAnimatedString; + k4: SVGAnimatedNumber; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} +declare var SVGFECompositeElement: { + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} + +interface ValidityState { + customError: boolean; + valueMissing: boolean; + stepMismatch: boolean; + rangeUnderflow: boolean; + rangeOverflow: boolean; + typeMismatch: boolean; + patternMismatch: boolean; + tooLong: boolean; + valid: boolean; +} + +interface HTMLTrackElement extends HTMLElement { + kind: string; + src: string; + srclang: string; + track: TextTrack; + label: string; + default: boolean; +} + +interface MSApp { + createFileFromStorageFile(storageFile: any): File; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + terminateApp(exceptionObject: any): void; + createDataPackage(object: any): any; + execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; + getHtmlPrintDocumentSource(htmlDoc: any): any; + addPublicLocalApplicationUri(uri: string): void; + createDataPackageFromSelection(): any; +} +declare var MSApp: MSApp; + +interface HTMLVideoElement { + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + onMSVideoOptimalLayoutChanged: (ev: any) => any; + onMSVideoFrameStepCompleted: (ev: any) => any; + msStereo3DRenderMode: string; + msIsLayoutOptimalForPlayback: boolean; + msHorizontalMirror: boolean; + onMSVideoFormatChanged: (ev: any) => any; + msZoom: boolean; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + msFrameStep(forward: boolean): void; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + diffuseConstant: SVGAnimatedNumber; +} + +interface MSCSSMatrix { + m24: number; + m34: number; + a: number; + d: number; + m32: number; + m41: number; + m11: number; + f: number; + e: number; + m23: number; + m14: number; + m33: number; + m22: number; + m21: number; + c: number; + m12: number; + b: number; + m42: number; + m31: number; + m43: number; + m13: number; + m44: number; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + setMatrixValue(value: string): void; + inverse(): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + toString(): string; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + translate(x: number, y: number, z?: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + skewX(angle: number): MSCSSMatrix; +} +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new (text?: string): MSCSSMatrix; +} + +interface Worker extends AbstractWorker { + onmessage: (ev: any) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; +} +declare var Worker: { + prototype: Worker; + new (stringUrl: string): Worker; +} + +interface HTMLIFrameElement { + sandbox: DOMSettableTokenList; +} + +declare var onmspointerdown: (ev: any) => any; +declare var animationStartTime: number; +declare var onmsgesturedoubletap: (ev: any) => any; +declare var onmspointerhover: (ev: any) => any; +declare var onmsgesturehold: (ev: any) => any; +declare var onmspointermove: (ev: any) => any; +declare var onmsgesturechange: (ev: any) => any; +declare var onmsgesturestart: (ev: any) => any; +declare var onmspointercancel: (ev: any) => any; +declare var onmsgestureend: (ev: any) => any; +declare var onmsgesturetap: (ev: any) => any; +declare var onmspointerout: (ev: any) => any; +declare var msAnimationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var onmsinertiastart: (ev: any) => any; +declare var onmspointerover: (ev: any) => any; +declare var onpopstate: (ev: PopStateEvent) => any; +declare var onmspointerup: (ev: any) => any; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function cancelAnimationFrame(handle: number): void; +declare function msIsStaticHTML(html: string): boolean; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function btoa(rawString: string): string; +declare function atob(encodedString: string): string; +declare var msIndexedDB: IDBFactory; +declare var indexedDB: IDBFactory; +declare var console: Console; + + +///////////////////////////// +/// IE11 DOM APIs +///////////////////////////// + + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: Array; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: Array; +} + +interface AlgorithmParameters { +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: Array; +} + +interface ExceptionInformation { + domain?: string; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface Algorithm { + name?: string; + params?: AlgorithmParameters; +} + +interface NavigatorID { + product: string; + vendor: string; +} + +interface HTMLBodyElement { + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; +} + +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} + +interface MSWindowExtensions { + captureEvents(): void; + releaseEvents(): void; +} + +interface MSGraphicsTrust { + status: string; + constrictionActive: boolean; +} + +interface AudioTrack { + sourceBuffer: SourceBuffer; +} + +interface DragEvent { + msConvertURL(file: File, targetType: string, targetURL?: string): void; +} + +interface SubtleCrypto { + unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; + encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; + verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; + deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; + exportKey(format: string, key: Key): KeyOperation; + generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; +} + +interface Crypto extends RandomSource { + subtle: SubtleCrypto; +} + +interface VideoPlaybackQuality { + totalFrameDelay: number; + creationTime: number; + totalVideoFrames: number; + droppedVideoFrames: number; +} + +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 extends GlobalEventHandlers { + onpageshow: (ev: PageTransitionEvent) => any; + ondevicemotion: (ev: DeviceMotionEvent) => any; + devicePixelRatio: number; + msCrypto: Crypto; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + doNotTrack: string; + onmspointerenter: (ev: any) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onmspointerleave: (ev: any) => any; +} + +interface Key { + algorithm: Algorithm; + type: string; + extractable: boolean; + keyUsage: string[]; +} + +interface TextTrackList extends EventTarget { + onaddtrack: (ev: any) => any; +} + +interface DeviceAcceleration { + y: number; + x: number; + z: number; +} + +interface Console { + count(countTitle?: string): void; + groupEnd(): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(): void; + group(groupTitle?: string): void; + dirxml(value: any): void; + debug(message?: string, ...optionalParams: any[]): void; + groupCollapsed(groupTitle?: string): void; + select(element: Element): void; +} + +interface MSNavigatorDoNotTrack { + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; +} + +interface HTMLImageElement { + crossOrigin: string; + msPlayToPreferredSourceUri: string; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; + //[name: string]: Element; +} + +interface MSNavigatorExtensions { + language: string; +} + +interface AesGcmEncryptResult { + ciphertext: ArrayBuffer; + tag: ArrayBuffer; +} + +interface HTMLSourceElement { + msKeySystem: string; +} + +interface CSSStyleDeclaration { + alignItems: string; + borderImageSource: string; + flexBasis: string; + borderImageWidth: string; + borderImageRepeat: string; + order: string; + flex: string; + alignContent: string; + msImeAlign: string; + flexShrink: string; + flexGrow: string; + borderImageSlice: string; + flexWrap: string; + borderImageOutset: string; + flexDirection: string; + touchAction: string; + flexFlow: string; + borderImage: string; + justifyContent: string; + alignSelf: string; + msTextCombineHorizontal: string; +} + +interface NavigationCompletedEvent extends NavigationEvent { + webErrorStatus: number; + isSuccess: boolean; +} + +interface MutationRecord { + oldValue: string; + previousSibling: Node; + addedNodes: NodeList; + attributeName: string; + removedNodes: NodeList; + target: Node; + nextSibling: Node; + attributeNamespace: string; + type: string; +} + +interface Navigator { + pointerEnabled: boolean; + maxTouchPoints: number; +} + +interface Document extends MSDocumentExtensions, GlobalEventHandlers { + msFullscreenEnabled: boolean; + onmsfullscreenerror: (ev: any) => any; + onmspointerenter: (ev: any) => any; + msFullscreenElement: Element; + onmsfullscreenchange: (ev: any) => any; + onmspointerleave: (ev: any) => any; + msExitFullscreen(): void; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(type: string): Plugin; + //[type: string]: Plugin; +} + +interface HTMLMediaElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + msKeys: MSMediaKeys; + msGraphicsTrustStatus: MSGraphicsTrust; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; +} + +interface TextTrack { + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; +} + +interface KeyOperation extends EventTarget { + oncomplete: (ev: any) => any; + onerror: (ev: any) => any; + result: any; +} + +interface DOMStringMap { +} + +interface DeviceOrientationEvent extends Event { + gamma: number; + alpha: number; + absolute: boolean; + beta: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; + isTypeSupported(keySystem: string, type?: string): boolean; +} +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new (): MSMediaKeys; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} + +interface MSHTMLWebViewElement extends HTMLElement { + documentTitle: string; + width: number; + src: string; + canGoForward: boolean; + height: number; + canGoBack: boolean; + navigateWithHttpRequestMessage(requestMessage: any): void; + goBack(): void; + navigate(uri: string): void; + stop(): void; + navigateToString(contents: string): void; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + refresh(): void; + goForward(): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; +} + +interface NavigationEvent extends Event { + uri: string; +} + +interface Element extends GlobalEventHandlers { + onlostpointercapture: (ev: PointerEvent) => any; + onmspointerenter: (ev: any) => any; + ongotpointercapture: (ev: PointerEvent) => any; + onmspointerleave: (ev: any) => any; + msZoomTo(args: MsZoomToOptions): void; + setPointerCapture(pointerId: number): void; + msGetUntransformedBounds(): ClientRect; + releasePointerCapture(pointerId: number): void; + msRequestFullscreen(): void; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface XMLHttpRequest { + msCaching: string; + msCachingEnabled(): boolean; + overrideMimeType(mime: string): void; +} + +interface SourceBuffer extends EventTarget { + updating: boolean; + appendWindowStart: number; + appendWindowEnd: number; + buffered: TimeRanges; + timestampOffset: number; + audioTracks: AudioTrackList; + appendBuffer(data: ArrayBuffer): void; + remove(start: number, end: number): void; + abort(): void; + appendStream(stream: MSStream, maxSize?: number): void; +} + +interface MSInputMethodContext extends EventTarget { + oncandidatewindowshow: (ev: any) => any; + target: HTMLElement; + compositionStartOffset: number; + oncandidatewindowhide: (ev: any) => any; + oncandidatewindowupdate: (ev: any) => any; + compositionEndOffset: number; + getCompositionAlternatives(): string[]; + getCandidateWindowClientRect(): ClientRect; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; +} + +interface DeviceRotationRate { + gamma: number; + alpha: number; + beta: number; +} + +interface PluginArray { + length: number; + refresh(reload?: boolean): void; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(name: string): Plugin; + //[name: string]: Plugin; +} + +interface MSMediaKeyError { + systemCode: number; + code: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} +declare var MSMediaKeyError: { + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} + +interface Plugin { + length: number; + filename: string; + version: string; + name: string; + description: string; + item(index: number): MimeType; + [index: number]: MimeType; + namedItem(type: string): MimeType; + //[type: string]: MimeType; +} + +interface HTMLFrameSetElement { + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; +} + +interface Screen extends EventTarget { + msOrientation: string; + onmsorientationchange: (ev: any) => any; + msLockOrientation(orientations: string[]): boolean; + msUnlockOrientation(): void; +} + +interface MediaSource extends EventTarget { + sourceBuffers: SourceBufferList; + duration: number; + readyState: string; + activeSourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: string): void; + isTypeSupported(type: string): boolean; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} +declare var MediaSource: { + prototype: MediaSource; + new (): MediaSource; +} + +interface MediaError { + MS_MEDIA_ERR_ENCRYPTED: number; +} +//declare var MediaError: { +// MS_MEDIA_ERR_ENCRYPTED: number; +//} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +interface XMLDocument extends Document { +} + +interface DeviceMotionEvent extends Event { + rotationRate: DeviceRotationRate; + acceleration: DeviceAcceleration; + interval: number; + accelerationIncludingGravity: DeviceAcceleration; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} + +interface MimeType { + enabledPlugin: Plugin; + suffixes: string; + type: string; + description: string; +} + +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 { + captureEvents(): void; + releaseEvents(): void; +} + +interface HTMLElement { + dataset: DOMStringMap; + hidden: boolean; + msGetInputContext(): MSInputMethodContext; +} + +interface MutationObserver { + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; + disconnect(): void; +} +declare var MutationObserver: { + prototype: MutationObserver; + new (): MutationObserver; +} + +interface AudioTrackList { + onremovetrack: (ev: PluginArray) => any; +} + +interface HTMLObjectElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * 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. + */ + msPlayToSource: any; +} + +interface HTMLEmbedElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * 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. + */ + msPlayToSource: any; +} + +interface MSWebViewAsyncOperation extends EventTarget { + target: MSHTMLWebViewElement; + oncomplete: (ev: any) => any; + error: DOMError; + onerror: (ev: any) => any; + readyState: number; + type: number; + result: any; + start(): void; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} +declare var MSWebViewAsyncOperation: { + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} + +interface ScriptNotifyEvent extends Event { + value: string; + callingUri: string; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + redirectCount: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + type: string; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} + +interface MSManipulationEvent { + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_CANCELLED: number; +} +//declare var MSManipulationEvent: { +// MS_MANIPULATION_STATE_SELECTING: number; +// MS_MANIPULATION_STATE_COMMITTED: number; +// MS_MANIPULATION_STATE_PRESELECT: number; +// MS_MANIPULATION_STATE_DRAGGING: number; +// MS_MANIPULATION_STATE_CANCELLED: number; +//} + +interface LongRunningScriptDetectedEvent extends Event { + stopPageScriptExecution: boolean; + executionTime: number; +} + +interface MSAppView { + viewId: number; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; +} + +interface PerfWidgetExternal { + maxCpuSpeed: 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; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} + +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} + +interface HTMLDocument extends Document { +} + +interface KeyPair { + privateKey: Key; + publicKey: Key; +} + +interface MSApp { + getViewOpener(): MSAppView; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + createNewView(uri: string): MSAppView; + getCurrentPriority(): string; + NORMAL: string; + HIGH: string; + IDLE: string; + CURRENT: string; +} +//declare var MSApp: { +// NORMAL: string; +// HIGH: string; +// IDLE: string; +// CURRENT: string; +//} + +interface MSMediaKeySession extends EventTarget { + sessionId: string; + error: MSMediaKeyError; + keySystem: string; + close(): void; + update(key: Uint8Array): void; +} + +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 { + getVideoPlaybackQuality(): VideoPlaybackQuality; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEvent { + referrer: string; +} + +interface CryptoOperation extends EventTarget { + algorithm: Algorithm; + oncomplete: (ev: any) => any; + onerror: (ev: any) => any; + onprogress: (ev: any) => any; + onabort: (ev: any) => any; + key: Key; + result: any; + abort(): void; + finish(): void; + process(buffer: ArrayBufferView): void; +} + +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare var devicePixelRatio: number; +declare var msCrypto: Crypto; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare var doNotTrack: string; +declare var onmspointerenter: (ev: any) => any; +declare var onpagehide: (ev: PageTransitionEvent) => any; +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; + + +///////////////////////////// +/// WorkerGlobalScope APIs +///////////////////////////// +// TODO: These are only available in a Web Worker - should be in a separate lib file +declare function importScripts(...urls: string[]): void; + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// +declare var ActiveXObject: { new (s: string): any; }; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +declare var WScript: { + Echo(s: any): void; + StdErr: ITextWriter; + StdOut: ITextWriter; + Arguments: { length: number; Item(n: number): string; }; + ScriptFullName: string; + Quit(exitCode?: number): number; +} diff --git a/_infrastructure/tests/typescript/0.9.7-59a846/tsc b/_infrastructure/tests/typescript/0.9.7-59a846/tsc new file mode 100644 index 0000000000..3c0dab574f --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-59a846/tsc @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./tsc.js') diff --git a/_infrastructure/tests/typescript/0.9.7-59a846/tsc.js b/_infrastructure/tests/typescript/0.9.7-59a846/tsc.js new file mode 100644 index 0000000000..37eafa1aed --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-59a846/tsc.js @@ -0,0 +1,62781 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.DiagnosticCode = { + error_TS_0_1: "error TS{0}: {1}", + warning_TS_0_1: "warning TS{0}: {1}", + Unrecognized_escape_sequence: "Unrecognized escape sequence.", + Unexpected_character_0: "Unexpected character {0}.", + Missing_close_quote_character: "Missing close quote character.", + Identifier_expected: "Identifier expected.", + _0_keyword_expected: "'{0}' keyword expected.", + _0_expected: "'{0}' expected.", + Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", + Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", + Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", + Trailing_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", + Unexpected_token: "Unexpected token.", + Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", + Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", + Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", + Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", + Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", + Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", + extends_clause_already_seen: "'extends' clause already seen.", + extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", + Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", + implements_clause_already_seen: "'implements' clause already seen.", + Accessibility_modifier_already_seen: "Accessibility modifier already seen.", + _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", + _0_modifier_already_seen: "'{0}' modifier already seen.", + _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", + Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", + super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", + Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", + Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", + 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_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}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", + set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", + set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", + get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", + Modifiers_cannot_appear_here: "Modifiers cannot appear here.", + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", + Class_name_cannot_be_0: "Class name cannot be '{0}'.", + Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", + Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + Enum_member_must_have_initializer: "Enum member must have initializer.", + Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", + module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", + constructor_function_accessor_or_variable: "constructor, function, accessor or variable", + statement: "statement", + case_or_default_clause: "case or default clause", + identifier: "identifier", + call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", + expression: "expression", + type_name: "type name", + property_or_accessor: "property or accessor", + parameter: "parameter", + type: "type", + type_parameter: "type parameter", + 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_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.", + super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", + Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", + Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", + Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", + Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", + Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", + Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", + Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", + Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", + Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", + Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", + Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", + Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", + Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", + Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", + Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", + Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", + Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", + Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", + Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", + Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", + Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", + Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", + Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", + Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", + Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", + Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", + Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", + Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", + Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", + Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", + Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", + Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", + Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", + Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", + A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", + Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", + Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", + Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", + A_class_may_only_extend_another_class: "A class may only extend another class.", + A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", + An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", + Unable_to_resolve_type: "Unable to resolve type.", + Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", + Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", + Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", + Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", + Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", + Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", + Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", + Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", + Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + 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_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.", + _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.", + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", + Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", + Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", + 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_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}'.", + 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.", + Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", + Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", + Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", + All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", + Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", + Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", + this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", + Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", + Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", + 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_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.", + Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", + A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", + 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_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_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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", + Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", + Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", + 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_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}", + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", + Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", + All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", + super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", + Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", + Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", + Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", + Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", + Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", + continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", + break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", + Jump_target_not_found: "Jump target not found.", + Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", + TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", + TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", + TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", + TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", + TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", + TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", + Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", + 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}", + Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", + Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", + Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", + Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", + Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", + Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", + Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", + Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", + Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", + 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.", + 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_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_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.", + Could_not_find_file_0: "Could not find file: '{0}'.", + A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", + Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", + Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", + Emit_Error_0: "Emit Error: {0}.", + Cannot_read_file_0_1: "Cannot read file '{0}': {1}", + Unsupported_file_encoding: "Unsupported file encoding.", + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Invalid_call_to_up: "Invalid call to 'up'", + Invalid_call_to_down: "Invalid call to 'down'", + Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", + Unknown_option_0: "Unknown option '{0}'", + Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", + Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", + Could_not_delete_file_0: "Could not delete file '{0}'", + Could_not_create_directory_0: "Could not create directory '{0}'", + Error_while_executing_file_0: "Error while executing file '{0}': ", + Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", + Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", + Option_0_specified_without_1: "Option '{0}' specified without '{1}'", + codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", + Generates_corresponding_0_file: "Generates corresponding {0} file.", + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", + Watch_input_files: "Watch input files.", + Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", + Do_not_emit_comments_to_output: "Do not emit comments to output.", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", + Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", + Print_this_message: "Print this message.", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file1: "file", + Examples: "Examples:", + Options: "Options:", + Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", + Version_0: "Version {0}", + Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", + NL_Recompiling_0: "{NL}Recompiling ({0}):", + STRING: "STRING", + KIND: "KIND", + file2: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + 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})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", + Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", + Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", + Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", + Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", + new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", + _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", + Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", + 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.", + 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; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + return false; + } + + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0, n = array1.length; i < n; i++) { + if (!equals(array1[i], array2[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.distinct = function (array, equalsFn) { + var result = []; + + for (var i = 0, n = array.length; i < n; i++) { + var current = array[i]; + for (var j = 0; j < result.length; j++) { + if (equalsFn(result[j], current)) { + break; + } + } + + if (j === result.length) { + result.push(current); + } + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.lastOrDefault = function (array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var v = array[i]; + if (predicate(v, i)) { + return v; + } + } + + return null; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value, i)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.first = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (!func || func(value, i)) { + return value; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + var low = 0; + var high = array.length - 1; + + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + + if (midValue === value) { + return middle; + } else if (midValue > value) { + high = middle - 1; + } else { + low = middle + 1; + } + } + + return ~low; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + + ArrayUtilities.indexOf = function (array, predicate) { + for (var i = 0, n = array.length; i < n; i++) { + if (predicate(array[i])) { + return i; + } + } + + return -1; + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitVector) { + var pool = []; + var Constants; + (function (Constants) { + Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; + Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; + + Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; + + Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; + Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; + + Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; + Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; + Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; + })(Constants || (Constants = {})); + + var BitVectorImpl = (function () { + function BitVectorImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.bits = []; + } + BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; + }; + + BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; + }; + + BitVectorImpl.prototype.valueAt = function (index) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return undefined; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { + return true; + } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { + return false; + } else { + return undefined; + } + } else { + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return false; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { + return true; + } else { + return false; + } + } + }; + + BitVectorImpl.prototype.setValueAt = function (index, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); + + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === undefined) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + + var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); + encoded = encoded & clearMask; + + if (value === true) { + encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); + } else if (value === false) { + encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } else { + TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); + + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === false) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + + encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); + + if (value) { + encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } + }; + + BitVectorImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + this.bits.length = 0; + pool.push(this); + }; + return BitVectorImpl; + })(); + + function getBitVector(allowUndefinedValues) { + if (pool.length === 0) { + return new BitVectorImpl(allowUndefinedValues); + } + + var vector = pool.pop(); + vector.isReleased = false; + vector.allowUndefinedValues = allowUndefinedValues; + + return vector; + } + BitVector.getBitVector = getBitVector; + })(TypeScript.BitVector || (TypeScript.BitVector = {})); + var BitVector = TypeScript.BitVector; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitMatrix) { + var pool = []; + + var BitMatrixImpl = (function () { + function BitMatrixImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.vectors = []; + } + BitMatrixImpl.prototype.valueAt = function (x, y) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + return this.allowUndefinedValues ? undefined : false; + } + + return vector.valueAt(y); + }; + + BitMatrixImpl.prototype.setValueAt = function (x, y, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + if (value === undefined) { + return; + } + + vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); + this.vectors[x] = vector; + } + + vector.setValueAt(y, value); + }; + + BitMatrixImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + + for (var name in this.vectors) { + if (this.vectors.hasOwnProperty(name)) { + var vector = this.vectors[name]; + vector.release(); + } + } + + this.vectors.length = 0; + pool.push(this); + }; + return BitMatrixImpl; + })(); + + function getBitMatrix(allowUndefinedValues) { + if (pool.length === 0) { + return new BitMatrixImpl(allowUndefinedValues); + } + + var matrix = pool.pop(); + matrix.isReleased = false; + matrix.allowUndefinedValues = allowUndefinedValues; + + return matrix; + } + BitMatrix.getBitMatrix = getBitMatrix; + })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); + var BitMatrix = TypeScript.BitMatrix; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); + var AssertionLevel = TypeScript.AssertionLevel; + + var Debug = (function () { + function Debug() { + } + Debug.shouldAssert = function (level) { + return this.currentAssertionLevel >= level; + }; + + Debug.assert = function (expression, message, verboseDebugInfo) { + if (typeof message === "undefined") { message = ""; } + if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); + } + + throw new Error("Debug Failure. False expression: " + message + verboseDebugString); + } + }; + + Debug.fail = function (message) { + Debug.assert(false, message); + }; + Debug.currentAssertionLevel = 0 /* None */; + return Debug; + })(); + 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 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(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; + } + + return result; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return this._additionalLocations || []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + + Diagnostic.prototype.info = function () { + return getDiagnosticInfoFromKey(this.diagnosticKey()); + }; + return Diagnostic; + })(Location); + TypeScript.Diagnostic = Diagnostic; + + function newLine() { + return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while (match = regex.exec(diagnostic)) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result); + return result; + } + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); + } + + diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { + return typeof args[num] !== 'undefined' ? args[num] : match; + }); + + diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { + return TypeScript.newLine(); + }); + + return diagnosticMessageText; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error("Invalid argument: " + argument + ". " + message); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error("Argument out of range: " + argument); + }; + + Errors.argumentNull = function (argument) { + return new Error("Argument null: " + argument); + }; + + Errors.abstract = function () { + return new Error("Operation not implemented properly by subclass."); + }; + + Errors.notYetImplemented = function () { + return new Error("Not yet implemented."); + }; + + Errors.invalidOperation = function (message) { + return new Error("Invalid operation: " + message); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft === 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, + 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, + 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, + 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, + 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, + 4166287, 4999559, 5999471, 7199369]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? key.hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', "Key was already in table."); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; + + (function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; + })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); + var ByteOrderMark = TypeScript.ByteOrderMark; + + var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; + })(); + TypeScript.FileInformation = FileInformation; + + TypeScript.Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return WScript.CreateObject("WScript.Shell").CurrentDirectory; + }, + supportsCodePage: function () { + return WScript.ReadFile; + }, + readFile: function (path, codepage) { + try { + if (codepage !== null && this.supportsCodePage()) { + try { + var contents = WScript.ReadFile(path, codepage); + return new FileInformation(contents, 0 /* None */); + } catch (e) { + } + } + + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return process.cwd(); + }, + supportsCodePage: function () { + return false; + }, + readFile: function (file, codepage) { + if (codepage !== null) { + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); + } + + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 509); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IntegerUtilities) { + function integerDivide(numerator, denominator) { + return (numerator / denominator) >> 0; + } + IntegerUtilities.integerDivide = integerDivide; + + function integerMultiplyLow32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + } + IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; + + function integerMultiplyHigh32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + } + IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + IntegerUtilities.isInteger = isInteger; + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + IntegerUtilities.isHexInteger = isHexInteger; + })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); + var IntegerUtilities = TypeScript.IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_computeLineStarts, length) { + this._computeLineStarts = _computeLineStarts; + this.length = length; + this._lineStarts = null; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this.lineStarts(), length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + if (this._lineStarts === null) { + this._lineStarts = this._computeLineStarts(); + } + + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + LineMap.empty = new LineMap(function () { + return [0]; + }, 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { + return e; + } + } + + return null; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + if (text.length !== length) { + return false; + } + + var s = start; + for (var i = 0; i < length; i++) { + if (text.charCodeAt(i) !== array[s]) { + return false; + } + + s++; + } + + return true; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static.": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static.": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Invalid 'reference' directive syntax.": { + "code": 1084, + "category": 1 /* Error */ + }, + "Octal literals are not available when targeting ECMAScript 5 and higher.": { + "code": 1085, + "category": 1 /* Error */ + }, + "Accessors are not allowed in ambient contexts.": { + "code": 1086, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a constructor declaration.": { + "code": 1089, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a parameter.": { + "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 */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static members cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* Error */ + }, + "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { + "code": 2104, + "category": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in local functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* Error */ + }, + "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { + "code": 2117, + "category": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "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 */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Type '{0}' does not have type parameters.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or not exported.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not assignable to any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "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 assignable to numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are only allowed in implementation.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { + "code": 2188, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { + "code": 2189, + "category": 1 /* Error */ + }, + "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { + "code": 2190, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot be reopened.": { + "code": 2191, + "category": 1 /* Error */ + }, + "All declarations of merged declaration '{0}' must be exported or not exported.": { + "code": 2192, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in constructor arguments.": { + "code": 2193, + "category": 1 /* Error */ + }, + "Return type of constructor signature must be assignable to the instance type of the class.": { + "code": 2194, + "category": 1 /* Error */ + }, + "Ambient external module declaration must be defined in global context.": { + "code": 2195, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot specify relative module name.": { + "code": 2196, + "category": 1 /* Error */ + }, + "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { + "code": 2197, + "category": 1 /* Error */ + }, + "Could not find the best common type of types of all return statement expressions.": { + "code": 2198, + "category": 1 /* Error */ + }, + "Import declaration cannot refer to external module reference when --noResolve option is set.": { + "code": 2199, + "category": 1 /* Error */ + }, + "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { + "code": 2200, + "category": 1 /* Error */ + }, + "'continue' statement can only be used within an enclosing iteration statement.": { + "code": 2201, + "category": 1 /* Error */ + }, + "'break' statement can only be used within an enclosing iteration or switch statement.": { + "code": 2202, + "category": 1 /* Error */ + }, + "Jump target not found.": { + "code": 2203, + "category": 1 /* Error */ + }, + "Jump target cannot cross function boundary.": { + "code": 2204, + "category": 1 /* Error */ + }, + "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { + "code": 2205, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { + "code": 2206, + "category": 1 /* Error */ + }, + "Expression resolves to '_super' that compiler uses to capture base class reference.": { + "code": 2207, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2208, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2209, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2210, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2211, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2212, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2213, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2214, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2215, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2216, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2217, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2218, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2219, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { + "code": 2220, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2221, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { + "code": 2222, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2223, + "category": 1 /* Error */ + }, + "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { + "code": 2224, + "category": 1 /* Error */ + }, + "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { + "code": 2225, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { + "code": 2226, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { + "code": 2227, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { + "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 */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Variable declaration cannot have the same name as an import declaration.": { + "code": 4026, + "category": 1 /* Error */ + }, + "Signature expected {0} type arguments, got {1} instead.": { + "code": 4027, + "category": 1 /* Error */ + }, + "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { + "code": 4028, + "category": 3 /* NoPrefix */ + }, + "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 infinitely expanding type reference have incompatible type arguments.": { + "code": 4030, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "code": 4031, + "category": 3 /* NoPrefix */ + }, + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { + "code": 4032, + "category": 3 /* NoPrefix */ + }, + "Types of string indexer of types '{0}' and '{1}' are not identical.": { + "code": 4033, + "category": 3 /* NoPrefix */ + }, + "Types of number indexer of types '{0}' and '{1}' are not identical.": { + "code": 4034, + "category": 3 /* NoPrefix */ + }, + "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 assignable to string indexer type in type '{2}'.{NL}{3}": { + "code": 4036, + "category": 3 /* NoPrefix */ + }, + "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 */ + }, + "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { + "code": 5002, + "category": 1 /* Error */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 1 /* Error */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit.": { + "code": 5021, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead.": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Option '{0}' specified without '{1}'": { + "code": 5041, + "category": 1 /* Error */ + }, + "'codepage' option not supported on current platform.": { + "code": 5042, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file.": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file.": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files.": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory.": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output.": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing.": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: '{0}' (default), or '{1}'": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: '{0}' or '{1}'": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message.": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated '{0}' keyword when referencing an external module.": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file1": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options.": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "file2": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "NUMBER": { + "code": 6039, + "category": 2 /* Message */ + }, + "Specify the codepage to use when opening source files.": { + "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 */ + }, + "Unknown rule.": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7015, + "category": 1 /* Error */ + }, + "'{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 = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + this._lineStartPositions = null; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + if (!this._lineStartPositions) { + this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); + } + + return this._lineStartPositions; + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LineMap1) { + function fromSimpleText(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return text.charCodeAt(index); + }, length: text.length() }); + }, text.length()); + } + LineMap1.fromSimpleText = fromSimpleText; + + function fromScriptSnapshot(scriptSnapshot) { + return new TypeScript.LineMap(function () { + return scriptSnapshot.getLineStartPositions(); + }, scriptSnapshot.getLength()); + } + LineMap1.fromScriptSnapshot = fromScriptSnapshot; + + function fromString(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts(text); + }, text.length); + } + LineMap1.fromString = fromString; + })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); + var LineMap1 = TypeScript.LineMap1; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this._lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this._lineStarts(); + }, this.length()); + }; + + TextBase.prototype._lineStarts = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this._lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + this._lazyLineStarts = null; + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.substr = function (start, length, intern) { + var startInOriginalText = this.span.start() + start; + return this.text.substr(startInOriginalText, length, intern); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SubText.prototype._lineStarts = function () { + var _this = this; + if (!this._lazyLineStarts) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return _this.charCodeAt(index); + }, length: this.length() }); + } + + return this._lazyLineStarts; + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + this._lazyLineStarts = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + + StringText.prototype._lineStarts = function () { + if (this._lazyLineStarts === null) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); + } + + return this._lazyLineStarts; + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap1.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + this._lineMap = null; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + if (!this._lineMap) { + this._lineMap = TypeScript.LineMap1.fromString(this.value); + } + + return this._lineMap; + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this.scriptSnapshot.getLineStartPositions(); + }, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length; + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + var change0 = changes[0]; + + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + + oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + CharacterInfo.isOctalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 55 /* _7 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + + SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; + + SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; + SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; + + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + + SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; + SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 164 /* PlusExpression */; + case 90 /* MinusToken */: + return 165 /* NegateExpression */; + case 102 /* TildeToken */: + return 166 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 167 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 168 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 169 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 210 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 211 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 205 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 206 /* DivideExpression */; + + case 92 /* PercentToken */: + return 207 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 208 /* AddExpression */; + + case 90 /* MinusToken */: + return 209 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 202 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 203 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 204 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 196 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 197 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 198 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 199 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 200 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 201 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 192 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 193 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 194 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 195 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 191 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 190 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 189 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 188 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 187 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 182 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 180 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 181 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 183 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 184 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 185 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 175 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 176 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 177 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 178 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 179 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 174 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 173 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function getOperatorTokenFromBinaryExpression(tokenKind) { + switch (tokenKind) { + case 205 /* MultiplyExpression */: + return 91 /* AsteriskToken */; + + case 206 /* DivideExpression */: + return 118 /* SlashToken */; + + case 207 /* ModuloExpression */: + return 92 /* PercentToken */; + + case 208 /* AddExpression */: + return 89 /* PlusToken */; + + case 209 /* SubtractExpression */: + return 90 /* MinusToken */; + + case 202 /* LeftShiftExpression */: + return 95 /* LessThanLessThanToken */; + + case 203 /* SignedRightShiftExpression */: + return 96 /* GreaterThanGreaterThanToken */; + + case 204 /* UnsignedRightShiftExpression */: + return 97 /* GreaterThanGreaterThanGreaterThanToken */; + + case 196 /* LessThanExpression */: + return 80 /* LessThanToken */; + + case 197 /* GreaterThanExpression */: + return 81 /* GreaterThanToken */; + + case 198 /* LessThanOrEqualExpression */: + return 82 /* LessThanEqualsToken */; + + case 199 /* GreaterThanOrEqualExpression */: + return 83 /* GreaterThanEqualsToken */; + + case 200 /* InstanceOfExpression */: + return 30 /* InstanceOfKeyword */; + + case 201 /* InExpression */: + return 29 /* InKeyword */; + + case 192 /* EqualsWithTypeConversionExpression */: + return 84 /* EqualsEqualsToken */; + + case 193 /* NotEqualsWithTypeConversionExpression */: + return 86 /* ExclamationEqualsToken */; + + case 194 /* EqualsExpression */: + return 87 /* EqualsEqualsEqualsToken */; + + case 195 /* NotEqualsExpression */: + return 88 /* ExclamationEqualsEqualsToken */; + + case 191 /* BitwiseAndExpression */: + return 98 /* AmpersandToken */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 100 /* CaretToken */; + + case 189 /* BitwiseOrExpression */: + return 99 /* BarToken */; + + case 188 /* LogicalAndExpression */: + return 103 /* AmpersandAmpersandToken */; + + case 187 /* LogicalOrExpression */: + return 104 /* BarBarToken */; + + case 182 /* OrAssignmentExpression */: + return 116 /* BarEqualsToken */; + + case 180 /* AndAssignmentExpression */: + return 115 /* AmpersandEqualsToken */; + + case 181 /* ExclusiveOrAssignmentExpression */: + return 117 /* CaretEqualsToken */; + + case 183 /* LeftShiftAssignmentExpression */: + return 112 /* LessThanLessThanEqualsToken */; + + case 184 /* SignedRightShiftAssignmentExpression */: + return 113 /* GreaterThanGreaterThanEqualsToken */; + + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + + case 175 /* AddAssignmentExpression */: + return 108 /* PlusEqualsToken */; + + case 176 /* SubtractAssignmentExpression */: + return 109 /* MinusEqualsToken */; + + case 177 /* MultiplyAssignmentExpression */: + return 110 /* AsteriskEqualsToken */; + + case 178 /* DivideAssignmentExpression */: + return 119 /* SlashEqualsToken */; + + case 179 /* ModuloAssignmentExpression */: + return 111 /* PercentEqualsToken */; + + case 174 /* AssignmentExpression */: + return 107 /* EqualsToken */; + + case 173 /* CommaExpression */: + return 79 /* CommaToken */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); + 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + 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 { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + 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(fullText, kind); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(text, start, isTrailing); + }; + + Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.slidingWindow.absoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(diagnostics); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(diagnostics); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifierOrKeyword(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var slidingWindow = this.slidingWindow; + var window = slidingWindow.window; + + var startIndex = slidingWindow.currentRelativeItemIndex; + var endIndex = slidingWindow.windowCount; + var currentIndex = startIndex; + var character = 0; + + while (currentIndex < endIndex) { + character = window[currentIndex]; + if (!isIdentifierPartCharacter[character]) { + break; + } + + currentIndex++; + } + + if (currentIndex === endIndex) { + return 0 /* None */; + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + return 0 /* None */; + } else { + var kind; + var identifierLength = currentIndex - startIndex; + if (isKeywordStartCharacter[firstCharacter]) { + kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); + } else { + kind = 11 /* IdentifierName */; + } + + slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); + + return kind; + } + }; + + Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + var sawUnicodeEscape = false; + + do { + var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); + sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + var length = this.slidingWindow.absoluteIndex() - startIndex; + var text = this.text.substr(startIndex, length, false); + var valueText = TypeScript.Syntax.massageEscapes(text); + + var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); + if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { + if (sawUnicodeEscape) { + return keywordKind | -2147483648 /* IsVariableWidthKeyword */; + } else { + return keywordKind; + } + } + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function (diagnostics) { + if (this.isHexNumericLiteral()) { + this.scanHexNumericLiteral(); + } else if (this.isOctalNumericLiteral()) { + this.scanOctalNumericLiteral(diagnostics); + } else { + this.scanDecimalNumericLiteral(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isOctalNumericLiteral = function () { + return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); + }; + + Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { + var position = this.absoluteIndex(); + + while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.languageVersion() >= 1 /* EcmaScript5 */) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); + } + }; + + Scanner.prototype.scanDecimalDigits = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + this.scanDecimalDigits(); + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + this.scanDecimalDigits(); + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + var nextChar1 = this.slidingWindow.peekItemN(1); + + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { + var nextChar2 = this.slidingWindow.peekItemN(2); + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } + } + } + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function (diagnostics) { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(diagnostics); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 12 /* RegularExpressionLiteral */; + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + break; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + break; + + default: + break; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + this.scanUnicodeOrHexEscape(errors); + return true; + } + } + + this.slidingWindow.moveToNextItem(); + return false; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return parent.type === nodeOrToken; + case 220 /* CastExpression */: + return parent.type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + case 228 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return TypeScript.Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return nodeOrToken.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + element.insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + element.insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + var firstToken = this.firstToken(); + return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.trailingTrivia = function () { + var lastToken = this.lastToken(); + return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + 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 === thisAsIndexable[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isExpression = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + + this._kind = kind; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.kind = function () { + return this._kind; + }; + + HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { + if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.name = name; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.name; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withName = function (name) { + return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { + if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.callSignature = callSignature; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 146 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.modifiers; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifiers = function (modifiers) { + return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + + this.arguments = _arguments; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 142 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 227 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 239 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.constructorKeyword = constructorKeyword; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.constructorKeyword; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + 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 */), CallSignatureSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var GetAccessorSyntax = (function (_super) { + __extends(GetAccessorSyntax, _super); + function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.getKeyword = getKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + } + GetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessor(this); + }; + + GetAccessorSyntax.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + + GetAccessorSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + GetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + GetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetAccessorSyntax.create1 = function (propertyName) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GetAccessorSyntax = GetAccessorSyntax; + + var SetAccessorSyntax = (function (_super) { + __extends(SetAccessorSyntax, _super); + function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.setKeyword = setKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + SetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessor(this); + }; + + SetAccessorSyntax.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + + SetAccessorSyntax.prototype.childCount = function () { + return 5; + }; + + SetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + SetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetAccessorSyntax.create1 = function (propertyName) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SetAccessorSyntax = SetAccessorSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var IndexMemberDeclarationSyntax = (function (_super) { + __extends(IndexMemberDeclarationSyntax, _super); + function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.indexSignature = indexSignature; + this.semicolonToken = semicolonToken; + } + IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexMemberDeclaration(this); + }; + + IndexMemberDeclarationSyntax.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + + IndexMemberDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.indexSignature; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexMemberDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { + if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { + return this; + } + + return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); + }; + + IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); + }; + + IndexMemberDeclarationSyntax.create1 = function (indexSignature) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { + return this.update(this.modifiers, indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.indexSignature, semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexMemberDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + this.colonToken = colonToken; + this.statements = statements; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + this.colonToken = colonToken; + this.statements = statements; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.doKeyword = doKeyword; + this.statement = statement; + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + 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) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var dedentThisTrivia = dedentNextWhitespace; + dedentNextWhitespace = false; + + if (dedentThisTrivia) { + if (trivia.kind() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + var indentNextTrivia = true; + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var indentThisTrivia = indentNextTrivia; + indentNextTrivia = false; + + switch (trivia.kind()) { + case 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; + this.tokenKind = kind; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function isExpression(token) { + switch (token.tokenKind) { + case 11 /* IdentifierName */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 50 /* SuperKeyword */: + return true; + } + + return false; + } + Syntax.isExpression = isExpression; + + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + case 13 /* carriageReturn */: + var nextIndex = i + 1; + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { + i++; + } + continue; + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + return regularExpressionValue(text); + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function regularExpressionValue(text) { + try { + var lastSlash = text.lastIndexOf("/"); + var body = text.substring(1, lastSlash); + var flags = text.substring(lastSlash + 1); + return new RegExp(body, flags); + } catch (e) { + return null; + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + EmptyToken.prototype.isExpression = function () { + return isExpression(this); + }; + + EmptyToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + + RealizedToken.prototype.isExpression = function () { + return isExpression(this); + }; + + RealizedToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var AbstractTrivia = (function () { + function AbstractTrivia(_kind) { + this._kind = _kind; + } + AbstractTrivia.prototype.fullWidth = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.fullText = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.toJSON = function (key) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === this._kind) { + result.kind = name; + break; + } + } + + if (this.isSkippedToken()) { + result.skippedToken = this.skippedToken(); + } else { + result.text = this.fullText(); + } + return result; + }; + + AbstractTrivia.prototype.kind = function () { + return this._kind; + }; + + AbstractTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + AbstractTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + AbstractTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + AbstractTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + AbstractTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return AbstractTrivia; + })(); + + var NormalTrivia = (function (_super) { + __extends(NormalTrivia, _super); + function NormalTrivia(kind, _text) { + _super.call(this, kind); + this._text = _text; + } + NormalTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + NormalTrivia.prototype.fullText = function () { + return this._text; + }; + + NormalTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return NormalTrivia; + })(AbstractTrivia); + + var SkippedTokenTrivia = (function (_super) { + __extends(SkippedTokenTrivia, _super); + function SkippedTokenTrivia(_skippedToken) { + _super.call(this, 8 /* SkippedTokenTrivia */); + this._skippedToken = _skippedToken; + } + SkippedTokenTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SkippedTokenTrivia.prototype.fullText = function () { + return this.skippedToken().fullText(); + }; + + SkippedTokenTrivia.prototype.skippedToken = function () { + return this._skippedToken; + }; + return SkippedTokenTrivia; + })(AbstractTrivia); + + var DeferredTrivia = (function (_super) { + __extends(DeferredTrivia, _super); + function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { + _super.call(this, kind); + this._text = _text; + this._fullStart = _fullStart; + this._fullWidth = _fullWidth; + this._fullText = null; + } + DeferredTrivia.prototype.fullWidth = function () { + return this._fullWidth; + }; + + DeferredTrivia.prototype.fullText = function () { + if (!this._fullText) { + this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); + this._text = null; + } + + return this._fullText; + }; + + DeferredTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return DeferredTrivia; + })(AbstractTrivia); + + function deferredTrivia(kind, text, fullStart, fullWidth) { + return new DeferredTrivia(kind, text, fullStart, fullWidth); + } + Syntax.deferredTrivia = deferredTrivia; + + function trivia(kind, text) { + return new NormalTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SkippedTokenTrivia(token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + this.trivia[i].collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 228 /* TypeArgumentList */: + case 229 /* TypeParameterList */: + case 220 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.name); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitList(node.modifiers); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.constructorKeyword); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.indexSignature); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + + + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + var result = this.currentToken(); + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + + return result; + }; + return SyntaxCursor; + })(); + + + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); + } + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { + this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 173 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 186 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 187 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 188 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 189 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 191 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 167 /* LogicalNotExpression */: + case 170 /* DeleteExpression */: + case 171 /* TypeOfExpression */: + case 172 /* VoidExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); + } + } + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + var modifierCount = this.modifierCount(); + return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + var modifierCount = this.modifierCount(); + if (this.isImportDeclaration(modifierCount)) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration(modifierCount)) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration(modifierCount)) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration(modifierCount)) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration(modifierCount)) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(inErrorRecovery)) { + return this.parseStatement(inErrorRecovery); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + + return typeArgumentList; + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isAccessor = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(false); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexMemberDeclaration()) { + return this.parseIndexMemberDeclaration(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var modifiers = this.parseModifiers(); + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var callSignature = this.parseCallSignature(false); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.isIndexMemberDeclaration = function () { + var index = this.modifierCount(); + return this.isIndexSignature(index); + }; + + ParserImpl.prototype.parseIndexMemberDeclaration = function () { + var modifiers = this.parseModifiers(); + var indexSignature = this.parseIndexSignature(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + if (callSignature.lastToken()) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature(0)) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(inErrorRecovery)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(inErrorRecovery)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function (tokenIndex) { + return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isIdentifier(this.currentToken())) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + + break; + + case 28 /* IfKeyword */: + case 70 /* OpenBraceToken */: + case 33 /* ReturnKeyword */: + case 34 /* SwitchKeyword */: + case 36 /* ThrowKeyword */: + case 15 /* BreakKeyword */: + case 18 /* ContinueKeyword */: + case 26 /* ForKeyword */: + case 42 /* WhileKeyword */: + case 43 /* WithKeyword */: + case 22 /* DoKeyword */: + case 38 /* TryKeyword */: + case 19 /* DebuggerKeyword */: + return true; + } + + if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { + return false; + } + + return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); + }; + + ParserImpl.prototype.parseStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 28 /* IfKeyword */: + return this.parseIfStatement(); + case 70 /* OpenBraceToken */: + return this.parseBlock(false, false); + case 33 /* ReturnKeyword */: + return this.parseReturnStatement(); + case 34 /* SwitchKeyword */: + return this.parseSwitchStatement(); + case 36 /* ThrowKeyword */: + return this.parseThrowStatement(); + case 15 /* BreakKeyword */: + return this.parseBreakStatement(); + case 18 /* ContinueKeyword */: + return this.parseContinueStatement(); + case 26 /* ForKeyword */: + return this.parseForOrForInStatement(); + case 42 /* WhileKeyword */: + return this.parseWhileStatement(); + case 43 /* WithKeyword */: + return this.parseWithStatement(); + case 22 /* DoKeyword */: + return this.parseDoStatement(); + case 38 /* TryKeyword */: + return this.parseTryStatement(); + case 19 /* DebuggerKeyword */: + return this.parseDebuggerStatement(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement(currentToken)) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { + return this.parseEmptyStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(false); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function (currentToken) { + return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(false); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return currentToken.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function (currentToken) { + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function (currentToken) { + switch (currentToken.tokenKind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + + case 74 /* OpenBracketToken */: + + case 72 /* OpenParenToken */: + + case 80 /* LessThanToken */: + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + + case 70 /* OpenBraceToken */: + + case 85 /* EqualsGreaterThanToken */: + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + + case 31 /* NewKeyword */: + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + + case 27 /* FunctionKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(false); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 225 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(token0); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpressionOrLower = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpressionOrLower(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else if (currentTokenKind === 39 /* TypeOfKeyword */) { + return this.parseTypeOfExpression(); + } else if (currentTokenKind === 41 /* VoidKeyword */) { + return this.parseVoidExpression(); + } else if (currentTokenKind === 21 /* DeleteKeyword */) { + return this.parseDeleteExpression(); + } else if (currentTokenKind === 80 /* LessThanToken */) { + return this.parseCastExpression(); + } else { + return this.parsePostfixExpressionOrLower(); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + if (precedence <= 2 /* AssignmentExpressionPrecedence */) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } + + var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); + if (parethesizedArrowFunction !== null) { + return parethesizedArrowFunction; + } + } + + var leftOperand = this.parseUnaryExpressionOrLower(); + return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } + + var expression = this.parsePrimaryExpression(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + return this.parseMemberExpressionRest(expression, false, inObjectCreation); + }; + + ParserImpl.prototype.parseCallExpressionOrLower = function () { + var expression; + if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { + expression = this.eatKeyword(50 /* SuperKeyword */); + + var currentTokenKind = this.currentToken().tokenKind; + if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + } + } else { + expression = this.parseMemberExpressionOrLower(false); + } + + return this.parseMemberExpressionRest(expression, true, false); + }; + + ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (!allowArguments) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (!allowArguments) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseCallExpressionOrLower(); + } + }; + + ParserImpl.prototype.parsePostfixExpressionOrLower = function () { + var expression = this.parseLeftHandSideExpressionOrLower(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + } + + return expression; + }; + + ParserImpl.prototype.tryParseGenericArgumentList = function () { + var rewindPoint = this.getRewindPoint(); + + var typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + + var argumentList = null; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } else { + return this.parseArgumentList(typeArgumentList); + } + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + return this.tryParseGenericArgumentList(); + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(null); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var _arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + _arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parsePrimaryExpression = function () { + var currentToken = this.currentToken(); + + if (this.isIdentifier(currentToken)) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseObjectCreationExpressionOrLower(true); + var argumentList = this.tryParseArgumentList(); + + var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); + return this.parseMemberExpressionRest(result, true, false); + }; + + ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseMemberExpressionOrLower(inObjectCreation); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedExpression = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { + return null; + } + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + + this.releaseRewindPoint(rewindPoint); + return arrowFunction; + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.tryParseArrowFunctionBlock = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { + return this.parseBlock(true, false); + } else { + return null; + } + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + token2 = this.peekToken(2); + if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { + if (this.isIdentifier(token2)) { + return true; + } + } + + if (!this.isIdentifier(token1)) { + return false; + } + + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { + if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(true); + } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + return this.eatKeyword(35 /* ThisKeyword */); + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameters = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); + + return typeParameterList; + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 39 /* TypeOfKeyword */: + + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + + case 70 /* OpenBraceToken */: + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + + case 31 /* NewKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + var type = this.parseNonArrayType(currentToken); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function (currentToken) { + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return this.eatAnyToken(); + + case 70 /* OpenBraceToken */: + return this.parseObjectType(); + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + return this.parseFunctionType(); + + case 31 /* NewKeyword */: + return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); + } + + return this.parseNameOrGenericType(); + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + var tokenKind = token.tokenKind; + if (tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { + if (this.isIdentifier(token)) { + var nextTokenKind = this.peekToken(1).tokenKind; + switch (nextTokenKind) { + case 73 /* CloseParenToken */: + case 106 /* ColonToken */: + case 107 /* EqualsToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { + modifierArray.push(this.eatAnyToken()); + continue; + } + + break; + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + 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; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType, inErrorRecovery); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + var currentToken = this.currentToken(); + if (this.isExpression(currentToken)) { + return true; + } + + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.parseStatement(inErrorRecovery); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(inErrorRecovery); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.inObjectLiteralExpression = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { + return true; + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { + if (parameter.modifiers.childCount() > 0) { + var modifiers = parameter.modifiers; + var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + + if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { + if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); + return true; + } else { + if (modifierIndex > 0) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + 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.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; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.modifiers.childCount() > 0) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + 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; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + 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) { + 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; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + 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; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { + var getKeywordFullStart = this.childFullStart(node, getKeyword); + if (parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { + if (this.checkIndexMemberModifiers(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIndexMemberDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { + if (node.modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(node, node.modifiers); + this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { + var savedInObjectLiteralExpression = this.inObjectLiteralExpression; + this.inObjectLiteralExpression = true; + _super.prototype.visitObjectLiteralExpression.call(this, node); + this.inObjectLiteralExpression = savedInObjectLiteralExpression; + }; + + GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { + var setKeywordFullStart = this.childFullStart(node, setKeyword); + if (parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); + var parameter = parameterList.parameters.childAt(0); + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + 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 && previousValueWasComputed) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (node.stringLiteral === null) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { + this.skip(node); + return; + } + + _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); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock || this.inObjectLiteralExpression) { + if (modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { + this.skip(node); + return; + } + + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { + var currentElementFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var child = modifiers.childAt(i); + if (child.kind() !== 57 /* PublicKeyword */) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); + return true; + } + + currentElementFullStart += child.fullWidth(); + } + + 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); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Document = (function () { + function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { + this._compiler = _compiler; + this._semanticInfoChain = _semanticInfoChain; + this.fileName = fileName; + this.referencedFiles = referencedFiles; + this._scriptSnapshot = _scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._syntaxTree = _syntaxTree; + this._topLevelDecl = _topLevelDecl; + this._diagnostics = null; + this._bloomFilter = null; + this._sourceUnit = null; + this._lineMap = null; + this._declASTMap = []; + this._astDeclMap = []; + this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; + } + Document.prototype.invalidate = function () { + this._declASTMap.length = 0; + this._astDeclMap.length = 0; + this._topLevelDecl = null; + + this._syntaxTree = null; + this._sourceUnit = null; + this._diagnostics = null; + this._bloomFilter = null; + }; + + Document.prototype.isDeclareFile = function () { + return TypeScript.isDTSFile(this.fileName); + }; + + Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + + this._lineMap = syntaxTree.lineMap(); + + var sourceUnit = syntaxTree.sourceUnit(); + var leadingTrivia = sourceUnit.leadingTrivia(); + + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); + + var amdDependencies = []; + 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); + } + } + } + + this._amdDependencies = amdDependencies; + }; + + Document.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(trivia.fullText()); + + if (match) { + return new TypeScript.TextSpan(position, trivia.fullWidth()); + } + + return null; + }; + + 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); + } + } + + position += moduleElement.fullWidth(); + } + + return null; + ; + }; + + Document.prototype.sourceUnit = function () { + if (!this._sourceUnit) { + var start = new Date().getTime(); + var syntaxTree = this.syntaxTree(); + this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + + if (!this.isOpen) { + this._syntaxTree = null; + } + } + + return this._sourceUnit; + }; + + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._diagnostics); + } + + return this._diagnostics; + }; + + Document.prototype.lineMap = function () { + if (this._lineMap === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._lineMap); + } + + return this._lineMap; + }; + + Document.prototype.isExternalModule = function () { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); + } + + return this._externalModuleIndicatorSpan; + }; + + Document.prototype.amdDependencies = function () { + if (this._amdDependencies === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._amdDependencies !== undefined); + } + + return this._amdDependencies; + }; + + Document.prototype.syntaxTree = function () { + var result = this._syntaxTree; + if (!result) { + var start = new Date().getTime(); + + result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); + + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + if (this.isOpen || !this._sourceUnit) { + this._syntaxTree = result; + } + } + + this.cacheSyntaxTreeInfo(result); + return result; + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = TypeScript.createIntrinsicsObject(); + var pre = function (cur) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { + if (cur.kind() === 11 /* IdentifierName */) { + var nodeText = cur.valueText(); + + identifiers[nodeText] = true; + } + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.emitToOwnOutputFile = function () { + return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { + var oldSyntaxTree = this._syntaxTree; + + if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { + var oldText = this._scriptSnapshot; + var newText = scriptSnapshot; + + TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); + var newTextPrefix = newText.getText(0, textChangeRange.span().start()); + TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); + + var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); + var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); + TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); + }; + + Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); + }; + + Document.prototype.topLevelDecl = function () { + if (this._topLevelDecl === null) { + this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); + } + + return this._topLevelDecl; + }; + + Document.prototype._getDeclForAST = function (ast) { + this.topLevelDecl(); + return this._astDeclMap[ast.syntaxID()]; + }; + + Document.prototype.getEnclosingDecl = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + return this._getDeclForAST(ast); + } + + ast = ast.parent; + var decl = null; + while (ast) { + decl = this._getDeclForAST(ast); + + if (decl) { + break; + } + + ast = ast.parent; + } + + return decl._getEnclosingDeclFromParentDecl(); + }; + + Document.prototype._setDeclForAST = function (ast, decl) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._astDeclMap[ast.syntaxID()] = decl; + }; + + Document.prototype._getASTForDecl = function (decl) { + return this._declASTMap[decl.declID]; + }; + + Document.prototype._setASTForDecl = function (decl, ast) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._declASTMap[decl.declID] = ast; + }; + return Document; + })(); + TypeScript.Document = Document; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var proto = "__proto__"; + + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + + this[proto] = null; + this[proto] = undefined; + } + return BlockIntrinsics; + })(); + + function createIntrinsicsObject() { + return new BlockIntrinsics(); + } + TypeScript.createIntrinsicsObject = createIntrinsicsObject; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = createIntrinsicsObject(); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (!fn(k, this.table[k], context)) { + return false; + } + } + } + + return true; + }; + + StringHashTable.prototype.some = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (fn(k, this.table[k], context)) { + return true; + } + } + } + + return false; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + + StringHashTable.prototype.remove = function (key) { + if (this.table[key] !== undefined) { + this.table[key] = undefined; + this.itemCount--; + } + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (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); + } + ASTHelpers.moduleIsElided = moduleIsElided; + + 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)) { + 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; + } + ASTHelpers.enumIsElided = enumIsElided; + + function isValidAstNode(ast) { + if (!ast) + return false; + + if (ast.start() === -1 || ast.end() === -1) + return false; + + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; + + 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; + + 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) { + top = cur; + } + } + } + } + + 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; + } + } + + return false; + } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; + + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } + + 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); + } + 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; + } + + current = current.parent; + } + 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; + } + + return null; + } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; + + 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; + } + 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; + + function parametersFromIdentifier(id) { + return { + length: 1, + lastParameterIsRest: function () { + return false; + }, + ast: id, + astAt: function (index) { + return id; + }, + identifierAt: function (index) { + return id; + }, + typeAt: function (index) { + return null; + }, + initializerAt: function (index) { + return null; + }, + isOptionalAt: function (index) { + return false; + } + }; + } + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; + + function parametersFromParameter(parameter) { + return { + length: 1, + lastParameterIsRest: function () { + return parameter.dotDotDotToken !== null; + }, + ast: parameter, + astAt: function (index) { + return parameter; + }, + identifierAt: function (index) { + return parameter.identifier; + }, + typeAt: function (index) { + return getType(parameter); + }, + initializerAt: function (index) { + return parameter.equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(parameter); + } + }; + } + ASTHelpers.parametersFromParameter = parametersFromParameter; + + function parameterIsOptional(parameter) { + return parameter.questionToken !== null || parameter.equalsValueClause !== null; + } + + function parametersFromParameterList(list) { + return { + length: list.parameters.nonSeparatorCount(), + lastParameterIsRest: function () { + return TypeScript.lastParameterIsRest(list); + }, + ast: list.parameters, + astAt: function (index) { + return list.parameters.nonSeparatorAt(index); + }, + identifierAt: function (index) { + return list.parameters.nonSeparatorAt(index).identifier; + }, + typeAt: function (index) { + return getType(list.parameters.nonSeparatorAt(index)); + }, + initializerAt: function (index) { + return list.parameters.nonSeparatorAt(index).equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(list.parameters.nonSeparatorAt(index)); + } + }; + } + ASTHelpers.parametersFromParameterList = parametersFromParameterList; + + 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; + } + } + ASTHelpers.isDeclarationAST = isDeclarationAST; + + 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; + } + + 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; + } + + ast = ast.parent; + } + + return null; + } + ASTHelpers.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); + + 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 { + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); + } + } + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function walkListChildren(preAst, walker) { + for (var i = 0, n = preAst.childCount(); i < n; i++) { + walker.walk(preAst.childAt(i)); + } + } + + function walkThrowStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkPrefixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkPostfixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkDeleteExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkTypeArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArguments); + } + + function walkTypeOfExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkVoidExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArgumentList); + walker.walk(preAst.arguments); + } + + function walkArrayLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.expressions); + } + + function walkSimplePropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.expression); + } + + function walkFunctionPropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkGetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkSeparatedListChildren(preAst, walker) { + for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { + walker.walk(preAst.nonSeparatorAt(i)); + } + } + + function walkSetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.block); + } + + function walkObjectLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.propertyAssignments); + } + + function walkCastExpressionChildren(preAst, walker) { + walker.walk(preAst.type); + walker.walk(preAst.expression); + } + + function walkParenthesizedExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkElementAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentExpression); + } + + function walkMemberAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.name); + } + + function walkQualifiedNameChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkBinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkEqualsValueClauseChildren(preAst, walker) { + walker.walk(preAst.value); + } + + function walkTypeParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.constraint); + } + + function walkTypeParameterListChildren(preAst, walker) { + walker.walk(preAst.typeParameters); + } + + function walkGenericTypeChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.typeArgumentList); + } + + function walkTypeAnnotationChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkTypeQueryChildren(preAst, walker) { + walker.walk(preAst.name); + } + + function walkInvocationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkObjectCreationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkTrinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.whenTrue); + walker.walk(preAst.whenFalse); + } + + function walkFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFunctionTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkMemberFunctionDeclarationChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFuncDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkIndexMemberDeclarationChildren(preAst, walker) { + walker.walk(preAst.indexSignature); + } + + function walkIndexSignatureChildren(preAst, walker) { + walker.walk(preAst.parameter); + walker.walk(preAst.typeAnnotation); + } + + function walkCallSignatureChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + } + + function walkConstraintChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkConstructorDeclarationChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkConstructorTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkConstructSignatureChildren(preAst, walker) { + walker.walk(preAst.callSignature); + } + + function walkParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkParameterListChildren(preAst, walker) { + walker.walk(preAst.parameters); + } + + function walkPropertySignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + } + + function walkVariableDeclaratorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkMemberVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.variableDeclarator); + } + + function walkMethodSignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + } + + function walkReturnStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkForStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.initializer); + walker.walk(preAst.condition); + walker.walk(preAst.incrementor); + walker.walk(preAst.statement); + } + + function walkForInStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.left); + walker.walk(preAst.expression); + walker.walk(preAst.statement); + } + + function walkIfStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + walker.walk(preAst.elseClause); + } + + function walkElseClauseChildren(preAst, walker) { + walker.walk(preAst.statement); + } + + function walkWhileStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkDoStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkBlockChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.declarators); + } + + function walkCaseSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.statements); + } + + function walkDefaultSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkSwitchStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.switchClauses); + } + + function walkTryStatementChildren(preAst, walker) { + walker.walk(preAst.block); + walker.walk(preAst.catchClause); + walker.walk(preAst.finallyClause); + } + + function walkCatchClauseChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkExternalModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.stringLiteral); + } + + function walkFinallyClauseChildren(preAst, walker) { + walker.walk(preAst.block); + } + + function walkClassDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.classElements); + } + + function walkScriptChildren(preAst, walker) { + walker.walk(preAst.moduleElements); + } + + function walkHeritageClauseChildren(preAst, walker) { + walker.walk(preAst.typeNames); + } + + function walkInterfaceDeclerationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.body); + } + + function walkObjectTypeChildren(preAst, walker) { + walker.walk(preAst.typeMembers); + } + + function walkArrayTypeChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkModuleDeclarationChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.stringLiteral); + walker.walk(preAst.moduleElements); + } + + function walkModuleNameModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.moduleName); + } + + function walkEnumDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.enumElements); + } + + function walkEnumElementChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.equalsValueClause); + } + + function walkImportDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.moduleReference); + } + + function walkExportAssignmentChildren(preAst, walker) { + walker.walk(preAst.identifier); + } + + function walkWithStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkExpressionStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkLabeledStatementChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.statement); + } + + function walkVariableStatementChildren(preAst, walker) { + walker.walk(preAst.declaration); + } + + var childrenWalkers = new Array(246 /* Last */ + 1); + + for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { + childrenWalkers[i] = null; + } + for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { + childrenWalkers[i] = null; + } + + childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; + childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[60 /* AnyKeyword */] = null; + childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; + childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; + childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; + childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; + childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; + childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[146 /* Block */] = walkBlockChildren; + childrenWalkers[61 /* BooleanKeyword */] = null; + childrenWalkers[152 /* BreakStatement */] = null; + childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; + childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; + childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; + childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; + childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; + childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; + childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; + childrenWalkers[239 /* Constraint */] = walkConstraintChildren; + childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; + childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; + childrenWalkers[153 /* ContinueStatement */] = null; + childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; + childrenWalkers[162 /* DebuggerStatement */] = null; + childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; + childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; + childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; + childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; + childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; + childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; + childrenWalkers[156 /* EmptyStatement */] = null; + childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; + childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; + childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; + childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; + childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; + childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; + childrenWalkers[24 /* FalseKeyword */] = null; + childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; + childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; + childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; + childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; + childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; + childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; + childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; + childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; + childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; + childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; + childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; + childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; + childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; + childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; + childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; + childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; + childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; + childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; + childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[1 /* List */] = walkListChildren; + childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; + childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; + childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; + childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; + childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; + childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; + childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; + childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; + childrenWalkers[11 /* IdentifierName */] = null; + childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[0 /* None */] = null; + childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[32 /* NullKeyword */] = null; + childrenWalkers[67 /* NumberKeyword */] = null; + childrenWalkers[13 /* NumericLiteral */] = null; + childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; + childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; + childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; + childrenWalkers[223 /* OmittedExpression */] = null; + childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[242 /* Parameter */] = walkParameterChildren; + childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; + childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; + childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; + childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; + childrenWalkers[12 /* RegularExpressionLiteral */] = null; + childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; + childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; + childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; + childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; + childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; + childrenWalkers[14 /* StringLiteral */] = null; + childrenWalkers[69 /* StringKeyword */] = null; + childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; + childrenWalkers[50 /* SuperKeyword */] = null; + childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; + childrenWalkers[35 /* ThisKeyword */] = null; + childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; + childrenWalkers[3 /* TriviaList */] = null; + childrenWalkers[37 /* TrueKeyword */] = null; + childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; + childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; + childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; + childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; + childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; + childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; + childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; + childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; + childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; + childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; + childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; + childrenWalkers[41 /* VoidKeyword */] = null; + childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; + childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; + + for (var e in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { + TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); + } + } + + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + this.stopWalking = false; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var SimplePreAstWalker = (function () { + function SimplePreAstWalker(pre, state) { + this.pre = pre; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePreAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + }; + return SimplePreAstWalker; + })(); + + var SimplePrePostAstWalker = (function () { + function SimplePrePostAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePrePostAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + + this.post(ast, this.state); + }; + return SimplePrePostAstWalker; + })(); + + var NormalAstWalker = (function () { + function NormalAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + NormalAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + if (this.options.stopWalking) { + return; + } + + this.pre(ast, this); + + if (this.options.stopWalking) { + return; + } + + if (this.options.goChildren) { + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + } else { + this.options.goChildren = true; + } + + if (this.post) { + this.post(ast, this); + } + }; + return NormalAstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { + new NormalAstWalker(pre, post, state).walk(ast); + }; + + AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { + if (post) { + new SimplePrePostAstWalker(pre, post, state).walk(ast); + } else { + new SimplePreAstWalker(pre, state).walk(ast); + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory = new AstWalkerFactory(); + + function getAstWalkerFactory() { + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapEntry = (function () { + function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { + this.emittedFile = emittedFile; + this.emittedLine = emittedLine; + this.emittedColumn = emittedColumn; + this.sourceFile = sourceFile; + this.sourceLine = sourceLine; + this.sourceColumn = sourceColumn; + this.sourceName = sourceName; + TypeScript.Debug.assert(isFinite(emittedLine)); + TypeScript.Debug.assert(isFinite(emittedColumn)); + TypeScript.Debug.assert(isFinite(sourceColumn)); + TypeScript.Debug.assert(isFinite(sourceLine)); + } + return SourceMapEntry; + })(); + TypeScript.SourceMapEntry = SourceMapEntry; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.names = []; + this.mappingLevel = []; + this.tsFilePaths = []; + this.allSourceMappings = []; + this.sourceMapEntries = []; + this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); + this.setNewSourceFile(document, emitOptions); + } + SourceMapper.prototype.getOutputFile = function () { + var result = this.sourceMapOut.getOutputFile(); + result.sourceMapEntries = this.sourceMapEntries; + + return result; + }; + + SourceMapper.prototype.increaseMappingLevel = function (ast) { + this.mappingLevel.push(ast); + }; + + SourceMapper.prototype.decreaseMappingLevel = function (ast) { + TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); + var expectedAst = this.mappingLevel.pop(); + var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; + var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; + TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); + }; + + SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { + var sourceMappings = []; + this.allSourceMappings.push(sourceMappings); + this.currentMappings = [sourceMappings]; + this.currentNameIndex = []; + + this.setNewSourceFilePath(document, emitOptions); + }; + + SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; + this.jsFileName = prettyJsFileName; + + if (emitOptions.sourceMapRootDirectory()) { + this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); + if (document.emitToOwnOutputFile()) { + this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); + } + + if (TypeScript.isRelative(this.sourceMapDirectory)) { + this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; + this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); + this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); + } else { + this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; + } + } else { + this.sourceMapPath = prettyMapFileName; + this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + this.sourceRoot = emitOptions.sourceRootDirectory(); + }; + + SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + if (emitOptions.sourceRootDirectory()) { + tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); + } else { + tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); + } + this.tsFilePaths.push(tsFilePath); + }; + + SourceMapper.prototype.emitSourceMapping = function () { + var _this = this; + TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { + return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); + }).join(', ')); + + this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); + + var mappingsString = ""; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); + prevSourceIndex = sourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); + prevNameIndex = nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + for (var i = 0; i < sourceMappings.length; i++) { + var sourceMapping = sourceMappings[i]; + recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); + recordSourceMappingSiblings(sourceMapping.childMappings); + recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); + } + }; + + recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); + } + + this.sourceMapOut.Write(JSON.stringify({ + version: 3, + file: this.jsFileName, + sourceRoot: this.sourceRoot, + sources: this.tsFilePaths, + names: this.names, + mappings: mappingsString + })); + + this.sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compiler, resolvePath) { + this.resolvePath = resolvePath; + this._diagnostic = null; + this._settings = null; + this._commonDirectoryPath = ""; + this._sharedOutputFile = ""; + this._sourceRootDirectory = ""; + this._sourceMapRootDirectory = ""; + this._outputDirectory = ""; + var settings = compiler.compilationSettings(); + this._settings = settings; + + 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()) { + if (settings.mapRoot()) { + if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } else { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } else if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } + + this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); + this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); + + if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { + if (settings.outFileOption()) { + this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); + } + + if (settings.outDirOption()) { + this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); + } + + if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { + this.determineCommonDirectoryPath(compiler); + } + } + } + EmitOptions.prototype.diagnostic = function () { + return this._diagnostic; + }; + + EmitOptions.prototype.commonDirectoryPath = function () { + return this._commonDirectoryPath; + }; + EmitOptions.prototype.sharedOutputFile = function () { + return this._sharedOutputFile; + }; + EmitOptions.prototype.sourceRootDirectory = function () { + return this._sourceRootDirectory; + }; + EmitOptions.prototype.sourceMapRootDirectory = function () { + return this._sourceMapRootDirectory; + }; + EmitOptions.prototype.outputDirectory = function () { + return this._outputDirectory; + }; + + EmitOptions.prototype.compilationSettings = function () { + return this._settings; + }; + + EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = compiler.fileNames(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = compiler.getDocument(fileNames[i]); + var sourceUnit = document.sourceUnit(); + + if (!document.isDeclareFile()) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + 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; + } + + return; + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + function lastParameterIsRest(parameterList) { + var parameters = parameterList.parameters; + return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; + } + TypeScript.lastParameterIsRest = lastParameterIsRest; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.inArrowFunction = false; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.declStack = []; + this.exportAssignment = null; + this.inWithBlock = false; + this.document = null; + this.detachedCommentsElement = null; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; + }; + + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.shouldEmitImportDeclaration = 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 */; + + 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 */; + + this.emitComments(importDeclAST, true); + + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + 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 */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + if (isAmdCodeGen && isExternalModuleReference) { + needsPropertyAssignment = true; + } else { + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.identifier.text() + " = "); + var aliasAST = importDeclAST.moduleReference; + + if (isExternalModuleReference) { + this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); + } else { + this.emitJavascript(aliasAST.moduleName, false); + } + + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + } + } + + if (needsPropertyAssignment) { + this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + }; + + Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { + this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); + }; + + Emitter.prototype.setSourceMapperNewSourceFile = function (document) { + this.sourceMapper.setNewSourceFile(document, this.emitOptions); + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { + this.recordSourceMappingStart(astSpan); + this.writeToOutput(s); + this.recordSourceMappingEnd(astSpan); + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeLineToOutput = function (s, force) { + if (typeof force === "undefined") { force = false; } + if (!force && s === "" && this.emitState.column === 0) { + return; + } + + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment, trailing, first) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var text = getTrimmedTextLines(comment); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } else if (trailing && first) { + this.writeToOutput(" "); + } + + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (!trailing && emitColumn !== 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { + 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; + } + } + + if (pre) { + var preComments = ast.preComments(); + + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; + } + + if (preComments && onlyPinnedOrTripleSlashComments) { + preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { + return _this.isPinnedOrTripleSlash(c); + }); + } + + this.emitCommentsArray(preComments, false); + } else { + this.emitCommentsArray(ast.postComments(), true); + } + }; + + Emitter.prototype.isPinnedOrTripleSlash = function (comment) { + var fullText = comment.fullText(); + if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { + return true; + } else { + return fullText.indexOf("/*!") === 0; + } + }; + + Emitter.prototype.emitCommentsArray = function (comments, trailing) { + if (!this.emitOptions.compilationSettings().removeComments() && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i], trailing, i === 0); + } + } + }; + + Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { + this.recordSourceMappingStart(objectLiteral); + + this.writeToOutput("{"); + this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); + this.writeToOutput("}"); + + this.recordSourceMappingEnd(objectLiteral); + }; + + Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { + this.recordSourceMappingStart(arrayLiteral); + + this.writeToOutput("["); + this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); + this.writeToOutput("]"); + + this.recordSourceMappingEnd(arrayLiteral); + }; + + Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { + this.recordSourceMappingStart(objectCreationExpression); + this.writeToOutput("new "); + var target = objectCreationExpression.expression; + + this.emit(target); + if (objectCreationExpression.argumentList) { + this.recordSourceMappingStart(objectCreationExpression.argumentList); + this.writeToOutput("("); + this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); + this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); + this.recordSourceMappingEnd(objectCreationExpression.argumentList); + } + + this.recordSourceMappingEnd(objectCreationExpression); + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); + if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + if (pullDecl.kind === 67108864 /* EnumMember */) { + return pullDecl; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + var propertyName = dotExpr.name; + var boundDecl = this.getConstantDecl(dotExpr); + if (boundDecl) { + var value = boundDecl.constantValue; + if (value !== null) { + this.recordSourceMappingStart(dotExpr); + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.text(); + comment += " */"; + this.writeToOutput(comment); + this.recordSourceMappingEnd(dotExpr); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitInvocationExpression = function (callNode) { + this.recordSourceMappingStart(callNode); + var target = callNode.expression; + var args = callNode.argumentList.arguments; + + if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { + this.emit(target); + this.writeToOutput(".call"); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitThis(); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + } else { + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + + this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); + this.recordSourceMappingEnd(args); + this.recordSourceMappingEnd(callNode); + }; + + Emitter.prototype.emitParameterList = function (list) { + this.writeToOutput("("); + this.emitCommentsArray(list.openParenTrailingComments, true); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); + this.writeToOutput(")"); + }; + + Emitter.prototype.emitFunctionParameters = function (parameters) { + var argsLen = 0; + + if (parameters) { + this.emitComments(parameters.ast, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = parameters.length; + var printLen = argsLen; + if (parameters.lastParameterIsRest()) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = parameters.astAt(i); + this.emit(arg); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(parameters.ast, false); + } + }; + + Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { + this.writeLineToOutput(" {"); + if (name) { + this.recordSourceMappingNameStart(name); + } + + this.indenter.increaseIndent(); + + 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); + } else { + this.emitIndent(); + this.emitCommentsArray(bodyExpression.preComments(), false); + this.writeToOutput("return "); + this.emit(bodyExpression); + this.writeLineToOutput(";"); + this.emitCommentsArray(bodyExpression.postComments(), true); + } + + this.indenter.decreaseIndent(); + this.emitIndent(); + + if (block) { + this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); + } else { + this.writeToOutputWithSourceMapRecord("}", bodyExpression); + } + + if (name) { + this.recordSourceMappingNameEnd(); + } + }; + + Emitter.prototype.emitDefaultValueAssignments = function (parameters) { + var n = parameters.length; + if (parameters.lastParameterIsRest()) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = parameters.astAt(i); + var id = parameters.identifierAt(i); + var equalsValueClause = parameters.initializerAt(i); + if (equalsValueClause) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.emitJavascript(equalsValueClause, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (parameters) { + if (parameters.lastParameterIsRest()) { + var n = parameters.length; + var lastArg = parameters.astAt(n - 1); + var id = parameters.identifierAt(n - 1); + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); + this.writeToOutput(" "); + this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); + this.writeToOutput("; "); + this.writeToOutputWithSourceMapRecord("_i++", lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + var result = []; + + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + var queue = dynamicModuleDecl.getChildDecls(); + + for (var i = 0, n = queue.length; i < n; i++) { + var decl = queue[i]; + + if (decl.kind & 128 /* TypeAlias */) { + var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { + var importList = ""; + var dependencyList = ""; + + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue()) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += importStatementDecl.name; + dependencyList += importStatementAST.moduleReference.stringLiteral.text(); + } + } + } + + var amdDependencies = this.document.amdDependencies(); + for (var i = 0; i < amdDependencies.length; i++) { + dependencyList += ", \"" + amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); + } + + var decl = this.semanticInfoChain.getDeclForAST(ast); + if (decl) { + return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); + } + + return false; + }; + + Emitter.prototype.emitEnum = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.identifier.text(); + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.identifier); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(this.moduleName); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitSeparatedList(moduleDecl.enumElements); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { + return moduleDecl; + } else if (changeNameIfAnyDeclarationInContext) { + var symbol = moduleDecl.getSymbol(); + if (symbol) { + var otherDecls = symbol.getDeclarations(); + for (var i = 0; i < otherDecls.length; i++) { + if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { + return otherDecls[i]; + } + } + } + } + + return null; + }; + + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { + var _this = this; + var childDecls = parentDecl.getChildDecls(); + return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { + 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; + } + } + return false; + }); + }; + + Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + var moduleName = moduleDecl.name; + var moduleDisplayName = moduleDecl.getDisplayName(); + + moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { + moduleName = "_" + moduleName; + moduleDisplayName = "_" + moduleDisplayName; + } + } + + return moduleDisplayName; + }; + + Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { + if (moduleDecl.stringLiteral) { + this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); + } + }; + + Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); + + if (isLastName) { + this.emitComments(moduleDecl, true); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + + if (moduleDecl.stringLiteral) { + this.moduleName = moduleDecl.stringLiteral.valueText(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + } else { + this.moduleName = moduleName.text(); + } + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleName); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleName); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + + this.moduleName = this.getModuleName(pullDecl); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(moduleName.text()); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + if (moduleName === moduleDecl.stringLiteral) { + this.emitList(moduleDecl.moduleElements); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + var nameIndex = moduleNames.indexOf(moduleName); + TypeScript.Debug.assert(nameIndex >= 0); + + if (isLastName) { + this.emitList(moduleDecl.moduleElements); + } else { + this.emitIndent(); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); + this.writeLineToOutput(""); + } + } + + this.moduleName = moduleName.text(); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + + if (isLastName) { + this.emitComments(moduleDecl, false); + } + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.propertyName.text(); + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput(']'); + + if (varDecl.equalsValueClause) { + this.emit(varDecl.equalsValueClause); + } else if (pullDecl.constantValue !== null) { + this.writeToOutput(' = '); + this.writeToOutput(pullDecl.constantValue.toString()); + } else { + this.writeToOutput(' = null'); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitElementAccessExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("["); + this.emit(expression.argumentExpression); + this.writeToOutput("]"); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = true; + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(arrowFunction); + + var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); + this.pushDecl(pullDecl); + + this.emitComments(arrowFunction, true); + + this.recordSourceMappingStart(arrowFunction); + this.writeToOutput("function "); + this.writeToOutput("("); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); + + this.recordSourceMappingEnd(arrowFunction); + + this.recordSourceMappingEnd(arrowFunction); + + this.emitComments(arrowFunction, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConstructor = function (funcDecl) { + if (!funcDecl.block) { + return; + } + var temp = this.setContainer(4 /* Constructor */); + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + this.writeToOutput(this.thisClassNode.identifier.text()); + this.writeToOutput("("); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart("constructor"); + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(parameters); + this.emitRestParameterInitializer(parameters); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + this.emitConstructorStatements(funcDecl); + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + }; + + Emitter.prototype.emitGetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("get "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitSetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("set "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitFunctionExpression = function (funcDecl) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + this.writeToOutput(funcDecl.identifier.text()); + this.recordSourceMappingEnd(funcDecl.identifier); + } + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (funcDecl.block === null) { + return; + } + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier.text(); + + this.recordSourceMappingStart(funcDecl); + + var printName = funcDecl.identifier !== null; + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (printName) { + var id = funcDecl.identifier.text(); + if (id) { + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + } + this.writeToOutput(id); + if (funcDecl.identifier) { + this.recordSourceMappingEnd(funcDecl.identifier); + } + } + } + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + + if (funcDecl.block) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + this.recordSourceMappingStart(this.currentVariableDeclaration); + if (varDecl.equalsValueClause) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + this.emitJavascript(varDecl.equalsValueClause, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.currentVariableDeclaration) { + this.writeToOutput("var "); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + + this.emitComments(declaration, true); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; + if (!isAmbientWithoutInit) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.currentVariableDeclaration = declaration; + + for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { + var declarator = declaration.declarators.nonSeparatorAt(i); + + if (i > 0) { + this.writeToOutput(", "); + } + + this.emit(declarator); + } + this.currentVariableDeclaration = prevVariableDeclaration; + + this.recordSourceMappingEnd(declaration); + } + + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { + TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); + + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + + if (quotedOrNumber) { + this.writeToOutput("this["); + } else { + this.writeToOutput("this."); + } + + this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); + + if (quotedOrNumber) { + this.writeToOutput("]"); + } + + if (varDecl.variableDeclarator.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.variableDeclarator.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(this.currentVariableDeclaration); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.propertyName.text(); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); + + if (parentIsModule) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + + if (varDecl.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.currentVariableDeclaration = undefined; + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { + var decl = pullSymbol.getDeclarations()[0]; + var parentDecl = decl.getParentDecl(); + var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; + + var enclosingContextDeclPath = this.declStack; + var commonNodeIndex = -1; + + if (enclosingContextDeclPath.length) { + for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { + var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; + for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { + var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; + if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { + commonNodeIndex = i; + break; + } + } + + if (commonNodeIndex >= 0) { + break; + } + } + } + + var startingIndex = symbolContainerDeclPath.length - 1; + for (var i = startingIndex - 1; i > commonNodeIndex; i--) { + if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { + startingIndex = i; + } else { + break; + } + } + return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; + }; + + Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { + for (var i = startingIndex; i <= lastIndex; i++) { + if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.getModuleName(declPath[i], true) + "."); + } + } + }; + + Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { + var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); + var potentialDeclPath = declPathInfo.potentialPath; + var startingIndex = declPathInfo.startingIndex; + + this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); + }; + + Emitter.prototype.getSymbolForEmit = function (ast) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol === symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (name.text().length > 0) { + var symbolForEmit = this.getSymbolForEmit(name); + var pullSymbol = symbolForEmit.symbol; + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = symbolForEmit.aliasSymbol; + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } + } + } + + this.writeToOutput(name.text()); + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var nameIndex = -1; + if (name) { + if (this.sourceMapper.currentNameIndex.length > 0) { + var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { + break; + } + } + + if (nameIndex === -1) { + nameIndex = this.sourceMapper.names.length; + this.sourceMapper.names.push(name); + } + } + this.sourceMapper.currentNameIndex.push(nameIndex); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (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; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap(); + lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); + + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + this.sourceMapper.increaseMappingLevel(ast); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); + + this.sourceMapper.decreaseMappingLevel(ast); + } + }; + + Emitter.prototype.getOutputFiles = function () { + var result = []; + if (this.sourceMapper !== null) { + this.sourceMapper.emitSourceMapping(); + result.push(this.sourceMapper.getOutputFile()); + } + + result.push(this.outfile.getOutputFile()); + return result; + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = getLastConstructor(this.thisClassNode); + + 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(); + this.recordSourceMappingStart(parameter); + this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); + this.writeToOutput(" = "); + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(parameter); + } + } + } + + for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { + if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = this.thisClassNode.classElements.childAt(i); + if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitIndent(); + this.emitMemberVariableDeclaration(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.isOnSameLine = function (pos1, pos2) { + var lineMap = this.document.lineMap(); + return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); + }; + + Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { + if (list === null || list.nonSeparatorCount() === 0) { + return; + } + + var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); + + if (preserveNewLines) { + this.indenter.increaseIndent(); + } + + if (startLine) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(buffer); + } + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + var emitNode = list.nonSeparatorAt(i); + + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); + if (startLine) { + this.writeLineToOutput(","); + } else { + this.writeToOutput(", "); + } + } + } + + if (preserveNewLines) { + this.indenter.decreaseIndent(); + } + + if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(buffer); + } + }; + + Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.nonSeparatorAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.kind() === 14 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { + return; + } + + var lineMap = this.document.lineMap(); + var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput("", true); + } + }; + + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); + if (preComments) { + var lineMap = this.document.lineMap(); + + var detachedComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); + var commentLine = lineMap.getLineNumberFromPosition(comment.start()); + + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + detachedComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); + if (astLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { + if (list.childCount() > 0) { + var firstElement = list.childAt(0); + + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); + } + }; + + Emitter.prototype.emitScriptElements = function (sourceUnit) { + var list = sourceUnit.moduleElements; + + this.emitPossibleCopyrightHeaders(sourceUnit); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var node = list.childAt(i); + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(sourceUnit); + + var isExternalModule = this.document.isExternalModule(); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); + if (isNonElidedExternalModule) { + this.recordSourceMappingStart(sourceUnit); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } + + if (isExternalModule) { + var temp = this.setContainer(2 /* DynamicModule */); + + var svModuleName = this.moduleName; + this.moduleName = sourceUnit.fileName(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + this.setExportAssignment(null); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); + + if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { + this.writeCaptureThisStatement(sourceUnit); + } + + this.pushDecl(externalModule); + } + + this.emitList(list, true, i, n); + + if (isExternalModule) { + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + + if (isNonElidedExternalModule) { + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; + var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(sourceUnit); + this.writeLineToOutput(""); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + this.popDecl(externalModule); + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + this.emit(ast); + }; + + Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { + if (funcDecl.kind() !== 139 /* GetAccessor */) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + + this.writeToOutput("Object.defineProperty(" + className); + if (isProto) { + this.writeToOutput(".prototype, "); + } else { + this.writeToOutput(", "); + } + + var functionName = name.text(); + if (TypeScript.isQuoted(functionName)) { + this.writeToOutput(functionName); + } else { + this.writeToOutput('"' + functionName + '"'); + } + + this.writeLineToOutput(", {"); + + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.emitComments(accessors.getter, true); + this.writeToOutput("get: "); + this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.emitComments(accessors.setter, true); + this.writeToOutput("set: "); + this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.identifier.text(); + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var baseTypeReference = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); + } + + this.emitIndent(); + + var constrDecl = getLastConstructor(classDecl); + + if (constrDecl) { + this.emit(constrDecl); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.emitJavascript(baseTypeReference, false); + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 139 /* GetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var getter = memberDecl; + this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 140 /* SetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var setter = memberDecl; + this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { + var memberFunction = memberDecl; + + if (memberFunction.block) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + + this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); + lastEmittedMember = memberDecl; + } + } + } + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = memberDecl; + + if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); + } else { + this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); + } + + this.emit(varDecl.variableDeclarator.equalsValueClause); + + this.recordSourceMappingEnd(varDecl); + this.writeLineToOutput(";"); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + var functionName = funcDecl.propertyName.text(); + + this.writeToOutput(classDecl.identifier.text()); + + if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + this.writeToOutput(".prototype"); + } + + if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput("[" + functionName + "] = "); + } else { + this.writeToOutput("." + functionName + " = "); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + + this.writeLineToOutput(";"); + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + + if (moduleElement.kind() === 130 /* ModuleDeclaration */) { + var moduleAST = moduleElement; + + if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { + return true; + } + } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (sourceUnit) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(sourceUnit)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitThis = function () { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.kind() === 146 /* Block */) { + this.emit(node); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitLiteralExpression = function (expression) { + switch (expression.kind()) { + case 32 /* NullKeyword */: + this.writeToOutputWithSourceMapRecord("null", expression); + break; + case 24 /* FalseKeyword */: + this.writeToOutputWithSourceMapRecord("false", expression); + break; + case 37 /* TrueKeyword */: + this.writeToOutputWithSourceMapRecord("true", expression); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + Emitter.prototype.emitThisExpression = function (expression) { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutputWithSourceMapRecord("_this", expression); + } else { + this.writeToOutputWithSourceMapRecord("this", expression); + } + }; + + Emitter.prototype.emitSuperExpression = function (expression) { + this.writeToOutputWithSourceMapRecord("_super.prototype", expression); + }; + + Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { + if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { + this.emit(parenthesizedExpression.expression); + } else { + this.recordSourceMappingStart(parenthesizedExpression); + this.writeToOutput("("); + this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); + this.emit(parenthesizedExpression.expression); + this.writeToOutput(")"); + this.recordSourceMappingEnd(parenthesizedExpression); + } + }; + + Emitter.prototype.emitCastExpression = function (expression) { + this.emit(expression.expression); + }; + + Emitter.prototype.emitPrefixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 167 /* LogicalNotExpression */: + this.writeToOutput("!"); + this.emit(expression.operand); + break; + case 166 /* BitwiseNotExpression */: + this.writeToOutput("~"); + this.emit(expression.operand); + break; + case 165 /* NegateExpression */: + this.writeToOutput("-"); + if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 164 /* PlusExpression */: + this.writeToOutput("+"); + if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 168 /* PreIncrementExpression */: + this.writeToOutput("++"); + this.emit(expression.operand); + break; + case 169 /* PreDecrementExpression */: + this.writeToOutput("--"); + this.emit(expression.operand); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitPostfixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 210 /* PostIncrementExpression */: + this.emit(expression.operand); + this.writeToOutput("++"); + break; + case 211 /* PostDecrementExpression */: + this.emit(expression.operand); + this.writeToOutput("--"); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitTypeOfExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("typeof "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDeleteExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("delete "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitVoidExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("void "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { + var memberExpressionNodeType = expression.expression.kind(); + + 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 */) { + return this.canEmitDottedNameMemberAccessExpression(expression.expression); + } + + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { + this.recordSourceMappingStart(expression); + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { + this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); + } else { + this.emitComments(expression.expression, true); + this.recordSourceMappingStart(expression.expression); + + this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); + + this.writeToOutput(expression.expression.text()); + + this.recordSourceMappingEnd(expression.expression); + this.emitComments(expression.expression, false); + } + + this.writeToOutput("."); + this.emitName(expression.name, false); + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { + this.emitComments(expression, true); + + if (lastIndex - startingIndex < 1) { + startingIndex = lastIndex - 1; + TypeScript.Debug.assert(startingIndex >= 0); + } + + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); + this.emitComments(expression, false); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { + var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; + + var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); + }; + + Emitter.prototype.emitMemberAccessExpression = function (expression) { + if (!this.tryEmitConstant(expression)) { + if (this.canEmitDottedNameMemberAccessExpression(expression)) { + this.emitDottedNameMemberAccessExpression(expression); + } else { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("."); + this.emitName(expression.name, false); + this.recordSourceMappingEnd(expression); + } + } + }; + + Emitter.prototype.emitQualifiedName = function (name) { + this.recordSourceMappingStart(name); + + this.emit(name.left); + this.writeToOutput("."); + this.emitName(name.right, false); + + this.recordSourceMappingEnd(name); + }; + + Emitter.prototype.emitBinaryExpression = function (expression) { + this.recordSourceMappingStart(expression); + switch (expression.kind()) { + case 173 /* CommaExpression */: + this.emit(expression.left); + this.writeToOutput(", "); + this.emit(expression.right); + break; + default: { + this.emit(expression.left); + var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); + if (binOp === "instanceof") { + this.writeToOutput(" instanceof "); + } else if (binOp === "in") { + this.writeToOutput(" in "); + } else { + this.writeToOutput(" " + binOp + " "); + } + this.emit(expression.right); + } + } + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimplePropertyAssignment = function (property) { + this.recordSourceMappingStart(property); + this.emit(property.propertyName); + this.writeToOutput(": "); + this.emit(property.expression); + this.recordSourceMappingEnd(property); + }; + + Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { + this.recordSourceMappingStart(funcProp); + + this.emit(funcProp.propertyName); + this.writeToOutput(": "); + + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); + + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + var funcName = funcProp.propertyName; + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcProp); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); + + this.recordSourceMappingEnd(funcProp); + + this.recordSourceMappingEnd(funcProp); + + this.emitComments(funcProp, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConditionalExpression = function (expression) { + this.emit(expression.condition); + this.writeToOutput(" ? "); + this.emit(expression.whenTrue); + this.writeToOutput(" : "); + this.emit(expression.whenFalse); + }; + + Emitter.prototype.emitThrowStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("throw "); + this.emit(statement.expression); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitExpressionStatement = function (statement) { + var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; + + this.recordSourceMappingStart(statement); + if (isArrowExpression) { + this.writeToOutput("("); + } + + this.emit(statement.expression); + + if (isArrowExpression) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitLabeledStatement = function (statement) { + this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); + this.writeLineToOutput(":"); + this.emitJavascript(statement.statement, true); + }; + + Emitter.prototype.emitBlock = function (block) { + this.recordSourceMappingStart(block); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + if (block.statements) { + this.emitList(block.statements); + } + this.emitCommentsArray(block.closeBraceLeadingComments, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(block); + }; + + Emitter.prototype.emitBreakStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("break"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitContinueStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("continue"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitWhileStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("while ("); + this.emit(statement.condition); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitDoStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("do"); + this.emitBlockOrStatement(statement.statement); + this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); + this.writeToOutput('('); + this.emit(statement.condition); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitIfStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("if ("); + this.emit(statement.condition); + this.writeToOutput(")"); + + this.emitBlockOrStatement(statement.statement); + + if (statement.elseClause) { + if (statement.statement.kind() !== 146 /* Block */) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + + this.emit(statement.elseClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitElseClause = function (elseClause) { + if (elseClause.statement.kind() === 147 /* IfStatement */) { + this.writeToOutput("else "); + this.emit(elseClause.statement); + } else { + this.writeToOutput("else"); + this.emitBlockOrStatement(elseClause.statement); + } + }; + + Emitter.prototype.emitReturnStatement = function (statement) { + this.recordSourceMappingStart(statement); + if (statement.expression) { + this.writeToOutput("return "); + this.emit(statement.expression); + } else { + this.writeToOutput("return"); + } + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitForInStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.left) { + this.emit(statement.left); + } else { + this.emit(statement.variableDeclaration); + } + this.writeToOutput(" in "); + this.emit(statement.expression); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitForStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.variableDeclaration) { + this.emit(statement.variableDeclaration); + } else if (statement.initializer) { + this.emit(statement.initializer); + } + + this.writeToOutput("; "); + this.emitJavascript(statement.condition, false); + this.writeToOutput(";"); + if (statement.incrementor) { + this.writeToOutput(" "); + this.emitJavascript(statement.incrementor, false); + } + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitWithStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("with ("); + if (statement.condition) { + this.emit(statement.condition); + } + + this.writeToOutput(")"); + var prevInWithBlock = this.inWithBlock; + this.inWithBlock = true; + this.emitBlockOrStatement(statement.statement); + this.inWithBlock = prevInWithBlock; + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitSwitchStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("switch ("); + this.emit(statement.expression); + this.recordSourceMappingStart(statement.closeParenToken); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement.closeParenToken); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + this.emitList(statement.switchClauses, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCaseSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("case "); + this.emit(clause.expression); + this.writeToOutput(":"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitSwitchClauseBody = function (body) { + if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { + this.emit(body.childAt(0)); + this.writeLineToOutput(""); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emit(body); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitDefaultSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("default:"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitTryStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("try "); + this.emit(statement.block); + this.emitJavascript(statement.catchClause, false); + + if (statement.finallyClause) { + this.emit(statement.finallyClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCatchClause = function (clause) { + this.writeToOutput(" "); + this.recordSourceMappingStart(clause); + this.writeToOutput("catch ("); + this.emit(clause.identifier); + this.writeToOutput(")"); + this.emit(clause.block); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitFinallyClause = function (clause) { + this.writeToOutput(" finally"); + this.emit(clause.block); + }; + + Emitter.prototype.emitDebuggerStatement = function (statement) { + this.writeToOutputWithSourceMapRecord("debugger", statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitNumericLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitRegularExpressionLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitStringLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitEqualsValueClause = function (clause) { + this.writeToOutput(" = "); + this.emit(clause.value); + }; + + Emitter.prototype.emitParameter = function (parameter) { + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); + }; + + Emitter.prototype.emitConstructorDeclaration = function (declaration) { + if (declaration.block) { + this.emitConstructor(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { + return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); + }; + + Emitter.prototype.emitFunctionDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { + this.emitFunction(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.emitSourceUnit = function (sourceUnit) { + if (!this.document.isDeclareFile()) { + var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + this.pushDecl(pullDecl); + this.emitScriptElements(sourceUnit); + this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); + } + }; + + Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); + }; + + Emitter.prototype.emitEnumDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { + this.emitComments(declaration, true); + this.emitEnum(declaration); + this.emitComments(declaration, false); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); + }; + + Emitter.prototype.emitModuleDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { + this.emitModuleDeclarationWorker(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); + }; + + Emitter.prototype.emitClassDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + this.emitClass(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { + return declaration.preComments() !== null; + }; + + Emitter.prototype.emitInterfaceDeclaration = function (declaration) { + this.emitComments(declaration, true, true); + }; + + Emitter.prototype.firstVariableDeclarator = function (statement) { + return statement.declaration.declarators.nonSeparatorAt(0); + }; + + Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { + return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; + }; + + Emitter.prototype.shouldEmitVariableStatement = function (statement) { + return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); + }; + + Emitter.prototype.emitVariableStatement = function (statement) { + if (this.isNotAmbientOrHasInitializer(statement)) { + this.emitComments(statement, true); + this.emit(statement.declaration); + this.writeToOutput(";"); + this.emitComments(statement, false); + } else { + this.emitComments(statement, true, true); + } + }; + + Emitter.prototype.emitGenericType = function (type) { + this.emit(type.name); + }; + + Emitter.prototype.shouldEmit = function (ast) { + if (!ast) { + return false; + } + + switch (ast.kind()) { + case 133 /* ImportDeclaration */: + return this.shouldEmitImportDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.shouldEmitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.shouldEmitInterfaceDeclaration(ast); + case 129 /* FunctionDeclaration */: + return this.shouldEmitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.shouldEmitModuleDeclaration(ast); + case 148 /* VariableStatement */: + return this.shouldEmitVariableStatement(ast); + case 223 /* OmittedExpression */: + return false; + case 132 /* EnumDeclaration */: + return this.shouldEmitEnumDeclaration(ast); + } + + return true; + }; + + Emitter.prototype.emit = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 2 /* SeparatedList */: + return this.emitSeparatedList(ast); + case 1 /* List */: + return this.emitList(ast); + case 120 /* SourceUnit */: + return this.emitSourceUnit(ast); + case 133 /* ImportDeclaration */: + return this.emitImportDeclaration(ast); + case 134 /* ExportAssignment */: + return this.setExportAssignment(ast); + case 131 /* ClassDeclaration */: + return this.emitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitInterfaceDeclaration(ast); + case 11 /* IdentifierName */: + return this.emitName(ast, true); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast); + case 219 /* SimpleArrowFunctionExpression */: + return this.emitSimpleArrowFunctionExpression(ast); + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.emitParenthesizedArrowFunctionExpression(ast); + case 129 /* FunctionDeclaration */: + return this.emitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitModuleDeclaration(ast); + case 224 /* VariableDeclaration */: + return this.emitVariableDeclaration(ast); + case 126 /* GenericType */: + return this.emitGenericType(ast); + case 137 /* ConstructorDeclaration */: + return this.emitConstructorDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitEnumDeclaration(ast); + case 243 /* EnumElement */: + return this.emitEnumElement(ast); + case 222 /* FunctionExpression */: + return this.emitFunctionExpression(ast); + case 148 /* VariableStatement */: + return this.emitVariableStatement(ast); + } + + this.emitComments(ast, true); + this.emitWorker(ast); + this.emitComments(ast, false); + }; + + Emitter.prototype.emitWorker = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 13 /* NumericLiteral */: + return this.emitNumericLiteral(ast); + case 12 /* RegularExpressionLiteral */: + return this.emitRegularExpressionLiteral(ast); + case 14 /* StringLiteral */: + return this.emitStringLiteral(ast); + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 37 /* TrueKeyword */: + return this.emitLiteralExpression(ast); + case 35 /* ThisKeyword */: + return this.emitThisExpression(ast); + case 50 /* SuperKeyword */: + return this.emitSuperExpression(ast); + case 217 /* ParenthesizedExpression */: + return this.emitParenthesizedExpression(ast); + case 214 /* ArrayLiteralExpression */: + return this.emitArrayLiteralExpression(ast); + case 211 /* PostDecrementExpression */: + case 210 /* PostIncrementExpression */: + return this.emitPostfixUnaryExpression(ast); + case 167 /* LogicalNotExpression */: + case 166 /* BitwiseNotExpression */: + case 165 /* NegateExpression */: + case 164 /* PlusExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.emitPrefixUnaryExpression(ast); + case 213 /* InvocationExpression */: + return this.emitInvocationExpression(ast); + case 221 /* ElementAccessExpression */: + return this.emitElementAccessExpression(ast); + case 212 /* MemberAccessExpression */: + return this.emitMemberAccessExpression(ast); + case 121 /* QualifiedName */: + return this.emitQualifiedName(ast); + case 173 /* CommaExpression */: + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 187 /* LogicalOrExpression */: + case 188 /* LogicalAndExpression */: + case 189 /* BitwiseOrExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 191 /* BitwiseAndExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return this.emitBinaryExpression(ast); + case 186 /* ConditionalExpression */: + return this.emitConditionalExpression(ast); + case 232 /* EqualsValueClause */: + return this.emitEqualsValueClause(ast); + case 242 /* Parameter */: + return this.emitParameter(ast); + case 146 /* Block */: + return this.emitBlock(ast); + case 235 /* ElseClause */: + return this.emitElseClause(ast); + case 147 /* IfStatement */: + return this.emitIfStatement(ast); + case 149 /* ExpressionStatement */: + return this.emitExpressionStatement(ast); + case 139 /* GetAccessor */: + return this.emitGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitSetAccessor(ast); + case 157 /* ThrowStatement */: + return this.emitThrowStatement(ast); + case 150 /* ReturnStatement */: + return this.emitReturnStatement(ast); + case 216 /* ObjectCreationExpression */: + return this.emitObjectCreationExpression(ast); + case 151 /* SwitchStatement */: + return this.emitSwitchStatement(ast); + case 233 /* CaseSwitchClause */: + return this.emitCaseSwitchClause(ast); + case 234 /* DefaultSwitchClause */: + return this.emitDefaultSwitchClause(ast); + case 152 /* BreakStatement */: + return this.emitBreakStatement(ast); + case 153 /* ContinueStatement */: + return this.emitContinueStatement(ast); + case 154 /* ForStatement */: + return this.emitForStatement(ast); + case 155 /* ForInStatement */: + return this.emitForInStatement(ast); + case 158 /* WhileStatement */: + return this.emitWhileStatement(ast); + case 163 /* WithStatement */: + return this.emitWithStatement(ast); + case 220 /* CastExpression */: + return this.emitCastExpression(ast); + case 215 /* ObjectLiteralExpression */: + return this.emitObjectLiteralExpression(ast); + case 240 /* SimplePropertyAssignment */: + return this.emitSimplePropertyAssignment(ast); + case 241 /* FunctionPropertyAssignment */: + return this.emitFunctionPropertyAssignment(ast); + case 156 /* EmptyStatement */: + return this.writeToOutputWithSourceMapRecord(";", ast); + case 159 /* TryStatement */: + return this.emitTryStatement(ast); + case 236 /* CatchClause */: + return this.emitCatchClause(ast); + case 237 /* FinallyClause */: + return this.emitFinallyClause(ast); + case 160 /* LabeledStatement */: + return this.emitLabeledStatement(ast); + case 161 /* DoStatement */: + return this.emitDoStatement(ast); + case 171 /* TypeOfExpression */: + return this.emitTypeOfExpression(ast); + case 170 /* DeleteExpression */: + return this.emitDeleteExpression(ast); + case 172 /* VoidExpression */: + return this.emitVoidExpression(ast); + case 162 /* DebuggerStatement */: + return this.emitDebuggerStatement(ast); + } + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; + + function getLastConstructor(classDecl) { + return classDecl.classElements.lastOrDefault(function (e) { + return e.kind() === 137 /* ConstructorDeclaration */; + }); + } + TypeScript.getLastConstructor = getLastConstructor; + + function getTrimmedTextLines(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + return comment.fullText().split("\n").map(function (s) { + return s.trim(); + }); + } else { + return [comment.fullText().trim()]; + } + } + TypeScript.getTrimmedTextLines = getTrimmedTextLines; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += memberName.text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function stripStartAndEndQuotes(str) { + var firstCharCode = str && str.charCodeAt(0); + if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + return str.substring(1, str.length - 1); + } + + return str; + } + TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; + + function isSingleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isDoubleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; + } + TypeScript.isDoubleQuoted = isDoubleQuoted; + + function isQuoted(str) { + return isDoubleQuoted(str) || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function changePathToDTS(modPath) { + return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + function convertToDirectoryPath(dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + } + TypeScript.convertToDirectoryPath = convertToDirectoryPath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + function isNoDefaultLibMatch(comment) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + return isNoDefaultLibRegex.exec(comment); + } + + TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; + + function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { + var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } + } + } + + return null; + } + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + var start = new Date().getTime(); + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionScanImportsTime += totalTime; + } + + function processTripleSlashDirectives(fileName, lineMap, firstToken) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + var diagnostics = []; + var referencedFiles = []; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + var isNoDefaultLib = isNoDefaultLibMatch(triviaText); + if (isNoDefaultLib) { + noDefaultLib = isNoDefaultLib[3] === "true"; + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; + } + + function preProcessFile(fileName, sourceText, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); + + scannerDiagnostics.length = 0; + return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); + } + TypeScript.getParseOptions = getParseOptions; + + function getReferencedFiles(fileName, sourceText) { + return preProcessFile(fileName, sourceText, false).referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, lineMap, position, length, isImported) { + this.filePath = filePath; + this.lineMap = lineMap; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { + this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this.inputFileNames = inputFileNames; + this.host = host; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { + var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var _this = this; + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); + this.inputFileNames.forEach(function (fileName) { + return _this.resolveIncludedFile(fileName, referenceLocation, result); + }); + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(tsFile)) { + normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + var start = new Date().getTime(); + + do { + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var _this = this; + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var start = new Date().getTime(); + var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionIOTime += totalTime; + + var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); + resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); + var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + }); + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(name, writeByteOrderMark, outputFileType) { + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.outputFileType = outputFileType; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + }; + + TextWriter.prototype.getOutputFile = function () { + return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.emittedReferencePaths = false; + this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); + } + DeclarationEmitter.prototype.getOutputFile = function () { + return this.declFile.getOutputFile(); + }; + + DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { + this.emitDeclarationsForSourceUnit(sourceUnit); + }; + + DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.emitDeclarationsForAST(list.childAt(i)); + } + }; + + DeclarationEmitter.prototype.emitSeparatedList = function (list) { + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.emitDeclarationsForAST(list.nonSeparatorAt(i)); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { + switch (ast.kind()) { + case 148 /* VariableStatement */: + return this.emitDeclarationsForVariableStatement(ast); + case 141 /* PropertySignature */: + return this.emitPropertySignature(ast); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast, true, true); + case 136 /* MemberVariableDeclaration */: + return this.emitDeclarationsForMemberVariableDeclaration(ast); + case 137 /* ConstructorDeclaration */: + return this.emitDeclarationsForConstructorDeclaration(ast); + case 139 /* GetAccessor */: + return this.emitDeclarationsForGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitDeclarationsForSetAccessor(ast); + case 138 /* IndexMemberDeclaration */: + return this.emitIndexMemberDeclaration(ast); + case 144 /* IndexSignature */: + return this.emitIndexSignature(ast); + case 142 /* CallSignature */: + return this.emitCallSignature(ast); + case 143 /* ConstructSignature */: + return this.emitConstructSignature(ast); + case 145 /* MethodSignature */: + return this.emitMethodSignature(ast); + case 129 /* FunctionDeclaration */: + return this.emitDeclarationsForFunctionDeclaration(ast); + case 135 /* MemberFunctionDeclaration */: + return this.emitMemberFunctionDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.emitDeclarationsForClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitDeclarationsForInterfaceDeclaration(ast); + case 133 /* ImportDeclaration */: + return this.emitDeclarationsForImportDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitDeclarationsForModuleDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitDeclarationsForEnumDeclaration(ast); + case 134 /* ExportAssignment */: + return this.emitDeclarationsForExportAssignment(ast); + } + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { + var container = this.getEnclosingContainer(declAST); + if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { + var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); + var container = this.getEnclosingContainer(declAST); + + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { + container = this.getEnclosingContainer(container); + } + + var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); + + if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { + result += "declare "; + } + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { + this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { + var declarationContainerAst = this.getEnclosingContainer(ast); + + var start = new Date().getTime(); + var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); + + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = TypeScript.getTrimmedTextLines(comment); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.semanticInfoChain.getDeclForAST(boundDecl); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = pullSymbol.type; + TypeScript.Debug.assert(type); + + this.declFile.Write(": "); + this.emitTypeSignature(boundDecl, type); + }; + + DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { + this.emitDeclarationComments(varDecl); + this.emitIndent(); + this.declFile.Write(varDecl.propertyName.text()); + if (varDecl.questionToken) { + this.declFile.Write("?"); + } + + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + if (isFirstVarInList) { + this.emitDeclFlags(varDecl, "var"); + } + + this.declFile.Write(varDecl.propertyName.text()); + + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + if (isLastVarInList) { + this.declFile.WriteLine(";"); + } else { + this.declFile.Write(", "); + } + } + }; + + DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { + if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } + this.declFile.Write("static "); + } else { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } else { + this.declFile.Write("public "); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(varDecl.modifiers); + ; + + this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); + + if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + this.declFile.WriteLine(";"); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { + this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); + }; + + 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); + } + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(id.text()); + if (isOptional) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (!isPrivate) { + this.emitTypeOfVariableDeclaratorOrParameter(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("constructor"); + + this.declFile.Write("("); + 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.ASTHelpers.parametersFromParameterList(parameterList)); + this.declFile.Write(")"); + }; + + DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { + var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); + var argsLen = parameterList.length; + if (hasLastParameterRestParameter) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + + if (hasLastParameterRestParameter) { + if (parameterList.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + var index = parameterList.length - 1; + this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); + } + }; + + DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitDeclFlags(funcDecl, "function"); + var id = funcDecl.propertyName.text(); + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); + + this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); + + if (!isPrivate) { + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + this.emitDeclarationComments(funcDecl); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); + + this.emitIndent(); + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("new"); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write(funcDecl.propertyName.text()); + if (funcDecl.questionToken) { + this.declFile.Write("? "); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + if (funcDecl.block) { + var funcTypeSymbol = funcSymbol.type; + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + var id = funcDecl.identifier.text(); + this.emitDeclFlags(funcDecl, "function"); + if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { + this.declFile.Write(id); + } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { + this.declFile.Write("new"); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { + this.emitDeclarationsForAST(funcDecl.indexSignature); + }; + + DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("["); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); + this.declFile.Write("]"); + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { + if (bases && (bases.nonSeparatorCount() > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.nonSeparatorCount(); + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + var base = bases.nonSeparatorAt(i); + var baseType = this.semanticInfoChain.getSymbolForAST(base); + this.emitTypeSignature(base, baseType); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); + } + if (accessors.setter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { + return; + } + + var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); + this.emitAccessorDeclarationComments(funcDecl); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(modifiers); + this.declFile.Write(name.text()); + if (!isPrivate) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(funcDecl, type); + } + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } + + 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(";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { + if (!this.canEmitDeclarations(classDecl)) { + return; + } + + var className = classDecl.identifier.text(); + this.emitDeclarationComments(classDecl); + var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.emitDeclFlags(classDecl, "class"); + this.declFile.Write(className); + + this.emitTypeParameters(classDecl.typeParameterList); + this.emitHeritageClauses(classDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + var constructorDecl = TypeScript.getLastConstructor(classDecl); + if (constructorDecl) { + this.emitClassMembersFromConstructorDefinition(constructorDecl); + } + + this.emitDeclarationsForList(classDecl.classElements); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { + if (clauses) { + for (var i = 0, n = clauses.childCount(); i < n; i++) { + this.emitHeritageClause(clauses.childAt(i)); + } + } + }; + + DeclarationEmitter.prototype.emitHeritageClause = function (clause) { + this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); + }; + + DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getEnclosingContainer(typeParams); + + var start = new Date().getTime(); + var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArgumentsOrTypeParameters(); + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { + if (!this.canEmitDeclarations(interfaceDecl)) { + return; + } + + var interfaceName = interfaceDecl.identifier.text(); + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); + this.emitDeclFlags(interfaceDecl, "interface"); + this.declFile.Write(interfaceName); + + this.emitTypeParameters(interfaceDecl.typeParameterList); + this.emitHeritageClauses(interfaceDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + + this.emitSeparatedList(interfaceDecl.body.typeMembers); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.identifier.text() + " = "); + if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); + } else { + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclFlags(moduleDecl, "enum"); + this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.enumElements.nonSeparatorCount(); + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); + var enumElement = memberDecl; + var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); + this.emitDeclarationComments(enumElement); + this.emitIndent(); + this.declFile.Write(enumElement.propertyName.text()); + if (enumElementDecl.constantValue !== null) { + this.declFile.Write(" = " + enumElementDecl.constantValue); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclarationComments(moduleDecl); + + var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); + this.emitDeclFlags(name, "module"); + + if (moduleDecl.stringLiteral) { + this.declFile.Write(moduleDecl.stringLiteral.text()); + } else { + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); + } + + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + + this.emitDeclarationsForList(moduleDecl.moduleElements); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.identifier.text()); + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { + if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { + return reference; + } + + var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); + var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); + return resolvedReferencePath; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.document.emitToOwnOutputFile()) { + var scriptReferences = this.document.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { + documents = documents.concat(document); + + if (!document.isDeclareFile() && document.isExternalModule()) { + addedGlobalDocument = true; + } + } + } + } else { + var fileNames = this.compiler.fileNames(); + for (var i = 0; i < fileNames.length; i++) { + var doc = this.compiler.getDocument(fileNames[i]); + if (!doc.isDeclareFile() && !doc.isExternalModule()) { + var scriptReferences = doc.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.isDeclareFile() || document.isExternalModule())) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] === document) { + break; + } + } + + if (k === documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.isDeclareFile()) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { + this.emitReferencePaths(sourceUnit); + this.emitDeclarationsForList(sourceUnit.moduleElements); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] !== array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + 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, createFileLog) { + this._propagateEnumConstants = propagateEnumConstants; + this._removeComments = removeComments; + this._watch = watch; + this._noResolve = noResolve; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + this._noImplicitAny = noImplicitAny; + this._noLib = noLib; + this._codeGenTarget = codeGenTarget; + this._moduleGenTarget = moduleGenTarget; + this._outFileOption = outFileOption; + this._outDirOption = outDirOption; + this._mapSourceFiles = mapSourceFiles; + this._mapRoot = mapRoot; + this._sourceRoot = sourceRoot; + this._generateDeclarationFiles = generateDeclarationFiles; + this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this._gatherDiagnostics = gatherDiagnostics; + this._codepage = codepage; + this._createFileLog = createFileLog; + } + ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { + return this._propagateEnumConstants; + }; + ImmutableCompilationSettings.prototype.removeComments = function () { + return this._removeComments; + }; + ImmutableCompilationSettings.prototype.watch = function () { + return this._watch; + }; + ImmutableCompilationSettings.prototype.noResolve = function () { + return this._noResolve; + }; + ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + ImmutableCompilationSettings.prototype.noImplicitAny = function () { + return this._noImplicitAny; + }; + ImmutableCompilationSettings.prototype.noLib = function () { + return this._noLib; + }; + ImmutableCompilationSettings.prototype.codeGenTarget = function () { + return this._codeGenTarget; + }; + ImmutableCompilationSettings.prototype.moduleGenTarget = function () { + return this._moduleGenTarget; + }; + ImmutableCompilationSettings.prototype.outFileOption = function () { + return this._outFileOption; + }; + ImmutableCompilationSettings.prototype.outDirOption = function () { + return this._outDirOption; + }; + ImmutableCompilationSettings.prototype.mapSourceFiles = function () { + return this._mapSourceFiles; + }; + ImmutableCompilationSettings.prototype.mapRoot = function () { + return this._mapRoot; + }; + ImmutableCompilationSettings.prototype.sourceRoot = function () { + return this._sourceRoot; + }; + ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { + return this._generateDeclarationFiles; + }; + ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { + return this._useCaseSensitiveFileResolution; + }; + ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { + return this._gatherDiagnostics; + }; + ImmutableCompilationSettings.prototype.codepage = function () { + return this._codepage; + }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; + + ImmutableCompilationSettings.defaultSettings = function () { + if (!ImmutableCompilationSettings._defaultSettings) { + ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); + } + + return ImmutableCompilationSettings._defaultSettings; + }; + + 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, 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, "_")) { + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; + } + } + + return result; + }; + return ImmutableCompilationSettings; + })(); + TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; + + PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + function hasModifier(modifiers, flag) { + for (var i = 0, n = modifiers.length; i < n; i++) { + if (TypeScript.hasFlag(modifiers[i], flag)) { + return true; + } + } + + return false; + } + TypeScript.hasModifier = hasModifier; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; + PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; + + 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.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"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var pullDeclID = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + 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; + this.childDeclTypeParameterCache = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.semanticInfoChain = semanticInfoChain; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + } + PullDecl.prototype.fileName = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentPath = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.isExternalModule = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getEnclosingDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { + var decl = this; + while (decl) { + switch (decl.kind) { + default: + return decl; + case 512 /* Variable */: + case 8192 /* TypeParameter */: + case 2048 /* Parameter */: + case 128 /* TypeAlias */: + case 67108864 /* EnumMember */: + } + + decl = decl.getParentDecl(); + } + + TypeScript.Debug.fail(); + }; + + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.semanticInfoChain.setSymbolForDecl(this, symbol); + }; + + 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 */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.semanticInfoChain.getSymbolForDecl(this); + }; + + PullDecl.prototype.hasSymbol = function () { + var symbol = this.semanticInfoChain.getSymbolForDecl(this); + return !!symbol; + }; + + PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); + }; + + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); + }; + + PullDecl.prototype.hasSignatureSymbol = function () { + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); + return !!signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; + }; + + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + if (declKind === 8192 /* TypeParameter */) { + if (!this.childDeclTypeParameterCache) { + this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeParameterCache; + } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { + if (!this.childDeclNamespaceCache) { + this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclNamespaceCache; + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { + if (!this.childDeclTypeCache) { + this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeCache; + } else { + if (!this.childDeclValueCache) { + this.childDeclValueCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclValueCache; + } + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + + if (!(childDecl.kind & 7340032 /* SomeSignature */)) { + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + } + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; + } else if (searchKind & 164 /* SomeContainer */) { + cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; + } else { + cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + if (!this.declGroups) { + this.declGroups = TypeScript.createIntrinsicsObject(); + } + + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + if (this.declGroups) { + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (declGroups === null) { + declGroups = []; + } + + declGroups.push(this.declGroups[declName].getDecls()); + } + } + } + + return declGroups || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.hasBeenBound = function () { + return this.hasSymbol() || this.hasSignatureSymbol(); + }; + + PullDecl.prototype.isSynthesized = function () { + return false; + }; + + PullDecl.prototype.ast = function () { + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var RootPullDecl = (function (_super) { + __extends(RootPullDecl, _super); + 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; + } + RootPullDecl.prototype.fileName = function () { + return this._fileName; + }; + + RootPullDecl.prototype.getParentPath = function () { + return [this]; + }; + + RootPullDecl.prototype.getParentDecl = function () { + return null; + }; + + RootPullDecl.prototype.isExternalModule = function () { + return this._isExternalModule; + }; + + 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, addToParent) { + if (typeof addToParent === "undefined") { addToParent = true; } + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); + this.parentDecl = null; + this.parentPath = null; + + this.parentDecl = parentDecl; + 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._rootDecl.fileName(); + }; + + NormalPullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + NormalPullDecl.prototype.getParentPath = function () { + if (!this.parentPath) { + var path = [this]; + var parentDecl = this.parentDecl; + + while (parentDecl) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { + path.unshift(parentDecl); + } + + parentDecl = parentDecl.getParentDecl(); + } + + this.parentPath = path; + } + + return this.parentPath; + }; + + NormalPullDecl.prototype.isExternalModule = function () { + return false; + }; + + 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) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); + this.constantValue = null; + } + return PullEnumElementDecl; + })(NormalPullDecl); + TypeScript.PullEnumElementDecl = PullEnumElementDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { + if (typeof displayName === "undefined") { displayName = ""; } + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(NormalPullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullSynthesizedDecl = (function (_super) { + __extends(PullSynthesizedDecl, _super); + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; + } + PullSynthesizedDecl.prototype.isSynthesized = function () { + return true; + }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; + return PullSynthesizedDecl; + })(NormalPullDecl); + TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = ++TypeScript.pullSymbolID; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.rootSymbol = null; + this._enclosingSignature = null; + this._docComments = null; + this.isPrinting = false; + this.name = name; + this.kind = declKind; + } + PullSymbol.prototype.isAny = function () { + return false; + }; + + PullSymbol.prototype.isType = function () { + return (this.kind & 58728795 /* SomeType */) !== 0; + }; + + PullSymbol.prototype.isTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & 7340032 /* SomeSignature */) !== 0; + }; + + PullSymbol.prototype.isArrayNamedTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { + if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } + if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } + var scopeDeclarations = scopeSymbol.getDeclarations(); + var scopeSymbolAliasesToLookIn = []; + + for (var i = 0; i < scopeDeclarations.length; i++) { + var scopeDecl = scopeDeclarations[i]; + if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { + visitedScopeDeclarations.push(scopeDecl); + + var childDecls = scopeDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { + var symbol = childDecl.getSymbol(); + + if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { + aliasSymbols.push(symbol); + return aliasSymbols; + } + + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { + scopeSymbolAliasesToLookIn.push(symbol); + } + } + } + } + } + + for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { + var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; + + aliasSymbols.push(scopeSymbolAlias); + var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); + if (result) { + return result; + } + + aliasSymbols.pop(); + } + + return null; + }; + + PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); + return symbols; + } + + return null; + }; + + PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { + if (aliasSymbol) { + if (aliasSymbol.assignedValue()) { + return false; + } + + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { + return false; + } + + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { + return false; + } + + return true; + } + + return false; + }; + + PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { + if (scopeSymbol) { + 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); + return internalAliases[0]; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { + if (!skipInternalAlias) { + var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); + if (internalAlias) { + return aliasNameGetter(internalAlias); + } + } + + var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); + + if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { + 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 aliasFullName; + } + + return null; + }; + + PullSymbol.prototype._getResolver = function () { + TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); + return this._declarations[0].semanticInfoChain.getResolver(); + }; + + PullSymbol.prototype._resolveDeclaredSymbol = function () { + return this._getResolver().resolveDeclaredSymbol(this); + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getName(); + }); + return aliasName || this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getDisplayName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getDisplayName(); + }, skipInternalAliasName); + if (aliasDisplayName) { + return aliasDisplayName; + } + + var decls = this.getDeclarations(); + var name = decls.length && decls[0].getDisplayName(); + + return (name && name.length) ? name : this.name; + }; + + PullSymbol.prototype.getIsSpecialized = function () { + return false; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + 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; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.hasDeclaration = function (decl) { + if (!this._declarations) { + return false; + } + + return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { + return eachDecl === decl; + }); + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.anyDeclHasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (TypeScript.hasFlag(declarations[i].flags, flag)) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!TypeScript.hasFlag(declarations[i].flags, flag)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = node.getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind === 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + PullSymbol.prototype.findCommonAncestorPath = function (b) { + var aPath = this.pathToRoot(); + if (aPath.length === 1) { + return aPath; + } + + var bPath; + if (b) { + bPath = b.pathToRoot(); + } else { + return aPath; + } + + 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; + } + } + } + if (commonNodeIndex >= 0) { + break; + } + } + + if (commonNodeIndex >= 0) { + return aPath.slice(0, commonNodeIndex); + } else { + return aPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; + var path = this.pathToRoot(); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol === _this ? null : symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + var path = this.findCommonAncestorPath(scopeSymbol); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { + var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + 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 */) { + var signatures = type.getCallSignatures(); + 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); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + + inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); + + var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); + inIsExternallyVisibleSymbols.pop(); + + return result; + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.rootSymbol) { + return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); + } + + if (this.isType()) { + var associatedContainerSymbol = this.getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.anyDeclHasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + var decls = this.getDeclarations(); + if (decls.length) { + var parentDecl = decls[0].getParentDecl(); + if (parentDecl) { + var parentSymbol = parentDecl.getSymbol(); + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { + return true; + } + + return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); + } + } + + return true; + } + + 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 */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { + var ast = decl.ast(); + + if (ast) { + 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.ASTHelpers.docComments(ast); + } + } + + return []; + }; + + PullSymbol.prototype.getDocCommentArray = function (symbol) { + var docComments = []; + if (!symbol) { + return docComments; + } + + 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 */) { + continue; + } + docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); + } + return docComments; + }; + + PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { + if (classSymbol.getHasDefaultConstructor()) { + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); + } + } + + return classSymbol.type.getConstructSignatures()[0]; + }; + + PullSymbol.prototype.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = this.getDocCommentTextValue(comments[c]); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + PullSymbol.prototype.getDocCommentTextValue = function (comment) { + return this.cleanJSDocComment(comment.fullText()); + }; + + PullSymbol.prototype.docComments = function (useConstructorAsClass) { + var decls = this.getDeclarations(); + 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 */) { + var classSymbol = this.returnType; + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + docComments = extendedTypes[0].getConstructorMethod().docComments(); + } else { + docComments = ""; + } + } else if (this.kind === 2048 /* Parameter */) { + var parameterComments = []; + + var funcContainer = this.getEnclosingSignature(); + var funcDocComments = this.getDocCommentArray(funcContainer); + var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); + if (paramComment != "") { + parameterComments.push(paramComment); + } + + var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); + if (paramSelfComment != "") { + parameterComments.push(paramSelfComment); + } + docComments = parameterComments.join("\n"); + } else { + var getSymbolComments = true; + if (this.kind === 16777216 /* FunctionType */) { + var functionSymbol = this.getFunctionSymbol(); + + if (functionSymbol) { + docComments = functionSymbol._docComments || ""; + getSymbolComments = false; + } else { + var declarationList = this.getDeclarations(); + if (declarationList.length > 0) { + docComments = declarationList[0].getSymbol()._docComments || ""; + getSymbolComments = false; + } + } + } + if (getSymbolComments) { + docComments = this.getDocCommentText(this.getDocCommentArray(this)); + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { + var callTypeSymbol = this.functionType; + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { + docComments = callTypeSymbol.docComments(); + } + } + } + } + } + + this._docComments = docComments; + } + + return this._docComments; + }; + + PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].fullText(); + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!this.isSpaceChar(commentContents, j)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + + PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.start; + for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.end); + } + + var newCleanPos = this.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + PullSymbol.prototype.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = this.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + start: nonSpaceIndex, + end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + 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.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; + this.hasBeenChecked = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return this._isDefinition; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + 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) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this._typeParameters) { + this._typeParameters = []; + } + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + 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 = []; + } + + return this._typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; + } + } + + memberSymbol = this._memberTypeParameterNameCache[name]; + + 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; + this._stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { + this._stringConstantOverload = true; + } + } + } + + 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); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + 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 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 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 wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + + var parameters = this.parameters; + + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._enclosedMemberContainers = null; + this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._enclosedContainerCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._containedNonMemberContainerCache = null; + this._simpleInstantiationCache = null; + this._complexInstantiationCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this._inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + this.typeReference = null; + this._widenedType = null; + this._isArrayNamedTypeReference = undefined; + this.type = this; + } + PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { + if (this._isArrayNamedTypeReference === undefined) { + this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); + } + + return this._isArrayNamedTypeReference; + }; + + PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { + var typeArgs = this.getTypeArguments(); + if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { + var declaration = this.getDeclarations()[0]; + + if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind === 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind === 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullTypeSymbol.prototype.isObject = function () { + 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 () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members !== TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return null; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberContainerCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = TypeScript.createIntrinsicsObject(); + } + + if (this._members === TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members.push(memberSymbol); + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + if (!enclosedContainer) { + return; + } + + enclosedContainer.setContainer(this); + + if (!this._enclosedContainerCache) { + this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberContainers) { + this._enclosedMemberContainers = []; + } + + this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; + this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + if (!enclosedNonMemberContainer) { + return; + } + + enclosedNonMemberContainer.setContainer(this); + + if (!this._containedNonMemberContainerCache) { + this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + 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 (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; + } + + 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; + } else { + if (!this._complexInstantiationCache) { + this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType.push(specializedVersionOfThisType); + }; + + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { + if (!this._simpleInstantiationCache) { + return null; + } + + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; + } else { + if (!this._complexInstantiationCache) { + return null; + } + + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + } + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return null; + }; + + PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + return this.getTypeParameters(); + }; + + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + 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 = []; + } + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + 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 = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + 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; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return this._constructSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function () { + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return this._indexSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnIndexSignatures = function () { + return this._indexSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function () { + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + } + } + + this._allIndexSignatures = signatures; + + 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; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { + if (typeof visited === "undefined") { visited = []; } + if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { + return true; + } + + if (TypeScript.ArrayUtilities.contains(visited, this)) { + return true; + } + + visited.push(this); + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + visited.pop(); + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (memberSymbol || !lookInParent) { + return memberSymbol; + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedContainerCache) { + return null; + } + + memberSymbol = this._enclosedContainerCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + var allMembers = []; + + 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 */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; + + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer()) { + if (this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + if (this._enclosedMemberContainers) { + for (var i = 0; i < this._enclosedMemberContainers.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberContainers[i]; + } + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArgumentsOrTypeParameters(); + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); + }; + + 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 !== "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); + return s; + }; + + 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, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + if (skipTypeParametersInName) { + return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); + } else { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + + var typars = this.getTypeArgumentsOrTypeParameters(); + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + } + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getTypeOfSymbol = function () { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + return associatedContainerType; + } + + var functionSymbol = this.getFunctionSymbol(); + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; + } + + return null; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + var typeOfSymbol = this.getTypeOfSymbol(); + if (typeOfSymbol) { + var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } + + if (this._inMemberTypeNameEx) { + return TypeScript.MemberName.create("any"); + } + + this._inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + 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()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && memberTypeName.delim === delim) { + allMemberNames.addAll(memberTypeName.entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this._inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + return 2 /* Closed */; + }; + + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + + if (type.isTypeParameter()) { + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; + } + + var constraint = type.getConstraint(); + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; + } + + if (type.inWrapCheck) { + return 0; + } + + 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; + + var typeArguments = type.getTypeArguments(); + + if (type.isGeneric() && !typeArguments) { + typeArguments = type.getTypeParameters(); + } + + if (typeArguments) { + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); + } + } + } + + 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); + } + + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); + } + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } + + return wrappingTypeParameterID; + }; + + 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + 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(); + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; + } + + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { + return true; + } + } + + 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); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isAny = function () { + 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 () { + return false; + }; + + 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; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(_anyType, name) { + _super.call(this, name); + 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); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerSymbol = (function (_super) { + __extends(PullContainerSymbol, _super); + function PullContainerSymbol(name, kind) { + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerSymbol.prototype.hasExportAssignment = function () { + return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; + }; + + PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { + return true; + } + + var moduleSymbol = containerSymbol; + var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerSymbol = PullContainerSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 128 /* TypeAlias */); + this._assignedValue = null; + this._assignedType = null; + 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; + }; + + PullTypeAliasSymbol.prototype.isUsedAsValue = function () { + this._resolveDeclaredSymbol(); + return this._isUsedAsValue; + }; + + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; + }; + + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; + + 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(); + }); + } + }; + + PullTypeAliasSymbol.prototype.assignedValue = function () { + this._resolveDeclaredSymbol(); + return this._assignedValue; + }; + + PullTypeAliasSymbol.prototype.assignedType = function () { + this._resolveDeclaredSymbol(); + return this._assignedType; + }; + + PullTypeAliasSymbol.prototype.assignedContainer = function () { + this._resolveDeclaredSymbol(); + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this._assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this._assignedValue) { + return this._assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this._assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedType) { + if (this._assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = this._assignedType.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this._assignedType !== this._assignedContainer) { + return this._assignedType; + } + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this._assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this._assignedType) { + return this._assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this._assignedType) { + return this._assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this._assignedType) { + return this._assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this._assignedType) { + return this._assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this._assignedType) { + return this._assignedType.findMember(name, true); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedContainer(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { + if (this._assignedType) { + return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); + } + + return TypeScript.sentinelEmptyArray; + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name) { + _super.call(this, name, 8192 /* TypeParameter */); + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + 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(); + } + + return _super.prototype.getCallSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getConstructSignatures = function () { + if (this._constraint) { + return this._constraint.getConstructSignatures(); + } + + return _super.prototype.getConstructSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getIndexSignatures = function () { + if (this._constraint) { + return this._constraint.getIndexSignatures(); + } + + return _super.prototype.getIndexSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { + var substitution = ""; + var members = null; + + 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 getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); + } + + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); + } + + return null; + } + + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.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"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; + })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); + 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._inferredTypeAfterFixing = null; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + 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 TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + this.candidateCache = []; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); + } + } + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { + return true; + } else { + this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); + return false; + } + }; + + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache.release(); + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + }; + + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolID]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolID] = info; + } + }; + + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolID]; + }; + + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { + var info = this.getInferenceInfo(param); + + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); + } + }; + + 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); + } + }; + + 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]; + + info.fixTypeParameter(this.resolver, this.context); + + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; + } + } + + results.push(info._inferredTypeAfterFixing); + } + + return results; + }; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; + })(); + 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, isInferentiallyTyping, typeArgumentInferenceContext) { + this.contextualType = contextualType; + this.provisional = provisional; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; + this.provisionallyTypedSymbols = []; + this.hasProvisionalErrors = false; + this.astSymbolMap = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].setUnresolved(); + } + }; + + PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()]; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + if (typeof fileName === "undefined") { fileName = null; } + this.resolver = resolver; + this.inTypeCheck = inTypeCheck; + 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"); + this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); + } + } + PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { + if (!this.inProvisionalResolution()) { + this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); + } + }; + + PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { + return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); + }; + + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); + }; + + 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(); + + if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; + } + + return tc; + }; + + PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + 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); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); + } + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { + if (diagnostic) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; + } else if (this.inTypeCheck && this.resolver) { + this.resolver.semanticInfoChain.addDiagnostic(diagnostic); + } + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inProvisionalResolution(); + }; + + PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { + this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); + }; + + PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + var typeContext = this.contextStack[i]; + if (!typeContext.provisional) { + break; + } + + var symbol = typeContext.getSymbolForAST(ast); + if (symbol) { + return symbol; + } + } + + 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; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OverloadApplicabilityStatus; + (function (OverloadApplicabilityStatus) { + OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; + })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + this.diagnosticsFromOverloadResolution = []; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var MemberWithBaseOrigin = (function () { + function MemberWithBaseOrigin(memberSymbol, baseOrigin) { + this.memberSymbol = memberSymbol; + this.baseOrigin = baseOrigin; + } + return MemberWithBaseOrigin; + })(); + + var SignatureWithBaseOrigin = (function () { + function SignatureWithBaseOrigin(signature, baseOrigin) { + this.signature = signature; + this.baseOrigin = baseOrigin; + } + return SignatureWithBaseOrigin; + })(); + + var InheritedIndexSignatureInfo = (function () { + function InheritedIndexSignatureInfo() { + } + return InheritedIndexSignatureInfo; + })(); + + 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(); + return CompilerReservedName[nameText]; + } + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this._cachedAnyTypeArgs = null; + this.typeCheckCallBacks = []; + this.postTypeCheckWorkitems = []; + this._cachedFunctionArgumentsSymbol = null; + 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 */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getArrayNamedType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { + if (!this._cachedFunctionArgumentsSymbol) { + this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); + functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); + this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + } + + 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); + }; + + PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { + return context.canTypeCheckAST(ast); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && context.inProvisionalResolution()) { + context.setSymbolForAST(ast, symbol); + } else { + this.semanticInfoChain.setSymbolForAST(ast, symbol); + } + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { + var symbol = this.semanticInfoChain.getSymbolForAST(ast); + + if (!symbol) { + if (context && context.inProvisionalResolution()) { + symbol = context.getSymbolForAST(ast); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { + if (typeof name === "undefined") { name = null; } + return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = decl.getParentPath(); + + if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.anyDeclHasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + 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 & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + + if (declSearchKind & 68147712 /* SomeValue */) { + member = parent.findMember(symbolName, true); + } else if (declSearchKind & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + } + + if (parent.kind & 164 /* SomeContainer */) { + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + return valueSymbol; + } + } + + return aliasSymbol; + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + 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; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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(); + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & 1032192 /* SomeFunction */) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (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) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = decl.getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var topLevelDecls = this.semanticInfoChain.topLevelDecls(); + for (var i = 0, n = topLevelDecls.length; i < n; i++) { + var topLevelDecl = topLevelDecls[i]; + if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { + continue; + } + + if (!topLevelDecl.isExternalModule()) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + 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 */ || lhs.kind === 64 /* Enum */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + this.resolveDeclaredSymbol(lhsType, context); + + if (lhsType.isContainer() && lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + var memberVisibilty = 2 /* externallyVisible */; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = enclosingDecl.getParentPath(); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { + memberVisibilty = 1 /* internallyVisible */; + break; + } + } + } + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + lhsType = this.getApparentType(lhsType); + + 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); + } + + 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 */)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { + var originalIdText = idText; + var symbol = null; + + if (TypeScript.isRelative(originalIdText)) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + symbol = this.semanticInfoChain.findExternalModule(path + idText); + } else { + idText = originalIdText; + + symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); + + if (!symbol) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + symbol = this.semanticInfoChain.findExternalModule(path + idText); + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + } + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { + if (!symbol || symbol.isResolved || symbol.isTypeReference()) { + return symbol; + } + + if (!context) { + context = new TypeScript.PullTypeResolutionContext(this); + } + + return this.resolveDeclaredSymbolWorker(symbol, context); + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.type && !symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + + var decls = symbol.getDeclarations(); + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + var ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + var resolvedSymbol; + 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 */); + resolvedSymbol = this.resolveAST(ast, false, context); + } + + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + 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(); + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); + }; + + PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { + var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); + var moduleSymbol = enclosingDecl.getSymbol(); + this.ensureAllSymbolsAreBound(moduleSymbol); + + this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); + this.resolveAST(sourceUnit.moduleElements, false, context); + + if (this.canTypeCheckAST(sourceUnit, context)) { + this.typeCheckSourceUnit(sourceUnit, context); + } + + return moduleSymbol; + }; + + 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) { + var containerDecl = this.semanticInfoChain.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + containerSymbol.setResolved(); + + this.resolveOtherDeclarations(ast, context); + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckEnumDeclaration(ast, context); + } + + return containerSymbol; + }; + + 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); + + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { + this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); + } + }; + + PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { + 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; + + if (ast.stringLiteral) { + result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckModuleDeclaration(ast, context); + } + + return result; + }; + + PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { + if (containerSymbol) { + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + }; + + PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + this.ensureAllSymbolsAreBound(containerSymbol); + + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, context); + } + + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + if (isLastName) { + this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); + } else if (sourceUnitAST) { + this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); + } + + containerSymbol.setResolved(); + + if (moduleDeclNameAST) { + this.resolveOtherDeclarations(moduleDeclNameAST, context); + } + + return containerSymbol; + }; + + 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 */) { + this.resolveExportAssignmentStatement(moduleElement, context); + return; + } + } + }; + + PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + var containerSymbol = containerDecl.getSymbol(); + + return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); + }; + + PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { + if (ast.stringLiteral) { + this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + }; + + PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; + this.setTypeChecked(ast, context); + + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { + this.resolveAST(ast.moduleElements, false, context); + } + + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + this.validateVariableDeclarationGroups(containerDecl, context); + + if (ast.stringLiteral) { + if (TypeScript.isRelative(ast.stringLiteral.valueText())) { + this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); + } + } + + 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) { + this.checkThisCaptureVariableCollides(ast, true, context); + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { + if (term.kind() === 11 /* IdentifierName */) { + return true; + } else if (term.kind() === 121 /* QualifiedName */) { + var binex = term; + + if (binex.right.kind() === 11 /* IdentifierName */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { + if (!type.isGeneric()) { + return type; + } + + var typeParameters = type.getTypeArgumentsOrTypeParameters(); + + var typeParameterArgumentMap = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); + } + + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); + if (extendsClause) { + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + + if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + } + } + } + + 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()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); + var implementedType = this.resolveTypeReference(implementedTypeAST, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + + if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addImplementedType(implementedType); + } + } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + + this.typeCheckCallBacks.push(function (context) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + _this.resolveClassDeclaration(classOrInterface, context); + } else { + _this.resolveInterfaceDeclaration(classOrInterface, context); + } + }); + + return typeDeclSymbol; + } + + this.setSymbolForAST(name, typeDeclSymbol, context); + this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + 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); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + var parentConstructor = parentType ? parentType.getConstructorMethod() : null; + + if (parentConstructor) { + this.resolveDeclaredSymbol(parentConstructor, context); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + + if (!parentConstructSignatures.length) { + parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + parentConstructSignature.returnType = parentType; + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); + parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); + parentConstructSignatures = [parentConstructSignature]; + } + + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + 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); + } + + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + + if (parentConstructorSymbol) { + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + } + } + + this.resolveOtherDeclarations(classDeclAST, context); + } + + if (this.canTypeCheckAST(classDeclAST, context)) { + this.typeCheckClassDeclaration(classDeclAST, context); + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { + var _this = this; + 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); + }); + } + } + }; + + PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { + this.setTypeChecked(classDeclAST, context); + + var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + + this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); + this.resolveAST(classDeclAST.classElements, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); + this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + + if (!classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); + }; + + PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { + this.checkThisCaptureVariableCollides(classDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { + var callSignatures = typeSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], context); + } + + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], context); + } + + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], context); + } + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); + + if (interfaceDeclSymbol.isResolved) { + this.resolveOtherDeclarations(interfaceDeclAST, context); + + if (this.canTypeCheckAST(interfaceDeclAST, context)) { + this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { + this.setTypeChecked(interfaceDeclAST, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); + this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); + + 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) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + this.resolveDeclaredSymbol(symbol, context); + + var alias = symbol; + if (kind & 164 /* SomeContainer */) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & 58728795 /* SomeType */) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & 68147712 /* SomeValue */) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); + + return { + symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), + aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null + }; + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + var rhsName = identifier.valueText(); + if (rhsName.length === 0) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); + var containerSymbol = memberSymbol.symbol; + var valueSymbol = null; + var typeSymbol = null; + var aliasSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + aliasSymbol = memberSymbol.aliasSymbol; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + aliasSymbol = containerSymbol; + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); + valueSymbol = memberSymbol.symbol; + if (valueSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + } + + if (!typeSymbol) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + typeSymbol = memberSymbol.symbol; + if (typeSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); + return null; + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol, + aliasSymbol: aliasSymbol + }; + }; + + 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"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleContainer) { + moduleName = dottedNameAST.right.valueText(); + + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; + if (!moduleSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); + } + } + } else { + var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); + var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); + + if (text.length > 0) { + var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); + moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); + if (moduleSymbol) { + 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]); + } + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var moduleReference = importStatementAST.moduleReference; + + var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; + + 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); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); + if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { + var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); + var instanceSymbol = aliasedType.getInstanceSymbol(); + + 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 { + importDeclSymbol.setAssignedValueSymbol(valueSymbol); + } + } + } else { + aliasedType = this.getNewErrorTypeSymbol(); + } + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); + return null; + } + } + } + + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + var declPath = enclosingDecl.getParentPath(); + + aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); + + if (!aliasedType) { + var path = importStatementAST.moduleReference.stringLiteral.text(); + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); + aliasedType = this.getNewErrorTypeSymbol(); + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); + } + + importDeclSymbol.setResolved(); + + this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); + 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); + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { + var _this = this; + this.setTypeChecked(importStatementAST, context); + + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (this.compilationSettings.noResolve()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); + } + + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + if (enclosingDecl.kind === 32 /* DynamicModule */) { + 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)); + } + } + } + } + + var checkPrivacy; + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind === 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + + 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; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { + var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + } + + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); + }; + + PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { + 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); + } + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { + var id = exportAssignmentAST.identifier.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && parentSymbol.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + + var aliasSymbol = containerSymbol; + var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + parentSymbol.setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + parentSymbol.setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + parentSymbol.setExportAssignedContainerSymbol(containerSymbol); + } + + this.resolveDeclaredSymbol(valueSymbol, context); + this.resolveDeclaredSymbol(typeSymbol, context); + this.resolveDeclaredSymbol(containerSymbol, context); + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + var funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); + } + } + + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.setTypeChecked(funcDeclAST, context); + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeAnnotation) { + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + 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) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + 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 (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(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + var contextualType = contextParam && contextParam.type; + var isImplicitAny = false; + + if (typeExpr) { + var typeRef = this.resolveTypeReference(typeExpr, context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + typeRef = this.getNewErrorTypeSymbol(); + } + + contextualType = typeRef || contextualType; + } + if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } + context.setTypeInContext(paramSymbol, contextualType); + } 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.propagateContextualType(contextualType); + } + + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + } + + if (!initExprSymbol || !initExprSymbol.type) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); + + if (!contextualType) { + context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); + } + } else { + var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); + if (!contextualType) { + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); + isImplicitAny = initTypeSymbol !== paramSymbol.type; + } else { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); + } + } + } + } + } + + if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + isImplicitAny = true; + } + + if (isImplicitAny && this.compilationSettings.noImplicitAny()) { + var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); + if (functionExpressionName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); + } + } + + if (canTypeCheckAST) { + this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { + var compilerReservedName = getCompilerReservedName(name); + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; + + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; + + case 3 /* arguments */: + this.checkArgumentsCollides(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; + } + }; + + PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { + var enclosingAST = this.getASTForDecl(someFunctionDecl); + var nodeType = enclosingAST.kind(); + + 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); + } 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 */) { + var constructorDeclaration = enclosingAST; + 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 */) { + var functionExpression = enclosingAST; + return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); + } + + return false; + }; + + PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { + if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); + } + } + } + }; + + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + 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)); + } + } + } + } + }; + + PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { + var decl = this.semanticInfoChain.getDeclForAST(ast); + + if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + var nameText = name.valueText(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); + } + } + }; + + PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); + TypeScript.Debug.assert(interfaceDecl); + + var interfaceSymbol = interfaceDecl.getSymbol(); + TypeScript.Debug.assert(interfaceSymbol); + + if (objectType.typeMembers) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = objectType.typeMembers; + + for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { + memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); + memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (this.canTypeCheckAST(objectType, context)) { + this.typeCheckObjectTypeTypeReference(objectType, context); + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { + this.setTypeChecked(objectType, context); + var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); + var objectTypeSymbol = objectTypeDecl.getSymbol(); + + this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); + }; + + PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { + return this.resolveTypeReference(typeAnnotation.type, context); + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { + if (typeRef === null) { + return null; + } + + TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); + + var aliasType = null; + var type = this.computeTypeReferenceSymbol(typeRef, context); + + if (type.kind === 4 /* Container */) { + var container = type; + var instanceSymbol = container.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + if (aliasType) { + this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); + } + } + + if (type && !type.isError()) { + 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 { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); + } + } + } + + if (this.canTypeCheckAST(typeRef, context)) { + this.setTypeChecked(typeRef, context); + } + + 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 */: + return this.semanticInfoChain.anyTypeSymbol; + case 61 /* BooleanKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + case 67 /* NumberKeyword */: + return this.semanticInfoChain.numberTypeSymbol; + case 69 /* StringKeyword */: + return this.semanticInfoChain.stringTypeSymbol; + case 41 /* VoidKeyword */: + return this.semanticInfoChain.voidTypeSymbol; + } + + var typeDeclSymbol = null; + + if (term.kind() === 11 /* IdentifierName */) { + typeDeclSymbol = this.resolveTypeNameExpression(term, context); + } else if (term.kind() === 123 /* FunctionType */) { + var functionType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); + } else if (term.kind() === 125 /* ConstructorType */) { + var constructorType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); + } else if (term.kind() === 122 /* ObjectType */) { + typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); + } else if (term.kind() === 126 /* GenericType */) { + typeDeclSymbol = this.resolveGenericTypeReference(term, context); + } else if (term.kind() === 121 /* QualifiedName */) { + typeDeclSymbol = this.resolveQualifiedName(term, context); + } else if (term.kind() === 14 /* StringLiteral */) { + 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, enclosingDecl.semanticInfoChain); + typeDeclSymbol.addDeclaration(decl); + } else if (term.kind() === 127 /* TypeQuery */) { + var typeQuery = term; + + var typeQueryTerm = typeQuery.name; + + var valueSymbol = this.resolveAST(typeQueryTerm, false, context); + + if (valueSymbol && valueSymbol.isAlias()) { + if (valueSymbol.assignedValue()) { + valueSymbol = valueSymbol.assignedValue(); + } else { + var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(); + } + } else if (term.kind() === 124 /* ArrayType */) { + var arrayType = term; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); + } else { + throw TypeScript.Errors.invalidOperation("unknown type"); + } + + if (!typeDeclSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); + return this.getNewErrorTypeSymbol(); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { + 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveParameterList = function (list, context) { + return this.resolveSeparatedList(list.parameters, context); + }; + + PullTypeResolver.prototype.resolveParameter = function (parameter, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { + var enumDeclaration = enumElement.parent.parent; + var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); + var symbol = decl.getSymbol(); + this.resolveDeclaredSymbol(symbol, context); + + return symbol; + }; + + PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { + if (this.canTypeCheckAST(clause, context)) { + this.setTypeChecked(clause, context); + } + + return this.resolveAST(clause.value, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + } else { + if (declSymbol.inResolution) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + + if (!declSymbol.type || !declSymbol.type.isError()) { + declSymbol.startResolving(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + if (!hasTypeExpr) { + this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + } + + if (!(hasTypeExpr || init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { + defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + } + } + + if (this.canTypeCheckAST(varDeclOrParameter, context)) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); + } + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (varDeclOrParameter.kind() === 243 /* EnumElement */) { + var result = this.getEnumTypeSymbol(varDeclOrParameter, context); + declSymbol.type = result; + return result; + } + + if (!typeExpr) { + return null; + } + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var typeExprSymbol = this.resolveTypeReference(typeExpr, context); + + if (!typeExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + declSymbol.type = this.getNewErrorTypeSymbol(); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = typeExprSymbol.getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } 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(); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + } + + return typeExprSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { + if (!init) { + return null; + } + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + if (typeExprSymbol) { + context.pushNewContextualType(typeExprSymbol); + } + + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); + + if (typeExprSymbol) { + context.popAnyContextualType(); + } + + if (!initExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + + if (!hasTypeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + var initTypeSymbol = initExprSymbol.type; + + if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); + context.setTypeInContext(declSymbol, widenedInitTypeSymbol); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny()) { + 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 initTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var _this = this; + this.setTypeChecked(varDeclOrParameter, context); + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + + if (hasTypeExpr || init) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = typeExprSymbol.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); + } + } + } + } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { + var wrapperDecl = this.getEnclosingDecl(decl); + 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])); + } else if (wrapperDecl.kind === 65536 /* Method */) { + var parentDecl = wrapperDecl.getParentDecl(); + + if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); + } 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 (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 */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } + } + } + + 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_only_allowed_in_implementation)); + } + } + 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 */)) { + this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); + } + }; + + PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { + return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; + }; + + PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { + var enclosingDecl = this.getEnclosingDeclForAST(superAST); + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); + + if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { + 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; + if (!block) { + return; + } + } + } + + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + if (parents.length) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); + } + } + }; + + PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { + if (isDeclaration) { + var decl = this.semanticInfoChain.getDeclForAST(_thisAST); + if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + return; + } + } + + var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + var declPath = enclosingDecl.getParentPath(); + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + continue; + } + + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); + } + break; + } + } + }; + + PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { + this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + 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) { + return; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + }; + + PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { + this.setTypeChecked(typeParameterAST, 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) { + if (this.canTypeCheckAST(constraint, context)) { + this.setTypeChecked(constraint, context); + } + + return this.resolveTypeReference(constraint.type, context); + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatementsExpressions = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, walker) { + var go = true; + + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); + go = false; + break; + + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, walker) { + switch (ast.kind()) { + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + if (block) { + TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + } else { + returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + } + + if (!returnStatementsExpressions.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnExpressions = []; + + for (var i = 0; i < returnStatementsExpressions.length; i++) { + var returnExpression = returnStatementsExpressions[i].expression; + if (returnExpression) { + var returnType = this.resolveAST(returnExpression, useContextualType, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { + this.setSymbolForAST(returnExpression.parent, returnType, context); + } + } + + returnExpressionSymbols.push(returnType); + returnExpressions.push(returnExpression); + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); + var returnType = bestCommonReturnType; + var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = returnType.widenedType(this, returnExpression, context); + signature.returnType = newReturnType; + + if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); + } + + if (this.compilationSettings.noImplicitAny()) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName === "") { + functionName = enclosingDecl.getFunctionExpressionName(); + } + + if (functionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } + + if (!functionSymbol.type && functionSymbol.isAccessor()) { + functionSymbol.type = signature.returnType; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { + var _this = this; + this.setTypeChecked(funcDeclAST, context); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { + var _this = this; + if (constructorDecl.block) { + var foundSuperCall = false; + var pre = function (ast, walker) { + if (_this.isSuperInvocationExpression(ast)) { + foundSuperCall = true; + walker.options.stopWalking = true; + } + }; + + TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); + return foundSuperCall; + } + + return false; + }; + + 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(parameters, false, context); + + this.resolveAST(block, false, context); + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + this.validateVariableDeclarationGroups(funcDecl, context); + + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); + + if (funcDecl.kind === 16384 /* Function */) { + this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); + } + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + this.resolveAST(funcDeclAST.parameter, false, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); + var stringIndexSignature = allIndexSignatures.stringSignature; + var numberIndexSignature = allIndexSignatures.numericSignature; + var isNumericIndexer = numberIndexSignature === signature; + + if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { + var comparisonInfo = new TypeComparisonInfo(); + + 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + } + } + } + + var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); + for (var i = 0; i < allMembers.length; i++) { + var member = allMembers[i]; + var name = member.name; + if (name || (member.kind === 4096 /* Property */ && name === "")) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], context); + } + + if (parentSymbol !== allMembers[i].getContainer()) { + var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); + var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; + var onlyStringIndexerIsPresent = !numberIndexSignature; + + if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { + var comparisonInfo = new TypeComparisonInfo(); + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); + } + } + } + } + } + }); + }; + + PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { + this.checkThisCaptureVariableCollides(funcDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { + var returnTypeSymbol = null; + + if (returnTypeAnnotation) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + } else { + var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } + + return returnTypeSymbol; + }; + + 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + return funcSymbol; + } + + if (!signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + 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(); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveIndexSignature(ast.indexSignature, context); + }; + + PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + return funcSymbol; + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.typeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.parameter) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + this.resolveParameter(funcDeclAST.parameter, context); + context.inTypeCheck = prevInTypeCheck; + } + + if (funcDeclAST.typeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + + context.inTypeCheck = prevInTypeCheck; + } + + if (returnTypeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { + if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { + 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; + if (funcDeclASTName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } + } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { + if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); + } + + return null; + }; + + 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.ASTHelpers.getType(parameter), context); + } + + return null; + }; + + PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + + if (accessorSymbol.inResolution) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + accessorSymbol.setResolved(); + + return accessorSymbol; + } + + if (accessorSymbol.isResolved) { + if (!accessorSymbol.type) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else { + var getterSymbol = accessorSymbol.getGetter(); + var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; + var hasGetter = getterSymbol !== null; + + var setterSymbol = accessorSymbol.getSetter(); + var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; + var hasSetter = setterSymbol !== null; + + var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); + var getterHasTypeAnnotation = getterAnnotatedType !== null; + + var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); + var setterHasTypeAnnotation = setterAnnotatedType !== null; + + accessorSymbol.startResolving(); + + if (hasGetter) { + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + } + + if (hasSetter) { + setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); + } + + if (hasGetter && hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + var getterSig = getterSymbol.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { + getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; + getterSig.returnType = setterSuppliedTypeSymbol; + } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { + setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; + + if (setterHasParameters) { + setterParameters[0].type = getterSuppliedTypeSymbol; + } + } + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + accessorSymbol.type = this.getNewErrorTypeSymbol(); + } else { + accessorSymbol.type = getterSuppliedTypeSymbol; + } + } else if (hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + + accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; + } else { + var getterSig = getterSymbol.type.getCallSignatures()[0]; + accessorSymbol.type = getterSig.returnType; + } + + accessorSymbol.setResolved(); + } + + if (this.canTypeCheckAST(funcDeclAst, context)) { + this.typeCheckAccessorDeclaration(funcDeclAst, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { + this.setTypeChecked(funcDeclAst, context); + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + var getterSymbol = accessorSymbol.getGetter(); + var setterSymbol = accessorSymbol.getSetter(); + + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; + if (isGetter) { + var getterFunctionDeclarationAst = funcDeclAst; + context.pushNewContextualType(getterSymbol.type); + this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); + context.popAnyContextualType(); + } else { + var setterFunctionDeclarationAst = funcDeclAst; + this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); + } + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return getterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return getterSymbol; + } + + signature.startResolving(); + + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + if (!setterAnnotatedType) { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } else { + signature.returnType = setterAnnotatedType; + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + return getterSymbol; + }; + + PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + if (getter && setter) { + var getterAST = getter.getDeclarations()[0].ast(); + var setterAST = setter.getDeclarations()[0].ast(); + + if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { + var setterSig = setter.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + + var getter = accessorSymbol.getGetter(); + var getterSig = getter.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterParameters[0].type; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + var funcNameAST = funcDeclAST.propertyName; + + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); + } + + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); + var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + 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.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; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return setterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + signature.setResolved(); + return setterSymbol; + } + + signature.startResolving(); + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + } + + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + + if (!hadError) { + signature.setResolved(); + } + } + + return setterSymbol; + }; + + PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + if (funcDeclAST.parameterList) { + for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + + var getter = accessorSymbol.getGetter(); + + var funcNameAST = funcDeclAST.propertyName; + + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); + var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + if (getterIsPrivate !== setterIsPrivate) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); + } + + this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); + } else { + if (this.compilationSettings.noImplicitAny()) { + var setterFunctionDeclarationAst = funcDeclAST; + 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + }; + + PullTypeResolver.prototype.resolveList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.childCount(); i < n; i++) { + this.resolveAST(list.childAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.resolveAST(list.nonSeparatorAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLogicalOperation(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { + this.setTypeChecked(binex, context); + + var leftType = this.resolveAST(binex.left, false, context).type; + var rightType = this.resolveAST(binex.right, false, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(binex); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ + TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), + leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); + } + }; + + PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.operand, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckUnaryArithmeticOperation(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckPostfixUnaryExpression(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { + return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); + }; + + PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + return; + } + + TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { + if (this.canTypeCheckAST(binaryExpression, context)) { + this.typeCheckBinaryArithmeticExpression(binaryExpression, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } + + if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } + + var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); + var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); + + if (!rhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!lhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (lhsIsFit && rhsIsFit) { + switch (binaryExpression.kind()) { + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + if (!this.isReference(binaryExpression.left, lhsSymbol)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); + } + } + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInstanceOfExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); + var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); + 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_of_a_type_assignable_to_the_Function_interface_type)); + } + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { + if (this.canTypeCheckAST(commaExpression, context)) { + this.setTypeChecked(commaExpression, context); + + this.resolveAST(commaExpression.left, false, context); + } + + return this.resolveAST(commaExpression.right, false, context).type; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; + + var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); + + if (!isValidLHS) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); + } + + if (!isValidRHS) { + 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)); + } + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.variableDeclaration, false, context); + this.resolveAST(ast.initializer, false, context); + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.incrementor, false, context); + this.resolveAST(ast.statement, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { + if (this.canTypeCheckAST(forInStatement, context)) { + this.typeCheckForInStatement(forInStatement, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { + this.setTypeChecked(forInStatement, context); + + if (forInStatement.variableDeclaration) { + var declaration = forInStatement.variableDeclaration; + + 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); + + 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 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)); + } + + this.resolveAST(forInStatement.statement, false, context); + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWhileStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckDoStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckIfStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + this.resolveAST(ast.elseClause, false, context); + }; + + PullTypeResolver.prototype.resolveElseClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckElseClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.statements, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declaration, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declarators, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWithStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var withStatement = ast; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckTryStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var tryStatement = ast; + + this.resolveAST(tryStatement.block, false, context); + this.resolveAST(tryStatement.catchClause, false, context); + this.resolveAST(tryStatement.finallyClause, false, context); + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckCatchClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + + var catchDecl = this.semanticInfoChain.getDeclForAST(ast); + this.validateVariableDeclarationGroups(catchDecl, context); + }; + + PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckFinallyClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + }; + + PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + while (enclosingDecl) { + if (enclosingDecl.kind & 1032192 /* SomeFunction */) { + return enclosingDecl; + } + + enclosingDecl = enclosingDecl.getParentDecl(); + } + + return null; + }; + + PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var isContextuallyTyped = false; + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); + if (returnTypeAnnotationSymbol) { + isContextuallyTyped = true; + context.pushNewContextualType(returnTypeAnnotationSymbol); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + isContextuallyTyped = true; + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); + } + } + } + } + + var result = this.resolveAST(expression, isContextuallyTyped, context).type; + if (isContextuallyTyped) { + context.popAnyContextualType(); + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { + if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingFunction.getParentDecl(); + if (classDecl) { + var classSymbol = classDecl.getSymbol(); + this.resolveDeclaredSymbol(classSymbol, context); + + var comparisonInfo = new TypeComparisonInfo(); + var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); + if (!isAssignable) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); + } + } + } + + if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); + } + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { + var signatureSymbol = enclosingFunction.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (expressionType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + this.resolveDeclaredSymbol(expressionType, context); + this.resolveDeclaredSymbol(sigReturnType, context); + + var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); + } + } + } + } + } + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { + var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var returnType = this.getSymbolForAST(returnAST, context); + var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); + if (!returnType || canTypeCheckAST) { + var returnExpr = returnAST.expression; + + var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); + + if (!returnType) { + returnType = resolvedReturnType; + this.setSymbolForAST(returnAST, resolvedReturnType, context); + } + + if (returnExpr && canTypeCheckAST) { + this.setTypeChecked(returnExpr, context); + this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSwitchStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var expressionType = this.resolveAST(ast.expression, false, context).type; + + for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { + var switchClause = ast.switchClauses.childAt(i); + if (switchClause.kind() === 233 /* CaseSwitchClause */) { + var caseSwitchClause = switchClause; + + var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; + this.resolveAST(caseSwitchClause.statements, false, context); + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); + } + } + } else { + var defaultSwitchClause = switchClause; + this.resolveAST(defaultSwitchClause.statements, false, context); + } + } + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLabeledStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var labelIdentifier = ast.identifier.valueText(); + + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + 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); + }; + + PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { + switch (statement.kind()) { + case 160 /* LabeledStatement */: + return this.labelIsOnContinuableConstruct(statement.statement); + + case 158 /* WhileStatement */: + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 161 /* DoStatement */: + return true; + + default: + return false; + } + }; + + PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckContinueStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.isIterationStatement = function (ast) { + switch (ast.kind()) { + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 158 /* WhileStatement */: + case 161 /* DoStatement */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { + switch (ast.kind()) { + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 129 /* FunctionDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 241 /* FunctionPropertyAssignment */: + case 137 /* ConstructorDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.inSwitchStatement = function (ast) { + while (ast) { + if (ast.kind() === 151 /* SwitchStatement */) { + return true; + } + + if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { + while (ast) { + if (this.isIterationStatement(ast)) { + return true; + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { + var result = []; + + ast = ast.parent; + while (ast) { + if (ast.kind() === 160 /* LabeledStatement */) { + var labeledStatement = ast; + if (breakable) { + result.push(labeledStatement); + } else { + if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { + result.push(labeledStatement); + } + } + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + break; + } + + ast = ast.parent; + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + 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.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var continuableLabels = this.getEnclosingLabels(ast, false, true); + + 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)); + } + } + } + }; + + PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckBreakStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + if (ast.identifier) { + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var breakableLabels = this.getEnclosingLabels(ast, true, true); + 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, 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)); + } + } + }; + + PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { + if (!ast) { + return; + } + + var symbol = this.getSymbolForAST(ast, context); + if (symbol && symbol.isResolved) { + this.typeCheckAST(ast, isContextuallyTyped, context); + return symbol; + } + + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + + var nodeType = ast.kind(); + + switch (nodeType) { + case 124 /* ArrayType */: + case 126 /* GenericType */: + case 122 /* ObjectType */: + case 127 /* TypeQuery */: + case 125 /* ConstructorType */: + case 123 /* FunctionType */: + return this.resolveTypeReference(ast, context); + + case 1 /* List */: + return this.resolveList(ast, context); + + case 2 /* SeparatedList */: + return this.resolveSeparatedList(ast, context); + + case 120 /* SourceUnit */: + return this.resolveSourceUnit(ast, context); + + case 132 /* EnumDeclaration */: + return this.resolveEnumDeclaration(ast, context); + + case 130 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 128 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 131 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 224 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, context); + + case 136 /* MemberVariableDeclaration */: + return this.resolveMemberVariableDeclaration(ast, context); + + case 225 /* VariableDeclarator */: + return this.resolveVariableDeclarator(ast, context); + + case 141 /* PropertySignature */: + return this.resolvePropertySignature(ast, context); + + case 227 /* ParameterList */: + return this.resolveParameterList(ast, context); + + case 242 /* Parameter */: + return this.resolveParameter(ast, context); + + case 243 /* EnumElement */: + return this.resolveEnumElement(ast, context); + + case 232 /* EqualsValueClause */: + return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); + + case 238 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 239 /* Constraint */: + return this.resolveConstraint(ast, context); + + case 133 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 240 /* SimplePropertyAssignment */: + return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); + + case 241 /* FunctionPropertyAssignment */: + return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); + + case 121 /* QualifiedName */: + return this.resolveQualifiedName(ast, context); + + case 137 /* ConstructorDeclaration */: + return this.resolveConstructorDeclaration(ast, context); + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return this.resolveAccessorDeclaration(ast, context); + + case 138 /* IndexMemberDeclaration */: + return this.resolveIndexMemberDeclaration(ast, context); + + case 144 /* IndexSignature */: + return this.resolveIndexSignature(ast, context); + + case 135 /* MemberFunctionDeclaration */: + return this.resolveMemberFunctionDeclaration(ast, context); + + case 142 /* CallSignature */: + return this.resolveCallSignature(ast, context); + + case 143 /* ConstructSignature */: + return this.resolveConstructSignature(ast, context); + + case 145 /* MethodSignature */: + return this.resolveMethodSignature(ast, context); + + 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); + + case 219 /* SimpleArrowFunctionExpression */: + return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 214 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + + case 35 /* ThisKeyword */: + return this.resolveThisExpression(ast, context); + + case 50 /* SuperKeyword */: + return this.resolveSuperExpression(ast, context); + + case 213 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, context); + + case 216 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, context); + + case 220 /* CastExpression */: + return this.resolveCastExpression(ast, context); + + case 13 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + + case 14 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + + case 32 /* NullKeyword */: + return this.semanticInfoChain.nullTypeSymbol; + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + + case 172 /* VoidExpression */: + return this.resolveVoidExpression(ast, context); + + case 174 /* AssignmentExpression */: + return this.resolveAssignmentExpression(ast, context); + + case 167 /* LogicalNotExpression */: + return this.resolveLogicalNotExpression(ast, context); + + case 193 /* NotEqualsWithTypeConversionExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 197 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, context); + + case 208 /* AddExpression */: + case 175 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, context); + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, context); + + case 210 /* PostIncrementExpression */: + case 211 /* PostDecrementExpression */: + return this.resolvePostfixUnaryExpression(ast, context); + + case 209 /* SubtractExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 189 /* BitwiseOrExpression */: + case 191 /* BitwiseAndExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, context); + + case 221 /* ElementAccessExpression */: + return this.resolveElementAccessExpression(ast, context); + + case 187 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); + + case 188 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, context); + + case 171 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, context); + + case 170 /* DeleteExpression */: + return this.resolveDeleteExpression(ast, context); + + case 186 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, isContextuallyTyped, context); + + case 12 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 217 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, context); + + case 200 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, context); + + case 173 /* CommaExpression */: + return this.resolveCommaExpression(ast, context); + + case 201 /* InExpression */: + return this.resolveInExpression(ast, context); + + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; + } + + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); + }; + + PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { + if (!this.canTypeCheckAST(ast, context)) { + return; + } + + var nodeType = ast.kind(); + switch (nodeType) { + case 120 /* SourceUnit */: + this.typeCheckSourceUnit(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.typeCheckEnumDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.typeCheckModuleDeclaration(ast, context); + return; + + case 128 /* InterfaceDeclaration */: + this.typeCheckInterfaceDeclaration(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.typeCheckClassDeclaration(ast, context); + return; + + case 243 /* EnumElement */: + this.typeCheckEnumElement(ast, context); + return; + + case 136 /* MemberVariableDeclaration */: + this.typeCheckMemberVariableDeclaration(ast, context); + return; + + case 225 /* VariableDeclarator */: + this.typeCheckVariableDeclarator(ast, context); + return; + + case 141 /* PropertySignature */: + this.typeCheckPropertySignature(ast, context); + return; + + case 242 /* Parameter */: + this.typeCheckParameter(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.typeCheckImportDeclaration(ast, context); + return; + + case 215 /* ObjectLiteralExpression */: + this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 241 /* FunctionPropertyAssignment */: + this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); + return; + + case 11 /* IdentifierName */: + if (isTypesOnlyLocation(ast)) { + this.resolveTypeNameExpression(ast, context); + } else { + this.resolveNameExpression(ast, context); + } + return; + + case 212 /* MemberAccessExpression */: + this.resolveMemberAccessExpression(ast, context); + return; + + case 121 /* QualifiedName */: + this.resolveQualifiedName(ast, context); + return; + + case 222 /* FunctionExpression */: + 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); + break; + + case 142 /* CallSignature */: + this.typeCheckCallSignature(ast, context); + return; + + case 143 /* ConstructSignature */: + this.typeCheckConstructSignature(ast, context); + return; + + case 129 /* FunctionDeclaration */: { + var funcDecl = ast; + 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, isContextuallyTyped, context); + return; + + case 218 /* ParenthesizedArrowFunctionExpression */: + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 214 /* ArrayLiteralExpression */: + this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 213 /* InvocationExpression */: + this.typeCheckInvocationExpression(ast, context); + return; + + case 216 /* ObjectCreationExpression */: + this.typeCheckObjectCreationExpression(ast, context); + return; + + case 150 /* ReturnStatement */: + this.resolveReturnStatement(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); + } + }; + + PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { + while (this.postTypeCheckWorkitems.length) { + var ast = this.postTypeCheckWorkitems.pop(); + this.postTypeCheck(ast, context); + } + }; + + PullTypeResolver.prototype.postTypeCheck = function (ast, context) { + var nodeType = ast.kind(); + + switch (nodeType) { + case 242 /* Parameter */: + case 225 /* VariableDeclarator */: + this.postTypeCheckVariableDeclaratorOrParameter(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.postTypeCheckClassDeclaration(ast, context); + return; + + case 129 /* FunctionDeclaration */: + this.postTypeCheckFunctionDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.postTypeCheckModuleDeclaration(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.postTypeCheckEnumDeclaration(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.postTypeCheckImportDeclaration(ast, context); + return; + + case 11 /* IdentifierName */: + this.postTypeCheckNameExpression(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); + } + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { + this.checkThisCaptureVariableCollides(nameAST, false, context); + }; + + PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { + this.setTypeChecked(nameAST, context); + this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { + var nameSymbol = this.getSymbolForAST(nameAST, context); + var foundCached = nameSymbol !== null; + + if (!foundCached || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.typeCheckNameExpression(nameAST, context); + } + nameSymbol = this.computeNameExpression(nameAST, context); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + 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.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; + } + + var nameSymbol = null; + var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); + } + + 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) { + 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]; + var nameParentDecl = nameDeclaration.getParentDecl(); + if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { + var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); + var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); + + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); + + if (currentParameterIndex >= 0) { + var matchingParameter; + if (parameterList) { + for (var i = 0; i <= currentParameterIndex; i++) { + var candidateParameter = parameterList.parameters.nonSeparatorAt(i); + if (candidateParameter && candidateParameter.identifier.valueText() === id) { + matchingParameter = candidateParameter; + break; + } + } + } + + 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); + } + } + } + + var aliasSymbol = null; + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + if (!this.inTypeQuery(nameAST)) { + aliasSymbol.setIsUsedAsValue(); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); + + var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); + if (parameterList) { + while (parameter && parameter.parent) { + if (parameter.parent.parent === parameterList) { + return parameterList.parameters.nonSeparatorIndexOf(parameter); + } + + parameter = parameter.parent; + } + } + + return -1; + }; + + PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { + var symbol = this.getSymbolForAST(dottedNameAST, context); + var foundCached = symbol !== null; + + if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheckDottedNameAST) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); + } + + this.resolveDeclaredSymbol(symbol, context); + + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(name, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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)) { + lhsAlias.setIsUsedAsValue(); + } + lhsType = lhsAlias.getExportAssignedTypeSymbol(); + } + + if (lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); + return this.getNewErrorTypeSymbol(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); + + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { + var instanceSymbol = lhsType.getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); + + if (!nameSymbol) { + if (lhsType.kind === 32 /* DynamicModule */) { + var container = lhsType; + var associatedInstance = container.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); + } + } + + 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + } + + if (checkSuperPrivateAndStaticAccess) { + this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST, context); + + if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.setTypeChecked(nameAST, context); + } + typeNameSymbol = this.computeTypeNameExpression(nameAST, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + this.resolveDeclaredSymbol(typeNameSymbol, context); + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { + var id = nameAST.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(nameAST); + + var declPath = enclosingDecl.getParentPath(); + + var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); + + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + this.resolveDeclaredSymbol(typeNameSymbol, context); + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + this.resolveDeclaredSymbol(aliasedType, context); + } + + if (typeNameSymbol.isTypeParameter()) { + if (this.isInStaticMemberContext(enclosingDecl)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); + return this.getNewErrorTypeSymbol(); + } + } + } + + if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { + typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); + } + + 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; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, context); + } + + 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()) { + for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + + if (typeArgs[i].isError()) { + typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + } + + 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(); + } + + if (!genericTypeSymbol.isResolved) { + var typeDecls = genericTypeSymbol.getDeclarations(); + var childDecls = null; + + for (var i = 0; i < typeDecls.length; i++) { + childDecls = typeDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + + var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); + + var typeConstraint = null; + var upperBound = null; + + typeParameters = specializedSymbol.getTypeParameters(); + + var typeConstraintSubstitutionMap = []; + var typeArg = null; + + var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < typeParameters.length; i++) { + typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + for (var id in instantiatedSubstitutionMap) { + typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; + } + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] === typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } else if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); + } + + if (typeArg.isTypeParameter()) { + upperBound = typeArg.getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + 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)])); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { + if (this.inTypeQuery(dottedNameAST)) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; + } + + var symbol = this.getSymbolForAST(dottedNameAST, context); + if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheck) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeQualifiedName(dottedNameAST, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + this.resolveDeclaredSymbol(symbol, context); + + 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) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); + var lhs = this.resolveAST(dottedNameAST.left, false, context); + + var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; + + if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { + if (lhs.isAlias()) { + lhs.setIsUsedAsValue(); + } + } + + if (!lhsType) { + return this.getNewErrorTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); + var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; + + 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & 164 /* SomeContainer */) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { + if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { + return false; + } + + if (returnTypeAnnotation) { + return false; + } + + if (parameters) { + for (var i = 0, n = parameters.length; i < n; i++) { + if (parameters.typeAt(i)) { + return false; + } + } + } + + var contextualFunctionTypeSymbol = context.getContextualType(); + + if (contextualFunctionTypeSymbol) { + this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); + var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; + if (!exactlyOneCallSignature) { + return false; + } + + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; + return !callSignatureIsGeneric; + } + + return false; + }; + + PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { + var funcDeclSymbol = null; + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { + return funcDeclSymbol; + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + TypeScript.Debug.assert(funcDeclSymbol); + + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.propagateContextualType(returnType); + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); + context.popAnyContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + var functionExpressionName = functionDecl.getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); + } + } + + context.setTypeInContext(funcDeclSymbol, funcDeclType); + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); + } + + return funcDeclSymbol; + }; + + 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + var returnTypeSymbol = signature.returnType; + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + 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.popAnyContextualType(); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); + + this.validateVariableDeclarationGroups(functionDecl, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { + var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); + var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; + + if (this.canTypeCheckAST(thisExpression, context)) { + this.typeCheckThisExpression(thisExpression, context, enclosingDecl); + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.inTypeArgumentList = function (ast) { + var previous = null; + var current = ast; + + while (current) { + switch (current.kind()) { + case 126 /* GenericType */: + var genericType = current; + if (genericType.typeArgumentList === previous) { + return true; + } + break; + + case 226 /* ArgumentList */: + var argumentList = current; + return argumentList.typeArgumentList === previous; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { + while (ast) { + switch (ast.kind()) { + case 230 /* ExtendsHeritageClause */: + var heritageClause = ast; + + return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inTypeQuery = function (ast) { + while (ast) { + switch (ast.kind()) { + case 127 /* TypeQuery */: + return true; + case 129 /* FunctionDeclaration */: + case 213 /* InvocationExpression */: + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 213 /* InvocationExpression */: + var invocationExpression = current; + if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + break; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inConstructorParameterList = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } + + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + 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 */) { + return true; + } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { + this.checkForThisCaptureInArrowFunction(thisExpression); + + if (this.inConstructorParameterList(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); + return; + } + + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { + return; + } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + if (currentDecl.getParentDecl() === null) { + return; + } else { + 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)); + } + + return; + } else if (currentDecl.kind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); + } + + return; + } + } + }; + + PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var isStaticContext = false; + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + return null; + } else if (declKind === 16384 /* Function */) { + return null; + } else if (declKind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(ast)) { + return this.getNewErrorTypeSymbol(); + } else { + var classSymbol = decl.getSymbol(); + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + return constructorSymbol.type; + } else { + return classSymbol; + } + } + } + } + } + + return null; + }; + + PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { + return true; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + var superType = this.semanticInfoChain.anyTypeSymbol; + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); + + if (classSymbol) { + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSuperExpression(ast, context, enclosingDecl); + } + + return superType; + }; + + PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { + this.setTypeChecked(ast, context); + + this.checkForThisCaptureInArrowFunction(ast); + + var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; + var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; + TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); + + if (isSuperPropertyAccess) { + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + break; + } else if (currentDecl.kind === 8 /* Class */) { + if (!this.enclosingClassIsDerived(currentDecl)) { + 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 if (this.inStaticMemberVariableDeclaration(ast)) { + break; + } + + 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; + } + + return; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); + } + }; + + PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { + return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (this.canTypeCheckAST(expressionAST, context)) { + this.setTypeChecked(expressionAST, context); + } + symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { + var boundMemberSymbols = []; + var memberSymbol; + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var id = this.getPropertyAssignmentName(propertyAssignment); + var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); + + var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; + var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); + TypeScript.Debug.assert(decl); + + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + if (!isUsingExistingSymbol) { + memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } else { + memberSymbol = decl.getSymbol(); + } + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + memberSymbol = decl.getSymbol(); + } else { + TypeScript.Debug.assert(isAccessor); + memberSymbol = decl.getSymbol(); + } + + if (!isUsingExistingSymbol && !isAccessor) { + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); + } + + objectLiteralTypeSymbol.addMember(memberSymbol); + } + + boundMemberSymbols.push(memberSymbol); + } + + return boundMemberSymbols; + }; + + PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var acceptedContextualType = false; + var assigningSymbol = null; + + var id = this.getPropertyAssignmentName(propertyAssignment); + var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; + + if (objectLiteralContextualType) { + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + + if (!assigningSymbol) { + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + assigningSymbol = numericIndexerSignature; + } else if (stringIndexerSignature) { + assigningSymbol = stringIndexerSignature; + } + } + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); + + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = contextualMemberType; + } + } + } + + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; + + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { + objectLiteralTypeSymbol.setHasGenericMember(); + } + + if (stringIndexerSignature) { + allMemberTypes.push(memberSymbolType); + } + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + allNumericMemberTypes.push(memberSymbolType); + } + } + + if (acceptedContextualType) { + pullTypeContext.popAnyContextualType(); + } + + var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; + if (!memberSymbol.isResolved) { + if (isAccessor) { + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); + } else { + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); + memberSymbol.setResolved(); + + this.setSymbolForAST(id, memberSymbol, pullTypeContext); + } + } + } + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { + var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); + TypeScript.Debug.assert(objectLitDecl); + + var typeSymbol = this.getSymbolForAST(objectLitAST, context); + var isUsingExistingSymbol = !!typeSymbol; + + if (!typeSymbol) { + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); + typeSymbol.addDeclaration(objectLitDecl); + this.setSymbolForAST(objectLitAST, typeSymbol, context); + objectLitDecl.setSymbol(typeSymbol); + } + + var propertyAssignments = objectLitAST.propertyAssignments; + var contextualType = null; + + if (isContextuallyTyped) { + contextualType = context.getContextualType(); + this.resolveDeclaredSymbol(contextualType, context); + } + + var stringIndexerSignature = null; + var numericIndexerSignature = null; + var allMemberTypes = null; + var allNumericMemberTypes = null; + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + + stringIndexerSignature = indexSignatures.stringSignature; + numericIndexerSignature = indexSignatures.numericSignature; + + var inInferentialTyping = context.isInferentiallyTyping(); + if (stringIndexerSignature) { + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; + } + + if (numericIndexerSignature) { + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; + } + } + + if (propertyAssignments) { + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); + + this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); + + if (!isUsingExistingSymbol) { + this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); + this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { + return propertyAssignment.propertyName; + } else { + TypeScript.Debug.assert(false); + } + }; + + PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { + if (contextualIndexSignature) { + var typeCollection = { + getLength: function () { + return indexerTypeCandidates.length; + }, + getTypeAtIndex: function (index) { + return indexerTypeCandidates[index]; + } + }; + var decl = objectLiteralSymbol.getDeclarations()[0]; + 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); + } + } + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { + var symbol = this.getSymbolForAST(arrayLit, context); + if (!symbol || this.canTypeCheckAST(arrayLit, context)) { + if (this.canTypeCheckAST(arrayLit, context)) { + this.setTypeChecked(arrayLit, context); + } + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { + var elements = arrayLit.expressions; + var elementType = null; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, context); + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + if (indexSignatures.numericSignature) { + contextualElementType = indexSignatures.numericSignature.returnType; + } + } + } + + if (elements) { + if (contextualElementType) { + context.propagateContextualType(contextualElementType); + } + + for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { + elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); + } + + if (contextualElementType) { + context.popAnyContextualType(); + } + } + + if (elementTypes.length) { + elementType = elementTypes[0]; + } + var collection; + + if (contextualElementType && !context.isInferentiallyTyping()) { + if (!elementType) { + elementType = contextualElementType; + } + + collection = { + getLength: function () { + return elements.nonSeparatorCount() + 1; + }, + getTypeAtIndex: function (index) { + return index === 0 ? contextualElementType : elementTypes[index - 1]; + } + }; + } else { + collection = { + getLength: function () { + return elements.nonSeparatorCount(); + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + } + + elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; + + if (!elementType) { + elementType = this.semanticInfoChain.undefinedTypeSymbol; + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { + var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); + + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); + } + + return symbolAndDiagnostic.symbol; + }; + + PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { + this.setTypeChecked(callEx, context); + context.postDiagnostic(symbolAndDiagnostic.diagnostic); + }; + + PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; + + var targetTypeSymbol = targetSymbol.type; + + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return { symbol: targetTypeSymbol }; + } + + var elementType = targetTypeSymbol.getElementType(); + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return { symbol: elementType }; + } + + 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); + + if (member) { + this.resolveDeclaredSymbol(member, context); + + return { symbol: member.type }; + } + } + + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); + + var stringSignature = signatures.stringSignature; + var numberSignature = signatures.numericSignature; + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; + } 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 { + symbol: this.getNewErrorTypeSymbol(), + diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) + }; + } + }; + + 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; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + if (!signature.isResolved) { + this.resolveDeclaredSymbol(signature, context); + } + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signature; + continue; + } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { + numberSignature = signature; + continue; + } + } + } + + return { + numericSignature: numberSignature, + stringSignature: stringSignature + }; + }; + + 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; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } + + 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 { + lhsType = rhsType; + } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (exprType) { + if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { + if (!this.isReference(binaryExpression.left, lhsExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, exprType, lhsType, context); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); + } + } + + if (!exprType) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { + return this.findBestCommonType({ + getLength: function () { + return 2; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + } + } + }, context); + }; + + PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { + return this.findBestCommonType({ + getLength: function () { + return 3; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + case 2: + return type3; + } + } + }, context); + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + } + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; + var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; + + 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.pushNewContextualType(leftType); + var rightType = this.resolveAST(binex.right, true, context).type; + context.popAnyContextualType(); + + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + + this.resolveAST(binex.left, false, context); + } + + return this.resolveAST(binex.right, false, context).type; + }; + + PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { + var contextualType = context.getContextualType(); + return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + } else { + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { + var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; + var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; + + var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); + + var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); + + if (this.canTypeCheckAST(trinex, context)) { + this.setTypeChecked(trinex, context); + this.resolveAST(trinex.condition, false, context); + + if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); + } + } + } + + if (!conditionalTypesAreValid) { + return this.getNewErrorTypeSymbol(); + } + + return expressionType; + }; + + PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { + return true; + } + } else { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveAST(ast.expression, false, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckInvocationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + var targetSymbol = this.resolveAST(callEx.expression, false, context); + + if (callEx.argumentList.arguments) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + + var len = callEx.argumentList.arguments.nonSeparatorCount(); + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); + return this.getNewErrorTypeSymbol(); + } + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.expression.kind() === 50 /* SuperKeyword */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + targetSymbol = targetTypeSymbol.getConstructorMethod(); + this.resolveDeclaredSymbol(targetSymbol, context); + targetTypeSymbol = targetSymbol.type; + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); + this.resolveAST(callEx.argumentList.arguments, false, context); + + return this.getNewErrorTypeSymbol(); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + 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 explicitTypeArgs = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + var triedToInferTypeArgs = false; + + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var beforeResolutionSignatures = signatures; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + + if (signatures[i].isGeneric() && typeParameters.length) { + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); + } + + 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, 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; + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + + var errorCondition = null; + if (!signatures.length) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (!couldNotFindGenericOverload) { + 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); + } + return this.semanticInfoChain.anyTypeSymbol; + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); + } else if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + } + + 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 (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; + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + this.setSymbolForAST(callEx, symbol, context); + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckObjectCreationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + this.resolveAST(callEx.expression, false, context); + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (callEx.argumentList) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + var len = callEx.argumentList.arguments.nonSeparatorCount(); + + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { + if (!context.inProvisionalResolution()) { + additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); + } + context.postDiagnostic(diagnostic); + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var explicitTypeArgs = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny()) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); + } + } + + if (constructSignatures.length) { + if (callEx.argumentList && callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var triedToInferTypeArgs; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric()) { + typeParameters = constructSignatures[i].getTypeParameters(); + + 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, explicitTypeArgs.length]); + continue; + } + } 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 { + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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(constructSignatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } else { + if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); + } else { + returnType = this.instantiateTypeToAny(returnType, context); + } + } + + if (usedCallSignaturesInstead) { + 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(); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList && callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); + + return this.getNewErrorTypeSymbol(); + }; + + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { + var typeReplacementMap = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters = signatureAToInstantiate.getTypeParameters(); + var typeConstraint = null; + + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; + var enclosingTypeParameterMap; + + if (functionTypeA) { + enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + if (functionTypeB) { + enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); + + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); + }; + + PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { + var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; + + if (this.canTypeCheckAST(assertionExpression, context)) { + this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); + } + + return typeAssertionType; + }; + + PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { + this.setTypeChecked(assertionExpression, context); + + context.pushNewContextualType(typeAssertionType); + var exprType = this.resolveAST(assertionExpression.expression, true, context).type; + context.popAnyContextualType(); + + this.resolveDeclaredSymbol(typeAssertionType, context); + this.resolveDeclaredSymbol(exprType, context); + + var comparisonInfo = new TypeComparisonInfo(); + + 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); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { + var leftExpr = this.resolveAST(binaryExpression.left, false, context); + var leftType = leftExpr.type; + + context.pushNewContextualType(leftType); + var rightType = this.resolveAST(binaryExpression.right, true, context).type; + context.popAnyContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (!this.isReference(binaryExpression.left, leftExpr)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } else { + this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); + } + } + + return rightType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { + var instanceTypeSymbol = typeToReturn.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.widenType = function (type, ast, context) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (type.isArrayNamedTypeReference()) { + 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(); + + for (var i = 0; i < len; i++) { + var candidateType = collection.getTypeAtIndex(i); + if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { + return candidateType; + } + } + + return this.semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { + for (var i = 0; i < collection.getLength(); i++) { + var otherType = collection.getTypeAtIndex(i); + if (candidateType === otherType) { + continue; + } + + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { + t1 = this.getSymbolForRelationshipCheck(t1); + t2 = this.getSymbolForRelationshipCheck(t2); + + if (t1 === t2) { + return true; + } + + if (t1 && t2) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); + } + } + + return this.typesAreIdentical(t1, t2, context); + }; + + 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); + + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; + } + + if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + 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(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return false; + } + } + + if (t1.isPrimitive() !== t2.isPrimitive()) { + return 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) { + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { + return false; + } + + return true; + }; + + 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; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length !== sg2.length) { + return false; + } + + 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; + } + } + + return true; + }; + + 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; + } + + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; + } + + 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) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0] === decls2[0]; + } + + return false; + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { + return true; + } + + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); + }; + + 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.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) { + if (symbol && symbol.isTypeReference()) { + return symbol.getReferencedTypeSymbol(); + } + + return symbol; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + source = this.getSymbolForRelationshipCheck(source); + target = this.getSymbolForRelationshipCheck(target); + + if (source === target) { + return true; + } + + if (source && target) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + } + } + + 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); + + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + var sourceApparentType = this.getApparentType(source); + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; + } + + if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + 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) { + return true; + } + + return false; + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return assignableTo; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.getIsSpecialized() && target.getIsSpecialized()) { + 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, true); + + for (var i = 0; i < sourceTypeArguments.length; i++) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { + break; + } + } + + if (i === sourceTypeArguments.length) { + return true; + } else { + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + } + } + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } + } else { + if (isComparingInstantiatedSignatures) { + target = target.getBaseConstraint(this.semanticInfoChain); + } else { + return this.typesAreIdentical(target, sourceApparentType, context); + } + } + } + + 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; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); + + this.resolveDeclaredSymbol(targetProp, context); + + var targetPropType = targetProp.type; + + 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); + + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + + 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var comparisonInfoTypeArgumentsCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); + } + 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_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_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, isRelatable); + return isRelatable; + }; + + 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)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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++) { + 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; + } + } + } + + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + }; + + 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 (comparisonInfo) { + var names = getNames(true); + var code; + if (targetPropIsPrivate) { + 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 { + 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; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (targetDecl !== sourceDecl) { + if (comparisonInfo) { + var names = getNames(true); + + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + 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; + } + } + + if (sourceProp.isOptional && !targetProp.isOptional) { + if (comparisonInfo) { + 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); + } + return false; + } + + this.resolveDeclaredSymbol(sourceProp, context); + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); + + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + var names = getNames(false); + if (comparisonInfoPropertyTypeCheck && 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 { + 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 isSourcePropertyRelatableToTargetProperty; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); + var targetStringSig = targetIndexSigs.stringSignature; + var targetNumberSig = targetIndexSigs.numericSignature; + + if (targetStringSig || targetNumberSig) { + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); + var sourceStringSig = sourceIndexSigs.stringSignature; + var sourceNumberSig = sourceIndexSigs.numericSignature; + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + 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++) { + var mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + var nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + 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; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + + return false; + } + + return true; + }; + + 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; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; + + 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, [targetParameters.length])); + } + return false; + } + + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; + } + + 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) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + + return false; + } + } + + 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 (!areParametersRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + } + + return areParametersRelatable; + }); + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { + var _this = this; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = application.argumentList ? application.argumentList.arguments : null; + + var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { + if (hasOverloads && signature.isDefinition()) { + return false; + } + + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { + return false; + } + + return _this.overloadHasCorrectArity(signature, args); + }); + + var firstAssignableButNotSupertypeSignature = null; + var firstAssignableWithProvisionalErrorsSignature = null; + + for (var i = 0; i < initialCandidates.length; i++) { + var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); + if (applicability === 3 /* Subtype */) { + return initialCandidates[i]; + } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { + firstAssignableButNotSupertypeSignature = initialCandidates[i]; + } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { + firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; + } + } + + if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { + return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; + } else { + var target = this.getCallTargetErrorSpanAST(application); + if (comparisonInfo.message) { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); + } else { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); + } + } + + return null; + }; + + PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { + return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; + }; + + PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { + if (args == null) { + return signature.nonOptionalParamCount === 0; + } + + var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); + if (numberOfArgs < signature.nonOptionalParamCount) { + return false; + } + if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { + if (args === null) { + return 3 /* Subtype */; + } + + var isInVarArg = false; + var parameters = signature.parameters; + var paramType = null; + + var overloadApplicability = 3 /* Subtype */; + + for (var i = 0; i < args.nonSeparatorCount(); i++) { + if (!isInVarArg) { + this.resolveDeclaredSymbol(parameters[i], context); + + if (parameters[i].isVarArg) { + paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); + isInVarArg = true; + } else { + paramType = parameters[i].type; + } + } + + var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); + + if (statusOfCurrentArgument === 0 /* NotAssignable */) { + return 0 /* NotAssignable */; + } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { + overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; + } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { + overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; + } + } + + return overloadApplicability; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType.isAny()) { + return 3 /* Subtype */; + } else if (paramType.isError()) { + return 1 /* AssignableButWithProvisionalErrors */; + } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrowFunction = arg; + 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.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.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 */) { + return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); + } else { + return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); + } + }; + + PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { + if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + 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.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveObjectLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType === this.cachedArrayInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveArrayLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + var argSym = this.resolveAST(arg, false, context); + + if (argSym.type.isAlias()) { + var aliasSym = argSym.type; + argSym = aliasSym.getExportAssignedTypeSymbol(); + } + + comparisonInfo.stringConstantVal = arg; + return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { + var tempComparisonInfo = new TypeComparisonInfo(); + tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; + if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { + return 3 /* Subtype */; + } + + if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { + return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; + } + + if (!comparisonInfo.message) { + var enclosingSymbol = this.getEnclosingSymbolForAST(arg); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); + } + + return 0 /* NotAssignable */; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); + + 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 (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 inferenceResultTypes; + }; + + PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { + var enclosingDecl = this.getEnclosingDeclForAST(args); + var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); + return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; + }; + + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { + if (expressionType && parameterType) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); + return; + } + } + this.relateTypeToTypeParameters(expressionType, parameterType, 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; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType.isTypeParameter()) { + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); + return; + } + + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { + return; + } + + 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.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) { + return; + } + + var expressionTypeTypeArguments = expressionType.getTypeArguments(); + var parameterTypeArguments = parameterType.getTypeArguments(); + + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { + for (var i = 0; i < expressionTypeTypeArguments.length; i++) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } + } + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { + var _this = this; + var expressionReturnType = expressionSignature.returnType; + var parameterReturnType = parameterSignature.returnType; + + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); + + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + if (objectMember) { + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); + } + } + + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); + + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; + } + + 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) { + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!typeParameters.length) { + return typeToSpecialize; + } + + var typeArguments = null; + + 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) { + typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var type = this.createInstantiatedType(typeToSpecialize, typeArguments); + + 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(); + + var resolver = semanticInfoChain.getResolver(); + var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); + + if (resolver.canTypeCheckAST(sourceUnit, context)) { + resolver.resolveAST(sourceUnit, false, context); + resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); + + while (resolver.typeCheckCallBacks.length) { + var callBack = resolver.typeCheckCallBacks.pop(); + callBack(context); + } + + resolver.processPostTypeCheckWorkItems(context); + } + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; + } + + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); + + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; + + 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) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + 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)); + } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); + } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + 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_assignable_to_any_non_specialized_signature)); + } + } + } else if (definitionSignature && definitionSignature !== signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { + var errorCode; + + 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; + } 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + var isNamedType = typeSymbol.isNamedTypeSymbol(); + + if (typeSymbol.isArrayNamedTypeReference()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); + return; + } + + if (!isNamedType) { + var typeOfSymbol = typeSymbol.getTypeOfSymbol(); + if (typeOfSymbol) { + this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); + return; + } + } + + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); + if (typars) { + for (var i = 0; i < typars.length; i++) { + this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); + } + } + + if (!isNamedType) { + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); + } + + typeSymbol.inSymbolPrivacyCheck = false; + + if (!isNamedType) { + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + 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]) { + 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(); + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } else if (symbol.kind === 128 /* TypeAlias */) { + var aliasSymbol = symbol; + symbolIsVisible = true; + aliasSymbol.setTypeUsedExternally(); + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); + } + }; + + 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; + var messageCode; + + var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; + } + } + + var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { + var typeSymbol = symbol; + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { + var _this = this; + if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; + var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; + var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); + var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); + this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { + return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); + }); + } + } + + if (!isGetter && !isIndexSignature) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var parameter = parameters.astAt(argIndex); + + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { + var _this = this; + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); + } + } + + if (block) { + var reportErrorOnReturnExpressions = function (ast, walker) { + var go = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { + TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); + + var classSymbol = classDecl.getSymbol(); + return classSymbol.getExtendedTypes().length > 0; + }; + + PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { + if (ast.kind() === 213 /* InvocationExpression */) { + var invocationExpression = ast; + if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { + if (node && node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + if (this.isSuperInvocationExpression(expressionStatement.expression)) { + return true; + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { + if (block && block.statements && block.statements.childCount() > 0) { + return block.statements.childAt(0); + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { + TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); + + if (constructorDecl) { + var enclosingClass = constructorDecl.getParentDecl(); + + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.kind() === 242 /* Parameter */) { + return true; + } + + if (ast.kind() === 136 /* MemberVariableDeclaration */) { + var variableDeclarator = ast; + if (variableDeclarator.variableDeclarator.equalsValueClause) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { + var enclosingDecl = this.getEnclosingDeclForAST(expression); + + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var inArrowFunction = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + inArrowFunction = true; + continue; + } + + if (inArrowFunction) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = decl.getSymbol().getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); + var stringSignature = indexSignatures.stringSignature; + var numberSignature = indexSignatures.numericSignature; + + if (stringSignature || numberSignature) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { + var memberSymbol = member.getSymbol(); + var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); + if (relevantSignature) { + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); + } + } + } + } + } + }; + + PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { + if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { + return numberIndexSignature; + } else if (stringIndexSignature) { + return stringIndexSignature; + } + + return null; + }; + + PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { + 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + var foundError1 = false; + var foundError2 = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName, true); + if (extendedTypeProp) { + this.resolveDeclaredSymbol(extendedTypeProp, context); + foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError1) { + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + } + + if (foundError1 || foundError2) { + foundError = true; + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); + } + + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + } + } + } + + if (foundError) { + var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); + + 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; + } + + if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + + if (associatedContainerType) { + return associatedContainerType !== typeSymbol.getRootSymbol(); + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + + var baseType = this.resolveTypeReference(baseDeclAST, context).type; + + if (!baseType) { + return; + } + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (!baseType.isError()) { + if (isExtendedType) { + if (typeDeclIsClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); + } + } + return; + } else if (typeDeclIsClass && isExtendedType) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + 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)])); + } + } + + if (baseType.hasBase(typeSymbol)) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); + return; + } + + if (isExtendedType) { + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); + } else { + TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); + + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { + var _this = this; + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); + if (!extendsClause && !implementsClause) { + return; + } + + if (extendsClause) { + for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (implementsClause) { + for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); + } + } + } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { + var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { + return decl.ast().heritageClauses !== null; + }).ast(); + if (classOrInterface === firstInterfaceASTWithExtendsClause) { + this.typeCheckCallBacks.push(function (context) { + _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); + }); + } + } + }; + + PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { + var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); + + var inheritedMembersMap = TypeScript.createIntrinsicsObject(); + var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); + + var typeHasOwnNumberIndexer = false; + var typeHasOwnStringIndexer = false; + + if (typeSymbol.hasOwnIndexSignatures()) { + var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); + for (var i = 0; i < ownIndexSignatures.length; i++) { + if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + typeHasOwnNumberIndexer = true; + } else { + typeHasOwnStringIndexer = true; + } + } + } + var baseTypes = typeSymbol.getExtendedTypes(); + for (var i = 0; i < baseTypes.length; i++) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + return; + } + } + + if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { + return; + } + + this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; + var memberName = member.name; + + if (interfaceSymbol.findMember(memberName, false)) { + continue; + } + + this.resolveDeclaredSymbol(member, context); + + if (inheritedMembersMap[memberName]) { + var prevMember = inheritedMembersMap[memberName]; + 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; + } + } else { + inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); + } + } + + return false; + }; + + PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { + if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { + return false; + } + + var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { + var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; + + var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; + 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, 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; + } + } else { + allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } else if (parameterTypeIsNumber) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin) { + 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; + } + } else { + allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { + if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; + var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; + for (var memberName in inheritedMembers) { + var memberWithBaseOrigin = inheritedMembers[memberName]; + if (!memberWithBaseOrigin) { + continue; + } + + var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); + if (!relevantSignature) { + continue; + } + + var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; + + if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { + continue; + } + + 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_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_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])); + } + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + 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_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, [ + interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), + inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.isReference = function (ast, astSymbol) { + if (ast.kind() === 217 /* ParenthesizedExpression */) { + return this.isReference(ast.expression, astSymbol); + } + + if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { + return false; + } + + if (ast.kind() === 11 /* IdentifierName */) { + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { + return false; + } + + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { + return false; + } + + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { + return false; + } + } + + if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { + if (resolvedName) { + if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { + return this.semanticInfoChain.getEnclosingDecl(ast); + }; + + PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + return enclosingDecl ? enclosingDecl.getSymbol() : null; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { + if (resolvedName) { + if (resolvedName.anyDeclHasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var memberClass = memberContainer.getDeclarations()[0].ast(); + TypeScript.Debug.assert(memberClass); + + var containingClass = this.getEnclosingClassDeclaration(name); + + if (!containingClass || containingClass !== memberClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { + if (type.isPrimitive()) { + return type; + } + + if (type.isError()) { + return type; + } + + if (typeParameterArgumentMap[type.pullSymbolID]) { + return typeParameterArgumentMap[type.pullSymbolID]; + } + + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); + } + + if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + } + + return type; + }; + + 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 rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); + + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); + + 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) { + for (var j = 0; j < parameters.length; j++) { + parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + instantiatedSignature.hasVarArgs = true; + } + instantiatedSignature.addParameter(parameter, parameter.isOptional); + + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); + } + } + + return instantiatedSignature; + }; + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; + + function getPropertyAssignmentNameTextFromIdentifier(identifier) { + if (identifier.kind() === 11 /* IdentifierName */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 14 /* StringLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 13 /* NumericLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; + + function isTypesOnlyLocation(ast) { + while (ast && ast.parent) { + switch (ast.parent.kind()) { + case 244 /* TypeAnnotation */: + return true; + case 127 /* TypeQuery */: + return false; + case 125 /* ConstructorType */: + var constructorType = ast.parent; + if (constructorType.type === ast) { + return true; + } + break; + case 123 /* FunctionType */: + var functionType = ast.parent; + if (functionType.type === ast) { + return true; + } + break; + case 239 /* Constraint */: + var constraint = ast.parent; + if (constraint.type === ast) { + return true; + } + break; + case 220 /* CastExpression */: + var castExpression = ast.parent; + return castExpression.type === ast; + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + return true; + case 228 /* TypeArgumentList */: + return true; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + case 129 /* FunctionDeclaration */: + case 145 /* MethodSignature */: + case 212 /* MemberAccessExpression */: + case 242 /* Parameter */: + return false; + } + + ast = ast.parent; + } + + return false; + } + TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfoChain = (function () { + function SemanticInfoChain(compiler, logger) { + this.compiler = compiler; + this.logger = logger; + this.documents = []; + this.fileNameToDocument = TypeScript.createIntrinsicsObject(); + this.anyTypeDecl = null; + this.booleanTypeDecl = null; + this.numberTypeDecl = null; + this.stringTypeDecl = null; + this.nullTypeDecl = null; + this.undefinedTypeDecl = null; + this.voidTypeDecl = null; + this.undefinedValueDecl = null; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + this.undefinedValueSymbol = null; + this.emptyTypeSymbol = null; + this.astSymbolMap = []; + this.astAliasSymbolMap = []; + this.astCallResolutionDataMap = []; + this.declSymbolMap = []; + this.declSignatureSymbolMap = []; + this.declCache = null; + this.symbolCache = null; + this.fileNameToDiagnostics = null; + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + 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); + 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 */, 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 || null; + }; + + SemanticInfoChain.prototype.lineMap = function (fileName) { + return this.getDocument(fileName).lineMap(); + }; + + SemanticInfoChain.prototype.fileNames = function () { + if (this._fileNames === null) { + this._fileNames = this.documents.slice(1).map(function (s) { + return s.fileName; + }); + } + + return this._fileNames; + }; + + SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { + newSymbol.addDeclaration(decl); + decl.setSymbol(newSymbol); + newSymbol.setResolved(); + + return newSymbol; + }; + + SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { + var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { + var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); + newSymbol.type = type; + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.resetGlobalSymbols = function () { + this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); + this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); + this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); + this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); + this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); + this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); + this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); + this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); + + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); + var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + emptyTypeDecl.setSymbol(emptyTypeSymbol); + emptyTypeSymbol.addDeclaration(emptyTypeDecl); + emptyTypeSymbol.setResolved(); + this.emptyTypeSymbol = emptyTypeSymbol; + }; + + SemanticInfoChain.prototype.addDocument = function (document) { + var fileName = document.fileName; + + var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (existingIndex < 0) { + this.documents.push(document); + } else { + this.documents[existingIndex] = document; + } + + this.fileNameToDocument[fileName] = document; + + this.invalidate(); + }; + + SemanticInfoChain.prototype.removeDocument = function (fileName) { + TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); + var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (index > 0) { + this.fileNameToDocument[fileName] = undefined; + this.documents.splice(index, 1); + this.invalidate(); + } + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[cacheID]; + + if (!symbol) { + for (var i = 0, n = this.documents.length; i < n; i++) { + var topLevelDecl = this.documents[i].topLevelDecl(); + + var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); + if (symbol) { + break; + } + + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { + return null; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { + var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; + + var foundDecls = topLevelDecl.searchChildDecls(name, kind); + + for (var j = 0; j < foundDecls.length; j++) { + var foundDecl = foundDecls[j]; + + if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { + break; + } + + var symbol = foundDecls[j].getSymbol(); + if (symbol) { + return symbol; + } + } + + return null; + }; + + SemanticInfoChain.prototype.findExternalModule = function (id) { + id = TypeScript.normalizePath(id); + + var tsFile = id + ".ts"; + var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); + symbol = this.symbolCache[tsCacheID]; + if (symbol != undefined) { + return symbol; + } + + 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 isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + symbol = dynamicModuleDecl.getSymbol(); + + 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 null; + }; + + SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { + var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); + + var symbol = this.symbolCache[cacheID]; + if (symbol == undefined) { + symbol = null; + for (var i = 0; i < this.documents.length; i++) { + var document = this.documents[i]; + var topLevelDecl = document.topLevelDecl(); + + if (!topLevelDecl.isExternalModule()) { + var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); + if (dynamicModules.length) { + symbol = dynamicModules[0].getSymbol(); + break; + } + } + } + + this.symbolCache[cacheID] = symbol; + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + var declsToSearch = this.topLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + + 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, kind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls === TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + 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; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + } + }; + + SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { + if (typeof oldSettings === "undefined") { oldSettings = null; } + if (typeof newSettings === "undefined") { newSettings = null; } + TypeScript.PullTypeResolver.globalTypeCheckPhase++; + + var cleanStart = new Date().getTime(); + + this.astSymbolMap.length = 0; + this.astAliasSymbolMap.length = 0; + this.astCallResolutionDataMap.length = 0; + + this.declCache = TypeScript.createIntrinsicsObject(); + this.symbolCache = TypeScript.createIntrinsicsObject(); + this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + + this.declSymbolMap.length = 0; + this.declSignatureSymbolMap.length = 0; + + if (oldSettings && newSettings) { + if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { + for (var i = 1, n = this.documents.length; i < n; i++) { + this.documents[i].invalidate(); + } + } + } + + TypeScript.pullSymbolID = 0; + + this.resetGlobalSymbols(); + + var cleanEnd = new Date().getTime(); + }; + + SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()] || null; + }; + + SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { + this.astAliasSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { + return this.astAliasSymbolMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { + return this.astCallResolutionDataMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; + } + }; + + SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { + this.declSymbolMap[decl.declID] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { + return this.declSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { + this.declSignatureSymbolMap[decl.declID] = signatureSymbol; + }; + + SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { + return this.declSignatureSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { + var fileName = diagnostic.fileName(); + var diagnostics = this.fileNameToDiagnostics[fileName]; + if (!diagnostics) { + diagnostics = []; + this.fileNameToDiagnostics[fileName] = diagnostics; + } + + diagnostics.push(diagnostic); + }; + + SemanticInfoChain.prototype.getDiagnostics = function (fileName) { + var diagnostics = this.fileNameToDiagnostics[fileName]; + return diagnostics || []; + }; + + SemanticInfoChain.prototype.getBinder = function () { + if (!this._binder) { + this._binder = new TypeScript.PullSymbolBinder(this); + } + + return this._binder; + }; + + SemanticInfoChain.prototype.getResolver = function () { + if (!this._resolver) { + this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); + } + + return this._resolver; + }; + + SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); + indexParameterSymbol.type = indexParamType; + indexSignature.addParameter(indexParameterSymbol); + indexSignature.returnType = returnType; + indexSignature.setResolved(); + indexParameterSymbol.setResolved(); + + containingSymbol.addIndexSignature(indexSignature); + + 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); + indexParameterSymbol.addDeclaration(indexParamDecl); + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast) { + var document = this.getDocument(ast.fileName()); + + if (document) { + return document._getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { + return this.getDocument(ast.fileName()).getEnclosingDecl(ast); + }; + + SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { + this.getDocument(decl.fileName())._setDeclForAST(ast, decl); + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var document = this.getDocument(decl.fileName()); + if (document) { + return document._getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { + this.getDocument(decl.fileName())._setASTForDecl(decl, ast); + }; + + SemanticInfoChain.prototype.topLevelDecl = function (fileName) { + var document = this.getDocument(fileName); + if (document) { + return document.topLevelDecl(); + } + + return null; + }; + + SemanticInfoChain.prototype.topLevelDecls = function () { + if (!this._topLevelDecls) { + this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { + return u.topLevelDecl(); + }); + } + + return this._topLevelDecls; + }; + + 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, 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; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { + this.document = document; + this.semanticInfoChain = semanticInfoChain; + this.propagateEnumConstants = propagateEnumConstants; + this.isDeclareFile = false; + this.parentChain = []; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + return DeclCollectionContext; + })(); + + function containingModuleHasExportAssignment(ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = ast; + return moduleDecl.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } else if (ast.kind() === 120 /* SourceUnit */) { + var sourceUnit = ast; + return sourceUnit.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } + + ast = ast.parent; + } + + return false; + } + + function isParsingAmbientModule(ast, context) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { + return true; + } + } + + ast = ast.parent; + } + + return false; + } + + function preCollectImportDecls(ast, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + + var parent = context.getParent(); + + if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { + declFlags |= 1 /* Exported */; + } + + 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 fileName = sourceUnit.fileName(); + + var isExternalModule = context.document.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); + + context.isDeclareFile = context.document.isDeclareFile(); + + context.pushParent(decl); + + if (isExternalModule) { + var declFlags = 1 /* Exported */; + if (TypeScript.isDTSFile(fileName)) { + declFlags |= 8 /* Ambient */; + } + + var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); + var kind = 32 /* DynamicModule */; + var valueText = TypeScript.quoteStr(fileName); + + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); + + context.semanticInfoChain.setASTForDecl(decl, sourceUnit); + + context.semanticInfoChain.setDeclForAST(sourceUnit, decl); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, sourceUnit, context); + } + + context.pushParent(decl); + } + } + + function preCollectEnumDecls(enumDecl, context) { + var declFlags = 0 /* None */; + var enumName = enumDecl.identifier.valueText(); + + if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + declFlags |= 4096 /* Enum */; + var kind = 64 /* Enum */; + + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); + context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); + context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); + + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); + enumDeclaration.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); + + context.pushParent(enumDeclaration); + } + + function createEnumElementDecls(propertyDecl, context) { + var parent = context.getParent(); + + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function preCollectModuleDecls(moduleDecl, context) { + var declFlags = 0 /* None */; + + var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); + + var isDynamic = moduleDecl.stringLiteral !== null; + + if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + + 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()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); + } + + context.pushParent(decl); + } else { + var moduleNames = getModuleNames(moduleDecl.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + var moduleName = moduleNames[i]; + + var specificFlags = declFlags; + if (i > 0) { + specificFlags |= 1 /* Exported */; + } + + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleName, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleName); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleName, context); + } + + context.pushParent(decl); + } + } + } + + function getModuleNames(name, result) { + result = result || []; + + if (name.kind() === 121 /* QualifiedName */) { + getModuleNames(name.left, result); + result.push(name.right); + } else { + result.push(name); + } + + return result; + } + TypeScript.getModuleNames = getModuleNames; + + 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.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); + } + + function containsExecutableCode(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); + + if (member.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = member; + + if (containsExecutableCode(moduleDecl.moduleElements)) { + return true; + } + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + } + + function preCollectClassDecls(classDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var parent = context.getParent(); + + 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); + + decl.setValueDecl(constructorDecl); + + context.semanticInfoChain.setDeclForAST(classDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, classDecl); + context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); + + context.pushParent(decl); + } + + function preCollectObjectTypeDecls(objectType, context) { + if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { + return; + } + + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setDeclForAST(objectType, decl); + context.semanticInfoChain.setASTForDecl(decl, objectType); + + context.pushParent(decl); + } + + function preCollectInterfaceDecls(interfaceDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { + declFlags |= 1 /* Exported */; + } + + var parent = context.getParent(); + + 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); + + context.pushParent(decl); + } + + function preCollectParameterDecl(argDecl, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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 */) { + decl.setFlag(67108864 /* ConstructorParameter */); + } + + var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); + var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; + if (isPublicOrPrivate && isInConstructor) { + var parentsParent = context.parentChain[context.parentChain.length - 2]; + + 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 */) { + propDecl.setFlag(67108864 /* ConstructorParameter */); + } + + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setASTForDecl(propDecl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, decl); + } + + parent.addVariableDeclToGroup(decl); + } + + function preCollectTypeParameterDecl(typeParameterDecl, context) { + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); + context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = 4096 /* Property */; + + if (propertyDecl.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var parent = context.getParent(); + + 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); + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 512 /* Variable */; + + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); + if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + 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); + context.semanticInfoChain.setDeclForAST(varDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, varDecl); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectVarDecls(ast, context) { + if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { + return; + } + + var varDecl = ast; + createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + 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); + context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); + + context.pushParent(decl); + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + 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); + context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); + + context.pushParent(decl); + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + 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); + context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); + + context.pushParent(decl); + } + + function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { + if (typeof displayName === "undefined") { displayName = null; } + var declFlags = 0 /* None */; + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { + declFlags |= 8192 /* ArrowFunction */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = id ? id.text() : ""; + var displayNameText = displayName ? displayName.text() : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); + context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); + + context.pushParent(decl); + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrow = functionExpressionDeclAST; + var declFlags = 4 /* Public */; + + var parent = context.getParent(); + + if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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); + + parent.addVariableDeclToGroup(decl); + } + } + + function createMemberFunctionDeclaration(funcDecl, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!funcDecl.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(funcDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDecl); + + context.pushParent(decl); + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 4194304 /* IndexSignature */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); + + context.pushParent(decl); + } + + function createCallSignatureDeclaration(callSignature, context) { + var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; + + if (!isChildOfObjectType) { + return; + } + + var declFlags = 2048 /* Signature */; + var declType = 1048576 /* CallSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(callSignature, decl); + context.semanticInfoChain.setASTForDecl(decl, callSignature); + + context.pushParent(decl); + } + + function createMethodSignatureDeclaration(method, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + declFlags |= 4 /* Public */; + declFlags |= 2048 /* Signature */; + + if (method.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(method, decl); + context.semanticInfoChain.setASTForDecl(decl, method); + + context.pushParent(decl); + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 2097152 /* ConstructSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); + + context.pushParent(decl); + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); + + context.pushParent(decl); + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); + + context.pushParent(decl); + } + + function createFunctionExpressionDeclaration(expression, context) { + createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); + + context.pushParent(decl); + } + + function preCollectCatchDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 268435456 /* CatchBlock */; + + 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); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + + var declFlags = 0 /* None */; + var declType = 1024 /* CatchVariable */; + + 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); + context.semanticInfoChain.setDeclForAST(ast.identifier, decl); + context.semanticInfoChain.setASTForDecl(decl, ast.identifier); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectWithDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 134217728 /* WithBlock */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectObjectLiteralDecls(ast, context) { + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); + + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectSimplePropertyAssignmentDecls(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()); + + context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); + } + + function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { + var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); + + 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); + + createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); + } + + function preCollectDecls(ast, context) { + switch (ast.kind()) { + case 120 /* SourceUnit */: + preCollectScriptDecls(ast, context); + break; + case 132 /* EnumDeclaration */: + preCollectEnumDecls(ast, context); + break; + case 243 /* EnumElement */: + createEnumElementDecls(ast, context); + break; + case 130 /* ModuleDeclaration */: + preCollectModuleDecls(ast, context); + break; + case 131 /* ClassDeclaration */: + preCollectClassDecls(ast, context); + break; + case 128 /* InterfaceDeclaration */: + preCollectInterfaceDecls(ast, context); + break; + case 122 /* ObjectType */: + preCollectObjectTypeDecls(ast, context); + break; + case 242 /* Parameter */: + preCollectParameterDecl(ast, context); + break; + case 136 /* MemberVariableDeclaration */: + createMemberVariableDeclaration(ast, context); + break; + case 141 /* PropertySignature */: + createPropertySignature(ast, context); + break; + case 225 /* VariableDeclarator */: + preCollectVarDecls(ast, context); + break; + case 137 /* ConstructorDeclaration */: + createClassConstructorDeclaration(ast, context); + break; + case 139 /* GetAccessor */: + createGetAccessorDeclaration(ast, context); + break; + case 140 /* SetAccessor */: + createSetAccessorDeclaration(ast, context); + break; + case 222 /* FunctionExpression */: + createFunctionExpressionDeclaration(ast, context); + break; + case 135 /* MemberFunctionDeclaration */: + createMemberFunctionDeclaration(ast, context); + break; + case 144 /* IndexSignature */: + createIndexSignatureDeclaration(ast, context); + break; + case 123 /* FunctionType */: + createFunctionTypeDeclaration(ast, context); + break; + case 125 /* ConstructorType */: + createConstructorTypeDeclaration(ast, context); + break; + case 142 /* CallSignature */: + createCallSignatureDeclaration(ast, context); + break; + case 143 /* ConstructSignature */: + createConstructSignatureDeclaration(ast, context); + break; + case 145 /* MethodSignature */: + createMethodSignatureDeclaration(ast, context); + break; + case 129 /* FunctionDeclaration */: + createFunctionDeclaration(ast, context); + break; + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + createAnyFunctionExpressionDeclaration(ast, null, context); + break; + case 133 /* ImportDeclaration */: + preCollectImportDecls(ast, context); + break; + case 238 /* TypeParameter */: + preCollectTypeParameterDecl(ast, context); + break; + case 236 /* CatchClause */: + preCollectCatchDecls(ast, context); + break; + case 163 /* WithStatement */: + preCollectWithDecls(ast, context); + break; + case 215 /* ObjectLiteralExpression */: + preCollectObjectLiteralDecls(ast, context); + break; + case 240 /* SimplePropertyAssignment */: + preCollectSimplePropertyAssignmentDecls(ast, context); + break; + case 241 /* FunctionPropertyAssignment */: + preCollectFunctionPropertyAssignmentDecls(ast, context); + break; + } + } + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, context) { + var currentDecl = context.getParent(); + + if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { + if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + return; + } + } + + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDeclaration = ast; + if (moduleDeclaration.stringLiteral) { + TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); + context.popParent(); + } else { + var moduleNames = getModuleNames(moduleDeclaration.name); + for (var i = moduleNames.length - 1; i >= 0; i--) { + var moduleName = moduleNames[i]; + TypeScript.Debug.assert(currentDecl.ast() === moduleName); + context.popParent(); + currentDecl = context.getParent(); + } + } + } + + if (ast.kind() === 132 /* EnumDeclaration */) { + computeEnumElementConstantValues(ast, currentDecl, context); + } + + while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { + context.popParent(); + currentDecl = context.getParent(); + } + } + + function computeEnumElementConstantValues(ast, enumDecl, context) { + TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); + + var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); + var inConstantSection = !isAmbientEnum; + var currentConstantValue = 0; + var enumMemberDecls = enumDecl.getChildDecls(); + + for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { + var enumElement = ast.enumElements.nonSeparatorAt(i); + var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { + return context.semanticInfoChain.getASTForDecl(d) === enumElement; + }); + + TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); + + if (enumElement.equalsValueClause === null) { + if (inConstantSection) { + enumElementDecl.constantValue = currentConstantValue; + currentConstantValue++; + } + } else { + enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); + if (enumElementDecl.constantValue !== null && !isAmbientEnum) { + inConstantSection = true; + currentConstantValue = enumElementDecl.constantValue + 1; + } else { + inConstantSection = false; + } + } + + TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); + } + } + + function computeEnumElementConstantValue(expression, enumMemberDecls, context) { + TypeScript.Debug.assert(expression); + + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { + var token; + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + token = expression.operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; + } else if (context.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var name = expression; + var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { + return d.name === name.valueText(); + }); + + return matchingEnumElement ? matchingEnumElement.constantValue : null; + + case 202 /* LeftShiftExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left << right; + + case 189 /* BitwiseOrExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left | right; + } + + return null; + } else { + return null; + } + } + + (function (DeclarationCreator) { + function create(document, semanticInfoChain, compilationSettings) { + var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); + + TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); + + return declCollectionContext.getParent(); + } + DeclarationCreator.create = create; + })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); + var DeclarationCreator = TypeScript.DeclarationCreator; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBinder = (function () { + 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 */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.hasBeenBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind === 262144 /* GetAccessor */) { + parent = parent.getGetter(); + } else if (parentDeclKind === 524288 /* SetAccessor */) { + parent = parent.getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = parent.getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = startingDecl.getParentPath(); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + }; + + PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { + var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; + var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; + var name = decl.name; + if (parent) { + var isExported = (decl.flags & 1 /* Exported */) !== 0; + + var prevSymbol = null; + if (lookingForValue) { + prevSymbol = parent.findContainedNonMember(name); + } else if (lookingForType) { + prevSymbol = parent.findContainedNonMemberType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); + } + var prevIsExported = !prevSymbol; + if (!prevSymbol) { + if (lookingForValue) { + prevSymbol = parent.findMember(name, false); + } else if (lookingForType) { + prevSymbol = parent.findNestedType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findNestedContainer(name, searchKind); + } + } + + if (isExported && prevIsExported) { + return prevSymbol; + } + if (prevSymbol) { + var prevDecls = prevSymbol.getDeclarations(); + var lastPrevDecl = prevDecls[prevDecls.length - 1]; + var parentDecl = decl.getParentDecl(); + var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); + if (parentDecl !== prevParentDecl) { + return null; + } + + return prevSymbol; + } + } else { + var parentDecl = decl.getParentDecl(); + if (parentDecl && parentDecl.kind === 1 /* Script */) { + return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); + } else { + var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); + return prevDecls[0] && prevDecls[0].getSymbol(); + } + } + + return null; + }; + + PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { + if (typeof reportError === "undefined") { reportError = true; } + 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 (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()]); + } + return false; + } + + 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; + + var enumContainerSymbol = null; + var enumInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var enumInstanceDecl = enumContainerDecl.getValueDecl(); + + var enumDeclKind = enumContainerDecl.kind; + + var parent = this.getParent(enumContainerDecl); + var parentInstanceSymbol = this.getParent(enumContainerDecl, true); + var parentDecl = enumContainerDecl.getParentDecl(); + var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); + + var isExported = enumContainerDecl.flags & 1 /* Exported */; + + var createdNewSymbol = false; + + enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); + + if (enumContainerSymbol) { + if (enumContainerSymbol.kind !== enumDeclKind) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); + enumContainerSymbol = null; + } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { + enumContainerSymbol = null; + } + } + + if (enumContainerSymbol) { + enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); + } else { + enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); + } + } + + enumContainerSymbol.addDeclaration(enumContainerDecl); + enumContainerDecl.setSymbol(enumContainerSymbol); + + this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); + this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); + + if (!enumInstanceSymbol) { + var variableSymbol = null; + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] === enumContainerDecl) { + break; + } + + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol) { + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + enumInstanceSymbol = variableSymbol; + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); + } + + enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + enumInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); + } + } + + if (createdNewSymbol && parent) { + if (enumContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(enumContainerSymbol); + } else { + parent.addEnclosedNonMemberType(enumContainerSymbol); + } + } + + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } + var valueDecl = enumContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + 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(); + + enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; + + 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(); + + 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); + if (!moduleDeclAST) { + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); + + moduleDeclAST = moduleNameAST; + } + + var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); + var searchKind = 164 /* SomeContainer */; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; + + if (parent && moduleKind === 32 /* DynamicModule */) { + this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); + } + + var createdNewSymbol = false; + + moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); + + if (moduleContainerTypeSymbol) { + if (moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); + } + + moduleContainerTypeSymbol = null; + } 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) { + moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); + this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); + + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); + } + } + } + + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); + + 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); + } + } + + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(importSymbol); + } else { + parent.addEnclosedNonMemberContainer(importSymbol); + } + } + }; + + 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; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + 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, 58728795 /* SomeType */, parent); + + if (classSymbol && classSymbol.kind === 16 /* Interface */) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); + classSymbol = null; + } + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); + this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + 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; + + if (!constructorSymbol) { + var siblingValueDecls = null; + if (parentDecl) { + siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); + + if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { + constructorSymbol = siblingValueDecls[0].getSymbol(); + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + constructorSymbol.setIsSynthesized(); + constructorSymbol.type = constructorTypeSymbol; + } + + classSymbol.setConstructorMethod(constructorSymbol); + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); + + if (interfaceSymbol) { + if (!(interfaceSymbol.kind & acceptableSharedKind)) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); + interfaceSymbol = null; + } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { + interfaceSymbol = null; + } + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + 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; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + 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; + variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); + var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); + var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); + 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 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 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.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 || 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); + variableSymbol = null; + parentHadSymbol = false; + } + } + + if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { + variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); + } + } + + if ((declFlags & 118784 /* ImplicitVariable */) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + if (!parent && parentDecl.kind === 1 /* Script */) { + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); + this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfoChain.getASTForDecl(decl); + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & 102400 /* SomeInitializedModule */) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + 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); + } + variableDeclaration.setSymbol(variableSymbol); + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + if (!variableSymbol.hasDeclaration(variableDeclaration)) { + variableSymbol.addDeclaration(variableDeclaration); + } + 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); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); + + var declName = variableDeclaration.name; + + var variableSymbol = new TypeScript.PullSymbol(declName, declKind); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + + this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); + }; + + PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + var propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + + var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { + var parameters = []; + var params = TypeScript.createIntrinsicsObject(); + var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); + + if (parameterList) { + for (var i = 0, n = parameterList.length; i < n; i++) { + var argDecl = parameterList.astAt(i); + var id = parameterList.identifierAt(i); + var decl = this.semanticInfoChain.getDeclForAST(argDecl); + var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); + var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); + + if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { + parameterSymbol.isVarArg = 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); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); + + if (functionSymbol) { + 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); + functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); + } + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { + signature.hasVarArgs = true; + } + + var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); + + 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; + if (name) { + this.semanticInfoChain.setSymbolForAST(name, functionSymbol); + } + + this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); + + if (parameters.lastParameterIsRest()) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + + var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; + + TypeScript.Debug.assert(nameAST); + + this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); + this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); + + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); + if (TypeScript.lastParameterIsRest(parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); + signature.addTypeParameter(typeParameter); + } else { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { + var prototypeStr = "prototype"; + + var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); + if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { + 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], this.semanticInfoChain); + + prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + prototypeSymbol.setIsSynthesized(); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = classTypeSymbol; + constructorTypeSymbol.addMember(prototypeSymbol); + + if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { + var resolver = this.semanticInfoChain.getResolver(); + prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); + } + prototypeSymbol.setResolved(); + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); + constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.appendConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + constructSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + callSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); + + var parent = this.getParent(indexSignatureDeclaration); + parent.addIndexSignature(indexSignature); + indexSignature.setContainer(parent); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + + getterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); + } + }; + + 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) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + this.bindEnumDeclarationToPullSymbol(decl); + break; + + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 512 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 1024 /* CatchVariable */: + this.bindCatchVariableToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + this.bindEnumMemberDeclarationToPullSymbol(decl); + break; + + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 128 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + decl.getParentDecl().getSymbol(); + break; + + case 268435456 /* CatchBlock */: + case 134217728 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); + this.declsBeingBound.pop(); + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (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(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + + if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (functionDecl.kind === 4194304 /* IndexSignature */) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + + function isNameNumeric(name) { + return isFinite(+name); + } + PullHelpers.isNameNumeric = isNameNumeric; + + function typeSymbolsAreIdentical(a, b) { + if (a.isTypeReference() && !a.getIsSpecialized()) { + a = a.referencedTypeSymbol; + } + + if (b.isTypeReference() && !b.getIsSpecialized()) { + b = b.referencedTypeSymbol; + } + + return a === b; + } + PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; + + function getRootType(type) { + var rootType = type.getRootSymbol(); + + while (true) { + if (type === rootType) { + return type; + } + + type = rootType; + rootType = type.getRootSymbol(); + } + } + PullHelpers.getRootType = getRootType; + + function isSymbolLocal(symbol) { + var container = symbol.getContainer(); + if (container) { + var containerKind = container.kind; + if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { + return true; + } + + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { + return true; + } + } + + 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; + +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.fileResolutionIOTime = 0; + TypeScript.fileResolutionScanImportsTime = 0; + TypeScript.fileResolutionImportFileSearchTime = 0; + TypeScript.fileResolutionGetDefaultLibraryTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.compilerResolvePathTime = 0; + TypeScript.compilerDirectoryNameTime = 0; + TypeScript.compilerDirectoryExistsTime = 0; + TypeScript.compilerFileExistsTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + 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(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } + this.outputFiles = []; + this.emitOutputResult = emitOutputResult; + } + return EmitOutput; + })(); + TypeScript.EmitOutput = EmitOutput; + + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); + var OutputFileType = TypeScript.OutputFileType; + + var OutputFile = (function () { + function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { + if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.text = text; + this.fileType = fileType; + this.sourceMapEntries = sourceMapEntries; + } + return OutputFile; + })(); + TypeScript.OutputFile = OutputFile; + + var CompileResult = (function () { + function CompileResult() { + this.diagnostics = []; + this.outputFiles = []; + } + CompileResult.fromDiagnostics = function (diagnostics) { + var result = new CompileResult(); + result.diagnostics = diagnostics; + return result; + }; + + CompileResult.fromOutputFiles = function (outputFiles) { + var result = new CompileResult(); + result.outputFiles = outputFiles; + return result; + }; + return CompileResult; + })(); + TypeScript.CompileResult = CompileResult; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, _settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } + this.logger = logger; + this._settings = _settings; + this.semanticInfoChain = null; + this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); + } + TypeScriptCompiler.prototype.compilationSettings = function () { + return this._settings; + }; + + TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { + var oldSettings = this._settings; + this._settings = newSettings; + + if (!compareDataObjects(oldSettings, newSettings)) { + this.semanticInfoChain.invalidate(oldSettings, newSettings); + } + }; + + TypeScriptCompiler.prototype.getDocument = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.semanticInfoChain.getDocument(fileName); + }; + + TypeScriptCompiler.prototype.cleanupSemanticCache = function () { + this.semanticInfoChain.invalidate(); + }; + + TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); + + this.semanticInfoChain.addDocument(document); + }; + + TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); + + this.semanticInfoChain.addDocument(updatedDocument); + }; + + TypeScriptCompiler.prototype.removeFile = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + this.semanticInfoChain.removeDocument(fileName); + }; + + TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { + if (document.emitToOwnOutputFile()) { + var updatedFileName = document.fileName; + if (emitOptions.outputDirectory() !== "") { + updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); + updatedFileName = emitOptions.outputDirectory() + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(emitOptions.sharedOutputFile(), true); + } + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + var printReason = false; + + if (document.emitToOwnOutputFile()) { + var result = document.byteOrderMark !== 0 /* None */; + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + } + return result; + } else { + var fileNames = this.fileNames(); + + var result = false; + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + + if (document.isExternalModule()) { + continue; + } + + if (document.byteOrderMark !== 0 /* None */) { + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + result = true; + } else { + return true; + } + } + } + + return result; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype._shouldEmit = function (document) { + return !document.isDeclareFile(); + }; + + TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { + if (!this.compilationSettings().generateDeclarationFiles()) { + return false; + } + + return this._shouldEmit(document); + }; + + TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); + + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); + } + + declarationEmitter.emitDeclarations(sourceUnit); + return declarationEmitter; + }; + + TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmitDeclarations(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFile()); + } + } else { + sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var sharedEmitter = null; + var fileNames = this.fileNames(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileNames[i]); + + sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return emitOutput; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, null); + return emitOutput; + } else { + return this.emitAllDeclarations(resolvePath); + } + }; + + 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; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmit(document)); + + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); + var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); + + if (this.compilationSettings().mapSourceFiles()) { + var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); + emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); + } + } else if (this.compilationSettings().mapSourceFiles()) { + emitter.setSourceMapperNewSourceFile(document); + } + + emitter.setDocument(document); + emitter.emitJavascript(sourceUnit, false); + + return emitter; + }; + + TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmit(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFiles()); + } + } else { + sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var fileNames = this.fileNames(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + sharedEmitter = this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); + } + + TypeScript.emitTime += new Date().getTime() - start; + return emitOutput; + }; + + TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, null); + return emitOutput; + } else { + return this.emitAll(resolvePath); + } + }; + + TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { + if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } + return new CompilerIterator(this, resolvePath, continueOnDiagnostics); + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + + TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { + return this.getDocument(fileName).sourceUnit(); + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + var errors = this.semanticInfoChain.getDiagnostics(fileName); + + errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); + errors.sort(function (d1, d2) { + if (d1.fileName() < d2.fileName()) { + return -1; + } else if (d1.fileName() > d2.fileName()) { + return 1; + } + + if (d1.start() < d2.start()) { + return -1; + } else if (d1.start() > d2.start()) { + return 1; + } + + var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; + var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; + if (code1 < code2) { + return -1; + } else if (code1 > code2) { + return 1; + } + + return 0; + }); + + 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++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var ast = this.semanticInfoChain.getASTForDecl(decl); + if (!ast) { + return null; + } + + var enclosingDecl = resolver.getEnclosingDecl(decl); + if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { + return this.getSymbolOfDeclaration(enclosingDecl); + } + + return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { + var scriptName = document.fileName; + + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + var inWithBlock = false; + + var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); + + if (!ast) { + return null; + } + + var path = this.getASTPath(ast); + + for (var i = 0, n = path.length; i < n; i++) { + var current = path[i]; + + switch (current.kind()) { + case 222 /* FunctionExpression */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + if (propagateContextualTypes) { + resolver.resolveAST(current, true, resolutionContext); + } + break; + + case 136 /* MemberVariableDeclaration */: + var memberVariable = current; + inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); + break; + + case 225 /* VariableDeclarator */: + var variableDeclarator = current; + inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); + break; + + case 213 /* InvocationExpression */: + case 216 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.kind() === 216 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = path[i + 3]; + if (argExpression) { + for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { + if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext); + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 214 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 215 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.propertyAssignments; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { + if (memberDecls.nonSeparatorAt(j) === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + } + + break; + + case 174 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path[i + 1] && path[i + 1] === assignmentExpression.right) { + var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + 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; + + case 150 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 122 /* ObjectType */: + if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { + resolver.resolveAST(current, false, resolutionContext); + } + + break; + + case 163 /* WithStatement */: + inWithBlock = true; + break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; + } + + var decl = this.semanticInfoChain.getDeclForAST(current); + if (decl) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { + if (ast.parent.kind() === 212 /* MemberAccessExpression */) { + if (ast.parent.name === ast) { + ast = ast.parent; + } + } else if (ast.parent.kind() === 121 /* QualifiedName */) { + if (ast.parent.right === ast) { + ast = ast.parent; + } + } + } + + return { + ast: ast, + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment, + inWithBlock: inWithBlock + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + resolver.resolveAST(assigningAST, false, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushNewContextualType(contextualType); + + if (init) { + resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); + } + } + } + }; + + TypeScriptCompiler.prototype.getASTPath = function (ast) { + var result = []; + + while (ast) { + result.unshift(ast); + ast = ast.parent; + } + + return result; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + ast = context.ast; + 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()]); + return null; + } + + if (symbol.isTypeReference()) { + symbol = symbol.getReferencedTypeSymbol(); + } + + var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); + + return { + symbol: symbol, + aliasSymbol: aliasSymbol, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { + if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { + return null; + } + + var isNew = ast.kind() === 216 /* ObjectCreationExpression */; + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, false); + if (!context || context.inWithBlock) { + return null; + } + + return resolver.getVisibleDecls(context.enclosingDecl); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { + if (ast.kind() !== 215 /* ObjectLiteralExpression */) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var astForDecl = decl.ast(); + if (!astForDecl) { + return null; + } + + var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); + if (!astForDeclContext) { + return null; + } + + var symbol = decl.getSymbol(); + resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + aliasSymbol: null, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { + return this.semanticInfoChain.topLevelDecl(fileName); + }; + + TypeScriptCompiler.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast); + }; + + TypeScriptCompiler.prototype.fileNames = function () { + return this.semanticInfoChain.fileNames(); + }; + + 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; + + var CompilerPhase; + (function (CompilerPhase) { + CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; + CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; + CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; + CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; + CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; + })(CompilerPhase || (CompilerPhase = {})); + + var CompilerIterator = (function () { + function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { + if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } + this.compiler = compiler; + this.resolvePath = resolvePath; + this.continueOnDiagnostics = continueOnDiagnostics; + this.index = -1; + this.fileNames = null; + this._current = null; + this._emitOptions = null; + this._sharedEmitter = null; + this._sharedDeclarationEmitter = null; + this.hadSyntacticDiagnostics = false; + this.hadSemanticDiagnostics = false; + this.hadEmitDiagnostics = false; + this.fileNames = compiler.fileNames(); + this.compilerPhase = startingPhase; + } + CompilerIterator.prototype.current = function () { + return this._current; + }; + + CompilerIterator.prototype.moveNext = function () { + this._current = null; + + while (this.moveNextInternal()) { + if (this._current) { + return true; + } + } + + return false; + }; + + CompilerIterator.prototype.moveNextInternal = function () { + this.index++; + + while (this.shouldMoveToNextPhase()) { + this.index = 0; + this.compilerPhase++; + } + + if (this.compilerPhase > 4 /* DeclarationEmit */) { + return false; + } + + switch (this.compilerPhase) { + case 0 /* Syntax */: + return this.moveNextSyntaxPhase(); + case 1 /* Semantics */: + return this.moveNextSemanticsPhase(); + case 2 /* EmitOptionsValidation */: + return this.moveNextEmitOptionsValidationPhase(); + case 3 /* Emit */: + return this.moveNextEmitPhase(); + case 4 /* DeclarationEmit */: + return this.moveNextDeclarationEmitPhase(); + } + }; + + CompilerIterator.prototype.shouldMoveToNextPhase = function () { + switch (this.compilerPhase) { + case 2 /* EmitOptionsValidation */: + return this.index === 1; + + case 0 /* Syntax */: + case 1 /* Semantics */: + return this.index === this.fileNames.length; + + case 3 /* Emit */: + case 4 /* DeclarationEmit */: + return this.index === (this.fileNames.length + 1); + } + + return false; + }; + + CompilerIterator.prototype.moveNextSyntaxPhase = function () { + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + + var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSyntacticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextSemanticsPhase = function () { + if (this.hadSyntacticDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + var diagnostics = this.compiler.getSemanticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSemanticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + + if (!this._emitOptions) { + this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); + } + + if (this._emitOptions.diagnostic()) { + if (!this.continueOnDiagnostics) { + this.hadEmitDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(this._emitOptions); + + if (this.hadEmitDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { + _this._current = CompileResult.fromOutputFiles(outputFiles); + }, this._sharedEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedEmitter) { + this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); + } + + return true; + }; + + CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(!this.hadEmitDiagnostics); + if (this.hadSemanticDiagnostics) { + return false; + } + + if (!this.compiler.compilationSettings().generateDeclarationFiles()) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { + _this._current = CompileResult.fromOutputFiles([file]); + }, this._sharedDeclarationEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { + this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); + } + + return true; + }; + return CompilerIterator; + })(); + + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) + return false; + } else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) + return false; + } + } + return true; + } + TypeScript.compareDataObjects = compareDataObjects; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (GenerativeTypeClassification) { + GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; + GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; + GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; + GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; + })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); + var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; + + var PullTypeReferenceSymbol = (function (_super) { + __extends(PullTypeReferenceSymbol, _super); + function PullTypeReferenceSymbol(referencedTypeSymbol) { + _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); + this.referencedTypeSymbol = referencedTypeSymbol; + this.isResolved = true; + + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); + + this.setRootSymbol(referencedTypeSymbol); + + this.typeReference = this; + } + PullTypeReferenceSymbol.createTypeReference = function (type) { + if (type.isTypeReference()) { + return type; + } + + var typeReference = type.typeReference; + + if (!typeReference) { + typeReference = new PullTypeReferenceSymbol(type); + type.typeReference = typeReference; + } + + return typeReference; + }; + + PullTypeReferenceSymbol.prototype.isTypeReference = function () { + return true; + }; + + PullTypeReferenceSymbol.prototype.setResolved = function () { + }; + + PullTypeReferenceSymbol.prototype.setUnresolved = function () { + }; + PullTypeReferenceSymbol.prototype.invalidate = function () { + }; + + PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { + this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); + }; + + PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol; + }; + + PullTypeReferenceSymbol.prototype._getResolver = function () { + return this.referencedTypeSymbol._getResolver(); + }; + + PullTypeReferenceSymbol.prototype.hasMembers = function () { + return this.referencedTypeSymbol.hasMembers(); + }; + + PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); + }; + + PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + return this.referencedTypeSymbol.getAssociatedContainerType(); + }; + + PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getFunctionSymbol(); + }; + PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); + }; + + PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); + }; + PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); + }; + + PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); + }; + PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMember(name); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); + }; + + PullTypeReferenceSymbol.prototype.getMembers = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getMembers(); + }; + + PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); + }; + PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getHasDefaultConstructor(); + }; + PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructorMethod(); + }; + PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); + }; + PullTypeReferenceSymbol.prototype.getTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.isGeneric = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isGeneric(); + }; + + PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getSpecialization(substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getKnownSpecializations(); + }; + PullTypeReferenceSymbol.prototype.getTypeArguments = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArguments(); + }; + PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); + }; + 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"); + }; + + PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnIndexSignatures(); + }; + PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getIndexSignatures(); + }; + + PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { + this.referencedTypeSymbol.addImplementedType(implementedType); + }; + PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getImplementedTypes(); + }; + PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { + this.referencedTypeSymbol.addExtendedType(extendedType); + }; + PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getExtendedTypes(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExtendsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExtendThisType(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); + }; + + PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); + }; + + PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findMember(name, lookInParent); + }; + PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedType(name, kind); + }; + PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedContainer(name, kind); + }; + PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + }; + + PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findTypeParameter(name); + }; + + PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); + }; + return PullTypeReferenceSymbol; + })(TypeScript.PullTypeSymbol); + TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; + + var PullInstantiatedTypeReferenceSymbol = (function (_super) { + __extends(PullInstantiatedTypeReferenceSymbol, _super); + 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 = undefined; + this._instantiatedConstructorMethod = null; + this._instantiatedAssociatedContainerType = null; + this._isArray = undefined; + this._generativeTypeClassification = []; + + TypeScript.nSpecializationsCreated++; + } + PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { + return !this.isInstanceReferenceType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; + } + + 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()); + } + return this._isArray; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { + if (!this.isArrayNamedTypeReference()) { + return null; + } + + var typeArguments = this.getTypeArguments(); + return typeArguments ? typeArguments[0] : null; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.getIsSpecialized()) { + return this; + } + + return this.referencedTypeSymbol; + }; + + 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + 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; + } + } + + if (isInstanceReferenceType) { + typeParameterArgumentMap = []; + } + } + + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); + + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); + + return instantiation; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { + return this.getRootSymbol().isGeneric(); + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { + if (this.isInstanceReferenceType) { + return this.getTypeParameters(); + } + + if (this._typeArgumentReferences === undefined) { + var typeParameters = this.referencedTypeSymbol.getTypeParameters(); + + if (typeParameters.length) { + var typeArgument = null; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; + + if (!typeArgument) { + TypeScript.Debug.fail("type argument count mismatch"); + } + + if (typeArgument) { + typeArguments[typeArguments.length] = typeArgument; + } + } + + this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; + } + } + + return this._typeArgumentReferences; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + 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(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getMembers(); + } + + if (!this._instantiatedMembers) { + var referencedMembers = this.referencedTypeSymbol.getMembers(); + var referencedMember = null; + var instantiatedMember = null; + + this._instantiatedMembers = []; + + for (var i = 0; i < referencedMembers.length; i++) { + referencedMember = referencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (!this._instantiatedMemberNameCache[referencedMember.name]) { + this.populateInstantiatedMemberFromReferencedMember(referencedMember); + } + + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; + } + } + + return this._instantiatedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.findMember(name, lookInParent); + } + + var memberSymbol = this._instantiatedMemberNameCache[name]; + + if (!memberSymbol) { + var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); + + if (referencedMemberSymbol) { + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; + } else { + memberSymbol = null; + } + } + + return memberSymbol; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + } + + var requestedMembers = []; + var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + + if (!this._allInstantiatedMemberNameCache) { + this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); + + var members = this.getMembers(); + + for (var i = 0; i < members.length; i++) { + this._allInstantiatedMemberNameCache[members[i].name] = members[i]; + } + } + + var referencedMember = null; + var requestedMember = null; + + for (var i = 0; i < allReferencedMembers.length; i++) { + referencedMember = allReferencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (this._allInstantiatedMemberNameCache[referencedMember.name]) { + requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; + } else { + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; + requestedMembers[requestedMembers.length] = referencedMember; + } else { + requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + requestedMember.setRootSymbol(referencedMember); + + requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + requestedMember.isOptional = referencedMember.isOptional; + + this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; + requestedMembers[requestedMembers.length] = requestedMember; + } + } + } + + return requestedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructorMethod(); + } + + 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); + } + + return this._instantiatedConstructorMethod; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + if (!this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAssociatedContainerType(); + } + + if (!this._instantiatedAssociatedContainerType) { + var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); + + if (referencedAssociatedContainerType) { + this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); + } + } + + return this._instantiatedAssociatedContainerType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getCallSignatures(); + } + + if (this._instantiatedCallSignatures) { + return this._instantiatedCallSignatures; + } + + var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); + this._instantiatedCallSignatures = []; + + for (var i = 0; i < referencedCallSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); + + if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; + } else { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedCallSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructSignatures(); + } + + if (this._instantiatedConstructSignatures) { + return this._instantiatedConstructSignatures; + } + + var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); + this._instantiatedConstructSignatures = []; + + for (var i = 0; i < referencedConstructSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); + + if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; + } else { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedConstructSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getIndexSignatures(); + } + + if (this._instantiatedIndexSignatures) { + return this._instantiatedIndexSignatures; + } + + var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); + this._instantiatedIndexSignatures = []; + + for (var i = 0; i < referencedIndexSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); + + if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; + } else { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedIndexSignatures; + }; + 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) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { + if (element === null) { + return null; + } + + if (element.fullWidth() === 0) { + return new TypeScript.ASTSpan(-1, -1); + } + + var leadingTriviaWidth = element.leadingTriviaWidth(); + var trailingTriviaWidth = element.trailingTriviaWidth(); + + var start = fullStart + leadingTriviaWidth; + var end = fullStart + element.fullWidth() - trailingTriviaWidth; + + return new TypeScript.ASTSpan(start, end); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { + if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } + if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span._trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span._start = start; + span._end = end; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ISyntaxList2(this.fileName, array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { + return this.visitToken(token); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result = this.visitTokenWorker(token); + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { + switch (token.tokenKind) { + case 60 /* AnyKeyword */: + return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); + case 61 /* BooleanKeyword */: + return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); + case 67 /* NumberKeyword */: + return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); + case 69 /* StringKeyword */: + return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); + case 41 /* VoidKeyword */: + return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); + case 35 /* ThisKeyword */: + return new TypeScript.ThisExpression(token.text(), token.valueText()); + case 50 /* SuperKeyword */: + return new TypeScript.SuperExpression(token.text(), token.valueText()); + case 37 /* TrueKeyword */: + return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); + case 24 /* FalseKeyword */: + return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); + case 32 /* NullKeyword */: + return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); + case 14 /* StringLiteral */: + return new TypeScript.StringLiteral(token.text(), token.valueText()); + case 12 /* RegularExpressionLiteral */: + return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); + case 13 /* NumericLiteral */: + var fullStart = this.position; + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); + + result.setPreComments(preComments); + return result; + case 11 /* IdentifierName */: + return new TypeScript.Identifier(token.text()); + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { + var start = this.position; + TypeScript.Debug.assert(start === 0); + + var bod = this.visitSyntaxList(node.moduleElements); + 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; + }; + + SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { + var start = this.position; + + this.moveTo(node, node.stringLiteral); + var stringLiteral = node.stringLiteral.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ExternalModuleReference(stringLiteral); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { + var start = this.position; + var moduleName = node.moduleName.accept(this); + + var result = new TypeScript.ModuleNameModuleReference(moduleName); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + this.movePast(node.openBraceToken); + var members = this.visitSyntaxList(node.classElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { + var result = null; + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { + result = result || []; + result.push(1 /* Exported */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + result = result || []; + result.push(8 /* Ambient */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { + result = result || []; + result.push(16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { + result = result || []; + result.push(4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { + result = result || []; + result.push(2 /* Private */); + } + + return result || TypeScript.sentinelEmptyArray; + }; + + SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + var body = this.visitObjectType(node.body); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { + var start = this.position; + + this.movePast(node.extendsOrImplementsKeyword); + var typeNames = this.visitSeparatedSyntaxList(node.typeNames); + + var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { + var start = this.position; + + var modifiers = this.visitModifiers(node.modifiers); + + this.moveTo(node, node.moduleKeyword); + this.movePast(node.moduleKeyword); + + var moduleName = node.name ? node.name.accept(this) : null; + var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; + + this.movePast(node.openBraceToken); + + var moduleElements = this.visitSyntaxList(node.moduleElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + this.movePast(node.openBraceToken); + + var enumElements = this.visitSeparatedSyntaxList(node.enumElements); + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + var start = this.position; + + var memberName = this.visitToken(node.propertyName); + + var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.EnumElement(memberName, value); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ImportDeclaration(modifiers, name, alias); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.VariableStatement(modifiers, declaration); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var propertyName = this.visitToken(node.propertyName); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var start = this.position; + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var value = node.value.accept(this); + value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); + + var result = new TypeScript.EqualsValueClause(value); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayLiteralExpression(expressions); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(openParenToken); + + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = node.identifier.accept(this); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var callSignature = this.visitCallSignature(node.callSignature); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + return type ? type.accept(this) : null; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var result = new TypeScript.TypeQuery(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left); + this.movePast(node.dotToken); + var right = this.visitIdentifier(node.right); + + var result = new TypeScript.QualifiedName(left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeArgumentList(typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectType(typeMembers); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayType(underlying); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name); + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + var result = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.colonToken); + var type = this.visitType(node.type); + + var result = new TypeScript.TypeAnnotation(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.visitIdentifier(node.name); + + var result = new TypeScript.MemberAccessExpression(expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + this.movePast(node.openParenToken); + + 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()); + } + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(node.kind(), left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.ConstructSignature(callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.MethodSignature(name, questionToken, callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.IndexSignature(parameter, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + var openParenToken = node.openParenToken; + + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + var openParenTrailingComments = null; + if (node.parameters.childCount() === 0) { + openParenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + } + + this.movePast(node.openParenToken); + var parameters = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeParameterList(typeParameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + var start = this.position; + this.movePast(node.extendsKeyword); + var type = this.visitType(node.type); + + var result = new TypeScript.Constraint(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + var start = this.position; + + this.movePast(node.elseKeyword); + var statement = node.statement.accept(this); + + var result = new TypeScript.ElseClause(statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var expression = node.expression.accept(this); + + var semicolonPosition = this.position; + + var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + 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(callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.indexSignature); + var indexSignature = node.indexSignature.accept(this); + + this.movePast(node.semicolonToken); + + var result = new TypeScript.IndexMemberDeclaration(indexSignature); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + var variableDeclarator = node.variableDeclarator.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + this.movePast(node.openBraceToken); + var switchClauses = this.visitSyntaxList(node.switchClauses); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseSwitchClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.DefaultSwitchClause(statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.BreakStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ContinueStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var initializer = node.initializer ? node.initializer.accept(this) : null; + + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var left = node.left ? node.left.accept(this) : null; + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.CastExpression(castTerm, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + var propertyName = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var expression = node.expression.accept(this); + expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); + + var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var propertyName = node.propertyName.accept(this); + var callSignature = this.visitCallSignature(node.callSignature); + var block = this.visitBlock(node.block); + + var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionExpression(name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.visitIdentifier(node.identifier); + var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + var start = this.position; + this.movePast(node.finallyKeyword); + var block = node.block.accept(this); + + var result = new TypeScript.FinallyClause(block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, whileKeyword, condition); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.TypeOfExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.DeleteExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.VoidExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + function applyDelta(ast, delta) { + if (ast) { + if (ast._start !== -1) { + ast._start += delta; + } + + if (ast._end !== -1) { + ast._end += delta; + } + } + } + + function applyDeltaToComments(comments, delta) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment, delta); + } + } + } + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var pre = function (cur) { + applyDelta(cur, delta); + applyDeltaToComments(cur.preComments(), delta); + applyDeltaToComments(cur.postComments(), delta); + + switch (cur.kind()) { + case 146 /* Block */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 226 /* ArgumentList */: + applyDelta(cur.closeParenToken, delta); + break; + + case 130 /* ModuleDeclaration */: + applyDelta(cur.endingToken, delta); + break; + + case 131 /* ClassDeclaration */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 161 /* DoStatement */: + applyDelta(cur.whileKeyword, delta); + break; + + case 151 /* SwitchStatement */: + applyDelta(cur.closeParenToken, delta); + break; + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span._start !== -1) { + var delta = start - span._start; + this.applyDelta(span, delta); + + span._end = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = element._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + element._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan(_start, _end) { + this._start = _start; + this._end = _end; + } + ASTSpan.prototype.start = function () { + return this._start; + }; + + ASTSpan.prototype.end = function () { + return this._end; + }; + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, false); + } + + function commentStructuralEqualsIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, true); + } + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); + } + + function commentStructuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + function commentArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.parent = null; + this._start = -1; + this._end = -1; + this._trailingTriviaWidth = 0; + this._astID = astID++; + this._preComments = null; + this._postComments = null; + } + AST.prototype.syntaxID = function () { + return this._astID; + }; + + AST.prototype.start = function () { + return this._start; + }; + + AST.prototype.end = function () { + return this._end; + }; + + AST.prototype.trailingTriviaWidth = function () { + return this._trailingTriviaWidth; + }; + + AST.prototype.fileName = function () { + return this.parent.fileName(); + }; + + AST.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.width = function () { + return this.end() - this.start(); + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + + AST.prototype.isExpression = function () { + return false; + }; + return AST; + })(); + TypeScript.AST = AST; + + var ISyntaxList2 = (function (_super) { + __extends(ISyntaxList2, _super); + function ISyntaxList2(_fileName, members) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISyntaxList2.prototype.childCount = function () { + return this.members.length; + }; + + ISyntaxList2.prototype.childAt = function (index) { + return this.members[index]; + }; + + ISyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISyntaxList2.prototype.kind = function () { + return 1 /* List */; + }; + + ISyntaxList2.prototype.firstOrDefault = function (func) { + return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.lastOrDefault = function (func) { + return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.any = function (func) { + return TypeScript.ArrayUtilities.any(this.members, func); + }; + + ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISyntaxList2; + })(AST); + TypeScript.ISyntaxList2 = ISyntaxList2; + + var ISeparatedSyntaxList2 = (function (_super) { + __extends(ISeparatedSyntaxList2, _super); + function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + this._separatorCount = _separatorCount; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { + return this.members.length; + }; + + ISeparatedSyntaxList2.prototype.separatorCount = function () { + return this._separatorCount; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { + return this.members[index]; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i) === ast) { + return i; + } + } + + return -1; + }; + + ISeparatedSyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISeparatedSyntaxList2.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISeparatedSyntaxList2; + })(AST); + TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; + + var SourceUnit = (function (_super) { + __extends(SourceUnit, _super); + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { + _super.call(this); + this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; + this._fileName = _fileName; + moduleElements && (moduleElements.parent = this); + } + SourceUnit.prototype.fileName = function () { + return this._fileName; + }; + + SourceUnit.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return SourceUnit; + })(AST); + TypeScript.SourceUnit = SourceUnit; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(_text) { + _super.call(this); + this._text = _text; + this._valueText = null; + } + Identifier.prototype.text = function () { + return this._text; + }; + Identifier.prototype.valueText = function () { + if (!this._valueText) { + var text = this._text; + if (text === "__proto__") { + this._valueText = "#__proto__"; + } else { + this._valueText = TypeScript.Syntax.massageEscapes(text); + } + } + + return this._valueText; + }; + + Identifier.prototype.kind = function () { + return 11 /* IdentifierName */; + }; + + 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; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + LiteralExpression.prototype.text = function () { + return this._text; + }; + + LiteralExpression.prototype.valueText = function () { + return this._valueText; + }; + + LiteralExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + ThisExpression.prototype.text = function () { + return this._text; + }; + + ThisExpression.prototype.valueText = function () { + return this._valueText; + }; + + ThisExpression.prototype.kind = function () { + return 35 /* ThisKeyword */; + }; + + 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; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + SuperExpression.prototype.text = function () { + return this._text; + }; + + SuperExpression.prototype.valueText = function () { + return this._valueText; + }; + + SuperExpression.prototype.kind = function () { + return 50 /* SuperKeyword */; + }; + + 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; + + var NumericLiteral = (function (_super) { + __extends(NumericLiteral, _super); + function NumericLiteral(_value, _text, _valueText) { + _super.call(this); + this._value = _value; + this._text = _text; + this._valueText = _valueText; + } + NumericLiteral.prototype.text = function () { + return this._text; + }; + NumericLiteral.prototype.valueText = function () { + return this._valueText; + }; + NumericLiteral.prototype.value = function () { + return this._value; + }; + + NumericLiteral.prototype.kind = function () { + return 13 /* NumericLiteral */; + }; + + 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; + + var RegularExpressionLiteral = (function (_super) { + __extends(RegularExpressionLiteral, _super); + function RegularExpressionLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + RegularExpressionLiteral.prototype.text = function () { + return this._text; + }; + + RegularExpressionLiteral.prototype.valueText = function () { + return this._valueText; + }; + + RegularExpressionLiteral.prototype.kind = function () { + return 12 /* RegularExpressionLiteral */; + }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; + return RegularExpressionLiteral; + })(AST); + TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + StringLiteral.prototype.valueText = function () { + return this._valueText; + }; + + StringLiteral.prototype.kind = function () { + return 14 /* StringLiteral */; + }; + + 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; + + var TypeAnnotation = (function (_super) { + __extends(TypeAnnotation, _super); + function TypeAnnotation(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + TypeAnnotation.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + return TypeAnnotation; + })(AST); + TypeScript.TypeAnnotation = TypeAnnotation; + + var BuiltInType = (function (_super) { + __extends(BuiltInType, _super); + function BuiltInType(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + BuiltInType.prototype.text = function () { + return this._text; + }; + + BuiltInType.prototype.valueText = function () { + return this._valueText; + }; + + BuiltInType.prototype.kind = function () { + return this._nodeType; + }; + return BuiltInType; + })(AST); + TypeScript.BuiltInType = BuiltInType; + + var ExternalModuleReference = (function (_super) { + __extends(ExternalModuleReference, _super); + function ExternalModuleReference(stringLiteral) { + _super.call(this); + this.stringLiteral = stringLiteral; + stringLiteral && (stringLiteral.parent = this); + } + ExternalModuleReference.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + return ExternalModuleReference; + })(AST); + TypeScript.ExternalModuleReference = ExternalModuleReference; + + var ModuleNameModuleReference = (function (_super) { + __extends(ModuleNameModuleReference, _super); + function ModuleNameModuleReference(moduleName) { + _super.call(this); + this.moduleName = moduleName; + moduleName && (moduleName.parent = this); + } + ModuleNameModuleReference.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + return ModuleNameModuleReference; + })(AST); + TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(modifiers, identifier, moduleReference) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.moduleReference = moduleReference; + identifier && (identifier.parent = this); + moduleReference && (moduleReference.parent = this); + } + ImportDeclaration.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(identifier) { + _super.call(this); + this.identifier = identifier; + identifier && (identifier.parent = this); + } + ExportAssignment.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var TypeParameterList = (function (_super) { + __extends(TypeParameterList, _super); + function TypeParameterList(typeParameters) { + _super.call(this); + this.typeParameters = typeParameters; + typeParameters && (typeParameters.parent = this); + } + TypeParameterList.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + return TypeParameterList; + })(AST); + TypeScript.TypeParameterList = TypeParameterList; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + heritageClauses && (heritageClauses.parent = this); + classElements && (classElements.parent = this); + } + ClassDeclaration.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return ClassDeclaration; + })(AST); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + body && (body.parent = this); + heritageClauses && (heritageClauses.parent = this); + } + InterfaceDeclaration.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return InterfaceDeclaration; + })(AST); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var HeritageClause = (function (_super) { + __extends(HeritageClause, _super); + function HeritageClause(_nodeType, typeNames) { + _super.call(this); + this._nodeType = _nodeType; + this.typeNames = typeNames; + typeNames && (typeNames.parent = this); + } + HeritageClause.prototype.kind = function () { + return this._nodeType; + }; + + HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); + }; + return HeritageClause; + })(AST); + TypeScript.HeritageClause = HeritageClause; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { + _super.call(this); + this.modifiers = modifiers; + this.name = name; + this.stringLiteral = stringLiteral; + this.moduleElements = moduleElements; + this.endingToken = endingToken; + name && (name.parent = this); + stringLiteral && (stringLiteral.parent = this); + moduleElements && (moduleElements.parent = this); + } + ModuleDeclaration.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(modifiers, identifier, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionDeclaration.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(modifiers, declaration) { + _super.call(this); + this.modifiers = modifiers; + this.declaration = declaration; + declaration && (declaration.parent = this); + } + VariableStatement.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + declarators && (declarators.parent = this); + } + VariableDeclaration.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + VariableDeclarator.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + return VariableDeclarator; + })(AST); + TypeScript.VariableDeclarator = VariableDeclarator; + + var EqualsValueClause = (function (_super) { + __extends(EqualsValueClause, _super); + function EqualsValueClause(value) { + _super.call(this); + this.value = value; + value && (value.parent = this); + } + EqualsValueClause.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + return EqualsValueClause; + })(AST); + TypeScript.EqualsValueClause = EqualsValueClause; + + var PrefixUnaryExpression = (function (_super) { + __extends(PrefixUnaryExpression, _super); + function PrefixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PrefixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ArrayLiteralExpression = (function (_super) { + __extends(ArrayLiteralExpression, _super); + function ArrayLiteralExpression(expressions) { + _super.call(this); + this.expressions = expressions; + expressions && (expressions.parent = this); + } + ArrayLiteralExpression.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + 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; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + 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; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(openParenTrailingComments, expression) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.expression = expression; + expression && (expression.parent = this); + } + ParenthesizedExpression.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + 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; + + var SimpleArrowFunctionExpression = (function (_super) { + __extends(SimpleArrowFunctionExpression, _super); + function SimpleArrowFunctionExpression(identifier, block, expression) { + _super.call(this); + this.identifier = identifier; + this.block = block; + this.expression = expression; + identifier && (identifier.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + SimpleArrowFunctionExpression.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return SimpleArrowFunctionExpression; + })(AST); + TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; + + var ParenthesizedArrowFunctionExpression = (function (_super) { + __extends(ParenthesizedArrowFunctionExpression, _super); + function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + this.expression = expression; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + ParenthesizedArrowFunctionExpression.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return ParenthesizedArrowFunctionExpression; + })(AST); + TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; + + var QualifiedName = (function (_super) { + __extends(QualifiedName, _super); + function QualifiedName(left, right) { + _super.call(this); + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + QualifiedName.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedName.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); + }; + return QualifiedName; + })(AST); + TypeScript.QualifiedName = QualifiedName; + + var ParameterList = (function (_super) { + __extends(ParameterList, _super); + function ParameterList(openParenTrailingComments, parameters) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.parameters = parameters; + parameters && (parameters.parent = this); + } + ParameterList.prototype.kind = function () { + return 227 /* ParameterList */; + }; + return ParameterList; + })(AST); + TypeScript.ParameterList = ParameterList; + + var ConstructorType = (function (_super) { + __extends(ConstructorType, _super); + function ConstructorType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + ConstructorType.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + return ConstructorType; + })(AST); + TypeScript.ConstructorType = ConstructorType; + + var FunctionType = (function (_super) { + __extends(FunctionType, _super); + function FunctionType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + FunctionType.prototype.kind = function () { + return 123 /* FunctionType */; + }; + return FunctionType; + })(AST); + TypeScript.FunctionType = FunctionType; + + var ObjectType = (function (_super) { + __extends(ObjectType, _super); + function ObjectType(typeMembers) { + _super.call(this); + this.typeMembers = typeMembers; + typeMembers && (typeMembers.parent = this); + } + ObjectType.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); + }; + return ObjectType; + })(AST); + TypeScript.ObjectType = ObjectType; + + var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + ArrayType.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); + }; + return ArrayType; + })(AST); + TypeScript.ArrayType = ArrayType; + + var TypeArgumentList = (function (_super) { + __extends(TypeArgumentList, _super); + function TypeArgumentList(typeArguments) { + _super.call(this); + this.typeArguments = typeArguments; + typeArguments && (typeArguments.parent = this); + } + TypeArgumentList.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + return TypeArgumentList; + })(AST); + TypeScript.TypeArgumentList = TypeArgumentList; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArgumentList) { + _super.call(this); + this.name = name; + this.typeArgumentList = typeArgumentList; + name && (name.parent = this); + typeArgumentList && (typeArgumentList.parent = this); + } + GenericType.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + name && (name.parent = this); + } + TypeQuery.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceLeadingComments, closeBraceToken) { + _super.call(this); + this.statements = statements; + this.closeBraceLeadingComments = closeBraceLeadingComments; + this.closeBraceToken = closeBraceToken; + statements && (statements.parent = this); + } + Block.prototype.kind = function () { + return 146 /* Block */; + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + _super.call(this); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + Parameter.prototype.kind = function () { + return 242 /* Parameter */; + }; + return Parameter; + })(AST); + TypeScript.Parameter = Parameter; + + var MemberAccessExpression = (function (_super) { + __extends(MemberAccessExpression, _super); + function MemberAccessExpression(expression, name) { + _super.call(this); + this.expression = expression; + this.name = name; + expression && (expression.parent = this); + name && (name.parent = this); + } + MemberAccessExpression.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + 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; + + var PostfixUnaryExpression = (function (_super) { + __extends(PostfixUnaryExpression, _super); + function PostfixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PostfixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ElementAccessExpression = (function (_super) { + __extends(ElementAccessExpression, _super); + function ElementAccessExpression(expression, argumentExpression) { + _super.call(this); + this.expression = expression; + this.argumentExpression = argumentExpression; + expression && (expression.parent = this); + argumentExpression && (argumentExpression.parent = this); + } + ElementAccessExpression.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + 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; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + InvocationExpression.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + 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) { + _super.call(this); + this.typeArgumentList = typeArgumentList; + this.closeParenToken = closeParenToken; + this.arguments = _arguments; + + typeArgumentList && (typeArgumentList.parent = this); + _arguments && (_arguments.parent = this); + } + ArgumentList.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + return ArgumentList; + })(AST); + TypeScript.ArgumentList = ArgumentList; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, left, right) { + _super.call(this); + this._nodeType = _nodeType; + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + BinaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(condition, whenTrue, whenFalse) { + _super.call(this); + this.condition = condition; + this.whenTrue = whenTrue; + this.whenFalse = whenFalse; + condition && (condition.parent = this); + whenTrue && (whenTrue.parent = this); + whenFalse && (whenFalse.parent = this); + } + ConditionalExpression.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + 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; + + var ConstructSignature = (function (_super) { + __extends(ConstructSignature, _super); + function ConstructSignature(callSignature) { + _super.call(this); + this.callSignature = callSignature; + callSignature && (callSignature.parent = this); + } + ConstructSignature.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + return ConstructSignature; + })(AST); + TypeScript.ConstructSignature = ConstructSignature; + + var MethodSignature = (function (_super) { + __extends(MethodSignature, _super); + function MethodSignature(propertyName, questionToken, callSignature) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + } + MethodSignature.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + return MethodSignature; + })(AST); + TypeScript.MethodSignature = MethodSignature; + + var IndexSignature = (function (_super) { + __extends(IndexSignature, _super); + function IndexSignature(parameter, typeAnnotation) { + _super.call(this); + this.parameter = parameter; + this.typeAnnotation = typeAnnotation; + parameter && (parameter.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + IndexSignature.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + return IndexSignature; + })(AST); + TypeScript.IndexSignature = IndexSignature; + + var PropertySignature = (function (_super) { + __extends(PropertySignature, _super); + function PropertySignature(propertyName, questionToken, typeAnnotation) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + PropertySignature.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + return PropertySignature; + })(AST); + TypeScript.PropertySignature = PropertySignature; + + var CallSignature = (function (_super) { + __extends(CallSignature, _super); + function CallSignature(typeParameterList, parameterList, typeAnnotation) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + CallSignature.prototype.kind = function () { + return 142 /* CallSignature */; + }; + return CallSignature; + })(AST); + TypeScript.CallSignature = CallSignature; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(identifier, constraint) { + _super.call(this); + this.identifier = identifier; + this.constraint = constraint; + identifier && (identifier.parent = this); + constraint && (constraint.parent = this); + } + TypeParameter.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + Constraint.prototype.kind = function () { + return 239 /* Constraint */; + }; + return Constraint; + })(AST); + TypeScript.Constraint = Constraint; + + var ElseClause = (function (_super) { + __extends(ElseClause, _super); + function ElseClause(statement) { + _super.call(this); + this.statement = statement; + statement && (statement.parent = this); + } + ElseClause.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ElseClause; + })(AST); + TypeScript.ElseClause = ElseClause; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(condition, statement, elseClause) { + _super.call(this); + this.condition = condition; + this.statement = statement; + this.elseClause = elseClause; + condition && (condition.parent = this); + statement && (statement.parent = this); + elseClause && (elseClause.parent = this); + } + IfStatement.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ExpressionStatement.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var ConstructorDeclaration = (function (_super) { + __extends(ConstructorDeclaration, _super); + function ConstructorDeclaration(callSignature, block) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + ConstructorDeclaration.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + return ConstructorDeclaration; + })(AST); + TypeScript.ConstructorDeclaration = ConstructorDeclaration; + + var MemberFunctionDeclaration = (function (_super) { + __extends(MemberFunctionDeclaration, _super); + function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + MemberFunctionDeclaration.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + return MemberFunctionDeclaration; + })(AST); + TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; + + var GetAccessor = (function (_super) { + __extends(GetAccessor, _super); + function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + GetAccessor.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + return GetAccessor; + })(AST); + TypeScript.GetAccessor = GetAccessor; + + var SetAccessor = (function (_super) { + __extends(SetAccessor, _super); + function SetAccessor(modifiers, propertyName, parameterList, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + block && (block.parent = this); + } + SetAccessor.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + return SetAccessor; + })(AST); + TypeScript.SetAccessor = SetAccessor; + + var MemberVariableDeclaration = (function (_super) { + __extends(MemberVariableDeclaration, _super); + function MemberVariableDeclaration(modifiers, variableDeclarator) { + _super.call(this); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + variableDeclarator && (variableDeclarator.parent = this); + } + MemberVariableDeclaration.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + return MemberVariableDeclaration; + })(AST); + TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; + + var IndexMemberDeclaration = (function (_super) { + __extends(IndexMemberDeclaration, _super); + function IndexMemberDeclaration(indexSignature) { + _super.call(this); + this.indexSignature = indexSignature; + indexSignature && (indexSignature.parent = this); + } + IndexMemberDeclaration.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + return IndexMemberDeclaration; + })(AST); + TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ThrowStatement.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ReturnStatement.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + ObjectCreationExpression.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + 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; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(expression, closeParenToken, switchClauses) { + _super.call(this); + this.expression = expression; + this.closeParenToken = closeParenToken; + this.switchClauses = switchClauses; + expression && (expression.parent = this); + switchClauses && (switchClauses.parent = this); + } + SwitchStatement.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseSwitchClause = (function (_super) { + __extends(CaseSwitchClause, _super); + function CaseSwitchClause(expression, statements) { + _super.call(this); + this.expression = expression; + this.statements = statements; + expression && (expression.parent = this); + statements && (statements.parent = this); + } + CaseSwitchClause.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return CaseSwitchClause; + })(AST); + TypeScript.CaseSwitchClause = CaseSwitchClause; + + var DefaultSwitchClause = (function (_super) { + __extends(DefaultSwitchClause, _super); + function DefaultSwitchClause(statements) { + _super.call(this); + this.statements = statements; + statements && (statements.parent = this); + } + DefaultSwitchClause.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return DefaultSwitchClause; + })(AST); + TypeScript.DefaultSwitchClause = DefaultSwitchClause; + + var BreakStatement = (function (_super) { + __extends(BreakStatement, _super); + function BreakStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + BreakStatement.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return BreakStatement; + })(AST); + TypeScript.BreakStatement = BreakStatement; + + var ContinueStatement = (function (_super) { + __extends(ContinueStatement, _super); + function ContinueStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + ContinueStatement.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ContinueStatement; + })(AST); + TypeScript.ContinueStatement = ContinueStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.condition = condition; + this.incrementor = incrementor; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + initializer && (initializer.parent = this); + condition && (condition.parent = this); + incrementor && (incrementor.parent = this); + statement && (statement.parent = this); + } + ForStatement.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(variableDeclaration, left, expression, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.left = left; + this.expression = expression; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + left && (left.parent = this); + expression && (expression.parent = this); + statement && (statement.parent = this); + } + ForInStatement.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WhileStatement.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WithStatement.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var EnumDeclaration = (function (_super) { + __extends(EnumDeclaration, _super); + function EnumDeclaration(modifiers, identifier, enumElements) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.enumElements = enumElements; + identifier && (identifier.parent = this); + enumElements && (enumElements.parent = this); + } + EnumDeclaration.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + return EnumDeclaration; + })(AST); + TypeScript.EnumDeclaration = EnumDeclaration; + + var EnumElement = (function (_super) { + __extends(EnumElement, _super); + function EnumElement(propertyName, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + EnumElement.prototype.kind = function () { + return 243 /* EnumElement */; + }; + return EnumElement; + })(AST); + TypeScript.EnumElement = EnumElement; + + var CastExpression = (function (_super) { + __extends(CastExpression, _super); + function CastExpression(type, expression) { + _super.call(this); + this.type = type; + this.expression = expression; + type && (type.parent = this); + expression && (expression.parent = this); + } + CastExpression.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + 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; + + var ObjectLiteralExpression = (function (_super) { + __extends(ObjectLiteralExpression, _super); + function ObjectLiteralExpression(propertyAssignments) { + _super.call(this); + this.propertyAssignments = propertyAssignments; + propertyAssignments && (propertyAssignments.parent = this); + } + ObjectLiteralExpression.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + 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; + + var SimplePropertyAssignment = (function (_super) { + __extends(SimplePropertyAssignment, _super); + function SimplePropertyAssignment(propertyName, expression) { + _super.call(this); + this.propertyName = propertyName; + this.expression = expression; + propertyName && (propertyName.parent = this); + expression && (expression.parent = this); + } + SimplePropertyAssignment.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + return SimplePropertyAssignment; + })(AST); + TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; + + var FunctionPropertyAssignment = (function (_super) { + __extends(FunctionPropertyAssignment, _super); + function FunctionPropertyAssignment(propertyName, callSignature, block) { + _super.call(this); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionPropertyAssignment.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + return FunctionPropertyAssignment; + })(AST); + TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; + + var FunctionExpression = (function (_super) { + __extends(FunctionExpression, _super); + function FunctionExpression(identifier, callSignature, block) { + _super.call(this); + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionExpression.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; + return FunctionExpression; + })(AST); + TypeScript.FunctionExpression = FunctionExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(block, catchClause, finallyClause) { + _super.call(this); + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + block && (block.parent = this); + catchClause && (catchClause.parent = this); + finallyClause && (finallyClause.parent = this); + } + TryStatement.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(identifier, typeAnnotation, block) { + _super.call(this); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.block = block; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + CatchClause.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var FinallyClause = (function (_super) { + __extends(FinallyClause, _super); + function FinallyClause(block) { + _super.call(this); + this.block = block; + block && (block.parent = this); + } + FinallyClause.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return FinallyClause; + })(AST); + TypeScript.FinallyClause = FinallyClause; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + identifier && (identifier.parent = this); + statement && (statement.parent = this); + } + LabeledStatement.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(statement, whileKeyword, condition) { + _super.call(this); + this.statement = statement; + this.whileKeyword = whileKeyword; + this.condition = condition; + statement && (statement.parent = this); + condition && (condition.parent = this); + } + DoStatement.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var TypeOfExpression = (function (_super) { + __extends(TypeOfExpression, _super); + function TypeOfExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + TypeOfExpression.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + 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; + + var DeleteExpression = (function (_super) { + __extends(DeleteExpression, _super); + function DeleteExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + DeleteExpression.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + 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; + + var VoidExpression = (function (_super) { + __extends(VoidExpression, _super); + function VoidExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + VoidExpression.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + 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; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var Comment = (function () { + function Comment(_trivia, endsLine, _start, _end) { + this._trivia = _trivia; + this.endsLine = endsLine; + this._start = _start; + this._end = _end; + } + Comment.prototype.start = function () { + return this._start; + }; + + Comment.prototype.end = function () { + return this._end; + }; + + Comment.prototype.fullText = function () { + return this._trivia.fullText(); + }; + + Comment.prototype.kind = function () { + return this._trivia.kind(); + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; + }; + return Comment; + })(); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IOUtils) { + function createDirectoryStructure(ioHost, dirName) { + if (ioHost.directoryExists(dirName)) { + return; + } + + var parentDirectory = ioHost.dirName(dirName); + if (parentDirectory != "") { + createDirectoryStructure(ioHost, parentDirectory); + } + ioHost.createDirectory(dirName); + } + + function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + var path = ioHost.resolvePath(fileName); + TypeScript.ioHostResolvePathTime += new Date().getTime() - start; + + var start = new Date().getTime(); + var dirName = ioHost.dirName(path); + TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start; + + var start = new Date().getTime(); + createDirectoryStructure(ioHost, dirName); + TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start; + + var start = new Date().getTime(); + ioHost.writeFile(path, contents, writeByteOrderMark); + TypeScript.ioHostWriteFileTime += new Date().getTime() - start; + } + IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; + + function throwIOError(message, error) { + var errorMessage = message; + if (error && error.message) { + errorMessage += (" " + error.message); + } + throw new Error(errorMessage); + } + IOUtils.throwIOError = throwIOError; + + function combine(prefix, suffix) { + return prefix + "/" + suffix; + } + IOUtils.combine = combine; + + var BufferedTextWriter = (function () { + function BufferedTextWriter(writer, capacity) { + if (typeof capacity === "undefined") { capacity = 1024; } + this.writer = writer; + this.capacity = capacity; + this.buffer = ""; + } + BufferedTextWriter.prototype.Write = function (str) { + this.buffer += str; + if (this.buffer.length >= this.capacity) { + this.writer.Write(this.buffer); + this.buffer = ""; + } + }; + BufferedTextWriter.prototype.WriteLine = function (str) { + this.Write(str + '\r\n'); + }; + BufferedTextWriter.prototype.Close = function () { + this.writer.Write(this.buffer); + this.writer.Close(); + this.buffer = null; + }; + return BufferedTextWriter; + })(); + IOUtils.BufferedTextWriter = BufferedTextWriter; + })(TypeScript.IOUtils || (TypeScript.IOUtils = {})); + var IOUtils = TypeScript.IOUtils; + + TypeScript.IO = (function () { + function getWindowsScriptHostIO() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + 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); + }, + writeFile: function (path, contents, writeByteOrderMark) { + TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + dirName: function (path) { + return fso.GetParentFolderName(path); + }, + findFile: function (rootPath, partialFilePath) { + var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; + + while (true) { + if (fso.FileExists(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); + + if (rootPath == "") { + return null; + } else { + path = fso.BuildPath(rootPath, partialFilePath); + } + } + } + }, + deleteFile: function (path) { + try { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + fso.CreateFolder(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + dir: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "/" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + print: function (str) { + WScript.StdOut.Write(str); + }, + printLine: function (str) { + WScript.Echo(str); + }, + arguments: args, + stderr: WScript.StdErr, + stdout: WScript.StdOut, + watchFile: null, + run: function (source, fileName) { + try { + eval(source); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Error_while_executing_file_0, [fileName]), e); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + quit: function (exitCode) { + if (typeof exitCode === "undefined") { exitCode = 0; } + try { + WScript.Quit(exitCode); + } catch (e) { + } + } + }; + } + ; + + function getNodeIO() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + + return { + appendFile: function (path, content) { + _fs.appendFileSync(path, content); + }, + readFile: function (file, codepage) { + return TypeScript.Environment.readFile(file, codepage); + }, + writeFile: function (path, contents, writeByteOrderMark) { + TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + dir: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + try { + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "/" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "/" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "/" + files[i]); + } + } + } catch (err) { + } + + return paths; + } + + return filesInFolder(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + _fs.mkdirSync(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + dirName: function (path) { + var dirPath = _path.dirname(path); + + if (dirPath === path) { + dirPath = null; + } + + return dirPath; + }, + findFile: function (rootPath, partialFilePath) { + var path = rootPath + "/" + partialFilePath; + + while (true) { + if (_fs.existsSync(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + var parentPath = _path.resolve(rootPath, ".."); + + if (rootPath === parentPath) { + return null; + } else { + rootPath = parentPath; + path = _path.resolve(rootPath, partialFilePath); + } + } + } + }, + print: function (str) { + process.stdout.write(str); + }, + printLine: function (str) { + process.stdout.write(str + '\n'); + }, + arguments: process.argv.slice(2), + stderr: { + Write: function (str) { + process.stderr.write(str); + }, + WriteLine: function (str) { + process.stderr.write(str + '\n'); + }, + Close: function () { + } + }, + stdout: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + }, + watchFile: function (fileName, callback) { + var firstRun = true; + var processingChange = false; + + var fileChanged = function (curr, prev) { + if (!firstRun) { + if (curr.mtime < prev.mtime) { + return; + } + + _fs.unwatchFile(fileName, fileChanged); + if (!processingChange) { + processingChange = true; + callback(fileName); + setTimeout(function () { + processingChange = false; + }, 100); + } + } + firstRun = false; + _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); + }; + + fileChanged(); + return { + fileName: fileName, + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + }, + run: function (source, fileName) { + require.main.fileName = fileName; + require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); + require.main._compile(source, fileName); + }, + getExecutingFilePath: function () { + return process.mainModule.filename; + }, + quit: function (code) { + var stderrFlushed = process.stderr.write(''); + var stdoutFlushed = process.stdout.write(''); + process.stderr.on('drain', function () { + stderrFlushed = true; + if (stdoutFlushed) { + process.exit(code); + } + }); + process.stdout.on('drain', function () { + stdoutFlushed = true; + if (stderrFlushed) { + process.exit(code); + } + }); + setTimeout(function () { + process.exit(code); + }, 5); + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") + return getWindowsScriptHostIO(); + else if (typeof module !== 'undefined' && module.exports) + return getNodeIO(); + else + return null; + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OptionsParser = (function () { + function OptionsParser(host, version) { + this.host = host; + this.version = version; + this.DEFAULT_SHORT_FLAG = "-"; + this.DEFAULT_LONG_FLAG = "--"; + this.printedVersion = false; + this.unnamed = []; + this.options = []; + } + OptionsParser.prototype.findOption = function (arg) { + var upperCaseArg = arg && arg.toUpperCase(); + + for (var i = 0; i < this.options.length; i++) { + var current = this.options[i]; + + if (upperCaseArg === (current.short && current.short.toUpperCase()) || upperCaseArg === (current.name && current.name.toUpperCase())) { + return current; + } + } + + return null; + }; + + OptionsParser.prototype.printUsage = function () { + this.printVersion(); + + var optionsWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.options, null); + var fileWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.file1, null); + var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]"; + var syntaxHelp = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Syntax_0, [tscSyntax]); + this.host.printLine(syntaxHelp); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Examples, null) + " tsc hello.ts"); + this.host.printLine(" tsc --out foo.js foo.ts"); + this.host.printLine(" tsc @args.txt"); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Options, null)); + + var output = []; + var maxLength = 0; + var i = 0; + + this.options = this.options.sort(function (a, b) { + var aName = a.name.toLowerCase(); + var bName = b.name.toLowerCase(); + + if (aName > bName) { + return 1; + } else if (aName < bName) { + return -1; + } else { + return 0; + } + }); + + for (i = 0; i < this.options.length; i++) { + var option = this.options[i]; + + if (option.experimental) { + continue; + } + + if (!option.usage) { + break; + } + + var usageString = " "; + var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : ""; + + if (option.short) { + usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; + } + + usageString += this.DEFAULT_LONG_FLAG + option.name + type; + + output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]); + + if (usageString.length > maxLength) { + maxLength = usageString.length; + } + } + + var fileDescription = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null); + output.push([" @<" + fileWord + ">", fileDescription]); + + for (i = 0; i < output.length; i++) { + this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); + } + }; + + OptionsParser.prototype.printVersion = function () { + if (!this.printedVersion) { + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Version_0, [this.version])); + this.printedVersion = true; + } + }; + + OptionsParser.prototype.option = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = false; + + this.options.push(config); + }; + + OptionsParser.prototype.flag = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = true; + + this.options.push(config); + }; + + OptionsParser.prototype.parseString = function (argString) { + var position = 0; + var tokens = argString.match(/\s+|"|[^\s"]+/g); + + function peek() { + return tokens[position]; + } + + function consume() { + return tokens[position++]; + } + + function consumeQuotedString() { + var value = ''; + consume(); + + var token = peek(); + + while (token && token !== '"') { + consume(); + + value += token; + + token = peek(); + } + + consume(); + + return value; + } + + var args = []; + var currentArg = ''; + + while (position < tokens.length) { + var token = peek(); + + if (token === '"') { + currentArg += consumeQuotedString(); + } else if (token.match(/\s/)) { + if (currentArg.length > 0) { + args.push(currentArg); + currentArg = ''; + } + + consume(); + } else { + consume(); + currentArg += token; + } + } + + if (currentArg.length > 0) { + args.push(currentArg); + } + + this.parse(args); + }; + + OptionsParser.prototype.parse = function (args) { + var position = 0; + + function consume() { + return args[position++]; + } + + while (position < args.length) { + var current = consume(); + var match = current.match(/^(--?|@)(.*)/); + var value = null; + + if (match) { + if (match[1] === '@') { + this.parseString(this.host.readFile(match[2], null).contents); + } else { + var arg = match[2]; + var option = this.findOption(arg); + + if (option === null) { + this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_option_0, [arg])); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); + } else { + if (!option.flag) { + value = consume(); + if (value === undefined) { + this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Option_0_specified_without_1, [arg, TypeScript.getLocalizedText(option.type, null)])); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); + continue; + } + } + + option.set(value); + } + } + } else { + this.unnamed.push(current); + } + } + }; + return OptionsParser; + })(); + TypeScript.OptionsParser = OptionsParser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceFile = (function () { + function SourceFile(scriptSnapshot, byteOrderMark) { + this.scriptSnapshot = scriptSnapshot; + this.byteOrderMark = byteOrderMark; + } + return SourceFile; + })(); + + var DiagnosticsLogger = (function () { + function DiagnosticsLogger(ioHost) { + this.ioHost = ioHost; + } + DiagnosticsLogger.prototype.information = function () { + return false; + }; + DiagnosticsLogger.prototype.debug = function () { + return false; + }; + DiagnosticsLogger.prototype.warning = function () { + return false; + }; + DiagnosticsLogger.prototype.error = function () { + return false; + }; + DiagnosticsLogger.prototype.fatal = function () { + return false; + }; + DiagnosticsLogger.prototype.log = function (s) { + this.ioHost.stdout.WriteLine(s); + }; + 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.7.0"; + this.inputFiles = []; + this.resolvedFiles = []; + this.fileNameToSourceFile = new TypeScript.StringHashTable(); + this.hasErrors = false; + this.logger = null; + this.fileExistsCache = TypeScript.createIntrinsicsObject(); + this.resolvePathCache = TypeScript.createIntrinsicsObject(); + } + BatchCompiler.prototype.batchCompile = function () { + var _this = this; + var start = new Date().getTime(); + + TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { + _this.ioHost.printLine(s); + } }; + + if (this.parseOptions()) { + 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(); + return; + } + + this.resolve(); + + 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); + this.logger.log(" file read: " + TypeScript.fileResolutionIOTime); + this.logger.log(" scan imports: " + TypeScript.fileResolutionScanImportsTime); + this.logger.log(" import search: " + TypeScript.fileResolutionImportFileSearchTime); + this.logger.log(" get lib.d.ts: " + TypeScript.fileResolutionGetDefaultLibraryTime); + + this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime); + this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime); + this.logger.log("AST translation time: " + TypeScript.astTranslationTime); + this.logger.log(""); + this.logger.log("Type check time: " + TypeScript.typeCheckTime); + this.logger.log(""); + this.logger.log("Emit time: " + TypeScript.emitTime); + this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime); + + this.logger.log("Total number of symbols created: " + TypeScript.pullSymbolID); + this.logger.log("Specialized types created: " + TypeScript.nSpecializationsCreated); + this.logger.log("Specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); + + this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime); + this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime); + this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime); + this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime); + this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime); + this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime); + this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime); + this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime); + this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime); + + this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime); + + this.logger.log("Compiler resolve path time: " + TypeScript.compilerResolvePathTime); + this.logger.log("Compiler directory name time: " + TypeScript.compilerDirectoryNameTime); + this.logger.log("Compiler directory exists time: " + TypeScript.compilerDirectoryExistsTime); + this.logger.log("Compiler file exists time: " + TypeScript.compilerFileExistsTime); + + this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime); + this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime); + this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime); + this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime); + + this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime); + this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime); + this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime); + } + } + + this.ioHost.quit(this.hasErrors ? 1 : 0); + }; + + BatchCompiler.prototype.resolve = function () { + var _this = this; + var includeDefaultLibrary = !this.compilationSettings.noLib(); + var resolvedFiles = []; + + var start = new Date().getTime(); + + if (!this.compilationSettings.noResolve()) { + var resolutionResults = TypeScript.ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings.useCaseSensitiveFileResolution()); + resolvedFiles = resolutionResults.resolvedFiles; + + includeDefaultLibrary = !this.compilationSettings.noLib() && !resolutionResults.seenNoDefaultLibTag; + + resolutionResults.diagnostics.forEach(function (d) { + return _this.addDiagnostic(d); + }); + } else { + for (var i = 0, n = this.inputFiles.length; i < n; i++) { + var inputFile = this.inputFiles[i]; + var referencedFiles = []; + var importedFiles = []; + + if (this.compilationSettings.generateDeclarationFiles()) { + var references = TypeScript.getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile)); + for (var j = 0; j < references.length; j++) { + referencedFiles.push(references[j].path); + } + + inputFile = this.resolvePath(inputFile); + } + + resolvedFiles.push({ + path: inputFile, + referencedFiles: referencedFiles, + importedFiles: importedFiles + }); + } + } + + var defaultLibStart = new Date().getTime(); + if (includeDefaultLibrary) { + var libraryResolvedFile = { + path: this.getDefaultLibraryFilePath(), + referencedFiles: [], + importedFiles: [] + }; + + resolvedFiles = [libraryResolvedFile].concat(resolvedFiles); + } + TypeScript.fileResolutionGetDefaultLibraryTime += new Date().getTime() - defaultLibStart; + + this.resolvedFiles = resolvedFiles; + + TypeScript.fileResolutionTime = new Date().getTime() - start; + }; + + BatchCompiler.prototype.compile = function () { + var _this = this; + var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); + + this.resolvedFiles.forEach(function (resolvedFile) { + var sourceFile = _this.getSourceFile(resolvedFile.path); + compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, false, resolvedFile.referencedFiles); + }); + + for (var it = compiler.compile(function (path) { + return _this.resolvePath(path); + }); it.moveNext();) { + var result = it.current(); + + result.diagnostics.forEach(function (d) { + return _this.addDiagnostic(d); + }); + if (!this.tryWriteOutputFiles(result.outputFiles)) { + return; + } + } + }; + + BatchCompiler.prototype.parseOptions = function () { + var _this = this; + var opts = new TypeScript.OptionsParser(this.ioHost, this.compilerVersion); + + var mutableSettings = new TypeScript.CompilationSettings(); + opts.option('out', { + usage: { + locCode: TypeScript.DiagnosticCode.Concatenate_and_emit_output_to_single_file, + args: null + }, + type: TypeScript.DiagnosticCode.file2, + set: function (str) { + mutableSettings.outFileOption = str; + } + }); + + opts.option('outDir', { + usage: { + locCode: TypeScript.DiagnosticCode.Redirect_output_structure_to_the_directory, + args: null + }, + type: TypeScript.DiagnosticCode.DIRECTORY, + set: function (str) { + mutableSettings.outDirOption = str; + } + }); + + opts.flag('sourcemap', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.map'] + }, + set: function () { + mutableSettings.mapSourceFiles = true; + } + }); + + opts.option('mapRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + mutableSettings.mapRoot = str; + } + }); + + opts.option('sourceRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + mutableSettings.sourceRoot = str; + } + }); + + opts.flag('declaration', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.d.ts'] + }, + set: function () { + mutableSettings.generateDeclarationFiles = true; + } + }, 'd'); + + if (this.ioHost.watchFile) { + opts.flag('watch', { + usage: { + locCode: TypeScript.DiagnosticCode.Watch_input_files, + args: null + }, + set: function () { + mutableSettings.watch = true; + } + }, 'w'); + } + + opts.flag('propagateEnumConstants', { + experimental: true, + set: function () { + mutableSettings.propagateEnumConstants = true; + } + }); + + opts.flag('removeComments', { + usage: { + locCode: TypeScript.DiagnosticCode.Do_not_emit_comments_to_output, + args: null + }, + set: function () { + mutableSettings.removeComments = true; + } + }); + + opts.flag('noResolve', { + experimental: true, + usage: { + locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, + args: null + }, + set: function () { + mutableSettings.noResolve = true; + } + }); + + opts.flag('noLib', { + experimental: true, + set: function () { + mutableSettings.noLib = true; + } + }); + + opts.flag('diagnostics', { + experimental: true, + set: function () { + mutableSettings.gatherDiagnostics = true; + } + }); + + 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, + args: ['ES3', 'ES5'] + }, + type: TypeScript.DiagnosticCode.VERSION, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'es3') { + mutableSettings.codeGenTarget = 0 /* EcmaScript3 */; + } else if (type === 'es5') { + mutableSettings.codeGenTarget = 1 /* EcmaScript5 */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2, [type, "ES3", "ES5"])); + } + } + }, 't'); + + opts.option('module', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1, + args: ['commonjs', 'amd'] + }, + type: TypeScript.DiagnosticCode.KIND, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'commonjs') { + mutableSettings.moduleGenTarget = 1 /* Synchronous */; + } else if (type === 'amd') { + mutableSettings.moduleGenTarget = 2 /* Asynchronous */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type])); + } + } + }, 'm'); + + var needsHelp = false; + opts.flag('help', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_this_message, + args: null + }, + set: function () { + needsHelp = true; + } + }, 'h'); + + opts.flag('useCaseSensitiveFileResolution', { + experimental: true, + set: function () { + mutableSettings.useCaseSensitiveFileResolution = true; + } + }); + var shouldPrintVersionOnly = false; + opts.flag('version', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_the_compiler_s_version_0, + args: [this.compilerVersion] + }, + set: function () { + shouldPrintVersionOnly = true; + } + }, 'v'); + + var locale = null; + opts.option('locale', { + experimental: true, + usage: { + locCode: TypeScript.DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1, + args: ['en', 'ja-jp'] + }, + type: TypeScript.DiagnosticCode.STRING, + set: function (value) { + locale = value; + } + }); + + opts.flag('noImplicitAny', { + usage: { + locCode: TypeScript.DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, + args: null + }, + set: function () { + mutableSettings.noImplicitAny = true; + } + }); + + if (TypeScript.Environment.supportsCodePage()) { + opts.option('codepage', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_the_codepage_to_use_when_opening_source_files, + args: null + }, + type: TypeScript.DiagnosticCode.NUMBER, + set: function (arg) { + mutableSettings.codepage = parseInt(arg, 10); + } + }); + } + + opts.parse(this.ioHost.arguments); + + this.compilationSettings = TypeScript.ImmutableCompilationSettings.fromCompilationSettings(mutableSettings); + + if (locale) { + if (!this.setLocale(locale)) { + return false; + } + } + + this.inputFiles.push.apply(this.inputFiles, opts.unnamed); + + if (shouldPrintVersionOnly) { + opts.printVersion(); + return false; + } else if (this.inputFiles.length === 0 || needsHelp) { + opts.printUsage(); + return false; + } + + return !this.hasErrors; + }; + + BatchCompiler.prototype.setLocale = function (locale) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp'])); + return false; + } + + var language = matchResult[1]; + var territory = matchResult[3]; + + if (!this.setLanguageAndTerritory(language, territory) && !this.setLanguageAndTerritory(language, null)) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Unsupported_locale_0, [locale])); + return false; + } + + return true; + }; + + BatchCompiler.prototype.setLanguageAndTerritory = function (language, territory) { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + + var filePath = TypeScript.IOUtils.combine(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + + filePath = this.resolvePath(TypeScript.IOUtils.combine(filePath, "diagnosticMessages.generated.json")); + + if (!this.fileExists(filePath)) { + return false; + } + + var fileContents = this.ioHost.readFile(filePath, this.compilationSettings.codepage()); + TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents); + return true; + }; + + BatchCompiler.prototype.watchFiles = function () { + var _this = this; + if (!this.ioHost.watchFile) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]'])); + return; + } + + var lastResolvedFileSet = []; + var watchers = {}; + var firstTime = true; + + var addWatcher = function (fileName) { + if (!watchers[fileName]) { + var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); + watchers[fileName] = watcher; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); + } + }; + + var removeWatcher = function (fileName) { + if (watchers[fileName]) { + watchers[fileName].close(); + delete watchers[fileName]; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); + } + }; + + var onWatchedFileChange = function () { + _this.hasErrors = false; + + _this.fileNameToSourceFile = new TypeScript.StringHashTable(); + + _this.resolve(); + + var oldFiles = lastResolvedFileSet; + var newFiles = _this.resolvedFiles.map(function (resolvedFile) { + return resolvedFile.path; + }).sort(); + + var i = 0, j = 0; + while (i < oldFiles.length && j < newFiles.length) { + var compareResult = oldFiles[i].localeCompare(newFiles[j]); + if (compareResult === 0) { + i++; + j++; + } else if (compareResult < 0) { + removeWatcher(oldFiles[i]); + i++; + } else { + addWatcher(newFiles[j]); + j++; + } + } + + for (var k = i; k < oldFiles.length; k++) { + removeWatcher(oldFiles[k]); + } + + for (k = j; k < newFiles.length; k++) { + addWatcher(newFiles[k]); + } + + lastResolvedFileSet = newFiles; + + if (!firstTime) { + var fileNames = ""; + for (var k = 0; k < lastResolvedFileSet.length; k++) { + fileNames += TypeScript.Environment.newLine + " " + lastResolvedFileSet[k]; + } + _this.ioHost.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.NL_Recompiling_0, [fileNames])); + } else { + firstTime = false; + } + + _this.compile(); + }; + + this.ioHost.stderr = this.ioHost.stdout; + + onWatchedFileChange(); + }; + + BatchCompiler.prototype.getSourceFile = function (fileName) { + var sourceFile = this.fileNameToSourceFile.lookup(fileName); + if (!sourceFile) { + var fileInformation; + + try { + fileInformation = this.ioHost.readFile(fileName, this.compilationSettings.codepage()); + } catch (e) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message])); + fileInformation = new TypeScript.FileInformation("", 0 /* None */); + } + + var snapshot = TypeScript.ScriptSnapshot.fromString(fileInformation.contents); + var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark); + this.fileNameToSourceFile.add(fileName, sourceFile); + } + + return sourceFile; + }; + + BatchCompiler.prototype.getDefaultLibraryFilePath = function () { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + var libraryFilePath = this.resolvePath(TypeScript.IOUtils.combine(containingDirectoryPath, "lib.d.ts")); + + return libraryFilePath; + }; + + BatchCompiler.prototype.getScriptSnapshot = function (fileName) { + return this.getSourceFile(fileName).scriptSnapshot; + }; + + BatchCompiler.prototype.resolveRelativePath = function (path, directory) { + var start = new Date().getTime(); + + var unQuotedPath = TypeScript.stripStartAndEndQuotes(path); + var normalizedPath; + + if (TypeScript.isRooted(unQuotedPath) || !directory) { + normalizedPath = unQuotedPath; + } else { + normalizedPath = TypeScript.IOUtils.combine(directory, unQuotedPath); + } + + normalizedPath = this.resolvePath(normalizedPath); + + normalizedPath = TypeScript.switchToForwardSlashes(normalizedPath); + + return normalizedPath; + }; + + BatchCompiler.prototype.fileExists = function (path) { + var exists = this.fileExistsCache[path]; + if (exists === undefined) { + var start = new Date().getTime(); + exists = this.ioHost.fileExists(path); + this.fileExistsCache[path] = exists; + TypeScript.compilerFileExistsTime += new Date().getTime() - start; + } + + return exists; + }; + + BatchCompiler.prototype.getParentDirectory = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.dirName(path); + TypeScript.compilerDirectoryNameTime += new Date().getTime() - start; + + return result; + }; + + BatchCompiler.prototype.addDiagnostic = function (diagnostic) { + var diagnosticInfo = diagnostic.info(); + if (diagnosticInfo.category === 1 /* Error */) { + this.hasErrors = true; + } + + this.ioHost.stderr.Write(TypeScript.TypeScriptCompiler.getFullDiagnosticText(diagnostic)); + }; + + BatchCompiler.prototype.tryWriteOutputFiles = function (outputFiles) { + for (var i = 0, n = outputFiles.length; i < n; i++) { + var outputFile = outputFiles[i]; + + try { + this.writeFile(outputFile.name, outputFile.text, outputFile.writeByteOrderMark); + } catch (e) { + this.addDiagnostic(new TypeScript.Diagnostic(outputFile.name, null, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])); + return false; + } + } + + return true; + }; + + BatchCompiler.prototype.writeFile = function (fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + TypeScript.IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark); + TypeScript.emitWriteFileTime += new Date().getTime() - start; + }; + + BatchCompiler.prototype.directoryExists = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.directoryExists(path); + TypeScript.compilerDirectoryExistsTime += new Date().getTime() - start; + return result; + }; + + BatchCompiler.prototype.resolvePath = function (path) { + var cachedValue = this.resolvePathCache[path]; + if (!cachedValue) { + var start = new Date().getTime(); + cachedValue = this.ioHost.resolvePath(path); + this.resolvePathCache[path] = cachedValue; + TypeScript.compilerResolvePathTime += new Date().getTime() - start; + } + + return cachedValue; + }; + return BatchCompiler; + })(); + TypeScript.BatchCompiler = BatchCompiler; + + var batch = new TypeScript.BatchCompiler(TypeScript.IO); + batch.batchCompile(); +})(TypeScript || (TypeScript = {})); diff --git a/_infrastructure/tests/typescript/0.9.7-59a846/typescript.js b/_infrastructure/tests/typescript/0.9.7-59a846/typescript.js new file mode 100644 index 0000000000..0a4100df0e --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-59a846/typescript.js @@ -0,0 +1,61371 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.DiagnosticCode = { + error_TS_0_1: "error TS{0}: {1}", + warning_TS_0_1: "warning TS{0}: {1}", + Unrecognized_escape_sequence: "Unrecognized escape sequence.", + Unexpected_character_0: "Unexpected character {0}.", + Missing_close_quote_character: "Missing close quote character.", + Identifier_expected: "Identifier expected.", + _0_keyword_expected: "'{0}' keyword expected.", + _0_expected: "'{0}' expected.", + Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", + Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", + Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", + Trailing_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", + Unexpected_token: "Unexpected token.", + Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", + Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", + Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", + Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", + Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", + Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", + extends_clause_already_seen: "'extends' clause already seen.", + extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", + Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", + implements_clause_already_seen: "'implements' clause already seen.", + Accessibility_modifier_already_seen: "Accessibility modifier already seen.", + _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", + _0_modifier_already_seen: "'{0}' modifier already seen.", + _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", + Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", + super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", + Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", + Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", + 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_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}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", + set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", + set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", + get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", + Modifiers_cannot_appear_here: "Modifiers cannot appear here.", + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", + Class_name_cannot_be_0: "Class name cannot be '{0}'.", + Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", + Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + Enum_member_must_have_initializer: "Enum member must have initializer.", + Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", + module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", + constructor_function_accessor_or_variable: "constructor, function, accessor or variable", + statement: "statement", + case_or_default_clause: "case or default clause", + identifier: "identifier", + call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", + expression: "expression", + type_name: "type name", + property_or_accessor: "property or accessor", + parameter: "parameter", + type: "type", + type_parameter: "type parameter", + 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_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.", + super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", + Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", + Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", + Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", + Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", + Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", + Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", + Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", + Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", + Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", + Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", + Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", + Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", + Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", + Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", + Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", + Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", + Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", + Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", + Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", + Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", + Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", + Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", + Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", + Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", + Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", + Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", + Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", + Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", + Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", + Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", + Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", + Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", + Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", + Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", + A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", + Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", + Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", + Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", + A_class_may_only_extend_another_class: "A class may only extend another class.", + A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", + An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", + Unable_to_resolve_type: "Unable to resolve type.", + Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", + Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", + Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", + Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", + Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", + Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", + Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", + Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", + Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + 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_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.", + _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.", + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", + Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", + Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", + 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_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}'.", + 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.", + Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", + Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", + Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", + All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", + Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", + Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", + this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", + Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", + Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", + 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_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.", + Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", + A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", + 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_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_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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", + Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", + Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", + 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_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}", + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", + Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", + All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", + super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", + Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", + Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", + Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", + Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", + Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", + continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", + break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", + Jump_target_not_found: "Jump target not found.", + Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", + TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", + TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", + TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", + TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", + TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", + TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", + Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", + 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}", + Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", + Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", + Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", + Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", + Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", + Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", + Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", + Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", + Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", + 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.", + 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_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_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.", + Could_not_find_file_0: "Could not find file: '{0}'.", + A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", + Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", + Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", + Emit_Error_0: "Emit Error: {0}.", + Cannot_read_file_0_1: "Cannot read file '{0}': {1}", + Unsupported_file_encoding: "Unsupported file encoding.", + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Invalid_call_to_up: "Invalid call to 'up'", + Invalid_call_to_down: "Invalid call to 'down'", + Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", + Unknown_option_0: "Unknown option '{0}'", + Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", + Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", + Could_not_delete_file_0: "Could not delete file '{0}'", + Could_not_create_directory_0: "Could not create directory '{0}'", + Error_while_executing_file_0: "Error while executing file '{0}': ", + Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", + Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", + Option_0_specified_without_1: "Option '{0}' specified without '{1}'", + codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", + Generates_corresponding_0_file: "Generates corresponding {0} file.", + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", + Watch_input_files: "Watch input files.", + Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", + Do_not_emit_comments_to_output: "Do not emit comments to output.", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", + Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", + Print_this_message: "Print this message.", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file1: "file", + Examples: "Examples:", + Options: "Options:", + Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", + Version_0: "Version {0}", + Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", + NL_Recompiling_0: "{NL}Recompiling ({0}):", + STRING: "STRING", + KIND: "KIND", + file2: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + 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})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", + Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", + Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", + Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", + Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", + new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", + _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", + Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", + 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.", + 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; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + return false; + } + + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0, n = array1.length; i < n; i++) { + if (!equals(array1[i], array2[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.distinct = function (array, equalsFn) { + var result = []; + + for (var i = 0, n = array.length; i < n; i++) { + var current = array[i]; + for (var j = 0; j < result.length; j++) { + if (equalsFn(result[j], current)) { + break; + } + } + + if (j === result.length) { + result.push(current); + } + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.lastOrDefault = function (array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var v = array[i]; + if (predicate(v, i)) { + return v; + } + } + + return null; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value, i)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.first = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (!func || func(value, i)) { + return value; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + var low = 0; + var high = array.length - 1; + + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + + if (midValue === value) { + return middle; + } else if (midValue > value) { + high = middle - 1; + } else { + low = middle + 1; + } + } + + return ~low; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + + ArrayUtilities.indexOf = function (array, predicate) { + for (var i = 0, n = array.length; i < n; i++) { + if (predicate(array[i])) { + return i; + } + } + + return -1; + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitVector) { + var pool = []; + var Constants; + (function (Constants) { + Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; + Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; + + Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; + + Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; + Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; + + Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; + Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; + Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; + })(Constants || (Constants = {})); + + var BitVectorImpl = (function () { + function BitVectorImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.bits = []; + } + BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; + }; + + BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; + }; + + BitVectorImpl.prototype.valueAt = function (index) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return undefined; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { + return true; + } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { + return false; + } else { + return undefined; + } + } else { + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return false; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { + return true; + } else { + return false; + } + } + }; + + BitVectorImpl.prototype.setValueAt = function (index, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); + + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === undefined) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + + var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); + encoded = encoded & clearMask; + + if (value === true) { + encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); + } else if (value === false) { + encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } else { + TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); + + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === false) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + + encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); + + if (value) { + encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } + }; + + BitVectorImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + this.bits.length = 0; + pool.push(this); + }; + return BitVectorImpl; + })(); + + function getBitVector(allowUndefinedValues) { + if (pool.length === 0) { + return new BitVectorImpl(allowUndefinedValues); + } + + var vector = pool.pop(); + vector.isReleased = false; + vector.allowUndefinedValues = allowUndefinedValues; + + return vector; + } + BitVector.getBitVector = getBitVector; + })(TypeScript.BitVector || (TypeScript.BitVector = {})); + var BitVector = TypeScript.BitVector; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitMatrix) { + var pool = []; + + var BitMatrixImpl = (function () { + function BitMatrixImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.vectors = []; + } + BitMatrixImpl.prototype.valueAt = function (x, y) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + return this.allowUndefinedValues ? undefined : false; + } + + return vector.valueAt(y); + }; + + BitMatrixImpl.prototype.setValueAt = function (x, y, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + if (value === undefined) { + return; + } + + vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); + this.vectors[x] = vector; + } + + vector.setValueAt(y, value); + }; + + BitMatrixImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + + for (var name in this.vectors) { + if (this.vectors.hasOwnProperty(name)) { + var vector = this.vectors[name]; + vector.release(); + } + } + + this.vectors.length = 0; + pool.push(this); + }; + return BitMatrixImpl; + })(); + + function getBitMatrix(allowUndefinedValues) { + if (pool.length === 0) { + return new BitMatrixImpl(allowUndefinedValues); + } + + var matrix = pool.pop(); + matrix.isReleased = false; + matrix.allowUndefinedValues = allowUndefinedValues; + + return matrix; + } + BitMatrix.getBitMatrix = getBitMatrix; + })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); + var BitMatrix = TypeScript.BitMatrix; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); + var AssertionLevel = TypeScript.AssertionLevel; + + var Debug = (function () { + function Debug() { + } + Debug.shouldAssert = function (level) { + return this.currentAssertionLevel >= level; + }; + + Debug.assert = function (expression, message, verboseDebugInfo) { + if (typeof message === "undefined") { message = ""; } + if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); + } + + throw new Error("Debug Failure. False expression: " + message + verboseDebugString); + } + }; + + Debug.fail = function (message) { + Debug.assert(false, message); + }; + Debug.currentAssertionLevel = 0 /* None */; + return Debug; + })(); + 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 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(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; + } + + return result; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return this._additionalLocations || []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + + Diagnostic.prototype.info = function () { + return getDiagnosticInfoFromKey(this.diagnosticKey()); + }; + return Diagnostic; + })(Location); + TypeScript.Diagnostic = Diagnostic; + + function newLine() { + return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while (match = regex.exec(diagnostic)) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result); + return result; + } + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); + } + + diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { + return typeof args[num] !== 'undefined' ? args[num] : match; + }); + + diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { + return TypeScript.newLine(); + }); + + return diagnosticMessageText; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error("Invalid argument: " + argument + ". " + message); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error("Argument out of range: " + argument); + }; + + Errors.argumentNull = function (argument) { + return new Error("Argument null: " + argument); + }; + + Errors.abstract = function () { + return new Error("Operation not implemented properly by subclass."); + }; + + Errors.notYetImplemented = function () { + return new Error("Not yet implemented."); + }; + + Errors.invalidOperation = function (message) { + return new Error("Invalid operation: " + message); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft === 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, + 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, + 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, + 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, + 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, + 4166287, 4999559, 5999471, 7199369]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? key.hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', "Key was already in table."); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; + + (function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; + })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); + var ByteOrderMark = TypeScript.ByteOrderMark; + + var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; + })(); + TypeScript.FileInformation = FileInformation; + + TypeScript.Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return WScript.CreateObject("WScript.Shell").CurrentDirectory; + }, + supportsCodePage: function () { + return WScript.ReadFile; + }, + readFile: function (path, codepage) { + try { + if (codepage !== null && this.supportsCodePage()) { + try { + var contents = WScript.ReadFile(path, codepage); + return new FileInformation(contents, 0 /* None */); + } catch (e) { + } + } + + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return process.cwd(); + }, + supportsCodePage: function () { + return false; + }, + readFile: function (file, codepage) { + if (codepage !== null) { + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); + } + + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 509); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IntegerUtilities) { + function integerDivide(numerator, denominator) { + return (numerator / denominator) >> 0; + } + IntegerUtilities.integerDivide = integerDivide; + + function integerMultiplyLow32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + } + IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; + + function integerMultiplyHigh32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + } + IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + IntegerUtilities.isInteger = isInteger; + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + IntegerUtilities.isHexInteger = isHexInteger; + })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); + var IntegerUtilities = TypeScript.IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_computeLineStarts, length) { + this._computeLineStarts = _computeLineStarts; + this.length = length; + this._lineStarts = null; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this.lineStarts(), length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + if (this._lineStarts === null) { + this._lineStarts = this._computeLineStarts(); + } + + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + LineMap.empty = new LineMap(function () { + return [0]; + }, 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { + return e; + } + } + + return null; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + if (text.length !== length) { + return false; + } + + var s = start; + for (var i = 0; i < length; i++) { + if (text.charCodeAt(i) !== array[s]) { + return false; + } + + s++; + } + + return true; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static.": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static.": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Invalid 'reference' directive syntax.": { + "code": 1084, + "category": 1 /* Error */ + }, + "Octal literals are not available when targeting ECMAScript 5 and higher.": { + "code": 1085, + "category": 1 /* Error */ + }, + "Accessors are not allowed in ambient contexts.": { + "code": 1086, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a constructor declaration.": { + "code": 1089, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a parameter.": { + "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 */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static members cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* Error */ + }, + "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { + "code": 2104, + "category": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in local functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* Error */ + }, + "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { + "code": 2117, + "category": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "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 */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Type '{0}' does not have type parameters.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or not exported.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not assignable to any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "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 assignable to numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are only allowed in implementation.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { + "code": 2188, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { + "code": 2189, + "category": 1 /* Error */ + }, + "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { + "code": 2190, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot be reopened.": { + "code": 2191, + "category": 1 /* Error */ + }, + "All declarations of merged declaration '{0}' must be exported or not exported.": { + "code": 2192, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in constructor arguments.": { + "code": 2193, + "category": 1 /* Error */ + }, + "Return type of constructor signature must be assignable to the instance type of the class.": { + "code": 2194, + "category": 1 /* Error */ + }, + "Ambient external module declaration must be defined in global context.": { + "code": 2195, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot specify relative module name.": { + "code": 2196, + "category": 1 /* Error */ + }, + "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { + "code": 2197, + "category": 1 /* Error */ + }, + "Could not find the best common type of types of all return statement expressions.": { + "code": 2198, + "category": 1 /* Error */ + }, + "Import declaration cannot refer to external module reference when --noResolve option is set.": { + "code": 2199, + "category": 1 /* Error */ + }, + "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { + "code": 2200, + "category": 1 /* Error */ + }, + "'continue' statement can only be used within an enclosing iteration statement.": { + "code": 2201, + "category": 1 /* Error */ + }, + "'break' statement can only be used within an enclosing iteration or switch statement.": { + "code": 2202, + "category": 1 /* Error */ + }, + "Jump target not found.": { + "code": 2203, + "category": 1 /* Error */ + }, + "Jump target cannot cross function boundary.": { + "code": 2204, + "category": 1 /* Error */ + }, + "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { + "code": 2205, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { + "code": 2206, + "category": 1 /* Error */ + }, + "Expression resolves to '_super' that compiler uses to capture base class reference.": { + "code": 2207, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2208, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2209, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2210, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2211, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2212, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2213, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2214, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2215, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2216, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2217, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2218, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2219, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { + "code": 2220, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2221, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { + "code": 2222, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2223, + "category": 1 /* Error */ + }, + "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { + "code": 2224, + "category": 1 /* Error */ + }, + "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { + "code": 2225, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { + "code": 2226, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { + "code": 2227, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { + "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 */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Variable declaration cannot have the same name as an import declaration.": { + "code": 4026, + "category": 1 /* Error */ + }, + "Signature expected {0} type arguments, got {1} instead.": { + "code": 4027, + "category": 1 /* Error */ + }, + "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { + "code": 4028, + "category": 3 /* NoPrefix */ + }, + "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 infinitely expanding type reference have incompatible type arguments.": { + "code": 4030, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "code": 4031, + "category": 3 /* NoPrefix */ + }, + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { + "code": 4032, + "category": 3 /* NoPrefix */ + }, + "Types of string indexer of types '{0}' and '{1}' are not identical.": { + "code": 4033, + "category": 3 /* NoPrefix */ + }, + "Types of number indexer of types '{0}' and '{1}' are not identical.": { + "code": 4034, + "category": 3 /* NoPrefix */ + }, + "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 assignable to string indexer type in type '{2}'.{NL}{3}": { + "code": 4036, + "category": 3 /* NoPrefix */ + }, + "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 */ + }, + "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { + "code": 5002, + "category": 1 /* Error */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 1 /* Error */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit.": { + "code": 5021, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead.": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Option '{0}' specified without '{1}'": { + "code": 5041, + "category": 1 /* Error */ + }, + "'codepage' option not supported on current platform.": { + "code": 5042, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file.": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file.": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files.": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory.": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output.": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing.": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: '{0}' (default), or '{1}'": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: '{0}' or '{1}'": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message.": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated '{0}' keyword when referencing an external module.": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file1": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options.": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "file2": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "NUMBER": { + "code": 6039, + "category": 2 /* Message */ + }, + "Specify the codepage to use when opening source files.": { + "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 */ + }, + "Unknown rule.": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7015, + "category": 1 /* Error */ + }, + "'{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 = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + this._lineStartPositions = null; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + if (!this._lineStartPositions) { + this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); + } + + return this._lineStartPositions; + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LineMap1) { + function fromSimpleText(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return text.charCodeAt(index); + }, length: text.length() }); + }, text.length()); + } + LineMap1.fromSimpleText = fromSimpleText; + + function fromScriptSnapshot(scriptSnapshot) { + return new TypeScript.LineMap(function () { + return scriptSnapshot.getLineStartPositions(); + }, scriptSnapshot.getLength()); + } + LineMap1.fromScriptSnapshot = fromScriptSnapshot; + + function fromString(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts(text); + }, text.length); + } + LineMap1.fromString = fromString; + })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); + var LineMap1 = TypeScript.LineMap1; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this._lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this._lineStarts(); + }, this.length()); + }; + + TextBase.prototype._lineStarts = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this._lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + this._lazyLineStarts = null; + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.substr = function (start, length, intern) { + var startInOriginalText = this.span.start() + start; + return this.text.substr(startInOriginalText, length, intern); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SubText.prototype._lineStarts = function () { + var _this = this; + if (!this._lazyLineStarts) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return _this.charCodeAt(index); + }, length: this.length() }); + } + + return this._lazyLineStarts; + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + this._lazyLineStarts = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + + StringText.prototype._lineStarts = function () { + if (this._lazyLineStarts === null) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); + } + + return this._lazyLineStarts; + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap1.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + this._lineMap = null; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + if (!this._lineMap) { + this._lineMap = TypeScript.LineMap1.fromString(this.value); + } + + return this._lineMap; + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this.scriptSnapshot.getLineStartPositions(); + }, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length; + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + var change0 = changes[0]; + + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + + oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + CharacterInfo.isOctalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 55 /* _7 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + + SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; + + SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; + SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; + + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + + SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; + SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 164 /* PlusExpression */; + case 90 /* MinusToken */: + return 165 /* NegateExpression */; + case 102 /* TildeToken */: + return 166 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 167 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 168 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 169 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 210 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 211 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 205 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 206 /* DivideExpression */; + + case 92 /* PercentToken */: + return 207 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 208 /* AddExpression */; + + case 90 /* MinusToken */: + return 209 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 202 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 203 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 204 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 196 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 197 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 198 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 199 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 200 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 201 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 192 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 193 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 194 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 195 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 191 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 190 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 189 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 188 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 187 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 182 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 180 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 181 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 183 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 184 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 185 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 175 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 176 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 177 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 178 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 179 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 174 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 173 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function getOperatorTokenFromBinaryExpression(tokenKind) { + switch (tokenKind) { + case 205 /* MultiplyExpression */: + return 91 /* AsteriskToken */; + + case 206 /* DivideExpression */: + return 118 /* SlashToken */; + + case 207 /* ModuloExpression */: + return 92 /* PercentToken */; + + case 208 /* AddExpression */: + return 89 /* PlusToken */; + + case 209 /* SubtractExpression */: + return 90 /* MinusToken */; + + case 202 /* LeftShiftExpression */: + return 95 /* LessThanLessThanToken */; + + case 203 /* SignedRightShiftExpression */: + return 96 /* GreaterThanGreaterThanToken */; + + case 204 /* UnsignedRightShiftExpression */: + return 97 /* GreaterThanGreaterThanGreaterThanToken */; + + case 196 /* LessThanExpression */: + return 80 /* LessThanToken */; + + case 197 /* GreaterThanExpression */: + return 81 /* GreaterThanToken */; + + case 198 /* LessThanOrEqualExpression */: + return 82 /* LessThanEqualsToken */; + + case 199 /* GreaterThanOrEqualExpression */: + return 83 /* GreaterThanEqualsToken */; + + case 200 /* InstanceOfExpression */: + return 30 /* InstanceOfKeyword */; + + case 201 /* InExpression */: + return 29 /* InKeyword */; + + case 192 /* EqualsWithTypeConversionExpression */: + return 84 /* EqualsEqualsToken */; + + case 193 /* NotEqualsWithTypeConversionExpression */: + return 86 /* ExclamationEqualsToken */; + + case 194 /* EqualsExpression */: + return 87 /* EqualsEqualsEqualsToken */; + + case 195 /* NotEqualsExpression */: + return 88 /* ExclamationEqualsEqualsToken */; + + case 191 /* BitwiseAndExpression */: + return 98 /* AmpersandToken */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 100 /* CaretToken */; + + case 189 /* BitwiseOrExpression */: + return 99 /* BarToken */; + + case 188 /* LogicalAndExpression */: + return 103 /* AmpersandAmpersandToken */; + + case 187 /* LogicalOrExpression */: + return 104 /* BarBarToken */; + + case 182 /* OrAssignmentExpression */: + return 116 /* BarEqualsToken */; + + case 180 /* AndAssignmentExpression */: + return 115 /* AmpersandEqualsToken */; + + case 181 /* ExclusiveOrAssignmentExpression */: + return 117 /* CaretEqualsToken */; + + case 183 /* LeftShiftAssignmentExpression */: + return 112 /* LessThanLessThanEqualsToken */; + + case 184 /* SignedRightShiftAssignmentExpression */: + return 113 /* GreaterThanGreaterThanEqualsToken */; + + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + + case 175 /* AddAssignmentExpression */: + return 108 /* PlusEqualsToken */; + + case 176 /* SubtractAssignmentExpression */: + return 109 /* MinusEqualsToken */; + + case 177 /* MultiplyAssignmentExpression */: + return 110 /* AsteriskEqualsToken */; + + case 178 /* DivideAssignmentExpression */: + return 119 /* SlashEqualsToken */; + + case 179 /* ModuloAssignmentExpression */: + return 111 /* PercentEqualsToken */; + + case 174 /* AssignmentExpression */: + return 107 /* EqualsToken */; + + case 173 /* CommaExpression */: + return 79 /* CommaToken */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); + 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + 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 { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + 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(fullText, kind); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(text, start, isTrailing); + }; + + Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.slidingWindow.absoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(diagnostics); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(diagnostics); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifierOrKeyword(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var slidingWindow = this.slidingWindow; + var window = slidingWindow.window; + + var startIndex = slidingWindow.currentRelativeItemIndex; + var endIndex = slidingWindow.windowCount; + var currentIndex = startIndex; + var character = 0; + + while (currentIndex < endIndex) { + character = window[currentIndex]; + if (!isIdentifierPartCharacter[character]) { + break; + } + + currentIndex++; + } + + if (currentIndex === endIndex) { + return 0 /* None */; + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + return 0 /* None */; + } else { + var kind; + var identifierLength = currentIndex - startIndex; + if (isKeywordStartCharacter[firstCharacter]) { + kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); + } else { + kind = 11 /* IdentifierName */; + } + + slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); + + return kind; + } + }; + + Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + var sawUnicodeEscape = false; + + do { + var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); + sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + var length = this.slidingWindow.absoluteIndex() - startIndex; + var text = this.text.substr(startIndex, length, false); + var valueText = TypeScript.Syntax.massageEscapes(text); + + var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); + if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { + if (sawUnicodeEscape) { + return keywordKind | -2147483648 /* IsVariableWidthKeyword */; + } else { + return keywordKind; + } + } + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function (diagnostics) { + if (this.isHexNumericLiteral()) { + this.scanHexNumericLiteral(); + } else if (this.isOctalNumericLiteral()) { + this.scanOctalNumericLiteral(diagnostics); + } else { + this.scanDecimalNumericLiteral(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isOctalNumericLiteral = function () { + return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); + }; + + Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { + var position = this.absoluteIndex(); + + while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.languageVersion() >= 1 /* EcmaScript5 */) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); + } + }; + + Scanner.prototype.scanDecimalDigits = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + this.scanDecimalDigits(); + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + this.scanDecimalDigits(); + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + var nextChar1 = this.slidingWindow.peekItemN(1); + + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { + var nextChar2 = this.slidingWindow.peekItemN(2); + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } + } + } + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function (diagnostics) { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(diagnostics); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 12 /* RegularExpressionLiteral */; + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + break; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + break; + + default: + break; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + this.scanUnicodeOrHexEscape(errors); + return true; + } + } + + this.slidingWindow.moveToNextItem(); + return false; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return parent.type === nodeOrToken; + case 220 /* CastExpression */: + return parent.type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + case 228 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return TypeScript.Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return nodeOrToken.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + element.insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + element.insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + var firstToken = this.firstToken(); + return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.trailingTrivia = function () { + var lastToken = this.lastToken(); + return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + 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 === thisAsIndexable[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isExpression = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + + this._kind = kind; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.kind = function () { + return this._kind; + }; + + HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { + if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.name = name; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.name; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withName = function (name) { + return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { + if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.callSignature = callSignature; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 146 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.modifiers; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifiers = function (modifiers) { + return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + + this.arguments = _arguments; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 142 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 227 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 239 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.constructorKeyword = constructorKeyword; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.constructorKeyword; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + 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 */), CallSignatureSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var GetAccessorSyntax = (function (_super) { + __extends(GetAccessorSyntax, _super); + function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.getKeyword = getKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + } + GetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessor(this); + }; + + GetAccessorSyntax.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + + GetAccessorSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + GetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + GetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetAccessorSyntax.create1 = function (propertyName) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GetAccessorSyntax = GetAccessorSyntax; + + var SetAccessorSyntax = (function (_super) { + __extends(SetAccessorSyntax, _super); + function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.setKeyword = setKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + SetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessor(this); + }; + + SetAccessorSyntax.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + + SetAccessorSyntax.prototype.childCount = function () { + return 5; + }; + + SetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + SetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetAccessorSyntax.create1 = function (propertyName) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SetAccessorSyntax = SetAccessorSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var IndexMemberDeclarationSyntax = (function (_super) { + __extends(IndexMemberDeclarationSyntax, _super); + function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.indexSignature = indexSignature; + this.semicolonToken = semicolonToken; + } + IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexMemberDeclaration(this); + }; + + IndexMemberDeclarationSyntax.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + + IndexMemberDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.indexSignature; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexMemberDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { + if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { + return this; + } + + return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); + }; + + IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); + }; + + IndexMemberDeclarationSyntax.create1 = function (indexSignature) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { + return this.update(this.modifiers, indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.indexSignature, semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexMemberDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + this.colonToken = colonToken; + this.statements = statements; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + this.colonToken = colonToken; + this.statements = statements; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.doKeyword = doKeyword; + this.statement = statement; + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + 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) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var dedentThisTrivia = dedentNextWhitespace; + dedentNextWhitespace = false; + + if (dedentThisTrivia) { + if (trivia.kind() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + var indentNextTrivia = true; + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var indentThisTrivia = indentNextTrivia; + indentNextTrivia = false; + + switch (trivia.kind()) { + case 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; + this.tokenKind = kind; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function isExpression(token) { + switch (token.tokenKind) { + case 11 /* IdentifierName */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 50 /* SuperKeyword */: + return true; + } + + return false; + } + Syntax.isExpression = isExpression; + + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + case 13 /* carriageReturn */: + var nextIndex = i + 1; + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { + i++; + } + continue; + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + return regularExpressionValue(text); + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function regularExpressionValue(text) { + try { + var lastSlash = text.lastIndexOf("/"); + var body = text.substring(1, lastSlash); + var flags = text.substring(lastSlash + 1); + return new RegExp(body, flags); + } catch (e) { + return null; + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + EmptyToken.prototype.isExpression = function () { + return isExpression(this); + }; + + EmptyToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + + RealizedToken.prototype.isExpression = function () { + return isExpression(this); + }; + + RealizedToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var AbstractTrivia = (function () { + function AbstractTrivia(_kind) { + this._kind = _kind; + } + AbstractTrivia.prototype.fullWidth = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.fullText = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.toJSON = function (key) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === this._kind) { + result.kind = name; + break; + } + } + + if (this.isSkippedToken()) { + result.skippedToken = this.skippedToken(); + } else { + result.text = this.fullText(); + } + return result; + }; + + AbstractTrivia.prototype.kind = function () { + return this._kind; + }; + + AbstractTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + AbstractTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + AbstractTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + AbstractTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + AbstractTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return AbstractTrivia; + })(); + + var NormalTrivia = (function (_super) { + __extends(NormalTrivia, _super); + function NormalTrivia(kind, _text) { + _super.call(this, kind); + this._text = _text; + } + NormalTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + NormalTrivia.prototype.fullText = function () { + return this._text; + }; + + NormalTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return NormalTrivia; + })(AbstractTrivia); + + var SkippedTokenTrivia = (function (_super) { + __extends(SkippedTokenTrivia, _super); + function SkippedTokenTrivia(_skippedToken) { + _super.call(this, 8 /* SkippedTokenTrivia */); + this._skippedToken = _skippedToken; + } + SkippedTokenTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SkippedTokenTrivia.prototype.fullText = function () { + return this.skippedToken().fullText(); + }; + + SkippedTokenTrivia.prototype.skippedToken = function () { + return this._skippedToken; + }; + return SkippedTokenTrivia; + })(AbstractTrivia); + + var DeferredTrivia = (function (_super) { + __extends(DeferredTrivia, _super); + function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { + _super.call(this, kind); + this._text = _text; + this._fullStart = _fullStart; + this._fullWidth = _fullWidth; + this._fullText = null; + } + DeferredTrivia.prototype.fullWidth = function () { + return this._fullWidth; + }; + + DeferredTrivia.prototype.fullText = function () { + if (!this._fullText) { + this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); + this._text = null; + } + + return this._fullText; + }; + + DeferredTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return DeferredTrivia; + })(AbstractTrivia); + + function deferredTrivia(kind, text, fullStart, fullWidth) { + return new DeferredTrivia(kind, text, fullStart, fullWidth); + } + Syntax.deferredTrivia = deferredTrivia; + + function trivia(kind, text) { + return new NormalTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SkippedTokenTrivia(token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + this.trivia[i].collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 228 /* TypeArgumentList */: + case 229 /* TypeParameterList */: + case 220 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.name); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitList(node.modifiers); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.constructorKeyword); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.indexSignature); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + + + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + var result = this.currentToken(); + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + + return result; + }; + return SyntaxCursor; + })(); + + + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); + } + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { + this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 173 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 186 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 187 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 188 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 189 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 191 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 167 /* LogicalNotExpression */: + case 170 /* DeleteExpression */: + case 171 /* TypeOfExpression */: + case 172 /* VoidExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); + } + } + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + var modifierCount = this.modifierCount(); + return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + var modifierCount = this.modifierCount(); + if (this.isImportDeclaration(modifierCount)) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration(modifierCount)) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration(modifierCount)) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration(modifierCount)) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration(modifierCount)) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(inErrorRecovery)) { + return this.parseStatement(inErrorRecovery); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + + return typeArgumentList; + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isAccessor = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(false); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexMemberDeclaration()) { + return this.parseIndexMemberDeclaration(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var modifiers = this.parseModifiers(); + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var callSignature = this.parseCallSignature(false); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.isIndexMemberDeclaration = function () { + var index = this.modifierCount(); + return this.isIndexSignature(index); + }; + + ParserImpl.prototype.parseIndexMemberDeclaration = function () { + var modifiers = this.parseModifiers(); + var indexSignature = this.parseIndexSignature(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + if (callSignature.lastToken()) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature(0)) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(inErrorRecovery)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(inErrorRecovery)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function (tokenIndex) { + return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isIdentifier(this.currentToken())) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + + break; + + case 28 /* IfKeyword */: + case 70 /* OpenBraceToken */: + case 33 /* ReturnKeyword */: + case 34 /* SwitchKeyword */: + case 36 /* ThrowKeyword */: + case 15 /* BreakKeyword */: + case 18 /* ContinueKeyword */: + case 26 /* ForKeyword */: + case 42 /* WhileKeyword */: + case 43 /* WithKeyword */: + case 22 /* DoKeyword */: + case 38 /* TryKeyword */: + case 19 /* DebuggerKeyword */: + return true; + } + + if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { + return false; + } + + return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); + }; + + ParserImpl.prototype.parseStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 28 /* IfKeyword */: + return this.parseIfStatement(); + case 70 /* OpenBraceToken */: + return this.parseBlock(false, false); + case 33 /* ReturnKeyword */: + return this.parseReturnStatement(); + case 34 /* SwitchKeyword */: + return this.parseSwitchStatement(); + case 36 /* ThrowKeyword */: + return this.parseThrowStatement(); + case 15 /* BreakKeyword */: + return this.parseBreakStatement(); + case 18 /* ContinueKeyword */: + return this.parseContinueStatement(); + case 26 /* ForKeyword */: + return this.parseForOrForInStatement(); + case 42 /* WhileKeyword */: + return this.parseWhileStatement(); + case 43 /* WithKeyword */: + return this.parseWithStatement(); + case 22 /* DoKeyword */: + return this.parseDoStatement(); + case 38 /* TryKeyword */: + return this.parseTryStatement(); + case 19 /* DebuggerKeyword */: + return this.parseDebuggerStatement(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement(currentToken)) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { + return this.parseEmptyStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(false); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function (currentToken) { + return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(false); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return currentToken.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function (currentToken) { + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function (currentToken) { + switch (currentToken.tokenKind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + + case 74 /* OpenBracketToken */: + + case 72 /* OpenParenToken */: + + case 80 /* LessThanToken */: + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + + case 70 /* OpenBraceToken */: + + case 85 /* EqualsGreaterThanToken */: + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + + case 31 /* NewKeyword */: + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + + case 27 /* FunctionKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(false); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 225 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(token0); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpressionOrLower = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpressionOrLower(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else if (currentTokenKind === 39 /* TypeOfKeyword */) { + return this.parseTypeOfExpression(); + } else if (currentTokenKind === 41 /* VoidKeyword */) { + return this.parseVoidExpression(); + } else if (currentTokenKind === 21 /* DeleteKeyword */) { + return this.parseDeleteExpression(); + } else if (currentTokenKind === 80 /* LessThanToken */) { + return this.parseCastExpression(); + } else { + return this.parsePostfixExpressionOrLower(); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + if (precedence <= 2 /* AssignmentExpressionPrecedence */) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } + + var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); + if (parethesizedArrowFunction !== null) { + return parethesizedArrowFunction; + } + } + + var leftOperand = this.parseUnaryExpressionOrLower(); + return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } + + var expression = this.parsePrimaryExpression(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + return this.parseMemberExpressionRest(expression, false, inObjectCreation); + }; + + ParserImpl.prototype.parseCallExpressionOrLower = function () { + var expression; + if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { + expression = this.eatKeyword(50 /* SuperKeyword */); + + var currentTokenKind = this.currentToken().tokenKind; + if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + } + } else { + expression = this.parseMemberExpressionOrLower(false); + } + + return this.parseMemberExpressionRest(expression, true, false); + }; + + ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (!allowArguments) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (!allowArguments) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseCallExpressionOrLower(); + } + }; + + ParserImpl.prototype.parsePostfixExpressionOrLower = function () { + var expression = this.parseLeftHandSideExpressionOrLower(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + } + + return expression; + }; + + ParserImpl.prototype.tryParseGenericArgumentList = function () { + var rewindPoint = this.getRewindPoint(); + + var typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + + var argumentList = null; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } else { + return this.parseArgumentList(typeArgumentList); + } + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + return this.tryParseGenericArgumentList(); + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(null); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var _arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + _arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parsePrimaryExpression = function () { + var currentToken = this.currentToken(); + + if (this.isIdentifier(currentToken)) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseObjectCreationExpressionOrLower(true); + var argumentList = this.tryParseArgumentList(); + + var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); + return this.parseMemberExpressionRest(result, true, false); + }; + + ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseMemberExpressionOrLower(inObjectCreation); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedExpression = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { + return null; + } + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + + this.releaseRewindPoint(rewindPoint); + return arrowFunction; + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.tryParseArrowFunctionBlock = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { + return this.parseBlock(true, false); + } else { + return null; + } + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + token2 = this.peekToken(2); + if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { + if (this.isIdentifier(token2)) { + return true; + } + } + + if (!this.isIdentifier(token1)) { + return false; + } + + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { + if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(true); + } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + return this.eatKeyword(35 /* ThisKeyword */); + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameters = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); + + return typeParameterList; + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 39 /* TypeOfKeyword */: + + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + + case 70 /* OpenBraceToken */: + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + + case 31 /* NewKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + var type = this.parseNonArrayType(currentToken); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function (currentToken) { + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return this.eatAnyToken(); + + case 70 /* OpenBraceToken */: + return this.parseObjectType(); + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + return this.parseFunctionType(); + + case 31 /* NewKeyword */: + return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); + } + + return this.parseNameOrGenericType(); + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + var tokenKind = token.tokenKind; + if (tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { + if (this.isIdentifier(token)) { + var nextTokenKind = this.peekToken(1).tokenKind; + switch (nextTokenKind) { + case 73 /* CloseParenToken */: + case 106 /* ColonToken */: + case 107 /* EqualsToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { + modifierArray.push(this.eatAnyToken()); + continue; + } + + break; + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + 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; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType, inErrorRecovery); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + var currentToken = this.currentToken(); + if (this.isExpression(currentToken)) { + return true; + } + + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.parseStatement(inErrorRecovery); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(inErrorRecovery); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.inObjectLiteralExpression = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { + return true; + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { + if (parameter.modifiers.childCount() > 0) { + var modifiers = parameter.modifiers; + var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + + if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { + if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); + return true; + } else { + if (modifierIndex > 0) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + 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.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; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.modifiers.childCount() > 0) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + 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; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + 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) { + 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; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + 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; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { + var getKeywordFullStart = this.childFullStart(node, getKeyword); + if (parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { + if (this.checkIndexMemberModifiers(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIndexMemberDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { + if (node.modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(node, node.modifiers); + this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { + var savedInObjectLiteralExpression = this.inObjectLiteralExpression; + this.inObjectLiteralExpression = true; + _super.prototype.visitObjectLiteralExpression.call(this, node); + this.inObjectLiteralExpression = savedInObjectLiteralExpression; + }; + + GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { + var setKeywordFullStart = this.childFullStart(node, setKeyword); + if (parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); + var parameter = parameterList.parameters.childAt(0); + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + 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 && previousValueWasComputed) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (node.stringLiteral === null) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { + this.skip(node); + return; + } + + _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); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock || this.inObjectLiteralExpression) { + if (modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { + this.skip(node); + return; + } + + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { + var currentElementFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var child = modifiers.childAt(i); + if (child.kind() !== 57 /* PublicKeyword */) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); + return true; + } + + currentElementFullStart += child.fullWidth(); + } + + 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); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Document = (function () { + function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { + this._compiler = _compiler; + this._semanticInfoChain = _semanticInfoChain; + this.fileName = fileName; + this.referencedFiles = referencedFiles; + this._scriptSnapshot = _scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._syntaxTree = _syntaxTree; + this._topLevelDecl = _topLevelDecl; + this._diagnostics = null; + this._bloomFilter = null; + this._sourceUnit = null; + this._lineMap = null; + this._declASTMap = []; + this._astDeclMap = []; + this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; + } + Document.prototype.invalidate = function () { + this._declASTMap.length = 0; + this._astDeclMap.length = 0; + this._topLevelDecl = null; + + this._syntaxTree = null; + this._sourceUnit = null; + this._diagnostics = null; + this._bloomFilter = null; + }; + + Document.prototype.isDeclareFile = function () { + return TypeScript.isDTSFile(this.fileName); + }; + + Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + + this._lineMap = syntaxTree.lineMap(); + + var sourceUnit = syntaxTree.sourceUnit(); + var leadingTrivia = sourceUnit.leadingTrivia(); + + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); + + var amdDependencies = []; + 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); + } + } + } + + this._amdDependencies = amdDependencies; + }; + + Document.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(trivia.fullText()); + + if (match) { + return new TypeScript.TextSpan(position, trivia.fullWidth()); + } + + return null; + }; + + 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); + } + } + + position += moduleElement.fullWidth(); + } + + return null; + ; + }; + + Document.prototype.sourceUnit = function () { + if (!this._sourceUnit) { + var start = new Date().getTime(); + var syntaxTree = this.syntaxTree(); + this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + + if (!this.isOpen) { + this._syntaxTree = null; + } + } + + return this._sourceUnit; + }; + + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._diagnostics); + } + + return this._diagnostics; + }; + + Document.prototype.lineMap = function () { + if (this._lineMap === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._lineMap); + } + + return this._lineMap; + }; + + Document.prototype.isExternalModule = function () { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); + } + + return this._externalModuleIndicatorSpan; + }; + + Document.prototype.amdDependencies = function () { + if (this._amdDependencies === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._amdDependencies !== undefined); + } + + return this._amdDependencies; + }; + + Document.prototype.syntaxTree = function () { + var result = this._syntaxTree; + if (!result) { + var start = new Date().getTime(); + + result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); + + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + if (this.isOpen || !this._sourceUnit) { + this._syntaxTree = result; + } + } + + this.cacheSyntaxTreeInfo(result); + return result; + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = TypeScript.createIntrinsicsObject(); + var pre = function (cur) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { + if (cur.kind() === 11 /* IdentifierName */) { + var nodeText = cur.valueText(); + + identifiers[nodeText] = true; + } + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.emitToOwnOutputFile = function () { + return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { + var oldSyntaxTree = this._syntaxTree; + + if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { + var oldText = this._scriptSnapshot; + var newText = scriptSnapshot; + + TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); + var newTextPrefix = newText.getText(0, textChangeRange.span().start()); + TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); + + var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); + var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); + TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); + }; + + Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); + }; + + Document.prototype.topLevelDecl = function () { + if (this._topLevelDecl === null) { + this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); + } + + return this._topLevelDecl; + }; + + Document.prototype._getDeclForAST = function (ast) { + this.topLevelDecl(); + return this._astDeclMap[ast.syntaxID()]; + }; + + Document.prototype.getEnclosingDecl = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + return this._getDeclForAST(ast); + } + + ast = ast.parent; + var decl = null; + while (ast) { + decl = this._getDeclForAST(ast); + + if (decl) { + break; + } + + ast = ast.parent; + } + + return decl._getEnclosingDeclFromParentDecl(); + }; + + Document.prototype._setDeclForAST = function (ast, decl) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._astDeclMap[ast.syntaxID()] = decl; + }; + + Document.prototype._getASTForDecl = function (decl) { + return this._declASTMap[decl.declID]; + }; + + Document.prototype._setASTForDecl = function (decl, ast) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._declASTMap[decl.declID] = ast; + }; + return Document; + })(); + TypeScript.Document = Document; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var proto = "__proto__"; + + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + + this[proto] = null; + this[proto] = undefined; + } + return BlockIntrinsics; + })(); + + function createIntrinsicsObject() { + return new BlockIntrinsics(); + } + TypeScript.createIntrinsicsObject = createIntrinsicsObject; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = createIntrinsicsObject(); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (!fn(k, this.table[k], context)) { + return false; + } + } + } + + return true; + }; + + StringHashTable.prototype.some = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (fn(k, this.table[k], context)) { + return true; + } + } + } + + return false; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + + StringHashTable.prototype.remove = function (key) { + if (this.table[key] !== undefined) { + this.table[key] = undefined; + this.itemCount--; + } + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (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); + } + ASTHelpers.moduleIsElided = moduleIsElided; + + 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)) { + 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; + } + ASTHelpers.enumIsElided = enumIsElided; + + function isValidAstNode(ast) { + if (!ast) + return false; + + if (ast.start() === -1 || ast.end() === -1) + return false; + + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; + + 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; + + 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) { + top = cur; + } + } + } + } + + 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; + } + } + + return false; + } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; + + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } + + 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); + } + 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; + } + + current = current.parent; + } + 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; + } + + return null; + } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; + + 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; + } + 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; + + function parametersFromIdentifier(id) { + return { + length: 1, + lastParameterIsRest: function () { + return false; + }, + ast: id, + astAt: function (index) { + return id; + }, + identifierAt: function (index) { + return id; + }, + typeAt: function (index) { + return null; + }, + initializerAt: function (index) { + return null; + }, + isOptionalAt: function (index) { + return false; + } + }; + } + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; + + function parametersFromParameter(parameter) { + return { + length: 1, + lastParameterIsRest: function () { + return parameter.dotDotDotToken !== null; + }, + ast: parameter, + astAt: function (index) { + return parameter; + }, + identifierAt: function (index) { + return parameter.identifier; + }, + typeAt: function (index) { + return getType(parameter); + }, + initializerAt: function (index) { + return parameter.equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(parameter); + } + }; + } + ASTHelpers.parametersFromParameter = parametersFromParameter; + + function parameterIsOptional(parameter) { + return parameter.questionToken !== null || parameter.equalsValueClause !== null; + } + + function parametersFromParameterList(list) { + return { + length: list.parameters.nonSeparatorCount(), + lastParameterIsRest: function () { + return TypeScript.lastParameterIsRest(list); + }, + ast: list.parameters, + astAt: function (index) { + return list.parameters.nonSeparatorAt(index); + }, + identifierAt: function (index) { + return list.parameters.nonSeparatorAt(index).identifier; + }, + typeAt: function (index) { + return getType(list.parameters.nonSeparatorAt(index)); + }, + initializerAt: function (index) { + return list.parameters.nonSeparatorAt(index).equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(list.parameters.nonSeparatorAt(index)); + } + }; + } + ASTHelpers.parametersFromParameterList = parametersFromParameterList; + + 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; + } + } + ASTHelpers.isDeclarationAST = isDeclarationAST; + + 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; + } + + 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; + } + + ast = ast.parent; + } + + return null; + } + ASTHelpers.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); + + 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 { + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); + } + } + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function walkListChildren(preAst, walker) { + for (var i = 0, n = preAst.childCount(); i < n; i++) { + walker.walk(preAst.childAt(i)); + } + } + + function walkThrowStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkPrefixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkPostfixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkDeleteExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkTypeArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArguments); + } + + function walkTypeOfExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkVoidExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArgumentList); + walker.walk(preAst.arguments); + } + + function walkArrayLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.expressions); + } + + function walkSimplePropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.expression); + } + + function walkFunctionPropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkGetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkSeparatedListChildren(preAst, walker) { + for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { + walker.walk(preAst.nonSeparatorAt(i)); + } + } + + function walkSetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.block); + } + + function walkObjectLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.propertyAssignments); + } + + function walkCastExpressionChildren(preAst, walker) { + walker.walk(preAst.type); + walker.walk(preAst.expression); + } + + function walkParenthesizedExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkElementAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentExpression); + } + + function walkMemberAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.name); + } + + function walkQualifiedNameChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkBinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkEqualsValueClauseChildren(preAst, walker) { + walker.walk(preAst.value); + } + + function walkTypeParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.constraint); + } + + function walkTypeParameterListChildren(preAst, walker) { + walker.walk(preAst.typeParameters); + } + + function walkGenericTypeChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.typeArgumentList); + } + + function walkTypeAnnotationChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkTypeQueryChildren(preAst, walker) { + walker.walk(preAst.name); + } + + function walkInvocationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkObjectCreationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkTrinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.whenTrue); + walker.walk(preAst.whenFalse); + } + + function walkFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFunctionTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkMemberFunctionDeclarationChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFuncDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkIndexMemberDeclarationChildren(preAst, walker) { + walker.walk(preAst.indexSignature); + } + + function walkIndexSignatureChildren(preAst, walker) { + walker.walk(preAst.parameter); + walker.walk(preAst.typeAnnotation); + } + + function walkCallSignatureChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + } + + function walkConstraintChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkConstructorDeclarationChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkConstructorTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkConstructSignatureChildren(preAst, walker) { + walker.walk(preAst.callSignature); + } + + function walkParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkParameterListChildren(preAst, walker) { + walker.walk(preAst.parameters); + } + + function walkPropertySignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + } + + function walkVariableDeclaratorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkMemberVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.variableDeclarator); + } + + function walkMethodSignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + } + + function walkReturnStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkForStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.initializer); + walker.walk(preAst.condition); + walker.walk(preAst.incrementor); + walker.walk(preAst.statement); + } + + function walkForInStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.left); + walker.walk(preAst.expression); + walker.walk(preAst.statement); + } + + function walkIfStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + walker.walk(preAst.elseClause); + } + + function walkElseClauseChildren(preAst, walker) { + walker.walk(preAst.statement); + } + + function walkWhileStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkDoStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkBlockChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.declarators); + } + + function walkCaseSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.statements); + } + + function walkDefaultSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkSwitchStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.switchClauses); + } + + function walkTryStatementChildren(preAst, walker) { + walker.walk(preAst.block); + walker.walk(preAst.catchClause); + walker.walk(preAst.finallyClause); + } + + function walkCatchClauseChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkExternalModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.stringLiteral); + } + + function walkFinallyClauseChildren(preAst, walker) { + walker.walk(preAst.block); + } + + function walkClassDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.classElements); + } + + function walkScriptChildren(preAst, walker) { + walker.walk(preAst.moduleElements); + } + + function walkHeritageClauseChildren(preAst, walker) { + walker.walk(preAst.typeNames); + } + + function walkInterfaceDeclerationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.body); + } + + function walkObjectTypeChildren(preAst, walker) { + walker.walk(preAst.typeMembers); + } + + function walkArrayTypeChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkModuleDeclarationChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.stringLiteral); + walker.walk(preAst.moduleElements); + } + + function walkModuleNameModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.moduleName); + } + + function walkEnumDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.enumElements); + } + + function walkEnumElementChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.equalsValueClause); + } + + function walkImportDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.moduleReference); + } + + function walkExportAssignmentChildren(preAst, walker) { + walker.walk(preAst.identifier); + } + + function walkWithStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkExpressionStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkLabeledStatementChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.statement); + } + + function walkVariableStatementChildren(preAst, walker) { + walker.walk(preAst.declaration); + } + + var childrenWalkers = new Array(246 /* Last */ + 1); + + for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { + childrenWalkers[i] = null; + } + for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { + childrenWalkers[i] = null; + } + + childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; + childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[60 /* AnyKeyword */] = null; + childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; + childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; + childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; + childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; + childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; + childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[146 /* Block */] = walkBlockChildren; + childrenWalkers[61 /* BooleanKeyword */] = null; + childrenWalkers[152 /* BreakStatement */] = null; + childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; + childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; + childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; + childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; + childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; + childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; + childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; + childrenWalkers[239 /* Constraint */] = walkConstraintChildren; + childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; + childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; + childrenWalkers[153 /* ContinueStatement */] = null; + childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; + childrenWalkers[162 /* DebuggerStatement */] = null; + childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; + childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; + childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; + childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; + childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; + childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; + childrenWalkers[156 /* EmptyStatement */] = null; + childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; + childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; + childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; + childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; + childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; + childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; + childrenWalkers[24 /* FalseKeyword */] = null; + childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; + childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; + childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; + childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; + childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; + childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; + childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; + childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; + childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; + childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; + childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; + childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; + childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; + childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; + childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; + childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; + childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; + childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; + childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[1 /* List */] = walkListChildren; + childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; + childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; + childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; + childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; + childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; + childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; + childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; + childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; + childrenWalkers[11 /* IdentifierName */] = null; + childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[0 /* None */] = null; + childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[32 /* NullKeyword */] = null; + childrenWalkers[67 /* NumberKeyword */] = null; + childrenWalkers[13 /* NumericLiteral */] = null; + childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; + childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; + childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; + childrenWalkers[223 /* OmittedExpression */] = null; + childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[242 /* Parameter */] = walkParameterChildren; + childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; + childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; + childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; + childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; + childrenWalkers[12 /* RegularExpressionLiteral */] = null; + childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; + childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; + childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; + childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; + childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; + childrenWalkers[14 /* StringLiteral */] = null; + childrenWalkers[69 /* StringKeyword */] = null; + childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; + childrenWalkers[50 /* SuperKeyword */] = null; + childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; + childrenWalkers[35 /* ThisKeyword */] = null; + childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; + childrenWalkers[3 /* TriviaList */] = null; + childrenWalkers[37 /* TrueKeyword */] = null; + childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; + childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; + childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; + childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; + childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; + childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; + childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; + childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; + childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; + childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; + childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; + childrenWalkers[41 /* VoidKeyword */] = null; + childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; + childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; + + for (var e in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { + TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); + } + } + + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + this.stopWalking = false; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var SimplePreAstWalker = (function () { + function SimplePreAstWalker(pre, state) { + this.pre = pre; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePreAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + }; + return SimplePreAstWalker; + })(); + + var SimplePrePostAstWalker = (function () { + function SimplePrePostAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePrePostAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + + this.post(ast, this.state); + }; + return SimplePrePostAstWalker; + })(); + + var NormalAstWalker = (function () { + function NormalAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + NormalAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + if (this.options.stopWalking) { + return; + } + + this.pre(ast, this); + + if (this.options.stopWalking) { + return; + } + + if (this.options.goChildren) { + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + } else { + this.options.goChildren = true; + } + + if (this.post) { + this.post(ast, this); + } + }; + return NormalAstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { + new NormalAstWalker(pre, post, state).walk(ast); + }; + + AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { + if (post) { + new SimplePrePostAstWalker(pre, post, state).walk(ast); + } else { + new SimplePreAstWalker(pre, state).walk(ast); + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory = new AstWalkerFactory(); + + function getAstWalkerFactory() { + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapEntry = (function () { + function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { + this.emittedFile = emittedFile; + this.emittedLine = emittedLine; + this.emittedColumn = emittedColumn; + this.sourceFile = sourceFile; + this.sourceLine = sourceLine; + this.sourceColumn = sourceColumn; + this.sourceName = sourceName; + TypeScript.Debug.assert(isFinite(emittedLine)); + TypeScript.Debug.assert(isFinite(emittedColumn)); + TypeScript.Debug.assert(isFinite(sourceColumn)); + TypeScript.Debug.assert(isFinite(sourceLine)); + } + return SourceMapEntry; + })(); + TypeScript.SourceMapEntry = SourceMapEntry; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.names = []; + this.mappingLevel = []; + this.tsFilePaths = []; + this.allSourceMappings = []; + this.sourceMapEntries = []; + this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); + this.setNewSourceFile(document, emitOptions); + } + SourceMapper.prototype.getOutputFile = function () { + var result = this.sourceMapOut.getOutputFile(); + result.sourceMapEntries = this.sourceMapEntries; + + return result; + }; + + SourceMapper.prototype.increaseMappingLevel = function (ast) { + this.mappingLevel.push(ast); + }; + + SourceMapper.prototype.decreaseMappingLevel = function (ast) { + TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); + var expectedAst = this.mappingLevel.pop(); + var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; + var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; + TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); + }; + + SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { + var sourceMappings = []; + this.allSourceMappings.push(sourceMappings); + this.currentMappings = [sourceMappings]; + this.currentNameIndex = []; + + this.setNewSourceFilePath(document, emitOptions); + }; + + SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; + this.jsFileName = prettyJsFileName; + + if (emitOptions.sourceMapRootDirectory()) { + this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); + if (document.emitToOwnOutputFile()) { + this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); + } + + if (TypeScript.isRelative(this.sourceMapDirectory)) { + this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; + this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); + this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); + } else { + this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; + } + } else { + this.sourceMapPath = prettyMapFileName; + this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + this.sourceRoot = emitOptions.sourceRootDirectory(); + }; + + SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + if (emitOptions.sourceRootDirectory()) { + tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); + } else { + tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); + } + this.tsFilePaths.push(tsFilePath); + }; + + SourceMapper.prototype.emitSourceMapping = function () { + var _this = this; + TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { + return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); + }).join(', ')); + + this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); + + var mappingsString = ""; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); + prevSourceIndex = sourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); + prevNameIndex = nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + for (var i = 0; i < sourceMappings.length; i++) { + var sourceMapping = sourceMappings[i]; + recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); + recordSourceMappingSiblings(sourceMapping.childMappings); + recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); + } + }; + + recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); + } + + this.sourceMapOut.Write(JSON.stringify({ + version: 3, + file: this.jsFileName, + sourceRoot: this.sourceRoot, + sources: this.tsFilePaths, + names: this.names, + mappings: mappingsString + })); + + this.sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compiler, resolvePath) { + this.resolvePath = resolvePath; + this._diagnostic = null; + this._settings = null; + this._commonDirectoryPath = ""; + this._sharedOutputFile = ""; + this._sourceRootDirectory = ""; + this._sourceMapRootDirectory = ""; + this._outputDirectory = ""; + var settings = compiler.compilationSettings(); + this._settings = settings; + + 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()) { + if (settings.mapRoot()) { + if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } else { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } else if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } + + this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); + this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); + + if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { + if (settings.outFileOption()) { + this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); + } + + if (settings.outDirOption()) { + this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); + } + + if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { + this.determineCommonDirectoryPath(compiler); + } + } + } + EmitOptions.prototype.diagnostic = function () { + return this._diagnostic; + }; + + EmitOptions.prototype.commonDirectoryPath = function () { + return this._commonDirectoryPath; + }; + EmitOptions.prototype.sharedOutputFile = function () { + return this._sharedOutputFile; + }; + EmitOptions.prototype.sourceRootDirectory = function () { + return this._sourceRootDirectory; + }; + EmitOptions.prototype.sourceMapRootDirectory = function () { + return this._sourceMapRootDirectory; + }; + EmitOptions.prototype.outputDirectory = function () { + return this._outputDirectory; + }; + + EmitOptions.prototype.compilationSettings = function () { + return this._settings; + }; + + EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = compiler.fileNames(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = compiler.getDocument(fileNames[i]); + var sourceUnit = document.sourceUnit(); + + if (!document.isDeclareFile()) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + 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; + } + + return; + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + function lastParameterIsRest(parameterList) { + var parameters = parameterList.parameters; + return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; + } + TypeScript.lastParameterIsRest = lastParameterIsRest; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.inArrowFunction = false; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.declStack = []; + this.exportAssignment = null; + this.inWithBlock = false; + this.document = null; + this.detachedCommentsElement = null; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; + }; + + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.shouldEmitImportDeclaration = 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 */; + + 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 */; + + this.emitComments(importDeclAST, true); + + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + 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 */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + if (isAmdCodeGen && isExternalModuleReference) { + needsPropertyAssignment = true; + } else { + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.identifier.text() + " = "); + var aliasAST = importDeclAST.moduleReference; + + if (isExternalModuleReference) { + this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); + } else { + this.emitJavascript(aliasAST.moduleName, false); + } + + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + } + } + + if (needsPropertyAssignment) { + this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + }; + + Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { + this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); + }; + + Emitter.prototype.setSourceMapperNewSourceFile = function (document) { + this.sourceMapper.setNewSourceFile(document, this.emitOptions); + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { + this.recordSourceMappingStart(astSpan); + this.writeToOutput(s); + this.recordSourceMappingEnd(astSpan); + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeLineToOutput = function (s, force) { + if (typeof force === "undefined") { force = false; } + if (!force && s === "" && this.emitState.column === 0) { + return; + } + + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment, trailing, first) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var text = getTrimmedTextLines(comment); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } else if (trailing && first) { + this.writeToOutput(" "); + } + + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (!trailing && emitColumn !== 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { + 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; + } + } + + if (pre) { + var preComments = ast.preComments(); + + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; + } + + if (preComments && onlyPinnedOrTripleSlashComments) { + preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { + return _this.isPinnedOrTripleSlash(c); + }); + } + + this.emitCommentsArray(preComments, false); + } else { + this.emitCommentsArray(ast.postComments(), true); + } + }; + + Emitter.prototype.isPinnedOrTripleSlash = function (comment) { + var fullText = comment.fullText(); + if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { + return true; + } else { + return fullText.indexOf("/*!") === 0; + } + }; + + Emitter.prototype.emitCommentsArray = function (comments, trailing) { + if (!this.emitOptions.compilationSettings().removeComments() && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i], trailing, i === 0); + } + } + }; + + Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { + this.recordSourceMappingStart(objectLiteral); + + this.writeToOutput("{"); + this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); + this.writeToOutput("}"); + + this.recordSourceMappingEnd(objectLiteral); + }; + + Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { + this.recordSourceMappingStart(arrayLiteral); + + this.writeToOutput("["); + this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); + this.writeToOutput("]"); + + this.recordSourceMappingEnd(arrayLiteral); + }; + + Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { + this.recordSourceMappingStart(objectCreationExpression); + this.writeToOutput("new "); + var target = objectCreationExpression.expression; + + this.emit(target); + if (objectCreationExpression.argumentList) { + this.recordSourceMappingStart(objectCreationExpression.argumentList); + this.writeToOutput("("); + this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); + this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); + this.recordSourceMappingEnd(objectCreationExpression.argumentList); + } + + this.recordSourceMappingEnd(objectCreationExpression); + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); + if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + if (pullDecl.kind === 67108864 /* EnumMember */) { + return pullDecl; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + var propertyName = dotExpr.name; + var boundDecl = this.getConstantDecl(dotExpr); + if (boundDecl) { + var value = boundDecl.constantValue; + if (value !== null) { + this.recordSourceMappingStart(dotExpr); + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.text(); + comment += " */"; + this.writeToOutput(comment); + this.recordSourceMappingEnd(dotExpr); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitInvocationExpression = function (callNode) { + this.recordSourceMappingStart(callNode); + var target = callNode.expression; + var args = callNode.argumentList.arguments; + + if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { + this.emit(target); + this.writeToOutput(".call"); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitThis(); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + } else { + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + + this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); + this.recordSourceMappingEnd(args); + this.recordSourceMappingEnd(callNode); + }; + + Emitter.prototype.emitParameterList = function (list) { + this.writeToOutput("("); + this.emitCommentsArray(list.openParenTrailingComments, true); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); + this.writeToOutput(")"); + }; + + Emitter.prototype.emitFunctionParameters = function (parameters) { + var argsLen = 0; + + if (parameters) { + this.emitComments(parameters.ast, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = parameters.length; + var printLen = argsLen; + if (parameters.lastParameterIsRest()) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = parameters.astAt(i); + this.emit(arg); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(parameters.ast, false); + } + }; + + Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { + this.writeLineToOutput(" {"); + if (name) { + this.recordSourceMappingNameStart(name); + } + + this.indenter.increaseIndent(); + + 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); + } else { + this.emitIndent(); + this.emitCommentsArray(bodyExpression.preComments(), false); + this.writeToOutput("return "); + this.emit(bodyExpression); + this.writeLineToOutput(";"); + this.emitCommentsArray(bodyExpression.postComments(), true); + } + + this.indenter.decreaseIndent(); + this.emitIndent(); + + if (block) { + this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); + } else { + this.writeToOutputWithSourceMapRecord("}", bodyExpression); + } + + if (name) { + this.recordSourceMappingNameEnd(); + } + }; + + Emitter.prototype.emitDefaultValueAssignments = function (parameters) { + var n = parameters.length; + if (parameters.lastParameterIsRest()) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = parameters.astAt(i); + var id = parameters.identifierAt(i); + var equalsValueClause = parameters.initializerAt(i); + if (equalsValueClause) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.emitJavascript(equalsValueClause, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (parameters) { + if (parameters.lastParameterIsRest()) { + var n = parameters.length; + var lastArg = parameters.astAt(n - 1); + var id = parameters.identifierAt(n - 1); + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); + this.writeToOutput(" "); + this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); + this.writeToOutput("; "); + this.writeToOutputWithSourceMapRecord("_i++", lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + var result = []; + + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + var queue = dynamicModuleDecl.getChildDecls(); + + for (var i = 0, n = queue.length; i < n; i++) { + var decl = queue[i]; + + if (decl.kind & 128 /* TypeAlias */) { + var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { + var importList = ""; + var dependencyList = ""; + + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue()) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += importStatementDecl.name; + dependencyList += importStatementAST.moduleReference.stringLiteral.text(); + } + } + } + + var amdDependencies = this.document.amdDependencies(); + for (var i = 0; i < amdDependencies.length; i++) { + dependencyList += ", \"" + amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); + } + + var decl = this.semanticInfoChain.getDeclForAST(ast); + if (decl) { + return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); + } + + return false; + }; + + Emitter.prototype.emitEnum = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.identifier.text(); + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.identifier); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(this.moduleName); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitSeparatedList(moduleDecl.enumElements); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { + return moduleDecl; + } else if (changeNameIfAnyDeclarationInContext) { + var symbol = moduleDecl.getSymbol(); + if (symbol) { + var otherDecls = symbol.getDeclarations(); + for (var i = 0; i < otherDecls.length; i++) { + if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { + return otherDecls[i]; + } + } + } + } + + return null; + }; + + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { + var _this = this; + var childDecls = parentDecl.getChildDecls(); + return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { + 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; + } + } + return false; + }); + }; + + Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + var moduleName = moduleDecl.name; + var moduleDisplayName = moduleDecl.getDisplayName(); + + moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { + moduleName = "_" + moduleName; + moduleDisplayName = "_" + moduleDisplayName; + } + } + + return moduleDisplayName; + }; + + Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { + if (moduleDecl.stringLiteral) { + this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); + } + }; + + Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); + + if (isLastName) { + this.emitComments(moduleDecl, true); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + + if (moduleDecl.stringLiteral) { + this.moduleName = moduleDecl.stringLiteral.valueText(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + } else { + this.moduleName = moduleName.text(); + } + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleName); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleName); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + + this.moduleName = this.getModuleName(pullDecl); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(moduleName.text()); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + if (moduleName === moduleDecl.stringLiteral) { + this.emitList(moduleDecl.moduleElements); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + var nameIndex = moduleNames.indexOf(moduleName); + TypeScript.Debug.assert(nameIndex >= 0); + + if (isLastName) { + this.emitList(moduleDecl.moduleElements); + } else { + this.emitIndent(); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); + this.writeLineToOutput(""); + } + } + + this.moduleName = moduleName.text(); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + + if (isLastName) { + this.emitComments(moduleDecl, false); + } + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.propertyName.text(); + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput(']'); + + if (varDecl.equalsValueClause) { + this.emit(varDecl.equalsValueClause); + } else if (pullDecl.constantValue !== null) { + this.writeToOutput(' = '); + this.writeToOutput(pullDecl.constantValue.toString()); + } else { + this.writeToOutput(' = null'); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitElementAccessExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("["); + this.emit(expression.argumentExpression); + this.writeToOutput("]"); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = true; + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(arrowFunction); + + var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); + this.pushDecl(pullDecl); + + this.emitComments(arrowFunction, true); + + this.recordSourceMappingStart(arrowFunction); + this.writeToOutput("function "); + this.writeToOutput("("); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); + + this.recordSourceMappingEnd(arrowFunction); + + this.recordSourceMappingEnd(arrowFunction); + + this.emitComments(arrowFunction, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConstructor = function (funcDecl) { + if (!funcDecl.block) { + return; + } + var temp = this.setContainer(4 /* Constructor */); + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + this.writeToOutput(this.thisClassNode.identifier.text()); + this.writeToOutput("("); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart("constructor"); + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(parameters); + this.emitRestParameterInitializer(parameters); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + this.emitConstructorStatements(funcDecl); + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + }; + + Emitter.prototype.emitGetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("get "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitSetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("set "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitFunctionExpression = function (funcDecl) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + this.writeToOutput(funcDecl.identifier.text()); + this.recordSourceMappingEnd(funcDecl.identifier); + } + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (funcDecl.block === null) { + return; + } + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier.text(); + + this.recordSourceMappingStart(funcDecl); + + var printName = funcDecl.identifier !== null; + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (printName) { + var id = funcDecl.identifier.text(); + if (id) { + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + } + this.writeToOutput(id); + if (funcDecl.identifier) { + this.recordSourceMappingEnd(funcDecl.identifier); + } + } + } + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + + if (funcDecl.block) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + this.recordSourceMappingStart(this.currentVariableDeclaration); + if (varDecl.equalsValueClause) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + this.emitJavascript(varDecl.equalsValueClause, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.currentVariableDeclaration) { + this.writeToOutput("var "); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + + this.emitComments(declaration, true); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; + if (!isAmbientWithoutInit) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.currentVariableDeclaration = declaration; + + for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { + var declarator = declaration.declarators.nonSeparatorAt(i); + + if (i > 0) { + this.writeToOutput(", "); + } + + this.emit(declarator); + } + this.currentVariableDeclaration = prevVariableDeclaration; + + this.recordSourceMappingEnd(declaration); + } + + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { + TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); + + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + + if (quotedOrNumber) { + this.writeToOutput("this["); + } else { + this.writeToOutput("this."); + } + + this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); + + if (quotedOrNumber) { + this.writeToOutput("]"); + } + + if (varDecl.variableDeclarator.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.variableDeclarator.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(this.currentVariableDeclaration); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.propertyName.text(); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); + + if (parentIsModule) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + + if (varDecl.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.currentVariableDeclaration = undefined; + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { + var decl = pullSymbol.getDeclarations()[0]; + var parentDecl = decl.getParentDecl(); + var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; + + var enclosingContextDeclPath = this.declStack; + var commonNodeIndex = -1; + + if (enclosingContextDeclPath.length) { + for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { + var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; + for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { + var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; + if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { + commonNodeIndex = i; + break; + } + } + + if (commonNodeIndex >= 0) { + break; + } + } + } + + var startingIndex = symbolContainerDeclPath.length - 1; + for (var i = startingIndex - 1; i > commonNodeIndex; i--) { + if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { + startingIndex = i; + } else { + break; + } + } + return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; + }; + + Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { + for (var i = startingIndex; i <= lastIndex; i++) { + if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.getModuleName(declPath[i], true) + "."); + } + } + }; + + Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { + var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); + var potentialDeclPath = declPathInfo.potentialPath; + var startingIndex = declPathInfo.startingIndex; + + this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); + }; + + Emitter.prototype.getSymbolForEmit = function (ast) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol === symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (name.text().length > 0) { + var symbolForEmit = this.getSymbolForEmit(name); + var pullSymbol = symbolForEmit.symbol; + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = symbolForEmit.aliasSymbol; + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } + } + } + + this.writeToOutput(name.text()); + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var nameIndex = -1; + if (name) { + if (this.sourceMapper.currentNameIndex.length > 0) { + var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { + break; + } + } + + if (nameIndex === -1) { + nameIndex = this.sourceMapper.names.length; + this.sourceMapper.names.push(name); + } + } + this.sourceMapper.currentNameIndex.push(nameIndex); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (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; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap(); + lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); + + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + this.sourceMapper.increaseMappingLevel(ast); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); + + this.sourceMapper.decreaseMappingLevel(ast); + } + }; + + Emitter.prototype.getOutputFiles = function () { + var result = []; + if (this.sourceMapper !== null) { + this.sourceMapper.emitSourceMapping(); + result.push(this.sourceMapper.getOutputFile()); + } + + result.push(this.outfile.getOutputFile()); + return result; + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = getLastConstructor(this.thisClassNode); + + 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(); + this.recordSourceMappingStart(parameter); + this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); + this.writeToOutput(" = "); + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(parameter); + } + } + } + + for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { + if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = this.thisClassNode.classElements.childAt(i); + if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitIndent(); + this.emitMemberVariableDeclaration(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.isOnSameLine = function (pos1, pos2) { + var lineMap = this.document.lineMap(); + return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); + }; + + Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { + if (list === null || list.nonSeparatorCount() === 0) { + return; + } + + var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); + + if (preserveNewLines) { + this.indenter.increaseIndent(); + } + + if (startLine) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(buffer); + } + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + var emitNode = list.nonSeparatorAt(i); + + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); + if (startLine) { + this.writeLineToOutput(","); + } else { + this.writeToOutput(", "); + } + } + } + + if (preserveNewLines) { + this.indenter.decreaseIndent(); + } + + if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(buffer); + } + }; + + Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.nonSeparatorAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.kind() === 14 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { + return; + } + + var lineMap = this.document.lineMap(); + var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput("", true); + } + }; + + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); + if (preComments) { + var lineMap = this.document.lineMap(); + + var detachedComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); + var commentLine = lineMap.getLineNumberFromPosition(comment.start()); + + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + detachedComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); + if (astLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { + if (list.childCount() > 0) { + var firstElement = list.childAt(0); + + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); + } + }; + + Emitter.prototype.emitScriptElements = function (sourceUnit) { + var list = sourceUnit.moduleElements; + + this.emitPossibleCopyrightHeaders(sourceUnit); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var node = list.childAt(i); + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(sourceUnit); + + var isExternalModule = this.document.isExternalModule(); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); + if (isNonElidedExternalModule) { + this.recordSourceMappingStart(sourceUnit); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } + + if (isExternalModule) { + var temp = this.setContainer(2 /* DynamicModule */); + + var svModuleName = this.moduleName; + this.moduleName = sourceUnit.fileName(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + this.setExportAssignment(null); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); + + if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { + this.writeCaptureThisStatement(sourceUnit); + } + + this.pushDecl(externalModule); + } + + this.emitList(list, true, i, n); + + if (isExternalModule) { + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + + if (isNonElidedExternalModule) { + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; + var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(sourceUnit); + this.writeLineToOutput(""); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + this.popDecl(externalModule); + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + this.emit(ast); + }; + + Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { + if (funcDecl.kind() !== 139 /* GetAccessor */) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + + this.writeToOutput("Object.defineProperty(" + className); + if (isProto) { + this.writeToOutput(".prototype, "); + } else { + this.writeToOutput(", "); + } + + var functionName = name.text(); + if (TypeScript.isQuoted(functionName)) { + this.writeToOutput(functionName); + } else { + this.writeToOutput('"' + functionName + '"'); + } + + this.writeLineToOutput(", {"); + + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.emitComments(accessors.getter, true); + this.writeToOutput("get: "); + this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.emitComments(accessors.setter, true); + this.writeToOutput("set: "); + this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.identifier.text(); + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var baseTypeReference = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); + } + + this.emitIndent(); + + var constrDecl = getLastConstructor(classDecl); + + if (constrDecl) { + this.emit(constrDecl); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.emitJavascript(baseTypeReference, false); + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 139 /* GetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var getter = memberDecl; + this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 140 /* SetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var setter = memberDecl; + this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { + var memberFunction = memberDecl; + + if (memberFunction.block) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + + this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); + lastEmittedMember = memberDecl; + } + } + } + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = memberDecl; + + if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); + } else { + this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); + } + + this.emit(varDecl.variableDeclarator.equalsValueClause); + + this.recordSourceMappingEnd(varDecl); + this.writeLineToOutput(";"); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + var functionName = funcDecl.propertyName.text(); + + this.writeToOutput(classDecl.identifier.text()); + + if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + this.writeToOutput(".prototype"); + } + + if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput("[" + functionName + "] = "); + } else { + this.writeToOutput("." + functionName + " = "); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + + this.writeLineToOutput(";"); + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + + if (moduleElement.kind() === 130 /* ModuleDeclaration */) { + var moduleAST = moduleElement; + + if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { + return true; + } + } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (sourceUnit) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(sourceUnit)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitThis = function () { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.kind() === 146 /* Block */) { + this.emit(node); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitLiteralExpression = function (expression) { + switch (expression.kind()) { + case 32 /* NullKeyword */: + this.writeToOutputWithSourceMapRecord("null", expression); + break; + case 24 /* FalseKeyword */: + this.writeToOutputWithSourceMapRecord("false", expression); + break; + case 37 /* TrueKeyword */: + this.writeToOutputWithSourceMapRecord("true", expression); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + Emitter.prototype.emitThisExpression = function (expression) { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutputWithSourceMapRecord("_this", expression); + } else { + this.writeToOutputWithSourceMapRecord("this", expression); + } + }; + + Emitter.prototype.emitSuperExpression = function (expression) { + this.writeToOutputWithSourceMapRecord("_super.prototype", expression); + }; + + Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { + if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { + this.emit(parenthesizedExpression.expression); + } else { + this.recordSourceMappingStart(parenthesizedExpression); + this.writeToOutput("("); + this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); + this.emit(parenthesizedExpression.expression); + this.writeToOutput(")"); + this.recordSourceMappingEnd(parenthesizedExpression); + } + }; + + Emitter.prototype.emitCastExpression = function (expression) { + this.emit(expression.expression); + }; + + Emitter.prototype.emitPrefixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 167 /* LogicalNotExpression */: + this.writeToOutput("!"); + this.emit(expression.operand); + break; + case 166 /* BitwiseNotExpression */: + this.writeToOutput("~"); + this.emit(expression.operand); + break; + case 165 /* NegateExpression */: + this.writeToOutput("-"); + if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 164 /* PlusExpression */: + this.writeToOutput("+"); + if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 168 /* PreIncrementExpression */: + this.writeToOutput("++"); + this.emit(expression.operand); + break; + case 169 /* PreDecrementExpression */: + this.writeToOutput("--"); + this.emit(expression.operand); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitPostfixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 210 /* PostIncrementExpression */: + this.emit(expression.operand); + this.writeToOutput("++"); + break; + case 211 /* PostDecrementExpression */: + this.emit(expression.operand); + this.writeToOutput("--"); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitTypeOfExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("typeof "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDeleteExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("delete "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitVoidExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("void "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { + var memberExpressionNodeType = expression.expression.kind(); + + 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 */) { + return this.canEmitDottedNameMemberAccessExpression(expression.expression); + } + + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { + this.recordSourceMappingStart(expression); + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { + this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); + } else { + this.emitComments(expression.expression, true); + this.recordSourceMappingStart(expression.expression); + + this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); + + this.writeToOutput(expression.expression.text()); + + this.recordSourceMappingEnd(expression.expression); + this.emitComments(expression.expression, false); + } + + this.writeToOutput("."); + this.emitName(expression.name, false); + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { + this.emitComments(expression, true); + + if (lastIndex - startingIndex < 1) { + startingIndex = lastIndex - 1; + TypeScript.Debug.assert(startingIndex >= 0); + } + + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); + this.emitComments(expression, false); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { + var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; + + var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); + }; + + Emitter.prototype.emitMemberAccessExpression = function (expression) { + if (!this.tryEmitConstant(expression)) { + if (this.canEmitDottedNameMemberAccessExpression(expression)) { + this.emitDottedNameMemberAccessExpression(expression); + } else { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("."); + this.emitName(expression.name, false); + this.recordSourceMappingEnd(expression); + } + } + }; + + Emitter.prototype.emitQualifiedName = function (name) { + this.recordSourceMappingStart(name); + + this.emit(name.left); + this.writeToOutput("."); + this.emitName(name.right, false); + + this.recordSourceMappingEnd(name); + }; + + Emitter.prototype.emitBinaryExpression = function (expression) { + this.recordSourceMappingStart(expression); + switch (expression.kind()) { + case 173 /* CommaExpression */: + this.emit(expression.left); + this.writeToOutput(", "); + this.emit(expression.right); + break; + default: { + this.emit(expression.left); + var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); + if (binOp === "instanceof") { + this.writeToOutput(" instanceof "); + } else if (binOp === "in") { + this.writeToOutput(" in "); + } else { + this.writeToOutput(" " + binOp + " "); + } + this.emit(expression.right); + } + } + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimplePropertyAssignment = function (property) { + this.recordSourceMappingStart(property); + this.emit(property.propertyName); + this.writeToOutput(": "); + this.emit(property.expression); + this.recordSourceMappingEnd(property); + }; + + Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { + this.recordSourceMappingStart(funcProp); + + this.emit(funcProp.propertyName); + this.writeToOutput(": "); + + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); + + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + var funcName = funcProp.propertyName; + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcProp); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); + + this.recordSourceMappingEnd(funcProp); + + this.recordSourceMappingEnd(funcProp); + + this.emitComments(funcProp, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConditionalExpression = function (expression) { + this.emit(expression.condition); + this.writeToOutput(" ? "); + this.emit(expression.whenTrue); + this.writeToOutput(" : "); + this.emit(expression.whenFalse); + }; + + Emitter.prototype.emitThrowStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("throw "); + this.emit(statement.expression); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitExpressionStatement = function (statement) { + var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; + + this.recordSourceMappingStart(statement); + if (isArrowExpression) { + this.writeToOutput("("); + } + + this.emit(statement.expression); + + if (isArrowExpression) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitLabeledStatement = function (statement) { + this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); + this.writeLineToOutput(":"); + this.emitJavascript(statement.statement, true); + }; + + Emitter.prototype.emitBlock = function (block) { + this.recordSourceMappingStart(block); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + if (block.statements) { + this.emitList(block.statements); + } + this.emitCommentsArray(block.closeBraceLeadingComments, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(block); + }; + + Emitter.prototype.emitBreakStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("break"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitContinueStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("continue"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitWhileStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("while ("); + this.emit(statement.condition); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitDoStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("do"); + this.emitBlockOrStatement(statement.statement); + this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); + this.writeToOutput('('); + this.emit(statement.condition); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitIfStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("if ("); + this.emit(statement.condition); + this.writeToOutput(")"); + + this.emitBlockOrStatement(statement.statement); + + if (statement.elseClause) { + if (statement.statement.kind() !== 146 /* Block */) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + + this.emit(statement.elseClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitElseClause = function (elseClause) { + if (elseClause.statement.kind() === 147 /* IfStatement */) { + this.writeToOutput("else "); + this.emit(elseClause.statement); + } else { + this.writeToOutput("else"); + this.emitBlockOrStatement(elseClause.statement); + } + }; + + Emitter.prototype.emitReturnStatement = function (statement) { + this.recordSourceMappingStart(statement); + if (statement.expression) { + this.writeToOutput("return "); + this.emit(statement.expression); + } else { + this.writeToOutput("return"); + } + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitForInStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.left) { + this.emit(statement.left); + } else { + this.emit(statement.variableDeclaration); + } + this.writeToOutput(" in "); + this.emit(statement.expression); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitForStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.variableDeclaration) { + this.emit(statement.variableDeclaration); + } else if (statement.initializer) { + this.emit(statement.initializer); + } + + this.writeToOutput("; "); + this.emitJavascript(statement.condition, false); + this.writeToOutput(";"); + if (statement.incrementor) { + this.writeToOutput(" "); + this.emitJavascript(statement.incrementor, false); + } + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitWithStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("with ("); + if (statement.condition) { + this.emit(statement.condition); + } + + this.writeToOutput(")"); + var prevInWithBlock = this.inWithBlock; + this.inWithBlock = true; + this.emitBlockOrStatement(statement.statement); + this.inWithBlock = prevInWithBlock; + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitSwitchStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("switch ("); + this.emit(statement.expression); + this.recordSourceMappingStart(statement.closeParenToken); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement.closeParenToken); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + this.emitList(statement.switchClauses, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCaseSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("case "); + this.emit(clause.expression); + this.writeToOutput(":"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitSwitchClauseBody = function (body) { + if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { + this.emit(body.childAt(0)); + this.writeLineToOutput(""); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emit(body); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitDefaultSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("default:"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitTryStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("try "); + this.emit(statement.block); + this.emitJavascript(statement.catchClause, false); + + if (statement.finallyClause) { + this.emit(statement.finallyClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCatchClause = function (clause) { + this.writeToOutput(" "); + this.recordSourceMappingStart(clause); + this.writeToOutput("catch ("); + this.emit(clause.identifier); + this.writeToOutput(")"); + this.emit(clause.block); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitFinallyClause = function (clause) { + this.writeToOutput(" finally"); + this.emit(clause.block); + }; + + Emitter.prototype.emitDebuggerStatement = function (statement) { + this.writeToOutputWithSourceMapRecord("debugger", statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitNumericLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitRegularExpressionLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitStringLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitEqualsValueClause = function (clause) { + this.writeToOutput(" = "); + this.emit(clause.value); + }; + + Emitter.prototype.emitParameter = function (parameter) { + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); + }; + + Emitter.prototype.emitConstructorDeclaration = function (declaration) { + if (declaration.block) { + this.emitConstructor(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { + return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); + }; + + Emitter.prototype.emitFunctionDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { + this.emitFunction(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.emitSourceUnit = function (sourceUnit) { + if (!this.document.isDeclareFile()) { + var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + this.pushDecl(pullDecl); + this.emitScriptElements(sourceUnit); + this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); + } + }; + + Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); + }; + + Emitter.prototype.emitEnumDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { + this.emitComments(declaration, true); + this.emitEnum(declaration); + this.emitComments(declaration, false); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); + }; + + Emitter.prototype.emitModuleDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { + this.emitModuleDeclarationWorker(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); + }; + + Emitter.prototype.emitClassDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + this.emitClass(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { + return declaration.preComments() !== null; + }; + + Emitter.prototype.emitInterfaceDeclaration = function (declaration) { + this.emitComments(declaration, true, true); + }; + + Emitter.prototype.firstVariableDeclarator = function (statement) { + return statement.declaration.declarators.nonSeparatorAt(0); + }; + + Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { + return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; + }; + + Emitter.prototype.shouldEmitVariableStatement = function (statement) { + return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); + }; + + Emitter.prototype.emitVariableStatement = function (statement) { + if (this.isNotAmbientOrHasInitializer(statement)) { + this.emitComments(statement, true); + this.emit(statement.declaration); + this.writeToOutput(";"); + this.emitComments(statement, false); + } else { + this.emitComments(statement, true, true); + } + }; + + Emitter.prototype.emitGenericType = function (type) { + this.emit(type.name); + }; + + Emitter.prototype.shouldEmit = function (ast) { + if (!ast) { + return false; + } + + switch (ast.kind()) { + case 133 /* ImportDeclaration */: + return this.shouldEmitImportDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.shouldEmitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.shouldEmitInterfaceDeclaration(ast); + case 129 /* FunctionDeclaration */: + return this.shouldEmitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.shouldEmitModuleDeclaration(ast); + case 148 /* VariableStatement */: + return this.shouldEmitVariableStatement(ast); + case 223 /* OmittedExpression */: + return false; + case 132 /* EnumDeclaration */: + return this.shouldEmitEnumDeclaration(ast); + } + + return true; + }; + + Emitter.prototype.emit = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 2 /* SeparatedList */: + return this.emitSeparatedList(ast); + case 1 /* List */: + return this.emitList(ast); + case 120 /* SourceUnit */: + return this.emitSourceUnit(ast); + case 133 /* ImportDeclaration */: + return this.emitImportDeclaration(ast); + case 134 /* ExportAssignment */: + return this.setExportAssignment(ast); + case 131 /* ClassDeclaration */: + return this.emitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitInterfaceDeclaration(ast); + case 11 /* IdentifierName */: + return this.emitName(ast, true); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast); + case 219 /* SimpleArrowFunctionExpression */: + return this.emitSimpleArrowFunctionExpression(ast); + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.emitParenthesizedArrowFunctionExpression(ast); + case 129 /* FunctionDeclaration */: + return this.emitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitModuleDeclaration(ast); + case 224 /* VariableDeclaration */: + return this.emitVariableDeclaration(ast); + case 126 /* GenericType */: + return this.emitGenericType(ast); + case 137 /* ConstructorDeclaration */: + return this.emitConstructorDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitEnumDeclaration(ast); + case 243 /* EnumElement */: + return this.emitEnumElement(ast); + case 222 /* FunctionExpression */: + return this.emitFunctionExpression(ast); + case 148 /* VariableStatement */: + return this.emitVariableStatement(ast); + } + + this.emitComments(ast, true); + this.emitWorker(ast); + this.emitComments(ast, false); + }; + + Emitter.prototype.emitWorker = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 13 /* NumericLiteral */: + return this.emitNumericLiteral(ast); + case 12 /* RegularExpressionLiteral */: + return this.emitRegularExpressionLiteral(ast); + case 14 /* StringLiteral */: + return this.emitStringLiteral(ast); + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 37 /* TrueKeyword */: + return this.emitLiteralExpression(ast); + case 35 /* ThisKeyword */: + return this.emitThisExpression(ast); + case 50 /* SuperKeyword */: + return this.emitSuperExpression(ast); + case 217 /* ParenthesizedExpression */: + return this.emitParenthesizedExpression(ast); + case 214 /* ArrayLiteralExpression */: + return this.emitArrayLiteralExpression(ast); + case 211 /* PostDecrementExpression */: + case 210 /* PostIncrementExpression */: + return this.emitPostfixUnaryExpression(ast); + case 167 /* LogicalNotExpression */: + case 166 /* BitwiseNotExpression */: + case 165 /* NegateExpression */: + case 164 /* PlusExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.emitPrefixUnaryExpression(ast); + case 213 /* InvocationExpression */: + return this.emitInvocationExpression(ast); + case 221 /* ElementAccessExpression */: + return this.emitElementAccessExpression(ast); + case 212 /* MemberAccessExpression */: + return this.emitMemberAccessExpression(ast); + case 121 /* QualifiedName */: + return this.emitQualifiedName(ast); + case 173 /* CommaExpression */: + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 187 /* LogicalOrExpression */: + case 188 /* LogicalAndExpression */: + case 189 /* BitwiseOrExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 191 /* BitwiseAndExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return this.emitBinaryExpression(ast); + case 186 /* ConditionalExpression */: + return this.emitConditionalExpression(ast); + case 232 /* EqualsValueClause */: + return this.emitEqualsValueClause(ast); + case 242 /* Parameter */: + return this.emitParameter(ast); + case 146 /* Block */: + return this.emitBlock(ast); + case 235 /* ElseClause */: + return this.emitElseClause(ast); + case 147 /* IfStatement */: + return this.emitIfStatement(ast); + case 149 /* ExpressionStatement */: + return this.emitExpressionStatement(ast); + case 139 /* GetAccessor */: + return this.emitGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitSetAccessor(ast); + case 157 /* ThrowStatement */: + return this.emitThrowStatement(ast); + case 150 /* ReturnStatement */: + return this.emitReturnStatement(ast); + case 216 /* ObjectCreationExpression */: + return this.emitObjectCreationExpression(ast); + case 151 /* SwitchStatement */: + return this.emitSwitchStatement(ast); + case 233 /* CaseSwitchClause */: + return this.emitCaseSwitchClause(ast); + case 234 /* DefaultSwitchClause */: + return this.emitDefaultSwitchClause(ast); + case 152 /* BreakStatement */: + return this.emitBreakStatement(ast); + case 153 /* ContinueStatement */: + return this.emitContinueStatement(ast); + case 154 /* ForStatement */: + return this.emitForStatement(ast); + case 155 /* ForInStatement */: + return this.emitForInStatement(ast); + case 158 /* WhileStatement */: + return this.emitWhileStatement(ast); + case 163 /* WithStatement */: + return this.emitWithStatement(ast); + case 220 /* CastExpression */: + return this.emitCastExpression(ast); + case 215 /* ObjectLiteralExpression */: + return this.emitObjectLiteralExpression(ast); + case 240 /* SimplePropertyAssignment */: + return this.emitSimplePropertyAssignment(ast); + case 241 /* FunctionPropertyAssignment */: + return this.emitFunctionPropertyAssignment(ast); + case 156 /* EmptyStatement */: + return this.writeToOutputWithSourceMapRecord(";", ast); + case 159 /* TryStatement */: + return this.emitTryStatement(ast); + case 236 /* CatchClause */: + return this.emitCatchClause(ast); + case 237 /* FinallyClause */: + return this.emitFinallyClause(ast); + case 160 /* LabeledStatement */: + return this.emitLabeledStatement(ast); + case 161 /* DoStatement */: + return this.emitDoStatement(ast); + case 171 /* TypeOfExpression */: + return this.emitTypeOfExpression(ast); + case 170 /* DeleteExpression */: + return this.emitDeleteExpression(ast); + case 172 /* VoidExpression */: + return this.emitVoidExpression(ast); + case 162 /* DebuggerStatement */: + return this.emitDebuggerStatement(ast); + } + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; + + function getLastConstructor(classDecl) { + return classDecl.classElements.lastOrDefault(function (e) { + return e.kind() === 137 /* ConstructorDeclaration */; + }); + } + TypeScript.getLastConstructor = getLastConstructor; + + function getTrimmedTextLines(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + return comment.fullText().split("\n").map(function (s) { + return s.trim(); + }); + } else { + return [comment.fullText().trim()]; + } + } + TypeScript.getTrimmedTextLines = getTrimmedTextLines; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += memberName.text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function stripStartAndEndQuotes(str) { + var firstCharCode = str && str.charCodeAt(0); + if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + return str.substring(1, str.length - 1); + } + + return str; + } + TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; + + function isSingleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isDoubleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; + } + TypeScript.isDoubleQuoted = isDoubleQuoted; + + function isQuoted(str) { + return isDoubleQuoted(str) || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function changePathToDTS(modPath) { + return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + function convertToDirectoryPath(dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + } + TypeScript.convertToDirectoryPath = convertToDirectoryPath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + function isNoDefaultLibMatch(comment) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + return isNoDefaultLibRegex.exec(comment); + } + + TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; + + function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { + var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } + } + } + + return null; + } + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + var start = new Date().getTime(); + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionScanImportsTime += totalTime; + } + + function processTripleSlashDirectives(fileName, lineMap, firstToken) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + var diagnostics = []; + var referencedFiles = []; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + var isNoDefaultLib = isNoDefaultLibMatch(triviaText); + if (isNoDefaultLib) { + noDefaultLib = isNoDefaultLib[3] === "true"; + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; + } + + function preProcessFile(fileName, sourceText, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); + + scannerDiagnostics.length = 0; + return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); + } + TypeScript.getParseOptions = getParseOptions; + + function getReferencedFiles(fileName, sourceText) { + return preProcessFile(fileName, sourceText, false).referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, lineMap, position, length, isImported) { + this.filePath = filePath; + this.lineMap = lineMap; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { + this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this.inputFileNames = inputFileNames; + this.host = host; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { + var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var _this = this; + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); + this.inputFileNames.forEach(function (fileName) { + return _this.resolveIncludedFile(fileName, referenceLocation, result); + }); + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(tsFile)) { + normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + var start = new Date().getTime(); + + do { + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var _this = this; + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var start = new Date().getTime(); + var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionIOTime += totalTime; + + var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); + resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); + var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + }); + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(name, writeByteOrderMark, outputFileType) { + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.outputFileType = outputFileType; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + }; + + TextWriter.prototype.getOutputFile = function () { + return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.emittedReferencePaths = false; + this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); + } + DeclarationEmitter.prototype.getOutputFile = function () { + return this.declFile.getOutputFile(); + }; + + DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { + this.emitDeclarationsForSourceUnit(sourceUnit); + }; + + DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.emitDeclarationsForAST(list.childAt(i)); + } + }; + + DeclarationEmitter.prototype.emitSeparatedList = function (list) { + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.emitDeclarationsForAST(list.nonSeparatorAt(i)); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { + switch (ast.kind()) { + case 148 /* VariableStatement */: + return this.emitDeclarationsForVariableStatement(ast); + case 141 /* PropertySignature */: + return this.emitPropertySignature(ast); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast, true, true); + case 136 /* MemberVariableDeclaration */: + return this.emitDeclarationsForMemberVariableDeclaration(ast); + case 137 /* ConstructorDeclaration */: + return this.emitDeclarationsForConstructorDeclaration(ast); + case 139 /* GetAccessor */: + return this.emitDeclarationsForGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitDeclarationsForSetAccessor(ast); + case 138 /* IndexMemberDeclaration */: + return this.emitIndexMemberDeclaration(ast); + case 144 /* IndexSignature */: + return this.emitIndexSignature(ast); + case 142 /* CallSignature */: + return this.emitCallSignature(ast); + case 143 /* ConstructSignature */: + return this.emitConstructSignature(ast); + case 145 /* MethodSignature */: + return this.emitMethodSignature(ast); + case 129 /* FunctionDeclaration */: + return this.emitDeclarationsForFunctionDeclaration(ast); + case 135 /* MemberFunctionDeclaration */: + return this.emitMemberFunctionDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.emitDeclarationsForClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitDeclarationsForInterfaceDeclaration(ast); + case 133 /* ImportDeclaration */: + return this.emitDeclarationsForImportDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitDeclarationsForModuleDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitDeclarationsForEnumDeclaration(ast); + case 134 /* ExportAssignment */: + return this.emitDeclarationsForExportAssignment(ast); + } + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { + var container = this.getEnclosingContainer(declAST); + if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { + var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); + var container = this.getEnclosingContainer(declAST); + + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { + container = this.getEnclosingContainer(container); + } + + var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); + + if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { + result += "declare "; + } + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { + this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { + var declarationContainerAst = this.getEnclosingContainer(ast); + + var start = new Date().getTime(); + var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); + + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = TypeScript.getTrimmedTextLines(comment); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.semanticInfoChain.getDeclForAST(boundDecl); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = pullSymbol.type; + TypeScript.Debug.assert(type); + + this.declFile.Write(": "); + this.emitTypeSignature(boundDecl, type); + }; + + DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { + this.emitDeclarationComments(varDecl); + this.emitIndent(); + this.declFile.Write(varDecl.propertyName.text()); + if (varDecl.questionToken) { + this.declFile.Write("?"); + } + + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + if (isFirstVarInList) { + this.emitDeclFlags(varDecl, "var"); + } + + this.declFile.Write(varDecl.propertyName.text()); + + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + if (isLastVarInList) { + this.declFile.WriteLine(";"); + } else { + this.declFile.Write(", "); + } + } + }; + + DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { + if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } + this.declFile.Write("static "); + } else { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } else { + this.declFile.Write("public "); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(varDecl.modifiers); + ; + + this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); + + if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + this.declFile.WriteLine(";"); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { + this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); + }; + + 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); + } + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(id.text()); + if (isOptional) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (!isPrivate) { + this.emitTypeOfVariableDeclaratorOrParameter(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("constructor"); + + this.declFile.Write("("); + 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.ASTHelpers.parametersFromParameterList(parameterList)); + this.declFile.Write(")"); + }; + + DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { + var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); + var argsLen = parameterList.length; + if (hasLastParameterRestParameter) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + + if (hasLastParameterRestParameter) { + if (parameterList.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + var index = parameterList.length - 1; + this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); + } + }; + + DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitDeclFlags(funcDecl, "function"); + var id = funcDecl.propertyName.text(); + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); + + this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); + + if (!isPrivate) { + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + this.emitDeclarationComments(funcDecl); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); + + this.emitIndent(); + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("new"); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write(funcDecl.propertyName.text()); + if (funcDecl.questionToken) { + this.declFile.Write("? "); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + if (funcDecl.block) { + var funcTypeSymbol = funcSymbol.type; + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + var id = funcDecl.identifier.text(); + this.emitDeclFlags(funcDecl, "function"); + if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { + this.declFile.Write(id); + } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { + this.declFile.Write("new"); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { + this.emitDeclarationsForAST(funcDecl.indexSignature); + }; + + DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("["); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); + this.declFile.Write("]"); + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { + if (bases && (bases.nonSeparatorCount() > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.nonSeparatorCount(); + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + var base = bases.nonSeparatorAt(i); + var baseType = this.semanticInfoChain.getSymbolForAST(base); + this.emitTypeSignature(base, baseType); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); + } + if (accessors.setter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { + return; + } + + var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); + this.emitAccessorDeclarationComments(funcDecl); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(modifiers); + this.declFile.Write(name.text()); + if (!isPrivate) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(funcDecl, type); + } + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } + + 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(";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { + if (!this.canEmitDeclarations(classDecl)) { + return; + } + + var className = classDecl.identifier.text(); + this.emitDeclarationComments(classDecl); + var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.emitDeclFlags(classDecl, "class"); + this.declFile.Write(className); + + this.emitTypeParameters(classDecl.typeParameterList); + this.emitHeritageClauses(classDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + var constructorDecl = TypeScript.getLastConstructor(classDecl); + if (constructorDecl) { + this.emitClassMembersFromConstructorDefinition(constructorDecl); + } + + this.emitDeclarationsForList(classDecl.classElements); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { + if (clauses) { + for (var i = 0, n = clauses.childCount(); i < n; i++) { + this.emitHeritageClause(clauses.childAt(i)); + } + } + }; + + DeclarationEmitter.prototype.emitHeritageClause = function (clause) { + this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); + }; + + DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getEnclosingContainer(typeParams); + + var start = new Date().getTime(); + var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArgumentsOrTypeParameters(); + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { + if (!this.canEmitDeclarations(interfaceDecl)) { + return; + } + + var interfaceName = interfaceDecl.identifier.text(); + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); + this.emitDeclFlags(interfaceDecl, "interface"); + this.declFile.Write(interfaceName); + + this.emitTypeParameters(interfaceDecl.typeParameterList); + this.emitHeritageClauses(interfaceDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + + this.emitSeparatedList(interfaceDecl.body.typeMembers); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.identifier.text() + " = "); + if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); + } else { + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclFlags(moduleDecl, "enum"); + this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.enumElements.nonSeparatorCount(); + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); + var enumElement = memberDecl; + var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); + this.emitDeclarationComments(enumElement); + this.emitIndent(); + this.declFile.Write(enumElement.propertyName.text()); + if (enumElementDecl.constantValue !== null) { + this.declFile.Write(" = " + enumElementDecl.constantValue); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclarationComments(moduleDecl); + + var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); + this.emitDeclFlags(name, "module"); + + if (moduleDecl.stringLiteral) { + this.declFile.Write(moduleDecl.stringLiteral.text()); + } else { + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); + } + + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + + this.emitDeclarationsForList(moduleDecl.moduleElements); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.identifier.text()); + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { + if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { + return reference; + } + + var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); + var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); + return resolvedReferencePath; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.document.emitToOwnOutputFile()) { + var scriptReferences = this.document.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { + documents = documents.concat(document); + + if (!document.isDeclareFile() && document.isExternalModule()) { + addedGlobalDocument = true; + } + } + } + } else { + var fileNames = this.compiler.fileNames(); + for (var i = 0; i < fileNames.length; i++) { + var doc = this.compiler.getDocument(fileNames[i]); + if (!doc.isDeclareFile() && !doc.isExternalModule()) { + var scriptReferences = doc.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.isDeclareFile() || document.isExternalModule())) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] === document) { + break; + } + } + + if (k === documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.isDeclareFile()) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { + this.emitReferencePaths(sourceUnit); + this.emitDeclarationsForList(sourceUnit.moduleElements); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] !== array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + 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, createFileLog) { + this._propagateEnumConstants = propagateEnumConstants; + this._removeComments = removeComments; + this._watch = watch; + this._noResolve = noResolve; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + this._noImplicitAny = noImplicitAny; + this._noLib = noLib; + this._codeGenTarget = codeGenTarget; + this._moduleGenTarget = moduleGenTarget; + this._outFileOption = outFileOption; + this._outDirOption = outDirOption; + this._mapSourceFiles = mapSourceFiles; + this._mapRoot = mapRoot; + this._sourceRoot = sourceRoot; + this._generateDeclarationFiles = generateDeclarationFiles; + this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this._gatherDiagnostics = gatherDiagnostics; + this._codepage = codepage; + this._createFileLog = createFileLog; + } + ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { + return this._propagateEnumConstants; + }; + ImmutableCompilationSettings.prototype.removeComments = function () { + return this._removeComments; + }; + ImmutableCompilationSettings.prototype.watch = function () { + return this._watch; + }; + ImmutableCompilationSettings.prototype.noResolve = function () { + return this._noResolve; + }; + ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + ImmutableCompilationSettings.prototype.noImplicitAny = function () { + return this._noImplicitAny; + }; + ImmutableCompilationSettings.prototype.noLib = function () { + return this._noLib; + }; + ImmutableCompilationSettings.prototype.codeGenTarget = function () { + return this._codeGenTarget; + }; + ImmutableCompilationSettings.prototype.moduleGenTarget = function () { + return this._moduleGenTarget; + }; + ImmutableCompilationSettings.prototype.outFileOption = function () { + return this._outFileOption; + }; + ImmutableCompilationSettings.prototype.outDirOption = function () { + return this._outDirOption; + }; + ImmutableCompilationSettings.prototype.mapSourceFiles = function () { + return this._mapSourceFiles; + }; + ImmutableCompilationSettings.prototype.mapRoot = function () { + return this._mapRoot; + }; + ImmutableCompilationSettings.prototype.sourceRoot = function () { + return this._sourceRoot; + }; + ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { + return this._generateDeclarationFiles; + }; + ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { + return this._useCaseSensitiveFileResolution; + }; + ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { + return this._gatherDiagnostics; + }; + ImmutableCompilationSettings.prototype.codepage = function () { + return this._codepage; + }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; + + ImmutableCompilationSettings.defaultSettings = function () { + if (!ImmutableCompilationSettings._defaultSettings) { + ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); + } + + return ImmutableCompilationSettings._defaultSettings; + }; + + 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, 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, "_")) { + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; + } + } + + return result; + }; + return ImmutableCompilationSettings; + })(); + TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; + + PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + function hasModifier(modifiers, flag) { + for (var i = 0, n = modifiers.length; i < n; i++) { + if (TypeScript.hasFlag(modifiers[i], flag)) { + return true; + } + } + + return false; + } + TypeScript.hasModifier = hasModifier; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; + PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; + + 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.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"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var pullDeclID = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + 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; + this.childDeclTypeParameterCache = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.semanticInfoChain = semanticInfoChain; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + } + PullDecl.prototype.fileName = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentPath = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.isExternalModule = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getEnclosingDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { + var decl = this; + while (decl) { + switch (decl.kind) { + default: + return decl; + case 512 /* Variable */: + case 8192 /* TypeParameter */: + case 2048 /* Parameter */: + case 128 /* TypeAlias */: + case 67108864 /* EnumMember */: + } + + decl = decl.getParentDecl(); + } + + TypeScript.Debug.fail(); + }; + + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.semanticInfoChain.setSymbolForDecl(this, symbol); + }; + + 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 */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.semanticInfoChain.getSymbolForDecl(this); + }; + + PullDecl.prototype.hasSymbol = function () { + var symbol = this.semanticInfoChain.getSymbolForDecl(this); + return !!symbol; + }; + + PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); + }; + + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); + }; + + PullDecl.prototype.hasSignatureSymbol = function () { + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); + return !!signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; + }; + + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + if (declKind === 8192 /* TypeParameter */) { + if (!this.childDeclTypeParameterCache) { + this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeParameterCache; + } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { + if (!this.childDeclNamespaceCache) { + this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclNamespaceCache; + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { + if (!this.childDeclTypeCache) { + this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeCache; + } else { + if (!this.childDeclValueCache) { + this.childDeclValueCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclValueCache; + } + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + + if (!(childDecl.kind & 7340032 /* SomeSignature */)) { + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + } + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; + } else if (searchKind & 164 /* SomeContainer */) { + cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; + } else { + cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + if (!this.declGroups) { + this.declGroups = TypeScript.createIntrinsicsObject(); + } + + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + if (this.declGroups) { + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (declGroups === null) { + declGroups = []; + } + + declGroups.push(this.declGroups[declName].getDecls()); + } + } + } + + return declGroups || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.hasBeenBound = function () { + return this.hasSymbol() || this.hasSignatureSymbol(); + }; + + PullDecl.prototype.isSynthesized = function () { + return false; + }; + + PullDecl.prototype.ast = function () { + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var RootPullDecl = (function (_super) { + __extends(RootPullDecl, _super); + 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; + } + RootPullDecl.prototype.fileName = function () { + return this._fileName; + }; + + RootPullDecl.prototype.getParentPath = function () { + return [this]; + }; + + RootPullDecl.prototype.getParentDecl = function () { + return null; + }; + + RootPullDecl.prototype.isExternalModule = function () { + return this._isExternalModule; + }; + + 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, addToParent) { + if (typeof addToParent === "undefined") { addToParent = true; } + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); + this.parentDecl = null; + this.parentPath = null; + + this.parentDecl = parentDecl; + 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._rootDecl.fileName(); + }; + + NormalPullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + NormalPullDecl.prototype.getParentPath = function () { + if (!this.parentPath) { + var path = [this]; + var parentDecl = this.parentDecl; + + while (parentDecl) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { + path.unshift(parentDecl); + } + + parentDecl = parentDecl.getParentDecl(); + } + + this.parentPath = path; + } + + return this.parentPath; + }; + + NormalPullDecl.prototype.isExternalModule = function () { + return false; + }; + + 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) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); + this.constantValue = null; + } + return PullEnumElementDecl; + })(NormalPullDecl); + TypeScript.PullEnumElementDecl = PullEnumElementDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { + if (typeof displayName === "undefined") { displayName = ""; } + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(NormalPullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullSynthesizedDecl = (function (_super) { + __extends(PullSynthesizedDecl, _super); + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; + } + PullSynthesizedDecl.prototype.isSynthesized = function () { + return true; + }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; + return PullSynthesizedDecl; + })(NormalPullDecl); + TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = ++TypeScript.pullSymbolID; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.rootSymbol = null; + this._enclosingSignature = null; + this._docComments = null; + this.isPrinting = false; + this.name = name; + this.kind = declKind; + } + PullSymbol.prototype.isAny = function () { + return false; + }; + + PullSymbol.prototype.isType = function () { + return (this.kind & 58728795 /* SomeType */) !== 0; + }; + + PullSymbol.prototype.isTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & 7340032 /* SomeSignature */) !== 0; + }; + + PullSymbol.prototype.isArrayNamedTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { + if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } + if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } + var scopeDeclarations = scopeSymbol.getDeclarations(); + var scopeSymbolAliasesToLookIn = []; + + for (var i = 0; i < scopeDeclarations.length; i++) { + var scopeDecl = scopeDeclarations[i]; + if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { + visitedScopeDeclarations.push(scopeDecl); + + var childDecls = scopeDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { + var symbol = childDecl.getSymbol(); + + if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { + aliasSymbols.push(symbol); + return aliasSymbols; + } + + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { + scopeSymbolAliasesToLookIn.push(symbol); + } + } + } + } + } + + for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { + var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; + + aliasSymbols.push(scopeSymbolAlias); + var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); + if (result) { + return result; + } + + aliasSymbols.pop(); + } + + return null; + }; + + PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); + return symbols; + } + + return null; + }; + + PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { + if (aliasSymbol) { + if (aliasSymbol.assignedValue()) { + return false; + } + + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { + return false; + } + + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { + return false; + } + + return true; + } + + return false; + }; + + PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { + if (scopeSymbol) { + 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); + return internalAliases[0]; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { + if (!skipInternalAlias) { + var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); + if (internalAlias) { + return aliasNameGetter(internalAlias); + } + } + + var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); + + if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { + 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 aliasFullName; + } + + return null; + }; + + PullSymbol.prototype._getResolver = function () { + TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); + return this._declarations[0].semanticInfoChain.getResolver(); + }; + + PullSymbol.prototype._resolveDeclaredSymbol = function () { + return this._getResolver().resolveDeclaredSymbol(this); + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getName(); + }); + return aliasName || this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getDisplayName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getDisplayName(); + }, skipInternalAliasName); + if (aliasDisplayName) { + return aliasDisplayName; + } + + var decls = this.getDeclarations(); + var name = decls.length && decls[0].getDisplayName(); + + return (name && name.length) ? name : this.name; + }; + + PullSymbol.prototype.getIsSpecialized = function () { + return false; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + 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; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.hasDeclaration = function (decl) { + if (!this._declarations) { + return false; + } + + return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { + return eachDecl === decl; + }); + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.anyDeclHasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (TypeScript.hasFlag(declarations[i].flags, flag)) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!TypeScript.hasFlag(declarations[i].flags, flag)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = node.getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind === 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + PullSymbol.prototype.findCommonAncestorPath = function (b) { + var aPath = this.pathToRoot(); + if (aPath.length === 1) { + return aPath; + } + + var bPath; + if (b) { + bPath = b.pathToRoot(); + } else { + return aPath; + } + + 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; + } + } + } + if (commonNodeIndex >= 0) { + break; + } + } + + if (commonNodeIndex >= 0) { + return aPath.slice(0, commonNodeIndex); + } else { + return aPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; + var path = this.pathToRoot(); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol === _this ? null : symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + var path = this.findCommonAncestorPath(scopeSymbol); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { + var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + 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 */) { + var signatures = type.getCallSignatures(); + 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); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + + inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); + + var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); + inIsExternallyVisibleSymbols.pop(); + + return result; + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.rootSymbol) { + return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); + } + + if (this.isType()) { + var associatedContainerSymbol = this.getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.anyDeclHasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + var decls = this.getDeclarations(); + if (decls.length) { + var parentDecl = decls[0].getParentDecl(); + if (parentDecl) { + var parentSymbol = parentDecl.getSymbol(); + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { + return true; + } + + return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); + } + } + + return true; + } + + 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 */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { + var ast = decl.ast(); + + if (ast) { + 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.ASTHelpers.docComments(ast); + } + } + + return []; + }; + + PullSymbol.prototype.getDocCommentArray = function (symbol) { + var docComments = []; + if (!symbol) { + return docComments; + } + + 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 */) { + continue; + } + docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); + } + return docComments; + }; + + PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { + if (classSymbol.getHasDefaultConstructor()) { + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); + } + } + + return classSymbol.type.getConstructSignatures()[0]; + }; + + PullSymbol.prototype.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = this.getDocCommentTextValue(comments[c]); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + PullSymbol.prototype.getDocCommentTextValue = function (comment) { + return this.cleanJSDocComment(comment.fullText()); + }; + + PullSymbol.prototype.docComments = function (useConstructorAsClass) { + var decls = this.getDeclarations(); + 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 */) { + var classSymbol = this.returnType; + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + docComments = extendedTypes[0].getConstructorMethod().docComments(); + } else { + docComments = ""; + } + } else if (this.kind === 2048 /* Parameter */) { + var parameterComments = []; + + var funcContainer = this.getEnclosingSignature(); + var funcDocComments = this.getDocCommentArray(funcContainer); + var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); + if (paramComment != "") { + parameterComments.push(paramComment); + } + + var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); + if (paramSelfComment != "") { + parameterComments.push(paramSelfComment); + } + docComments = parameterComments.join("\n"); + } else { + var getSymbolComments = true; + if (this.kind === 16777216 /* FunctionType */) { + var functionSymbol = this.getFunctionSymbol(); + + if (functionSymbol) { + docComments = functionSymbol._docComments || ""; + getSymbolComments = false; + } else { + var declarationList = this.getDeclarations(); + if (declarationList.length > 0) { + docComments = declarationList[0].getSymbol()._docComments || ""; + getSymbolComments = false; + } + } + } + if (getSymbolComments) { + docComments = this.getDocCommentText(this.getDocCommentArray(this)); + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { + var callTypeSymbol = this.functionType; + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { + docComments = callTypeSymbol.docComments(); + } + } + } + } + } + + this._docComments = docComments; + } + + return this._docComments; + }; + + PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].fullText(); + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!this.isSpaceChar(commentContents, j)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + + PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.start; + for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.end); + } + + var newCleanPos = this.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + PullSymbol.prototype.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = this.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + start: nonSpaceIndex, + end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + 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.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; + this.hasBeenChecked = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return this._isDefinition; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + 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) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this._typeParameters) { + this._typeParameters = []; + } + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + 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 = []; + } + + return this._typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; + } + } + + memberSymbol = this._memberTypeParameterNameCache[name]; + + 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; + this._stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { + this._stringConstantOverload = true; + } + } + } + + 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); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + 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 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 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 wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + + var parameters = this.parameters; + + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._enclosedMemberContainers = null; + this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._enclosedContainerCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._containedNonMemberContainerCache = null; + this._simpleInstantiationCache = null; + this._complexInstantiationCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this._inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + this.typeReference = null; + this._widenedType = null; + this._isArrayNamedTypeReference = undefined; + this.type = this; + } + PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { + if (this._isArrayNamedTypeReference === undefined) { + this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); + } + + return this._isArrayNamedTypeReference; + }; + + PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { + var typeArgs = this.getTypeArguments(); + if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { + var declaration = this.getDeclarations()[0]; + + if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind === 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind === 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullTypeSymbol.prototype.isObject = function () { + 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 () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members !== TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return null; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberContainerCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = TypeScript.createIntrinsicsObject(); + } + + if (this._members === TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members.push(memberSymbol); + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + if (!enclosedContainer) { + return; + } + + enclosedContainer.setContainer(this); + + if (!this._enclosedContainerCache) { + this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberContainers) { + this._enclosedMemberContainers = []; + } + + this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; + this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + if (!enclosedNonMemberContainer) { + return; + } + + enclosedNonMemberContainer.setContainer(this); + + if (!this._containedNonMemberContainerCache) { + this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + 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 (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; + } + + 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; + } else { + if (!this._complexInstantiationCache) { + this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType.push(specializedVersionOfThisType); + }; + + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { + if (!this._simpleInstantiationCache) { + return null; + } + + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; + } else { + if (!this._complexInstantiationCache) { + return null; + } + + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + } + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return null; + }; + + PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + return this.getTypeParameters(); + }; + + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + 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 = []; + } + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + 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 = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + 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; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return this._constructSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function () { + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return this._indexSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnIndexSignatures = function () { + return this._indexSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function () { + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + } + } + + this._allIndexSignatures = signatures; + + 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; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { + if (typeof visited === "undefined") { visited = []; } + if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { + return true; + } + + if (TypeScript.ArrayUtilities.contains(visited, this)) { + return true; + } + + visited.push(this); + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + visited.pop(); + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (memberSymbol || !lookInParent) { + return memberSymbol; + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedContainerCache) { + return null; + } + + memberSymbol = this._enclosedContainerCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + var allMembers = []; + + 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 */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; + + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer()) { + if (this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + if (this._enclosedMemberContainers) { + for (var i = 0; i < this._enclosedMemberContainers.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberContainers[i]; + } + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArgumentsOrTypeParameters(); + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); + }; + + 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 !== "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); + return s; + }; + + 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, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + if (skipTypeParametersInName) { + return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); + } else { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + + var typars = this.getTypeArgumentsOrTypeParameters(); + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + } + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getTypeOfSymbol = function () { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + return associatedContainerType; + } + + var functionSymbol = this.getFunctionSymbol(); + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; + } + + return null; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + var typeOfSymbol = this.getTypeOfSymbol(); + if (typeOfSymbol) { + var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } + + if (this._inMemberTypeNameEx) { + return TypeScript.MemberName.create("any"); + } + + this._inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + 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()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && memberTypeName.delim === delim) { + allMemberNames.addAll(memberTypeName.entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this._inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + return 2 /* Closed */; + }; + + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + + if (type.isTypeParameter()) { + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; + } + + var constraint = type.getConstraint(); + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; + } + + if (type.inWrapCheck) { + return 0; + } + + 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; + + var typeArguments = type.getTypeArguments(); + + if (type.isGeneric() && !typeArguments) { + typeArguments = type.getTypeParameters(); + } + + if (typeArguments) { + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); + } + } + } + + 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); + } + + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); + } + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } + + return wrappingTypeParameterID; + }; + + 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + 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(); + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; + } + + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { + return true; + } + } + + 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); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isAny = function () { + 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 () { + return false; + }; + + 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; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(_anyType, name) { + _super.call(this, name); + 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); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerSymbol = (function (_super) { + __extends(PullContainerSymbol, _super); + function PullContainerSymbol(name, kind) { + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerSymbol.prototype.hasExportAssignment = function () { + return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; + }; + + PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { + return true; + } + + var moduleSymbol = containerSymbol; + var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerSymbol = PullContainerSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 128 /* TypeAlias */); + this._assignedValue = null; + this._assignedType = null; + 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; + }; + + PullTypeAliasSymbol.prototype.isUsedAsValue = function () { + this._resolveDeclaredSymbol(); + return this._isUsedAsValue; + }; + + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; + }; + + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; + + 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(); + }); + } + }; + + PullTypeAliasSymbol.prototype.assignedValue = function () { + this._resolveDeclaredSymbol(); + return this._assignedValue; + }; + + PullTypeAliasSymbol.prototype.assignedType = function () { + this._resolveDeclaredSymbol(); + return this._assignedType; + }; + + PullTypeAliasSymbol.prototype.assignedContainer = function () { + this._resolveDeclaredSymbol(); + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this._assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this._assignedValue) { + return this._assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this._assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedType) { + if (this._assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = this._assignedType.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this._assignedType !== this._assignedContainer) { + return this._assignedType; + } + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this._assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this._assignedType) { + return this._assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this._assignedType) { + return this._assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this._assignedType) { + return this._assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this._assignedType) { + return this._assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this._assignedType) { + return this._assignedType.findMember(name, true); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedContainer(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { + if (this._assignedType) { + return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); + } + + return TypeScript.sentinelEmptyArray; + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name) { + _super.call(this, name, 8192 /* TypeParameter */); + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + 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(); + } + + return _super.prototype.getCallSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getConstructSignatures = function () { + if (this._constraint) { + return this._constraint.getConstructSignatures(); + } + + return _super.prototype.getConstructSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getIndexSignatures = function () { + if (this._constraint) { + return this._constraint.getIndexSignatures(); + } + + return _super.prototype.getIndexSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { + var substitution = ""; + var members = null; + + 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 getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); + } + + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); + } + + return null; + } + + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.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"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; + })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); + 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._inferredTypeAfterFixing = null; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + 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 TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + this.candidateCache = []; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); + } + } + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { + return true; + } else { + this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); + return false; + } + }; + + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache.release(); + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + }; + + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolID]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolID] = info; + } + }; + + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolID]; + }; + + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { + var info = this.getInferenceInfo(param); + + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); + } + }; + + 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); + } + }; + + 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]; + + info.fixTypeParameter(this.resolver, this.context); + + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; + } + } + + results.push(info._inferredTypeAfterFixing); + } + + return results; + }; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; + })(); + 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, isInferentiallyTyping, typeArgumentInferenceContext) { + this.contextualType = contextualType; + this.provisional = provisional; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; + this.provisionallyTypedSymbols = []; + this.hasProvisionalErrors = false; + this.astSymbolMap = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].setUnresolved(); + } + }; + + PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()]; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + if (typeof fileName === "undefined") { fileName = null; } + this.resolver = resolver; + this.inTypeCheck = inTypeCheck; + 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"); + this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); + } + } + PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { + if (!this.inProvisionalResolution()) { + this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); + } + }; + + PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { + return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); + }; + + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); + }; + + 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(); + + if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; + } + + return tc; + }; + + PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + 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); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); + } + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { + if (diagnostic) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; + } else if (this.inTypeCheck && this.resolver) { + this.resolver.semanticInfoChain.addDiagnostic(diagnostic); + } + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inProvisionalResolution(); + }; + + PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { + this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); + }; + + PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + var typeContext = this.contextStack[i]; + if (!typeContext.provisional) { + break; + } + + var symbol = typeContext.getSymbolForAST(ast); + if (symbol) { + return symbol; + } + } + + 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; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OverloadApplicabilityStatus; + (function (OverloadApplicabilityStatus) { + OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; + })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + this.diagnosticsFromOverloadResolution = []; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var MemberWithBaseOrigin = (function () { + function MemberWithBaseOrigin(memberSymbol, baseOrigin) { + this.memberSymbol = memberSymbol; + this.baseOrigin = baseOrigin; + } + return MemberWithBaseOrigin; + })(); + + var SignatureWithBaseOrigin = (function () { + function SignatureWithBaseOrigin(signature, baseOrigin) { + this.signature = signature; + this.baseOrigin = baseOrigin; + } + return SignatureWithBaseOrigin; + })(); + + var InheritedIndexSignatureInfo = (function () { + function InheritedIndexSignatureInfo() { + } + return InheritedIndexSignatureInfo; + })(); + + 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(); + return CompilerReservedName[nameText]; + } + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this._cachedAnyTypeArgs = null; + this.typeCheckCallBacks = []; + this.postTypeCheckWorkitems = []; + this._cachedFunctionArgumentsSymbol = null; + 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 */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getArrayNamedType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { + if (!this._cachedFunctionArgumentsSymbol) { + this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); + functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); + this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + } + + 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); + }; + + PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { + return context.canTypeCheckAST(ast); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && context.inProvisionalResolution()) { + context.setSymbolForAST(ast, symbol); + } else { + this.semanticInfoChain.setSymbolForAST(ast, symbol); + } + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { + var symbol = this.semanticInfoChain.getSymbolForAST(ast); + + if (!symbol) { + if (context && context.inProvisionalResolution()) { + symbol = context.getSymbolForAST(ast); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { + if (typeof name === "undefined") { name = null; } + return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = decl.getParentPath(); + + if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.anyDeclHasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + 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 & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + + if (declSearchKind & 68147712 /* SomeValue */) { + member = parent.findMember(symbolName, true); + } else if (declSearchKind & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + } + + if (parent.kind & 164 /* SomeContainer */) { + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + return valueSymbol; + } + } + + return aliasSymbol; + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + 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; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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(); + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & 1032192 /* SomeFunction */) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (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) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = decl.getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var topLevelDecls = this.semanticInfoChain.topLevelDecls(); + for (var i = 0, n = topLevelDecls.length; i < n; i++) { + var topLevelDecl = topLevelDecls[i]; + if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { + continue; + } + + if (!topLevelDecl.isExternalModule()) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + 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 */ || lhs.kind === 64 /* Enum */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + this.resolveDeclaredSymbol(lhsType, context); + + if (lhsType.isContainer() && lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + var memberVisibilty = 2 /* externallyVisible */; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = enclosingDecl.getParentPath(); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { + memberVisibilty = 1 /* internallyVisible */; + break; + } + } + } + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + lhsType = this.getApparentType(lhsType); + + 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); + } + + 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 */)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { + var originalIdText = idText; + var symbol = null; + + if (TypeScript.isRelative(originalIdText)) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + symbol = this.semanticInfoChain.findExternalModule(path + idText); + } else { + idText = originalIdText; + + symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); + + if (!symbol) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + symbol = this.semanticInfoChain.findExternalModule(path + idText); + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + } + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { + if (!symbol || symbol.isResolved || symbol.isTypeReference()) { + return symbol; + } + + if (!context) { + context = new TypeScript.PullTypeResolutionContext(this); + } + + return this.resolveDeclaredSymbolWorker(symbol, context); + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.type && !symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + + var decls = symbol.getDeclarations(); + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + var ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + var resolvedSymbol; + 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 */); + resolvedSymbol = this.resolveAST(ast, false, context); + } + + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + 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(); + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); + }; + + PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { + var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); + var moduleSymbol = enclosingDecl.getSymbol(); + this.ensureAllSymbolsAreBound(moduleSymbol); + + this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); + this.resolveAST(sourceUnit.moduleElements, false, context); + + if (this.canTypeCheckAST(sourceUnit, context)) { + this.typeCheckSourceUnit(sourceUnit, context); + } + + return moduleSymbol; + }; + + 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) { + var containerDecl = this.semanticInfoChain.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + containerSymbol.setResolved(); + + this.resolveOtherDeclarations(ast, context); + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckEnumDeclaration(ast, context); + } + + return containerSymbol; + }; + + 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); + + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { + this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); + } + }; + + PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { + 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; + + if (ast.stringLiteral) { + result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckModuleDeclaration(ast, context); + } + + return result; + }; + + PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { + if (containerSymbol) { + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + }; + + PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + this.ensureAllSymbolsAreBound(containerSymbol); + + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, context); + } + + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + if (isLastName) { + this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); + } else if (sourceUnitAST) { + this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); + } + + containerSymbol.setResolved(); + + if (moduleDeclNameAST) { + this.resolveOtherDeclarations(moduleDeclNameAST, context); + } + + return containerSymbol; + }; + + 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 */) { + this.resolveExportAssignmentStatement(moduleElement, context); + return; + } + } + }; + + PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + var containerSymbol = containerDecl.getSymbol(); + + return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); + }; + + PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { + if (ast.stringLiteral) { + this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + }; + + PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; + this.setTypeChecked(ast, context); + + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { + this.resolveAST(ast.moduleElements, false, context); + } + + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + this.validateVariableDeclarationGroups(containerDecl, context); + + if (ast.stringLiteral) { + if (TypeScript.isRelative(ast.stringLiteral.valueText())) { + this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); + } + } + + 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) { + this.checkThisCaptureVariableCollides(ast, true, context); + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { + if (term.kind() === 11 /* IdentifierName */) { + return true; + } else if (term.kind() === 121 /* QualifiedName */) { + var binex = term; + + if (binex.right.kind() === 11 /* IdentifierName */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { + if (!type.isGeneric()) { + return type; + } + + var typeParameters = type.getTypeArgumentsOrTypeParameters(); + + var typeParameterArgumentMap = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); + } + + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); + if (extendsClause) { + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + + if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + } + } + } + + 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()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); + var implementedType = this.resolveTypeReference(implementedTypeAST, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + + if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addImplementedType(implementedType); + } + } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + + this.typeCheckCallBacks.push(function (context) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + _this.resolveClassDeclaration(classOrInterface, context); + } else { + _this.resolveInterfaceDeclaration(classOrInterface, context); + } + }); + + return typeDeclSymbol; + } + + this.setSymbolForAST(name, typeDeclSymbol, context); + this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + 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); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + var parentConstructor = parentType ? parentType.getConstructorMethod() : null; + + if (parentConstructor) { + this.resolveDeclaredSymbol(parentConstructor, context); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + + if (!parentConstructSignatures.length) { + parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + parentConstructSignature.returnType = parentType; + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); + parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); + parentConstructSignatures = [parentConstructSignature]; + } + + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + 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); + } + + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + + if (parentConstructorSymbol) { + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + } + } + + this.resolveOtherDeclarations(classDeclAST, context); + } + + if (this.canTypeCheckAST(classDeclAST, context)) { + this.typeCheckClassDeclaration(classDeclAST, context); + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { + var _this = this; + 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); + }); + } + } + }; + + PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { + this.setTypeChecked(classDeclAST, context); + + var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + + this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); + this.resolveAST(classDeclAST.classElements, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); + this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + + if (!classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); + }; + + PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { + this.checkThisCaptureVariableCollides(classDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { + var callSignatures = typeSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], context); + } + + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], context); + } + + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], context); + } + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); + + if (interfaceDeclSymbol.isResolved) { + this.resolveOtherDeclarations(interfaceDeclAST, context); + + if (this.canTypeCheckAST(interfaceDeclAST, context)) { + this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { + this.setTypeChecked(interfaceDeclAST, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); + this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); + + 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) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + this.resolveDeclaredSymbol(symbol, context); + + var alias = symbol; + if (kind & 164 /* SomeContainer */) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & 58728795 /* SomeType */) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & 68147712 /* SomeValue */) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); + + return { + symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), + aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null + }; + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + var rhsName = identifier.valueText(); + if (rhsName.length === 0) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); + var containerSymbol = memberSymbol.symbol; + var valueSymbol = null; + var typeSymbol = null; + var aliasSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + aliasSymbol = memberSymbol.aliasSymbol; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + aliasSymbol = containerSymbol; + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); + valueSymbol = memberSymbol.symbol; + if (valueSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + } + + if (!typeSymbol) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + typeSymbol = memberSymbol.symbol; + if (typeSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); + return null; + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol, + aliasSymbol: aliasSymbol + }; + }; + + 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"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleContainer) { + moduleName = dottedNameAST.right.valueText(); + + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; + if (!moduleSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); + } + } + } else { + var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); + var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); + + if (text.length > 0) { + var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); + moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); + if (moduleSymbol) { + 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]); + } + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var moduleReference = importStatementAST.moduleReference; + + var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; + + 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); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); + if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { + var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); + var instanceSymbol = aliasedType.getInstanceSymbol(); + + 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 { + importDeclSymbol.setAssignedValueSymbol(valueSymbol); + } + } + } else { + aliasedType = this.getNewErrorTypeSymbol(); + } + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); + return null; + } + } + } + + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + var declPath = enclosingDecl.getParentPath(); + + aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); + + if (!aliasedType) { + var path = importStatementAST.moduleReference.stringLiteral.text(); + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); + aliasedType = this.getNewErrorTypeSymbol(); + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); + } + + importDeclSymbol.setResolved(); + + this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); + 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); + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { + var _this = this; + this.setTypeChecked(importStatementAST, context); + + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (this.compilationSettings.noResolve()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); + } + + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + if (enclosingDecl.kind === 32 /* DynamicModule */) { + 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)); + } + } + } + } + + var checkPrivacy; + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind === 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + + 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; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { + var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + } + + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); + }; + + PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { + 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); + } + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { + var id = exportAssignmentAST.identifier.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && parentSymbol.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + + var aliasSymbol = containerSymbol; + var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + parentSymbol.setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + parentSymbol.setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + parentSymbol.setExportAssignedContainerSymbol(containerSymbol); + } + + this.resolveDeclaredSymbol(valueSymbol, context); + this.resolveDeclaredSymbol(typeSymbol, context); + this.resolveDeclaredSymbol(containerSymbol, context); + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + var funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); + } + } + + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.setTypeChecked(funcDeclAST, context); + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeAnnotation) { + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + 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) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + 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 (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(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + var contextualType = contextParam && contextParam.type; + var isImplicitAny = false; + + if (typeExpr) { + var typeRef = this.resolveTypeReference(typeExpr, context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + typeRef = this.getNewErrorTypeSymbol(); + } + + contextualType = typeRef || contextualType; + } + if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } + context.setTypeInContext(paramSymbol, contextualType); + } 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.propagateContextualType(contextualType); + } + + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + } + + if (!initExprSymbol || !initExprSymbol.type) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); + + if (!contextualType) { + context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); + } + } else { + var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); + if (!contextualType) { + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); + isImplicitAny = initTypeSymbol !== paramSymbol.type; + } else { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); + } + } + } + } + } + + if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + isImplicitAny = true; + } + + if (isImplicitAny && this.compilationSettings.noImplicitAny()) { + var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); + if (functionExpressionName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); + } + } + + if (canTypeCheckAST) { + this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { + var compilerReservedName = getCompilerReservedName(name); + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; + + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; + + case 3 /* arguments */: + this.checkArgumentsCollides(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; + } + }; + + PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { + var enclosingAST = this.getASTForDecl(someFunctionDecl); + var nodeType = enclosingAST.kind(); + + 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); + } 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 */) { + var constructorDeclaration = enclosingAST; + 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 */) { + var functionExpression = enclosingAST; + return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); + } + + return false; + }; + + PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { + if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); + } + } + } + }; + + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + 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)); + } + } + } + } + }; + + PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { + var decl = this.semanticInfoChain.getDeclForAST(ast); + + if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + var nameText = name.valueText(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); + } + } + }; + + PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); + TypeScript.Debug.assert(interfaceDecl); + + var interfaceSymbol = interfaceDecl.getSymbol(); + TypeScript.Debug.assert(interfaceSymbol); + + if (objectType.typeMembers) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = objectType.typeMembers; + + for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { + memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); + memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (this.canTypeCheckAST(objectType, context)) { + this.typeCheckObjectTypeTypeReference(objectType, context); + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { + this.setTypeChecked(objectType, context); + var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); + var objectTypeSymbol = objectTypeDecl.getSymbol(); + + this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); + }; + + PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { + return this.resolveTypeReference(typeAnnotation.type, context); + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { + if (typeRef === null) { + return null; + } + + TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); + + var aliasType = null; + var type = this.computeTypeReferenceSymbol(typeRef, context); + + if (type.kind === 4 /* Container */) { + var container = type; + var instanceSymbol = container.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + if (aliasType) { + this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); + } + } + + if (type && !type.isError()) { + 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 { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); + } + } + } + + if (this.canTypeCheckAST(typeRef, context)) { + this.setTypeChecked(typeRef, context); + } + + 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 */: + return this.semanticInfoChain.anyTypeSymbol; + case 61 /* BooleanKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + case 67 /* NumberKeyword */: + return this.semanticInfoChain.numberTypeSymbol; + case 69 /* StringKeyword */: + return this.semanticInfoChain.stringTypeSymbol; + case 41 /* VoidKeyword */: + return this.semanticInfoChain.voidTypeSymbol; + } + + var typeDeclSymbol = null; + + if (term.kind() === 11 /* IdentifierName */) { + typeDeclSymbol = this.resolveTypeNameExpression(term, context); + } else if (term.kind() === 123 /* FunctionType */) { + var functionType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); + } else if (term.kind() === 125 /* ConstructorType */) { + var constructorType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); + } else if (term.kind() === 122 /* ObjectType */) { + typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); + } else if (term.kind() === 126 /* GenericType */) { + typeDeclSymbol = this.resolveGenericTypeReference(term, context); + } else if (term.kind() === 121 /* QualifiedName */) { + typeDeclSymbol = this.resolveQualifiedName(term, context); + } else if (term.kind() === 14 /* StringLiteral */) { + 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, enclosingDecl.semanticInfoChain); + typeDeclSymbol.addDeclaration(decl); + } else if (term.kind() === 127 /* TypeQuery */) { + var typeQuery = term; + + var typeQueryTerm = typeQuery.name; + + var valueSymbol = this.resolveAST(typeQueryTerm, false, context); + + if (valueSymbol && valueSymbol.isAlias()) { + if (valueSymbol.assignedValue()) { + valueSymbol = valueSymbol.assignedValue(); + } else { + var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(); + } + } else if (term.kind() === 124 /* ArrayType */) { + var arrayType = term; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); + } else { + throw TypeScript.Errors.invalidOperation("unknown type"); + } + + if (!typeDeclSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); + return this.getNewErrorTypeSymbol(); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { + 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveParameterList = function (list, context) { + return this.resolveSeparatedList(list.parameters, context); + }; + + PullTypeResolver.prototype.resolveParameter = function (parameter, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { + var enumDeclaration = enumElement.parent.parent; + var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); + var symbol = decl.getSymbol(); + this.resolveDeclaredSymbol(symbol, context); + + return symbol; + }; + + PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { + if (this.canTypeCheckAST(clause, context)) { + this.setTypeChecked(clause, context); + } + + return this.resolveAST(clause.value, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + } else { + if (declSymbol.inResolution) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + + if (!declSymbol.type || !declSymbol.type.isError()) { + declSymbol.startResolving(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + if (!hasTypeExpr) { + this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + } + + if (!(hasTypeExpr || init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { + defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + } + } + + if (this.canTypeCheckAST(varDeclOrParameter, context)) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); + } + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (varDeclOrParameter.kind() === 243 /* EnumElement */) { + var result = this.getEnumTypeSymbol(varDeclOrParameter, context); + declSymbol.type = result; + return result; + } + + if (!typeExpr) { + return null; + } + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var typeExprSymbol = this.resolveTypeReference(typeExpr, context); + + if (!typeExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + declSymbol.type = this.getNewErrorTypeSymbol(); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = typeExprSymbol.getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } 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(); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + } + + return typeExprSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { + if (!init) { + return null; + } + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + if (typeExprSymbol) { + context.pushNewContextualType(typeExprSymbol); + } + + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); + + if (typeExprSymbol) { + context.popAnyContextualType(); + } + + if (!initExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + + if (!hasTypeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + var initTypeSymbol = initExprSymbol.type; + + if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); + context.setTypeInContext(declSymbol, widenedInitTypeSymbol); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny()) { + 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 initTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var _this = this; + this.setTypeChecked(varDeclOrParameter, context); + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + + if (hasTypeExpr || init) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = typeExprSymbol.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); + } + } + } + } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { + var wrapperDecl = this.getEnclosingDecl(decl); + 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])); + } else if (wrapperDecl.kind === 65536 /* Method */) { + var parentDecl = wrapperDecl.getParentDecl(); + + if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); + } 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 (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 */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } + } + } + + 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_only_allowed_in_implementation)); + } + } + 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 */)) { + this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); + } + }; + + PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { + return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; + }; + + PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { + var enclosingDecl = this.getEnclosingDeclForAST(superAST); + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); + + if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { + 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; + if (!block) { + return; + } + } + } + + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + if (parents.length) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); + } + } + }; + + PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { + if (isDeclaration) { + var decl = this.semanticInfoChain.getDeclForAST(_thisAST); + if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + return; + } + } + + var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + var declPath = enclosingDecl.getParentPath(); + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + continue; + } + + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); + } + break; + } + } + }; + + PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { + this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + 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) { + return; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + }; + + PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { + this.setTypeChecked(typeParameterAST, 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) { + if (this.canTypeCheckAST(constraint, context)) { + this.setTypeChecked(constraint, context); + } + + return this.resolveTypeReference(constraint.type, context); + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatementsExpressions = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, walker) { + var go = true; + + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); + go = false; + break; + + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, walker) { + switch (ast.kind()) { + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + if (block) { + TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + } else { + returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + } + + if (!returnStatementsExpressions.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnExpressions = []; + + for (var i = 0; i < returnStatementsExpressions.length; i++) { + var returnExpression = returnStatementsExpressions[i].expression; + if (returnExpression) { + var returnType = this.resolveAST(returnExpression, useContextualType, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { + this.setSymbolForAST(returnExpression.parent, returnType, context); + } + } + + returnExpressionSymbols.push(returnType); + returnExpressions.push(returnExpression); + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); + var returnType = bestCommonReturnType; + var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = returnType.widenedType(this, returnExpression, context); + signature.returnType = newReturnType; + + if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); + } + + if (this.compilationSettings.noImplicitAny()) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName === "") { + functionName = enclosingDecl.getFunctionExpressionName(); + } + + if (functionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } + + if (!functionSymbol.type && functionSymbol.isAccessor()) { + functionSymbol.type = signature.returnType; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { + var _this = this; + this.setTypeChecked(funcDeclAST, context); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { + var _this = this; + if (constructorDecl.block) { + var foundSuperCall = false; + var pre = function (ast, walker) { + if (_this.isSuperInvocationExpression(ast)) { + foundSuperCall = true; + walker.options.stopWalking = true; + } + }; + + TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); + return foundSuperCall; + } + + return false; + }; + + 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(parameters, false, context); + + this.resolveAST(block, false, context); + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + this.validateVariableDeclarationGroups(funcDecl, context); + + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); + + if (funcDecl.kind === 16384 /* Function */) { + this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); + } + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + this.resolveAST(funcDeclAST.parameter, false, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); + var stringIndexSignature = allIndexSignatures.stringSignature; + var numberIndexSignature = allIndexSignatures.numericSignature; + var isNumericIndexer = numberIndexSignature === signature; + + if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { + var comparisonInfo = new TypeComparisonInfo(); + + 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + } + } + } + + var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); + for (var i = 0; i < allMembers.length; i++) { + var member = allMembers[i]; + var name = member.name; + if (name || (member.kind === 4096 /* Property */ && name === "")) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], context); + } + + if (parentSymbol !== allMembers[i].getContainer()) { + var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); + var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; + var onlyStringIndexerIsPresent = !numberIndexSignature; + + if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { + var comparisonInfo = new TypeComparisonInfo(); + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); + } + } + } + } + } + }); + }; + + PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { + this.checkThisCaptureVariableCollides(funcDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { + var returnTypeSymbol = null; + + if (returnTypeAnnotation) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + } else { + var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } + + return returnTypeSymbol; + }; + + 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + return funcSymbol; + } + + if (!signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + 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(); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveIndexSignature(ast.indexSignature, context); + }; + + PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + return funcSymbol; + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.typeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.parameter) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + this.resolveParameter(funcDeclAST.parameter, context); + context.inTypeCheck = prevInTypeCheck; + } + + if (funcDeclAST.typeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + + context.inTypeCheck = prevInTypeCheck; + } + + if (returnTypeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { + if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { + 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; + if (funcDeclASTName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } + } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { + if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); + } + + return null; + }; + + 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.ASTHelpers.getType(parameter), context); + } + + return null; + }; + + PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + + if (accessorSymbol.inResolution) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + accessorSymbol.setResolved(); + + return accessorSymbol; + } + + if (accessorSymbol.isResolved) { + if (!accessorSymbol.type) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else { + var getterSymbol = accessorSymbol.getGetter(); + var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; + var hasGetter = getterSymbol !== null; + + var setterSymbol = accessorSymbol.getSetter(); + var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; + var hasSetter = setterSymbol !== null; + + var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); + var getterHasTypeAnnotation = getterAnnotatedType !== null; + + var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); + var setterHasTypeAnnotation = setterAnnotatedType !== null; + + accessorSymbol.startResolving(); + + if (hasGetter) { + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + } + + if (hasSetter) { + setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); + } + + if (hasGetter && hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + var getterSig = getterSymbol.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { + getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; + getterSig.returnType = setterSuppliedTypeSymbol; + } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { + setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; + + if (setterHasParameters) { + setterParameters[0].type = getterSuppliedTypeSymbol; + } + } + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + accessorSymbol.type = this.getNewErrorTypeSymbol(); + } else { + accessorSymbol.type = getterSuppliedTypeSymbol; + } + } else if (hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + + accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; + } else { + var getterSig = getterSymbol.type.getCallSignatures()[0]; + accessorSymbol.type = getterSig.returnType; + } + + accessorSymbol.setResolved(); + } + + if (this.canTypeCheckAST(funcDeclAst, context)) { + this.typeCheckAccessorDeclaration(funcDeclAst, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { + this.setTypeChecked(funcDeclAst, context); + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + var getterSymbol = accessorSymbol.getGetter(); + var setterSymbol = accessorSymbol.getSetter(); + + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; + if (isGetter) { + var getterFunctionDeclarationAst = funcDeclAst; + context.pushNewContextualType(getterSymbol.type); + this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); + context.popAnyContextualType(); + } else { + var setterFunctionDeclarationAst = funcDeclAst; + this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); + } + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return getterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return getterSymbol; + } + + signature.startResolving(); + + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + if (!setterAnnotatedType) { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } else { + signature.returnType = setterAnnotatedType; + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + return getterSymbol; + }; + + PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + if (getter && setter) { + var getterAST = getter.getDeclarations()[0].ast(); + var setterAST = setter.getDeclarations()[0].ast(); + + if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { + var setterSig = setter.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + + var getter = accessorSymbol.getGetter(); + var getterSig = getter.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterParameters[0].type; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + var funcNameAST = funcDeclAST.propertyName; + + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); + } + + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); + var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + 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.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; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return setterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + signature.setResolved(); + return setterSymbol; + } + + signature.startResolving(); + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + } + + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + + if (!hadError) { + signature.setResolved(); + } + } + + return setterSymbol; + }; + + PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + if (funcDeclAST.parameterList) { + for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + + var getter = accessorSymbol.getGetter(); + + var funcNameAST = funcDeclAST.propertyName; + + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); + var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + if (getterIsPrivate !== setterIsPrivate) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); + } + + this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); + } else { + if (this.compilationSettings.noImplicitAny()) { + var setterFunctionDeclarationAst = funcDeclAST; + 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + }; + + PullTypeResolver.prototype.resolveList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.childCount(); i < n; i++) { + this.resolveAST(list.childAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.resolveAST(list.nonSeparatorAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLogicalOperation(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { + this.setTypeChecked(binex, context); + + var leftType = this.resolveAST(binex.left, false, context).type; + var rightType = this.resolveAST(binex.right, false, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(binex); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ + TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), + leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); + } + }; + + PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.operand, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckUnaryArithmeticOperation(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckPostfixUnaryExpression(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { + return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); + }; + + PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + return; + } + + TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { + if (this.canTypeCheckAST(binaryExpression, context)) { + this.typeCheckBinaryArithmeticExpression(binaryExpression, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } + + if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } + + var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); + var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); + + if (!rhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!lhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (lhsIsFit && rhsIsFit) { + switch (binaryExpression.kind()) { + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + if (!this.isReference(binaryExpression.left, lhsSymbol)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); + } + } + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInstanceOfExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); + var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); + 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_of_a_type_assignable_to_the_Function_interface_type)); + } + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { + if (this.canTypeCheckAST(commaExpression, context)) { + this.setTypeChecked(commaExpression, context); + + this.resolveAST(commaExpression.left, false, context); + } + + return this.resolveAST(commaExpression.right, false, context).type; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; + + var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); + + if (!isValidLHS) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); + } + + if (!isValidRHS) { + 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)); + } + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.variableDeclaration, false, context); + this.resolveAST(ast.initializer, false, context); + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.incrementor, false, context); + this.resolveAST(ast.statement, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { + if (this.canTypeCheckAST(forInStatement, context)) { + this.typeCheckForInStatement(forInStatement, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { + this.setTypeChecked(forInStatement, context); + + if (forInStatement.variableDeclaration) { + var declaration = forInStatement.variableDeclaration; + + 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); + + 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 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)); + } + + this.resolveAST(forInStatement.statement, false, context); + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWhileStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckDoStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckIfStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + this.resolveAST(ast.elseClause, false, context); + }; + + PullTypeResolver.prototype.resolveElseClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckElseClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.statements, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declaration, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declarators, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWithStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var withStatement = ast; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckTryStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var tryStatement = ast; + + this.resolveAST(tryStatement.block, false, context); + this.resolveAST(tryStatement.catchClause, false, context); + this.resolveAST(tryStatement.finallyClause, false, context); + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckCatchClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + + var catchDecl = this.semanticInfoChain.getDeclForAST(ast); + this.validateVariableDeclarationGroups(catchDecl, context); + }; + + PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckFinallyClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + }; + + PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + while (enclosingDecl) { + if (enclosingDecl.kind & 1032192 /* SomeFunction */) { + return enclosingDecl; + } + + enclosingDecl = enclosingDecl.getParentDecl(); + } + + return null; + }; + + PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var isContextuallyTyped = false; + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); + if (returnTypeAnnotationSymbol) { + isContextuallyTyped = true; + context.pushNewContextualType(returnTypeAnnotationSymbol); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + isContextuallyTyped = true; + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); + } + } + } + } + + var result = this.resolveAST(expression, isContextuallyTyped, context).type; + if (isContextuallyTyped) { + context.popAnyContextualType(); + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { + if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingFunction.getParentDecl(); + if (classDecl) { + var classSymbol = classDecl.getSymbol(); + this.resolveDeclaredSymbol(classSymbol, context); + + var comparisonInfo = new TypeComparisonInfo(); + var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); + if (!isAssignable) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); + } + } + } + + if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); + } + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { + var signatureSymbol = enclosingFunction.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (expressionType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + this.resolveDeclaredSymbol(expressionType, context); + this.resolveDeclaredSymbol(sigReturnType, context); + + var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); + } + } + } + } + } + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { + var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var returnType = this.getSymbolForAST(returnAST, context); + var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); + if (!returnType || canTypeCheckAST) { + var returnExpr = returnAST.expression; + + var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); + + if (!returnType) { + returnType = resolvedReturnType; + this.setSymbolForAST(returnAST, resolvedReturnType, context); + } + + if (returnExpr && canTypeCheckAST) { + this.setTypeChecked(returnExpr, context); + this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSwitchStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var expressionType = this.resolveAST(ast.expression, false, context).type; + + for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { + var switchClause = ast.switchClauses.childAt(i); + if (switchClause.kind() === 233 /* CaseSwitchClause */) { + var caseSwitchClause = switchClause; + + var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; + this.resolveAST(caseSwitchClause.statements, false, context); + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); + } + } + } else { + var defaultSwitchClause = switchClause; + this.resolveAST(defaultSwitchClause.statements, false, context); + } + } + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLabeledStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var labelIdentifier = ast.identifier.valueText(); + + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + 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); + }; + + PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { + switch (statement.kind()) { + case 160 /* LabeledStatement */: + return this.labelIsOnContinuableConstruct(statement.statement); + + case 158 /* WhileStatement */: + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 161 /* DoStatement */: + return true; + + default: + return false; + } + }; + + PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckContinueStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.isIterationStatement = function (ast) { + switch (ast.kind()) { + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 158 /* WhileStatement */: + case 161 /* DoStatement */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { + switch (ast.kind()) { + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 129 /* FunctionDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 241 /* FunctionPropertyAssignment */: + case 137 /* ConstructorDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.inSwitchStatement = function (ast) { + while (ast) { + if (ast.kind() === 151 /* SwitchStatement */) { + return true; + } + + if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { + while (ast) { + if (this.isIterationStatement(ast)) { + return true; + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { + var result = []; + + ast = ast.parent; + while (ast) { + if (ast.kind() === 160 /* LabeledStatement */) { + var labeledStatement = ast; + if (breakable) { + result.push(labeledStatement); + } else { + if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { + result.push(labeledStatement); + } + } + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + break; + } + + ast = ast.parent; + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + 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.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var continuableLabels = this.getEnclosingLabels(ast, false, true); + + 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)); + } + } + } + }; + + PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckBreakStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + if (ast.identifier) { + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var breakableLabels = this.getEnclosingLabels(ast, true, true); + 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, 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)); + } + } + }; + + PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { + if (!ast) { + return; + } + + var symbol = this.getSymbolForAST(ast, context); + if (symbol && symbol.isResolved) { + this.typeCheckAST(ast, isContextuallyTyped, context); + return symbol; + } + + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + + var nodeType = ast.kind(); + + switch (nodeType) { + case 124 /* ArrayType */: + case 126 /* GenericType */: + case 122 /* ObjectType */: + case 127 /* TypeQuery */: + case 125 /* ConstructorType */: + case 123 /* FunctionType */: + return this.resolveTypeReference(ast, context); + + case 1 /* List */: + return this.resolveList(ast, context); + + case 2 /* SeparatedList */: + return this.resolveSeparatedList(ast, context); + + case 120 /* SourceUnit */: + return this.resolveSourceUnit(ast, context); + + case 132 /* EnumDeclaration */: + return this.resolveEnumDeclaration(ast, context); + + case 130 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 128 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 131 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 224 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, context); + + case 136 /* MemberVariableDeclaration */: + return this.resolveMemberVariableDeclaration(ast, context); + + case 225 /* VariableDeclarator */: + return this.resolveVariableDeclarator(ast, context); + + case 141 /* PropertySignature */: + return this.resolvePropertySignature(ast, context); + + case 227 /* ParameterList */: + return this.resolveParameterList(ast, context); + + case 242 /* Parameter */: + return this.resolveParameter(ast, context); + + case 243 /* EnumElement */: + return this.resolveEnumElement(ast, context); + + case 232 /* EqualsValueClause */: + return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); + + case 238 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 239 /* Constraint */: + return this.resolveConstraint(ast, context); + + case 133 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 240 /* SimplePropertyAssignment */: + return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); + + case 241 /* FunctionPropertyAssignment */: + return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); + + case 121 /* QualifiedName */: + return this.resolveQualifiedName(ast, context); + + case 137 /* ConstructorDeclaration */: + return this.resolveConstructorDeclaration(ast, context); + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return this.resolveAccessorDeclaration(ast, context); + + case 138 /* IndexMemberDeclaration */: + return this.resolveIndexMemberDeclaration(ast, context); + + case 144 /* IndexSignature */: + return this.resolveIndexSignature(ast, context); + + case 135 /* MemberFunctionDeclaration */: + return this.resolveMemberFunctionDeclaration(ast, context); + + case 142 /* CallSignature */: + return this.resolveCallSignature(ast, context); + + case 143 /* ConstructSignature */: + return this.resolveConstructSignature(ast, context); + + case 145 /* MethodSignature */: + return this.resolveMethodSignature(ast, context); + + 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); + + case 219 /* SimpleArrowFunctionExpression */: + return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 214 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + + case 35 /* ThisKeyword */: + return this.resolveThisExpression(ast, context); + + case 50 /* SuperKeyword */: + return this.resolveSuperExpression(ast, context); + + case 213 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, context); + + case 216 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, context); + + case 220 /* CastExpression */: + return this.resolveCastExpression(ast, context); + + case 13 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + + case 14 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + + case 32 /* NullKeyword */: + return this.semanticInfoChain.nullTypeSymbol; + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + + case 172 /* VoidExpression */: + return this.resolveVoidExpression(ast, context); + + case 174 /* AssignmentExpression */: + return this.resolveAssignmentExpression(ast, context); + + case 167 /* LogicalNotExpression */: + return this.resolveLogicalNotExpression(ast, context); + + case 193 /* NotEqualsWithTypeConversionExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 197 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, context); + + case 208 /* AddExpression */: + case 175 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, context); + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, context); + + case 210 /* PostIncrementExpression */: + case 211 /* PostDecrementExpression */: + return this.resolvePostfixUnaryExpression(ast, context); + + case 209 /* SubtractExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 189 /* BitwiseOrExpression */: + case 191 /* BitwiseAndExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, context); + + case 221 /* ElementAccessExpression */: + return this.resolveElementAccessExpression(ast, context); + + case 187 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); + + case 188 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, context); + + case 171 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, context); + + case 170 /* DeleteExpression */: + return this.resolveDeleteExpression(ast, context); + + case 186 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, isContextuallyTyped, context); + + case 12 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 217 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, context); + + case 200 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, context); + + case 173 /* CommaExpression */: + return this.resolveCommaExpression(ast, context); + + case 201 /* InExpression */: + return this.resolveInExpression(ast, context); + + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; + } + + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); + }; + + PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { + if (!this.canTypeCheckAST(ast, context)) { + return; + } + + var nodeType = ast.kind(); + switch (nodeType) { + case 120 /* SourceUnit */: + this.typeCheckSourceUnit(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.typeCheckEnumDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.typeCheckModuleDeclaration(ast, context); + return; + + case 128 /* InterfaceDeclaration */: + this.typeCheckInterfaceDeclaration(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.typeCheckClassDeclaration(ast, context); + return; + + case 243 /* EnumElement */: + this.typeCheckEnumElement(ast, context); + return; + + case 136 /* MemberVariableDeclaration */: + this.typeCheckMemberVariableDeclaration(ast, context); + return; + + case 225 /* VariableDeclarator */: + this.typeCheckVariableDeclarator(ast, context); + return; + + case 141 /* PropertySignature */: + this.typeCheckPropertySignature(ast, context); + return; + + case 242 /* Parameter */: + this.typeCheckParameter(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.typeCheckImportDeclaration(ast, context); + return; + + case 215 /* ObjectLiteralExpression */: + this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 241 /* FunctionPropertyAssignment */: + this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); + return; + + case 11 /* IdentifierName */: + if (isTypesOnlyLocation(ast)) { + this.resolveTypeNameExpression(ast, context); + } else { + this.resolveNameExpression(ast, context); + } + return; + + case 212 /* MemberAccessExpression */: + this.resolveMemberAccessExpression(ast, context); + return; + + case 121 /* QualifiedName */: + this.resolveQualifiedName(ast, context); + return; + + case 222 /* FunctionExpression */: + 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); + break; + + case 142 /* CallSignature */: + this.typeCheckCallSignature(ast, context); + return; + + case 143 /* ConstructSignature */: + this.typeCheckConstructSignature(ast, context); + return; + + case 129 /* FunctionDeclaration */: { + var funcDecl = ast; + 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, isContextuallyTyped, context); + return; + + case 218 /* ParenthesizedArrowFunctionExpression */: + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 214 /* ArrayLiteralExpression */: + this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 213 /* InvocationExpression */: + this.typeCheckInvocationExpression(ast, context); + return; + + case 216 /* ObjectCreationExpression */: + this.typeCheckObjectCreationExpression(ast, context); + return; + + case 150 /* ReturnStatement */: + this.resolveReturnStatement(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); + } + }; + + PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { + while (this.postTypeCheckWorkitems.length) { + var ast = this.postTypeCheckWorkitems.pop(); + this.postTypeCheck(ast, context); + } + }; + + PullTypeResolver.prototype.postTypeCheck = function (ast, context) { + var nodeType = ast.kind(); + + switch (nodeType) { + case 242 /* Parameter */: + case 225 /* VariableDeclarator */: + this.postTypeCheckVariableDeclaratorOrParameter(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.postTypeCheckClassDeclaration(ast, context); + return; + + case 129 /* FunctionDeclaration */: + this.postTypeCheckFunctionDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.postTypeCheckModuleDeclaration(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.postTypeCheckEnumDeclaration(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.postTypeCheckImportDeclaration(ast, context); + return; + + case 11 /* IdentifierName */: + this.postTypeCheckNameExpression(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); + } + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { + this.checkThisCaptureVariableCollides(nameAST, false, context); + }; + + PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { + this.setTypeChecked(nameAST, context); + this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { + var nameSymbol = this.getSymbolForAST(nameAST, context); + var foundCached = nameSymbol !== null; + + if (!foundCached || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.typeCheckNameExpression(nameAST, context); + } + nameSymbol = this.computeNameExpression(nameAST, context); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + 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.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; + } + + var nameSymbol = null; + var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); + } + + 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) { + 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]; + var nameParentDecl = nameDeclaration.getParentDecl(); + if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { + var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); + var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); + + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); + + if (currentParameterIndex >= 0) { + var matchingParameter; + if (parameterList) { + for (var i = 0; i <= currentParameterIndex; i++) { + var candidateParameter = parameterList.parameters.nonSeparatorAt(i); + if (candidateParameter && candidateParameter.identifier.valueText() === id) { + matchingParameter = candidateParameter; + break; + } + } + } + + 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); + } + } + } + + var aliasSymbol = null; + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + if (!this.inTypeQuery(nameAST)) { + aliasSymbol.setIsUsedAsValue(); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); + + var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); + if (parameterList) { + while (parameter && parameter.parent) { + if (parameter.parent.parent === parameterList) { + return parameterList.parameters.nonSeparatorIndexOf(parameter); + } + + parameter = parameter.parent; + } + } + + return -1; + }; + + PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { + var symbol = this.getSymbolForAST(dottedNameAST, context); + var foundCached = symbol !== null; + + if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheckDottedNameAST) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); + } + + this.resolveDeclaredSymbol(symbol, context); + + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(name, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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)) { + lhsAlias.setIsUsedAsValue(); + } + lhsType = lhsAlias.getExportAssignedTypeSymbol(); + } + + if (lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); + return this.getNewErrorTypeSymbol(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); + + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { + var instanceSymbol = lhsType.getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); + + if (!nameSymbol) { + if (lhsType.kind === 32 /* DynamicModule */) { + var container = lhsType; + var associatedInstance = container.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); + } + } + + 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + } + + if (checkSuperPrivateAndStaticAccess) { + this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST, context); + + if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.setTypeChecked(nameAST, context); + } + typeNameSymbol = this.computeTypeNameExpression(nameAST, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + this.resolveDeclaredSymbol(typeNameSymbol, context); + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { + var id = nameAST.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(nameAST); + + var declPath = enclosingDecl.getParentPath(); + + var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); + + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + this.resolveDeclaredSymbol(typeNameSymbol, context); + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + this.resolveDeclaredSymbol(aliasedType, context); + } + + if (typeNameSymbol.isTypeParameter()) { + if (this.isInStaticMemberContext(enclosingDecl)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); + return this.getNewErrorTypeSymbol(); + } + } + } + + if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { + typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); + } + + 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; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, context); + } + + 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()) { + for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + + if (typeArgs[i].isError()) { + typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + } + + 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(); + } + + if (!genericTypeSymbol.isResolved) { + var typeDecls = genericTypeSymbol.getDeclarations(); + var childDecls = null; + + for (var i = 0; i < typeDecls.length; i++) { + childDecls = typeDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + + var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); + + var typeConstraint = null; + var upperBound = null; + + typeParameters = specializedSymbol.getTypeParameters(); + + var typeConstraintSubstitutionMap = []; + var typeArg = null; + + var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < typeParameters.length; i++) { + typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + for (var id in instantiatedSubstitutionMap) { + typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; + } + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] === typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } else if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); + } + + if (typeArg.isTypeParameter()) { + upperBound = typeArg.getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + 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)])); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { + if (this.inTypeQuery(dottedNameAST)) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; + } + + var symbol = this.getSymbolForAST(dottedNameAST, context); + if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheck) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeQualifiedName(dottedNameAST, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + this.resolveDeclaredSymbol(symbol, context); + + 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) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); + var lhs = this.resolveAST(dottedNameAST.left, false, context); + + var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; + + if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { + if (lhs.isAlias()) { + lhs.setIsUsedAsValue(); + } + } + + if (!lhsType) { + return this.getNewErrorTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); + var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; + + 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & 164 /* SomeContainer */) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { + if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { + return false; + } + + if (returnTypeAnnotation) { + return false; + } + + if (parameters) { + for (var i = 0, n = parameters.length; i < n; i++) { + if (parameters.typeAt(i)) { + return false; + } + } + } + + var contextualFunctionTypeSymbol = context.getContextualType(); + + if (contextualFunctionTypeSymbol) { + this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); + var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; + if (!exactlyOneCallSignature) { + return false; + } + + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; + return !callSignatureIsGeneric; + } + + return false; + }; + + PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { + var funcDeclSymbol = null; + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { + return funcDeclSymbol; + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + TypeScript.Debug.assert(funcDeclSymbol); + + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.propagateContextualType(returnType); + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); + context.popAnyContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + var functionExpressionName = functionDecl.getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); + } + } + + context.setTypeInContext(funcDeclSymbol, funcDeclType); + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); + } + + return funcDeclSymbol; + }; + + 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + var returnTypeSymbol = signature.returnType; + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + 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.popAnyContextualType(); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); + + this.validateVariableDeclarationGroups(functionDecl, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { + var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); + var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; + + if (this.canTypeCheckAST(thisExpression, context)) { + this.typeCheckThisExpression(thisExpression, context, enclosingDecl); + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.inTypeArgumentList = function (ast) { + var previous = null; + var current = ast; + + while (current) { + switch (current.kind()) { + case 126 /* GenericType */: + var genericType = current; + if (genericType.typeArgumentList === previous) { + return true; + } + break; + + case 226 /* ArgumentList */: + var argumentList = current; + return argumentList.typeArgumentList === previous; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { + while (ast) { + switch (ast.kind()) { + case 230 /* ExtendsHeritageClause */: + var heritageClause = ast; + + return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inTypeQuery = function (ast) { + while (ast) { + switch (ast.kind()) { + case 127 /* TypeQuery */: + return true; + case 129 /* FunctionDeclaration */: + case 213 /* InvocationExpression */: + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 213 /* InvocationExpression */: + var invocationExpression = current; + if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + break; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inConstructorParameterList = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } + + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + 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 */) { + return true; + } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { + this.checkForThisCaptureInArrowFunction(thisExpression); + + if (this.inConstructorParameterList(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); + return; + } + + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { + return; + } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + if (currentDecl.getParentDecl() === null) { + return; + } else { + 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)); + } + + return; + } else if (currentDecl.kind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); + } + + return; + } + } + }; + + PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var isStaticContext = false; + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + return null; + } else if (declKind === 16384 /* Function */) { + return null; + } else if (declKind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(ast)) { + return this.getNewErrorTypeSymbol(); + } else { + var classSymbol = decl.getSymbol(); + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + return constructorSymbol.type; + } else { + return classSymbol; + } + } + } + } + } + + return null; + }; + + PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { + return true; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + var superType = this.semanticInfoChain.anyTypeSymbol; + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); + + if (classSymbol) { + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSuperExpression(ast, context, enclosingDecl); + } + + return superType; + }; + + PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { + this.setTypeChecked(ast, context); + + this.checkForThisCaptureInArrowFunction(ast); + + var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; + var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; + TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); + + if (isSuperPropertyAccess) { + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + break; + } else if (currentDecl.kind === 8 /* Class */) { + if (!this.enclosingClassIsDerived(currentDecl)) { + 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 if (this.inStaticMemberVariableDeclaration(ast)) { + break; + } + + 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; + } + + return; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); + } + }; + + PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { + return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (this.canTypeCheckAST(expressionAST, context)) { + this.setTypeChecked(expressionAST, context); + } + symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { + var boundMemberSymbols = []; + var memberSymbol; + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var id = this.getPropertyAssignmentName(propertyAssignment); + var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); + + var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; + var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); + TypeScript.Debug.assert(decl); + + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + if (!isUsingExistingSymbol) { + memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } else { + memberSymbol = decl.getSymbol(); + } + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + memberSymbol = decl.getSymbol(); + } else { + TypeScript.Debug.assert(isAccessor); + memberSymbol = decl.getSymbol(); + } + + if (!isUsingExistingSymbol && !isAccessor) { + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); + } + + objectLiteralTypeSymbol.addMember(memberSymbol); + } + + boundMemberSymbols.push(memberSymbol); + } + + return boundMemberSymbols; + }; + + PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var acceptedContextualType = false; + var assigningSymbol = null; + + var id = this.getPropertyAssignmentName(propertyAssignment); + var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; + + if (objectLiteralContextualType) { + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + + if (!assigningSymbol) { + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + assigningSymbol = numericIndexerSignature; + } else if (stringIndexerSignature) { + assigningSymbol = stringIndexerSignature; + } + } + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); + + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = contextualMemberType; + } + } + } + + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; + + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { + objectLiteralTypeSymbol.setHasGenericMember(); + } + + if (stringIndexerSignature) { + allMemberTypes.push(memberSymbolType); + } + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + allNumericMemberTypes.push(memberSymbolType); + } + } + + if (acceptedContextualType) { + pullTypeContext.popAnyContextualType(); + } + + var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; + if (!memberSymbol.isResolved) { + if (isAccessor) { + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); + } else { + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); + memberSymbol.setResolved(); + + this.setSymbolForAST(id, memberSymbol, pullTypeContext); + } + } + } + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { + var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); + TypeScript.Debug.assert(objectLitDecl); + + var typeSymbol = this.getSymbolForAST(objectLitAST, context); + var isUsingExistingSymbol = !!typeSymbol; + + if (!typeSymbol) { + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); + typeSymbol.addDeclaration(objectLitDecl); + this.setSymbolForAST(objectLitAST, typeSymbol, context); + objectLitDecl.setSymbol(typeSymbol); + } + + var propertyAssignments = objectLitAST.propertyAssignments; + var contextualType = null; + + if (isContextuallyTyped) { + contextualType = context.getContextualType(); + this.resolveDeclaredSymbol(contextualType, context); + } + + var stringIndexerSignature = null; + var numericIndexerSignature = null; + var allMemberTypes = null; + var allNumericMemberTypes = null; + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + + stringIndexerSignature = indexSignatures.stringSignature; + numericIndexerSignature = indexSignatures.numericSignature; + + var inInferentialTyping = context.isInferentiallyTyping(); + if (stringIndexerSignature) { + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; + } + + if (numericIndexerSignature) { + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; + } + } + + if (propertyAssignments) { + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); + + this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); + + if (!isUsingExistingSymbol) { + this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); + this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { + return propertyAssignment.propertyName; + } else { + TypeScript.Debug.assert(false); + } + }; + + PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { + if (contextualIndexSignature) { + var typeCollection = { + getLength: function () { + return indexerTypeCandidates.length; + }, + getTypeAtIndex: function (index) { + return indexerTypeCandidates[index]; + } + }; + var decl = objectLiteralSymbol.getDeclarations()[0]; + 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); + } + } + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { + var symbol = this.getSymbolForAST(arrayLit, context); + if (!symbol || this.canTypeCheckAST(arrayLit, context)) { + if (this.canTypeCheckAST(arrayLit, context)) { + this.setTypeChecked(arrayLit, context); + } + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { + var elements = arrayLit.expressions; + var elementType = null; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, context); + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + if (indexSignatures.numericSignature) { + contextualElementType = indexSignatures.numericSignature.returnType; + } + } + } + + if (elements) { + if (contextualElementType) { + context.propagateContextualType(contextualElementType); + } + + for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { + elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); + } + + if (contextualElementType) { + context.popAnyContextualType(); + } + } + + if (elementTypes.length) { + elementType = elementTypes[0]; + } + var collection; + + if (contextualElementType && !context.isInferentiallyTyping()) { + if (!elementType) { + elementType = contextualElementType; + } + + collection = { + getLength: function () { + return elements.nonSeparatorCount() + 1; + }, + getTypeAtIndex: function (index) { + return index === 0 ? contextualElementType : elementTypes[index - 1]; + } + }; + } else { + collection = { + getLength: function () { + return elements.nonSeparatorCount(); + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + } + + elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; + + if (!elementType) { + elementType = this.semanticInfoChain.undefinedTypeSymbol; + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { + var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); + + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); + } + + return symbolAndDiagnostic.symbol; + }; + + PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { + this.setTypeChecked(callEx, context); + context.postDiagnostic(symbolAndDiagnostic.diagnostic); + }; + + PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; + + var targetTypeSymbol = targetSymbol.type; + + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return { symbol: targetTypeSymbol }; + } + + var elementType = targetTypeSymbol.getElementType(); + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return { symbol: elementType }; + } + + 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); + + if (member) { + this.resolveDeclaredSymbol(member, context); + + return { symbol: member.type }; + } + } + + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); + + var stringSignature = signatures.stringSignature; + var numberSignature = signatures.numericSignature; + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; + } 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 { + symbol: this.getNewErrorTypeSymbol(), + diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) + }; + } + }; + + 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; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + if (!signature.isResolved) { + this.resolveDeclaredSymbol(signature, context); + } + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signature; + continue; + } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { + numberSignature = signature; + continue; + } + } + } + + return { + numericSignature: numberSignature, + stringSignature: stringSignature + }; + }; + + 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; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } + + 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 { + lhsType = rhsType; + } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (exprType) { + if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { + if (!this.isReference(binaryExpression.left, lhsExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, exprType, lhsType, context); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); + } + } + + if (!exprType) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { + return this.findBestCommonType({ + getLength: function () { + return 2; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + } + } + }, context); + }; + + PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { + return this.findBestCommonType({ + getLength: function () { + return 3; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + case 2: + return type3; + } + } + }, context); + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + } + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; + var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; + + 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.pushNewContextualType(leftType); + var rightType = this.resolveAST(binex.right, true, context).type; + context.popAnyContextualType(); + + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + + this.resolveAST(binex.left, false, context); + } + + return this.resolveAST(binex.right, false, context).type; + }; + + PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { + var contextualType = context.getContextualType(); + return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + } else { + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { + var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; + var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; + + var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); + + var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); + + if (this.canTypeCheckAST(trinex, context)) { + this.setTypeChecked(trinex, context); + this.resolveAST(trinex.condition, false, context); + + if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); + } + } + } + + if (!conditionalTypesAreValid) { + return this.getNewErrorTypeSymbol(); + } + + return expressionType; + }; + + PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { + return true; + } + } else { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveAST(ast.expression, false, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckInvocationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + var targetSymbol = this.resolveAST(callEx.expression, false, context); + + if (callEx.argumentList.arguments) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + + var len = callEx.argumentList.arguments.nonSeparatorCount(); + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); + return this.getNewErrorTypeSymbol(); + } + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.expression.kind() === 50 /* SuperKeyword */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + targetSymbol = targetTypeSymbol.getConstructorMethod(); + this.resolveDeclaredSymbol(targetSymbol, context); + targetTypeSymbol = targetSymbol.type; + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); + this.resolveAST(callEx.argumentList.arguments, false, context); + + return this.getNewErrorTypeSymbol(); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + 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 explicitTypeArgs = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + var triedToInferTypeArgs = false; + + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var beforeResolutionSignatures = signatures; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + + if (signatures[i].isGeneric() && typeParameters.length) { + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); + } + + 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, 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; + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + + var errorCondition = null; + if (!signatures.length) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (!couldNotFindGenericOverload) { + 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); + } + return this.semanticInfoChain.anyTypeSymbol; + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); + } else if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + } + + 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 (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; + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + this.setSymbolForAST(callEx, symbol, context); + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckObjectCreationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + this.resolveAST(callEx.expression, false, context); + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (callEx.argumentList) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + var len = callEx.argumentList.arguments.nonSeparatorCount(); + + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { + if (!context.inProvisionalResolution()) { + additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); + } + context.postDiagnostic(diagnostic); + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var explicitTypeArgs = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny()) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); + } + } + + if (constructSignatures.length) { + if (callEx.argumentList && callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var triedToInferTypeArgs; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric()) { + typeParameters = constructSignatures[i].getTypeParameters(); + + 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, explicitTypeArgs.length]); + continue; + } + } 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 { + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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(constructSignatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } else { + if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); + } else { + returnType = this.instantiateTypeToAny(returnType, context); + } + } + + if (usedCallSignaturesInstead) { + 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(); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList && callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); + + return this.getNewErrorTypeSymbol(); + }; + + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { + var typeReplacementMap = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters = signatureAToInstantiate.getTypeParameters(); + var typeConstraint = null; + + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; + var enclosingTypeParameterMap; + + if (functionTypeA) { + enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + if (functionTypeB) { + enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); + + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); + }; + + PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { + var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; + + if (this.canTypeCheckAST(assertionExpression, context)) { + this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); + } + + return typeAssertionType; + }; + + PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { + this.setTypeChecked(assertionExpression, context); + + context.pushNewContextualType(typeAssertionType); + var exprType = this.resolveAST(assertionExpression.expression, true, context).type; + context.popAnyContextualType(); + + this.resolveDeclaredSymbol(typeAssertionType, context); + this.resolveDeclaredSymbol(exprType, context); + + var comparisonInfo = new TypeComparisonInfo(); + + 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); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { + var leftExpr = this.resolveAST(binaryExpression.left, false, context); + var leftType = leftExpr.type; + + context.pushNewContextualType(leftType); + var rightType = this.resolveAST(binaryExpression.right, true, context).type; + context.popAnyContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (!this.isReference(binaryExpression.left, leftExpr)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } else { + this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); + } + } + + return rightType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { + var instanceTypeSymbol = typeToReturn.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.widenType = function (type, ast, context) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (type.isArrayNamedTypeReference()) { + 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(); + + for (var i = 0; i < len; i++) { + var candidateType = collection.getTypeAtIndex(i); + if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { + return candidateType; + } + } + + return this.semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { + for (var i = 0; i < collection.getLength(); i++) { + var otherType = collection.getTypeAtIndex(i); + if (candidateType === otherType) { + continue; + } + + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { + t1 = this.getSymbolForRelationshipCheck(t1); + t2 = this.getSymbolForRelationshipCheck(t2); + + if (t1 === t2) { + return true; + } + + if (t1 && t2) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); + } + } + + return this.typesAreIdentical(t1, t2, context); + }; + + 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); + + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; + } + + if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + 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(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return false; + } + } + + if (t1.isPrimitive() !== t2.isPrimitive()) { + return 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) { + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { + return false; + } + + return true; + }; + + 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; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length !== sg2.length) { + return false; + } + + 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; + } + } + + return true; + }; + + 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; + } + + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; + } + + 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) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0] === decls2[0]; + } + + return false; + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { + return true; + } + + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); + }; + + 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.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) { + if (symbol && symbol.isTypeReference()) { + return symbol.getReferencedTypeSymbol(); + } + + return symbol; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + source = this.getSymbolForRelationshipCheck(source); + target = this.getSymbolForRelationshipCheck(target); + + if (source === target) { + return true; + } + + if (source && target) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + } + } + + 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); + + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + var sourceApparentType = this.getApparentType(source); + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; + } + + if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + 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) { + return true; + } + + return false; + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return assignableTo; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.getIsSpecialized() && target.getIsSpecialized()) { + 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, true); + + for (var i = 0; i < sourceTypeArguments.length; i++) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { + break; + } + } + + if (i === sourceTypeArguments.length) { + return true; + } else { + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + } + } + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } + } else { + if (isComparingInstantiatedSignatures) { + target = target.getBaseConstraint(this.semanticInfoChain); + } else { + return this.typesAreIdentical(target, sourceApparentType, context); + } + } + } + + 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; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); + + this.resolveDeclaredSymbol(targetProp, context); + + var targetPropType = targetProp.type; + + 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); + + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + + 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var comparisonInfoTypeArgumentsCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); + } + 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_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_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, isRelatable); + return isRelatable; + }; + + 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)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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++) { + 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; + } + } + } + + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + }; + + 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 (comparisonInfo) { + var names = getNames(true); + var code; + if (targetPropIsPrivate) { + 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 { + 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; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (targetDecl !== sourceDecl) { + if (comparisonInfo) { + var names = getNames(true); + + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + 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; + } + } + + if (sourceProp.isOptional && !targetProp.isOptional) { + if (comparisonInfo) { + 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); + } + return false; + } + + this.resolveDeclaredSymbol(sourceProp, context); + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); + + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + var names = getNames(false); + if (comparisonInfoPropertyTypeCheck && 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 { + 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 isSourcePropertyRelatableToTargetProperty; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); + var targetStringSig = targetIndexSigs.stringSignature; + var targetNumberSig = targetIndexSigs.numericSignature; + + if (targetStringSig || targetNumberSig) { + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); + var sourceStringSig = sourceIndexSigs.stringSignature; + var sourceNumberSig = sourceIndexSigs.numericSignature; + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + 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++) { + var mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + var nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + 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; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + + return false; + } + + return true; + }; + + 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; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; + + 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, [targetParameters.length])); + } + return false; + } + + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; + } + + 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) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + + return false; + } + } + + 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 (!areParametersRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + } + + return areParametersRelatable; + }); + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { + var _this = this; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = application.argumentList ? application.argumentList.arguments : null; + + var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { + if (hasOverloads && signature.isDefinition()) { + return false; + } + + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { + return false; + } + + return _this.overloadHasCorrectArity(signature, args); + }); + + var firstAssignableButNotSupertypeSignature = null; + var firstAssignableWithProvisionalErrorsSignature = null; + + for (var i = 0; i < initialCandidates.length; i++) { + var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); + if (applicability === 3 /* Subtype */) { + return initialCandidates[i]; + } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { + firstAssignableButNotSupertypeSignature = initialCandidates[i]; + } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { + firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; + } + } + + if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { + return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; + } else { + var target = this.getCallTargetErrorSpanAST(application); + if (comparisonInfo.message) { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); + } else { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); + } + } + + return null; + }; + + PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { + return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; + }; + + PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { + if (args == null) { + return signature.nonOptionalParamCount === 0; + } + + var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); + if (numberOfArgs < signature.nonOptionalParamCount) { + return false; + } + if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { + if (args === null) { + return 3 /* Subtype */; + } + + var isInVarArg = false; + var parameters = signature.parameters; + var paramType = null; + + var overloadApplicability = 3 /* Subtype */; + + for (var i = 0; i < args.nonSeparatorCount(); i++) { + if (!isInVarArg) { + this.resolveDeclaredSymbol(parameters[i], context); + + if (parameters[i].isVarArg) { + paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); + isInVarArg = true; + } else { + paramType = parameters[i].type; + } + } + + var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); + + if (statusOfCurrentArgument === 0 /* NotAssignable */) { + return 0 /* NotAssignable */; + } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { + overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; + } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { + overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; + } + } + + return overloadApplicability; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType.isAny()) { + return 3 /* Subtype */; + } else if (paramType.isError()) { + return 1 /* AssignableButWithProvisionalErrors */; + } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrowFunction = arg; + 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.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.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 */) { + return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); + } else { + return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); + } + }; + + PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { + if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + 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.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveObjectLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType === this.cachedArrayInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveArrayLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + var argSym = this.resolveAST(arg, false, context); + + if (argSym.type.isAlias()) { + var aliasSym = argSym.type; + argSym = aliasSym.getExportAssignedTypeSymbol(); + } + + comparisonInfo.stringConstantVal = arg; + return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { + var tempComparisonInfo = new TypeComparisonInfo(); + tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; + if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { + return 3 /* Subtype */; + } + + if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { + return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; + } + + if (!comparisonInfo.message) { + var enclosingSymbol = this.getEnclosingSymbolForAST(arg); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); + } + + return 0 /* NotAssignable */; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); + + 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 (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 inferenceResultTypes; + }; + + PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { + var enclosingDecl = this.getEnclosingDeclForAST(args); + var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); + return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; + }; + + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { + if (expressionType && parameterType) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); + return; + } + } + this.relateTypeToTypeParameters(expressionType, parameterType, 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; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType.isTypeParameter()) { + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); + return; + } + + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { + return; + } + + 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.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) { + return; + } + + var expressionTypeTypeArguments = expressionType.getTypeArguments(); + var parameterTypeArguments = parameterType.getTypeArguments(); + + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { + for (var i = 0; i < expressionTypeTypeArguments.length; i++) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } + } + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { + var _this = this; + var expressionReturnType = expressionSignature.returnType; + var parameterReturnType = parameterSignature.returnType; + + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); + + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + if (objectMember) { + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); + } + } + + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); + + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; + } + + 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) { + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!typeParameters.length) { + return typeToSpecialize; + } + + var typeArguments = null; + + 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) { + typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var type = this.createInstantiatedType(typeToSpecialize, typeArguments); + + 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(); + + var resolver = semanticInfoChain.getResolver(); + var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); + + if (resolver.canTypeCheckAST(sourceUnit, context)) { + resolver.resolveAST(sourceUnit, false, context); + resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); + + while (resolver.typeCheckCallBacks.length) { + var callBack = resolver.typeCheckCallBacks.pop(); + callBack(context); + } + + resolver.processPostTypeCheckWorkItems(context); + } + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; + } + + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); + + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; + + 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) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + 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)); + } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); + } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + 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_assignable_to_any_non_specialized_signature)); + } + } + } else if (definitionSignature && definitionSignature !== signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { + var errorCode; + + 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; + } 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + var isNamedType = typeSymbol.isNamedTypeSymbol(); + + if (typeSymbol.isArrayNamedTypeReference()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); + return; + } + + if (!isNamedType) { + var typeOfSymbol = typeSymbol.getTypeOfSymbol(); + if (typeOfSymbol) { + this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); + return; + } + } + + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); + if (typars) { + for (var i = 0; i < typars.length; i++) { + this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); + } + } + + if (!isNamedType) { + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); + } + + typeSymbol.inSymbolPrivacyCheck = false; + + if (!isNamedType) { + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + 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]) { + 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(); + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } else if (symbol.kind === 128 /* TypeAlias */) { + var aliasSymbol = symbol; + symbolIsVisible = true; + aliasSymbol.setTypeUsedExternally(); + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); + } + }; + + 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; + var messageCode; + + var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; + } + } + + var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { + var typeSymbol = symbol; + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { + var _this = this; + if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; + var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; + var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); + var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); + this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { + return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); + }); + } + } + + if (!isGetter && !isIndexSignature) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var parameter = parameters.astAt(argIndex); + + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { + var _this = this; + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); + } + } + + if (block) { + var reportErrorOnReturnExpressions = function (ast, walker) { + var go = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { + TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); + + var classSymbol = classDecl.getSymbol(); + return classSymbol.getExtendedTypes().length > 0; + }; + + PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { + if (ast.kind() === 213 /* InvocationExpression */) { + var invocationExpression = ast; + if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { + if (node && node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + if (this.isSuperInvocationExpression(expressionStatement.expression)) { + return true; + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { + if (block && block.statements && block.statements.childCount() > 0) { + return block.statements.childAt(0); + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { + TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); + + if (constructorDecl) { + var enclosingClass = constructorDecl.getParentDecl(); + + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.kind() === 242 /* Parameter */) { + return true; + } + + if (ast.kind() === 136 /* MemberVariableDeclaration */) { + var variableDeclarator = ast; + if (variableDeclarator.variableDeclarator.equalsValueClause) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { + var enclosingDecl = this.getEnclosingDeclForAST(expression); + + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var inArrowFunction = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + inArrowFunction = true; + continue; + } + + if (inArrowFunction) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = decl.getSymbol().getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); + var stringSignature = indexSignatures.stringSignature; + var numberSignature = indexSignatures.numericSignature; + + if (stringSignature || numberSignature) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { + var memberSymbol = member.getSymbol(); + var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); + if (relevantSignature) { + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); + } + } + } + } + } + }; + + PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { + if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { + return numberIndexSignature; + } else if (stringIndexSignature) { + return stringIndexSignature; + } + + return null; + }; + + PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { + 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + var foundError1 = false; + var foundError2 = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName, true); + if (extendedTypeProp) { + this.resolveDeclaredSymbol(extendedTypeProp, context); + foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError1) { + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + } + + if (foundError1 || foundError2) { + foundError = true; + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); + } + + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + } + } + } + + if (foundError) { + var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); + + 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; + } + + if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + + if (associatedContainerType) { + return associatedContainerType !== typeSymbol.getRootSymbol(); + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + + var baseType = this.resolveTypeReference(baseDeclAST, context).type; + + if (!baseType) { + return; + } + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (!baseType.isError()) { + if (isExtendedType) { + if (typeDeclIsClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); + } + } + return; + } else if (typeDeclIsClass && isExtendedType) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + 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)])); + } + } + + if (baseType.hasBase(typeSymbol)) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); + return; + } + + if (isExtendedType) { + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); + } else { + TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); + + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { + var _this = this; + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); + if (!extendsClause && !implementsClause) { + return; + } + + if (extendsClause) { + for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (implementsClause) { + for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); + } + } + } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { + var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { + return decl.ast().heritageClauses !== null; + }).ast(); + if (classOrInterface === firstInterfaceASTWithExtendsClause) { + this.typeCheckCallBacks.push(function (context) { + _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); + }); + } + } + }; + + PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { + var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); + + var inheritedMembersMap = TypeScript.createIntrinsicsObject(); + var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); + + var typeHasOwnNumberIndexer = false; + var typeHasOwnStringIndexer = false; + + if (typeSymbol.hasOwnIndexSignatures()) { + var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); + for (var i = 0; i < ownIndexSignatures.length; i++) { + if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + typeHasOwnNumberIndexer = true; + } else { + typeHasOwnStringIndexer = true; + } + } + } + var baseTypes = typeSymbol.getExtendedTypes(); + for (var i = 0; i < baseTypes.length; i++) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + return; + } + } + + if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { + return; + } + + this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; + var memberName = member.name; + + if (interfaceSymbol.findMember(memberName, false)) { + continue; + } + + this.resolveDeclaredSymbol(member, context); + + if (inheritedMembersMap[memberName]) { + var prevMember = inheritedMembersMap[memberName]; + 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; + } + } else { + inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); + } + } + + return false; + }; + + PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { + if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { + return false; + } + + var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { + var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; + + var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; + 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, 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; + } + } else { + allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } else if (parameterTypeIsNumber) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin) { + 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; + } + } else { + allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { + if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; + var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; + for (var memberName in inheritedMembers) { + var memberWithBaseOrigin = inheritedMembers[memberName]; + if (!memberWithBaseOrigin) { + continue; + } + + var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); + if (!relevantSignature) { + continue; + } + + var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; + + if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { + continue; + } + + 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_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_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])); + } + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + 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_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, [ + interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), + inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.isReference = function (ast, astSymbol) { + if (ast.kind() === 217 /* ParenthesizedExpression */) { + return this.isReference(ast.expression, astSymbol); + } + + if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { + return false; + } + + if (ast.kind() === 11 /* IdentifierName */) { + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { + return false; + } + + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { + return false; + } + + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { + return false; + } + } + + if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { + if (resolvedName) { + if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { + return this.semanticInfoChain.getEnclosingDecl(ast); + }; + + PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + return enclosingDecl ? enclosingDecl.getSymbol() : null; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { + if (resolvedName) { + if (resolvedName.anyDeclHasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var memberClass = memberContainer.getDeclarations()[0].ast(); + TypeScript.Debug.assert(memberClass); + + var containingClass = this.getEnclosingClassDeclaration(name); + + if (!containingClass || containingClass !== memberClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { + if (type.isPrimitive()) { + return type; + } + + if (type.isError()) { + return type; + } + + if (typeParameterArgumentMap[type.pullSymbolID]) { + return typeParameterArgumentMap[type.pullSymbolID]; + } + + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); + } + + if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + } + + return type; + }; + + 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 rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); + + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); + + 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) { + for (var j = 0; j < parameters.length; j++) { + parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + instantiatedSignature.hasVarArgs = true; + } + instantiatedSignature.addParameter(parameter, parameter.isOptional); + + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); + } + } + + return instantiatedSignature; + }; + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; + + function getPropertyAssignmentNameTextFromIdentifier(identifier) { + if (identifier.kind() === 11 /* IdentifierName */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 14 /* StringLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 13 /* NumericLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; + + function isTypesOnlyLocation(ast) { + while (ast && ast.parent) { + switch (ast.parent.kind()) { + case 244 /* TypeAnnotation */: + return true; + case 127 /* TypeQuery */: + return false; + case 125 /* ConstructorType */: + var constructorType = ast.parent; + if (constructorType.type === ast) { + return true; + } + break; + case 123 /* FunctionType */: + var functionType = ast.parent; + if (functionType.type === ast) { + return true; + } + break; + case 239 /* Constraint */: + var constraint = ast.parent; + if (constraint.type === ast) { + return true; + } + break; + case 220 /* CastExpression */: + var castExpression = ast.parent; + return castExpression.type === ast; + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + return true; + case 228 /* TypeArgumentList */: + return true; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + case 129 /* FunctionDeclaration */: + case 145 /* MethodSignature */: + case 212 /* MemberAccessExpression */: + case 242 /* Parameter */: + return false; + } + + ast = ast.parent; + } + + return false; + } + TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfoChain = (function () { + function SemanticInfoChain(compiler, logger) { + this.compiler = compiler; + this.logger = logger; + this.documents = []; + this.fileNameToDocument = TypeScript.createIntrinsicsObject(); + this.anyTypeDecl = null; + this.booleanTypeDecl = null; + this.numberTypeDecl = null; + this.stringTypeDecl = null; + this.nullTypeDecl = null; + this.undefinedTypeDecl = null; + this.voidTypeDecl = null; + this.undefinedValueDecl = null; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + this.undefinedValueSymbol = null; + this.emptyTypeSymbol = null; + this.astSymbolMap = []; + this.astAliasSymbolMap = []; + this.astCallResolutionDataMap = []; + this.declSymbolMap = []; + this.declSignatureSymbolMap = []; + this.declCache = null; + this.symbolCache = null; + this.fileNameToDiagnostics = null; + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + 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); + 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 */, 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 || null; + }; + + SemanticInfoChain.prototype.lineMap = function (fileName) { + return this.getDocument(fileName).lineMap(); + }; + + SemanticInfoChain.prototype.fileNames = function () { + if (this._fileNames === null) { + this._fileNames = this.documents.slice(1).map(function (s) { + return s.fileName; + }); + } + + return this._fileNames; + }; + + SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { + newSymbol.addDeclaration(decl); + decl.setSymbol(newSymbol); + newSymbol.setResolved(); + + return newSymbol; + }; + + SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { + var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { + var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); + newSymbol.type = type; + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.resetGlobalSymbols = function () { + this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); + this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); + this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); + this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); + this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); + this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); + this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); + this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); + + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); + var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + emptyTypeDecl.setSymbol(emptyTypeSymbol); + emptyTypeSymbol.addDeclaration(emptyTypeDecl); + emptyTypeSymbol.setResolved(); + this.emptyTypeSymbol = emptyTypeSymbol; + }; + + SemanticInfoChain.prototype.addDocument = function (document) { + var fileName = document.fileName; + + var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (existingIndex < 0) { + this.documents.push(document); + } else { + this.documents[existingIndex] = document; + } + + this.fileNameToDocument[fileName] = document; + + this.invalidate(); + }; + + SemanticInfoChain.prototype.removeDocument = function (fileName) { + TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); + var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (index > 0) { + this.fileNameToDocument[fileName] = undefined; + this.documents.splice(index, 1); + this.invalidate(); + } + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[cacheID]; + + if (!symbol) { + for (var i = 0, n = this.documents.length; i < n; i++) { + var topLevelDecl = this.documents[i].topLevelDecl(); + + var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); + if (symbol) { + break; + } + + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { + return null; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { + var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; + + var foundDecls = topLevelDecl.searchChildDecls(name, kind); + + for (var j = 0; j < foundDecls.length; j++) { + var foundDecl = foundDecls[j]; + + if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { + break; + } + + var symbol = foundDecls[j].getSymbol(); + if (symbol) { + return symbol; + } + } + + return null; + }; + + SemanticInfoChain.prototype.findExternalModule = function (id) { + id = TypeScript.normalizePath(id); + + var tsFile = id + ".ts"; + var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); + symbol = this.symbolCache[tsCacheID]; + if (symbol != undefined) { + return symbol; + } + + 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 isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + symbol = dynamicModuleDecl.getSymbol(); + + 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 null; + }; + + SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { + var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); + + var symbol = this.symbolCache[cacheID]; + if (symbol == undefined) { + symbol = null; + for (var i = 0; i < this.documents.length; i++) { + var document = this.documents[i]; + var topLevelDecl = document.topLevelDecl(); + + if (!topLevelDecl.isExternalModule()) { + var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); + if (dynamicModules.length) { + symbol = dynamicModules[0].getSymbol(); + break; + } + } + } + + this.symbolCache[cacheID] = symbol; + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + var declsToSearch = this.topLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + + 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, kind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls === TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + 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; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + } + }; + + SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { + if (typeof oldSettings === "undefined") { oldSettings = null; } + if (typeof newSettings === "undefined") { newSettings = null; } + TypeScript.PullTypeResolver.globalTypeCheckPhase++; + + var cleanStart = new Date().getTime(); + + this.astSymbolMap.length = 0; + this.astAliasSymbolMap.length = 0; + this.astCallResolutionDataMap.length = 0; + + this.declCache = TypeScript.createIntrinsicsObject(); + this.symbolCache = TypeScript.createIntrinsicsObject(); + this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + + this.declSymbolMap.length = 0; + this.declSignatureSymbolMap.length = 0; + + if (oldSettings && newSettings) { + if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { + for (var i = 1, n = this.documents.length; i < n; i++) { + this.documents[i].invalidate(); + } + } + } + + TypeScript.pullSymbolID = 0; + + this.resetGlobalSymbols(); + + var cleanEnd = new Date().getTime(); + }; + + SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()] || null; + }; + + SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { + this.astAliasSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { + return this.astAliasSymbolMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { + return this.astCallResolutionDataMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; + } + }; + + SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { + this.declSymbolMap[decl.declID] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { + return this.declSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { + this.declSignatureSymbolMap[decl.declID] = signatureSymbol; + }; + + SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { + return this.declSignatureSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { + var fileName = diagnostic.fileName(); + var diagnostics = this.fileNameToDiagnostics[fileName]; + if (!diagnostics) { + diagnostics = []; + this.fileNameToDiagnostics[fileName] = diagnostics; + } + + diagnostics.push(diagnostic); + }; + + SemanticInfoChain.prototype.getDiagnostics = function (fileName) { + var diagnostics = this.fileNameToDiagnostics[fileName]; + return diagnostics || []; + }; + + SemanticInfoChain.prototype.getBinder = function () { + if (!this._binder) { + this._binder = new TypeScript.PullSymbolBinder(this); + } + + return this._binder; + }; + + SemanticInfoChain.prototype.getResolver = function () { + if (!this._resolver) { + this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); + } + + return this._resolver; + }; + + SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); + indexParameterSymbol.type = indexParamType; + indexSignature.addParameter(indexParameterSymbol); + indexSignature.returnType = returnType; + indexSignature.setResolved(); + indexParameterSymbol.setResolved(); + + containingSymbol.addIndexSignature(indexSignature); + + 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); + indexParameterSymbol.addDeclaration(indexParamDecl); + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast) { + var document = this.getDocument(ast.fileName()); + + if (document) { + return document._getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { + return this.getDocument(ast.fileName()).getEnclosingDecl(ast); + }; + + SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { + this.getDocument(decl.fileName())._setDeclForAST(ast, decl); + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var document = this.getDocument(decl.fileName()); + if (document) { + return document._getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { + this.getDocument(decl.fileName())._setASTForDecl(decl, ast); + }; + + SemanticInfoChain.prototype.topLevelDecl = function (fileName) { + var document = this.getDocument(fileName); + if (document) { + return document.topLevelDecl(); + } + + return null; + }; + + SemanticInfoChain.prototype.topLevelDecls = function () { + if (!this._topLevelDecls) { + this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { + return u.topLevelDecl(); + }); + } + + return this._topLevelDecls; + }; + + 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, 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; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { + this.document = document; + this.semanticInfoChain = semanticInfoChain; + this.propagateEnumConstants = propagateEnumConstants; + this.isDeclareFile = false; + this.parentChain = []; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + return DeclCollectionContext; + })(); + + function containingModuleHasExportAssignment(ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = ast; + return moduleDecl.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } else if (ast.kind() === 120 /* SourceUnit */) { + var sourceUnit = ast; + return sourceUnit.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } + + ast = ast.parent; + } + + return false; + } + + function isParsingAmbientModule(ast, context) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { + return true; + } + } + + ast = ast.parent; + } + + return false; + } + + function preCollectImportDecls(ast, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + + var parent = context.getParent(); + + if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { + declFlags |= 1 /* Exported */; + } + + 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 fileName = sourceUnit.fileName(); + + var isExternalModule = context.document.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); + + context.isDeclareFile = context.document.isDeclareFile(); + + context.pushParent(decl); + + if (isExternalModule) { + var declFlags = 1 /* Exported */; + if (TypeScript.isDTSFile(fileName)) { + declFlags |= 8 /* Ambient */; + } + + var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); + var kind = 32 /* DynamicModule */; + var valueText = TypeScript.quoteStr(fileName); + + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); + + context.semanticInfoChain.setASTForDecl(decl, sourceUnit); + + context.semanticInfoChain.setDeclForAST(sourceUnit, decl); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, sourceUnit, context); + } + + context.pushParent(decl); + } + } + + function preCollectEnumDecls(enumDecl, context) { + var declFlags = 0 /* None */; + var enumName = enumDecl.identifier.valueText(); + + if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + declFlags |= 4096 /* Enum */; + var kind = 64 /* Enum */; + + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); + context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); + context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); + + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); + enumDeclaration.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); + + context.pushParent(enumDeclaration); + } + + function createEnumElementDecls(propertyDecl, context) { + var parent = context.getParent(); + + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function preCollectModuleDecls(moduleDecl, context) { + var declFlags = 0 /* None */; + + var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); + + var isDynamic = moduleDecl.stringLiteral !== null; + + if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + + 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()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); + } + + context.pushParent(decl); + } else { + var moduleNames = getModuleNames(moduleDecl.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + var moduleName = moduleNames[i]; + + var specificFlags = declFlags; + if (i > 0) { + specificFlags |= 1 /* Exported */; + } + + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleName, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleName); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleName, context); + } + + context.pushParent(decl); + } + } + } + + function getModuleNames(name, result) { + result = result || []; + + if (name.kind() === 121 /* QualifiedName */) { + getModuleNames(name.left, result); + result.push(name.right); + } else { + result.push(name); + } + + return result; + } + TypeScript.getModuleNames = getModuleNames; + + 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.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); + } + + function containsExecutableCode(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); + + if (member.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = member; + + if (containsExecutableCode(moduleDecl.moduleElements)) { + return true; + } + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + } + + function preCollectClassDecls(classDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var parent = context.getParent(); + + 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); + + decl.setValueDecl(constructorDecl); + + context.semanticInfoChain.setDeclForAST(classDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, classDecl); + context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); + + context.pushParent(decl); + } + + function preCollectObjectTypeDecls(objectType, context) { + if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { + return; + } + + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setDeclForAST(objectType, decl); + context.semanticInfoChain.setASTForDecl(decl, objectType); + + context.pushParent(decl); + } + + function preCollectInterfaceDecls(interfaceDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { + declFlags |= 1 /* Exported */; + } + + var parent = context.getParent(); + + 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); + + context.pushParent(decl); + } + + function preCollectParameterDecl(argDecl, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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 */) { + decl.setFlag(67108864 /* ConstructorParameter */); + } + + var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); + var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; + if (isPublicOrPrivate && isInConstructor) { + var parentsParent = context.parentChain[context.parentChain.length - 2]; + + 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 */) { + propDecl.setFlag(67108864 /* ConstructorParameter */); + } + + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setASTForDecl(propDecl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, decl); + } + + parent.addVariableDeclToGroup(decl); + } + + function preCollectTypeParameterDecl(typeParameterDecl, context) { + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); + context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = 4096 /* Property */; + + if (propertyDecl.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var parent = context.getParent(); + + 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); + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 512 /* Variable */; + + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); + if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + 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); + context.semanticInfoChain.setDeclForAST(varDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, varDecl); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectVarDecls(ast, context) { + if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { + return; + } + + var varDecl = ast; + createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + 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); + context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); + + context.pushParent(decl); + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + 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); + context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); + + context.pushParent(decl); + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + 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); + context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); + + context.pushParent(decl); + } + + function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { + if (typeof displayName === "undefined") { displayName = null; } + var declFlags = 0 /* None */; + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { + declFlags |= 8192 /* ArrowFunction */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = id ? id.text() : ""; + var displayNameText = displayName ? displayName.text() : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); + context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); + + context.pushParent(decl); + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrow = functionExpressionDeclAST; + var declFlags = 4 /* Public */; + + var parent = context.getParent(); + + if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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); + + parent.addVariableDeclToGroup(decl); + } + } + + function createMemberFunctionDeclaration(funcDecl, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!funcDecl.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(funcDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDecl); + + context.pushParent(decl); + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 4194304 /* IndexSignature */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); + + context.pushParent(decl); + } + + function createCallSignatureDeclaration(callSignature, context) { + var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; + + if (!isChildOfObjectType) { + return; + } + + var declFlags = 2048 /* Signature */; + var declType = 1048576 /* CallSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(callSignature, decl); + context.semanticInfoChain.setASTForDecl(decl, callSignature); + + context.pushParent(decl); + } + + function createMethodSignatureDeclaration(method, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + declFlags |= 4 /* Public */; + declFlags |= 2048 /* Signature */; + + if (method.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(method, decl); + context.semanticInfoChain.setASTForDecl(decl, method); + + context.pushParent(decl); + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 2097152 /* ConstructSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); + + context.pushParent(decl); + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); + + context.pushParent(decl); + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); + + context.pushParent(decl); + } + + function createFunctionExpressionDeclaration(expression, context) { + createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); + + context.pushParent(decl); + } + + function preCollectCatchDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 268435456 /* CatchBlock */; + + 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); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + + var declFlags = 0 /* None */; + var declType = 1024 /* CatchVariable */; + + 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); + context.semanticInfoChain.setDeclForAST(ast.identifier, decl); + context.semanticInfoChain.setASTForDecl(decl, ast.identifier); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectWithDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 134217728 /* WithBlock */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectObjectLiteralDecls(ast, context) { + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); + + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectSimplePropertyAssignmentDecls(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()); + + context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); + } + + function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { + var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); + + 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); + + createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); + } + + function preCollectDecls(ast, context) { + switch (ast.kind()) { + case 120 /* SourceUnit */: + preCollectScriptDecls(ast, context); + break; + case 132 /* EnumDeclaration */: + preCollectEnumDecls(ast, context); + break; + case 243 /* EnumElement */: + createEnumElementDecls(ast, context); + break; + case 130 /* ModuleDeclaration */: + preCollectModuleDecls(ast, context); + break; + case 131 /* ClassDeclaration */: + preCollectClassDecls(ast, context); + break; + case 128 /* InterfaceDeclaration */: + preCollectInterfaceDecls(ast, context); + break; + case 122 /* ObjectType */: + preCollectObjectTypeDecls(ast, context); + break; + case 242 /* Parameter */: + preCollectParameterDecl(ast, context); + break; + case 136 /* MemberVariableDeclaration */: + createMemberVariableDeclaration(ast, context); + break; + case 141 /* PropertySignature */: + createPropertySignature(ast, context); + break; + case 225 /* VariableDeclarator */: + preCollectVarDecls(ast, context); + break; + case 137 /* ConstructorDeclaration */: + createClassConstructorDeclaration(ast, context); + break; + case 139 /* GetAccessor */: + createGetAccessorDeclaration(ast, context); + break; + case 140 /* SetAccessor */: + createSetAccessorDeclaration(ast, context); + break; + case 222 /* FunctionExpression */: + createFunctionExpressionDeclaration(ast, context); + break; + case 135 /* MemberFunctionDeclaration */: + createMemberFunctionDeclaration(ast, context); + break; + case 144 /* IndexSignature */: + createIndexSignatureDeclaration(ast, context); + break; + case 123 /* FunctionType */: + createFunctionTypeDeclaration(ast, context); + break; + case 125 /* ConstructorType */: + createConstructorTypeDeclaration(ast, context); + break; + case 142 /* CallSignature */: + createCallSignatureDeclaration(ast, context); + break; + case 143 /* ConstructSignature */: + createConstructSignatureDeclaration(ast, context); + break; + case 145 /* MethodSignature */: + createMethodSignatureDeclaration(ast, context); + break; + case 129 /* FunctionDeclaration */: + createFunctionDeclaration(ast, context); + break; + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + createAnyFunctionExpressionDeclaration(ast, null, context); + break; + case 133 /* ImportDeclaration */: + preCollectImportDecls(ast, context); + break; + case 238 /* TypeParameter */: + preCollectTypeParameterDecl(ast, context); + break; + case 236 /* CatchClause */: + preCollectCatchDecls(ast, context); + break; + case 163 /* WithStatement */: + preCollectWithDecls(ast, context); + break; + case 215 /* ObjectLiteralExpression */: + preCollectObjectLiteralDecls(ast, context); + break; + case 240 /* SimplePropertyAssignment */: + preCollectSimplePropertyAssignmentDecls(ast, context); + break; + case 241 /* FunctionPropertyAssignment */: + preCollectFunctionPropertyAssignmentDecls(ast, context); + break; + } + } + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, context) { + var currentDecl = context.getParent(); + + if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { + if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + return; + } + } + + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDeclaration = ast; + if (moduleDeclaration.stringLiteral) { + TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); + context.popParent(); + } else { + var moduleNames = getModuleNames(moduleDeclaration.name); + for (var i = moduleNames.length - 1; i >= 0; i--) { + var moduleName = moduleNames[i]; + TypeScript.Debug.assert(currentDecl.ast() === moduleName); + context.popParent(); + currentDecl = context.getParent(); + } + } + } + + if (ast.kind() === 132 /* EnumDeclaration */) { + computeEnumElementConstantValues(ast, currentDecl, context); + } + + while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { + context.popParent(); + currentDecl = context.getParent(); + } + } + + function computeEnumElementConstantValues(ast, enumDecl, context) { + TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); + + var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); + var inConstantSection = !isAmbientEnum; + var currentConstantValue = 0; + var enumMemberDecls = enumDecl.getChildDecls(); + + for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { + var enumElement = ast.enumElements.nonSeparatorAt(i); + var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { + return context.semanticInfoChain.getASTForDecl(d) === enumElement; + }); + + TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); + + if (enumElement.equalsValueClause === null) { + if (inConstantSection) { + enumElementDecl.constantValue = currentConstantValue; + currentConstantValue++; + } + } else { + enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); + if (enumElementDecl.constantValue !== null && !isAmbientEnum) { + inConstantSection = true; + currentConstantValue = enumElementDecl.constantValue + 1; + } else { + inConstantSection = false; + } + } + + TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); + } + } + + function computeEnumElementConstantValue(expression, enumMemberDecls, context) { + TypeScript.Debug.assert(expression); + + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { + var token; + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + token = expression.operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; + } else if (context.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var name = expression; + var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { + return d.name === name.valueText(); + }); + + return matchingEnumElement ? matchingEnumElement.constantValue : null; + + case 202 /* LeftShiftExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left << right; + + case 189 /* BitwiseOrExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left | right; + } + + return null; + } else { + return null; + } + } + + (function (DeclarationCreator) { + function create(document, semanticInfoChain, compilationSettings) { + var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); + + TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); + + return declCollectionContext.getParent(); + } + DeclarationCreator.create = create; + })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); + var DeclarationCreator = TypeScript.DeclarationCreator; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBinder = (function () { + 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 */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.hasBeenBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind === 262144 /* GetAccessor */) { + parent = parent.getGetter(); + } else if (parentDeclKind === 524288 /* SetAccessor */) { + parent = parent.getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = parent.getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = startingDecl.getParentPath(); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + }; + + PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { + var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; + var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; + var name = decl.name; + if (parent) { + var isExported = (decl.flags & 1 /* Exported */) !== 0; + + var prevSymbol = null; + if (lookingForValue) { + prevSymbol = parent.findContainedNonMember(name); + } else if (lookingForType) { + prevSymbol = parent.findContainedNonMemberType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); + } + var prevIsExported = !prevSymbol; + if (!prevSymbol) { + if (lookingForValue) { + prevSymbol = parent.findMember(name, false); + } else if (lookingForType) { + prevSymbol = parent.findNestedType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findNestedContainer(name, searchKind); + } + } + + if (isExported && prevIsExported) { + return prevSymbol; + } + if (prevSymbol) { + var prevDecls = prevSymbol.getDeclarations(); + var lastPrevDecl = prevDecls[prevDecls.length - 1]; + var parentDecl = decl.getParentDecl(); + var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); + if (parentDecl !== prevParentDecl) { + return null; + } + + return prevSymbol; + } + } else { + var parentDecl = decl.getParentDecl(); + if (parentDecl && parentDecl.kind === 1 /* Script */) { + return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); + } else { + var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); + return prevDecls[0] && prevDecls[0].getSymbol(); + } + } + + return null; + }; + + PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { + if (typeof reportError === "undefined") { reportError = true; } + 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 (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()]); + } + return false; + } + + 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; + + var enumContainerSymbol = null; + var enumInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var enumInstanceDecl = enumContainerDecl.getValueDecl(); + + var enumDeclKind = enumContainerDecl.kind; + + var parent = this.getParent(enumContainerDecl); + var parentInstanceSymbol = this.getParent(enumContainerDecl, true); + var parentDecl = enumContainerDecl.getParentDecl(); + var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); + + var isExported = enumContainerDecl.flags & 1 /* Exported */; + + var createdNewSymbol = false; + + enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); + + if (enumContainerSymbol) { + if (enumContainerSymbol.kind !== enumDeclKind) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); + enumContainerSymbol = null; + } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { + enumContainerSymbol = null; + } + } + + if (enumContainerSymbol) { + enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); + } else { + enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); + } + } + + enumContainerSymbol.addDeclaration(enumContainerDecl); + enumContainerDecl.setSymbol(enumContainerSymbol); + + this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); + this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); + + if (!enumInstanceSymbol) { + var variableSymbol = null; + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] === enumContainerDecl) { + break; + } + + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol) { + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + enumInstanceSymbol = variableSymbol; + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); + } + + enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + enumInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); + } + } + + if (createdNewSymbol && parent) { + if (enumContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(enumContainerSymbol); + } else { + parent.addEnclosedNonMemberType(enumContainerSymbol); + } + } + + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } + var valueDecl = enumContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + 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(); + + enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; + + 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(); + + 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); + if (!moduleDeclAST) { + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); + + moduleDeclAST = moduleNameAST; + } + + var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); + var searchKind = 164 /* SomeContainer */; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; + + if (parent && moduleKind === 32 /* DynamicModule */) { + this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); + } + + var createdNewSymbol = false; + + moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); + + if (moduleContainerTypeSymbol) { + if (moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); + } + + moduleContainerTypeSymbol = null; + } 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) { + moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); + this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); + + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); + } + } + } + + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); + + 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); + } + } + + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(importSymbol); + } else { + parent.addEnclosedNonMemberContainer(importSymbol); + } + } + }; + + 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; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + 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, 58728795 /* SomeType */, parent); + + if (classSymbol && classSymbol.kind === 16 /* Interface */) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); + classSymbol = null; + } + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); + this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + 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; + + if (!constructorSymbol) { + var siblingValueDecls = null; + if (parentDecl) { + siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); + + if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { + constructorSymbol = siblingValueDecls[0].getSymbol(); + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + constructorSymbol.setIsSynthesized(); + constructorSymbol.type = constructorTypeSymbol; + } + + classSymbol.setConstructorMethod(constructorSymbol); + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); + + if (interfaceSymbol) { + if (!(interfaceSymbol.kind & acceptableSharedKind)) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); + interfaceSymbol = null; + } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { + interfaceSymbol = null; + } + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + 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; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + 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; + variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); + var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); + var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); + 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 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 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.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 || 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); + variableSymbol = null; + parentHadSymbol = false; + } + } + + if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { + variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); + } + } + + if ((declFlags & 118784 /* ImplicitVariable */) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + if (!parent && parentDecl.kind === 1 /* Script */) { + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); + this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfoChain.getASTForDecl(decl); + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & 102400 /* SomeInitializedModule */) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + 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); + } + variableDeclaration.setSymbol(variableSymbol); + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + if (!variableSymbol.hasDeclaration(variableDeclaration)) { + variableSymbol.addDeclaration(variableDeclaration); + } + 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); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); + + var declName = variableDeclaration.name; + + var variableSymbol = new TypeScript.PullSymbol(declName, declKind); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + + this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); + }; + + PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + var propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + + var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { + var parameters = []; + var params = TypeScript.createIntrinsicsObject(); + var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); + + if (parameterList) { + for (var i = 0, n = parameterList.length; i < n; i++) { + var argDecl = parameterList.astAt(i); + var id = parameterList.identifierAt(i); + var decl = this.semanticInfoChain.getDeclForAST(argDecl); + var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); + var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); + + if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { + parameterSymbol.isVarArg = 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); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); + + if (functionSymbol) { + 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); + functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); + } + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { + signature.hasVarArgs = true; + } + + var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); + + 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; + if (name) { + this.semanticInfoChain.setSymbolForAST(name, functionSymbol); + } + + this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); + + if (parameters.lastParameterIsRest()) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + + var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; + + TypeScript.Debug.assert(nameAST); + + this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); + this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); + + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); + if (TypeScript.lastParameterIsRest(parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); + signature.addTypeParameter(typeParameter); + } else { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { + var prototypeStr = "prototype"; + + var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); + if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { + 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], this.semanticInfoChain); + + prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + prototypeSymbol.setIsSynthesized(); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = classTypeSymbol; + constructorTypeSymbol.addMember(prototypeSymbol); + + if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { + var resolver = this.semanticInfoChain.getResolver(); + prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); + } + prototypeSymbol.setResolved(); + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); + constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.appendConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + constructSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + callSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); + + var parent = this.getParent(indexSignatureDeclaration); + parent.addIndexSignature(indexSignature); + indexSignature.setContainer(parent); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + + getterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); + } + }; + + 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) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + this.bindEnumDeclarationToPullSymbol(decl); + break; + + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 512 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 1024 /* CatchVariable */: + this.bindCatchVariableToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + this.bindEnumMemberDeclarationToPullSymbol(decl); + break; + + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 128 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + decl.getParentDecl().getSymbol(); + break; + + case 268435456 /* CatchBlock */: + case 134217728 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); + this.declsBeingBound.pop(); + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (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(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + + if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (functionDecl.kind === 4194304 /* IndexSignature */) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + + function isNameNumeric(name) { + return isFinite(+name); + } + PullHelpers.isNameNumeric = isNameNumeric; + + function typeSymbolsAreIdentical(a, b) { + if (a.isTypeReference() && !a.getIsSpecialized()) { + a = a.referencedTypeSymbol; + } + + if (b.isTypeReference() && !b.getIsSpecialized()) { + b = b.referencedTypeSymbol; + } + + return a === b; + } + PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; + + function getRootType(type) { + var rootType = type.getRootSymbol(); + + while (true) { + if (type === rootType) { + return type; + } + + type = rootType; + rootType = type.getRootSymbol(); + } + } + PullHelpers.getRootType = getRootType; + + function isSymbolLocal(symbol) { + var container = symbol.getContainer(); + if (container) { + var containerKind = container.kind; + if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { + return true; + } + + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { + return true; + } + } + + 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; + +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.fileResolutionIOTime = 0; + TypeScript.fileResolutionScanImportsTime = 0; + TypeScript.fileResolutionImportFileSearchTime = 0; + TypeScript.fileResolutionGetDefaultLibraryTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.compilerResolvePathTime = 0; + TypeScript.compilerDirectoryNameTime = 0; + TypeScript.compilerDirectoryExistsTime = 0; + TypeScript.compilerFileExistsTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + 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(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } + this.outputFiles = []; + this.emitOutputResult = emitOutputResult; + } + return EmitOutput; + })(); + TypeScript.EmitOutput = EmitOutput; + + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); + var OutputFileType = TypeScript.OutputFileType; + + var OutputFile = (function () { + function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { + if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.text = text; + this.fileType = fileType; + this.sourceMapEntries = sourceMapEntries; + } + return OutputFile; + })(); + TypeScript.OutputFile = OutputFile; + + var CompileResult = (function () { + function CompileResult() { + this.diagnostics = []; + this.outputFiles = []; + } + CompileResult.fromDiagnostics = function (diagnostics) { + var result = new CompileResult(); + result.diagnostics = diagnostics; + return result; + }; + + CompileResult.fromOutputFiles = function (outputFiles) { + var result = new CompileResult(); + result.outputFiles = outputFiles; + return result; + }; + return CompileResult; + })(); + TypeScript.CompileResult = CompileResult; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, _settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } + this.logger = logger; + this._settings = _settings; + this.semanticInfoChain = null; + this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); + } + TypeScriptCompiler.prototype.compilationSettings = function () { + return this._settings; + }; + + TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { + var oldSettings = this._settings; + this._settings = newSettings; + + if (!compareDataObjects(oldSettings, newSettings)) { + this.semanticInfoChain.invalidate(oldSettings, newSettings); + } + }; + + TypeScriptCompiler.prototype.getDocument = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.semanticInfoChain.getDocument(fileName); + }; + + TypeScriptCompiler.prototype.cleanupSemanticCache = function () { + this.semanticInfoChain.invalidate(); + }; + + TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); + + this.semanticInfoChain.addDocument(document); + }; + + TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); + + this.semanticInfoChain.addDocument(updatedDocument); + }; + + TypeScriptCompiler.prototype.removeFile = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + this.semanticInfoChain.removeDocument(fileName); + }; + + TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { + if (document.emitToOwnOutputFile()) { + var updatedFileName = document.fileName; + if (emitOptions.outputDirectory() !== "") { + updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); + updatedFileName = emitOptions.outputDirectory() + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(emitOptions.sharedOutputFile(), true); + } + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + var printReason = false; + + if (document.emitToOwnOutputFile()) { + var result = document.byteOrderMark !== 0 /* None */; + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + } + return result; + } else { + var fileNames = this.fileNames(); + + var result = false; + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + + if (document.isExternalModule()) { + continue; + } + + if (document.byteOrderMark !== 0 /* None */) { + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + result = true; + } else { + return true; + } + } + } + + return result; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype._shouldEmit = function (document) { + return !document.isDeclareFile(); + }; + + TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { + if (!this.compilationSettings().generateDeclarationFiles()) { + return false; + } + + return this._shouldEmit(document); + }; + + TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); + + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); + } + + declarationEmitter.emitDeclarations(sourceUnit); + return declarationEmitter; + }; + + TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmitDeclarations(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFile()); + } + } else { + sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var sharedEmitter = null; + var fileNames = this.fileNames(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileNames[i]); + + sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return emitOutput; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, null); + return emitOutput; + } else { + return this.emitAllDeclarations(resolvePath); + } + }; + + 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; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmit(document)); + + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); + var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); + + if (this.compilationSettings().mapSourceFiles()) { + var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); + emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); + } + } else if (this.compilationSettings().mapSourceFiles()) { + emitter.setSourceMapperNewSourceFile(document); + } + + emitter.setDocument(document); + emitter.emitJavascript(sourceUnit, false); + + return emitter; + }; + + TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmit(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFiles()); + } + } else { + sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var fileNames = this.fileNames(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + sharedEmitter = this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); + } + + TypeScript.emitTime += new Date().getTime() - start; + return emitOutput; + }; + + TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, null); + return emitOutput; + } else { + return this.emitAll(resolvePath); + } + }; + + TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { + if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } + return new CompilerIterator(this, resolvePath, continueOnDiagnostics); + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + + TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { + return this.getDocument(fileName).sourceUnit(); + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + var errors = this.semanticInfoChain.getDiagnostics(fileName); + + errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); + errors.sort(function (d1, d2) { + if (d1.fileName() < d2.fileName()) { + return -1; + } else if (d1.fileName() > d2.fileName()) { + return 1; + } + + if (d1.start() < d2.start()) { + return -1; + } else if (d1.start() > d2.start()) { + return 1; + } + + var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; + var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; + if (code1 < code2) { + return -1; + } else if (code1 > code2) { + return 1; + } + + return 0; + }); + + 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++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var ast = this.semanticInfoChain.getASTForDecl(decl); + if (!ast) { + return null; + } + + var enclosingDecl = resolver.getEnclosingDecl(decl); + if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { + return this.getSymbolOfDeclaration(enclosingDecl); + } + + return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { + var scriptName = document.fileName; + + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + var inWithBlock = false; + + var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); + + if (!ast) { + return null; + } + + var path = this.getASTPath(ast); + + for (var i = 0, n = path.length; i < n; i++) { + var current = path[i]; + + switch (current.kind()) { + case 222 /* FunctionExpression */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + if (propagateContextualTypes) { + resolver.resolveAST(current, true, resolutionContext); + } + break; + + case 136 /* MemberVariableDeclaration */: + var memberVariable = current; + inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); + break; + + case 225 /* VariableDeclarator */: + var variableDeclarator = current; + inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); + break; + + case 213 /* InvocationExpression */: + case 216 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.kind() === 216 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = path[i + 3]; + if (argExpression) { + for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { + if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext); + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 214 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 215 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.propertyAssignments; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { + if (memberDecls.nonSeparatorAt(j) === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + } + + break; + + case 174 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path[i + 1] && path[i + 1] === assignmentExpression.right) { + var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + 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; + + case 150 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 122 /* ObjectType */: + if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { + resolver.resolveAST(current, false, resolutionContext); + } + + break; + + case 163 /* WithStatement */: + inWithBlock = true; + break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; + } + + var decl = this.semanticInfoChain.getDeclForAST(current); + if (decl) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { + if (ast.parent.kind() === 212 /* MemberAccessExpression */) { + if (ast.parent.name === ast) { + ast = ast.parent; + } + } else if (ast.parent.kind() === 121 /* QualifiedName */) { + if (ast.parent.right === ast) { + ast = ast.parent; + } + } + } + + return { + ast: ast, + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment, + inWithBlock: inWithBlock + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + resolver.resolveAST(assigningAST, false, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushNewContextualType(contextualType); + + if (init) { + resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); + } + } + } + }; + + TypeScriptCompiler.prototype.getASTPath = function (ast) { + var result = []; + + while (ast) { + result.unshift(ast); + ast = ast.parent; + } + + return result; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + ast = context.ast; + 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()]); + return null; + } + + if (symbol.isTypeReference()) { + symbol = symbol.getReferencedTypeSymbol(); + } + + var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); + + return { + symbol: symbol, + aliasSymbol: aliasSymbol, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { + if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { + return null; + } + + var isNew = ast.kind() === 216 /* ObjectCreationExpression */; + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, false); + if (!context || context.inWithBlock) { + return null; + } + + return resolver.getVisibleDecls(context.enclosingDecl); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { + if (ast.kind() !== 215 /* ObjectLiteralExpression */) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var astForDecl = decl.ast(); + if (!astForDecl) { + return null; + } + + var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); + if (!astForDeclContext) { + return null; + } + + var symbol = decl.getSymbol(); + resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + aliasSymbol: null, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { + return this.semanticInfoChain.topLevelDecl(fileName); + }; + + TypeScriptCompiler.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast); + }; + + TypeScriptCompiler.prototype.fileNames = function () { + return this.semanticInfoChain.fileNames(); + }; + + 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; + + var CompilerPhase; + (function (CompilerPhase) { + CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; + CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; + CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; + CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; + CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; + })(CompilerPhase || (CompilerPhase = {})); + + var CompilerIterator = (function () { + function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { + if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } + this.compiler = compiler; + this.resolvePath = resolvePath; + this.continueOnDiagnostics = continueOnDiagnostics; + this.index = -1; + this.fileNames = null; + this._current = null; + this._emitOptions = null; + this._sharedEmitter = null; + this._sharedDeclarationEmitter = null; + this.hadSyntacticDiagnostics = false; + this.hadSemanticDiagnostics = false; + this.hadEmitDiagnostics = false; + this.fileNames = compiler.fileNames(); + this.compilerPhase = startingPhase; + } + CompilerIterator.prototype.current = function () { + return this._current; + }; + + CompilerIterator.prototype.moveNext = function () { + this._current = null; + + while (this.moveNextInternal()) { + if (this._current) { + return true; + } + } + + return false; + }; + + CompilerIterator.prototype.moveNextInternal = function () { + this.index++; + + while (this.shouldMoveToNextPhase()) { + this.index = 0; + this.compilerPhase++; + } + + if (this.compilerPhase > 4 /* DeclarationEmit */) { + return false; + } + + switch (this.compilerPhase) { + case 0 /* Syntax */: + return this.moveNextSyntaxPhase(); + case 1 /* Semantics */: + return this.moveNextSemanticsPhase(); + case 2 /* EmitOptionsValidation */: + return this.moveNextEmitOptionsValidationPhase(); + case 3 /* Emit */: + return this.moveNextEmitPhase(); + case 4 /* DeclarationEmit */: + return this.moveNextDeclarationEmitPhase(); + } + }; + + CompilerIterator.prototype.shouldMoveToNextPhase = function () { + switch (this.compilerPhase) { + case 2 /* EmitOptionsValidation */: + return this.index === 1; + + case 0 /* Syntax */: + case 1 /* Semantics */: + return this.index === this.fileNames.length; + + case 3 /* Emit */: + case 4 /* DeclarationEmit */: + return this.index === (this.fileNames.length + 1); + } + + return false; + }; + + CompilerIterator.prototype.moveNextSyntaxPhase = function () { + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + + var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSyntacticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextSemanticsPhase = function () { + if (this.hadSyntacticDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + var diagnostics = this.compiler.getSemanticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSemanticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + + if (!this._emitOptions) { + this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); + } + + if (this._emitOptions.diagnostic()) { + if (!this.continueOnDiagnostics) { + this.hadEmitDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(this._emitOptions); + + if (this.hadEmitDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { + _this._current = CompileResult.fromOutputFiles(outputFiles); + }, this._sharedEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedEmitter) { + this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); + } + + return true; + }; + + CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(!this.hadEmitDiagnostics); + if (this.hadSemanticDiagnostics) { + return false; + } + + if (!this.compiler.compilationSettings().generateDeclarationFiles()) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { + _this._current = CompileResult.fromOutputFiles([file]); + }, this._sharedDeclarationEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { + this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); + } + + return true; + }; + return CompilerIterator; + })(); + + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) + return false; + } else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) + return false; + } + } + return true; + } + TypeScript.compareDataObjects = compareDataObjects; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (GenerativeTypeClassification) { + GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; + GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; + GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; + GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; + })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); + var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; + + var PullTypeReferenceSymbol = (function (_super) { + __extends(PullTypeReferenceSymbol, _super); + function PullTypeReferenceSymbol(referencedTypeSymbol) { + _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); + this.referencedTypeSymbol = referencedTypeSymbol; + this.isResolved = true; + + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); + + this.setRootSymbol(referencedTypeSymbol); + + this.typeReference = this; + } + PullTypeReferenceSymbol.createTypeReference = function (type) { + if (type.isTypeReference()) { + return type; + } + + var typeReference = type.typeReference; + + if (!typeReference) { + typeReference = new PullTypeReferenceSymbol(type); + type.typeReference = typeReference; + } + + return typeReference; + }; + + PullTypeReferenceSymbol.prototype.isTypeReference = function () { + return true; + }; + + PullTypeReferenceSymbol.prototype.setResolved = function () { + }; + + PullTypeReferenceSymbol.prototype.setUnresolved = function () { + }; + PullTypeReferenceSymbol.prototype.invalidate = function () { + }; + + PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { + this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); + }; + + PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol; + }; + + PullTypeReferenceSymbol.prototype._getResolver = function () { + return this.referencedTypeSymbol._getResolver(); + }; + + PullTypeReferenceSymbol.prototype.hasMembers = function () { + return this.referencedTypeSymbol.hasMembers(); + }; + + PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); + }; + + PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + return this.referencedTypeSymbol.getAssociatedContainerType(); + }; + + PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getFunctionSymbol(); + }; + PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); + }; + + PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); + }; + PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); + }; + + PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); + }; + PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMember(name); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); + }; + + PullTypeReferenceSymbol.prototype.getMembers = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getMembers(); + }; + + PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); + }; + PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getHasDefaultConstructor(); + }; + PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructorMethod(); + }; + PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); + }; + PullTypeReferenceSymbol.prototype.getTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.isGeneric = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isGeneric(); + }; + + PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getSpecialization(substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getKnownSpecializations(); + }; + PullTypeReferenceSymbol.prototype.getTypeArguments = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArguments(); + }; + PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); + }; + 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"); + }; + + PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnIndexSignatures(); + }; + PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getIndexSignatures(); + }; + + PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { + this.referencedTypeSymbol.addImplementedType(implementedType); + }; + PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getImplementedTypes(); + }; + PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { + this.referencedTypeSymbol.addExtendedType(extendedType); + }; + PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getExtendedTypes(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExtendsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExtendThisType(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); + }; + + PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); + }; + + PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findMember(name, lookInParent); + }; + PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedType(name, kind); + }; + PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedContainer(name, kind); + }; + PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + }; + + PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findTypeParameter(name); + }; + + PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); + }; + return PullTypeReferenceSymbol; + })(TypeScript.PullTypeSymbol); + TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; + + var PullInstantiatedTypeReferenceSymbol = (function (_super) { + __extends(PullInstantiatedTypeReferenceSymbol, _super); + 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 = undefined; + this._instantiatedConstructorMethod = null; + this._instantiatedAssociatedContainerType = null; + this._isArray = undefined; + this._generativeTypeClassification = []; + + TypeScript.nSpecializationsCreated++; + } + PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { + return !this.isInstanceReferenceType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; + } + + 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()); + } + return this._isArray; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { + if (!this.isArrayNamedTypeReference()) { + return null; + } + + var typeArguments = this.getTypeArguments(); + return typeArguments ? typeArguments[0] : null; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.getIsSpecialized()) { + return this; + } + + return this.referencedTypeSymbol; + }; + + 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + 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; + } + } + + if (isInstanceReferenceType) { + typeParameterArgumentMap = []; + } + } + + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); + + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); + + return instantiation; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { + return this.getRootSymbol().isGeneric(); + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { + if (this.isInstanceReferenceType) { + return this.getTypeParameters(); + } + + if (this._typeArgumentReferences === undefined) { + var typeParameters = this.referencedTypeSymbol.getTypeParameters(); + + if (typeParameters.length) { + var typeArgument = null; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; + + if (!typeArgument) { + TypeScript.Debug.fail("type argument count mismatch"); + } + + if (typeArgument) { + typeArguments[typeArguments.length] = typeArgument; + } + } + + this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; + } + } + + return this._typeArgumentReferences; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + 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(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getMembers(); + } + + if (!this._instantiatedMembers) { + var referencedMembers = this.referencedTypeSymbol.getMembers(); + var referencedMember = null; + var instantiatedMember = null; + + this._instantiatedMembers = []; + + for (var i = 0; i < referencedMembers.length; i++) { + referencedMember = referencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (!this._instantiatedMemberNameCache[referencedMember.name]) { + this.populateInstantiatedMemberFromReferencedMember(referencedMember); + } + + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; + } + } + + return this._instantiatedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.findMember(name, lookInParent); + } + + var memberSymbol = this._instantiatedMemberNameCache[name]; + + if (!memberSymbol) { + var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); + + if (referencedMemberSymbol) { + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; + } else { + memberSymbol = null; + } + } + + return memberSymbol; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + } + + var requestedMembers = []; + var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + + if (!this._allInstantiatedMemberNameCache) { + this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); + + var members = this.getMembers(); + + for (var i = 0; i < members.length; i++) { + this._allInstantiatedMemberNameCache[members[i].name] = members[i]; + } + } + + var referencedMember = null; + var requestedMember = null; + + for (var i = 0; i < allReferencedMembers.length; i++) { + referencedMember = allReferencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (this._allInstantiatedMemberNameCache[referencedMember.name]) { + requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; + } else { + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; + requestedMembers[requestedMembers.length] = referencedMember; + } else { + requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + requestedMember.setRootSymbol(referencedMember); + + requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + requestedMember.isOptional = referencedMember.isOptional; + + this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; + requestedMembers[requestedMembers.length] = requestedMember; + } + } + } + + return requestedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructorMethod(); + } + + 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); + } + + return this._instantiatedConstructorMethod; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + if (!this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAssociatedContainerType(); + } + + if (!this._instantiatedAssociatedContainerType) { + var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); + + if (referencedAssociatedContainerType) { + this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); + } + } + + return this._instantiatedAssociatedContainerType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getCallSignatures(); + } + + if (this._instantiatedCallSignatures) { + return this._instantiatedCallSignatures; + } + + var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); + this._instantiatedCallSignatures = []; + + for (var i = 0; i < referencedCallSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); + + if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; + } else { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedCallSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructSignatures(); + } + + if (this._instantiatedConstructSignatures) { + return this._instantiatedConstructSignatures; + } + + var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); + this._instantiatedConstructSignatures = []; + + for (var i = 0; i < referencedConstructSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); + + if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; + } else { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedConstructSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getIndexSignatures(); + } + + if (this._instantiatedIndexSignatures) { + return this._instantiatedIndexSignatures; + } + + var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); + this._instantiatedIndexSignatures = []; + + for (var i = 0; i < referencedIndexSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); + + if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; + } else { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedIndexSignatures; + }; + 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) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { + if (element === null) { + return null; + } + + if (element.fullWidth() === 0) { + return new TypeScript.ASTSpan(-1, -1); + } + + var leadingTriviaWidth = element.leadingTriviaWidth(); + var trailingTriviaWidth = element.trailingTriviaWidth(); + + var start = fullStart + leadingTriviaWidth; + var end = fullStart + element.fullWidth() - trailingTriviaWidth; + + return new TypeScript.ASTSpan(start, end); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { + if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } + if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span._trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span._start = start; + span._end = end; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ISyntaxList2(this.fileName, array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { + return this.visitToken(token); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result = this.visitTokenWorker(token); + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { + switch (token.tokenKind) { + case 60 /* AnyKeyword */: + return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); + case 61 /* BooleanKeyword */: + return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); + case 67 /* NumberKeyword */: + return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); + case 69 /* StringKeyword */: + return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); + case 41 /* VoidKeyword */: + return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); + case 35 /* ThisKeyword */: + return new TypeScript.ThisExpression(token.text(), token.valueText()); + case 50 /* SuperKeyword */: + return new TypeScript.SuperExpression(token.text(), token.valueText()); + case 37 /* TrueKeyword */: + return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); + case 24 /* FalseKeyword */: + return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); + case 32 /* NullKeyword */: + return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); + case 14 /* StringLiteral */: + return new TypeScript.StringLiteral(token.text(), token.valueText()); + case 12 /* RegularExpressionLiteral */: + return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); + case 13 /* NumericLiteral */: + var fullStart = this.position; + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); + + result.setPreComments(preComments); + return result; + case 11 /* IdentifierName */: + return new TypeScript.Identifier(token.text()); + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { + var start = this.position; + TypeScript.Debug.assert(start === 0); + + var bod = this.visitSyntaxList(node.moduleElements); + 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; + }; + + SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { + var start = this.position; + + this.moveTo(node, node.stringLiteral); + var stringLiteral = node.stringLiteral.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ExternalModuleReference(stringLiteral); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { + var start = this.position; + var moduleName = node.moduleName.accept(this); + + var result = new TypeScript.ModuleNameModuleReference(moduleName); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + this.movePast(node.openBraceToken); + var members = this.visitSyntaxList(node.classElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { + var result = null; + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { + result = result || []; + result.push(1 /* Exported */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + result = result || []; + result.push(8 /* Ambient */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { + result = result || []; + result.push(16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { + result = result || []; + result.push(4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { + result = result || []; + result.push(2 /* Private */); + } + + return result || TypeScript.sentinelEmptyArray; + }; + + SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + var body = this.visitObjectType(node.body); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { + var start = this.position; + + this.movePast(node.extendsOrImplementsKeyword); + var typeNames = this.visitSeparatedSyntaxList(node.typeNames); + + var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { + var start = this.position; + + var modifiers = this.visitModifiers(node.modifiers); + + this.moveTo(node, node.moduleKeyword); + this.movePast(node.moduleKeyword); + + var moduleName = node.name ? node.name.accept(this) : null; + var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; + + this.movePast(node.openBraceToken); + + var moduleElements = this.visitSyntaxList(node.moduleElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + this.movePast(node.openBraceToken); + + var enumElements = this.visitSeparatedSyntaxList(node.enumElements); + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + var start = this.position; + + var memberName = this.visitToken(node.propertyName); + + var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.EnumElement(memberName, value); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ImportDeclaration(modifiers, name, alias); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.VariableStatement(modifiers, declaration); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var propertyName = this.visitToken(node.propertyName); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var start = this.position; + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var value = node.value.accept(this); + value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); + + var result = new TypeScript.EqualsValueClause(value); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayLiteralExpression(expressions); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(openParenToken); + + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = node.identifier.accept(this); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var callSignature = this.visitCallSignature(node.callSignature); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + return type ? type.accept(this) : null; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var result = new TypeScript.TypeQuery(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left); + this.movePast(node.dotToken); + var right = this.visitIdentifier(node.right); + + var result = new TypeScript.QualifiedName(left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeArgumentList(typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectType(typeMembers); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayType(underlying); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name); + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + var result = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.colonToken); + var type = this.visitType(node.type); + + var result = new TypeScript.TypeAnnotation(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.visitIdentifier(node.name); + + var result = new TypeScript.MemberAccessExpression(expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + this.movePast(node.openParenToken); + + 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()); + } + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(node.kind(), left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.ConstructSignature(callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.MethodSignature(name, questionToken, callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.IndexSignature(parameter, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + var openParenToken = node.openParenToken; + + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + var openParenTrailingComments = null; + if (node.parameters.childCount() === 0) { + openParenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + } + + this.movePast(node.openParenToken); + var parameters = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeParameterList(typeParameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + var start = this.position; + this.movePast(node.extendsKeyword); + var type = this.visitType(node.type); + + var result = new TypeScript.Constraint(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + var start = this.position; + + this.movePast(node.elseKeyword); + var statement = node.statement.accept(this); + + var result = new TypeScript.ElseClause(statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var expression = node.expression.accept(this); + + var semicolonPosition = this.position; + + var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + 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(callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.indexSignature); + var indexSignature = node.indexSignature.accept(this); + + this.movePast(node.semicolonToken); + + var result = new TypeScript.IndexMemberDeclaration(indexSignature); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + var variableDeclarator = node.variableDeclarator.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + this.movePast(node.openBraceToken); + var switchClauses = this.visitSyntaxList(node.switchClauses); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseSwitchClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.DefaultSwitchClause(statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.BreakStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ContinueStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var initializer = node.initializer ? node.initializer.accept(this) : null; + + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var left = node.left ? node.left.accept(this) : null; + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.CastExpression(castTerm, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + var propertyName = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var expression = node.expression.accept(this); + expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); + + var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var propertyName = node.propertyName.accept(this); + var callSignature = this.visitCallSignature(node.callSignature); + var block = this.visitBlock(node.block); + + var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionExpression(name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.visitIdentifier(node.identifier); + var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + var start = this.position; + this.movePast(node.finallyKeyword); + var block = node.block.accept(this); + + var result = new TypeScript.FinallyClause(block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, whileKeyword, condition); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.TypeOfExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.DeleteExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.VoidExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + function applyDelta(ast, delta) { + if (ast) { + if (ast._start !== -1) { + ast._start += delta; + } + + if (ast._end !== -1) { + ast._end += delta; + } + } + } + + function applyDeltaToComments(comments, delta) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment, delta); + } + } + } + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var pre = function (cur) { + applyDelta(cur, delta); + applyDeltaToComments(cur.preComments(), delta); + applyDeltaToComments(cur.postComments(), delta); + + switch (cur.kind()) { + case 146 /* Block */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 226 /* ArgumentList */: + applyDelta(cur.closeParenToken, delta); + break; + + case 130 /* ModuleDeclaration */: + applyDelta(cur.endingToken, delta); + break; + + case 131 /* ClassDeclaration */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 161 /* DoStatement */: + applyDelta(cur.whileKeyword, delta); + break; + + case 151 /* SwitchStatement */: + applyDelta(cur.closeParenToken, delta); + break; + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span._start !== -1) { + var delta = start - span._start; + this.applyDelta(span, delta); + + span._end = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = element._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + element._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan(_start, _end) { + this._start = _start; + this._end = _end; + } + ASTSpan.prototype.start = function () { + return this._start; + }; + + ASTSpan.prototype.end = function () { + return this._end; + }; + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, false); + } + + function commentStructuralEqualsIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, true); + } + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); + } + + function commentStructuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + function commentArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.parent = null; + this._start = -1; + this._end = -1; + this._trailingTriviaWidth = 0; + this._astID = astID++; + this._preComments = null; + this._postComments = null; + } + AST.prototype.syntaxID = function () { + return this._astID; + }; + + AST.prototype.start = function () { + return this._start; + }; + + AST.prototype.end = function () { + return this._end; + }; + + AST.prototype.trailingTriviaWidth = function () { + return this._trailingTriviaWidth; + }; + + AST.prototype.fileName = function () { + return this.parent.fileName(); + }; + + AST.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.width = function () { + return this.end() - this.start(); + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + + AST.prototype.isExpression = function () { + return false; + }; + return AST; + })(); + TypeScript.AST = AST; + + var ISyntaxList2 = (function (_super) { + __extends(ISyntaxList2, _super); + function ISyntaxList2(_fileName, members) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISyntaxList2.prototype.childCount = function () { + return this.members.length; + }; + + ISyntaxList2.prototype.childAt = function (index) { + return this.members[index]; + }; + + ISyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISyntaxList2.prototype.kind = function () { + return 1 /* List */; + }; + + ISyntaxList2.prototype.firstOrDefault = function (func) { + return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.lastOrDefault = function (func) { + return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.any = function (func) { + return TypeScript.ArrayUtilities.any(this.members, func); + }; + + ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISyntaxList2; + })(AST); + TypeScript.ISyntaxList2 = ISyntaxList2; + + var ISeparatedSyntaxList2 = (function (_super) { + __extends(ISeparatedSyntaxList2, _super); + function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + this._separatorCount = _separatorCount; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { + return this.members.length; + }; + + ISeparatedSyntaxList2.prototype.separatorCount = function () { + return this._separatorCount; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { + return this.members[index]; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i) === ast) { + return i; + } + } + + return -1; + }; + + ISeparatedSyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISeparatedSyntaxList2.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISeparatedSyntaxList2; + })(AST); + TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; + + var SourceUnit = (function (_super) { + __extends(SourceUnit, _super); + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { + _super.call(this); + this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; + this._fileName = _fileName; + moduleElements && (moduleElements.parent = this); + } + SourceUnit.prototype.fileName = function () { + return this._fileName; + }; + + SourceUnit.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return SourceUnit; + })(AST); + TypeScript.SourceUnit = SourceUnit; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(_text) { + _super.call(this); + this._text = _text; + this._valueText = null; + } + Identifier.prototype.text = function () { + return this._text; + }; + Identifier.prototype.valueText = function () { + if (!this._valueText) { + var text = this._text; + if (text === "__proto__") { + this._valueText = "#__proto__"; + } else { + this._valueText = TypeScript.Syntax.massageEscapes(text); + } + } + + return this._valueText; + }; + + Identifier.prototype.kind = function () { + return 11 /* IdentifierName */; + }; + + 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; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + LiteralExpression.prototype.text = function () { + return this._text; + }; + + LiteralExpression.prototype.valueText = function () { + return this._valueText; + }; + + LiteralExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + ThisExpression.prototype.text = function () { + return this._text; + }; + + ThisExpression.prototype.valueText = function () { + return this._valueText; + }; + + ThisExpression.prototype.kind = function () { + return 35 /* ThisKeyword */; + }; + + 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; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + SuperExpression.prototype.text = function () { + return this._text; + }; + + SuperExpression.prototype.valueText = function () { + return this._valueText; + }; + + SuperExpression.prototype.kind = function () { + return 50 /* SuperKeyword */; + }; + + 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; + + var NumericLiteral = (function (_super) { + __extends(NumericLiteral, _super); + function NumericLiteral(_value, _text, _valueText) { + _super.call(this); + this._value = _value; + this._text = _text; + this._valueText = _valueText; + } + NumericLiteral.prototype.text = function () { + return this._text; + }; + NumericLiteral.prototype.valueText = function () { + return this._valueText; + }; + NumericLiteral.prototype.value = function () { + return this._value; + }; + + NumericLiteral.prototype.kind = function () { + return 13 /* NumericLiteral */; + }; + + 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; + + var RegularExpressionLiteral = (function (_super) { + __extends(RegularExpressionLiteral, _super); + function RegularExpressionLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + RegularExpressionLiteral.prototype.text = function () { + return this._text; + }; + + RegularExpressionLiteral.prototype.valueText = function () { + return this._valueText; + }; + + RegularExpressionLiteral.prototype.kind = function () { + return 12 /* RegularExpressionLiteral */; + }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; + return RegularExpressionLiteral; + })(AST); + TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + StringLiteral.prototype.valueText = function () { + return this._valueText; + }; + + StringLiteral.prototype.kind = function () { + return 14 /* StringLiteral */; + }; + + 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; + + var TypeAnnotation = (function (_super) { + __extends(TypeAnnotation, _super); + function TypeAnnotation(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + TypeAnnotation.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + return TypeAnnotation; + })(AST); + TypeScript.TypeAnnotation = TypeAnnotation; + + var BuiltInType = (function (_super) { + __extends(BuiltInType, _super); + function BuiltInType(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + BuiltInType.prototype.text = function () { + return this._text; + }; + + BuiltInType.prototype.valueText = function () { + return this._valueText; + }; + + BuiltInType.prototype.kind = function () { + return this._nodeType; + }; + return BuiltInType; + })(AST); + TypeScript.BuiltInType = BuiltInType; + + var ExternalModuleReference = (function (_super) { + __extends(ExternalModuleReference, _super); + function ExternalModuleReference(stringLiteral) { + _super.call(this); + this.stringLiteral = stringLiteral; + stringLiteral && (stringLiteral.parent = this); + } + ExternalModuleReference.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + return ExternalModuleReference; + })(AST); + TypeScript.ExternalModuleReference = ExternalModuleReference; + + var ModuleNameModuleReference = (function (_super) { + __extends(ModuleNameModuleReference, _super); + function ModuleNameModuleReference(moduleName) { + _super.call(this); + this.moduleName = moduleName; + moduleName && (moduleName.parent = this); + } + ModuleNameModuleReference.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + return ModuleNameModuleReference; + })(AST); + TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(modifiers, identifier, moduleReference) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.moduleReference = moduleReference; + identifier && (identifier.parent = this); + moduleReference && (moduleReference.parent = this); + } + ImportDeclaration.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(identifier) { + _super.call(this); + this.identifier = identifier; + identifier && (identifier.parent = this); + } + ExportAssignment.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var TypeParameterList = (function (_super) { + __extends(TypeParameterList, _super); + function TypeParameterList(typeParameters) { + _super.call(this); + this.typeParameters = typeParameters; + typeParameters && (typeParameters.parent = this); + } + TypeParameterList.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + return TypeParameterList; + })(AST); + TypeScript.TypeParameterList = TypeParameterList; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + heritageClauses && (heritageClauses.parent = this); + classElements && (classElements.parent = this); + } + ClassDeclaration.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return ClassDeclaration; + })(AST); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + body && (body.parent = this); + heritageClauses && (heritageClauses.parent = this); + } + InterfaceDeclaration.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return InterfaceDeclaration; + })(AST); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var HeritageClause = (function (_super) { + __extends(HeritageClause, _super); + function HeritageClause(_nodeType, typeNames) { + _super.call(this); + this._nodeType = _nodeType; + this.typeNames = typeNames; + typeNames && (typeNames.parent = this); + } + HeritageClause.prototype.kind = function () { + return this._nodeType; + }; + + HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); + }; + return HeritageClause; + })(AST); + TypeScript.HeritageClause = HeritageClause; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { + _super.call(this); + this.modifiers = modifiers; + this.name = name; + this.stringLiteral = stringLiteral; + this.moduleElements = moduleElements; + this.endingToken = endingToken; + name && (name.parent = this); + stringLiteral && (stringLiteral.parent = this); + moduleElements && (moduleElements.parent = this); + } + ModuleDeclaration.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(modifiers, identifier, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionDeclaration.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(modifiers, declaration) { + _super.call(this); + this.modifiers = modifiers; + this.declaration = declaration; + declaration && (declaration.parent = this); + } + VariableStatement.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + declarators && (declarators.parent = this); + } + VariableDeclaration.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + VariableDeclarator.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + return VariableDeclarator; + })(AST); + TypeScript.VariableDeclarator = VariableDeclarator; + + var EqualsValueClause = (function (_super) { + __extends(EqualsValueClause, _super); + function EqualsValueClause(value) { + _super.call(this); + this.value = value; + value && (value.parent = this); + } + EqualsValueClause.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + return EqualsValueClause; + })(AST); + TypeScript.EqualsValueClause = EqualsValueClause; + + var PrefixUnaryExpression = (function (_super) { + __extends(PrefixUnaryExpression, _super); + function PrefixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PrefixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ArrayLiteralExpression = (function (_super) { + __extends(ArrayLiteralExpression, _super); + function ArrayLiteralExpression(expressions) { + _super.call(this); + this.expressions = expressions; + expressions && (expressions.parent = this); + } + ArrayLiteralExpression.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + 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; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + 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; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(openParenTrailingComments, expression) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.expression = expression; + expression && (expression.parent = this); + } + ParenthesizedExpression.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + 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; + + var SimpleArrowFunctionExpression = (function (_super) { + __extends(SimpleArrowFunctionExpression, _super); + function SimpleArrowFunctionExpression(identifier, block, expression) { + _super.call(this); + this.identifier = identifier; + this.block = block; + this.expression = expression; + identifier && (identifier.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + SimpleArrowFunctionExpression.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return SimpleArrowFunctionExpression; + })(AST); + TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; + + var ParenthesizedArrowFunctionExpression = (function (_super) { + __extends(ParenthesizedArrowFunctionExpression, _super); + function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + this.expression = expression; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + ParenthesizedArrowFunctionExpression.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return ParenthesizedArrowFunctionExpression; + })(AST); + TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; + + var QualifiedName = (function (_super) { + __extends(QualifiedName, _super); + function QualifiedName(left, right) { + _super.call(this); + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + QualifiedName.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedName.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); + }; + return QualifiedName; + })(AST); + TypeScript.QualifiedName = QualifiedName; + + var ParameterList = (function (_super) { + __extends(ParameterList, _super); + function ParameterList(openParenTrailingComments, parameters) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.parameters = parameters; + parameters && (parameters.parent = this); + } + ParameterList.prototype.kind = function () { + return 227 /* ParameterList */; + }; + return ParameterList; + })(AST); + TypeScript.ParameterList = ParameterList; + + var ConstructorType = (function (_super) { + __extends(ConstructorType, _super); + function ConstructorType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + ConstructorType.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + return ConstructorType; + })(AST); + TypeScript.ConstructorType = ConstructorType; + + var FunctionType = (function (_super) { + __extends(FunctionType, _super); + function FunctionType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + FunctionType.prototype.kind = function () { + return 123 /* FunctionType */; + }; + return FunctionType; + })(AST); + TypeScript.FunctionType = FunctionType; + + var ObjectType = (function (_super) { + __extends(ObjectType, _super); + function ObjectType(typeMembers) { + _super.call(this); + this.typeMembers = typeMembers; + typeMembers && (typeMembers.parent = this); + } + ObjectType.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); + }; + return ObjectType; + })(AST); + TypeScript.ObjectType = ObjectType; + + var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + ArrayType.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); + }; + return ArrayType; + })(AST); + TypeScript.ArrayType = ArrayType; + + var TypeArgumentList = (function (_super) { + __extends(TypeArgumentList, _super); + function TypeArgumentList(typeArguments) { + _super.call(this); + this.typeArguments = typeArguments; + typeArguments && (typeArguments.parent = this); + } + TypeArgumentList.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + return TypeArgumentList; + })(AST); + TypeScript.TypeArgumentList = TypeArgumentList; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArgumentList) { + _super.call(this); + this.name = name; + this.typeArgumentList = typeArgumentList; + name && (name.parent = this); + typeArgumentList && (typeArgumentList.parent = this); + } + GenericType.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + name && (name.parent = this); + } + TypeQuery.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceLeadingComments, closeBraceToken) { + _super.call(this); + this.statements = statements; + this.closeBraceLeadingComments = closeBraceLeadingComments; + this.closeBraceToken = closeBraceToken; + statements && (statements.parent = this); + } + Block.prototype.kind = function () { + return 146 /* Block */; + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + _super.call(this); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + Parameter.prototype.kind = function () { + return 242 /* Parameter */; + }; + return Parameter; + })(AST); + TypeScript.Parameter = Parameter; + + var MemberAccessExpression = (function (_super) { + __extends(MemberAccessExpression, _super); + function MemberAccessExpression(expression, name) { + _super.call(this); + this.expression = expression; + this.name = name; + expression && (expression.parent = this); + name && (name.parent = this); + } + MemberAccessExpression.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + 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; + + var PostfixUnaryExpression = (function (_super) { + __extends(PostfixUnaryExpression, _super); + function PostfixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PostfixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ElementAccessExpression = (function (_super) { + __extends(ElementAccessExpression, _super); + function ElementAccessExpression(expression, argumentExpression) { + _super.call(this); + this.expression = expression; + this.argumentExpression = argumentExpression; + expression && (expression.parent = this); + argumentExpression && (argumentExpression.parent = this); + } + ElementAccessExpression.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + 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; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + InvocationExpression.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + 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) { + _super.call(this); + this.typeArgumentList = typeArgumentList; + this.closeParenToken = closeParenToken; + this.arguments = _arguments; + + typeArgumentList && (typeArgumentList.parent = this); + _arguments && (_arguments.parent = this); + } + ArgumentList.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + return ArgumentList; + })(AST); + TypeScript.ArgumentList = ArgumentList; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, left, right) { + _super.call(this); + this._nodeType = _nodeType; + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + BinaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(condition, whenTrue, whenFalse) { + _super.call(this); + this.condition = condition; + this.whenTrue = whenTrue; + this.whenFalse = whenFalse; + condition && (condition.parent = this); + whenTrue && (whenTrue.parent = this); + whenFalse && (whenFalse.parent = this); + } + ConditionalExpression.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + 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; + + var ConstructSignature = (function (_super) { + __extends(ConstructSignature, _super); + function ConstructSignature(callSignature) { + _super.call(this); + this.callSignature = callSignature; + callSignature && (callSignature.parent = this); + } + ConstructSignature.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + return ConstructSignature; + })(AST); + TypeScript.ConstructSignature = ConstructSignature; + + var MethodSignature = (function (_super) { + __extends(MethodSignature, _super); + function MethodSignature(propertyName, questionToken, callSignature) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + } + MethodSignature.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + return MethodSignature; + })(AST); + TypeScript.MethodSignature = MethodSignature; + + var IndexSignature = (function (_super) { + __extends(IndexSignature, _super); + function IndexSignature(parameter, typeAnnotation) { + _super.call(this); + this.parameter = parameter; + this.typeAnnotation = typeAnnotation; + parameter && (parameter.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + IndexSignature.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + return IndexSignature; + })(AST); + TypeScript.IndexSignature = IndexSignature; + + var PropertySignature = (function (_super) { + __extends(PropertySignature, _super); + function PropertySignature(propertyName, questionToken, typeAnnotation) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + PropertySignature.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + return PropertySignature; + })(AST); + TypeScript.PropertySignature = PropertySignature; + + var CallSignature = (function (_super) { + __extends(CallSignature, _super); + function CallSignature(typeParameterList, parameterList, typeAnnotation) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + CallSignature.prototype.kind = function () { + return 142 /* CallSignature */; + }; + return CallSignature; + })(AST); + TypeScript.CallSignature = CallSignature; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(identifier, constraint) { + _super.call(this); + this.identifier = identifier; + this.constraint = constraint; + identifier && (identifier.parent = this); + constraint && (constraint.parent = this); + } + TypeParameter.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + Constraint.prototype.kind = function () { + return 239 /* Constraint */; + }; + return Constraint; + })(AST); + TypeScript.Constraint = Constraint; + + var ElseClause = (function (_super) { + __extends(ElseClause, _super); + function ElseClause(statement) { + _super.call(this); + this.statement = statement; + statement && (statement.parent = this); + } + ElseClause.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ElseClause; + })(AST); + TypeScript.ElseClause = ElseClause; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(condition, statement, elseClause) { + _super.call(this); + this.condition = condition; + this.statement = statement; + this.elseClause = elseClause; + condition && (condition.parent = this); + statement && (statement.parent = this); + elseClause && (elseClause.parent = this); + } + IfStatement.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ExpressionStatement.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var ConstructorDeclaration = (function (_super) { + __extends(ConstructorDeclaration, _super); + function ConstructorDeclaration(callSignature, block) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + ConstructorDeclaration.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + return ConstructorDeclaration; + })(AST); + TypeScript.ConstructorDeclaration = ConstructorDeclaration; + + var MemberFunctionDeclaration = (function (_super) { + __extends(MemberFunctionDeclaration, _super); + function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + MemberFunctionDeclaration.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + return MemberFunctionDeclaration; + })(AST); + TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; + + var GetAccessor = (function (_super) { + __extends(GetAccessor, _super); + function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + GetAccessor.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + return GetAccessor; + })(AST); + TypeScript.GetAccessor = GetAccessor; + + var SetAccessor = (function (_super) { + __extends(SetAccessor, _super); + function SetAccessor(modifiers, propertyName, parameterList, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + block && (block.parent = this); + } + SetAccessor.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + return SetAccessor; + })(AST); + TypeScript.SetAccessor = SetAccessor; + + var MemberVariableDeclaration = (function (_super) { + __extends(MemberVariableDeclaration, _super); + function MemberVariableDeclaration(modifiers, variableDeclarator) { + _super.call(this); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + variableDeclarator && (variableDeclarator.parent = this); + } + MemberVariableDeclaration.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + return MemberVariableDeclaration; + })(AST); + TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; + + var IndexMemberDeclaration = (function (_super) { + __extends(IndexMemberDeclaration, _super); + function IndexMemberDeclaration(indexSignature) { + _super.call(this); + this.indexSignature = indexSignature; + indexSignature && (indexSignature.parent = this); + } + IndexMemberDeclaration.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + return IndexMemberDeclaration; + })(AST); + TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ThrowStatement.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ReturnStatement.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + ObjectCreationExpression.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + 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; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(expression, closeParenToken, switchClauses) { + _super.call(this); + this.expression = expression; + this.closeParenToken = closeParenToken; + this.switchClauses = switchClauses; + expression && (expression.parent = this); + switchClauses && (switchClauses.parent = this); + } + SwitchStatement.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseSwitchClause = (function (_super) { + __extends(CaseSwitchClause, _super); + function CaseSwitchClause(expression, statements) { + _super.call(this); + this.expression = expression; + this.statements = statements; + expression && (expression.parent = this); + statements && (statements.parent = this); + } + CaseSwitchClause.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return CaseSwitchClause; + })(AST); + TypeScript.CaseSwitchClause = CaseSwitchClause; + + var DefaultSwitchClause = (function (_super) { + __extends(DefaultSwitchClause, _super); + function DefaultSwitchClause(statements) { + _super.call(this); + this.statements = statements; + statements && (statements.parent = this); + } + DefaultSwitchClause.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return DefaultSwitchClause; + })(AST); + TypeScript.DefaultSwitchClause = DefaultSwitchClause; + + var BreakStatement = (function (_super) { + __extends(BreakStatement, _super); + function BreakStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + BreakStatement.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return BreakStatement; + })(AST); + TypeScript.BreakStatement = BreakStatement; + + var ContinueStatement = (function (_super) { + __extends(ContinueStatement, _super); + function ContinueStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + ContinueStatement.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ContinueStatement; + })(AST); + TypeScript.ContinueStatement = ContinueStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.condition = condition; + this.incrementor = incrementor; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + initializer && (initializer.parent = this); + condition && (condition.parent = this); + incrementor && (incrementor.parent = this); + statement && (statement.parent = this); + } + ForStatement.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(variableDeclaration, left, expression, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.left = left; + this.expression = expression; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + left && (left.parent = this); + expression && (expression.parent = this); + statement && (statement.parent = this); + } + ForInStatement.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WhileStatement.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WithStatement.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var EnumDeclaration = (function (_super) { + __extends(EnumDeclaration, _super); + function EnumDeclaration(modifiers, identifier, enumElements) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.enumElements = enumElements; + identifier && (identifier.parent = this); + enumElements && (enumElements.parent = this); + } + EnumDeclaration.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + return EnumDeclaration; + })(AST); + TypeScript.EnumDeclaration = EnumDeclaration; + + var EnumElement = (function (_super) { + __extends(EnumElement, _super); + function EnumElement(propertyName, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + EnumElement.prototype.kind = function () { + return 243 /* EnumElement */; + }; + return EnumElement; + })(AST); + TypeScript.EnumElement = EnumElement; + + var CastExpression = (function (_super) { + __extends(CastExpression, _super); + function CastExpression(type, expression) { + _super.call(this); + this.type = type; + this.expression = expression; + type && (type.parent = this); + expression && (expression.parent = this); + } + CastExpression.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + 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; + + var ObjectLiteralExpression = (function (_super) { + __extends(ObjectLiteralExpression, _super); + function ObjectLiteralExpression(propertyAssignments) { + _super.call(this); + this.propertyAssignments = propertyAssignments; + propertyAssignments && (propertyAssignments.parent = this); + } + ObjectLiteralExpression.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + 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; + + var SimplePropertyAssignment = (function (_super) { + __extends(SimplePropertyAssignment, _super); + function SimplePropertyAssignment(propertyName, expression) { + _super.call(this); + this.propertyName = propertyName; + this.expression = expression; + propertyName && (propertyName.parent = this); + expression && (expression.parent = this); + } + SimplePropertyAssignment.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + return SimplePropertyAssignment; + })(AST); + TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; + + var FunctionPropertyAssignment = (function (_super) { + __extends(FunctionPropertyAssignment, _super); + function FunctionPropertyAssignment(propertyName, callSignature, block) { + _super.call(this); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionPropertyAssignment.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + return FunctionPropertyAssignment; + })(AST); + TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; + + var FunctionExpression = (function (_super) { + __extends(FunctionExpression, _super); + function FunctionExpression(identifier, callSignature, block) { + _super.call(this); + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionExpression.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; + return FunctionExpression; + })(AST); + TypeScript.FunctionExpression = FunctionExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(block, catchClause, finallyClause) { + _super.call(this); + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + block && (block.parent = this); + catchClause && (catchClause.parent = this); + finallyClause && (finallyClause.parent = this); + } + TryStatement.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(identifier, typeAnnotation, block) { + _super.call(this); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.block = block; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + CatchClause.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var FinallyClause = (function (_super) { + __extends(FinallyClause, _super); + function FinallyClause(block) { + _super.call(this); + this.block = block; + block && (block.parent = this); + } + FinallyClause.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return FinallyClause; + })(AST); + TypeScript.FinallyClause = FinallyClause; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + identifier && (identifier.parent = this); + statement && (statement.parent = this); + } + LabeledStatement.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(statement, whileKeyword, condition) { + _super.call(this); + this.statement = statement; + this.whileKeyword = whileKeyword; + this.condition = condition; + statement && (statement.parent = this); + condition && (condition.parent = this); + } + DoStatement.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var TypeOfExpression = (function (_super) { + __extends(TypeOfExpression, _super); + function TypeOfExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + TypeOfExpression.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + 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; + + var DeleteExpression = (function (_super) { + __extends(DeleteExpression, _super); + function DeleteExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + DeleteExpression.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + 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; + + var VoidExpression = (function (_super) { + __extends(VoidExpression, _super); + function VoidExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + VoidExpression.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + 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; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var Comment = (function () { + function Comment(_trivia, endsLine, _start, _end) { + this._trivia = _trivia; + this.endsLine = endsLine; + this._start = _start; + this._end = _end; + } + Comment.prototype.start = function () { + return this._start; + }; + + Comment.prototype.end = function () { + return this._end; + }; + + Comment.prototype.fullText = function () { + return this._trivia.fullText(); + }; + + Comment.prototype.kind = function () { + return this._trivia.kind(); + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; + }; + return Comment; + })(); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); From fa06e1310ea2827a44740fc1b678c7d841442bb2 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 12 Feb 2014 12:21:40 +0900 Subject: [PATCH 135/240] Modified the version of TypeScript in test runner (0.9.7-59a846) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61c1dc6cdd..93f27fc421 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,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-59a846" } } From 4924c77584176c4515aeb11facd5074bed692921 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Tue, 11 Feb 2014 23:25:19 -0500 Subject: [PATCH 136/240] Fixed generics return value of Window and Buffer operators Generics values where incorrect. The correct result for windowWithXXX operators is Observable> and for bufferWithXXX it's Observable --- rx.js/rx.time.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rx.js/rx.time.d.ts b/rx.js/rx.time.d.ts index 1ee0d4f22f..013665517d 100644 --- a/rx.js/rx.time.d.ts +++ b/rx.js/rx.time.d.ts @@ -25,12 +25,12 @@ declare module Rx { delay(dueTime: number, scheduler?: IScheduler): Observable; throttle(dueTime: number, scheduler?: IScheduler): Observable; - windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; - windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable; - windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; - bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; - bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable; - bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; + windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable>; + windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable>; + windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable>; + bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable; + bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable; + bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable; timeInterval(scheduler?: IScheduler): Observable>; timestamp(scheduler?: IScheduler): Observable>; sample(interval: number, scheduler?: IScheduler): Observable; From dc8b0911bdb3aae953217b7acf2116d886bb9500 Mon Sep 17 00:00:00 2001 From: Matthew James Davis Date: Wed, 12 Feb 2014 21:08:59 +0900 Subject: [PATCH 137/240] Update to latest mapsjs definition file --- mapsjs/mapsjs.d.ts | 123 +++++++++++++++++++++++++++++++++------------ 1 file changed, 92 insertions(+), 31 deletions(-) diff --git a/mapsjs/mapsjs.d.ts b/mapsjs/mapsjs.d.ts index 29627eae92..2a8ed3f077 100644 --- a/mapsjs/mapsjs.d.ts +++ b/mapsjs/mapsjs.d.ts @@ -423,7 +423,7 @@ declare module 'mapsjs' { * @param {number} [idx] Index of the line for which to compute the distance. * @returns {number} Distance in meters of the line. */ - getActualDistance(idx: number): number; + getActualDistance(idx?: number): number; /** * Determines whether this polyline intersects a given geometry. @@ -504,7 +504,7 @@ declare module 'mapsjs' { * @param {number} [idx] Index of the ring for which to compute the area. * @returns {number} Area in square meters of the ring. */ - getActualArea(idx: number): number; + getActualArea(idx?: number): number; /** * Calculates perimeter of a ring in a polygon by index according @@ -513,7 +513,7 @@ declare module 'mapsjs' { * @param {number} [idx] Index of the ring for which to compute the perimeter. * @returns {number} Length in meters of the perimeter of the ring. */ - getActualPerimeter(idx: number): number; + getActualPerimeter(idx?: number): number; /** * Determines whether this polygon intersects a given geometry. @@ -543,7 +543,7 @@ declare module 'mapsjs' { * @class geometryStyle */ export class geometryStyle { - constructor(); + constructor(options?: styleObj); /** * Gets path outline thickness in pixels. @@ -894,8 +894,14 @@ declare module 'mapsjs' { * @class styledGeometry */ export class styledGeometry { - constructor(geom: geometry, gStyle: geometryStyle); + constructor(geom: geometry, gStyle?: geometryStyle); + /** + * Set this styledGeometry's geometry. + * @param {geometry} g A new Geometry. + */ + setGeometry(g: geometry): void; + /** * Set this styledGeometry's geometryStyle. * @param {geometryStyle} gs A new styledGeometry. @@ -907,6 +913,12 @@ declare module 'mapsjs' { * @returns {geometry} The underlying geometry. */ getGeometry(): geometry; + + /** + * Gets the styledGeometry's underlying geometryStyle object. + * @returns {geometryStyle} The underlying geometry style. + */ + getGeometryStyle(): geometryStyle; /** * Gets path outline thickness in pixels. @@ -928,7 +940,7 @@ declare module 'mapsjs' { /** * Gets path outline opacity in decimal format. - * @returns {number} Outline opacity. + * @param {number} Outline opacity. */ setOutlineColor(c: string): void; @@ -1317,6 +1329,11 @@ declare module 'mapsjs' { ulX: number; ulY: number; }; + + /** + * Unbind all associations with this tile layer to facilitate garbage collection + */ + dispose(): void; } /** @@ -2216,8 +2233,53 @@ declare module 'mapsjs' { * @returns {number} maxY coord as integer */ maxY: number; - } - + } + + interface extentChangeStatsObj { + + centerX: number; + centerY: number; + centerLat: number; + centerLon: number; + zoomLevel: number; + mapScale: number; + mapScaleProjected: number; + mapUnitsPerPixel: number; + extents: envelope; + } + + interface repositionStatsObj { + + centerX: number; + centerY: number; + zoomLevel: number; + mapUnitsPerPixel: number; + } + + interface beginDigitizeOptions { + key?: string; + shapeType: string; + geometryStyle?: geometryStyle; + styledGeometry?: styledGeometry; + nodeTapAndHoldAction?: (setIdx: number, idx: number) => boolean; + nodeMoveAction?: (x: number, y: number, actionType: string) => any; + shapeChangeAction?: () => void; + envelopeEndAction?: (env: envelope) => void; + circleEndAction?: (circle: geometry.polygon) => void; + suppressNodeAdd?: boolean; + leavePath?: boolean; + } + + + interface styleObj { + fillColor?: string; + fillOpacity?: number; + outlineColor?: string; + outlineOpacity?: number; + outlineThicknessPix?: number + dashArray?: string; + } + interface mapsjsWidget { /** @@ -2507,12 +2569,18 @@ declare module 'mapsjs' { * content area DOM. If an attempt to add a geometry is made with the same * key, the geometry is swapped out. You must remove using removePathGeometry * for resource cleanup. - * @param {styleGeometry} styledGeom THe styledGeometry to render. - * @param {string} key String used to tie a geometry to its SVG + * @param {styleGeometry} styledGeom The styledGeometry to render. + * @param {string} key String used to tie a geometry to its SVG + * @param {function} addAction optional function that is called when mapsjs adds an svg element to the DOM representing this styledGeometry. + * @param {function} removeAction optional function that is called when mapsjs adds an svg element to the DOM representing this styledGeometry. * rendering in the DOM. * @returns {element} The SVG element which was added to the DOM. */ - addPathGeometry(styledGeom: styledGeometry, key: string): void; + addPathGeometry( + styledGeom: styledGeometry, + key: string, + addAction?: (svg: SVGElement) => void, + removeAction?: (svg: SVGElement) => void): SVGElement; /** * Updates an existing path geometry to reflect a style change. @@ -2524,41 +2592,34 @@ declare module 'mapsjs' { /** * Removes a styledGeometry from display. * @param {string} key The key of the geometry to remove. + * @returns {element} The SVG element which was removed from the DOM. */ - removePathGeometry(key: string): void; + removePathGeometry(key?: string): SVGElement; /** * Initiates digitization on the map control. This creates a new * geometry and adds verticies to the geometry accord to mouse * click locations. * @param {object} options JavaScript object of the form { key, - * shapeType, geometryStyle, nodeTapAndHoldAction, nodeMoveAction, - * shapeChangeAction, envelopeEndAction, supressNodeAdd, leavePath } + * shapeType, geometryStyle, styledGeometry, nodeTapAndHoldAction, nodeMoveAction, + * shapeChangeAction, envelopeEndAction, circleEndAction, supressNodeAdd, leavePath } * where key is a a string associated with this geometry, shapeType - * is the type of shape this geometry is, one of 'point', 'path', or - * 'polygon', geometryStyle is a geometryStyle which should be applied - * to the digitized geometry, nodeTapAndHoldAction is a callback invoked + * is the type of shape this geometry is, one of 'polygon', 'polyline', 'multipoint', 'envelope' or 'circle', + * geometryStyle is a geometryStyle which should be applied + * to the digitized geometry, styledGeometry is an optional styledGeometry for existing paths to edit, set this to enter edit mode, + * nodeTapAndHoldAction is a callback invoked * when any point in the geometry is clicked and held and has the * signature nodeTapAndHoldAction(setIdx, idx), nodeMoveAction is a * callback invoked after any node is dragged to a new location and * has signature nodeMoveAction(x, y, actionType), shapeChangeAction * is a callback that is invoked after the geometry shape changes and, - * has signature shapeChangeAction(), envelopeEndAction is a callback + * has signature shapeChangeAction(shape), envelopeEndAction is a callback * invoked after an envelope is created and has signature envelopeEndAction(envelope), + * circleEndAction is similar to envelopeEndAction but takes a geometry.polygon representing the circle, * and leavePath is a flag that indicates whether the digitized shape * should be left on the map after digitization is complete. */ - beginDigitize(options: { - key?: string; - shapeType: string; - geometryStyle?: geometryStyle; - nodeTapAndHoldAction?: (setIdx: number, idx: number) => boolean; - nodeMoveAction?: (x: number, y: number, actionType: string) => any; - shapeChangeAction?: () => void; - envelopeEndAction?: (env: envelope) => void; - suppressNodeAdd?: boolean; - leavePath?: boolean; - }): void; + beginDigitize(options: beginDigitizeOptions): void; endDigitize(): void; /** @@ -2601,7 +2662,7 @@ declare module 'mapsjs' { * the form { centerX, centerY, centerLat, centerLon, zoomLevel, mapScale, * mapScaleProjected, mapUnitsPerPixel, extents }. */ - setExtentChangeCompleteAction(action: (vals: {}) => void): void; + setExtentChangeCompleteAction(action: (vals: extentChangeStatsObj) => void): void; /** * Set the function called when map content (map tiles and fixed elements) are @@ -2611,7 +2672,7 @@ declare module 'mapsjs' { * completes repositioning with signature action(object) where object * is of the form { centerX, centerY, zoomLevel, mapUnitsPerPixel }. */ - setContentRepositionAction(action: (vals: {}) => void): void; + setContentRepositionAction(action: (vals: repositionStatsObj) => void): void; /** * Sets function called when map is clicked or tapped. From 62f9fa8fdab21bcf8797fffb4f8bec81ba2c8ddd Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Wed, 12 Feb 2014 14:49:25 +0100 Subject: [PATCH 138/240] Adding angular $animate definition --- angularjs/angular-animate.d.ts | 21 +++++++++++++++++++++ angularjs/angular-tests.ts | 2 +- angularjs/angular.d.ts | 13 +++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 angularjs/angular-animate.d.ts diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts new file mode 100644 index 0000000000..696e6f8349 --- /dev/null +++ b/angularjs/angular-animate.d.ts @@ -0,0 +1,21 @@ +// Type definitions for Angular JS 1.2+ (ngAnimate module) +// Project: http://angularjs.org +// Definitions by: Michel Salib +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngAnimate module (angular-animate.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.animate { + + /////////////////////////////////////////////////////////////////////////// + // AnimateService + // see http://docs.angularjs.org/api/ngAnimate.$animate + /////////////////////////////////////////////////////////////////////////// + interface IAnimateService extends ng.IAnimateService { + enabled(value?: boolean, element?: JQuery): boolean; + } +} diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 18f5ccb4ee..4ce3116985 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -1,7 +1,7 @@ /// // issue: https://github.com/borisyankov/DefinitelyTyped/issues/369 -https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js +// https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js /** * @license HTTP Auth Interceptor Module for AngularJS * (c) 2012 Witold Szczerba diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index a8c1d991dd..3a8bca7a04 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -799,10 +799,19 @@ declare module ng { inheritedData(key: string, value: any): JQuery; inheritedData(obj: { [key: string]: any; }): JQuery; inheritedData(key?: string): any; - - } + /////////////////////////////////////////////////////////////////////// + // AnimateService + // see http://docs.angularjs.org/api/ng.$animate + /////////////////////////////////////////////////////////////////////// + interface IAnimateService { + addClass(element: JQuery, className: string, done?: Function); + enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function); + leave(element: JQuery, done?: Function); + move(element: JQuery, parent: JQuery, after: JQuery, done?: Function); + removeClass(element: JQuery, className: string, done?: Function); + } /////////////////////////////////////////////////////////////////////////// // AUTO module (angular.js) From 59263e826bfa09aa97b9cfd9624094801965cb8b Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Wed, 12 Feb 2014 15:55:41 +0100 Subject: [PATCH 139/240] Add missing return types --- angularjs/angular.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 3a8bca7a04..0fee898409 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -806,11 +806,11 @@ declare module ng { // see http://docs.angularjs.org/api/ng.$animate /////////////////////////////////////////////////////////////////////// interface IAnimateService { - addClass(element: JQuery, className: string, done?: Function); - enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function); - leave(element: JQuery, done?: Function); - move(element: JQuery, parent: JQuery, after: JQuery, done?: Function); - removeClass(element: JQuery, className: string, done?: Function); + addClass(element: JQuery, className: string, done?: Function): void; + enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + leave(element: JQuery, done?: Function): void; + move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + removeClass(element: JQuery, className: string, done?: Function): void; } /////////////////////////////////////////////////////////////////////////// From 5a9a727fa1ebba95f678d6e725bb552c5b143a4d Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 12 Feb 2014 16:04:30 +0000 Subject: [PATCH 140/240] jQuery: removed redundant interface --- jquery/jquery.d.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 0d26a82533..ea9d327f99 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -485,14 +485,6 @@ interface JQueryAnimationOptions { specialEasing?: Object; } -/** - * The interface used to specify easing functions. - */ -interface JQueryEasing { - linear(p: number): number; - swing(p: number): number; -} - /** * Static members of jQuery (those on $ and jQuery themselves) */ From b3fa44db17b4f7db21177df73f5ac445194d72f9 Mon Sep 17 00:00:00 2001 From: Sven Date: Wed, 12 Feb 2014 21:55:43 +0100 Subject: [PATCH 141/240] Added closeRegions to Marionette.Application --- marionette/marionette.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index dca2915c53..75bae47f22 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -288,6 +288,7 @@ declare module Marionette { addInitializer(initializer); start(options?); addRegions(regions); + closeRegions(): void; removeRegion(region: Region); getRegion(regionName: string): Region; module(moduleNames, moduleDefinition); From 6667394125c2d14fa67dc57492aaae0a6bf54db9 Mon Sep 17 00:00:00 2001 From: Sven Date: Wed, 12 Feb 2014 22:11:31 +0100 Subject: [PATCH 142/240] Improvment on AppRouter Added appRoute to Marionette.AppRouter Removed Controller type on processAppRoutes controller arg Added AppRouterOptions --- marionette/marionette.d.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 75bae47f22..6c18b8906d 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -269,11 +269,18 @@ declare module Marionette { render(): Layout; removeRegion(name: string); } + + interface AppRouterOptions extends Backbone.RouterOptions { + appRoutes: any; + controller: any; + } class AppRouter extends Backbone.Router { - constructor(options?: any); - processAppRoutes(controller: Controller, appRoutes: any); + constructor(options?: AppRouterOptions); + processAppRoutes(controller: any, appRoutes: any); + appRoute(route:string, methodName:string):void; + } class Application extends Backbone.Events { From e496efed374d76c60d5585f3e1a7d7a01396a9c4 Mon Sep 17 00:00:00 2001 From: Sven Date: Wed, 12 Feb 2014 22:22:50 +0100 Subject: [PATCH 143/240] Typed callback arg to Marionette.Callbacks.add as a Function --- marionette/marionette.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 6c18b8906d..3427d6de4e 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -112,8 +112,8 @@ declare module Marionette { function unbindEntityEvents(target, entity, bindings); class Callbacks { - add(callback, contextOverride): void; - run(options, context): void; + add(callback:Function, contextOverride:any): void; + run(options:any, context:any): void; reset(): void; } From 2bd68070e93979c115f4d906838cdea8084cc7ce Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 13 Feb 2014 09:14:40 +0000 Subject: [PATCH 144/240] jQuery: added cr to retrigger CI build --- jquery/jquery.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index ea9d327f99..bc7886e448 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -18,6 +18,7 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + /** * Interface for the AJAX setting that will configure the AJAX request */ From 1cbc6388ea0813c2d5e2fa8847975fbcd289ae0c Mon Sep 17 00:00:00 2001 From: scottmcarthur Date: Thu, 13 Feb 2014 09:47:35 +0000 Subject: [PATCH 145/240] Resolves KeyCode - Type reference cannot refer to a property The interface of the property `$.ui.keyCode` uses a non-standard name `keyCode` which clashes with the property name, giving error `Type reference cannot refer to a property`. Changing the interface name from `keyCode` to `KeyCode` follows the interface naming convention and resolves this issue. --- jqueryui/jqueryui.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 3a1823a920..41cc3214df 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -714,7 +714,7 @@ declare module JQueryUI { distance?: number; } - interface keyCode { + interface KeyCode { BACKSPACE: number; COMMA: number; DELETE: number; @@ -751,7 +751,7 @@ declare module JQueryUI { buttonset: Button; datepicker: Datepicker; dialog: Dialog; - keyCode: keyCode; + keyCode: KeyCode; menu: Menu; progressbar: Progressbar; slider: Slider; From 7699097b96225ac9d607d115b113cd5119e3f567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20B=C3=BChler?= Date: Thu, 13 Feb 2014 16:47:29 +0100 Subject: [PATCH 146/240] Added definitions for doT (https://github.com/olado/doT) --- README.md | 1 + dot/dot-tests.ts | 32 +++++++++++++++++++++++++++++++ dot/dot.d.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 dot/dot-tests.ts create mode 100644 dot/dot.d.ts diff --git a/README.md b/README.md index 2512630105..157d9ab302 100755 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ List of Definitions * [dhtmlxScheduler](http://dhtmlx.com/docs/products/dhtmlxScheduler) (by [Maksim Kozhukh](http://github.com/mkozhukh)) * [docCookies](https://developer.mozilla.org/en-US/docs/Web/API/document.cookie) (by [Jon Egerton](https://github.com/jonegerton)) * [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) +* [doT](https://github.com/olado/doT) (by [ZombieHunter](https://github.com/ZombieHunter)) * [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) diff --git a/dot/dot-tests.ts b/dot/dot-tests.ts new file mode 100644 index 0000000000..59e6cff759 --- /dev/null +++ b/dot/dot-tests.ts @@ -0,0 +1,32 @@ +/// + +var headertmpl = "

{{=it.title}}

"; + +var pagetmpl = "

Here is the page using a header template< / h2 >\n" + + "{{#def.header}}\n" + + "{{=it.name}}"; + +var customizableheadertmpl = "{{#def.header}}" + + "\n{{#def.mycustominjectionintoheader || ''} }"; + +var pagetmplwithcustomizableheader = "

Here is the page with customized header template

\n" + + "{{##def.mycustominjectionintoheader:\n" + + "
{{=it.title}} is not {{=it.name}}
\n" + + "#}}\n" + + "{{#def.customheader}}\n" + + "{{=it.name}}"; + +var def = { + header: headertmpl, + customheader: customizableheadertmpl +}; +var data = { + title: "My title", + name: "My name" +}; + +var pagefn = doT.template(pagetmpl, undefined, def); +var content = pagefn(data); + +pagefn = doT.template(pagetmplwithcustomizableheader, undefined, def); +var contentcustom = pagefn(data); diff --git a/dot/dot.d.ts b/dot/dot.d.ts new file mode 100644 index 0000000000..2ab677c26d --- /dev/null +++ b/dot/dot.d.ts @@ -0,0 +1,50 @@ +// Type definitions for doT v1.0.1 +// Project: https://github.com/olado/doT +// Definitions by: ZombieHunter +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var doT: doT.doTStatic; + +declare module doT { + + interface doTStatic { + /** + * Version number + */ + version: string; + /** + * Default template settings + */ + templateSettings: TemplateSettings; + + /** + * Compile template + */ + template(tmpl: string, c?: TemplateSettings, def?: Object): Function; + + /** + * For express + */ + compile(tmpl: string, def?: Object): Function; + } + + interface TemplateSettings { + evaluate: RegExp; + interpolate: RegExp; + encode: RegExp; + use: RegExp; + useParams: RegExp; + define: RegExp; + defineParams: RegExp; + conditional: RegExp; + iterate: RegExp; + varname: string; + strip: boolean; + append: boolean; + selfcontained: boolean; + } +} + +interface String { + encodeHTML(): string; +} \ No newline at end of file From 72997bd71995c635447ff809f285feb26b2c5ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Farzat?= Date: Thu, 13 Feb 2014 17:43:48 -0200 Subject: [PATCH 147/240] Fixing Set interface method from 'Add' to 'add' --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index ec3f94147c..4bce47e2b3 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -847,7 +847,7 @@ declare module D3 { export interface Set{ has(value: any): boolean; - Add(value: any): any; + add(value: any): any; remove(value: any): boolean; values(): Array; forEach(func: (value: any) => void ): void; From 68ebedc9b7f7e8a00e147cad00a8f91518fba26d Mon Sep 17 00:00:00 2001 From: Michel Salib Date: Fri, 14 Feb 2014 15:42:11 +0100 Subject: [PATCH 148/240] Add more flexibility sugar.js calls Add some optional parameters ad return types. --- sugar/sugar.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index ca21b3e7c2..e5f9c97d7b 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -2133,7 +2133,7 @@ interface Array { * }, 2, true); **/ each( - fn: (element: T, index: number, array: T[]) => boolean, + fn: (element: T, index?: number, array?: T[]) => any, index?: number, loop?: boolean): T[]; @@ -3386,7 +3386,7 @@ interface ObjectStatic { * }); * **/ - watch(obj: any, prop: string, fn: (prop: string, oldVal: any, newVal: any) => any): void; + watch(obj: any, prop: string, fn: (prop?: string, oldVal?: any, newVal?: any) => any): void; } interface Object { @@ -3836,7 +3836,7 @@ interface Object { * }); * **/ - watch(prop: string, fn: (prop: string, oldVal: any, newVal: any) => any): void; + watch(prop: string, fn: (prop?: string, oldVal?: any, newVal?: any) => any): void; } interface Function { From 122ff1fb4c1551da6fd522cdaa42b9548ae29913 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 14 Feb 2014 16:36:27 +0000 Subject: [PATCH 149/240] jQuery: trigger now JSDoc'd and typings brought in line with documentation. Also added test suite. --- jquery/jquery-tests.ts | 55 ++++++++++++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 30 +++++++++++++++++++++-- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index c3fc3032f3..a6249b9f37 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -754,6 +754,61 @@ function test_submit() { $("#target").submit(); } +function test_trigger() { + + $("#foo").on("click", function () { + alert($(this).text()); + }); + $("#foo").trigger("click"); + + //$("#foo").on("custom", function (event, param1, param2) { + // alert(param1 + "\n" + param2); + //}); + $("#foo").trigger("custom", ["Custom", "Event"]); + + $("button:first").click(function () { + update($("span:first")); + }); + + $("button:last").click(function () { + $("button:first").trigger("click"); + update($("span:last")); + }); + + function update(j) { + var n = parseInt(j.text(), 10); + j.text(n + 1); + } + + $("form:first").trigger("submit"); + + var event = jQuery.Event("submit"); + $("form:first").trigger(event); + if (event.isDefaultPrevented()) { + // Perform an action... + } + + $("p") + .click(function (event, a, b) { + // When a normal click fires, a and b are undefined + // for a trigger like below a refers to "foo" and b refers to "bar" + }) + .trigger("click", ["foo", "bar"]); + + var event = jQuery.Event("logged"); + (event).user = "foo"; + (event).pass = "bar"; + $("body").trigger(event); + + // Adapted from jQuery documentation which may be wrong on this occasion + var event2 = jQuery.Event("logged"); + $("body").trigger(event2, { + type: "logged", + user: "foo", + pass: "bar" + }); +} + function test_clone() { $('.hello').clone().appendTo('.goodbye'); var $elem = $('#elem').data({ "arr": [1] }), diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index bc7886e448..235022bf99 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2531,8 +2531,34 @@ interface JQuery { */ submit(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; - trigger(eventType: string, ...extraParameters: any[]): JQuery; - trigger(event: JQueryEventObject): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(eventType: string, extraParameters?: any[]): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(eventType: string, extraParameters?: Object): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param event A jQuery.Event object. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(event: JQueryEventObject, extraParameters?: any[]): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param event A jQuery.Event object. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(event: JQueryEventObject, extraParameters?: Object): JQuery; triggerHandler(eventType: string, ...extraParameters: any[]): Object; From fede925bfecb64ed78eb77406c17a226584aa6da Mon Sep 17 00:00:00 2001 From: timbow574521 Date: Fri, 14 Feb 2014 11:43:13 -0500 Subject: [PATCH 150/240] Add getValue in DataTable in google.visualization.d.ts. --- google.visualization/google.visualization.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts index d478cf9aa6..553c8e6549 100644 --- a/google.visualization/google.visualization.d.ts +++ b/google.visualization/google.visualization.d.ts @@ -76,6 +76,7 @@ declare module google { addRows(array: any[]): number; getFilteredRows(filters: DataTableCellFilter[]): number[]; getFormattedValue(rowIndex: number, columnIndex: number): string; + getValue(rowIndex: number, columnIndex: number): any; getNumberOfColumns(): number; getNumberOfRows(): number; removeRow(rowIndex: number): void; From 4c2d50af485fbe47178284ed7291fa4c57110e3c Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 14 Feb 2014 16:48:11 +0000 Subject: [PATCH 151/240] jQuery: uncommented tests realised they could be used as long as param1 and param2 made optional --- jquery/jquery-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index a6249b9f37..57ba838ee3 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -761,9 +761,9 @@ function test_trigger() { }); $("#foo").trigger("click"); - //$("#foo").on("custom", function (event, param1, param2) { - // alert(param1 + "\n" + param2); - //}); + $("#foo").on("custom", function (event, param1?, param2?) { + alert(param1 + "\n" + param2); + }); $("#foo").trigger("custom", ["Custom", "Event"]); $("button:first").click(function () { From 18c992059db0e1bbabb2c81a407490ccd531fd0a Mon Sep 17 00:00:00 2001 From: vagrant Date: Fri, 14 Feb 2014 16:52:45 +0000 Subject: [PATCH 152/240] add missing export function basicAuth(callback: (user: string, pass: string) => boolean, realm?: string): Handler; --- express/express.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/express/express.d.ts b/express/express.d.ts index b97888998f..6d87249cdc 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -1451,6 +1451,8 @@ declare module "express" { * @param callback or username * @param realm */ + export function basicAuth(callback: (user: string, pass: string, fn : Function) => void, realm?: string): Handler; + export function basicAuth(callback: (user: string, pass: string) => boolean, realm?: string): Handler; export function basicAuth(user: string, pass: string, realm?: string): Handler; From 1195fc6b5eb88872af95850521ea54babac2407c Mon Sep 17 00:00:00 2001 From: scottmcarthur Date: Sat, 15 Feb 2014 09:06:02 +0000 Subject: [PATCH 153/240] Added $promise & $resolved properties [ngResource.$resource](http://docs.angularjs.org/api/ngResource.$resource) defines a `$promise` property and a `$resolve` property on the Resource. --- angularjs/angular-resource.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index eebed96c30..c26bc9fe82 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -105,6 +105,10 @@ declare module ng.resource { $delete(dataOrParams: any, success: Function): T; $delete(success: Function, error?: Function): T; $delete(params: any, data: any, success?: Function, error?: Function): T; + + /** the promise of the original server interaction that created this instance. **/ + $promise : ng.IPromise; + $resolved : boolean; } /** when creating a resource factory via IModule.factory */ @@ -122,3 +126,10 @@ declare module ng { factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; } } + +interface Array> +{ + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise>; + $resolved : boolean; +} From 4d64913cdbf438a6ab8cdf812c4e75cfae1ccf7b Mon Sep 17 00:00:00 2001 From: Scott McArthur Date: Sat, 15 Feb 2014 20:37:05 +0000 Subject: [PATCH 154/240] angular.d.ts Annotated spelt incorrectly Fixed spelling mistake in parameter names. Changed all occurrences of `Annotaded` to `Annotated` --- angularjs/angular.d.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index a8c1d991dd..a2a335d0ff 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -79,7 +79,7 @@ declare module ng { /////////////////////////////////////////////////////////////////////////// interface IModule { animation(name: string, animationFactory: Function): IModule; - animation(name: string, inlineAnnotadedFunction: any[]): IModule; + animation(name: string, inlineAnnotatedFunction: any[]): IModule; animation(object: Object): IModule; /** configure existing services. Use this method to register work which needs to be performed on module loading @@ -88,29 +88,29 @@ declare module ng { /** configure existing services. Use this method to register work which needs to be performed on module loading */ - config(inlineAnnotadedFunction: any[]): IModule; + config(inlineAnnotatedFunction: any[]): IModule; constant(name: string, value: any): IModule; constant(object: Object): IModule; controller(name: string, controllerConstructor: Function): IModule; - controller(name: string, inlineAnnotadedConstructor: any[]): IModule; + controller(name: string, inlineAnnotatedConstructor: any[]): IModule; controller(object : Object): IModule; directive(name: string, directiveFactory: Function): IModule; - directive(name: string, inlineAnnotadedFunction: any[]): IModule; + directive(name: string, inlineAnnotatedFunction: any[]): IModule; directive(object: Object): IModule; factory(name: string, serviceFactoryFunction: Function): IModule; - factory(name: string, inlineAnnotadedFunction: any[]): IModule; + factory(name: string, inlineAnnotatedFunction: any[]): IModule; factory(object: Object): IModule; filter(name: string, filterFactoryFunction: Function): IModule; - filter(name: string, inlineAnnotadedFunction: any[]): IModule; + filter(name: string, inlineAnnotatedFunction: any[]): IModule; filter(object: Object): IModule; provider(name: string, serviceProviderConstructor: Function): IModule; - provider(name: string, inlineAnnotadedConstructor: any[]): IModule; + provider(name: string, inlineAnnotatedConstructor: any[]): IModule; provider(name: string, providerObject: auto.IProvider): IModule; provider(object: Object): IModule; run(initializationFunction: Function): IModule; - run(inlineAnnotadedFunction: any[]): IModule; + run(inlineAnnotatedFunction: any[]): IModule; service(name: string, serviceConstructor: Function): IModule; - service(name: string, inlineAnnotadedConstructor: any[]): IModule; + service(name: string, inlineAnnotatedConstructor: any[]): IModule; service(object: Object): IModule; value(name: string, value: any): IModule; value(object: Object): IModule; @@ -570,7 +570,7 @@ declare module ng { interface IControllerProvider extends IServiceProvider { register(name: string, controllerConstructor: Function): void; - register(name: string, dependencyAnnotadedConstructor: any[]): void; + register(name: string, dependencyAnnotatedConstructor: any[]): void; } /////////////////////////////////////////////////////////////////////////// @@ -818,11 +818,11 @@ declare module ng { /////////////////////////////////////////////////////////////////////// interface IInjectorService { annotate(fn: Function): string[]; - annotate(inlineAnnotadedFunction: any[]): string[]; + annotate(inlineAnnotatedFunction: any[]): string[]; get(name: string): any; has(name: string): boolean; instantiate(typeConstructor: Function, locals?: any): any; - invoke(inlineAnnotadedFunction: any[]): any; + invoke(inlineAnnotatedFunction: any[]): any; invoke(func: Function, context?: any, locals?: any): any; } @@ -839,7 +839,7 @@ declare module ng { decorator(name: string, decorator: Function): void; decorator(name: string, decoratorInline: any[]): void; factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider; - factory(name: string, inlineAnnotadedFunction: any[]): ng.IServiceProvider; + factory(name: string, inlineAnnotatedFunction: any[]): ng.IServiceProvider; provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider; provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider; service(name: string, constructor: Function): ng.IServiceProvider; From f300bab55704471a4eefeb2288164a9af58f7e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?De=CC=81nes=20Harmath?= Date: Sat, 15 Feb 2014 21:54:35 +0100 Subject: [PATCH 155/240] Add header & tests --- angularfire/angularfire-tests.ts | 79 ++++++++++++++++++++++++++++++++ angularfire/angularfire.d.ts | 5 ++ 2 files changed, 84 insertions(+) create mode 100644 angularfire/angularfire-tests.ts diff --git a/angularfire/angularfire-tests.ts b/angularfire/angularfire-tests.ts new file mode 100644 index 0000000000..6722527299 --- /dev/null +++ b/angularfire/angularfire-tests.ts @@ -0,0 +1,79 @@ +/// + +// Based on https://www.firebase.com/docs/angular/index.html + +var myapp = angular.module("myapp", ["firebase"]); + +interface AngularFireScope { + items: AngularFire; +} + +myapp.controller("MyController", ["$scope", "$firebase", + function($scope: AngularFireScope, $firebase: AngularFireService) { + $scope.items = $firebase(new Firebase(URL)); + $scope.items.$add({ foo: "bar" }); + $scope.items.$remove("foo"); // Removes child named "foo". + $scope.items.$remove(); // Removes the entire object. + $scope.items.foo = "baz"; + $scope.items.$save("foo"); // new Firebase(URL + "/foo") now contains "baz". + var child = $scope.items.$child("foo"); + child.$remove(); // Same as calling $scope.items.$remove("foo"); + $scope.items.$set({ bar: "baz" }); // new Firebase(URL + "/foo") is now null. + var keys = $scope.items.$getIndex(); + keys.forEach(function(key, i) { + console.log(i, $scope.items[key]); // prints items in order they appear in Firebase + }); + $scope.items.foo.$priority = 20; + $scope.items.$save("foo"); // new Firebase(URL + "foo")'s priority is now 20. + $scope.items.$on("loaded", function() { + console.log("Initial data received!"); + }); + $scope.items.$on("change", function() { + console.log("A remote change was applied locally!"); + }); + // Detaches all `loaded` event handlers. + $scope.items.$off('loaded'); + // Stops synchronization on `$scope.items` completely. + function stopSync() { + $scope.items.$off(); + } + $scope.items.$bind($scope, "remoteItems"); + $scope.remoteItems.bar = "foo"; // new Firebase(URL + "/bar") is now "foo". + $scope.items.$bind($scope, "remote").then(function(unbind) { + unbind(); + $scope.remote.bar = "foo"; // No changes have been made to the remote data. + }); + } +]); + +interface AngularFireAuthScope { + loginObj: AngularFireAuth; +} + +myapp.controller("MyAuthController", ["$scope", "$firebaseSimpleLogin", + function($scope: AngularFireAuthScope, $firebaseSimpleLogin) { + var dataRef = new Firebase("https://myapp.firebaseio.com"); + $scope.loginObj = $firebaseSimpleLogin(dataRef); + $scope.loginObj.$getCurrentUser().then(_ => { + }); + var email = 'my@email.com'; + var password = 'mypassword'; + $scope.loginObj.$login('password', { + email: email, + password: password + }).then(function(user) { + console.log('Logged in as: ', user.uid); + }, function(error) { + console.error('Login failed: ', error); + }); + $scope.loginObj.$logout(); + $scope.loginObj.$createUser(email, password).then(_ => { + }); + $scope.loginObj.$changePassword(email, password, password).then(_ => { + }); + $scope.loginObj.$removeUser(email, password).then(_ => { + }); + $scope.loginObj.$sendPasswordResetEmail(email).then(_ => { + }); + } +]); \ No newline at end of file diff --git a/angularfire/angularfire.d.ts b/angularfire/angularfire.d.ts index 3cb409fd02..25f44332cb 100644 --- a/angularfire/angularfire.d.ts +++ b/angularfire/angularfire.d.ts @@ -1,3 +1,8 @@ +// Type definitions for AngularFire 0.6.0 +// Project: http://angularfire.com +// Definitions by: Dénes Harmath +// Definitions: https://github.com/borisyankov/DefinitelyTyped + interface AngularFireService { (firebase: Firebase): AngularFire; } From 4238c803afcb92b1a17fb3c6b9bf0de6fb7ec1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?De=CC=81nes=20Harmath?= Date: Sat, 15 Feb 2014 23:53:59 +0100 Subject: [PATCH 156/240] Fix compile errors --- angularfire/angularfire-tests.ts | 44 +++++++++++++++++--------------- angularfire/angularfire.d.ts | 12 ++++++--- firebase/firebase.d.ts | 2 +- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/angularfire/angularfire-tests.ts b/angularfire/angularfire-tests.ts index 6722527299..e3a04712c3 100644 --- a/angularfire/angularfire-tests.ts +++ b/angularfire/angularfire-tests.ts @@ -1,58 +1,62 @@ /// -// Based on https://www.firebase.com/docs/angular/index.html - var myapp = angular.module("myapp", ["firebase"]); -interface AngularFireScope { +interface AngularFireScope extends ng.IScope { items: AngularFire; + remoteItems: RemoteItems; } +interface RemoteItems { + bar: string; +} + +var url = "https://myapp.firebaseio.com"; + myapp.controller("MyController", ["$scope", "$firebase", function($scope: AngularFireScope, $firebase: AngularFireService) { - $scope.items = $firebase(new Firebase(URL)); + $scope.items = $firebase(new Firebase(url)); $scope.items.$add({ foo: "bar" }); - $scope.items.$remove("foo"); // Removes child named "foo". - $scope.items.$remove(); // Removes the entire object. - $scope.items.foo = "baz"; - $scope.items.$save("foo"); // new Firebase(URL + "/foo") now contains "baz". + $scope.items.$remove("foo"); + $scope.items.$remove(); + $scope.items.$save(); var child = $scope.items.$child("foo"); - child.$remove(); // Same as calling $scope.items.$remove("foo"); - $scope.items.$set({ bar: "baz" }); // new Firebase(URL + "/foo") is now null. + child.$remove(); + $scope.items.$set({ bar: "baz" }); var keys = $scope.items.$getIndex(); keys.forEach(function(key, i) { - console.log(i, $scope.items[key]); // prints items in order they appear in Firebase + console.log(i, $scope.items[key]); }); - $scope.items.foo.$priority = 20; - $scope.items.$save("foo"); // new Firebase(URL + "foo")'s priority is now 20. $scope.items.$on("loaded", function() { console.log("Initial data received!"); }); $scope.items.$on("change", function() { console.log("A remote change was applied locally!"); }); - // Detaches all `loaded` event handlers. $scope.items.$off('loaded'); - // Stops synchronization on `$scope.items` completely. function stopSync() { $scope.items.$off(); } $scope.items.$bind($scope, "remoteItems"); - $scope.remoteItems.bar = "foo"; // new Firebase(URL + "/bar") is now "foo". + $scope.remoteItems.bar = "foo"; $scope.items.$bind($scope, "remote").then(function(unbind) { unbind(); - $scope.remote.bar = "foo"; // No changes have been made to the remote data. + $scope.remoteItems.bar = "foo"; }); } ]); -interface AngularFireAuthScope { +var foo: AngularFireObject = { + $priority: 0 +}; + +interface AngularFireAuthScope extends ng.IScope { loginObj: AngularFireAuth; } myapp.controller("MyAuthController", ["$scope", "$firebaseSimpleLogin", - function($scope: AngularFireAuthScope, $firebaseSimpleLogin) { - var dataRef = new Firebase("https://myapp.firebaseio.com"); + function($scope: AngularFireAuthScope, $firebaseSimpleLogin: AngularFireAuthService) { + var dataRef = new Firebase(url); $scope.loginObj = $firebaseSimpleLogin(dataRef); $scope.loginObj.$getCurrentUser().then(_ => { }); diff --git a/angularfire/angularfire.d.ts b/angularfire/angularfire.d.ts index 25f44332cb..3f2b0aa106 100644 --- a/angularfire/angularfire.d.ts +++ b/angularfire/angularfire.d.ts @@ -3,6 +3,9 @@ // Definitions by: Dénes Harmath // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// +/// + interface AngularFireService { (firebase: Firebase): AngularFire; } @@ -13,13 +16,16 @@ interface AngularFire { $save(key?: string): void; $child(key: string): AngularFire; $set(value: any): void; - $getIndex(): number; - $priority: number; + $getIndex(): string[]; $on(eventType: string, callback: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void; - $off(eventType: string, callback: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void; + $off(eventType?: string, callback?: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void; $bind($scope: ng.IScope, modelName: string): ng.IPromise; } +interface AngularFireObject { + $priority: number; +} + interface AngularFireAuthService { (firebase: Firebase): AngularFireAuth; } diff --git a/firebase/firebase.d.ts b/firebase/firebase.d.ts index 83f9ca84bf..bac32fbc63 100644 --- a/firebase/firebase.d.ts +++ b/firebase/firebase.d.ts @@ -53,7 +53,7 @@ declare class Firebase implements IFirebaseQuery { toString(): string; set(value: any, onComplete?: (error: any) => void): void; update(value: any, onComplete?: (error: any) => void): void; - remove(onComplete?: (error: any) => void); + remove(onComplete?: (error: any) => void): void; push(value: any, onComplete?: (error: any) => void): Firebase; setWithPriority(value: any, priority: string, onComplete?: (error: any) => void): void; setWithPriority(value: any, priority: number, onComplete?: (error: any) => void): void; From 8265a175698b41774b3b467292856f5de3719e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maido=20Ka=CC=88a=CC=88ra?= Date: Sun, 16 Feb 2014 13:51:13 +0000 Subject: [PATCH 157/240] Type definitions for server side nodejs socket.io client. --- README.md | 1 + socket.io-client/socket.io-client-tests.ts | 10 +++++++ socket.io-client/socket.io-client.d.ts | 33 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 socket.io-client/socket.io-client-tests.ts create mode 100644 socket.io-client/socket.io-client.d.ts diff --git a/README.md b/README.md index 2512630105..4ce7c2ca14 100755 --- a/README.md +++ b/README.md @@ -233,6 +233,7 @@ List of Definitions * [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin)) * [smoothie](https://github.com/joewalnes/smoothie) (by [Mike H. Hawley](https://github.com/mikehhawley)) * [socket.io](http://socket.io) (by [William Orr](https://github.com/worr)) +* [socket.io-client](http://socket.io) (by [Maido Kaara](https://github.com/v3rm0n)) * [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) * [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/socket.io-client/socket.io-client-tests.ts b/socket.io-client/socket.io-client-tests.ts new file mode 100644 index 0000000000..9c6018a19c --- /dev/null +++ b/socket.io-client/socket.io-client-tests.ts @@ -0,0 +1,10 @@ +import io = require('socket.io-client'); + +var socket = io('http://localhost:80'); + +socket.on('connect', function () { + console.log('Connected!'); + socket.send('some test data', function () { + console.log('Sent some data.'); + }); +}); \ No newline at end of file diff --git a/socket.io-client/socket.io-client.d.ts b/socket.io-client/socket.io-client.d.ts new file mode 100644 index 0000000000..0bef47c58a --- /dev/null +++ b/socket.io-client/socket.io-client.d.ts @@ -0,0 +1,33 @@ +// Type definitions for socket.io nodejs client +// Project: http://socket.io/ +// Definitions by: Maido Kaara +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "socket.io-client" { + + export function connect(host: string, details?: any): Socket; + + interface EventEmitter { + emit(name: string, ...data: any[]): any; + on(ns: string, fn: Function): EventEmitter; + addListener(ns: string, fn: Function): EventEmitter; + removeListener(ns: string, fn: Function): EventEmitter; + removeAllListeners(ns: string): EventEmitter; + once(ns: string, fn: Function): EventEmitter; + listeners(ns: string): Function[]; + } + + interface SocketNamespace extends EventEmitter { + of(name: string): SocketNamespace; + send(data: any, fn: Function): SocketNamespace; + emit(name: string): SocketNamespace; + } + + interface Socket extends EventEmitter { + of(name: string): SocketNamespace; + connect(fn: Function): Socket; + packet(data: any): Socket; + flushBuffer(): void; + disconnect(): Socket; + } +} \ No newline at end of file From d20a2330b88f5c31f19ef0cca9e165df0702d5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maido=20Ka=CC=88a=CC=88ra?= Date: Sun, 16 Feb 2014 13:53:26 +0000 Subject: [PATCH 158/240] Added newlines to the end of the files --- socket.io-client/socket.io-client-tests.ts | 2 +- socket.io-client/socket.io-client.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/socket.io-client/socket.io-client-tests.ts b/socket.io-client/socket.io-client-tests.ts index 9c6018a19c..f4171fe158 100644 --- a/socket.io-client/socket.io-client-tests.ts +++ b/socket.io-client/socket.io-client-tests.ts @@ -7,4 +7,4 @@ socket.on('connect', function () { socket.send('some test data', function () { console.log('Sent some data.'); }); -}); \ No newline at end of file +}); diff --git a/socket.io-client/socket.io-client.d.ts b/socket.io-client/socket.io-client.d.ts index 0bef47c58a..e4c6e0e38c 100644 --- a/socket.io-client/socket.io-client.d.ts +++ b/socket.io-client/socket.io-client.d.ts @@ -30,4 +30,4 @@ declare module "socket.io-client" { flushBuffer(): void; disconnect(): Socket; } -} \ No newline at end of file +} From 511cde8b917ed0b0b4830c773676e4a3cd0ba4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maido=20Ka=CC=88a=CC=88ra?= Date: Sun, 16 Feb 2014 15:21:15 +0000 Subject: [PATCH 159/240] Fixed test --- socket.io-client/socket.io-client-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socket.io-client/socket.io-client-tests.ts b/socket.io-client/socket.io-client-tests.ts index f4171fe158..7b5f967473 100644 --- a/socket.io-client/socket.io-client-tests.ts +++ b/socket.io-client/socket.io-client-tests.ts @@ -1,10 +1,10 @@ import io = require('socket.io-client'); -var socket = io('http://localhost:80'); +var socket = io.connect('http://localhost:80'); socket.on('connect', function () { console.log('Connected!'); - socket.send('some test data', function () { + socket.emit('event', 'some test data', function () { console.log('Sent some data.'); }); }); From 0db96af9995078fa79915e203f1b5d1760f5b99b Mon Sep 17 00:00:00 2001 From: Zach Nation Date: Mon, 17 Feb 2014 14:07:20 -0800 Subject: [PATCH 160/240] Add module declaration to bootstrap so it can be required as an AMD module --- bootstrap/bootstrap.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bootstrap/bootstrap.d.ts b/bootstrap/bootstrap.d.ts index c14bf61d4b..b9fe9cd597 100644 --- a/bootstrap/bootstrap.d.ts +++ b/bootstrap/bootstrap.d.ts @@ -107,3 +107,6 @@ interface JQuery { affix(options?: AffixOptions): JQuery; } + +declare module "bootstrap" { +} From e509a3dd61b188663f3d9a1e410f2eaba3e4734d Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 18 Feb 2014 00:09:13 +0100 Subject: [PATCH 161/240] added module declaration to underscore.string.d.ts --- underscore.string/underscore.string.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/underscore.string/underscore.string.d.ts b/underscore.string/underscore.string.d.ts index d016dc908d..db9ec042d4 100644 --- a/underscore.string/underscore.string.d.ts +++ b/underscore.string/underscore.string.d.ts @@ -562,5 +562,7 @@ interface UnderscoreStringStaticExports { toBoolean(str: string, trueValues?: any[], falseValues?: any[]): boolean; } - +declare module "underscore.string" { +export = UnderscoreStringStatic; +} // TODO interface UnderscoreString extends Underscore From acf9de177a5107c212fd610eb090a5cafa1f3a0a Mon Sep 17 00:00:00 2001 From: Johan Nilsson Date: Mon, 17 Feb 2014 21:59:39 -0400 Subject: [PATCH 162/240] StreetView : bool => StreetViewControl:bool Added StreetView: StreetViewPanorama --- googlemaps/google.maps.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index ebe11fda93..4589e09f0a 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -113,7 +113,8 @@ declare module google.maps { scaleControl?: boolean; scaleControlOptions?: ScaleControlOptions; scrollwheel?: boolean; - streetView?: boolean; + streetView?: StreetViewPanorama; + streetViewControl?: boolean; streetViewControlOptions?: StreetViewControlOptions; styles?: MapTypeStyle[]; tilt?: number; From ec984b303002ffecc74746ee9a934b4d14e70e45 Mon Sep 17 00:00:00 2001 From: John Vilk Date: Tue, 18 Feb 2014 00:06:23 -0500 Subject: [PATCH 163/240] Adding typings for the Microsoft Live Connect API. --- README.md | 5 +- .../microsoft-live-connect.d.ts | 2337 +++++++++++++++++ .../microsoft-live-connect.ts | 1048 ++++++++ 3 files changed, 3388 insertions(+), 2 deletions(-) create mode 100644 microsoft-live-connect/microsoft-live-connect.d.ts create mode 100644 microsoft-live-connect/microsoft-live-connect.ts diff --git a/README.md b/README.md index 5e94c6003f..d6a6b02cc2 100755 --- a/README.md +++ b/README.md @@ -185,8 +185,9 @@ List of Definitions * [Lodash](http://lodash.com/) (by [Brian Zengel](https://github.com/bczengel)) * [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle)) * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) -* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams] (https://github.com/flurg)) +* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) +* [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) * [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee)) @@ -201,7 +202,7 @@ List of Definitions * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) * [NProgress](https://github.com/rstacruz/nprogress) (by [Judah Gabriel Himango](https://github.com/judahgabriel)) * [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/)) -* [OpenLayers] (https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/)) +* [OpenLayers](https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/)) * [Parallel.js](https://github.com/adambom/parallel.js) (by [Josh Baldwin](https://github.com/jbaldwin)) * [PDF.js](https://github.com/mozilla/pdf.js) (by [Josh Baldwin](https://github.com/jbaldwin)) * [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto)) diff --git a/microsoft-live-connect/microsoft-live-connect.d.ts b/microsoft-live-connect/microsoft-live-connect.d.ts new file mode 100644 index 0000000000..04ff3ef79b --- /dev/null +++ b/microsoft-live-connect/microsoft-live-connect.d.ts @@ -0,0 +1,2337 @@ +/// +// Type definitions for Microsoft Live Connect v5.0. +// Project: http://msdn.microsoft.com/en-us/library/live/hh243643.aspx +// Definitions by: John Vilk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Microsoft.Live { + //#region REST Object Information + + /** + * Sub object of REST objects that contains information about a user. + */ + interface IUserInfo { + /** + * The name of the user. + */ + name: string; + /** + * The Live ID of the user. + */ + id: string; + } + + /** + * Sub object of REST objects that contains information about who the + * item is shared with. + */ + interface ISharedWith { + /** + * A localized string that contains info about who can access the + * item. The options are: + * - People I selected + * - Just me + * - Everyone (public) + * - Friends + * - My friends and their friends + * - People with a link + * The default is Just me. + */ + access: string; + } + + /** + * Convenience interface for when you have a bunch of objects of different + * types in a single collection. You discriminate between them using their + * 'type' field. + */ + interface IObject { + /** + * The object's type. + */ + type: string; + } + + /** + * Contains a collection of one type of object. + */ + interface IObjectCollection { + /** + * An array container for objects when a collection of objects is + * returned. + */ + data: T[]; + } + + /** + * The Album object contains info about a user's albums in Microsoft + * SkyDrive. Albums are stored at the root level of a user's SkyDrive + * directory, and can contain combinations of photos, videos, audio, files, + * and folders. The Live Connect REST API supports reading Album objects. + * Use the wl.photos scope to read a user's Album objects. Use the + * wl.skydrive scope to read a user's files. Use the wl.contacts_photos + * scope to read any albums, photos, videos, and audio that other users have + * shared with the user. + */ + interface IAlbum { + /** + * The Album object's ID. + */ + id: string; + /** + * Info about the user who authored the album. + */ + from: IUserInfo; + /** + * The name of the album. + */ + name: string; + /** + * A description of the album, or null if no description is specified. + */ + description: string; + /** + * The resource ID of the parent. + */ + parent_id: string; + /** + * The URL to upload items to the album, hosted in SkyDrive. Requires + * the wl.skydrive scope. + */ + upload_location: string; + /** + * A value that indicates whether this album can be embedded. If this + * album can be embedded, this value is true; otherwise, it is false. + */ + is_embeddable: boolean; + /** + * The total number of items in the album. + */ + count: number; + /** + * A URL of the album, hosted in SkyDrive. + */ + link: string; + /** + * The type of object; in this case, "album". + */ + type: string; + /** + * The object that contains permissions info for the album. Requires the + * wl.skydrive scope. + */ + shared_with: ISharedWith; + /** + * The time, in ISO 8601 format, at which the album was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, that the system updated the album last. + */ + updated_time: string; + /** + * The time, in ISO 8601 format, that the file was last updated. + */ + client_updated_time: string; + } + + /** + * Represents a new album. + */ + interface INewAlbum { + /** + * The name of the album. + */ + name: string; + /** + * A description of the album. + */ + description?: string; + } + + /** + * The Audio object contains info about a user's audio in SkyDrive. The Live + * Connect REST API supports creating, reading, updating, and deleting Audio + * objects. Use the wl.skydrive scope to read Audio objects. Use the + * wl.contacts_skydrive scope to read any audio that other users have shared + * with the user. Use the wl.skydrive_update scope to create, update, or + * delete Audio objects. + */ + interface IAudio { + /** + * The Audio object's ID. + */ + id: string; + /** + * Info about the user who uploaded the audio. + */ + from: IUserInfo; + /** + * The name of the audio. + */ + name: string; + /** + * A description of the audio, or null if no description is specified. + */ + description: string; + /** + * The id of the folder in which the audio is currently stored. + */ + parent_id: string; + /** + * The size, in bytes, of the audio. + */ + size: number; + /** + * The URL to use to upload a new audio to overwrite the existing audio. + */ + upload_location: string; + /** + * The number of comments associated with the audio. + */ + comments_count: number; + /** + * A value that indicates whether comments are enabled for the audio. If + * comments can be made, this value is true; otherwise, it is false. + */ + comments_enabled: boolean; + /** + * A value that indicates whether this audio can be embedded. If this + * audio can be embedded, this value is true; otherwise, it is false. + */ + is_embeddable: boolean; + /** + * The URL to use to download the audio from SkyDrive. + * Warning + * This value is not persistent. Use it immediately after making the + * request, and avoid caching. + */ + source: string; + /** + * A URL to view the item on SkyDrive. + */ + link: string; + /** + * The type of object; in this case, "audio". + */ + type: string; + /** + * The audio's title. + */ + title: string; + /** + * The audio's artist name. + */ + artist: string; + /** + * The audio's album name. + */ + album: string; + /** + * The artist name of the audio's album. + */ + album_artist: string; + /** + * The audio's genre. + */ + genre: string; + /** + * The audio's playing time, in milliseconds. + */ + duration: number; + /** + * A URL to view the audio's picture on SkyDrive. + */ + picture: string; + /** + * The object that contains permission info. + */ + shared_with: ISharedWith; + /** + * The time, in ISO 8601 format, at which the audio was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, at which the audio was last updated. + */ + updated_time: string; + } + + /** + * Represents a new audio item. + */ + interface INewAudio { + /** + * The name of the audio. + */ + name: string; + /** + * A description of the audio. + */ + description?: string; + /** + * The audio's title. + */ + title?: string; + /** + * The audio's artist name. + */ + artist?: string; + /** + * The audio's album name. + */ + album?: string; + /** + * The artist name of the audio's album. + */ + album_artist?: string; + /** + * The audio's genre. + */ + genre?: string; + } + + /** + * The Calendar object contains info about a user's Outlook.com calendar. + * The Live Connect REST API supports creating, reading, updating, and + * deleting calendars. Use the wl.calendars scope to read a user's Calendar + * objects. Use the wl.calendars_update scope to create Calendar objects for + * a user. Use the wl.contacts_calendars scope to read a user's friends' + * Calendar objects. + */ + interface ICalendar { + /** + * The Calendar object's ID. + */ + id: string; + /** + * Name of the calendar. + */ + name: string; + /** + * Description of the calendar. + */ + description: string; + /** + * The time, in ISO 8601 format, at which the calendar was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, that the calendar was last updated. + */ + updated_time: string; + /** + * Info about the user who owns the calendar. + */ + from: IUserInfo; + /** + * A value that indicates whether this calendar is the default calendar. + * If this calendar is the default calendar, this value is true; + * otherwise, it is false. + */ + is_default: boolean; + /** + * A public subscription URL with which Live Connect will synchronize + * properties and events periodically for this calendar. A NULL value + * indicates that this is not a subscribed calendar. + */ + subscription_location: string; + /** + * Role and permissions that are granted to the user for the calendar. + * The possible values are: + * - free_busy: The user can see only free/busy info. + * - limited_details: The user can see a subset of all details. + * - read: The user can only read the content of the calendar events. + * - read_write: The user can read and write calendar and events. + * - co_owner: The user is co-owner of this calendar. + * - owner: The user is the owner of this calendar. + */ + permissions: string; + } + + /** + * Represents a new calendar item. + */ + interface INewCalendar { + /** + * Name of the calendar. + */ + name: string; + /** + * Description of the calendar. + */ + description?: string; + } + + /** + * Represents a request to create a new calendar that subscribes to the + * given iCal calendar. + */ + interface INewCalendarSubscription { + /** + * Name of the calendar. + */ + name: string; + /** + * A public subscription URL with which Live Connect will synchronize + * properties and events periodically for this calendar. + */ + subscription_location: string; + } + + /** + * The Comment object contains info about comments that are associated with + * a photo, audio, or video on SkyDrive. The Live Connect REST API supports + * reading Comment objects. Use the wl.photos scope to read Comment objects. + * Use the wl.contacts_photos scope to read the Comment objects that are + * associated with any albums, photos, and videos that other users have + * shared with the user. + */ + interface IComment { + /** + * The Comment object's id. + */ + id: string; + /** + * Info about the user who created the comment. + */ + from: IUserInfo; + /** + * The text of the comment. The maximum length of a comment is 10,000 + * characters. + */ + message: string; + /** + * The time, in ISO 8601 format, at which the comment was created. + */ + created_time: string; + } + + /** + * Represents a new comment. + */ + interface INewComment { + /** + * The text of the comment. The maximum length of a comment is 10,000 + * characters. + */ + message: string; + } + + /** + * The Contact object contains info about a user's Outlook.com contacts. The + * Live Connect REST API supports reading Contact objects. + */ + interface IContact { + /** + * The Contact object's ID. + */ + id: string; + /** + * The contact's first name, or null if no first name is specified. + */ + first_name: string; + /** + * The contact's last name, or null if no last name is specified. + */ + last_name: string; + /** + * The contact's full name, formatted for location. + */ + name: string; + /** + * A value that indicates whether the contact is set as a friend. If the + * contact is a friend, this value is true; otherwise, it is false. + */ + is_friend: boolean; + /** + * A value that indicates whether the contact is set as a favorite + * contact. If the contact is a favorite, this value is true; otherwise, + * it is false. + */ + is_favorite: boolean; + /** + * The contact's ID, if the contact has one. If not, this value is null. + */ + user_id: string; + /** + * An array containing a SHA-256 hash for each of the contact's email + * addresses. For more info, see Friend finder. + */ + email_hashes: string[]; + /** + * The time, in ISO 8601 format, at which the user last updated the + * data. + */ + updated_time: string; + /** + * The day of the contact's birth date, or null if no birth date is + * specified. + */ + birth_day: number; + /** + * The month of the contact's birth date, or null if no birth date is + * specified. + */ + birth_month: number; + } + + /** + * Represents a new contact. + */ + interface INewContact { + /** + * The contact's first name. + */ + first_name?: string; + /** + * The contact's last name. + */ + last_name?: string; + /** + * An array that contains the contact's work info. + */ + work?: { + employer: { + name: string; + } + }[]; + /** + * The contact's email addresses. + */ + emails?: { + /** + * The contact's preferred email address. + */ + preferred?: string; + /** + * The contact's personal email address. + */ + personal?: string; + /** + * The contact's business email address. + */ + business?: string; + /** + * The contact's "alternate" email address. + */ + other?: string; + }; + } + + /** + * The Error object contains info about an error that is returned by the + * Live Connect APIs. + */ + interface IError { + /** + * Info about the error. + */ + error: { + /** + * The error code. + */ + code: string; + /** + * The error message. + */ + message: string; + }; + } + + /** + * The Event object contains info about events on a user's Outlook.com + * calendars. The Live Connect REST API supports creating Event objects. Use + * the wl.events_create scope to create Event objects on the user's default + * calendar only. Use the wl.calendars scope to read Event objects on the + * user's calendars. Use wl.calendars_update to create Event objects on any + * of the user's calendars. Use the wl.contacts_calendars scope to read + * Event objects from the user's friend's calendars. + */ + interface IEvent { + /** + * The ID of the event. + */ + id: string; + /** + * The name of the event, with a maximum length of 255 characters. This + * structure is required. + */ + name: string; + /** + * The time, in ISO 8601 format, at which the event was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, at which the event was updated. This + * structure is visible only in the Event object that is returned if the + * event was successfully created. + */ + updated_time: string; + /** + * A description of the event, with a maximum length of 32,768 + * characters. This structure is required. + */ + description: string; + /** + * The ID of the calendar that contains the event. + */ + calendar_id: string; + /** + * The object that contains the name and ID of the organizer. + */ + from: IUserInfo; + /** + * The start time, in ISO 8601 format, of the event. When the event is + * being read, the time will be the user's local time, in ISO 8601 + * format. + */ + start_time: string; + /** + * The end time, in ISO 8601 format, of the event. If no end time is + * specified, the default value is 30 minutes after start_time. This + * structure is optional when creating an event. When the event is being + * read, the time will be the user's local time, in ISO 8601 format. + */ + end_time: string; + /** + * The name of the location at which the event will take place. The + * maximum length is 1,000 characters. + */ + location: string; + /** + * A value that specifies whether the event is an all-day event. If the + * event is an all-day event, this value is true; otherwise, it is + * false. If this structure is missing, the default value is false. + */ + is_all_day_event: boolean; + /** + * A value that specifies whether the event is recurring. If the event + * is recurring, this value is true; otherwise, it is false. + */ + is_recurrent: boolean; + /** + * The text description of the recurrence pattern, for example, "Occurs + * every week on Tuesday". The value is Null if this is not a recurrent + * event. + */ + recurrence: string; + /** + * The time, in minutes, before the event for the reminder alarm. + */ + reminder_time: number; + /** + * The user's availability status for the event. Valid values are: + * - free + * - busy + * - tentative + * - out_of_office + * @default "free" + */ + availability: string; + /** + * A value that specifies whether the event is publicly visible. Valid + * values are: + * - publicthe event is visible to anyone who can view the calendar. + * - private"the event is visible only to the event owner. + * @default "public" + */ + visibility: string; + } + + /** + * Represents a new event. + */ + interface INewEvent { + /** + * The name of the event, with a maximum length of 255 characters. This + * structure is required. + */ + name: string; + /** + * A description of the event, with a maximum length of 32,768 + * characters. This structure is required. + */ + description: string; + /** + * The start time of the event. When the event is being read, the time + * will be the user's local time, in ISO 8601 format. + * Can be a date string, or a Date object. + */ + start_time: any; + /** + * The end time of the event. If no end time is specified, the default + * value is 30 minutes after start_time. This structure is optional when + * creating an event. When the event is being read, the time will be the + * user's local time, in ISO 8601 format. + * Can be a date string, or a Date object. + */ + end_time?: any; + /** + * The name of the location at which the event will take place. The + * maximum length is 1,000 characters. + */ + location?: string; + /** + * A value that specifies whether the event is an all-day event. If the + * event is an all-day event, this value is true; otherwise, it is + * false. If this structure is missing, the default value is false. + */ + is_all_day_event?: boolean; + /** + * The time, in minutes, before the event for the reminder alarm. + */ + reminder_time?: number; + /** + * The user's availability status for the event. Valid values are: + * - free + * - busy + * - tentative + * - out_of_office + * @default "free" + */ + availability?: string; + /** + * A value that specifies whether the event is publicly visible. Valid + * values are: + * - publicthe event is visible to anyone who can view the calendar. + * - private"the event is visible only to the event owner. + * @default "public" + */ + visibility?: string; + } + + /** + * Response received after successfully creating a new event. + */ + interface INewEventResponse { + /** + * The name of the event, with a maximum length of 255 characters. This + * structure is required. + */ + name: string; + /** + * A description of the event, with a maximum length of 32,768 + * characters. This structure is required. + */ + description: string; + /** + * The start time, in ISO 8601 format, of the event. When the event is + * being read, the time will be the user's local time, in ISO 8601 + * format. + */ + start_time: string; + /** + * The end time, in ISO 8601 format, of the event. If no end time is + * specified, the default value is 30 minutes after start_time. This + * structure is optional when creating an event. When the event is being + * read, the time will be the user's local time, in ISO 8601 format. + */ + end_time: string; + /** + * The name of the location at which the event will take place. The + * maximum length is 1,000 characters. + */ + location: string; + /** + * A value that specifies whether the event is an all-day event. If the + * event is an all-day event, this value is true; otherwise, it is + * false. If this structure is missing, the default value is false. + */ + is_all_day_event: boolean; + /** + * A value that specifies whether the event is recurring. If the event + * is recurring, this value is true; otherwise, it is false. + */ + is_recurrent: boolean; + /** + * The text description of the recurrence pattern, for example, "Occurs + * every week on Tuesday". The value is Null if this is not a recurrent + * event. + */ + recurrence: string; + /** + * The time, in minutes, before the event for the reminder alarm. + */ + reminder_time: number; + /** + * The user's availability status for the event. Valid values are: + * - free + * - busy + * - tentative + * - out_of_office + * @default "free" + */ + availability: string; + /** + * A value that specifies whether the event is publicly visible. Valid + * values are: + * - publicthe event is visible to anyone who can view the calendar. + * - private"the event is visible only to the event owner. + * @default "public" + */ + visibility: string; + /** + * The time, in ISO 8601 format, at which the event was updated. This + * structure is visible only in the Event object that is returned if the + * event was successfully created. + */ + updated_time: string; + } + + /** + * The File object contains info about a user's files in SkyDrive. The Live + * Connect REST API supports creating, reading, updating, and deleting File + * objects. Use the wl.skydrive scope to read File objects. Use the + * wl.contacts_skydrive scope to read any files that other users have shared + * with the user. Use the wl.skydrive_update scope to create, update, or + * delete File objects. + */ + interface IFile { + /** + * The File object's ID. + */ + id: string; + /** + * Info about the user who uploaded the file. + */ + from: IUserInfo; + /** + * The name of the file. + */ + name: string; + /** + * A description of the file, or null if no description is specified. + */ + description: string; + /** + * The ID of the folder the file is currently stored in. + */ + parent_id: string; + /** + * The size, in bytes, of the file. + */ + size: number; + /** + * The URL to upload file content hosted in SkyDrive. + * Note: This structure is not available if the file is an Microsoft + * Office OneNote notebook. + */ + upload_location: string; + /** + * The number of comments that are associated with the file. + */ + comments_count: number; + /** + * A value that indicates whether comments are enabled for the file. If + * comments can be made, this value is true; otherwise, it is false. + */ + comments_enabled: boolean; + /** + * A value that indicates whether this file can be embedded. If this + * file can be embedded, this value is true; otherwise, it is false. + */ + is_embeddable: boolean; + /** + * The URL to use to download the file from SkyDrive. + * Warning: This value is not persistent. Use it immediately after + * making the request, and avoid caching. + * Note: This structure is not available if the file is an Office + * OneNote notebook. + */ + source: string; + /** + * A URL to view the item on SkyDrive. + */ + link: string; + /** + * The type of object; in this case, "file". + * Note: If the file is a Office OneNote notebook, the type structure is + * set to "notebook". + */ + type: string; + /** + * Object that contains permission info. + */ + shared_with: ISharedWith; + /** + * The time, in ISO 8601 format, at which the file was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, that the system updated the file last. + */ + updated_time: string; + /** + * The time, in ISO 8601 format, that the client machine updated the + * file last. + */ + client_updated_time: string; + /** + * Sorts the items to specify the following criteria: updated, name, + * size, or default. + */ + sort_by: string; + } + + /** + * Success response to a new file creation request. + */ + interface INewFileResponse { + /** + * ID of the new item. + */ + id: string; + /** + * The file's name and file extension. + */ + name: string; + /** + * URL where the item can be downloaded from. + */ + source: string; + } + + /** + * Returns when you perform a GET request to /FILE_ID/content. + */ + interface IFileDownloadLink { + /** + * A URL download link for the file. + */ + location: string; + } + + /** + * The Folder object contains info about a user's folders in SkyDrive. + * Folders can contain combinations of photos, videos, audio, and + * subfolders. The Live Connect REST API supports reading Folder objects. + * Use the wl.photos scope to read Folder objects. Use the + * wl.contacts_photos scope to read any albums, photos, videos, and audio + * that other users have shared with the user. + */ + interface IFolder { + /** + * The Folder object's ID. + */ + id: string; + /** + * Info about the user who created the folder. + */ + from: IUserInfo; + /** + * The name of the folder. + */ + name: string; + /** + * A description of the folder, or null if no description is specified. + */ + description: string; + /** + * The total number of items in the folder. + */ + count: number; + /** + * The URL of the folder, hosted in SkyDrive. + */ + link: string; + /** + * The resource ID of the parent. + */ + parent_id: string; + /** + * The URL to upload items to the folder hosted in SkyDrive. Requires + * the wl.skydrive scope. + */ + upload_location: string; + /** + * A value that indicates whether this folder can be embedded. If this + * folder can be embedded, this value is true; otherwise, it is false. + */ + is_embeddable: boolean; + /** + * The type of object; in this case, "folder". + */ + type: string; + /** + * The time, in ISO 8601 format, at which the folder was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, that the system updated the file last. + */ + updated_time: string; + /** + * The time, in ISO 8601 format, that the client machine updated the + * file last. + */ + client_updated_time: string; + /** + * Permissions info for the folder. Requires the wl.skydrive scope. + */ + shared_with: ISharedWith; + /** + * Sorts the items to specify the following criteria: updated, name, + * size, or default. + */ + sort_by: string; + } + + /** + * Represents a new folder. + */ + interface INewFolder { + /** + * The name of the folder. + */ + name: string; + /** + * A description of the folder. + */ + description?: string; + /** + * Sorts the items to specify the following criteria: updated, name, + * size, or default. + */ + sort_by?: string; + } + + /** + * The Friend object contains info about a user's friends. A Friend object + * represents a user's contact whose is_friend value is set to true. The + * Live Connect REST API supports reading Friend objects. + */ + interface IFriend { + /** + * The friend's ID. + */ + id: string; + /** + * The friend's full name, formatted for locale. + */ + name: string; + } + + /** + * The Permissions object contains a list of scopes, showing those scopes to + * which the user has consented. The response body contains a JSON object + * that lists all consented scopes as a name/value pair. Each scope to which + * the user consented is present as a key. + */ + interface IPermissions { + [scope: string]: number; + } + + /** + * Information about an image. + */ + interface IImageInfo { + /** + * The height, in pixels, of this image of this particular size. + */ + height: number; + /** + * The width, in pixels, of this image of this particular size. + */ + width: number; + /** + * The width, in pixels, of this image of this particular size. + */ + source: string; + /** + * The type of this image of this particular size. Valid values are: + * full (maximum size: 2048 2048 pixels) + * - normal (maximum size 800 800 pixels) + * - album (maximum size 176 176 pixels) + * - small (maximum size 96 96 pixels) + */ + type: string; + } + + /** + * Represents location information. + */ + interface ILocation { + /** + * The latitude portion of the location, expressed as positive (north) + * or negative (south) degrees relative to the equator. + */ + latitude: number; + /** + * The longitude portion of the location expressed as positive (east) or + * negative (west) degrees relative to the Prime Meridian. + */ + longitude: number; + /** + * The altitude portion of the location, expressed as positive (above) + * or negative (below) values relative to sea level, in units of + * measurement as determined by the camera. + */ + altitude: number; + } + + /** + * The Photo object contains info about a user's photos on SkyDrive. The + * Live Connect REST API supports creating, reading, updating, and deleting + * Photo objects. Use the wl.photos scope to read Photo objects. Use the + * wl.contacts_photos scope to read any albums, photos, videos, and audio + * that other users have shared with the user. Use the wl.skydrive_update + * scope to create, update, or delete Photo objects. + */ + interface IPhoto { + /** + * The Photo object's ID. + */ + id: string; + /** + * Info about the user who uploaded the photo. + */ + from: IUserInfo; + /** + * The file name of the photo. + */ + name: string; + /** + * A description of the photo, or null if no description is specified. + */ + description: string; + /** + * The ID of the folder where the item is stored. + */ + parent_id: string; + /** + * The size, in bytes, of the photo. + */ + size: number; + /** + * The number of comments associated with the photo. + */ + comments_count: number; + /** + * A value that indicates whether comments are enabled for the photo. If + * comments can be made, this value is true; otherwise, it is false. + */ + comments_enabled: boolean; + /** + * The number of tags on the photo. + */ + tags_count: number; + /** + * A value that indicates whether tags are enabled for the photo. If + * users can tag the photo, this value is true; otherwise, it is false. + */ + tags_enabled: boolean; + /** + * A value that indicates whether this photo can be embedded. If this + * photo can be embedded, this value is true; otherwise, it is false. + */ + is_embeddable: boolean; + /** + * A URL of the photo's picture. + */ + picture: string; + /** + * The download URL for the photo. + * Warning: This value is not persistent. Use it immediately after + * making the request, and avoid caching. + */ + source: string; + /** + * The URL to upload photo content hosted in SkyDrive. This value is + * returned only if the wl.skydrive scope is present. + */ + upload_location: string; + /** + * Info about various sizes of the photo. + */ + images: IImageInfo[]; + /** + * A URL of the photo, hosted in SkyDrive. + */ + link: string; + /** + * The date, in ISO 8601 format, on which the photo was taken, or null + * if no date is specified. + */ + when_taken: string; + /** + * The height, in pixels, of the photo. + */ + height: number; + /** + * The width, in pixels, of the photo. + */ + width: number; + /** + * The type of object; in this case, "photo". + */ + type: string; + /** + * The location where the photo was taken. + * Note: The location object is not available for shared photos. + */ + location: ILocation; + /** + * The manufacturer of the camera that took the photo. + */ + camera_make: string; + /** + * The brand and model number of the camera that took the photo. + */ + camera_model: string; + /** + * The f-number that the photo was taken at. + */ + focal_ratio: number; + /** + * The focal length that the photo was taken at, typically expressed in + * millimeters for newer lenses. + */ + focal_length: number; + /** + * The numerator of the shutter speed (for example, the "1" in "1/15 s") + * that the photo was taken at. + */ + exposure_numerator: number; + /** + * The denominator of the shutter speed (for example, the "15" in "1/15 + * s") that the photo was taken at. + */ + exposure_denominator: number; + /** + * The object that contains permissions info for the photo. + */ + shared_with: ISharedWith; + /** + * The time, in ISO 8601 format, at which the photo was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, at which the photo was last updated. + */ + updated_time: string; + } + + /** + * The Search object contains info about the objects found in a user's + * SkyDrive that match the search query. See Search query parameters for + * info about formatting a search query request. + */ + interface ISearch { + /** + * An array of file and folder objects found in a user's SkyDrive that + * match the search query. + */ + data: IObject[]; + /** + * The path strings that reference the next and previous sets in a + * paginated response. + */ + paging?: { + /** + * Path string for the next set of results. + */ + next?: string; + /** + * Path string for the previous set of results. + */ + previous?: string; + }; + } + + /** + * The Tag object contains info about tags that are associated with a photo + * or a video on SkyDrive. The Live Connect REST API supports reading Tag + * objects. Use the wl.photos, and wl.skydrive scopes to read Tag objects. + * Use the wl.contacts_photos and wl.contacts_skydrive scopes to read the + * Tag objects that are associated with any photos that other users have + * shared with the user. + */ + interface ITag { + /** + * The Tag object's ID. + */ + id: string; + /** + * The user object for the tagged person. + */ + user: IUserInfo; + /** + * The center of the tag's horizontal position, measured as a + * floating-point percentage from 0 to 100, from the left edge of the + * photo. This value is not returned for Video objects. + */ + x: number; + /** + * The center of the tag's vertical position, measured as a + * floating-point percentage from 0 to 100, from the top edge of the + * photo. This value is not returned for Video objects. + */ + y: number; + /** + * The time, in ISO 8601 format, at which the tag was created. + */ + created_time: string; + } + + /** + * Contains work information for one employer. + */ + interface IWorkInfo { + /** + * Info about the user's employer. + */ + employer: { + /** + * The name of the user's employer, or null if the employer's name + * is not specified. + */ + name: string; + }; + /** + * Info about the user's work position. + */ + position: { + /** + * The name of the user's work position, or null if the name of the + * work position is not specified. + */ + name: string; + }; + } + + /** + * Information about one postal address. + */ + interface IPostalAddress { + /** + * The street address, or null if one is not specified. + */ + street: string; + /** + * The second line of the street address, or null if one is not + * specified. + */ + street_2: string; + /** + * The city of the address, or null if one is not specified. + */ + city: string; + /** + * The state of the address, or null if one is not specified. + */ + state: string; + /** + * The postal code of the address, or null if one is not specified. + */ + postal_code: string; + /** + * The region of the address, or null if one is not specified. + */ + region: string; + } + + /** + * The User object contains info about a user. The Live Connect REST API + * supports reading User objects. + */ + interface IUser { + /** + * The user's ID. + */ + id: string; + /** + * The user's full name. + */ + name: string; + /** + * The user's first name. + */ + first_name: string; + /** + * The user's last name. + */ + last_name: string; + /** + * The user's gender, or null if no gender is specified. + */ + gender: string; + /** + * The URL of the user's profile page. + */ + link: string; + /** + * The day of the user's birth date, or null if no birth date is + * specified. + */ + birth_day: number; + /** + * The month of the user's birth date, or null if no birth date is + * specified. + */ + birth_month: number; + /** + * The year of the user's birth date, or null if no birth date is + * specified. + */ + birth_year: number; + /** + * An array that contains the user's work info. + */ + work: IWorkInfo[]; + /** + * The user's email addresses. + */ + emails: { + /** + * The user's preferred email address, or null if one is not + * specified. + */ + preferred: string; + /** + * The email address that is associated with the account. + */ + account: string; + /** + * The user's personal email address, or null if one is not + * specified. + */ + personal: string; + /** + * The user's business email address, or null if one is not + * specified. + */ + business: string; + /** + * The user's "alternate" email address, or null if one is not + * specified. + */ + other: string; + }; + /** + * The user's postal addresses. + */ + addresses: { + /** + * The user's personal postal address. + */ + personal: IPostalAddress; + /** + * The user's business postal address. + */ + business: IPostalAddress; + }; + /** + * The user's phone numbers. + */ + phones: { + /** + * The user's personal phone number, or null if one is not + * specified. + */ + personal: string; + /** + * The user's business phone number, or null if one is not + * specified. + */ + business: string; + /** + * The user's mobile phone number, or null if one is not specified. + */ + mobile: string; + }; + /** + * The user's locale code. + */ + locale: string; + /** + * The time, in ISO 8601 format, at which the user last updated the + * object. + */ + updated_time: string; + } + + /** + * The Video object contains info about a user's videos on SkyDrive. The + * Live Connect REST API supports creating, reading, updating, and deleting + * Video objects. Use the wl.photos scope to read Video objects. Use the + * wl.contacts_photos scope to read albums, photos, and videos that other + * users have shared with the user. Use the wl.skydrive_update scope to + * create, update, or delete Video objects. + */ + interface IVideo { + /** + * The Video object's ID. + */ + id: string; + /** + * Info about the user who uploaded the video. + */ + from: IUserInfo; + /** + * The file name of the video. + */ + name: string; + /** + * A description of the video, or null if no description is specified. + */ + description: string; + /** + * The id of the folder where the item is stored. + */ + parent_id: string; + /** + * The size, in bytes, of the video. + */ + size: number; + /** + * The number of comments that are associated with the video. + */ + comments_count: number; + /** + * A value that indicates whether comments are enabled for the video. If + * comments can be made, this value is true; otherwise, it is false. + */ + comments_enabled: boolean; + /** + * The number of tags on the video. + */ + tags_count: number; + /** + * A value that indicates whether tags are enabled for the video. If + * tags can be set, this value is true; otherwise, it is false. + */ + tags_enabled: boolean; + /** + * A value that indicates whether this video can be embedded. If this + * video can be embedded, this value is true; otherwise, it is false. + */ + is_embeddable: boolean; + /** + * A URL of a picture that represents the video. + */ + picture: string; + /** + * The download URL for the video. + * Warning: This value is not persistent. Use it immediately after + * making the request, and avoid caching. + */ + source: string; + /** + * The URL to upload video content, hosted in SkyDrive. This value is + * returned only if the wl.skydrive scope is present. + */ + upload_location: string; + /** + * A URL of the video, hosted in SkyDrive. + */ + link: string; + /** + * The height, in pixels, of the video. + */ + height: number; + /** + * The width, in pixels, of the video. + */ + width: number; + /** + * The duration, in milliseconds, of the video run time. + */ + duration: number; + /** + * The bit rate, in bits per second, of the video. + */ + bitrate: number; + /** + * The type of object; in this case, "video". + */ + type: string; + /** + * The object that contains permission info. + */ + shared_with: ISharedWith; + /** + * The time, in ISO 8601 format, at which the video was created. + */ + created_time: string; + /** + * The time, in ISO 8601 format, at which the video was last updated. + */ + updated_time: string; + } + + //#endregion REST Object Information + + //#region API Properties Interfaces + + /** + * 'Properties' object passed into the WL.api method. + */ + interface IAPIProperties { + /** + * Contains the path to the REST API object. For information on + * specifying paths for REST objects, see REST reference. + * http://msdn.microsoft.com/en-us/library/live/hh243648.aspx + */ + path: string; + /** + * An HTTP method that specifies the action required for the API call. + * These actions are standard REST API actions: "COPY", "GET", "MOVE", + * "PUT", "POST", and "DELETE". + * @default "GET" + */ + method?: string; + /** + * A JSON object that specifies the REST API request body. The body + * property is used only for "POST" and "PUT" requests. + */ + body?: any; + } + + /** + * 'Properties' object passed into the WL.backgroundDownload method. + */ + interface IBackgroundDownloadProperties { + /** + * The path to the file to download. For information on specifying paths + * for REST objects, see REST reference. + * http://msdn.microsoft.com/en-us/library/live/hh243648.aspx + */ + path: string; + /** + * The file output object to which the downloaded file data is written. + */ + file_output?: Windows.Storage.StorageFile; + } + + /** + * 'Properties' object passed into the WL.backgroundUpload method. + */ + interface IBackgroundUploadProperties { + /** + * The path to the file to upload. + */ + path: string; + /** + * The name of the file to upload. + */ + file_name?: string; + /** + * The file input object to read the file from. Can be a + * Windows.Storage.StorageFile or an IFile. + */ + file_input?: any; + /** + * The file input stream to read the file from. + */ + stream_input?: Windows.Storage.Streams.IInputStream; + /** + * Indicates whether the uploaded file should overwrite an existing + * copy. Specify "true" to overwrite, "false" to not overwrite and for + * the WL.backgroundUpload method call to fail, or "rename" to not + * overwrite and enable SkyDrive to assign a new name to the uploaded + * file. + * @default "false". + */ + overwrite?: string; + } + + /** + * 'Properties' object passed into the WL.download method. + */ + interface IDownloadProperties { + /** + * The path to the file to download. For information on specifying paths + * for REST objects, see REST reference. + * http://msdn.microsoft.com/en-us/library/live/hh243648.aspx + */ + path: string; + } + + /** + * 'Properties' object passed into the WL.fileDialog method. + */ + interface IFileDialogProperties { + /** + * Specifies the type of SkyDrive file picker to display. Specify "open" + * to display the download version of the file picker. Specify "save" + * to display the upload version of the file picker. + */ + mode: string; + /** + * Specify only if the mode property is set to "open". Specifies how + * many files the user can select to download. Specify "single" for a + * single file. Specify "multi" for multiple files. + * @default "single" + */ + select?: string; + /** + * The color pallette to use for the file picker. Specify "white", + * "grey", or "transparent". + * @default "white" + */ + lightbox?: string; + } + + /** + * 'Properties' object passed into the WL.init method. + */ + interface IInitProperties { + /** + * Web apps: Required. + * Specifies your app's OAuth client ID for web apps. + * + * Windows Store apps using JavaScript: not needed. + */ + client_id?: string; + /** + * Contains the default redirect URI to be used for OAuth + * authentication. For web apps, the OAuth server redirects to this URI + * during the OAuth flow. + * + * For Windows Store apps using JavaScript, specifying this value will + * enable the library to return the authentication token. + */ + redirect_uri?: string; + /** + * The scope values used to determine which portions of user data the + * app has access to, if the user consents. + * + * For a single scope, use this format: scope: "wl.signin". For multiple + * scopes, use this format: scope: ["wl.signin", "wl.basic"]. + */ + scope?: any; + /** + * If set to "true", the library logs error info to the web browser + * console and notifies your app by means of the wl.log event. + * @default true + */ + logging?: boolean; + /** + * Web apps: optional. + * Windows Store apps using JavaScript: not applicable. + * If set to "true", the library attempts to retrieve the user's sign-in + * status from Live Connect. + * @default true + */ + status?: boolean; + /** + * Web apps: optional. + * Windows Store apps using JavaScript: not applicable. + * Specifies the OAuth response type value. If set to "token", the + * client receives the access token directly. If set to "code", the + * client receives an authorization code, and the app server that serves + * the redirect_uri page should retrieve the access_token from the OAuth + * server by using the authorization code and client secret. + * + * You can only set response_type to "code" for web apps. + * @default "token" + */ + response_type?: string; + /** + * Web apps: optional. + * Windows Store apps using JavaScript: not applicable. + * If set to "true", the library specifies a secure attribute when + * writing a cookie on an HTTPS page. + * @default "false" + */ + secure_cookie?: string; + } + + /** + * 'Properties' object passed into the WL.login method. + */ + interface ILoginProperties { + /** + * This parameter only applies to web apps. + * Contains the redirect URI to be used for OAuth authentication. This + * value overrides the default redirect URI that is provided in the call + * to WL.init. + */ + redirect_uri?: string; + /** + * Specifies the scopes to which the user who is signing in consents. + * + * For a single scope, use this format: scope: "wl.signin". For multiple + * scopes, use this format: scope: ["wl.signin", "wl.basic"]. + * + * If no scope is provided, the scope value of WL.init is used. If no + * scope is provided in WL.init or WL.login, WL.login returns an error. + * + * Note WL.login can request the "wl.offline_access" scope, but it + * requires a server-side implementation, and the WL.init function must + * set its response_type property to "code". For more info, see + * Server-side scenarios. + * http://msdn.microsoft.com/en-us/library/live/hh243649.aspx + */ + scope: any; + /** + * Windows Store apps using JavaScript: not applicable. + * Web apps: Optional. If the WL.init function's response_type object is + * set to "code" and the app uses server-flow authentication, the state + * object here can be used to track the web app's calling state on the + * web app server side. For more info, see the description of the state + * query parameter in the Server-side scenarios topic's "Getting an + * authorization code" section. + * http://msdn.microsoft.com/en-us/library/live/hh243649.aspx + */ + state?: string; + } + + /** + * 'Properties' object passed into the WL.ui method. + */ + interface IUIProperties { + /** + * Specifies the type of button to display. Specify "signin" to display + * the Live Connect sign-in button. Specify "skydrivepicker" to display + * the SkyDrive button. + */ + name: string; + /** + * The value of the id attribute of the
tag to display the button + * in. + */ + element: string; + /** + * Windows Store apps using JavaScript: not applicable. + * Web apps: Optional. If the name property is set to "signin", the + * WL.init function's response_type property is set to "code", and the + * app uses server-flow authentication, the state object here can be + * used to track the web app's calling state on the web app server side. + * For more info, see the description of the state query parameter in + * the Server-side scenarios topic's "Getting an authorization code" + * section. + * http://msdn.microsoft.com/en-us/library/live/hh243649.aspx + */ + state?: string; + } + + /** + * 'Properties' object passed into the WL.ui method when 'name' is set to + * 'skydrivepicker'. + */ + interface ISkyDrivePickerProperies extends IUIProperties { + /** + * The type of SkyDrive file picker button to display. Specify "save" to + * display the upload button. Specify "open" to display the download + * button. + */ + mode: string; + /** + * Required if the mode property is set to "open". Specifies how many + * files the user can select to download. Specify "single" for a single + * file. Specify "multi" for multiple files. + * @default "single" + */ + select?: string; + /** + * Defines the color pallette used for the file picker button. Valid + * values are "white" and "blue". + * @default "white" + */ + theme?: string; + /** + * Defines the color pallette used for the file picker dialog box. Valid + * values are "white", "gray", and "transparent". + * @default "white" + */ + lightbox?: string; + /** + * If the mode property is set to "save", specifies the function to call + * after the user clicks either Save or Cancel in the file picker. If + * the mode property is set to "open", specifies the function to call + * after the user clicks either Open or Cancel in the file picker. + */ + onselected?: Function; + /** + * Specifies the function to call if the selected files cannot be + * successfully uploaded or downloaded. + */ + onerror?: Function; + } + + /** + * 'Properties' object passed into the WL.ui method when 'name' is set to + * 'signin'. + */ + interface ISignInProperties extends IUIProperties { + /** + * Defines the brand, or type of icon, to be used with the Live Connect + * sign-in button. + * @default "windows" + */ + brand?: string; + /** + * Defines the color pallette used for the sign-in button. For Windows + * Store apps using JavaScript, valid values are "dark" and "light". + * For web apps, valid values are "blue" and "white". + */ + theme?: string; + /** + * Defines the type of button. + * @default "signin" + */ + type?: string; + /** + * If the value of the type property is set to "custom", this value + * specifies the sign-in text to be displayed in the button. + */ + sign_in_text?: string; + /** + * If the value of the type property is "custom", this value specifies + * the sign-out text to be displayed in the button. + */ + sign_out_text?: string; + /** + * Specifies the function to call after the user completes the sign-in + * process. + */ + onloggedin?: Function; + /** + * Specifies the function to call after the user completes the sign-out + * process. + */ + onloggedout?: Function; + /** + * Specifies the function to call whenever there is any error while the + * sign-in control is initializing or while the user is signing in. + */ + onerror?: Function; + } + + /** + * 'Properties' object passed into the WL.upload method. + */ + interface IUploadProperties { + /** + * The path to the file to upload. + */ + path: string; + /** + * The id attribute of the tag containing info about the file to + * upload. + */ + element: string; + /** + * Indicates whether the uploaded file should overwrite an existing + * copy. Specify true or "true" to overwrite, false or "false" to not + * overwrite and for the WL.upload method call to fail, or "rename" to + * not overwrite and enable SkyDrive to assign a new name to the + * uploaded file. + * @default "false" + */ + overwrite?: string; + } + + //#endregion API Properties Interfaces + + /** + * Represents the user's session. + */ + interface ISession { + /** + * The user's access token. + */ + access_token: string; + /** + * The authentication token. + */ + authentication_token: string; + /** + * A list of scopes that the app has requested and that the user has + * consented to. + * + * Note: This property is not available for Windows Store apps using + * JavaScript. + */ + scope?: string[]; + /** + * The amount of time remaining, in seconds, until the user's access + * token expires. + * + * Note: This property is not available for Windows Store apps using + * JavaScript. + */ + expires_in?: number; + /** + * The exact time when the session will expire. This time is expressed + * in the number of seconds since 1 January, 1970. + * + * Note: This property is not available for Windows Store apps using + * JavaScript. + */ + expires?: number; + } + + /** + * Represents the user's login status. + */ + interface ILoginStatus { + /** + * The sign-in status of the user. Valid values are "connected", + * "notConnected", or "unknown". + */ + status: string; + /** + * A JSON object that contains the properties of the current session. + */ + session: ISession; + } + + /** + * Represents the Microsoft.Live.API.Event object. + */ + interface IEventAPI { + /** + * Adds a handler to an event. + * @param event Required. The name of the event to which to add a + * handler. + * @param callback Required. Specifies the name of the callback function + * to handle the event. + * @returns This function can return the following errors: + * WL.Event.subscribe: The input parameter/property 'callback' must be + * included. + * WL.Event.subscribe: The input value for parameter/property 'event' + * is not valid. + */ + subscribe(event: string, callback: Function): void; + /** + * Removes a handler from an event. + * @param event Required. The name of the event from which to remove a + * handler. + * @param callback Optional. Removes the callback function from the + * event. If this parameter is omitted or is null, all callback + * functions that are registered to the event are removed. Removes the + * callback function from the specified event. + */ + unsubscribe(event: string, callback?: Function): void; + } + + /** + * Returned from a successful file picker operation. + */ + interface IFilePickerResult { + /** + * Contains data concerning the user's picked files. + */ + data: { + /** + * Information on files choden in the picker. + */ + files?: IFile[]; + /** + * Information on folders chosen in the picker. + */ + folders?: IFolder[]; + } + } + + /** + * The promise API implemented by this library. + */ + interface IPromise { + /** + * Adds event listeners for particular events. + * @param onSuccess Called when the promised event successfully occurs. + * @param onError Called when the promised event fails to occur. Could + * be an IError or an IJSError. + * @param onProgress Called to indicate that the promised event is + * making progress toward completion. + */ + then(onSuccess: (response: T) => void, + onError?: (error: any) => void, + onProgress?: (progress: any) => void): IPromise; + /** + * Cancels the pending request represented by the Promise, and triggers + * the error callback if the promised event has not yet occurred. + */ + cancel(): void; + } + + /** + * An error returned by the JavaScript library, as opposed to an error + * object from the REST API (which we represent with IError). + */ + interface IJSError { + /** + * The error code. + */ + error: string; + /** + * A description of the error. + */ + error_description: string; + } + + /** + * The Live Connect JavaScript API (Windows 8 and web), together with the + * REST API, enables apps to read, update, and share user data by using the + * JavaScript programming language. The JavaScript API (Windows 8 and web) + * provides methods for signing users in and out, getting user status, + * subscribing to events, creating UI controls, and calling the + * Representational State Transfer (REST) API. + */ + interface API { + /** + * Makes a call to the Live Connect Representational State Transfer + * (REST) API. This method encapsulates a REST API request, and then + * calls a callback function to process the response. + * @param properties Required. A JSON object that contains properties + * that are necessary to make the REST API call. + * @param callback Specifies a callback function that is executed when + * the REST API call is complete. The callback function takes the API + * response object as a parameter. The response object exposes the + * data returned from Live Connect, or, if an error occurs, an error + * property that contains the error code. + * @returns Returns a Promise object. This object's then method provides + * the onSuccess, onError, and onProgress parameters to enable your + * code to handle a successful, failed, and in-progress call to the + * corresponding WL.api method, respectively. + */ + api(properties: IAPIProperties, + callback?: (response: any) => void): IPromise; + /** + * Makes a call to download a file from Microsoft SkyDrive. + * + * **Important**: WL.backgroundDownload is supported only for use with + * Windows Store apps using JavaScript. If you are writing a web app, + * use WL.download instead. + * @param properties Required. A JSON object that contains properties + * that are necessary to make the REST API call. + * @param Optional. Specifies a callback function that is executed when + * the REST API call is complete. The callback function takes the API + * response object as a parameter. The response object exposes the + * data that is returned from Live Connect, or, if an error occurs, an + * error property that contains the error code. + * @returns Returns a Promise object. This object's then method accepts + * callback functions for onSuccess, onError, and onProgress to enable + * your code to handle a successful, failed, and in-progress call to + * the corresponding WL.download method, respectively. + * The onSuccess callback is passed a response object that contains + * content_type and stream properties, representing the downloaded + * file's content type and file stream, respectively. + */ + backgroundDownload(properties: IBackgroundDownloadProperties, + callback?: (response: any) => void): IPromise; + /** + * Makes a call to upload a file to Microsoft SkyDrive. + * + * **Important**: WL.backgroundUpload is supported only for use with + * Windows Store apps using JavaScript. If you are writing a web app, + * use WL.upload instead. + * @param properties Required. A JSON object that contains properties + * that are necessary to make the REST API call. + * @param callback Optional. Specifies a callback function that is + * executed when the REST API call is complete. The callback function + * takes the API response object as a parameter. The response object + * exposes the data returned from Live Connect, or if an error occurs, + * an error property that contains the error code. + * @returns Returns a Promise object. For Windows Store apps using + * JavaScript, this object's then method accepts callback functions + * for onSuccess, onError, and onProgress to enable your code to + * handle a successful, failed, and in-progress call to the + * corresponding WL.backgroudUpload method, respectively. + */ + backgroundUpload(properties: IBackgroundUploadProperties, + callback?: (response: any) => void): IPromise; + /** + * Specifies whether the current user can be signed out of his or her + * Microsoft account. + * + * For Windows Store apps using JavaScript, you can use this function to + * determine whether you should display a control to the user to enable + * him or her to sign out of his or her Microsoft account. If this + * function returns true, you should display the control. However, if + * this function returns false, you should not display this control, as + * attempting to sign out the user in this case will have no effect. + * + * For web apps, this function always returns true. + * @returns Returns true if the user can be signed out; otherwise, + * returns false if the user can't be signed out. + */ + canLogout(): boolean; + /** + * Makes a call to download a file from Microsoft SkyDrive. + * + * **Important**: WL.download is supported only for use with web apps. + * If you are writing a Windows Store app using JavaScript, use + * WL.backgroundDownload instead. + * @param properties Required. A JSON object that contains properties + * that are necessary to make the REST API call. + * @param callback Specifies a callback function that is executed when + * the REST API call is complete. The callback function takes the API + * response object as a parameter. The response object exposes the + * data that is returned from Live Connect, or, if an error occurs, an + * error property that contains the error code. + * @returns Returns a Promise object. This object's then method provides + * the onError parameter to enable your code to handle a failed call + * to the corresponding WL.download method. + */ + download(properties: IDownloadProperties, + callback?: (response: any) => void): IPromise; + Event: IEventAPI; + /** + * Displays the Microsoft SkyDrive file picker, which enables + * JavaScript-based web apps to display a pre-built, consistent user + * interface that enables a user to select files to upload and download + * to and from his or her SkyDrive storage location. + * @param properties Required. A JSON object containing properties for + * displaying the button. + * @param callback Optional. A callback function that is executed after + * the user finishes interacting with the SkyDrive file picker. + * @returns Returns a Promise object. This object's then method provides + * the onSuccess and onError parameters to enable your code to handle + * a successful and failed call to the corresponding WL.fileDialog + * method, respectively. + */ + fileDialog(properties: IFileDialogProperties, + callback?: (response: any) => void): IPromise; + /** + * Returns the sign-in status of the current user. If the user is signed + * in and connected to your app, this function returns the session + * object. This is an asynchronous function that returns the user's + * status by contacting the Live Connect authentication web service. + * @param callback Returns the sign-in status of the current user. If + * the user is signed in and connected to your app, this function + * returns the session object. This is an asynchronous function that + * returns the user's status by contacting the Live Connect + * authentication web service. + * @param force Optional. If set to "true", the function contacts the + * Live Connect authentication web service to determine the user's + * status. If set to "false" (the default), the function can return + * the user status that is currently in memory, if there is one. If + * the user's status has already been retrieved, the library can + * return the cached value. However, you can force the library to + * retrieve current status by setting the force parameter to "true". + * @returns Returns a Promise object. This object's then method provides + * the onSuccess and onError parameters to enable your code to handle + * a successful and failed call to the corresponding WL.getLoginStatus + * method, respectively. + * In the body of the onSuccess function, a status object is returned, + * which contains the user's sign-in status and the session object. + */ + getLoginStatus(callback?: (status: ILoginStatus) => void, + force?: boolean): IPromise; + /** + * Retrieves the current session object synchronously, if a session + * object exists. For situations in which performance is critical, such + * as page loads, use the asynchronous WL.getLoginStatus method instead. + * @returns Returns the current session as a session object instance. + */ + getSession(): ISession; + /** + * Initializes the JavaScript library. An app must call this function on + * every page before making other function calls in the library. The app + * should call this function before making function calls that subscribe + * to events. If the JavaScript library has already been initialized on + * the page, calling this function succeeds silently; the client_id and + * redirect_uri parameters are not validated. + * @param properties Required. A JSON object with initialization + * properties. + * @returns Returns a Promise object. This object's then method provides + * the onSuccess and onError parameters to enable your code to handle + * a successful and failed call to the corresponding WL.init method, + * respectively. + * When the onSuccess callback is invoked, a login status object is + * passed in as parameter that indicates the current user's login + * status. + */ + init(properties: IInitProperties): IPromise; + /** + * Signs in the user or expands the user's list of scopes. Because this + * function can result in launching the consent page prompt, you should + * call it only in response to a user action, such as clicking a button. + * Otherwise, the user's web browser might block the popup. + * + * Typically, this function is used by apps that define their own + * sign-in controls, or by apps that ask users to grant additional + * permissions during an activity. For example, to enable a user to post + * his or her status to Live Connect, your app may have to prompt the + * user for permission and call this function with an expanded scope. + * + * If you call this function when the user has already consented to the + * requested scope and is already signed in, the callback function is + * invoked immediately with the current session. + * This function logs errors to the web browser console. + * @param properties Required. A JSON object with login properties. + * @param callback Optional. Specifies a callback function to execute + * when sign-in is complete. The callback function takes the status + * object as a parameter. For a description of the status object, see + * WL.getLoginStatus. If you do not specify a callback function, your + * app can still get the sign-in callback info by listening for an + * auth.sessionChange or auth.statusChange event. + * @returns Returns a Promise object. This object's then method provides + * the onSuccess, onError, and onProgress parameters to enable your + * code to handle a successful, failed, and in-progress call to the + * corresponding WL.login method, respectively. + */ + login(properties: ILoginProperties, + callback?: (status: any) => void): IPromise; + /** + * Signs the user out of Live Connect and clears any user state that is + * maintained by the JavaScript library, such as cookies. If the user + * account is connected, this function logs out the user from the app, + * but not from the PC. This function is useful primarily for websites + * that do not use the sign-in control. + * @param callback Optional. Specifies a callback function that is + * executed when sign-out is complete. The callback function takes the + * status object as a parameter. For a description of the status + * object, see WL.getLoginStatus. If you do not specify a callback + * function, your app can still get the sign-out callback info by + * listening for an auth.sessionChange or auth.statusChange event. + * @returns Returns a Promise object. This object's then method provides + * the onSuccess, onError, and onProgress parameters to enable your + * code to handle a successful, failed, and in-progress call to the + * corresponding WL.logout method, respectively. + */ + logout(callback?: (status: ILoginStatus) => void): IPromise; + /** + * Displays either the Live Connect sign-in button or the Microsoft + * SkyDrive file picker button. The sign-in button either prompts the + * user for his or her Microsoft account credentials if he or she is not + * signed in or else signs out the user if he or she is signed in. The + * file picker button displays the SkyDrive file picker to help the user + * select files to upload or download to or from his or her SkyDrive + * storage location. + * @param properties Required. A JSON object containing properties for + * displaying the button. + * @param callback Optional. A callback function that is executed after + * the sign-in button or file picker button is displayed. + * Note: Do not use the callback parameter to run code after the user + * finishes interacting with the sign-in button or file picker. Use a + * combination of the onselected, onloggedin, onloggedout, and onerror + * properties as previously described. + */ + ui(properties: IUIProperties, callback?: () => void): void; + /** + * Makes a call to upload a file to Microsoft SkyDrive. + * + * **Important**: WL.upload is supported only for use with web apps. If + * you are writing a Windows Store app using JavaScript, use + * WL.backgroundUpload instead. + * @param properties Required. A JSON object that contains properties + * that are necessary to make the REST API call. + * @param callback Optional. Specifies a callback function that is + * executed when the REST API call is complete. The callback function + * takes the API response object as a parameter. The response object + * exposes the data returned from Live Connect, or if an error occurs, + * an error property that contains the error code. + * @returns Returns a Promise object. This object's then method provides + * the onSuccess, onError, and onProgress parameters to enable your + * code to handle a successful, failed, and in-progress call to the + * corresponding WL.upload method, respectively; however, the + * onProgress parameter applies to newer web browsers such as Internet + * Explorer 10 only. + */ + upload(properties: IUploadProperties, + callback?: (response: any) => void): IPromise; + } +} + +/** + * The WL object is a global object that encapsulates all functions of the + * JavaScript API (Windows 8 and web). Your app uses the WL object to call all + * of the JavaScript API (Windows 8 and web) functions. + */ +declare var WL: Microsoft.Live.API; diff --git a/microsoft-live-connect/microsoft-live-connect.ts b/microsoft-live-connect/microsoft-live-connect.ts new file mode 100644 index 0000000000..98fcf5a3b7 --- /dev/null +++ b/microsoft-live-connect/microsoft-live-connect.ts @@ -0,0 +1,1048 @@ +/// + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550838.aspx + */ +function createFolder_onClick() { + var login_props: Microsoft.Live.ILoginProperties = { + scope: "wl.skydrive_update" + }; + WL.login(login_props).then( + function (response) { + var newFolder: Microsoft.Live.INewFolder = { + "name": "This is a new folder", + "description": "A new folder" + }, api_properties: Microsoft.Live.IAPIProperties = { + path: "me/skydrive", + method: "POST", + body: newFolder + }; + WL.api(api_properties).then( + function (response) { + document.getElementById("infoArea").innerText = + "Created folder. Name: " + response.name + ", ID: " + response.id; + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("infoArea").innerText = + "Error calling API: " + responseFailed.error.message; + } + ); + }, + function (responseFailed: Microsoft.Live.IJSError) { + document.getElementById("infoArea").innerText = + "Error signing in: " + responseFailed.error_description; + } + ); +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/jj219386.aspx + */ +function downloadFile_onClick() { + var picker = setupSavePicker(); + picker.pickSaveFileAsync().then( + function (file) { + if (file && (file instanceof Windows.Storage.StorageFile)) { + WL.login({ + scope: "wl.skydrive" + }).then( + function (response) { + WL.backgroundDownload({ + path: "file.8c8ce076ca27823f.8C8CE076CA27823F!129/picture?type=thumbnail", + file_output: file + }).then( + function (response) { + document.getElementById("infoLabel").innerText = "Downloaded file."; + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("infoLabel").innerText = + "Error calling API: " + responseFailed.error.message; + } + ); + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("infoLabel").innerText = + "Error signing in: " + responseFailed.error.message; + } + ); + } + else { + document.getElementById("infoLabel").innerText = "Cannot download file."; + } + }, + function (fileFailed) { + document.getElementById("infoLabel").innerText = "Cannot download file."; + } + ); +} + +function setupSavePicker() { + var savepicker = new Windows.Storage.Pickers.FileSavePicker(); + savepicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.documentsLibrary; + // XXX: Type hack for other typings. Apparently string[] isn't an IVector. + (savepicker.fileTypeChoices).insert("Picture", [".jpg"]); + return savepicker; +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/jj219387.aspx + */ +function uploadFile_onClick() { + var picker = setupOpenPicker(); + var filePickOp = picker.pickSingleFileAsync().then( + function (file) { + WL.login({ + scope: "wl.skydrive_update" + }).then( + function (response) { + WL.backgroundUpload({ + path: "me/skydrive", + file_name: file.name, + file_input: file, + overwrite: "rename" + }).then( + function (response) { + document.getElementById("infoLabel").innerText = "Uploaded file."; + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("infoLabel").innerText = + "Error calling API: " + responseFailed.error.message; + } + ); + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("infoLabel").innerText = + "Error signing in: " + responseFailed.error.message; + } + ); + }, + function (fileFailed) { + document.getElementById("infoLabel").innerText = "Cannot upload file."; + } + ); +} + +function setupOpenPicker() { + var openpicker = new Windows.Storage.Pickers.FileOpenPicker(); + openpicker.fileTypeFilter.replaceAll(["*"]); + return openpicker; +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550839.aspx + */ +function downloadFile() { + WL.login({ + scope: "wl.skydrive" + }).then( + function (response) { + WL.download({ + path: "file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!131/content" + }).then( + function (response) { + // Will not be called for web apps. + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error downloading file: " + responseFailed.error.message; + } + ); + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error signing in: " + responseFailed.error.message; + } + ); +} + +WL.Event.subscribe("auth.login", function () { }); +WL.Event.unsubscribe("auth.logout"); + +/** + * From: http://msdn.microsoft.com/en-us/library/live/jj219389.aspx + */ +function uploadFile_fileDialog() { + WL.fileDialog({ + mode: "save" + }).then( + function (response) { + WL.upload({ + path: response.data.folders[0].id, + element: "file", + overwrite: "rename" + }).then( + function (response) { + document.getElementById("info").innerText = + "File uploaded."; + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error uploading file: " + responseFailed.error.message; + } + ); + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error getting folder info: " + responseFailed.error.message; + } + ); +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550842.aspx + */ +function loginStatus() { + WL.getLoginStatus(function (response) { alert("Your status is: " + response.status) }); +} + +/** + * From http://msdn.microsoft.com/en-us/library/live/hh550843.aspx + */ +function onSessionChange() { + var session = WL.getSession(); + if (session) { + document.getElementById("infoLabel").innerText = + "Something about the session changed."; + } + else { + document.getElementById("infoLabel").innerText = + "Signed out or session error."; + } +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550844.aspx + */ +WL.init({ + client_id: "APP_CLIENT_ID", + redirect_uri: "REDIRECT_URL", + scope: "wl.signin", + response_type: "token" +}); +WL.init({ scope: "wl.signin" }); + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550845.aspx + */ +function streamlineAccountReg_onClick() { + WL.login({ + scope: ["wl.signin", "wl.basic", "wl.birthday", "wl.emails"] + }).then( + function (response) { + WL.api({ + path: "me", + method: "GET" + }).then( + function (response) { + document.getElementById("first_name").innerText = response.first_name; + document.getElementById("last_name").innerText = response.last_name; + document.getElementById("email").innerText = response.emails.preferred; + document.getElementById("gender").innerText = response.gender; + document.getElementById("birthday").innerText = + response.birth_month + " " + response.birth_day + " " + response.birth_year; + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("infoArea").innerText = + "Error calling API: " + responseFailed.error.message; + } + ); + }, + function (responseFailed: Microsoft.Live.IJSError) { + document.getElementById("infoArea").innerText = + "Error signing in: " + responseFailed.error_description; + } + ); +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550846.aspx + */ +function signUserOut() { + WL.logout(); +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550847.aspx + */ +var signInProps: Microsoft.Live.ISignInProperties = { + name: "signin", + element: "signin" +}; +WL.ui(signInProps); +var skyDriveProps: Microsoft.Live.ISkyDrivePickerProperies = { + name: "skydrivepicker", + element: "uploadFile_div", + mode: "save", + onselected: onUploadFileCompleted, + onerror: onUploadFileError +}; +WL.ui(skyDriveProps); + +function onUploadFileCompleted(response: Microsoft.Live.IFilePickerResult) { + WL.upload({ + path: response.data.folders[0].id, + element: "file", + overwrite: "rename" + }).then( + function (response) { + document.getElementById("info").innerText = + "File uploaded."; + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error uploading file: " + responseFailed.error.message; + } + ); +}; + +function onUploadFileError(response: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error getting folder info: " + response.error.message; +} +skyDriveProps = { + name: "skydrivepicker", + element: "downloadFile_div", + mode: "open", + select: "multi", + onselected: onDownloadFileCompleted, + onerror: onDownloadFileError +}; +WL.ui(skyDriveProps); + +function onDownloadFileCompleted(response: Microsoft.Live.IFilePickerResult) { + var msg = "", folder, file; + // For each folder selected... + if (response.data.folders.length > 0) { + for (folder = 0; folder < response.data.folders.length; folder++) { + // Use folder IDs to iterate through child folders and files as needed. + msg += "\n" + response.data.folders[folder].id; + } + } + // For each file selected... + if (response.data.files.length > 0) { + for (file = 0; file < response.data.files.length; file++) { + // Use file IDs to iterate through files as needed. + msg += "\n" + response.data.files[file].id; + } + } + document.getElementById("info").innerText = + "Selected folders/files:" + msg; +}; + +function onDownloadFileError(responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error getting folder/file info: " + responseFailed.error.message; +} + +/** + * From: http://msdn.microsoft.com/en-us/library/live/hh550848.aspx + */ +function uploadFile() { + WL.login({ + scope: "wl.skydrive_update" + }).then( + function (response) { + WL.upload({ + path: "folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!170", + element: "file", + overwrite: "rename" + }).then( + function (response) { + document.getElementById("info").innerText = + "File uploaded."; + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error uploading file: " + responseFailed.error.message; + } + ); + }, + function (responseFailed: Microsoft.Live.IError) { + document.getElementById("info").innerText = + "Error signing in: " + responseFailed.error.message; + } + ); +} + + +//#region From: http://msdn.microsoft.com/en-us/library/live/hh243648.aspx +/** + * This region contains REST object examples, and verifies that they pass + * type checking. + */ +var albumCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "album.8c8ce076ca27823f.8C8CE076CA27823F!126", + "from": { + "name": "Roberto Tamburello", + "id": "8c8ce076ca27823f" + }, + "name": "My Sample Album 1", + "description": "", + "parent_id": "folder.de57f4126ed7e411", + "upload_location": "https://apis.live.net/v5.0/folder.de57f4126ed7e411.DE57F4126ED7E411!126/files/", + "is_embeddable": true, + "count": 4, + "link": "https://cid-8c8ce076ca27823f.skydrive.live.com/redir.aspx?page\u003dself\u0026resid\u003d8C8CE076CA27823F!126\u0026type\u003d5", + "type": "album", + "shared_with": { + "access": "Everyone (public)" + }, + "created_time": "2011-04-21T23:19:47+0000", + "updated_time": "2011-04-22T19:18:12+0000", + // XXX: The API example documentation missed this property, but it has been wrong in the past... + "client_updated_time": "2011-04-22T19:18:12+0000", + } + ] +}; +var newAlbum: Microsoft.Live.INewAlbum = { + "name": "Vacation 2011", + "description": "Photos from our fun vacation." +}; +var audioCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!144", + "from": { + "name": "Stig Struve-Christensen", + "id": "a6b2a7e8f2515e5e" + }, + "name": "SampleAudio.mp3", + "description": null, + "parent_id": "folder.a6b2a7e8f2515e5e", + "size": 8414449, + "upload_location": "https://apis.live.net/v5.0/file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!144/content/", + "comments_count": 0, + "comments_enabled": false, + "is_embeddable": false, + "source": "http://storage.live.com/s1p60U8Xs4UzIXTScrTioalE-ZaVFiDQBA15MS2BwcsuNjfG64Z2fw-DAjXnPuqC47YR40_xAoPD8aRGhtna9ZFZ9_oO4BTz4CWF973DTXMxc5U3TntcQ9qEA/SampleAudio.mp3:Binary", + "link": "https://skydrive.live.com/redir.aspx?cid\u003d22688711f5410e6c\u0026page\u003dview\u0026resid\u003d22688711F5410E6C!582\u0026parid\u003d22688711F5410E6C!581", + "type": "audio", + "title": "My Sample Audio", + "artist": "My Favorite Artist", + "album": "My Favorite Album", + "album_artist": "My Favorite Artist", + "genre": "Easy Listening", + "duration": 225000, + "picture": "https://storage.live.com/items/A6B2A7E8F2515E5E!144:MobileReady/SampleAudio.mp3?psid=1&ck=0&ex=720", + "shared_with": { + "access": "Just me" + }, + "created_time": "2012-09-23T22:00:57+0000", + "updated_time": "2012-09-03T22:00:57+0000" + } + ] +}; + +var newAudioResponse: Microsoft.Live.INewFileResponse = { + "id": "ID of the new audio", + "name": "The file's name and file extension", + "source": "URL where the audio can be downloaded from" +}; + +var newAudio: Microsoft.Live.INewAudio = { + "name": "SampleAudioChanged.wav", + "description": "Holiday Concert" +}; + +var calendarCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "calendar.42d4dbc866f94c83849c88c6eb9985bc", + "name": "Birthday calendar", + "description": "If you have birthdays listed for your contacts, they'll appear on this calendar. You can add more birthdays, but you can't add other types of events.", + "created_time": "2011-08-05T19:41:04+0000", + "updated_time": "2011-08-05T19:41:04+0000", + "from": { + "name": null, + "id": null + }, + "is_default": false, + "subscription_location": null, + "permissions": "read" + } + ] +}; + +var newCalendar: Microsoft.Live.INewCalendar = { + "name": "Summer Events", + "summary": "Things we are doing this summer." +}; + +var newCalendarSub: Microsoft.Live.INewCalendarSubscription = { + "name": "Soccer League", + "subscription_location": "ical.sharedcalendars.com/98754auv" +}; + +var commentCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "comment.22688711f5410e6c.22688711f0410e6c!818.22688711F5410E6C!979", + "from": { + "name": "Roberto Tamburello", + "id": "8c8ce076ca27823f" + }, + "message": "A lighthouse built on some rocks.", + "created_time": "2011-04-21T23:21:28+0000" + } + ] +}; + +var newContact: Microsoft.Live.INewContact = { + "first_name": "", + "last_name": "", + "emails": { + "preferred": "", + "personal": "", + "business": "", + "other": "" + }, + "work": [ + { + "employer": { + "name": "" + } + } + ] +}; + +var contactCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "contact.b4466224b2ca42798c3d4ea90c75aa56", + "first_name": "Henrik", + "last_name": "Jensen", + "name": "Henrik Jensen", + "is_friend": false, + "is_favorite": false, + "user_id": null, + "email_hashes": [ + "9ecdb19f4eb8e04304c5d1280368c42e85b6e4fe39f08b0c837ec592b905a620", + "fc05492f50da6488aa14dcf221d395bcb29a4e43b43b250d60c68df4f831cad3" + ], + "updated_time": "2011-04-22T00:11:13+0000", + "birth_day": 29, + "birth_month": 3 + + } + ] +}; + +var errorObj: Microsoft.Live.IError = { + "error": { + "code": "request_token_expired", + "message": "The provided access token has expired." + } +}; + +var event: Microsoft.Live.IEvent = { + "id": "event.611afb17fa9448f28cdb8277e8ffeb77.e9f015000d0249ce847c5306a25d7d75", + "name": "Global Project Risk Management Meeting", + "description": "Generate and assess risks for the project", + "calendar_id": "calendar.611afb17fa9448f28cdb8277e8ffeb77", + "from": { + "name": "William Flash", + "id": "de57f4126ed7e411" + }, + "start_time": "2011-04-20T01:00:00+0000", + "end_time": "2011-04-20T02:00:00+0000", + "location": "Building 81, Room 9981, 123 Anywhere St., Redmond WA 19599", + "is_all_day_event": false, + "is_recurrent": false, + "recurrence": null, + "reminder_time": null, + "availability": "busy", + "visibility": "public", + "created_time": "2011-03-14T23:01:31+0000", + "updated_time": "2011-04-19T20:23:03+0000" +}; + +var newEvent: Microsoft.Live.INewEvent = { + "name": "Global Project Risk Management Meeting", + "description": "Generate and assess risks for the project", + "start_time": "2011-04-20T01:00:00-07:00", + "end_time": "2011-04-20T02:00:00-07:00", + "location": "Building 81, Room 9981, 123 Anywhere St., Redmond WA 19599", + "is_all_day_event": false, + "availability": "busy", + "visibility": "public" +}; + +var eventResponse: Microsoft.Live.INewEventResponse = { + "name": "Global Project Risk Management Meeting", + "description": "Generate and assess risks for the project", + "start_time": "2011-04-20T01:00:00+0000", + "end_time": "2011-04-20T02:00:00+0000", + "location": "Building 81, Room 9981, 123 Anywhere St., Redmond WA 19599", + "is_all_day_event": false, + "is_recurrent": false, + "recurrence": null, + "reminder_time": null, + "availability": "busy", + "visibility": "public", + "updated_time": "2011-04-19T20:23:03+0000" +}; + +var file: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "file.22688711f5410e6c.22688711F5410E6C!942", + "from": { + "name": "William Flash", + "id": "22688711f5410e6c" + }, + "name": "Processing.docx", + "description": null, + "parent_id": "folder.22688711f5410e6c.22688711F5410E6C!479", + "size": 12692, + "upload_location": "https://apis.live.net/v5.0/file.22688711f5410e6c.22688711F5410E6C!942/content/", + "comments_count": 0, + "comments_enabled": true, + "is_embeddable": false, + "source": "http://storage.live.com/s1pEwo9qzyT4_BJZqMNm-aVzgLo-WRsQGzjzFsXjyREuQG5pDYr237vKz3i2pmqFuniYPzsuIZAOCUMB_gdfKCUpLpVcaAMXGrk4T7jOWenRniCv9vex7GWfSvy-XCVBVnU/Processing.docx:Binary", + "link": "https://skydrive-df.live.com/redir.aspx?cid\u003d22688711f5410e6c\u0026page\u003dview\u0026resid\u003d22688711F5410E6C!942\u0026parid\u003d22688711F5410E6C!479", + "type": "file", + "shared_with": { + "access": "Everyone (public)" + }, + "created_time": "2011-10-12T23:18:23+0000", + "updated_time": "2011-10-12T23:18:23+0000", + // XXX: Not specified in example. Could be a bug in documentation, or maybe these are optional fields. + "client_updated_time": "2011-10-12T23:18:23+0000", + "sort_by": null + } + ] +}; + +var fileDownload: Microsoft.Live.IFileDownloadLink = { + "location": "..." +}; + +var newFileResponse: Microsoft.Live.INewFileResponse = { + "id": "file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!184", + "name":"MyNewFile.txt", + "source": "http://storage.live.com/s1pasGKzgXFvuEQCbxGtOyIpboUVH1OCHoRzUJNDDwL0zVoidb0RRrNVk88hUrOEve5OMT7eCkuxPbop7dV9tMJQ-eE8SCQ28vFv9ZgPnDGwQMRm-0FeG3-KEY4HL9dQSw9/MyNewFile.txt:Binary,Default/MyNewFile.txt" +}; + +var folderCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "folder.8c8ce076ca27823f.8C8CE076CA27823F!142", + "from": { + "name": "Roberto Tamburello", + "id": "8c8ce076ca27823f" + }, + "name": "My Sample Folder in Album 1", + "description": "", + "parent_id": "folder.de57f4126ed7e411", + "upload_location": "https://apis.live.net/v5.0/folder.de57f4126ed7e411.DE57F4126ED7E411!126/files/", + "is_embeddable": true, + "count": 3, + "link": "https://cid-8c8ce076ca27823f.skydrive.live.com/redir.aspx?page\u003dself\u0026resid\u003d8C8CE076CA27823F!142\u0026parid\u003d8C8CE076CA27823F!126\u0026type\u003d5", + "type": "folder", + "shared_with": { + "access": "Just me" + }, + "created_time": "2011-04-22T00:36:30+0000", + "updated_time": "2011-04-22T19:18:12+0000", + // XXX: Omitted in the example. + "client_updated_time": "???", + "sort_by": "???" + } + ] +}; + +var newFolder: Microsoft.Live.INewFolder = { + "name": "Informative Spreadsheets", + "description": "A folder full of useful data visualizations." +}; + +var friendCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "d09ea18fafc39a0c", + "name": "Henrik Jensen" + } + ] +}; + +var permissionsCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "wl.basic": 1, + "wl.offline_access": 1, + "wl.signin": 1 + } + ] +}; + +var photoCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "file.de57f4126ed7e411.DE57F4126ED7E411!128", + "from": { + "name": "Nuno Bento", + "id": "de57f4126ed7e411" + }, + "name": "Maui-2012_0034.JPG", + "description": null, + "parent_id": "folder.de57f4126ed7e411.DE57F4126ED7E411!126", + "size": 561683, + "comments_count": 1, + "comments_enabled": true, + "tags_count": 0, + "tags_enabled": true, + "is_embeddable": true, + "picture": "http://storage.live.com/s1pKk5vzd-gdPanbzKYhB0nQGn8wGq5DSgqvrgIHU1NTXA4e2-spGkAhQjW1d9pcgKAGLB4NsEsSvDoREmdx5w-JiFrinEJJuEoz08Ws_IFupkX2bPSvy5qmths9ijwvDrXi1OBCWk9GW9Kt-qNNOAA9g/Maui09_0034.JPG:Thumbnail", + "source": "http://storage.live.com/s1pKk5vzd-gdPanbzKYhB0nQGn8wGq5DSgqvrgIHU1NTXA4e2-spGkAhQjW1d9pcgKAGLB4NsEsSvDoREmdx5w-JiFrinEJJuEoz08Ws_IFupkX2bPSvy5qmths9ijwvDrXi1OBCWk9GW9Kt-qNNOAA9g/Maui09_0034.JPG:HighRes", + "upload_location": "https://apis.live.net/v5.0/file.de57f4126ed7e411.DE57F4126ED7E411!128/content/", + "images": [ + { + "height": 450, + "width": 600, + "source": "http://storage.live.com/s1pKk5vzd-gdPanbzKYhB0nQGn8wGq5DSgqvrgIHU1NTXA4e2-spGkAhQjW1d9pcgKAGLB4NsEsSvDoREmdx5w-JiFrinEJJuEoz08Ws_IFupkX2bPSvy5qmths9ijwvDrXi1OBCWk9GW9Kt-qNNOAA9g/Maui09_0034.JPG:WebReady", + "type": "normal" + }, { + "height": 132, + "width": 176, + "source": "http://storage.live.com/s1pKk5vzd-gdPanbzKYhB0nQGn8wGq5DSgqvrgIHU1NTXA4e2-spGkAhQjW1d9pcgKAGLB4NsEsSvDoREmdx5w-JiFrinEJJuEoz08Ws_IFupkX2bPSvy5qmths9ijwvDrXi1OBCWk9GW9Kt-qNNOAA9g/Maui09_0034.JPG:MobileReady", + "type": "album" + }, { + "height": 72, + "width": 96, + "source": "http://storage.live.com/s1pKk5vzd-gdPanbzKYhB0nQGn8wGq5DSgqvrgIHU1NTXA4e2-spGkAhQjW1d9pcgKAGLB4NsEsSvDoREmdx5w-JiFrinEJJuEoz08Ws_IFupkX2bPSvy5qmths9ijwvDrXi1OBCWk9GW9Kt-qNNOAA9g/Maui09_0034.JPG:Thumbnail", + "type": "thumbnail" + }, { + "height": 1200, + "width": 1600, + "source": "http://storage.live.com/s1pKk5vzd-gdPanbzKYhB0nQGn8wGq5DSgqvrgIHU1NTXA4e2-spGkAhQjW1d9pcgKAGLB4NsEsSvDoREmdx5w-JiFrinEJJuEoz08Ws_IFupkX2bPSvy5qmths9ijwvDrXi1OBCWk9GW9Kt-qNNOAA9g/Maui09_0034.JPG:HighRes", + "type": "full" + } + ], + "link": "https://skydrive.live.com/redir.aspx?cid\u003dde57f4126ed7e411\u0026page\u003dview\u0026resid\u003dDE57F4126ED7E411!128\u0026parid\u003dDE57F4126ED7E411!126", + "when_taken": "2008-03-24T23:41:53+0000", + "height": 1200, + "width": 1600, + "type": "photo", + "location": { + "latitude": 47.65316, + "longitude": -122.135911, + "altitude": 43 + }, + "camera_make": "MyManufacturer", + "camera_model": "MyModel", + "focal_ratio": 2.8, + "focal_length": 3.85, + "exposure_numerator": 1, + "exposure_denominator": 15, + "shared_with": { + "access": "Everyone (public)" + }, + "created_time": "2012-12-03T18:14:03+0000", + "updated_time": "2012-12-03T18:31:01+0000" + } + ] +}; + +var tag: Microsoft.Live.ITag = { + "id": "tag.22688711f5410e6c.22688711f5410e6c!767.PRaXZrdHI1uYGQYi9CU0StrzHak", + "user": { + "name": "Roberto Tamburello", + "id": "8c8ce076ca27823f" + }, + "x": 43.8986, + "y": 54.4138, + "created_time": "2011-04-22T01:17:00+0000" +}; + +var user: Microsoft.Live.IUser = { + "id": "8c8ce076ca27823f", + "name": "Roberto Tamburello", + "first_name": "Roberto", + "last_name": "Tamburello", + // XXX: Not in the REST API example, but is included in the WL.ui example. + "gender": null, + "link": "http://cid-8c8ce076ca27823f.profile.live.com/", + "birth_day": 20, + "birth_month": 4, + "birth_year": 2010, + "work": [ + { + "employer": { + "name": "Microsoft Corporation" + }, + "position": { + "name": "Software Development Engineer" + } + } + ], + "emails": { + "preferred": "Roberto@contoso.com", + "account": "Roberto@contoso.com", + "personal": "Roberto@fabrikam.com", + "business": "Robert@adatum.com", + "other": "Roberto@adventure-works.com" + }, + "addresses": { + "personal": { + "street": "123 Main St.", + "street_2": "Apt. A", + "city": "Redmond", + "state": "WA", + "postal_code": "12990", + "region": "United States" + }, + "business": { + "street": "456 Anywhere St.", + "street_2": "Suite 1", + "city": "Redmond", + "state": "WA", + "postal_code": "12399", + "region": "United States" + } + }, + "phones": { + "personal": "(555) 555-1212", + "business": "(555) 111-1212", + "mobile": null + }, + "locale": "en_US", + "updated_time": "2011-04-21T23:55:34+0000" +}; + +var videoCollection: Microsoft.Live.IObjectCollection = { + "data": [ + { + "id": "file.de57f4126ed7e411.DE57F4126ED7E411!135", + "from": { + "name": "Nuno Bento", + "id": "de57f4126ed7e411" + }, + "name": "Wildlife.wmv", + "description": null, + "parent_id": "folder.de57f4126ed7e411.DE57F4126ED7E411!126", + "size": 26246026, + "comments_count": 0, + "comments_enabled": true, + "tags_count": 0, + "tags_enabled": true, + "is_embeddable": true, + "picture": "http://storage.live.com/s1pKk5vzd-gdPaJ5Q1MKN34itsyRlUkAYzD_zsr0Dg-5r4bH8Qo8XRgsunA0M-V4G-XPpu1spowx4xwfjCuDcWQVa7aWld2WCdfeWjBK_coPqaQqzoE26BJP3OZAITB5i_DRPK8jK3ZLilSbNJd-onrOA/Wildlife.wmv:Thumbnail", + "source": "http://storage.live.com/s1pKk5vzd-gdPaJ5Q1MKN34itsyRlUkAYzD_zsr0Dg-5r4bH8Qo8XRgsunA0M-V4G-XPpu1spowx4xwfjCuDcWQVa7aWld2WCdfeWjBK_coPqaQqzoE26BJP3OZAITB5i_DRPK8jK3ZLilSbNJd-onrOA/Wildlife.wmv:VideoMain", + "upload_location": "https://apis.live.net/v5.0/file.de57f4126ed7e411.DE57F4126ED7E411!135/content/", + "link": "https://skydrive.live.com/redir.aspx?cid\u003dde57f4126ed7e411\u0026page\u003dview\u0026resid\u003dDE57F4126ED7E411!135\u0026parid\u003dDE57F4126ED7E411!126", + "height": 720, + "width": 1280, + "duration": 30093, + "bitrate": 5942130, + "type": "video", + "shared_with": { + "access": "Everyone (public)" + }, + "created_time": "2011-08-23T23:41:18+0000", + "updated_time": "2011-08-23T23:41:32+0000" + } + ] +}; +//#endregion From: http://msdn.microsoft.com/en-us/library/live/hh243648.aspx + +//#region From http://isdk.dev.live.com/dev/isdk/Default.aspx +/** + * The following code snippets were lifted from the Interactive Live SDK + * sandbox. We only include snippets that exercise portions of the API not + * already exercised above. + */ + +function log(message) { + var child = document.createTextNode(message); + var parent = document.getElementById('JsOutputDiv') || document.body; + parent.appendChild(child); + parent.appendChild(document.createElement("br")); +} + +function openFromSkyDrive() { + WL.fileDialog({ + mode: 'open', + select: 'single' + }).then( + function (response) { + log("The following file is being downloaded:"); + log(""); + + var files = response.data.files; + for (var i = 0; i < files.length; i++) { + var file = files[i]; + log(file.name); + WL.download({ "path": file.id + "/content" }); + } + }, + function (errorResponse) { + log("WL.fileDialog errorResponse = " + JSON.stringify(errorResponse)); + } + ); +} + +function saveToSkyDrive() { + WL.fileDialog({ mode: 'save' }).then( + function (response) { + var folder = response.data.folders[0]; + + WL.upload({ + path: folder.id, + element: 'save-to-skydrive-file-input', + overwrite: 'rename' + }).then( + function (response) { + log("You saved to " + response.source + ". " + + "Below is the result of the upload."); + log(""); + log(JSON.stringify(response)); + }, + function (errorResponse) { + log("WL.upload errorResponse = " + JSON.stringify(errorResponse)); + }, + function (progress) { + // progress events for the upload are raised here + } + ); + }, function (errorResponse) { + log("WL.fileDialog errorResponse = " + JSON.stringify(errorResponse)); + } + ); +} + +function getFiles() { + var files_path = "/me/skydrive/files"; + WL.api>({ path: files_path, method: "GET" }).then( + onGetFilesComplete, + function (response) { + log("Cannot get files and folders: " + + JSON.stringify(response.error).replace(/,/g, ",\n")); + } + ); +} + +// should have an interface that captures the fact that it only has type. +function onGetFilesComplete(response: Microsoft.Live.IObjectCollection) { + var items = response.data; + var foundFolder = 0; + for (var i = 0; i < items.length; i++) { + if (items[i].type === "folder") { + log("Found a folder with the following information: " + + JSON.stringify(items[i]).replace(/,/g, ",\n")); + foundFolder = 1; + break; + } + } + + if (foundFolder == 0) { + log("Unable to find any folders"); + } +} + +function registerUser() { + WL.api({ path: "/me", method: "GET" }).then( + function (response) { + fillRegistrationForm(response); + }, + function (response) { + log("API call failed: " + JSON.stringify(response.error).replace(/,/g, "\n")); + } + ); +} + +function fillRegistrationForm(user: Microsoft.Live.IUser) { + // NOTE: Assign these values to your form elements to streamline registration. + log("First name: " + user.first_name); + log("Last name: " + user.last_name); + log("Preferred email: " + user.emails.preferred); + log("Gender: " + user.gender); + log("Birthday: " + user.birth_month + "/" + user.birth_day + "/" + user.birth_year); +} + +function showUserContactInfo() { + WL.api({ path: "/me", method: "GET" }).then( + function (response) { + log("Addresses: " + JSON.stringify(response.addresses).replace(/,/g, "\n")); + log("Phone Numbers: " + JSON.stringify(response.phones).replace(/,/g, "\n")); + log("Email Addresses: " + JSON.stringify(response.emails).replace(/,/g, "\n")); + }, + function (response) { + log("API call failed: " + JSON.stringify(response.error).replace(/,/g, "\n")); + } + ); +} + +function enablePurchase(response) { + var date = new Date(); + var year = date.getFullYear(); + + WL.api({ path: "/me", method: "GET" }).then( + function (response) { + var user = response; + if (year - user.birth_year >= 18) { + log("Purchase enabled."); + } else { + log("Purchase disabled. You are only " + user.birth_year + " year(s) old."); + } + }, + function (response) { + log("API call failed: " + JSON.stringify(response.error).replace(/,/g, "\n")); + } + ); +} + +function createContact() { + var contact: Microsoft.Live.INewContact = { + first_name: "William", + last_name: "Flash" + }; + WL.api({ + path: "/me/contacts", + method: "POST", + body: contact + }).then( + function (response) { + log(JSON.stringify(response).replace(/,/g, ",\n")); + }, + function (response) { + log("Cannot create contact: " + + JSON.stringify(response.error).replace(/,/g, ",\n")); + } + ); +} + +function createEvent() { + var startTime = new Date(); + var endTime = new Date(startTime.getTime() + (60 * 60 * 1000)); + + log("Start time: " + startTime); + log("End time: " + endTime); + var newEvent: Microsoft.Live.INewEvent = { + name: "Family Dinner", + description: "Dinner with Cynthia's family", + start_time: startTime, + end_time: endTime, + location: "Coho Vineyard and Winery, 123 Main St., Redmond WA 98052", + is_all_day_event: false, + availability: "busy", + visibility: "public" + }; + + WL.api({ + path: "/me/events", + method: "POST", + body: newEvent + }).then( + function (response) { + log("Successfully created event. Response: " + + JSON.stringify(response).replace(/,/g, "\n")); + }, + function (response) { + log("Could not create event: " + + JSON.stringify(response.error).replace(/,/g, "\n")); + } + ); +} +//#endregion From http://isdk.dev.live.com/dev/isdk/Default.aspx From 586de634a88bf01828fc36fcf5d4c7a445701de9 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 18 Feb 2014 16:52:02 +0000 Subject: [PATCH 164/240] jQuery: JSDoc'd bind --- jquery/jquery-tests.ts | 2 +- jquery/jquery.d.ts | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 57ba838ee3..7177b13330 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -568,7 +568,7 @@ function test_bind() { $("form").bind("submit", function (event) { event.stopPropagation(); }); - $("p").bind("myCustomEvent", function (e, myName, myValue) { + $("p").bind("myCustomEvent", function (e, myName?, myValue?) { $(this).text(myName + ", hi there!"); $("span").stop().css("opacity", 1) .text("myName = " + myName) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 235022bf99..87f3a9afd5 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2028,12 +2028,42 @@ interface JQuery { */ toggle(showOrHide: boolean): JQuery; - // Events + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute each time the event is triggered. + */ bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ bind(eventType: string, preventBubble: boolean): JQuery; - bind(...events: any[]): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param events An object containing one or more DOM event types and functions to execute for them. + */ + bind(events: any): JQuery; blur(handler: (eventObject: JQueryEventObject) => any): JQuery; blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; From b4ce3c8e6eb6eadd9ba167c580b3afb1bb241bca Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 18 Feb 2014 16:56:14 +0000 Subject: [PATCH 165/240] jQuery: JSDoc'd blur --- jquery/jquery.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 87f3a9afd5..83f2288d0c 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2065,7 +2065,22 @@ interface JQuery { */ bind(events: any): JQuery; + /** + * Trigger the "blur" event on an element + */ + blur(): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ blur(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; /** From 83f6f736fdaab965c4c9aa8b9c417a0f0ee3dd81 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 18 Feb 2014 22:19:36 +0100 Subject: [PATCH 166/240] set to private :cold_sweat: --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 61c1dc6cdd..382b060bd2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { + "private": true, "name": "DefinitelyTyped", "version": "0.0.0", - "scripts": { - "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.5" - } + "scripts": { + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.5" + } } From a26949b652ef468890e5f480df704dfcee3af198 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 18 Feb 2014 22:29:59 +0100 Subject: [PATCH 167/240] added CONTRIBUTING.md with link to wiki --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..13053ce7ff --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +Please see the [contribution guide](https://github.com/borisyankov/DefinitelyTyped/wiki/How-to-contribute) for information on how to contribute to this project. From 3e989b586a25149ea5b8ce33e9ffe621525db1d8 Mon Sep 17 00:00:00 2001 From: jraymakers Date: Wed, 19 Feb 2014 09:18:16 -0800 Subject: [PATCH 168/240] underscore: remove 'extends {}' constraint from each and map --- underscore/underscore.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 41b634081b..10e4ccb23a 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -100,7 +100,7 @@ interface UnderscoreStatic { * @param iterator Iterator function for each property on `obj`. * @param context 'this' object in `iterator`, optional. **/ - each( + each( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): void; @@ -116,7 +116,7 @@ interface UnderscoreStatic { /** * @see _.each **/ - forEach( + forEach( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): void; @@ -142,7 +142,7 @@ interface UnderscoreStatic { * @param context `this` object in `iterator`, optional. * @return The mapped object result. **/ - map( + map( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): TResult[]; @@ -158,7 +158,7 @@ interface UnderscoreStatic { /** * @see _.map **/ - collect( + collect( object: _.Dictionary, iterator: _.ObjectIterator, context?: any): TResult[]; From d820bc739dfb068b00b620f7d7b675bfe16de425 Mon Sep 17 00:00:00 2001 From: pushplay Date: Wed, 19 Feb 2014 13:31:44 -0800 Subject: [PATCH 169/240] Added definitions for XSockets.net. --- xsockets/XSockets-tests.ts | 61 ++++++++++++++++++++++++++++ xsockets/XSockets-tests.ts.tscparams | 1 + xsockets/XSockets.d.ts | 38 +++++++++++++++++ xsockets/XSockets.d.ts.tscparams | 1 + 4 files changed, 101 insertions(+) create mode 100644 xsockets/XSockets-tests.ts create mode 100644 xsockets/XSockets-tests.ts.tscparams create mode 100644 xsockets/XSockets.d.ts create mode 100644 xsockets/XSockets.d.ts.tscparams diff --git a/xsockets/XSockets-tests.ts b/xsockets/XSockets-tests.ts new file mode 100644 index 0000000000..0b65bf9078 --- /dev/null +++ b/xsockets/XSockets-tests.ts @@ -0,0 +1,61 @@ +/// + +var conn = new XSockets.WebSocket('ws://localhost:4502/Generic'); + +conn.on(XSockets.Events.open,function (clientInfo) { + console.log('Open', clientInfo); +}); + +conn.on(XSockets.Events.onError, function (err) { + console.log('Error', err); +}); + +conn.on(XSockets.Events.close, function () { + console.log('Closed'); +}); + +conn.publish('foo', {text:'Hello Real-Time World'}); + +conn.on('foo', function(data) { + console.log('subscription to foo fired with data = ', data); +}); + +conn.unbind('foo'); + +conn.one('foo', function(data) { + console.log('subscription to foo fired with data = ', data); +}); + +conn.many('foo',4, function(data) { + console.log('subscription to foo fired with data = ', data); +}); + +conn.on('foo', function (data) { + console.log('subscription to foo fired with data = ', data); +}, function (confirmation) { + console.log('subscription confirmed',confirmation); + conn.publish('foo', { text: 'Hello Real-Time World' }); +}); + +conn.publish(XSockets.Events.storage.set, { + Key: "yourKey", + Value: { + Name: "John Doe", + Age: 40, + Likes: ["Beer", "Food", "Coffe"] + } +}); + +conn.publish(XSockets.Events.storage.remove, {Key: 'yourKey'}); + +conn.on(XSockets.Events.storage.getAll, function (data) { + data.forEach(function (item) { + console.log(item); + }); +}); + +conn.publish(XSockets.Events.storage.getAll, {}); + +conn.publish('set_MyProp',{value:'New Value'}); + +conn.on('get_MyProp',function(prop){console.log('Value Of MyProp',prop)}); \ No newline at end of file diff --git a/xsockets/XSockets-tests.ts.tscparams b/xsockets/XSockets-tests.ts.tscparams new file mode 100644 index 0000000000..3cc762b550 --- /dev/null +++ b/xsockets/XSockets-tests.ts.tscparams @@ -0,0 +1 @@ +"" \ No newline at end of file diff --git a/xsockets/XSockets.d.ts b/xsockets/XSockets.d.ts new file mode 100644 index 0000000000..b09e577a89 --- /dev/null +++ b/xsockets/XSockets.d.ts @@ -0,0 +1,38 @@ +// Type definitions for XSockets.NET 3.0 +// Project: http://xsockets.net/ +// Definitions by: Jeffery Grajkowski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module XSockets { + export class WebSocket { + id: string; + constructor(url: string, subprotocol?: string, settings?: any); + on(event: string, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void; + one(event: string, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void; + many(event: string, times: number, handler: (data: any) => void, confirmation?: (arg: ConfirmationArgument) => void): void; + unbind(event: string): void; + publish(topic: string, data: any): void; + } + export interface ConfirmationArgument { + event: string; + } + export module Events { + export var close: string; + export var onBlob: string; + export var onError: string; + export module bindings { + export var completed: string; + } + export var open: string; + export module pubSub { + export var subscribe: string; + export var unsubscribe: string; + } + export module storage { + export var get: string; + export var getAll: string; + export var remove: string; + export var set: string; + } + } +} diff --git a/xsockets/XSockets.d.ts.tscparams b/xsockets/XSockets.d.ts.tscparams new file mode 100644 index 0000000000..3cc762b550 --- /dev/null +++ b/xsockets/XSockets.d.ts.tscparams @@ -0,0 +1 @@ +"" \ No newline at end of file From e88a5272edae42666fd7121e84a774c7ce54e50b Mon Sep 17 00:00:00 2001 From: Paul Vick Date: Wed, 19 Feb 2014 22:05:35 -0800 Subject: [PATCH 170/240] Fixes for jake definitions * There were a couple of definitions that were missing type decorations that would infer "any" implicitly. * Exec had four constructors that the actual jake object doesn't seem to have. Exec objects are always created using createExec. * The methods implementing node's EventEmitter didn't match the actual EventEmitter signatures, so I updated them. --- jake/jake.d.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 349e08e52c..6995abc83c 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -114,7 +114,7 @@ declare module jake{ */ breakOnError?:boolean; } - export function exec(cmds:string[], callback?:()=>void, opts?:ExecOptions); + export function exec(cmds:string[], callback?:()=>void, opts?:ExecOptions):void; /** @@ -125,10 +125,6 @@ declare module jake{ * @event error When a shell-command */ export interface Exec extends NodeEventEmitter { - constructor(cmds:string[], callback?:()=>void, opts?:ExecOptions); - constructor(cmds:string[], opts?:ExecOptions, callback?:()=>void); - constructor(cmds:string, callback?:()=>void, opts?:ExecOptions); - constructor(cmds:string, opts?:ExecOptions, callback?:()=>void); append(cmd:string): void; run(): void; } @@ -208,11 +204,9 @@ declare module jake{ removeAllListeners(event?: string): NodeEventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; - emit(event: string, arg1?: any, arg2?: any): boolean; + emit(event: string, ...args: any[]): boolean; } - - export class DirectoryTask{ /** * @param name The name of the directory to create. @@ -275,7 +269,6 @@ declare module jake{ exclude(file:FileFilter[]): void; exclude(...file:FileFilter[]): void; - /** * Populates the FileList from the include/exclude rules with a list of * actual files @@ -377,12 +370,12 @@ declare module jake{ constructor(name:string, packageFiles:string[]); } - export function addListener(event: string, listener: Function); - export function on(event: string, listener: Function); - export function once(event: string, listener: Function): void; - export function removeListener(event: string, listener: Function): void; - export function removeAllListener(event: string): void; + export function addListener(event: string, listener: Function): NodeEventEmitter; + export function on(event: string, listener: Function): NodeEventEmitter; + export function once(event: string, listener: Function): NodeEventEmitter; + export function removeListener(event: string, listener: Function): NodeEventEmitter; + export function removeAllListener(event: string): NodeEventEmitter; export function setMaxListeners(n: number): void; - export function listeners(event: string): { Function; }[]; - export function emit(event: string, arg1?: any, arg2?: any): void; + export function listeners(event: string): Function[]; + export function emit(event: string, ...args: any[]): boolean; } From 6fccc6e510f8b4cf40246f205df906e1dac8d6a0 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Feb 2014 11:52:31 +0000 Subject: [PATCH 171/240] jQuery: fix to jquerymobile tests --- jquerymobile/jquerymobile-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquerymobile/jquerymobile-tests.ts b/jquerymobile/jquerymobile-tests.ts index 19231849f4..b28d308a02 100644 --- a/jquerymobile/jquerymobile-tests.ts +++ b/jquerymobile/jquerymobile-tests.ts @@ -71,7 +71,7 @@ function test_pagesDialogs() { } }); - $(document).bind("pagebeforechange", function (e, data) { + $(document).bind("pagebeforechange", function (e, data?) { if (typeof data.toPage === "string") { var u = $.mobile.path.parseUrl(data.toPage), re = /^#category-item/; From f4e9a367db89730a1b2acaf57dd7085815566e6b Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 20 Feb 2014 16:58:11 +0000 Subject: [PATCH 172/240] jQuery: and fixed Sammy too --- sammyjs/sammyjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sammyjs/sammyjs-tests.ts b/sammyjs/sammyjs-tests.ts index da0da616e8..1aa151d6ea 100644 --- a/sammyjs/sammyjs-tests.ts +++ b/sammyjs/sammyjs-tests.ts @@ -422,7 +422,7 @@ function test_misc() { }); store = new Sammy.Store({ name: 'kvo' }); - $('body').bind('set-kvo-foo', function (e, data) { + $('body').bind('set-kvo-foo', function (e, data?) { Sammy.log(data.key + ' changed to ' + data.value); }); store.set('foo', 'bar'); From b875f439c4ff0e191c5a6a64d70bd6b029cfcca9 Mon Sep 17 00:00:00 2001 From: SomaticIT Date: Fri, 21 Feb 2014 01:04:46 +0100 Subject: [PATCH 173/240] Add moment amd definition (require shim) --- moment/moment.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 4bc63c8075..0d7affcb2d 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -324,3 +324,7 @@ interface MomentStatic { } declare var moment: MomentStatic; + +declare module "moment" { + export = moment; +} From 699ad8ec9f041b12d923b9f76df6b89fcd0a3377 Mon Sep 17 00:00:00 2001 From: david pichsenmeister Date: Fri, 21 Feb 2014 15:03:21 +0100 Subject: [PATCH 174/240] added tests --- README.md | 1 + localForage/localForage-tests.ts | 34 ++++++++++++++++++++++++++++++++ localForage/localForage.d.ts | 6 +++--- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 localForage/localForage-tests.ts diff --git a/README.md b/README.md index ab4a8cdaef..2095f510bf 100755 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ List of Definitions * [Levelup](https://github.com/rvagg/node-levelup) (by [Bret Little](https://github.com/blittle)) * [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) * [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone)) +* [localForage](https://github.com/mozilla/localForage) (by [david pichsenmeister](https://github.com/3x14159265)) * [Lodash](http://lodash.com/) (by [Brian Zengel](https://github.com/bczengel)) * [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle)) * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts new file mode 100644 index 0000000000..f1a416dcf7 --- /dev/null +++ b/localForage/localForage-tests.ts @@ -0,0 +1,34 @@ +/// + +declare var localForage: lf.ILocalForage +declare var callback: lf.ICallback +declare var promise: lf.IPromise + +() => { + localForage.clear() + localForage.length + localForage.key(0) + + localForage.getItem("key", (str: string) => { + var newStr: string = str + }) + localForage.getItem("key").then((str: string) => { + var newStr: string = str + }) + + localForage.setItem("key", "value", (str: string) => { + var newStr: string = str + }) + localForage.setItem("key", "value").then((str: string) => { + var newStr: string = str + }) + + localForage.removeItem("key", (str: string) => { + var newStr: string = str + }) + localForage.removeItem("key").then((str: string) => { + var newStr: string = str + }) + + promise.then(callback) +} diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index 71ccaba3c2..c3d0371d00 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -8,11 +8,11 @@ declare module lf { clear(): void key(index: number): T length: number - getItem(key: string, callback: ICallback) + getItem(key: string, callback: ICallback): void getItem(key: string): IPromise - setItem(key: string, value: T, callback: ICallback) + setItem(key: string, value: T, callback: ICallback): void setItem(key: string, value: T): IPromise - removeItem(key: string, callback: ICallback) + removeItem(key: string, callback: ICallback): void removeItem(key: string): IPromise } From 301188b6bfb1f11461f65389de56e35025d1ede4 Mon Sep 17 00:00:00 2001 From: rmoudy Date: Fri, 21 Feb 2014 08:22:18 -0600 Subject: [PATCH 175/240] Update three.d.ts Added missing .userData property to Object3D --- threejs/three.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index e2e923f87f..2767570333 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1856,6 +1856,12 @@ declare module THREE { static defaultEulerOrder: string; // static defaultEulerOrder:EulerOrder; + + /** + * An object that can be used to store custom data about the Object3d. + * It should not hold references to functions as these will not be cloned. + */ + userData: any; } var Object3DIdCount: number; From bc8eb1b106a19fec56838bc471df1d12d16fef74 Mon Sep 17 00:00:00 2001 From: gscshoyru Date: Fri, 21 Feb 2014 11:21:32 -0500 Subject: [PATCH 176/240] Change resolver type to Function in lodash.d.ts Change to support functions with arbitrary number of inputs, not just one. --- lodash/lodash.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b40a59f2b1..0afd193702 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2672,7 +2672,7 @@ declare module _ { **/ memoize( func: T, - resolver?: (n: any) => string): T; + resolver?: Function): T; } //_.once From 3824f54c02943d5cd38a55c1dc9c08b9cdd50bde Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 22 Feb 2014 01:26:56 +0100 Subject: [PATCH 177/240] temporary removed link to tsdpm.com until Diullei updates the DNS to the github pages --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e94c6003f..2628d4b8f9 100755 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ See the section: [How to contribute](https://github.com/borisyankov/DefinitelyTy Other means to get the definitions ---------------------------------- * [NuGet packages](http://nuget.org/packages?q=DefinitelyTyped) -* [TypeScript definition package manager](https://github.com/Diullei/tsd) -* [tsdpm](http://www.tsdpm.com/) - Online search +* [TypeScript Definition package manager](https://github.com/DefinitelyTyped/tsd) List of Definitions ------------------- From cc33dd64a40e819db960a3b06c73bf7c0494163d Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 22 Feb 2014 19:51:18 +0100 Subject: [PATCH 178/240] fixed bluebird (dynamic version) mistake in test name added 'preliminary typings' note to definitions --- bluebird/{bluebird-test.ts => bluebird-tests.ts} | 0 bluebird/bluebird.d.ts | 10 ++++++++++ 2 files changed, 10 insertions(+) rename bluebird/{bluebird-test.ts => bluebird-tests.ts} (100%) diff --git a/bluebird/bluebird-test.ts b/bluebird/bluebird-tests.ts similarity index 100% rename from bluebird/bluebird-test.ts rename to bluebird/bluebird-tests.ts diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index c05f8b02b8..4706991439 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -3,6 +3,13 @@ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped +// note: these are preliminary typings using `any`: the generic versions are under construction, see: + +// https://github.com/borisyankov/DefinitelyTyped/issues/1563 + +// https://github.com/borisyankov/DefinitelyTyped/tree/def/bluebird + + declare module Bluebird { interface ArrayLike { @@ -496,3 +503,6 @@ declare module Bluebird { filter(values:any[], filterer:(item:any, index?:number, arrayLength?:number) => any):Promise; } } +declare module 'bluebird' { + export = Bluebird; +} From 4ce66d41dc3973d29da86786e161c6c2306f94bc Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 22 Feb 2014 21:19:54 +0100 Subject: [PATCH 179/240] Fixed gruntjs done() callback signature --- gruntjs/gruntjs-tests.ts | 15 +++++++++++++-- gruntjs/gruntjs.d.ts | 7 ++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gruntjs/gruntjs-tests.ts b/gruntjs/gruntjs-tests.ts index f36b74d764..853cac370b 100644 --- a/gruntjs/gruntjs-tests.ts +++ b/gruntjs/gruntjs-tests.ts @@ -42,9 +42,20 @@ exports = (grunt: IGrunt) => { var valid = false; valid = valid && options.sourceRoot === "default"; valid = valid && currenttask.data.repeat > 0; - return valid; + + var done = this.async(); + done(); }); + grunt.registerMultiTask('task-1', "", function() { + var done = this.async(); + done(new Error('nope')); + }); + + grunt.registerMultiTask('task-2', "", function() { + var done = this.async(); + done(false); + }); // util methods var testOneArg = (a: number) => a * 2; @@ -61,4 +72,4 @@ exports = (grunt: IGrunt) => { fileMaps.length; fileMaps[0].src.length; fileMaps[0].dest; -}; \ No newline at end of file +}; diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index f601ce4fb6..cfe2825e41 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -816,9 +816,10 @@ declare module grunt { * Either false or an Error object may be passed to the done function * to instruct Grunt that the task has failed. */ - done(success: boolean): void; - done(error: Error): void; - done(result: any): void; + (success: boolean): void; + (error: Error): void; + (result: any): void; + (): void; } /** From c9007a305f2de31ead84ddd613f6635fdc33f43a Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:01:02 -0500 Subject: [PATCH 180/240] Adjusted the result type of ajax requests The generic result type of ajax requests were incorrect. Now adjusted with right values. --- rx.js/rx.jquery.d.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rx.js/rx.jquery.d.ts b/rx.js/rx.jquery.d.ts index f8513cf446..28183aa6f1 100644 --- a/rx.js/rx.jquery.d.ts +++ b/rx.js/rx.jquery.d.ts @@ -6,12 +6,18 @@ /// /// +interface RxJQueryResult { + data: T; + textStatus: string; + jqXHR: JQueryXHR; +} + interface JQueryStatic { - ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable; - getAsObservable(url: string, data: any, dataType: string): Rx.Observable; - getJSONAsObservable(url: string, data: any): Rx.Observable; - getScriptAsObservable(url: string, data: any): Rx.Observable; - postAsObservable(url: string, data: any, dataType: string): Rx.Observable; + ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable>; + getAsObservable(url: string, data: any, dataType: string): Rx.Observable>; + getJSONAsObservable(url: string, data: any): Rx.Observable>; + getScriptAsObservable(url: string, data: any): Rx.Observable>; + postAsObservable(url: string, data: any, dataType: string): Rx.Observable>; } interface JQuery { From 36ab9ba2a0bf62badeac14f2b71b7ed0c1718d26 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:05:19 -0500 Subject: [PATCH 181/240] Renamed RxJQueryResult to RxJQueryAjaxResult --- rx.js/rx.jquery.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rx.js/rx.jquery.d.ts b/rx.js/rx.jquery.d.ts index 28183aa6f1..f2dcb284a7 100644 --- a/rx.js/rx.jquery.d.ts +++ b/rx.js/rx.jquery.d.ts @@ -6,18 +6,18 @@ /// /// -interface RxJQueryResult { +interface RxJQueryAjaxResult { data: T; textStatus: string; jqXHR: JQueryXHR; } interface JQueryStatic { - ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable>; - getAsObservable(url: string, data: any, dataType: string): Rx.Observable>; - getJSONAsObservable(url: string, data: any): Rx.Observable>; - getScriptAsObservable(url: string, data: any): Rx.Observable>; - postAsObservable(url: string, data: any, dataType: string): Rx.Observable>; + ajaxAsObservable(settings: JQueryAjaxSettings): Rx.Observable>; + getAsObservable(url: string, data: any, dataType: string): Rx.Observable>; + getJSONAsObservable(url: string, data: any): Rx.Observable>; + getScriptAsObservable(url: string, data: any): Rx.Observable>; + postAsObservable(url: string, data: any, dataType: string): Rx.Observable>; } interface JQuery { From f8afb57dfec69aef8b5380442c0a144db881b862 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:23:20 -0500 Subject: [PATCH 182/240] Corrected Rx.IObservable => Rx.Observable The interface name changed in the RxJs definitions. Corrections reported here. --- knockout.rx/knockout.rx.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/knockout.rx/knockout.rx.d.ts b/knockout.rx/knockout.rx.d.ts index 2822b12f4f..f897bc7619 100644 --- a/knockout.rx/knockout.rx.d.ts +++ b/knockout.rx/knockout.rx.d.ts @@ -7,20 +7,20 @@ /// interface KnockoutSubscribableFunctions { - toObservable(event?: string): Rx.IObservable; - toObservable(event: string): Rx.IObservable; + toObservable(event?: string): Rx.Observable; + toObservable(event: string): Rx.Observable; } interface KnockoutObservableFunctions { - toObservableWithReplyLatest(): Rx.IObservable; + toObservableWithReplyLatest(): Rx.Observable; } interface KnockoutComputedFunctions { - toObservableWithReplyLatest(): Rx.IObservable; + toObservableWithReplyLatest(): Rx.Observable; } declare module Rx { - interface IObservable { + interface Observable { toKoSubscribable(): KnockoutSubscribable; toKoObservable(initialValue?: T): KnockoutObservable; } From 9a2a6fd4323eee5f5339ee0c422e12b1ab4ba2c5 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Sun, 23 Feb 2014 10:28:13 -0500 Subject: [PATCH 183/240] Fixed unit test too --- knockout.rx/knockout.rx-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout.rx/knockout.rx-tests.ts b/knockout.rx/knockout.rx-tests.ts index 674e9bb6a4..21a0a52484 100644 --- a/knockout.rx/knockout.rx-tests.ts +++ b/knockout.rx/knockout.rx-tests.ts @@ -1,6 +1,6 @@ /// -var ax: Rx.IObservable; +var ax: Rx.Observable; var ao = ax.toKoObservable(); From 490945c9dc9ac88dd27fdd689c28f616d34896d5 Mon Sep 17 00:00:00 2001 From: Donny Nadolny Date: Sun, 23 Feb 2014 16:50:26 -0500 Subject: [PATCH 184/240] Create jquery.cycle2.d.ts --- README.md | 1 + jquery.cycle2/jquery.cycle2-tests.ts | 50 ++++++++++ jquery.cycle2/jquery.cycle2.d.ts | 143 +++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 jquery.cycle2/jquery.cycle2-tests.ts create mode 100644 jquery.cycle2/jquery.cycle2.d.ts diff --git a/README.md b/README.md index 1ad14a26c8..f18d6fee08 100755 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ List of Definitions * [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) * [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode)) * [jQuery.Cycle](http://jquery.malsup.com/cycle/) (by [François Guillot](http://fguillot.developpez.com/)) +* [jQuery.Cycle2](http://jquery.malsup.com/cycle2/) (by [Donny Nadolny](https://github.com/dnadolny)) * [jQuery.dataTables](http://www.datatables.net) (by [Armin Sander](https://github.com/pragmatrix)) * [jQuery.dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon)) * [jQuery.Flot](http://www.flotcharts.org/) (by [Matt Burland](https://github.com/burlandm)) diff --git a/jquery.cycle2/jquery.cycle2-tests.ts b/jquery.cycle2/jquery.cycle2-tests.ts new file mode 100644 index 0000000000..8a7eedf635 --- /dev/null +++ b/jquery.cycle2/jquery.cycle2-tests.ts @@ -0,0 +1,50 @@ +/// +/// + +// basic +$('#element').cycle(); + + +// code snippets from http://jquery.malsup.com/cycle2/api +$('.cycle-slideshow').cycle({ + speed: 600, + manualSpeed: 100 +}); + +var newSlide = ''; +$('.cycle-slideshow').cycle('add', newSlide); + +$('.cycle-slideshow').cycle('destroy'); + +// goto 3rd slide +$('.cycle-slideshow').cycle('goto', 2); + +$('.cycle-slideshow').cycle('next'); + +$('.cycle-slideshow').cycle('pause'); + +$('.cycle-slideshow').cycle('prev'); + +$('.cycle-slideshow').cycle('reinit'); + +// remove 2nd slide +$('.cycle-slideshow').cycle('remove', 1); + +$('.cycle-slideshow').cycle('resume'); + +$('.cycle-slideshow').cycle('stop'); + + +// from http://jquery.malsup.com/cycle2/demo/add.php +var images = [ + '', + '', + '' +]; + +$('button').one('click', function() { + for (var i=0; i < images.length; i++) { + $('.cycle-slideshow').cycle('add', images[i]); + } + $(this).prop('disabled', true) +}) diff --git a/jquery.cycle2/jquery.cycle2.d.ts b/jquery.cycle2/jquery.cycle2.d.ts new file mode 100644 index 0000000000..699d2aff87 --- /dev/null +++ b/jquery.cycle2/jquery.cycle2.d.ts @@ -0,0 +1,143 @@ +// Type definitions for jQuery Cycle2 version 2.1.2 (build 20140216) +// Project: http://jquery.malsup.com/cycle2/ (also https://github.com/malsup/cycle2) +// Definitions by: Donny Nadolny +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +interface JQuery { + cycle: JQueryCycle2.Cycle2; + + on(methodName: 'cycle-after', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, outgoingSlideEl: Element, incomingSlideEl: Element, forwardFlag: boolean) => void): JQuery; + on(methodName: 'cycle-before', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, outgoingSlideEl: Element, incomingSlideEl: Element, forwardFlag: boolean) => void): JQuery; + on(methodName: 'cycle-bootstrap', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, API: JQueryCycle2.API) => void): JQuery; + on(methodName: 'cycle-destroyed', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-finished', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-initialized', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-next', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-pager-activated', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-paused', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-post-initialize', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-pre-initialize', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-prev', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-resumed', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-slide-added', callback: (event: JQueryEventObject, jQueryWrappedSlideEl: JQuery) => void): JQuery; + on(methodName: 'cycle-slide-removed', callback: (event: JQueryEventObject, indexOfSlideRemoved: number, removedSlideEl: Element) => void): JQuery; + on(methodName: 'cycle-stopped', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-transition-stopped', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState) => void): JQuery; + on(methodName: 'cycle-update-view', callback: (event: JQueryEventObject, optionHash: JQueryCycle2.OptionsWithState, slideOptionsHash: JQueryCycle2.OptionsWithState, currentSlideEl: Element) => void): JQuery; +} + + +declare module JQueryCycle2 { + interface Cycle2 { + (options?: Options): JQuery; + (methodName: 'add', newSlide: any): JQuery; // string or JQuery + (methodName: 'destroy'): JQuery; + (methodName: 'goto', index: number): JQuery; + (methodName: 'next'): JQuery; + (methodName: 'pause'): JQuery; + (methodName: 'prev'): JQuery; + (methodName: 'reinit'): JQuery; + (methodName: 'remove', index: number): JQuery; + (methodName: 'resume'): JQuery; + (methodName: 'stop'): JQuery; + (methodNameDontCallMe: string, arg1DontCallMe: any, arg2DontCallMe: any): JQuery; // catch-all, shouldn't ever be called though + } + + interface Options { + allowWrap?: boolean; + autoHeight?: any; // number or string + autoSelector?: string; + caption?: string; + captionTemplate?: string; + continueAuto?: boolean; + delay?: number; + disabledClass?: string; + easing?: string; + fx?: string; + hideNonActive?: boolean; + loader?: any; // boolean or 'wait' + log?: boolean; + loop?: number; + manualSpeed?: number; + manualTrump?: boolean; + next?: string; + nextEvent?: string; + overlay?: string; + overlayTemplate?: string; + pager?: string; + pagerActivateClass?: string; + pagerEvent?: string; + pagerTemplate?: string; + pauseOnHover?: any; // boolean or string + paused?: boolean; + prev?: string; + prevEvent?: string; + progressive?: string; + random?: boolean; + reverse?: boolean; + slideActiveClass?: string; + slideCss?: any; + slideClass?: string; + slides?: string; + speed?: number; + startingSlide?: number; + swipe?: boolean; + sync?: boolean; + timeout?: number; + tmplRegex?: string; + updateView?: number; + } + + interface OptionsWithState extends Options { + busy: boolean; + currSlide: number; + nextSlide: number; + paused: boolean; + slideNum: number; + slideCount: number; + } + + interface API { + add(slides: any, prepend?: boolean): void; // string or array or JQuery + addInitialSlides(): void; + advanceSlide(numberOfOpositions: number): boolean; // always false + buildPagerLink(slideOptionHash: Options, slide: any /*not sure*/): void; + buildSlideOpts(slide: any /*not sure*/): Options; + calcFirstSlide(): void; + calcNextSlide(): void; + calcTx(slideOptions: Options, manual: boolean): Transition; + destroy(): void; + doTransition(slideOptions: Options, currEl: Element, nextEl: Element, fwdFlag: boolean, callback: Function): void; + getComponent(nameOfComponent: string): JQuery; + getSlideIndex(slideElement: Element): number; + getSlideOpts(slideIndex: number): Options; + goto(index: number): void; + initSlide(slideOptions: Options, slide: any /*not sure*/, suggestedZindex: number): void; + initSlideshow(): void; + log(...args: any[]): void; + next(): void; + page(pagerEl: Element, targetEl: Element): void; + pause(): void; + postInitSlideshow(): void; + preInitSlideshow(): void; + prepareTx(manualFlag: boolean, fwdFlag: boolean): void; + prev(): void; + queueTransition(slideOptions: Options): void; + reinit(): void; + remove(slideIndexToRemove: number): void; + resume(): void; + stackSlides(currEl: Element, nextEl: Element, fwdFlag: boolean): void; + stop(): void; + stopTransition(): void; + tmpl(templateString: string, optionHash: Options, slideEl: Element): void; + trigger(eventName: String, ...args: any[]): void; + updateView(): void; + } + + interface Transition { + before(opts: Options, curr: Element, next: Element, fwd: boolean): void; + } +} \ No newline at end of file From 35e573697c1613a4fa293a2ff4eab333f24032b8 Mon Sep 17 00:00:00 2001 From: vvakame Date: Mon, 24 Feb 2014 11:48:00 +0900 Subject: [PATCH 185/240] remove not required .tscparams --- firebase/firebase-tests.ts.tscparams | 1 - firebase/firebase.d.ts.tscparams | 1 - jake/jake.d.ts.tscparams | 1 - xsockets/XSockets.d.ts.tscparams | 1 - 4 files changed, 4 deletions(-) delete mode 100644 firebase/firebase-tests.ts.tscparams delete mode 100644 firebase/firebase.d.ts.tscparams delete mode 100644 jake/jake.d.ts.tscparams delete mode 100644 xsockets/XSockets.d.ts.tscparams diff --git a/firebase/firebase-tests.ts.tscparams b/firebase/firebase-tests.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/firebase/firebase-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/firebase/firebase.d.ts.tscparams b/firebase/firebase.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/firebase/firebase.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/jake/jake.d.ts.tscparams b/jake/jake.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/jake/jake.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" diff --git a/xsockets/XSockets.d.ts.tscparams b/xsockets/XSockets.d.ts.tscparams deleted file mode 100644 index 3cc762b550..0000000000 --- a/xsockets/XSockets.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" \ No newline at end of file From 50bc863d8c142aefda434259ca60b6781bb7b087 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 24 Feb 2014 14:49:28 +0000 Subject: [PATCH 186/240] jQuery: JSDoc'd unbind and added test suite --- jquery/jquery-tests.ts | 64 ++++++++++++++++++++++++++++++++++++++++++ jquery/jquery.d.ts | 23 +++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 7177b13330..37cf5495ec 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -590,6 +590,70 @@ function test_bind() { }); } +function test_unbind() { + $("#foo").unbind(); + + $("#foo").unbind("click"); + + var handler = function () { + alert("The quick brown fox jumps over the lazy dog."); + }; + $("#foo").bind("click", handler); + $("#foo").unbind("click", handler); + + $("#foo").bind("click", function () { + alert("The quick brown fox jumps over the lazy dog."); + }); + + // Will NOT work + $("#foo").unbind("click", function () { + alert("The quick brown fox jumps over the lazy dog."); + }); + + $("#foo").bind("click.myEvents", handler); + + $("#foo").unbind("click"); + + $("#foo").unbind("click.myEvents"); + + $("#foo").unbind(".myEvents"); + + var timesClicked = 0; + $("#foo").bind("click", function (event) { + alert("The quick brown fox jumps over the lazy dog."); + timesClicked++; + if (timesClicked >= 3) { + $(this).unbind(event); + } + }); + + function aClick() { + $("div").show().fadeOut("slow"); + } + $("#bind").click(function () { + $("#theone") + .bind("click", aClick) + .text("Can Click!"); + }); + $("#unbind").click(function () { + $("#theone") + .unbind("click", aClick) + .text("Does nothing..."); + }); + + $("p").unbind(); + + $("p").unbind("click"); + + var foo = function () { + // Code to handle some kind of event + }; + + $("p").bind("click", foo); // ... Now foo will be called when paragraphs are clicked ... + + $("p").unbind("click", foo); // ... foo will no longer be called. +} + function test_blur() { $('#target').blur(function () { alert('Handler for .blur() called.'); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 83f2288d0c..76e5172f33 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2605,10 +2605,33 @@ interface JQuery { */ trigger(event: JQueryEventObject, extraParameters?: Object): JQuery; + /** + * Execute all handlers attached to an element for an event. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters An array of additional parameters to pass along to the event handler. + */ triggerHandler(eventType: string, ...extraParameters: any[]): Object; + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param handler The function that is to be no longer executed. + */ unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). + */ unbind(eventType: string, fls: boolean): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param evt A JavaScript event object as passed to an event handler. + */ unbind(evt: any): JQuery; undelegate(): JQuery; From 69f36f7e0bbf6bd29415b5a609588c5f7d5286c4 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 24 Feb 2014 14:57:10 +0000 Subject: [PATCH 187/240] jQuery: JSDoc'd undelegate added delegate / undelegate test suites --- jquery/jquery-tests.ts | 46 +++++++++++++++++++++++++++++++++++++++--- jquery/jquery.d.ts | 25 +++++++++++++++++++++-- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 37cf5495ec..cfd4ae56f4 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1183,7 +1183,6 @@ function test_delay() { }); } -/* Not existing, but not recommended either function test_delegate() { $("table").delegate("td", "click", function () { $(this).toggleClass("chosen"); @@ -1201,7 +1200,7 @@ function test_delegate() { $("body").delegate("a", "click", function (event) { event.preventDefault(); }); - $("body").delegate("p", "myCustomEvent", function (e, myName, myValue) { + $("body").delegate("p", "myCustomEvent", function (e, myName?, myValue?) { $(this).text("Hi there!"); $("span").stop().css("opacity", 1) .text("myName = " + myName) @@ -1211,7 +1210,48 @@ function test_delegate() { $("p").trigger("myCustomEvent"); }); } -*/ + +function test_undelegate() { + function aClick() { + $("div").show().fadeOut("slow"); + } + $("#bind").click(function () { + $("body") + .delegate("#theone", "click", aClick) + .find("#theone").text("Can Click!"); + }); + $("#unbind").click(function () { + $("body") + .undelegate("#theone", "click", aClick) + .find("#theone").text("Does nothing..."); + }); + + $("p").undelegate(); + + $("p").undelegate("click"); + + var foo = function () { + // Code to handle some kind of event + }; + + // ... Now foo will be called when paragraphs are clicked ... + $("body").delegate("p", "click", foo); + + // ... foo will no longer be called. + $("body").undelegate("p", "click", foo); + + var foo = function () { + // Code to handle some kind of event + }; + + // Delegate events under the ".whatever" namespace + $("form").delegate(":button", "click.whatever", foo); + + $("form").delegate("input[type='text'] ", "keypress.whatever", foo); + + // Unbind all events delegated under the ".whatever" namespace + $("form").undelegate(".whatever"); +} function test_dequeue() { $("button").click(function () { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 76e5172f33..329e0a177e 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2634,9 +2634,30 @@ interface JQuery { */ unbind(evt: any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + */ undelegate(): JQuery; - undelegate(selector: any, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; - undelegate(selector: any, events: any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param eventType A string containing a JavaScript event type, such as "click" or "keydown" + * @param handler A function to execute at the time the event is triggered. + */ + undelegate(selector: string, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param events An object of one or more event types and previously bound functions to unbind from them. + */ + undelegate(selector: string, events: Object): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param namespace A string containing a namespace to unbind all events from. + */ undelegate(namespace: string): JQuery; unload(handler: (eventObject: JQueryEventObject) => any): JQuery; From 99468aa382e6b3662a0d06006d139cab8ae9f90e Mon Sep 17 00:00:00 2001 From: Gabriele Genta Date: Mon, 24 Feb 2014 16:24:46 +0100 Subject: [PATCH 188/240] Made every type declaration explicit to prevent compilation errors when using the --noImplicitAny switch. --- restangular/restangular.d.ts | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index f6ea5b97b1..a5b7de20d9 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -24,46 +24,46 @@ interface Restangular extends RestangularCustom { all(route: string): RestangularCollection; allUrl(route: string, url: string): RestangularCollection; copy(fromElement: any): RestangularElement; - withConfig(configurer: (RestangularProvider) => any): Restangular; - restangularizeElement(parent: any, element: any, route: string, collection?, reqParams?): RestangularElement; + withConfig(configurer: (RestangularProvider: RestangularProvider) => any): Restangular; + restangularizeElement(parent: any, element: any, route: string, collection?: any, reqParams?: any): RestangularElement; restangularizeCollection(parent: any, element: any, route: string): RestangularCollection; stripRestangular(element: any): any; } interface RestangularElement extends Restangular { - get (queryParams?: any, headers?: any): ng.IPromise; + get(queryParams?: any, headers?: any): ng.IPromise; getList(subElement: any, queryParams?: any, headers?: any): ng.IPromise; put(queryParams?: any, headers?: any): ng.IPromise; - post(subElement, elementToPost, queryParams?, headers?): ng.IPromise; - remove(queryParams?, headers?): ng.IPromise; - head(queryParams?, headers?): ng.IPromise; - trace(queryParams?, headers?): ng.IPromise; - options(queryParams?, headers?): ng.IPromise; - patch(queryParams?, headers?): ng.IPromise; + post(subElement: any, elementToPost: any, queryParams?: any, headers?: any): ng.IPromise; + remove(queryParams?: any, headers?: any): ng.IPromise; + head(queryParams?: any, headers?: any): ng.IPromise; + trace(queryParams?: any, headers?: any): ng.IPromise; + options(queryParams?: any, headers?: any): ng.IPromise; + patch(queryParams?: any, headers?: any): ng.IPromise; withHttpConfig(httpConfig: RestangularRequestConfig): RestangularElement; getRestangularUrl(): string; } interface RestangularCollection extends Restangular { - getList(queryParams?, headers?): ng.IPromise; - post(elementToPost, queryParams?, headers?): ng.IPromise; - head(queryParams?, headers?): ng.IPromise; - trace(queryParams?, headers?): ng.IPromise; - options(queryParams?, headers?): ng.IPromise; - patch(queryParams?, headers?): ng.IPromise; - putElement(idx, params, headers): ng.IPromise; + getList(queryParams?: any, headers?: any): ng.IPromise; + post(elementToPost: any, queryParams?: any, headers?: any): ng.IPromise; + head(queryParams?: any, headers?: any): ng.IPromise; + trace(queryParams?: any, headers?: any): ng.IPromise; + options(queryParams?: any, headers?: any): ng.IPromise; + patch(queryParams?: any, headers?: any): ng.IPromise; + putElement(idx: any, params: any, headers: any): ng.IPromise; withHttpConfig(httpConfig: RestangularRequestConfig): RestangularCollection; getRestangularUrl(): string; } interface RestangularCustom { - customGET(path, params?, headers?): ng.IPromise; - customGETLIST(path, params?, headers?): ng.IPromise; - customDELETE(path, params?, headers?): ng.IPromise; - customPOST(path, params?, headers?, elem?): ng.IPromise; - customPUT(path, params?, headers?, elem?): ng.IPromise; - customOperation(operation, path, params?, headers?, elem?): ng.IPromise; - addRestangularMethod(name, operation, path?, params?, headers?, elem?): ng.IPromise; + customGET(path: string, params?: any, headers?: any): ng.IPromise; + customGETLIST(path: string, params?: any, headers?: any): ng.IPromise; + customDELETE(path: string, params?: any, headers?: any): ng.IPromise; + customPOST(path: string, params?: any, headers?: any, elem?: any): ng.IPromise; + customPUT(path: string, params?: any, headers?: any, elem?: any): ng.IPromise; + customOperation(operation: string, path: string, params?: any, headers?: any, elem?: any): ng.IPromise; + addRestangularMethod(name: string, operation: string, path?: string, params?: any, headers?: any, elem?: any): ng.IPromise; } interface RestangularProvider { @@ -76,8 +76,8 @@ interface RestangularProvider { setOnElemRestangularized(callback: (elem: any, isCollection: boolean, what: string, restangular: Restangular) => any): void; setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred) => any): void; setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred) => any): void; - setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any); - setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any) => {element: any; headers: any; params: any}); + setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; + setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any) => {element: any; headers: any; params: any}): void; setErrorInterceptor(errorInterceptor: (response: RestangularResponse) => any): void; setRestangularFields(fields: {[fieldName: string]: string}): void; setMethodOverriders(overriders: string[]): void; From ee76deaaeff5ebb403d7319ffbbcc4f4cb3b6b98 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 25 Feb 2014 00:19:24 +0100 Subject: [PATCH 189/240] Fixed non-generic bluebird Changed structure, export to Promise --- bluebird/bluebird-tests.ts | 74 ++- bluebird/bluebird.d.ts | 993 ++++++++++++++++++------------------- 2 files changed, 526 insertions(+), 541 deletions(-) diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index 92e5e7b6b2..14528b9b57 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -1,5 +1,7 @@ /// +// Note: try to maintain the ordering and separators + var obj:Object; var bool:boolean; var num:number; @@ -15,32 +17,25 @@ var numArr:string[]; var value:any = null; var reason:any = null; -var Promise:Bluebird.PromiseStatic; +var promise:Promise; +var p:Promise; -var promise:Bluebird.Promise; -var p:Bluebird.Promise; - -var resolver:Bluebird.PromiseResolver; -var inspection:Bluebird.PromiseInspection; -var arrLike:Bluebird.ArrayLike; +var resolver:Promise.Resolver; +var inspection:Promise.Inspection; // - - - - - - - - - - - - - - - - - - - - - - - - var promise = new Promise((resolve:(value:any) => void, reject:(reason:any) => void) => { - if(true) { - resolve(123); - } - else { - reject(new Error('nope')); - } + if(true) { + resolve(123); + } + else { + reject(new Error('nope')); + } }); // - - - - - - - - - - - - - - - - - - - - - - - - -num = arrLike.length; - -// - - - - - - - - - - - - - - - - - - - - - - - - - resolver.resolve(x); resolver.reject(x); @@ -89,12 +84,12 @@ p = promise.caught((reason:any) => { }); p = promise.catch((reason:any) => { - return true; + return true; }, (reason:any) => { }); p = promise.caught((reason:any) => { - return true; + return true; }, (reason:any) => { }); @@ -219,43 +214,40 @@ p = promise.spread((value:any) => { }); p = promise.map((item:any, index:number, arrayLength:number) => { - return x; + return x; }); p = promise.reduce((total:number, memo:any, index:number, arrayLength:number) => { - return memo; + return memo; }); p = promise.reduce((total:number, memo:any, index:number, arrayLength:number) => { - return memo; + return memo; }, x); p = promise.filter((item:any, index?:number, arrayLength?:number) => { - return true; + return true; }); // - - - - - - - - - - - - - - - - - - - - - - - - p = new Promise((resolve:(value:any) => any, reject:(reason:any) => any) => { - if(true) { - resolve(value); - } - else { - reject(new Error('xyz')); - } + if(true) { + resolve(value); + } + else { + reject(new Error('xyz')); + } }); -p = Promise.try(() => {}); -p = Promise.try(() => {}, arr); -p = Promise.try(() => {}, arr, x); -p = Promise.try(() => {}, arrLike); -p = Promise.try(() => {}, arrLike, x); - +/* + p = Promise.try(() => {}); + p = Promise.try(() => {}, arr); + p = Promise.try(() => {}, arr, x); + */ p = Promise.attempt(() => {}); p = Promise.attempt(() => {}, arr); p = Promise.attempt(() => {}, arr, x); -p = Promise.attempt(() => {}, arrLike); -p = Promise.attempt(() => {}, arrLike, x); f = Promise.method(function() { @@ -312,16 +304,16 @@ p = Promise.some(arr, x); p = Promise.join(1, 2, 3); p = Promise.map(arr, (item:any, index:number, arrayLength:number) => { - return x; + return x; }); p = Promise.reduce(arr, (total:number, memo:any, index:number, arrayLength:number) => { - return memo; + return memo; }); p = Promise.reduce(arr, (total:number, memo:any, index:number, arrayLength:number) => { - return memo; + return memo; }, x); p = Promise.filter(arr, (item:any, index?:number, arrayLength?:number) => { - return true; + return true; }); diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index 4706991439..5db21d63ed 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -3,506 +3,499 @@ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped -// note: these are preliminary typings using `any`: the generic versions are under construction, see: - -// https://github.com/borisyankov/DefinitelyTyped/issues/1563 - -// https://github.com/borisyankov/DefinitelyTyped/tree/def/bluebird - - -declare module Bluebird { - - interface ArrayLike { - length:number; - } - - interface Promise { - /** - * Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. - */ - then(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any, progressHandler?:(note:any) => any):Promise; - - /** - * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. - * - * Alias `.caught();` for compatibility with earlier ECMAScript version. - */ - catch(handler:(reason:any) => any):Promise; - caught(handler:(reason:any) => any):Promise; - - /** - * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. - * - * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. - * - * Alias `.caught();` for compatibility with earlier ECMAScript version. - */ - //TODO expand this complex overload (weird) - catch(predicate:(reason:any) => boolean, handler:(reason:any) => any):Promise; - caught(predicate:(reason:any) => boolean, handler:(reason:any) => any):Promise; - - catch(ErrorClass:Function, handler:(reason:any) => any):Promise; - caught(ErrorClass:Function, handler:(reason:any) => any):Promise; - - /** - * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. - */ - error(rejectedHandler:(reason:any) => any):Promise; - - /** - * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. - * - * Alias `.lastly();` for compatibility with earlier ECMAScript version. - */ - finally(handler:(value:any) => any):Promise; - lastly(handler:(value:any) => any):Promise; - - /** - * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. - */ - bind(thisArg:any):Promise; - - /** - * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error. - */ - done(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any, progressHandler?:(note:any) => any):Promise; - - /** - * Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise. - */ - progressed(handler:(note:any) => any):Promise; - - /** - * Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - delay(ms:number):Promise; - - /** - * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance. - * - * You may specify a custom error message with the `message` parameter. - */ - - timeout(ms:number, message?:string):Promise; - - /** - * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. - * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything. - */ - nodeify(callback?:Function):Promise; - - /** - * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise. - */ - cancellable():Promise; - - /** - * Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending. - * - * That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason. - * - * In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`. - * - * Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable. - */ - cancel():Promise; - - /** - * Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors. - */ - fork(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any, progressHandler?:(note:any) => any):Promise; - - /** - * Create an uncancellable promise based on this promise. - */ - uncancellable():Promise; - - /** - * See if this promise can be cancelled. - */ - isCancellable():boolean; - - /** - * See if this `promise` has been fulfilled. - */ - isFulfilled():boolean; - - /** - * See if this `promise` has been rejected. - */ - isRejected():boolean; - - /** - * See if this `promise` is still defer. - */ - isPending():boolean; - - /** - * See if this `promise` is resolved -> either fulfilled or rejected. - */ - isResolved():boolean; - - /** - * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`. - */ - inspect():PromiseInspection; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName].call(obj, arg...); - * }); - * - */ - call(propertyName:string, ...args:any[]):Promise; - - /** - * This is a convenience method for doing: - * - * - * promise.then(function(obj){ - * return obj[propertyName]; - * }); - * - */ - get(propertyName:string):Promise; - - /** - * Convenience method for: - * - * - * .then(function() { - * return value; - * }); - * - * - * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()` - * - * Alias `.thenReturn();` for compatibility with earlier ECMAScript version. - */ - return(value:any):Promise; - thenReturn():Promise; - - /** - * Convenience method for: - * - * - * .then(function() { - * throw reason; - * }); - * - * Same limitations apply as with `.return()`. - * - * Alias `.thenThrow();` for compatibility with earlier ECMAScript version. - */ - throw(reason:any):Promise; - thenThrow():Promise; - - /** - * Convert to String. - */ - toString():string; - - /** - * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`. - */ - toJSON():Object; - - /** - * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - all():Promise; - - /** - * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - props():Promise; - - /** - * Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - settle():Promise; - - /** - * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - any():Promise; - - /** - * Same as calling `Promise.race(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - some(count:number):Promise; - - /** - * Same as calling `Promise.some(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - race():Promise; - - /** - * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. - */ - spread(fulfilledHandler?:(value:any) => any, rejectedHandler?:(reason:any) => any):Promise; - - /** - * Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - map(mapper:(item:any, index:number, arrayLength:number) => any):Promise; - - /** - * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - reduce(reducer:(total:number, current:any, index:number, arrayLength:number) => any, initialValue?:any):Promise; - - /** - * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. - */ - filter(filterer:(item:any, index:number, arrayLength:number) => any):Promise; - } - - interface PromiseResolver { - /** - * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state. - */ - resolve(value:any):void; - - /** - * Reject the underlying promise with `reason` as the rejection reason. - */ - reject(reason:any):void; - - /** - * Progress the underlying promise with `value` as the progression value. - */ - progress(value:any):void; - - /** - * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. - * - * If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values. - */ - callback:Function; - } - - interface PromiseInspection { - /** - * See if the underlying promise was fulfilled at the creation time of this inspection object. - */ - isFulfilled():boolean; - - /** - * See if the underlying promise was rejected at the creation time of this inspection object. - */ - isRejected():boolean; - - /** - * See if the underlying promise was defer at the creation time of this inspection object. - */ - isPending():boolean; - - /** - * Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object. - * - * throws `TypeError` - */ - value():any; - - /** - * Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object. - * - * throws `TypeError` - */ - error():any; - } - - interface PromiseStatic { - /** - * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. - */ - new(resolver:(resolve:(value:any) => void, reject:(reason:any) => any) => void):Promise; - - /** - * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. - * - * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call. - * - * Alias for `attempt();` for compatibility with earlier ECMAScript version. - */ - try(fn:() => any, args?:any[], ctx?:any):Promise; - try(fn:() => any, args?:ArrayLike, ctx?:any):Promise; - attempt(fn:() => any, args?:any[], ctx?:any):Promise; - attempt(fn:() => any, args?:ArrayLike, ctx?:any):Promise; - - /** - * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. - * This method is convenient when a function can sometimes return synchronously or throw synchronously. - */ - method(fn:Function):Function; - - /** - * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. - */ - resolve(value:any):Promise; - - /** - * Create a promise that is rejected with the given `reason`. - */ - reject(reason:any):Promise; - - /** - * Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?:Promise(#promise-resolution). - */ - defer():PromiseResolver; - - /** - * Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is:Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that:Promise assimilates the state of the thenable. - */ - cast(value:any):Promise; - - /** - * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. - */ - bind(thisArg:any):Promise; - - /** - * See if `value` is a trusted Promise. - */ - is(value:any):boolean; - - /** - * Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. - */ - longStackTraces():void; - - /** - * Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise. - */ - delay(value:Promise, ms:number):Promise; - delay(value:any, ms:number):Promise; - delay(ms:number):Promise; - - /** - * Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. - * - * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them. - * - * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. - */ - promisify(nodeFunction:Function, receiver?:any):Function; - - /** - * This overload has been **deprecated**. The overload will continue working for now. The recommended method for promisifying multiple methods at once is ``Promise.promisifyAll(Object target)`` - */ - promisify(target:Object):Object; - - /** - * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. - * - * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. - */ - promisifyAll(target:Object):Object; - - /** - * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. - */ - coroutine(generatorFunction:Function):Function; - - /** - * Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. - */ - spawn(generatorFunction:Function):Promise; - - /** - * This is relevant to browser environments with no module loader. - * - * Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else. - */ - noConflict():Object; - - /** - * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. - * - * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. - */ - onPossiblyUnhandledRejection(handler:(reason:any) => any):void; - - /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason. - */ - all(values:any[]):Promise; - - /** - * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. - * - * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. - * - * *The original object is not modified.* - */ - props(object:Promise):Promise; - props(object:Object):Promise; - - /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array. - * - * *original:The array is not modified. The input array sparsity is retained in the resulting array.* - */ - settle(values:any[]):Promise; - - /** - * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. - */ - any(values:any[]):Promise; - - /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. - * - * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. - */ - race(values:any[]):Promise; - - /** - * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. - * - * If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in. - * - * *The original array is not modified.* - */ - some(values:any[], count:number):Promise; - - /** - * Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments. - */ - join(...values:any[]):Promise; - - /** - * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. - * - * *The original array is not modified.* - */ - map(values:any[], mapper:(item:any, index:number, arrayLength:number) => any):Promise; - - /** - * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. - * - * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* - */ - reduce(values:any[], reducer:(total:number, current:any, index:number, arrayLength:number) => any, initialValue?:any):Promise; - - /** - * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. - * - * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result. - * - * *The original array is not modified. - */ - filter(values:any[], filterer:(item:any, index?:number, arrayLength?:number) => any):Promise; - } +// Note: these are preliminary non-generic typings using `any`: the generic versions are ready but need (tsc >= v1.0.0) due to issues in the compiler +// - https://github.com/borisyankov/DefinitelyTyped/issues/1563 +// - https://github.com/borisyankov/DefinitelyTyped/tree/def/bluebird/bluebird + +declare class Promise { + /** + * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. + */ + constructor(resolver: (resolve: (value: any) => void, reject: (reason: any) => any) => void); + /** + * Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. + */ + then(fulfilledHandler?: (value: any) => any, rejectedHandler?: (reason: any) => any, progressHandler?: (note: any) => any):Promise; + + /** + * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. + * + * Alias `.caught();` for compatibility with earlier ECMAScript version. + */ + catch(handler: (reason: any) => any):Promise; + caught(handler: (reason: any) => any):Promise; + + /** + * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. + * + * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. + * + * Alias `.caught();` for compatibility with earlier ECMAScript version. + */ + //TODO expand this complex overload (weird) + catch(predicate: (reason: any) => boolean, handler: (reason: any) => any): Promise; + caught(predicate: (reason: any) => boolean, handler: (reason: any) => any): Promise; + + catch(ErrorClass: Function, handler: (reason: any) => any): Promise; + caught(ErrorClass: Function, handler: (reason: any) => any): Promise; + + /** + * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. + */ + error(rejectedHandler: (reason: any) => any): Promise; + + /** + * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. + * + * Alias `.lastly();` for compatibility with earlier ECMAScript version. + */ + finally(handler: (value: any) => any): Promise; + lastly(handler: (value: any) => any): Promise; + + /** + * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. + */ + bind(thisArg: any): Promise; + + /** + * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error. + */ + done(fulfilledHandler?: (value: any) => any, rejectedHandler?: (reason: any) => any, progressHandler?: (note: any) => any): Promise; + + /** + * Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise. + */ + progressed(handler: (note: any) => any): Promise; + + /** + * Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + delay(ms: number): Promise; + + /** + * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance. + * + * You may specify a custom error message with the `message` parameter. + */ + + timeout(ms: number, message?: string): Promise; + + /** + * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. + * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything. + */ + nodeify(callback?: Function): Promise; + + /** + * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise. + */ + cancellable(): Promise; + + /** + * Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending. + * + * That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason. + * + * In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`. + * + * Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable. + */ + cancel(): Promise; + + /** + * Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors. + */ + fork(fulfilledHandler?: (value: any) => any, rejectedHandler?: (reason: any) => any, progressHandler?: (note: any) => any): Promise; + + /** + * Create an uncancellable promise based on this promise. + */ + uncancellable(): Promise; + + /** + * See if this promise can be cancelled. + */ + isCancellable(): boolean; + + /** + * See if this `promise` has been fulfilled. + */ + isFulfilled(): boolean; + + /** + * See if this `promise` has been rejected. + */ + isRejected(): boolean; + + /** + * See if this `promise` is still defer. + */ + isPending(): boolean; + + /** + * See if this `promise` is resolved -> either fulfilled or rejected. + */ + isResolved(): boolean; + + /** + * Synchronously inspect the state of this `promise`. The `Promise.Inspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`. + */ + inspect(): Promise.Inspection; + + /** + * This is a convenience method for doing: + * + * + * promise.then(function(obj){ + * return obj[propertyName].call(obj, arg...); + * }); + * + */ + call(propertyName: string, ...args: any[]): Promise; + + /** + * This is a convenience method for doing: + * + * + * promise.then(function(obj){ + * return obj[propertyName]; + * }); + * + */ + get(propertyName: string): Promise; + + /** + * Convenience method for: + * + * + * .then(function() { + * return value; + * }); + * + * + * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()` + * + * Alias `.thenReturn();` for compatibility with earlier ECMAScript version. + */ + return(value: any): Promise; + thenReturn(): Promise; + + /** + * Convenience method for: + * + * + * .then(function() { + * throw reason; + * }); + * + * Same limitations apply as with `.return()`. + * + * Alias `.thenThrow();` for compatibility with earlier ECMAScript version. + */ + throw(reason: any): Promise; + thenThrow(): Promise; + + /** + * Convert to String. + */ + toString(): string; + + /** + * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`. + */ + toJSON(): Object; + + /** + * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + all(): Promise; + + /** + * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + props(): Promise; + + /** + * Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + settle(): Promise; + + /** + * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + any(): Promise; + + /** + * Same as calling `Promise.race(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + some(count: number): Promise; + + /** + * Same as calling `Promise.some(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + race(): Promise; + + /** + * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. + */ + spread(fulfilledHandler?: (value: any) => any, rejectedHandler?: (reason: any) => any): Promise; + + /** + * Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + map(mapper: (item: any, index: number, arrayLength: number) => any): Promise; + + /** + * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + reduce(reducer: (total: number, current: any, index: number, arrayLength: number) => any, initialValue?: any): Promise; + + /** + * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + filter(filterer: (item: any, index: number, arrayLength: number) => any): Promise; } + +declare module Promise { + + interface Resolver { + /** + * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state. + */ + resolve(value: any): void; + + /** + * Reject the underlying promise with `reason` as the rejection reason. + */ + reject(reason: any): void; + + /** + * Progress the underlying promise with `value` as the progression value. + */ + progress(value: any): void; + + /** + * Gives you a callback representation of the `Promise.Resolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. + * + * If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values. + */ + callback:Function; + } + + interface Inspection { + /** + * See if the underlying promise was fulfilled at the creation time of this inspection object. + */ + isFulfilled(): boolean; + + /** + * See if the underlying promise was rejected at the creation time of this inspection object. + */ + isRejected(): boolean; + + /** + * See if the underlying promise was defer at the creation time of this inspection object. + */ + isPending(): boolean; + + /** + * Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object. + * + * throws `TypeError` + */ + value(): any; + + /** + * Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object. + * + * throws `TypeError` + */ + error(): any; + } + + /** + * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. + * + * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call. + * + * Alias for `attempt();` for compatibility with earlier ECMAScript version. + */ + // function try(fn: () => any, args?: any[], ctx?: any): Promise; + + function attempt(fn: () => any, args?: any[], ctx?: any): Promise; + + /** + * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. + * This method is convenient when a function can sometimes return synchronously or throw synchronously. + */ + function method(fn: Function): Function; + + /** + * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. + */ + function resolve(value: any): Promise; + + /** + * Create a promise that is rejected with the given `reason`. + */ + function reject(reason: any): Promise; + + /** + * Create a promise with undecided fate and return a `Promise.Resolver` to control it. See resolution?:Promise(#promise-resolution). + */ + function defer(): Promise.Resolver; + + /** + * Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is:Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that:Promise assimilates the state of the thenable. + */ + function cast(value: any): Promise; + + /** + * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. + */ + function bind(thisArg: any): Promise; + + /** + * See if `value` is a trusted Promise. + */ + function is(value: any): boolean; + + /** + * Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. + */ + function longStackTraces(): void; + + /** + * Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise. + */ + function delay(value: Promise, ms: number): Promise; + + function delay(value: any, ms: number): Promise; + + function delay(ms: number): Promise; + + /** + * Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. + * + * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them. + * + * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. + */ + function promisify(nodeFunction: Function, receiver?: any): Function; + + /** + * This overload has been **deprecated**. The overload will continue working for now. The recommended method for promisifying multiple methods at once is ``Promise.promisifyAll(Object target)`` + */ + function promisify(target: Object): Object; + + /** + * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. + * + * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. + */ + function promisifyAll(target: Object): Object; + + /** + * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. + */ + function coroutine(generatorFunction: Function): Function; + + /** + * Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. + */ + function spawn(generatorFunction: Function): Promise; + + /** + * This is relevant to browser environments with no module loader. + * + * Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else. + */ + function noConflict(): Object; + + /** + * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. + * + * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. + */ + function onPossiblyUnhandledRejection(handler: (reason: any) => any): void; + + /** + * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason. + */ + function all(values: any[]): Promise; + + /** + * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. + * + * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. + * + * *The original object is not modified.* + */ + function props(object: Promise): Promise; + + function props(object: Object): Promise; + + /** + * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``Promise.Inspection`` instances at respective positions in relation to the input array. + * + * *original:The array is not modified. The input array sparsity is retained in the resulting array.* + */ + function settle(values: any[]): Promise; + + /** + * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. + */ + function any(values: any[]): Promise; + + /** + * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. + * + * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. + */ + function race(values: any[]): Promise; + + /** + * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. + * + * If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in. + * + * *The original array is not modified.* + */ + function some(values: any[], count: number): Promise; + + /** + * Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments. + */ + function join(...values: any[]): Promise; + + /** + * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * + * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. + * + * *The original array is not modified.* + */ + function map(values: any[], mapper: (item: any, index: number, arrayLength: number) => any): Promise; + + /** + * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * + * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. + * + * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* + */ + function reduce(values: any[], reducer: (total: number, current: any, index: number, arrayLength: number) => any, initialValue?: any): Promise; + + /** + * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * + * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result. + * + * *The original array is not modified. + */ + function filter(values: any[], filterer: (item: any, index?: number, arrayLength?: number) => any): Promise; +} + declare module 'bluebird' { - export = Bluebird; +export = Promise; } From e49bdda008c4048e4dc6d79ad173a0a04a9f99ab Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Mon, 24 Feb 2014 17:33:22 -0800 Subject: [PATCH 190/240] create bigscreen.d.ts --- README.md | 1 + bigscreen/bigscreen-tests.ts | 23 +++++++++++++++++++++++ bigscreen/bigscreen.d.ts | 20 ++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 bigscreen/bigscreen-tests.ts create mode 100644 bigscreen/bigscreen.d.ts diff --git a/README.md b/README.md index 11e46c7cde..03f2122102 100755 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ List of Definitions * [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov)) * [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm)) +* [BigScreen](http://brad.is/coding/BigScreen/) (by [Douglas Eichelberger](https://github.com/dduugg)) * [Bluebird](https://github.com/petkaantonov/bluebird) (by [Bart van der Schoor](https://github.com/Bartvds)) * [Bootbox](https://github.com/makeusabrew/bootbox) (by [Vincent Bortone](https://github.com/vbortone/)) * [Bootstrap](http://twitter.github.com/bootstrap/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/bigscreen/bigscreen-tests.ts b/bigscreen/bigscreen-tests.ts new file mode 100644 index 0000000000..0ae13acd73 --- /dev/null +++ b/bigscreen/bigscreen-tests.ts @@ -0,0 +1,23 @@ +/// + +BigScreen.onchange = function(element: Element) { + console.log("Full-screen element " + element + " changed."); +} + +BigScreen.onenter = function(element: Element) { + console.log(BigScreen.element + " entered full-screen."); +}; + +BigScreen.onexit = function() { + console.log("Exited full-screen."); +} + +BigScreen.onerror = function(element: Element, reason: string) { + console.log("Error sending " + element + " into full-screen: " + reason); +} + +console.log("full-screen-enabled? " + BigScreen.enabled); + +BigScreen.request(document.documentElement); +BigScreen.exit(); +BigScreen.toggle(document.documentElement); diff --git a/bigscreen/bigscreen.d.ts b/bigscreen/bigscreen.d.ts new file mode 100644 index 0000000000..bdabdc101d --- /dev/null +++ b/bigscreen/bigscreen.d.ts @@ -0,0 +1,20 @@ +// Type definitions for BigScreen 2.0.4 +// Project: http://brad.is/coding/BigScreen/ +// Definitions by: Douglas Eichelberger +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface BigScreenStatic { + element: any; + enabled: boolean; + + exit(): void; + onchange(element: Element): void; + onenter(element: Element): void; + onerror(element: Element, reason: string): void; + onexit(): void; + request(element: Element, onEnter?: (element: Element) => void, onExit?: () => void, onError?: (element: Element, reason: string) => void): void; + toggle(element: Element, onEnter?: (element: Element) => void, onExit?: () => void, onError?: (element: Element, reason: string) => void): void; + videoEnabled(video: HTMLVideoElement): boolean; +} + +declare var BigScreen: BigScreenStatic; From 281e3ab86688dc1ce73a1c43b9433ac33f25997e Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 25 Feb 2014 11:15:50 +0900 Subject: [PATCH 191/240] Added a new version of TypeScript (66c2df0a382d7533605236567acfb8fcc7800726) --- .../tests/typescript/0.9.7-66c2df/lib.d.ts | 14931 ++++ .../tests/typescript/0.9.7-66c2df/tsc | 2 + .../tests/typescript/0.9.7-66c2df/tsc.js | 62790 ++++++++++++++++ .../typescript/0.9.7-66c2df/typescript.js | 61380 +++++++++++++++ 4 files changed, 139103 insertions(+) create mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts create mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/tsc create mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/tsc.js create mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/typescript.js diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts b/_infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts new file mode 100644 index 0000000000..94c477fd4a --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts @@ -0,0 +1,14931 @@ +/* ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +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; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +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; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +declare var Function: { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +interface Boolean { +} +declare var Boolean: { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + 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): 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): 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): 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): 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): 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): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + 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): 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): 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): 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): 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): 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): 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. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +declare var Date: { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +interface RegExpExecArray { + [index: number]: string; + length: number; + + index: number; + input: string; + + toString(): string; + toLocaleString(): string; + concat(...items: string[][]): string[]; + join(separator?: string): string; + pop(): string; + push(...items: string[]): number; + reverse(): string[]; + shift(): 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[]; + unshift(...items: string[]): number; + + indexOf(searchElement: string, fromIndex?: number): number; + lastIndexOf(searchElement: string, fromIndex?: number): number; + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; + map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; + filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; + reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; + reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +} + + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + 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. + */ + test(string: string): boolean; + + /** 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; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} +declare var RegExp: { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +interface Error { + name: string; + message: string; +} +declare var Error: { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +interface EvalError extends Error { +} +declare var EvalError: { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +interface RangeError extends Error { +} +declare var RangeError: { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +interface ReferenceError extends Error { +} +declare var ReferenceError: { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +interface SyntaxError extends Error { +} +declare var SyntaxError: { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +interface TypeError extends Error { +} +declare var TypeError: { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +interface URIError extends Error { +} +declare var URIError: { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + + [n: number]: T; +} +declare var Array: { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + + +///////////////////////////// +/// IE10 ECMAScript Extensions +///////////////////////////// + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; +} + +declare var ArrayBuffer: { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; +} + +interface ArrayBufferView { + buffer: ArrayBuffer; + byteOffset: number; + byteLength: number; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; +} +declare var Int8Array: { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Uint8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; +} +declare var Uint8Array: { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 16-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; +} +declare var Int16Array: { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Uint16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; +} +declare var Uint16Array: { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; +} +declare var Int32Array: { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; +} +declare var Uint32Array: { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Float32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Float32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; +} +declare var Float32Array: { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Float64Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Float64Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; +} +declare var Float64Array: { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + BYTES_PER_ELEMENT: number; +} + +/** + * You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer. + */ +interface DataView extends ArrayBufferView { + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; +} +declare var DataView: { + prototype: DataView; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; +} + +///////////////////////////// +/// IE11 ECMAScript Extensions +///////////////////////////// + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): Map; + size: number; +} +declare var Map: { + new (): Map; +} + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): WeakMap; +} +declare var WeakMap: { + new (): WeakMap; +} + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + size: number; +} +declare var Set: { + new (): Set; +} + +declare module Intl { + + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): Collator; + new (locale?: string, options?: NumberFormatOptions): Collator; + (locales?: string[], options?: NumberFormatOptions): Collator; + (locale?: string, options?: NumberFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date: number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): Collator; + new (locale?: string, options?: DateTimeFormatOptions): Collator; + (locales?: string[], options?: DateTimeFormatOptions): Collator; + (locale?: string, options?: DateTimeFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + 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; +} + + +///////////////////////////// +/// IE9 DOM APIs +///////////////////////////// + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface NavigatorID { + appVersion: string; + appName: string; + userAgent: string; + platform: string; +} + +interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the amount of space between cells in a table. + */ + cellSpacing: string; + /** + * Retrieves the tFoot object of the table. + */ + tFoot: HTMLTableSectionElement; + /** + * Sets or retrieves the way the border frame around the table is displayed. + */ + frame: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Sets or retrieves which dividing lines (inner borders) are displayed. + */ + rules: string; + /** + * Sets or retrieves the number of columns in the table. + */ + cols: number; + /** + * Sets or retrieves a description and/or structure of the object. + */ + summary: string; + /** + * Retrieves the caption object of a table. + */ + caption: HTMLTableCaptionElement; + /** + * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. + */ + tBodies: HTMLCollection; + /** + * Retrieves the tHead object of the table. + */ + tHead: HTMLTableSectionElement; + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Retrieves a collection of all cells in the table row or in the entire table. + */ + cells: HTMLCollection; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the amount of space between the border of the cell and the content of the cell. + */ + cellPadding: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Creates an empty tBody element in the table. + */ + createTBody(): HTMLElement; + /** + * Deletes the caption element and its contents from the table. + */ + deleteCaption(): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; + /** + * Deletes the tFoot element and its contents from the table. + */ + deleteTFoot(): void; + /** + * Returns the tHead element object if successful, or null otherwise. + */ + createTHead(): HTMLElement; + /** + * Deletes the tHead element and its contents from the table. + */ + deleteTHead(): void; + /** + * Creates an empty caption element in the table. + */ + createCaption(): HTMLElement; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): Object; + /** + * Creates an empty tFoot element in the table. + */ + createTFoot(): HTMLElement; +} +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new (): HTMLTableElement; +} + +interface TreeWalker { + whatToShow: number; + filter: NodeFilter; + root: Node; + currentNode: Node; + expandEntityReferences: boolean; + previousSibling(): Node; + lastChild(): Node; + nextSibling(): Node; + nextNode(): Node; + parentNode(): Node; + firstChild(): Node; + previousNode(): Node; +} +declare var TreeWalker: { + prototype: TreeWalker; + new (): TreeWalker; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new (): SVGPathSegCurvetoQuadraticRel; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + getEntriesByType(entryType: string): any; + toJSON(): any; + getMeasures(measureName?: string): any; + clearMarks(markName?: string): void; + getMarks(markName?: string): any; + clearResourceTimings(): void; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + getEntriesByName(name: string, entryType?: string): any; + getEntries(): any; + clearMeasures(measureName?: string): void; + setResourceTimingBufferSize(maxSize: number): void; +} +declare var Performance: { + prototype: Performance; + new (): Performance; +} + +interface MSDataBindingTableExtensions { + dataPageSize: number; + nextPage(): void; + firstPage(): void; + refresh(): void; + previousPage(): void; + lastPage(): void; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} +declare var CompositionEvent: { + prototype: CompositionEvent; + new (): CompositionEvent; +} + +interface WindowTimers { + clearTimeout(handle: number): void; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; + clearInterval(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { + orientType: SVGAnimatedEnumeration; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + markerHeight: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + refY: SVGAnimatedLength; + refX: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new (): SVGMarkerElement; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} + +interface CSSStyleDeclaration { + backgroundAttachment: string; + visibility: string; + textAlignLast: string; + borderRightStyle: string; + counterIncrement: string; + orphans: string; + cssText: string; + borderStyle: string; + pointerEvents: string; + borderTopColor: string; + markerEnd: string; + textIndent: string; + listStyleImage: string; + cursor: string; + listStylePosition: string; + wordWrap: string; + borderTopStyle: string; + alignmentBaseline: string; + opacity: string; + direction: string; + strokeMiterlimit: string; + maxWidth: string; + color: string; + clip: string; + borderRightWidth: string; + verticalAlign: string; + overflow: string; + mask: string; + borderLeftStyle: string; + emptyCells: string; + stopOpacity: string; + paddingRight: string; + parentRule: CSSRule; + background: string; + boxSizing: string; + textJustify: string; + height: string; + paddingTop: string; + length: number; + right: string; + baselineShift: string; + borderLeft: string; + widows: string; + lineHeight: string; + left: string; + textUnderlinePosition: string; + glyphOrientationHorizontal: string; + display: string; + textAnchor: string; + cssFloat: string; + strokeDasharray: string; + rubyAlign: string; + fontSizeAdjust: string; + borderLeftColor: string; + backgroundImage: string; + listStyleType: string; + strokeWidth: string; + textOverflow: string; + fillRule: string; + borderBottomColor: string; + zIndex: string; + position: string; + listStyle: string; + msTransformOrigin: string; + dominantBaseline: string; + overflowY: string; + fill: string; + captionSide: string; + borderCollapse: string; + boxShadow: string; + quotes: string; + tableLayout: string; + unicodeBidi: string; + borderBottomWidth: string; + backgroundSize: string; + textDecoration: string; + strokeDashoffset: string; + fontSize: string; + border: string; + pageBreakBefore: string; + borderTopRightRadius: string; + msTransform: string; + borderBottomLeftRadius: string; + textTransform: string; + rubyPosition: string; + strokeLinejoin: string; + clipPath: string; + borderRightColor: string; + fontFamily: string; + clear: string; + content: string; + backgroundClip: string; + marginBottom: string; + counterReset: string; + outlineWidth: string; + marginRight: string; + paddingLeft: string; + borderBottom: string; + wordBreak: string; + marginTop: string; + top: string; + fontWeight: string; + borderRight: string; + width: string; + kerning: string; + pageBreakAfter: string; + borderBottomStyle: string; + fontStretch: string; + padding: string; + strokeOpacity: string; + markerStart: string; + bottom: string; + borderLeftWidth: string; + clipRule: string; + backgroundPosition: string; + backgroundColor: string; + pageBreakInside: string; + backgroundOrigin: string; + strokeLinecap: string; + borderTopWidth: string; + outlineStyle: string; + borderTop: string; + outlineColor: string; + paddingBottom: string; + marginLeft: string; + font: string; + outline: string; + wordSpacing: string; + maxHeight: string; + fillOpacity: string; + letterSpacing: string; + borderSpacing: string; + backgroundRepeat: string; + borderRadius: string; + borderWidth: string; + borderBottomRightRadius: string; + whiteSpace: string; + fontStyle: string; + minWidth: string; + stopColor: string; + borderTopLeftRadius: string; + borderColor: string; + marker: string; + glyphOrientationVertical: string; + markerMid: string; + fontVariant: string; + minHeight: string; + stroke: string; + rubyOverhang: string; + overflowX: string; + textAlign: string; + margin: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + removeProperty(propertyName: string): string; + item(index: number): string; + [index: number]: string; + setProperty(propertyName: string, value: string, priority?: string): void; +} +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new (): CSSStyleDeclaration; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGGElement: { + prototype: SVGGElement; + new (): SVGGElement; +} + +interface MSStyleCSSProperties extends MSCSSProperties { + pixelWidth: number; + posHeight: number; + posLeft: number; + pixelTop: number; + pixelBottom: number; + textDecorationNone: boolean; + pixelLeft: number; + posTop: number; + posBottom: number; + textDecorationOverline: boolean; + posWidth: number; + textDecorationLineThrough: boolean; + pixelHeight: number; + textDecorationBlink: boolean; + posRight: number; + pixelRight: number; + textDecorationUnderline: boolean; +} +declare var MSStyleCSSProperties: { + prototype: MSStyleCSSProperties; + new (): MSStyleCSSProperties; +} + +interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils { +} +declare var Navigator: { + prototype: Navigator; + new (): Navigator; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new (): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGZoomEvent extends UIEvent { + zoomRectScreen: SVGRect; + previousScale: number; + newScale: number; + previousTranslate: SVGPoint; + newTranslate: SVGPoint; +} +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new (): SVGZoomEvent; +} + +interface NodeSelector { + querySelectorAll(selectors: string): NodeList; + querySelector(selectors: string): Element; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new (): HTMLTableDataCellElement; +} + +interface HTMLBaseElement extends HTMLElement { + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Gets or sets the baseline URL on which relative links are based. + */ + href: string; +} +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new (): HTMLBaseElement; +} + +interface ClientRect { + left: number; + width: number; + right: number; + top: number; + bottom: number; + height: number; +} +declare var ClientRect: { + prototype: ClientRect; + new (): ClientRect; +} + +interface PositionErrorCallback { + (error: PositionError): void; +} + +interface DOMImplementation { + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + hasFeature(feature: string, version?: string): boolean; + createHTMLDocument(title: string): Document; +} +declare var DOMImplementation: { + prototype: DOMImplementation; + new (): DOMImplementation; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: { + prototype: SVGUnitTypes; + new (): SVGUnitTypes; + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} + +interface Element extends Node, NodeSelector, ElementTraversal { + scrollTop: number; + clientLeft: number; + scrollLeft: number; + tagName: string; + clientWidth: number; + scrollWidth: number; + clientHeight: number; + clientTop: number; + scrollHeight: number; + getAttribute(name?: string): string; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + getBoundingClientRect(): ClientRect; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + msMatchesSelector(selectors: string): boolean; + hasAttribute(name: string): boolean; + removeAttribute(name?: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + getAttributeNode(name: string): Attr; + fireEvent(eventName: string, eventObj?: any): boolean; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "bdi"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "main"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rp"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "source"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "summary"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: string): NodeList; + getClientRects(): ClientRectList; + setAttributeNode(newAttr: Attr): Attr; + removeAttributeNode(oldAttr: Attr): Attr; + setAttribute(name?: string, value?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; +} +declare var Element: { + prototype: Element; + new (): Element; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new (): HTMLNextIdElement; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new (): SVGPathSegMovetoRel; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLineElement: { + prototype: SVGLineElement; + new (): SVGLineElement; +} + +interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; +} +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new (): HTMLParagraphElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + /** + * Removes an element from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + */ + add(element: HTMLElement, before?: any): void; +} +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new (): HTMLAreasCollection; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGDescElement: { + prototype: SVGDescElement; + new (): SVGDescElement; +} + +interface Node extends EventTarget { + nodeType: number; + previousSibling: Node; + localName: string; + namespaceURI: string; + textContent: string; + parentNode: Node; + nextSibling: Node; + nodeValue: string; + lastChild: Node; + childNodes: NodeList; + nodeName: string; + ownerDocument: Document; + attributes: NamedNodeMap; + firstChild: Node; + prefix: string; + removeChild(oldChild: Node): Node; + appendChild(newChild: Node): Node; + isSupported(feature: string, version: string): boolean; + isEqualNode(arg: Node): boolean; + lookupPrefix(namespaceURI: string): string; + isDefaultNamespace(namespaceURI: string): boolean; + compareDocumentPosition(other: Node): number; + normalize(): void; + isSameNode(other: Node): boolean; + hasAttributes(): boolean; + lookupNamespaceURI(prefix: string): string; + cloneNode(deep?: boolean): Node; + hasChildNodes(): boolean; + replaceChild(newChild: Node, oldChild: Node): Node; + insertBefore(newChild: Node, refChild?: Node): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} +declare var Node: { + prototype: Node; + new (): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new (): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface DOML2DeprecatedListSpaceReduction { + compact: boolean; +} + +interface MSScriptHost { +} +declare var MSScriptHost: { + prototype: MSScriptHost; + new (): MSScriptHost; +} + +interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + clipPathUnits: SVGAnimatedEnumeration; +} +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new (): SVGClipPathElement; +} + +interface MouseEvent extends UIEvent { + toElement: Element; + layerY: number; + fromElement: Element; + which: number; + pageX: number; + offsetY: number; + x: number; + y: number; + metaKey: boolean; + altKey: boolean; + ctrlKey: boolean; + offsetX: number; + screenX: number; + clientY: number; + shiftKey: boolean; + layerX: number; + screenY: number; + relatedTarget: EventTarget; + button: number; + pageY: number; + buttons: number; + clientX: number; + initMouseEvent(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): void; + getModifierState(keyArg: string): boolean; +} +declare var MouseEvent: { + prototype: MouseEvent; + new (): MouseEvent; +} + +interface RangeException { + code: number; + message: string; + toString(): string; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} +declare var RangeException: { + prototype: RangeException; + new (): RangeException; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + y: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + dy: SVGAnimatedLengthList; + x: SVGAnimatedLengthList; + dx: SVGAnimatedLengthList; +} +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new (): SVGTextPositioningElement; +} + +interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + width: number; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + object: string; + form: HTMLFormElement; + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. + */ + declare: boolean; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new (): HTMLAppletElement; +} + +interface TextMetrics { + width: number; +} +declare var TextMetrics: { + prototype: TextMetrics; + new (): TextMetrics; +} + +interface DocumentEvent { + createEvent(eventInterface: string): Event; +} + +interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * The starting number. + */ + start: number; +} +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new (): HTMLOListElement; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new (): SVGPathSegLinetoVerticalRel; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new (): SVGAnimatedString; +} + +interface CDATASection extends Text { +} +declare var CDATASection: { + prototype: CDATASection; + new (): CDATASection; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} +declare var StyleMedia: { + prototype: StyleMedia; + new (): StyleMedia; +} + +interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { + options: HTMLSelectElement; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the number of rows in the list box. + */ + size: number; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the index of the selected option in a select object. + */ + selectedIndex: number; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Retrieves the type of select control based on the value of the MULTIPLE attribute. + */ + type: string; + /** + * Removes an element from the collection. + * @param index Number that specifies the zero-based index of the element to remove from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. + * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. + */ + add(element: HTMLElement, before?: any): void; + /** + * Retrieves a select object or an object from an options collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a select object or an object from an options collection. + * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. + */ + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new (): HTMLSelectElement; +} + +interface TextRange { + boundingLeft: number; + htmlText: string; + offsetLeft: number; + boundingWidth: number; + boundingHeight: number; + boundingTop: number; + text: string; + offsetTop: number; + moveToPoint(x: number, y: number): void; + queryCommandValue(cmdID: string): any; + getBookmark(): string; + move(unit: string, count?: number): number; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(fStart?: boolean): void; + findText(string: string, count?: number, flags?: number): boolean; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + getBoundingClientRect(): ClientRect; + moveToBookmark(bookmark: string): boolean; + isEqual(range: TextRange): boolean; + duplicate(): TextRange; + collapse(start?: boolean): void; + queryCommandText(cmdID: string): string; + select(): void; + pasteHTML(html: string): void; + inRange(range: TextRange): boolean; + moveEnd(unit: string, count?: number): number; + getClientRects(): ClientRectList; + moveStart(unit: string, count?: number): number; + parentElement(): Element; + queryCommandState(cmdID: string): boolean; + compareEndPoints(how: string, sourceRange: TextRange): number; + execCommandShowHelp(cmdID: string): boolean; + moveToElementText(element: Element): void; + expand(Unit: string): boolean; + queryCommandSupported(cmdID: string): boolean; + setEndPoint(how: string, SourceRange: TextRange): void; + queryCommandEnabled(cmdID: string): boolean; +} +declare var TextRange: { + prototype: TextRange; + new (): TextRange; +} + +interface SVGTests { + requiredFeatures: SVGStringList; + requiredExtensions: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new (): HTMLBlockElement; +} + +interface CSSStyleSheet extends StyleSheet { + owningElement: Element; + imports: StyleSheetList; + isAlternate: boolean; + rules: MSCSSRuleList; + isPrefAlternate: boolean; + readOnly: boolean; + cssText: string; + ownerRule: CSSRule; + href: string; + cssRules: CSSRuleList; + id: string; + pages: StyleSheetPageList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + insertRule(rule: string, index?: number): number; + removeRule(lIndex: number): void; + deleteRule(index?: number): void; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + removeImport(lIndex: number): void; +} +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new (): CSSStyleSheet; +} + +interface MSSelection { + type: string; + typeDetail: string; + createRange(): TextRange; + clear(): void; + createRangeCollection(): TextRangeCollection; + empty(): void; +} +declare var MSSelection: { + prototype: MSSelection; + new (): MSSelection; +} + +interface HTMLMetaElement extends HTMLElement { + /** + * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. + */ + httpEquiv: string; + /** + * Sets or retrieves the value specified in the content attribute of the meta object. + */ + name: string; + /** + * Gets or sets meta-information to associate with httpEquiv or name. + */ + content: string; + /** + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + */ + url: string; + /** + * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. + */ + scheme: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; +} +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new (): HTMLMetaElement; +} + +interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { + patternUnits: SVGAnimatedEnumeration; + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + height: SVGAnimatedLength; +} +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new (): SVGPatternElement; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new (): SVGAnimatedAngle; +} + +interface Selection { + isCollapsed: boolean; + anchorNode: Node; + focusNode: Node; + anchorOffset: number; + focusOffset: number; + rangeCount: number; + addRange(range: Range): void; + collapseToEnd(): void; + toString(): string; + selectAllChildren(parentNode: Node): void; + getRangeAt(index: number): Range; + collapse(parentNode: Node, offset: number): void; + removeAllRanges(): void; + collapseToStart(): void; + deleteFromDocument(): void; + removeRange(range: Range): void; +} +declare var Selection: { + prototype: Selection; + new (): Selection; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; +} +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new (): SVGScriptElement; +} + +interface HTMLDDElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new (): HTMLDDElement; +} + +interface MSDataBindingRecordSetReadonlyExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface CSSStyleRule extends CSSRule { + selectorText: string; + style: MSStyleCSSProperties; + readOnly: boolean; +} +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new (): CSSStyleRule; +} + +interface NodeIterator { + whatToShow: number; + filter: NodeFilter; + root: Node; + expandEntityReferences: boolean; + nextNode(): Node; + detach(): void; + previousNode(): Node; +} +declare var NodeIterator: { + prototype: NodeIterator; + new (): NodeIterator; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { + viewTarget: SVGStringList; +} +declare var SVGViewElement: { + prototype: SVGViewElement; + new (): SVGViewElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; +} +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new (): HTMLLinkElement; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getTransformToElement(element: SVGElement): SVGMatrix; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; +} +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new (): HTMLFontElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new (): SVGTitleElement; +} + +interface ControlRangeCollection { + length: number; + queryCommandValue(cmdID: string): any; + remove(index: number): void; + add(item: Element): void; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(varargStart?: any): void; + item(index: number): Element; + [index: number]: Element; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + addElement(item: Element): void; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandEnabled(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + select(): void; +} +declare var ControlRangeCollection: { + prototype: ControlRangeCollection; + new (): ControlRangeCollection; +} + +interface MSNamespaceInfo extends MSEventAttachmentTarget { + urn: string; + onreadystatechange: (ev: Event) => any; + name: string; + readyState: string; + doImport(implementationUrl: string): void; +} +declare var MSNamespaceInfo: { + prototype: MSNamespaceInfo; + new (): MSNamespaceInfo; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new (): SVGAnimatedTransformList; +} + +interface HTMLTableCaptionElement extends HTMLElement { + /** + * Sets or retrieves the alignment of the caption or legend. + */ + align: string; + /** + * Sets or retrieves whether the caption appears at the top or bottom of the table. + */ + vAlign: string; +} +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new (): HTMLTableCaptionElement; +} + +interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; + create(): HTMLOptionElement; +} +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new (): HTMLOptionElement; +} + +interface HTMLMapElement extends HTMLElement { + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves a collection of the area objects defined for the given map object. + */ + areas: HTMLAreasCollection; +} +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new (): HTMLMapElement; +} + +interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { + type: string; +} +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new (): HTMLMenuElement; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new (): MouseWheelEvent; +} + +interface SVGFitToViewBox { + viewBox: SVGAnimatedRect; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface SVGPointList { + numberOfItems: number; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; + getItem(index: number): SVGPoint; + clear(): void; + appendItem(newItem: SVGPoint): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + removeItem(index: number): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; +} +declare var SVGPointList: { + prototype: SVGPointList; + new (): SVGPointList; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new (): SVGAnimatedLengthList; +} + +interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers { + ondragend: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + ondragover: (ev: DragEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + screenX: number; + onmouseover: (ev: MouseEvent) => any; + ondragleave: (ev: DragEvent) => any; + history: History; + pageXOffset: number; + name: string; + onafterprint: (ev: Event) => any; + onpause: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + top: Window; + onmousedown: (ev: MouseEvent) => any; + onseeked: (ev: Event) => any; + opener: Window; + onclick: (ev: MouseEvent) => any; + innerHeight: number; + onwaiting: (ev: Event) => any; + ononline: (ev: Event) => any; + ondurationchange: (ev: Event) => any; + frames: Window; + onblur: (ev: FocusEvent) => any; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + outerWidth: number; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + innerWidth: number; + onoffline: (ev: Event) => any; + length: number; + screen: Screen; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onratechange: (ev: Event) => any; + onstorage: (ev: StorageEvent) => any; + onloadstart: (ev: Event) => any; + ondragenter: (ev: DragEvent) => any; + onsubmit: (ev: Event) => any; + self: Window; + document: Document; + onprogress: (ev: any) => any; + ondblclick: (ev: MouseEvent) => any; + pageYOffset: number; + oncontextmenu: (ev: MouseEvent) => any; + onchange: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onplay: (ev: Event) => any; + onerror: ErrorEventHandler; + onplaying: (ev: Event) => any; + parent: Window; + location: Location; + oncanplaythrough: (ev: Event) => any; + onabort: (ev: UIEvent) => any; + onreadystatechange: (ev: Event) => any; + outerHeight: number; + onkeypress: (ev: KeyboardEvent) => any; + frameElement: Element; + onloadeddata: (ev: Event) => any; + onsuspend: (ev: Event) => any; + window: Window; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onselect: (ev: UIEvent) => any; + navigator: Navigator; + styleMedia: StyleMedia; + ondrop: (ev: DragEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onended: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onunload: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + screenY: number; + onmousewheel: (ev: MouseWheelEvent) => any; + onload: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + oninput: (ev: Event) => any; + performance: Performance; + alert(message?: any): void; + scroll(x?: number, y?: number): void; + focus(): void; + scrollTo(x?: number, y?: number): void; + print(): void; + prompt(message?: string, defaul?: string): string; + toString(): string; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + scrollBy(x?: number, y?: number): void; + confirm(message?: string): boolean; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; + showModalDialog(url?: string, argument?: any, options?: any): any; + blur(): void; + getSelection(): Selection; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +} +declare var Window: { + prototype: Window; + new (): Window; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new (): SVGAnimatedPreserveAspectRatio; +} + +interface MSSiteModeEvent extends Event { + buttonID: number; + actionURL: string; +} +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new (): MSSiteModeEvent; +} + +interface DOML2DeprecatedTextFlowControl { + clear: string; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new (): StyleSheetPageList; +} + +interface MSCSSProperties extends CSSStyleDeclaration { + scrollbarShadowColor: string; + scrollbarHighlightColor: string; + layoutGridChar: string; + layoutGridType: string; + textAutospace: string; + textKashidaSpace: string; + writingMode: string; + scrollbarFaceColor: string; + backgroundPositionY: string; + lineBreak: string; + imeMode: string; + msBlockProgression: string; + layoutGridLine: string; + scrollbarBaseColor: string; + layoutGrid: string; + layoutFlow: string; + textKashida: string; + filter: string; + zoom: string; + scrollbarArrowColor: string; + behavior: string; + backgroundPositionX: string; + accelerator: string; + layoutGridMode: string; + textJustifyTrim: string; + scrollbar3dLightColor: string; + msInterpolationMode: string; + scrollbarTrackColor: string; + scrollbarDarkShadowColor: string; + styleFloat: string; + getAttribute(attributeName: string, flags?: number): any; + setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; + removeAttribute(attributeName: string, flags?: number): boolean; +} +declare var MSCSSProperties: { + prototype: MSCSSProperties; + new (): MSCSSProperties; +} + +interface HTMLCollection extends MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Retrieves an object from various collections. + */ + item(nameOrIndex?: any, optionalIndex?: any): Element; + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element; + [name: number]: Element; +} +declare var HTMLCollection: { + prototype: HTMLCollection; + new (): HTMLCollection; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * The original height of the image resource before sizing. + */ + naturalHeight: number; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * The original width of the image resource before sizing. + */ + naturalWidth: number; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: number; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. + */ + longDesc: string; + /** + * Contains the hypertext reference (HREF) of the URL. + */ + href: string; + /** + * Sets or retrieves whether the image is a server-side image map. + */ + isMap: boolean; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + create(): HTMLImageElement; +} +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new (): HTMLImageElement; +} + +interface HTMLAreaElement extends HTMLElement { + /** + * Sets or retrieves the protocol portion of a URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Sets or retrieves the host name part of the location or URL. + */ + hostname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Sets or retrieves the file name or path specified by the object. + */ + pathname: string; + /** + * Sets or retrieves the hostname and port number of the location or URL. + */ + host: string; + /** + * Sets or retrieves the subsection of the href property that follows the number sign (#). + */ + hash: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or gets whether clicks in this region cause action. + */ + noHref: boolean; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new (): HTMLAreaElement; +} + +interface EventTarget { + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; +} + +interface SVGAngle { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} +declare var SVGAngle: { + prototype: SVGAngle; + new (): SVGAngle; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} + +interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the default or selected value of the control. + */ + value: string; + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets the classification and default behavior of the button. + */ + type: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; +} +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new (): HTMLButtonElement; +} + +interface HTMLSourceElement extends HTMLElement { + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the intended media type of the media source. + */ + media: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; +} +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new (): HTMLSourceElement; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} +declare var CanvasGradient: { + prototype: CanvasGradient; + new (): CanvasGradient; +} + +interface KeyboardEvent extends UIEvent { + location: number; + keyCode: number; + shiftKey: boolean; + which: number; + locale: string; + key: string; + altKey: boolean; + metaKey: boolean; + char: string; + ctrlKey: boolean; + repeat: boolean; + charCode: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new (): KeyboardEvent; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} + +interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions { + /** + * Retrieves the collection of user agents and versions declared in the X-UA-Compatible + */ + compatible: MSCompatibleInfoCollection; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (ev: KeyboardEvent) => any; + + /** + * Gets the implementation object of the current document. + */ + implementation: DOMImplementation; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (ev: Event) => any; + + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollection; + + /** + * Fires when the user presses the F1 key while the browser is the active window. + * @param ev The event. + */ + onhelp: (ev: Event) => any; + + /** + * 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; + + /** + * Gets or sets the character set used to encode the object. + */ + charset: string; + + /** + * Fires for an element just prior to setting focus on that element. + * @param ev The focus event + */ + onfocusin: (ev: FocusEvent) => any; + + + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (ev: Event) => any; + + security: string; + + /** + * Contains the title of the document. + */ + title: string; + + /** + * Retrieves a collection of namespace objects. + */ + namespaces: MSNamespaceInfoCollection; + + /** + * Gets the default character set from the current regional language settings. + */ + defaultCharset: string; + + /** + * Retrieves a collection of all embed objects in the document. + */ + embeds: HTMLCollection; + + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + styleSheets: StyleSheetList; + + /** + * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. + */ + frames: Window; + + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (ev: Event) => any; + + + /** + * Returns a reference to the collection of elements contained by the object. + */ + all: HTMLCollection; + + /** + * Retrieves a collection, in source order, of all form objects in the document. + */ + forms: HTMLCollection; + + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (ev: FocusEvent) => any; + + + /** + * Sets or retrieves a value that indicates the reading order of the object. + */ + dir: string; + + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (ev: Event) => any; + + + /** + * Sets or gets a value that indicates whether the document can be edited. + */ + designMode: string; + + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (ev: Event) => any; + + + /** + * Fires when the activeElement is changed from the current object to another object in the parent document. + * @param ev The UI Event + */ + ondeactivate: (ev: UIEvent) => any; + + + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (ev: Event) => any; + + + /** + * Fires when the data set exposed by a data source object changes. + * @param ev The event. + */ + ondatasetchanged: (ev: MSEventObj) => any; + + + /** + * Fires when rows are about to be deleted from the recordset. + * @param ev The event + */ + onrowsdelete: (ev: MSEventObj) => any; + + Script: MSScriptHost; + + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (ev: Event) => any; + + + /** + * Gets the URL for the document, stripped of any character encoding. + */ + URLUnencoded: string; + + defaultView: Window; + + /** + * Fires when the user is about to make a control selection of the object. + * @param ev The event. + */ + oncontrolselect: (ev: MSEventObj) => any; + + + /** + * Fires on the target element when the user drags the object to a valid drop target. + * @param ev The drag event. + */ + ondragenter: (ev: DragEvent) => any; + + onsubmit: (ev: Event) => any; + + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + inputEncoding: string; + + /** + * Gets the object that has the focus when the parent document has focus. + */ + activeElement: Element; + + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (ev: Event) => any; + + + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + */ + links: HTMLCollection; + + /** + * Retrieves an autogenerated, unique identifier for the object. + */ + uniqueID: string; + + /** + * Sets or gets the URL for the current document. + */ + URL: string; + + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (ev: UIEvent) => any; + + head: HTMLHeadElement; + cookie: string; + xmlEncoding: string; + oncanplaythrough: (ev: Event) => any; + + /** + * Retrieves the document compatibility mode of the document. + */ + documentMode: number; + + characterSet: string; + + /** + * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. + */ + anchors: HTMLCollection; + + onbeforeupdate: (ev: MSEventObj) => any; + + /** + * Fires to indicate that all data is available from the data source object. + * @param ev The event. + */ + ondatasetcomplete: (ev: MSEventObj) => any; + + plugins: HTMLCollection; + + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (ev: Event) => any; + + + /** + * Gets the root svg element in the document hierarchy. + */ + rootElement: SVGSVGElement; + + /** + * Retrieves a value that indicates the current state of the object. + */ + readyState: string; + + /** + * Gets the URL of the location that referred the user to the current page. + */ + referrer: string; + + /** + * Sets or gets the color of all active links in the document. + */ + alinkColor: string; + + /** + * Fires on a databound object when an error occurs while updating the associated data in the data source object. + * @param ev The event. + */ + onerrorupdate: (ev: MSEventObj) => any; + + + /** + * Gets a reference to the container object of the window. + */ + parentWindow: Window; + + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (ev: MouseEvent) => any; + + + /** + * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. + * @param ev The event. + */ + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + + + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (ev: MouseWheelEvent) => any; + + + /** + * Occurs when the volume is changed, or playback is muted or unmuted. + * @param ev The event. + */ + onvolumechange: (ev: Event) => any; + + + /** + * Fires when data changes in the data provider. + * @param ev The event. + */ + oncellchange: (ev: MSEventObj) => any; + + + /** + * Fires just before the data source control changes the current row in the object. + * @param ev The event. + */ + onrowexit: (ev: MSEventObj) => any; + + + /** + * Fires just after new rows are inserted in the current recordset. + * @param ev The event. + */ + onrowsinserted: (ev: MSEventObj) => any; + + + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string; + + msCapsLockWarningOff: boolean; + + /** + * Fires when a property changes on the object. + * @param ev The event. + */ + onpropertychange: (ev: MSEventObj) => any; + + + /** + * Fires on the source object when the user releases the mouse at the close of a drag operation. + * @param ev The event. + */ + ondragend: (ev: DragEvent) => any; + + + /** + * Gets an object representing the document type declaration associated with the current document. + */ + doctype: DocumentType; + + /** + * Fires on the target element continuously while the user drags the object over a valid drop target. + * @param ev The event. + */ + ondragover: (ev: DragEvent) => any; + + + /** + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + */ + bgColor: string; + + /** + * Fires on the source object when the user starts to drag a text selection or selected object. + * @param ev The event. + */ + ondragstart: (ev: DragEvent) => any; + + + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (ev: MouseEvent) => any; + + + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (ev: DragEvent) => any; + + + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (ev: MouseEvent) => any; + + + /** + * Sets or gets the color of the document links. + */ + linkColor: string; + + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (ev: Event) => any; + + + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (ev: MouseEvent) => any; + + + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (ev: MouseEvent) => any; + + + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (ev: Event) => any; + + + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (ev: Event) => any; + + /** + * false (false)[rolls + */ + + /** + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * @param ev The event. + */ + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + + + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollection; + + /** + * Specifies the beginning and end of the document body. + */ + body: HTMLElement; + + /** + * Sets or gets the security domain of the document. + */ + domain: string; + + xmlStandalone: boolean; + + /** + * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. + */ + selection: MSSelection; + + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (ev: Event) => any; + + + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (ev: MouseEvent) => any; + + + /** + * Gets a reference to the root node of the document. + */ + documentElement: HTMLElement; + + /** + * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. + * @param ev The event. + */ + onbeforeeditfocus: (ev: MSEventObj) => any; + + + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (ev: Event) => any; + + + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (ev: any) => any; + + + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (ev: MouseEvent) => any; + + + /** + * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * @param ev The mouse event. + */ + oncontextmenu: (ev: MouseEvent) => any; + + + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (ev: Event) => any; + + media: string; + + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (ev: Event) => any; + + + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (ev: Event) => any; + + onafterupdate: (ev: MSEventObj) => any; + + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (ev: Event) => any; + + + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollection; + + /** + * Contains information about the current URL. + */ + location: Location; + + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (ev: UIEvent) => any; + + + /** + * Fires for the current element with focus immediately after moving focus to another element. + * @param ev The event. + */ + onfocusout: (ev: FocusEvent) => any; + + + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (ev: Event) => any; + + + /** + * Fires when a local DOM Storage area is written to disk. + * @param ev The event. + */ + onstoragecommit: (ev: StorageEvent) => any; + + + /** + * Fires periodically as data arrives from data source objects that asynchronously transmit their data. + * @param ev The event. + */ + ondataavailable: (ev: MSEventObj) => any; + + + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (ev: Event) => any; + + + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + lastModified: string; + + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (ev: KeyboardEvent) => any; + + + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (ev: Event) => any; + + + /** + * Fires immediately before the activeElement is changed from the current object to another object in the parent document. + * @param ev The event. + */ + onbeforedeactivate: (ev: UIEvent) => any; + + + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (ev: UIEvent) => any; + + + onselectstart: (ev: Event) => any; + + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (ev: FocusEvent) => any; + + + /** + * Sets or gets the foreground (text) color of the document. + */ + fgColor: string; + + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (ev: Event) => any; + + + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (ev: UIEvent) => any; + + ondrop: (ev: DragEvent) => any; + + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (ev: Event) => any; + + + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + */ + compatMode: string; + + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (ev: UIEvent) => any; + + + /** + * Fires to indicate that the current row has changed in the data source and new data values are available on the object. + * @param ev The event. + */ + onrowenter: (ev: MSEventObj) => any; + + + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (ev: Event) => any; + + oninput: (ev: Event) => any; + + /** + * Returns the current value of the document, range, or current selection for the given command. + * @param commandId String that specifies a command identifier. + */ + queryCommandValue(commandId: string): string; + + adoptNode(source: Node): Node; + + /** + * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. + * @param commandId String that specifies a command identifier. + */ + queryCommandIndeterm(commandId: string): boolean; + + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + + /** + * Executes a command on the current document, current selection, or the given range. + * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. + * @param showUI Display the user interface, defaults to false. + * @param value Value to assign. + */ + execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + + /** + * Returns the element for the specified x coordinate and the specified y coordinate. + * @param x The x-offset + * @param y The y-offset + */ + elementFromPoint(x: number, y: number): Element; + createCDATASection(data: string): CDATASection; + + /** + * Retrieves the string associated with a command. + * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. + */ + queryCommandText(commandId: string): string; + + /** + * Writes one or more HTML expressions to a document in the specified window. + * @param content Specifies the text and HTML tags to write. + */ + write(...content: string[]): void; + + /** + * Allows updating the print settings for the page. + */ + updateSettings(): void; + + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "a"): HTMLAnchorElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "abbr"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "address"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "area"): HTMLAreaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "article"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "aside"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "audio"): HTMLAudioElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "b"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "base"): HTMLBaseElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "bdi"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "bdo"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "blockquote"): HTMLQuoteElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "body"): HTMLBodyElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "br"): HTMLBRElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "button"): HTMLButtonElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "canvas"): HTMLCanvasElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "caption"): HTMLTableCaptionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "cite"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "code"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "col"): HTMLTableColElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "colgroup"): HTMLTableColElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "datalist"): HTMLDataListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dd"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "del"): HTMLModElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dfn"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "div"): HTMLDivElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dl"): HTMLDListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dt"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "em"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "embed"): HTMLEmbedElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "fieldset"): HTMLFieldSetElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "figcaption"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "figure"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "footer"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "form"): HTMLFormElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h1"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h2"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h3"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h4"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h5"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h6"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "head"): HTMLHeadElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "header"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "hgroup"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "hr"): HTMLHRElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "html"): HTMLHtmlElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "i"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "iframe"): HTMLIFrameElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "img"): HTMLImageElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "input"): HTMLInputElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ins"): HTMLModElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "kbd"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "label"): HTMLLabelElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "legend"): HTMLLegendElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "li"): HTMLLIElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "link"): HTMLLinkElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "main"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "map"): HTMLMapElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "mark"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "menu"): HTMLMenuElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "meta"): HTMLMetaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "nav"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "noscript"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "object"): HTMLObjectElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ol"): HTMLOListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "optgroup"): HTMLOptGroupElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "option"): HTMLOptionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "p"): HTMLParagraphElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "param"): HTMLParamElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "pre"): HTMLPreElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "progress"): HTMLProgressElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "q"): HTMLQuoteElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "rp"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "rt"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ruby"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "s"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "samp"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "script"): HTMLScriptElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "section"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "select"): HTMLSelectElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "small"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "source"): HTMLSourceElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "span"): HTMLSpanElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "strong"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "style"): HTMLStyleElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "sub"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "summary"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "sup"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "table"): HTMLTableElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tbody"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "td"): HTMLTableDataCellElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "textarea"): HTMLTextAreaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tfoot"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "th"): HTMLTableHeaderCellElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "thead"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "title"): HTMLTitleElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tr"): HTMLTableRowElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "track"): HTMLTrackElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "u"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ul"): HTMLUListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "var"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "video"): HTMLVideoElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "wbr"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: string): HTMLElement; + + /** + * Removes mouse capture from the object in the current document. + */ + releaseCapture(): void; + + /** + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * @param content The text and HTML tags to write. + */ + writeln(...content: string[]): void; + createElementNS(namespaceURI: string, qualifiedName: string): Element; + + /** + * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. + * @param url Specifies a MIME type for the document. + * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. + * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. + * @param replace Specifies whether the existing entry for the document is replaced in the history list. + */ + open(url?: string, name?: string, features?: string, replace?: boolean): any; + + /** + * Returns a Boolean value that indicates whether the current command is supported on the current range. + * @param commandId Specifies a command identifier. + */ + queryCommandSupported(commandId: string): boolean; + + /** + * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. + * @param filter A custom NodeFilter function to use. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + + /** + * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. + * @param commandId Specifies a command identifier. + */ + queryCommandEnabled(commandId: string): boolean; + + /** + * Causes the element to receive the focus and executes the code specified by the onfocus event. + */ + focus(): void; + + /** + * Closes an output stream and forces the sent data to display. + */ + close(): void; + + getElementsByClassName(classNames: string): NodeList; + importNode(importedNode: Node, deep: boolean): Node; + + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + */ + createRange(): Range; + + /** + * Fires a specified event on the object. + * @param eventName Specifies the name of the event to fire. + * @param eventObj Object that specifies the event object from which to obtain event object properties. + */ + fireEvent(eventName: string, eventObj?: any): boolean; + + /** + * Creates a comment object with the specified data. + * @param data Sets the comment object's data. + */ + createComment(data: string): Comment; + + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "a"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "abbr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "address"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "area"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "article"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "aside"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "audio"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "b"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "base"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "bdi"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "bdo"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "blockquote"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "body"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "br"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "button"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "canvas"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "caption"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "cite"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "code"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "col"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "colgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "datalist"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dd"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "del"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dfn"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "div"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dl"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dt"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "em"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "embed"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "fieldset"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "figcaption"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "figure"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "footer"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "form"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h1"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h2"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h3"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h4"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h5"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h6"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "head"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "header"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "hgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "hr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "html"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "i"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "iframe"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "img"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "input"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ins"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "kbd"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "label"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "legend"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "li"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "link"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "main"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "map"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "mark"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "menu"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "meta"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "nav"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "noscript"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "object"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ol"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "optgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "option"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "p"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "param"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "pre"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "progress"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "q"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "rp"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "rt"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ruby"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "s"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "samp"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "script"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "section"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "select"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "small"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "source"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "span"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "strong"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "style"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "sub"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "summary"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "sup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "table"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tbody"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "td"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "textarea"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tfoot"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "th"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "thead"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "title"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "track"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "u"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ul"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "var"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "video"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "wbr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: string): NodeList; + + /** + * Creates a new document. + */ + createDocumentFragment(): DocumentFragment; + + /** + * Creates a style sheet for the document. + * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. + * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. + */ + createStyleSheet(href?: string, index?: number): CSSStyleSheet; + + /** + * Gets a collection of objects based on the value of the NAME or ID attribute. + * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. + */ + getElementsByName(elementName: string): NodeList; + + /** + * Returns a Boolean value that indicates the current state of the command. + * @param commandId String that specifies a command identifier. + */ + queryCommandState(commandId: string): boolean; + + /** + * Gets a value indicating whether the object currently has focus. + */ + hasFocus(): boolean; + + /** + * Displays help information for the given command identifier. + * @param commandId Displays help information for the given command identifier. + */ + execCommandShowHelp(commandId: string): boolean; + + /** + * Creates an attribute object with a specified name. + * @param name String that sets the attribute object's name. + */ + createAttribute(name: string): Attr; + + /** + * Creates a text string from the specified value. + * @param data String that specifies the nodeValue property of the text node. + */ + createTextNode(data: string): Text; + + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list + * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; + + /** + * Generates an event object to pass event context information when you use the fireEvent method. + * @param eventObj An object that specifies an existing event object on which to base the new object. + */ + createEventObject(eventObj?: any): MSEventObj; + + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection; + + /** + * Returns a reference to the first object with the specified value of the ID or NAME attribute. + * @param elementId String that specifies the ID value. Case-insensitive. + */ + getElementById(elementId: string): HTMLElement; +} + +declare var Document: { + prototype: Document; + new (): Document; +} + +interface MessageEvent extends Event { + source: Window; + origin: string; + data: any; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} +declare var MessageEvent: { + prototype: MessageEvent; + new (): MessageEvent; +} + +interface SVGElement extends Element { + onmouseover: (ev: MouseEvent) => any; + viewportElement: SVGElement; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + ondblclick: (ev: MouseEvent) => any; + onfocusout: (ev: FocusEvent) => any; + onfocusin: (ev: FocusEvent) => any; + xmlbase: string; + onmousedown: (ev: MouseEvent) => any; + onload: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + ownerSVGElement: SVGSVGElement; + id: string; +} +declare var SVGElement: { + prototype: SVGElement; + new (): SVGElement; +} + +interface HTMLScriptElement extends HTMLElement { + /** + * Sets or retrieves the status of the script. + */ + defer: boolean; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Retrieves the URL to an external file that contains the source code or data. + */ + src: string; + /** + * Sets or retrieves the object that is bound to the event script. + */ + htmlFor: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the MIME type for the associated scripting engine. + */ + type: string; + /** + * Sets or retrieves the event for which the script is written. + */ + event: string; +} +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new (): HTMLScriptElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Retrieves the position of the object in the rows collection for the table. + */ + rowIndex: number; + /** + * Retrieves a collection of all cells in the table row. + */ + cells: HTMLCollection; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Retrieves the position of the object in the collection. + */ + sectionRowIndex: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified cell from the table row, as well as from the cells collection. + * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. + */ + deleteCell(index?: number): void; + /** + * Creates a new cell in the table row, and adds the cell to the cells collection. + * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. + */ + insertCell(index?: number): HTMLElement; +} +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new (): HTMLTableRowElement; +} + +interface CanvasRenderingContext2D { + miterLimit: number; + font: string; + globalCompositeOperation: string; + msFillRule: string; + lineCap: string; + msImageSmoothingEnabled: boolean; + lineDashOffset: number; + shadowColor: string; + lineJoin: string; + shadowOffsetX: number; + lineWidth: number; + canvas: HTMLCanvasElement; + strokeStyle: any; + globalAlpha: number; + shadowOffsetY: number; + fillStyle: any; + shadowBlur: number; + textAlign: string; + textBaseline: string; + restore(): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + save(): void; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + measureText(text: string): TextMetrics; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + rotate(angle: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + translate(x: number, y: number): void; + scale(x: number, y: number): void; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + lineTo(x: number, y: number): void; + getLineDash(): Array; + fill(fillRule?: string): void; + createImageData(imageDataOrSw: any, sh?: number): ImageData; + createPattern(image: HTMLElement, repetition: string): CanvasPattern; + closePath(): void; + rect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + clearRect(x: number, y: number, w: number, h: number): void; + moveTo(x: number, y: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + fillRect(x: number, y: number, w: number, h: number): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + setLineDash(segments: Array): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + beginPath(): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; +} +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new (): CanvasRenderingContext2D; +} + +interface MSCSSRuleList { + length: number; + item(index?: number): CSSStyleRule; + [index: number]: CSSStyleRule; +} +declare var MSCSSRuleList: { + prototype: MSCSSRuleList; + new (): MSCSSRuleList; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new (): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new (): SVGPathSegArcAbs; +} + +interface SVGTransformList { + numberOfItems: number; + getItem(index: number): SVGTransform; + consolidate(): SVGTransform; + clear(): void; + appendItem(newItem: SVGTransform): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + removeItem(index: number): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; +} +declare var SVGTransformList: { + prototype: SVGTransformList; + new (): SVGTransformList; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; +} +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new (): HTMLHtmlElement; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new (): SVGPathSegClosePath; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; +} +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new (): HTMLFrameElement; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new (): SVGAnimatedLength; +} + +interface SVGAnimatedPoints { + points: SVGPointList; + animatedPoints: SVGPointList; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new (): SVGDefsElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new (): HTMLQuoteElement; +} + +interface CSSMediaRule extends CSSRule { + media: MediaList; + cssRules: CSSRuleList; + insertRule(rule: string, index?: number): number; + deleteRule(index?: number): void; +} +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new (): CSSMediaRule; +} + +interface WindowModal { + dialogArguments: any; + returnValue: any; +} + +interface XMLHttpRequest extends EventTarget { + responseBody: any; + status: number; + readyState: number; + responseText: string; + responseXML: Document; + ontimeout: (ev: Event) => any; + statusText: string; + onreadystatechange: (ev: Event) => any; + timeout: number; + onload: (ev: Event) => any; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + create(): XMLHttpRequest; + send(data?: any): void; + abort(): void; + getAllResponseHeaders(): string; + setRequestHeader(header: string, value: string): void; + getResponseHeader(header: string): string; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new (): XMLHttpRequest; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; +} +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new (): HTMLTableHeaderCellElement; +} + +interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { +} +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new (): HTMLDListElement; +} + +interface MSDataBindingExtensions { + dataSrc: string; + dataFormatAs: string; + dataFld: string; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new (): SVGPathSegLinetoHorizontalRel; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + ry: SVGAnimatedLength; + cx: SVGAnimatedLength; + rx: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new (): SVGEllipseElement; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; +} +declare var SVGAElement: { + prototype: SVGAElement; + new (): SVGAElement; +} + +interface SVGStylable { + className: SVGAnimatedString; + style: CSSStyleDeclaration; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface HTMLFrameSetElement extends HTMLElement { + ononline: (ev: Event) => any; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + /** + * Sets or retrieves the frame widths of the object. + */ + cols: string; + /** + * Fires when the object loses the input focus. + */ + onblur: (ev: FocusEvent) => any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Fires when the object receives focus. + */ + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + onerror: (ev: Event) => any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + onresize: (ev: UIEvent) => any; + name: string; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + border: string; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onstorage: (ev: StorageEvent) => any; +} +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new (): HTMLFrameSetElement; +} + +interface Screen { + width: number; + deviceXDPI: number; + fontSmoothingEnabled: boolean; + bufferDepth: number; + logicalXDPI: number; + systemXDPI: number; + availHeight: number; + height: number; + logicalYDPI: number; + systemYDPI: number; + updateInterval: number; + colorDepth: number; + availWidth: number; + deviceYDPI: number; + pixelDepth: number; +} +declare var Screen: { + prototype: Screen; + new (): Screen; +} + +interface Coordinates { + altitudeAccuracy: number; + longitude: number; + latitude: number; + speed: number; + heading: number; + altitude: number; + accuracy: number; +} +declare var Coordinates: { + prototype: Coordinates; + new (): Coordinates; +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorContentUtils { +} + +interface EventListener { + (evt: Event): void; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface DataTransfer { + effectAllowed: string; + dropEffect: string; + clearData(format?: string): boolean; + setData(format: string, data: string): boolean; + getData(format: string): string; +} +declare var DataTransfer: { + prototype: DataTransfer; + new (): DataTransfer; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} +declare var FocusEvent: { + prototype: FocusEvent; + new (): FocusEvent; +} + +interface Range { + startOffset: number; + collapsed: boolean; + endOffset: number; + startContainer: Node; + endContainer: Node; + commonAncestorContainer: Node; + setStart(refNode: Node, offset: number): void; + setEndBefore(refNode: Node): void; + setStartBefore(refNode: Node): void; + selectNode(refNode: Node): void; + detach(): void; + getBoundingClientRect(): ClientRect; + toString(): string; + compareBoundaryPoints(how: number, sourceRange: Range): number; + insertNode(newNode: Node): void; + collapse(toStart: boolean): void; + selectNodeContents(refNode: Node): void; + cloneContents(): DocumentFragment; + setEnd(refNode: Node, offset: number): void; + cloneRange(): Range; + getClientRects(): ClientRectList; + surroundContents(newParent: Node): void; + deleteContents(): void; + setStartAfter(refNode: Node): void; + extractContents(): DocumentFragment; + setEndAfter(refNode: Node): void; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} +declare var Range: { + prototype: Range; + new (): Range; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} + +interface SVGPoint { + y: number; + x: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} +declare var SVGPoint: { + prototype: SVGPoint; + new (): SVGPoint; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new (): MSPluginsCollection; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new (): SVGAnimatedNumberList; +} + +interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { + width: SVGAnimatedLength; + x: SVGAnimatedLength; + contentStyleType: string; + onzoom: (ev: any) => any; + y: SVGAnimatedLength; + viewport: SVGRect; + onerror: (ev: Event) => any; + pixelUnitToMillimeterY: number; + onresize: (ev: UIEvent) => any; + screenPixelToMillimeterY: number; + height: SVGAnimatedLength; + onabort: (ev: UIEvent) => any; + contentScriptType: string; + pixelUnitToMillimeterX: number; + currentTranslate: SVGPoint; + onunload: (ev: Event) => any; + currentScale: number; + onscroll: (ev: UIEvent) => any; + screenPixelToMillimeterX: number; + setCurrentTime(seconds: number): void; + createSVGLength(): SVGLength; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + unpauseAnimations(): void; + createSVGRect(): SVGRect; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + unsuspendRedrawAll(): void; + pauseAnimations(): void; + suspendRedraw(maxWaitMilliseconds: number): number; + deselectAll(): void; + createSVGAngle(): SVGAngle; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + createSVGTransform(): SVGTransform; + unsuspendRedraw(suspendHandleID: number): void; + forceRedraw(): void; + getCurrentTime(): number; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + createSVGMatrix(): SVGMatrix; + createSVGPoint(): SVGPoint; + createSVGNumber(): SVGNumber; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getElementById(elementId: string): Element; +} +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new (): SVGSVGElement; +} + +interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new (): HTMLLabelElement; +} + +interface MSResourceMetadata { + protocol: string; + fileSize: string; + fileUpdatedDate: string; + nameProp: string; + fileCreatedDate: string; + fileModifiedDate: string; + mimeType: string; +} + +interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new (): HTMLLegendElement; +} + +interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new (): HTMLDirectoryElement; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new (): SVGAnimatedInteger; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +} +declare var SVGTextElement: { + prototype: SVGTextElement; + new (): SVGTextElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new (): SVGTSpanElement; +} + +interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * Sets or retrieves the value of a list item. + */ + value: number; +} +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new (): HTMLLIElement; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new (): SVGPathSegLinetoVerticalAbs; +} + +interface MSStorageExtensions { + remainingSpace: number; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + type: string; + title: string; +} +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new (): SVGStyleElement; +} + +interface MSCurrentStyleCSSProperties extends MSCSSProperties { + blockDirection: string; + clipBottom: string; + clipLeft: string; + clipRight: string; + clipTop: string; + hasLayout: string; +} +declare var MSCurrentStyleCSSProperties: { + prototype: MSCurrentStyleCSSProperties; + new (): MSCurrentStyleCSSProperties; +} + +interface MSHTMLCollectionExtensions { + urns(urn: any): Object; + tags(tagName: any): Object; +} + +interface Storage extends MSStorageExtensions { + length: number; + getItem(key: string): any; + [key: string]: any; + setItem(key: string, data: string): void; + clear(): void; + removeItem(key: string): void; + key(index: number): string; + [index: number]: any; +} +declare var Storage: { + prototype: Storage; + new (): Storage; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Sets or retrieves the horizontal margin for the object. + */ + hspace: number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; +} +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new (): HTMLIFrameElement; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new (): TextRangeCollection; +} + +interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + scroll: string; + ononline: (ev: Event) => any; + onblur: (ev: FocusEvent) => any; + noWrap: boolean; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + text: any; + onerror: (ev: Event) => any; + bgProperties: string; + onresize: (ev: UIEvent) => any; + link: any; + aLink: any; + bottomMargin: any; + topMargin: any; + onafterprint: (ev: Event) => any; + vLink: any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + rightMargin: any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + leftMargin: any; + onstorage: (ev: StorageEvent) => any; + createTextRange(): TextRange; +} +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new (): HTMLBodyElement; +} + +interface DocumentType extends Node { + name: string; + notations: NamedNodeMap; + systemId: string; + internalSubset: string; + entities: NamedNodeMap; + publicId: string; +} +declare var DocumentType: { + prototype: DocumentType; + new (): DocumentType; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; +} +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new (): SVGRadialGradientElement; +} + +interface MutationEvent extends Event { + newValue: string; + attrChange: number; + attrName: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} +declare var MutationEvent: { + prototype: MutationEvent; + new (): MutationEvent; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(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, dataTransferArg: DataTransfer): void; +} +declare var DragEvent: { + prototype: DragEvent; + new (): DragEvent; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): Object; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; +} +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new (): HTMLTableSectionElement; +} + +interface DOML2DeprecatedListNumberingAndBulletStyle { + type: string; +} + +interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + status: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + indeterminate: boolean; + readOnly: boolean; + size: number; + loop: number; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. + */ + vrml: string; + /** + * Sets or retrieves a lower resolution image to display. + */ + lowsrc: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves a comma-separated list of content types. + */ + accept: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + defaultChecked: boolean; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Returns the value of the data at the cursor's current position. + */ + value: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + dynsrc: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + checked: boolean; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + start: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Makes the selection equal to the current object. + */ + select(): void; +} +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new (): HTMLInputElement; +} + +interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Contains the protocol of the URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Contains the hostname of a URL. + */ + hostname: string; + /** + * Contains the pathname of the URL. + */ + pathname: string; + Methods: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + protocolLong: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Contains the hostname and port values of the URL. + */ + host: string; + /** + * Contains the anchor portion of the URL including the hash sign (#). + */ + hash: string; + nameProp: string; + urn: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + type: string; + mimeType: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new (): HTMLAnchorElement; +} + +interface HTMLParamElement extends HTMLElement { + /** + * Sets or retrieves the value of an input parameter for an element. + */ + value: string; + /** + * Sets or retrieves the name of an input parameter for an element. + */ + name: string; + /** + * Sets or retrieves the content type of the resource designated by the value attribute. + */ + type: string; + /** + * Sets or retrieves the data type of the value attribute. + */ + valueType: string; +} +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new (): HTMLParamElement; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGImageElement: { + prototype: SVGImageElement; + new (): SVGImageElement; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new (): SVGAnimatedNumber; +} + +interface PerformanceTiming { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + msFirstPaint: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + toJSON(): any; +} +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new (): PerformanceTiming; +} + +interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + /** + * Indicates a citation by rendering text in italic type. + */ + cite: string; +} +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new (): HTMLPreElement; +} + +interface EventException { + code: number; + message: string; + toString(): string; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} +declare var EventException: { + prototype: EventException; + new (): EventException; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} + +interface MSNavigatorDoNotTrack { + msDoNotTrack: string; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface SVGMetadataElement extends SVGElement { +} +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new (): SVGMetadataElement; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new (): SVGPathSegArcRel; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new (): SVGPathSegMovetoAbs; +} + +interface SVGStringList { + numberOfItems: number; + replaceItem(newItem: string, index: number): string; + getItem(index: number): string; + clear(): void; + appendItem(newItem: string): string; + initialize(newItem: string): string; + removeItem(index: number): string; + insertItemBefore(newItem: string, index: number): string; +} +declare var SVGStringList: { + prototype: SVGStringList; + new (): SVGStringList; +} + +interface XDomainRequest { + timeout: number; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onprogress: (ev: any) => any; + ontimeout: (ev: Event) => any; + responseText: string; + contentType: string; + open(method: string, url: string): void; + create(): XDomainRequest; + abort(): void; + send(data?: any): void; +} +declare var XDomainRequest: { + prototype: XDomainRequest; + new (): XDomainRequest; +} + +interface DOML2DeprecatedBackgroundColorStyle { + bgColor: any; +} + +interface ElementTraversal { + childElementCount: number; + previousElementSibling: Element; + lastElementChild: Element; + nextElementSibling: Element; + firstElementChild: Element; +} + +interface SVGLength { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} +declare var SVGLength: { + prototype: SVGLength; + new (): SVGLength; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new (): SVGPolygonElement; +} + +interface HTMLPhraseElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new (): HTMLPhraseElement; +} + +interface NavigatorStorageUtils { +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new (): SVGPathSegCurvetoCubicRel; +} + +interface MSEventObj extends Event { + nextPage: string; + keyCode: number; + toElement: Element; + returnValue: any; + dataFld: string; + y: number; + dataTransfer: DataTransfer; + propertyName: string; + url: string; + offsetX: number; + recordset: Object; + screenX: number; + buttonID: number; + wheelDelta: number; + reason: number; + origin: string; + data: string; + srcFilter: Object; + boundElements: HTMLCollection; + cancelBubble: boolean; + altLeft: boolean; + behaviorCookie: number; + bookmarks: BookmarkCollection; + type: string; + repeat: boolean; + srcElement: Element; + source: Window; + fromElement: Element; + offsetY: number; + x: number; + behaviorPart: number; + qualifier: string; + altKey: boolean; + ctrlKey: boolean; + clientY: number; + shiftKey: boolean; + shiftLeft: boolean; + contentOverflow: boolean; + screenY: number; + ctrlLeft: boolean; + button: number; + srcUrn: string; + clientX: number; + actionURL: string; + getAttribute(strAttributeName: string, lFlags?: number): any; + setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; + removeAttribute(strAttributeName: string, lFlags?: number): boolean; +} +declare var MSEventObj: { + prototype: MSEventObj; + new (): MSEventObj; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + textLength: SVGAnimatedLength; + lengthAdjust: SVGAnimatedEnumeration; + getCharNumAtPosition(point: SVGPoint): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getComputedTextLength(): number; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getEndPositionOfChar(charnum: number): SVGPoint; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new (): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface HTMLCanvasElement extends HTMLElement { + /** + * Gets or sets the width of a canvas element on a document. + */ + width: number; + /** + * Gets or sets the height of a canvas element on a document. + */ + height: number; + /** + * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. + * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. + */ + toDataURL(type?: string, ...args: any[]): string; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @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: { + prototype: HTMLCanvasElement; + new (): HTMLCanvasElement; +} + +interface Location { + hash: string; + protocol: string; + search: string; + href: string; + hostname: string; + port: string; + pathname: string; + host: string; + reload(flag?: boolean): void; + replace(url: string): void; + assign(url: string): void; + toString(): string; +} +declare var Location: { + prototype: Location; + new (): Location; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new (): HTMLTitleElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; +} +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new (): HTMLStyleElement; +} + +interface PerformanceEntry { + name: string; + startTime: number; + duration: number; + entryType: string; +} +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new (): PerformanceEntry; +} + +interface SVGTransform { + type: number; + angle: number; + matrix: SVGMatrix; + setTranslate(tx: number, ty: number): void; + setScale(sx: number, sy: number): void; + setMatrix(matrix: SVGMatrix): void; + setSkewY(angle: number): void; + setRotate(angle: number, cx: number, cy: number): void; + setSkewX(angle: number): void; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} +declare var SVGTransform: { + prototype: SVGTransform; + new (): SVGTransform; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} +declare var UIEvent: { + prototype: UIEvent; + new (): UIEvent; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new (): SVGPathSeg; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} + +interface WheelEvent extends MouseEvent { + deltaZ: number; + deltaX: number; + deltaMode: number; + deltaY: number; + initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} +declare var WheelEvent: { + prototype: WheelEvent; + new (): WheelEvent; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} + +interface MSEventAttachmentTarget { + attachEvent(event: string, listener: EventListener): boolean; + detachEvent(event: string, listener: EventListener): void; +} + +interface SVGNumber { + value: number; +} +declare var SVGNumber: { + prototype: SVGNumber; + new (): SVGNumber; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + getTotalLength(): number; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; +} +declare var SVGPathElement: { + prototype: SVGPathElement; + new (): SVGPathElement; +} + +interface MSCompatibleInfo { + version: string; + userAgent: string; +} +declare var MSCompatibleInfo: { + prototype: MSCompatibleInfo; + new (): MSCompatibleInfo; +} + +interface Text extends CharacterData, MSNodeExtensions { + wholeText: string; + splitText(offset: number): Text; + replaceWholeText(content: string): Text; +} +declare var Text: { + prototype: Text; + new (): Text; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new (): SVGAnimatedRect; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new (): CSSNamespaceRule; +} + +interface SVGPathSegList { + numberOfItems: number; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; + getItem(index: number): SVGPathSeg; + clear(): void; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; +} +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new (): SVGPathSegList; +} + +interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { +} +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new (): HTMLUnknownElement; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new (): HTMLAudioElement; +} + +interface MSImageResourceExtensions { + dynsrc: string; + vrml: string; + lowsrc: string; + start: string; + loop: number; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} +declare var PositionError: { + prototype: PositionError; + new (): PositionError; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves a list of header cells that provide information for the object. + */ + headers: string; + /** + * Retrieves the position of the object in the cells collection of a row. + */ + cellIndex: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the number columns in the table that the object should span. + */ + colSpan: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. + */ + axis: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; + /** + * Sets or retrieves abbreviated text for the object. + */ + abbr: string; + /** + * Sets or retrieves how many rows in a table the cell should span. + */ + rowSpan: number; + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; +} +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new (): HTMLTableCellElement; +} + +interface SVGElementInstance extends EventTarget { + previousSibling: SVGElementInstance; + parentNode: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + childNodes: SVGElementInstanceList; + correspondingUseElement: SVGUseElement; + correspondingElement: SVGElement; + firstChild: SVGElementInstance; +} +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new (): SVGElementInstance; +} + +interface MSNamespaceInfoCollection { + length: number; + add(namespace?: string, urn?: string, implementationUrl?: any): Object; + item(index: any): Object; + [index: string]: Object; +} +declare var MSNamespaceInfoCollection: { + prototype: MSNamespaceInfoCollection; + new (): MSNamespaceInfoCollection; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new (): SVGCircleElement; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} +declare var StyleSheetList: { + prototype: StyleSheetList; + new (): StyleSheetList; +} + +interface CSSImportRule extends CSSRule { + styleSheet: CSSStyleSheet; + href: string; + media: MediaList; +} +declare var CSSImportRule: { + prototype: CSSImportRule; + new (): CSSImportRule; +} + +interface CustomEvent extends Event { + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; +} +declare var CustomEvent: { + prototype: CustomEvent; + new (): CustomEvent; +} + +interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + /** + * Sets or retrieves the font size of the object. + */ + size: number; +} +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new (): HTMLBaseFontElement; +} + +interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves or sets the text in the entry field of the textArea element. + */ + value: string; + /** + * Sets or retrieves the value indicating whether the control is selected. + */ + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: number; + /** + * Sets or retrieves the width of the object. + */ + cols: number; + /** + * Sets or retrieves the value indicated whether the content of the object is read-only. + */ + readOnly: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Retrieves the type of control. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Highlights the input area of a form element. + */ + select(): void; +} +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new (): HTMLTextAreaElement; +} + +interface Geolocation { + clearWatch(watchId: number): void; + getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; + watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; +} +declare var Geolocation: { + prototype: Geolocation; + new (): Geolocation; +} + +interface DOML2DeprecatedMarginStyle { + vspace: number; + hspace: number; +} + +interface MSWindowModeless { + dialogTop: any; + dialogLeft: any; + dialogWidth: any; + dialogHeight: any; + menuArguments: any; +} + +interface DOML2DeprecatedAlignmentStyle { + align: string; +} + +interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { + width: string; + onbounce: (ev: Event) => any; + vspace: number; + trueSpeed: boolean; + scrollAmount: number; + scrollDelay: number; + behavior: string; + height: string; + loop: number; + direction: string; + hspace: number; + onstart: (ev: Event) => any; + onfinish: (ev: Event) => any; + stop(): void; + start(): void; +} +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new (): HTMLMarqueeElement; +} + +interface SVGRect { + y: number; + width: number; + x: number; + height: number; +} +declare var SVGRect: { + prototype: SVGRect; + new (): SVGRect; +} + +interface MSNodeExtensions { + swapNode(otherNode: Node): Node; + removeNode(deep?: boolean): Node; + replaceNode(replacement: Node): Node; +} + +interface History { + length: number; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; +} +declare var History: { + prototype: History; + new (): History; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new (): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new (): SVGPathSegCurvetoQuadraticAbs; +} + +interface TimeRanges { + length: number; + start(index: number): number; + end(index: number): number; +} +declare var TimeRanges: { + prototype: TimeRanges; + new (): TimeRanges; +} + +interface CSSRule { + cssText: string; + parentStyleSheet: CSSStyleSheet; + parentRule: CSSRule; + type: number; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} +declare var CSSRule: { + prototype: CSSRule; + new (): CSSRule; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new (): SVGPathSegLinetoAbs; +} + +interface HTMLModElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLModElement: { + prototype: HTMLModElement; + new (): HTMLModElement; +} + +interface SVGMatrix { + e: number; + c: number; + a: number; + b: number; + d: number; + f: number; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + flipY(): SVGMatrix; + skewY(angle: number): SVGMatrix; + inverse(): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + rotate(angle: number): SVGMatrix; + flipX(): SVGMatrix; + translate(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + skewX(angle: number): SVGMatrix; +} +declare var SVGMatrix: { + prototype: SVGMatrix; + new (): SVGMatrix; +} + +interface MSPopupWindow { + document: Document; + isOpen: boolean; + show(x: number, y: number, w: number, h: number, element?: any): void; + hide(): void; +} +declare var MSPopupWindow: { + prototype: MSPopupWindow; + new (): MSPopupWindow; +} + +interface BeforeUnloadEvent extends Event { + returnValue: string; +} +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new (): BeforeUnloadEvent; +} + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + animatedInstanceRoot: SVGElementInstance; + instanceRoot: SVGElementInstance; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGUseElement: { + prototype: SVGUseElement; + new (): SVGUseElement; +} + +interface Event { + timeStamp: number; + defaultPrevented: boolean; + isTrusted: boolean; + currentTarget: EventTarget; + cancelBubble: boolean; + target: EventTarget; + eventPhase: number; + cancelable: boolean; + type: string; + srcElement: Element; + bubbles: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + stopPropagation(): void; + stopImmediatePropagation(): void; + preventDefault(): void; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} +declare var Event: { + prototype: Event; + new (): Event; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} + +interface ImageData { + width: number; + data: Uint8Array; + height: number; +} +declare var ImageData: { + prototype: ImageData; + new (): ImageData; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves the alignment of the object relative to the display or table. + */ + align: string; + /** + * Sets or retrieves the number of columns in the group. + */ + span: number; +} +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new (): HTMLTableColElement; +} + +interface SVGException { + code: number; + message: string; + toString(): string; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} +declare var SVGException: { + prototype: SVGException; + new (): SVGException; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new (): SVGLinearGradientElement; +} + +interface HTMLTableAlignment { + /** + * Sets or retrieves a value that you can use to implement your own ch functionality for the object. + */ + ch: string; + /** + * Sets or retrieves how text and other content are vertically aligned within the object that contains them. + */ + vAlign: string; + /** + * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. + */ + chOff: string; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new (): SVGAnimatedEnumeration; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new (): HTMLUListElement; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + ry: SVGAnimatedLength; + rx: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGRectElement: { + prototype: SVGRectElement; + new (): SVGRectElement; +} + +interface ErrorEventHandler { + (event: Event, source: string, fileno: number, columnNumber: number): void; + (message: any, uri: string, lineNumber: number, columnNumber?: number): void; +} + +interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new (): HTMLDivElement; +} + +interface DOML2DeprecatedBorderStyle { + border: string; +} + +interface NamedNodeMap { + length: number; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + [index: number]: Attr; + removeNamedItem(name: string): Attr; + getNamedItem(name: string): Attr; + setNamedItem(arg: Attr): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItemNS(arg: Attr): Attr; +} +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new (): NamedNodeMap; +} + +interface MediaList { + length: number; + mediaText: string; + deleteMedium(oldMedium: string): void; + appendMedium(newMedium: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var MediaList: { + prototype: MediaList; + new (): MediaList; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new (): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new (): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGLengthList { + numberOfItems: number; + replaceItem(newItem: SVGLength, index: number): SVGLength; + getItem(index: number): SVGLength; + clear(): void; + appendItem(newItem: SVGLength): SVGLength; + initialize(newItem: SVGLength): SVGLength; + removeItem(index: number): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; +} +declare var SVGLengthList: { + prototype: SVGLengthList; + new (): SVGLengthList; +} + +interface ProcessingInstruction extends Node { + target: string; + data: string; +} +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new (): ProcessingInstruction; +} + +interface MSWindowExtensions { + status: string; + onmouseleave: (ev: MouseEvent) => any; + screenLeft: number; + offscreenBuffering: any; + maxConnectionsPerServer: number; + onmouseenter: (ev: MouseEvent) => any; + clipboardData: DataTransfer; + defaultStatus: string; + clientInformation: Navigator; + closed: boolean; + onhelp: (ev: Event) => any; + external: External; + event: MSEventObj; + onfocusout: (ev: FocusEvent) => any; + screenTop: number; + onfocusin: (ev: FocusEvent) => any; + showModelessDialog(url?: string, argument?: any, options?: any): Window; + navigate(url: string): void; + resizeBy(x?: number, y?: number): void; + item(index: any): any; + resizeTo(x?: number, y?: number): void; + createPopup(arguments?: any): MSPopupWindow; + toStaticHTML(html: string): string; + execScript(code: string, language?: string): any; + msWriteProfilerMark(profilerMarkName: string): void; + moveTo(x?: number, y?: number): void; + moveBy(x?: number, y?: number): void; + showHelp(url: string, helpArg?: any, features?: string): void; +} + +interface MSBehaviorUrnsCollection { + length: number; + item(index: number): string; +} +declare var MSBehaviorUrnsCollection: { + prototype: MSBehaviorUrnsCollection; + new (): MSBehaviorUrnsCollection; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new (): CSSFontFaceRule; +} + +interface DOML2DeprecatedBackgroundStyle { + background: string; +} + +interface TextEvent extends UIEvent { + inputMethod: number; + data: string; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} +declare var TextEvent: { + prototype: TextEvent; + new (): TextEvent; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} + +interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { +} +declare var DocumentFragment: { + prototype: DocumentFragment; + new (): DocumentFragment; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new (): SVGPolylineElement; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface Position { + timestamp: number; + coords: Coordinates; +} +declare var Position: { + prototype: Position; + new (): Position; +} + +interface BookmarkCollection { + length: number; + item(index: number): any; + [index: number]: any; +} +declare var BookmarkCollection: { + prototype: BookmarkCollection; + new (): BookmarkCollection; +} + +interface PerformanceMark extends PerformanceEntry { +} +declare var PerformanceMark: { + prototype: PerformanceMark; + new (): PerformanceMark; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selectorText: string; + selector: string; + style: CSSStyleDeclaration; +} +declare var CSSPageRule: { + prototype: CSSPageRule; + new (): CSSPageRule; +} + +interface HTMLBRElement extends HTMLElement { + /** + * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. + */ + clear: string; +} +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new (): HTMLBRElement; +} + +interface MSNavigatorExtensions { + userLanguage: string; + plugins: MSPluginsCollection; + cookieEnabled: boolean; + appCodeName: string; + cpuClass: string; + appMinorVersion: string; + connectionSpeed: number; + browserLanguage: string; + mimeTypes: MSMimeTypesCollection; + systemLanguage: string; + javaEnabled(): boolean; + taintEnabled(): boolean; +} + +interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { +} +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new (): HTMLSpanElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new (): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; +} +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new (): HTMLHeadingElement; +} + +interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. + */ + acceptCharset: string; + /** + * Sets or retrieves the encoding type for the form. + */ + enctype: string; + /** + * Retrieves a collection, in source order, of all controls in a given form. + */ + elements: HTMLCollection; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves how to send the form data to the server. + */ + method: string; + /** + * Sets or retrieves the MIME encoding for the form. + */ + encoding: string; + /** + * Fires when the user resets a form. + */ + reset(): void; + /** + * Retrieves a form object or an object from an elements collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Fires when a FORM is about to be submitted. + */ + submit(): void; + /** + * Retrieves a form object or an object from an elements collection. + */ + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new (): HTMLFormElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} +declare var SVGZoomAndPan: { + prototype: SVGZoomAndPan; + new (): SVGZoomAndPan; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Gets the earliest possible position, in seconds, that the playback can begin. + */ + initialTime: number; + /** + * Gets TimeRanges for the current media resource that has been played. + */ + played: TimeRanges; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + currentSrc: string; + readyState: any; + /** + * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. + */ + autobuffer: boolean; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + /** + * Gets information about whether the playback has ended or not. + */ + ended: boolean; + /** + * Gets a collection of buffered time ranges. + */ + buffered: TimeRanges; + /** + * Returns an object representing the current error state of the audio or video element. + */ + error: MediaError; + /** + * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + */ + seekable: TimeRanges; + /** + * Gets or sets a value that indicates whether to start playing the media automatically. + */ + autoplay: boolean; + /** + * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + */ + controls: boolean; + /** + * Gets or sets the volume level for audio portions of the media element. + */ + volume: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. + */ + playbackRate: number; + /** + * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + */ + duration: number; + /** + * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + */ + muted: boolean; + /** + * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. + */ + defaultPlaybackRate: number; + /** + * Gets a flag that specifies whether playback is paused. + */ + paused: boolean; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + seeking: boolean; + /** + * Gets or sets the current playback position, in seconds. + */ + currentTime: number; + /** + * Gets or sets the current playback position, in seconds. + */ + preload: string; + /** + * Gets the current network activity for the element. + */ + networkState: number; + /** + * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. + */ + pause(): void; + /** + * Loads and starts playback of a media resource. + */ + play(): void; + /** + * Fires immediately after the client loads the object. + */ + load(): void; + /** + * Returns a string that specifies whether the client can play a given media resource type. + */ + canPlayType(type: string): string; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new (): HTMLMediaElement; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} + +interface ElementCSSInlineStyle { + runtimeStyle: MSStyleCSSProperties; + currentStyle: MSCurrentStyleCSSProperties; + doScroll(component?: any): void; + componentFromPoint(x: number, y: number): string; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} +declare var DOMParser: { + prototype: DOMParser; + new (): DOMParser; +} + +interface MSMimeTypesCollection { + length: number; +} +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new (): MSMimeTypesCollection; +} + +interface StyleSheet { + disabled: boolean; + ownerNode: Node; + parentStyleSheet: StyleSheet; + href: string; + media: MediaList; + type: string; + title: string; +} +declare var StyleSheet: { + prototype: StyleSheet; + new (): StyleSheet; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + startOffset: SVGAnimatedLength; + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new (): SVGTextPathElement; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} + +interface HTMLDTElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new (): HTMLDTElement; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} +declare var NodeList: { + prototype: NodeList; + new (): NodeList; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} +declare var XMLSerializer: { + prototype: XMLSerializer; + new (): XMLSerializer; +} + +interface PerformanceMeasure extends PerformanceEntry { +} +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new (): PerformanceMeasure; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { + spreadMethod: SVGAnimatedEnumeration; + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new (): SVGGradientElement; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} +declare var NodeFilter: { + prototype: NodeFilter; + new (): NodeFilter; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} + +interface SVGNumberList { + numberOfItems: number; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; + getItem(index: number): SVGNumber; + clear(): void; + appendItem(newItem: SVGNumber): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + removeItem(index: number): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; +} +declare var SVGNumberList: { + prototype: SVGNumberList; + new (): SVGNumberList; +} + +interface MediaError { + code: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} +declare var MediaError: { + prototype: MediaError; + new (): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} + +interface HTMLFieldSetElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new (): HTMLFieldSetElement; +} + +interface HTMLBGSoundElement extends HTMLElement { + /** + * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. + */ + balance: any; + /** + * Sets or gets the volume setting for the sound. + */ + volume: any; + /** + * Sets or gets the URL of a sound to play. + */ + src: string; + /** + * Sets or retrieves the number of times a sound or video clip will loop when activated. + */ + loop: number; +} +declare var HTMLBGSoundElement: { + prototype: HTMLBGSoundElement; + new (): HTMLBGSoundElement; +} + +interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { + onmouseleave: (ev: MouseEvent) => any; + onbeforecut: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + onmove: (ev: MSEventObj) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onhelp: (ev: Event) => any; + ondragleave: (ev: DragEvent) => any; + className: string; + onfocusin: (ev: FocusEvent) => any; + onseeked: (ev: Event) => any; + recordNumber: any; + title: string; + parentTextEdit: Element; + outerHTML: string; + ondurationchange: (ev: Event) => any; + offsetHeight: number; + all: HTMLCollection; + onblur: (ev: FocusEvent) => any; + dir: string; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + ondeactivate: (ev: UIEvent) => any; + ondatasetchanged: (ev: MSEventObj) => any; + onrowsdelete: (ev: MSEventObj) => any; + sourceIndex: number; + onloadstart: (ev: Event) => any; + onlosecapture: (ev: MSEventObj) => any; + ondragenter: (ev: DragEvent) => any; + oncontrolselect: (ev: MSEventObj) => any; + onsubmit: (ev: Event) => any; + behaviorUrns: MSBehaviorUrnsCollection; + scopeName: string; + onchange: (ev: Event) => any; + id: string; + onlayoutcomplete: (ev: MSEventObj) => any; + uniqueID: string; + onbeforeactivate: (ev: UIEvent) => any; + oncanplaythrough: (ev: Event) => any; + onbeforeupdate: (ev: MSEventObj) => any; + onfilterchange: (ev: MSEventObj) => any; + offsetParent: Element; + ondatasetcomplete: (ev: MSEventObj) => any; + onsuspend: (ev: Event) => any; + readyState: any; + onmouseenter: (ev: MouseEvent) => any; + innerText: string; + onerrorupdate: (ev: MSEventObj) => any; + onmouseout: (ev: MouseEvent) => any; + parentElement: HTMLElement; + onmousewheel: (ev: MouseWheelEvent) => any; + onvolumechange: (ev: Event) => any; + oncellchange: (ev: MSEventObj) => any; + onrowexit: (ev: MSEventObj) => any; + onrowsinserted: (ev: MSEventObj) => any; + onpropertychange: (ev: MSEventObj) => any; + filters: Object; + children: HTMLCollection; + ondragend: (ev: DragEvent) => any; + onbeforepaste: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + offsetTop: number; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + onbeforecopy: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + innerHTML: string; + onmouseover: (ev: MouseEvent) => any; + lang: string; + uniqueNumber: number; + onpause: (ev: Event) => any; + tagUrn: string; + onmousedown: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + onwaiting: (ev: Event) => any; + onresizestart: (ev: MSEventObj) => any; + offsetLeft: number; + isTextEdit: boolean; + isDisabled: boolean; + onpaste: (ev: DragEvent) => any; + canHaveHTML: boolean; + onmoveend: (ev: MSEventObj) => any; + language: string; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + style: MSStyleCSSProperties; + isContentEditable: boolean; + onbeforeeditfocus: (ev: MSEventObj) => any; + onratechange: (ev: Event) => any; + contentEditable: string; + tabIndex: number; + document: Document; + onprogress: (ev: any) => any; + ondblclick: (ev: MouseEvent) => any; + oncontextmenu: (ev: MouseEvent) => any; + onloadedmetadata: (ev: Event) => any; + onafterupdate: (ev: MSEventObj) => any; + onerror: (ev: Event) => any; + onplay: (ev: Event) => any; + onresizeend: (ev: MSEventObj) => any; + onplaying: (ev: Event) => any; + isMultiLine: boolean; + onfocusout: (ev: FocusEvent) => any; + onabort: (ev: UIEvent) => any; + ondataavailable: (ev: MSEventObj) => any; + hideFocus: boolean; + onreadystatechange: (ev: Event) => any; + onkeypress: (ev: KeyboardEvent) => any; + onloadeddata: (ev: Event) => any; + onbeforedeactivate: (ev: UIEvent) => any; + outerText: string; + disabled: boolean; + onactivate: (ev: UIEvent) => any; + accessKey: string; + onmovestart: (ev: MSEventObj) => any; + onselectstart: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + oncut: (ev: DragEvent) => any; + onselect: (ev: UIEvent) => any; + ondrop: (ev: DragEvent) => any; + offsetWidth: number; + oncopy: (ev: DragEvent) => any; + onended: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + onrowenter: (ev: MSEventObj) => any; + onload: (ev: Event) => any; + canHaveChildren: boolean; + oninput: (ev: Event) => any; + dragDrop(): boolean; + scrollIntoView(top?: boolean): void; + addFilter(filter: Object): void; + setCapture(containerCapture?: boolean): void; + focus(): void; + getAdjacentText(where: string): string; + insertAdjacentText(where: string, text: string): void; + getElementsByClassName(classNames: string): NodeList; + setActive(): void; + removeFilter(filter: Object): void; + blur(): void; + clearAttributes(): void; + releaseCapture(): void; + createControlRange(): ControlRangeCollection; + removeBehavior(cookie: number): boolean; + contains(child: HTMLElement): boolean; + click(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; + replaceAdjacentText(where: string, newText: string): string; + applyElement(apply: Element, where?: string): Element; + addBehavior(bstrUrl: string, factory?: any): number; + insertAdjacentHTML(where: string, html: string): void; +} +declare var HTMLElement: { + prototype: HTMLElement; + new (): HTMLElement; +} + +interface Comment extends CharacterData { + text: string; +} +declare var Comment: { + prototype: Comment; + new (): Comment; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + redirectStart: number; + redirectEnd: number; + domainLookupEnd: number; + responseStart: number; + domainLookupStart: number; + fetchStart: number; + requestStart: number; + connectEnd: number; + connectStart: number; + initiatorType: string; + responseEnd: number; +} +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new (): PerformanceResourceTiming; +} + +interface CanvasPattern { +} +declare var CanvasPattern: { + prototype: CanvasPattern; + new (): CanvasPattern; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. + */ + noShade: boolean; +} +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new (): HTMLHRElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Retrieves the contained object. + */ + object: Object; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL of the file containing the compiled Java class. + */ + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + declare: boolean; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new (): HTMLObjectElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Retrieves the palette used for the embedded document. + */ + palette: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + pluginspage: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the height and width units of the embed object. + */ + units: string; +} +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new (): HTMLEmbedElement; +} + +interface StorageEvent extends Event { + oldValue: any; + newValue: any; + url: string; + storageArea: Storage; + key: string; + initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; +} +declare var StorageEvent: { + prototype: StorageEvent; + new (): StorageEvent; +} + +interface CharacterData extends Node { + length: number; + data: string; + deleteData(offset: number, count: number): void; + replaceData(offset: number, count: number, arg: string): void; + appendData(arg: string): void; + insertData(offset: number, arg: string): void; + substringData(offset: number, count: number): string; +} +declare var CharacterData: { + prototype: CharacterData; + new (): CharacterData; +} + +interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; +} +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new (): HTMLOptGroupElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + prompt: string; +} +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new (): HTMLIsIndexElement; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new (): SVGPathSegLinetoRel; +} + +interface DOMException { + code: number; + message: string; + toString(): string; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} +declare var DOMException: { + prototype: DOMException; + new (): DOMException; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new (): SVGAnimatedBoolean; +} + +interface MSCompatibleInfoCollection { + length: number; + item(index: number): MSCompatibleInfo; +} +declare var MSCompatibleInfoCollection: { + prototype: MSCompatibleInfoCollection; + new (): MSCompatibleInfoCollection; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new (): SVGSwitchElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new (): SVGPreserveAspectRatio; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} + +interface Attr extends Node { + expando: boolean; + specified: boolean; + ownerElement: Element; + value: string; + name: string; +} +declare var Attr: { + prototype: Attr; + new (): Attr; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new (): PerformanceNavigation; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; +} +declare var SVGStopElement: { + prototype: SVGStopElement; + new (): SVGStopElement; +} + +interface PositionCallback { + (position: Position): void; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { +} +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new (): SVGSymbolElement; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new (): SVGElementInstanceList; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} +declare var CSSRuleList: { + prototype: CSSRuleList; + new (): CSSRuleList; +} + +interface MSDataBindingRecordSetExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface LinkStyle { + styleSheet: StyleSheet; + sheet: StyleSheet; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the width of the video element. + */ + width: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoWidth: number; + /** + * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoHeight: number; + /** + * Gets or sets the height of the video element. + */ + height: number; + /** + * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. + */ + poster: string; +} +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new (): HTMLVideoElement; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} +declare var ClientRectList: { + prototype: ClientRectList; + new (): ClientRectList; +} + +interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + maskUnits: SVGAnimatedEnumeration; + maskContentUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new (): SVGMaskElement; +} + +interface External { +} +declare var External: { + prototype: External; + new (): External; +} + +declare var Audio: { new (src?: string): HTMLAudioElement; }; +declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; +declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; + +declare var ondragend: (ev: DragEvent) => any; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare var ondragover: (ev: DragEvent) => any; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare var onreset: (ev: Event) => any; +declare var onmouseup: (ev: MouseEvent) => any; +declare var ondragstart: (ev: DragEvent) => any; +declare var ondrag: (ev: DragEvent) => any; +declare var screenX: number; +declare var onmouseover: (ev: MouseEvent) => any; +declare var ondragleave: (ev: DragEvent) => any; +declare var history: History; +declare var pageXOffset: number; +declare var name: string; +declare var onafterprint: (ev: Event) => any; +declare var onpause: (ev: Event) => any; +declare var onbeforeprint: (ev: Event) => any; +declare var top: Window; +declare var onmousedown: (ev: MouseEvent) => any; +declare var onseeked: (ev: Event) => any; +declare var opener: Window; +declare var onclick: (ev: MouseEvent) => any; +declare var innerHeight: number; +declare var onwaiting: (ev: Event) => any; +declare var ononline: (ev: Event) => any; +declare var ondurationchange: (ev: Event) => any; +declare var frames: Window; +declare var onblur: (ev: FocusEvent) => any; +declare var onemptied: (ev: Event) => any; +declare var onseeking: (ev: Event) => any; +declare var oncanplay: (ev: Event) => any; +declare var outerWidth: number; +declare var onstalled: (ev: Event) => any; +declare var onmousemove: (ev: MouseEvent) => any; +declare var innerWidth: number; +declare var onoffline: (ev: Event) => any; +declare var length: number; +declare var screen: Screen; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare var onratechange: (ev: Event) => any; +declare var onstorage: (ev: StorageEvent) => any; +declare var onloadstart: (ev: Event) => any; +declare var ondragenter: (ev: DragEvent) => any; +declare var onsubmit: (ev: Event) => any; +declare var self: Window; +declare var document: Document; +declare var onprogress: (ev: any) => any; +declare var ondblclick: (ev: MouseEvent) => any; +declare var pageYOffset: number; +declare var oncontextmenu: (ev: MouseEvent) => any; +declare var onchange: (ev: Event) => any; +declare var onloadedmetadata: (ev: Event) => any; +declare var onplay: (ev: Event) => any; +declare var onerror: ErrorEventHandler; +declare var onplaying: (ev: Event) => any; +declare var parent: Window; +declare var location: Location; +declare var oncanplaythrough: (ev: Event) => any; +declare var onabort: (ev: UIEvent) => any; +declare var onreadystatechange: (ev: Event) => any; +declare var outerHeight: number; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare var frameElement: Element; +declare var onloadeddata: (ev: Event) => any; +declare var onsuspend: (ev: Event) => any; +declare var window: Window; +declare var onfocus: (ev: FocusEvent) => any; +declare var onmessage: (ev: MessageEvent) => any; +declare var ontimeupdate: (ev: Event) => any; +declare var onresize: (ev: UIEvent) => any; +declare var onselect: (ev: UIEvent) => any; +declare var navigator: Navigator; +declare var styleMedia: StyleMedia; +declare var ondrop: (ev: DragEvent) => any; +declare var onmouseout: (ev: MouseEvent) => any; +declare var onended: (ev: Event) => any; +declare var onhashchange: (ev: Event) => any; +declare var onunload: (ev: Event) => any; +declare var onscroll: (ev: UIEvent) => any; +declare var screenY: number; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onload: (ev: Event) => any; +declare var onvolumechange: (ev: Event) => any; +declare var oninput: (ev: Event) => any; +declare var performance: Performance; +declare function alert(message?: any): void; +declare function scroll(x?: number, y?: number): void; +declare function focus(): void; +declare function scrollTo(x?: number, y?: number): void; +declare function print(): void; +declare function prompt(message?: string, defaul?: string): string; +declare function toString(): string; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function scrollBy(x?: number, y?: number): void; +declare function confirm(message?: string): boolean; +declare function close(): void; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function showModalDialog(url?: string, argument?: any, options?: any): any; +declare function blur(): void; +declare function getSelection(): Selection; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function attachEvent(event: string, listener: EventListener): boolean; +declare function detachEvent(event: string, listener: EventListener): void; +declare var localStorage: Storage; +declare var status: string; +declare var onmouseleave: (ev: MouseEvent) => any; +declare var screenLeft: number; +declare var offscreenBuffering: any; +declare var maxConnectionsPerServer: number; +declare var onmouseenter: (ev: MouseEvent) => any; +declare var clipboardData: DataTransfer; +declare var defaultStatus: string; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var onhelp: (ev: Event) => any; +declare var external: External; +declare var event: MSEventObj; +declare var onfocusout: (ev: FocusEvent) => any; +declare var screenTop: number; +declare var onfocusin: (ev: FocusEvent) => any; +declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; +declare function navigate(url: string): void; +declare function resizeBy(x?: number, y?: number): void; +declare function item(index: any): any; +declare function resizeTo(x?: number, y?: number): void; +declare function createPopup(arguments?: any): MSPopupWindow; +declare function toStaticHTML(html: string): string; +declare function execScript(code: string, language?: string): any; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function moveTo(x?: number, y?: number): void; +declare function moveBy(x?: number, y?: number): void; +declare function showHelp(url: string, helpArg?: any, features?: string): void; +declare var sessionStorage: Storage; +declare function clearTimeout(handle: number): void; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearInterval(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; + + +///////////////////////////// +/// IE10 DOM APIs +///////////////////////////// + + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface HTMLBodyElement { + onpopstate: (ev: PopStateEvent) => any; +} + +interface MSGestureEvent extends UIEvent { + offsetY: number; + translationY: number; + velocityExpansion: number; + velocityY: number; + velocityAngular: number; + translationX: number; + velocityX: number; + hwTimestamp: number; + offsetX: number; + screenX: number; + rotation: number; + expansion: number; + clientY: number; + screenY: number; + scale: number; + gestureObject: any; + clientX: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} +declare var MSGestureEvent: { + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface HTMLAnchorElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} + +interface HTMLInputElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a FileList object on a file type input object. + */ + files: FileList; + /** + * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. + */ + max: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. + */ + step: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Returns the input field value as a number. + */ + valueAsNumber: number; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Specifies the ID of a pre-defined datalist of options for an input element. + */ + list: HTMLElement; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. + */ + min: string; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Gets or sets a string containing a regular expression that the user's input must match. + */ + pattern: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. + * @param n Value to decrement the value by. + */ + stepDown(n?: number): void; + /** + * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. + * @param n Value to increment the value by. + */ + stepUp(n?: number): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +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; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + filterResX: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + primitiveUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + filterResY: SVGAnimatedInteger; + setFilterRes(filterResX: number, filterResY: number): void; +} + +interface TrackEvent extends Event { + track: any; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} +declare var MSGesture: { + prototype: MSGesture; + new (): MSGesture; +} + +interface TextTrackCue extends EventTarget { + onenter: (ev: Event) => any; + track: TextTrack; + endTime: number; + text: string; + pauseOnExit: boolean; + id: string; + startTime: number; + onexit: (ev: Event) => any; + getCueAsHTML(): DocumentFragment; +} +declare var TextTrackCue: { + prototype: TextTrackCue; + new (): TextTrackCue; +} + +interface MSStreamReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; +} +declare var MSStreamReader: { + prototype: MSStreamReader; + new (): MSStreamReader; +} + +interface DOMTokenList { + length: number; + contains(token: string): boolean; + remove(token: string): void; + toggle(token: string): boolean; + add(token: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} + +interface EventException { + name: string; +} + +interface Performance { + now(): number; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} +declare var SVGFEBlendElement: { + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} + +interface WindowTimers extends WindowTimersExtension { +} + +interface CSSStyleDeclaration { + animationFillMode: string; + floodColor: string; + animationIterationCount: string; + textShadow: string; + backfaceVisibility: string; + msAnimationIterationCount: string; + animationDelay: string; + animationTimingFunction: string; + columnWidth: any; + msScrollSnapX: string; + columnRuleColor: any; + columnRuleWidth: any; + transitionDelay: string; + transition: string; + msFlowFrom: string; + msScrollSnapType: string; + msContentZoomSnapType: string; + msGridColumns: string; + msAnimationName: string; + msGridRowAlign: string; + msContentZoomChaining: string; + msGridColumn: any; + msHyphenateLimitZone: any; + msScrollRails: string; + msAnimationDelay: string; + enableBackground: string; + msWrapThrough: string; + columnRuleStyle: string; + msAnimation: string; + msFlexFlow: string; + msScrollSnapY: string; + msHyphenateLimitLines: any; + msTouchAction: string; + msScrollLimit: string; + animation: string; + transform: string; + filter: string; + colorInterpolationFilters: string; + transitionTimingFunction: string; + msBackfaceVisibility: string; + animationPlayState: string; + transformOrigin: string; + msScrollLimitYMin: any; + msFontFeatureSettings: string; + msContentZoomLimitMin: any; + columnGap: any; + transitionProperty: string; + msAnimationDuration: string; + msAnimationFillMode: string; + msFlexDirection: string; + msTransitionDuration: string; + fontFeatureSettings: string; + breakBefore: string; + msFlexWrap: string; + perspective: string; + msFlowInto: string; + msTransformStyle: string; + msScrollTranslation: string; + msTransitionProperty: string; + msUserSelect: string; + msOverflowStyle: string; + msScrollSnapPointsY: string; + animationDirection: string; + animationDuration: string; + msFlex: string; + msTransitionTimingFunction: string; + animationName: string; + columnRule: string; + msGridColumnSpan: any; + msFlexNegative: string; + columnFill: string; + msGridRow: any; + msFlexOrder: string; + msFlexItemAlign: string; + msFlexPositive: string; + msContentZoomLimitMax: any; + msScrollLimitYMax: any; + msGridColumnAlign: string; + perspectiveOrigin: string; + lightingColor: string; + columns: string; + msScrollChaining: string; + msHyphenateLimitChars: string; + msTouchSelect: string; + floodOpacity: string; + msAnimationDirection: string; + msAnimationPlayState: string; + columnSpan: string; + msContentZooming: string; + msPerspective: string; + msFlexPack: string; + msScrollSnapPointsX: string; + msContentZoomSnapPoints: string; + msGridRowSpan: any; + msContentZoomSnap: string; + msScrollLimitXMin: any; + breakInside: string; + msHighContrastAdjust: string; + msFlexLinePack: string; + msGridRows: string; + transitionDuration: string; + msHyphens: string; + breakAfter: string; + msTransition: string; + msPerspectiveOrigin: string; + msContentZoomLimit: string; + msScrollLimitXMax: any; + msFlexAlign: string; + msWrapMargin: any; + columnCount: any; + msAnimationTimingFunction: string; + msTransitionDelay: string; + transformStyle: string; + msWrapFlow: string; + msFlexPreferredSize: string; +} + +interface MessageChannel { + port2: MessagePort; + port1: MessagePort; +} +declare var MessageChannel: { + prototype: MessageChannel; + new (): MessageChannel; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} + +interface Navigator extends MSFileSaver { + msMaxTouchPoints: number; + msPointerEnabled: boolean; + msManipulationViewsEnabled: boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; +} + +interface TransitionEvent extends Event { + propertyName: string; + elapsedTime: number; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +interface DOMError { + name: string; + toString(): string; +} + +interface CloseEvent extends Event { + wasClean: boolean; + reason: string; + code: number; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +interface WebSocket extends EventTarget { + protocol: string; + readyState: number; + bufferedAmount: number; + onopen: (ev: Event) => any; + extensions: string; + onmessage: (ev: any) => any; + onclose: (ev: CloseEvent) => any; + onerror: (ev: ErrorEvent) => any; + binaryType: string; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} +declare var WebSocket: { + prototype: WebSocket; + new (url: string): WebSocket; + new (url: string, prototcol: string): WebSocket; + new (url: string, prototcol: string[]): WebSocket; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} + +interface SVGFEPointLightElement extends SVGElement { + y: SVGAnimatedNumber; + x: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} + +interface ProgressEvent extends Event { + loaded: number; + lengthComputable: boolean; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + name: string; + transaction: IDBTransaction; + keyPath: string; + count(key?: any): IDBRequest; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + put(value: any, key?: any): IDBRequest; + openCursor(range?: any, direction?: string): IDBRequest; + deleteIndex(indexName: string): void; + index(name: string): IDBIndex; + get(key: any): IDBRequest; + delete(key: any): IDBRequest; +} + +interface HTMLCanvasElement { + /** + * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. + */ + msToBlob(): Blob; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + stdDeviationX: SVGAnimatedNumber; + in1: SVGAnimatedString; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + result: SVGAnimatedString; +} + +interface Element { + msRegionOverflow: string; + onmspointerdown: (ev: any) => any; + onmsgotpointercapture: (ev: any) => any; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + onmslostpointercapture: (ev: any) => any; + onmspointerover: (ev: any) => any; + msContentZoomFactor: number; + onmspointerup: (ev: any) => any; + msGetRegionContent(): MSRangeCollection; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} + +interface IDBIndex { + unique: boolean; + name: string; + keyPath: string; + objectStore: IDBObjectStore; + count(key?: any): IDBRequest; + getKey(key: any): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + get(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} + +interface WheelEvent { + getCurrentPoint(element: Element): void; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} + +interface IDBCursor { + source: any; + direction: string; + key: any; + primaryKey: any; + advance(count: number): void; + delete(): IDBRequest; + continue(key?: any): void; + update(value: any): IDBRequest; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} + +interface URL { + revokeObjectURL(url: string): void; + createObjectURL(object: any, options?: ObjectURLOptions): string; +} +declare var URL: URL; + +interface RangeException { + name: string; +} + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} + +interface HTMLTextAreaElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface XMLHttpRequestEventTarget extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: any) => any; + ontimeout: (ev: any) => any; + onabort: (ev: any) => any; + onloadstart: (ev: any) => any; + onloadend: (ev: ProgressEvent) => any; +} + +interface IDBEnvironment { + msIndexedDB: IDBFactory; + indexedDB: IDBFactory; +} + +interface AudioTrackList extends EventTarget { + length: number; + onchange: (ev: any) => any; + onaddtrack: (ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + [index: number]: AudioTrack; +} + +interface MSBaseReader extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + readyState: number; + onabort: (ev: any) => any; + onloadend: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: any) => any; + onloadstart: (ev: any) => any; + result: any; + abort(): void; + LOADING: number; + EMPTY: number; + DONE: number; +} + +interface History { + state: any; + replaceState(statedata: any, title: string, url?: string): void; + pushState(statedata: any, title: string, url?: string): void; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} +declare var SVGFEMorphologyElement: { + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} + +interface HTMLSelectElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface CSSRule { + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} +//declare var CSSRule: { +// KEYFRAMES_RULE: number; +// KEYFRAME_RULE: number; +// VIEWPORT_RULE: number; +//} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} + +interface WindowTimersExtension { + msSetImmediate(expression: any, ...args: any[]): number; + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + setImmediate(expression: any, ...args: any[]): number; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + scale: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} +declare var SVGFEDisplacementMapElement: { + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + tableValues: SVGAnimatedNumberList; + slope: SVGAnimatedNumber; + type: SVGAnimatedEnumeration; + exponent: SVGAnimatedNumber; + amplitude: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} +declare var SVGComponentTransferFunctionElement: { + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} + +interface SVGException { + name: string; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} + +interface IDBKeyRange { + upper: any; + upperOpen: boolean; + lower: any; + lowerOpen: boolean; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface WindowConsole { + console: Console; +} + +interface IDBTransaction extends EventTarget { + oncomplete: (ev: Event) => any; + db: IDBDatabase; + mode: string; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: any) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; +} + +interface AudioTrack { + kind: string; + language: string; + id: string; + label: string; + enabled: boolean; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + orderY: SVGAnimatedInteger; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + kernelMatrix: SVGAnimatedNumberList; + edgeMode: SVGAnimatedEnumeration; + kernelUnitLengthX: SVGAnimatedNumber; + bias: SVGAnimatedNumber; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + divisor: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} +declare var SVGFEConvolveMatrixElement: { + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} + +interface TextTrackCueList { + length: number; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; + getCueById(id: string): TextTrackCue; +} + +interface CSSKeyframesRule extends CSSRule { + name: string; + cssRules: CSSRuleList; + findRule(rule: string): CSSKeyframeRule; + deleteRule(rule: string): void; + appendRule(rule: string): void; +} + +interface Window extends WindowBase64, IDBEnvironment, WindowConsole { + onmspointerdown: (ev: any) => any; + animationStartTime: number; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + msAnimationStartTime: number; + applicationCache: ApplicationCache; + onmsinertiastart: (ev: any) => any; + onmspointerover: (ev: any) => any; + onpopstate: (ev: PopStateEvent) => any; + onmspointerup: (ev: any) => any; + msCancelRequestAnimationFrame(handle: number): void; + matchMedia(mediaQuery: string): MediaQueryList; + cancelAnimationFrame(handle: number): void; + msIsStaticHTML(html: string): boolean; + msMatchMedia(mediaQuery: string): MediaQueryList; + requestAnimationFrame(callback: FrameRequestCallback): number; + msRequestAnimationFrame(callback: FrameRequestCallback): number; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + type: SVGAnimatedEnumeration; + baseFrequencyY: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + seed: SVGAnimatedNumber; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} +declare var SVGFETurbulenceElement: { + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} + +interface TextTrackList { + length: number; + item(index: number): TextTrack; + [index: number]: TextTrack; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} +declare var SVGFEColorMatrixElement: { + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} + +interface Console { + info(message?: any, ...optionalParams: any[]): void; + profile(reportName?: string): void; + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + clear(): void; + dir(value?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; + error(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + profileEnd(): void; +} + +interface SVGFESpotLightElement extends SVGElement { + pointsAtY: SVGAnimatedNumber; + y: SVGAnimatedNumber; + limitingConeAngle: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + z: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; +} + +interface HTMLImageElement { + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; +} + +interface WindowBase64 { + btoa(rawString: string): string; + atob(encodedString: string): string; +} + +interface IDBDatabase extends EventTarget { + version: string; + name: string; + objectStoreNames: DOMStringList; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: any) => any; + createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + close(): void; + transaction(storeNames: any, mode?: string): IDBTransaction; + deleteObjectStore(name: string): void; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} + +interface HTMLButtonElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface IDBOpenDBRequest extends IDBRequest { + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + onblocked: (ev: Event) => any; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. + */ + value: number; + /** + * Defines the maximum, or "done" value for a progress element. + */ + max: number; + /** + * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). + */ + position: number; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} + +interface MSLaunchUriCallback { + (): void; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + dx: SVGAnimatedNumber; +} + +interface HTMLFormElement { + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Designates a form that is not validated when submitted. + */ + noValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; +} + +interface MSUnsafeFunctionCallback { + (): any; +} + +interface Document { + onmspointerdown: (ev: any) => any; + msHidden: boolean; + msVisibilityState: string; + onmsgesturedoubletap: (ev: any) => any; + visibilityState: string; + onmsmanipulationstatechanged: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmscontentzoom: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + msCSSOMElementFloatMetrics: boolean; + onmspointerover: (ev: any) => any; + hidden: boolean; + onmspointerup: (ev: any) => any; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + clear(): void; +} + +interface MessageEvent extends Event { + ports: any; +} + +interface HTMLScriptElement { + async: boolean; +} + +interface HTMLMediaElement { + /** + * Specifies the purpose of the audio or video media, such as background audio or alerts. + */ + msAudioCategory: string; + /** + * Specifies whether or not to enable low-latency playback on the media element. + */ + msRealTime: boolean; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + textTracks: TextTrackList; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + audioTracks: AudioTrackList; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Specifies the output device id that the audio will be sent to. + */ + msAudioDeviceType: string; + /** + * Clears all effects from the media pipeline. + */ + msClearEffects(): void; + /** + * Specifies the media protection manager for a given media pipeline. + */ + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + /** + * Inserts the specified audio effect into media pipeline. + */ + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; +} + +interface TextTrack extends EventTarget { + language: string; + mode: any; + readyState: number; + activeCues: TextTrackCueList; + cues: TextTrackCueList; + oncuechange: (ev: Event) => any; + kind: string; + onload: (ev: any) => any; + onerror: (ev: ErrorEvent) => any; + label: string; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} +declare var TextTrack: { + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} + +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} + +interface IDBRequest extends EventTarget { + source: any; + onsuccess: (ev: Event) => any; + error: DOMError; + transaction: IDBTransaction; + onerror: (ev: ErrorEvent) => any; + readyState: string; + result: any; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: any) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; +} + +interface FileReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; +} +declare var FileReader: { + prototype: FileReader; + new (): FileReader; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface Blob { + type: string; + size: number; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; + msClose(): void; +} +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface ApplicationCache extends EventTarget { + status: number; + ondownloading: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onupdateready: (ev: Event) => any; + oncached: (ev: Event) => any; + onobsolete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + onchecking: (ev: Event) => any; + onnoupdate: (ev: Event) => any; + swapCache(): void; + abort(): void; + update(): void; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} +declare var ApplicationCache: { + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} + +interface FrameRequestCallback { + (time: number): void; +} + +interface XMLHttpRequest { + response: any; + withCredentials: boolean; + onprogress: (ev: ProgressEvent) => any; + onabort: (ev: any) => any; + responseType: string; + onloadend: (ev: ProgressEvent) => any; + upload: XMLHttpRequestEventTarget; + onerror: (ev: ErrorEvent) => any; + onloadstart: (ev: any) => any; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSStream { + type: string; + msDetachStream(): any; + msClose(): void; +} + +interface MediaError { + msExtendedCode: number; +} + +interface HTMLFieldSetElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new (): MSBlobBuilder; +} + +interface HTMLElement { + onmscontentzoom: (ev: any) => any; + oncuechange: (ev: Event) => any; + spellcheck: boolean; + classList: DOMTokenList; + onmsmanipulationstatechanged: (ev: any) => any; + draggable: boolean; +} + +interface DataTransfer { + types: DOMStringList; + files: FileList; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} + +interface IDBFactory { + open(name: string, version?: number): IDBOpenDBRequest; + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; +} + +interface Range { + createContextualFragment(fragment: string): DocumentFragment; +} + +interface HTMLObjectElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface MSPointerEvent 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; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} +declare var MSPointerEvent: { + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} + +interface DOMException { + name: string; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} +//declare var DOMException: { +// INVALID_NODE_TYPE_ERR: number; +// DATA_CLONE_ERR: number; +// TIMEOUT_ERR: number; +//} + +interface MSManipulationEvent extends UIEvent { + lastState: number; + currentState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} +declare var MSManipulationEvent: { + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} + +interface FormData { + append(name: any, value: any, blobName?: string): void; +} +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollection; +} + +interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface AbstractWorker extends EventTarget { + onerror: (ev: ErrorEvent) => any; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + in2: SVGAnimatedString; + k2: SVGAnimatedNumber; + k1: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + in1: SVGAnimatedString; + k4: SVGAnimatedNumber; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} +declare var SVGFECompositeElement: { + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} + +interface ValidityState { + customError: boolean; + valueMissing: boolean; + stepMismatch: boolean; + rangeUnderflow: boolean; + rangeOverflow: boolean; + typeMismatch: boolean; + patternMismatch: boolean; + tooLong: boolean; + valid: boolean; +} + +interface HTMLTrackElement extends HTMLElement { + kind: string; + src: string; + srclang: string; + track: TextTrack; + label: string; + default: boolean; +} + +interface MSApp { + createFileFromStorageFile(storageFile: any): File; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + terminateApp(exceptionObject: any): void; + createDataPackage(object: any): any; + execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; + getHtmlPrintDocumentSource(htmlDoc: any): any; + addPublicLocalApplicationUri(uri: string): void; + createDataPackageFromSelection(): any; +} +declare var MSApp: MSApp; + +interface HTMLVideoElement { + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + onMSVideoOptimalLayoutChanged: (ev: any) => any; + onMSVideoFrameStepCompleted: (ev: any) => any; + msStereo3DRenderMode: string; + msIsLayoutOptimalForPlayback: boolean; + msHorizontalMirror: boolean; + onMSVideoFormatChanged: (ev: any) => any; + msZoom: boolean; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + msFrameStep(forward: boolean): void; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + diffuseConstant: SVGAnimatedNumber; +} + +interface MSCSSMatrix { + m24: number; + m34: number; + a: number; + d: number; + m32: number; + m41: number; + m11: number; + f: number; + e: number; + m23: number; + m14: number; + m33: number; + m22: number; + m21: number; + c: number; + m12: number; + b: number; + m42: number; + m31: number; + m43: number; + m13: number; + m44: number; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + setMatrixValue(value: string): void; + inverse(): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + toString(): string; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + translate(x: number, y: number, z?: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + skewX(angle: number): MSCSSMatrix; +} +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new (text?: string): MSCSSMatrix; +} + +interface Worker extends AbstractWorker { + onmessage: (ev: any) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; +} +declare var Worker: { + prototype: Worker; + new (stringUrl: string): Worker; +} + +interface HTMLIFrameElement { + sandbox: DOMSettableTokenList; +} + +declare var onmspointerdown: (ev: any) => any; +declare var animationStartTime: number; +declare var onmsgesturedoubletap: (ev: any) => any; +declare var onmspointerhover: (ev: any) => any; +declare var onmsgesturehold: (ev: any) => any; +declare var onmspointermove: (ev: any) => any; +declare var onmsgesturechange: (ev: any) => any; +declare var onmsgesturestart: (ev: any) => any; +declare var onmspointercancel: (ev: any) => any; +declare var onmsgestureend: (ev: any) => any; +declare var onmsgesturetap: (ev: any) => any; +declare var onmspointerout: (ev: any) => any; +declare var msAnimationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var onmsinertiastart: (ev: any) => any; +declare var onmspointerover: (ev: any) => any; +declare var onpopstate: (ev: PopStateEvent) => any; +declare var onmspointerup: (ev: any) => any; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function cancelAnimationFrame(handle: number): void; +declare function msIsStaticHTML(html: string): boolean; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function btoa(rawString: string): string; +declare function atob(encodedString: string): string; +declare var msIndexedDB: IDBFactory; +declare var indexedDB: IDBFactory; +declare var console: Console; + + +///////////////////////////// +/// IE11 DOM APIs +///////////////////////////// + + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: Array; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: Array; +} + +interface AlgorithmParameters { +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: Array; +} + +interface ExceptionInformation { + domain?: string; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface Algorithm { + name?: string; + params?: AlgorithmParameters; +} + +interface NavigatorID { + product: string; + vendor: string; +} + +interface HTMLBodyElement { + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; +} + +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} + +interface MSWindowExtensions { + captureEvents(): void; + releaseEvents(): void; +} + +interface MSGraphicsTrust { + status: string; + constrictionActive: boolean; +} + +interface AudioTrack { + sourceBuffer: SourceBuffer; +} + +interface DragEvent { + msConvertURL(file: File, targetType: string, targetURL?: string): void; +} + +interface SubtleCrypto { + unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; + encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; + verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; + deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; + exportKey(format: string, key: Key): KeyOperation; + generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; +} + +interface Crypto extends RandomSource { + subtle: SubtleCrypto; +} + +interface VideoPlaybackQuality { + totalFrameDelay: number; + creationTime: number; + totalVideoFrames: number; + droppedVideoFrames: number; +} + +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 extends GlobalEventHandlers { + onpageshow: (ev: PageTransitionEvent) => any; + ondevicemotion: (ev: DeviceMotionEvent) => any; + devicePixelRatio: number; + msCrypto: Crypto; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + doNotTrack: string; + onmspointerenter: (ev: any) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onmspointerleave: (ev: any) => any; +} + +interface Key { + algorithm: Algorithm; + type: string; + extractable: boolean; + keyUsage: string[]; +} + +interface TextTrackList extends EventTarget { + onaddtrack: (ev: any) => any; +} + +interface DeviceAcceleration { + y: number; + x: number; + z: number; +} + +interface Console { + count(countTitle?: string): void; + groupEnd(): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(): void; + group(groupTitle?: string): void; + dirxml(value: any): void; + debug(message?: string, ...optionalParams: any[]): void; + groupCollapsed(groupTitle?: string): void; + select(element: Element): void; +} + +interface MSNavigatorDoNotTrack { + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; +} + +interface HTMLImageElement { + crossOrigin: string; + msPlayToPreferredSourceUri: string; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; + //[name: string]: Element; +} + +interface MSNavigatorExtensions { + language: string; +} + +interface AesGcmEncryptResult { + ciphertext: ArrayBuffer; + tag: ArrayBuffer; +} + +interface HTMLSourceElement { + msKeySystem: string; +} + +interface CSSStyleDeclaration { + alignItems: string; + borderImageSource: string; + flexBasis: string; + borderImageWidth: string; + borderImageRepeat: string; + order: string; + flex: string; + alignContent: string; + msImeAlign: string; + flexShrink: string; + flexGrow: string; + borderImageSlice: string; + flexWrap: string; + borderImageOutset: string; + flexDirection: string; + touchAction: string; + flexFlow: string; + borderImage: string; + justifyContent: string; + alignSelf: string; + msTextCombineHorizontal: string; +} + +interface NavigationCompletedEvent extends NavigationEvent { + webErrorStatus: number; + isSuccess: boolean; +} + +interface MutationRecord { + oldValue: string; + previousSibling: Node; + addedNodes: NodeList; + attributeName: string; + removedNodes: NodeList; + target: Node; + nextSibling: Node; + attributeNamespace: string; + type: string; +} + +interface Navigator { + pointerEnabled: boolean; + maxTouchPoints: number; +} + +interface Document extends MSDocumentExtensions, GlobalEventHandlers { + msFullscreenEnabled: boolean; + onmsfullscreenerror: (ev: any) => any; + onmspointerenter: (ev: any) => any; + msFullscreenElement: Element; + onmsfullscreenchange: (ev: any) => any; + onmspointerleave: (ev: any) => any; + msExitFullscreen(): void; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(type: string): Plugin; + //[type: string]: Plugin; +} + +interface HTMLMediaElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + msKeys: MSMediaKeys; + msGraphicsTrustStatus: MSGraphicsTrust; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; +} + +interface TextTrack { + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; +} + +interface KeyOperation extends EventTarget { + oncomplete: (ev: any) => any; + onerror: (ev: any) => any; + result: any; +} + +interface DOMStringMap { +} + +interface DeviceOrientationEvent extends Event { + gamma: number; + alpha: number; + absolute: boolean; + beta: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; + isTypeSupported(keySystem: string, type?: string): boolean; +} +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new (): MSMediaKeys; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} + +interface MSHTMLWebViewElement extends HTMLElement { + documentTitle: string; + width: number; + src: string; + canGoForward: boolean; + height: number; + canGoBack: boolean; + navigateWithHttpRequestMessage(requestMessage: any): void; + goBack(): void; + navigate(uri: string): void; + stop(): void; + navigateToString(contents: string): void; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + refresh(): void; + goForward(): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; +} + +interface NavigationEvent extends Event { + uri: string; +} + +interface Element extends GlobalEventHandlers { + onlostpointercapture: (ev: PointerEvent) => any; + onmspointerenter: (ev: any) => any; + ongotpointercapture: (ev: PointerEvent) => any; + onmspointerleave: (ev: any) => any; + msZoomTo(args: MsZoomToOptions): void; + setPointerCapture(pointerId: number): void; + msGetUntransformedBounds(): ClientRect; + releasePointerCapture(pointerId: number): void; + msRequestFullscreen(): void; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface XMLHttpRequest { + msCaching: string; + msCachingEnabled(): boolean; + overrideMimeType(mime: string): void; +} + +interface SourceBuffer extends EventTarget { + updating: boolean; + appendWindowStart: number; + appendWindowEnd: number; + buffered: TimeRanges; + timestampOffset: number; + audioTracks: AudioTrackList; + appendBuffer(data: ArrayBuffer): void; + remove(start: number, end: number): void; + abort(): void; + appendStream(stream: MSStream, maxSize?: number): void; +} + +interface MSInputMethodContext extends EventTarget { + oncandidatewindowshow: (ev: any) => any; + target: HTMLElement; + compositionStartOffset: number; + oncandidatewindowhide: (ev: any) => any; + oncandidatewindowupdate: (ev: any) => any; + compositionEndOffset: number; + getCompositionAlternatives(): string[]; + getCandidateWindowClientRect(): ClientRect; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; +} + +interface DeviceRotationRate { + gamma: number; + alpha: number; + beta: number; +} + +interface PluginArray { + length: number; + refresh(reload?: boolean): void; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(name: string): Plugin; + //[name: string]: Plugin; +} + +interface MSMediaKeyError { + systemCode: number; + code: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} +declare var MSMediaKeyError: { + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} + +interface Plugin { + length: number; + filename: string; + version: string; + name: string; + description: string; + item(index: number): MimeType; + [index: number]: MimeType; + namedItem(type: string): MimeType; + //[type: string]: MimeType; +} + +interface HTMLFrameSetElement { + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; +} + +interface Screen extends EventTarget { + msOrientation: string; + onmsorientationchange: (ev: any) => any; + msLockOrientation(orientations: string[]): boolean; + msUnlockOrientation(): void; +} + +interface MediaSource extends EventTarget { + sourceBuffers: SourceBufferList; + duration: number; + readyState: string; + activeSourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: string): void; + isTypeSupported(type: string): boolean; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} +declare var MediaSource: { + prototype: MediaSource; + new (): MediaSource; +} + +interface MediaError { + MS_MEDIA_ERR_ENCRYPTED: number; +} +//declare var MediaError: { +// MS_MEDIA_ERR_ENCRYPTED: number; +//} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +interface XMLDocument extends Document { +} + +interface DeviceMotionEvent extends Event { + rotationRate: DeviceRotationRate; + acceleration: DeviceAcceleration; + interval: number; + accelerationIncludingGravity: DeviceAcceleration; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} + +interface MimeType { + enabledPlugin: Plugin; + suffixes: string; + type: string; + description: string; +} + +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 { + captureEvents(): void; + releaseEvents(): void; +} + +interface HTMLElement { + dataset: DOMStringMap; + hidden: boolean; + msGetInputContext(): MSInputMethodContext; +} + +interface MutationObserver { + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; + disconnect(): void; +} +declare var MutationObserver: { + prototype: MutationObserver; + new (): MutationObserver; +} + +interface AudioTrackList { + onremovetrack: (ev: PluginArray) => any; +} + +interface HTMLObjectElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * 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. + */ + msPlayToSource: any; +} + +interface HTMLEmbedElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * 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. + */ + msPlayToSource: any; +} + +interface MSWebViewAsyncOperation extends EventTarget { + target: MSHTMLWebViewElement; + oncomplete: (ev: any) => any; + error: DOMError; + onerror: (ev: any) => any; + readyState: number; + type: number; + result: any; + start(): void; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} +declare var MSWebViewAsyncOperation: { + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} + +interface ScriptNotifyEvent extends Event { + value: string; + callingUri: string; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + redirectCount: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + type: string; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} + +interface MSManipulationEvent { + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_CANCELLED: number; +} +//declare var MSManipulationEvent: { +// MS_MANIPULATION_STATE_SELECTING: number; +// MS_MANIPULATION_STATE_COMMITTED: number; +// MS_MANIPULATION_STATE_PRESELECT: number; +// MS_MANIPULATION_STATE_DRAGGING: number; +// MS_MANIPULATION_STATE_CANCELLED: number; +//} + +interface LongRunningScriptDetectedEvent extends Event { + stopPageScriptExecution: boolean; + executionTime: number; +} + +interface MSAppView { + viewId: number; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; +} + +interface PerfWidgetExternal { + maxCpuSpeed: 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; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} + +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} + +interface HTMLDocument extends Document { +} + +interface KeyPair { + privateKey: Key; + publicKey: Key; +} + +interface MSApp { + getViewOpener(): MSAppView; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + createNewView(uri: string): MSAppView; + getCurrentPriority(): string; + NORMAL: string; + HIGH: string; + IDLE: string; + CURRENT: string; +} +//declare var MSApp: { +// NORMAL: string; +// HIGH: string; +// IDLE: string; +// CURRENT: string; +//} + +interface MSMediaKeySession extends EventTarget { + sessionId: string; + error: MSMediaKeyError; + keySystem: string; + close(): void; + update(key: Uint8Array): void; +} + +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 { + getVideoPlaybackQuality(): VideoPlaybackQuality; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEvent { + referrer: string; +} + +interface CryptoOperation extends EventTarget { + algorithm: Algorithm; + oncomplete: (ev: any) => any; + onerror: (ev: any) => any; + onprogress: (ev: any) => any; + onabort: (ev: any) => any; + key: Key; + result: any; + abort(): void; + finish(): void; + process(buffer: ArrayBufferView): void; +} + +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare var devicePixelRatio: number; +declare var msCrypto: Crypto; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare var doNotTrack: string; +declare var onmspointerenter: (ev: any) => any; +declare var onpagehide: (ev: PageTransitionEvent) => any; +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; + + +///////////////////////////// +/// WorkerGlobalScope APIs +///////////////////////////// +// TODO: These are only available in a Web Worker - should be in a separate lib file +declare function importScripts(...urls: string[]): void; + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// +declare var ActiveXObject: { new (s: string): any; }; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +declare var WScript: { + Echo(s: any): void; + StdErr: ITextWriter; + StdOut: ITextWriter; + Arguments: { length: number; Item(n: number): string; }; + ScriptFullName: string; + Quit(exitCode?: number): number; +} diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/tsc b/_infrastructure/tests/typescript/0.9.7-66c2df/tsc new file mode 100644 index 0000000000..3c0dab574f --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-66c2df/tsc @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./tsc.js') diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/tsc.js b/_infrastructure/tests/typescript/0.9.7-66c2df/tsc.js new file mode 100644 index 0000000000..01bea509c4 --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-66c2df/tsc.js @@ -0,0 +1,62790 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.DiagnosticCode = { + error_TS_0_1: "error TS{0}: {1}", + warning_TS_0_1: "warning TS{0}: {1}", + Unrecognized_escape_sequence: "Unrecognized escape sequence.", + Unexpected_character_0: "Unexpected character {0}.", + Missing_close_quote_character: "Missing close quote character.", + Identifier_expected: "Identifier expected.", + _0_keyword_expected: "'{0}' keyword expected.", + _0_expected: "'{0}' expected.", + Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", + Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", + Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", + Trailing_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", + Unexpected_token: "Unexpected token.", + Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", + Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", + Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", + Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", + Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", + Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", + extends_clause_already_seen: "'extends' clause already seen.", + extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", + Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", + implements_clause_already_seen: "'implements' clause already seen.", + Accessibility_modifier_already_seen: "Accessibility modifier already seen.", + _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", + _0_modifier_already_seen: "'{0}' modifier already seen.", + _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", + Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", + super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", + Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", + Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", + 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_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}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", + set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", + set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", + get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", + Modifiers_cannot_appear_here: "Modifiers cannot appear here.", + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", + Class_name_cannot_be_0: "Class name cannot be '{0}'.", + Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", + Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + Enum_member_must_have_initializer: "Enum member must have initializer.", + Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", + module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", + constructor_function_accessor_or_variable: "constructor, function, accessor or variable", + statement: "statement", + case_or_default_clause: "case or default clause", + identifier: "identifier", + call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", + expression: "expression", + type_name: "type name", + property_or_accessor: "property or accessor", + parameter: "parameter", + type: "type", + type_parameter: "type parameter", + 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_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.", + super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", + Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", + Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", + Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", + Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", + Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", + Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", + Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", + Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", + Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", + Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", + Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", + Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", + Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", + Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", + Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", + Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", + Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", + Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", + Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", + Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", + Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", + Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", + Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", + Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", + Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", + Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", + Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", + Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", + Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", + Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", + Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", + Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", + Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", + Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", + A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", + Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", + Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", + Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", + A_class_may_only_extend_another_class: "A class may only extend another class.", + A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", + An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", + Unable_to_resolve_type: "Unable to resolve type.", + Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", + Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", + Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", + Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", + Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", + Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", + Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", + Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", + Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + 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_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_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.", + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", + Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", + Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", + 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_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}'.", + 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.", + Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", + Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", + Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", + All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", + Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", + Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", + this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", + Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", + Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", + 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_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.", + Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", + A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", + 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_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_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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", + Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", + Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", + 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_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}", + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", + Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", + All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", + super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", + Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", + Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", + Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", + Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", + Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", + continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", + break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", + Jump_target_not_found: "Jump target not found.", + Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", + TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", + TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", + TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", + TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", + TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", + TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", + Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", + 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}", + Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", + Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", + Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", + Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", + Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", + Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", + Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", + Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", + Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", + 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.", + 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_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_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.", + Could_not_find_file_0: "Could not find file: '{0}'.", + A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", + Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", + Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", + Emit_Error_0: "Emit Error: {0}.", + Cannot_read_file_0_1: "Cannot read file '{0}': {1}", + Unsupported_file_encoding: "Unsupported file encoding.", + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Invalid_call_to_up: "Invalid call to 'up'", + Invalid_call_to_down: "Invalid call to 'down'", + Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", + Unknown_option_0: "Unknown option '{0}'", + Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", + Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", + Could_not_delete_file_0: "Could not delete file '{0}'", + Could_not_create_directory_0: "Could not create directory '{0}'", + Error_while_executing_file_0: "Error while executing file '{0}': ", + Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", + Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", + Option_0_specified_without_1: "Option '{0}' specified without '{1}'", + codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", + Generates_corresponding_0_file: "Generates corresponding {0} file.", + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", + Watch_input_files: "Watch input files.", + Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", + Do_not_emit_comments_to_output: "Do not emit comments to output.", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", + Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", + Print_this_message: "Print this message.", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file1: "file", + Examples: "Examples:", + Options: "Options:", + Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", + Version_0: "Version {0}", + Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", + NL_Recompiling_0: "{NL}Recompiling ({0}):", + STRING: "STRING", + KIND: "KIND", + file2: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + 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})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", + Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", + Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", + Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", + Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", + new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", + _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", + Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", + 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.", + 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; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + return false; + } + + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0, n = array1.length; i < n; i++) { + if (!equals(array1[i], array2[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.distinct = function (array, equalsFn) { + var result = []; + + for (var i = 0, n = array.length; i < n; i++) { + var current = array[i]; + for (var j = 0; j < result.length; j++) { + if (equalsFn(result[j], current)) { + break; + } + } + + if (j === result.length) { + result.push(current); + } + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.lastOrDefault = function (array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var v = array[i]; + if (predicate(v, i)) { + return v; + } + } + + return null; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value, i)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.first = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (!func || func(value, i)) { + return value; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + var low = 0; + var high = array.length - 1; + + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + + if (midValue === value) { + return middle; + } else if (midValue > value) { + high = middle - 1; + } else { + low = middle + 1; + } + } + + return ~low; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + + ArrayUtilities.indexOf = function (array, predicate) { + for (var i = 0, n = array.length; i < n; i++) { + if (predicate(array[i])) { + return i; + } + } + + return -1; + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitVector) { + var pool = []; + var Constants; + (function (Constants) { + Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; + Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; + + Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; + + Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; + Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; + + Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; + Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; + Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; + })(Constants || (Constants = {})); + + var BitVectorImpl = (function () { + function BitVectorImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.bits = []; + } + BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; + }; + + BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; + }; + + BitVectorImpl.prototype.valueAt = function (index) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return undefined; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { + return true; + } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { + return false; + } else { + return undefined; + } + } else { + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return false; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { + return true; + } else { + return false; + } + } + }; + + BitVectorImpl.prototype.setValueAt = function (index, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); + + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === undefined) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + + var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); + encoded = encoded & clearMask; + + if (value === true) { + encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); + } else if (value === false) { + encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } else { + TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); + + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === false) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + + encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); + + if (value) { + encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } + }; + + BitVectorImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + this.bits.length = 0; + pool.push(this); + }; + return BitVectorImpl; + })(); + + function getBitVector(allowUndefinedValues) { + if (pool.length === 0) { + return new BitVectorImpl(allowUndefinedValues); + } + + var vector = pool.pop(); + vector.isReleased = false; + vector.allowUndefinedValues = allowUndefinedValues; + + return vector; + } + BitVector.getBitVector = getBitVector; + })(TypeScript.BitVector || (TypeScript.BitVector = {})); + var BitVector = TypeScript.BitVector; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitMatrix) { + var pool = []; + + var BitMatrixImpl = (function () { + function BitMatrixImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.vectors = []; + } + BitMatrixImpl.prototype.valueAt = function (x, y) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + return this.allowUndefinedValues ? undefined : false; + } + + return vector.valueAt(y); + }; + + BitMatrixImpl.prototype.setValueAt = function (x, y, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + if (value === undefined) { + return; + } + + vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); + this.vectors[x] = vector; + } + + vector.setValueAt(y, value); + }; + + BitMatrixImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + + for (var name in this.vectors) { + if (this.vectors.hasOwnProperty(name)) { + var vector = this.vectors[name]; + vector.release(); + } + } + + this.vectors.length = 0; + pool.push(this); + }; + return BitMatrixImpl; + })(); + + function getBitMatrix(allowUndefinedValues) { + if (pool.length === 0) { + return new BitMatrixImpl(allowUndefinedValues); + } + + var matrix = pool.pop(); + matrix.isReleased = false; + matrix.allowUndefinedValues = allowUndefinedValues; + + return matrix; + } + BitMatrix.getBitMatrix = getBitMatrix; + })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); + var BitMatrix = TypeScript.BitMatrix; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); + var AssertionLevel = TypeScript.AssertionLevel; + + var Debug = (function () { + function Debug() { + } + Debug.shouldAssert = function (level) { + return this.currentAssertionLevel >= level; + }; + + Debug.assert = function (expression, message, verboseDebugInfo) { + if (typeof message === "undefined") { message = ""; } + if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); + } + + throw new Error("Debug Failure. False expression: " + message + verboseDebugString); + } + }; + + Debug.fail = function (message) { + Debug.assert(false, message); + }; + Debug.currentAssertionLevel = 0 /* None */; + return Debug; + })(); + 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 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(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; + } + + return result; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return this._additionalLocations || []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + + Diagnostic.prototype.info = function () { + return getDiagnosticInfoFromKey(this.diagnosticKey()); + }; + return Diagnostic; + })(Location); + TypeScript.Diagnostic = Diagnostic; + + function newLine() { + return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while (match = regex.exec(diagnostic)) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result); + return result; + } + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); + } + + diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { + return typeof args[num] !== 'undefined' ? args[num] : match; + }); + + diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { + return TypeScript.newLine(); + }); + + return diagnosticMessageText; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error("Invalid argument: " + argument + ". " + message); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error("Argument out of range: " + argument); + }; + + Errors.argumentNull = function (argument) { + return new Error("Argument null: " + argument); + }; + + Errors.abstract = function () { + return new Error("Operation not implemented properly by subclass."); + }; + + Errors.notYetImplemented = function () { + return new Error("Not yet implemented."); + }; + + Errors.invalidOperation = function (message) { + return new Error("Invalid operation: " + message); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft === 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, + 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, + 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, + 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, + 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, + 4166287, 4999559, 5999471, 7199369]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? key.hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', "Key was already in table."); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; + + (function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; + })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); + var ByteOrderMark = TypeScript.ByteOrderMark; + + var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; + })(); + TypeScript.FileInformation = FileInformation; + + TypeScript.Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return WScript.CreateObject("WScript.Shell").CurrentDirectory; + }, + supportsCodePage: function () { + return WScript.ReadFile; + }, + readFile: function (path, codepage) { + try { + if (codepage !== null && this.supportsCodePage()) { + try { + var contents = WScript.ReadFile(path, codepage); + return new FileInformation(contents, 0 /* None */); + } catch (e) { + } + } + + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return process.cwd(); + }, + supportsCodePage: function () { + return false; + }, + readFile: function (file, codepage) { + if (codepage !== null) { + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); + } + + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 509); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IntegerUtilities) { + function integerDivide(numerator, denominator) { + return (numerator / denominator) >> 0; + } + IntegerUtilities.integerDivide = integerDivide; + + function integerMultiplyLow32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + } + IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; + + function integerMultiplyHigh32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + } + IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + IntegerUtilities.isInteger = isInteger; + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + IntegerUtilities.isHexInteger = isHexInteger; + })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); + var IntegerUtilities = TypeScript.IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_computeLineStarts, length) { + this._computeLineStarts = _computeLineStarts; + this.length = length; + this._lineStarts = null; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this.lineStarts(), length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + if (this._lineStarts === null) { + this._lineStarts = this._computeLineStarts(); + } + + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + LineMap.empty = new LineMap(function () { + return [0]; + }, 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { + return e; + } + } + + return null; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + if (text.length !== length) { + return false; + } + + var s = start; + for (var i = 0; i < length; i++) { + if (text.charCodeAt(i) !== array[s]) { + return false; + } + + s++; + } + + return true; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static.": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static.": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Invalid 'reference' directive syntax.": { + "code": 1084, + "category": 1 /* Error */ + }, + "Octal literals are not available when targeting ECMAScript 5 and higher.": { + "code": 1085, + "category": 1 /* Error */ + }, + "Accessors are not allowed in ambient contexts.": { + "code": 1086, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a constructor declaration.": { + "code": 1089, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a parameter.": { + "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 */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static members cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* Error */ + }, + "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { + "code": 2104, + "category": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* Error */ + }, + "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { + "code": 2117, + "category": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "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 */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Type '{0}' does not have type parameters.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or not exported.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not assignable to any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "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 assignable to numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are only allowed in implementation.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { + "code": 2188, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { + "code": 2189, + "category": 1 /* Error */ + }, + "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { + "code": 2190, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot be reopened.": { + "code": 2191, + "category": 1 /* Error */ + }, + "All declarations of merged declaration '{0}' must be exported or not exported.": { + "code": 2192, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in constructor arguments.": { + "code": 2193, + "category": 1 /* Error */ + }, + "Return type of constructor signature must be assignable to the instance type of the class.": { + "code": 2194, + "category": 1 /* Error */ + }, + "Ambient external module declaration must be defined in global context.": { + "code": 2195, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot specify relative module name.": { + "code": 2196, + "category": 1 /* Error */ + }, + "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { + "code": 2197, + "category": 1 /* Error */ + }, + "Could not find the best common type of types of all return statement expressions.": { + "code": 2198, + "category": 1 /* Error */ + }, + "Import declaration cannot refer to external module reference when --noResolve option is set.": { + "code": 2199, + "category": 1 /* Error */ + }, + "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { + "code": 2200, + "category": 1 /* Error */ + }, + "'continue' statement can only be used within an enclosing iteration statement.": { + "code": 2201, + "category": 1 /* Error */ + }, + "'break' statement can only be used within an enclosing iteration or switch statement.": { + "code": 2202, + "category": 1 /* Error */ + }, + "Jump target not found.": { + "code": 2203, + "category": 1 /* Error */ + }, + "Jump target cannot cross function boundary.": { + "code": 2204, + "category": 1 /* Error */ + }, + "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { + "code": 2205, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { + "code": 2206, + "category": 1 /* Error */ + }, + "Expression resolves to '_super' that compiler uses to capture base class reference.": { + "code": 2207, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2208, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2209, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2210, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2211, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2212, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2213, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2214, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2215, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2216, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2217, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2218, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2219, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { + "code": 2220, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2221, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { + "code": 2222, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2223, + "category": 1 /* Error */ + }, + "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { + "code": 2224, + "category": 1 /* Error */ + }, + "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { + "code": 2225, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { + "code": 2226, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { + "code": 2227, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { + "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 */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Variable declaration cannot have the same name as an import declaration.": { + "code": 4026, + "category": 1 /* Error */ + }, + "Signature expected {0} type arguments, got {1} instead.": { + "code": 4027, + "category": 1 /* Error */ + }, + "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { + "code": 4028, + "category": 3 /* NoPrefix */ + }, + "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 infinitely expanding type reference have incompatible type arguments.": { + "code": 4030, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "code": 4031, + "category": 3 /* NoPrefix */ + }, + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { + "code": 4032, + "category": 3 /* NoPrefix */ + }, + "Types of string indexer of types '{0}' and '{1}' are not identical.": { + "code": 4033, + "category": 3 /* NoPrefix */ + }, + "Types of number indexer of types '{0}' and '{1}' are not identical.": { + "code": 4034, + "category": 3 /* NoPrefix */ + }, + "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 assignable to string indexer type in type '{2}'.{NL}{3}": { + "code": 4036, + "category": 3 /* NoPrefix */ + }, + "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 */ + }, + "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { + "code": 5002, + "category": 1 /* Error */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 1 /* Error */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit.": { + "code": 5021, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead.": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Option '{0}' specified without '{1}'": { + "code": 5041, + "category": 1 /* Error */ + }, + "'codepage' option not supported on current platform.": { + "code": 5042, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file.": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file.": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files.": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory.": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output.": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing.": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: '{0}' (default), or '{1}'": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: '{0}' or '{1}'": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message.": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated '{0}' keyword when referencing an external module.": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file1": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options.": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "file2": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "NUMBER": { + "code": 6039, + "category": 2 /* Message */ + }, + "Specify the codepage to use when opening source files.": { + "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 */ + }, + "Unknown rule.": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7015, + "category": 1 /* Error */ + }, + "'{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 = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + this._lineStartPositions = null; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + if (!this._lineStartPositions) { + this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); + } + + return this._lineStartPositions; + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LineMap1) { + function fromSimpleText(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return text.charCodeAt(index); + }, length: text.length() }); + }, text.length()); + } + LineMap1.fromSimpleText = fromSimpleText; + + function fromScriptSnapshot(scriptSnapshot) { + return new TypeScript.LineMap(function () { + return scriptSnapshot.getLineStartPositions(); + }, scriptSnapshot.getLength()); + } + LineMap1.fromScriptSnapshot = fromScriptSnapshot; + + function fromString(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts(text); + }, text.length); + } + LineMap1.fromString = fromString; + })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); + var LineMap1 = TypeScript.LineMap1; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this._lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this._lineStarts(); + }, this.length()); + }; + + TextBase.prototype._lineStarts = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this._lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + this._lazyLineStarts = null; + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.substr = function (start, length, intern) { + var startInOriginalText = this.span.start() + start; + return this.text.substr(startInOriginalText, length, intern); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SubText.prototype._lineStarts = function () { + var _this = this; + if (!this._lazyLineStarts) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return _this.charCodeAt(index); + }, length: this.length() }); + } + + return this._lazyLineStarts; + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + this._lazyLineStarts = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + + StringText.prototype._lineStarts = function () { + if (this._lazyLineStarts === null) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); + } + + return this._lazyLineStarts; + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap1.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + this._lineMap = null; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + if (!this._lineMap) { + this._lineMap = TypeScript.LineMap1.fromString(this.value); + } + + return this._lineMap; + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this.scriptSnapshot.getLineStartPositions(); + }, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length; + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + var change0 = changes[0]; + + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + + oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + CharacterInfo.isOctalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 55 /* _7 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + + SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; + + SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; + SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; + + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + + SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; + SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 164 /* PlusExpression */; + case 90 /* MinusToken */: + return 165 /* NegateExpression */; + case 102 /* TildeToken */: + return 166 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 167 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 168 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 169 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 210 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 211 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 205 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 206 /* DivideExpression */; + + case 92 /* PercentToken */: + return 207 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 208 /* AddExpression */; + + case 90 /* MinusToken */: + return 209 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 202 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 203 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 204 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 196 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 197 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 198 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 199 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 200 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 201 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 192 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 193 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 194 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 195 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 191 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 190 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 189 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 188 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 187 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 182 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 180 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 181 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 183 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 184 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 185 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 175 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 176 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 177 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 178 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 179 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 174 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 173 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function getOperatorTokenFromBinaryExpression(tokenKind) { + switch (tokenKind) { + case 205 /* MultiplyExpression */: + return 91 /* AsteriskToken */; + + case 206 /* DivideExpression */: + return 118 /* SlashToken */; + + case 207 /* ModuloExpression */: + return 92 /* PercentToken */; + + case 208 /* AddExpression */: + return 89 /* PlusToken */; + + case 209 /* SubtractExpression */: + return 90 /* MinusToken */; + + case 202 /* LeftShiftExpression */: + return 95 /* LessThanLessThanToken */; + + case 203 /* SignedRightShiftExpression */: + return 96 /* GreaterThanGreaterThanToken */; + + case 204 /* UnsignedRightShiftExpression */: + return 97 /* GreaterThanGreaterThanGreaterThanToken */; + + case 196 /* LessThanExpression */: + return 80 /* LessThanToken */; + + case 197 /* GreaterThanExpression */: + return 81 /* GreaterThanToken */; + + case 198 /* LessThanOrEqualExpression */: + return 82 /* LessThanEqualsToken */; + + case 199 /* GreaterThanOrEqualExpression */: + return 83 /* GreaterThanEqualsToken */; + + case 200 /* InstanceOfExpression */: + return 30 /* InstanceOfKeyword */; + + case 201 /* InExpression */: + return 29 /* InKeyword */; + + case 192 /* EqualsWithTypeConversionExpression */: + return 84 /* EqualsEqualsToken */; + + case 193 /* NotEqualsWithTypeConversionExpression */: + return 86 /* ExclamationEqualsToken */; + + case 194 /* EqualsExpression */: + return 87 /* EqualsEqualsEqualsToken */; + + case 195 /* NotEqualsExpression */: + return 88 /* ExclamationEqualsEqualsToken */; + + case 191 /* BitwiseAndExpression */: + return 98 /* AmpersandToken */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 100 /* CaretToken */; + + case 189 /* BitwiseOrExpression */: + return 99 /* BarToken */; + + case 188 /* LogicalAndExpression */: + return 103 /* AmpersandAmpersandToken */; + + case 187 /* LogicalOrExpression */: + return 104 /* BarBarToken */; + + case 182 /* OrAssignmentExpression */: + return 116 /* BarEqualsToken */; + + case 180 /* AndAssignmentExpression */: + return 115 /* AmpersandEqualsToken */; + + case 181 /* ExclusiveOrAssignmentExpression */: + return 117 /* CaretEqualsToken */; + + case 183 /* LeftShiftAssignmentExpression */: + return 112 /* LessThanLessThanEqualsToken */; + + case 184 /* SignedRightShiftAssignmentExpression */: + return 113 /* GreaterThanGreaterThanEqualsToken */; + + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + + case 175 /* AddAssignmentExpression */: + return 108 /* PlusEqualsToken */; + + case 176 /* SubtractAssignmentExpression */: + return 109 /* MinusEqualsToken */; + + case 177 /* MultiplyAssignmentExpression */: + return 110 /* AsteriskEqualsToken */; + + case 178 /* DivideAssignmentExpression */: + return 119 /* SlashEqualsToken */; + + case 179 /* ModuloAssignmentExpression */: + return 111 /* PercentEqualsToken */; + + case 174 /* AssignmentExpression */: + return 107 /* EqualsToken */; + + case 173 /* CommaExpression */: + return 79 /* CommaToken */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); + 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + 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 { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + 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(fullText, kind); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(text, start, isTrailing); + }; + + Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.slidingWindow.absoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(diagnostics); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(diagnostics); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifierOrKeyword(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var slidingWindow = this.slidingWindow; + var window = slidingWindow.window; + + var startIndex = slidingWindow.currentRelativeItemIndex; + var endIndex = slidingWindow.windowCount; + var currentIndex = startIndex; + var character = 0; + + while (currentIndex < endIndex) { + character = window[currentIndex]; + if (!isIdentifierPartCharacter[character]) { + break; + } + + currentIndex++; + } + + if (currentIndex === endIndex) { + return 0 /* None */; + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + return 0 /* None */; + } else { + var kind; + var identifierLength = currentIndex - startIndex; + if (isKeywordStartCharacter[firstCharacter]) { + kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); + } else { + kind = 11 /* IdentifierName */; + } + + slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); + + return kind; + } + }; + + Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + var sawUnicodeEscape = false; + + do { + var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); + sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + var length = this.slidingWindow.absoluteIndex() - startIndex; + var text = this.text.substr(startIndex, length, false); + var valueText = TypeScript.Syntax.massageEscapes(text); + + var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); + if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { + if (sawUnicodeEscape) { + return keywordKind | -2147483648 /* IsVariableWidthKeyword */; + } else { + return keywordKind; + } + } + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function (diagnostics) { + if (this.isHexNumericLiteral()) { + this.scanHexNumericLiteral(); + } else if (this.isOctalNumericLiteral()) { + this.scanOctalNumericLiteral(diagnostics); + } else { + this.scanDecimalNumericLiteral(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isOctalNumericLiteral = function () { + return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); + }; + + Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { + var position = this.absoluteIndex(); + + while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.languageVersion() >= 1 /* EcmaScript5 */) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); + } + }; + + Scanner.prototype.scanDecimalDigits = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + this.scanDecimalDigits(); + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + this.scanDecimalDigits(); + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + var nextChar1 = this.slidingWindow.peekItemN(1); + + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { + var nextChar2 = this.slidingWindow.peekItemN(2); + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } + } + } + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function (diagnostics) { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(diagnostics); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 12 /* RegularExpressionLiteral */; + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + break; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + break; + + default: + break; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + this.scanUnicodeOrHexEscape(errors); + return true; + } + } + + this.slidingWindow.moveToNextItem(); + return false; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return parent.type === nodeOrToken; + case 220 /* CastExpression */: + return parent.type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + case 228 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return TypeScript.Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return nodeOrToken.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + element.insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + element.insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + var firstToken = this.firstToken(); + return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.trailingTrivia = function () { + var lastToken = this.lastToken(); + return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + 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 === thisAsIndexable[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isExpression = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + + this._kind = kind; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.kind = function () { + return this._kind; + }; + + HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { + if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.name = name; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.name; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withName = function (name) { + return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { + if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.callSignature = callSignature; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 146 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.modifiers; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifiers = function (modifiers) { + return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + + this.arguments = _arguments; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 142 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 227 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 239 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.constructorKeyword = constructorKeyword; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.constructorKeyword; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + 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 */), CallSignatureSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var GetAccessorSyntax = (function (_super) { + __extends(GetAccessorSyntax, _super); + function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.getKeyword = getKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + } + GetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessor(this); + }; + + GetAccessorSyntax.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + + GetAccessorSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + GetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + GetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetAccessorSyntax.create1 = function (propertyName) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GetAccessorSyntax = GetAccessorSyntax; + + var SetAccessorSyntax = (function (_super) { + __extends(SetAccessorSyntax, _super); + function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.setKeyword = setKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + SetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessor(this); + }; + + SetAccessorSyntax.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + + SetAccessorSyntax.prototype.childCount = function () { + return 5; + }; + + SetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + SetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetAccessorSyntax.create1 = function (propertyName) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SetAccessorSyntax = SetAccessorSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var IndexMemberDeclarationSyntax = (function (_super) { + __extends(IndexMemberDeclarationSyntax, _super); + function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.indexSignature = indexSignature; + this.semicolonToken = semicolonToken; + } + IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexMemberDeclaration(this); + }; + + IndexMemberDeclarationSyntax.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + + IndexMemberDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.indexSignature; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexMemberDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { + if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { + return this; + } + + return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); + }; + + IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); + }; + + IndexMemberDeclarationSyntax.create1 = function (indexSignature) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { + return this.update(this.modifiers, indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.indexSignature, semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexMemberDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + this.colonToken = colonToken; + this.statements = statements; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + this.colonToken = colonToken; + this.statements = statements; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.doKeyword = doKeyword; + this.statement = statement; + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + 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) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var dedentThisTrivia = dedentNextWhitespace; + dedentNextWhitespace = false; + + if (dedentThisTrivia) { + if (trivia.kind() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + var indentNextTrivia = true; + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var indentThisTrivia = indentNextTrivia; + indentNextTrivia = false; + + switch (trivia.kind()) { + case 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; + this.tokenKind = kind; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function isExpression(token) { + switch (token.tokenKind) { + case 11 /* IdentifierName */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 50 /* SuperKeyword */: + return true; + } + + return false; + } + Syntax.isExpression = isExpression; + + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + case 13 /* carriageReturn */: + var nextIndex = i + 1; + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { + i++; + } + continue; + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + return regularExpressionValue(text); + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function regularExpressionValue(text) { + try { + var lastSlash = text.lastIndexOf("/"); + var body = text.substring(1, lastSlash); + var flags = text.substring(lastSlash + 1); + return new RegExp(body, flags); + } catch (e) { + return null; + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + EmptyToken.prototype.isExpression = function () { + return isExpression(this); + }; + + EmptyToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + + RealizedToken.prototype.isExpression = function () { + return isExpression(this); + }; + + RealizedToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var AbstractTrivia = (function () { + function AbstractTrivia(_kind) { + this._kind = _kind; + } + AbstractTrivia.prototype.fullWidth = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.fullText = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.toJSON = function (key) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === this._kind) { + result.kind = name; + break; + } + } + + if (this.isSkippedToken()) { + result.skippedToken = this.skippedToken(); + } else { + result.text = this.fullText(); + } + return result; + }; + + AbstractTrivia.prototype.kind = function () { + return this._kind; + }; + + AbstractTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + AbstractTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + AbstractTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + AbstractTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + AbstractTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return AbstractTrivia; + })(); + + var NormalTrivia = (function (_super) { + __extends(NormalTrivia, _super); + function NormalTrivia(kind, _text) { + _super.call(this, kind); + this._text = _text; + } + NormalTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + NormalTrivia.prototype.fullText = function () { + return this._text; + }; + + NormalTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return NormalTrivia; + })(AbstractTrivia); + + var SkippedTokenTrivia = (function (_super) { + __extends(SkippedTokenTrivia, _super); + function SkippedTokenTrivia(_skippedToken) { + _super.call(this, 8 /* SkippedTokenTrivia */); + this._skippedToken = _skippedToken; + } + SkippedTokenTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SkippedTokenTrivia.prototype.fullText = function () { + return this.skippedToken().fullText(); + }; + + SkippedTokenTrivia.prototype.skippedToken = function () { + return this._skippedToken; + }; + return SkippedTokenTrivia; + })(AbstractTrivia); + + var DeferredTrivia = (function (_super) { + __extends(DeferredTrivia, _super); + function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { + _super.call(this, kind); + this._text = _text; + this._fullStart = _fullStart; + this._fullWidth = _fullWidth; + this._fullText = null; + } + DeferredTrivia.prototype.fullWidth = function () { + return this._fullWidth; + }; + + DeferredTrivia.prototype.fullText = function () { + if (!this._fullText) { + this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); + this._text = null; + } + + return this._fullText; + }; + + DeferredTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return DeferredTrivia; + })(AbstractTrivia); + + function deferredTrivia(kind, text, fullStart, fullWidth) { + return new DeferredTrivia(kind, text, fullStart, fullWidth); + } + Syntax.deferredTrivia = deferredTrivia; + + function trivia(kind, text) { + return new NormalTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SkippedTokenTrivia(token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + this.trivia[i].collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 228 /* TypeArgumentList */: + case 229 /* TypeParameterList */: + case 220 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.name); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitList(node.modifiers); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.constructorKeyword); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.indexSignature); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + + + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + var result = this.currentToken(); + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + + return result; + }; + return SyntaxCursor; + })(); + + + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); + } + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { + this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 173 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 186 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 187 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 188 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 189 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 191 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 167 /* LogicalNotExpression */: + case 170 /* DeleteExpression */: + case 171 /* TypeOfExpression */: + case 172 /* VoidExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); + } + } + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + var modifierCount = this.modifierCount(); + return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + var modifierCount = this.modifierCount(); + if (this.isImportDeclaration(modifierCount)) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration(modifierCount)) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration(modifierCount)) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration(modifierCount)) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration(modifierCount)) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(inErrorRecovery)) { + return this.parseStatement(inErrorRecovery); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + + return typeArgumentList; + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isAccessor = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(false); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexMemberDeclaration()) { + return this.parseIndexMemberDeclaration(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var modifiers = this.parseModifiers(); + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var callSignature = this.parseCallSignature(false); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.isIndexMemberDeclaration = function () { + var index = this.modifierCount(); + return this.isIndexSignature(index); + }; + + ParserImpl.prototype.parseIndexMemberDeclaration = function () { + var modifiers = this.parseModifiers(); + var indexSignature = this.parseIndexSignature(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + if (callSignature.lastToken()) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature(0)) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(inErrorRecovery)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(inErrorRecovery)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function (tokenIndex) { + return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isIdentifier(this.currentToken())) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + + break; + + case 28 /* IfKeyword */: + case 70 /* OpenBraceToken */: + case 33 /* ReturnKeyword */: + case 34 /* SwitchKeyword */: + case 36 /* ThrowKeyword */: + case 15 /* BreakKeyword */: + case 18 /* ContinueKeyword */: + case 26 /* ForKeyword */: + case 42 /* WhileKeyword */: + case 43 /* WithKeyword */: + case 22 /* DoKeyword */: + case 38 /* TryKeyword */: + case 19 /* DebuggerKeyword */: + return true; + } + + if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { + return false; + } + + return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); + }; + + ParserImpl.prototype.parseStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 28 /* IfKeyword */: + return this.parseIfStatement(); + case 70 /* OpenBraceToken */: + return this.parseBlock(false, false); + case 33 /* ReturnKeyword */: + return this.parseReturnStatement(); + case 34 /* SwitchKeyword */: + return this.parseSwitchStatement(); + case 36 /* ThrowKeyword */: + return this.parseThrowStatement(); + case 15 /* BreakKeyword */: + return this.parseBreakStatement(); + case 18 /* ContinueKeyword */: + return this.parseContinueStatement(); + case 26 /* ForKeyword */: + return this.parseForOrForInStatement(); + case 42 /* WhileKeyword */: + return this.parseWhileStatement(); + case 43 /* WithKeyword */: + return this.parseWithStatement(); + case 22 /* DoKeyword */: + return this.parseDoStatement(); + case 38 /* TryKeyword */: + return this.parseTryStatement(); + case 19 /* DebuggerKeyword */: + return this.parseDebuggerStatement(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement(currentToken)) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { + return this.parseEmptyStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(false); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function (currentToken) { + return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(false); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return currentToken.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function (currentToken) { + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function (currentToken) { + switch (currentToken.tokenKind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + + case 74 /* OpenBracketToken */: + + case 72 /* OpenParenToken */: + + case 80 /* LessThanToken */: + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + + case 70 /* OpenBraceToken */: + + case 85 /* EqualsGreaterThanToken */: + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + + case 31 /* NewKeyword */: + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + + case 27 /* FunctionKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(false); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 225 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(token0); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpressionOrLower = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpressionOrLower(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else if (currentTokenKind === 39 /* TypeOfKeyword */) { + return this.parseTypeOfExpression(); + } else if (currentTokenKind === 41 /* VoidKeyword */) { + return this.parseVoidExpression(); + } else if (currentTokenKind === 21 /* DeleteKeyword */) { + return this.parseDeleteExpression(); + } else if (currentTokenKind === 80 /* LessThanToken */) { + return this.parseCastExpression(); + } else { + return this.parsePostfixExpressionOrLower(); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + if (precedence <= 2 /* AssignmentExpressionPrecedence */) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } + + var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); + if (parethesizedArrowFunction !== null) { + return parethesizedArrowFunction; + } + } + + var leftOperand = this.parseUnaryExpressionOrLower(); + return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } + + var expression = this.parsePrimaryExpression(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + return this.parseMemberExpressionRest(expression, false, inObjectCreation); + }; + + ParserImpl.prototype.parseCallExpressionOrLower = function () { + var expression; + if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { + expression = this.eatKeyword(50 /* SuperKeyword */); + + var currentTokenKind = this.currentToken().tokenKind; + if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + } + } else { + expression = this.parseMemberExpressionOrLower(false); + } + + return this.parseMemberExpressionRest(expression, true, false); + }; + + ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (!allowArguments) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (!allowArguments) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseCallExpressionOrLower(); + } + }; + + ParserImpl.prototype.parsePostfixExpressionOrLower = function () { + var expression = this.parseLeftHandSideExpressionOrLower(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + } + + return expression; + }; + + ParserImpl.prototype.tryParseGenericArgumentList = function () { + var rewindPoint = this.getRewindPoint(); + + var typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + + var argumentList = null; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } else { + return this.parseArgumentList(typeArgumentList); + } + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + return this.tryParseGenericArgumentList(); + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(null); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var _arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + _arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parsePrimaryExpression = function () { + var currentToken = this.currentToken(); + + if (this.isIdentifier(currentToken)) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseObjectCreationExpressionOrLower(true); + var argumentList = this.tryParseArgumentList(); + + var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); + return this.parseMemberExpressionRest(result, true, false); + }; + + ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseMemberExpressionOrLower(inObjectCreation); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedExpression = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { + return null; + } + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + + this.releaseRewindPoint(rewindPoint); + return arrowFunction; + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.tryParseArrowFunctionBlock = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { + return this.parseBlock(true, false); + } else { + return null; + } + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + token2 = this.peekToken(2); + if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { + if (this.isIdentifier(token2)) { + return true; + } + } + + if (!this.isIdentifier(token1)) { + return false; + } + + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { + if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(true); + } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + return this.eatKeyword(35 /* ThisKeyword */); + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameters = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); + + return typeParameterList; + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 39 /* TypeOfKeyword */: + + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + + case 70 /* OpenBraceToken */: + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + + case 31 /* NewKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + var type = this.parseNonArrayType(currentToken); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function (currentToken) { + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return this.eatAnyToken(); + + case 70 /* OpenBraceToken */: + return this.parseObjectType(); + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + return this.parseFunctionType(); + + case 31 /* NewKeyword */: + return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); + } + + return this.parseNameOrGenericType(); + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + var tokenKind = token.tokenKind; + if (tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { + if (this.isIdentifier(token)) { + var nextTokenKind = this.peekToken(1).tokenKind; + switch (nextTokenKind) { + case 73 /* CloseParenToken */: + case 106 /* ColonToken */: + case 107 /* EqualsToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { + modifierArray.push(this.eatAnyToken()); + continue; + } + + break; + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + 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; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType, inErrorRecovery); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + var currentToken = this.currentToken(); + if (this.isExpression(currentToken)) { + return true; + } + + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.parseStatement(inErrorRecovery); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(inErrorRecovery); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.inObjectLiteralExpression = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { + return true; + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { + if (parameter.modifiers.childCount() > 0) { + var modifiers = parameter.modifiers; + var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + + if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { + if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); + return true; + } else { + if (modifierIndex > 0) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + 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.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; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.modifiers.childCount() > 0) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + 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; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + 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) { + 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; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + 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; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { + var getKeywordFullStart = this.childFullStart(node, getKeyword); + if (parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { + if (this.checkIndexMemberModifiers(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIndexMemberDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { + if (node.modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(node, node.modifiers); + this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { + var savedInObjectLiteralExpression = this.inObjectLiteralExpression; + this.inObjectLiteralExpression = true; + _super.prototype.visitObjectLiteralExpression.call(this, node); + this.inObjectLiteralExpression = savedInObjectLiteralExpression; + }; + + GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { + var setKeywordFullStart = this.childFullStart(node, setKeyword); + if (parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); + var parameter = parameterList.parameters.childAt(0); + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + 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 && previousValueWasComputed) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (node.stringLiteral === null) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { + this.skip(node); + return; + } + + _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); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock || this.inObjectLiteralExpression) { + if (modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { + this.skip(node); + return; + } + + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { + var currentElementFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var child = modifiers.childAt(i); + if (child.kind() !== 57 /* PublicKeyword */) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); + return true; + } + + currentElementFullStart += child.fullWidth(); + } + + 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); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Document = (function () { + function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { + this._compiler = _compiler; + this._semanticInfoChain = _semanticInfoChain; + this.fileName = fileName; + this.referencedFiles = referencedFiles; + this._scriptSnapshot = _scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._syntaxTree = _syntaxTree; + this._topLevelDecl = _topLevelDecl; + this._diagnostics = null; + this._bloomFilter = null; + this._sourceUnit = null; + this._lineMap = null; + this._declASTMap = []; + this._astDeclMap = []; + this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; + } + Document.prototype.invalidate = function () { + this._declASTMap.length = 0; + this._astDeclMap.length = 0; + this._topLevelDecl = null; + + this._syntaxTree = null; + this._sourceUnit = null; + this._diagnostics = null; + this._bloomFilter = null; + }; + + Document.prototype.isDeclareFile = function () { + return TypeScript.isDTSFile(this.fileName); + }; + + Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + + this._lineMap = syntaxTree.lineMap(); + + var sourceUnit = syntaxTree.sourceUnit(); + var leadingTrivia = sourceUnit.leadingTrivia(); + + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); + + var amdDependencies = []; + 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); + } + } + } + + this._amdDependencies = amdDependencies; + }; + + Document.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(trivia.fullText()); + + if (match) { + return new TypeScript.TextSpan(position, trivia.fullWidth()); + } + + return null; + }; + + 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); + } + } + + position += moduleElement.fullWidth(); + } + + return null; + ; + }; + + Document.prototype.sourceUnit = function () { + if (!this._sourceUnit) { + var start = new Date().getTime(); + var syntaxTree = this.syntaxTree(); + this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + + if (!this.isOpen) { + this._syntaxTree = null; + } + } + + return this._sourceUnit; + }; + + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._diagnostics); + } + + return this._diagnostics; + }; + + Document.prototype.lineMap = function () { + if (this._lineMap === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._lineMap); + } + + return this._lineMap; + }; + + Document.prototype.isExternalModule = function () { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); + } + + return this._externalModuleIndicatorSpan; + }; + + Document.prototype.amdDependencies = function () { + if (this._amdDependencies === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._amdDependencies !== undefined); + } + + return this._amdDependencies; + }; + + Document.prototype.syntaxTree = function () { + var result = this._syntaxTree; + if (!result) { + var start = new Date().getTime(); + + result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); + + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + if (this.isOpen || !this._sourceUnit) { + this._syntaxTree = result; + } + } + + this.cacheSyntaxTreeInfo(result); + return result; + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = TypeScript.createIntrinsicsObject(); + var pre = function (cur) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { + if (cur.kind() === 11 /* IdentifierName */) { + var nodeText = cur.valueText(); + + identifiers[nodeText] = true; + } + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.emitToOwnOutputFile = function () { + return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { + var oldSyntaxTree = this._syntaxTree; + + if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { + var oldText = this._scriptSnapshot; + var newText = scriptSnapshot; + + TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); + var newTextPrefix = newText.getText(0, textChangeRange.span().start()); + TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); + + var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); + var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); + TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); + }; + + Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); + }; + + Document.prototype.topLevelDecl = function () { + if (this._topLevelDecl === null) { + this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); + } + + return this._topLevelDecl; + }; + + Document.prototype._getDeclForAST = function (ast) { + this.topLevelDecl(); + return this._astDeclMap[ast.syntaxID()]; + }; + + Document.prototype.getEnclosingDecl = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + return this._getDeclForAST(ast); + } + + ast = ast.parent; + var decl = null; + while (ast) { + decl = this._getDeclForAST(ast); + + if (decl) { + break; + } + + ast = ast.parent; + } + + return decl._getEnclosingDeclFromParentDecl(); + }; + + Document.prototype._setDeclForAST = function (ast, decl) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._astDeclMap[ast.syntaxID()] = decl; + }; + + Document.prototype._getASTForDecl = function (decl) { + return this._declASTMap[decl.declID]; + }; + + Document.prototype._setASTForDecl = function (decl, ast) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._declASTMap[decl.declID] = ast; + }; + return Document; + })(); + TypeScript.Document = Document; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var proto = "__proto__"; + + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + + this[proto] = null; + this[proto] = undefined; + } + return BlockIntrinsics; + })(); + + function createIntrinsicsObject() { + return new BlockIntrinsics(); + } + TypeScript.createIntrinsicsObject = createIntrinsicsObject; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = createIntrinsicsObject(); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (!fn(k, this.table[k], context)) { + return false; + } + } + } + + return true; + }; + + StringHashTable.prototype.some = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (fn(k, this.table[k], context)) { + return true; + } + } + } + + return false; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + + StringHashTable.prototype.remove = function (key) { + if (this.table[key] !== undefined) { + this.table[key] = undefined; + this.itemCount--; + } + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (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); + } + ASTHelpers.moduleIsElided = moduleIsElided; + + 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)) { + 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; + } + ASTHelpers.enumIsElided = enumIsElided; + + function isValidAstNode(ast) { + if (!ast) + return false; + + if (ast.start() === -1 || ast.end() === -1) + return false; + + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; + + 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; + + 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) { + top = cur; + } + } + } + } + + 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; + } + } + + return false; + } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; + + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } + + 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); + } + 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; + } + + current = current.parent; + } + 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; + } + + return null; + } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; + + 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; + } + 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; + + function parametersFromIdentifier(id) { + return { + length: 1, + lastParameterIsRest: function () { + return false; + }, + ast: id, + astAt: function (index) { + return id; + }, + identifierAt: function (index) { + return id; + }, + typeAt: function (index) { + return null; + }, + initializerAt: function (index) { + return null; + }, + isOptionalAt: function (index) { + return false; + } + }; + } + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; + + function parametersFromParameter(parameter) { + return { + length: 1, + lastParameterIsRest: function () { + return parameter.dotDotDotToken !== null; + }, + ast: parameter, + astAt: function (index) { + return parameter; + }, + identifierAt: function (index) { + return parameter.identifier; + }, + typeAt: function (index) { + return getType(parameter); + }, + initializerAt: function (index) { + return parameter.equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(parameter); + } + }; + } + ASTHelpers.parametersFromParameter = parametersFromParameter; + + function parameterIsOptional(parameter) { + return parameter.questionToken !== null || parameter.equalsValueClause !== null; + } + + function parametersFromParameterList(list) { + return { + length: list.parameters.nonSeparatorCount(), + lastParameterIsRest: function () { + return TypeScript.lastParameterIsRest(list); + }, + ast: list.parameters, + astAt: function (index) { + return list.parameters.nonSeparatorAt(index); + }, + identifierAt: function (index) { + return list.parameters.nonSeparatorAt(index).identifier; + }, + typeAt: function (index) { + return getType(list.parameters.nonSeparatorAt(index)); + }, + initializerAt: function (index) { + return list.parameters.nonSeparatorAt(index).equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(list.parameters.nonSeparatorAt(index)); + } + }; + } + ASTHelpers.parametersFromParameterList = parametersFromParameterList; + + 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; + } + } + ASTHelpers.isDeclarationAST = isDeclarationAST; + + 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; + } + + 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; + } + + ast = ast.parent; + } + + return null; + } + ASTHelpers.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); + + 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 { + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); + } + } + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function walkListChildren(preAst, walker) { + for (var i = 0, n = preAst.childCount(); i < n; i++) { + walker.walk(preAst.childAt(i)); + } + } + + function walkThrowStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkPrefixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkPostfixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkDeleteExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkTypeArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArguments); + } + + function walkTypeOfExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkVoidExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArgumentList); + walker.walk(preAst.arguments); + } + + function walkArrayLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.expressions); + } + + function walkSimplePropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.expression); + } + + function walkFunctionPropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkGetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkSeparatedListChildren(preAst, walker) { + for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { + walker.walk(preAst.nonSeparatorAt(i)); + } + } + + function walkSetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.block); + } + + function walkObjectLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.propertyAssignments); + } + + function walkCastExpressionChildren(preAst, walker) { + walker.walk(preAst.type); + walker.walk(preAst.expression); + } + + function walkParenthesizedExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkElementAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentExpression); + } + + function walkMemberAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.name); + } + + function walkQualifiedNameChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkBinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkEqualsValueClauseChildren(preAst, walker) { + walker.walk(preAst.value); + } + + function walkTypeParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.constraint); + } + + function walkTypeParameterListChildren(preAst, walker) { + walker.walk(preAst.typeParameters); + } + + function walkGenericTypeChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.typeArgumentList); + } + + function walkTypeAnnotationChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkTypeQueryChildren(preAst, walker) { + walker.walk(preAst.name); + } + + function walkInvocationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkObjectCreationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkTrinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.whenTrue); + walker.walk(preAst.whenFalse); + } + + function walkFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFunctionTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkMemberFunctionDeclarationChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFuncDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkIndexMemberDeclarationChildren(preAst, walker) { + walker.walk(preAst.indexSignature); + } + + function walkIndexSignatureChildren(preAst, walker) { + walker.walk(preAst.parameter); + walker.walk(preAst.typeAnnotation); + } + + function walkCallSignatureChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + } + + function walkConstraintChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkConstructorDeclarationChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkConstructorTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkConstructSignatureChildren(preAst, walker) { + walker.walk(preAst.callSignature); + } + + function walkParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkParameterListChildren(preAst, walker) { + walker.walk(preAst.parameters); + } + + function walkPropertySignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + } + + function walkVariableDeclaratorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkMemberVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.variableDeclarator); + } + + function walkMethodSignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + } + + function walkReturnStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkForStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.initializer); + walker.walk(preAst.condition); + walker.walk(preAst.incrementor); + walker.walk(preAst.statement); + } + + function walkForInStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.left); + walker.walk(preAst.expression); + walker.walk(preAst.statement); + } + + function walkIfStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + walker.walk(preAst.elseClause); + } + + function walkElseClauseChildren(preAst, walker) { + walker.walk(preAst.statement); + } + + function walkWhileStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkDoStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkBlockChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.declarators); + } + + function walkCaseSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.statements); + } + + function walkDefaultSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkSwitchStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.switchClauses); + } + + function walkTryStatementChildren(preAst, walker) { + walker.walk(preAst.block); + walker.walk(preAst.catchClause); + walker.walk(preAst.finallyClause); + } + + function walkCatchClauseChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkExternalModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.stringLiteral); + } + + function walkFinallyClauseChildren(preAst, walker) { + walker.walk(preAst.block); + } + + function walkClassDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.classElements); + } + + function walkScriptChildren(preAst, walker) { + walker.walk(preAst.moduleElements); + } + + function walkHeritageClauseChildren(preAst, walker) { + walker.walk(preAst.typeNames); + } + + function walkInterfaceDeclerationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.body); + } + + function walkObjectTypeChildren(preAst, walker) { + walker.walk(preAst.typeMembers); + } + + function walkArrayTypeChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkModuleDeclarationChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.stringLiteral); + walker.walk(preAst.moduleElements); + } + + function walkModuleNameModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.moduleName); + } + + function walkEnumDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.enumElements); + } + + function walkEnumElementChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.equalsValueClause); + } + + function walkImportDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.moduleReference); + } + + function walkExportAssignmentChildren(preAst, walker) { + walker.walk(preAst.identifier); + } + + function walkWithStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkExpressionStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkLabeledStatementChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.statement); + } + + function walkVariableStatementChildren(preAst, walker) { + walker.walk(preAst.declaration); + } + + var childrenWalkers = new Array(246 /* Last */ + 1); + + for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { + childrenWalkers[i] = null; + } + for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { + childrenWalkers[i] = null; + } + + childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; + childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[60 /* AnyKeyword */] = null; + childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; + childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; + childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; + childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; + childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; + childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[146 /* Block */] = walkBlockChildren; + childrenWalkers[61 /* BooleanKeyword */] = null; + childrenWalkers[152 /* BreakStatement */] = null; + childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; + childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; + childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; + childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; + childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; + childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; + childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; + childrenWalkers[239 /* Constraint */] = walkConstraintChildren; + childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; + childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; + childrenWalkers[153 /* ContinueStatement */] = null; + childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; + childrenWalkers[162 /* DebuggerStatement */] = null; + childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; + childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; + childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; + childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; + childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; + childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; + childrenWalkers[156 /* EmptyStatement */] = null; + childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; + childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; + childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; + childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; + childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; + childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; + childrenWalkers[24 /* FalseKeyword */] = null; + childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; + childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; + childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; + childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; + childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; + childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; + childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; + childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; + childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; + childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; + childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; + childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; + childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; + childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; + childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; + childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; + childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; + childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; + childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[1 /* List */] = walkListChildren; + childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; + childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; + childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; + childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; + childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; + childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; + childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; + childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; + childrenWalkers[11 /* IdentifierName */] = null; + childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[0 /* None */] = null; + childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[32 /* NullKeyword */] = null; + childrenWalkers[67 /* NumberKeyword */] = null; + childrenWalkers[13 /* NumericLiteral */] = null; + childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; + childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; + childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; + childrenWalkers[223 /* OmittedExpression */] = null; + childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[242 /* Parameter */] = walkParameterChildren; + childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; + childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; + childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; + childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; + childrenWalkers[12 /* RegularExpressionLiteral */] = null; + childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; + childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; + childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; + childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; + childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; + childrenWalkers[14 /* StringLiteral */] = null; + childrenWalkers[69 /* StringKeyword */] = null; + childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; + childrenWalkers[50 /* SuperKeyword */] = null; + childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; + childrenWalkers[35 /* ThisKeyword */] = null; + childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; + childrenWalkers[3 /* TriviaList */] = null; + childrenWalkers[37 /* TrueKeyword */] = null; + childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; + childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; + childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; + childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; + childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; + childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; + childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; + childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; + childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; + childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; + childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; + childrenWalkers[41 /* VoidKeyword */] = null; + childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; + childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; + + for (var e in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { + TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); + } + } + + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + this.stopWalking = false; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var SimplePreAstWalker = (function () { + function SimplePreAstWalker(pre, state) { + this.pre = pre; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePreAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + }; + return SimplePreAstWalker; + })(); + + var SimplePrePostAstWalker = (function () { + function SimplePrePostAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePrePostAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + + this.post(ast, this.state); + }; + return SimplePrePostAstWalker; + })(); + + var NormalAstWalker = (function () { + function NormalAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + NormalAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + if (this.options.stopWalking) { + return; + } + + this.pre(ast, this); + + if (this.options.stopWalking) { + return; + } + + if (this.options.goChildren) { + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + } else { + this.options.goChildren = true; + } + + if (this.post) { + this.post(ast, this); + } + }; + return NormalAstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { + new NormalAstWalker(pre, post, state).walk(ast); + }; + + AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { + if (post) { + new SimplePrePostAstWalker(pre, post, state).walk(ast); + } else { + new SimplePreAstWalker(pre, state).walk(ast); + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory = new AstWalkerFactory(); + + function getAstWalkerFactory() { + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapEntry = (function () { + function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { + this.emittedFile = emittedFile; + this.emittedLine = emittedLine; + this.emittedColumn = emittedColumn; + this.sourceFile = sourceFile; + this.sourceLine = sourceLine; + this.sourceColumn = sourceColumn; + this.sourceName = sourceName; + TypeScript.Debug.assert(isFinite(emittedLine)); + TypeScript.Debug.assert(isFinite(emittedColumn)); + TypeScript.Debug.assert(isFinite(sourceColumn)); + TypeScript.Debug.assert(isFinite(sourceLine)); + } + return SourceMapEntry; + })(); + TypeScript.SourceMapEntry = SourceMapEntry; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.names = []; + this.mappingLevel = []; + this.tsFilePaths = []; + this.allSourceMappings = []; + this.sourceMapEntries = []; + this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); + this.setNewSourceFile(document, emitOptions); + } + SourceMapper.prototype.getOutputFile = function () { + var result = this.sourceMapOut.getOutputFile(); + result.sourceMapEntries = this.sourceMapEntries; + + return result; + }; + + SourceMapper.prototype.increaseMappingLevel = function (ast) { + this.mappingLevel.push(ast); + }; + + SourceMapper.prototype.decreaseMappingLevel = function (ast) { + TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); + var expectedAst = this.mappingLevel.pop(); + var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; + var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; + TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); + }; + + SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { + var sourceMappings = []; + this.allSourceMappings.push(sourceMappings); + this.currentMappings = [sourceMappings]; + this.currentNameIndex = []; + + this.setNewSourceFilePath(document, emitOptions); + }; + + SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; + this.jsFileName = prettyJsFileName; + + if (emitOptions.sourceMapRootDirectory()) { + this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); + if (document.emitToOwnOutputFile()) { + this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); + } + + if (TypeScript.isRelative(this.sourceMapDirectory)) { + this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; + this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); + this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); + } else { + this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; + } + } else { + this.sourceMapPath = prettyMapFileName; + this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + this.sourceRoot = emitOptions.sourceRootDirectory(); + }; + + SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + if (emitOptions.sourceRootDirectory()) { + tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); + } else { + tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); + } + this.tsFilePaths.push(tsFilePath); + }; + + SourceMapper.prototype.emitSourceMapping = function () { + var _this = this; + TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { + return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); + }).join(', ')); + + this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); + + var mappingsString = ""; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); + prevSourceIndex = sourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); + prevNameIndex = nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + for (var i = 0; i < sourceMappings.length; i++) { + var sourceMapping = sourceMappings[i]; + recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); + recordSourceMappingSiblings(sourceMapping.childMappings); + recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); + } + }; + + recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); + } + + this.sourceMapOut.Write(JSON.stringify({ + version: 3, + file: this.jsFileName, + sourceRoot: this.sourceRoot, + sources: this.tsFilePaths, + names: this.names, + mappings: mappingsString + })); + + this.sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compiler, resolvePath) { + this.resolvePath = resolvePath; + this._diagnostic = null; + this._settings = null; + this._commonDirectoryPath = ""; + this._sharedOutputFile = ""; + this._sourceRootDirectory = ""; + this._sourceMapRootDirectory = ""; + this._outputDirectory = ""; + var settings = compiler.compilationSettings(); + this._settings = settings; + + 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()) { + if (settings.mapRoot()) { + if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } else { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } else if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } + + this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); + this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); + + if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { + if (settings.outFileOption()) { + this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); + } + + if (settings.outDirOption()) { + this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); + } + + if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { + this.determineCommonDirectoryPath(compiler); + } + } + } + EmitOptions.prototype.diagnostic = function () { + return this._diagnostic; + }; + + EmitOptions.prototype.commonDirectoryPath = function () { + return this._commonDirectoryPath; + }; + EmitOptions.prototype.sharedOutputFile = function () { + return this._sharedOutputFile; + }; + EmitOptions.prototype.sourceRootDirectory = function () { + return this._sourceRootDirectory; + }; + EmitOptions.prototype.sourceMapRootDirectory = function () { + return this._sourceMapRootDirectory; + }; + EmitOptions.prototype.outputDirectory = function () { + return this._outputDirectory; + }; + + EmitOptions.prototype.compilationSettings = function () { + return this._settings; + }; + + EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = compiler.fileNames(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = compiler.getDocument(fileNames[i]); + var sourceUnit = document.sourceUnit(); + + if (!document.isDeclareFile()) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + 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; + } + + return; + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + function lastParameterIsRest(parameterList) { + var parameters = parameterList.parameters; + return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; + } + TypeScript.lastParameterIsRest = lastParameterIsRest; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.inArrowFunction = false; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.declStack = []; + this.exportAssignment = null; + this.inWithBlock = false; + this.document = null; + this.detachedCommentsElement = null; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; + }; + + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.shouldEmitImportDeclaration = 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 */; + + 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 */; + + this.emitComments(importDeclAST, true); + + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + 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 */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + if (isAmdCodeGen && isExternalModuleReference) { + needsPropertyAssignment = true; + } else { + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.identifier.text() + " = "); + var aliasAST = importDeclAST.moduleReference; + + if (isExternalModuleReference) { + this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); + } else { + this.emitJavascript(aliasAST.moduleName, false); + } + + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + } + } + + if (needsPropertyAssignment) { + this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + }; + + Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { + this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); + }; + + Emitter.prototype.setSourceMapperNewSourceFile = function (document) { + this.sourceMapper.setNewSourceFile(document, this.emitOptions); + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { + this.recordSourceMappingStart(astSpan); + this.writeToOutput(s); + this.recordSourceMappingEnd(astSpan); + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeLineToOutput = function (s, force) { + if (typeof force === "undefined") { force = false; } + if (!force && s === "" && this.emitState.column === 0) { + return; + } + + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment, trailing, first) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var text = getTrimmedTextLines(comment); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } else if (trailing && first) { + this.writeToOutput(" "); + } + + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (!trailing && emitColumn !== 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { + 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; + } + } + + if (pre) { + var preComments = ast.preComments(); + + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; + } + + if (preComments && onlyPinnedOrTripleSlashComments) { + preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { + return _this.isPinnedOrTripleSlash(c); + }); + } + + this.emitCommentsArray(preComments, false); + } else { + this.emitCommentsArray(ast.postComments(), true); + } + }; + + Emitter.prototype.isPinnedOrTripleSlash = function (comment) { + var fullText = comment.fullText(); + if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { + return true; + } else { + return fullText.indexOf("/*!") === 0; + } + }; + + Emitter.prototype.emitCommentsArray = function (comments, trailing) { + if (!this.emitOptions.compilationSettings().removeComments() && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i], trailing, i === 0); + } + } + }; + + Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { + this.recordSourceMappingStart(objectLiteral); + + this.writeToOutput("{"); + this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); + this.writeToOutput("}"); + + this.recordSourceMappingEnd(objectLiteral); + }; + + Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { + this.recordSourceMappingStart(arrayLiteral); + + this.writeToOutput("["); + this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); + this.writeToOutput("]"); + + this.recordSourceMappingEnd(arrayLiteral); + }; + + Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { + this.recordSourceMappingStart(objectCreationExpression); + this.writeToOutput("new "); + var target = objectCreationExpression.expression; + + this.emit(target); + if (objectCreationExpression.argumentList) { + this.recordSourceMappingStart(objectCreationExpression.argumentList); + this.writeToOutput("("); + this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); + this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); + this.recordSourceMappingEnd(objectCreationExpression.argumentList); + } + + this.recordSourceMappingEnd(objectCreationExpression); + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); + if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + if (pullDecl.kind === 67108864 /* EnumMember */) { + return pullDecl; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + var propertyName = dotExpr.name; + var boundDecl = this.getConstantDecl(dotExpr); + if (boundDecl) { + var value = boundDecl.constantValue; + if (value !== null) { + this.recordSourceMappingStart(dotExpr); + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.text(); + comment += " */"; + this.writeToOutput(comment); + this.recordSourceMappingEnd(dotExpr); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitInvocationExpression = function (callNode) { + this.recordSourceMappingStart(callNode); + var target = callNode.expression; + var args = callNode.argumentList.arguments; + + if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { + this.emit(target); + this.writeToOutput(".call"); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitThis(); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + } else { + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + + this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); + this.recordSourceMappingEnd(args); + this.recordSourceMappingEnd(callNode); + }; + + Emitter.prototype.emitParameterList = function (list) { + this.writeToOutput("("); + this.emitCommentsArray(list.openParenTrailingComments, true); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); + this.writeToOutput(")"); + }; + + Emitter.prototype.emitFunctionParameters = function (parameters) { + var argsLen = 0; + + if (parameters) { + this.emitComments(parameters.ast, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = parameters.length; + var printLen = argsLen; + if (parameters.lastParameterIsRest()) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = parameters.astAt(i); + this.emit(arg); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(parameters.ast, false); + } + }; + + Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { + this.writeLineToOutput(" {"); + if (name) { + this.recordSourceMappingNameStart(name); + } + + this.indenter.increaseIndent(); + + 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); + } else { + this.emitIndent(); + this.emitCommentsArray(bodyExpression.preComments(), false); + this.writeToOutput("return "); + this.emit(bodyExpression); + this.writeLineToOutput(";"); + this.emitCommentsArray(bodyExpression.postComments(), true); + } + + this.indenter.decreaseIndent(); + this.emitIndent(); + + if (block) { + this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); + } else { + this.writeToOutputWithSourceMapRecord("}", bodyExpression); + } + + if (name) { + this.recordSourceMappingNameEnd(); + } + }; + + Emitter.prototype.emitDefaultValueAssignments = function (parameters) { + var n = parameters.length; + if (parameters.lastParameterIsRest()) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = parameters.astAt(i); + var id = parameters.identifierAt(i); + var equalsValueClause = parameters.initializerAt(i); + if (equalsValueClause) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.emitJavascript(equalsValueClause, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (parameters) { + if (parameters.lastParameterIsRest()) { + var n = parameters.length; + var lastArg = parameters.astAt(n - 1); + var id = parameters.identifierAt(n - 1); + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); + this.writeToOutput(" "); + this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); + this.writeToOutput("; "); + this.writeToOutputWithSourceMapRecord("_i++", lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + var result = []; + + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + var queue = dynamicModuleDecl.getChildDecls(); + + for (var i = 0, n = queue.length; i < n; i++) { + var decl = queue[i]; + + if (decl.kind & 128 /* TypeAlias */) { + var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { + var importList = ""; + var dependencyList = ""; + + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue()) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += importStatementDecl.name; + dependencyList += importStatementAST.moduleReference.stringLiteral.text(); + } + } + } + + var amdDependencies = this.document.amdDependencies(); + for (var i = 0; i < amdDependencies.length; i++) { + dependencyList += ", \"" + amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); + } + + var decl = this.semanticInfoChain.getDeclForAST(ast); + if (decl) { + return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); + } + + return false; + }; + + Emitter.prototype.emitEnum = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.identifier.text(); + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.identifier); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(this.moduleName); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitSeparatedList(moduleDecl.enumElements); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { + return moduleDecl; + } else if (changeNameIfAnyDeclarationInContext) { + var symbol = moduleDecl.getSymbol(); + if (symbol) { + var otherDecls = symbol.getDeclarations(); + for (var i = 0; i < otherDecls.length; i++) { + if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { + return otherDecls[i]; + } + } + } + } + + return null; + }; + + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { + var _this = this; + var childDecls = parentDecl.getChildDecls(); + return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { + 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; + } + } + return false; + }); + }; + + Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + var moduleName = moduleDecl.name; + var moduleDisplayName = moduleDecl.getDisplayName(); + + moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { + moduleName = "_" + moduleName; + moduleDisplayName = "_" + moduleDisplayName; + } + } + + return moduleDisplayName; + }; + + Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { + if (moduleDecl.stringLiteral) { + this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); + } + }; + + Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); + + if (isLastName) { + this.emitComments(moduleDecl, true); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + + if (moduleDecl.stringLiteral) { + this.moduleName = moduleDecl.stringLiteral.valueText(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + } else { + this.moduleName = moduleName.text(); + } + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleName); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleName); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + + this.moduleName = this.getModuleName(pullDecl); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(moduleName.text()); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + if (moduleName === moduleDecl.stringLiteral) { + this.emitList(moduleDecl.moduleElements); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + var nameIndex = moduleNames.indexOf(moduleName); + TypeScript.Debug.assert(nameIndex >= 0); + + if (isLastName) { + this.emitList(moduleDecl.moduleElements); + } else { + this.emitIndent(); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); + this.writeLineToOutput(""); + } + } + + this.moduleName = moduleName.text(); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + + if (isLastName) { + this.emitComments(moduleDecl, false); + } + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.propertyName.text(); + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput(']'); + + if (varDecl.equalsValueClause) { + this.emit(varDecl.equalsValueClause); + } else if (pullDecl.constantValue !== null) { + this.writeToOutput(' = '); + this.writeToOutput(pullDecl.constantValue.toString()); + } else { + this.writeToOutput(' = null'); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitElementAccessExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("["); + this.emit(expression.argumentExpression); + this.writeToOutput("]"); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = true; + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(arrowFunction); + + var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); + this.pushDecl(pullDecl); + + this.emitComments(arrowFunction, true); + + this.recordSourceMappingStart(arrowFunction); + this.writeToOutput("function "); + this.writeToOutput("("); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); + + this.recordSourceMappingEnd(arrowFunction); + + this.recordSourceMappingEnd(arrowFunction); + + this.emitComments(arrowFunction, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConstructor = function (funcDecl) { + if (!funcDecl.block) { + return; + } + var temp = this.setContainer(4 /* Constructor */); + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + this.writeToOutput(this.thisClassNode.identifier.text()); + this.writeToOutput("("); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart("constructor"); + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(parameters); + this.emitRestParameterInitializer(parameters); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + this.emitConstructorStatements(funcDecl); + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + }; + + Emitter.prototype.emitGetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("get "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitSetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("set "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitFunctionExpression = function (funcDecl) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + this.writeToOutput(funcDecl.identifier.text()); + this.recordSourceMappingEnd(funcDecl.identifier); + } + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (funcDecl.block === null) { + return; + } + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier.text(); + + this.recordSourceMappingStart(funcDecl); + + var printName = funcDecl.identifier !== null; + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (printName) { + var id = funcDecl.identifier.text(); + if (id) { + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + } + this.writeToOutput(id); + if (funcDecl.identifier) { + this.recordSourceMappingEnd(funcDecl.identifier); + } + } + } + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + + if (funcDecl.block) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + this.recordSourceMappingStart(this.currentVariableDeclaration); + if (varDecl.equalsValueClause) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + this.emitJavascript(varDecl.equalsValueClause, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.currentVariableDeclaration) { + this.writeToOutput("var "); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + + this.emitComments(declaration, true); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; + if (!isAmbientWithoutInit) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.currentVariableDeclaration = declaration; + + for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { + var declarator = declaration.declarators.nonSeparatorAt(i); + + if (i > 0) { + this.writeToOutput(", "); + } + + this.emit(declarator); + } + this.currentVariableDeclaration = prevVariableDeclaration; + + this.recordSourceMappingEnd(declaration); + } + + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { + TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); + + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + + if (quotedOrNumber) { + this.writeToOutput("this["); + } else { + this.writeToOutput("this."); + } + + this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); + + if (quotedOrNumber) { + this.writeToOutput("]"); + } + + if (varDecl.variableDeclarator.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.variableDeclarator.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(this.currentVariableDeclaration); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.propertyName.text(); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); + + if (parentIsModule) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + + if (varDecl.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.currentVariableDeclaration = undefined; + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { + var decl = pullSymbol.getDeclarations()[0]; + var parentDecl = decl.getParentDecl(); + var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; + + var enclosingContextDeclPath = this.declStack; + var commonNodeIndex = -1; + + if (enclosingContextDeclPath.length) { + for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { + var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; + for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { + var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; + if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { + commonNodeIndex = i; + break; + } + } + + if (commonNodeIndex >= 0) { + break; + } + } + } + + var startingIndex = symbolContainerDeclPath.length - 1; + for (var i = startingIndex - 1; i > commonNodeIndex; i--) { + if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { + startingIndex = i; + } else { + break; + } + } + return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; + }; + + Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { + for (var i = startingIndex; i <= lastIndex; i++) { + if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.getModuleName(declPath[i], true) + "."); + } + } + }; + + Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { + var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); + var potentialDeclPath = declPathInfo.potentialPath; + var startingIndex = declPathInfo.startingIndex; + + this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); + }; + + Emitter.prototype.getSymbolForEmit = function (ast) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol === symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (name.text().length > 0) { + var symbolForEmit = this.getSymbolForEmit(name); + var pullSymbol = symbolForEmit.symbol; + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = symbolForEmit.aliasSymbol; + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } + } + } + + this.writeToOutput(name.text()); + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var nameIndex = -1; + if (name) { + if (this.sourceMapper.currentNameIndex.length > 0) { + var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { + break; + } + } + + if (nameIndex === -1) { + nameIndex = this.sourceMapper.names.length; + this.sourceMapper.names.push(name); + } + } + this.sourceMapper.currentNameIndex.push(nameIndex); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (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; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap(); + lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); + + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + this.sourceMapper.increaseMappingLevel(ast); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); + + this.sourceMapper.decreaseMappingLevel(ast); + } + }; + + Emitter.prototype.getOutputFiles = function () { + var result = []; + if (this.sourceMapper !== null) { + this.sourceMapper.emitSourceMapping(); + result.push(this.sourceMapper.getOutputFile()); + } + + result.push(this.outfile.getOutputFile()); + return result; + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = getLastConstructor(this.thisClassNode); + + 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(); + this.recordSourceMappingStart(parameter); + this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); + this.writeToOutput(" = "); + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(parameter); + } + } + } + + for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { + if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = this.thisClassNode.classElements.childAt(i); + if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitIndent(); + this.emitMemberVariableDeclaration(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.isOnSameLine = function (pos1, pos2) { + var lineMap = this.document.lineMap(); + return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); + }; + + Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { + if (list === null || list.nonSeparatorCount() === 0) { + return; + } + + var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); + + if (preserveNewLines) { + this.indenter.increaseIndent(); + } + + if (startLine) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(buffer); + } + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + var emitNode = list.nonSeparatorAt(i); + + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); + if (startLine) { + this.writeLineToOutput(","); + } else { + this.writeToOutput(", "); + } + } + } + + if (preserveNewLines) { + this.indenter.decreaseIndent(); + } + + if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(buffer); + } + }; + + Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.nonSeparatorAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.kind() === 14 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { + return; + } + + var lineMap = this.document.lineMap(); + var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput("", true); + } + }; + + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); + if (preComments) { + var lineMap = this.document.lineMap(); + + var detachedComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); + var commentLine = lineMap.getLineNumberFromPosition(comment.start()); + + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + detachedComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); + if (astLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { + if (list.childCount() > 0) { + var firstElement = list.childAt(0); + + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); + } + }; + + Emitter.prototype.emitScriptElements = function (sourceUnit) { + var list = sourceUnit.moduleElements; + + this.emitPossibleCopyrightHeaders(sourceUnit); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var node = list.childAt(i); + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(sourceUnit); + + var isExternalModule = this.document.isExternalModule(); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); + if (isNonElidedExternalModule) { + this.recordSourceMappingStart(sourceUnit); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } + + if (isExternalModule) { + var temp = this.setContainer(2 /* DynamicModule */); + + var svModuleName = this.moduleName; + this.moduleName = sourceUnit.fileName(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + this.setExportAssignment(null); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); + + if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { + this.writeCaptureThisStatement(sourceUnit); + } + + this.pushDecl(externalModule); + } + + this.emitList(list, true, i, n); + + if (isExternalModule) { + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + + if (isNonElidedExternalModule) { + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; + var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(sourceUnit); + this.writeLineToOutput(""); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + this.popDecl(externalModule); + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + this.emit(ast); + }; + + Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { + if (funcDecl.kind() !== 139 /* GetAccessor */) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + + this.writeToOutput("Object.defineProperty(" + className); + if (isProto) { + this.writeToOutput(".prototype, "); + } else { + this.writeToOutput(", "); + } + + var functionName = name.text(); + if (TypeScript.isQuoted(functionName)) { + this.writeToOutput(functionName); + } else { + this.writeToOutput('"' + functionName + '"'); + } + + this.writeLineToOutput(", {"); + + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.emitComments(accessors.getter, true); + this.writeToOutput("get: "); + this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.emitComments(accessors.setter, true); + this.writeToOutput("set: "); + this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.identifier.text(); + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var baseTypeReference = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); + } + + this.emitIndent(); + + var constrDecl = getLastConstructor(classDecl); + + if (constrDecl) { + this.emit(constrDecl); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.emitJavascript(baseTypeReference, false); + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 139 /* GetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var getter = memberDecl; + this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 140 /* SetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var setter = memberDecl; + this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { + var memberFunction = memberDecl; + + if (memberFunction.block) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + + this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); + lastEmittedMember = memberDecl; + } + } + } + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = memberDecl; + + if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); + } else { + this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); + } + + this.emit(varDecl.variableDeclarator.equalsValueClause); + + this.recordSourceMappingEnd(varDecl); + this.writeLineToOutput(";"); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + var functionName = funcDecl.propertyName.text(); + + this.writeToOutput(classDecl.identifier.text()); + + if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + this.writeToOutput(".prototype"); + } + + if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput("[" + functionName + "] = "); + } else { + this.writeToOutput("." + functionName + " = "); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + + this.writeLineToOutput(";"); + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + + if (moduleElement.kind() === 130 /* ModuleDeclaration */) { + var moduleAST = moduleElement; + + if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { + return true; + } + } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (sourceUnit) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(sourceUnit)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitThis = function () { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.kind() === 146 /* Block */) { + this.emit(node); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitLiteralExpression = function (expression) { + switch (expression.kind()) { + case 32 /* NullKeyword */: + this.writeToOutputWithSourceMapRecord("null", expression); + break; + case 24 /* FalseKeyword */: + this.writeToOutputWithSourceMapRecord("false", expression); + break; + case 37 /* TrueKeyword */: + this.writeToOutputWithSourceMapRecord("true", expression); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + Emitter.prototype.emitThisExpression = function (expression) { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutputWithSourceMapRecord("_this", expression); + } else { + this.writeToOutputWithSourceMapRecord("this", expression); + } + }; + + Emitter.prototype.emitSuperExpression = function (expression) { + this.writeToOutputWithSourceMapRecord("_super.prototype", expression); + }; + + Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { + if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { + this.emit(parenthesizedExpression.expression); + } else { + this.recordSourceMappingStart(parenthesizedExpression); + this.writeToOutput("("); + this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); + this.emit(parenthesizedExpression.expression); + this.writeToOutput(")"); + this.recordSourceMappingEnd(parenthesizedExpression); + } + }; + + Emitter.prototype.emitCastExpression = function (expression) { + this.emit(expression.expression); + }; + + Emitter.prototype.emitPrefixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 167 /* LogicalNotExpression */: + this.writeToOutput("!"); + this.emit(expression.operand); + break; + case 166 /* BitwiseNotExpression */: + this.writeToOutput("~"); + this.emit(expression.operand); + break; + case 165 /* NegateExpression */: + this.writeToOutput("-"); + if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 164 /* PlusExpression */: + this.writeToOutput("+"); + if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 168 /* PreIncrementExpression */: + this.writeToOutput("++"); + this.emit(expression.operand); + break; + case 169 /* PreDecrementExpression */: + this.writeToOutput("--"); + this.emit(expression.operand); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitPostfixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 210 /* PostIncrementExpression */: + this.emit(expression.operand); + this.writeToOutput("++"); + break; + case 211 /* PostDecrementExpression */: + this.emit(expression.operand); + this.writeToOutput("--"); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitTypeOfExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("typeof "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDeleteExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("delete "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitVoidExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("void "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { + var memberExpressionNodeType = expression.expression.kind(); + + 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 */) { + return this.canEmitDottedNameMemberAccessExpression(expression.expression); + } + + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { + this.recordSourceMappingStart(expression); + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { + this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); + } else { + this.emitComments(expression.expression, true); + this.recordSourceMappingStart(expression.expression); + + this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); + + this.writeToOutput(expression.expression.text()); + + this.recordSourceMappingEnd(expression.expression); + this.emitComments(expression.expression, false); + } + + this.writeToOutput("."); + this.emitName(expression.name, false); + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { + this.emitComments(expression, true); + + if (lastIndex - startingIndex < 1) { + startingIndex = lastIndex - 1; + TypeScript.Debug.assert(startingIndex >= 0); + } + + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); + this.emitComments(expression, false); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { + var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; + + var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); + }; + + Emitter.prototype.emitMemberAccessExpression = function (expression) { + if (!this.tryEmitConstant(expression)) { + if (this.canEmitDottedNameMemberAccessExpression(expression)) { + this.emitDottedNameMemberAccessExpression(expression); + } else { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("."); + this.emitName(expression.name, false); + this.recordSourceMappingEnd(expression); + } + } + }; + + Emitter.prototype.emitQualifiedName = function (name) { + this.recordSourceMappingStart(name); + + this.emit(name.left); + this.writeToOutput("."); + this.emitName(name.right, false); + + this.recordSourceMappingEnd(name); + }; + + Emitter.prototype.emitBinaryExpression = function (expression) { + this.recordSourceMappingStart(expression); + switch (expression.kind()) { + case 173 /* CommaExpression */: + this.emit(expression.left); + this.writeToOutput(", "); + this.emit(expression.right); + break; + default: { + this.emit(expression.left); + var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); + if (binOp === "instanceof") { + this.writeToOutput(" instanceof "); + } else if (binOp === "in") { + this.writeToOutput(" in "); + } else { + this.writeToOutput(" " + binOp + " "); + } + this.emit(expression.right); + } + } + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimplePropertyAssignment = function (property) { + this.recordSourceMappingStart(property); + this.emit(property.propertyName); + this.writeToOutput(": "); + this.emit(property.expression); + this.recordSourceMappingEnd(property); + }; + + Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { + this.recordSourceMappingStart(funcProp); + + this.emit(funcProp.propertyName); + this.writeToOutput(": "); + + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); + + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + var funcName = funcProp.propertyName; + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcProp); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); + + this.recordSourceMappingEnd(funcProp); + + this.recordSourceMappingEnd(funcProp); + + this.emitComments(funcProp, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConditionalExpression = function (expression) { + this.emit(expression.condition); + this.writeToOutput(" ? "); + this.emit(expression.whenTrue); + this.writeToOutput(" : "); + this.emit(expression.whenFalse); + }; + + Emitter.prototype.emitThrowStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("throw "); + this.emit(statement.expression); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitExpressionStatement = function (statement) { + var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; + + this.recordSourceMappingStart(statement); + if (isArrowExpression) { + this.writeToOutput("("); + } + + this.emit(statement.expression); + + if (isArrowExpression) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitLabeledStatement = function (statement) { + this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); + this.writeLineToOutput(":"); + this.emitJavascript(statement.statement, true); + }; + + Emitter.prototype.emitBlock = function (block) { + this.recordSourceMappingStart(block); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + if (block.statements) { + this.emitList(block.statements); + } + this.emitCommentsArray(block.closeBraceLeadingComments, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(block); + }; + + Emitter.prototype.emitBreakStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("break"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitContinueStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("continue"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitWhileStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("while ("); + this.emit(statement.condition); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitDoStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("do"); + this.emitBlockOrStatement(statement.statement); + this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); + this.writeToOutput('('); + this.emit(statement.condition); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitIfStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("if ("); + this.emit(statement.condition); + this.writeToOutput(")"); + + this.emitBlockOrStatement(statement.statement); + + if (statement.elseClause) { + if (statement.statement.kind() !== 146 /* Block */) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + + this.emit(statement.elseClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitElseClause = function (elseClause) { + if (elseClause.statement.kind() === 147 /* IfStatement */) { + this.writeToOutput("else "); + this.emit(elseClause.statement); + } else { + this.writeToOutput("else"); + this.emitBlockOrStatement(elseClause.statement); + } + }; + + Emitter.prototype.emitReturnStatement = function (statement) { + this.recordSourceMappingStart(statement); + if (statement.expression) { + this.writeToOutput("return "); + this.emit(statement.expression); + } else { + this.writeToOutput("return"); + } + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitForInStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.left) { + this.emit(statement.left); + } else { + this.emit(statement.variableDeclaration); + } + this.writeToOutput(" in "); + this.emit(statement.expression); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitForStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.variableDeclaration) { + this.emit(statement.variableDeclaration); + } else if (statement.initializer) { + this.emit(statement.initializer); + } + + this.writeToOutput("; "); + this.emitJavascript(statement.condition, false); + this.writeToOutput(";"); + if (statement.incrementor) { + this.writeToOutput(" "); + this.emitJavascript(statement.incrementor, false); + } + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitWithStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("with ("); + if (statement.condition) { + this.emit(statement.condition); + } + + this.writeToOutput(")"); + var prevInWithBlock = this.inWithBlock; + this.inWithBlock = true; + this.emitBlockOrStatement(statement.statement); + this.inWithBlock = prevInWithBlock; + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitSwitchStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("switch ("); + this.emit(statement.expression); + this.recordSourceMappingStart(statement.closeParenToken); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement.closeParenToken); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + this.emitList(statement.switchClauses, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCaseSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("case "); + this.emit(clause.expression); + this.writeToOutput(":"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitSwitchClauseBody = function (body) { + if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { + this.emit(body.childAt(0)); + this.writeLineToOutput(""); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emit(body); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitDefaultSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("default:"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitTryStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("try "); + this.emit(statement.block); + this.emitJavascript(statement.catchClause, false); + + if (statement.finallyClause) { + this.emit(statement.finallyClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCatchClause = function (clause) { + this.writeToOutput(" "); + this.recordSourceMappingStart(clause); + this.writeToOutput("catch ("); + this.emit(clause.identifier); + this.writeToOutput(")"); + this.emit(clause.block); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitFinallyClause = function (clause) { + this.writeToOutput(" finally"); + this.emit(clause.block); + }; + + Emitter.prototype.emitDebuggerStatement = function (statement) { + this.writeToOutputWithSourceMapRecord("debugger", statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitNumericLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitRegularExpressionLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitStringLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitEqualsValueClause = function (clause) { + this.writeToOutput(" = "); + this.emit(clause.value); + }; + + Emitter.prototype.emitParameter = function (parameter) { + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); + }; + + Emitter.prototype.emitConstructorDeclaration = function (declaration) { + if (declaration.block) { + this.emitConstructor(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { + return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); + }; + + Emitter.prototype.emitFunctionDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { + this.emitFunction(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.emitSourceUnit = function (sourceUnit) { + if (!this.document.isDeclareFile()) { + var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + this.pushDecl(pullDecl); + this.emitScriptElements(sourceUnit); + this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); + } + }; + + Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); + }; + + Emitter.prototype.emitEnumDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { + this.emitComments(declaration, true); + this.emitEnum(declaration); + this.emitComments(declaration, false); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); + }; + + Emitter.prototype.emitModuleDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { + this.emitModuleDeclarationWorker(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); + }; + + Emitter.prototype.emitClassDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + this.emitClass(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { + return declaration.preComments() !== null; + }; + + Emitter.prototype.emitInterfaceDeclaration = function (declaration) { + this.emitComments(declaration, true, true); + }; + + Emitter.prototype.firstVariableDeclarator = function (statement) { + return statement.declaration.declarators.nonSeparatorAt(0); + }; + + Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { + return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; + }; + + Emitter.prototype.shouldEmitVariableStatement = function (statement) { + return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); + }; + + Emitter.prototype.emitVariableStatement = function (statement) { + if (this.isNotAmbientOrHasInitializer(statement)) { + this.emitComments(statement, true); + this.emit(statement.declaration); + this.writeToOutput(";"); + this.emitComments(statement, false); + } else { + this.emitComments(statement, true, true); + } + }; + + Emitter.prototype.emitGenericType = function (type) { + this.emit(type.name); + }; + + Emitter.prototype.shouldEmit = function (ast) { + if (!ast) { + return false; + } + + switch (ast.kind()) { + case 133 /* ImportDeclaration */: + return this.shouldEmitImportDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.shouldEmitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.shouldEmitInterfaceDeclaration(ast); + case 129 /* FunctionDeclaration */: + return this.shouldEmitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.shouldEmitModuleDeclaration(ast); + case 148 /* VariableStatement */: + return this.shouldEmitVariableStatement(ast); + case 223 /* OmittedExpression */: + return false; + case 132 /* EnumDeclaration */: + return this.shouldEmitEnumDeclaration(ast); + } + + return true; + }; + + Emitter.prototype.emit = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 2 /* SeparatedList */: + return this.emitSeparatedList(ast); + case 1 /* List */: + return this.emitList(ast); + case 120 /* SourceUnit */: + return this.emitSourceUnit(ast); + case 133 /* ImportDeclaration */: + return this.emitImportDeclaration(ast); + case 134 /* ExportAssignment */: + return this.setExportAssignment(ast); + case 131 /* ClassDeclaration */: + return this.emitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitInterfaceDeclaration(ast); + case 11 /* IdentifierName */: + return this.emitName(ast, true); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast); + case 219 /* SimpleArrowFunctionExpression */: + return this.emitSimpleArrowFunctionExpression(ast); + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.emitParenthesizedArrowFunctionExpression(ast); + case 129 /* FunctionDeclaration */: + return this.emitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitModuleDeclaration(ast); + case 224 /* VariableDeclaration */: + return this.emitVariableDeclaration(ast); + case 126 /* GenericType */: + return this.emitGenericType(ast); + case 137 /* ConstructorDeclaration */: + return this.emitConstructorDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitEnumDeclaration(ast); + case 243 /* EnumElement */: + return this.emitEnumElement(ast); + case 222 /* FunctionExpression */: + return this.emitFunctionExpression(ast); + case 148 /* VariableStatement */: + return this.emitVariableStatement(ast); + } + + this.emitComments(ast, true); + this.emitWorker(ast); + this.emitComments(ast, false); + }; + + Emitter.prototype.emitWorker = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 13 /* NumericLiteral */: + return this.emitNumericLiteral(ast); + case 12 /* RegularExpressionLiteral */: + return this.emitRegularExpressionLiteral(ast); + case 14 /* StringLiteral */: + return this.emitStringLiteral(ast); + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 37 /* TrueKeyword */: + return this.emitLiteralExpression(ast); + case 35 /* ThisKeyword */: + return this.emitThisExpression(ast); + case 50 /* SuperKeyword */: + return this.emitSuperExpression(ast); + case 217 /* ParenthesizedExpression */: + return this.emitParenthesizedExpression(ast); + case 214 /* ArrayLiteralExpression */: + return this.emitArrayLiteralExpression(ast); + case 211 /* PostDecrementExpression */: + case 210 /* PostIncrementExpression */: + return this.emitPostfixUnaryExpression(ast); + case 167 /* LogicalNotExpression */: + case 166 /* BitwiseNotExpression */: + case 165 /* NegateExpression */: + case 164 /* PlusExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.emitPrefixUnaryExpression(ast); + case 213 /* InvocationExpression */: + return this.emitInvocationExpression(ast); + case 221 /* ElementAccessExpression */: + return this.emitElementAccessExpression(ast); + case 212 /* MemberAccessExpression */: + return this.emitMemberAccessExpression(ast); + case 121 /* QualifiedName */: + return this.emitQualifiedName(ast); + case 173 /* CommaExpression */: + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 187 /* LogicalOrExpression */: + case 188 /* LogicalAndExpression */: + case 189 /* BitwiseOrExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 191 /* BitwiseAndExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return this.emitBinaryExpression(ast); + case 186 /* ConditionalExpression */: + return this.emitConditionalExpression(ast); + case 232 /* EqualsValueClause */: + return this.emitEqualsValueClause(ast); + case 242 /* Parameter */: + return this.emitParameter(ast); + case 146 /* Block */: + return this.emitBlock(ast); + case 235 /* ElseClause */: + return this.emitElseClause(ast); + case 147 /* IfStatement */: + return this.emitIfStatement(ast); + case 149 /* ExpressionStatement */: + return this.emitExpressionStatement(ast); + case 139 /* GetAccessor */: + return this.emitGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitSetAccessor(ast); + case 157 /* ThrowStatement */: + return this.emitThrowStatement(ast); + case 150 /* ReturnStatement */: + return this.emitReturnStatement(ast); + case 216 /* ObjectCreationExpression */: + return this.emitObjectCreationExpression(ast); + case 151 /* SwitchStatement */: + return this.emitSwitchStatement(ast); + case 233 /* CaseSwitchClause */: + return this.emitCaseSwitchClause(ast); + case 234 /* DefaultSwitchClause */: + return this.emitDefaultSwitchClause(ast); + case 152 /* BreakStatement */: + return this.emitBreakStatement(ast); + case 153 /* ContinueStatement */: + return this.emitContinueStatement(ast); + case 154 /* ForStatement */: + return this.emitForStatement(ast); + case 155 /* ForInStatement */: + return this.emitForInStatement(ast); + case 158 /* WhileStatement */: + return this.emitWhileStatement(ast); + case 163 /* WithStatement */: + return this.emitWithStatement(ast); + case 220 /* CastExpression */: + return this.emitCastExpression(ast); + case 215 /* ObjectLiteralExpression */: + return this.emitObjectLiteralExpression(ast); + case 240 /* SimplePropertyAssignment */: + return this.emitSimplePropertyAssignment(ast); + case 241 /* FunctionPropertyAssignment */: + return this.emitFunctionPropertyAssignment(ast); + case 156 /* EmptyStatement */: + return this.writeToOutputWithSourceMapRecord(";", ast); + case 159 /* TryStatement */: + return this.emitTryStatement(ast); + case 236 /* CatchClause */: + return this.emitCatchClause(ast); + case 237 /* FinallyClause */: + return this.emitFinallyClause(ast); + case 160 /* LabeledStatement */: + return this.emitLabeledStatement(ast); + case 161 /* DoStatement */: + return this.emitDoStatement(ast); + case 171 /* TypeOfExpression */: + return this.emitTypeOfExpression(ast); + case 170 /* DeleteExpression */: + return this.emitDeleteExpression(ast); + case 172 /* VoidExpression */: + return this.emitVoidExpression(ast); + case 162 /* DebuggerStatement */: + return this.emitDebuggerStatement(ast); + } + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; + + function getLastConstructor(classDecl) { + return classDecl.classElements.lastOrDefault(function (e) { + return e.kind() === 137 /* ConstructorDeclaration */; + }); + } + TypeScript.getLastConstructor = getLastConstructor; + + function getTrimmedTextLines(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + return comment.fullText().split("\n").map(function (s) { + return s.trim(); + }); + } else { + return [comment.fullText().trim()]; + } + } + TypeScript.getTrimmedTextLines = getTrimmedTextLines; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += memberName.text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function stripStartAndEndQuotes(str) { + var firstCharCode = str && str.charCodeAt(0); + if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + return str.substring(1, str.length - 1); + } + + return str; + } + TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; + + function isSingleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isDoubleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; + } + TypeScript.isDoubleQuoted = isDoubleQuoted; + + function isQuoted(str) { + return isDoubleQuoted(str) || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function changePathToDTS(modPath) { + return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + function convertToDirectoryPath(dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + } + TypeScript.convertToDirectoryPath = convertToDirectoryPath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + function isNoDefaultLibMatch(comment) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + return isNoDefaultLibRegex.exec(comment); + } + + TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; + + function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { + var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } + } + } + + return null; + } + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + var start = new Date().getTime(); + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionScanImportsTime += totalTime; + } + + function processTripleSlashDirectives(fileName, lineMap, firstToken) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + var diagnostics = []; + var referencedFiles = []; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + var isNoDefaultLib = isNoDefaultLibMatch(triviaText); + if (isNoDefaultLib) { + noDefaultLib = isNoDefaultLib[3] === "true"; + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; + } + + function preProcessFile(fileName, sourceText, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); + + scannerDiagnostics.length = 0; + return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); + } + TypeScript.getParseOptions = getParseOptions; + + function getReferencedFiles(fileName, sourceText) { + return preProcessFile(fileName, sourceText, false).referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, lineMap, position, length, isImported) { + this.filePath = filePath; + this.lineMap = lineMap; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { + this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this.inputFileNames = inputFileNames; + this.host = host; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { + var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var _this = this; + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); + this.inputFileNames.forEach(function (fileName) { + return _this.resolveIncludedFile(fileName, referenceLocation, result); + }); + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(tsFile)) { + normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + var start = new Date().getTime(); + + do { + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var _this = this; + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var start = new Date().getTime(); + var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionIOTime += totalTime; + + var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); + resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); + var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + }); + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(name, writeByteOrderMark, outputFileType) { + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.outputFileType = outputFileType; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + }; + + TextWriter.prototype.getOutputFile = function () { + return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.emittedReferencePaths = false; + this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); + } + DeclarationEmitter.prototype.getOutputFile = function () { + return this.declFile.getOutputFile(); + }; + + DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { + this.emitDeclarationsForSourceUnit(sourceUnit); + }; + + DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.emitDeclarationsForAST(list.childAt(i)); + } + }; + + DeclarationEmitter.prototype.emitSeparatedList = function (list) { + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.emitDeclarationsForAST(list.nonSeparatorAt(i)); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { + switch (ast.kind()) { + case 148 /* VariableStatement */: + return this.emitDeclarationsForVariableStatement(ast); + case 141 /* PropertySignature */: + return this.emitPropertySignature(ast); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast, true, true); + case 136 /* MemberVariableDeclaration */: + return this.emitDeclarationsForMemberVariableDeclaration(ast); + case 137 /* ConstructorDeclaration */: + return this.emitDeclarationsForConstructorDeclaration(ast); + case 139 /* GetAccessor */: + return this.emitDeclarationsForGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitDeclarationsForSetAccessor(ast); + case 138 /* IndexMemberDeclaration */: + return this.emitIndexMemberDeclaration(ast); + case 144 /* IndexSignature */: + return this.emitIndexSignature(ast); + case 142 /* CallSignature */: + return this.emitCallSignature(ast); + case 143 /* ConstructSignature */: + return this.emitConstructSignature(ast); + case 145 /* MethodSignature */: + return this.emitMethodSignature(ast); + case 129 /* FunctionDeclaration */: + return this.emitDeclarationsForFunctionDeclaration(ast); + case 135 /* MemberFunctionDeclaration */: + return this.emitMemberFunctionDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.emitDeclarationsForClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitDeclarationsForInterfaceDeclaration(ast); + case 133 /* ImportDeclaration */: + return this.emitDeclarationsForImportDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitDeclarationsForModuleDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitDeclarationsForEnumDeclaration(ast); + case 134 /* ExportAssignment */: + return this.emitDeclarationsForExportAssignment(ast); + } + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { + var container = this.getEnclosingContainer(declAST); + if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { + var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); + var container = this.getEnclosingContainer(declAST); + + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { + container = this.getEnclosingContainer(container); + } + + var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); + + if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { + result += "declare "; + } + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { + this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { + var declarationContainerAst = this.getEnclosingContainer(ast); + + var start = new Date().getTime(); + var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); + + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = TypeScript.getTrimmedTextLines(comment); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.semanticInfoChain.getDeclForAST(boundDecl); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = pullSymbol.type; + TypeScript.Debug.assert(type); + + this.declFile.Write(": "); + this.emitTypeSignature(boundDecl, type); + }; + + DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { + this.emitDeclarationComments(varDecl); + this.emitIndent(); + this.declFile.Write(varDecl.propertyName.text()); + if (varDecl.questionToken) { + this.declFile.Write("?"); + } + + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + if (isFirstVarInList) { + this.emitDeclFlags(varDecl, "var"); + } + + this.declFile.Write(varDecl.propertyName.text()); + + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + if (isLastVarInList) { + this.declFile.WriteLine(";"); + } else { + this.declFile.Write(", "); + } + } + }; + + DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { + if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } + this.declFile.Write("static "); + } else { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } else { + this.declFile.Write("public "); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(varDecl.modifiers); + ; + + this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); + + if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + this.declFile.WriteLine(";"); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { + this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); + }; + + 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); + } + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(id.text()); + if (isOptional) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (!isPrivate) { + this.emitTypeOfVariableDeclaratorOrParameter(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("constructor"); + + this.declFile.Write("("); + 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.ASTHelpers.parametersFromParameterList(parameterList)); + this.declFile.Write(")"); + }; + + DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { + var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); + var argsLen = parameterList.length; + if (hasLastParameterRestParameter) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + + if (hasLastParameterRestParameter) { + if (parameterList.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + var index = parameterList.length - 1; + this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); + } + }; + + DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitDeclFlags(funcDecl, "function"); + var id = funcDecl.propertyName.text(); + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); + + this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); + + if (!isPrivate) { + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + this.emitDeclarationComments(funcDecl); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); + + this.emitIndent(); + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("new"); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write(funcDecl.propertyName.text()); + if (funcDecl.questionToken) { + this.declFile.Write("? "); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + if (funcDecl.block) { + var funcTypeSymbol = funcSymbol.type; + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + var id = funcDecl.identifier.text(); + this.emitDeclFlags(funcDecl, "function"); + if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { + this.declFile.Write(id); + } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { + this.declFile.Write("new"); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { + this.emitDeclarationsForAST(funcDecl.indexSignature); + }; + + DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("["); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); + this.declFile.Write("]"); + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { + if (bases && (bases.nonSeparatorCount() > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.nonSeparatorCount(); + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + var base = bases.nonSeparatorAt(i); + var baseType = this.semanticInfoChain.getSymbolForAST(base); + this.emitTypeSignature(base, baseType); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); + } + if (accessors.setter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { + return; + } + + var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); + this.emitAccessorDeclarationComments(funcDecl); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(modifiers); + this.declFile.Write(name.text()); + if (!isPrivate) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(funcDecl, type); + } + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } + + 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(";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { + if (!this.canEmitDeclarations(classDecl)) { + return; + } + + var className = classDecl.identifier.text(); + this.emitDeclarationComments(classDecl); + var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.emitDeclFlags(classDecl, "class"); + this.declFile.Write(className); + + this.emitTypeParameters(classDecl.typeParameterList); + this.emitHeritageClauses(classDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + var constructorDecl = TypeScript.getLastConstructor(classDecl); + if (constructorDecl) { + this.emitClassMembersFromConstructorDefinition(constructorDecl); + } + + this.emitDeclarationsForList(classDecl.classElements); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { + if (clauses) { + for (var i = 0, n = clauses.childCount(); i < n; i++) { + this.emitHeritageClause(clauses.childAt(i)); + } + } + }; + + DeclarationEmitter.prototype.emitHeritageClause = function (clause) { + this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); + }; + + DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getEnclosingContainer(typeParams); + + var start = new Date().getTime(); + var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArgumentsOrTypeParameters(); + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { + if (!this.canEmitDeclarations(interfaceDecl)) { + return; + } + + var interfaceName = interfaceDecl.identifier.text(); + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); + this.emitDeclFlags(interfaceDecl, "interface"); + this.declFile.Write(interfaceName); + + this.emitTypeParameters(interfaceDecl.typeParameterList); + this.emitHeritageClauses(interfaceDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + + this.emitSeparatedList(interfaceDecl.body.typeMembers); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.identifier.text() + " = "); + if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); + } else { + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclFlags(moduleDecl, "enum"); + this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.enumElements.nonSeparatorCount(); + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); + var enumElement = memberDecl; + var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); + this.emitDeclarationComments(enumElement); + this.emitIndent(); + this.declFile.Write(enumElement.propertyName.text()); + if (enumElementDecl.constantValue !== null) { + this.declFile.Write(" = " + enumElementDecl.constantValue); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclarationComments(moduleDecl); + + var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); + this.emitDeclFlags(name, "module"); + + if (moduleDecl.stringLiteral) { + this.declFile.Write(moduleDecl.stringLiteral.text()); + } else { + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); + } + + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + + this.emitDeclarationsForList(moduleDecl.moduleElements); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.identifier.text()); + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { + if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { + return reference; + } + + var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); + var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); + return resolvedReferencePath; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.document.emitToOwnOutputFile()) { + var scriptReferences = this.document.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { + documents = documents.concat(document); + + if (!document.isDeclareFile() && document.isExternalModule()) { + addedGlobalDocument = true; + } + } + } + } else { + var fileNames = this.compiler.fileNames(); + for (var i = 0; i < fileNames.length; i++) { + var doc = this.compiler.getDocument(fileNames[i]); + if (!doc.isDeclareFile() && !doc.isExternalModule()) { + var scriptReferences = doc.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.isDeclareFile() || document.isExternalModule())) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] === document) { + break; + } + } + + if (k === documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.isDeclareFile()) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { + this.emitReferencePaths(sourceUnit); + this.emitDeclarationsForList(sourceUnit.moduleElements); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] !== array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + 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, createFileLog) { + this._propagateEnumConstants = propagateEnumConstants; + this._removeComments = removeComments; + this._watch = watch; + this._noResolve = noResolve; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + this._noImplicitAny = noImplicitAny; + this._noLib = noLib; + this._codeGenTarget = codeGenTarget; + this._moduleGenTarget = moduleGenTarget; + this._outFileOption = outFileOption; + this._outDirOption = outDirOption; + this._mapSourceFiles = mapSourceFiles; + this._mapRoot = mapRoot; + this._sourceRoot = sourceRoot; + this._generateDeclarationFiles = generateDeclarationFiles; + this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this._gatherDiagnostics = gatherDiagnostics; + this._codepage = codepage; + this._createFileLog = createFileLog; + } + ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { + return this._propagateEnumConstants; + }; + ImmutableCompilationSettings.prototype.removeComments = function () { + return this._removeComments; + }; + ImmutableCompilationSettings.prototype.watch = function () { + return this._watch; + }; + ImmutableCompilationSettings.prototype.noResolve = function () { + return this._noResolve; + }; + ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + ImmutableCompilationSettings.prototype.noImplicitAny = function () { + return this._noImplicitAny; + }; + ImmutableCompilationSettings.prototype.noLib = function () { + return this._noLib; + }; + ImmutableCompilationSettings.prototype.codeGenTarget = function () { + return this._codeGenTarget; + }; + ImmutableCompilationSettings.prototype.moduleGenTarget = function () { + return this._moduleGenTarget; + }; + ImmutableCompilationSettings.prototype.outFileOption = function () { + return this._outFileOption; + }; + ImmutableCompilationSettings.prototype.outDirOption = function () { + return this._outDirOption; + }; + ImmutableCompilationSettings.prototype.mapSourceFiles = function () { + return this._mapSourceFiles; + }; + ImmutableCompilationSettings.prototype.mapRoot = function () { + return this._mapRoot; + }; + ImmutableCompilationSettings.prototype.sourceRoot = function () { + return this._sourceRoot; + }; + ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { + return this._generateDeclarationFiles; + }; + ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { + return this._useCaseSensitiveFileResolution; + }; + ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { + return this._gatherDiagnostics; + }; + ImmutableCompilationSettings.prototype.codepage = function () { + return this._codepage; + }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; + + ImmutableCompilationSettings.defaultSettings = function () { + if (!ImmutableCompilationSettings._defaultSettings) { + ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); + } + + return ImmutableCompilationSettings._defaultSettings; + }; + + 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, 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, "_")) { + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; + } + } + + return result; + }; + return ImmutableCompilationSettings; + })(); + TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; + + PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + function hasModifier(modifiers, flag) { + for (var i = 0, n = modifiers.length; i < n; i++) { + if (TypeScript.hasFlag(modifiers[i], flag)) { + return true; + } + } + + return false; + } + TypeScript.hasModifier = hasModifier; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; + PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; + + 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.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"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var pullDeclID = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + 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; + this.childDeclTypeParameterCache = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.semanticInfoChain = semanticInfoChain; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + } + PullDecl.prototype.fileName = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentPath = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.isExternalModule = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getEnclosingDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { + var decl = this; + while (decl) { + switch (decl.kind) { + default: + return decl; + case 512 /* Variable */: + case 8192 /* TypeParameter */: + case 2048 /* Parameter */: + case 128 /* TypeAlias */: + case 67108864 /* EnumMember */: + } + + decl = decl.getParentDecl(); + } + + TypeScript.Debug.fail(); + }; + + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.semanticInfoChain.setSymbolForDecl(this, symbol); + }; + + 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 */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.semanticInfoChain.getSymbolForDecl(this); + }; + + PullDecl.prototype.hasSymbol = function () { + var symbol = this.semanticInfoChain.getSymbolForDecl(this); + return !!symbol; + }; + + PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); + }; + + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); + }; + + PullDecl.prototype.hasSignatureSymbol = function () { + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); + return !!signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; + }; + + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + if (declKind === 8192 /* TypeParameter */) { + if (!this.childDeclTypeParameterCache) { + this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeParameterCache; + } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { + if (!this.childDeclNamespaceCache) { + this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclNamespaceCache; + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { + if (!this.childDeclTypeCache) { + this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeCache; + } else { + if (!this.childDeclValueCache) { + this.childDeclValueCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclValueCache; + } + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + + if (!(childDecl.kind & 7340032 /* SomeSignature */)) { + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + } + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; + } else if (searchKind & 164 /* SomeContainer */) { + cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; + } else { + cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + if (!this.declGroups) { + this.declGroups = TypeScript.createIntrinsicsObject(); + } + + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + if (this.declGroups) { + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (declGroups === null) { + declGroups = []; + } + + declGroups.push(this.declGroups[declName].getDecls()); + } + } + } + + return declGroups || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.hasBeenBound = function () { + return this.hasSymbol() || this.hasSignatureSymbol(); + }; + + PullDecl.prototype.isSynthesized = function () { + return false; + }; + + PullDecl.prototype.ast = function () { + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var RootPullDecl = (function (_super) { + __extends(RootPullDecl, _super); + 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; + } + RootPullDecl.prototype.fileName = function () { + return this._fileName; + }; + + RootPullDecl.prototype.getParentPath = function () { + return [this]; + }; + + RootPullDecl.prototype.getParentDecl = function () { + return null; + }; + + RootPullDecl.prototype.isExternalModule = function () { + return this._isExternalModule; + }; + + 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, addToParent) { + if (typeof addToParent === "undefined") { addToParent = true; } + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); + this.parentDecl = null; + this.parentPath = null; + + this.parentDecl = parentDecl; + 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._rootDecl.fileName(); + }; + + NormalPullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + NormalPullDecl.prototype.getParentPath = function () { + if (!this.parentPath) { + var path = [this]; + var parentDecl = this.parentDecl; + + while (parentDecl) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { + path.unshift(parentDecl); + } + + parentDecl = parentDecl.getParentDecl(); + } + + this.parentPath = path; + } + + return this.parentPath; + }; + + NormalPullDecl.prototype.isExternalModule = function () { + return false; + }; + + 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) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); + this.constantValue = null; + } + return PullEnumElementDecl; + })(NormalPullDecl); + TypeScript.PullEnumElementDecl = PullEnumElementDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { + if (typeof displayName === "undefined") { displayName = ""; } + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(NormalPullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullSynthesizedDecl = (function (_super) { + __extends(PullSynthesizedDecl, _super); + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; + } + PullSynthesizedDecl.prototype.isSynthesized = function () { + return true; + }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; + return PullSynthesizedDecl; + })(NormalPullDecl); + TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = ++TypeScript.pullSymbolID; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.rootSymbol = null; + this._enclosingSignature = null; + this._docComments = null; + this.isPrinting = false; + this.name = name; + this.kind = declKind; + } + PullSymbol.prototype.isAny = function () { + return false; + }; + + PullSymbol.prototype.isType = function () { + return (this.kind & 58728795 /* SomeType */) !== 0; + }; + + PullSymbol.prototype.isTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & 7340032 /* SomeSignature */) !== 0; + }; + + PullSymbol.prototype.isArrayNamedTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { + if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } + if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } + var scopeDeclarations = scopeSymbol.getDeclarations(); + var scopeSymbolAliasesToLookIn = []; + + for (var i = 0; i < scopeDeclarations.length; i++) { + var scopeDecl = scopeDeclarations[i]; + if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { + visitedScopeDeclarations.push(scopeDecl); + + var childDecls = scopeDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { + var symbol = childDecl.getSymbol(); + + if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { + aliasSymbols.push(symbol); + return aliasSymbols; + } + + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { + scopeSymbolAliasesToLookIn.push(symbol); + } + } + } + } + } + + for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { + var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; + + aliasSymbols.push(scopeSymbolAlias); + var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); + if (result) { + return result; + } + + aliasSymbols.pop(); + } + + return null; + }; + + PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); + return symbols; + } + + return null; + }; + + PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { + if (aliasSymbol) { + if (aliasSymbol.assignedValue()) { + return false; + } + + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { + return false; + } + + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { + return false; + } + + return true; + } + + return false; + }; + + PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { + if (scopeSymbol) { + 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); + return internalAliases[0]; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { + if (!skipInternalAlias) { + var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); + if (internalAlias) { + return aliasNameGetter(internalAlias); + } + } + + var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); + + if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { + 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 aliasFullName; + } + + return null; + }; + + PullSymbol.prototype._getResolver = function () { + TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); + return this._declarations[0].semanticInfoChain.getResolver(); + }; + + PullSymbol.prototype._resolveDeclaredSymbol = function () { + return this._getResolver().resolveDeclaredSymbol(this); + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getName(); + }); + return aliasName || this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getDisplayName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getDisplayName(); + }, skipInternalAliasName); + if (aliasDisplayName) { + return aliasDisplayName; + } + + var decls = this.getDeclarations(); + var name = decls.length && decls[0].getDisplayName(); + + return (name && name.length) ? name : this.name; + }; + + PullSymbol.prototype.getIsSpecialized = function () { + return false; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + 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; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.hasDeclaration = function (decl) { + if (!this._declarations) { + return false; + } + + return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { + return eachDecl === decl; + }); + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.anyDeclHasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (TypeScript.hasFlag(declarations[i].flags, flag)) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!TypeScript.hasFlag(declarations[i].flags, flag)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = node.getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind === 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + 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 memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { + return true; + } + + var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol) { + return true; + } + } + } + + 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 (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { + return thisPath.slice(0, thisCommonAncestorIndex); + } else { + return thisPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; + var path = this.pathToRoot(); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol === _this ? null : symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { + var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + 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 */) { + var signatures = type.getCallSignatures(); + 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); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + + inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); + + var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); + inIsExternallyVisibleSymbols.pop(); + + return result; + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.rootSymbol) { + return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); + } + + if (this.isType()) { + var associatedContainerSymbol = this.getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.anyDeclHasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + var decls = this.getDeclarations(); + if (decls.length) { + var parentDecl = decls[0].getParentDecl(); + if (parentDecl) { + var parentSymbol = parentDecl.getSymbol(); + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { + return true; + } + + return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); + } + } + + return true; + } + + 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 */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { + var ast = decl.ast(); + + if (ast) { + 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.ASTHelpers.docComments(ast); + } + } + + return []; + }; + + PullSymbol.prototype.getDocCommentArray = function (symbol) { + var docComments = []; + if (!symbol) { + return docComments; + } + + 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 */) { + continue; + } + docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); + } + return docComments; + }; + + PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { + if (classSymbol.getHasDefaultConstructor()) { + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); + } + } + + return classSymbol.type.getConstructSignatures()[0]; + }; + + PullSymbol.prototype.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = this.getDocCommentTextValue(comments[c]); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + PullSymbol.prototype.getDocCommentTextValue = function (comment) { + return this.cleanJSDocComment(comment.fullText()); + }; + + PullSymbol.prototype.docComments = function (useConstructorAsClass) { + var decls = this.getDeclarations(); + 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 */) { + var classSymbol = this.returnType; + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + docComments = extendedTypes[0].getConstructorMethod().docComments(); + } else { + docComments = ""; + } + } else if (this.kind === 2048 /* Parameter */) { + var parameterComments = []; + + var funcContainer = this.getEnclosingSignature(); + var funcDocComments = this.getDocCommentArray(funcContainer); + var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); + if (paramComment != "") { + parameterComments.push(paramComment); + } + + var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); + if (paramSelfComment != "") { + parameterComments.push(paramSelfComment); + } + docComments = parameterComments.join("\n"); + } else { + var getSymbolComments = true; + if (this.kind === 16777216 /* FunctionType */) { + var functionSymbol = this.getFunctionSymbol(); + + if (functionSymbol) { + docComments = functionSymbol._docComments || ""; + getSymbolComments = false; + } else { + var declarationList = this.getDeclarations(); + if (declarationList.length > 0) { + docComments = declarationList[0].getSymbol()._docComments || ""; + getSymbolComments = false; + } + } + } + if (getSymbolComments) { + docComments = this.getDocCommentText(this.getDocCommentArray(this)); + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { + var callTypeSymbol = this.functionType; + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { + docComments = callTypeSymbol.docComments(); + } + } + } + } + } + + this._docComments = docComments; + } + + return this._docComments; + }; + + PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].fullText(); + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!this.isSpaceChar(commentContents, j)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + + PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.start; + for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.end); + } + + var newCleanPos = this.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + PullSymbol.prototype.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = this.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + start: nonSpaceIndex, + end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + 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.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; + this.hasBeenChecked = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return this._isDefinition; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + 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) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this._typeParameters) { + this._typeParameters = []; + } + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + 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 = []; + } + + return this._typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; + } + } + + memberSymbol = this._memberTypeParameterNameCache[name]; + + 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; + this._stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { + this._stringConstantOverload = true; + } + } + } + + 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); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + 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 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 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 wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + + var parameters = this.parameters; + + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._enclosedMemberContainers = null; + this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._enclosedContainerCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._containedNonMemberContainerCache = null; + this._simpleInstantiationCache = null; + this._complexInstantiationCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this._inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + this.typeReference = null; + this._widenedType = null; + this._isArrayNamedTypeReference = undefined; + this.type = this; + } + PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { + if (this._isArrayNamedTypeReference === undefined) { + this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); + } + + return this._isArrayNamedTypeReference; + }; + + PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { + var typeArgs = this.getTypeArguments(); + if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { + var declaration = this.getDeclarations()[0]; + + if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind === 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind === 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullTypeSymbol.prototype.isObject = function () { + 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 () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members !== TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return null; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberContainerCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = TypeScript.createIntrinsicsObject(); + } + + if (this._members === TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members.push(memberSymbol); + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + if (!enclosedContainer) { + return; + } + + enclosedContainer.setContainer(this); + + if (!this._enclosedContainerCache) { + this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberContainers) { + this._enclosedMemberContainers = []; + } + + this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; + this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + if (!enclosedNonMemberContainer) { + return; + } + + enclosedNonMemberContainer.setContainer(this); + + if (!this._containedNonMemberContainerCache) { + this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + 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 (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; + } + + 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; + } else { + if (!this._complexInstantiationCache) { + this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType.push(specializedVersionOfThisType); + }; + + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { + if (!this._simpleInstantiationCache) { + return null; + } + + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; + } else { + if (!this._complexInstantiationCache) { + return null; + } + + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + } + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return null; + }; + + PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + return this.getTypeParameters(); + }; + + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + 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 = []; + } + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + 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 = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + 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; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return this._constructSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function () { + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return this._indexSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnIndexSignatures = function () { + return this._indexSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function () { + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + } + } + + this._allIndexSignatures = signatures; + + 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; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { + if (typeof visited === "undefined") { visited = []; } + if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { + return true; + } + + if (TypeScript.ArrayUtilities.contains(visited, this)) { + return true; + } + + visited.push(this); + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + visited.pop(); + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (memberSymbol || !lookInParent) { + return memberSymbol; + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedContainerCache) { + return null; + } + + memberSymbol = this._enclosedContainerCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + var allMembers = []; + + 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 */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; + + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer()) { + if (this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + if (this._enclosedMemberContainers) { + for (var i = 0; i < this._enclosedMemberContainers.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberContainers[i]; + } + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArgumentsOrTypeParameters(); + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); + }; + + 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 !== "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); + return s; + }; + + 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, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + if (skipTypeParametersInName) { + return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); + } else { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + + var typars = this.getTypeArgumentsOrTypeParameters(); + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + } + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getTypeOfSymbol = function () { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + return associatedContainerType; + } + + var functionSymbol = this.getFunctionSymbol(); + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; + } + + return null; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + var typeOfSymbol = this.getTypeOfSymbol(); + if (typeOfSymbol) { + var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } + + if (this._inMemberTypeNameEx) { + return TypeScript.MemberName.create("any"); + } + + this._inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + 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()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && memberTypeName.delim === delim) { + allMemberNames.addAll(memberTypeName.entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this._inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + return 2 /* Closed */; + }; + + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + + if (type.isTypeParameter()) { + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; + } + + var constraint = type.getConstraint(); + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; + } + + if (type.inWrapCheck) { + return 0; + } + + 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; + + var typeArguments = type.getTypeArguments(); + + if (type.isGeneric() && !typeArguments) { + typeArguments = type.getTypeParameters(); + } + + if (typeArguments) { + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); + } + } + } + + 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); + } + + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); + } + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } + + return wrappingTypeParameterID; + }; + + 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + 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(); + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; + } + + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { + return true; + } + } + + 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); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isAny = function () { + 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 () { + return false; + }; + + 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; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(_anyType, name) { + _super.call(this, name); + 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); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerSymbol = (function (_super) { + __extends(PullContainerSymbol, _super); + function PullContainerSymbol(name, kind) { + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerSymbol.prototype.hasExportAssignment = function () { + return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; + }; + + PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { + return true; + } + + var moduleSymbol = containerSymbol; + var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerSymbol = PullContainerSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 128 /* TypeAlias */); + this._assignedValue = null; + this._assignedType = null; + 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; + }; + + PullTypeAliasSymbol.prototype.isUsedAsValue = function () { + this._resolveDeclaredSymbol(); + return this._isUsedAsValue; + }; + + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; + }; + + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; + + 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(); + }); + } + }; + + PullTypeAliasSymbol.prototype.assignedValue = function () { + this._resolveDeclaredSymbol(); + return this._assignedValue; + }; + + PullTypeAliasSymbol.prototype.assignedType = function () { + this._resolveDeclaredSymbol(); + return this._assignedType; + }; + + PullTypeAliasSymbol.prototype.assignedContainer = function () { + this._resolveDeclaredSymbol(); + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this._assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this._assignedValue) { + return this._assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this._assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedType) { + if (this._assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = this._assignedType.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this._assignedType !== this._assignedContainer) { + return this._assignedType; + } + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this._assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this._assignedType) { + return this._assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this._assignedType) { + return this._assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this._assignedType) { + return this._assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this._assignedType) { + return this._assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this._assignedType) { + return this._assignedType.findMember(name, true); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedContainer(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { + if (this._assignedType) { + return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); + } + + return TypeScript.sentinelEmptyArray; + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name) { + _super.call(this, name, 8192 /* TypeParameter */); + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + 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(); + } + + return _super.prototype.getCallSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getConstructSignatures = function () { + if (this._constraint) { + return this._constraint.getConstructSignatures(); + } + + return _super.prototype.getConstructSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getIndexSignatures = function () { + if (this._constraint) { + return this._constraint.getIndexSignatures(); + } + + return _super.prototype.getIndexSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { + var substitution = ""; + var members = null; + + 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 getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); + } + + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); + } + + return null; + } + + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.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"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; + })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); + 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._inferredTypeAfterFixing = null; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + 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 TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + this.candidateCache = []; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); + } + } + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { + return true; + } else { + this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); + return false; + } + }; + + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache.release(); + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + }; + + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolID]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolID] = info; + } + }; + + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolID]; + }; + + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { + var info = this.getInferenceInfo(param); + + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); + } + }; + + 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); + } + }; + + 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]; + + info.fixTypeParameter(this.resolver, this.context); + + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; + } + } + + results.push(info._inferredTypeAfterFixing); + } + + return results; + }; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; + })(); + 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, isInferentiallyTyping, typeArgumentInferenceContext) { + this.contextualType = contextualType; + this.provisional = provisional; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; + this.provisionallyTypedSymbols = []; + this.hasProvisionalErrors = false; + this.astSymbolMap = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].setUnresolved(); + } + }; + + PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()]; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + if (typeof fileName === "undefined") { fileName = null; } + this.resolver = resolver; + this.inTypeCheck = inTypeCheck; + 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"); + this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); + } + } + PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { + if (!this.inProvisionalResolution()) { + this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); + } + }; + + PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { + return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); + }; + + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); + }; + + 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(); + + if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; + } + + return tc; + }; + + PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + 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); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); + } + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { + if (diagnostic) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; + } else if (this.inTypeCheck && this.resolver) { + this.resolver.semanticInfoChain.addDiagnostic(diagnostic); + } + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inProvisionalResolution(); + }; + + PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { + this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); + }; + + PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + var typeContext = this.contextStack[i]; + if (!typeContext.provisional) { + break; + } + + var symbol = typeContext.getSymbolForAST(ast); + if (symbol) { + return symbol; + } + } + + 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; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OverloadApplicabilityStatus; + (function (OverloadApplicabilityStatus) { + OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; + })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + this.diagnosticsFromOverloadResolution = []; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var MemberWithBaseOrigin = (function () { + function MemberWithBaseOrigin(memberSymbol, baseOrigin) { + this.memberSymbol = memberSymbol; + this.baseOrigin = baseOrigin; + } + return MemberWithBaseOrigin; + })(); + + var SignatureWithBaseOrigin = (function () { + function SignatureWithBaseOrigin(signature, baseOrigin) { + this.signature = signature; + this.baseOrigin = baseOrigin; + } + return SignatureWithBaseOrigin; + })(); + + var InheritedIndexSignatureInfo = (function () { + function InheritedIndexSignatureInfo() { + } + return InheritedIndexSignatureInfo; + })(); + + 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(); + return CompilerReservedName[nameText]; + } + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this._cachedAnyTypeArgs = null; + this.typeCheckCallBacks = []; + this.postTypeCheckWorkitems = []; + this._cachedFunctionArgumentsSymbol = null; + 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 */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getArrayNamedType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { + if (!this._cachedFunctionArgumentsSymbol) { + this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); + functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); + this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + } + + 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); + }; + + PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { + return context.canTypeCheckAST(ast); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && context.inProvisionalResolution()) { + context.setSymbolForAST(ast, symbol); + } else { + this.semanticInfoChain.setSymbolForAST(ast, symbol); + } + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { + var symbol = this.semanticInfoChain.getSymbolForAST(ast); + + if (!symbol) { + if (context && context.inProvisionalResolution()) { + symbol = context.getSymbolForAST(ast); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { + if (typeof name === "undefined") { name = null; } + return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = decl.getParentPath(); + + if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.anyDeclHasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + 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 & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + + if (declSearchKind & 68147712 /* SomeValue */) { + member = parent.findMember(symbolName, true); + } else if (declSearchKind & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + } + + if (parent.kind & 164 /* SomeContainer */) { + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + return valueSymbol; + } + } + + return aliasSymbol; + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + 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; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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(); + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & 1032192 /* SomeFunction */) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (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) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = decl.getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var topLevelDecls = this.semanticInfoChain.topLevelDecls(); + for (var i = 0, n = topLevelDecls.length; i < n; i++) { + var topLevelDecl = topLevelDecls[i]; + if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { + continue; + } + + if (!topLevelDecl.isExternalModule()) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + 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 */ || lhs.kind === 64 /* Enum */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + this.resolveDeclaredSymbol(lhsType, context); + + if (lhsType.isContainer() && lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + var memberVisibilty = 2 /* externallyVisible */; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = enclosingDecl.getParentPath(); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { + memberVisibilty = 1 /* internallyVisible */; + break; + } + } + } + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + lhsType = this.getApparentType(lhsType); + + 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); + } + + 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 */)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { + var originalIdText = idText; + var symbol = null; + + if (TypeScript.isRelative(originalIdText)) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + symbol = this.semanticInfoChain.findExternalModule(path + idText); + } else { + idText = originalIdText; + + symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); + + if (!symbol) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + symbol = this.semanticInfoChain.findExternalModule(path + idText); + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + } + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { + if (!symbol || symbol.isResolved || symbol.isTypeReference()) { + return symbol; + } + + if (!context) { + context = new TypeScript.PullTypeResolutionContext(this); + } + + return this.resolveDeclaredSymbolWorker(symbol, context); + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.type && !symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + + var decls = symbol.getDeclarations(); + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + var ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + var resolvedSymbol; + 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 */); + resolvedSymbol = this.resolveAST(ast, false, context); + } + + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + 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(); + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); + }; + + PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { + var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); + var moduleSymbol = enclosingDecl.getSymbol(); + this.ensureAllSymbolsAreBound(moduleSymbol); + + this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); + this.resolveAST(sourceUnit.moduleElements, false, context); + + if (this.canTypeCheckAST(sourceUnit, context)) { + this.typeCheckSourceUnit(sourceUnit, context); + } + + return moduleSymbol; + }; + + 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) { + var containerDecl = this.semanticInfoChain.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + containerSymbol.setResolved(); + + this.resolveOtherDeclarations(ast, context); + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckEnumDeclaration(ast, context); + } + + return containerSymbol; + }; + + 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); + + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { + this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); + } + }; + + PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { + 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; + + if (ast.stringLiteral) { + result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckModuleDeclaration(ast, context); + } + + return result; + }; + + PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { + if (containerSymbol) { + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + }; + + PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + this.ensureAllSymbolsAreBound(containerSymbol); + + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, context); + } + + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + if (isLastName) { + this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); + } else if (sourceUnitAST) { + this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); + } + + containerSymbol.setResolved(); + + if (moduleDeclNameAST) { + this.resolveOtherDeclarations(moduleDeclNameAST, context); + } + + return containerSymbol; + }; + + 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 */) { + this.resolveExportAssignmentStatement(moduleElement, context); + return; + } + } + }; + + PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + var containerSymbol = containerDecl.getSymbol(); + + return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); + }; + + PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { + if (ast.stringLiteral) { + this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + }; + + PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; + this.setTypeChecked(ast, context); + + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { + this.resolveAST(ast.moduleElements, false, context); + } + + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + this.validateVariableDeclarationGroups(containerDecl, context); + + if (ast.stringLiteral) { + if (TypeScript.isRelative(ast.stringLiteral.valueText())) { + this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); + } + } + + 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) { + this.checkThisCaptureVariableCollides(ast, true, context); + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { + if (term.kind() === 11 /* IdentifierName */) { + return true; + } else if (term.kind() === 121 /* QualifiedName */) { + var binex = term; + + if (binex.right.kind() === 11 /* IdentifierName */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { + if (!type.isGeneric()) { + return type; + } + + var typeParameters = type.getTypeArgumentsOrTypeParameters(); + + var typeParameterArgumentMap = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); + } + + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); + if (extendsClause) { + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + + if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + } + } + } + + 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()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); + var implementedType = this.resolveTypeReference(implementedTypeAST, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + + if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addImplementedType(implementedType); + } + } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + + this.typeCheckCallBacks.push(function (context) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + _this.resolveClassDeclaration(classOrInterface, context); + } else { + _this.resolveInterfaceDeclaration(classOrInterface, context); + } + }); + + return typeDeclSymbol; + } + + this.setSymbolForAST(name, typeDeclSymbol, context); + this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + 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); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + var parentConstructor = parentType ? parentType.getConstructorMethod() : null; + + if (parentConstructor) { + this.resolveDeclaredSymbol(parentConstructor, context); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + + if (!parentConstructSignatures.length) { + parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + parentConstructSignature.returnType = parentType; + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); + parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); + parentConstructSignatures = [parentConstructSignature]; + } + + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + 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); + } + + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + + if (parentConstructorSymbol) { + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + } + } + + this.resolveOtherDeclarations(classDeclAST, context); + } + + if (this.canTypeCheckAST(classDeclAST, context)) { + this.typeCheckClassDeclaration(classDeclAST, context); + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { + var _this = this; + 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); + }); + } + } + }; + + PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { + this.setTypeChecked(classDeclAST, context); + + var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + + this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); + this.resolveAST(classDeclAST.classElements, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); + this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + + if (!classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); + }; + + PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { + this.checkThisCaptureVariableCollides(classDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { + var callSignatures = typeSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], context); + } + + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], context); + } + + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], context); + } + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); + + if (interfaceDeclSymbol.isResolved) { + this.resolveOtherDeclarations(interfaceDeclAST, context); + + if (this.canTypeCheckAST(interfaceDeclAST, context)) { + this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { + this.setTypeChecked(interfaceDeclAST, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); + this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); + + 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) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + this.resolveDeclaredSymbol(symbol, context); + + var alias = symbol; + if (kind & 164 /* SomeContainer */) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & 58728795 /* SomeType */) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & 68147712 /* SomeValue */) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); + + return { + symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), + aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null + }; + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + var rhsName = identifier.valueText(); + if (rhsName.length === 0) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); + var containerSymbol = memberSymbol.symbol; + var valueSymbol = null; + var typeSymbol = null; + var aliasSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + aliasSymbol = memberSymbol.aliasSymbol; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + aliasSymbol = containerSymbol; + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); + valueSymbol = memberSymbol.symbol; + if (valueSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + } + + if (!typeSymbol) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + typeSymbol = memberSymbol.symbol; + if (typeSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); + return null; + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol, + aliasSymbol: aliasSymbol + }; + }; + + 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"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleContainer) { + moduleName = dottedNameAST.right.valueText(); + + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; + if (!moduleSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); + } + } + } else { + var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); + var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); + + if (text.length > 0) { + var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); + moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); + if (moduleSymbol) { + 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]); + } + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var moduleReference = importStatementAST.moduleReference; + + var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; + + 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); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); + if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { + var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); + var instanceSymbol = aliasedType.getInstanceSymbol(); + + 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 { + importDeclSymbol.setAssignedValueSymbol(valueSymbol); + } + } + } else { + aliasedType = this.getNewErrorTypeSymbol(); + } + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); + return null; + } + } + } + + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + var declPath = enclosingDecl.getParentPath(); + + aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); + + if (!aliasedType) { + var path = importStatementAST.moduleReference.stringLiteral.text(); + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); + aliasedType = this.getNewErrorTypeSymbol(); + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); + } + + importDeclSymbol.setResolved(); + + this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); + 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); + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { + var _this = this; + this.setTypeChecked(importStatementAST, context); + + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (this.compilationSettings.noResolve()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); + } + + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + if (enclosingDecl.kind === 32 /* DynamicModule */) { + 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)); + } + } + } + } + + var checkPrivacy; + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind === 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + + 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; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { + var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + } + + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); + }; + + PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { + 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); + } + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { + var id = exportAssignmentAST.identifier.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && parentSymbol.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + + var aliasSymbol = containerSymbol; + var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + parentSymbol.setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + parentSymbol.setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + parentSymbol.setExportAssignedContainerSymbol(containerSymbol); + } + + this.resolveDeclaredSymbol(valueSymbol, context); + this.resolveDeclaredSymbol(typeSymbol, context); + this.resolveDeclaredSymbol(containerSymbol, context); + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + var funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); + } + } + + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.setTypeChecked(funcDeclAST, context); + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeAnnotation) { + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + 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) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + 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 (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(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + var contextualType = contextParam && contextParam.type; + var isImplicitAny = false; + + if (typeExpr) { + var typeRef = this.resolveTypeReference(typeExpr, context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + typeRef = this.getNewErrorTypeSymbol(); + } + + contextualType = typeRef || contextualType; + } + if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } + context.setTypeInContext(paramSymbol, contextualType); + } 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.propagateContextualType(contextualType); + } + + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + } + + if (!initExprSymbol || !initExprSymbol.type) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); + + if (!contextualType) { + context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); + } + } else { + var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); + if (!contextualType) { + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); + isImplicitAny = initTypeSymbol !== paramSymbol.type; + } else { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); + } + } + } + } + } + + if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + isImplicitAny = true; + } + + if (isImplicitAny && this.compilationSettings.noImplicitAny()) { + var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); + if (functionExpressionName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); + } + } + + if (canTypeCheckAST) { + this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { + var compilerReservedName = getCompilerReservedName(name); + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; + + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; + + case 3 /* arguments */: + this.checkArgumentsCollides(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; + } + }; + + PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { + var enclosingAST = this.getASTForDecl(someFunctionDecl); + var nodeType = enclosingAST.kind(); + + 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); + } 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 */) { + var constructorDeclaration = enclosingAST; + 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 */) { + var functionExpression = enclosingAST; + return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); + } + + return false; + }; + + PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { + if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); + } + } + } + }; + + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + 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)); + } + } + } + } + }; + + PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { + var decl = this.semanticInfoChain.getDeclForAST(ast); + + if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + var nameText = name.valueText(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); + } + } + }; + + PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); + TypeScript.Debug.assert(interfaceDecl); + + var interfaceSymbol = interfaceDecl.getSymbol(); + TypeScript.Debug.assert(interfaceSymbol); + + if (objectType.typeMembers) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = objectType.typeMembers; + + for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { + memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); + memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (this.canTypeCheckAST(objectType, context)) { + this.typeCheckObjectTypeTypeReference(objectType, context); + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { + this.setTypeChecked(objectType, context); + var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); + var objectTypeSymbol = objectTypeDecl.getSymbol(); + + this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); + }; + + PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { + return this.resolveTypeReference(typeAnnotation.type, context); + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { + if (typeRef === null) { + return null; + } + + TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); + + var aliasType = null; + var type = this.computeTypeReferenceSymbol(typeRef, context); + + if (type.kind === 4 /* Container */) { + var container = type; + var instanceSymbol = container.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + if (aliasType) { + this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); + } + } + + if (type && !type.isError()) { + 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 { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); + } + } + } + + if (this.canTypeCheckAST(typeRef, context)) { + this.setTypeChecked(typeRef, context); + } + + 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 */: + return this.semanticInfoChain.anyTypeSymbol; + case 61 /* BooleanKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + case 67 /* NumberKeyword */: + return this.semanticInfoChain.numberTypeSymbol; + case 69 /* StringKeyword */: + return this.semanticInfoChain.stringTypeSymbol; + case 41 /* VoidKeyword */: + return this.semanticInfoChain.voidTypeSymbol; + } + + var typeDeclSymbol = null; + + if (term.kind() === 11 /* IdentifierName */) { + typeDeclSymbol = this.resolveTypeNameExpression(term, context); + } else if (term.kind() === 123 /* FunctionType */) { + var functionType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); + } else if (term.kind() === 125 /* ConstructorType */) { + var constructorType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); + } else if (term.kind() === 122 /* ObjectType */) { + typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); + } else if (term.kind() === 126 /* GenericType */) { + typeDeclSymbol = this.resolveGenericTypeReference(term, context); + } else if (term.kind() === 121 /* QualifiedName */) { + typeDeclSymbol = this.resolveQualifiedName(term, context); + } else if (term.kind() === 14 /* StringLiteral */) { + 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, enclosingDecl.semanticInfoChain); + typeDeclSymbol.addDeclaration(decl); + } else if (term.kind() === 127 /* TypeQuery */) { + var typeQuery = term; + + var typeQueryTerm = typeQuery.name; + + var valueSymbol = this.resolveAST(typeQueryTerm, false, context); + + if (valueSymbol && valueSymbol.isAlias()) { + if (valueSymbol.assignedValue()) { + valueSymbol = valueSymbol.assignedValue(); + } else { + var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(); + } + } else if (term.kind() === 124 /* ArrayType */) { + var arrayType = term; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); + } else { + throw TypeScript.Errors.invalidOperation("unknown type"); + } + + if (!typeDeclSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); + return this.getNewErrorTypeSymbol(); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { + 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveParameterList = function (list, context) { + return this.resolveSeparatedList(list.parameters, context); + }; + + PullTypeResolver.prototype.resolveParameter = function (parameter, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { + var enumDeclaration = enumElement.parent.parent; + var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); + var symbol = decl.getSymbol(); + this.resolveDeclaredSymbol(symbol, context); + + return symbol; + }; + + PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { + if (this.canTypeCheckAST(clause, context)) { + this.setTypeChecked(clause, context); + } + + return this.resolveAST(clause.value, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + } else { + if (declSymbol.inResolution) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + + if (!declSymbol.type || !declSymbol.type.isError()) { + declSymbol.startResolving(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + if (!hasTypeExpr) { + this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + } + + if (!(hasTypeExpr || init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { + defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + } + } + + if (this.canTypeCheckAST(varDeclOrParameter, context)) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); + } + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (varDeclOrParameter.kind() === 243 /* EnumElement */) { + var result = this.getEnumTypeSymbol(varDeclOrParameter, context); + declSymbol.type = result; + return result; + } + + if (!typeExpr) { + return null; + } + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var typeExprSymbol = this.resolveTypeReference(typeExpr, context); + + if (!typeExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + declSymbol.type = this.getNewErrorTypeSymbol(); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = typeExprSymbol.getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } 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(); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + } + + return typeExprSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { + if (!init) { + return null; + } + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + if (typeExprSymbol) { + context.pushNewContextualType(typeExprSymbol); + } + + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); + + if (typeExprSymbol) { + context.popAnyContextualType(); + } + + if (!initExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + + if (!hasTypeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + var initTypeSymbol = initExprSymbol.type; + + if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); + context.setTypeInContext(declSymbol, widenedInitTypeSymbol); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny()) { + 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 initTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var _this = this; + this.setTypeChecked(varDeclOrParameter, context); + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + + if (hasTypeExpr || init) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = typeExprSymbol.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); + } + } + } + } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { + var wrapperDecl = this.getEnclosingDecl(decl); + 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])); + } else if (wrapperDecl.kind === 65536 /* Method */) { + var parentDecl = wrapperDecl.getParentDecl(); + + if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); + } 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 (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 */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } + } + } + + 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_only_allowed_in_implementation)); + } + } + 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 */)) { + this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); + } + }; + + PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { + return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; + }; + + PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { + var enclosingDecl = this.getEnclosingDeclForAST(superAST); + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); + + if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { + 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; + if (!block) { + return; + } + } + } + + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + if (parents.length) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); + } + } + }; + + PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { + if (isDeclaration) { + var decl = this.semanticInfoChain.getDeclForAST(_thisAST); + if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + return; + } + } + + var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + var declPath = enclosingDecl.getParentPath(); + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + continue; + } + + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); + } + break; + } + } + }; + + PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { + this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + 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) { + return; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + }; + + PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { + this.setTypeChecked(typeParameterAST, 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) { + if (this.canTypeCheckAST(constraint, context)) { + this.setTypeChecked(constraint, context); + } + + return this.resolveTypeReference(constraint.type, context); + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatementsExpressions = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, walker) { + var go = true; + + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); + go = false; + break; + + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, walker) { + switch (ast.kind()) { + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + if (block) { + TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + } else { + returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + } + + if (!returnStatementsExpressions.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnExpressions = []; + + for (var i = 0; i < returnStatementsExpressions.length; i++) { + var returnExpression = returnStatementsExpressions[i].expression; + if (returnExpression) { + var returnType = this.resolveAST(returnExpression, useContextualType, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { + this.setSymbolForAST(returnExpression.parent, returnType, context); + } + } + + returnExpressionSymbols.push(returnType); + returnExpressions.push(returnExpression); + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); + var returnType = bestCommonReturnType; + var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = returnType.widenedType(this, returnExpression, context); + signature.returnType = newReturnType; + + if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); + } + + if (this.compilationSettings.noImplicitAny()) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName === "") { + functionName = enclosingDecl.getFunctionExpressionName(); + } + + if (functionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } + + if (!functionSymbol.type && functionSymbol.isAccessor()) { + functionSymbol.type = signature.returnType; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { + var _this = this; + this.setTypeChecked(funcDeclAST, context); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { + var _this = this; + if (constructorDecl.block) { + var foundSuperCall = false; + var pre = function (ast, walker) { + 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; + } + } + }; + + TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); + return foundSuperCall; + } + + return false; + }; + + 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(parameters, false, context); + + this.resolveAST(block, false, context); + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + this.validateVariableDeclarationGroups(funcDecl, context); + + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); + + if (funcDecl.kind === 16384 /* Function */) { + this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); + } + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + this.resolveAST(funcDeclAST.parameter, false, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); + var stringIndexSignature = allIndexSignatures.stringSignature; + var numberIndexSignature = allIndexSignatures.numericSignature; + var isNumericIndexer = numberIndexSignature === signature; + + if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { + var comparisonInfo = new TypeComparisonInfo(); + + 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + } + } + } + + var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); + for (var i = 0; i < allMembers.length; i++) { + var member = allMembers[i]; + var name = member.name; + if (name || (member.kind === 4096 /* Property */ && name === "")) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], context); + } + + if (parentSymbol !== allMembers[i].getContainer()) { + var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); + var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; + var onlyStringIndexerIsPresent = !numberIndexSignature; + + if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { + var comparisonInfo = new TypeComparisonInfo(); + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); + } + } + } + } + } + }); + }; + + PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { + this.checkThisCaptureVariableCollides(funcDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { + var returnTypeSymbol = null; + + if (returnTypeAnnotation) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + } else { + var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } + + return returnTypeSymbol; + }; + + 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + return funcSymbol; + } + + if (!signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + 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(); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveIndexSignature(ast.indexSignature, context); + }; + + PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + return funcSymbol; + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.typeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.parameter) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + this.resolveParameter(funcDeclAST.parameter, context); + context.inTypeCheck = prevInTypeCheck; + } + + if (funcDeclAST.typeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + + context.inTypeCheck = prevInTypeCheck; + } + + if (returnTypeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { + if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { + 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; + if (funcDeclASTName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } + } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { + if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); + } + + return null; + }; + + 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.ASTHelpers.getType(parameter), context); + } + + return null; + }; + + PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + + if (accessorSymbol.inResolution) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + accessorSymbol.setResolved(); + + return accessorSymbol; + } + + if (accessorSymbol.isResolved) { + if (!accessorSymbol.type) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else { + var getterSymbol = accessorSymbol.getGetter(); + var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; + var hasGetter = getterSymbol !== null; + + var setterSymbol = accessorSymbol.getSetter(); + var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; + var hasSetter = setterSymbol !== null; + + var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); + var getterHasTypeAnnotation = getterAnnotatedType !== null; + + var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); + var setterHasTypeAnnotation = setterAnnotatedType !== null; + + accessorSymbol.startResolving(); + + if (hasGetter) { + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + } + + if (hasSetter) { + setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); + } + + if (hasGetter && hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + var getterSig = getterSymbol.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { + getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; + getterSig.returnType = setterSuppliedTypeSymbol; + } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { + setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; + + if (setterHasParameters) { + setterParameters[0].type = getterSuppliedTypeSymbol; + } + } + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + accessorSymbol.type = this.getNewErrorTypeSymbol(); + } else { + accessorSymbol.type = getterSuppliedTypeSymbol; + } + } else if (hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + + accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; + } else { + var getterSig = getterSymbol.type.getCallSignatures()[0]; + accessorSymbol.type = getterSig.returnType; + } + + accessorSymbol.setResolved(); + } + + if (this.canTypeCheckAST(funcDeclAst, context)) { + this.typeCheckAccessorDeclaration(funcDeclAst, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { + this.setTypeChecked(funcDeclAst, context); + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + var getterSymbol = accessorSymbol.getGetter(); + var setterSymbol = accessorSymbol.getSetter(); + + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; + if (isGetter) { + var getterFunctionDeclarationAst = funcDeclAst; + context.pushNewContextualType(getterSymbol.type); + this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); + context.popAnyContextualType(); + } else { + var setterFunctionDeclarationAst = funcDeclAst; + this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); + } + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return getterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return getterSymbol; + } + + signature.startResolving(); + + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + if (!setterAnnotatedType) { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } else { + signature.returnType = setterAnnotatedType; + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + return getterSymbol; + }; + + PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + if (getter && setter) { + var getterAST = getter.getDeclarations()[0].ast(); + var setterAST = setter.getDeclarations()[0].ast(); + + if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { + var setterSig = setter.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + + var getter = accessorSymbol.getGetter(); + var getterSig = getter.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterParameters[0].type; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + var funcNameAST = funcDeclAST.propertyName; + + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); + } + + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); + var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + 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.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; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return setterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + signature.setResolved(); + return setterSymbol; + } + + signature.startResolving(); + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + } + + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + + if (!hadError) { + signature.setResolved(); + } + } + + return setterSymbol; + }; + + PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + if (funcDeclAST.parameterList) { + for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + + var getter = accessorSymbol.getGetter(); + + var funcNameAST = funcDeclAST.propertyName; + + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); + var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + if (getterIsPrivate !== setterIsPrivate) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); + } + + this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); + } else { + if (this.compilationSettings.noImplicitAny()) { + var setterFunctionDeclarationAst = funcDeclAST; + 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + }; + + PullTypeResolver.prototype.resolveList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.childCount(); i < n; i++) { + this.resolveAST(list.childAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.resolveAST(list.nonSeparatorAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLogicalOperation(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { + this.setTypeChecked(binex, context); + + var leftType = this.resolveAST(binex.left, false, context).type; + var rightType = this.resolveAST(binex.right, false, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(binex); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ + TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), + leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); + } + }; + + PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.operand, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckUnaryArithmeticOperation(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckPostfixUnaryExpression(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { + return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); + }; + + PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + return; + } + + TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { + if (this.canTypeCheckAST(binaryExpression, context)) { + this.typeCheckBinaryArithmeticExpression(binaryExpression, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } + + if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } + + var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); + var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); + + if (!rhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!lhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (lhsIsFit && rhsIsFit) { + switch (binaryExpression.kind()) { + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + if (!this.isReference(binaryExpression.left, lhsSymbol)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); + } + } + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInstanceOfExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); + var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); + 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_of_a_type_assignable_to_the_Function_interface_type)); + } + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { + if (this.canTypeCheckAST(commaExpression, context)) { + this.setTypeChecked(commaExpression, context); + + this.resolveAST(commaExpression.left, false, context); + } + + return this.resolveAST(commaExpression.right, false, context).type; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; + + var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); + + if (!isValidLHS) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); + } + + if (!isValidRHS) { + 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)); + } + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.variableDeclaration, false, context); + this.resolveAST(ast.initializer, false, context); + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.incrementor, false, context); + this.resolveAST(ast.statement, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { + if (this.canTypeCheckAST(forInStatement, context)) { + this.typeCheckForInStatement(forInStatement, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { + this.setTypeChecked(forInStatement, context); + + if (forInStatement.variableDeclaration) { + var declaration = forInStatement.variableDeclaration; + + 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); + + 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 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)); + } + + this.resolveAST(forInStatement.statement, false, context); + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWhileStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckDoStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckIfStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + this.resolveAST(ast.elseClause, false, context); + }; + + PullTypeResolver.prototype.resolveElseClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckElseClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.statements, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declaration, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declarators, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWithStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var withStatement = ast; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckTryStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var tryStatement = ast; + + this.resolveAST(tryStatement.block, false, context); + this.resolveAST(tryStatement.catchClause, false, context); + this.resolveAST(tryStatement.finallyClause, false, context); + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckCatchClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + + var catchDecl = this.semanticInfoChain.getDeclForAST(ast); + this.validateVariableDeclarationGroups(catchDecl, context); + }; + + PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckFinallyClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + }; + + PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + while (enclosingDecl) { + if (enclosingDecl.kind & 1032192 /* SomeFunction */) { + return enclosingDecl; + } + + enclosingDecl = enclosingDecl.getParentDecl(); + } + + return null; + }; + + PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var isContextuallyTyped = false; + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); + if (returnTypeAnnotationSymbol) { + isContextuallyTyped = true; + context.pushNewContextualType(returnTypeAnnotationSymbol); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + isContextuallyTyped = true; + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); + } + } + } + } + + var result = this.resolveAST(expression, isContextuallyTyped, context).type; + if (isContextuallyTyped) { + context.popAnyContextualType(); + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { + if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingFunction.getParentDecl(); + if (classDecl) { + var classSymbol = classDecl.getSymbol(); + this.resolveDeclaredSymbol(classSymbol, context); + + var comparisonInfo = new TypeComparisonInfo(); + var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); + if (!isAssignable) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); + } + } + } + + if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); + } + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { + var signatureSymbol = enclosingFunction.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (expressionType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + this.resolveDeclaredSymbol(expressionType, context); + this.resolveDeclaredSymbol(sigReturnType, context); + + var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); + } + } + } + } + } + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { + var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var returnType = this.getSymbolForAST(returnAST, context); + var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); + if (!returnType || canTypeCheckAST) { + var returnExpr = returnAST.expression; + + var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); + + if (!returnType) { + returnType = resolvedReturnType; + this.setSymbolForAST(returnAST, resolvedReturnType, context); + } + + if (returnExpr && canTypeCheckAST) { + this.setTypeChecked(returnExpr, context); + this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSwitchStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var expressionType = this.resolveAST(ast.expression, false, context).type; + + for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { + var switchClause = ast.switchClauses.childAt(i); + if (switchClause.kind() === 233 /* CaseSwitchClause */) { + var caseSwitchClause = switchClause; + + var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; + this.resolveAST(caseSwitchClause.statements, false, context); + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); + } + } + } else { + var defaultSwitchClause = switchClause; + this.resolveAST(defaultSwitchClause.statements, false, context); + } + } + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLabeledStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var labelIdentifier = ast.identifier.valueText(); + + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + 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); + }; + + PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { + switch (statement.kind()) { + case 160 /* LabeledStatement */: + return this.labelIsOnContinuableConstruct(statement.statement); + + case 158 /* WhileStatement */: + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 161 /* DoStatement */: + return true; + + default: + return false; + } + }; + + PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckContinueStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.isIterationStatement = function (ast) { + switch (ast.kind()) { + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 158 /* WhileStatement */: + case 161 /* DoStatement */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { + switch (ast.kind()) { + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 129 /* FunctionDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 241 /* FunctionPropertyAssignment */: + case 137 /* ConstructorDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.inSwitchStatement = function (ast) { + while (ast) { + if (ast.kind() === 151 /* SwitchStatement */) { + return true; + } + + if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { + while (ast) { + if (this.isIterationStatement(ast)) { + return true; + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { + var result = []; + + ast = ast.parent; + while (ast) { + if (ast.kind() === 160 /* LabeledStatement */) { + var labeledStatement = ast; + if (breakable) { + result.push(labeledStatement); + } else { + if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { + result.push(labeledStatement); + } + } + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + break; + } + + ast = ast.parent; + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + 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.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var continuableLabels = this.getEnclosingLabels(ast, false, true); + + 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)); + } + } + } + }; + + PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckBreakStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + if (ast.identifier) { + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var breakableLabels = this.getEnclosingLabels(ast, true, true); + 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, 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)); + } + } + }; + + PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { + if (!ast) { + return; + } + + var symbol = this.getSymbolForAST(ast, context); + if (symbol && symbol.isResolved) { + this.typeCheckAST(ast, isContextuallyTyped, context); + return symbol; + } + + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + + var nodeType = ast.kind(); + + switch (nodeType) { + case 124 /* ArrayType */: + case 126 /* GenericType */: + case 122 /* ObjectType */: + case 127 /* TypeQuery */: + case 125 /* ConstructorType */: + case 123 /* FunctionType */: + return this.resolveTypeReference(ast, context); + + case 1 /* List */: + return this.resolveList(ast, context); + + case 2 /* SeparatedList */: + return this.resolveSeparatedList(ast, context); + + case 120 /* SourceUnit */: + return this.resolveSourceUnit(ast, context); + + case 132 /* EnumDeclaration */: + return this.resolveEnumDeclaration(ast, context); + + case 130 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 128 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 131 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 224 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, context); + + case 136 /* MemberVariableDeclaration */: + return this.resolveMemberVariableDeclaration(ast, context); + + case 225 /* VariableDeclarator */: + return this.resolveVariableDeclarator(ast, context); + + case 141 /* PropertySignature */: + return this.resolvePropertySignature(ast, context); + + case 227 /* ParameterList */: + return this.resolveParameterList(ast, context); + + case 242 /* Parameter */: + return this.resolveParameter(ast, context); + + case 243 /* EnumElement */: + return this.resolveEnumElement(ast, context); + + case 232 /* EqualsValueClause */: + return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); + + case 238 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 239 /* Constraint */: + return this.resolveConstraint(ast, context); + + case 133 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 240 /* SimplePropertyAssignment */: + return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); + + case 241 /* FunctionPropertyAssignment */: + return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); + + case 121 /* QualifiedName */: + return this.resolveQualifiedName(ast, context); + + case 137 /* ConstructorDeclaration */: + return this.resolveConstructorDeclaration(ast, context); + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return this.resolveAccessorDeclaration(ast, context); + + case 138 /* IndexMemberDeclaration */: + return this.resolveIndexMemberDeclaration(ast, context); + + case 144 /* IndexSignature */: + return this.resolveIndexSignature(ast, context); + + case 135 /* MemberFunctionDeclaration */: + return this.resolveMemberFunctionDeclaration(ast, context); + + case 142 /* CallSignature */: + return this.resolveCallSignature(ast, context); + + case 143 /* ConstructSignature */: + return this.resolveConstructSignature(ast, context); + + case 145 /* MethodSignature */: + return this.resolveMethodSignature(ast, context); + + 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); + + case 219 /* SimpleArrowFunctionExpression */: + return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 214 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + + case 35 /* ThisKeyword */: + return this.resolveThisExpression(ast, context); + + case 50 /* SuperKeyword */: + return this.resolveSuperExpression(ast, context); + + case 213 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, context); + + case 216 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, context); + + case 220 /* CastExpression */: + return this.resolveCastExpression(ast, context); + + case 13 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + + case 14 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + + case 32 /* NullKeyword */: + return this.semanticInfoChain.nullTypeSymbol; + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + + case 172 /* VoidExpression */: + return this.resolveVoidExpression(ast, context); + + case 174 /* AssignmentExpression */: + return this.resolveAssignmentExpression(ast, context); + + case 167 /* LogicalNotExpression */: + return this.resolveLogicalNotExpression(ast, context); + + case 193 /* NotEqualsWithTypeConversionExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 197 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, context); + + case 208 /* AddExpression */: + case 175 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, context); + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, context); + + case 210 /* PostIncrementExpression */: + case 211 /* PostDecrementExpression */: + return this.resolvePostfixUnaryExpression(ast, context); + + case 209 /* SubtractExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 189 /* BitwiseOrExpression */: + case 191 /* BitwiseAndExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, context); + + case 221 /* ElementAccessExpression */: + return this.resolveElementAccessExpression(ast, context); + + case 187 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); + + case 188 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, context); + + case 171 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, context); + + case 170 /* DeleteExpression */: + return this.resolveDeleteExpression(ast, context); + + case 186 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, isContextuallyTyped, context); + + case 12 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 217 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, context); + + case 200 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, context); + + case 173 /* CommaExpression */: + return this.resolveCommaExpression(ast, context); + + case 201 /* InExpression */: + return this.resolveInExpression(ast, context); + + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; + } + + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); + }; + + PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { + if (!this.canTypeCheckAST(ast, context)) { + return; + } + + var nodeType = ast.kind(); + switch (nodeType) { + case 120 /* SourceUnit */: + this.typeCheckSourceUnit(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.typeCheckEnumDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.typeCheckModuleDeclaration(ast, context); + return; + + case 128 /* InterfaceDeclaration */: + this.typeCheckInterfaceDeclaration(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.typeCheckClassDeclaration(ast, context); + return; + + case 243 /* EnumElement */: + this.typeCheckEnumElement(ast, context); + return; + + case 136 /* MemberVariableDeclaration */: + this.typeCheckMemberVariableDeclaration(ast, context); + return; + + case 225 /* VariableDeclarator */: + this.typeCheckVariableDeclarator(ast, context); + return; + + case 141 /* PropertySignature */: + this.typeCheckPropertySignature(ast, context); + return; + + case 242 /* Parameter */: + this.typeCheckParameter(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.typeCheckImportDeclaration(ast, context); + return; + + case 215 /* ObjectLiteralExpression */: + this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 241 /* FunctionPropertyAssignment */: + this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); + return; + + case 11 /* IdentifierName */: + if (isTypesOnlyLocation(ast)) { + this.resolveTypeNameExpression(ast, context); + } else { + this.resolveNameExpression(ast, context); + } + return; + + case 212 /* MemberAccessExpression */: + this.resolveMemberAccessExpression(ast, context); + return; + + case 121 /* QualifiedName */: + this.resolveQualifiedName(ast, context); + return; + + case 222 /* FunctionExpression */: + 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); + break; + + case 142 /* CallSignature */: + this.typeCheckCallSignature(ast, context); + return; + + case 143 /* ConstructSignature */: + this.typeCheckConstructSignature(ast, context); + return; + + case 129 /* FunctionDeclaration */: { + var funcDecl = ast; + 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, isContextuallyTyped, context); + return; + + case 218 /* ParenthesizedArrowFunctionExpression */: + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 214 /* ArrayLiteralExpression */: + this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 213 /* InvocationExpression */: + this.typeCheckInvocationExpression(ast, context); + return; + + case 216 /* ObjectCreationExpression */: + this.typeCheckObjectCreationExpression(ast, context); + return; + + case 150 /* ReturnStatement */: + this.resolveReturnStatement(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); + } + }; + + PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { + while (this.postTypeCheckWorkitems.length) { + var ast = this.postTypeCheckWorkitems.pop(); + this.postTypeCheck(ast, context); + } + }; + + PullTypeResolver.prototype.postTypeCheck = function (ast, context) { + var nodeType = ast.kind(); + + switch (nodeType) { + case 242 /* Parameter */: + case 225 /* VariableDeclarator */: + this.postTypeCheckVariableDeclaratorOrParameter(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.postTypeCheckClassDeclaration(ast, context); + return; + + case 129 /* FunctionDeclaration */: + this.postTypeCheckFunctionDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.postTypeCheckModuleDeclaration(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.postTypeCheckEnumDeclaration(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.postTypeCheckImportDeclaration(ast, context); + return; + + case 11 /* IdentifierName */: + this.postTypeCheckNameExpression(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); + } + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { + this.checkThisCaptureVariableCollides(nameAST, false, context); + }; + + PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { + this.setTypeChecked(nameAST, context); + this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { + var nameSymbol = this.getSymbolForAST(nameAST, context); + var foundCached = nameSymbol !== null; + + if (!foundCached || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.typeCheckNameExpression(nameAST, context); + } + nameSymbol = this.computeNameExpression(nameAST, context); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + 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.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; + } + + var nameSymbol = null; + var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); + } + + 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) { + 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]; + var nameParentDecl = nameDeclaration.getParentDecl(); + if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { + var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); + var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); + + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); + + if (currentParameterIndex >= 0) { + var matchingParameter; + if (parameterList) { + for (var i = 0; i <= currentParameterIndex; i++) { + var candidateParameter = parameterList.parameters.nonSeparatorAt(i); + if (candidateParameter && candidateParameter.identifier.valueText() === id) { + matchingParameter = candidateParameter; + break; + } + } + } + + 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); + } + } + } + + var aliasSymbol = null; + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + if (!this.inTypeQuery(nameAST)) { + aliasSymbol.setIsUsedAsValue(); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); + + var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); + if (parameterList) { + while (parameter && parameter.parent) { + if (parameter.parent.parent === parameterList) { + return parameterList.parameters.nonSeparatorIndexOf(parameter); + } + + parameter = parameter.parent; + } + } + + return -1; + }; + + PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { + var symbol = this.getSymbolForAST(dottedNameAST, context); + var foundCached = symbol !== null; + + if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheckDottedNameAST) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); + } + + this.resolveDeclaredSymbol(symbol, context); + + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(name, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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)) { + lhsAlias.setIsUsedAsValue(); + } + lhsType = lhsAlias.getExportAssignedTypeSymbol(); + } + + if (lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); + return this.getNewErrorTypeSymbol(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); + + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { + var instanceSymbol = lhsType.getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); + + if (!nameSymbol) { + if (lhsType.kind === 32 /* DynamicModule */) { + var container = lhsType; + var associatedInstance = container.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); + } + } + + 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + } + + if (checkSuperPrivateAndStaticAccess) { + this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST, context); + + if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.setTypeChecked(nameAST, context); + } + typeNameSymbol = this.computeTypeNameExpression(nameAST, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + this.resolveDeclaredSymbol(typeNameSymbol, context); + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { + var id = nameAST.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(nameAST); + + var declPath = enclosingDecl.getParentPath(); + + var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); + + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + this.resolveDeclaredSymbol(typeNameSymbol, context); + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + this.resolveDeclaredSymbol(aliasedType, context); + } + + if (typeNameSymbol.isTypeParameter()) { + if (this.isInStaticMemberContext(enclosingDecl)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); + return this.getNewErrorTypeSymbol(); + } + } + } + + if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { + typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); + } + + 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; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, context); + } + + 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()) { + for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + + if (typeArgs[i].isError()) { + typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + } + + 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(); + } + + if (!genericTypeSymbol.isResolved) { + var typeDecls = genericTypeSymbol.getDeclarations(); + var childDecls = null; + + for (var i = 0; i < typeDecls.length; i++) { + childDecls = typeDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + + var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); + + var typeConstraint = null; + var upperBound = null; + + typeParameters = specializedSymbol.getTypeParameters(); + + var typeConstraintSubstitutionMap = []; + var typeArg = null; + + var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < typeParameters.length; i++) { + typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + for (var id in instantiatedSubstitutionMap) { + typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; + } + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] === typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } else if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); + } + + if (typeArg.isTypeParameter()) { + upperBound = typeArg.getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + 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)])); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { + if (this.inTypeQuery(dottedNameAST)) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; + } + + var symbol = this.getSymbolForAST(dottedNameAST, context); + if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheck) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeQualifiedName(dottedNameAST, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + this.resolveDeclaredSymbol(symbol, context); + + 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) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); + var lhs = this.resolveAST(dottedNameAST.left, false, context); + + var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; + + if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { + if (lhs.isAlias()) { + lhs.setIsUsedAsValue(); + } + } + + if (!lhsType) { + return this.getNewErrorTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); + var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; + + 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & 164 /* SomeContainer */) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { + if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { + return false; + } + + if (returnTypeAnnotation) { + return false; + } + + if (parameters) { + for (var i = 0, n = parameters.length; i < n; i++) { + if (parameters.typeAt(i)) { + return false; + } + } + } + + var contextualFunctionTypeSymbol = context.getContextualType(); + + if (contextualFunctionTypeSymbol) { + this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); + var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; + if (!exactlyOneCallSignature) { + return false; + } + + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; + return !callSignatureIsGeneric; + } + + return false; + }; + + PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { + var funcDeclSymbol = null; + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { + return funcDeclSymbol; + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + TypeScript.Debug.assert(funcDeclSymbol); + + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.propagateContextualType(returnType); + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); + context.popAnyContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + var functionExpressionName = functionDecl.getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); + } + } + + context.setTypeInContext(funcDeclSymbol, funcDeclType); + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); + } + + return funcDeclSymbol; + }; + + 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + var returnTypeSymbol = signature.returnType; + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + 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.popAnyContextualType(); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); + + this.validateVariableDeclarationGroups(functionDecl, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { + var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); + var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; + + if (this.canTypeCheckAST(thisExpression, context)) { + this.typeCheckThisExpression(thisExpression, context, enclosingDecl); + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.inTypeArgumentList = function (ast) { + var previous = null; + var current = ast; + + while (current) { + switch (current.kind()) { + case 126 /* GenericType */: + var genericType = current; + if (genericType.typeArgumentList === previous) { + return true; + } + break; + + case 226 /* ArgumentList */: + var argumentList = current; + return argumentList.typeArgumentList === previous; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { + while (ast) { + switch (ast.kind()) { + case 230 /* ExtendsHeritageClause */: + var heritageClause = ast; + + return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inTypeQuery = function (ast) { + while (ast) { + switch (ast.kind()) { + case 127 /* TypeQuery */: + return true; + case 129 /* FunctionDeclaration */: + case 213 /* InvocationExpression */: + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 213 /* InvocationExpression */: + var invocationExpression = current; + if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + break; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inConstructorParameterList = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } + + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + 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 */) { + return true; + } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { + this.checkForThisCaptureInArrowFunction(thisExpression); + + if (this.inConstructorParameterList(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); + return; + } + + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { + return; + } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + if (currentDecl.getParentDecl() === null) { + return; + } else { + 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)); + } + + return; + } else if (currentDecl.kind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); + } + + return; + } + } + }; + + PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var isStaticContext = false; + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + return null; + } else if (declKind === 16384 /* Function */) { + return null; + } else if (declKind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(ast)) { + return this.getNewErrorTypeSymbol(); + } else { + var classSymbol = decl.getSymbol(); + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + return constructorSymbol.type; + } else { + return classSymbol; + } + } + } + } + } + + return null; + }; + + PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { + return true; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + var superType = this.semanticInfoChain.anyTypeSymbol; + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); + + if (classSymbol) { + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSuperExpression(ast, context, enclosingDecl); + } + + return superType; + }; + + PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { + this.setTypeChecked(ast, context); + + this.checkForThisCaptureInArrowFunction(ast); + + var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; + var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; + TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); + + if (isSuperPropertyAccess) { + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + break; + } else if (currentDecl.kind === 8 /* Class */) { + if (!this.enclosingClassIsDerived(currentDecl)) { + 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 if (this.inStaticMemberVariableDeclaration(ast)) { + break; + } + + 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 { + 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)); + } + } + }; + + PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { + return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (this.canTypeCheckAST(expressionAST, context)) { + this.setTypeChecked(expressionAST, context); + } + symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { + var boundMemberSymbols = []; + var memberSymbol; + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var id = this.getPropertyAssignmentName(propertyAssignment); + var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); + + var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; + var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); + TypeScript.Debug.assert(decl); + + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + if (!isUsingExistingSymbol) { + memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } else { + memberSymbol = decl.getSymbol(); + } + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + memberSymbol = decl.getSymbol(); + } else { + TypeScript.Debug.assert(isAccessor); + memberSymbol = decl.getSymbol(); + } + + if (!isUsingExistingSymbol && !isAccessor) { + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); + } + + objectLiteralTypeSymbol.addMember(memberSymbol); + } + + boundMemberSymbols.push(memberSymbol); + } + + return boundMemberSymbols; + }; + + PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var acceptedContextualType = false; + var assigningSymbol = null; + + var id = this.getPropertyAssignmentName(propertyAssignment); + var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; + + if (objectLiteralContextualType) { + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + + if (!assigningSymbol) { + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + assigningSymbol = numericIndexerSignature; + } else if (stringIndexerSignature) { + assigningSymbol = stringIndexerSignature; + } + } + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); + + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = contextualMemberType; + } + } + } + + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; + + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { + objectLiteralTypeSymbol.setHasGenericMember(); + } + + if (stringIndexerSignature) { + allMemberTypes.push(memberSymbolType); + } + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + allNumericMemberTypes.push(memberSymbolType); + } + } + + if (acceptedContextualType) { + pullTypeContext.popAnyContextualType(); + } + + var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; + if (!memberSymbol.isResolved) { + if (isAccessor) { + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); + } else { + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); + memberSymbol.setResolved(); + + this.setSymbolForAST(id, memberSymbol, pullTypeContext); + } + } + } + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { + var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); + TypeScript.Debug.assert(objectLitDecl); + + var typeSymbol = this.getSymbolForAST(objectLitAST, context); + var isUsingExistingSymbol = !!typeSymbol; + + if (!typeSymbol) { + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); + typeSymbol.addDeclaration(objectLitDecl); + this.setSymbolForAST(objectLitAST, typeSymbol, context); + objectLitDecl.setSymbol(typeSymbol); + } + + var propertyAssignments = objectLitAST.propertyAssignments; + var contextualType = null; + + if (isContextuallyTyped) { + contextualType = context.getContextualType(); + this.resolveDeclaredSymbol(contextualType, context); + } + + var stringIndexerSignature = null; + var numericIndexerSignature = null; + var allMemberTypes = null; + var allNumericMemberTypes = null; + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + + stringIndexerSignature = indexSignatures.stringSignature; + numericIndexerSignature = indexSignatures.numericSignature; + + var inInferentialTyping = context.isInferentiallyTyping(); + if (stringIndexerSignature) { + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; + } + + if (numericIndexerSignature) { + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; + } + } + + if (propertyAssignments) { + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); + + this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); + + if (!isUsingExistingSymbol) { + this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); + this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { + return propertyAssignment.propertyName; + } else { + TypeScript.Debug.assert(false); + } + }; + + PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { + if (contextualIndexSignature) { + var typeCollection = { + getLength: function () { + return indexerTypeCandidates.length; + }, + getTypeAtIndex: function (index) { + return indexerTypeCandidates[index]; + } + }; + var decl = objectLiteralSymbol.getDeclarations()[0]; + 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); + } + } + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { + var symbol = this.getSymbolForAST(arrayLit, context); + if (!symbol || this.canTypeCheckAST(arrayLit, context)) { + if (this.canTypeCheckAST(arrayLit, context)) { + this.setTypeChecked(arrayLit, context); + } + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { + var elements = arrayLit.expressions; + var elementType = null; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, context); + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + if (indexSignatures.numericSignature) { + contextualElementType = indexSignatures.numericSignature.returnType; + } + } + } + + if (elements) { + if (contextualElementType) { + context.propagateContextualType(contextualElementType); + } + + for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { + elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); + } + + if (contextualElementType) { + context.popAnyContextualType(); + } + } + + if (elementTypes.length) { + elementType = elementTypes[0]; + } + var collection; + + if (contextualElementType && !context.isInferentiallyTyping()) { + if (!elementType) { + elementType = contextualElementType; + } + + collection = { + getLength: function () { + return elements.nonSeparatorCount() + 1; + }, + getTypeAtIndex: function (index) { + return index === 0 ? contextualElementType : elementTypes[index - 1]; + } + }; + } else { + collection = { + getLength: function () { + return elements.nonSeparatorCount(); + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + } + + elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; + + if (!elementType) { + elementType = this.semanticInfoChain.undefinedTypeSymbol; + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { + var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); + + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); + } + + return symbolAndDiagnostic.symbol; + }; + + PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { + this.setTypeChecked(callEx, context); + context.postDiagnostic(symbolAndDiagnostic.diagnostic); + }; + + PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; + + var targetTypeSymbol = targetSymbol.type; + + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return { symbol: targetTypeSymbol }; + } + + var elementType = targetTypeSymbol.getElementType(); + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return { symbol: elementType }; + } + + 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); + + if (member) { + this.resolveDeclaredSymbol(member, context); + + return { symbol: member.type }; + } + } + + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); + + var stringSignature = signatures.stringSignature; + var numberSignature = signatures.numericSignature; + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; + } 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 { + symbol: this.getNewErrorTypeSymbol(), + diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) + }; + } + }; + + 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; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + if (!signature.isResolved) { + this.resolveDeclaredSymbol(signature, context); + } + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signature; + continue; + } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { + numberSignature = signature; + continue; + } + } + } + + return { + numericSignature: numberSignature, + stringSignature: stringSignature + }; + }; + + 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; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } + + 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 { + lhsType = rhsType; + } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (exprType) { + if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { + if (!this.isReference(binaryExpression.left, lhsExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, exprType, lhsType, context); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); + } + } + + if (!exprType) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { + return this.findBestCommonType({ + getLength: function () { + return 2; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + } + } + }, context); + }; + + PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { + return this.findBestCommonType({ + getLength: function () { + return 3; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + case 2: + return type3; + } + } + }, context); + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + } + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; + var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; + + 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.pushNewContextualType(leftType); + var rightType = this.resolveAST(binex.right, true, context).type; + context.popAnyContextualType(); + + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + + this.resolveAST(binex.left, false, context); + } + + return this.resolveAST(binex.right, false, context).type; + }; + + PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { + var contextualType = context.getContextualType(); + return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + } else { + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { + var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; + var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; + + var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); + + var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); + + if (this.canTypeCheckAST(trinex, context)) { + this.setTypeChecked(trinex, context); + this.resolveAST(trinex.condition, false, context); + + if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); + } + } + } + + if (!conditionalTypesAreValid) { + return this.getNewErrorTypeSymbol(); + } + + return expressionType; + }; + + PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { + return true; + } + } else { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveAST(ast.expression, false, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckInvocationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + var targetSymbol = this.resolveAST(callEx.expression, false, context); + + if (callEx.argumentList.arguments) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + + var len = callEx.argumentList.arguments.nonSeparatorCount(); + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); + return this.getNewErrorTypeSymbol(); + } + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.expression.kind() === 50 /* SuperKeyword */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + targetSymbol = targetTypeSymbol.getConstructorMethod(); + this.resolveDeclaredSymbol(targetSymbol, context); + targetTypeSymbol = targetSymbol.type; + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); + this.resolveAST(callEx.argumentList.arguments, false, context); + + return this.getNewErrorTypeSymbol(); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + 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 explicitTypeArgs = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + var triedToInferTypeArgs = false; + + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var beforeResolutionSignatures = signatures; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + + if (signatures[i].isGeneric() && typeParameters.length) { + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); + } + + 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, 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; + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + + var errorCondition = null; + if (!signatures.length) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (!couldNotFindGenericOverload) { + 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); + } + return this.semanticInfoChain.anyTypeSymbol; + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); + } else if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + } + + 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 (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; + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + this.setSymbolForAST(callEx, symbol, context); + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckObjectCreationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + this.resolveAST(callEx.expression, false, context); + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (callEx.argumentList) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + var len = callEx.argumentList.arguments.nonSeparatorCount(); + + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { + if (!context.inProvisionalResolution()) { + additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); + } + context.postDiagnostic(diagnostic); + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var explicitTypeArgs = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny()) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); + } + } + + if (constructSignatures.length) { + if (callEx.argumentList && callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var triedToInferTypeArgs; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric()) { + typeParameters = constructSignatures[i].getTypeParameters(); + + 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, explicitTypeArgs.length]); + continue; + } + } 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 { + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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(constructSignatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } else { + if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); + } else { + returnType = this.instantiateTypeToAny(returnType, context); + } + } + + if (usedCallSignaturesInstead) { + 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(); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList && callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); + + return this.getNewErrorTypeSymbol(); + }; + + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { + var typeReplacementMap = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters = signatureAToInstantiate.getTypeParameters(); + var typeConstraint = null; + + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; + var enclosingTypeParameterMap; + + if (functionTypeA) { + enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + if (functionTypeB) { + enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); + + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); + }; + + PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { + var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; + + if (this.canTypeCheckAST(assertionExpression, context)) { + this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); + } + + return typeAssertionType; + }; + + PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { + this.setTypeChecked(assertionExpression, context); + + context.pushNewContextualType(typeAssertionType); + var exprType = this.resolveAST(assertionExpression.expression, true, context).type; + context.popAnyContextualType(); + + this.resolveDeclaredSymbol(typeAssertionType, context); + this.resolveDeclaredSymbol(exprType, context); + + var comparisonInfo = new TypeComparisonInfo(); + + 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); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { + var leftExpr = this.resolveAST(binaryExpression.left, false, context); + var leftType = leftExpr.type; + + context.pushNewContextualType(leftType); + var rightType = this.resolveAST(binaryExpression.right, true, context).type; + context.popAnyContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (!this.isReference(binaryExpression.left, leftExpr)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } else { + this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); + } + } + + return rightType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { + var instanceTypeSymbol = typeToReturn.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.widenType = function (type, ast, context) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (type.isArrayNamedTypeReference()) { + 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(); + + for (var i = 0; i < len; i++) { + var candidateType = collection.getTypeAtIndex(i); + if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { + return candidateType; + } + } + + return this.semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { + for (var i = 0; i < collection.getLength(); i++) { + var otherType = collection.getTypeAtIndex(i); + if (candidateType === otherType) { + continue; + } + + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { + t1 = this.getSymbolForRelationshipCheck(t1); + t2 = this.getSymbolForRelationshipCheck(t2); + + if (t1 === t2) { + return true; + } + + if (t1 && t2) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); + } + } + + return this.typesAreIdentical(t1, t2, context); + }; + + 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); + + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; + } + + if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + 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(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return false; + } + } + + if (t1.isPrimitive() !== t2.isPrimitive()) { + return 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) { + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { + return false; + } + + return true; + }; + + 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; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length !== sg2.length) { + return false; + } + + 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; + } + } + + return true; + }; + + 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; + } + + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; + } + + 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) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0] === decls2[0]; + } + + return false; + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { + return true; + } + + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); + }; + + 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.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) { + if (symbol && symbol.isTypeReference()) { + return symbol.getReferencedTypeSymbol(); + } + + return symbol; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + source = this.getSymbolForRelationshipCheck(source); + target = this.getSymbolForRelationshipCheck(target); + + if (source === target) { + return true; + } + + if (source && target) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + } + } + + 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); + + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + var sourceApparentType = this.getApparentType(source); + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; + } + + if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + 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) { + return true; + } + + return false; + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return assignableTo; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.getIsSpecialized() && target.getIsSpecialized()) { + 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, true); + + for (var i = 0; i < sourceTypeArguments.length; i++) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { + break; + } + } + + if (i === sourceTypeArguments.length) { + return true; + } else { + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + } + } + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } + } else { + if (isComparingInstantiatedSignatures) { + target = target.getBaseConstraint(this.semanticInfoChain); + } else { + return this.typesAreIdentical(target, sourceApparentType, context); + } + } + } + + 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; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); + + this.resolveDeclaredSymbol(targetProp, context); + + var targetPropType = targetProp.type; + + 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); + + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + + 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var comparisonInfoTypeArgumentsCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); + } + 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_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_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, isRelatable); + return isRelatable; + }; + + 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)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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++) { + 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; + } + } + } + + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + }; + + 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 (comparisonInfo) { + var names = getNames(true); + var code; + if (targetPropIsPrivate) { + 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 { + 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; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (targetDecl !== sourceDecl) { + if (comparisonInfo) { + var names = getNames(true); + + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + 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; + } + } + + if (sourceProp.isOptional && !targetProp.isOptional) { + if (comparisonInfo) { + 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); + } + return false; + } + + this.resolveDeclaredSymbol(sourceProp, context); + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); + + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + var names = getNames(false); + if (comparisonInfoPropertyTypeCheck && 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 { + 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 isSourcePropertyRelatableToTargetProperty; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); + var targetStringSig = targetIndexSigs.stringSignature; + var targetNumberSig = targetIndexSigs.numericSignature; + + if (targetStringSig || targetNumberSig) { + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); + var sourceStringSig = sourceIndexSigs.stringSignature; + var sourceNumberSig = sourceIndexSigs.numericSignature; + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + 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++) { + var mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + var nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + 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; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + + return false; + } + + return true; + }; + + 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; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; + + 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, [targetParameters.length])); + } + return false; + } + + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; + } + + 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) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + + return false; + } + } + + 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 (!areParametersRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + } + + return areParametersRelatable; + }); + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { + var _this = this; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = application.argumentList ? application.argumentList.arguments : null; + + var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { + if (hasOverloads && signature.isDefinition()) { + return false; + } + + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { + return false; + } + + return _this.overloadHasCorrectArity(signature, args); + }); + + var firstAssignableButNotSupertypeSignature = null; + var firstAssignableWithProvisionalErrorsSignature = null; + + for (var i = 0; i < initialCandidates.length; i++) { + var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); + if (applicability === 3 /* Subtype */) { + return initialCandidates[i]; + } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { + firstAssignableButNotSupertypeSignature = initialCandidates[i]; + } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { + firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; + } + } + + if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { + return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; + } else { + var target = this.getCallTargetErrorSpanAST(application); + if (comparisonInfo.message) { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); + } else { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); + } + } + + return null; + }; + + PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { + return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; + }; + + PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { + if (args == null) { + return signature.nonOptionalParamCount === 0; + } + + var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); + if (numberOfArgs < signature.nonOptionalParamCount) { + return false; + } + if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { + if (args === null) { + return 3 /* Subtype */; + } + + var isInVarArg = false; + var parameters = signature.parameters; + var paramType = null; + + var overloadApplicability = 3 /* Subtype */; + + for (var i = 0; i < args.nonSeparatorCount(); i++) { + if (!isInVarArg) { + this.resolveDeclaredSymbol(parameters[i], context); + + if (parameters[i].isVarArg) { + paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); + isInVarArg = true; + } else { + paramType = parameters[i].type; + } + } + + var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); + + if (statusOfCurrentArgument === 0 /* NotAssignable */) { + return 0 /* NotAssignable */; + } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { + overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; + } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { + overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; + } + } + + return overloadApplicability; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType.isAny()) { + return 3 /* Subtype */; + } else if (paramType.isError()) { + return 1 /* AssignableButWithProvisionalErrors */; + } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrowFunction = arg; + 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.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.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 */) { + return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); + } else { + return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); + } + }; + + PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { + if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + 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.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveObjectLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType === this.cachedArrayInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveArrayLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + var argSym = this.resolveAST(arg, false, context); + + if (argSym.type.isAlias()) { + var aliasSym = argSym.type; + argSym = aliasSym.getExportAssignedTypeSymbol(); + } + + comparisonInfo.stringConstantVal = arg; + return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { + var tempComparisonInfo = new TypeComparisonInfo(); + tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; + if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { + return 3 /* Subtype */; + } + + if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { + return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; + } + + if (!comparisonInfo.message) { + var enclosingSymbol = this.getEnclosingSymbolForAST(arg); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); + } + + return 0 /* NotAssignable */; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); + + 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 (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 inferenceResultTypes; + }; + + PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { + var enclosingDecl = this.getEnclosingDeclForAST(args); + var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); + return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; + }; + + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { + if (expressionType && parameterType) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); + return; + } + } + this.relateTypeToTypeParameters(expressionType, parameterType, 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; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType.isTypeParameter()) { + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); + return; + } + + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { + return; + } + + 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.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) { + return; + } + + var expressionTypeTypeArguments = expressionType.getTypeArguments(); + var parameterTypeArguments = parameterType.getTypeArguments(); + + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { + for (var i = 0; i < expressionTypeTypeArguments.length; i++) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } + } + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { + var _this = this; + var expressionReturnType = expressionSignature.returnType; + var parameterReturnType = parameterSignature.returnType; + + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); + + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + if (objectMember) { + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); + } + } + + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); + + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; + } + + 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) { + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!typeParameters.length) { + return typeToSpecialize; + } + + var typeArguments = null; + + 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) { + typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var type = this.createInstantiatedType(typeToSpecialize, typeArguments); + + 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(); + + var resolver = semanticInfoChain.getResolver(); + var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); + + if (resolver.canTypeCheckAST(sourceUnit, context)) { + resolver.resolveAST(sourceUnit, false, context); + resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); + + while (resolver.typeCheckCallBacks.length) { + var callBack = resolver.typeCheckCallBacks.pop(); + callBack(context); + } + + resolver.processPostTypeCheckWorkItems(context); + } + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; + } + + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); + + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; + + 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) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + 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)); + } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); + } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + 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_assignable_to_any_non_specialized_signature)); + } + } + } else if (definitionSignature && definitionSignature !== signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { + var errorCode; + + 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; + } 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + var isNamedType = typeSymbol.isNamedTypeSymbol(); + + if (typeSymbol.isArrayNamedTypeReference()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); + return; + } + + if (!isNamedType) { + var typeOfSymbol = typeSymbol.getTypeOfSymbol(); + if (typeOfSymbol) { + this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); + return; + } + } + + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); + if (typars) { + for (var i = 0; i < typars.length; i++) { + this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); + } + } + + if (!isNamedType) { + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); + } + + typeSymbol.inSymbolPrivacyCheck = false; + + if (!isNamedType) { + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + 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]) { + 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(); + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } else if (symbol.kind === 128 /* TypeAlias */) { + var aliasSymbol = symbol; + symbolIsVisible = true; + aliasSymbol.setTypeUsedExternally(); + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); + } + }; + + 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; + var messageCode; + + var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; + } + } + + var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { + var typeSymbol = symbol; + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { + var _this = this; + if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; + var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; + var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); + var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); + this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { + return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); + }); + } + } + + if (!isGetter && !isIndexSignature) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var parameter = parameters.astAt(argIndex); + + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { + var _this = this; + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); + } + } + + if (block) { + var reportErrorOnReturnExpressions = function (ast, walker) { + var go = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { + TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); + + var classSymbol = classDecl.getSymbol(); + return classSymbol.getExtendedTypes().length > 0; + }; + + PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { + if (ast.kind() === 213 /* InvocationExpression */) { + var invocationExpression = ast; + if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { + if (node && node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + if (this.isSuperInvocationExpression(expressionStatement.expression)) { + return true; + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { + if (block && block.statements && block.statements.childCount() > 0) { + return block.statements.childAt(0); + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { + TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); + + if (constructorDecl) { + var enclosingClass = constructorDecl.getParentDecl(); + + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.kind() === 242 /* Parameter */) { + return true; + } + + if (ast.kind() === 136 /* MemberVariableDeclaration */) { + var variableDeclarator = ast; + if (variableDeclarator.variableDeclarator.equalsValueClause) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { + var enclosingDecl = this.getEnclosingDeclForAST(expression); + + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var inArrowFunction = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + inArrowFunction = true; + continue; + } + + if (inArrowFunction) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = decl.getSymbol().getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); + var stringSignature = indexSignatures.stringSignature; + var numberSignature = indexSignatures.numericSignature; + + if (stringSignature || numberSignature) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { + var memberSymbol = member.getSymbol(); + var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); + if (relevantSignature) { + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); + } + } + } + } + } + }; + + PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { + if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { + return numberIndexSignature; + } else if (stringIndexSignature) { + return stringIndexSignature; + } + + return null; + }; + + PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { + 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + var foundError1 = false; + var foundError2 = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName, true); + if (extendedTypeProp) { + this.resolveDeclaredSymbol(extendedTypeProp, context); + foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError1) { + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + } + + if (foundError1 || foundError2) { + foundError = true; + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); + } + + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + } + } + } + + if (foundError) { + var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); + + 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; + } + + if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + + if (associatedContainerType) { + return associatedContainerType !== typeSymbol.getRootSymbol(); + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + + var baseType = this.resolveTypeReference(baseDeclAST, context).type; + + if (!baseType) { + return; + } + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (!baseType.isError()) { + if (isExtendedType) { + if (typeDeclIsClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); + } + } + return; + } else if (typeDeclIsClass && isExtendedType) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + 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)])); + } + } + + if (baseType.hasBase(typeSymbol)) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); + return; + } + + if (isExtendedType) { + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); + } else { + TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); + + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { + var _this = this; + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); + if (!extendsClause && !implementsClause) { + return; + } + + if (extendsClause) { + for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (implementsClause) { + for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); + } + } + } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { + var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { + return decl.ast().heritageClauses !== null; + }).ast(); + if (classOrInterface === firstInterfaceASTWithExtendsClause) { + this.typeCheckCallBacks.push(function (context) { + _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); + }); + } + } + }; + + PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { + var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); + + var inheritedMembersMap = TypeScript.createIntrinsicsObject(); + var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); + + var typeHasOwnNumberIndexer = false; + var typeHasOwnStringIndexer = false; + + if (typeSymbol.hasOwnIndexSignatures()) { + var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); + for (var i = 0; i < ownIndexSignatures.length; i++) { + if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + typeHasOwnNumberIndexer = true; + } else { + typeHasOwnStringIndexer = true; + } + } + } + var baseTypes = typeSymbol.getExtendedTypes(); + for (var i = 0; i < baseTypes.length; i++) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + return; + } + } + + if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { + return; + } + + this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; + var memberName = member.name; + + if (interfaceSymbol.findMember(memberName, false)) { + continue; + } + + this.resolveDeclaredSymbol(member, context); + + if (inheritedMembersMap[memberName]) { + var prevMember = inheritedMembersMap[memberName]; + 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; + } + } else { + inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); + } + } + + return false; + }; + + PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { + if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { + return false; + } + + var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { + var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; + + var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; + 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, 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; + } + } else { + allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } else if (parameterTypeIsNumber) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin) { + 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; + } + } else { + allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { + if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; + var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; + for (var memberName in inheritedMembers) { + var memberWithBaseOrigin = inheritedMembers[memberName]; + if (!memberWithBaseOrigin) { + continue; + } + + var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); + if (!relevantSignature) { + continue; + } + + var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; + + if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { + continue; + } + + 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_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_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])); + } + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + 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_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, [ + interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), + inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.isReference = function (ast, astSymbol) { + if (ast.kind() === 217 /* ParenthesizedExpression */) { + return this.isReference(ast.expression, astSymbol); + } + + if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { + return false; + } + + if (ast.kind() === 11 /* IdentifierName */) { + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { + return false; + } + + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { + return false; + } + + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { + return false; + } + } + + if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { + if (resolvedName) { + if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { + return this.semanticInfoChain.getEnclosingDecl(ast); + }; + + PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + return enclosingDecl ? enclosingDecl.getSymbol() : null; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { + if (resolvedName) { + if (resolvedName.anyDeclHasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var memberClass = memberContainer.getDeclarations()[0].ast(); + TypeScript.Debug.assert(memberClass); + + var containingClass = this.getEnclosingClassDeclaration(name); + + if (!containingClass || containingClass !== memberClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { + if (type.isPrimitive()) { + return type; + } + + if (type.isError()) { + return type; + } + + if (typeParameterArgumentMap[type.pullSymbolID]) { + return typeParameterArgumentMap[type.pullSymbolID]; + } + + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); + } + + if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + } + + return type; + }; + + 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 rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); + + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); + + 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) { + for (var j = 0; j < parameters.length; j++) { + parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + instantiatedSignature.hasVarArgs = true; + } + instantiatedSignature.addParameter(parameter, parameter.isOptional); + + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); + } + } + + return instantiatedSignature; + }; + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; + + function getPropertyAssignmentNameTextFromIdentifier(identifier) { + if (identifier.kind() === 11 /* IdentifierName */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 14 /* StringLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 13 /* NumericLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; + + function isTypesOnlyLocation(ast) { + while (ast && ast.parent) { + switch (ast.parent.kind()) { + case 244 /* TypeAnnotation */: + return true; + case 127 /* TypeQuery */: + return false; + case 125 /* ConstructorType */: + var constructorType = ast.parent; + if (constructorType.type === ast) { + return true; + } + break; + case 123 /* FunctionType */: + var functionType = ast.parent; + if (functionType.type === ast) { + return true; + } + break; + case 239 /* Constraint */: + var constraint = ast.parent; + if (constraint.type === ast) { + return true; + } + break; + case 220 /* CastExpression */: + var castExpression = ast.parent; + return castExpression.type === ast; + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + return true; + case 228 /* TypeArgumentList */: + return true; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + case 129 /* FunctionDeclaration */: + case 145 /* MethodSignature */: + case 212 /* MemberAccessExpression */: + case 242 /* Parameter */: + return false; + } + + ast = ast.parent; + } + + return false; + } + TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfoChain = (function () { + function SemanticInfoChain(compiler, logger) { + this.compiler = compiler; + this.logger = logger; + this.documents = []; + this.fileNameToDocument = TypeScript.createIntrinsicsObject(); + this.anyTypeDecl = null; + this.booleanTypeDecl = null; + this.numberTypeDecl = null; + this.stringTypeDecl = null; + this.nullTypeDecl = null; + this.undefinedTypeDecl = null; + this.voidTypeDecl = null; + this.undefinedValueDecl = null; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + this.undefinedValueSymbol = null; + this.emptyTypeSymbol = null; + this.astSymbolMap = []; + this.astAliasSymbolMap = []; + this.astCallResolutionDataMap = []; + this.declSymbolMap = []; + this.declSignatureSymbolMap = []; + this.declCache = null; + this.symbolCache = null; + this.fileNameToDiagnostics = null; + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + 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); + 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 */, 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 || null; + }; + + SemanticInfoChain.prototype.lineMap = function (fileName) { + return this.getDocument(fileName).lineMap(); + }; + + SemanticInfoChain.prototype.fileNames = function () { + if (this._fileNames === null) { + this._fileNames = this.documents.slice(1).map(function (s) { + return s.fileName; + }); + } + + return this._fileNames; + }; + + SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { + newSymbol.addDeclaration(decl); + decl.setSymbol(newSymbol); + newSymbol.setResolved(); + + return newSymbol; + }; + + SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { + var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { + var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); + newSymbol.type = type; + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.resetGlobalSymbols = function () { + this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); + this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); + this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); + this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); + this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); + this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); + this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); + this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); + + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); + var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + emptyTypeDecl.setSymbol(emptyTypeSymbol); + emptyTypeSymbol.addDeclaration(emptyTypeDecl); + emptyTypeSymbol.setResolved(); + this.emptyTypeSymbol = emptyTypeSymbol; + }; + + SemanticInfoChain.prototype.addDocument = function (document) { + var fileName = document.fileName; + + var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (existingIndex < 0) { + this.documents.push(document); + } else { + this.documents[existingIndex] = document; + } + + this.fileNameToDocument[fileName] = document; + + this.invalidate(); + }; + + SemanticInfoChain.prototype.removeDocument = function (fileName) { + TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); + var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (index > 0) { + this.fileNameToDocument[fileName] = undefined; + this.documents.splice(index, 1); + this.invalidate(); + } + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[cacheID]; + + if (!symbol) { + for (var i = 0, n = this.documents.length; i < n; i++) { + var topLevelDecl = this.documents[i].topLevelDecl(); + + var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); + if (symbol) { + break; + } + + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { + return null; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { + var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; + + var foundDecls = topLevelDecl.searchChildDecls(name, kind); + + for (var j = 0; j < foundDecls.length; j++) { + var foundDecl = foundDecls[j]; + + if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { + break; + } + + var symbol = foundDecls[j].getSymbol(); + if (symbol) { + return symbol; + } + } + + return null; + }; + + SemanticInfoChain.prototype.findExternalModule = function (id) { + id = TypeScript.normalizePath(id); + + var tsFile = id + ".ts"; + var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); + symbol = this.symbolCache[tsCacheID]; + if (symbol != undefined) { + return symbol; + } + + 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 isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + symbol = dynamicModuleDecl.getSymbol(); + + 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 null; + }; + + SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { + var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); + + var symbol = this.symbolCache[cacheID]; + if (symbol == undefined) { + symbol = null; + for (var i = 0; i < this.documents.length; i++) { + var document = this.documents[i]; + var topLevelDecl = document.topLevelDecl(); + + if (!topLevelDecl.isExternalModule()) { + var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); + if (dynamicModules.length) { + symbol = dynamicModules[0].getSymbol(); + break; + } + } + } + + this.symbolCache[cacheID] = symbol; + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + var declsToSearch = this.topLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + + 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, kind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls === TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + 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; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + } + }; + + SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { + if (typeof oldSettings === "undefined") { oldSettings = null; } + if (typeof newSettings === "undefined") { newSettings = null; } + TypeScript.PullTypeResolver.globalTypeCheckPhase++; + + var cleanStart = new Date().getTime(); + + this.astSymbolMap.length = 0; + this.astAliasSymbolMap.length = 0; + this.astCallResolutionDataMap.length = 0; + + this.declCache = TypeScript.createIntrinsicsObject(); + this.symbolCache = TypeScript.createIntrinsicsObject(); + this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + + this.declSymbolMap.length = 0; + this.declSignatureSymbolMap.length = 0; + + if (oldSettings && newSettings) { + if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { + for (var i = 1, n = this.documents.length; i < n; i++) { + this.documents[i].invalidate(); + } + } + } + + TypeScript.pullSymbolID = 0; + + this.resetGlobalSymbols(); + + var cleanEnd = new Date().getTime(); + }; + + SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()] || null; + }; + + SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { + this.astAliasSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { + return this.astAliasSymbolMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { + return this.astCallResolutionDataMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; + } + }; + + SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { + this.declSymbolMap[decl.declID] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { + return this.declSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { + this.declSignatureSymbolMap[decl.declID] = signatureSymbol; + }; + + SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { + return this.declSignatureSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { + var fileName = diagnostic.fileName(); + var diagnostics = this.fileNameToDiagnostics[fileName]; + if (!diagnostics) { + diagnostics = []; + this.fileNameToDiagnostics[fileName] = diagnostics; + } + + diagnostics.push(diagnostic); + }; + + SemanticInfoChain.prototype.getDiagnostics = function (fileName) { + var diagnostics = this.fileNameToDiagnostics[fileName]; + return diagnostics || []; + }; + + SemanticInfoChain.prototype.getBinder = function () { + if (!this._binder) { + this._binder = new TypeScript.PullSymbolBinder(this); + } + + return this._binder; + }; + + SemanticInfoChain.prototype.getResolver = function () { + if (!this._resolver) { + this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); + } + + return this._resolver; + }; + + SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); + indexParameterSymbol.type = indexParamType; + indexSignature.addParameter(indexParameterSymbol); + indexSignature.returnType = returnType; + indexSignature.setResolved(); + indexParameterSymbol.setResolved(); + + containingSymbol.addIndexSignature(indexSignature); + + 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); + indexParameterSymbol.addDeclaration(indexParamDecl); + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast) { + var document = this.getDocument(ast.fileName()); + + if (document) { + return document._getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { + return this.getDocument(ast.fileName()).getEnclosingDecl(ast); + }; + + SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { + this.getDocument(decl.fileName())._setDeclForAST(ast, decl); + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var document = this.getDocument(decl.fileName()); + if (document) { + return document._getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { + this.getDocument(decl.fileName())._setASTForDecl(decl, ast); + }; + + SemanticInfoChain.prototype.topLevelDecl = function (fileName) { + var document = this.getDocument(fileName); + if (document) { + return document.topLevelDecl(); + } + + return null; + }; + + SemanticInfoChain.prototype.topLevelDecls = function () { + if (!this._topLevelDecls) { + this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { + return u.topLevelDecl(); + }); + } + + return this._topLevelDecls; + }; + + 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, 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; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { + this.document = document; + this.semanticInfoChain = semanticInfoChain; + this.propagateEnumConstants = propagateEnumConstants; + this.isDeclareFile = false; + this.parentChain = []; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + return DeclCollectionContext; + })(); + + function containingModuleHasExportAssignment(ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = ast; + return moduleDecl.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } else if (ast.kind() === 120 /* SourceUnit */) { + var sourceUnit = ast; + return sourceUnit.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } + + ast = ast.parent; + } + + return false; + } + + function isParsingAmbientModule(ast, context) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { + return true; + } + } + + ast = ast.parent; + } + + return false; + } + + function preCollectImportDecls(ast, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + + var parent = context.getParent(); + + if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { + declFlags |= 1 /* Exported */; + } + + 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 fileName = sourceUnit.fileName(); + + var isExternalModule = context.document.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); + + context.isDeclareFile = context.document.isDeclareFile(); + + context.pushParent(decl); + + if (isExternalModule) { + var declFlags = 1 /* Exported */; + if (TypeScript.isDTSFile(fileName)) { + declFlags |= 8 /* Ambient */; + } + + var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); + var kind = 32 /* DynamicModule */; + var valueText = TypeScript.quoteStr(fileName); + + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); + + context.semanticInfoChain.setASTForDecl(decl, sourceUnit); + + context.semanticInfoChain.setDeclForAST(sourceUnit, decl); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, sourceUnit, context); + } + + context.pushParent(decl); + } + } + + function preCollectEnumDecls(enumDecl, context) { + var declFlags = 0 /* None */; + var enumName = enumDecl.identifier.valueText(); + + if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + declFlags |= 4096 /* Enum */; + var kind = 64 /* Enum */; + + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); + context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); + context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); + + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); + enumDeclaration.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); + + context.pushParent(enumDeclaration); + } + + function createEnumElementDecls(propertyDecl, context) { + var parent = context.getParent(); + + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function preCollectModuleDecls(moduleDecl, context) { + var declFlags = 0 /* None */; + + var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); + + var isDynamic = moduleDecl.stringLiteral !== null; + + if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + + 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()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); + } + + context.pushParent(decl); + } else { + var moduleNames = getModuleNames(moduleDecl.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + var moduleName = moduleNames[i]; + + var specificFlags = declFlags; + if (i > 0) { + specificFlags |= 1 /* Exported */; + } + + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleName, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleName); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleName, context); + } + + context.pushParent(decl); + } + } + } + + function getModuleNames(name, result) { + result = result || []; + + if (name.kind() === 121 /* QualifiedName */) { + getModuleNames(name.left, result); + result.push(name.right); + } else { + result.push(name); + } + + return result; + } + TypeScript.getModuleNames = getModuleNames; + + 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.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); + } + + function containsExecutableCode(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); + + if (member.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = member; + + if (containsExecutableCode(moduleDecl.moduleElements)) { + return true; + } + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + } + + function preCollectClassDecls(classDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var parent = context.getParent(); + + 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); + + decl.setValueDecl(constructorDecl); + + context.semanticInfoChain.setDeclForAST(classDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, classDecl); + context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); + + context.pushParent(decl); + } + + function preCollectObjectTypeDecls(objectType, context) { + if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { + return; + } + + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setDeclForAST(objectType, decl); + context.semanticInfoChain.setASTForDecl(decl, objectType); + + context.pushParent(decl); + } + + function preCollectInterfaceDecls(interfaceDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { + declFlags |= 1 /* Exported */; + } + + var parent = context.getParent(); + + 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); + + context.pushParent(decl); + } + + function preCollectParameterDecl(argDecl, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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 */) { + decl.setFlag(67108864 /* ConstructorParameter */); + } + + var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); + var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; + if (isPublicOrPrivate && isInConstructor) { + var parentsParent = context.parentChain[context.parentChain.length - 2]; + + 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 */) { + propDecl.setFlag(67108864 /* ConstructorParameter */); + } + + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setASTForDecl(propDecl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, decl); + } + + parent.addVariableDeclToGroup(decl); + } + + function preCollectTypeParameterDecl(typeParameterDecl, context) { + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); + context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = 4096 /* Property */; + + if (propertyDecl.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var parent = context.getParent(); + + 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); + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 512 /* Variable */; + + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); + if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + 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); + context.semanticInfoChain.setDeclForAST(varDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, varDecl); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectVarDecls(ast, context) { + if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { + return; + } + + var varDecl = ast; + createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + 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); + context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); + + context.pushParent(decl); + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + 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); + context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); + + context.pushParent(decl); + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + 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); + context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); + + context.pushParent(decl); + } + + function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { + if (typeof displayName === "undefined") { displayName = null; } + var declFlags = 0 /* None */; + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { + declFlags |= 8192 /* ArrowFunction */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = id ? id.text() : ""; + var displayNameText = displayName ? displayName.text() : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); + context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); + + context.pushParent(decl); + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrow = functionExpressionDeclAST; + var declFlags = 4 /* Public */; + + var parent = context.getParent(); + + if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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); + + parent.addVariableDeclToGroup(decl); + } + } + + function createMemberFunctionDeclaration(funcDecl, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!funcDecl.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(funcDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDecl); + + context.pushParent(decl); + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 4194304 /* IndexSignature */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); + + context.pushParent(decl); + } + + function createCallSignatureDeclaration(callSignature, context) { + var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; + + if (!isChildOfObjectType) { + return; + } + + var declFlags = 2048 /* Signature */; + var declType = 1048576 /* CallSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(callSignature, decl); + context.semanticInfoChain.setASTForDecl(decl, callSignature); + + context.pushParent(decl); + } + + function createMethodSignatureDeclaration(method, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + declFlags |= 4 /* Public */; + declFlags |= 2048 /* Signature */; + + if (method.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(method, decl); + context.semanticInfoChain.setASTForDecl(decl, method); + + context.pushParent(decl); + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 2097152 /* ConstructSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); + + context.pushParent(decl); + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); + + context.pushParent(decl); + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); + + context.pushParent(decl); + } + + function createFunctionExpressionDeclaration(expression, context) { + createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); + + context.pushParent(decl); + } + + function preCollectCatchDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 268435456 /* CatchBlock */; + + 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); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + + var declFlags = 0 /* None */; + var declType = 1024 /* CatchVariable */; + + 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); + context.semanticInfoChain.setDeclForAST(ast.identifier, decl); + context.semanticInfoChain.setASTForDecl(decl, ast.identifier); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectWithDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 134217728 /* WithBlock */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectObjectLiteralDecls(ast, context) { + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); + + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectSimplePropertyAssignmentDecls(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()); + + context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); + } + + function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { + var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); + + 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); + + createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); + } + + function preCollectDecls(ast, context) { + switch (ast.kind()) { + case 120 /* SourceUnit */: + preCollectScriptDecls(ast, context); + break; + case 132 /* EnumDeclaration */: + preCollectEnumDecls(ast, context); + break; + case 243 /* EnumElement */: + createEnumElementDecls(ast, context); + break; + case 130 /* ModuleDeclaration */: + preCollectModuleDecls(ast, context); + break; + case 131 /* ClassDeclaration */: + preCollectClassDecls(ast, context); + break; + case 128 /* InterfaceDeclaration */: + preCollectInterfaceDecls(ast, context); + break; + case 122 /* ObjectType */: + preCollectObjectTypeDecls(ast, context); + break; + case 242 /* Parameter */: + preCollectParameterDecl(ast, context); + break; + case 136 /* MemberVariableDeclaration */: + createMemberVariableDeclaration(ast, context); + break; + case 141 /* PropertySignature */: + createPropertySignature(ast, context); + break; + case 225 /* VariableDeclarator */: + preCollectVarDecls(ast, context); + break; + case 137 /* ConstructorDeclaration */: + createClassConstructorDeclaration(ast, context); + break; + case 139 /* GetAccessor */: + createGetAccessorDeclaration(ast, context); + break; + case 140 /* SetAccessor */: + createSetAccessorDeclaration(ast, context); + break; + case 222 /* FunctionExpression */: + createFunctionExpressionDeclaration(ast, context); + break; + case 135 /* MemberFunctionDeclaration */: + createMemberFunctionDeclaration(ast, context); + break; + case 144 /* IndexSignature */: + createIndexSignatureDeclaration(ast, context); + break; + case 123 /* FunctionType */: + createFunctionTypeDeclaration(ast, context); + break; + case 125 /* ConstructorType */: + createConstructorTypeDeclaration(ast, context); + break; + case 142 /* CallSignature */: + createCallSignatureDeclaration(ast, context); + break; + case 143 /* ConstructSignature */: + createConstructSignatureDeclaration(ast, context); + break; + case 145 /* MethodSignature */: + createMethodSignatureDeclaration(ast, context); + break; + case 129 /* FunctionDeclaration */: + createFunctionDeclaration(ast, context); + break; + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + createAnyFunctionExpressionDeclaration(ast, null, context); + break; + case 133 /* ImportDeclaration */: + preCollectImportDecls(ast, context); + break; + case 238 /* TypeParameter */: + preCollectTypeParameterDecl(ast, context); + break; + case 236 /* CatchClause */: + preCollectCatchDecls(ast, context); + break; + case 163 /* WithStatement */: + preCollectWithDecls(ast, context); + break; + case 215 /* ObjectLiteralExpression */: + preCollectObjectLiteralDecls(ast, context); + break; + case 240 /* SimplePropertyAssignment */: + preCollectSimplePropertyAssignmentDecls(ast, context); + break; + case 241 /* FunctionPropertyAssignment */: + preCollectFunctionPropertyAssignmentDecls(ast, context); + break; + } + } + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, context) { + var currentDecl = context.getParent(); + + if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { + if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + return; + } + } + + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDeclaration = ast; + if (moduleDeclaration.stringLiteral) { + TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); + context.popParent(); + } else { + var moduleNames = getModuleNames(moduleDeclaration.name); + for (var i = moduleNames.length - 1; i >= 0; i--) { + var moduleName = moduleNames[i]; + TypeScript.Debug.assert(currentDecl.ast() === moduleName); + context.popParent(); + currentDecl = context.getParent(); + } + } + } + + if (ast.kind() === 132 /* EnumDeclaration */) { + computeEnumElementConstantValues(ast, currentDecl, context); + } + + while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { + context.popParent(); + currentDecl = context.getParent(); + } + } + + function computeEnumElementConstantValues(ast, enumDecl, context) { + TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); + + var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); + var inConstantSection = !isAmbientEnum; + var currentConstantValue = 0; + var enumMemberDecls = enumDecl.getChildDecls(); + + for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { + var enumElement = ast.enumElements.nonSeparatorAt(i); + var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { + return context.semanticInfoChain.getASTForDecl(d) === enumElement; + }); + + TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); + + if (enumElement.equalsValueClause === null) { + if (inConstantSection) { + enumElementDecl.constantValue = currentConstantValue; + currentConstantValue++; + } + } else { + enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); + if (enumElementDecl.constantValue !== null && !isAmbientEnum) { + inConstantSection = true; + currentConstantValue = enumElementDecl.constantValue + 1; + } else { + inConstantSection = false; + } + } + + TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); + } + } + + function computeEnumElementConstantValue(expression, enumMemberDecls, context) { + TypeScript.Debug.assert(expression); + + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { + var token; + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + token = expression.operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; + } else if (context.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var name = expression; + var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { + return d.name === name.valueText(); + }); + + return matchingEnumElement ? matchingEnumElement.constantValue : null; + + case 202 /* LeftShiftExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left << right; + + case 189 /* BitwiseOrExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left | right; + } + + return null; + } else { + return null; + } + } + + (function (DeclarationCreator) { + function create(document, semanticInfoChain, compilationSettings) { + var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); + + TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); + + return declCollectionContext.getParent(); + } + DeclarationCreator.create = create; + })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); + var DeclarationCreator = TypeScript.DeclarationCreator; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBinder = (function () { + 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 */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.hasBeenBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind === 262144 /* GetAccessor */) { + parent = parent.getGetter(); + } else if (parentDeclKind === 524288 /* SetAccessor */) { + parent = parent.getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = parent.getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = startingDecl.getParentPath(); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + }; + + PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { + var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; + var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; + var name = decl.name; + if (parent) { + var isExported = (decl.flags & 1 /* Exported */) !== 0; + + var prevSymbol = null; + if (lookingForValue) { + prevSymbol = parent.findContainedNonMember(name); + } else if (lookingForType) { + prevSymbol = parent.findContainedNonMemberType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); + } + var prevIsExported = !prevSymbol; + if (!prevSymbol) { + if (lookingForValue) { + prevSymbol = parent.findMember(name, false); + } else if (lookingForType) { + prevSymbol = parent.findNestedType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findNestedContainer(name, searchKind); + } + } + + if (isExported && prevIsExported) { + return prevSymbol; + } + if (prevSymbol) { + var prevDecls = prevSymbol.getDeclarations(); + var lastPrevDecl = prevDecls[prevDecls.length - 1]; + var parentDecl = decl.getParentDecl(); + var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); + if (parentDecl !== prevParentDecl) { + return null; + } + + return prevSymbol; + } + } else { + var parentDecl = decl.getParentDecl(); + if (parentDecl && parentDecl.kind === 1 /* Script */) { + return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); + } else { + var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); + return prevDecls[0] && prevDecls[0].getSymbol(); + } + } + + return null; + }; + + PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { + if (typeof reportError === "undefined") { reportError = true; } + 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 (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()]); + } + return false; + } + + 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; + + var enumContainerSymbol = null; + var enumInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var enumInstanceDecl = enumContainerDecl.getValueDecl(); + + var enumDeclKind = enumContainerDecl.kind; + + var parent = this.getParent(enumContainerDecl); + var parentInstanceSymbol = this.getParent(enumContainerDecl, true); + var parentDecl = enumContainerDecl.getParentDecl(); + var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); + + var isExported = enumContainerDecl.flags & 1 /* Exported */; + + var createdNewSymbol = false; + + enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); + + if (enumContainerSymbol) { + if (enumContainerSymbol.kind !== enumDeclKind) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); + enumContainerSymbol = null; + } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { + enumContainerSymbol = null; + } + } + + if (enumContainerSymbol) { + enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); + } else { + enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); + } + } + + enumContainerSymbol.addDeclaration(enumContainerDecl); + enumContainerDecl.setSymbol(enumContainerSymbol); + + this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); + this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); + + if (!enumInstanceSymbol) { + var variableSymbol = null; + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] === enumContainerDecl) { + break; + } + + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol) { + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + enumInstanceSymbol = variableSymbol; + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); + } + + enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + enumInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); + } + } + + if (createdNewSymbol && parent) { + if (enumContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(enumContainerSymbol); + } else { + parent.addEnclosedNonMemberType(enumContainerSymbol); + } + } + + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } + var valueDecl = enumContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + 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(); + + enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; + + 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(); + + 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); + if (!moduleDeclAST) { + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); + + moduleDeclAST = moduleNameAST; + } + + var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); + var searchKind = 164 /* SomeContainer */; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; + + if (parent && moduleKind === 32 /* DynamicModule */) { + this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); + } + + var createdNewSymbol = false; + + moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); + + if (moduleContainerTypeSymbol) { + if (moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); + } + + moduleContainerTypeSymbol = null; + } 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) { + moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); + this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); + + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); + } + } + } + + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); + + 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); + } + } + + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(importSymbol); + } else { + parent.addEnclosedNonMemberContainer(importSymbol); + } + } + }; + + 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; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + 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, 58728795 /* SomeType */, parent); + + if (classSymbol && classSymbol.kind === 16 /* Interface */) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); + classSymbol = null; + } + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); + this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + 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; + + if (!constructorSymbol) { + var siblingValueDecls = null; + if (parentDecl) { + siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); + + if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { + constructorSymbol = siblingValueDecls[0].getSymbol(); + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + constructorSymbol.setIsSynthesized(); + constructorSymbol.type = constructorTypeSymbol; + } + + classSymbol.setConstructorMethod(constructorSymbol); + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); + + if (interfaceSymbol) { + if (!(interfaceSymbol.kind & acceptableSharedKind)) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); + interfaceSymbol = null; + } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { + interfaceSymbol = null; + } + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + 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; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + 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; + variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); + var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); + var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); + 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 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 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.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 || 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); + variableSymbol = null; + parentHadSymbol = false; + } + } + + if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { + variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); + } + } + + if ((declFlags & 118784 /* ImplicitVariable */) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + if (!parent && parentDecl.kind === 1 /* Script */) { + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); + this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfoChain.getASTForDecl(decl); + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & 102400 /* SomeInitializedModule */) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + 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); + } + variableDeclaration.setSymbol(variableSymbol); + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + if (!variableSymbol.hasDeclaration(variableDeclaration)) { + variableSymbol.addDeclaration(variableDeclaration); + } + 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); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); + + var declName = variableDeclaration.name; + + var variableSymbol = new TypeScript.PullSymbol(declName, declKind); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + + this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); + }; + + PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + var propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + + var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { + var parameters = []; + var params = TypeScript.createIntrinsicsObject(); + var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); + + if (parameterList) { + for (var i = 0, n = parameterList.length; i < n; i++) { + var argDecl = parameterList.astAt(i); + var id = parameterList.identifierAt(i); + var decl = this.semanticInfoChain.getDeclForAST(argDecl); + var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); + var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); + + if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { + parameterSymbol.isVarArg = 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); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); + + if (functionSymbol) { + 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); + functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); + } + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { + signature.hasVarArgs = true; + } + + var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); + + 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; + if (name) { + this.semanticInfoChain.setSymbolForAST(name, functionSymbol); + } + + this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); + + if (parameters.lastParameterIsRest()) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + + var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; + + TypeScript.Debug.assert(nameAST); + + this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); + this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); + + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); + if (TypeScript.lastParameterIsRest(parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); + signature.addTypeParameter(typeParameter); + } else { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { + var prototypeStr = "prototype"; + + var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); + if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { + 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], this.semanticInfoChain); + + prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + prototypeSymbol.setIsSynthesized(); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = classTypeSymbol; + constructorTypeSymbol.addMember(prototypeSymbol); + + if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { + var resolver = this.semanticInfoChain.getResolver(); + prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); + } + prototypeSymbol.setResolved(); + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); + constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.appendConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + constructSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + callSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); + + var parent = this.getParent(indexSignatureDeclaration); + parent.addIndexSignature(indexSignature); + indexSignature.setContainer(parent); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + + getterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); + } + }; + + 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) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + this.bindEnumDeclarationToPullSymbol(decl); + break; + + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 512 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 1024 /* CatchVariable */: + this.bindCatchVariableToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + this.bindEnumMemberDeclarationToPullSymbol(decl); + break; + + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 128 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + decl.getParentDecl().getSymbol(); + break; + + case 268435456 /* CatchBlock */: + case 134217728 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); + this.declsBeingBound.pop(); + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (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(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + + if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (functionDecl.kind === 4194304 /* IndexSignature */) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + + function isNameNumeric(name) { + return isFinite(+name); + } + PullHelpers.isNameNumeric = isNameNumeric; + + function typeSymbolsAreIdentical(a, b) { + if (a.isTypeReference() && !a.getIsSpecialized()) { + a = a.referencedTypeSymbol; + } + + if (b.isTypeReference() && !b.getIsSpecialized()) { + b = b.referencedTypeSymbol; + } + + return a === b; + } + PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; + + function getRootType(type) { + var rootType = type.getRootSymbol(); + + while (true) { + if (type === rootType) { + return type; + } + + type = rootType; + rootType = type.getRootSymbol(); + } + } + PullHelpers.getRootType = getRootType; + + function isSymbolLocal(symbol) { + var container = symbol.getContainer(); + if (container) { + var containerKind = container.kind; + if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { + return true; + } + + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { + return true; + } + } + + 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; + +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.fileResolutionIOTime = 0; + TypeScript.fileResolutionScanImportsTime = 0; + TypeScript.fileResolutionImportFileSearchTime = 0; + TypeScript.fileResolutionGetDefaultLibraryTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.compilerResolvePathTime = 0; + TypeScript.compilerDirectoryNameTime = 0; + TypeScript.compilerDirectoryExistsTime = 0; + TypeScript.compilerFileExistsTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + 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(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } + this.outputFiles = []; + this.emitOutputResult = emitOutputResult; + } + return EmitOutput; + })(); + TypeScript.EmitOutput = EmitOutput; + + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); + var OutputFileType = TypeScript.OutputFileType; + + var OutputFile = (function () { + function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { + if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.text = text; + this.fileType = fileType; + this.sourceMapEntries = sourceMapEntries; + } + return OutputFile; + })(); + TypeScript.OutputFile = OutputFile; + + var CompileResult = (function () { + function CompileResult() { + this.diagnostics = []; + this.outputFiles = []; + } + CompileResult.fromDiagnostics = function (diagnostics) { + var result = new CompileResult(); + result.diagnostics = diagnostics; + return result; + }; + + CompileResult.fromOutputFiles = function (outputFiles) { + var result = new CompileResult(); + result.outputFiles = outputFiles; + return result; + }; + return CompileResult; + })(); + TypeScript.CompileResult = CompileResult; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, _settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } + this.logger = logger; + this._settings = _settings; + this.semanticInfoChain = null; + this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); + } + TypeScriptCompiler.prototype.compilationSettings = function () { + return this._settings; + }; + + TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { + var oldSettings = this._settings; + this._settings = newSettings; + + if (!compareDataObjects(oldSettings, newSettings)) { + this.semanticInfoChain.invalidate(oldSettings, newSettings); + } + }; + + TypeScriptCompiler.prototype.getDocument = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.semanticInfoChain.getDocument(fileName); + }; + + TypeScriptCompiler.prototype.cleanupSemanticCache = function () { + this.semanticInfoChain.invalidate(); + }; + + TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); + + this.semanticInfoChain.addDocument(document); + }; + + TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); + + this.semanticInfoChain.addDocument(updatedDocument); + }; + + TypeScriptCompiler.prototype.removeFile = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + this.semanticInfoChain.removeDocument(fileName); + }; + + TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { + if (document.emitToOwnOutputFile()) { + var updatedFileName = document.fileName; + if (emitOptions.outputDirectory() !== "") { + updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); + updatedFileName = emitOptions.outputDirectory() + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(emitOptions.sharedOutputFile(), true); + } + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + var printReason = false; + + if (document.emitToOwnOutputFile()) { + var result = document.byteOrderMark !== 0 /* None */; + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + } + return result; + } else { + var fileNames = this.fileNames(); + + var result = false; + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + + if (document.isExternalModule()) { + continue; + } + + if (document.byteOrderMark !== 0 /* None */) { + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + result = true; + } else { + return true; + } + } + } + + return result; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype._shouldEmit = function (document) { + return !document.isDeclareFile(); + }; + + TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { + if (!this.compilationSettings().generateDeclarationFiles()) { + return false; + } + + return this._shouldEmit(document); + }; + + TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); + + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); + } + + declarationEmitter.emitDeclarations(sourceUnit); + return declarationEmitter; + }; + + TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmitDeclarations(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFile()); + } + } else { + sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var sharedEmitter = null; + var fileNames = this.fileNames(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileNames[i]); + + sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return emitOutput; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, null); + return emitOutput; + } else { + return this.emitAllDeclarations(resolvePath); + } + }; + + 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; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmit(document)); + + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); + var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); + + if (this.compilationSettings().mapSourceFiles()) { + var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); + emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); + } + } else if (this.compilationSettings().mapSourceFiles()) { + emitter.setSourceMapperNewSourceFile(document); + } + + emitter.setDocument(document); + emitter.emitJavascript(sourceUnit, false); + + return emitter; + }; + + TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmit(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFiles()); + } + } else { + sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var fileNames = this.fileNames(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + sharedEmitter = this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); + } + + TypeScript.emitTime += new Date().getTime() - start; + return emitOutput; + }; + + TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, null); + return emitOutput; + } else { + return this.emitAll(resolvePath); + } + }; + + TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { + if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } + return new CompilerIterator(this, resolvePath, continueOnDiagnostics); + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + + TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { + return this.getDocument(fileName).sourceUnit(); + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + var errors = this.semanticInfoChain.getDiagnostics(fileName); + + errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); + errors.sort(function (d1, d2) { + if (d1.fileName() < d2.fileName()) { + return -1; + } else if (d1.fileName() > d2.fileName()) { + return 1; + } + + if (d1.start() < d2.start()) { + return -1; + } else if (d1.start() > d2.start()) { + return 1; + } + + var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; + var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; + if (code1 < code2) { + return -1; + } else if (code1 > code2) { + return 1; + } + + return 0; + }); + + 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++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var ast = this.semanticInfoChain.getASTForDecl(decl); + if (!ast) { + return null; + } + + var enclosingDecl = resolver.getEnclosingDecl(decl); + if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { + return this.getSymbolOfDeclaration(enclosingDecl); + } + + return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { + var scriptName = document.fileName; + + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + var inWithBlock = false; + + var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); + + if (!ast) { + return null; + } + + var path = this.getASTPath(ast); + + for (var i = 0, n = path.length; i < n; i++) { + var current = path[i]; + + switch (current.kind()) { + case 222 /* FunctionExpression */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + if (propagateContextualTypes) { + resolver.resolveAST(current, true, resolutionContext); + } + break; + + case 136 /* MemberVariableDeclaration */: + var memberVariable = current; + inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); + break; + + case 225 /* VariableDeclarator */: + var variableDeclarator = current; + inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); + break; + + case 213 /* InvocationExpression */: + case 216 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.kind() === 216 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = path[i + 3]; + if (argExpression) { + for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { + if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext); + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 214 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 215 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.propertyAssignments; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { + if (memberDecls.nonSeparatorAt(j) === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + } + + break; + + case 174 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path[i + 1] && path[i + 1] === assignmentExpression.right) { + var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + 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; + + case 150 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 122 /* ObjectType */: + if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { + resolver.resolveAST(current, false, resolutionContext); + } + + break; + + case 163 /* WithStatement */: + inWithBlock = true; + break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; + } + + var decl = this.semanticInfoChain.getDeclForAST(current); + if (decl) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { + if (ast.parent.kind() === 212 /* MemberAccessExpression */) { + if (ast.parent.name === ast) { + ast = ast.parent; + } + } else if (ast.parent.kind() === 121 /* QualifiedName */) { + if (ast.parent.right === ast) { + ast = ast.parent; + } + } + } + + return { + ast: ast, + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment, + inWithBlock: inWithBlock + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + resolver.resolveAST(assigningAST, false, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushNewContextualType(contextualType); + + if (init) { + resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); + } + } + } + }; + + TypeScriptCompiler.prototype.getASTPath = function (ast) { + var result = []; + + while (ast) { + result.unshift(ast); + ast = ast.parent; + } + + return result; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + ast = context.ast; + 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()]); + return null; + } + + if (symbol.isTypeReference()) { + symbol = symbol.getReferencedTypeSymbol(); + } + + var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); + + return { + symbol: symbol, + aliasSymbol: aliasSymbol, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { + if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { + return null; + } + + var isNew = ast.kind() === 216 /* ObjectCreationExpression */; + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, false); + if (!context || context.inWithBlock) { + return null; + } + + return resolver.getVisibleDecls(context.enclosingDecl); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { + if (ast.kind() !== 215 /* ObjectLiteralExpression */) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var astForDecl = decl.ast(); + if (!astForDecl) { + return null; + } + + var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); + if (!astForDeclContext) { + return null; + } + + var symbol = decl.getSymbol(); + resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + aliasSymbol: null, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { + return this.semanticInfoChain.topLevelDecl(fileName); + }; + + TypeScriptCompiler.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast); + }; + + TypeScriptCompiler.prototype.fileNames = function () { + return this.semanticInfoChain.fileNames(); + }; + + 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; + + var CompilerPhase; + (function (CompilerPhase) { + CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; + CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; + CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; + CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; + CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; + })(CompilerPhase || (CompilerPhase = {})); + + var CompilerIterator = (function () { + function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { + if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } + this.compiler = compiler; + this.resolvePath = resolvePath; + this.continueOnDiagnostics = continueOnDiagnostics; + this.index = -1; + this.fileNames = null; + this._current = null; + this._emitOptions = null; + this._sharedEmitter = null; + this._sharedDeclarationEmitter = null; + this.hadSyntacticDiagnostics = false; + this.hadSemanticDiagnostics = false; + this.hadEmitDiagnostics = false; + this.fileNames = compiler.fileNames(); + this.compilerPhase = startingPhase; + } + CompilerIterator.prototype.current = function () { + return this._current; + }; + + CompilerIterator.prototype.moveNext = function () { + this._current = null; + + while (this.moveNextInternal()) { + if (this._current) { + return true; + } + } + + return false; + }; + + CompilerIterator.prototype.moveNextInternal = function () { + this.index++; + + while (this.shouldMoveToNextPhase()) { + this.index = 0; + this.compilerPhase++; + } + + if (this.compilerPhase > 4 /* DeclarationEmit */) { + return false; + } + + switch (this.compilerPhase) { + case 0 /* Syntax */: + return this.moveNextSyntaxPhase(); + case 1 /* Semantics */: + return this.moveNextSemanticsPhase(); + case 2 /* EmitOptionsValidation */: + return this.moveNextEmitOptionsValidationPhase(); + case 3 /* Emit */: + return this.moveNextEmitPhase(); + case 4 /* DeclarationEmit */: + return this.moveNextDeclarationEmitPhase(); + } + }; + + CompilerIterator.prototype.shouldMoveToNextPhase = function () { + switch (this.compilerPhase) { + case 2 /* EmitOptionsValidation */: + return this.index === 1; + + case 0 /* Syntax */: + case 1 /* Semantics */: + return this.index === this.fileNames.length; + + case 3 /* Emit */: + case 4 /* DeclarationEmit */: + return this.index === (this.fileNames.length + 1); + } + + return false; + }; + + CompilerIterator.prototype.moveNextSyntaxPhase = function () { + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + + var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSyntacticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextSemanticsPhase = function () { + if (this.hadSyntacticDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + var diagnostics = this.compiler.getSemanticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSemanticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + + if (!this._emitOptions) { + this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); + } + + if (this._emitOptions.diagnostic()) { + if (!this.continueOnDiagnostics) { + this.hadEmitDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(this._emitOptions); + + if (this.hadEmitDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { + _this._current = CompileResult.fromOutputFiles(outputFiles); + }, this._sharedEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedEmitter) { + this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); + } + + return true; + }; + + CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(!this.hadEmitDiagnostics); + if (this.hadSemanticDiagnostics) { + return false; + } + + if (!this.compiler.compilationSettings().generateDeclarationFiles()) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { + _this._current = CompileResult.fromOutputFiles([file]); + }, this._sharedDeclarationEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { + this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); + } + + return true; + }; + return CompilerIterator; + })(); + + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) + return false; + } else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) + return false; + } + } + return true; + } + TypeScript.compareDataObjects = compareDataObjects; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (GenerativeTypeClassification) { + GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; + GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; + GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; + GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; + })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); + var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; + + var PullTypeReferenceSymbol = (function (_super) { + __extends(PullTypeReferenceSymbol, _super); + function PullTypeReferenceSymbol(referencedTypeSymbol) { + _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); + this.referencedTypeSymbol = referencedTypeSymbol; + this.isResolved = true; + + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); + + this.setRootSymbol(referencedTypeSymbol); + + this.typeReference = this; + } + PullTypeReferenceSymbol.createTypeReference = function (type) { + if (type.isTypeReference()) { + return type; + } + + var typeReference = type.typeReference; + + if (!typeReference) { + typeReference = new PullTypeReferenceSymbol(type); + type.typeReference = typeReference; + } + + return typeReference; + }; + + PullTypeReferenceSymbol.prototype.isTypeReference = function () { + return true; + }; + + PullTypeReferenceSymbol.prototype.setResolved = function () { + }; + + PullTypeReferenceSymbol.prototype.setUnresolved = function () { + }; + PullTypeReferenceSymbol.prototype.invalidate = function () { + }; + + PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { + this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); + }; + + PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol; + }; + + PullTypeReferenceSymbol.prototype._getResolver = function () { + return this.referencedTypeSymbol._getResolver(); + }; + + PullTypeReferenceSymbol.prototype.hasMembers = function () { + return this.referencedTypeSymbol.hasMembers(); + }; + + PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); + }; + + PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + return this.referencedTypeSymbol.getAssociatedContainerType(); + }; + + PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getFunctionSymbol(); + }; + PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); + }; + + PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); + }; + PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); + }; + + PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); + }; + PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMember(name); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); + }; + + PullTypeReferenceSymbol.prototype.getMembers = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getMembers(); + }; + + PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); + }; + PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getHasDefaultConstructor(); + }; + PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructorMethod(); + }; + PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); + }; + PullTypeReferenceSymbol.prototype.getTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.isGeneric = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isGeneric(); + }; + + PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getSpecialization(substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getKnownSpecializations(); + }; + PullTypeReferenceSymbol.prototype.getTypeArguments = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArguments(); + }; + PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); + }; + 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"); + }; + + PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnIndexSignatures(); + }; + PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getIndexSignatures(); + }; + + PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { + this.referencedTypeSymbol.addImplementedType(implementedType); + }; + PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getImplementedTypes(); + }; + PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { + this.referencedTypeSymbol.addExtendedType(extendedType); + }; + PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getExtendedTypes(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExtendsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExtendThisType(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); + }; + + PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); + }; + + PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findMember(name, lookInParent); + }; + PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedType(name, kind); + }; + PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedContainer(name, kind); + }; + PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + }; + + PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findTypeParameter(name); + }; + + PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); + }; + return PullTypeReferenceSymbol; + })(TypeScript.PullTypeSymbol); + TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; + + var PullInstantiatedTypeReferenceSymbol = (function (_super) { + __extends(PullInstantiatedTypeReferenceSymbol, _super); + 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 = undefined; + this._instantiatedConstructorMethod = null; + this._instantiatedAssociatedContainerType = null; + this._isArray = undefined; + this._generativeTypeClassification = []; + + TypeScript.nSpecializationsCreated++; + } + PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { + return !this.isInstanceReferenceType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; + } + + 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()); + } + return this._isArray; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { + if (!this.isArrayNamedTypeReference()) { + return null; + } + + var typeArguments = this.getTypeArguments(); + return typeArguments ? typeArguments[0] : null; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.getIsSpecialized()) { + return this; + } + + return this.referencedTypeSymbol; + }; + + 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + 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; + } + } + + if (isInstanceReferenceType) { + typeParameterArgumentMap = []; + } + } + + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); + + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); + + return instantiation; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { + return this.getRootSymbol().isGeneric(); + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { + if (this.isInstanceReferenceType) { + return this.getTypeParameters(); + } + + if (this._typeArgumentReferences === undefined) { + var typeParameters = this.referencedTypeSymbol.getTypeParameters(); + + if (typeParameters.length) { + var typeArgument = null; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; + + if (!typeArgument) { + TypeScript.Debug.fail("type argument count mismatch"); + } + + if (typeArgument) { + typeArguments[typeArguments.length] = typeArgument; + } + } + + this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; + } + } + + return this._typeArgumentReferences; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + 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(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getMembers(); + } + + if (!this._instantiatedMembers) { + var referencedMembers = this.referencedTypeSymbol.getMembers(); + var referencedMember = null; + var instantiatedMember = null; + + this._instantiatedMembers = []; + + for (var i = 0; i < referencedMembers.length; i++) { + referencedMember = referencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (!this._instantiatedMemberNameCache[referencedMember.name]) { + this.populateInstantiatedMemberFromReferencedMember(referencedMember); + } + + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; + } + } + + return this._instantiatedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.findMember(name, lookInParent); + } + + var memberSymbol = this._instantiatedMemberNameCache[name]; + + if (!memberSymbol) { + var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); + + if (referencedMemberSymbol) { + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; + } else { + memberSymbol = null; + } + } + + return memberSymbol; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + } + + var requestedMembers = []; + var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + + if (!this._allInstantiatedMemberNameCache) { + this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); + + var members = this.getMembers(); + + for (var i = 0; i < members.length; i++) { + this._allInstantiatedMemberNameCache[members[i].name] = members[i]; + } + } + + var referencedMember = null; + var requestedMember = null; + + for (var i = 0; i < allReferencedMembers.length; i++) { + referencedMember = allReferencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (this._allInstantiatedMemberNameCache[referencedMember.name]) { + requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; + } else { + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; + requestedMembers[requestedMembers.length] = referencedMember; + } else { + requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + requestedMember.setRootSymbol(referencedMember); + + requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + requestedMember.isOptional = referencedMember.isOptional; + + this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; + requestedMembers[requestedMembers.length] = requestedMember; + } + } + } + + return requestedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructorMethod(); + } + + 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); + } + + return this._instantiatedConstructorMethod; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + if (!this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAssociatedContainerType(); + } + + if (!this._instantiatedAssociatedContainerType) { + var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); + + if (referencedAssociatedContainerType) { + this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); + } + } + + return this._instantiatedAssociatedContainerType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getCallSignatures(); + } + + if (this._instantiatedCallSignatures) { + return this._instantiatedCallSignatures; + } + + var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); + this._instantiatedCallSignatures = []; + + for (var i = 0; i < referencedCallSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); + + if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; + } else { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedCallSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructSignatures(); + } + + if (this._instantiatedConstructSignatures) { + return this._instantiatedConstructSignatures; + } + + var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); + this._instantiatedConstructSignatures = []; + + for (var i = 0; i < referencedConstructSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); + + if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; + } else { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedConstructSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getIndexSignatures(); + } + + if (this._instantiatedIndexSignatures) { + return this._instantiatedIndexSignatures; + } + + var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); + this._instantiatedIndexSignatures = []; + + for (var i = 0; i < referencedIndexSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); + + if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; + } else { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedIndexSignatures; + }; + 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) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { + if (element === null) { + return null; + } + + if (element.fullWidth() === 0) { + return new TypeScript.ASTSpan(-1, -1); + } + + var leadingTriviaWidth = element.leadingTriviaWidth(); + var trailingTriviaWidth = element.trailingTriviaWidth(); + + var start = fullStart + leadingTriviaWidth; + var end = fullStart + element.fullWidth() - trailingTriviaWidth; + + return new TypeScript.ASTSpan(start, end); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { + if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } + if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span._trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span._start = start; + span._end = end; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ISyntaxList2(this.fileName, array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { + return this.visitToken(token); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result = this.visitTokenWorker(token); + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { + switch (token.tokenKind) { + case 60 /* AnyKeyword */: + return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); + case 61 /* BooleanKeyword */: + return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); + case 67 /* NumberKeyword */: + return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); + case 69 /* StringKeyword */: + return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); + case 41 /* VoidKeyword */: + return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); + case 35 /* ThisKeyword */: + return new TypeScript.ThisExpression(token.text(), token.valueText()); + case 50 /* SuperKeyword */: + return new TypeScript.SuperExpression(token.text(), token.valueText()); + case 37 /* TrueKeyword */: + return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); + case 24 /* FalseKeyword */: + return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); + case 32 /* NullKeyword */: + return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); + case 14 /* StringLiteral */: + return new TypeScript.StringLiteral(token.text(), token.valueText()); + case 12 /* RegularExpressionLiteral */: + return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); + case 13 /* NumericLiteral */: + var fullStart = this.position; + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); + + result.setPreComments(preComments); + return result; + case 11 /* IdentifierName */: + return new TypeScript.Identifier(token.text()); + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { + var start = this.position; + TypeScript.Debug.assert(start === 0); + + var bod = this.visitSyntaxList(node.moduleElements); + 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; + }; + + SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { + var start = this.position; + + this.moveTo(node, node.stringLiteral); + var stringLiteral = node.stringLiteral.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ExternalModuleReference(stringLiteral); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { + var start = this.position; + var moduleName = node.moduleName.accept(this); + + var result = new TypeScript.ModuleNameModuleReference(moduleName); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + this.movePast(node.openBraceToken); + var members = this.visitSyntaxList(node.classElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { + var result = null; + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { + result = result || []; + result.push(1 /* Exported */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + result = result || []; + result.push(8 /* Ambient */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { + result = result || []; + result.push(16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { + result = result || []; + result.push(4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { + result = result || []; + result.push(2 /* Private */); + } + + return result || TypeScript.sentinelEmptyArray; + }; + + SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + var body = this.visitObjectType(node.body); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { + var start = this.position; + + this.movePast(node.extendsOrImplementsKeyword); + var typeNames = this.visitSeparatedSyntaxList(node.typeNames); + + var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { + var start = this.position; + + var modifiers = this.visitModifiers(node.modifiers); + + this.moveTo(node, node.moduleKeyword); + this.movePast(node.moduleKeyword); + + var moduleName = node.name ? node.name.accept(this) : null; + var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; + + this.movePast(node.openBraceToken); + + var moduleElements = this.visitSyntaxList(node.moduleElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + this.movePast(node.openBraceToken); + + var enumElements = this.visitSeparatedSyntaxList(node.enumElements); + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + var start = this.position; + + var memberName = this.visitToken(node.propertyName); + + var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.EnumElement(memberName, value); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ImportDeclaration(modifiers, name, alias); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.VariableStatement(modifiers, declaration); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var propertyName = this.visitToken(node.propertyName); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var start = this.position; + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var value = node.value.accept(this); + value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); + + var result = new TypeScript.EqualsValueClause(value); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayLiteralExpression(expressions); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(openParenToken); + + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = node.identifier.accept(this); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var callSignature = this.visitCallSignature(node.callSignature); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + return type ? type.accept(this) : null; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var result = new TypeScript.TypeQuery(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left); + this.movePast(node.dotToken); + var right = this.visitIdentifier(node.right); + + var result = new TypeScript.QualifiedName(left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeArgumentList(typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectType(typeMembers); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayType(underlying); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name); + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + var result = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.colonToken); + var type = this.visitType(node.type); + + var result = new TypeScript.TypeAnnotation(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.visitIdentifier(node.name); + + var result = new TypeScript.MemberAccessExpression(expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + this.movePast(node.openParenToken); + + 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()); + } + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(node.kind(), left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.ConstructSignature(callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.MethodSignature(name, questionToken, callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.IndexSignature(parameter, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + var openParenToken = node.openParenToken; + + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + var openParenTrailingComments = null; + if (node.parameters.childCount() === 0) { + openParenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + } + + this.movePast(node.openParenToken); + var parameters = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeParameterList(typeParameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + var start = this.position; + this.movePast(node.extendsKeyword); + var type = this.visitType(node.type); + + var result = new TypeScript.Constraint(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + var start = this.position; + + this.movePast(node.elseKeyword); + var statement = node.statement.accept(this); + + var result = new TypeScript.ElseClause(statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var expression = node.expression.accept(this); + + var semicolonPosition = this.position; + + var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + 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(callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.indexSignature); + var indexSignature = node.indexSignature.accept(this); + + this.movePast(node.semicolonToken); + + var result = new TypeScript.IndexMemberDeclaration(indexSignature); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + var variableDeclarator = node.variableDeclarator.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + this.movePast(node.openBraceToken); + var switchClauses = this.visitSyntaxList(node.switchClauses); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseSwitchClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.DefaultSwitchClause(statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.BreakStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ContinueStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var initializer = node.initializer ? node.initializer.accept(this) : null; + + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var left = node.left ? node.left.accept(this) : null; + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.CastExpression(castTerm, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + var propertyName = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var expression = node.expression.accept(this); + expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); + + var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var propertyName = node.propertyName.accept(this); + var callSignature = this.visitCallSignature(node.callSignature); + var block = this.visitBlock(node.block); + + var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionExpression(name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.visitIdentifier(node.identifier); + var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + var start = this.position; + this.movePast(node.finallyKeyword); + var block = node.block.accept(this); + + var result = new TypeScript.FinallyClause(block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, whileKeyword, condition); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.TypeOfExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.DeleteExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.VoidExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + function applyDelta(ast, delta) { + if (ast) { + if (ast._start !== -1) { + ast._start += delta; + } + + if (ast._end !== -1) { + ast._end += delta; + } + } + } + + function applyDeltaToComments(comments, delta) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment, delta); + } + } + } + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var pre = function (cur) { + applyDelta(cur, delta); + applyDeltaToComments(cur.preComments(), delta); + applyDeltaToComments(cur.postComments(), delta); + + switch (cur.kind()) { + case 146 /* Block */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 226 /* ArgumentList */: + applyDelta(cur.closeParenToken, delta); + break; + + case 130 /* ModuleDeclaration */: + applyDelta(cur.endingToken, delta); + break; + + case 131 /* ClassDeclaration */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 161 /* DoStatement */: + applyDelta(cur.whileKeyword, delta); + break; + + case 151 /* SwitchStatement */: + applyDelta(cur.closeParenToken, delta); + break; + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span._start !== -1) { + var delta = start - span._start; + this.applyDelta(span, delta); + + span._end = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = element._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + element._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan(_start, _end) { + this._start = _start; + this._end = _end; + } + ASTSpan.prototype.start = function () { + return this._start; + }; + + ASTSpan.prototype.end = function () { + return this._end; + }; + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, false); + } + + function commentStructuralEqualsIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, true); + } + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); + } + + function commentStructuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + function commentArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.parent = null; + this._start = -1; + this._end = -1; + this._trailingTriviaWidth = 0; + this._astID = astID++; + this._preComments = null; + this._postComments = null; + } + AST.prototype.syntaxID = function () { + return this._astID; + }; + + AST.prototype.start = function () { + return this._start; + }; + + AST.prototype.end = function () { + return this._end; + }; + + AST.prototype.trailingTriviaWidth = function () { + return this._trailingTriviaWidth; + }; + + AST.prototype.fileName = function () { + return this.parent.fileName(); + }; + + AST.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.width = function () { + return this.end() - this.start(); + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + + AST.prototype.isExpression = function () { + return false; + }; + return AST; + })(); + TypeScript.AST = AST; + + var ISyntaxList2 = (function (_super) { + __extends(ISyntaxList2, _super); + function ISyntaxList2(_fileName, members) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISyntaxList2.prototype.childCount = function () { + return this.members.length; + }; + + ISyntaxList2.prototype.childAt = function (index) { + return this.members[index]; + }; + + ISyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISyntaxList2.prototype.kind = function () { + return 1 /* List */; + }; + + ISyntaxList2.prototype.firstOrDefault = function (func) { + return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.lastOrDefault = function (func) { + return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.any = function (func) { + return TypeScript.ArrayUtilities.any(this.members, func); + }; + + ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISyntaxList2; + })(AST); + TypeScript.ISyntaxList2 = ISyntaxList2; + + var ISeparatedSyntaxList2 = (function (_super) { + __extends(ISeparatedSyntaxList2, _super); + function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + this._separatorCount = _separatorCount; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { + return this.members.length; + }; + + ISeparatedSyntaxList2.prototype.separatorCount = function () { + return this._separatorCount; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { + return this.members[index]; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i) === ast) { + return i; + } + } + + return -1; + }; + + ISeparatedSyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISeparatedSyntaxList2.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISeparatedSyntaxList2; + })(AST); + TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; + + var SourceUnit = (function (_super) { + __extends(SourceUnit, _super); + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { + _super.call(this); + this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; + this._fileName = _fileName; + moduleElements && (moduleElements.parent = this); + } + SourceUnit.prototype.fileName = function () { + return this._fileName; + }; + + SourceUnit.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return SourceUnit; + })(AST); + TypeScript.SourceUnit = SourceUnit; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(_text) { + _super.call(this); + this._text = _text; + this._valueText = null; + } + Identifier.prototype.text = function () { + return this._text; + }; + Identifier.prototype.valueText = function () { + if (!this._valueText) { + var text = this._text; + if (text === "__proto__") { + this._valueText = "#__proto__"; + } else { + this._valueText = TypeScript.Syntax.massageEscapes(text); + } + } + + return this._valueText; + }; + + Identifier.prototype.kind = function () { + return 11 /* IdentifierName */; + }; + + 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; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + LiteralExpression.prototype.text = function () { + return this._text; + }; + + LiteralExpression.prototype.valueText = function () { + return this._valueText; + }; + + LiteralExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + ThisExpression.prototype.text = function () { + return this._text; + }; + + ThisExpression.prototype.valueText = function () { + return this._valueText; + }; + + ThisExpression.prototype.kind = function () { + return 35 /* ThisKeyword */; + }; + + 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; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + SuperExpression.prototype.text = function () { + return this._text; + }; + + SuperExpression.prototype.valueText = function () { + return this._valueText; + }; + + SuperExpression.prototype.kind = function () { + return 50 /* SuperKeyword */; + }; + + 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; + + var NumericLiteral = (function (_super) { + __extends(NumericLiteral, _super); + function NumericLiteral(_value, _text, _valueText) { + _super.call(this); + this._value = _value; + this._text = _text; + this._valueText = _valueText; + } + NumericLiteral.prototype.text = function () { + return this._text; + }; + NumericLiteral.prototype.valueText = function () { + return this._valueText; + }; + NumericLiteral.prototype.value = function () { + return this._value; + }; + + NumericLiteral.prototype.kind = function () { + return 13 /* NumericLiteral */; + }; + + 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; + + var RegularExpressionLiteral = (function (_super) { + __extends(RegularExpressionLiteral, _super); + function RegularExpressionLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + RegularExpressionLiteral.prototype.text = function () { + return this._text; + }; + + RegularExpressionLiteral.prototype.valueText = function () { + return this._valueText; + }; + + RegularExpressionLiteral.prototype.kind = function () { + return 12 /* RegularExpressionLiteral */; + }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; + return RegularExpressionLiteral; + })(AST); + TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + StringLiteral.prototype.valueText = function () { + return this._valueText; + }; + + StringLiteral.prototype.kind = function () { + return 14 /* StringLiteral */; + }; + + 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; + + var TypeAnnotation = (function (_super) { + __extends(TypeAnnotation, _super); + function TypeAnnotation(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + TypeAnnotation.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + return TypeAnnotation; + })(AST); + TypeScript.TypeAnnotation = TypeAnnotation; + + var BuiltInType = (function (_super) { + __extends(BuiltInType, _super); + function BuiltInType(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + BuiltInType.prototype.text = function () { + return this._text; + }; + + BuiltInType.prototype.valueText = function () { + return this._valueText; + }; + + BuiltInType.prototype.kind = function () { + return this._nodeType; + }; + return BuiltInType; + })(AST); + TypeScript.BuiltInType = BuiltInType; + + var ExternalModuleReference = (function (_super) { + __extends(ExternalModuleReference, _super); + function ExternalModuleReference(stringLiteral) { + _super.call(this); + this.stringLiteral = stringLiteral; + stringLiteral && (stringLiteral.parent = this); + } + ExternalModuleReference.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + return ExternalModuleReference; + })(AST); + TypeScript.ExternalModuleReference = ExternalModuleReference; + + var ModuleNameModuleReference = (function (_super) { + __extends(ModuleNameModuleReference, _super); + function ModuleNameModuleReference(moduleName) { + _super.call(this); + this.moduleName = moduleName; + moduleName && (moduleName.parent = this); + } + ModuleNameModuleReference.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + return ModuleNameModuleReference; + })(AST); + TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(modifiers, identifier, moduleReference) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.moduleReference = moduleReference; + identifier && (identifier.parent = this); + moduleReference && (moduleReference.parent = this); + } + ImportDeclaration.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(identifier) { + _super.call(this); + this.identifier = identifier; + identifier && (identifier.parent = this); + } + ExportAssignment.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var TypeParameterList = (function (_super) { + __extends(TypeParameterList, _super); + function TypeParameterList(typeParameters) { + _super.call(this); + this.typeParameters = typeParameters; + typeParameters && (typeParameters.parent = this); + } + TypeParameterList.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + return TypeParameterList; + })(AST); + TypeScript.TypeParameterList = TypeParameterList; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + heritageClauses && (heritageClauses.parent = this); + classElements && (classElements.parent = this); + } + ClassDeclaration.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return ClassDeclaration; + })(AST); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + body && (body.parent = this); + heritageClauses && (heritageClauses.parent = this); + } + InterfaceDeclaration.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return InterfaceDeclaration; + })(AST); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var HeritageClause = (function (_super) { + __extends(HeritageClause, _super); + function HeritageClause(_nodeType, typeNames) { + _super.call(this); + this._nodeType = _nodeType; + this.typeNames = typeNames; + typeNames && (typeNames.parent = this); + } + HeritageClause.prototype.kind = function () { + return this._nodeType; + }; + + HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); + }; + return HeritageClause; + })(AST); + TypeScript.HeritageClause = HeritageClause; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { + _super.call(this); + this.modifiers = modifiers; + this.name = name; + this.stringLiteral = stringLiteral; + this.moduleElements = moduleElements; + this.endingToken = endingToken; + name && (name.parent = this); + stringLiteral && (stringLiteral.parent = this); + moduleElements && (moduleElements.parent = this); + } + ModuleDeclaration.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(modifiers, identifier, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionDeclaration.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(modifiers, declaration) { + _super.call(this); + this.modifiers = modifiers; + this.declaration = declaration; + declaration && (declaration.parent = this); + } + VariableStatement.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + declarators && (declarators.parent = this); + } + VariableDeclaration.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + VariableDeclarator.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + return VariableDeclarator; + })(AST); + TypeScript.VariableDeclarator = VariableDeclarator; + + var EqualsValueClause = (function (_super) { + __extends(EqualsValueClause, _super); + function EqualsValueClause(value) { + _super.call(this); + this.value = value; + value && (value.parent = this); + } + EqualsValueClause.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + return EqualsValueClause; + })(AST); + TypeScript.EqualsValueClause = EqualsValueClause; + + var PrefixUnaryExpression = (function (_super) { + __extends(PrefixUnaryExpression, _super); + function PrefixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PrefixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ArrayLiteralExpression = (function (_super) { + __extends(ArrayLiteralExpression, _super); + function ArrayLiteralExpression(expressions) { + _super.call(this); + this.expressions = expressions; + expressions && (expressions.parent = this); + } + ArrayLiteralExpression.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + 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; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + 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; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(openParenTrailingComments, expression) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.expression = expression; + expression && (expression.parent = this); + } + ParenthesizedExpression.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + 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; + + var SimpleArrowFunctionExpression = (function (_super) { + __extends(SimpleArrowFunctionExpression, _super); + function SimpleArrowFunctionExpression(identifier, block, expression) { + _super.call(this); + this.identifier = identifier; + this.block = block; + this.expression = expression; + identifier && (identifier.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + SimpleArrowFunctionExpression.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return SimpleArrowFunctionExpression; + })(AST); + TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; + + var ParenthesizedArrowFunctionExpression = (function (_super) { + __extends(ParenthesizedArrowFunctionExpression, _super); + function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + this.expression = expression; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + ParenthesizedArrowFunctionExpression.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return ParenthesizedArrowFunctionExpression; + })(AST); + TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; + + var QualifiedName = (function (_super) { + __extends(QualifiedName, _super); + function QualifiedName(left, right) { + _super.call(this); + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + QualifiedName.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedName.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); + }; + return QualifiedName; + })(AST); + TypeScript.QualifiedName = QualifiedName; + + var ParameterList = (function (_super) { + __extends(ParameterList, _super); + function ParameterList(openParenTrailingComments, parameters) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.parameters = parameters; + parameters && (parameters.parent = this); + } + ParameterList.prototype.kind = function () { + return 227 /* ParameterList */; + }; + return ParameterList; + })(AST); + TypeScript.ParameterList = ParameterList; + + var ConstructorType = (function (_super) { + __extends(ConstructorType, _super); + function ConstructorType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + ConstructorType.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + return ConstructorType; + })(AST); + TypeScript.ConstructorType = ConstructorType; + + var FunctionType = (function (_super) { + __extends(FunctionType, _super); + function FunctionType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + FunctionType.prototype.kind = function () { + return 123 /* FunctionType */; + }; + return FunctionType; + })(AST); + TypeScript.FunctionType = FunctionType; + + var ObjectType = (function (_super) { + __extends(ObjectType, _super); + function ObjectType(typeMembers) { + _super.call(this); + this.typeMembers = typeMembers; + typeMembers && (typeMembers.parent = this); + } + ObjectType.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); + }; + return ObjectType; + })(AST); + TypeScript.ObjectType = ObjectType; + + var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + ArrayType.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); + }; + return ArrayType; + })(AST); + TypeScript.ArrayType = ArrayType; + + var TypeArgumentList = (function (_super) { + __extends(TypeArgumentList, _super); + function TypeArgumentList(typeArguments) { + _super.call(this); + this.typeArguments = typeArguments; + typeArguments && (typeArguments.parent = this); + } + TypeArgumentList.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + return TypeArgumentList; + })(AST); + TypeScript.TypeArgumentList = TypeArgumentList; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArgumentList) { + _super.call(this); + this.name = name; + this.typeArgumentList = typeArgumentList; + name && (name.parent = this); + typeArgumentList && (typeArgumentList.parent = this); + } + GenericType.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + name && (name.parent = this); + } + TypeQuery.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceLeadingComments, closeBraceToken) { + _super.call(this); + this.statements = statements; + this.closeBraceLeadingComments = closeBraceLeadingComments; + this.closeBraceToken = closeBraceToken; + statements && (statements.parent = this); + } + Block.prototype.kind = function () { + return 146 /* Block */; + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + _super.call(this); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + Parameter.prototype.kind = function () { + return 242 /* Parameter */; + }; + return Parameter; + })(AST); + TypeScript.Parameter = Parameter; + + var MemberAccessExpression = (function (_super) { + __extends(MemberAccessExpression, _super); + function MemberAccessExpression(expression, name) { + _super.call(this); + this.expression = expression; + this.name = name; + expression && (expression.parent = this); + name && (name.parent = this); + } + MemberAccessExpression.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + 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; + + var PostfixUnaryExpression = (function (_super) { + __extends(PostfixUnaryExpression, _super); + function PostfixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PostfixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ElementAccessExpression = (function (_super) { + __extends(ElementAccessExpression, _super); + function ElementAccessExpression(expression, argumentExpression) { + _super.call(this); + this.expression = expression; + this.argumentExpression = argumentExpression; + expression && (expression.parent = this); + argumentExpression && (argumentExpression.parent = this); + } + ElementAccessExpression.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + 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; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + InvocationExpression.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + 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) { + _super.call(this); + this.typeArgumentList = typeArgumentList; + this.closeParenToken = closeParenToken; + this.arguments = _arguments; + + typeArgumentList && (typeArgumentList.parent = this); + _arguments && (_arguments.parent = this); + } + ArgumentList.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + return ArgumentList; + })(AST); + TypeScript.ArgumentList = ArgumentList; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, left, right) { + _super.call(this); + this._nodeType = _nodeType; + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + BinaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(condition, whenTrue, whenFalse) { + _super.call(this); + this.condition = condition; + this.whenTrue = whenTrue; + this.whenFalse = whenFalse; + condition && (condition.parent = this); + whenTrue && (whenTrue.parent = this); + whenFalse && (whenFalse.parent = this); + } + ConditionalExpression.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + 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; + + var ConstructSignature = (function (_super) { + __extends(ConstructSignature, _super); + function ConstructSignature(callSignature) { + _super.call(this); + this.callSignature = callSignature; + callSignature && (callSignature.parent = this); + } + ConstructSignature.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + return ConstructSignature; + })(AST); + TypeScript.ConstructSignature = ConstructSignature; + + var MethodSignature = (function (_super) { + __extends(MethodSignature, _super); + function MethodSignature(propertyName, questionToken, callSignature) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + } + MethodSignature.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + return MethodSignature; + })(AST); + TypeScript.MethodSignature = MethodSignature; + + var IndexSignature = (function (_super) { + __extends(IndexSignature, _super); + function IndexSignature(parameter, typeAnnotation) { + _super.call(this); + this.parameter = parameter; + this.typeAnnotation = typeAnnotation; + parameter && (parameter.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + IndexSignature.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + return IndexSignature; + })(AST); + TypeScript.IndexSignature = IndexSignature; + + var PropertySignature = (function (_super) { + __extends(PropertySignature, _super); + function PropertySignature(propertyName, questionToken, typeAnnotation) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + PropertySignature.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + return PropertySignature; + })(AST); + TypeScript.PropertySignature = PropertySignature; + + var CallSignature = (function (_super) { + __extends(CallSignature, _super); + function CallSignature(typeParameterList, parameterList, typeAnnotation) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + CallSignature.prototype.kind = function () { + return 142 /* CallSignature */; + }; + return CallSignature; + })(AST); + TypeScript.CallSignature = CallSignature; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(identifier, constraint) { + _super.call(this); + this.identifier = identifier; + this.constraint = constraint; + identifier && (identifier.parent = this); + constraint && (constraint.parent = this); + } + TypeParameter.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + Constraint.prototype.kind = function () { + return 239 /* Constraint */; + }; + return Constraint; + })(AST); + TypeScript.Constraint = Constraint; + + var ElseClause = (function (_super) { + __extends(ElseClause, _super); + function ElseClause(statement) { + _super.call(this); + this.statement = statement; + statement && (statement.parent = this); + } + ElseClause.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ElseClause; + })(AST); + TypeScript.ElseClause = ElseClause; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(condition, statement, elseClause) { + _super.call(this); + this.condition = condition; + this.statement = statement; + this.elseClause = elseClause; + condition && (condition.parent = this); + statement && (statement.parent = this); + elseClause && (elseClause.parent = this); + } + IfStatement.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ExpressionStatement.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var ConstructorDeclaration = (function (_super) { + __extends(ConstructorDeclaration, _super); + function ConstructorDeclaration(callSignature, block) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + ConstructorDeclaration.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + return ConstructorDeclaration; + })(AST); + TypeScript.ConstructorDeclaration = ConstructorDeclaration; + + var MemberFunctionDeclaration = (function (_super) { + __extends(MemberFunctionDeclaration, _super); + function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + MemberFunctionDeclaration.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + return MemberFunctionDeclaration; + })(AST); + TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; + + var GetAccessor = (function (_super) { + __extends(GetAccessor, _super); + function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + GetAccessor.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + return GetAccessor; + })(AST); + TypeScript.GetAccessor = GetAccessor; + + var SetAccessor = (function (_super) { + __extends(SetAccessor, _super); + function SetAccessor(modifiers, propertyName, parameterList, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + block && (block.parent = this); + } + SetAccessor.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + return SetAccessor; + })(AST); + TypeScript.SetAccessor = SetAccessor; + + var MemberVariableDeclaration = (function (_super) { + __extends(MemberVariableDeclaration, _super); + function MemberVariableDeclaration(modifiers, variableDeclarator) { + _super.call(this); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + variableDeclarator && (variableDeclarator.parent = this); + } + MemberVariableDeclaration.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + return MemberVariableDeclaration; + })(AST); + TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; + + var IndexMemberDeclaration = (function (_super) { + __extends(IndexMemberDeclaration, _super); + function IndexMemberDeclaration(indexSignature) { + _super.call(this); + this.indexSignature = indexSignature; + indexSignature && (indexSignature.parent = this); + } + IndexMemberDeclaration.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + return IndexMemberDeclaration; + })(AST); + TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ThrowStatement.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ReturnStatement.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + ObjectCreationExpression.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + 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; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(expression, closeParenToken, switchClauses) { + _super.call(this); + this.expression = expression; + this.closeParenToken = closeParenToken; + this.switchClauses = switchClauses; + expression && (expression.parent = this); + switchClauses && (switchClauses.parent = this); + } + SwitchStatement.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseSwitchClause = (function (_super) { + __extends(CaseSwitchClause, _super); + function CaseSwitchClause(expression, statements) { + _super.call(this); + this.expression = expression; + this.statements = statements; + expression && (expression.parent = this); + statements && (statements.parent = this); + } + CaseSwitchClause.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return CaseSwitchClause; + })(AST); + TypeScript.CaseSwitchClause = CaseSwitchClause; + + var DefaultSwitchClause = (function (_super) { + __extends(DefaultSwitchClause, _super); + function DefaultSwitchClause(statements) { + _super.call(this); + this.statements = statements; + statements && (statements.parent = this); + } + DefaultSwitchClause.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return DefaultSwitchClause; + })(AST); + TypeScript.DefaultSwitchClause = DefaultSwitchClause; + + var BreakStatement = (function (_super) { + __extends(BreakStatement, _super); + function BreakStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + BreakStatement.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return BreakStatement; + })(AST); + TypeScript.BreakStatement = BreakStatement; + + var ContinueStatement = (function (_super) { + __extends(ContinueStatement, _super); + function ContinueStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + ContinueStatement.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ContinueStatement; + })(AST); + TypeScript.ContinueStatement = ContinueStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.condition = condition; + this.incrementor = incrementor; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + initializer && (initializer.parent = this); + condition && (condition.parent = this); + incrementor && (incrementor.parent = this); + statement && (statement.parent = this); + } + ForStatement.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(variableDeclaration, left, expression, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.left = left; + this.expression = expression; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + left && (left.parent = this); + expression && (expression.parent = this); + statement && (statement.parent = this); + } + ForInStatement.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WhileStatement.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WithStatement.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var EnumDeclaration = (function (_super) { + __extends(EnumDeclaration, _super); + function EnumDeclaration(modifiers, identifier, enumElements) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.enumElements = enumElements; + identifier && (identifier.parent = this); + enumElements && (enumElements.parent = this); + } + EnumDeclaration.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + return EnumDeclaration; + })(AST); + TypeScript.EnumDeclaration = EnumDeclaration; + + var EnumElement = (function (_super) { + __extends(EnumElement, _super); + function EnumElement(propertyName, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + EnumElement.prototype.kind = function () { + return 243 /* EnumElement */; + }; + return EnumElement; + })(AST); + TypeScript.EnumElement = EnumElement; + + var CastExpression = (function (_super) { + __extends(CastExpression, _super); + function CastExpression(type, expression) { + _super.call(this); + this.type = type; + this.expression = expression; + type && (type.parent = this); + expression && (expression.parent = this); + } + CastExpression.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + 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; + + var ObjectLiteralExpression = (function (_super) { + __extends(ObjectLiteralExpression, _super); + function ObjectLiteralExpression(propertyAssignments) { + _super.call(this); + this.propertyAssignments = propertyAssignments; + propertyAssignments && (propertyAssignments.parent = this); + } + ObjectLiteralExpression.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + 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; + + var SimplePropertyAssignment = (function (_super) { + __extends(SimplePropertyAssignment, _super); + function SimplePropertyAssignment(propertyName, expression) { + _super.call(this); + this.propertyName = propertyName; + this.expression = expression; + propertyName && (propertyName.parent = this); + expression && (expression.parent = this); + } + SimplePropertyAssignment.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + return SimplePropertyAssignment; + })(AST); + TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; + + var FunctionPropertyAssignment = (function (_super) { + __extends(FunctionPropertyAssignment, _super); + function FunctionPropertyAssignment(propertyName, callSignature, block) { + _super.call(this); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionPropertyAssignment.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + return FunctionPropertyAssignment; + })(AST); + TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; + + var FunctionExpression = (function (_super) { + __extends(FunctionExpression, _super); + function FunctionExpression(identifier, callSignature, block) { + _super.call(this); + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionExpression.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; + return FunctionExpression; + })(AST); + TypeScript.FunctionExpression = FunctionExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(block, catchClause, finallyClause) { + _super.call(this); + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + block && (block.parent = this); + catchClause && (catchClause.parent = this); + finallyClause && (finallyClause.parent = this); + } + TryStatement.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(identifier, typeAnnotation, block) { + _super.call(this); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.block = block; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + CatchClause.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var FinallyClause = (function (_super) { + __extends(FinallyClause, _super); + function FinallyClause(block) { + _super.call(this); + this.block = block; + block && (block.parent = this); + } + FinallyClause.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return FinallyClause; + })(AST); + TypeScript.FinallyClause = FinallyClause; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + identifier && (identifier.parent = this); + statement && (statement.parent = this); + } + LabeledStatement.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(statement, whileKeyword, condition) { + _super.call(this); + this.statement = statement; + this.whileKeyword = whileKeyword; + this.condition = condition; + statement && (statement.parent = this); + condition && (condition.parent = this); + } + DoStatement.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var TypeOfExpression = (function (_super) { + __extends(TypeOfExpression, _super); + function TypeOfExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + TypeOfExpression.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + 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; + + var DeleteExpression = (function (_super) { + __extends(DeleteExpression, _super); + function DeleteExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + DeleteExpression.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + 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; + + var VoidExpression = (function (_super) { + __extends(VoidExpression, _super); + function VoidExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + VoidExpression.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + 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; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var Comment = (function () { + function Comment(_trivia, endsLine, _start, _end) { + this._trivia = _trivia; + this.endsLine = endsLine; + this._start = _start; + this._end = _end; + } + Comment.prototype.start = function () { + return this._start; + }; + + Comment.prototype.end = function () { + return this._end; + }; + + Comment.prototype.fullText = function () { + return this._trivia.fullText(); + }; + + Comment.prototype.kind = function () { + return this._trivia.kind(); + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; + }; + return Comment; + })(); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IOUtils) { + function createDirectoryStructure(ioHost, dirName) { + if (ioHost.directoryExists(dirName)) { + return; + } + + var parentDirectory = ioHost.dirName(dirName); + if (parentDirectory != "") { + createDirectoryStructure(ioHost, parentDirectory); + } + ioHost.createDirectory(dirName); + } + + function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + var path = ioHost.resolvePath(fileName); + TypeScript.ioHostResolvePathTime += new Date().getTime() - start; + + var start = new Date().getTime(); + var dirName = ioHost.dirName(path); + TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start; + + var start = new Date().getTime(); + createDirectoryStructure(ioHost, dirName); + TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start; + + var start = new Date().getTime(); + ioHost.writeFile(path, contents, writeByteOrderMark); + TypeScript.ioHostWriteFileTime += new Date().getTime() - start; + } + IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; + + function throwIOError(message, error) { + var errorMessage = message; + if (error && error.message) { + errorMessage += (" " + error.message); + } + throw new Error(errorMessage); + } + IOUtils.throwIOError = throwIOError; + + function combine(prefix, suffix) { + return prefix + "/" + suffix; + } + IOUtils.combine = combine; + + var BufferedTextWriter = (function () { + function BufferedTextWriter(writer, capacity) { + if (typeof capacity === "undefined") { capacity = 1024; } + this.writer = writer; + this.capacity = capacity; + this.buffer = ""; + } + BufferedTextWriter.prototype.Write = function (str) { + this.buffer += str; + if (this.buffer.length >= this.capacity) { + this.writer.Write(this.buffer); + this.buffer = ""; + } + }; + BufferedTextWriter.prototype.WriteLine = function (str) { + this.Write(str + '\r\n'); + }; + BufferedTextWriter.prototype.Close = function () { + this.writer.Write(this.buffer); + this.writer.Close(); + this.buffer = null; + }; + return BufferedTextWriter; + })(); + IOUtils.BufferedTextWriter = BufferedTextWriter; + })(TypeScript.IOUtils || (TypeScript.IOUtils = {})); + var IOUtils = TypeScript.IOUtils; + + TypeScript.IO = (function () { + function getWindowsScriptHostIO() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + 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); + }, + writeFile: function (path, contents, writeByteOrderMark) { + TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + dirName: function (path) { + return fso.GetParentFolderName(path); + }, + findFile: function (rootPath, partialFilePath) { + var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; + + while (true) { + if (fso.FileExists(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); + + if (rootPath == "") { + return null; + } else { + path = fso.BuildPath(rootPath, partialFilePath); + } + } + } + }, + deleteFile: function (path) { + try { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + fso.CreateFolder(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + dir: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "/" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + print: function (str) { + WScript.StdOut.Write(str); + }, + printLine: function (str) { + WScript.Echo(str); + }, + arguments: args, + stderr: WScript.StdErr, + stdout: WScript.StdOut, + watchFile: null, + run: function (source, fileName) { + try { + eval(source); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Error_while_executing_file_0, [fileName]), e); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + quit: function (exitCode) { + if (typeof exitCode === "undefined") { exitCode = 0; } + try { + WScript.Quit(exitCode); + } catch (e) { + } + } + }; + } + ; + + function getNodeIO() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + + return { + appendFile: function (path, content) { + _fs.appendFileSync(path, content); + }, + readFile: function (file, codepage) { + return TypeScript.Environment.readFile(file, codepage); + }, + writeFile: function (path, contents, writeByteOrderMark) { + TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + dir: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + try { + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "/" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "/" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "/" + files[i]); + } + } + } catch (err) { + } + + return paths; + } + + return filesInFolder(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + _fs.mkdirSync(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + dirName: function (path) { + var dirPath = _path.dirname(path); + + if (dirPath === path) { + dirPath = null; + } + + return dirPath; + }, + findFile: function (rootPath, partialFilePath) { + var path = rootPath + "/" + partialFilePath; + + while (true) { + if (_fs.existsSync(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + var parentPath = _path.resolve(rootPath, ".."); + + if (rootPath === parentPath) { + return null; + } else { + rootPath = parentPath; + path = _path.resolve(rootPath, partialFilePath); + } + } + } + }, + print: function (str) { + process.stdout.write(str); + }, + printLine: function (str) { + process.stdout.write(str + '\n'); + }, + arguments: process.argv.slice(2), + stderr: { + Write: function (str) { + process.stderr.write(str); + }, + WriteLine: function (str) { + process.stderr.write(str + '\n'); + }, + Close: function () { + } + }, + stdout: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + }, + watchFile: function (fileName, callback) { + var firstRun = true; + var processingChange = false; + + var fileChanged = function (curr, prev) { + if (!firstRun) { + if (curr.mtime < prev.mtime) { + return; + } + + _fs.unwatchFile(fileName, fileChanged); + if (!processingChange) { + processingChange = true; + callback(fileName); + setTimeout(function () { + processingChange = false; + }, 100); + } + } + firstRun = false; + _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); + }; + + fileChanged(); + return { + fileName: fileName, + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + }, + run: function (source, fileName) { + require.main.fileName = fileName; + require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); + require.main._compile(source, fileName); + }, + getExecutingFilePath: function () { + return process.mainModule.filename; + }, + quit: function (code) { + var stderrFlushed = process.stderr.write(''); + var stdoutFlushed = process.stdout.write(''); + process.stderr.on('drain', function () { + stderrFlushed = true; + if (stdoutFlushed) { + process.exit(code); + } + }); + process.stdout.on('drain', function () { + stdoutFlushed = true; + if (stderrFlushed) { + process.exit(code); + } + }); + setTimeout(function () { + process.exit(code); + }, 5); + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") + return getWindowsScriptHostIO(); + else if (typeof module !== 'undefined' && module.exports) + return getNodeIO(); + else + return null; + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OptionsParser = (function () { + function OptionsParser(host, version) { + this.host = host; + this.version = version; + this.DEFAULT_SHORT_FLAG = "-"; + this.DEFAULT_LONG_FLAG = "--"; + this.printedVersion = false; + this.unnamed = []; + this.options = []; + } + OptionsParser.prototype.findOption = function (arg) { + var upperCaseArg = arg && arg.toUpperCase(); + + for (var i = 0; i < this.options.length; i++) { + var current = this.options[i]; + + if (upperCaseArg === (current.short && current.short.toUpperCase()) || upperCaseArg === (current.name && current.name.toUpperCase())) { + return current; + } + } + + return null; + }; + + OptionsParser.prototype.printUsage = function () { + this.printVersion(); + + var optionsWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.options, null); + var fileWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.file1, null); + var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]"; + var syntaxHelp = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Syntax_0, [tscSyntax]); + this.host.printLine(syntaxHelp); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Examples, null) + " tsc hello.ts"); + this.host.printLine(" tsc --out foo.js foo.ts"); + this.host.printLine(" tsc @args.txt"); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Options, null)); + + var output = []; + var maxLength = 0; + var i = 0; + + this.options = this.options.sort(function (a, b) { + var aName = a.name.toLowerCase(); + var bName = b.name.toLowerCase(); + + if (aName > bName) { + return 1; + } else if (aName < bName) { + return -1; + } else { + return 0; + } + }); + + for (i = 0; i < this.options.length; i++) { + var option = this.options[i]; + + if (option.experimental) { + continue; + } + + if (!option.usage) { + break; + } + + var usageString = " "; + var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : ""; + + if (option.short) { + usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; + } + + usageString += this.DEFAULT_LONG_FLAG + option.name + type; + + output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]); + + if (usageString.length > maxLength) { + maxLength = usageString.length; + } + } + + var fileDescription = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null); + output.push([" @<" + fileWord + ">", fileDescription]); + + for (i = 0; i < output.length; i++) { + this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); + } + }; + + OptionsParser.prototype.printVersion = function () { + if (!this.printedVersion) { + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Version_0, [this.version])); + this.printedVersion = true; + } + }; + + OptionsParser.prototype.option = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = false; + + this.options.push(config); + }; + + OptionsParser.prototype.flag = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = true; + + this.options.push(config); + }; + + OptionsParser.prototype.parseString = function (argString) { + var position = 0; + var tokens = argString.match(/\s+|"|[^\s"]+/g); + + function peek() { + return tokens[position]; + } + + function consume() { + return tokens[position++]; + } + + function consumeQuotedString() { + var value = ''; + consume(); + + var token = peek(); + + while (token && token !== '"') { + consume(); + + value += token; + + token = peek(); + } + + consume(); + + return value; + } + + var args = []; + var currentArg = ''; + + while (position < tokens.length) { + var token = peek(); + + if (token === '"') { + currentArg += consumeQuotedString(); + } else if (token.match(/\s/)) { + if (currentArg.length > 0) { + args.push(currentArg); + currentArg = ''; + } + + consume(); + } else { + consume(); + currentArg += token; + } + } + + if (currentArg.length > 0) { + args.push(currentArg); + } + + this.parse(args); + }; + + OptionsParser.prototype.parse = function (args) { + var position = 0; + + function consume() { + return args[position++]; + } + + while (position < args.length) { + var current = consume(); + var match = current.match(/^(--?|@)(.*)/); + var value = null; + + if (match) { + if (match[1] === '@') { + this.parseString(this.host.readFile(match[2], null).contents); + } else { + var arg = match[2]; + var option = this.findOption(arg); + + if (option === null) { + this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_option_0, [arg])); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); + } else { + if (!option.flag) { + value = consume(); + if (value === undefined) { + this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Option_0_specified_without_1, [arg, TypeScript.getLocalizedText(option.type, null)])); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); + continue; + } + } + + option.set(value); + } + } + } else { + this.unnamed.push(current); + } + } + }; + return OptionsParser; + })(); + TypeScript.OptionsParser = OptionsParser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceFile = (function () { + function SourceFile(scriptSnapshot, byteOrderMark) { + this.scriptSnapshot = scriptSnapshot; + this.byteOrderMark = byteOrderMark; + } + return SourceFile; + })(); + + var DiagnosticsLogger = (function () { + function DiagnosticsLogger(ioHost) { + this.ioHost = ioHost; + } + DiagnosticsLogger.prototype.information = function () { + return false; + }; + DiagnosticsLogger.prototype.debug = function () { + return false; + }; + DiagnosticsLogger.prototype.warning = function () { + return false; + }; + DiagnosticsLogger.prototype.error = function () { + return false; + }; + DiagnosticsLogger.prototype.fatal = function () { + return false; + }; + DiagnosticsLogger.prototype.log = function (s) { + this.ioHost.stdout.WriteLine(s); + }; + 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.7.0"; + this.inputFiles = []; + this.resolvedFiles = []; + this.fileNameToSourceFile = new TypeScript.StringHashTable(); + this.hasErrors = false; + this.logger = null; + this.fileExistsCache = TypeScript.createIntrinsicsObject(); + this.resolvePathCache = TypeScript.createIntrinsicsObject(); + } + BatchCompiler.prototype.batchCompile = function () { + var _this = this; + var start = new Date().getTime(); + + TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { + _this.ioHost.printLine(s); + } }; + + if (this.parseOptions()) { + 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(); + return; + } + + this.resolve(); + + 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); + this.logger.log(" file read: " + TypeScript.fileResolutionIOTime); + this.logger.log(" scan imports: " + TypeScript.fileResolutionScanImportsTime); + this.logger.log(" import search: " + TypeScript.fileResolutionImportFileSearchTime); + this.logger.log(" get lib.d.ts: " + TypeScript.fileResolutionGetDefaultLibraryTime); + + this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime); + this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime); + this.logger.log("AST translation time: " + TypeScript.astTranslationTime); + this.logger.log(""); + this.logger.log("Type check time: " + TypeScript.typeCheckTime); + this.logger.log(""); + this.logger.log("Emit time: " + TypeScript.emitTime); + this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime); + + this.logger.log("Total number of symbols created: " + TypeScript.pullSymbolID); + this.logger.log("Specialized types created: " + TypeScript.nSpecializationsCreated); + this.logger.log("Specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); + + this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime); + this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime); + this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime); + this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime); + this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime); + this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime); + this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime); + this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime); + this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime); + + this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime); + + this.logger.log("Compiler resolve path time: " + TypeScript.compilerResolvePathTime); + this.logger.log("Compiler directory name time: " + TypeScript.compilerDirectoryNameTime); + this.logger.log("Compiler directory exists time: " + TypeScript.compilerDirectoryExistsTime); + this.logger.log("Compiler file exists time: " + TypeScript.compilerFileExistsTime); + + this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime); + this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime); + this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime); + this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime); + + this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime); + this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime); + this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime); + } + } + + this.ioHost.quit(this.hasErrors ? 1 : 0); + }; + + BatchCompiler.prototype.resolve = function () { + var _this = this; + var includeDefaultLibrary = !this.compilationSettings.noLib(); + var resolvedFiles = []; + + var start = new Date().getTime(); + + if (!this.compilationSettings.noResolve()) { + var resolutionResults = TypeScript.ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings.useCaseSensitiveFileResolution()); + resolvedFiles = resolutionResults.resolvedFiles; + + includeDefaultLibrary = !this.compilationSettings.noLib() && !resolutionResults.seenNoDefaultLibTag; + + resolutionResults.diagnostics.forEach(function (d) { + return _this.addDiagnostic(d); + }); + } else { + for (var i = 0, n = this.inputFiles.length; i < n; i++) { + var inputFile = this.inputFiles[i]; + var referencedFiles = []; + var importedFiles = []; + + if (this.compilationSettings.generateDeclarationFiles()) { + var references = TypeScript.getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile)); + for (var j = 0; j < references.length; j++) { + referencedFiles.push(references[j].path); + } + + inputFile = this.resolvePath(inputFile); + } + + resolvedFiles.push({ + path: inputFile, + referencedFiles: referencedFiles, + importedFiles: importedFiles + }); + } + } + + var defaultLibStart = new Date().getTime(); + if (includeDefaultLibrary) { + var libraryResolvedFile = { + path: this.getDefaultLibraryFilePath(), + referencedFiles: [], + importedFiles: [] + }; + + resolvedFiles = [libraryResolvedFile].concat(resolvedFiles); + } + TypeScript.fileResolutionGetDefaultLibraryTime += new Date().getTime() - defaultLibStart; + + this.resolvedFiles = resolvedFiles; + + TypeScript.fileResolutionTime = new Date().getTime() - start; + }; + + BatchCompiler.prototype.compile = function () { + var _this = this; + var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); + + this.resolvedFiles.forEach(function (resolvedFile) { + var sourceFile = _this.getSourceFile(resolvedFile.path); + compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, false, resolvedFile.referencedFiles); + }); + + for (var it = compiler.compile(function (path) { + return _this.resolvePath(path); + }); it.moveNext();) { + var result = it.current(); + + result.diagnostics.forEach(function (d) { + return _this.addDiagnostic(d); + }); + if (!this.tryWriteOutputFiles(result.outputFiles)) { + return; + } + } + }; + + BatchCompiler.prototype.parseOptions = function () { + var _this = this; + var opts = new TypeScript.OptionsParser(this.ioHost, this.compilerVersion); + + var mutableSettings = new TypeScript.CompilationSettings(); + opts.option('out', { + usage: { + locCode: TypeScript.DiagnosticCode.Concatenate_and_emit_output_to_single_file, + args: null + }, + type: TypeScript.DiagnosticCode.file2, + set: function (str) { + mutableSettings.outFileOption = str; + } + }); + + opts.option('outDir', { + usage: { + locCode: TypeScript.DiagnosticCode.Redirect_output_structure_to_the_directory, + args: null + }, + type: TypeScript.DiagnosticCode.DIRECTORY, + set: function (str) { + mutableSettings.outDirOption = str; + } + }); + + opts.flag('sourcemap', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.map'] + }, + set: function () { + mutableSettings.mapSourceFiles = true; + } + }); + + opts.option('mapRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + mutableSettings.mapRoot = str; + } + }); + + opts.option('sourceRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + mutableSettings.sourceRoot = str; + } + }); + + opts.flag('declaration', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.d.ts'] + }, + set: function () { + mutableSettings.generateDeclarationFiles = true; + } + }, 'd'); + + if (this.ioHost.watchFile) { + opts.flag('watch', { + usage: { + locCode: TypeScript.DiagnosticCode.Watch_input_files, + args: null + }, + set: function () { + mutableSettings.watch = true; + } + }, 'w'); + } + + opts.flag('propagateEnumConstants', { + experimental: true, + set: function () { + mutableSettings.propagateEnumConstants = true; + } + }); + + opts.flag('removeComments', { + usage: { + locCode: TypeScript.DiagnosticCode.Do_not_emit_comments_to_output, + args: null + }, + set: function () { + mutableSettings.removeComments = true; + } + }); + + opts.flag('noResolve', { + experimental: true, + usage: { + locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, + args: null + }, + set: function () { + mutableSettings.noResolve = true; + } + }); + + opts.flag('noLib', { + experimental: true, + set: function () { + mutableSettings.noLib = true; + } + }); + + opts.flag('diagnostics', { + experimental: true, + set: function () { + mutableSettings.gatherDiagnostics = true; + } + }); + + 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, + args: ['ES3', 'ES5'] + }, + type: TypeScript.DiagnosticCode.VERSION, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'es3') { + mutableSettings.codeGenTarget = 0 /* EcmaScript3 */; + } else if (type === 'es5') { + mutableSettings.codeGenTarget = 1 /* EcmaScript5 */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2, [type, "ES3", "ES5"])); + } + } + }, 't'); + + opts.option('module', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1, + args: ['commonjs', 'amd'] + }, + type: TypeScript.DiagnosticCode.KIND, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'commonjs') { + mutableSettings.moduleGenTarget = 1 /* Synchronous */; + } else if (type === 'amd') { + mutableSettings.moduleGenTarget = 2 /* Asynchronous */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type])); + } + } + }, 'm'); + + var needsHelp = false; + opts.flag('help', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_this_message, + args: null + }, + set: function () { + needsHelp = true; + } + }, 'h'); + + opts.flag('useCaseSensitiveFileResolution', { + experimental: true, + set: function () { + mutableSettings.useCaseSensitiveFileResolution = true; + } + }); + var shouldPrintVersionOnly = false; + opts.flag('version', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_the_compiler_s_version_0, + args: [this.compilerVersion] + }, + set: function () { + shouldPrintVersionOnly = true; + } + }, 'v'); + + var locale = null; + opts.option('locale', { + experimental: true, + usage: { + locCode: TypeScript.DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1, + args: ['en', 'ja-jp'] + }, + type: TypeScript.DiagnosticCode.STRING, + set: function (value) { + locale = value; + } + }); + + opts.flag('noImplicitAny', { + usage: { + locCode: TypeScript.DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, + args: null + }, + set: function () { + mutableSettings.noImplicitAny = true; + } + }); + + if (TypeScript.Environment.supportsCodePage()) { + opts.option('codepage', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_the_codepage_to_use_when_opening_source_files, + args: null + }, + type: TypeScript.DiagnosticCode.NUMBER, + set: function (arg) { + mutableSettings.codepage = parseInt(arg, 10); + } + }); + } + + opts.parse(this.ioHost.arguments); + + this.compilationSettings = TypeScript.ImmutableCompilationSettings.fromCompilationSettings(mutableSettings); + + if (locale) { + if (!this.setLocale(locale)) { + return false; + } + } + + this.inputFiles.push.apply(this.inputFiles, opts.unnamed); + + if (shouldPrintVersionOnly) { + opts.printVersion(); + return false; + } else if (this.inputFiles.length === 0 || needsHelp) { + opts.printUsage(); + return false; + } + + return !this.hasErrors; + }; + + BatchCompiler.prototype.setLocale = function (locale) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp'])); + return false; + } + + var language = matchResult[1]; + var territory = matchResult[3]; + + if (!this.setLanguageAndTerritory(language, territory) && !this.setLanguageAndTerritory(language, null)) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Unsupported_locale_0, [locale])); + return false; + } + + return true; + }; + + BatchCompiler.prototype.setLanguageAndTerritory = function (language, territory) { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + + var filePath = TypeScript.IOUtils.combine(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + + filePath = this.resolvePath(TypeScript.IOUtils.combine(filePath, "diagnosticMessages.generated.json")); + + if (!this.fileExists(filePath)) { + return false; + } + + var fileContents = this.ioHost.readFile(filePath, this.compilationSettings.codepage()); + TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents); + return true; + }; + + BatchCompiler.prototype.watchFiles = function () { + var _this = this; + if (!this.ioHost.watchFile) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]'])); + return; + } + + var lastResolvedFileSet = []; + var watchers = {}; + var firstTime = true; + + var addWatcher = function (fileName) { + if (!watchers[fileName]) { + var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); + watchers[fileName] = watcher; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); + } + }; + + var removeWatcher = function (fileName) { + if (watchers[fileName]) { + watchers[fileName].close(); + delete watchers[fileName]; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); + } + }; + + var onWatchedFileChange = function () { + _this.hasErrors = false; + + _this.fileNameToSourceFile = new TypeScript.StringHashTable(); + + _this.resolve(); + + var oldFiles = lastResolvedFileSet; + var newFiles = _this.resolvedFiles.map(function (resolvedFile) { + return resolvedFile.path; + }).sort(); + + var i = 0, j = 0; + while (i < oldFiles.length && j < newFiles.length) { + var compareResult = oldFiles[i].localeCompare(newFiles[j]); + if (compareResult === 0) { + i++; + j++; + } else if (compareResult < 0) { + removeWatcher(oldFiles[i]); + i++; + } else { + addWatcher(newFiles[j]); + j++; + } + } + + for (var k = i; k < oldFiles.length; k++) { + removeWatcher(oldFiles[k]); + } + + for (k = j; k < newFiles.length; k++) { + addWatcher(newFiles[k]); + } + + lastResolvedFileSet = newFiles; + + if (!firstTime) { + var fileNames = ""; + for (var k = 0; k < lastResolvedFileSet.length; k++) { + fileNames += TypeScript.Environment.newLine + " " + lastResolvedFileSet[k]; + } + _this.ioHost.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.NL_Recompiling_0, [fileNames])); + } else { + firstTime = false; + } + + _this.compile(); + }; + + this.ioHost.stderr = this.ioHost.stdout; + + onWatchedFileChange(); + }; + + BatchCompiler.prototype.getSourceFile = function (fileName) { + var sourceFile = this.fileNameToSourceFile.lookup(fileName); + if (!sourceFile) { + var fileInformation; + + try { + fileInformation = this.ioHost.readFile(fileName, this.compilationSettings.codepage()); + } catch (e) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message])); + fileInformation = new TypeScript.FileInformation("", 0 /* None */); + } + + var snapshot = TypeScript.ScriptSnapshot.fromString(fileInformation.contents); + var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark); + this.fileNameToSourceFile.add(fileName, sourceFile); + } + + return sourceFile; + }; + + BatchCompiler.prototype.getDefaultLibraryFilePath = function () { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + var libraryFilePath = this.resolvePath(TypeScript.IOUtils.combine(containingDirectoryPath, "lib.d.ts")); + + return libraryFilePath; + }; + + BatchCompiler.prototype.getScriptSnapshot = function (fileName) { + return this.getSourceFile(fileName).scriptSnapshot; + }; + + BatchCompiler.prototype.resolveRelativePath = function (path, directory) { + var start = new Date().getTime(); + + var unQuotedPath = TypeScript.stripStartAndEndQuotes(path); + var normalizedPath; + + if (TypeScript.isRooted(unQuotedPath) || !directory) { + normalizedPath = unQuotedPath; + } else { + normalizedPath = TypeScript.IOUtils.combine(directory, unQuotedPath); + } + + normalizedPath = this.resolvePath(normalizedPath); + + normalizedPath = TypeScript.switchToForwardSlashes(normalizedPath); + + return normalizedPath; + }; + + BatchCompiler.prototype.fileExists = function (path) { + var exists = this.fileExistsCache[path]; + if (exists === undefined) { + var start = new Date().getTime(); + exists = this.ioHost.fileExists(path); + this.fileExistsCache[path] = exists; + TypeScript.compilerFileExistsTime += new Date().getTime() - start; + } + + return exists; + }; + + BatchCompiler.prototype.getParentDirectory = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.dirName(path); + TypeScript.compilerDirectoryNameTime += new Date().getTime() - start; + + return result; + }; + + BatchCompiler.prototype.addDiagnostic = function (diagnostic) { + var diagnosticInfo = diagnostic.info(); + if (diagnosticInfo.category === 1 /* Error */) { + this.hasErrors = true; + } + + this.ioHost.stderr.Write(TypeScript.TypeScriptCompiler.getFullDiagnosticText(diagnostic)); + }; + + BatchCompiler.prototype.tryWriteOutputFiles = function (outputFiles) { + for (var i = 0, n = outputFiles.length; i < n; i++) { + var outputFile = outputFiles[i]; + + try { + this.writeFile(outputFile.name, outputFile.text, outputFile.writeByteOrderMark); + } catch (e) { + this.addDiagnostic(new TypeScript.Diagnostic(outputFile.name, null, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])); + return false; + } + } + + return true; + }; + + BatchCompiler.prototype.writeFile = function (fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + TypeScript.IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark); + TypeScript.emitWriteFileTime += new Date().getTime() - start; + }; + + BatchCompiler.prototype.directoryExists = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.directoryExists(path); + TypeScript.compilerDirectoryExistsTime += new Date().getTime() - start; + return result; + }; + + BatchCompiler.prototype.resolvePath = function (path) { + var cachedValue = this.resolvePathCache[path]; + if (!cachedValue) { + var start = new Date().getTime(); + cachedValue = this.ioHost.resolvePath(path); + this.resolvePathCache[path] = cachedValue; + TypeScript.compilerResolvePathTime += new Date().getTime() - start; + } + + return cachedValue; + }; + return BatchCompiler; + })(); + TypeScript.BatchCompiler = BatchCompiler; + + var batch = new TypeScript.BatchCompiler(TypeScript.IO); + batch.batchCompile(); +})(TypeScript || (TypeScript = {})); diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/typescript.js b/_infrastructure/tests/typescript/0.9.7-66c2df/typescript.js new file mode 100644 index 0000000000..29ed8063a7 --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7-66c2df/typescript.js @@ -0,0 +1,61380 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.DiagnosticCode = { + error_TS_0_1: "error TS{0}: {1}", + warning_TS_0_1: "warning TS{0}: {1}", + Unrecognized_escape_sequence: "Unrecognized escape sequence.", + Unexpected_character_0: "Unexpected character {0}.", + Missing_close_quote_character: "Missing close quote character.", + Identifier_expected: "Identifier expected.", + _0_keyword_expected: "'{0}' keyword expected.", + _0_expected: "'{0}' expected.", + Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", + Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", + Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", + Trailing_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", + Unexpected_token: "Unexpected token.", + Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", + Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", + Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", + Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", + Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", + Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", + extends_clause_already_seen: "'extends' clause already seen.", + extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", + Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", + implements_clause_already_seen: "'implements' clause already seen.", + Accessibility_modifier_already_seen: "Accessibility modifier already seen.", + _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", + _0_modifier_already_seen: "'{0}' modifier already seen.", + _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", + Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", + super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", + Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", + Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", + 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_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}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", + set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", + set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", + get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", + Modifiers_cannot_appear_here: "Modifiers cannot appear here.", + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", + Class_name_cannot_be_0: "Class name cannot be '{0}'.", + Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", + Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + Enum_member_must_have_initializer: "Enum member must have initializer.", + Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", + module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", + constructor_function_accessor_or_variable: "constructor, function, accessor or variable", + statement: "statement", + case_or_default_clause: "case or default clause", + identifier: "identifier", + call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", + expression: "expression", + type_name: "type name", + property_or_accessor: "property or accessor", + parameter: "parameter", + type: "type", + type_parameter: "type parameter", + 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_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.", + super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", + Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", + Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", + Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", + Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", + Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", + Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", + Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", + Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", + Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", + Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", + Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", + Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", + Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", + Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", + Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", + Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", + Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", + Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", + Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", + Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", + Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", + Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", + Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", + Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", + Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", + Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", + Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", + Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", + Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", + Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", + Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", + Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", + Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", + Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", + A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", + Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", + Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", + Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", + A_class_may_only_extend_another_class: "A class may only extend another class.", + A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", + An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", + Unable_to_resolve_type: "Unable to resolve type.", + Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", + Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", + Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", + Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", + Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", + Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", + Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", + Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", + Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + 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_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_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.", + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", + Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", + Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", + 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_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}'.", + 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.", + Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", + Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", + Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", + All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", + Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", + Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", + this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", + Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", + Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", + 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_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.", + Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", + A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", + 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_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_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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", + Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", + Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", + 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_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}", + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", + Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", + All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", + super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", + Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", + Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", + Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", + Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", + Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", + continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", + break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", + Jump_target_not_found: "Jump target not found.", + Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", + TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", + TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", + TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", + TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", + TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", + TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", + Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", + 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}", + Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", + Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", + Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", + Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", + Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", + Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", + Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", + Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", + Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", + 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.", + 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_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_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.", + Could_not_find_file_0: "Could not find file: '{0}'.", + A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", + Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", + Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", + Emit_Error_0: "Emit Error: {0}.", + Cannot_read_file_0_1: "Cannot read file '{0}': {1}", + Unsupported_file_encoding: "Unsupported file encoding.", + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Invalid_call_to_up: "Invalid call to 'up'", + Invalid_call_to_down: "Invalid call to 'down'", + Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", + Unknown_option_0: "Unknown option '{0}'", + Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", + Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", + Could_not_delete_file_0: "Could not delete file '{0}'", + Could_not_create_directory_0: "Could not create directory '{0}'", + Error_while_executing_file_0: "Error while executing file '{0}': ", + Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", + Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", + Option_0_specified_without_1: "Option '{0}' specified without '{1}'", + codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", + Generates_corresponding_0_file: "Generates corresponding {0} file.", + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", + Watch_input_files: "Watch input files.", + Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", + Do_not_emit_comments_to_output: "Do not emit comments to output.", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", + Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", + Print_this_message: "Print this message.", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file1: "file", + Examples: "Examples:", + Options: "Options:", + Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", + Version_0: "Version {0}", + Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", + NL_Recompiling_0: "{NL}Recompiling ({0}):", + STRING: "STRING", + KIND: "KIND", + file2: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + 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})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", + Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", + Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", + Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", + Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", + new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", + _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", + Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", + 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.", + 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; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + return false; + } + + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0, n = array1.length; i < n; i++) { + if (!equals(array1[i], array2[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.distinct = function (array, equalsFn) { + var result = []; + + for (var i = 0, n = array.length; i < n; i++) { + var current = array[i]; + for (var j = 0; j < result.length; j++) { + if (equalsFn(result[j], current)) { + break; + } + } + + if (j === result.length) { + result.push(current); + } + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.lastOrDefault = function (array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var v = array[i]; + if (predicate(v, i)) { + return v; + } + } + + return null; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value, i)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.first = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (!func || func(value, i)) { + return value; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + var low = 0; + var high = array.length - 1; + + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + + if (midValue === value) { + return middle; + } else if (midValue > value) { + high = middle - 1; + } else { + low = middle + 1; + } + } + + return ~low; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + + ArrayUtilities.indexOf = function (array, predicate) { + for (var i = 0, n = array.length; i < n; i++) { + if (predicate(array[i])) { + return i; + } + } + + return -1; + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitVector) { + var pool = []; + var Constants; + (function (Constants) { + Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; + Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; + + Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; + + Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; + Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; + + Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; + Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; + Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; + })(Constants || (Constants = {})); + + var BitVectorImpl = (function () { + function BitVectorImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.bits = []; + } + BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; + }; + + BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; + }; + + BitVectorImpl.prototype.valueAt = function (index) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return undefined; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { + return true; + } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { + return false; + } else { + return undefined; + } + } else { + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return false; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { + return true; + } else { + return false; + } + } + }; + + BitVectorImpl.prototype.setValueAt = function (index, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); + + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === undefined) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + + var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); + encoded = encoded & clearMask; + + if (value === true) { + encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); + } else if (value === false) { + encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } else { + TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); + + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === false) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + + encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); + + if (value) { + encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } + }; + + BitVectorImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + this.bits.length = 0; + pool.push(this); + }; + return BitVectorImpl; + })(); + + function getBitVector(allowUndefinedValues) { + if (pool.length === 0) { + return new BitVectorImpl(allowUndefinedValues); + } + + var vector = pool.pop(); + vector.isReleased = false; + vector.allowUndefinedValues = allowUndefinedValues; + + return vector; + } + BitVector.getBitVector = getBitVector; + })(TypeScript.BitVector || (TypeScript.BitVector = {})); + var BitVector = TypeScript.BitVector; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitMatrix) { + var pool = []; + + var BitMatrixImpl = (function () { + function BitMatrixImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.vectors = []; + } + BitMatrixImpl.prototype.valueAt = function (x, y) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + return this.allowUndefinedValues ? undefined : false; + } + + return vector.valueAt(y); + }; + + BitMatrixImpl.prototype.setValueAt = function (x, y, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + if (value === undefined) { + return; + } + + vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); + this.vectors[x] = vector; + } + + vector.setValueAt(y, value); + }; + + BitMatrixImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + + for (var name in this.vectors) { + if (this.vectors.hasOwnProperty(name)) { + var vector = this.vectors[name]; + vector.release(); + } + } + + this.vectors.length = 0; + pool.push(this); + }; + return BitMatrixImpl; + })(); + + function getBitMatrix(allowUndefinedValues) { + if (pool.length === 0) { + return new BitMatrixImpl(allowUndefinedValues); + } + + var matrix = pool.pop(); + matrix.isReleased = false; + matrix.allowUndefinedValues = allowUndefinedValues; + + return matrix; + } + BitMatrix.getBitMatrix = getBitMatrix; + })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); + var BitMatrix = TypeScript.BitMatrix; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); + var AssertionLevel = TypeScript.AssertionLevel; + + var Debug = (function () { + function Debug() { + } + Debug.shouldAssert = function (level) { + return this.currentAssertionLevel >= level; + }; + + Debug.assert = function (expression, message, verboseDebugInfo) { + if (typeof message === "undefined") { message = ""; } + if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); + } + + throw new Error("Debug Failure. False expression: " + message + verboseDebugString); + } + }; + + Debug.fail = function (message) { + Debug.assert(false, message); + }; + Debug.currentAssertionLevel = 0 /* None */; + return Debug; + })(); + 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 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(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; + } + + return result; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return this._additionalLocations || []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + + Diagnostic.prototype.info = function () { + return getDiagnosticInfoFromKey(this.diagnosticKey()); + }; + return Diagnostic; + })(Location); + TypeScript.Diagnostic = Diagnostic; + + function newLine() { + return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while (match = regex.exec(diagnostic)) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result); + return result; + } + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); + } + + diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { + return typeof args[num] !== 'undefined' ? args[num] : match; + }); + + diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { + return TypeScript.newLine(); + }); + + return diagnosticMessageText; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error("Invalid argument: " + argument + ". " + message); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error("Argument out of range: " + argument); + }; + + Errors.argumentNull = function (argument) { + return new Error("Argument null: " + argument); + }; + + Errors.abstract = function () { + return new Error("Operation not implemented properly by subclass."); + }; + + Errors.notYetImplemented = function () { + return new Error("Not yet implemented."); + }; + + Errors.invalidOperation = function (message) { + return new Error("Invalid operation: " + message); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft === 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, + 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, + 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, + 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, + 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, + 4166287, 4999559, 5999471, 7199369]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? key.hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', "Key was already in table."); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; + + (function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; + })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); + var ByteOrderMark = TypeScript.ByteOrderMark; + + var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; + })(); + TypeScript.FileInformation = FileInformation; + + TypeScript.Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return WScript.CreateObject("WScript.Shell").CurrentDirectory; + }, + supportsCodePage: function () { + return WScript.ReadFile; + }, + readFile: function (path, codepage) { + try { + if (codepage !== null && this.supportsCodePage()) { + try { + var contents = WScript.ReadFile(path, codepage); + return new FileInformation(contents, 0 /* None */); + } catch (e) { + } + } + + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return process.cwd(); + }, + supportsCodePage: function () { + return false; + }, + readFile: function (file, codepage) { + if (codepage !== null) { + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); + } + + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 509); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IntegerUtilities) { + function integerDivide(numerator, denominator) { + return (numerator / denominator) >> 0; + } + IntegerUtilities.integerDivide = integerDivide; + + function integerMultiplyLow32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + } + IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; + + function integerMultiplyHigh32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + } + IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + IntegerUtilities.isInteger = isInteger; + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + IntegerUtilities.isHexInteger = isHexInteger; + })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); + var IntegerUtilities = TypeScript.IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_computeLineStarts, length) { + this._computeLineStarts = _computeLineStarts; + this.length = length; + this._lineStarts = null; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this.lineStarts(), length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + if (this._lineStarts === null) { + this._lineStarts = this._computeLineStarts(); + } + + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + LineMap.empty = new LineMap(function () { + return [0]; + }, 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { + return e; + } + } + + return null; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + if (text.length !== length) { + return false; + } + + var s = start; + for (var i = 0; i < length; i++) { + if (text.charCodeAt(i) !== array[s]) { + return false; + } + + s++; + } + + return true; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static.": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static.": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Invalid 'reference' directive syntax.": { + "code": 1084, + "category": 1 /* Error */ + }, + "Octal literals are not available when targeting ECMAScript 5 and higher.": { + "code": 1085, + "category": 1 /* Error */ + }, + "Accessors are not allowed in ambient contexts.": { + "code": 1086, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a constructor declaration.": { + "code": 1089, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a parameter.": { + "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 */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static members cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* Error */ + }, + "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { + "code": 2104, + "category": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* Error */ + }, + "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { + "code": 2117, + "category": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "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 */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Type '{0}' does not have type parameters.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or not exported.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not assignable to any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "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 assignable to numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are only allowed in implementation.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { + "code": 2188, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { + "code": 2189, + "category": 1 /* Error */ + }, + "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { + "code": 2190, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot be reopened.": { + "code": 2191, + "category": 1 /* Error */ + }, + "All declarations of merged declaration '{0}' must be exported or not exported.": { + "code": 2192, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in constructor arguments.": { + "code": 2193, + "category": 1 /* Error */ + }, + "Return type of constructor signature must be assignable to the instance type of the class.": { + "code": 2194, + "category": 1 /* Error */ + }, + "Ambient external module declaration must be defined in global context.": { + "code": 2195, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot specify relative module name.": { + "code": 2196, + "category": 1 /* Error */ + }, + "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { + "code": 2197, + "category": 1 /* Error */ + }, + "Could not find the best common type of types of all return statement expressions.": { + "code": 2198, + "category": 1 /* Error */ + }, + "Import declaration cannot refer to external module reference when --noResolve option is set.": { + "code": 2199, + "category": 1 /* Error */ + }, + "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { + "code": 2200, + "category": 1 /* Error */ + }, + "'continue' statement can only be used within an enclosing iteration statement.": { + "code": 2201, + "category": 1 /* Error */ + }, + "'break' statement can only be used within an enclosing iteration or switch statement.": { + "code": 2202, + "category": 1 /* Error */ + }, + "Jump target not found.": { + "code": 2203, + "category": 1 /* Error */ + }, + "Jump target cannot cross function boundary.": { + "code": 2204, + "category": 1 /* Error */ + }, + "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { + "code": 2205, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { + "code": 2206, + "category": 1 /* Error */ + }, + "Expression resolves to '_super' that compiler uses to capture base class reference.": { + "code": 2207, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2208, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2209, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2210, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2211, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2212, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2213, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2214, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2215, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2216, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2217, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2218, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2219, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { + "code": 2220, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2221, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { + "code": 2222, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2223, + "category": 1 /* Error */ + }, + "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { + "code": 2224, + "category": 1 /* Error */ + }, + "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { + "code": 2225, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { + "code": 2226, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { + "code": 2227, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { + "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 */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Variable declaration cannot have the same name as an import declaration.": { + "code": 4026, + "category": 1 /* Error */ + }, + "Signature expected {0} type arguments, got {1} instead.": { + "code": 4027, + "category": 1 /* Error */ + }, + "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { + "code": 4028, + "category": 3 /* NoPrefix */ + }, + "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 infinitely expanding type reference have incompatible type arguments.": { + "code": 4030, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "code": 4031, + "category": 3 /* NoPrefix */ + }, + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { + "code": 4032, + "category": 3 /* NoPrefix */ + }, + "Types of string indexer of types '{0}' and '{1}' are not identical.": { + "code": 4033, + "category": 3 /* NoPrefix */ + }, + "Types of number indexer of types '{0}' and '{1}' are not identical.": { + "code": 4034, + "category": 3 /* NoPrefix */ + }, + "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 assignable to string indexer type in type '{2}'.{NL}{3}": { + "code": 4036, + "category": 3 /* NoPrefix */ + }, + "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 */ + }, + "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { + "code": 5002, + "category": 1 /* Error */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 1 /* Error */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit.": { + "code": 5021, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead.": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Option '{0}' specified without '{1}'": { + "code": 5041, + "category": 1 /* Error */ + }, + "'codepage' option not supported on current platform.": { + "code": 5042, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file.": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file.": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files.": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory.": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output.": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing.": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: '{0}' (default), or '{1}'": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: '{0}' or '{1}'": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message.": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated '{0}' keyword when referencing an external module.": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file1": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options.": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "file2": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "NUMBER": { + "code": 6039, + "category": 2 /* Message */ + }, + "Specify the codepage to use when opening source files.": { + "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 */ + }, + "Unknown rule.": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7015, + "category": 1 /* Error */ + }, + "'{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 = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + this._lineStartPositions = null; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + if (!this._lineStartPositions) { + this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); + } + + return this._lineStartPositions; + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LineMap1) { + function fromSimpleText(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return text.charCodeAt(index); + }, length: text.length() }); + }, text.length()); + } + LineMap1.fromSimpleText = fromSimpleText; + + function fromScriptSnapshot(scriptSnapshot) { + return new TypeScript.LineMap(function () { + return scriptSnapshot.getLineStartPositions(); + }, scriptSnapshot.getLength()); + } + LineMap1.fromScriptSnapshot = fromScriptSnapshot; + + function fromString(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts(text); + }, text.length); + } + LineMap1.fromString = fromString; + })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); + var LineMap1 = TypeScript.LineMap1; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this._lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this._lineStarts(); + }, this.length()); + }; + + TextBase.prototype._lineStarts = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this._lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + this._lazyLineStarts = null; + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.substr = function (start, length, intern) { + var startInOriginalText = this.span.start() + start; + return this.text.substr(startInOriginalText, length, intern); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SubText.prototype._lineStarts = function () { + var _this = this; + if (!this._lazyLineStarts) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return _this.charCodeAt(index); + }, length: this.length() }); + } + + return this._lazyLineStarts; + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + this._lazyLineStarts = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + + StringText.prototype._lineStarts = function () { + if (this._lazyLineStarts === null) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); + } + + return this._lazyLineStarts; + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap1.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + this._lineMap = null; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + if (!this._lineMap) { + this._lineMap = TypeScript.LineMap1.fromString(this.value); + } + + return this._lineMap; + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this.scriptSnapshot.getLineStartPositions(); + }, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length; + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + var change0 = changes[0]; + + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + + oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + CharacterInfo.isOctalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 55 /* _7 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + + SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; + + SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; + SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; + + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + + SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; + SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 164 /* PlusExpression */; + case 90 /* MinusToken */: + return 165 /* NegateExpression */; + case 102 /* TildeToken */: + return 166 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 167 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 168 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 169 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 210 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 211 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 205 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 206 /* DivideExpression */; + + case 92 /* PercentToken */: + return 207 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 208 /* AddExpression */; + + case 90 /* MinusToken */: + return 209 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 202 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 203 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 204 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 196 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 197 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 198 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 199 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 200 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 201 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 192 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 193 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 194 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 195 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 191 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 190 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 189 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 188 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 187 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 182 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 180 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 181 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 183 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 184 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 185 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 175 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 176 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 177 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 178 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 179 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 174 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 173 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function getOperatorTokenFromBinaryExpression(tokenKind) { + switch (tokenKind) { + case 205 /* MultiplyExpression */: + return 91 /* AsteriskToken */; + + case 206 /* DivideExpression */: + return 118 /* SlashToken */; + + case 207 /* ModuloExpression */: + return 92 /* PercentToken */; + + case 208 /* AddExpression */: + return 89 /* PlusToken */; + + case 209 /* SubtractExpression */: + return 90 /* MinusToken */; + + case 202 /* LeftShiftExpression */: + return 95 /* LessThanLessThanToken */; + + case 203 /* SignedRightShiftExpression */: + return 96 /* GreaterThanGreaterThanToken */; + + case 204 /* UnsignedRightShiftExpression */: + return 97 /* GreaterThanGreaterThanGreaterThanToken */; + + case 196 /* LessThanExpression */: + return 80 /* LessThanToken */; + + case 197 /* GreaterThanExpression */: + return 81 /* GreaterThanToken */; + + case 198 /* LessThanOrEqualExpression */: + return 82 /* LessThanEqualsToken */; + + case 199 /* GreaterThanOrEqualExpression */: + return 83 /* GreaterThanEqualsToken */; + + case 200 /* InstanceOfExpression */: + return 30 /* InstanceOfKeyword */; + + case 201 /* InExpression */: + return 29 /* InKeyword */; + + case 192 /* EqualsWithTypeConversionExpression */: + return 84 /* EqualsEqualsToken */; + + case 193 /* NotEqualsWithTypeConversionExpression */: + return 86 /* ExclamationEqualsToken */; + + case 194 /* EqualsExpression */: + return 87 /* EqualsEqualsEqualsToken */; + + case 195 /* NotEqualsExpression */: + return 88 /* ExclamationEqualsEqualsToken */; + + case 191 /* BitwiseAndExpression */: + return 98 /* AmpersandToken */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 100 /* CaretToken */; + + case 189 /* BitwiseOrExpression */: + return 99 /* BarToken */; + + case 188 /* LogicalAndExpression */: + return 103 /* AmpersandAmpersandToken */; + + case 187 /* LogicalOrExpression */: + return 104 /* BarBarToken */; + + case 182 /* OrAssignmentExpression */: + return 116 /* BarEqualsToken */; + + case 180 /* AndAssignmentExpression */: + return 115 /* AmpersandEqualsToken */; + + case 181 /* ExclusiveOrAssignmentExpression */: + return 117 /* CaretEqualsToken */; + + case 183 /* LeftShiftAssignmentExpression */: + return 112 /* LessThanLessThanEqualsToken */; + + case 184 /* SignedRightShiftAssignmentExpression */: + return 113 /* GreaterThanGreaterThanEqualsToken */; + + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + + case 175 /* AddAssignmentExpression */: + return 108 /* PlusEqualsToken */; + + case 176 /* SubtractAssignmentExpression */: + return 109 /* MinusEqualsToken */; + + case 177 /* MultiplyAssignmentExpression */: + return 110 /* AsteriskEqualsToken */; + + case 178 /* DivideAssignmentExpression */: + return 119 /* SlashEqualsToken */; + + case 179 /* ModuloAssignmentExpression */: + return 111 /* PercentEqualsToken */; + + case 174 /* AssignmentExpression */: + return 107 /* EqualsToken */; + + case 173 /* CommaExpression */: + return 79 /* CommaToken */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); + 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + 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 { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + 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(fullText, kind); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(text, start, isTrailing); + }; + + Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.slidingWindow.absoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(diagnostics); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(diagnostics); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifierOrKeyword(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var slidingWindow = this.slidingWindow; + var window = slidingWindow.window; + + var startIndex = slidingWindow.currentRelativeItemIndex; + var endIndex = slidingWindow.windowCount; + var currentIndex = startIndex; + var character = 0; + + while (currentIndex < endIndex) { + character = window[currentIndex]; + if (!isIdentifierPartCharacter[character]) { + break; + } + + currentIndex++; + } + + if (currentIndex === endIndex) { + return 0 /* None */; + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + return 0 /* None */; + } else { + var kind; + var identifierLength = currentIndex - startIndex; + if (isKeywordStartCharacter[firstCharacter]) { + kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); + } else { + kind = 11 /* IdentifierName */; + } + + slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); + + return kind; + } + }; + + Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + var sawUnicodeEscape = false; + + do { + var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); + sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + var length = this.slidingWindow.absoluteIndex() - startIndex; + var text = this.text.substr(startIndex, length, false); + var valueText = TypeScript.Syntax.massageEscapes(text); + + var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); + if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { + if (sawUnicodeEscape) { + return keywordKind | -2147483648 /* IsVariableWidthKeyword */; + } else { + return keywordKind; + } + } + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function (diagnostics) { + if (this.isHexNumericLiteral()) { + this.scanHexNumericLiteral(); + } else if (this.isOctalNumericLiteral()) { + this.scanOctalNumericLiteral(diagnostics); + } else { + this.scanDecimalNumericLiteral(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isOctalNumericLiteral = function () { + return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); + }; + + Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { + var position = this.absoluteIndex(); + + while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.languageVersion() >= 1 /* EcmaScript5 */) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); + } + }; + + Scanner.prototype.scanDecimalDigits = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + this.scanDecimalDigits(); + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + this.scanDecimalDigits(); + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + var nextChar1 = this.slidingWindow.peekItemN(1); + + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { + var nextChar2 = this.slidingWindow.peekItemN(2); + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } + } + } + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function (diagnostics) { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(diagnostics); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 12 /* RegularExpressionLiteral */; + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + break; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + break; + + default: + break; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + this.scanUnicodeOrHexEscape(errors); + return true; + } + } + + this.slidingWindow.moveToNextItem(); + return false; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return parent.type === nodeOrToken; + case 220 /* CastExpression */: + return parent.type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + case 228 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return TypeScript.Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return nodeOrToken.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + element.insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + element.insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + var firstToken = this.firstToken(); + return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.trailingTrivia = function () { + var lastToken = this.lastToken(); + return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + 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 === thisAsIndexable[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isExpression = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + + this._kind = kind; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.kind = function () { + return this._kind; + }; + + HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { + if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.name = name; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.name; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withName = function (name) { + return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { + if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.callSignature = callSignature; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 146 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.modifiers; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifiers = function (modifiers) { + return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + + this.arguments = _arguments; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 142 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 227 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 239 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.constructorKeyword = constructorKeyword; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.constructorKeyword; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + 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 */), CallSignatureSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var GetAccessorSyntax = (function (_super) { + __extends(GetAccessorSyntax, _super); + function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.getKeyword = getKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + } + GetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessor(this); + }; + + GetAccessorSyntax.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + + GetAccessorSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + GetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + GetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetAccessorSyntax.create1 = function (propertyName) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GetAccessorSyntax = GetAccessorSyntax; + + var SetAccessorSyntax = (function (_super) { + __extends(SetAccessorSyntax, _super); + function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.setKeyword = setKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + SetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessor(this); + }; + + SetAccessorSyntax.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + + SetAccessorSyntax.prototype.childCount = function () { + return 5; + }; + + SetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + SetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetAccessorSyntax.create1 = function (propertyName) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SetAccessorSyntax = SetAccessorSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var IndexMemberDeclarationSyntax = (function (_super) { + __extends(IndexMemberDeclarationSyntax, _super); + function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.indexSignature = indexSignature; + this.semicolonToken = semicolonToken; + } + IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexMemberDeclaration(this); + }; + + IndexMemberDeclarationSyntax.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + + IndexMemberDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.indexSignature; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexMemberDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { + if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { + return this; + } + + return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); + }; + + IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); + }; + + IndexMemberDeclarationSyntax.create1 = function (indexSignature) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { + return this.update(this.modifiers, indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.indexSignature, semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexMemberDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + this.colonToken = colonToken; + this.statements = statements; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + this.colonToken = colonToken; + this.statements = statements; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.doKeyword = doKeyword; + this.statement = statement; + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + 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) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var dedentThisTrivia = dedentNextWhitespace; + dedentNextWhitespace = false; + + if (dedentThisTrivia) { + if (trivia.kind() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + var indentNextTrivia = true; + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var indentThisTrivia = indentNextTrivia; + indentNextTrivia = false; + + switch (trivia.kind()) { + case 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; + this.tokenKind = kind; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function isExpression(token) { + switch (token.tokenKind) { + case 11 /* IdentifierName */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 50 /* SuperKeyword */: + return true; + } + + return false; + } + Syntax.isExpression = isExpression; + + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + case 13 /* carriageReturn */: + var nextIndex = i + 1; + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { + i++; + } + continue; + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + return regularExpressionValue(text); + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function regularExpressionValue(text) { + try { + var lastSlash = text.lastIndexOf("/"); + var body = text.substring(1, lastSlash); + var flags = text.substring(lastSlash + 1); + return new RegExp(body, flags); + } catch (e) { + return null; + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + EmptyToken.prototype.isExpression = function () { + return isExpression(this); + }; + + EmptyToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + + RealizedToken.prototype.isExpression = function () { + return isExpression(this); + }; + + RealizedToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var AbstractTrivia = (function () { + function AbstractTrivia(_kind) { + this._kind = _kind; + } + AbstractTrivia.prototype.fullWidth = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.fullText = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.toJSON = function (key) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === this._kind) { + result.kind = name; + break; + } + } + + if (this.isSkippedToken()) { + result.skippedToken = this.skippedToken(); + } else { + result.text = this.fullText(); + } + return result; + }; + + AbstractTrivia.prototype.kind = function () { + return this._kind; + }; + + AbstractTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + AbstractTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + AbstractTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + AbstractTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + AbstractTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return AbstractTrivia; + })(); + + var NormalTrivia = (function (_super) { + __extends(NormalTrivia, _super); + function NormalTrivia(kind, _text) { + _super.call(this, kind); + this._text = _text; + } + NormalTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + NormalTrivia.prototype.fullText = function () { + return this._text; + }; + + NormalTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return NormalTrivia; + })(AbstractTrivia); + + var SkippedTokenTrivia = (function (_super) { + __extends(SkippedTokenTrivia, _super); + function SkippedTokenTrivia(_skippedToken) { + _super.call(this, 8 /* SkippedTokenTrivia */); + this._skippedToken = _skippedToken; + } + SkippedTokenTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SkippedTokenTrivia.prototype.fullText = function () { + return this.skippedToken().fullText(); + }; + + SkippedTokenTrivia.prototype.skippedToken = function () { + return this._skippedToken; + }; + return SkippedTokenTrivia; + })(AbstractTrivia); + + var DeferredTrivia = (function (_super) { + __extends(DeferredTrivia, _super); + function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { + _super.call(this, kind); + this._text = _text; + this._fullStart = _fullStart; + this._fullWidth = _fullWidth; + this._fullText = null; + } + DeferredTrivia.prototype.fullWidth = function () { + return this._fullWidth; + }; + + DeferredTrivia.prototype.fullText = function () { + if (!this._fullText) { + this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); + this._text = null; + } + + return this._fullText; + }; + + DeferredTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return DeferredTrivia; + })(AbstractTrivia); + + function deferredTrivia(kind, text, fullStart, fullWidth) { + return new DeferredTrivia(kind, text, fullStart, fullWidth); + } + Syntax.deferredTrivia = deferredTrivia; + + function trivia(kind, text) { + return new NormalTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SkippedTokenTrivia(token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + this.trivia[i].collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 228 /* TypeArgumentList */: + case 229 /* TypeParameterList */: + case 220 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.name); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitList(node.modifiers); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.constructorKeyword); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.indexSignature); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + + + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + var result = this.currentToken(); + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + + return result; + }; + return SyntaxCursor; + })(); + + + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); + } + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { + this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 173 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 186 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 187 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 188 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 189 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 191 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 167 /* LogicalNotExpression */: + case 170 /* DeleteExpression */: + case 171 /* TypeOfExpression */: + case 172 /* VoidExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); + } + } + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + var modifierCount = this.modifierCount(); + return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + var modifierCount = this.modifierCount(); + if (this.isImportDeclaration(modifierCount)) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration(modifierCount)) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration(modifierCount)) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration(modifierCount)) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration(modifierCount)) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(inErrorRecovery)) { + return this.parseStatement(inErrorRecovery); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + + return typeArgumentList; + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isAccessor = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(false); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexMemberDeclaration()) { + return this.parseIndexMemberDeclaration(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var modifiers = this.parseModifiers(); + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var callSignature = this.parseCallSignature(false); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.isIndexMemberDeclaration = function () { + var index = this.modifierCount(); + return this.isIndexSignature(index); + }; + + ParserImpl.prototype.parseIndexMemberDeclaration = function () { + var modifiers = this.parseModifiers(); + var indexSignature = this.parseIndexSignature(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + if (callSignature.lastToken()) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature(0)) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(inErrorRecovery)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(inErrorRecovery)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function (tokenIndex) { + return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isIdentifier(this.currentToken())) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + + break; + + case 28 /* IfKeyword */: + case 70 /* OpenBraceToken */: + case 33 /* ReturnKeyword */: + case 34 /* SwitchKeyword */: + case 36 /* ThrowKeyword */: + case 15 /* BreakKeyword */: + case 18 /* ContinueKeyword */: + case 26 /* ForKeyword */: + case 42 /* WhileKeyword */: + case 43 /* WithKeyword */: + case 22 /* DoKeyword */: + case 38 /* TryKeyword */: + case 19 /* DebuggerKeyword */: + return true; + } + + if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { + return false; + } + + return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); + }; + + ParserImpl.prototype.parseStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 28 /* IfKeyword */: + return this.parseIfStatement(); + case 70 /* OpenBraceToken */: + return this.parseBlock(false, false); + case 33 /* ReturnKeyword */: + return this.parseReturnStatement(); + case 34 /* SwitchKeyword */: + return this.parseSwitchStatement(); + case 36 /* ThrowKeyword */: + return this.parseThrowStatement(); + case 15 /* BreakKeyword */: + return this.parseBreakStatement(); + case 18 /* ContinueKeyword */: + return this.parseContinueStatement(); + case 26 /* ForKeyword */: + return this.parseForOrForInStatement(); + case 42 /* WhileKeyword */: + return this.parseWhileStatement(); + case 43 /* WithKeyword */: + return this.parseWithStatement(); + case 22 /* DoKeyword */: + return this.parseDoStatement(); + case 38 /* TryKeyword */: + return this.parseTryStatement(); + case 19 /* DebuggerKeyword */: + return this.parseDebuggerStatement(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement(currentToken)) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { + return this.parseEmptyStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(false); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function (currentToken) { + return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(false); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return currentToken.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function (currentToken) { + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function (currentToken) { + switch (currentToken.tokenKind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + + case 74 /* OpenBracketToken */: + + case 72 /* OpenParenToken */: + + case 80 /* LessThanToken */: + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + + case 70 /* OpenBraceToken */: + + case 85 /* EqualsGreaterThanToken */: + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + + case 31 /* NewKeyword */: + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + + case 27 /* FunctionKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(false); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 225 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(token0); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpressionOrLower = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpressionOrLower(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else if (currentTokenKind === 39 /* TypeOfKeyword */) { + return this.parseTypeOfExpression(); + } else if (currentTokenKind === 41 /* VoidKeyword */) { + return this.parseVoidExpression(); + } else if (currentTokenKind === 21 /* DeleteKeyword */) { + return this.parseDeleteExpression(); + } else if (currentTokenKind === 80 /* LessThanToken */) { + return this.parseCastExpression(); + } else { + return this.parsePostfixExpressionOrLower(); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + if (precedence <= 2 /* AssignmentExpressionPrecedence */) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } + + var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); + if (parethesizedArrowFunction !== null) { + return parethesizedArrowFunction; + } + } + + var leftOperand = this.parseUnaryExpressionOrLower(); + return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } + + var expression = this.parsePrimaryExpression(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + return this.parseMemberExpressionRest(expression, false, inObjectCreation); + }; + + ParserImpl.prototype.parseCallExpressionOrLower = function () { + var expression; + if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { + expression = this.eatKeyword(50 /* SuperKeyword */); + + var currentTokenKind = this.currentToken().tokenKind; + if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + } + } else { + expression = this.parseMemberExpressionOrLower(false); + } + + return this.parseMemberExpressionRest(expression, true, false); + }; + + ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (!allowArguments) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (!allowArguments) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseCallExpressionOrLower(); + } + }; + + ParserImpl.prototype.parsePostfixExpressionOrLower = function () { + var expression = this.parseLeftHandSideExpressionOrLower(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + } + + return expression; + }; + + ParserImpl.prototype.tryParseGenericArgumentList = function () { + var rewindPoint = this.getRewindPoint(); + + var typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + + var argumentList = null; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } else { + return this.parseArgumentList(typeArgumentList); + } + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + return this.tryParseGenericArgumentList(); + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(null); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var _arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + _arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parsePrimaryExpression = function () { + var currentToken = this.currentToken(); + + if (this.isIdentifier(currentToken)) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseObjectCreationExpressionOrLower(true); + var argumentList = this.tryParseArgumentList(); + + var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); + return this.parseMemberExpressionRest(result, true, false); + }; + + ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseMemberExpressionOrLower(inObjectCreation); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedExpression = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { + return null; + } + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + + this.releaseRewindPoint(rewindPoint); + return arrowFunction; + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.tryParseArrowFunctionBlock = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { + return this.parseBlock(true, false); + } else { + return null; + } + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + token2 = this.peekToken(2); + if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { + if (this.isIdentifier(token2)) { + return true; + } + } + + if (!this.isIdentifier(token1)) { + return false; + } + + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { + if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(true); + } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + return this.eatKeyword(35 /* ThisKeyword */); + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameters = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); + + return typeParameterList; + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 39 /* TypeOfKeyword */: + + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + + case 70 /* OpenBraceToken */: + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + + case 31 /* NewKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + var type = this.parseNonArrayType(currentToken); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function (currentToken) { + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return this.eatAnyToken(); + + case 70 /* OpenBraceToken */: + return this.parseObjectType(); + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + return this.parseFunctionType(); + + case 31 /* NewKeyword */: + return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); + } + + return this.parseNameOrGenericType(); + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + var tokenKind = token.tokenKind; + if (tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { + if (this.isIdentifier(token)) { + var nextTokenKind = this.peekToken(1).tokenKind; + switch (nextTokenKind) { + case 73 /* CloseParenToken */: + case 106 /* ColonToken */: + case 107 /* EqualsToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { + modifierArray.push(this.eatAnyToken()); + continue; + } + + break; + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + 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; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType, inErrorRecovery); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + var currentToken = this.currentToken(); + if (this.isExpression(currentToken)) { + return true; + } + + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.parseStatement(inErrorRecovery); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(inErrorRecovery); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.inObjectLiteralExpression = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { + return true; + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { + if (parameter.modifiers.childCount() > 0) { + var modifiers = parameter.modifiers; + var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + + if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { + if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); + return true; + } else { + if (modifierIndex > 0) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + 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.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; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.modifiers.childCount() > 0) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + 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; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + 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) { + 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; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + 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; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { + var getKeywordFullStart = this.childFullStart(node, getKeyword); + if (parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { + if (this.checkIndexMemberModifiers(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIndexMemberDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { + if (node.modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(node, node.modifiers); + this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { + var savedInObjectLiteralExpression = this.inObjectLiteralExpression; + this.inObjectLiteralExpression = true; + _super.prototype.visitObjectLiteralExpression.call(this, node); + this.inObjectLiteralExpression = savedInObjectLiteralExpression; + }; + + GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { + var setKeywordFullStart = this.childFullStart(node, setKeyword); + if (parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); + var parameter = parameterList.parameters.childAt(0); + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + 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 && previousValueWasComputed) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (node.stringLiteral === null) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { + this.skip(node); + return; + } + + _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); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock || this.inObjectLiteralExpression) { + if (modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { + this.skip(node); + return; + } + + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { + var currentElementFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var child = modifiers.childAt(i); + if (child.kind() !== 57 /* PublicKeyword */) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); + return true; + } + + currentElementFullStart += child.fullWidth(); + } + + 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); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Document = (function () { + function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { + this._compiler = _compiler; + this._semanticInfoChain = _semanticInfoChain; + this.fileName = fileName; + this.referencedFiles = referencedFiles; + this._scriptSnapshot = _scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._syntaxTree = _syntaxTree; + this._topLevelDecl = _topLevelDecl; + this._diagnostics = null; + this._bloomFilter = null; + this._sourceUnit = null; + this._lineMap = null; + this._declASTMap = []; + this._astDeclMap = []; + this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; + } + Document.prototype.invalidate = function () { + this._declASTMap.length = 0; + this._astDeclMap.length = 0; + this._topLevelDecl = null; + + this._syntaxTree = null; + this._sourceUnit = null; + this._diagnostics = null; + this._bloomFilter = null; + }; + + Document.prototype.isDeclareFile = function () { + return TypeScript.isDTSFile(this.fileName); + }; + + Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + + this._lineMap = syntaxTree.lineMap(); + + var sourceUnit = syntaxTree.sourceUnit(); + var leadingTrivia = sourceUnit.leadingTrivia(); + + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); + + var amdDependencies = []; + 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); + } + } + } + + this._amdDependencies = amdDependencies; + }; + + Document.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(trivia.fullText()); + + if (match) { + return new TypeScript.TextSpan(position, trivia.fullWidth()); + } + + return null; + }; + + 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); + } + } + + position += moduleElement.fullWidth(); + } + + return null; + ; + }; + + Document.prototype.sourceUnit = function () { + if (!this._sourceUnit) { + var start = new Date().getTime(); + var syntaxTree = this.syntaxTree(); + this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + + if (!this.isOpen) { + this._syntaxTree = null; + } + } + + return this._sourceUnit; + }; + + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._diagnostics); + } + + return this._diagnostics; + }; + + Document.prototype.lineMap = function () { + if (this._lineMap === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._lineMap); + } + + return this._lineMap; + }; + + Document.prototype.isExternalModule = function () { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); + } + + return this._externalModuleIndicatorSpan; + }; + + Document.prototype.amdDependencies = function () { + if (this._amdDependencies === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._amdDependencies !== undefined); + } + + return this._amdDependencies; + }; + + Document.prototype.syntaxTree = function () { + var result = this._syntaxTree; + if (!result) { + var start = new Date().getTime(); + + result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); + + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + if (this.isOpen || !this._sourceUnit) { + this._syntaxTree = result; + } + } + + this.cacheSyntaxTreeInfo(result); + return result; + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = TypeScript.createIntrinsicsObject(); + var pre = function (cur) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { + if (cur.kind() === 11 /* IdentifierName */) { + var nodeText = cur.valueText(); + + identifiers[nodeText] = true; + } + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.emitToOwnOutputFile = function () { + return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { + var oldSyntaxTree = this._syntaxTree; + + if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { + var oldText = this._scriptSnapshot; + var newText = scriptSnapshot; + + TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); + var newTextPrefix = newText.getText(0, textChangeRange.span().start()); + TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); + + var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); + var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); + TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); + }; + + Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); + }; + + Document.prototype.topLevelDecl = function () { + if (this._topLevelDecl === null) { + this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); + } + + return this._topLevelDecl; + }; + + Document.prototype._getDeclForAST = function (ast) { + this.topLevelDecl(); + return this._astDeclMap[ast.syntaxID()]; + }; + + Document.prototype.getEnclosingDecl = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + return this._getDeclForAST(ast); + } + + ast = ast.parent; + var decl = null; + while (ast) { + decl = this._getDeclForAST(ast); + + if (decl) { + break; + } + + ast = ast.parent; + } + + return decl._getEnclosingDeclFromParentDecl(); + }; + + Document.prototype._setDeclForAST = function (ast, decl) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._astDeclMap[ast.syntaxID()] = decl; + }; + + Document.prototype._getASTForDecl = function (decl) { + return this._declASTMap[decl.declID]; + }; + + Document.prototype._setASTForDecl = function (decl, ast) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._declASTMap[decl.declID] = ast; + }; + return Document; + })(); + TypeScript.Document = Document; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var proto = "__proto__"; + + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + + this[proto] = null; + this[proto] = undefined; + } + return BlockIntrinsics; + })(); + + function createIntrinsicsObject() { + return new BlockIntrinsics(); + } + TypeScript.createIntrinsicsObject = createIntrinsicsObject; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = createIntrinsicsObject(); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (!fn(k, this.table[k], context)) { + return false; + } + } + } + + return true; + }; + + StringHashTable.prototype.some = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (fn(k, this.table[k], context)) { + return true; + } + } + } + + return false; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + + StringHashTable.prototype.remove = function (key) { + if (this.table[key] !== undefined) { + this.table[key] = undefined; + this.itemCount--; + } + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (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); + } + ASTHelpers.moduleIsElided = moduleIsElided; + + 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)) { + 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; + } + ASTHelpers.enumIsElided = enumIsElided; + + function isValidAstNode(ast) { + if (!ast) + return false; + + if (ast.start() === -1 || ast.end() === -1) + return false; + + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; + + 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; + + 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) { + top = cur; + } + } + } + } + + 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; + } + } + + return false; + } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; + + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } + + 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); + } + 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; + } + + current = current.parent; + } + 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; + } + + return null; + } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; + + 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; + } + 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; + + function parametersFromIdentifier(id) { + return { + length: 1, + lastParameterIsRest: function () { + return false; + }, + ast: id, + astAt: function (index) { + return id; + }, + identifierAt: function (index) { + return id; + }, + typeAt: function (index) { + return null; + }, + initializerAt: function (index) { + return null; + }, + isOptionalAt: function (index) { + return false; + } + }; + } + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; + + function parametersFromParameter(parameter) { + return { + length: 1, + lastParameterIsRest: function () { + return parameter.dotDotDotToken !== null; + }, + ast: parameter, + astAt: function (index) { + return parameter; + }, + identifierAt: function (index) { + return parameter.identifier; + }, + typeAt: function (index) { + return getType(parameter); + }, + initializerAt: function (index) { + return parameter.equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(parameter); + } + }; + } + ASTHelpers.parametersFromParameter = parametersFromParameter; + + function parameterIsOptional(parameter) { + return parameter.questionToken !== null || parameter.equalsValueClause !== null; + } + + function parametersFromParameterList(list) { + return { + length: list.parameters.nonSeparatorCount(), + lastParameterIsRest: function () { + return TypeScript.lastParameterIsRest(list); + }, + ast: list.parameters, + astAt: function (index) { + return list.parameters.nonSeparatorAt(index); + }, + identifierAt: function (index) { + return list.parameters.nonSeparatorAt(index).identifier; + }, + typeAt: function (index) { + return getType(list.parameters.nonSeparatorAt(index)); + }, + initializerAt: function (index) { + return list.parameters.nonSeparatorAt(index).equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(list.parameters.nonSeparatorAt(index)); + } + }; + } + ASTHelpers.parametersFromParameterList = parametersFromParameterList; + + 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; + } + } + ASTHelpers.isDeclarationAST = isDeclarationAST; + + 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; + } + + 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; + } + + ast = ast.parent; + } + + return null; + } + ASTHelpers.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); + + 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 { + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); + } + } + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function walkListChildren(preAst, walker) { + for (var i = 0, n = preAst.childCount(); i < n; i++) { + walker.walk(preAst.childAt(i)); + } + } + + function walkThrowStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkPrefixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkPostfixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkDeleteExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkTypeArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArguments); + } + + function walkTypeOfExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkVoidExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArgumentList); + walker.walk(preAst.arguments); + } + + function walkArrayLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.expressions); + } + + function walkSimplePropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.expression); + } + + function walkFunctionPropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkGetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkSeparatedListChildren(preAst, walker) { + for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { + walker.walk(preAst.nonSeparatorAt(i)); + } + } + + function walkSetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.block); + } + + function walkObjectLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.propertyAssignments); + } + + function walkCastExpressionChildren(preAst, walker) { + walker.walk(preAst.type); + walker.walk(preAst.expression); + } + + function walkParenthesizedExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkElementAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentExpression); + } + + function walkMemberAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.name); + } + + function walkQualifiedNameChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkBinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkEqualsValueClauseChildren(preAst, walker) { + walker.walk(preAst.value); + } + + function walkTypeParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.constraint); + } + + function walkTypeParameterListChildren(preAst, walker) { + walker.walk(preAst.typeParameters); + } + + function walkGenericTypeChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.typeArgumentList); + } + + function walkTypeAnnotationChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkTypeQueryChildren(preAst, walker) { + walker.walk(preAst.name); + } + + function walkInvocationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkObjectCreationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkTrinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.whenTrue); + walker.walk(preAst.whenFalse); + } + + function walkFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFunctionTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkMemberFunctionDeclarationChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFuncDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkIndexMemberDeclarationChildren(preAst, walker) { + walker.walk(preAst.indexSignature); + } + + function walkIndexSignatureChildren(preAst, walker) { + walker.walk(preAst.parameter); + walker.walk(preAst.typeAnnotation); + } + + function walkCallSignatureChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + } + + function walkConstraintChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkConstructorDeclarationChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkConstructorTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkConstructSignatureChildren(preAst, walker) { + walker.walk(preAst.callSignature); + } + + function walkParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkParameterListChildren(preAst, walker) { + walker.walk(preAst.parameters); + } + + function walkPropertySignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + } + + function walkVariableDeclaratorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkMemberVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.variableDeclarator); + } + + function walkMethodSignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + } + + function walkReturnStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkForStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.initializer); + walker.walk(preAst.condition); + walker.walk(preAst.incrementor); + walker.walk(preAst.statement); + } + + function walkForInStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.left); + walker.walk(preAst.expression); + walker.walk(preAst.statement); + } + + function walkIfStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + walker.walk(preAst.elseClause); + } + + function walkElseClauseChildren(preAst, walker) { + walker.walk(preAst.statement); + } + + function walkWhileStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkDoStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkBlockChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.declarators); + } + + function walkCaseSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.statements); + } + + function walkDefaultSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkSwitchStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.switchClauses); + } + + function walkTryStatementChildren(preAst, walker) { + walker.walk(preAst.block); + walker.walk(preAst.catchClause); + walker.walk(preAst.finallyClause); + } + + function walkCatchClauseChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkExternalModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.stringLiteral); + } + + function walkFinallyClauseChildren(preAst, walker) { + walker.walk(preAst.block); + } + + function walkClassDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.classElements); + } + + function walkScriptChildren(preAst, walker) { + walker.walk(preAst.moduleElements); + } + + function walkHeritageClauseChildren(preAst, walker) { + walker.walk(preAst.typeNames); + } + + function walkInterfaceDeclerationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.body); + } + + function walkObjectTypeChildren(preAst, walker) { + walker.walk(preAst.typeMembers); + } + + function walkArrayTypeChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkModuleDeclarationChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.stringLiteral); + walker.walk(preAst.moduleElements); + } + + function walkModuleNameModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.moduleName); + } + + function walkEnumDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.enumElements); + } + + function walkEnumElementChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.equalsValueClause); + } + + function walkImportDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.moduleReference); + } + + function walkExportAssignmentChildren(preAst, walker) { + walker.walk(preAst.identifier); + } + + function walkWithStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkExpressionStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkLabeledStatementChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.statement); + } + + function walkVariableStatementChildren(preAst, walker) { + walker.walk(preAst.declaration); + } + + var childrenWalkers = new Array(246 /* Last */ + 1); + + for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { + childrenWalkers[i] = null; + } + for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { + childrenWalkers[i] = null; + } + + childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; + childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[60 /* AnyKeyword */] = null; + childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; + childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; + childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; + childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; + childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; + childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[146 /* Block */] = walkBlockChildren; + childrenWalkers[61 /* BooleanKeyword */] = null; + childrenWalkers[152 /* BreakStatement */] = null; + childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; + childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; + childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; + childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; + childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; + childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; + childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; + childrenWalkers[239 /* Constraint */] = walkConstraintChildren; + childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; + childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; + childrenWalkers[153 /* ContinueStatement */] = null; + childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; + childrenWalkers[162 /* DebuggerStatement */] = null; + childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; + childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; + childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; + childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; + childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; + childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; + childrenWalkers[156 /* EmptyStatement */] = null; + childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; + childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; + childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; + childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; + childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; + childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; + childrenWalkers[24 /* FalseKeyword */] = null; + childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; + childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; + childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; + childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; + childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; + childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; + childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; + childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; + childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; + childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; + childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; + childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; + childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; + childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; + childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; + childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; + childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; + childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; + childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[1 /* List */] = walkListChildren; + childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; + childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; + childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; + childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; + childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; + childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; + childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; + childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; + childrenWalkers[11 /* IdentifierName */] = null; + childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[0 /* None */] = null; + childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[32 /* NullKeyword */] = null; + childrenWalkers[67 /* NumberKeyword */] = null; + childrenWalkers[13 /* NumericLiteral */] = null; + childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; + childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; + childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; + childrenWalkers[223 /* OmittedExpression */] = null; + childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[242 /* Parameter */] = walkParameterChildren; + childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; + childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; + childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; + childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; + childrenWalkers[12 /* RegularExpressionLiteral */] = null; + childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; + childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; + childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; + childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; + childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; + childrenWalkers[14 /* StringLiteral */] = null; + childrenWalkers[69 /* StringKeyword */] = null; + childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; + childrenWalkers[50 /* SuperKeyword */] = null; + childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; + childrenWalkers[35 /* ThisKeyword */] = null; + childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; + childrenWalkers[3 /* TriviaList */] = null; + childrenWalkers[37 /* TrueKeyword */] = null; + childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; + childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; + childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; + childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; + childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; + childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; + childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; + childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; + childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; + childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; + childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; + childrenWalkers[41 /* VoidKeyword */] = null; + childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; + childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; + + for (var e in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { + TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); + } + } + + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + this.stopWalking = false; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var SimplePreAstWalker = (function () { + function SimplePreAstWalker(pre, state) { + this.pre = pre; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePreAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + }; + return SimplePreAstWalker; + })(); + + var SimplePrePostAstWalker = (function () { + function SimplePrePostAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePrePostAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + + this.post(ast, this.state); + }; + return SimplePrePostAstWalker; + })(); + + var NormalAstWalker = (function () { + function NormalAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + NormalAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + if (this.options.stopWalking) { + return; + } + + this.pre(ast, this); + + if (this.options.stopWalking) { + return; + } + + if (this.options.goChildren) { + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + } else { + this.options.goChildren = true; + } + + if (this.post) { + this.post(ast, this); + } + }; + return NormalAstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { + new NormalAstWalker(pre, post, state).walk(ast); + }; + + AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { + if (post) { + new SimplePrePostAstWalker(pre, post, state).walk(ast); + } else { + new SimplePreAstWalker(pre, state).walk(ast); + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory = new AstWalkerFactory(); + + function getAstWalkerFactory() { + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapEntry = (function () { + function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { + this.emittedFile = emittedFile; + this.emittedLine = emittedLine; + this.emittedColumn = emittedColumn; + this.sourceFile = sourceFile; + this.sourceLine = sourceLine; + this.sourceColumn = sourceColumn; + this.sourceName = sourceName; + TypeScript.Debug.assert(isFinite(emittedLine)); + TypeScript.Debug.assert(isFinite(emittedColumn)); + TypeScript.Debug.assert(isFinite(sourceColumn)); + TypeScript.Debug.assert(isFinite(sourceLine)); + } + return SourceMapEntry; + })(); + TypeScript.SourceMapEntry = SourceMapEntry; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.names = []; + this.mappingLevel = []; + this.tsFilePaths = []; + this.allSourceMappings = []; + this.sourceMapEntries = []; + this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); + this.setNewSourceFile(document, emitOptions); + } + SourceMapper.prototype.getOutputFile = function () { + var result = this.sourceMapOut.getOutputFile(); + result.sourceMapEntries = this.sourceMapEntries; + + return result; + }; + + SourceMapper.prototype.increaseMappingLevel = function (ast) { + this.mappingLevel.push(ast); + }; + + SourceMapper.prototype.decreaseMappingLevel = function (ast) { + TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); + var expectedAst = this.mappingLevel.pop(); + var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; + var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; + TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); + }; + + SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { + var sourceMappings = []; + this.allSourceMappings.push(sourceMappings); + this.currentMappings = [sourceMappings]; + this.currentNameIndex = []; + + this.setNewSourceFilePath(document, emitOptions); + }; + + SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; + this.jsFileName = prettyJsFileName; + + if (emitOptions.sourceMapRootDirectory()) { + this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); + if (document.emitToOwnOutputFile()) { + this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); + } + + if (TypeScript.isRelative(this.sourceMapDirectory)) { + this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; + this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); + this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); + } else { + this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; + } + } else { + this.sourceMapPath = prettyMapFileName; + this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + this.sourceRoot = emitOptions.sourceRootDirectory(); + }; + + SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + if (emitOptions.sourceRootDirectory()) { + tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); + } else { + tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); + } + this.tsFilePaths.push(tsFilePath); + }; + + SourceMapper.prototype.emitSourceMapping = function () { + var _this = this; + TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { + return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); + }).join(', ')); + + this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); + + var mappingsString = ""; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); + prevSourceIndex = sourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); + prevNameIndex = nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + for (var i = 0; i < sourceMappings.length; i++) { + var sourceMapping = sourceMappings[i]; + recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); + recordSourceMappingSiblings(sourceMapping.childMappings); + recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); + } + }; + + recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); + } + + this.sourceMapOut.Write(JSON.stringify({ + version: 3, + file: this.jsFileName, + sourceRoot: this.sourceRoot, + sources: this.tsFilePaths, + names: this.names, + mappings: mappingsString + })); + + this.sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compiler, resolvePath) { + this.resolvePath = resolvePath; + this._diagnostic = null; + this._settings = null; + this._commonDirectoryPath = ""; + this._sharedOutputFile = ""; + this._sourceRootDirectory = ""; + this._sourceMapRootDirectory = ""; + this._outputDirectory = ""; + var settings = compiler.compilationSettings(); + this._settings = settings; + + 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()) { + if (settings.mapRoot()) { + if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } else { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } else if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } + + this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); + this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); + + if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { + if (settings.outFileOption()) { + this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); + } + + if (settings.outDirOption()) { + this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); + } + + if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { + this.determineCommonDirectoryPath(compiler); + } + } + } + EmitOptions.prototype.diagnostic = function () { + return this._diagnostic; + }; + + EmitOptions.prototype.commonDirectoryPath = function () { + return this._commonDirectoryPath; + }; + EmitOptions.prototype.sharedOutputFile = function () { + return this._sharedOutputFile; + }; + EmitOptions.prototype.sourceRootDirectory = function () { + return this._sourceRootDirectory; + }; + EmitOptions.prototype.sourceMapRootDirectory = function () { + return this._sourceMapRootDirectory; + }; + EmitOptions.prototype.outputDirectory = function () { + return this._outputDirectory; + }; + + EmitOptions.prototype.compilationSettings = function () { + return this._settings; + }; + + EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = compiler.fileNames(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = compiler.getDocument(fileNames[i]); + var sourceUnit = document.sourceUnit(); + + if (!document.isDeclareFile()) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + 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; + } + + return; + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + function lastParameterIsRest(parameterList) { + var parameters = parameterList.parameters; + return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; + } + TypeScript.lastParameterIsRest = lastParameterIsRest; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.inArrowFunction = false; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.declStack = []; + this.exportAssignment = null; + this.inWithBlock = false; + this.document = null; + this.detachedCommentsElement = null; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; + }; + + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.shouldEmitImportDeclaration = 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 */; + + 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 */; + + this.emitComments(importDeclAST, true); + + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + 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 */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + if (isAmdCodeGen && isExternalModuleReference) { + needsPropertyAssignment = true; + } else { + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.identifier.text() + " = "); + var aliasAST = importDeclAST.moduleReference; + + if (isExternalModuleReference) { + this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); + } else { + this.emitJavascript(aliasAST.moduleName, false); + } + + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + } + } + + if (needsPropertyAssignment) { + this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + }; + + Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { + this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); + }; + + Emitter.prototype.setSourceMapperNewSourceFile = function (document) { + this.sourceMapper.setNewSourceFile(document, this.emitOptions); + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { + this.recordSourceMappingStart(astSpan); + this.writeToOutput(s); + this.recordSourceMappingEnd(astSpan); + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeLineToOutput = function (s, force) { + if (typeof force === "undefined") { force = false; } + if (!force && s === "" && this.emitState.column === 0) { + return; + } + + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment, trailing, first) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var text = getTrimmedTextLines(comment); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } else if (trailing && first) { + this.writeToOutput(" "); + } + + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (!trailing && emitColumn !== 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { + 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; + } + } + + if (pre) { + var preComments = ast.preComments(); + + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; + } + + if (preComments && onlyPinnedOrTripleSlashComments) { + preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { + return _this.isPinnedOrTripleSlash(c); + }); + } + + this.emitCommentsArray(preComments, false); + } else { + this.emitCommentsArray(ast.postComments(), true); + } + }; + + Emitter.prototype.isPinnedOrTripleSlash = function (comment) { + var fullText = comment.fullText(); + if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { + return true; + } else { + return fullText.indexOf("/*!") === 0; + } + }; + + Emitter.prototype.emitCommentsArray = function (comments, trailing) { + if (!this.emitOptions.compilationSettings().removeComments() && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i], trailing, i === 0); + } + } + }; + + Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { + this.recordSourceMappingStart(objectLiteral); + + this.writeToOutput("{"); + this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); + this.writeToOutput("}"); + + this.recordSourceMappingEnd(objectLiteral); + }; + + Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { + this.recordSourceMappingStart(arrayLiteral); + + this.writeToOutput("["); + this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); + this.writeToOutput("]"); + + this.recordSourceMappingEnd(arrayLiteral); + }; + + Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { + this.recordSourceMappingStart(objectCreationExpression); + this.writeToOutput("new "); + var target = objectCreationExpression.expression; + + this.emit(target); + if (objectCreationExpression.argumentList) { + this.recordSourceMappingStart(objectCreationExpression.argumentList); + this.writeToOutput("("); + this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); + this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); + this.recordSourceMappingEnd(objectCreationExpression.argumentList); + } + + this.recordSourceMappingEnd(objectCreationExpression); + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); + if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + if (pullDecl.kind === 67108864 /* EnumMember */) { + return pullDecl; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + var propertyName = dotExpr.name; + var boundDecl = this.getConstantDecl(dotExpr); + if (boundDecl) { + var value = boundDecl.constantValue; + if (value !== null) { + this.recordSourceMappingStart(dotExpr); + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.text(); + comment += " */"; + this.writeToOutput(comment); + this.recordSourceMappingEnd(dotExpr); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitInvocationExpression = function (callNode) { + this.recordSourceMappingStart(callNode); + var target = callNode.expression; + var args = callNode.argumentList.arguments; + + if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { + this.emit(target); + this.writeToOutput(".call"); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitThis(); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + } else { + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + + this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); + this.recordSourceMappingEnd(args); + this.recordSourceMappingEnd(callNode); + }; + + Emitter.prototype.emitParameterList = function (list) { + this.writeToOutput("("); + this.emitCommentsArray(list.openParenTrailingComments, true); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); + this.writeToOutput(")"); + }; + + Emitter.prototype.emitFunctionParameters = function (parameters) { + var argsLen = 0; + + if (parameters) { + this.emitComments(parameters.ast, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = parameters.length; + var printLen = argsLen; + if (parameters.lastParameterIsRest()) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = parameters.astAt(i); + this.emit(arg); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(parameters.ast, false); + } + }; + + Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { + this.writeLineToOutput(" {"); + if (name) { + this.recordSourceMappingNameStart(name); + } + + this.indenter.increaseIndent(); + + 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); + } else { + this.emitIndent(); + this.emitCommentsArray(bodyExpression.preComments(), false); + this.writeToOutput("return "); + this.emit(bodyExpression); + this.writeLineToOutput(";"); + this.emitCommentsArray(bodyExpression.postComments(), true); + } + + this.indenter.decreaseIndent(); + this.emitIndent(); + + if (block) { + this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); + } else { + this.writeToOutputWithSourceMapRecord("}", bodyExpression); + } + + if (name) { + this.recordSourceMappingNameEnd(); + } + }; + + Emitter.prototype.emitDefaultValueAssignments = function (parameters) { + var n = parameters.length; + if (parameters.lastParameterIsRest()) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = parameters.astAt(i); + var id = parameters.identifierAt(i); + var equalsValueClause = parameters.initializerAt(i); + if (equalsValueClause) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.emitJavascript(equalsValueClause, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (parameters) { + if (parameters.lastParameterIsRest()) { + var n = parameters.length; + var lastArg = parameters.astAt(n - 1); + var id = parameters.identifierAt(n - 1); + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); + this.writeToOutput(" "); + this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); + this.writeToOutput("; "); + this.writeToOutputWithSourceMapRecord("_i++", lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + var result = []; + + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + var queue = dynamicModuleDecl.getChildDecls(); + + for (var i = 0, n = queue.length; i < n; i++) { + var decl = queue[i]; + + if (decl.kind & 128 /* TypeAlias */) { + var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { + var importList = ""; + var dependencyList = ""; + + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue()) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += importStatementDecl.name; + dependencyList += importStatementAST.moduleReference.stringLiteral.text(); + } + } + } + + var amdDependencies = this.document.amdDependencies(); + for (var i = 0; i < amdDependencies.length; i++) { + dependencyList += ", \"" + amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); + } + + var decl = this.semanticInfoChain.getDeclForAST(ast); + if (decl) { + return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); + } + + return false; + }; + + Emitter.prototype.emitEnum = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.identifier.text(); + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.identifier); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(this.moduleName); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitSeparatedList(moduleDecl.enumElements); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { + return moduleDecl; + } else if (changeNameIfAnyDeclarationInContext) { + var symbol = moduleDecl.getSymbol(); + if (symbol) { + var otherDecls = symbol.getDeclarations(); + for (var i = 0; i < otherDecls.length; i++) { + if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { + return otherDecls[i]; + } + } + } + } + + return null; + }; + + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { + var _this = this; + var childDecls = parentDecl.getChildDecls(); + return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { + 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; + } + } + return false; + }); + }; + + Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + var moduleName = moduleDecl.name; + var moduleDisplayName = moduleDecl.getDisplayName(); + + moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { + moduleName = "_" + moduleName; + moduleDisplayName = "_" + moduleDisplayName; + } + } + + return moduleDisplayName; + }; + + Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { + if (moduleDecl.stringLiteral) { + this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); + } + }; + + Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); + + if (isLastName) { + this.emitComments(moduleDecl, true); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + + if (moduleDecl.stringLiteral) { + this.moduleName = moduleDecl.stringLiteral.valueText(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + } else { + this.moduleName = moduleName.text(); + } + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleName); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleName); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + + this.moduleName = this.getModuleName(pullDecl); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(moduleName.text()); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + if (moduleName === moduleDecl.stringLiteral) { + this.emitList(moduleDecl.moduleElements); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + var nameIndex = moduleNames.indexOf(moduleName); + TypeScript.Debug.assert(nameIndex >= 0); + + if (isLastName) { + this.emitList(moduleDecl.moduleElements); + } else { + this.emitIndent(); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); + this.writeLineToOutput(""); + } + } + + this.moduleName = moduleName.text(); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + + if (isLastName) { + this.emitComments(moduleDecl, false); + } + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.propertyName.text(); + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput(']'); + + if (varDecl.equalsValueClause) { + this.emit(varDecl.equalsValueClause); + } else if (pullDecl.constantValue !== null) { + this.writeToOutput(' = '); + this.writeToOutput(pullDecl.constantValue.toString()); + } else { + this.writeToOutput(' = null'); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitElementAccessExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("["); + this.emit(expression.argumentExpression); + this.writeToOutput("]"); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = true; + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(arrowFunction); + + var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); + this.pushDecl(pullDecl); + + this.emitComments(arrowFunction, true); + + this.recordSourceMappingStart(arrowFunction); + this.writeToOutput("function "); + this.writeToOutput("("); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); + + this.recordSourceMappingEnd(arrowFunction); + + this.recordSourceMappingEnd(arrowFunction); + + this.emitComments(arrowFunction, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConstructor = function (funcDecl) { + if (!funcDecl.block) { + return; + } + var temp = this.setContainer(4 /* Constructor */); + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + this.writeToOutput(this.thisClassNode.identifier.text()); + this.writeToOutput("("); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart("constructor"); + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(parameters); + this.emitRestParameterInitializer(parameters); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + this.emitConstructorStatements(funcDecl); + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + }; + + Emitter.prototype.emitGetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("get "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitSetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("set "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitFunctionExpression = function (funcDecl) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + this.writeToOutput(funcDecl.identifier.text()); + this.recordSourceMappingEnd(funcDecl.identifier); + } + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (funcDecl.block === null) { + return; + } + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier.text(); + + this.recordSourceMappingStart(funcDecl); + + var printName = funcDecl.identifier !== null; + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (printName) { + var id = funcDecl.identifier.text(); + if (id) { + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + } + this.writeToOutput(id); + if (funcDecl.identifier) { + this.recordSourceMappingEnd(funcDecl.identifier); + } + } + } + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + + if (funcDecl.block) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + this.recordSourceMappingStart(this.currentVariableDeclaration); + if (varDecl.equalsValueClause) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + this.emitJavascript(varDecl.equalsValueClause, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.currentVariableDeclaration) { + this.writeToOutput("var "); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + + this.emitComments(declaration, true); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; + if (!isAmbientWithoutInit) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.currentVariableDeclaration = declaration; + + for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { + var declarator = declaration.declarators.nonSeparatorAt(i); + + if (i > 0) { + this.writeToOutput(", "); + } + + this.emit(declarator); + } + this.currentVariableDeclaration = prevVariableDeclaration; + + this.recordSourceMappingEnd(declaration); + } + + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { + TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); + + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + + if (quotedOrNumber) { + this.writeToOutput("this["); + } else { + this.writeToOutput("this."); + } + + this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); + + if (quotedOrNumber) { + this.writeToOutput("]"); + } + + if (varDecl.variableDeclarator.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.variableDeclarator.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(this.currentVariableDeclaration); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.propertyName.text(); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); + + if (parentIsModule) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + + if (varDecl.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.currentVariableDeclaration = undefined; + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { + var decl = pullSymbol.getDeclarations()[0]; + var parentDecl = decl.getParentDecl(); + var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; + + var enclosingContextDeclPath = this.declStack; + var commonNodeIndex = -1; + + if (enclosingContextDeclPath.length) { + for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { + var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; + for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { + var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; + if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { + commonNodeIndex = i; + break; + } + } + + if (commonNodeIndex >= 0) { + break; + } + } + } + + var startingIndex = symbolContainerDeclPath.length - 1; + for (var i = startingIndex - 1; i > commonNodeIndex; i--) { + if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { + startingIndex = i; + } else { + break; + } + } + return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; + }; + + Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { + for (var i = startingIndex; i <= lastIndex; i++) { + if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.getModuleName(declPath[i], true) + "."); + } + } + }; + + Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { + var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); + var potentialDeclPath = declPathInfo.potentialPath; + var startingIndex = declPathInfo.startingIndex; + + this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); + }; + + Emitter.prototype.getSymbolForEmit = function (ast) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol === symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (name.text().length > 0) { + var symbolForEmit = this.getSymbolForEmit(name); + var pullSymbol = symbolForEmit.symbol; + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = symbolForEmit.aliasSymbol; + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } + } + } + + this.writeToOutput(name.text()); + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var nameIndex = -1; + if (name) { + if (this.sourceMapper.currentNameIndex.length > 0) { + var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { + break; + } + } + + if (nameIndex === -1) { + nameIndex = this.sourceMapper.names.length; + this.sourceMapper.names.push(name); + } + } + this.sourceMapper.currentNameIndex.push(nameIndex); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (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; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap(); + lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); + + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + this.sourceMapper.increaseMappingLevel(ast); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); + + this.sourceMapper.decreaseMappingLevel(ast); + } + }; + + Emitter.prototype.getOutputFiles = function () { + var result = []; + if (this.sourceMapper !== null) { + this.sourceMapper.emitSourceMapping(); + result.push(this.sourceMapper.getOutputFile()); + } + + result.push(this.outfile.getOutputFile()); + return result; + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = getLastConstructor(this.thisClassNode); + + 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(); + this.recordSourceMappingStart(parameter); + this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); + this.writeToOutput(" = "); + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(parameter); + } + } + } + + for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { + if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = this.thisClassNode.classElements.childAt(i); + if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitIndent(); + this.emitMemberVariableDeclaration(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.isOnSameLine = function (pos1, pos2) { + var lineMap = this.document.lineMap(); + return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); + }; + + Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { + if (list === null || list.nonSeparatorCount() === 0) { + return; + } + + var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); + + if (preserveNewLines) { + this.indenter.increaseIndent(); + } + + if (startLine) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(buffer); + } + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + var emitNode = list.nonSeparatorAt(i); + + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); + if (startLine) { + this.writeLineToOutput(","); + } else { + this.writeToOutput(", "); + } + } + } + + if (preserveNewLines) { + this.indenter.decreaseIndent(); + } + + if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(buffer); + } + }; + + Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.nonSeparatorAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.kind() === 14 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { + return; + } + + var lineMap = this.document.lineMap(); + var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput("", true); + } + }; + + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); + if (preComments) { + var lineMap = this.document.lineMap(); + + var detachedComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); + var commentLine = lineMap.getLineNumberFromPosition(comment.start()); + + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + detachedComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); + if (astLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { + if (list.childCount() > 0) { + var firstElement = list.childAt(0); + + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); + } + }; + + Emitter.prototype.emitScriptElements = function (sourceUnit) { + var list = sourceUnit.moduleElements; + + this.emitPossibleCopyrightHeaders(sourceUnit); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var node = list.childAt(i); + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(sourceUnit); + + var isExternalModule = this.document.isExternalModule(); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); + if (isNonElidedExternalModule) { + this.recordSourceMappingStart(sourceUnit); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } + + if (isExternalModule) { + var temp = this.setContainer(2 /* DynamicModule */); + + var svModuleName = this.moduleName; + this.moduleName = sourceUnit.fileName(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + this.setExportAssignment(null); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); + + if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { + this.writeCaptureThisStatement(sourceUnit); + } + + this.pushDecl(externalModule); + } + + this.emitList(list, true, i, n); + + if (isExternalModule) { + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + + if (isNonElidedExternalModule) { + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; + var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(sourceUnit); + this.writeLineToOutput(""); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + this.popDecl(externalModule); + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + this.emit(ast); + }; + + Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { + if (funcDecl.kind() !== 139 /* GetAccessor */) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + + this.writeToOutput("Object.defineProperty(" + className); + if (isProto) { + this.writeToOutput(".prototype, "); + } else { + this.writeToOutput(", "); + } + + var functionName = name.text(); + if (TypeScript.isQuoted(functionName)) { + this.writeToOutput(functionName); + } else { + this.writeToOutput('"' + functionName + '"'); + } + + this.writeLineToOutput(", {"); + + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.emitComments(accessors.getter, true); + this.writeToOutput("get: "); + this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.emitComments(accessors.setter, true); + this.writeToOutput("set: "); + this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.identifier.text(); + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var baseTypeReference = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); + } + + this.emitIndent(); + + var constrDecl = getLastConstructor(classDecl); + + if (constrDecl) { + this.emit(constrDecl); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.emitJavascript(baseTypeReference, false); + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 139 /* GetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var getter = memberDecl; + this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 140 /* SetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var setter = memberDecl; + this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { + var memberFunction = memberDecl; + + if (memberFunction.block) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + + this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); + lastEmittedMember = memberDecl; + } + } + } + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = memberDecl; + + if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); + } else { + this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); + } + + this.emit(varDecl.variableDeclarator.equalsValueClause); + + this.recordSourceMappingEnd(varDecl); + this.writeLineToOutput(";"); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + var functionName = funcDecl.propertyName.text(); + + this.writeToOutput(classDecl.identifier.text()); + + if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + this.writeToOutput(".prototype"); + } + + if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput("[" + functionName + "] = "); + } else { + this.writeToOutput("." + functionName + " = "); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + + this.writeLineToOutput(";"); + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + + if (moduleElement.kind() === 130 /* ModuleDeclaration */) { + var moduleAST = moduleElement; + + if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { + return true; + } + } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (sourceUnit) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(sourceUnit)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitThis = function () { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.kind() === 146 /* Block */) { + this.emit(node); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitLiteralExpression = function (expression) { + switch (expression.kind()) { + case 32 /* NullKeyword */: + this.writeToOutputWithSourceMapRecord("null", expression); + break; + case 24 /* FalseKeyword */: + this.writeToOutputWithSourceMapRecord("false", expression); + break; + case 37 /* TrueKeyword */: + this.writeToOutputWithSourceMapRecord("true", expression); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + Emitter.prototype.emitThisExpression = function (expression) { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutputWithSourceMapRecord("_this", expression); + } else { + this.writeToOutputWithSourceMapRecord("this", expression); + } + }; + + Emitter.prototype.emitSuperExpression = function (expression) { + this.writeToOutputWithSourceMapRecord("_super.prototype", expression); + }; + + Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { + if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { + this.emit(parenthesizedExpression.expression); + } else { + this.recordSourceMappingStart(parenthesizedExpression); + this.writeToOutput("("); + this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); + this.emit(parenthesizedExpression.expression); + this.writeToOutput(")"); + this.recordSourceMappingEnd(parenthesizedExpression); + } + }; + + Emitter.prototype.emitCastExpression = function (expression) { + this.emit(expression.expression); + }; + + Emitter.prototype.emitPrefixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 167 /* LogicalNotExpression */: + this.writeToOutput("!"); + this.emit(expression.operand); + break; + case 166 /* BitwiseNotExpression */: + this.writeToOutput("~"); + this.emit(expression.operand); + break; + case 165 /* NegateExpression */: + this.writeToOutput("-"); + if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 164 /* PlusExpression */: + this.writeToOutput("+"); + if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 168 /* PreIncrementExpression */: + this.writeToOutput("++"); + this.emit(expression.operand); + break; + case 169 /* PreDecrementExpression */: + this.writeToOutput("--"); + this.emit(expression.operand); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitPostfixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 210 /* PostIncrementExpression */: + this.emit(expression.operand); + this.writeToOutput("++"); + break; + case 211 /* PostDecrementExpression */: + this.emit(expression.operand); + this.writeToOutput("--"); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitTypeOfExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("typeof "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDeleteExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("delete "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitVoidExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("void "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { + var memberExpressionNodeType = expression.expression.kind(); + + 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 */) { + return this.canEmitDottedNameMemberAccessExpression(expression.expression); + } + + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { + this.recordSourceMappingStart(expression); + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { + this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); + } else { + this.emitComments(expression.expression, true); + this.recordSourceMappingStart(expression.expression); + + this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); + + this.writeToOutput(expression.expression.text()); + + this.recordSourceMappingEnd(expression.expression); + this.emitComments(expression.expression, false); + } + + this.writeToOutput("."); + this.emitName(expression.name, false); + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { + this.emitComments(expression, true); + + if (lastIndex - startingIndex < 1) { + startingIndex = lastIndex - 1; + TypeScript.Debug.assert(startingIndex >= 0); + } + + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); + this.emitComments(expression, false); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { + var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; + + var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); + }; + + Emitter.prototype.emitMemberAccessExpression = function (expression) { + if (!this.tryEmitConstant(expression)) { + if (this.canEmitDottedNameMemberAccessExpression(expression)) { + this.emitDottedNameMemberAccessExpression(expression); + } else { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("."); + this.emitName(expression.name, false); + this.recordSourceMappingEnd(expression); + } + } + }; + + Emitter.prototype.emitQualifiedName = function (name) { + this.recordSourceMappingStart(name); + + this.emit(name.left); + this.writeToOutput("."); + this.emitName(name.right, false); + + this.recordSourceMappingEnd(name); + }; + + Emitter.prototype.emitBinaryExpression = function (expression) { + this.recordSourceMappingStart(expression); + switch (expression.kind()) { + case 173 /* CommaExpression */: + this.emit(expression.left); + this.writeToOutput(", "); + this.emit(expression.right); + break; + default: { + this.emit(expression.left); + var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); + if (binOp === "instanceof") { + this.writeToOutput(" instanceof "); + } else if (binOp === "in") { + this.writeToOutput(" in "); + } else { + this.writeToOutput(" " + binOp + " "); + } + this.emit(expression.right); + } + } + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimplePropertyAssignment = function (property) { + this.recordSourceMappingStart(property); + this.emit(property.propertyName); + this.writeToOutput(": "); + this.emit(property.expression); + this.recordSourceMappingEnd(property); + }; + + Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { + this.recordSourceMappingStart(funcProp); + + this.emit(funcProp.propertyName); + this.writeToOutput(": "); + + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); + + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + var funcName = funcProp.propertyName; + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcProp); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); + + this.recordSourceMappingEnd(funcProp); + + this.recordSourceMappingEnd(funcProp); + + this.emitComments(funcProp, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConditionalExpression = function (expression) { + this.emit(expression.condition); + this.writeToOutput(" ? "); + this.emit(expression.whenTrue); + this.writeToOutput(" : "); + this.emit(expression.whenFalse); + }; + + Emitter.prototype.emitThrowStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("throw "); + this.emit(statement.expression); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitExpressionStatement = function (statement) { + var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; + + this.recordSourceMappingStart(statement); + if (isArrowExpression) { + this.writeToOutput("("); + } + + this.emit(statement.expression); + + if (isArrowExpression) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitLabeledStatement = function (statement) { + this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); + this.writeLineToOutput(":"); + this.emitJavascript(statement.statement, true); + }; + + Emitter.prototype.emitBlock = function (block) { + this.recordSourceMappingStart(block); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + if (block.statements) { + this.emitList(block.statements); + } + this.emitCommentsArray(block.closeBraceLeadingComments, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(block); + }; + + Emitter.prototype.emitBreakStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("break"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitContinueStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("continue"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitWhileStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("while ("); + this.emit(statement.condition); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitDoStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("do"); + this.emitBlockOrStatement(statement.statement); + this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); + this.writeToOutput('('); + this.emit(statement.condition); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitIfStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("if ("); + this.emit(statement.condition); + this.writeToOutput(")"); + + this.emitBlockOrStatement(statement.statement); + + if (statement.elseClause) { + if (statement.statement.kind() !== 146 /* Block */) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + + this.emit(statement.elseClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitElseClause = function (elseClause) { + if (elseClause.statement.kind() === 147 /* IfStatement */) { + this.writeToOutput("else "); + this.emit(elseClause.statement); + } else { + this.writeToOutput("else"); + this.emitBlockOrStatement(elseClause.statement); + } + }; + + Emitter.prototype.emitReturnStatement = function (statement) { + this.recordSourceMappingStart(statement); + if (statement.expression) { + this.writeToOutput("return "); + this.emit(statement.expression); + } else { + this.writeToOutput("return"); + } + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitForInStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.left) { + this.emit(statement.left); + } else { + this.emit(statement.variableDeclaration); + } + this.writeToOutput(" in "); + this.emit(statement.expression); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitForStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.variableDeclaration) { + this.emit(statement.variableDeclaration); + } else if (statement.initializer) { + this.emit(statement.initializer); + } + + this.writeToOutput("; "); + this.emitJavascript(statement.condition, false); + this.writeToOutput(";"); + if (statement.incrementor) { + this.writeToOutput(" "); + this.emitJavascript(statement.incrementor, false); + } + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitWithStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("with ("); + if (statement.condition) { + this.emit(statement.condition); + } + + this.writeToOutput(")"); + var prevInWithBlock = this.inWithBlock; + this.inWithBlock = true; + this.emitBlockOrStatement(statement.statement); + this.inWithBlock = prevInWithBlock; + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitSwitchStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("switch ("); + this.emit(statement.expression); + this.recordSourceMappingStart(statement.closeParenToken); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement.closeParenToken); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + this.emitList(statement.switchClauses, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCaseSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("case "); + this.emit(clause.expression); + this.writeToOutput(":"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitSwitchClauseBody = function (body) { + if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { + this.emit(body.childAt(0)); + this.writeLineToOutput(""); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emit(body); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitDefaultSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("default:"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitTryStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("try "); + this.emit(statement.block); + this.emitJavascript(statement.catchClause, false); + + if (statement.finallyClause) { + this.emit(statement.finallyClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCatchClause = function (clause) { + this.writeToOutput(" "); + this.recordSourceMappingStart(clause); + this.writeToOutput("catch ("); + this.emit(clause.identifier); + this.writeToOutput(")"); + this.emit(clause.block); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitFinallyClause = function (clause) { + this.writeToOutput(" finally"); + this.emit(clause.block); + }; + + Emitter.prototype.emitDebuggerStatement = function (statement) { + this.writeToOutputWithSourceMapRecord("debugger", statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitNumericLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitRegularExpressionLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitStringLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitEqualsValueClause = function (clause) { + this.writeToOutput(" = "); + this.emit(clause.value); + }; + + Emitter.prototype.emitParameter = function (parameter) { + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); + }; + + Emitter.prototype.emitConstructorDeclaration = function (declaration) { + if (declaration.block) { + this.emitConstructor(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { + return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); + }; + + Emitter.prototype.emitFunctionDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { + this.emitFunction(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.emitSourceUnit = function (sourceUnit) { + if (!this.document.isDeclareFile()) { + var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + this.pushDecl(pullDecl); + this.emitScriptElements(sourceUnit); + this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); + } + }; + + Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); + }; + + Emitter.prototype.emitEnumDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { + this.emitComments(declaration, true); + this.emitEnum(declaration); + this.emitComments(declaration, false); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); + }; + + Emitter.prototype.emitModuleDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { + this.emitModuleDeclarationWorker(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); + }; + + Emitter.prototype.emitClassDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + this.emitClass(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { + return declaration.preComments() !== null; + }; + + Emitter.prototype.emitInterfaceDeclaration = function (declaration) { + this.emitComments(declaration, true, true); + }; + + Emitter.prototype.firstVariableDeclarator = function (statement) { + return statement.declaration.declarators.nonSeparatorAt(0); + }; + + Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { + return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; + }; + + Emitter.prototype.shouldEmitVariableStatement = function (statement) { + return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); + }; + + Emitter.prototype.emitVariableStatement = function (statement) { + if (this.isNotAmbientOrHasInitializer(statement)) { + this.emitComments(statement, true); + this.emit(statement.declaration); + this.writeToOutput(";"); + this.emitComments(statement, false); + } else { + this.emitComments(statement, true, true); + } + }; + + Emitter.prototype.emitGenericType = function (type) { + this.emit(type.name); + }; + + Emitter.prototype.shouldEmit = function (ast) { + if (!ast) { + return false; + } + + switch (ast.kind()) { + case 133 /* ImportDeclaration */: + return this.shouldEmitImportDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.shouldEmitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.shouldEmitInterfaceDeclaration(ast); + case 129 /* FunctionDeclaration */: + return this.shouldEmitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.shouldEmitModuleDeclaration(ast); + case 148 /* VariableStatement */: + return this.shouldEmitVariableStatement(ast); + case 223 /* OmittedExpression */: + return false; + case 132 /* EnumDeclaration */: + return this.shouldEmitEnumDeclaration(ast); + } + + return true; + }; + + Emitter.prototype.emit = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 2 /* SeparatedList */: + return this.emitSeparatedList(ast); + case 1 /* List */: + return this.emitList(ast); + case 120 /* SourceUnit */: + return this.emitSourceUnit(ast); + case 133 /* ImportDeclaration */: + return this.emitImportDeclaration(ast); + case 134 /* ExportAssignment */: + return this.setExportAssignment(ast); + case 131 /* ClassDeclaration */: + return this.emitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitInterfaceDeclaration(ast); + case 11 /* IdentifierName */: + return this.emitName(ast, true); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast); + case 219 /* SimpleArrowFunctionExpression */: + return this.emitSimpleArrowFunctionExpression(ast); + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.emitParenthesizedArrowFunctionExpression(ast); + case 129 /* FunctionDeclaration */: + return this.emitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitModuleDeclaration(ast); + case 224 /* VariableDeclaration */: + return this.emitVariableDeclaration(ast); + case 126 /* GenericType */: + return this.emitGenericType(ast); + case 137 /* ConstructorDeclaration */: + return this.emitConstructorDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitEnumDeclaration(ast); + case 243 /* EnumElement */: + return this.emitEnumElement(ast); + case 222 /* FunctionExpression */: + return this.emitFunctionExpression(ast); + case 148 /* VariableStatement */: + return this.emitVariableStatement(ast); + } + + this.emitComments(ast, true); + this.emitWorker(ast); + this.emitComments(ast, false); + }; + + Emitter.prototype.emitWorker = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 13 /* NumericLiteral */: + return this.emitNumericLiteral(ast); + case 12 /* RegularExpressionLiteral */: + return this.emitRegularExpressionLiteral(ast); + case 14 /* StringLiteral */: + return this.emitStringLiteral(ast); + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 37 /* TrueKeyword */: + return this.emitLiteralExpression(ast); + case 35 /* ThisKeyword */: + return this.emitThisExpression(ast); + case 50 /* SuperKeyword */: + return this.emitSuperExpression(ast); + case 217 /* ParenthesizedExpression */: + return this.emitParenthesizedExpression(ast); + case 214 /* ArrayLiteralExpression */: + return this.emitArrayLiteralExpression(ast); + case 211 /* PostDecrementExpression */: + case 210 /* PostIncrementExpression */: + return this.emitPostfixUnaryExpression(ast); + case 167 /* LogicalNotExpression */: + case 166 /* BitwiseNotExpression */: + case 165 /* NegateExpression */: + case 164 /* PlusExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.emitPrefixUnaryExpression(ast); + case 213 /* InvocationExpression */: + return this.emitInvocationExpression(ast); + case 221 /* ElementAccessExpression */: + return this.emitElementAccessExpression(ast); + case 212 /* MemberAccessExpression */: + return this.emitMemberAccessExpression(ast); + case 121 /* QualifiedName */: + return this.emitQualifiedName(ast); + case 173 /* CommaExpression */: + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 187 /* LogicalOrExpression */: + case 188 /* LogicalAndExpression */: + case 189 /* BitwiseOrExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 191 /* BitwiseAndExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return this.emitBinaryExpression(ast); + case 186 /* ConditionalExpression */: + return this.emitConditionalExpression(ast); + case 232 /* EqualsValueClause */: + return this.emitEqualsValueClause(ast); + case 242 /* Parameter */: + return this.emitParameter(ast); + case 146 /* Block */: + return this.emitBlock(ast); + case 235 /* ElseClause */: + return this.emitElseClause(ast); + case 147 /* IfStatement */: + return this.emitIfStatement(ast); + case 149 /* ExpressionStatement */: + return this.emitExpressionStatement(ast); + case 139 /* GetAccessor */: + return this.emitGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitSetAccessor(ast); + case 157 /* ThrowStatement */: + return this.emitThrowStatement(ast); + case 150 /* ReturnStatement */: + return this.emitReturnStatement(ast); + case 216 /* ObjectCreationExpression */: + return this.emitObjectCreationExpression(ast); + case 151 /* SwitchStatement */: + return this.emitSwitchStatement(ast); + case 233 /* CaseSwitchClause */: + return this.emitCaseSwitchClause(ast); + case 234 /* DefaultSwitchClause */: + return this.emitDefaultSwitchClause(ast); + case 152 /* BreakStatement */: + return this.emitBreakStatement(ast); + case 153 /* ContinueStatement */: + return this.emitContinueStatement(ast); + case 154 /* ForStatement */: + return this.emitForStatement(ast); + case 155 /* ForInStatement */: + return this.emitForInStatement(ast); + case 158 /* WhileStatement */: + return this.emitWhileStatement(ast); + case 163 /* WithStatement */: + return this.emitWithStatement(ast); + case 220 /* CastExpression */: + return this.emitCastExpression(ast); + case 215 /* ObjectLiteralExpression */: + return this.emitObjectLiteralExpression(ast); + case 240 /* SimplePropertyAssignment */: + return this.emitSimplePropertyAssignment(ast); + case 241 /* FunctionPropertyAssignment */: + return this.emitFunctionPropertyAssignment(ast); + case 156 /* EmptyStatement */: + return this.writeToOutputWithSourceMapRecord(";", ast); + case 159 /* TryStatement */: + return this.emitTryStatement(ast); + case 236 /* CatchClause */: + return this.emitCatchClause(ast); + case 237 /* FinallyClause */: + return this.emitFinallyClause(ast); + case 160 /* LabeledStatement */: + return this.emitLabeledStatement(ast); + case 161 /* DoStatement */: + return this.emitDoStatement(ast); + case 171 /* TypeOfExpression */: + return this.emitTypeOfExpression(ast); + case 170 /* DeleteExpression */: + return this.emitDeleteExpression(ast); + case 172 /* VoidExpression */: + return this.emitVoidExpression(ast); + case 162 /* DebuggerStatement */: + return this.emitDebuggerStatement(ast); + } + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; + + function getLastConstructor(classDecl) { + return classDecl.classElements.lastOrDefault(function (e) { + return e.kind() === 137 /* ConstructorDeclaration */; + }); + } + TypeScript.getLastConstructor = getLastConstructor; + + function getTrimmedTextLines(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + return comment.fullText().split("\n").map(function (s) { + return s.trim(); + }); + } else { + return [comment.fullText().trim()]; + } + } + TypeScript.getTrimmedTextLines = getTrimmedTextLines; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += memberName.text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function stripStartAndEndQuotes(str) { + var firstCharCode = str && str.charCodeAt(0); + if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + return str.substring(1, str.length - 1); + } + + return str; + } + TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; + + function isSingleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isDoubleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; + } + TypeScript.isDoubleQuoted = isDoubleQuoted; + + function isQuoted(str) { + return isDoubleQuoted(str) || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function changePathToDTS(modPath) { + return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + function convertToDirectoryPath(dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + } + TypeScript.convertToDirectoryPath = convertToDirectoryPath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + function isNoDefaultLibMatch(comment) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + return isNoDefaultLibRegex.exec(comment); + } + + TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; + + function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { + var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } + } + } + + return null; + } + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + var start = new Date().getTime(); + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionScanImportsTime += totalTime; + } + + function processTripleSlashDirectives(fileName, lineMap, firstToken) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + var diagnostics = []; + var referencedFiles = []; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + var isNoDefaultLib = isNoDefaultLibMatch(triviaText); + if (isNoDefaultLib) { + noDefaultLib = isNoDefaultLib[3] === "true"; + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; + } + + function preProcessFile(fileName, sourceText, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); + + scannerDiagnostics.length = 0; + return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); + } + TypeScript.getParseOptions = getParseOptions; + + function getReferencedFiles(fileName, sourceText) { + return preProcessFile(fileName, sourceText, false).referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, lineMap, position, length, isImported) { + this.filePath = filePath; + this.lineMap = lineMap; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { + this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this.inputFileNames = inputFileNames; + this.host = host; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { + var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var _this = this; + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); + this.inputFileNames.forEach(function (fileName) { + return _this.resolveIncludedFile(fileName, referenceLocation, result); + }); + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(tsFile)) { + normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + var start = new Date().getTime(); + + do { + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var _this = this; + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var start = new Date().getTime(); + var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionIOTime += totalTime; + + var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); + resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); + var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + }); + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(name, writeByteOrderMark, outputFileType) { + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.outputFileType = outputFileType; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + }; + + TextWriter.prototype.getOutputFile = function () { + return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.emittedReferencePaths = false; + this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); + } + DeclarationEmitter.prototype.getOutputFile = function () { + return this.declFile.getOutputFile(); + }; + + DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { + this.emitDeclarationsForSourceUnit(sourceUnit); + }; + + DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.emitDeclarationsForAST(list.childAt(i)); + } + }; + + DeclarationEmitter.prototype.emitSeparatedList = function (list) { + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.emitDeclarationsForAST(list.nonSeparatorAt(i)); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { + switch (ast.kind()) { + case 148 /* VariableStatement */: + return this.emitDeclarationsForVariableStatement(ast); + case 141 /* PropertySignature */: + return this.emitPropertySignature(ast); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast, true, true); + case 136 /* MemberVariableDeclaration */: + return this.emitDeclarationsForMemberVariableDeclaration(ast); + case 137 /* ConstructorDeclaration */: + return this.emitDeclarationsForConstructorDeclaration(ast); + case 139 /* GetAccessor */: + return this.emitDeclarationsForGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitDeclarationsForSetAccessor(ast); + case 138 /* IndexMemberDeclaration */: + return this.emitIndexMemberDeclaration(ast); + case 144 /* IndexSignature */: + return this.emitIndexSignature(ast); + case 142 /* CallSignature */: + return this.emitCallSignature(ast); + case 143 /* ConstructSignature */: + return this.emitConstructSignature(ast); + case 145 /* MethodSignature */: + return this.emitMethodSignature(ast); + case 129 /* FunctionDeclaration */: + return this.emitDeclarationsForFunctionDeclaration(ast); + case 135 /* MemberFunctionDeclaration */: + return this.emitMemberFunctionDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.emitDeclarationsForClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitDeclarationsForInterfaceDeclaration(ast); + case 133 /* ImportDeclaration */: + return this.emitDeclarationsForImportDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitDeclarationsForModuleDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitDeclarationsForEnumDeclaration(ast); + case 134 /* ExportAssignment */: + return this.emitDeclarationsForExportAssignment(ast); + } + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { + var container = this.getEnclosingContainer(declAST); + if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { + var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); + var container = this.getEnclosingContainer(declAST); + + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { + container = this.getEnclosingContainer(container); + } + + var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); + + if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { + result += "declare "; + } + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { + this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { + var declarationContainerAst = this.getEnclosingContainer(ast); + + var start = new Date().getTime(); + var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); + + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = TypeScript.getTrimmedTextLines(comment); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.semanticInfoChain.getDeclForAST(boundDecl); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = pullSymbol.type; + TypeScript.Debug.assert(type); + + this.declFile.Write(": "); + this.emitTypeSignature(boundDecl, type); + }; + + DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { + this.emitDeclarationComments(varDecl); + this.emitIndent(); + this.declFile.Write(varDecl.propertyName.text()); + if (varDecl.questionToken) { + this.declFile.Write("?"); + } + + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + if (isFirstVarInList) { + this.emitDeclFlags(varDecl, "var"); + } + + this.declFile.Write(varDecl.propertyName.text()); + + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + if (isLastVarInList) { + this.declFile.WriteLine(";"); + } else { + this.declFile.Write(", "); + } + } + }; + + DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { + if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } + this.declFile.Write("static "); + } else { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } else { + this.declFile.Write("public "); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(varDecl.modifiers); + ; + + this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); + + if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + this.declFile.WriteLine(";"); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { + this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); + }; + + 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); + } + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(id.text()); + if (isOptional) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (!isPrivate) { + this.emitTypeOfVariableDeclaratorOrParameter(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("constructor"); + + this.declFile.Write("("); + 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.ASTHelpers.parametersFromParameterList(parameterList)); + this.declFile.Write(")"); + }; + + DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { + var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); + var argsLen = parameterList.length; + if (hasLastParameterRestParameter) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + + if (hasLastParameterRestParameter) { + if (parameterList.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + var index = parameterList.length - 1; + this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); + } + }; + + DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitDeclFlags(funcDecl, "function"); + var id = funcDecl.propertyName.text(); + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); + + this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); + + if (!isPrivate) { + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + this.emitDeclarationComments(funcDecl); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); + + this.emitIndent(); + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("new"); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write(funcDecl.propertyName.text()); + if (funcDecl.questionToken) { + this.declFile.Write("? "); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + if (funcDecl.block) { + var funcTypeSymbol = funcSymbol.type; + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + var id = funcDecl.identifier.text(); + this.emitDeclFlags(funcDecl, "function"); + if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { + this.declFile.Write(id); + } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { + this.declFile.Write("new"); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { + this.emitDeclarationsForAST(funcDecl.indexSignature); + }; + + DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("["); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); + this.declFile.Write("]"); + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { + if (bases && (bases.nonSeparatorCount() > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.nonSeparatorCount(); + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + var base = bases.nonSeparatorAt(i); + var baseType = this.semanticInfoChain.getSymbolForAST(base); + this.emitTypeSignature(base, baseType); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); + } + if (accessors.setter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { + return; + } + + var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); + this.emitAccessorDeclarationComments(funcDecl); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(modifiers); + this.declFile.Write(name.text()); + if (!isPrivate) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(funcDecl, type); + } + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } + + 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(";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { + if (!this.canEmitDeclarations(classDecl)) { + return; + } + + var className = classDecl.identifier.text(); + this.emitDeclarationComments(classDecl); + var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.emitDeclFlags(classDecl, "class"); + this.declFile.Write(className); + + this.emitTypeParameters(classDecl.typeParameterList); + this.emitHeritageClauses(classDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + var constructorDecl = TypeScript.getLastConstructor(classDecl); + if (constructorDecl) { + this.emitClassMembersFromConstructorDefinition(constructorDecl); + } + + this.emitDeclarationsForList(classDecl.classElements); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { + if (clauses) { + for (var i = 0, n = clauses.childCount(); i < n; i++) { + this.emitHeritageClause(clauses.childAt(i)); + } + } + }; + + DeclarationEmitter.prototype.emitHeritageClause = function (clause) { + this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); + }; + + DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getEnclosingContainer(typeParams); + + var start = new Date().getTime(); + var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArgumentsOrTypeParameters(); + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { + if (!this.canEmitDeclarations(interfaceDecl)) { + return; + } + + var interfaceName = interfaceDecl.identifier.text(); + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); + this.emitDeclFlags(interfaceDecl, "interface"); + this.declFile.Write(interfaceName); + + this.emitTypeParameters(interfaceDecl.typeParameterList); + this.emitHeritageClauses(interfaceDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + + this.emitSeparatedList(interfaceDecl.body.typeMembers); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.identifier.text() + " = "); + if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); + } else { + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclFlags(moduleDecl, "enum"); + this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.enumElements.nonSeparatorCount(); + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); + var enumElement = memberDecl; + var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); + this.emitDeclarationComments(enumElement); + this.emitIndent(); + this.declFile.Write(enumElement.propertyName.text()); + if (enumElementDecl.constantValue !== null) { + this.declFile.Write(" = " + enumElementDecl.constantValue); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclarationComments(moduleDecl); + + var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); + this.emitDeclFlags(name, "module"); + + if (moduleDecl.stringLiteral) { + this.declFile.Write(moduleDecl.stringLiteral.text()); + } else { + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); + } + + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + + this.emitDeclarationsForList(moduleDecl.moduleElements); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.identifier.text()); + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { + if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { + return reference; + } + + var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); + var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); + return resolvedReferencePath; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.document.emitToOwnOutputFile()) { + var scriptReferences = this.document.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { + documents = documents.concat(document); + + if (!document.isDeclareFile() && document.isExternalModule()) { + addedGlobalDocument = true; + } + } + } + } else { + var fileNames = this.compiler.fileNames(); + for (var i = 0; i < fileNames.length; i++) { + var doc = this.compiler.getDocument(fileNames[i]); + if (!doc.isDeclareFile() && !doc.isExternalModule()) { + var scriptReferences = doc.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.isDeclareFile() || document.isExternalModule())) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] === document) { + break; + } + } + + if (k === documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.isDeclareFile()) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { + this.emitReferencePaths(sourceUnit); + this.emitDeclarationsForList(sourceUnit.moduleElements); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] !== array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + 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, createFileLog) { + this._propagateEnumConstants = propagateEnumConstants; + this._removeComments = removeComments; + this._watch = watch; + this._noResolve = noResolve; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + this._noImplicitAny = noImplicitAny; + this._noLib = noLib; + this._codeGenTarget = codeGenTarget; + this._moduleGenTarget = moduleGenTarget; + this._outFileOption = outFileOption; + this._outDirOption = outDirOption; + this._mapSourceFiles = mapSourceFiles; + this._mapRoot = mapRoot; + this._sourceRoot = sourceRoot; + this._generateDeclarationFiles = generateDeclarationFiles; + this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this._gatherDiagnostics = gatherDiagnostics; + this._codepage = codepage; + this._createFileLog = createFileLog; + } + ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { + return this._propagateEnumConstants; + }; + ImmutableCompilationSettings.prototype.removeComments = function () { + return this._removeComments; + }; + ImmutableCompilationSettings.prototype.watch = function () { + return this._watch; + }; + ImmutableCompilationSettings.prototype.noResolve = function () { + return this._noResolve; + }; + ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + ImmutableCompilationSettings.prototype.noImplicitAny = function () { + return this._noImplicitAny; + }; + ImmutableCompilationSettings.prototype.noLib = function () { + return this._noLib; + }; + ImmutableCompilationSettings.prototype.codeGenTarget = function () { + return this._codeGenTarget; + }; + ImmutableCompilationSettings.prototype.moduleGenTarget = function () { + return this._moduleGenTarget; + }; + ImmutableCompilationSettings.prototype.outFileOption = function () { + return this._outFileOption; + }; + ImmutableCompilationSettings.prototype.outDirOption = function () { + return this._outDirOption; + }; + ImmutableCompilationSettings.prototype.mapSourceFiles = function () { + return this._mapSourceFiles; + }; + ImmutableCompilationSettings.prototype.mapRoot = function () { + return this._mapRoot; + }; + ImmutableCompilationSettings.prototype.sourceRoot = function () { + return this._sourceRoot; + }; + ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { + return this._generateDeclarationFiles; + }; + ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { + return this._useCaseSensitiveFileResolution; + }; + ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { + return this._gatherDiagnostics; + }; + ImmutableCompilationSettings.prototype.codepage = function () { + return this._codepage; + }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; + + ImmutableCompilationSettings.defaultSettings = function () { + if (!ImmutableCompilationSettings._defaultSettings) { + ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); + } + + return ImmutableCompilationSettings._defaultSettings; + }; + + 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, 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, "_")) { + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; + } + } + + return result; + }; + return ImmutableCompilationSettings; + })(); + TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; + + PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + function hasModifier(modifiers, flag) { + for (var i = 0, n = modifiers.length; i < n; i++) { + if (TypeScript.hasFlag(modifiers[i], flag)) { + return true; + } + } + + return false; + } + TypeScript.hasModifier = hasModifier; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; + PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; + + 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.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"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var pullDeclID = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + 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; + this.childDeclTypeParameterCache = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.semanticInfoChain = semanticInfoChain; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + } + PullDecl.prototype.fileName = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentPath = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.isExternalModule = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getEnclosingDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { + var decl = this; + while (decl) { + switch (decl.kind) { + default: + return decl; + case 512 /* Variable */: + case 8192 /* TypeParameter */: + case 2048 /* Parameter */: + case 128 /* TypeAlias */: + case 67108864 /* EnumMember */: + } + + decl = decl.getParentDecl(); + } + + TypeScript.Debug.fail(); + }; + + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.semanticInfoChain.setSymbolForDecl(this, symbol); + }; + + 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 */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.semanticInfoChain.getSymbolForDecl(this); + }; + + PullDecl.prototype.hasSymbol = function () { + var symbol = this.semanticInfoChain.getSymbolForDecl(this); + return !!symbol; + }; + + PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); + }; + + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); + }; + + PullDecl.prototype.hasSignatureSymbol = function () { + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); + return !!signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; + }; + + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + if (declKind === 8192 /* TypeParameter */) { + if (!this.childDeclTypeParameterCache) { + this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeParameterCache; + } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { + if (!this.childDeclNamespaceCache) { + this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclNamespaceCache; + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { + if (!this.childDeclTypeCache) { + this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeCache; + } else { + if (!this.childDeclValueCache) { + this.childDeclValueCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclValueCache; + } + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + + if (!(childDecl.kind & 7340032 /* SomeSignature */)) { + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + } + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; + } else if (searchKind & 164 /* SomeContainer */) { + cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; + } else { + cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + if (!this.declGroups) { + this.declGroups = TypeScript.createIntrinsicsObject(); + } + + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + if (this.declGroups) { + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (declGroups === null) { + declGroups = []; + } + + declGroups.push(this.declGroups[declName].getDecls()); + } + } + } + + return declGroups || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.hasBeenBound = function () { + return this.hasSymbol() || this.hasSignatureSymbol(); + }; + + PullDecl.prototype.isSynthesized = function () { + return false; + }; + + PullDecl.prototype.ast = function () { + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var RootPullDecl = (function (_super) { + __extends(RootPullDecl, _super); + 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; + } + RootPullDecl.prototype.fileName = function () { + return this._fileName; + }; + + RootPullDecl.prototype.getParentPath = function () { + return [this]; + }; + + RootPullDecl.prototype.getParentDecl = function () { + return null; + }; + + RootPullDecl.prototype.isExternalModule = function () { + return this._isExternalModule; + }; + + 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, addToParent) { + if (typeof addToParent === "undefined") { addToParent = true; } + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); + this.parentDecl = null; + this.parentPath = null; + + this.parentDecl = parentDecl; + 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._rootDecl.fileName(); + }; + + NormalPullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + NormalPullDecl.prototype.getParentPath = function () { + if (!this.parentPath) { + var path = [this]; + var parentDecl = this.parentDecl; + + while (parentDecl) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { + path.unshift(parentDecl); + } + + parentDecl = parentDecl.getParentDecl(); + } + + this.parentPath = path; + } + + return this.parentPath; + }; + + NormalPullDecl.prototype.isExternalModule = function () { + return false; + }; + + 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) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); + this.constantValue = null; + } + return PullEnumElementDecl; + })(NormalPullDecl); + TypeScript.PullEnumElementDecl = PullEnumElementDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { + if (typeof displayName === "undefined") { displayName = ""; } + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(NormalPullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullSynthesizedDecl = (function (_super) { + __extends(PullSynthesizedDecl, _super); + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; + } + PullSynthesizedDecl.prototype.isSynthesized = function () { + return true; + }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; + return PullSynthesizedDecl; + })(NormalPullDecl); + TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = ++TypeScript.pullSymbolID; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.rootSymbol = null; + this._enclosingSignature = null; + this._docComments = null; + this.isPrinting = false; + this.name = name; + this.kind = declKind; + } + PullSymbol.prototype.isAny = function () { + return false; + }; + + PullSymbol.prototype.isType = function () { + return (this.kind & 58728795 /* SomeType */) !== 0; + }; + + PullSymbol.prototype.isTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & 7340032 /* SomeSignature */) !== 0; + }; + + PullSymbol.prototype.isArrayNamedTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { + if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } + if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } + var scopeDeclarations = scopeSymbol.getDeclarations(); + var scopeSymbolAliasesToLookIn = []; + + for (var i = 0; i < scopeDeclarations.length; i++) { + var scopeDecl = scopeDeclarations[i]; + if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { + visitedScopeDeclarations.push(scopeDecl); + + var childDecls = scopeDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { + var symbol = childDecl.getSymbol(); + + if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { + aliasSymbols.push(symbol); + return aliasSymbols; + } + + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { + scopeSymbolAliasesToLookIn.push(symbol); + } + } + } + } + } + + for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { + var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; + + aliasSymbols.push(scopeSymbolAlias); + var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); + if (result) { + return result; + } + + aliasSymbols.pop(); + } + + return null; + }; + + PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); + return symbols; + } + + return null; + }; + + PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { + if (aliasSymbol) { + if (aliasSymbol.assignedValue()) { + return false; + } + + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { + return false; + } + + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { + return false; + } + + return true; + } + + return false; + }; + + PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { + if (scopeSymbol) { + 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); + return internalAliases[0]; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { + if (!skipInternalAlias) { + var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); + if (internalAlias) { + return aliasNameGetter(internalAlias); + } + } + + var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); + + if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { + 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 aliasFullName; + } + + return null; + }; + + PullSymbol.prototype._getResolver = function () { + TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); + return this._declarations[0].semanticInfoChain.getResolver(); + }; + + PullSymbol.prototype._resolveDeclaredSymbol = function () { + return this._getResolver().resolveDeclaredSymbol(this); + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getName(); + }); + return aliasName || this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getDisplayName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getDisplayName(); + }, skipInternalAliasName); + if (aliasDisplayName) { + return aliasDisplayName; + } + + var decls = this.getDeclarations(); + var name = decls.length && decls[0].getDisplayName(); + + return (name && name.length) ? name : this.name; + }; + + PullSymbol.prototype.getIsSpecialized = function () { + return false; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + 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; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.hasDeclaration = function (decl) { + if (!this._declarations) { + return false; + } + + return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { + return eachDecl === decl; + }); + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.anyDeclHasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (TypeScript.hasFlag(declarations[i].flags, flag)) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!TypeScript.hasFlag(declarations[i].flags, flag)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = node.getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind === 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + 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 memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { + return true; + } + + var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol) { + return true; + } + } + } + + 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 (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { + return thisPath.slice(0, thisCommonAncestorIndex); + } else { + return thisPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; + var path = this.pathToRoot(); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol === _this ? null : symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { + var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + 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 */) { + var signatures = type.getCallSignatures(); + 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); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + + inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); + + var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); + inIsExternallyVisibleSymbols.pop(); + + return result; + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.rootSymbol) { + return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); + } + + if (this.isType()) { + var associatedContainerSymbol = this.getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.anyDeclHasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + var decls = this.getDeclarations(); + if (decls.length) { + var parentDecl = decls[0].getParentDecl(); + if (parentDecl) { + var parentSymbol = parentDecl.getSymbol(); + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { + return true; + } + + return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); + } + } + + return true; + } + + 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 */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { + var ast = decl.ast(); + + if (ast) { + 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.ASTHelpers.docComments(ast); + } + } + + return []; + }; + + PullSymbol.prototype.getDocCommentArray = function (symbol) { + var docComments = []; + if (!symbol) { + return docComments; + } + + 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 */) { + continue; + } + docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); + } + return docComments; + }; + + PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { + if (classSymbol.getHasDefaultConstructor()) { + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); + } + } + + return classSymbol.type.getConstructSignatures()[0]; + }; + + PullSymbol.prototype.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = this.getDocCommentTextValue(comments[c]); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + PullSymbol.prototype.getDocCommentTextValue = function (comment) { + return this.cleanJSDocComment(comment.fullText()); + }; + + PullSymbol.prototype.docComments = function (useConstructorAsClass) { + var decls = this.getDeclarations(); + 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 */) { + var classSymbol = this.returnType; + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + docComments = extendedTypes[0].getConstructorMethod().docComments(); + } else { + docComments = ""; + } + } else if (this.kind === 2048 /* Parameter */) { + var parameterComments = []; + + var funcContainer = this.getEnclosingSignature(); + var funcDocComments = this.getDocCommentArray(funcContainer); + var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); + if (paramComment != "") { + parameterComments.push(paramComment); + } + + var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); + if (paramSelfComment != "") { + parameterComments.push(paramSelfComment); + } + docComments = parameterComments.join("\n"); + } else { + var getSymbolComments = true; + if (this.kind === 16777216 /* FunctionType */) { + var functionSymbol = this.getFunctionSymbol(); + + if (functionSymbol) { + docComments = functionSymbol._docComments || ""; + getSymbolComments = false; + } else { + var declarationList = this.getDeclarations(); + if (declarationList.length > 0) { + docComments = declarationList[0].getSymbol()._docComments || ""; + getSymbolComments = false; + } + } + } + if (getSymbolComments) { + docComments = this.getDocCommentText(this.getDocCommentArray(this)); + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { + var callTypeSymbol = this.functionType; + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { + docComments = callTypeSymbol.docComments(); + } + } + } + } + } + + this._docComments = docComments; + } + + return this._docComments; + }; + + PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].fullText(); + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!this.isSpaceChar(commentContents, j)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + + PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.start; + for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.end); + } + + var newCleanPos = this.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + PullSymbol.prototype.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = this.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + start: nonSpaceIndex, + end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + 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.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; + this.hasBeenChecked = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return this._isDefinition; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + 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) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this._typeParameters) { + this._typeParameters = []; + } + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + 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 = []; + } + + return this._typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; + } + } + + memberSymbol = this._memberTypeParameterNameCache[name]; + + 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; + this._stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { + this._stringConstantOverload = true; + } + } + } + + 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); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + 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 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 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 wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + + var parameters = this.parameters; + + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._enclosedMemberContainers = null; + this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._enclosedContainerCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._containedNonMemberContainerCache = null; + this._simpleInstantiationCache = null; + this._complexInstantiationCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this._inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + this.typeReference = null; + this._widenedType = null; + this._isArrayNamedTypeReference = undefined; + this.type = this; + } + PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { + if (this._isArrayNamedTypeReference === undefined) { + this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); + } + + return this._isArrayNamedTypeReference; + }; + + PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { + var typeArgs = this.getTypeArguments(); + if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { + var declaration = this.getDeclarations()[0]; + + if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind === 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind === 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullTypeSymbol.prototype.isObject = function () { + 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 () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members !== TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return null; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberContainerCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = TypeScript.createIntrinsicsObject(); + } + + if (this._members === TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members.push(memberSymbol); + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + if (!enclosedContainer) { + return; + } + + enclosedContainer.setContainer(this); + + if (!this._enclosedContainerCache) { + this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberContainers) { + this._enclosedMemberContainers = []; + } + + this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; + this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + if (!enclosedNonMemberContainer) { + return; + } + + enclosedNonMemberContainer.setContainer(this); + + if (!this._containedNonMemberContainerCache) { + this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + 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 (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; + } + + 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; + } else { + if (!this._complexInstantiationCache) { + this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType.push(specializedVersionOfThisType); + }; + + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { + if (!this._simpleInstantiationCache) { + return null; + } + + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; + } else { + if (!this._complexInstantiationCache) { + return null; + } + + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + } + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return null; + }; + + PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + return this.getTypeParameters(); + }; + + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + 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 = []; + } + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + 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 = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + 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; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return this._constructSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function () { + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return this._indexSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnIndexSignatures = function () { + return this._indexSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function () { + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + } + } + + this._allIndexSignatures = signatures; + + 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; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { + if (typeof visited === "undefined") { visited = []; } + if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { + return true; + } + + if (TypeScript.ArrayUtilities.contains(visited, this)) { + return true; + } + + visited.push(this); + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + visited.pop(); + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (memberSymbol || !lookInParent) { + return memberSymbol; + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedContainerCache) { + return null; + } + + memberSymbol = this._enclosedContainerCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + var allMembers = []; + + 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 */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; + + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer()) { + if (this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + if (this._enclosedMemberContainers) { + for (var i = 0; i < this._enclosedMemberContainers.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberContainers[i]; + } + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArgumentsOrTypeParameters(); + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); + }; + + 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 !== "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); + return s; + }; + + 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, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + if (skipTypeParametersInName) { + return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); + } else { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + + var typars = this.getTypeArgumentsOrTypeParameters(); + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + } + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getTypeOfSymbol = function () { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + return associatedContainerType; + } + + var functionSymbol = this.getFunctionSymbol(); + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; + } + + return null; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + var typeOfSymbol = this.getTypeOfSymbol(); + if (typeOfSymbol) { + var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } + + if (this._inMemberTypeNameEx) { + return TypeScript.MemberName.create("any"); + } + + this._inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + 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()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && memberTypeName.delim === delim) { + allMemberNames.addAll(memberTypeName.entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this._inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + return 2 /* Closed */; + }; + + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + + if (type.isTypeParameter()) { + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; + } + + var constraint = type.getConstraint(); + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; + } + + if (type.inWrapCheck) { + return 0; + } + + 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; + + var typeArguments = type.getTypeArguments(); + + if (type.isGeneric() && !typeArguments) { + typeArguments = type.getTypeParameters(); + } + + if (typeArguments) { + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); + } + } + } + + 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); + } + + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); + } + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } + + return wrappingTypeParameterID; + }; + + 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + 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(); + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; + } + + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { + return true; + } + } + + 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); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isAny = function () { + 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 () { + return false; + }; + + 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; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(_anyType, name) { + _super.call(this, name); + 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); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerSymbol = (function (_super) { + __extends(PullContainerSymbol, _super); + function PullContainerSymbol(name, kind) { + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerSymbol.prototype.hasExportAssignment = function () { + return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; + }; + + PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { + return true; + } + + var moduleSymbol = containerSymbol; + var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerSymbol = PullContainerSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 128 /* TypeAlias */); + this._assignedValue = null; + this._assignedType = null; + 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; + }; + + PullTypeAliasSymbol.prototype.isUsedAsValue = function () { + this._resolveDeclaredSymbol(); + return this._isUsedAsValue; + }; + + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; + }; + + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; + + 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(); + }); + } + }; + + PullTypeAliasSymbol.prototype.assignedValue = function () { + this._resolveDeclaredSymbol(); + return this._assignedValue; + }; + + PullTypeAliasSymbol.prototype.assignedType = function () { + this._resolveDeclaredSymbol(); + return this._assignedType; + }; + + PullTypeAliasSymbol.prototype.assignedContainer = function () { + this._resolveDeclaredSymbol(); + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this._assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this._assignedValue) { + return this._assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this._assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedType) { + if (this._assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = this._assignedType.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this._assignedType !== this._assignedContainer) { + return this._assignedType; + } + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this._assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this._assignedType) { + return this._assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this._assignedType) { + return this._assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this._assignedType) { + return this._assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this._assignedType) { + return this._assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this._assignedType) { + return this._assignedType.findMember(name, true); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedContainer(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { + if (this._assignedType) { + return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); + } + + return TypeScript.sentinelEmptyArray; + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name) { + _super.call(this, name, 8192 /* TypeParameter */); + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + 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(); + } + + return _super.prototype.getCallSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getConstructSignatures = function () { + if (this._constraint) { + return this._constraint.getConstructSignatures(); + } + + return _super.prototype.getConstructSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getIndexSignatures = function () { + if (this._constraint) { + return this._constraint.getIndexSignatures(); + } + + return _super.prototype.getIndexSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { + var substitution = ""; + var members = null; + + 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 getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); + } + + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); + } + + return null; + } + + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.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"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; + })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); + 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._inferredTypeAfterFixing = null; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + 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 TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + this.candidateCache = []; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); + } + } + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { + return true; + } else { + this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); + return false; + } + }; + + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache.release(); + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + }; + + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolID]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolID] = info; + } + }; + + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolID]; + }; + + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { + var info = this.getInferenceInfo(param); + + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); + } + }; + + 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); + } + }; + + 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]; + + info.fixTypeParameter(this.resolver, this.context); + + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; + } + } + + results.push(info._inferredTypeAfterFixing); + } + + return results; + }; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; + })(); + 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, isInferentiallyTyping, typeArgumentInferenceContext) { + this.contextualType = contextualType; + this.provisional = provisional; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; + this.provisionallyTypedSymbols = []; + this.hasProvisionalErrors = false; + this.astSymbolMap = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].setUnresolved(); + } + }; + + PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()]; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + if (typeof fileName === "undefined") { fileName = null; } + this.resolver = resolver; + this.inTypeCheck = inTypeCheck; + 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"); + this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); + } + } + PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { + if (!this.inProvisionalResolution()) { + this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); + } + }; + + PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { + return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); + }; + + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); + }; + + 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(); + + if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; + } + + return tc; + }; + + PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + 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); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); + } + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { + if (diagnostic) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; + } else if (this.inTypeCheck && this.resolver) { + this.resolver.semanticInfoChain.addDiagnostic(diagnostic); + } + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inProvisionalResolution(); + }; + + PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { + this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); + }; + + PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + var typeContext = this.contextStack[i]; + if (!typeContext.provisional) { + break; + } + + var symbol = typeContext.getSymbolForAST(ast); + if (symbol) { + return symbol; + } + } + + 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; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OverloadApplicabilityStatus; + (function (OverloadApplicabilityStatus) { + OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; + })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + this.diagnosticsFromOverloadResolution = []; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var MemberWithBaseOrigin = (function () { + function MemberWithBaseOrigin(memberSymbol, baseOrigin) { + this.memberSymbol = memberSymbol; + this.baseOrigin = baseOrigin; + } + return MemberWithBaseOrigin; + })(); + + var SignatureWithBaseOrigin = (function () { + function SignatureWithBaseOrigin(signature, baseOrigin) { + this.signature = signature; + this.baseOrigin = baseOrigin; + } + return SignatureWithBaseOrigin; + })(); + + var InheritedIndexSignatureInfo = (function () { + function InheritedIndexSignatureInfo() { + } + return InheritedIndexSignatureInfo; + })(); + + 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(); + return CompilerReservedName[nameText]; + } + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this._cachedAnyTypeArgs = null; + this.typeCheckCallBacks = []; + this.postTypeCheckWorkitems = []; + this._cachedFunctionArgumentsSymbol = null; + 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 */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getArrayNamedType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { + if (!this._cachedFunctionArgumentsSymbol) { + this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); + functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); + this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + } + + 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); + }; + + PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { + return context.canTypeCheckAST(ast); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && context.inProvisionalResolution()) { + context.setSymbolForAST(ast, symbol); + } else { + this.semanticInfoChain.setSymbolForAST(ast, symbol); + } + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { + var symbol = this.semanticInfoChain.getSymbolForAST(ast); + + if (!symbol) { + if (context && context.inProvisionalResolution()) { + symbol = context.getSymbolForAST(ast); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { + if (typeof name === "undefined") { name = null; } + return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = decl.getParentPath(); + + if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.anyDeclHasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + 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 & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + + if (declSearchKind & 68147712 /* SomeValue */) { + member = parent.findMember(symbolName, true); + } else if (declSearchKind & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + } + + if (parent.kind & 164 /* SomeContainer */) { + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + return valueSymbol; + } + } + + return aliasSymbol; + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + 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; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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(); + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & 1032192 /* SomeFunction */) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (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) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = decl.getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var topLevelDecls = this.semanticInfoChain.topLevelDecls(); + for (var i = 0, n = topLevelDecls.length; i < n; i++) { + var topLevelDecl = topLevelDecls[i]; + if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { + continue; + } + + if (!topLevelDecl.isExternalModule()) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + 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 */ || lhs.kind === 64 /* Enum */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + this.resolveDeclaredSymbol(lhsType, context); + + if (lhsType.isContainer() && lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + var memberVisibilty = 2 /* externallyVisible */; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = enclosingDecl.getParentPath(); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { + memberVisibilty = 1 /* internallyVisible */; + break; + } + } + } + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + lhsType = this.getApparentType(lhsType); + + 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); + } + + 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 */)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { + var originalIdText = idText; + var symbol = null; + + if (TypeScript.isRelative(originalIdText)) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + symbol = this.semanticInfoChain.findExternalModule(path + idText); + } else { + idText = originalIdText; + + symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); + + if (!symbol) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + symbol = this.semanticInfoChain.findExternalModule(path + idText); + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + } + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { + if (!symbol || symbol.isResolved || symbol.isTypeReference()) { + return symbol; + } + + if (!context) { + context = new TypeScript.PullTypeResolutionContext(this); + } + + return this.resolveDeclaredSymbolWorker(symbol, context); + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.type && !symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + + var decls = symbol.getDeclarations(); + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + var ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + var resolvedSymbol; + 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 */); + resolvedSymbol = this.resolveAST(ast, false, context); + } + + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + 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(); + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); + }; + + PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { + var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); + var moduleSymbol = enclosingDecl.getSymbol(); + this.ensureAllSymbolsAreBound(moduleSymbol); + + this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); + this.resolveAST(sourceUnit.moduleElements, false, context); + + if (this.canTypeCheckAST(sourceUnit, context)) { + this.typeCheckSourceUnit(sourceUnit, context); + } + + return moduleSymbol; + }; + + 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) { + var containerDecl = this.semanticInfoChain.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + containerSymbol.setResolved(); + + this.resolveOtherDeclarations(ast, context); + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckEnumDeclaration(ast, context); + } + + return containerSymbol; + }; + + 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); + + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { + this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); + } + }; + + PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { + 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; + + if (ast.stringLiteral) { + result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckModuleDeclaration(ast, context); + } + + return result; + }; + + PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { + if (containerSymbol) { + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + }; + + PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + this.ensureAllSymbolsAreBound(containerSymbol); + + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, context); + } + + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + if (isLastName) { + this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); + } else if (sourceUnitAST) { + this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); + } + + containerSymbol.setResolved(); + + if (moduleDeclNameAST) { + this.resolveOtherDeclarations(moduleDeclNameAST, context); + } + + return containerSymbol; + }; + + 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 */) { + this.resolveExportAssignmentStatement(moduleElement, context); + return; + } + } + }; + + PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + var containerSymbol = containerDecl.getSymbol(); + + return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); + }; + + PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { + if (ast.stringLiteral) { + this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + }; + + PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; + this.setTypeChecked(ast, context); + + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { + this.resolveAST(ast.moduleElements, false, context); + } + + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + this.validateVariableDeclarationGroups(containerDecl, context); + + if (ast.stringLiteral) { + if (TypeScript.isRelative(ast.stringLiteral.valueText())) { + this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); + } + } + + 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) { + this.checkThisCaptureVariableCollides(ast, true, context); + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { + if (term.kind() === 11 /* IdentifierName */) { + return true; + } else if (term.kind() === 121 /* QualifiedName */) { + var binex = term; + + if (binex.right.kind() === 11 /* IdentifierName */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { + if (!type.isGeneric()) { + return type; + } + + var typeParameters = type.getTypeArgumentsOrTypeParameters(); + + var typeParameterArgumentMap = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); + } + + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); + if (extendsClause) { + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + + if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + } + } + } + + 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()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); + var implementedType = this.resolveTypeReference(implementedTypeAST, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + + if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addImplementedType(implementedType); + } + } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + + this.typeCheckCallBacks.push(function (context) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + _this.resolveClassDeclaration(classOrInterface, context); + } else { + _this.resolveInterfaceDeclaration(classOrInterface, context); + } + }); + + return typeDeclSymbol; + } + + this.setSymbolForAST(name, typeDeclSymbol, context); + this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + 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); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + var parentConstructor = parentType ? parentType.getConstructorMethod() : null; + + if (parentConstructor) { + this.resolveDeclaredSymbol(parentConstructor, context); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + + if (!parentConstructSignatures.length) { + parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + parentConstructSignature.returnType = parentType; + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); + parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); + parentConstructSignatures = [parentConstructSignature]; + } + + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + 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); + } + + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + + if (parentConstructorSymbol) { + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + } + } + + this.resolveOtherDeclarations(classDeclAST, context); + } + + if (this.canTypeCheckAST(classDeclAST, context)) { + this.typeCheckClassDeclaration(classDeclAST, context); + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { + var _this = this; + 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); + }); + } + } + }; + + PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { + this.setTypeChecked(classDeclAST, context); + + var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + + this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); + this.resolveAST(classDeclAST.classElements, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); + this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + + if (!classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); + }; + + PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { + this.checkThisCaptureVariableCollides(classDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { + var callSignatures = typeSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], context); + } + + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], context); + } + + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], context); + } + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); + + if (interfaceDeclSymbol.isResolved) { + this.resolveOtherDeclarations(interfaceDeclAST, context); + + if (this.canTypeCheckAST(interfaceDeclAST, context)) { + this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { + this.setTypeChecked(interfaceDeclAST, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); + this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); + + 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) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + this.resolveDeclaredSymbol(symbol, context); + + var alias = symbol; + if (kind & 164 /* SomeContainer */) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & 58728795 /* SomeType */) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & 68147712 /* SomeValue */) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); + + return { + symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), + aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null + }; + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + var rhsName = identifier.valueText(); + if (rhsName.length === 0) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); + var containerSymbol = memberSymbol.symbol; + var valueSymbol = null; + var typeSymbol = null; + var aliasSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + aliasSymbol = memberSymbol.aliasSymbol; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + aliasSymbol = containerSymbol; + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); + valueSymbol = memberSymbol.symbol; + if (valueSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + } + + if (!typeSymbol) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + typeSymbol = memberSymbol.symbol; + if (typeSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); + return null; + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol, + aliasSymbol: aliasSymbol + }; + }; + + 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"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleContainer) { + moduleName = dottedNameAST.right.valueText(); + + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; + if (!moduleSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); + } + } + } else { + var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); + var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); + + if (text.length > 0) { + var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); + moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); + if (moduleSymbol) { + 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]); + } + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var moduleReference = importStatementAST.moduleReference; + + var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; + + 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); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); + if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { + var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); + var instanceSymbol = aliasedType.getInstanceSymbol(); + + 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 { + importDeclSymbol.setAssignedValueSymbol(valueSymbol); + } + } + } else { + aliasedType = this.getNewErrorTypeSymbol(); + } + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); + return null; + } + } + } + + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + var declPath = enclosingDecl.getParentPath(); + + aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); + + if (!aliasedType) { + var path = importStatementAST.moduleReference.stringLiteral.text(); + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); + aliasedType = this.getNewErrorTypeSymbol(); + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); + } + + importDeclSymbol.setResolved(); + + this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); + 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); + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { + var _this = this; + this.setTypeChecked(importStatementAST, context); + + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (this.compilationSettings.noResolve()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); + } + + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + if (enclosingDecl.kind === 32 /* DynamicModule */) { + 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)); + } + } + } + } + + var checkPrivacy; + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind === 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + + 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; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { + var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + } + + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); + }; + + PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { + 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); + } + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { + var id = exportAssignmentAST.identifier.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && parentSymbol.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + + var aliasSymbol = containerSymbol; + var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + parentSymbol.setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + parentSymbol.setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + parentSymbol.setExportAssignedContainerSymbol(containerSymbol); + } + + this.resolveDeclaredSymbol(valueSymbol, context); + this.resolveDeclaredSymbol(typeSymbol, context); + this.resolveDeclaredSymbol(containerSymbol, context); + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + var funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); + } + } + + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.setTypeChecked(funcDeclAST, context); + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeAnnotation) { + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + 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) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + 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 (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(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + var contextualType = contextParam && contextParam.type; + var isImplicitAny = false; + + if (typeExpr) { + var typeRef = this.resolveTypeReference(typeExpr, context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + typeRef = this.getNewErrorTypeSymbol(); + } + + contextualType = typeRef || contextualType; + } + if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } + context.setTypeInContext(paramSymbol, contextualType); + } 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.propagateContextualType(contextualType); + } + + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + } + + if (!initExprSymbol || !initExprSymbol.type) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); + + if (!contextualType) { + context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); + } + } else { + var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); + if (!contextualType) { + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); + isImplicitAny = initTypeSymbol !== paramSymbol.type; + } else { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); + } + } + } + } + } + + if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + isImplicitAny = true; + } + + if (isImplicitAny && this.compilationSettings.noImplicitAny()) { + var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); + if (functionExpressionName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); + } + } + + if (canTypeCheckAST) { + this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { + var compilerReservedName = getCompilerReservedName(name); + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; + + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; + + case 3 /* arguments */: + this.checkArgumentsCollides(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; + } + }; + + PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { + var enclosingAST = this.getASTForDecl(someFunctionDecl); + var nodeType = enclosingAST.kind(); + + 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); + } 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 */) { + var constructorDeclaration = enclosingAST; + 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 */) { + var functionExpression = enclosingAST; + return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); + } + + return false; + }; + + PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { + if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); + } + } + } + }; + + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + 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)); + } + } + } + } + }; + + PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { + var decl = this.semanticInfoChain.getDeclForAST(ast); + + if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + var nameText = name.valueText(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); + } + } + }; + + PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); + TypeScript.Debug.assert(interfaceDecl); + + var interfaceSymbol = interfaceDecl.getSymbol(); + TypeScript.Debug.assert(interfaceSymbol); + + if (objectType.typeMembers) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = objectType.typeMembers; + + for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { + memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); + memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (this.canTypeCheckAST(objectType, context)) { + this.typeCheckObjectTypeTypeReference(objectType, context); + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { + this.setTypeChecked(objectType, context); + var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); + var objectTypeSymbol = objectTypeDecl.getSymbol(); + + this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); + }; + + PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { + return this.resolveTypeReference(typeAnnotation.type, context); + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { + if (typeRef === null) { + return null; + } + + TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); + + var aliasType = null; + var type = this.computeTypeReferenceSymbol(typeRef, context); + + if (type.kind === 4 /* Container */) { + var container = type; + var instanceSymbol = container.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + if (aliasType) { + this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); + } + } + + if (type && !type.isError()) { + 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 { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); + } + } + } + + if (this.canTypeCheckAST(typeRef, context)) { + this.setTypeChecked(typeRef, context); + } + + 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 */: + return this.semanticInfoChain.anyTypeSymbol; + case 61 /* BooleanKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + case 67 /* NumberKeyword */: + return this.semanticInfoChain.numberTypeSymbol; + case 69 /* StringKeyword */: + return this.semanticInfoChain.stringTypeSymbol; + case 41 /* VoidKeyword */: + return this.semanticInfoChain.voidTypeSymbol; + } + + var typeDeclSymbol = null; + + if (term.kind() === 11 /* IdentifierName */) { + typeDeclSymbol = this.resolveTypeNameExpression(term, context); + } else if (term.kind() === 123 /* FunctionType */) { + var functionType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); + } else if (term.kind() === 125 /* ConstructorType */) { + var constructorType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); + } else if (term.kind() === 122 /* ObjectType */) { + typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); + } else if (term.kind() === 126 /* GenericType */) { + typeDeclSymbol = this.resolveGenericTypeReference(term, context); + } else if (term.kind() === 121 /* QualifiedName */) { + typeDeclSymbol = this.resolveQualifiedName(term, context); + } else if (term.kind() === 14 /* StringLiteral */) { + 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, enclosingDecl.semanticInfoChain); + typeDeclSymbol.addDeclaration(decl); + } else if (term.kind() === 127 /* TypeQuery */) { + var typeQuery = term; + + var typeQueryTerm = typeQuery.name; + + var valueSymbol = this.resolveAST(typeQueryTerm, false, context); + + if (valueSymbol && valueSymbol.isAlias()) { + if (valueSymbol.assignedValue()) { + valueSymbol = valueSymbol.assignedValue(); + } else { + var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(); + } + } else if (term.kind() === 124 /* ArrayType */) { + var arrayType = term; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); + } else { + throw TypeScript.Errors.invalidOperation("unknown type"); + } + + if (!typeDeclSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); + return this.getNewErrorTypeSymbol(); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { + 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveParameterList = function (list, context) { + return this.resolveSeparatedList(list.parameters, context); + }; + + PullTypeResolver.prototype.resolveParameter = function (parameter, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { + var enumDeclaration = enumElement.parent.parent; + var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); + var symbol = decl.getSymbol(); + this.resolveDeclaredSymbol(symbol, context); + + return symbol; + }; + + PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { + if (this.canTypeCheckAST(clause, context)) { + this.setTypeChecked(clause, context); + } + + return this.resolveAST(clause.value, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + } else { + if (declSymbol.inResolution) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + + if (!declSymbol.type || !declSymbol.type.isError()) { + declSymbol.startResolving(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + if (!hasTypeExpr) { + this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + } + + if (!(hasTypeExpr || init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { + defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + } + } + + if (this.canTypeCheckAST(varDeclOrParameter, context)) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); + } + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (varDeclOrParameter.kind() === 243 /* EnumElement */) { + var result = this.getEnumTypeSymbol(varDeclOrParameter, context); + declSymbol.type = result; + return result; + } + + if (!typeExpr) { + return null; + } + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var typeExprSymbol = this.resolveTypeReference(typeExpr, context); + + if (!typeExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + declSymbol.type = this.getNewErrorTypeSymbol(); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = typeExprSymbol.getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } 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(); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + } + + return typeExprSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { + if (!init) { + return null; + } + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + if (typeExprSymbol) { + context.pushNewContextualType(typeExprSymbol); + } + + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); + + if (typeExprSymbol) { + context.popAnyContextualType(); + } + + if (!initExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + + if (!hasTypeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + var initTypeSymbol = initExprSymbol.type; + + if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); + context.setTypeInContext(declSymbol, widenedInitTypeSymbol); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny()) { + 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 initTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var _this = this; + this.setTypeChecked(varDeclOrParameter, context); + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + + if (hasTypeExpr || init) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = typeExprSymbol.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); + } + } + } + } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { + var wrapperDecl = this.getEnclosingDecl(decl); + 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])); + } else if (wrapperDecl.kind === 65536 /* Method */) { + var parentDecl = wrapperDecl.getParentDecl(); + + if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); + } 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 (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 */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } + } + } + + 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_only_allowed_in_implementation)); + } + } + 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 */)) { + this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); + } + }; + + PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { + return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; + }; + + PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { + var enclosingDecl = this.getEnclosingDeclForAST(superAST); + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); + + if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { + 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; + if (!block) { + return; + } + } + } + + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + if (parents.length) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); + } + } + }; + + PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { + if (isDeclaration) { + var decl = this.semanticInfoChain.getDeclForAST(_thisAST); + if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + return; + } + } + + var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + var declPath = enclosingDecl.getParentPath(); + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + continue; + } + + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); + } + break; + } + } + }; + + PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { + this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + 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) { + return; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + }; + + PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { + this.setTypeChecked(typeParameterAST, 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) { + if (this.canTypeCheckAST(constraint, context)) { + this.setTypeChecked(constraint, context); + } + + return this.resolveTypeReference(constraint.type, context); + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatementsExpressions = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, walker) { + var go = true; + + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); + go = false; + break; + + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, walker) { + switch (ast.kind()) { + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + if (block) { + TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + } else { + returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + } + + if (!returnStatementsExpressions.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnExpressions = []; + + for (var i = 0; i < returnStatementsExpressions.length; i++) { + var returnExpression = returnStatementsExpressions[i].expression; + if (returnExpression) { + var returnType = this.resolveAST(returnExpression, useContextualType, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { + this.setSymbolForAST(returnExpression.parent, returnType, context); + } + } + + returnExpressionSymbols.push(returnType); + returnExpressions.push(returnExpression); + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); + var returnType = bestCommonReturnType; + var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = returnType.widenedType(this, returnExpression, context); + signature.returnType = newReturnType; + + if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); + } + + if (this.compilationSettings.noImplicitAny()) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName === "") { + functionName = enclosingDecl.getFunctionExpressionName(); + } + + if (functionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } + + if (!functionSymbol.type && functionSymbol.isAccessor()) { + functionSymbol.type = signature.returnType; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { + var _this = this; + this.setTypeChecked(funcDeclAST, context); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { + var _this = this; + if (constructorDecl.block) { + var foundSuperCall = false; + var pre = function (ast, walker) { + 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; + } + } + }; + + TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); + return foundSuperCall; + } + + return false; + }; + + 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(parameters, false, context); + + this.resolveAST(block, false, context); + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + this.validateVariableDeclarationGroups(funcDecl, context); + + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); + + if (funcDecl.kind === 16384 /* Function */) { + this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); + } + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + this.resolveAST(funcDeclAST.parameter, false, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); + var stringIndexSignature = allIndexSignatures.stringSignature; + var numberIndexSignature = allIndexSignatures.numericSignature; + var isNumericIndexer = numberIndexSignature === signature; + + if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { + var comparisonInfo = new TypeComparisonInfo(); + + 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + } + } + } + + var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); + for (var i = 0; i < allMembers.length; i++) { + var member = allMembers[i]; + var name = member.name; + if (name || (member.kind === 4096 /* Property */ && name === "")) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], context); + } + + if (parentSymbol !== allMembers[i].getContainer()) { + var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); + var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; + var onlyStringIndexerIsPresent = !numberIndexSignature; + + if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { + var comparisonInfo = new TypeComparisonInfo(); + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); + } + } + } + } + } + }); + }; + + PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { + this.checkThisCaptureVariableCollides(funcDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { + var returnTypeSymbol = null; + + if (returnTypeAnnotation) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + } else { + var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } + + return returnTypeSymbol; + }; + + 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + return funcSymbol; + } + + if (!signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + 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(); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveIndexSignature(ast.indexSignature, context); + }; + + PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + return funcSymbol; + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.typeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.parameter) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + this.resolveParameter(funcDeclAST.parameter, context); + context.inTypeCheck = prevInTypeCheck; + } + + if (funcDeclAST.typeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + + context.inTypeCheck = prevInTypeCheck; + } + + if (returnTypeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { + if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { + 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; + if (funcDeclASTName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } + } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { + if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); + } + + return null; + }; + + 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.ASTHelpers.getType(parameter), context); + } + + return null; + }; + + PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + + if (accessorSymbol.inResolution) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + accessorSymbol.setResolved(); + + return accessorSymbol; + } + + if (accessorSymbol.isResolved) { + if (!accessorSymbol.type) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else { + var getterSymbol = accessorSymbol.getGetter(); + var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; + var hasGetter = getterSymbol !== null; + + var setterSymbol = accessorSymbol.getSetter(); + var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; + var hasSetter = setterSymbol !== null; + + var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); + var getterHasTypeAnnotation = getterAnnotatedType !== null; + + var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); + var setterHasTypeAnnotation = setterAnnotatedType !== null; + + accessorSymbol.startResolving(); + + if (hasGetter) { + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + } + + if (hasSetter) { + setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); + } + + if (hasGetter && hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + var getterSig = getterSymbol.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { + getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; + getterSig.returnType = setterSuppliedTypeSymbol; + } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { + setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; + + if (setterHasParameters) { + setterParameters[0].type = getterSuppliedTypeSymbol; + } + } + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + accessorSymbol.type = this.getNewErrorTypeSymbol(); + } else { + accessorSymbol.type = getterSuppliedTypeSymbol; + } + } else if (hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + + accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; + } else { + var getterSig = getterSymbol.type.getCallSignatures()[0]; + accessorSymbol.type = getterSig.returnType; + } + + accessorSymbol.setResolved(); + } + + if (this.canTypeCheckAST(funcDeclAst, context)) { + this.typeCheckAccessorDeclaration(funcDeclAst, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { + this.setTypeChecked(funcDeclAst, context); + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + var getterSymbol = accessorSymbol.getGetter(); + var setterSymbol = accessorSymbol.getSetter(); + + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; + if (isGetter) { + var getterFunctionDeclarationAst = funcDeclAst; + context.pushNewContextualType(getterSymbol.type); + this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); + context.popAnyContextualType(); + } else { + var setterFunctionDeclarationAst = funcDeclAst; + this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); + } + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return getterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return getterSymbol; + } + + signature.startResolving(); + + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + if (!setterAnnotatedType) { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } else { + signature.returnType = setterAnnotatedType; + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + return getterSymbol; + }; + + PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + if (getter && setter) { + var getterAST = getter.getDeclarations()[0].ast(); + var setterAST = setter.getDeclarations()[0].ast(); + + if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { + var setterSig = setter.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + + var getter = accessorSymbol.getGetter(); + var getterSig = getter.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterParameters[0].type; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + var funcNameAST = funcDeclAST.propertyName; + + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); + } + + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); + var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + 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.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; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return setterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + signature.setResolved(); + return setterSymbol; + } + + signature.startResolving(); + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + } + + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + + if (!hadError) { + signature.setResolved(); + } + } + + return setterSymbol; + }; + + PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + if (funcDeclAST.parameterList) { + for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + + var getter = accessorSymbol.getGetter(); + + var funcNameAST = funcDeclAST.propertyName; + + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); + var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + if (getterIsPrivate !== setterIsPrivate) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); + } + + this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); + } else { + if (this.compilationSettings.noImplicitAny()) { + var setterFunctionDeclarationAst = funcDeclAST; + 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + }; + + PullTypeResolver.prototype.resolveList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.childCount(); i < n; i++) { + this.resolveAST(list.childAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.resolveAST(list.nonSeparatorAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLogicalOperation(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { + this.setTypeChecked(binex, context); + + var leftType = this.resolveAST(binex.left, false, context).type; + var rightType = this.resolveAST(binex.right, false, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(binex); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ + TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), + leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); + } + }; + + PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.operand, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckUnaryArithmeticOperation(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckPostfixUnaryExpression(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { + return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); + }; + + PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + return; + } + + TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { + if (this.canTypeCheckAST(binaryExpression, context)) { + this.typeCheckBinaryArithmeticExpression(binaryExpression, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } + + if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } + + var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); + var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); + + if (!rhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!lhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (lhsIsFit && rhsIsFit) { + switch (binaryExpression.kind()) { + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + if (!this.isReference(binaryExpression.left, lhsSymbol)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); + } + } + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInstanceOfExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); + var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); + 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_of_a_type_assignable_to_the_Function_interface_type)); + } + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { + if (this.canTypeCheckAST(commaExpression, context)) { + this.setTypeChecked(commaExpression, context); + + this.resolveAST(commaExpression.left, false, context); + } + + return this.resolveAST(commaExpression.right, false, context).type; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; + + var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); + + if (!isValidLHS) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); + } + + if (!isValidRHS) { + 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)); + } + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.variableDeclaration, false, context); + this.resolveAST(ast.initializer, false, context); + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.incrementor, false, context); + this.resolveAST(ast.statement, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { + if (this.canTypeCheckAST(forInStatement, context)) { + this.typeCheckForInStatement(forInStatement, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { + this.setTypeChecked(forInStatement, context); + + if (forInStatement.variableDeclaration) { + var declaration = forInStatement.variableDeclaration; + + 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); + + 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 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)); + } + + this.resolveAST(forInStatement.statement, false, context); + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWhileStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckDoStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckIfStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + this.resolveAST(ast.elseClause, false, context); + }; + + PullTypeResolver.prototype.resolveElseClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckElseClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.statements, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declaration, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declarators, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWithStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var withStatement = ast; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckTryStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var tryStatement = ast; + + this.resolveAST(tryStatement.block, false, context); + this.resolveAST(tryStatement.catchClause, false, context); + this.resolveAST(tryStatement.finallyClause, false, context); + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckCatchClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + + var catchDecl = this.semanticInfoChain.getDeclForAST(ast); + this.validateVariableDeclarationGroups(catchDecl, context); + }; + + PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckFinallyClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + }; + + PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + while (enclosingDecl) { + if (enclosingDecl.kind & 1032192 /* SomeFunction */) { + return enclosingDecl; + } + + enclosingDecl = enclosingDecl.getParentDecl(); + } + + return null; + }; + + PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var isContextuallyTyped = false; + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); + if (returnTypeAnnotationSymbol) { + isContextuallyTyped = true; + context.pushNewContextualType(returnTypeAnnotationSymbol); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + isContextuallyTyped = true; + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); + } + } + } + } + + var result = this.resolveAST(expression, isContextuallyTyped, context).type; + if (isContextuallyTyped) { + context.popAnyContextualType(); + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { + if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingFunction.getParentDecl(); + if (classDecl) { + var classSymbol = classDecl.getSymbol(); + this.resolveDeclaredSymbol(classSymbol, context); + + var comparisonInfo = new TypeComparisonInfo(); + var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); + if (!isAssignable) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); + } + } + } + + if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); + } + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { + var signatureSymbol = enclosingFunction.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (expressionType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + this.resolveDeclaredSymbol(expressionType, context); + this.resolveDeclaredSymbol(sigReturnType, context); + + var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); + } + } + } + } + } + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { + var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var returnType = this.getSymbolForAST(returnAST, context); + var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); + if (!returnType || canTypeCheckAST) { + var returnExpr = returnAST.expression; + + var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); + + if (!returnType) { + returnType = resolvedReturnType; + this.setSymbolForAST(returnAST, resolvedReturnType, context); + } + + if (returnExpr && canTypeCheckAST) { + this.setTypeChecked(returnExpr, context); + this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSwitchStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var expressionType = this.resolveAST(ast.expression, false, context).type; + + for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { + var switchClause = ast.switchClauses.childAt(i); + if (switchClause.kind() === 233 /* CaseSwitchClause */) { + var caseSwitchClause = switchClause; + + var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; + this.resolveAST(caseSwitchClause.statements, false, context); + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); + } + } + } else { + var defaultSwitchClause = switchClause; + this.resolveAST(defaultSwitchClause.statements, false, context); + } + } + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLabeledStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var labelIdentifier = ast.identifier.valueText(); + + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + 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); + }; + + PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { + switch (statement.kind()) { + case 160 /* LabeledStatement */: + return this.labelIsOnContinuableConstruct(statement.statement); + + case 158 /* WhileStatement */: + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 161 /* DoStatement */: + return true; + + default: + return false; + } + }; + + PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckContinueStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.isIterationStatement = function (ast) { + switch (ast.kind()) { + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 158 /* WhileStatement */: + case 161 /* DoStatement */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { + switch (ast.kind()) { + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 129 /* FunctionDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 241 /* FunctionPropertyAssignment */: + case 137 /* ConstructorDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.inSwitchStatement = function (ast) { + while (ast) { + if (ast.kind() === 151 /* SwitchStatement */) { + return true; + } + + if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { + while (ast) { + if (this.isIterationStatement(ast)) { + return true; + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { + var result = []; + + ast = ast.parent; + while (ast) { + if (ast.kind() === 160 /* LabeledStatement */) { + var labeledStatement = ast; + if (breakable) { + result.push(labeledStatement); + } else { + if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { + result.push(labeledStatement); + } + } + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + break; + } + + ast = ast.parent; + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + 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.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var continuableLabels = this.getEnclosingLabels(ast, false, true); + + 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)); + } + } + } + }; + + PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckBreakStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + if (ast.identifier) { + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var breakableLabels = this.getEnclosingLabels(ast, true, true); + 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, 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)); + } + } + }; + + PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { + if (!ast) { + return; + } + + var symbol = this.getSymbolForAST(ast, context); + if (symbol && symbol.isResolved) { + this.typeCheckAST(ast, isContextuallyTyped, context); + return symbol; + } + + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + + var nodeType = ast.kind(); + + switch (nodeType) { + case 124 /* ArrayType */: + case 126 /* GenericType */: + case 122 /* ObjectType */: + case 127 /* TypeQuery */: + case 125 /* ConstructorType */: + case 123 /* FunctionType */: + return this.resolveTypeReference(ast, context); + + case 1 /* List */: + return this.resolveList(ast, context); + + case 2 /* SeparatedList */: + return this.resolveSeparatedList(ast, context); + + case 120 /* SourceUnit */: + return this.resolveSourceUnit(ast, context); + + case 132 /* EnumDeclaration */: + return this.resolveEnumDeclaration(ast, context); + + case 130 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 128 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 131 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 224 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, context); + + case 136 /* MemberVariableDeclaration */: + return this.resolveMemberVariableDeclaration(ast, context); + + case 225 /* VariableDeclarator */: + return this.resolveVariableDeclarator(ast, context); + + case 141 /* PropertySignature */: + return this.resolvePropertySignature(ast, context); + + case 227 /* ParameterList */: + return this.resolveParameterList(ast, context); + + case 242 /* Parameter */: + return this.resolveParameter(ast, context); + + case 243 /* EnumElement */: + return this.resolveEnumElement(ast, context); + + case 232 /* EqualsValueClause */: + return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); + + case 238 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 239 /* Constraint */: + return this.resolveConstraint(ast, context); + + case 133 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 240 /* SimplePropertyAssignment */: + return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); + + case 241 /* FunctionPropertyAssignment */: + return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); + + case 121 /* QualifiedName */: + return this.resolveQualifiedName(ast, context); + + case 137 /* ConstructorDeclaration */: + return this.resolveConstructorDeclaration(ast, context); + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return this.resolveAccessorDeclaration(ast, context); + + case 138 /* IndexMemberDeclaration */: + return this.resolveIndexMemberDeclaration(ast, context); + + case 144 /* IndexSignature */: + return this.resolveIndexSignature(ast, context); + + case 135 /* MemberFunctionDeclaration */: + return this.resolveMemberFunctionDeclaration(ast, context); + + case 142 /* CallSignature */: + return this.resolveCallSignature(ast, context); + + case 143 /* ConstructSignature */: + return this.resolveConstructSignature(ast, context); + + case 145 /* MethodSignature */: + return this.resolveMethodSignature(ast, context); + + 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); + + case 219 /* SimpleArrowFunctionExpression */: + return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 214 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + + case 35 /* ThisKeyword */: + return this.resolveThisExpression(ast, context); + + case 50 /* SuperKeyword */: + return this.resolveSuperExpression(ast, context); + + case 213 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, context); + + case 216 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, context); + + case 220 /* CastExpression */: + return this.resolveCastExpression(ast, context); + + case 13 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + + case 14 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + + case 32 /* NullKeyword */: + return this.semanticInfoChain.nullTypeSymbol; + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + + case 172 /* VoidExpression */: + return this.resolveVoidExpression(ast, context); + + case 174 /* AssignmentExpression */: + return this.resolveAssignmentExpression(ast, context); + + case 167 /* LogicalNotExpression */: + return this.resolveLogicalNotExpression(ast, context); + + case 193 /* NotEqualsWithTypeConversionExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 197 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, context); + + case 208 /* AddExpression */: + case 175 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, context); + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, context); + + case 210 /* PostIncrementExpression */: + case 211 /* PostDecrementExpression */: + return this.resolvePostfixUnaryExpression(ast, context); + + case 209 /* SubtractExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 189 /* BitwiseOrExpression */: + case 191 /* BitwiseAndExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, context); + + case 221 /* ElementAccessExpression */: + return this.resolveElementAccessExpression(ast, context); + + case 187 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); + + case 188 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, context); + + case 171 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, context); + + case 170 /* DeleteExpression */: + return this.resolveDeleteExpression(ast, context); + + case 186 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, isContextuallyTyped, context); + + case 12 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 217 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, context); + + case 200 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, context); + + case 173 /* CommaExpression */: + return this.resolveCommaExpression(ast, context); + + case 201 /* InExpression */: + return this.resolveInExpression(ast, context); + + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; + } + + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); + }; + + PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { + if (!this.canTypeCheckAST(ast, context)) { + return; + } + + var nodeType = ast.kind(); + switch (nodeType) { + case 120 /* SourceUnit */: + this.typeCheckSourceUnit(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.typeCheckEnumDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.typeCheckModuleDeclaration(ast, context); + return; + + case 128 /* InterfaceDeclaration */: + this.typeCheckInterfaceDeclaration(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.typeCheckClassDeclaration(ast, context); + return; + + case 243 /* EnumElement */: + this.typeCheckEnumElement(ast, context); + return; + + case 136 /* MemberVariableDeclaration */: + this.typeCheckMemberVariableDeclaration(ast, context); + return; + + case 225 /* VariableDeclarator */: + this.typeCheckVariableDeclarator(ast, context); + return; + + case 141 /* PropertySignature */: + this.typeCheckPropertySignature(ast, context); + return; + + case 242 /* Parameter */: + this.typeCheckParameter(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.typeCheckImportDeclaration(ast, context); + return; + + case 215 /* ObjectLiteralExpression */: + this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 241 /* FunctionPropertyAssignment */: + this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); + return; + + case 11 /* IdentifierName */: + if (isTypesOnlyLocation(ast)) { + this.resolveTypeNameExpression(ast, context); + } else { + this.resolveNameExpression(ast, context); + } + return; + + case 212 /* MemberAccessExpression */: + this.resolveMemberAccessExpression(ast, context); + return; + + case 121 /* QualifiedName */: + this.resolveQualifiedName(ast, context); + return; + + case 222 /* FunctionExpression */: + 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); + break; + + case 142 /* CallSignature */: + this.typeCheckCallSignature(ast, context); + return; + + case 143 /* ConstructSignature */: + this.typeCheckConstructSignature(ast, context); + return; + + case 129 /* FunctionDeclaration */: { + var funcDecl = ast; + 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, isContextuallyTyped, context); + return; + + case 218 /* ParenthesizedArrowFunctionExpression */: + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 214 /* ArrayLiteralExpression */: + this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 213 /* InvocationExpression */: + this.typeCheckInvocationExpression(ast, context); + return; + + case 216 /* ObjectCreationExpression */: + this.typeCheckObjectCreationExpression(ast, context); + return; + + case 150 /* ReturnStatement */: + this.resolveReturnStatement(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); + } + }; + + PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { + while (this.postTypeCheckWorkitems.length) { + var ast = this.postTypeCheckWorkitems.pop(); + this.postTypeCheck(ast, context); + } + }; + + PullTypeResolver.prototype.postTypeCheck = function (ast, context) { + var nodeType = ast.kind(); + + switch (nodeType) { + case 242 /* Parameter */: + case 225 /* VariableDeclarator */: + this.postTypeCheckVariableDeclaratorOrParameter(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.postTypeCheckClassDeclaration(ast, context); + return; + + case 129 /* FunctionDeclaration */: + this.postTypeCheckFunctionDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.postTypeCheckModuleDeclaration(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.postTypeCheckEnumDeclaration(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.postTypeCheckImportDeclaration(ast, context); + return; + + case 11 /* IdentifierName */: + this.postTypeCheckNameExpression(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); + } + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { + this.checkThisCaptureVariableCollides(nameAST, false, context); + }; + + PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { + this.setTypeChecked(nameAST, context); + this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { + var nameSymbol = this.getSymbolForAST(nameAST, context); + var foundCached = nameSymbol !== null; + + if (!foundCached || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.typeCheckNameExpression(nameAST, context); + } + nameSymbol = this.computeNameExpression(nameAST, context); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + 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.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; + } + + var nameSymbol = null; + var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); + } + + 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) { + 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]; + var nameParentDecl = nameDeclaration.getParentDecl(); + if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { + var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); + var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); + + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); + + if (currentParameterIndex >= 0) { + var matchingParameter; + if (parameterList) { + for (var i = 0; i <= currentParameterIndex; i++) { + var candidateParameter = parameterList.parameters.nonSeparatorAt(i); + if (candidateParameter && candidateParameter.identifier.valueText() === id) { + matchingParameter = candidateParameter; + break; + } + } + } + + 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); + } + } + } + + var aliasSymbol = null; + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + if (!this.inTypeQuery(nameAST)) { + aliasSymbol.setIsUsedAsValue(); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); + + var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); + if (parameterList) { + while (parameter && parameter.parent) { + if (parameter.parent.parent === parameterList) { + return parameterList.parameters.nonSeparatorIndexOf(parameter); + } + + parameter = parameter.parent; + } + } + + return -1; + }; + + PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { + var symbol = this.getSymbolForAST(dottedNameAST, context); + var foundCached = symbol !== null; + + if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheckDottedNameAST) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); + } + + this.resolveDeclaredSymbol(symbol, context); + + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(name, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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)) { + lhsAlias.setIsUsedAsValue(); + } + lhsType = lhsAlias.getExportAssignedTypeSymbol(); + } + + if (lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); + return this.getNewErrorTypeSymbol(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); + + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { + var instanceSymbol = lhsType.getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); + + if (!nameSymbol) { + if (lhsType.kind === 32 /* DynamicModule */) { + var container = lhsType; + var associatedInstance = container.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); + } + } + + 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + } + + if (checkSuperPrivateAndStaticAccess) { + this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST, context); + + if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.setTypeChecked(nameAST, context); + } + typeNameSymbol = this.computeTypeNameExpression(nameAST, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + this.resolveDeclaredSymbol(typeNameSymbol, context); + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { + var id = nameAST.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(nameAST); + + var declPath = enclosingDecl.getParentPath(); + + var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); + + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + this.resolveDeclaredSymbol(typeNameSymbol, context); + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + this.resolveDeclaredSymbol(aliasedType, context); + } + + if (typeNameSymbol.isTypeParameter()) { + if (this.isInStaticMemberContext(enclosingDecl)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); + return this.getNewErrorTypeSymbol(); + } + } + } + + if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { + typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); + } + + 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; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, context); + } + + 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()) { + for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + + if (typeArgs[i].isError()) { + typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + } + + 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(); + } + + if (!genericTypeSymbol.isResolved) { + var typeDecls = genericTypeSymbol.getDeclarations(); + var childDecls = null; + + for (var i = 0; i < typeDecls.length; i++) { + childDecls = typeDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + + var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); + + var typeConstraint = null; + var upperBound = null; + + typeParameters = specializedSymbol.getTypeParameters(); + + var typeConstraintSubstitutionMap = []; + var typeArg = null; + + var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < typeParameters.length; i++) { + typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + for (var id in instantiatedSubstitutionMap) { + typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; + } + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] === typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } else if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); + } + + if (typeArg.isTypeParameter()) { + upperBound = typeArg.getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + 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)])); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { + if (this.inTypeQuery(dottedNameAST)) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; + } + + var symbol = this.getSymbolForAST(dottedNameAST, context); + if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheck) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeQualifiedName(dottedNameAST, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + this.resolveDeclaredSymbol(symbol, context); + + 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) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); + var lhs = this.resolveAST(dottedNameAST.left, false, context); + + var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; + + if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { + if (lhs.isAlias()) { + lhs.setIsUsedAsValue(); + } + } + + if (!lhsType) { + return this.getNewErrorTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); + var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; + + 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & 164 /* SomeContainer */) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { + if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { + return false; + } + + if (returnTypeAnnotation) { + return false; + } + + if (parameters) { + for (var i = 0, n = parameters.length; i < n; i++) { + if (parameters.typeAt(i)) { + return false; + } + } + } + + var contextualFunctionTypeSymbol = context.getContextualType(); + + if (contextualFunctionTypeSymbol) { + this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); + var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; + if (!exactlyOneCallSignature) { + return false; + } + + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; + return !callSignatureIsGeneric; + } + + return false; + }; + + PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { + var funcDeclSymbol = null; + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { + return funcDeclSymbol; + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + TypeScript.Debug.assert(funcDeclSymbol); + + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.propagateContextualType(returnType); + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); + context.popAnyContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + var functionExpressionName = functionDecl.getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); + } + } + + context.setTypeInContext(funcDeclSymbol, funcDeclType); + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); + } + + return funcDeclSymbol; + }; + + 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + var returnTypeSymbol = signature.returnType; + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + 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.popAnyContextualType(); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); + + this.validateVariableDeclarationGroups(functionDecl, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { + var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); + var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; + + if (this.canTypeCheckAST(thisExpression, context)) { + this.typeCheckThisExpression(thisExpression, context, enclosingDecl); + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.inTypeArgumentList = function (ast) { + var previous = null; + var current = ast; + + while (current) { + switch (current.kind()) { + case 126 /* GenericType */: + var genericType = current; + if (genericType.typeArgumentList === previous) { + return true; + } + break; + + case 226 /* ArgumentList */: + var argumentList = current; + return argumentList.typeArgumentList === previous; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { + while (ast) { + switch (ast.kind()) { + case 230 /* ExtendsHeritageClause */: + var heritageClause = ast; + + return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inTypeQuery = function (ast) { + while (ast) { + switch (ast.kind()) { + case 127 /* TypeQuery */: + return true; + case 129 /* FunctionDeclaration */: + case 213 /* InvocationExpression */: + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 213 /* InvocationExpression */: + var invocationExpression = current; + if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + break; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inConstructorParameterList = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } + + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + 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 */) { + return true; + } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { + this.checkForThisCaptureInArrowFunction(thisExpression); + + if (this.inConstructorParameterList(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); + return; + } + + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { + return; + } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + if (currentDecl.getParentDecl() === null) { + return; + } else { + 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)); + } + + return; + } else if (currentDecl.kind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); + } + + return; + } + } + }; + + PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var isStaticContext = false; + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + return null; + } else if (declKind === 16384 /* Function */) { + return null; + } else if (declKind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(ast)) { + return this.getNewErrorTypeSymbol(); + } else { + var classSymbol = decl.getSymbol(); + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + return constructorSymbol.type; + } else { + return classSymbol; + } + } + } + } + } + + return null; + }; + + PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { + return true; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + var superType = this.semanticInfoChain.anyTypeSymbol; + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); + + if (classSymbol) { + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSuperExpression(ast, context, enclosingDecl); + } + + return superType; + }; + + PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { + this.setTypeChecked(ast, context); + + this.checkForThisCaptureInArrowFunction(ast); + + var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; + var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; + TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); + + if (isSuperPropertyAccess) { + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + break; + } else if (currentDecl.kind === 8 /* Class */) { + if (!this.enclosingClassIsDerived(currentDecl)) { + 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 if (this.inStaticMemberVariableDeclaration(ast)) { + break; + } + + 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 { + 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)); + } + } + }; + + PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { + return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (this.canTypeCheckAST(expressionAST, context)) { + this.setTypeChecked(expressionAST, context); + } + symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { + var boundMemberSymbols = []; + var memberSymbol; + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var id = this.getPropertyAssignmentName(propertyAssignment); + var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); + + var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; + var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); + TypeScript.Debug.assert(decl); + + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + if (!isUsingExistingSymbol) { + memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } else { + memberSymbol = decl.getSymbol(); + } + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + memberSymbol = decl.getSymbol(); + } else { + TypeScript.Debug.assert(isAccessor); + memberSymbol = decl.getSymbol(); + } + + if (!isUsingExistingSymbol && !isAccessor) { + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); + } + + objectLiteralTypeSymbol.addMember(memberSymbol); + } + + boundMemberSymbols.push(memberSymbol); + } + + return boundMemberSymbols; + }; + + PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var acceptedContextualType = false; + var assigningSymbol = null; + + var id = this.getPropertyAssignmentName(propertyAssignment); + var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; + + if (objectLiteralContextualType) { + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + + if (!assigningSymbol) { + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + assigningSymbol = numericIndexerSignature; + } else if (stringIndexerSignature) { + assigningSymbol = stringIndexerSignature; + } + } + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); + + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = contextualMemberType; + } + } + } + + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; + + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { + objectLiteralTypeSymbol.setHasGenericMember(); + } + + if (stringIndexerSignature) { + allMemberTypes.push(memberSymbolType); + } + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + allNumericMemberTypes.push(memberSymbolType); + } + } + + if (acceptedContextualType) { + pullTypeContext.popAnyContextualType(); + } + + var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; + if (!memberSymbol.isResolved) { + if (isAccessor) { + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); + } else { + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); + memberSymbol.setResolved(); + + this.setSymbolForAST(id, memberSymbol, pullTypeContext); + } + } + } + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { + var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); + TypeScript.Debug.assert(objectLitDecl); + + var typeSymbol = this.getSymbolForAST(objectLitAST, context); + var isUsingExistingSymbol = !!typeSymbol; + + if (!typeSymbol) { + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); + typeSymbol.addDeclaration(objectLitDecl); + this.setSymbolForAST(objectLitAST, typeSymbol, context); + objectLitDecl.setSymbol(typeSymbol); + } + + var propertyAssignments = objectLitAST.propertyAssignments; + var contextualType = null; + + if (isContextuallyTyped) { + contextualType = context.getContextualType(); + this.resolveDeclaredSymbol(contextualType, context); + } + + var stringIndexerSignature = null; + var numericIndexerSignature = null; + var allMemberTypes = null; + var allNumericMemberTypes = null; + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + + stringIndexerSignature = indexSignatures.stringSignature; + numericIndexerSignature = indexSignatures.numericSignature; + + var inInferentialTyping = context.isInferentiallyTyping(); + if (stringIndexerSignature) { + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; + } + + if (numericIndexerSignature) { + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; + } + } + + if (propertyAssignments) { + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); + + this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); + + if (!isUsingExistingSymbol) { + this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); + this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { + return propertyAssignment.propertyName; + } else { + TypeScript.Debug.assert(false); + } + }; + + PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { + if (contextualIndexSignature) { + var typeCollection = { + getLength: function () { + return indexerTypeCandidates.length; + }, + getTypeAtIndex: function (index) { + return indexerTypeCandidates[index]; + } + }; + var decl = objectLiteralSymbol.getDeclarations()[0]; + 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); + } + } + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { + var symbol = this.getSymbolForAST(arrayLit, context); + if (!symbol || this.canTypeCheckAST(arrayLit, context)) { + if (this.canTypeCheckAST(arrayLit, context)) { + this.setTypeChecked(arrayLit, context); + } + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { + var elements = arrayLit.expressions; + var elementType = null; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, context); + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + if (indexSignatures.numericSignature) { + contextualElementType = indexSignatures.numericSignature.returnType; + } + } + } + + if (elements) { + if (contextualElementType) { + context.propagateContextualType(contextualElementType); + } + + for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { + elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); + } + + if (contextualElementType) { + context.popAnyContextualType(); + } + } + + if (elementTypes.length) { + elementType = elementTypes[0]; + } + var collection; + + if (contextualElementType && !context.isInferentiallyTyping()) { + if (!elementType) { + elementType = contextualElementType; + } + + collection = { + getLength: function () { + return elements.nonSeparatorCount() + 1; + }, + getTypeAtIndex: function (index) { + return index === 0 ? contextualElementType : elementTypes[index - 1]; + } + }; + } else { + collection = { + getLength: function () { + return elements.nonSeparatorCount(); + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + } + + elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; + + if (!elementType) { + elementType = this.semanticInfoChain.undefinedTypeSymbol; + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { + var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); + + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); + } + + return symbolAndDiagnostic.symbol; + }; + + PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { + this.setTypeChecked(callEx, context); + context.postDiagnostic(symbolAndDiagnostic.diagnostic); + }; + + PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; + + var targetTypeSymbol = targetSymbol.type; + + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return { symbol: targetTypeSymbol }; + } + + var elementType = targetTypeSymbol.getElementType(); + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return { symbol: elementType }; + } + + 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); + + if (member) { + this.resolveDeclaredSymbol(member, context); + + return { symbol: member.type }; + } + } + + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); + + var stringSignature = signatures.stringSignature; + var numberSignature = signatures.numericSignature; + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; + } 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 { + symbol: this.getNewErrorTypeSymbol(), + diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) + }; + } + }; + + 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; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + if (!signature.isResolved) { + this.resolveDeclaredSymbol(signature, context); + } + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signature; + continue; + } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { + numberSignature = signature; + continue; + } + } + } + + return { + numericSignature: numberSignature, + stringSignature: stringSignature + }; + }; + + 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; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } + + 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 { + lhsType = rhsType; + } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (exprType) { + if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { + if (!this.isReference(binaryExpression.left, lhsExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, exprType, lhsType, context); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); + } + } + + if (!exprType) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { + return this.findBestCommonType({ + getLength: function () { + return 2; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + } + } + }, context); + }; + + PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { + return this.findBestCommonType({ + getLength: function () { + return 3; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + case 2: + return type3; + } + } + }, context); + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + } + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; + var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; + + 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.pushNewContextualType(leftType); + var rightType = this.resolveAST(binex.right, true, context).type; + context.popAnyContextualType(); + + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + + this.resolveAST(binex.left, false, context); + } + + return this.resolveAST(binex.right, false, context).type; + }; + + PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { + var contextualType = context.getContextualType(); + return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + } else { + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { + var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; + var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; + + var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); + + var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); + + if (this.canTypeCheckAST(trinex, context)) { + this.setTypeChecked(trinex, context); + this.resolveAST(trinex.condition, false, context); + + if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); + } + } + } + + if (!conditionalTypesAreValid) { + return this.getNewErrorTypeSymbol(); + } + + return expressionType; + }; + + PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { + return true; + } + } else { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveAST(ast.expression, false, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckInvocationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + var targetSymbol = this.resolveAST(callEx.expression, false, context); + + if (callEx.argumentList.arguments) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + + var len = callEx.argumentList.arguments.nonSeparatorCount(); + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); + return this.getNewErrorTypeSymbol(); + } + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.expression.kind() === 50 /* SuperKeyword */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + targetSymbol = targetTypeSymbol.getConstructorMethod(); + this.resolveDeclaredSymbol(targetSymbol, context); + targetTypeSymbol = targetSymbol.type; + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); + this.resolveAST(callEx.argumentList.arguments, false, context); + + return this.getNewErrorTypeSymbol(); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + 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 explicitTypeArgs = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + var triedToInferTypeArgs = false; + + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var beforeResolutionSignatures = signatures; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + + if (signatures[i].isGeneric() && typeParameters.length) { + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); + } + + 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, 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; + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + + var errorCondition = null; + if (!signatures.length) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (!couldNotFindGenericOverload) { + 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); + } + return this.semanticInfoChain.anyTypeSymbol; + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); + } else if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + } + + 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 (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; + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + this.setSymbolForAST(callEx, symbol, context); + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckObjectCreationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + this.resolveAST(callEx.expression, false, context); + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (callEx.argumentList) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + var len = callEx.argumentList.arguments.nonSeparatorCount(); + + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { + if (!context.inProvisionalResolution()) { + additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); + } + context.postDiagnostic(diagnostic); + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var explicitTypeArgs = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny()) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); + } + } + + if (constructSignatures.length) { + if (callEx.argumentList && callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var triedToInferTypeArgs; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric()) { + typeParameters = constructSignatures[i].getTypeParameters(); + + 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, explicitTypeArgs.length]); + continue; + } + } 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 { + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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(constructSignatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } else { + if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); + } else { + returnType = this.instantiateTypeToAny(returnType, context); + } + } + + if (usedCallSignaturesInstead) { + 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(); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList && callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); + + return this.getNewErrorTypeSymbol(); + }; + + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { + var typeReplacementMap = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters = signatureAToInstantiate.getTypeParameters(); + var typeConstraint = null; + + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; + var enclosingTypeParameterMap; + + if (functionTypeA) { + enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + if (functionTypeB) { + enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); + + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); + }; + + PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { + var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; + + if (this.canTypeCheckAST(assertionExpression, context)) { + this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); + } + + return typeAssertionType; + }; + + PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { + this.setTypeChecked(assertionExpression, context); + + context.pushNewContextualType(typeAssertionType); + var exprType = this.resolveAST(assertionExpression.expression, true, context).type; + context.popAnyContextualType(); + + this.resolveDeclaredSymbol(typeAssertionType, context); + this.resolveDeclaredSymbol(exprType, context); + + var comparisonInfo = new TypeComparisonInfo(); + + 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); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { + var leftExpr = this.resolveAST(binaryExpression.left, false, context); + var leftType = leftExpr.type; + + context.pushNewContextualType(leftType); + var rightType = this.resolveAST(binaryExpression.right, true, context).type; + context.popAnyContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (!this.isReference(binaryExpression.left, leftExpr)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } else { + this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); + } + } + + return rightType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { + var instanceTypeSymbol = typeToReturn.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.widenType = function (type, ast, context) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (type.isArrayNamedTypeReference()) { + 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(); + + for (var i = 0; i < len; i++) { + var candidateType = collection.getTypeAtIndex(i); + if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { + return candidateType; + } + } + + return this.semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { + for (var i = 0; i < collection.getLength(); i++) { + var otherType = collection.getTypeAtIndex(i); + if (candidateType === otherType) { + continue; + } + + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { + t1 = this.getSymbolForRelationshipCheck(t1); + t2 = this.getSymbolForRelationshipCheck(t2); + + if (t1 === t2) { + return true; + } + + if (t1 && t2) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); + } + } + + return this.typesAreIdentical(t1, t2, context); + }; + + 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); + + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; + } + + if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + 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(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return false; + } + } + + if (t1.isPrimitive() !== t2.isPrimitive()) { + return 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) { + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { + return false; + } + + return true; + }; + + 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; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length !== sg2.length) { + return false; + } + + 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; + } + } + + return true; + }; + + 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; + } + + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; + } + + 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) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0] === decls2[0]; + } + + return false; + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { + return true; + } + + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); + }; + + 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.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) { + if (symbol && symbol.isTypeReference()) { + return symbol.getReferencedTypeSymbol(); + } + + return symbol; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + source = this.getSymbolForRelationshipCheck(source); + target = this.getSymbolForRelationshipCheck(target); + + if (source === target) { + return true; + } + + if (source && target) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + } + } + + 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); + + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + var sourceApparentType = this.getApparentType(source); + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; + } + + if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + 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) { + return true; + } + + return false; + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return assignableTo; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.getIsSpecialized() && target.getIsSpecialized()) { + 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, true); + + for (var i = 0; i < sourceTypeArguments.length; i++) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { + break; + } + } + + if (i === sourceTypeArguments.length) { + return true; + } else { + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + } + } + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } + } else { + if (isComparingInstantiatedSignatures) { + target = target.getBaseConstraint(this.semanticInfoChain); + } else { + return this.typesAreIdentical(target, sourceApparentType, context); + } + } + } + + 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; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); + + this.resolveDeclaredSymbol(targetProp, context); + + var targetPropType = targetProp.type; + + 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); + + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + + 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var comparisonInfoTypeArgumentsCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); + } + 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_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_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, isRelatable); + return isRelatable; + }; + + 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)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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++) { + 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; + } + } + } + + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + }; + + 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 (comparisonInfo) { + var names = getNames(true); + var code; + if (targetPropIsPrivate) { + 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 { + 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; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (targetDecl !== sourceDecl) { + if (comparisonInfo) { + var names = getNames(true); + + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + 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; + } + } + + if (sourceProp.isOptional && !targetProp.isOptional) { + if (comparisonInfo) { + 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); + } + return false; + } + + this.resolveDeclaredSymbol(sourceProp, context); + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); + + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + var names = getNames(false); + if (comparisonInfoPropertyTypeCheck && 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 { + 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 isSourcePropertyRelatableToTargetProperty; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); + var targetStringSig = targetIndexSigs.stringSignature; + var targetNumberSig = targetIndexSigs.numericSignature; + + if (targetStringSig || targetNumberSig) { + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); + var sourceStringSig = sourceIndexSigs.stringSignature; + var sourceNumberSig = sourceIndexSigs.numericSignature; + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + 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++) { + var mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + var nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + 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; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + + return false; + } + + return true; + }; + + 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; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; + + 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, [targetParameters.length])); + } + return false; + } + + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; + } + + 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) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + + return false; + } + } + + 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 (!areParametersRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + } + + return areParametersRelatable; + }); + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { + var _this = this; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = application.argumentList ? application.argumentList.arguments : null; + + var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { + if (hasOverloads && signature.isDefinition()) { + return false; + } + + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { + return false; + } + + return _this.overloadHasCorrectArity(signature, args); + }); + + var firstAssignableButNotSupertypeSignature = null; + var firstAssignableWithProvisionalErrorsSignature = null; + + for (var i = 0; i < initialCandidates.length; i++) { + var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); + if (applicability === 3 /* Subtype */) { + return initialCandidates[i]; + } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { + firstAssignableButNotSupertypeSignature = initialCandidates[i]; + } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { + firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; + } + } + + if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { + return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; + } else { + var target = this.getCallTargetErrorSpanAST(application); + if (comparisonInfo.message) { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); + } else { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); + } + } + + return null; + }; + + PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { + return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; + }; + + PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { + if (args == null) { + return signature.nonOptionalParamCount === 0; + } + + var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); + if (numberOfArgs < signature.nonOptionalParamCount) { + return false; + } + if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { + if (args === null) { + return 3 /* Subtype */; + } + + var isInVarArg = false; + var parameters = signature.parameters; + var paramType = null; + + var overloadApplicability = 3 /* Subtype */; + + for (var i = 0; i < args.nonSeparatorCount(); i++) { + if (!isInVarArg) { + this.resolveDeclaredSymbol(parameters[i], context); + + if (parameters[i].isVarArg) { + paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); + isInVarArg = true; + } else { + paramType = parameters[i].type; + } + } + + var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); + + if (statusOfCurrentArgument === 0 /* NotAssignable */) { + return 0 /* NotAssignable */; + } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { + overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; + } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { + overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; + } + } + + return overloadApplicability; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType.isAny()) { + return 3 /* Subtype */; + } else if (paramType.isError()) { + return 1 /* AssignableButWithProvisionalErrors */; + } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrowFunction = arg; + 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.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.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 */) { + return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); + } else { + return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); + } + }; + + PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { + if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + 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.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveObjectLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType === this.cachedArrayInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveArrayLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + var argSym = this.resolveAST(arg, false, context); + + if (argSym.type.isAlias()) { + var aliasSym = argSym.type; + argSym = aliasSym.getExportAssignedTypeSymbol(); + } + + comparisonInfo.stringConstantVal = arg; + return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { + var tempComparisonInfo = new TypeComparisonInfo(); + tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; + if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { + return 3 /* Subtype */; + } + + if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { + return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; + } + + if (!comparisonInfo.message) { + var enclosingSymbol = this.getEnclosingSymbolForAST(arg); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); + } + + return 0 /* NotAssignable */; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); + + 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 (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 inferenceResultTypes; + }; + + PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { + var enclosingDecl = this.getEnclosingDeclForAST(args); + var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); + return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; + }; + + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { + if (expressionType && parameterType) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); + return; + } + } + this.relateTypeToTypeParameters(expressionType, parameterType, 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; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType.isTypeParameter()) { + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); + return; + } + + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { + return; + } + + 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.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) { + return; + } + + var expressionTypeTypeArguments = expressionType.getTypeArguments(); + var parameterTypeArguments = parameterType.getTypeArguments(); + + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { + for (var i = 0; i < expressionTypeTypeArguments.length; i++) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } + } + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { + var _this = this; + var expressionReturnType = expressionSignature.returnType; + var parameterReturnType = parameterSignature.returnType; + + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); + + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + if (objectMember) { + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); + } + } + + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); + + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; + } + + 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) { + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!typeParameters.length) { + return typeToSpecialize; + } + + var typeArguments = null; + + 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) { + typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var type = this.createInstantiatedType(typeToSpecialize, typeArguments); + + 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(); + + var resolver = semanticInfoChain.getResolver(); + var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); + + if (resolver.canTypeCheckAST(sourceUnit, context)) { + resolver.resolveAST(sourceUnit, false, context); + resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); + + while (resolver.typeCheckCallBacks.length) { + var callBack = resolver.typeCheckCallBacks.pop(); + callBack(context); + } + + resolver.processPostTypeCheckWorkItems(context); + } + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; + } + + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); + + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; + + 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) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + 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)); + } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); + } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + 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_assignable_to_any_non_specialized_signature)); + } + } + } else if (definitionSignature && definitionSignature !== signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { + var errorCode; + + 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; + } 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + var isNamedType = typeSymbol.isNamedTypeSymbol(); + + if (typeSymbol.isArrayNamedTypeReference()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); + return; + } + + if (!isNamedType) { + var typeOfSymbol = typeSymbol.getTypeOfSymbol(); + if (typeOfSymbol) { + this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); + return; + } + } + + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); + if (typars) { + for (var i = 0; i < typars.length; i++) { + this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); + } + } + + if (!isNamedType) { + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); + } + + typeSymbol.inSymbolPrivacyCheck = false; + + if (!isNamedType) { + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + 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]) { + 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(); + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } else if (symbol.kind === 128 /* TypeAlias */) { + var aliasSymbol = symbol; + symbolIsVisible = true; + aliasSymbol.setTypeUsedExternally(); + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); + } + }; + + 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; + var messageCode; + + var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; + } + } + + var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { + var typeSymbol = symbol; + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { + var _this = this; + if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; + var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; + var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); + var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); + this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { + return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); + }); + } + } + + if (!isGetter && !isIndexSignature) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var parameter = parameters.astAt(argIndex); + + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { + var _this = this; + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); + } + } + + if (block) { + var reportErrorOnReturnExpressions = function (ast, walker) { + var go = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { + TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); + + var classSymbol = classDecl.getSymbol(); + return classSymbol.getExtendedTypes().length > 0; + }; + + PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { + if (ast.kind() === 213 /* InvocationExpression */) { + var invocationExpression = ast; + if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { + if (node && node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + if (this.isSuperInvocationExpression(expressionStatement.expression)) { + return true; + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { + if (block && block.statements && block.statements.childCount() > 0) { + return block.statements.childAt(0); + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { + TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); + + if (constructorDecl) { + var enclosingClass = constructorDecl.getParentDecl(); + + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.kind() === 242 /* Parameter */) { + return true; + } + + if (ast.kind() === 136 /* MemberVariableDeclaration */) { + var variableDeclarator = ast; + if (variableDeclarator.variableDeclarator.equalsValueClause) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { + var enclosingDecl = this.getEnclosingDeclForAST(expression); + + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var inArrowFunction = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + inArrowFunction = true; + continue; + } + + if (inArrowFunction) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = decl.getSymbol().getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); + var stringSignature = indexSignatures.stringSignature; + var numberSignature = indexSignatures.numericSignature; + + if (stringSignature || numberSignature) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { + var memberSymbol = member.getSymbol(); + var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); + if (relevantSignature) { + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); + } + } + } + } + } + }; + + PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { + if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { + return numberIndexSignature; + } else if (stringIndexSignature) { + return stringIndexSignature; + } + + return null; + }; + + PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { + 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + var foundError1 = false; + var foundError2 = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName, true); + if (extendedTypeProp) { + this.resolveDeclaredSymbol(extendedTypeProp, context); + foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError1) { + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + } + + if (foundError1 || foundError2) { + foundError = true; + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); + } + + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + } + } + } + + if (foundError) { + var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); + + 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; + } + + if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + + if (associatedContainerType) { + return associatedContainerType !== typeSymbol.getRootSymbol(); + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + + var baseType = this.resolveTypeReference(baseDeclAST, context).type; + + if (!baseType) { + return; + } + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (!baseType.isError()) { + if (isExtendedType) { + if (typeDeclIsClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); + } + } + return; + } else if (typeDeclIsClass && isExtendedType) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + 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)])); + } + } + + if (baseType.hasBase(typeSymbol)) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); + return; + } + + if (isExtendedType) { + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); + } else { + TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); + + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { + var _this = this; + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); + if (!extendsClause && !implementsClause) { + return; + } + + if (extendsClause) { + for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (implementsClause) { + for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); + } + } + } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { + var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { + return decl.ast().heritageClauses !== null; + }).ast(); + if (classOrInterface === firstInterfaceASTWithExtendsClause) { + this.typeCheckCallBacks.push(function (context) { + _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); + }); + } + } + }; + + PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { + var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); + + var inheritedMembersMap = TypeScript.createIntrinsicsObject(); + var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); + + var typeHasOwnNumberIndexer = false; + var typeHasOwnStringIndexer = false; + + if (typeSymbol.hasOwnIndexSignatures()) { + var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); + for (var i = 0; i < ownIndexSignatures.length; i++) { + if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + typeHasOwnNumberIndexer = true; + } else { + typeHasOwnStringIndexer = true; + } + } + } + var baseTypes = typeSymbol.getExtendedTypes(); + for (var i = 0; i < baseTypes.length; i++) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + return; + } + } + + if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { + return; + } + + this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; + var memberName = member.name; + + if (interfaceSymbol.findMember(memberName, false)) { + continue; + } + + this.resolveDeclaredSymbol(member, context); + + if (inheritedMembersMap[memberName]) { + var prevMember = inheritedMembersMap[memberName]; + 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; + } + } else { + inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); + } + } + + return false; + }; + + PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { + if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { + return false; + } + + var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { + var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; + + var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; + 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, 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; + } + } else { + allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } else if (parameterTypeIsNumber) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin) { + 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; + } + } else { + allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { + if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; + var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; + for (var memberName in inheritedMembers) { + var memberWithBaseOrigin = inheritedMembers[memberName]; + if (!memberWithBaseOrigin) { + continue; + } + + var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); + if (!relevantSignature) { + continue; + } + + var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; + + if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { + continue; + } + + 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_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_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])); + } + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + 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_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, [ + interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), + inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.isReference = function (ast, astSymbol) { + if (ast.kind() === 217 /* ParenthesizedExpression */) { + return this.isReference(ast.expression, astSymbol); + } + + if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { + return false; + } + + if (ast.kind() === 11 /* IdentifierName */) { + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { + return false; + } + + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { + return false; + } + + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { + return false; + } + } + + if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { + if (resolvedName) { + if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { + return this.semanticInfoChain.getEnclosingDecl(ast); + }; + + PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + return enclosingDecl ? enclosingDecl.getSymbol() : null; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { + if (resolvedName) { + if (resolvedName.anyDeclHasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var memberClass = memberContainer.getDeclarations()[0].ast(); + TypeScript.Debug.assert(memberClass); + + var containingClass = this.getEnclosingClassDeclaration(name); + + if (!containingClass || containingClass !== memberClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { + if (type.isPrimitive()) { + return type; + } + + if (type.isError()) { + return type; + } + + if (typeParameterArgumentMap[type.pullSymbolID]) { + return typeParameterArgumentMap[type.pullSymbolID]; + } + + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); + } + + if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + } + + return type; + }; + + 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 rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); + + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); + + 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) { + for (var j = 0; j < parameters.length; j++) { + parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + instantiatedSignature.hasVarArgs = true; + } + instantiatedSignature.addParameter(parameter, parameter.isOptional); + + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); + } + } + + return instantiatedSignature; + }; + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; + + function getPropertyAssignmentNameTextFromIdentifier(identifier) { + if (identifier.kind() === 11 /* IdentifierName */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 14 /* StringLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 13 /* NumericLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; + + function isTypesOnlyLocation(ast) { + while (ast && ast.parent) { + switch (ast.parent.kind()) { + case 244 /* TypeAnnotation */: + return true; + case 127 /* TypeQuery */: + return false; + case 125 /* ConstructorType */: + var constructorType = ast.parent; + if (constructorType.type === ast) { + return true; + } + break; + case 123 /* FunctionType */: + var functionType = ast.parent; + if (functionType.type === ast) { + return true; + } + break; + case 239 /* Constraint */: + var constraint = ast.parent; + if (constraint.type === ast) { + return true; + } + break; + case 220 /* CastExpression */: + var castExpression = ast.parent; + return castExpression.type === ast; + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + return true; + case 228 /* TypeArgumentList */: + return true; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + case 129 /* FunctionDeclaration */: + case 145 /* MethodSignature */: + case 212 /* MemberAccessExpression */: + case 242 /* Parameter */: + return false; + } + + ast = ast.parent; + } + + return false; + } + TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfoChain = (function () { + function SemanticInfoChain(compiler, logger) { + this.compiler = compiler; + this.logger = logger; + this.documents = []; + this.fileNameToDocument = TypeScript.createIntrinsicsObject(); + this.anyTypeDecl = null; + this.booleanTypeDecl = null; + this.numberTypeDecl = null; + this.stringTypeDecl = null; + this.nullTypeDecl = null; + this.undefinedTypeDecl = null; + this.voidTypeDecl = null; + this.undefinedValueDecl = null; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + this.undefinedValueSymbol = null; + this.emptyTypeSymbol = null; + this.astSymbolMap = []; + this.astAliasSymbolMap = []; + this.astCallResolutionDataMap = []; + this.declSymbolMap = []; + this.declSignatureSymbolMap = []; + this.declCache = null; + this.symbolCache = null; + this.fileNameToDiagnostics = null; + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + 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); + 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 */, 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 || null; + }; + + SemanticInfoChain.prototype.lineMap = function (fileName) { + return this.getDocument(fileName).lineMap(); + }; + + SemanticInfoChain.prototype.fileNames = function () { + if (this._fileNames === null) { + this._fileNames = this.documents.slice(1).map(function (s) { + return s.fileName; + }); + } + + return this._fileNames; + }; + + SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { + newSymbol.addDeclaration(decl); + decl.setSymbol(newSymbol); + newSymbol.setResolved(); + + return newSymbol; + }; + + SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { + var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { + var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); + newSymbol.type = type; + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.resetGlobalSymbols = function () { + this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); + this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); + this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); + this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); + this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); + this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); + this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); + this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); + + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); + var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + emptyTypeDecl.setSymbol(emptyTypeSymbol); + emptyTypeSymbol.addDeclaration(emptyTypeDecl); + emptyTypeSymbol.setResolved(); + this.emptyTypeSymbol = emptyTypeSymbol; + }; + + SemanticInfoChain.prototype.addDocument = function (document) { + var fileName = document.fileName; + + var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (existingIndex < 0) { + this.documents.push(document); + } else { + this.documents[existingIndex] = document; + } + + this.fileNameToDocument[fileName] = document; + + this.invalidate(); + }; + + SemanticInfoChain.prototype.removeDocument = function (fileName) { + TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); + var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (index > 0) { + this.fileNameToDocument[fileName] = undefined; + this.documents.splice(index, 1); + this.invalidate(); + } + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[cacheID]; + + if (!symbol) { + for (var i = 0, n = this.documents.length; i < n; i++) { + var topLevelDecl = this.documents[i].topLevelDecl(); + + var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); + if (symbol) { + break; + } + + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { + return null; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { + var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; + + var foundDecls = topLevelDecl.searchChildDecls(name, kind); + + for (var j = 0; j < foundDecls.length; j++) { + var foundDecl = foundDecls[j]; + + if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { + break; + } + + var symbol = foundDecls[j].getSymbol(); + if (symbol) { + return symbol; + } + } + + return null; + }; + + SemanticInfoChain.prototype.findExternalModule = function (id) { + id = TypeScript.normalizePath(id); + + var tsFile = id + ".ts"; + var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); + symbol = this.symbolCache[tsCacheID]; + if (symbol != undefined) { + return symbol; + } + + 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 isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + symbol = dynamicModuleDecl.getSymbol(); + + 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 null; + }; + + SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { + var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); + + var symbol = this.symbolCache[cacheID]; + if (symbol == undefined) { + symbol = null; + for (var i = 0; i < this.documents.length; i++) { + var document = this.documents[i]; + var topLevelDecl = document.topLevelDecl(); + + if (!topLevelDecl.isExternalModule()) { + var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); + if (dynamicModules.length) { + symbol = dynamicModules[0].getSymbol(); + break; + } + } + } + + this.symbolCache[cacheID] = symbol; + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + var declsToSearch = this.topLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + + 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, kind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls === TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + 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; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + } + }; + + SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { + if (typeof oldSettings === "undefined") { oldSettings = null; } + if (typeof newSettings === "undefined") { newSettings = null; } + TypeScript.PullTypeResolver.globalTypeCheckPhase++; + + var cleanStart = new Date().getTime(); + + this.astSymbolMap.length = 0; + this.astAliasSymbolMap.length = 0; + this.astCallResolutionDataMap.length = 0; + + this.declCache = TypeScript.createIntrinsicsObject(); + this.symbolCache = TypeScript.createIntrinsicsObject(); + this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + + this.declSymbolMap.length = 0; + this.declSignatureSymbolMap.length = 0; + + if (oldSettings && newSettings) { + if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { + for (var i = 1, n = this.documents.length; i < n; i++) { + this.documents[i].invalidate(); + } + } + } + + TypeScript.pullSymbolID = 0; + + this.resetGlobalSymbols(); + + var cleanEnd = new Date().getTime(); + }; + + SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()] || null; + }; + + SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { + this.astAliasSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { + return this.astAliasSymbolMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { + return this.astCallResolutionDataMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; + } + }; + + SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { + this.declSymbolMap[decl.declID] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { + return this.declSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { + this.declSignatureSymbolMap[decl.declID] = signatureSymbol; + }; + + SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { + return this.declSignatureSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { + var fileName = diagnostic.fileName(); + var diagnostics = this.fileNameToDiagnostics[fileName]; + if (!diagnostics) { + diagnostics = []; + this.fileNameToDiagnostics[fileName] = diagnostics; + } + + diagnostics.push(diagnostic); + }; + + SemanticInfoChain.prototype.getDiagnostics = function (fileName) { + var diagnostics = this.fileNameToDiagnostics[fileName]; + return diagnostics || []; + }; + + SemanticInfoChain.prototype.getBinder = function () { + if (!this._binder) { + this._binder = new TypeScript.PullSymbolBinder(this); + } + + return this._binder; + }; + + SemanticInfoChain.prototype.getResolver = function () { + if (!this._resolver) { + this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); + } + + return this._resolver; + }; + + SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); + indexParameterSymbol.type = indexParamType; + indexSignature.addParameter(indexParameterSymbol); + indexSignature.returnType = returnType; + indexSignature.setResolved(); + indexParameterSymbol.setResolved(); + + containingSymbol.addIndexSignature(indexSignature); + + 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); + indexParameterSymbol.addDeclaration(indexParamDecl); + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast) { + var document = this.getDocument(ast.fileName()); + + if (document) { + return document._getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { + return this.getDocument(ast.fileName()).getEnclosingDecl(ast); + }; + + SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { + this.getDocument(decl.fileName())._setDeclForAST(ast, decl); + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var document = this.getDocument(decl.fileName()); + if (document) { + return document._getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { + this.getDocument(decl.fileName())._setASTForDecl(decl, ast); + }; + + SemanticInfoChain.prototype.topLevelDecl = function (fileName) { + var document = this.getDocument(fileName); + if (document) { + return document.topLevelDecl(); + } + + return null; + }; + + SemanticInfoChain.prototype.topLevelDecls = function () { + if (!this._topLevelDecls) { + this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { + return u.topLevelDecl(); + }); + } + + return this._topLevelDecls; + }; + + 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, 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; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { + this.document = document; + this.semanticInfoChain = semanticInfoChain; + this.propagateEnumConstants = propagateEnumConstants; + this.isDeclareFile = false; + this.parentChain = []; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + return DeclCollectionContext; + })(); + + function containingModuleHasExportAssignment(ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = ast; + return moduleDecl.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } else if (ast.kind() === 120 /* SourceUnit */) { + var sourceUnit = ast; + return sourceUnit.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } + + ast = ast.parent; + } + + return false; + } + + function isParsingAmbientModule(ast, context) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { + return true; + } + } + + ast = ast.parent; + } + + return false; + } + + function preCollectImportDecls(ast, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + + var parent = context.getParent(); + + if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { + declFlags |= 1 /* Exported */; + } + + 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 fileName = sourceUnit.fileName(); + + var isExternalModule = context.document.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); + + context.isDeclareFile = context.document.isDeclareFile(); + + context.pushParent(decl); + + if (isExternalModule) { + var declFlags = 1 /* Exported */; + if (TypeScript.isDTSFile(fileName)) { + declFlags |= 8 /* Ambient */; + } + + var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); + var kind = 32 /* DynamicModule */; + var valueText = TypeScript.quoteStr(fileName); + + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); + + context.semanticInfoChain.setASTForDecl(decl, sourceUnit); + + context.semanticInfoChain.setDeclForAST(sourceUnit, decl); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, sourceUnit, context); + } + + context.pushParent(decl); + } + } + + function preCollectEnumDecls(enumDecl, context) { + var declFlags = 0 /* None */; + var enumName = enumDecl.identifier.valueText(); + + if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + declFlags |= 4096 /* Enum */; + var kind = 64 /* Enum */; + + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); + context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); + context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); + + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); + enumDeclaration.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); + + context.pushParent(enumDeclaration); + } + + function createEnumElementDecls(propertyDecl, context) { + var parent = context.getParent(); + + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function preCollectModuleDecls(moduleDecl, context) { + var declFlags = 0 /* None */; + + var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); + + var isDynamic = moduleDecl.stringLiteral !== null; + + if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + + 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()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); + } + + context.pushParent(decl); + } else { + var moduleNames = getModuleNames(moduleDecl.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + var moduleName = moduleNames[i]; + + var specificFlags = declFlags; + if (i > 0) { + specificFlags |= 1 /* Exported */; + } + + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleName, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleName); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleName, context); + } + + context.pushParent(decl); + } + } + } + + function getModuleNames(name, result) { + result = result || []; + + if (name.kind() === 121 /* QualifiedName */) { + getModuleNames(name.left, result); + result.push(name.right); + } else { + result.push(name); + } + + return result; + } + TypeScript.getModuleNames = getModuleNames; + + 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.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); + } + + function containsExecutableCode(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); + + if (member.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = member; + + if (containsExecutableCode(moduleDecl.moduleElements)) { + return true; + } + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + } + + function preCollectClassDecls(classDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var parent = context.getParent(); + + 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); + + decl.setValueDecl(constructorDecl); + + context.semanticInfoChain.setDeclForAST(classDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, classDecl); + context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); + + context.pushParent(decl); + } + + function preCollectObjectTypeDecls(objectType, context) { + if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { + return; + } + + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setDeclForAST(objectType, decl); + context.semanticInfoChain.setASTForDecl(decl, objectType); + + context.pushParent(decl); + } + + function preCollectInterfaceDecls(interfaceDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { + declFlags |= 1 /* Exported */; + } + + var parent = context.getParent(); + + 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); + + context.pushParent(decl); + } + + function preCollectParameterDecl(argDecl, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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 */) { + decl.setFlag(67108864 /* ConstructorParameter */); + } + + var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); + var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; + if (isPublicOrPrivate && isInConstructor) { + var parentsParent = context.parentChain[context.parentChain.length - 2]; + + 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 */) { + propDecl.setFlag(67108864 /* ConstructorParameter */); + } + + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setASTForDecl(propDecl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, decl); + } + + parent.addVariableDeclToGroup(decl); + } + + function preCollectTypeParameterDecl(typeParameterDecl, context) { + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); + context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = 4096 /* Property */; + + if (propertyDecl.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var parent = context.getParent(); + + 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); + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 512 /* Variable */; + + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); + if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + 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); + context.semanticInfoChain.setDeclForAST(varDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, varDecl); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectVarDecls(ast, context) { + if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { + return; + } + + var varDecl = ast; + createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + 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); + context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); + + context.pushParent(decl); + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + 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); + context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); + + context.pushParent(decl); + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + 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); + context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); + + context.pushParent(decl); + } + + function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { + if (typeof displayName === "undefined") { displayName = null; } + var declFlags = 0 /* None */; + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { + declFlags |= 8192 /* ArrowFunction */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = id ? id.text() : ""; + var displayNameText = displayName ? displayName.text() : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); + context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); + + context.pushParent(decl); + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrow = functionExpressionDeclAST; + var declFlags = 4 /* Public */; + + var parent = context.getParent(); + + if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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); + + parent.addVariableDeclToGroup(decl); + } + } + + function createMemberFunctionDeclaration(funcDecl, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!funcDecl.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(funcDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDecl); + + context.pushParent(decl); + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 4194304 /* IndexSignature */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); + + context.pushParent(decl); + } + + function createCallSignatureDeclaration(callSignature, context) { + var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; + + if (!isChildOfObjectType) { + return; + } + + var declFlags = 2048 /* Signature */; + var declType = 1048576 /* CallSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(callSignature, decl); + context.semanticInfoChain.setASTForDecl(decl, callSignature); + + context.pushParent(decl); + } + + function createMethodSignatureDeclaration(method, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + declFlags |= 4 /* Public */; + declFlags |= 2048 /* Signature */; + + if (method.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(method, decl); + context.semanticInfoChain.setASTForDecl(decl, method); + + context.pushParent(decl); + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 2097152 /* ConstructSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); + + context.pushParent(decl); + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); + + context.pushParent(decl); + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); + + context.pushParent(decl); + } + + function createFunctionExpressionDeclaration(expression, context) { + createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); + + context.pushParent(decl); + } + + function preCollectCatchDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 268435456 /* CatchBlock */; + + 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); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + + var declFlags = 0 /* None */; + var declType = 1024 /* CatchVariable */; + + 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); + context.semanticInfoChain.setDeclForAST(ast.identifier, decl); + context.semanticInfoChain.setASTForDecl(decl, ast.identifier); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectWithDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 134217728 /* WithBlock */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectObjectLiteralDecls(ast, context) { + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); + + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectSimplePropertyAssignmentDecls(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()); + + context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); + } + + function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { + var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); + + 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); + + createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); + } + + function preCollectDecls(ast, context) { + switch (ast.kind()) { + case 120 /* SourceUnit */: + preCollectScriptDecls(ast, context); + break; + case 132 /* EnumDeclaration */: + preCollectEnumDecls(ast, context); + break; + case 243 /* EnumElement */: + createEnumElementDecls(ast, context); + break; + case 130 /* ModuleDeclaration */: + preCollectModuleDecls(ast, context); + break; + case 131 /* ClassDeclaration */: + preCollectClassDecls(ast, context); + break; + case 128 /* InterfaceDeclaration */: + preCollectInterfaceDecls(ast, context); + break; + case 122 /* ObjectType */: + preCollectObjectTypeDecls(ast, context); + break; + case 242 /* Parameter */: + preCollectParameterDecl(ast, context); + break; + case 136 /* MemberVariableDeclaration */: + createMemberVariableDeclaration(ast, context); + break; + case 141 /* PropertySignature */: + createPropertySignature(ast, context); + break; + case 225 /* VariableDeclarator */: + preCollectVarDecls(ast, context); + break; + case 137 /* ConstructorDeclaration */: + createClassConstructorDeclaration(ast, context); + break; + case 139 /* GetAccessor */: + createGetAccessorDeclaration(ast, context); + break; + case 140 /* SetAccessor */: + createSetAccessorDeclaration(ast, context); + break; + case 222 /* FunctionExpression */: + createFunctionExpressionDeclaration(ast, context); + break; + case 135 /* MemberFunctionDeclaration */: + createMemberFunctionDeclaration(ast, context); + break; + case 144 /* IndexSignature */: + createIndexSignatureDeclaration(ast, context); + break; + case 123 /* FunctionType */: + createFunctionTypeDeclaration(ast, context); + break; + case 125 /* ConstructorType */: + createConstructorTypeDeclaration(ast, context); + break; + case 142 /* CallSignature */: + createCallSignatureDeclaration(ast, context); + break; + case 143 /* ConstructSignature */: + createConstructSignatureDeclaration(ast, context); + break; + case 145 /* MethodSignature */: + createMethodSignatureDeclaration(ast, context); + break; + case 129 /* FunctionDeclaration */: + createFunctionDeclaration(ast, context); + break; + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + createAnyFunctionExpressionDeclaration(ast, null, context); + break; + case 133 /* ImportDeclaration */: + preCollectImportDecls(ast, context); + break; + case 238 /* TypeParameter */: + preCollectTypeParameterDecl(ast, context); + break; + case 236 /* CatchClause */: + preCollectCatchDecls(ast, context); + break; + case 163 /* WithStatement */: + preCollectWithDecls(ast, context); + break; + case 215 /* ObjectLiteralExpression */: + preCollectObjectLiteralDecls(ast, context); + break; + case 240 /* SimplePropertyAssignment */: + preCollectSimplePropertyAssignmentDecls(ast, context); + break; + case 241 /* FunctionPropertyAssignment */: + preCollectFunctionPropertyAssignmentDecls(ast, context); + break; + } + } + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, context) { + var currentDecl = context.getParent(); + + if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { + if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + return; + } + } + + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDeclaration = ast; + if (moduleDeclaration.stringLiteral) { + TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); + context.popParent(); + } else { + var moduleNames = getModuleNames(moduleDeclaration.name); + for (var i = moduleNames.length - 1; i >= 0; i--) { + var moduleName = moduleNames[i]; + TypeScript.Debug.assert(currentDecl.ast() === moduleName); + context.popParent(); + currentDecl = context.getParent(); + } + } + } + + if (ast.kind() === 132 /* EnumDeclaration */) { + computeEnumElementConstantValues(ast, currentDecl, context); + } + + while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { + context.popParent(); + currentDecl = context.getParent(); + } + } + + function computeEnumElementConstantValues(ast, enumDecl, context) { + TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); + + var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); + var inConstantSection = !isAmbientEnum; + var currentConstantValue = 0; + var enumMemberDecls = enumDecl.getChildDecls(); + + for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { + var enumElement = ast.enumElements.nonSeparatorAt(i); + var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { + return context.semanticInfoChain.getASTForDecl(d) === enumElement; + }); + + TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); + + if (enumElement.equalsValueClause === null) { + if (inConstantSection) { + enumElementDecl.constantValue = currentConstantValue; + currentConstantValue++; + } + } else { + enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); + if (enumElementDecl.constantValue !== null && !isAmbientEnum) { + inConstantSection = true; + currentConstantValue = enumElementDecl.constantValue + 1; + } else { + inConstantSection = false; + } + } + + TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); + } + } + + function computeEnumElementConstantValue(expression, enumMemberDecls, context) { + TypeScript.Debug.assert(expression); + + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { + var token; + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + token = expression.operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; + } else if (context.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var name = expression; + var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { + return d.name === name.valueText(); + }); + + return matchingEnumElement ? matchingEnumElement.constantValue : null; + + case 202 /* LeftShiftExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left << right; + + case 189 /* BitwiseOrExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left | right; + } + + return null; + } else { + return null; + } + } + + (function (DeclarationCreator) { + function create(document, semanticInfoChain, compilationSettings) { + var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); + + TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); + + return declCollectionContext.getParent(); + } + DeclarationCreator.create = create; + })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); + var DeclarationCreator = TypeScript.DeclarationCreator; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBinder = (function () { + 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 */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.hasBeenBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind === 262144 /* GetAccessor */) { + parent = parent.getGetter(); + } else if (parentDeclKind === 524288 /* SetAccessor */) { + parent = parent.getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = parent.getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = startingDecl.getParentPath(); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + }; + + PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { + var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; + var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; + var name = decl.name; + if (parent) { + var isExported = (decl.flags & 1 /* Exported */) !== 0; + + var prevSymbol = null; + if (lookingForValue) { + prevSymbol = parent.findContainedNonMember(name); + } else if (lookingForType) { + prevSymbol = parent.findContainedNonMemberType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); + } + var prevIsExported = !prevSymbol; + if (!prevSymbol) { + if (lookingForValue) { + prevSymbol = parent.findMember(name, false); + } else if (lookingForType) { + prevSymbol = parent.findNestedType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findNestedContainer(name, searchKind); + } + } + + if (isExported && prevIsExported) { + return prevSymbol; + } + if (prevSymbol) { + var prevDecls = prevSymbol.getDeclarations(); + var lastPrevDecl = prevDecls[prevDecls.length - 1]; + var parentDecl = decl.getParentDecl(); + var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); + if (parentDecl !== prevParentDecl) { + return null; + } + + return prevSymbol; + } + } else { + var parentDecl = decl.getParentDecl(); + if (parentDecl && parentDecl.kind === 1 /* Script */) { + return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); + } else { + var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); + return prevDecls[0] && prevDecls[0].getSymbol(); + } + } + + return null; + }; + + PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { + if (typeof reportError === "undefined") { reportError = true; } + 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 (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()]); + } + return false; + } + + 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; + + var enumContainerSymbol = null; + var enumInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var enumInstanceDecl = enumContainerDecl.getValueDecl(); + + var enumDeclKind = enumContainerDecl.kind; + + var parent = this.getParent(enumContainerDecl); + var parentInstanceSymbol = this.getParent(enumContainerDecl, true); + var parentDecl = enumContainerDecl.getParentDecl(); + var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); + + var isExported = enumContainerDecl.flags & 1 /* Exported */; + + var createdNewSymbol = false; + + enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); + + if (enumContainerSymbol) { + if (enumContainerSymbol.kind !== enumDeclKind) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); + enumContainerSymbol = null; + } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { + enumContainerSymbol = null; + } + } + + if (enumContainerSymbol) { + enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); + } else { + enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); + } + } + + enumContainerSymbol.addDeclaration(enumContainerDecl); + enumContainerDecl.setSymbol(enumContainerSymbol); + + this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); + this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); + + if (!enumInstanceSymbol) { + var variableSymbol = null; + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] === enumContainerDecl) { + break; + } + + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol) { + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + enumInstanceSymbol = variableSymbol; + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); + } + + enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + enumInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); + } + } + + if (createdNewSymbol && parent) { + if (enumContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(enumContainerSymbol); + } else { + parent.addEnclosedNonMemberType(enumContainerSymbol); + } + } + + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } + var valueDecl = enumContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + 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(); + + enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; + + 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(); + + 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); + if (!moduleDeclAST) { + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); + + moduleDeclAST = moduleNameAST; + } + + var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); + var searchKind = 164 /* SomeContainer */; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; + + if (parent && moduleKind === 32 /* DynamicModule */) { + this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); + } + + var createdNewSymbol = false; + + moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); + + if (moduleContainerTypeSymbol) { + if (moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); + } + + moduleContainerTypeSymbol = null; + } 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) { + moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); + this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); + + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); + } + } + } + + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); + + 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); + } + } + + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(importSymbol); + } else { + parent.addEnclosedNonMemberContainer(importSymbol); + } + } + }; + + 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; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + 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, 58728795 /* SomeType */, parent); + + if (classSymbol && classSymbol.kind === 16 /* Interface */) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); + classSymbol = null; + } + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); + this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + 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; + + if (!constructorSymbol) { + var siblingValueDecls = null; + if (parentDecl) { + siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); + + if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { + constructorSymbol = siblingValueDecls[0].getSymbol(); + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + constructorSymbol.setIsSynthesized(); + constructorSymbol.type = constructorTypeSymbol; + } + + classSymbol.setConstructorMethod(constructorSymbol); + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); + + if (interfaceSymbol) { + if (!(interfaceSymbol.kind & acceptableSharedKind)) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); + interfaceSymbol = null; + } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { + interfaceSymbol = null; + } + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + 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; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + 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; + variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); + var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); + var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); + 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 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 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.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 || 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); + variableSymbol = null; + parentHadSymbol = false; + } + } + + if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { + variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); + } + } + + if ((declFlags & 118784 /* ImplicitVariable */) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + if (!parent && parentDecl.kind === 1 /* Script */) { + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); + this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfoChain.getASTForDecl(decl); + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & 102400 /* SomeInitializedModule */) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + 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); + } + variableDeclaration.setSymbol(variableSymbol); + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + if (!variableSymbol.hasDeclaration(variableDeclaration)) { + variableSymbol.addDeclaration(variableDeclaration); + } + 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); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); + + var declName = variableDeclaration.name; + + var variableSymbol = new TypeScript.PullSymbol(declName, declKind); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + + this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); + }; + + PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + var propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + + var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { + var parameters = []; + var params = TypeScript.createIntrinsicsObject(); + var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); + + if (parameterList) { + for (var i = 0, n = parameterList.length; i < n; i++) { + var argDecl = parameterList.astAt(i); + var id = parameterList.identifierAt(i); + var decl = this.semanticInfoChain.getDeclForAST(argDecl); + var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); + var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); + + if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { + parameterSymbol.isVarArg = 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); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); + + if (functionSymbol) { + 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); + functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); + } + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { + signature.hasVarArgs = true; + } + + var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); + + 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; + if (name) { + this.semanticInfoChain.setSymbolForAST(name, functionSymbol); + } + + this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); + + if (parameters.lastParameterIsRest()) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + + var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; + + TypeScript.Debug.assert(nameAST); + + this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); + this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); + + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); + if (TypeScript.lastParameterIsRest(parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); + signature.addTypeParameter(typeParameter); + } else { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { + var prototypeStr = "prototype"; + + var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); + if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { + 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], this.semanticInfoChain); + + prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + prototypeSymbol.setIsSynthesized(); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = classTypeSymbol; + constructorTypeSymbol.addMember(prototypeSymbol); + + if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { + var resolver = this.semanticInfoChain.getResolver(); + prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); + } + prototypeSymbol.setResolved(); + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); + constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.appendConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + constructSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + callSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); + + var parent = this.getParent(indexSignatureDeclaration); + parent.addIndexSignature(indexSignature); + indexSignature.setContainer(parent); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + + getterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); + } + }; + + 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) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + this.bindEnumDeclarationToPullSymbol(decl); + break; + + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 512 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 1024 /* CatchVariable */: + this.bindCatchVariableToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + this.bindEnumMemberDeclarationToPullSymbol(decl); + break; + + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 128 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + decl.getParentDecl().getSymbol(); + break; + + case 268435456 /* CatchBlock */: + case 134217728 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); + this.declsBeingBound.pop(); + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (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(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + + if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (functionDecl.kind === 4194304 /* IndexSignature */) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + + function isNameNumeric(name) { + return isFinite(+name); + } + PullHelpers.isNameNumeric = isNameNumeric; + + function typeSymbolsAreIdentical(a, b) { + if (a.isTypeReference() && !a.getIsSpecialized()) { + a = a.referencedTypeSymbol; + } + + if (b.isTypeReference() && !b.getIsSpecialized()) { + b = b.referencedTypeSymbol; + } + + return a === b; + } + PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; + + function getRootType(type) { + var rootType = type.getRootSymbol(); + + while (true) { + if (type === rootType) { + return type; + } + + type = rootType; + rootType = type.getRootSymbol(); + } + } + PullHelpers.getRootType = getRootType; + + function isSymbolLocal(symbol) { + var container = symbol.getContainer(); + if (container) { + var containerKind = container.kind; + if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { + return true; + } + + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { + return true; + } + } + + 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; + +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.fileResolutionIOTime = 0; + TypeScript.fileResolutionScanImportsTime = 0; + TypeScript.fileResolutionImportFileSearchTime = 0; + TypeScript.fileResolutionGetDefaultLibraryTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.compilerResolvePathTime = 0; + TypeScript.compilerDirectoryNameTime = 0; + TypeScript.compilerDirectoryExistsTime = 0; + TypeScript.compilerFileExistsTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + 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(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } + this.outputFiles = []; + this.emitOutputResult = emitOutputResult; + } + return EmitOutput; + })(); + TypeScript.EmitOutput = EmitOutput; + + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); + var OutputFileType = TypeScript.OutputFileType; + + var OutputFile = (function () { + function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { + if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.text = text; + this.fileType = fileType; + this.sourceMapEntries = sourceMapEntries; + } + return OutputFile; + })(); + TypeScript.OutputFile = OutputFile; + + var CompileResult = (function () { + function CompileResult() { + this.diagnostics = []; + this.outputFiles = []; + } + CompileResult.fromDiagnostics = function (diagnostics) { + var result = new CompileResult(); + result.diagnostics = diagnostics; + return result; + }; + + CompileResult.fromOutputFiles = function (outputFiles) { + var result = new CompileResult(); + result.outputFiles = outputFiles; + return result; + }; + return CompileResult; + })(); + TypeScript.CompileResult = CompileResult; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, _settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } + this.logger = logger; + this._settings = _settings; + this.semanticInfoChain = null; + this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); + } + TypeScriptCompiler.prototype.compilationSettings = function () { + return this._settings; + }; + + TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { + var oldSettings = this._settings; + this._settings = newSettings; + + if (!compareDataObjects(oldSettings, newSettings)) { + this.semanticInfoChain.invalidate(oldSettings, newSettings); + } + }; + + TypeScriptCompiler.prototype.getDocument = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.semanticInfoChain.getDocument(fileName); + }; + + TypeScriptCompiler.prototype.cleanupSemanticCache = function () { + this.semanticInfoChain.invalidate(); + }; + + TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); + + this.semanticInfoChain.addDocument(document); + }; + + TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); + + this.semanticInfoChain.addDocument(updatedDocument); + }; + + TypeScriptCompiler.prototype.removeFile = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + this.semanticInfoChain.removeDocument(fileName); + }; + + TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { + if (document.emitToOwnOutputFile()) { + var updatedFileName = document.fileName; + if (emitOptions.outputDirectory() !== "") { + updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); + updatedFileName = emitOptions.outputDirectory() + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(emitOptions.sharedOutputFile(), true); + } + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + var printReason = false; + + if (document.emitToOwnOutputFile()) { + var result = document.byteOrderMark !== 0 /* None */; + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + } + return result; + } else { + var fileNames = this.fileNames(); + + var result = false; + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + + if (document.isExternalModule()) { + continue; + } + + if (document.byteOrderMark !== 0 /* None */) { + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + result = true; + } else { + return true; + } + } + } + + return result; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype._shouldEmit = function (document) { + return !document.isDeclareFile(); + }; + + TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { + if (!this.compilationSettings().generateDeclarationFiles()) { + return false; + } + + return this._shouldEmit(document); + }; + + TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); + + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); + } + + declarationEmitter.emitDeclarations(sourceUnit); + return declarationEmitter; + }; + + TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmitDeclarations(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFile()); + } + } else { + sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var sharedEmitter = null; + var fileNames = this.fileNames(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileNames[i]); + + sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return emitOutput; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, null); + return emitOutput; + } else { + return this.emitAllDeclarations(resolvePath); + } + }; + + 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; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmit(document)); + + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); + var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); + + if (this.compilationSettings().mapSourceFiles()) { + var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); + emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); + } + } else if (this.compilationSettings().mapSourceFiles()) { + emitter.setSourceMapperNewSourceFile(document); + } + + emitter.setDocument(document); + emitter.emitJavascript(sourceUnit, false); + + return emitter; + }; + + TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmit(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFiles()); + } + } else { + sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var fileNames = this.fileNames(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + sharedEmitter = this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); + } + + TypeScript.emitTime += new Date().getTime() - start; + return emitOutput; + }; + + TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, null); + return emitOutput; + } else { + return this.emitAll(resolvePath); + } + }; + + TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { + if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } + return new CompilerIterator(this, resolvePath, continueOnDiagnostics); + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + + TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { + return this.getDocument(fileName).sourceUnit(); + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + var errors = this.semanticInfoChain.getDiagnostics(fileName); + + errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); + errors.sort(function (d1, d2) { + if (d1.fileName() < d2.fileName()) { + return -1; + } else if (d1.fileName() > d2.fileName()) { + return 1; + } + + if (d1.start() < d2.start()) { + return -1; + } else if (d1.start() > d2.start()) { + return 1; + } + + var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; + var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; + if (code1 < code2) { + return -1; + } else if (code1 > code2) { + return 1; + } + + return 0; + }); + + 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++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var ast = this.semanticInfoChain.getASTForDecl(decl); + if (!ast) { + return null; + } + + var enclosingDecl = resolver.getEnclosingDecl(decl); + if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { + return this.getSymbolOfDeclaration(enclosingDecl); + } + + return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { + var scriptName = document.fileName; + + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + var inWithBlock = false; + + var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); + + if (!ast) { + return null; + } + + var path = this.getASTPath(ast); + + for (var i = 0, n = path.length; i < n; i++) { + var current = path[i]; + + switch (current.kind()) { + case 222 /* FunctionExpression */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + if (propagateContextualTypes) { + resolver.resolveAST(current, true, resolutionContext); + } + break; + + case 136 /* MemberVariableDeclaration */: + var memberVariable = current; + inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); + break; + + case 225 /* VariableDeclarator */: + var variableDeclarator = current; + inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); + break; + + case 213 /* InvocationExpression */: + case 216 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.kind() === 216 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = path[i + 3]; + if (argExpression) { + for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { + if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext); + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 214 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 215 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.propertyAssignments; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { + if (memberDecls.nonSeparatorAt(j) === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + } + + break; + + case 174 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path[i + 1] && path[i + 1] === assignmentExpression.right) { + var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + 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; + + case 150 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 122 /* ObjectType */: + if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { + resolver.resolveAST(current, false, resolutionContext); + } + + break; + + case 163 /* WithStatement */: + inWithBlock = true; + break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; + } + + var decl = this.semanticInfoChain.getDeclForAST(current); + if (decl) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { + if (ast.parent.kind() === 212 /* MemberAccessExpression */) { + if (ast.parent.name === ast) { + ast = ast.parent; + } + } else if (ast.parent.kind() === 121 /* QualifiedName */) { + if (ast.parent.right === ast) { + ast = ast.parent; + } + } + } + + return { + ast: ast, + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment, + inWithBlock: inWithBlock + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + resolver.resolveAST(assigningAST, false, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushNewContextualType(contextualType); + + if (init) { + resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); + } + } + } + }; + + TypeScriptCompiler.prototype.getASTPath = function (ast) { + var result = []; + + while (ast) { + result.unshift(ast); + ast = ast.parent; + } + + return result; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + ast = context.ast; + 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()]); + return null; + } + + if (symbol.isTypeReference()) { + symbol = symbol.getReferencedTypeSymbol(); + } + + var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); + + return { + symbol: symbol, + aliasSymbol: aliasSymbol, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { + if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { + return null; + } + + var isNew = ast.kind() === 216 /* ObjectCreationExpression */; + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, false); + if (!context || context.inWithBlock) { + return null; + } + + return resolver.getVisibleDecls(context.enclosingDecl); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { + if (ast.kind() !== 215 /* ObjectLiteralExpression */) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var astForDecl = decl.ast(); + if (!astForDecl) { + return null; + } + + var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); + if (!astForDeclContext) { + return null; + } + + var symbol = decl.getSymbol(); + resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + aliasSymbol: null, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { + return this.semanticInfoChain.topLevelDecl(fileName); + }; + + TypeScriptCompiler.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast); + }; + + TypeScriptCompiler.prototype.fileNames = function () { + return this.semanticInfoChain.fileNames(); + }; + + 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; + + var CompilerPhase; + (function (CompilerPhase) { + CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; + CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; + CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; + CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; + CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; + })(CompilerPhase || (CompilerPhase = {})); + + var CompilerIterator = (function () { + function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { + if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } + this.compiler = compiler; + this.resolvePath = resolvePath; + this.continueOnDiagnostics = continueOnDiagnostics; + this.index = -1; + this.fileNames = null; + this._current = null; + this._emitOptions = null; + this._sharedEmitter = null; + this._sharedDeclarationEmitter = null; + this.hadSyntacticDiagnostics = false; + this.hadSemanticDiagnostics = false; + this.hadEmitDiagnostics = false; + this.fileNames = compiler.fileNames(); + this.compilerPhase = startingPhase; + } + CompilerIterator.prototype.current = function () { + return this._current; + }; + + CompilerIterator.prototype.moveNext = function () { + this._current = null; + + while (this.moveNextInternal()) { + if (this._current) { + return true; + } + } + + return false; + }; + + CompilerIterator.prototype.moveNextInternal = function () { + this.index++; + + while (this.shouldMoveToNextPhase()) { + this.index = 0; + this.compilerPhase++; + } + + if (this.compilerPhase > 4 /* DeclarationEmit */) { + return false; + } + + switch (this.compilerPhase) { + case 0 /* Syntax */: + return this.moveNextSyntaxPhase(); + case 1 /* Semantics */: + return this.moveNextSemanticsPhase(); + case 2 /* EmitOptionsValidation */: + return this.moveNextEmitOptionsValidationPhase(); + case 3 /* Emit */: + return this.moveNextEmitPhase(); + case 4 /* DeclarationEmit */: + return this.moveNextDeclarationEmitPhase(); + } + }; + + CompilerIterator.prototype.shouldMoveToNextPhase = function () { + switch (this.compilerPhase) { + case 2 /* EmitOptionsValidation */: + return this.index === 1; + + case 0 /* Syntax */: + case 1 /* Semantics */: + return this.index === this.fileNames.length; + + case 3 /* Emit */: + case 4 /* DeclarationEmit */: + return this.index === (this.fileNames.length + 1); + } + + return false; + }; + + CompilerIterator.prototype.moveNextSyntaxPhase = function () { + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + + var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSyntacticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextSemanticsPhase = function () { + if (this.hadSyntacticDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + var diagnostics = this.compiler.getSemanticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSemanticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + + if (!this._emitOptions) { + this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); + } + + if (this._emitOptions.diagnostic()) { + if (!this.continueOnDiagnostics) { + this.hadEmitDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(this._emitOptions); + + if (this.hadEmitDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { + _this._current = CompileResult.fromOutputFiles(outputFiles); + }, this._sharedEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedEmitter) { + this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); + } + + return true; + }; + + CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(!this.hadEmitDiagnostics); + if (this.hadSemanticDiagnostics) { + return false; + } + + if (!this.compiler.compilationSettings().generateDeclarationFiles()) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { + _this._current = CompileResult.fromOutputFiles([file]); + }, this._sharedDeclarationEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { + this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); + } + + return true; + }; + return CompilerIterator; + })(); + + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) + return false; + } else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) + return false; + } + } + return true; + } + TypeScript.compareDataObjects = compareDataObjects; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (GenerativeTypeClassification) { + GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; + GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; + GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; + GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; + })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); + var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; + + var PullTypeReferenceSymbol = (function (_super) { + __extends(PullTypeReferenceSymbol, _super); + function PullTypeReferenceSymbol(referencedTypeSymbol) { + _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); + this.referencedTypeSymbol = referencedTypeSymbol; + this.isResolved = true; + + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); + + this.setRootSymbol(referencedTypeSymbol); + + this.typeReference = this; + } + PullTypeReferenceSymbol.createTypeReference = function (type) { + if (type.isTypeReference()) { + return type; + } + + var typeReference = type.typeReference; + + if (!typeReference) { + typeReference = new PullTypeReferenceSymbol(type); + type.typeReference = typeReference; + } + + return typeReference; + }; + + PullTypeReferenceSymbol.prototype.isTypeReference = function () { + return true; + }; + + PullTypeReferenceSymbol.prototype.setResolved = function () { + }; + + PullTypeReferenceSymbol.prototype.setUnresolved = function () { + }; + PullTypeReferenceSymbol.prototype.invalidate = function () { + }; + + PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { + this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); + }; + + PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol; + }; + + PullTypeReferenceSymbol.prototype._getResolver = function () { + return this.referencedTypeSymbol._getResolver(); + }; + + PullTypeReferenceSymbol.prototype.hasMembers = function () { + return this.referencedTypeSymbol.hasMembers(); + }; + + PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); + }; + + PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + return this.referencedTypeSymbol.getAssociatedContainerType(); + }; + + PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getFunctionSymbol(); + }; + PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); + }; + + PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); + }; + PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); + }; + + PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); + }; + PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMember(name); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); + }; + + PullTypeReferenceSymbol.prototype.getMembers = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getMembers(); + }; + + PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); + }; + PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getHasDefaultConstructor(); + }; + PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructorMethod(); + }; + PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); + }; + PullTypeReferenceSymbol.prototype.getTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.isGeneric = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isGeneric(); + }; + + PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getSpecialization(substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getKnownSpecializations(); + }; + PullTypeReferenceSymbol.prototype.getTypeArguments = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArguments(); + }; + PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); + }; + 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"); + }; + + PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnIndexSignatures(); + }; + PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getIndexSignatures(); + }; + + PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { + this.referencedTypeSymbol.addImplementedType(implementedType); + }; + PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getImplementedTypes(); + }; + PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { + this.referencedTypeSymbol.addExtendedType(extendedType); + }; + PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getExtendedTypes(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExtendsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExtendThisType(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); + }; + + PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); + }; + + PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findMember(name, lookInParent); + }; + PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedType(name, kind); + }; + PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedContainer(name, kind); + }; + PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + }; + + PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findTypeParameter(name); + }; + + PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); + }; + return PullTypeReferenceSymbol; + })(TypeScript.PullTypeSymbol); + TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; + + var PullInstantiatedTypeReferenceSymbol = (function (_super) { + __extends(PullInstantiatedTypeReferenceSymbol, _super); + 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 = undefined; + this._instantiatedConstructorMethod = null; + this._instantiatedAssociatedContainerType = null; + this._isArray = undefined; + this._generativeTypeClassification = []; + + TypeScript.nSpecializationsCreated++; + } + PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { + return !this.isInstanceReferenceType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; + } + + 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()); + } + return this._isArray; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { + if (!this.isArrayNamedTypeReference()) { + return null; + } + + var typeArguments = this.getTypeArguments(); + return typeArguments ? typeArguments[0] : null; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.getIsSpecialized()) { + return this; + } + + return this.referencedTypeSymbol; + }; + + 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + 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; + } + } + + if (isInstanceReferenceType) { + typeParameterArgumentMap = []; + } + } + + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); + + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); + + return instantiation; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { + return this.getRootSymbol().isGeneric(); + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { + if (this.isInstanceReferenceType) { + return this.getTypeParameters(); + } + + if (this._typeArgumentReferences === undefined) { + var typeParameters = this.referencedTypeSymbol.getTypeParameters(); + + if (typeParameters.length) { + var typeArgument = null; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; + + if (!typeArgument) { + TypeScript.Debug.fail("type argument count mismatch"); + } + + if (typeArgument) { + typeArguments[typeArguments.length] = typeArgument; + } + } + + this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; + } + } + + return this._typeArgumentReferences; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + 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(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getMembers(); + } + + if (!this._instantiatedMembers) { + var referencedMembers = this.referencedTypeSymbol.getMembers(); + var referencedMember = null; + var instantiatedMember = null; + + this._instantiatedMembers = []; + + for (var i = 0; i < referencedMembers.length; i++) { + referencedMember = referencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (!this._instantiatedMemberNameCache[referencedMember.name]) { + this.populateInstantiatedMemberFromReferencedMember(referencedMember); + } + + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; + } + } + + return this._instantiatedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.findMember(name, lookInParent); + } + + var memberSymbol = this._instantiatedMemberNameCache[name]; + + if (!memberSymbol) { + var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); + + if (referencedMemberSymbol) { + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; + } else { + memberSymbol = null; + } + } + + return memberSymbol; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + } + + var requestedMembers = []; + var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + + if (!this._allInstantiatedMemberNameCache) { + this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); + + var members = this.getMembers(); + + for (var i = 0; i < members.length; i++) { + this._allInstantiatedMemberNameCache[members[i].name] = members[i]; + } + } + + var referencedMember = null; + var requestedMember = null; + + for (var i = 0; i < allReferencedMembers.length; i++) { + referencedMember = allReferencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (this._allInstantiatedMemberNameCache[referencedMember.name]) { + requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; + } else { + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; + requestedMembers[requestedMembers.length] = referencedMember; + } else { + requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + requestedMember.setRootSymbol(referencedMember); + + requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + requestedMember.isOptional = referencedMember.isOptional; + + this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; + requestedMembers[requestedMembers.length] = requestedMember; + } + } + } + + return requestedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructorMethod(); + } + + 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); + } + + return this._instantiatedConstructorMethod; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + if (!this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAssociatedContainerType(); + } + + if (!this._instantiatedAssociatedContainerType) { + var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); + + if (referencedAssociatedContainerType) { + this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); + } + } + + return this._instantiatedAssociatedContainerType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getCallSignatures(); + } + + if (this._instantiatedCallSignatures) { + return this._instantiatedCallSignatures; + } + + var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); + this._instantiatedCallSignatures = []; + + for (var i = 0; i < referencedCallSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); + + if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; + } else { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedCallSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructSignatures(); + } + + if (this._instantiatedConstructSignatures) { + return this._instantiatedConstructSignatures; + } + + var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); + this._instantiatedConstructSignatures = []; + + for (var i = 0; i < referencedConstructSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); + + if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; + } else { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedConstructSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getIndexSignatures(); + } + + if (this._instantiatedIndexSignatures) { + return this._instantiatedIndexSignatures; + } + + var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); + this._instantiatedIndexSignatures = []; + + for (var i = 0; i < referencedIndexSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); + + if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; + } else { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedIndexSignatures; + }; + 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) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { + if (element === null) { + return null; + } + + if (element.fullWidth() === 0) { + return new TypeScript.ASTSpan(-1, -1); + } + + var leadingTriviaWidth = element.leadingTriviaWidth(); + var trailingTriviaWidth = element.trailingTriviaWidth(); + + var start = fullStart + leadingTriviaWidth; + var end = fullStart + element.fullWidth() - trailingTriviaWidth; + + return new TypeScript.ASTSpan(start, end); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { + if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } + if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span._trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span._start = start; + span._end = end; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ISyntaxList2(this.fileName, array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { + return this.visitToken(token); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result = this.visitTokenWorker(token); + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { + switch (token.tokenKind) { + case 60 /* AnyKeyword */: + return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); + case 61 /* BooleanKeyword */: + return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); + case 67 /* NumberKeyword */: + return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); + case 69 /* StringKeyword */: + return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); + case 41 /* VoidKeyword */: + return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); + case 35 /* ThisKeyword */: + return new TypeScript.ThisExpression(token.text(), token.valueText()); + case 50 /* SuperKeyword */: + return new TypeScript.SuperExpression(token.text(), token.valueText()); + case 37 /* TrueKeyword */: + return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); + case 24 /* FalseKeyword */: + return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); + case 32 /* NullKeyword */: + return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); + case 14 /* StringLiteral */: + return new TypeScript.StringLiteral(token.text(), token.valueText()); + case 12 /* RegularExpressionLiteral */: + return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); + case 13 /* NumericLiteral */: + var fullStart = this.position; + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); + + result.setPreComments(preComments); + return result; + case 11 /* IdentifierName */: + return new TypeScript.Identifier(token.text()); + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { + var start = this.position; + TypeScript.Debug.assert(start === 0); + + var bod = this.visitSyntaxList(node.moduleElements); + 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; + }; + + SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { + var start = this.position; + + this.moveTo(node, node.stringLiteral); + var stringLiteral = node.stringLiteral.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ExternalModuleReference(stringLiteral); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { + var start = this.position; + var moduleName = node.moduleName.accept(this); + + var result = new TypeScript.ModuleNameModuleReference(moduleName); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + this.movePast(node.openBraceToken); + var members = this.visitSyntaxList(node.classElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { + var result = null; + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { + result = result || []; + result.push(1 /* Exported */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + result = result || []; + result.push(8 /* Ambient */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { + result = result || []; + result.push(16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { + result = result || []; + result.push(4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { + result = result || []; + result.push(2 /* Private */); + } + + return result || TypeScript.sentinelEmptyArray; + }; + + SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + var body = this.visitObjectType(node.body); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { + var start = this.position; + + this.movePast(node.extendsOrImplementsKeyword); + var typeNames = this.visitSeparatedSyntaxList(node.typeNames); + + var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { + var start = this.position; + + var modifiers = this.visitModifiers(node.modifiers); + + this.moveTo(node, node.moduleKeyword); + this.movePast(node.moduleKeyword); + + var moduleName = node.name ? node.name.accept(this) : null; + var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; + + this.movePast(node.openBraceToken); + + var moduleElements = this.visitSyntaxList(node.moduleElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + this.movePast(node.openBraceToken); + + var enumElements = this.visitSeparatedSyntaxList(node.enumElements); + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + var start = this.position; + + var memberName = this.visitToken(node.propertyName); + + var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.EnumElement(memberName, value); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ImportDeclaration(modifiers, name, alias); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.VariableStatement(modifiers, declaration); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var propertyName = this.visitToken(node.propertyName); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var start = this.position; + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var value = node.value.accept(this); + value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); + + var result = new TypeScript.EqualsValueClause(value); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayLiteralExpression(expressions); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(openParenToken); + + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = node.identifier.accept(this); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var callSignature = this.visitCallSignature(node.callSignature); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + return type ? type.accept(this) : null; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var result = new TypeScript.TypeQuery(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left); + this.movePast(node.dotToken); + var right = this.visitIdentifier(node.right); + + var result = new TypeScript.QualifiedName(left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeArgumentList(typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectType(typeMembers); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayType(underlying); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name); + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + var result = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.colonToken); + var type = this.visitType(node.type); + + var result = new TypeScript.TypeAnnotation(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.visitIdentifier(node.name); + + var result = new TypeScript.MemberAccessExpression(expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + this.movePast(node.openParenToken); + + 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()); + } + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(node.kind(), left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.ConstructSignature(callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.MethodSignature(name, questionToken, callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.IndexSignature(parameter, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + var openParenToken = node.openParenToken; + + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + var openParenTrailingComments = null; + if (node.parameters.childCount() === 0) { + openParenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + } + + this.movePast(node.openParenToken); + var parameters = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeParameterList(typeParameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + var start = this.position; + this.movePast(node.extendsKeyword); + var type = this.visitType(node.type); + + var result = new TypeScript.Constraint(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + var start = this.position; + + this.movePast(node.elseKeyword); + var statement = node.statement.accept(this); + + var result = new TypeScript.ElseClause(statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var expression = node.expression.accept(this); + + var semicolonPosition = this.position; + + var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + 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(callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.indexSignature); + var indexSignature = node.indexSignature.accept(this); + + this.movePast(node.semicolonToken); + + var result = new TypeScript.IndexMemberDeclaration(indexSignature); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + var variableDeclarator = node.variableDeclarator.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + this.movePast(node.openBraceToken); + var switchClauses = this.visitSyntaxList(node.switchClauses); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseSwitchClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.DefaultSwitchClause(statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.BreakStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ContinueStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var initializer = node.initializer ? node.initializer.accept(this) : null; + + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var left = node.left ? node.left.accept(this) : null; + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.CastExpression(castTerm, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + var propertyName = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var expression = node.expression.accept(this); + expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); + + var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var propertyName = node.propertyName.accept(this); + var callSignature = this.visitCallSignature(node.callSignature); + var block = this.visitBlock(node.block); + + var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionExpression(name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.visitIdentifier(node.identifier); + var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + var start = this.position; + this.movePast(node.finallyKeyword); + var block = node.block.accept(this); + + var result = new TypeScript.FinallyClause(block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, whileKeyword, condition); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.TypeOfExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.DeleteExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.VoidExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + function applyDelta(ast, delta) { + if (ast) { + if (ast._start !== -1) { + ast._start += delta; + } + + if (ast._end !== -1) { + ast._end += delta; + } + } + } + + function applyDeltaToComments(comments, delta) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment, delta); + } + } + } + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var pre = function (cur) { + applyDelta(cur, delta); + applyDeltaToComments(cur.preComments(), delta); + applyDeltaToComments(cur.postComments(), delta); + + switch (cur.kind()) { + case 146 /* Block */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 226 /* ArgumentList */: + applyDelta(cur.closeParenToken, delta); + break; + + case 130 /* ModuleDeclaration */: + applyDelta(cur.endingToken, delta); + break; + + case 131 /* ClassDeclaration */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 161 /* DoStatement */: + applyDelta(cur.whileKeyword, delta); + break; + + case 151 /* SwitchStatement */: + applyDelta(cur.closeParenToken, delta); + break; + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span._start !== -1) { + var delta = start - span._start; + this.applyDelta(span, delta); + + span._end = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = element._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + element._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan(_start, _end) { + this._start = _start; + this._end = _end; + } + ASTSpan.prototype.start = function () { + return this._start; + }; + + ASTSpan.prototype.end = function () { + return this._end; + }; + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, false); + } + + function commentStructuralEqualsIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, true); + } + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); + } + + function commentStructuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + function commentArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.parent = null; + this._start = -1; + this._end = -1; + this._trailingTriviaWidth = 0; + this._astID = astID++; + this._preComments = null; + this._postComments = null; + } + AST.prototype.syntaxID = function () { + return this._astID; + }; + + AST.prototype.start = function () { + return this._start; + }; + + AST.prototype.end = function () { + return this._end; + }; + + AST.prototype.trailingTriviaWidth = function () { + return this._trailingTriviaWidth; + }; + + AST.prototype.fileName = function () { + return this.parent.fileName(); + }; + + AST.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.width = function () { + return this.end() - this.start(); + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + + AST.prototype.isExpression = function () { + return false; + }; + return AST; + })(); + TypeScript.AST = AST; + + var ISyntaxList2 = (function (_super) { + __extends(ISyntaxList2, _super); + function ISyntaxList2(_fileName, members) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISyntaxList2.prototype.childCount = function () { + return this.members.length; + }; + + ISyntaxList2.prototype.childAt = function (index) { + return this.members[index]; + }; + + ISyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISyntaxList2.prototype.kind = function () { + return 1 /* List */; + }; + + ISyntaxList2.prototype.firstOrDefault = function (func) { + return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.lastOrDefault = function (func) { + return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.any = function (func) { + return TypeScript.ArrayUtilities.any(this.members, func); + }; + + ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISyntaxList2; + })(AST); + TypeScript.ISyntaxList2 = ISyntaxList2; + + var ISeparatedSyntaxList2 = (function (_super) { + __extends(ISeparatedSyntaxList2, _super); + function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + this._separatorCount = _separatorCount; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { + return this.members.length; + }; + + ISeparatedSyntaxList2.prototype.separatorCount = function () { + return this._separatorCount; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { + return this.members[index]; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i) === ast) { + return i; + } + } + + return -1; + }; + + ISeparatedSyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISeparatedSyntaxList2.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISeparatedSyntaxList2; + })(AST); + TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; + + var SourceUnit = (function (_super) { + __extends(SourceUnit, _super); + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { + _super.call(this); + this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; + this._fileName = _fileName; + moduleElements && (moduleElements.parent = this); + } + SourceUnit.prototype.fileName = function () { + return this._fileName; + }; + + SourceUnit.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return SourceUnit; + })(AST); + TypeScript.SourceUnit = SourceUnit; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(_text) { + _super.call(this); + this._text = _text; + this._valueText = null; + } + Identifier.prototype.text = function () { + return this._text; + }; + Identifier.prototype.valueText = function () { + if (!this._valueText) { + var text = this._text; + if (text === "__proto__") { + this._valueText = "#__proto__"; + } else { + this._valueText = TypeScript.Syntax.massageEscapes(text); + } + } + + return this._valueText; + }; + + Identifier.prototype.kind = function () { + return 11 /* IdentifierName */; + }; + + 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; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + LiteralExpression.prototype.text = function () { + return this._text; + }; + + LiteralExpression.prototype.valueText = function () { + return this._valueText; + }; + + LiteralExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + ThisExpression.prototype.text = function () { + return this._text; + }; + + ThisExpression.prototype.valueText = function () { + return this._valueText; + }; + + ThisExpression.prototype.kind = function () { + return 35 /* ThisKeyword */; + }; + + 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; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + SuperExpression.prototype.text = function () { + return this._text; + }; + + SuperExpression.prototype.valueText = function () { + return this._valueText; + }; + + SuperExpression.prototype.kind = function () { + return 50 /* SuperKeyword */; + }; + + 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; + + var NumericLiteral = (function (_super) { + __extends(NumericLiteral, _super); + function NumericLiteral(_value, _text, _valueText) { + _super.call(this); + this._value = _value; + this._text = _text; + this._valueText = _valueText; + } + NumericLiteral.prototype.text = function () { + return this._text; + }; + NumericLiteral.prototype.valueText = function () { + return this._valueText; + }; + NumericLiteral.prototype.value = function () { + return this._value; + }; + + NumericLiteral.prototype.kind = function () { + return 13 /* NumericLiteral */; + }; + + 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; + + var RegularExpressionLiteral = (function (_super) { + __extends(RegularExpressionLiteral, _super); + function RegularExpressionLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + RegularExpressionLiteral.prototype.text = function () { + return this._text; + }; + + RegularExpressionLiteral.prototype.valueText = function () { + return this._valueText; + }; + + RegularExpressionLiteral.prototype.kind = function () { + return 12 /* RegularExpressionLiteral */; + }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; + return RegularExpressionLiteral; + })(AST); + TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + StringLiteral.prototype.valueText = function () { + return this._valueText; + }; + + StringLiteral.prototype.kind = function () { + return 14 /* StringLiteral */; + }; + + 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; + + var TypeAnnotation = (function (_super) { + __extends(TypeAnnotation, _super); + function TypeAnnotation(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + TypeAnnotation.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + return TypeAnnotation; + })(AST); + TypeScript.TypeAnnotation = TypeAnnotation; + + var BuiltInType = (function (_super) { + __extends(BuiltInType, _super); + function BuiltInType(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + BuiltInType.prototype.text = function () { + return this._text; + }; + + BuiltInType.prototype.valueText = function () { + return this._valueText; + }; + + BuiltInType.prototype.kind = function () { + return this._nodeType; + }; + return BuiltInType; + })(AST); + TypeScript.BuiltInType = BuiltInType; + + var ExternalModuleReference = (function (_super) { + __extends(ExternalModuleReference, _super); + function ExternalModuleReference(stringLiteral) { + _super.call(this); + this.stringLiteral = stringLiteral; + stringLiteral && (stringLiteral.parent = this); + } + ExternalModuleReference.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + return ExternalModuleReference; + })(AST); + TypeScript.ExternalModuleReference = ExternalModuleReference; + + var ModuleNameModuleReference = (function (_super) { + __extends(ModuleNameModuleReference, _super); + function ModuleNameModuleReference(moduleName) { + _super.call(this); + this.moduleName = moduleName; + moduleName && (moduleName.parent = this); + } + ModuleNameModuleReference.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + return ModuleNameModuleReference; + })(AST); + TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(modifiers, identifier, moduleReference) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.moduleReference = moduleReference; + identifier && (identifier.parent = this); + moduleReference && (moduleReference.parent = this); + } + ImportDeclaration.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(identifier) { + _super.call(this); + this.identifier = identifier; + identifier && (identifier.parent = this); + } + ExportAssignment.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var TypeParameterList = (function (_super) { + __extends(TypeParameterList, _super); + function TypeParameterList(typeParameters) { + _super.call(this); + this.typeParameters = typeParameters; + typeParameters && (typeParameters.parent = this); + } + TypeParameterList.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + return TypeParameterList; + })(AST); + TypeScript.TypeParameterList = TypeParameterList; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + heritageClauses && (heritageClauses.parent = this); + classElements && (classElements.parent = this); + } + ClassDeclaration.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return ClassDeclaration; + })(AST); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + body && (body.parent = this); + heritageClauses && (heritageClauses.parent = this); + } + InterfaceDeclaration.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return InterfaceDeclaration; + })(AST); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var HeritageClause = (function (_super) { + __extends(HeritageClause, _super); + function HeritageClause(_nodeType, typeNames) { + _super.call(this); + this._nodeType = _nodeType; + this.typeNames = typeNames; + typeNames && (typeNames.parent = this); + } + HeritageClause.prototype.kind = function () { + return this._nodeType; + }; + + HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); + }; + return HeritageClause; + })(AST); + TypeScript.HeritageClause = HeritageClause; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { + _super.call(this); + this.modifiers = modifiers; + this.name = name; + this.stringLiteral = stringLiteral; + this.moduleElements = moduleElements; + this.endingToken = endingToken; + name && (name.parent = this); + stringLiteral && (stringLiteral.parent = this); + moduleElements && (moduleElements.parent = this); + } + ModuleDeclaration.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(modifiers, identifier, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionDeclaration.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(modifiers, declaration) { + _super.call(this); + this.modifiers = modifiers; + this.declaration = declaration; + declaration && (declaration.parent = this); + } + VariableStatement.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + declarators && (declarators.parent = this); + } + VariableDeclaration.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + VariableDeclarator.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + return VariableDeclarator; + })(AST); + TypeScript.VariableDeclarator = VariableDeclarator; + + var EqualsValueClause = (function (_super) { + __extends(EqualsValueClause, _super); + function EqualsValueClause(value) { + _super.call(this); + this.value = value; + value && (value.parent = this); + } + EqualsValueClause.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + return EqualsValueClause; + })(AST); + TypeScript.EqualsValueClause = EqualsValueClause; + + var PrefixUnaryExpression = (function (_super) { + __extends(PrefixUnaryExpression, _super); + function PrefixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PrefixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ArrayLiteralExpression = (function (_super) { + __extends(ArrayLiteralExpression, _super); + function ArrayLiteralExpression(expressions) { + _super.call(this); + this.expressions = expressions; + expressions && (expressions.parent = this); + } + ArrayLiteralExpression.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + 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; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + 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; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(openParenTrailingComments, expression) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.expression = expression; + expression && (expression.parent = this); + } + ParenthesizedExpression.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + 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; + + var SimpleArrowFunctionExpression = (function (_super) { + __extends(SimpleArrowFunctionExpression, _super); + function SimpleArrowFunctionExpression(identifier, block, expression) { + _super.call(this); + this.identifier = identifier; + this.block = block; + this.expression = expression; + identifier && (identifier.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + SimpleArrowFunctionExpression.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return SimpleArrowFunctionExpression; + })(AST); + TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; + + var ParenthesizedArrowFunctionExpression = (function (_super) { + __extends(ParenthesizedArrowFunctionExpression, _super); + function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + this.expression = expression; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + ParenthesizedArrowFunctionExpression.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return ParenthesizedArrowFunctionExpression; + })(AST); + TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; + + var QualifiedName = (function (_super) { + __extends(QualifiedName, _super); + function QualifiedName(left, right) { + _super.call(this); + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + QualifiedName.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedName.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); + }; + return QualifiedName; + })(AST); + TypeScript.QualifiedName = QualifiedName; + + var ParameterList = (function (_super) { + __extends(ParameterList, _super); + function ParameterList(openParenTrailingComments, parameters) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.parameters = parameters; + parameters && (parameters.parent = this); + } + ParameterList.prototype.kind = function () { + return 227 /* ParameterList */; + }; + return ParameterList; + })(AST); + TypeScript.ParameterList = ParameterList; + + var ConstructorType = (function (_super) { + __extends(ConstructorType, _super); + function ConstructorType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + ConstructorType.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + return ConstructorType; + })(AST); + TypeScript.ConstructorType = ConstructorType; + + var FunctionType = (function (_super) { + __extends(FunctionType, _super); + function FunctionType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + FunctionType.prototype.kind = function () { + return 123 /* FunctionType */; + }; + return FunctionType; + })(AST); + TypeScript.FunctionType = FunctionType; + + var ObjectType = (function (_super) { + __extends(ObjectType, _super); + function ObjectType(typeMembers) { + _super.call(this); + this.typeMembers = typeMembers; + typeMembers && (typeMembers.parent = this); + } + ObjectType.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); + }; + return ObjectType; + })(AST); + TypeScript.ObjectType = ObjectType; + + var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + ArrayType.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); + }; + return ArrayType; + })(AST); + TypeScript.ArrayType = ArrayType; + + var TypeArgumentList = (function (_super) { + __extends(TypeArgumentList, _super); + function TypeArgumentList(typeArguments) { + _super.call(this); + this.typeArguments = typeArguments; + typeArguments && (typeArguments.parent = this); + } + TypeArgumentList.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + return TypeArgumentList; + })(AST); + TypeScript.TypeArgumentList = TypeArgumentList; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArgumentList) { + _super.call(this); + this.name = name; + this.typeArgumentList = typeArgumentList; + name && (name.parent = this); + typeArgumentList && (typeArgumentList.parent = this); + } + GenericType.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + name && (name.parent = this); + } + TypeQuery.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceLeadingComments, closeBraceToken) { + _super.call(this); + this.statements = statements; + this.closeBraceLeadingComments = closeBraceLeadingComments; + this.closeBraceToken = closeBraceToken; + statements && (statements.parent = this); + } + Block.prototype.kind = function () { + return 146 /* Block */; + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + _super.call(this); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + Parameter.prototype.kind = function () { + return 242 /* Parameter */; + }; + return Parameter; + })(AST); + TypeScript.Parameter = Parameter; + + var MemberAccessExpression = (function (_super) { + __extends(MemberAccessExpression, _super); + function MemberAccessExpression(expression, name) { + _super.call(this); + this.expression = expression; + this.name = name; + expression && (expression.parent = this); + name && (name.parent = this); + } + MemberAccessExpression.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + 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; + + var PostfixUnaryExpression = (function (_super) { + __extends(PostfixUnaryExpression, _super); + function PostfixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PostfixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ElementAccessExpression = (function (_super) { + __extends(ElementAccessExpression, _super); + function ElementAccessExpression(expression, argumentExpression) { + _super.call(this); + this.expression = expression; + this.argumentExpression = argumentExpression; + expression && (expression.parent = this); + argumentExpression && (argumentExpression.parent = this); + } + ElementAccessExpression.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + 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; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + InvocationExpression.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + 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) { + _super.call(this); + this.typeArgumentList = typeArgumentList; + this.closeParenToken = closeParenToken; + this.arguments = _arguments; + + typeArgumentList && (typeArgumentList.parent = this); + _arguments && (_arguments.parent = this); + } + ArgumentList.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + return ArgumentList; + })(AST); + TypeScript.ArgumentList = ArgumentList; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, left, right) { + _super.call(this); + this._nodeType = _nodeType; + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + BinaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(condition, whenTrue, whenFalse) { + _super.call(this); + this.condition = condition; + this.whenTrue = whenTrue; + this.whenFalse = whenFalse; + condition && (condition.parent = this); + whenTrue && (whenTrue.parent = this); + whenFalse && (whenFalse.parent = this); + } + ConditionalExpression.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + 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; + + var ConstructSignature = (function (_super) { + __extends(ConstructSignature, _super); + function ConstructSignature(callSignature) { + _super.call(this); + this.callSignature = callSignature; + callSignature && (callSignature.parent = this); + } + ConstructSignature.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + return ConstructSignature; + })(AST); + TypeScript.ConstructSignature = ConstructSignature; + + var MethodSignature = (function (_super) { + __extends(MethodSignature, _super); + function MethodSignature(propertyName, questionToken, callSignature) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + } + MethodSignature.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + return MethodSignature; + })(AST); + TypeScript.MethodSignature = MethodSignature; + + var IndexSignature = (function (_super) { + __extends(IndexSignature, _super); + function IndexSignature(parameter, typeAnnotation) { + _super.call(this); + this.parameter = parameter; + this.typeAnnotation = typeAnnotation; + parameter && (parameter.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + IndexSignature.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + return IndexSignature; + })(AST); + TypeScript.IndexSignature = IndexSignature; + + var PropertySignature = (function (_super) { + __extends(PropertySignature, _super); + function PropertySignature(propertyName, questionToken, typeAnnotation) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + PropertySignature.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + return PropertySignature; + })(AST); + TypeScript.PropertySignature = PropertySignature; + + var CallSignature = (function (_super) { + __extends(CallSignature, _super); + function CallSignature(typeParameterList, parameterList, typeAnnotation) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + CallSignature.prototype.kind = function () { + return 142 /* CallSignature */; + }; + return CallSignature; + })(AST); + TypeScript.CallSignature = CallSignature; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(identifier, constraint) { + _super.call(this); + this.identifier = identifier; + this.constraint = constraint; + identifier && (identifier.parent = this); + constraint && (constraint.parent = this); + } + TypeParameter.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + Constraint.prototype.kind = function () { + return 239 /* Constraint */; + }; + return Constraint; + })(AST); + TypeScript.Constraint = Constraint; + + var ElseClause = (function (_super) { + __extends(ElseClause, _super); + function ElseClause(statement) { + _super.call(this); + this.statement = statement; + statement && (statement.parent = this); + } + ElseClause.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ElseClause; + })(AST); + TypeScript.ElseClause = ElseClause; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(condition, statement, elseClause) { + _super.call(this); + this.condition = condition; + this.statement = statement; + this.elseClause = elseClause; + condition && (condition.parent = this); + statement && (statement.parent = this); + elseClause && (elseClause.parent = this); + } + IfStatement.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ExpressionStatement.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var ConstructorDeclaration = (function (_super) { + __extends(ConstructorDeclaration, _super); + function ConstructorDeclaration(callSignature, block) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + ConstructorDeclaration.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + return ConstructorDeclaration; + })(AST); + TypeScript.ConstructorDeclaration = ConstructorDeclaration; + + var MemberFunctionDeclaration = (function (_super) { + __extends(MemberFunctionDeclaration, _super); + function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + MemberFunctionDeclaration.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + return MemberFunctionDeclaration; + })(AST); + TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; + + var GetAccessor = (function (_super) { + __extends(GetAccessor, _super); + function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + GetAccessor.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + return GetAccessor; + })(AST); + TypeScript.GetAccessor = GetAccessor; + + var SetAccessor = (function (_super) { + __extends(SetAccessor, _super); + function SetAccessor(modifiers, propertyName, parameterList, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + block && (block.parent = this); + } + SetAccessor.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + return SetAccessor; + })(AST); + TypeScript.SetAccessor = SetAccessor; + + var MemberVariableDeclaration = (function (_super) { + __extends(MemberVariableDeclaration, _super); + function MemberVariableDeclaration(modifiers, variableDeclarator) { + _super.call(this); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + variableDeclarator && (variableDeclarator.parent = this); + } + MemberVariableDeclaration.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + return MemberVariableDeclaration; + })(AST); + TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; + + var IndexMemberDeclaration = (function (_super) { + __extends(IndexMemberDeclaration, _super); + function IndexMemberDeclaration(indexSignature) { + _super.call(this); + this.indexSignature = indexSignature; + indexSignature && (indexSignature.parent = this); + } + IndexMemberDeclaration.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + return IndexMemberDeclaration; + })(AST); + TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ThrowStatement.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ReturnStatement.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + ObjectCreationExpression.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + 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; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(expression, closeParenToken, switchClauses) { + _super.call(this); + this.expression = expression; + this.closeParenToken = closeParenToken; + this.switchClauses = switchClauses; + expression && (expression.parent = this); + switchClauses && (switchClauses.parent = this); + } + SwitchStatement.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseSwitchClause = (function (_super) { + __extends(CaseSwitchClause, _super); + function CaseSwitchClause(expression, statements) { + _super.call(this); + this.expression = expression; + this.statements = statements; + expression && (expression.parent = this); + statements && (statements.parent = this); + } + CaseSwitchClause.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return CaseSwitchClause; + })(AST); + TypeScript.CaseSwitchClause = CaseSwitchClause; + + var DefaultSwitchClause = (function (_super) { + __extends(DefaultSwitchClause, _super); + function DefaultSwitchClause(statements) { + _super.call(this); + this.statements = statements; + statements && (statements.parent = this); + } + DefaultSwitchClause.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return DefaultSwitchClause; + })(AST); + TypeScript.DefaultSwitchClause = DefaultSwitchClause; + + var BreakStatement = (function (_super) { + __extends(BreakStatement, _super); + function BreakStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + BreakStatement.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return BreakStatement; + })(AST); + TypeScript.BreakStatement = BreakStatement; + + var ContinueStatement = (function (_super) { + __extends(ContinueStatement, _super); + function ContinueStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + ContinueStatement.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ContinueStatement; + })(AST); + TypeScript.ContinueStatement = ContinueStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.condition = condition; + this.incrementor = incrementor; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + initializer && (initializer.parent = this); + condition && (condition.parent = this); + incrementor && (incrementor.parent = this); + statement && (statement.parent = this); + } + ForStatement.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(variableDeclaration, left, expression, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.left = left; + this.expression = expression; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + left && (left.parent = this); + expression && (expression.parent = this); + statement && (statement.parent = this); + } + ForInStatement.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WhileStatement.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WithStatement.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var EnumDeclaration = (function (_super) { + __extends(EnumDeclaration, _super); + function EnumDeclaration(modifiers, identifier, enumElements) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.enumElements = enumElements; + identifier && (identifier.parent = this); + enumElements && (enumElements.parent = this); + } + EnumDeclaration.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + return EnumDeclaration; + })(AST); + TypeScript.EnumDeclaration = EnumDeclaration; + + var EnumElement = (function (_super) { + __extends(EnumElement, _super); + function EnumElement(propertyName, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + EnumElement.prototype.kind = function () { + return 243 /* EnumElement */; + }; + return EnumElement; + })(AST); + TypeScript.EnumElement = EnumElement; + + var CastExpression = (function (_super) { + __extends(CastExpression, _super); + function CastExpression(type, expression) { + _super.call(this); + this.type = type; + this.expression = expression; + type && (type.parent = this); + expression && (expression.parent = this); + } + CastExpression.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + 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; + + var ObjectLiteralExpression = (function (_super) { + __extends(ObjectLiteralExpression, _super); + function ObjectLiteralExpression(propertyAssignments) { + _super.call(this); + this.propertyAssignments = propertyAssignments; + propertyAssignments && (propertyAssignments.parent = this); + } + ObjectLiteralExpression.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + 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; + + var SimplePropertyAssignment = (function (_super) { + __extends(SimplePropertyAssignment, _super); + function SimplePropertyAssignment(propertyName, expression) { + _super.call(this); + this.propertyName = propertyName; + this.expression = expression; + propertyName && (propertyName.parent = this); + expression && (expression.parent = this); + } + SimplePropertyAssignment.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + return SimplePropertyAssignment; + })(AST); + TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; + + var FunctionPropertyAssignment = (function (_super) { + __extends(FunctionPropertyAssignment, _super); + function FunctionPropertyAssignment(propertyName, callSignature, block) { + _super.call(this); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionPropertyAssignment.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + return FunctionPropertyAssignment; + })(AST); + TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; + + var FunctionExpression = (function (_super) { + __extends(FunctionExpression, _super); + function FunctionExpression(identifier, callSignature, block) { + _super.call(this); + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionExpression.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; + return FunctionExpression; + })(AST); + TypeScript.FunctionExpression = FunctionExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(block, catchClause, finallyClause) { + _super.call(this); + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + block && (block.parent = this); + catchClause && (catchClause.parent = this); + finallyClause && (finallyClause.parent = this); + } + TryStatement.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(identifier, typeAnnotation, block) { + _super.call(this); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.block = block; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + CatchClause.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var FinallyClause = (function (_super) { + __extends(FinallyClause, _super); + function FinallyClause(block) { + _super.call(this); + this.block = block; + block && (block.parent = this); + } + FinallyClause.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return FinallyClause; + })(AST); + TypeScript.FinallyClause = FinallyClause; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + identifier && (identifier.parent = this); + statement && (statement.parent = this); + } + LabeledStatement.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(statement, whileKeyword, condition) { + _super.call(this); + this.statement = statement; + this.whileKeyword = whileKeyword; + this.condition = condition; + statement && (statement.parent = this); + condition && (condition.parent = this); + } + DoStatement.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var TypeOfExpression = (function (_super) { + __extends(TypeOfExpression, _super); + function TypeOfExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + TypeOfExpression.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + 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; + + var DeleteExpression = (function (_super) { + __extends(DeleteExpression, _super); + function DeleteExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + DeleteExpression.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + 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; + + var VoidExpression = (function (_super) { + __extends(VoidExpression, _super); + function VoidExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + VoidExpression.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + 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; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var Comment = (function () { + function Comment(_trivia, endsLine, _start, _end) { + this._trivia = _trivia; + this.endsLine = endsLine; + this._start = _start; + this._end = _end; + } + Comment.prototype.start = function () { + return this._start; + }; + + Comment.prototype.end = function () { + return this._end; + }; + + Comment.prototype.fullText = function () { + return this._trivia.fullText(); + }; + + Comment.prototype.kind = function () { + return this._trivia.kind(); + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; + }; + return Comment; + })(); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); From fae603cd10471296df66ed6d33442cffa87366ca Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 25 Feb 2014 11:16:53 +0900 Subject: [PATCH 192/240] Modified the version of TypeScript in test runner (0.9.7-66c2df) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5cbbac47de..46226fb2da 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.7-59a846" + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7-66c2df" } } From 309b6d144422247aa566119a466fc7f70891ec83 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 25 Feb 2014 01:24:46 +0100 Subject: [PATCH 193/240] Fixed lazy.js module export --- lazy.js/lazy.js.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lazy.js/lazy.js.d.ts b/lazy.js/lazy.js.d.ts index baba46a461..47925bdf94 100644 --- a/lazy.js/lazy.js.d.ts +++ b/lazy.js/lazy.js.d.ts @@ -242,3 +242,7 @@ declare module LazyJS { declare var Lazy:LazyJS.LazyStatic; +declare module 'lazy.js' { +export = Lazy; +} + From 73428e95c0a99d37fddd1e1907a501784209be5d Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 25 Feb 2014 01:47:26 +0100 Subject: [PATCH 194/240] Created definitions for highland.js "The high-level streams library" http://highlandjs.org/ Known limitations: stream-methods not exported on module --- README.md | 1 + highland/highland-tests.ts | 354 +++++++++ highland/highland.d.ts | 1394 ++++++++++++++++++++++++++++++++++++ 3 files changed, 1749 insertions(+) create mode 100644 highland/highland-tests.ts create mode 100644 highland/highland.d.ts diff --git a/README.md b/README.md index 11e46c7cde..509da1a3d2 100755 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ List of Definitions * [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home)) * [Hashtable](http://www.timdown.co.uk/jshashtable/) (by [Sergey Gerasimov](https://github.com/gerich-home)) * [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) +* [Highland](http://highlandjs.org/) (by [Bart van der Schoor](https://github.com/Bartvds/)) * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) * [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) * [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn)) diff --git a/highland/highland-tests.ts b/highland/highland-tests.ts new file mode 100644 index 0000000000..3f885a2bc7 --- /dev/null +++ b/highland/highland-tests.ts @@ -0,0 +1,354 @@ +/// + +// Note: try to maintain the ordering and separators + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +import _ = require('highland'); + +var obj: Object; +var err: Error; +var bool: boolean; +var num; +var str: string; +var x: any; +var f: Function; +var fn; +var func: Function; +var arr: any[]; +var exp: RegExp; +var anyArr: any[]; +var strArr: string[]; +var numArr: string[]; +var funcArr: Function[]; + +// - - - - - - - - - - - - - - - - - + +var value: any; +var reason: any; +var insanity: any; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +var numStream: Highland.Stream; +var strStream: Highland.Stream; +var anyStream: Highland.Stream; +var boolStream: Highland.Stream; +var objStream: Highland.Stream; +var voidStream: Highland.Stream; + +// - - - - - - - - - - - - - - - - - + +var anyArrStream: Highland.Stream; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +interface Foo { + foo(): string; +} +interface Bar { + bar(): string; +} + +interface StrFooArrMap { + [key:string]: Foo[]; +} + +interface StrBarArrMap { + [key:string]: Bar[]; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +var foo: Foo; +var bar: Bar; + +var fooArr: Foo[]; +var barArr: Bar[]; + +var fooStream: Highland.Stream; +var barStream: Highland.Stream; + +var fooArrStream: Highland.Stream; +var barArrStream: Highland.Stream; + +var fooStreamArr: Highland.Stream[]; +var barStreamArr: Highland.Stream[]; + +var fooStreamArr: Highland.Stream[]; +var barStreamArr: Highland.Stream[]; + +var strFooArrMapStream: Highland.Stream; +var strBarArrMapStream: Highland.Stream; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// curries +var objCurStr: (obj: Object) => string; +var objCurObj: (obj: Object) => Object; +var objCurAny: (obj: Object) => any; +var numCurNum: (num) => number; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +var steamError: Highland.StreamError; +var streamRedirect: Highland.StreamRedirect; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/* + interface Highland { + + (xs: R[]): Highland.Stream; + (xs: (push: (err:Error, x?:R) => void, next:() => void) => void): Highland.Stream; + (xs: Highland.Stream): Highland.Stream; + + (xs: ReadableStream): Highland.Stream; + (xs: NodeEventEmitter): Highland.Stream; + + (xs: Thenable): Highland.Stream; + (xs: Thenable>): Highland.Stream; + + (): Highland.Stream; + } + + fooStream = _([1, 2, 3]); + */ + +obj = _.nil; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +f = _.curry(fn, foo); +f = _.curry(fn, foo, bar); + +f = _.ncurry(num, fn, foo); +f = _.ncurry(num, fn, foo, bar); + +f = _.partial(f, foo); +f = _.partial(f, foo, bar); + +f = _.flip(fn, foo); +f = _.flip(fn, foo, bar); + +f = _.compose(f); +f = _.compose(f, f); + +f = _.seq(f); +f = _.seq(f, f); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +steamError = new Highland.StreamError(err); +err = steamError.error; + +streamRedirect = new Highland.StreamRedirect(fooStream); +fooStream = streamRedirect.to; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +bool = _.isStream(x); +bool = _.isStream(fooStream); + +bool = _.isStreamError(x); +bool = _.isStreamError(fooStream); + +bool = _.isStreamRedirect(x); +bool = _.isStreamRedirect(fooStream); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream.pause(); +fooStream.resume(); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream.end(); + +fooStream = fooStream.pipe(fooStream); + +fooStream.destroy(); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +barStream = fooStream.consume((err: Error, x: Foo, push: (err: Error, value?: Bar) => void, next: () => void) => { + push(err); + push(null, bar); + next(); +}); + +fooStream.pull((err: Error, x: Foo) => { + +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +bool = fooStream.write(foo); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream = fooStream.fork(); + +fooStream = fooStream.observe(); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream = fooStream.errors((err: Error, push: (e: Error, x?: Foo) => void) => { + push(err); + push(null, x); + push(null, foo); +}); + +fooStream = fooStream.stopOnError((e: Error) => { + +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream.each((x: Foo) => { + +}); + +fooStream.apply(func); + +fooStream.toArray((arr: Foo[]) => { + +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +barStream = fooStream.map((x: Foo) => { + return bar; +}); + +barStream = fooStream.flatMap((x: Foo) => { + return barStream; +}); + +barStream = fooStream.flatMap((x: Foo) => { + return bar; +}); + +barStream = fooStream.pluck(str); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream = fooStream.filter((x: Foo) => { + return bool; +}); + +fooStream = fooStream.flatFilter((x: Foo) => { + return boolStream; +}); + +fooStream = fooStream.find((x: Foo) => { + return bool; +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +strFooArrMapStream = fooStream.group((x: Foo) => { + return str; +}); +strFooArrMapStream = fooStream.group(str); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream = fooStream.compact(); + +fooStream = fooStream.where(obj); + +fooStream = fooStream.zip(fooStream); +fooStream = fooStream.zip([foo, foo]); + +fooStream = fooStream.take(num); + +fooStream = fooStream.last(); + +barStream = fooStream.sequence(); + +barStream = fooStream.series(); + +barStream = fooStream.flatten(); + +fooStream = fooStream.parallel(num); + +fooStream = fooStream.otherwise(fooStream); + +fooStream = fooStream.append(foo); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +barStream = fooStream.reduce(bar, (memo: Bar, x: Foo) => { + return memo; +}); + +barStream = fooStream.reduce1(bar, (memo: Bar, x: Foo) => { + return memo; +}); + +fooArrStream = fooStream.collect(); + +barStream = fooStream.scan(bar, (memo: Bar, x: Foo) => { + return memo; +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream = fooStream.concat(fooStream); + +fooStream = fooStream.concat(fooArr); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +barStream = fooStream.invoke(str, anyArr); + +fooStream = fooStream.throttle(num); + +fooStream = fooStream.debounce(num); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream = fooStream.latest(); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +anyStream = _.values(obj); +fooStream = _.values(fooArr); + +strStream = _.keys(obj); + +anyArrStream = _.pairs(obj); +anyArrStream = _.pairs(fooArr); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +obj = _.extend(obj, obj); + +objCurObj = _.extend(obj); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +x = _.get(str, obj); + +objCurObj = _.get(str); + +obj = _.set(str, foo, obj); + +objCurAny = _.set(str, foo); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +_.log(str); +_.log(str, num, foo); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +f = _.wrapCallback(func); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +num = _.add(num, num); + +numCurNum = _.add(num); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/highland/highland.d.ts b/highland/highland.d.ts new file mode 100644 index 0000000000..1306811044 --- /dev/null +++ b/highland/highland.d.ts @@ -0,0 +1,1394 @@ +// Type definitions for Highland 1.14.0 +// Project: http://highlandjs.org/ +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +// Note: make sure to updated both the module and instance methods + +// TODO figure out curry arguments +// TODO use externalised Thenable + +// TODO export module functions + +/** + * Highland: the high-level streams library + * + * Highland may be freely distributed under the Apache 2.0 license. + * http://github.com/caolan/highland + * Copyright (c) Caolan McMahon + * + */ + +/** + * The Stream constructor, accepts an array of values or a generator function + * as an optional argument. This is typically the entry point to the Highland + * APIs, providing a convenient way of chaining calls together. + * + * **Arrays -** Streams created from Arrays will emit each value of the Array + * and then emit a [nil](#nil) value to signal the end of the Stream. + * + * **Generators -** These are functions which provide values for the Stream. + * They are lazy and can be infinite, they can also be asynchronous (for + * example, making a HTTP request). You emit values on the Stream by calling + * `push(err, val)`, much like a standard Node.js callback. You call `next()` + * to signal you've finished processing the current data. If the Stream is + * still being consumed the generator function will then be called again. + * + * You can also redirect a generator Stream by passing a new source Stream + * to read from to next. For example: `next(other_stream)` - then any subsequent + * calls will be made to the new source. + * + * **Node Readable Stream -** Pass in a Node Readable Stream object to wrap + * it with the Highland API. Reading from the resulting Highland Stream will + * begin piping the data from the Node Stream to the Highland Stream. + * + * **EventEmitter / jQuery Elements -** Pass in both an event name and an + * event emitter as the two arguments to the constructor and the first + * argument emitted to the event handler will be written to the new Stream. + * + * **Promise -** Accepts an ES6 / jQuery style promise and returns a + * Highland Stream which will emit a single value (or an error). + * + * @id _(source) + * @section Streams + * @name _(source) + * @param {Array | Function | Readable Stream | Promise} source - (optional) source to take values from from + * @api public + * + * // from an Array + * _([1, 2, 3, 4]); + * + * // using a generator function + * _(function (push, next) { + * push(null, 1); + * push(err); + * next(); + * }); + * + * // a stream with no source, can pipe node streams through it etc. + * var through = _(); + * + * // wrapping a Node Readable Stream so you can easily manipulate it + * _(readable).filter(hasSomething).pipe(writeable); + * + * // creating a stream from events + * _('click', btn).each(handleEvent); + * + * // from a Promise object + * var foo = _($.getJSON('/api/foo')); + */ +declare function Highland(): Highland.Stream; +declare function Highland(xs: R[]): Highland.Stream; +declare function Highland(xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream; +declare function Highland(xs: Highland.Stream): Highland.Stream; + +declare function Highland(xs: ReadableStream): Highland.Stream; +declare function Highland(xs: NodeEventEmitter): Highland.Stream; + +declare function Highland(xs: Highland.Thenable>): Highland.Stream; +declare function Highland(xs: Highland.Thenable): Highland.Stream; + +declare module Highland { + + interface Thenable { + then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; + then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; + } + + /** + * The end of stream marker. This is sent along the data channel of a Stream + * to tell consumers that the Stream has ended. See the following map code for + * an example of detecting the end of a Stream: + * + * @id nil + * @section Streams + * @name _.nil + * @api public + * + * var map(iter, source) { + * return source.consume(function (err, val, push, next) { + * if (err) { + * push(err); + * next(); + * } + * else if (val === _.nil) { + * push(null, val); + * } + * else { + * push(null, iter(val)); + * next(); + * } + * }); + * }; + */ + var nil: Nil; + + // hacky unique + // TODO do we need this? + interface Nil { + Highland_NIL: Nil; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Transforms a function with specific arity (all arguments must be + * defined) in a way that it can be called as a chain of functions until + * the arguments list is saturated. + * + * This function is not itself curryable. + * + * @id curry + * @name curry(fn, [*arguments]) + * @section Functions + * @param {Function} fn - the function to curry + * @param args.. - any number of arguments to pre-apply to the function + * @returns Function + * @api public + * + * fn = curry(function (a, b, c) { + * return a + b + c; + * }); + * + * fn(1)(2)(3) == fn(1, 2, 3) + * fn(1, 2)(3) == fn(1, 2, 3) + * fn(1)(2, 3) == fn(1, 2, 3) + */ + function curry(fn: Function, ...args: any[]): Function; + + /** + * Same as `curry` but with a specific number of arguments. This can be + * useful when functions do not explicitly define all its parameters. + * + * This function is not itself curryable. + * + * @id ncurry + * @name ncurry(n, fn, [args...]) + * @section Functions + * @param {Number} n - the number of arguments to wait for before apply fn + * @param {Function} fn - the function to curry + * @param args... - any number of arguments to pre-apply to the function + * @returns Function + * @api public + * + * fn = ncurry(3, function () { + * return Array.prototype.join.call(arguments, '.'); + * }); + * + * fn(1, 2, 3) == '1.2.3'; + * fn(1, 2)(3) == '1.2.3'; + * fn(1)(2)(3) == '1.2.3'; + */ + function ncurry(n: number, fn: Function, ...args: any[]): Function; + + /** + * Partially applies the function (regardless of whether it has had curry + * called on it). This will always postpone execution until at least the next + * call of the partially applied function. + * + * @id partial + * @name partial(fn, args...) + * @section Functions + * @param {Function} fn - function to partial apply + * @param args... - the arguments to apply to the function + * @api public + * + * var addAll = function () { + * var args = Array.prototype.slice.call(arguments); + * return foldl1(add, args); + * }; + * var f = partial(addAll, 1, 2); + * f(3, 4) == 10 + */ + function partial(f: Function, ...args: any[]): Function; + + /** + * Evaluates the function `fn` with the argument positions swapped. Only + * works with functions that accept two arguments. + * + * @id flip + * @name flip(fn, [x, y]) + * @section Functions + * @param {Function} f - function to flip argument application for + * @param x - parameter to apply to the right hand side of f + * @param y - parameter to apply to the left hand side of f + * @api public + * + * div(2, 4) == 0.5 + * flip(div, 2, 4) == 2 + * flip(div)(2, 4) == 2 + */ + function flip(fn: Function, ...args: any[]): Function; + + /** + * Creates a composite function, which is the application of function1 to + * the results of function2. You can pass an arbitrary number of arguments + * and have them composed. This means you can't partially apply the compose + * function itself. + * + * @id compose + * @name compose(fn1, fn2, ...) + * @section Functions + * @api public + * + * var add1 = add(1); + * var mul3 = mul(3); + * + * var add1mul3 = compose(mul3, add1); + * add1mul3(2) == 9 + */ + function compose(...functions: Function[]): Function; + + /** + * The reversed version of compose. Where arguments are in the order of + * application. + * + * @id seq + * @name seq(fn1, fn2, ...) + * @section Functions + * @api public + * + * var add1 = add(1); + * var mul3 = mul(3); + * + * var add1mul3 = seq(add1, mul3); + * add1mul3(2) == 9 + */ + function seq(...functions: Function[]): Function; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Used as an Error marker when writing to a Stream's incoming buffer + */ + // TODO is this public? + class StreamError { + constructor(err: Error); + + error: Error; + } + + /** + * Used as a Redirect marker when writing to a Stream's incoming buffer + */ + // TODO is this public? + class StreamRedirect { + constructor(to: Stream) + + to: Stream; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Returns true if `x` is a Highland Stream. + * + * @id isStream + * @section Streams + * @name _.isStream(x) + * @param x - the object to test + * @api public + * + * _.isStream('foo') // => false + * _.isStream(_([1,2,3])) // => true + */ + function isStream(x: any): boolean; + + function isStreamError(x: any): boolean; + + function isStreamRedirect(x: any): boolean; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Actual Stream constructor wrapped the the main exported function + */ + interface Stream extends NodeEventEmitter { + + /** + * Pauses the stream. All Highland Streams start in the paused state. + * + * @id pause + * @section Streams + * @name Stream.pause() + * @api public + * + * var xs = _(generator); + * xs.pause(); + */ + pause(): void; + + /** + * Resumes a paused Stream. This will either read from the Stream's incoming + * buffer or request more data from an upstream source. + * + * @id resume + * @section Streams + * @name Stream.resume() + * @api public + * + * var xs = _(generator); + * xs.resume(); + */ + resume(): void; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Ends a Stream. This is the same as sending a [nil](#nil) value as data. + * You shouldn't need to call this directly, rather it will be called by + * any [Node Readable Streams](http://nodejs.org/api/stream.html#stream_class_stream_readable) + * you pipe in. + * + * @id end + * @section Streams + * @name Stream.end() + * @api public + * + * mystream.end(); + */ + end(): void; + + /** + * Pipes a Highland Stream to a [Node Writable Stream](http://nodejs.org/api/stream.html#stream_class_stream_writable) + * (Highland Streams are also Node Writable Streams). This will pull all the + * data from the source Highland Stream and write it to the destination, + * automatically managing flow so that the destination is not overwhelmed + * by a fast source. + * + * This function returns the destination so you can chain together pipe calls. + * + * @id pipe + * @section Streams + * @name Stream.pipe(dest) + * @param {Writable Stream} dest - the destination to write all data to + * @api public + * + * var source = _(generator); + * var dest = fs.createWriteStream('myfile.txt') + * source.pipe(dest); + * + * // chained call + * source.pipe(through).pipe(dest); + */ + pipe(dest: Stream): Stream; + pipe(dest: ReadWriteStream): Stream; + pipe(dest: WritableStream): void; + + /** + * Destroys a stream by unlinking it from any consumers and sources. This will + * stop all consumers from receiving events from this stream and removes this + * stream as a consumer of any source stream. + * + * This function calls end() on the stream and unlinks it from any piped-to streams. + * + * @id pipe + * @section Streams + * @name Stream.destroy() + * @api public + */ + destroy(): void; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Consumes values from a Stream (once resumed) and returns a new Stream for + * you to optionally push values onto using the provided push / next functions. + * + * This function forms the basis of many higher-level Stream operations. + * It will not cause a paused stream to immediately resume, but behaves more + * like a 'through' stream, handling values as they are read. + * + * @id consume + * @section Streams + * @name Stream.consume(f) + * @param {Function} f - the function to handle errors and values + * @api public + * + * var filter = function (f, source) { + * return source.consume(function (err, x, push, next) { + * if (err) { + * // pass errors along the stream and consume next value + * push(err); + * next(); + * } + * else if (x === _.nil) { + * // pass nil (end event) along the stream + * push(null, x); + * } + * else { + * // pass on the value only if the value passes the predicate + * if (f(x)) { + * push(null, x); + * } + * next(); + * } + * }); + * }; + */ + consume(f: (err: Error, x: R, push: (err: Error, value?: U) => void, next: () => void) => void): Stream; + + /** + * Consumes a single item from the Stream. Unlike consume, this function will + * not provide a new stream for you to push values onto, and it will unsubscribe + * as soon as it has a single error, value or nil from the source. + * + * You probably won't need to use this directly, but it is used internally by + * some functions in the Highland library. + * + * @id pull + * @section Streams + * @name Stream.pull(f) + * @param {Function} f - the function to handle data + * @api public + * + * xs.pull(function (err, x) { + * // do something + * }); + */ + pull(f: (err: Error, x: R) => void): void; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Writes a value to the Stream. If the Stream is paused it will go into the + * Stream's incoming buffer, otherwise it will be immediately processed and + * sent to the Stream's consumers (if any). Returns false if the Stream is + * paused, true otherwise. This lets Node's pipe method handle back-pressure. + * + * You shouldn't need to call this yourself, but it may be called by Node + * functions which treat Highland Streams as a [Node Writable Stream](http://nodejs.org/api/stream.html#stream_class_stream_writable). + * + * @id write + * @section Streams + * @name Stream.write(x) + * @param x - the value to write to the Stream + * @api public + * + * var xs = _(); + * xs.write(1); + * xs.write(2); + * xs.end(); + * + * xs.toArray(function (ys) { + * // ys will be [1, 2] + * }); + */ + write(x: R): boolean; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Forks a stream, allowing you to add additional consumers with shared + * back-pressure. A stream forked to multiple consumers will only pull values + * from it's source as fast as the slowest consumer can handle them. + * + * @id fork + * @section Streams + * @name Stream.fork() + * @api public + * + * var xs = _([1, 2, 3, 4]); + * var ys = xs.fork(); + * var zs = xs.fork(); + * + * // no values will be pulled from xs until zs also resume + * ys.resume(); + * + * // now both ys and zs will get values from xs + * zs.resume(); + */ + fork(): Stream; + + /** + * Observes a stream, allowing you to handle values as they are emitted, without + * adding back-pressure or causing data to be pulled from the source. This can + * be useful when you are performing two related queries on a stream where one + * would block the other. Just be aware that a slow observer could fill up it's + * buffer and cause memory issues. Where possible, you should use [fork](#fork). + * + * @id observe + * @section Streams + * @name Stream.observe() + * @api public + * + * var xs = _([1, 2, 3, 4]); + * var ys = xs.fork(); + * var zs = xs.observe(); + * + * // now both zs and ys will recieve data as fast as ys can handle it + * ys.resume(); + */ + observe(): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Extracts errors from a Stream and applies them to an error handler + * function. Returns a new Stream with the errors removed (unless the error + * handler chooses to rethrow them using `push`). Errors can also be + * transformed and put back onto the Stream as values. + * + * @id errors + * @section Streams + * @name Stream.errors(f) + * @param {Function} f - the function to pass all errors to + * @api public + * + * getDocument.errors(function (err, push) { + * if (err.statusCode === 404) { + * // not found, return empty doc + * push(null, {}); + * } + * else { + * // otherwise, re-throw the error + * push(err); + * } + * }); + */ + errors(f: (err: Error, push: (err: Error, x?: R) => void) => void): Stream; + + // function errors(f: (err: Error, push: (err: Error, x?: R) => void) => void): Stream; + + /** + * Like the [errors](#errors) method, but emits a Stream end marker after + * an Error is encountered. + * + * @id stopOnError + * @section Streams + * @name Stream.stopOnError(f) + * @param {Function} f - the function to handle an error + * @api public + * + * brokenStream.stopOnError(function (err) { + * console.error('Something broke: ' + err); + * }); + */ + stopOnError(f: (err: Error) => void): Stream; + + // function stopOnError(f: (err: Error) => void): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Iterates over every value from the Stream, calling the iterator function + * on each of them. This function causes a **thunk**. + * + * If an error from the Stream reaches the `each` call, it will emit an + * error event (which will cause it to throw if unhandled). + * + * @id each + * @section Streams + * @name Stream.each(f) + * @param {Function} f - the iterator function + * @api public + * + * _([1, 2, 3, 4]).each(function (x) { + * // will be called 4 times with x being 1, 2, 3 and 4 + * }); + */ + each(f: (x: R) => void): void; + + // function each(f: (x: R) => void): void; + + /** + * Applies results from a Stream as arguments to a function + * + * @id apply + * @section Streams + * @name Stream.apply(f) + * @param {Function} f - the function to apply arguments to + * @api public + * + * _([1, 2, 3]).apply(function (a, b, c) { + * // a === 1 + * // b === 2 + * // c === 3 + * }); + */ + // TODO what to do here? + apply(f: Function): void; + + //function apply(f:Function): Stream; + + /** + * Collects all values from a Stream into an Array and calls a function with + * once with the result. This function causes a **thunk**. + * + * If an error from the Stream reaches the `toArray` call, it will emit an + * error event (which will cause it to throw if unhandled). + * + * @id toArray + * @section Streams + * @name Stream.toArray(f) + * @param {Function} f - the callback to provide the completed Array to + * @api public + * + * _([1, 2, 3, 4]).each(function (x) { + * // will be called 4 times with x being 1, 2, 3 and 4 + * }); + */ + toArray(f: (arr: R[]) => void): void; + + //function toArray(f:(arr:any[]) => void): void; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Creates a new Stream of transformed values by applying a function to each + * value from the source. The transformation function can be replaced with + * a non-function value for convenience, and it will emit that value + * for every data event on the source Stream. + * + * @id map + * @section Streams + * @name Stream.map(f) + * @param f - the transformation function or value to map to + * @api public + * + * var doubled = _([1, 2, 3, 4]).map(function (x) { + * return x * 2; + * }); + * + * _([1, 2, 3]).map('hi') // => 'hi', 'hi', 'hi' + */ + map(f: (x: R) => U): Stream; + + //function map(f:(arr:any) => any): Stream; + + /** + * Creates a new Stream of values by applying each item in a Stream to an + * iterator function which may return a Stream. Each item on these result + * Streams are then emitted on a single output Stream. + * + * The same as calling `stream.map(f).flatten()`. + * + * @id flatMap + * @section Streams + * @name Stream.flatMap(f) + * @param {Function} f - the iterator function + * @api public + * + * filenames.flatMap(readFile) + */ + flatMap(f: (x: R) => Stream): Stream; + flatMap(f: (x: R) => U): Stream; + + // function flatMap(f:(arr:any) => any): Stream; + + /** + * Retrieves values associated with a given property from all elements in + * the collection. + * + * @id pluck + * @section Streams + * @name Stream.pluck(property) + * @param {String} prop - the property to which values should be associated + * @api public + * + * var docs = [ + * {type: 'blogpost', title: 'foo'}, + * {type: 'blogpost', title: 'bar'}, + * {type: 'comment', title: 'baz'} + * ]; + * + * _(docs).pluck('title').toArray(function (xs) { + * // xs is now ['foo', 'bar', 'baz'] + * }); + */ + // forced parametrise? + pluck(prop: string): Stream; + + // function pluck(prop:string): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Creates a new Stream including only the values which pass a truth test. + * + * @id filter + * @section Streams + * @name Stream.filter(f) + * @param f - the truth test function + * @api public + * + * var evens = _([1, 2, 3, 4]).filter(function (x) { + * return x % 2 === 0; + * }); + */ + filter(f: (x: R) => boolean): Stream; + + // function filter(f:(arr:any) => boolean): Stream; + + /** + * Filters using a predicate which returns a Stream. If you need to check + * against an asynchronous data source when filtering a Stream, this can + * be convenient. The Stream returned from the filter function should have + * a Boolean as it's first value (all other values on the Stream will be + * disregarded). + * + * @id flatFilter + * @section Streams + * @name Stream.flatFilter(f) + * @param {Function} f - the truth test function which returns a Stream + * @api public + * + * var checkExists = _.wrapCallback(fs.exists); + * filenames.flatFilter(checkExists) + */ + flatFilter(f: (x: R) => Stream): Stream; + + // function flatFilter(): Stream; + + /** + * A convenient form of filter, which returns the first object from a + * Stream that passes the provided truth test + * + * @id find + * @section Streams + * @name Stream.find(f) + * @param {Function} f - the truth test function which returns a Stream + * @api public + * + * var docs = [ + * {type: 'blogpost', title: 'foo'}, + * {type: 'blogpost', title: 'bar'}, + * {type: 'comment', title: 'foo'} + * ]; + * + * var f(x) { + * return x.type == 'blogpost'; + * }; + * + * _(docs).find(f); + * // => [{type: 'blogpost', title: 'foo'}] + * + * // example with partial application + * var firstBlogpost = _.find(f); + * + * firstBlogpost(docs) + * // => [{type: 'blogpost', title: 'foo'}] + */ + find(f: (x: R) => boolean): Stream; + + // function find(): Stream; + + /** + * A convenient form of reduce, which groups items based on a function or property name + * + * @id group + * @section Streams + * @name Stream.group(f) + * @param {Function|String} f - the function or property name on which to group, + * toString() is called on the result of a function. + * @api public + * + * var docs = [ + * {type: 'blogpost', title: 'foo'}, + * {type: 'blogpost', title: 'bar'}, + * {type: 'comment', title: 'foo'} + * ]; + * + * var f(x) { + * return x.type; + * }; + * + * _(docs).group(f); OR _(docs).group('type'); + * // => { + * // => 'blogpost': [{type: 'blogpost', title: 'foo'}, {type: 'blogpost', title: 'bar'}] + * // => 'comment': [{type: 'comment', title: 'foo'}] + * // => } + * + */ + // TODO verify this + group(f: (x: R) => string): Stream<{[prop:string]:R[]}>; + group(prop: string): Stream<{[prop:string]:R[]}>; + + // function group(): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Filters a Stream to drop all non-truthy values. + * + * @id compact + * @section Streams + * @name Stream.compact() + * @api public + * + * var compacted = _([0, 1, false, 3, null, undefined, 6]).compact(); + * // => [1, 3, 6] + */ + compact(): Stream; + + // function compact(): Stream; + + /** + * A convenient form of filter, which returns all objects from a Stream + * match a set of property values. + * + * @id where + * @section Streams + * @name Stream.where(props) + * @param {Object} props - the properties to match against + * @api public + * + * var docs = [ + * {type: 'blogpost', title: 'foo'}, + * {type: 'blogpost', title: 'bar'}, + * {type: 'comment', title: 'foo'} + * ]; + * + * _(docs).where({title: 'foo'}) + * // => {type: 'blogpost', title: 'foo'} + * // => {type: 'comment', title: 'foo'} + * + * // example with partial application + * var getBlogposts = _.where({type: 'blogpost'}); + * + * getBlogposts(docs) + * // => {type: 'blogpost', title: 'foo'} + * // => {type: 'blogpost', title: 'bar'} + */ + where(props: Object): Stream; + + // function where(): Stream; + + /** + * Takes two Streams and returns a Stream of corresponding pairs. + * + * @id zip + * @section Streams + * @name Stream.zip(ys) + * @param {Array | Stream} ys - the other stream to combine values with + * @api public + * + * _(['a', 'b', 'c']).zip([1, 2, 3]) // => ['a', 1], ['b', 2], ['c', 3] + */ + zip(ys: R[]): Stream; + zip(ys: Stream): Stream; + + // function zip(): Stream; + + /** + * Creates a new Stream with the first `n` values from the source. + * + * @id take + * @section Streams + * @name Stream.take(n) + * @param {Number} n - integer representing number of values to read from source + * @api public + * + * _([1, 2, 3, 4]).take(2) // => 1, 2 + */ + take(n: number): Stream; + + // function take(): Stream; + + /** + * Drops all values from the Stream apart from the last one (if any). + * + * @id last + * @section Streams + * @name Stream.last() + * @api public + * + * _([1, 2, 3, 4]).last() // => 4 + */ + last(): Stream; + + // function last(): Stream; + + /** + * Reads values from a Stream of Streams, emitting them on a Single output + * Stream. This can be thought of as a flatten, just one level deep. Often + * used for resolving asynchronous actions such as a HTTP request or reading + * a file. + * + * @id sequence + * @section Streams + * @name Stream.sequence() + * @api public + * + * var nums = _([ + * _([1, 2, 3]), + * _([4, 5, 6]) + * ]); + * + * nums.sequence() // => 1, 2, 3, 4, 5, 6 + * + * // using sequence to read from files in series + * filenames.map(readFile).sequence() + */ + //TODO figure out typing + sequence(): Stream; + + // function sequence(): Stream; + + /** + * An alias for the [sequence](#sequence) method. + * + * @id series + * @section Streams + * @name Stream.series() + * @api public + * + * filenames.map(readFile).series() + */ + // TODO figure out typing + series(): Stream; + + // function series = _.sequence; + + /** + * Recursively reads values from a Stream which may contain nested Streams + * or Arrays. As values or errors are encountered, they are emitted on a + * single output Stream. + * + * @id flatten + * @section Streams + * @name Stream.flatten() + * @api public + * + * _([1, [2, 3], [[4]]]).flatten(); // => 1, 2, 3, 4 + * + * var nums = _( + * _([1, 2, 3]), + * _([4, _([5, 6]) ]) + * ); + * + * nums.flatten(); // => 1, 2, 3, 4, 5, 6 + */ + flatten(): Stream; + flatten(): Stream; + + // function flatten(): Stream; + + /** + * Takes a Stream of Streams and reads from them in parallel, buffering + * the results until they can be returned to the consumer in their original + * order. + * + * @id parallel + * @section Streams + * @name Stream.parallel(n) + * @param {Number} n - the maximum number of concurrent reads/buffers + * @api public + * + * var readFile = _.wrapCallback(fs.readFile); + * var filenames = _(['foo.txt', 'bar.txt', 'baz.txt']); + * + * // read from up to 10 files at once + * filenames.map(readFile).parallel(10); + */ + parallel(n: number): Stream; + + // function parallel(): Stream; + + /** + * Switches source to an alternate Stream if the current Stream is empty. + * + * @id otherwise + * @section Streams + * @name Stream.otherwise(ys) + * @param {Stream} ys - alternate stream to use if this stream is empty + * @api public + * + * _([1,2,3]).otherwise(['foo']) // => 1, 2, 3 + * _([]).otherwise(['foo']) // => 'foo' + * + * _.otherwise(_(['foo']), _([1,2,3])) // => 1, 2, 3 + * _.otherwise(_(['foo']), _([])) // => 'foo' + */ + otherwise(ys: Stream): Stream; + + // function otherwise(): Stream; + + /** + * Adds a value to the end of a Stream. + * + * @id append + * @section Streams + * @name Stream.append(y) + * @param y - the value to append to the Stream + * @api public + * + * _([1, 2, 3]).append(4) // => 1, 2, 3, 4 + */ + append(y: R): Stream; + + // function append(): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Boils down a Stream to a single value. The memo is the initial state + * of the reduction, and each successive step of it should be returned by + * the iterator function. The iterator is passed two arguments: + * the memo and the next value. + * + * @id reduce + * @section Streams + * @name Stream.reduce(memo, iterator) + * @param memo - the initial state of the reduction + * @param {Function} iterator - the function which reduces the values + * @api public + * + * var add = function (a, b) { + * return a + b; + * }; + * + * _([1, 2, 3, 4]).reduce(0, add) // => 10 + */ + // TODO: convert this to this.scan(z, f).last() + reduce(memo: U, f: (memo: U, x: R) => U): Stream; + + // function reduce(): Stream; + + /** + * Same as [reduce](#reduce), but uses the first element as the initial + * state instead of passing in a `memo` value. + * + * @id reduce1 + * @section Streams + * @name Stream.reduce1(iterator) + * @param {Function} iterator - the function which reduces the values + * @api public + * + * _([1, 2, 3, 4]).reduce1(add) // => 10 + */ + reduce1(memo: U, f: (memo: U, x: R) => U): Stream; + + // function reduce1(): Stream; + + /** + * Groups all values into an Array and passes down the stream as a single + * data event. This is a bit like doing [toArray](#toArray), but instead + * of accepting a callback and causing a *thunk*, it passes the value on. + * + * @id collect + * @section Streams + * @name Stream.collect() + * @api public + * + * _(['foo', 'bar']).collect().toArray(function (xs) { + * // xs will be [['foo', 'bar']] + * }); + */ + collect(): Stream; + + // function collect(): Stream; + + /** + * Like [reduce](#reduce), but emits each intermediate value of the + * reduction as it is calculated. + * + * @id scan + * @section Streams + * @name Stream.scan(memo, iterator) + * @param memo - the initial state of the reduction + * @param {Function} iterator - the function which reduces the values + * @api public + * + * _([1, 2, 3, 4]).scan(0, add) // => 0, 1, 3, 6, 10 + */ + scan(memo: U, x: (memo: U, x: R) => U): Stream; + + //function scan(): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Concatenates a Stream to the end of this Stream. + * + * Be aware that in the top-level export, the args may be in the reverse + * order to what you'd expect `_([a], [b]) => [b, a]`, as this follows the + * convention of other top-level exported functions which do `x` to `y`. + * + * @id concat + * @section Streams + * @name Stream.concat(ys) + * @params {Stream | Array} ys - the values to concatenate onto this Stream + * @api public + * + * _([1, 2]).concat([3, 4]) // => 1, 2, 3, 4 + * _.concat([3, 4], [1, 2]) // => 1, 2, 3, 4 + */ + concat(ys: Stream): Stream; + concat(ys: R[]): Stream; + + // function concat(): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Calls a named method on each object from the Stream - returning + * a new stream with the result of those calls. + * + * @id invoke + * @section Streams + * @name Stream.invoke(method, args) + * @param {String} method - the method name to call + * @param {Array} args - the arguments to call the method with + * @api public + * + * _(['foo', 'bar']).invoke('toUpperCase', []) // => FOO, BAR + * + * filenames.map(readFile).sequence().invoke('toString', ['utf8']); + */ + invoke(method: string, args: any[]): Stream; + + // function invoke(): Stream; + + /** + * Ensures that only one data event is push downstream (or into the buffer) + * every `ms` milliseconds, any other values are dropped. + * + * @id throttle + * @section Streams + * @name Stream.throttle(ms) + * @param {Number} ms - the minimum milliseconds between each value + * @api public + * + * _('mousemove', document).throttle(1000); + */ + throttle(ms: number): Stream; + + // function throttle(ms:number): Stream; + + /** + * Holds off pushing data events downstream until there has been no more + * data for `ms` milliseconds. Sends the last value that occurred before + * the delay, discarding all other values. + * + * @id debounce + * @section Streams + * @name Stream.debounce(ms) + * @param {Number} ms - the milliseconds to wait before sending data + * @api public + * + * // sends last keyup event after user has stopped typing for 1 second + * $('keyup', textbox).debounce(1000); + */ + debounce(ms: number): Stream; + + // function debounce(ms:number): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Creates a new Stream, which when read from, only returns the last + * seen value from the source. The source stream does not experience + * back-pressure. Useful if you're using a Stream to model a changing + * property which you need to query periodically. + * + * @id latest + * @section Streams + * @name Stream.latest() + * @api public + * + * // slowThing will always get the last known mouse position + * // when it asks for more data from the mousePosition stream + * mousePosition.latest().map(slowThing) + */ + latest(): Stream; + + // function latest(): Stream; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Returns values from an Object as a Stream. Reads properties + * lazily, so if you don't read from all keys on an object, not + * all properties will be read from (may have an effect where getters + * are used). + * + * @id values + * @section Objects + * @name _.values(obj) + * @param {Object} obj - the object to return values from + * @api public + * + * _.values({foo: 1, bar: 2, baz: 3}) // => 1, 2, 3 + */ + function values(obj: Object): Stream; + + /** + * Returns keys from an Object as a Stream. + * + * @id keys + * @section Objects + * @name _.keys(obj) + * @param {Object} obj - the object to return keys from + * @api public + * + * _.keys({foo: 1, bar: 2, baz: 3}) // => 'foo', 'bar', 'baz' + */ + function keys(obj: Object): Stream; + + /** + * Returns key/value pairs for an Object as a Stream. Reads properties + * lazily, so if you don't read from all keys on an object, not + * all properties will be read from (may have an effect where getters + * are used). + * + * @id pairs + * @section Objects + * @name _.pairs(obj) + * @param {Object} obj - the object to return key/value pairs from + * @api public + * + * _.pairs({foo: 1, bar: 2}) // => ['foo', 1], ['bar', 2] + */ + function pairs(obj: Object): Stream; + + function pairs(obj: any[]): Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Extends one object with the properties of another. **Note:** The + * arguments are in the reverse order of other libraries such as + * underscore. This is so it follows the convention of other functions in + * this library and so you can more meaningfully partially apply it. + * + * @id extend + * @section Objects + * @name _.extend(a, b) + * @param {Object} a - the properties to extend b with + * @param {Object} b - the original object to extend + * @api public + * + * _.extend({name: 'bar'}, {name: 'foo', price: 20}) + * // => {name: 'bar', price: 20} + * + * // example of partial application + * var publish = _.extend({published: true}); + * + * publish({title: 'test post'}) + * // => {title: 'test post', published: true} + */ + function extend(extensions: Object, target: Object): Object; + + function extend(target: Object): (extensions: Object) => Object; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Returns a property from an object. + * + * @id get + * @section Objects + * @name _.get(prop, obj) + * @param {String} prop - the property to return + * @param {Object} obj - the object to read properties from + * @api public + * + * var obj = {foo: 'bar', baz: 123}; + * _.get('foo', obj) // => 'bar' + * + * // making use of partial application + * var posts = [ + * {title: 'one'}, + * {title: 'two'}, + * {title: 'three'} + * ]; + * + * _(posts).map(_.get('title')) // => 'one', 'two', 'three' + */ + function get(prop: string, obj: Object): string; + + function get(prop: string): (obj: Object) => Object; + + /** + * Updates a property on an object, returning the updated object. + * + * @id set + * @section Objects + * @name _.set(prop, value, obj) + * @param {String} prop - the property to return + * @param value - the value to set the property to + * @param {Object} obj - the object to set properties on + * @api public + * + * var obj = {foo: 'bar', baz: 123}; + * _.set('foo', 'wheeee', obj) // => {foo: 'wheeee', baz: 123} + * + * // making use of partial application + * var publish = _.set('published', true); + * + * publish({title: 'example'}) // => {title: 'example', published: true} + */ + function set(prop: string, val: any, obj: Object): Object; + + function set(prop: string, val: any): (obj: Object) => Object; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Logs values to the console, a simple wrapper around `console.log` that + * it suitable for passing to other functions by reference without having to + * call `bind`. + * + * @id log + * @section Utils + * @name _.log(args..) + * @api public + * + * _.log('Hello, world!'); + * + * _([1, 2, 3, 4]).each(_.log); + */ + function log(x: any, ...args: any[]): void; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Wraps a node-style async function which accepts a callback, transforming + * it to a function which accepts the same arguments minus the callback and + * returns a Highland Stream instead. Only the first argument to the + * callback (or an error) will be pushed onto the Stream. + * + * @id wrapCallback + * @section Utils + * @name _.wrapCallback(f) + * @param {Function} f - the node-style function to wrap + * @api public + * + * var fs = require('fs'); + * + * var readFile = _.wrapCallback(fs.readFile); + * + * readFile('example.txt').apply(function (data) { + * // data is now the contents of example.txt + * }); + */ + function wrapCallback(f: Function): Function; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Add two values. Can be partially applied. + * + * @id add + * @section Operators + * @name _.add(a, b) + * @api public + * + * add(1, 2) === 3 + * add(1)(5) === 6 + */ + function add(a: number, b: number): number; + + function add(a: number): (b: number) => number; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +} +declare module 'highland' { +export = Highland; +} From 39daafa17e67737d2eb45ad10b9af2a03cc3cf45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Oborn=C3=ADk?= Date: Tue, 25 Feb 2014 09:44:01 +0100 Subject: [PATCH 195/240] mongodb.ObjectID has optional constructor string --- mongodb/mongodb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongodb/mongodb.d.ts b/mongodb/mongodb.d.ts index cc2de59bed..0805e832ab 100644 --- a/mongodb/mongodb.d.ts +++ b/mongodb/mongodb.d.ts @@ -109,7 +109,7 @@ declare module "mongodb" { // Class documentation : http://mongodb.github.io/node-mongodb-native/api-bson-generated/objectid.html // Last update: doc. version 1.3.13 (28.08.2013) export class ObjectID { - constructor (s: string); + constructor (s?: string); // Returns the ObjectID id as a 24 byte hex string representation public toHexString() : string; From 52275912b527414602d34de54fea769c464d6bf2 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 25 Feb 2014 09:53:36 +0000 Subject: [PATCH 196/240] jQuery: JSDoc for unload, append, after, appendTo Have improved typings where possible (less ...any[]) --- jquery/jquery-tests.ts | 11 +-- jquery/jquery.d.ts | 153 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 148 insertions(+), 16 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index cfd4ae56f4..6778f40713 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1877,15 +1877,10 @@ function test_has() { } function test_hasClass() { - $("div#result1").append($("p:first").hasClass("selected")); - $("div#result2").append($("p:last").hasClass("selected")); - $("div#result3").append($("p").hasClass("selected")); - $('#mydiv').hasClass('foo'); - // typescript has a bug to (boolean).toString() - I'll comment this code until typescript team solve this problem. - //$("div#result1").append($("p:first").hasClass("selected").toString()); - //$("div#result2").append($("p:last").hasClass("selected").toString()); - //$("div#result3").append($("p").hasClass("selected").toString()); + $("div#result1").append($("p:first").hasClass("selected").toString()); + $("div#result2").append($("p:last").hasClass("selected").toString()); + $("div#result3").append($("p").hasClass("selected").toString()); } function test_hasData() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 329e0a177e..5fb884b080 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2660,27 +2660,164 @@ interface JQuery { */ undelegate(namespace: string): JQuery; + /** + * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) + * + * @param handler A function to execute when the event is triggered. + */ unload(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) + * + * @param eventData A plain object of data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ unload(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; - // Internals + /** + * The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. (DEPRECATED from v1.10) + */ context: Element; + jquery: string; + /** + * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) + * + * @param handler A function to execute when the event is triggered. + */ error(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) + * + * @param eventData A plain object of data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ error(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Add a collection of DOM elements onto the jQuery stack. + * + * @param elements An array of elements to push onto the stack and make into a new jQuery object. + */ pushStack(elements: any[]): JQuery; - pushStack(elements: any[], name: any, arguments: any): JQuery; + /** + * Add a collection of DOM elements onto the jQuery stack. + * + * @param elements An array of elements to push onto the stack and make into a new jQuery object. + * @param name The name of a jQuery method that generated the array of elements. + * @param arguments The arguments that were passed in to the jQuery method (for serialization). + */ + pushStack(elements: any[], name: string, arguments: any[]): JQuery; - // Manipulation - after(...content: any[]): JQuery; - after(func: (index: any) => any): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: JQuery, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: any[], ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: Element, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: Text, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + after(func: (index: number) => any): JQuery; - append(...content: any[]): JQuery; - append(func: (index: any, html: any) => any): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: JQuery, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: any[], ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: Element, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: Text, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + */ + append(func: (index: number, html: string) => any): JQuery; - appendTo(target: any): JQuery; + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: JQuery): JQuery; + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: any[]): JQuery; + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: Element): JQuery; + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: string): JQuery; before(...content: any[]): JQuery; before(func: (index: any) => any): JQuery; From e1b395a7c5ecc763c30a0b4148196eb9ec92faf9 Mon Sep 17 00:00:00 2001 From: malaporte Date: Tue, 25 Feb 2014 16:12:08 +0100 Subject: [PATCH 197/240] JQuery: Add support for outerWidth and outerHeight used as setters As described in the following blog post, outerWidth and outerHeight can now be used to set the size of elements. http://blog.jquery.com/2012/08/16/jquery-1-8-box-sizing-width-csswidth-and-outerwidth/ --- jquery/jquery-tests.ts | 4 ++++ jquery/jquery.d.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 6778f40713..6be06e1ebf 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2178,6 +2178,8 @@ function test_outerHeight() { $("p:last").text( "outerHeight:" + p.outerHeight() + " , outerHeight( true ):" + p.outerHeight(true)); + + p.outerHeight(123); } function test_outerWidth() { @@ -2185,6 +2187,8 @@ function test_outerWidth() { $("p:last").text( "outerWidth:" + p.outerWidth() + " , outerWidth( true ):" + p.outerWidth(true)); + + p.outerWidth(123); } function test_scrollLeft() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 5fb884b080..5add44d2e4 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1447,6 +1447,13 @@ interface JQuery { */ outerHeight(includeMargin?: boolean): number; + /** + * Sets the outer height on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerHeight(height: number): JQuery; + /** * Get the current computed width for the first element in the set of matched elements, including padding and border. * @@ -1454,6 +1461,13 @@ interface JQuery { */ outerWidth(includeMargin?: boolean): number; + /** + * Sets the outer width on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerWidth(width: number): JQuery; + /** * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. */ From b9873f2071c017712adfe4b58d31fa38f8872bdc Mon Sep 17 00:00:00 2001 From: malaporte Date: Tue, 25 Feb 2014 17:23:07 +0100 Subject: [PATCH 198/240] Added string overloads as well as support for innerWidth and innerHeight. --- jquery/jquery-tests.ts | 8 +++++++ jquery/jquery.d.ts | 52 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 6be06e1ebf..06f19801d5 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2166,11 +2166,17 @@ function test_index() { function test_innerHeight() { var p = $("p:first"); $("p:last").text("innerHeight:" + p.innerHeight()); + + p.innerHeight(123); + p.innerHeight('123px'); } function test_innerWidth() { var p = $("p:first"); $("p:last").text("innerWidth:" + p.innerWidth()); + + p.innerWidth(123); + p.innerWidth('123px'); } function test_outerHeight() { @@ -2180,6 +2186,7 @@ function test_outerHeight() { " , outerHeight( true ):" + p.outerHeight(true)); p.outerHeight(123); + p.outerHeight('123px'); } function test_outerWidth() { @@ -2189,6 +2196,7 @@ function test_outerWidth() { " , outerWidth( true ):" + p.outerWidth(true)); p.outerWidth(123); + p.outerWidth('123px'); } function test_scrollLeft() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 5add44d2e4..958128e2c1 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1418,11 +1418,39 @@ interface JQuery { */ innerHeight(): number; + /** + * Sets the inner height on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerHeight(height: number): JQuery; + + /** + * Sets the inner height on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerHeight(height: string): JQuery; + /** * Get the current computed width for the first element in the set of matched elements, including padding but not border. */ innerWidth(): number; + /** + * Sets the inner width on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerWidth(width: number): JQuery; + + /** + * Sets the inner width on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerWidth(width: string): JQuery; + /** * Get the current coordinates of the first element in the set of matched elements, relative to the document. */ @@ -1454,6 +1482,13 @@ interface JQuery { */ outerHeight(height: number): JQuery; + /** + * Sets the outer height on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerHeight(height: string): JQuery; + /** * Get the current computed width for the first element in the set of matched elements, including padding and border. * @@ -1461,13 +1496,20 @@ interface JQuery { */ outerWidth(includeMargin?: boolean): number; - /** - * Sets the outer width on elements in the set of matched elements, including padding and border. - * - * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). - */ + /** + * Sets the outer width on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ outerWidth(width: number): JQuery; + /** + * Sets the outer width on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerWidth(width: string): JQuery; + /** * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. */ From 4e691646f402c371c0d33e55ab158d94461d6f76 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 25 Feb 2014 21:00:24 +0100 Subject: [PATCH 199/240] Fixed lazy.js tests --- lazy.js/lazy.js-test.ts | 194 --------------------------------------- lazy.js/lazy.js-tests.ts | 191 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+), 194 deletions(-) delete mode 100644 lazy.js/lazy.js-test.ts create mode 100644 lazy.js/lazy.js-tests.ts diff --git a/lazy.js/lazy.js-test.ts b/lazy.js/lazy.js-test.ts deleted file mode 100644 index b5252a1bcf..0000000000 --- a/lazy.js/lazy.js-test.ts +++ /dev/null @@ -1,194 +0,0 @@ -/// - -var sequence:LazyJS.Sequence; -var arraySeq:LazyJS.ArrayLikeSequence; -var objectSeq:LazyJS.ObjectLikeSequence; -var asyncSeq:LazyJS.AsyncSequence; -var stringSeq:LazyJS.StringLikeSequence; - -var obj:Object; -var bool:boolean; -var num:number; -var str:string; -var x:any = null; -var arr:any[]; -var exp:RegExp; -var strArr:string[]; -var numArr:string[]; - -function fnCallback():void { -} - -function fnErrorCallback(error:any):void { - -} - -function fnValueCallback(value:any):void { -} - -function fnGetKeyCallback(value:any):string { - return ''; -} - -function fnTestCallback(value:any):boolean { - return false; -} - -function fnMapCallback(value:any):any { - return null; -} - -function fnMapStringCallback(value:string):string { - return ''; -} - -function fnNumberCallback(value:any):number { - return 0; -} - -function fnMemoCallback(memo:any, value:any):any { - return null; -} - -function fnGeneratorCallback(index:number):any { - return null; -} - -// Lazy - -arraySeq = Lazy([]); -objectSeq = Lazy({}); -stringSeq = Lazy(''); - -// Strict - -var Strict = Lazy.strict(); -arraySeq = Strict([1,2,num]).pop(); - -// Sequence - -asyncSeq = sequence.async(num); -sequence = sequence.chunk(num); -sequence = sequence.compact(); -sequence = sequence.concat(arr); -sequence = sequence.consecutive(num); -bool = sequence.contains(x); -sequence = sequence.countBy(str); -sequence = sequence.countBy(fnGetKeyCallback); -sequence = sequence.dropWhile(fnTestCallback); -sequence = sequence.each(fnValueCallback); -bool = sequence.every(fnTestCallback); -sequence = sequence.filter(fnTestCallback); -sequence = sequence.find(fnTestCallback); -sequence = sequence.findWhere(obj); - -x = sequence.first(); -sequence= sequence.first(num); - -sequence = sequence.flatten(); -objectSeq = sequence.groupBy(fnGetKeyCallback); -sequence = sequence.indexOf(x); -sequence = sequence.initial(); -sequence = sequence.initial(num); -sequence = sequence.intersection(arr); -sequence = sequence.invoke(str); -bool = sequence.isEmpty(); -str = sequence.join(); -str = sequence.join(str); - -x = sequence.last(); -sequence = sequence.last(num); - -sequence = sequence.lastIndexOf(x); -sequence = sequence.map(fnMapCallback); -x = sequence.max(); -x = sequence.max(fnNumberCallback); -x = sequence.min(); -x = sequence.min(fnNumberCallback); -sequence = sequence.pluck(str); -x = sequence.reduce(fnMemoCallback); -x = sequence.reduce(fnMemoCallback, x); -x = sequence.reduceRight(fnMemoCallback, x); -sequence = sequence.reject(fnTestCallback); -sequence = sequence.rest(num); -sequence = sequence.reverse(); -sequence = sequence.shuffle(); -bool = sequence.some(); -bool = sequence.some(fnTestCallback); -sequence = sequence.sortBy(fnNumberCallback); -sequence = sequence.sortedIndex(x); -sequence = sequence.sum(); -sequence = sequence.sum(fnNumberCallback); -sequence = sequence.takeWhile(fnTestCallback); -sequence = sequence.union(arr); -sequence = sequence.uniq(); -sequence = sequence.where(obj); -sequence = sequence.without(arr); -sequence = sequence.zip(arr); - -arr = sequence.toArray(); -obj = sequence.toObject(); - - -// ArrayLikeSequence - -arraySeq = arraySeq.concat(); -arraySeq = arraySeq.first(); -arraySeq = arraySeq.first(num); -x = arraySeq.get(num); -num = arraySeq.length(); -arraySeq = arraySeq.map(fnMapCallback); -arraySeq = arraySeq.pop(); -arraySeq = arraySeq.rest(); -arraySeq = arraySeq.rest(num); -arraySeq = arraySeq.reverse(); -arraySeq = arraySeq.shift(); -arraySeq = arraySeq.slice(num); -arraySeq = arraySeq.slice(num, num); - - -// ObjectLikeSequence - -objectSeq = objectSeq.defaults(obj); -sequence = objectSeq.functions(); -objectSeq = objectSeq.get(str); -objectSeq = objectSeq.invert(); -sequence = objectSeq.keys(); -objectSeq = objectSeq.omit(strArr); -sequence = objectSeq.pairs(); -objectSeq = objectSeq.pick(strArr); -arr = objectSeq.toArray(); -obj = objectSeq.toObject(); -sequence = objectSeq.values(); - - -// StringLikeSequence - -str = stringSeq.charAt(num); -num = stringSeq.charCodeAt(num); -bool = stringSeq.contains(str); -bool = stringSeq.endsWith(str); - -str = stringSeq.first(); -stringSeq = stringSeq.first(num); - -num = stringSeq.indexOf(str); -num = stringSeq.indexOf(str, num); - -str = stringSeq.last(); -stringSeq = stringSeq.last(num); - -num = stringSeq.lastIndexOf(str); -num = stringSeq.lastIndexOf(str, num); -stringSeq = stringSeq.mapString(fnMapStringCallback); -stringSeq = stringSeq.match(exp); -stringSeq = stringSeq.reverse(); - -sequence = stringSeq.split(str); -sequence = stringSeq.split(exp); - -bool = stringSeq.startsWith(str); -stringSeq = stringSeq.substring(num); -stringSeq = stringSeq.substring(num, num); -stringSeq = stringSeq.toLowerCase(); -stringSeq = stringSeq.toUpperCase(); diff --git a/lazy.js/lazy.js-tests.ts b/lazy.js/lazy.js-tests.ts new file mode 100644 index 0000000000..356ee177b5 --- /dev/null +++ b/lazy.js/lazy.js-tests.ts @@ -0,0 +1,191 @@ +/// + +var sequence: LazyJS.Sequence; +var arraySeq: LazyJS.ArrayLikeSequence; +var objectSeq: LazyJS.ObjectLikeSequence; +var asyncSeq: LazyJS.AsyncSequence; +var stringSeq: LazyJS.StringLikeSequence; + +var obj: Object; +var bool: boolean; +var num: number; +var str: string; +var x: any = null; +var arr: any[]; +var exp: RegExp; +var strArr: string[]; +var numArr: string[]; + +function fnCallback(): void { +} + +function fnErrorCallback(error: any): void { + +} + +function fnValueCallback(value: any): void { +} + +function fnGetKeyCallback(value: any): string { + return ''; +} + +function fnTestCallback(value: any): boolean { + return false; +} + +function fnMapCallback(value: any): any { + return null; +} + +function fnMapStringCallback(value: string): string { + return ''; +} + +function fnNumberCallback(value: any): number { + return 0; +} + +function fnMemoCallback(memo: any, value: any): any { + return null; +} + +function fnGeneratorCallback(index: number): any { + return null; +} + +// Lazy + +arraySeq = Lazy([]); +objectSeq = Lazy({}); +stringSeq = Lazy(''); + +// Strict + +var Strict = Lazy.strict(); +arraySeq = Strict([1, 2, num]).pop(); + +// Sequence + +asyncSeq = sequence.async(num); +sequence = sequence.chunk(num); +sequence = sequence.compact(); +sequence = sequence.concat(arr); +sequence = sequence.consecutive(num); +bool = sequence.contains(x); +sequence = sequence.countBy(str); +sequence = sequence.countBy(fnGetKeyCallback); +sequence = sequence.dropWhile(fnTestCallback); +sequence = sequence.each(fnValueCallback); +bool = sequence.every(fnTestCallback); +sequence = sequence.filter(fnTestCallback); +sequence = sequence.find(fnTestCallback); +sequence = sequence.findWhere(obj); + +x = sequence.first(); +sequence = sequence.first(num); + +sequence = sequence.flatten(); +objectSeq = sequence.groupBy(fnGetKeyCallback); +sequence = sequence.indexOf(x); +sequence = sequence.initial(); +sequence = sequence.initial(num); +sequence = sequence.intersection(arr); +sequence = sequence.invoke(str); +bool = sequence.isEmpty(); +str = sequence.join(); +str = sequence.join(str); + +x = sequence.last(); +sequence = sequence.last(num); + +sequence = sequence.lastIndexOf(x); +sequence = sequence.map(fnMapCallback); +x = sequence.max(); +x = sequence.max(fnNumberCallback); +x = sequence.min(); +x = sequence.min(fnNumberCallback); +sequence = sequence.pluck(str); +x = sequence.reduce(fnMemoCallback); +x = sequence.reduce(fnMemoCallback, x); +x = sequence.reduceRight(fnMemoCallback, x); +sequence = sequence.reject(fnTestCallback); +sequence = sequence.rest(num); +sequence = sequence.reverse(); +sequence = sequence.shuffle(); +bool = sequence.some(); +bool = sequence.some(fnTestCallback); +sequence = sequence.sortBy(fnNumberCallback); +sequence = sequence.sortedIndex(x); +sequence = sequence.sum(); +sequence = sequence.sum(fnNumberCallback); +sequence = sequence.takeWhile(fnTestCallback); +sequence = sequence.union(arr); +sequence = sequence.uniq(); +sequence = sequence.where(obj); +sequence = sequence.without(arr); +sequence = sequence.zip(arr); + +arr = sequence.toArray(); +obj = sequence.toObject(); + +// ArrayLikeSequence + +arraySeq = arraySeq.concat(); +arraySeq = arraySeq.first(); +arraySeq = arraySeq.first(num); +x = arraySeq.get(num); +num = arraySeq.length(); +arraySeq = arraySeq.map(fnMapCallback); +arraySeq = arraySeq.pop(); +arraySeq = arraySeq.rest(); +arraySeq = arraySeq.rest(num); +arraySeq = arraySeq.reverse(); +arraySeq = arraySeq.shift(); +arraySeq = arraySeq.slice(num); +arraySeq = arraySeq.slice(num, num); + +// ObjectLikeSequence + +objectSeq = objectSeq.defaults(obj); +sequence = objectSeq.functions(); +objectSeq = objectSeq.get(str); +objectSeq = objectSeq.invert(); +sequence = objectSeq.keys(); +objectSeq = objectSeq.omit(strArr); +sequence = objectSeq.pairs(); +objectSeq = objectSeq.pick(strArr); +arr = objectSeq.toArray(); +obj = objectSeq.toObject(); +sequence = objectSeq.values(); + +// StringLikeSequence + +str = stringSeq.charAt(num); +num = stringSeq.charCodeAt(num); +bool = stringSeq.contains(str); +bool = stringSeq.endsWith(str); + +str = stringSeq.first(); +stringSeq = stringSeq.first(num); + +num = stringSeq.indexOf(str); +num = stringSeq.indexOf(str, num); + +str = stringSeq.last(); +stringSeq = stringSeq.last(num); + +num = stringSeq.lastIndexOf(str); +num = stringSeq.lastIndexOf(str, num); +stringSeq = stringSeq.mapString(fnMapStringCallback); +stringSeq = stringSeq.match(exp); +stringSeq = stringSeq.reverse(); + +sequence = stringSeq.split(str); +sequence = stringSeq.split(exp); + +bool = stringSeq.startsWith(str); +stringSeq = stringSeq.substring(num); +stringSeq = stringSeq.substring(num, num); +stringSeq = stringSeq.toLowerCase(); +stringSeq = stringSeq.toUpperCase(); From dd6c5074d472b6873dc97f9defbf97c38b49896a Mon Sep 17 00:00:00 2001 From: gscshoyru Date: Tue, 25 Feb 2014 18:23:15 -0500 Subject: [PATCH 200/240] Fix misspelled variable name --- slickgrid/SlickGrid.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slickgrid/SlickGrid.d.ts b/slickgrid/SlickGrid.d.ts index 63fd76c979..b7810f4671 100644 --- a/slickgrid/SlickGrid.d.ts +++ b/slickgrid/SlickGrid.d.ts @@ -475,7 +475,7 @@ declare module Slick { /** * If set to true, whenever this column is resized, the entire table view will rerender. **/ - rerenderOnReize?: boolean; + rerenderOnResize?: boolean; /** * If false, column can no longer be resized. From 52909c35cae70ce06602dbce42696bc0a9753129 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Wed, 26 Feb 2014 00:01:54 +0100 Subject: [PATCH 201/240] Restructured highland definitions Changed pattern to underscore's, added module call tests --- highland/highland-tests.ts | 174 ++++--- highland/highland.d.ts | 898 ++++++++++--------------------------- 2 files changed, 337 insertions(+), 735 deletions(-) diff --git a/highland/highland-tests.ts b/highland/highland-tests.ts index 3f885a2bc7..7acc6c50b9 100644 --- a/highland/highland-tests.ts +++ b/highland/highland-tests.ts @@ -4,16 +4,16 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -import _ = require('highland'); +var _: HighlandStatic; var obj: Object; var err: Error; var bool: boolean; -var num; +var num: number; var str: string; var x: any; var f: Function; -var fn; +var fn: Function; var func: Function; var arr: any[]; var exp: RegExp; @@ -22,6 +22,10 @@ var strArr: string[]; var numArr: string[]; var funcArr: Function[]; +var readable: ReadableStream; +var writable: WritableStream; +var emitter: NodeEventEmitter; + // - - - - - - - - - - - - - - - - - var value: any; @@ -81,13 +85,25 @@ var barStreamArr: Highland.Stream[]; var strFooArrMapStream: Highland.Stream; var strBarArrMapStream: Highland.Stream; +var fooThen: Highland.Thenable; +var barThen: Highland.Thenable; + +var fooArrThen: Highland.Thenable; +var barArrThen: Highland.Thenable; + +var fooThenArr: Highland.Thenable[]; +var barThenArr: Highland.Thenable[]; + +var fooStreamThen: Highland.Thenable>; +var barStreamThen: Highland.Thenable>; + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // curries var objCurStr: (obj: Object) => string; var objCurObj: (obj: Object) => Object; var objCurAny: (obj: Object) => any; -var numCurNum: (num) => number; +var numCurNum: (num: number) => number; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -95,24 +111,35 @@ var steamError: Highland.StreamError; var streamRedirect: Highland.StreamRedirect; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/* - interface Highland { - (xs: R[]): Highland.Stream; - (xs: (push: (err:Error, x?:R) => void, next:() => void) => void): Highland.Stream; - (xs: Highland.Stream): Highland.Stream; +steamError = new Highland.StreamError(err); +err = steamError.error; - (xs: ReadableStream): Highland.Stream; - (xs: NodeEventEmitter): Highland.Stream; +streamRedirect = new Highland.StreamRedirect(fooStream); +fooStream = streamRedirect.to; - (xs: Thenable): Highland.Stream; - (xs: Thenable>): Highland.Stream; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (): Highland.Stream; - } +// top-level module - fooStream = _([1, 2, 3]); - */ +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +fooStream = _(); +fooStream = _(fooArr); +fooStream = _((push, next) => { + push(null, foo); + push(err); + next(); +}); + +fooStream = _(fooStream); +fooStream = _(readable); +fooStream = _(emitter); + +fooStream = _(fooStreamThen); +fooStream = _(fooArrThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - obj = _.nil; @@ -138,14 +165,6 @@ f = _.seq(f, f); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -steamError = new Highland.StreamError(err); -err = steamError.error; - -streamRedirect = new Highland.StreamRedirect(fooStream); -fooStream = streamRedirect.to; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool = _.isStream(x); bool = _.isStream(fooStream); @@ -157,6 +176,51 @@ bool = _.isStreamRedirect(fooStream); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +anyStream = _.values(obj); +fooStream = _.values(fooArr); + +strStream = _.keys(obj); + +anyArrStream = _.pairs(obj); +anyArrStream = _.pairs(fooArr); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +obj = _.extend(obj, obj); + +objCurObj = _.extend(obj); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +x = _.get(str, obj); + +objCurObj = _.get(str); + +obj = _.set(str, foo, obj); + +objCurAny = _.set(str, foo); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +_.log(str); +_.log(str, num, foo); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +f = _.wrapCallback(func); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +num = _.add(num, num); + +numCurNum = _.add(num); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// instance methods + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + fooStream.pause(); fooStream.resume(); @@ -165,6 +229,7 @@ fooStream.resume(); fooStream.end(); fooStream = fooStream.pipe(fooStream); +barStream = fooStream.pipe(barStream); fooStream.destroy(); @@ -176,10 +241,22 @@ barStream = fooStream.consume((err: Error, x: Foo, push: (err: Error, value?: Ba next(); }); +barStream = fooStream.consume((err, x, push, next) => { + push(err); + push(null, bar); + next(); +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + fooStream.pull((err: Error, x: Foo) => { }); +fooStream.pull((err, x) => { + +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool = fooStream.write(foo); @@ -198,6 +275,12 @@ fooStream = fooStream.errors((err: Error, push: (e: Error, x?: Foo) => void) => push(null, foo); }); +fooStream = fooStream.errors((err, push) => { + push(err); + push(null, x); + push(null, foo); +}); + fooStream = fooStream.stopOnError((e: Error) => { }); @@ -311,44 +394,3 @@ fooStream = fooStream.debounce(num); fooStream = fooStream.latest(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -anyStream = _.values(obj); -fooStream = _.values(fooArr); - -strStream = _.keys(obj); - -anyArrStream = _.pairs(obj); -anyArrStream = _.pairs(fooArr); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -obj = _.extend(obj, obj); - -objCurObj = _.extend(obj); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -x = _.get(str, obj); - -objCurObj = _.get(str); - -obj = _.set(str, foo, obj); - -objCurAny = _.set(str, foo); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -_.log(str); -_.log(str, num, foo); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -f = _.wrapCallback(func); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -num = _.add(num, num); - -numCurNum = _.add(num); - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/highland/highland.d.ts b/highland/highland.d.ts index 1306811044..252c617eaa 100644 --- a/highland/highland.d.ts +++ b/highland/highland.d.ts @@ -5,12 +5,11 @@ /// -// Note: make sure to updated both the module and instance methods +// TODO export the top-level functions // TODO figure out curry arguments // TODO use externalised Thenable - -// TODO export module functions +// TODO use externalised Readable/Writable (not node's) /** * Highland: the high-level streams library @@ -21,83 +20,54 @@ * */ -/** - * The Stream constructor, accepts an array of values or a generator function - * as an optional argument. This is typically the entry point to the Highland - * APIs, providing a convenient way of chaining calls together. - * - * **Arrays -** Streams created from Arrays will emit each value of the Array - * and then emit a [nil](#nil) value to signal the end of the Stream. - * - * **Generators -** These are functions which provide values for the Stream. - * They are lazy and can be infinite, they can also be asynchronous (for - * example, making a HTTP request). You emit values on the Stream by calling - * `push(err, val)`, much like a standard Node.js callback. You call `next()` - * to signal you've finished processing the current data. If the Stream is - * still being consumed the generator function will then be called again. - * - * You can also redirect a generator Stream by passing a new source Stream - * to read from to next. For example: `next(other_stream)` - then any subsequent - * calls will be made to the new source. - * - * **Node Readable Stream -** Pass in a Node Readable Stream object to wrap - * it with the Highland API. Reading from the resulting Highland Stream will - * begin piping the data from the Node Stream to the Highland Stream. - * - * **EventEmitter / jQuery Elements -** Pass in both an event name and an - * event emitter as the two arguments to the constructor and the first - * argument emitted to the event handler will be written to the new Stream. - * - * **Promise -** Accepts an ES6 / jQuery style promise and returns a - * Highland Stream which will emit a single value (or an error). - * - * @id _(source) - * @section Streams - * @name _(source) - * @param {Array | Function | Readable Stream | Promise} source - (optional) source to take values from from - * @api public - * - * // from an Array - * _([1, 2, 3, 4]); - * - * // using a generator function - * _(function (push, next) { - * push(null, 1); - * push(err); - * next(); - * }); - * - * // a stream with no source, can pipe node streams through it etc. - * var through = _(); - * - * // wrapping a Node Readable Stream so you can easily manipulate it - * _(readable).filter(hasSomething).pipe(writeable); - * - * // creating a stream from events - * _('click', btn).each(handleEvent); - * - * // from a Promise object - * var foo = _($.getJSON('/api/foo')); - */ -declare function Highland(): Highland.Stream; -declare function Highland(xs: R[]): Highland.Stream; -declare function Highland(xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream; -declare function Highland(xs: Highland.Stream): Highland.Stream; +interface HighlandStatic { + /** + * The Stream constructor, accepts an array of values or a generator function + * as an optional argument. This is typically the entry point to the Highland + * APIs, providing a convenient way of chaining calls together. + * + * **Arrays -** Streams created from Arrays will emit each value of the Array + * and then emit a [nil](#nil) value to signal the end of the Stream. + * + * **Generators -** These are functions which provide values for the Stream. + * They are lazy and can be infinite, they can also be asynchronous (for + * example, making a HTTP request). You emit values on the Stream by calling + * `push(err, val)`, much like a standard Node.js callback. You call `next()` + * to signal you've finished processing the current data. If the Stream is + * still being consumed the generator function will then be called again. + * + * You can also redirect a generator Stream by passing a new source Stream + * to read from to next. For example: `next(other_stream)` - then any subsequent + * calls will be made to the new source. + * + * **Node Readable Stream -** Pass in a Node Readable Stream object to wrap + * it with the Highland API. Reading from the resulting Highland Stream will + * begin piping the data from the Node Stream to the Highland Stream. + * + * **EventEmitter / jQuery Elements -** Pass in both an event name and an + * event emitter as the two arguments to the constructor and the first + * argument emitted to the event handler will be written to the new Stream. + * + * **Promise -** Accepts an ES6 / jQuery style promise and returns a + * Highland Stream which will emit a single value (or an error). + * + * @id _(source) + * @section Streams + * @name _(source) + * @param {Array | Function | Readable Stream | Promise} source - (optional) source to take values from from + * @api public + */ + (): Highland.Stream; + (xs: R[]): Highland.Stream; + (xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream; -declare function Highland(xs: ReadableStream): Highland.Stream; -declare function Highland(xs: NodeEventEmitter): Highland.Stream; + (xs: Highland.Stream): Highland.Stream; + (xs: ReadableStream): Highland.Stream; + (xs: NodeEventEmitter): Highland.Stream; -declare function Highland(xs: Highland.Thenable>): Highland.Stream; -declare function Highland(xs: Highland.Thenable): Highland.Stream; - -declare module Highland { - - interface Thenable { - then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; - then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; - then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; - } + // moar (promise for everything?) + (xs: Highland.Thenable>): Highland.Stream; + (xs: Highland.Thenable): Highland.Stream; /** * The end of stream marker. This is sent along the data channel of a Stream @@ -108,30 +78,8 @@ declare module Highland { * @section Streams * @name _.nil * @api public - * - * var map(iter, source) { - * return source.consume(function (err, val, push, next) { - * if (err) { - * push(err); - * next(); - * } - * else if (val === _.nil) { - * push(null, val); - * } - * else { - * push(null, iter(val)); - * next(); - * } - * }); - * }; */ - var nil: Nil; - - // hacky unique - // TODO do we need this? - interface Nil { - Highland_NIL: Nil; - } + nil: Highland.Nil; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -149,16 +97,8 @@ declare module Highland { * @param args.. - any number of arguments to pre-apply to the function * @returns Function * @api public - * - * fn = curry(function (a, b, c) { - * return a + b + c; - * }); - * - * fn(1)(2)(3) == fn(1, 2, 3) - * fn(1, 2)(3) == fn(1, 2, 3) - * fn(1)(2, 3) == fn(1, 2, 3) */ - function curry(fn: Function, ...args: any[]): Function; + curry(fn: Function, ...args: any[]): Function; /** * Same as `curry` but with a specific number of arguments. This can be @@ -174,16 +114,8 @@ declare module Highland { * @param args... - any number of arguments to pre-apply to the function * @returns Function * @api public - * - * fn = ncurry(3, function () { - * return Array.prototype.join.call(arguments, '.'); - * }); - * - * fn(1, 2, 3) == '1.2.3'; - * fn(1, 2)(3) == '1.2.3'; - * fn(1)(2)(3) == '1.2.3'; */ - function ncurry(n: number, fn: Function, ...args: any[]): Function; + ncurry(n: number, fn: Function, ...args: any[]): Function; /** * Partially applies the function (regardless of whether it has had curry @@ -196,15 +128,8 @@ declare module Highland { * @param {Function} fn - function to partial apply * @param args... - the arguments to apply to the function * @api public - * - * var addAll = function () { - * var args = Array.prototype.slice.call(arguments); - * return foldl1(add, args); - * }; - * var f = partial(addAll, 1, 2); - * f(3, 4) == 10 */ - function partial(f: Function, ...args: any[]): Function; + partial(f: Function, ...args: any[]): Function; /** * Evaluates the function `fn` with the argument positions swapped. Only @@ -217,12 +142,8 @@ declare module Highland { * @param x - parameter to apply to the right hand side of f * @param y - parameter to apply to the left hand side of f * @api public - * - * div(2, 4) == 0.5 - * flip(div, 2, 4) == 2 - * flip(div)(2, 4) == 2 */ - function flip(fn: Function, ...args: any[]): Function; + flip(fn: Function, ...args: any[]): Function; /** * Creates a composite function, which is the application of function1 to @@ -234,14 +155,8 @@ declare module Highland { * @name compose(fn1, fn2, ...) * @section Functions * @api public - * - * var add1 = add(1); - * var mul3 = mul(3); - * - * var add1mul3 = compose(mul3, add1); - * add1mul3(2) == 9 */ - function compose(...functions: Function[]): Function; + compose(...functions: Function[]): Function; /** * The reversed version of compose. Where arguments are in the order of @@ -251,14 +166,177 @@ declare module Highland { * @name seq(fn1, fn2, ...) * @section Functions * @api public - * - * var add1 = add(1); - * var mul3 = mul(3); - * - * var add1mul3 = seq(add1, mul3); - * add1mul3(2) == 9 */ - function seq(...functions: Function[]): Function; + seq(...functions: Function[]): Function; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Returns true if `x` is a Highland Stream. + * + * @id isStream + * @section Streams + * @name _.isStream(x) + * @param x - the object to test + * @api public + */ + isStream(x: any): boolean; + + isStreamError(x: any): boolean; + + isStreamRedirect(x: any): boolean; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Returns values from an Object as a Stream. Reads properties + * lazily, so if you don't read from all keys on an object, not + * all properties will be read from (may have an effect where getters + * are used). + * + * @id values + * @section Objects + * @name _.values(obj) + * @param {Object} obj - the object to return values from + * @api public + */ + values(obj: Object): Highland.Stream; + + /** + * Returns keys from an Object as a Stream. + * + * @id keys + * @section Objects + * @name _.keys(obj) + * @param {Object} obj - the object to return keys from + * @api public + */ + keys(obj: Object): Highland.Stream; + + /** + * Returns key/value pairs for an Object as a Stream. Reads properties + * lazily, so if you don't read from all keys on an object, not + * all properties will be read from (may have an effect where getters + * are used). + * + * @id pairs + * @section Objects + * @name _.pairs(obj) + * @param {Object} obj - the object to return key/value pairs from + * @api public + */ + pairs(obj: Object): Highland.Stream; + + pairs(obj: any[]): Highland.Stream; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Extends one object with the properties of another. **Note:** The + * arguments are in the reverse order of other libraries such as + * underscore. This is so it follows the convention of other functions in + * this library and so you can more meaningfully partially apply it. + * + * @id extend + * @section Objects + * @name _.extend(a, b) + * @param {Object} a - the properties to extend b with + * @param {Object} b - the original object to extend + * @api public + */ + extend(extensions: Object, target: Object): Object; + + extend(target: Object): (extensions: Object) => Object; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Returns a property from an object. + * + * @id get + * @section Objects + * @name _.get(prop, obj) + * @param {String} prop - the property to return + * @param {Object} obj - the object to read properties from + * @api public + */ + get(prop: string, obj: Object): string; + + get(prop: string): (obj: Object) => Object; + + /** + * Updates a property on an object, returning the updated object. + * + * @id set + * @section Objects + * @name _.set(prop, value, obj) + * @param {String} prop - the property to return + * @param value - the value to set the property to + * @param {Object} obj - the object to set properties on + * @api public + */ + set(prop: string, val: any, obj: Object): Object; + + set(prop: string, val: any): (obj: Object) => Object; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Logs values to the console, a simple wrapper around `console.log` that + * it suitable for passing to other functions by reference without having to + * call `bind`. + * + * @id log + * @section Utils + * @name _.log(args..) + * @api public + */ + log(x: any, ...args: any[]): void; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Wraps a node-style async function which accepts a callback, transforming + * it to a function which accepts the same arguments minus the callback and + * returns a Highland Stream instead. Only the first argument to the + * callback (or an error) will be pushed onto the Stream. + * + * @id wrapCallback + * @section Utils + * @name _.wrapCallback(f) + * @param {Function} f - the node-style function to wrap + * @api public + */ + wrapCallback(f: Function): Function; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + /** + * Add two values. Can be partially applied. + * + * @id add + * @section Operators + * @name _.add(a, b) + * @api public + */ + add(a: number, b: number): number; + + add(a: number): (b: number) => number; +} + +declare module Highland { + + interface Thenable { + then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; + then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; + } + // hacky unique + // TODO do we need this? + interface Nil { + Highland_NIL: Nil; + } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -281,27 +359,6 @@ declare module Highland { to: Stream; } - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Returns true if `x` is a Highland Stream. - * - * @id isStream - * @section Streams - * @name _.isStream(x) - * @param x - the object to test - * @api public - * - * _.isStream('foo') // => false - * _.isStream(_([1,2,3])) // => true - */ - function isStream(x: any): boolean; - - function isStreamError(x: any): boolean; - - function isStreamRedirect(x: any): boolean; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -316,9 +373,6 @@ declare module Highland { * @section Streams * @name Stream.pause() * @api public - * - * var xs = _(generator); - * xs.pause(); */ pause(): void; @@ -330,9 +384,6 @@ declare module Highland { * @section Streams * @name Stream.resume() * @api public - * - * var xs = _(generator); - * xs.resume(); */ resume(): void; @@ -348,8 +399,6 @@ declare module Highland { * @section Streams * @name Stream.end() * @api public - * - * mystream.end(); */ end(): void; @@ -367,13 +416,6 @@ declare module Highland { * @name Stream.pipe(dest) * @param {Writable Stream} dest - the destination to write all data to * @api public - * - * var source = _(generator); - * var dest = fs.createWriteStream('myfile.txt') - * source.pipe(dest); - * - * // chained call - * source.pipe(through).pipe(dest); */ pipe(dest: Stream): Stream; pipe(dest: ReadWriteStream): Stream; @@ -408,27 +450,6 @@ declare module Highland { * @name Stream.consume(f) * @param {Function} f - the function to handle errors and values * @api public - * - * var filter = function (f, source) { - * return source.consume(function (err, x, push, next) { - * if (err) { - * // pass errors along the stream and consume next value - * push(err); - * next(); - * } - * else if (x === _.nil) { - * // pass nil (end event) along the stream - * push(null, x); - * } - * else { - * // pass on the value only if the value passes the predicate - * if (f(x)) { - * push(null, x); - * } - * next(); - * } - * }); - * }; */ consume(f: (err: Error, x: R, push: (err: Error, value?: U) => void, next: () => void) => void): Stream; @@ -445,10 +466,6 @@ declare module Highland { * @name Stream.pull(f) * @param {Function} f - the function to handle data * @api public - * - * xs.pull(function (err, x) { - * // do something - * }); */ pull(f: (err: Error, x: R) => void): void; @@ -468,15 +485,6 @@ declare module Highland { * @name Stream.write(x) * @param x - the value to write to the Stream * @api public - * - * var xs = _(); - * xs.write(1); - * xs.write(2); - * xs.end(); - * - * xs.toArray(function (ys) { - * // ys will be [1, 2] - * }); */ write(x: R): boolean; @@ -491,16 +499,6 @@ declare module Highland { * @section Streams * @name Stream.fork() * @api public - * - * var xs = _([1, 2, 3, 4]); - * var ys = xs.fork(); - * var zs = xs.fork(); - * - * // no values will be pulled from xs until zs also resume - * ys.resume(); - * - * // now both ys and zs will get values from xs - * zs.resume(); */ fork(): Stream; @@ -515,13 +513,6 @@ declare module Highland { * @section Streams * @name Stream.observe() * @api public - * - * var xs = _([1, 2, 3, 4]); - * var ys = xs.fork(); - * var zs = xs.observe(); - * - * // now both zs and ys will recieve data as fast as ys can handle it - * ys.resume(); */ observe(): Stream; @@ -538,22 +529,9 @@ declare module Highland { * @name Stream.errors(f) * @param {Function} f - the function to pass all errors to * @api public - * - * getDocument.errors(function (err, push) { - * if (err.statusCode === 404) { - * // not found, return empty doc - * push(null, {}); - * } - * else { - * // otherwise, re-throw the error - * push(err); - * } - * }); */ errors(f: (err: Error, push: (err: Error, x?: R) => void) => void): Stream; - // function errors(f: (err: Error, push: (err: Error, x?: R) => void) => void): Stream; - /** * Like the [errors](#errors) method, but emits a Stream end marker after * an Error is encountered. @@ -563,15 +541,9 @@ declare module Highland { * @name Stream.stopOnError(f) * @param {Function} f - the function to handle an error * @api public - * - * brokenStream.stopOnError(function (err) { - * console.error('Something broke: ' + err); - * }); */ stopOnError(f: (err: Error) => void): Stream; - // function stopOnError(f: (err: Error) => void): Stream; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -586,15 +558,9 @@ declare module Highland { * @name Stream.each(f) * @param {Function} f - the iterator function * @api public - * - * _([1, 2, 3, 4]).each(function (x) { - * // will be called 4 times with x being 1, 2, 3 and 4 - * }); */ each(f: (x: R) => void): void; - // function each(f: (x: R) => void): void; - /** * Applies results from a Stream as arguments to a function * @@ -603,18 +569,10 @@ declare module Highland { * @name Stream.apply(f) * @param {Function} f - the function to apply arguments to * @api public - * - * _([1, 2, 3]).apply(function (a, b, c) { - * // a === 1 - * // b === 2 - * // c === 3 - * }); */ // TODO what to do here? apply(f: Function): void; - //function apply(f:Function): Stream; - /** * Collects all values from a Stream into an Array and calls a function with * once with the result. This function causes a **thunk**. @@ -627,15 +585,9 @@ declare module Highland { * @name Stream.toArray(f) * @param {Function} f - the callback to provide the completed Array to * @api public - * - * _([1, 2, 3, 4]).each(function (x) { - * // will be called 4 times with x being 1, 2, 3 and 4 - * }); */ toArray(f: (arr: R[]) => void): void; - //function toArray(f:(arr:any[]) => void): void; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -649,17 +601,9 @@ declare module Highland { * @name Stream.map(f) * @param f - the transformation function or value to map to * @api public - * - * var doubled = _([1, 2, 3, 4]).map(function (x) { - * return x * 2; - * }); - * - * _([1, 2, 3]).map('hi') // => 'hi', 'hi', 'hi' */ map(f: (x: R) => U): Stream; - //function map(f:(arr:any) => any): Stream; - /** * Creates a new Stream of values by applying each item in a Stream to an * iterator function which may return a Stream. Each item on these result @@ -672,14 +616,10 @@ declare module Highland { * @name Stream.flatMap(f) * @param {Function} f - the iterator function * @api public - * - * filenames.flatMap(readFile) */ flatMap(f: (x: R) => Stream): Stream; flatMap(f: (x: R) => U): Stream; - // function flatMap(f:(arr:any) => any): Stream; - /** * Retrieves values associated with a given property from all elements in * the collection. @@ -689,22 +629,9 @@ declare module Highland { * @name Stream.pluck(property) * @param {String} prop - the property to which values should be associated * @api public - * - * var docs = [ - * {type: 'blogpost', title: 'foo'}, - * {type: 'blogpost', title: 'bar'}, - * {type: 'comment', title: 'baz'} - * ]; - * - * _(docs).pluck('title').toArray(function (xs) { - * // xs is now ['foo', 'bar', 'baz'] - * }); */ - // forced parametrise? pluck(prop: string): Stream; - // function pluck(prop:string): Stream; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -715,15 +642,9 @@ declare module Highland { * @name Stream.filter(f) * @param f - the truth test function * @api public - * - * var evens = _([1, 2, 3, 4]).filter(function (x) { - * return x % 2 === 0; - * }); */ filter(f: (x: R) => boolean): Stream; - // function filter(f:(arr:any) => boolean): Stream; - /** * Filters using a predicate which returns a Stream. If you need to check * against an asynchronous data source when filtering a Stream, this can @@ -736,14 +657,9 @@ declare module Highland { * @name Stream.flatFilter(f) * @param {Function} f - the truth test function which returns a Stream * @api public - * - * var checkExists = _.wrapCallback(fs.exists); - * filenames.flatFilter(checkExists) */ flatFilter(f: (x: R) => Stream): Stream; - // function flatFilter(): Stream; - /** * A convenient form of filter, which returns the first object from a * Stream that passes the provided truth test @@ -753,30 +669,9 @@ declare module Highland { * @name Stream.find(f) * @param {Function} f - the truth test function which returns a Stream * @api public - * - * var docs = [ - * {type: 'blogpost', title: 'foo'}, - * {type: 'blogpost', title: 'bar'}, - * {type: 'comment', title: 'foo'} - * ]; - * - * var f(x) { - * return x.type == 'blogpost'; - * }; - * - * _(docs).find(f); - * // => [{type: 'blogpost', title: 'foo'}] - * - * // example with partial application - * var firstBlogpost = _.find(f); - * - * firstBlogpost(docs) - * // => [{type: 'blogpost', title: 'foo'}] */ find(f: (x: R) => boolean): Stream; - // function find(): Stream; - /** * A convenient form of reduce, which groups items based on a function or property name * @@ -786,30 +681,11 @@ declare module Highland { * @param {Function|String} f - the function or property name on which to group, * toString() is called on the result of a function. * @api public - * - * var docs = [ - * {type: 'blogpost', title: 'foo'}, - * {type: 'blogpost', title: 'bar'}, - * {type: 'comment', title: 'foo'} - * ]; - * - * var f(x) { - * return x.type; - * }; - * - * _(docs).group(f); OR _(docs).group('type'); - * // => { - * // => 'blogpost': [{type: 'blogpost', title: 'foo'}, {type: 'blogpost', title: 'bar'}] - * // => 'comment': [{type: 'comment', title: 'foo'}] - * // => } - * */ // TODO verify this group(f: (x: R) => string): Stream<{[prop:string]:R[]}>; group(prop: string): Stream<{[prop:string]:R[]}>; - // function group(): Stream; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -819,14 +695,9 @@ declare module Highland { * @section Streams * @name Stream.compact() * @api public - * - * var compacted = _([0, 1, false, 3, null, undefined, 6]).compact(); - * // => [1, 3, 6] */ compact(): Stream; - // function compact(): Stream; - /** * A convenient form of filter, which returns all objects from a Stream * match a set of property values. @@ -836,28 +707,9 @@ declare module Highland { * @name Stream.where(props) * @param {Object} props - the properties to match against * @api public - * - * var docs = [ - * {type: 'blogpost', title: 'foo'}, - * {type: 'blogpost', title: 'bar'}, - * {type: 'comment', title: 'foo'} - * ]; - * - * _(docs).where({title: 'foo'}) - * // => {type: 'blogpost', title: 'foo'} - * // => {type: 'comment', title: 'foo'} - * - * // example with partial application - * var getBlogposts = _.where({type: 'blogpost'}); - * - * getBlogposts(docs) - * // => {type: 'blogpost', title: 'foo'} - * // => {type: 'blogpost', title: 'bar'} */ where(props: Object): Stream; - // function where(): Stream; - /** * Takes two Streams and returns a Stream of corresponding pairs. * @@ -866,14 +718,10 @@ declare module Highland { * @name Stream.zip(ys) * @param {Array | Stream} ys - the other stream to combine values with * @api public - * - * _(['a', 'b', 'c']).zip([1, 2, 3]) // => ['a', 1], ['b', 2], ['c', 3] */ zip(ys: R[]): Stream; zip(ys: Stream): Stream; - // function zip(): Stream; - /** * Creates a new Stream with the first `n` values from the source. * @@ -882,13 +730,9 @@ declare module Highland { * @name Stream.take(n) * @param {Number} n - integer representing number of values to read from source * @api public - * - * _([1, 2, 3, 4]).take(2) // => 1, 2 */ take(n: number): Stream; - // function take(): Stream; - /** * Drops all values from the Stream apart from the last one (if any). * @@ -896,13 +740,9 @@ declare module Highland { * @section Streams * @name Stream.last() * @api public - * - * _([1, 2, 3, 4]).last() // => 4 */ last(): Stream; - // function last(): Stream; - /** * Reads values from a Stream of Streams, emitting them on a Single output * Stream. This can be thought of as a flatten, just one level deep. Often @@ -913,22 +753,10 @@ declare module Highland { * @section Streams * @name Stream.sequence() * @api public - * - * var nums = _([ - * _([1, 2, 3]), - * _([4, 5, 6]) - * ]); - * - * nums.sequence() // => 1, 2, 3, 4, 5, 6 - * - * // using sequence to read from files in series - * filenames.map(readFile).sequence() */ //TODO figure out typing sequence(): Stream; - // function sequence(): Stream; - /** * An alias for the [sequence](#sequence) method. * @@ -936,14 +764,10 @@ declare module Highland { * @section Streams * @name Stream.series() * @api public - * - * filenames.map(readFile).series() */ // TODO figure out typing series(): Stream; - // function series = _.sequence; - /** * Recursively reads values from a Stream which may contain nested Streams * or Arrays. As values or errors are encountered, they are emitted on a @@ -953,21 +777,10 @@ declare module Highland { * @section Streams * @name Stream.flatten() * @api public - * - * _([1, [2, 3], [[4]]]).flatten(); // => 1, 2, 3, 4 - * - * var nums = _( - * _([1, 2, 3]), - * _([4, _([5, 6]) ]) - * ); - * - * nums.flatten(); // => 1, 2, 3, 4, 5, 6 */ flatten(): Stream; flatten(): Stream; - // function flatten(): Stream; - /** * Takes a Stream of Streams and reads from them in parallel, buffering * the results until they can be returned to the consumer in their original @@ -978,17 +791,9 @@ declare module Highland { * @name Stream.parallel(n) * @param {Number} n - the maximum number of concurrent reads/buffers * @api public - * - * var readFile = _.wrapCallback(fs.readFile); - * var filenames = _(['foo.txt', 'bar.txt', 'baz.txt']); - * - * // read from up to 10 files at once - * filenames.map(readFile).parallel(10); */ parallel(n: number): Stream; - // function parallel(): Stream; - /** * Switches source to an alternate Stream if the current Stream is empty. * @@ -997,17 +802,9 @@ declare module Highland { * @name Stream.otherwise(ys) * @param {Stream} ys - alternate stream to use if this stream is empty * @api public - * - * _([1,2,3]).otherwise(['foo']) // => 1, 2, 3 - * _([]).otherwise(['foo']) // => 'foo' - * - * _.otherwise(_(['foo']), _([1,2,3])) // => 1, 2, 3 - * _.otherwise(_(['foo']), _([])) // => 'foo' */ otherwise(ys: Stream): Stream; - // function otherwise(): Stream; - /** * Adds a value to the end of a Stream. * @@ -1016,13 +813,9 @@ declare module Highland { * @name Stream.append(y) * @param y - the value to append to the Stream * @api public - * - * _([1, 2, 3]).append(4) // => 1, 2, 3, 4 */ append(y: R): Stream; - // function append(): Stream; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -1037,18 +830,10 @@ declare module Highland { * @param memo - the initial state of the reduction * @param {Function} iterator - the function which reduces the values * @api public - * - * var add = function (a, b) { - * return a + b; - * }; - * - * _([1, 2, 3, 4]).reduce(0, add) // => 10 */ // TODO: convert this to this.scan(z, f).last() reduce(memo: U, f: (memo: U, x: R) => U): Stream; - // function reduce(): Stream; - /** * Same as [reduce](#reduce), but uses the first element as the initial * state instead of passing in a `memo` value. @@ -1058,13 +843,9 @@ declare module Highland { * @name Stream.reduce1(iterator) * @param {Function} iterator - the function which reduces the values * @api public - * - * _([1, 2, 3, 4]).reduce1(add) // => 10 */ reduce1(memo: U, f: (memo: U, x: R) => U): Stream; - // function reduce1(): Stream; - /** * Groups all values into an Array and passes down the stream as a single * data event. This is a bit like doing [toArray](#toArray), but instead @@ -1074,15 +855,9 @@ declare module Highland { * @section Streams * @name Stream.collect() * @api public - * - * _(['foo', 'bar']).collect().toArray(function (xs) { - * // xs will be [['foo', 'bar']] - * }); */ collect(): Stream; - // function collect(): Stream; - /** * Like [reduce](#reduce), but emits each intermediate value of the * reduction as it is calculated. @@ -1093,13 +868,9 @@ declare module Highland { * @param memo - the initial state of the reduction * @param {Function} iterator - the function which reduces the values * @api public - * - * _([1, 2, 3, 4]).scan(0, add) // => 0, 1, 3, 6, 10 */ scan(memo: U, x: (memo: U, x: R) => U): Stream; - //function scan(): Stream; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -1114,15 +885,10 @@ declare module Highland { * @name Stream.concat(ys) * @params {Stream | Array} ys - the values to concatenate onto this Stream * @api public - * - * _([1, 2]).concat([3, 4]) // => 1, 2, 3, 4 - * _.concat([3, 4], [1, 2]) // => 1, 2, 3, 4 */ concat(ys: Stream): Stream; concat(ys: R[]): Stream; - // function concat(): Stream; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -1135,15 +901,9 @@ declare module Highland { * @param {String} method - the method name to call * @param {Array} args - the arguments to call the method with * @api public - * - * _(['foo', 'bar']).invoke('toUpperCase', []) // => FOO, BAR - * - * filenames.map(readFile).sequence().invoke('toString', ['utf8']); */ invoke(method: string, args: any[]): Stream; - // function invoke(): Stream; - /** * Ensures that only one data event is push downstream (or into the buffer) * every `ms` milliseconds, any other values are dropped. @@ -1153,13 +913,9 @@ declare module Highland { * @name Stream.throttle(ms) * @param {Number} ms - the minimum milliseconds between each value * @api public - * - * _('mousemove', document).throttle(1000); */ throttle(ms: number): Stream; - // function throttle(ms:number): Stream; - /** * Holds off pushing data events downstream until there has been no more * data for `ms` milliseconds. Sends the last value that occurred before @@ -1170,14 +926,9 @@ declare module Highland { * @name Stream.debounce(ms) * @param {Number} ms - the milliseconds to wait before sending data * @api public - * - * // sends last keyup event after user has stopped typing for 1 second - * $('keyup', textbox).debounce(1000); */ debounce(ms: number): Stream; - // function debounce(ms:number): Stream; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** @@ -1190,205 +941,14 @@ declare module Highland { * @section Streams * @name Stream.latest() * @api public - * - * // slowThing will always get the last known mouse position - * // when it asks for more data from the mousePosition stream - * mousePosition.latest().map(slowThing) */ latest(): Stream; - - // function latest(): Stream; } - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Returns values from an Object as a Stream. Reads properties - * lazily, so if you don't read from all keys on an object, not - * all properties will be read from (may have an effect where getters - * are used). - * - * @id values - * @section Objects - * @name _.values(obj) - * @param {Object} obj - the object to return values from - * @api public - * - * _.values({foo: 1, bar: 2, baz: 3}) // => 1, 2, 3 - */ - function values(obj: Object): Stream; - - /** - * Returns keys from an Object as a Stream. - * - * @id keys - * @section Objects - * @name _.keys(obj) - * @param {Object} obj - the object to return keys from - * @api public - * - * _.keys({foo: 1, bar: 2, baz: 3}) // => 'foo', 'bar', 'baz' - */ - function keys(obj: Object): Stream; - - /** - * Returns key/value pairs for an Object as a Stream. Reads properties - * lazily, so if you don't read from all keys on an object, not - * all properties will be read from (may have an effect where getters - * are used). - * - * @id pairs - * @section Objects - * @name _.pairs(obj) - * @param {Object} obj - the object to return key/value pairs from - * @api public - * - * _.pairs({foo: 1, bar: 2}) // => ['foo', 1], ['bar', 2] - */ - function pairs(obj: Object): Stream; - - function pairs(obj: any[]): Stream; - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Extends one object with the properties of another. **Note:** The - * arguments are in the reverse order of other libraries such as - * underscore. This is so it follows the convention of other functions in - * this library and so you can more meaningfully partially apply it. - * - * @id extend - * @section Objects - * @name _.extend(a, b) - * @param {Object} a - the properties to extend b with - * @param {Object} b - the original object to extend - * @api public - * - * _.extend({name: 'bar'}, {name: 'foo', price: 20}) - * // => {name: 'bar', price: 20} - * - * // example of partial application - * var publish = _.extend({published: true}); - * - * publish({title: 'test post'}) - * // => {title: 'test post', published: true} - */ - function extend(extensions: Object, target: Object): Object; - - function extend(target: Object): (extensions: Object) => Object; - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Returns a property from an object. - * - * @id get - * @section Objects - * @name _.get(prop, obj) - * @param {String} prop - the property to return - * @param {Object} obj - the object to read properties from - * @api public - * - * var obj = {foo: 'bar', baz: 123}; - * _.get('foo', obj) // => 'bar' - * - * // making use of partial application - * var posts = [ - * {title: 'one'}, - * {title: 'two'}, - * {title: 'three'} - * ]; - * - * _(posts).map(_.get('title')) // => 'one', 'two', 'three' - */ - function get(prop: string, obj: Object): string; - - function get(prop: string): (obj: Object) => Object; - - /** - * Updates a property on an object, returning the updated object. - * - * @id set - * @section Objects - * @name _.set(prop, value, obj) - * @param {String} prop - the property to return - * @param value - the value to set the property to - * @param {Object} obj - the object to set properties on - * @api public - * - * var obj = {foo: 'bar', baz: 123}; - * _.set('foo', 'wheeee', obj) // => {foo: 'wheeee', baz: 123} - * - * // making use of partial application - * var publish = _.set('published', true); - * - * publish({title: 'example'}) // => {title: 'example', published: true} - */ - function set(prop: string, val: any, obj: Object): Object; - - function set(prop: string, val: any): (obj: Object) => Object; - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Logs values to the console, a simple wrapper around `console.log` that - * it suitable for passing to other functions by reference without having to - * call `bind`. - * - * @id log - * @section Utils - * @name _.log(args..) - * @api public - * - * _.log('Hello, world!'); - * - * _([1, 2, 3, 4]).each(_.log); - */ - function log(x: any, ...args: any[]): void; - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Wraps a node-style async function which accepts a callback, transforming - * it to a function which accepts the same arguments minus the callback and - * returns a Highland Stream instead. Only the first argument to the - * callback (or an error) will be pushed onto the Stream. - * - * @id wrapCallback - * @section Utils - * @name _.wrapCallback(f) - * @param {Function} f - the node-style function to wrap - * @api public - * - * var fs = require('fs'); - * - * var readFile = _.wrapCallback(fs.readFile); - * - * readFile('example.txt').apply(function (data) { - * // data is now the contents of example.txt - * }); - */ - function wrapCallback(f: Function): Function; - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Add two values. Can be partially applied. - * - * @id add - * @section Operators - * @name _.add(a, b) - * @api public - * - * add(1, 2) === 3 - * add(1)(5) === 6 - */ - function add(a: number, b: number): number; - - function add(a: number): (b: number) => number; - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } + +declare var highland:HighlandStatic; + declare module 'highland' { -export = Highland; + export = highland; } + From f1ca4ab75f83c56301ade4758cf212a3574974d7 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Tue, 25 Feb 2014 14:51:52 -0800 Subject: [PATCH 202/240] add module declaration to bigscreen.d.ts --- bigscreen/bigscreen-tests.ts | 2 ++ bigscreen/bigscreen.d.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bigscreen/bigscreen-tests.ts b/bigscreen/bigscreen-tests.ts index 0ae13acd73..9e0c9fda8c 100644 --- a/bigscreen/bigscreen-tests.ts +++ b/bigscreen/bigscreen-tests.ts @@ -1,5 +1,7 @@ /// +import BigScreen = require("bigscreen"); + BigScreen.onchange = function(element: Element) { console.log("Full-screen element " + element + " changed."); } diff --git a/bigscreen/bigscreen.d.ts b/bigscreen/bigscreen.d.ts index bdabdc101d..8bec685ff8 100644 --- a/bigscreen/bigscreen.d.ts +++ b/bigscreen/bigscreen.d.ts @@ -4,9 +4,11 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped interface BigScreenStatic { - element: any; + // Properties + element: Element; enabled: boolean; + // Methods exit(): void; onchange(element: Element): void; onenter(element: Element): void; @@ -17,4 +19,8 @@ interface BigScreenStatic { videoEnabled(video: HTMLVideoElement): boolean; } -declare var BigScreen: BigScreenStatic; +declare var bigscreen: BigScreenStatic; + +declare module "bigscreen" { + export = bigscreen; +} From 53a1f820ca2b1ea6088b22270e1358b2b8955ac1 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 09:32:53 +0900 Subject: [PATCH 203/240] Added a new version of TypeScript (0.9.7) --- .../tests/typescript/0.9.7/lib.d.ts | 14931 ++++ _infrastructure/tests/typescript/0.9.7/tsc | 2 + _infrastructure/tests/typescript/0.9.7/tsc.js | 62790 ++++++++++++++++ .../tests/typescript/0.9.7/typescript.js | 61380 +++++++++++++++ 4 files changed, 139103 insertions(+) create mode 100644 _infrastructure/tests/typescript/0.9.7/lib.d.ts create mode 100644 _infrastructure/tests/typescript/0.9.7/tsc create mode 100644 _infrastructure/tests/typescript/0.9.7/tsc.js create mode 100644 _infrastructure/tests/typescript/0.9.7/typescript.js diff --git a/_infrastructure/tests/typescript/0.9.7/lib.d.ts b/_infrastructure/tests/typescript/0.9.7/lib.d.ts new file mode 100644 index 0000000000..94c477fd4a --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7/lib.d.ts @@ -0,0 +1,14931 @@ +/* ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + +///////////////////////////// +/// ECMAScript APIs +///////////////////////////// + +declare var NaN: number; +declare var Infinity: number; + +/** + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ +declare function eval(x: string): any; + +/** + * Converts A string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ +declare function parseInt(s: string, radix?: number): number; + +/** + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ +declare function parseFloat(string: string): number; + +/** + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ +declare function isNaN(number: number): boolean; + +/** + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ +declare function isFinite(number: number): boolean; + +/** + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ +declare function decodeURI(encodedURI: string): string; + +/** + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ +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; + +/** + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ +declare function encodeURIComponent(uriComponent: string): string; + +interface PropertyDescriptor { + configurable?: boolean; + enumerable?: boolean; + value?: any; + writable?: boolean; + get? (): any; + set? (v: any): void; +} + +interface PropertyDescriptorMap { + [s: string]: PropertyDescriptor; +} + +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; + + /** Returns the primitive value of the specified object. */ + valueOf(): Object; + + /** + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ + hasOwnProperty(v: string): boolean; + + /** + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ + isPrototypeOf(v: Object): boolean; + + /** + * Determines whether a specified property is enumerable. + * @param v A property name. + */ + propertyIsEnumerable(v: string): boolean; +} + +/** + * Provides functionality common to all JavaScript objects. + */ +declare var Object: { + new (value?: any): Object; + (): any; + (value: any): any; + + /** A reference to the prototype for a class of objects. */ + prototype: Object; + + /** + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ + getPrototypeOf(o: any): any; + + /** + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + + /** + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ + getOwnPropertyNames(o: any): string[]; + + /** + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ + create(o: any, properties?: PropertyDescriptorMap): any; + + /** + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ + defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; + + /** + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ + defineProperties(o: any, properties: PropertyDescriptorMap): any; + + /** + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + seal(o: any): any; + + /** + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(o: any): any; + + /** + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ + preventExtensions(o: any): any; + + /** + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ + isSealed(o: any): boolean; + + /** + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ + isFrozen(o: any): boolean; + + /** + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ + isExtensible(o: any): boolean; + + /** + * Returns the names of the enumerable properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: any): string[]; +} + +/** + * Creates a new function. + */ +interface Function { + /** + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ + apply(thisArg: any, argArray?: any): any; + + /** + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ + call(thisArg: any, ...argArray: any[]): any; + + /** + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ + bind(thisArg: any, ...argArray: any[]): any; + + prototype: any; + length: number; + + // Non-standard extensions + arguments: any; + caller: Function; +} + +declare var Function: { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; +} + +interface IArguments { + [index: number]: any; + length: number; + callee: Function; +} + +interface String { + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Removes the leading and trailing white space and line terminator characters from a string. */ + trim(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; +} + +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ +declare var String: { + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; +} + +interface Boolean { +} +declare var Boolean: { + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; +} + +interface Number { + /** + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ + toString(radix?: number): string; + + /** + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toFixed(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ + toExponential(fractionDigits?: number): string; + + /** + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ + toPrecision(precision?: number): string; +} + +/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ +declare var Number: { + new (value?: any): Number; + (value?: any): number; + prototype: Number; + + /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ + MAX_VALUE: number; + + /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ + MIN_VALUE: number; + + /** + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ + NaN: number; + + /** + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ + NEGATIVE_INFINITY: number; + + /** + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ + POSITIVE_INFINITY: number; +} + +interface Math { + /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ + E: number; + /** The natural logarithm of 10. */ + LN10: number; + /** The natural logarithm of 2. */ + LN2: number; + /** The base-2 logarithm of e. */ + LOG2E: number; + /** The base-10 logarithm of e. */ + LOG10E: number; + /** Pi. This is the ratio of the circumference of a circle to its diameter. */ + PI: number; + /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ + SQRT1_2: number; + /** The square root of 2. */ + SQRT2: number; + /** + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ + abs(x: number): number; + /** + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ + acos(x: number): number; + /** + * Returns the arcsine of a number. + * @param x A numeric expression. + */ + asin(x: number): number; + /** + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ + atan(x: number): number; + /** + * Returns the angle (in radians) from the X axis to a point (y,x). + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ + atan2(y: number, x: number): number; + /** + * Returns the smallest number greater than or equal to its numeric argument. + * @param x A numeric expression. + */ + ceil(x: number): number; + /** + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + cos(x: number): number; + /** + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ + exp(x: number): number; + /** + * Returns the greatest number less than or equal to its numeric argument. + * @param x A numeric expression. + */ + floor(x: number): number; + /** + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ + log(x: number): number; + /** + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + max(...values: number[]): number; + /** + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ + min(...values: number[]): number; + /** + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ + pow(x: number, y: number): number; + /** Returns a pseudorandom number between 0 and 1. */ + random(): number; + /** + * Returns a supplied numeric expression rounded to the nearest number. + * @param x The value to be rounded to the nearest number. + */ + round(x: number): number; + /** + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + sin(x: number): number; + /** + * Returns the square root of a number. + * @param x A numeric expression. + */ + sqrt(x: number): number; + /** + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ + tan(x: number): number; +} +/** An intrinsic object that provides basic mathematics functionality and constants. */ +declare var Math: Math; + +/** Enables basic storage and retrieval of dates and times. */ +interface Date { + /** Returns a string representation of a date. The format of the string depends on the locale. */ + toString(): string; + /** Returns a date as a string value. */ + toDateString(): string; + /** Returns a time as a string value. */ + toTimeString(): string; + /** Returns a value as a string value appropriate to the host environment's current locale. */ + toLocaleString(): string; + /** Returns a date as a string value appropriate to the host environment's current locale. */ + toLocaleDateString(): string; + /** Returns a time as a string value appropriate to the host environment's current locale. */ + toLocaleTimeString(): string; + /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ + valueOf(): number; + /** Gets the time value in milliseconds. */ + getTime(): number; + /** Gets the year, using local time. */ + getFullYear(): number; + /** Gets the year using Universal Coordinated Time (UTC). */ + getUTCFullYear(): number; + /** Gets the month, using local time. */ + getMonth(): number; + /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ + getUTCMonth(): number; + /** Gets the day-of-the-month, using local time. */ + getDate(): number; + /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ + getUTCDate(): number; + /** Gets the day of the week, using local time. */ + getDay(): number; + /** Gets the day of the week using Universal Coordinated Time (UTC). */ + getUTCDay(): number; + /** Gets the hours in a date, using local time. */ + getHours(): number; + /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ + getUTCHours(): number; + /** Gets the minutes of a Date object, using local time. */ + getMinutes(): number; + /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ + getUTCMinutes(): number; + /** Gets the seconds of a Date object, using local time. */ + getSeconds(): number; + /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCSeconds(): number; + /** Gets the milliseconds of a Date, using local time. */ + getMilliseconds(): number; + /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ + getUTCMilliseconds(): number; + /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + getTimezoneOffset(): number; + /** + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ + 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): 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): 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): 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): 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): 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): number; + /** + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + setHours(hours: number, min?: number, sec?: number, ms?: number): number; + /** + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ + 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): 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): 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): 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): 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): 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): 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. */ + toISOString(): string; + /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ + toJSON(key?: any): string; +} + +declare var Date: { + new (): Date; + new (value: number): Date; + new (value: string): Date; + new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; + (): string; + prototype: Date; + /** + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ + parse(s: string): number; + /** + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as an number between 0 and 11 (January to December). + * @param date The date as an number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. + * @param ms An number from 0 to 999 that specifies the milliseconds. + */ + UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; + now(): number; +} + +interface RegExpExecArray { + [index: number]: string; + length: number; + + index: number; + input: string; + + toString(): string; + toLocaleString(): string; + concat(...items: string[][]): string[]; + join(separator?: string): string; + pop(): string; + push(...items: string[]): number; + reverse(): string[]; + shift(): 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[]; + unshift(...items: string[]): number; + + indexOf(searchElement: string, fromIndex?: number): number; + lastIndexOf(searchElement: string, fromIndex?: number): number; + every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; + forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; + map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; + filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; + reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; + reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; +} + + +interface RegExp { + /** + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ + 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. + */ + test(string: string): boolean; + + /** 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; + + /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ + ignoreCase: boolean; + + /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ + multiline: boolean; + + lastIndex: number; + + // Non-standard extensions + compile(): RegExp; +} +declare var RegExp: { + new (pattern: string, flags?: string): RegExp; + (pattern: string, flags?: string): RegExp; + + // Non-standard extensions + $1: string; + $2: string; + $3: string; + $4: string; + $5: string; + $6: string; + $7: string; + $8: string; + $9: string; + lastMatch: string; +} + +interface Error { + name: string; + message: string; +} +declare var Error: { + new (message?: string): Error; + (message?: string): Error; + prototype: Error; +} + +interface EvalError extends Error { +} +declare var EvalError: { + new (message?: string): EvalError; + (message?: string): EvalError; + prototype: EvalError; +} + +interface RangeError extends Error { +} +declare var RangeError: { + new (message?: string): RangeError; + (message?: string): RangeError; + prototype: RangeError; +} + +interface ReferenceError extends Error { +} +declare var ReferenceError: { + new (message?: string): ReferenceError; + (message?: string): ReferenceError; + prototype: ReferenceError; +} + +interface SyntaxError extends Error { +} +declare var SyntaxError: { + new (message?: string): SyntaxError; + (message?: string): SyntaxError; + prototype: SyntaxError; +} + +interface TypeError extends Error { +} +declare var TypeError: { + new (message?: string): TypeError; + (message?: string): TypeError; + prototype: TypeError; +} + +interface URIError extends Error { +} +declare var URIError: { + new (message?: string): URIError; + (message?: string): URIError; + prototype: URIError; +} + +interface JSON { + /** + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ + parse(text: string, reviver?: (key: any, value: any) => any): any; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + */ + stringify(value: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + */ + stringify(value: any, replacer: (key: string, value: any) => any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + */ + stringify(value: any, replacer: any[]): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; + /** + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer Array that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ + stringify(value: any, replacer: any[], space: any): string; +} +/** + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ +declare var JSON: JSON; + + +///////////////////////////// +/// ECMAScript Array API (specially handled by compiler) +///////////////////////////// + +interface Array { + /** + * Returns a string representation of an array. + */ + toString(): string; + toLocaleString(): string; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: T[]): T[]; + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ + join(separator?: string): string; + /** + * Removes the last element from an array and returns it. + */ + pop(): T; + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ + push(...items: T[]): number; + /** + * Reverses the elements in an Array. + */ + reverse(): T[]; + /** + * Removes the first element from an array and returns it. + */ + shift(): T; + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + */ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + */ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ + length: number; + + [n: number]: T; +} +declare var Array: { + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; +} + + +///////////////////////////// +/// IE10 ECMAScript Extensions +///////////////////////////// + +/** + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ +interface ArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + byteLength: number; +} + +declare var ArrayBuffer: { + prototype: ArrayBuffer; + new (byteLength: number): ArrayBuffer; +} + +interface ArrayBufferView { + buffer: ArrayBuffer; + byteOffset: number; + byteLength: number; +} + +/** + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int8Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int8Array; +} +declare var Int8Array: { + prototype: Int8Array; + new (length: number): Int8Array; + new (array: Int8Array): Int8Array; + new (array: number[]): Int8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint8Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint8Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Uint8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint8Array; +} +declare var Uint8Array: { + prototype: Uint8Array; + new (length: number): Uint8Array; + new (array: Uint8Array): Uint8Array; + new (array: number[]): Uint8Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 16-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int16Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int16Array; +} +declare var Int16Array: { + prototype: Int16Array; + new (length: number): Int16Array; + new (array: Int16Array): Int16Array; + new (array: number[]): Int16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint16Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint16Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Uint16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint16Array; +} +declare var Uint16Array: { + prototype: Uint16Array; + new (length: number): Uint16Array; + new (array: Uint16Array): Uint16Array; + new (array: number[]): Uint16Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Int32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Int32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Int32Array; +} +declare var Int32Array: { + prototype: Int32Array; + new (length: number): Int32Array; + new (array: Int32Array): Int32Array; + new (array: number[]): Int32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Uint32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Uint32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Uint32Array; +} +declare var Uint32Array: { + prototype: Uint32Array; + new (length: number): Uint32Array; + new (array: Uint32Array): Uint32Array; + new (array: number[]): Uint32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Float32Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float32Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Float32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float32Array; +} +declare var Float32Array: { + prototype: Float32Array; + new (length: number): Float32Array; + new (array: Float32Array): Float32Array; + new (array: number[]): Float32Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + BYTES_PER_ELEMENT: number; +} + +/** + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. + */ +interface Float64Array extends ArrayBufferView { + /** + * The size in bytes of each element in the array. + */ + BYTES_PER_ELEMENT: number; + + /** + * The length of the array. + */ + length: number; + [index: number]: number; + + /** + * Gets the element at the specified index. + * @param index The index at which to get the element of the array. + */ + get(index: number): number; + + /** + * Sets a value or an array of values. + * @param index The index of the location to set. + * @param value The value to set. + */ + set(index: number, value: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: Float64Array, offset?: number): void; + + /** + * Sets a value or an array of values. + * @param A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ + set(array: number[], offset?: number): void; + + /** + * Gets a new Float64Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin: number, end?: number): Float64Array; +} +declare var Float64Array: { + prototype: Float64Array; + new (length: number): Float64Array; + new (array: Float64Array): Float64Array; + new (array: number[]): Float64Array; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + BYTES_PER_ELEMENT: number; +} + +/** + * You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer. + */ +interface DataView extends ArrayBufferView { + /** + * Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt8(byteOffset: number): number; + + /** + * Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint8(byteOffset: number): number; + + /** + * Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint16(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getInt32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getUint32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat32(byteOffset: number, littleEndian?: boolean): number; + + /** + * Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ + getFloat64(byteOffset: number, littleEndian?: boolean): number; + + /** + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setInt8(byteOffset: number, value: number): void; + + /** + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ + setUint8(byteOffset: number, value: number): void; + + /** + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; + + /** + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. + */ + setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; +} +declare var DataView: { + prototype: DataView; + new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; +} + +///////////////////////////// +/// IE11 ECMAScript Extensions +///////////////////////////// + +interface Map { + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): Map; + size: number; +} +declare var Map: { + new (): Map; +} + +interface WeakMap { + clear(): void; + delete(key: K): boolean; + get(key: K): V; + has(key: K): boolean; + set(key: K, value: V): WeakMap; +} +declare var WeakMap: { + new (): WeakMap; +} + +interface Set { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + size: number; +} +declare var Set: { + new (): Set; +} + +declare module Intl { + + interface CollatorOptions { + usage?: string; + localeMatcher?: string; + numeric?: boolean; + caseFirst?: string; + sensitivity?: string; + ignorePunctuation?: boolean; + } + + interface ResolvedCollatorOptions { + locale: string; + usage: string; + sensitivity: string; + ignorePunctuation: boolean; + collation: string; + caseFirst: string; + numeric: boolean; + } + + interface Collator { + compare(x: string, y: string): number; + resolvedOptions(): ResolvedCollatorOptions; + } + var Collator: { + new (locales?: string[], options?: CollatorOptions): Collator; + new (locale?: string, options?: CollatorOptions): Collator; + (locales?: string[], options?: CollatorOptions): Collator; + (locale?: string, options?: CollatorOptions): Collator; + supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; + supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; + } + + interface NumberFormatOptions { + localeMatcher?: string; + style?: string; + currency?: string; + currencyDisplay?: string; + useGrouping?: boolean; + } + + interface ResolvedNumberFormatOptions { + locale: string; + numberingSystem: string; + style: string; + currency?: string; + currencyDisplay?: string; + minimumintegerDigits: number; + minimumFractionDigits: number; + maximumFractionDigits: number; + minimumSignificantDigits?: number; + maximumSignificantDigits?: number; + useGrouping: boolean; + } + + interface NumberFormat { + format(value: number): string; + resolvedOptions(): ResolvedNumberFormatOptions; + } + var NumberFormat: { + new (locales?: string[], options?: NumberFormatOptions): Collator; + new (locale?: string, options?: NumberFormatOptions): Collator; + (locales?: string[], options?: NumberFormatOptions): Collator; + (locale?: string, options?: NumberFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; + } + + interface DateTimeFormatOptions { + localeMatcher?: string; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + formatMatcher?: string; + hour12: boolean; + } + + interface ResolvedDateTimeFormatOptions { + locale: string; + calendar: string; + numberingSystem: string; + timeZone: string; + hour12?: boolean; + weekday?: string; + era?: string; + year?: string; + month?: string; + day?: string; + hour?: string; + minute?: string; + second?: string; + timeZoneName?: string; + } + + interface DateTimeFormat { + format(date: number): string; + resolvedOptions(): ResolvedDateTimeFormatOptions; + } + var DateTimeFormat: { + new (locales?: string[], options?: DateTimeFormatOptions): Collator; + new (locale?: string, options?: DateTimeFormatOptions): Collator; + (locales?: string[], options?: DateTimeFormatOptions): Collator; + (locale?: string, options?: DateTimeFormatOptions): Collator; + supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; + supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; + } +} + +interface String { + localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; + localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; +} + +interface Number { + 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; +} + + +///////////////////////////// +/// IE9 DOM APIs +///////////////////////////// + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface NavigatorID { + appVersion: string; + appName: string; + userAgent: string; + platform: string; +} + +interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the amount of space between cells in a table. + */ + cellSpacing: string; + /** + * Retrieves the tFoot object of the table. + */ + tFoot: HTMLTableSectionElement; + /** + * Sets or retrieves the way the border frame around the table is displayed. + */ + frame: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Sets or retrieves which dividing lines (inner borders) are displayed. + */ + rules: string; + /** + * Sets or retrieves the number of columns in the table. + */ + cols: number; + /** + * Sets or retrieves a description and/or structure of the object. + */ + summary: string; + /** + * Retrieves the caption object of a table. + */ + caption: HTMLTableCaptionElement; + /** + * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. + */ + tBodies: HTMLCollection; + /** + * Retrieves the tHead object of the table. + */ + tHead: HTMLTableSectionElement; + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Retrieves a collection of all cells in the table row or in the entire table. + */ + cells: HTMLCollection; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the amount of space between the border of the cell and the content of the cell. + */ + cellPadding: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Creates an empty tBody element in the table. + */ + createTBody(): HTMLElement; + /** + * Deletes the caption element and its contents from the table. + */ + deleteCaption(): void; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; + /** + * Deletes the tFoot element and its contents from the table. + */ + deleteTFoot(): void; + /** + * Returns the tHead element object if successful, or null otherwise. + */ + createTHead(): HTMLElement; + /** + * Deletes the tHead element and its contents from the table. + */ + deleteTHead(): void; + /** + * Creates an empty caption element in the table. + */ + createCaption(): HTMLElement; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): Object; + /** + * Creates an empty tFoot element in the table. + */ + createTFoot(): HTMLElement; +} +declare var HTMLTableElement: { + prototype: HTMLTableElement; + new (): HTMLTableElement; +} + +interface TreeWalker { + whatToShow: number; + filter: NodeFilter; + root: Node; + currentNode: Node; + expandEntityReferences: boolean; + previousSibling(): Node; + lastChild(): Node; + nextSibling(): Node; + nextNode(): Node; + parentNode(): Node; + firstChild(): Node; + previousNode(): Node; +} +declare var TreeWalker: { + prototype: TreeWalker; + new (): TreeWalker; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticRel: { + prototype: SVGPathSegCurvetoQuadraticRel; + new (): SVGPathSegCurvetoQuadraticRel; +} + +interface Performance { + navigation: PerformanceNavigation; + timing: PerformanceTiming; + getEntriesByType(entryType: string): any; + toJSON(): any; + getMeasures(measureName?: string): any; + clearMarks(markName?: string): void; + getMarks(markName?: string): any; + clearResourceTimings(): void; + mark(markName: string): void; + measure(measureName: string, startMarkName?: string, endMarkName?: string): void; + getEntriesByName(name: string, entryType?: string): any; + getEntries(): any; + clearMeasures(measureName?: string): void; + setResourceTimingBufferSize(maxSize: number): void; +} +declare var Performance: { + prototype: Performance; + new (): Performance; +} + +interface MSDataBindingTableExtensions { + dataPageSize: number; + nextPage(): void; + firstPage(): void; + refresh(): void; + previousPage(): void; + lastPage(): void; +} + +interface CompositionEvent extends UIEvent { + data: string; + locale: string; + initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; +} +declare var CompositionEvent: { + prototype: CompositionEvent; + new (): CompositionEvent; +} + +interface WindowTimers { + clearTimeout(handle: number): void; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; + clearInterval(handle: number): void; + setInterval(handler: any, timeout?: any, ...args: any[]): number; +} + +interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { + orientType: SVGAnimatedEnumeration; + markerUnits: SVGAnimatedEnumeration; + markerWidth: SVGAnimatedLength; + markerHeight: SVGAnimatedLength; + orientAngle: SVGAnimatedAngle; + refY: SVGAnimatedLength; + refX: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new (): SVGMarkerElement; + SVG_MARKER_ORIENT_UNKNOWN: number; + SVG_MARKER_ORIENT_ANGLE: number; + SVG_MARKERUNITS_UNKNOWN: number; + SVG_MARKERUNITS_STROKEWIDTH: number; + SVG_MARKER_ORIENT_AUTO: number; + SVG_MARKERUNITS_USERSPACEONUSE: number; +} + +interface CSSStyleDeclaration { + backgroundAttachment: string; + visibility: string; + textAlignLast: string; + borderRightStyle: string; + counterIncrement: string; + orphans: string; + cssText: string; + borderStyle: string; + pointerEvents: string; + borderTopColor: string; + markerEnd: string; + textIndent: string; + listStyleImage: string; + cursor: string; + listStylePosition: string; + wordWrap: string; + borderTopStyle: string; + alignmentBaseline: string; + opacity: string; + direction: string; + strokeMiterlimit: string; + maxWidth: string; + color: string; + clip: string; + borderRightWidth: string; + verticalAlign: string; + overflow: string; + mask: string; + borderLeftStyle: string; + emptyCells: string; + stopOpacity: string; + paddingRight: string; + parentRule: CSSRule; + background: string; + boxSizing: string; + textJustify: string; + height: string; + paddingTop: string; + length: number; + right: string; + baselineShift: string; + borderLeft: string; + widows: string; + lineHeight: string; + left: string; + textUnderlinePosition: string; + glyphOrientationHorizontal: string; + display: string; + textAnchor: string; + cssFloat: string; + strokeDasharray: string; + rubyAlign: string; + fontSizeAdjust: string; + borderLeftColor: string; + backgroundImage: string; + listStyleType: string; + strokeWidth: string; + textOverflow: string; + fillRule: string; + borderBottomColor: string; + zIndex: string; + position: string; + listStyle: string; + msTransformOrigin: string; + dominantBaseline: string; + overflowY: string; + fill: string; + captionSide: string; + borderCollapse: string; + boxShadow: string; + quotes: string; + tableLayout: string; + unicodeBidi: string; + borderBottomWidth: string; + backgroundSize: string; + textDecoration: string; + strokeDashoffset: string; + fontSize: string; + border: string; + pageBreakBefore: string; + borderTopRightRadius: string; + msTransform: string; + borderBottomLeftRadius: string; + textTransform: string; + rubyPosition: string; + strokeLinejoin: string; + clipPath: string; + borderRightColor: string; + fontFamily: string; + clear: string; + content: string; + backgroundClip: string; + marginBottom: string; + counterReset: string; + outlineWidth: string; + marginRight: string; + paddingLeft: string; + borderBottom: string; + wordBreak: string; + marginTop: string; + top: string; + fontWeight: string; + borderRight: string; + width: string; + kerning: string; + pageBreakAfter: string; + borderBottomStyle: string; + fontStretch: string; + padding: string; + strokeOpacity: string; + markerStart: string; + bottom: string; + borderLeftWidth: string; + clipRule: string; + backgroundPosition: string; + backgroundColor: string; + pageBreakInside: string; + backgroundOrigin: string; + strokeLinecap: string; + borderTopWidth: string; + outlineStyle: string; + borderTop: string; + outlineColor: string; + paddingBottom: string; + marginLeft: string; + font: string; + outline: string; + wordSpacing: string; + maxHeight: string; + fillOpacity: string; + letterSpacing: string; + borderSpacing: string; + backgroundRepeat: string; + borderRadius: string; + borderWidth: string; + borderBottomRightRadius: string; + whiteSpace: string; + fontStyle: string; + minWidth: string; + stopColor: string; + borderTopLeftRadius: string; + borderColor: string; + marker: string; + glyphOrientationVertical: string; + markerMid: string; + fontVariant: string; + minHeight: string; + stroke: string; + rubyOverhang: string; + overflowX: string; + textAlign: string; + margin: string; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + removeProperty(propertyName: string): string; + item(index: number): string; + [index: number]: string; + setProperty(propertyName: string, value: string, priority?: string): void; +} +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new (): CSSStyleDeclaration; +} + +interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGGElement: { + prototype: SVGGElement; + new (): SVGGElement; +} + +interface MSStyleCSSProperties extends MSCSSProperties { + pixelWidth: number; + posHeight: number; + posLeft: number; + pixelTop: number; + pixelBottom: number; + textDecorationNone: boolean; + pixelLeft: number; + posTop: number; + posBottom: number; + textDecorationOverline: boolean; + posWidth: number; + textDecorationLineThrough: boolean; + pixelHeight: number; + textDecorationBlink: boolean; + posRight: number; + pixelRight: number; + textDecorationUnderline: boolean; +} +declare var MSStyleCSSProperties: { + prototype: MSStyleCSSProperties; + new (): MSStyleCSSProperties; +} + +interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils { +} +declare var Navigator: { + prototype: Navigator; + new (): Navigator; +} + +interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothAbs: { + prototype: SVGPathSegCurvetoCubicSmoothAbs; + new (): SVGPathSegCurvetoCubicSmoothAbs; +} + +interface SVGZoomEvent extends UIEvent { + zoomRectScreen: SVGRect; + previousScale: number; + newScale: number; + previousTranslate: SVGPoint; + newTranslate: SVGPoint; +} +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new (): SVGZoomEvent; +} + +interface NodeSelector { + querySelectorAll(selectors: string): NodeList; + querySelector(selectors: string): Element; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { +} +declare var HTMLTableDataCellElement: { + prototype: HTMLTableDataCellElement; + new (): HTMLTableDataCellElement; +} + +interface HTMLBaseElement extends HTMLElement { + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Gets or sets the baseline URL on which relative links are based. + */ + href: string; +} +declare var HTMLBaseElement: { + prototype: HTMLBaseElement; + new (): HTMLBaseElement; +} + +interface ClientRect { + left: number; + width: number; + right: number; + top: number; + bottom: number; + height: number; +} +declare var ClientRect: { + prototype: ClientRect; + new (): ClientRect; +} + +interface PositionErrorCallback { + (error: PositionError): void; +} + +interface DOMImplementation { + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; + hasFeature(feature: string, version?: string): boolean; + createHTMLDocument(title: string): Document; +} +declare var DOMImplementation: { + prototype: DOMImplementation; + new (): DOMImplementation; +} + +interface SVGUnitTypes { + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: { + prototype: SVGUnitTypes; + new (): SVGUnitTypes; + SVG_UNIT_TYPE_UNKNOWN: number; + SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + SVG_UNIT_TYPE_USERSPACEONUSE: number; +} + +interface Element extends Node, NodeSelector, ElementTraversal { + scrollTop: number; + clientLeft: number; + scrollLeft: number; + tagName: string; + clientWidth: number; + scrollWidth: number; + clientHeight: number; + clientTop: number; + scrollHeight: number; + getAttribute(name?: string): string; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + hasAttributeNS(namespaceURI: string, localName: string): boolean; + getBoundingClientRect(): ClientRect; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + setAttributeNodeNS(newAttr: Attr): Attr; + msMatchesSelector(selectors: string): boolean; + hasAttribute(name: string): boolean; + removeAttribute(name?: string): void; + setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; + getAttributeNode(name: string): Attr; + fireEvent(eventName: string, eventObj?: any): boolean; + getElementsByTagName(name: "a"): NodeListOf; + getElementsByTagName(name: "abbr"): NodeListOf; + getElementsByTagName(name: "address"): NodeListOf; + getElementsByTagName(name: "area"): NodeListOf; + getElementsByTagName(name: "article"): NodeListOf; + getElementsByTagName(name: "aside"): NodeListOf; + getElementsByTagName(name: "audio"): NodeListOf; + getElementsByTagName(name: "b"): NodeListOf; + getElementsByTagName(name: "base"): NodeListOf; + getElementsByTagName(name: "bdi"): NodeListOf; + getElementsByTagName(name: "bdo"): NodeListOf; + getElementsByTagName(name: "blockquote"): NodeListOf; + getElementsByTagName(name: "body"): NodeListOf; + getElementsByTagName(name: "br"): NodeListOf; + getElementsByTagName(name: "button"): NodeListOf; + getElementsByTagName(name: "canvas"): NodeListOf; + getElementsByTagName(name: "caption"): NodeListOf; + getElementsByTagName(name: "cite"): NodeListOf; + getElementsByTagName(name: "code"): NodeListOf; + getElementsByTagName(name: "col"): NodeListOf; + getElementsByTagName(name: "colgroup"): NodeListOf; + getElementsByTagName(name: "datalist"): NodeListOf; + getElementsByTagName(name: "dd"): NodeListOf; + getElementsByTagName(name: "del"): NodeListOf; + getElementsByTagName(name: "dfn"): NodeListOf; + getElementsByTagName(name: "div"): NodeListOf; + getElementsByTagName(name: "dl"): NodeListOf; + getElementsByTagName(name: "dt"): NodeListOf; + getElementsByTagName(name: "em"): NodeListOf; + getElementsByTagName(name: "embed"): NodeListOf; + getElementsByTagName(name: "fieldset"): NodeListOf; + getElementsByTagName(name: "figcaption"): NodeListOf; + getElementsByTagName(name: "figure"): NodeListOf; + getElementsByTagName(name: "footer"): NodeListOf; + getElementsByTagName(name: "form"): NodeListOf; + getElementsByTagName(name: "h1"): NodeListOf; + getElementsByTagName(name: "h2"): NodeListOf; + getElementsByTagName(name: "h3"): NodeListOf; + getElementsByTagName(name: "h4"): NodeListOf; + getElementsByTagName(name: "h5"): NodeListOf; + getElementsByTagName(name: "h6"): NodeListOf; + getElementsByTagName(name: "head"): NodeListOf; + getElementsByTagName(name: "header"): NodeListOf; + getElementsByTagName(name: "hgroup"): NodeListOf; + getElementsByTagName(name: "hr"): NodeListOf; + getElementsByTagName(name: "html"): NodeListOf; + getElementsByTagName(name: "i"): NodeListOf; + getElementsByTagName(name: "iframe"): NodeListOf; + getElementsByTagName(name: "img"): NodeListOf; + getElementsByTagName(name: "input"): NodeListOf; + getElementsByTagName(name: "ins"): NodeListOf; + getElementsByTagName(name: "kbd"): NodeListOf; + getElementsByTagName(name: "label"): NodeListOf; + getElementsByTagName(name: "legend"): NodeListOf; + getElementsByTagName(name: "li"): NodeListOf; + getElementsByTagName(name: "link"): NodeListOf; + getElementsByTagName(name: "main"): NodeListOf; + getElementsByTagName(name: "map"): NodeListOf; + getElementsByTagName(name: "mark"): NodeListOf; + getElementsByTagName(name: "menu"): NodeListOf; + getElementsByTagName(name: "meta"): NodeListOf; + getElementsByTagName(name: "nav"): NodeListOf; + getElementsByTagName(name: "noscript"): NodeListOf; + getElementsByTagName(name: "object"): NodeListOf; + getElementsByTagName(name: "ol"): NodeListOf; + getElementsByTagName(name: "optgroup"): NodeListOf; + getElementsByTagName(name: "option"): NodeListOf; + getElementsByTagName(name: "p"): NodeListOf; + getElementsByTagName(name: "param"): NodeListOf; + getElementsByTagName(name: "pre"): NodeListOf; + getElementsByTagName(name: "progress"): NodeListOf; + getElementsByTagName(name: "q"): NodeListOf; + getElementsByTagName(name: "rp"): NodeListOf; + getElementsByTagName(name: "rt"): NodeListOf; + getElementsByTagName(name: "ruby"): NodeListOf; + getElementsByTagName(name: "s"): NodeListOf; + getElementsByTagName(name: "samp"): NodeListOf; + getElementsByTagName(name: "script"): NodeListOf; + getElementsByTagName(name: "section"): NodeListOf; + getElementsByTagName(name: "select"): NodeListOf; + getElementsByTagName(name: "small"): NodeListOf; + getElementsByTagName(name: "source"): NodeListOf; + getElementsByTagName(name: "span"): NodeListOf; + getElementsByTagName(name: "strong"): NodeListOf; + getElementsByTagName(name: "style"): NodeListOf; + getElementsByTagName(name: "sub"): NodeListOf; + getElementsByTagName(name: "summary"): NodeListOf; + getElementsByTagName(name: "sup"): NodeListOf; + getElementsByTagName(name: "table"): NodeListOf; + getElementsByTagName(name: "tbody"): NodeListOf; + getElementsByTagName(name: "td"): NodeListOf; + getElementsByTagName(name: "textarea"): NodeListOf; + getElementsByTagName(name: "tfoot"): NodeListOf; + getElementsByTagName(name: "th"): NodeListOf; + getElementsByTagName(name: "thead"): NodeListOf; + getElementsByTagName(name: "title"): NodeListOf; + getElementsByTagName(name: "tr"): NodeListOf; + getElementsByTagName(name: "track"): NodeListOf; + getElementsByTagName(name: "u"): NodeListOf; + getElementsByTagName(name: "ul"): NodeListOf; + getElementsByTagName(name: "var"): NodeListOf; + getElementsByTagName(name: "video"): NodeListOf; + getElementsByTagName(name: "wbr"): NodeListOf; + getElementsByTagName(name: string): NodeList; + getClientRects(): ClientRectList; + setAttributeNode(newAttr: Attr): Attr; + removeAttributeNode(oldAttr: Attr): Attr; + setAttribute(name?: string, value?: string): void; + removeAttributeNS(namespaceURI: string, localName: string): void; +} +declare var Element: { + prototype: Element; + new (): Element; +} + +interface HTMLNextIdElement extends HTMLElement { + n: string; +} +declare var HTMLNextIdElement: { + prototype: HTMLNextIdElement; + new (): HTMLNextIdElement; +} + +interface SVGPathSegMovetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoRel: { + prototype: SVGPathSegMovetoRel; + new (): SVGPathSegMovetoRel; +} + +interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLineElement: { + prototype: SVGLineElement; + new (): SVGLineElement; +} + +interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; +} +declare var HTMLParagraphElement: { + prototype: HTMLParagraphElement; + new (): HTMLParagraphElement; +} + +interface HTMLAreasCollection extends HTMLCollection { + /** + * Removes an element from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + */ + add(element: HTMLElement, before?: any): void; +} +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new (): HTMLAreasCollection; +} + +interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGDescElement: { + prototype: SVGDescElement; + new (): SVGDescElement; +} + +interface Node extends EventTarget { + nodeType: number; + previousSibling: Node; + localName: string; + namespaceURI: string; + textContent: string; + parentNode: Node; + nextSibling: Node; + nodeValue: string; + lastChild: Node; + childNodes: NodeList; + nodeName: string; + ownerDocument: Document; + attributes: NamedNodeMap; + firstChild: Node; + prefix: string; + removeChild(oldChild: Node): Node; + appendChild(newChild: Node): Node; + isSupported(feature: string, version: string): boolean; + isEqualNode(arg: Node): boolean; + lookupPrefix(namespaceURI: string): string; + isDefaultNamespace(namespaceURI: string): boolean; + compareDocumentPosition(other: Node): number; + normalize(): void; + isSameNode(other: Node): boolean; + hasAttributes(): boolean; + lookupNamespaceURI(prefix: string): string; + cloneNode(deep?: boolean): Node; + hasChildNodes(): boolean; + replaceChild(newChild: Node, oldChild: Node): Node; + insertBefore(newChild: Node, refChild?: Node): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} +declare var Node: { + prototype: Node; + new (): Node; + ENTITY_REFERENCE_NODE: number; + ATTRIBUTE_NODE: number; + DOCUMENT_FRAGMENT_NODE: number; + TEXT_NODE: number; + ELEMENT_NODE: number; + COMMENT_NODE: number; + DOCUMENT_POSITION_DISCONNECTED: number; + DOCUMENT_POSITION_CONTAINED_BY: number; + DOCUMENT_POSITION_CONTAINS: number; + DOCUMENT_TYPE_NODE: number; + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + DOCUMENT_NODE: number; + ENTITY_NODE: number; + PROCESSING_INSTRUCTION_NODE: number; + CDATA_SECTION_NODE: number; + NOTATION_NODE: number; + DOCUMENT_POSITION_FOLLOWING: number; + DOCUMENT_POSITION_PRECEDING: number; +} + +interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothRel: { + prototype: SVGPathSegCurvetoQuadraticSmoothRel; + new (): SVGPathSegCurvetoQuadraticSmoothRel; +} + +interface DOML2DeprecatedListSpaceReduction { + compact: boolean; +} + +interface MSScriptHost { +} +declare var MSScriptHost: { + prototype: MSScriptHost; + new (): MSScriptHost; +} + +interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + clipPathUnits: SVGAnimatedEnumeration; +} +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new (): SVGClipPathElement; +} + +interface MouseEvent extends UIEvent { + toElement: Element; + layerY: number; + fromElement: Element; + which: number; + pageX: number; + offsetY: number; + x: number; + y: number; + metaKey: boolean; + altKey: boolean; + ctrlKey: boolean; + offsetX: number; + screenX: number; + clientY: number; + shiftKey: boolean; + layerX: number; + screenY: number; + relatedTarget: EventTarget; + button: number; + pageY: number; + buttons: number; + clientX: number; + initMouseEvent(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): void; + getModifierState(keyArg: string): boolean; +} +declare var MouseEvent: { + prototype: MouseEvent; + new (): MouseEvent; +} + +interface RangeException { + code: number; + message: string; + toString(): string; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} +declare var RangeException: { + prototype: RangeException; + new (): RangeException; + INVALID_NODE_TYPE_ERR: number; + BAD_BOUNDARYPOINTS_ERR: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + y: SVGAnimatedLengthList; + rotate: SVGAnimatedNumberList; + dy: SVGAnimatedLengthList; + x: SVGAnimatedLengthList; + dx: SVGAnimatedLengthList; +} +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new (): SVGTextPositioningElement; +} + +interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + width: number; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + object: string; + form: HTMLFormElement; + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. + */ + contentDocument: Document; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + /** + * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. + */ + declare: boolean; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLAppletElement: { + prototype: HTMLAppletElement; + new (): HTMLAppletElement; +} + +interface TextMetrics { + width: number; +} +declare var TextMetrics: { + prototype: TextMetrics; + new (): TextMetrics; +} + +interface DocumentEvent { + createEvent(eventInterface: string): Event; +} + +interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * The starting number. + */ + start: number; +} +declare var HTMLOListElement: { + prototype: HTMLOListElement; + new (): HTMLOListElement; +} + +interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalRel: { + prototype: SVGPathSegLinetoVerticalRel; + new (): SVGPathSegLinetoVerticalRel; +} + +interface SVGAnimatedString { + animVal: string; + baseVal: string; +} +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new (): SVGAnimatedString; +} + +interface CDATASection extends Text { +} +declare var CDATASection: { + prototype: CDATASection; + new (): CDATASection; +} + +interface StyleMedia { + type: string; + matchMedium(mediaquery: string): boolean; +} +declare var StyleMedia: { + prototype: StyleMedia; + new (): StyleMedia; +} + +interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { + options: HTMLSelectElement; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the number of rows in the list box. + */ + size: number; + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the index of the selected option in a select object. + */ + selectedIndex: number; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Retrieves the type of select control based on the value of the MULTIPLE attribute. + */ + type: string; + /** + * Removes an element from the collection. + * @param index Number that specifies the zero-based index of the element to remove from the collection. + */ + remove(index?: number): void; + /** + * Adds an element to the areas, controlRange, or options collection. + * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. + * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. + */ + add(element: HTMLElement, before?: any): void; + /** + * Retrieves a select object or an object from an options collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Retrieves a select object or an object from an options collection. + * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. + */ + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLSelectElement: { + prototype: HTMLSelectElement; + new (): HTMLSelectElement; +} + +interface TextRange { + boundingLeft: number; + htmlText: string; + offsetLeft: number; + boundingWidth: number; + boundingHeight: number; + boundingTop: number; + text: string; + offsetTop: number; + moveToPoint(x: number, y: number): void; + queryCommandValue(cmdID: string): any; + getBookmark(): string; + move(unit: string, count?: number): number; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(fStart?: boolean): void; + findText(string: string, count?: number, flags?: number): boolean; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + getBoundingClientRect(): ClientRect; + moveToBookmark(bookmark: string): boolean; + isEqual(range: TextRange): boolean; + duplicate(): TextRange; + collapse(start?: boolean): void; + queryCommandText(cmdID: string): string; + select(): void; + pasteHTML(html: string): void; + inRange(range: TextRange): boolean; + moveEnd(unit: string, count?: number): number; + getClientRects(): ClientRectList; + moveStart(unit: string, count?: number): number; + parentElement(): Element; + queryCommandState(cmdID: string): boolean; + compareEndPoints(how: string, sourceRange: TextRange): number; + execCommandShowHelp(cmdID: string): boolean; + moveToElementText(element: Element): void; + expand(Unit: string): boolean; + queryCommandSupported(cmdID: string): boolean; + setEndPoint(how: string, SourceRange: TextRange): void; + queryCommandEnabled(cmdID: string): boolean; +} +declare var TextRange: { + prototype: TextRange; + new (): TextRange; +} + +interface SVGTests { + requiredFeatures: SVGStringList; + requiredExtensions: SVGStringList; + systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLBlockElement: { + prototype: HTMLBlockElement; + new (): HTMLBlockElement; +} + +interface CSSStyleSheet extends StyleSheet { + owningElement: Element; + imports: StyleSheetList; + isAlternate: boolean; + rules: MSCSSRuleList; + isPrefAlternate: boolean; + readOnly: boolean; + cssText: string; + ownerRule: CSSRule; + href: string; + cssRules: CSSRuleList; + id: string; + pages: StyleSheetPageList; + addImport(bstrURL: string, lIndex?: number): number; + addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; + insertRule(rule: string, index?: number): number; + removeRule(lIndex: number): void; + deleteRule(index?: number): void; + addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; + removeImport(lIndex: number): void; +} +declare var CSSStyleSheet: { + prototype: CSSStyleSheet; + new (): CSSStyleSheet; +} + +interface MSSelection { + type: string; + typeDetail: string; + createRange(): TextRange; + clear(): void; + createRangeCollection(): TextRangeCollection; + empty(): void; +} +declare var MSSelection: { + prototype: MSSelection; + new (): MSSelection; +} + +interface HTMLMetaElement extends HTMLElement { + /** + * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. + */ + httpEquiv: string; + /** + * Sets or retrieves the value specified in the content attribute of the meta object. + */ + name: string; + /** + * Gets or sets meta-information to associate with httpEquiv or name. + */ + content: string; + /** + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + */ + url: string; + /** + * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. + */ + scheme: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; +} +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new (): HTMLMetaElement; +} + +interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { + patternUnits: SVGAnimatedEnumeration; + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + patternContentUnits: SVGAnimatedEnumeration; + patternTransform: SVGAnimatedTransformList; + height: SVGAnimatedLength; +} +declare var SVGPatternElement: { + prototype: SVGPatternElement; + new (): SVGPatternElement; +} + +interface SVGAnimatedAngle { + animVal: SVGAngle; + baseVal: SVGAngle; +} +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new (): SVGAnimatedAngle; +} + +interface Selection { + isCollapsed: boolean; + anchorNode: Node; + focusNode: Node; + anchorOffset: number; + focusOffset: number; + rangeCount: number; + addRange(range: Range): void; + collapseToEnd(): void; + toString(): string; + selectAllChildren(parentNode: Node): void; + getRangeAt(index: number): Range; + collapse(parentNode: Node, offset: number): void; + removeAllRanges(): void; + collapseToStart(): void; + deleteFromDocument(): void; + removeRange(range: Range): void; +} +declare var Selection: { + prototype: Selection; + new (): Selection; +} + +interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { + type: string; +} +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new (): SVGScriptElement; +} + +interface HTMLDDElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDDElement: { + prototype: HTMLDDElement; + new (): HTMLDDElement; +} + +interface MSDataBindingRecordSetReadonlyExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface CSSStyleRule extends CSSRule { + selectorText: string; + style: MSStyleCSSProperties; + readOnly: boolean; +} +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new (): CSSStyleRule; +} + +interface NodeIterator { + whatToShow: number; + filter: NodeFilter; + root: Node; + expandEntityReferences: boolean; + nextNode(): Node; + detach(): void; + previousNode(): Node; +} +declare var NodeIterator: { + prototype: NodeIterator; + new (): NodeIterator; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { + viewTarget: SVGStringList; +} +declare var SVGViewElement: { + prototype: SVGViewElement; + new (): SVGViewElement; +} + +interface HTMLLinkElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; +} +declare var HTMLLinkElement: { + prototype: HTMLLinkElement; + new (): HTMLLinkElement; +} + +interface SVGLocatable { + farthestViewportElement: SVGElement; + nearestViewportElement: SVGElement; + getBBox(): SVGRect; + getTransformToElement(element: SVGElement): SVGMatrix; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; +} + +interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; +} +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new (): HTMLFontElement; +} + +interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { +} +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new (): SVGTitleElement; +} + +interface ControlRangeCollection { + length: number; + queryCommandValue(cmdID: string): any; + remove(index: number): void; + add(item: Element): void; + queryCommandIndeterm(cmdID: string): boolean; + scrollIntoView(varargStart?: any): void; + item(index: number): Element; + [index: number]: Element; + execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; + addElement(item: Element): void; + queryCommandState(cmdID: string): boolean; + queryCommandSupported(cmdID: string): boolean; + queryCommandEnabled(cmdID: string): boolean; + queryCommandText(cmdID: string): string; + select(): void; +} +declare var ControlRangeCollection: { + prototype: ControlRangeCollection; + new (): ControlRangeCollection; +} + +interface MSNamespaceInfo extends MSEventAttachmentTarget { + urn: string; + onreadystatechange: (ev: Event) => any; + name: string; + readyState: string; + doImport(implementationUrl: string): void; +} +declare var MSNamespaceInfo: { + prototype: MSNamespaceInfo; + new (): MSNamespaceInfo; +} + +interface WindowSessionStorage { + sessionStorage: Storage; +} + +interface SVGAnimatedTransformList { + animVal: SVGTransformList; + baseVal: SVGTransformList; +} +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new (): SVGAnimatedTransformList; +} + +interface HTMLTableCaptionElement extends HTMLElement { + /** + * Sets or retrieves the alignment of the caption or legend. + */ + align: string; + /** + * Sets or retrieves whether the caption appears at the top or bottom of the table. + */ + vAlign: string; +} +declare var HTMLTableCaptionElement: { + prototype: HTMLTableCaptionElement; + new (): HTMLTableCaptionElement; +} + +interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; + create(): HTMLOptionElement; +} +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new (): HTMLOptionElement; +} + +interface HTMLMapElement extends HTMLElement { + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves a collection of the area objects defined for the given map object. + */ + areas: HTMLAreasCollection; +} +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new (): HTMLMapElement; +} + +interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { + type: string; +} +declare var HTMLMenuElement: { + prototype: HTMLMenuElement; + new (): HTMLMenuElement; +} + +interface MouseWheelEvent extends MouseEvent { + wheelDelta: number; + initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; +} +declare var MouseWheelEvent: { + prototype: MouseWheelEvent; + new (): MouseWheelEvent; +} + +interface SVGFitToViewBox { + viewBox: SVGAnimatedRect; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface SVGPointList { + numberOfItems: number; + replaceItem(newItem: SVGPoint, index: number): SVGPoint; + getItem(index: number): SVGPoint; + clear(): void; + appendItem(newItem: SVGPoint): SVGPoint; + initialize(newItem: SVGPoint): SVGPoint; + removeItem(index: number): SVGPoint; + insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; +} +declare var SVGPointList: { + prototype: SVGPointList; + new (): SVGPointList; +} + +interface SVGAnimatedLengthList { + animVal: SVGLengthList; + baseVal: SVGLengthList; +} +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new (): SVGAnimatedLengthList; +} + +interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers { + ondragend: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + ondragover: (ev: DragEvent) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + screenX: number; + onmouseover: (ev: MouseEvent) => any; + ondragleave: (ev: DragEvent) => any; + history: History; + pageXOffset: number; + name: string; + onafterprint: (ev: Event) => any; + onpause: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + top: Window; + onmousedown: (ev: MouseEvent) => any; + onseeked: (ev: Event) => any; + opener: Window; + onclick: (ev: MouseEvent) => any; + innerHeight: number; + onwaiting: (ev: Event) => any; + ononline: (ev: Event) => any; + ondurationchange: (ev: Event) => any; + frames: Window; + onblur: (ev: FocusEvent) => any; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + outerWidth: number; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + innerWidth: number; + onoffline: (ev: Event) => any; + length: number; + screen: Screen; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onratechange: (ev: Event) => any; + onstorage: (ev: StorageEvent) => any; + onloadstart: (ev: Event) => any; + ondragenter: (ev: DragEvent) => any; + onsubmit: (ev: Event) => any; + self: Window; + document: Document; + onprogress: (ev: any) => any; + ondblclick: (ev: MouseEvent) => any; + pageYOffset: number; + oncontextmenu: (ev: MouseEvent) => any; + onchange: (ev: Event) => any; + onloadedmetadata: (ev: Event) => any; + onplay: (ev: Event) => any; + onerror: ErrorEventHandler; + onplaying: (ev: Event) => any; + parent: Window; + location: Location; + oncanplaythrough: (ev: Event) => any; + onabort: (ev: UIEvent) => any; + onreadystatechange: (ev: Event) => any; + outerHeight: number; + onkeypress: (ev: KeyboardEvent) => any; + frameElement: Element; + onloadeddata: (ev: Event) => any; + onsuspend: (ev: Event) => any; + window: Window; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + onselect: (ev: UIEvent) => any; + navigator: Navigator; + styleMedia: StyleMedia; + ondrop: (ev: DragEvent) => any; + onmouseout: (ev: MouseEvent) => any; + onended: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onunload: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + screenY: number; + onmousewheel: (ev: MouseWheelEvent) => any; + onload: (ev: Event) => any; + onvolumechange: (ev: Event) => any; + oninput: (ev: Event) => any; + performance: Performance; + alert(message?: any): void; + scroll(x?: number, y?: number): void; + focus(): void; + scrollTo(x?: number, y?: number): void; + print(): void; + prompt(message?: string, defaul?: string): string; + toString(): string; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + scrollBy(x?: number, y?: number): void; + confirm(message?: string): boolean; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; + showModalDialog(url?: string, argument?: any, options?: any): any; + blur(): void; + getSelection(): Selection; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +} +declare var Window: { + prototype: Window; + new (): Window; +} + +interface SVGAnimatedPreserveAspectRatio { + animVal: SVGPreserveAspectRatio; + baseVal: SVGPreserveAspectRatio; +} +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new (): SVGAnimatedPreserveAspectRatio; +} + +interface MSSiteModeEvent extends Event { + buttonID: number; + actionURL: string; +} +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new (): MSSiteModeEvent; +} + +interface DOML2DeprecatedTextFlowControl { + clear: string; +} + +interface StyleSheetPageList { + length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new (): StyleSheetPageList; +} + +interface MSCSSProperties extends CSSStyleDeclaration { + scrollbarShadowColor: string; + scrollbarHighlightColor: string; + layoutGridChar: string; + layoutGridType: string; + textAutospace: string; + textKashidaSpace: string; + writingMode: string; + scrollbarFaceColor: string; + backgroundPositionY: string; + lineBreak: string; + imeMode: string; + msBlockProgression: string; + layoutGridLine: string; + scrollbarBaseColor: string; + layoutGrid: string; + layoutFlow: string; + textKashida: string; + filter: string; + zoom: string; + scrollbarArrowColor: string; + behavior: string; + backgroundPositionX: string; + accelerator: string; + layoutGridMode: string; + textJustifyTrim: string; + scrollbar3dLightColor: string; + msInterpolationMode: string; + scrollbarTrackColor: string; + scrollbarDarkShadowColor: string; + styleFloat: string; + getAttribute(attributeName: string, flags?: number): any; + setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; + removeAttribute(attributeName: string, flags?: number): boolean; +} +declare var MSCSSProperties: { + prototype: MSCSSProperties; + new (): MSCSSProperties; +} + +interface HTMLCollection extends MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Retrieves an object from various collections. + */ + item(nameOrIndex?: any, optionalIndex?: any): Element; + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element; + [name: number]: Element; +} +declare var HTMLCollection: { + prototype: HTMLCollection; + new (): HTMLCollection; +} + +interface SVGExternalResourcesRequired { + externalResourcesRequired: SVGAnimatedBoolean; +} + +interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * The original height of the image resource before sizing. + */ + naturalHeight: number; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * The original width of the image resource before sizing. + */ + naturalWidth: number; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: number; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. + */ + longDesc: string; + /** + * Contains the hypertext reference (HREF) of the URL. + */ + href: string; + /** + * Sets or retrieves whether the image is a server-side image map. + */ + isMap: boolean; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + create(): HTMLImageElement; +} +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new (): HTMLImageElement; +} + +interface HTMLAreaElement extends HTMLElement { + /** + * Sets or retrieves the protocol portion of a URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Sets or retrieves the host name part of the location or URL. + */ + hostname: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Sets or retrieves the file name or path specified by the object. + */ + pathname: string; + /** + * Sets or retrieves the hostname and port number of the location or URL. + */ + host: string; + /** + * Sets or retrieves the subsection of the href property that follows the number sign (#). + */ + hash: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or gets whether clicks in this region cause action. + */ + noHref: boolean; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new (): HTMLAreaElement; +} + +interface EventTarget { + addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; + dispatchEvent(evt: Event): boolean; +} + +interface SVGAngle { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} +declare var SVGAngle: { + prototype: SVGAngle; + new (): SVGAngle; + SVG_ANGLETYPE_RAD: number; + SVG_ANGLETYPE_UNKNOWN: number; + SVG_ANGLETYPE_UNSPECIFIED: number; + SVG_ANGLETYPE_DEG: number; + SVG_ANGLETYPE_GRAD: number; +} + +interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the default or selected value of the control. + */ + value: string; + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets the classification and default behavior of the button. + */ + type: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; +} +declare var HTMLButtonElement: { + prototype: HTMLButtonElement; + new (): HTMLButtonElement; +} + +interface HTMLSourceElement extends HTMLElement { + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the intended media type of the media source. + */ + media: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; +} +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new (): HTMLSourceElement; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} +declare var CanvasGradient: { + prototype: CanvasGradient; + new (): CanvasGradient; +} + +interface KeyboardEvent extends UIEvent { + location: number; + keyCode: number; + shiftKey: boolean; + which: number; + locale: string; + key: string; + altKey: boolean; + metaKey: boolean; + char: string; + ctrlKey: boolean; + repeat: boolean; + charCode: number; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new (): KeyboardEvent; + DOM_KEY_LOCATION_RIGHT: number; + DOM_KEY_LOCATION_STANDARD: number; + DOM_KEY_LOCATION_LEFT: number; + DOM_KEY_LOCATION_NUMPAD: number; + DOM_KEY_LOCATION_JOYSTICK: number; + DOM_KEY_LOCATION_MOBILE: number; +} + +interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions { + /** + * Retrieves the collection of user agents and versions declared in the X-UA-Compatible + */ + compatible: MSCompatibleInfoCollection; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (ev: KeyboardEvent) => any; + + /** + * Gets the implementation object of the current document. + */ + implementation: DOMImplementation; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (ev: Event) => any; + + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollection; + + /** + * Fires when the user presses the F1 key while the browser is the active window. + * @param ev The event. + */ + onhelp: (ev: Event) => any; + + /** + * 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; + + /** + * Gets or sets the character set used to encode the object. + */ + charset: string; + + /** + * Fires for an element just prior to setting focus on that element. + * @param ev The focus event + */ + onfocusin: (ev: FocusEvent) => any; + + + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (ev: Event) => any; + + security: string; + + /** + * Contains the title of the document. + */ + title: string; + + /** + * Retrieves a collection of namespace objects. + */ + namespaces: MSNamespaceInfoCollection; + + /** + * Gets the default character set from the current regional language settings. + */ + defaultCharset: string; + + /** + * Retrieves a collection of all embed objects in the document. + */ + embeds: HTMLCollection; + + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + styleSheets: StyleSheetList; + + /** + * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. + */ + frames: Window; + + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (ev: Event) => any; + + + /** + * Returns a reference to the collection of elements contained by the object. + */ + all: HTMLCollection; + + /** + * Retrieves a collection, in source order, of all form objects in the document. + */ + forms: HTMLCollection; + + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (ev: FocusEvent) => any; + + + /** + * Sets or retrieves a value that indicates the reading order of the object. + */ + dir: string; + + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (ev: Event) => any; + + + /** + * Sets or gets a value that indicates whether the document can be edited. + */ + designMode: string; + + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (ev: Event) => any; + + + /** + * Fires when the activeElement is changed from the current object to another object in the parent document. + * @param ev The UI Event + */ + ondeactivate: (ev: UIEvent) => any; + + + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (ev: Event) => any; + + + /** + * Fires when the data set exposed by a data source object changes. + * @param ev The event. + */ + ondatasetchanged: (ev: MSEventObj) => any; + + + /** + * Fires when rows are about to be deleted from the recordset. + * @param ev The event + */ + onrowsdelete: (ev: MSEventObj) => any; + + Script: MSScriptHost; + + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (ev: Event) => any; + + + /** + * Gets the URL for the document, stripped of any character encoding. + */ + URLUnencoded: string; + + defaultView: Window; + + /** + * Fires when the user is about to make a control selection of the object. + * @param ev The event. + */ + oncontrolselect: (ev: MSEventObj) => any; + + + /** + * Fires on the target element when the user drags the object to a valid drop target. + * @param ev The drag event. + */ + ondragenter: (ev: DragEvent) => any; + + onsubmit: (ev: Event) => any; + + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + inputEncoding: string; + + /** + * Gets the object that has the focus when the parent document has focus. + */ + activeElement: Element; + + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (ev: Event) => any; + + + /** + * Retrieves a collection of all a objects that specify the href property and all area objects in the document. + */ + links: HTMLCollection; + + /** + * Retrieves an autogenerated, unique identifier for the object. + */ + uniqueID: string; + + /** + * Sets or gets the URL for the current document. + */ + URL: string; + + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (ev: UIEvent) => any; + + head: HTMLHeadElement; + cookie: string; + xmlEncoding: string; + oncanplaythrough: (ev: Event) => any; + + /** + * Retrieves the document compatibility mode of the document. + */ + documentMode: number; + + characterSet: string; + + /** + * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. + */ + anchors: HTMLCollection; + + onbeforeupdate: (ev: MSEventObj) => any; + + /** + * Fires to indicate that all data is available from the data source object. + * @param ev The event. + */ + ondatasetcomplete: (ev: MSEventObj) => any; + + plugins: HTMLCollection; + + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (ev: Event) => any; + + + /** + * Gets the root svg element in the document hierarchy. + */ + rootElement: SVGSVGElement; + + /** + * Retrieves a value that indicates the current state of the object. + */ + readyState: string; + + /** + * Gets the URL of the location that referred the user to the current page. + */ + referrer: string; + + /** + * Sets or gets the color of all active links in the document. + */ + alinkColor: string; + + /** + * Fires on a databound object when an error occurs while updating the associated data in the data source object. + * @param ev The event. + */ + onerrorupdate: (ev: MSEventObj) => any; + + + /** + * Gets a reference to the container object of the window. + */ + parentWindow: Window; + + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (ev: MouseEvent) => any; + + + /** + * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. + * @param ev The event. + */ + onmsthumbnailclick: (ev: MSSiteModeEvent) => any; + + + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (ev: MouseWheelEvent) => any; + + + /** + * Occurs when the volume is changed, or playback is muted or unmuted. + * @param ev The event. + */ + onvolumechange: (ev: Event) => any; + + + /** + * Fires when data changes in the data provider. + * @param ev The event. + */ + oncellchange: (ev: MSEventObj) => any; + + + /** + * Fires just before the data source control changes the current row in the object. + * @param ev The event. + */ + onrowexit: (ev: MSEventObj) => any; + + + /** + * Fires just after new rows are inserted in the current recordset. + * @param ev The event. + */ + onrowsinserted: (ev: MSEventObj) => any; + + + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string; + + msCapsLockWarningOff: boolean; + + /** + * Fires when a property changes on the object. + * @param ev The event. + */ + onpropertychange: (ev: MSEventObj) => any; + + + /** + * Fires on the source object when the user releases the mouse at the close of a drag operation. + * @param ev The event. + */ + ondragend: (ev: DragEvent) => any; + + + /** + * Gets an object representing the document type declaration associated with the current document. + */ + doctype: DocumentType; + + /** + * Fires on the target element continuously while the user drags the object over a valid drop target. + * @param ev The event. + */ + ondragover: (ev: DragEvent) => any; + + + /** + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + */ + bgColor: string; + + /** + * Fires on the source object when the user starts to drag a text selection or selected object. + * @param ev The event. + */ + ondragstart: (ev: DragEvent) => any; + + + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (ev: MouseEvent) => any; + + + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (ev: DragEvent) => any; + + + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (ev: MouseEvent) => any; + + + /** + * Sets or gets the color of the document links. + */ + linkColor: string; + + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (ev: Event) => any; + + + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (ev: MouseEvent) => any; + + + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (ev: MouseEvent) => any; + + + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (ev: Event) => any; + + + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (ev: Event) => any; + + /** + * false (false)[rolls + */ + + /** + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * @param ev The event. + */ + onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; + + + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollection; + + /** + * Specifies the beginning and end of the document body. + */ + body: HTMLElement; + + /** + * Sets or gets the security domain of the document. + */ + domain: string; + + xmlStandalone: boolean; + + /** + * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. + */ + selection: MSSelection; + + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (ev: Event) => any; + + + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (ev: MouseEvent) => any; + + + /** + * Gets a reference to the root node of the document. + */ + documentElement: HTMLElement; + + /** + * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. + * @param ev The event. + */ + onbeforeeditfocus: (ev: MSEventObj) => any; + + + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (ev: Event) => any; + + + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (ev: any) => any; + + + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (ev: MouseEvent) => any; + + + /** + * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * @param ev The mouse event. + */ + oncontextmenu: (ev: MouseEvent) => any; + + + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (ev: Event) => any; + + media: string; + + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (ev: Event) => any; + + + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (ev: Event) => any; + + onafterupdate: (ev: MSEventObj) => any; + + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (ev: Event) => any; + + + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollection; + + /** + * Contains information about the current URL. + */ + location: Location; + + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (ev: UIEvent) => any; + + + /** + * Fires for the current element with focus immediately after moving focus to another element. + * @param ev The event. + */ + onfocusout: (ev: FocusEvent) => any; + + + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (ev: Event) => any; + + + /** + * Fires when a local DOM Storage area is written to disk. + * @param ev The event. + */ + onstoragecommit: (ev: StorageEvent) => any; + + + /** + * Fires periodically as data arrives from data source objects that asynchronously transmit their data. + * @param ev The event. + */ + ondataavailable: (ev: MSEventObj) => any; + + + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (ev: Event) => any; + + + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + lastModified: string; + + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (ev: KeyboardEvent) => any; + + + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (ev: Event) => any; + + + /** + * Fires immediately before the activeElement is changed from the current object to another object in the parent document. + * @param ev The event. + */ + onbeforedeactivate: (ev: UIEvent) => any; + + + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (ev: UIEvent) => any; + + + onselectstart: (ev: Event) => any; + + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (ev: FocusEvent) => any; + + + /** + * Sets or gets the foreground (text) color of the document. + */ + fgColor: string; + + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (ev: Event) => any; + + + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (ev: UIEvent) => any; + + ondrop: (ev: DragEvent) => any; + + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (ev: Event) => any; + + + /** + * Gets a value that indicates whether standards-compliant mode is switched on for the object. + */ + compatMode: string; + + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (ev: UIEvent) => any; + + + /** + * Fires to indicate that the current row has changed in the data source and new data values are available on the object. + * @param ev The event. + */ + onrowenter: (ev: MSEventObj) => any; + + + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (ev: Event) => any; + + oninput: (ev: Event) => any; + + /** + * Returns the current value of the document, range, or current selection for the given command. + * @param commandId String that specifies a command identifier. + */ + queryCommandValue(commandId: string): string; + + adoptNode(source: Node): Node; + + /** + * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. + * @param commandId String that specifies a command identifier. + */ + queryCommandIndeterm(commandId: string): boolean; + + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + createProcessingInstruction(target: string, data: string): ProcessingInstruction; + + /** + * Executes a command on the current document, current selection, or the given range. + * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. + * @param showUI Display the user interface, defaults to false. + * @param value Value to assign. + */ + execCommand(commandId: string, showUI?: boolean, value?: any): boolean; + + /** + * Returns the element for the specified x coordinate and the specified y coordinate. + * @param x The x-offset + * @param y The y-offset + */ + elementFromPoint(x: number, y: number): Element; + createCDATASection(data: string): CDATASection; + + /** + * Retrieves the string associated with a command. + * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. + */ + queryCommandText(commandId: string): string; + + /** + * Writes one or more HTML expressions to a document in the specified window. + * @param content Specifies the text and HTML tags to write. + */ + write(...content: string[]): void; + + /** + * Allows updating the print settings for the page. + */ + updateSettings(): void; + + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "a"): HTMLAnchorElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "abbr"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "address"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "area"): HTMLAreaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "article"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "aside"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "audio"): HTMLAudioElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "b"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "base"): HTMLBaseElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "bdi"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "bdo"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "blockquote"): HTMLQuoteElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "body"): HTMLBodyElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "br"): HTMLBRElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "button"): HTMLButtonElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "canvas"): HTMLCanvasElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "caption"): HTMLTableCaptionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "cite"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "code"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "col"): HTMLTableColElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "colgroup"): HTMLTableColElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "datalist"): HTMLDataListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dd"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "del"): HTMLModElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dfn"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "div"): HTMLDivElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dl"): HTMLDListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "dt"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "em"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "embed"): HTMLEmbedElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "fieldset"): HTMLFieldSetElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "figcaption"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "figure"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "footer"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "form"): HTMLFormElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h1"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h2"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h3"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h4"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h5"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "h6"): HTMLHeadingElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "head"): HTMLHeadElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "header"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "hgroup"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "hr"): HTMLHRElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "html"): HTMLHtmlElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "i"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "iframe"): HTMLIFrameElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "img"): HTMLImageElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "input"): HTMLInputElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ins"): HTMLModElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "kbd"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "label"): HTMLLabelElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "legend"): HTMLLegendElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "li"): HTMLLIElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "link"): HTMLLinkElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "main"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "map"): HTMLMapElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "mark"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "menu"): HTMLMenuElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "meta"): HTMLMetaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "nav"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "noscript"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "object"): HTMLObjectElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ol"): HTMLOListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "optgroup"): HTMLOptGroupElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "option"): HTMLOptionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "p"): HTMLParagraphElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "param"): HTMLParamElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "pre"): HTMLPreElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "progress"): HTMLProgressElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "q"): HTMLQuoteElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "rp"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "rt"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ruby"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "s"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "samp"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "script"): HTMLScriptElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "section"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "select"): HTMLSelectElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "small"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "source"): HTMLSourceElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "span"): HTMLSpanElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "strong"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "style"): HTMLStyleElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "sub"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "summary"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "sup"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "table"): HTMLTableElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tbody"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "td"): HTMLTableDataCellElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "textarea"): HTMLTextAreaElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tfoot"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "th"): HTMLTableHeaderCellElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "thead"): HTMLTableSectionElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "title"): HTMLTitleElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "tr"): HTMLTableRowElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "track"): HTMLTrackElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "u"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "ul"): HTMLUListElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "var"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "video"): HTMLVideoElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: "wbr"): HTMLElement; + /** + * Creates an instance of the element for the specified tag. + * @param tagName The name of an element. + */ + createElement(tagName: string): HTMLElement; + + /** + * Removes mouse capture from the object in the current document. + */ + releaseCapture(): void; + + /** + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * @param content The text and HTML tags to write. + */ + writeln(...content: string[]): void; + createElementNS(namespaceURI: string, qualifiedName: string): Element; + + /** + * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. + * @param url Specifies a MIME type for the document. + * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. + * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. + * @param replace Specifies whether the existing entry for the document is replaced in the history list. + */ + open(url?: string, name?: string, features?: string, replace?: boolean): any; + + /** + * Returns a Boolean value that indicates whether the current command is supported on the current range. + * @param commandId Specifies a command identifier. + */ + queryCommandSupported(commandId: string): boolean; + + /** + * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. + * @param filter A custom NodeFilter function to use. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; + createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; + + /** + * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. + * @param commandId Specifies a command identifier. + */ + queryCommandEnabled(commandId: string): boolean; + + /** + * Causes the element to receive the focus and executes the code specified by the onfocus event. + */ + focus(): void; + + /** + * Closes an output stream and forces the sent data to display. + */ + close(): void; + + getElementsByClassName(classNames: string): NodeList; + importNode(importedNode: Node, deep: boolean): Node; + + /** + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + */ + createRange(): Range; + + /** + * Fires a specified event on the object. + * @param eventName Specifies the name of the event to fire. + * @param eventObj Object that specifies the event object from which to obtain event object properties. + */ + fireEvent(eventName: string, eventObj?: any): boolean; + + /** + * Creates a comment object with the specified data. + * @param data Sets the comment object's data. + */ + createComment(data: string): Comment; + + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "a"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "abbr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "address"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "area"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "article"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "aside"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "audio"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "b"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "base"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "bdi"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "bdo"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "blockquote"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "body"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "br"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "button"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "canvas"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "caption"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "cite"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "code"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "col"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "colgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "datalist"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dd"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "del"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dfn"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "div"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dl"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "dt"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "em"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "embed"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "fieldset"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "figcaption"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "figure"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "footer"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "form"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h1"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h2"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h3"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h4"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h5"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "h6"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "head"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "header"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "hgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "hr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "html"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "i"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "iframe"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "img"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "input"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ins"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "kbd"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "label"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "legend"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "li"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "link"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "main"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "map"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "mark"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "menu"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "meta"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "nav"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "noscript"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "object"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ol"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "optgroup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "option"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "p"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "param"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "pre"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "progress"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "q"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "rp"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "rt"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ruby"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "s"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "samp"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "script"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "section"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "select"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "small"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "source"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "span"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "strong"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "style"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "sub"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "summary"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "sup"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "table"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tbody"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "td"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "textarea"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tfoot"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "th"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "thead"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "title"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "tr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "track"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "u"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "ul"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "var"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "video"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: "wbr"): NodeListOf; + /** + * Retrieves a collection of objects based on the specified element name. + * @param name Specifies the name of an element. + */ + getElementsByTagName(name: string): NodeList; + + /** + * Creates a new document. + */ + createDocumentFragment(): DocumentFragment; + + /** + * Creates a style sheet for the document. + * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. + * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. + */ + createStyleSheet(href?: string, index?: number): CSSStyleSheet; + + /** + * Gets a collection of objects based on the value of the NAME or ID attribute. + * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. + */ + getElementsByName(elementName: string): NodeList; + + /** + * Returns a Boolean value that indicates the current state of the command. + * @param commandId String that specifies a command identifier. + */ + queryCommandState(commandId: string): boolean; + + /** + * Gets a value indicating whether the object currently has focus. + */ + hasFocus(): boolean; + + /** + * Displays help information for the given command identifier. + * @param commandId Displays help information for the given command identifier. + */ + execCommandShowHelp(commandId: string): boolean; + + /** + * Creates an attribute object with a specified name. + * @param name String that sets the attribute object's name. + */ + createAttribute(name: string): Attr; + + /** + * Creates a text string from the specified value. + * @param data String that specifies the nodeValue property of the text node. + */ + createTextNode(data: string): Text; + + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * @param root The root element or node to start traversing on. + * @param whatToShow The type of nodes or elements to appear in the node list + * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. + * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. + */ + createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; + + /** + * Generates an event object to pass event context information when you use the fireEvent method. + * @param eventObj An object that specifies an existing event object on which to base the new object. + */ + createEventObject(eventObj?: any): MSEventObj; + + /** + * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. + */ + getSelection(): Selection; + + /** + * Returns a reference to the first object with the specified value of the ID or NAME attribute. + * @param elementId String that specifies the ID value. Case-insensitive. + */ + getElementById(elementId: string): HTMLElement; +} + +declare var Document: { + prototype: Document; + new (): Document; +} + +interface MessageEvent extends Event { + source: Window; + origin: string; + data: any; + initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; +} +declare var MessageEvent: { + prototype: MessageEvent; + new (): MessageEvent; +} + +interface SVGElement extends Element { + onmouseover: (ev: MouseEvent) => any; + viewportElement: SVGElement; + onmousemove: (ev: MouseEvent) => any; + onmouseout: (ev: MouseEvent) => any; + ondblclick: (ev: MouseEvent) => any; + onfocusout: (ev: FocusEvent) => any; + onfocusin: (ev: FocusEvent) => any; + xmlbase: string; + onmousedown: (ev: MouseEvent) => any; + onload: (ev: Event) => any; + onmouseup: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + ownerSVGElement: SVGSVGElement; + id: string; +} +declare var SVGElement: { + prototype: SVGElement; + new (): SVGElement; +} + +interface HTMLScriptElement extends HTMLElement { + /** + * Sets or retrieves the status of the script. + */ + defer: boolean; + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + /** + * Retrieves the URL to an external file that contains the source code or data. + */ + src: string; + /** + * Sets or retrieves the object that is bound to the event script. + */ + htmlFor: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the MIME type for the associated scripting engine. + */ + type: string; + /** + * Sets or retrieves the event for which the script is written. + */ + event: string; +} +declare var HTMLScriptElement: { + prototype: HTMLScriptElement; + new (): HTMLScriptElement; +} + +interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Retrieves the position of the object in the rows collection for the table. + */ + rowIndex: number; + /** + * Retrieves a collection of all cells in the table row. + */ + cells: HTMLCollection; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Retrieves the position of the object in the collection. + */ + sectionRowIndex: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; + /** + * Removes the specified cell from the table row, as well as from the cells collection. + * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. + */ + deleteCell(index?: number): void; + /** + * Creates a new cell in the table row, and adds the cell to the cells collection. + * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. + */ + insertCell(index?: number): HTMLElement; +} +declare var HTMLTableRowElement: { + prototype: HTMLTableRowElement; + new (): HTMLTableRowElement; +} + +interface CanvasRenderingContext2D { + miterLimit: number; + font: string; + globalCompositeOperation: string; + msFillRule: string; + lineCap: string; + msImageSmoothingEnabled: boolean; + lineDashOffset: number; + shadowColor: string; + lineJoin: string; + shadowOffsetX: number; + lineWidth: number; + canvas: HTMLCanvasElement; + strokeStyle: any; + globalAlpha: number; + shadowOffsetY: number; + fillStyle: any; + shadowBlur: number; + textAlign: string; + textBaseline: string; + restore(): void; + setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + save(): void; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + measureText(text: string): TextMetrics; + isPointInPath(x: number, y: number, fillRule?: string): boolean; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; + rotate(angle: number): void; + fillText(text: string, x: number, y: number, maxWidth?: number): void; + translate(x: number, y: number): void; + scale(x: number, y: number): void; + createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; + lineTo(x: number, y: number): void; + getLineDash(): Array; + fill(fillRule?: string): void; + createImageData(imageDataOrSw: any, sh?: number): ImageData; + createPattern(image: HTMLElement, repetition: string): CanvasPattern; + closePath(): void; + rect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: string): void; + clearRect(x: number, y: number, w: number, h: number): void; + moveTo(x: number, y: number): void; + getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; + fillRect(x: number, y: number, w: number, h: number): void; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; + stroke(): void; + strokeRect(x: number, y: number, w: number, h: number): void; + setLineDash(segments: Array): void; + strokeText(text: string, x: number, y: number, maxWidth?: number): void; + beginPath(): void; + arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; + createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; +} +declare var CanvasRenderingContext2D: { + prototype: CanvasRenderingContext2D; + new (): CanvasRenderingContext2D; +} + +interface MSCSSRuleList { + length: number; + item(index?: number): CSSStyleRule; + [index: number]: CSSStyleRule; +} +declare var MSCSSRuleList: { + prototype: MSCSSRuleList; + new (): MSCSSRuleList; +} + +interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalAbs: { + prototype: SVGPathSegLinetoHorizontalAbs; + new (): SVGPathSegLinetoHorizontalAbs; +} + +interface SVGPathSegArcAbs extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcAbs: { + prototype: SVGPathSegArcAbs; + new (): SVGPathSegArcAbs; +} + +interface SVGTransformList { + numberOfItems: number; + getItem(index: number): SVGTransform; + consolidate(): SVGTransform; + clear(): void; + appendItem(newItem: SVGTransform): SVGTransform; + initialize(newItem: SVGTransform): SVGTransform; + removeItem(index: number): SVGTransform; + insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; + replaceItem(newItem: SVGTransform, index: number): SVGTransform; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; +} +declare var SVGTransformList: { + prototype: SVGTransformList; + new (): SVGTransformList; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; +} +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new (): HTMLHtmlElement; +} + +interface SVGPathSegClosePath extends SVGPathSeg { +} +declare var SVGPathSegClosePath: { + prototype: SVGPathSegClosePath; + new (): SVGPathSegClosePath; +} + +interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; +} +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new (): HTMLFrameElement; +} + +interface SVGAnimatedLength { + animVal: SVGLength; + baseVal: SVGLength; +} +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new (): SVGAnimatedLength; +} + +interface SVGAnimatedPoints { + points: SVGPointList; + animatedPoints: SVGPointList; +} + +interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new (): SVGDefsElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLQuoteElement: { + prototype: HTMLQuoteElement; + new (): HTMLQuoteElement; +} + +interface CSSMediaRule extends CSSRule { + media: MediaList; + cssRules: CSSRuleList; + insertRule(rule: string, index?: number): number; + deleteRule(index?: number): void; +} +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new (): CSSMediaRule; +} + +interface WindowModal { + dialogArguments: any; + returnValue: any; +} + +interface XMLHttpRequest extends EventTarget { + responseBody: any; + status: number; + readyState: number; + responseText: string; + responseXML: Document; + ontimeout: (ev: Event) => any; + statusText: string; + onreadystatechange: (ev: Event) => any; + timeout: number; + onload: (ev: Event) => any; + open(method: string, url: string, async?: boolean, user?: string, password?: string): void; + create(): XMLHttpRequest; + send(data?: any): void; + abort(): void; + getAllResponseHeaders(): string; + setRequestHeader(header: string, value: string): void; + getResponseHeader(header: string): string; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new (): XMLHttpRequest; + LOADING: number; + DONE: number; + UNSENT: number; + OPENED: number; + HEADERS_RECEIVED: number; +} + +interface HTMLTableHeaderCellElement extends HTMLTableCellElement { + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; +} +declare var HTMLTableHeaderCellElement: { + prototype: HTMLTableHeaderCellElement; + new (): HTMLTableHeaderCellElement; +} + +interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { +} +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new (): HTMLDListElement; +} + +interface MSDataBindingExtensions { + dataSrc: string; + dataFormatAs: string; + dataFld: string; +} + +interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { + x: number; +} +declare var SVGPathSegLinetoHorizontalRel: { + prototype: SVGPathSegLinetoHorizontalRel; + new (): SVGPathSegLinetoHorizontalRel; +} + +interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + ry: SVGAnimatedLength; + cx: SVGAnimatedLength; + rx: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new (): SVGEllipseElement; +} + +interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + target: SVGAnimatedString; +} +declare var SVGAElement: { + prototype: SVGAElement; + new (): SVGAElement; +} + +interface SVGStylable { + className: SVGAnimatedString; + style: CSSStyleDeclaration; +} + +interface SVGTransformable extends SVGLocatable { + transform: SVGAnimatedTransformList; +} + +interface HTMLFrameSetElement extends HTMLElement { + ononline: (ev: Event) => any; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + /** + * Sets or retrieves the frame widths of the object. + */ + cols: string; + /** + * Fires when the object loses the input focus. + */ + onblur: (ev: FocusEvent) => any; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Fires when the object receives focus. + */ + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + onerror: (ev: Event) => any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + onresize: (ev: UIEvent) => any; + name: string; + onafterprint: (ev: Event) => any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + border: string; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + onstorage: (ev: StorageEvent) => any; +} +declare var HTMLFrameSetElement: { + prototype: HTMLFrameSetElement; + new (): HTMLFrameSetElement; +} + +interface Screen { + width: number; + deviceXDPI: number; + fontSmoothingEnabled: boolean; + bufferDepth: number; + logicalXDPI: number; + systemXDPI: number; + availHeight: number; + height: number; + logicalYDPI: number; + systemYDPI: number; + updateInterval: number; + colorDepth: number; + availWidth: number; + deviceYDPI: number; + pixelDepth: number; +} +declare var Screen: { + prototype: Screen; + new (): Screen; +} + +interface Coordinates { + altitudeAccuracy: number; + longitude: number; + latitude: number; + speed: number; + heading: number; + altitude: number; + accuracy: number; +} +declare var Coordinates: { + prototype: Coordinates; + new (): Coordinates; +} + +interface NavigatorGeolocation { + geolocation: Geolocation; +} + +interface NavigatorContentUtils { +} + +interface EventListener { + (evt: Event): void; +} + +interface SVGLangSpace { + xmllang: string; + xmlspace: string; +} + +interface DataTransfer { + effectAllowed: string; + dropEffect: string; + clearData(format?: string): boolean; + setData(format: string, data: string): boolean; + getData(format: string): string; +} +declare var DataTransfer: { + prototype: DataTransfer; + new (): DataTransfer; +} + +interface FocusEvent extends UIEvent { + relatedTarget: EventTarget; + initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; +} +declare var FocusEvent: { + prototype: FocusEvent; + new (): FocusEvent; +} + +interface Range { + startOffset: number; + collapsed: boolean; + endOffset: number; + startContainer: Node; + endContainer: Node; + commonAncestorContainer: Node; + setStart(refNode: Node, offset: number): void; + setEndBefore(refNode: Node): void; + setStartBefore(refNode: Node): void; + selectNode(refNode: Node): void; + detach(): void; + getBoundingClientRect(): ClientRect; + toString(): string; + compareBoundaryPoints(how: number, sourceRange: Range): number; + insertNode(newNode: Node): void; + collapse(toStart: boolean): void; + selectNodeContents(refNode: Node): void; + cloneContents(): DocumentFragment; + setEnd(refNode: Node, offset: number): void; + cloneRange(): Range; + getClientRects(): ClientRectList; + surroundContents(newParent: Node): void; + deleteContents(): void; + setStartAfter(refNode: Node): void; + extractContents(): DocumentFragment; + setEndAfter(refNode: Node): void; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} +declare var Range: { + prototype: Range; + new (): Range; + END_TO_END: number; + START_TO_START: number; + START_TO_END: number; + END_TO_START: number; +} + +interface SVGPoint { + y: number; + x: number; + matrixTransform(matrix: SVGMatrix): SVGPoint; +} +declare var SVGPoint: { + prototype: SVGPoint; + new (): SVGPoint; +} + +interface MSPluginsCollection { + length: number; + refresh(reload?: boolean): void; +} +declare var MSPluginsCollection: { + prototype: MSPluginsCollection; + new (): MSPluginsCollection; +} + +interface SVGAnimatedNumberList { + animVal: SVGNumberList; + baseVal: SVGNumberList; +} +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new (): SVGAnimatedNumberList; +} + +interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { + width: SVGAnimatedLength; + x: SVGAnimatedLength; + contentStyleType: string; + onzoom: (ev: any) => any; + y: SVGAnimatedLength; + viewport: SVGRect; + onerror: (ev: Event) => any; + pixelUnitToMillimeterY: number; + onresize: (ev: UIEvent) => any; + screenPixelToMillimeterY: number; + height: SVGAnimatedLength; + onabort: (ev: UIEvent) => any; + contentScriptType: string; + pixelUnitToMillimeterX: number; + currentTranslate: SVGPoint; + onunload: (ev: Event) => any; + currentScale: number; + onscroll: (ev: UIEvent) => any; + screenPixelToMillimeterX: number; + setCurrentTime(seconds: number): void; + createSVGLength(): SVGLength; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; + unpauseAnimations(): void; + createSVGRect(): SVGRect; + checkIntersection(element: SVGElement, rect: SVGRect): boolean; + unsuspendRedrawAll(): void; + pauseAnimations(): void; + suspendRedraw(maxWaitMilliseconds: number): number; + deselectAll(): void; + createSVGAngle(): SVGAngle; + getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; + createSVGTransform(): SVGTransform; + unsuspendRedraw(suspendHandleID: number): void; + forceRedraw(): void; + getCurrentTime(): number; + checkEnclosure(element: SVGElement, rect: SVGRect): boolean; + createSVGMatrix(): SVGMatrix; + createSVGPoint(): SVGPoint; + createSVGNumber(): SVGNumber; + createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; + getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; + getElementById(elementId: string): Element; +} +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new (): SVGSVGElement; +} + +interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLabelElement: { + prototype: HTMLLabelElement; + new (): HTMLLabelElement; +} + +interface MSResourceMetadata { + protocol: string; + fileSize: string; + fileUpdatedDate: string; + nameProp: string; + fileCreatedDate: string; + fileModifiedDate: string; + mimeType: string; +} + +interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLLegendElement: { + prototype: HTMLLegendElement; + new (): HTMLLegendElement; +} + +interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLDirectoryElement: { + prototype: HTMLDirectoryElement; + new (): HTMLDirectoryElement; +} + +interface SVGAnimatedInteger { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new (): SVGAnimatedInteger; +} + +interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { +} +declare var SVGTextElement: { + prototype: SVGTextElement; + new (): SVGTextElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { +} +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new (): SVGTSpanElement; +} + +interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { + /** + * Sets or retrieves the value of a list item. + */ + value: number; +} +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new (): HTMLLIElement; +} + +interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { + y: number; +} +declare var SVGPathSegLinetoVerticalAbs: { + prototype: SVGPathSegLinetoVerticalAbs; + new (): SVGPathSegLinetoVerticalAbs; +} + +interface MSStorageExtensions { + remainingSpace: number; +} + +interface SVGStyleElement extends SVGElement, SVGLangSpace { + media: string; + type: string; + title: string; +} +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new (): SVGStyleElement; +} + +interface MSCurrentStyleCSSProperties extends MSCSSProperties { + blockDirection: string; + clipBottom: string; + clipLeft: string; + clipRight: string; + clipTop: string; + hasLayout: string; +} +declare var MSCurrentStyleCSSProperties: { + prototype: MSCurrentStyleCSSProperties; + new (): MSCurrentStyleCSSProperties; +} + +interface MSHTMLCollectionExtensions { + urns(urn: any): Object; + tags(tagName: any): Object; +} + +interface Storage extends MSStorageExtensions { + length: number; + getItem(key: string): any; + [key: string]: any; + setItem(key: string, data: string): void; + clear(): void; + removeItem(key: string): void; + key(index: number): string; + [index: number]: any; +} +declare var Storage: { + prototype: Storage; + new (): Storage; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. + */ + marginHeight: string; + /** + * Sets or retrieves the left and right margin widths before displaying the text in a frame. + */ + marginWidth: string; + /** + * Sets or retrieves the amount of additional space between the frames. + */ + frameSpacing: any; + /** + * Sets or retrieves whether to display a border for the frame. + */ + frameBorder: string; + /** + * Sets or retrieves whether the user can resize the frame. + */ + noResize: boolean; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Retrieves the object of the specified. + */ + contentWindow: Window; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the frame name. + */ + name: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Sets or retrieves the horizontal margin for the object. + */ + hspace: number; + /** + * Sets or retrieves a URI to a long description of the object. + */ + longDesc: string; + /** + * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. + */ + security: any; + /** + * Raised when the object has been completely received from the server. + */ + onload: (ev: Event) => any; +} +declare var HTMLIFrameElement: { + prototype: HTMLIFrameElement; + new (): HTMLIFrameElement; +} + +interface TextRangeCollection { + length: number; + item(index: number): TextRange; + [index: number]: TextRange; +} +declare var TextRangeCollection: { + prototype: TextRangeCollection; + new (): TextRangeCollection; +} + +interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + scroll: string; + ononline: (ev: Event) => any; + onblur: (ev: FocusEvent) => any; + noWrap: boolean; + onfocus: (ev: FocusEvent) => any; + onmessage: (ev: MessageEvent) => any; + text: any; + onerror: (ev: Event) => any; + bgProperties: string; + onresize: (ev: UIEvent) => any; + link: any; + aLink: any; + bottomMargin: any; + topMargin: any; + onafterprint: (ev: Event) => any; + vLink: any; + onbeforeprint: (ev: Event) => any; + onoffline: (ev: Event) => any; + onunload: (ev: Event) => any; + onhashchange: (ev: Event) => any; + onload: (ev: Event) => any; + rightMargin: any; + onbeforeunload: (ev: BeforeUnloadEvent) => any; + leftMargin: any; + onstorage: (ev: StorageEvent) => any; + createTextRange(): TextRange; +} +declare var HTMLBodyElement: { + prototype: HTMLBodyElement; + new (): HTMLBodyElement; +} + +interface DocumentType extends Node { + name: string; + notations: NamedNodeMap; + systemId: string; + internalSubset: string; + entities: NamedNodeMap; + publicId: string; +} +declare var DocumentType: { + prototype: DocumentType; + new (): DocumentType; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; + fx: SVGAnimatedLength; + fy: SVGAnimatedLength; +} +declare var SVGRadialGradientElement: { + prototype: SVGRadialGradientElement; + new (): SVGRadialGradientElement; +} + +interface MutationEvent extends Event { + newValue: string; + attrChange: number; + attrName: string; + prevValue: string; + relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} +declare var MutationEvent: { + prototype: MutationEvent; + new (): MutationEvent; + MODIFICATION: number; + REMOVAL: number; + ADDITION: number; +} + +interface DragEvent extends MouseEvent { + dataTransfer: DataTransfer; + initDragEvent(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, dataTransferArg: DataTransfer): void; +} +declare var DragEvent: { + prototype: DragEvent; + new (): DragEvent; +} + +interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: HTMLCollection; + /** + * Removes the specified row (tr) from the element and from the rows collection. + * @param index Number that specifies the zero-based position in the rows collection of the row to remove. + */ + deleteRow(index?: number): void; + /** + * Moves a table row to a new position. + * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. + * @param indexTo Number that specifies where the row is moved within the rows collection. + */ + moveRow(indexFrom?: number, indexTo?: number): Object; + /** + * Creates a new row (tr) in the table, and adds the row to the rows collection. + * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. + */ + insertRow(index?: number): HTMLElement; +} +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new (): HTMLTableSectionElement; +} + +interface DOML2DeprecatedListNumberingAndBulletStyle { + type: string; +} + +interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + status: boolean; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + indeterminate: boolean; + readOnly: boolean; + size: number; + loop: number; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. + */ + vrml: string; + /** + * Sets or retrieves a lower resolution image to display. + */ + lowsrc: string; + /** + * Sets or retrieves the vertical margin for the object. + */ + vspace: number; + /** + * Sets or retrieves a comma-separated list of content types. + */ + accept: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + defaultChecked: boolean; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Returns the value of the data at the cursor's current position. + */ + value: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + border: string; + dynsrc: string; + /** + * Sets or retrieves the state of the check box or radio button. + */ + checked: boolean; + /** + * Sets or retrieves the width of the border to draw around the object. + */ + hspace: number; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns the content type of the object. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Retrieves whether the object is fully loaded. + */ + complete: boolean; + start: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Makes the selection equal to the current object. + */ + select(): void; +} +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new (): HTMLInputElement; +} + +interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rel: string; + /** + * Contains the protocol of the URL. + */ + protocol: string; + /** + * Sets or retrieves the substring of the href property that follows the question mark. + */ + search: string; + /** + * Sets or retrieves the coordinates of the object. + */ + coords: string; + /** + * Contains the hostname of a URL. + */ + hostname: string; + /** + * Contains the pathname of the URL. + */ + pathname: string; + Methods: string; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + protocolLong: string; + /** + * Sets or retrieves a destination URL or an anchor point. + */ + href: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + /** + * Sets or retrieves the character set used to encode the object. + */ + charset: string; + /** + * Sets or retrieves the language code of the object. + */ + hreflang: string; + /** + * Sets or retrieves the port number associated with a URL. + */ + port: string; + /** + * Contains the hostname and port values of the URL. + */ + host: string; + /** + * Contains the anchor portion of the URL including the hash sign (#). + */ + hash: string; + nameProp: string; + urn: string; + /** + * Sets or retrieves the relationship between the object and the destination of the link. + */ + rev: string; + /** + * Sets or retrieves the shape of the object. + */ + shape: string; + type: string; + mimeType: string; + /** + * Returns a string representation of an object. + */ + toString(): string; +} +declare var HTMLAnchorElement: { + prototype: HTMLAnchorElement; + new (): HTMLAnchorElement; +} + +interface HTMLParamElement extends HTMLElement { + /** + * Sets or retrieves the value of an input parameter for an element. + */ + value: string; + /** + * Sets or retrieves the name of an input parameter for an element. + */ + name: string; + /** + * Sets or retrieves the content type of the resource designated by the value attribute. + */ + type: string; + /** + * Sets or retrieves the data type of the value attribute. + */ + valueType: string; +} +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new (): HTMLParamElement; +} + +interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGImageElement: { + prototype: SVGImageElement; + new (): SVGImageElement; +} + +interface SVGAnimatedNumber { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new (): SVGAnimatedNumber; +} + +interface PerformanceTiming { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + msFirstPaint: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + toJSON(): any; +} +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new (): PerformanceTiming; +} + +interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + /** + * Indicates a citation by rendering text in italic type. + */ + cite: string; +} +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new (): HTMLPreElement; +} + +interface EventException { + code: number; + message: string; + toString(): string; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} +declare var EventException: { + prototype: EventException; + new (): EventException; + DISPATCH_REQUEST_ERR: number; + UNSPECIFIED_EVENT_TYPE_ERR: number; +} + +interface MSNavigatorDoNotTrack { + msDoNotTrack: string; +} + +interface NavigatorOnLine { + onLine: boolean; +} + +interface WindowLocalStorage { + localStorage: Storage; +} + +interface SVGMetadataElement extends SVGElement { +} +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new (): SVGMetadataElement; +} + +interface SVGPathSegArcRel extends SVGPathSeg { + y: number; + sweepFlag: boolean; + r2: number; + x: number; + angle: number; + r1: number; + largeArcFlag: boolean; +} +declare var SVGPathSegArcRel: { + prototype: SVGPathSegArcRel; + new (): SVGPathSegArcRel; +} + +interface SVGPathSegMovetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegMovetoAbs: { + prototype: SVGPathSegMovetoAbs; + new (): SVGPathSegMovetoAbs; +} + +interface SVGStringList { + numberOfItems: number; + replaceItem(newItem: string, index: number): string; + getItem(index: number): string; + clear(): void; + appendItem(newItem: string): string; + initialize(newItem: string): string; + removeItem(index: number): string; + insertItemBefore(newItem: string, index: number): string; +} +declare var SVGStringList: { + prototype: SVGStringList; + new (): SVGStringList; +} + +interface XDomainRequest { + timeout: number; + onerror: (ev: Event) => any; + onload: (ev: Event) => any; + onprogress: (ev: any) => any; + ontimeout: (ev: Event) => any; + responseText: string; + contentType: string; + open(method: string, url: string): void; + create(): XDomainRequest; + abort(): void; + send(data?: any): void; +} +declare var XDomainRequest: { + prototype: XDomainRequest; + new (): XDomainRequest; +} + +interface DOML2DeprecatedBackgroundColorStyle { + bgColor: any; +} + +interface ElementTraversal { + childElementCount: number; + previousElementSibling: Element; + lastElementChild: Element; + nextElementSibling: Element; + firstElementChild: Element; +} + +interface SVGLength { + valueAsString: string; + valueInSpecifiedUnits: number; + value: number; + unitType: number; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + convertToSpecifiedUnits(unitType: number): void; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} +declare var SVGLength: { + prototype: SVGLength; + new (): SVGLength; + SVG_LENGTHTYPE_NUMBER: number; + SVG_LENGTHTYPE_CM: number; + SVG_LENGTHTYPE_PC: number; + SVG_LENGTHTYPE_PERCENTAGE: number; + SVG_LENGTHTYPE_MM: number; + SVG_LENGTHTYPE_PT: number; + SVG_LENGTHTYPE_IN: number; + SVG_LENGTHTYPE_EMS: number; + SVG_LENGTHTYPE_PX: number; + SVG_LENGTHTYPE_UNKNOWN: number; + SVG_LENGTHTYPE_EXS: number; +} + +interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new (): SVGPolygonElement; +} + +interface HTMLPhraseElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLPhraseElement: { + prototype: HTMLPhraseElement; + new (): HTMLPhraseElement; +} + +interface NavigatorStorageUtils { +} + +interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicRel: { + prototype: SVGPathSegCurvetoCubicRel; + new (): SVGPathSegCurvetoCubicRel; +} + +interface MSEventObj extends Event { + nextPage: string; + keyCode: number; + toElement: Element; + returnValue: any; + dataFld: string; + y: number; + dataTransfer: DataTransfer; + propertyName: string; + url: string; + offsetX: number; + recordset: Object; + screenX: number; + buttonID: number; + wheelDelta: number; + reason: number; + origin: string; + data: string; + srcFilter: Object; + boundElements: HTMLCollection; + cancelBubble: boolean; + altLeft: boolean; + behaviorCookie: number; + bookmarks: BookmarkCollection; + type: string; + repeat: boolean; + srcElement: Element; + source: Window; + fromElement: Element; + offsetY: number; + x: number; + behaviorPart: number; + qualifier: string; + altKey: boolean; + ctrlKey: boolean; + clientY: number; + shiftKey: boolean; + shiftLeft: boolean; + contentOverflow: boolean; + screenY: number; + ctrlLeft: boolean; + button: number; + srcUrn: string; + clientX: number; + actionURL: string; + getAttribute(strAttributeName: string, lFlags?: number): any; + setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; + removeAttribute(strAttributeName: string, lFlags?: number): boolean; +} +declare var MSEventObj: { + prototype: MSEventObj; + new (): MSEventObj; +} + +interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + textLength: SVGAnimatedLength; + lengthAdjust: SVGAnimatedEnumeration; + getCharNumAtPosition(point: SVGPoint): number; + getStartPositionOfChar(charnum: number): SVGPoint; + getExtentOfChar(charnum: number): SVGRect; + getComputedTextLength(): number; + getSubStringLength(charnum: number, nchars: number): number; + selectSubString(charnum: number, nchars: number): void; + getNumberOfChars(): number; + getRotationOfChar(charnum: number): number; + getEndPositionOfChar(charnum: number): SVGPoint; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new (): SVGTextContentElement; + LENGTHADJUST_SPACING: number; + LENGTHADJUST_SPACINGANDGLYPHS: number; + LENGTHADJUST_UNKNOWN: number; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface HTMLCanvasElement extends HTMLElement { + /** + * Gets or sets the width of a canvas element on a document. + */ + width: number; + /** + * Gets or sets the height of a canvas element on a document. + */ + height: number; + /** + * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. + * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. + */ + toDataURL(type?: string, ...args: any[]): string; + /** + * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. + * @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: { + prototype: HTMLCanvasElement; + new (): HTMLCanvasElement; +} + +interface Location { + hash: string; + protocol: string; + search: string; + href: string; + hostname: string; + port: string; + pathname: string; + host: string; + reload(flag?: boolean): void; + replace(url: string): void; + assign(url: string): void; + toString(): string; +} +declare var Location: { + prototype: Location; + new (): Location; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new (): HTMLTitleElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; +} +declare var HTMLStyleElement: { + prototype: HTMLStyleElement; + new (): HTMLStyleElement; +} + +interface PerformanceEntry { + name: string; + startTime: number; + duration: number; + entryType: string; +} +declare var PerformanceEntry: { + prototype: PerformanceEntry; + new (): PerformanceEntry; +} + +interface SVGTransform { + type: number; + angle: number; + matrix: SVGMatrix; + setTranslate(tx: number, ty: number): void; + setScale(sx: number, sy: number): void; + setMatrix(matrix: SVGMatrix): void; + setSkewY(angle: number): void; + setRotate(angle: number, cx: number, cy: number): void; + setSkewX(angle: number): void; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} +declare var SVGTransform: { + prototype: SVGTransform; + new (): SVGTransform; + SVG_TRANSFORM_SKEWX: number; + SVG_TRANSFORM_UNKNOWN: number; + SVG_TRANSFORM_SCALE: number; + SVG_TRANSFORM_TRANSLATE: number; + SVG_TRANSFORM_MATRIX: number; + SVG_TRANSFORM_ROTATE: number; + SVG_TRANSFORM_SKEWY: number; +} + +interface UIEvent extends Event { + detail: number; + view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} +declare var UIEvent: { + prototype: UIEvent; + new (): UIEvent; +} + +interface SVGURIReference { + href: SVGAnimatedString; +} + +interface SVGPathSeg { + pathSegType: number; + pathSegTypeAsLetter: string; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new (): SVGPathSeg; + PATHSEG_MOVETO_REL: number; + PATHSEG_LINETO_VERTICAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + PATHSEG_CURVETO_QUADRATIC_REL: number; + PATHSEG_CURVETO_CUBIC_ABS: number; + PATHSEG_LINETO_HORIZONTAL_ABS: number; + PATHSEG_CURVETO_QUADRATIC_ABS: number; + PATHSEG_LINETO_ABS: number; + PATHSEG_CLOSEPATH: number; + PATHSEG_LINETO_HORIZONTAL_REL: number; + PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + PATHSEG_LINETO_REL: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + PATHSEG_ARC_REL: number; + PATHSEG_CURVETO_CUBIC_REL: number; + PATHSEG_UNKNOWN: number; + PATHSEG_LINETO_VERTICAL_ABS: number; + PATHSEG_ARC_ABS: number; + PATHSEG_MOVETO_ABS: number; + PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; +} + +interface WheelEvent extends MouseEvent { + deltaZ: number; + deltaX: number; + deltaMode: number; + deltaY: number; + initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} +declare var WheelEvent: { + prototype: WheelEvent; + new (): WheelEvent; + DOM_DELTA_PIXEL: number; + DOM_DELTA_LINE: number; + DOM_DELTA_PAGE: number; +} + +interface MSEventAttachmentTarget { + attachEvent(event: string, listener: EventListener): boolean; + detachEvent(event: string, listener: EventListener): void; +} + +interface SVGNumber { + value: number; +} +declare var SVGNumber: { + prototype: SVGNumber; + new (): SVGNumber; +} + +interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + getPathSegAtLength(distance: number): number; + getPointAtLength(distance: number): SVGPoint; + createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; + createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; + createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; + createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; + createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; + createSVGPathSegClosePath(): SVGPathSegClosePath; + createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; + createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; + createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; + createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; + createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; + createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; + createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; + createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; + createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; + getTotalLength(): number; + createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; + createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; + createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; + createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; +} +declare var SVGPathElement: { + prototype: SVGPathElement; + new (): SVGPathElement; +} + +interface MSCompatibleInfo { + version: string; + userAgent: string; +} +declare var MSCompatibleInfo: { + prototype: MSCompatibleInfo; + new (): MSCompatibleInfo; +} + +interface Text extends CharacterData, MSNodeExtensions { + wholeText: string; + splitText(offset: number): Text; + replaceWholeText(content: string): Text; +} +declare var Text: { + prototype: Text; + new (): Text; +} + +interface SVGAnimatedRect { + animVal: SVGRect; + baseVal: SVGRect; +} +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new (): SVGAnimatedRect; +} + +interface CSSNamespaceRule extends CSSRule { + namespaceURI: string; + prefix: string; +} +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new (): CSSNamespaceRule; +} + +interface SVGPathSegList { + numberOfItems: number; + replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; + getItem(index: number): SVGPathSeg; + clear(): void; + appendItem(newItem: SVGPathSeg): SVGPathSeg; + initialize(newItem: SVGPathSeg): SVGPathSeg; + removeItem(index: number): SVGPathSeg; + insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; +} +declare var SVGPathSegList: { + prototype: SVGPathSegList; + new (): SVGPathSegList; +} + +interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { +} +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new (): HTMLUnknownElement; +} + +interface HTMLAudioElement extends HTMLMediaElement { +} +declare var HTMLAudioElement: { + prototype: HTMLAudioElement; + new (): HTMLAudioElement; +} + +interface MSImageResourceExtensions { + dynsrc: string; + vrml: string; + lowsrc: string; + start: string; + loop: number; +} + +interface PositionError { + code: number; + message: string; + toString(): string; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} +declare var PositionError: { + prototype: PositionError; + new (): PositionError; + POSITION_UNAVAILABLE: number; + PERMISSION_DENIED: number; + TIMEOUT: number; +} + +interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves a list of header cells that provide information for the object. + */ + headers: string; + /** + * Retrieves the position of the object in the cells collection of a row. + */ + cellIndex: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorLight: any; + /** + * Sets or retrieves the number columns in the table that the object should span. + */ + colSpan: number; + /** + * Sets or retrieves the border color of the object. + */ + borderColor: any; + /** + * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. + */ + axis: string; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; + /** + * Sets or retrieves abbreviated text for the object. + */ + abbr: string; + /** + * Sets or retrieves how many rows in a table the cell should span. + */ + rowSpan: number; + /** + * Sets or retrieves the group of cells in a table to which the object's information applies. + */ + scope: string; + /** + * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. + */ + borderColorDark: any; +} +declare var HTMLTableCellElement: { + prototype: HTMLTableCellElement; + new (): HTMLTableCellElement; +} + +interface SVGElementInstance extends EventTarget { + previousSibling: SVGElementInstance; + parentNode: SVGElementInstance; + lastChild: SVGElementInstance; + nextSibling: SVGElementInstance; + childNodes: SVGElementInstanceList; + correspondingUseElement: SVGUseElement; + correspondingElement: SVGElement; + firstChild: SVGElementInstance; +} +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new (): SVGElementInstance; +} + +interface MSNamespaceInfoCollection { + length: number; + add(namespace?: string, urn?: string, implementationUrl?: any): Object; + item(index: any): Object; + [index: string]: Object; +} +declare var MSNamespaceInfoCollection: { + prototype: MSNamespaceInfoCollection; + new (): MSNamespaceInfoCollection; +} + +interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + cx: SVGAnimatedLength; + r: SVGAnimatedLength; + cy: SVGAnimatedLength; +} +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new (): SVGCircleElement; +} + +interface StyleSheetList { + length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} +declare var StyleSheetList: { + prototype: StyleSheetList; + new (): StyleSheetList; +} + +interface CSSImportRule extends CSSRule { + styleSheet: CSSStyleSheet; + href: string; + media: MediaList; +} +declare var CSSImportRule: { + prototype: CSSImportRule; + new (): CSSImportRule; +} + +interface CustomEvent extends Event { + detail: any; + initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; +} +declare var CustomEvent: { + prototype: CustomEvent; + new (): CustomEvent; +} + +interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { + /** + * Sets or retrieves the current typeface family. + */ + face: string; + /** + * Sets or retrieves the font size of the object. + */ + size: number; +} +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new (): HTMLBaseFontElement; +} + +interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { + /** + * Retrieves or sets the text in the entry field of the textArea element. + */ + value: string; + /** + * Sets or retrieves the value indicating whether the control is selected. + */ + status: any; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Gets or sets the starting position or offset of a text selection. + */ + selectionStart: number; + /** + * Sets or retrieves the number of horizontal rows contained in the object. + */ + rows: number; + /** + * Sets or retrieves the width of the object. + */ + cols: number; + /** + * Sets or retrieves the value indicated whether the content of the object is read-only. + */ + readOnly: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + /** + * Gets or sets the end position or offset of a text selection. + */ + selectionEnd: number; + /** + * Retrieves the type of control. + */ + type: string; + /** + * Sets or retrieves the initial contents of the object. + */ + defaultValue: string; + /** + * Creates a TextRange object for the element. + */ + createTextRange(): TextRange; + /** + * Sets the start and end positions of a selection in a text field. + * @param start The offset into the text field for the start of the selection. + * @param end The offset into the text field for the end of the selection. + */ + setSelectionRange(start: number, end: number): void; + /** + * Highlights the input area of a form element. + */ + select(): void; +} +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new (): HTMLTextAreaElement; +} + +interface Geolocation { + clearWatch(watchId: number): void; + getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; + watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; +} +declare var Geolocation: { + prototype: Geolocation; + new (): Geolocation; +} + +interface DOML2DeprecatedMarginStyle { + vspace: number; + hspace: number; +} + +interface MSWindowModeless { + dialogTop: any; + dialogLeft: any; + dialogWidth: any; + dialogHeight: any; + menuArguments: any; +} + +interface DOML2DeprecatedAlignmentStyle { + align: string; +} + +interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { + width: string; + onbounce: (ev: Event) => any; + vspace: number; + trueSpeed: boolean; + scrollAmount: number; + scrollDelay: number; + behavior: string; + height: string; + loop: number; + direction: string; + hspace: number; + onstart: (ev: Event) => any; + onfinish: (ev: Event) => any; + stop(): void; + start(): void; +} +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new (): HTMLMarqueeElement; +} + +interface SVGRect { + y: number; + width: number; + x: number; + height: number; +} +declare var SVGRect: { + prototype: SVGRect; + new (): SVGRect; +} + +interface MSNodeExtensions { + swapNode(otherNode: Node): Node; + removeNode(deep?: boolean): Node; + replaceNode(replacement: Node): Node; +} + +interface History { + length: number; + back(distance?: any): void; + forward(distance?: any): void; + go(delta?: any): void; +} +declare var History: { + prototype: History; + new (): History; +} + +interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { + y: number; + y1: number; + x2: number; + x: number; + x1: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicAbs: { + prototype: SVGPathSegCurvetoCubicAbs; + new (): SVGPathSegCurvetoCubicAbs; +} + +interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { + y: number; + y1: number; + x: number; + x1: number; +} +declare var SVGPathSegCurvetoQuadraticAbs: { + prototype: SVGPathSegCurvetoQuadraticAbs; + new (): SVGPathSegCurvetoQuadraticAbs; +} + +interface TimeRanges { + length: number; + start(index: number): number; + end(index: number): number; +} +declare var TimeRanges: { + prototype: TimeRanges; + new (): TimeRanges; +} + +interface CSSRule { + cssText: string; + parentStyleSheet: CSSStyleSheet; + parentRule: CSSRule; + type: number; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} +declare var CSSRule: { + prototype: CSSRule; + new (): CSSRule; + IMPORT_RULE: number; + MEDIA_RULE: number; + STYLE_RULE: number; + NAMESPACE_RULE: number; + PAGE_RULE: number; + UNKNOWN_RULE: number; + FONT_FACE_RULE: number; + CHARSET_RULE: number; +} + +interface SVGPathSegLinetoAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoAbs: { + prototype: SVGPathSegLinetoAbs; + new (): SVGPathSegLinetoAbs; +} + +interface HTMLModElement extends HTMLElement { + /** + * Sets or retrieves the date and time of a modification to the object. + */ + dateTime: string; + /** + * Sets or retrieves reference information about the object. + */ + cite: string; +} +declare var HTMLModElement: { + prototype: HTMLModElement; + new (): HTMLModElement; +} + +interface SVGMatrix { + e: number; + c: number; + a: number; + b: number; + d: number; + f: number; + multiply(secondMatrix: SVGMatrix): SVGMatrix; + flipY(): SVGMatrix; + skewY(angle: number): SVGMatrix; + inverse(): SVGMatrix; + scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; + rotate(angle: number): SVGMatrix; + flipX(): SVGMatrix; + translate(x: number, y: number): SVGMatrix; + scale(scaleFactor: number): SVGMatrix; + rotateFromVector(x: number, y: number): SVGMatrix; + skewX(angle: number): SVGMatrix; +} +declare var SVGMatrix: { + prototype: SVGMatrix; + new (): SVGMatrix; +} + +interface MSPopupWindow { + document: Document; + isOpen: boolean; + show(x: number, y: number, w: number, h: number, element?: any): void; + hide(): void; +} +declare var MSPopupWindow: { + prototype: MSPopupWindow; + new (): MSPopupWindow; +} + +interface BeforeUnloadEvent extends Event { + returnValue: string; +} +declare var BeforeUnloadEvent: { + prototype: BeforeUnloadEvent; + new (): BeforeUnloadEvent; +} + +interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + animatedInstanceRoot: SVGElementInstance; + instanceRoot: SVGElementInstance; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGUseElement: { + prototype: SVGUseElement; + new (): SVGUseElement; +} + +interface Event { + timeStamp: number; + defaultPrevented: boolean; + isTrusted: boolean; + currentTarget: EventTarget; + cancelBubble: boolean; + target: EventTarget; + eventPhase: number; + cancelable: boolean; + type: string; + srcElement: Element; + bubbles: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + stopPropagation(): void; + stopImmediatePropagation(): void; + preventDefault(): void; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} +declare var Event: { + prototype: Event; + new (): Event; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; +} + +interface ImageData { + width: number; + data: Uint8Array; + height: number; +} +declare var ImageData: { + prototype: ImageData; + new (): ImageData; +} + +interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { + /** + * Sets or retrieves the width of the object. + */ + width: any; + /** + * Sets or retrieves the alignment of the object relative to the display or table. + */ + align: string; + /** + * Sets or retrieves the number of columns in the group. + */ + span: number; +} +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new (): HTMLTableColElement; +} + +interface SVGException { + code: number; + message: string; + toString(): string; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} +declare var SVGException: { + prototype: SVGException; + new (): SVGException; + SVG_MATRIX_NOT_INVERTABLE: number; + SVG_WRONG_TYPE_ERR: number; + SVG_INVALID_VALUE_ERR: number; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + y1: SVGAnimatedLength; + x2: SVGAnimatedLength; + x1: SVGAnimatedLength; + y2: SVGAnimatedLength; +} +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new (): SVGLinearGradientElement; +} + +interface HTMLTableAlignment { + /** + * Sets or retrieves a value that you can use to implement your own ch functionality for the object. + */ + ch: string; + /** + * Sets or retrieves how text and other content are vertically aligned within the object that contains them. + */ + vAlign: string; + /** + * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. + */ + chOff: string; +} + +interface SVGAnimatedEnumeration { + animVal: number; + baseVal: number; +} +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new (): SVGAnimatedEnumeration; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { +} +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new (): HTMLUListElement; +} + +interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + ry: SVGAnimatedLength; + rx: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGRectElement: { + prototype: SVGRectElement; + new (): SVGRectElement; +} + +interface ErrorEventHandler { + (event: Event, source: string, fileno: number, columnNumber: number): void; + (message: any, uri: string, lineNumber: number, columnNumber?: number): void; +} + +interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new (): HTMLDivElement; +} + +interface DOML2DeprecatedBorderStyle { + border: string; +} + +interface NamedNodeMap { + length: number; + removeNamedItemNS(namespaceURI: string, localName: string): Attr; + item(index: number): Attr; + [index: number]: Attr; + removeNamedItem(name: string): Attr; + getNamedItem(name: string): Attr; + setNamedItem(arg: Attr): Attr; + getNamedItemNS(namespaceURI: string, localName: string): Attr; + setNamedItemNS(arg: Attr): Attr; +} +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new (): NamedNodeMap; +} + +interface MediaList { + length: number; + mediaText: string; + deleteMedium(oldMedium: string): void; + appendMedium(newMedium: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} +declare var MediaList: { + prototype: MediaList; + new (): MediaList; +} + +interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegCurvetoQuadraticSmoothAbs: { + prototype: SVGPathSegCurvetoQuadraticSmoothAbs; + new (): SVGPathSegCurvetoQuadraticSmoothAbs; +} + +interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { + y: number; + x2: number; + x: number; + y2: number; +} +declare var SVGPathSegCurvetoCubicSmoothRel: { + prototype: SVGPathSegCurvetoCubicSmoothRel; + new (): SVGPathSegCurvetoCubicSmoothRel; +} + +interface SVGLengthList { + numberOfItems: number; + replaceItem(newItem: SVGLength, index: number): SVGLength; + getItem(index: number): SVGLength; + clear(): void; + appendItem(newItem: SVGLength): SVGLength; + initialize(newItem: SVGLength): SVGLength; + removeItem(index: number): SVGLength; + insertItemBefore(newItem: SVGLength, index: number): SVGLength; +} +declare var SVGLengthList: { + prototype: SVGLengthList; + new (): SVGLengthList; +} + +interface ProcessingInstruction extends Node { + target: string; + data: string; +} +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new (): ProcessingInstruction; +} + +interface MSWindowExtensions { + status: string; + onmouseleave: (ev: MouseEvent) => any; + screenLeft: number; + offscreenBuffering: any; + maxConnectionsPerServer: number; + onmouseenter: (ev: MouseEvent) => any; + clipboardData: DataTransfer; + defaultStatus: string; + clientInformation: Navigator; + closed: boolean; + onhelp: (ev: Event) => any; + external: External; + event: MSEventObj; + onfocusout: (ev: FocusEvent) => any; + screenTop: number; + onfocusin: (ev: FocusEvent) => any; + showModelessDialog(url?: string, argument?: any, options?: any): Window; + navigate(url: string): void; + resizeBy(x?: number, y?: number): void; + item(index: any): any; + resizeTo(x?: number, y?: number): void; + createPopup(arguments?: any): MSPopupWindow; + toStaticHTML(html: string): string; + execScript(code: string, language?: string): any; + msWriteProfilerMark(profilerMarkName: string): void; + moveTo(x?: number, y?: number): void; + moveBy(x?: number, y?: number): void; + showHelp(url: string, helpArg?: any, features?: string): void; +} + +interface MSBehaviorUrnsCollection { + length: number; + item(index: number): string; +} +declare var MSBehaviorUrnsCollection: { + prototype: MSBehaviorUrnsCollection; + new (): MSBehaviorUrnsCollection; +} + +interface CSSFontFaceRule extends CSSRule { + style: CSSStyleDeclaration; +} +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new (): CSSFontFaceRule; +} + +interface DOML2DeprecatedBackgroundStyle { + background: string; +} + +interface TextEvent extends UIEvent { + inputMethod: number; + data: string; + locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} +declare var TextEvent: { + prototype: TextEvent; + new (): TextEvent; + DOM_INPUT_METHOD_KEYBOARD: number; + DOM_INPUT_METHOD_DROP: number; + DOM_INPUT_METHOD_IME: number; + DOM_INPUT_METHOD_SCRIPT: number; + DOM_INPUT_METHOD_VOICE: number; + DOM_INPUT_METHOD_UNKNOWN: number; + DOM_INPUT_METHOD_PASTE: number; + DOM_INPUT_METHOD_HANDWRITING: number; + DOM_INPUT_METHOD_OPTION: number; + DOM_INPUT_METHOD_MULTIMODAL: number; +} + +interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { +} +declare var DocumentFragment: { + prototype: DocumentFragment; + new (): DocumentFragment; +} + +interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new (): SVGPolylineElement; +} + +interface SVGAnimatedPathData { + pathSegList: SVGPathSegList; +} + +interface Position { + timestamp: number; + coords: Coordinates; +} +declare var Position: { + prototype: Position; + new (): Position; +} + +interface BookmarkCollection { + length: number; + item(index: number): any; + [index: number]: any; +} +declare var BookmarkCollection: { + prototype: BookmarkCollection; + new (): BookmarkCollection; +} + +interface PerformanceMark extends PerformanceEntry { +} +declare var PerformanceMark: { + prototype: PerformanceMark; + new (): PerformanceMark; +} + +interface CSSPageRule extends CSSRule { + pseudoClass: string; + selectorText: string; + selector: string; + style: CSSStyleDeclaration; +} +declare var CSSPageRule: { + prototype: CSSPageRule; + new (): CSSPageRule; +} + +interface HTMLBRElement extends HTMLElement { + /** + * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. + */ + clear: string; +} +declare var HTMLBRElement: { + prototype: HTMLBRElement; + new (): HTMLBRElement; +} + +interface MSNavigatorExtensions { + userLanguage: string; + plugins: MSPluginsCollection; + cookieEnabled: boolean; + appCodeName: string; + cpuClass: string; + appMinorVersion: string; + connectionSpeed: number; + browserLanguage: string; + mimeTypes: MSMimeTypesCollection; + systemLanguage: string; + javaEnabled(): boolean; + taintEnabled(): boolean; +} + +interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { +} +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new (): HTMLSpanElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; +} +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new (): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; +} +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new (): HTMLHeadingElement; +} + +interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { + /** + * Sets or retrieves the number of objects in a collection. + */ + length: number; + /** + * Sets or retrieves the window or frame at which to target content. + */ + target: string; + /** + * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. + */ + acceptCharset: string; + /** + * Sets or retrieves the encoding type for the form. + */ + enctype: string; + /** + * Retrieves a collection, in source order, of all controls in a given form. + */ + elements: HTMLCollection; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves how to send the form data to the server. + */ + method: string; + /** + * Sets or retrieves the MIME encoding for the form. + */ + encoding: string; + /** + * Fires when the user resets a form. + */ + reset(): void; + /** + * Retrieves a form object or an object from an elements collection. + * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. + * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. + */ + item(name?: any, index?: any): any; + /** + * Fires when a FORM is about to be submitted. + */ + submit(): void; + /** + * Retrieves a form object or an object from an elements collection. + */ + namedItem(name: string): any; + [name: string]: any; +} +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new (): HTMLFormElement; +} + +interface SVGZoomAndPan { + zoomAndPan: number; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} +declare var SVGZoomAndPan: { + prototype: SVGZoomAndPan; + new (): SVGZoomAndPan; + SVG_ZOOMANDPAN_MAGNIFY: number; + SVG_ZOOMANDPAN_UNKNOWN: number; + SVG_ZOOMANDPAN_DISABLE: number; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Gets the earliest possible position, in seconds, that the playback can begin. + */ + initialTime: number; + /** + * Gets TimeRanges for the current media resource that has been played. + */ + played: TimeRanges; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + currentSrc: string; + readyState: any; + /** + * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. + */ + autobuffer: boolean; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + /** + * Gets information about whether the playback has ended or not. + */ + ended: boolean; + /** + * Gets a collection of buffered time ranges. + */ + buffered: TimeRanges; + /** + * Returns an object representing the current error state of the audio or video element. + */ + error: MediaError; + /** + * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. + */ + seekable: TimeRanges; + /** + * Gets or sets a value that indicates whether to start playing the media automatically. + */ + autoplay: boolean; + /** + * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). + */ + controls: boolean; + /** + * Gets or sets the volume level for audio portions of the media element. + */ + volume: number; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + /** + * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. + */ + playbackRate: number; + /** + * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. + */ + duration: number; + /** + * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. + */ + muted: boolean; + /** + * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. + */ + defaultPlaybackRate: number; + /** + * Gets a flag that specifies whether playback is paused. + */ + paused: boolean; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + seeking: boolean; + /** + * Gets or sets the current playback position, in seconds. + */ + currentTime: number; + /** + * Gets or sets the current playback position, in seconds. + */ + preload: string; + /** + * Gets the current network activity for the element. + */ + networkState: number; + /** + * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. + */ + pause(): void; + /** + * Loads and starts playback of a media resource. + */ + play(): void; + /** + * Fires immediately after the client loads the object. + */ + load(): void; + /** + * Returns a string that specifies whether the client can play a given media resource type. + */ + canPlayType(type: string): string; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new (): HTMLMediaElement; + HAVE_METADATA: number; + HAVE_CURRENT_DATA: number; + HAVE_NOTHING: number; + NETWORK_NO_SOURCE: number; + HAVE_ENOUGH_DATA: number; + NETWORK_EMPTY: number; + NETWORK_LOADING: number; + NETWORK_IDLE: number; + HAVE_FUTURE_DATA: number; +} + +interface ElementCSSInlineStyle { + runtimeStyle: MSStyleCSSProperties; + currentStyle: MSCurrentStyleCSSProperties; + doScroll(component?: any): void; + componentFromPoint(x: number, y: number): string; +} + +interface DOMParser { + parseFromString(source: string, mimeType: string): Document; +} +declare var DOMParser: { + prototype: DOMParser; + new (): DOMParser; +} + +interface MSMimeTypesCollection { + length: number; +} +declare var MSMimeTypesCollection: { + prototype: MSMimeTypesCollection; + new (): MSMimeTypesCollection; +} + +interface StyleSheet { + disabled: boolean; + ownerNode: Node; + parentStyleSheet: StyleSheet; + href: string; + media: MediaList; + type: string; + title: string; +} +declare var StyleSheet: { + prototype: StyleSheet; + new (): StyleSheet; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + startOffset: SVGAnimatedLength; + method: SVGAnimatedEnumeration; + spacing: SVGAnimatedEnumeration; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new (): SVGTextPathElement; + TEXTPATH_SPACINGTYPE_EXACT: number; + TEXTPATH_METHODTYPE_STRETCH: number; + TEXTPATH_SPACINGTYPE_AUTO: number; + TEXTPATH_SPACINGTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_UNKNOWN: number; + TEXTPATH_METHODTYPE_ALIGN: number; +} + +interface HTMLDTElement extends HTMLElement { + /** + * Sets or retrieves whether the browser automatically performs wordwrap. + */ + noWrap: boolean; +} +declare var HTMLDTElement: { + prototype: HTMLDTElement; + new (): HTMLDTElement; +} + +interface NodeList { + length: number; + item(index: number): Node; + [index: number]: Node; +} +declare var NodeList: { + prototype: NodeList; + new (): NodeList; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface XMLSerializer { + serializeToString(target: Node): string; +} +declare var XMLSerializer: { + prototype: XMLSerializer; + new (): XMLSerializer; +} + +interface PerformanceMeasure extends PerformanceEntry { +} +declare var PerformanceMeasure: { + prototype: PerformanceMeasure; + new (): PerformanceMeasure; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { + spreadMethod: SVGAnimatedEnumeration; + gradientTransform: SVGAnimatedTransformList; + gradientUnits: SVGAnimatedEnumeration; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new (): SVGGradientElement; + SVG_SPREADMETHOD_REFLECT: number; + SVG_SPREADMETHOD_PAD: number; + SVG_SPREADMETHOD_UNKNOWN: number; + SVG_SPREADMETHOD_REPEAT: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} +declare var NodeFilter: { + prototype: NodeFilter; + new (): NodeFilter; + SHOW_ENTITY_REFERENCE: number; + SHOW_NOTATION: number; + SHOW_ENTITY: number; + SHOW_DOCUMENT: number; + SHOW_PROCESSING_INSTRUCTION: number; + FILTER_REJECT: number; + SHOW_CDATA_SECTION: number; + FILTER_ACCEPT: number; + SHOW_ALL: number; + SHOW_DOCUMENT_TYPE: number; + SHOW_TEXT: number; + SHOW_ELEMENT: number; + SHOW_COMMENT: number; + FILTER_SKIP: number; + SHOW_ATTRIBUTE: number; + SHOW_DOCUMENT_FRAGMENT: number; +} + +interface SVGNumberList { + numberOfItems: number; + replaceItem(newItem: SVGNumber, index: number): SVGNumber; + getItem(index: number): SVGNumber; + clear(): void; + appendItem(newItem: SVGNumber): SVGNumber; + initialize(newItem: SVGNumber): SVGNumber; + removeItem(index: number): SVGNumber; + insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; +} +declare var SVGNumberList: { + prototype: SVGNumberList; + new (): SVGNumberList; +} + +interface MediaError { + code: number; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} +declare var MediaError: { + prototype: MediaError; + new (): MediaError; + MEDIA_ERR_ABORTED: number; + MEDIA_ERR_NETWORK: number; + MEDIA_ERR_SRC_NOT_SUPPORTED: number; + MEDIA_ERR_DECODE: number; +} + +interface HTMLFieldSetElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} +declare var HTMLFieldSetElement: { + prototype: HTMLFieldSetElement; + new (): HTMLFieldSetElement; +} + +interface HTMLBGSoundElement extends HTMLElement { + /** + * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. + */ + balance: any; + /** + * Sets or gets the volume setting for the sound. + */ + volume: any; + /** + * Sets or gets the URL of a sound to play. + */ + src: string; + /** + * Sets or retrieves the number of times a sound or video clip will loop when activated. + */ + loop: number; +} +declare var HTMLBGSoundElement: { + prototype: HTMLBGSoundElement; + new (): HTMLBGSoundElement; +} + +interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { + onmouseleave: (ev: MouseEvent) => any; + onbeforecut: (ev: DragEvent) => any; + onkeydown: (ev: KeyboardEvent) => any; + onmove: (ev: MSEventObj) => any; + onkeyup: (ev: KeyboardEvent) => any; + onreset: (ev: Event) => any; + onhelp: (ev: Event) => any; + ondragleave: (ev: DragEvent) => any; + className: string; + onfocusin: (ev: FocusEvent) => any; + onseeked: (ev: Event) => any; + recordNumber: any; + title: string; + parentTextEdit: Element; + outerHTML: string; + ondurationchange: (ev: Event) => any; + offsetHeight: number; + all: HTMLCollection; + onblur: (ev: FocusEvent) => any; + dir: string; + onemptied: (ev: Event) => any; + onseeking: (ev: Event) => any; + oncanplay: (ev: Event) => any; + ondeactivate: (ev: UIEvent) => any; + ondatasetchanged: (ev: MSEventObj) => any; + onrowsdelete: (ev: MSEventObj) => any; + sourceIndex: number; + onloadstart: (ev: Event) => any; + onlosecapture: (ev: MSEventObj) => any; + ondragenter: (ev: DragEvent) => any; + oncontrolselect: (ev: MSEventObj) => any; + onsubmit: (ev: Event) => any; + behaviorUrns: MSBehaviorUrnsCollection; + scopeName: string; + onchange: (ev: Event) => any; + id: string; + onlayoutcomplete: (ev: MSEventObj) => any; + uniqueID: string; + onbeforeactivate: (ev: UIEvent) => any; + oncanplaythrough: (ev: Event) => any; + onbeforeupdate: (ev: MSEventObj) => any; + onfilterchange: (ev: MSEventObj) => any; + offsetParent: Element; + ondatasetcomplete: (ev: MSEventObj) => any; + onsuspend: (ev: Event) => any; + readyState: any; + onmouseenter: (ev: MouseEvent) => any; + innerText: string; + onerrorupdate: (ev: MSEventObj) => any; + onmouseout: (ev: MouseEvent) => any; + parentElement: HTMLElement; + onmousewheel: (ev: MouseWheelEvent) => any; + onvolumechange: (ev: Event) => any; + oncellchange: (ev: MSEventObj) => any; + onrowexit: (ev: MSEventObj) => any; + onrowsinserted: (ev: MSEventObj) => any; + onpropertychange: (ev: MSEventObj) => any; + filters: Object; + children: HTMLCollection; + ondragend: (ev: DragEvent) => any; + onbeforepaste: (ev: DragEvent) => any; + ondragover: (ev: DragEvent) => any; + offsetTop: number; + onmouseup: (ev: MouseEvent) => any; + ondragstart: (ev: DragEvent) => any; + onbeforecopy: (ev: DragEvent) => any; + ondrag: (ev: DragEvent) => any; + innerHTML: string; + onmouseover: (ev: MouseEvent) => any; + lang: string; + uniqueNumber: number; + onpause: (ev: Event) => any; + tagUrn: string; + onmousedown: (ev: MouseEvent) => any; + onclick: (ev: MouseEvent) => any; + onwaiting: (ev: Event) => any; + onresizestart: (ev: MSEventObj) => any; + offsetLeft: number; + isTextEdit: boolean; + isDisabled: boolean; + onpaste: (ev: DragEvent) => any; + canHaveHTML: boolean; + onmoveend: (ev: MSEventObj) => any; + language: string; + onstalled: (ev: Event) => any; + onmousemove: (ev: MouseEvent) => any; + style: MSStyleCSSProperties; + isContentEditable: boolean; + onbeforeeditfocus: (ev: MSEventObj) => any; + onratechange: (ev: Event) => any; + contentEditable: string; + tabIndex: number; + document: Document; + onprogress: (ev: any) => any; + ondblclick: (ev: MouseEvent) => any; + oncontextmenu: (ev: MouseEvent) => any; + onloadedmetadata: (ev: Event) => any; + onafterupdate: (ev: MSEventObj) => any; + onerror: (ev: Event) => any; + onplay: (ev: Event) => any; + onresizeend: (ev: MSEventObj) => any; + onplaying: (ev: Event) => any; + isMultiLine: boolean; + onfocusout: (ev: FocusEvent) => any; + onabort: (ev: UIEvent) => any; + ondataavailable: (ev: MSEventObj) => any; + hideFocus: boolean; + onreadystatechange: (ev: Event) => any; + onkeypress: (ev: KeyboardEvent) => any; + onloadeddata: (ev: Event) => any; + onbeforedeactivate: (ev: UIEvent) => any; + outerText: string; + disabled: boolean; + onactivate: (ev: UIEvent) => any; + accessKey: string; + onmovestart: (ev: MSEventObj) => any; + onselectstart: (ev: Event) => any; + onfocus: (ev: FocusEvent) => any; + ontimeupdate: (ev: Event) => any; + onresize: (ev: UIEvent) => any; + oncut: (ev: DragEvent) => any; + onselect: (ev: UIEvent) => any; + ondrop: (ev: DragEvent) => any; + offsetWidth: number; + oncopy: (ev: DragEvent) => any; + onended: (ev: Event) => any; + onscroll: (ev: UIEvent) => any; + onrowenter: (ev: MSEventObj) => any; + onload: (ev: Event) => any; + canHaveChildren: boolean; + oninput: (ev: Event) => any; + dragDrop(): boolean; + scrollIntoView(top?: boolean): void; + addFilter(filter: Object): void; + setCapture(containerCapture?: boolean): void; + focus(): void; + getAdjacentText(where: string): string; + insertAdjacentText(where: string, text: string): void; + getElementsByClassName(classNames: string): NodeList; + setActive(): void; + removeFilter(filter: Object): void; + blur(): void; + clearAttributes(): void; + releaseCapture(): void; + createControlRange(): ControlRangeCollection; + removeBehavior(cookie: number): boolean; + contains(child: HTMLElement): boolean; + click(): void; + insertAdjacentElement(position: string, insertedElement: Element): Element; + mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; + replaceAdjacentText(where: string, newText: string): string; + applyElement(apply: Element, where?: string): Element; + addBehavior(bstrUrl: string, factory?: any): number; + insertAdjacentHTML(where: string, html: string): void; +} +declare var HTMLElement: { + prototype: HTMLElement; + new (): HTMLElement; +} + +interface Comment extends CharacterData { + text: string; +} +declare var Comment: { + prototype: Comment; + new (): Comment; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + redirectStart: number; + redirectEnd: number; + domainLookupEnd: number; + responseStart: number; + domainLookupStart: number; + fetchStart: number; + requestStart: number; + connectEnd: number; + connectStart: number; + initiatorType: string; + responseEnd: number; +} +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new (): PerformanceResourceTiming; +} + +interface CanvasPattern { +} +declare var CanvasPattern: { + prototype: CanvasPattern; + new (): CanvasPattern; +} + +interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { + /** + * Sets or retrieves the width of the object. + */ + width: number; + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + /** + * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. + */ + noShade: boolean; +} +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new (): HTMLHRElement; +} + +interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Sets or retrieves the Internet media type for the code associated with the object. + */ + codeType: string; + /** + * Retrieves the contained object. + */ + object: Object; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL of the file containing the compiled Java class. + */ + code: string; + /** + * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. + */ + archive: string; + /** + * Sets or retrieves a message to be displayed while an object is loading. + */ + standby: string; + /** + * Sets or retrieves a text alternative to the graphic. + */ + alt: string; + /** + * Sets or retrieves the class identifier for the object. + */ + classid: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. + */ + useMap: string; + /** + * Sets or retrieves the URL that references the data of the object. + */ + data: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Retrieves the document object of the page or frame. + */ + contentDocument: Document; + /** + * Gets or sets the optional alternative HTML script to execute if the object fails to load. + */ + altHtml: string; + /** + * Sets or retrieves the URL of the component. + */ + codeBase: string; + declare: boolean; + /** + * Sets or retrieves the MIME type of the object. + */ + type: string; + /** + * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. + */ + BaseHref: string; +} +declare var HTMLObjectElement: { + prototype: HTMLObjectElement; + new (): HTMLObjectElement; +} + +interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Retrieves the palette used for the embedded document. + */ + palette: string; + /** + * Sets or retrieves a URL to be loaded by the object. + */ + src: string; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + pluginspage: string; + /** + * Sets or retrieves the height of the object. + */ + height: string; + /** + * Sets or retrieves the height and width units of the embed object. + */ + units: string; +} +declare var HTMLEmbedElement: { + prototype: HTMLEmbedElement; + new (): HTMLEmbedElement; +} + +interface StorageEvent extends Event { + oldValue: any; + newValue: any; + url: string; + storageArea: Storage; + key: string; + initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; +} +declare var StorageEvent: { + prototype: StorageEvent; + new (): StorageEvent; +} + +interface CharacterData extends Node { + length: number; + data: string; + deleteData(offset: number, count: number): void; + replaceData(offset: number, count: number, arg: string): void; + appendData(arg: string): void; + insertData(offset: number, arg: string): void; + substringData(offset: number, count: number): string; +} +declare var CharacterData: { + prototype: CharacterData; + new (): CharacterData; +} + +interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + index: number; + /** + * Sets or retrieves the status of an option. + */ + defaultSelected: boolean; + /** + * Sets or retrieves the text string specified by the option tag. + */ + text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves a value that you can use to implement your own label functionality for the object. + */ + label: string; + /** + * Sets or retrieves whether the option in the list box is the default item. + */ + selected: boolean; +} +declare var HTMLOptGroupElement: { + prototype: HTMLOptGroupElement; + new (): HTMLOptGroupElement; +} + +interface HTMLIsIndexElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; + /** + * Sets or retrieves the URL to which the form content is sent for processing. + */ + action: string; + prompt: string; +} +declare var HTMLIsIndexElement: { + prototype: HTMLIsIndexElement; + new (): HTMLIsIndexElement; +} + +interface SVGPathSegLinetoRel extends SVGPathSeg { + y: number; + x: number; +} +declare var SVGPathSegLinetoRel: { + prototype: SVGPathSegLinetoRel; + new (): SVGPathSegLinetoRel; +} + +interface DOMException { + code: number; + message: string; + toString(): string; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} +declare var DOMException: { + prototype: DOMException; + new (): DOMException; + HIERARCHY_REQUEST_ERR: number; + NO_MODIFICATION_ALLOWED_ERR: number; + INVALID_MODIFICATION_ERR: number; + NAMESPACE_ERR: number; + INVALID_CHARACTER_ERR: number; + TYPE_MISMATCH_ERR: number; + ABORT_ERR: number; + INVALID_STATE_ERR: number; + SECURITY_ERR: number; + NETWORK_ERR: number; + WRONG_DOCUMENT_ERR: number; + QUOTA_EXCEEDED_ERR: number; + INDEX_SIZE_ERR: number; + DOMSTRING_SIZE_ERR: number; + SYNTAX_ERR: number; + SERIALIZE_ERR: number; + VALIDATION_ERR: number; + NOT_FOUND_ERR: number; + URL_MISMATCH_ERR: number; + PARSE_ERR: number; + NO_DATA_ALLOWED_ERR: number; + NOT_SUPPORTED_ERR: number; + INVALID_ACCESS_ERR: number; + INUSE_ATTRIBUTE_ERR: number; +} + +interface SVGAnimatedBoolean { + animVal: boolean; + baseVal: boolean; +} +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new (): SVGAnimatedBoolean; +} + +interface MSCompatibleInfoCollection { + length: number; + item(index: number): MSCompatibleInfo; +} +declare var MSCompatibleInfoCollection: { + prototype: MSCompatibleInfoCollection; + new (): MSCompatibleInfoCollection; +} + +interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { +} +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new (): SVGSwitchElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new (): SVGPreserveAspectRatio; + SVG_PRESERVEASPECTRATIO_NONE: number; + SVG_PRESERVEASPECTRATIO_XMINYMID: number; + SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + SVG_MEETORSLICE_UNKNOWN: number; + SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + SVG_PRESERVEASPECTRATIO_XMINYMIN: number; + SVG_MEETORSLICE_MEET: number; + SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + SVG_MEETORSLICE_SLICE: number; + SVG_PRESERVEASPECTRATIO_UNKNOWN: number; +} + +interface Attr extends Node { + expando: boolean; + specified: boolean; + ownerElement: Element; + value: string; + name: string; +} +declare var Attr: { + prototype: Attr; + new (): Attr; +} + +interface PerformanceNavigation { + redirectCount: number; + type: number; + toJSON(): any; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new (): PerformanceNavigation; + TYPE_RELOAD: number; + TYPE_RESERVED: number; + TYPE_BACK_FORWARD: number; + TYPE_NAVIGATE: number; +} + +interface SVGStopElement extends SVGElement, SVGStylable { + offset: SVGAnimatedNumber; +} +declare var SVGStopElement: { + prototype: SVGStopElement; + new (): SVGStopElement; +} + +interface PositionCallback { + (position: Position): void; +} + +interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { +} +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new (): SVGSymbolElement; +} + +interface SVGElementInstanceList { + length: number; + item(index: number): SVGElementInstance; +} +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new (): SVGElementInstanceList; +} + +interface CSSRuleList { + length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} +declare var CSSRuleList: { + prototype: CSSRuleList; + new (): CSSRuleList; +} + +interface MSDataBindingRecordSetExtensions { + recordset: Object; + namedRecordset(dataMember: string, hierarchy?: any): Object; +} + +interface LinkStyle { + styleSheet: StyleSheet; + sheet: StyleSheet; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the width of the video element. + */ + width: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoWidth: number; + /** + * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. + */ + videoHeight: number; + /** + * Gets or sets the height of the video element. + */ + height: number; + /** + * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. + */ + poster: string; +} +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new (): HTMLVideoElement; +} + +interface ClientRectList { + length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} +declare var ClientRectList: { + prototype: ClientRectList; + new (): ClientRectList; +} + +interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + maskUnits: SVGAnimatedEnumeration; + maskContentUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; +} +declare var SVGMaskElement: { + prototype: SVGMaskElement; + new (): SVGMaskElement; +} + +interface External { +} +declare var External: { + prototype: External; + new (): External; +} + +declare var Audio: { new (src?: string): HTMLAudioElement; }; +declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; +declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; + +declare var ondragend: (ev: DragEvent) => any; +declare var onkeydown: (ev: KeyboardEvent) => any; +declare var ondragover: (ev: DragEvent) => any; +declare var onkeyup: (ev: KeyboardEvent) => any; +declare var onreset: (ev: Event) => any; +declare var onmouseup: (ev: MouseEvent) => any; +declare var ondragstart: (ev: DragEvent) => any; +declare var ondrag: (ev: DragEvent) => any; +declare var screenX: number; +declare var onmouseover: (ev: MouseEvent) => any; +declare var ondragleave: (ev: DragEvent) => any; +declare var history: History; +declare var pageXOffset: number; +declare var name: string; +declare var onafterprint: (ev: Event) => any; +declare var onpause: (ev: Event) => any; +declare var onbeforeprint: (ev: Event) => any; +declare var top: Window; +declare var onmousedown: (ev: MouseEvent) => any; +declare var onseeked: (ev: Event) => any; +declare var opener: Window; +declare var onclick: (ev: MouseEvent) => any; +declare var innerHeight: number; +declare var onwaiting: (ev: Event) => any; +declare var ononline: (ev: Event) => any; +declare var ondurationchange: (ev: Event) => any; +declare var frames: Window; +declare var onblur: (ev: FocusEvent) => any; +declare var onemptied: (ev: Event) => any; +declare var onseeking: (ev: Event) => any; +declare var oncanplay: (ev: Event) => any; +declare var outerWidth: number; +declare var onstalled: (ev: Event) => any; +declare var onmousemove: (ev: MouseEvent) => any; +declare var innerWidth: number; +declare var onoffline: (ev: Event) => any; +declare var length: number; +declare var screen: Screen; +declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; +declare var onratechange: (ev: Event) => any; +declare var onstorage: (ev: StorageEvent) => any; +declare var onloadstart: (ev: Event) => any; +declare var ondragenter: (ev: DragEvent) => any; +declare var onsubmit: (ev: Event) => any; +declare var self: Window; +declare var document: Document; +declare var onprogress: (ev: any) => any; +declare var ondblclick: (ev: MouseEvent) => any; +declare var pageYOffset: number; +declare var oncontextmenu: (ev: MouseEvent) => any; +declare var onchange: (ev: Event) => any; +declare var onloadedmetadata: (ev: Event) => any; +declare var onplay: (ev: Event) => any; +declare var onerror: ErrorEventHandler; +declare var onplaying: (ev: Event) => any; +declare var parent: Window; +declare var location: Location; +declare var oncanplaythrough: (ev: Event) => any; +declare var onabort: (ev: UIEvent) => any; +declare var onreadystatechange: (ev: Event) => any; +declare var outerHeight: number; +declare var onkeypress: (ev: KeyboardEvent) => any; +declare var frameElement: Element; +declare var onloadeddata: (ev: Event) => any; +declare var onsuspend: (ev: Event) => any; +declare var window: Window; +declare var onfocus: (ev: FocusEvent) => any; +declare var onmessage: (ev: MessageEvent) => any; +declare var ontimeupdate: (ev: Event) => any; +declare var onresize: (ev: UIEvent) => any; +declare var onselect: (ev: UIEvent) => any; +declare var navigator: Navigator; +declare var styleMedia: StyleMedia; +declare var ondrop: (ev: DragEvent) => any; +declare var onmouseout: (ev: MouseEvent) => any; +declare var onended: (ev: Event) => any; +declare var onhashchange: (ev: Event) => any; +declare var onunload: (ev: Event) => any; +declare var onscroll: (ev: UIEvent) => any; +declare var screenY: number; +declare var onmousewheel: (ev: MouseWheelEvent) => any; +declare var onload: (ev: Event) => any; +declare var onvolumechange: (ev: Event) => any; +declare var oninput: (ev: Event) => any; +declare var performance: Performance; +declare function alert(message?: any): void; +declare function scroll(x?: number, y?: number): void; +declare function focus(): void; +declare function scrollTo(x?: number, y?: number): void; +declare function print(): void; +declare function prompt(message?: string, defaul?: string): string; +declare function toString(): string; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function scrollBy(x?: number, y?: number): void; +declare function confirm(message?: string): boolean; +declare function close(): void; +declare function postMessage(message: any, targetOrigin: string, ports?: any): void; +declare function showModalDialog(url?: string, argument?: any, options?: any): any; +declare function blur(): void; +declare function getSelection(): Selection; +declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; +declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; +declare function dispatchEvent(evt: Event): boolean; +declare function attachEvent(event: string, listener: EventListener): boolean; +declare function detachEvent(event: string, listener: EventListener): void; +declare var localStorage: Storage; +declare var status: string; +declare var onmouseleave: (ev: MouseEvent) => any; +declare var screenLeft: number; +declare var offscreenBuffering: any; +declare var maxConnectionsPerServer: number; +declare var onmouseenter: (ev: MouseEvent) => any; +declare var clipboardData: DataTransfer; +declare var defaultStatus: string; +declare var clientInformation: Navigator; +declare var closed: boolean; +declare var onhelp: (ev: Event) => any; +declare var external: External; +declare var event: MSEventObj; +declare var onfocusout: (ev: FocusEvent) => any; +declare var screenTop: number; +declare var onfocusin: (ev: FocusEvent) => any; +declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; +declare function navigate(url: string): void; +declare function resizeBy(x?: number, y?: number): void; +declare function item(index: any): any; +declare function resizeTo(x?: number, y?: number): void; +declare function createPopup(arguments?: any): MSPopupWindow; +declare function toStaticHTML(html: string): string; +declare function execScript(code: string, language?: string): any; +declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function moveTo(x?: number, y?: number): void; +declare function moveBy(x?: number, y?: number): void; +declare function showHelp(url: string, helpArg?: any, features?: string): void; +declare var sessionStorage: Storage; +declare function clearTimeout(handle: number): void; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearInterval(handle: number): void; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; + + +///////////////////////////// +/// IE10 DOM APIs +///////////////////////////// + + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface HTMLBodyElement { + onpopstate: (ev: PopStateEvent) => any; +} + +interface MSGestureEvent extends UIEvent { + offsetY: number; + translationY: number; + velocityExpansion: number; + velocityY: number; + velocityAngular: number; + translationX: number; + velocityX: number; + hwTimestamp: number; + offsetX: number; + screenX: number; + rotation: number; + expansion: number; + clientY: number; + screenY: number; + scale: number; + gestureObject: any; + clientX: number; + initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} +declare var MSGestureEvent: { + MSGESTURE_FLAG_BEGIN: number; + MSGESTURE_FLAG_END: number; + MSGESTURE_FLAG_CANCEL: number; + MSGESTURE_FLAG_INERTIA: number; + MSGESTURE_FLAG_NONE: number; +} + +interface HTMLAnchorElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; +} + +interface HTMLInputElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a FileList object on a file type input object. + */ + files: FileList; + /** + * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. + */ + max: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. + */ + step: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Returns the input field value as a number. + */ + valueAsNumber: number; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Specifies the ID of a pre-defined datalist of options for an input element. + */ + list: HTMLElement; + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. + */ + min: string; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Gets or sets a string containing a regular expression that the user's input must match. + */ + pattern: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. + */ + multiple: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. + * @param n Value to decrement the value by. + */ + stepDown(n?: number): void; + /** + * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. + * @param n Value to increment the value by. + */ + stepUp(n?: number): void; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +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; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + filterResX: SVGAnimatedInteger; + filterUnits: SVGAnimatedEnumeration; + primitiveUnits: SVGAnimatedEnumeration; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + filterResY: SVGAnimatedInteger; + setFilterRes(filterResX: number, filterResY: number): void; +} + +interface TrackEvent extends Event { + track: any; +} + +interface SVGFEMergeNodeElement extends SVGElement { + in1: SVGAnimatedString; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} +declare var MSGesture: { + prototype: MSGesture; + new (): MSGesture; +} + +interface TextTrackCue extends EventTarget { + onenter: (ev: Event) => any; + track: TextTrack; + endTime: number; + text: string; + pauseOnExit: boolean; + id: string; + startTime: number; + onexit: (ev: Event) => any; + getCueAsHTML(): DocumentFragment; +} +declare var TextTrackCue: { + prototype: TextTrackCue; + new (): TextTrackCue; +} + +interface MSStreamReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(stream: MSStream, size?: number): void; + readAsBlob(stream: MSStream, size?: number): void; + readAsDataURL(stream: MSStream, size?: number): void; + readAsText(stream: MSStream, encoding?: string, size?: number): void; +} +declare var MSStreamReader: { + prototype: MSStreamReader; + new (): MSStreamReader; +} + +interface DOMTokenList { + length: number; + contains(token: string): boolean; + remove(token: string): void; + toggle(token: string): boolean; + add(token: string): void; + item(index: number): string; + [index: number]: string; + toString(): string; +} + +interface EventException { + name: string; +} + +interface Performance { + now(): number; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + mode: SVGAnimatedEnumeration; + in1: SVGAnimatedString; + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} +declare var SVGFEBlendElement: { + SVG_FEBLEND_MODE_DARKEN: number; + SVG_FEBLEND_MODE_UNKNOWN: number; + SVG_FEBLEND_MODE_MULTIPLY: number; + SVG_FEBLEND_MODE_NORMAL: number; + SVG_FEBLEND_MODE_SCREEN: number; + SVG_FEBLEND_MODE_LIGHTEN: number; +} + +interface WindowTimers extends WindowTimersExtension { +} + +interface CSSStyleDeclaration { + animationFillMode: string; + floodColor: string; + animationIterationCount: string; + textShadow: string; + backfaceVisibility: string; + msAnimationIterationCount: string; + animationDelay: string; + animationTimingFunction: string; + columnWidth: any; + msScrollSnapX: string; + columnRuleColor: any; + columnRuleWidth: any; + transitionDelay: string; + transition: string; + msFlowFrom: string; + msScrollSnapType: string; + msContentZoomSnapType: string; + msGridColumns: string; + msAnimationName: string; + msGridRowAlign: string; + msContentZoomChaining: string; + msGridColumn: any; + msHyphenateLimitZone: any; + msScrollRails: string; + msAnimationDelay: string; + enableBackground: string; + msWrapThrough: string; + columnRuleStyle: string; + msAnimation: string; + msFlexFlow: string; + msScrollSnapY: string; + msHyphenateLimitLines: any; + msTouchAction: string; + msScrollLimit: string; + animation: string; + transform: string; + filter: string; + colorInterpolationFilters: string; + transitionTimingFunction: string; + msBackfaceVisibility: string; + animationPlayState: string; + transformOrigin: string; + msScrollLimitYMin: any; + msFontFeatureSettings: string; + msContentZoomLimitMin: any; + columnGap: any; + transitionProperty: string; + msAnimationDuration: string; + msAnimationFillMode: string; + msFlexDirection: string; + msTransitionDuration: string; + fontFeatureSettings: string; + breakBefore: string; + msFlexWrap: string; + perspective: string; + msFlowInto: string; + msTransformStyle: string; + msScrollTranslation: string; + msTransitionProperty: string; + msUserSelect: string; + msOverflowStyle: string; + msScrollSnapPointsY: string; + animationDirection: string; + animationDuration: string; + msFlex: string; + msTransitionTimingFunction: string; + animationName: string; + columnRule: string; + msGridColumnSpan: any; + msFlexNegative: string; + columnFill: string; + msGridRow: any; + msFlexOrder: string; + msFlexItemAlign: string; + msFlexPositive: string; + msContentZoomLimitMax: any; + msScrollLimitYMax: any; + msGridColumnAlign: string; + perspectiveOrigin: string; + lightingColor: string; + columns: string; + msScrollChaining: string; + msHyphenateLimitChars: string; + msTouchSelect: string; + floodOpacity: string; + msAnimationDirection: string; + msAnimationPlayState: string; + columnSpan: string; + msContentZooming: string; + msPerspective: string; + msFlexPack: string; + msScrollSnapPointsX: string; + msContentZoomSnapPoints: string; + msGridRowSpan: any; + msContentZoomSnap: string; + msScrollLimitXMin: any; + breakInside: string; + msHighContrastAdjust: string; + msFlexLinePack: string; + msGridRows: string; + transitionDuration: string; + msHyphens: string; + breakAfter: string; + msTransition: string; + msPerspectiveOrigin: string; + msContentZoomLimit: string; + msScrollLimitXMax: any; + msFlexAlign: string; + msWrapMargin: any; + columnCount: any; + msAnimationTimingFunction: string; + msTransitionDelay: string; + transformStyle: string; + msWrapFlow: string; + msFlexPreferredSize: string; +} + +interface MessageChannel { + port2: MessagePort; + port1: MessagePort; +} +declare var MessageChannel: { + prototype: MessageChannel; + new (): MessageChannel; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { +} + +interface Navigator extends MSFileSaver { + msMaxTouchPoints: number; + msPointerEnabled: boolean; + msManipulationViewsEnabled: boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; +} + +interface TransitionEvent extends Event { + propertyName: string; + elapsedTime: number; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +interface MediaQueryList { + matches: boolean; + media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +interface DOMError { + name: string; + toString(): string; +} + +interface CloseEvent extends Event { + wasClean: boolean; + reason: string; + code: number; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +interface WebSocket extends EventTarget { + protocol: string; + readyState: number; + bufferedAmount: number; + onopen: (ev: Event) => any; + extensions: string; + onmessage: (ev: any) => any; + onclose: (ev: CloseEvent) => any; + onerror: (ev: ErrorEvent) => any; + binaryType: string; + url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} +declare var WebSocket: { + prototype: WebSocket; + new (url: string): WebSocket; + new (url: string, prototcol: string): WebSocket; + new (url: string, prototcol: string[]): WebSocket; + OPEN: number; + CLOSING: number; + CONNECTING: number; + CLOSED: number; +} + +interface SVGFEPointLightElement extends SVGElement { + y: SVGAnimatedNumber; + x: SVGAnimatedNumber; + z: SVGAnimatedNumber; +} + +interface ProgressEvent extends Event { + loaded: number; + lengthComputable: boolean; + total: number; + initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; +} + +interface IDBObjectStore { + indexNames: DOMStringList; + name: string; + transaction: IDBTransaction; + keyPath: string; + count(key?: any): IDBRequest; + add(value: any, key?: any): IDBRequest; + clear(): IDBRequest; + createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; + put(value: any, key?: any): IDBRequest; + openCursor(range?: any, direction?: string): IDBRequest; + deleteIndex(indexName: string): void; + index(name: string): IDBIndex; + get(key: any): IDBRequest; + delete(key: any): IDBRequest; +} + +interface HTMLCanvasElement { + /** + * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. + */ + msToBlob(): Blob; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + stdDeviationX: SVGAnimatedNumber; + in1: SVGAnimatedString; + stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; +} + +interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { + y: SVGAnimatedLength; + width: SVGAnimatedLength; + x: SVGAnimatedLength; + height: SVGAnimatedLength; + result: SVGAnimatedString; +} + +interface Element { + msRegionOverflow: string; + onmspointerdown: (ev: any) => any; + onmsgotpointercapture: (ev: any) => any; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + onmslostpointercapture: (ev: any) => any; + onmspointerover: (ev: any) => any; + msContentZoomFactor: number; + onmspointerup: (ev: any) => any; + msGetRegionContent(): MSRangeCollection; + msReleasePointerCapture(pointerId: number): void; + msSetPointerCapture(pointerId: number): void; +} + +interface IDBVersionChangeEvent extends Event { + newVersion: number; + oldVersion: number; +} + +interface IDBIndex { + unique: boolean; + name: string; + keyPath: string; + objectStore: IDBObjectStore; + count(key?: any): IDBRequest; + getKey(key: any): IDBRequest; + openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; + get(key: any): IDBRequest; + openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; +} + +interface WheelEvent { + getCurrentPoint(element: Element): void; +} + +interface FileList { + length: number; + item(index: number): File; + [index: number]: File; +} + +interface IDBCursor { + source: any; + direction: string; + key: any; + primaryKey: any; + advance(count: number): void; + delete(): IDBRequest; + continue(key?: any): void; + update(value: any): IDBRequest; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + specularConstant: SVGAnimatedNumber; +} + +interface File extends Blob { + lastModifiedDate: any; + name: string; +} + +interface URL { + revokeObjectURL(url: string): void; + createObjectURL(object: any, options?: ObjectURLOptions): string; +} +declare var URL: URL; + +interface RangeException { + name: string; +} + +interface IDBCursorWithValue extends IDBCursor { + value: any; +} + +interface HTMLTextAreaElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Sets or retrieves the maximum number of characters that the user can enter in a text control. + */ + maxLength: number; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. + */ + placeholder: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface XMLHttpRequestEventTarget extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: any) => any; + ontimeout: (ev: any) => any; + onabort: (ev: any) => any; + onloadstart: (ev: any) => any; + onloadend: (ev: ProgressEvent) => any; +} + +interface IDBEnvironment { + msIndexedDB: IDBFactory; + indexedDB: IDBFactory; +} + +interface AudioTrackList extends EventTarget { + length: number; + onchange: (ev: any) => any; + onaddtrack: (ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack; + item(index: number): AudioTrack; + [index: number]: AudioTrack; +} + +interface MSBaseReader extends EventTarget { + onprogress: (ev: ProgressEvent) => any; + readyState: number; + onabort: (ev: any) => any; + onloadend: (ev: ProgressEvent) => any; + onerror: (ev: ErrorEvent) => any; + onload: (ev: any) => any; + onloadstart: (ev: any) => any; + result: any; + abort(): void; + LOADING: number; + EMPTY: number; + DONE: number; +} + +interface History { + state: any; + replaceState(statedata: any, title: string, url?: string): void; + pushState(statedata: any, title: string, url?: string): void; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + radiusX: SVGAnimatedNumber; + radiusY: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} +declare var SVGFEMorphologyElement: { + SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + SVG_MORPHOLOGY_OPERATOR_ERODE: number; + SVG_MORPHOLOGY_OPERATOR_DILATE: number; +} + +interface HTMLSelectElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * When present, marks an element that can't be submitted without a value. + */ + required: boolean; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface CSSRule { + KEYFRAMES_RULE: number; + KEYFRAME_RULE: number; + VIEWPORT_RULE: number; +} +//declare var CSSRule: { +// KEYFRAMES_RULE: number; +// KEYFRAME_RULE: number; +// VIEWPORT_RULE: number; +//} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { +} + +interface WindowTimersExtension { + msSetImmediate(expression: any, ...args: any[]): number; + clearImmediate(handle: number): void; + msClearImmediate(handle: number): void; + setImmediate(expression: any, ...args: any[]): number; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in2: SVGAnimatedString; + xChannelSelector: SVGAnimatedEnumeration; + yChannelSelector: SVGAnimatedEnumeration; + scale: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} +declare var SVGFEDisplacementMapElement: { + SVG_CHANNEL_B: number; + SVG_CHANNEL_R: number; + SVG_CHANNEL_G: number; + SVG_CHANNEL_UNKNOWN: number; + SVG_CHANNEL_A: number; +} + +interface AnimationEvent extends Event { + animationName: string; + elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + tableValues: SVGAnimatedNumberList; + slope: SVGAnimatedNumber; + type: SVGAnimatedEnumeration; + exponent: SVGAnimatedNumber; + amplitude: SVGAnimatedNumber; + intercept: SVGAnimatedNumber; + offset: SVGAnimatedNumber; + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} +declare var SVGComponentTransferFunctionElement: { + SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; +} + +interface MSRangeCollection { + length: number; + item(index: number): Range; + [index: number]: Range; +} + +interface SVGFEDistantLightElement extends SVGElement { + azimuth: SVGAnimatedNumber; + elevation: SVGAnimatedNumber; +} + +interface SVGException { + name: string; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { +} + +interface IDBKeyRange { + upper: any; + upperOpen: boolean; + lower: any; + lowerOpen: boolean; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + lowerBound(bound: any, open?: boolean): IDBKeyRange; + upperBound(bound: any, open?: boolean): IDBKeyRange; +} + +interface WindowConsole { + console: Console; +} + +interface IDBTransaction extends EventTarget { + oncomplete: (ev: Event) => any; + db: IDBDatabase; + mode: string; + error: DOMError; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: any) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; +} + +interface AudioTrack { + kind: string; + language: string; + id: string; + label: string; + enabled: boolean; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + orderY: SVGAnimatedInteger; + kernelUnitLengthY: SVGAnimatedNumber; + orderX: SVGAnimatedInteger; + preserveAlpha: SVGAnimatedBoolean; + kernelMatrix: SVGAnimatedNumberList; + edgeMode: SVGAnimatedEnumeration; + kernelUnitLengthX: SVGAnimatedNumber; + bias: SVGAnimatedNumber; + targetX: SVGAnimatedInteger; + targetY: SVGAnimatedInteger; + divisor: SVGAnimatedNumber; + in1: SVGAnimatedString; + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} +declare var SVGFEConvolveMatrixElement: { + SVG_EDGEMODE_WRAP: number; + SVG_EDGEMODE_DUPLICATE: number; + SVG_EDGEMODE_UNKNOWN: number; + SVG_EDGEMODE_NONE: number; +} + +interface TextTrackCueList { + length: number; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; + getCueById(id: string): TextTrackCue; +} + +interface CSSKeyframesRule extends CSSRule { + name: string; + cssRules: CSSRuleList; + findRule(rule: string): CSSKeyframeRule; + deleteRule(rule: string): void; + appendRule(rule: string): void; +} + +interface Window extends WindowBase64, IDBEnvironment, WindowConsole { + onmspointerdown: (ev: any) => any; + animationStartTime: number; + onmsgesturedoubletap: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + msAnimationStartTime: number; + applicationCache: ApplicationCache; + onmsinertiastart: (ev: any) => any; + onmspointerover: (ev: any) => any; + onpopstate: (ev: PopStateEvent) => any; + onmspointerup: (ev: any) => any; + msCancelRequestAnimationFrame(handle: number): void; + matchMedia(mediaQuery: string): MediaQueryList; + cancelAnimationFrame(handle: number): void; + msIsStaticHTML(html: string): boolean; + msMatchMedia(mediaQuery: string): MediaQueryList; + requestAnimationFrame(callback: FrameRequestCallback): number; + msRequestAnimationFrame(callback: FrameRequestCallback): number; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + baseFrequencyX: SVGAnimatedNumber; + numOctaves: SVGAnimatedInteger; + type: SVGAnimatedEnumeration; + baseFrequencyY: SVGAnimatedNumber; + stitchTiles: SVGAnimatedEnumeration; + seed: SVGAnimatedNumber; + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} +declare var SVGFETurbulenceElement: { + SVG_STITCHTYPE_UNKNOWN: number; + SVG_STITCHTYPE_NOSTITCH: number; + SVG_TURBULENCE_TYPE_UNKNOWN: number; + SVG_TURBULENCE_TYPE_TURBULENCE: number; + SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + SVG_STITCHTYPE_STITCH: number; +} + +interface TextTrackList { + length: number; + item(index: number): TextTrack; + [index: number]: TextTrack; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; + type: SVGAnimatedEnumeration; + values: SVGAnimatedNumberList; + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} +declare var SVGFEColorMatrixElement: { + SVG_FECOLORMATRIX_TYPE_SATURATE: number; + SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + SVG_FECOLORMATRIX_TYPE_MATRIX: number; + SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; +} + +interface Console { + info(message?: any, ...optionalParams: any[]): void; + profile(reportName?: string): void; + assert(test?: boolean, message?: string, ...optionalParams: any[]): void; + msIsIndependentlyComposed(element: Element): boolean; + clear(): void; + dir(value?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; + error(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + profileEnd(): void; +} + +interface SVGFESpotLightElement extends SVGElement { + pointsAtY: SVGAnimatedNumber; + y: SVGAnimatedNumber; + limitingConeAngle: SVGAnimatedNumber; + specularExponent: SVGAnimatedNumber; + x: SVGAnimatedNumber; + pointsAtZ: SVGAnimatedNumber; + z: SVGAnimatedNumber; + pointsAtX: SVGAnimatedNumber; +} + +interface HTMLImageElement { + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; +} + +interface WindowBase64 { + btoa(rawString: string): string; + atob(encodedString: string): string; +} + +interface IDBDatabase extends EventTarget { + version: string; + name: string; + objectStoreNames: DOMStringList; + onerror: (ev: ErrorEvent) => any; + onabort: (ev: any) => any; + createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; + close(): void; + transaction(storeNames: any, mode?: string): IDBTransaction; + deleteObjectStore(name: string): void; +} + +interface DOMStringList { + length: number; + contains(str: string): boolean; + item(index: number): string; + [index: number]: string; +} + +interface HTMLButtonElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Overrides the target attribute on a form element. + */ + formTarget: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Overrides the action attribute (where the data on a form is sent) on the parent form element. + */ + formAction: string; + /** + * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. + */ + autofocus: boolean; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. + */ + formNoValidate: string; + /** + * Used to override the encoding (formEnctype attribute) specified on the form element. + */ + formEnctype: string; + /** + * Overrides the submit method attribute previously specified on a form element. + */ + formMethod: string; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface IDBOpenDBRequest extends IDBRequest { + onupgradeneeded: (ev: IDBVersionChangeEvent) => any; + onblocked: (ev: Event) => any; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. + */ + value: number; + /** + * Defines the maximum, or "done" value for a progress element. + */ + max: number; + /** + * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). + */ + position: number; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + form: HTMLFormElement; +} + +interface MSLaunchUriCallback { + (): void; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + dy: SVGAnimatedNumber; + in1: SVGAnimatedString; + dx: SVGAnimatedNumber; +} + +interface HTMLFormElement { + /** + * Specifies whether autocomplete is applied to an editable text field. + */ + autocomplete: string; + /** + * Designates a form that is not validated when submitted. + */ + noValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; +} + +interface MSUnsafeFunctionCallback { + (): any; +} + +interface Document { + onmspointerdown: (ev: any) => any; + msHidden: boolean; + msVisibilityState: string; + onmsgesturedoubletap: (ev: any) => any; + visibilityState: string; + onmsmanipulationstatechanged: (ev: any) => any; + onmspointerhover: (ev: any) => any; + onmscontentzoom: (ev: any) => any; + onmspointermove: (ev: any) => any; + onmsgesturehold: (ev: any) => any; + onmsgesturechange: (ev: any) => any; + onmsgesturestart: (ev: any) => any; + onmspointercancel: (ev: any) => any; + onmsgestureend: (ev: any) => any; + onmsgesturetap: (ev: any) => any; + onmspointerout: (ev: any) => any; + onmsinertiastart: (ev: any) => any; + msCSSOMElementFloatMetrics: boolean; + onmspointerover: (ev: any) => any; + hidden: boolean; + onmspointerup: (ev: any) => any; + msElementsFromPoint(x: number, y: number): NodeList; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; + clear(): void; +} + +interface MessageEvent extends Event { + ports: any; +} + +interface HTMLScriptElement { + async: boolean; +} + +interface HTMLMediaElement { + /** + * Specifies the purpose of the audio or video media, such as background audio or alerts. + */ + msAudioCategory: string; + /** + * Specifies whether or not to enable low-latency playback on the media element. + */ + msRealTime: boolean; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + textTracks: TextTrackList; + /** + * Gets or sets whether the DLNA PlayTo device is available. + */ + msPlayToDisabled: boolean; + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + audioTracks: AudioTrackList; + /** + * Gets the source associated with the media element for use by the PlayToManager. + */ + msPlayToSource: any; + /** + * Specifies the output device id that the audio will be sent to. + */ + msAudioDeviceType: string; + /** + * Clears all effects from the media pipeline. + */ + msClearEffects(): void; + /** + * Specifies the media protection manager for a given media pipeline. + */ + msSetMediaProtectionManager(mediaProtectionManager?: any): void; + /** + * Inserts the specified audio effect into media pipeline. + */ + msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; +} + +interface TextTrack extends EventTarget { + language: string; + mode: any; + readyState: number; + activeCues: TextTrackCueList; + cues: TextTrackCueList; + oncuechange: (ev: Event) => any; + kind: string; + onload: (ev: any) => any; + onerror: (ev: ErrorEvent) => any; + label: string; + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} +declare var TextTrack: { + ERROR: number; + SHOWING: number; + LOADING: number; + LOADED: number; + NONE: number; + HIDDEN: number; + DISABLED: number; +} + +interface MediaQueryListListener { + (mql: MediaQueryList): void; +} + +interface IDBRequest extends EventTarget { + source: any; + onsuccess: (ev: Event) => any; + error: DOMError; + transaction: IDBTransaction; + onerror: (ev: ErrorEvent) => any; + readyState: string; + result: any; +} + +interface MessagePort extends EventTarget { + onmessage: (ev: any) => any; + close(): void; + postMessage(message?: any, ports?: any): void; + start(): void; +} + +interface FileReader extends MSBaseReader { + error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; +} +declare var FileReader: { + prototype: FileReader; + new (): FileReader; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface Blob { + type: string; + size: number; + msDetachStream(): any; + slice(start?: number, end?: number, contentType?: string): Blob; + msClose(): void; +} +declare var Blob: { + prototype: Blob; + new (blobParts?: any[], options?: BlobPropertyBag): Blob; +} + +interface ApplicationCache extends EventTarget { + status: number; + ondownloading: (ev: Event) => any; + onprogress: (ev: ProgressEvent) => any; + onupdateready: (ev: Event) => any; + oncached: (ev: Event) => any; + onobsolete: (ev: Event) => any; + onerror: (ev: ErrorEvent) => any; + onchecking: (ev: Event) => any; + onnoupdate: (ev: Event) => any; + swapCache(): void; + abort(): void; + update(): void; + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} +declare var ApplicationCache: { + CHECKING: number; + UNCACHED: number; + UPDATEREADY: number; + DOWNLOADING: number; + IDLE: number; + OBSOLETE: number; +} + +interface FrameRequestCallback { + (time: number): void; +} + +interface XMLHttpRequest { + response: any; + withCredentials: boolean; + onprogress: (ev: ProgressEvent) => any; + onabort: (ev: any) => any; + responseType: string; + onloadend: (ev: ProgressEvent) => any; + upload: XMLHttpRequestEventTarget; + onerror: (ev: ErrorEvent) => any; + onloadstart: (ev: any) => any; +} + +interface PopStateEvent extends Event { + state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + style: CSSStyleDeclaration; +} + +interface MSFileSaver { + msSaveBlob(blob: any, defaultName?: string): boolean; + msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; +} + +interface MSStream { + type: string; + msDetachStream(): any; + msClose(): void; +} + +interface MediaError { + msExtendedCode: number; +} + +interface HTMLFieldSetElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new (): MSBlobBuilder; +} + +interface HTMLElement { + onmscontentzoom: (ev: any) => any; + oncuechange: (ev: Event) => any; + spellcheck: boolean; + classList: DOMTokenList; + onmsmanipulationstatechanged: (ev: any) => any; + draggable: boolean; +} + +interface DataTransfer { + types: DOMStringList; + files: FileList; +} + +interface DOMSettableTokenList extends DOMTokenList { + value: string; +} + +interface IDBFactory { + open(name: string, version?: number): IDBOpenDBRequest; + cmp(first: any, second: any): number; + deleteDatabase(name: string): IDBOpenDBRequest; +} + +interface Range { + createContextualFragment(fragment: string): DocumentFragment; +} + +interface HTMLObjectElement { + /** + * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. + */ + validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + willValidate: boolean; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * Sets a custom error message that is displayed when a form is submitted. + * @param error Sets a custom error message that is displayed when a form is submitted. + */ + setCustomValidity(error: string): void; +} + +interface MSPointerEvent 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; + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} +declare var MSPointerEvent: { + MSPOINTER_TYPE_PEN: number; + MSPOINTER_TYPE_MOUSE: number; + MSPOINTER_TYPE_TOUCH: number; +} + +interface DOMException { + name: string; + INVALID_NODE_TYPE_ERR: number; + DATA_CLONE_ERR: number; + TIMEOUT_ERR: number; +} +//declare var DOMException: { +// INVALID_NODE_TYPE_ERR: number; +// DATA_CLONE_ERR: number; +// TIMEOUT_ERR: number; +//} + +interface MSManipulationEvent extends UIEvent { + lastState: number; + currentState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} +declare var MSManipulationEvent: { + MS_MANIPULATION_STATE_STOPPED: number; + MS_MANIPULATION_STATE_ACTIVE: number; + MS_MANIPULATION_STATE_INERTIA: number; +} + +interface FormData { + append(name: any, value: any, blobName?: string): void; +} +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollection; +} + +interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { + preserveAspectRatio: SVGAnimatedPreserveAspectRatio; +} + +interface AbstractWorker extends EventTarget { + onerror: (ev: ErrorEvent) => any; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + operator: SVGAnimatedEnumeration; + in2: SVGAnimatedString; + k2: SVGAnimatedNumber; + k1: SVGAnimatedNumber; + k3: SVGAnimatedNumber; + in1: SVGAnimatedString; + k4: SVGAnimatedNumber; + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} +declare var SVGFECompositeElement: { + SVG_FECOMPOSITE_OPERATOR_OUT: number; + SVG_FECOMPOSITE_OPERATOR_OVER: number; + SVG_FECOMPOSITE_OPERATOR_XOR: number; + SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + SVG_FECOMPOSITE_OPERATOR_IN: number; + SVG_FECOMPOSITE_OPERATOR_ATOP: number; +} + +interface ValidityState { + customError: boolean; + valueMissing: boolean; + stepMismatch: boolean; + rangeUnderflow: boolean; + rangeOverflow: boolean; + typeMismatch: boolean; + patternMismatch: boolean; + tooLong: boolean; + valid: boolean; +} + +interface HTMLTrackElement extends HTMLElement { + kind: string; + src: string; + srclang: string; + track: TextTrack; + label: string; + default: boolean; +} + +interface MSApp { + createFileFromStorageFile(storageFile: any): File; + createBlobFromRandomAccessStream(type: string, seeker: any): Blob; + createStreamFromInputStream(type: string, inputStream: any): MSStream; + terminateApp(exceptionObject: any): void; + createDataPackage(object: any): any; + execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; + getHtmlPrintDocumentSource(htmlDoc: any): any; + addPublicLocalApplicationUri(uri: string): void; + createDataPackageFromSelection(): any; +} +declare var MSApp: MSApp; + +interface HTMLVideoElement { + msIsStereo3D: boolean; + msStereo3DPackingMode: string; + onMSVideoOptimalLayoutChanged: (ev: any) => any; + onMSVideoFrameStepCompleted: (ev: any) => any; + msStereo3DRenderMode: string; + msIsLayoutOptimalForPlayback: boolean; + msHorizontalMirror: boolean; + onMSVideoFormatChanged: (ev: any) => any; + msZoom: boolean; + msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; + msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; + msFrameStep(forward: boolean): void; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + in1: SVGAnimatedString; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + kernelUnitLengthY: SVGAnimatedNumber; + surfaceScale: SVGAnimatedNumber; + in1: SVGAnimatedString; + kernelUnitLengthX: SVGAnimatedNumber; + diffuseConstant: SVGAnimatedNumber; +} + +interface MSCSSMatrix { + m24: number; + m34: number; + a: number; + d: number; + m32: number; + m41: number; + m11: number; + f: number; + e: number; + m23: number; + m14: number; + m33: number; + m22: number; + m21: number; + c: number; + m12: number; + b: number; + m42: number; + m31: number; + m43: number; + m13: number; + m44: number; + multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; + skewY(angle: number): MSCSSMatrix; + setMatrixValue(value: string): void; + inverse(): MSCSSMatrix; + rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; + toString(): string; + rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; + translate(x: number, y: number, z?: number): MSCSSMatrix; + scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; + skewX(angle: number): MSCSSMatrix; +} +declare var MSCSSMatrix: { + prototype: MSCSSMatrix; + new (text?: string): MSCSSMatrix; +} + +interface Worker extends AbstractWorker { + onmessage: (ev: any) => any; + postMessage(message: any, ports?: any): void; + terminate(): void; +} +declare var Worker: { + prototype: Worker; + new (stringUrl: string): Worker; +} + +interface HTMLIFrameElement { + sandbox: DOMSettableTokenList; +} + +declare var onmspointerdown: (ev: any) => any; +declare var animationStartTime: number; +declare var onmsgesturedoubletap: (ev: any) => any; +declare var onmspointerhover: (ev: any) => any; +declare var onmsgesturehold: (ev: any) => any; +declare var onmspointermove: (ev: any) => any; +declare var onmsgesturechange: (ev: any) => any; +declare var onmsgesturestart: (ev: any) => any; +declare var onmspointercancel: (ev: any) => any; +declare var onmsgestureend: (ev: any) => any; +declare var onmsgesturetap: (ev: any) => any; +declare var onmspointerout: (ev: any) => any; +declare var msAnimationStartTime: number; +declare var applicationCache: ApplicationCache; +declare var onmsinertiastart: (ev: any) => any; +declare var onmspointerover: (ev: any) => any; +declare var onpopstate: (ev: PopStateEvent) => any; +declare var onmspointerup: (ev: any) => any; +declare function msCancelRequestAnimationFrame(handle: number): void; +declare function matchMedia(mediaQuery: string): MediaQueryList; +declare function cancelAnimationFrame(handle: number): void; +declare function msIsStaticHTML(html: string): boolean; +declare function msMatchMedia(mediaQuery: string): MediaQueryList; +declare function requestAnimationFrame(callback: FrameRequestCallback): number; +declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function btoa(rawString: string): string; +declare function atob(encodedString: string): string; +declare var msIndexedDB: IDBFactory; +declare var indexedDB: IDBFactory; +declare var console: Console; + + +///////////////////////////// +/// IE11 DOM APIs +///////////////////////////// + + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: Array; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: Array; +} + +interface AlgorithmParameters { +} + +interface MutationObserverInit { + childList?: boolean; + attributes?: boolean; + characterData?: boolean; + subtree?: boolean; + attributeOldValue?: boolean; + characterDataOldValue?: boolean; + attributeFilter?: Array; +} + +interface ExceptionInformation { + domain?: string; +} + +interface MsZoomToOptions { + contentX?: number; + contentY?: number; + viewportX?: string; + viewportY?: string; + scaleFactor?: number; + animate?: string; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface Algorithm { + name?: string; + params?: AlgorithmParameters; +} + +interface NavigatorID { + product: string; + vendor: string; +} + +interface HTMLBodyElement { + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; +} + +interface MSExecAtPriorityFunctionCallback { + (...args: any[]): any; +} + +interface MSWindowExtensions { + captureEvents(): void; + releaseEvents(): void; +} + +interface MSGraphicsTrust { + status: string; + constrictionActive: boolean; +} + +interface AudioTrack { + sourceBuffer: SourceBuffer; +} + +interface DragEvent { + msConvertURL(file: File, targetType: string, targetURL?: string): void; +} + +interface SubtleCrypto { + unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; + encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; + verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; + deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; + exportKey(format: string, key: Key): KeyOperation; + generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; + sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; + decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; +} + +interface Crypto extends RandomSource { + subtle: SubtleCrypto; +} + +interface VideoPlaybackQuality { + totalFrameDelay: number; + creationTime: number; + totalVideoFrames: number; + droppedVideoFrames: number; +} + +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 extends GlobalEventHandlers { + onpageshow: (ev: PageTransitionEvent) => any; + ondevicemotion: (ev: DeviceMotionEvent) => any; + devicePixelRatio: number; + msCrypto: Crypto; + ondeviceorientation: (ev: DeviceOrientationEvent) => any; + doNotTrack: string; + onmspointerenter: (ev: any) => any; + onpagehide: (ev: PageTransitionEvent) => any; + onmspointerleave: (ev: any) => any; +} + +interface Key { + algorithm: Algorithm; + type: string; + extractable: boolean; + keyUsage: string[]; +} + +interface TextTrackList extends EventTarget { + onaddtrack: (ev: any) => any; +} + +interface DeviceAcceleration { + y: number; + x: number; + z: number; +} + +interface Console { + count(countTitle?: string): void; + groupEnd(): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(): void; + group(groupTitle?: string): void; + dirxml(value: any): void; + debug(message?: string, ...optionalParams: any[]): void; + groupCollapsed(groupTitle?: string): void; + select(element: Element): void; +} + +interface MSNavigatorDoNotTrack { + removeSiteSpecificTrackingException(args: ExceptionInformation): void; + removeWebWideTrackingException(args: ExceptionInformation): void; + storeWebWideTrackingException(args: StoreExceptionsInformation): void; + storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; + confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; + confirmWebWideTrackingException(args: ExceptionInformation): boolean; +} + +interface HTMLImageElement { + crossOrigin: string; + msPlayToPreferredSourceUri: string; +} + +interface HTMLAllCollection extends HTMLCollection { + namedItem(name: string): Element; + //[name: string]: Element; +} + +interface MSNavigatorExtensions { + language: string; +} + +interface AesGcmEncryptResult { + ciphertext: ArrayBuffer; + tag: ArrayBuffer; +} + +interface HTMLSourceElement { + msKeySystem: string; +} + +interface CSSStyleDeclaration { + alignItems: string; + borderImageSource: string; + flexBasis: string; + borderImageWidth: string; + borderImageRepeat: string; + order: string; + flex: string; + alignContent: string; + msImeAlign: string; + flexShrink: string; + flexGrow: string; + borderImageSlice: string; + flexWrap: string; + borderImageOutset: string; + flexDirection: string; + touchAction: string; + flexFlow: string; + borderImage: string; + justifyContent: string; + alignSelf: string; + msTextCombineHorizontal: string; +} + +interface NavigationCompletedEvent extends NavigationEvent { + webErrorStatus: number; + isSuccess: boolean; +} + +interface MutationRecord { + oldValue: string; + previousSibling: Node; + addedNodes: NodeList; + attributeName: string; + removedNodes: NodeList; + target: Node; + nextSibling: Node; + attributeNamespace: string; + type: string; +} + +interface Navigator { + pointerEnabled: boolean; + maxTouchPoints: number; +} + +interface Document extends MSDocumentExtensions, GlobalEventHandlers { + msFullscreenEnabled: boolean; + onmsfullscreenerror: (ev: any) => any; + onmspointerenter: (ev: any) => any; + msFullscreenElement: Element; + onmsfullscreenchange: (ev: any) => any; + onmspointerleave: (ev: any) => any; + msExitFullscreen(): void; +} + +interface MimeTypeArray { + length: number; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(type: string): Plugin; + //[type: string]: Plugin; +} + +interface HTMLMediaElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + msKeys: MSMediaKeys; + msGraphicsTrustStatus: MSGraphicsTrust; + msSetMediaKeys(mediaKeys: MSMediaKeys): void; + addTextTrack(kind: string, label?: string, language?: string): TextTrack; +} + +interface TextTrack { + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; +} + +interface KeyOperation extends EventTarget { + oncomplete: (ev: any) => any; + onerror: (ev: any) => any; + result: any; +} + +interface DOMStringMap { +} + +interface DeviceOrientationEvent extends Event { + gamma: number; + alpha: number; + absolute: boolean; + beta: number; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; +} + +interface MSMediaKeys { + keySystem: string; + createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; + isTypeSupported(keySystem: string, type?: string): boolean; +} +declare var MSMediaKeys: { + prototype: MSMediaKeys; + new (): MSMediaKeys; +} + +interface MSMediaKeyMessageEvent extends Event { + destinationURL: string; + message: Uint8Array; +} + +interface MSHTMLWebViewElement extends HTMLElement { + documentTitle: string; + width: number; + src: string; + canGoForward: boolean; + height: number; + canGoBack: boolean; + navigateWithHttpRequestMessage(requestMessage: any): void; + goBack(): void; + navigate(uri: string): void; + stop(): void; + navigateToString(contents: string): void; + captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; + capturePreviewToBlobAsync(): MSWebViewAsyncOperation; + refresh(): void; + goForward(): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; + buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; +} + +interface NavigationEvent extends Event { + uri: string; +} + +interface Element extends GlobalEventHandlers { + onlostpointercapture: (ev: PointerEvent) => any; + onmspointerenter: (ev: any) => any; + ongotpointercapture: (ev: PointerEvent) => any; + onmspointerleave: (ev: any) => any; + msZoomTo(args: MsZoomToOptions): void; + setPointerCapture(pointerId: number): void; + msGetUntransformedBounds(): ClientRect; + releasePointerCapture(pointerId: number): void; + msRequestFullscreen(): void; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface XMLHttpRequest { + msCaching: string; + msCachingEnabled(): boolean; + overrideMimeType(mime: string): void; +} + +interface SourceBuffer extends EventTarget { + updating: boolean; + appendWindowStart: number; + appendWindowEnd: number; + buffered: TimeRanges; + timestampOffset: number; + audioTracks: AudioTrackList; + appendBuffer(data: ArrayBuffer): void; + remove(start: number, end: number): void; + abort(): void; + appendStream(stream: MSStream, maxSize?: number): void; +} + +interface MSInputMethodContext extends EventTarget { + oncandidatewindowshow: (ev: any) => any; + target: HTMLElement; + compositionStartOffset: number; + oncandidatewindowhide: (ev: any) => any; + oncandidatewindowupdate: (ev: any) => any; + compositionEndOffset: number; + getCompositionAlternatives(): string[]; + getCandidateWindowClientRect(): ClientRect; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; +} + +interface DeviceRotationRate { + gamma: number; + alpha: number; + beta: number; +} + +interface PluginArray { + length: number; + refresh(reload?: boolean): void; + item(index: number): Plugin; + [index: number]: Plugin; + namedItem(name: string): Plugin; + //[name: string]: Plugin; +} + +interface MSMediaKeyError { + systemCode: number; + code: number; + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} +declare var MSMediaKeyError: { + MS_MEDIA_KEYERR_SERVICE: number; + MS_MEDIA_KEYERR_HARDWARECHANGE: number; + MS_MEDIA_KEYERR_OUTPUT: number; + MS_MEDIA_KEYERR_DOMAIN: number; + MS_MEDIA_KEYERR_UNKNOWN: number; + MS_MEDIA_KEYERR_CLIENT: number; +} + +interface Plugin { + length: number; + filename: string; + version: string; + name: string; + description: string; + item(index: number): MimeType; + [index: number]: MimeType; + namedItem(type: string): MimeType; + //[type: string]: MimeType; +} + +interface HTMLFrameSetElement { + onpageshow: (ev: PageTransitionEvent) => any; + onpagehide: (ev: PageTransitionEvent) => any; +} + +interface Screen extends EventTarget { + msOrientation: string; + onmsorientationchange: (ev: any) => any; + msLockOrientation(orientations: string[]): boolean; + msUnlockOrientation(): void; +} + +interface MediaSource extends EventTarget { + sourceBuffers: SourceBufferList; + duration: number; + readyState: string; + activeSourceBuffers: SourceBufferList; + addSourceBuffer(type: string): SourceBuffer; + endOfStream(error?: string): void; + isTypeSupported(type: string): boolean; + removeSourceBuffer(sourceBuffer: SourceBuffer): void; +} +declare var MediaSource: { + prototype: MediaSource; + new (): MediaSource; +} + +interface MediaError { + MS_MEDIA_ERR_ENCRYPTED: number; +} +//declare var MediaError: { +// MS_MEDIA_ERR_ENCRYPTED: number; +//} + +interface SourceBufferList extends EventTarget { + length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +interface XMLDocument extends Document { +} + +interface DeviceMotionEvent extends Event { + rotationRate: DeviceRotationRate; + acceleration: DeviceAcceleration; + interval: number; + accelerationIncludingGravity: DeviceAcceleration; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; +} + +interface MimeType { + enabledPlugin: Plugin; + suffixes: string; + type: string; + description: string; +} + +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 { + captureEvents(): void; + releaseEvents(): void; +} + +interface HTMLElement { + dataset: DOMStringMap; + hidden: boolean; + msGetInputContext(): MSInputMethodContext; +} + +interface MutationObserver { + observe(target: Node, options: MutationObserverInit): void; + takeRecords(): MutationRecord[]; + disconnect(): void; +} +declare var MutationObserver: { + prototype: MutationObserver; + new (): MutationObserver; +} + +interface AudioTrackList { + onremovetrack: (ev: PluginArray) => any; +} + +interface HTMLObjectElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * 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. + */ + msPlayToSource: any; +} + +interface HTMLEmbedElement { + /** + * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. + */ + msPlayToPreferredSourceUri: string; + /** + * Gets or sets the primary DLNA PlayTo device. + */ + msPlayToPrimary: boolean; + /** + * 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. + */ + msPlayToSource: any; +} + +interface MSWebViewAsyncOperation extends EventTarget { + target: MSHTMLWebViewElement; + oncomplete: (ev: any) => any; + error: DOMError; + onerror: (ev: any) => any; + readyState: number; + type: number; + result: any; + start(): void; + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} +declare var MSWebViewAsyncOperation: { + ERROR: number; + TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + TYPE_INVOKE_SCRIPT: number; + COMPLETED: number; + TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + STARTED: number; +} + +interface ScriptNotifyEvent extends Event { + value: string; + callingUri: string; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + redirectStart: number; + domainLookupEnd: number; + responseStart: number; + domComplete: number; + domainLookupStart: number; + loadEventStart: number; + unloadEventEnd: number; + fetchStart: number; + requestStart: number; + domInteractive: number; + navigationStart: number; + connectEnd: number; + loadEventEnd: number; + connectStart: number; + responseEnd: number; + domLoading: number; + redirectEnd: number; + redirectCount: number; + unloadEventStart: number; + domContentLoadedEventStart: number; + domContentLoadedEventEnd: number; + type: string; +} + +interface MSMediaKeyNeededEvent extends Event { + initData: Uint8Array; +} + +interface MSManipulationEvent { + MS_MANIPULATION_STATE_SELECTING: number; + MS_MANIPULATION_STATE_COMMITTED: number; + MS_MANIPULATION_STATE_PRESELECT: number; + MS_MANIPULATION_STATE_DRAGGING: number; + MS_MANIPULATION_STATE_CANCELLED: number; +} +//declare var MSManipulationEvent: { +// MS_MANIPULATION_STATE_SELECTING: number; +// MS_MANIPULATION_STATE_COMMITTED: number; +// MS_MANIPULATION_STATE_PRESELECT: number; +// MS_MANIPULATION_STATE_DRAGGING: number; +// MS_MANIPULATION_STATE_CANCELLED: number; +//} + +interface LongRunningScriptDetectedEvent extends Event { + stopPageScriptExecution: boolean; + executionTime: number; +} + +interface MSAppView { + viewId: number; + close(): void; + postMessage(message: any, targetOrigin: string, ports?: any): void; +} + +interface PerfWidgetExternal { + maxCpuSpeed: 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; +} + +interface PageTransitionEvent extends Event { + persisted: boolean; +} + +interface MutationCallback { + (mutations: MutationRecord[], observer: MutationObserver): void; +} + +interface HTMLDocument extends Document { +} + +interface KeyPair { + privateKey: Key; + publicKey: Key; +} + +interface MSApp { + getViewOpener(): MSAppView; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; + createNewView(uri: string): MSAppView; + getCurrentPriority(): string; + NORMAL: string; + HIGH: string; + IDLE: string; + CURRENT: string; +} +//declare var MSApp: { +// NORMAL: string; +// HIGH: string; +// IDLE: string; +// CURRENT: string; +//} + +interface MSMediaKeySession extends EventTarget { + sessionId: string; + error: MSMediaKeyError; + keySystem: string; + close(): void; + update(key: Uint8Array): void; +} + +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 { + getVideoPlaybackQuality(): VideoPlaybackQuality; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEvent { + referrer: string; +} + +interface CryptoOperation extends EventTarget { + algorithm: Algorithm; + oncomplete: (ev: any) => any; + onerror: (ev: any) => any; + onprogress: (ev: any) => any; + onabort: (ev: any) => any; + key: Key; + result: any; + abort(): void; + finish(): void; + process(buffer: ArrayBufferView): void; +} + +declare var onpageshow: (ev: PageTransitionEvent) => any; +declare var ondevicemotion: (ev: DeviceMotionEvent) => any; +declare var devicePixelRatio: number; +declare var msCrypto: Crypto; +declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; +declare var doNotTrack: string; +declare var onmspointerenter: (ev: any) => any; +declare var onpagehide: (ev: PageTransitionEvent) => any; +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; + + +///////////////////////////// +/// WorkerGlobalScope APIs +///////////////////////////// +// TODO: These are only available in a Web Worker - should be in a separate lib file +declare function importScripts(...urls: string[]): void; + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// +declare var ActiveXObject: { new (s: string): any; }; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +declare var WScript: { + Echo(s: any): void; + StdErr: ITextWriter; + StdOut: ITextWriter; + Arguments: { length: number; Item(n: number): string; }; + ScriptFullName: string; + Quit(exitCode?: number): number; +} diff --git a/_infrastructure/tests/typescript/0.9.7/tsc b/_infrastructure/tests/typescript/0.9.7/tsc new file mode 100644 index 0000000000..3c0dab574f --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7/tsc @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./tsc.js') diff --git a/_infrastructure/tests/typescript/0.9.7/tsc.js b/_infrastructure/tests/typescript/0.9.7/tsc.js new file mode 100644 index 0000000000..01bea509c4 --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7/tsc.js @@ -0,0 +1,62790 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.DiagnosticCode = { + error_TS_0_1: "error TS{0}: {1}", + warning_TS_0_1: "warning TS{0}: {1}", + Unrecognized_escape_sequence: "Unrecognized escape sequence.", + Unexpected_character_0: "Unexpected character {0}.", + Missing_close_quote_character: "Missing close quote character.", + Identifier_expected: "Identifier expected.", + _0_keyword_expected: "'{0}' keyword expected.", + _0_expected: "'{0}' expected.", + Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", + Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", + Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", + Trailing_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", + Unexpected_token: "Unexpected token.", + Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", + Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", + Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", + Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", + Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", + Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", + extends_clause_already_seen: "'extends' clause already seen.", + extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", + Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", + implements_clause_already_seen: "'implements' clause already seen.", + Accessibility_modifier_already_seen: "Accessibility modifier already seen.", + _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", + _0_modifier_already_seen: "'{0}' modifier already seen.", + _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", + Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", + super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", + Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", + Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", + 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_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}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", + set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", + set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", + get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", + Modifiers_cannot_appear_here: "Modifiers cannot appear here.", + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", + Class_name_cannot_be_0: "Class name cannot be '{0}'.", + Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", + Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + Enum_member_must_have_initializer: "Enum member must have initializer.", + Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", + module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", + constructor_function_accessor_or_variable: "constructor, function, accessor or variable", + statement: "statement", + case_or_default_clause: "case or default clause", + identifier: "identifier", + call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", + expression: "expression", + type_name: "type name", + property_or_accessor: "property or accessor", + parameter: "parameter", + type: "type", + type_parameter: "type parameter", + 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_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.", + super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", + Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", + Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", + Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", + Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", + Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", + Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", + Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", + Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", + Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", + Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", + Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", + Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", + Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", + Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", + Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", + Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", + Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", + Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", + Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", + Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", + Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", + Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", + Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", + Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", + Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", + Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", + Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", + Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", + Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", + Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", + Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", + Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", + Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", + Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", + A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", + Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", + Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", + Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", + A_class_may_only_extend_another_class: "A class may only extend another class.", + A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", + An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", + Unable_to_resolve_type: "Unable to resolve type.", + Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", + Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", + Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", + Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", + Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", + Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", + Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", + Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", + Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + 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_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_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.", + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", + Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", + Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", + 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_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}'.", + 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.", + Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", + Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", + Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", + All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", + Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", + Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", + this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", + Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", + Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", + 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_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.", + Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", + A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", + 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_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_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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", + Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", + Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", + 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_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}", + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", + Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", + All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", + super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", + Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", + Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", + Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", + Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", + Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", + continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", + break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", + Jump_target_not_found: "Jump target not found.", + Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", + TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", + TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", + TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", + TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", + TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", + TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", + Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", + 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}", + Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", + Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", + Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", + Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", + Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", + Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", + Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", + Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", + Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", + 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.", + 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_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_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.", + Could_not_find_file_0: "Could not find file: '{0}'.", + A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", + Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", + Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", + Emit_Error_0: "Emit Error: {0}.", + Cannot_read_file_0_1: "Cannot read file '{0}': {1}", + Unsupported_file_encoding: "Unsupported file encoding.", + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Invalid_call_to_up: "Invalid call to 'up'", + Invalid_call_to_down: "Invalid call to 'down'", + Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", + Unknown_option_0: "Unknown option '{0}'", + Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", + Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", + Could_not_delete_file_0: "Could not delete file '{0}'", + Could_not_create_directory_0: "Could not create directory '{0}'", + Error_while_executing_file_0: "Error while executing file '{0}': ", + Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", + Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", + Option_0_specified_without_1: "Option '{0}' specified without '{1}'", + codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", + Generates_corresponding_0_file: "Generates corresponding {0} file.", + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", + Watch_input_files: "Watch input files.", + Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", + Do_not_emit_comments_to_output: "Do not emit comments to output.", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", + Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", + Print_this_message: "Print this message.", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file1: "file", + Examples: "Examples:", + Options: "Options:", + Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", + Version_0: "Version {0}", + Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", + NL_Recompiling_0: "{NL}Recompiling ({0}):", + STRING: "STRING", + KIND: "KIND", + file2: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + 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})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", + Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", + Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", + Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", + Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", + new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", + _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", + Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", + 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.", + 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; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + return false; + } + + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0, n = array1.length; i < n; i++) { + if (!equals(array1[i], array2[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.distinct = function (array, equalsFn) { + var result = []; + + for (var i = 0, n = array.length; i < n; i++) { + var current = array[i]; + for (var j = 0; j < result.length; j++) { + if (equalsFn(result[j], current)) { + break; + } + } + + if (j === result.length) { + result.push(current); + } + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.lastOrDefault = function (array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var v = array[i]; + if (predicate(v, i)) { + return v; + } + } + + return null; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value, i)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.first = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (!func || func(value, i)) { + return value; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + var low = 0; + var high = array.length - 1; + + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + + if (midValue === value) { + return middle; + } else if (midValue > value) { + high = middle - 1; + } else { + low = middle + 1; + } + } + + return ~low; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + + ArrayUtilities.indexOf = function (array, predicate) { + for (var i = 0, n = array.length; i < n; i++) { + if (predicate(array[i])) { + return i; + } + } + + return -1; + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitVector) { + var pool = []; + var Constants; + (function (Constants) { + Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; + Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; + + Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; + + Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; + Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; + + Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; + Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; + Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; + })(Constants || (Constants = {})); + + var BitVectorImpl = (function () { + function BitVectorImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.bits = []; + } + BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; + }; + + BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; + }; + + BitVectorImpl.prototype.valueAt = function (index) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return undefined; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { + return true; + } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { + return false; + } else { + return undefined; + } + } else { + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return false; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { + return true; + } else { + return false; + } + } + }; + + BitVectorImpl.prototype.setValueAt = function (index, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); + + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === undefined) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + + var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); + encoded = encoded & clearMask; + + if (value === true) { + encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); + } else if (value === false) { + encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } else { + TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); + + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === false) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + + encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); + + if (value) { + encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } + }; + + BitVectorImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + this.bits.length = 0; + pool.push(this); + }; + return BitVectorImpl; + })(); + + function getBitVector(allowUndefinedValues) { + if (pool.length === 0) { + return new BitVectorImpl(allowUndefinedValues); + } + + var vector = pool.pop(); + vector.isReleased = false; + vector.allowUndefinedValues = allowUndefinedValues; + + return vector; + } + BitVector.getBitVector = getBitVector; + })(TypeScript.BitVector || (TypeScript.BitVector = {})); + var BitVector = TypeScript.BitVector; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitMatrix) { + var pool = []; + + var BitMatrixImpl = (function () { + function BitMatrixImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.vectors = []; + } + BitMatrixImpl.prototype.valueAt = function (x, y) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + return this.allowUndefinedValues ? undefined : false; + } + + return vector.valueAt(y); + }; + + BitMatrixImpl.prototype.setValueAt = function (x, y, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + if (value === undefined) { + return; + } + + vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); + this.vectors[x] = vector; + } + + vector.setValueAt(y, value); + }; + + BitMatrixImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + + for (var name in this.vectors) { + if (this.vectors.hasOwnProperty(name)) { + var vector = this.vectors[name]; + vector.release(); + } + } + + this.vectors.length = 0; + pool.push(this); + }; + return BitMatrixImpl; + })(); + + function getBitMatrix(allowUndefinedValues) { + if (pool.length === 0) { + return new BitMatrixImpl(allowUndefinedValues); + } + + var matrix = pool.pop(); + matrix.isReleased = false; + matrix.allowUndefinedValues = allowUndefinedValues; + + return matrix; + } + BitMatrix.getBitMatrix = getBitMatrix; + })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); + var BitMatrix = TypeScript.BitMatrix; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); + var AssertionLevel = TypeScript.AssertionLevel; + + var Debug = (function () { + function Debug() { + } + Debug.shouldAssert = function (level) { + return this.currentAssertionLevel >= level; + }; + + Debug.assert = function (expression, message, verboseDebugInfo) { + if (typeof message === "undefined") { message = ""; } + if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); + } + + throw new Error("Debug Failure. False expression: " + message + verboseDebugString); + } + }; + + Debug.fail = function (message) { + Debug.assert(false, message); + }; + Debug.currentAssertionLevel = 0 /* None */; + return Debug; + })(); + 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 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(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; + } + + return result; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return this._additionalLocations || []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + + Diagnostic.prototype.info = function () { + return getDiagnosticInfoFromKey(this.diagnosticKey()); + }; + return Diagnostic; + })(Location); + TypeScript.Diagnostic = Diagnostic; + + function newLine() { + return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while (match = regex.exec(diagnostic)) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result); + return result; + } + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); + } + + diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { + return typeof args[num] !== 'undefined' ? args[num] : match; + }); + + diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { + return TypeScript.newLine(); + }); + + return diagnosticMessageText; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error("Invalid argument: " + argument + ". " + message); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error("Argument out of range: " + argument); + }; + + Errors.argumentNull = function (argument) { + return new Error("Argument null: " + argument); + }; + + Errors.abstract = function () { + return new Error("Operation not implemented properly by subclass."); + }; + + Errors.notYetImplemented = function () { + return new Error("Not yet implemented."); + }; + + Errors.invalidOperation = function (message) { + return new Error("Invalid operation: " + message); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft === 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, + 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, + 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, + 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, + 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, + 4166287, 4999559, 5999471, 7199369]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? key.hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', "Key was already in table."); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; + + (function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; + })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); + var ByteOrderMark = TypeScript.ByteOrderMark; + + var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; + })(); + TypeScript.FileInformation = FileInformation; + + TypeScript.Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return WScript.CreateObject("WScript.Shell").CurrentDirectory; + }, + supportsCodePage: function () { + return WScript.ReadFile; + }, + readFile: function (path, codepage) { + try { + if (codepage !== null && this.supportsCodePage()) { + try { + var contents = WScript.ReadFile(path, codepage); + return new FileInformation(contents, 0 /* None */); + } catch (e) { + } + } + + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return process.cwd(); + }, + supportsCodePage: function () { + return false; + }, + readFile: function (file, codepage) { + if (codepage !== null) { + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); + } + + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 509); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IntegerUtilities) { + function integerDivide(numerator, denominator) { + return (numerator / denominator) >> 0; + } + IntegerUtilities.integerDivide = integerDivide; + + function integerMultiplyLow32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + } + IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; + + function integerMultiplyHigh32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + } + IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + IntegerUtilities.isInteger = isInteger; + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + IntegerUtilities.isHexInteger = isHexInteger; + })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); + var IntegerUtilities = TypeScript.IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_computeLineStarts, length) { + this._computeLineStarts = _computeLineStarts; + this.length = length; + this._lineStarts = null; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this.lineStarts(), length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + if (this._lineStarts === null) { + this._lineStarts = this._computeLineStarts(); + } + + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + LineMap.empty = new LineMap(function () { + return [0]; + }, 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { + return e; + } + } + + return null; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + if (text.length !== length) { + return false; + } + + var s = start; + for (var i = 0; i < length; i++) { + if (text.charCodeAt(i) !== array[s]) { + return false; + } + + s++; + } + + return true; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static.": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static.": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Invalid 'reference' directive syntax.": { + "code": 1084, + "category": 1 /* Error */ + }, + "Octal literals are not available when targeting ECMAScript 5 and higher.": { + "code": 1085, + "category": 1 /* Error */ + }, + "Accessors are not allowed in ambient contexts.": { + "code": 1086, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a constructor declaration.": { + "code": 1089, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a parameter.": { + "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 */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static members cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* Error */ + }, + "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { + "code": 2104, + "category": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* Error */ + }, + "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { + "code": 2117, + "category": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "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 */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Type '{0}' does not have type parameters.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or not exported.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not assignable to any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "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 assignable to numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are only allowed in implementation.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { + "code": 2188, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { + "code": 2189, + "category": 1 /* Error */ + }, + "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { + "code": 2190, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot be reopened.": { + "code": 2191, + "category": 1 /* Error */ + }, + "All declarations of merged declaration '{0}' must be exported or not exported.": { + "code": 2192, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in constructor arguments.": { + "code": 2193, + "category": 1 /* Error */ + }, + "Return type of constructor signature must be assignable to the instance type of the class.": { + "code": 2194, + "category": 1 /* Error */ + }, + "Ambient external module declaration must be defined in global context.": { + "code": 2195, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot specify relative module name.": { + "code": 2196, + "category": 1 /* Error */ + }, + "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { + "code": 2197, + "category": 1 /* Error */ + }, + "Could not find the best common type of types of all return statement expressions.": { + "code": 2198, + "category": 1 /* Error */ + }, + "Import declaration cannot refer to external module reference when --noResolve option is set.": { + "code": 2199, + "category": 1 /* Error */ + }, + "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { + "code": 2200, + "category": 1 /* Error */ + }, + "'continue' statement can only be used within an enclosing iteration statement.": { + "code": 2201, + "category": 1 /* Error */ + }, + "'break' statement can only be used within an enclosing iteration or switch statement.": { + "code": 2202, + "category": 1 /* Error */ + }, + "Jump target not found.": { + "code": 2203, + "category": 1 /* Error */ + }, + "Jump target cannot cross function boundary.": { + "code": 2204, + "category": 1 /* Error */ + }, + "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { + "code": 2205, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { + "code": 2206, + "category": 1 /* Error */ + }, + "Expression resolves to '_super' that compiler uses to capture base class reference.": { + "code": 2207, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2208, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2209, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2210, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2211, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2212, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2213, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2214, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2215, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2216, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2217, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2218, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2219, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { + "code": 2220, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2221, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { + "code": 2222, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2223, + "category": 1 /* Error */ + }, + "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { + "code": 2224, + "category": 1 /* Error */ + }, + "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { + "code": 2225, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { + "code": 2226, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { + "code": 2227, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { + "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 */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Variable declaration cannot have the same name as an import declaration.": { + "code": 4026, + "category": 1 /* Error */ + }, + "Signature expected {0} type arguments, got {1} instead.": { + "code": 4027, + "category": 1 /* Error */ + }, + "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { + "code": 4028, + "category": 3 /* NoPrefix */ + }, + "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 infinitely expanding type reference have incompatible type arguments.": { + "code": 4030, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "code": 4031, + "category": 3 /* NoPrefix */ + }, + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { + "code": 4032, + "category": 3 /* NoPrefix */ + }, + "Types of string indexer of types '{0}' and '{1}' are not identical.": { + "code": 4033, + "category": 3 /* NoPrefix */ + }, + "Types of number indexer of types '{0}' and '{1}' are not identical.": { + "code": 4034, + "category": 3 /* NoPrefix */ + }, + "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 assignable to string indexer type in type '{2}'.{NL}{3}": { + "code": 4036, + "category": 3 /* NoPrefix */ + }, + "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 */ + }, + "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { + "code": 5002, + "category": 1 /* Error */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 1 /* Error */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit.": { + "code": 5021, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead.": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Option '{0}' specified without '{1}'": { + "code": 5041, + "category": 1 /* Error */ + }, + "'codepage' option not supported on current platform.": { + "code": 5042, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file.": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file.": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files.": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory.": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output.": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing.": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: '{0}' (default), or '{1}'": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: '{0}' or '{1}'": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message.": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated '{0}' keyword when referencing an external module.": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file1": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options.": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "file2": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "NUMBER": { + "code": 6039, + "category": 2 /* Message */ + }, + "Specify the codepage to use when opening source files.": { + "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 */ + }, + "Unknown rule.": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7015, + "category": 1 /* Error */ + }, + "'{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 = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + this._lineStartPositions = null; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + if (!this._lineStartPositions) { + this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); + } + + return this._lineStartPositions; + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LineMap1) { + function fromSimpleText(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return text.charCodeAt(index); + }, length: text.length() }); + }, text.length()); + } + LineMap1.fromSimpleText = fromSimpleText; + + function fromScriptSnapshot(scriptSnapshot) { + return new TypeScript.LineMap(function () { + return scriptSnapshot.getLineStartPositions(); + }, scriptSnapshot.getLength()); + } + LineMap1.fromScriptSnapshot = fromScriptSnapshot; + + function fromString(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts(text); + }, text.length); + } + LineMap1.fromString = fromString; + })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); + var LineMap1 = TypeScript.LineMap1; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this._lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this._lineStarts(); + }, this.length()); + }; + + TextBase.prototype._lineStarts = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this._lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + this._lazyLineStarts = null; + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.substr = function (start, length, intern) { + var startInOriginalText = this.span.start() + start; + return this.text.substr(startInOriginalText, length, intern); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SubText.prototype._lineStarts = function () { + var _this = this; + if (!this._lazyLineStarts) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return _this.charCodeAt(index); + }, length: this.length() }); + } + + return this._lazyLineStarts; + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + this._lazyLineStarts = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + + StringText.prototype._lineStarts = function () { + if (this._lazyLineStarts === null) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); + } + + return this._lazyLineStarts; + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap1.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + this._lineMap = null; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + if (!this._lineMap) { + this._lineMap = TypeScript.LineMap1.fromString(this.value); + } + + return this._lineMap; + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this.scriptSnapshot.getLineStartPositions(); + }, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length; + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + var change0 = changes[0]; + + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + + oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + CharacterInfo.isOctalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 55 /* _7 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + + SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; + + SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; + SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; + + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + + SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; + SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 164 /* PlusExpression */; + case 90 /* MinusToken */: + return 165 /* NegateExpression */; + case 102 /* TildeToken */: + return 166 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 167 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 168 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 169 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 210 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 211 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 205 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 206 /* DivideExpression */; + + case 92 /* PercentToken */: + return 207 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 208 /* AddExpression */; + + case 90 /* MinusToken */: + return 209 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 202 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 203 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 204 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 196 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 197 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 198 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 199 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 200 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 201 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 192 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 193 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 194 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 195 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 191 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 190 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 189 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 188 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 187 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 182 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 180 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 181 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 183 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 184 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 185 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 175 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 176 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 177 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 178 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 179 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 174 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 173 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function getOperatorTokenFromBinaryExpression(tokenKind) { + switch (tokenKind) { + case 205 /* MultiplyExpression */: + return 91 /* AsteriskToken */; + + case 206 /* DivideExpression */: + return 118 /* SlashToken */; + + case 207 /* ModuloExpression */: + return 92 /* PercentToken */; + + case 208 /* AddExpression */: + return 89 /* PlusToken */; + + case 209 /* SubtractExpression */: + return 90 /* MinusToken */; + + case 202 /* LeftShiftExpression */: + return 95 /* LessThanLessThanToken */; + + case 203 /* SignedRightShiftExpression */: + return 96 /* GreaterThanGreaterThanToken */; + + case 204 /* UnsignedRightShiftExpression */: + return 97 /* GreaterThanGreaterThanGreaterThanToken */; + + case 196 /* LessThanExpression */: + return 80 /* LessThanToken */; + + case 197 /* GreaterThanExpression */: + return 81 /* GreaterThanToken */; + + case 198 /* LessThanOrEqualExpression */: + return 82 /* LessThanEqualsToken */; + + case 199 /* GreaterThanOrEqualExpression */: + return 83 /* GreaterThanEqualsToken */; + + case 200 /* InstanceOfExpression */: + return 30 /* InstanceOfKeyword */; + + case 201 /* InExpression */: + return 29 /* InKeyword */; + + case 192 /* EqualsWithTypeConversionExpression */: + return 84 /* EqualsEqualsToken */; + + case 193 /* NotEqualsWithTypeConversionExpression */: + return 86 /* ExclamationEqualsToken */; + + case 194 /* EqualsExpression */: + return 87 /* EqualsEqualsEqualsToken */; + + case 195 /* NotEqualsExpression */: + return 88 /* ExclamationEqualsEqualsToken */; + + case 191 /* BitwiseAndExpression */: + return 98 /* AmpersandToken */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 100 /* CaretToken */; + + case 189 /* BitwiseOrExpression */: + return 99 /* BarToken */; + + case 188 /* LogicalAndExpression */: + return 103 /* AmpersandAmpersandToken */; + + case 187 /* LogicalOrExpression */: + return 104 /* BarBarToken */; + + case 182 /* OrAssignmentExpression */: + return 116 /* BarEqualsToken */; + + case 180 /* AndAssignmentExpression */: + return 115 /* AmpersandEqualsToken */; + + case 181 /* ExclusiveOrAssignmentExpression */: + return 117 /* CaretEqualsToken */; + + case 183 /* LeftShiftAssignmentExpression */: + return 112 /* LessThanLessThanEqualsToken */; + + case 184 /* SignedRightShiftAssignmentExpression */: + return 113 /* GreaterThanGreaterThanEqualsToken */; + + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + + case 175 /* AddAssignmentExpression */: + return 108 /* PlusEqualsToken */; + + case 176 /* SubtractAssignmentExpression */: + return 109 /* MinusEqualsToken */; + + case 177 /* MultiplyAssignmentExpression */: + return 110 /* AsteriskEqualsToken */; + + case 178 /* DivideAssignmentExpression */: + return 119 /* SlashEqualsToken */; + + case 179 /* ModuloAssignmentExpression */: + return 111 /* PercentEqualsToken */; + + case 174 /* AssignmentExpression */: + return 107 /* EqualsToken */; + + case 173 /* CommaExpression */: + return 79 /* CommaToken */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); + 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + 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 { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + 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(fullText, kind); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(text, start, isTrailing); + }; + + Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.slidingWindow.absoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(diagnostics); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(diagnostics); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifierOrKeyword(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var slidingWindow = this.slidingWindow; + var window = slidingWindow.window; + + var startIndex = slidingWindow.currentRelativeItemIndex; + var endIndex = slidingWindow.windowCount; + var currentIndex = startIndex; + var character = 0; + + while (currentIndex < endIndex) { + character = window[currentIndex]; + if (!isIdentifierPartCharacter[character]) { + break; + } + + currentIndex++; + } + + if (currentIndex === endIndex) { + return 0 /* None */; + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + return 0 /* None */; + } else { + var kind; + var identifierLength = currentIndex - startIndex; + if (isKeywordStartCharacter[firstCharacter]) { + kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); + } else { + kind = 11 /* IdentifierName */; + } + + slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); + + return kind; + } + }; + + Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + var sawUnicodeEscape = false; + + do { + var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); + sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + var length = this.slidingWindow.absoluteIndex() - startIndex; + var text = this.text.substr(startIndex, length, false); + var valueText = TypeScript.Syntax.massageEscapes(text); + + var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); + if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { + if (sawUnicodeEscape) { + return keywordKind | -2147483648 /* IsVariableWidthKeyword */; + } else { + return keywordKind; + } + } + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function (diagnostics) { + if (this.isHexNumericLiteral()) { + this.scanHexNumericLiteral(); + } else if (this.isOctalNumericLiteral()) { + this.scanOctalNumericLiteral(diagnostics); + } else { + this.scanDecimalNumericLiteral(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isOctalNumericLiteral = function () { + return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); + }; + + Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { + var position = this.absoluteIndex(); + + while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.languageVersion() >= 1 /* EcmaScript5 */) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); + } + }; + + Scanner.prototype.scanDecimalDigits = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + this.scanDecimalDigits(); + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + this.scanDecimalDigits(); + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + var nextChar1 = this.slidingWindow.peekItemN(1); + + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { + var nextChar2 = this.slidingWindow.peekItemN(2); + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } + } + } + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function (diagnostics) { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(diagnostics); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 12 /* RegularExpressionLiteral */; + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + break; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + break; + + default: + break; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + this.scanUnicodeOrHexEscape(errors); + return true; + } + } + + this.slidingWindow.moveToNextItem(); + return false; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return parent.type === nodeOrToken; + case 220 /* CastExpression */: + return parent.type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + case 228 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return TypeScript.Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return nodeOrToken.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + element.insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + element.insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + var firstToken = this.firstToken(); + return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.trailingTrivia = function () { + var lastToken = this.lastToken(); + return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + 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 === thisAsIndexable[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isExpression = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + + this._kind = kind; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.kind = function () { + return this._kind; + }; + + HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { + if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.name = name; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.name; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withName = function (name) { + return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { + if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.callSignature = callSignature; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 146 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.modifiers; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifiers = function (modifiers) { + return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + + this.arguments = _arguments; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 142 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 227 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 239 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.constructorKeyword = constructorKeyword; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.constructorKeyword; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + 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 */), CallSignatureSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var GetAccessorSyntax = (function (_super) { + __extends(GetAccessorSyntax, _super); + function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.getKeyword = getKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + } + GetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessor(this); + }; + + GetAccessorSyntax.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + + GetAccessorSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + GetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + GetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetAccessorSyntax.create1 = function (propertyName) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GetAccessorSyntax = GetAccessorSyntax; + + var SetAccessorSyntax = (function (_super) { + __extends(SetAccessorSyntax, _super); + function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.setKeyword = setKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + SetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessor(this); + }; + + SetAccessorSyntax.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + + SetAccessorSyntax.prototype.childCount = function () { + return 5; + }; + + SetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + SetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetAccessorSyntax.create1 = function (propertyName) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SetAccessorSyntax = SetAccessorSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var IndexMemberDeclarationSyntax = (function (_super) { + __extends(IndexMemberDeclarationSyntax, _super); + function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.indexSignature = indexSignature; + this.semicolonToken = semicolonToken; + } + IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexMemberDeclaration(this); + }; + + IndexMemberDeclarationSyntax.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + + IndexMemberDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.indexSignature; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexMemberDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { + if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { + return this; + } + + return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); + }; + + IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); + }; + + IndexMemberDeclarationSyntax.create1 = function (indexSignature) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { + return this.update(this.modifiers, indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.indexSignature, semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexMemberDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + this.colonToken = colonToken; + this.statements = statements; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + this.colonToken = colonToken; + this.statements = statements; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.doKeyword = doKeyword; + this.statement = statement; + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + 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) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var dedentThisTrivia = dedentNextWhitespace; + dedentNextWhitespace = false; + + if (dedentThisTrivia) { + if (trivia.kind() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + var indentNextTrivia = true; + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var indentThisTrivia = indentNextTrivia; + indentNextTrivia = false; + + switch (trivia.kind()) { + case 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; + this.tokenKind = kind; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function isExpression(token) { + switch (token.tokenKind) { + case 11 /* IdentifierName */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 50 /* SuperKeyword */: + return true; + } + + return false; + } + Syntax.isExpression = isExpression; + + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + case 13 /* carriageReturn */: + var nextIndex = i + 1; + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { + i++; + } + continue; + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + return regularExpressionValue(text); + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function regularExpressionValue(text) { + try { + var lastSlash = text.lastIndexOf("/"); + var body = text.substring(1, lastSlash); + var flags = text.substring(lastSlash + 1); + return new RegExp(body, flags); + } catch (e) { + return null; + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + EmptyToken.prototype.isExpression = function () { + return isExpression(this); + }; + + EmptyToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + + RealizedToken.prototype.isExpression = function () { + return isExpression(this); + }; + + RealizedToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var AbstractTrivia = (function () { + function AbstractTrivia(_kind) { + this._kind = _kind; + } + AbstractTrivia.prototype.fullWidth = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.fullText = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.toJSON = function (key) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === this._kind) { + result.kind = name; + break; + } + } + + if (this.isSkippedToken()) { + result.skippedToken = this.skippedToken(); + } else { + result.text = this.fullText(); + } + return result; + }; + + AbstractTrivia.prototype.kind = function () { + return this._kind; + }; + + AbstractTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + AbstractTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + AbstractTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + AbstractTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + AbstractTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return AbstractTrivia; + })(); + + var NormalTrivia = (function (_super) { + __extends(NormalTrivia, _super); + function NormalTrivia(kind, _text) { + _super.call(this, kind); + this._text = _text; + } + NormalTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + NormalTrivia.prototype.fullText = function () { + return this._text; + }; + + NormalTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return NormalTrivia; + })(AbstractTrivia); + + var SkippedTokenTrivia = (function (_super) { + __extends(SkippedTokenTrivia, _super); + function SkippedTokenTrivia(_skippedToken) { + _super.call(this, 8 /* SkippedTokenTrivia */); + this._skippedToken = _skippedToken; + } + SkippedTokenTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SkippedTokenTrivia.prototype.fullText = function () { + return this.skippedToken().fullText(); + }; + + SkippedTokenTrivia.prototype.skippedToken = function () { + return this._skippedToken; + }; + return SkippedTokenTrivia; + })(AbstractTrivia); + + var DeferredTrivia = (function (_super) { + __extends(DeferredTrivia, _super); + function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { + _super.call(this, kind); + this._text = _text; + this._fullStart = _fullStart; + this._fullWidth = _fullWidth; + this._fullText = null; + } + DeferredTrivia.prototype.fullWidth = function () { + return this._fullWidth; + }; + + DeferredTrivia.prototype.fullText = function () { + if (!this._fullText) { + this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); + this._text = null; + } + + return this._fullText; + }; + + DeferredTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return DeferredTrivia; + })(AbstractTrivia); + + function deferredTrivia(kind, text, fullStart, fullWidth) { + return new DeferredTrivia(kind, text, fullStart, fullWidth); + } + Syntax.deferredTrivia = deferredTrivia; + + function trivia(kind, text) { + return new NormalTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SkippedTokenTrivia(token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + this.trivia[i].collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 228 /* TypeArgumentList */: + case 229 /* TypeParameterList */: + case 220 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.name); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitList(node.modifiers); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.constructorKeyword); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.indexSignature); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + + + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + var result = this.currentToken(); + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + + return result; + }; + return SyntaxCursor; + })(); + + + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); + } + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { + this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 173 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 186 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 187 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 188 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 189 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 191 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 167 /* LogicalNotExpression */: + case 170 /* DeleteExpression */: + case 171 /* TypeOfExpression */: + case 172 /* VoidExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); + } + } + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + var modifierCount = this.modifierCount(); + return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + var modifierCount = this.modifierCount(); + if (this.isImportDeclaration(modifierCount)) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration(modifierCount)) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration(modifierCount)) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration(modifierCount)) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration(modifierCount)) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(inErrorRecovery)) { + return this.parseStatement(inErrorRecovery); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + + return typeArgumentList; + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isAccessor = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(false); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexMemberDeclaration()) { + return this.parseIndexMemberDeclaration(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var modifiers = this.parseModifiers(); + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var callSignature = this.parseCallSignature(false); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.isIndexMemberDeclaration = function () { + var index = this.modifierCount(); + return this.isIndexSignature(index); + }; + + ParserImpl.prototype.parseIndexMemberDeclaration = function () { + var modifiers = this.parseModifiers(); + var indexSignature = this.parseIndexSignature(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + if (callSignature.lastToken()) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature(0)) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(inErrorRecovery)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(inErrorRecovery)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function (tokenIndex) { + return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isIdentifier(this.currentToken())) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + + break; + + case 28 /* IfKeyword */: + case 70 /* OpenBraceToken */: + case 33 /* ReturnKeyword */: + case 34 /* SwitchKeyword */: + case 36 /* ThrowKeyword */: + case 15 /* BreakKeyword */: + case 18 /* ContinueKeyword */: + case 26 /* ForKeyword */: + case 42 /* WhileKeyword */: + case 43 /* WithKeyword */: + case 22 /* DoKeyword */: + case 38 /* TryKeyword */: + case 19 /* DebuggerKeyword */: + return true; + } + + if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { + return false; + } + + return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); + }; + + ParserImpl.prototype.parseStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 28 /* IfKeyword */: + return this.parseIfStatement(); + case 70 /* OpenBraceToken */: + return this.parseBlock(false, false); + case 33 /* ReturnKeyword */: + return this.parseReturnStatement(); + case 34 /* SwitchKeyword */: + return this.parseSwitchStatement(); + case 36 /* ThrowKeyword */: + return this.parseThrowStatement(); + case 15 /* BreakKeyword */: + return this.parseBreakStatement(); + case 18 /* ContinueKeyword */: + return this.parseContinueStatement(); + case 26 /* ForKeyword */: + return this.parseForOrForInStatement(); + case 42 /* WhileKeyword */: + return this.parseWhileStatement(); + case 43 /* WithKeyword */: + return this.parseWithStatement(); + case 22 /* DoKeyword */: + return this.parseDoStatement(); + case 38 /* TryKeyword */: + return this.parseTryStatement(); + case 19 /* DebuggerKeyword */: + return this.parseDebuggerStatement(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement(currentToken)) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { + return this.parseEmptyStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(false); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function (currentToken) { + return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(false); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return currentToken.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function (currentToken) { + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function (currentToken) { + switch (currentToken.tokenKind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + + case 74 /* OpenBracketToken */: + + case 72 /* OpenParenToken */: + + case 80 /* LessThanToken */: + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + + case 70 /* OpenBraceToken */: + + case 85 /* EqualsGreaterThanToken */: + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + + case 31 /* NewKeyword */: + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + + case 27 /* FunctionKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(false); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 225 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(token0); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpressionOrLower = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpressionOrLower(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else if (currentTokenKind === 39 /* TypeOfKeyword */) { + return this.parseTypeOfExpression(); + } else if (currentTokenKind === 41 /* VoidKeyword */) { + return this.parseVoidExpression(); + } else if (currentTokenKind === 21 /* DeleteKeyword */) { + return this.parseDeleteExpression(); + } else if (currentTokenKind === 80 /* LessThanToken */) { + return this.parseCastExpression(); + } else { + return this.parsePostfixExpressionOrLower(); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + if (precedence <= 2 /* AssignmentExpressionPrecedence */) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } + + var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); + if (parethesizedArrowFunction !== null) { + return parethesizedArrowFunction; + } + } + + var leftOperand = this.parseUnaryExpressionOrLower(); + return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } + + var expression = this.parsePrimaryExpression(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + return this.parseMemberExpressionRest(expression, false, inObjectCreation); + }; + + ParserImpl.prototype.parseCallExpressionOrLower = function () { + var expression; + if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { + expression = this.eatKeyword(50 /* SuperKeyword */); + + var currentTokenKind = this.currentToken().tokenKind; + if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + } + } else { + expression = this.parseMemberExpressionOrLower(false); + } + + return this.parseMemberExpressionRest(expression, true, false); + }; + + ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (!allowArguments) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (!allowArguments) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseCallExpressionOrLower(); + } + }; + + ParserImpl.prototype.parsePostfixExpressionOrLower = function () { + var expression = this.parseLeftHandSideExpressionOrLower(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + } + + return expression; + }; + + ParserImpl.prototype.tryParseGenericArgumentList = function () { + var rewindPoint = this.getRewindPoint(); + + var typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + + var argumentList = null; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } else { + return this.parseArgumentList(typeArgumentList); + } + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + return this.tryParseGenericArgumentList(); + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(null); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var _arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + _arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parsePrimaryExpression = function () { + var currentToken = this.currentToken(); + + if (this.isIdentifier(currentToken)) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseObjectCreationExpressionOrLower(true); + var argumentList = this.tryParseArgumentList(); + + var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); + return this.parseMemberExpressionRest(result, true, false); + }; + + ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseMemberExpressionOrLower(inObjectCreation); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedExpression = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { + return null; + } + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + + this.releaseRewindPoint(rewindPoint); + return arrowFunction; + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.tryParseArrowFunctionBlock = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { + return this.parseBlock(true, false); + } else { + return null; + } + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + token2 = this.peekToken(2); + if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { + if (this.isIdentifier(token2)) { + return true; + } + } + + if (!this.isIdentifier(token1)) { + return false; + } + + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { + if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(true); + } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + return this.eatKeyword(35 /* ThisKeyword */); + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameters = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); + + return typeParameterList; + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 39 /* TypeOfKeyword */: + + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + + case 70 /* OpenBraceToken */: + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + + case 31 /* NewKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + var type = this.parseNonArrayType(currentToken); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function (currentToken) { + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return this.eatAnyToken(); + + case 70 /* OpenBraceToken */: + return this.parseObjectType(); + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + return this.parseFunctionType(); + + case 31 /* NewKeyword */: + return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); + } + + return this.parseNameOrGenericType(); + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + var tokenKind = token.tokenKind; + if (tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { + if (this.isIdentifier(token)) { + var nextTokenKind = this.peekToken(1).tokenKind; + switch (nextTokenKind) { + case 73 /* CloseParenToken */: + case 106 /* ColonToken */: + case 107 /* EqualsToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { + modifierArray.push(this.eatAnyToken()); + continue; + } + + break; + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + 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; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType, inErrorRecovery); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + var currentToken = this.currentToken(); + if (this.isExpression(currentToken)) { + return true; + } + + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.parseStatement(inErrorRecovery); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(inErrorRecovery); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.inObjectLiteralExpression = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { + return true; + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { + if (parameter.modifiers.childCount() > 0) { + var modifiers = parameter.modifiers; + var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + + if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { + if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); + return true; + } else { + if (modifierIndex > 0) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + 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.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; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.modifiers.childCount() > 0) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + 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; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + 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) { + 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; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + 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; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { + var getKeywordFullStart = this.childFullStart(node, getKeyword); + if (parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { + if (this.checkIndexMemberModifiers(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIndexMemberDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { + if (node.modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(node, node.modifiers); + this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { + var savedInObjectLiteralExpression = this.inObjectLiteralExpression; + this.inObjectLiteralExpression = true; + _super.prototype.visitObjectLiteralExpression.call(this, node); + this.inObjectLiteralExpression = savedInObjectLiteralExpression; + }; + + GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { + var setKeywordFullStart = this.childFullStart(node, setKeyword); + if (parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); + var parameter = parameterList.parameters.childAt(0); + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + 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 && previousValueWasComputed) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (node.stringLiteral === null) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { + this.skip(node); + return; + } + + _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); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock || this.inObjectLiteralExpression) { + if (modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { + this.skip(node); + return; + } + + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { + var currentElementFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var child = modifiers.childAt(i); + if (child.kind() !== 57 /* PublicKeyword */) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); + return true; + } + + currentElementFullStart += child.fullWidth(); + } + + 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); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Document = (function () { + function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { + this._compiler = _compiler; + this._semanticInfoChain = _semanticInfoChain; + this.fileName = fileName; + this.referencedFiles = referencedFiles; + this._scriptSnapshot = _scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._syntaxTree = _syntaxTree; + this._topLevelDecl = _topLevelDecl; + this._diagnostics = null; + this._bloomFilter = null; + this._sourceUnit = null; + this._lineMap = null; + this._declASTMap = []; + this._astDeclMap = []; + this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; + } + Document.prototype.invalidate = function () { + this._declASTMap.length = 0; + this._astDeclMap.length = 0; + this._topLevelDecl = null; + + this._syntaxTree = null; + this._sourceUnit = null; + this._diagnostics = null; + this._bloomFilter = null; + }; + + Document.prototype.isDeclareFile = function () { + return TypeScript.isDTSFile(this.fileName); + }; + + Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + + this._lineMap = syntaxTree.lineMap(); + + var sourceUnit = syntaxTree.sourceUnit(); + var leadingTrivia = sourceUnit.leadingTrivia(); + + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); + + var amdDependencies = []; + 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); + } + } + } + + this._amdDependencies = amdDependencies; + }; + + Document.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(trivia.fullText()); + + if (match) { + return new TypeScript.TextSpan(position, trivia.fullWidth()); + } + + return null; + }; + + 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); + } + } + + position += moduleElement.fullWidth(); + } + + return null; + ; + }; + + Document.prototype.sourceUnit = function () { + if (!this._sourceUnit) { + var start = new Date().getTime(); + var syntaxTree = this.syntaxTree(); + this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + + if (!this.isOpen) { + this._syntaxTree = null; + } + } + + return this._sourceUnit; + }; + + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._diagnostics); + } + + return this._diagnostics; + }; + + Document.prototype.lineMap = function () { + if (this._lineMap === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._lineMap); + } + + return this._lineMap; + }; + + Document.prototype.isExternalModule = function () { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); + } + + return this._externalModuleIndicatorSpan; + }; + + Document.prototype.amdDependencies = function () { + if (this._amdDependencies === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._amdDependencies !== undefined); + } + + return this._amdDependencies; + }; + + Document.prototype.syntaxTree = function () { + var result = this._syntaxTree; + if (!result) { + var start = new Date().getTime(); + + result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); + + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + if (this.isOpen || !this._sourceUnit) { + this._syntaxTree = result; + } + } + + this.cacheSyntaxTreeInfo(result); + return result; + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = TypeScript.createIntrinsicsObject(); + var pre = function (cur) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { + if (cur.kind() === 11 /* IdentifierName */) { + var nodeText = cur.valueText(); + + identifiers[nodeText] = true; + } + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.emitToOwnOutputFile = function () { + return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { + var oldSyntaxTree = this._syntaxTree; + + if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { + var oldText = this._scriptSnapshot; + var newText = scriptSnapshot; + + TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); + var newTextPrefix = newText.getText(0, textChangeRange.span().start()); + TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); + + var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); + var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); + TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); + }; + + Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); + }; + + Document.prototype.topLevelDecl = function () { + if (this._topLevelDecl === null) { + this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); + } + + return this._topLevelDecl; + }; + + Document.prototype._getDeclForAST = function (ast) { + this.topLevelDecl(); + return this._astDeclMap[ast.syntaxID()]; + }; + + Document.prototype.getEnclosingDecl = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + return this._getDeclForAST(ast); + } + + ast = ast.parent; + var decl = null; + while (ast) { + decl = this._getDeclForAST(ast); + + if (decl) { + break; + } + + ast = ast.parent; + } + + return decl._getEnclosingDeclFromParentDecl(); + }; + + Document.prototype._setDeclForAST = function (ast, decl) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._astDeclMap[ast.syntaxID()] = decl; + }; + + Document.prototype._getASTForDecl = function (decl) { + return this._declASTMap[decl.declID]; + }; + + Document.prototype._setASTForDecl = function (decl, ast) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._declASTMap[decl.declID] = ast; + }; + return Document; + })(); + TypeScript.Document = Document; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var proto = "__proto__"; + + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + + this[proto] = null; + this[proto] = undefined; + } + return BlockIntrinsics; + })(); + + function createIntrinsicsObject() { + return new BlockIntrinsics(); + } + TypeScript.createIntrinsicsObject = createIntrinsicsObject; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = createIntrinsicsObject(); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (!fn(k, this.table[k], context)) { + return false; + } + } + } + + return true; + }; + + StringHashTable.prototype.some = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (fn(k, this.table[k], context)) { + return true; + } + } + } + + return false; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + + StringHashTable.prototype.remove = function (key) { + if (this.table[key] !== undefined) { + this.table[key] = undefined; + this.itemCount--; + } + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (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); + } + ASTHelpers.moduleIsElided = moduleIsElided; + + 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)) { + 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; + } + ASTHelpers.enumIsElided = enumIsElided; + + function isValidAstNode(ast) { + if (!ast) + return false; + + if (ast.start() === -1 || ast.end() === -1) + return false; + + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; + + 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; + + 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) { + top = cur; + } + } + } + } + + 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; + } + } + + return false; + } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; + + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } + + 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); + } + 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; + } + + current = current.parent; + } + 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; + } + + return null; + } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; + + 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; + } + 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; + + function parametersFromIdentifier(id) { + return { + length: 1, + lastParameterIsRest: function () { + return false; + }, + ast: id, + astAt: function (index) { + return id; + }, + identifierAt: function (index) { + return id; + }, + typeAt: function (index) { + return null; + }, + initializerAt: function (index) { + return null; + }, + isOptionalAt: function (index) { + return false; + } + }; + } + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; + + function parametersFromParameter(parameter) { + return { + length: 1, + lastParameterIsRest: function () { + return parameter.dotDotDotToken !== null; + }, + ast: parameter, + astAt: function (index) { + return parameter; + }, + identifierAt: function (index) { + return parameter.identifier; + }, + typeAt: function (index) { + return getType(parameter); + }, + initializerAt: function (index) { + return parameter.equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(parameter); + } + }; + } + ASTHelpers.parametersFromParameter = parametersFromParameter; + + function parameterIsOptional(parameter) { + return parameter.questionToken !== null || parameter.equalsValueClause !== null; + } + + function parametersFromParameterList(list) { + return { + length: list.parameters.nonSeparatorCount(), + lastParameterIsRest: function () { + return TypeScript.lastParameterIsRest(list); + }, + ast: list.parameters, + astAt: function (index) { + return list.parameters.nonSeparatorAt(index); + }, + identifierAt: function (index) { + return list.parameters.nonSeparatorAt(index).identifier; + }, + typeAt: function (index) { + return getType(list.parameters.nonSeparatorAt(index)); + }, + initializerAt: function (index) { + return list.parameters.nonSeparatorAt(index).equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(list.parameters.nonSeparatorAt(index)); + } + }; + } + ASTHelpers.parametersFromParameterList = parametersFromParameterList; + + 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; + } + } + ASTHelpers.isDeclarationAST = isDeclarationAST; + + 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; + } + + 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; + } + + ast = ast.parent; + } + + return null; + } + ASTHelpers.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); + + 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 { + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); + } + } + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function walkListChildren(preAst, walker) { + for (var i = 0, n = preAst.childCount(); i < n; i++) { + walker.walk(preAst.childAt(i)); + } + } + + function walkThrowStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkPrefixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkPostfixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkDeleteExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkTypeArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArguments); + } + + function walkTypeOfExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkVoidExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArgumentList); + walker.walk(preAst.arguments); + } + + function walkArrayLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.expressions); + } + + function walkSimplePropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.expression); + } + + function walkFunctionPropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkGetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkSeparatedListChildren(preAst, walker) { + for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { + walker.walk(preAst.nonSeparatorAt(i)); + } + } + + function walkSetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.block); + } + + function walkObjectLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.propertyAssignments); + } + + function walkCastExpressionChildren(preAst, walker) { + walker.walk(preAst.type); + walker.walk(preAst.expression); + } + + function walkParenthesizedExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkElementAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentExpression); + } + + function walkMemberAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.name); + } + + function walkQualifiedNameChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkBinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkEqualsValueClauseChildren(preAst, walker) { + walker.walk(preAst.value); + } + + function walkTypeParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.constraint); + } + + function walkTypeParameterListChildren(preAst, walker) { + walker.walk(preAst.typeParameters); + } + + function walkGenericTypeChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.typeArgumentList); + } + + function walkTypeAnnotationChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkTypeQueryChildren(preAst, walker) { + walker.walk(preAst.name); + } + + function walkInvocationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkObjectCreationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkTrinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.whenTrue); + walker.walk(preAst.whenFalse); + } + + function walkFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFunctionTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkMemberFunctionDeclarationChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFuncDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkIndexMemberDeclarationChildren(preAst, walker) { + walker.walk(preAst.indexSignature); + } + + function walkIndexSignatureChildren(preAst, walker) { + walker.walk(preAst.parameter); + walker.walk(preAst.typeAnnotation); + } + + function walkCallSignatureChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + } + + function walkConstraintChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkConstructorDeclarationChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkConstructorTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkConstructSignatureChildren(preAst, walker) { + walker.walk(preAst.callSignature); + } + + function walkParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkParameterListChildren(preAst, walker) { + walker.walk(preAst.parameters); + } + + function walkPropertySignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + } + + function walkVariableDeclaratorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkMemberVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.variableDeclarator); + } + + function walkMethodSignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + } + + function walkReturnStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkForStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.initializer); + walker.walk(preAst.condition); + walker.walk(preAst.incrementor); + walker.walk(preAst.statement); + } + + function walkForInStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.left); + walker.walk(preAst.expression); + walker.walk(preAst.statement); + } + + function walkIfStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + walker.walk(preAst.elseClause); + } + + function walkElseClauseChildren(preAst, walker) { + walker.walk(preAst.statement); + } + + function walkWhileStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkDoStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkBlockChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.declarators); + } + + function walkCaseSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.statements); + } + + function walkDefaultSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkSwitchStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.switchClauses); + } + + function walkTryStatementChildren(preAst, walker) { + walker.walk(preAst.block); + walker.walk(preAst.catchClause); + walker.walk(preAst.finallyClause); + } + + function walkCatchClauseChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkExternalModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.stringLiteral); + } + + function walkFinallyClauseChildren(preAst, walker) { + walker.walk(preAst.block); + } + + function walkClassDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.classElements); + } + + function walkScriptChildren(preAst, walker) { + walker.walk(preAst.moduleElements); + } + + function walkHeritageClauseChildren(preAst, walker) { + walker.walk(preAst.typeNames); + } + + function walkInterfaceDeclerationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.body); + } + + function walkObjectTypeChildren(preAst, walker) { + walker.walk(preAst.typeMembers); + } + + function walkArrayTypeChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkModuleDeclarationChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.stringLiteral); + walker.walk(preAst.moduleElements); + } + + function walkModuleNameModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.moduleName); + } + + function walkEnumDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.enumElements); + } + + function walkEnumElementChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.equalsValueClause); + } + + function walkImportDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.moduleReference); + } + + function walkExportAssignmentChildren(preAst, walker) { + walker.walk(preAst.identifier); + } + + function walkWithStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkExpressionStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkLabeledStatementChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.statement); + } + + function walkVariableStatementChildren(preAst, walker) { + walker.walk(preAst.declaration); + } + + var childrenWalkers = new Array(246 /* Last */ + 1); + + for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { + childrenWalkers[i] = null; + } + for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { + childrenWalkers[i] = null; + } + + childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; + childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[60 /* AnyKeyword */] = null; + childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; + childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; + childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; + childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; + childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; + childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[146 /* Block */] = walkBlockChildren; + childrenWalkers[61 /* BooleanKeyword */] = null; + childrenWalkers[152 /* BreakStatement */] = null; + childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; + childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; + childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; + childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; + childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; + childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; + childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; + childrenWalkers[239 /* Constraint */] = walkConstraintChildren; + childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; + childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; + childrenWalkers[153 /* ContinueStatement */] = null; + childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; + childrenWalkers[162 /* DebuggerStatement */] = null; + childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; + childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; + childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; + childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; + childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; + childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; + childrenWalkers[156 /* EmptyStatement */] = null; + childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; + childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; + childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; + childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; + childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; + childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; + childrenWalkers[24 /* FalseKeyword */] = null; + childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; + childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; + childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; + childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; + childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; + childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; + childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; + childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; + childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; + childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; + childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; + childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; + childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; + childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; + childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; + childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; + childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; + childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; + childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[1 /* List */] = walkListChildren; + childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; + childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; + childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; + childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; + childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; + childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; + childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; + childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; + childrenWalkers[11 /* IdentifierName */] = null; + childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[0 /* None */] = null; + childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[32 /* NullKeyword */] = null; + childrenWalkers[67 /* NumberKeyword */] = null; + childrenWalkers[13 /* NumericLiteral */] = null; + childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; + childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; + childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; + childrenWalkers[223 /* OmittedExpression */] = null; + childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[242 /* Parameter */] = walkParameterChildren; + childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; + childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; + childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; + childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; + childrenWalkers[12 /* RegularExpressionLiteral */] = null; + childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; + childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; + childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; + childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; + childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; + childrenWalkers[14 /* StringLiteral */] = null; + childrenWalkers[69 /* StringKeyword */] = null; + childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; + childrenWalkers[50 /* SuperKeyword */] = null; + childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; + childrenWalkers[35 /* ThisKeyword */] = null; + childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; + childrenWalkers[3 /* TriviaList */] = null; + childrenWalkers[37 /* TrueKeyword */] = null; + childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; + childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; + childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; + childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; + childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; + childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; + childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; + childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; + childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; + childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; + childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; + childrenWalkers[41 /* VoidKeyword */] = null; + childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; + childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; + + for (var e in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { + TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); + } + } + + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + this.stopWalking = false; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var SimplePreAstWalker = (function () { + function SimplePreAstWalker(pre, state) { + this.pre = pre; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePreAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + }; + return SimplePreAstWalker; + })(); + + var SimplePrePostAstWalker = (function () { + function SimplePrePostAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePrePostAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + + this.post(ast, this.state); + }; + return SimplePrePostAstWalker; + })(); + + var NormalAstWalker = (function () { + function NormalAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + NormalAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + if (this.options.stopWalking) { + return; + } + + this.pre(ast, this); + + if (this.options.stopWalking) { + return; + } + + if (this.options.goChildren) { + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + } else { + this.options.goChildren = true; + } + + if (this.post) { + this.post(ast, this); + } + }; + return NormalAstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { + new NormalAstWalker(pre, post, state).walk(ast); + }; + + AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { + if (post) { + new SimplePrePostAstWalker(pre, post, state).walk(ast); + } else { + new SimplePreAstWalker(pre, state).walk(ast); + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory = new AstWalkerFactory(); + + function getAstWalkerFactory() { + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapEntry = (function () { + function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { + this.emittedFile = emittedFile; + this.emittedLine = emittedLine; + this.emittedColumn = emittedColumn; + this.sourceFile = sourceFile; + this.sourceLine = sourceLine; + this.sourceColumn = sourceColumn; + this.sourceName = sourceName; + TypeScript.Debug.assert(isFinite(emittedLine)); + TypeScript.Debug.assert(isFinite(emittedColumn)); + TypeScript.Debug.assert(isFinite(sourceColumn)); + TypeScript.Debug.assert(isFinite(sourceLine)); + } + return SourceMapEntry; + })(); + TypeScript.SourceMapEntry = SourceMapEntry; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.names = []; + this.mappingLevel = []; + this.tsFilePaths = []; + this.allSourceMappings = []; + this.sourceMapEntries = []; + this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); + this.setNewSourceFile(document, emitOptions); + } + SourceMapper.prototype.getOutputFile = function () { + var result = this.sourceMapOut.getOutputFile(); + result.sourceMapEntries = this.sourceMapEntries; + + return result; + }; + + SourceMapper.prototype.increaseMappingLevel = function (ast) { + this.mappingLevel.push(ast); + }; + + SourceMapper.prototype.decreaseMappingLevel = function (ast) { + TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); + var expectedAst = this.mappingLevel.pop(); + var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; + var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; + TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); + }; + + SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { + var sourceMappings = []; + this.allSourceMappings.push(sourceMappings); + this.currentMappings = [sourceMappings]; + this.currentNameIndex = []; + + this.setNewSourceFilePath(document, emitOptions); + }; + + SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; + this.jsFileName = prettyJsFileName; + + if (emitOptions.sourceMapRootDirectory()) { + this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); + if (document.emitToOwnOutputFile()) { + this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); + } + + if (TypeScript.isRelative(this.sourceMapDirectory)) { + this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; + this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); + this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); + } else { + this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; + } + } else { + this.sourceMapPath = prettyMapFileName; + this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + this.sourceRoot = emitOptions.sourceRootDirectory(); + }; + + SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + if (emitOptions.sourceRootDirectory()) { + tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); + } else { + tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); + } + this.tsFilePaths.push(tsFilePath); + }; + + SourceMapper.prototype.emitSourceMapping = function () { + var _this = this; + TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { + return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); + }).join(', ')); + + this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); + + var mappingsString = ""; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); + prevSourceIndex = sourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); + prevNameIndex = nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + for (var i = 0; i < sourceMappings.length; i++) { + var sourceMapping = sourceMappings[i]; + recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); + recordSourceMappingSiblings(sourceMapping.childMappings); + recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); + } + }; + + recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); + } + + this.sourceMapOut.Write(JSON.stringify({ + version: 3, + file: this.jsFileName, + sourceRoot: this.sourceRoot, + sources: this.tsFilePaths, + names: this.names, + mappings: mappingsString + })); + + this.sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compiler, resolvePath) { + this.resolvePath = resolvePath; + this._diagnostic = null; + this._settings = null; + this._commonDirectoryPath = ""; + this._sharedOutputFile = ""; + this._sourceRootDirectory = ""; + this._sourceMapRootDirectory = ""; + this._outputDirectory = ""; + var settings = compiler.compilationSettings(); + this._settings = settings; + + 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()) { + if (settings.mapRoot()) { + if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } else { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } else if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } + + this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); + this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); + + if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { + if (settings.outFileOption()) { + this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); + } + + if (settings.outDirOption()) { + this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); + } + + if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { + this.determineCommonDirectoryPath(compiler); + } + } + } + EmitOptions.prototype.diagnostic = function () { + return this._diagnostic; + }; + + EmitOptions.prototype.commonDirectoryPath = function () { + return this._commonDirectoryPath; + }; + EmitOptions.prototype.sharedOutputFile = function () { + return this._sharedOutputFile; + }; + EmitOptions.prototype.sourceRootDirectory = function () { + return this._sourceRootDirectory; + }; + EmitOptions.prototype.sourceMapRootDirectory = function () { + return this._sourceMapRootDirectory; + }; + EmitOptions.prototype.outputDirectory = function () { + return this._outputDirectory; + }; + + EmitOptions.prototype.compilationSettings = function () { + return this._settings; + }; + + EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = compiler.fileNames(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = compiler.getDocument(fileNames[i]); + var sourceUnit = document.sourceUnit(); + + if (!document.isDeclareFile()) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + 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; + } + + return; + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + function lastParameterIsRest(parameterList) { + var parameters = parameterList.parameters; + return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; + } + TypeScript.lastParameterIsRest = lastParameterIsRest; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.inArrowFunction = false; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.declStack = []; + this.exportAssignment = null; + this.inWithBlock = false; + this.document = null; + this.detachedCommentsElement = null; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; + }; + + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.shouldEmitImportDeclaration = 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 */; + + 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 */; + + this.emitComments(importDeclAST, true); + + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + 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 */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + if (isAmdCodeGen && isExternalModuleReference) { + needsPropertyAssignment = true; + } else { + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.identifier.text() + " = "); + var aliasAST = importDeclAST.moduleReference; + + if (isExternalModuleReference) { + this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); + } else { + this.emitJavascript(aliasAST.moduleName, false); + } + + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + } + } + + if (needsPropertyAssignment) { + this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + }; + + Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { + this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); + }; + + Emitter.prototype.setSourceMapperNewSourceFile = function (document) { + this.sourceMapper.setNewSourceFile(document, this.emitOptions); + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { + this.recordSourceMappingStart(astSpan); + this.writeToOutput(s); + this.recordSourceMappingEnd(astSpan); + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeLineToOutput = function (s, force) { + if (typeof force === "undefined") { force = false; } + if (!force && s === "" && this.emitState.column === 0) { + return; + } + + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment, trailing, first) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var text = getTrimmedTextLines(comment); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } else if (trailing && first) { + this.writeToOutput(" "); + } + + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (!trailing && emitColumn !== 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { + 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; + } + } + + if (pre) { + var preComments = ast.preComments(); + + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; + } + + if (preComments && onlyPinnedOrTripleSlashComments) { + preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { + return _this.isPinnedOrTripleSlash(c); + }); + } + + this.emitCommentsArray(preComments, false); + } else { + this.emitCommentsArray(ast.postComments(), true); + } + }; + + Emitter.prototype.isPinnedOrTripleSlash = function (comment) { + var fullText = comment.fullText(); + if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { + return true; + } else { + return fullText.indexOf("/*!") === 0; + } + }; + + Emitter.prototype.emitCommentsArray = function (comments, trailing) { + if (!this.emitOptions.compilationSettings().removeComments() && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i], trailing, i === 0); + } + } + }; + + Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { + this.recordSourceMappingStart(objectLiteral); + + this.writeToOutput("{"); + this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); + this.writeToOutput("}"); + + this.recordSourceMappingEnd(objectLiteral); + }; + + Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { + this.recordSourceMappingStart(arrayLiteral); + + this.writeToOutput("["); + this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); + this.writeToOutput("]"); + + this.recordSourceMappingEnd(arrayLiteral); + }; + + Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { + this.recordSourceMappingStart(objectCreationExpression); + this.writeToOutput("new "); + var target = objectCreationExpression.expression; + + this.emit(target); + if (objectCreationExpression.argumentList) { + this.recordSourceMappingStart(objectCreationExpression.argumentList); + this.writeToOutput("("); + this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); + this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); + this.recordSourceMappingEnd(objectCreationExpression.argumentList); + } + + this.recordSourceMappingEnd(objectCreationExpression); + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); + if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + if (pullDecl.kind === 67108864 /* EnumMember */) { + return pullDecl; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + var propertyName = dotExpr.name; + var boundDecl = this.getConstantDecl(dotExpr); + if (boundDecl) { + var value = boundDecl.constantValue; + if (value !== null) { + this.recordSourceMappingStart(dotExpr); + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.text(); + comment += " */"; + this.writeToOutput(comment); + this.recordSourceMappingEnd(dotExpr); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitInvocationExpression = function (callNode) { + this.recordSourceMappingStart(callNode); + var target = callNode.expression; + var args = callNode.argumentList.arguments; + + if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { + this.emit(target); + this.writeToOutput(".call"); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitThis(); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + } else { + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + + this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); + this.recordSourceMappingEnd(args); + this.recordSourceMappingEnd(callNode); + }; + + Emitter.prototype.emitParameterList = function (list) { + this.writeToOutput("("); + this.emitCommentsArray(list.openParenTrailingComments, true); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); + this.writeToOutput(")"); + }; + + Emitter.prototype.emitFunctionParameters = function (parameters) { + var argsLen = 0; + + if (parameters) { + this.emitComments(parameters.ast, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = parameters.length; + var printLen = argsLen; + if (parameters.lastParameterIsRest()) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = parameters.astAt(i); + this.emit(arg); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(parameters.ast, false); + } + }; + + Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { + this.writeLineToOutput(" {"); + if (name) { + this.recordSourceMappingNameStart(name); + } + + this.indenter.increaseIndent(); + + 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); + } else { + this.emitIndent(); + this.emitCommentsArray(bodyExpression.preComments(), false); + this.writeToOutput("return "); + this.emit(bodyExpression); + this.writeLineToOutput(";"); + this.emitCommentsArray(bodyExpression.postComments(), true); + } + + this.indenter.decreaseIndent(); + this.emitIndent(); + + if (block) { + this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); + } else { + this.writeToOutputWithSourceMapRecord("}", bodyExpression); + } + + if (name) { + this.recordSourceMappingNameEnd(); + } + }; + + Emitter.prototype.emitDefaultValueAssignments = function (parameters) { + var n = parameters.length; + if (parameters.lastParameterIsRest()) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = parameters.astAt(i); + var id = parameters.identifierAt(i); + var equalsValueClause = parameters.initializerAt(i); + if (equalsValueClause) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.emitJavascript(equalsValueClause, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (parameters) { + if (parameters.lastParameterIsRest()) { + var n = parameters.length; + var lastArg = parameters.astAt(n - 1); + var id = parameters.identifierAt(n - 1); + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); + this.writeToOutput(" "); + this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); + this.writeToOutput("; "); + this.writeToOutputWithSourceMapRecord("_i++", lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + var result = []; + + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + var queue = dynamicModuleDecl.getChildDecls(); + + for (var i = 0, n = queue.length; i < n; i++) { + var decl = queue[i]; + + if (decl.kind & 128 /* TypeAlias */) { + var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { + var importList = ""; + var dependencyList = ""; + + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue()) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += importStatementDecl.name; + dependencyList += importStatementAST.moduleReference.stringLiteral.text(); + } + } + } + + var amdDependencies = this.document.amdDependencies(); + for (var i = 0; i < amdDependencies.length; i++) { + dependencyList += ", \"" + amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); + } + + var decl = this.semanticInfoChain.getDeclForAST(ast); + if (decl) { + return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); + } + + return false; + }; + + Emitter.prototype.emitEnum = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.identifier.text(); + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.identifier); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(this.moduleName); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitSeparatedList(moduleDecl.enumElements); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { + return moduleDecl; + } else if (changeNameIfAnyDeclarationInContext) { + var symbol = moduleDecl.getSymbol(); + if (symbol) { + var otherDecls = symbol.getDeclarations(); + for (var i = 0; i < otherDecls.length; i++) { + if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { + return otherDecls[i]; + } + } + } + } + + return null; + }; + + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { + var _this = this; + var childDecls = parentDecl.getChildDecls(); + return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { + 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; + } + } + return false; + }); + }; + + Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + var moduleName = moduleDecl.name; + var moduleDisplayName = moduleDecl.getDisplayName(); + + moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { + moduleName = "_" + moduleName; + moduleDisplayName = "_" + moduleDisplayName; + } + } + + return moduleDisplayName; + }; + + Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { + if (moduleDecl.stringLiteral) { + this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); + } + }; + + Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); + + if (isLastName) { + this.emitComments(moduleDecl, true); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + + if (moduleDecl.stringLiteral) { + this.moduleName = moduleDecl.stringLiteral.valueText(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + } else { + this.moduleName = moduleName.text(); + } + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleName); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleName); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + + this.moduleName = this.getModuleName(pullDecl); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(moduleName.text()); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + if (moduleName === moduleDecl.stringLiteral) { + this.emitList(moduleDecl.moduleElements); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + var nameIndex = moduleNames.indexOf(moduleName); + TypeScript.Debug.assert(nameIndex >= 0); + + if (isLastName) { + this.emitList(moduleDecl.moduleElements); + } else { + this.emitIndent(); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); + this.writeLineToOutput(""); + } + } + + this.moduleName = moduleName.text(); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + + if (isLastName) { + this.emitComments(moduleDecl, false); + } + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.propertyName.text(); + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput(']'); + + if (varDecl.equalsValueClause) { + this.emit(varDecl.equalsValueClause); + } else if (pullDecl.constantValue !== null) { + this.writeToOutput(' = '); + this.writeToOutput(pullDecl.constantValue.toString()); + } else { + this.writeToOutput(' = null'); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitElementAccessExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("["); + this.emit(expression.argumentExpression); + this.writeToOutput("]"); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = true; + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(arrowFunction); + + var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); + this.pushDecl(pullDecl); + + this.emitComments(arrowFunction, true); + + this.recordSourceMappingStart(arrowFunction); + this.writeToOutput("function "); + this.writeToOutput("("); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); + + this.recordSourceMappingEnd(arrowFunction); + + this.recordSourceMappingEnd(arrowFunction); + + this.emitComments(arrowFunction, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConstructor = function (funcDecl) { + if (!funcDecl.block) { + return; + } + var temp = this.setContainer(4 /* Constructor */); + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + this.writeToOutput(this.thisClassNode.identifier.text()); + this.writeToOutput("("); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart("constructor"); + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(parameters); + this.emitRestParameterInitializer(parameters); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + this.emitConstructorStatements(funcDecl); + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + }; + + Emitter.prototype.emitGetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("get "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitSetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("set "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitFunctionExpression = function (funcDecl) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + this.writeToOutput(funcDecl.identifier.text()); + this.recordSourceMappingEnd(funcDecl.identifier); + } + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (funcDecl.block === null) { + return; + } + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier.text(); + + this.recordSourceMappingStart(funcDecl); + + var printName = funcDecl.identifier !== null; + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (printName) { + var id = funcDecl.identifier.text(); + if (id) { + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + } + this.writeToOutput(id); + if (funcDecl.identifier) { + this.recordSourceMappingEnd(funcDecl.identifier); + } + } + } + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + + if (funcDecl.block) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + this.recordSourceMappingStart(this.currentVariableDeclaration); + if (varDecl.equalsValueClause) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + this.emitJavascript(varDecl.equalsValueClause, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.currentVariableDeclaration) { + this.writeToOutput("var "); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + + this.emitComments(declaration, true); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; + if (!isAmbientWithoutInit) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.currentVariableDeclaration = declaration; + + for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { + var declarator = declaration.declarators.nonSeparatorAt(i); + + if (i > 0) { + this.writeToOutput(", "); + } + + this.emit(declarator); + } + this.currentVariableDeclaration = prevVariableDeclaration; + + this.recordSourceMappingEnd(declaration); + } + + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { + TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); + + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + + if (quotedOrNumber) { + this.writeToOutput("this["); + } else { + this.writeToOutput("this."); + } + + this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); + + if (quotedOrNumber) { + this.writeToOutput("]"); + } + + if (varDecl.variableDeclarator.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.variableDeclarator.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(this.currentVariableDeclaration); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.propertyName.text(); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); + + if (parentIsModule) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + + if (varDecl.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.currentVariableDeclaration = undefined; + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { + var decl = pullSymbol.getDeclarations()[0]; + var parentDecl = decl.getParentDecl(); + var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; + + var enclosingContextDeclPath = this.declStack; + var commonNodeIndex = -1; + + if (enclosingContextDeclPath.length) { + for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { + var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; + for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { + var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; + if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { + commonNodeIndex = i; + break; + } + } + + if (commonNodeIndex >= 0) { + break; + } + } + } + + var startingIndex = symbolContainerDeclPath.length - 1; + for (var i = startingIndex - 1; i > commonNodeIndex; i--) { + if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { + startingIndex = i; + } else { + break; + } + } + return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; + }; + + Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { + for (var i = startingIndex; i <= lastIndex; i++) { + if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.getModuleName(declPath[i], true) + "."); + } + } + }; + + Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { + var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); + var potentialDeclPath = declPathInfo.potentialPath; + var startingIndex = declPathInfo.startingIndex; + + this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); + }; + + Emitter.prototype.getSymbolForEmit = function (ast) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol === symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (name.text().length > 0) { + var symbolForEmit = this.getSymbolForEmit(name); + var pullSymbol = symbolForEmit.symbol; + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = symbolForEmit.aliasSymbol; + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } + } + } + + this.writeToOutput(name.text()); + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var nameIndex = -1; + if (name) { + if (this.sourceMapper.currentNameIndex.length > 0) { + var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { + break; + } + } + + if (nameIndex === -1) { + nameIndex = this.sourceMapper.names.length; + this.sourceMapper.names.push(name); + } + } + this.sourceMapper.currentNameIndex.push(nameIndex); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (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; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap(); + lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); + + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + this.sourceMapper.increaseMappingLevel(ast); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); + + this.sourceMapper.decreaseMappingLevel(ast); + } + }; + + Emitter.prototype.getOutputFiles = function () { + var result = []; + if (this.sourceMapper !== null) { + this.sourceMapper.emitSourceMapping(); + result.push(this.sourceMapper.getOutputFile()); + } + + result.push(this.outfile.getOutputFile()); + return result; + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = getLastConstructor(this.thisClassNode); + + 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(); + this.recordSourceMappingStart(parameter); + this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); + this.writeToOutput(" = "); + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(parameter); + } + } + } + + for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { + if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = this.thisClassNode.classElements.childAt(i); + if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitIndent(); + this.emitMemberVariableDeclaration(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.isOnSameLine = function (pos1, pos2) { + var lineMap = this.document.lineMap(); + return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); + }; + + Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { + if (list === null || list.nonSeparatorCount() === 0) { + return; + } + + var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); + + if (preserveNewLines) { + this.indenter.increaseIndent(); + } + + if (startLine) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(buffer); + } + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + var emitNode = list.nonSeparatorAt(i); + + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); + if (startLine) { + this.writeLineToOutput(","); + } else { + this.writeToOutput(", "); + } + } + } + + if (preserveNewLines) { + this.indenter.decreaseIndent(); + } + + if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(buffer); + } + }; + + Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.nonSeparatorAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.kind() === 14 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { + return; + } + + var lineMap = this.document.lineMap(); + var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput("", true); + } + }; + + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); + if (preComments) { + var lineMap = this.document.lineMap(); + + var detachedComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); + var commentLine = lineMap.getLineNumberFromPosition(comment.start()); + + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + detachedComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); + if (astLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { + if (list.childCount() > 0) { + var firstElement = list.childAt(0); + + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); + } + }; + + Emitter.prototype.emitScriptElements = function (sourceUnit) { + var list = sourceUnit.moduleElements; + + this.emitPossibleCopyrightHeaders(sourceUnit); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var node = list.childAt(i); + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(sourceUnit); + + var isExternalModule = this.document.isExternalModule(); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); + if (isNonElidedExternalModule) { + this.recordSourceMappingStart(sourceUnit); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } + + if (isExternalModule) { + var temp = this.setContainer(2 /* DynamicModule */); + + var svModuleName = this.moduleName; + this.moduleName = sourceUnit.fileName(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + this.setExportAssignment(null); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); + + if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { + this.writeCaptureThisStatement(sourceUnit); + } + + this.pushDecl(externalModule); + } + + this.emitList(list, true, i, n); + + if (isExternalModule) { + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + + if (isNonElidedExternalModule) { + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; + var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(sourceUnit); + this.writeLineToOutput(""); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + this.popDecl(externalModule); + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + this.emit(ast); + }; + + Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { + if (funcDecl.kind() !== 139 /* GetAccessor */) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + + this.writeToOutput("Object.defineProperty(" + className); + if (isProto) { + this.writeToOutput(".prototype, "); + } else { + this.writeToOutput(", "); + } + + var functionName = name.text(); + if (TypeScript.isQuoted(functionName)) { + this.writeToOutput(functionName); + } else { + this.writeToOutput('"' + functionName + '"'); + } + + this.writeLineToOutput(", {"); + + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.emitComments(accessors.getter, true); + this.writeToOutput("get: "); + this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.emitComments(accessors.setter, true); + this.writeToOutput("set: "); + this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.identifier.text(); + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var baseTypeReference = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); + } + + this.emitIndent(); + + var constrDecl = getLastConstructor(classDecl); + + if (constrDecl) { + this.emit(constrDecl); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.emitJavascript(baseTypeReference, false); + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 139 /* GetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var getter = memberDecl; + this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 140 /* SetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var setter = memberDecl; + this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { + var memberFunction = memberDecl; + + if (memberFunction.block) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + + this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); + lastEmittedMember = memberDecl; + } + } + } + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = memberDecl; + + if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); + } else { + this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); + } + + this.emit(varDecl.variableDeclarator.equalsValueClause); + + this.recordSourceMappingEnd(varDecl); + this.writeLineToOutput(";"); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + var functionName = funcDecl.propertyName.text(); + + this.writeToOutput(classDecl.identifier.text()); + + if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + this.writeToOutput(".prototype"); + } + + if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput("[" + functionName + "] = "); + } else { + this.writeToOutput("." + functionName + " = "); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + + this.writeLineToOutput(";"); + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + + if (moduleElement.kind() === 130 /* ModuleDeclaration */) { + var moduleAST = moduleElement; + + if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { + return true; + } + } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (sourceUnit) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(sourceUnit)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitThis = function () { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.kind() === 146 /* Block */) { + this.emit(node); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitLiteralExpression = function (expression) { + switch (expression.kind()) { + case 32 /* NullKeyword */: + this.writeToOutputWithSourceMapRecord("null", expression); + break; + case 24 /* FalseKeyword */: + this.writeToOutputWithSourceMapRecord("false", expression); + break; + case 37 /* TrueKeyword */: + this.writeToOutputWithSourceMapRecord("true", expression); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + Emitter.prototype.emitThisExpression = function (expression) { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutputWithSourceMapRecord("_this", expression); + } else { + this.writeToOutputWithSourceMapRecord("this", expression); + } + }; + + Emitter.prototype.emitSuperExpression = function (expression) { + this.writeToOutputWithSourceMapRecord("_super.prototype", expression); + }; + + Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { + if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { + this.emit(parenthesizedExpression.expression); + } else { + this.recordSourceMappingStart(parenthesizedExpression); + this.writeToOutput("("); + this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); + this.emit(parenthesizedExpression.expression); + this.writeToOutput(")"); + this.recordSourceMappingEnd(parenthesizedExpression); + } + }; + + Emitter.prototype.emitCastExpression = function (expression) { + this.emit(expression.expression); + }; + + Emitter.prototype.emitPrefixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 167 /* LogicalNotExpression */: + this.writeToOutput("!"); + this.emit(expression.operand); + break; + case 166 /* BitwiseNotExpression */: + this.writeToOutput("~"); + this.emit(expression.operand); + break; + case 165 /* NegateExpression */: + this.writeToOutput("-"); + if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 164 /* PlusExpression */: + this.writeToOutput("+"); + if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 168 /* PreIncrementExpression */: + this.writeToOutput("++"); + this.emit(expression.operand); + break; + case 169 /* PreDecrementExpression */: + this.writeToOutput("--"); + this.emit(expression.operand); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitPostfixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 210 /* PostIncrementExpression */: + this.emit(expression.operand); + this.writeToOutput("++"); + break; + case 211 /* PostDecrementExpression */: + this.emit(expression.operand); + this.writeToOutput("--"); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitTypeOfExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("typeof "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDeleteExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("delete "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitVoidExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("void "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { + var memberExpressionNodeType = expression.expression.kind(); + + 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 */) { + return this.canEmitDottedNameMemberAccessExpression(expression.expression); + } + + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { + this.recordSourceMappingStart(expression); + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { + this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); + } else { + this.emitComments(expression.expression, true); + this.recordSourceMappingStart(expression.expression); + + this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); + + this.writeToOutput(expression.expression.text()); + + this.recordSourceMappingEnd(expression.expression); + this.emitComments(expression.expression, false); + } + + this.writeToOutput("."); + this.emitName(expression.name, false); + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { + this.emitComments(expression, true); + + if (lastIndex - startingIndex < 1) { + startingIndex = lastIndex - 1; + TypeScript.Debug.assert(startingIndex >= 0); + } + + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); + this.emitComments(expression, false); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { + var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; + + var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); + }; + + Emitter.prototype.emitMemberAccessExpression = function (expression) { + if (!this.tryEmitConstant(expression)) { + if (this.canEmitDottedNameMemberAccessExpression(expression)) { + this.emitDottedNameMemberAccessExpression(expression); + } else { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("."); + this.emitName(expression.name, false); + this.recordSourceMappingEnd(expression); + } + } + }; + + Emitter.prototype.emitQualifiedName = function (name) { + this.recordSourceMappingStart(name); + + this.emit(name.left); + this.writeToOutput("."); + this.emitName(name.right, false); + + this.recordSourceMappingEnd(name); + }; + + Emitter.prototype.emitBinaryExpression = function (expression) { + this.recordSourceMappingStart(expression); + switch (expression.kind()) { + case 173 /* CommaExpression */: + this.emit(expression.left); + this.writeToOutput(", "); + this.emit(expression.right); + break; + default: { + this.emit(expression.left); + var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); + if (binOp === "instanceof") { + this.writeToOutput(" instanceof "); + } else if (binOp === "in") { + this.writeToOutput(" in "); + } else { + this.writeToOutput(" " + binOp + " "); + } + this.emit(expression.right); + } + } + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimplePropertyAssignment = function (property) { + this.recordSourceMappingStart(property); + this.emit(property.propertyName); + this.writeToOutput(": "); + this.emit(property.expression); + this.recordSourceMappingEnd(property); + }; + + Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { + this.recordSourceMappingStart(funcProp); + + this.emit(funcProp.propertyName); + this.writeToOutput(": "); + + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); + + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + var funcName = funcProp.propertyName; + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcProp); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); + + this.recordSourceMappingEnd(funcProp); + + this.recordSourceMappingEnd(funcProp); + + this.emitComments(funcProp, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConditionalExpression = function (expression) { + this.emit(expression.condition); + this.writeToOutput(" ? "); + this.emit(expression.whenTrue); + this.writeToOutput(" : "); + this.emit(expression.whenFalse); + }; + + Emitter.prototype.emitThrowStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("throw "); + this.emit(statement.expression); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitExpressionStatement = function (statement) { + var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; + + this.recordSourceMappingStart(statement); + if (isArrowExpression) { + this.writeToOutput("("); + } + + this.emit(statement.expression); + + if (isArrowExpression) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitLabeledStatement = function (statement) { + this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); + this.writeLineToOutput(":"); + this.emitJavascript(statement.statement, true); + }; + + Emitter.prototype.emitBlock = function (block) { + this.recordSourceMappingStart(block); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + if (block.statements) { + this.emitList(block.statements); + } + this.emitCommentsArray(block.closeBraceLeadingComments, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(block); + }; + + Emitter.prototype.emitBreakStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("break"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitContinueStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("continue"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitWhileStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("while ("); + this.emit(statement.condition); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitDoStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("do"); + this.emitBlockOrStatement(statement.statement); + this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); + this.writeToOutput('('); + this.emit(statement.condition); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitIfStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("if ("); + this.emit(statement.condition); + this.writeToOutput(")"); + + this.emitBlockOrStatement(statement.statement); + + if (statement.elseClause) { + if (statement.statement.kind() !== 146 /* Block */) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + + this.emit(statement.elseClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitElseClause = function (elseClause) { + if (elseClause.statement.kind() === 147 /* IfStatement */) { + this.writeToOutput("else "); + this.emit(elseClause.statement); + } else { + this.writeToOutput("else"); + this.emitBlockOrStatement(elseClause.statement); + } + }; + + Emitter.prototype.emitReturnStatement = function (statement) { + this.recordSourceMappingStart(statement); + if (statement.expression) { + this.writeToOutput("return "); + this.emit(statement.expression); + } else { + this.writeToOutput("return"); + } + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitForInStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.left) { + this.emit(statement.left); + } else { + this.emit(statement.variableDeclaration); + } + this.writeToOutput(" in "); + this.emit(statement.expression); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitForStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.variableDeclaration) { + this.emit(statement.variableDeclaration); + } else if (statement.initializer) { + this.emit(statement.initializer); + } + + this.writeToOutput("; "); + this.emitJavascript(statement.condition, false); + this.writeToOutput(";"); + if (statement.incrementor) { + this.writeToOutput(" "); + this.emitJavascript(statement.incrementor, false); + } + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitWithStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("with ("); + if (statement.condition) { + this.emit(statement.condition); + } + + this.writeToOutput(")"); + var prevInWithBlock = this.inWithBlock; + this.inWithBlock = true; + this.emitBlockOrStatement(statement.statement); + this.inWithBlock = prevInWithBlock; + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitSwitchStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("switch ("); + this.emit(statement.expression); + this.recordSourceMappingStart(statement.closeParenToken); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement.closeParenToken); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + this.emitList(statement.switchClauses, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCaseSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("case "); + this.emit(clause.expression); + this.writeToOutput(":"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitSwitchClauseBody = function (body) { + if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { + this.emit(body.childAt(0)); + this.writeLineToOutput(""); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emit(body); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitDefaultSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("default:"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitTryStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("try "); + this.emit(statement.block); + this.emitJavascript(statement.catchClause, false); + + if (statement.finallyClause) { + this.emit(statement.finallyClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCatchClause = function (clause) { + this.writeToOutput(" "); + this.recordSourceMappingStart(clause); + this.writeToOutput("catch ("); + this.emit(clause.identifier); + this.writeToOutput(")"); + this.emit(clause.block); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitFinallyClause = function (clause) { + this.writeToOutput(" finally"); + this.emit(clause.block); + }; + + Emitter.prototype.emitDebuggerStatement = function (statement) { + this.writeToOutputWithSourceMapRecord("debugger", statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitNumericLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitRegularExpressionLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitStringLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitEqualsValueClause = function (clause) { + this.writeToOutput(" = "); + this.emit(clause.value); + }; + + Emitter.prototype.emitParameter = function (parameter) { + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); + }; + + Emitter.prototype.emitConstructorDeclaration = function (declaration) { + if (declaration.block) { + this.emitConstructor(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { + return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); + }; + + Emitter.prototype.emitFunctionDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { + this.emitFunction(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.emitSourceUnit = function (sourceUnit) { + if (!this.document.isDeclareFile()) { + var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + this.pushDecl(pullDecl); + this.emitScriptElements(sourceUnit); + this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); + } + }; + + Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); + }; + + Emitter.prototype.emitEnumDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { + this.emitComments(declaration, true); + this.emitEnum(declaration); + this.emitComments(declaration, false); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); + }; + + Emitter.prototype.emitModuleDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { + this.emitModuleDeclarationWorker(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); + }; + + Emitter.prototype.emitClassDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + this.emitClass(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { + return declaration.preComments() !== null; + }; + + Emitter.prototype.emitInterfaceDeclaration = function (declaration) { + this.emitComments(declaration, true, true); + }; + + Emitter.prototype.firstVariableDeclarator = function (statement) { + return statement.declaration.declarators.nonSeparatorAt(0); + }; + + Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { + return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; + }; + + Emitter.prototype.shouldEmitVariableStatement = function (statement) { + return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); + }; + + Emitter.prototype.emitVariableStatement = function (statement) { + if (this.isNotAmbientOrHasInitializer(statement)) { + this.emitComments(statement, true); + this.emit(statement.declaration); + this.writeToOutput(";"); + this.emitComments(statement, false); + } else { + this.emitComments(statement, true, true); + } + }; + + Emitter.prototype.emitGenericType = function (type) { + this.emit(type.name); + }; + + Emitter.prototype.shouldEmit = function (ast) { + if (!ast) { + return false; + } + + switch (ast.kind()) { + case 133 /* ImportDeclaration */: + return this.shouldEmitImportDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.shouldEmitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.shouldEmitInterfaceDeclaration(ast); + case 129 /* FunctionDeclaration */: + return this.shouldEmitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.shouldEmitModuleDeclaration(ast); + case 148 /* VariableStatement */: + return this.shouldEmitVariableStatement(ast); + case 223 /* OmittedExpression */: + return false; + case 132 /* EnumDeclaration */: + return this.shouldEmitEnumDeclaration(ast); + } + + return true; + }; + + Emitter.prototype.emit = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 2 /* SeparatedList */: + return this.emitSeparatedList(ast); + case 1 /* List */: + return this.emitList(ast); + case 120 /* SourceUnit */: + return this.emitSourceUnit(ast); + case 133 /* ImportDeclaration */: + return this.emitImportDeclaration(ast); + case 134 /* ExportAssignment */: + return this.setExportAssignment(ast); + case 131 /* ClassDeclaration */: + return this.emitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitInterfaceDeclaration(ast); + case 11 /* IdentifierName */: + return this.emitName(ast, true); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast); + case 219 /* SimpleArrowFunctionExpression */: + return this.emitSimpleArrowFunctionExpression(ast); + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.emitParenthesizedArrowFunctionExpression(ast); + case 129 /* FunctionDeclaration */: + return this.emitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitModuleDeclaration(ast); + case 224 /* VariableDeclaration */: + return this.emitVariableDeclaration(ast); + case 126 /* GenericType */: + return this.emitGenericType(ast); + case 137 /* ConstructorDeclaration */: + return this.emitConstructorDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitEnumDeclaration(ast); + case 243 /* EnumElement */: + return this.emitEnumElement(ast); + case 222 /* FunctionExpression */: + return this.emitFunctionExpression(ast); + case 148 /* VariableStatement */: + return this.emitVariableStatement(ast); + } + + this.emitComments(ast, true); + this.emitWorker(ast); + this.emitComments(ast, false); + }; + + Emitter.prototype.emitWorker = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 13 /* NumericLiteral */: + return this.emitNumericLiteral(ast); + case 12 /* RegularExpressionLiteral */: + return this.emitRegularExpressionLiteral(ast); + case 14 /* StringLiteral */: + return this.emitStringLiteral(ast); + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 37 /* TrueKeyword */: + return this.emitLiteralExpression(ast); + case 35 /* ThisKeyword */: + return this.emitThisExpression(ast); + case 50 /* SuperKeyword */: + return this.emitSuperExpression(ast); + case 217 /* ParenthesizedExpression */: + return this.emitParenthesizedExpression(ast); + case 214 /* ArrayLiteralExpression */: + return this.emitArrayLiteralExpression(ast); + case 211 /* PostDecrementExpression */: + case 210 /* PostIncrementExpression */: + return this.emitPostfixUnaryExpression(ast); + case 167 /* LogicalNotExpression */: + case 166 /* BitwiseNotExpression */: + case 165 /* NegateExpression */: + case 164 /* PlusExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.emitPrefixUnaryExpression(ast); + case 213 /* InvocationExpression */: + return this.emitInvocationExpression(ast); + case 221 /* ElementAccessExpression */: + return this.emitElementAccessExpression(ast); + case 212 /* MemberAccessExpression */: + return this.emitMemberAccessExpression(ast); + case 121 /* QualifiedName */: + return this.emitQualifiedName(ast); + case 173 /* CommaExpression */: + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 187 /* LogicalOrExpression */: + case 188 /* LogicalAndExpression */: + case 189 /* BitwiseOrExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 191 /* BitwiseAndExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return this.emitBinaryExpression(ast); + case 186 /* ConditionalExpression */: + return this.emitConditionalExpression(ast); + case 232 /* EqualsValueClause */: + return this.emitEqualsValueClause(ast); + case 242 /* Parameter */: + return this.emitParameter(ast); + case 146 /* Block */: + return this.emitBlock(ast); + case 235 /* ElseClause */: + return this.emitElseClause(ast); + case 147 /* IfStatement */: + return this.emitIfStatement(ast); + case 149 /* ExpressionStatement */: + return this.emitExpressionStatement(ast); + case 139 /* GetAccessor */: + return this.emitGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitSetAccessor(ast); + case 157 /* ThrowStatement */: + return this.emitThrowStatement(ast); + case 150 /* ReturnStatement */: + return this.emitReturnStatement(ast); + case 216 /* ObjectCreationExpression */: + return this.emitObjectCreationExpression(ast); + case 151 /* SwitchStatement */: + return this.emitSwitchStatement(ast); + case 233 /* CaseSwitchClause */: + return this.emitCaseSwitchClause(ast); + case 234 /* DefaultSwitchClause */: + return this.emitDefaultSwitchClause(ast); + case 152 /* BreakStatement */: + return this.emitBreakStatement(ast); + case 153 /* ContinueStatement */: + return this.emitContinueStatement(ast); + case 154 /* ForStatement */: + return this.emitForStatement(ast); + case 155 /* ForInStatement */: + return this.emitForInStatement(ast); + case 158 /* WhileStatement */: + return this.emitWhileStatement(ast); + case 163 /* WithStatement */: + return this.emitWithStatement(ast); + case 220 /* CastExpression */: + return this.emitCastExpression(ast); + case 215 /* ObjectLiteralExpression */: + return this.emitObjectLiteralExpression(ast); + case 240 /* SimplePropertyAssignment */: + return this.emitSimplePropertyAssignment(ast); + case 241 /* FunctionPropertyAssignment */: + return this.emitFunctionPropertyAssignment(ast); + case 156 /* EmptyStatement */: + return this.writeToOutputWithSourceMapRecord(";", ast); + case 159 /* TryStatement */: + return this.emitTryStatement(ast); + case 236 /* CatchClause */: + return this.emitCatchClause(ast); + case 237 /* FinallyClause */: + return this.emitFinallyClause(ast); + case 160 /* LabeledStatement */: + return this.emitLabeledStatement(ast); + case 161 /* DoStatement */: + return this.emitDoStatement(ast); + case 171 /* TypeOfExpression */: + return this.emitTypeOfExpression(ast); + case 170 /* DeleteExpression */: + return this.emitDeleteExpression(ast); + case 172 /* VoidExpression */: + return this.emitVoidExpression(ast); + case 162 /* DebuggerStatement */: + return this.emitDebuggerStatement(ast); + } + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; + + function getLastConstructor(classDecl) { + return classDecl.classElements.lastOrDefault(function (e) { + return e.kind() === 137 /* ConstructorDeclaration */; + }); + } + TypeScript.getLastConstructor = getLastConstructor; + + function getTrimmedTextLines(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + return comment.fullText().split("\n").map(function (s) { + return s.trim(); + }); + } else { + return [comment.fullText().trim()]; + } + } + TypeScript.getTrimmedTextLines = getTrimmedTextLines; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += memberName.text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function stripStartAndEndQuotes(str) { + var firstCharCode = str && str.charCodeAt(0); + if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + return str.substring(1, str.length - 1); + } + + return str; + } + TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; + + function isSingleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isDoubleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; + } + TypeScript.isDoubleQuoted = isDoubleQuoted; + + function isQuoted(str) { + return isDoubleQuoted(str) || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function changePathToDTS(modPath) { + return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + function convertToDirectoryPath(dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + } + TypeScript.convertToDirectoryPath = convertToDirectoryPath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + function isNoDefaultLibMatch(comment) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + return isNoDefaultLibRegex.exec(comment); + } + + TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; + + function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { + var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } + } + } + + return null; + } + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + var start = new Date().getTime(); + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionScanImportsTime += totalTime; + } + + function processTripleSlashDirectives(fileName, lineMap, firstToken) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + var diagnostics = []; + var referencedFiles = []; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + var isNoDefaultLib = isNoDefaultLibMatch(triviaText); + if (isNoDefaultLib) { + noDefaultLib = isNoDefaultLib[3] === "true"; + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; + } + + function preProcessFile(fileName, sourceText, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); + + scannerDiagnostics.length = 0; + return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); + } + TypeScript.getParseOptions = getParseOptions; + + function getReferencedFiles(fileName, sourceText) { + return preProcessFile(fileName, sourceText, false).referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, lineMap, position, length, isImported) { + this.filePath = filePath; + this.lineMap = lineMap; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { + this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this.inputFileNames = inputFileNames; + this.host = host; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { + var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var _this = this; + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); + this.inputFileNames.forEach(function (fileName) { + return _this.resolveIncludedFile(fileName, referenceLocation, result); + }); + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(tsFile)) { + normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + var start = new Date().getTime(); + + do { + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var _this = this; + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var start = new Date().getTime(); + var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionIOTime += totalTime; + + var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); + resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); + var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + }); + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(name, writeByteOrderMark, outputFileType) { + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.outputFileType = outputFileType; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + }; + + TextWriter.prototype.getOutputFile = function () { + return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.emittedReferencePaths = false; + this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); + } + DeclarationEmitter.prototype.getOutputFile = function () { + return this.declFile.getOutputFile(); + }; + + DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { + this.emitDeclarationsForSourceUnit(sourceUnit); + }; + + DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.emitDeclarationsForAST(list.childAt(i)); + } + }; + + DeclarationEmitter.prototype.emitSeparatedList = function (list) { + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.emitDeclarationsForAST(list.nonSeparatorAt(i)); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { + switch (ast.kind()) { + case 148 /* VariableStatement */: + return this.emitDeclarationsForVariableStatement(ast); + case 141 /* PropertySignature */: + return this.emitPropertySignature(ast); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast, true, true); + case 136 /* MemberVariableDeclaration */: + return this.emitDeclarationsForMemberVariableDeclaration(ast); + case 137 /* ConstructorDeclaration */: + return this.emitDeclarationsForConstructorDeclaration(ast); + case 139 /* GetAccessor */: + return this.emitDeclarationsForGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitDeclarationsForSetAccessor(ast); + case 138 /* IndexMemberDeclaration */: + return this.emitIndexMemberDeclaration(ast); + case 144 /* IndexSignature */: + return this.emitIndexSignature(ast); + case 142 /* CallSignature */: + return this.emitCallSignature(ast); + case 143 /* ConstructSignature */: + return this.emitConstructSignature(ast); + case 145 /* MethodSignature */: + return this.emitMethodSignature(ast); + case 129 /* FunctionDeclaration */: + return this.emitDeclarationsForFunctionDeclaration(ast); + case 135 /* MemberFunctionDeclaration */: + return this.emitMemberFunctionDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.emitDeclarationsForClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitDeclarationsForInterfaceDeclaration(ast); + case 133 /* ImportDeclaration */: + return this.emitDeclarationsForImportDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitDeclarationsForModuleDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitDeclarationsForEnumDeclaration(ast); + case 134 /* ExportAssignment */: + return this.emitDeclarationsForExportAssignment(ast); + } + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { + var container = this.getEnclosingContainer(declAST); + if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { + var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); + var container = this.getEnclosingContainer(declAST); + + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { + container = this.getEnclosingContainer(container); + } + + var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); + + if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { + result += "declare "; + } + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { + this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { + var declarationContainerAst = this.getEnclosingContainer(ast); + + var start = new Date().getTime(); + var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); + + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = TypeScript.getTrimmedTextLines(comment); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.semanticInfoChain.getDeclForAST(boundDecl); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = pullSymbol.type; + TypeScript.Debug.assert(type); + + this.declFile.Write(": "); + this.emitTypeSignature(boundDecl, type); + }; + + DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { + this.emitDeclarationComments(varDecl); + this.emitIndent(); + this.declFile.Write(varDecl.propertyName.text()); + if (varDecl.questionToken) { + this.declFile.Write("?"); + } + + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + if (isFirstVarInList) { + this.emitDeclFlags(varDecl, "var"); + } + + this.declFile.Write(varDecl.propertyName.text()); + + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + if (isLastVarInList) { + this.declFile.WriteLine(";"); + } else { + this.declFile.Write(", "); + } + } + }; + + DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { + if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } + this.declFile.Write("static "); + } else { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } else { + this.declFile.Write("public "); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(varDecl.modifiers); + ; + + this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); + + if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + this.declFile.WriteLine(";"); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { + this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); + }; + + 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); + } + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(id.text()); + if (isOptional) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (!isPrivate) { + this.emitTypeOfVariableDeclaratorOrParameter(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("constructor"); + + this.declFile.Write("("); + 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.ASTHelpers.parametersFromParameterList(parameterList)); + this.declFile.Write(")"); + }; + + DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { + var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); + var argsLen = parameterList.length; + if (hasLastParameterRestParameter) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + + if (hasLastParameterRestParameter) { + if (parameterList.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + var index = parameterList.length - 1; + this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); + } + }; + + DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitDeclFlags(funcDecl, "function"); + var id = funcDecl.propertyName.text(); + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); + + this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); + + if (!isPrivate) { + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + this.emitDeclarationComments(funcDecl); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); + + this.emitIndent(); + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("new"); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write(funcDecl.propertyName.text()); + if (funcDecl.questionToken) { + this.declFile.Write("? "); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + if (funcDecl.block) { + var funcTypeSymbol = funcSymbol.type; + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + var id = funcDecl.identifier.text(); + this.emitDeclFlags(funcDecl, "function"); + if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { + this.declFile.Write(id); + } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { + this.declFile.Write("new"); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { + this.emitDeclarationsForAST(funcDecl.indexSignature); + }; + + DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("["); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); + this.declFile.Write("]"); + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { + if (bases && (bases.nonSeparatorCount() > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.nonSeparatorCount(); + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + var base = bases.nonSeparatorAt(i); + var baseType = this.semanticInfoChain.getSymbolForAST(base); + this.emitTypeSignature(base, baseType); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); + } + if (accessors.setter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { + return; + } + + var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); + this.emitAccessorDeclarationComments(funcDecl); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(modifiers); + this.declFile.Write(name.text()); + if (!isPrivate) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(funcDecl, type); + } + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } + + 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(";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { + if (!this.canEmitDeclarations(classDecl)) { + return; + } + + var className = classDecl.identifier.text(); + this.emitDeclarationComments(classDecl); + var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.emitDeclFlags(classDecl, "class"); + this.declFile.Write(className); + + this.emitTypeParameters(classDecl.typeParameterList); + this.emitHeritageClauses(classDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + var constructorDecl = TypeScript.getLastConstructor(classDecl); + if (constructorDecl) { + this.emitClassMembersFromConstructorDefinition(constructorDecl); + } + + this.emitDeclarationsForList(classDecl.classElements); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { + if (clauses) { + for (var i = 0, n = clauses.childCount(); i < n; i++) { + this.emitHeritageClause(clauses.childAt(i)); + } + } + }; + + DeclarationEmitter.prototype.emitHeritageClause = function (clause) { + this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); + }; + + DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getEnclosingContainer(typeParams); + + var start = new Date().getTime(); + var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArgumentsOrTypeParameters(); + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { + if (!this.canEmitDeclarations(interfaceDecl)) { + return; + } + + var interfaceName = interfaceDecl.identifier.text(); + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); + this.emitDeclFlags(interfaceDecl, "interface"); + this.declFile.Write(interfaceName); + + this.emitTypeParameters(interfaceDecl.typeParameterList); + this.emitHeritageClauses(interfaceDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + + this.emitSeparatedList(interfaceDecl.body.typeMembers); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.identifier.text() + " = "); + if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); + } else { + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclFlags(moduleDecl, "enum"); + this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.enumElements.nonSeparatorCount(); + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); + var enumElement = memberDecl; + var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); + this.emitDeclarationComments(enumElement); + this.emitIndent(); + this.declFile.Write(enumElement.propertyName.text()); + if (enumElementDecl.constantValue !== null) { + this.declFile.Write(" = " + enumElementDecl.constantValue); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclarationComments(moduleDecl); + + var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); + this.emitDeclFlags(name, "module"); + + if (moduleDecl.stringLiteral) { + this.declFile.Write(moduleDecl.stringLiteral.text()); + } else { + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); + } + + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + + this.emitDeclarationsForList(moduleDecl.moduleElements); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.identifier.text()); + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { + if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { + return reference; + } + + var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); + var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); + return resolvedReferencePath; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.document.emitToOwnOutputFile()) { + var scriptReferences = this.document.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { + documents = documents.concat(document); + + if (!document.isDeclareFile() && document.isExternalModule()) { + addedGlobalDocument = true; + } + } + } + } else { + var fileNames = this.compiler.fileNames(); + for (var i = 0; i < fileNames.length; i++) { + var doc = this.compiler.getDocument(fileNames[i]); + if (!doc.isDeclareFile() && !doc.isExternalModule()) { + var scriptReferences = doc.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.isDeclareFile() || document.isExternalModule())) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] === document) { + break; + } + } + + if (k === documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.isDeclareFile()) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { + this.emitReferencePaths(sourceUnit); + this.emitDeclarationsForList(sourceUnit.moduleElements); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] !== array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + 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, createFileLog) { + this._propagateEnumConstants = propagateEnumConstants; + this._removeComments = removeComments; + this._watch = watch; + this._noResolve = noResolve; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + this._noImplicitAny = noImplicitAny; + this._noLib = noLib; + this._codeGenTarget = codeGenTarget; + this._moduleGenTarget = moduleGenTarget; + this._outFileOption = outFileOption; + this._outDirOption = outDirOption; + this._mapSourceFiles = mapSourceFiles; + this._mapRoot = mapRoot; + this._sourceRoot = sourceRoot; + this._generateDeclarationFiles = generateDeclarationFiles; + this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this._gatherDiagnostics = gatherDiagnostics; + this._codepage = codepage; + this._createFileLog = createFileLog; + } + ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { + return this._propagateEnumConstants; + }; + ImmutableCompilationSettings.prototype.removeComments = function () { + return this._removeComments; + }; + ImmutableCompilationSettings.prototype.watch = function () { + return this._watch; + }; + ImmutableCompilationSettings.prototype.noResolve = function () { + return this._noResolve; + }; + ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + ImmutableCompilationSettings.prototype.noImplicitAny = function () { + return this._noImplicitAny; + }; + ImmutableCompilationSettings.prototype.noLib = function () { + return this._noLib; + }; + ImmutableCompilationSettings.prototype.codeGenTarget = function () { + return this._codeGenTarget; + }; + ImmutableCompilationSettings.prototype.moduleGenTarget = function () { + return this._moduleGenTarget; + }; + ImmutableCompilationSettings.prototype.outFileOption = function () { + return this._outFileOption; + }; + ImmutableCompilationSettings.prototype.outDirOption = function () { + return this._outDirOption; + }; + ImmutableCompilationSettings.prototype.mapSourceFiles = function () { + return this._mapSourceFiles; + }; + ImmutableCompilationSettings.prototype.mapRoot = function () { + return this._mapRoot; + }; + ImmutableCompilationSettings.prototype.sourceRoot = function () { + return this._sourceRoot; + }; + ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { + return this._generateDeclarationFiles; + }; + ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { + return this._useCaseSensitiveFileResolution; + }; + ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { + return this._gatherDiagnostics; + }; + ImmutableCompilationSettings.prototype.codepage = function () { + return this._codepage; + }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; + + ImmutableCompilationSettings.defaultSettings = function () { + if (!ImmutableCompilationSettings._defaultSettings) { + ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); + } + + return ImmutableCompilationSettings._defaultSettings; + }; + + 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, 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, "_")) { + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; + } + } + + return result; + }; + return ImmutableCompilationSettings; + })(); + TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; + + PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + function hasModifier(modifiers, flag) { + for (var i = 0, n = modifiers.length; i < n; i++) { + if (TypeScript.hasFlag(modifiers[i], flag)) { + return true; + } + } + + return false; + } + TypeScript.hasModifier = hasModifier; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; + PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; + + 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.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"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var pullDeclID = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + 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; + this.childDeclTypeParameterCache = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.semanticInfoChain = semanticInfoChain; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + } + PullDecl.prototype.fileName = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentPath = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.isExternalModule = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getEnclosingDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { + var decl = this; + while (decl) { + switch (decl.kind) { + default: + return decl; + case 512 /* Variable */: + case 8192 /* TypeParameter */: + case 2048 /* Parameter */: + case 128 /* TypeAlias */: + case 67108864 /* EnumMember */: + } + + decl = decl.getParentDecl(); + } + + TypeScript.Debug.fail(); + }; + + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.semanticInfoChain.setSymbolForDecl(this, symbol); + }; + + 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 */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.semanticInfoChain.getSymbolForDecl(this); + }; + + PullDecl.prototype.hasSymbol = function () { + var symbol = this.semanticInfoChain.getSymbolForDecl(this); + return !!symbol; + }; + + PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); + }; + + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); + }; + + PullDecl.prototype.hasSignatureSymbol = function () { + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); + return !!signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; + }; + + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + if (declKind === 8192 /* TypeParameter */) { + if (!this.childDeclTypeParameterCache) { + this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeParameterCache; + } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { + if (!this.childDeclNamespaceCache) { + this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclNamespaceCache; + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { + if (!this.childDeclTypeCache) { + this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeCache; + } else { + if (!this.childDeclValueCache) { + this.childDeclValueCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclValueCache; + } + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + + if (!(childDecl.kind & 7340032 /* SomeSignature */)) { + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + } + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; + } else if (searchKind & 164 /* SomeContainer */) { + cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; + } else { + cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + if (!this.declGroups) { + this.declGroups = TypeScript.createIntrinsicsObject(); + } + + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + if (this.declGroups) { + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (declGroups === null) { + declGroups = []; + } + + declGroups.push(this.declGroups[declName].getDecls()); + } + } + } + + return declGroups || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.hasBeenBound = function () { + return this.hasSymbol() || this.hasSignatureSymbol(); + }; + + PullDecl.prototype.isSynthesized = function () { + return false; + }; + + PullDecl.prototype.ast = function () { + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var RootPullDecl = (function (_super) { + __extends(RootPullDecl, _super); + 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; + } + RootPullDecl.prototype.fileName = function () { + return this._fileName; + }; + + RootPullDecl.prototype.getParentPath = function () { + return [this]; + }; + + RootPullDecl.prototype.getParentDecl = function () { + return null; + }; + + RootPullDecl.prototype.isExternalModule = function () { + return this._isExternalModule; + }; + + 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, addToParent) { + if (typeof addToParent === "undefined") { addToParent = true; } + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); + this.parentDecl = null; + this.parentPath = null; + + this.parentDecl = parentDecl; + 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._rootDecl.fileName(); + }; + + NormalPullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + NormalPullDecl.prototype.getParentPath = function () { + if (!this.parentPath) { + var path = [this]; + var parentDecl = this.parentDecl; + + while (parentDecl) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { + path.unshift(parentDecl); + } + + parentDecl = parentDecl.getParentDecl(); + } + + this.parentPath = path; + } + + return this.parentPath; + }; + + NormalPullDecl.prototype.isExternalModule = function () { + return false; + }; + + 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) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); + this.constantValue = null; + } + return PullEnumElementDecl; + })(NormalPullDecl); + TypeScript.PullEnumElementDecl = PullEnumElementDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { + if (typeof displayName === "undefined") { displayName = ""; } + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(NormalPullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullSynthesizedDecl = (function (_super) { + __extends(PullSynthesizedDecl, _super); + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; + } + PullSynthesizedDecl.prototype.isSynthesized = function () { + return true; + }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; + return PullSynthesizedDecl; + })(NormalPullDecl); + TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = ++TypeScript.pullSymbolID; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.rootSymbol = null; + this._enclosingSignature = null; + this._docComments = null; + this.isPrinting = false; + this.name = name; + this.kind = declKind; + } + PullSymbol.prototype.isAny = function () { + return false; + }; + + PullSymbol.prototype.isType = function () { + return (this.kind & 58728795 /* SomeType */) !== 0; + }; + + PullSymbol.prototype.isTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & 7340032 /* SomeSignature */) !== 0; + }; + + PullSymbol.prototype.isArrayNamedTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { + if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } + if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } + var scopeDeclarations = scopeSymbol.getDeclarations(); + var scopeSymbolAliasesToLookIn = []; + + for (var i = 0; i < scopeDeclarations.length; i++) { + var scopeDecl = scopeDeclarations[i]; + if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { + visitedScopeDeclarations.push(scopeDecl); + + var childDecls = scopeDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { + var symbol = childDecl.getSymbol(); + + if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { + aliasSymbols.push(symbol); + return aliasSymbols; + } + + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { + scopeSymbolAliasesToLookIn.push(symbol); + } + } + } + } + } + + for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { + var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; + + aliasSymbols.push(scopeSymbolAlias); + var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); + if (result) { + return result; + } + + aliasSymbols.pop(); + } + + return null; + }; + + PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); + return symbols; + } + + return null; + }; + + PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { + if (aliasSymbol) { + if (aliasSymbol.assignedValue()) { + return false; + } + + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { + return false; + } + + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { + return false; + } + + return true; + } + + return false; + }; + + PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { + if (scopeSymbol) { + 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); + return internalAliases[0]; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { + if (!skipInternalAlias) { + var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); + if (internalAlias) { + return aliasNameGetter(internalAlias); + } + } + + var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); + + if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { + 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 aliasFullName; + } + + return null; + }; + + PullSymbol.prototype._getResolver = function () { + TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); + return this._declarations[0].semanticInfoChain.getResolver(); + }; + + PullSymbol.prototype._resolveDeclaredSymbol = function () { + return this._getResolver().resolveDeclaredSymbol(this); + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getName(); + }); + return aliasName || this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getDisplayName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getDisplayName(); + }, skipInternalAliasName); + if (aliasDisplayName) { + return aliasDisplayName; + } + + var decls = this.getDeclarations(); + var name = decls.length && decls[0].getDisplayName(); + + return (name && name.length) ? name : this.name; + }; + + PullSymbol.prototype.getIsSpecialized = function () { + return false; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + 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; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.hasDeclaration = function (decl) { + if (!this._declarations) { + return false; + } + + return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { + return eachDecl === decl; + }); + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.anyDeclHasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (TypeScript.hasFlag(declarations[i].flags, flag)) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!TypeScript.hasFlag(declarations[i].flags, flag)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = node.getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind === 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + 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 memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { + return true; + } + + var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol) { + return true; + } + } + } + + 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 (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { + return thisPath.slice(0, thisCommonAncestorIndex); + } else { + return thisPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; + var path = this.pathToRoot(); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol === _this ? null : symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { + var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + 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 */) { + var signatures = type.getCallSignatures(); + 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); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + + inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); + + var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); + inIsExternallyVisibleSymbols.pop(); + + return result; + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.rootSymbol) { + return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); + } + + if (this.isType()) { + var associatedContainerSymbol = this.getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.anyDeclHasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + var decls = this.getDeclarations(); + if (decls.length) { + var parentDecl = decls[0].getParentDecl(); + if (parentDecl) { + var parentSymbol = parentDecl.getSymbol(); + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { + return true; + } + + return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); + } + } + + return true; + } + + 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 */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { + var ast = decl.ast(); + + if (ast) { + 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.ASTHelpers.docComments(ast); + } + } + + return []; + }; + + PullSymbol.prototype.getDocCommentArray = function (symbol) { + var docComments = []; + if (!symbol) { + return docComments; + } + + 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 */) { + continue; + } + docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); + } + return docComments; + }; + + PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { + if (classSymbol.getHasDefaultConstructor()) { + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); + } + } + + return classSymbol.type.getConstructSignatures()[0]; + }; + + PullSymbol.prototype.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = this.getDocCommentTextValue(comments[c]); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + PullSymbol.prototype.getDocCommentTextValue = function (comment) { + return this.cleanJSDocComment(comment.fullText()); + }; + + PullSymbol.prototype.docComments = function (useConstructorAsClass) { + var decls = this.getDeclarations(); + 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 */) { + var classSymbol = this.returnType; + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + docComments = extendedTypes[0].getConstructorMethod().docComments(); + } else { + docComments = ""; + } + } else if (this.kind === 2048 /* Parameter */) { + var parameterComments = []; + + var funcContainer = this.getEnclosingSignature(); + var funcDocComments = this.getDocCommentArray(funcContainer); + var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); + if (paramComment != "") { + parameterComments.push(paramComment); + } + + var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); + if (paramSelfComment != "") { + parameterComments.push(paramSelfComment); + } + docComments = parameterComments.join("\n"); + } else { + var getSymbolComments = true; + if (this.kind === 16777216 /* FunctionType */) { + var functionSymbol = this.getFunctionSymbol(); + + if (functionSymbol) { + docComments = functionSymbol._docComments || ""; + getSymbolComments = false; + } else { + var declarationList = this.getDeclarations(); + if (declarationList.length > 0) { + docComments = declarationList[0].getSymbol()._docComments || ""; + getSymbolComments = false; + } + } + } + if (getSymbolComments) { + docComments = this.getDocCommentText(this.getDocCommentArray(this)); + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { + var callTypeSymbol = this.functionType; + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { + docComments = callTypeSymbol.docComments(); + } + } + } + } + } + + this._docComments = docComments; + } + + return this._docComments; + }; + + PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].fullText(); + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!this.isSpaceChar(commentContents, j)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + + PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.start; + for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.end); + } + + var newCleanPos = this.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + PullSymbol.prototype.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = this.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + start: nonSpaceIndex, + end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + 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.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; + this.hasBeenChecked = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return this._isDefinition; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + 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) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this._typeParameters) { + this._typeParameters = []; + } + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + 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 = []; + } + + return this._typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; + } + } + + memberSymbol = this._memberTypeParameterNameCache[name]; + + 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; + this._stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { + this._stringConstantOverload = true; + } + } + } + + 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); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + 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 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 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 wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + + var parameters = this.parameters; + + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._enclosedMemberContainers = null; + this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._enclosedContainerCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._containedNonMemberContainerCache = null; + this._simpleInstantiationCache = null; + this._complexInstantiationCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this._inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + this.typeReference = null; + this._widenedType = null; + this._isArrayNamedTypeReference = undefined; + this.type = this; + } + PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { + if (this._isArrayNamedTypeReference === undefined) { + this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); + } + + return this._isArrayNamedTypeReference; + }; + + PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { + var typeArgs = this.getTypeArguments(); + if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { + var declaration = this.getDeclarations()[0]; + + if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind === 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind === 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullTypeSymbol.prototype.isObject = function () { + 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 () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members !== TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return null; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberContainerCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = TypeScript.createIntrinsicsObject(); + } + + if (this._members === TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members.push(memberSymbol); + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + if (!enclosedContainer) { + return; + } + + enclosedContainer.setContainer(this); + + if (!this._enclosedContainerCache) { + this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberContainers) { + this._enclosedMemberContainers = []; + } + + this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; + this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + if (!enclosedNonMemberContainer) { + return; + } + + enclosedNonMemberContainer.setContainer(this); + + if (!this._containedNonMemberContainerCache) { + this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + 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 (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; + } + + 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; + } else { + if (!this._complexInstantiationCache) { + this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType.push(specializedVersionOfThisType); + }; + + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { + if (!this._simpleInstantiationCache) { + return null; + } + + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; + } else { + if (!this._complexInstantiationCache) { + return null; + } + + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + } + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return null; + }; + + PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + return this.getTypeParameters(); + }; + + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + 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 = []; + } + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + 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 = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + 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; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return this._constructSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function () { + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return this._indexSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnIndexSignatures = function () { + return this._indexSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function () { + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + } + } + + this._allIndexSignatures = signatures; + + 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; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { + if (typeof visited === "undefined") { visited = []; } + if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { + return true; + } + + if (TypeScript.ArrayUtilities.contains(visited, this)) { + return true; + } + + visited.push(this); + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + visited.pop(); + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (memberSymbol || !lookInParent) { + return memberSymbol; + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedContainerCache) { + return null; + } + + memberSymbol = this._enclosedContainerCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + var allMembers = []; + + 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 */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; + + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer()) { + if (this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + if (this._enclosedMemberContainers) { + for (var i = 0; i < this._enclosedMemberContainers.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberContainers[i]; + } + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArgumentsOrTypeParameters(); + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); + }; + + 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 !== "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); + return s; + }; + + 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, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + if (skipTypeParametersInName) { + return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); + } else { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + + var typars = this.getTypeArgumentsOrTypeParameters(); + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + } + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getTypeOfSymbol = function () { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + return associatedContainerType; + } + + var functionSymbol = this.getFunctionSymbol(); + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; + } + + return null; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + var typeOfSymbol = this.getTypeOfSymbol(); + if (typeOfSymbol) { + var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } + + if (this._inMemberTypeNameEx) { + return TypeScript.MemberName.create("any"); + } + + this._inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + 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()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && memberTypeName.delim === delim) { + allMemberNames.addAll(memberTypeName.entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this._inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + return 2 /* Closed */; + }; + + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + + if (type.isTypeParameter()) { + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; + } + + var constraint = type.getConstraint(); + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; + } + + if (type.inWrapCheck) { + return 0; + } + + 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; + + var typeArguments = type.getTypeArguments(); + + if (type.isGeneric() && !typeArguments) { + typeArguments = type.getTypeParameters(); + } + + if (typeArguments) { + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); + } + } + } + + 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); + } + + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); + } + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } + + return wrappingTypeParameterID; + }; + + 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + 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(); + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; + } + + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { + return true; + } + } + + 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); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isAny = function () { + 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 () { + return false; + }; + + 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; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(_anyType, name) { + _super.call(this, name); + 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); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerSymbol = (function (_super) { + __extends(PullContainerSymbol, _super); + function PullContainerSymbol(name, kind) { + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerSymbol.prototype.hasExportAssignment = function () { + return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; + }; + + PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { + return true; + } + + var moduleSymbol = containerSymbol; + var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerSymbol = PullContainerSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 128 /* TypeAlias */); + this._assignedValue = null; + this._assignedType = null; + 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; + }; + + PullTypeAliasSymbol.prototype.isUsedAsValue = function () { + this._resolveDeclaredSymbol(); + return this._isUsedAsValue; + }; + + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; + }; + + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; + + 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(); + }); + } + }; + + PullTypeAliasSymbol.prototype.assignedValue = function () { + this._resolveDeclaredSymbol(); + return this._assignedValue; + }; + + PullTypeAliasSymbol.prototype.assignedType = function () { + this._resolveDeclaredSymbol(); + return this._assignedType; + }; + + PullTypeAliasSymbol.prototype.assignedContainer = function () { + this._resolveDeclaredSymbol(); + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this._assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this._assignedValue) { + return this._assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this._assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedType) { + if (this._assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = this._assignedType.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this._assignedType !== this._assignedContainer) { + return this._assignedType; + } + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this._assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this._assignedType) { + return this._assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this._assignedType) { + return this._assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this._assignedType) { + return this._assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this._assignedType) { + return this._assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this._assignedType) { + return this._assignedType.findMember(name, true); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedContainer(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { + if (this._assignedType) { + return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); + } + + return TypeScript.sentinelEmptyArray; + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name) { + _super.call(this, name, 8192 /* TypeParameter */); + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + 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(); + } + + return _super.prototype.getCallSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getConstructSignatures = function () { + if (this._constraint) { + return this._constraint.getConstructSignatures(); + } + + return _super.prototype.getConstructSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getIndexSignatures = function () { + if (this._constraint) { + return this._constraint.getIndexSignatures(); + } + + return _super.prototype.getIndexSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { + var substitution = ""; + var members = null; + + 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 getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); + } + + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); + } + + return null; + } + + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.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"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; + })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); + 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._inferredTypeAfterFixing = null; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + 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 TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + this.candidateCache = []; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); + } + } + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { + return true; + } else { + this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); + return false; + } + }; + + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache.release(); + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + }; + + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolID]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolID] = info; + } + }; + + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolID]; + }; + + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { + var info = this.getInferenceInfo(param); + + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); + } + }; + + 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); + } + }; + + 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]; + + info.fixTypeParameter(this.resolver, this.context); + + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; + } + } + + results.push(info._inferredTypeAfterFixing); + } + + return results; + }; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; + })(); + 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, isInferentiallyTyping, typeArgumentInferenceContext) { + this.contextualType = contextualType; + this.provisional = provisional; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; + this.provisionallyTypedSymbols = []; + this.hasProvisionalErrors = false; + this.astSymbolMap = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].setUnresolved(); + } + }; + + PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()]; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + if (typeof fileName === "undefined") { fileName = null; } + this.resolver = resolver; + this.inTypeCheck = inTypeCheck; + 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"); + this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); + } + } + PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { + if (!this.inProvisionalResolution()) { + this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); + } + }; + + PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { + return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); + }; + + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); + }; + + 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(); + + if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; + } + + return tc; + }; + + PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + 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); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); + } + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { + if (diagnostic) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; + } else if (this.inTypeCheck && this.resolver) { + this.resolver.semanticInfoChain.addDiagnostic(diagnostic); + } + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inProvisionalResolution(); + }; + + PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { + this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); + }; + + PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + var typeContext = this.contextStack[i]; + if (!typeContext.provisional) { + break; + } + + var symbol = typeContext.getSymbolForAST(ast); + if (symbol) { + return symbol; + } + } + + 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; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OverloadApplicabilityStatus; + (function (OverloadApplicabilityStatus) { + OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; + })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + this.diagnosticsFromOverloadResolution = []; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var MemberWithBaseOrigin = (function () { + function MemberWithBaseOrigin(memberSymbol, baseOrigin) { + this.memberSymbol = memberSymbol; + this.baseOrigin = baseOrigin; + } + return MemberWithBaseOrigin; + })(); + + var SignatureWithBaseOrigin = (function () { + function SignatureWithBaseOrigin(signature, baseOrigin) { + this.signature = signature; + this.baseOrigin = baseOrigin; + } + return SignatureWithBaseOrigin; + })(); + + var InheritedIndexSignatureInfo = (function () { + function InheritedIndexSignatureInfo() { + } + return InheritedIndexSignatureInfo; + })(); + + 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(); + return CompilerReservedName[nameText]; + } + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this._cachedAnyTypeArgs = null; + this.typeCheckCallBacks = []; + this.postTypeCheckWorkitems = []; + this._cachedFunctionArgumentsSymbol = null; + 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 */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getArrayNamedType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { + if (!this._cachedFunctionArgumentsSymbol) { + this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); + functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); + this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + } + + 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); + }; + + PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { + return context.canTypeCheckAST(ast); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && context.inProvisionalResolution()) { + context.setSymbolForAST(ast, symbol); + } else { + this.semanticInfoChain.setSymbolForAST(ast, symbol); + } + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { + var symbol = this.semanticInfoChain.getSymbolForAST(ast); + + if (!symbol) { + if (context && context.inProvisionalResolution()) { + symbol = context.getSymbolForAST(ast); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { + if (typeof name === "undefined") { name = null; } + return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = decl.getParentPath(); + + if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.anyDeclHasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + 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 & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + + if (declSearchKind & 68147712 /* SomeValue */) { + member = parent.findMember(symbolName, true); + } else if (declSearchKind & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + } + + if (parent.kind & 164 /* SomeContainer */) { + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + return valueSymbol; + } + } + + return aliasSymbol; + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + 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; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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(); + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & 1032192 /* SomeFunction */) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (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) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = decl.getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var topLevelDecls = this.semanticInfoChain.topLevelDecls(); + for (var i = 0, n = topLevelDecls.length; i < n; i++) { + var topLevelDecl = topLevelDecls[i]; + if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { + continue; + } + + if (!topLevelDecl.isExternalModule()) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + 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 */ || lhs.kind === 64 /* Enum */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + this.resolveDeclaredSymbol(lhsType, context); + + if (lhsType.isContainer() && lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + var memberVisibilty = 2 /* externallyVisible */; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = enclosingDecl.getParentPath(); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { + memberVisibilty = 1 /* internallyVisible */; + break; + } + } + } + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + lhsType = this.getApparentType(lhsType); + + 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); + } + + 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 */)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { + var originalIdText = idText; + var symbol = null; + + if (TypeScript.isRelative(originalIdText)) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + symbol = this.semanticInfoChain.findExternalModule(path + idText); + } else { + idText = originalIdText; + + symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); + + if (!symbol) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + symbol = this.semanticInfoChain.findExternalModule(path + idText); + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + } + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { + if (!symbol || symbol.isResolved || symbol.isTypeReference()) { + return symbol; + } + + if (!context) { + context = new TypeScript.PullTypeResolutionContext(this); + } + + return this.resolveDeclaredSymbolWorker(symbol, context); + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.type && !symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + + var decls = symbol.getDeclarations(); + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + var ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + var resolvedSymbol; + 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 */); + resolvedSymbol = this.resolveAST(ast, false, context); + } + + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + 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(); + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); + }; + + PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { + var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); + var moduleSymbol = enclosingDecl.getSymbol(); + this.ensureAllSymbolsAreBound(moduleSymbol); + + this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); + this.resolveAST(sourceUnit.moduleElements, false, context); + + if (this.canTypeCheckAST(sourceUnit, context)) { + this.typeCheckSourceUnit(sourceUnit, context); + } + + return moduleSymbol; + }; + + 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) { + var containerDecl = this.semanticInfoChain.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + containerSymbol.setResolved(); + + this.resolveOtherDeclarations(ast, context); + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckEnumDeclaration(ast, context); + } + + return containerSymbol; + }; + + 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); + + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { + this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); + } + }; + + PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { + 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; + + if (ast.stringLiteral) { + result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckModuleDeclaration(ast, context); + } + + return result; + }; + + PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { + if (containerSymbol) { + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + }; + + PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + this.ensureAllSymbolsAreBound(containerSymbol); + + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, context); + } + + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + if (isLastName) { + this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); + } else if (sourceUnitAST) { + this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); + } + + containerSymbol.setResolved(); + + if (moduleDeclNameAST) { + this.resolveOtherDeclarations(moduleDeclNameAST, context); + } + + return containerSymbol; + }; + + 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 */) { + this.resolveExportAssignmentStatement(moduleElement, context); + return; + } + } + }; + + PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + var containerSymbol = containerDecl.getSymbol(); + + return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); + }; + + PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { + if (ast.stringLiteral) { + this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + }; + + PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; + this.setTypeChecked(ast, context); + + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { + this.resolveAST(ast.moduleElements, false, context); + } + + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + this.validateVariableDeclarationGroups(containerDecl, context); + + if (ast.stringLiteral) { + if (TypeScript.isRelative(ast.stringLiteral.valueText())) { + this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); + } + } + + 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) { + this.checkThisCaptureVariableCollides(ast, true, context); + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { + if (term.kind() === 11 /* IdentifierName */) { + return true; + } else if (term.kind() === 121 /* QualifiedName */) { + var binex = term; + + if (binex.right.kind() === 11 /* IdentifierName */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { + if (!type.isGeneric()) { + return type; + } + + var typeParameters = type.getTypeArgumentsOrTypeParameters(); + + var typeParameterArgumentMap = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); + } + + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); + if (extendsClause) { + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + + if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + } + } + } + + 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()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); + var implementedType = this.resolveTypeReference(implementedTypeAST, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + + if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addImplementedType(implementedType); + } + } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + + this.typeCheckCallBacks.push(function (context) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + _this.resolveClassDeclaration(classOrInterface, context); + } else { + _this.resolveInterfaceDeclaration(classOrInterface, context); + } + }); + + return typeDeclSymbol; + } + + this.setSymbolForAST(name, typeDeclSymbol, context); + this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + 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); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + var parentConstructor = parentType ? parentType.getConstructorMethod() : null; + + if (parentConstructor) { + this.resolveDeclaredSymbol(parentConstructor, context); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + + if (!parentConstructSignatures.length) { + parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + parentConstructSignature.returnType = parentType; + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); + parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); + parentConstructSignatures = [parentConstructSignature]; + } + + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + 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); + } + + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + + if (parentConstructorSymbol) { + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + } + } + + this.resolveOtherDeclarations(classDeclAST, context); + } + + if (this.canTypeCheckAST(classDeclAST, context)) { + this.typeCheckClassDeclaration(classDeclAST, context); + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { + var _this = this; + 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); + }); + } + } + }; + + PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { + this.setTypeChecked(classDeclAST, context); + + var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + + this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); + this.resolveAST(classDeclAST.classElements, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); + this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + + if (!classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); + }; + + PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { + this.checkThisCaptureVariableCollides(classDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { + var callSignatures = typeSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], context); + } + + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], context); + } + + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], context); + } + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); + + if (interfaceDeclSymbol.isResolved) { + this.resolveOtherDeclarations(interfaceDeclAST, context); + + if (this.canTypeCheckAST(interfaceDeclAST, context)) { + this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { + this.setTypeChecked(interfaceDeclAST, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); + this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); + + 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) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + this.resolveDeclaredSymbol(symbol, context); + + var alias = symbol; + if (kind & 164 /* SomeContainer */) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & 58728795 /* SomeType */) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & 68147712 /* SomeValue */) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); + + return { + symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), + aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null + }; + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + var rhsName = identifier.valueText(); + if (rhsName.length === 0) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); + var containerSymbol = memberSymbol.symbol; + var valueSymbol = null; + var typeSymbol = null; + var aliasSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + aliasSymbol = memberSymbol.aliasSymbol; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + aliasSymbol = containerSymbol; + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); + valueSymbol = memberSymbol.symbol; + if (valueSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + } + + if (!typeSymbol) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + typeSymbol = memberSymbol.symbol; + if (typeSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); + return null; + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol, + aliasSymbol: aliasSymbol + }; + }; + + 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"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleContainer) { + moduleName = dottedNameAST.right.valueText(); + + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; + if (!moduleSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); + } + } + } else { + var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); + var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); + + if (text.length > 0) { + var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); + moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); + if (moduleSymbol) { + 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]); + } + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var moduleReference = importStatementAST.moduleReference; + + var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; + + 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); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); + if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { + var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); + var instanceSymbol = aliasedType.getInstanceSymbol(); + + 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 { + importDeclSymbol.setAssignedValueSymbol(valueSymbol); + } + } + } else { + aliasedType = this.getNewErrorTypeSymbol(); + } + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); + return null; + } + } + } + + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + var declPath = enclosingDecl.getParentPath(); + + aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); + + if (!aliasedType) { + var path = importStatementAST.moduleReference.stringLiteral.text(); + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); + aliasedType = this.getNewErrorTypeSymbol(); + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); + } + + importDeclSymbol.setResolved(); + + this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); + 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); + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { + var _this = this; + this.setTypeChecked(importStatementAST, context); + + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (this.compilationSettings.noResolve()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); + } + + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + if (enclosingDecl.kind === 32 /* DynamicModule */) { + 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)); + } + } + } + } + + var checkPrivacy; + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind === 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + + 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; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { + var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + } + + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); + }; + + PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { + 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); + } + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { + var id = exportAssignmentAST.identifier.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && parentSymbol.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + + var aliasSymbol = containerSymbol; + var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + parentSymbol.setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + parentSymbol.setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + parentSymbol.setExportAssignedContainerSymbol(containerSymbol); + } + + this.resolveDeclaredSymbol(valueSymbol, context); + this.resolveDeclaredSymbol(typeSymbol, context); + this.resolveDeclaredSymbol(containerSymbol, context); + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + var funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); + } + } + + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.setTypeChecked(funcDeclAST, context); + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeAnnotation) { + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + 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) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + 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 (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(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + var contextualType = contextParam && contextParam.type; + var isImplicitAny = false; + + if (typeExpr) { + var typeRef = this.resolveTypeReference(typeExpr, context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + typeRef = this.getNewErrorTypeSymbol(); + } + + contextualType = typeRef || contextualType; + } + if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } + context.setTypeInContext(paramSymbol, contextualType); + } 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.propagateContextualType(contextualType); + } + + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + } + + if (!initExprSymbol || !initExprSymbol.type) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); + + if (!contextualType) { + context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); + } + } else { + var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); + if (!contextualType) { + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); + isImplicitAny = initTypeSymbol !== paramSymbol.type; + } else { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); + } + } + } + } + } + + if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + isImplicitAny = true; + } + + if (isImplicitAny && this.compilationSettings.noImplicitAny()) { + var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); + if (functionExpressionName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); + } + } + + if (canTypeCheckAST) { + this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { + var compilerReservedName = getCompilerReservedName(name); + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; + + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; + + case 3 /* arguments */: + this.checkArgumentsCollides(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; + } + }; + + PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { + var enclosingAST = this.getASTForDecl(someFunctionDecl); + var nodeType = enclosingAST.kind(); + + 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); + } 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 */) { + var constructorDeclaration = enclosingAST; + 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 */) { + var functionExpression = enclosingAST; + return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); + } + + return false; + }; + + PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { + if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); + } + } + } + }; + + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + 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)); + } + } + } + } + }; + + PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { + var decl = this.semanticInfoChain.getDeclForAST(ast); + + if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + var nameText = name.valueText(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); + } + } + }; + + PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); + TypeScript.Debug.assert(interfaceDecl); + + var interfaceSymbol = interfaceDecl.getSymbol(); + TypeScript.Debug.assert(interfaceSymbol); + + if (objectType.typeMembers) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = objectType.typeMembers; + + for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { + memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); + memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (this.canTypeCheckAST(objectType, context)) { + this.typeCheckObjectTypeTypeReference(objectType, context); + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { + this.setTypeChecked(objectType, context); + var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); + var objectTypeSymbol = objectTypeDecl.getSymbol(); + + this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); + }; + + PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { + return this.resolveTypeReference(typeAnnotation.type, context); + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { + if (typeRef === null) { + return null; + } + + TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); + + var aliasType = null; + var type = this.computeTypeReferenceSymbol(typeRef, context); + + if (type.kind === 4 /* Container */) { + var container = type; + var instanceSymbol = container.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + if (aliasType) { + this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); + } + } + + if (type && !type.isError()) { + 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 { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); + } + } + } + + if (this.canTypeCheckAST(typeRef, context)) { + this.setTypeChecked(typeRef, context); + } + + 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 */: + return this.semanticInfoChain.anyTypeSymbol; + case 61 /* BooleanKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + case 67 /* NumberKeyword */: + return this.semanticInfoChain.numberTypeSymbol; + case 69 /* StringKeyword */: + return this.semanticInfoChain.stringTypeSymbol; + case 41 /* VoidKeyword */: + return this.semanticInfoChain.voidTypeSymbol; + } + + var typeDeclSymbol = null; + + if (term.kind() === 11 /* IdentifierName */) { + typeDeclSymbol = this.resolveTypeNameExpression(term, context); + } else if (term.kind() === 123 /* FunctionType */) { + var functionType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); + } else if (term.kind() === 125 /* ConstructorType */) { + var constructorType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); + } else if (term.kind() === 122 /* ObjectType */) { + typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); + } else if (term.kind() === 126 /* GenericType */) { + typeDeclSymbol = this.resolveGenericTypeReference(term, context); + } else if (term.kind() === 121 /* QualifiedName */) { + typeDeclSymbol = this.resolveQualifiedName(term, context); + } else if (term.kind() === 14 /* StringLiteral */) { + 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, enclosingDecl.semanticInfoChain); + typeDeclSymbol.addDeclaration(decl); + } else if (term.kind() === 127 /* TypeQuery */) { + var typeQuery = term; + + var typeQueryTerm = typeQuery.name; + + var valueSymbol = this.resolveAST(typeQueryTerm, false, context); + + if (valueSymbol && valueSymbol.isAlias()) { + if (valueSymbol.assignedValue()) { + valueSymbol = valueSymbol.assignedValue(); + } else { + var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(); + } + } else if (term.kind() === 124 /* ArrayType */) { + var arrayType = term; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); + } else { + throw TypeScript.Errors.invalidOperation("unknown type"); + } + + if (!typeDeclSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); + return this.getNewErrorTypeSymbol(); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { + 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveParameterList = function (list, context) { + return this.resolveSeparatedList(list.parameters, context); + }; + + PullTypeResolver.prototype.resolveParameter = function (parameter, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { + var enumDeclaration = enumElement.parent.parent; + var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); + var symbol = decl.getSymbol(); + this.resolveDeclaredSymbol(symbol, context); + + return symbol; + }; + + PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { + if (this.canTypeCheckAST(clause, context)) { + this.setTypeChecked(clause, context); + } + + return this.resolveAST(clause.value, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + } else { + if (declSymbol.inResolution) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + + if (!declSymbol.type || !declSymbol.type.isError()) { + declSymbol.startResolving(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + if (!hasTypeExpr) { + this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + } + + if (!(hasTypeExpr || init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { + defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + } + } + + if (this.canTypeCheckAST(varDeclOrParameter, context)) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); + } + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (varDeclOrParameter.kind() === 243 /* EnumElement */) { + var result = this.getEnumTypeSymbol(varDeclOrParameter, context); + declSymbol.type = result; + return result; + } + + if (!typeExpr) { + return null; + } + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var typeExprSymbol = this.resolveTypeReference(typeExpr, context); + + if (!typeExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + declSymbol.type = this.getNewErrorTypeSymbol(); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = typeExprSymbol.getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } 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(); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + } + + return typeExprSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { + if (!init) { + return null; + } + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + if (typeExprSymbol) { + context.pushNewContextualType(typeExprSymbol); + } + + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); + + if (typeExprSymbol) { + context.popAnyContextualType(); + } + + if (!initExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + + if (!hasTypeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + var initTypeSymbol = initExprSymbol.type; + + if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); + context.setTypeInContext(declSymbol, widenedInitTypeSymbol); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny()) { + 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 initTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var _this = this; + this.setTypeChecked(varDeclOrParameter, context); + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + + if (hasTypeExpr || init) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = typeExprSymbol.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); + } + } + } + } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { + var wrapperDecl = this.getEnclosingDecl(decl); + 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])); + } else if (wrapperDecl.kind === 65536 /* Method */) { + var parentDecl = wrapperDecl.getParentDecl(); + + if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); + } 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 (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 */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } + } + } + + 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_only_allowed_in_implementation)); + } + } + 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 */)) { + this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); + } + }; + + PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { + return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; + }; + + PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { + var enclosingDecl = this.getEnclosingDeclForAST(superAST); + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); + + if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { + 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; + if (!block) { + return; + } + } + } + + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + if (parents.length) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); + } + } + }; + + PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { + if (isDeclaration) { + var decl = this.semanticInfoChain.getDeclForAST(_thisAST); + if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + return; + } + } + + var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + var declPath = enclosingDecl.getParentPath(); + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + continue; + } + + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); + } + break; + } + } + }; + + PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { + this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + 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) { + return; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + }; + + PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { + this.setTypeChecked(typeParameterAST, 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) { + if (this.canTypeCheckAST(constraint, context)) { + this.setTypeChecked(constraint, context); + } + + return this.resolveTypeReference(constraint.type, context); + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatementsExpressions = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, walker) { + var go = true; + + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); + go = false; + break; + + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, walker) { + switch (ast.kind()) { + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + if (block) { + TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + } else { + returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + } + + if (!returnStatementsExpressions.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnExpressions = []; + + for (var i = 0; i < returnStatementsExpressions.length; i++) { + var returnExpression = returnStatementsExpressions[i].expression; + if (returnExpression) { + var returnType = this.resolveAST(returnExpression, useContextualType, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { + this.setSymbolForAST(returnExpression.parent, returnType, context); + } + } + + returnExpressionSymbols.push(returnType); + returnExpressions.push(returnExpression); + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); + var returnType = bestCommonReturnType; + var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = returnType.widenedType(this, returnExpression, context); + signature.returnType = newReturnType; + + if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); + } + + if (this.compilationSettings.noImplicitAny()) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName === "") { + functionName = enclosingDecl.getFunctionExpressionName(); + } + + if (functionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } + + if (!functionSymbol.type && functionSymbol.isAccessor()) { + functionSymbol.type = signature.returnType; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { + var _this = this; + this.setTypeChecked(funcDeclAST, context); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { + var _this = this; + if (constructorDecl.block) { + var foundSuperCall = false; + var pre = function (ast, walker) { + 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; + } + } + }; + + TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); + return foundSuperCall; + } + + return false; + }; + + 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(parameters, false, context); + + this.resolveAST(block, false, context); + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + this.validateVariableDeclarationGroups(funcDecl, context); + + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); + + if (funcDecl.kind === 16384 /* Function */) { + this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); + } + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + this.resolveAST(funcDeclAST.parameter, false, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); + var stringIndexSignature = allIndexSignatures.stringSignature; + var numberIndexSignature = allIndexSignatures.numericSignature; + var isNumericIndexer = numberIndexSignature === signature; + + if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { + var comparisonInfo = new TypeComparisonInfo(); + + 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + } + } + } + + var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); + for (var i = 0; i < allMembers.length; i++) { + var member = allMembers[i]; + var name = member.name; + if (name || (member.kind === 4096 /* Property */ && name === "")) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], context); + } + + if (parentSymbol !== allMembers[i].getContainer()) { + var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); + var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; + var onlyStringIndexerIsPresent = !numberIndexSignature; + + if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { + var comparisonInfo = new TypeComparisonInfo(); + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); + } + } + } + } + } + }); + }; + + PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { + this.checkThisCaptureVariableCollides(funcDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { + var returnTypeSymbol = null; + + if (returnTypeAnnotation) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + } else { + var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } + + return returnTypeSymbol; + }; + + 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + return funcSymbol; + } + + if (!signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + 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(); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveIndexSignature(ast.indexSignature, context); + }; + + PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + return funcSymbol; + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.typeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.parameter) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + this.resolveParameter(funcDeclAST.parameter, context); + context.inTypeCheck = prevInTypeCheck; + } + + if (funcDeclAST.typeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + + context.inTypeCheck = prevInTypeCheck; + } + + if (returnTypeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { + if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { + 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; + if (funcDeclASTName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } + } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { + if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); + } + + return null; + }; + + 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.ASTHelpers.getType(parameter), context); + } + + return null; + }; + + PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + + if (accessorSymbol.inResolution) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + accessorSymbol.setResolved(); + + return accessorSymbol; + } + + if (accessorSymbol.isResolved) { + if (!accessorSymbol.type) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else { + var getterSymbol = accessorSymbol.getGetter(); + var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; + var hasGetter = getterSymbol !== null; + + var setterSymbol = accessorSymbol.getSetter(); + var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; + var hasSetter = setterSymbol !== null; + + var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); + var getterHasTypeAnnotation = getterAnnotatedType !== null; + + var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); + var setterHasTypeAnnotation = setterAnnotatedType !== null; + + accessorSymbol.startResolving(); + + if (hasGetter) { + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + } + + if (hasSetter) { + setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); + } + + if (hasGetter && hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + var getterSig = getterSymbol.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { + getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; + getterSig.returnType = setterSuppliedTypeSymbol; + } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { + setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; + + if (setterHasParameters) { + setterParameters[0].type = getterSuppliedTypeSymbol; + } + } + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + accessorSymbol.type = this.getNewErrorTypeSymbol(); + } else { + accessorSymbol.type = getterSuppliedTypeSymbol; + } + } else if (hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + + accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; + } else { + var getterSig = getterSymbol.type.getCallSignatures()[0]; + accessorSymbol.type = getterSig.returnType; + } + + accessorSymbol.setResolved(); + } + + if (this.canTypeCheckAST(funcDeclAst, context)) { + this.typeCheckAccessorDeclaration(funcDeclAst, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { + this.setTypeChecked(funcDeclAst, context); + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + var getterSymbol = accessorSymbol.getGetter(); + var setterSymbol = accessorSymbol.getSetter(); + + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; + if (isGetter) { + var getterFunctionDeclarationAst = funcDeclAst; + context.pushNewContextualType(getterSymbol.type); + this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); + context.popAnyContextualType(); + } else { + var setterFunctionDeclarationAst = funcDeclAst; + this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); + } + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return getterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return getterSymbol; + } + + signature.startResolving(); + + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + if (!setterAnnotatedType) { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } else { + signature.returnType = setterAnnotatedType; + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + return getterSymbol; + }; + + PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + if (getter && setter) { + var getterAST = getter.getDeclarations()[0].ast(); + var setterAST = setter.getDeclarations()[0].ast(); + + if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { + var setterSig = setter.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + + var getter = accessorSymbol.getGetter(); + var getterSig = getter.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterParameters[0].type; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + var funcNameAST = funcDeclAST.propertyName; + + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); + } + + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); + var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + 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.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; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return setterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + signature.setResolved(); + return setterSymbol; + } + + signature.startResolving(); + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + } + + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + + if (!hadError) { + signature.setResolved(); + } + } + + return setterSymbol; + }; + + PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + if (funcDeclAST.parameterList) { + for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + + var getter = accessorSymbol.getGetter(); + + var funcNameAST = funcDeclAST.propertyName; + + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); + var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + if (getterIsPrivate !== setterIsPrivate) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); + } + + this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); + } else { + if (this.compilationSettings.noImplicitAny()) { + var setterFunctionDeclarationAst = funcDeclAST; + 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + }; + + PullTypeResolver.prototype.resolveList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.childCount(); i < n; i++) { + this.resolveAST(list.childAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.resolveAST(list.nonSeparatorAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLogicalOperation(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { + this.setTypeChecked(binex, context); + + var leftType = this.resolveAST(binex.left, false, context).type; + var rightType = this.resolveAST(binex.right, false, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(binex); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ + TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), + leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); + } + }; + + PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.operand, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckUnaryArithmeticOperation(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckPostfixUnaryExpression(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { + return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); + }; + + PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + return; + } + + TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { + if (this.canTypeCheckAST(binaryExpression, context)) { + this.typeCheckBinaryArithmeticExpression(binaryExpression, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } + + if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } + + var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); + var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); + + if (!rhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!lhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (lhsIsFit && rhsIsFit) { + switch (binaryExpression.kind()) { + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + if (!this.isReference(binaryExpression.left, lhsSymbol)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); + } + } + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInstanceOfExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); + var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); + 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_of_a_type_assignable_to_the_Function_interface_type)); + } + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { + if (this.canTypeCheckAST(commaExpression, context)) { + this.setTypeChecked(commaExpression, context); + + this.resolveAST(commaExpression.left, false, context); + } + + return this.resolveAST(commaExpression.right, false, context).type; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; + + var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); + + if (!isValidLHS) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); + } + + if (!isValidRHS) { + 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)); + } + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.variableDeclaration, false, context); + this.resolveAST(ast.initializer, false, context); + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.incrementor, false, context); + this.resolveAST(ast.statement, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { + if (this.canTypeCheckAST(forInStatement, context)) { + this.typeCheckForInStatement(forInStatement, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { + this.setTypeChecked(forInStatement, context); + + if (forInStatement.variableDeclaration) { + var declaration = forInStatement.variableDeclaration; + + 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); + + 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 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)); + } + + this.resolveAST(forInStatement.statement, false, context); + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWhileStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckDoStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckIfStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + this.resolveAST(ast.elseClause, false, context); + }; + + PullTypeResolver.prototype.resolveElseClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckElseClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.statements, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declaration, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declarators, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWithStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var withStatement = ast; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckTryStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var tryStatement = ast; + + this.resolveAST(tryStatement.block, false, context); + this.resolveAST(tryStatement.catchClause, false, context); + this.resolveAST(tryStatement.finallyClause, false, context); + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckCatchClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + + var catchDecl = this.semanticInfoChain.getDeclForAST(ast); + this.validateVariableDeclarationGroups(catchDecl, context); + }; + + PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckFinallyClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + }; + + PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + while (enclosingDecl) { + if (enclosingDecl.kind & 1032192 /* SomeFunction */) { + return enclosingDecl; + } + + enclosingDecl = enclosingDecl.getParentDecl(); + } + + return null; + }; + + PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var isContextuallyTyped = false; + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); + if (returnTypeAnnotationSymbol) { + isContextuallyTyped = true; + context.pushNewContextualType(returnTypeAnnotationSymbol); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + isContextuallyTyped = true; + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); + } + } + } + } + + var result = this.resolveAST(expression, isContextuallyTyped, context).type; + if (isContextuallyTyped) { + context.popAnyContextualType(); + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { + if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingFunction.getParentDecl(); + if (classDecl) { + var classSymbol = classDecl.getSymbol(); + this.resolveDeclaredSymbol(classSymbol, context); + + var comparisonInfo = new TypeComparisonInfo(); + var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); + if (!isAssignable) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); + } + } + } + + if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); + } + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { + var signatureSymbol = enclosingFunction.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (expressionType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + this.resolveDeclaredSymbol(expressionType, context); + this.resolveDeclaredSymbol(sigReturnType, context); + + var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); + } + } + } + } + } + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { + var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var returnType = this.getSymbolForAST(returnAST, context); + var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); + if (!returnType || canTypeCheckAST) { + var returnExpr = returnAST.expression; + + var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); + + if (!returnType) { + returnType = resolvedReturnType; + this.setSymbolForAST(returnAST, resolvedReturnType, context); + } + + if (returnExpr && canTypeCheckAST) { + this.setTypeChecked(returnExpr, context); + this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSwitchStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var expressionType = this.resolveAST(ast.expression, false, context).type; + + for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { + var switchClause = ast.switchClauses.childAt(i); + if (switchClause.kind() === 233 /* CaseSwitchClause */) { + var caseSwitchClause = switchClause; + + var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; + this.resolveAST(caseSwitchClause.statements, false, context); + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); + } + } + } else { + var defaultSwitchClause = switchClause; + this.resolveAST(defaultSwitchClause.statements, false, context); + } + } + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLabeledStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var labelIdentifier = ast.identifier.valueText(); + + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + 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); + }; + + PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { + switch (statement.kind()) { + case 160 /* LabeledStatement */: + return this.labelIsOnContinuableConstruct(statement.statement); + + case 158 /* WhileStatement */: + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 161 /* DoStatement */: + return true; + + default: + return false; + } + }; + + PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckContinueStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.isIterationStatement = function (ast) { + switch (ast.kind()) { + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 158 /* WhileStatement */: + case 161 /* DoStatement */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { + switch (ast.kind()) { + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 129 /* FunctionDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 241 /* FunctionPropertyAssignment */: + case 137 /* ConstructorDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.inSwitchStatement = function (ast) { + while (ast) { + if (ast.kind() === 151 /* SwitchStatement */) { + return true; + } + + if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { + while (ast) { + if (this.isIterationStatement(ast)) { + return true; + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { + var result = []; + + ast = ast.parent; + while (ast) { + if (ast.kind() === 160 /* LabeledStatement */) { + var labeledStatement = ast; + if (breakable) { + result.push(labeledStatement); + } else { + if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { + result.push(labeledStatement); + } + } + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + break; + } + + ast = ast.parent; + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + 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.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var continuableLabels = this.getEnclosingLabels(ast, false, true); + + 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)); + } + } + } + }; + + PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckBreakStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + if (ast.identifier) { + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var breakableLabels = this.getEnclosingLabels(ast, true, true); + 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, 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)); + } + } + }; + + PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { + if (!ast) { + return; + } + + var symbol = this.getSymbolForAST(ast, context); + if (symbol && symbol.isResolved) { + this.typeCheckAST(ast, isContextuallyTyped, context); + return symbol; + } + + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + + var nodeType = ast.kind(); + + switch (nodeType) { + case 124 /* ArrayType */: + case 126 /* GenericType */: + case 122 /* ObjectType */: + case 127 /* TypeQuery */: + case 125 /* ConstructorType */: + case 123 /* FunctionType */: + return this.resolveTypeReference(ast, context); + + case 1 /* List */: + return this.resolveList(ast, context); + + case 2 /* SeparatedList */: + return this.resolveSeparatedList(ast, context); + + case 120 /* SourceUnit */: + return this.resolveSourceUnit(ast, context); + + case 132 /* EnumDeclaration */: + return this.resolveEnumDeclaration(ast, context); + + case 130 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 128 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 131 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 224 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, context); + + case 136 /* MemberVariableDeclaration */: + return this.resolveMemberVariableDeclaration(ast, context); + + case 225 /* VariableDeclarator */: + return this.resolveVariableDeclarator(ast, context); + + case 141 /* PropertySignature */: + return this.resolvePropertySignature(ast, context); + + case 227 /* ParameterList */: + return this.resolveParameterList(ast, context); + + case 242 /* Parameter */: + return this.resolveParameter(ast, context); + + case 243 /* EnumElement */: + return this.resolveEnumElement(ast, context); + + case 232 /* EqualsValueClause */: + return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); + + case 238 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 239 /* Constraint */: + return this.resolveConstraint(ast, context); + + case 133 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 240 /* SimplePropertyAssignment */: + return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); + + case 241 /* FunctionPropertyAssignment */: + return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); + + case 121 /* QualifiedName */: + return this.resolveQualifiedName(ast, context); + + case 137 /* ConstructorDeclaration */: + return this.resolveConstructorDeclaration(ast, context); + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return this.resolveAccessorDeclaration(ast, context); + + case 138 /* IndexMemberDeclaration */: + return this.resolveIndexMemberDeclaration(ast, context); + + case 144 /* IndexSignature */: + return this.resolveIndexSignature(ast, context); + + case 135 /* MemberFunctionDeclaration */: + return this.resolveMemberFunctionDeclaration(ast, context); + + case 142 /* CallSignature */: + return this.resolveCallSignature(ast, context); + + case 143 /* ConstructSignature */: + return this.resolveConstructSignature(ast, context); + + case 145 /* MethodSignature */: + return this.resolveMethodSignature(ast, context); + + 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); + + case 219 /* SimpleArrowFunctionExpression */: + return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 214 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + + case 35 /* ThisKeyword */: + return this.resolveThisExpression(ast, context); + + case 50 /* SuperKeyword */: + return this.resolveSuperExpression(ast, context); + + case 213 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, context); + + case 216 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, context); + + case 220 /* CastExpression */: + return this.resolveCastExpression(ast, context); + + case 13 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + + case 14 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + + case 32 /* NullKeyword */: + return this.semanticInfoChain.nullTypeSymbol; + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + + case 172 /* VoidExpression */: + return this.resolveVoidExpression(ast, context); + + case 174 /* AssignmentExpression */: + return this.resolveAssignmentExpression(ast, context); + + case 167 /* LogicalNotExpression */: + return this.resolveLogicalNotExpression(ast, context); + + case 193 /* NotEqualsWithTypeConversionExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 197 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, context); + + case 208 /* AddExpression */: + case 175 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, context); + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, context); + + case 210 /* PostIncrementExpression */: + case 211 /* PostDecrementExpression */: + return this.resolvePostfixUnaryExpression(ast, context); + + case 209 /* SubtractExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 189 /* BitwiseOrExpression */: + case 191 /* BitwiseAndExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, context); + + case 221 /* ElementAccessExpression */: + return this.resolveElementAccessExpression(ast, context); + + case 187 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); + + case 188 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, context); + + case 171 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, context); + + case 170 /* DeleteExpression */: + return this.resolveDeleteExpression(ast, context); + + case 186 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, isContextuallyTyped, context); + + case 12 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 217 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, context); + + case 200 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, context); + + case 173 /* CommaExpression */: + return this.resolveCommaExpression(ast, context); + + case 201 /* InExpression */: + return this.resolveInExpression(ast, context); + + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; + } + + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); + }; + + PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { + if (!this.canTypeCheckAST(ast, context)) { + return; + } + + var nodeType = ast.kind(); + switch (nodeType) { + case 120 /* SourceUnit */: + this.typeCheckSourceUnit(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.typeCheckEnumDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.typeCheckModuleDeclaration(ast, context); + return; + + case 128 /* InterfaceDeclaration */: + this.typeCheckInterfaceDeclaration(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.typeCheckClassDeclaration(ast, context); + return; + + case 243 /* EnumElement */: + this.typeCheckEnumElement(ast, context); + return; + + case 136 /* MemberVariableDeclaration */: + this.typeCheckMemberVariableDeclaration(ast, context); + return; + + case 225 /* VariableDeclarator */: + this.typeCheckVariableDeclarator(ast, context); + return; + + case 141 /* PropertySignature */: + this.typeCheckPropertySignature(ast, context); + return; + + case 242 /* Parameter */: + this.typeCheckParameter(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.typeCheckImportDeclaration(ast, context); + return; + + case 215 /* ObjectLiteralExpression */: + this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 241 /* FunctionPropertyAssignment */: + this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); + return; + + case 11 /* IdentifierName */: + if (isTypesOnlyLocation(ast)) { + this.resolveTypeNameExpression(ast, context); + } else { + this.resolveNameExpression(ast, context); + } + return; + + case 212 /* MemberAccessExpression */: + this.resolveMemberAccessExpression(ast, context); + return; + + case 121 /* QualifiedName */: + this.resolveQualifiedName(ast, context); + return; + + case 222 /* FunctionExpression */: + 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); + break; + + case 142 /* CallSignature */: + this.typeCheckCallSignature(ast, context); + return; + + case 143 /* ConstructSignature */: + this.typeCheckConstructSignature(ast, context); + return; + + case 129 /* FunctionDeclaration */: { + var funcDecl = ast; + 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, isContextuallyTyped, context); + return; + + case 218 /* ParenthesizedArrowFunctionExpression */: + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 214 /* ArrayLiteralExpression */: + this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 213 /* InvocationExpression */: + this.typeCheckInvocationExpression(ast, context); + return; + + case 216 /* ObjectCreationExpression */: + this.typeCheckObjectCreationExpression(ast, context); + return; + + case 150 /* ReturnStatement */: + this.resolveReturnStatement(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); + } + }; + + PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { + while (this.postTypeCheckWorkitems.length) { + var ast = this.postTypeCheckWorkitems.pop(); + this.postTypeCheck(ast, context); + } + }; + + PullTypeResolver.prototype.postTypeCheck = function (ast, context) { + var nodeType = ast.kind(); + + switch (nodeType) { + case 242 /* Parameter */: + case 225 /* VariableDeclarator */: + this.postTypeCheckVariableDeclaratorOrParameter(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.postTypeCheckClassDeclaration(ast, context); + return; + + case 129 /* FunctionDeclaration */: + this.postTypeCheckFunctionDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.postTypeCheckModuleDeclaration(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.postTypeCheckEnumDeclaration(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.postTypeCheckImportDeclaration(ast, context); + return; + + case 11 /* IdentifierName */: + this.postTypeCheckNameExpression(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); + } + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { + this.checkThisCaptureVariableCollides(nameAST, false, context); + }; + + PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { + this.setTypeChecked(nameAST, context); + this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { + var nameSymbol = this.getSymbolForAST(nameAST, context); + var foundCached = nameSymbol !== null; + + if (!foundCached || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.typeCheckNameExpression(nameAST, context); + } + nameSymbol = this.computeNameExpression(nameAST, context); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + 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.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; + } + + var nameSymbol = null; + var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); + } + + 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) { + 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]; + var nameParentDecl = nameDeclaration.getParentDecl(); + if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { + var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); + var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); + + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); + + if (currentParameterIndex >= 0) { + var matchingParameter; + if (parameterList) { + for (var i = 0; i <= currentParameterIndex; i++) { + var candidateParameter = parameterList.parameters.nonSeparatorAt(i); + if (candidateParameter && candidateParameter.identifier.valueText() === id) { + matchingParameter = candidateParameter; + break; + } + } + } + + 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); + } + } + } + + var aliasSymbol = null; + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + if (!this.inTypeQuery(nameAST)) { + aliasSymbol.setIsUsedAsValue(); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); + + var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); + if (parameterList) { + while (parameter && parameter.parent) { + if (parameter.parent.parent === parameterList) { + return parameterList.parameters.nonSeparatorIndexOf(parameter); + } + + parameter = parameter.parent; + } + } + + return -1; + }; + + PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { + var symbol = this.getSymbolForAST(dottedNameAST, context); + var foundCached = symbol !== null; + + if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheckDottedNameAST) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); + } + + this.resolveDeclaredSymbol(symbol, context); + + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(name, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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)) { + lhsAlias.setIsUsedAsValue(); + } + lhsType = lhsAlias.getExportAssignedTypeSymbol(); + } + + if (lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); + return this.getNewErrorTypeSymbol(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); + + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { + var instanceSymbol = lhsType.getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); + + if (!nameSymbol) { + if (lhsType.kind === 32 /* DynamicModule */) { + var container = lhsType; + var associatedInstance = container.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); + } + } + + 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + } + + if (checkSuperPrivateAndStaticAccess) { + this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST, context); + + if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.setTypeChecked(nameAST, context); + } + typeNameSymbol = this.computeTypeNameExpression(nameAST, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + this.resolveDeclaredSymbol(typeNameSymbol, context); + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { + var id = nameAST.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(nameAST); + + var declPath = enclosingDecl.getParentPath(); + + var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); + + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + this.resolveDeclaredSymbol(typeNameSymbol, context); + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + this.resolveDeclaredSymbol(aliasedType, context); + } + + if (typeNameSymbol.isTypeParameter()) { + if (this.isInStaticMemberContext(enclosingDecl)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); + return this.getNewErrorTypeSymbol(); + } + } + } + + if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { + typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); + } + + 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; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, context); + } + + 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()) { + for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + + if (typeArgs[i].isError()) { + typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + } + + 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(); + } + + if (!genericTypeSymbol.isResolved) { + var typeDecls = genericTypeSymbol.getDeclarations(); + var childDecls = null; + + for (var i = 0; i < typeDecls.length; i++) { + childDecls = typeDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + + var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); + + var typeConstraint = null; + var upperBound = null; + + typeParameters = specializedSymbol.getTypeParameters(); + + var typeConstraintSubstitutionMap = []; + var typeArg = null; + + var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < typeParameters.length; i++) { + typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + for (var id in instantiatedSubstitutionMap) { + typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; + } + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] === typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } else if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); + } + + if (typeArg.isTypeParameter()) { + upperBound = typeArg.getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + 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)])); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { + if (this.inTypeQuery(dottedNameAST)) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; + } + + var symbol = this.getSymbolForAST(dottedNameAST, context); + if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheck) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeQualifiedName(dottedNameAST, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + this.resolveDeclaredSymbol(symbol, context); + + 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) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); + var lhs = this.resolveAST(dottedNameAST.left, false, context); + + var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; + + if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { + if (lhs.isAlias()) { + lhs.setIsUsedAsValue(); + } + } + + if (!lhsType) { + return this.getNewErrorTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); + var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; + + 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & 164 /* SomeContainer */) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { + if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { + return false; + } + + if (returnTypeAnnotation) { + return false; + } + + if (parameters) { + for (var i = 0, n = parameters.length; i < n; i++) { + if (parameters.typeAt(i)) { + return false; + } + } + } + + var contextualFunctionTypeSymbol = context.getContextualType(); + + if (contextualFunctionTypeSymbol) { + this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); + var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; + if (!exactlyOneCallSignature) { + return false; + } + + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; + return !callSignatureIsGeneric; + } + + return false; + }; + + PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { + var funcDeclSymbol = null; + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { + return funcDeclSymbol; + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + TypeScript.Debug.assert(funcDeclSymbol); + + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.propagateContextualType(returnType); + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); + context.popAnyContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + var functionExpressionName = functionDecl.getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); + } + } + + context.setTypeInContext(funcDeclSymbol, funcDeclType); + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); + } + + return funcDeclSymbol; + }; + + 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + var returnTypeSymbol = signature.returnType; + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + 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.popAnyContextualType(); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); + + this.validateVariableDeclarationGroups(functionDecl, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { + var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); + var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; + + if (this.canTypeCheckAST(thisExpression, context)) { + this.typeCheckThisExpression(thisExpression, context, enclosingDecl); + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.inTypeArgumentList = function (ast) { + var previous = null; + var current = ast; + + while (current) { + switch (current.kind()) { + case 126 /* GenericType */: + var genericType = current; + if (genericType.typeArgumentList === previous) { + return true; + } + break; + + case 226 /* ArgumentList */: + var argumentList = current; + return argumentList.typeArgumentList === previous; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { + while (ast) { + switch (ast.kind()) { + case 230 /* ExtendsHeritageClause */: + var heritageClause = ast; + + return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inTypeQuery = function (ast) { + while (ast) { + switch (ast.kind()) { + case 127 /* TypeQuery */: + return true; + case 129 /* FunctionDeclaration */: + case 213 /* InvocationExpression */: + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 213 /* InvocationExpression */: + var invocationExpression = current; + if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + break; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inConstructorParameterList = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } + + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + 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 */) { + return true; + } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { + this.checkForThisCaptureInArrowFunction(thisExpression); + + if (this.inConstructorParameterList(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); + return; + } + + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { + return; + } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + if (currentDecl.getParentDecl() === null) { + return; + } else { + 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)); + } + + return; + } else if (currentDecl.kind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); + } + + return; + } + } + }; + + PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var isStaticContext = false; + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + return null; + } else if (declKind === 16384 /* Function */) { + return null; + } else if (declKind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(ast)) { + return this.getNewErrorTypeSymbol(); + } else { + var classSymbol = decl.getSymbol(); + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + return constructorSymbol.type; + } else { + return classSymbol; + } + } + } + } + } + + return null; + }; + + PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { + return true; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + var superType = this.semanticInfoChain.anyTypeSymbol; + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); + + if (classSymbol) { + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSuperExpression(ast, context, enclosingDecl); + } + + return superType; + }; + + PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { + this.setTypeChecked(ast, context); + + this.checkForThisCaptureInArrowFunction(ast); + + var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; + var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; + TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); + + if (isSuperPropertyAccess) { + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + break; + } else if (currentDecl.kind === 8 /* Class */) { + if (!this.enclosingClassIsDerived(currentDecl)) { + 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 if (this.inStaticMemberVariableDeclaration(ast)) { + break; + } + + 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 { + 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)); + } + } + }; + + PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { + return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (this.canTypeCheckAST(expressionAST, context)) { + this.setTypeChecked(expressionAST, context); + } + symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { + var boundMemberSymbols = []; + var memberSymbol; + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var id = this.getPropertyAssignmentName(propertyAssignment); + var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); + + var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; + var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); + TypeScript.Debug.assert(decl); + + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + if (!isUsingExistingSymbol) { + memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } else { + memberSymbol = decl.getSymbol(); + } + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + memberSymbol = decl.getSymbol(); + } else { + TypeScript.Debug.assert(isAccessor); + memberSymbol = decl.getSymbol(); + } + + if (!isUsingExistingSymbol && !isAccessor) { + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); + } + + objectLiteralTypeSymbol.addMember(memberSymbol); + } + + boundMemberSymbols.push(memberSymbol); + } + + return boundMemberSymbols; + }; + + PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var acceptedContextualType = false; + var assigningSymbol = null; + + var id = this.getPropertyAssignmentName(propertyAssignment); + var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; + + if (objectLiteralContextualType) { + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + + if (!assigningSymbol) { + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + assigningSymbol = numericIndexerSignature; + } else if (stringIndexerSignature) { + assigningSymbol = stringIndexerSignature; + } + } + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); + + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = contextualMemberType; + } + } + } + + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; + + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { + objectLiteralTypeSymbol.setHasGenericMember(); + } + + if (stringIndexerSignature) { + allMemberTypes.push(memberSymbolType); + } + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + allNumericMemberTypes.push(memberSymbolType); + } + } + + if (acceptedContextualType) { + pullTypeContext.popAnyContextualType(); + } + + var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; + if (!memberSymbol.isResolved) { + if (isAccessor) { + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); + } else { + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); + memberSymbol.setResolved(); + + this.setSymbolForAST(id, memberSymbol, pullTypeContext); + } + } + } + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { + var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); + TypeScript.Debug.assert(objectLitDecl); + + var typeSymbol = this.getSymbolForAST(objectLitAST, context); + var isUsingExistingSymbol = !!typeSymbol; + + if (!typeSymbol) { + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); + typeSymbol.addDeclaration(objectLitDecl); + this.setSymbolForAST(objectLitAST, typeSymbol, context); + objectLitDecl.setSymbol(typeSymbol); + } + + var propertyAssignments = objectLitAST.propertyAssignments; + var contextualType = null; + + if (isContextuallyTyped) { + contextualType = context.getContextualType(); + this.resolveDeclaredSymbol(contextualType, context); + } + + var stringIndexerSignature = null; + var numericIndexerSignature = null; + var allMemberTypes = null; + var allNumericMemberTypes = null; + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + + stringIndexerSignature = indexSignatures.stringSignature; + numericIndexerSignature = indexSignatures.numericSignature; + + var inInferentialTyping = context.isInferentiallyTyping(); + if (stringIndexerSignature) { + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; + } + + if (numericIndexerSignature) { + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; + } + } + + if (propertyAssignments) { + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); + + this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); + + if (!isUsingExistingSymbol) { + this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); + this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { + return propertyAssignment.propertyName; + } else { + TypeScript.Debug.assert(false); + } + }; + + PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { + if (contextualIndexSignature) { + var typeCollection = { + getLength: function () { + return indexerTypeCandidates.length; + }, + getTypeAtIndex: function (index) { + return indexerTypeCandidates[index]; + } + }; + var decl = objectLiteralSymbol.getDeclarations()[0]; + 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); + } + } + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { + var symbol = this.getSymbolForAST(arrayLit, context); + if (!symbol || this.canTypeCheckAST(arrayLit, context)) { + if (this.canTypeCheckAST(arrayLit, context)) { + this.setTypeChecked(arrayLit, context); + } + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { + var elements = arrayLit.expressions; + var elementType = null; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, context); + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + if (indexSignatures.numericSignature) { + contextualElementType = indexSignatures.numericSignature.returnType; + } + } + } + + if (elements) { + if (contextualElementType) { + context.propagateContextualType(contextualElementType); + } + + for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { + elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); + } + + if (contextualElementType) { + context.popAnyContextualType(); + } + } + + if (elementTypes.length) { + elementType = elementTypes[0]; + } + var collection; + + if (contextualElementType && !context.isInferentiallyTyping()) { + if (!elementType) { + elementType = contextualElementType; + } + + collection = { + getLength: function () { + return elements.nonSeparatorCount() + 1; + }, + getTypeAtIndex: function (index) { + return index === 0 ? contextualElementType : elementTypes[index - 1]; + } + }; + } else { + collection = { + getLength: function () { + return elements.nonSeparatorCount(); + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + } + + elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; + + if (!elementType) { + elementType = this.semanticInfoChain.undefinedTypeSymbol; + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { + var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); + + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); + } + + return symbolAndDiagnostic.symbol; + }; + + PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { + this.setTypeChecked(callEx, context); + context.postDiagnostic(symbolAndDiagnostic.diagnostic); + }; + + PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; + + var targetTypeSymbol = targetSymbol.type; + + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return { symbol: targetTypeSymbol }; + } + + var elementType = targetTypeSymbol.getElementType(); + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return { symbol: elementType }; + } + + 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); + + if (member) { + this.resolveDeclaredSymbol(member, context); + + return { symbol: member.type }; + } + } + + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); + + var stringSignature = signatures.stringSignature; + var numberSignature = signatures.numericSignature; + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; + } 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 { + symbol: this.getNewErrorTypeSymbol(), + diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) + }; + } + }; + + 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; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + if (!signature.isResolved) { + this.resolveDeclaredSymbol(signature, context); + } + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signature; + continue; + } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { + numberSignature = signature; + continue; + } + } + } + + return { + numericSignature: numberSignature, + stringSignature: stringSignature + }; + }; + + 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; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } + + 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 { + lhsType = rhsType; + } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (exprType) { + if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { + if (!this.isReference(binaryExpression.left, lhsExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, exprType, lhsType, context); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); + } + } + + if (!exprType) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { + return this.findBestCommonType({ + getLength: function () { + return 2; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + } + } + }, context); + }; + + PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { + return this.findBestCommonType({ + getLength: function () { + return 3; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + case 2: + return type3; + } + } + }, context); + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + } + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; + var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; + + 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.pushNewContextualType(leftType); + var rightType = this.resolveAST(binex.right, true, context).type; + context.popAnyContextualType(); + + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + + this.resolveAST(binex.left, false, context); + } + + return this.resolveAST(binex.right, false, context).type; + }; + + PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { + var contextualType = context.getContextualType(); + return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + } else { + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { + var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; + var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; + + var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); + + var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); + + if (this.canTypeCheckAST(trinex, context)) { + this.setTypeChecked(trinex, context); + this.resolveAST(trinex.condition, false, context); + + if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); + } + } + } + + if (!conditionalTypesAreValid) { + return this.getNewErrorTypeSymbol(); + } + + return expressionType; + }; + + PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { + return true; + } + } else { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveAST(ast.expression, false, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckInvocationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + var targetSymbol = this.resolveAST(callEx.expression, false, context); + + if (callEx.argumentList.arguments) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + + var len = callEx.argumentList.arguments.nonSeparatorCount(); + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); + return this.getNewErrorTypeSymbol(); + } + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.expression.kind() === 50 /* SuperKeyword */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + targetSymbol = targetTypeSymbol.getConstructorMethod(); + this.resolveDeclaredSymbol(targetSymbol, context); + targetTypeSymbol = targetSymbol.type; + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); + this.resolveAST(callEx.argumentList.arguments, false, context); + + return this.getNewErrorTypeSymbol(); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + 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 explicitTypeArgs = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + var triedToInferTypeArgs = false; + + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var beforeResolutionSignatures = signatures; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + + if (signatures[i].isGeneric() && typeParameters.length) { + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); + } + + 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, 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; + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + + var errorCondition = null; + if (!signatures.length) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (!couldNotFindGenericOverload) { + 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); + } + return this.semanticInfoChain.anyTypeSymbol; + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); + } else if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + } + + 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 (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; + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + this.setSymbolForAST(callEx, symbol, context); + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckObjectCreationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + this.resolveAST(callEx.expression, false, context); + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (callEx.argumentList) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + var len = callEx.argumentList.arguments.nonSeparatorCount(); + + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { + if (!context.inProvisionalResolution()) { + additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); + } + context.postDiagnostic(diagnostic); + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var explicitTypeArgs = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny()) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); + } + } + + if (constructSignatures.length) { + if (callEx.argumentList && callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var triedToInferTypeArgs; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric()) { + typeParameters = constructSignatures[i].getTypeParameters(); + + 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, explicitTypeArgs.length]); + continue; + } + } 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 { + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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(constructSignatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } else { + if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); + } else { + returnType = this.instantiateTypeToAny(returnType, context); + } + } + + if (usedCallSignaturesInstead) { + 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(); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList && callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); + + return this.getNewErrorTypeSymbol(); + }; + + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { + var typeReplacementMap = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters = signatureAToInstantiate.getTypeParameters(); + var typeConstraint = null; + + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; + var enclosingTypeParameterMap; + + if (functionTypeA) { + enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + if (functionTypeB) { + enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); + + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); + }; + + PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { + var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; + + if (this.canTypeCheckAST(assertionExpression, context)) { + this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); + } + + return typeAssertionType; + }; + + PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { + this.setTypeChecked(assertionExpression, context); + + context.pushNewContextualType(typeAssertionType); + var exprType = this.resolveAST(assertionExpression.expression, true, context).type; + context.popAnyContextualType(); + + this.resolveDeclaredSymbol(typeAssertionType, context); + this.resolveDeclaredSymbol(exprType, context); + + var comparisonInfo = new TypeComparisonInfo(); + + 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); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { + var leftExpr = this.resolveAST(binaryExpression.left, false, context); + var leftType = leftExpr.type; + + context.pushNewContextualType(leftType); + var rightType = this.resolveAST(binaryExpression.right, true, context).type; + context.popAnyContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (!this.isReference(binaryExpression.left, leftExpr)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } else { + this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); + } + } + + return rightType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { + var instanceTypeSymbol = typeToReturn.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.widenType = function (type, ast, context) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (type.isArrayNamedTypeReference()) { + 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(); + + for (var i = 0; i < len; i++) { + var candidateType = collection.getTypeAtIndex(i); + if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { + return candidateType; + } + } + + return this.semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { + for (var i = 0; i < collection.getLength(); i++) { + var otherType = collection.getTypeAtIndex(i); + if (candidateType === otherType) { + continue; + } + + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { + t1 = this.getSymbolForRelationshipCheck(t1); + t2 = this.getSymbolForRelationshipCheck(t2); + + if (t1 === t2) { + return true; + } + + if (t1 && t2) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); + } + } + + return this.typesAreIdentical(t1, t2, context); + }; + + 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); + + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; + } + + if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + 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(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return false; + } + } + + if (t1.isPrimitive() !== t2.isPrimitive()) { + return 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) { + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { + return false; + } + + return true; + }; + + 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; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length !== sg2.length) { + return false; + } + + 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; + } + } + + return true; + }; + + 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; + } + + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; + } + + 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) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0] === decls2[0]; + } + + return false; + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { + return true; + } + + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); + }; + + 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.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) { + if (symbol && symbol.isTypeReference()) { + return symbol.getReferencedTypeSymbol(); + } + + return symbol; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + source = this.getSymbolForRelationshipCheck(source); + target = this.getSymbolForRelationshipCheck(target); + + if (source === target) { + return true; + } + + if (source && target) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + } + } + + 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); + + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + var sourceApparentType = this.getApparentType(source); + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; + } + + if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + 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) { + return true; + } + + return false; + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return assignableTo; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.getIsSpecialized() && target.getIsSpecialized()) { + 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, true); + + for (var i = 0; i < sourceTypeArguments.length; i++) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { + break; + } + } + + if (i === sourceTypeArguments.length) { + return true; + } else { + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + } + } + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } + } else { + if (isComparingInstantiatedSignatures) { + target = target.getBaseConstraint(this.semanticInfoChain); + } else { + return this.typesAreIdentical(target, sourceApparentType, context); + } + } + } + + 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; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); + + this.resolveDeclaredSymbol(targetProp, context); + + var targetPropType = targetProp.type; + + 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); + + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + + 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var comparisonInfoTypeArgumentsCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); + } + 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_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_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, isRelatable); + return isRelatable; + }; + + 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)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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++) { + 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; + } + } + } + + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + }; + + 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 (comparisonInfo) { + var names = getNames(true); + var code; + if (targetPropIsPrivate) { + 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 { + 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; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (targetDecl !== sourceDecl) { + if (comparisonInfo) { + var names = getNames(true); + + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + 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; + } + } + + if (sourceProp.isOptional && !targetProp.isOptional) { + if (comparisonInfo) { + 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); + } + return false; + } + + this.resolveDeclaredSymbol(sourceProp, context); + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); + + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + var names = getNames(false); + if (comparisonInfoPropertyTypeCheck && 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 { + 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 isSourcePropertyRelatableToTargetProperty; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); + var targetStringSig = targetIndexSigs.stringSignature; + var targetNumberSig = targetIndexSigs.numericSignature; + + if (targetStringSig || targetNumberSig) { + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); + var sourceStringSig = sourceIndexSigs.stringSignature; + var sourceNumberSig = sourceIndexSigs.numericSignature; + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + 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++) { + var mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + var nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + 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; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + + return false; + } + + return true; + }; + + 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; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; + + 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, [targetParameters.length])); + } + return false; + } + + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; + } + + 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) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + + return false; + } + } + + 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 (!areParametersRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + } + + return areParametersRelatable; + }); + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { + var _this = this; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = application.argumentList ? application.argumentList.arguments : null; + + var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { + if (hasOverloads && signature.isDefinition()) { + return false; + } + + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { + return false; + } + + return _this.overloadHasCorrectArity(signature, args); + }); + + var firstAssignableButNotSupertypeSignature = null; + var firstAssignableWithProvisionalErrorsSignature = null; + + for (var i = 0; i < initialCandidates.length; i++) { + var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); + if (applicability === 3 /* Subtype */) { + return initialCandidates[i]; + } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { + firstAssignableButNotSupertypeSignature = initialCandidates[i]; + } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { + firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; + } + } + + if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { + return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; + } else { + var target = this.getCallTargetErrorSpanAST(application); + if (comparisonInfo.message) { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); + } else { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); + } + } + + return null; + }; + + PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { + return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; + }; + + PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { + if (args == null) { + return signature.nonOptionalParamCount === 0; + } + + var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); + if (numberOfArgs < signature.nonOptionalParamCount) { + return false; + } + if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { + if (args === null) { + return 3 /* Subtype */; + } + + var isInVarArg = false; + var parameters = signature.parameters; + var paramType = null; + + var overloadApplicability = 3 /* Subtype */; + + for (var i = 0; i < args.nonSeparatorCount(); i++) { + if (!isInVarArg) { + this.resolveDeclaredSymbol(parameters[i], context); + + if (parameters[i].isVarArg) { + paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); + isInVarArg = true; + } else { + paramType = parameters[i].type; + } + } + + var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); + + if (statusOfCurrentArgument === 0 /* NotAssignable */) { + return 0 /* NotAssignable */; + } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { + overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; + } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { + overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; + } + } + + return overloadApplicability; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType.isAny()) { + return 3 /* Subtype */; + } else if (paramType.isError()) { + return 1 /* AssignableButWithProvisionalErrors */; + } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrowFunction = arg; + 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.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.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 */) { + return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); + } else { + return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); + } + }; + + PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { + if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + 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.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveObjectLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType === this.cachedArrayInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveArrayLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + var argSym = this.resolveAST(arg, false, context); + + if (argSym.type.isAlias()) { + var aliasSym = argSym.type; + argSym = aliasSym.getExportAssignedTypeSymbol(); + } + + comparisonInfo.stringConstantVal = arg; + return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { + var tempComparisonInfo = new TypeComparisonInfo(); + tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; + if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { + return 3 /* Subtype */; + } + + if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { + return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; + } + + if (!comparisonInfo.message) { + var enclosingSymbol = this.getEnclosingSymbolForAST(arg); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); + } + + return 0 /* NotAssignable */; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); + + 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 (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 inferenceResultTypes; + }; + + PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { + var enclosingDecl = this.getEnclosingDeclForAST(args); + var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); + return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; + }; + + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { + if (expressionType && parameterType) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); + return; + } + } + this.relateTypeToTypeParameters(expressionType, parameterType, 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; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType.isTypeParameter()) { + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); + return; + } + + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { + return; + } + + 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.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) { + return; + } + + var expressionTypeTypeArguments = expressionType.getTypeArguments(); + var parameterTypeArguments = parameterType.getTypeArguments(); + + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { + for (var i = 0; i < expressionTypeTypeArguments.length; i++) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } + } + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { + var _this = this; + var expressionReturnType = expressionSignature.returnType; + var parameterReturnType = parameterSignature.returnType; + + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); + + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + if (objectMember) { + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); + } + } + + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); + + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; + } + + 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) { + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!typeParameters.length) { + return typeToSpecialize; + } + + var typeArguments = null; + + 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) { + typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var type = this.createInstantiatedType(typeToSpecialize, typeArguments); + + 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(); + + var resolver = semanticInfoChain.getResolver(); + var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); + + if (resolver.canTypeCheckAST(sourceUnit, context)) { + resolver.resolveAST(sourceUnit, false, context); + resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); + + while (resolver.typeCheckCallBacks.length) { + var callBack = resolver.typeCheckCallBacks.pop(); + callBack(context); + } + + resolver.processPostTypeCheckWorkItems(context); + } + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; + } + + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); + + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; + + 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) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + 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)); + } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); + } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + 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_assignable_to_any_non_specialized_signature)); + } + } + } else if (definitionSignature && definitionSignature !== signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { + var errorCode; + + 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; + } 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + var isNamedType = typeSymbol.isNamedTypeSymbol(); + + if (typeSymbol.isArrayNamedTypeReference()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); + return; + } + + if (!isNamedType) { + var typeOfSymbol = typeSymbol.getTypeOfSymbol(); + if (typeOfSymbol) { + this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); + return; + } + } + + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); + if (typars) { + for (var i = 0; i < typars.length; i++) { + this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); + } + } + + if (!isNamedType) { + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); + } + + typeSymbol.inSymbolPrivacyCheck = false; + + if (!isNamedType) { + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + 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]) { + 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(); + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } else if (symbol.kind === 128 /* TypeAlias */) { + var aliasSymbol = symbol; + symbolIsVisible = true; + aliasSymbol.setTypeUsedExternally(); + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); + } + }; + + 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; + var messageCode; + + var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; + } + } + + var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { + var typeSymbol = symbol; + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { + var _this = this; + if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; + var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; + var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); + var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); + this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { + return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); + }); + } + } + + if (!isGetter && !isIndexSignature) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var parameter = parameters.astAt(argIndex); + + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { + var _this = this; + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); + } + } + + if (block) { + var reportErrorOnReturnExpressions = function (ast, walker) { + var go = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { + TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); + + var classSymbol = classDecl.getSymbol(); + return classSymbol.getExtendedTypes().length > 0; + }; + + PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { + if (ast.kind() === 213 /* InvocationExpression */) { + var invocationExpression = ast; + if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { + if (node && node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + if (this.isSuperInvocationExpression(expressionStatement.expression)) { + return true; + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { + if (block && block.statements && block.statements.childCount() > 0) { + return block.statements.childAt(0); + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { + TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); + + if (constructorDecl) { + var enclosingClass = constructorDecl.getParentDecl(); + + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.kind() === 242 /* Parameter */) { + return true; + } + + if (ast.kind() === 136 /* MemberVariableDeclaration */) { + var variableDeclarator = ast; + if (variableDeclarator.variableDeclarator.equalsValueClause) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { + var enclosingDecl = this.getEnclosingDeclForAST(expression); + + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var inArrowFunction = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + inArrowFunction = true; + continue; + } + + if (inArrowFunction) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = decl.getSymbol().getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); + var stringSignature = indexSignatures.stringSignature; + var numberSignature = indexSignatures.numericSignature; + + if (stringSignature || numberSignature) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { + var memberSymbol = member.getSymbol(); + var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); + if (relevantSignature) { + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); + } + } + } + } + } + }; + + PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { + if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { + return numberIndexSignature; + } else if (stringIndexSignature) { + return stringIndexSignature; + } + + return null; + }; + + PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { + 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + var foundError1 = false; + var foundError2 = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName, true); + if (extendedTypeProp) { + this.resolveDeclaredSymbol(extendedTypeProp, context); + foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError1) { + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + } + + if (foundError1 || foundError2) { + foundError = true; + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); + } + + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + } + } + } + + if (foundError) { + var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); + + 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; + } + + if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + + if (associatedContainerType) { + return associatedContainerType !== typeSymbol.getRootSymbol(); + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + + var baseType = this.resolveTypeReference(baseDeclAST, context).type; + + if (!baseType) { + return; + } + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (!baseType.isError()) { + if (isExtendedType) { + if (typeDeclIsClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); + } + } + return; + } else if (typeDeclIsClass && isExtendedType) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + 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)])); + } + } + + if (baseType.hasBase(typeSymbol)) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); + return; + } + + if (isExtendedType) { + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); + } else { + TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); + + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { + var _this = this; + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); + if (!extendsClause && !implementsClause) { + return; + } + + if (extendsClause) { + for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (implementsClause) { + for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); + } + } + } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { + var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { + return decl.ast().heritageClauses !== null; + }).ast(); + if (classOrInterface === firstInterfaceASTWithExtendsClause) { + this.typeCheckCallBacks.push(function (context) { + _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); + }); + } + } + }; + + PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { + var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); + + var inheritedMembersMap = TypeScript.createIntrinsicsObject(); + var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); + + var typeHasOwnNumberIndexer = false; + var typeHasOwnStringIndexer = false; + + if (typeSymbol.hasOwnIndexSignatures()) { + var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); + for (var i = 0; i < ownIndexSignatures.length; i++) { + if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + typeHasOwnNumberIndexer = true; + } else { + typeHasOwnStringIndexer = true; + } + } + } + var baseTypes = typeSymbol.getExtendedTypes(); + for (var i = 0; i < baseTypes.length; i++) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + return; + } + } + + if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { + return; + } + + this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; + var memberName = member.name; + + if (interfaceSymbol.findMember(memberName, false)) { + continue; + } + + this.resolveDeclaredSymbol(member, context); + + if (inheritedMembersMap[memberName]) { + var prevMember = inheritedMembersMap[memberName]; + 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; + } + } else { + inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); + } + } + + return false; + }; + + PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { + if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { + return false; + } + + var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { + var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; + + var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; + 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, 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; + } + } else { + allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } else if (parameterTypeIsNumber) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin) { + 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; + } + } else { + allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { + if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; + var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; + for (var memberName in inheritedMembers) { + var memberWithBaseOrigin = inheritedMembers[memberName]; + if (!memberWithBaseOrigin) { + continue; + } + + var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); + if (!relevantSignature) { + continue; + } + + var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; + + if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { + continue; + } + + 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_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_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])); + } + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + 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_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, [ + interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), + inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.isReference = function (ast, astSymbol) { + if (ast.kind() === 217 /* ParenthesizedExpression */) { + return this.isReference(ast.expression, astSymbol); + } + + if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { + return false; + } + + if (ast.kind() === 11 /* IdentifierName */) { + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { + return false; + } + + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { + return false; + } + + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { + return false; + } + } + + if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { + if (resolvedName) { + if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { + return this.semanticInfoChain.getEnclosingDecl(ast); + }; + + PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + return enclosingDecl ? enclosingDecl.getSymbol() : null; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { + if (resolvedName) { + if (resolvedName.anyDeclHasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var memberClass = memberContainer.getDeclarations()[0].ast(); + TypeScript.Debug.assert(memberClass); + + var containingClass = this.getEnclosingClassDeclaration(name); + + if (!containingClass || containingClass !== memberClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { + if (type.isPrimitive()) { + return type; + } + + if (type.isError()) { + return type; + } + + if (typeParameterArgumentMap[type.pullSymbolID]) { + return typeParameterArgumentMap[type.pullSymbolID]; + } + + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); + } + + if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + } + + return type; + }; + + 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 rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); + + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); + + 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) { + for (var j = 0; j < parameters.length; j++) { + parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + instantiatedSignature.hasVarArgs = true; + } + instantiatedSignature.addParameter(parameter, parameter.isOptional); + + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); + } + } + + return instantiatedSignature; + }; + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; + + function getPropertyAssignmentNameTextFromIdentifier(identifier) { + if (identifier.kind() === 11 /* IdentifierName */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 14 /* StringLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 13 /* NumericLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; + + function isTypesOnlyLocation(ast) { + while (ast && ast.parent) { + switch (ast.parent.kind()) { + case 244 /* TypeAnnotation */: + return true; + case 127 /* TypeQuery */: + return false; + case 125 /* ConstructorType */: + var constructorType = ast.parent; + if (constructorType.type === ast) { + return true; + } + break; + case 123 /* FunctionType */: + var functionType = ast.parent; + if (functionType.type === ast) { + return true; + } + break; + case 239 /* Constraint */: + var constraint = ast.parent; + if (constraint.type === ast) { + return true; + } + break; + case 220 /* CastExpression */: + var castExpression = ast.parent; + return castExpression.type === ast; + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + return true; + case 228 /* TypeArgumentList */: + return true; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + case 129 /* FunctionDeclaration */: + case 145 /* MethodSignature */: + case 212 /* MemberAccessExpression */: + case 242 /* Parameter */: + return false; + } + + ast = ast.parent; + } + + return false; + } + TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfoChain = (function () { + function SemanticInfoChain(compiler, logger) { + this.compiler = compiler; + this.logger = logger; + this.documents = []; + this.fileNameToDocument = TypeScript.createIntrinsicsObject(); + this.anyTypeDecl = null; + this.booleanTypeDecl = null; + this.numberTypeDecl = null; + this.stringTypeDecl = null; + this.nullTypeDecl = null; + this.undefinedTypeDecl = null; + this.voidTypeDecl = null; + this.undefinedValueDecl = null; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + this.undefinedValueSymbol = null; + this.emptyTypeSymbol = null; + this.astSymbolMap = []; + this.astAliasSymbolMap = []; + this.astCallResolutionDataMap = []; + this.declSymbolMap = []; + this.declSignatureSymbolMap = []; + this.declCache = null; + this.symbolCache = null; + this.fileNameToDiagnostics = null; + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + 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); + 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 */, 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 || null; + }; + + SemanticInfoChain.prototype.lineMap = function (fileName) { + return this.getDocument(fileName).lineMap(); + }; + + SemanticInfoChain.prototype.fileNames = function () { + if (this._fileNames === null) { + this._fileNames = this.documents.slice(1).map(function (s) { + return s.fileName; + }); + } + + return this._fileNames; + }; + + SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { + newSymbol.addDeclaration(decl); + decl.setSymbol(newSymbol); + newSymbol.setResolved(); + + return newSymbol; + }; + + SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { + var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { + var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); + newSymbol.type = type; + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.resetGlobalSymbols = function () { + this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); + this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); + this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); + this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); + this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); + this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); + this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); + this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); + + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); + var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + emptyTypeDecl.setSymbol(emptyTypeSymbol); + emptyTypeSymbol.addDeclaration(emptyTypeDecl); + emptyTypeSymbol.setResolved(); + this.emptyTypeSymbol = emptyTypeSymbol; + }; + + SemanticInfoChain.prototype.addDocument = function (document) { + var fileName = document.fileName; + + var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (existingIndex < 0) { + this.documents.push(document); + } else { + this.documents[existingIndex] = document; + } + + this.fileNameToDocument[fileName] = document; + + this.invalidate(); + }; + + SemanticInfoChain.prototype.removeDocument = function (fileName) { + TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); + var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (index > 0) { + this.fileNameToDocument[fileName] = undefined; + this.documents.splice(index, 1); + this.invalidate(); + } + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[cacheID]; + + if (!symbol) { + for (var i = 0, n = this.documents.length; i < n; i++) { + var topLevelDecl = this.documents[i].topLevelDecl(); + + var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); + if (symbol) { + break; + } + + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { + return null; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { + var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; + + var foundDecls = topLevelDecl.searchChildDecls(name, kind); + + for (var j = 0; j < foundDecls.length; j++) { + var foundDecl = foundDecls[j]; + + if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { + break; + } + + var symbol = foundDecls[j].getSymbol(); + if (symbol) { + return symbol; + } + } + + return null; + }; + + SemanticInfoChain.prototype.findExternalModule = function (id) { + id = TypeScript.normalizePath(id); + + var tsFile = id + ".ts"; + var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); + symbol = this.symbolCache[tsCacheID]; + if (symbol != undefined) { + return symbol; + } + + 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 isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + symbol = dynamicModuleDecl.getSymbol(); + + 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 null; + }; + + SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { + var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); + + var symbol = this.symbolCache[cacheID]; + if (symbol == undefined) { + symbol = null; + for (var i = 0; i < this.documents.length; i++) { + var document = this.documents[i]; + var topLevelDecl = document.topLevelDecl(); + + if (!topLevelDecl.isExternalModule()) { + var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); + if (dynamicModules.length) { + symbol = dynamicModules[0].getSymbol(); + break; + } + } + } + + this.symbolCache[cacheID] = symbol; + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + var declsToSearch = this.topLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + + 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, kind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls === TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + 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; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + } + }; + + SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { + if (typeof oldSettings === "undefined") { oldSettings = null; } + if (typeof newSettings === "undefined") { newSettings = null; } + TypeScript.PullTypeResolver.globalTypeCheckPhase++; + + var cleanStart = new Date().getTime(); + + this.astSymbolMap.length = 0; + this.astAliasSymbolMap.length = 0; + this.astCallResolutionDataMap.length = 0; + + this.declCache = TypeScript.createIntrinsicsObject(); + this.symbolCache = TypeScript.createIntrinsicsObject(); + this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + + this.declSymbolMap.length = 0; + this.declSignatureSymbolMap.length = 0; + + if (oldSettings && newSettings) { + if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { + for (var i = 1, n = this.documents.length; i < n; i++) { + this.documents[i].invalidate(); + } + } + } + + TypeScript.pullSymbolID = 0; + + this.resetGlobalSymbols(); + + var cleanEnd = new Date().getTime(); + }; + + SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()] || null; + }; + + SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { + this.astAliasSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { + return this.astAliasSymbolMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { + return this.astCallResolutionDataMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; + } + }; + + SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { + this.declSymbolMap[decl.declID] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { + return this.declSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { + this.declSignatureSymbolMap[decl.declID] = signatureSymbol; + }; + + SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { + return this.declSignatureSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { + var fileName = diagnostic.fileName(); + var diagnostics = this.fileNameToDiagnostics[fileName]; + if (!diagnostics) { + diagnostics = []; + this.fileNameToDiagnostics[fileName] = diagnostics; + } + + diagnostics.push(diagnostic); + }; + + SemanticInfoChain.prototype.getDiagnostics = function (fileName) { + var diagnostics = this.fileNameToDiagnostics[fileName]; + return diagnostics || []; + }; + + SemanticInfoChain.prototype.getBinder = function () { + if (!this._binder) { + this._binder = new TypeScript.PullSymbolBinder(this); + } + + return this._binder; + }; + + SemanticInfoChain.prototype.getResolver = function () { + if (!this._resolver) { + this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); + } + + return this._resolver; + }; + + SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); + indexParameterSymbol.type = indexParamType; + indexSignature.addParameter(indexParameterSymbol); + indexSignature.returnType = returnType; + indexSignature.setResolved(); + indexParameterSymbol.setResolved(); + + containingSymbol.addIndexSignature(indexSignature); + + 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); + indexParameterSymbol.addDeclaration(indexParamDecl); + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast) { + var document = this.getDocument(ast.fileName()); + + if (document) { + return document._getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { + return this.getDocument(ast.fileName()).getEnclosingDecl(ast); + }; + + SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { + this.getDocument(decl.fileName())._setDeclForAST(ast, decl); + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var document = this.getDocument(decl.fileName()); + if (document) { + return document._getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { + this.getDocument(decl.fileName())._setASTForDecl(decl, ast); + }; + + SemanticInfoChain.prototype.topLevelDecl = function (fileName) { + var document = this.getDocument(fileName); + if (document) { + return document.topLevelDecl(); + } + + return null; + }; + + SemanticInfoChain.prototype.topLevelDecls = function () { + if (!this._topLevelDecls) { + this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { + return u.topLevelDecl(); + }); + } + + return this._topLevelDecls; + }; + + 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, 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; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { + this.document = document; + this.semanticInfoChain = semanticInfoChain; + this.propagateEnumConstants = propagateEnumConstants; + this.isDeclareFile = false; + this.parentChain = []; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + return DeclCollectionContext; + })(); + + function containingModuleHasExportAssignment(ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = ast; + return moduleDecl.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } else if (ast.kind() === 120 /* SourceUnit */) { + var sourceUnit = ast; + return sourceUnit.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } + + ast = ast.parent; + } + + return false; + } + + function isParsingAmbientModule(ast, context) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { + return true; + } + } + + ast = ast.parent; + } + + return false; + } + + function preCollectImportDecls(ast, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + + var parent = context.getParent(); + + if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { + declFlags |= 1 /* Exported */; + } + + 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 fileName = sourceUnit.fileName(); + + var isExternalModule = context.document.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); + + context.isDeclareFile = context.document.isDeclareFile(); + + context.pushParent(decl); + + if (isExternalModule) { + var declFlags = 1 /* Exported */; + if (TypeScript.isDTSFile(fileName)) { + declFlags |= 8 /* Ambient */; + } + + var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); + var kind = 32 /* DynamicModule */; + var valueText = TypeScript.quoteStr(fileName); + + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); + + context.semanticInfoChain.setASTForDecl(decl, sourceUnit); + + context.semanticInfoChain.setDeclForAST(sourceUnit, decl); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, sourceUnit, context); + } + + context.pushParent(decl); + } + } + + function preCollectEnumDecls(enumDecl, context) { + var declFlags = 0 /* None */; + var enumName = enumDecl.identifier.valueText(); + + if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + declFlags |= 4096 /* Enum */; + var kind = 64 /* Enum */; + + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); + context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); + context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); + + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); + enumDeclaration.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); + + context.pushParent(enumDeclaration); + } + + function createEnumElementDecls(propertyDecl, context) { + var parent = context.getParent(); + + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function preCollectModuleDecls(moduleDecl, context) { + var declFlags = 0 /* None */; + + var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); + + var isDynamic = moduleDecl.stringLiteral !== null; + + if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + + 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()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); + } + + context.pushParent(decl); + } else { + var moduleNames = getModuleNames(moduleDecl.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + var moduleName = moduleNames[i]; + + var specificFlags = declFlags; + if (i > 0) { + specificFlags |= 1 /* Exported */; + } + + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleName, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleName); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleName, context); + } + + context.pushParent(decl); + } + } + } + + function getModuleNames(name, result) { + result = result || []; + + if (name.kind() === 121 /* QualifiedName */) { + getModuleNames(name.left, result); + result.push(name.right); + } else { + result.push(name); + } + + return result; + } + TypeScript.getModuleNames = getModuleNames; + + 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.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); + } + + function containsExecutableCode(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); + + if (member.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = member; + + if (containsExecutableCode(moduleDecl.moduleElements)) { + return true; + } + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + } + + function preCollectClassDecls(classDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var parent = context.getParent(); + + 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); + + decl.setValueDecl(constructorDecl); + + context.semanticInfoChain.setDeclForAST(classDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, classDecl); + context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); + + context.pushParent(decl); + } + + function preCollectObjectTypeDecls(objectType, context) { + if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { + return; + } + + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setDeclForAST(objectType, decl); + context.semanticInfoChain.setASTForDecl(decl, objectType); + + context.pushParent(decl); + } + + function preCollectInterfaceDecls(interfaceDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { + declFlags |= 1 /* Exported */; + } + + var parent = context.getParent(); + + 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); + + context.pushParent(decl); + } + + function preCollectParameterDecl(argDecl, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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 */) { + decl.setFlag(67108864 /* ConstructorParameter */); + } + + var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); + var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; + if (isPublicOrPrivate && isInConstructor) { + var parentsParent = context.parentChain[context.parentChain.length - 2]; + + 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 */) { + propDecl.setFlag(67108864 /* ConstructorParameter */); + } + + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setASTForDecl(propDecl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, decl); + } + + parent.addVariableDeclToGroup(decl); + } + + function preCollectTypeParameterDecl(typeParameterDecl, context) { + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); + context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = 4096 /* Property */; + + if (propertyDecl.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var parent = context.getParent(); + + 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); + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 512 /* Variable */; + + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); + if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + 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); + context.semanticInfoChain.setDeclForAST(varDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, varDecl); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectVarDecls(ast, context) { + if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { + return; + } + + var varDecl = ast; + createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + 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); + context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); + + context.pushParent(decl); + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + 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); + context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); + + context.pushParent(decl); + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + 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); + context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); + + context.pushParent(decl); + } + + function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { + if (typeof displayName === "undefined") { displayName = null; } + var declFlags = 0 /* None */; + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { + declFlags |= 8192 /* ArrowFunction */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = id ? id.text() : ""; + var displayNameText = displayName ? displayName.text() : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); + context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); + + context.pushParent(decl); + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrow = functionExpressionDeclAST; + var declFlags = 4 /* Public */; + + var parent = context.getParent(); + + if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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); + + parent.addVariableDeclToGroup(decl); + } + } + + function createMemberFunctionDeclaration(funcDecl, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!funcDecl.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(funcDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDecl); + + context.pushParent(decl); + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 4194304 /* IndexSignature */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); + + context.pushParent(decl); + } + + function createCallSignatureDeclaration(callSignature, context) { + var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; + + if (!isChildOfObjectType) { + return; + } + + var declFlags = 2048 /* Signature */; + var declType = 1048576 /* CallSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(callSignature, decl); + context.semanticInfoChain.setASTForDecl(decl, callSignature); + + context.pushParent(decl); + } + + function createMethodSignatureDeclaration(method, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + declFlags |= 4 /* Public */; + declFlags |= 2048 /* Signature */; + + if (method.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(method, decl); + context.semanticInfoChain.setASTForDecl(decl, method); + + context.pushParent(decl); + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 2097152 /* ConstructSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); + + context.pushParent(decl); + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); + + context.pushParent(decl); + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); + + context.pushParent(decl); + } + + function createFunctionExpressionDeclaration(expression, context) { + createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); + + context.pushParent(decl); + } + + function preCollectCatchDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 268435456 /* CatchBlock */; + + 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); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + + var declFlags = 0 /* None */; + var declType = 1024 /* CatchVariable */; + + 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); + context.semanticInfoChain.setDeclForAST(ast.identifier, decl); + context.semanticInfoChain.setASTForDecl(decl, ast.identifier); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectWithDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 134217728 /* WithBlock */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectObjectLiteralDecls(ast, context) { + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); + + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectSimplePropertyAssignmentDecls(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()); + + context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); + } + + function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { + var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); + + 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); + + createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); + } + + function preCollectDecls(ast, context) { + switch (ast.kind()) { + case 120 /* SourceUnit */: + preCollectScriptDecls(ast, context); + break; + case 132 /* EnumDeclaration */: + preCollectEnumDecls(ast, context); + break; + case 243 /* EnumElement */: + createEnumElementDecls(ast, context); + break; + case 130 /* ModuleDeclaration */: + preCollectModuleDecls(ast, context); + break; + case 131 /* ClassDeclaration */: + preCollectClassDecls(ast, context); + break; + case 128 /* InterfaceDeclaration */: + preCollectInterfaceDecls(ast, context); + break; + case 122 /* ObjectType */: + preCollectObjectTypeDecls(ast, context); + break; + case 242 /* Parameter */: + preCollectParameterDecl(ast, context); + break; + case 136 /* MemberVariableDeclaration */: + createMemberVariableDeclaration(ast, context); + break; + case 141 /* PropertySignature */: + createPropertySignature(ast, context); + break; + case 225 /* VariableDeclarator */: + preCollectVarDecls(ast, context); + break; + case 137 /* ConstructorDeclaration */: + createClassConstructorDeclaration(ast, context); + break; + case 139 /* GetAccessor */: + createGetAccessorDeclaration(ast, context); + break; + case 140 /* SetAccessor */: + createSetAccessorDeclaration(ast, context); + break; + case 222 /* FunctionExpression */: + createFunctionExpressionDeclaration(ast, context); + break; + case 135 /* MemberFunctionDeclaration */: + createMemberFunctionDeclaration(ast, context); + break; + case 144 /* IndexSignature */: + createIndexSignatureDeclaration(ast, context); + break; + case 123 /* FunctionType */: + createFunctionTypeDeclaration(ast, context); + break; + case 125 /* ConstructorType */: + createConstructorTypeDeclaration(ast, context); + break; + case 142 /* CallSignature */: + createCallSignatureDeclaration(ast, context); + break; + case 143 /* ConstructSignature */: + createConstructSignatureDeclaration(ast, context); + break; + case 145 /* MethodSignature */: + createMethodSignatureDeclaration(ast, context); + break; + case 129 /* FunctionDeclaration */: + createFunctionDeclaration(ast, context); + break; + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + createAnyFunctionExpressionDeclaration(ast, null, context); + break; + case 133 /* ImportDeclaration */: + preCollectImportDecls(ast, context); + break; + case 238 /* TypeParameter */: + preCollectTypeParameterDecl(ast, context); + break; + case 236 /* CatchClause */: + preCollectCatchDecls(ast, context); + break; + case 163 /* WithStatement */: + preCollectWithDecls(ast, context); + break; + case 215 /* ObjectLiteralExpression */: + preCollectObjectLiteralDecls(ast, context); + break; + case 240 /* SimplePropertyAssignment */: + preCollectSimplePropertyAssignmentDecls(ast, context); + break; + case 241 /* FunctionPropertyAssignment */: + preCollectFunctionPropertyAssignmentDecls(ast, context); + break; + } + } + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, context) { + var currentDecl = context.getParent(); + + if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { + if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + return; + } + } + + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDeclaration = ast; + if (moduleDeclaration.stringLiteral) { + TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); + context.popParent(); + } else { + var moduleNames = getModuleNames(moduleDeclaration.name); + for (var i = moduleNames.length - 1; i >= 0; i--) { + var moduleName = moduleNames[i]; + TypeScript.Debug.assert(currentDecl.ast() === moduleName); + context.popParent(); + currentDecl = context.getParent(); + } + } + } + + if (ast.kind() === 132 /* EnumDeclaration */) { + computeEnumElementConstantValues(ast, currentDecl, context); + } + + while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { + context.popParent(); + currentDecl = context.getParent(); + } + } + + function computeEnumElementConstantValues(ast, enumDecl, context) { + TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); + + var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); + var inConstantSection = !isAmbientEnum; + var currentConstantValue = 0; + var enumMemberDecls = enumDecl.getChildDecls(); + + for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { + var enumElement = ast.enumElements.nonSeparatorAt(i); + var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { + return context.semanticInfoChain.getASTForDecl(d) === enumElement; + }); + + TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); + + if (enumElement.equalsValueClause === null) { + if (inConstantSection) { + enumElementDecl.constantValue = currentConstantValue; + currentConstantValue++; + } + } else { + enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); + if (enumElementDecl.constantValue !== null && !isAmbientEnum) { + inConstantSection = true; + currentConstantValue = enumElementDecl.constantValue + 1; + } else { + inConstantSection = false; + } + } + + TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); + } + } + + function computeEnumElementConstantValue(expression, enumMemberDecls, context) { + TypeScript.Debug.assert(expression); + + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { + var token; + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + token = expression.operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; + } else if (context.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var name = expression; + var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { + return d.name === name.valueText(); + }); + + return matchingEnumElement ? matchingEnumElement.constantValue : null; + + case 202 /* LeftShiftExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left << right; + + case 189 /* BitwiseOrExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left | right; + } + + return null; + } else { + return null; + } + } + + (function (DeclarationCreator) { + function create(document, semanticInfoChain, compilationSettings) { + var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); + + TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); + + return declCollectionContext.getParent(); + } + DeclarationCreator.create = create; + })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); + var DeclarationCreator = TypeScript.DeclarationCreator; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBinder = (function () { + 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 */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.hasBeenBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind === 262144 /* GetAccessor */) { + parent = parent.getGetter(); + } else if (parentDeclKind === 524288 /* SetAccessor */) { + parent = parent.getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = parent.getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = startingDecl.getParentPath(); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + }; + + PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { + var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; + var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; + var name = decl.name; + if (parent) { + var isExported = (decl.flags & 1 /* Exported */) !== 0; + + var prevSymbol = null; + if (lookingForValue) { + prevSymbol = parent.findContainedNonMember(name); + } else if (lookingForType) { + prevSymbol = parent.findContainedNonMemberType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); + } + var prevIsExported = !prevSymbol; + if (!prevSymbol) { + if (lookingForValue) { + prevSymbol = parent.findMember(name, false); + } else if (lookingForType) { + prevSymbol = parent.findNestedType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findNestedContainer(name, searchKind); + } + } + + if (isExported && prevIsExported) { + return prevSymbol; + } + if (prevSymbol) { + var prevDecls = prevSymbol.getDeclarations(); + var lastPrevDecl = prevDecls[prevDecls.length - 1]; + var parentDecl = decl.getParentDecl(); + var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); + if (parentDecl !== prevParentDecl) { + return null; + } + + return prevSymbol; + } + } else { + var parentDecl = decl.getParentDecl(); + if (parentDecl && parentDecl.kind === 1 /* Script */) { + return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); + } else { + var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); + return prevDecls[0] && prevDecls[0].getSymbol(); + } + } + + return null; + }; + + PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { + if (typeof reportError === "undefined") { reportError = true; } + 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 (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()]); + } + return false; + } + + 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; + + var enumContainerSymbol = null; + var enumInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var enumInstanceDecl = enumContainerDecl.getValueDecl(); + + var enumDeclKind = enumContainerDecl.kind; + + var parent = this.getParent(enumContainerDecl); + var parentInstanceSymbol = this.getParent(enumContainerDecl, true); + var parentDecl = enumContainerDecl.getParentDecl(); + var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); + + var isExported = enumContainerDecl.flags & 1 /* Exported */; + + var createdNewSymbol = false; + + enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); + + if (enumContainerSymbol) { + if (enumContainerSymbol.kind !== enumDeclKind) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); + enumContainerSymbol = null; + } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { + enumContainerSymbol = null; + } + } + + if (enumContainerSymbol) { + enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); + } else { + enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); + } + } + + enumContainerSymbol.addDeclaration(enumContainerDecl); + enumContainerDecl.setSymbol(enumContainerSymbol); + + this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); + this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); + + if (!enumInstanceSymbol) { + var variableSymbol = null; + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] === enumContainerDecl) { + break; + } + + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol) { + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + enumInstanceSymbol = variableSymbol; + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); + } + + enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + enumInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); + } + } + + if (createdNewSymbol && parent) { + if (enumContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(enumContainerSymbol); + } else { + parent.addEnclosedNonMemberType(enumContainerSymbol); + } + } + + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } + var valueDecl = enumContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + 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(); + + enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; + + 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(); + + 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); + if (!moduleDeclAST) { + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); + + moduleDeclAST = moduleNameAST; + } + + var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); + var searchKind = 164 /* SomeContainer */; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; + + if (parent && moduleKind === 32 /* DynamicModule */) { + this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); + } + + var createdNewSymbol = false; + + moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); + + if (moduleContainerTypeSymbol) { + if (moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); + } + + moduleContainerTypeSymbol = null; + } 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) { + moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); + this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); + + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); + } + } + } + + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); + + 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); + } + } + + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(importSymbol); + } else { + parent.addEnclosedNonMemberContainer(importSymbol); + } + } + }; + + 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; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + 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, 58728795 /* SomeType */, parent); + + if (classSymbol && classSymbol.kind === 16 /* Interface */) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); + classSymbol = null; + } + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); + this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + 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; + + if (!constructorSymbol) { + var siblingValueDecls = null; + if (parentDecl) { + siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); + + if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { + constructorSymbol = siblingValueDecls[0].getSymbol(); + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + constructorSymbol.setIsSynthesized(); + constructorSymbol.type = constructorTypeSymbol; + } + + classSymbol.setConstructorMethod(constructorSymbol); + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); + + if (interfaceSymbol) { + if (!(interfaceSymbol.kind & acceptableSharedKind)) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); + interfaceSymbol = null; + } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { + interfaceSymbol = null; + } + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + 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; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + 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; + variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); + var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); + var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); + 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 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 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.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 || 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); + variableSymbol = null; + parentHadSymbol = false; + } + } + + if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { + variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); + } + } + + if ((declFlags & 118784 /* ImplicitVariable */) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + if (!parent && parentDecl.kind === 1 /* Script */) { + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); + this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfoChain.getASTForDecl(decl); + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & 102400 /* SomeInitializedModule */) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + 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); + } + variableDeclaration.setSymbol(variableSymbol); + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + if (!variableSymbol.hasDeclaration(variableDeclaration)) { + variableSymbol.addDeclaration(variableDeclaration); + } + 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); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); + + var declName = variableDeclaration.name; + + var variableSymbol = new TypeScript.PullSymbol(declName, declKind); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + + this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); + }; + + PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + var propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + + var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { + var parameters = []; + var params = TypeScript.createIntrinsicsObject(); + var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); + + if (parameterList) { + for (var i = 0, n = parameterList.length; i < n; i++) { + var argDecl = parameterList.astAt(i); + var id = parameterList.identifierAt(i); + var decl = this.semanticInfoChain.getDeclForAST(argDecl); + var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); + var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); + + if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { + parameterSymbol.isVarArg = 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); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); + + if (functionSymbol) { + 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); + functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); + } + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { + signature.hasVarArgs = true; + } + + var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); + + 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; + if (name) { + this.semanticInfoChain.setSymbolForAST(name, functionSymbol); + } + + this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); + + if (parameters.lastParameterIsRest()) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + + var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; + + TypeScript.Debug.assert(nameAST); + + this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); + this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); + + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); + if (TypeScript.lastParameterIsRest(parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); + signature.addTypeParameter(typeParameter); + } else { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { + var prototypeStr = "prototype"; + + var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); + if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { + 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], this.semanticInfoChain); + + prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + prototypeSymbol.setIsSynthesized(); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = classTypeSymbol; + constructorTypeSymbol.addMember(prototypeSymbol); + + if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { + var resolver = this.semanticInfoChain.getResolver(); + prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); + } + prototypeSymbol.setResolved(); + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); + constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.appendConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + constructSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + callSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); + + var parent = this.getParent(indexSignatureDeclaration); + parent.addIndexSignature(indexSignature); + indexSignature.setContainer(parent); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + + getterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); + } + }; + + 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) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + this.bindEnumDeclarationToPullSymbol(decl); + break; + + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 512 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 1024 /* CatchVariable */: + this.bindCatchVariableToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + this.bindEnumMemberDeclarationToPullSymbol(decl); + break; + + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 128 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + decl.getParentDecl().getSymbol(); + break; + + case 268435456 /* CatchBlock */: + case 134217728 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); + this.declsBeingBound.pop(); + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (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(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + + if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (functionDecl.kind === 4194304 /* IndexSignature */) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + + function isNameNumeric(name) { + return isFinite(+name); + } + PullHelpers.isNameNumeric = isNameNumeric; + + function typeSymbolsAreIdentical(a, b) { + if (a.isTypeReference() && !a.getIsSpecialized()) { + a = a.referencedTypeSymbol; + } + + if (b.isTypeReference() && !b.getIsSpecialized()) { + b = b.referencedTypeSymbol; + } + + return a === b; + } + PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; + + function getRootType(type) { + var rootType = type.getRootSymbol(); + + while (true) { + if (type === rootType) { + return type; + } + + type = rootType; + rootType = type.getRootSymbol(); + } + } + PullHelpers.getRootType = getRootType; + + function isSymbolLocal(symbol) { + var container = symbol.getContainer(); + if (container) { + var containerKind = container.kind; + if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { + return true; + } + + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { + return true; + } + } + + 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; + +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.fileResolutionIOTime = 0; + TypeScript.fileResolutionScanImportsTime = 0; + TypeScript.fileResolutionImportFileSearchTime = 0; + TypeScript.fileResolutionGetDefaultLibraryTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.compilerResolvePathTime = 0; + TypeScript.compilerDirectoryNameTime = 0; + TypeScript.compilerDirectoryExistsTime = 0; + TypeScript.compilerFileExistsTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + 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(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } + this.outputFiles = []; + this.emitOutputResult = emitOutputResult; + } + return EmitOutput; + })(); + TypeScript.EmitOutput = EmitOutput; + + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); + var OutputFileType = TypeScript.OutputFileType; + + var OutputFile = (function () { + function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { + if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.text = text; + this.fileType = fileType; + this.sourceMapEntries = sourceMapEntries; + } + return OutputFile; + })(); + TypeScript.OutputFile = OutputFile; + + var CompileResult = (function () { + function CompileResult() { + this.diagnostics = []; + this.outputFiles = []; + } + CompileResult.fromDiagnostics = function (diagnostics) { + var result = new CompileResult(); + result.diagnostics = diagnostics; + return result; + }; + + CompileResult.fromOutputFiles = function (outputFiles) { + var result = new CompileResult(); + result.outputFiles = outputFiles; + return result; + }; + return CompileResult; + })(); + TypeScript.CompileResult = CompileResult; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, _settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } + this.logger = logger; + this._settings = _settings; + this.semanticInfoChain = null; + this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); + } + TypeScriptCompiler.prototype.compilationSettings = function () { + return this._settings; + }; + + TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { + var oldSettings = this._settings; + this._settings = newSettings; + + if (!compareDataObjects(oldSettings, newSettings)) { + this.semanticInfoChain.invalidate(oldSettings, newSettings); + } + }; + + TypeScriptCompiler.prototype.getDocument = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.semanticInfoChain.getDocument(fileName); + }; + + TypeScriptCompiler.prototype.cleanupSemanticCache = function () { + this.semanticInfoChain.invalidate(); + }; + + TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); + + this.semanticInfoChain.addDocument(document); + }; + + TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); + + this.semanticInfoChain.addDocument(updatedDocument); + }; + + TypeScriptCompiler.prototype.removeFile = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + this.semanticInfoChain.removeDocument(fileName); + }; + + TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { + if (document.emitToOwnOutputFile()) { + var updatedFileName = document.fileName; + if (emitOptions.outputDirectory() !== "") { + updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); + updatedFileName = emitOptions.outputDirectory() + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(emitOptions.sharedOutputFile(), true); + } + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + var printReason = false; + + if (document.emitToOwnOutputFile()) { + var result = document.byteOrderMark !== 0 /* None */; + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + } + return result; + } else { + var fileNames = this.fileNames(); + + var result = false; + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + + if (document.isExternalModule()) { + continue; + } + + if (document.byteOrderMark !== 0 /* None */) { + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + result = true; + } else { + return true; + } + } + } + + return result; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype._shouldEmit = function (document) { + return !document.isDeclareFile(); + }; + + TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { + if (!this.compilationSettings().generateDeclarationFiles()) { + return false; + } + + return this._shouldEmit(document); + }; + + TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); + + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); + } + + declarationEmitter.emitDeclarations(sourceUnit); + return declarationEmitter; + }; + + TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmitDeclarations(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFile()); + } + } else { + sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var sharedEmitter = null; + var fileNames = this.fileNames(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileNames[i]); + + sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return emitOutput; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, null); + return emitOutput; + } else { + return this.emitAllDeclarations(resolvePath); + } + }; + + 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; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmit(document)); + + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); + var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); + + if (this.compilationSettings().mapSourceFiles()) { + var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); + emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); + } + } else if (this.compilationSettings().mapSourceFiles()) { + emitter.setSourceMapperNewSourceFile(document); + } + + emitter.setDocument(document); + emitter.emitJavascript(sourceUnit, false); + + return emitter; + }; + + TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmit(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFiles()); + } + } else { + sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var fileNames = this.fileNames(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + sharedEmitter = this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); + } + + TypeScript.emitTime += new Date().getTime() - start; + return emitOutput; + }; + + TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, null); + return emitOutput; + } else { + return this.emitAll(resolvePath); + } + }; + + TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { + if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } + return new CompilerIterator(this, resolvePath, continueOnDiagnostics); + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + + TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { + return this.getDocument(fileName).sourceUnit(); + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + var errors = this.semanticInfoChain.getDiagnostics(fileName); + + errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); + errors.sort(function (d1, d2) { + if (d1.fileName() < d2.fileName()) { + return -1; + } else if (d1.fileName() > d2.fileName()) { + return 1; + } + + if (d1.start() < d2.start()) { + return -1; + } else if (d1.start() > d2.start()) { + return 1; + } + + var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; + var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; + if (code1 < code2) { + return -1; + } else if (code1 > code2) { + return 1; + } + + return 0; + }); + + 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++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var ast = this.semanticInfoChain.getASTForDecl(decl); + if (!ast) { + return null; + } + + var enclosingDecl = resolver.getEnclosingDecl(decl); + if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { + return this.getSymbolOfDeclaration(enclosingDecl); + } + + return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { + var scriptName = document.fileName; + + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + var inWithBlock = false; + + var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); + + if (!ast) { + return null; + } + + var path = this.getASTPath(ast); + + for (var i = 0, n = path.length; i < n; i++) { + var current = path[i]; + + switch (current.kind()) { + case 222 /* FunctionExpression */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + if (propagateContextualTypes) { + resolver.resolveAST(current, true, resolutionContext); + } + break; + + case 136 /* MemberVariableDeclaration */: + var memberVariable = current; + inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); + break; + + case 225 /* VariableDeclarator */: + var variableDeclarator = current; + inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); + break; + + case 213 /* InvocationExpression */: + case 216 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.kind() === 216 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = path[i + 3]; + if (argExpression) { + for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { + if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext); + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 214 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 215 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.propertyAssignments; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { + if (memberDecls.nonSeparatorAt(j) === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + } + + break; + + case 174 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path[i + 1] && path[i + 1] === assignmentExpression.right) { + var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + 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; + + case 150 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 122 /* ObjectType */: + if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { + resolver.resolveAST(current, false, resolutionContext); + } + + break; + + case 163 /* WithStatement */: + inWithBlock = true; + break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; + } + + var decl = this.semanticInfoChain.getDeclForAST(current); + if (decl) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { + if (ast.parent.kind() === 212 /* MemberAccessExpression */) { + if (ast.parent.name === ast) { + ast = ast.parent; + } + } else if (ast.parent.kind() === 121 /* QualifiedName */) { + if (ast.parent.right === ast) { + ast = ast.parent; + } + } + } + + return { + ast: ast, + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment, + inWithBlock: inWithBlock + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + resolver.resolveAST(assigningAST, false, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushNewContextualType(contextualType); + + if (init) { + resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); + } + } + } + }; + + TypeScriptCompiler.prototype.getASTPath = function (ast) { + var result = []; + + while (ast) { + result.unshift(ast); + ast = ast.parent; + } + + return result; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + ast = context.ast; + 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()]); + return null; + } + + if (symbol.isTypeReference()) { + symbol = symbol.getReferencedTypeSymbol(); + } + + var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); + + return { + symbol: symbol, + aliasSymbol: aliasSymbol, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { + if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { + return null; + } + + var isNew = ast.kind() === 216 /* ObjectCreationExpression */; + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, false); + if (!context || context.inWithBlock) { + return null; + } + + return resolver.getVisibleDecls(context.enclosingDecl); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { + if (ast.kind() !== 215 /* ObjectLiteralExpression */) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var astForDecl = decl.ast(); + if (!astForDecl) { + return null; + } + + var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); + if (!astForDeclContext) { + return null; + } + + var symbol = decl.getSymbol(); + resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + aliasSymbol: null, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { + return this.semanticInfoChain.topLevelDecl(fileName); + }; + + TypeScriptCompiler.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast); + }; + + TypeScriptCompiler.prototype.fileNames = function () { + return this.semanticInfoChain.fileNames(); + }; + + 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; + + var CompilerPhase; + (function (CompilerPhase) { + CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; + CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; + CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; + CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; + CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; + })(CompilerPhase || (CompilerPhase = {})); + + var CompilerIterator = (function () { + function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { + if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } + this.compiler = compiler; + this.resolvePath = resolvePath; + this.continueOnDiagnostics = continueOnDiagnostics; + this.index = -1; + this.fileNames = null; + this._current = null; + this._emitOptions = null; + this._sharedEmitter = null; + this._sharedDeclarationEmitter = null; + this.hadSyntacticDiagnostics = false; + this.hadSemanticDiagnostics = false; + this.hadEmitDiagnostics = false; + this.fileNames = compiler.fileNames(); + this.compilerPhase = startingPhase; + } + CompilerIterator.prototype.current = function () { + return this._current; + }; + + CompilerIterator.prototype.moveNext = function () { + this._current = null; + + while (this.moveNextInternal()) { + if (this._current) { + return true; + } + } + + return false; + }; + + CompilerIterator.prototype.moveNextInternal = function () { + this.index++; + + while (this.shouldMoveToNextPhase()) { + this.index = 0; + this.compilerPhase++; + } + + if (this.compilerPhase > 4 /* DeclarationEmit */) { + return false; + } + + switch (this.compilerPhase) { + case 0 /* Syntax */: + return this.moveNextSyntaxPhase(); + case 1 /* Semantics */: + return this.moveNextSemanticsPhase(); + case 2 /* EmitOptionsValidation */: + return this.moveNextEmitOptionsValidationPhase(); + case 3 /* Emit */: + return this.moveNextEmitPhase(); + case 4 /* DeclarationEmit */: + return this.moveNextDeclarationEmitPhase(); + } + }; + + CompilerIterator.prototype.shouldMoveToNextPhase = function () { + switch (this.compilerPhase) { + case 2 /* EmitOptionsValidation */: + return this.index === 1; + + case 0 /* Syntax */: + case 1 /* Semantics */: + return this.index === this.fileNames.length; + + case 3 /* Emit */: + case 4 /* DeclarationEmit */: + return this.index === (this.fileNames.length + 1); + } + + return false; + }; + + CompilerIterator.prototype.moveNextSyntaxPhase = function () { + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + + var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSyntacticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextSemanticsPhase = function () { + if (this.hadSyntacticDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + var diagnostics = this.compiler.getSemanticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSemanticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + + if (!this._emitOptions) { + this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); + } + + if (this._emitOptions.diagnostic()) { + if (!this.continueOnDiagnostics) { + this.hadEmitDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(this._emitOptions); + + if (this.hadEmitDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { + _this._current = CompileResult.fromOutputFiles(outputFiles); + }, this._sharedEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedEmitter) { + this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); + } + + return true; + }; + + CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(!this.hadEmitDiagnostics); + if (this.hadSemanticDiagnostics) { + return false; + } + + if (!this.compiler.compilationSettings().generateDeclarationFiles()) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { + _this._current = CompileResult.fromOutputFiles([file]); + }, this._sharedDeclarationEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { + this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); + } + + return true; + }; + return CompilerIterator; + })(); + + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) + return false; + } else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) + return false; + } + } + return true; + } + TypeScript.compareDataObjects = compareDataObjects; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (GenerativeTypeClassification) { + GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; + GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; + GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; + GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; + })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); + var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; + + var PullTypeReferenceSymbol = (function (_super) { + __extends(PullTypeReferenceSymbol, _super); + function PullTypeReferenceSymbol(referencedTypeSymbol) { + _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); + this.referencedTypeSymbol = referencedTypeSymbol; + this.isResolved = true; + + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); + + this.setRootSymbol(referencedTypeSymbol); + + this.typeReference = this; + } + PullTypeReferenceSymbol.createTypeReference = function (type) { + if (type.isTypeReference()) { + return type; + } + + var typeReference = type.typeReference; + + if (!typeReference) { + typeReference = new PullTypeReferenceSymbol(type); + type.typeReference = typeReference; + } + + return typeReference; + }; + + PullTypeReferenceSymbol.prototype.isTypeReference = function () { + return true; + }; + + PullTypeReferenceSymbol.prototype.setResolved = function () { + }; + + PullTypeReferenceSymbol.prototype.setUnresolved = function () { + }; + PullTypeReferenceSymbol.prototype.invalidate = function () { + }; + + PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { + this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); + }; + + PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol; + }; + + PullTypeReferenceSymbol.prototype._getResolver = function () { + return this.referencedTypeSymbol._getResolver(); + }; + + PullTypeReferenceSymbol.prototype.hasMembers = function () { + return this.referencedTypeSymbol.hasMembers(); + }; + + PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); + }; + + PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + return this.referencedTypeSymbol.getAssociatedContainerType(); + }; + + PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getFunctionSymbol(); + }; + PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); + }; + + PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); + }; + PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); + }; + + PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); + }; + PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMember(name); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); + }; + + PullTypeReferenceSymbol.prototype.getMembers = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getMembers(); + }; + + PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); + }; + PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getHasDefaultConstructor(); + }; + PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructorMethod(); + }; + PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); + }; + PullTypeReferenceSymbol.prototype.getTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.isGeneric = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isGeneric(); + }; + + PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getSpecialization(substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getKnownSpecializations(); + }; + PullTypeReferenceSymbol.prototype.getTypeArguments = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArguments(); + }; + PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); + }; + 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"); + }; + + PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnIndexSignatures(); + }; + PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getIndexSignatures(); + }; + + PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { + this.referencedTypeSymbol.addImplementedType(implementedType); + }; + PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getImplementedTypes(); + }; + PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { + this.referencedTypeSymbol.addExtendedType(extendedType); + }; + PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getExtendedTypes(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExtendsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExtendThisType(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); + }; + + PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); + }; + + PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findMember(name, lookInParent); + }; + PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedType(name, kind); + }; + PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedContainer(name, kind); + }; + PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + }; + + PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findTypeParameter(name); + }; + + PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); + }; + return PullTypeReferenceSymbol; + })(TypeScript.PullTypeSymbol); + TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; + + var PullInstantiatedTypeReferenceSymbol = (function (_super) { + __extends(PullInstantiatedTypeReferenceSymbol, _super); + 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 = undefined; + this._instantiatedConstructorMethod = null; + this._instantiatedAssociatedContainerType = null; + this._isArray = undefined; + this._generativeTypeClassification = []; + + TypeScript.nSpecializationsCreated++; + } + PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { + return !this.isInstanceReferenceType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; + } + + 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()); + } + return this._isArray; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { + if (!this.isArrayNamedTypeReference()) { + return null; + } + + var typeArguments = this.getTypeArguments(); + return typeArguments ? typeArguments[0] : null; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.getIsSpecialized()) { + return this; + } + + return this.referencedTypeSymbol; + }; + + 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + 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; + } + } + + if (isInstanceReferenceType) { + typeParameterArgumentMap = []; + } + } + + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); + + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); + + return instantiation; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { + return this.getRootSymbol().isGeneric(); + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { + if (this.isInstanceReferenceType) { + return this.getTypeParameters(); + } + + if (this._typeArgumentReferences === undefined) { + var typeParameters = this.referencedTypeSymbol.getTypeParameters(); + + if (typeParameters.length) { + var typeArgument = null; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; + + if (!typeArgument) { + TypeScript.Debug.fail("type argument count mismatch"); + } + + if (typeArgument) { + typeArguments[typeArguments.length] = typeArgument; + } + } + + this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; + } + } + + return this._typeArgumentReferences; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + 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(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getMembers(); + } + + if (!this._instantiatedMembers) { + var referencedMembers = this.referencedTypeSymbol.getMembers(); + var referencedMember = null; + var instantiatedMember = null; + + this._instantiatedMembers = []; + + for (var i = 0; i < referencedMembers.length; i++) { + referencedMember = referencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (!this._instantiatedMemberNameCache[referencedMember.name]) { + this.populateInstantiatedMemberFromReferencedMember(referencedMember); + } + + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; + } + } + + return this._instantiatedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.findMember(name, lookInParent); + } + + var memberSymbol = this._instantiatedMemberNameCache[name]; + + if (!memberSymbol) { + var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); + + if (referencedMemberSymbol) { + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; + } else { + memberSymbol = null; + } + } + + return memberSymbol; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + } + + var requestedMembers = []; + var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + + if (!this._allInstantiatedMemberNameCache) { + this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); + + var members = this.getMembers(); + + for (var i = 0; i < members.length; i++) { + this._allInstantiatedMemberNameCache[members[i].name] = members[i]; + } + } + + var referencedMember = null; + var requestedMember = null; + + for (var i = 0; i < allReferencedMembers.length; i++) { + referencedMember = allReferencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (this._allInstantiatedMemberNameCache[referencedMember.name]) { + requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; + } else { + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; + requestedMembers[requestedMembers.length] = referencedMember; + } else { + requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + requestedMember.setRootSymbol(referencedMember); + + requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + requestedMember.isOptional = referencedMember.isOptional; + + this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; + requestedMembers[requestedMembers.length] = requestedMember; + } + } + } + + return requestedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructorMethod(); + } + + 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); + } + + return this._instantiatedConstructorMethod; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + if (!this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAssociatedContainerType(); + } + + if (!this._instantiatedAssociatedContainerType) { + var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); + + if (referencedAssociatedContainerType) { + this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); + } + } + + return this._instantiatedAssociatedContainerType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getCallSignatures(); + } + + if (this._instantiatedCallSignatures) { + return this._instantiatedCallSignatures; + } + + var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); + this._instantiatedCallSignatures = []; + + for (var i = 0; i < referencedCallSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); + + if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; + } else { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedCallSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructSignatures(); + } + + if (this._instantiatedConstructSignatures) { + return this._instantiatedConstructSignatures; + } + + var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); + this._instantiatedConstructSignatures = []; + + for (var i = 0; i < referencedConstructSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); + + if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; + } else { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedConstructSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getIndexSignatures(); + } + + if (this._instantiatedIndexSignatures) { + return this._instantiatedIndexSignatures; + } + + var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); + this._instantiatedIndexSignatures = []; + + for (var i = 0; i < referencedIndexSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); + + if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; + } else { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedIndexSignatures; + }; + 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) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { + if (element === null) { + return null; + } + + if (element.fullWidth() === 0) { + return new TypeScript.ASTSpan(-1, -1); + } + + var leadingTriviaWidth = element.leadingTriviaWidth(); + var trailingTriviaWidth = element.trailingTriviaWidth(); + + var start = fullStart + leadingTriviaWidth; + var end = fullStart + element.fullWidth() - trailingTriviaWidth; + + return new TypeScript.ASTSpan(start, end); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { + if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } + if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span._trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span._start = start; + span._end = end; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ISyntaxList2(this.fileName, array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { + return this.visitToken(token); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result = this.visitTokenWorker(token); + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { + switch (token.tokenKind) { + case 60 /* AnyKeyword */: + return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); + case 61 /* BooleanKeyword */: + return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); + case 67 /* NumberKeyword */: + return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); + case 69 /* StringKeyword */: + return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); + case 41 /* VoidKeyword */: + return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); + case 35 /* ThisKeyword */: + return new TypeScript.ThisExpression(token.text(), token.valueText()); + case 50 /* SuperKeyword */: + return new TypeScript.SuperExpression(token.text(), token.valueText()); + case 37 /* TrueKeyword */: + return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); + case 24 /* FalseKeyword */: + return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); + case 32 /* NullKeyword */: + return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); + case 14 /* StringLiteral */: + return new TypeScript.StringLiteral(token.text(), token.valueText()); + case 12 /* RegularExpressionLiteral */: + return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); + case 13 /* NumericLiteral */: + var fullStart = this.position; + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); + + result.setPreComments(preComments); + return result; + case 11 /* IdentifierName */: + return new TypeScript.Identifier(token.text()); + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { + var start = this.position; + TypeScript.Debug.assert(start === 0); + + var bod = this.visitSyntaxList(node.moduleElements); + 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; + }; + + SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { + var start = this.position; + + this.moveTo(node, node.stringLiteral); + var stringLiteral = node.stringLiteral.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ExternalModuleReference(stringLiteral); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { + var start = this.position; + var moduleName = node.moduleName.accept(this); + + var result = new TypeScript.ModuleNameModuleReference(moduleName); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + this.movePast(node.openBraceToken); + var members = this.visitSyntaxList(node.classElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { + var result = null; + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { + result = result || []; + result.push(1 /* Exported */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + result = result || []; + result.push(8 /* Ambient */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { + result = result || []; + result.push(16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { + result = result || []; + result.push(4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { + result = result || []; + result.push(2 /* Private */); + } + + return result || TypeScript.sentinelEmptyArray; + }; + + SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + var body = this.visitObjectType(node.body); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { + var start = this.position; + + this.movePast(node.extendsOrImplementsKeyword); + var typeNames = this.visitSeparatedSyntaxList(node.typeNames); + + var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { + var start = this.position; + + var modifiers = this.visitModifiers(node.modifiers); + + this.moveTo(node, node.moduleKeyword); + this.movePast(node.moduleKeyword); + + var moduleName = node.name ? node.name.accept(this) : null; + var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; + + this.movePast(node.openBraceToken); + + var moduleElements = this.visitSyntaxList(node.moduleElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + this.movePast(node.openBraceToken); + + var enumElements = this.visitSeparatedSyntaxList(node.enumElements); + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + var start = this.position; + + var memberName = this.visitToken(node.propertyName); + + var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.EnumElement(memberName, value); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ImportDeclaration(modifiers, name, alias); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.VariableStatement(modifiers, declaration); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var propertyName = this.visitToken(node.propertyName); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var start = this.position; + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var value = node.value.accept(this); + value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); + + var result = new TypeScript.EqualsValueClause(value); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayLiteralExpression(expressions); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(openParenToken); + + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = node.identifier.accept(this); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var callSignature = this.visitCallSignature(node.callSignature); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + return type ? type.accept(this) : null; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var result = new TypeScript.TypeQuery(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left); + this.movePast(node.dotToken); + var right = this.visitIdentifier(node.right); + + var result = new TypeScript.QualifiedName(left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeArgumentList(typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectType(typeMembers); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayType(underlying); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name); + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + var result = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.colonToken); + var type = this.visitType(node.type); + + var result = new TypeScript.TypeAnnotation(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.visitIdentifier(node.name); + + var result = new TypeScript.MemberAccessExpression(expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + this.movePast(node.openParenToken); + + 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()); + } + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(node.kind(), left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.ConstructSignature(callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.MethodSignature(name, questionToken, callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.IndexSignature(parameter, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + var openParenToken = node.openParenToken; + + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + var openParenTrailingComments = null; + if (node.parameters.childCount() === 0) { + openParenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + } + + this.movePast(node.openParenToken); + var parameters = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeParameterList(typeParameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + var start = this.position; + this.movePast(node.extendsKeyword); + var type = this.visitType(node.type); + + var result = new TypeScript.Constraint(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + var start = this.position; + + this.movePast(node.elseKeyword); + var statement = node.statement.accept(this); + + var result = new TypeScript.ElseClause(statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var expression = node.expression.accept(this); + + var semicolonPosition = this.position; + + var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + 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(callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.indexSignature); + var indexSignature = node.indexSignature.accept(this); + + this.movePast(node.semicolonToken); + + var result = new TypeScript.IndexMemberDeclaration(indexSignature); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + var variableDeclarator = node.variableDeclarator.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + this.movePast(node.openBraceToken); + var switchClauses = this.visitSyntaxList(node.switchClauses); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseSwitchClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.DefaultSwitchClause(statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.BreakStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ContinueStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var initializer = node.initializer ? node.initializer.accept(this) : null; + + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var left = node.left ? node.left.accept(this) : null; + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.CastExpression(castTerm, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + var propertyName = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var expression = node.expression.accept(this); + expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); + + var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var propertyName = node.propertyName.accept(this); + var callSignature = this.visitCallSignature(node.callSignature); + var block = this.visitBlock(node.block); + + var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionExpression(name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.visitIdentifier(node.identifier); + var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + var start = this.position; + this.movePast(node.finallyKeyword); + var block = node.block.accept(this); + + var result = new TypeScript.FinallyClause(block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, whileKeyword, condition); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.TypeOfExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.DeleteExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.VoidExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + function applyDelta(ast, delta) { + if (ast) { + if (ast._start !== -1) { + ast._start += delta; + } + + if (ast._end !== -1) { + ast._end += delta; + } + } + } + + function applyDeltaToComments(comments, delta) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment, delta); + } + } + } + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var pre = function (cur) { + applyDelta(cur, delta); + applyDeltaToComments(cur.preComments(), delta); + applyDeltaToComments(cur.postComments(), delta); + + switch (cur.kind()) { + case 146 /* Block */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 226 /* ArgumentList */: + applyDelta(cur.closeParenToken, delta); + break; + + case 130 /* ModuleDeclaration */: + applyDelta(cur.endingToken, delta); + break; + + case 131 /* ClassDeclaration */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 161 /* DoStatement */: + applyDelta(cur.whileKeyword, delta); + break; + + case 151 /* SwitchStatement */: + applyDelta(cur.closeParenToken, delta); + break; + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span._start !== -1) { + var delta = start - span._start; + this.applyDelta(span, delta); + + span._end = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = element._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + element._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan(_start, _end) { + this._start = _start; + this._end = _end; + } + ASTSpan.prototype.start = function () { + return this._start; + }; + + ASTSpan.prototype.end = function () { + return this._end; + }; + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, false); + } + + function commentStructuralEqualsIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, true); + } + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); + } + + function commentStructuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + function commentArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.parent = null; + this._start = -1; + this._end = -1; + this._trailingTriviaWidth = 0; + this._astID = astID++; + this._preComments = null; + this._postComments = null; + } + AST.prototype.syntaxID = function () { + return this._astID; + }; + + AST.prototype.start = function () { + return this._start; + }; + + AST.prototype.end = function () { + return this._end; + }; + + AST.prototype.trailingTriviaWidth = function () { + return this._trailingTriviaWidth; + }; + + AST.prototype.fileName = function () { + return this.parent.fileName(); + }; + + AST.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.width = function () { + return this.end() - this.start(); + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + + AST.prototype.isExpression = function () { + return false; + }; + return AST; + })(); + TypeScript.AST = AST; + + var ISyntaxList2 = (function (_super) { + __extends(ISyntaxList2, _super); + function ISyntaxList2(_fileName, members) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISyntaxList2.prototype.childCount = function () { + return this.members.length; + }; + + ISyntaxList2.prototype.childAt = function (index) { + return this.members[index]; + }; + + ISyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISyntaxList2.prototype.kind = function () { + return 1 /* List */; + }; + + ISyntaxList2.prototype.firstOrDefault = function (func) { + return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.lastOrDefault = function (func) { + return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.any = function (func) { + return TypeScript.ArrayUtilities.any(this.members, func); + }; + + ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISyntaxList2; + })(AST); + TypeScript.ISyntaxList2 = ISyntaxList2; + + var ISeparatedSyntaxList2 = (function (_super) { + __extends(ISeparatedSyntaxList2, _super); + function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + this._separatorCount = _separatorCount; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { + return this.members.length; + }; + + ISeparatedSyntaxList2.prototype.separatorCount = function () { + return this._separatorCount; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { + return this.members[index]; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i) === ast) { + return i; + } + } + + return -1; + }; + + ISeparatedSyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISeparatedSyntaxList2.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISeparatedSyntaxList2; + })(AST); + TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; + + var SourceUnit = (function (_super) { + __extends(SourceUnit, _super); + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { + _super.call(this); + this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; + this._fileName = _fileName; + moduleElements && (moduleElements.parent = this); + } + SourceUnit.prototype.fileName = function () { + return this._fileName; + }; + + SourceUnit.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return SourceUnit; + })(AST); + TypeScript.SourceUnit = SourceUnit; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(_text) { + _super.call(this); + this._text = _text; + this._valueText = null; + } + Identifier.prototype.text = function () { + return this._text; + }; + Identifier.prototype.valueText = function () { + if (!this._valueText) { + var text = this._text; + if (text === "__proto__") { + this._valueText = "#__proto__"; + } else { + this._valueText = TypeScript.Syntax.massageEscapes(text); + } + } + + return this._valueText; + }; + + Identifier.prototype.kind = function () { + return 11 /* IdentifierName */; + }; + + 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; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + LiteralExpression.prototype.text = function () { + return this._text; + }; + + LiteralExpression.prototype.valueText = function () { + return this._valueText; + }; + + LiteralExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + ThisExpression.prototype.text = function () { + return this._text; + }; + + ThisExpression.prototype.valueText = function () { + return this._valueText; + }; + + ThisExpression.prototype.kind = function () { + return 35 /* ThisKeyword */; + }; + + 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; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + SuperExpression.prototype.text = function () { + return this._text; + }; + + SuperExpression.prototype.valueText = function () { + return this._valueText; + }; + + SuperExpression.prototype.kind = function () { + return 50 /* SuperKeyword */; + }; + + 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; + + var NumericLiteral = (function (_super) { + __extends(NumericLiteral, _super); + function NumericLiteral(_value, _text, _valueText) { + _super.call(this); + this._value = _value; + this._text = _text; + this._valueText = _valueText; + } + NumericLiteral.prototype.text = function () { + return this._text; + }; + NumericLiteral.prototype.valueText = function () { + return this._valueText; + }; + NumericLiteral.prototype.value = function () { + return this._value; + }; + + NumericLiteral.prototype.kind = function () { + return 13 /* NumericLiteral */; + }; + + 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; + + var RegularExpressionLiteral = (function (_super) { + __extends(RegularExpressionLiteral, _super); + function RegularExpressionLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + RegularExpressionLiteral.prototype.text = function () { + return this._text; + }; + + RegularExpressionLiteral.prototype.valueText = function () { + return this._valueText; + }; + + RegularExpressionLiteral.prototype.kind = function () { + return 12 /* RegularExpressionLiteral */; + }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; + return RegularExpressionLiteral; + })(AST); + TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + StringLiteral.prototype.valueText = function () { + return this._valueText; + }; + + StringLiteral.prototype.kind = function () { + return 14 /* StringLiteral */; + }; + + 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; + + var TypeAnnotation = (function (_super) { + __extends(TypeAnnotation, _super); + function TypeAnnotation(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + TypeAnnotation.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + return TypeAnnotation; + })(AST); + TypeScript.TypeAnnotation = TypeAnnotation; + + var BuiltInType = (function (_super) { + __extends(BuiltInType, _super); + function BuiltInType(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + BuiltInType.prototype.text = function () { + return this._text; + }; + + BuiltInType.prototype.valueText = function () { + return this._valueText; + }; + + BuiltInType.prototype.kind = function () { + return this._nodeType; + }; + return BuiltInType; + })(AST); + TypeScript.BuiltInType = BuiltInType; + + var ExternalModuleReference = (function (_super) { + __extends(ExternalModuleReference, _super); + function ExternalModuleReference(stringLiteral) { + _super.call(this); + this.stringLiteral = stringLiteral; + stringLiteral && (stringLiteral.parent = this); + } + ExternalModuleReference.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + return ExternalModuleReference; + })(AST); + TypeScript.ExternalModuleReference = ExternalModuleReference; + + var ModuleNameModuleReference = (function (_super) { + __extends(ModuleNameModuleReference, _super); + function ModuleNameModuleReference(moduleName) { + _super.call(this); + this.moduleName = moduleName; + moduleName && (moduleName.parent = this); + } + ModuleNameModuleReference.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + return ModuleNameModuleReference; + })(AST); + TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(modifiers, identifier, moduleReference) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.moduleReference = moduleReference; + identifier && (identifier.parent = this); + moduleReference && (moduleReference.parent = this); + } + ImportDeclaration.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(identifier) { + _super.call(this); + this.identifier = identifier; + identifier && (identifier.parent = this); + } + ExportAssignment.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var TypeParameterList = (function (_super) { + __extends(TypeParameterList, _super); + function TypeParameterList(typeParameters) { + _super.call(this); + this.typeParameters = typeParameters; + typeParameters && (typeParameters.parent = this); + } + TypeParameterList.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + return TypeParameterList; + })(AST); + TypeScript.TypeParameterList = TypeParameterList; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + heritageClauses && (heritageClauses.parent = this); + classElements && (classElements.parent = this); + } + ClassDeclaration.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return ClassDeclaration; + })(AST); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + body && (body.parent = this); + heritageClauses && (heritageClauses.parent = this); + } + InterfaceDeclaration.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return InterfaceDeclaration; + })(AST); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var HeritageClause = (function (_super) { + __extends(HeritageClause, _super); + function HeritageClause(_nodeType, typeNames) { + _super.call(this); + this._nodeType = _nodeType; + this.typeNames = typeNames; + typeNames && (typeNames.parent = this); + } + HeritageClause.prototype.kind = function () { + return this._nodeType; + }; + + HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); + }; + return HeritageClause; + })(AST); + TypeScript.HeritageClause = HeritageClause; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { + _super.call(this); + this.modifiers = modifiers; + this.name = name; + this.stringLiteral = stringLiteral; + this.moduleElements = moduleElements; + this.endingToken = endingToken; + name && (name.parent = this); + stringLiteral && (stringLiteral.parent = this); + moduleElements && (moduleElements.parent = this); + } + ModuleDeclaration.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(modifiers, identifier, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionDeclaration.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(modifiers, declaration) { + _super.call(this); + this.modifiers = modifiers; + this.declaration = declaration; + declaration && (declaration.parent = this); + } + VariableStatement.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + declarators && (declarators.parent = this); + } + VariableDeclaration.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + VariableDeclarator.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + return VariableDeclarator; + })(AST); + TypeScript.VariableDeclarator = VariableDeclarator; + + var EqualsValueClause = (function (_super) { + __extends(EqualsValueClause, _super); + function EqualsValueClause(value) { + _super.call(this); + this.value = value; + value && (value.parent = this); + } + EqualsValueClause.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + return EqualsValueClause; + })(AST); + TypeScript.EqualsValueClause = EqualsValueClause; + + var PrefixUnaryExpression = (function (_super) { + __extends(PrefixUnaryExpression, _super); + function PrefixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PrefixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ArrayLiteralExpression = (function (_super) { + __extends(ArrayLiteralExpression, _super); + function ArrayLiteralExpression(expressions) { + _super.call(this); + this.expressions = expressions; + expressions && (expressions.parent = this); + } + ArrayLiteralExpression.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + 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; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + 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; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(openParenTrailingComments, expression) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.expression = expression; + expression && (expression.parent = this); + } + ParenthesizedExpression.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + 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; + + var SimpleArrowFunctionExpression = (function (_super) { + __extends(SimpleArrowFunctionExpression, _super); + function SimpleArrowFunctionExpression(identifier, block, expression) { + _super.call(this); + this.identifier = identifier; + this.block = block; + this.expression = expression; + identifier && (identifier.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + SimpleArrowFunctionExpression.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return SimpleArrowFunctionExpression; + })(AST); + TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; + + var ParenthesizedArrowFunctionExpression = (function (_super) { + __extends(ParenthesizedArrowFunctionExpression, _super); + function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + this.expression = expression; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + ParenthesizedArrowFunctionExpression.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return ParenthesizedArrowFunctionExpression; + })(AST); + TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; + + var QualifiedName = (function (_super) { + __extends(QualifiedName, _super); + function QualifiedName(left, right) { + _super.call(this); + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + QualifiedName.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedName.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); + }; + return QualifiedName; + })(AST); + TypeScript.QualifiedName = QualifiedName; + + var ParameterList = (function (_super) { + __extends(ParameterList, _super); + function ParameterList(openParenTrailingComments, parameters) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.parameters = parameters; + parameters && (parameters.parent = this); + } + ParameterList.prototype.kind = function () { + return 227 /* ParameterList */; + }; + return ParameterList; + })(AST); + TypeScript.ParameterList = ParameterList; + + var ConstructorType = (function (_super) { + __extends(ConstructorType, _super); + function ConstructorType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + ConstructorType.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + return ConstructorType; + })(AST); + TypeScript.ConstructorType = ConstructorType; + + var FunctionType = (function (_super) { + __extends(FunctionType, _super); + function FunctionType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + FunctionType.prototype.kind = function () { + return 123 /* FunctionType */; + }; + return FunctionType; + })(AST); + TypeScript.FunctionType = FunctionType; + + var ObjectType = (function (_super) { + __extends(ObjectType, _super); + function ObjectType(typeMembers) { + _super.call(this); + this.typeMembers = typeMembers; + typeMembers && (typeMembers.parent = this); + } + ObjectType.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); + }; + return ObjectType; + })(AST); + TypeScript.ObjectType = ObjectType; + + var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + ArrayType.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); + }; + return ArrayType; + })(AST); + TypeScript.ArrayType = ArrayType; + + var TypeArgumentList = (function (_super) { + __extends(TypeArgumentList, _super); + function TypeArgumentList(typeArguments) { + _super.call(this); + this.typeArguments = typeArguments; + typeArguments && (typeArguments.parent = this); + } + TypeArgumentList.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + return TypeArgumentList; + })(AST); + TypeScript.TypeArgumentList = TypeArgumentList; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArgumentList) { + _super.call(this); + this.name = name; + this.typeArgumentList = typeArgumentList; + name && (name.parent = this); + typeArgumentList && (typeArgumentList.parent = this); + } + GenericType.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + name && (name.parent = this); + } + TypeQuery.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceLeadingComments, closeBraceToken) { + _super.call(this); + this.statements = statements; + this.closeBraceLeadingComments = closeBraceLeadingComments; + this.closeBraceToken = closeBraceToken; + statements && (statements.parent = this); + } + Block.prototype.kind = function () { + return 146 /* Block */; + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + _super.call(this); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + Parameter.prototype.kind = function () { + return 242 /* Parameter */; + }; + return Parameter; + })(AST); + TypeScript.Parameter = Parameter; + + var MemberAccessExpression = (function (_super) { + __extends(MemberAccessExpression, _super); + function MemberAccessExpression(expression, name) { + _super.call(this); + this.expression = expression; + this.name = name; + expression && (expression.parent = this); + name && (name.parent = this); + } + MemberAccessExpression.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + 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; + + var PostfixUnaryExpression = (function (_super) { + __extends(PostfixUnaryExpression, _super); + function PostfixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PostfixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ElementAccessExpression = (function (_super) { + __extends(ElementAccessExpression, _super); + function ElementAccessExpression(expression, argumentExpression) { + _super.call(this); + this.expression = expression; + this.argumentExpression = argumentExpression; + expression && (expression.parent = this); + argumentExpression && (argumentExpression.parent = this); + } + ElementAccessExpression.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + 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; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + InvocationExpression.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + 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) { + _super.call(this); + this.typeArgumentList = typeArgumentList; + this.closeParenToken = closeParenToken; + this.arguments = _arguments; + + typeArgumentList && (typeArgumentList.parent = this); + _arguments && (_arguments.parent = this); + } + ArgumentList.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + return ArgumentList; + })(AST); + TypeScript.ArgumentList = ArgumentList; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, left, right) { + _super.call(this); + this._nodeType = _nodeType; + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + BinaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(condition, whenTrue, whenFalse) { + _super.call(this); + this.condition = condition; + this.whenTrue = whenTrue; + this.whenFalse = whenFalse; + condition && (condition.parent = this); + whenTrue && (whenTrue.parent = this); + whenFalse && (whenFalse.parent = this); + } + ConditionalExpression.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + 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; + + var ConstructSignature = (function (_super) { + __extends(ConstructSignature, _super); + function ConstructSignature(callSignature) { + _super.call(this); + this.callSignature = callSignature; + callSignature && (callSignature.parent = this); + } + ConstructSignature.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + return ConstructSignature; + })(AST); + TypeScript.ConstructSignature = ConstructSignature; + + var MethodSignature = (function (_super) { + __extends(MethodSignature, _super); + function MethodSignature(propertyName, questionToken, callSignature) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + } + MethodSignature.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + return MethodSignature; + })(AST); + TypeScript.MethodSignature = MethodSignature; + + var IndexSignature = (function (_super) { + __extends(IndexSignature, _super); + function IndexSignature(parameter, typeAnnotation) { + _super.call(this); + this.parameter = parameter; + this.typeAnnotation = typeAnnotation; + parameter && (parameter.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + IndexSignature.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + return IndexSignature; + })(AST); + TypeScript.IndexSignature = IndexSignature; + + var PropertySignature = (function (_super) { + __extends(PropertySignature, _super); + function PropertySignature(propertyName, questionToken, typeAnnotation) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + PropertySignature.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + return PropertySignature; + })(AST); + TypeScript.PropertySignature = PropertySignature; + + var CallSignature = (function (_super) { + __extends(CallSignature, _super); + function CallSignature(typeParameterList, parameterList, typeAnnotation) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + CallSignature.prototype.kind = function () { + return 142 /* CallSignature */; + }; + return CallSignature; + })(AST); + TypeScript.CallSignature = CallSignature; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(identifier, constraint) { + _super.call(this); + this.identifier = identifier; + this.constraint = constraint; + identifier && (identifier.parent = this); + constraint && (constraint.parent = this); + } + TypeParameter.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + Constraint.prototype.kind = function () { + return 239 /* Constraint */; + }; + return Constraint; + })(AST); + TypeScript.Constraint = Constraint; + + var ElseClause = (function (_super) { + __extends(ElseClause, _super); + function ElseClause(statement) { + _super.call(this); + this.statement = statement; + statement && (statement.parent = this); + } + ElseClause.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ElseClause; + })(AST); + TypeScript.ElseClause = ElseClause; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(condition, statement, elseClause) { + _super.call(this); + this.condition = condition; + this.statement = statement; + this.elseClause = elseClause; + condition && (condition.parent = this); + statement && (statement.parent = this); + elseClause && (elseClause.parent = this); + } + IfStatement.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ExpressionStatement.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var ConstructorDeclaration = (function (_super) { + __extends(ConstructorDeclaration, _super); + function ConstructorDeclaration(callSignature, block) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + ConstructorDeclaration.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + return ConstructorDeclaration; + })(AST); + TypeScript.ConstructorDeclaration = ConstructorDeclaration; + + var MemberFunctionDeclaration = (function (_super) { + __extends(MemberFunctionDeclaration, _super); + function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + MemberFunctionDeclaration.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + return MemberFunctionDeclaration; + })(AST); + TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; + + var GetAccessor = (function (_super) { + __extends(GetAccessor, _super); + function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + GetAccessor.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + return GetAccessor; + })(AST); + TypeScript.GetAccessor = GetAccessor; + + var SetAccessor = (function (_super) { + __extends(SetAccessor, _super); + function SetAccessor(modifiers, propertyName, parameterList, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + block && (block.parent = this); + } + SetAccessor.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + return SetAccessor; + })(AST); + TypeScript.SetAccessor = SetAccessor; + + var MemberVariableDeclaration = (function (_super) { + __extends(MemberVariableDeclaration, _super); + function MemberVariableDeclaration(modifiers, variableDeclarator) { + _super.call(this); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + variableDeclarator && (variableDeclarator.parent = this); + } + MemberVariableDeclaration.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + return MemberVariableDeclaration; + })(AST); + TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; + + var IndexMemberDeclaration = (function (_super) { + __extends(IndexMemberDeclaration, _super); + function IndexMemberDeclaration(indexSignature) { + _super.call(this); + this.indexSignature = indexSignature; + indexSignature && (indexSignature.parent = this); + } + IndexMemberDeclaration.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + return IndexMemberDeclaration; + })(AST); + TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ThrowStatement.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ReturnStatement.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + ObjectCreationExpression.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + 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; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(expression, closeParenToken, switchClauses) { + _super.call(this); + this.expression = expression; + this.closeParenToken = closeParenToken; + this.switchClauses = switchClauses; + expression && (expression.parent = this); + switchClauses && (switchClauses.parent = this); + } + SwitchStatement.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseSwitchClause = (function (_super) { + __extends(CaseSwitchClause, _super); + function CaseSwitchClause(expression, statements) { + _super.call(this); + this.expression = expression; + this.statements = statements; + expression && (expression.parent = this); + statements && (statements.parent = this); + } + CaseSwitchClause.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return CaseSwitchClause; + })(AST); + TypeScript.CaseSwitchClause = CaseSwitchClause; + + var DefaultSwitchClause = (function (_super) { + __extends(DefaultSwitchClause, _super); + function DefaultSwitchClause(statements) { + _super.call(this); + this.statements = statements; + statements && (statements.parent = this); + } + DefaultSwitchClause.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return DefaultSwitchClause; + })(AST); + TypeScript.DefaultSwitchClause = DefaultSwitchClause; + + var BreakStatement = (function (_super) { + __extends(BreakStatement, _super); + function BreakStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + BreakStatement.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return BreakStatement; + })(AST); + TypeScript.BreakStatement = BreakStatement; + + var ContinueStatement = (function (_super) { + __extends(ContinueStatement, _super); + function ContinueStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + ContinueStatement.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ContinueStatement; + })(AST); + TypeScript.ContinueStatement = ContinueStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.condition = condition; + this.incrementor = incrementor; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + initializer && (initializer.parent = this); + condition && (condition.parent = this); + incrementor && (incrementor.parent = this); + statement && (statement.parent = this); + } + ForStatement.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(variableDeclaration, left, expression, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.left = left; + this.expression = expression; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + left && (left.parent = this); + expression && (expression.parent = this); + statement && (statement.parent = this); + } + ForInStatement.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WhileStatement.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WithStatement.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var EnumDeclaration = (function (_super) { + __extends(EnumDeclaration, _super); + function EnumDeclaration(modifiers, identifier, enumElements) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.enumElements = enumElements; + identifier && (identifier.parent = this); + enumElements && (enumElements.parent = this); + } + EnumDeclaration.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + return EnumDeclaration; + })(AST); + TypeScript.EnumDeclaration = EnumDeclaration; + + var EnumElement = (function (_super) { + __extends(EnumElement, _super); + function EnumElement(propertyName, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + EnumElement.prototype.kind = function () { + return 243 /* EnumElement */; + }; + return EnumElement; + })(AST); + TypeScript.EnumElement = EnumElement; + + var CastExpression = (function (_super) { + __extends(CastExpression, _super); + function CastExpression(type, expression) { + _super.call(this); + this.type = type; + this.expression = expression; + type && (type.parent = this); + expression && (expression.parent = this); + } + CastExpression.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + 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; + + var ObjectLiteralExpression = (function (_super) { + __extends(ObjectLiteralExpression, _super); + function ObjectLiteralExpression(propertyAssignments) { + _super.call(this); + this.propertyAssignments = propertyAssignments; + propertyAssignments && (propertyAssignments.parent = this); + } + ObjectLiteralExpression.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + 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; + + var SimplePropertyAssignment = (function (_super) { + __extends(SimplePropertyAssignment, _super); + function SimplePropertyAssignment(propertyName, expression) { + _super.call(this); + this.propertyName = propertyName; + this.expression = expression; + propertyName && (propertyName.parent = this); + expression && (expression.parent = this); + } + SimplePropertyAssignment.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + return SimplePropertyAssignment; + })(AST); + TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; + + var FunctionPropertyAssignment = (function (_super) { + __extends(FunctionPropertyAssignment, _super); + function FunctionPropertyAssignment(propertyName, callSignature, block) { + _super.call(this); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionPropertyAssignment.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + return FunctionPropertyAssignment; + })(AST); + TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; + + var FunctionExpression = (function (_super) { + __extends(FunctionExpression, _super); + function FunctionExpression(identifier, callSignature, block) { + _super.call(this); + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionExpression.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; + return FunctionExpression; + })(AST); + TypeScript.FunctionExpression = FunctionExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(block, catchClause, finallyClause) { + _super.call(this); + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + block && (block.parent = this); + catchClause && (catchClause.parent = this); + finallyClause && (finallyClause.parent = this); + } + TryStatement.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(identifier, typeAnnotation, block) { + _super.call(this); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.block = block; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + CatchClause.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var FinallyClause = (function (_super) { + __extends(FinallyClause, _super); + function FinallyClause(block) { + _super.call(this); + this.block = block; + block && (block.parent = this); + } + FinallyClause.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return FinallyClause; + })(AST); + TypeScript.FinallyClause = FinallyClause; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + identifier && (identifier.parent = this); + statement && (statement.parent = this); + } + LabeledStatement.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(statement, whileKeyword, condition) { + _super.call(this); + this.statement = statement; + this.whileKeyword = whileKeyword; + this.condition = condition; + statement && (statement.parent = this); + condition && (condition.parent = this); + } + DoStatement.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var TypeOfExpression = (function (_super) { + __extends(TypeOfExpression, _super); + function TypeOfExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + TypeOfExpression.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + 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; + + var DeleteExpression = (function (_super) { + __extends(DeleteExpression, _super); + function DeleteExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + DeleteExpression.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + 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; + + var VoidExpression = (function (_super) { + __extends(VoidExpression, _super); + function VoidExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + VoidExpression.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + 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; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var Comment = (function () { + function Comment(_trivia, endsLine, _start, _end) { + this._trivia = _trivia; + this.endsLine = endsLine; + this._start = _start; + this._end = _end; + } + Comment.prototype.start = function () { + return this._start; + }; + + Comment.prototype.end = function () { + return this._end; + }; + + Comment.prototype.fullText = function () { + return this._trivia.fullText(); + }; + + Comment.prototype.kind = function () { + return this._trivia.kind(); + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; + }; + return Comment; + })(); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IOUtils) { + function createDirectoryStructure(ioHost, dirName) { + if (ioHost.directoryExists(dirName)) { + return; + } + + var parentDirectory = ioHost.dirName(dirName); + if (parentDirectory != "") { + createDirectoryStructure(ioHost, parentDirectory); + } + ioHost.createDirectory(dirName); + } + + function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + var path = ioHost.resolvePath(fileName); + TypeScript.ioHostResolvePathTime += new Date().getTime() - start; + + var start = new Date().getTime(); + var dirName = ioHost.dirName(path); + TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start; + + var start = new Date().getTime(); + createDirectoryStructure(ioHost, dirName); + TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start; + + var start = new Date().getTime(); + ioHost.writeFile(path, contents, writeByteOrderMark); + TypeScript.ioHostWriteFileTime += new Date().getTime() - start; + } + IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; + + function throwIOError(message, error) { + var errorMessage = message; + if (error && error.message) { + errorMessage += (" " + error.message); + } + throw new Error(errorMessage); + } + IOUtils.throwIOError = throwIOError; + + function combine(prefix, suffix) { + return prefix + "/" + suffix; + } + IOUtils.combine = combine; + + var BufferedTextWriter = (function () { + function BufferedTextWriter(writer, capacity) { + if (typeof capacity === "undefined") { capacity = 1024; } + this.writer = writer; + this.capacity = capacity; + this.buffer = ""; + } + BufferedTextWriter.prototype.Write = function (str) { + this.buffer += str; + if (this.buffer.length >= this.capacity) { + this.writer.Write(this.buffer); + this.buffer = ""; + } + }; + BufferedTextWriter.prototype.WriteLine = function (str) { + this.Write(str + '\r\n'); + }; + BufferedTextWriter.prototype.Close = function () { + this.writer.Write(this.buffer); + this.writer.Close(); + this.buffer = null; + }; + return BufferedTextWriter; + })(); + IOUtils.BufferedTextWriter = BufferedTextWriter; + })(TypeScript.IOUtils || (TypeScript.IOUtils = {})); + var IOUtils = TypeScript.IOUtils; + + TypeScript.IO = (function () { + function getWindowsScriptHostIO() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + 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); + }, + writeFile: function (path, contents, writeByteOrderMark) { + TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + dirName: function (path) { + return fso.GetParentFolderName(path); + }, + findFile: function (rootPath, partialFilePath) { + var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; + + while (true) { + if (fso.FileExists(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); + + if (rootPath == "") { + return null; + } else { + path = fso.BuildPath(rootPath, partialFilePath); + } + } + } + }, + deleteFile: function (path) { + try { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + fso.CreateFolder(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + dir: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "/" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + print: function (str) { + WScript.StdOut.Write(str); + }, + printLine: function (str) { + WScript.Echo(str); + }, + arguments: args, + stderr: WScript.StdErr, + stdout: WScript.StdOut, + watchFile: null, + run: function (source, fileName) { + try { + eval(source); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Error_while_executing_file_0, [fileName]), e); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + quit: function (exitCode) { + if (typeof exitCode === "undefined") { exitCode = 0; } + try { + WScript.Quit(exitCode); + } catch (e) { + } + } + }; + } + ; + + function getNodeIO() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + + return { + appendFile: function (path, content) { + _fs.appendFileSync(path, content); + }, + readFile: function (file, codepage) { + return TypeScript.Environment.readFile(file, codepage); + }, + writeFile: function (path, contents, writeByteOrderMark) { + TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); + } + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + dir: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + try { + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "/" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "/" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "/" + files[i]); + } + } + } catch (err) { + } + + return paths; + } + + return filesInFolder(path); + }, + createDirectory: function (path) { + try { + if (!this.directoryExists(path)) { + _fs.mkdirSync(path); + } + } catch (e) { + IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + dirName: function (path) { + var dirPath = _path.dirname(path); + + if (dirPath === path) { + dirPath = null; + } + + return dirPath; + }, + findFile: function (rootPath, partialFilePath) { + var path = rootPath + "/" + partialFilePath; + + while (true) { + if (_fs.existsSync(path)) { + return { fileInformation: this.readFile(path), path: path }; + } else { + var parentPath = _path.resolve(rootPath, ".."); + + if (rootPath === parentPath) { + return null; + } else { + rootPath = parentPath; + path = _path.resolve(rootPath, partialFilePath); + } + } + } + }, + print: function (str) { + process.stdout.write(str); + }, + printLine: function (str) { + process.stdout.write(str + '\n'); + }, + arguments: process.argv.slice(2), + stderr: { + Write: function (str) { + process.stderr.write(str); + }, + WriteLine: function (str) { + process.stderr.write(str + '\n'); + }, + Close: function () { + } + }, + stdout: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + }, + watchFile: function (fileName, callback) { + var firstRun = true; + var processingChange = false; + + var fileChanged = function (curr, prev) { + if (!firstRun) { + if (curr.mtime < prev.mtime) { + return; + } + + _fs.unwatchFile(fileName, fileChanged); + if (!processingChange) { + processingChange = true; + callback(fileName); + setTimeout(function () { + processingChange = false; + }, 100); + } + } + firstRun = false; + _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); + }; + + fileChanged(); + return { + fileName: fileName, + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + }, + run: function (source, fileName) { + require.main.fileName = fileName; + require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); + require.main._compile(source, fileName); + }, + getExecutingFilePath: function () { + return process.mainModule.filename; + }, + quit: function (code) { + var stderrFlushed = process.stderr.write(''); + var stdoutFlushed = process.stdout.write(''); + process.stderr.on('drain', function () { + stderrFlushed = true; + if (stdoutFlushed) { + process.exit(code); + } + }); + process.stdout.on('drain', function () { + stdoutFlushed = true; + if (stderrFlushed) { + process.exit(code); + } + }); + setTimeout(function () { + process.exit(code); + }, 5); + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") + return getWindowsScriptHostIO(); + else if (typeof module !== 'undefined' && module.exports) + return getNodeIO(); + else + return null; + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OptionsParser = (function () { + function OptionsParser(host, version) { + this.host = host; + this.version = version; + this.DEFAULT_SHORT_FLAG = "-"; + this.DEFAULT_LONG_FLAG = "--"; + this.printedVersion = false; + this.unnamed = []; + this.options = []; + } + OptionsParser.prototype.findOption = function (arg) { + var upperCaseArg = arg && arg.toUpperCase(); + + for (var i = 0; i < this.options.length; i++) { + var current = this.options[i]; + + if (upperCaseArg === (current.short && current.short.toUpperCase()) || upperCaseArg === (current.name && current.name.toUpperCase())) { + return current; + } + } + + return null; + }; + + OptionsParser.prototype.printUsage = function () { + this.printVersion(); + + var optionsWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.options, null); + var fileWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.file1, null); + var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]"; + var syntaxHelp = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Syntax_0, [tscSyntax]); + this.host.printLine(syntaxHelp); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Examples, null) + " tsc hello.ts"); + this.host.printLine(" tsc --out foo.js foo.ts"); + this.host.printLine(" tsc @args.txt"); + this.host.printLine(""); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Options, null)); + + var output = []; + var maxLength = 0; + var i = 0; + + this.options = this.options.sort(function (a, b) { + var aName = a.name.toLowerCase(); + var bName = b.name.toLowerCase(); + + if (aName > bName) { + return 1; + } else if (aName < bName) { + return -1; + } else { + return 0; + } + }); + + for (i = 0; i < this.options.length; i++) { + var option = this.options[i]; + + if (option.experimental) { + continue; + } + + if (!option.usage) { + break; + } + + var usageString = " "; + var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : ""; + + if (option.short) { + usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; + } + + usageString += this.DEFAULT_LONG_FLAG + option.name + type; + + output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]); + + if (usageString.length > maxLength) { + maxLength = usageString.length; + } + } + + var fileDescription = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null); + output.push([" @<" + fileWord + ">", fileDescription]); + + for (i = 0; i < output.length; i++) { + this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); + } + }; + + OptionsParser.prototype.printVersion = function () { + if (!this.printedVersion) { + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Version_0, [this.version])); + this.printedVersion = true; + } + }; + + OptionsParser.prototype.option = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = false; + + this.options.push(config); + }; + + OptionsParser.prototype.flag = function (name, config, short) { + if (!config) { + config = short; + short = null; + } + + config.name = name; + config.short = short; + config.flag = true; + + this.options.push(config); + }; + + OptionsParser.prototype.parseString = function (argString) { + var position = 0; + var tokens = argString.match(/\s+|"|[^\s"]+/g); + + function peek() { + return tokens[position]; + } + + function consume() { + return tokens[position++]; + } + + function consumeQuotedString() { + var value = ''; + consume(); + + var token = peek(); + + while (token && token !== '"') { + consume(); + + value += token; + + token = peek(); + } + + consume(); + + return value; + } + + var args = []; + var currentArg = ''; + + while (position < tokens.length) { + var token = peek(); + + if (token === '"') { + currentArg += consumeQuotedString(); + } else if (token.match(/\s/)) { + if (currentArg.length > 0) { + args.push(currentArg); + currentArg = ''; + } + + consume(); + } else { + consume(); + currentArg += token; + } + } + + if (currentArg.length > 0) { + args.push(currentArg); + } + + this.parse(args); + }; + + OptionsParser.prototype.parse = function (args) { + var position = 0; + + function consume() { + return args[position++]; + } + + while (position < args.length) { + var current = consume(); + var match = current.match(/^(--?|@)(.*)/); + var value = null; + + if (match) { + if (match[1] === '@') { + this.parseString(this.host.readFile(match[2], null).contents); + } else { + var arg = match[2]; + var option = this.findOption(arg); + + if (option === null) { + this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_option_0, [arg])); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); + } else { + if (!option.flag) { + value = consume(); + if (value === undefined) { + this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Option_0_specified_without_1, [arg, TypeScript.getLocalizedText(option.type, null)])); + this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); + continue; + } + } + + option.set(value); + } + } + } else { + this.unnamed.push(current); + } + } + }; + return OptionsParser; + })(); + TypeScript.OptionsParser = OptionsParser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceFile = (function () { + function SourceFile(scriptSnapshot, byteOrderMark) { + this.scriptSnapshot = scriptSnapshot; + this.byteOrderMark = byteOrderMark; + } + return SourceFile; + })(); + + var DiagnosticsLogger = (function () { + function DiagnosticsLogger(ioHost) { + this.ioHost = ioHost; + } + DiagnosticsLogger.prototype.information = function () { + return false; + }; + DiagnosticsLogger.prototype.debug = function () { + return false; + }; + DiagnosticsLogger.prototype.warning = function () { + return false; + }; + DiagnosticsLogger.prototype.error = function () { + return false; + }; + DiagnosticsLogger.prototype.fatal = function () { + return false; + }; + DiagnosticsLogger.prototype.log = function (s) { + this.ioHost.stdout.WriteLine(s); + }; + 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.7.0"; + this.inputFiles = []; + this.resolvedFiles = []; + this.fileNameToSourceFile = new TypeScript.StringHashTable(); + this.hasErrors = false; + this.logger = null; + this.fileExistsCache = TypeScript.createIntrinsicsObject(); + this.resolvePathCache = TypeScript.createIntrinsicsObject(); + } + BatchCompiler.prototype.batchCompile = function () { + var _this = this; + var start = new Date().getTime(); + + TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { + _this.ioHost.printLine(s); + } }; + + if (this.parseOptions()) { + 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(); + return; + } + + this.resolve(); + + 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); + this.logger.log(" file read: " + TypeScript.fileResolutionIOTime); + this.logger.log(" scan imports: " + TypeScript.fileResolutionScanImportsTime); + this.logger.log(" import search: " + TypeScript.fileResolutionImportFileSearchTime); + this.logger.log(" get lib.d.ts: " + TypeScript.fileResolutionGetDefaultLibraryTime); + + this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime); + this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime); + this.logger.log("AST translation time: " + TypeScript.astTranslationTime); + this.logger.log(""); + this.logger.log("Type check time: " + TypeScript.typeCheckTime); + this.logger.log(""); + this.logger.log("Emit time: " + TypeScript.emitTime); + this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime); + + this.logger.log("Total number of symbols created: " + TypeScript.pullSymbolID); + this.logger.log("Specialized types created: " + TypeScript.nSpecializationsCreated); + this.logger.log("Specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); + + this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime); + this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime); + this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime); + this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime); + this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime); + this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime); + this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime); + this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime); + this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime); + + this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime); + + this.logger.log("Compiler resolve path time: " + TypeScript.compilerResolvePathTime); + this.logger.log("Compiler directory name time: " + TypeScript.compilerDirectoryNameTime); + this.logger.log("Compiler directory exists time: " + TypeScript.compilerDirectoryExistsTime); + this.logger.log("Compiler file exists time: " + TypeScript.compilerFileExistsTime); + + this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime); + this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime); + this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime); + this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime); + + this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime); + this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime); + this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime); + } + } + + this.ioHost.quit(this.hasErrors ? 1 : 0); + }; + + BatchCompiler.prototype.resolve = function () { + var _this = this; + var includeDefaultLibrary = !this.compilationSettings.noLib(); + var resolvedFiles = []; + + var start = new Date().getTime(); + + if (!this.compilationSettings.noResolve()) { + var resolutionResults = TypeScript.ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings.useCaseSensitiveFileResolution()); + resolvedFiles = resolutionResults.resolvedFiles; + + includeDefaultLibrary = !this.compilationSettings.noLib() && !resolutionResults.seenNoDefaultLibTag; + + resolutionResults.diagnostics.forEach(function (d) { + return _this.addDiagnostic(d); + }); + } else { + for (var i = 0, n = this.inputFiles.length; i < n; i++) { + var inputFile = this.inputFiles[i]; + var referencedFiles = []; + var importedFiles = []; + + if (this.compilationSettings.generateDeclarationFiles()) { + var references = TypeScript.getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile)); + for (var j = 0; j < references.length; j++) { + referencedFiles.push(references[j].path); + } + + inputFile = this.resolvePath(inputFile); + } + + resolvedFiles.push({ + path: inputFile, + referencedFiles: referencedFiles, + importedFiles: importedFiles + }); + } + } + + var defaultLibStart = new Date().getTime(); + if (includeDefaultLibrary) { + var libraryResolvedFile = { + path: this.getDefaultLibraryFilePath(), + referencedFiles: [], + importedFiles: [] + }; + + resolvedFiles = [libraryResolvedFile].concat(resolvedFiles); + } + TypeScript.fileResolutionGetDefaultLibraryTime += new Date().getTime() - defaultLibStart; + + this.resolvedFiles = resolvedFiles; + + TypeScript.fileResolutionTime = new Date().getTime() - start; + }; + + BatchCompiler.prototype.compile = function () { + var _this = this; + var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); + + this.resolvedFiles.forEach(function (resolvedFile) { + var sourceFile = _this.getSourceFile(resolvedFile.path); + compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, false, resolvedFile.referencedFiles); + }); + + for (var it = compiler.compile(function (path) { + return _this.resolvePath(path); + }); it.moveNext();) { + var result = it.current(); + + result.diagnostics.forEach(function (d) { + return _this.addDiagnostic(d); + }); + if (!this.tryWriteOutputFiles(result.outputFiles)) { + return; + } + } + }; + + BatchCompiler.prototype.parseOptions = function () { + var _this = this; + var opts = new TypeScript.OptionsParser(this.ioHost, this.compilerVersion); + + var mutableSettings = new TypeScript.CompilationSettings(); + opts.option('out', { + usage: { + locCode: TypeScript.DiagnosticCode.Concatenate_and_emit_output_to_single_file, + args: null + }, + type: TypeScript.DiagnosticCode.file2, + set: function (str) { + mutableSettings.outFileOption = str; + } + }); + + opts.option('outDir', { + usage: { + locCode: TypeScript.DiagnosticCode.Redirect_output_structure_to_the_directory, + args: null + }, + type: TypeScript.DiagnosticCode.DIRECTORY, + set: function (str) { + mutableSettings.outDirOption = str; + } + }); + + opts.flag('sourcemap', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.map'] + }, + set: function () { + mutableSettings.mapSourceFiles = true; + } + }); + + opts.option('mapRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + mutableSettings.mapRoot = str; + } + }); + + opts.option('sourceRoot', { + usage: { + locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + args: null + }, + type: TypeScript.DiagnosticCode.LOCATION, + set: function (str) { + mutableSettings.sourceRoot = str; + } + }); + + opts.flag('declaration', { + usage: { + locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, + args: ['.d.ts'] + }, + set: function () { + mutableSettings.generateDeclarationFiles = true; + } + }, 'd'); + + if (this.ioHost.watchFile) { + opts.flag('watch', { + usage: { + locCode: TypeScript.DiagnosticCode.Watch_input_files, + args: null + }, + set: function () { + mutableSettings.watch = true; + } + }, 'w'); + } + + opts.flag('propagateEnumConstants', { + experimental: true, + set: function () { + mutableSettings.propagateEnumConstants = true; + } + }); + + opts.flag('removeComments', { + usage: { + locCode: TypeScript.DiagnosticCode.Do_not_emit_comments_to_output, + args: null + }, + set: function () { + mutableSettings.removeComments = true; + } + }); + + opts.flag('noResolve', { + experimental: true, + usage: { + locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, + args: null + }, + set: function () { + mutableSettings.noResolve = true; + } + }); + + opts.flag('noLib', { + experimental: true, + set: function () { + mutableSettings.noLib = true; + } + }); + + opts.flag('diagnostics', { + experimental: true, + set: function () { + mutableSettings.gatherDiagnostics = true; + } + }); + + 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, + args: ['ES3', 'ES5'] + }, + type: TypeScript.DiagnosticCode.VERSION, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'es3') { + mutableSettings.codeGenTarget = 0 /* EcmaScript3 */; + } else if (type === 'es5') { + mutableSettings.codeGenTarget = 1 /* EcmaScript5 */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2, [type, "ES3", "ES5"])); + } + } + }, 't'); + + opts.option('module', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1, + args: ['commonjs', 'amd'] + }, + type: TypeScript.DiagnosticCode.KIND, + set: function (type) { + type = type.toLowerCase(); + + if (type === 'commonjs') { + mutableSettings.moduleGenTarget = 1 /* Synchronous */; + } else if (type === 'amd') { + mutableSettings.moduleGenTarget = 2 /* Asynchronous */; + } else { + _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type])); + } + } + }, 'm'); + + var needsHelp = false; + opts.flag('help', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_this_message, + args: null + }, + set: function () { + needsHelp = true; + } + }, 'h'); + + opts.flag('useCaseSensitiveFileResolution', { + experimental: true, + set: function () { + mutableSettings.useCaseSensitiveFileResolution = true; + } + }); + var shouldPrintVersionOnly = false; + opts.flag('version', { + usage: { + locCode: TypeScript.DiagnosticCode.Print_the_compiler_s_version_0, + args: [this.compilerVersion] + }, + set: function () { + shouldPrintVersionOnly = true; + } + }, 'v'); + + var locale = null; + opts.option('locale', { + experimental: true, + usage: { + locCode: TypeScript.DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1, + args: ['en', 'ja-jp'] + }, + type: TypeScript.DiagnosticCode.STRING, + set: function (value) { + locale = value; + } + }); + + opts.flag('noImplicitAny', { + usage: { + locCode: TypeScript.DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, + args: null + }, + set: function () { + mutableSettings.noImplicitAny = true; + } + }); + + if (TypeScript.Environment.supportsCodePage()) { + opts.option('codepage', { + usage: { + locCode: TypeScript.DiagnosticCode.Specify_the_codepage_to_use_when_opening_source_files, + args: null + }, + type: TypeScript.DiagnosticCode.NUMBER, + set: function (arg) { + mutableSettings.codepage = parseInt(arg, 10); + } + }); + } + + opts.parse(this.ioHost.arguments); + + this.compilationSettings = TypeScript.ImmutableCompilationSettings.fromCompilationSettings(mutableSettings); + + if (locale) { + if (!this.setLocale(locale)) { + return false; + } + } + + this.inputFiles.push.apply(this.inputFiles, opts.unnamed); + + if (shouldPrintVersionOnly) { + opts.printVersion(); + return false; + } else if (this.inputFiles.length === 0 || needsHelp) { + opts.printUsage(); + return false; + } + + return !this.hasErrors; + }; + + BatchCompiler.prototype.setLocale = function (locale) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp'])); + return false; + } + + var language = matchResult[1]; + var territory = matchResult[3]; + + if (!this.setLanguageAndTerritory(language, territory) && !this.setLanguageAndTerritory(language, null)) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Unsupported_locale_0, [locale])); + return false; + } + + return true; + }; + + BatchCompiler.prototype.setLanguageAndTerritory = function (language, territory) { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + + var filePath = TypeScript.IOUtils.combine(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + + filePath = this.resolvePath(TypeScript.IOUtils.combine(filePath, "diagnosticMessages.generated.json")); + + if (!this.fileExists(filePath)) { + return false; + } + + var fileContents = this.ioHost.readFile(filePath, this.compilationSettings.codepage()); + TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents); + return true; + }; + + BatchCompiler.prototype.watchFiles = function () { + var _this = this; + if (!this.ioHost.watchFile) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]'])); + return; + } + + var lastResolvedFileSet = []; + var watchers = {}; + var firstTime = true; + + var addWatcher = function (fileName) { + if (!watchers[fileName]) { + var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); + watchers[fileName] = watcher; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); + } + }; + + var removeWatcher = function (fileName) { + if (watchers[fileName]) { + watchers[fileName].close(); + delete watchers[fileName]; + } else { + TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); + } + }; + + var onWatchedFileChange = function () { + _this.hasErrors = false; + + _this.fileNameToSourceFile = new TypeScript.StringHashTable(); + + _this.resolve(); + + var oldFiles = lastResolvedFileSet; + var newFiles = _this.resolvedFiles.map(function (resolvedFile) { + return resolvedFile.path; + }).sort(); + + var i = 0, j = 0; + while (i < oldFiles.length && j < newFiles.length) { + var compareResult = oldFiles[i].localeCompare(newFiles[j]); + if (compareResult === 0) { + i++; + j++; + } else if (compareResult < 0) { + removeWatcher(oldFiles[i]); + i++; + } else { + addWatcher(newFiles[j]); + j++; + } + } + + for (var k = i; k < oldFiles.length; k++) { + removeWatcher(oldFiles[k]); + } + + for (k = j; k < newFiles.length; k++) { + addWatcher(newFiles[k]); + } + + lastResolvedFileSet = newFiles; + + if (!firstTime) { + var fileNames = ""; + for (var k = 0; k < lastResolvedFileSet.length; k++) { + fileNames += TypeScript.Environment.newLine + " " + lastResolvedFileSet[k]; + } + _this.ioHost.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.NL_Recompiling_0, [fileNames])); + } else { + firstTime = false; + } + + _this.compile(); + }; + + this.ioHost.stderr = this.ioHost.stdout; + + onWatchedFileChange(); + }; + + BatchCompiler.prototype.getSourceFile = function (fileName) { + var sourceFile = this.fileNameToSourceFile.lookup(fileName); + if (!sourceFile) { + var fileInformation; + + try { + fileInformation = this.ioHost.readFile(fileName, this.compilationSettings.codepage()); + } catch (e) { + this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message])); + fileInformation = new TypeScript.FileInformation("", 0 /* None */); + } + + var snapshot = TypeScript.ScriptSnapshot.fromString(fileInformation.contents); + var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark); + this.fileNameToSourceFile.add(fileName, sourceFile); + } + + return sourceFile; + }; + + BatchCompiler.prototype.getDefaultLibraryFilePath = function () { + var compilerFilePath = this.ioHost.getExecutingFilePath(); + var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); + var libraryFilePath = this.resolvePath(TypeScript.IOUtils.combine(containingDirectoryPath, "lib.d.ts")); + + return libraryFilePath; + }; + + BatchCompiler.prototype.getScriptSnapshot = function (fileName) { + return this.getSourceFile(fileName).scriptSnapshot; + }; + + BatchCompiler.prototype.resolveRelativePath = function (path, directory) { + var start = new Date().getTime(); + + var unQuotedPath = TypeScript.stripStartAndEndQuotes(path); + var normalizedPath; + + if (TypeScript.isRooted(unQuotedPath) || !directory) { + normalizedPath = unQuotedPath; + } else { + normalizedPath = TypeScript.IOUtils.combine(directory, unQuotedPath); + } + + normalizedPath = this.resolvePath(normalizedPath); + + normalizedPath = TypeScript.switchToForwardSlashes(normalizedPath); + + return normalizedPath; + }; + + BatchCompiler.prototype.fileExists = function (path) { + var exists = this.fileExistsCache[path]; + if (exists === undefined) { + var start = new Date().getTime(); + exists = this.ioHost.fileExists(path); + this.fileExistsCache[path] = exists; + TypeScript.compilerFileExistsTime += new Date().getTime() - start; + } + + return exists; + }; + + BatchCompiler.prototype.getParentDirectory = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.dirName(path); + TypeScript.compilerDirectoryNameTime += new Date().getTime() - start; + + return result; + }; + + BatchCompiler.prototype.addDiagnostic = function (diagnostic) { + var diagnosticInfo = diagnostic.info(); + if (diagnosticInfo.category === 1 /* Error */) { + this.hasErrors = true; + } + + this.ioHost.stderr.Write(TypeScript.TypeScriptCompiler.getFullDiagnosticText(diagnostic)); + }; + + BatchCompiler.prototype.tryWriteOutputFiles = function (outputFiles) { + for (var i = 0, n = outputFiles.length; i < n; i++) { + var outputFile = outputFiles[i]; + + try { + this.writeFile(outputFile.name, outputFile.text, outputFile.writeByteOrderMark); + } catch (e) { + this.addDiagnostic(new TypeScript.Diagnostic(outputFile.name, null, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])); + return false; + } + } + + return true; + }; + + BatchCompiler.prototype.writeFile = function (fileName, contents, writeByteOrderMark) { + var start = new Date().getTime(); + TypeScript.IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark); + TypeScript.emitWriteFileTime += new Date().getTime() - start; + }; + + BatchCompiler.prototype.directoryExists = function (path) { + var start = new Date().getTime(); + var result = this.ioHost.directoryExists(path); + TypeScript.compilerDirectoryExistsTime += new Date().getTime() - start; + return result; + }; + + BatchCompiler.prototype.resolvePath = function (path) { + var cachedValue = this.resolvePathCache[path]; + if (!cachedValue) { + var start = new Date().getTime(); + cachedValue = this.ioHost.resolvePath(path); + this.resolvePathCache[path] = cachedValue; + TypeScript.compilerResolvePathTime += new Date().getTime() - start; + } + + return cachedValue; + }; + return BatchCompiler; + })(); + TypeScript.BatchCompiler = BatchCompiler; + + var batch = new TypeScript.BatchCompiler(TypeScript.IO); + batch.batchCompile(); +})(TypeScript || (TypeScript = {})); diff --git a/_infrastructure/tests/typescript/0.9.7/typescript.js b/_infrastructure/tests/typescript/0.9.7/typescript.js new file mode 100644 index 0000000000..29ed8063a7 --- /dev/null +++ b/_infrastructure/tests/typescript/0.9.7/typescript.js @@ -0,0 +1,61380 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +var TypeScript; +(function (TypeScript) { + TypeScript.DiagnosticCode = { + error_TS_0_1: "error TS{0}: {1}", + warning_TS_0_1: "warning TS{0}: {1}", + Unrecognized_escape_sequence: "Unrecognized escape sequence.", + Unexpected_character_0: "Unexpected character {0}.", + Missing_close_quote_character: "Missing close quote character.", + Identifier_expected: "Identifier expected.", + _0_keyword_expected: "'{0}' keyword expected.", + _0_expected: "'{0}' expected.", + Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", + Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", + Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", + Trailing_separator_not_allowed: "Trailing separator not allowed.", + AsteriskSlash_expected: "'*/' expected.", + public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", + Unexpected_token: "Unexpected token.", + Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", + Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", + Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", + Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", + Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", + Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", + Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", + Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", + Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", + Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", + Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", + extends_clause_already_seen: "'extends' clause already seen.", + extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", + Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", + implements_clause_already_seen: "'implements' clause already seen.", + Accessibility_modifier_already_seen: "Accessibility modifier already seen.", + _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", + _0_modifier_already_seen: "'{0}' modifier already seen.", + _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", + Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", + super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", + Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", + Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", + 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_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}'.", + _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", + declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", + declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", + Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", + Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", + set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", + set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", + set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", + set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", + get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", + Modifiers_cannot_appear_here: "Modifiers cannot appear here.", + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", + Class_name_cannot_be_0: "Class name cannot be '{0}'.", + Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", + Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", + Module_name_cannot_be_0: "Module name cannot be '{0}'.", + Enum_member_must_have_initializer: "Enum member must have initializer.", + Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", + Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", + Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", + Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", + module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", + constructor_function_accessor_or_variable: "constructor, function, accessor or variable", + statement: "statement", + case_or_default_clause: "case or default clause", + identifier: "identifier", + call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", + expression: "expression", + type_name: "type name", + property_or_accessor: "property or accessor", + parameter: "parameter", + type: "type", + type_parameter: "type parameter", + 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_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.", + super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", + Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", + Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", + Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", + Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", + Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", + Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", + Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", + Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", + Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", + Getter_0_already_declared: "Getter '{0}' already declared.", + Setter_0_already_declared: "Setter '{0}' already declared.", + Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", + Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", + Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", + Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", + Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", + Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", + Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", + Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", + Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", + Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", + Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", + Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", + Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", + Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", + Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", + Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", + Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", + Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", + Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", + Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", + Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", + Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", + Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", + Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", + Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", + Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", + Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", + Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", + Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", + Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", + Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", + Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", + Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", + Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", + Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", + Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", + Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", + Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", + Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", + Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", + Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", + Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", + Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", + new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", + A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", + Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", + Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", + Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", + A_class_may_only_extend_another_class: "A class may only extend another class.", + A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", + An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", + Unable_to_resolve_type: "Unable to resolve type.", + Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", + Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", + Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", + Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", + Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", + Invalid_new_expression: "Invalid 'new' expression.", + Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", + Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", + Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", + Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", + Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", + Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", + Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", + Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", + Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", + The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", + 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_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_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.", + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", + The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", + Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", + Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", + 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_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}'.", + 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.", + Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", + Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", + Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", + All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", + Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", + Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", + Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", + this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", + Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", + Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", + Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", + Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", + Duplicate_overload_call_signature: "Duplicate overload call signature.", + Duplicate_overload_construct_signature: "Duplicate overload construct signature.", + Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", + Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", + Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", + 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_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.", + Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", + A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", + Rest_parameters_must_be_array_types: "Rest parameters must be array types.", + Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", + 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_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_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.", + Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", + Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", + Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", + Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", + 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_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}", + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", + Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", + All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", + super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", + Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", + Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", + Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", + Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", + Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", + continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", + break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", + Jump_target_not_found: "Jump target not found.", + Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", + TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", + TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", + TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", + TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", + TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", + TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", + TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", + TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", + TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", + TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", + Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", + 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}", + Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", + Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", + Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", + Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", + Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", + Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", + Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", + Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", + Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", + Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", + Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", + Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", + 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.", + 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_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_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.", + Could_not_find_file_0: "Could not find file: '{0}'.", + A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", + Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", + Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", + Emit_Error_0: "Emit Error: {0}.", + Cannot_read_file_0_1: "Cannot read file '{0}': {1}", + Unsupported_file_encoding: "Unsupported file encoding.", + Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", + Unsupported_locale_0: "Unsupported locale: '{0}'.", + Execution_Failed_NL: "Execution Failed.{NL}", + Invalid_call_to_up: "Invalid call to 'up'", + Invalid_call_to_down: "Invalid call to 'down'", + Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", + Unknown_option_0: "Unknown option '{0}'", + Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", + Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", + Could_not_delete_file_0: "Could not delete file '{0}'", + Could_not_create_directory_0: "Could not create directory '{0}'", + Error_while_executing_file_0: "Error while executing file '{0}': ", + Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", + Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", + Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", + Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", + Option_0_specified_without_1: "Option '{0}' specified without '{1}'", + codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", + Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", + Generates_corresponding_0_file: "Generates corresponding {0} file.", + Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", + Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", + Watch_input_files: "Watch input files.", + Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", + Do_not_emit_comments_to_output: "Do not emit comments to output.", + Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", + Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", + Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", + Print_this_message: "Print this message.", + Print_the_compiler_s_version_0: "Print the compiler's version: {0}", + Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", + Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", + Syntax_0: "Syntax: {0}", + options: "options", + file1: "file", + Examples: "Examples:", + Options: "Options:", + Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", + Version_0: "Version {0}", + Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", + NL_Recompiling_0: "{NL}Recompiling ({0}):", + STRING: "STRING", + KIND: "KIND", + file2: "FILE", + VERSION: "VERSION", + LOCATION: "LOCATION", + 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})", + Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", + Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", + Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", + Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", + Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", + new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", + _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", + Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", + Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", + 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.", + 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; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.isArray = function (value) { + return Object.prototype.toString.apply(value, []) === '[object Array]'; + }; + + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + + if (array1 === null || array2 === null) { + return false; + } + + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0, n = array1.length; i < n; i++) { + if (!equals(array1[i], array2[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + + return false; + }; + + ArrayUtilities.groupBy = function (array, func) { + var result = {}; + + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + + var list = result[k] || []; + list.push(v); + result[k] = list; + } + + return result; + }; + + ArrayUtilities.distinct = function (array, equalsFn) { + var result = []; + + for (var i = 0, n = array.length; i < n; i++) { + var current = array[i]; + for (var j = 0; j < result.length; j++) { + if (equalsFn(result[j], current)) { + break; + } + } + + if (j === result.length) { + result.push(current); + } + } + + return result; + }; + + ArrayUtilities.min = function (array, func) { + var min = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + + return min; + }; + + ArrayUtilities.max = function (array, func) { + var max = func(array[0]); + + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + + return max; + }; + + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + + return array[array.length - 1]; + }; + + ArrayUtilities.lastOrDefault = function (array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var v = array[i]; + if (predicate(v, i)) { + return v; + } + } + + return null; + }; + + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value, i)) { + return value; + } + } + + return null; + }; + + ArrayUtilities.first = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (!func || func(value, i)) { + return value; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ArrayUtilities.sum = function (array, func) { + var result = 0; + + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + + return result; + }; + + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + + return result; + }; + + ArrayUtilities.where = function (values, func) { + var result = new Array(); + + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + + return result; + }; + + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + + return false; + }; + + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + + return true; + }; + + ArrayUtilities.binarySearch = function (array, value) { + var low = 0; + var high = array.length - 1; + + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + + if (midValue === value) { + return middle; + } else if (midValue > value) { + high = middle - 1; + } else { + low = middle + 1; + } + } + + return ~low; + }; + + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + + return result; + }; + + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + + ArrayUtilities.indexOf = function (array, predicate) { + for (var i = 0, n = array.length; i < n; i++) { + if (predicate(array[i])) { + return i; + } + } + + return -1; + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitVector) { + var pool = []; + var Constants; + (function (Constants) { + Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; + Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; + + Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; + + Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; + Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; + + Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; + Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; + Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; + })(Constants || (Constants = {})); + + var BitVectorImpl = (function () { + function BitVectorImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.bits = []; + } + BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index / encodedValuesPerNumber) >>> 0; + }; + + BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; + + return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; + }; + + BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { + var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; + + return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; + }; + + BitVectorImpl.prototype.valueAt = function (index) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return undefined; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { + return true; + } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { + return false; + } else { + return undefined; + } + } else { + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + return false; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { + return true; + } else { + return false; + } + } + }; + + BitVectorImpl.prototype.setValueAt = function (index, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + if (this.allowUndefinedValues) { + TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); + + var arrayIndex = this.computeTriStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === undefined) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeTriStateEncodedValueIndex(index); + + var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); + encoded = encoded & clearMask; + + if (value === true) { + encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); + } else if (value === false) { + encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } else { + TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); + + var arrayIndex = this.computeBiStateArrayIndex(index); + var encoded = this.bits[arrayIndex]; + if (encoded === undefined) { + if (value === false) { + return; + } + + encoded = 0; + } + + var bitIndex = this.computeBiStateEncodedValueIndex(index); + + encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); + + if (value) { + encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); + } + + this.bits[arrayIndex] = encoded; + } + }; + + BitVectorImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + this.bits.length = 0; + pool.push(this); + }; + return BitVectorImpl; + })(); + + function getBitVector(allowUndefinedValues) { + if (pool.length === 0) { + return new BitVectorImpl(allowUndefinedValues); + } + + var vector = pool.pop(); + vector.isReleased = false; + vector.allowUndefinedValues = allowUndefinedValues; + + return vector; + } + BitVector.getBitVector = getBitVector; + })(TypeScript.BitVector || (TypeScript.BitVector = {})); + var BitVector = TypeScript.BitVector; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (BitMatrix) { + var pool = []; + + var BitMatrixImpl = (function () { + function BitMatrixImpl(allowUndefinedValues) { + this.allowUndefinedValues = allowUndefinedValues; + this.isReleased = false; + this.vectors = []; + } + BitMatrixImpl.prototype.valueAt = function (x, y) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + return this.allowUndefinedValues ? undefined : false; + } + + return vector.valueAt(y); + }; + + BitMatrixImpl.prototype.setValueAt = function (x, y, value) { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + var vector = this.vectors[x]; + if (!vector) { + if (value === undefined) { + return; + } + + vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); + this.vectors[x] = vector; + } + + vector.setValueAt(y, value); + }; + + BitMatrixImpl.prototype.release = function () { + TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); + this.isReleased = true; + + for (var name in this.vectors) { + if (this.vectors.hasOwnProperty(name)) { + var vector = this.vectors[name]; + vector.release(); + } + } + + this.vectors.length = 0; + pool.push(this); + }; + return BitMatrixImpl; + })(); + + function getBitMatrix(allowUndefinedValues) { + if (pool.length === 0) { + return new BitMatrixImpl(allowUndefinedValues); + } + + var matrix = pool.pop(); + matrix.isReleased = false; + matrix.allowUndefinedValues = allowUndefinedValues; + + return matrix; + } + BitMatrix.getBitMatrix = getBitMatrix; + })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); + var BitMatrix = TypeScript.BitMatrix; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Constants) { + Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; + Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; + })(TypeScript.Constants || (TypeScript.Constants = {})); + var Constants = TypeScript.Constants; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); + var AssertionLevel = TypeScript.AssertionLevel; + + var Debug = (function () { + function Debug() { + } + Debug.shouldAssert = function (level) { + return this.currentAssertionLevel >= level; + }; + + Debug.assert = function (expression, message, verboseDebugInfo) { + if (typeof message === "undefined") { message = ""; } + if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } + if (!expression) { + var verboseDebugString = ""; + if (verboseDebugInfo) { + verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); + } + + throw new Error("Debug Failure. False expression: " + message + verboseDebugString); + } + }; + + Debug.fail = function (message) { + Debug.assert(false, message); + }; + Debug.currentAssertionLevel = 0 /* None */; + return Debug; + })(); + 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 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(); + result.length = this.length(); + + result.diagnosticCode = this._diagnosticKey; + + var _arguments = this.arguments(); + if (_arguments && _arguments.length > 0) { + result.arguments = _arguments; + } + + return result; + }; + + Diagnostic.prototype.diagnosticKey = function () { + return this._diagnosticKey; + }; + + Diagnostic.prototype.arguments = function () { + return this._arguments; + }; + + Diagnostic.prototype.text = function () { + return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.message = function () { + return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); + }; + + Diagnostic.prototype.additionalLocations = function () { + return this._additionalLocations || []; + }; + + Diagnostic.equals = function (diagnostic1, diagnostic2) { + return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { + return v1 === v2; + }); + }; + + Diagnostic.prototype.info = function () { + return getDiagnosticInfoFromKey(this.diagnosticKey()); + }; + return Diagnostic; + })(Location); + TypeScript.Diagnostic = Diagnostic; + + function newLine() { + return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; + } + TypeScript.newLine = newLine; + + function getLargestIndex(diagnostic) { + var largest = -1; + var regex = /\{(\d+)\}/g; + + var match; + while (match = regex.exec(diagnostic)) { + var val = parseInt(match[1]); + if (!isNaN(val) && val > largest) { + largest = val; + } + } + + return largest; + } + + function getDiagnosticInfoFromKey(diagnosticKey) { + var result = TypeScript.diagnosticInformationMap[diagnosticKey]; + TypeScript.Debug.assert(result); + return result; + } + + function getLocalizedText(diagnosticKey, args) { + if (TypeScript.LocalizedDiagnosticMessages) { + } + + var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; + TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); + + var actualCount = args ? args.length : 0; + + var expectedCount = 1 + getLargestIndex(diagnosticKey); + + if (expectedCount !== actualCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); + } + + var valueCount = 1 + getLargestIndex(diagnosticMessageText); + if (valueCount !== expectedCount) { + throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); + } + + diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { + return typeof args[num] !== 'undefined' ? args[num] : match; + }); + + diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { + return TypeScript.newLine(); + }); + + return diagnosticMessageText; + } + TypeScript.getLocalizedText = getLocalizedText; + + function getDiagnosticMessage(diagnosticKey, args) { + var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); + var diagnosticMessageText = getLocalizedText(diagnosticKey, args); + + var message; + if (diagnostic.category === 1 /* Error */) { + message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else if (diagnostic.category === 0 /* Warning */) { + message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); + } else { + message = diagnosticMessageText; + } + + return message; + } + TypeScript.getDiagnosticMessage = getDiagnosticMessage; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error("Invalid argument: " + argument + ". " + message); + }; + + Errors.argumentOutOfRange = function (argument) { + return new Error("Argument out of range: " + argument); + }; + + Errors.argumentNull = function (argument) { + return new Error("Argument null: " + argument); + }; + + Errors.abstract = function () { + return new Error("Operation not implemented properly by subclass."); + }; + + Errors.notYetImplemented = function () { + return new Error("Not yet implemented."); + }; + + Errors.invalidOperation = function (message) { + return new Error("Invalid operation: " + message); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Hash = (function () { + function Hash() { + } + Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { + var hashCode = Hash.FNV_BASE; + var end = start + len; + + for (var i = start; i < end; i++) { + hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); + } + + return hashCode; + }; + + Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { + var hash = 0; + + for (var i = 0; i < len; i++) { + var ch = key[start + i]; + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeSimple31BitStringHashCode = function (key) { + var hash = 0; + + var start = 0; + var len = key.length; + + for (var i = 0; i < len; i++) { + var ch = key.charCodeAt(start + i); + + hash = ((((hash << 5) - hash) | 0) + ch) | 0; + } + + return hash & 0x7FFFFFFF; + }; + + Hash.computeMurmur2StringHashCode = function (key, seed) { + var m = 0x5bd1e995; + var r = 24; + + var numberOfCharsLeft = key.length; + var h = Math.abs(seed ^ numberOfCharsLeft); + + var index = 0; + while (numberOfCharsLeft >= 2) { + var c1 = key.charCodeAt(index); + var c2 = key.charCodeAt(index + 1); + + var k = Math.abs(c1 | (c2 << 16)); + + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + k ^= k >> r; + k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); + + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= k; + + index += 2; + numberOfCharsLeft -= 2; + } + + if (numberOfCharsLeft === 1) { + h ^= key.charCodeAt(index); + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + } + + h ^= h >> 13; + h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); + h ^= h >> 15; + + return h; + }; + + Hash.getPrime = function (min) { + for (var i = 0; i < Hash.primes.length; i++) { + var num = Hash.primes[i]; + if (num >= min) { + return num; + } + } + + throw TypeScript.Errors.notYetImplemented(); + }; + + Hash.expandPrime = function (oldSize) { + var num = oldSize << 1; + if (num > 2146435069 && 2146435069 > oldSize) { + return 2146435069; + } + return Hash.getPrime(num); + }; + + Hash.combine = function (value, currentHash) { + return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; + }; + Hash.FNV_BASE = 2166136261; + Hash.FNV_PRIME = 16777619; + + Hash.primes = [ + 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, + 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, + 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, + 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, + 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, + 4166287, 4999559, 5999471, 7199369]; + return Hash; + })(); + TypeScript.Hash = Hash; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultHashTableCapacity = 1024; + + var HashTableEntry = (function () { + function HashTableEntry(Key, Value, HashCode, Next) { + this.Key = Key; + this.Value = Value; + this.HashCode = HashCode; + this.Next = Next; + } + return HashTableEntry; + })(); + + var HashTable = (function () { + function HashTable(capacity, hash) { + this.hash = hash; + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + HashTable.prototype.set = function (key, value) { + this.addOrSet(key, value, false); + }; + + HashTable.prototype.add = function (key, value) { + this.addOrSet(key, value, true); + }; + + HashTable.prototype.containsKey = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + return entry !== null; + }; + + HashTable.prototype.get = function (key) { + var hashCode = this.computeHashCode(key); + var entry = this.findEntry(key, hashCode); + + return entry === null ? null : entry.Value; + }; + + HashTable.prototype.computeHashCode = function (key) { + var hashCode = this.hash === null ? key.hashCode : this.hash(key); + + hashCode = hashCode & 0x7FFFFFFF; + TypeScript.Debug.assert(hashCode >= 0); + + return hashCode; + }; + + HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { + var hashCode = this.computeHashCode(key); + + var entry = this.findEntry(key, hashCode); + if (entry !== null) { + if (throwOnExistingEntry) { + throw TypeScript.Errors.argument('key', "Key was already in table."); + } + + entry.Key = key; + entry.Value = value; + return; + } + + return this.addEntry(key, value, hashCode); + }; + + HashTable.prototype.findEntry = function (key, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && key === e.Key) { + return e; + } + } + + return null; + }; + + HashTable.prototype.addEntry = function (key, value, hashCode) { + var index = hashCode % this.entries.length; + + var e = new HashTableEntry(key, value, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count >= (this.entries.length / 2)) { + this.grow(); + } + + this.count++; + return e.Key; + }; + + HashTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + return HashTable; + })(); + Collections.HashTable = HashTable; + + function createHashTable(capacity, hash) { + if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } + if (typeof hash === "undefined") { hash = null; } + return new HashTable(capacity, hash); + } + Collections.createHashTable = createHashTable; + + var currentHashCode = 1; + function identityHashCode(value) { + if (value.__hash === undefined) { + value.__hash = currentHashCode; + currentHashCode++; + } + + return value.__hash; + } + Collections.identityHashCode = identityHashCode; + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + TypeScript.nodeMakeDirectoryTime = 0; + TypeScript.nodeCreateBufferTime = 0; + TypeScript.nodeWriteFileSyncTime = 0; + + (function (ByteOrderMark) { + ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; + ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; + ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; + ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; + })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); + var ByteOrderMark = TypeScript.ByteOrderMark; + + var FileInformation = (function () { + function FileInformation(contents, byteOrderMark) { + this.contents = contents; + this.byteOrderMark = byteOrderMark; + } + return FileInformation; + })(); + TypeScript.FileInformation = FileInformation; + + TypeScript.Environment = (function () { + function getWindowsScriptHostEnvironment() { + try { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + } catch (e) { + return null; + } + + var streamObjectPool = []; + + function getStreamObject() { + if (streamObjectPool.length > 0) { + return streamObjectPool.pop(); + } else { + return new ActiveXObject("ADODB.Stream"); + } + } + + function releaseStreamObject(obj) { + streamObjectPool.push(obj); + } + + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + + return { + newLine: "\r\n", + currentDirectory: function () { + return WScript.CreateObject("WScript.Shell").CurrentDirectory; + }, + supportsCodePage: function () { + return WScript.ReadFile; + }, + readFile: function (path, codepage) { + try { + if (codepage !== null && this.supportsCodePage()) { + try { + var contents = WScript.ReadFile(path, codepage); + return new FileInformation(contents, 0 /* None */); + } catch (e) { + } + } + + var streamObj = getStreamObject(); + streamObj.Open(); + streamObj.Type = 2; + + streamObj.Charset = 'x-ansi'; + + streamObj.LoadFromFile(path); + var bomChar = streamObj.ReadText(2); + + streamObj.Position = 0; + + var byteOrderMark = 0 /* None */; + + if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { + streamObj.Charset = 'unicode'; + byteOrderMark = 2 /* Utf16BigEndian */; + } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { + streamObj.Charset = 'unicode'; + byteOrderMark = 3 /* Utf16LittleEndian */; + } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { + streamObj.Charset = 'utf-8'; + byteOrderMark = 1 /* Utf8 */; + } else { + streamObj.Charset = 'utf-8'; + } + + var contents = streamObj.ReadText(-1); + streamObj.Close(); + releaseStreamObject(streamObj); + return new FileInformation(contents, byteOrderMark); + } catch (err) { + var message; + if (err.number === -2147024809) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); + } + + throw new Error(message); + } + }, + writeFile: function (path, contents, writeByteOrderMark) { + var textStream = getStreamObject(); + textStream.Charset = 'utf-8'; + textStream.Open(); + textStream.WriteText(contents, 0); + + if (!writeByteOrderMark) { + textStream.Position = 3; + } else { + textStream.Position = 0; + } + + var fileStream = getStreamObject(); + fileStream.Type = 1; + fileStream.Open(); + + textStream.CopyTo(fileStream); + + fileStream.Flush(); + fileStream.SaveToFile(path, 2); + fileStream.Close(); + + textStream.Flush(); + textStream.Close(); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + deleteFile: function (path) { + if (fso.FileExists(path)) { + fso.DeleteFile(path, true); + } + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + listFiles: function (path, spec, options) { + options = options || {}; + function filesInFolder(folder, root) { + var paths = []; + var fc; + + if (options.recursive) { + fc = new Enumerator(folder.subfolders); + + for (; !fc.atEnd(); fc.moveNext()) { + paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); + } + } + + fc = new Enumerator(folder.files); + + for (; !fc.atEnd(); fc.moveNext()) { + if (!spec || fc.item().Name.match(spec)) { + paths.push(root + "\\" + fc.item().Name); + } + } + + return paths; + } + + var folder = fso.GetFolder(path); + var paths = []; + + return filesInFolder(folder, path); + }, + arguments: args, + standardOut: WScript.StdOut + }; + } + ; + + function getNodeEnvironment() { + var _fs = require('fs'); + var _path = require('path'); + var _module = require('module'); + var _os = require('os'); + + return { + newLine: _os.EOL, + currentDirectory: function () { + return process.cwd(); + }, + supportsCodePage: function () { + return false; + }, + readFile: function (file, codepage) { + if (codepage !== null) { + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); + } + + var buffer = _fs.readFileSync(file); + switch (buffer[0]) { + case 0xFE: + if (buffer[1] === 0xFF) { + var i = 0; + while ((i + 1) < buffer.length) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + i += 2; + } + return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); + } + break; + case 0xFF: + if (buffer[1] === 0xFE) { + return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); + } + break; + case 0xEF: + if (buffer[1] === 0xBB) { + return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); + } + } + + return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); + }, + writeFile: function (path, contents, writeByteOrderMark) { + function mkdirRecursiveSync(path) { + var stats = _fs.statSync(path); + if (stats.isFile()) { + throw "\"" + path + "\" exists but isn't a directory."; + } else if (stats.isDirectory()) { + return; + } else { + mkdirRecursiveSync(_path.dirname(path)); + _fs.mkdirSync(path, 509); + } + } + var start = new Date().getTime(); + mkdirRecursiveSync(_path.dirname(path)); + TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; + + if (writeByteOrderMark) { + contents = '\uFEFF' + contents; + } + + var start = new Date().getTime(); + + var chunkLength = 4 * 1024; + var fileDescriptor = _fs.openSync(path, "w"); + try { + for (var index = 0; index < contents.length; index += chunkLength) { + var bufferStart = new Date().getTime(); + var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); + TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; + + _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); + } + } finally { + _fs.closeSync(fileDescriptor); + } + + TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + deleteFile: function (path) { + try { + _fs.unlinkSync(path); + } catch (e) { + } + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + listFiles: function dir(path, spec, options) { + options = options || {}; + + function filesInFolder(folder) { + var paths = []; + + var files = _fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = _fs.statSync(folder + "\\" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "\\" + files[i])); + } else if (stat.isFile() && (!spec || files[i].match(spec))) { + paths.push(folder + "\\" + files[i]); + } + } + + return paths; + } + + return filesInFolder(path); + }, + arguments: process.argv.slice(2), + standardOut: { + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } + } + }; + } + ; + + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWindowsScriptHostEnvironment(); + } else if (typeof module !== 'undefined' && module.exports) { + return getNodeEnvironment(); + } else { + return null; + } + })(); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (IntegerUtilities) { + function integerDivide(numerator, denominator) { + return (numerator / denominator) >> 0; + } + IntegerUtilities.integerDivide = integerDivide; + + function integerMultiplyLow32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; + return resultLow32; + } + IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; + + function integerMultiplyHigh32Bits(n1, n2) { + var n1Low16 = n1 & 0x0000ffff; + var n1High16 = n1 >>> 16; + + var n2Low16 = n2 & 0x0000ffff; + var n2High16 = n2 >>> 16; + + var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); + return resultHigh32; + } + IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; + + function isInteger(text) { + return /^[0-9]+$/.test(text); + } + IntegerUtilities.isInteger = isInteger; + + function isHexInteger(text) { + return /^0(x|X)[0-9a-fA-F]+$/.test(text); + } + IntegerUtilities.isHexInteger = isHexInteger; + })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); + var IntegerUtilities = TypeScript.IntegerUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineMap = (function () { + function LineMap(_computeLineStarts, length) { + this._computeLineStarts = _computeLineStarts; + this.length = length; + this._lineStarts = null; + } + LineMap.prototype.toJSON = function (key) { + return { lineStarts: this.lineStarts(), length: this.length }; + }; + + LineMap.prototype.equals = function (other) { + return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { + return v1 === v2; + }); + }; + + LineMap.prototype.lineStarts = function () { + if (this._lineStarts === null) { + this._lineStarts = this._computeLineStarts(); + } + + return this._lineStarts; + }; + + LineMap.prototype.lineCount = function () { + return this.lineStarts().length; + }; + + LineMap.prototype.getPosition = function (line, character) { + return this.lineStarts()[line] + character; + }; + + LineMap.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + LineMap.prototype.getLineStartPosition = function (lineNumber) { + return this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + lineAndCharacter.line = lineNumber; + lineAndCharacter.character = position - this.lineStarts()[lineNumber]; + }; + + LineMap.prototype.getLineAndCharacterFromPosition = function (position) { + if (position < 0 || position > this.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); + }; + LineMap.empty = new LineMap(function () { + return [0]; + }, 0); + return LineMap; + })(); + TypeScript.LineMap = LineMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var LineAndCharacter = (function () { + function LineAndCharacter(line, character) { + this._line = 0; + this._character = 0; + if (line < 0) { + throw TypeScript.Errors.argumentOutOfRange("line"); + } + + if (character < 0) { + throw TypeScript.Errors.argumentOutOfRange("character"); + } + + this._line = line; + this._character = character; + } + LineAndCharacter.prototype.line = function () { + return this._line; + }; + + LineAndCharacter.prototype.character = function () { + return this._character; + }; + return LineAndCharacter; + })(); + TypeScript.LineAndCharacter = LineAndCharacter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MathPrototype = (function () { + function MathPrototype() { + } + MathPrototype.max = function (a, b) { + return a >= b ? a : b; + }; + + MathPrototype.min = function (a, b) { + return a <= b ? a : b; + }; + return MathPrototype; + })(); + TypeScript.MathPrototype = MathPrototype; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Collections) { + Collections.DefaultStringTableCapacity = 256; + + var StringTableEntry = (function () { + function StringTableEntry(Text, HashCode, Next) { + this.Text = Text; + this.HashCode = HashCode; + this.Next = Next; + } + return StringTableEntry; + })(); + + var StringTable = (function () { + function StringTable(capacity) { + this.count = 0; + var size = TypeScript.Hash.getPrime(capacity); + this.entries = TypeScript.ArrayUtilities.createArray(size, null); + } + StringTable.prototype.addCharArray = function (key, start, len) { + var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; + + var entry = this.findCharArrayEntry(key, start, len, hashCode); + if (entry !== null) { + return entry.Text; + } + + var slice = key.slice(start, start + len); + return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); + }; + + StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { + for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { + if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { + return e; + } + } + + return null; + }; + + StringTable.prototype.addEntry = function (text, hashCode) { + var index = hashCode % this.entries.length; + + var e = new StringTableEntry(text, hashCode, this.entries[index]); + + this.entries[index] = e; + + if (this.count === this.entries.length) { + this.grow(); + } + + this.count++; + return e.Text; + }; + + StringTable.prototype.grow = function () { + var newSize = TypeScript.Hash.expandPrime(this.entries.length); + + var oldEntries = this.entries; + var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); + + this.entries = newEntries; + + for (var i = 0; i < oldEntries.length; i++) { + var e = oldEntries[i]; + while (e !== null) { + var newIndex = e.HashCode % newSize; + var tmp = e.Next; + e.Next = newEntries[newIndex]; + newEntries[newIndex] = e; + e = tmp; + } + } + }; + + StringTable.textCharArrayEquals = function (text, array, start, length) { + if (text.length !== length) { + return false; + } + + var s = start; + for (var i = 0; i < length; i++) { + if (text.charCodeAt(i) !== array[s]) { + return false; + } + + s++; + } + + return true; + }; + return StringTable; + })(); + Collections.StringTable = StringTable; + + Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); + })(TypeScript.Collections || (TypeScript.Collections = {})); + var Collections = TypeScript.Collections; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + + StringUtilities.fromCharCodeArray = function (array) { + return String.fromCharCode.apply(null, array); + }; + + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + + StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { + for (var i = 0; i < count; i++) { + destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); + } + }; + + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + + StringUtilities.stringEquals = function (val1, val2) { + return val1 === val2; + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var global = Function("return this").call(null); + +var TypeScript; +(function (TypeScript) { + var Clock; + (function (Clock) { + Clock.now; + Clock.resolution; + + if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { + global['WScript'].InitializeProjection(); + + Clock.now = function () { + return TestUtilities.QueryPerformanceCounter(); + }; + + Clock.resolution = TestUtilities.QueryPerformanceFrequency(); + } else { + Clock.now = function () { + return Date.now(); + }; + + Clock.resolution = 1000; + } + })(Clock || (Clock = {})); + + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = Clock.now(); + }; + + Timer.prototype.end = function () { + this.time = (Clock.now() - this.startTime); + }; + return Timer; + })(); + TypeScript.Timer = Timer; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (DiagnosticCategory) { + DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; + DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; + DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; + DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; + })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); + var DiagnosticCategory = TypeScript.DiagnosticCategory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.diagnosticInformationMap = { + "error TS{0}: {1}": { + "code": 0, + "category": 3 /* NoPrefix */ + }, + "warning TS{0}: {1}": { + "code": 1, + "category": 3 /* NoPrefix */ + }, + "Unrecognized escape sequence.": { + "code": 1000, + "category": 1 /* Error */ + }, + "Unexpected character {0}.": { + "code": 1001, + "category": 1 /* Error */ + }, + "Missing close quote character.": { + "code": 1002, + "category": 1 /* Error */ + }, + "Identifier expected.": { + "code": 1003, + "category": 1 /* Error */ + }, + "'{0}' keyword expected.": { + "code": 1004, + "category": 1 /* Error */ + }, + "'{0}' expected.": { + "code": 1005, + "category": 1 /* Error */ + }, + "Identifier expected; '{0}' is a keyword.": { + "code": 1006, + "category": 1 /* Error */ + }, + "Automatic semicolon insertion not allowed.": { + "code": 1007, + "category": 1 /* Error */ + }, + "Unexpected token; '{0}' expected.": { + "code": 1008, + "category": 1 /* Error */ + }, + "Trailing separator not allowed.": { + "code": 1009, + "category": 1 /* Error */ + }, + "'*/' expected.": { + "code": 1010, + "category": 1 /* Error */ + }, + "'public' or 'private' modifier must precede 'static'.": { + "code": 1011, + "category": 1 /* Error */ + }, + "Unexpected token.": { + "code": 1012, + "category": 1 /* Error */ + }, + "Catch clause parameter cannot have a type annotation.": { + "code": 1013, + "category": 1 /* Error */ + }, + "Rest parameter must be last in list.": { + "code": 1014, + "category": 1 /* Error */ + }, + "Parameter cannot have question mark and initializer.": { + "code": 1015, + "category": 1 /* Error */ + }, + "Required parameter cannot follow optional parameter.": { + "code": 1016, + "category": 1 /* Error */ + }, + "Index signatures cannot have rest parameters.": { + "code": 1017, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have accessibility modifiers.": { + "code": 1018, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have a question mark.": { + "code": 1019, + "category": 1 /* Error */ + }, + "Index signature parameter cannot have an initializer.": { + "code": 1020, + "category": 1 /* Error */ + }, + "Index signature must have a type annotation.": { + "code": 1021, + "category": 1 /* Error */ + }, + "Index signature parameter must have a type annotation.": { + "code": 1022, + "category": 1 /* Error */ + }, + "Index signature parameter type must be 'string' or 'number'.": { + "code": 1023, + "category": 1 /* Error */ + }, + "'extends' clause already seen.": { + "code": 1024, + "category": 1 /* Error */ + }, + "'extends' clause must precede 'implements' clause.": { + "code": 1025, + "category": 1 /* Error */ + }, + "Classes can only extend a single class.": { + "code": 1026, + "category": 1 /* Error */ + }, + "'implements' clause already seen.": { + "code": 1027, + "category": 1 /* Error */ + }, + "Accessibility modifier already seen.": { + "code": 1028, + "category": 1 /* Error */ + }, + "'{0}' modifier must precede '{1}' modifier.": { + "code": 1029, + "category": 1 /* Error */ + }, + "'{0}' modifier already seen.": { + "code": 1030, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a class element.": { + "code": 1031, + "category": 1 /* Error */ + }, + "Interface declaration cannot have 'implements' clause.": { + "code": 1032, + "category": 1 /* Error */ + }, + "'super' invocation cannot have type arguments.": { + "code": 1034, + "category": 1 /* Error */ + }, + "Only ambient modules can use quoted names.": { + "code": 1035, + "category": 1 /* Error */ + }, + "Statements are not allowed in ambient contexts.": { + "code": 1036, + "category": 1 /* Error */ + }, + "Implementations are not allowed in ambient contexts.": { + "code": 1037, + "category": 1 /* Error */ + }, + "'declare' modifier not allowed for code already in an ambient context.": { + "code": 1038, + "category": 1 /* Error */ + }, + "Initializers are not allowed in ambient contexts.": { + "code": 1039, + "category": 1 /* Error */ + }, + "Parameter property declarations can only be used in a non-ambient constructor declaration.": { + "code": 1040, + "category": 1 /* Error */ + }, + "Function implementation expected.": { + "code": 1041, + "category": 1 /* Error */ + }, + "Constructor implementation expected.": { + "code": 1042, + "category": 1 /* Error */ + }, + "Function overload name must be '{0}'.": { + "code": 1043, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a module element.": { + "code": 1044, + "category": 1 /* Error */ + }, + "'declare' modifier cannot appear on an interface declaration.": { + "code": 1045, + "category": 1 /* Error */ + }, + "'declare' modifier required for top level element.": { + "code": 1046, + "category": 1 /* Error */ + }, + "Rest parameter cannot be optional.": { + "code": 1047, + "category": 1 /* Error */ + }, + "Rest parameter cannot have an initializer.": { + "code": 1048, + "category": 1 /* Error */ + }, + "'set' accessor must have one and only one parameter.": { + "code": 1049, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot be optional.": { + "code": 1051, + "category": 1 /* Error */ + }, + "'set' accessor parameter cannot have an initializer.": { + "code": 1052, + "category": 1 /* Error */ + }, + "'set' accessor cannot have rest parameter.": { + "code": 1053, + "category": 1 /* Error */ + }, + "'get' accessor cannot have parameters.": { + "code": 1054, + "category": 1 /* Error */ + }, + "Modifiers cannot appear here.": { + "code": 1055, + "category": 1 /* Error */ + }, + "Accessors are only available when targeting ECMAScript 5 and higher.": { + "code": 1056, + "category": 1 /* Error */ + }, + "Class name cannot be '{0}'.": { + "code": 1057, + "category": 1 /* Error */ + }, + "Interface name cannot be '{0}'.": { + "code": 1058, + "category": 1 /* Error */ + }, + "Enum name cannot be '{0}'.": { + "code": 1059, + "category": 1 /* Error */ + }, + "Module name cannot be '{0}'.": { + "code": 1060, + "category": 1 /* Error */ + }, + "Enum member must have initializer.": { + "code": 1061, + "category": 1 /* Error */ + }, + "Export assignment cannot be used in internal modules.": { + "code": 1063, + "category": 1 /* Error */ + }, + "Export assignment not allowed in module with exported element.": { + "code": 1064, + "category": 1 /* Error */ + }, + "Module cannot have multiple export assignments.": { + "code": 1065, + "category": 1 /* Error */ + }, + "Ambient enum elements can only have integer literal initializers.": { + "code": 1066, + "category": 1 /* Error */ + }, + "module, class, interface, enum, import or statement": { + "code": 1067, + "category": 3 /* NoPrefix */ + }, + "constructor, function, accessor or variable": { + "code": 1068, + "category": 3 /* NoPrefix */ + }, + "statement": { + "code": 1069, + "category": 3 /* NoPrefix */ + }, + "case or default clause": { + "code": 1070, + "category": 3 /* NoPrefix */ + }, + "identifier": { + "code": 1071, + "category": 3 /* NoPrefix */ + }, + "call, construct, index, property or function signature": { + "code": 1072, + "category": 3 /* NoPrefix */ + }, + "expression": { + "code": 1073, + "category": 3 /* NoPrefix */ + }, + "type name": { + "code": 1074, + "category": 3 /* NoPrefix */ + }, + "property or accessor": { + "code": 1075, + "category": 3 /* NoPrefix */ + }, + "parameter": { + "code": 1076, + "category": 3 /* NoPrefix */ + }, + "type": { + "code": 1077, + "category": 3 /* NoPrefix */ + }, + "type parameter": { + "code": 1078, + "category": 3 /* NoPrefix */ + }, + "'declare' modifier not allowed on import declaration.": { + "code": 1079, + "category": 1 /* Error */ + }, + "Function overload must be static.": { + "code": 1080, + "category": 1 /* Error */ + }, + "Function overload must not be static.": { + "code": 1081, + "category": 1 /* Error */ + }, + "Parameter property declarations cannot be used in a constructor overload.": { + "code": 1083, + "category": 1 /* Error */ + }, + "Invalid 'reference' directive syntax.": { + "code": 1084, + "category": 1 /* Error */ + }, + "Octal literals are not available when targeting ECMAScript 5 and higher.": { + "code": 1085, + "category": 1 /* Error */ + }, + "Accessors are not allowed in ambient contexts.": { + "code": 1086, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a constructor declaration.": { + "code": 1089, + "category": 1 /* Error */ + }, + "'{0}' modifier cannot appear on a parameter.": { + "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 */ + }, + "The name '{0}' does not exist in the current scope.": { + "code": 2001, + "category": 1 /* Error */ + }, + "The name '{0}' does not refer to a value.": { + "code": 2002, + "category": 1 /* Error */ + }, + "'super' can only be used inside a class instance method.": { + "code": 2003, + "category": 1 /* Error */ + }, + "The left-hand side of an assignment expression must be a variable, property or indexer.": { + "code": 2004, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable. Did you mean to include 'new'?": { + "code": 2161, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not callable.": { + "code": 2006, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not newable.": { + "code": 2007, + "category": 1 /* Error */ + }, + "Value of type '{0}' is not indexable by type '{1}'.": { + "code": 2008, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { + "code": 2009, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { + "code": 2010, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}'.": { + "code": 2011, + "category": 1 /* Error */ + }, + "Cannot convert '{0}' to '{1}':{NL}{2}": { + "code": 2012, + "category": 1 /* Error */ + }, + "Expected var, class, interface, or module.": { + "code": 2013, + "category": 1 /* Error */ + }, + "Operator '{0}' cannot be applied to type '{1}'.": { + "code": 2014, + "category": 1 /* Error */ + }, + "Getter '{0}' already declared.": { + "code": 2015, + "category": 1 /* Error */ + }, + "Setter '{0}' already declared.": { + "code": 2016, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends private class '{1}'.": { + "code": 2018, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements private interface '{1}'.": { + "code": 2019, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends private interface '{1}'.": { + "code": 2020, + "category": 1 /* Error */ + }, + "Exported class '{0}' extends class from inaccessible module {1}.": { + "code": 2021, + "category": 1 /* Error */ + }, + "Exported class '{0}' implements interface from inaccessible module {1}.": { + "code": 2022, + "category": 1 /* Error */ + }, + "Exported interface '{0}' extends interface from inaccessible module {1}.": { + "code": 2023, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2024, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class has or is using private type '{1}'.": { + "code": 2025, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2026, + "category": 1 /* Error */ + }, + "Exported variable '{0}' has or is using private type '{1}'.": { + "code": 2027, + "category": 1 /* Error */ + }, + "Public static property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2028, + "category": 1 /* Error */ + }, + "Public property '{0}' of exported class is using inaccessible module {1}.": { + "code": 2029, + "category": 1 /* Error */ + }, + "Property '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2030, + "category": 1 /* Error */ + }, + "Exported variable '{0}' is using inaccessible module {1}.": { + "code": 2031, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { + "code": 2032, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { + "code": 2033, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { + "code": 2034, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2035, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2036, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2037, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2038, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2039, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2040, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { + "code": 2041, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { + "code": 2042, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { + "code": 2043, + "category": 1 /* Error */ + }, + "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2044, + "category": 1 /* Error */ + }, + "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2045, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2046, + "category": 1 /* Error */ + }, + "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2047, + "category": 1 /* Error */ + }, + "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2048, + "category": 1 /* Error */ + }, + "Parameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2049, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class has or is using private type '{0}'.": { + "code": 2050, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class has or is using private type '{0}'.": { + "code": 2051, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface has or is using private type '{0}'.": { + "code": 2052, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface has or is using private type '{0}'.": { + "code": 2053, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface has or is using private type '{0}'.": { + "code": 2054, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class has or is using private type '{0}'.": { + "code": 2055, + "category": 1 /* Error */ + }, + "Return type of public method from exported class has or is using private type '{0}'.": { + "code": 2056, + "category": 1 /* Error */ + }, + "Return type of method from exported interface has or is using private type '{0}'.": { + "code": 2057, + "category": 1 /* Error */ + }, + "Return type of exported function has or is using private type '{0}'.": { + "code": 2058, + "category": 1 /* Error */ + }, + "Return type of public static property getter from exported class is using inaccessible module {0}.": { + "code": 2059, + "category": 1 /* Error */ + }, + "Return type of public property getter from exported class is using inaccessible module {0}.": { + "code": 2060, + "category": 1 /* Error */ + }, + "Return type of constructor signature from exported interface is using inaccessible module {0}.": { + "code": 2061, + "category": 1 /* Error */ + }, + "Return type of call signature from exported interface is using inaccessible module {0}.": { + "code": 2062, + "category": 1 /* Error */ + }, + "Return type of index signature from exported interface is using inaccessible module {0}.": { + "code": 2063, + "category": 1 /* Error */ + }, + "Return type of public static method from exported class is using inaccessible module {0}.": { + "code": 2064, + "category": 1 /* Error */ + }, + "Return type of public method from exported class is using inaccessible module {0}.": { + "code": 2065, + "category": 1 /* Error */ + }, + "Return type of method from exported interface is using inaccessible module {0}.": { + "code": 2066, + "category": 1 /* Error */ + }, + "Return type of exported function is using inaccessible module {0}.": { + "code": 2067, + "category": 1 /* Error */ + }, + "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { + "code": 2068, + "category": 1 /* Error */ + }, + "A parameter list must follow a generic type argument list. '(' expected.": { + "code": 2069, + "category": 1 /* Error */ + }, + "Multiple constructor implementations are not allowed.": { + "code": 2070, + "category": 1 /* Error */ + }, + "Unable to resolve external module '{0}'.": { + "code": 2071, + "category": 1 /* Error */ + }, + "Module cannot be aliased to a non-module type.": { + "code": 2072, + "category": 1 /* Error */ + }, + "A class may only extend another class.": { + "code": 2073, + "category": 1 /* Error */ + }, + "A class may only implement another class or interface.": { + "code": 2074, + "category": 1 /* Error */ + }, + "An interface may only extend another class or interface.": { + "code": 2075, + "category": 1 /* Error */ + }, + "Unable to resolve type.": { + "code": 2077, + "category": 1 /* Error */ + }, + "Unable to resolve type of '{0}'.": { + "code": 2078, + "category": 1 /* Error */ + }, + "Unable to resolve type parameter constraint.": { + "code": 2079, + "category": 1 /* Error */ + }, + "Type parameter constraint cannot be a primitive type.": { + "code": 2080, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target.": { + "code": 2081, + "category": 1 /* Error */ + }, + "Supplied parameters do not match any signature of call target:{NL}{0}": { + "code": 2082, + "category": 1 /* Error */ + }, + "Invalid 'new' expression.": { + "code": 2083, + "category": 1 /* Error */ + }, + "Call signatures used in a 'new' expression must have a 'void' return type.": { + "code": 2084, + "category": 1 /* Error */ + }, + "Could not select overload for 'new' expression.": { + "code": 2085, + "category": 1 /* Error */ + }, + "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { + "code": 2086, + "category": 1 /* Error */ + }, + "Could not select overload for 'call' expression.": { + "code": 2087, + "category": 1 /* Error */ + }, + "Cannot invoke an expression whose type lacks a call signature.": { + "code": 2088, + "category": 1 /* Error */ + }, + "Calls to 'super' are only valid inside a class.": { + "code": 2089, + "category": 1 /* Error */ + }, + "Generic type '{0}' requires {1} type argument(s).": { + "code": 2090, + "category": 1 /* Error */ + }, + "Type of array literal cannot be determined. Best common type could not be found for array elements.": { + "code": 2092, + "category": 1 /* Error */ + }, + "Could not find enclosing symbol for dotted name '{0}'.": { + "code": 2093, + "category": 1 /* Error */ + }, + "The property '{0}' does not exist on value of type '{1}'.": { + "code": 2094, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}'.": { + "code": 2095, + "category": 1 /* Error */ + }, + "'get' and 'set' accessor must have the same type.": { + "code": 2096, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in current location.": { + "code": 2097, + "category": 1 /* Error */ + }, + "Static members cannot reference class type parameters.": { + "code": 2099, + "category": 1 /* Error */ + }, + "Class '{0}' is recursively referenced as a base type of itself.": { + "code": 2100, + "category": 1 /* Error */ + }, + "Interface '{0}' is recursively referenced as a base type of itself.": { + "code": 2101, + "category": 1 /* Error */ + }, + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { + "code": 2102, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in non-derived classes.": { + "code": 2103, + "category": 1 /* Error */ + }, + "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { + "code": 2104, + "category": 1 /* Error */ + }, + "Constructors for derived classes must contain a 'super' call.": { + "code": 2105, + "category": 1 /* Error */ + }, + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { + "code": 2106, + "category": 1 /* Error */ + }, + "'{0}.{1}' is inaccessible.": { + "code": 2107, + "category": 1 /* Error */ + }, + "'this' cannot be referenced within module bodies.": { + "code": 2108, + "category": 1 /* Error */ + }, + "Invalid '+' expression - types not known to support the addition operator.": { + "code": 2111, + "category": 1 /* Error */ + }, + "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2112, + "category": 1 /* Error */ + }, + "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { + "code": 2113, + "category": 1 /* Error */ + }, + "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { + "code": 2114, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement cannot use a type annotation.": { + "code": 2115, + "category": 1 /* Error */ + }, + "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "code": 2116, + "category": 1 /* Error */ + }, + "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { + "code": 2117, + "category": 1 /* Error */ + }, + "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { + "code": 2118, + "category": 1 /* Error */ + }, + "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { + "code": 2119, + "category": 1 /* Error */ + }, + "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { + "code": 2120, + "category": 1 /* Error */ + }, + "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 */ + }, + "Setters cannot return a value.": { + "code": 2122, + "category": 1 /* Error */ + }, + "Tried to query type of uninitialized module '{0}'.": { + "code": 2123, + "category": 1 /* Error */ + }, + "Tried to set variable type to uninitialized module type '{0}'.": { + "code": 2124, + "category": 1 /* Error */ + }, + "Type '{0}' does not have type parameters.": { + "code": 2125, + "category": 1 /* Error */ + }, + "Getters must return a value.": { + "code": 2126, + "category": 1 /* Error */ + }, + "Getter and setter accessors do not agree in visibility.": { + "code": 2127, + "category": 1 /* Error */ + }, + "Invalid left-hand side of assignment expression.": { + "code": 2130, + "category": 1 /* Error */ + }, + "Function declared a non-void return type, but has no return expression.": { + "code": 2131, + "category": 1 /* Error */ + }, + "Cannot resolve return type reference.": { + "code": 2132, + "category": 1 /* Error */ + }, + "Constructors cannot have a return type of 'void'.": { + "code": 2133, + "category": 1 /* Error */ + }, + "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { + "code": 2134, + "category": 1 /* Error */ + }, + "All symbols within a with block will be resolved to 'any'.": { + "code": 2135, + "category": 1 /* Error */ + }, + "Import declarations in an internal module cannot reference an external module.": { + "code": 2136, + "category": 1 /* Error */ + }, + "Class {0} declares interface {1} but does not implement it:{NL}{2}": { + "code": 2137, + "category": 1 /* Error */ + }, + "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { + "code": 2138, + "category": 1 /* Error */ + }, + "The operand of an increment or decrement operator must be a variable, property or indexer.": { + "code": 2139, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in static initializers in a class body.": { + "code": 2140, + "category": 1 /* Error */ + }, + "Class '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2141, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend class '{1}':{NL}{2}": { + "code": 2142, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { + "code": 2143, + "category": 1 /* Error */ + }, + "Duplicate overload signature for '{0}'.": { + "code": 2144, + "category": 1 /* Error */ + }, + "Duplicate constructor overload signature.": { + "code": 2145, + "category": 1 /* Error */ + }, + "Duplicate overload call signature.": { + "code": 2146, + "category": 1 /* Error */ + }, + "Duplicate overload construct signature.": { + "code": 2147, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition.": { + "code": 2148, + "category": 1 /* Error */ + }, + "Overload signature is not compatible with function definition:{NL}{0}": { + "code": 2149, + "category": 1 /* Error */ + }, + "Overload signatures must all be public or private.": { + "code": 2150, + "category": 1 /* Error */ + }, + "Overload signatures must all be exported or not exported.": { + "code": 2151, + "category": 1 /* Error */ + }, + "Overload signatures must all be ambient or non-ambient.": { + "code": 2152, + "category": 1 /* Error */ + }, + "Overload signatures must all be optional or required.": { + "code": 2153, + "category": 1 /* Error */ + }, + "Specialized overload signature is not assignable to any non-specialized signature.": { + "code": 2154, + "category": 1 /* Error */ + }, + "'this' cannot be referenced in constructor arguments.": { + "code": 2155, + "category": 1 /* Error */ + }, + "Instance member cannot be accessed off a class.": { + "code": 2157, + "category": 1 /* Error */ + }, + "Untyped function calls may not accept type arguments.": { + "code": 2158, + "category": 1 /* Error */ + }, + "Non-generic functions may not accept type arguments.": { + "code": 2159, + "category": 1 /* Error */ + }, + "A generic type may not reference itself with a wrapped form of its own type parameters.": { + "code": 2160, + "category": 1 /* Error */ + }, + "Rest parameters must be array types.": { + "code": 2162, + "category": 1 /* Error */ + }, + "Overload signature implementation cannot use specialized type.": { + "code": 2163, + "category": 1 /* Error */ + }, + "Export assignments may only be used at the top-level of external modules.": { + "code": 2164, + "category": 1 /* Error */ + }, + "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2165, + "category": 1 /* Error */ + }, + "Only public methods of the base class are accessible via the 'super' keyword.": { + "code": 2166, + "category": 1 /* Error */ + }, + "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { + "code": 2167, + "category": 1 /* Error */ + }, + "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 assignable to numeric indexer type '{0}'.": { + "code": 2169, + "category": 1 /* Error */ + }, + "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { + "code": 2170, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}'.": { + "code": 2171, + "category": 1 /* Error */ + }, + "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { + "code": 2172, + "category": 1 /* Error */ + }, + "Generic type references must include all type arguments.": { + "code": 2173, + "category": 1 /* Error */ + }, + "Default arguments are only allowed in implementation.": { + "code": 2174, + "category": 1 /* Error */ + }, + "Overloads cannot differ only by return type.": { + "code": 2175, + "category": 1 /* Error */ + }, + "Function expression declared a non-void return type, but has no return expression.": { + "code": 2176, + "category": 1 /* Error */ + }, + "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { + "code": 2177, + "category": 1 /* Error */ + }, + "Could not find symbol '{0}' in module '{1}'.": { + "code": 2178, + "category": 1 /* Error */ + }, + "Unable to resolve module reference '{0}'.": { + "code": 2179, + "category": 1 /* Error */ + }, + "Could not find module '{0}' in module '{1}'.": { + "code": 2180, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { + "code": 2181, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { + "code": 2182, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { + "code": 2183, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { + "code": 2184, + "category": 1 /* Error */ + }, + "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { + "code": 2185, + "category": 1 /* Error */ + }, + "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { + "code": 2186, + "category": 1 /* Error */ + }, + "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { + "code": 2187, + "category": 1 /* Error */ + }, + "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { + "code": 2188, + "category": 1 /* Error */ + }, + "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { + "code": 2189, + "category": 1 /* Error */ + }, + "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { + "code": 2190, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot be reopened.": { + "code": 2191, + "category": 1 /* Error */ + }, + "All declarations of merged declaration '{0}' must be exported or not exported.": { + "code": 2192, + "category": 1 /* Error */ + }, + "'super' cannot be referenced in constructor arguments.": { + "code": 2193, + "category": 1 /* Error */ + }, + "Return type of constructor signature must be assignable to the instance type of the class.": { + "code": 2194, + "category": 1 /* Error */ + }, + "Ambient external module declaration must be defined in global context.": { + "code": 2195, + "category": 1 /* Error */ + }, + "Ambient external module declaration cannot specify relative module name.": { + "code": 2196, + "category": 1 /* Error */ + }, + "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { + "code": 2197, + "category": 1 /* Error */ + }, + "Could not find the best common type of types of all return statement expressions.": { + "code": 2198, + "category": 1 /* Error */ + }, + "Import declaration cannot refer to external module reference when --noResolve option is set.": { + "code": 2199, + "category": 1 /* Error */ + }, + "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { + "code": 2200, + "category": 1 /* Error */ + }, + "'continue' statement can only be used within an enclosing iteration statement.": { + "code": 2201, + "category": 1 /* Error */ + }, + "'break' statement can only be used within an enclosing iteration or switch statement.": { + "code": 2202, + "category": 1 /* Error */ + }, + "Jump target not found.": { + "code": 2203, + "category": 1 /* Error */ + }, + "Jump target cannot cross function boundary.": { + "code": 2204, + "category": 1 /* Error */ + }, + "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { + "code": 2205, + "category": 1 /* Error */ + }, + "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { + "code": 2206, + "category": 1 /* Error */ + }, + "Expression resolves to '_super' that compiler uses to capture base class reference.": { + "code": 2207, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { + "code": 2208, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { + "code": 2209, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { + "code": 2210, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { + "code": 2211, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { + "code": 2212, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { + "code": 2213, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { + "code": 2214, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { + "code": 2215, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { + "code": 2216, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { + "code": 2217, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { + "code": 2218, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { + "code": 2219, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { + "code": 2220, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { + "code": 2221, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { + "code": 2222, + "category": 1 /* Error */ + }, + "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { + "code": 2223, + "category": 1 /* Error */ + }, + "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { + "code": 2224, + "category": 1 /* Error */ + }, + "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { + "code": 2225, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { + "code": 2226, + "category": 1 /* Error */ + }, + "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { + "code": 2227, + "category": 1 /* Error */ + }, + "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { + "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 */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { + "code": 4001, + "category": 3 /* NoPrefix */ + }, + "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { + "code": 4002, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { + "code": 4003, + "category": 3 /* NoPrefix */ + }, + "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { + "code": 4004, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' define property '{2}' as private.": { + "code": 4005, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4006, + "category": 3 /* NoPrefix */ + }, + "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4007, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a call signature, but type '{1}' lacks one.": { + "code": 4008, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4009, + "category": 3 /* NoPrefix */ + }, + "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4010, + "category": 3 /* NoPrefix */ + }, + "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { + "code": 4011, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible.": { + "code": 4012, + "category": 3 /* NoPrefix */ + }, + "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { + "code": 4013, + "category": 3 /* NoPrefix */ + }, + "Call signature expects {0} or fewer parameters.": { + "code": 4014, + "category": 3 /* NoPrefix */ + }, + "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { + "code": 4015, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4016, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { + "code": 4017, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { + "code": 4018, + "category": 3 /* NoPrefix */ + }, + "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { + "code": 4019, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { + "code": 4020, + "category": 3 /* NoPrefix */ + }, + "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { + "code": 4021, + "category": 3 /* NoPrefix */ + }, + "Type reference cannot refer to container '{0}'.": { + "code": 4022, + "category": 1 /* Error */ + }, + "Type reference must refer to type.": { + "code": 4023, + "category": 1 /* Error */ + }, + "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { + "code": 4024, + "category": 1 /* Error */ + }, + " (+ {0} overload(s))": { + "code": 4025, + "category": 2 /* Message */ + }, + "Variable declaration cannot have the same name as an import declaration.": { + "code": 4026, + "category": 1 /* Error */ + }, + "Signature expected {0} type arguments, got {1} instead.": { + "code": 4027, + "category": 1 /* Error */ + }, + "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { + "code": 4028, + "category": 3 /* NoPrefix */ + }, + "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 infinitely expanding type reference have incompatible type arguments.": { + "code": 4030, + "category": 3 /* NoPrefix */ + }, + "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { + "code": 4031, + "category": 3 /* NoPrefix */ + }, + "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { + "code": 4032, + "category": 3 /* NoPrefix */ + }, + "Types of string indexer of types '{0}' and '{1}' are not identical.": { + "code": 4033, + "category": 3 /* NoPrefix */ + }, + "Types of number indexer of types '{0}' and '{1}' are not identical.": { + "code": 4034, + "category": 3 /* NoPrefix */ + }, + "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 assignable to string indexer type in type '{2}'.{NL}{3}": { + "code": 4036, + "category": 3 /* NoPrefix */ + }, + "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 */ + }, + "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { + "code": 5002, + "category": 1 /* Error */ + }, + "Module code generation '{0}' not supported.": { + "code": 5003, + "category": 1 /* Error */ + }, + "Could not find file: '{0}'.": { + "code": 5004, + "category": 1 /* Error */ + }, + "A file cannot have a reference to itself.": { + "code": 5006, + "category": 1 /* Error */ + }, + "Cannot resolve referenced file: '{0}'.": { + "code": 5007, + "category": 1 /* Error */ + }, + "Cannot find the common subdirectory path for the input files.": { + "code": 5009, + "category": 1 /* Error */ + }, + "Emit Error: {0}.": { + "code": 5011, + "category": 1 /* Error */ + }, + "Cannot read file '{0}': {1}": { + "code": 5012, + "category": 1 /* Error */ + }, + "Unsupported file encoding.": { + "code": 5013, + "category": 3 /* NoPrefix */ + }, + "Locale must be of the form or -. For example '{0}' or '{1}'.": { + "code": 5014, + "category": 1 /* Error */ + }, + "Unsupported locale: '{0}'.": { + "code": 5015, + "category": 1 /* Error */ + }, + "Execution Failed.{NL}": { + "code": 5016, + "category": 1 /* Error */ + }, + "Invalid call to 'up'": { + "code": 5019, + "category": 1 /* Error */ + }, + "Invalid call to 'down'": { + "code": 5020, + "category": 1 /* Error */ + }, + "Base64 value '{0}' finished with a continuation bit.": { + "code": 5021, + "category": 1 /* Error */ + }, + "Unknown option '{0}'": { + "code": 5023, + "category": 1 /* Error */ + }, + "Expected {0} arguments to message, got {1} instead.": { + "code": 5024, + "category": 1 /* Error */ + }, + "Expected the message '{0}' to have {1} arguments, but it had {2}": { + "code": 5025, + "category": 1 /* Error */ + }, + "Could not delete file '{0}'": { + "code": 5034, + "category": 1 /* Error */ + }, + "Could not create directory '{0}'": { + "code": 5035, + "category": 1 /* Error */ + }, + "Error while executing file '{0}': ": { + "code": 5036, + "category": 1 /* Error */ + }, + "Cannot compile external modules unless the '--module' flag is provided.": { + "code": 5037, + "category": 1 /* Error */ + }, + "Option mapRoot cannot be specified without specifying sourcemap option.": { + "code": 5038, + "category": 1 /* Error */ + }, + "Option sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5039, + "category": 1 /* Error */ + }, + "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { + "code": 5040, + "category": 1 /* Error */ + }, + "Option '{0}' specified without '{1}'": { + "code": 5041, + "category": 1 /* Error */ + }, + "'codepage' option not supported on current platform.": { + "code": 5042, + "category": 1 /* Error */ + }, + "Concatenate and emit output to single file.": { + "code": 6001, + "category": 2 /* Message */ + }, + "Generates corresponding {0} file.": { + "code": 6002, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate map files instead of generated locations.": { + "code": 6003, + "category": 2 /* Message */ + }, + "Specifies the location where debugger should locate TypeScript files instead of source locations.": { + "code": 6004, + "category": 2 /* Message */ + }, + "Watch input files.": { + "code": 6005, + "category": 2 /* Message */ + }, + "Redirect output structure to the directory.": { + "code": 6006, + "category": 2 /* Message */ + }, + "Do not emit comments to output.": { + "code": 6009, + "category": 2 /* Message */ + }, + "Skip resolution and preprocessing.": { + "code": 6010, + "category": 2 /* Message */ + }, + "Specify ECMAScript target version: '{0}' (default), or '{1}'": { + "code": 6015, + "category": 2 /* Message */ + }, + "Specify module code generation: '{0}' or '{1}'": { + "code": 6016, + "category": 2 /* Message */ + }, + "Print this message.": { + "code": 6017, + "category": 2 /* Message */ + }, + "Print the compiler's version: {0}": { + "code": 6019, + "category": 2 /* Message */ + }, + "Allow use of deprecated '{0}' keyword when referencing an external module.": { + "code": 6021, + "category": 2 /* Message */ + }, + "Specify locale for errors and messages. For example '{0}' or '{1}'": { + "code": 6022, + "category": 2 /* Message */ + }, + "Syntax: {0}": { + "code": 6023, + "category": 2 /* Message */ + }, + "options": { + "code": 6024, + "category": 2 /* Message */ + }, + "file1": { + "code": 6025, + "category": 2 /* Message */ + }, + "Examples:": { + "code": 6026, + "category": 2 /* Message */ + }, + "Options:": { + "code": 6027, + "category": 2 /* Message */ + }, + "Insert command line options and files from a file.": { + "code": 6030, + "category": 2 /* Message */ + }, + "Version {0}": { + "code": 6029, + "category": 2 /* Message */ + }, + "Use the '{0}' flag to see options.": { + "code": 6031, + "category": 2 /* Message */ + }, + "{NL}Recompiling ({0}):": { + "code": 6032, + "category": 2 /* Message */ + }, + "STRING": { + "code": 6033, + "category": 2 /* Message */ + }, + "KIND": { + "code": 6034, + "category": 2 /* Message */ + }, + "file2": { + "code": 6035, + "category": 2 /* Message */ + }, + "VERSION": { + "code": 6036, + "category": 2 /* Message */ + }, + "LOCATION": { + "code": 6037, + "category": 2 /* Message */ + }, + "DIRECTORY": { + "code": 6038, + "category": 2 /* Message */ + }, + "NUMBER": { + "code": 6039, + "category": 2 /* Message */ + }, + "Specify the codepage to use when opening source files.": { + "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 */ + }, + "Unknown rule.": { + "code": 7002, + "category": 1 /* Error */ + }, + "Invalid line number ({0})": { + "code": 7003, + "category": 1 /* Error */ + }, + "Warn on expressions and declarations with an implied 'any' type.": { + "code": 7004, + "category": 2 /* Message */ + }, + "Variable '{0}' implicitly has an 'any' type.": { + "code": 7005, + "category": 1 /* Error */ + }, + "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { + "code": 7006, + "category": 1 /* Error */ + }, + "Parameter '{0}' of function type implicitly has an 'any' type.": { + "code": 7007, + "category": 1 /* Error */ + }, + "Member '{0}' of object type implicitly has an 'any' type.": { + "code": 7008, + "category": 1 /* Error */ + }, + "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { + "code": 7009, + "category": 1 /* Error */ + }, + "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7010, + "category": 1 /* Error */ + }, + "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7011, + "category": 1 /* Error */ + }, + "Parameter '{0}' of lambda function implicitly has an 'any' type.": { + "code": 7012, + "category": 1 /* Error */ + }, + "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7013, + "category": 1 /* Error */ + }, + "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { + "code": 7014, + "category": 1 /* Error */ + }, + "Array Literal implicitly has an 'any' type from widening.": { + "code": 7015, + "category": 1 /* Error */ + }, + "'{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 = {})); +var TypeScript; +(function (TypeScript) { + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; + + CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; + + CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; + + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); + var CharacterCodes = TypeScript.CharacterCodes; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + (function (ScriptSnapshot) { + var StringScriptSnapshot = (function () { + function StringScriptSnapshot(text) { + this.text = text; + this._lineStartPositions = null; + } + StringScriptSnapshot.prototype.getText = function (start, end) { + return this.text.substring(start, end); + }; + + StringScriptSnapshot.prototype.getLength = function () { + return this.text.length; + }; + + StringScriptSnapshot.prototype.getLineStartPositions = function () { + if (!this._lineStartPositions) { + this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); + } + + return this._lineStartPositions; + }; + + StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { + throw TypeScript.Errors.notYetImplemented(); + }; + return StringScriptSnapshot; + })(); + + function fromString(text) { + return new StringScriptSnapshot(text); + } + ScriptSnapshot.fromString = fromString; + })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); + var ScriptSnapshot = TypeScript.ScriptSnapshot; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LineMap1) { + function fromSimpleText(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return text.charCodeAt(index); + }, length: text.length() }); + }, text.length()); + } + LineMap1.fromSimpleText = fromSimpleText; + + function fromScriptSnapshot(scriptSnapshot) { + return new TypeScript.LineMap(function () { + return scriptSnapshot.getLineStartPositions(); + }, scriptSnapshot.getLength()); + } + LineMap1.fromScriptSnapshot = fromScriptSnapshot; + + function fromString(text) { + return new TypeScript.LineMap(function () { + return TypeScript.TextUtilities.parseLineStarts(text); + }, text.length); + } + LineMap1.fromString = fromString; + })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); + var LineMap1 = TypeScript.LineMap1; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextFactory) { + function getStartAndLengthOfLineBreakEndingAt(text, index, info) { + var c = text.charCodeAt(index); + if (c === 10 /* lineFeed */) { + if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { + info.startPosition = index - 1; + info.length = 2; + } else { + info.startPosition = index; + info.length = 1; + } + } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { + info.startPosition = index; + info.length = 1; + } else { + info.startPosition = index + 1; + info.length = 0; + } + } + + var LinebreakInfo = (function () { + function LinebreakInfo(startPosition, length) { + this.startPosition = startPosition; + this.length = length; + } + return LinebreakInfo; + })(); + + var TextLine = (function () { + function TextLine(text, body, lineBreakLength, lineNumber) { + this._text = null; + this._textSpan = null; + if (text === null) { + throw TypeScript.Errors.argumentNull('text'); + } + TypeScript.Debug.assert(lineBreakLength >= 0); + TypeScript.Debug.assert(lineNumber >= 0); + this._text = text; + this._textSpan = body; + this._lineBreakLength = lineBreakLength; + this._lineNumber = lineNumber; + } + TextLine.prototype.start = function () { + return this._textSpan.start(); + }; + + TextLine.prototype.end = function () { + return this._textSpan.end(); + }; + + TextLine.prototype.endIncludingLineBreak = function () { + return this.end() + this._lineBreakLength; + }; + + TextLine.prototype.extent = function () { + return this._textSpan; + }; + + TextLine.prototype.extentIncludingLineBreak = function () { + return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); + }; + + TextLine.prototype.toString = function () { + return this._text.toString(this._textSpan); + }; + + TextLine.prototype.lineNumber = function () { + return this._lineNumber; + }; + return TextLine; + })(); + + var TextBase = (function () { + function TextBase() { + this.linebreakInfo = new LinebreakInfo(0, 0); + this.lastLineFoundForPosition = null; + } + TextBase.prototype.length = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.charCodeAt = function (position) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + TextBase.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this, span); + }; + + TextBase.prototype.substr = function (start, length, intern) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.lineCount = function () { + return this._lineStarts().length; + }; + + TextBase.prototype.lines = function () { + var lines = []; + + var length = this.lineCount(); + for (var i = 0; i < length; ++i) { + lines[i] = this.getLineFromLineNumber(i); + } + + return lines; + }; + + TextBase.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this._lineStarts(); + }, this.length()); + }; + + TextBase.prototype._lineStarts = function () { + throw TypeScript.Errors.abstract(); + }; + + TextBase.prototype.getLineFromLineNumber = function (lineNumber) { + var lineStarts = this._lineStarts(); + + if (lineNumber < 0 || lineNumber >= lineStarts.length) { + throw TypeScript.Errors.argumentOutOfRange("lineNumber"); + } + + var first = lineStarts[lineNumber]; + if (lineNumber === lineStarts.length - 1) { + return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); + } else { + getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); + return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); + } + }; + + TextBase.prototype.getLineFromPosition = function (position) { + var lastFound = this.lastLineFoundForPosition; + if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { + return lastFound; + } + + var lineNumber = this.getLineNumberFromPosition(position); + + var result = this.getLineFromLineNumber(lineNumber); + this.lastLineFoundForPosition = result; + return result; + }; + + TextBase.prototype.getLineNumberFromPosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + if (position === this.length()) { + return this.lineCount() - 1; + } + + var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); + if (lineNumber < 0) { + lineNumber = (~lineNumber) - 1; + } + + return lineNumber; + }; + + TextBase.prototype.getLinePosition = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var lineNumber = this.getLineNumberFromPosition(position); + + return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); + }; + return TextBase; + })(); + + var SubText = (function (_super) { + __extends(SubText, _super); + function SubText(text, span) { + _super.call(this); + this._lazyLineStarts = null; + + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SubText.prototype.length = function () { + return this.span.length(); + }; + + SubText.prototype.charCodeAt = function (position) { + if (position < 0 || position > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.text.charCodeAt(this.span.start() + position); + }; + + SubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SubText.prototype.substr = function (start, length, intern) { + var startInOriginalText = this.span.start() + start; + return this.text.substr(startInOriginalText, length, intern); + }; + + SubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SubText.prototype._lineStarts = function () { + var _this = this; + if (!this._lazyLineStarts) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { + return _this.charCodeAt(index); + }, length: this.length() }); + } + + return this._lazyLineStarts; + }; + return SubText; + })(TextBase); + + var StringText = (function (_super) { + __extends(StringText, _super); + function StringText(data) { + _super.call(this); + this.source = null; + this._lazyLineStarts = null; + + if (data === null) { + throw TypeScript.Errors.argumentNull("data"); + } + + this.source = data; + } + StringText.prototype.length = function () { + return this.source.length; + }; + + StringText.prototype.charCodeAt = function (position) { + if (position < 0 || position >= this.source.length) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + return this.source.charCodeAt(position); + }; + + StringText.prototype.substr = function (start, length, intern) { + return this.source.substr(start, length); + }; + + StringText.prototype.toString = function (span) { + if (typeof span === "undefined") { span = null; } + if (span === null) { + span = new TypeScript.TextSpan(0, this.length()); + } + + this.checkSubSpan(span); + + if (span.start() === 0 && span.length() === this.length()) { + return this.source; + } + + return this.source.substr(span.start(), span.length()); + }; + + StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); + }; + + StringText.prototype._lineStarts = function () { + if (this._lazyLineStarts === null) { + this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); + } + + return this._lazyLineStarts; + }; + return StringText; + })(TextBase); + + function createText(value) { + return new StringText(value); + } + TextFactory.createText = createText; + })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); + var TextFactory = TypeScript.TextFactory; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (SimpleText) { + var SimpleSubText = (function () { + function SimpleSubText(text, span) { + this.text = null; + this.span = null; + if (text === null) { + throw TypeScript.Errors.argumentNull("text"); + } + + if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { + throw TypeScript.Errors.argument("span"); + } + + this.text = text; + this.span = span; + } + SimpleSubText.prototype.checkSubSpan = function (span) { + if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { + throw TypeScript.Errors.argumentOutOfRange("span"); + } + }; + + SimpleSubText.prototype.checkSubPosition = function (position) { + if (position < 0 || position >= this.length()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + }; + + SimpleSubText.prototype.length = function () { + return this.span.length(); + }; + + SimpleSubText.prototype.subText = function (span) { + this.checkSubSpan(span); + + return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); + }; + + SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var span = this.getCompositeSpan(sourceIndex, count); + this.text.copyTo(span.start(), destination, destinationIndex, span.length()); + }; + + SimpleSubText.prototype.substr = function (start, length, intern) { + var span = this.getCompositeSpan(start, length); + return this.text.substr(span.start(), span.length(), intern); + }; + + SimpleSubText.prototype.getCompositeSpan = function (start, length) { + var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); + var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); + return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); + }; + + SimpleSubText.prototype.charCodeAt = function (index) { + this.checkSubPosition(index); + return this.text.charCodeAt(this.span.start() + index); + }; + + SimpleSubText.prototype.lineMap = function () { + return TypeScript.LineMap1.fromSimpleText(this); + }; + return SimpleSubText; + })(); + + var SimpleStringText = (function () { + function SimpleStringText(value) { + this.value = value; + this._lineMap = null; + } + SimpleStringText.prototype.length = function () { + return this.value.length; + }; + + SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); + }; + + SimpleStringText.prototype.substr = function (start, length, intern) { + if (intern) { + var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); + this.copyTo(start, array, 0, length); + return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); + } + + return this.value.substr(start, length); + }; + + SimpleStringText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleStringText.prototype.charCodeAt = function (index) { + return this.value.charCodeAt(index); + }; + + SimpleStringText.prototype.lineMap = function () { + if (!this._lineMap) { + this._lineMap = TypeScript.LineMap1.fromString(this.value); + } + + return this._lineMap; + }; + SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); + return SimpleStringText; + })(); + + var SimpleScriptSnapshotText = (function () { + function SimpleScriptSnapshotText(scriptSnapshot) { + this.scriptSnapshot = scriptSnapshot; + } + SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { + return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); + }; + + SimpleScriptSnapshotText.prototype.length = function () { + return this.scriptSnapshot.getLength(); + }; + + SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { + var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); + TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); + }; + + SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { + return this.scriptSnapshot.getText(start, start + length); + }; + + SimpleScriptSnapshotText.prototype.subText = function (span) { + return new SimpleSubText(this, span); + }; + + SimpleScriptSnapshotText.prototype.lineMap = function () { + var _this = this; + return new TypeScript.LineMap(function () { + return _this.scriptSnapshot.getLineStartPositions(); + }, this.length()); + }; + return SimpleScriptSnapshotText; + })(); + + function fromString(value) { + return new SimpleStringText(value); + } + SimpleText.fromString = fromString; + + function fromScriptSnapshot(scriptSnapshot) { + return new SimpleScriptSnapshotText(scriptSnapshot); + } + SimpleText.fromScriptSnapshot = fromScriptSnapshot; + })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); + var SimpleText = TypeScript.SimpleText; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (TextUtilities) { + function parseLineStarts(text) { + var length = text.length; + + if (0 === length) { + var result = new Array(); + result.push(0); + return result; + } + + var position = 0; + var index = 0; + var arrayBuilder = new Array(); + var lineNumber = 0; + + while (index < length) { + var c = text.charCodeAt(index); + var lineBreakLength; + + if (c > 13 /* carriageReturn */ && c <= 127) { + index++; + continue; + } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { + lineBreakLength = 2; + } else if (c === 10 /* lineFeed */) { + lineBreakLength = 1; + } else { + lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); + } + + if (0 === lineBreakLength) { + index++; + } else { + arrayBuilder.push(position); + index += lineBreakLength; + position = index; + lineNumber++; + } + } + + arrayBuilder.push(position); + + return arrayBuilder; + } + TextUtilities.parseLineStarts = parseLineStarts; + + function getLengthOfLineBreakSlow(text, index, c) { + if (c === 13 /* carriageReturn */) { + var next = index + 1; + return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; + } else if (isAnyLineBreakCharacter(c)) { + return 1; + } else { + return 0; + } + } + TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; + + function getLengthOfLineBreak(text, index) { + var c = text.charCodeAt(index); + + if (c > 13 /* carriageReturn */ && c <= 127) { + return 0; + } + + return getLengthOfLineBreakSlow(text, index, c); + } + TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; + + function isAnyLineBreakCharacter(c) { + return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; + } + TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; + })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); + var TextUtilities = TypeScript.TextUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextSpan = (function () { + function TextSpan(start, length) { + if (start < 0) { + TypeScript.Errors.argument("start"); + } + + if (length < 0) { + TypeScript.Errors.argument("length"); + } + + this._start = start; + this._length = length; + } + TextSpan.prototype.start = function () { + return this._start; + }; + + TextSpan.prototype.length = function () { + return this._length; + }; + + TextSpan.prototype.end = function () { + return this._start + this._length; + }; + + TextSpan.prototype.isEmpty = function () { + return this._length === 0; + }; + + TextSpan.prototype.containsPosition = function (position) { + return position >= this._start && position < this.end(); + }; + + TextSpan.prototype.containsTextSpan = function (span) { + return span._start >= this._start && span.end() <= this.end(); + }; + + TextSpan.prototype.overlapsWith = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + return overlapStart < overlapEnd; + }; + + TextSpan.prototype.overlap = function (span) { + var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); + var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (overlapStart < overlapEnd) { + return TextSpan.fromBounds(overlapStart, overlapEnd); + } + + return null; + }; + + TextSpan.prototype.intersectsWithTextSpan = function (span) { + return span._start <= this.end() && span.end() >= this._start; + }; + + TextSpan.prototype.intersectsWith = function (start, length) { + var end = start + length; + return start <= this.end() && end >= this._start; + }; + + TextSpan.prototype.intersectsWithPosition = function (position) { + return position <= this.end() && position >= this._start; + }; + + TextSpan.prototype.intersection = function (span) { + var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); + var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); + + if (intersectStart <= intersectEnd) { + return TextSpan.fromBounds(intersectStart, intersectEnd); + } + + return null; + }; + + TextSpan.fromBounds = function (start, end) { + TypeScript.Debug.assert(start >= 0); + TypeScript.Debug.assert(end - start >= 0); + return new TextSpan(start, end - start); + }; + return TextSpan; + })(); + TypeScript.TextSpan = TextSpan; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextChangeRange = (function () { + function TextChangeRange(span, newLength) { + if (newLength < 0) { + throw TypeScript.Errors.argumentOutOfRange("newLength"); + } + + this._span = span; + this._newLength = newLength; + } + TextChangeRange.prototype.span = function () { + return this._span; + }; + + TextChangeRange.prototype.newLength = function () { + return this._newLength; + }; + + TextChangeRange.prototype.newSpan = function () { + return new TypeScript.TextSpan(this.span().start(), this.newLength()); + }; + + TextChangeRange.prototype.isUnchanged = function () { + return this.span().isEmpty() && this.newLength() === 0; + }; + + TextChangeRange.collapseChangesFromSingleVersion = function (changes) { + var diff = 0; + var start = 1073741823 /* Max31BitInteger */; + var end = 0; + + for (var i = 0; i < changes.length; i++) { + var change = changes[i]; + diff += change.newLength() - change.span().length(); + + if (change.span().start() < start) { + start = change.span().start(); + } + + if (change.span().end() > end) { + end = change.span().end(); + } + } + + if (start > end) { + return null; + } + + var combined = TypeScript.TextSpan.fromBounds(start, end); + var newLen = combined.length() + diff; + + return new TextChangeRange(combined, newLen); + }; + + TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { + if (changes.length === 0) { + return TextChangeRange.unchanged; + } + + if (changes.length === 1) { + return changes[0]; + } + + var change0 = changes[0]; + + var oldStartN = change0.span().start(); + var oldEndN = change0.span().end(); + var newEndN = oldStartN + change0.newLength(); + + for (var i = 1; i < changes.length; i++) { + var nextChange = changes[i]; + + var oldStart1 = oldStartN; + var oldEnd1 = oldEndN; + var newEnd1 = newEndN; + + var oldStart2 = nextChange.span().start(); + var oldEnd2 = nextChange.span().end(); + var newEnd2 = oldStart2 + nextChange.newLength(); + + oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); + oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); + newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); + } + + return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); + }; + TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); + return TextChangeRange; + })(); + TypeScript.TextChangeRange = TextChangeRange; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CharacterInfo = (function () { + function CharacterInfo() { + } + CharacterInfo.isDecimalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 57 /* _9 */; + }; + CharacterInfo.isOctalDigit = function (c) { + return c >= 48 /* _0 */ && c <= 55 /* _7 */; + }; + + CharacterInfo.isHexDigit = function (c) { + return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); + }; + + CharacterInfo.hexValue = function (c) { + return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; + }; + + CharacterInfo.isWhitespace = function (ch) { + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + return true; + } + + return false; + }; + + CharacterInfo.isLineTerminator = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + } + + return false; + }; + return CharacterInfo; + })(); + TypeScript.CharacterInfo = CharacterInfo; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxConstants) { + SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; + SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; + SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; + + SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; + SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; + SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; + SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; + + SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; + })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); + var SyntaxConstants = TypeScript.SyntaxConstants; +})(TypeScript || (TypeScript = {})); +var FormattingOptions = (function () { + function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { + this.useTabs = useTabs; + this.spacesPerTab = spacesPerTab; + this.indentSpaces = indentSpaces; + this.newLineCharacter = newLineCharacter; + } + FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); + return FormattingOptions; +})(); +var TypeScript; +(function (TypeScript) { + (function (Indentation) { + function columnForEndOfToken(token, syntaxInformationMap, options) { + return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); + } + Indentation.columnForEndOfToken = columnForEndOfToken; + + function columnForStartOfToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + var current = token; + while (current !== firstTokenInLine) { + current = syntaxInformationMap.previousToken(current); + + if (current === firstTokenInLine) { + leadingTextInReverse.push(current.trailingTrivia().fullText()); + leadingTextInReverse.push(current.text()); + } else { + leadingTextInReverse.push(current.fullText()); + } + } + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfToken = columnForStartOfToken; + + function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { + var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); + var leadingTextInReverse = []; + + collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); + + return columnForLeadingTextInReverse(leadingTextInReverse, options); + } + Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; + + function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { + var leadingTrivia = firstTokenInLine.leadingTrivia(); + + for (var i = leadingTrivia.count() - 1; i >= 0; i--) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + if (trivia.kind() === 5 /* NewLineTrivia */) { + break; + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); + + if (lineSegments.length > 0) { + break; + } + } + + leadingTextInReverse.push(trivia.fullText()); + } + } + + function columnForLeadingTextInReverse(leadingTextInReverse, options) { + var column = 0; + + for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { + var text = leadingTextInReverse[i]; + column = columnForPositionInStringWorker(text, text.length, column, options); + } + + return column; + } + + function columnForPositionInString(input, position, options) { + return columnForPositionInStringWorker(input, position, 0, options); + } + Indentation.columnForPositionInString = columnForPositionInString; + + function columnForPositionInStringWorker(input, position, startColumn, options) { + var column = startColumn; + var spacesPerTab = options.spacesPerTab; + + for (var j = 0; j < position; j++) { + var ch = input.charCodeAt(j); + + if (ch === 9 /* tab */) { + column += spacesPerTab - column % spacesPerTab; + } else { + column++; + } + } + + return column; + } + + function indentationString(column, options) { + var numberOfTabs = 0; + var numberOfSpaces = TypeScript.MathPrototype.max(0, column); + + if (options.useTabs) { + numberOfTabs = Math.floor(column / options.spacesPerTab); + numberOfSpaces -= numberOfTabs * options.spacesPerTab; + } + + return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); + } + Indentation.indentationString = indentationString; + + function indentationTrivia(column, options) { + return TypeScript.Syntax.whitespace(this.indentationString(column, options)); + } + Indentation.indentationTrivia = indentationTrivia; + + function firstNonWhitespacePosition(value) { + for (var i = 0; i < value.length; i++) { + var ch = value.charCodeAt(i); + if (!TypeScript.CharacterInfo.isWhitespace(ch)) { + return i; + } + } + + return value.length; + } + Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; + })(TypeScript.Indentation || (TypeScript.Indentation = {})); + var Indentation = TypeScript.Indentation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (LanguageVersion) { + LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; + LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; + })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); + var LanguageVersion = TypeScript.LanguageVersion; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ParseOptions = (function () { + function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { + this._languageVersion = languageVersion; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + } + ParseOptions.prototype.toJSON = function (key) { + return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; + }; + + ParseOptions.prototype.languageVersion = function () { + return this._languageVersion; + }; + + ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + return ParseOptions; + })(); + TypeScript.ParseOptions = ParseOptions; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionedElement = (function () { + function PositionedElement(parent, element, fullStart) { + this._parent = parent; + this._element = element; + this._fullStart = fullStart; + } + PositionedElement.create = function (parent, element, fullStart) { + if (element === null) { + return null; + } + + if (element.isNode()) { + return new PositionedNode(parent, element, fullStart); + } else if (element.isToken()) { + return new PositionedToken(parent, element, fullStart); + } else if (element.isList()) { + return new PositionedList(parent, element, fullStart); + } else if (element.isSeparatedList()) { + return new PositionedSeparatedList(parent, element, fullStart); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + PositionedElement.prototype.parent = function () { + return this._parent; + }; + + PositionedElement.prototype.parentElement = function () { + return this._parent && this._parent._element; + }; + + PositionedElement.prototype.element = function () { + return this._element; + }; + + PositionedElement.prototype.kind = function () { + return this.element().kind(); + }; + + PositionedElement.prototype.childIndex = function (child) { + return TypeScript.Syntax.childIndex(this.element(), child); + }; + + PositionedElement.prototype.childCount = function () { + return this.element().childCount(); + }; + + PositionedElement.prototype.childAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); + }; + + PositionedElement.prototype.childStart = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEnd = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.childStartAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth(); + }; + + PositionedElement.prototype.childEndAt = function (index) { + var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); + var child = this.element().childAt(index); + return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); + }; + + PositionedElement.prototype.getPositionedChild = function (child) { + var offset = TypeScript.Syntax.childOffset(this.element(), child); + return PositionedElement.create(this, child, this.fullStart() + offset); + }; + + PositionedElement.prototype.fullStart = function () { + return this._fullStart; + }; + + PositionedElement.prototype.fullEnd = function () { + return this.fullStart() + this.element().fullWidth(); + }; + + PositionedElement.prototype.fullWidth = function () { + return this.element().fullWidth(); + }; + + PositionedElement.prototype.start = function () { + return this.fullStart() + this.element().leadingTriviaWidth(); + }; + + PositionedElement.prototype.end = function () { + return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); + }; + + PositionedElement.prototype.root = function () { + var current = this; + while (current.parent() !== null) { + current = current.parent(); + } + + return current; + }; + + PositionedElement.prototype.containingNode = function () { + var current = this.parent(); + + while (current !== null && !current.element().isNode()) { + current = current.parent(); + } + + return current; + }; + return PositionedElement; + })(); + TypeScript.PositionedElement = PositionedElement; + + var PositionedNodeOrToken = (function (_super) { + __extends(PositionedNodeOrToken, _super); + function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { + _super.call(this, parent, nodeOrToken, fullStart); + } + PositionedNodeOrToken.prototype.nodeOrToken = function () { + return this.element(); + }; + return PositionedNodeOrToken; + })(PositionedElement); + TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; + + var PositionedNode = (function (_super) { + __extends(PositionedNode, _super); + function PositionedNode(parent, node, fullStart) { + _super.call(this, parent, node, fullStart); + } + PositionedNode.prototype.node = function () { + return this.element(); + }; + return PositionedNode; + })(PositionedNodeOrToken); + TypeScript.PositionedNode = PositionedNode; + + var PositionedToken = (function (_super) { + __extends(PositionedToken, _super); + function PositionedToken(parent, token, fullStart) { + _super.call(this, parent, token, fullStart); + } + PositionedToken.prototype.token = function () { + return this.element(); + }; + + PositionedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var triviaList = this.token().leadingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var currentTriviaEndPosition = this.start(); + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); + } + + currentTriviaEndPosition -= trivia.fullWidth(); + } + } + + var start = this.fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + var triviaList = this.token().trailingTrivia(); + if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { + var fullStart = this.end(); + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (trivia.isSkippedToken()) { + return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); + } + + fullStart += trivia.fullWidth(); + } + } + + return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); + }; + return PositionedToken; + })(PositionedNodeOrToken); + TypeScript.PositionedToken = PositionedToken; + + var PositionedList = (function (_super) { + __extends(PositionedList, _super); + function PositionedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedList.prototype.list = function () { + return this.element(); + }; + return PositionedList; + })(PositionedElement); + TypeScript.PositionedList = PositionedList; + + var PositionedSeparatedList = (function (_super) { + __extends(PositionedSeparatedList, _super); + function PositionedSeparatedList(parent, list, fullStart) { + _super.call(this, parent, list, fullStart); + } + PositionedSeparatedList.prototype.list = function () { + return this.element(); + }; + return PositionedSeparatedList; + })(PositionedElement); + TypeScript.PositionedSeparatedList = PositionedSeparatedList; + + var PositionedSkippedToken = (function (_super) { + __extends(PositionedSkippedToken, _super); + function PositionedSkippedToken(parentToken, token, fullStart) { + _super.call(this, parentToken.parent(), token, fullStart); + this._parentToken = parentToken; + } + PositionedSkippedToken.prototype.parentToken = function () { + return this._parentToken; + }; + + PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var start = this.fullStart(); + + if (includeSkippedTokens) { + var previousToken; + + if (start >= this.parentToken().end()) { + previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + + return this.parentToken(); + } else { + previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); + + if (previousToken) { + return previousToken; + } + } + } + + var start = this.parentToken().fullStart(); + if (start === 0) { + return null; + } + + return this.root().node().findToken(start - 1, includeSkippedTokens); + }; + + PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + if (this.token().tokenKind === 10 /* EndOfFileToken */) { + return null; + } + + if (includeSkippedTokens) { + var end = this.end(); + var nextToken; + + if (end <= this.parentToken().start()) { + nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + + return this.parentToken(); + } else { + nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); + + if (nextToken) { + return nextToken; + } + } + } + + return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); + }; + return PositionedSkippedToken; + })(PositionedToken); + TypeScript.PositionedSkippedToken = PositionedSkippedToken; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; + SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; + + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; + + SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; + + SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; + + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; + + SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; + + SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; + + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; + + SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; + + SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; + + SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; + + SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; + + SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; + + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; + + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; + + SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; + + SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; + + SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; + + SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; + SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; + SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; + SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; + SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; + SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; + SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; + SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; + SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; + SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; + SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; + SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; + SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; + SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; + SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; + SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; + SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; + SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; + SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; + SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; + SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; + SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; + SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; + SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; + SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; + SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; + SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; + SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; + SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; + SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; + SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; + SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; + SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; + SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; + SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; + SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; + SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; + SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; + SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; + + SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; + + SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; + + SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; + SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; + + SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; + + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; + + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; + + SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; + + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + + SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; + SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 60 /* AnyKeyword */, + "boolean": 61 /* BooleanKeyword */, + "break": 15 /* BreakKeyword */, + "case": 16 /* CaseKeyword */, + "catch": 17 /* CatchKeyword */, + "class": 44 /* ClassKeyword */, + "continue": 18 /* ContinueKeyword */, + "const": 45 /* ConstKeyword */, + "constructor": 62 /* ConstructorKeyword */, + "debugger": 19 /* DebuggerKeyword */, + "declare": 63 /* DeclareKeyword */, + "default": 20 /* DefaultKeyword */, + "delete": 21 /* DeleteKeyword */, + "do": 22 /* DoKeyword */, + "else": 23 /* ElseKeyword */, + "enum": 46 /* EnumKeyword */, + "export": 47 /* ExportKeyword */, + "extends": 48 /* ExtendsKeyword */, + "false": 24 /* FalseKeyword */, + "finally": 25 /* FinallyKeyword */, + "for": 26 /* ForKeyword */, + "function": 27 /* FunctionKeyword */, + "get": 64 /* GetKeyword */, + "if": 28 /* IfKeyword */, + "implements": 51 /* ImplementsKeyword */, + "import": 49 /* ImportKeyword */, + "in": 29 /* InKeyword */, + "instanceof": 30 /* InstanceOfKeyword */, + "interface": 52 /* InterfaceKeyword */, + "let": 53 /* LetKeyword */, + "module": 65 /* ModuleKeyword */, + "new": 31 /* NewKeyword */, + "null": 32 /* NullKeyword */, + "number": 67 /* NumberKeyword */, + "package": 54 /* PackageKeyword */, + "private": 55 /* PrivateKeyword */, + "protected": 56 /* ProtectedKeyword */, + "public": 57 /* PublicKeyword */, + "require": 66 /* RequireKeyword */, + "return": 33 /* ReturnKeyword */, + "set": 68 /* SetKeyword */, + "static": 58 /* StaticKeyword */, + "string": 69 /* StringKeyword */, + "super": 50 /* SuperKeyword */, + "switch": 34 /* SwitchKeyword */, + "this": 35 /* ThisKeyword */, + "throw": 36 /* ThrowKeyword */, + "true": 37 /* TrueKeyword */, + "try": 38 /* TryKeyword */, + "typeof": 39 /* TypeOfKeyword */, + "var": 40 /* VarKeyword */, + "void": 41 /* VoidKeyword */, + "while": 42 /* WhileKeyword */, + "with": 43 /* WithKeyword */, + "yield": 59 /* YieldKeyword */, + "{": 70 /* OpenBraceToken */, + "}": 71 /* CloseBraceToken */, + "(": 72 /* OpenParenToken */, + ")": 73 /* CloseParenToken */, + "[": 74 /* OpenBracketToken */, + "]": 75 /* CloseBracketToken */, + ".": 76 /* DotToken */, + "...": 77 /* DotDotDotToken */, + ";": 78 /* SemicolonToken */, + ",": 79 /* CommaToken */, + "<": 80 /* LessThanToken */, + ">": 81 /* GreaterThanToken */, + "<=": 82 /* LessThanEqualsToken */, + ">=": 83 /* GreaterThanEqualsToken */, + "==": 84 /* EqualsEqualsToken */, + "=>": 85 /* EqualsGreaterThanToken */, + "!=": 86 /* ExclamationEqualsToken */, + "===": 87 /* EqualsEqualsEqualsToken */, + "!==": 88 /* ExclamationEqualsEqualsToken */, + "+": 89 /* PlusToken */, + "-": 90 /* MinusToken */, + "*": 91 /* AsteriskToken */, + "%": 92 /* PercentToken */, + "++": 93 /* PlusPlusToken */, + "--": 94 /* MinusMinusToken */, + "<<": 95 /* LessThanLessThanToken */, + ">>": 96 /* GreaterThanGreaterThanToken */, + ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 98 /* AmpersandToken */, + "|": 99 /* BarToken */, + "^": 100 /* CaretToken */, + "!": 101 /* ExclamationToken */, + "~": 102 /* TildeToken */, + "&&": 103 /* AmpersandAmpersandToken */, + "||": 104 /* BarBarToken */, + "?": 105 /* QuestionToken */, + ":": 106 /* ColonToken */, + "=": 107 /* EqualsToken */, + "+=": 108 /* PlusEqualsToken */, + "-=": 109 /* MinusEqualsToken */, + "*=": 110 /* AsteriskEqualsToken */, + "%=": 111 /* PercentEqualsToken */, + "<<=": 112 /* LessThanLessThanEqualsToken */, + ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 115 /* AmpersandEqualsToken */, + "|=": 116 /* BarEqualsToken */, + "^=": 117 /* CaretEqualsToken */, + "/": 118 /* SlashToken */, + "/=": 119 /* SlashEqualsToken */ + }; + + var kindToText = new Array(); + + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + + kindToText[62 /* ConstructorKeyword */] = "constructor"; + + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + + function getText(kind) { + var result = kindToText[kind]; + return result !== undefined ? result : null; + } + SyntaxFacts.getText = getText; + + function isTokenKind(kind) { + return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; + } + SyntaxFacts.isTokenKind = isTokenKind; + + function isAnyKeyword(kind) { + return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + + function isStandardKeyword(kind) { + return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; + } + SyntaxFacts.isStandardKeyword = isStandardKeyword; + + function isFutureReservedKeyword(kind) { + return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; + } + SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; + + function isFutureReservedStrictKeyword(kind) { + return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; + } + SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; + + function isAnyPunctuation(kind) { + return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + + function isBinaryExpressionOperatorToken(tokenKind) { + return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + + function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 89 /* PlusToken */: + return 164 /* PlusExpression */; + case 90 /* MinusToken */: + return 165 /* NegateExpression */; + case 102 /* TildeToken */: + return 166 /* BitwiseNotExpression */; + case 101 /* ExclamationToken */: + return 167 /* LogicalNotExpression */; + case 93 /* PlusPlusToken */: + return 168 /* PreIncrementExpression */; + case 94 /* MinusMinusToken */: + return 169 /* PreDecrementExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; + + function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* PlusPlusToken */: + return 210 /* PostIncrementExpression */; + case 94 /* MinusMinusToken */: + return 211 /* PostDecrementExpression */; + default: + return 0 /* None */; + } + } + SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; + + function getBinaryExpressionFromOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* AsteriskToken */: + return 205 /* MultiplyExpression */; + + case 118 /* SlashToken */: + return 206 /* DivideExpression */; + + case 92 /* PercentToken */: + return 207 /* ModuloExpression */; + + case 89 /* PlusToken */: + return 208 /* AddExpression */; + + case 90 /* MinusToken */: + return 209 /* SubtractExpression */; + + case 95 /* LessThanLessThanToken */: + return 202 /* LeftShiftExpression */; + + case 96 /* GreaterThanGreaterThanToken */: + return 203 /* SignedRightShiftExpression */; + + case 97 /* GreaterThanGreaterThanGreaterThanToken */: + return 204 /* UnsignedRightShiftExpression */; + + case 80 /* LessThanToken */: + return 196 /* LessThanExpression */; + + case 81 /* GreaterThanToken */: + return 197 /* GreaterThanExpression */; + + case 82 /* LessThanEqualsToken */: + return 198 /* LessThanOrEqualExpression */; + + case 83 /* GreaterThanEqualsToken */: + return 199 /* GreaterThanOrEqualExpression */; + + case 30 /* InstanceOfKeyword */: + return 200 /* InstanceOfExpression */; + + case 29 /* InKeyword */: + return 201 /* InExpression */; + + case 84 /* EqualsEqualsToken */: + return 192 /* EqualsWithTypeConversionExpression */; + + case 86 /* ExclamationEqualsToken */: + return 193 /* NotEqualsWithTypeConversionExpression */; + + case 87 /* EqualsEqualsEqualsToken */: + return 194 /* EqualsExpression */; + + case 88 /* ExclamationEqualsEqualsToken */: + return 195 /* NotEqualsExpression */; + + case 98 /* AmpersandToken */: + return 191 /* BitwiseAndExpression */; + + case 100 /* CaretToken */: + return 190 /* BitwiseExclusiveOrExpression */; + + case 99 /* BarToken */: + return 189 /* BitwiseOrExpression */; + + case 103 /* AmpersandAmpersandToken */: + return 188 /* LogicalAndExpression */; + + case 104 /* BarBarToken */: + return 187 /* LogicalOrExpression */; + + case 116 /* BarEqualsToken */: + return 182 /* OrAssignmentExpression */; + + case 115 /* AmpersandEqualsToken */: + return 180 /* AndAssignmentExpression */; + + case 117 /* CaretEqualsToken */: + return 181 /* ExclusiveOrAssignmentExpression */; + + case 112 /* LessThanLessThanEqualsToken */: + return 183 /* LeftShiftAssignmentExpression */; + + case 113 /* GreaterThanGreaterThanEqualsToken */: + return 184 /* SignedRightShiftAssignmentExpression */; + + case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return 185 /* UnsignedRightShiftAssignmentExpression */; + + case 108 /* PlusEqualsToken */: + return 175 /* AddAssignmentExpression */; + + case 109 /* MinusEqualsToken */: + return 176 /* SubtractAssignmentExpression */; + + case 110 /* AsteriskEqualsToken */: + return 177 /* MultiplyAssignmentExpression */; + + case 119 /* SlashEqualsToken */: + return 178 /* DivideAssignmentExpression */; + + case 111 /* PercentEqualsToken */: + return 179 /* ModuloAssignmentExpression */; + + case 107 /* EqualsToken */: + return 174 /* AssignmentExpression */; + + case 79 /* CommaToken */: + return 173 /* CommaExpression */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; + + function getOperatorTokenFromBinaryExpression(tokenKind) { + switch (tokenKind) { + case 205 /* MultiplyExpression */: + return 91 /* AsteriskToken */; + + case 206 /* DivideExpression */: + return 118 /* SlashToken */; + + case 207 /* ModuloExpression */: + return 92 /* PercentToken */; + + case 208 /* AddExpression */: + return 89 /* PlusToken */; + + case 209 /* SubtractExpression */: + return 90 /* MinusToken */; + + case 202 /* LeftShiftExpression */: + return 95 /* LessThanLessThanToken */; + + case 203 /* SignedRightShiftExpression */: + return 96 /* GreaterThanGreaterThanToken */; + + case 204 /* UnsignedRightShiftExpression */: + return 97 /* GreaterThanGreaterThanGreaterThanToken */; + + case 196 /* LessThanExpression */: + return 80 /* LessThanToken */; + + case 197 /* GreaterThanExpression */: + return 81 /* GreaterThanToken */; + + case 198 /* LessThanOrEqualExpression */: + return 82 /* LessThanEqualsToken */; + + case 199 /* GreaterThanOrEqualExpression */: + return 83 /* GreaterThanEqualsToken */; + + case 200 /* InstanceOfExpression */: + return 30 /* InstanceOfKeyword */; + + case 201 /* InExpression */: + return 29 /* InKeyword */; + + case 192 /* EqualsWithTypeConversionExpression */: + return 84 /* EqualsEqualsToken */; + + case 193 /* NotEqualsWithTypeConversionExpression */: + return 86 /* ExclamationEqualsToken */; + + case 194 /* EqualsExpression */: + return 87 /* EqualsEqualsEqualsToken */; + + case 195 /* NotEqualsExpression */: + return 88 /* ExclamationEqualsEqualsToken */; + + case 191 /* BitwiseAndExpression */: + return 98 /* AmpersandToken */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 100 /* CaretToken */; + + case 189 /* BitwiseOrExpression */: + return 99 /* BarToken */; + + case 188 /* LogicalAndExpression */: + return 103 /* AmpersandAmpersandToken */; + + case 187 /* LogicalOrExpression */: + return 104 /* BarBarToken */; + + case 182 /* OrAssignmentExpression */: + return 116 /* BarEqualsToken */; + + case 180 /* AndAssignmentExpression */: + return 115 /* AmpersandEqualsToken */; + + case 181 /* ExclusiveOrAssignmentExpression */: + return 117 /* CaretEqualsToken */; + + case 183 /* LeftShiftAssignmentExpression */: + return 112 /* LessThanLessThanEqualsToken */; + + case 184 /* SignedRightShiftAssignmentExpression */: + return 113 /* GreaterThanGreaterThanEqualsToken */; + + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + + case 175 /* AddAssignmentExpression */: + return 108 /* PlusEqualsToken */; + + case 176 /* SubtractAssignmentExpression */: + return 109 /* MinusEqualsToken */; + + case 177 /* MultiplyAssignmentExpression */: + return 110 /* AsteriskEqualsToken */; + + case 178 /* DivideAssignmentExpression */: + return 119 /* SlashEqualsToken */; + + case 179 /* ModuloAssignmentExpression */: + return 111 /* PercentEqualsToken */; + + case 174 /* AssignmentExpression */: + return 107 /* EqualsToken */; + + case 173 /* CommaExpression */: + return 79 /* CommaToken */; + + default: + return 0 /* None */; + } + } + SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; + + function isAnyDivideToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideToken = isAnyDivideToken; + + function isAnyDivideOrRegularExpressionToken(kind) { + switch (kind) { + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + case 12 /* RegularExpressionLiteral */: + return true; + default: + return false; + } + } + SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); + + for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { + if (character >= 97 /* a */ && character <= 122 /* z */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { + isIdentifierStartCharacter[character] = true; + isIdentifierPartCharacter[character] = true; + } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { + isIdentifierPartCharacter[character] = true; + isNumericLiteralStart[character] = true; + } + } + + isNumericLiteralStart[46 /* dot */] = true; + + for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { + var keyword = TypeScript.SyntaxFacts.getText(keywordKind); + isKeywordStartCharacter[keyword.charCodeAt(0)] = true; + } + + var Scanner = (function () { + function Scanner(fileName, text, languageVersion, window) { + if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } + this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); + this.fileName = fileName; + this.text = text; + this._languageVersion = languageVersion; + } + Scanner.prototype.languageVersion = function () { + return this._languageVersion; + }; + + Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { + var charactersRemaining = this.text.length() - sourceIndex; + var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); + this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); + return amountToRead; + }; + + Scanner.prototype.currentCharCode = function () { + return this.slidingWindow.currentItem(null); + }; + + Scanner.prototype.absoluteIndex = function () { + return this.slidingWindow.absoluteIndex(); + }; + + Scanner.prototype.setAbsoluteIndex = function (index) { + this.slidingWindow.setAbsoluteIndex(index); + }; + + Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { + var diagnosticsLength = diagnostics.length; + var fullStart = this.slidingWindow.absoluteIndex(); + var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); + + var start = this.slidingWindow.absoluteIndex(); + var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); + 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); + + return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; + }; + + 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 { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); + return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + 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(fullText, kind); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); + } + } else if (trailingTriviaInfo === 0) { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); + } else { + return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); + } + } + }; + + Scanner.scanTrivia = function (text, start, length, isTrailing) { + var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); + return scanner.scanTrivia(text, start, isTrailing); + }; + + Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { + var trivia = new Array(); + + while (true) { + if (!this.slidingWindow.isAtEndOfSource()) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + if (ch2 === 42 /* asterisk */) { + trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); + continue; + } + + throw TypeScript.Errors.invalidOperation(); + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); + + if (!isTrailing) { + continue; + } + + break; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + return TypeScript.Syntax.triviaList(trivia); + } + }; + + Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { + var width = 0; + var hasCommentOrNewLine = 0; + + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + + case 47 /* slash */: + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 47 /* slash */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanSingleLineCommentTriviaLength(); + continue; + } + + if (ch2 === 42 /* asterisk */) { + hasCommentOrNewLine |= 2 /* TriviaCommentMask */; + width += this.scanMultiLineCommentTriviaLength(diagnostics); + continue; + } + + break; + + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; + width += this.scanLineTerminatorSequenceLength(ch); + + if (!isTrailing) { + continue; + } + + break; + } + + return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; + } + }; + + Scanner.prototype.isNewLineCharacter = function (ch) { + switch (ch) { + case 13 /* carriageReturn */: + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + return true; + default: + return false; + } + }; + + Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + + var width = 0; + while (true) { + var ch = this.currentCharCode(); + + switch (ch) { + case 32 /* space */: + case 160 /* nonBreakingSpace */: + case 8192 /* enQuad */: + case 8193 /* emQuad */: + case 8194 /* enSpace */: + case 8195 /* emSpace */: + case 8196 /* threePerEmSpace */: + case 8197 /* fourPerEmSpace */: + case 8198 /* sixPerEmSpace */: + case 8199 /* figureSpace */: + case 8200 /* punctuationSpace */: + case 8201 /* thinSpace */: + case 8202 /* hairSpace */: + case 8203 /* zeroWidthSpace */: + case 8239 /* narrowNoBreakSpace */: + case 12288 /* ideographicSpace */: + + case 9 /* tab */: + case 11 /* verticalTab */: + case 12 /* formFeed */: + case 65279 /* byteOrderMark */: + this.slidingWindow.moveToNextItem(); + width++; + continue; + } + + break; + } + + return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.slidingWindow.absoluteIndex(); + var width = this.scanSingleLineCommentTriviaLength(); + + return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanSingleLineCommentTriviaLength = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { + var absoluteStartIndex = this.absoluteIndex(); + var width = this.scanMultiLineCommentTriviaLength(null); + + return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); + }; + + Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + var width = 2; + while (true) { + if (this.slidingWindow.isAtEndOfSource()) { + if (diagnostics !== null) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); + } + + return width; + } + + var ch = this.currentCharCode(); + if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + width += 2; + return width; + } + + this.slidingWindow.moveToNextItem(); + width++; + } + }; + + Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { + var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + var width = this.scanLineTerminatorSequenceLength(ch); + + var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); + + return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); + }; + + Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { + this.slidingWindow.moveToNextItem(); + + if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + return 2; + } else { + return 1; + } + }; + + Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { + if (this.slidingWindow.isAtEndOfSource()) { + return 10 /* EndOfFileToken */; + } + + var character = this.currentCharCode(); + + switch (character) { + case 34 /* doubleQuote */: + case 39 /* singleQuote */: + return this.scanStringLiteral(diagnostics); + + case 47 /* slash */: + return this.scanSlashToken(allowRegularExpression); + + case 46 /* dot */: + return this.scanDotToken(diagnostics); + + case 45 /* minus */: + return this.scanMinusToken(); + + case 33 /* exclamation */: + return this.scanExclamationToken(); + + case 61 /* equals */: + return this.scanEqualsToken(); + + case 124 /* bar */: + return this.scanBarToken(); + + case 42 /* asterisk */: + return this.scanAsteriskToken(); + + case 43 /* plus */: + return this.scanPlusToken(); + + case 37 /* percent */: + return this.scanPercentToken(); + + case 38 /* ampersand */: + return this.scanAmpersandToken(); + + case 94 /* caret */: + return this.scanCaretToken(); + + case 60 /* lessThan */: + return this.scanLessThanToken(); + + case 62 /* greaterThan */: + return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); + + case 44 /* comma */: + return this.advanceAndSetTokenKind(79 /* CommaToken */); + + case 58 /* colon */: + return this.advanceAndSetTokenKind(106 /* ColonToken */); + + case 59 /* semicolon */: + return this.advanceAndSetTokenKind(78 /* SemicolonToken */); + + case 126 /* tilde */: + return this.advanceAndSetTokenKind(102 /* TildeToken */); + + case 40 /* openParen */: + return this.advanceAndSetTokenKind(72 /* OpenParenToken */); + + case 41 /* closeParen */: + return this.advanceAndSetTokenKind(73 /* CloseParenToken */); + + case 123 /* openBrace */: + return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); + + case 125 /* closeBrace */: + return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); + + case 91 /* openBracket */: + return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); + + case 93 /* closeBracket */: + return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); + + case 63 /* question */: + return this.advanceAndSetTokenKind(105 /* QuestionToken */); + } + + if (isNumericLiteralStart[character]) { + return this.scanNumericLiteral(diagnostics); + } + + if (isIdentifierStartCharacter[character]) { + var result = this.tryFastScanIdentifierOrKeyword(character); + if (result !== 0 /* None */) { + return result; + } + } + + if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { + return this.slowScanIdentifierOrKeyword(diagnostics); + } + + return this.scanDefaultCharacter(character, diagnostics); + }; + + Scanner.prototype.isIdentifierStart = function (interpretedChar) { + if (isIdentifierStartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.isIdentifierPart = function (interpretedChar) { + if (isIdentifierPartCharacter[interpretedChar]) { + return true; + } + + return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); + }; + + Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { + var slidingWindow = this.slidingWindow; + var window = slidingWindow.window; + + var startIndex = slidingWindow.currentRelativeItemIndex; + var endIndex = slidingWindow.windowCount; + var currentIndex = startIndex; + var character = 0; + + while (currentIndex < endIndex) { + character = window[currentIndex]; + if (!isIdentifierPartCharacter[character]) { + break; + } + + currentIndex++; + } + + if (currentIndex === endIndex) { + return 0 /* None */; + } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { + return 0 /* None */; + } else { + var kind; + var identifierLength = currentIndex - startIndex; + if (isKeywordStartCharacter[firstCharacter]) { + kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); + } else { + kind = 11 /* IdentifierName */; + } + + slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); + + return kind; + } + }; + + Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { + var startIndex = this.slidingWindow.absoluteIndex(); + var sawUnicodeEscape = false; + + do { + var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); + sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; + } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); + + var length = this.slidingWindow.absoluteIndex() - startIndex; + var text = this.text.substr(startIndex, length, false); + var valueText = TypeScript.Syntax.massageEscapes(text); + + var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); + if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { + if (sawUnicodeEscape) { + return keywordKind | -2147483648 /* IsVariableWidthKeyword */; + } else { + return keywordKind; + } + } + + return 11 /* IdentifierName */; + }; + + Scanner.prototype.scanNumericLiteral = function (diagnostics) { + if (this.isHexNumericLiteral()) { + this.scanHexNumericLiteral(); + } else if (this.isOctalNumericLiteral()) { + this.scanOctalNumericLiteral(diagnostics); + } else { + this.scanDecimalNumericLiteral(); + } + + return 13 /* NumericLiteral */; + }; + + Scanner.prototype.isOctalNumericLiteral = function () { + return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); + }; + + Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { + var position = this.absoluteIndex(); + + while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + + if (this.languageVersion() >= 1 /* EcmaScript5 */) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); + } + }; + + Scanner.prototype.scanDecimalDigits = function () { + while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.scanDecimalNumericLiteral = function () { + this.scanDecimalDigits(); + + if (this.currentCharCode() === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + } + + this.scanDecimalDigits(); + + var ch = this.currentCharCode(); + if (ch === 101 /* e */ || ch === 69 /* E */) { + var nextChar1 = this.slidingWindow.peekItemN(1); + + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { + var nextChar2 = this.slidingWindow.peekItemN(2); + if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + this.scanDecimalDigits(); + } + } + } + }; + + Scanner.prototype.scanHexNumericLiteral = function () { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + + while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { + this.slidingWindow.moveToNextItem(); + } + }; + + Scanner.prototype.isHexNumericLiteral = function () { + if (this.currentCharCode() === 48 /* _0 */) { + var ch = this.slidingWindow.peekItemN(1); + + if (ch === 120 /* x */ || ch === 88 /* X */) { + ch = this.slidingWindow.peekItemN(2); + + return TypeScript.CharacterInfo.isHexDigit(ch); + } + } + + return false; + }; + + Scanner.prototype.advanceAndSetTokenKind = function (kind) { + this.slidingWindow.moveToNextItem(); + return kind; + }; + + Scanner.prototype.scanLessThanToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 82 /* LessThanEqualsToken */; + } else if (this.currentCharCode() === 60 /* lessThan */) { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 112 /* LessThanLessThanEqualsToken */; + } else { + return 95 /* LessThanLessThanToken */; + } + } else { + return 80 /* LessThanToken */; + } + }; + + Scanner.prototype.scanBarToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 116 /* BarEqualsToken */; + } else if (this.currentCharCode() === 124 /* bar */) { + this.slidingWindow.moveToNextItem(); + return 104 /* BarBarToken */; + } else { + return 99 /* BarToken */; + } + }; + + Scanner.prototype.scanCaretToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 117 /* CaretEqualsToken */; + } else { + return 100 /* CaretToken */; + } + }; + + Scanner.prototype.scanAmpersandToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 115 /* AmpersandEqualsToken */; + } else if (this.currentCharCode() === 38 /* ampersand */) { + this.slidingWindow.moveToNextItem(); + return 103 /* AmpersandAmpersandToken */; + } else { + return 98 /* AmpersandToken */; + } + }; + + Scanner.prototype.scanPercentToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 111 /* PercentEqualsToken */; + } else { + return 92 /* PercentToken */; + } + }; + + Scanner.prototype.scanMinusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 109 /* MinusEqualsToken */; + } else if (character === 45 /* minus */) { + this.slidingWindow.moveToNextItem(); + return 94 /* MinusMinusToken */; + } else { + return 90 /* MinusToken */; + } + }; + + Scanner.prototype.scanPlusToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 108 /* PlusEqualsToken */; + } else if (character === 43 /* plus */) { + this.slidingWindow.moveToNextItem(); + return 93 /* PlusPlusToken */; + } else { + return 89 /* PlusToken */; + } + }; + + Scanner.prototype.scanAsteriskToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 110 /* AsteriskEqualsToken */; + } else { + return 91 /* AsteriskToken */; + } + }; + + Scanner.prototype.scanEqualsToken = function () { + this.slidingWindow.moveToNextItem(); + var character = this.currentCharCode(); + if (character === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 87 /* EqualsEqualsEqualsToken */; + } else { + return 84 /* EqualsEqualsToken */; + } + } else if (character === 62 /* greaterThan */) { + this.slidingWindow.moveToNextItem(); + return 85 /* EqualsGreaterThanToken */; + } else { + return 107 /* EqualsToken */; + } + }; + + Scanner.prototype.isDotPrefixedNumericLiteral = function () { + if (this.currentCharCode() === 46 /* dot */) { + var ch = this.slidingWindow.peekItemN(1); + return TypeScript.CharacterInfo.isDecimalDigit(ch); + } + + return false; + }; + + Scanner.prototype.scanDotToken = function (diagnostics) { + if (this.isDotPrefixedNumericLiteral()) { + return this.scanNumericLiteral(diagnostics); + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { + this.slidingWindow.moveToNextItem(); + this.slidingWindow.moveToNextItem(); + return 77 /* DotDotDotToken */; + } else { + return 76 /* DotToken */; + } + }; + + Scanner.prototype.scanSlashToken = function (allowRegularExpression) { + if (allowRegularExpression) { + var result = this.tryScanRegularExpressionToken(); + if (result !== 0 /* None */) { + return result; + } + } + + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + return 119 /* SlashEqualsToken */; + } else { + return 118 /* SlashToken */; + } + }; + + Scanner.prototype.tryScanRegularExpressionToken = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var inEscape = false; + var inCharacterClass = false; + while (true) { + var ch = this.currentCharCode(); + + if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 0 /* None */; + } + + this.slidingWindow.moveToNextItem(); + if (inEscape) { + inEscape = false; + continue; + } + + switch (ch) { + case 92 /* backslash */: + inEscape = true; + continue; + + case 91 /* openBracket */: + inCharacterClass = true; + continue; + + case 93 /* closeBracket */: + inCharacterClass = false; + continue; + + case 47 /* slash */: + if (inCharacterClass) { + continue; + } + + break; + + default: + continue; + } + + break; + } + + while (isIdentifierPartCharacter[this.currentCharCode()]) { + this.slidingWindow.moveToNextItem(); + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + return 12 /* RegularExpressionLiteral */; + }; + + Scanner.prototype.scanExclamationToken = function () { + this.slidingWindow.moveToNextItem(); + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + if (this.currentCharCode() === 61 /* equals */) { + this.slidingWindow.moveToNextItem(); + + return 88 /* ExclamationEqualsEqualsToken */; + } else { + return 86 /* ExclamationEqualsToken */; + } + } else { + return 101 /* ExclamationToken */; + } + }; + + Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { + var position = this.slidingWindow.absoluteIndex(); + this.slidingWindow.moveToNextItem(); + + var text = String.fromCharCode(character); + var messageText = this.getErrorMessageText(text); + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); + + return 9 /* ErrorToken */; + }; + + Scanner.prototype.getErrorMessageText = function (text) { + if (text === "\\") { + return '"\\"'; + } + + return JSON.stringify(text); + }; + + Scanner.prototype.skipEscapeSequence = function (diagnostics) { + var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); + + this.slidingWindow.moveToNextItem(); + + var ch = this.currentCharCode(); + this.slidingWindow.moveToNextItem(); + switch (ch) { + case 120 /* x */: + case 117 /* u */: + this.slidingWindow.rewindToPinnedIndex(rewindPoint); + var value = this.scanUnicodeOrHexEscape(diagnostics); + break; + + case 13 /* carriageReturn */: + if (this.currentCharCode() === 10 /* lineFeed */) { + this.slidingWindow.moveToNextItem(); + } + break; + + default: + break; + } + + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); + }; + + Scanner.prototype.scanStringLiteral = function (diagnostics) { + var quoteCharacter = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + while (true) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + this.skipEscapeSequence(diagnostics); + } else if (ch === quoteCharacter) { + this.slidingWindow.moveToNextItem(); + break; + } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { + diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); + break; + } else { + this.slidingWindow.moveToNextItem(); + } + } + + return 14 /* StringLiteral */; + }; + + Scanner.prototype.isUnicodeEscape = function (character) { + if (character === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + return true; + } + } + + return false; + }; + + Scanner.prototype.peekCharOrUnicodeEscape = function () { + var character = this.currentCharCode(); + if (this.isUnicodeEscape(character)) { + return this.peekUnicodeOrHexEscape(); + } else { + return character; + } + }; + + Scanner.prototype.peekUnicodeOrHexEscape = function () { + var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var ch = this.scanUnicodeOrHexEscape(null); + + this.slidingWindow.rewindToPinnedIndex(startIndex); + this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); + + return ch; + }; + + Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { + var ch = this.currentCharCode(); + if (ch === 92 /* backslash */) { + var ch2 = this.slidingWindow.peekItemN(1); + if (ch2 === 117 /* u */) { + this.scanUnicodeOrHexEscape(errors); + return true; + } + } + + this.slidingWindow.moveToNextItem(); + return false; + }; + + Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { + var start = this.slidingWindow.absoluteIndex(); + var character = this.currentCharCode(); + + this.slidingWindow.moveToNextItem(); + + character = this.currentCharCode(); + + var intChar = 0; + this.slidingWindow.moveToNextItem(); + + var count = character === 117 /* u */ ? 4 : 2; + + for (var i = 0; i < count; i++) { + var ch2 = this.currentCharCode(); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + if (errors !== null) { + var end = this.slidingWindow.absoluteIndex(); + var info = this.createIllegalEscapeDiagnostic(start, end); + errors.push(info); + } + + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + this.slidingWindow.moveToNextItem(); + } + + return intChar; + }; + + Scanner.prototype.substring = function (start, end, intern) { + var length = end - start; + var offset = start - this.slidingWindow.windowAbsoluteStartIndex; + + if (intern) { + return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); + } else { + return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); + } + }; + + Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { + return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + }; + + Scanner.isValidIdentifier = function (text, languageVersion) { + var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); + var errors = new Array(); + var token = scanner.scan(errors, false); + + return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); + }; + Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + return Scanner; + })(); + TypeScript.Scanner = Scanner; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ScannerUtilities = (function () { + function ScannerUtilities() { + } + ScannerUtilities.identifierKind = function (array, startIndex, length) { + switch (length) { + case 2: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + switch (array[startIndex + 1]) { + case 102 /* f */: + return 28 /* IfKeyword */; + case 110 /* n */: + return 29 /* InKeyword */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 3: + switch (array[startIndex]) { + case 102 /* f */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; + case 118 /* v */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; + case 97 /* a */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; + case 103 /* g */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 4: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + switch (array[startIndex + 1]) { + case 108 /* l */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 1]) { + case 104 /* h */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 118 /* v */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 5: + switch (array[startIndex]) { + case 98 /* b */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; + case 108 /* l */: + return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; + case 111 /* o */: + return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; + case 119 /* w */: + return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; + case 121 /* y */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 6: + switch (array[startIndex]) { + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 115 /* s */: + switch (array[startIndex + 1]) { + case 119 /* w */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; + case 116 /* t */: + switch (array[startIndex + 2]) { + case 97 /* a */: + return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 116 /* t */: + return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; + case 105 /* i */: + return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 7: + switch (array[startIndex]) { + case 100 /* d */: + switch (array[startIndex + 1]) { + case 101 /* e */: + switch (array[startIndex + 2]) { + case 102 /* f */: + return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: + return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 102 /* f */: + return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: + return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + switch (array[startIndex + 1]) { + case 97 /* a */: + return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 98 /* b */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 114 /* r */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 8: + switch (array[startIndex]) { + case 99 /* c */: + return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: + return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; + case 102 /* f */: + return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 9: + switch (array[startIndex]) { + case 105 /* i */: + return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; + case 112 /* p */: + return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + case 10: + switch (array[startIndex]) { + case 105 /* i */: + switch (array[startIndex + 1]) { + case 110 /* n */: + return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; + case 109 /* m */: + return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + + default: + return 11 /* IdentifierName */; + } + + case 11: + return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; + default: + return 11 /* IdentifierName */; + } + }; + return ScannerUtilities; + })(); + TypeScript.ScannerUtilities = ScannerUtilities; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySeparatedSyntaxList = (function () { + function EmptySeparatedSyntaxList() { + } + EmptySeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + EmptySeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isList = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + EmptySeparatedSyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return []; + }; + + EmptySeparatedSyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySeparatedSyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySeparatedSyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySeparatedSyntaxList.prototype.width = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + + EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + return EmptySeparatedSyntaxList; + })(); + + Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); + + var SingletonSeparatedSyntaxList = (function () { + function SingletonSeparatedSyntaxList(item) { + this.item = item; + } + SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + SingletonSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + + SingletonSeparatedSyntaxList.prototype.childCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return 1; + }; + SingletonSeparatedSyntaxList.prototype.separatorCount = function () { + return 0; + }; + + SingletonSeparatedSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + return [this.item]; + }; + + SingletonSeparatedSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSeparatedSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSeparatedSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSeparatedSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSeparatedSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSeparatedSyntaxList; + })(); + + var NormalSeparatedSyntaxList = (function () { + function NormalSeparatedSyntaxList(elements) { + this._data = 0; + this.elements = elements; + } + NormalSeparatedSyntaxList.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + NormalSeparatedSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isList = function () { + return false; + }; + NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { + return true; + }; + NormalSeparatedSyntaxList.prototype.toJSON = function (key) { + return this.elements; + }; + + NormalSeparatedSyntaxList.prototype.childCount = function () { + return this.elements.length; + }; + NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); + }; + NormalSeparatedSyntaxList.prototype.separatorCount = function () { + return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); + }; + + NormalSeparatedSyntaxList.prototype.toArray = function () { + return this.elements.slice(0); + }; + + NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { + var result = []; + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + result.push(this.nonSeparatorAt(i)); + } + + return result; + }; + + NormalSeparatedSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[index]; + }; + + NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { + var value = index * 2; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { + var value = index * 2 + 1; + if (value < 0 || value >= this.elements.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.elements[value]; + }; + + NormalSeparatedSyntaxList.prototype.firstToken = function () { + var token; + for (var i = 0, n = this.elements.length; i < n; i++) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.firstToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.lastToken = function () { + var token; + for (var i = this.elements.length - 1; i >= 0; i--) { + if (i % 2 === 0) { + var nodeOrToken = this.elements[i]; + token = nodeOrToken.lastToken(); + if (token !== null) { + return token; + } + } else { + token = this.elements[i]; + if (token.width() > 0) { + return token; + } + } + } + + return null; + }; + + NormalSeparatedSyntaxList.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSeparatedSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSeparatedSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSeparatedSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + fullWidth += childWidth; + + isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSeparatedSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + + var childWidth = element.fullWidth(); + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.elements.length; i < n; i++) { + var element = this.elements[i]; + element.collectTextElements(elements); + } + }; + + NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.elements); + } else { + array.splice.apply(array, [index, 0].concat(this.elements)); + } + }; + return NormalSeparatedSyntaxList; + })(); + + function separatedList(nodes) { + return separatedListAndValidate(nodes, false); + } + Syntax.separatedList = separatedList; + + function separatedListAndValidate(nodes, validate) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptySeparatedList; + } + + if (validate) { + for (var i = 0; i < nodes.length; i++) { + var item = nodes[i]; + + if (i % 2 === 1) { + } + } + } + + if (nodes.length === 1) { + return new SingletonSeparatedSyntaxList(nodes[0]); + } + + return new NormalSeparatedSyntaxList(nodes); + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SlidingWindow = (function () { + function SlidingWindow(source, window, defaultValue, sourceLength) { + if (typeof sourceLength === "undefined") { sourceLength = -1; } + this.source = source; + this.window = window; + this.defaultValue = defaultValue; + this.sourceLength = sourceLength; + this.windowCount = 0; + this.windowAbsoluteStartIndex = 0; + this.currentRelativeItemIndex = 0; + this._pinCount = 0; + this.firstPinnedAbsoluteIndex = -1; + } + SlidingWindow.prototype.windowAbsoluteEndIndex = function () { + return this.windowAbsoluteStartIndex + this.windowCount; + }; + + SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { + if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { + return false; + } + + if (this.windowCount >= this.window.length) { + this.tryShiftOrGrowWindow(); + } + + var spaceAvailable = this.window.length - this.windowCount; + var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); + + this.windowCount += amountFetched; + return amountFetched > 0; + }; + + SlidingWindow.prototype.tryShiftOrGrowWindow = function () { + var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); + + var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; + + if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { + var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; + + var shiftCount = this.windowCount - shiftStartIndex; + + if (shiftCount > 0) { + TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); + } + + this.windowAbsoluteStartIndex += shiftStartIndex; + + this.windowCount -= shiftStartIndex; + + this.currentRelativeItemIndex -= shiftStartIndex; + } else { + TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); + } + }; + + SlidingWindow.prototype.absoluteIndex = function () { + return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.isAtEndOfSource = function () { + return this.absoluteIndex() >= this.sourceLength; + }; + + SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { + var absoluteIndex = this.absoluteIndex(); + var pinCount = this._pinCount++; + if (pinCount === 0) { + this.firstPinnedAbsoluteIndex = absoluteIndex; + } + + return absoluteIndex; + }; + + SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { + this._pinCount--; + if (this._pinCount === 0) { + this.firstPinnedAbsoluteIndex = -1; + } + }; + + SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { + var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; + + this.currentRelativeItemIndex = relativeIndex; + }; + + SlidingWindow.prototype.currentItem = function (argument) { + if (this.currentRelativeItemIndex >= this.windowCount) { + if (!this.addMoreItemsToWindow(argument)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex]; + }; + + SlidingWindow.prototype.peekItemN = function (n) { + while (this.currentRelativeItemIndex + n >= this.windowCount) { + if (!this.addMoreItemsToWindow(null)) { + return this.defaultValue; + } + } + + return this.window[this.currentRelativeItemIndex + n]; + }; + + SlidingWindow.prototype.moveToNextItem = function () { + this.currentRelativeItemIndex++; + }; + + SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { + this.windowCount = this.currentRelativeItemIndex; + }; + + SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { + if (this.absoluteIndex() === absoluteIndex) { + return; + } + + if (this._pinCount > 0) { + } + + if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { + this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); + } else { + this.windowAbsoluteStartIndex = absoluteIndex; + + this.windowCount = 0; + + this.currentRelativeItemIndex = 0; + } + }; + + SlidingWindow.prototype.pinCount = function () { + return this._pinCount; + }; + return SlidingWindow; + })(); + TypeScript.SlidingWindow = SlidingWindow; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function emptySourceUnit() { + return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); + } + Syntax.emptySourceUnit = emptySourceUnit; + + function getStandaloneExpression(positionedToken) { + var token = positionedToken.token(); + if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { + var parentPositionedNode = positionedToken.containingNode(); + var parentNode = parentPositionedNode.node(); + + if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { + return parentPositionedNode; + } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { + return parentPositionedNode; + } + } + + return positionedToken; + } + Syntax.getStandaloneExpression = getStandaloneExpression; + + function isInModuleOrTypeContext(positionedToken) { + if (positionedToken !== null) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var parent = positionedNodeOrToken.containingNode(); + + if (parent !== null) { + switch (parent.kind()) { + case 246 /* ModuleNameModuleReference */: + return true; + case 121 /* QualifiedName */: + return true; + default: + return isInTypeOnlyContext(positionedToken); + } + } + } + + return false; + } + Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; + + function isInTypeOnlyContext(positionedToken) { + var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); + var positionedParent = positionedNodeOrToken.containingNode(); + + var parent = positionedParent.node(); + var nodeOrToken = positionedNodeOrToken.nodeOrToken(); + + if (parent !== null) { + switch (parent.kind()) { + case 124 /* ArrayType */: + return parent.type === nodeOrToken; + case 220 /* CastExpression */: + return parent.type === nodeOrToken; + case 244 /* TypeAnnotation */: + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + case 228 /* TypeArgumentList */: + return true; + } + } + + return false; + } + Syntax.isInTypeOnlyContext = isInTypeOnlyContext; + + function childOffset(parent, child) { + var offset = 0; + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return offset; + } + + if (current !== null) { + offset += current.fullWidth(); + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childOffset = childOffset; + + function childOffsetAt(parent, index) { + var offset = 0; + for (var i = 0; i < index; i++) { + var current = parent.childAt(i); + if (current !== null) { + offset += current.fullWidth(); + } + } + + return offset; + } + Syntax.childOffsetAt = childOffsetAt; + + function childIndex(parent, child) { + for (var i = 0, n = parent.childCount(); i < n; i++) { + var current = parent.childAt(i); + if (current === child) { + return i; + } + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.childIndex = childIndex; + + function nodeStructuralEquals(node1, node2) { + if (node1 === null) { + return node2 === null; + } + + return node1.structuralEquals(node2); + } + Syntax.nodeStructuralEquals = nodeStructuralEquals; + + function nodeOrTokenStructuralEquals(node1, node2) { + if (node1 === node2) { + return true; + } + + if (node1 === null || node2 === null) { + return false; + } + + if (node1.isToken()) { + return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; + } + + return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; + } + Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; + + function tokenStructuralEquals(token1, token2) { + if (token1 === token2) { + return true; + } + + if (token1 === null || token2 === null) { + return false; + } + + return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); + } + Syntax.tokenStructuralEquals = tokenStructuralEquals; + + function triviaListStructuralEquals(triviaList1, triviaList2) { + if (triviaList1.count() !== triviaList2.count()) { + return false; + } + + for (var i = 0, n = triviaList1.count(); i < n; i++) { + if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { + return false; + } + } + + return true; + } + Syntax.triviaListStructuralEquals = triviaListStructuralEquals; + + function triviaStructuralEquals(trivia1, trivia2) { + return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); + } + Syntax.triviaStructuralEquals = triviaStructuralEquals; + + function listStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var child1 = list1.childAt(i); + var child2 = list2.childAt(i); + + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { + return false; + } + } + + return true; + } + Syntax.listStructuralEquals = listStructuralEquals; + + function separatedListStructuralEquals(list1, list2) { + if (list1.childCount() !== list2.childCount()) { + return false; + } + + for (var i = 0, n = list1.childCount(); i < n; i++) { + var element1 = list1.childAt(i); + var element2 = list2.childAt(i); + if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + } + Syntax.separatedListStructuralEquals = separatedListStructuralEquals; + + function elementStructuralEquals(element1, element2) { + if (element1 === element2) { + return true; + } + + if (element1 === null || element2 === null) { + return false; + } + + if (element2.kind() !== element2.kind()) { + return false; + } + + if (element1.isToken()) { + return tokenStructuralEquals(element1, element2); + } else if (element1.isNode()) { + return nodeStructuralEquals(element1, element2); + } else if (element1.isList()) { + return listStructuralEquals(element1, element2); + } else if (element1.isSeparatedList()) { + return separatedListStructuralEquals(element1, element2); + } + + throw TypeScript.Errors.invalidOperation(); + } + Syntax.elementStructuralEquals = elementStructuralEquals; + + function identifierName(text, info) { + if (typeof info === "undefined") { info = null; } + return TypeScript.Syntax.identifier(text); + } + Syntax.identifierName = identifierName; + + function trueExpression() { + return TypeScript.Syntax.token(37 /* TrueKeyword */); + } + Syntax.trueExpression = trueExpression; + + function falseExpression() { + return TypeScript.Syntax.token(24 /* FalseKeyword */); + } + Syntax.falseExpression = falseExpression; + + function numericLiteralExpression(text) { + return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); + } + Syntax.numericLiteralExpression = numericLiteralExpression; + + function stringLiteralExpression(text) { + return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); + } + Syntax.stringLiteralExpression = stringLiteralExpression; + + function isSuperInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperInvocationExpression = isSuperInvocationExpression; + + function isSuperInvocationExpressionStatement(node) { + return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); + } + Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; + + function isSuperMemberAccessExpression(node) { + return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; + } + Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; + + function isSuperMemberAccessInvocationExpression(node) { + return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); + } + Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; + + function assignmentExpression(left, token, right) { + return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); + } + Syntax.assignmentExpression = assignmentExpression; + + function nodeHasSkippedOrMissingTokens(node) { + for (var i = 0; i < node.childCount(); i++) { + var child = node.childAt(i); + if (child !== null && child.isToken()) { + var token = child; + + if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + return true; + } + } + } + return false; + } + Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; + + function isUnterminatedStringLiteral(token) { + if (token && token.kind() === 14 /* StringLiteral */) { + var text = token.text(); + return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); + } + + return false; + } + Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; + + function isUnterminatedMultilineCommentTrivia(trivia) { + if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + var text = trivia.fullText(); + return text.length < 4 || text.substring(text.length - 2) !== "*/"; + } + return false; + } + Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; + + function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { + if (trivia && trivia.isComment() && position > fullStart) { + var end = fullStart + trivia.fullWidth(); + if (position < end) { + return true; + } else if (position === end) { + return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + } + } + + return false; + } + Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; + + function isEntirelyInsideComment(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + var fullStart = positionedToken.fullStart(); + var triviaList = null; + var lastTriviaBeforeToken = null; + + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.token().hasLeadingTrivia()) { + triviaList = positionedToken.token().leadingTrivia(); + } else { + positionedToken = positionedToken.previousToken(); + if (positionedToken) { + if (positionedToken && positionedToken.token().hasTrailingTrivia()) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + } + } else { + if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { + triviaList = positionedToken.token().leadingTrivia(); + } else if (position >= (fullStart + positionedToken.token().width())) { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + } + + if (triviaList) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + if (position <= fullStart) { + break; + } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { + lastTriviaBeforeToken = trivia; + break; + } + + fullStart += trivia.fullWidth(); + } + } + + return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); + } + Syntax.isEntirelyInsideComment = isEntirelyInsideComment; + + function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { + var positionedToken = sourceUnit.findToken(position); + + if (positionedToken) { + if (positionedToken.kind() === 10 /* EndOfFileToken */) { + positionedToken = positionedToken.previousToken(); + return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); + } else if (position > positionedToken.start()) { + return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); + } + } + + return false; + } + Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; + + function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullStart; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullStart = positionedToken.fullStart(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullStart = positionedToken.end(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); + } + + fullStart += triviaWidth; + } + } + + return null; + } + + function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { + var triviaList = null; + var fullEnd; + + if (lookInLeadingTriviaList) { + triviaList = positionedToken.token().leadingTrivia(); + fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); + } else { + triviaList = positionedToken.token().trailingTrivia(); + fullEnd = positionedToken.fullEnd(); + } + + if (triviaList && triviaList.hasSkippedToken()) { + for (var i = triviaList.count() - 1; i >= 0; i--) { + var trivia = triviaList.syntaxTriviaAt(i); + var triviaWidth = trivia.fullWidth(); + + if (trivia.isSkippedToken() && position >= fullEnd) { + return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); + } + + fullEnd -= triviaWidth; + } + } + + return null; + } + + function findSkippedTokenInLeadingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, true); + } + Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; + + function findSkippedTokenInTrailingTriviaList(positionedToken, position) { + return findSkippedTokenInTriviaList(positionedToken, position, false); + } + Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; + + function findSkippedTokenInPositionedToken(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; + + function findSkippedTokenOnLeft(positionedToken, position) { + var positionInLeadingTriviaList = (position < positionedToken.start()); + return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); + } + Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; + + function getAncestorOfKind(positionedToken, kind) { + while (positionedToken && positionedToken.parent()) { + if (positionedToken.parent().kind() === kind) { + return positionedToken.parent(); + } + + positionedToken = positionedToken.parent(); + } + + return null; + } + Syntax.getAncestorOfKind = getAncestorOfKind; + + function hasAncestorOfKind(positionedToken, kind) { + return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; + } + Syntax.hasAncestorOfKind = hasAncestorOfKind; + + function isIntegerLiteral(expression) { + if (expression) { + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + expression = expression.operand; + return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); + + case 13 /* NumericLiteral */: + var text = expression.text(); + return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); + } + } + + return false; + } + Syntax.isIntegerLiteral = isIntegerLiteral; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var NormalModeFactory = (function () { + function NormalModeFactory() { + } + NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); + }; + NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); + }; + NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); + }; + NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); + }; + NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); + }; + NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); + }; + NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); + }; + NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); + }; + NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); + }; + NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); + }; + NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); + }; + NormalModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(false); + }; + NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); + }; + NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); + }; + NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); + }; + NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); + }; + NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); + }; + NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); + }; + NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); + }; + NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); + }; + NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); + }; + NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); + }; + NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); + }; + NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); + }; + NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); + }; + NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); + }; + NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); + }; + NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); + }; + NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); + }; + NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); + }; + NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); + }; + NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); + }; + NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); + }; + NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); + }; + NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); + }; + NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); + }; + NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); + }; + NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, false); + }; + NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); + }; + NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); + }; + NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); + }; + NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); + }; + NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); + }; + NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); + }; + NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); + }; + NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); + }; + NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); + }; + NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); + }; + NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); + }; + NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); + }; + NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); + }; + NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); + }; + NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); + }; + NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); + }; + NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); + }; + NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); + }; + NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); + }; + NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); + }; + NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); + }; + NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, false); + }; + NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); + }; + NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); + }; + NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); + }; + NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); + }; + NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); + }; + NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); + }; + NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); + }; + NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); + }; + NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); + }; + return NormalModeFactory; + })(); + Syntax.NormalModeFactory = NormalModeFactory; + + var StrictModeFactory = (function () { + function StrictModeFactory() { + } + StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { + return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); + }; + StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); + }; + StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { + return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); + }; + StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); + }; + StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { + return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); + }; + StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { + return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); + }; + StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); + }; + StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { + return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); + }; + StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { + return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); + }; + StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { + return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { + return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); + }; + StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { + return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); + }; + StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { + return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); + }; + StrictModeFactory.prototype.omittedExpression = function () { + return new TypeScript.OmittedExpressionSyntax(true); + }; + StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { + return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); + }; + StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { + return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); + }; + StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { + return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); + }; + StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { + return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); + }; + StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); + }; + StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { + return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); + }; + StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { + return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); + }; + StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { + return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); + }; + StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { + return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); + }; + StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { + return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); + }; + StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { + return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); + }; + StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); + }; + StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { + return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); + }; + StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { + return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); + }; + StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); + }; + StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { + return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); + }; + StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); + }; + StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { + return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); + }; + StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); + }; + StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { + return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); + }; + StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { + return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); + }; + StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { + return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); + }; + StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { + return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); + }; + StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { + return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); + }; + StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { + return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); + }; + StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { + return new TypeScript.TypeParameterSyntax(identifier, constraint, true); + }; + StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { + return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); + }; + StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { + return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); + }; + StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); + }; + StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { + return new TypeScript.ExpressionStatementSyntax(expression, 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); + }; + StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); + }; + StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { + return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); + }; + StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { + return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); + }; + StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { + return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); + }; + StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { + return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { + return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); + }; + StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { + return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); + }; + StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); + }; + StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { + return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); + }; + StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { + return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); + }; + StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { + return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { + return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); + }; + StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); + }; + StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); + }; + StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { + return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); + }; + StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { + return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); + }; + StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { + return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); + }; + StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { + return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); + }; + StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { + return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); + }; + StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { + return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); + }; + StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { + return new TypeScript.EmptyStatementSyntax(semicolonToken, true); + }; + StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { + return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); + }; + StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); + }; + StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { + return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); + }; + StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { + return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); + }; + StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); + }; + StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { + return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); + }; + StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { + return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); + }; + StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { + return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); + }; + StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { + return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); + }; + return StrictModeFactory; + })(); + Syntax.StrictModeFactory = StrictModeFactory; + + Syntax.normalModeFactory = new NormalModeFactory(); + Syntax.strictModeFactory = new StrictModeFactory(); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxFacts) { + function isDirectivePrologueElement(node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + var expression = expressionStatement.expression; + + if (expression.kind() === 14 /* StringLiteral */) { + return true; + } + } + + return false; + } + SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; + + function isUseStrictDirective(node) { + var expressionStatement = node; + var stringLiteral = expressionStatement.expression; + + var text = stringLiteral.text(); + return text === '"use strict"' || text === "'use strict'"; + } + SyntaxFacts.isUseStrictDirective = isUseStrictDirective; + + function isIdentifierNameOrAnyKeyword(token) { + var tokenKind = token.tokenKind; + return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); + } + SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; + })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); + var SyntaxFacts = TypeScript.SyntaxFacts; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var EmptySyntaxList = (function () { + function EmptySyntaxList() { + } + EmptySyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + EmptySyntaxList.prototype.isNode = function () { + return false; + }; + EmptySyntaxList.prototype.isToken = function () { + return false; + }; + EmptySyntaxList.prototype.isList = function () { + return true; + }; + EmptySyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + EmptySyntaxList.prototype.toJSON = function (key) { + return []; + }; + + EmptySyntaxList.prototype.childCount = function () { + return 0; + }; + + EmptySyntaxList.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptySyntaxList.prototype.toArray = function () { + return []; + }; + + EmptySyntaxList.prototype.collectTextElements = function (elements) { + }; + + EmptySyntaxList.prototype.firstToken = function () { + return null; + }; + + EmptySyntaxList.prototype.lastToken = function () { + return null; + }; + + EmptySyntaxList.prototype.fullWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.width = function () { + return 0; + }; + + EmptySyntaxList.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + EmptySyntaxList.prototype.leadingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.trailingTriviaWidth = function () { + return 0; + }; + + EmptySyntaxList.prototype.fullText = function () { + return ""; + }; + + EmptySyntaxList.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptySyntaxList.prototype.isIncrementallyUnusable = function () { + return false; + }; + + EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + throw TypeScript.Errors.invalidOperation(); + }; + + EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { + }; + return EmptySyntaxList; + })(); + Syntax.EmptySyntaxList = EmptySyntaxList; + + Syntax.emptyList = new EmptySyntaxList(); + + var SingletonSyntaxList = (function () { + function SingletonSyntaxList(item) { + this.item = item; + } + SingletonSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + SingletonSyntaxList.prototype.isToken = function () { + return false; + }; + SingletonSyntaxList.prototype.isNode = function () { + return false; + }; + SingletonSyntaxList.prototype.isList = function () { + return true; + }; + SingletonSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + SingletonSyntaxList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxList.prototype.childCount = function () { + return 1; + }; + + SingletonSyntaxList.prototype.childAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxList.prototype.firstToken = function () { + return this.item.firstToken(); + }; + + SingletonSyntaxList.prototype.lastToken = function () { + return this.item.lastToken(); + }; + + SingletonSyntaxList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxList.prototype.width = function () { + return this.item.width(); + }; + + SingletonSyntaxList.prototype.leadingTrivia = function () { + return this.item.leadingTrivia(); + }; + + SingletonSyntaxList.prototype.trailingTrivia = function () { + return this.item.trailingTrivia(); + }; + + SingletonSyntaxList.prototype.leadingTriviaWidth = function () { + return this.item.leadingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.trailingTriviaWidth = function () { + return this.item.trailingTriviaWidth(); + }; + + SingletonSyntaxList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { + return this.item.isTypeScriptSpecific(); + }; + + SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { + return this.item.isIncrementallyUnusable(); + }; + + SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); + }; + + SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { + array.splice(index, 0, this.item); + }; + return SingletonSyntaxList; + })(); + + var NormalSyntaxList = (function () { + function NormalSyntaxList(nodeOrTokens) { + this._data = 0; + this.nodeOrTokens = nodeOrTokens; + } + NormalSyntaxList.prototype.kind = function () { + return 1 /* List */; + }; + + NormalSyntaxList.prototype.isNode = function () { + return false; + }; + NormalSyntaxList.prototype.isToken = function () { + return false; + }; + NormalSyntaxList.prototype.isList = function () { + return true; + }; + NormalSyntaxList.prototype.isSeparatedList = function () { + return false; + }; + + NormalSyntaxList.prototype.toJSON = function (key) { + return this.nodeOrTokens; + }; + + NormalSyntaxList.prototype.childCount = function () { + return this.nodeOrTokens.length; + }; + + NormalSyntaxList.prototype.childAt = function (index) { + if (index < 0 || index >= this.nodeOrTokens.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.nodeOrTokens[index]; + }; + + NormalSyntaxList.prototype.toArray = function () { + return this.nodeOrTokens.slice(0); + }; + + NormalSyntaxList.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var element = this.nodeOrTokens[i]; + element.collectTextElements(elements); + } + }; + + NormalSyntaxList.prototype.firstToken = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var token = this.nodeOrTokens[i].firstToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.lastToken = function () { + for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { + var token = this.nodeOrTokens[i].lastToken(); + if (token !== null) { + return token; + } + } + + return null; + }; + + NormalSyntaxList.prototype.fullText = function () { + var elements = new Array(); + this.collectTextElements(elements); + return elements.join(""); + }; + + NormalSyntaxList.prototype.isTypeScriptSpecific = function () { + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + if (this.nodeOrTokens[i].isTypeScriptSpecific()) { + return true; + } + } + + return false; + }; + + NormalSyntaxList.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + NormalSyntaxList.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + NormalSyntaxList.prototype.width = function () { + var fullWidth = this.fullWidth(); + return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.leadingTrivia = function () { + return this.firstToken().leadingTrivia(); + }; + + NormalSyntaxList.prototype.trailingTrivia = function () { + return this.lastToken().trailingTrivia(); + }; + + NormalSyntaxList.prototype.leadingTriviaWidth = function () { + return this.firstToken().leadingTriviaWidth(); + }; + + NormalSyntaxList.prototype.trailingTriviaWidth = function () { + return this.lastToken().trailingTriviaWidth(); + }; + + NormalSyntaxList.prototype.computeData = function () { + var fullWidth = 0; + var isIncrementallyUnusable = false; + + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var node = this.nodeOrTokens[i]; + fullWidth += node.fullWidth(); + isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + NormalSyntaxList.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data = this.computeData(); + } + + return this._data; + }; + + NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedList(parent, this, fullStart); + for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { + var nodeOrToken = this.nodeOrTokens[i]; + + var childWidth = nodeOrToken.fullWidth(); + if (position < childWidth) { + return nodeOrToken.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { + if (index === 0) { + array.unshift.apply(array, this.nodeOrTokens); + } else { + array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); + } + }; + return NormalSyntaxList; + })(); + + function list(nodes) { + if (nodes === undefined || nodes === null || nodes.length === 0) { + return Syntax.emptyList; + } + + if (nodes.length === 1) { + var item = nodes[0]; + return new SingletonSyntaxList(item); + } + + return new NormalSyntaxList(nodes); + } + Syntax.list = list; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNode = (function () { + function SyntaxNode(parsedInStrictMode) { + this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; + } + SyntaxNode.prototype.isNode = function () { + return true; + }; + SyntaxNode.prototype.isToken = function () { + return false; + }; + SyntaxNode.prototype.isList = function () { + return false; + }; + SyntaxNode.prototype.isSeparatedList = function () { + return false; + }; + + SyntaxNode.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childCount = function () { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.childAt = function (slot) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.firstToken = function () { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.firstToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.lastToken = function () { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { + return element.lastToken(); + } + } + } + + return null; + }; + + SyntaxNode.prototype.insertChildrenInto = function (array, index) { + for (var i = this.childCount() - 1; i >= 0; i--) { + var element = this.childAt(i); + + if (element !== null) { + if (element.isNode() || element.isToken()) { + array.splice(index, 0, element); + } else if (element.isList()) { + element.insertChildrenInto(array, index); + } else if (element.isSeparatedList()) { + element.insertChildrenInto(array, index); + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + } + }; + + SyntaxNode.prototype.leadingTrivia = function () { + var firstToken = this.firstToken(); + return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.trailingTrivia = function () { + var lastToken = this.lastToken(); + return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; + }; + + SyntaxNode.prototype.toJSON = function (key) { + var result = { + kind: TypeScript.SyntaxKind[this.kind()], + fullWidth: this.fullWidth() + }; + + if (this.isIncrementallyUnusable()) { + result.isIncrementallyUnusable = true; + } + + if (this.parsedInStrictMode()) { + 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 === thisAsIndexable[name]) { + result[name] = value; + break; + } + } + } + } + + return result; + }; + + SyntaxNode.prototype.accept = function (visitor) { + throw TypeScript.Errors.abstract(); + }; + + SyntaxNode.prototype.fullText = function () { + var elements = []; + this.collectTextElements(elements); + return elements.join(""); + }; + + SyntaxNode.prototype.collectTextElements = function (elements) { + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + element.collectTextElements(elements); + } + } + }; + + SyntaxNode.prototype.replaceToken = function (token1, token2) { + if (token1 === token2) { + return this; + } + + return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); + }; + + SyntaxNode.prototype.withLeadingTrivia = function (trivia) { + return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); + }; + + SyntaxNode.prototype.withTrailingTrivia = function (trivia) { + return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); + }; + + SyntaxNode.prototype.hasLeadingTrivia = function () { + return this.lastToken().hasLeadingTrivia(); + }; + + SyntaxNode.prototype.hasTrailingTrivia = function () { + return this.lastToken().hasTrailingTrivia(); + }; + + SyntaxNode.prototype.isTypeScriptSpecific = function () { + return false; + }; + + SyntaxNode.prototype.isIncrementallyUnusable = function () { + return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; + }; + + SyntaxNode.prototype.parsedInStrictMode = function () { + return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; + }; + + SyntaxNode.prototype.fullWidth = function () { + return this.data() >>> 3 /* NodeFullWidthShift */; + }; + + SyntaxNode.prototype.computeData = function () { + var slotCount = this.childCount(); + + var fullWidth = 0; + var childWidth = 0; + + var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; + + for (var i = 0, n = slotCount; i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + childWidth = element.fullWidth(); + fullWidth += childWidth; + + if (!isIncrementallyUnusable) { + isIncrementallyUnusable = element.isIncrementallyUnusable(); + } + } + } + + return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; + }; + + SyntaxNode.prototype.data = function () { + if ((this._data & 1 /* NodeDataComputed */) === 0) { + this._data |= this.computeData(); + } + + return this._data; + }; + + SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var endOfFileToken = this.tryGetEndOfFileAt(position); + if (endOfFileToken !== null) { + return endOfFileToken; + } + + if (position < 0 || position >= this.fullWidth()) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + + var positionedToken = this.findTokenInternal(null, position, 0); + + if (includeSkippedTokens) { + return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + } + + return positionedToken; + }; + + SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { + if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { + var sourceUnit = this; + return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); + } + + return null; + }; + + SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { + parent = new TypeScript.PositionedNode(parent, this, fullStart); + for (var i = 0, n = this.childCount(); i < n; i++) { + var element = this.childAt(i); + + if (element !== null) { + var childWidth = element.fullWidth(); + + if (position < childWidth) { + return element.findTokenInternal(parent, position, fullStart); + } + + position -= childWidth; + fullStart += childWidth; + } + } + + throw TypeScript.Errors.invalidOperation(); + }; + + SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + var start = positionedToken.start(); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (position > start) { + return positionedToken; + } + + if (positionedToken.fullStart() === 0) { + return null; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { + if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } + var positionedToken = this.findToken(position, false); + + if (includeSkippedTokens) { + positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; + } + + if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { + return positionedToken; + } + + return positionedToken.previousToken(includeSkippedTokens); + }; + + SyntaxNode.prototype.isModuleElement = function () { + return false; + }; + + SyntaxNode.prototype.isClassElement = function () { + return false; + }; + + SyntaxNode.prototype.isTypeMember = function () { + return false; + }; + + SyntaxNode.prototype.isStatement = function () { + return false; + }; + + SyntaxNode.prototype.isExpression = function () { + return false; + }; + + SyntaxNode.prototype.isSwitchClause = function () { + return false; + }; + + SyntaxNode.prototype.structuralEquals = function (node) { + if (this === node) { + return true; + } + if (node === null) { + return false; + } + if (this.kind() !== node.kind()) { + return false; + } + + for (var i = 0, n = this.childCount(); i < n; i++) { + var element1 = this.childAt(i); + var element2 = node.childAt(i); + + if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { + return false; + } + } + + return true; + }; + + SyntaxNode.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + SyntaxNode.prototype.leadingTriviaWidth = function () { + var firstToken = this.firstToken(); + return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); + }; + + SyntaxNode.prototype.trailingTriviaWidth = function () { + var lastToken = this.lastToken(); + return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); + }; + return SyntaxNode; + })(); + TypeScript.SyntaxNode = SyntaxNode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceUnitSyntax = (function (_super) { + __extends(SourceUnitSyntax, _super); + function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleElements = moduleElements; + this.endOfFileToken = endOfFileToken; + } + SourceUnitSyntax.prototype.accept = function (visitor) { + return visitor.visitSourceUnit(this); + }; + + SourceUnitSyntax.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnitSyntax.prototype.childCount = function () { + return 2; + }; + + SourceUnitSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleElements; + case 1: + return this.endOfFileToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { + if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { + return this; + } + + return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); + }; + + SourceUnitSyntax.create = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.create1 = function (endOfFileToken) { + return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); + }; + + SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(moduleElements, this.endOfFileToken); + }; + + SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { + return this.update(this.moduleElements, endOfFileToken); + }; + + SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { + if (this.moduleElements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SourceUnitSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SourceUnitSyntax = SourceUnitSyntax; + + var ExternalModuleReferenceSyntax = (function (_super) { + __extends(ExternalModuleReferenceSyntax, _super); + function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.requireKeyword = requireKeyword; + this.openParenToken = openParenToken; + this.stringLiteral = stringLiteral; + this.closeParenToken = closeParenToken; + } + ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitExternalModuleReference(this); + }; + + ExternalModuleReferenceSyntax.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + + ExternalModuleReferenceSyntax.prototype.childCount = function () { + return 4; + }; + + ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.requireKeyword; + case 1: + return this.openParenToken; + case 2: + return this.stringLiteral; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { + return this; + } + + return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); + }; + + ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { + return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { + return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); + }; + + ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExternalModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; + + var ModuleNameModuleReferenceSyntax = (function (_super) { + __extends(ModuleNameModuleReferenceSyntax, _super); + function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.moduleName = moduleName; + } + ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleNameModuleReference(this); + }; + + ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + + ModuleNameModuleReferenceSyntax.prototype.childCount = function () { + return 1; + }; + + ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.moduleName; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { + return true; + }; + + ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { + if (this.moduleName === moduleName) { + return this; + } + + return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); + }; + + ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { + return this.update(moduleName); + }; + + ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleNameModuleReferenceSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; + + var ImportDeclarationSyntax = (function (_super) { + __extends(ImportDeclarationSyntax, _super); + function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.importKeyword = importKeyword; + this.identifier = identifier; + this.equalsToken = equalsToken; + this.moduleReference = moduleReference; + this.semicolonToken = semicolonToken; + } + ImportDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitImportDeclaration(this); + }; + + ImportDeclarationSyntax.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + ImportDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.importKeyword; + case 2: + return this.identifier; + case 3: + return this.equalsToken; + case 4: + return this.moduleReference; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ImportDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { + return this; + } + + return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); + }; + + ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); + }; + + ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { + return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { + return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); + }; + + ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); + }; + + ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ImportDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; + + var ExportAssignmentSyntax = (function (_super) { + __extends(ExportAssignmentSyntax, _super); + function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.exportKeyword = exportKeyword; + this.equalsToken = equalsToken; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ExportAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitExportAssignment(this); + }; + + ExportAssignmentSyntax.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignmentSyntax.prototype.childCount = function () { + return 4; + }; + + ExportAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.exportKeyword; + case 1: + return this.equalsToken; + case 2: + return this.identifier; + case 3: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExportAssignmentSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { + if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ExportAssignmentSyntax.create1 = function (identifier) { + return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { + return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); + }; + + ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); + }; + + ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ExportAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; + + var ClassDeclarationSyntax = (function (_super) { + __extends(ClassDeclarationSyntax, _super); + function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.classKeyword = classKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.openBraceToken = openBraceToken; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + } + ClassDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitClassDeclaration(this); + }; + + ClassDeclarationSyntax.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclarationSyntax.prototype.childCount = function () { + return 8; + }; + + ClassDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.classKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.openBraceToken; + case 6: + return this.classElements; + case 7: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ClassDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ClassDeclarationSyntax.create1 = function (identifier) { + return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { + return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { + return this.withClassElements(TypeScript.Syntax.list([classElement])); + }; + + ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); + }; + + ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ClassDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; + + var InterfaceDeclarationSyntax = (function (_super) { + __extends(InterfaceDeclarationSyntax, _super); + function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.interfaceKeyword = interfaceKeyword; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + } + InterfaceDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitInterfaceDeclaration(this); + }; + + InterfaceDeclarationSyntax.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + InterfaceDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.interfaceKeyword; + case 2: + return this.identifier; + case 3: + return this.typeParameterList; + case 4: + return this.heritageClauses; + case 5: + return this.body; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InterfaceDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { + return this; + } + + return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); + }; + + InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); + }; + + InterfaceDeclarationSyntax.create1 = function (identifier) { + return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); + }; + + InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { + return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); + }; + + InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { + return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); + }; + + InterfaceDeclarationSyntax.prototype.withBody = function (body) { + return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); + }; + + InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return InterfaceDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; + + var HeritageClauseSyntax = (function (_super) { + __extends(HeritageClauseSyntax, _super); + function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; + this.typeNames = typeNames; + + this._kind = kind; + } + HeritageClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitHeritageClause(this); + }; + + HeritageClauseSyntax.prototype.childCount = function () { + return 2; + }; + + HeritageClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsOrImplementsKeyword; + case 1: + return this.typeNames; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + HeritageClauseSyntax.prototype.kind = function () { + return this._kind; + }; + + HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { + if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { + return this; + } + + return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); + }; + + HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + HeritageClauseSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { + return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { + return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); + }; + + HeritageClauseSyntax.prototype.withTypeName = function (typeName) { + return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); + }; + + HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return HeritageClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; + + var ModuleDeclarationSyntax = (function (_super) { + __extends(ModuleDeclarationSyntax, _super); + function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.moduleKeyword = moduleKeyword; + this.name = name; + this.stringLiteral = stringLiteral; + this.openBraceToken = openBraceToken; + this.moduleElements = moduleElements; + this.closeBraceToken = closeBraceToken; + } + ModuleDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitModuleDeclaration(this); + }; + + ModuleDeclarationSyntax.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclarationSyntax.prototype.childCount = function () { + return 7; + }; + + ModuleDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.moduleKeyword; + case 2: + return this.name; + case 3: + return this.stringLiteral; + case 4: + return this.openBraceToken; + case 5: + return this.moduleElements; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ModuleDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); + }; + + ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + ModuleDeclarationSyntax.create1 = function () { + return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { + return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withName = function (name) { + return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { + return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { + return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); + }; + + ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); + }; + + ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ModuleDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; + + var FunctionDeclarationSyntax = (function (_super) { + __extends(FunctionDeclarationSyntax, _super); + function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + FunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionDeclaration(this); + }; + + FunctionDeclarationSyntax.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + FunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.functionKeyword; + case 2: + return this.identifier; + case 3: + return this.callSignature; + case 4: + return this.block; + case 5: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionDeclarationSyntax.prototype.isStatement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); + }; + + FunctionDeclarationSyntax.create1 = function (identifier) { + return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); + }; + + FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); + }; + + FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block !== null && this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; + + var VariableStatementSyntax = (function (_super) { + __extends(VariableStatementSyntax, _super); + function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclaration = variableDeclaration; + this.semicolonToken = semicolonToken; + } + VariableStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableStatement(this); + }; + + VariableStatementSyntax.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatementSyntax.prototype.childCount = function () { + return 3; + }; + + VariableStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclaration; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableStatementSyntax.prototype.isStatement = function () { + return true; + }; + + VariableStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { + return this; + } + + return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); + }; + + VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); + }; + + VariableStatementSyntax.create1 = function (variableDeclaration) { + return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableStatementSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.modifiers, variableDeclaration, this.semicolonToken); + }; + + VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclaration, semicolonToken); + }; + + VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableStatementSyntax = VariableStatementSyntax; + + var VariableDeclarationSyntax = (function (_super) { + __extends(VariableDeclarationSyntax, _super); + function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.varKeyword = varKeyword; + this.variableDeclarators = variableDeclarators; + } + VariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclaration(this); + }; + + VariableDeclarationSyntax.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclarationSyntax.prototype.childCount = function () { + return 2; + }; + + VariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.varKeyword; + case 1: + return this.variableDeclarators; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { + if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { + return this; + } + + return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); + }; + + VariableDeclarationSyntax.create1 = function (variableDeclarators) { + return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); + }; + + VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { + return this.update(varKeyword, this.variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { + return this.update(this.varKeyword, variableDeclarators); + }; + + VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); + }; + + VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclarators.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; + + var VariableDeclaratorSyntax = (function (_super) { + __extends(VariableDeclaratorSyntax, _super); + function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + VariableDeclaratorSyntax.prototype.accept = function (visitor) { + return visitor.visitVariableDeclarator(this); + }; + + VariableDeclaratorSyntax.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + + VariableDeclaratorSyntax.prototype.childCount = function () { + return 3; + }; + + VariableDeclaratorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.typeAnnotation; + case 2: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { + if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + VariableDeclaratorSyntax.create = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.create1 = function (propertyName) { + return new VariableDeclaratorSyntax(propertyName, null, null, false); + }; + + VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); + }; + + VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VariableDeclaratorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; + + var EqualsValueClauseSyntax = (function (_super) { + __extends(EqualsValueClauseSyntax, _super); + function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.equalsToken = equalsToken; + this.value = value; + } + EqualsValueClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitEqualsValueClause(this); + }; + + EqualsValueClauseSyntax.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + + EqualsValueClauseSyntax.prototype.childCount = function () { + return 2; + }; + + EqualsValueClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.equalsToken; + case 1: + return this.value; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { + if (this.equalsToken === equalsToken && this.value === value) { + return this; + } + + return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); + }; + + EqualsValueClauseSyntax.create1 = function (value) { + return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); + }; + + EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { + return this.update(equalsToken, this.value); + }; + + EqualsValueClauseSyntax.prototype.withValue = function (value) { + return this.update(this.equalsToken, value); + }; + + EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.value.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EqualsValueClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; + + var PrefixUnaryExpressionSyntax = (function (_super) { + __extends(PrefixUnaryExpressionSyntax, _super); + function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operatorToken = operatorToken; + this.operand = operand; + + this._kind = kind; + } + PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPrefixUnaryExpression(this); + }; + + PrefixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operatorToken; + case 1: + return this.operand; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PrefixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { + if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { + return this; + } + + return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); + }; + + PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, operatorToken, this.operand); + }; + + PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, this.operatorToken, operand); + }; + + PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PrefixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; + + var ArrayLiteralExpressionSyntax = (function (_super) { + __extends(ArrayLiteralExpressionSyntax, _super); + function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.expressions = expressions; + this.closeBracketToken = closeBracketToken; + } + ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayLiteralExpression(this); + }; + + ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + ArrayLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.expressions; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { + if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { + return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); + }; + + ArrayLiteralExpressionSyntax.create1 = function () { + return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { + return this.update(this.openBracketToken, expressions, this.closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { + return this.withExpressions(TypeScript.Syntax.separatedList([expression])); + }; + + ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.expressions, closeBracketToken); + }; + + ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expressions.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArrayLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; + + var OmittedExpressionSyntax = (function (_super) { + __extends(OmittedExpressionSyntax, _super); + function OmittedExpressionSyntax(parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + } + OmittedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitOmittedExpression(this); + }; + + OmittedExpressionSyntax.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + OmittedExpressionSyntax.prototype.childCount = function () { + return 0; + }; + + OmittedExpressionSyntax.prototype.childAt = function (slot) { + throw TypeScript.Errors.invalidOperation(); + }; + + OmittedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + OmittedExpressionSyntax.prototype.update = function () { + return this; + }; + + OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return OmittedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; + + var ParenthesizedExpressionSyntax = (function (_super) { + __extends(ParenthesizedExpressionSyntax, _super); + function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + } + ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedExpression(this); + }; + + ParenthesizedExpressionSyntax.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + ParenthesizedExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.expression; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { + if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); + }; + + ParenthesizedExpressionSyntax.create1 = function (expression) { + return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.openParenToken, expression, this.closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.expression, closeParenToken); + }; + + ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParenthesizedExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; + + var SimpleArrowFunctionExpressionSyntax = (function (_super) { + __extends(SimpleArrowFunctionExpressionSyntax, _super); + function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitSimpleArrowFunctionExpression(this); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { + if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { + return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { + return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); + }; + + SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SimpleArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; + + var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { + __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); + function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.callSignature = callSignature; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.block = block; + this.expression = expression; + } + ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitParenthesizedArrowFunctionExpression(this); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.callSignature; + case 1: + return this.equalsGreaterThanToken; + case 2: + return this.block; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { + if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { + return this; + } + + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { + return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { + return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); + }; + + ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ParenthesizedArrowFunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; + + var QualifiedNameSyntax = (function (_super) { + __extends(QualifiedNameSyntax, _super); + function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.dotToken = dotToken; + this.right = right; + } + QualifiedNameSyntax.prototype.accept = function (visitor) { + return visitor.visitQualifiedName(this); + }; + + QualifiedNameSyntax.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedNameSyntax.prototype.childCount = function () { + return 3; + }; + + QualifiedNameSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.dotToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + QualifiedNameSyntax.prototype.isName = function () { + return true; + }; + + QualifiedNameSyntax.prototype.isType = function () { + return true; + }; + + QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { + if (this.left === left && this.dotToken === dotToken && this.right === right) { + return this; + } + + return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); + }; + + QualifiedNameSyntax.create1 = function (left, right) { + return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); + }; + + QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + QualifiedNameSyntax.prototype.withLeft = function (left) { + return this.update(left, this.dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.left, dotToken, this.right); + }; + + QualifiedNameSyntax.prototype.withRight = function (right) { + return this.update(this.left, this.dotToken, right); + }; + + QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return QualifiedNameSyntax; + })(TypeScript.SyntaxNode); + TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; + + var TypeArgumentListSyntax = (function (_super) { + __extends(TypeArgumentListSyntax, _super); + function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeArguments = typeArguments; + this.greaterThanToken = greaterThanToken; + } + TypeArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeArgumentList(this); + }; + + TypeArgumentListSyntax.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + + TypeArgumentListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeArguments; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeArgumentListSyntax.create1 = function () { + return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { + return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { + return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); + }; + + TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); + }; + + TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; + + var ConstructorTypeSyntax = (function (_super) { + __extends(ConstructorTypeSyntax, _super); + function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + ConstructorTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorType(this); + }; + + ConstructorTypeSyntax.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + + ConstructorTypeSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.typeParameterList; + case 2: + return this.parameterList; + case 3: + return this.equalsGreaterThanToken; + case 4: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorTypeSyntax.prototype.isType = function () { + return true; + }; + + ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { + return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); + }; + + ConstructorTypeSyntax.create1 = function (type) { + return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + ConstructorTypeSyntax.prototype.withType = function (type) { + return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; + + var FunctionTypeSyntax = (function (_super) { + __extends(FunctionTypeSyntax, _super); + function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.equalsGreaterThanToken = equalsGreaterThanToken; + this.type = type; + } + FunctionTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionType(this); + }; + + FunctionTypeSyntax.prototype.kind = function () { + return 123 /* FunctionType */; + }; + + FunctionTypeSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.equalsGreaterThanToken; + case 3: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionTypeSyntax.prototype.isType = function () { + return true; + }; + + FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { + return this; + } + + return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); + }; + + FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { + return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); + }; + + FunctionTypeSyntax.create1 = function (type) { + return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); + }; + + FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { + return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); + }; + + FunctionTypeSyntax.prototype.withType = function (type) { + return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); + }; + + FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return FunctionTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; + + var ObjectTypeSyntax = (function (_super) { + __extends(ObjectTypeSyntax, _super); + function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.typeMembers = typeMembers; + this.closeBraceToken = closeBraceToken; + } + ObjectTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectType(this); + }; + + ObjectTypeSyntax.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.typeMembers; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectTypeSyntax.prototype.isType = function () { + return true; + }; + + ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectTypeSyntax.create1 = function () { + return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { + return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); + }; + + ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { + return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); + }; + + ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); + }; + + ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ObjectTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; + + var ArrayTypeSyntax = (function (_super) { + __extends(ArrayTypeSyntax, _super); + function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.type = type; + this.openBracketToken = openBracketToken; + this.closeBracketToken = closeBracketToken; + } + ArrayTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitArrayType(this); + }; + + ArrayTypeSyntax.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayTypeSyntax.prototype.childCount = function () { + return 3; + }; + + ArrayTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.type; + case 1: + return this.openBracketToken; + case 2: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArrayTypeSyntax.prototype.isType = function () { + return true; + }; + + ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { + if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); + }; + + ArrayTypeSyntax.create1 = function (type) { + return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArrayTypeSyntax.prototype.withType = function (type) { + return this.update(type, this.openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.type, openBracketToken, this.closeBracketToken); + }; + + ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.type, this.openBracketToken, closeBracketToken); + }; + + ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ArrayTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; + + var GenericTypeSyntax = (function (_super) { + __extends(GenericTypeSyntax, _super); + function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.name = name; + this.typeArgumentList = typeArgumentList; + } + GenericTypeSyntax.prototype.accept = function (visitor) { + return visitor.visitGenericType(this); + }; + + GenericTypeSyntax.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericTypeSyntax.prototype.childCount = function () { + return 2; + }; + + GenericTypeSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.name; + case 1: + return this.typeArgumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GenericTypeSyntax.prototype.isType = function () { + return true; + }; + + GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { + if (this.name === name && this.typeArgumentList === typeArgumentList) { + return this; + } + + return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); + }; + + GenericTypeSyntax.create1 = function (name) { + return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); + }; + + GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GenericTypeSyntax.prototype.withName = function (name) { + return this.update(name, this.typeArgumentList); + }; + + GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(this.name, typeArgumentList); + }; + + GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return GenericTypeSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GenericTypeSyntax = GenericTypeSyntax; + + var TypeQuerySyntax = (function (_super) { + __extends(TypeQuerySyntax, _super); + function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.name = name; + } + TypeQuerySyntax.prototype.accept = function (visitor) { + return visitor.visitTypeQuery(this); + }; + + TypeQuerySyntax.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuerySyntax.prototype.childCount = function () { + return 2; + }; + + TypeQuerySyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeQuerySyntax.prototype.isType = function () { + return true; + }; + + TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { + if (this.typeOfKeyword === typeOfKeyword && this.name === name) { + return this; + } + + return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); + }; + + TypeQuerySyntax.create1 = function (name) { + return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); + }; + + TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.name); + }; + + TypeQuerySyntax.prototype.withName = function (name) { + return this.update(this.typeOfKeyword, name); + }; + + TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeQuerySyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeQuerySyntax = TypeQuerySyntax; + + var TypeAnnotationSyntax = (function (_super) { + __extends(TypeAnnotationSyntax, _super); + function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.colonToken = colonToken; + this.type = type; + } + TypeAnnotationSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeAnnotation(this); + }; + + TypeAnnotationSyntax.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + + TypeAnnotationSyntax.prototype.childCount = function () { + return 2; + }; + + TypeAnnotationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.colonToken; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeAnnotationSyntax.prototype.update = function (colonToken, type) { + if (this.colonToken === colonToken && this.type === type) { + return this; + } + + return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); + }; + + TypeAnnotationSyntax.create1 = function (type) { + return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); + }; + + TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { + return this.update(colonToken, this.type); + }; + + TypeAnnotationSyntax.prototype.withType = function (type) { + return this.update(this.colonToken, type); + }; + + TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeAnnotationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; + + var BlockSyntax = (function (_super) { + __extends(BlockSyntax, _super); + function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.statements = statements; + this.closeBraceToken = closeBraceToken; + } + BlockSyntax.prototype.accept = function (visitor) { + return visitor.visitBlock(this); + }; + + BlockSyntax.prototype.kind = function () { + return 146 /* Block */; + }; + + BlockSyntax.prototype.childCount = function () { + return 3; + }; + + BlockSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.statements; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BlockSyntax.prototype.isStatement = function () { + return true; + }; + + BlockSyntax.prototype.isModuleElement = function () { + return true; + }; + + BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); + }; + + BlockSyntax.create = function (openBraceToken, closeBraceToken) { + return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + BlockSyntax.create1 = function () { + return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + BlockSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatements = function (statements) { + return this.update(this.openBraceToken, statements, this.closeBraceToken); + }; + + BlockSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.statements, closeBraceToken); + }; + + BlockSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BlockSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BlockSyntax = BlockSyntax; + + var ParameterSyntax = (function (_super) { + __extends(ParameterSyntax, _super); + function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + } + ParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitParameter(this); + }; + + ParameterSyntax.prototype.kind = function () { + return 242 /* Parameter */; + }; + + ParameterSyntax.prototype.childCount = function () { + return 6; + }; + + ParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.dotDotDotToken; + case 1: + return this.modifiers; + case 2: + return this.identifier; + case 3: + return this.questionToken; + case 4: + return this.typeAnnotation; + case 5: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); + }; + + ParameterSyntax.create = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.create1 = function (identifier) { + return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); + }; + + ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { + return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifiers = function (modifiers) { + return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); + }; + + ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); + }; + + ParameterSyntax.prototype.isTypeScriptSpecific = function () { + if (this.dotDotDotToken !== null) { + return true; + } + if (this.modifiers.isTypeScriptSpecific()) { + return true; + } + if (this.questionToken !== null) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.equalsValueClause !== null) { + return true; + } + return false; + }; + return ParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterSyntax = ParameterSyntax; + + var MemberAccessExpressionSyntax = (function (_super) { + __extends(MemberAccessExpressionSyntax, _super); + function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.dotToken = dotToken; + this.name = name; + } + MemberAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberAccessExpression(this); + }; + + MemberAccessExpressionSyntax.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + MemberAccessExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + MemberAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.dotToken; + case 2: + return this.name; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { + if (this.expression === expression && this.dotToken === dotToken && this.name === name) { + return this; + } + + return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); + }; + + MemberAccessExpressionSyntax.create1 = function (expression, name) { + return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); + }; + + MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { + return this.update(this.expression, dotToken, this.name); + }; + + MemberAccessExpressionSyntax.prototype.withName = function (name) { + return this.update(this.expression, this.dotToken, name); + }; + + MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MemberAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; + + var PostfixUnaryExpressionSyntax = (function (_super) { + __extends(PostfixUnaryExpressionSyntax, _super); + function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.operand = operand; + this.operatorToken = operatorToken; + + this._kind = kind; + } + PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitPostfixUnaryExpression(this); + }; + + PostfixUnaryExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.operand; + case 1: + return this.operatorToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + PostfixUnaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { + if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { + return this; + } + + return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); + }; + + PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { + return this.update(this._kind, operand, this.operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.operand, operatorToken); + }; + + PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.operand.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return PostfixUnaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; + + var ElementAccessExpressionSyntax = (function (_super) { + __extends(ElementAccessExpressionSyntax, _super); + function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.openBracketToken = openBracketToken; + this.argumentExpression = argumentExpression; + this.closeBracketToken = closeBracketToken; + } + ElementAccessExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitElementAccessExpression(this); + }; + + ElementAccessExpressionSyntax.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + ElementAccessExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + ElementAccessExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.openBracketToken; + case 2: + return this.argumentExpression; + case 3: + return this.closeBracketToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { + if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { + return this; + } + + return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); + }; + + ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { + return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); + }; + + ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { + return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); + }; + + ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentExpression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElementAccessExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; + + var InvocationExpressionSyntax = (function (_super) { + __extends(InvocationExpressionSyntax, _super); + function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.argumentList = argumentList; + } + InvocationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitInvocationExpression(this); + }; + + InvocationExpressionSyntax.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + InvocationExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + InvocationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + InvocationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { + if (this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); + }; + + InvocationExpressionSyntax.create1 = function (expression) { + return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); + }; + + InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + InvocationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.argumentList); + }; + + InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.expression, argumentList); + }; + + InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return InvocationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; + + var ArgumentListSyntax = (function (_super) { + __extends(ArgumentListSyntax, _super); + function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeArgumentList = typeArgumentList; + this.openParenToken = openParenToken; + this.closeParenToken = closeParenToken; + + this.arguments = _arguments; + } + ArgumentListSyntax.prototype.accept = function (visitor) { + return visitor.visitArgumentList(this); + }; + + ArgumentListSyntax.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + + ArgumentListSyntax.prototype.childCount = function () { + return 4; + }; + + ArgumentListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeArgumentList; + case 1: + return this.openParenToken; + case 2: + return this.arguments; + case 3: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { + return this; + } + + return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); + }; + + ArgumentListSyntax.create = function (openParenToken, closeParenToken) { + return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ArgumentListSyntax.create1 = function () { + return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { + return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArguments = function (_arguments) { + return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); + }; + + ArgumentListSyntax.prototype.withArgument = function (_argument) { + return this.withArguments(TypeScript.Syntax.separatedList([_argument])); + }; + + ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); + }; + + ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { + return true; + } + if (this.arguments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ArgumentListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ArgumentListSyntax = ArgumentListSyntax; + + var BinaryExpressionSyntax = (function (_super) { + __extends(BinaryExpressionSyntax, _super); + function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.left = left; + this.operatorToken = operatorToken; + this.right = right; + + this._kind = kind; + } + BinaryExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitBinaryExpression(this); + }; + + BinaryExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + BinaryExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.left; + case 1: + return this.operatorToken; + case 2: + return this.right; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BinaryExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + BinaryExpressionSyntax.prototype.kind = function () { + return this._kind; + }; + + BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { + if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { + return this; + } + + return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); + }; + + BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BinaryExpressionSyntax.prototype.withKind = function (kind) { + return this.update(kind, this.left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withLeft = function (left) { + return this.update(this._kind, left, this.operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { + return this.update(this._kind, this.left, operatorToken, this.right); + }; + + BinaryExpressionSyntax.prototype.withRight = function (right) { + return this.update(this._kind, this.left, this.operatorToken, right); + }; + + BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.left.isTypeScriptSpecific()) { + return true; + } + if (this.right.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return BinaryExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; + + var ConditionalExpressionSyntax = (function (_super) { + __extends(ConditionalExpressionSyntax, _super); + function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.condition = condition; + this.questionToken = questionToken; + this.whenTrue = whenTrue; + this.colonToken = colonToken; + this.whenFalse = whenFalse; + } + ConditionalExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitConditionalExpression(this); + }; + + ConditionalExpressionSyntax.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + ConditionalExpressionSyntax.prototype.childCount = function () { + return 5; + }; + + ConditionalExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.condition; + case 1: + return this.questionToken; + case 2: + return this.whenTrue; + case 3: + return this.colonToken; + case 4: + return this.whenFalse; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConditionalExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { + if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { + return this; + } + + return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); + }; + + ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { + return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); + }; + + ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConditionalExpressionSyntax.prototype.withCondition = function (condition) { + return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { + return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); + }; + + ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { + return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); + }; + + ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.whenTrue.isTypeScriptSpecific()) { + return true; + } + if (this.whenFalse.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ConditionalExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; + + var ConstructSignatureSyntax = (function (_super) { + __extends(ConstructSignatureSyntax, _super); + function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.callSignature = callSignature; + } + ConstructSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructSignature(this); + }; + + ConstructSignatureSyntax.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + + ConstructSignatureSyntax.prototype.childCount = function () { + return 2; + }; + + ConstructSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { + if (this.newKeyword === newKeyword && this.callSignature === callSignature) { + return this; + } + + return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); + }; + + ConstructSignatureSyntax.create1 = function () { + return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); + }; + + ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.callSignature); + }; + + ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.newKeyword, callSignature); + }; + + ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; + + var MethodSignatureSyntax = (function (_super) { + __extends(MethodSignatureSyntax, _super); + function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + } + MethodSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitMethodSignature(this); + }; + + MethodSignatureSyntax.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + + MethodSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + MethodSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.callSignature; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MethodSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { + return this; + } + + return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); + }; + + MethodSignatureSyntax.create = function (propertyName, callSignature) { + return new MethodSignatureSyntax(propertyName, null, callSignature, false); + }; + + MethodSignatureSyntax.create1 = function (propertyName) { + return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); + }; + + MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.callSignature); + }; + + MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, this.questionToken, callSignature); + }; + + MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return MethodSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; + + var IndexSignatureSyntax = (function (_super) { + __extends(IndexSignatureSyntax, _super); + function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBracketToken = openBracketToken; + this.parameter = parameter; + this.closeBracketToken = closeBracketToken; + this.typeAnnotation = typeAnnotation; + } + IndexSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexSignature(this); + }; + + IndexSignatureSyntax.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + + IndexSignatureSyntax.prototype.childCount = function () { + return 4; + }; + + IndexSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBracketToken; + case 1: + return this.parameter; + case 2: + return this.closeBracketToken; + case 3: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { + if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); + }; + + IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { + return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); + }; + + IndexSignatureSyntax.create1 = function (parameter) { + return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); + }; + + IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { + return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withParameter = function (parameter) { + return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { + return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); + }; + + IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); + }; + + IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; + + var PropertySignatureSyntax = (function (_super) { + __extends(PropertySignatureSyntax, _super); + function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + } + PropertySignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitPropertySignature(this); + }; + + PropertySignatureSyntax.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + + PropertySignatureSyntax.prototype.childCount = function () { + return 3; + }; + + PropertySignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.questionToken; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + PropertySignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { + if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); + }; + + PropertySignatureSyntax.create = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.create1 = function (propertyName) { + return new PropertySignatureSyntax(propertyName, null, null, false); + }; + + PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { + return this.update(this.propertyName, questionToken, this.typeAnnotation); + }; + + PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.propertyName, this.questionToken, typeAnnotation); + }; + + PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return PropertySignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; + + var CallSignatureSyntax = (function (_super) { + __extends(CallSignatureSyntax, _super); + function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + } + CallSignatureSyntax.prototype.accept = function (visitor) { + return visitor.visitCallSignature(this); + }; + + CallSignatureSyntax.prototype.kind = function () { + return 142 /* CallSignature */; + }; + + CallSignatureSyntax.prototype.childCount = function () { + return 3; + }; + + CallSignatureSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeParameterList; + case 1: + return this.parameterList; + case 2: + return this.typeAnnotation; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CallSignatureSyntax.prototype.isTypeMember = function () { + return true; + }; + + CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { + if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { + return this; + } + + return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); + }; + + CallSignatureSyntax.create = function (parameterList) { + return new CallSignatureSyntax(null, parameterList, null, false); + }; + + CallSignatureSyntax.create1 = function () { + return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); + }; + + CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { + return this.update(typeParameterList, this.parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.typeParameterList, parameterList, this.typeAnnotation); + }; + + CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.typeParameterList, this.parameterList, typeAnnotation); + }; + + CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeParameterList !== null) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + return false; + }; + return CallSignatureSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CallSignatureSyntax = CallSignatureSyntax; + + var ParameterListSyntax = (function (_super) { + __extends(ParameterListSyntax, _super); + function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openParenToken = openParenToken; + this.parameters = parameters; + this.closeParenToken = closeParenToken; + } + ParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitParameterList(this); + }; + + ParameterListSyntax.prototype.kind = function () { + return 227 /* ParameterList */; + }; + + ParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + ParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openParenToken; + case 1: + return this.parameters; + case 2: + return this.closeParenToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { + if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { + return this; + } + + return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); + }; + + ParameterListSyntax.create = function (openParenToken, closeParenToken) { + return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); + }; + + ParameterListSyntax.create1 = function () { + return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); + }; + + ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(openParenToken, this.parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameters = function (parameters) { + return this.update(this.openParenToken, parameters, this.closeParenToken); + }; + + ParameterListSyntax.prototype.withParameter = function (parameter) { + return this.withParameters(TypeScript.Syntax.separatedList([parameter])); + }; + + ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.openParenToken, this.parameters, closeParenToken); + }; + + ParameterListSyntax.prototype.isTypeScriptSpecific = function () { + if (this.parameters.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ParameterListSyntax = ParameterListSyntax; + + var TypeParameterListSyntax = (function (_super) { + __extends(TypeParameterListSyntax, _super); + function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.typeParameters = typeParameters; + this.greaterThanToken = greaterThanToken; + } + TypeParameterListSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameterList(this); + }; + + TypeParameterListSyntax.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + + TypeParameterListSyntax.prototype.childCount = function () { + return 3; + }; + + TypeParameterListSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.typeParameters; + case 2: + return this.greaterThanToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { + if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { + return this; + } + + return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); + }; + + TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { + return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); + }; + + TypeParameterListSyntax.create1 = function () { + return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); + }; + + TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { + return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); + }; + + TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { + return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); + }; + + TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); + }; + + TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterListSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; + + var TypeParameterSyntax = (function (_super) { + __extends(TypeParameterSyntax, _super); + function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.constraint = constraint; + } + TypeParameterSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeParameter(this); + }; + + TypeParameterSyntax.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameterSyntax.prototype.childCount = function () { + return 2; + }; + + TypeParameterSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.constraint; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeParameterSyntax.prototype.update = function (identifier, constraint) { + if (this.identifier === identifier && this.constraint === constraint) { + return this; + } + + return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); + }; + + TypeParameterSyntax.create = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.create1 = function (identifier) { + return new TypeParameterSyntax(identifier, null, false); + }; + + TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeParameterSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.constraint); + }; + + TypeParameterSyntax.prototype.withConstraint = function (constraint) { + return this.update(this.identifier, constraint); + }; + + TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return TypeParameterSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeParameterSyntax = TypeParameterSyntax; + + var ConstraintSyntax = (function (_super) { + __extends(ConstraintSyntax, _super); + function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.extendsKeyword = extendsKeyword; + this.type = type; + } + ConstraintSyntax.prototype.accept = function (visitor) { + return visitor.visitConstraint(this); + }; + + ConstraintSyntax.prototype.kind = function () { + return 239 /* Constraint */; + }; + + ConstraintSyntax.prototype.childCount = function () { + return 2; + }; + + ConstraintSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.extendsKeyword; + case 1: + return this.type; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstraintSyntax.prototype.update = function (extendsKeyword, type) { + if (this.extendsKeyword === extendsKeyword && this.type === type) { + return this; + } + + return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); + }; + + ConstraintSyntax.create1 = function (type) { + return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); + }; + + ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { + return this.update(extendsKeyword, this.type); + }; + + ConstraintSyntax.prototype.withType = function (type) { + return this.update(this.extendsKeyword, type); + }; + + ConstraintSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstraintSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstraintSyntax = ConstraintSyntax; + + var ElseClauseSyntax = (function (_super) { + __extends(ElseClauseSyntax, _super); + function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.elseKeyword = elseKeyword; + this.statement = statement; + } + ElseClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitElseClause(this); + }; + + ElseClauseSyntax.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClauseSyntax.prototype.childCount = function () { + return 2; + }; + + ElseClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.elseKeyword; + case 1: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { + if (this.elseKeyword === elseKeyword && this.statement === statement) { + return this; + } + + return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); + }; + + ElseClauseSyntax.create1 = function (statement) { + return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); + }; + + ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { + return this.update(elseKeyword, this.statement); + }; + + ElseClauseSyntax.prototype.withStatement = function (statement) { + return this.update(this.elseKeyword, statement); + }; + + ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ElseClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ElseClauseSyntax = ElseClauseSyntax; + + var IfStatementSyntax = (function (_super) { + __extends(IfStatementSyntax, _super); + function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.ifKeyword = ifKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + this.elseClause = elseClause; + } + IfStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitIfStatement(this); + }; + + IfStatementSyntax.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatementSyntax.prototype.childCount = function () { + return 6; + }; + + IfStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.ifKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + case 5: + return this.elseClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IfStatementSyntax.prototype.isStatement = function () { + return true; + }; + + IfStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { + return this; + } + + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); + }; + + IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { + return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); + }; + + IfStatementSyntax.create1 = function (condition, statement) { + return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); + }; + + IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { + return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); + }; + + IfStatementSyntax.prototype.withElseClause = function (elseClause) { + return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); + }; + + IfStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return IfStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IfStatementSyntax = IfStatementSyntax; + + var ExpressionStatementSyntax = (function (_super) { + __extends(ExpressionStatementSyntax, _super); + function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ExpressionStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitExpressionStatement(this); + }; + + ExpressionStatementSyntax.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatementSyntax.prototype.childCount = function () { + return 2; + }; + + ExpressionStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.expression; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ExpressionStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { + if (this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); + }; + + ExpressionStatementSyntax.create1 = function (expression) { + return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ExpressionStatementSyntax.prototype.withExpression = function (expression) { + return this.update(expression, this.semicolonToken); + }; + + ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.expression, semicolonToken); + }; + + ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ExpressionStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; + + var ConstructorDeclarationSyntax = (function (_super) { + __extends(ConstructorDeclarationSyntax, _super); + function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.constructorKeyword = constructorKeyword; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + ConstructorDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitConstructorDeclaration(this); + }; + + ConstructorDeclarationSyntax.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + + ConstructorDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + ConstructorDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.constructorKeyword; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ConstructorDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + 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 */), CallSignatureSyntax.create1(), null, null, false); + }; + + ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { + return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); + }; + + ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return ConstructorDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; + + var MemberFunctionDeclarationSyntax = (function (_super) { + __extends(MemberFunctionDeclarationSyntax, _super); + function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + this.semicolonToken = semicolonToken; + } + MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberFunctionDeclaration(this); + }; + + MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + + MemberFunctionDeclarationSyntax.prototype.childCount = function () { + return 5; + }; + + MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.propertyName; + case 2: + return this.callSignature; + case 3: + return this.block; + case 4: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { + if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); + }; + + MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); + }; + + MemberFunctionDeclarationSyntax.create1 = function (propertyName) { + return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); + }; + + MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); + }; + + MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberFunctionDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; + + var GetAccessorSyntax = (function (_super) { + __extends(GetAccessorSyntax, _super); + function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.getKeyword = getKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + } + GetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitGetAccessor(this); + }; + + GetAccessorSyntax.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + + GetAccessorSyntax.prototype.childCount = function () { + return 6; + }; + + GetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.getKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.typeAnnotation; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + GetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + GetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + GetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { + if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { + return this; + } + + return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); + }; + + GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); + }; + + GetAccessorSyntax.create1 = function (propertyName) { + return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); + }; + + GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + GetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { + return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); + }; + + GetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); + }; + + GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + if (this.modifiers.childCount() > 0) { + return true; + } + if (this.parameterList.isTypeScriptSpecific()) { + return true; + } + if (this.typeAnnotation !== null) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return GetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.GetAccessorSyntax = GetAccessorSyntax; + + var SetAccessorSyntax = (function (_super) { + __extends(SetAccessorSyntax, _super); + function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.setKeyword = setKeyword; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + } + SetAccessorSyntax.prototype.accept = function (visitor) { + return visitor.visitSetAccessor(this); + }; + + SetAccessorSyntax.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + + SetAccessorSyntax.prototype.childCount = function () { + return 5; + }; + + SetAccessorSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.setKeyword; + case 2: + return this.propertyName; + case 3: + return this.parameterList; + case 4: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SetAccessorSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + SetAccessorSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SetAccessorSyntax.prototype.isClassElement = function () { + return true; + }; + + SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { + if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { + return this; + } + + return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); + }; + + SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); + }; + + SetAccessorSyntax.create1 = function (propertyName) { + return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); + }; + + SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SetAccessorSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { + return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withParameterList = function (parameterList) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); + }; + + SetAccessorSyntax.prototype.withBlock = function (block) { + return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); + }; + + SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return SetAccessorSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SetAccessorSyntax = SetAccessorSyntax; + + var MemberVariableDeclarationSyntax = (function (_super) { + __extends(MemberVariableDeclarationSyntax, _super); + function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + this.semicolonToken = semicolonToken; + } + MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitMemberVariableDeclaration(this); + }; + + MemberVariableDeclarationSyntax.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + + MemberVariableDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.variableDeclarator; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { + if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { + return this; + } + + return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); + }; + + MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); + }; + + MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { + return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { + return this.update(this.modifiers, variableDeclarator, this.semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.variableDeclarator, semicolonToken); + }; + + MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return MemberVariableDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; + + var IndexMemberDeclarationSyntax = (function (_super) { + __extends(IndexMemberDeclarationSyntax, _super); + function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.indexSignature = indexSignature; + this.semicolonToken = semicolonToken; + } + IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitIndexMemberDeclaration(this); + }; + + IndexMemberDeclarationSyntax.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + + IndexMemberDeclarationSyntax.prototype.childCount = function () { + return 3; + }; + + IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.indexSignature; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + IndexMemberDeclarationSyntax.prototype.isClassElement = function () { + return true; + }; + + IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { + if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { + return this; + } + + return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); + }; + + IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); + }; + + IndexMemberDeclarationSyntax.create1 = function (indexSignature) { + return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { + return this.update(this.modifiers, indexSignature, this.semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.modifiers, this.indexSignature, semicolonToken); + }; + + IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return IndexMemberDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; + + var ThrowStatementSyntax = (function (_super) { + __extends(ThrowStatementSyntax, _super); + function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.throwKeyword = throwKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ThrowStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitThrowStatement(this); + }; + + ThrowStatementSyntax.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ThrowStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.throwKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ThrowStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { + if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ThrowStatementSyntax.create1 = function (expression) { + return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { + return this.update(throwKeyword, this.expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.throwKeyword, expression, this.semicolonToken); + }; + + ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.throwKeyword, this.expression, semicolonToken); + }; + + ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ThrowStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; + + var ReturnStatementSyntax = (function (_super) { + __extends(ReturnStatementSyntax, _super); + function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.returnKeyword = returnKeyword; + this.expression = expression; + this.semicolonToken = semicolonToken; + } + ReturnStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitReturnStatement(this); + }; + + ReturnStatementSyntax.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ReturnStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.returnKeyword; + case 1: + return this.expression; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ReturnStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { + if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { + return this; + } + + return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); + }; + + ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { + return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); + }; + + ReturnStatementSyntax.create1 = function () { + return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { + return this.update(returnKeyword, this.expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.returnKeyword, expression, this.semicolonToken); + }; + + ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.returnKeyword, this.expression, semicolonToken); + }; + + ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression !== null && this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ReturnStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; + + var ObjectCreationExpressionSyntax = (function (_super) { + __extends(ObjectCreationExpressionSyntax, _super); + function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.newKeyword = newKeyword; + this.expression = expression; + this.argumentList = argumentList; + } + ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectCreationExpression(this); + }; + + ObjectCreationExpressionSyntax.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + ObjectCreationExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.newKeyword; + case 1: + return this.expression; + case 2: + return this.argumentList; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { + if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { + return this; + } + + return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); + }; + + ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { + return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); + }; + + ObjectCreationExpressionSyntax.create1 = function (expression) { + return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); + }; + + ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { + return this.update(newKeyword, this.expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.newKeyword, expression, this.argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { + return this.update(this.newKeyword, this.expression, argumentList); + }; + + ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectCreationExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; + + var SwitchStatementSyntax = (function (_super) { + __extends(SwitchStatementSyntax, _super); + function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.switchKeyword = switchKeyword; + this.openParenToken = openParenToken; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.openBraceToken = openBraceToken; + this.switchClauses = switchClauses; + this.closeBraceToken = closeBraceToken; + } + SwitchStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitSwitchStatement(this); + }; + + SwitchStatementSyntax.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatementSyntax.prototype.childCount = function () { + return 7; + }; + + SwitchStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.switchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.expression; + case 3: + return this.closeParenToken; + case 4: + return this.openBraceToken; + case 5: + return this.switchClauses; + case 6: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SwitchStatementSyntax.prototype.isStatement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); + }; + + SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { + return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); + }; + + SwitchStatementSyntax.create1 = function (expression) { + return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { + return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); + }; + + SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { + return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); + }; + + SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); + }; + + SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.switchClauses.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SwitchStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; + + var CaseSwitchClauseSyntax = (function (_super) { + __extends(CaseSwitchClauseSyntax, _super); + function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.caseKeyword = caseKeyword; + this.expression = expression; + this.colonToken = colonToken; + this.statements = statements; + } + CaseSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCaseSwitchClause(this); + }; + + CaseSwitchClauseSyntax.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClauseSyntax.prototype.childCount = function () { + return 4; + }; + + CaseSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.caseKeyword; + case 1: + return this.expression; + case 2: + return this.colonToken; + case 3: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { + if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); + }; + + CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { + return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.create1 = function (expression) { + return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { + return this.update(caseKeyword, this.expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { + return this.update(this.caseKeyword, expression, this.colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.caseKeyword, this.expression, colonToken, this.statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.caseKeyword, this.expression, this.colonToken, statements); + }; + + CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CaseSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; + + var DefaultSwitchClauseSyntax = (function (_super) { + __extends(DefaultSwitchClauseSyntax, _super); + function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.defaultKeyword = defaultKeyword; + this.colonToken = colonToken; + this.statements = statements; + } + DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitDefaultSwitchClause(this); + }; + + DefaultSwitchClauseSyntax.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClauseSyntax.prototype.childCount = function () { + return 3; + }; + + DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.defaultKeyword; + case 1: + return this.colonToken; + case 2: + return this.statements; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { + return true; + }; + + DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { + if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { + return this; + } + + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); + }; + + DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { + return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.create1 = function () { + return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); + }; + + DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { + return this.update(defaultKeyword, this.colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.defaultKeyword, colonToken, this.statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { + return this.update(this.defaultKeyword, this.colonToken, statements); + }; + + DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { + return this.withStatements(TypeScript.Syntax.list([statement])); + }; + + DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statements.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DefaultSwitchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; + + var BreakStatementSyntax = (function (_super) { + __extends(BreakStatementSyntax, _super); + function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.breakKeyword = breakKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + BreakStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitBreakStatement(this); + }; + + BreakStatementSyntax.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatementSyntax.prototype.childCount = function () { + return 3; + }; + + BreakStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.breakKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + BreakStatementSyntax.prototype.isStatement = function () { + return true; + }; + + BreakStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { + if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { + return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); + }; + + BreakStatementSyntax.create1 = function () { + return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { + return this.update(breakKeyword, this.identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.breakKeyword, identifier, this.semicolonToken); + }; + + BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.breakKeyword, this.identifier, semicolonToken); + }; + + BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return BreakStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.BreakStatementSyntax = BreakStatementSyntax; + + var ContinueStatementSyntax = (function (_super) { + __extends(ContinueStatementSyntax, _super); + function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.continueKeyword = continueKeyword; + this.identifier = identifier; + this.semicolonToken = semicolonToken; + } + ContinueStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitContinueStatement(this); + }; + + ContinueStatementSyntax.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatementSyntax.prototype.childCount = function () { + return 3; + }; + + ContinueStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.continueKeyword; + case 1: + return this.identifier; + case 2: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ContinueStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { + if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { + return this; + } + + return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); + }; + + ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { + return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); + }; + + ContinueStatementSyntax.create1 = function () { + return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { + return this.update(continueKeyword, this.identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.continueKeyword, identifier, this.semicolonToken); + }; + + ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.continueKeyword, this.identifier, semicolonToken); + }; + + ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return ContinueStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; + + var ForStatementSyntax = (function (_super) { + __extends(ForStatementSyntax, _super); + function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.firstSemicolonToken = firstSemicolonToken; + this.condition = condition; + this.secondSemicolonToken = secondSemicolonToken; + this.incrementor = incrementor; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForStatement(this); + }; + + ForStatementSyntax.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatementSyntax.prototype.childCount = function () { + return 10; + }; + + ForStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.initializer; + case 4: + return this.firstSemicolonToken; + case 5: + return this.condition; + case 6: + return this.secondSemicolonToken; + case 7: + return this.incrementor; + case 8: + return this.closeParenToken; + case 9: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { + return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); + }; + + ForStatementSyntax.create1 = function (statement) { + return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withInitializer = function (initializer) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withIncrementor = function (incrementor) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); + }; + + ForStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); + }; + + ForStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { + return true; + } + if (this.condition !== null && this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForStatementSyntax = ForStatementSyntax; + + var ForInStatementSyntax = (function (_super) { + __extends(ForInStatementSyntax, _super); + function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.forKeyword = forKeyword; + this.openParenToken = openParenToken; + this.variableDeclaration = variableDeclaration; + this.left = left; + this.inKeyword = inKeyword; + this.expression = expression; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + ForInStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitForInStatement(this); + }; + + ForInStatementSyntax.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatementSyntax.prototype.childCount = function () { + return 8; + }; + + ForInStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.forKeyword; + case 1: + return this.openParenToken; + case 2: + return this.variableDeclaration; + case 3: + return this.left; + case 4: + return this.inKeyword; + case 5: + return this.expression; + case 6: + return this.closeParenToken; + case 7: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ForInStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isStatement = function () { + return true; + }; + + ForInStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); + }; + + ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { + return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); + }; + + ForInStatementSyntax.create1 = function (expression, statement) { + return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { + return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { + return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withLeft = function (left) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withExpression = function (expression) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); + }; + + ForInStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); + }; + + ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { + return true; + } + if (this.left !== null && this.left.isTypeScriptSpecific()) { + return true; + } + if (this.expression.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ForInStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ForInStatementSyntax = ForInStatementSyntax; + + var WhileStatementSyntax = (function (_super) { + __extends(WhileStatementSyntax, _super); + function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WhileStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWhileStatement(this); + }; + + WhileStatementSyntax.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WhileStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.whileKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WhileStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WhileStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WhileStatementSyntax.create1 = function (condition, statement) { + return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WhileStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WhileStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WhileStatementSyntax = WhileStatementSyntax; + + var WithStatementSyntax = (function (_super) { + __extends(WithStatementSyntax, _super); + function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.withKeyword = withKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.statement = statement; + } + WithStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitWithStatement(this); + }; + + WithStatementSyntax.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatementSyntax.prototype.childCount = function () { + return 5; + }; + + WithStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.withKeyword; + case 1: + return this.openParenToken; + case 2: + return this.condition; + case 3: + return this.closeParenToken; + case 4: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + WithStatementSyntax.prototype.isStatement = function () { + return true; + }; + + WithStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { + if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { + return this; + } + + return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); + }; + + WithStatementSyntax.create1 = function (condition, statement) { + return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); + }; + + WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { + return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); + }; + + WithStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); + }; + + WithStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.condition.isTypeScriptSpecific()) { + return true; + } + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return WithStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.WithStatementSyntax = WithStatementSyntax; + + var EnumDeclarationSyntax = (function (_super) { + __extends(EnumDeclarationSyntax, _super); + function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.modifiers = modifiers; + this.enumKeyword = enumKeyword; + this.identifier = identifier; + this.openBraceToken = openBraceToken; + this.enumElements = enumElements; + this.closeBraceToken = closeBraceToken; + } + EnumDeclarationSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumDeclaration(this); + }; + + EnumDeclarationSyntax.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + + EnumDeclarationSyntax.prototype.childCount = function () { + return 6; + }; + + EnumDeclarationSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.modifiers; + case 1: + return this.enumKeyword; + case 2: + return this.identifier; + case 3: + return this.openBraceToken; + case 4: + return this.enumElements; + case 5: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumDeclarationSyntax.prototype.isModuleElement = function () { + return true; + }; + + EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); + }; + + EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + EnumDeclarationSyntax.create1 = function (identifier) { + return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { + return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withModifier = function (modifier) { + return this.withModifiers(TypeScript.Syntax.list([modifier])); + }; + + EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { + return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { + return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); + }; + + EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); + }; + + EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return EnumDeclarationSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; + + var EnumElementSyntax = (function (_super) { + __extends(EnumElementSyntax, _super); + function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + } + EnumElementSyntax.prototype.accept = function (visitor) { + return visitor.visitEnumElement(this); + }; + + EnumElementSyntax.prototype.kind = function () { + return 243 /* EnumElement */; + }; + + EnumElementSyntax.prototype.childCount = function () { + return 2; + }; + + EnumElementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.equalsValueClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { + if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { + return this; + } + + return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); + }; + + EnumElementSyntax.create = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.create1 = function (propertyName) { + return new EnumElementSyntax(propertyName, null, false); + }; + + EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EnumElementSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.equalsValueClause); + }; + + EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { + return this.update(this.propertyName, equalsValueClause); + }; + + EnumElementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return EnumElementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EnumElementSyntax = EnumElementSyntax; + + var CastExpressionSyntax = (function (_super) { + __extends(CastExpressionSyntax, _super); + function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.lessThanToken = lessThanToken; + this.type = type; + this.greaterThanToken = greaterThanToken; + this.expression = expression; + } + CastExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitCastExpression(this); + }; + + CastExpressionSyntax.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + CastExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + CastExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.lessThanToken; + case 1: + return this.type; + case 2: + return this.greaterThanToken; + case 3: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CastExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { + if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { + return this; + } + + return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); + }; + + CastExpressionSyntax.create1 = function (type, expression) { + return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); + }; + + CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { + return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withType = function (type) { + return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { + return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); + }; + + CastExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); + }; + + CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { + return true; + }; + return CastExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CastExpressionSyntax = CastExpressionSyntax; + + var ObjectLiteralExpressionSyntax = (function (_super) { + __extends(ObjectLiteralExpressionSyntax, _super); + function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.openBraceToken = openBraceToken; + this.propertyAssignments = propertyAssignments; + this.closeBraceToken = closeBraceToken; + } + ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitObjectLiteralExpression(this); + }; + + ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + ObjectLiteralExpressionSyntax.prototype.childCount = function () { + return 3; + }; + + ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.openBraceToken; + case 1: + return this.propertyAssignments; + case 2: + return this.closeBraceToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { + if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { + return this; + } + + return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); + }; + + ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { + return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); + }; + + ObjectLiteralExpressionSyntax.create1 = function () { + return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); + }; + + ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { + return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { + return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { + return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); + }; + + ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { + return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); + }; + + ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.propertyAssignments.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return ObjectLiteralExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; + + var SimplePropertyAssignmentSyntax = (function (_super) { + __extends(SimplePropertyAssignmentSyntax, _super); + function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.colonToken = colonToken; + this.expression = expression; + } + SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitSimplePropertyAssignment(this); + }; + + SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + + SimplePropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.colonToken; + case 2: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { + if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { + return this; + } + + return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); + }; + + SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { + return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); + }; + + SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.propertyName, colonToken, this.expression); + }; + + SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { + return this.update(this.propertyName, this.colonToken, expression); + }; + + SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return SimplePropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; + + var FunctionPropertyAssignmentSyntax = (function (_super) { + __extends(FunctionPropertyAssignmentSyntax, _super); + function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + } + FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionPropertyAssignment(this); + }; + + FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + + FunctionPropertyAssignmentSyntax.prototype.childCount = function () { + return 3; + }; + + FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.propertyName; + case 1: + return this.callSignature; + case 2: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { + return true; + }; + + FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { + if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { + return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { + return this.update(propertyName, this.callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.propertyName, callSignature, this.block); + }; + + FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { + return this.update(this.propertyName, this.callSignature, block); + }; + + FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionPropertyAssignmentSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; + + var FunctionExpressionSyntax = (function (_super) { + __extends(FunctionExpressionSyntax, _super); + function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.functionKeyword = functionKeyword; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + } + FunctionExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitFunctionExpression(this); + }; + + FunctionExpressionSyntax.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpressionSyntax.prototype.childCount = function () { + return 4; + }; + + FunctionExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.functionKeyword; + case 1: + return this.identifier; + case 2: + return this.callSignature; + case 3: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isMemberExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isPostfixExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { + if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { + return this; + } + + return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); + }; + + FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { + return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); + }; + + FunctionExpressionSyntax.create1 = function () { + return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); + }; + + FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { + return this.update(functionKeyword, this.identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.functionKeyword, identifier, this.callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { + return this.update(this.functionKeyword, this.identifier, callSignature, this.block); + }; + + FunctionExpressionSyntax.prototype.withBlock = function (block) { + return this.update(this.functionKeyword, this.identifier, this.callSignature, block); + }; + + FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.callSignature.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FunctionExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; + + var EmptyStatementSyntax = (function (_super) { + __extends(EmptyStatementSyntax, _super); + function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.semicolonToken = semicolonToken; + } + EmptyStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitEmptyStatement(this); + }; + + EmptyStatementSyntax.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatementSyntax.prototype.childCount = function () { + return 1; + }; + + EmptyStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + EmptyStatementSyntax.prototype.isStatement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + EmptyStatementSyntax.prototype.update = function (semicolonToken) { + if (this.semicolonToken === semicolonToken) { + return this; + } + + return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); + }; + + EmptyStatementSyntax.create1 = function () { + return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(semicolonToken); + }; + + EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return EmptyStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; + + var TryStatementSyntax = (function (_super) { + __extends(TryStatementSyntax, _super); + function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.tryKeyword = tryKeyword; + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + } + TryStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitTryStatement(this); + }; + + TryStatementSyntax.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatementSyntax.prototype.childCount = function () { + return 4; + }; + + TryStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.tryKeyword; + case 1: + return this.block; + case 2: + return this.catchClause; + case 3: + return this.finallyClause; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TryStatementSyntax.prototype.isStatement = function () { + return true; + }; + + TryStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { + if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { + return this; + } + + return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); + }; + + TryStatementSyntax.create = function (tryKeyword, block) { + return new TryStatementSyntax(tryKeyword, block, null, null, false); + }; + + TryStatementSyntax.create1 = function () { + return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); + }; + + TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { + return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withBlock = function (block) { + return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withCatchClause = function (catchClause) { + return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); + }; + + TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { + return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); + }; + + TryStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { + return true; + } + if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TryStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TryStatementSyntax = TryStatementSyntax; + + var CatchClauseSyntax = (function (_super) { + __extends(CatchClauseSyntax, _super); + function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.catchKeyword = catchKeyword; + this.openParenToken = openParenToken; + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.closeParenToken = closeParenToken; + this.block = block; + } + CatchClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitCatchClause(this); + }; + + CatchClauseSyntax.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClauseSyntax.prototype.childCount = function () { + return 6; + }; + + CatchClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.catchKeyword; + case 1: + return this.openParenToken; + case 2: + return this.identifier; + case 3: + return this.typeAnnotation; + case 4: + return this.closeParenToken; + case 5: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { + return this; + } + + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); + }; + + CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { + return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); + }; + + CatchClauseSyntax.create1 = function (identifier) { + return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); + }; + + CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { + return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withIdentifier = function (identifier) { + return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); + }; + + CatchClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); + }; + + CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { + return true; + } + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return CatchClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.CatchClauseSyntax = CatchClauseSyntax; + + var FinallyClauseSyntax = (function (_super) { + __extends(FinallyClauseSyntax, _super); + function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.finallyKeyword = finallyKeyword; + this.block = block; + } + FinallyClauseSyntax.prototype.accept = function (visitor) { + return visitor.visitFinallyClause(this); + }; + + FinallyClauseSyntax.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClauseSyntax.prototype.childCount = function () { + return 2; + }; + + FinallyClauseSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.finallyKeyword; + case 1: + return this.block; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { + if (this.finallyKeyword === finallyKeyword && this.block === block) { + return this; + } + + return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); + }; + + FinallyClauseSyntax.create1 = function () { + return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); + }; + + FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { + return this.update(finallyKeyword, this.block); + }; + + FinallyClauseSyntax.prototype.withBlock = function (block) { + return this.update(this.finallyKeyword, block); + }; + + FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { + if (this.block.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return FinallyClauseSyntax; + })(TypeScript.SyntaxNode); + TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; + + var LabeledStatementSyntax = (function (_super) { + __extends(LabeledStatementSyntax, _super); + function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.identifier = identifier; + this.colonToken = colonToken; + this.statement = statement; + } + LabeledStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitLabeledStatement(this); + }; + + LabeledStatementSyntax.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatementSyntax.prototype.childCount = function () { + return 3; + }; + + LabeledStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.identifier; + case 1: + return this.colonToken; + case 2: + return this.statement; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + LabeledStatementSyntax.prototype.isStatement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { + if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { + return this; + } + + return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); + }; + + LabeledStatementSyntax.create1 = function (identifier, statement) { + return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); + }; + + LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { + return this.update(identifier, this.colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { + return this.update(this.identifier, colonToken, this.statement); + }; + + LabeledStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.identifier, this.colonToken, statement); + }; + + LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return LabeledStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; + + var DoStatementSyntax = (function (_super) { + __extends(DoStatementSyntax, _super); + function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.doKeyword = doKeyword; + this.statement = statement; + this.whileKeyword = whileKeyword; + this.openParenToken = openParenToken; + this.condition = condition; + this.closeParenToken = closeParenToken; + this.semicolonToken = semicolonToken; + } + DoStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDoStatement(this); + }; + + DoStatementSyntax.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatementSyntax.prototype.childCount = function () { + return 7; + }; + + DoStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.doKeyword; + case 1: + return this.statement; + case 2: + return this.whileKeyword; + case 3: + return this.openParenToken; + case 4: + return this.condition; + case 5: + return this.closeParenToken; + case 6: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DoStatementSyntax.prototype.isIterationStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DoStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { + return this; + } + + return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); + }; + + DoStatementSyntax.create1 = function (statement, condition) { + return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { + return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withStatement = function (statement) { + return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { + return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCondition = function (condition) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); + }; + + DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); + }; + + DoStatementSyntax.prototype.isTypeScriptSpecific = function () { + if (this.statement.isTypeScriptSpecific()) { + return true; + } + if (this.condition.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DoStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DoStatementSyntax = DoStatementSyntax; + + var TypeOfExpressionSyntax = (function (_super) { + __extends(TypeOfExpressionSyntax, _super); + function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.typeOfKeyword = typeOfKeyword; + this.expression = expression; + } + TypeOfExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitTypeOfExpression(this); + }; + + TypeOfExpressionSyntax.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + TypeOfExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + TypeOfExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.typeOfKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { + if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { + return this; + } + + return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); + }; + + TypeOfExpressionSyntax.create1 = function (expression) { + return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); + }; + + TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { + return this.update(typeOfKeyword, this.expression); + }; + + TypeOfExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.typeOfKeyword, expression); + }; + + TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return TypeOfExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; + + var DeleteExpressionSyntax = (function (_super) { + __extends(DeleteExpressionSyntax, _super); + function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.deleteKeyword = deleteKeyword; + this.expression = expression; + } + DeleteExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitDeleteExpression(this); + }; + + DeleteExpressionSyntax.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + DeleteExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + DeleteExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.deleteKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DeleteExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { + if (this.deleteKeyword === deleteKeyword && this.expression === expression) { + return this; + } + + return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); + }; + + DeleteExpressionSyntax.create1 = function (expression) { + return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); + }; + + DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { + return this.update(deleteKeyword, this.expression); + }; + + DeleteExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.deleteKeyword, expression); + }; + + DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return DeleteExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; + + var VoidExpressionSyntax = (function (_super) { + __extends(VoidExpressionSyntax, _super); + function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.voidKeyword = voidKeyword; + this.expression = expression; + } + VoidExpressionSyntax.prototype.accept = function (visitor) { + return visitor.visitVoidExpression(this); + }; + + VoidExpressionSyntax.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + VoidExpressionSyntax.prototype.childCount = function () { + return 2; + }; + + VoidExpressionSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.voidKeyword; + case 1: + return this.expression; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + VoidExpressionSyntax.prototype.isUnaryExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.isExpression = function () { + return true; + }; + + VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { + if (this.voidKeyword === voidKeyword && this.expression === expression) { + return this; + } + + return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); + }; + + VoidExpressionSyntax.create1 = function (expression) { + return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); + }; + + VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { + return this.update(voidKeyword, this.expression); + }; + + VoidExpressionSyntax.prototype.withExpression = function (expression) { + return this.update(this.voidKeyword, expression); + }; + + VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { + if (this.expression.isTypeScriptSpecific()) { + return true; + } + return false; + }; + return VoidExpressionSyntax; + })(TypeScript.SyntaxNode); + TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; + + var DebuggerStatementSyntax = (function (_super) { + __extends(DebuggerStatementSyntax, _super); + function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { + _super.call(this, parsedInStrictMode); + this.debuggerKeyword = debuggerKeyword; + this.semicolonToken = semicolonToken; + } + DebuggerStatementSyntax.prototype.accept = function (visitor) { + return visitor.visitDebuggerStatement(this); + }; + + DebuggerStatementSyntax.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + + DebuggerStatementSyntax.prototype.childCount = function () { + return 2; + }; + + DebuggerStatementSyntax.prototype.childAt = function (slot) { + switch (slot) { + case 0: + return this.debuggerKeyword; + case 1: + return this.semicolonToken; + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + DebuggerStatementSyntax.prototype.isStatement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.isModuleElement = function () { + return true; + }; + + DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { + if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { + return this; + } + + return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); + }; + + DebuggerStatementSyntax.create1 = function () { + return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); + }; + + DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { + return _super.prototype.withLeadingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { + return _super.prototype.withTrailingTrivia.call(this, trivia); + }; + + DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { + return this.update(debuggerKeyword, this.semicolonToken); + }; + + DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { + return this.update(this.debuggerKeyword, semicolonToken); + }; + + DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { + return false; + }; + return DebuggerStatementSyntax; + })(TypeScript.SyntaxNode); + TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxRewriter = (function () { + function SyntaxRewriter() { + } + SyntaxRewriter.prototype.visitToken = function (token) { + return token; + }; + + SyntaxRewriter.prototype.visitNode = function (node) { + return node.accept(this); + }; + + SyntaxRewriter.prototype.visitNodeOrToken = function (node) { + return node.isToken() ? this.visitToken(node) : this.visitNode(node); + }; + + SyntaxRewriter.prototype.visitList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = this.visitNodeOrToken(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.list(newItems); + }; + + SyntaxRewriter.prototype.visitSeparatedList = function (list) { + var newItems = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); + + if (item !== newItem && newItems === null) { + newItems = []; + for (var j = 0; j < i; j++) { + newItems.push(list.childAt(j)); + } + } + + if (newItems) { + newItems.push(newItem); + } + } + + return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); + }; + + SyntaxRewriter.prototype.visitSourceUnit = function (node) { + return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); + }; + + SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { + return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { + return node.update(this.visitNodeOrToken(node.moduleName)); + }; + + SyntaxRewriter.prototype.visitImportDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitExportAssignment = function (node) { + return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitClassDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); + }; + + SyntaxRewriter.prototype.visitHeritageClause = function (node) { + return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); + }; + + SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableStatement = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { + return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); + }; + + SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { + return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { + return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); + }; + + SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); + }; + + SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitOmittedExpression = function (node) { + return node; + }; + + SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitQualifiedName = function (node) { + return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); + }; + + SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitConstructorType = function (node) { + return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitFunctionType = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitObjectType = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitArrayType = function (node) { + return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitGenericType = function (node) { + return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); + }; + + SyntaxRewriter.prototype.visitTypeQuery = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); + }; + + SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { + return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitBlock = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitParameter = function (node) { + return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); + }; + + SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); + }; + + SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); + }; + + SyntaxRewriter.prototype.visitInvocationExpression = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitArgumentList = function (node) { + return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitBinaryExpression = function (node) { + return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); + }; + + SyntaxRewriter.prototype.visitConditionalExpression = function (node) { + return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); + }; + + SyntaxRewriter.prototype.visitConstructSignature = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitMethodSignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); + }; + + SyntaxRewriter.prototype.visitIndexSignature = function (node) { + return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitPropertySignature = function (node) { + return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitCallSignature = function (node) { + return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); + }; + + SyntaxRewriter.prototype.visitParameterList = function (node) { + return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameterList = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); + }; + + SyntaxRewriter.prototype.visitTypeParameter = function (node) { + return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); + }; + + SyntaxRewriter.prototype.visitConstraint = function (node) { + return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); + }; + + SyntaxRewriter.prototype.visitElseClause = function (node) { + return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitIfStatement = function (node) { + return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); + }; + + SyntaxRewriter.prototype.visitExpressionStatement = function (node) { + return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { + 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) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitGetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitSetAccessor = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitThrowStatement = function (node) { + return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitReturnStatement = function (node) { + return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { + return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); + }; + + SyntaxRewriter.prototype.visitSwitchStatement = function (node) { + return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { + return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { + return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); + }; + + SyntaxRewriter.prototype.visitBreakStatement = function (node) { + return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitContinueStatement = function (node) { + return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitForStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitForInStatement = function (node) { + return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWhileStatement = function (node) { + return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitWithStatement = function (node) { + return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { + return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitEnumElement = function (node) { + return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); + }; + + SyntaxRewriter.prototype.visitCastExpression = function (node) { + return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { + return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); + }; + + SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { + return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFunctionExpression = function (node) { + return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitEmptyStatement = function (node) { + return node.update(this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTryStatement = function (node) { + return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); + }; + + SyntaxRewriter.prototype.visitCatchClause = function (node) { + return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitFinallyClause = function (node) { + return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); + }; + + SyntaxRewriter.prototype.visitLabeledStatement = function (node) { + return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); + }; + + SyntaxRewriter.prototype.visitDoStatement = function (node) { + return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); + }; + + SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { + return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDeleteExpression = function (node) { + return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitVoidExpression = function (node) { + return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); + }; + + SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { + return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); + }; + return SyntaxRewriter; + })(); + TypeScript.SyntaxRewriter = SyntaxRewriter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxDedenter = (function (_super) { + __extends(SyntaxDedenter, _super); + function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { + _super.call(this); + this.dedentationAmount = dedentationAmount; + this.minimumIndent = minimumIndent; + this.options = options; + this.lastTriviaWasNewLine = dedentFirstToken; + } + SyntaxDedenter.prototype.abort = function () { + this.lastTriviaWasNewLine = false; + this.dedentationAmount = 0; + }; + + SyntaxDedenter.prototype.isAborted = function () { + return this.dedentationAmount === 0; + }; + + SyntaxDedenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); + } + + if (this.isAborted()) { + return token; + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { + var result = []; + var dedentNextWhitespace = true; + + for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var dedentThisTrivia = dedentNextWhitespace; + dedentNextWhitespace = false; + + if (dedentThisTrivia) { + if (trivia.kind() === 4 /* WhitespaceTrivia */) { + var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; + result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); + continue; + } else if (trivia.kind() !== 5 /* NewLineTrivia */) { + this.abort(); + break; + } + } + + if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + result.push(this.dedentMultiLineComment(trivia)); + continue; + } + + result.push(trivia); + if (trivia.kind() === 5 /* NewLineTrivia */) { + dedentNextWhitespace = true; + } + } + + if (dedentNextWhitespace) { + this.abort(); + } + + if (this.isAborted()) { + return triviaList; + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition === segment.length) { + if (hasFollowingNewLineTrivia) { + return ""; + } + } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment.substring(firstNonWhitespacePosition); + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); + + if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { + this.abort(); + return segment; + } + + this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; + TypeScript.Debug.assert(this.dedentationAmount >= 0); + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { + var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); + return TypeScript.Syntax.whitespace(newIndentation); + }; + + SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + if (segments.length === 1) { + return trivia; + } + + for (var i = 1; i < segments.length; i++) { + var segment = segments[i]; + segments[i] = this.dedentSegment(segment, false); + } + + var result = segments.join(""); + + return TypeScript.Syntax.multiLineComment(result); + }; + + SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { + var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); + var result = node.accept(dedenter); + + if (dedenter.isAborted()) { + return node; + } + + return result; + }; + return SyntaxDedenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxDedenter = SyntaxDedenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxIndenter = (function (_super) { + __extends(SyntaxIndenter, _super); + function SyntaxIndenter(indentFirstToken, indentationAmount, options) { + _super.call(this); + this.indentationAmount = indentationAmount; + this.options = options; + this.lastTriviaWasNewLine = indentFirstToken; + this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); + } + SyntaxIndenter.prototype.visitToken = function (token) { + if (token.width() === 0) { + return token; + } + + var result = token; + if (this.lastTriviaWasNewLine) { + result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); + } + + this.lastTriviaWasNewLine = token.hasTrailingNewLine(); + return result; + }; + + SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { + var result = []; + + var indentNextTrivia = true; + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + var indentThisTrivia = indentNextTrivia; + indentNextTrivia = false; + + switch (trivia.kind()) { + case 6 /* MultiLineCommentTrivia */: + this.indentMultiLineComment(trivia, indentThisTrivia, result); + continue; + + case 7 /* SingleLineCommentTrivia */: + case 8 /* SkippedTokenTrivia */: + this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); + continue; + + case 4 /* WhitespaceTrivia */: + this.indentWhitespace(trivia, indentThisTrivia, result); + continue; + + case 5 /* NewLineTrivia */: + result.push(trivia); + indentNextTrivia = true; + continue; + + default: + throw TypeScript.Errors.invalidOperation(); + } + } + + if (indentNextTrivia) { + result.push(this.indentationTrivia); + } + + return TypeScript.Syntax.triviaList(result); + }; + + SyntaxIndenter.prototype.indentSegment = function (segment) { + var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); + + if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { + return segment; + } + + var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); + + var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; + + var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); + + return indentationString + segment.substring(firstNonWhitespacePosition); + }; + + SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { + if (!indentThisTrivia) { + result.push(trivia); + return; + } + + var newIndentation = this.indentSegment(trivia.fullText()); + result.push(TypeScript.Syntax.whitespace(newIndentation)); + }; + + SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + result.push(trivia); + }; + + SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { + if (indentThisTrivia) { + result.push(this.indentationTrivia); + } + + var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); + + for (var i = 1; i < segments.length; i++) { + segments[i] = this.indentSegment(segments[i]); + } + + var newText = segments.join(""); + result.push(TypeScript.Syntax.multiLineComment(newText)); + }; + + SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + return node.accept(indenter); + }; + + SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { + var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); + var result = TypeScript.ArrayUtilities.select(nodes, function (n) { + return n.accept(indenter); + }); + + return result; + }; + return SyntaxIndenter; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxIndenter = SyntaxIndenter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var VariableWidthTokenWithNoTrivia = (function () { + function VariableWidthTokenWithNoTrivia(fullText, kind) { + this._fullText = fullText; + this.tokenKind = kind; + } + VariableWidthTokenWithNoTrivia.prototype.clone = function () { + return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); + }; + + VariableWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithNoTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithNoTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithNoTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithNoTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithNoTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithNoTrivia; + })(); + Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; + + var VariableWidthTokenWithLeadingTrivia = (function () { + function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; + + var VariableWidthTokenWithTrailingTrivia = (function () { + function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; + + var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { + function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + this._trailingTriviaInfo = trailingTriviaInfo; + } + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { + return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return this.fullText().substr(this.leadingTriviaWidth(), this.width()); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + if (this._value === undefined) { + this._value = TypeScript.Syntax.value(this); + } + + return this._value; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + if (this._valueText === undefined) { + this._valueText = TypeScript.Syntax.valueText(this); + } + + return this._valueText; + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return VariableWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; + + var FixedWidthTokenWithNoTrivia = (function () { + function FixedWidthTokenWithNoTrivia(kind) { + this.tokenKind = kind; + } + FixedWidthTokenWithNoTrivia.prototype.clone = function () { + return new FixedWidthTokenWithNoTrivia(this.tokenKind); + }; + + FixedWidthTokenWithNoTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithNoTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithNoTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithNoTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithNoTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.fullText = function () { + return this.text(); + }; + + FixedWidthTokenWithNoTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithNoTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithNoTrivia; + })(); + Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; + + var FixedWidthTokenWithLeadingTrivia = (function () { + function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._leadingTriviaInfo = leadingTriviaInfo; + } + FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; + + var FixedWidthTokenWithTrailingTrivia = (function () { + function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { + this._fullText = fullText; + this.tokenKind = kind; + this._trailingTriviaInfo = trailingTriviaInfo; + } + FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { + return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { + return 0; + }; + FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; + + var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { + 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { + return false; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { + return this.tokenKind; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange('index'); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { + return this.text().length; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { + return TypeScript.SyntaxFacts.getText(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { + return this._fullText; + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { + return TypeScript.Syntax.value(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { + return TypeScript.Syntax.valueText(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { + return hasTriviaComment(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { + return hasTriviaNewLine(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { + return getTriviaWidth(this._leadingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { + return true; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { + return hasTriviaComment(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { + return hasTriviaNewLine(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { + return getTriviaWidth(this._trailingTriviaInfo); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { + return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { + return TypeScript.Syntax.tokenToJSON(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { + return this; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { + return false; + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { + return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { + return TypeScript.Syntax.realizeToken(this); + }; + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { + collectTokenTextElements(this, elements); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { + return TypeScript.Syntax.isExpression(this); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return FixedWidthTokenWithLeadingAndTrailingTrivia; + })(); + Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; + + function collectTokenTextElements(token, elements) { + token.leadingTrivia().collectTextElements(elements); + elements.push(token.text()); + token.trailingTrivia().collectTextElements(elements); + } + + function getTriviaWidth(value) { + return value >>> 2 /* TriviaFullWidthShift */; + } + + function hasTriviaComment(value) { + return (value & 2 /* TriviaCommentMask */) !== 0; + } + + function hasTriviaNewLine(value) { + return (value & 1 /* TriviaNewLineMask */) !== 0; + } + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + function isExpression(token) { + switch (token.tokenKind) { + case 11 /* IdentifierName */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 50 /* SuperKeyword */: + return true; + } + + return false; + } + Syntax.isExpression = isExpression; + + function realizeToken(token) { + return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); + } + Syntax.realizeToken = realizeToken; + + function convertToIdentifierName(token) { + TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); + return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); + } + Syntax.convertToIdentifierName = convertToIdentifierName; + + function tokenToJSON(token) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === token.kind()) { + result.kind = name; + break; + } + } + + result.width = token.width(); + if (token.fullWidth() !== token.width()) { + result.fullWidth = token.fullWidth(); + } + + result.text = token.text(); + + var value = token.value(); + if (value !== null) { + result.value = value; + result.valueText = token.valueText(); + } + + if (token.hasLeadingTrivia()) { + result.hasLeadingTrivia = true; + } + + if (token.hasLeadingComment()) { + result.hasLeadingComment = true; + } + + if (token.hasLeadingNewLine()) { + result.hasLeadingNewLine = true; + } + + if (token.hasLeadingSkippedText()) { + result.hasLeadingSkippedText = true; + } + + if (token.hasTrailingTrivia()) { + result.hasTrailingTrivia = true; + } + + if (token.hasTrailingComment()) { + result.hasTrailingComment = true; + } + + if (token.hasTrailingNewLine()) { + result.hasTrailingNewLine = true; + } + + if (token.hasTrailingSkippedText()) { + result.hasTrailingSkippedText = true; + } + + var trivia = token.leadingTrivia(); + if (trivia.count() > 0) { + result.leadingTrivia = trivia; + } + + trivia = token.trailingTrivia(); + if (trivia.count() > 0) { + result.trailingTrivia = trivia; + } + + return result; + } + Syntax.tokenToJSON = tokenToJSON; + + function value(token) { + return value1(token.tokenKind, token.text()); + } + Syntax.value = value; + + function hexValue(text, start, length) { + var intChar = 0; + for (var i = 0; i < length; i++) { + var ch2 = text.charCodeAt(start + i); + if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { + break; + } + + intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); + } + + return intChar; + } + + var characterArray = []; + + function convertEscapes(text) { + characterArray.length = 0; + var result = ""; + + for (var i = 0, n = text.length; i < n; i++) { + var ch = text.charCodeAt(i); + + if (ch === 92 /* backslash */) { + i++; + if (i < n) { + ch = text.charCodeAt(i); + switch (ch) { + case 48 /* _0 */: + characterArray.push(0 /* nullCharacter */); + continue; + + case 98 /* b */: + characterArray.push(8 /* backspace */); + continue; + + case 102 /* f */: + characterArray.push(12 /* formFeed */); + continue; + + case 110 /* n */: + characterArray.push(10 /* lineFeed */); + continue; + + case 114 /* r */: + characterArray.push(13 /* carriageReturn */); + continue; + + case 116 /* t */: + characterArray.push(9 /* tab */); + continue; + + case 118 /* v */: + characterArray.push(11 /* verticalTab */); + continue; + + case 120 /* x */: + characterArray.push(hexValue(text, i + 1, 2)); + i += 2; + continue; + + case 117 /* u */: + characterArray.push(hexValue(text, i + 1, 4)); + i += 4; + continue; + + case 13 /* carriageReturn */: + var nextIndex = i + 1; + if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { + i++; + } + continue; + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + continue; + + default: + } + } + } + + characterArray.push(ch); + + if (i && !(i % 1024)) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + characterArray.length = 0; + } + } + + if (characterArray.length) { + result = result.concat(String.fromCharCode.apply(null, characterArray)); + } + + return result; + } + + function massageEscapes(text) { + return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; + } + Syntax.massageEscapes = massageEscapes; + + function value1(kind, text) { + if (kind === 11 /* IdentifierName */) { + return massageEscapes(text); + } + + switch (kind) { + case 37 /* TrueKeyword */: + return true; + case 24 /* FalseKeyword */: + return false; + case 32 /* NullKeyword */: + return null; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { + return TypeScript.SyntaxFacts.getText(kind); + } + + if (kind === 13 /* NumericLiteral */) { + return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); + } else if (kind === 14 /* StringLiteral */) { + if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { + return massageEscapes(text.substr(1, text.length - 2)); + } else { + return massageEscapes(text.substr(1)); + } + } else if (kind === 12 /* RegularExpressionLiteral */) { + return regularExpressionValue(text); + } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { + return null; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + + function regularExpressionValue(text) { + try { + var lastSlash = text.lastIndexOf("/"); + var body = text.substring(1, lastSlash); + var flags = text.substring(lastSlash + 1); + return new RegExp(body, flags); + } catch (e) { + return null; + } + } + + function valueText1(kind, text) { + var value = value1(kind, text); + return value === null ? "" : value.toString(); + } + + function valueText(token) { + var value = token.value(); + return value === null ? "" : value.toString(); + } + Syntax.valueText = valueText; + + var EmptyToken = (function () { + function EmptyToken(kind) { + this.tokenKind = kind; + } + EmptyToken.prototype.clone = function () { + return new EmptyToken(this.tokenKind); + }; + + EmptyToken.prototype.kind = function () { + return this.tokenKind; + }; + + EmptyToken.prototype.isToken = function () { + return true; + }; + EmptyToken.prototype.isNode = function () { + return false; + }; + EmptyToken.prototype.isList = function () { + return false; + }; + EmptyToken.prototype.isSeparatedList = function () { + return false; + }; + + EmptyToken.prototype.childCount = function () { + return 0; + }; + + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + EmptyToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + EmptyToken.prototype.firstToken = function () { + return this; + }; + EmptyToken.prototype.lastToken = function () { + return this; + }; + EmptyToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + EmptyToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + EmptyToken.prototype.fullWidth = function () { + return 0; + }; + EmptyToken.prototype.width = function () { + return 0; + }; + EmptyToken.prototype.text = function () { + return ""; + }; + EmptyToken.prototype.fullText = function () { + return ""; + }; + EmptyToken.prototype.value = function () { + return null; + }; + EmptyToken.prototype.valueText = function () { + return ""; + }; + + EmptyToken.prototype.hasLeadingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasLeadingComment = function () { + return false; + }; + EmptyToken.prototype.hasLeadingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasLeadingSkippedText = function () { + return false; + }; + EmptyToken.prototype.leadingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.hasTrailingTrivia = function () { + return false; + }; + EmptyToken.prototype.hasTrailingComment = function () { + return false; + }; + EmptyToken.prototype.hasTrailingNewLine = function () { + return false; + }; + EmptyToken.prototype.hasTrailingSkippedText = function () { + return false; + }; + EmptyToken.prototype.hasSkippedToken = function () { + return false; + }; + + EmptyToken.prototype.trailingTriviaWidth = function () { + return 0; + }; + EmptyToken.prototype.leadingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.trailingTrivia = function () { + return TypeScript.Syntax.emptyTriviaList; + }; + EmptyToken.prototype.realize = function () { + return realizeToken(this); + }; + EmptyToken.prototype.collectTextElements = function (elements) { + }; + + EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return this.realize().withLeadingTrivia(leadingTrivia); + }; + + EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return this.realize().withTrailingTrivia(trailingTrivia); + }; + + EmptyToken.prototype.isExpression = function () { + return isExpression(this); + }; + + EmptyToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + EmptyToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return EmptyToken; + })(); + + function emptyToken(kind) { + return new EmptyToken(kind); + } + Syntax.emptyToken = emptyToken; + + var RealizedToken = (function () { + function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { + this.tokenKind = tokenKind; + this._leadingTrivia = leadingTrivia; + this._text = text; + this._value = value; + this._valueText = valueText; + this._trailingTrivia = trailingTrivia; + } + RealizedToken.prototype.clone = function () { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.kind = function () { + return this.tokenKind; + }; + RealizedToken.prototype.toJSON = function (key) { + return tokenToJSON(this); + }; + RealizedToken.prototype.firstToken = function () { + return this; + }; + RealizedToken.prototype.lastToken = function () { + return this; + }; + RealizedToken.prototype.isTypeScriptSpecific = function () { + return false; + }; + + RealizedToken.prototype.isIncrementallyUnusable = function () { + return true; + }; + + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; + + RealizedToken.prototype.childCount = function () { + return 0; + }; + + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }; + + RealizedToken.prototype.isToken = function () { + return true; + }; + RealizedToken.prototype.isNode = function () { + return false; + }; + RealizedToken.prototype.isList = function () { + return false; + }; + RealizedToken.prototype.isSeparatedList = function () { + return false; + }; + RealizedToken.prototype.isTrivia = function () { + return false; + }; + RealizedToken.prototype.isTriviaList = function () { + return false; + }; + + RealizedToken.prototype.fullWidth = function () { + return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); + }; + RealizedToken.prototype.width = function () { + return this.text().length; + }; + + RealizedToken.prototype.text = function () { + return this._text; + }; + RealizedToken.prototype.fullText = function () { + return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); + }; + + RealizedToken.prototype.value = function () { + return this._value; + }; + RealizedToken.prototype.valueText = function () { + return this._valueText; + }; + + RealizedToken.prototype.hasLeadingTrivia = function () { + return this._leadingTrivia.count() > 0; + }; + RealizedToken.prototype.hasLeadingComment = function () { + return this._leadingTrivia.hasComment(); + }; + RealizedToken.prototype.hasLeadingNewLine = function () { + return this._leadingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasLeadingSkippedText = function () { + return this._leadingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.leadingTriviaWidth = function () { + return this._leadingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasTrailingTrivia = function () { + return this._trailingTrivia.count() > 0; + }; + RealizedToken.prototype.hasTrailingComment = function () { + return this._trailingTrivia.hasComment(); + }; + RealizedToken.prototype.hasTrailingNewLine = function () { + return this._trailingTrivia.hasNewLine(); + }; + RealizedToken.prototype.hasTrailingSkippedText = function () { + return this._trailingTrivia.hasSkippedToken(); + }; + RealizedToken.prototype.trailingTriviaWidth = function () { + return this._trailingTrivia.fullWidth(); + }; + + RealizedToken.prototype.hasSkippedToken = function () { + return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); + }; + + RealizedToken.prototype.leadingTrivia = function () { + return this._leadingTrivia; + }; + RealizedToken.prototype.trailingTrivia = function () { + return this._trailingTrivia; + }; + + RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { + return new TypeScript.PositionedToken(parent, this, fullStart); + }; + + RealizedToken.prototype.collectTextElements = function (elements) { + this.leadingTrivia().collectTextElements(elements); + elements.push(this.text()); + this.trailingTrivia().collectTextElements(elements); + }; + + RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { + return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); + }; + + RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { + return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); + }; + + RealizedToken.prototype.isExpression = function () { + return isExpression(this); + }; + + RealizedToken.prototype.isPrimaryExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isMemberExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isPostfixExpression = function () { + return this.isExpression(); + }; + + RealizedToken.prototype.isUnaryExpression = function () { + return this.isExpression(); + }; + return RealizedToken; + })(); + + function token(kind, info) { + if (typeof info === "undefined") { info = null; } + var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); + + return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); + } + Syntax.token = token; + + function identifier(text, info) { + if (typeof info === "undefined") { info = null; } + info = info || {}; + info.text = text; + return token(11 /* IdentifierName */, info); + } + Syntax.identifier = identifier; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTokenReplacer = (function (_super) { + __extends(SyntaxTokenReplacer, _super); + function SyntaxTokenReplacer(token1, token2) { + _super.call(this); + this.token1 = token1; + this.token2 = token2; + } + SyntaxTokenReplacer.prototype.visitToken = function (token) { + if (token === this.token1) { + var result = this.token2; + this.token1 = null; + this.token2 = null; + + return result; + } + + return token; + }; + + SyntaxTokenReplacer.prototype.visitNode = function (node) { + if (this.token1 === null) { + return node; + } + + return _super.prototype.visitNode.call(this, node); + }; + + SyntaxTokenReplacer.prototype.visitList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitList.call(this, list); + }; + + SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { + if (this.token1 === null) { + return list; + } + + return _super.prototype.visitSeparatedList.call(this, list); + }; + return SyntaxTokenReplacer; + })(TypeScript.SyntaxRewriter); + TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + var AbstractTrivia = (function () { + function AbstractTrivia(_kind) { + this._kind = _kind; + } + AbstractTrivia.prototype.fullWidth = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.fullText = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.abstract(); + }; + + AbstractTrivia.prototype.toJSON = function (key) { + var result = {}; + + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === this._kind) { + result.kind = name; + break; + } + } + + if (this.isSkippedToken()) { + result.skippedToken = this.skippedToken(); + } else { + result.text = this.fullText(); + } + return result; + }; + + AbstractTrivia.prototype.kind = function () { + return this._kind; + }; + + AbstractTrivia.prototype.isWhitespace = function () { + return this.kind() === 4 /* WhitespaceTrivia */; + }; + + AbstractTrivia.prototype.isComment = function () { + return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + }; + + AbstractTrivia.prototype.isNewLine = function () { + return this.kind() === 5 /* NewLineTrivia */; + }; + + AbstractTrivia.prototype.isSkippedToken = function () { + return this.kind() === 8 /* SkippedTokenTrivia */; + }; + + AbstractTrivia.prototype.collectTextElements = function (elements) { + elements.push(this.fullText()); + }; + return AbstractTrivia; + })(); + + var NormalTrivia = (function (_super) { + __extends(NormalTrivia, _super); + function NormalTrivia(kind, _text) { + _super.call(this, kind); + this._text = _text; + } + NormalTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + NormalTrivia.prototype.fullText = function () { + return this._text; + }; + + NormalTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return NormalTrivia; + })(AbstractTrivia); + + var SkippedTokenTrivia = (function (_super) { + __extends(SkippedTokenTrivia, _super); + function SkippedTokenTrivia(_skippedToken) { + _super.call(this, 8 /* SkippedTokenTrivia */); + this._skippedToken = _skippedToken; + } + SkippedTokenTrivia.prototype.fullWidth = function () { + return this.fullText().length; + }; + + SkippedTokenTrivia.prototype.fullText = function () { + return this.skippedToken().fullText(); + }; + + SkippedTokenTrivia.prototype.skippedToken = function () { + return this._skippedToken; + }; + return SkippedTokenTrivia; + })(AbstractTrivia); + + var DeferredTrivia = (function (_super) { + __extends(DeferredTrivia, _super); + function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { + _super.call(this, kind); + this._text = _text; + this._fullStart = _fullStart; + this._fullWidth = _fullWidth; + this._fullText = null; + } + DeferredTrivia.prototype.fullWidth = function () { + return this._fullWidth; + }; + + DeferredTrivia.prototype.fullText = function () { + if (!this._fullText) { + this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); + this._text = null; + } + + return this._fullText; + }; + + DeferredTrivia.prototype.skippedToken = function () { + throw TypeScript.Errors.invalidOperation(); + }; + return DeferredTrivia; + })(AbstractTrivia); + + function deferredTrivia(kind, text, fullStart, fullWidth) { + return new DeferredTrivia(kind, text, fullStart, fullWidth); + } + Syntax.deferredTrivia = deferredTrivia; + + function trivia(kind, text) { + return new NormalTrivia(kind, text); + } + Syntax.trivia = trivia; + + function skippedTokenTrivia(token) { + TypeScript.Debug.assert(!token.hasLeadingTrivia()); + TypeScript.Debug.assert(!token.hasTrailingTrivia()); + TypeScript.Debug.assert(token.fullWidth() > 0); + return new SkippedTokenTrivia(token); + } + Syntax.skippedTokenTrivia = skippedTokenTrivia; + + function spaces(count) { + return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); + } + Syntax.spaces = spaces; + + function whitespace(text) { + return trivia(4 /* WhitespaceTrivia */, text); + } + Syntax.whitespace = whitespace; + + function multiLineComment(text) { + return trivia(6 /* MultiLineCommentTrivia */, text); + } + Syntax.multiLineComment = multiLineComment; + + function singleLineComment(text) { + return trivia(7 /* SingleLineCommentTrivia */, text); + } + Syntax.singleLineComment = singleLineComment; + + Syntax.spaceTrivia = spaces(1); + Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); + Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); + Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); + + function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { + var result = []; + + var triviaText = trivia.fullText(); + var currentIndex = 0; + + for (var i = 0; i < triviaText.length; i++) { + var ch = triviaText.charCodeAt(i); + + var isCarriageReturnLineFeed = false; + switch (ch) { + case 13 /* carriageReturn */: + if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { + i++; + } + + case 10 /* lineFeed */: + case 8233 /* paragraphSeparator */: + case 8232 /* lineSeparator */: + result.push(triviaText.substring(currentIndex, i + 1)); + + currentIndex = i + 1; + continue; + } + } + + result.push(triviaText.substring(currentIndex)); + return result; + } + Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (function (Syntax) { + Syntax.emptyTriviaList = { + kind: function () { + return 3 /* TriviaList */; + }, + count: function () { + return 0; + }, + syntaxTriviaAt: function (index) { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + last: function () { + throw TypeScript.Errors.argumentOutOfRange("index"); + }, + fullWidth: function () { + return 0; + }, + fullText: function () { + return ""; + }, + hasComment: function () { + return false; + }, + hasNewLine: function () { + return false; + }, + hasSkippedToken: function () { + return false; + }, + toJSON: function (key) { + return []; + }, + collectTextElements: function (elements) { + }, + toArray: function () { + return []; + }, + concat: function (trivia) { + return trivia; + } + }; + + function concatTrivia(list1, list2) { + if (list1.count() === 0) { + return list2; + } + + if (list2.count() === 0) { + return list1; + } + + var trivia = list1.toArray(); + trivia.push.apply(trivia, list2.toArray()); + + return triviaList(trivia); + } + + function isComment(trivia) { + return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + } + + var SingletonSyntaxTriviaList = (function () { + function SingletonSyntaxTriviaList(item) { + this.item = item; + } + SingletonSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + SingletonSyntaxTriviaList.prototype.count = function () { + return 1; + }; + + SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index !== 0) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.last = function () { + return this.item; + }; + + SingletonSyntaxTriviaList.prototype.fullWidth = function () { + return this.item.fullWidth(); + }; + + SingletonSyntaxTriviaList.prototype.fullText = function () { + return this.item.fullText(); + }; + + SingletonSyntaxTriviaList.prototype.hasComment = function () { + return isComment(this.item); + }; + + SingletonSyntaxTriviaList.prototype.hasNewLine = function () { + return this.item.kind() === 5 /* NewLineTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { + return this.item.kind() === 8 /* SkippedTokenTrivia */; + }; + + SingletonSyntaxTriviaList.prototype.toJSON = function (key) { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { + this.item.collectTextElements(elements); + }; + + SingletonSyntaxTriviaList.prototype.toArray = function () { + return [this.item]; + }; + + SingletonSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return SingletonSyntaxTriviaList; + })(); + + var NormalSyntaxTriviaList = (function () { + function NormalSyntaxTriviaList(trivia) { + this.trivia = trivia; + } + NormalSyntaxTriviaList.prototype.kind = function () { + return 3 /* TriviaList */; + }; + + NormalSyntaxTriviaList.prototype.count = function () { + return this.trivia.length; + }; + + NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { + if (index < 0 || index >= this.trivia.length) { + throw TypeScript.Errors.argumentOutOfRange("index"); + } + + return this.trivia[index]; + }; + + NormalSyntaxTriviaList.prototype.last = function () { + return this.trivia[this.trivia.length - 1]; + }; + + NormalSyntaxTriviaList.prototype.fullWidth = function () { + return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { + return t.fullWidth(); + }); + }; + + NormalSyntaxTriviaList.prototype.fullText = function () { + var result = ""; + + for (var i = 0, n = this.trivia.length; i < n; i++) { + result += this.trivia[i].fullText(); + } + + return result; + }; + + NormalSyntaxTriviaList.prototype.hasComment = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (isComment(this.trivia[i])) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasNewLine = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { + for (var i = 0; i < this.trivia.length; i++) { + if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + return true; + } + } + + return false; + }; + + NormalSyntaxTriviaList.prototype.toJSON = function (key) { + return this.trivia; + }; + + NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { + for (var i = 0; i < this.trivia.length; i++) { + this.trivia[i].collectTextElements(elements); + } + }; + + NormalSyntaxTriviaList.prototype.toArray = function () { + return this.trivia.slice(0); + }; + + NormalSyntaxTriviaList.prototype.concat = function (trivia) { + return concatTrivia(this, trivia); + }; + return NormalSyntaxTriviaList; + })(); + + function triviaList(trivia) { + if (trivia === undefined || trivia === null || trivia.length === 0) { + return Syntax.emptyTriviaList; + } + + if (trivia.length === 1) { + return new SingletonSyntaxTriviaList(trivia[0]); + } + + return new NormalSyntaxTriviaList(trivia); + } + Syntax.triviaList = triviaList; + + Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); + })(TypeScript.Syntax || (TypeScript.Syntax = {})); + var Syntax = TypeScript.Syntax; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxUtilities = (function () { + function SyntaxUtilities() { + } + SyntaxUtilities.isAngleBracket = function (positionedElement) { + var element = positionedElement.element(); + var parent = positionedElement.parentElement(); + if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + switch (parent.kind()) { + case 228 /* TypeArgumentList */: + case 229 /* TypeParameterList */: + case 220 /* CastExpression */: + return true; + } + } + + return false; + }; + + SyntaxUtilities.getToken = function (list, kind) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var token = list.childAt(i); + if (token.tokenKind === kind) { + return token; + } + } + + return null; + }; + + SyntaxUtilities.containsToken = function (list, kind) { + return SyntaxUtilities.getToken(list, kind) !== null; + }; + + SyntaxUtilities.hasExportKeyword = function (moduleElement) { + return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + }; + + SyntaxUtilities.getExportKeyword = function (moduleElement) { + switch (moduleElement.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + case 128 /* InterfaceDeclaration */: + case 133 /* ImportDeclaration */: + return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); + default: + return null; + } + }; + + SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { + if (!positionNode) { + return false; + } + + var node = positionNode.node(); + switch (node.kind()) { + case 130 /* ModuleDeclaration */: + case 131 /* ClassDeclaration */: + case 129 /* FunctionDeclaration */: + case 148 /* VariableStatement */: + case 132 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + return true; + } + + case 133 /* ImportDeclaration */: + case 137 /* ConstructorDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + case 136 /* MemberVariableDeclaration */: + if (node.isClassElement() || node.isModuleElement()) { + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + + case 243 /* EnumElement */: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); + + default: + return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); + } + }; + return SyntaxUtilities; + })(); + TypeScript.SyntaxUtilities = SyntaxUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxVisitor = (function () { + function SyntaxVisitor() { + } + SyntaxVisitor.prototype.defaultVisit = function (node) { + return null; + }; + + SyntaxVisitor.prototype.visitToken = function (token) { + return this.defaultVisit(token); + }; + + SyntaxVisitor.prototype.visitSourceUnit = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitImportDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExportAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitClassDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitHeritageClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitOmittedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitQualifiedName = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArrayType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGenericType = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeQuery = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBlock = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitInvocationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitArgumentList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBinaryExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConditionalExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMethodSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitPropertySignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCallSignature = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameterList = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeParameter = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstraint = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitElseClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIfStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitExpressionStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitGetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSetAccessor = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitThrowStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitReturnStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSwitchStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitBreakStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitContinueStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitForInStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWhileStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitWithStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEnumElement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCastExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFunctionExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitEmptyStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTryStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitCatchClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitFinallyClause = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitLabeledStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDoStatement = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDeleteExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitVoidExpression = function (node) { + return this.defaultVisit(node); + }; + + SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { + return this.defaultVisit(node); + }; + return SyntaxVisitor; + })(); + TypeScript.SyntaxVisitor = SyntaxVisitor; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxWalker = (function () { + function SyntaxWalker() { + } + SyntaxWalker.prototype.visitToken = function (token) { + }; + + SyntaxWalker.prototype.visitNode = function (node) { + node.accept(this); + }; + + SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { + if (nodeOrToken.isToken()) { + this.visitToken(nodeOrToken); + } else { + this.visitNode(nodeOrToken); + } + }; + + SyntaxWalker.prototype.visitOptionalToken = function (token) { + if (token === null) { + return; + } + + this.visitToken(token); + }; + + SyntaxWalker.prototype.visitOptionalNode = function (node) { + if (node === null) { + return; + } + + this.visitNode(node); + }; + + SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { + if (nodeOrToken === null) { + return; + } + + this.visitNodeOrToken(nodeOrToken); + }; + + SyntaxWalker.prototype.visitList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.visitNodeOrToken(list.childAt(i)); + } + }; + + SyntaxWalker.prototype.visitSeparatedList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + var item = list.childAt(i); + this.visitNodeOrToken(item); + } + }; + + SyntaxWalker.prototype.visitSourceUnit = function (node) { + this.visitList(node.moduleElements); + this.visitToken(node.endOfFileToken); + }; + + SyntaxWalker.prototype.visitExternalModuleReference = function (node) { + this.visitToken(node.requireKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.stringLiteral); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { + this.visitNodeOrToken(node.moduleName); + }; + + SyntaxWalker.prototype.visitImportDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.importKeyword); + this.visitToken(node.identifier); + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.moduleReference); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitExportAssignment = function (node) { + this.visitToken(node.exportKeyword); + this.visitToken(node.equalsToken); + this.visitToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitClassDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.classKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitToken(node.openBraceToken); + this.visitList(node.classElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.interfaceKeyword); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeParameterList); + this.visitList(node.heritageClauses); + this.visitNode(node.body); + }; + + SyntaxWalker.prototype.visitHeritageClause = function (node) { + this.visitToken(node.extendsOrImplementsKeyword); + this.visitSeparatedList(node.typeNames); + }; + + SyntaxWalker.prototype.visitModuleDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.moduleKeyword); + this.visitOptionalNodeOrToken(node.name); + this.visitOptionalToken(node.stringLiteral); + this.visitToken(node.openBraceToken); + this.visitList(node.moduleElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.functionKeyword); + this.visitToken(node.identifier); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableStatement = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclaration); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitVariableDeclaration = function (node) { + this.visitToken(node.varKeyword); + this.visitSeparatedList(node.variableDeclarators); + }; + + SyntaxWalker.prototype.visitVariableDeclarator = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitEqualsValueClause = function (node) { + this.visitToken(node.equalsToken); + this.visitNodeOrToken(node.value); + }; + + SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.operand); + }; + + SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { + this.visitToken(node.openBracketToken); + this.visitSeparatedList(node.expressions); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitOmittedExpression = function (node) { + }; + + SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + this.visitNode(node.callSignature); + this.visitToken(node.equalsGreaterThanToken); + this.visitOptionalNode(node.block); + this.visitOptionalNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitQualifiedName = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.dotToken); + this.visitToken(node.right); + }; + + SyntaxWalker.prototype.visitTypeArgumentList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeArguments); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitConstructorType = function (node) { + this.visitToken(node.newKeyword); + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitFunctionType = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitToken(node.equalsGreaterThanToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitObjectType = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.typeMembers); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitArrayType = function (node) { + this.visitNodeOrToken(node.type); + this.visitToken(node.openBracketToken); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitGenericType = function (node) { + this.visitNodeOrToken(node.name); + this.visitNode(node.typeArgumentList); + }; + + SyntaxWalker.prototype.visitTypeQuery = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.name); + }; + + SyntaxWalker.prototype.visitTypeAnnotation = function (node) { + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitBlock = function (node) { + this.visitToken(node.openBraceToken); + this.visitList(node.statements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitParameter = function (node) { + this.visitOptionalToken(node.dotDotDotToken); + this.visitList(node.modifiers); + this.visitToken(node.identifier); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.dotToken); + this.visitToken(node.name); + }; + + SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { + this.visitNodeOrToken(node.operand); + this.visitToken(node.operatorToken); + }; + + SyntaxWalker.prototype.visitElementAccessExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.openBracketToken); + this.visitNodeOrToken(node.argumentExpression); + this.visitToken(node.closeBracketToken); + }; + + SyntaxWalker.prototype.visitInvocationExpression = function (node) { + this.visitNodeOrToken(node.expression); + this.visitNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitArgumentList = function (node) { + this.visitOptionalNode(node.typeArgumentList); + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.arguments); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitBinaryExpression = function (node) { + this.visitNodeOrToken(node.left); + this.visitToken(node.operatorToken); + this.visitNodeOrToken(node.right); + }; + + SyntaxWalker.prototype.visitConditionalExpression = function (node) { + this.visitNodeOrToken(node.condition); + this.visitToken(node.questionToken); + this.visitNodeOrToken(node.whenTrue); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.whenFalse); + }; + + SyntaxWalker.prototype.visitConstructSignature = function (node) { + this.visitToken(node.newKeyword); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitMethodSignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitNode(node.callSignature); + }; + + SyntaxWalker.prototype.visitIndexSignature = function (node) { + this.visitToken(node.openBracketToken); + this.visitNode(node.parameter); + this.visitToken(node.closeBracketToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitPropertySignature = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalToken(node.questionToken); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitCallSignature = function (node) { + this.visitOptionalNode(node.typeParameterList); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + }; + + SyntaxWalker.prototype.visitParameterList = function (node) { + this.visitToken(node.openParenToken); + this.visitSeparatedList(node.parameters); + this.visitToken(node.closeParenToken); + }; + + SyntaxWalker.prototype.visitTypeParameterList = function (node) { + this.visitToken(node.lessThanToken); + this.visitSeparatedList(node.typeParameters); + this.visitToken(node.greaterThanToken); + }; + + SyntaxWalker.prototype.visitTypeParameter = function (node) { + this.visitToken(node.identifier); + this.visitOptionalNode(node.constraint); + }; + + SyntaxWalker.prototype.visitConstraint = function (node) { + this.visitToken(node.extendsKeyword); + this.visitNodeOrToken(node.type); + }; + + SyntaxWalker.prototype.visitElseClause = function (node) { + this.visitToken(node.elseKeyword); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitIfStatement = function (node) { + this.visitToken(node.ifKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + this.visitOptionalNode(node.elseClause); + }; + + SyntaxWalker.prototype.visitExpressionStatement = function (node) { + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.constructorKeyword); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitOptionalNode(node.block); + this.visitOptionalToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitGetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.getKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitOptionalNode(node.typeAnnotation); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitSetAccessor = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.setKeyword); + this.visitToken(node.propertyName); + this.visitNode(node.parameterList); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.variableDeclarator); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitNode(node.indexSignature); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitThrowStatement = function (node) { + this.visitToken(node.throwKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitReturnStatement = function (node) { + this.visitToken(node.returnKeyword); + this.visitOptionalNodeOrToken(node.expression); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { + this.visitToken(node.newKeyword); + this.visitNodeOrToken(node.expression); + this.visitOptionalNode(node.argumentList); + }; + + SyntaxWalker.prototype.visitSwitchStatement = function (node) { + this.visitToken(node.switchKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitToken(node.openBraceToken); + this.visitList(node.switchClauses); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { + this.visitToken(node.caseKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { + this.visitToken(node.defaultKeyword); + this.visitToken(node.colonToken); + this.visitList(node.statements); + }; + + SyntaxWalker.prototype.visitBreakStatement = function (node) { + this.visitToken(node.breakKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitContinueStatement = function (node) { + this.visitToken(node.continueKeyword); + this.visitOptionalToken(node.identifier); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitForStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.initializer); + this.visitToken(node.firstSemicolonToken); + this.visitOptionalNodeOrToken(node.condition); + this.visitToken(node.secondSemicolonToken); + this.visitOptionalNodeOrToken(node.incrementor); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitForInStatement = function (node) { + this.visitToken(node.forKeyword); + this.visitToken(node.openParenToken); + this.visitOptionalNode(node.variableDeclaration); + this.visitOptionalNodeOrToken(node.left); + this.visitToken(node.inKeyword); + this.visitNodeOrToken(node.expression); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWhileStatement = function (node) { + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitWithStatement = function (node) { + this.visitToken(node.withKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitEnumDeclaration = function (node) { + this.visitList(node.modifiers); + this.visitToken(node.enumKeyword); + this.visitToken(node.identifier); + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.enumElements); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitEnumElement = function (node) { + this.visitToken(node.propertyName); + this.visitOptionalNode(node.equalsValueClause); + }; + + SyntaxWalker.prototype.visitCastExpression = function (node) { + this.visitToken(node.lessThanToken); + this.visitNodeOrToken(node.type); + this.visitToken(node.greaterThanToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { + this.visitToken(node.openBraceToken); + this.visitSeparatedList(node.propertyAssignments); + this.visitToken(node.closeBraceToken); + }; + + SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { + this.visitToken(node.propertyName); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFunctionExpression = function (node) { + this.visitToken(node.functionKeyword); + this.visitOptionalToken(node.identifier); + this.visitNode(node.callSignature); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitEmptyStatement = function (node) { + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTryStatement = function (node) { + this.visitToken(node.tryKeyword); + this.visitNode(node.block); + this.visitOptionalNode(node.catchClause); + this.visitOptionalNode(node.finallyClause); + }; + + SyntaxWalker.prototype.visitCatchClause = function (node) { + this.visitToken(node.catchKeyword); + this.visitToken(node.openParenToken); + this.visitToken(node.identifier); + this.visitOptionalNode(node.typeAnnotation); + this.visitToken(node.closeParenToken); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitFinallyClause = function (node) { + this.visitToken(node.finallyKeyword); + this.visitNode(node.block); + }; + + SyntaxWalker.prototype.visitLabeledStatement = function (node) { + this.visitToken(node.identifier); + this.visitToken(node.colonToken); + this.visitNodeOrToken(node.statement); + }; + + SyntaxWalker.prototype.visitDoStatement = function (node) { + this.visitToken(node.doKeyword); + this.visitNodeOrToken(node.statement); + this.visitToken(node.whileKeyword); + this.visitToken(node.openParenToken); + this.visitNodeOrToken(node.condition); + this.visitToken(node.closeParenToken); + this.visitToken(node.semicolonToken); + }; + + SyntaxWalker.prototype.visitTypeOfExpression = function (node) { + this.visitToken(node.typeOfKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDeleteExpression = function (node) { + this.visitToken(node.deleteKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitVoidExpression = function (node) { + this.visitToken(node.voidKeyword); + this.visitNodeOrToken(node.expression); + }; + + SyntaxWalker.prototype.visitDebuggerStatement = function (node) { + this.visitToken(node.debuggerKeyword); + this.visitToken(node.semicolonToken); + }; + return SyntaxWalker; + })(); + TypeScript.SyntaxWalker = SyntaxWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PositionTrackingWalker = (function (_super) { + __extends(PositionTrackingWalker, _super); + function PositionTrackingWalker() { + _super.apply(this, arguments); + this._position = 0; + } + PositionTrackingWalker.prototype.visitToken = function (token) { + this._position += token.fullWidth(); + }; + + PositionTrackingWalker.prototype.position = function () { + return this._position; + }; + + PositionTrackingWalker.prototype.skip = function (element) { + this._position += element.fullWidth(); + }; + return PositionTrackingWalker; + })(TypeScript.SyntaxWalker); + TypeScript.PositionTrackingWalker = PositionTrackingWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxInformationMap = (function (_super) { + __extends(SyntaxInformationMap, _super); + function SyntaxInformationMap(trackParents, trackPreviousToken) { + _super.call(this); + this.trackParents = trackParents; + this.trackPreviousToken = trackPreviousToken; + this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._previousToken = null; + this._previousTokenInformation = null; + this._currentPosition = 0; + this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + this._parentStack = []; + this._parentStack.push(null); + } + SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { + var map = new SyntaxInformationMap(trackParents, trackPreviousToken); + map.visitNode(node); + return map; + }; + + SyntaxInformationMap.prototype.visitNode = function (node) { + this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); + this.elementToPosition.add(node, this._currentPosition); + + this.trackParents && this._parentStack.push(node); + _super.prototype.visitNode.call(this, node); + this.trackParents && this._parentStack.pop(); + }; + + SyntaxInformationMap.prototype.visitToken = function (token) { + this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); + + if (this.trackPreviousToken) { + var tokenInformation = { + previousToken: this._previousToken, + nextToken: null + }; + + if (this._previousTokenInformation !== null) { + this._previousTokenInformation.nextToken = token; + } + + this._previousToken = token; + this._previousTokenInformation = tokenInformation; + + this.tokenToInformation.add(token, tokenInformation); + } + + this.elementToPosition.add(token, this._currentPosition); + this._currentPosition += token.fullWidth(); + }; + + SyntaxInformationMap.prototype.parent = function (element) { + return this._elementToParent.get(element); + }; + + SyntaxInformationMap.prototype.fullStart = function (element) { + return this.elementToPosition.get(element); + }; + + SyntaxInformationMap.prototype.start = function (element) { + return this.fullStart(element) + element.leadingTriviaWidth(); + }; + + SyntaxInformationMap.prototype.end = function (element) { + return this.start(element) + element.width(); + }; + + SyntaxInformationMap.prototype.previousToken = function (token) { + return this.tokenInformation(token).previousToken; + }; + + SyntaxInformationMap.prototype.tokenInformation = function (token) { + return this.tokenToInformation.get(token); + }; + + SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { + var current = token; + while (true) { + var information = this.tokenInformation(current); + if (this.isFirstTokenInLineWorker(information)) { + break; + } + + current = information.previousToken; + } + + return current; + }; + + SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { + var information = this.tokenInformation(token); + return this.isFirstTokenInLineWorker(information); + }; + + SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { + return information.previousToken === null || information.previousToken.hasTrailingNewLine(); + }; + return SyntaxInformationMap; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxInformationMap = SyntaxInformationMap; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxNodeInvariantsChecker = (function (_super) { + __extends(SyntaxNodeInvariantsChecker, _super); + function SyntaxNodeInvariantsChecker() { + _super.apply(this, arguments); + this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); + } + SyntaxNodeInvariantsChecker.checkInvariants = function (node) { + node.accept(new SyntaxNodeInvariantsChecker()); + }; + + SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { + this.tokenTable.add(token, token); + }; + return SyntaxNodeInvariantsChecker; + })(TypeScript.SyntaxWalker); + TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DepthLimitedWalker = (function (_super) { + __extends(DepthLimitedWalker, _super); + function DepthLimitedWalker(maximumDepth) { + _super.call(this); + this._depth = 0; + this._maximumDepth = 0; + this._maximumDepth = maximumDepth; + } + DepthLimitedWalker.prototype.visitNode = function (node) { + if (this._depth < this._maximumDepth) { + this._depth++; + _super.prototype.visitNode.call(this, node); + this._depth--; + } else { + this.skip(node); + } + }; + return DepthLimitedWalker; + })(TypeScript.PositionTrackingWalker); + TypeScript.DepthLimitedWalker = DepthLimitedWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (Parser) { + + + var ExpressionPrecedence; + (function (ExpressionPrecedence) { + ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; + ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; + ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; + + ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; + })(ExpressionPrecedence || (ExpressionPrecedence = {})); + + var ListParsingState; + (function (ListParsingState) { + ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; + ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; + ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; + ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; + ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; + ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; + ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; + ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; + ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; + ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; + ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; + ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; + ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; + ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; + ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; + ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; + ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; + ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; + ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; + + ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; + ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; + })(ListParsingState || (ListParsingState = {})); + + var SyntaxCursor = (function () { + function SyntaxCursor(sourceUnit) { + this._elements = []; + this._index = 0; + this._pinCount = 0; + sourceUnit.insertChildrenInto(this._elements, 0); + } + SyntaxCursor.prototype.isFinished = function () { + return this._index === this._elements.length; + }; + + SyntaxCursor.prototype.currentElement = function () { + if (this.isFinished()) { + return null; + } + + return this._elements[this._index]; + }; + + SyntaxCursor.prototype.currentNode = function () { + var element = this.currentElement(); + return element !== null && element.isNode() ? element : null; + }; + + SyntaxCursor.prototype.moveToFirstChild = function () { + if (this.isFinished()) { + return; + } + + var element = this._elements[this._index]; + if (element.isToken()) { + return; + } + + var node = element; + + this._elements.splice(this._index, 1); + + node.insertChildrenInto(this._elements, this._index); + }; + + SyntaxCursor.prototype.moveToNextSibling = function () { + if (this.isFinished()) { + return; + } + + if (this._pinCount > 0) { + this._index++; + return; + } + + this._elements.shift(); + }; + + SyntaxCursor.prototype.getAndPinCursorIndex = function () { + this._pinCount++; + return this._index; + }; + + SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { + this._pinCount--; + if (this._pinCount === 0) { + } + }; + + SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { + this._index = index; + }; + + SyntaxCursor.prototype.pinCount = function () { + return this._pinCount; + }; + + SyntaxCursor.prototype.moveToFirstToken = function () { + var element; + + while (!this.isFinished()) { + element = this.currentElement(); + if (element.isNode()) { + this.moveToFirstChild(); + continue; + } + + return; + } + }; + + SyntaxCursor.prototype.currentToken = function () { + this.moveToFirstToken(); + if (this.isFinished()) { + return null; + } + + var element = this.currentElement(); + + return element; + }; + + SyntaxCursor.prototype.peekToken = function (n) { + this.moveToFirstToken(); + var pin = this.getAndPinCursorIndex(); + + for (var i = 0; i < n; i++) { + this.moveToNextSibling(); + this.moveToFirstToken(); + } + + var result = this.currentToken(); + this.rewindToPinnedCursorIndex(pin); + this.releaseAndUnpinCursorIndex(pin); + + return result; + }; + return SyntaxCursor; + })(); + + + + var NormalParserSource = (function () { + function NormalParserSource(fileName, text, languageVersion) { + this._previousToken = null; + this._absolutePosition = 0; + this._tokenDiagnostics = []; + this.rewindPointPool = []; + this.rewindPointPoolCount = 0; + this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); + this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); + } + NormalParserSource.prototype.currentNode = function () { + return null; + }; + + NormalParserSource.prototype.moveToNextNode = function () { + throw TypeScript.Errors.invalidOperation(); + }; + + NormalParserSource.prototype.absolutePosition = function () { + return this._absolutePosition; + }; + + NormalParserSource.prototype.previousToken = function () { + return this._previousToken; + }; + + NormalParserSource.prototype.tokenDiagnostics = function () { + return this._tokenDiagnostics; + }; + + NormalParserSource.prototype.getOrCreateRewindPoint = function () { + if (this.rewindPointPoolCount === 0) { + return {}; + } + + this.rewindPointPoolCount--; + var result = this.rewindPointPool[this.rewindPointPoolCount]; + this.rewindPointPool[this.rewindPointPoolCount] = null; + return result; + }; + + NormalParserSource.prototype.getRewindPoint = function () { + var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); + + var rewindPoint = this.getOrCreateRewindPoint(); + + rewindPoint.slidingWindowIndex = slidingWindowIndex; + rewindPoint.previousToken = this._previousToken; + rewindPoint.absolutePosition = this._absolutePosition; + + rewindPoint.pinCount = this.slidingWindow.pinCount(); + + return rewindPoint; + }; + + NormalParserSource.prototype.isPinned = function () { + return this.slidingWindow.pinCount() > 0; + }; + + NormalParserSource.prototype.rewind = function (rewindPoint) { + this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); + + this._previousToken = rewindPoint.previousToken; + this._absolutePosition = rewindPoint.absolutePosition; + }; + + NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); + + this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; + this.rewindPointPoolCount++; + }; + + NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { + window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); + return 1; + }; + + NormalParserSource.prototype.peekToken = function (n) { + return this.slidingWindow.peekItemN(n); + }; + + NormalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + this._absolutePosition += currentToken.fullWidth(); + this._previousToken = currentToken; + + this.slidingWindow.moveToNextItem(); + }; + + NormalParserSource.prototype.currentToken = function () { + return this.slidingWindow.currentItem(false); + }; + + NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { + var tokenDiagnosticsLength = this._tokenDiagnostics.length; + while (tokenDiagnosticsLength > 0) { + var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; + if (diagnostic.start() >= position) { + tokenDiagnosticsLength--; + } else { + break; + } + } + + this._tokenDiagnostics.length = tokenDiagnosticsLength; + }; + + NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { + this._absolutePosition = absolutePosition; + this._previousToken = previousToken; + + this.removeDiagnosticsOnOrAfterPosition(absolutePosition); + + this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); + + this.scanner.setAbsoluteIndex(absolutePosition); + }; + + NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + this.resetToPosition(this._absolutePosition, this._previousToken); + + var token = this.slidingWindow.currentItem(true); + + return token; + }; + return NormalParserSource; + })(); + + var IncrementalParserSource = (function () { + function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { + this._changeDelta = 0; + var oldSourceUnit = oldSyntaxTree.sourceUnit(); + this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); + + this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); + } + + this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); + } + IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { + var maxLookahead = 1; + + var start = changeRange.span().start(); + + for (var i = 0; start > 0 && i <= maxLookahead; i++) { + var token = sourceUnit.findToken(start); + + var position = token.fullStart(); + + start = TypeScript.MathPrototype.max(0, position - 1); + } + + var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); + var finalLength = changeRange.newLength() + (changeRange.span().start() - start); + + return new TypeScript.TextChangeRange(finalSpan, finalLength); + }; + + IncrementalParserSource.prototype.absolutePosition = function () { + return this._normalParserSource.absolutePosition(); + }; + + IncrementalParserSource.prototype.previousToken = function () { + return this._normalParserSource.previousToken(); + }; + + IncrementalParserSource.prototype.tokenDiagnostics = function () { + return this._normalParserSource.tokenDiagnostics(); + }; + + IncrementalParserSource.prototype.getRewindPoint = function () { + var rewindPoint = this._normalParserSource.getRewindPoint(); + var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); + + rewindPoint.changeDelta = this._changeDelta; + rewindPoint.changeRange = this._changeRange; + rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; + + return rewindPoint; + }; + + IncrementalParserSource.prototype.rewind = function (rewindPoint) { + this._changeRange = rewindPoint.changeRange; + this._changeDelta = rewindPoint.changeDelta; + this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + + this._normalParserSource.rewind(rewindPoint); + }; + + IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { + this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); + this._normalParserSource.releaseRewindPoint(rewindPoint); + }; + + IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { + if (this._normalParserSource.isPinned()) { + return false; + } + + if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { + return false; + } + + this.syncCursorToNewTextIfBehind(); + + return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); + }; + + IncrementalParserSource.prototype.currentNode = function () { + if (this.canReadFromOldSourceUnit()) { + return this.tryGetNodeFromOldSourceUnit(); + } + + return null; + }; + + IncrementalParserSource.prototype.currentToken = function () { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryGetTokenFromOldSourceUnit(); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.currentToken(); + }; + + IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { + return this._normalParserSource.currentTokenAllowingRegularExpression(); + }; + + IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { + while (true) { + if (this._oldSourceUnitCursor.isFinished()) { + break; + } + + if (this._changeDelta >= 0) { + break; + } + + var currentElement = this._oldSourceUnitCursor.currentElement(); + + if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { + this._oldSourceUnitCursor.moveToFirstChild(); + } else { + this._oldSourceUnitCursor.moveToNextSibling(); + + this._changeDelta += currentElement.fullWidth(); + } + } + }; + + IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { + return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); + }; + + IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { + while (true) { + var node = this._oldSourceUnitCursor.currentNode(); + if (node === null) { + return null; + } + + if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { + if (!node.isIncrementallyUnusable()) { + return node; + } + } + + this._oldSourceUnitCursor.moveToFirstChild(); + } + }; + + IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { + if (token !== null) { + if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { + if (!token.isIncrementallyUnusable()) { + return true; + } + } + } + + return false; + }; + + IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { + var token = this._oldSourceUnitCursor.currentToken(); + + return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; + }; + + IncrementalParserSource.prototype.peekToken = function (n) { + if (this.canReadFromOldSourceUnit()) { + var token = this.tryPeekTokenFromOldSourceUnit(n); + if (token !== null) { + return token; + } + } + + return this._normalParserSource.peekToken(n); + }; + + IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { + var currentPosition = this.absolutePosition(); + for (var i = 0; i < n; i++) { + var interimToken = this._oldSourceUnitCursor.peekToken(i); + if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { + return null; + } + + currentPosition += interimToken.fullWidth(); + } + + var token = this._oldSourceUnitCursor.peekToken(n); + return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + }; + + IncrementalParserSource.prototype.moveToNextNode = function () { + var currentElement = this._oldSourceUnitCursor.currentElement(); + var currentNode = this._oldSourceUnitCursor.currentNode(); + + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); + var previousToken = currentNode.lastToken(); + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + }; + + IncrementalParserSource.prototype.moveToNextToken = function () { + var currentToken = this.currentToken(); + + if (this._oldSourceUnitCursor.currentToken() === currentToken) { + this._oldSourceUnitCursor.moveToNextSibling(); + + var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); + var previousToken = currentToken; + this._normalParserSource.resetToPosition(absolutePosition, previousToken); + + if (this._changeRange !== null) { + } + } else { + this._changeDelta -= currentToken.fullWidth(); + + this._normalParserSource.moveToNextToken(); + + if (this._changeRange !== null) { + var changeRangeSpanInNewText = this._changeRange.newSpan(); + if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { + this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); + this._changeRange = null; + } + } + } + }; + return IncrementalParserSource; + })(); + + var ParserImpl = (function () { + function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { + this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; + this.listParsingState = 0; + this.isInStrictMode = false; + this.diagnostics = []; + this.factory = TypeScript.Syntax.normalModeFactory; + this.mergeTokensStorage = []; + this.arrayPool = []; + this.fileName = fileName; + this.lineMap = lineMap; + this.source = source; + this.parseOptions = parseOptions; + } + ParserImpl.prototype.getRewindPoint = function () { + var rewindPoint = this.source.getRewindPoint(); + + rewindPoint.diagnosticsCount = this.diagnostics.length; + + rewindPoint.isInStrictMode = this.isInStrictMode; + rewindPoint.listParsingState = this.listParsingState; + + return rewindPoint; + }; + + ParserImpl.prototype.rewind = function (rewindPoint) { + this.source.rewind(rewindPoint); + + this.diagnostics.length = rewindPoint.diagnosticsCount; + }; + + ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { + this.source.releaseRewindPoint(rewindPoint); + }; + + ParserImpl.prototype.currentTokenStart = function () { + return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenStart = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); + }; + + ParserImpl.prototype.previousTokenEnd = function () { + if (this.previousToken() === null) { + return 0; + } + + return this.previousTokenStart() + this.previousToken().width(); + }; + + ParserImpl.prototype.currentNode = function () { + var node = this.source.currentNode(); + + if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { + return null; + } + + return node; + }; + + ParserImpl.prototype.currentToken = function () { + return this.source.currentToken(); + }; + + ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { + return this.source.currentTokenAllowingRegularExpression(); + }; + + ParserImpl.prototype.peekToken = function (n) { + return this.source.peekToken(n); + }; + + ParserImpl.prototype.eatAnyToken = function () { + var token = this.currentToken(); + this.moveToNextToken(); + return token; + }; + + ParserImpl.prototype.moveToNextToken = function () { + this.source.moveToNextToken(); + }; + + ParserImpl.prototype.previousToken = function () { + return this.source.previousToken(); + }; + + ParserImpl.prototype.eatNode = function () { + var node = this.source.currentNode(); + this.source.moveToNextNode(); + return node; + }; + + ParserImpl.prototype.eatToken = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.tryEatToken = function (kind) { + if (this.currentToken().tokenKind === kind) { + return this.eatToken(kind); + } + + return null; + }; + + ParserImpl.prototype.eatKeyword = function (kind) { + var token = this.currentToken(); + if (token.tokenKind === kind) { + this.moveToNextToken(); + return token; + } + + return this.createMissingToken(kind, token); + }; + + ParserImpl.prototype.isIdentifier = function (token) { + var tokenKind = token.tokenKind; + + if (tokenKind === 11 /* IdentifierName */) { + return true; + } + + if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { + if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { + return !this.isInStrictMode; + } + + return tokenKind <= 69 /* LastTypeScriptKeyword */; + } + + return false; + }; + + ParserImpl.prototype.eatIdentifierNameToken = function () { + var token = this.currentToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + this.moveToNextToken(); + return token; + } + + if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { + this.moveToNextToken(); + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.eatIdentifierToken = function () { + var token = this.currentToken(); + if (this.isIdentifier(token)) { + this.moveToNextToken(); + + if (token.tokenKind === 11 /* IdentifierName */) { + return token; + } + + return TypeScript.Syntax.convertToIdentifierName(token); + } + + return this.createMissingToken(11 /* IdentifierName */, token); + }; + + ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { + var token = this.currentToken(); + + if (token.tokenKind === 10 /* EndOfFileToken */) { + return true; + } + + if (token.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + if (allowWithoutNewLine) { + return true; + } + + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return true; + } + + return this.canEatAutomaticSemicolon(allowWithoutNewline); + }; + + ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { + var token = this.currentToken(); + + if (token.tokenKind === 78 /* SemicolonToken */) { + return this.eatToken(78 /* SemicolonToken */); + } + + if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { + var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); + + if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { + this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); + } + + return semicolonToken; + } + + return this.eatToken(78 /* SemicolonToken */); + }; + + ParserImpl.prototype.isKeyword = function (kind) { + if (kind >= 15 /* FirstKeyword */) { + if (kind <= 50 /* LastFutureReservedKeyword */) { + return true; + } + + if (this.isInStrictMode) { + return kind <= 59 /* LastFutureReservedStrictKeyword */; + } + } + + return false; + }; + + ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { + var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); + this.addDiagnostic(diagnostic); + + return TypeScript.Syntax.emptyToken(expectedKind); + }; + + ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { + var token = this.currentToken(); + + if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); + } else { + if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); + } else { + return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); + } + } + }; + + ParserImpl.getPrecedence = function (expressionKind) { + switch (expressionKind) { + case 173 /* CommaExpression */: + return 1 /* CommaExpressionPrecedence */; + + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return 2 /* AssignmentExpressionPrecedence */; + + case 186 /* ConditionalExpression */: + return 3 /* ConditionalExpressionPrecedence */; + + case 187 /* LogicalOrExpression */: + return 5 /* LogicalOrExpressionPrecedence */; + + case 188 /* LogicalAndExpression */: + return 6 /* LogicalAndExpressionPrecedence */; + + case 189 /* BitwiseOrExpression */: + return 7 /* BitwiseOrExpressionPrecedence */; + + case 190 /* BitwiseExclusiveOrExpression */: + return 8 /* BitwiseExclusiveOrExpressionPrecedence */; + + case 191 /* BitwiseAndExpression */: + return 9 /* BitwiseAndExpressionPrecedence */; + + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + return 10 /* EqualityExpressionPrecedence */; + + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + return 11 /* RelationalExpressionPrecedence */; + + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + return 12 /* ShiftExpressionPrecdence */; + + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return 13 /* AdditiveExpressionPrecedence */; + + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + return 14 /* MultiplicativeExpressionPrecedence */; + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 167 /* LogicalNotExpression */: + case 170 /* DeleteExpression */: + case 171 /* TypeOfExpression */: + case 172 /* VoidExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return 15 /* UnaryExpressionPrecedence */; + } + + throw TypeScript.Errors.invalidOperation(); + }; + + ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { + if (nodeOrToken.isToken()) { + return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); + } else if (nodeOrToken.isNode()) { + return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { + var oldToken = node.lastToken(); + var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); + + return node.replaceToken(oldToken, newToken); + }; + + ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { + if (skippedTokens.length > 0) { + var oldToken = node.firstToken(); + var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); + + return node.replaceToken(oldToken, newToken); + } + + return node; + }; + + ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { + var leadingTrivia = []; + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); + } + + this.addTriviaTo(token.leadingTrivia(), leadingTrivia); + + this.returnArray(skippedTokens); + return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { + if (skippedTokens.length === 0) { + this.returnArray(skippedTokens); + return token; + } + + var trailingTrivia = token.trailingTrivia().toArray(); + + for (var i = 0, n = skippedTokens.length; i < n; i++) { + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); + } + + this.returnArray(skippedTokens); + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { + var trailingTrivia = token.trailingTrivia().toArray(); + this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); + + return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); + }; + + ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { + this.addTriviaTo(skippedToken.leadingTrivia(), array); + + var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); + array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); + + this.addTriviaTo(skippedToken.trailingTrivia(), array); + }; + + ParserImpl.prototype.addTriviaTo = function (list, array) { + for (var i = 0, n = list.count(); i < n; i++) { + array.push(list.syntaxTriviaAt(i)); + } + }; + + ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { + var sourceUnit = this.parseSourceUnit(); + + var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); + allDiagnostics.sort(function (a, b) { + return a.start() - b.start(); + }); + + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); + }; + + ParserImpl.prototype.setStrictMode = function (isInStrictMode) { + this.isInStrictMode = isInStrictMode; + this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; + }; + + ParserImpl.prototype.parseSourceUnit = function () { + var savedIsInStrictMode = this.isInStrictMode; + + var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); + var moduleElements = result.list; + + this.setStrictMode(savedIsInStrictMode); + + var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); + sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); + + if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); + } + } + + return sourceUnit; + }; + + ParserImpl.updateStrictModeState = function (parser, items) { + if (!parser.isInStrictMode) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { + return; + } + } + + parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); + } + }; + + ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return true; + } + + var modifierCount = this.modifierCount(); + return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); + }; + + ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isModuleElement()) { + return this.eatNode(); + } + + var modifierCount = this.modifierCount(); + if (this.isImportDeclaration(modifierCount)) { + return this.parseImportDeclaration(); + } else if (this.isExportAssignment()) { + return this.parseExportAssignment(); + } else if (this.isModuleDeclaration(modifierCount)) { + return this.parseModuleDeclaration(); + } else if (this.isInterfaceDeclaration(modifierCount)) { + return this.parseInterfaceDeclaration(); + } else if (this.isClassDeclaration(modifierCount)) { + return this.parseClassDeclaration(); + } else if (this.isEnumDeclaration(modifierCount)) { + return this.parseEnumDeclaration(); + } else if (this.isStatement(inErrorRecovery)) { + return this.parseStatement(inErrorRecovery); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isImportDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseImportDeclaration = function () { + var modifiers = this.parseModifiers(); + var importKeyword = this.eatKeyword(49 /* ImportKeyword */); + var identifier = this.eatIdentifierToken(); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var moduleReference = this.parseModuleReference(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); + }; + + ParserImpl.prototype.isExportAssignment = function () { + return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; + }; + + ParserImpl.prototype.parseExportAssignment = function () { + var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); + var equalsToken = this.eatToken(107 /* EqualsToken */); + var identifier = this.eatIdentifierToken(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); + }; + + ParserImpl.prototype.parseModuleReference = function () { + if (this.isExternalModuleReference()) { + return this.parseExternalModuleReference(); + } else { + return this.parseModuleNameModuleReference(); + } + }; + + ParserImpl.prototype.isExternalModuleReference = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 66 /* RequireKeyword */) { + return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; + } + + return false; + }; + + ParserImpl.prototype.parseExternalModuleReference = function () { + var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var stringLiteral = this.eatToken(14 /* StringLiteral */); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); + }; + + ParserImpl.prototype.parseModuleNameModuleReference = function () { + var name = this.parseName(); + return this.factory.moduleNameModuleReference(name); + }; + + ParserImpl.prototype.parseIdentifierName = function () { + var identifierName = this.eatIdentifierNameToken(); + return identifierName; + }; + + ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { + if (this.currentToken().kind() !== 80 /* LessThanToken */) { + return null; + } + + var lessThanToken; + var greaterThanToken; + var result; + var typeArguments; + + if (!inExpression) { + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + } + + var rewindPoint = this.getRewindPoint(); + + lessThanToken = this.eatToken(80 /* LessThanToken */); + + result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); + typeArguments = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { + this.rewind(rewindPoint); + + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); + + return typeArgumentList; + } + }; + + ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { + switch (kind) { + case 72 /* OpenParenToken */: + case 76 /* DotToken */: + + case 73 /* CloseParenToken */: + case 75 /* CloseBracketToken */: + case 106 /* ColonToken */: + case 78 /* SemicolonToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + case 84 /* EqualsEqualsToken */: + case 87 /* EqualsEqualsEqualsToken */: + case 86 /* ExclamationEqualsToken */: + case 88 /* ExclamationEqualsEqualsToken */: + case 103 /* AmpersandAmpersandToken */: + case 104 /* BarBarToken */: + case 100 /* CaretToken */: + case 98 /* AmpersandToken */: + case 99 /* BarToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseName = function () { + var shouldContinue = this.isIdentifier(this.currentToken()); + var current = this.eatIdentifierToken(); + + while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { + var dotToken = this.eatToken(76 /* DotToken */); + + var currentToken = this.currentToken(); + var identifierName; + + if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { + identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); + } else { + identifierName = this.eatIdentifierNameToken(); + } + + current = this.factory.qualifiedName(current, dotToken, identifierName); + + shouldContinue = identifierName.fullWidth() > 0; + } + + return current; + }; + + ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseEnumDeclaration = function () { + var modifiers = this.parseModifiers(); + var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); + var identifier = this.eatIdentifierToken(); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var enumElements = TypeScript.Syntax.emptySeparatedList; + + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); + enumElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); + }; + + ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return true; + } + + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseEnumElement = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { + return this.eatNode(); + } + + var propertyName = this.eatPropertyName(); + var equalsValueClause = null; + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.enumElement(propertyName, equalsValueClause); + }; + + ParserImpl.isModifier = function (token) { + switch (token.tokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + case 47 /* ExportKeyword */: + case 63 /* DeclareKeyword */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.modifierCount = function () { + var modifierCount = 0; + while (true) { + if (ParserImpl.isModifier(this.peekToken(modifierCount))) { + modifierCount++; + continue; + } + + break; + } + + return modifierCount; + }; + + ParserImpl.prototype.parseModifiers = function () { + var tokens = this.getArray(); + + while (true) { + if (ParserImpl.isModifier(this.currentToken())) { + tokens.push(this.eatAnyToken()); + continue; + } + + break; + } + + var result = TypeScript.Syntax.list(tokens); + + this.returnZeroOrOneLengthArray(tokens); + + return result; + }; + + ParserImpl.prototype.isClassDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseHeritageClauses = function () { + var heritageClauses = TypeScript.Syntax.emptyList; + + if (this.isHeritageClause()) { + var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); + heritageClauses = result.list; + TypeScript.Debug.assert(result.skippedTokens.length === 0); + } + + return heritageClauses; + }; + + ParserImpl.prototype.parseClassDeclaration = function () { + var modifiers = this.parseModifiers(); + + var classKeyword = this.eatKeyword(44 /* ClassKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + var classElements = TypeScript.Syntax.emptyList; + + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); + + classElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); + }; + + ParserImpl.isPublicOrPrivateKeyword = function (token) { + return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; + }; + + ParserImpl.prototype.isAccessor = function (inErrorRecovery) { + var index = this.modifierCount(); + + if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { + return false; + } + + index++; + return this.isPropertyName(this.peekToken(index), inErrorRecovery); + }; + + ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { + var modifiers = this.parseModifiers(); + + if (this.currentToken().tokenKind === 64 /* GetKeyword */) { + return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { + return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var getKeyword = this.eatKeyword(64 /* GetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); + }; + + ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { + var setKeyword = this.eatKeyword(68 /* SetKeyword */); + var propertyName = this.eatPropertyName(); + var parameterList = this.parseParameterList(); + var block = this.parseBlock(false, checkForStrictMode); + + return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); + }; + + ParserImpl.prototype.isClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return true; + } + + return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); + }; + + ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isClassElement()) { + return this.eatNode(); + } + + if (this.isConstructorDeclaration()) { + return this.parseConstructorDeclaration(); + } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { + return this.parseMemberFunctionDeclaration(); + } else if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(false); + } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { + return this.parseMemberVariableDeclaration(); + } else if (this.isIndexMemberDeclaration()) { + return this.parseIndexMemberDeclaration(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isConstructorDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; + }; + + ParserImpl.prototype.parseConstructorDeclaration = function () { + var modifiers = this.parseModifiers(); + var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); + var callSignature = this.parseCallSignature(false); + + var semicolonToken = null; + var block = null; + + if (this.isBlock()) { + block = this.parseBlock(false, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { + return true; + } + + if (ParserImpl.isModifier(token)) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberFunctionDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var block = null; + var semicolon = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolon = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); + }; + + ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { + if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { + switch (this.peekToken(index + 1).tokenKind) { + case 78 /* SemicolonToken */: + case 107 /* EqualsToken */: + case 106 /* ColonToken */: + case 71 /* CloseBraceToken */: + case 10 /* EndOfFileToken */: + return true; + default: + return false; + } + } else { + return true; + } + }; + + ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { + var index = 0; + + while (true) { + var token = this.peekToken(index); + if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { + return true; + } + + if (ParserImpl.isModifier(this.peekToken(index))) { + index++; + continue; + } + + return false; + } + }; + + ParserImpl.prototype.parseMemberVariableDeclaration = function () { + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { + break; + } + + TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); + modifierArray.push(this.eatAnyToken()); + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var variableDeclarator = this.parseVariableDeclarator(true, true); + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); + }; + + ParserImpl.prototype.isIndexMemberDeclaration = function () { + var index = this.modifierCount(); + return this.isIndexSignature(index); + }; + + ParserImpl.prototype.parseIndexMemberDeclaration = function () { + var modifiers = this.parseModifiers(); + var indexSignature = this.parseIndexSignature(); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); + }; + + ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { + var token0 = this.currentToken(); + + var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; + if (hasEqualsGreaterThanToken) { + if (callSignature.lastToken()) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + this.addDiagnostic(diagnostic); + + var token = this.eatAnyToken(); + return this.addSkippedTokenAfterNode(callSignature, token0); + } + } + + return callSignature; + }; + + ParserImpl.prototype.isFunctionDeclaration = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; + }; + + ParserImpl.prototype.parseFunctionDeclaration = function () { + var modifiers = this.parseModifiers(); + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = this.eatIdentifierToken(); + var callSignature = this.parseCallSignature(false); + + var parseBlockEvenWithNoOpenBrace = false; + var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); + if (newCallSignature !== callSignature) { + parseBlockEvenWithNoOpenBrace = true; + callSignature = newCallSignature; + } + + var semicolonToken = null; + var block = null; + + if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { + block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); + } else { + semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + } + + return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + }; + + ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { + return true; + } + + if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { + var token1 = this.peekToken(1); + return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; + } + + return false; + }; + + ParserImpl.prototype.parseModuleDeclaration = function () { + var modifiers = this.parseModifiers(); + var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); + + var moduleName = null; + var stringLiteral = null; + + if (this.currentToken().tokenKind === 14 /* StringLiteral */) { + stringLiteral = this.eatToken(14 /* StringLiteral */); + } else { + moduleName = this.parseName(); + } + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var moduleElements = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); + moduleElements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); + }; + + ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { + if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { + return true; + } + + return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); + }; + + ParserImpl.prototype.parseInterfaceDeclaration = function () { + var modifiers = this.parseModifiers(); + var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); + var identifier = this.eatIdentifierToken(); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var heritageClauses = this.parseHeritageClauses(); + + var objectType = this.parseObjectType(); + return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); + }; + + ParserImpl.prototype.parseObjectType = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var typeMembers = TypeScript.Syntax.emptySeparatedList; + if (openBraceToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); + typeMembers = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); + }; + + ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return true; + } + + return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); + }; + + ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isTypeMember()) { + return this.eatNode(); + } + + if (this.isCallSignature(0)) { + return this.parseCallSignature(false); + } else if (this.isConstructSignature()) { + return this.parseConstructSignature(); + } else if (this.isIndexSignature(0)) { + return this.parseIndexSignature(); + } else if (this.isMethodSignature(inErrorRecovery)) { + return this.parseMethodSignature(); + } else if (this.isPropertySignature(inErrorRecovery)) { + return this.parsePropertySignature(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseConstructSignature = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var callSignature = this.parseCallSignature(false); + + return this.factory.constructSignature(newKeyword, callSignature); + }; + + ParserImpl.prototype.parseIndexSignature = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var parameter = this.parseParameter(); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); + }; + + ParserImpl.prototype.parseMethodSignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var callSignature = this.parseCallSignature(false); + + return this.factory.methodSignature(propertyName, questionToken, callSignature); + }; + + ParserImpl.prototype.parsePropertySignature = function () { + var propertyName = this.eatPropertyName(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); + }; + + ParserImpl.prototype.isCallSignature = function (tokenIndex) { + var tokenKind = this.peekToken(tokenIndex).tokenKind; + return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + }; + + ParserImpl.prototype.isConstructSignature = function () { + if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { + return false; + } + + var token1 = this.peekToken(1); + return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; + }; + + ParserImpl.prototype.isIndexSignature = function (tokenIndex) { + return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; + }; + + ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { + if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { + if (this.isCallSignature(1)) { + return true; + } + + if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { + var currentToken = this.currentToken(); + + if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { + return false; + } + + return this.isPropertyName(currentToken, inErrorRecovery); + }; + + ParserImpl.prototype.isHeritageClause = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; + }; + + ParserImpl.prototype.isNotHeritageClauseTypeName = function () { + if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { + return this.isIdentifier(this.peekToken(1)); + } + + return false; + }; + + ParserImpl.prototype.isHeritageClauseTypeName = function () { + if (this.isIdentifier(this.currentToken())) { + return !this.isNotHeritageClauseTypeName(); + } + + return false; + }; + + ParserImpl.prototype.parseHeritageClause = function () { + var extendsOrImplementsKeyword = this.eatAnyToken(); + TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + + var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); + var typeNames = result.list; + extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); + + return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); + }; + + ParserImpl.prototype.isStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return true; + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 57 /* PublicKeyword */: + case 55 /* PrivateKeyword */: + case 58 /* StaticKeyword */: + var token1 = this.peekToken(1); + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { + return false; + } + + break; + + case 28 /* IfKeyword */: + case 70 /* OpenBraceToken */: + case 33 /* ReturnKeyword */: + case 34 /* SwitchKeyword */: + case 36 /* ThrowKeyword */: + case 15 /* BreakKeyword */: + case 18 /* ContinueKeyword */: + case 26 /* ForKeyword */: + case 42 /* WhileKeyword */: + case 43 /* WithKeyword */: + case 22 /* DoKeyword */: + case 38 /* TryKeyword */: + case 19 /* DebuggerKeyword */: + return true; + } + + if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { + return false; + } + + return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); + }; + + ParserImpl.prototype.parseStatement = function (inErrorRecovery) { + if (this.currentNode() !== null && this.currentNode().isStatement()) { + return this.eatNode(); + } + + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 28 /* IfKeyword */: + return this.parseIfStatement(); + case 70 /* OpenBraceToken */: + return this.parseBlock(false, false); + case 33 /* ReturnKeyword */: + return this.parseReturnStatement(); + case 34 /* SwitchKeyword */: + return this.parseSwitchStatement(); + case 36 /* ThrowKeyword */: + return this.parseThrowStatement(); + case 15 /* BreakKeyword */: + return this.parseBreakStatement(); + case 18 /* ContinueKeyword */: + return this.parseContinueStatement(); + case 26 /* ForKeyword */: + return this.parseForOrForInStatement(); + case 42 /* WhileKeyword */: + return this.parseWhileStatement(); + case 43 /* WithKeyword */: + return this.parseWithStatement(); + case 22 /* DoKeyword */: + return this.parseDoStatement(); + case 38 /* TryKeyword */: + return this.parseTryStatement(); + case 19 /* DebuggerKeyword */: + return this.parseDebuggerStatement(); + } + + if (this.isVariableStatement()) { + return this.parseVariableStatement(); + } else if (this.isLabeledStatement(currentToken)) { + return this.parseLabeledStatement(); + } else if (this.isFunctionDeclaration()) { + return this.parseFunctionDeclaration(); + } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { + return this.parseEmptyStatement(); + } else { + return this.parseExpressionStatement(); + } + }; + + ParserImpl.prototype.parseDebuggerStatement = function () { + var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); + }; + + ParserImpl.prototype.parseDoStatement = function () { + var doKeyword = this.eatKeyword(22 /* DoKeyword */); + var statement = this.parseStatement(false); + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); + + return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); + }; + + ParserImpl.prototype.isLabeledStatement = function (currentToken) { + return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseLabeledStatement = function () { + var identifier = this.eatIdentifierToken(); + var colonToken = this.eatToken(106 /* ColonToken */); + var statement = this.parseStatement(false); + + return this.factory.labeledStatement(identifier, colonToken, statement); + }; + + ParserImpl.prototype.parseTryStatement = function () { + var tryKeyword = this.eatKeyword(38 /* TryKeyword */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 64 /* TryBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + var catchClause = null; + if (this.isCatchClause()) { + catchClause = this.parseCatchClause(); + } + + var finallyClause = null; + if (catchClause === null || this.isFinallyClause()) { + finallyClause = this.parseFinallyClause(); + } + + return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); + }; + + ParserImpl.prototype.isCatchClause = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */; + }; + + ParserImpl.prototype.parseCatchClause = function () { + var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var identifier = this.eatIdentifierToken(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var savedListParsingState = this.listParsingState; + this.listParsingState |= 128 /* CatchBlock_Statements */; + var block = this.parseBlock(false, false); + this.listParsingState = savedListParsingState; + + return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); + }; + + ParserImpl.prototype.isFinallyClause = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.parseFinallyClause = function () { + var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); + var block = this.parseBlock(false, false); + + return this.factory.finallyClause(finallyKeyword, block); + }; + + ParserImpl.prototype.parseWithStatement = function () { + var withKeyword = this.eatKeyword(43 /* WithKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.parseWhileStatement = function () { + var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); + }; + + ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { + if (inErrorRecovery) { + return false; + } + + return currentToken.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.parseEmptyStatement = function () { + var semicolonToken = this.eatToken(78 /* SemicolonToken */); + return this.factory.emptyStatement(semicolonToken); + }; + + ParserImpl.prototype.parseForOrForInStatement = function () { + var forKeyword = this.eatKeyword(26 /* ForKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 40 /* VarKeyword */) { + return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); + } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { + return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); + } else { + return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); + } + }; + + ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { + var variableDeclaration = this.parseVariableDeclaration(false); + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + } + + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + }; + + ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var inKeyword = this.eatKeyword(29 /* InKeyword */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); + }; + + ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { + var initializer = this.parseExpression(false); + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } else { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + } + }; + + ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { + return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); + }; + + ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { + var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var condition = null; + if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + condition = this.parseExpression(true); + } + + var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); + + var incrementor = null; + if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { + incrementor = this.parseExpression(true); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); + }; + + ParserImpl.prototype.parseBreakStatement = function () { + var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.breakStatement(breakKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseContinueStatement = function () { + var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); + + var identifier = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + } + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + return this.factory.continueStatement(continueKeyword, identifier, semicolon); + }; + + ParserImpl.prototype.parseSwitchStatement = function () { + var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var switchClauses = TypeScript.Syntax.emptyList; + if (openBraceToken.width() > 0) { + var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); + switchClauses = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); + }; + + ParserImpl.prototype.isCaseSwitchClause = function () { + return this.currentToken().tokenKind === 16 /* CaseKeyword */; + }; + + ParserImpl.prototype.isDefaultSwitchClause = function () { + return this.currentToken().tokenKind === 20 /* DefaultKeyword */; + }; + + ParserImpl.prototype.isSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return true; + } + + return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); + }; + + ParserImpl.prototype.parseSwitchClause = function () { + if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { + return this.eatNode(); + } + + if (this.isCaseSwitchClause()) { + return this.parseCaseSwitchClause(); + } else if (this.isDefaultSwitchClause()) { + return this.parseDefaultSwitchClause(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseCaseSwitchClause = function () { + var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); + var expression = this.parseExpression(true); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); + }; + + ParserImpl.prototype.parseDefaultSwitchClause = function () { + var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); + var colonToken = this.eatToken(106 /* ColonToken */); + var statements = TypeScript.Syntax.emptyList; + + if (colonToken.fullWidth() > 0) { + var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); + statements = result.list; + colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); + } + + return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); + }; + + ParserImpl.prototype.parseThrowStatement = function () { + var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); + + var expression = null; + if (this.canEatExplicitOrAutomaticSemicolon(false)) { + var token = this.createMissingToken(11 /* IdentifierName */, null); + expression = token; + } else { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.throwStatement(throwKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.parseReturnStatement = function () { + var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); + + var expression = null; + if (!this.canEatExplicitOrAutomaticSemicolon(false)) { + expression = this.parseExpression(true); + } + + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.returnStatement(returnKeyword, expression, semicolonToken); + }; + + ParserImpl.prototype.isExpressionStatement = function (currentToken) { + var kind = currentToken.tokenKind; + if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { + return false; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { + var currentToken = this.currentToken(); + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return this.isExpression(currentToken); + }; + + ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { + if (this.currentToken().tokenKind === 79 /* CommaToken */) { + return this.factory.omittedExpression(); + } + + return this.parseAssignmentExpression(true); + }; + + ParserImpl.prototype.isExpression = function (currentToken) { + switch (currentToken.tokenKind) { + case 13 /* NumericLiteral */: + case 14 /* StringLiteral */: + case 12 /* RegularExpressionLiteral */: + + case 74 /* OpenBracketToken */: + + case 72 /* OpenParenToken */: + + case 80 /* LessThanToken */: + + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 89 /* PlusToken */: + case 90 /* MinusToken */: + case 102 /* TildeToken */: + case 101 /* ExclamationToken */: + + case 70 /* OpenBraceToken */: + + case 85 /* EqualsGreaterThanToken */: + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + + case 50 /* SuperKeyword */: + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + + case 31 /* NewKeyword */: + + case 21 /* DeleteKeyword */: + case 41 /* VoidKeyword */: + case 39 /* TypeOfKeyword */: + + case 27 /* FunctionKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseExpressionStatement = function () { + var expression = this.parseExpression(true); + + var semicolon = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.expressionStatement(expression, semicolon); + }; + + ParserImpl.prototype.parseIfStatement = function () { + var ifKeyword = this.eatKeyword(28 /* IfKeyword */); + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var condition = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + var statement = this.parseStatement(false); + + var elseClause = null; + if (this.isElseClause()) { + elseClause = this.parseElseClause(); + } + + return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); + }; + + ParserImpl.prototype.isElseClause = function () { + return this.currentToken().tokenKind === 23 /* ElseKeyword */; + }; + + ParserImpl.prototype.parseElseClause = function () { + var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); + var statement = this.parseStatement(false); + + return this.factory.elseClause(elseKeyword, statement); + }; + + ParserImpl.prototype.isVariableStatement = function () { + var index = this.modifierCount(); + return this.peekToken(index).tokenKind === 40 /* VarKeyword */; + }; + + ParserImpl.prototype.parseVariableStatement = function () { + var modifiers = this.parseModifiers(); + var variableDeclaration = this.parseVariableDeclaration(true); + var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); + + return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); + }; + + ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { + var varKeyword = this.eatKeyword(40 /* VarKeyword */); + + var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; + + var result = this.parseSeparatedSyntaxList(listParsingState); + var variableDeclarators = result.list; + varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); + + return this.factory.variableDeclaration(varKeyword, variableDeclarators); + }; + + ParserImpl.prototype.isVariableDeclarator = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { + return true; + } + + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { + if (node === null || node.kind() !== 225 /* VariableDeclarator */) { + return false; + } + + var variableDeclarator = node; + return variableDeclarator.equalsValueClause === null; + }; + + ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { + if (this.canReuseVariableDeclaratorNode(this.currentNode())) { + return this.eatNode(); + } + + var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); + var equalsValueClause = null; + var typeAnnotation = null; + + if (propertyName.width() > 0) { + typeAnnotation = this.parseOptionalTypeAnnotation(false); + + if (this.isEqualsValueClause(false)) { + equalsValueClause = this.parseEqualsValueClause(allowIn); + } + } + + return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.isColonValueClause = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.isEqualsValueClause = function (inParameter) { + var token0 = this.currentToken(); + if (token0.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (!this.previousToken().hasTrailingNewLine()) { + if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { + return false; + } + + if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { + return false; + } + + return this.isExpression(token0); + } + + return false; + }; + + ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { + var equalsToken = this.eatToken(107 /* EqualsToken */); + var value = this.parseAssignmentExpression(allowIn); + + return this.factory.equalsValueClause(equalsToken, value); + }; + + ParserImpl.prototype.parseExpression = function (allowIn) { + return this.parseSubExpression(0, allowIn); + }; + + ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { + return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); + }; + + ParserImpl.prototype.parseUnaryExpressionOrLower = function () { + var currentTokenKind = this.currentToken().tokenKind; + if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { + var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); + + var operatorToken = this.eatAnyToken(); + + var operand = this.parseUnaryExpressionOrLower(); + return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); + } else if (currentTokenKind === 39 /* TypeOfKeyword */) { + return this.parseTypeOfExpression(); + } else if (currentTokenKind === 41 /* VoidKeyword */) { + return this.parseVoidExpression(); + } else if (currentTokenKind === 21 /* DeleteKeyword */) { + return this.parseDeleteExpression(); + } else if (currentTokenKind === 80 /* LessThanToken */) { + return this.parseCastExpression(); + } else { + return this.parsePostfixExpressionOrLower(); + } + }; + + ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { + if (precedence <= 2 /* AssignmentExpressionPrecedence */) { + if (this.isSimpleArrowFunctionExpression()) { + return this.parseSimpleArrowFunctionExpression(); + } + + var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); + if (parethesizedArrowFunction !== null) { + return parethesizedArrowFunction; + } + } + + var leftOperand = this.parseUnaryExpressionOrLower(); + return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); + }; + + ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { + while (true) { + var token0 = this.currentToken(); + var token0Kind = token0.tokenKind; + + if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { + if (token0Kind === 29 /* InKeyword */ && !allowIn) { + break; + } + + var mergedToken = this.tryMergeBinaryExpressionTokens(); + var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; + + var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); + var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); + + if (newPrecedence < precedence) { + break; + } + + if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { + break; + } + + var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); + + var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; + for (var i = 0; i < skipCount; i++) { + this.eatAnyToken(); + } + + leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); + continue; + } + + if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { + var questionToken = this.eatToken(105 /* QuestionToken */); + + var whenTrueExpression = this.parseAssignmentExpression(allowIn); + var colon = this.eatToken(106 /* ColonToken */); + + var whenFalseExpression = this.parseAssignmentExpression(allowIn); + leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); + continue; + } + + break; + } + + return leftOperand; + }; + + ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { + var token0 = this.currentToken(); + + if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { + var storage = this.mergeTokensStorage; + storage[0] = 0 /* None */; + storage[1] = 0 /* None */; + storage[2] = 0 /* None */; + + for (var i = 0; i < storage.length; i++) { + var nextToken = this.peekToken(i + 1); + + if (!nextToken.hasLeadingTrivia()) { + storage[i] = nextToken.tokenKind; + } + + if (nextToken.hasTrailingTrivia()) { + break; + } + } + + if (storage[0] === 81 /* GreaterThanToken */) { + if (storage[1] === 81 /* GreaterThanToken */) { + if (storage[2] === 107 /* EqualsToken */) { + return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; + } + } else if (storage[1] === 107 /* EqualsToken */) { + return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; + } else { + return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; + } + } else if (storage[0] === 107 /* EqualsToken */) { + return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; + } + } + + return null; + }; + + ParserImpl.prototype.isRightAssociative = function (expressionKind) { + switch (expressionKind) { + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + return true; + default: + return false; + } + }; + + ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } + + var expression = this.parsePrimaryExpression(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + return this.parseMemberExpressionRest(expression, false, inObjectCreation); + }; + + ParserImpl.prototype.parseCallExpressionOrLower = function () { + var expression; + if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { + expression = this.eatKeyword(50 /* SuperKeyword */); + + var currentTokenKind = this.currentToken().tokenKind; + if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + } + } else { + expression = this.parseMemberExpressionOrLower(false); + } + + return this.parseMemberExpressionRest(expression, true, false); + }; + + ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { + while (true) { + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 72 /* OpenParenToken */: + if (!allowArguments) { + return expression; + } + + expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); + continue; + + case 80 /* LessThanToken */: + if (!allowArguments) { + return expression; + } + + var argumentList = this.tryParseArgumentList(); + if (argumentList !== null) { + expression = this.factory.invocationExpression(expression, argumentList); + continue; + } + + break; + + case 74 /* OpenBracketToken */: + expression = this.parseElementAccessExpression(expression, inObjectCreation); + continue; + + case 76 /* DotToken */: + expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); + continue; + } + + return expression; + } + }; + + ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseCallExpressionOrLower(); + } + }; + + ParserImpl.prototype.parsePostfixExpressionOrLower = function () { + var expression = this.parseLeftHandSideExpressionOrLower(); + if (expression === null) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = this.currentToken().tokenKind; + + switch (currentTokenKind) { + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { + break; + } + + return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); + } + + return expression; + }; + + ParserImpl.prototype.tryParseGenericArgumentList = function () { + var rewindPoint = this.getRewindPoint(); + + var typeArgumentList = this.tryParseTypeArgumentList(true); + var token0 = this.currentToken(); + + var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; + var isDot = token0.tokenKind === 76 /* DotToken */; + var isOpenParenOrDot = isOpenParen || isDot; + + var argumentList = null; + if (typeArgumentList === null || !isOpenParenOrDot) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + + if (isDot) { + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + this.addDiagnostic(diagnostic); + + return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + } else { + return this.parseArgumentList(typeArgumentList); + } + } + }; + + ParserImpl.prototype.tryParseArgumentList = function () { + if (this.currentToken().tokenKind === 80 /* LessThanToken */) { + return this.tryParseGenericArgumentList(); + } + + if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { + return this.parseArgumentList(null); + } + + return null; + }; + + ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + + var _arguments = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.fullWidth() > 0) { + var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); + _arguments = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); + }; + + ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { + var start = this.currentTokenStart(); + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var argumentExpression; + + if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { + var end = this.currentTokenStart() + this.currentToken().width(); + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + this.addDiagnostic(diagnostic); + + argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + } else { + argumentExpression = this.parseExpression(true); + } + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); + }; + + ParserImpl.prototype.parsePrimaryExpression = function () { + var currentToken = this.currentToken(); + + if (this.isIdentifier(currentToken)) { + return this.eatIdentifierToken(); + } + + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 35 /* ThisKeyword */: + return this.parseThisExpression(); + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.parseLiteralExpression(); + + case 32 /* NullKeyword */: + return this.parseLiteralExpression(); + + case 27 /* FunctionKeyword */: + return this.parseFunctionExpression(); + + case 13 /* NumericLiteral */: + return this.parseLiteralExpression(); + + case 12 /* RegularExpressionLiteral */: + return this.parseLiteralExpression(); + + case 14 /* StringLiteral */: + return this.parseLiteralExpression(); + + case 74 /* OpenBracketToken */: + return this.parseArrayLiteralExpression(); + + case 70 /* OpenBraceToken */: + return this.parseObjectLiteralExpression(); + + case 72 /* OpenParenToken */: + return this.parseParenthesizedExpression(); + + case 118 /* SlashToken */: + case 119 /* SlashEqualsToken */: + var result = this.tryReparseDivideAsRegularExpression(); + if (result !== null) { + return result; + } + break; + } + + return null; + }; + + ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { + var currentToken = this.currentToken(); + + if (this.previousToken() !== null) { + var previousTokenKind = this.previousToken().tokenKind; + switch (previousTokenKind) { + case 11 /* IdentifierName */: + return null; + + case 35 /* ThisKeyword */: + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return null; + + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: + case 93 /* PlusPlusToken */: + case 94 /* MinusMinusToken */: + case 75 /* CloseBracketToken */: + return null; + } + } + + currentToken = this.currentTokenAllowingRegularExpression(); + + if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { + return null; + } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { + return this.parseLiteralExpression(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.parseTypeOfExpression = function () { + var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.typeOfExpression(typeOfKeyword, expression); + }; + + ParserImpl.prototype.parseDeleteExpression = function () { + var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.deleteExpression(deleteKeyword, expression); + }; + + ParserImpl.prototype.parseVoidExpression = function () { + var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.voidExpression(voidKeyword, expression); + }; + + ParserImpl.prototype.parseFunctionExpression = function () { + var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); + var identifier = null; + + if (this.isIdentifier(this.currentToken())) { + identifier = this.eatIdentifierToken(); + } + + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); + }; + + ParserImpl.prototype.parseObjectCreationExpression = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + + var expression = this.parseObjectCreationExpressionOrLower(true); + var argumentList = this.tryParseArgumentList(); + + var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); + return this.parseMemberExpressionRest(result, true, false); + }; + + ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { + if (this.currentToken().tokenKind === 31 /* NewKeyword */) { + return this.parseObjectCreationExpression(); + } else { + return this.parseMemberExpressionOrLower(inObjectCreation); + } + }; + + ParserImpl.prototype.parseCastExpression = function () { + var lessThanToken = this.eatToken(80 /* LessThanToken */); + var type = this.parseType(); + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + var expression = this.parseUnaryExpressionOrLower(); + + return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); + }; + + ParserImpl.prototype.parseParenthesizedExpression = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var expression = this.parseExpression(true); + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + + return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); + }; + + ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { + var tokenKind = this.currentToken().tokenKind; + if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { + return null; + } + + if (this.isDefinitelyArrowFunctionExpression()) { + return this.parseParenthesizedArrowFunctionExpression(false); + } + + if (!this.isPossiblyArrowFunctionExpression()) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); + if (arrowFunction === null) { + this.rewind(rewindPoint); + } + + this.releaseRewindPoint(rewindPoint); + return arrowFunction; + }; + + ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { + var currentToken = this.currentToken(); + + var callSignature = this.parseCallSignature(true); + + if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { + return null; + } + + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.tryParseArrowFunctionBlock = function () { + if (this.isBlock()) { + return this.parseBlock(false, false); + } else { + if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { + return this.parseBlock(true, false); + } else { + return null; + } + } + }; + + ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; + }; + + ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { + var identifier = this.eatIdentifierToken(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + + var block = this.tryParseArrowFunctionBlock(); + var expression = null; + if (block === null) { + expression = this.parseAssignmentExpression(true); + } + + return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); + }; + + ParserImpl.prototype.isBlock = function () { + return this.currentToken().tokenKind === 70 /* OpenBraceToken */; + }; + + ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return false; + } + + var token1 = this.peekToken(1); + var token2; + + if (token1.tokenKind === 73 /* CloseParenToken */) { + token2 = this.peekToken(2); + return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; + } + + if (token1.tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + token2 = this.peekToken(2); + if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { + if (this.isIdentifier(token2)) { + return true; + } + } + + if (!this.isIdentifier(token1)) { + return false; + } + + if (token2.tokenKind === 106 /* ColonToken */) { + return true; + } + + var token3 = this.peekToken(3); + if (token2.tokenKind === 105 /* QuestionToken */) { + if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { + return true; + } + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { + var token0 = this.currentToken(); + if (token0.tokenKind !== 72 /* OpenParenToken */) { + return true; + } + + var token1 = this.peekToken(1); + + if (!this.isIdentifier(token1)) { + return false; + } + + var token2 = this.peekToken(2); + if (token2.tokenKind === 107 /* EqualsToken */) { + return true; + } + + if (token2.tokenKind === 79 /* CommaToken */) { + return true; + } + + if (token2.tokenKind === 73 /* CloseParenToken */) { + var token3 = this.peekToken(3); + if (token3.tokenKind === 106 /* ColonToken */) { + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseObjectLiteralExpression = function () { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); + var propertyAssignments = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); + }; + + ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { + if (this.isAccessor(inErrorRecovery)) { + return this.parseAccessor(true); + } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { + return this.parseFunctionPropertyAssignment(); + } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { + return this.parseSimplePropertyAssignment(); + } else { + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { + return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); + }; + + ParserImpl.prototype.eatPropertyName = function () { + return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); + }; + + ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); + }; + + ParserImpl.prototype.parseFunctionPropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var callSignature = this.parseCallSignature(false); + var block = this.parseBlock(false, true); + + return this.factory.functionPropertyAssignment(propertyName, callSignature, block); + }; + + ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { + return this.isPropertyName(this.currentToken(), inErrorRecovery); + }; + + ParserImpl.prototype.parseSimplePropertyAssignment = function () { + var propertyName = this.eatPropertyName(); + var colonToken = this.eatToken(106 /* ColonToken */); + var expression = this.parseAssignmentExpression(true); + + return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); + }; + + ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + if (inErrorRecovery) { + return this.isIdentifier(token); + } else { + return true; + } + } + + switch (token.tokenKind) { + case 14 /* StringLiteral */: + case 13 /* NumericLiteral */: + return true; + + default: + return false; + } + }; + + ParserImpl.prototype.parseArrayLiteralExpression = function () { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + + var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); + var expressions = result.list; + openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); + + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); + }; + + ParserImpl.prototype.parseLiteralExpression = function () { + return this.eatAnyToken(); + }; + + ParserImpl.prototype.parseThisExpression = function () { + return this.eatKeyword(35 /* ThisKeyword */); + }; + + ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { + var openBraceToken = this.eatToken(70 /* OpenBraceToken */); + + var statements = TypeScript.Syntax.emptyList; + + if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { + var savedIsInStrictMode = this.isInStrictMode; + + var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; + var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); + statements = result.list; + openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); + + this.setStrictMode(savedIsInStrictMode); + } + + var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); + + return this.factory.block(openBraceToken, statements, closeBraceToken); + }; + + ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { + var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); + var parameterList = this.parseParameterList(); + var typeAnnotation = this.parseOptionalTypeAnnotation(false); + + return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); + }; + + ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { + if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { + return null; + } + + var rewindPoint = this.getRewindPoint(); + + var lessThanToken = this.eatToken(80 /* LessThanToken */); + + var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); + var typeParameters = result.list; + lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); + + var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); + + if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { + this.rewind(rewindPoint); + this.releaseRewindPoint(rewindPoint); + return null; + } else { + this.releaseRewindPoint(rewindPoint); + var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); + + return typeParameterList; + } + }; + + ParserImpl.prototype.isTypeParameter = function () { + return this.isIdentifier(this.currentToken()); + }; + + ParserImpl.prototype.parseTypeParameter = function () { + var identifier = this.eatIdentifierToken(); + var constraint = this.parseOptionalConstraint(); + + return this.factory.typeParameter(identifier, constraint); + }; + + ParserImpl.prototype.parseOptionalConstraint = function () { + if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { + return null; + } + + var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); + var type = this.parseType(); + + return this.factory.constraint(extendsKeyword, type); + }; + + ParserImpl.prototype.parseParameterList = function () { + var openParenToken = this.eatToken(72 /* OpenParenToken */); + var parameters = TypeScript.Syntax.emptySeparatedList; + + if (openParenToken.width() > 0) { + var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); + parameters = result.list; + openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); + } + + var closeParenToken = this.eatToken(73 /* CloseParenToken */); + return this.factory.parameterList(openParenToken, parameters, closeParenToken); + }; + + ParserImpl.prototype.isTypeAnnotation = function () { + return this.currentToken().tokenKind === 106 /* ColonToken */; + }; + + ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { + return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; + }; + + ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { + var colonToken = this.eatToken(106 /* ColonToken */); + var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); + + return this.factory.typeAnnotation(colonToken, type); + }; + + ParserImpl.prototype.isType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + switch (currentTokenKind) { + case 39 /* TypeOfKeyword */: + + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + + case 70 /* OpenBraceToken */: + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + + case 31 /* NewKeyword */: + return true; + } + + return this.isIdentifier(currentToken); + }; + + ParserImpl.prototype.parseType = function () { + var currentToken = this.currentToken(); + var currentTokenKind = currentToken.tokenKind; + + var type = this.parseNonArrayType(currentToken); + + while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { + var openBracketToken = this.eatToken(74 /* OpenBracketToken */); + var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); + + type = this.factory.arrayType(type, openBracketToken, closeBracketToken); + } + + return type; + }; + + ParserImpl.prototype.isTypeQuery = function () { + return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; + }; + + ParserImpl.prototype.parseTypeQuery = function () { + var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); + var name = this.parseName(); + + return this.factory.typeQuery(typeOfKeyword, name); + }; + + ParserImpl.prototype.parseNonArrayType = function (currentToken) { + var currentTokenKind = currentToken.tokenKind; + switch (currentTokenKind) { + case 60 /* AnyKeyword */: + case 67 /* NumberKeyword */: + case 61 /* BooleanKeyword */: + case 69 /* StringKeyword */: + case 41 /* VoidKeyword */: + return this.eatAnyToken(); + + case 70 /* OpenBraceToken */: + return this.parseObjectType(); + + case 72 /* OpenParenToken */: + case 80 /* LessThanToken */: + return this.parseFunctionType(); + + case 31 /* NewKeyword */: + return this.parseConstructorType(); + + case 39 /* TypeOfKeyword */: + return this.parseTypeQuery(); + } + + return this.parseNameOrGenericType(); + }; + + ParserImpl.prototype.parseNameOrGenericType = function () { + var name = this.parseName(); + var typeArgumentList = this.tryParseTypeArgumentList(false); + + return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); + }; + + ParserImpl.prototype.parseFunctionType = function () { + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var returnType = this.parseType(); + + return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); + }; + + ParserImpl.prototype.parseConstructorType = function () { + var newKeyword = this.eatKeyword(31 /* NewKeyword */); + var typeParameterList = this.parseOptionalTypeParameterList(false); + var parameterList = this.parseParameterList(); + var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); + var type = this.parseType(); + + return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); + }; + + ParserImpl.prototype.isParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return true; + } + + var token = this.currentToken(); + var tokenKind = token.tokenKind; + if (tokenKind === 77 /* DotDotDotToken */) { + return true; + } + + if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { + return true; + } + + return this.isIdentifier(token); + }; + + ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { + if (this.isIdentifier(token)) { + var nextTokenKind = this.peekToken(1).tokenKind; + switch (nextTokenKind) { + case 73 /* CloseParenToken */: + case 106 /* ColonToken */: + case 107 /* EqualsToken */: + case 79 /* CommaToken */: + case 105 /* QuestionToken */: + return true; + } + } + + return false; + }; + + ParserImpl.prototype.parseParameter = function () { + if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { + return this.eatNode(); + } + + var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); + + var modifierArray = this.getArray(); + + while (true) { + var currentToken = this.currentToken(); + if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { + modifierArray.push(this.eatAnyToken()); + continue; + } + + break; + } + + var modifiers = TypeScript.Syntax.list(modifierArray); + this.returnZeroOrOneLengthArray(modifierArray); + + var identifier = this.eatIdentifierToken(); + var questionToken = this.tryEatToken(105 /* QuestionToken */); + var typeAnnotation = this.parseOptionalTypeAnnotation(true); + + var equalsValueClause = null; + if (this.isEqualsValueClause(true)) { + equalsValueClause = this.parseEqualsValueClause(true); + } + + return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + }; + + ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { + if (typeof processItems === "undefined") { processItems = null; } + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSyntaxListWorker(currentListType, processItems); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { + var savedListParsingState = this.listParsingState; + this.listParsingState |= currentListType; + + var result = this.parseSeparatedSyntaxListWorker(currentListType); + + this.listParsingState = savedListParsingState; + + return result; + }; + + ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { + this.reportUnexpectedTokenDiagnostic(currentListType); + + 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; + } + } + } + + var skippedToken = this.currentToken(); + + this.moveToNextToken(); + + this.addSkippedTokenToList(items, skippedTokens, skippedToken); + + return false; + }; + + ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { + for (var i = items.length - 1; i >= 0; i--) { + var item = items[i]; + var lastToken = item.lastToken(); + if (lastToken.fullWidth() > 0) { + items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; + } + } + + skippedTokens.push(skippedToken); + }; + + ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { + if (this.isExpectedListItem(currentListType, inErrorRecovery)) { + var item = this.parseExpectedListItem(currentListType, inErrorRecovery); + + items.push(item); + + if (processItems !== null) { + processItems(this, items); + } + } + }; + + ParserImpl.prototype.listIsTerminated = function (currentListType) { + return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.getArray = function () { + if (this.arrayPool.length > 0) { + return this.arrayPool.pop(); + } + + return []; + }; + + ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { + if (array.length <= 1) { + this.returnArray(array); + } + }; + + ParserImpl.prototype.returnArray = function (array) { + array.length = 0; + this.arrayPool.push(array); + }; + + ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + + while (true) { + var oldItemsCount = items.length; + this.tryParseExpectedListItem(currentListType, false, items, processItems); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } + } + } + + var result = TypeScript.Syntax.list(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { + var items = this.getArray(); + var skippedTokens = this.getArray(); + TypeScript.Debug.assert(items.length === 0); + TypeScript.Debug.assert(skippedTokens.length === 0); + TypeScript.Debug.assert(skippedTokens !== items); + + var separatorKind = this.separatorKind(currentListType); + var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; + + var inErrorRecovery = false; + var listWasTerminated = false; + while (true) { + var oldItemsCount = items.length; + + this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); + + var newItemsCount = items.length; + if (newItemsCount === oldItemsCount) { + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); + if (abort) { + break; + } else { + inErrorRecovery = true; + continue; + } + } + + inErrorRecovery = false; + + var currentToken = this.currentToken(); + if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { + items.push(this.eatAnyToken()); + continue; + } + + if (this.listIsTerminated(currentListType)) { + listWasTerminated = true; + break; + } + + if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { + items.push(this.eatExplicitOrAutomaticSemicolon(false)); + + continue; + } + + items.push(this.eatToken(separatorKind)); + + inErrorRecovery = true; + } + + var result = TypeScript.Syntax.separatedList(items); + + this.returnZeroOrOneLengthArray(items); + + return { skippedTokens: skippedTokens, list: result }; + }; + + ParserImpl.prototype.separatorKind = function (currentListType) { + switch (currentListType) { + case 2048 /* HeritageClause_TypeNameList */: + case 16384 /* ArgumentList_AssignmentExpressions */: + case 256 /* EnumDeclaration_EnumElements */: + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + case 131072 /* ParameterList_Parameters */: + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + case 262144 /* TypeArgumentList_Types */: + case 524288 /* TypeParameterList_TypeParameters */: + return 79 /* CommaToken */; + + case 512 /* ObjectType_TypeMembers */: + return 78 /* SemicolonToken */; + + case 1 /* SourceUnit_ModuleElements */: + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + case 2 /* ClassDeclaration_ClassElements */: + case 4 /* ModuleDeclaration_ModuleElements */: + case 8 /* SwitchStatement_SwitchClauses */: + case 16 /* SwitchClause_Statements */: + case 32 /* Block_Statements */: + default: + throw TypeScript.Errors.notYetImplemented(); + } + }; + + ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { + var token = this.currentToken(); + + var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); + this.addDiagnostic(diagnostic); + }; + + ParserImpl.prototype.addDiagnostic = function (diagnostic) { + if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { + return; + } + + this.diagnostics.push(diagnostic); + }; + + ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isExpectedSourceUnit_ModuleElementsTerminator(); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isExpectedClassDeclaration_ClassElementsTerminator(); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isExpectedSwitchStatement_SwitchClausesTerminator(); + + case 16 /* SwitchClause_Statements */: + return this.isExpectedSwitchClause_StatementsTerminator(); + + case 32 /* Block_Statements */: + return this.isExpectedBlock_StatementsTerminator(); + + case 64 /* TryBlock_Statements */: + return this.isExpectedTryBlock_StatementsTerminator(); + + case 128 /* CatchBlock_Statements */: + return this.isExpectedCatchBlock_StatementsTerminator(); + + case 256 /* EnumDeclaration_EnumElements */: + return this.isExpectedEnumDeclaration_EnumElementsTerminator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isExpectedObjectType_TypeMembersTerminator(); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isExpectedHeritageClause_TypeNameListTerminator(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + + case 131072 /* ParameterList_Parameters */: + return this.isExpectedParameterList_ParametersTerminator(); + + case 262144 /* TypeArgumentList_Types */: + return this.isExpectedTypeArgumentList_TypesTerminator(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isExpectedTypeParameterList_TypeParametersTerminator(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 10 /* EndOfFileToken */; + }; + + ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { + return this.currentToken().tokenKind === 75 /* CloseBracketToken */; + }; + + ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 81 /* GreaterThanToken */) { + return true; + } + + if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { + var token = this.currentToken(); + if (token.tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (token.tokenKind === 70 /* OpenBraceToken */) { + return true; + } + + if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { + if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { + return true; + } + + if (this.currentToken().tokenKind === 29 /* InKeyword */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { + if (this.previousToken().tokenKind === 79 /* CommaToken */) { + return false; + } + + if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { + return true; + } + + return this.canEatExplicitOrAutomaticSemicolon(false); + }; + + ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { + var token0 = this.currentToken(); + if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { + return true; + } + + if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { + return true; + } + + return false; + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { + var token0 = this.currentToken(); + return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; + }; + + ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); + }; + + ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 71 /* CloseBraceToken */; + }; + + ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { + return this.currentToken().tokenKind === 25 /* FinallyKeyword */; + }; + + ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.isHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.isClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.isModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.isSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.isStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.isStatement(inErrorRecovery); + + case 64 /* TryBlock_Statements */: + case 128 /* CatchBlock_Statements */: + return false; + + case 256 /* EnumDeclaration_EnumElements */: + return this.isEnumElement(inErrorRecovery); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.isVariableDeclarator(); + + case 512 /* ObjectType_TypeMembers */: + return this.isTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.isExpectedArgumentList_AssignmentExpression(); + + case 2048 /* HeritageClause_TypeNameList */: + return this.isHeritageClauseTypeName(); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.isPropertyAssignment(inErrorRecovery); + + case 131072 /* ParameterList_Parameters */: + return this.isParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.isType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.isTypeParameter(); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.isAssignmentOrOmittedExpression(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { + var currentToken = this.currentToken(); + if (this.isExpression(currentToken)) { + return true; + } + + if (currentToken.tokenKind === 79 /* CommaToken */) { + return true; + } + + return false; + }; + + ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return this.parseHeritageClause(); + + case 2 /* ClassDeclaration_ClassElements */: + return this.parseClassElement(inErrorRecovery); + + case 4 /* ModuleDeclaration_ModuleElements */: + return this.parseModuleElement(inErrorRecovery); + + case 8 /* SwitchStatement_SwitchClauses */: + return this.parseSwitchClause(); + + case 16 /* SwitchClause_Statements */: + return this.parseStatement(inErrorRecovery); + + case 32 /* Block_Statements */: + return this.parseStatement(inErrorRecovery); + + case 256 /* EnumDeclaration_EnumElements */: + return this.parseEnumElement(); + + case 512 /* ObjectType_TypeMembers */: + return this.parseTypeMember(inErrorRecovery); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return this.parseAssignmentExpression(true); + + case 2048 /* HeritageClause_TypeNameList */: + return this.parseNameOrGenericType(); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + return this.parseVariableDeclarator(true, false); + + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return this.parseVariableDeclarator(false, false); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return this.parsePropertyAssignment(inErrorRecovery); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return this.parseAssignmentOrOmittedExpression(); + + case 131072 /* ParameterList_Parameters */: + return this.parseParameter(); + + case 262144 /* TypeArgumentList_Types */: + return this.parseType(); + + case 524288 /* TypeParameterList_TypeParameters */: + return this.parseTypeParameter(); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + ParserImpl.prototype.getExpectedListElementType = function (currentListType) { + switch (currentListType) { + case 1 /* SourceUnit_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: + return '{'; + + case 2 /* ClassDeclaration_ClassElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); + + case 4 /* ModuleDeclaration_ModuleElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); + + case 8 /* SwitchStatement_SwitchClauses */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); + + case 16 /* SwitchClause_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 32 /* Block_Statements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); + + case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: + case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 256 /* EnumDeclaration_EnumElements */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); + + case 512 /* ObjectType_TypeMembers */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); + + case 16384 /* ArgumentList_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + case 2048 /* HeritageClause_TypeNameList */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); + + case 32768 /* ObjectLiteralExpression_PropertyAssignments */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); + + case 131072 /* ParameterList_Parameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); + + case 262144 /* TypeArgumentList_Types */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); + + case 524288 /* TypeParameterList_TypeParameters */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); + + case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: + return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); + + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + return ParserImpl; + })(); + + function parse(fileName, text, isDeclaration, options) { + var source = new NormalParserSource(fileName, text, options.languageVersion()); + + return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); + } + Parser.parse = parse; + + function incrementalParse(oldSyntaxTree, textChangeRange, newText) { + if (textChangeRange.isUnchanged()) { + return oldSyntaxTree; + } + + var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); + + return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); + } + Parser.incrementalParse = incrementalParse; + })(TypeScript.Parser || (TypeScript.Parser = {})); + var Parser = TypeScript.Parser; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxTree = (function () { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { + this._allDiagnostics = null; + this._sourceUnit = sourceUnit; + this._isDeclaration = isDeclaration; + this._parserDiagnostics = diagnostics; + this._fileName = fileName; + this._lineMap = lineMap; + this._parseOptions = parseOtions; + } + SyntaxTree.prototype.toJSON = function (key) { + var result = {}; + + result.isDeclaration = this._isDeclaration; + result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; + result.parseOptions = this._parseOptions; + + if (this.diagnostics().length > 0) { + result.diagnostics = this.diagnostics(); + } + + result.sourceUnit = this._sourceUnit; + result.lineMap = this._lineMap; + + return result; + }; + + SyntaxTree.prototype.sourceUnit = function () { + return this._sourceUnit; + }; + + SyntaxTree.prototype.isDeclaration = function () { + return this._isDeclaration; + }; + + SyntaxTree.prototype.computeDiagnostics = function () { + if (this._parserDiagnostics.length > 0) { + return this._parserDiagnostics; + } + + var diagnostics = []; + this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); + + return diagnostics; + }; + + SyntaxTree.prototype.diagnostics = function () { + if (this._allDiagnostics === null) { + this._allDiagnostics = this.computeDiagnostics(); + } + + return this._allDiagnostics; + }; + + SyntaxTree.prototype.fileName = function () { + return this._fileName; + }; + + SyntaxTree.prototype.lineMap = function () { + return this._lineMap; + }; + + SyntaxTree.prototype.parseOptions = function () { + return this._parseOptions; + }; + + SyntaxTree.prototype.structuralEquals = function (tree) { + return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); + }; + return SyntaxTree; + })(); + TypeScript.SyntaxTree = SyntaxTree; + + var GrammarCheckerWalker = (function (_super) { + __extends(GrammarCheckerWalker, _super); + function GrammarCheckerWalker(syntaxTree, diagnostics) { + _super.call(this); + this.syntaxTree = syntaxTree; + this.diagnostics = diagnostics; + this.inAmbientDeclaration = false; + this.inBlock = false; + this.inObjectLiteralExpression = false; + this.currentConstructor = null; + } + GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { + return this.position() + TypeScript.Syntax.childOffset(parent, child); + }; + + GrammarCheckerWalker.prototype.childStart = function (parent, child) { + return this.childFullStart(parent, child) + child.leadingTriviaWidth(); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { + if (typeof args === "undefined") { args = null; } + this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); + }; + + GrammarCheckerWalker.prototype.visitCatchClause = function (node) { + if (node.typeAnnotation) { + this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); + } + + _super.prototype.visitCatchClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + var seenOptionalParameter = false; + var parameterCount = node.parameters.nonSeparatorCount(); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameterIndex = i / 2; + var parameter = node.parameters.childAt(i); + + if (parameter.dotDotDotToken) { + if (parameterIndex !== (parameterCount - 1)) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); + return true; + } + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); + return true; + } + } else if (parameter.questionToken || parameter.equalsValueClause) { + seenOptionalParameter = true; + + if (parameter.questionToken && parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); + return true; + } + } else { + if (seenOptionalParameter) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); + return true; + } + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameters); + + for (var i = 0, n = node.parameters.childCount(); i < n; i++) { + var nodeOrToken = node.parameters.childAt(i); + if (i % 2 === 0) { + var parameter = node.parameters.childAt(i); + + if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { + return true; + } + } + + parameterFullStart += nodeOrToken.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { + if (parameter.modifiers.childCount() > 0) { + var modifiers = parameter.modifiers; + var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + + if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { + if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); + return true; + } else { + if (modifierIndex > 0) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + 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.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; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { + if (list.childCount() === 0 || list.childCount() % 2 === 1) { + return false; + } + + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i === n - 1) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); + } + + currentElementFullStart += child.fullWidth(); + } + + return true; + }; + + GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { + if (list.childCount() > 0) { + return false; + } + + var listFullStart = this.childFullStart(parent, list); + var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); + + this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); + + return true; + }; + + GrammarCheckerWalker.prototype.visitParameterList = function (node) { + if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { + this.skip(node); + return; + } + + _super.prototype.visitParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { + if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { + this.skip(node); + return; + } + + _super.prototype.visitHeritageClause.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.arguments)) { + this.skip(node); + return; + } + + _super.prototype.visitArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { + if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeArgumentList.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { + if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { + this.skip(node); + return; + } + + _super.prototype.visitTypeParameterList.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { + var parameterFullStart = this.childFullStart(node, node.parameter); + var parameter = node.parameter; + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); + return true; + } else if (parameter.modifiers.childCount() > 0) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); + return true; + } else if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); + return true; + } else if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); + return true; + } else if (!parameter.typeAnnotation) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); + return true; + } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { + if (this.checkIndexSignatureParameter(node)) { + this.skip(node); + return; + } + + if (!node.typeAnnotation) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); + this.skip(node); + return; + } + + _super.prototype.visitIndexSignature.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + var seenImplementsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 2); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); + return true; + } + + if (heritageClause.typeNames.nonSeparatorCount() > 1) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + if (seenImplementsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); + return true; + } + + seenImplementsClause = true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { + if (this.inAmbientDeclaration) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { + if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); + return true; + } + } + }; + + GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { + if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + + var inFunctionOverloadChain = false; + var functionOverloadChainName = null; + + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + var lastElement = i === (n - 1); + + if (inFunctionOverloadChain) { + if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { + this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + var functionDeclaration = moduleElement; + if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { + var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); + this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); + return true; + } + } + + if (moduleElement.kind() === 129 /* FunctionDeclaration */) { + functionDeclaration = moduleElement; + if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { + inFunctionOverloadChain = functionDeclaration.block === null; + functionOverloadChainName = functionDeclaration.identifier.valueText(); + + 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; + functionOverloadChainName = ""; + } + } + + moduleElementFullStart += moduleElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var classElementFullStart = this.childFullStart(node, node.classElements); + + var inFunctionOverloadChain = false; + var inConstructorOverloadChain = false; + + var functionOverloadChainName = null; + var isInStaticOverloadChain = null; + var memberFunctionDeclaration = null; + + for (var i = 0, n = node.classElements.childCount(); i < n; i++) { + var classElement = node.classElements.childAt(i); + var lastElement = i === (n - 1); + var isStaticOverload = null; + + if (inFunctionOverloadChain) { + if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); + return true; + } + + memberFunctionDeclaration = classElement; + if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { + var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); + 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) { + 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; + } + } else if (inConstructorOverloadChain) { + if (classElement.kind() !== 137 /* ConstructorDeclaration */) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { + memberFunctionDeclaration = classElement; + + inFunctionOverloadChain = memberFunctionDeclaration.block === null; + functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); + isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); + + 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; + + inConstructorOverloadChain = constructorDeclaration.block === null; + if (lastElement && inConstructorOverloadChain) { + this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); + return true; + } + } + + classElementFullStart += classElement.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { + var nameFullStart = this.childFullStart(parent, name); + var token; + var tokenFullStart; + + var current = name; + while (current !== null) { + if (current.kind() === 121 /* QualifiedName */) { + var qualifiedName = current; + token = qualifiedName.right; + tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); + current = qualifiedName.left; + } else { + TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); + token = current; + tokenFullStart = nameFullStart; + current = null; + } + + switch (token.valueText()) { + case "any": + case "number": + case "boolean": + case "string": + case "void": + this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitClassDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { + var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); + + var seenExtendsClause = false; + + for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { + TypeScript.Debug.assert(i <= 1); + var heritageClause = node.heritageClauses.childAt(i); + + if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { + if (seenExtendsClause) { + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); + return true; + } + + seenExtendsClause = true; + } else { + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); + this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); + return true; + } + + heritageClauseFullStart += heritageClause.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { + var modifierFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { + this.skip(node); + return; + } + + _super.prototype.visitInterfaceDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { + var modifierFullStart = this.position(); + + var seenAccessibilityModifier = false; + var seenStaticModifier = false; + + for (var i = 0, n = list.childCount(); i < n; i++) { + var modifier = list.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { + if (seenAccessibilityModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return true; + } + + if (seenStaticModifier) { + var previousToken = list.childAt(i - 1); + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); + return true; + } + + seenAccessibilityModifier = true; + } else if (modifier.tokenKind === 58 /* StaticKeyword */) { + if (seenStaticModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return true; + } + + seenStaticModifier = true; + } else { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); + return true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberVariableDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitMemberFunctionDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { + var getKeywordFullStart = this.childFullStart(node, getKeyword); + if (parameterList.parameters.childCount() !== 0) { + this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { + if (this.checkIndexMemberModifiers(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIndexMemberDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { + if (node.modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(node, node.modifiers); + this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { + if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { + var nodeFullStart = this.childFullStart(parent, node); + this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { + var savedInObjectLiteralExpression = this.inObjectLiteralExpression; + this.inObjectLiteralExpression = true; + _super.prototype.visitObjectLiteralExpression.call(this, node); + this.inObjectLiteralExpression = savedInObjectLiteralExpression; + }; + + GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitGetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { + if (this.inAmbientDeclaration) { + this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { + var setKeywordFullStart = this.childFullStart(node, setKeyword); + if (parameterList.parameters.childCount() !== 1) { + this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); + return true; + } + + var parameterListFullStart = this.childFullStart(node, parameterList); + var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); + var parameter = parameterList.parameters.childAt(0); + + if (parameter.questionToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); + return true; + } + + if (parameter.equalsValueClause) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); + return true; + } + + if (parameter.dotDotDotToken) { + this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { + this.skip(node); + return; + } + + _super.prototype.visitSetAccessor.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { + if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitEnumDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkEnumElements = function (node) { + var enumElementFullStart = this.childFullStart(node, node.enumElements); + + 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 && previousValueWasComputed) { + this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); + return true; + } + + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); + } + } + + enumElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + var expression = node.equalsValueClause.value; + if (!TypeScript.Syntax.isIntegerLiteral(expression)) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); + this.skip(node); + return; + } + } + + _super.prototype.visitEnumElement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { + if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); + } + + _super.prototype.visitInvocationExpression.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { + var modifierFullStart = this.position(); + var seenExportModifier = false; + var seenDeclareModifier = false; + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var modifier = modifiers.childAt(i); + if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); + return true; + } + + if (modifier.tokenKind === 63 /* DeclareKeyword */) { + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); + return; + } + + seenDeclareModifier = true; + } else if (modifier.tokenKind === 47 /* ExportKeyword */) { + if (seenExportModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); + return; + } + + if (seenDeclareModifier) { + this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + return; + } + + seenExportModifier = true; + } + + modifierFullStart += modifier.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { + var currentElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + if (child.kind() === 133 /* ImportDeclaration */) { + var importDeclaration = child; + if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (node.stringLiteral === null) { + this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); + } + } + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + + if (declareToken) { + this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); + return true; + } + }; + + GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + _super.prototype.visitImportDeclaration.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { + if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { + this.skip(node); + return; + } + + if (node.stringLiteral) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); + this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); + this.skip(node); + return; + } + } + + if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitModuleDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { + var seenExportedElement = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { + seenExportedElement = true; + break; + } + } + + var moduleElementFullStart = this.childFullStart(node, moduleElements); + if (seenExportedElement) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { + var moduleElementFullStart = this.childFullStart(node, moduleElements); + var seenExportAssignment = false; + var errorFound = false; + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var child = moduleElements.childAt(i); + if (child.kind() === 134 /* ExportAssignment */) { + if (seenExportAssignment) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); + errorFound = true; + } + seenExportAssignment = true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return errorFound; + }; + + GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { + var moduleElementFullStart = this.childFullStart(node, node.moduleElements); + + for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { + var child = node.moduleElements.childAt(i); + + if (child.kind() === 134 /* ExportAssignment */) { + this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); + + return true; + } + + moduleElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBlock = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + if (this.checkFunctionOverloads(node, node.statements)) { + this.skip(node); + return; + } + + var savedInBlock = this.inBlock; + this.inBlock = true; + _super.prototype.visitBlock.call(this, node); + this.inBlock = savedInBlock; + }; + + GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { + if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { + this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); + return true; + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitBreakStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitContinueStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDebuggerStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitDoStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitDoStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitEmptyStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitExpressionStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitForInStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { + this.skip(node); + return; + } + + _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); + return; + } + + _super.prototype.visitForStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitIfStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitIfStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitLabeledStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitReturnStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitSwitchStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitThrowStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitTryStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitTryStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWhileStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitWithStatement = function (node) { + if (this.checkForStatementInAmbientContxt(node)) { + this.skip(node); + return; + } + + _super.prototype.visitWithStatement.call(this, node); + }; + + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + if (this.inBlock || this.inObjectLiteralExpression) { + if (modifiers.childCount() > 0) { + var modifierFullStart = this.childFullStart(parent, modifiers); + this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + return true; + } + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitFunctionDeclaration.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + _super.prototype.visitVariableStatement.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { + var currentElementFullStart = this.childFullStart(parent, list); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var child = list.childAt(i); + if (i % 2 === 1 && child.kind() !== kind) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); + } + + currentElementFullStart += child.fullWidth(); + } + + return false; + }; + + GrammarCheckerWalker.prototype.visitObjectType = function (node) { + if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + this.skip(node); + return; + } + + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitObjectType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitArrayType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitArrayType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitFunctionType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitFunctionType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitConstructorType = function (node) { + var savedInAmbientDeclaration = this.inAmbientDeclaration; + this.inAmbientDeclaration = true; + _super.prototype.visitConstructorType.call(this, node); + this.inAmbientDeclaration = savedInAmbientDeclaration; + }; + + GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { + if (this.inAmbientDeclaration && node.equalsValueClause) { + this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); + this.skip(node); + return; + } + + _super.prototype.visitVariableDeclarator.call(this, node); + }; + + GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { + this.skip(node); + return; + } + + var savedCurrentConstructor = this.currentConstructor; + this.currentConstructor = node; + _super.prototype.visitConstructorDeclaration.call(this, node); + this.currentConstructor = savedCurrentConstructor; + }; + + GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { + var currentElementFullStart = this.position(); + + for (var i = 0, n = modifiers.childCount(); i < n; i++) { + var child = modifiers.childAt(i); + if (child.kind() !== 57 /* PublicKeyword */) { + this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); + return true; + } + + currentElementFullStart += child.fullWidth(); + } + + 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); + return; + } + + _super.prototype.visitSourceUnit.call(this, node); + }; + return GrammarCheckerWalker; + })(TypeScript.PositionTrackingWalker); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Unicode = (function () { + function Unicode() { + } + Unicode.lookupInUnicodeMap = function (code, map) { + if (code < map[0]) { + return false; + } + + var lo = 0; + var hi = map.length; + var mid; + + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + + if (code < map[mid]) { + hi = mid; + } else { + lo = mid + 2; + } + } + + return false; + }; + + Unicode.isIdentifierStart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + + Unicode.isIdentifierPart = function (code, languageVersion) { + if (languageVersion === 0 /* EcmaScript3 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); + } else if (languageVersion === 1 /* EcmaScript5 */) { + return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); + } else { + throw TypeScript.Errors.argumentOutOfRange("languageVersion"); + } + }; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; + return Unicode; + })(); + TypeScript.Unicode = Unicode; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (CompilerDiagnostics) { + CompilerDiagnostics.debug = false; + + CompilerDiagnostics.diagnosticWriter = null; + + CompilerDiagnostics.analysisPass = 0; + + function Alert(output) { + if (CompilerDiagnostics.diagnosticWriter) { + CompilerDiagnostics.diagnosticWriter.Alert(output); + } + } + CompilerDiagnostics.Alert = Alert; + + function debugPrint(s) { + if (CompilerDiagnostics.debug) { + Alert(s); + } + } + CompilerDiagnostics.debugPrint = debugPrint; + + function assert(condition, s) { + if (CompilerDiagnostics.debug) { + if (!condition) { + Alert(s); + } + } + } + CompilerDiagnostics.assert = assert; + })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); + var CompilerDiagnostics = TypeScript.CompilerDiagnostics; + + var NullLogger = (function () { + function NullLogger() { + } + NullLogger.prototype.information = function () { + return false; + }; + NullLogger.prototype.debug = function () { + return false; + }; + NullLogger.prototype.warning = function () { + return false; + }; + NullLogger.prototype.error = function () { + return false; + }; + NullLogger.prototype.fatal = function () { + return false; + }; + NullLogger.prototype.log = function (s) { + }; + return NullLogger; + })(); + TypeScript.NullLogger = NullLogger; + + function timeFunction(logger, funcDescription, func) { + var start = (new Date()).getTime(); + var result = func(); + var end = (new Date()).getTime(); + if (logger.information()) { + logger.log(funcDescription + " completed in " + (end - start) + " msec"); + } + return result; + } + TypeScript.timeFunction = timeFunction; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Document = (function () { + function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { + this._compiler = _compiler; + this._semanticInfoChain = _semanticInfoChain; + this.fileName = fileName; + this.referencedFiles = referencedFiles; + this._scriptSnapshot = _scriptSnapshot; + this.byteOrderMark = byteOrderMark; + this.version = version; + this.isOpen = isOpen; + this._syntaxTree = _syntaxTree; + this._topLevelDecl = _topLevelDecl; + this._diagnostics = null; + this._bloomFilter = null; + this._sourceUnit = null; + this._lineMap = null; + this._declASTMap = []; + this._astDeclMap = []; + this._amdDependencies = undefined; + this._externalModuleIndicatorSpan = undefined; + } + Document.prototype.invalidate = function () { + this._declASTMap.length = 0; + this._astDeclMap.length = 0; + this._topLevelDecl = null; + + this._syntaxTree = null; + this._sourceUnit = null; + this._diagnostics = null; + this._bloomFilter = null; + }; + + Document.prototype.isDeclareFile = function () { + return TypeScript.isDTSFile(this.fileName); + }; + + Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { + var start = new Date().getTime(); + this._diagnostics = syntaxTree.diagnostics(); + TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; + + this._lineMap = syntaxTree.lineMap(); + + var sourceUnit = syntaxTree.sourceUnit(); + var leadingTrivia = sourceUnit.leadingTrivia(); + + this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); + + var amdDependencies = []; + 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); + } + } + } + + this._amdDependencies = amdDependencies; + }; + + Document.prototype.getAmdDependency = function (comment) { + var amdDependencyRegEx = /^\/\/\/\s*/gim; + var match = implicitImportRegEx.exec(trivia.fullText()); + + if (match) { + return new TypeScript.TextSpan(position, trivia.fullWidth()); + } + + return null; + }; + + 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); + } + + if (moduleElement.kind() === 133 /* ImportDeclaration */) { + var importDecl = moduleElement; + if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { + return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); + } + } + + position += moduleElement.fullWidth(); + } + + return null; + ; + }; + + Document.prototype.sourceUnit = function () { + if (!this._sourceUnit) { + var start = new Date().getTime(); + var syntaxTree = this.syntaxTree(); + this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); + TypeScript.astTranslationTime += new Date().getTime() - start; + + if (!this.isOpen) { + this._syntaxTree = null; + } + } + + return this._sourceUnit; + }; + + Document.prototype.diagnostics = function () { + if (this._diagnostics === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._diagnostics); + } + + return this._diagnostics; + }; + + Document.prototype.lineMap = function () { + if (this._lineMap === null) { + this.syntaxTree(); + TypeScript.Debug.assert(this._lineMap); + } + + return this._lineMap; + }; + + Document.prototype.isExternalModule = function () { + return this.externalModuleIndicatorSpan() !== null; + }; + + Document.prototype.externalModuleIndicatorSpan = function () { + if (this._externalModuleIndicatorSpan === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); + } + + return this._externalModuleIndicatorSpan; + }; + + Document.prototype.amdDependencies = function () { + if (this._amdDependencies === undefined) { + this.syntaxTree(); + TypeScript.Debug.assert(this._amdDependencies !== undefined); + } + + return this._amdDependencies; + }; + + Document.prototype.syntaxTree = function () { + var result = this._syntaxTree; + if (!result) { + var start = new Date().getTime(); + + result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); + + TypeScript.syntaxTreeParseTime += new Date().getTime() - start; + + if (this.isOpen || !this._sourceUnit) { + this._syntaxTree = result; + } + } + + this.cacheSyntaxTreeInfo(result); + return result; + }; + + Document.prototype.bloomFilter = function () { + if (!this._bloomFilter) { + var identifiers = TypeScript.createIntrinsicsObject(); + var pre = function (cur) { + if (TypeScript.ASTHelpers.isValidAstNode(cur)) { + if (cur.kind() === 11 /* IdentifierName */) { + var nodeText = cur.valueText(); + + identifiers[nodeText] = true; + } + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); + + var identifierCount = 0; + for (var name in identifiers) { + if (identifiers[name]) { + identifierCount++; + } + } + + this._bloomFilter = new TypeScript.BloomFilter(identifierCount); + this._bloomFilter.addKeys(identifiers); + } + return this._bloomFilter; + }; + + Document.prototype.emitToOwnOutputFile = function () { + return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); + }; + + Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { + var oldSyntaxTree = this._syntaxTree; + + if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { + var oldText = this._scriptSnapshot; + var newText = scriptSnapshot; + + TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); + + if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { + var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); + var newTextPrefix = newText.getText(0, textChangeRange.span().start()); + TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); + + var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); + var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); + TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); + } + } + + var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); + + var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); + + return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); + }; + + Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); + }; + + Document.prototype.topLevelDecl = function () { + if (this._topLevelDecl === null) { + this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); + } + + return this._topLevelDecl; + }; + + Document.prototype._getDeclForAST = function (ast) { + this.topLevelDecl(); + return this._astDeclMap[ast.syntaxID()]; + }; + + Document.prototype.getEnclosingDecl = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + return this._getDeclForAST(ast); + } + + ast = ast.parent; + var decl = null; + while (ast) { + decl = this._getDeclForAST(ast); + + if (decl) { + break; + } + + ast = ast.parent; + } + + return decl._getEnclosingDeclFromParentDecl(); + }; + + Document.prototype._setDeclForAST = function (ast, decl) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._astDeclMap[ast.syntaxID()] = decl; + }; + + Document.prototype._getASTForDecl = function (decl) { + return this._declASTMap[decl.declID]; + }; + + Document.prototype._setASTForDecl = function (decl, ast) { + TypeScript.Debug.assert(decl.fileName() === this.fileName); + this._declASTMap[decl.declID] = ast; + }; + return Document; + })(); + TypeScript.Document = Document; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function hasFlag(val, flag) { + return (val & flag) !== 0; + } + TypeScript.hasFlag = hasFlag; + + (function (TypeRelationshipFlags) { + TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; + TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; + TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; + TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; + })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); + var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; + + (function (ModuleGenTarget) { + ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; + ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; + ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; + })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); + var ModuleGenTarget = TypeScript.ModuleGenTarget; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var proto = "__proto__"; + + var BlockIntrinsics = (function () { + function BlockIntrinsics() { + this.prototype = undefined; + this.toString = undefined; + this.toLocaleString = undefined; + this.valueOf = undefined; + this.hasOwnProperty = undefined; + this.propertyIsEnumerable = undefined; + this.isPrototypeOf = undefined; + this["constructor"] = undefined; + + this[proto] = null; + this[proto] = undefined; + } + return BlockIntrinsics; + })(); + + function createIntrinsicsObject() { + return new BlockIntrinsics(); + } + TypeScript.createIntrinsicsObject = createIntrinsicsObject; + + var StringHashTable = (function () { + function StringHashTable() { + this.itemCount = 0; + this.table = createIntrinsicsObject(); + } + StringHashTable.prototype.getAllKeys = function () { + var result = []; + + for (var k in this.table) { + if (this.table[k] !== undefined) { + result.push(k); + } + } + + return result; + }; + + StringHashTable.prototype.add = function (key, data) { + if (this.table[key] !== undefined) { + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.addOrUpdate = function (key, data) { + if (this.table[key] !== undefined) { + this.table[key] = data; + return false; + } + + this.table[key] = data; + this.itemCount++; + return true; + }; + + StringHashTable.prototype.map = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + fn(k, this.table[k], context); + } + } + }; + + StringHashTable.prototype.every = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (!fn(k, this.table[k], context)) { + return false; + } + } + } + + return true; + }; + + StringHashTable.prototype.some = function (fn, context) { + for (var k in this.table) { + var data = this.table[k]; + + if (data !== undefined) { + if (fn(k, this.table[k], context)) { + return true; + } + } + } + + return false; + }; + + StringHashTable.prototype.count = function () { + return this.itemCount; + }; + + StringHashTable.prototype.lookup = function (key) { + var data = this.table[key]; + return data === undefined ? null : data; + }; + + StringHashTable.prototype.remove = function (key) { + if (this.table[key] !== undefined) { + this.table[key] = undefined; + this.itemCount--; + } + }; + return StringHashTable; + })(); + TypeScript.StringHashTable = StringHashTable; + + var IdentiferNameHashTable = (function (_super) { + __extends(IdentiferNameHashTable, _super); + function IdentiferNameHashTable() { + _super.apply(this, arguments); + } + IdentiferNameHashTable.prototype.getAllKeys = function () { + var result = []; + + _super.prototype.map.call(this, function (k, v, c) { + if (v !== undefined) { + result.push(k.substring(1)); + } + }, null); + + return result; + }; + + IdentiferNameHashTable.prototype.add = function (key, data) { + return _super.prototype.add.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { + return _super.prototype.addOrUpdate.call(this, "#" + key, data); + }; + + IdentiferNameHashTable.prototype.map = function (fn, context) { + return _super.prototype.map.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.every = function (fn, context) { + return _super.prototype.every.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.some = function (fn, context) { + return _super.prototype.some.call(this, function (k, v, c) { + return fn(k.substring(1), v, c); + }, context); + }; + + IdentiferNameHashTable.prototype.lookup = function (key) { + return _super.prototype.lookup.call(this, "#" + key); + }; + return IdentiferNameHashTable; + })(StringHashTable); + TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; +})(TypeScript || (TypeScript = {})); + +var TypeScript; +(function (TypeScript) { + (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); + } + ASTHelpers.moduleIsElided = moduleIsElided; + + 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)) { + 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; + } + ASTHelpers.enumIsElided = enumIsElided; + + function isValidAstNode(ast) { + if (!ast) + return false; + + if (ast.start() === -1 || ast.end() === -1) + return false; + + return true; + } + ASTHelpers.isValidAstNode = isValidAstNode; + + 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; + + 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) { + top = cur; + } + } + } + } + + 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; + } + } + + return false; + } + ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; + + function isNameOfSomeDeclaration(ast) { + if (ast === null || ast.parent === null) { + return false; + } + if (ast.kind() !== 11 /* IdentifierName */) { + return false; + } + + 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); + } + 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; + } + + current = current.parent; + } + 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; + } + + return null; + } + ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; + + 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; + } + 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; + + function parametersFromIdentifier(id) { + return { + length: 1, + lastParameterIsRest: function () { + return false; + }, + ast: id, + astAt: function (index) { + return id; + }, + identifierAt: function (index) { + return id; + }, + typeAt: function (index) { + return null; + }, + initializerAt: function (index) { + return null; + }, + isOptionalAt: function (index) { + return false; + } + }; + } + ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; + + function parametersFromParameter(parameter) { + return { + length: 1, + lastParameterIsRest: function () { + return parameter.dotDotDotToken !== null; + }, + ast: parameter, + astAt: function (index) { + return parameter; + }, + identifierAt: function (index) { + return parameter.identifier; + }, + typeAt: function (index) { + return getType(parameter); + }, + initializerAt: function (index) { + return parameter.equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(parameter); + } + }; + } + ASTHelpers.parametersFromParameter = parametersFromParameter; + + function parameterIsOptional(parameter) { + return parameter.questionToken !== null || parameter.equalsValueClause !== null; + } + + function parametersFromParameterList(list) { + return { + length: list.parameters.nonSeparatorCount(), + lastParameterIsRest: function () { + return TypeScript.lastParameterIsRest(list); + }, + ast: list.parameters, + astAt: function (index) { + return list.parameters.nonSeparatorAt(index); + }, + identifierAt: function (index) { + return list.parameters.nonSeparatorAt(index).identifier; + }, + typeAt: function (index) { + return getType(list.parameters.nonSeparatorAt(index)); + }, + initializerAt: function (index) { + return list.parameters.nonSeparatorAt(index).equalsValueClause; + }, + isOptionalAt: function (index) { + return parameterIsOptional(list.parameters.nonSeparatorAt(index)); + } + }; + } + ASTHelpers.parametersFromParameterList = parametersFromParameterList; + + 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; + } + } + ASTHelpers.isDeclarationAST = isDeclarationAST; + + 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; + } + + 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; + } + + ast = ast.parent; + } + + return null; + } + ASTHelpers.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); + + 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 { + TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); + var dotExpr = name; + return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); + } + } + ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; + })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); + var ASTHelpers = TypeScript.ASTHelpers; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function walkListChildren(preAst, walker) { + for (var i = 0, n = preAst.childCount(); i < n; i++) { + walker.walk(preAst.childAt(i)); + } + } + + function walkThrowStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkPrefixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkPostfixUnaryExpressionChildren(preAst, walker) { + walker.walk(preAst.operand); + } + + function walkDeleteExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkTypeArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArguments); + } + + function walkTypeOfExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkVoidExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkArgumentListChildren(preAst, walker) { + walker.walk(preAst.typeArgumentList); + walker.walk(preAst.arguments); + } + + function walkArrayLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.expressions); + } + + function walkSimplePropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.expression); + } + + function walkFunctionPropertyAssignmentChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkGetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkSeparatedListChildren(preAst, walker) { + for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { + walker.walk(preAst.nonSeparatorAt(i)); + } + } + + function walkSetAccessorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.parameterList); + walker.walk(preAst.block); + } + + function walkObjectLiteralExpressionChildren(preAst, walker) { + walker.walk(preAst.propertyAssignments); + } + + function walkCastExpressionChildren(preAst, walker) { + walker.walk(preAst.type); + walker.walk(preAst.expression); + } + + function walkParenthesizedExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkElementAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentExpression); + } + + function walkMemberAccessExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.name); + } + + function walkQualifiedNameChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkBinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.left); + walker.walk(preAst.right); + } + + function walkEqualsValueClauseChildren(preAst, walker) { + walker.walk(preAst.value); + } + + function walkTypeParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.constraint); + } + + function walkTypeParameterListChildren(preAst, walker) { + walker.walk(preAst.typeParameters); + } + + function walkGenericTypeChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.typeArgumentList); + } + + function walkTypeAnnotationChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkTypeQueryChildren(preAst, walker) { + walker.walk(preAst.name); + } + + function walkInvocationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkObjectCreationExpressionChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.argumentList); + } + + function walkTrinaryExpressionChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.whenTrue); + walker.walk(preAst.whenFalse); + } + + function walkFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFunctionTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.block); + walker.walk(preAst.expression); + } + + function walkMemberFunctionDeclarationChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkFuncDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkIndexMemberDeclarationChildren(preAst, walker) { + walker.walk(preAst.indexSignature); + } + + function walkIndexSignatureChildren(preAst, walker) { + walker.walk(preAst.parameter); + walker.walk(preAst.typeAnnotation); + } + + function walkCallSignatureChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.typeAnnotation); + } + + function walkConstraintChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkConstructorDeclarationChildren(preAst, walker) { + walker.walk(preAst.callSignature); + walker.walk(preAst.block); + } + + function walkConstructorTypeChildren(preAst, walker) { + walker.walk(preAst.typeParameterList); + walker.walk(preAst.parameterList); + walker.walk(preAst.type); + } + + function walkConstructSignatureChildren(preAst, walker) { + walker.walk(preAst.callSignature); + } + + function walkParameterChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkParameterListChildren(preAst, walker) { + walker.walk(preAst.parameters); + } + + function walkPropertySignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + } + + function walkVariableDeclaratorChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.equalsValueClause); + } + + function walkMemberVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.variableDeclarator); + } + + function walkMethodSignatureChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.callSignature); + } + + function walkReturnStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkForStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.initializer); + walker.walk(preAst.condition); + walker.walk(preAst.incrementor); + walker.walk(preAst.statement); + } + + function walkForInStatementChildren(preAst, walker) { + walker.walk(preAst.variableDeclaration); + walker.walk(preAst.left); + walker.walk(preAst.expression); + walker.walk(preAst.statement); + } + + function walkIfStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + walker.walk(preAst.elseClause); + } + + function walkElseClauseChildren(preAst, walker) { + walker.walk(preAst.statement); + } + + function walkWhileStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkDoStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkBlockChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkVariableDeclarationChildren(preAst, walker) { + walker.walk(preAst.declarators); + } + + function walkCaseSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.statements); + } + + function walkDefaultSwitchClauseChildren(preAst, walker) { + walker.walk(preAst.statements); + } + + function walkSwitchStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + walker.walk(preAst.switchClauses); + } + + function walkTryStatementChildren(preAst, walker) { + walker.walk(preAst.block); + walker.walk(preAst.catchClause); + walker.walk(preAst.finallyClause); + } + + function walkCatchClauseChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeAnnotation); + walker.walk(preAst.block); + } + + function walkExternalModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.stringLiteral); + } + + function walkFinallyClauseChildren(preAst, walker) { + walker.walk(preAst.block); + } + + function walkClassDeclChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.classElements); + } + + function walkScriptChildren(preAst, walker) { + walker.walk(preAst.moduleElements); + } + + function walkHeritageClauseChildren(preAst, walker) { + walker.walk(preAst.typeNames); + } + + function walkInterfaceDeclerationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.typeParameterList); + walker.walk(preAst.heritageClauses); + walker.walk(preAst.body); + } + + function walkObjectTypeChildren(preAst, walker) { + walker.walk(preAst.typeMembers); + } + + function walkArrayTypeChildren(preAst, walker) { + walker.walk(preAst.type); + } + + function walkModuleDeclarationChildren(preAst, walker) { + walker.walk(preAst.name); + walker.walk(preAst.stringLiteral); + walker.walk(preAst.moduleElements); + } + + function walkModuleNameModuleReferenceChildren(preAst, walker) { + walker.walk(preAst.moduleName); + } + + function walkEnumDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.enumElements); + } + + function walkEnumElementChildren(preAst, walker) { + walker.walk(preAst.propertyName); + walker.walk(preAst.equalsValueClause); + } + + function walkImportDeclarationChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.moduleReference); + } + + function walkExportAssignmentChildren(preAst, walker) { + walker.walk(preAst.identifier); + } + + function walkWithStatementChildren(preAst, walker) { + walker.walk(preAst.condition); + walker.walk(preAst.statement); + } + + function walkExpressionStatementChildren(preAst, walker) { + walker.walk(preAst.expression); + } + + function walkLabeledStatementChildren(preAst, walker) { + walker.walk(preAst.identifier); + walker.walk(preAst.statement); + } + + function walkVariableStatementChildren(preAst, walker) { + walker.walk(preAst.declaration); + } + + var childrenWalkers = new Array(246 /* Last */ + 1); + + for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { + childrenWalkers[i] = null; + } + for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { + childrenWalkers[i] = null; + } + + childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; + childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[60 /* AnyKeyword */] = null; + childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; + childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; + childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; + childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; + childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; + childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[146 /* Block */] = walkBlockChildren; + childrenWalkers[61 /* BooleanKeyword */] = null; + childrenWalkers[152 /* BreakStatement */] = null; + childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; + childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; + childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; + childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; + childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; + childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; + childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; + childrenWalkers[239 /* Constraint */] = walkConstraintChildren; + childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; + childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; + childrenWalkers[153 /* ContinueStatement */] = null; + childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; + childrenWalkers[162 /* DebuggerStatement */] = null; + childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; + childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; + childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; + childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; + childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; + childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; + childrenWalkers[156 /* EmptyStatement */] = null; + childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; + childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; + childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; + childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; + childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; + childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; + childrenWalkers[24 /* FalseKeyword */] = null; + childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; + childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; + childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; + childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; + childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; + childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; + childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; + childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; + childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; + childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; + childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; + childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; + childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; + childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; + childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; + childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; + childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; + childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; + childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; + childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; + childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; + childrenWalkers[1 /* List */] = walkListChildren; + childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; + childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; + childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; + childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; + childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; + childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; + childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; + childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; + childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; + childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; + childrenWalkers[11 /* IdentifierName */] = null; + childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[0 /* None */] = null; + childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; + childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; + childrenWalkers[32 /* NullKeyword */] = null; + childrenWalkers[67 /* NumberKeyword */] = null; + childrenWalkers[13 /* NumericLiteral */] = null; + childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; + childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; + childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; + childrenWalkers[223 /* OmittedExpression */] = null; + childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[242 /* Parameter */] = walkParameterChildren; + childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; + childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; + childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; + childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; + childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; + childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; + childrenWalkers[12 /* RegularExpressionLiteral */] = null; + childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; + childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; + childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; + childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; + childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; + childrenWalkers[14 /* StringLiteral */] = null; + childrenWalkers[69 /* StringKeyword */] = null; + childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; + childrenWalkers[50 /* SuperKeyword */] = null; + childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; + childrenWalkers[35 /* ThisKeyword */] = null; + childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; + childrenWalkers[3 /* TriviaList */] = null; + childrenWalkers[37 /* TrueKeyword */] = null; + childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; + childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; + childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; + childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; + childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; + childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; + childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; + childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; + childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; + childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; + childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; + childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; + childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; + childrenWalkers[41 /* VoidKeyword */] = null; + childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; + childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; + + for (var e in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { + TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); + } + } + + var AstWalkOptions = (function () { + function AstWalkOptions() { + this.goChildren = true; + this.stopWalking = false; + } + return AstWalkOptions; + })(); + TypeScript.AstWalkOptions = AstWalkOptions; + + var SimplePreAstWalker = (function () { + function SimplePreAstWalker(pre, state) { + this.pre = pre; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePreAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + }; + return SimplePreAstWalker; + })(); + + var SimplePrePostAstWalker = (function () { + function SimplePrePostAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + SimplePrePostAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + this.pre(ast, this.state); + + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + + this.post(ast, this.state); + }; + return SimplePrePostAstWalker; + })(); + + var NormalAstWalker = (function () { + function NormalAstWalker(pre, post, state) { + this.pre = pre; + this.post = post; + this.state = state; + this.options = new AstWalkOptions(); + } + NormalAstWalker.prototype.walk = function (ast) { + if (!ast) { + return; + } + + if (this.options.stopWalking) { + return; + } + + this.pre(ast, this); + + if (this.options.stopWalking) { + return; + } + + if (this.options.goChildren) { + var walker = childrenWalkers[ast.kind()]; + if (walker) { + walker(ast, this); + } + } else { + this.options.goChildren = true; + } + + if (this.post) { + this.post(ast, this); + } + }; + return NormalAstWalker; + })(); + + var AstWalkerFactory = (function () { + function AstWalkerFactory() { + } + AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { + new NormalAstWalker(pre, post, state).walk(ast); + }; + + AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { + if (post) { + new SimplePrePostAstWalker(pre, post, state).walk(ast); + } else { + new SimplePreAstWalker(pre, state).walk(ast); + } + }; + return AstWalkerFactory; + })(); + TypeScript.AstWalkerFactory = AstWalkerFactory; + + var globalAstWalkerFactory = new AstWalkerFactory(); + + function getAstWalkerFactory() { + return globalAstWalkerFactory; + } + TypeScript.getAstWalkerFactory = getAstWalkerFactory; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var Base64Format = (function () { + function Base64Format() { + } + Base64Format.encode = function (inValue) { + if (inValue < 64) { + return Base64Format.encodedValues.charAt(inValue); + } + throw TypeError(inValue + ": not a 64 based value"); + }; + + Base64Format.decodeChar = function (inChar) { + if (inChar.length === 1) { + return Base64Format.encodedValues.indexOf(inChar); + } else { + throw TypeError('"' + inChar + '" must have length 1'); + } + }; + Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + return Base64Format; + })(); + + var Base64VLQFormat = (function () { + function Base64VLQFormat() { + } + Base64VLQFormat.encode = function (inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } else { + inValue = inValue << 1; + } + + var encodedStr = ""; + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + encodedStr = encodedStr + Base64Format.encode(currentDigit); + } while(inValue > 0); + + return encodedStr; + }; + + Base64VLQFormat.decode = function (inString) { + var result = 0; + var negative = false; + + var shift = 0; + for (var i = 0; i < inString.length; i++) { + var byte = Base64Format.decodeChar(inString[i]); + if (i === 0) { + if ((byte & 1) === 1) { + negative = true; + } + result = (byte >> 1) & 15; + } else { + result = result | ((byte & 31) << shift); + } + + shift += (i === 0) ? 4 : 5; + + if ((byte & 32) === 32) { + } else { + return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; + } + } + + throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); + }; + return Base64VLQFormat; + })(); + TypeScript.Base64VLQFormat = Base64VLQFormat; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SourceMapPosition = (function () { + function SourceMapPosition() { + } + return SourceMapPosition; + })(); + TypeScript.SourceMapPosition = SourceMapPosition; + + var SourceMapping = (function () { + function SourceMapping() { + this.start = new SourceMapPosition(); + this.end = new SourceMapPosition(); + this.nameIndex = -1; + this.childMappings = []; + } + return SourceMapping; + })(); + TypeScript.SourceMapping = SourceMapping; + + var SourceMapEntry = (function () { + function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { + this.emittedFile = emittedFile; + this.emittedLine = emittedLine; + this.emittedColumn = emittedColumn; + this.sourceFile = sourceFile; + this.sourceLine = sourceLine; + this.sourceColumn = sourceColumn; + this.sourceName = sourceName; + TypeScript.Debug.assert(isFinite(emittedLine)); + TypeScript.Debug.assert(isFinite(emittedColumn)); + TypeScript.Debug.assert(isFinite(sourceColumn)); + TypeScript.Debug.assert(isFinite(sourceLine)); + } + return SourceMapEntry; + })(); + TypeScript.SourceMapEntry = SourceMapEntry; + + var SourceMapper = (function () { + function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { + this.jsFile = jsFile; + this.sourceMapOut = sourceMapOut; + this.names = []; + this.mappingLevel = []; + this.tsFilePaths = []; + this.allSourceMappings = []; + this.sourceMapEntries = []; + this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); + this.setNewSourceFile(document, emitOptions); + } + SourceMapper.prototype.getOutputFile = function () { + var result = this.sourceMapOut.getOutputFile(); + result.sourceMapEntries = this.sourceMapEntries; + + return result; + }; + + SourceMapper.prototype.increaseMappingLevel = function (ast) { + this.mappingLevel.push(ast); + }; + + SourceMapper.prototype.decreaseMappingLevel = function (ast) { + TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); + var expectedAst = this.mappingLevel.pop(); + var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; + var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; + TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); + }; + + SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { + var sourceMappings = []; + this.allSourceMappings.push(sourceMappings); + this.currentMappings = [sourceMappings]; + this.currentNameIndex = []; + + this.setNewSourceFilePath(document, emitOptions); + }; + + SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { + var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); + var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; + this.jsFileName = prettyJsFileName; + + if (emitOptions.sourceMapRootDirectory()) { + this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); + if (document.emitToOwnOutputFile()) { + this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); + } + + if (TypeScript.isRelative(this.sourceMapDirectory)) { + this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; + this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); + this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); + } else { + this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; + } + } else { + this.sourceMapPath = prettyMapFileName; + this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); + } + this.sourceRoot = emitOptions.sourceRootDirectory(); + }; + + SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { + var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); + if (emitOptions.sourceRootDirectory()) { + tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); + } else { + tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); + } + this.tsFilePaths.push(tsFilePath); + }; + + SourceMapper.prototype.emitSourceMapping = function () { + var _this = this; + TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { + return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); + }).join(', ')); + + this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); + + var mappingsString = ""; + + var prevEmittedColumn = 0; + var prevEmittedLine = 0; + var prevSourceColumn = 0; + var prevSourceLine = 0; + var prevSourceIndex = 0; + var prevNameIndex = 0; + var emitComma = false; + + var recordedPosition = null; + for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { + var recordSourceMapping = function (mappedPosition, nameIndex) { + if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { + return; + } + + if (prevEmittedLine !== mappedPosition.emittedLine) { + while (prevEmittedLine < mappedPosition.emittedLine) { + prevEmittedColumn = 0; + mappingsString = mappingsString + ";"; + prevEmittedLine++; + } + emitComma = false; + } else if (emitComma) { + mappingsString = mappingsString + ","; + } + + _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); + prevEmittedColumn = mappedPosition.emittedColumn; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); + prevSourceIndex = sourceIndex; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); + prevSourceLine = mappedPosition.sourceLine - 1; + + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); + prevSourceColumn = mappedPosition.sourceColumn; + + if (nameIndex >= 0) { + mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); + prevNameIndex = nameIndex; + } + + emitComma = true; + recordedPosition = mappedPosition; + }; + + var recordSourceMappingSiblings = function (sourceMappings) { + for (var i = 0; i < sourceMappings.length; i++) { + var sourceMapping = sourceMappings[i]; + recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); + recordSourceMappingSiblings(sourceMapping.childMappings); + recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); + } + }; + + recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); + } + + this.sourceMapOut.Write(JSON.stringify({ + version: 3, + file: this.jsFileName, + sourceRoot: this.sourceRoot, + sources: this.tsFilePaths, + names: this.names, + mappings: mappingsString + })); + + this.sourceMapOut.Close(); + }; + SourceMapper.MapFileExtension = ".map"; + return SourceMapper; + })(); + TypeScript.SourceMapper = SourceMapper; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (EmitContainer) { + EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; + EmitContainer[EmitContainer["Module"] = 1] = "Module"; + EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; + EmitContainer[EmitContainer["Class"] = 3] = "Class"; + EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; + EmitContainer[EmitContainer["Function"] = 5] = "Function"; + EmitContainer[EmitContainer["Args"] = 6] = "Args"; + EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; + })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); + var EmitContainer = TypeScript.EmitContainer; + + var EmitState = (function () { + function EmitState() { + this.column = 0; + this.line = 0; + this.container = 0 /* Prog */; + } + return EmitState; + })(); + TypeScript.EmitState = EmitState; + + var EmitOptions = (function () { + function EmitOptions(compiler, resolvePath) { + this.resolvePath = resolvePath; + this._diagnostic = null; + this._settings = null; + this._commonDirectoryPath = ""; + this._sharedOutputFile = ""; + this._sourceRootDirectory = ""; + this._sourceMapRootDirectory = ""; + this._outputDirectory = ""; + var settings = compiler.compilationSettings(); + this._settings = settings; + + 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()) { + if (settings.mapRoot()) { + if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } else { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } else if (settings.sourceRoot()) { + this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); + return; + } + } + + this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); + this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); + + if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { + if (settings.outFileOption()) { + this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); + } + + if (settings.outDirOption()) { + this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); + } + + if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { + this.determineCommonDirectoryPath(compiler); + } + } + } + EmitOptions.prototype.diagnostic = function () { + return this._diagnostic; + }; + + EmitOptions.prototype.commonDirectoryPath = function () { + return this._commonDirectoryPath; + }; + EmitOptions.prototype.sharedOutputFile = function () { + return this._sharedOutputFile; + }; + EmitOptions.prototype.sourceRootDirectory = function () { + return this._sourceRootDirectory; + }; + EmitOptions.prototype.sourceMapRootDirectory = function () { + return this._sourceMapRootDirectory; + }; + EmitOptions.prototype.outputDirectory = function () { + return this._outputDirectory; + }; + + EmitOptions.prototype.compilationSettings = function () { + return this._settings; + }; + + EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { + var commonComponents = []; + var commonComponentsLength = -1; + + var fileNames = compiler.fileNames(); + for (var i = 0, len = fileNames.length; i < len; i++) { + var fileName = fileNames[i]; + var document = compiler.getDocument(fileNames[i]); + var sourceUnit = document.sourceUnit(); + + if (!document.isDeclareFile()) { + var fileComponents = TypeScript.filePathComponents(fileName); + if (commonComponentsLength === -1) { + commonComponents = fileComponents; + commonComponentsLength = commonComponents.length; + } else { + var updatedPath = false; + for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { + if (commonComponents[j] !== fileComponents[j]) { + commonComponentsLength = j; + updatedPath = true; + + if (j === 0) { + 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; + } + + return; + } + + break; + } + } + + if (!updatedPath && fileComponents.length < commonComponentsLength) { + commonComponentsLength = fileComponents.length; + } + } + } + } + + this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; + }; + return EmitOptions; + })(); + TypeScript.EmitOptions = EmitOptions; + + var Indenter = (function () { + function Indenter() { + this.indentAmt = 0; + } + Indenter.prototype.increaseIndent = function () { + this.indentAmt += Indenter.indentStep; + }; + + Indenter.prototype.decreaseIndent = function () { + this.indentAmt -= Indenter.indentStep; + }; + + Indenter.prototype.getIndent = function () { + var indentString = Indenter.indentStrings[this.indentAmt]; + if (indentString === undefined) { + indentString = ""; + for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { + indentString += Indenter.indentStepString; + } + Indenter.indentStrings[this.indentAmt] = indentString; + } + return indentString; + }; + Indenter.indentStep = 4; + Indenter.indentStepString = " "; + Indenter.indentStrings = []; + return Indenter; + })(); + TypeScript.Indenter = Indenter; + + function lastParameterIsRest(parameterList) { + var parameters = parameterList.parameters; + return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; + } + TypeScript.lastParameterIsRest = lastParameterIsRest; + + var Emitter = (function () { + function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.outfile = outfile; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.globalThisCapturePrologueEmitted = false; + this.extendsPrologueEmitted = false; + this.thisClassNode = null; + this.inArrowFunction = false; + this.moduleName = ""; + this.emitState = new EmitState(); + this.indenter = new Indenter(); + this.sourceMapper = null; + this.captureThisStmtString = "var _this = this;"; + this.declStack = []; + this.exportAssignment = null; + this.inWithBlock = false; + this.document = null; + this.detachedCommentsElement = null; + } + Emitter.prototype.pushDecl = function (decl) { + if (decl) { + this.declStack[this.declStack.length] = decl; + } + }; + + Emitter.prototype.popDecl = function (decl) { + if (decl) { + this.declStack.length--; + } + }; + + Emitter.prototype.getEnclosingDecl = function () { + var declStackLen = this.declStack.length; + var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; + return enclosingDecl; + }; + + Emitter.prototype.setExportAssignment = function (exportAssignment) { + this.exportAssignment = exportAssignment; + }; + + Emitter.prototype.getExportAssignment = function () { + return this.exportAssignment; + }; + + Emitter.prototype.setDocument = function (document) { + this.document = document; + }; + + Emitter.prototype.shouldEmitImportDeclaration = 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 */; + + 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 */; + + this.emitComments(importDeclAST, true); + + var importSymbol = importDecl.getSymbol(); + + var parentSymbol = importSymbol.getContainer(); + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; + var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; + + var needsPropertyAssignment = false; + var usePropertyAssignmentInsteadOfVarDecl = false; + var moduleNamePrefix; + + 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 */)) { + needsPropertyAssignment = true; + } else { + usePropertyAssignmentInsteadOfVarDecl = true; + } + } + + if (this.emitState.container === 2 /* DynamicModule */) { + moduleNamePrefix = "exports."; + } else { + moduleNamePrefix = this.moduleName + "."; + } + } + + if (isAmdCodeGen && isExternalModuleReference) { + needsPropertyAssignment = true; + } else { + this.recordSourceMappingStart(importDeclAST); + if (usePropertyAssignmentInsteadOfVarDecl) { + this.writeToOutput(moduleNamePrefix); + } else { + this.writeToOutput("var "); + } + this.writeToOutput(importDeclAST.identifier.text() + " = "); + var aliasAST = importDeclAST.moduleReference; + + if (isExternalModuleReference) { + this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); + } else { + this.emitJavascript(aliasAST.moduleName, false); + } + + this.recordSourceMappingEnd(importDeclAST); + this.writeToOutput(";"); + + if (needsPropertyAssignment) { + this.writeLineToOutput(""); + this.emitIndent(); + } + } + + if (needsPropertyAssignment) { + this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); + this.writeToOutput(";"); + } + this.emitComments(importDeclAST, false); + }; + + Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { + this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); + }; + + Emitter.prototype.setSourceMapperNewSourceFile = function (document) { + this.sourceMapper.setNewSourceFile(document, this.emitOptions); + }; + + Emitter.prototype.updateLineAndColumn = function (s) { + var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); + if (lineNumbers.length > 1) { + this.emitState.line += lineNumbers.length - 1; + this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; + } else { + this.emitState.column += s.length; + } + }; + + Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { + this.recordSourceMappingStart(astSpan); + this.writeToOutput(s); + this.recordSourceMappingEnd(astSpan); + }; + + Emitter.prototype.writeToOutput = function (s) { + this.outfile.Write(s); + this.updateLineAndColumn(s); + }; + + Emitter.prototype.writeLineToOutput = function (s, force) { + if (typeof force === "undefined") { force = false; } + if (!force && s === "" && this.emitState.column === 0) { + return; + } + + this.outfile.WriteLine(s); + this.updateLineAndColumn(s); + this.emitState.column = 0; + this.emitState.line++; + }; + + Emitter.prototype.writeCaptureThisStatement = function (ast) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); + this.writeLineToOutput(""); + }; + + Emitter.prototype.setContainer = function (c) { + var temp = this.emitState.container; + this.emitState.container = c; + return temp; + }; + + Emitter.prototype.getIndentString = function () { + return this.indenter.getIndent(); + }; + + Emitter.prototype.emitIndent = function () { + this.writeToOutput(this.getIndentString()); + }; + + Emitter.prototype.emitComment = function (comment, trailing, first) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var text = getTrimmedTextLines(comment); + var emitColumn = this.emitState.column; + + if (emitColumn === 0) { + this.emitIndent(); + } else if (trailing && first) { + this.writeToOutput(" "); + } + + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + + if (text.length > 1 || comment.endsLine) { + for (var i = 1; i < text.length; i++) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput(text[i]); + } + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingEnd(comment); + this.writeToOutput(" "); + return; + } + } else { + this.recordSourceMappingStart(comment); + this.writeToOutput(text[0]); + this.recordSourceMappingEnd(comment); + this.writeLineToOutput(""); + } + + if (!trailing && emitColumn !== 0) { + this.emitIndent(); + } + }; + + Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { + 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; + } + } + + if (pre) { + var preComments = ast.preComments(); + + if (preComments && ast === this.detachedCommentsElement) { + var detachedComments = this.getDetachedComments(ast); + preComments = preComments.slice(detachedComments.length); + this.detachedCommentsElement = null; + } + + if (preComments && onlyPinnedOrTripleSlashComments) { + preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { + return _this.isPinnedOrTripleSlash(c); + }); + } + + this.emitCommentsArray(preComments, false); + } else { + this.emitCommentsArray(ast.postComments(), true); + } + }; + + Emitter.prototype.isPinnedOrTripleSlash = function (comment) { + var fullText = comment.fullText(); + if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { + return true; + } else { + return fullText.indexOf("/*!") === 0; + } + }; + + Emitter.prototype.emitCommentsArray = function (comments, trailing) { + if (!this.emitOptions.compilationSettings().removeComments() && comments) { + for (var i = 0, n = comments.length; i < n; i++) { + this.emitComment(comments[i], trailing, i === 0); + } + } + }; + + Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { + this.recordSourceMappingStart(objectLiteral); + + this.writeToOutput("{"); + this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); + this.writeToOutput("}"); + + this.recordSourceMappingEnd(objectLiteral); + }; + + Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { + this.recordSourceMappingStart(arrayLiteral); + + this.writeToOutput("["); + this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); + this.writeToOutput("]"); + + this.recordSourceMappingEnd(arrayLiteral); + }; + + Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { + this.recordSourceMappingStart(objectCreationExpression); + this.writeToOutput("new "); + var target = objectCreationExpression.expression; + + this.emit(target); + if (objectCreationExpression.argumentList) { + this.recordSourceMappingStart(objectCreationExpression.argumentList); + this.writeToOutput("("); + this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); + this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); + this.recordSourceMappingEnd(objectCreationExpression.argumentList); + } + + this.recordSourceMappingEnd(objectCreationExpression); + }; + + Emitter.prototype.getConstantDecl = function (dotExpr) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); + if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { + var pullDecls = pullSymbol.getDeclarations(); + if (pullDecls.length === 1) { + var pullDecl = pullDecls[0]; + if (pullDecl.kind === 67108864 /* EnumMember */) { + return pullDecl; + } + } + } + + return null; + }; + + Emitter.prototype.tryEmitConstant = function (dotExpr) { + var propertyName = dotExpr.name; + var boundDecl = this.getConstantDecl(dotExpr); + if (boundDecl) { + var value = boundDecl.constantValue; + if (value !== null) { + this.recordSourceMappingStart(dotExpr); + this.writeToOutput(value.toString()); + var comment = " /* "; + comment += propertyName.text(); + comment += " */"; + this.writeToOutput(comment); + this.recordSourceMappingEnd(dotExpr); + return true; + } + } + + return false; + }; + + Emitter.prototype.emitInvocationExpression = function (callNode) { + this.recordSourceMappingStart(callNode); + var target = callNode.expression; + var args = callNode.argumentList.arguments; + + if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { + this.emit(target); + this.writeToOutput(".call"); + this.recordSourceMappingStart(args); + this.writeToOutput("("); + this.emitThis(); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + } else { + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("_super.call"); + } else { + this.emitJavascript(target, false); + } + this.recordSourceMappingStart(args); + this.writeToOutput("("); + if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { + this.writeToOutput("this"); + if (args && args.nonSeparatorCount() > 0) { + this.writeToOutput(", "); + } + } + this.emitCommaSeparatedList(callNode.argumentList, args, "", false); + } + + this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); + this.recordSourceMappingEnd(args); + this.recordSourceMappingEnd(callNode); + }; + + Emitter.prototype.emitParameterList = function (list) { + this.writeToOutput("("); + this.emitCommentsArray(list.openParenTrailingComments, true); + this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); + this.writeToOutput(")"); + }; + + Emitter.prototype.emitFunctionParameters = function (parameters) { + var argsLen = 0; + + if (parameters) { + this.emitComments(parameters.ast, true); + + var tempContainer = this.setContainer(6 /* Args */); + argsLen = parameters.length; + var printLen = argsLen; + if (parameters.lastParameterIsRest()) { + printLen--; + } + for (var i = 0; i < printLen; i++) { + var arg = parameters.astAt(i); + this.emit(arg); + + if (i < (printLen - 1)) { + this.writeToOutput(", "); + } + } + this.setContainer(tempContainer); + + this.emitComments(parameters.ast, false); + } + }; + + Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { + this.writeLineToOutput(" {"); + if (name) { + this.recordSourceMappingNameStart(name); + } + + this.indenter.increaseIndent(); + + 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); + } else { + this.emitIndent(); + this.emitCommentsArray(bodyExpression.preComments(), false); + this.writeToOutput("return "); + this.emit(bodyExpression); + this.writeLineToOutput(";"); + this.emitCommentsArray(bodyExpression.postComments(), true); + } + + this.indenter.decreaseIndent(); + this.emitIndent(); + + if (block) { + this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); + } else { + this.writeToOutputWithSourceMapRecord("}", bodyExpression); + } + + if (name) { + this.recordSourceMappingNameEnd(); + } + }; + + Emitter.prototype.emitDefaultValueAssignments = function (parameters) { + var n = parameters.length; + if (parameters.lastParameterIsRest()) { + n--; + } + + for (var i = 0; i < n; i++) { + var arg = parameters.astAt(i); + var id = parameters.identifierAt(i); + var equalsValueClause = parameters.initializerAt(i); + if (equalsValueClause) { + this.emitIndent(); + this.recordSourceMappingStart(arg); + this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.emitJavascript(equalsValueClause, false); + this.writeLineToOutput("; }"); + this.recordSourceMappingEnd(arg); + } + } + }; + + Emitter.prototype.emitRestParameterInitializer = function (parameters) { + if (parameters.lastParameterIsRest()) { + var n = parameters.length; + var lastArg = parameters.astAt(n - 1); + var id = parameters.identifierAt(n - 1); + this.emitIndent(); + this.recordSourceMappingStart(lastArg); + this.writeToOutput("var "); + this.writeToOutputWithSourceMapRecord(id.text(), id); + this.writeLineToOutput(" = [];"); + this.recordSourceMappingEnd(lastArg); + this.emitIndent(); + this.writeToOutput("for ("); + this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); + this.writeToOutput(" "); + this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); + this.writeToOutput("; "); + this.writeToOutputWithSourceMapRecord("_i++", lastArg); + this.writeLineToOutput(") {"); + this.indenter.increaseIndent(); + this.emitIndent(); + + this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("}"); + } + }; + + Emitter.prototype.getImportDecls = function (fileName) { + var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + var result = []; + + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + var queue = dynamicModuleDecl.getChildDecls(); + + for (var i = 0, n = queue.length; i < n; i++) { + var decl = queue[i]; + + if (decl.kind & 128 /* TypeAlias */) { + var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var symbol = decl.getSymbol(); + var typeSymbol = symbol && symbol.type; + if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { + result.push(decl); + } + } + } + } + + return result; + }; + + Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { + var importList = ""; + var dependencyList = ""; + + var importDecls = this.getImportDecls(this.document.fileName); + + if (importDecls.length) { + for (var i = 0; i < importDecls.length; i++) { + var importStatementDecl = importDecls[i]; + var importStatementSymbol = importStatementDecl.getSymbol(); + var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); + + if (importStatementSymbol.isUsedAsValue()) { + if (i <= importDecls.length - 1) { + dependencyList += ", "; + importList += ", "; + } + + importList += importStatementDecl.name; + dependencyList += importStatementAST.moduleReference.stringLiteral.text(); + } + } + } + + var amdDependencies = this.document.amdDependencies(); + for (var i = 0; i < amdDependencies.length; i++) { + dependencyList += ", \"" + amdDependencies[i] + "\""; + } + + return { + importList: importList, + dependencyList: dependencyList + }; + }; + + Emitter.prototype.shouldCaptureThis = function (ast) { + if (ast.kind() === 120 /* SourceUnit */) { + var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); + return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); + } + + var decl = this.semanticInfoChain.getDeclForAST(ast); + if (decl) { + return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); + } + + return false; + }; + + Emitter.prototype.emitEnum = function (moduleDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + this.moduleName = moduleDecl.identifier.text(); + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleDecl.identifier); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleDecl.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(this.moduleName); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + this.emitSeparatedList(moduleDecl.enumElements); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { + return moduleDecl; + } else if (changeNameIfAnyDeclarationInContext) { + var symbol = moduleDecl.getSymbol(); + if (symbol) { + var otherDecls = symbol.getDeclarations(); + for (var i = 0; i < otherDecls.length; i++) { + if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { + return otherDecls[i]; + } + } + } + } + + return null; + }; + + Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { + var _this = this; + var childDecls = parentDecl.getChildDecls(); + return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { + 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; + } + } + return false; + }); + }; + + Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { + var moduleName = moduleDecl.name; + var moduleDisplayName = moduleDecl.getDisplayName(); + + moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); + if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { + while (this.hasChildNameCollision(moduleName, moduleDecl)) { + moduleName = "_" + moduleName; + moduleDisplayName = "_" + moduleDisplayName; + } + } + + return moduleDisplayName; + }; + + Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { + if (moduleDecl.stringLiteral) { + this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); + } + }; + + Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); + + if (isLastName) { + this.emitComments(moduleDecl, true); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); + this.pushDecl(pullDecl); + + var svModuleName = this.moduleName; + + if (moduleDecl.stringLiteral) { + this.moduleName = moduleDecl.stringLiteral.valueText(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + } else { + this.moduleName = moduleName.text(); + } + + var temp = this.setContainer(1 /* Module */); + var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); + + if (!isExported) { + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("var "); + this.recordSourceMappingStart(moduleName); + this.writeToOutput(this.moduleName); + this.recordSourceMappingEnd(moduleName); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(moduleDecl); + this.emitIndent(); + } + + this.writeToOutput("("); + this.recordSourceMappingStart(moduleDecl); + this.writeToOutput("function ("); + + this.moduleName = this.getModuleName(pullDecl); + this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart(moduleName.text()); + + this.indenter.increaseIndent(); + + if (this.shouldCaptureThis(moduleDecl)) { + this.writeCaptureThisStatement(moduleDecl); + } + + if (moduleName === moduleDecl.stringLiteral) { + this.emitList(moduleDecl.moduleElements); + } else { + var moduleNames = TypeScript.getModuleNames(moduleDecl.name); + var nameIndex = moduleNames.indexOf(moduleName); + TypeScript.Debug.assert(nameIndex >= 0); + + if (isLastName) { + this.emitList(moduleDecl.moduleElements); + } else { + this.emitIndent(); + this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); + this.writeLineToOutput(""); + } + } + + this.moduleName = moduleName.text(); + this.indenter.decreaseIndent(); + this.emitIndent(); + + var parentIsDynamic = temp === 2 /* DynamicModule */; + this.recordSourceMappingStart(moduleDecl.endingToken); + if (temp === 0 /* Prog */ && isExported) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); + } else if (isExported || temp === 0 /* Prog */) { + var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); + } else if (!isExported && temp !== 0 /* Prog */) { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); + } else { + this.writeToOutput("}"); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(moduleDecl.endingToken); + this.writeToOutput(")();"); + } + + this.recordSourceMappingEnd(moduleDecl); + if (temp !== 0 /* Prog */ && isExported) { + this.recordSourceMappingStart(moduleDecl); + if (parentIsDynamic) { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); + } else { + this.writeLineToOutput(""); + this.emitIndent(); + this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); + } + this.recordSourceMappingEnd(moduleDecl); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + + this.popDecl(pullDecl); + + if (isLastName) { + this.emitComments(moduleDecl, false); + } + }; + + Emitter.prototype.emitEnumElement = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + var name = varDecl.propertyName.text(); + var quoted = TypeScript.isQuoted(name); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(this.moduleName); + this.writeToOutput('['); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.writeToOutput(']'); + + if (varDecl.equalsValueClause) { + this.emit(varDecl.equalsValueClause); + } else if (pullDecl.constantValue !== null) { + this.writeToOutput(' = '); + this.writeToOutput(pullDecl.constantValue.toString()); + } else { + this.writeToOutput(' = null'); + } + + this.writeToOutput('] = '); + this.writeToOutput(quoted ? name : '"' + name + '"'); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + this.writeToOutput(';'); + }; + + Emitter.prototype.emitElementAccessExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("["); + this.emit(expression.argumentExpression); + this.writeToOutput("]"); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { + this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); + }; + + Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = true; + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(arrowFunction); + + var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); + this.pushDecl(pullDecl); + + this.emitComments(arrowFunction, true); + + this.recordSourceMappingStart(arrowFunction); + this.writeToOutput("function "); + this.writeToOutput("("); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); + + this.recordSourceMappingEnd(arrowFunction); + + this.recordSourceMappingEnd(arrowFunction); + + this.emitComments(arrowFunction, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConstructor = function (funcDecl) { + if (!funcDecl.block) { + return; + } + var temp = this.setContainer(4 /* Constructor */); + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + this.writeToOutput(this.thisClassNode.identifier.text()); + this.writeToOutput("("); + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeLineToOutput(") {"); + + this.recordSourceMappingNameStart("constructor"); + this.indenter.increaseIndent(); + + this.emitDefaultValueAssignments(parameters); + this.emitRestParameterInitializer(parameters); + + if (this.shouldCaptureThis(funcDecl)) { + this.writeCaptureThisStatement(funcDecl); + } + + this.emitConstructorStatements(funcDecl); + this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + this.setContainer(temp); + }; + + Emitter.prototype.emitGetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("get "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitSetAccessor = function (accessor) { + this.recordSourceMappingStart(accessor); + this.writeToOutput("set "); + + var temp = this.setContainer(5 /* Function */); + + this.recordSourceMappingStart(accessor); + + var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(accessor); + + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); + var container = accessorSymbol.getContainer(); + var containerKind = container.kind; + + this.recordSourceMappingNameStart(accessor.propertyName.text()); + this.writeToOutput(accessor.propertyName.text()); + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); + + this.recordSourceMappingEnd(accessor); + + this.recordSourceMappingEnd(accessor); + + this.popDecl(pullDecl); + this.setContainer(temp); + this.recordSourceMappingEnd(accessor); + }; + + Emitter.prototype.emitFunctionExpression = function (funcDecl) { + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; + + this.recordSourceMappingStart(funcDecl); + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + this.writeToOutput(funcDecl.identifier.text()); + this.recordSourceMappingEnd(funcDecl.identifier); + } + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitFunction = function (funcDecl) { + if (funcDecl.block === null) { + return; + } + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + + var funcName = funcDecl.identifier.text(); + + this.recordSourceMappingStart(funcDecl); + + var printName = funcDecl.identifier !== null; + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.emitComments(funcDecl, true); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + if (printName) { + var id = funcDecl.identifier.text(); + if (id) { + if (funcDecl.identifier) { + this.recordSourceMappingStart(funcDecl.identifier); + } + this.writeToOutput(id); + if (funcDecl.identifier) { + this.recordSourceMappingEnd(funcDecl.identifier); + } + } + } + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + + if (funcDecl.block) { + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; + this.recordSourceMappingStart(funcDecl); + this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); + this.recordSourceMappingEnd(funcDecl); + } + } + }; + + Emitter.prototype.emitAmbientVarDecl = function (varDecl) { + this.recordSourceMappingStart(this.currentVariableDeclaration); + if (varDecl.equalsValueClause) { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + this.emitJavascript(varDecl.equalsValueClause, false); + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + }; + + Emitter.prototype.emitVarDeclVar = function () { + if (this.currentVariableDeclaration) { + this.writeToOutput("var "); + } + }; + + Emitter.prototype.emitVariableDeclaration = function (declaration) { + var varDecl = declaration.declarators.nonSeparatorAt(0); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; + + this.emitComments(declaration, true); + + var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); + var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; + if (!isAmbientWithoutInit) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.currentVariableDeclaration = declaration; + + for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { + var declarator = declaration.declarators.nonSeparatorAt(i); + + if (i > 0) { + this.writeToOutput(", "); + } + + this.emit(declarator); + } + this.currentVariableDeclaration = prevVariableDeclaration; + + this.recordSourceMappingEnd(declaration); + } + + this.emitComments(declaration, false); + }; + + Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { + TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); + + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + + this.emitComments(varDecl, true); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + + if (quotedOrNumber) { + this.writeToOutput("this["); + } else { + this.writeToOutput("this."); + } + + this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); + + if (quotedOrNumber) { + this.writeToOutput("]"); + } + + if (varDecl.variableDeclarator.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.variableDeclarator.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + if (this.emitState.container !== 6 /* Args */) { + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitVariableDeclarator = function (varDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); + this.pushDecl(pullDecl); + if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { + this.emitAmbientVarDecl(varDecl); + } else { + this.emitComments(varDecl, true); + this.recordSourceMappingStart(this.currentVariableDeclaration); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.propertyName.text(); + + var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); + var parentSymbol = symbol ? symbol.getContainer() : null; + var parentDecl = pullDecl && pullDecl.getParentDecl(); + var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); + + if (parentIsModule) { + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.emitVarDeclVar(); + } else { + if (this.emitState.container === 2 /* DynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.moduleName + "."); + } + } + } else { + this.emitVarDeclVar(); + } + + this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); + + if (varDecl.equalsValueClause) { + var prevVariableDeclaration = this.currentVariableDeclaration; + this.emit(varDecl.equalsValueClause); + this.currentVariableDeclaration = prevVariableDeclaration; + } + + this.recordSourceMappingEnd(varDecl); + this.emitComments(varDecl, false); + } + this.currentVariableDeclaration = undefined; + this.popDecl(pullDecl); + }; + + Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { + if (typeof dynamic === "undefined") { dynamic = false; } + var symDecls = symbol.getDeclarations(); + + if (symDecls.length) { + var enclosingDecl = this.getEnclosingDecl(); + if (enclosingDecl) { + var parentDecl = symDecls[0].getParentDecl(); + if (parentDecl) { + var symbolDeclarationEnclosingContainer = parentDecl; + var enclosingContainer = enclosingDecl; + + while (symbolDeclarationEnclosingContainer) { + if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); + } + + if (symbolDeclarationEnclosingContainer) { + while (enclosingContainer) { + if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { + break; + } + + enclosingContainer = enclosingContainer.getParentDecl(); + } + } + + if (symbolDeclarationEnclosingContainer && enclosingContainer) { + var same = symbolDeclarationEnclosingContainer === enclosingContainer; + + if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { + same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); + } + + return same; + } + } + } + } + + return false; + }; + + Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { + var decl = pullSymbol.getDeclarations()[0]; + var parentDecl = decl.getParentDecl(); + var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; + + var enclosingContextDeclPath = this.declStack; + var commonNodeIndex = -1; + + if (enclosingContextDeclPath.length) { + for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { + var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; + for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { + var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; + if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { + commonNodeIndex = i; + break; + } + } + + if (commonNodeIndex >= 0) { + break; + } + } + } + + var startingIndex = symbolContainerDeclPath.length - 1; + for (var i = startingIndex - 1; i > commonNodeIndex; i--) { + if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { + startingIndex = i; + } else { + break; + } + } + return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; + }; + + Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { + for (var i = startingIndex; i <= lastIndex; i++) { + if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { + this.writeToOutput("exports."); + } else { + this.writeToOutput(this.getModuleName(declPath[i], true) + "."); + } + } + }; + + Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { + var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); + var potentialDeclPath = declPathInfo.potentialPath; + var startingIndex = declPathInfo.startingIndex; + + this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); + }; + + Emitter.prototype.getSymbolForEmit = function (ast) { + var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); + var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); + if (pullSymbol && pullSymbolAlias) { + var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); + + if (pullSymbol === symbolToCompare) { + pullSymbol = pullSymbolAlias; + pullSymbolAlias = null; + } + } + return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; + }; + + Emitter.prototype.emitName = function (name, addThis) { + this.emitComments(name, true); + this.recordSourceMappingStart(name); + if (name.text().length > 0) { + var symbolForEmit = this.getSymbolForEmit(name); + var pullSymbol = symbolForEmit.symbol; + if (!pullSymbol) { + pullSymbol = this.semanticInfoChain.anyTypeSymbol; + } + var pullSymbolAlias = symbolForEmit.aliasSymbol; + var pullSymbolKind = pullSymbol.kind; + var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); + if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { + var pullSymbolContainer = pullSymbol.getContainer(); + + if (pullSymbolContainer) { + var pullSymbolContainerKind = pullSymbolContainer.kind; + + if (pullSymbolContainerKind === 8 /* Class */) { + if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbolKind === 4096 /* Property */) { + this.emitThis(); + this.writeToOutput("."); + } + } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { + this.emitSymbolContainerNameInEnclosingContext(pullSymbol); + } + } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { + if (pullSymbolKind === 4096 /* Property */) { + this.writeToOutput("exports."); + } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { + this.writeToOutput("exports."); + } + } + } + } + + this.writeToOutput(name.text()); + } + + this.recordSourceMappingEnd(name); + this.emitComments(name, false); + }; + + Emitter.prototype.recordSourceMappingNameStart = function (name) { + if (this.sourceMapper) { + var nameIndex = -1; + if (name) { + if (this.sourceMapper.currentNameIndex.length > 0) { + var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { + break; + } + } + + if (nameIndex === -1) { + nameIndex = this.sourceMapper.names.length; + this.sourceMapper.names.push(name); + } + } + this.sourceMapper.currentNameIndex.push(nameIndex); + } + }; + + Emitter.prototype.recordSourceMappingNameEnd = function () { + if (this.sourceMapper) { + this.sourceMapper.currentNameIndex.pop(); + } + }; + + Emitter.prototype.recordSourceMappingStart = function (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; + sourceMapping.start.emittedLine = this.emitState.line; + + var lineMap = this.document.lineMap(); + lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); + sourceMapping.start.sourceColumn = lineCol.character; + sourceMapping.start.sourceLine = lineCol.line + 1; + lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); + sourceMapping.end.sourceColumn = lineCol.character; + sourceMapping.end.sourceLine = lineCol.line + 1; + + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); + + if (this.sourceMapper.currentNameIndex.length > 0) { + sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; + } + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + siblings.push(sourceMapping); + this.sourceMapper.currentMappings.push(sourceMapping.childMappings); + this.sourceMapper.increaseMappingLevel(ast); + } + }; + + Emitter.prototype.recordSourceMappingEnd = function (ast) { + if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { + this.sourceMapper.currentMappings.pop(); + + var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; + var sourceMapping = siblings[siblings.length - 1]; + + sourceMapping.end.emittedColumn = this.emitState.column; + sourceMapping.end.emittedLine = this.emitState.line; + + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); + TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); + + this.sourceMapper.decreaseMappingLevel(ast); + } + }; + + Emitter.prototype.getOutputFiles = function () { + var result = []; + if (this.sourceMapper !== null) { + this.sourceMapper.emitSourceMapping(); + result.push(this.sourceMapper.getOutputFile()); + } + + result.push(this.outfile.getOutputFile()); + return result; + }; + + Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { + var constructorDecl = getLastConstructor(this.thisClassNode); + + 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(); + this.recordSourceMappingStart(parameter); + this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); + this.writeToOutput(" = "); + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); + this.writeLineToOutput(";"); + this.recordSourceMappingEnd(parameter); + } + } + } + + for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { + if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = this.thisClassNode.classElements.childAt(i); + if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitIndent(); + this.emitMemberVariableDeclaration(varDecl); + this.writeLineToOutput(""); + } + } + } + }; + + Emitter.prototype.isOnSameLine = function (pos1, pos2) { + var lineMap = this.document.lineMap(); + return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); + }; + + Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { + if (list === null || list.nonSeparatorCount() === 0) { + return; + } + + var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); + + if (preserveNewLines) { + this.indenter.increaseIndent(); + } + + if (startLine) { + this.writeLineToOutput(""); + } else { + this.writeToOutput(buffer); + } + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + var emitNode = list.nonSeparatorAt(i); + + this.emitJavascript(emitNode, startLine); + + if (i < (n - 1)) { + startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); + if (startLine) { + this.writeLineToOutput(","); + } else { + this.writeToOutput(", "); + } + } + } + + if (preserveNewLines) { + this.indenter.decreaseIndent(); + } + + if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(buffer); + } + }; + + Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { + if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } + if (typeof startInclusive === "undefined") { startInclusive = 0; } + if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } + if (list === null) { + return; + } + + this.emitComments(list, true); + var lastEmittedNode = null; + + for (var i = startInclusive; i < endExclusive; i++) { + var node = list.nonSeparatorAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + if (useNewLineSeparator) { + this.writeLineToOutput(""); + } + + lastEmittedNode = node; + } + } + + this.emitComments(list, false); + }; + + Emitter.prototype.isDirectivePrologueElement = function (node) { + if (node.kind() === 149 /* ExpressionStatement */) { + var exprStatement = node; + return exprStatement.expression.kind() === 14 /* StringLiteral */; + } + + return false; + }; + + Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { + if (node1 === null || node2 === null) { + return; + } + + if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { + return; + } + + var lineMap = this.document.lineMap(); + var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); + var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); + + if ((node2StartLine - node1EndLine) > 1) { + this.writeLineToOutput("", true); + } + }; + + Emitter.prototype.getDetachedComments = function (element) { + var preComments = element.preComments(); + if (preComments) { + var lineMap = this.document.lineMap(); + + var detachedComments = []; + var lastComment = null; + + for (var i = 0, n = preComments.length; i < n; i++) { + var comment = preComments[i]; + + if (lastComment) { + var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); + var commentLine = lineMap.getLineNumberFromPosition(comment.start()); + + if (commentLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + detachedComments.push(comment); + lastComment = comment; + } + + var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); + var astLine = lineMap.getLineNumberFromPosition(element.start()); + if (astLine >= lastCommentLine + 2) { + return detachedComments; + } + } + + return []; + }; + + Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { + this.emitDetachedComments(script.moduleElements); + }; + + Emitter.prototype.emitDetachedComments = function (list) { + if (list.childCount() > 0) { + var firstElement = list.childAt(0); + + this.detachedCommentsElement = firstElement; + this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); + } + }; + + Emitter.prototype.emitScriptElements = function (sourceUnit) { + var list = sourceUnit.moduleElements; + + this.emitPossibleCopyrightHeaders(sourceUnit); + + for (var i = 0, n = list.childCount(); i < n; i++) { + var node = list.childAt(i); + + if (!this.isDirectivePrologueElement(node)) { + break; + } + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + } + + this.emitPrologue(sourceUnit); + + var isExternalModule = this.document.isExternalModule(); + var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); + if (isNonElidedExternalModule) { + this.recordSourceMappingStart(sourceUnit); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + var dependencyList = "[\"require\", \"exports\""; + var importList = "require, exports"; + + var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); + importList += importAndDependencyList.importList; + dependencyList += importAndDependencyList.dependencyList + "]"; + + this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); + } + } + + if (isExternalModule) { + var temp = this.setContainer(2 /* DynamicModule */); + + var svModuleName = this.moduleName; + this.moduleName = sourceUnit.fileName(); + if (TypeScript.isTSFile(this.moduleName)) { + this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); + } + + this.setExportAssignment(null); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.increaseIndent(); + } + + var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); + + if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { + this.writeCaptureThisStatement(sourceUnit); + } + + this.pushDecl(externalModule); + } + + this.emitList(list, true, i, n); + + if (isExternalModule) { + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + this.indenter.decreaseIndent(); + } + + if (isNonElidedExternalModule) { + var exportAssignment = this.getExportAssignment(); + var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; + var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); + + if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { + if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.indenter.increaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); + this.writeLineToOutput(";"); + this.indenter.decreaseIndent(); + } + this.writeToOutput("});"); + } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); + this.writeToOutput(";"); + } + + this.recordSourceMappingEnd(sourceUnit); + this.writeLineToOutput(""); + } + + this.setContainer(temp); + this.moduleName = svModuleName; + this.popDecl(externalModule); + } + }; + + Emitter.prototype.emitConstructorStatements = function (funcDecl) { + var list = funcDecl.block.statements; + + if (list === null) { + return; + } + + this.emitComments(list, true); + + var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; + var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; + var lastEmittedNode = null; + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + var node = list.childAt(i); + + if (this.shouldEmit(node)) { + this.emitSpaceBetweenConstructs(lastEmittedNode, node); + + this.emitJavascript(node, true); + this.writeLineToOutput(""); + + lastEmittedNode = node; + } + } + + if (i === propertyAssignmentIndex) { + this.emitParameterPropertyAndMemberVariableAssignments(); + } + + this.emitComments(list, false); + }; + + Emitter.prototype.emitJavascript = function (ast, startLine) { + if (ast === null) { + return; + } + + if (startLine && this.indenter.indentAmt > 0) { + this.emitIndent(); + } + + this.emit(ast); + }; + + Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { + if (funcDecl.kind() !== 139 /* GetAccessor */) { + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + if (accessorSymbol.getGetter()) { + return; + } + } + + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + + this.writeToOutput("Object.defineProperty(" + className); + if (isProto) { + this.writeToOutput(".prototype, "); + } else { + this.writeToOutput(", "); + } + + var functionName = name.text(); + if (TypeScript.isQuoted(functionName)) { + this.writeToOutput(functionName); + } else { + this.writeToOutput('"' + functionName + '"'); + } + + this.writeLineToOutput(", {"); + + this.indenter.increaseIndent(); + + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + if (accessors.getter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.getter); + this.emitComments(accessors.getter, true); + this.writeToOutput("get: "); + this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); + this.writeLineToOutput(","); + } + + if (accessors.setter) { + this.emitIndent(); + this.recordSourceMappingStart(accessors.setter); + this.emitComments(accessors.setter, true); + this.writeToOutput("set: "); + this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); + this.writeLineToOutput(","); + } + + this.emitIndent(); + this.writeLineToOutput("enumerable: true,"); + this.emitIndent(); + this.writeLineToOutput("configurable: true"); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeLineToOutput("});"); + this.recordSourceMappingEnd(funcDecl); + }; + + Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClass = function (classDecl) { + var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.pushDecl(pullDecl); + + var svClassNode = this.thisClassNode; + this.thisClassNode = classDecl; + var className = classDecl.identifier.text(); + this.emitComments(classDecl, true); + var temp = this.setContainer(3 /* Class */); + + this.recordSourceMappingStart(classDecl); + this.writeToOutput("var " + className); + + var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; + var baseTypeReference = null; + var varDecl = null; + + if (hasBaseClass) { + this.writeLineToOutput(" = (function (_super) {"); + } else { + this.writeLineToOutput(" = (function () {"); + } + + this.recordSourceMappingNameStart(className); + this.indenter.increaseIndent(); + + if (hasBaseClass) { + baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); + this.writeLineToOutput(";"); + } + + this.emitIndent(); + + var constrDecl = getLastConstructor(classDecl); + + if (constrDecl) { + this.emit(constrDecl); + this.writeLineToOutput(""); + } else { + this.recordSourceMappingStart(classDecl); + + this.indenter.increaseIndent(); + this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); + this.recordSourceMappingNameStart("constructor"); + if (hasBaseClass) { + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); + this.writeLineToOutput(";"); + } + + if (this.shouldCaptureThis(classDecl)) { + this.writeCaptureThisStatement(classDecl); + } + + this.emitParameterPropertyAndMemberVariableAssignments(); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.writeLineToOutput(""); + + this.recordSourceMappingNameEnd(); + this.recordSourceMappingEnd(classDecl); + } + + this.emitClassMembers(classDecl); + + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); + this.writeLineToOutput(""); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); + this.recordSourceMappingNameEnd(); + this.recordSourceMappingStart(classDecl); + this.writeToOutput(")("); + if (hasBaseClass) { + this.emitJavascript(baseTypeReference, false); + } + this.writeToOutput(");"); + this.recordSourceMappingEnd(classDecl); + + if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + this.writeLineToOutput(""); + this.emitIndent(); + var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; + this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); + } + + this.recordSourceMappingEnd(classDecl); + this.emitComments(classDecl, false); + this.setContainer(temp); + this.thisClassNode = svClassNode; + + this.popDecl(pullDecl); + }; + + Emitter.prototype.emitClassMembers = function (classDecl) { + var lastEmittedMember = null; + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 139 /* GetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var getter = memberDecl; + this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 140 /* SetAccessor */) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + var setter = memberDecl; + this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); + lastEmittedMember = memberDecl; + } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { + var memberFunction = memberDecl; + + if (memberFunction.block) { + this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); + + this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); + lastEmittedMember = memberDecl; + } + } + } + + for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { + var memberDecl = classDecl.classElements.childAt(i); + + if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { + var varDecl = memberDecl; + + if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { + this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); + + this.emitIndent(); + this.recordSourceMappingStart(varDecl); + + var varDeclName = varDecl.variableDeclarator.propertyName.text(); + if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); + } else { + this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); + } + + this.emit(varDecl.variableDeclarator.equalsValueClause); + + this.recordSourceMappingEnd(varDecl); + this.writeLineToOutput(";"); + + lastEmittedMember = varDecl; + } + } + } + }; + + Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { + this.emitIndent(); + this.recordSourceMappingStart(funcDecl); + this.emitComments(funcDecl, true); + var functionName = funcDecl.propertyName.text(); + + this.writeToOutput(classDecl.identifier.text()); + + if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + this.writeToOutput(".prototype"); + } + + if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { + this.writeToOutput("[" + functionName + "] = "); + } else { + this.writeToOutput("." + functionName + " = "); + } + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcDecl); + this.writeToOutput("function "); + + this.emitParameterList(funcDecl.callSignature.parameterList); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); + this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); + + this.recordSourceMappingEnd(funcDecl); + + this.emitComments(funcDecl, false); + + this.recordSourceMappingEnd(funcDecl); + this.popDecl(pullDecl); + + this.writeLineToOutput(";"); + }; + + Emitter.prototype.requiresExtendsBlock = function (moduleElements) { + for (var i = 0, n = moduleElements.childCount(); i < n; i++) { + var moduleElement = moduleElements.childAt(i); + + if (moduleElement.kind() === 130 /* ModuleDeclaration */) { + var moduleAST = moduleElement; + + if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { + return true; + } + } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { + var classDeclaration = moduleElement; + + if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitPrologue = function (sourceUnit) { + if (!this.extendsPrologueEmitted) { + if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { + this.extendsPrologueEmitted = true; + this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); + this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); + this.writeLineToOutput(" function __() { this.constructor = d; }"); + this.writeLineToOutput(" __.prototype = b.prototype;"); + this.writeLineToOutput(" d.prototype = new __();"); + this.writeLineToOutput("};"); + } + } + + if (!this.globalThisCapturePrologueEmitted) { + if (this.shouldCaptureThis(sourceUnit)) { + this.globalThisCapturePrologueEmitted = true; + this.writeLineToOutput(this.captureThisStmtString); + } + } + }; + + Emitter.prototype.emitThis = function () { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutput("_this"); + } else { + this.writeToOutput("this"); + } + }; + + Emitter.prototype.emitBlockOrStatement = function (node) { + if (node.kind() === 146 /* Block */) { + this.emit(node); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emitJavascript(node, true); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitLiteralExpression = function (expression) { + switch (expression.kind()) { + case 32 /* NullKeyword */: + this.writeToOutputWithSourceMapRecord("null", expression); + break; + case 24 /* FalseKeyword */: + this.writeToOutputWithSourceMapRecord("false", expression); + break; + case 37 /* TrueKeyword */: + this.writeToOutputWithSourceMapRecord("true", expression); + break; + default: + throw TypeScript.Errors.abstract(); + } + }; + + Emitter.prototype.emitThisExpression = function (expression) { + if (!this.inWithBlock && this.inArrowFunction) { + this.writeToOutputWithSourceMapRecord("_this", expression); + } else { + this.writeToOutputWithSourceMapRecord("this", expression); + } + }; + + Emitter.prototype.emitSuperExpression = function (expression) { + this.writeToOutputWithSourceMapRecord("_super.prototype", expression); + }; + + Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { + if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { + this.emit(parenthesizedExpression.expression); + } else { + this.recordSourceMappingStart(parenthesizedExpression); + this.writeToOutput("("); + this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); + this.emit(parenthesizedExpression.expression); + this.writeToOutput(")"); + this.recordSourceMappingEnd(parenthesizedExpression); + } + }; + + Emitter.prototype.emitCastExpression = function (expression) { + this.emit(expression.expression); + }; + + Emitter.prototype.emitPrefixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 167 /* LogicalNotExpression */: + this.writeToOutput("!"); + this.emit(expression.operand); + break; + case 166 /* BitwiseNotExpression */: + this.writeToOutput("~"); + this.emit(expression.operand); + break; + case 165 /* NegateExpression */: + this.writeToOutput("-"); + if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 164 /* PlusExpression */: + this.writeToOutput("+"); + if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { + this.writeToOutput(" "); + } + this.emit(expression.operand); + break; + case 168 /* PreIncrementExpression */: + this.writeToOutput("++"); + this.emit(expression.operand); + break; + case 169 /* PreDecrementExpression */: + this.writeToOutput("--"); + this.emit(expression.operand); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitPostfixUnaryExpression = function (expression) { + var nodeType = expression.kind(); + + this.recordSourceMappingStart(expression); + switch (nodeType) { + case 210 /* PostIncrementExpression */: + this.emit(expression.operand); + this.writeToOutput("++"); + break; + case 211 /* PostDecrementExpression */: + this.emit(expression.operand); + this.writeToOutput("--"); + break; + default: + throw TypeScript.Errors.abstract(); + } + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitTypeOfExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("typeof "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDeleteExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("delete "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitVoidExpression = function (expression) { + this.recordSourceMappingStart(expression); + this.writeToOutput("void "); + this.emit(expression.expression); + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { + var memberExpressionNodeType = expression.expression.kind(); + + 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 */) { + return this.canEmitDottedNameMemberAccessExpression(expression.expression); + } + + return true; + } + } + } + + return false; + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { + this.recordSourceMappingStart(expression); + if (expression.expression.kind() === 212 /* MemberAccessExpression */) { + this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); + } else { + this.emitComments(expression.expression, true); + this.recordSourceMappingStart(expression.expression); + + this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); + + this.writeToOutput(expression.expression.text()); + + this.recordSourceMappingEnd(expression.expression); + this.emitComments(expression.expression, false); + } + + this.writeToOutput("."); + this.emitName(expression.name, false); + + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { + this.emitComments(expression, true); + + if (lastIndex - startingIndex < 1) { + startingIndex = lastIndex - 1; + TypeScript.Debug.assert(startingIndex >= 0); + } + + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); + this.emitComments(expression, false); + }; + + Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { + var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; + + var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); + this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); + }; + + Emitter.prototype.emitMemberAccessExpression = function (expression) { + if (!this.tryEmitConstant(expression)) { + if (this.canEmitDottedNameMemberAccessExpression(expression)) { + this.emitDottedNameMemberAccessExpression(expression); + } else { + this.recordSourceMappingStart(expression); + this.emit(expression.expression); + this.writeToOutput("."); + this.emitName(expression.name, false); + this.recordSourceMappingEnd(expression); + } + } + }; + + Emitter.prototype.emitQualifiedName = function (name) { + this.recordSourceMappingStart(name); + + this.emit(name.left); + this.writeToOutput("."); + this.emitName(name.right, false); + + this.recordSourceMappingEnd(name); + }; + + Emitter.prototype.emitBinaryExpression = function (expression) { + this.recordSourceMappingStart(expression); + switch (expression.kind()) { + case 173 /* CommaExpression */: + this.emit(expression.left); + this.writeToOutput(", "); + this.emit(expression.right); + break; + default: { + this.emit(expression.left); + var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); + if (binOp === "instanceof") { + this.writeToOutput(" instanceof "); + } else if (binOp === "in") { + this.writeToOutput(" in "); + } else { + this.writeToOutput(" " + binOp + " "); + } + this.emit(expression.right); + } + } + this.recordSourceMappingEnd(expression); + }; + + Emitter.prototype.emitSimplePropertyAssignment = function (property) { + this.recordSourceMappingStart(property); + this.emit(property.propertyName); + this.writeToOutput(": "); + this.emit(property.expression); + this.recordSourceMappingEnd(property); + }; + + Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { + this.recordSourceMappingStart(funcProp); + + this.emit(funcProp.propertyName); + this.writeToOutput(": "); + + var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); + + var savedInArrowFunction = this.inArrowFunction; + this.inArrowFunction = false; + + var temp = this.setContainer(5 /* Function */); + var funcName = funcProp.propertyName; + + var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); + this.pushDecl(pullDecl); + + this.recordSourceMappingStart(funcProp); + this.writeToOutput("function "); + + this.writeToOutput("("); + + var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); + this.emitFunctionParameters(parameters); + this.writeToOutput(")"); + + this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); + + this.recordSourceMappingEnd(funcProp); + + this.recordSourceMappingEnd(funcProp); + + this.emitComments(funcProp, false); + + this.popDecl(pullDecl); + + this.setContainer(temp); + this.inArrowFunction = savedInArrowFunction; + }; + + Emitter.prototype.emitConditionalExpression = function (expression) { + this.emit(expression.condition); + this.writeToOutput(" ? "); + this.emit(expression.whenTrue); + this.writeToOutput(" : "); + this.emit(expression.whenFalse); + }; + + Emitter.prototype.emitThrowStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("throw "); + this.emit(statement.expression); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitExpressionStatement = function (statement) { + var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; + + this.recordSourceMappingStart(statement); + if (isArrowExpression) { + this.writeToOutput("("); + } + + this.emit(statement.expression); + + if (isArrowExpression) { + this.writeToOutput(")"); + } + + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitLabeledStatement = function (statement) { + this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); + this.writeLineToOutput(":"); + this.emitJavascript(statement.statement, true); + }; + + Emitter.prototype.emitBlock = function (block) { + this.recordSourceMappingStart(block); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + if (block.statements) { + this.emitList(block.statements); + } + this.emitCommentsArray(block.closeBraceLeadingComments, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(block); + }; + + Emitter.prototype.emitBreakStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("break"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitContinueStatement = function (jump) { + this.recordSourceMappingStart(jump); + this.writeToOutput("continue"); + + if (jump.identifier) { + this.writeToOutput(" " + jump.identifier.text()); + } + + this.recordSourceMappingEnd(jump); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitWhileStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("while ("); + this.emit(statement.condition); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitDoStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("do"); + this.emitBlockOrStatement(statement.statement); + this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); + this.writeToOutput('('); + this.emit(statement.condition); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitIfStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("if ("); + this.emit(statement.condition); + this.writeToOutput(")"); + + this.emitBlockOrStatement(statement.statement); + + if (statement.elseClause) { + if (statement.statement.kind() !== 146 /* Block */) { + this.writeLineToOutput(""); + this.emitIndent(); + } else { + this.writeToOutput(" "); + } + + this.emit(statement.elseClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitElseClause = function (elseClause) { + if (elseClause.statement.kind() === 147 /* IfStatement */) { + this.writeToOutput("else "); + this.emit(elseClause.statement); + } else { + this.writeToOutput("else"); + this.emitBlockOrStatement(elseClause.statement); + } + }; + + Emitter.prototype.emitReturnStatement = function (statement) { + this.recordSourceMappingStart(statement); + if (statement.expression) { + this.writeToOutput("return "); + this.emit(statement.expression); + } else { + this.writeToOutput("return"); + } + this.recordSourceMappingEnd(statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitForInStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.left) { + this.emit(statement.left); + } else { + this.emit(statement.variableDeclaration); + } + this.writeToOutput(" in "); + this.emit(statement.expression); + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitForStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("for ("); + if (statement.variableDeclaration) { + this.emit(statement.variableDeclaration); + } else if (statement.initializer) { + this.emit(statement.initializer); + } + + this.writeToOutput("; "); + this.emitJavascript(statement.condition, false); + this.writeToOutput(";"); + if (statement.incrementor) { + this.writeToOutput(" "); + this.emitJavascript(statement.incrementor, false); + } + this.writeToOutput(")"); + this.emitBlockOrStatement(statement.statement); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitWithStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("with ("); + if (statement.condition) { + this.emit(statement.condition); + } + + this.writeToOutput(")"); + var prevInWithBlock = this.inWithBlock; + this.inWithBlock = true; + this.emitBlockOrStatement(statement.statement); + this.inWithBlock = prevInWithBlock; + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitSwitchStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("switch ("); + this.emit(statement.expression); + this.recordSourceMappingStart(statement.closeParenToken); + this.writeToOutput(")"); + this.recordSourceMappingEnd(statement.closeParenToken); + this.writeLineToOutput(" {"); + this.indenter.increaseIndent(); + this.emitList(statement.switchClauses, false); + this.indenter.decreaseIndent(); + this.emitIndent(); + this.writeToOutput("}"); + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCaseSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("case "); + this.emit(clause.expression); + this.writeToOutput(":"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitSwitchClauseBody = function (body) { + if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { + this.emit(body.childAt(0)); + this.writeLineToOutput(""); + } else { + this.writeLineToOutput(""); + this.indenter.increaseIndent(); + this.emit(body); + this.indenter.decreaseIndent(); + } + }; + + Emitter.prototype.emitDefaultSwitchClause = function (clause) { + this.recordSourceMappingStart(clause); + this.writeToOutput("default:"); + + this.emitSwitchClauseBody(clause.statements); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitTryStatement = function (statement) { + this.recordSourceMappingStart(statement); + this.writeToOutput("try "); + this.emit(statement.block); + this.emitJavascript(statement.catchClause, false); + + if (statement.finallyClause) { + this.emit(statement.finallyClause); + } + this.recordSourceMappingEnd(statement); + }; + + Emitter.prototype.emitCatchClause = function (clause) { + this.writeToOutput(" "); + this.recordSourceMappingStart(clause); + this.writeToOutput("catch ("); + this.emit(clause.identifier); + this.writeToOutput(")"); + this.emit(clause.block); + this.recordSourceMappingEnd(clause); + }; + + Emitter.prototype.emitFinallyClause = function (clause) { + this.writeToOutput(" finally"); + this.emit(clause.block); + }; + + Emitter.prototype.emitDebuggerStatement = function (statement) { + this.writeToOutputWithSourceMapRecord("debugger", statement); + this.writeToOutput(";"); + }; + + Emitter.prototype.emitNumericLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitRegularExpressionLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitStringLiteral = function (literal) { + this.writeToOutputWithSourceMapRecord(literal.text(), literal); + }; + + Emitter.prototype.emitEqualsValueClause = function (clause) { + this.writeToOutput(" = "); + this.emit(clause.value); + }; + + Emitter.prototype.emitParameter = function (parameter) { + this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); + }; + + Emitter.prototype.emitConstructorDeclaration = function (declaration) { + if (declaration.block) { + this.emitConstructor(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { + return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); + }; + + Emitter.prototype.emitFunctionDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { + this.emitFunction(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.emitSourceUnit = function (sourceUnit) { + if (!this.document.isDeclareFile()) { + var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); + this.pushDecl(pullDecl); + this.emitScriptElements(sourceUnit); + this.popDecl(pullDecl); + + this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); + } + }; + + Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); + }; + + Emitter.prototype.emitEnumDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { + this.emitComments(declaration, true); + this.emitEnum(declaration); + this.emitComments(declaration, false); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); + }; + + Emitter.prototype.emitModuleDeclaration = function (declaration) { + if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { + this.emitModuleDeclarationWorker(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { + return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); + }; + + Emitter.prototype.emitClassDeclaration = function (declaration) { + if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { + this.emitClass(declaration); + } else { + this.emitComments(declaration, true, true); + } + }; + + Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { + return declaration.preComments() !== null; + }; + + Emitter.prototype.emitInterfaceDeclaration = function (declaration) { + this.emitComments(declaration, true, true); + }; + + Emitter.prototype.firstVariableDeclarator = function (statement) { + return statement.declaration.declarators.nonSeparatorAt(0); + }; + + Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { + return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; + }; + + Emitter.prototype.shouldEmitVariableStatement = function (statement) { + return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); + }; + + Emitter.prototype.emitVariableStatement = function (statement) { + if (this.isNotAmbientOrHasInitializer(statement)) { + this.emitComments(statement, true); + this.emit(statement.declaration); + this.writeToOutput(";"); + this.emitComments(statement, false); + } else { + this.emitComments(statement, true, true); + } + }; + + Emitter.prototype.emitGenericType = function (type) { + this.emit(type.name); + }; + + Emitter.prototype.shouldEmit = function (ast) { + if (!ast) { + return false; + } + + switch (ast.kind()) { + case 133 /* ImportDeclaration */: + return this.shouldEmitImportDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.shouldEmitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.shouldEmitInterfaceDeclaration(ast); + case 129 /* FunctionDeclaration */: + return this.shouldEmitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.shouldEmitModuleDeclaration(ast); + case 148 /* VariableStatement */: + return this.shouldEmitVariableStatement(ast); + case 223 /* OmittedExpression */: + return false; + case 132 /* EnumDeclaration */: + return this.shouldEmitEnumDeclaration(ast); + } + + return true; + }; + + Emitter.prototype.emit = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 2 /* SeparatedList */: + return this.emitSeparatedList(ast); + case 1 /* List */: + return this.emitList(ast); + case 120 /* SourceUnit */: + return this.emitSourceUnit(ast); + case 133 /* ImportDeclaration */: + return this.emitImportDeclaration(ast); + case 134 /* ExportAssignment */: + return this.setExportAssignment(ast); + case 131 /* ClassDeclaration */: + return this.emitClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitInterfaceDeclaration(ast); + case 11 /* IdentifierName */: + return this.emitName(ast, true); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast); + case 219 /* SimpleArrowFunctionExpression */: + return this.emitSimpleArrowFunctionExpression(ast); + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.emitParenthesizedArrowFunctionExpression(ast); + case 129 /* FunctionDeclaration */: + return this.emitFunctionDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitModuleDeclaration(ast); + case 224 /* VariableDeclaration */: + return this.emitVariableDeclaration(ast); + case 126 /* GenericType */: + return this.emitGenericType(ast); + case 137 /* ConstructorDeclaration */: + return this.emitConstructorDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitEnumDeclaration(ast); + case 243 /* EnumElement */: + return this.emitEnumElement(ast); + case 222 /* FunctionExpression */: + return this.emitFunctionExpression(ast); + case 148 /* VariableStatement */: + return this.emitVariableStatement(ast); + } + + this.emitComments(ast, true); + this.emitWorker(ast); + this.emitComments(ast, false); + }; + + Emitter.prototype.emitWorker = function (ast) { + if (!ast) { + return; + } + + switch (ast.kind()) { + case 13 /* NumericLiteral */: + return this.emitNumericLiteral(ast); + case 12 /* RegularExpressionLiteral */: + return this.emitRegularExpressionLiteral(ast); + case 14 /* StringLiteral */: + return this.emitStringLiteral(ast); + case 24 /* FalseKeyword */: + case 32 /* NullKeyword */: + case 37 /* TrueKeyword */: + return this.emitLiteralExpression(ast); + case 35 /* ThisKeyword */: + return this.emitThisExpression(ast); + case 50 /* SuperKeyword */: + return this.emitSuperExpression(ast); + case 217 /* ParenthesizedExpression */: + return this.emitParenthesizedExpression(ast); + case 214 /* ArrayLiteralExpression */: + return this.emitArrayLiteralExpression(ast); + case 211 /* PostDecrementExpression */: + case 210 /* PostIncrementExpression */: + return this.emitPostfixUnaryExpression(ast); + case 167 /* LogicalNotExpression */: + case 166 /* BitwiseNotExpression */: + case 165 /* NegateExpression */: + case 164 /* PlusExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.emitPrefixUnaryExpression(ast); + case 213 /* InvocationExpression */: + return this.emitInvocationExpression(ast); + case 221 /* ElementAccessExpression */: + return this.emitElementAccessExpression(ast); + case 212 /* MemberAccessExpression */: + return this.emitMemberAccessExpression(ast); + case 121 /* QualifiedName */: + return this.emitQualifiedName(ast); + case 173 /* CommaExpression */: + case 174 /* AssignmentExpression */: + case 175 /* AddAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 187 /* LogicalOrExpression */: + case 188 /* LogicalAndExpression */: + case 189 /* BitwiseOrExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 191 /* BitwiseAndExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 193 /* NotEqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 197 /* GreaterThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 200 /* InstanceOfExpression */: + case 201 /* InExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 208 /* AddExpression */: + case 209 /* SubtractExpression */: + return this.emitBinaryExpression(ast); + case 186 /* ConditionalExpression */: + return this.emitConditionalExpression(ast); + case 232 /* EqualsValueClause */: + return this.emitEqualsValueClause(ast); + case 242 /* Parameter */: + return this.emitParameter(ast); + case 146 /* Block */: + return this.emitBlock(ast); + case 235 /* ElseClause */: + return this.emitElseClause(ast); + case 147 /* IfStatement */: + return this.emitIfStatement(ast); + case 149 /* ExpressionStatement */: + return this.emitExpressionStatement(ast); + case 139 /* GetAccessor */: + return this.emitGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitSetAccessor(ast); + case 157 /* ThrowStatement */: + return this.emitThrowStatement(ast); + case 150 /* ReturnStatement */: + return this.emitReturnStatement(ast); + case 216 /* ObjectCreationExpression */: + return this.emitObjectCreationExpression(ast); + case 151 /* SwitchStatement */: + return this.emitSwitchStatement(ast); + case 233 /* CaseSwitchClause */: + return this.emitCaseSwitchClause(ast); + case 234 /* DefaultSwitchClause */: + return this.emitDefaultSwitchClause(ast); + case 152 /* BreakStatement */: + return this.emitBreakStatement(ast); + case 153 /* ContinueStatement */: + return this.emitContinueStatement(ast); + case 154 /* ForStatement */: + return this.emitForStatement(ast); + case 155 /* ForInStatement */: + return this.emitForInStatement(ast); + case 158 /* WhileStatement */: + return this.emitWhileStatement(ast); + case 163 /* WithStatement */: + return this.emitWithStatement(ast); + case 220 /* CastExpression */: + return this.emitCastExpression(ast); + case 215 /* ObjectLiteralExpression */: + return this.emitObjectLiteralExpression(ast); + case 240 /* SimplePropertyAssignment */: + return this.emitSimplePropertyAssignment(ast); + case 241 /* FunctionPropertyAssignment */: + return this.emitFunctionPropertyAssignment(ast); + case 156 /* EmptyStatement */: + return this.writeToOutputWithSourceMapRecord(";", ast); + case 159 /* TryStatement */: + return this.emitTryStatement(ast); + case 236 /* CatchClause */: + return this.emitCatchClause(ast); + case 237 /* FinallyClause */: + return this.emitFinallyClause(ast); + case 160 /* LabeledStatement */: + return this.emitLabeledStatement(ast); + case 161 /* DoStatement */: + return this.emitDoStatement(ast); + case 171 /* TypeOfExpression */: + return this.emitTypeOfExpression(ast); + case 170 /* DeleteExpression */: + return this.emitDeleteExpression(ast); + case 172 /* VoidExpression */: + return this.emitVoidExpression(ast); + case 162 /* DebuggerStatement */: + return this.emitDebuggerStatement(ast); + } + }; + return Emitter; + })(); + TypeScript.Emitter = Emitter; + + function getLastConstructor(classDecl) { + return classDecl.classElements.lastOrDefault(function (e) { + return e.kind() === 137 /* ConstructorDeclaration */; + }); + } + TypeScript.getLastConstructor = getLastConstructor; + + function getTrimmedTextLines(comment) { + if (comment.kind() === 6 /* MultiLineCommentTrivia */) { + return comment.fullText().split("\n").map(function (s) { + return s.trim(); + }); + } else { + return [comment.fullText().trim()]; + } + } + TypeScript.getTrimmedTextLines = getTrimmedTextLines; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var MemberName = (function () { + function MemberName() { + this.prefix = ""; + this.suffix = ""; + } + MemberName.prototype.isString = function () { + return false; + }; + MemberName.prototype.isArray = function () { + return false; + }; + MemberName.prototype.isMarker = function () { + return !this.isString() && !this.isArray(); + }; + + MemberName.prototype.toString = function () { + return MemberName.memberNameToString(this); + }; + + MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { + if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } + var result = memberName.prefix; + + if (memberName.isString()) { + result += memberName.text; + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + if (ar.entries[index].isMarker()) { + if (markerInfo) { + markerInfo.push(markerBaseLength + result.length); + } + continue; + } + + result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); + result += ar.delim; + } + } + + result += memberName.suffix; + return result; + }; + + MemberName.create = function (arg1, arg2, arg3) { + if (typeof arg1 === "string") { + return new MemberNameString(arg1); + } else { + var result = new MemberNameArray(); + if (arg2) + result.prefix = arg2; + if (arg3) + result.suffix = arg3; + result.entries.push(arg1); + return result; + } + }; + return MemberName; + })(); + TypeScript.MemberName = MemberName; + + var MemberNameString = (function (_super) { + __extends(MemberNameString, _super); + function MemberNameString(text) { + _super.call(this); + this.text = text; + } + MemberNameString.prototype.isString = function () { + return true; + }; + return MemberNameString; + })(MemberName); + TypeScript.MemberNameString = MemberNameString; + + var MemberNameArray = (function (_super) { + __extends(MemberNameArray, _super); + function MemberNameArray() { + _super.call(this); + this.delim = ""; + this.entries = []; + } + MemberNameArray.prototype.isArray = function () { + return true; + }; + + MemberNameArray.prototype.add = function (entry) { + this.entries.push(entry); + }; + + MemberNameArray.prototype.addAll = function (entries) { + for (var i = 0; i < entries.length; i++) { + this.entries.push(entries[i]); + } + }; + return MemberNameArray; + })(MemberName); + TypeScript.MemberNameArray = MemberNameArray; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function stripStartAndEndQuotes(str) { + var firstCharCode = str && str.charCodeAt(0); + if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + return str.substring(1, str.length - 1); + } + + return str; + } + TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; + + function isSingleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; + } + TypeScript.isSingleQuoted = isSingleQuoted; + + function isDoubleQuoted(str) { + return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; + } + TypeScript.isDoubleQuoted = isDoubleQuoted; + + function isQuoted(str) { + return isDoubleQuoted(str) || isSingleQuoted(str); + } + TypeScript.isQuoted = isQuoted; + + function quoteStr(str) { + return "\"" + str + "\""; + } + TypeScript.quoteStr = quoteStr; + + var switchToForwardSlashesRegEx = /\\/g; + function switchToForwardSlashes(path) { + return path.replace(switchToForwardSlashesRegEx, "/"); + } + TypeScript.switchToForwardSlashes = switchToForwardSlashes; + + function trimModName(modName) { + if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { + return modName.substring(0, modName.length - 5); + } + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { + return modName.substring(0, modName.length - 3); + } + + if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { + return modName.substring(0, modName.length - 3); + } + + return modName; + } + TypeScript.trimModName = trimModName; + + function getDeclareFilePath(fname) { + return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); + } + TypeScript.getDeclareFilePath = getDeclareFilePath; + + function isFileOfExtension(fname, ext) { + var invariantFname = fname.toLocaleUpperCase(); + var invariantExt = ext.toLocaleUpperCase(); + var extLength = invariantExt.length; + return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; + } + + function isTSFile(fname) { + return isFileOfExtension(fname, ".ts"); + } + TypeScript.isTSFile = isTSFile; + + function isDTSFile(fname) { + return isFileOfExtension(fname, ".d.ts"); + } + TypeScript.isDTSFile = isDTSFile; + + function getPrettyName(modPath, quote, treatAsFileName) { + if (typeof quote === "undefined") { quote = true; } + if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } + var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); + var components = this.getPathComponents(modName); + return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; + } + TypeScript.getPrettyName = getPrettyName; + + function getPathComponents(path) { + return path.split("/"); + } + TypeScript.getPathComponents = getPathComponents; + + function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { + if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } + absoluteModPath = switchToForwardSlashes(absoluteModPath); + + var modComponents = this.getPathComponents(absoluteModPath); + var fixedModComponents = this.getPathComponents(fixedModFilePath); + + var joinStartIndex = 0; + for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { + break; + } + } + + if (joinStartIndex !== 0) { + var relativePath = ""; + var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); + for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { + if (fixedModComponents[joinStartIndex] !== "") { + relativePath = relativePath + "../"; + } + } + + return relativePath + relativePathComponents.join("/"); + } + + if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { + absoluteModPath = "file:///" + absoluteModPath; + } + + return absoluteModPath; + } + TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; + + function changePathToDTS(modPath) { + return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; + } + TypeScript.changePathToDTS = changePathToDTS; + + function isRelative(path) { + return path.length > 0 && path.charAt(0) === "."; + } + TypeScript.isRelative = isRelative; + function isRooted(path) { + return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); + } + TypeScript.isRooted = isRooted; + + function getRootFilePath(outFname) { + if (outFname === "") { + return outFname; + } else { + var isPath = outFname.indexOf("/") !== -1; + return isPath ? filePath(outFname) : ""; + } + } + TypeScript.getRootFilePath = getRootFilePath; + + function filePathComponents(fullPath) { + fullPath = switchToForwardSlashes(fullPath); + var components = getPathComponents(fullPath); + return components.slice(0, components.length - 1); + } + TypeScript.filePathComponents = filePathComponents; + + function filePath(fullPath) { + var path = filePathComponents(fullPath); + return path.join("/") + "/"; + } + TypeScript.filePath = filePath; + + function convertToDirectoryPath(dirPath) { + if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { + dirPath += "/"; + } + + return dirPath; + } + TypeScript.convertToDirectoryPath = convertToDirectoryPath; + + var normalizePathRegEx = /^\\\\[^\\]/; + function normalizePath(path) { + if (normalizePathRegEx.test(path)) { + path = "file:" + path; + } + var parts = this.getPathComponents(switchToForwardSlashes(path)); + var normalizedParts = []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part === ".") { + continue; + } + + if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { + normalizedParts.pop(); + continue; + } + + normalizedParts.push(part); + } + + return normalizedParts.join("/"); + } + TypeScript.normalizePath = normalizePath; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + + + function isNoDefaultLibMatch(comment) { + var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; + return isNoDefaultLibRegex.exec(comment); + } + + TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; + + function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { + var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; + if (isResident) { + TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); + } + return { + line: 0, + character: 0, + position: 0, + length: 0, + path: TypeScript.switchToForwardSlashes(adjustedPath), + isResident: isResident + }; + } + } + } + + return null; + } + + var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); + var scannerDiagnostics = []; + + function processImports(lineMap, scanner, token, importedFiles) { + var position = 0; + var lineChar = { line: -1, character: -1 }; + + var start = new Date().getTime(); + + while (token.tokenKind !== 10 /* EndOfFileToken */) { + if (token.tokenKind === 49 /* ImportKeyword */) { + var importStart = position + token.leadingTriviaWidth(); + token = scanner.scan(scannerDiagnostics, false); + + if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 107 /* EqualsToken */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { + token = scanner.scan(scannerDiagnostics, false); + + if (token.tokenKind === 72 /* OpenParenToken */) { + var afterOpenParenPosition = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + + lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); + + if (token.tokenKind === 14 /* StringLiteral */) { + var ref = { + line: lineChar.line, + character: lineChar.character, + position: afterOpenParenPosition + token.leadingTriviaWidth(), + length: token.width(), + path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), + isResident: false + }; + importedFiles.push(ref); + } + } + } + } + } + } + + position = scanner.absoluteIndex(); + token = scanner.scan(scannerDiagnostics, false); + } + + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionScanImportsTime += totalTime; + } + + function processTripleSlashDirectives(fileName, lineMap, firstToken) { + var leadingTrivia = firstToken.leadingTrivia(); + + var position = 0; + var lineChar = { line: -1, character: -1 }; + var noDefaultLib = false; + var diagnostics = []; + var referencedFiles = []; + + for (var i = 0, n = leadingTrivia.count(); i < n; i++) { + var trivia = leadingTrivia.syntaxTriviaAt(i); + + if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + var triviaText = trivia.fullText(); + var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); + + if (referencedCode) { + lineMap.fillLineAndCharacterFromPosition(position, lineChar); + referencedCode.position = position; + referencedCode.length = trivia.fullWidth(); + referencedCode.line = lineChar.line; + referencedCode.character = lineChar.character; + + referencedFiles.push(referencedCode); + } + + var isNoDefaultLib = isNoDefaultLibMatch(triviaText); + if (isNoDefaultLib) { + noDefaultLib = isNoDefaultLib[3] === "true"; + } + } + + position += trivia.fullWidth(); + } + + return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; + } + + function preProcessFile(fileName, sourceText, readImportFiles) { + if (typeof readImportFiles === "undefined") { readImportFiles = true; } + var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); + var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); + + var firstToken = scanner.scan(scannerDiagnostics, false); + + var importedFiles = []; + if (readImportFiles) { + processImports(text.lineMap(), scanner, firstToken, importedFiles); + } + + var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); + + scannerDiagnostics.length = 0; + return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; + } + TypeScript.preProcessFile = preProcessFile; + + function getParseOptions(settings) { + return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); + } + TypeScript.getParseOptions = getParseOptions; + + function getReferencedFiles(fileName, sourceText) { + return preProcessFile(fileName, sourceText, false).referencedFiles; + } + TypeScript.getReferencedFiles = getReferencedFiles; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ReferenceResolutionResult = (function () { + function ReferenceResolutionResult() { + this.resolvedFiles = []; + this.diagnostics = []; + this.seenNoDefaultLibTag = false; + } + return ReferenceResolutionResult; + })(); + TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; + + var ReferenceLocation = (function () { + function ReferenceLocation(filePath, lineMap, position, length, isImported) { + this.filePath = filePath; + this.lineMap = lineMap; + this.position = position; + this.length = length; + this.isImported = isImported; + } + return ReferenceLocation; + })(); + + var ReferenceResolver = (function () { + function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { + this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this.inputFileNames = inputFileNames; + this.host = host; + this.visited = {}; + } + ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { + var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); + return resolver.resolveInputFiles(); + }; + + ReferenceResolver.prototype.resolveInputFiles = function () { + var _this = this; + var result = new ReferenceResolutionResult(); + + if (!this.inputFileNames || this.inputFileNames.length <= 0) { + return result; + } + + var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); + this.inputFileNames.forEach(function (fileName) { + return _this.resolveIncludedFile(fileName, referenceLocation, result); + }); + + return result; + }; + + ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { + var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); + + if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); + } + + return normalizedPath; + } + + if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { + var dtsFile = normalizedPath + ".d.ts"; + var tsFile = normalizedPath + ".ts"; + + if (this.host.fileExists(tsFile)) { + normalizedPath = tsFile; + } else { + normalizedPath = dtsFile; + } + } + + if (!this.host.fileExists(normalizedPath)) { + if (!referenceLocation.isImported) { + resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); + } + + return normalizedPath; + } + + return this.resolveFile(normalizedPath, resolutionResult); + }; + + ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { + var isRelativePath = TypeScript.isRelative(path); + var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); + + if (isRelativePath || isRootedPath) { + return this.resolveIncludedFile(path, referenceLocation, resolutionResult); + } else { + var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); + var searchFilePath = null; + var dtsFileName = path + ".d.ts"; + var tsFilePath = path + ".ts"; + + var start = new Date().getTime(); + + do { + currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); + if (this.host.fileExists(currentFilePath)) { + searchFilePath = currentFilePath; + break; + } + + parentDirectory = this.host.getParentDirectory(parentDirectory); + } while(parentDirectory); + + TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; + + if (!searchFilePath) { + return path; + } + + return this.resolveFile(searchFilePath, resolutionResult); + } + }; + + ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { + var _this = this; + var visitedPath = this.isVisited(normalizedPath); + if (!visitedPath) { + this.recordVisitedFile(normalizedPath); + + var start = new Date().getTime(); + var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); + var totalTime = new Date().getTime() - start; + TypeScript.fileResolutionIOTime += totalTime; + + var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); + var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); + resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); + + if (preprocessedFileInformation.isLibFile) { + resolutionResult.seenNoDefaultLibTag = true; + } + + var normalizedReferencePaths = []; + preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); + var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); + normalizedReferencePaths.push(normalizedReferencePath); + }); + + var normalizedImportPaths = []; + for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { + var fileImport = preprocessedFileInformation.importedFiles[i]; + var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); + var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); + normalizedImportPaths.push(normalizedImportPath); + } + + resolutionResult.resolvedFiles.push({ + path: normalizedPath, + referencedFiles: normalizedReferencePaths, + importedFiles: normalizedImportPaths + }); + } else { + normalizedPath = visitedPath; + } + + return normalizedPath; + }; + + ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { + var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; + var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); + return normalizedPath; + }; + + ReferenceResolver.prototype.getUniqueFileId = function (filePath) { + return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); + }; + + ReferenceResolver.prototype.recordVisitedFile = function (filePath) { + this.visited[this.getUniqueFileId(filePath)] = filePath; + }; + + ReferenceResolver.prototype.isVisited = function (filePath) { + return this.visited[this.getUniqueFileId(filePath)]; + }; + + ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { + if (!filePath1 || !filePath2) { + return false; + } + + if (this.useCaseSensitiveFileResolution) { + return filePath1 === filePath2; + } else { + return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); + } + }; + return ReferenceResolver; + })(); + TypeScript.ReferenceResolver = ReferenceResolver; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var TextWriter = (function () { + function TextWriter(name, writeByteOrderMark, outputFileType) { + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.outputFileType = outputFileType; + this.contents = ""; + this.onNewLine = true; + } + TextWriter.prototype.Write = function (s) { + this.contents += s; + this.onNewLine = false; + }; + + TextWriter.prototype.WriteLine = function (s) { + this.contents += s; + this.contents += TypeScript.newLine(); + this.onNewLine = true; + }; + + TextWriter.prototype.Close = function () { + }; + + TextWriter.prototype.getOutputFile = function () { + return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); + }; + return TextWriter; + })(); + TypeScript.TextWriter = TextWriter; + + var DeclarationEmitter = (function () { + function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { + this.emittingFileName = emittingFileName; + this.document = document; + this.compiler = compiler; + this.emitOptions = emitOptions; + this.semanticInfoChain = semanticInfoChain; + this.declFile = null; + this.indenter = new TypeScript.Indenter(); + this.emittedReferencePaths = false; + this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); + } + DeclarationEmitter.prototype.getOutputFile = function () { + return this.declFile.getOutputFile(); + }; + + DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { + this.emitDeclarationsForSourceUnit(sourceUnit); + }; + + DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { + for (var i = 0, n = list.childCount(); i < n; i++) { + this.emitDeclarationsForAST(list.childAt(i)); + } + }; + + DeclarationEmitter.prototype.emitSeparatedList = function (list) { + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.emitDeclarationsForAST(list.nonSeparatorAt(i)); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { + switch (ast.kind()) { + case 148 /* VariableStatement */: + return this.emitDeclarationsForVariableStatement(ast); + case 141 /* PropertySignature */: + return this.emitPropertySignature(ast); + case 225 /* VariableDeclarator */: + return this.emitVariableDeclarator(ast, true, true); + case 136 /* MemberVariableDeclaration */: + return this.emitDeclarationsForMemberVariableDeclaration(ast); + case 137 /* ConstructorDeclaration */: + return this.emitDeclarationsForConstructorDeclaration(ast); + case 139 /* GetAccessor */: + return this.emitDeclarationsForGetAccessor(ast); + case 140 /* SetAccessor */: + return this.emitDeclarationsForSetAccessor(ast); + case 138 /* IndexMemberDeclaration */: + return this.emitIndexMemberDeclaration(ast); + case 144 /* IndexSignature */: + return this.emitIndexSignature(ast); + case 142 /* CallSignature */: + return this.emitCallSignature(ast); + case 143 /* ConstructSignature */: + return this.emitConstructSignature(ast); + case 145 /* MethodSignature */: + return this.emitMethodSignature(ast); + case 129 /* FunctionDeclaration */: + return this.emitDeclarationsForFunctionDeclaration(ast); + case 135 /* MemberFunctionDeclaration */: + return this.emitMemberFunctionDeclaration(ast); + case 131 /* ClassDeclaration */: + return this.emitDeclarationsForClassDeclaration(ast); + case 128 /* InterfaceDeclaration */: + return this.emitDeclarationsForInterfaceDeclaration(ast); + case 133 /* ImportDeclaration */: + return this.emitDeclarationsForImportDeclaration(ast); + case 130 /* ModuleDeclaration */: + return this.emitDeclarationsForModuleDeclaration(ast); + case 132 /* EnumDeclaration */: + return this.emitDeclarationsForEnumDeclaration(ast); + case 134 /* ExportAssignment */: + return this.emitDeclarationsForExportAssignment(ast); + } + }; + + DeclarationEmitter.prototype.getIndentString = function (declIndent) { + if (typeof declIndent === "undefined") { declIndent = false; } + return this.indenter.getIndent(); + }; + + DeclarationEmitter.prototype.emitIndent = function () { + this.declFile.Write(this.getIndentString()); + }; + + DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { + var container = this.getEnclosingContainer(declAST); + if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { + var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); + if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { + var start = new Date().getTime(); + var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); + var result = declSymbol && declSymbol.isExternallyVisible(); + TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; + + return result; + } + } + + return true; + }; + + DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { + var result = this.getIndentString(); + var pullFlags = pullDecl.flags; + + if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } + result += "static "; + } else { + if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { + result += "private "; + } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { + result += "public "; + } else { + var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); + + var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); + var container = this.getEnclosingContainer(declAST); + + if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { + container = this.getEnclosingContainer(container); + } + + var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); + + if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { + result += "export "; + emitDeclare = true; + } + + if (isExternalModule || container.kind() === 120 /* SourceUnit */) { + if (emitDeclare && typeString !== "interface" && typeString !== "import") { + result += "declare "; + } + } + + result += typeString + " "; + } + } + + return result; + }; + + DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { + this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); + }; + + DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { + if (typeof emitIndent === "undefined") { emitIndent = false; } + if (memberName.prefix === "{ ") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.WriteLine("{"); + this.indenter.increaseIndent(); + emitIndent = true; + } else if (memberName.prefix !== "") { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.prefix); + emitIndent = false; + } + + if (memberName.isString()) { + if (emitIndent) { + this.emitIndent(); + } + + this.declFile.Write(memberName.text); + } else if (memberName.isArray()) { + var ar = memberName; + for (var index = 0; index < ar.entries.length; index++) { + this.emitTypeNamesMember(ar.entries[index], emitIndent); + if (ar.delim === "; ") { + this.declFile.WriteLine(";"); + } + } + } + + if (memberName.suffix === "}") { + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.Write(memberName.suffix); + } else { + this.declFile.Write(memberName.suffix); + } + }; + + DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { + var declarationContainerAst = this.getEnclosingContainer(ast); + + var start = new Date().getTime(); + var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); + + var declarationPullSymbol = declarationContainerDecl.getSymbol(); + TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; + + var isNotAGenericType = ast.kind() !== 126 /* GenericType */; + + var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); + this.emitTypeNamesMember(typeNameMembers); + }; + + DeclarationEmitter.prototype.emitComment = function (comment) { + var text = TypeScript.getTrimmedTextLines(comment); + if (this.declFile.onNewLine) { + this.emitIndent(); + } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + this.emitIndent(); + } + + this.declFile.Write(text[0]); + + for (var i = 1; i < text.length; i++) { + this.declFile.WriteLine(""); + this.emitIndent(); + this.declFile.Write(text[i]); + } + + if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { + this.declFile.WriteLine(""); + } else { + this.declFile.Write(" "); + } + }; + + DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); + this.writeDeclarationComments(declComments, endLine); + }; + + DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { + if (typeof endLine === "undefined") { endLine = true; } + if (declComments.length > 0) { + for (var i = 0; i < declComments.length; i++) { + this.emitComment(declComments[i]); + } + + if (endLine) { + if (!this.declFile.onNewLine) { + this.declFile.WriteLine(""); + } + } else { + if (this.declFile.onNewLine) { + this.emitIndent(); + } + } + } + }; + + DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { + var start = new Date().getTime(); + var decl = this.semanticInfoChain.getDeclForAST(boundDecl); + var pullSymbol = decl.getSymbol(); + TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; + + var type = pullSymbol.type; + TypeScript.Debug.assert(type); + + this.declFile.Write(": "); + this.emitTypeSignature(boundDecl, type); + }; + + DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { + this.emitDeclarationComments(varDecl); + this.emitIndent(); + this.declFile.Write(varDecl.propertyName.text()); + if (varDecl.questionToken) { + this.declFile.Write("?"); + } + + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + if (isFirstVarInList) { + this.emitDeclFlags(varDecl, "var"); + } + + this.declFile.Write(varDecl.propertyName.text()); + + if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + if (isLastVarInList) { + this.declFile.WriteLine(";"); + } else { + this.declFile.Write(", "); + } + } + }; + + DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { + if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } + this.declFile.Write("static "); + } else { + if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { + this.declFile.Write("private "); + } else { + this.declFile.Write("public "); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { + if (this.canEmitDeclarations(varDecl)) { + this.emitDeclarationComments(varDecl); + + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(varDecl.modifiers); + ; + + this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); + + if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { + this.emitTypeOfVariableDeclaratorOrParameter(varDecl); + } + + this.declFile.WriteLine(";"); + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { + this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); + }; + + 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); + } + }; + + DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { + this.indenter.increaseIndent(); + + this.emitDeclarationComments(argDecl, false); + this.declFile.Write(id.text()); + if (isOptional) { + this.declFile.Write("?"); + } + + this.indenter.decreaseIndent(); + + if (!isPrivate) { + this.emitTypeOfVariableDeclaratorOrParameter(argDecl); + } + }; + + DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { + var start = new Date().getTime(); + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDecl.getSymbol(); + TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + var signatures = funcTypeSymbol.getCallSignatures(); + var result = signatures && signatures.length > 1; + + return result; + }; + + DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("constructor"); + + this.declFile.Write("("); + 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.ASTHelpers.parametersFromParameterList(parameterList)); + this.declFile.Write(")"); + }; + + DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { + var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); + var argsLen = parameterList.length; + if (hasLastParameterRestParameter) { + argsLen--; + } + + for (var i = 0; i < argsLen; i++) { + this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); + if (i < (argsLen - 1)) { + this.declFile.Write(", "); + } + } + + if (hasLastParameterRestParameter) { + if (parameterList.length > 1) { + this.declFile.Write(", ..."); + } else { + this.declFile.Write("..."); + } + + var index = parameterList.length - 1; + this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); + } + }; + + DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + var funcTypeSymbol = funcSymbol.type; + if (funcDecl.block) { + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { + var callSignatures = funcTypeSymbol.getCallSignatures(); + TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); + var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; + var firstSignatureDecl = firstSignature.getDeclarations()[0]; + var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); + if (firstFuncDecl !== funcDecl) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitDeclarationComments(funcDecl); + + this.emitDeclFlags(funcDecl, "function"); + var id = funcDecl.propertyName.text(); + this.declFile.Write(id); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); + + this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); + + if (!isPrivate) { + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + this.emitDeclarationComments(funcDecl); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); + + this.emitIndent(); + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("new"); + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write(funcDecl.propertyName.text()); + if (funcDecl.questionToken) { + this.declFile.Write("? "); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + + var start = new Date().getTime(); + var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); + + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; + + if (funcDecl.block) { + var funcTypeSymbol = funcSymbol.type; + var constructSignatures = funcTypeSymbol.getConstructSignatures(); + if (constructSignatures && constructSignatures.length > 1) { + return; + } else if (this.isOverloadedCallSignature(funcDecl)) { + return; + } + } + + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + var id = funcDecl.identifier.text(); + this.emitDeclFlags(funcDecl, "function"); + if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { + this.declFile.Write(id); + } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { + this.declFile.Write("new"); + } + + var funcSignature = funcPullDecl.getSignatureSymbol(); + this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); + + this.declFile.Write("("); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); + this.declFile.Write(")"); + + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + if (returnType) { + this.emitTypeSignature(funcDecl, returnType); + } else { + this.declFile.Write("any"); + } + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { + this.emitDeclarationsForAST(funcDecl.indexSignature); + }; + + DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { + if (!this.canEmitDeclarations(funcDecl)) { + return; + } + + this.emitDeclarationComments(funcDecl); + + this.emitIndent(); + this.declFile.Write("["); + this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); + this.declFile.Write("]"); + + var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSignature = funcPullDecl.getSignatureSymbol(); + var returnType = funcSignature.returnType; + this.declFile.Write(": "); + this.emitTypeSignature(funcDecl, returnType); + + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { + if (bases && (bases.nonSeparatorCount() > 0)) { + var qual = useExtendsList ? "extends" : "implements"; + this.declFile.Write(" " + qual + " "); + var basesLen = bases.nonSeparatorCount(); + for (var i = 0; i < basesLen; i++) { + if (i > 0) { + this.declFile.Write(", "); + } + var base = bases.nonSeparatorAt(i); + var baseType = this.semanticInfoChain.getSymbolForAST(base); + this.emitTypeSignature(base, baseType); + } + } + }; + + DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { + if (this.emitOptions.compilationSettings().removeComments()) { + return; + } + + var start = new Date().getTime(); + var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + var comments = []; + if (accessors.getter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); + } + if (accessors.setter) { + comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); + } + + this.writeDeclarationComments(comments); + }; + + DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { + this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); + }; + + DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { + var start = new Date().getTime(); + var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); + TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); + + if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { + return; + } + + var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); + this.emitAccessorDeclarationComments(funcDecl); + this.declFile.Write(this.getIndentString()); + this.emitClassElementModifiers(modifiers); + this.declFile.Write(name.text()); + if (!isPrivate) { + this.declFile.Write(" : "); + var type = accessorSymbol.type; + this.emitTypeSignature(funcDecl, type); + } + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { + var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); + if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { + argsLen--; + } + + 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(";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { + if (!this.canEmitDeclarations(classDecl)) { + return; + } + + var className = classDecl.identifier.text(); + this.emitDeclarationComments(classDecl); + var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); + this.emitDeclFlags(classDecl, "class"); + this.declFile.Write(className); + + this.emitTypeParameters(classDecl.typeParameterList); + this.emitHeritageClauses(classDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + var constructorDecl = TypeScript.getLastConstructor(classDecl); + if (constructorDecl) { + this.emitClassMembersFromConstructorDefinition(constructorDecl); + } + + this.emitDeclarationsForList(classDecl.classElements); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { + if (clauses) { + for (var i = 0, n = clauses.childCount(); i < n; i++) { + this.emitHeritageClause(clauses.childAt(i)); + } + } + }; + + DeclarationEmitter.prototype.emitHeritageClause = function (clause) { + this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); + }; + + DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { + if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { + return; + } + + this.declFile.Write("<"); + var containerAst = this.getEnclosingContainer(typeParams); + + var start = new Date().getTime(); + var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); + var containerSymbol = containerDecl.getSymbol(); + TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; + + var typars; + if (funcSignature) { + typars = funcSignature.getTypeParameters(); + } else { + typars = containerSymbol.getTypeArgumentsOrTypeParameters(); + } + + for (var i = 0; i < typars.length; i++) { + if (i) { + this.declFile.Write(", "); + } + + var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); + this.emitTypeNamesMember(memberName); + } + + this.declFile.Write(">"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { + if (!this.canEmitDeclarations(interfaceDecl)) { + return; + } + + var interfaceName = interfaceDecl.identifier.text(); + this.emitDeclarationComments(interfaceDecl); + var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); + this.emitDeclFlags(interfaceDecl, "interface"); + this.declFile.Write(interfaceName); + + this.emitTypeParameters(interfaceDecl.typeParameterList); + this.emitHeritageClauses(interfaceDecl.heritageClauses); + this.declFile.WriteLine(" {"); + + this.indenter.increaseIndent(); + + this.emitSeparatedList(interfaceDecl.body.typeMembers); + + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { + var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); + var importSymbol = importDecl.getSymbol(); + var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); + + if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { + this.emitDeclarationComments(importDeclAST); + this.emitIndent(); + if (isExportedImportDecl) { + this.declFile.Write("export "); + } + this.declFile.Write("import "); + this.declFile.Write(importDeclAST.identifier.text() + " = "); + if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); + } else { + this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); + } + } + }; + + DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + this.emitDeclarationComments(moduleDecl); + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclFlags(moduleDecl, "enum"); + this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); + + this.indenter.increaseIndent(); + var membersLen = moduleDecl.enumElements.nonSeparatorCount(); + for (var j = 0; j < membersLen; j++) { + var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); + var enumElement = memberDecl; + var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); + this.emitDeclarationComments(enumElement); + this.emitIndent(); + this.declFile.Write(enumElement.propertyName.text()); + if (enumElementDecl.constantValue !== null) { + this.declFile.Write(" = " + enumElementDecl.constantValue); + } + this.declFile.WriteLine(","); + } + this.indenter.decreaseIndent(); + + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { + if (!this.canEmitDeclarations(moduleDecl)) { + return; + } + + var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); + this.emitDeclarationComments(moduleDecl); + + var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); + this.emitDeclFlags(name, "module"); + + if (moduleDecl.stringLiteral) { + this.declFile.Write(moduleDecl.stringLiteral.text()); + } else { + this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); + } + + this.declFile.WriteLine(" {"); + this.indenter.increaseIndent(); + + this.emitDeclarationsForList(moduleDecl.moduleElements); + + this.indenter.decreaseIndent(); + this.emitIndent(); + this.declFile.WriteLine("}"); + }; + + DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { + this.emitIndent(); + this.declFile.Write("export = "); + this.declFile.Write(ast.identifier.text()); + this.declFile.WriteLine(";"); + }; + + DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { + if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { + return reference; + } + + var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); + var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); + return resolvedReferencePath; + }; + + DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { + if (this.emittedReferencePaths) { + return; + } + + var documents = []; + if (this.document.emitToOwnOutputFile()) { + var scriptReferences = this.document.referencedFiles; + var addedGlobalDocument = false; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { + documents = documents.concat(document); + + if (!document.isDeclareFile() && document.isExternalModule()) { + addedGlobalDocument = true; + } + } + } + } else { + var fileNames = this.compiler.fileNames(); + for (var i = 0; i < fileNames.length; i++) { + var doc = this.compiler.getDocument(fileNames[i]); + if (!doc.isDeclareFile() && !doc.isExternalModule()) { + var scriptReferences = doc.referencedFiles; + for (var j = 0; j < scriptReferences.length; j++) { + var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); + var document = this.compiler.getDocument(currentReference); + + if (document && (document.isDeclareFile() || document.isExternalModule())) { + for (var k = 0; k < documents.length; k++) { + if (documents[k] === document) { + break; + } + } + + if (k === documents.length) { + documents = documents.concat(document); + } + } + } + } + } + } + + var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; + for (var i = 0; i < documents.length; i++) { + var document = documents[i]; + var declFileName; + if (document.isDeclareFile()) { + declFileName = document.fileName; + } else { + declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); + } + + declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); + this.declFile.WriteLine('/// '); + } + + this.emittedReferencePaths = true; + }; + + DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { + this.emitReferencePaths(sourceUnit); + this.emitDeclarationsForList(sourceUnit.moduleElements); + }; + return DeclarationEmitter; + })(); + TypeScript.DeclarationEmitter = DeclarationEmitter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var BloomFilter = (function () { + function BloomFilter(expectedCount) { + var m = Math.max(1, BloomFilter.computeM(expectedCount)); + var k = Math.max(1, BloomFilter.computeK(expectedCount)); + ; + + var sizeInEvenBytes = (m + 7) & ~7; + + this.bitArray = []; + for (var i = 0, len = sizeInEvenBytes; i < len; i++) { + this.bitArray[i] = false; + } + this.hashFunctionCount = k; + } + BloomFilter.computeM = function (expectedCount) { + var p = BloomFilter.falsePositiveProbability; + var n = expectedCount; + + var numerator = n * Math.log(p); + var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); + return Math.ceil(numerator / denominator); + }; + + BloomFilter.computeK = function (expectedCount) { + var n = expectedCount; + var m = BloomFilter.computeM(expectedCount); + + var temp = Math.log(2.0) * m / n; + return Math.round(temp); + }; + + BloomFilter.prototype.computeHash = function (key, seed) { + return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); + }; + + BloomFilter.prototype.addKeys = function (keys) { + for (var name in keys) { + if (keys[name]) { + this.add(name); + } + } + }; + + BloomFilter.prototype.add = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + this.bitArray[Math.abs(hash)] = true; + } + }; + + BloomFilter.prototype.probablyContains = function (value) { + for (var i = 0; i < this.hashFunctionCount; i++) { + var hash = this.computeHash(value, i); + hash = hash % this.bitArray.length; + if (!this.bitArray[Math.abs(hash)]) { + return false; + } + } + + return true; + }; + + BloomFilter.prototype.isEquivalent = function (filter) { + return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; + }; + + BloomFilter.isEquivalent = function (array1, array2) { + if (array1.length !== array2.length) { + return false; + } + + for (var i = 0; i < array1.length; i++) { + if (array1[i] !== array2[i]) { + return false; + } + } + + return true; + }; + BloomFilter.falsePositiveProbability = 0.0001; + return BloomFilter; + })(); + TypeScript.BloomFilter = BloomFilter; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var IdentifierWalker = (function (_super) { + __extends(IdentifierWalker, _super); + function IdentifierWalker(list) { + _super.call(this); + this.list = list; + } + IdentifierWalker.prototype.visitToken = function (token) { + this.list[token.text()] = true; + }; + return IdentifierWalker; + })(TypeScript.SyntaxWalker); + TypeScript.IdentifierWalker = IdentifierWalker; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var CompilationSettings = (function () { + function CompilationSettings() { + this.propagateEnumConstants = false; + this.removeComments = false; + this.watch = false; + this.noResolve = false; + this.allowAutomaticSemicolonInsertion = true; + this.noImplicitAny = false; + this.noLib = false; + this.codeGenTarget = 0 /* EcmaScript3 */; + this.moduleGenTarget = 0 /* Unspecified */; + this.outFileOption = ""; + this.outDirOption = ""; + this.mapSourceFiles = false; + this.mapRoot = ""; + this.sourceRoot = ""; + this.generateDeclarationFiles = false; + 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, createFileLog) { + this._propagateEnumConstants = propagateEnumConstants; + this._removeComments = removeComments; + this._watch = watch; + this._noResolve = noResolve; + this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; + this._noImplicitAny = noImplicitAny; + this._noLib = noLib; + this._codeGenTarget = codeGenTarget; + this._moduleGenTarget = moduleGenTarget; + this._outFileOption = outFileOption; + this._outDirOption = outDirOption; + this._mapSourceFiles = mapSourceFiles; + this._mapRoot = mapRoot; + this._sourceRoot = sourceRoot; + this._generateDeclarationFiles = generateDeclarationFiles; + this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; + this._gatherDiagnostics = gatherDiagnostics; + this._codepage = codepage; + this._createFileLog = createFileLog; + } + ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { + return this._propagateEnumConstants; + }; + ImmutableCompilationSettings.prototype.removeComments = function () { + return this._removeComments; + }; + ImmutableCompilationSettings.prototype.watch = function () { + return this._watch; + }; + ImmutableCompilationSettings.prototype.noResolve = function () { + return this._noResolve; + }; + ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { + return this._allowAutomaticSemicolonInsertion; + }; + ImmutableCompilationSettings.prototype.noImplicitAny = function () { + return this._noImplicitAny; + }; + ImmutableCompilationSettings.prototype.noLib = function () { + return this._noLib; + }; + ImmutableCompilationSettings.prototype.codeGenTarget = function () { + return this._codeGenTarget; + }; + ImmutableCompilationSettings.prototype.moduleGenTarget = function () { + return this._moduleGenTarget; + }; + ImmutableCompilationSettings.prototype.outFileOption = function () { + return this._outFileOption; + }; + ImmutableCompilationSettings.prototype.outDirOption = function () { + return this._outDirOption; + }; + ImmutableCompilationSettings.prototype.mapSourceFiles = function () { + return this._mapSourceFiles; + }; + ImmutableCompilationSettings.prototype.mapRoot = function () { + return this._mapRoot; + }; + ImmutableCompilationSettings.prototype.sourceRoot = function () { + return this._sourceRoot; + }; + ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { + return this._generateDeclarationFiles; + }; + ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { + return this._useCaseSensitiveFileResolution; + }; + ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { + return this._gatherDiagnostics; + }; + ImmutableCompilationSettings.prototype.codepage = function () { + return this._codepage; + }; + ImmutableCompilationSettings.prototype.createFileLog = function () { + return this._createFileLog; + }; + + ImmutableCompilationSettings.defaultSettings = function () { + if (!ImmutableCompilationSettings._defaultSettings) { + ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); + } + + return ImmutableCompilationSettings._defaultSettings; + }; + + 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, 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, "_")) { + resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; + } + } + + return result; + }; + return ImmutableCompilationSettings; + })(); + TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (PullElementFlags) { + PullElementFlags[PullElementFlags["None"] = 0] = "None"; + PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; + PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; + PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; + PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; + PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; + PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; + PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; + PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; + PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; + + PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; + PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; + PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; + + PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; + + PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; + + PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; + + PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; + + PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; + + PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; + + PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; + + PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; + PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; + })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); + var PullElementFlags = TypeScript.PullElementFlags; + + function hasModifier(modifiers, flag) { + for (var i = 0, n = modifiers.length; i < n; i++) { + if (TypeScript.hasFlag(modifiers[i], flag)) { + return true; + } + } + + return false; + } + TypeScript.hasModifier = hasModifier; + + (function (PullElementKind) { + PullElementKind[PullElementKind["None"] = 0] = "None"; + PullElementKind[PullElementKind["Global"] = 0] = "Global"; + + PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; + PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; + + PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; + PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; + PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; + PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; + PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; + PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; + PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; + + PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; + PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; + PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; + PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; + PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; + + PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; + PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; + PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; + PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; + + PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; + PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; + + PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; + PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; + PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; + + PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; + PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; + PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; + + PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; + + PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; + PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; + + PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; + + PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; + + 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.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"; + + PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; + + PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; + + PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; + + PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; + })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); + var PullElementKind = TypeScript.PullElementKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var pullDeclID = 0; + var sentinelEmptyPullDeclArray = []; + + var PullDecl = (function () { + 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; + this.childDeclTypeParameterCache = null; + this.name = declName; + this.kind = kind; + this.flags = declFlags; + this.semanticInfoChain = semanticInfoChain; + + if (displayName !== this.name) { + this.declDisplayName = displayName; + } + } + PullDecl.prototype.fileName = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentPath = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getParentDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.isExternalModule = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype.getEnclosingDecl = function () { + throw TypeScript.Errors.abstract(); + }; + + PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { + var decl = this; + while (decl) { + switch (decl.kind) { + default: + return decl; + case 512 /* Variable */: + case 8192 /* TypeParameter */: + case 2048 /* Parameter */: + case 128 /* TypeAlias */: + case 67108864 /* EnumMember */: + } + + decl = decl.getParentDecl(); + } + + TypeScript.Debug.fail(); + }; + + PullDecl.prototype.getDisplayName = function () { + return this.declDisplayName === undefined ? this.name : this.declDisplayName; + }; + + PullDecl.prototype.setSymbol = function (symbol) { + this.semanticInfoChain.setSymbolForDecl(this, symbol); + }; + + 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 */) { + return null; + } + + this.ensureSymbolIsBound(); + + return this.semanticInfoChain.getSymbolForDecl(this); + }; + + PullDecl.prototype.hasSymbol = function () { + var symbol = this.semanticInfoChain.getSymbolForDecl(this); + return !!symbol; + }; + + PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { + this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); + }; + + PullDecl.prototype.getSignatureSymbol = function () { + this.ensureSymbolIsBound(); + return this.semanticInfoChain.getSignatureSymbolForDecl(this); + }; + + PullDecl.prototype.hasSignatureSymbol = function () { + var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); + return !!signatureSymbol; + }; + + PullDecl.prototype.setFlags = function (flags) { + this.flags = flags; + }; + + PullDecl.prototype.setFlag = function (flags) { + this.flags |= flags; + }; + + PullDecl.prototype.setValueDecl = function (valDecl) { + this.synthesizedValDecl = valDecl; + valDecl.containerDecl = this; + }; + + PullDecl.prototype.getValueDecl = function () { + return this.synthesizedValDecl; + }; + + PullDecl.prototype.getContainerDecl = function () { + return this.containerDecl; + }; + + PullDecl.prototype.getChildDeclCache = function (declKind) { + if (declKind === 8192 /* TypeParameter */) { + if (!this.childDeclTypeParameterCache) { + this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeParameterCache; + } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { + if (!this.childDeclNamespaceCache) { + this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclNamespaceCache; + } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { + if (!this.childDeclTypeCache) { + this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclTypeCache; + } else { + if (!this.childDeclValueCache) { + this.childDeclValueCache = TypeScript.createIntrinsicsObject(); + } + + return this.childDeclValueCache; + } + }; + + PullDecl.prototype.addChildDecl = function (childDecl) { + if (childDecl.kind === 8192 /* TypeParameter */) { + if (!this.typeParameters) { + this.typeParameters = []; + } + this.typeParameters[this.typeParameters.length] = childDecl; + } else { + if (!this.childDecls) { + this.childDecls = []; + } + this.childDecls[this.childDecls.length] = childDecl; + } + + var declName = childDecl.name; + + if (!(childDecl.kind & 7340032 /* SomeSignature */)) { + var cache = this.getChildDeclCache(childDecl.kind); + var childrenOfName = cache[declName]; + if (!childrenOfName) { + childrenOfName = []; + } + + childrenOfName.push(childDecl); + cache[declName] = childrenOfName; + } + }; + + PullDecl.prototype.searchChildDecls = function (declName, searchKind) { + var cacheVal = null; + + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; + } else if (searchKind & 164 /* SomeContainer */) { + cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; + } else { + cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; + } + + if (cacheVal) { + return cacheVal; + } else { + if (searchKind & 58728795 /* SomeType */) { + cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; + + if (cacheVal) { + return cacheVal; + } + } + + return sentinelEmptyPullDeclArray; + } + }; + + PullDecl.prototype.getChildDecls = function () { + return this.childDecls || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.getTypeParameters = function () { + return this.typeParameters || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.addVariableDeclToGroup = function (decl) { + if (!this.declGroups) { + this.declGroups = TypeScript.createIntrinsicsObject(); + } + + var declGroup = this.declGroups[decl.name]; + if (declGroup) { + declGroup.addDecl(decl); + } else { + declGroup = new PullDeclGroup(decl.name); + declGroup.addDecl(decl); + this.declGroups[decl.name] = declGroup; + } + }; + + PullDecl.prototype.getVariableDeclGroups = function () { + var declGroups = null; + + if (this.declGroups) { + for (var declName in this.declGroups) { + if (this.declGroups[declName]) { + if (declGroups === null) { + declGroups = []; + } + + declGroups.push(this.declGroups[declName].getDecls()); + } + } + } + + return declGroups || sentinelEmptyPullDeclArray; + }; + + PullDecl.prototype.hasBeenBound = function () { + return this.hasSymbol() || this.hasSignatureSymbol(); + }; + + PullDecl.prototype.isSynthesized = function () { + return false; + }; + + PullDecl.prototype.ast = function () { + return this.semanticInfoChain.getASTForDecl(this); + }; + + PullDecl.prototype.isRootDecl = function () { + throw TypeScript.Errors.abstract(); + }; + return PullDecl; + })(); + TypeScript.PullDecl = PullDecl; + + var RootPullDecl = (function (_super) { + __extends(RootPullDecl, _super); + 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; + } + RootPullDecl.prototype.fileName = function () { + return this._fileName; + }; + + RootPullDecl.prototype.getParentPath = function () { + return [this]; + }; + + RootPullDecl.prototype.getParentDecl = function () { + return null; + }; + + RootPullDecl.prototype.isExternalModule = function () { + return this._isExternalModule; + }; + + 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, addToParent) { + if (typeof addToParent === "undefined") { addToParent = true; } + _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); + this.parentDecl = null; + this.parentPath = null; + + this.parentDecl = parentDecl; + 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._rootDecl.fileName(); + }; + + NormalPullDecl.prototype.getParentDecl = function () { + return this.parentDecl; + }; + + NormalPullDecl.prototype.getParentPath = function () { + if (!this.parentPath) { + var path = [this]; + var parentDecl = this.parentDecl; + + while (parentDecl) { + if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { + path.unshift(parentDecl); + } + + parentDecl = parentDecl.getParentDecl(); + } + + this.parentPath = path; + } + + return this.parentPath; + }; + + NormalPullDecl.prototype.isExternalModule = function () { + return false; + }; + + 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) { + _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); + this.constantValue = null; + } + return PullEnumElementDecl; + })(NormalPullDecl); + TypeScript.PullEnumElementDecl = PullEnumElementDecl; + + var PullFunctionExpressionDecl = (function (_super) { + __extends(PullFunctionExpressionDecl, _super); + function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { + if (typeof displayName === "undefined") { displayName = ""; } + _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); + this.functionExpressionName = expressionName; + } + PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { + return this.functionExpressionName; + }; + return PullFunctionExpressionDecl; + })(NormalPullDecl); + TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; + + var PullSynthesizedDecl = (function (_super) { + __extends(PullSynthesizedDecl, _super); + function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { + _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); + this.semanticInfoChain = semanticInfoChain; + } + PullSynthesizedDecl.prototype.isSynthesized = function () { + return true; + }; + + PullSynthesizedDecl.prototype.fileName = function () { + return this._rootDecl ? this._rootDecl.fileName() : ""; + }; + return PullSynthesizedDecl; + })(NormalPullDecl); + TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; + + var PullDeclGroup = (function () { + function PullDeclGroup(name) { + this.name = name; + this._decls = []; + } + PullDeclGroup.prototype.addDecl = function (decl) { + if (decl.name === this.name) { + this._decls[this._decls.length] = decl; + } + }; + + PullDeclGroup.prototype.getDecls = function () { + return this._decls; + }; + return PullDeclGroup; + })(); + TypeScript.PullDeclGroup = PullDeclGroup; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.pullSymbolID = 0; + TypeScript.sentinelEmptyArray = []; + + var PullSymbol = (function () { + function PullSymbol(name, declKind) { + this.pullSymbolID = ++TypeScript.pullSymbolID; + this._container = null; + this.type = null; + this._declarations = null; + this.isResolved = false; + this.isOptional = false; + this.inResolution = false; + this.isSynthesized = false; + this.isVarArg = false; + this.rootSymbol = null; + this._enclosingSignature = null; + this._docComments = null; + this.isPrinting = false; + this.name = name; + this.kind = declKind; + } + PullSymbol.prototype.isAny = function () { + return false; + }; + + PullSymbol.prototype.isType = function () { + return (this.kind & 58728795 /* SomeType */) !== 0; + }; + + PullSymbol.prototype.isTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isSignature = function () { + return (this.kind & 7340032 /* SomeSignature */) !== 0; + }; + + PullSymbol.prototype.isArrayNamedTypeReference = function () { + return false; + }; + + PullSymbol.prototype.isPrimitive = function () { + return this.kind === 2 /* Primitive */; + }; + + PullSymbol.prototype.isAccessor = function () { + return false; + }; + + PullSymbol.prototype.isError = function () { + return false; + }; + + PullSymbol.prototype.isInterface = function () { + return this.kind === 16 /* Interface */; + }; + + PullSymbol.prototype.isMethod = function () { + return this.kind === 65536 /* Method */; + }; + + PullSymbol.prototype.isProperty = function () { + return this.kind === 4096 /* Property */; + }; + + PullSymbol.prototype.isAlias = function () { + return false; + }; + + PullSymbol.prototype.isContainer = function () { + return false; + }; + + PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { + if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } + if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } + var scopeDeclarations = scopeSymbol.getDeclarations(); + var scopeSymbolAliasesToLookIn = []; + + for (var i = 0; i < scopeDeclarations.length; i++) { + var scopeDecl = scopeDeclarations[i]; + if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { + visitedScopeDeclarations.push(scopeDecl); + + var childDecls = scopeDecl.getChildDecls(); + for (var j = 0; j < childDecls.length; j++) { + var childDecl = childDecls[j]; + if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { + var symbol = childDecl.getSymbol(); + + if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { + aliasSymbols.push(symbol); + return aliasSymbols; + } + + if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { + scopeSymbolAliasesToLookIn.push(symbol); + } + } + } + } + } + + for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { + var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; + + aliasSymbols.push(scopeSymbolAlias); + var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); + if (result) { + return result; + } + + aliasSymbols.pop(); + } + + return null; + }; + + PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { + if (!scopeSymbol) { + return null; + } + + var scopePath = scopeSymbol.pathToRoot(); + if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { + var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); + return symbols; + } + + return null; + }; + + PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { + if (aliasSymbol) { + if (aliasSymbol.assignedValue()) { + return false; + } + + if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { + return false; + } + + if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { + return false; + } + + return true; + } + + return false; + }; + + PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { + if (scopeSymbol) { + 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); + return internalAliases[0]; + } + } + } + } + + return null; + }; + + PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { + if (!skipInternalAlias) { + var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); + if (internalAlias) { + return aliasNameGetter(internalAlias); + } + } + + var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); + + if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { + 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 aliasFullName; + } + + return null; + }; + + PullSymbol.prototype._getResolver = function () { + TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); + return this._declarations[0].semanticInfoChain.getResolver(); + }; + + PullSymbol.prototype._resolveDeclaredSymbol = function () { + return this._getResolver().resolveDeclaredSymbol(this); + }; + + PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getName(); + }); + return aliasName || this.name; + }; + + PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getDisplayName(scopeSymbol, useConstraintInName); + }, function (symbol) { + return symbol.getDisplayName(); + }, skipInternalAliasName); + if (aliasDisplayName) { + return aliasDisplayName; + } + + var decls = this.getDeclarations(); + var name = decls.length && decls[0].getDisplayName(); + + return (name && name.length) ? name : this.name; + }; + + PullSymbol.prototype.getIsSpecialized = function () { + return false; + }; + + PullSymbol.prototype.getRootSymbol = function () { + if (!this.rootSymbol) { + return this; + } + return this.rootSymbol; + }; + PullSymbol.prototype.setRootSymbol = function (symbol) { + this.rootSymbol = symbol; + }; + + 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; + }; + + PullSymbol.prototype.setEnclosingSignature = function (signature) { + this._enclosingSignature = signature; + }; + + PullSymbol.prototype.getEnclosingSignature = function () { + return this._enclosingSignature; + }; + + PullSymbol.prototype.addDeclaration = function (decl) { + TypeScript.Debug.assert(!!decl); + + if (this.rootSymbol) { + return; + } + + if (!this._declarations) { + this._declarations = [decl]; + } else { + this._declarations[this._declarations.length] = decl; + } + }; + + PullSymbol.prototype.getDeclarations = function () { + if (this.rootSymbol) { + return this.rootSymbol.getDeclarations(); + } + + if (!this._declarations) { + this._declarations = []; + } + + return this._declarations; + }; + + PullSymbol.prototype.hasDeclaration = function (decl) { + if (!this._declarations) { + return false; + } + + return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { + return eachDecl === decl; + }); + }; + + PullSymbol.prototype.setContainer = function (containerSymbol) { + if (this.rootSymbol) { + return; + } + + this._container = containerSymbol; + }; + + PullSymbol.prototype.getContainer = function () { + if (this.rootSymbol) { + return this.rootSymbol.getContainer(); + } + + return this._container; + }; + + PullSymbol.prototype.setResolved = function () { + this.isResolved = true; + this.inResolution = false; + }; + + PullSymbol.prototype.startResolving = function () { + this.inResolution = true; + }; + + PullSymbol.prototype.setUnresolved = function () { + this.isResolved = false; + this.inResolution = false; + }; + + PullSymbol.prototype.anyDeclHasFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (TypeScript.hasFlag(declarations[i].flags, flag)) { + return true; + } + } + return false; + }; + + PullSymbol.prototype.allDeclsHaveFlag = function (flag) { + var declarations = this.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + if (!TypeScript.hasFlag(declarations[i].flags, flag)) { + return false; + } + } + return true; + }; + + PullSymbol.prototype.pathToRoot = function () { + var path = []; + var node = this; + while (node) { + if (node.isType()) { + var associatedContainerSymbol = node.getAssociatedContainerType(); + if (associatedContainerSymbol) { + node = associatedContainerSymbol; + } + } + path[path.length] = node; + var nodeKind = node.kind; + if (nodeKind === 2048 /* Parameter */) { + break; + } else { + node = node.getContainer(); + } + } + return path; + }; + + 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 memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { + return true; + } + + var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); + if (memberSymbol && memberSymbol != symbol) { + return true; + } + } + } + + 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 (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { + return thisPath.slice(0, thisCommonAncestorIndex); + } else { + return thisPath; + } + }; + + PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var str = this.getNameAndTypeName(scopeSymbol); + return str; + }; + + PullSymbol.prototype.getNamePartForFullName = function () { + return this.getDisplayName(null, true); + }; + + PullSymbol.prototype.fullName = function (scopeSymbol) { + var _this = this; + var path = this.pathToRoot(); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol === _this ? null : symbol.fullName(scopeSymbol); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + var scopedName = path[i].getNamePartForFullName(); + if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { + break; + } + + if (scopedName === "") { + break; + } + + fullName = scopedName + "." + fullName; + } + + fullName = fullName + this.getNamePartForFullName(); + return fullName; + }; + + PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); + var fullName = ""; + + var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + return aliasFullName; + } + + for (var i = 1; i < path.length; i++) { + var kind = path[i].kind; + if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { + var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { + return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); + }, function (symbol) { + return symbol.getNamePartForFullName(); + }, skipInternalAliasName); + if (aliasFullName) { + fullName = aliasFullName + "." + fullName; + break; + } + + if (kind === 4 /* Container */) { + fullName = path[i].getDisplayName() + "." + fullName; + } else { + var displayName = path[i].getDisplayName(); + if (TypeScript.isQuoted(displayName)) { + fullName = displayName + "." + fullName; + } + break; + } + } else { + break; + } + } + fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); + return fullName; + }; + + PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { + var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + return TypeScript.MemberName.create(name); + }; + + PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { + var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); + return memberName.toString(); + }; + + PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { + var type = this.type; + if (type) { + var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; + if (!memberName) { + memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); + } + + return memberName; + } + return TypeScript.MemberName.create(""); + }; + + 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 */) { + var signatures = type.getCallSignatures(); + 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); + return typeName; + } + } + + return null; + }; + + PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { + var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); + return nameAndTypeName.toString(); + }; + + PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { + var type = this.type; + var nameStr = this.getDisplayName(scopeSymbol); + if (type) { + nameStr = nameStr + (this.isOptional ? "?" : ""); + var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); + if (!memberName) { + var typeNameEx = type.getScopedNameEx(scopeSymbol); + memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); + } + return memberName; + } + return TypeScript.MemberName.create(nameStr); + }; + + PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { + return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); + }; + + PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = ""; + + if (typeParameters && typeParameters.length) { + builder.add(TypeScript.MemberName.create("<")); + + for (var i = 0; i < typeParameters.length; i++) { + if (i) { + builder.add(TypeScript.MemberName.create(", ")); + } + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + + builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); + + if (getTypeParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + } + + builder.add(TypeScript.MemberName.create(">")); + } + + return builder; + }; + + PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { + if (inIsExternallyVisibleSymbols) { + for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { + if (inIsExternallyVisibleSymbols[i] === symbol) { + return true; + } + } + } else { + inIsExternallyVisibleSymbols = []; + } + + if (fromIsExternallyVisibleSymbol === symbol) { + return true; + } + + inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); + + var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); + inIsExternallyVisibleSymbols.pop(); + + return result; + }; + + PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + var kind = this.kind; + if (kind === 2 /* Primitive */) { + return true; + } + + if (this.rootSymbol) { + return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); + } + + if (this.isType()) { + var associatedContainerSymbol = this.getAssociatedContainerType(); + if (associatedContainerSymbol) { + return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); + } + } + + if (this.anyDeclHasFlag(2 /* Private */)) { + return false; + } + + var container = this.getContainer(); + if (container === null) { + var decls = this.getDeclarations(); + if (decls.length) { + var parentDecl = decls[0].getParentDecl(); + if (parentDecl) { + var parentSymbol = parentDecl.getSymbol(); + if (!parentSymbol || parentDecl.kind === 1 /* Script */) { + return true; + } + + return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); + } + } + + return true; + } + + 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 */) { + return false; + } + + return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); + }; + + PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { + var ast = decl.ast(); + + if (ast) { + 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.ASTHelpers.docComments(ast); + } + } + + return []; + }; + + PullSymbol.prototype.getDocCommentArray = function (symbol) { + var docComments = []; + if (!symbol) { + return docComments; + } + + 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 */) { + continue; + } + docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); + } + return docComments; + }; + + PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { + if (classSymbol.getHasDefaultConstructor()) { + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); + } + } + + return classSymbol.type.getConstructSignatures()[0]; + }; + + PullSymbol.prototype.getDocCommentText = function (comments) { + var docCommentText = new Array(); + for (var c = 0; c < comments.length; c++) { + var commentText = this.getDocCommentTextValue(comments[c]); + if (commentText !== "") { + docCommentText.push(commentText); + } + } + return docCommentText.join("\n"); + }; + + PullSymbol.prototype.getDocCommentTextValue = function (comment) { + return this.cleanJSDocComment(comment.fullText()); + }; + + PullSymbol.prototype.docComments = function (useConstructorAsClass) { + var decls = this.getDeclarations(); + 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 */) { + var classSymbol = this.returnType; + var extendedTypes = classSymbol.getExtendedTypes(); + if (extendedTypes.length) { + docComments = extendedTypes[0].getConstructorMethod().docComments(); + } else { + docComments = ""; + } + } else if (this.kind === 2048 /* Parameter */) { + var parameterComments = []; + + var funcContainer = this.getEnclosingSignature(); + var funcDocComments = this.getDocCommentArray(funcContainer); + var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); + if (paramComment != "") { + parameterComments.push(paramComment); + } + + var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); + if (paramSelfComment != "") { + parameterComments.push(paramSelfComment); + } + docComments = parameterComments.join("\n"); + } else { + var getSymbolComments = true; + if (this.kind === 16777216 /* FunctionType */) { + var functionSymbol = this.getFunctionSymbol(); + + if (functionSymbol) { + docComments = functionSymbol._docComments || ""; + getSymbolComments = false; + } else { + var declarationList = this.getDeclarations(); + if (declarationList.length > 0) { + docComments = declarationList[0].getSymbol()._docComments || ""; + getSymbolComments = false; + } + } + } + if (getSymbolComments) { + docComments = this.getDocCommentText(this.getDocCommentArray(this)); + if (docComments === "") { + if (this.kind === 1048576 /* CallSignature */) { + var callTypeSymbol = this.functionType; + if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { + docComments = callTypeSymbol.docComments(); + } + } + } + } + } + + this._docComments = docComments; + } + + return this._docComments; + }; + + PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { + if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { + return ""; + } + + for (var i = 0; i < fncDocComments.length; i++) { + var commentContents = fncDocComments[i].fullText(); + for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { + j += 6; + if (!this.isSpaceChar(commentContents, j)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j); + if (j === -1) { + break; + } + + if (commentContents.charCodeAt(j) === 123 /* openBrace */) { + j++; + + var charCode = 0; + for (var curlies = 1; j < commentContents.length; j++) { + charCode = commentContents.charCodeAt(j); + + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + break; + } else { + continue; + } + } + + if (charCode === 64 /* at */) { + break; + } + } + + if (j === commentContents.length) { + break; + } + + if (charCode === 64 /* at */) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + 1); + if (j === -1) { + break; + } + } + + if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { + continue; + } + + j = this.consumeLeadingSpace(commentContents, j + param.length); + if (j === -1) { + return ""; + } + + var endOfParam = commentContents.indexOf("@", j); + var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); + + var paramSpacesToRemove = undefined; + var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; + if (paramLineIndex !== 0) { + if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { + paramLineIndex++; + } + } + var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); + if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { + paramSpacesToRemove = j - startSpaceRemovalIndex - 1; + } + + return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); + } + } + + return ""; + }; + + PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { + var docCommentLines = new Array(); + content = content.replace("/**", ""); + if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { + content = content.substring(0, content.length - 2); + } + var lines = content.split("\n"); + var inParamTag = false; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); + if (!cleanLinePos) { + continue; + } + + var docCommentText = ""; + var prevPos = cleanLinePos.start; + for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { + var wasInParamtag = inParamTag; + + if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { + if (!wasInParamtag) { + docCommentText += line.substring(prevPos, i); + } + + prevPos = i; + inParamTag = true; + } else if (wasInParamtag) { + prevPos = i; + inParamTag = false; + } + } + + if (!inParamTag) { + docCommentText += line.substring(prevPos, cleanLinePos.end); + } + + var newCleanPos = this.cleanDocCommentLine(docCommentText, false); + if (newCleanPos) { + if (spacesToRemove === undefined) { + spacesToRemove = cleanLinePos.jsDocSpacesRemoved; + } + docCommentLines.push(docCommentText); + } + } + + return docCommentLines.join("\n"); + }; + + PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { + var endIndex = line.length; + if (maxSpacesToRemove !== undefined) { + endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); + } + + for (; startIndex < endIndex; startIndex++) { + var charCode = line.charCodeAt(startIndex); + if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { + return startIndex; + } + } + + if (endIndex !== line.length) { + return endIndex; + } + + return -1; + }; + + PullSymbol.prototype.isSpaceChar = function (line, index) { + var length = line.length; + if (index < length) { + var charCode = line.charCodeAt(index); + + return charCode === 32 /* space */ || charCode === 9 /* tab */; + } + + return index === length; + }; + + PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { + var nonSpaceIndex = this.consumeLeadingSpace(line, 0); + if (nonSpaceIndex !== -1) { + var jsDocSpacesRemoved = nonSpaceIndex; + if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { + var startIndex = nonSpaceIndex + 1; + nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); + + if (nonSpaceIndex !== -1) { + jsDocSpacesRemoved = nonSpaceIndex - startIndex; + } else { + return null; + } + } + + return { + start: nonSpaceIndex, + end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, + jsDocSpacesRemoved: jsDocSpacesRemoved + }; + } + + return null; + }; + return PullSymbol; + })(); + TypeScript.PullSymbol = PullSymbol; + + + + var PullSignatureSymbol = (function (_super) { + __extends(PullSignatureSymbol, _super); + 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.returnType = null; + this.functionType = null; + this.hasOptionalParam = false; + this.nonOptionalParamCount = 0; + this.hasVarArgs = false; + this._allowedToReferenceTypeParameters = null; + this._instantiationCache = null; + this.hasBeenChecked = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + } + PullSignatureSymbol.prototype.isDefinition = function () { + return this._isDefinition; + }; + + PullSignatureSymbol.prototype.isGeneric = function () { + 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) { + this.parameters = []; + } + + this.parameters[this.parameters.length] = parameter; + this.hasOptionalParam = isOptional; + + if (!parameter.getEnclosingSignature()) { + parameter.setEnclosingSignature(this); + } + + if (!isOptional) { + this.nonOptionalParamCount++; + } + }; + + PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!this._typeParameters) { + this._typeParameters = []; + } + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + 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 = []; + } + + return this._typeParameters; + }; + + PullSignatureSymbol.prototype.findTypeParameter = function (name) { + var memberSymbol; + + if (!this._memberTypeParameterNameCache) { + this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); + + for (var i = 0; i < this.getTypeParameters().length; i++) { + this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; + } + } + + memberSymbol = this._memberTypeParameterNameCache[name]; + + 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; + this._stringConstantOverload = false; + for (var i = 0; i < params.length; i++) { + var paramType = params[i].type; + if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { + this._stringConstantOverload = true; + } + } + } + + 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); + allMemberNames.addAll(signatureMemberName); + return allMemberNames; + }; + + PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { + var result = []; + if (!signatures) { + return result; + } + + var len = signatures.length; + if (!getPrettyTypeName && len > 1) { + shortform = false; + } + + var foundDefinition = false; + if (candidateSignature && candidateSignature.isDefinition() && len > 1) { + candidateSignature = null; + } + + for (var i = 0; i < len; i++) { + if (len > 1 && signatures[i].isDefinition()) { + foundDefinition = true; + continue; + } + + var signature = signatures[i]; + if (getPrettyTypeName && candidateSignature) { + signature = candidateSignature; + } + + result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); + if (getPrettyTypeName) { + break; + } + } + + if (getPrettyTypeName && result.length && len > 1) { + var lastMemberName = result[result.length - 1]; + for (var i = i + 1; i < len; i++) { + if (signatures[i].isDefinition()) { + foundDefinition = true; + break; + } + } + var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); + lastMemberName.add(TypeScript.MemberName.create(overloadString)); + } + + return result; + }; + + PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); + return s; + }; + + PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { + var typeParamterBuilder = new TypeScript.MemberNameArray(); + + typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); + + if (brackets) { + typeParamterBuilder.add(TypeScript.MemberName.create("[")); + } else { + typeParamterBuilder.add(TypeScript.MemberName.create("(")); + } + + var builder = new TypeScript.MemberNameArray(); + builder.prefix = prefix; + + if (getTypeParamMarkerInfo) { + builder.prefix = prefix; + builder.addAll(typeParamterBuilder.entries); + } else { + builder.prefix = prefix + typeParamterBuilder.toString(); + } + + var params = this.parameters; + var paramLen = params.length; + for (var i = 0; i < paramLen; i++) { + var paramType = params[i].type; + var typeString = paramType ? ": " : ""; + var paramIsVarArg = params[i].isVarArg; + var varArgPrefix = paramIsVarArg ? "..." : ""; + var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); + if (paramType) { + builder.add(paramType.getScopedNameEx(scopeSymbol)); + } + if (getParamMarkerInfo) { + builder.add(new TypeScript.MemberName()); + } + if (i < paramLen - 1) { + builder.add(TypeScript.MemberName.create(", ")); + } + } + + if (shortform) { + if (brackets) { + builder.add(TypeScript.MemberName.create("] => ")); + } else { + builder.add(TypeScript.MemberName.create(") => ")); + } + } else { + if (brackets) { + builder.add(TypeScript.MemberName.create("]: ")); + } else { + builder.add(TypeScript.MemberName.create("): ")); + } + } + + if (this.returnType) { + builder.add(this.returnType.getScopedNameEx(scopeSymbol)); + } else { + builder.add(TypeScript.MemberName.create("any")); + } + + 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 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 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 wrappingTypeParameterID; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { + if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + + var parameters = this.parameters; + + for (var i = 0; i < parameters.length; i++) { + if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { + return true; + } + } + + return false; + }; + return PullSignatureSymbol; + })(PullSymbol); + TypeScript.PullSignatureSymbol = PullSignatureSymbol; + + var PullTypeSymbol = (function (_super) { + __extends(PullTypeSymbol, _super); + function PullTypeSymbol(name, kind) { + _super.call(this, name, kind); + this._members = TypeScript.sentinelEmptyArray; + this._enclosedMemberTypes = null; + this._enclosedMemberContainers = null; + this._typeParameters = null; + this._allowedToReferenceTypeParameters = null; + this._specializedVersionsOfThisType = null; + this._arrayVersionOfThisType = null; + this._implementedTypes = null; + this._extendedTypes = null; + this._typesThatExplicitlyImplementThisType = null; + this._typesThatExtendThisType = null; + this._callSignatures = null; + this._allCallSignatures = null; + this._constructSignatures = null; + this._indexSignatures = null; + this._allIndexSignatures = null; + this._allIndexSignaturesOfAugmentedType = null; + this._memberNameCache = null; + this._enclosedTypeNameCache = null; + this._enclosedContainerCache = null; + this._typeParameterNameCache = null; + this._containedNonMemberNameCache = null; + this._containedNonMemberTypeNameCache = null; + this._containedNonMemberContainerCache = null; + this._simpleInstantiationCache = null; + this._complexInstantiationCache = null; + this._hasGenericSignature = false; + this._hasGenericMember = false; + this._hasBaseTypeConflict = false; + this._knownBaseTypeCount = 0; + this._associatedContainerTypeSymbol = null; + this._constructorMethod = null; + this._hasDefaultConstructor = false; + this._functionSymbol = null; + this._inMemberTypeNameEx = false; + this.inSymbolPrivacyCheck = false; + this.inWrapCheck = false; + this.inWrapInfiniteExpandingReferenceCheck = false; + this.typeReference = null; + this._widenedType = null; + this._isArrayNamedTypeReference = undefined; + this.type = this; + } + PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { + if (this._isArrayNamedTypeReference === undefined) { + this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); + } + + return this._isArrayNamedTypeReference; + }; + + PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { + var typeArgs = this.getTypeArguments(); + if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { + var declaration = this.getDeclarations()[0]; + + if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.isType = function () { + return true; + }; + PullTypeSymbol.prototype.isClass = function () { + return this.kind === 8 /* Class */ || (this._constructorMethod !== null); + }; + PullTypeSymbol.prototype.isFunction = function () { + return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; + }; + PullTypeSymbol.prototype.isConstructor = function () { + return this.kind === 33554432 /* ConstructorType */; + }; + PullTypeSymbol.prototype.isTypeParameter = function () { + return false; + }; + PullTypeSymbol.prototype.isTypeVariable = function () { + return false; + }; + PullTypeSymbol.prototype.isError = function () { + return false; + }; + PullTypeSymbol.prototype.isEnum = function () { + return this.kind === 64 /* Enum */; + }; + + PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { + return null; + }; + + PullTypeSymbol.prototype.isObject = function () { + 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 () { + return this._knownBaseTypeCount; + }; + PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { + this._knownBaseTypeCount = 0; + }; + PullTypeSymbol.prototype.incrementKnownBaseCount = function () { + this._knownBaseTypeCount++; + }; + + PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { + this._hasBaseTypeConflict = true; + }; + PullTypeSymbol.prototype.hasBaseTypeConflict = function () { + return this._hasBaseTypeConflict; + }; + + PullTypeSymbol.prototype.hasMembers = function () { + if (this._members !== TypeScript.sentinelEmptyArray) { + return true; + } + + var parents = this.getExtendedTypes(); + + for (var i = 0; i < parents.length; i++) { + if (parents[i].hasMembers()) { + return true; + } + } + + return false; + }; + + PullTypeSymbol.prototype.setHasGenericSignature = function () { + this._hasGenericSignature = true; + }; + PullTypeSymbol.prototype.getHasGenericSignature = function () { + return this._hasGenericSignature; + }; + + PullTypeSymbol.prototype.setHasGenericMember = function () { + this._hasGenericMember = true; + }; + PullTypeSymbol.prototype.getHasGenericMember = function () { + return this._hasGenericMember; + }; + + PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { + this._associatedContainerTypeSymbol = type; + }; + + PullTypeSymbol.prototype.getAssociatedContainerType = function () { + return this._associatedContainerTypeSymbol; + }; + + PullTypeSymbol.prototype.getArrayType = function () { + return this._arrayVersionOfThisType; + }; + + PullTypeSymbol.prototype.getElementType = function () { + return null; + }; + + PullTypeSymbol.prototype.setArrayType = function (arrayType) { + this._arrayVersionOfThisType = arrayType; + }; + + PullTypeSymbol.prototype.getFunctionSymbol = function () { + return this._functionSymbol; + }; + + PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { + if (symbol) { + this._functionSymbol = symbol; + } + }; + + PullTypeSymbol.prototype.findContainedNonMember = function (name) { + if (!this._containedNonMemberNameCache) { + return null; + } + + return this._containedNonMemberNameCache[name]; + }; + + PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberTypeNameCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + if (!this._containedNonMemberContainerCache) { + return null; + } + + var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; + + if (nonMemberSymbol && kind !== 0 /* None */) { + nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; + } + + return nonMemberSymbol; + }; + + PullTypeSymbol.prototype.addMember = function (memberSymbol) { + if (!memberSymbol) { + return; + } + + memberSymbol.setContainer(this); + + if (!this._memberNameCache) { + this._memberNameCache = TypeScript.createIntrinsicsObject(); + } + + if (this._members === TypeScript.sentinelEmptyArray) { + this._members = []; + } + + this._members.push(memberSymbol); + this._memberNameCache[memberSymbol.name] = memberSymbol; + }; + + PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + if (!enclosedType) { + return; + } + + enclosedType.setContainer(this); + + if (!this._enclosedTypeNameCache) { + this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberTypes) { + this._enclosedMemberTypes = []; + } + + this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; + this._enclosedTypeNameCache[enclosedType.name] = enclosedType; + }; + + PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + if (!enclosedContainer) { + return; + } + + enclosedContainer.setContainer(this); + + if (!this._enclosedContainerCache) { + this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._enclosedMemberContainers) { + this._enclosedMemberContainers = []; + } + + this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; + this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; + }; + + PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + if (!enclosedNonMember) { + return; + } + + enclosedNonMember.setContainer(this); + + if (!this._containedNonMemberNameCache) { + this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + if (!enclosedNonMemberType) { + return; + } + + enclosedNonMemberType.setContainer(this); + + if (!this._containedNonMemberTypeNameCache) { + this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; + }; + + PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + if (!enclosedNonMemberContainer) { + return; + } + + enclosedNonMemberContainer.setContainer(this); + + if (!this._containedNonMemberContainerCache) { + this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); + } + + this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; + }; + + PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { + if (!typeParameter) { + return; + } + + if (!typeParameter.getContainer()) { + typeParameter.setContainer(this); + } + + if (!this._typeParameterNameCache) { + this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); + } + + if (!this._typeParameters) { + this._typeParameters = []; + } + + this._typeParameters[this._typeParameters.length] = typeParameter; + this._typeParameterNameCache[typeParameter.getName()] = typeParameter; + }; + + PullTypeSymbol.prototype.getMembers = function () { + return this._members; + }; + + PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + this._hasDefaultConstructor = hasOne; + }; + + PullTypeSymbol.prototype.getHasDefaultConstructor = function () { + return this._hasDefaultConstructor; + }; + + PullTypeSymbol.prototype.getConstructorMethod = function () { + return this._constructorMethod; + }; + + PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { + this._constructorMethod = constructorMethod; + }; + + PullTypeSymbol.prototype.getTypeParameters = function () { + if (!this._typeParameters) { + return TypeScript.sentinelEmptyArray; + } + + 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 (typeArgumentMap) { + if (this.isTypeParameter()) { + return true; + } + + 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; + } else { + if (!this._complexInstantiationCache) { + this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); + } + + this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; + } + + if (!this._specializedVersionsOfThisType) { + this._specializedVersionsOfThisType = []; + } + + this._specializedVersionsOfThisType.push(specializedVersionOfThisType); + }; + + PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { + if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { + if (!this._simpleInstantiationCache) { + return null; + } + + var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; + return result || null; + } else { + if (!this._complexInstantiationCache) { + return null; + } + + if (this.getAllowedToReferenceTypeParameters().length == 0) { + return this; + } + + var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; + return result || null; + } + }; + + PullTypeSymbol.prototype.getKnownSpecializations = function () { + if (!this._specializedVersionsOfThisType) { + return TypeScript.sentinelEmptyArray; + } + + return this._specializedVersionsOfThisType; + }; + + PullTypeSymbol.prototype.getTypeArguments = function () { + return null; + }; + + PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + return this.getTypeParameters(); + }; + + PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { + if (!this._callSignatures) { + this._callSignatures = []; + } + + if (callSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + callSignature.functionType = this; + }; + + 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 = []; + } + + if (constructSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + 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 = []; + } + + this._indexSignatures[this._indexSignatures.length] = indexSignature; + + if (indexSignature.isGeneric()) { + this._hasGenericSignature = true; + } + + indexSignature.functionType = this; + }; + + 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; + } + + var signatures = []; + + if (this._callSignatures) { + signatures = signatures.concat(this._callSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); + } + } + + this._allCallSignatures = signatures; + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { + return this._constructSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnConstructSignatures = function () { + return this._constructSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getConstructSignatures = function () { + var signatures = []; + + if (this._constructSignatures) { + signatures = signatures.concat(this._constructSignatures); + } + + if (this._extendedTypes && this.kind === 16 /* Interface */) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); + } + } + + return signatures; + }; + + PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { + return this._indexSignatures !== null; + }; + + PullTypeSymbol.prototype.getOwnIndexSignatures = function () { + return this._indexSignatures || TypeScript.sentinelEmptyArray; + }; + + PullTypeSymbol.prototype.getIndexSignatures = function () { + if (this._allIndexSignatures) { + return this._allIndexSignatures; + } + + var signatures = []; + + if (this._indexSignatures) { + signatures = signatures.concat(this._indexSignatures); + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + if (this._extendedTypes[i].hasBase(this)) { + continue; + } + + this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); + } + } + + this._allIndexSignatures = signatures; + + 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; + } + + if (!this._implementedTypes) { + this._implementedTypes = []; + } + + this._implementedTypes[this._implementedTypes.length] = implementedType; + + implementedType.addTypeThatExplicitlyImplementsThisType(this); + }; + + PullTypeSymbol.prototype.getImplementedTypes = function () { + if (!this._implementedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._implementedTypes; + }; + + PullTypeSymbol.prototype.addExtendedType = function (extendedType) { + if (!extendedType) { + return; + } + + if (!this._extendedTypes) { + this._extendedTypes = []; + } + + this._extendedTypes[this._extendedTypes.length] = extendedType; + + extendedType.addTypeThatExtendsThisType(this); + }; + + PullTypeSymbol.prototype.getExtendedTypes = function () { + if (!this._extendedTypes) { + return TypeScript.sentinelEmptyArray; + } + + return this._extendedTypes; + }; + + PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { + if (!this._typesThatExtendThisType) { + this._typesThatExtendThisType = []; + } + + return this._typesThatExtendThisType; + }; + + PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + if (!type) { + return; + } + + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; + }; + + PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + if (!this._typesThatExplicitlyImplementThisType) { + this._typesThatExplicitlyImplementThisType = []; + } + + return this._typesThatExplicitlyImplementThisType; + }; + + PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { + if (typeof visited === "undefined") { visited = []; } + if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { + return true; + } + + if (TypeScript.ArrayUtilities.contains(visited, this)) { + return true; + } + + visited.push(this); + + var extendedTypes = this.getExtendedTypes(); + + for (var i = 0; i < extendedTypes.length; i++) { + if (extendedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + var implementedTypes = this.getImplementedTypes(); + + for (var i = 0; i < implementedTypes.length; i++) { + if (implementedTypes[i].hasBase(potentialBase, visited)) { + return true; + } + } + + visited.pop(); + + return false; + }; + + PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + if (baseType.isError()) { + return false; + } + + var thisIsClass = this.isClass(); + if (isExtendedType) { + if (thisIsClass) { + return baseType.kind === 8 /* Class */; + } + } else { + if (!thisIsClass) { + return false; + } + } + + return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); + }; + + PullTypeSymbol.prototype.findMember = function (name, lookInParent) { + var memberSymbol = null; + + if (this._memberNameCache) { + memberSymbol = this._memberNameCache[name]; + } + + if (memberSymbol || !lookInParent) { + return memberSymbol; + } + + if (this._extendedTypes) { + for (var i = 0; i < this._extendedTypes.length; i++) { + memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); + + if (memberSymbol) { + return memberSymbol; + } + } + } + + return null; + }; + + PullTypeSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedTypeNameCache) { + return null; + } + + memberSymbol = this._enclosedTypeNameCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + var memberSymbol; + + if (!this._enclosedContainerCache) { + return null; + } + + memberSymbol = this._enclosedContainerCache[name]; + + if (memberSymbol && kind !== 0 /* None */) { + memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; + } + + return memberSymbol; + }; + + PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + var allMembers = []; + + 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 */))) { + allMembers[allMembers.length] = member; + } + } + } + + if (this._extendedTypes) { + var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; + + for (var i = 0, n = this._extendedTypes.length; i < n; i++) { + var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); + + for (var j = 0, m = extendedMembers.length; j < m; j++) { + var extendedMember = extendedMembers[j]; + if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { + allMembers[allMembers.length] = extendedMember; + } + } + } + } + + if (this.isContainer()) { + if (this._enclosedMemberTypes) { + for (var i = 0; i < this._enclosedMemberTypes.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberTypes[i]; + } + } + if (this._enclosedMemberContainers) { + for (var i = 0; i < this._enclosedMemberContainers.length; i++) { + allMembers[allMembers.length] = this._enclosedMemberContainers[i]; + } + } + } + + return allMembers; + }; + + PullTypeSymbol.prototype.findTypeParameter = function (name) { + if (!this._typeParameterNameCache) { + return null; + } + + return this._typeParameterNameCache[name]; + }; + + PullTypeSymbol.prototype.setResolved = function () { + _super.prototype.setResolved.call(this); + }; + + PullTypeSymbol.prototype.getNamePartForFullName = function () { + var name = _super.prototype.getNamePartForFullName.call(this); + + var typars = this.getTypeArgumentsOrTypeParameters(); + var typarString = PullSymbol.getTypeParameterString(typars, this, true); + return name + typarString; + }; + + PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { + return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); + }; + + 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 !== "")) { + return true; + } + + return false; + }; + + PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); + return s; + }; + + 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, "", "[]"); + } + + if (!this.isNamedTypeSymbol()) { + return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); + } + + if (skipTypeParametersInName) { + return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); + } else { + var builder = new TypeScript.MemberNameArray(); + builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); + + var typars = this.getTypeArgumentsOrTypeParameters(); + builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); + + return builder; + } + }; + + PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; + }; + + PullTypeSymbol.prototype.getTypeOfSymbol = function () { + var associatedContainerType = this.getAssociatedContainerType(); + if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { + return associatedContainerType; + } + + var functionSymbol = this.getFunctionSymbol(); + if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { + return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; + } + + return null; + }; + + PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { + var members = this.getMembers(); + var callSignatures = this.getCallSignatures(); + var constructSignatures = this.getConstructSignatures(); + var indexSignatures = this.getIndexSignatures(); + + if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { + var typeOfSymbol = this.getTypeOfSymbol(); + if (typeOfSymbol) { + var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); + return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); + } + + if (this._inMemberTypeNameEx) { + return TypeScript.MemberName.create("any"); + } + + this._inMemberTypeNameEx = true; + + var allMemberNames = new TypeScript.MemberNameArray(); + 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()) { + var methodCallSignatures = members[i].type.getCallSignatures(); + var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); + ; + var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); + allMemberNames.addAll(methodMemberNames); + } else { + var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); + if (memberTypeName.isArray() && memberTypeName.delim === delim) { + allMemberNames.addAll(memberTypeName.entries); + } else { + allMemberNames.add(memberTypeName); + } + } + curlies = true; + } + + var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); + + var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; + var useShortFormSignature = !curlies && (signatureCount === 1); + var signatureMemberName; + + if (callSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); + allMemberNames.addAll(signatureMemberName); + } + + if (constructSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if (indexSignatures.length > 0) { + signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); + allMemberNames.addAll(signatureMemberName); + } + + if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { + allMemberNames.prefix = "{ "; + allMemberNames.suffix = "}"; + allMemberNames.delim = delim; + } else if (allMemberNames.entries.length > 1) { + allMemberNames.delim = delim; + } + + this._inMemberTypeNameEx = false; + + return allMemberNames; + } + + return TypeScript.MemberName.create("{}"); + }; + + PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + return 2 /* Closed */; + }; + + PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; + }; + + PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { + var type = this; + + if (type.isTypeParameter()) { + if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { + return type.pullSymbolID; + } + + var constraint = type.getConstraint(); + var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; + return wrappingTypeParameterID; + } + + if (type.inWrapCheck) { + return 0; + } + + 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; + + var typeArguments = type.getTypeArguments(); + + if (type.isGeneric() && !typeArguments) { + typeArguments = type.getTypeParameters(); + } + + if (typeArguments) { + for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { + wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); + } + } + } + + 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); + } + + wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); + } + + if (!skipTypeArgumentCheck) { + type.inWrapCheck = false; + } + + return wrappingTypeParameterID; + }; + + 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { + var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); + if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { + return wrapsIntoInfinitelyExpandingTypeReference; + } + + if (this.inWrapInfiniteExpandingReferenceCheck) { + return false; + } + + this.inWrapInfiniteExpandingReferenceCheck = true; + wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); + knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); + this.inWrapInfiniteExpandingReferenceCheck = false; + + return wrapsIntoInfinitelyExpandingTypeReference; + }; + + 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(); + for (var i = 0; i < typeArguments.length; i++) { + if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { + continue; + } + + if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { + return true; + } + } + + 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); + TypeScript.PullTypeSymbol = PullTypeSymbol; + + var PullPrimitiveTypeSymbol = (function (_super) { + __extends(PullPrimitiveTypeSymbol, _super); + function PullPrimitiveTypeSymbol(name) { + _super.call(this, name, 2 /* Primitive */); + + this.isResolved = true; + } + PullPrimitiveTypeSymbol.prototype.isAny = function () { + 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 () { + return false; + }; + + 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; + + var PullStringConstantTypeSymbol = (function (_super) { + __extends(PullStringConstantTypeSymbol, _super); + function PullStringConstantTypeSymbol(name) { + _super.call(this, name); + } + PullStringConstantTypeSymbol.prototype.isStringConstant = function () { + return true; + }; + return PullStringConstantTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; + + var PullErrorTypeSymbol = (function (_super) { + __extends(PullErrorTypeSymbol, _super); + function PullErrorTypeSymbol(_anyType, name) { + _super.call(this, name); + 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); + }; + + PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + + PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { + return this._anyType.getName(scopeSymbol, useConstraintInName); + }; + return PullErrorTypeSymbol; + })(PullPrimitiveTypeSymbol); + TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; + + var PullContainerSymbol = (function (_super) { + __extends(PullContainerSymbol, _super); + function PullContainerSymbol(name, kind) { + _super.call(this, name, kind); + this.instanceSymbol = null; + this.assignedValue = null; + this.assignedType = null; + this.assignedContainer = null; + } + PullContainerSymbol.prototype.isContainer = function () { + return true; + }; + + PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { + this.instanceSymbol = symbol; + }; + + PullContainerSymbol.prototype.getInstanceSymbol = function () { + return this.instanceSymbol; + }; + + PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { + this.assignedValue = symbol; + }; + + PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { + return this.assignedValue; + }; + + PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { + this.assignedType = type; + }; + + PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { + return this.assignedType; + }; + + PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { + this.assignedContainer = container; + }; + + PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { + return this.assignedContainer; + }; + + PullContainerSymbol.prototype.hasExportAssignment = function () { + return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; + }; + + PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { + if (!containerSymbol || !containerSymbol.isContainer()) { + return false; + } + + if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { + return true; + } + + var moduleSymbol = containerSymbol; + var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); + var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); + var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); + if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { + return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); + } + + return false; + }; + + PullContainerSymbol.prototype.getInstanceType = function () { + return this.instanceSymbol ? this.instanceSymbol.type : null; + }; + return PullContainerSymbol; + })(PullTypeSymbol); + TypeScript.PullContainerSymbol = PullContainerSymbol; + + var PullTypeAliasSymbol = (function (_super) { + __extends(PullTypeAliasSymbol, _super); + function PullTypeAliasSymbol(name) { + _super.call(this, name, 128 /* TypeAlias */); + this._assignedValue = null; + this._assignedType = null; + 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; + }; + + PullTypeAliasSymbol.prototype.isUsedAsValue = function () { + this._resolveDeclaredSymbol(); + return this._isUsedAsValue; + }; + + PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { + this._typeUsedExternally = true; + }; + + PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { + this._isUsedInExportAlias = true; + if (this.linkedAliasSymbols) { + this.linkedAliasSymbols.forEach(function (s) { + return s.setIsUsedInExportedAlias(); + }); + } + }; + + 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(); + }); + } + }; + + PullTypeAliasSymbol.prototype.assignedValue = function () { + this._resolveDeclaredSymbol(); + return this._assignedValue; + }; + + PullTypeAliasSymbol.prototype.assignedType = function () { + this._resolveDeclaredSymbol(); + return this._assignedType; + }; + + PullTypeAliasSymbol.prototype.assignedContainer = function () { + this._resolveDeclaredSymbol(); + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.isAlias = function () { + return true; + }; + PullTypeAliasSymbol.prototype.isContainer = function () { + return true; + }; + + PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { + this._assignedValue = symbol; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { + if (this._assignedValue) { + return this._assignedValue; + } + + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedValueSymbol(); + this.retrievingExportAssignment = false; + return sym; + } + + return null; + }; + + PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { + this._assignedType = type; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedType) { + if (this._assignedType.isAlias()) { + this.retrievingExportAssignment = true; + var sym = this._assignedType.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + } else if (this._assignedType !== this._assignedContainer) { + return this._assignedType; + } + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedTypeSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { + this._assignedContainer = container; + }; + + PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { + if (this.retrievingExportAssignment) { + return null; + } + + if (this._assignedContainer) { + this.retrievingExportAssignment = true; + var sym = this._assignedContainer.getExportAssignedContainerSymbol(); + this.retrievingExportAssignment = false; + if (sym) { + return sym; + } + } + + return this._assignedContainer; + }; + + PullTypeAliasSymbol.prototype.getMembers = function () { + if (this._assignedType) { + return this._assignedType.getMembers(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getCallSignatures = function () { + if (this._assignedType) { + return this._assignedType.getCallSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getConstructSignatures = function () { + if (this._assignedType) { + return this._assignedType.getConstructSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.getIndexSignatures = function () { + if (this._assignedType) { + return this._assignedType.getIndexSignatures(); + } + + return TypeScript.sentinelEmptyArray; + }; + + PullTypeAliasSymbol.prototype.findMember = function (name) { + if (this._assignedType) { + return this._assignedType.findMember(name, true); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedType = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedType(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { + if (this._assignedType) { + return this._assignedType.findNestedContainer(name); + } + + return null; + }; + + PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { + if (this._assignedType) { + return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); + } + + return TypeScript.sentinelEmptyArray; + }; + return PullTypeAliasSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; + + var PullTypeParameterSymbol = (function (_super) { + __extends(PullTypeParameterSymbol, _super); + function PullTypeParameterSymbol(name) { + _super.call(this, name, 8192 /* TypeParameter */); + this._constraint = null; + } + PullTypeParameterSymbol.prototype.isTypeParameter = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { + this._constraint = constraintType; + }; + + PullTypeParameterSymbol.prototype.getConstraint = function () { + 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(); + } + + return _super.prototype.getCallSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getConstructSignatures = function () { + if (this._constraint) { + return this._constraint.getConstructSignatures(); + } + + return _super.prototype.getConstructSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.getIndexSignatures = function () { + if (this._constraint) { + return this._constraint.getIndexSignatures(); + } + + return _super.prototype.getIndexSignatures.call(this); + }; + + PullTypeParameterSymbol.prototype.isGeneric = function () { + return true; + }; + + PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { + var name = this.getDisplayName(scopeSymbol); + var container = this.getContainer(); + if (container) { + var containerName = container.fullName(scopeSymbol); + name = name + " in " + containerName; + } + + return name; + }; + + PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { + var name = _super.prototype.getName.call(this, scopeSymbol); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { + var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); + + if (this.isPrinting) { + return name; + } + + this.isPrinting = true; + + if (useConstraintInName && this._constraint) { + name += " extends " + this._constraint.toString(scopeSymbol); + } + + this.isPrinting = false; + + return name; + }; + + PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { + return true; + }; + return PullTypeParameterSymbol; + })(PullTypeSymbol); + TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; + + var PullAccessorSymbol = (function (_super) { + __extends(PullAccessorSymbol, _super); + function PullAccessorSymbol(name) { + _super.call(this, name, 4096 /* Property */); + this._getterSymbol = null; + this._setterSymbol = null; + } + PullAccessorSymbol.prototype.isAccessor = function () { + return true; + }; + + PullAccessorSymbol.prototype.setSetter = function (setter) { + if (!setter) { + return; + } + + this._setterSymbol = setter; + }; + + PullAccessorSymbol.prototype.getSetter = function () { + return this._setterSymbol; + }; + + PullAccessorSymbol.prototype.setGetter = function (getter) { + if (!getter) { + return; + } + + this._getterSymbol = getter; + }; + + PullAccessorSymbol.prototype.getGetter = function () { + return this._getterSymbol; + }; + return PullAccessorSymbol; + })(PullSymbol); + TypeScript.PullAccessorSymbol = PullAccessorSymbol; + + function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { + var substitution = ""; + var members = null; + + 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 getIDForTypeSubstitutionsOfType(type) { + var structure; + if (type.isError()) { + structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); + } else if (!type.isNamedTypeSymbol()) { + structure = getIDForTypeSubstitutionsFromObjectType(type); + } + + if (!structure) { + structure = type.pullSymbolID + "#"; + } + + return structure; + } + + function getIDForTypeSubstitutionsFromObjectType(type) { + if (type.isResolved) { + var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); + TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); + } + + return null; + } + + var GetIDForTypeSubStitutionWalker = (function () { + function GetIDForTypeSubStitutionWalker() { + this.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"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; + + GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; + })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); + 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._inferredTypeAfterFixing = null; + this.inferenceCandidates = []; + } + CandidateInferenceInfo.prototype.addCandidate = function (candidate) { + 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 TypeArgumentInferenceContext = (function () { + function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { + this.resolver = resolver; + this.context = context; + this.signatureBeingInferred = signatureBeingInferred; + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + this.candidateCache = []; + var typeParameters = signatureBeingInferred.getTypeParameters(); + for (var i = 0; i < typeParameters.length; i++) { + this.addInferenceRoot(typeParameters[i]); + } + } + TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { + if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { + return true; + } else { + this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); + return false; + } + }; + + TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { + this.inferenceCache.release(); + this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); + }; + + TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { + var info = this.candidateCache[param.pullSymbolID]; + + if (!info) { + info = new CandidateInferenceInfo(); + info.typeParameter = param; + this.candidateCache[param.pullSymbolID] = info; + } + }; + + TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { + return this.candidateCache[param.pullSymbolID]; + }; + + TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { + var info = this.getInferenceInfo(param); + + if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { + info.addCandidate(candidate); + } + }; + + 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); + } + }; + + 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]; + + info.fixTypeParameter(this.resolver, this.context); + + for (var i = 0; i < results.length; i++) { + if (results[i].type === info.typeParameter) { + results[i].type = info._inferredTypeAfterFixing; + } + } + + results.push(info._inferredTypeAfterFixing); + } + + return results; + }; + + TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { + throw TypeScript.Errors.abstract(); + }; + return TypeArgumentInferenceContext; + })(); + 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, isInferentiallyTyping, typeArgumentInferenceContext) { + this.contextualType = contextualType; + this.provisional = provisional; + this.isInferentiallyTyping = isInferentiallyTyping; + this.typeArgumentInferenceContext = typeArgumentInferenceContext; + this.provisionallyTypedSymbols = []; + this.hasProvisionalErrors = false; + this.astSymbolMap = []; + } + PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { + this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; + }; + + PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { + for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { + this.provisionallyTypedSymbols[i].setUnresolved(); + } + }; + + PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()]; + }; + return PullContextualTypeContext; + })(); + TypeScript.PullContextualTypeContext = PullContextualTypeContext; + + var PullTypeResolutionContext = (function () { + function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { + if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } + if (typeof fileName === "undefined") { fileName = null; } + this.resolver = resolver; + this.inTypeCheck = inTypeCheck; + 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"); + this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); + } + } + PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { + if (!this.inProvisionalResolution()) { + this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); + } + }; + + PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { + return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); + }; + + PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { + this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); + }; + + 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(); + + if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { + this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; + } + + return tc; + }; + + PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { + return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; + }; + + PullTypeResolutionContext.prototype.getContextualType = function () { + var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; + + if (context) { + var type = context.contextualType; + + if (!type) { + return null; + } + + 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); + }; + + PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { + return this.inBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { + var wasInBaseTypeResoltion = this.inBaseTypeResolution; + this.inBaseTypeResolution = true; + return wasInBaseTypeResoltion; + }; + + PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { + this.inBaseTypeResolution = wasInBaseTypeResolution; + }; + + PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); + } + }; + + PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { + if (diagnostic) { + if (this.inProvisionalResolution()) { + (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; + } else if (this.inTypeCheck && this.resolver) { + this.resolver.semanticInfoChain.addDiagnostic(diagnostic); + } + } + }; + + PullTypeResolutionContext.prototype.typeCheck = function () { + return this.inTypeCheck && !this.inProvisionalResolution(); + }; + + PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { + this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); + }; + + PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { + for (var i = this.contextStack.length - 1; i >= 0; i--) { + var typeContext = this.contextStack[i]; + if (!typeContext.provisional) { + break; + } + + var symbol = typeContext.getSymbolForAST(ast); + if (symbol) { + return symbol; + } + } + + 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; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var OverloadApplicabilityStatus; + (function (OverloadApplicabilityStatus) { + OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; + OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; + })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); + + var PullAdditionalCallResolutionData = (function () { + function PullAdditionalCallResolutionData() { + this.targetSymbol = null; + this.resolvedSignatures = null; + this.candidateSignature = null; + this.actualParametersContextTypeSymbols = null; + this.diagnosticsFromOverloadResolution = []; + } + return PullAdditionalCallResolutionData; + })(); + TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; + + var PullAdditionalObjectLiteralResolutionData = (function () { + function PullAdditionalObjectLiteralResolutionData() { + this.membersContextTypeSymbols = null; + } + return PullAdditionalObjectLiteralResolutionData; + })(); + TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; + + var MemberWithBaseOrigin = (function () { + function MemberWithBaseOrigin(memberSymbol, baseOrigin) { + this.memberSymbol = memberSymbol; + this.baseOrigin = baseOrigin; + } + return MemberWithBaseOrigin; + })(); + + var SignatureWithBaseOrigin = (function () { + function SignatureWithBaseOrigin(signature, baseOrigin) { + this.signature = signature; + this.baseOrigin = baseOrigin; + } + return SignatureWithBaseOrigin; + })(); + + var InheritedIndexSignatureInfo = (function () { + function InheritedIndexSignatureInfo() { + } + return InheritedIndexSignatureInfo; + })(); + + 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(); + return CompilerReservedName[nameText]; + } + + var PullTypeResolver = (function () { + function PullTypeResolver(compilationSettings, semanticInfoChain) { + this.compilationSettings = compilationSettings; + this.semanticInfoChain = semanticInfoChain; + this._cachedArrayInterfaceType = null; + this._cachedNumberInterfaceType = null; + this._cachedStringInterfaceType = null; + this._cachedBooleanInterfaceType = null; + this._cachedObjectInterfaceType = null; + this._cachedFunctionInterfaceType = null; + this._cachedIArgumentsInterfaceType = null; + this._cachedRegExpInterfaceType = null; + this._cachedAnyTypeArgs = null; + this.typeCheckCallBacks = []; + this.postTypeCheckWorkitems = []; + this._cachedFunctionArgumentsSymbol = null; + 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 */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedArrayInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedArrayInterfaceType; + }; + + PullTypeResolver.prototype.getArrayNamedType = function () { + return this.cachedArrayInterfaceType(); + }; + + PullTypeResolver.prototype.cachedNumberInterfaceType = function () { + if (!this._cachedNumberInterfaceType) { + this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedNumberInterfaceType; + }; + + PullTypeResolver.prototype.cachedStringInterfaceType = function () { + if (!this._cachedStringInterfaceType) { + this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedStringInterfaceType; + }; + + PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { + if (!this._cachedBooleanInterfaceType) { + this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedBooleanInterfaceType; + }; + + PullTypeResolver.prototype.cachedObjectInterfaceType = function () { + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType) { + this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!this._cachedObjectInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedObjectInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { + if (!this._cachedFunctionInterfaceType) { + this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedFunctionInterfaceType; + }; + + PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { + if (!this._cachedIArgumentsInterfaceType) { + this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedIArgumentsInterfaceType; + }; + + PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { + if (!this._cachedRegExpInterfaceType) { + this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; + } + + if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { + this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); + } + + return this._cachedRegExpInterfaceType; + }; + + PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { + if (!this._cachedFunctionArgumentsSymbol) { + this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); + this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; + this._cachedFunctionArgumentsSymbol.setResolved(); + + var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); + functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); + this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); + } + + 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); + }; + + PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { + return context.canTypeCheckAST(ast); + }; + + PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { + if (context && context.inProvisionalResolution()) { + context.setSymbolForAST(ast, symbol); + } else { + this.semanticInfoChain.setSymbolForAST(ast, symbol); + } + }; + + PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { + var symbol = this.semanticInfoChain.getSymbolForAST(ast); + + if (!symbol) { + if (context && context.inProvisionalResolution()) { + symbol = context.getSymbolForAST(ast); + } + } + + return symbol; + }; + + PullTypeResolver.prototype.getASTForDecl = function (decl) { + return this.semanticInfoChain.getASTForDecl(decl); + }; + + PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { + if (typeof name === "undefined") { name = null; } + return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); + }; + + PullTypeResolver.prototype.getEnclosingDecl = function (decl) { + var declPath = decl.getParentPath(); + + if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { + return declPath[declPath.length - 2]; + } else { + return declPath[declPath.length - 1]; + } + }; + + PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { + if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { + var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; + var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; + + if (isContainer && containerType) { + if (symbol.anyDeclHasFlag(1 /* Exported */)) { + return symbol; + } + + return null; + } + } + + return symbol; + }; + + 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 & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + + var containerType = parent.getAssociatedContainerType(); + + if (containerType) { + if (containerType.isClass()) { + return null; + } + + parent = containerType; + + if (declSearchKind & 68147712 /* SomeValue */) { + member = parent.findMember(symbolName, true); + } else if (declSearchKind & 58728795 /* SomeType */) { + member = parent.findNestedType(symbolName); + } else if (declSearchKind & 164 /* SomeContainer */) { + member = parent.findNestedContainer(symbolName); + } + + if (member) { + return this.getExportedMemberSymbol(member, parent); + } + } + + if (parent.kind & 164 /* SomeContainer */) { + var typeDeclarations = parent.getDeclarations(); + var childDecls = null; + + for (var j = 0; j < typeDeclarations.length; j++) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + member = childDecls[0].getSymbol(); + + if (!member) { + member = childDecls[0].getSignatureSymbol(); + } + return this.getExportedMemberSymbol(member, parent); + } + + if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { + childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); + if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { + var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); + if (aliasSymbol) { + if ((declSearchKind & 58728795 /* SomeType */) !== 0) { + var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); + if (typeSymbol) { + return typeSymbol; + } + } else { + var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + return valueSymbol; + } + } + + return aliasSymbol; + } + } + } + } + } + }; + + PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { + var _this = this; + var symbol = null; + + var decl = null; + var childDecls; + var declSymbol = null; + var declMembers; + var pathDeclKind; + var valDecl = null; + var kind; + var instanceSymbol = null; + 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; + + if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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(); + + if (instanceSymbol) { + instanceType = instanceSymbol.type; + + childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } + + valDecl = decl.getValueDecl(); + + if (valDecl) { + decl = valDecl; + } + } + + declSymbol = decl.getSymbol().type; + + var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); + + if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { + return childSymbol; + } + } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { + var candidateSymbol = null; + + if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { + candidateSymbol = decl.getSymbol(); + } + + childDecls = decl.searchChildDecls(symbolName, declSearchKind); + + if (childDecls.length) { + if (decl.kind & 1032192 /* SomeFunction */) { + decl.ensureSymbolIsBound(); + } + return childDecls[0].getSymbol(); + } + + if (candidateSymbol) { + return candidateSymbol; + } + + var alias = tryFindAlias(decl); + if (alias) { + return alias; + } + } + } + + symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); + if (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) { + var result = []; + var decl = null; + var childDecls; + var pathDeclKind; + + for (var i = declPath.length - 1; i >= 0; i--) { + decl = declPath[i]; + pathDeclKind = decl.kind; + + var declKind = decl.kind; + + if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { + this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); + } + + switch (declKind) { + case 4 /* Container */: + case 32 /* DynamicModule */: + var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); + for (var j = 0, m = otherDecls.length; j < m; j++) { + var otherDecl = otherDecls[j]; + if (otherDecl === decl) { + continue; + } + + var otherDeclChildren = otherDecl.getChildDecls(); + for (var k = 0, s = otherDeclChildren.length; k < s; k++) { + var otherDeclChild = otherDeclChildren[k]; + if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { + result.push(otherDeclChild); + } + } + } + + break; + + case 8 /* Class */: + case 16 /* Interface */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + + case 131072 /* FunctionExpression */: + var functionExpressionName = decl.getFunctionExpressionName(); + if (functionExpressionName) { + result.push(decl); + } + + case 16384 /* Function */: + case 32768 /* ConstructorMethod */: + case 65536 /* Method */: + var parameters = decl.getTypeParameters(); + if (parameters && parameters.length) { + this.addFilteredDecls(parameters, declSearchKind, result); + } + + break; + } + } + + var topLevelDecls = this.semanticInfoChain.topLevelDecls(); + for (var i = 0, n = topLevelDecls.length; i < n; i++) { + var topLevelDecl = topLevelDecls[i]; + if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { + continue; + } + + if (!topLevelDecl.isExternalModule()) { + this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); + } + } + + return result; + }; + + PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { + if (decls.length) { + for (var i = 0, n = decls.length; i < n; i++) { + var decl = decls[i]; + if (decl.kind & declSearchKind) { + result.push(decl); + } + } + } + }; + + PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); + }; + + PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { + var contextualTypeSymbol = context.getContextualType(); + if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { + return null; + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); + + for (var i = 0; i < members.length; i++) { + members[i].setUnresolved(); + } + + return members; + }; + + 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 */ || lhs.kind === 64 /* Enum */)) { + return null; + } + + var lhsType = lhs.type; + if (!lhsType) { + return null; + } + + this.resolveDeclaredSymbol(lhsType, context); + + if (lhsType.isContainer() && lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return null; + } + + var memberVisibilty = 2 /* externallyVisible */; + var containerSymbol = lhsType; + if (containerSymbol.kind === 33554432 /* ConstructorType */) { + containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; + } + + if (containerSymbol && containerSymbol.isClass()) { + var declPath = enclosingDecl.getParentPath(); + if (declPath && declPath.length) { + var declarations = containerSymbol.getDeclarations(); + for (var i = 0, n = declarations.length; i < n; i++) { + var declaration = declarations[i]; + if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { + memberVisibilty = 1 /* internallyVisible */; + break; + } + } + } + } + + var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; + + var members = []; + + if (lhsType.isContainer()) { + var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); + if (exportedAssignedContainerSymbol) { + lhsType = exportedAssignedContainerSymbol; + } + } + + lhsType = this.getApparentType(lhsType); + + 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); + } + + 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 */)); + } + + return members; + }; + + PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { + return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); + }; + + PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { + var originalIdText = idText; + var symbol = null; + + if (TypeScript.isRelative(originalIdText)) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + symbol = this.semanticInfoChain.findExternalModule(path + idText); + } else { + idText = originalIdText; + + symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); + + if (!symbol) { + var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); + + while (symbol === null && path != "") { + symbol = this.semanticInfoChain.findExternalModule(path + idText); + if (symbol === null) { + if (path === '/') { + path = ''; + } else { + path = TypeScript.normalizePath(path + ".."); + path = path && path != '/' ? path + '/' : path; + } + } + } + } + } + + return symbol; + }; + + PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { + if (!symbol || symbol.isResolved || symbol.isTypeReference()) { + return symbol; + } + + if (!context) { + context = new TypeScript.PullTypeResolutionContext(this); + } + + return this.resolveDeclaredSymbolWorker(symbol, context); + }; + + PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { + if (!symbol || symbol.isResolved) { + return symbol; + } + + if (symbol.inResolution) { + if (!symbol.type && !symbol.isType()) { + symbol.type = this.semanticInfoChain.anyTypeSymbol; + } + + return symbol; + } + + var decls = symbol.getDeclarations(); + + for (var i = 0; i < decls.length; i++) { + var decl = decls[i]; + + var ast = this.semanticInfoChain.getASTForDecl(decl); + + if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { + return symbol; + } + + if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { + return symbol; + } + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); + var resolvedSymbol; + 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 */); + resolvedSymbol = this.resolveAST(ast, false, context); + } + + if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { + symbol.type = resolvedSymbol.type; + symbol.setResolved(); + } + } + + 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(); + this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { + return _this.resolveOtherDecl(otherDecl, context); + }); + }; + + PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { + var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); + var moduleSymbol = enclosingDecl.getSymbol(); + this.ensureAllSymbolsAreBound(moduleSymbol); + + this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); + this.resolveAST(sourceUnit.moduleElements, false, context); + + if (this.canTypeCheckAST(sourceUnit, context)) { + this.typeCheckSourceUnit(sourceUnit, context); + } + + return moduleSymbol; + }; + + 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) { + var containerDecl = this.semanticInfoChain.getDeclForAST(ast); + var containerSymbol = containerDecl.getSymbol(); + + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + containerSymbol.setResolved(); + + this.resolveOtherDeclarations(ast, context); + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckEnumDeclaration(ast, context); + } + + return containerSymbol; + }; + + 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); + + this.typeCheckCallBacks.push(function (context) { + return _this.checkInitializersInEnumDeclarations(containerDecl, context); + }); + + if (!TypeScript.ASTHelpers.enumIsElided(ast)) { + this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); + } + }; + + PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { + 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; + + if (ast.stringLiteral) { + result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckModuleDeclaration(ast, context); + } + + return result; + }; + + PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { + if (containerSymbol) { + var containerDecls = containerSymbol.getDeclarations(); + + for (var i = 0; i < containerDecls.length; i++) { + var childDecls = containerDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + }; + + PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { + if (containerSymbol.isResolved || containerSymbol.inResolution) { + return containerSymbol; + } + + containerSymbol.inResolution = true; + this.ensureAllSymbolsAreBound(containerSymbol); + + var instanceSymbol = containerSymbol.getInstanceSymbol(); + + if (instanceSymbol) { + this.resolveDeclaredSymbol(instanceSymbol, context); + } + + var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); + if (isLastName) { + this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); + } else if (sourceUnitAST) { + this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); + } + + containerSymbol.setResolved(); + + if (moduleDeclNameAST) { + this.resolveOtherDeclarations(moduleDeclNameAST, context); + } + + return containerSymbol; + }; + + 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 */) { + this.resolveExportAssignmentStatement(moduleElement, context); + return; + } + } + }; + + PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + var containerSymbol = containerDecl.getSymbol(); + + return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); + }; + + PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { + if (ast.stringLiteral) { + this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); + } else { + var moduleNames = TypeScript.getModuleNames(ast.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); + } + } + }; + + PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { + var _this = this; + this.setTypeChecked(ast, context); + + if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { + this.resolveAST(ast.moduleElements, false, context); + } + + var containerDecl = this.semanticInfoChain.getDeclForAST(astName); + this.validateVariableDeclarationGroups(containerDecl, context); + + if (ast.stringLiteral) { + if (TypeScript.isRelative(ast.stringLiteral.valueText())) { + this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); + } + } + + 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) { + this.checkThisCaptureVariableCollides(ast, true, context); + }; + + PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { + if (term.kind() === 11 /* IdentifierName */) { + return true; + } else if (term.kind() === 121 /* QualifiedName */) { + var binex = term; + + if (binex.right.kind() === 11 /* IdentifierName */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { + if (!type.isGeneric()) { + return type; + } + + var typeParameters = type.getTypeArgumentsOrTypeParameters(); + + var typeParameterArgumentMap = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); + } + + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + }; + + PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(typeDecl); + var typeDeclSymbol = typeDecl.getSymbol(); + var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; + var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; + + if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { + return typeDeclSymbol; + } + + var wasResolving = typeDeclSymbol.inResolution; + typeDeclSymbol.startResolving(); + + var typeRefDecls = typeDeclSymbol.getDeclarations(); + + for (var i = 0; i < typeRefDecls.length; i++) { + var childDecls = typeRefDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + + 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); + if (extendsClause) { + for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { + typeDeclSymbol.incrementKnownBaseCount(); + var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); + + if (typeDeclSymbol.isValidBaseKind(parentType, true)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + + if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addExtendedType(parentType); + + var specializations = typeDeclSymbol.getKnownSpecializations(); + + for (var j = 0; j < specializations.length; j++) { + specializations[j].addExtendedType(parentType); + } + } + } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { + this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); + } + } + } + + 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()) { + typeDeclSymbol.incrementKnownBaseCount(); + var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); + var implementedType = this.resolveTypeReference(implementedTypeAST, context); + + if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + + if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { + typeDeclSymbol.addImplementedType(implementedType); + } + } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { + this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); + } + } + } + + context.doneBaseTypeResolution(wasInBaseTypeResolution); + + if (wasInBaseTypeResolution) { + typeDeclSymbol.inResolution = false; + + this.typeCheckCallBacks.push(function (context) { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + _this.resolveClassDeclaration(classOrInterface, context); + } else { + _this.resolveInterfaceDeclaration(classOrInterface, context); + } + }); + + return typeDeclSymbol; + } + + this.setSymbolForAST(name, typeDeclSymbol, context); + this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); + + typeDeclSymbol.setResolved(); + + return typeDeclSymbol; + }; + + 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); + + var constructorMethod = classDeclSymbol.getConstructorMethod(); + var extendedTypes = classDeclSymbol.getExtendedTypes(); + var parentType = extendedTypes.length ? extendedTypes[0] : null; + + if (constructorMethod) { + var constructorTypeSymbol = constructorMethod.type; + + var constructSignatures = constructorTypeSymbol.getConstructSignatures(); + + if (!constructSignatures.length) { + var constructorSignature; + + var parentConstructor = parentType ? parentType.getConstructorMethod() : null; + + if (parentConstructor) { + this.resolveDeclaredSymbol(parentConstructor, context); + var parentConstructorType = parentConstructor.type; + var parentConstructSignatures = parentConstructorType.getConstructSignatures(); + + var parentConstructSignature; + var parentParameters; + + if (!parentConstructSignatures.length) { + parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + parentConstructSignature.returnType = parentType; + parentConstructSignature.addTypeParametersFromReturnType(); + parentConstructorType.appendConstructSignature(parentConstructSignature); + parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); + parentConstructSignatures = [parentConstructSignature]; + } + + for (var i = 0; i < parentConstructSignatures.length; i++) { + parentConstructSignature = parentConstructSignatures[i]; + parentParameters = parentConstructSignature.parameters; + + 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); + } + + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } else { + constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + constructorSignature.returnType = classDeclSymbol; + constructorSignature.addTypeParametersFromReturnType(); + constructorTypeSymbol.appendConstructSignature(constructorSignature); + constructorSignature.addDeclaration(classDecl); + } + } + + if (!classDeclSymbol.isResolved) { + return classDeclSymbol; + } + + if (parentType) { + var parentConstructorSymbol = parentType.getConstructorMethod(); + + if (parentConstructorSymbol) { + var parentConstructorTypeSymbol = parentConstructorSymbol.type; + + if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { + constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); + } + } + } + } + + this.resolveOtherDeclarations(classDeclAST, context); + } + + if (this.canTypeCheckAST(classDeclAST, context)) { + this.typeCheckClassDeclaration(classDeclAST, context); + } + + return classDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { + var _this = this; + 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); + }); + } + } + }; + + PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { + this.setTypeChecked(classDeclAST, context); + + var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); + var classDeclSymbol = classDecl.getSymbol(); + + this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); + this.resolveAST(classDeclAST.classElements, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); + this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); + + if (!classDeclSymbol.hasBaseTypeConflict()) { + this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); + } + + this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); + }; + + PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { + this.checkThisCaptureVariableCollides(classDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { + var callSignatures = typeSymbol.getCallSignatures(); + for (var i = 0; i < callSignatures.length; i++) { + this.resolveDeclaredSymbol(callSignatures[i], context); + } + + var constructSignatures = typeSymbol.getConstructSignatures(); + for (var i = 0; i < constructSignatures.length; i++) { + this.resolveDeclaredSymbol(constructSignatures[i], context); + } + + var indexSignatures = typeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignatures.length; i++) { + this.resolveDeclaredSymbol(indexSignatures[i], context); + } + }; + + PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { + this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); + + if (interfaceDeclSymbol.isResolved) { + this.resolveOtherDeclarations(interfaceDeclAST, context); + + if (this.canTypeCheckAST(interfaceDeclAST, context)) { + this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); + } + } + + return interfaceDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { + this.setTypeChecked(interfaceDeclAST, context); + + var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); + var interfaceDeclSymbol = interfaceDecl.getSymbol(); + + this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); + + this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); + this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); + + 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) { + if (symbol) { + if (symbol.kind & kind) { + return symbol; + } + + if (symbol.isAlias()) { + this.resolveDeclaredSymbol(symbol, context); + + var alias = symbol; + if (kind & 164 /* SomeContainer */) { + return alias.getExportAssignedContainerSymbol(); + } else if (kind & 58728795 /* SomeType */) { + return alias.getExportAssignedTypeSymbol(); + } else if (kind & 68147712 /* SomeValue */) { + return alias.getExportAssignedValueSymbol(); + } + } + } + return null; + }; + + PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { + var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); + + return { + symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), + aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null + }; + }; + + PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { + var rhsName = identifier.valueText(); + if (rhsName.length === 0) { + return null; + } + + var moduleTypeSymbol = moduleSymbol.type; + var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); + var containerSymbol = memberSymbol.symbol; + var valueSymbol = null; + var typeSymbol = null; + var aliasSymbol = null; + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + aliasSymbol = memberSymbol.aliasSymbol; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + aliasSymbol = containerSymbol; + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return null; + } + + if (!valueSymbol) { + if (moduleTypeSymbol.getInstanceSymbol()) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); + valueSymbol = memberSymbol.symbol; + if (valueSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + } + + if (!typeSymbol) { + memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); + typeSymbol = memberSymbol.symbol; + if (typeSymbol && memberSymbol.aliasSymbol) { + aliasSymbol = memberSymbol.aliasSymbol; + } + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); + return null; + } + + if (!typeSymbol && containerSymbol) { + typeSymbol = containerSymbol; + } + + return { + valueSymbol: valueSymbol, + typeSymbol: typeSymbol, + containerSymbol: containerSymbol, + aliasSymbol: aliasSymbol + }; + }; + + 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"); + + var moduleSymbol = null; + var moduleName; + + if (moduleNameExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = moduleNameExpr; + var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleContainer) { + moduleName = dottedNameAST.right.valueText(); + + moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; + if (!moduleSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); + } + } + } else { + var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); + var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); + + if (text.length > 0) { + var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); + moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); + if (moduleSymbol) { + 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]); + } + } + } + + return moduleSymbol; + }; + + PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + + var moduleReference = importStatementAST.moduleReference; + + var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; + + 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); + if (moduleSymbol) { + aliasedType = moduleSymbol.type; + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); + if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { + var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); + var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); + var instanceSymbol = aliasedType.getInstanceSymbol(); + + 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 { + importDeclSymbol.setAssignedValueSymbol(valueSymbol); + } + } + } else { + aliasedType = this.getNewErrorTypeSymbol(); + } + } else if (aliasExpr.kind() === 121 /* QualifiedName */) { + var dottedNameAST = aliasExpr; + var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); + if (moduleSymbol) { + var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); + if (identifierResolution) { + importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); + importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); + importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); + this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); + return null; + } + } + } + + if (!aliasedType) { + importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); + } + + return aliasedType; + }; + + PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + var aliasedType = null; + + if (importDeclSymbol.isResolved) { + return importDeclSymbol; + } + + importDeclSymbol.startResolving(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + var declPath = enclosingDecl.getParentPath(); + + aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); + + if (!aliasedType) { + var path = importStatementAST.moduleReference.stringLiteral.text(); + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); + aliasedType = this.getNewErrorTypeSymbol(); + } + } else { + aliasedType = this.resolveInternalModuleReference(importStatementAST, context); + } + + if (aliasedType) { + if (!aliasedType.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); + if (!aliasedType.isError()) { + aliasedType = this.getNewErrorTypeSymbol(); + } + } + + if (aliasedType.isContainer()) { + importDeclSymbol.setAssignedContainerSymbol(aliasedType); + } + importDeclSymbol.setAssignedTypeSymbol(aliasedType); + + this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); + } + + importDeclSymbol.setResolved(); + + this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); + 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); + } + + return importDeclSymbol; + }; + + PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { + var _this = this; + this.setTypeChecked(importStatementAST, context); + + var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); + var enclosingDecl = this.getEnclosingDecl(importDecl); + var importDeclSymbol = importDecl.getSymbol(); + + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + if (this.compilationSettings.noResolve()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); + } + + var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); + if (enclosingDecl.kind === 32 /* DynamicModule */) { + 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)); + } + } + } + } + + var checkPrivacy; + if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var container = containerSymbol ? containerSymbol.getContainer() : null; + if (container && container.kind === 32 /* DynamicModule */) { + checkPrivacy = true; + } + } else { + checkPrivacy = true; + } + + if (checkPrivacy) { + var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); + var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); + var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); + + this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { + var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + + 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; + + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + + if (valueSymbol) { + this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { + var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; + var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); + }); + } + } + + this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); + }; + + PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { + 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); + } + }; + + PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { + var id = exportAssignmentAST.identifier.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var valueSymbol = null; + var typeSymbol = null; + var containerSymbol = null; + + var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); + var parentSymbol = enclosingDecl.getSymbol(); + + if (!parentSymbol.isType() && parentSymbol.isContainer()) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); + return this.semanticInfoChain.anyTypeSymbol; + } + + var declPath = enclosingDecl !== null ? [enclosingDecl] : []; + + containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); + + var acceptableAlias = true; + + if (containerSymbol) { + acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; + } + + if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { + this.resolveDeclaredSymbol(containerSymbol, context); + + var aliasSymbol = containerSymbol; + var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); + var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); + var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); + + if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { + valueSymbol = aliasedAssignedValue; + typeSymbol = aliasedAssignedType; + containerSymbol = aliasedAssignedContainer; + aliasSymbol.setTypeUsedExternally(); + if (valueSymbol) { + aliasSymbol.setIsUsedAsValue(); + } + acceptableAlias = true; + } + } + + if (!acceptableAlias) { + this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (!valueSymbol) { + valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); + } + if (!typeSymbol) { + typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); + } + + if (!valueSymbol && !typeSymbol && !containerSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); + return this.semanticInfoChain.voidTypeSymbol; + } + + if (valueSymbol) { + parentSymbol.setExportAssignedValueSymbol(valueSymbol); + } + if (typeSymbol) { + parentSymbol.setExportAssignedTypeSymbol(typeSymbol); + } + if (containerSymbol) { + parentSymbol.setExportAssignedContainerSymbol(containerSymbol); + } + + this.resolveDeclaredSymbol(valueSymbol, context); + this.resolveDeclaredSymbol(typeSymbol, context); + this.resolveDeclaredSymbol(containerSymbol, context); + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + var funcDeclSymbol = functionDecl.getSymbol(); + + var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); + } + } + + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.setTypeChecked(funcDeclAST, context); + this.typeCheckFunctionOverloads(funcDeclAST, context); + } + + return funcDeclSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + + if (argDeclAST.typeAnnotation) { + var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + 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) { + if (this.cachedArrayInterfaceType()) { + context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); + } else { + 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 (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(); + }; + + PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { + var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); + var paramSymbol = paramDecl.getSymbol(); + var contextualType = contextParam && contextParam.type; + var isImplicitAny = false; + + if (typeExpr) { + var typeRef = this.resolveTypeReference(typeExpr, context); + + if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { + var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); + typeRef = this.getNewErrorTypeSymbol(); + } + + contextualType = typeRef || contextualType; + } + if (contextualType) { + if (context.isInferentiallyTyping()) { + contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); + } + context.setTypeInContext(paramSymbol, contextualType); + } 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.propagateContextualType(contextualType); + } + + var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + } + + if (!initExprSymbol || !initExprSymbol.type) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); + + if (!contextualType) { + context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); + } + } else { + var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); + if (!contextualType) { + context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); + isImplicitAny = initTypeSymbol !== paramSymbol.type; + } else { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); + } + } + } + } + } + + if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { + context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); + isImplicitAny = true; + } + + if (isImplicitAny && this.compilationSettings.noImplicitAny()) { + var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); + if (functionExpressionName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); + } + } + + if (canTypeCheckAST) { + this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); + } + + paramSymbol.setResolved(); + }; + + PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { + var compilerReservedName = getCompilerReservedName(name); + switch (compilerReservedName) { + case 1 /* _this */: + this.postTypeCheckWorkitems.push(astWithName); + return; + + case 2 /* _super */: + this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); + return; + + case 3 /* arguments */: + this.checkArgumentsCollides(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; + } + }; + + PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { + var enclosingAST = this.getASTForDecl(someFunctionDecl); + var nodeType = enclosingAST.kind(); + + 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); + } 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 */) { + var constructorDeclaration = enclosingAST; + 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 */) { + var functionExpression = enclosingAST; + return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); + } + + return false; + }; + + PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { + if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); + } + } + } + }; + + PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { + if (!isDeclaration || ast.kind() === 242 /* Parameter */) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + 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)); + } + } + } + } + }; + + PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { + var decl = this.semanticInfoChain.getDeclForAST(ast); + + if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + var nameText = name.valueText(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); + } + } + }; + + PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { + var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); + TypeScript.Debug.assert(interfaceDecl); + + var interfaceSymbol = interfaceDecl.getSymbol(); + TypeScript.Debug.assert(interfaceSymbol); + + if (objectType.typeMembers) { + var memberDecl = null; + var memberSymbol = null; + var memberType = null; + var typeMembers = objectType.typeMembers; + + for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { + memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); + memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); + + this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); + + memberType = memberSymbol.type; + + if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { + interfaceSymbol.setHasGenericMember(); + } + } + } + + interfaceSymbol.setResolved(); + + if (this.canTypeCheckAST(objectType, context)) { + this.typeCheckObjectTypeTypeReference(objectType, context); + } + + return interfaceSymbol; + }; + + PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { + this.setTypeChecked(objectType, context); + var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); + var objectTypeSymbol = objectTypeDecl.getSymbol(); + + this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); + this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); + }; + + PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { + return this.resolveTypeReference(typeAnnotation.type, context); + }; + + PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { + if (typeRef === null) { + return null; + } + + TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); + + var aliasType = null; + var type = this.computeTypeReferenceSymbol(typeRef, context); + + if (type.kind === 4 /* Container */) { + var container = type; + var instanceSymbol = container.getInstanceSymbol(); + + if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { + type = instanceSymbol.type.getAssociatedContainerType(); + } + } + + if (type && type.isAlias()) { + aliasType = type; + type = aliasType.getExportAssignedTypeSymbol(); + } + + if (type && !type.isGeneric()) { + if (aliasType) { + this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); + } + } + + if (type && !type.isError()) { + 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 { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); + } + } + } + + if (this.canTypeCheckAST(typeRef, context)) { + this.setTypeChecked(typeRef, context); + } + + 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 */: + return this.semanticInfoChain.anyTypeSymbol; + case 61 /* BooleanKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + case 67 /* NumberKeyword */: + return this.semanticInfoChain.numberTypeSymbol; + case 69 /* StringKeyword */: + return this.semanticInfoChain.stringTypeSymbol; + case 41 /* VoidKeyword */: + return this.semanticInfoChain.voidTypeSymbol; + } + + var typeDeclSymbol = null; + + if (term.kind() === 11 /* IdentifierName */) { + typeDeclSymbol = this.resolveTypeNameExpression(term, context); + } else if (term.kind() === 123 /* FunctionType */) { + var functionType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); + } else if (term.kind() === 125 /* ConstructorType */) { + var constructorType = term; + typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); + } else if (term.kind() === 122 /* ObjectType */) { + typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); + } else if (term.kind() === 126 /* GenericType */) { + typeDeclSymbol = this.resolveGenericTypeReference(term, context); + } else if (term.kind() === 121 /* QualifiedName */) { + typeDeclSymbol = this.resolveQualifiedName(term, context); + } else if (term.kind() === 14 /* StringLiteral */) { + 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, enclosingDecl.semanticInfoChain); + typeDeclSymbol.addDeclaration(decl); + } else if (term.kind() === 127 /* TypeQuery */) { + var typeQuery = term; + + var typeQueryTerm = typeQuery.name; + + var valueSymbol = this.resolveAST(typeQueryTerm, false, context); + + if (valueSymbol && valueSymbol.isAlias()) { + if (valueSymbol.assignedValue()) { + valueSymbol = valueSymbol.assignedValue(); + } else { + var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); + valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; + } + } + + if (valueSymbol) { + typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); + } else { + typeDeclSymbol = this.getNewErrorTypeSymbol(); + } + } else if (term.kind() === 124 /* ArrayType */) { + var arrayType = term; + var underlying = this.resolveTypeReference(arrayType.type, context); + typeDeclSymbol = this.getArrayType(underlying); + } else { + throw TypeScript.Errors.invalidOperation("unknown type"); + } + + if (!typeDeclSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); + return this.getNewErrorTypeSymbol(); + } + + if (typeDeclSymbol.isError()) { + return typeDeclSymbol; + } + + if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); + typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); + } + + return typeDeclSymbol; + }; + + PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { + 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveParameterList = function (list, context) { + return this.resolveSeparatedList(list.parameters, context); + }; + + PullTypeResolver.prototype.resolveParameter = function (parameter, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { + var enumDeclaration = enumElement.parent.parent; + var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); + var symbol = decl.getSymbol(); + this.resolveDeclaredSymbol(symbol, context); + + return symbol; + }; + + PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { + return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); + }; + + PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { + if (this.canTypeCheckAST(clause, context)) { + this.setTypeChecked(clause, context); + } + + return this.resolveAST(clause.value, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + + if (enclosingDecl && decl.kind === 2048 /* Parameter */) { + enclosingDecl.ensureSymbolIsBound(); + } + + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (declSymbol.isResolved) { + var declType = declSymbol.type; + var valDecl = decl.getValueDecl(); + + if (valDecl) { + var valSymbol = valDecl.getSymbol(); + + if (valSymbol && !valSymbol.isResolved) { + valSymbol.type = declType; + valSymbol.setResolved(); + } + } + } else { + if (declSymbol.inResolution) { + declSymbol.type = this.semanticInfoChain.anyTypeSymbol; + declSymbol.setResolved(); + return declSymbol; + } + + if (!declSymbol.type || !declSymbol.type.isError()) { + declSymbol.startResolving(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + if (!hasTypeExpr) { + this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + } + + if (!(hasTypeExpr || init)) { + var defaultType = this.semanticInfoChain.anyTypeSymbol; + + if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { + defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); + } + + context.setTypeInContext(declSymbol, defaultType); + + if (declParameterSymbol) { + declParameterSymbol.type = defaultType; + } + } + declSymbol.setResolved(); + + if (declParameterSymbol) { + declParameterSymbol.setResolved(); + } + } + } + + if (this.canTypeCheckAST(varDeclOrParameter, context)) { + this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); + } + + return declSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + if (varDeclOrParameter.kind() === 243 /* EnumElement */) { + var result = this.getEnumTypeSymbol(varDeclOrParameter, context); + declSymbol.type = result; + return result; + } + + if (!typeExpr) { + return null; + } + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var typeExprSymbol = this.resolveTypeReference(typeExpr, context); + + if (!typeExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + declSymbol.type = this.getNewErrorTypeSymbol(); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } else if (typeExprSymbol.isError()) { + context.setTypeInContext(declSymbol, typeExprSymbol); + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, typeExprSymbol); + } + } else { + if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { + decl.setFlag(16777216 /* IsAnnotatedWithAny */); + } + + if (typeExprSymbol.isContainer()) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + typeExprSymbol = typeExprSymbol.type; + + if (typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { + var instanceSymbol = typeExprSymbol.getInstanceSymbol(); + + if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { + typeExprSymbol = this.getNewErrorTypeSymbol(); + } else { + typeExprSymbol = instanceSymbol.type; + } + } + } + } 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(); + } + + context.setTypeInContext(declSymbol, typeExprSymbol); + + if (declParameterSymbol) { + declParameterSymbol.type = typeExprSymbol; + } + + if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { + typeExprSymbol.setFunctionSymbol(declSymbol); + } + } + + return typeExprSymbol; + }; + + PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { + if (!init) { + return null; + } + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + if (typeExprSymbol) { + context.pushNewContextualType(typeExprSymbol); + } + + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; + + var wrapperDecl = this.getEnclosingDecl(decl); + wrapperDecl = wrapperDecl || enclosingDecl; + + var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); + + if (typeExprSymbol) { + context.popAnyContextualType(); + } + + if (!initExprSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); + + if (!hasTypeExpr) { + context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); + } + } + } else { + var initTypeSymbol = initExprSymbol.type; + + if (!hasTypeExpr) { + var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); + context.setTypeInContext(declSymbol, widenedInitTypeSymbol); + + if (declParameterSymbol) { + context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); + } + + if (this.compilationSettings.noImplicitAny()) { + 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 initTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); + }; + + PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { + var _this = this; + this.setTypeChecked(varDeclOrParameter, context); + + var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; + var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); + var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); + var declSymbol = decl.getSymbol(); + + var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); + + var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); + + if (hasTypeExpr || init) { + if (typeExprSymbol && typeExprSymbol.isAlias()) { + typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + } + + if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { + var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); + + if (exportedTypeSymbol) { + typeExprSymbol = exportedTypeSymbol; + } else { + var instanceTypeSymbol = typeExprSymbol.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); + typeExprSymbol = null; + } else { + typeExprSymbol = instanceTypeSymbol; + } + } + } + + initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); + + if (initTypeSymbol && typeExprSymbol) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); + } + } + } + } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { + var wrapperDecl = this.getEnclosingDecl(decl); + 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])); + } else if (wrapperDecl.kind === 65536 /* Method */) { + var parentDecl = wrapperDecl.getParentDecl(); + + if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); + } 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 (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 */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); + } + } + } + + 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_only_allowed_in_implementation)); + } + } + 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 */)) { + this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); + } + }; + + PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { + return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; + }; + + PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { + var enclosingDecl = this.getEnclosingDeclForAST(superAST); + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); + + if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { + 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; + if (!block) { + return; + } + } + } + + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + if (parents.length) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); + } + } + }; + + PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { + if (isDeclaration) { + var decl = this.semanticInfoChain.getDeclForAST(_thisAST); + if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { + return; + } + } + + var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); + + var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); + if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { + enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); + } + + var declPath = enclosingDecl.getParentPath(); + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + continue; + } + + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); + } + break; + } + } + }; + + PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { + this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); + }; + + PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { + 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) { + return; + } + + typeParameterSymbol.startResolving(); + + if (typeParameterAST.constraint) { + var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); + + if (constraintTypeSymbol) { + typeParameterSymbol.setConstraint(constraintTypeSymbol); + } + } + + typeParameterSymbol.setResolved(); + }; + + PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { + this.setTypeChecked(typeParameterAST, 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) { + if (this.canTypeCheckAST(constraint, context)) { + this.setTypeChecked(constraint, context); + } + + return this.resolveTypeReference(constraint.type, context); + }; + + PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { + var _this = this; + var returnStatementsExpressions = []; + + var enclosingDeclStack = [enclosingDecl]; + + var preFindReturnExpressionTypes = function (ast, walker) { + var go = true; + + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 215 /* ObjectLiteralExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); + go = false; + break; + + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); + break; + + default: + break; + } + + walker.options.goChildren = go; + + return ast; + }; + + var postFindReturnExpressionEnclosingDecls = function (ast, walker) { + switch (ast.kind()) { + case 236 /* CatchClause */: + case 163 /* WithStatement */: + enclosingDeclStack.length--; + break; + default: + break; + } + + walker.options.goChildren = true; + + return ast; + }; + + if (block) { + TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); + } else { + returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); + enclosingDecl.setFlag(4194304 /* HasReturnStatement */); + } + + if (!returnStatementsExpressions.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var returnExpressionSymbols = []; + var returnExpressions = []; + + for (var i = 0; i < returnStatementsExpressions.length; i++) { + var returnExpression = returnStatementsExpressions[i].expression; + if (returnExpression) { + var returnType = this.resolveAST(returnExpression, useContextualType, context).type; + + if (returnType.isError()) { + signature.returnType = returnType; + return; + } else { + if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { + this.setSymbolForAST(returnExpression.parent, returnType, context); + } + } + + returnExpressionSymbols.push(returnType); + returnExpressions.push(returnExpression); + } + } + + if (!returnExpressionSymbols.length) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + } else { + var collection = { + getLength: function () { + return returnExpressionSymbols.length; + }, + getTypeAtIndex: function (index) { + return returnExpressionSymbols[index].type; + } + }; + + var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); + var returnType = bestCommonReturnType; + var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + + if (returnType) { + var previousReturnType = returnType; + var newReturnType = returnType.widenedType(this, returnExpression, context); + signature.returnType = newReturnType; + + if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); + } + + if (this.compilationSettings.noImplicitAny()) { + if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { + var functionName = enclosingDecl.name; + if (functionName === "") { + functionName = enclosingDecl.getFunctionExpressionName(); + } + + if (functionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } + + if (!functionSymbol.type && functionSymbol.isAccessor()) { + functionSymbol.type = signature.returnType; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { + var _this = this; + this.setTypeChecked(funcDeclAST, context); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { + var _this = this; + if (constructorDecl.block) { + var foundSuperCall = false; + var pre = function (ast, walker) { + 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; + } + } + }; + + TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); + return foundSuperCall; + } + + return false; + }; + + 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); + }; + + PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { + this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(parameters, false, context); + + this.resolveAST(block, false, context); + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + this.validateVariableDeclarationGroups(funcDecl, context); + + this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); + + if (funcDecl.kind === 16384 /* Function */) { + this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); + } + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + 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); + + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + this.resolveAST(funcDeclAST.parameter, false, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); + var stringIndexSignature = allIndexSignatures.stringSignature; + var numberIndexSignature = allIndexSignatures.numericSignature; + var isNumericIndexer = numberIndexSignature === signature; + + if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { + var comparisonInfo = new TypeComparisonInfo(); + + 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); + } + } + } + + var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); + for (var i = 0; i < allMembers.length; i++) { + var member = allMembers[i]; + var name = member.name; + if (name || (member.kind === 4096 /* Property */ && name === "")) { + if (!allMembers[i].isResolved) { + _this.resolveDeclaredSymbol(allMembers[i], context); + } + + if (parentSymbol !== allMembers[i].getContainer()) { + var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); + var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; + var onlyStringIndexerIsPresent = !numberIndexSignature; + + if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { + var comparisonInfo = new TypeComparisonInfo(); + if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { + _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); + } + } + } + } + } + }); + }; + + PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { + this.checkThisCaptureVariableCollides(funcDeclAST, true, context); + }; + + PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { + var returnTypeSymbol = null; + + if (returnTypeAnnotation) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + } else { + var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } + + return returnTypeSymbol; + }; + + 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); + }; + + PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 131 /* ClassDeclaration */) { + return ast; + } + + ast = ast.parent; + } + + return null; + }; + + PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + return funcSymbol; + } + + if (!signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + 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(); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckConstructorDeclaration(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveIndexSignature(ast.indexSignature, context); + }; + + PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + return funcSymbol; + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (funcDeclAST.typeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (funcDeclAST.parameter) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + this.resolveParameter(funcDeclAST.parameter, context); + context.inTypeCheck = prevInTypeCheck; + } + + if (funcDeclAST.typeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckIndexSignature(funcDeclAST, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcSymbol = funcDecl.getSymbol(); + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; + + if (signature) { + if (signature.isResolved) { + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + return funcSymbol; + } + + if (isConstructor && !signature.inResolution) { + var classAST = this.getEnclosingClassDeclaration(funcDeclAST); + + if (classAST) { + var classDecl = this.semanticInfoChain.getDeclForAST(classAST); + var classSymbol = classDecl.getSymbol(); + + if (!classSymbol.isResolved && !classSymbol.inResolution) { + this.resolveDeclaredSymbol(classSymbol, context); + } + } + } + + var functionTypeSymbol = funcSymbol && funcSymbol.type; + + if (signature.inResolution) { + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + if (!returnTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + + if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); + } + } + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + } + + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + return funcSymbol; + } + + if (funcSymbol) { + funcSymbol.startResolving(); + } + signature.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + if (parameterList) { + var prevInTypeCheck = context.inTypeCheck; + + context.inTypeCheck = false; + + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + + context.inTypeCheck = prevInTypeCheck; + } + + if (returnTypeAnnotation) { + returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { + if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { + 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; + if (funcDeclASTName) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } + } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + + if (!hadError) { + if (funcSymbol) { + funcSymbol.setUnresolved(); + if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { + funcSymbol.type = functionTypeSymbol; + } + } + signature.setResolved(); + } + } + + if (funcSymbol) { + this.resolveOtherDeclarations(funcDeclAST, context); + } + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); + } + + return funcSymbol; + }; + + PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { + if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { + return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); + } + + return null; + }; + + 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.ASTHelpers.getType(parameter), context); + } + + return null; + }; + + PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + + if (accessorSymbol.inResolution) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + accessorSymbol.setResolved(); + + return accessorSymbol; + } + + if (accessorSymbol.isResolved) { + if (!accessorSymbol.type) { + accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else { + var getterSymbol = accessorSymbol.getGetter(); + var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; + var hasGetter = getterSymbol !== null; + + var setterSymbol = accessorSymbol.getSetter(); + var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; + var hasSetter = setterSymbol !== null; + + var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); + var getterHasTypeAnnotation = getterAnnotatedType !== null; + + var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); + var setterHasTypeAnnotation = setterAnnotatedType !== null; + + accessorSymbol.startResolving(); + + if (hasGetter) { + getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); + } + + if (hasSetter) { + setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); + } + + if (hasGetter && hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + var getterSig = getterSymbol.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { + getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; + getterSig.returnType = setterSuppliedTypeSymbol; + } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { + setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; + + if (setterHasParameters) { + setterParameters[0].type = getterSuppliedTypeSymbol; + } + } + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + accessorSymbol.type = this.getNewErrorTypeSymbol(); + } else { + accessorSymbol.type = getterSuppliedTypeSymbol; + } + } else if (hasSetter) { + var setterSig = setterSymbol.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + var setterHasParameters = setterParameters.length > 0; + + accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; + } else { + var getterSig = getterSymbol.type.getCallSignatures()[0]; + accessorSymbol.type = getterSig.returnType; + } + + accessorSymbol.setResolved(); + } + + if (this.canTypeCheckAST(funcDeclAst, context)) { + this.typeCheckAccessorDeclaration(funcDeclAst, context); + } + + return accessorSymbol; + }; + + PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { + this.setTypeChecked(funcDeclAst, context); + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); + var accessorSymbol = functionDeclaration.getSymbol(); + var getterSymbol = accessorSymbol.getGetter(); + var setterSymbol = accessorSymbol.getSetter(); + + var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; + if (isGetter) { + var getterFunctionDeclarationAst = funcDeclAst; + context.pushNewContextualType(getterSymbol.type); + this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); + context.popAnyContextualType(); + } else { + var setterFunctionDeclarationAst = funcDeclAst; + this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); + } + }; + + PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var getterSymbol = accessorSymbol.getGetter(); + var getterTypeSymbol = getterSymbol.type; + + var signature = getterTypeSymbol.getCallSignatures()[0]; + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return getterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + signature.setResolved(); + + return getterSymbol; + } + + signature.startResolving(); + + if (returnTypeAnnotation) { + var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); + + if (!returnTypeSymbol) { + signature.returnType = this.getNewErrorTypeSymbol(); + + hadError = true; + } else { + signature.returnType = returnTypeSymbol; + } + } else { + if (!setterAnnotatedType) { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); + } else { + signature.returnType = setterAnnotatedType; + } + } + + if (!hadError) { + signature.setResolved(); + } + } + + return getterSymbol; + }; + + PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + var getter = accessorSymbol.getGetter(); + var setter = accessorSymbol.getSetter(); + + if (getter && setter) { + var getterAST = getter.getDeclarations()[0].ast(); + var setterAST = setter.getDeclarations()[0].ast(); + + if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { + var setterSig = setter.type.getCallSignatures()[0]; + var setterParameters = setterSig.parameters; + + var getter = accessorSymbol.getGetter(); + var getterSig = getter.type.getCallSignatures()[0]; + + var setterSuppliedTypeSymbol = setterParameters[0].type; + var getterSuppliedTypeSymbol = getterSig.returnType; + + if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); + } + } + } + }; + + PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var enclosingDecl = this.getEnclosingDecl(funcDecl); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + var funcNameAST = funcDeclAST.propertyName; + + if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); + } + + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); + var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + 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.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; + }; + + PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + var setterSymbol = accessorSymbol.getSetter(); + var setterTypeSymbol = setterSymbol.type; + + var signature = funcDecl.getSignatureSymbol(); + + var hadError = false; + + if (signature) { + if (signature.isResolved) { + return setterSymbol; + } + + if (signature.inResolution) { + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + signature.setResolved(); + return setterSymbol; + } + + signature.startResolving(); + + if (parameterList) { + for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); + } + } + + signature.returnType = this.semanticInfoChain.voidTypeSymbol; + + if (!hadError) { + signature.setResolved(); + } + } + + return setterSymbol; + }; + + PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { + var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var accessorSymbol = funcDecl.getSymbol(); + + if (funcDeclAST.parameterList) { + for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { + this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); + } + } + + this.resolveAST(funcDeclAST.block, false, context); + + this.validateVariableDeclarationGroups(funcDecl, context); + + var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; + + var getter = accessorSymbol.getGetter(); + + var funcNameAST = funcDeclAST.propertyName; + + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); + var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); + + if (getterIsPrivate !== setterIsPrivate) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); + } + + this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); + } else { + if (this.compilationSettings.noImplicitAny()) { + var setterFunctionDeclarationAst = funcDeclAST; + 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); + }; + + PullTypeResolver.prototype.resolveList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.childCount(); i < n; i++) { + this.resolveAST(list.childAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { + if (this.canTypeCheckAST(list, context)) { + this.setTypeChecked(list, context); + + for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { + this.resolveAST(list.nonSeparatorAt(i), false, context); + } + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.undefinedTypeSymbol; + }; + + PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLogicalOperation(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { + this.setTypeChecked(binex, context); + + var leftType = this.resolveAST(binex.left, false, context).type; + var rightType = this.resolveAST(binex.right, false, context).type; + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(binex); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ + TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), + leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); + } + }; + + PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.operand, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckUnaryArithmeticOperation(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckPostfixUnaryExpression(ast, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { + return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); + }; + + PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { + return; + } + + TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { + this.setTypeChecked(unaryExpression, context); + + var nodeType = unaryExpression.kind(); + var expression = this.resolveAST(unaryExpression.operand, false, context); + + TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); + + var operandType = expression.type; + if (!this.isAnyOrNumberOrEnum(operandType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!this.isReference(unaryExpression.operand, expression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); + } + }; + + PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { + if (this.canTypeCheckAST(binaryExpression, context)) { + this.typeCheckBinaryArithmeticExpression(binaryExpression, context); + } + + return this.semanticInfoChain.numberTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); + + var lhsType = lhsSymbol.type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { + lhsType = rhsType; + } + + if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { + rhsType = lhsType; + } + + var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); + var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); + + if (!rhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (!lhsIsFit) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); + } + + if (lhsIsFit && rhsIsFit) { + switch (binaryExpression.kind()) { + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + if (!this.isReference(binaryExpression.left, lhsSymbol)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); + } + } + }; + + PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.stringTypeSymbol; + }; + + PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInstanceOfExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); + var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); + 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_of_a_type_assignable_to_the_Function_interface_type)); + } + }; + + PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { + if (this.canTypeCheckAST(commaExpression, context)) { + this.setTypeChecked(commaExpression, context); + + this.resolveAST(commaExpression.left, false, context); + } + + return this.resolveAST(commaExpression.right, false, context).type; + }; + + PullTypeResolver.prototype.resolveInExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckInExpression(ast, context); + } + + return this.semanticInfoChain.booleanTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { + this.setTypeChecked(binaryExpression, context); + + var lhsType = this.resolveAST(binaryExpression.left, false, context).type; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; + + var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); + + if (!isValidLHS) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); + } + + if (!isValidRHS) { + 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)); + } + }; + + PullTypeResolver.prototype.resolveForStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.variableDeclaration, false, context); + this.resolveAST(ast.initializer, false, context); + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.incrementor, false, context); + this.resolveAST(ast.statement, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { + if (this.canTypeCheckAST(forInStatement, context)) { + this.typeCheckForInStatement(forInStatement, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { + this.setTypeChecked(forInStatement, context); + + if (forInStatement.variableDeclaration) { + var declaration = forInStatement.variableDeclaration; + + 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); + + 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 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)); + } + + this.resolveAST(forInStatement.statement, false, context); + }; + + PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWhileStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckDoStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckIfStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.condition, false, context); + this.resolveAST(ast.statement, false, context); + this.resolveAST(ast.elseClause, false, context); + }; + + PullTypeResolver.prototype.resolveElseClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckElseClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.statement, false, context); + }; + + PullTypeResolver.prototype.resolveBlock = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.statements, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declaration, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.declarators, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckWithStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var withStatement = ast; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); + }; + + PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckTryStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { + this.setTypeChecked(ast, context); + var tryStatement = ast; + + this.resolveAST(tryStatement.block, false, context); + this.resolveAST(tryStatement.catchClause, false, context); + this.resolveAST(tryStatement.finallyClause, false, context); + }; + + PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckCatchClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + + var catchDecl = this.semanticInfoChain.getDeclForAST(ast); + this.validateVariableDeclarationGroups(catchDecl, context); + }; + + PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckFinallyClause(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { + this.setTypeChecked(ast, context); + this.resolveAST(ast.block, false, context); + }; + + PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + + while (enclosingDecl) { + if (enclosingDecl.kind & 1032192 /* SomeFunction */) { + return enclosingDecl; + } + + enclosingDecl = enclosingDecl.getParentDecl(); + } + + return null; + }; + + PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var isContextuallyTyped = false; + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); + if (returnTypeAnnotationSymbol) { + isContextuallyTyped = true; + context.pushNewContextualType(returnTypeAnnotationSymbol); + } + } else { + var currentContextualType = context.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + isContextuallyTyped = true; + context.propagateContextualType(currentContextualTypeReturnTypeSymbol); + } + } + } + } + + var result = this.resolveAST(expression, isContextuallyTyped, context).type; + if (isContextuallyTyped) { + context.popAnyContextualType(); + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { + if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { + var classDecl = enclosingFunction.getParentDecl(); + if (classDecl) { + var classSymbol = classDecl.getSymbol(); + this.resolveDeclaredSymbol(classSymbol, context); + + var comparisonInfo = new TypeComparisonInfo(); + var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); + if (!isAssignable) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); + } + } + } + + if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); + } + + if (enclosingFunction) { + var enclosingDeclAST = this.getASTForDecl(enclosingFunction); + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { + var signatureSymbol = enclosingFunction.getSignatureSymbol(); + var sigReturnType = signatureSymbol.returnType; + + if (expressionType && sigReturnType) { + var comparisonInfo = new TypeComparisonInfo(); + var upperBound = null; + + this.resolveDeclaredSymbol(expressionType, context); + this.resolveDeclaredSymbol(sigReturnType, context); + + var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); + } + } + } + } + } + }; + + PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { + var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); + if (enclosingFunction) { + enclosingFunction.setFlag(4194304 /* HasReturnStatement */); + } + + var returnType = this.getSymbolForAST(returnAST, context); + var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); + if (!returnType || canTypeCheckAST) { + var returnExpr = returnAST.expression; + + var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); + + if (!returnType) { + returnType = resolvedReturnType; + this.setSymbolForAST(returnAST, resolvedReturnType, context); + } + + if (returnExpr && canTypeCheckAST) { + this.setTypeChecked(returnExpr, context); + this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); + } + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSwitchStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var expressionType = this.resolveAST(ast.expression, false, context).type; + + for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { + var switchClause = ast.switchClauses.childAt(i); + if (switchClause.kind() === 233 /* CaseSwitchClause */) { + var caseSwitchClause = switchClause; + + var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; + this.resolveAST(caseSwitchClause.statements, false, context); + + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { + var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); + } + } + } else { + var defaultSwitchClause = switchClause; + this.resolveAST(defaultSwitchClause.statements, false, context); + } + } + }; + + PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckLabeledStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + var labelIdentifier = ast.identifier.valueText(); + + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + 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); + }; + + PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { + switch (statement.kind()) { + case 160 /* LabeledStatement */: + return this.labelIsOnContinuableConstruct(statement.statement); + + case 158 /* WhileStatement */: + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 161 /* DoStatement */: + return true; + + default: + return false; + } + }; + + PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckContinueStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.isIterationStatement = function (ast) { + switch (ast.kind()) { + case 154 /* ForStatement */: + case 155 /* ForInStatement */: + case 158 /* WhileStatement */: + case 161 /* DoStatement */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { + switch (ast.kind()) { + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + case 129 /* FunctionDeclaration */: + case 135 /* MemberFunctionDeclaration */: + case 241 /* FunctionPropertyAssignment */: + case 137 /* ConstructorDeclaration */: + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return true; + } + + return false; + }; + + PullTypeResolver.prototype.inSwitchStatement = function (ast) { + while (ast) { + if (ast.kind() === 151 /* SwitchStatement */) { + return true; + } + + if (this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { + while (ast) { + if (this.isIterationStatement(ast)) { + return true; + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { + var result = []; + + ast = ast.parent; + while (ast) { + if (ast.kind() === 160 /* LabeledStatement */) { + var labeledStatement = ast; + if (breakable) { + result.push(labeledStatement); + } else { + if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { + result.push(labeledStatement); + } + } + } + + if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { + break; + } + + ast = ast.parent; + } + + return result; + }; + + PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + 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.any(continuableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var continuableLabels = this.getEnclosingLabels(ast, false, true); + + 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)); + } + } + } + }; + + PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckBreakStatement(ast, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { + this.setTypeChecked(ast, context); + + if (ast.identifier) { + var breakableLabels = this.getEnclosingLabels(ast, true, false); + + if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { + return s.identifier.valueText() === ast.identifier.valueText(); + })) { + var breakableLabels = this.getEnclosingLabels(ast, true, true); + 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, 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)); + } + } + }; + + PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { + if (!ast) { + return; + } + + var symbol = this.getSymbolForAST(ast, context); + if (symbol && symbol.isResolved) { + this.typeCheckAST(ast, isContextuallyTyped, context); + return symbol; + } + + if (ast.isExpression() && !isTypesOnlyLocation(ast)) { + return this.resolveExpressionAST(ast, isContextuallyTyped, context); + } + + var nodeType = ast.kind(); + + switch (nodeType) { + case 124 /* ArrayType */: + case 126 /* GenericType */: + case 122 /* ObjectType */: + case 127 /* TypeQuery */: + case 125 /* ConstructorType */: + case 123 /* FunctionType */: + return this.resolveTypeReference(ast, context); + + case 1 /* List */: + return this.resolveList(ast, context); + + case 2 /* SeparatedList */: + return this.resolveSeparatedList(ast, context); + + case 120 /* SourceUnit */: + return this.resolveSourceUnit(ast, context); + + case 132 /* EnumDeclaration */: + return this.resolveEnumDeclaration(ast, context); + + case 130 /* ModuleDeclaration */: + return this.resolveModuleDeclaration(ast, context); + + case 128 /* InterfaceDeclaration */: + return this.resolveInterfaceDeclaration(ast, context); + + case 131 /* ClassDeclaration */: + return this.resolveClassDeclaration(ast, context); + + case 224 /* VariableDeclaration */: + return this.resolveVariableDeclarationList(ast, context); + + case 136 /* MemberVariableDeclaration */: + return this.resolveMemberVariableDeclaration(ast, context); + + case 225 /* VariableDeclarator */: + return this.resolveVariableDeclarator(ast, context); + + case 141 /* PropertySignature */: + return this.resolvePropertySignature(ast, context); + + case 227 /* ParameterList */: + return this.resolveParameterList(ast, context); + + case 242 /* Parameter */: + return this.resolveParameter(ast, context); + + case 243 /* EnumElement */: + return this.resolveEnumElement(ast, context); + + case 232 /* EqualsValueClause */: + return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); + + case 238 /* TypeParameter */: + return this.resolveTypeParameterDeclaration(ast, context); + + case 239 /* Constraint */: + return this.resolveConstraint(ast, context); + + case 133 /* ImportDeclaration */: + return this.resolveImportDeclaration(ast, context); + + case 240 /* SimplePropertyAssignment */: + return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); + + case 241 /* FunctionPropertyAssignment */: + return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); + + case 11 /* IdentifierName */: + TypeScript.Debug.assert(isTypesOnlyLocation(ast)); + return this.resolveTypeNameExpression(ast, context); + + case 121 /* QualifiedName */: + return this.resolveQualifiedName(ast, context); + + case 137 /* ConstructorDeclaration */: + return this.resolveConstructorDeclaration(ast, context); + + case 139 /* GetAccessor */: + case 140 /* SetAccessor */: + return this.resolveAccessorDeclaration(ast, context); + + case 138 /* IndexMemberDeclaration */: + return this.resolveIndexMemberDeclaration(ast, context); + + case 144 /* IndexSignature */: + return this.resolveIndexSignature(ast, context); + + case 135 /* MemberFunctionDeclaration */: + return this.resolveMemberFunctionDeclaration(ast, context); + + case 142 /* CallSignature */: + return this.resolveCallSignature(ast, context); + + case 143 /* ConstructSignature */: + return this.resolveConstructSignature(ast, context); + + case 145 /* MethodSignature */: + return this.resolveMethodSignature(ast, context); + + 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); + + case 219 /* SimpleArrowFunctionExpression */: + return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 218 /* ParenthesizedArrowFunctionExpression */: + return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + + case 214 /* ArrayLiteralExpression */: + return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + + case 35 /* ThisKeyword */: + return this.resolveThisExpression(ast, context); + + case 50 /* SuperKeyword */: + return this.resolveSuperExpression(ast, context); + + case 213 /* InvocationExpression */: + return this.resolveInvocationExpression(ast, context); + + case 216 /* ObjectCreationExpression */: + return this.resolveObjectCreationExpression(ast, context); + + case 220 /* CastExpression */: + return this.resolveCastExpression(ast, context); + + case 13 /* NumericLiteral */: + return this.semanticInfoChain.numberTypeSymbol; + + case 14 /* StringLiteral */: + return this.semanticInfoChain.stringTypeSymbol; + + case 32 /* NullKeyword */: + return this.semanticInfoChain.nullTypeSymbol; + + case 37 /* TrueKeyword */: + case 24 /* FalseKeyword */: + return this.semanticInfoChain.booleanTypeSymbol; + + case 172 /* VoidExpression */: + return this.resolveVoidExpression(ast, context); + + case 174 /* AssignmentExpression */: + return this.resolveAssignmentExpression(ast, context); + + case 167 /* LogicalNotExpression */: + return this.resolveLogicalNotExpression(ast, context); + + case 193 /* NotEqualsWithTypeConversionExpression */: + case 192 /* EqualsWithTypeConversionExpression */: + case 194 /* EqualsExpression */: + case 195 /* NotEqualsExpression */: + case 196 /* LessThanExpression */: + case 198 /* LessThanOrEqualExpression */: + case 199 /* GreaterThanOrEqualExpression */: + case 197 /* GreaterThanExpression */: + return this.resolveLogicalOperation(ast, context); + + case 208 /* AddExpression */: + case 175 /* AddAssignmentExpression */: + return this.resolveBinaryAdditionOperation(ast, context); + + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + case 166 /* BitwiseNotExpression */: + case 168 /* PreIncrementExpression */: + case 169 /* PreDecrementExpression */: + return this.resolveUnaryArithmeticOperation(ast, context); + + case 210 /* PostIncrementExpression */: + case 211 /* PostDecrementExpression */: + return this.resolvePostfixUnaryExpression(ast, context); + + case 209 /* SubtractExpression */: + case 205 /* MultiplyExpression */: + case 206 /* DivideExpression */: + case 207 /* ModuloExpression */: + case 189 /* BitwiseOrExpression */: + case 191 /* BitwiseAndExpression */: + case 202 /* LeftShiftExpression */: + case 203 /* SignedRightShiftExpression */: + case 204 /* UnsignedRightShiftExpression */: + case 190 /* BitwiseExclusiveOrExpression */: + case 181 /* ExclusiveOrAssignmentExpression */: + case 183 /* LeftShiftAssignmentExpression */: + case 184 /* SignedRightShiftAssignmentExpression */: + case 185 /* UnsignedRightShiftAssignmentExpression */: + case 176 /* SubtractAssignmentExpression */: + case 177 /* MultiplyAssignmentExpression */: + case 178 /* DivideAssignmentExpression */: + case 179 /* ModuloAssignmentExpression */: + case 182 /* OrAssignmentExpression */: + case 180 /* AndAssignmentExpression */: + return this.resolveBinaryArithmeticExpression(ast, context); + + case 221 /* ElementAccessExpression */: + return this.resolveElementAccessExpression(ast, context); + + case 187 /* LogicalOrExpression */: + return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); + + case 188 /* LogicalAndExpression */: + return this.resolveLogicalAndExpression(ast, context); + + case 171 /* TypeOfExpression */: + return this.resolveTypeOfExpression(ast, context); + + case 170 /* DeleteExpression */: + return this.resolveDeleteExpression(ast, context); + + case 186 /* ConditionalExpression */: + return this.resolveConditionalExpression(ast, isContextuallyTyped, context); + + case 12 /* RegularExpressionLiteral */: + return this.resolveRegularExpressionLiteral(); + + case 217 /* ParenthesizedExpression */: + return this.resolveParenthesizedExpression(ast, context); + + case 200 /* InstanceOfExpression */: + return this.resolveInstanceOfExpression(ast, context); + + case 173 /* CommaExpression */: + return this.resolveCommaExpression(ast, context); + + case 201 /* InExpression */: + return this.resolveInExpression(ast, context); + + case 223 /* OmittedExpression */: + return this.semanticInfoChain.undefinedTypeSymbol; + } + + TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); + }; + + PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { + if (!this.canTypeCheckAST(ast, context)) { + return; + } + + var nodeType = ast.kind(); + switch (nodeType) { + case 120 /* SourceUnit */: + this.typeCheckSourceUnit(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.typeCheckEnumDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.typeCheckModuleDeclaration(ast, context); + return; + + case 128 /* InterfaceDeclaration */: + this.typeCheckInterfaceDeclaration(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.typeCheckClassDeclaration(ast, context); + return; + + case 243 /* EnumElement */: + this.typeCheckEnumElement(ast, context); + return; + + case 136 /* MemberVariableDeclaration */: + this.typeCheckMemberVariableDeclaration(ast, context); + return; + + case 225 /* VariableDeclarator */: + this.typeCheckVariableDeclarator(ast, context); + return; + + case 141 /* PropertySignature */: + this.typeCheckPropertySignature(ast, context); + return; + + case 242 /* Parameter */: + this.typeCheckParameter(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.typeCheckImportDeclaration(ast, context); + return; + + case 215 /* ObjectLiteralExpression */: + this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 241 /* FunctionPropertyAssignment */: + this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); + return; + + case 11 /* IdentifierName */: + if (isTypesOnlyLocation(ast)) { + this.resolveTypeNameExpression(ast, context); + } else { + this.resolveNameExpression(ast, context); + } + return; + + case 212 /* MemberAccessExpression */: + this.resolveMemberAccessExpression(ast, context); + return; + + case 121 /* QualifiedName */: + this.resolveQualifiedName(ast, context); + return; + + case 222 /* FunctionExpression */: + 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); + break; + + case 142 /* CallSignature */: + this.typeCheckCallSignature(ast, context); + return; + + case 143 /* ConstructSignature */: + this.typeCheckConstructSignature(ast, context); + return; + + case 129 /* FunctionDeclaration */: { + var funcDecl = ast; + 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, isContextuallyTyped, context); + return; + + case 218 /* ParenthesizedArrowFunctionExpression */: + this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); + return; + + case 214 /* ArrayLiteralExpression */: + this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); + return; + + case 213 /* InvocationExpression */: + this.typeCheckInvocationExpression(ast, context); + return; + + case 216 /* ObjectCreationExpression */: + this.typeCheckObjectCreationExpression(ast, context); + return; + + case 150 /* ReturnStatement */: + this.resolveReturnStatement(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); + } + }; + + PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { + while (this.postTypeCheckWorkitems.length) { + var ast = this.postTypeCheckWorkitems.pop(); + this.postTypeCheck(ast, context); + } + }; + + PullTypeResolver.prototype.postTypeCheck = function (ast, context) { + var nodeType = ast.kind(); + + switch (nodeType) { + case 242 /* Parameter */: + case 225 /* VariableDeclarator */: + this.postTypeCheckVariableDeclaratorOrParameter(ast, context); + return; + + case 131 /* ClassDeclaration */: + this.postTypeCheckClassDeclaration(ast, context); + return; + + case 129 /* FunctionDeclaration */: + this.postTypeCheckFunctionDeclaration(ast, context); + return; + + case 130 /* ModuleDeclaration */: + this.postTypeCheckModuleDeclaration(ast, context); + return; + + case 132 /* EnumDeclaration */: + this.postTypeCheckEnumDeclaration(ast, context); + return; + + case 133 /* ImportDeclaration */: + this.postTypeCheckImportDeclaration(ast, context); + return; + + case 11 /* IdentifierName */: + this.postTypeCheckNameExpression(ast, context); + return; + + default: + TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); + } + }; + + PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { + if (this.cachedRegExpInterfaceType()) { + return this.cachedRegExpInterfaceType(); + } else { + return this.semanticInfoChain.anyTypeSymbol; + } + }; + + PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { + this.checkThisCaptureVariableCollides(nameAST, false, context); + }; + + PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { + this.setTypeChecked(nameAST, context); + this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); + }; + + PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { + var nameSymbol = this.getSymbolForAST(nameAST, context); + var foundCached = nameSymbol !== null; + + if (!foundCached || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.typeCheckNameExpression(nameAST, context); + } + nameSymbol = this.computeNameExpression(nameAST, context); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(nameAST, nameSymbol, context); + } + + return nameSymbol; + }; + + 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.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; + } + + var nameSymbol = null; + var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; + + if (!this.isInEnumDecl(enclosingDecl)) { + searchKind = searchKind & ~(67108864 /* EnumMember */); + } + + var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); + } + + 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) { + 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]; + var nameParentDecl = nameDeclaration.getParentDecl(); + if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { + var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); + var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); + + var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); + + if (currentParameterIndex >= 0) { + var matchingParameter; + if (parameterList) { + for (var i = 0; i <= currentParameterIndex; i++) { + var candidateParameter = parameterList.parameters.nonSeparatorAt(i); + if (candidateParameter && candidateParameter.identifier.valueText() === id) { + matchingParameter = candidateParameter; + break; + } + } + } + + 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); + } + } + } + + var aliasSymbol = null; + + if (nameSymbol.isType() && nameSymbol.isAlias()) { + aliasSymbol = nameSymbol; + if (!this.inTypeQuery(nameAST)) { + aliasSymbol.setIsUsedAsValue(); + } + + this.resolveDeclaredSymbol(nameSymbol, context); + + this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); + this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); + + var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); + + if (exportAssignmentSymbol) { + nameSymbol = exportAssignmentSymbol; + } else { + aliasSymbol = null; + } + } + + if (aliasSymbol) { + this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { + var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); + if (parameterList) { + while (parameter && parameter.parent) { + if (parameter.parent.parent === parameterList) { + return parameterList.parameters.nonSeparatorIndexOf(parameter); + } + + parameter = parameter.parent; + } + } + + return -1; + }; + + PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); + }; + + PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { + var symbol = this.getSymbolForAST(dottedNameAST, context); + var foundCached = symbol !== null; + + if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheckDottedNameAST) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); + } + + this.resolveDeclaredSymbol(symbol, context); + + if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { + this.setSymbolForAST(dottedNameAST, symbol, context); + this.setSymbolForAST(name, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { + var rhsName = name.valueText(); + if (rhsName.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + 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)) { + lhsAlias.setIsUsedAsValue(); + } + lhsType = lhsAlias.getExportAssignedTypeSymbol(); + } + + if (lhsType.isAlias()) { + lhsType = lhsType.getExportAssignedTypeSymbol(); + } + + if (!lhsType) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); + return this.getNewErrorTypeSymbol(); + } + + if (!lhsType.isResolved) { + var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); + + if (potentiallySpecializedType !== lhsType) { + if (!lhs.isType()) { + context.setTypeInContext(lhs, potentiallySpecializedType); + } + + lhsType = potentiallySpecializedType; + } + } + + if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { + var instanceSymbol = lhsType.getInstanceSymbol(); + + if (instanceSymbol) { + lhsType = instanceSymbol.type; + } + } + + var originalLhsTypeForErrorReporting = lhsType; + + lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); + + if (!nameSymbol) { + if (lhsType.kind === 32 /* DynamicModule */) { + var container = lhsType; + var associatedInstance = container.getInstanceSymbol(); + + if (associatedInstance) { + var instanceType = associatedInstance.type; + + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); + } + } else { + var associatedType = lhsType.getAssociatedContainerType(); + + if (associatedType && !associatedType.isClass()) { + nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); + } + } + + 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + } + + if (checkSuperPrivateAndStaticAccess) { + this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); + } + + return nameSymbol; + }; + + PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { + var typeNameSymbol = this.getSymbolForAST(nameAST, context); + + if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { + if (this.canTypeCheckAST(nameAST, context)) { + this.setTypeChecked(nameAST, context); + } + typeNameSymbol = this.computeTypeNameExpression(nameAST, context); + this.setSymbolForAST(nameAST, typeNameSymbol, context); + } + + this.resolveDeclaredSymbol(typeNameSymbol, context); + + return typeNameSymbol; + }; + + PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { + var id = nameAST.valueText(); + if (id.length === 0) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(nameAST); + + var declPath = enclosingDecl.getParentPath(); + + var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); + + var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; + var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; + + var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); + + if (!typeNameSymbol) { + typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); + } + + if (!typeNameSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); + return this.getNewErrorTypeSymbol(id); + } + + var typeNameSymbolAlias = null; + if (typeNameSymbol.isAlias()) { + typeNameSymbolAlias = typeNameSymbol; + this.resolveDeclaredSymbol(typeNameSymbol, context); + + var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); + + this.resolveDeclaredSymbol(aliasedType, context); + } + + if (typeNameSymbol.isTypeParameter()) { + if (this.isInStaticMemberContext(enclosingDecl)) { + var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); + + if (parentDecl.kind === 8 /* Class */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); + return this.getNewErrorTypeSymbol(); + } + } + } + + if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { + typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); + } + + 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; + }; + + PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { + var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; + + if (genericTypeSymbol.isError()) { + return genericTypeSymbol; + } + + if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { + this.resolveDeclaredSymbol(genericTypeSymbol, context); + } + + 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()) { + for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + + if (typeArgs[i].isError()) { + typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; + } + } + } + + 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(); + } + + if (!genericTypeSymbol.isResolved) { + var typeDecls = genericTypeSymbol.getDeclarations(); + var childDecls = null; + + for (var i = 0; i < typeDecls.length; i++) { + childDecls = typeDecls[i].getChildDecls(); + + for (var j = 0; j < childDecls.length; j++) { + childDecls[j].ensureSymbolIsBound(); + } + } + } + + var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); + + var typeConstraint = null; + var upperBound = null; + + typeParameters = specializedSymbol.getTypeParameters(); + + var typeConstraintSubstitutionMap = []; + var typeArg = null; + + var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < typeParameters.length; i++) { + typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; + } + + for (var id in instantiatedSubstitutionMap) { + typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; + } + + for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { + typeArg = typeArgs[iArg]; + typeConstraint = typeParameters[iArg].getConstraint(); + + typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; + + if (typeConstraint) { + if (typeConstraint.isTypeParameter()) { + for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { + if (typeParameters[j] === typeConstraint) { + typeConstraint = typeArgs[j]; + } + } + } else if (typeConstraint.isGeneric()) { + typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); + } + + if (typeArg.isTypeParameter()) { + upperBound = typeArg.getConstraint(); + + if (upperBound) { + typeArg = upperBound; + } + } + + 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)])); + } + } + } + + return specializedSymbol; + }; + + PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { + if (this.inTypeQuery(dottedNameAST)) { + return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; + } + + var symbol = this.getSymbolForAST(dottedNameAST, context); + if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { + var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); + if (canTypeCheck) { + this.setTypeChecked(dottedNameAST, context); + } + + symbol = this.computeQualifiedName(dottedNameAST, context); + this.setSymbolForAST(dottedNameAST, symbol, context); + } + + this.resolveDeclaredSymbol(symbol, context); + + 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) { + return this.semanticInfoChain.anyTypeSymbol; + } + + var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); + var lhs = this.resolveAST(dottedNameAST.left, false, context); + + var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; + + if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { + if (lhs.isAlias()) { + lhs.setIsUsedAsValue(); + } + } + + if (!lhsType) { + return this.getNewErrorTypeSymbol(); + } + + if (this.isAnyOrEquivalent(lhsType)) { + return lhsType; + } + + var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); + var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; + + 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); + } + } + + if (!childTypeSymbol && enclosingDecl) { + var parentDecl = enclosingDecl; + + while (parentDecl) { + if (parentDecl.kind & 164 /* SomeContainer */) { + break; + } + + parentDecl = parentDecl.getParentDecl(); + } + + if (parentDecl) { + var enclosingSymbolType = parentDecl.getSymbol().type; + + if (enclosingSymbolType === lhsType) { + childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); + } + } + } + + if (!childTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); + return this.getNewErrorTypeSymbol(rhsName); + } + + return childTypeSymbol; + }; + + PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { + if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { + return false; + } + + if (returnTypeAnnotation) { + return false; + } + + if (parameters) { + for (var i = 0, n = parameters.length; i < n; i++) { + if (parameters.typeAt(i)) { + return false; + } + } + } + + var contextualFunctionTypeSymbol = context.getContextualType(); + + if (contextualFunctionTypeSymbol) { + this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); + var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); + var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; + if (!exactlyOneCallSignature) { + return false; + } + + var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; + return !callSignatureIsGeneric; + } + + return false; + }; + + PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { + var funcDeclSymbol = null; + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + TypeScript.Debug.assert(functionDecl); + + if (functionDecl && functionDecl.hasSymbol()) { + funcDeclSymbol = functionDecl.getSymbol(); + if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { + return funcDeclSymbol; + } + } + + funcDeclSymbol = functionDecl.getSymbol(); + TypeScript.Debug.assert(funcDeclSymbol); + + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + funcDeclSymbol.startResolving(); + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + var assigningFunctionSignature = null; + if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { + assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; + } + + this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); + + if (returnTypeAnnotation) { + signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); + } else { + if (assigningFunctionSignature) { + var returnType = assigningFunctionSignature.returnType; + + if (returnType) { + context.propagateContextualType(returnType); + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); + context.popAnyContextualType(); + } else { + signature.returnType = this.semanticInfoChain.anyTypeSymbol; + + if (this.compilationSettings.noImplicitAny()) { + var functionExpressionName = functionDecl.getFunctionExpressionName(); + + if (functionExpressionName != "") { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); + } + } + } + } else { + this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); + } + } + + context.setTypeInContext(funcDeclSymbol, funcDeclType); + funcDeclSymbol.setResolved(); + + if (this.canTypeCheckAST(funcDeclAST, context)) { + this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); + } + + return funcDeclSymbol; + }; + + 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { + return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + + var funcDeclSymbol = functionDecl.getSymbol(); + var funcDeclType = funcDeclSymbol.type; + var signature = funcDeclType.getCallSignatures()[0]; + var returnTypeSymbol = signature.returnType; + + if (typeParameters) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); + } + } + + 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.popAnyContextualType(); + + this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); + + this.validateVariableDeclarationGroups(functionDecl, context); + + this.typeCheckCallBacks.push(function (context) { + _this.typeCheckFunctionOverloads(funcDeclAST, context); + }); + }; + + PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { + var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); + var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; + + if (this.canTypeCheckAST(thisExpression, context)) { + this.typeCheckThisExpression(thisExpression, context, enclosingDecl); + } + + return thisTypeSymbol; + }; + + PullTypeResolver.prototype.inTypeArgumentList = function (ast) { + var previous = null; + var current = ast; + + while (current) { + switch (current.kind()) { + case 126 /* GenericType */: + var genericType = current; + if (genericType.typeArgumentList === previous) { + return true; + } + break; + + case 226 /* ArgumentList */: + var argumentList = current; + return argumentList.typeArgumentList === previous; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { + while (ast) { + switch (ast.kind()) { + case 230 /* ExtendsHeritageClause */: + var heritageClause = ast; + + return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inTypeQuery = function (ast) { + while (ast) { + switch (ast.kind()) { + case 127 /* TypeQuery */: + return true; + case 129 /* FunctionDeclaration */: + case 213 /* InvocationExpression */: + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 213 /* InvocationExpression */: + var invocationExpression = current; + if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + break; + + case 137 /* ConstructorDeclaration */: + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + return false; + }; + + PullTypeResolver.prototype.inConstructorParameterList = function (ast) { + var previous = null; + var current = ast; + while (current) { + switch (current.kind()) { + case 142 /* CallSignature */: + var callSignature = current; + if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { + return true; + } + + case 131 /* ClassDeclaration */: + case 130 /* ModuleDeclaration */: + return false; + } + + previous = current; + current = current.parent; + } + + 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 */) { + return true; + } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { + return true; + } + + return false; + }; + + PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { + this.checkForThisCaptureInArrowFunction(thisExpression); + + if (this.inConstructorParameterList(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); + return; + } + + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { + return; + } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + if (currentDecl.getParentDecl() === null) { + return; + } else { + 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)); + } + + return; + } else if (currentDecl.kind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(thisExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); + } + + return; + } + } + }; + + PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var isStaticContext = false; + + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declFlags & 16 /* Static */) { + isStaticContext = true; + } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + return null; + } else if (declKind === 16384 /* Function */) { + return null; + } else if (declKind === 8 /* Class */) { + if (this.inStaticMemberVariableDeclaration(ast)) { + return this.getNewErrorTypeSymbol(); + } else { + var classSymbol = decl.getSymbol(); + if (isStaticContext) { + var constructorSymbol = classSymbol.getConstructorMethod(); + return constructorSymbol.type; + } else { + return classSymbol; + } + } + } + } + } + + return null; + }; + + PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { + while (ast) { + if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { + return true; + } + + ast = ast.parent; + } + + return false; + }; + + PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + var superType = this.semanticInfoChain.anyTypeSymbol; + + var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); + + if (classSymbol) { + this.resolveDeclaredSymbol(classSymbol, context); + + var parents = classSymbol.getExtendedTypes(); + + if (parents.length) { + superType = parents[0]; + } + } + + if (this.canTypeCheckAST(ast, context)) { + this.typeCheckSuperExpression(ast, context, enclosingDecl); + } + + return superType; + }; + + PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { + this.setTypeChecked(ast, context); + + this.checkForThisCaptureInArrowFunction(ast); + + var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; + var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; + TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); + + if (isSuperPropertyAccess) { + for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { + if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { + break; + } else if (currentDecl.kind === 8 /* Class */) { + if (!this.enclosingClassIsDerived(currentDecl)) { + 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 if (this.inStaticMemberVariableDeclaration(ast)) { + break; + } + + 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 { + 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)); + } + } + }; + + PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { + return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); + }; + + PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { + if (this.canTypeCheckAST(expressionAST, context)) { + this.setTypeChecked(expressionAST, context); + } + symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); + this.setSymbolForAST(expressionAST, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { + var boundMemberSymbols = []; + var memberSymbol; + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var id = this.getPropertyAssignmentName(propertyAssignment); + var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); + + var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; + var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); + TypeScript.Debug.assert(decl); + + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + if (!isUsingExistingSymbol) { + memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); + memberSymbol.addDeclaration(decl); + decl.setSymbol(memberSymbol); + } else { + memberSymbol = decl.getSymbol(); + } + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + memberSymbol = decl.getSymbol(); + } else { + TypeScript.Debug.assert(isAccessor); + memberSymbol = decl.getSymbol(); + } + + if (!isUsingExistingSymbol && !isAccessor) { + var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); + if (existingMember) { + pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); + } + + objectLiteralTypeSymbol.addMember(memberSymbol); + } + + boundMemberSymbols.push(memberSymbol); + } + + return boundMemberSymbols; + }; + + PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { + for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { + var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); + + var acceptedContextualType = false; + var assigningSymbol = null; + + var id = this.getPropertyAssignmentName(propertyAssignment); + var memberSymbol = boundMemberSymbols[i]; + var contextualMemberType = null; + + if (objectLiteralContextualType) { + assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); + + if (!assigningSymbol) { + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + assigningSymbol = numericIndexerSignature; + } else if (stringIndexerSignature) { + assigningSymbol = stringIndexerSignature; + } + } + + if (assigningSymbol) { + this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); + + contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; + pullTypeContext.propagateContextualType(contextualMemberType); + + acceptedContextualType = true; + + if (additionalResults) { + additionalResults.membersContextTypeSymbols[i] = contextualMemberType; + } + } + } + + var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; + + if (memberSymbolType) { + if (memberSymbolType.isGeneric()) { + objectLiteralTypeSymbol.setHasGenericMember(); + } + + if (stringIndexerSignature) { + allMemberTypes.push(memberSymbolType); + } + if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { + allNumericMemberTypes.push(memberSymbolType); + } + } + + if (acceptedContextualType) { + pullTypeContext.popAnyContextualType(); + } + + var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; + if (!memberSymbol.isResolved) { + if (isAccessor) { + this.setSymbolForAST(id, memberSymbolType, pullTypeContext); + } else { + pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); + memberSymbol.setResolved(); + + this.setSymbolForAST(id, memberSymbol, pullTypeContext); + } + } + } + }; + + PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { + var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); + TypeScript.Debug.assert(objectLitDecl); + + var typeSymbol = this.getSymbolForAST(objectLitAST, context); + var isUsingExistingSymbol = !!typeSymbol; + + if (!typeSymbol) { + typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); + typeSymbol.addDeclaration(objectLitDecl); + this.setSymbolForAST(objectLitAST, typeSymbol, context); + objectLitDecl.setSymbol(typeSymbol); + } + + var propertyAssignments = objectLitAST.propertyAssignments; + var contextualType = null; + + if (isContextuallyTyped) { + contextualType = context.getContextualType(); + this.resolveDeclaredSymbol(contextualType, context); + } + + var stringIndexerSignature = null; + var numericIndexerSignature = null; + var allMemberTypes = null; + var allNumericMemberTypes = null; + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + + stringIndexerSignature = indexSignatures.stringSignature; + numericIndexerSignature = indexSignatures.numericSignature; + + var inInferentialTyping = context.isInferentiallyTyping(); + if (stringIndexerSignature) { + allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; + } + + if (numericIndexerSignature) { + allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; + } + } + + if (propertyAssignments) { + if (additionalResults) { + additionalResults.membersContextTypeSymbols = []; + } + + var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); + + this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); + + if (!isUsingExistingSymbol) { + this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); + this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); + } + } + + typeSymbol.setResolved(); + return typeSymbol; + }; + + PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { + if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { + return propertyAssignment.propertyName; + } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { + return propertyAssignment.propertyName; + } else { + TypeScript.Debug.assert(false); + } + }; + + PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { + if (contextualIndexSignature) { + var typeCollection = { + getLength: function () { + return indexerTypeCandidates.length; + }, + getTypeAtIndex: function (index) { + return indexerTypeCandidates[index]; + } + }; + var decl = objectLiteralSymbol.getDeclarations()[0]; + 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); + } + } + }; + + PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { + var symbol = this.getSymbolForAST(arrayLit, context); + if (!symbol || this.canTypeCheckAST(arrayLit, context)) { + if (this.canTypeCheckAST(arrayLit, context)) { + this.setTypeChecked(arrayLit, context); + } + symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); + this.setSymbolForAST(arrayLit, symbol, context); + } + + return symbol; + }; + + PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { + var elements = arrayLit.expressions; + var elementType = null; + var elementTypes = []; + var comparisonInfo = new TypeComparisonInfo(); + var contextualElementType = null; + comparisonInfo.onlyCaptureFirstError = true; + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + + this.resolveDeclaredSymbol(contextualType, context); + + if (contextualType) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); + if (indexSignatures.numericSignature) { + contextualElementType = indexSignatures.numericSignature.returnType; + } + } + } + + if (elements) { + if (contextualElementType) { + context.propagateContextualType(contextualElementType); + } + + for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { + elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); + } + + if (contextualElementType) { + context.popAnyContextualType(); + } + } + + if (elementTypes.length) { + elementType = elementTypes[0]; + } + var collection; + + if (contextualElementType && !context.isInferentiallyTyping()) { + if (!elementType) { + elementType = contextualElementType; + } + + collection = { + getLength: function () { + return elements.nonSeparatorCount() + 1; + }, + getTypeAtIndex: function (index) { + return index === 0 ? contextualElementType : elementTypes[index - 1]; + } + }; + } else { + collection = { + getLength: function () { + return elements.nonSeparatorCount(); + }, + getTypeAtIndex: function (index) { + return elementTypes[index]; + } + }; + } + + elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; + + if (!elementType) { + elementType = this.semanticInfoChain.undefinedTypeSymbol; + } + + return this.getArrayType(elementType); + }; + + PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { + var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); + + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); + } + + return symbolAndDiagnostic.symbol; + }; + + PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { + this.setTypeChecked(callEx, context); + context.postDiagnostic(symbolAndDiagnostic.diagnostic); + }; + + PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; + + var targetTypeSymbol = targetSymbol.type; + + targetTypeSymbol = this.getApparentType(targetTypeSymbol); + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + return { symbol: targetTypeSymbol }; + } + + var elementType = targetTypeSymbol.getElementType(); + + var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); + + if (elementType && isNumberIndex) { + return { symbol: elementType }; + } + + 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); + + if (member) { + this.resolveDeclaredSymbol(member, context); + + return { symbol: member.type }; + } + } + + var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); + + var stringSignature = signatures.stringSignature; + var numberSignature = signatures.numericSignature; + + if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { + return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; + } 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 { + symbol: this.getNewErrorTypeSymbol(), + diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) + }; + } + }; + + 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; + var signature = null; + var paramSymbols; + var paramType; + + for (var i = 0; i < signatures.length; i++) { + if (stringSignature && numberSignature) { + break; + } + + signature = signatures[i]; + if (!signature.isResolved) { + this.resolveDeclaredSymbol(signature, context); + } + + paramSymbols = signature.parameters; + + if (paramSymbols.length) { + paramType = paramSymbols[0].type; + + if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { + stringSignature = signature; + continue; + } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { + numberSignature = signature; + continue; + } + } + } + + return { + numericSignature: numberSignature, + stringSignature: stringSignature + }; + }; + + 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; + var rhsType = this.resolveAST(binaryExpression.right, false, context).type; + + if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { + lhsType = this.semanticInfoChain.numberTypeSymbol; + } + + if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { + rhsType = this.semanticInfoChain.numberTypeSymbol; + } + + 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 { + lhsType = rhsType; + } + } else if (isRhsTypeNullOrUndefined) { + rhsType = lhsType; + } + + var exprType = null; + + if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { + exprType = this.semanticInfoChain.stringTypeSymbol; + } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { + exprType = this.semanticInfoChain.numberTypeSymbol; + } + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (exprType) { + if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { + if (!this.isReference(binaryExpression.left, lhsExpression)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } + + this.checkAssignability(binaryExpression.left, exprType, lhsType, context); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); + } + } + + if (!exprType) { + exprType = this.semanticInfoChain.anyTypeSymbol; + } + + return exprType; + }; + + PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { + return this.findBestCommonType({ + getLength: function () { + return 2; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + } + } + }, context); + }; + + PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { + return this.findBestCommonType({ + getLength: function () { + return 3; + }, + getTypeAtIndex: function (index) { + switch (index) { + case 0: + return type1; + case 1: + return type2; + case 2: + return type3; + } + } + }, context); + }; + + PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + } + + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; + var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; + + 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.pushNewContextualType(leftType); + var rightType = this.resolveAST(binex.right, true, context).type; + context.popAnyContextualType(); + + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { + if (this.canTypeCheckAST(binex, context)) { + this.setTypeChecked(binex, context); + + this.resolveAST(binex.left, false, context); + } + + return this.resolveAST(binex.right, false, context).type; + }; + + PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { + if (isContextuallyTyped && !context.isInferentiallyTyping()) { + var contextualType = context.getContextualType(); + return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); + } else { + return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); + } + }; + + PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { + var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; + var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; + + var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); + + var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); + + if (this.canTypeCheckAST(trinex, context)) { + this.setTypeChecked(trinex, context); + this.resolveAST(trinex.condition, false, context); + + if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); + } + } + } + + if (!conditionalTypesAreValid) { + return this.getNewErrorTypeSymbol(); + } + + return expressionType; + }; + + PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { + if (isContextuallyTyped) { + var contextualType = context.getContextualType(); + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { + return true; + } + } else { + if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + } + + return this.resolveAST(ast.expression, false, context); + }; + + PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { + if (this.canTypeCheckAST(ast, context)) { + this.setTypeChecked(ast, context); + + this.resolveAST(ast.expression, false, context); + } + + return this.semanticInfoChain.voidTypeSymbol; + }; + + PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + if (symbol !== this.semanticInfoChain.anyTypeSymbol) { + this.setSymbolForAST(callEx, symbol, context); + } + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckInvocationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + var targetSymbol = this.resolveAST(callEx.expression, false, context); + + if (callEx.argumentList.arguments) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + + var len = callEx.argumentList.arguments.nonSeparatorCount(); + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var targetTypeSymbol = targetSymbol.type; + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); + return this.getNewErrorTypeSymbol(); + } + } + + return this.semanticInfoChain.anyTypeSymbol; + } + + var isSuperCall = false; + + if (callEx.expression.kind() === 50 /* SuperKeyword */) { + isSuperCall = true; + + if (targetTypeSymbol.isClass()) { + targetSymbol = targetTypeSymbol.getConstructorMethod(); + this.resolveDeclaredSymbol(targetSymbol, context); + targetTypeSymbol = targetSymbol.type; + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); + this.resolveAST(callEx.argumentList.arguments, false, context); + + return this.getNewErrorTypeSymbol(); + } + } + + var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); + + 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 explicitTypeArgs = null; + var couldNotFindGenericOverload = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + var triedToInferTypeArgs = false; + + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var beforeResolutionSignatures = signatures; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < signatures.length; i++) { + typeParameters = signatures[i].getTypeParameters(); + couldNotAssignToConstraint = false; + + if (signatures[i].isGeneric() && typeParameters.length) { + if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { + explicitTypeArgs = signatures[i].returnType.getTypeArguments(); + } + + 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, 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; + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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]; + } + } + } + + if (signatures.length && !resolvedSignatures.length) { + couldNotFindGenericOverload = true; + } + + signatures = resolvedSignatures; + + var errorCondition = null; + if (!signatures.length) { + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; + + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + this.resolveAST(callEx.argumentList.arguments, false, context); + + if (!couldNotFindGenericOverload) { + 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); + } + return this.semanticInfoChain.anyTypeSymbol; + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); + } else if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } else { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); + var useBeforeResolutionSignatures = signature == null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!signatures.length) { + return errorCondition; + } + + signature = signatures[0]; + } + + 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 (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; + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + if (useBeforeResolutionSignatures && beforeResolutionSignatures) { + additionalResults.resolvedSignatures = beforeResolutionSignatures; + additionalResults.candidateSignature = beforeResolutionSignatures[0]; + } else { + additionalResults.resolvedSignatures = signatures; + additionalResults.candidateSignature = signature; + } + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + }; + + PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { + var symbol = this.getSymbolForAST(callEx, context); + + if (!symbol || !symbol.isResolved) { + if (!additionalResults) { + additionalResults = new PullAdditionalCallResolutionData(); + } + symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); + if (this.canTypeCheckAST(callEx, context)) { + this.setTypeChecked(callEx, context); + } + this.setSymbolForAST(callEx, symbol, context); + this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); + } else { + if (this.canTypeCheckAST(callEx, context)) { + this.typeCheckObjectCreationExpression(callEx, context); + } + + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (additionalResults && (callResolutionData !== additionalResults)) { + additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; + additionalResults.candidateSignature = callResolutionData.candidateSignature; + additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; + additionalResults.targetSymbol = callResolutionData.targetSymbol; + } + } + + return symbol; + }; + + PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { + this.setTypeChecked(callEx, context); + this.resolveAST(callEx.expression, false, context); + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + if (callEx.argumentList) { + var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); + var len = callEx.argumentList.arguments.nonSeparatorCount(); + + for (var i = 0; i < len; i++) { + var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; + if (contextualType) { + context.pushNewContextualType(contextualType); + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { + context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); + } + }; + + PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { + if (!context.inProvisionalResolution()) { + additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); + } + context.postDiagnostic(diagnostic); + }; + + PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { + var _this = this; + var returnType = null; + + var targetSymbol = this.resolveAST(callEx.expression, false, context); + var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; + + var targetAST = this.getCallTargetErrorSpanAST(callEx); + + var constructSignatures = targetTypeSymbol.getConstructSignatures(); + + var explicitTypeArgs = null; + var usedCallSignaturesInstead = false; + var couldNotAssignToConstraint; + var constraintDiagnostic = null; + var typeArgumentCountDiagnostic = null; + var diagnostics = []; + + if (this.isAnyOrEquivalent(targetTypeSymbol)) { + if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + return targetTypeSymbol; + } + + if (!constructSignatures.length) { + constructSignatures = targetTypeSymbol.getCallSignatures(); + usedCallSignaturesInstead = true; + + if (this.compilationSettings.noImplicitAny()) { + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); + } + } + + if (constructSignatures.length) { + if (callEx.argumentList && callEx.argumentList.typeArgumentList) { + explicitTypeArgs = []; + + if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { + for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { + explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); + } + } + } + + if (targetTypeSymbol.isGeneric()) { + var resolvedSignatures = []; + var inferredOrExplicitTypeArgs; + var specializedSignature; + var typeParameters; + var typeConstraint = null; + var triedToInferTypeArgs; + var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); + + for (var i = 0; i < constructSignatures.length; i++) { + couldNotAssignToConstraint = false; + + if (constructSignatures[i].isGeneric()) { + typeParameters = constructSignatures[i].getTypeParameters(); + + 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, explicitTypeArgs.length]); + continue; + } + } 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 { + inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { + return typeParameter.getDefaultConstraint(_this.semanticInfoChain); + }); + } + + TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); + + 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(constructSignatures[i], typeReplacementMap); + + if (specializedSignature) { + resolvedSignatures[resolvedSignatures.length] = specializedSignature; + } + } else { + if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { + resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; + } + } + } + + constructSignatures = resolvedSignatures; + } + + var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = []; + + if (!constructSignatures.length) { + if (constraintDiagnostic) { + this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); + } else if (typeArgumentCountDiagnostic) { + this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); + } + + return this.getNewErrorTypeSymbol(); + } + + var errorCondition = null; + + if (!signature) { + for (var i = 0; i < diagnostics.length; i++) { + this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); + + errorCondition = this.getNewErrorTypeSymbol(); + + if (!constructSignatures.length) { + return errorCondition; + } + + signature = constructSignatures[0]; + } + + returnType = signature.returnType; + + if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { + if (explicitTypeArgs && explicitTypeArgs.length) { + returnType = this.createInstantiatedType(returnType, explicitTypeArgs); + } else { + returnType = this.instantiateTypeToAny(returnType, context); + } + } + + if (usedCallSignaturesInstead) { + 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(); + } else { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + } + + if (!returnType) { + returnType = signature.returnType; + + if (!returnType) { + returnType = targetTypeSymbol; + } + } + + var actualParametersContextTypeSymbols = []; + if (callEx.argumentList && callEx.argumentList.arguments) { + var len = callEx.argumentList.arguments.nonSeparatorCount(); + var params = signature.parameters; + var contextualType = null; + var signatureDecl = signature.getDeclarations()[0]; + + for (var i = 0; i < len; i++) { + if (params.length) { + if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { + this.resolveDeclaredSymbol(params[i], context); + contextualType = params[i].type; + } else if (signature.hasVarArgs) { + contextualType = params[params.length - 1].type; + if (contextualType.isArrayNamedTypeReference()) { + contextualType = contextualType.getElementType(); + } + } + } + + if (contextualType) { + context.pushNewContextualType(contextualType); + actualParametersContextTypeSymbols[i] = contextualType; + } + + this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); + + if (contextualType) { + context.popAnyContextualType(); + contextualType = null; + } + } + } + + additionalResults.targetSymbol = targetSymbol; + additionalResults.resolvedSignatures = constructSignatures; + additionalResults.candidateSignature = signature; + additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; + + if (errorCondition) { + return errorCondition; + } + + if (!returnType) { + returnType = this.semanticInfoChain.anyTypeSymbol; + } + + return returnType; + } else if (callEx.argumentList) { + this.resolveAST(callEx.argumentList.arguments, false, context); + } + + this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); + + return this.getNewErrorTypeSymbol(); + }; + + PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { + var typeReplacementMap = []; + var inferredTypeArgs; + var specializedSignature; + var typeParameters = signatureAToInstantiate.getTypeParameters(); + var typeConstraint = null; + + var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); + inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); + + var functionTypeA = signatureAToInstantiate.functionType; + var functionTypeB = contextualSignatureB.functionType; + var enclosingTypeParameterMap; + + if (functionTypeA) { + enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + if (functionTypeB) { + enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); + + for (var id in enclosingTypeParameterMap) { + typeReplacementMap[id] = enclosingTypeParameterMap[id]; + } + } + + TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); + + return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); + }; + + PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { + var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; + + if (this.canTypeCheckAST(assertionExpression, context)) { + this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); + } + + return typeAssertionType; + }; + + PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { + this.setTypeChecked(assertionExpression, context); + + context.pushNewContextualType(typeAssertionType); + var exprType = this.resolveAST(assertionExpression.expression, true, context).type; + context.popAnyContextualType(); + + this.resolveDeclaredSymbol(typeAssertionType, context); + this.resolveDeclaredSymbol(exprType, context); + + var comparisonInfo = new TypeComparisonInfo(); + + 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); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { + var leftExpr = this.resolveAST(binaryExpression.left, false, context); + var leftType = leftExpr.type; + + context.pushNewContextualType(leftType); + var rightType = this.resolveAST(binaryExpression.right, true, context).type; + context.popAnyContextualType(); + + rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); + + if (this.canTypeCheckAST(binaryExpression, context)) { + this.setTypeChecked(binaryExpression, context); + + if (!this.isReference(binaryExpression.left, leftExpr)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); + } else { + this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); + } + } + + return rightType; + }; + + PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { + var typeToReturn = type; + if (typeToReturn && typeToReturn.isAlias()) { + typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); + } + + if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { + var instanceTypeSymbol = typeToReturn.getInstanceType(); + + if (!instanceTypeSymbol) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); + typeToReturn = null; + } else { + typeToReturn = instanceTypeSymbol; + } + } + + return typeToReturn; + }; + + PullTypeResolver.prototype.widenType = function (type, ast, context) { + if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { + return this.semanticInfoChain.anyTypeSymbol; + } + + if (type.isArrayNamedTypeReference()) { + 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(); + + for (var i = 0; i < len; i++) { + var candidateType = collection.getTypeAtIndex(i); + if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { + return candidateType; + } + } + + return this.semanticInfoChain.emptyTypeSymbol; + }; + + PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { + for (var i = 0; i < collection.getLength(); i++) { + var otherType = collection.getTypeAtIndex(i); + if (candidateType === otherType) { + continue; + } + + if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { + t1 = this.getSymbolForRelationshipCheck(t1); + t2 = this.getSymbolForRelationshipCheck(t2); + + if (t1 === t2) { + return true; + } + + if (t1 && t2) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); + } + } + + return this.typesAreIdentical(t1, t2, context); + }; + + 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); + + if (t1 === t2) { + return true; + } + + if (!t1 || !t2) { + return false; + } + + if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { + return false; + } + + if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); + } + + if (t1.isPrimitive() || t2.isPrimitive()) { + return false; + } + + if (t1.isError() && t2.isError()) { + return true; + } + + 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(); + var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); + + if (t1ParentDeclaration === t2ParentDeclaration) { + return this.symbolsShareDeclaration(t1, t2); + } else { + return false; + } + } + + if (t1.isPrimitive() !== t2.isPrimitive()) { + return 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) { + return false; + } + + var t1MemberSymbol = null; + var t2MemberSymbol = null; + + var t1MemberType = null; + var t2MemberType = null; + + for (var iMember = 0; iMember < t1Members.length; iMember++) { + t1MemberSymbol = t1Members[iMember]; + t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); + + if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { + return false; + } + } + } else if (t1.hasMembers() || t2.hasMembers()) { + return false; + } + + var t1CallSigs = t1.getCallSignatures(); + var t2CallSigs = t2.getCallSignatures(); + + var t1ConstructSigs = t1.getConstructSignatures(); + var t2ConstructSigs = t2.getConstructSignatures(); + + var t1IndexSigs = t1.getIndexSignatures(); + var t2IndexSigs = t2.getIndexSignatures(); + + if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { + return false; + } + + if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { + return false; + } + + return true; + }; + + 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; + } + + if (!sg1 || !sg2) { + return false; + } + + if (sg1.length !== sg2.length) { + return false; + } + + 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; + } + } + + return true; + }; + + 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; + } + + if (tp1 && tp2 && (tp1.length !== tp2.length)) { + return false; + } + + 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) { + var decls1 = symbol1.getDeclarations(); + var decls2 = symbol2.getDeclarations(); + + if (decls1.length && decls2.length) { + return decls1[0] === decls2[0]; + } + + return false; + }; + + PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { + if (source.isFunctionType()) { + return true; + } + + return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); + }; + + 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.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) { + if (symbol && symbol.isTypeReference()) { + return symbol.getReferencedTypeSymbol(); + } + + return symbol; + }; + + PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + source = this.getSymbolForRelationshipCheck(source); + target = this.getSymbolForRelationshipCheck(target); + + if (source === target) { + return true; + } + + if (source && target) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + } + } + + 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); + + if (source === target) { + return true; + } + + if (!(source && target)) { + return true; + } + + var sourceApparentType = this.getApparentType(source); + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { + return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); + } + + if (assignableTo) { + if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { + return true; + } + } else { + if (this.isAnyOrEquivalent(target)) { + return true; + } + } + + if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { + return true; + } + + if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { + return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); + } + + if (source === this.semanticInfoChain.undefinedTypeSymbol) { + return true; + } + + 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) { + return true; + } + + return false; + } else if (source === this.semanticInfoChain.voidTypeSymbol) { + if (target === this.semanticInfoChain.anyTypeSymbol) { + return true; + } + + return false; + } + + if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { + return true; + } + + if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { + return assignableTo; + } + + if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { + return this.symbolsShareDeclaration(target, source); + } + + if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { + return false; + } + + if (source.getIsSpecialized() && target.getIsSpecialized()) { + 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, true); + + for (var i = 0; i < sourceTypeArguments.length; i++) { + if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { + break; + } + } + + if (i === sourceTypeArguments.length) { + return true; + } else { + comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); + } + } + } + } + + if (target.isTypeParameter()) { + if (source.isTypeParameter()) { + if (!source.getConstraint()) { + return this.typesAreIdentical(target, source, context); + } else { + return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); + } + } else { + if (isComparingInstantiatedSignatures) { + target = target.getBaseConstraint(this.semanticInfoChain); + } else { + return this.typesAreIdentical(target, sourceApparentType, context); + } + } + } + + 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; + }; + + PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); + + for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { + var targetProp = targetProps[itargetProp]; + + var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); + + this.resolveDeclaredSymbol(targetProp, context); + + var targetPropType = targetProp.type; + + 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var widenedTargetType = targetType.widenedType(this, null, context); + var widenedSourceType = sourceType.widenedType(this, null, context); + + if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + + 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); + } + return false; + } + + var comparisonInfoTypeArgumentsCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); + } + 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_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_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, isRelatable); + return isRelatable; + }; + + 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)) { + var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); + var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); + if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); + return false; + } + + var sourceTypeArguments = sourceType.getTypeArguments(); + var targetTypeArguments = targetType.getTypeArguments(); + + if (!sourceTypeArguments && !targetTypeArguments) { + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + } + + 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++) { + 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; + } + } + } + + this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); + return true; + }; + + 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 (comparisonInfo) { + var names = getNames(true); + var code; + if (targetPropIsPrivate) { + 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 { + 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; + } else if (sourcePropIsPrivate && targetPropIsPrivate) { + var targetDecl = targetProp.getDeclarations()[0]; + var sourceDecl = sourceProp.getDeclarations()[0]; + + if (targetDecl !== sourceDecl) { + if (comparisonInfo) { + var names = getNames(true); + + comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; + 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; + } + } + + if (sourceProp.isOptional && !targetProp.isOptional) { + if (comparisonInfo) { + 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); + } + return false; + } + + this.resolveDeclaredSymbol(sourceProp, context); + + var sourcePropType = sourceProp.type; + var targetPropType = targetProp.type; + + var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); + if (isRelatableInfo) { + return isRelatableInfo.isRelatable; + } + + var comparisonInfoPropertyTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + context.walkMemberTypes(targetProp.name); + var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); + context.postWalkMemberTypes(); + + if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; + var message; + var names = getNames(false); + if (comparisonInfoPropertyTypeCheck && 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 { + 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 isSourcePropertyRelatableToTargetProperty; + }; + + PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetCallSigs = target.getCallSignatures(); + + if (targetCallSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceCallSigs = source.getCallSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (sourceCallSigs.length && targetCallSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetConstructSigs = target.getConstructSignatures(); + if (targetConstructSigs.length) { + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + var sourceConstructSigs = source.getConstructSignatures(); + if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { + if (comparisonInfo) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + var message; + if (sourceConstructSigs.length && targetConstructSigs.length) { + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + } else { + var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); + var targetStringSig = targetIndexSigs.stringSignature; + var targetNumberSig = targetIndexSigs.numericSignature; + + if (targetStringSig || targetNumberSig) { + var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); + var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); + var sourceStringSig = sourceIndexSigs.stringSignature; + var sourceNumberSig = sourceIndexSigs.numericSignature; + + var comparable = true; + var comparisonInfoSignatuesTypeCheck = null; + if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { + comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); + } + + if (targetStringSig) { + if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (comparable && targetNumberSig) { + if (sourceNumberSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else if (sourceStringSig) { + context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); + comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); + context.postWalkIndexSignatureReturnTypes(); + } else { + comparable = false; + } + } + + if (!comparable) { + if (comparisonInfo) { + var message; + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); + } else { + message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); + } + comparisonInfo.flags |= 4 /* IncompatibleSignatures */; + comparisonInfo.addMessage(message); + } + return false; + } + } + + return true; + }; + + PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { + if (sourceSG === targetSG) { + return true; + } + + if (!(sourceSG.length && targetSG.length)) { + return false; + } + + 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++) { + var mSig = targetSG[iMSig]; + + if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { + continue; + } + + for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { + var nSig = sourceSG[iNSig]; + + if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { + continue; + } + + 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; + } + } + + if (foundMatch) { + foundMatch = false; + continue; + } + + if (comparisonInfo && sigsCompared == 1) { + comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; + } + + return false; + } + + return true; + }; + + 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; + + if (!sourceParameters || !targetParameters) { + return false; + } + + var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; + var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; + + 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, [targetParameters.length])); + } + return false; + } + + if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { + return true; + } + + 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) { + context.walkReturnTypes(); + var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); + context.postWalkReturnTypes(); + if (!returnTypesAreRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; + } + + return false; + } + } + + 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 (!areParametersRelatable) { + if (comparisonInfo) { + comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; + } + } + + return areParametersRelatable; + }); + }; + + PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { + var _this = this; + var hasOverloads = group.length > 1; + var comparisonInfo = new TypeComparisonInfo(); + var args = application.argumentList ? application.argumentList.arguments : null; + + var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { + if (hasOverloads && signature.isDefinition()) { + return false; + } + + var rootSignature = signature.getRootSymbol(); + if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { + return false; + } + + return _this.overloadHasCorrectArity(signature, args); + }); + + var firstAssignableButNotSupertypeSignature = null; + var firstAssignableWithProvisionalErrorsSignature = null; + + for (var i = 0; i < initialCandidates.length; i++) { + var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); + if (applicability === 3 /* Subtype */) { + return initialCandidates[i]; + } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { + firstAssignableButNotSupertypeSignature = initialCandidates[i]; + } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { + firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; + } + } + + if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { + return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; + } else { + var target = this.getCallTargetErrorSpanAST(application); + if (comparisonInfo.message) { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); + } else { + diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); + } + } + + return null; + }; + + PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { + return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; + }; + + PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { + if (args == null) { + return signature.nonOptionalParamCount === 0; + } + + var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); + if (numberOfArgs < signature.nonOptionalParamCount) { + return false; + } + if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { + if (args === null) { + return 3 /* Subtype */; + } + + var isInVarArg = false; + var parameters = signature.parameters; + var paramType = null; + + var overloadApplicability = 3 /* Subtype */; + + for (var i = 0; i < args.nonSeparatorCount(); i++) { + if (!isInVarArg) { + this.resolveDeclaredSymbol(parameters[i], context); + + if (parameters[i].isVarArg) { + paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); + isInVarArg = true; + } else { + paramType = parameters[i].type; + } + } + + var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); + + if (statusOfCurrentArgument === 0 /* NotAssignable */) { + return 0 /* NotAssignable */; + } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { + overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; + } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { + overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; + } + } + + return overloadApplicability; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType.isAny()) { + return 3 /* Subtype */; + } else if (paramType.isError()) { + return 1 /* AssignableButWithProvisionalErrors */; + } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrowFunction = arg; + 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.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.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 */) { + return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); + } else { + return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); + } + }; + + PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { + if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + 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.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveObjectLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + if (paramType === this.cachedArrayInterfaceType()) { + return 2 /* AssignableWithNoProvisionalErrors */; + } + + context.pushProvisionalType(paramType); + var argSym = this.resolveArrayLiteralExpression(arg, true, context); + + var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + + context.popAnyContextualType(); + + return applicabilityStatus; + }; + + PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { + var argSym = this.resolveAST(arg, false, context); + + if (argSym.type.isAlias()) { + var aliasSym = argSym.type; + argSym = aliasSym.getExportAssignedTypeSymbol(); + } + + comparisonInfo.stringConstantVal = arg; + return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); + }; + + PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { + var tempComparisonInfo = new TypeComparisonInfo(); + tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; + if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { + return 3 /* Subtype */; + } + + if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { + return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; + } + + if (!comparisonInfo.message) { + var enclosingSymbol = this.getEnclosingSymbolForAST(arg); + comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); + } + + return 0 /* NotAssignable */; + }; + + PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { + var inferenceResultTypes = argContext.inferTypeArguments(); + var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); + TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); + + 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 (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 inferenceResultTypes; + }; + + PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { + var enclosingDecl = this.getEnclosingDeclForAST(args); + var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); + return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; + }; + + PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { + if (expressionType && parameterType) { + if (context.oneOfClassificationsIsInfinitelyExpanding()) { + this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); + return; + } + } + this.relateTypeToTypeParameters(expressionType, parameterType, 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; + } + + if (expressionType.isError()) { + expressionType = this.semanticInfoChain.anyTypeSymbol; + } + + if (parameterType.isTypeParameter()) { + var typeParameter = parameterType; + argContext.addCandidateForInference(typeParameter, expressionType); + return; + } + + if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { + return; + } + + 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.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) { + return; + } + + var expressionTypeTypeArguments = expressionType.getTypeArguments(); + var parameterTypeArguments = parameterType.getTypeArguments(); + + if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { + for (var i = 0; i < expressionTypeTypeArguments.length; i++) { + this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); + } + } + }; + + PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { + var _this = this; + var expressionReturnType = expressionSignature.returnType; + var parameterReturnType = parameterSignature.returnType; + + parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { + context.walkParameterTypes(i); + _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); + context.postWalkParameterTypes(); + return true; + }); + + context.walkReturnTypes(); + this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); + context.postWalkReturnTypes(); + }; + + PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { + var parameterTypeMembers = parameterType.getMembers(); + var parameterSignatures; + + var objectMember; + var objectSignatures; + + if (argContext.alreadyRelatingTypes(objectType, parameterType)) { + return; + } + + for (var i = 0; i < parameterTypeMembers.length; i++) { + objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); + if (objectMember) { + this.resolveDeclaredSymbol(objectMember); + this.resolveDeclaredSymbol(parameterTypeMembers[i]); + context.walkMemberTypes(parameterTypeMembers[i].name); + this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); + context.postWalkMemberTypes(); + } + } + + this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); + + this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; + } + + 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) { + var typeParameters = typeToSpecialize.getTypeParameters(); + + if (!typeParameters.length) { + return typeToSpecialize; + } + + var typeArguments = null; + + 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) { + typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; + } else { + typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; + } + } + + var type = this.createInstantiatedType(typeToSpecialize, typeArguments); + + 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(); + + var resolver = semanticInfoChain.getResolver(); + var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); + + if (resolver.canTypeCheckAST(sourceUnit, context)) { + resolver.resolveAST(sourceUnit, false, context); + resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); + + while (resolver.typeCheckCallBacks.length) { + var callBack = resolver.typeCheckCallBacks.pop(); + callBack(context); + } + + resolver.processPostTypeCheckWorkItems(context); + } + }; + + PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { + var _this = this; + this.scanVariableDeclarationGroups(enclosingDecl, function (_) { + }, function (subsequentDecl, firstSymbol) { + if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { + return; + } + + var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); + + var symbol = subsequentDecl.getSymbol(); + var symbolType = symbol.type; + var firstSymbolType = firstSymbol.type; + + 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) { + if (!signature) { + var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); + signature = functionSignatureInfo.signature; + allSignatures = functionSignatureInfo.allSignatures; + } + var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); + var funcSymbol = functionDeclaration.getSymbol(); + + var definitionSignature = null; + for (var i = allSignatures.length - 1; i >= 0; i--) { + if (allSignatures[i].isDefinition()) { + definitionSignature = allSignatures[i]; + break; + } + } + + if (!signature.isDefinition()) { + var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i] === signature) { + break; + } + + 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)); + } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); + } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); + } + + break; + } + } + } + + var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); + if (isConstantOverloadSignature) { + if (signature.isDefinition()) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); + } else { + var foundSubtypeSignature = false; + for (var i = 0; i < allSignatures.length; i++) { + if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { + continue; + } + + if (!allSignatures[i].isResolved) { + this.resolveDeclaredSymbol(allSignatures[i], context); + } + + if (allSignatures[i].isStringConstantOverloadSignature()) { + continue; + } + + 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_assignable_to_any_non_specialized_signature)); + } + } + } else if (definitionSignature && definitionSignature !== signature) { + var comparisonInfo = new TypeComparisonInfo(); + + if (!definitionSignature.isResolved) { + this.resolveDeclaredSymbol(definitionSignature, context); + } + + if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); + } + } + } + + var signatureForVisibilityCheck = definitionSignature; + if (!definitionSignature) { + if (allSignatures[0] === signature) { + return; + } + signatureForVisibilityCheck = allSignatures[0]; + } + + if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { + var errorCode; + + 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; + } 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 */)) { + errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; + } + + if (errorCode) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); + } + } + }; + + PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { + if (!symbol || symbol.kind === 2 /* Primitive */) { + return; + } + + if (symbol.isType()) { + var typeSymbol = symbol; + var isNamedType = typeSymbol.isNamedTypeSymbol(); + + if (typeSymbol.isArrayNamedTypeReference()) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); + return; + } + + if (!isNamedType) { + var typeOfSymbol = typeSymbol.getTypeOfSymbol(); + if (typeOfSymbol) { + this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); + return; + } + } + + if (typeSymbol.inSymbolPrivacyCheck) { + return; + } + + typeSymbol.inSymbolPrivacyCheck = true; + + var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); + if (typars) { + for (var i = 0; i < typars.length; i++) { + this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); + } + } + + if (!isNamedType) { + var members = typeSymbol.getMembers(); + for (var i = 0; i < members.length; i++) { + this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); + } + + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); + this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); + } else if (typeSymbol.kind === 8192 /* TypeParameter */) { + this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); + } + + typeSymbol.inSymbolPrivacyCheck = false; + + if (!isNamedType) { + return; + } + } + + if (declSymbol.isExternallyVisible()) { + var symbolIsVisible = symbol.isExternallyVisible(); + + 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]) { + 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(); + break; + } + } + symbol = symbolPath[symbolPath.length - 1]; + } + } else if (symbol.kind === 128 /* TypeAlias */) { + var aliasSymbol = symbol; + symbolIsVisible = true; + aliasSymbol.setTypeUsedExternally(); + } + + if (!symbolIsVisible) { + privacyErrorReporter(symbol); + } + } + }; + + PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (signatures.length > 1 && signature.isDefinition()) { + continue; + } + + var typeParams = signature.getTypeParameters(); + for (var j = 0; j < typeParams.length; j++) { + this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); + } + + var params = signature.parameters; + for (var j = 0; j < params.length; j++) { + var paramType = params[j].type; + this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); + } + + var returnType = signature.returnType; + this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); + } + }; + + 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; + var messageCode; + + var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; + } + } + + var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + var messageCode; + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; + } + } else { + if (classOrInterface.kind() === 131 /* ClassDeclaration */) { + if (isExtendedType) { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; + } else { + messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { + var typeSymbol = symbol; + var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isProperty = declSymbol.kind === 4096 /* Property */; + var isPropertyOfClass = false; + var declParent = declSymbol.getContainer(); + if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { + isPropertyOfClass = true; + } + + var messageCode; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; + } + } else { + if (declSymbol.anyDeclHasFlag(16 /* Static */)) { + messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; + } else if (isProperty) { + if (isPropertyOfClass) { + messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; + } + } + + var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + }; + + PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { + var _this = this; + if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { + return; + } + + var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); + var functionSymbol = functionDecl.getSymbol(); + ; + var functionSignature; + + var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; + var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; + var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; + + if (isGetter || isSetter) { + var accessorSymbol = functionSymbol; + functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; + } else { + if (!functionSymbol) { + var parentDecl = functionDecl.getParentDecl(); + functionSymbol = parentDecl.getSymbol(); + if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { + return; + } + } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { + return; + } + functionSignature = functionDecl.getSignatureSymbol(); + } + + if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { + for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { + var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); + var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); + this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { + return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); + }); + } + } + + if (!isGetter && !isIndexSignature) { + var funcParams = functionSignature.parameters; + for (var i = 0; i < funcParams.length; i++) { + this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { + return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); + }); + } + } + + if (!isSetter) { + this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { + return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); + }); + } + }; + + PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else { + messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); + var messageCode; + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; + } + } else if (!isGetter) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; + } + } else { + if (declAST.kind() === 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; + } else if (isSetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; + } else { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; + } + } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; + } + } + + if (messageCode) { + var parameter = parameters.astAt(argIndex); + + var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); + } + }; + + PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { + var _this = this; + var decl = this.semanticInfoChain.getDeclForAST(declAST); + var enclosingDecl = this.getEnclosingDecl(decl); + + var isGetter = declAST.kind() === 139 /* GetAccessor */; + var isSetter = declAST.kind() === 140 /* SetAccessor */; + var isMethod = decl.kind === 65536 /* Method */; + var isMethodOfClass = false; + var declParent = decl.getParentDecl(); + if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { + isMethodOfClass = true; + } + + var messageCode = null; + var typeSymbol = symbol; + var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); + if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { + if (!TypeScript.isQuoted(typeSymbolName)) { + typeSymbolName = "'" + typeSymbolName + "'"; + } + + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; + } + } else { + if (isGetter) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; + } + } else if (decl.kind === 2097152 /* ConstructSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 1048576 /* CallSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (decl.kind === 4194304 /* IndexSignature */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; + } else if (isMethod) { + if (isStatic) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; + } else if (isMethodOfClass) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; + } else { + messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; + } + } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { + messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; + } + } + + if (messageCode) { + var messageArguments = [typeSymbolName]; + var reportOnFuncDecl = false; + + if (returnTypeAnnotation) { + var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); + } + } + + if (block) { + var reportErrorOnReturnExpressions = function (ast, walker) { + var go = true; + switch (ast.kind()) { + case 129 /* FunctionDeclaration */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + case 222 /* FunctionExpression */: + go = false; + break; + + case 150 /* ReturnStatement */: + var returnStatement = ast; + var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; + + if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { + context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); + } else { + reportOnFuncDecl = true; + } + go = false; + break; + + default: + break; + } + + walker.options.goChildren = go; + return ast; + }; + + TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); + } + + if (reportOnFuncDecl) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); + } + } + }; + + PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { + TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); + + var classSymbol = classDecl.getSymbol(); + return classSymbol.getExtendedTypes().length > 0; + }; + + PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { + if (ast.kind() === 213 /* InvocationExpression */) { + var invocationExpression = ast; + if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { + if (node && node.kind() === 149 /* ExpressionStatement */) { + var expressionStatement = node; + if (this.isSuperInvocationExpression(expressionStatement.expression)) { + return true; + } + } + return false; + }; + + PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { + if (block && block.statements && block.statements.childCount() > 0) { + return block.statements.childAt(0); + } + + return null; + }; + + PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { + TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); + + if (constructorDecl) { + var enclosingClass = constructorDecl.getParentDecl(); + + var classSymbol = enclosingClass.getSymbol(); + if (classSymbol.getExtendedTypes().length === 0) { + return false; + } + + var classMembers = classSymbol.getMembers(); + for (var i = 0, n1 = classMembers.length; i < n1; i++) { + var member = classMembers[i]; + + if (member.kind === 4096 /* Property */) { + var declarations = member.getDeclarations(); + for (var j = 0, n2 = declarations.length; j < n2; j++) { + var declaration = declarations[j]; + var ast = this.semanticInfoChain.getASTForDecl(declaration); + if (ast.kind() === 242 /* Parameter */) { + return true; + } + + if (ast.kind() === 136 /* MemberVariableDeclaration */) { + var variableDeclarator = ast; + if (variableDeclarator.variableDeclarator.equalsValueClause) { + return true; + } + } + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { + var enclosingDecl = this.getEnclosingDeclForAST(expression); + + var declPath = enclosingDecl.getParentPath(); + + if (declPath.length) { + var inArrowFunction = false; + for (var i = declPath.length - 1; i >= 0; i--) { + var decl = declPath[i]; + var declKind = decl.kind; + var declFlags = decl.flags; + + if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { + inArrowFunction = true; + continue; + } + + if (inArrowFunction) { + if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { + decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); + + if (declKind === 8 /* Class */) { + var constructorSymbol = decl.getSymbol().getConstructorMethod(); + var constructorDecls = constructorSymbol.getDeclarations(); + for (var i = 0; i < constructorDecls.length; i++) { + constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; + } + } + break; + } + } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { + break; + } + } + } + }; + + PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { + var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); + var stringSignature = indexSignatures.stringSignature; + var numberSignature = indexSignatures.numericSignature; + + if (stringSignature || numberSignature) { + var members = containerTypeDecl.getChildDecls(); + for (var i = 0; i < members.length; i++) { + var member = members[i]; + if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { + var memberSymbol = member.getSymbol(); + var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); + if (relevantSignature) { + var comparisonInfo = new TypeComparisonInfo(); + if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { + this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); + } + } + } + } + } + }; + + PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { + if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { + return numberIndexSignature; + } else if (stringIndexSignature) { + return stringIndexSignature; + } + + return null; + }; + + PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { + 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { + if (!typeSymbol.isClass()) { + return true; + } + + var typeMemberKind = typeMember.kind; + var extendedMemberKind = extendedTypeMember.kind; + + if (typeMemberKind === extendedMemberKind) { + return true; + } + + var errorCode; + if (typeMemberKind === 4096 /* Property */) { + if (typeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + } else if (typeMemberKind === 65536 /* Method */) { + if (extendedTypeMember.isAccessor()) { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } else { + errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + + var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); + comparisonInfo.addMessage(message); + return false; + }; + + PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { + var typeMembers = typeSymbol.getMembers(); + + var comparisonInfo = new TypeComparisonInfo(); + var foundError = false; + var foundError1 = false; + var foundError2 = false; + + for (var i = 0; i < typeMembers.length; i++) { + var propName = typeMembers[i].name; + var extendedTypeProp = extendedType.findMember(propName, true); + if (extendedTypeProp) { + this.resolveDeclaredSymbol(extendedTypeProp, context); + foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); + + if (!foundError1) { + foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); + } + + if (foundError1 || foundError2) { + foundError = true; + break; + } + } + } + + if (!foundError && typeSymbol.hasOwnCallSignatures()) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnConstructSignatures()) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.hasOwnIndexSignatures()) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); + } + + if (!foundError && typeSymbol.isClass()) { + var typeConstructorType = typeSymbol.getConstructorMethod().type; + var typeConstructorTypeMembers = typeConstructorType.getMembers(); + if (typeConstructorTypeMembers.length) { + var extendedConstructorType = extendedType.getConstructorMethod().type; + var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); + + for (var i = 0; i < typeConstructorTypeMembers.length; i++) { + var propName = typeConstructorTypeMembers[i].name; + var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); + if (extendedConstructorTypeProp) { + if (!extendedConstructorTypeProp.isResolved) { + this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); + } + + if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { + foundError = true; + break; + } + } + } + } + } + + if (foundError) { + var errorCode; + if (typeSymbol.isClass()) { + errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; + } else { + if (extendedType.isClass()) { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; + } else { + errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; + } + } + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { + var comparisonInfo = new TypeComparisonInfo(); + var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + if (!foundError) { + foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); + } + } + } + + if (foundError) { + var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); + } + }; + + PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { + var prevInTypeCheck = context.inTypeCheck; + context.inTypeCheck = false; + + var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); + + 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; + } + + if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { + return true; + } + + var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; + + if (associatedContainerType) { + return associatedContainerType !== typeSymbol.getRootSymbol(); + } + + return true; + }; + + PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { + var _this = this; + var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); + + var baseType = this.resolveTypeReference(baseDeclAST, context).type; + + if (!baseType) { + return; + } + + var typeDeclIsClass = typeSymbol.isClass(); + + if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { + if (!baseType.isError()) { + if (isExtendedType) { + if (typeDeclIsClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); + } + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); + } + } + return; + } else if (typeDeclIsClass && isExtendedType) { + if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { + 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)])); + } + } + + if (baseType.hasBase(typeSymbol)) { + typeSymbol.setHasBaseTypeConflict(); + baseType.setHasBaseTypeConflict(); + + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); + return; + } + + if (isExtendedType) { + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); + }); + } else { + TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); + + this.typeCheckCallBacks.push(function (context) { + return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); + }); + } + + this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { + return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); + }); + }; + + PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { + var _this = this; + var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); + var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); + if (!extendsClause && !implementsClause) { + return; + } + + if (extendsClause) { + for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); + } + } + + if (typeSymbol.isClass()) { + if (implementsClause) { + for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { + this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); + } + } + } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { + var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { + return decl.ast().heritageClauses !== null; + }).ast(); + if (classOrInterface === firstInterfaceASTWithExtendsClause) { + this.typeCheckCallBacks.push(function (context) { + _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); + }); + } + } + }; + + PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { + var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); + + var inheritedMembersMap = TypeScript.createIntrinsicsObject(); + var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); + + var typeHasOwnNumberIndexer = false; + var typeHasOwnStringIndexer = false; + + if (typeSymbol.hasOwnIndexSignatures()) { + var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); + for (var i = 0; i < ownIndexSignatures.length; i++) { + if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { + typeHasOwnNumberIndexer = true; + } else { + typeHasOwnStringIndexer = true; + } + } + } + var baseTypes = typeSymbol.getExtendedTypes(); + for (var i = 0; i < baseTypes.length; i++) { + if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { + return; + } + } + + if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { + return; + } + + this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; + var memberName = member.name; + + if (interfaceSymbol.findMember(memberName, false)) { + continue; + } + + this.resolveDeclaredSymbol(member, context); + + if (inheritedMembersMap[memberName]) { + var prevMember = inheritedMembersMap[memberName]; + 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; + } + } else { + inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); + } + } + + return false; + }; + + PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { + if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { + return false; + } + + var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); + for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { + var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; + + var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; + 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, 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; + } + } else { + allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } else if (parameterTypeIsNumber) { + if (allInheritedSignatures.numberSignatureWithBaseOrigin) { + 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; + } + } else { + allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); + } + } + } + + return false; + }; + + PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { + if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; + var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; + for (var memberName in inheritedMembers) { + var memberWithBaseOrigin = inheritedMembers[memberName]; + if (!memberWithBaseOrigin) { + continue; + } + + var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); + if (!relevantSignature) { + continue; + } + + var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; + var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; + + if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { + continue; + } + + 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_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_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])); + } + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { + if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { + return false; + } + + var comparisonInfo = new TypeComparisonInfo(); + 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_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, [ + interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), + inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { + var comparisonInfo = new TypeComparisonInfo(); + + var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); + + if (!isAssignable) { + var enclosingSymbol = this.getEnclosingSymbolForAST(ast); + if (comparisonInfo.message) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); + } else { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); + } + } + }; + + PullTypeResolver.prototype.isReference = function (ast, astSymbol) { + if (ast.kind() === 217 /* ParenthesizedExpression */) { + return this.isReference(ast.expression, astSymbol); + } + + if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { + return false; + } + + if (ast.kind() === 11 /* IdentifierName */) { + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { + return false; + } + + if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { + return false; + } + + if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { + return false; + } + } + + if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { + return false; + } + + return true; + }; + + PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { + if (resolvedName) { + if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); + return true; + } + } + + return false; + }; + + PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { + return this.semanticInfoChain.getEnclosingDecl(ast); + }; + + PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { + var enclosingDecl = this.getEnclosingDeclForAST(ast); + return enclosingDecl ? enclosingDecl.getSymbol() : null; + }; + + PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { + if (resolvedName) { + if (resolvedName.anyDeclHasFlag(2 /* Private */)) { + var memberContainer = resolvedName.getContainer(); + if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { + memberContainer = memberContainer.getAssociatedContainerType(); + } + + if (memberContainer && memberContainer.isClass()) { + var memberClass = memberContainer.getDeclarations()[0].ast(); + TypeScript.Debug.assert(memberClass); + + var containingClass = this.getEnclosingClassDeclaration(name); + + if (!containingClass || containingClass !== memberClass) { + context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); + return true; + } + } + } + } + + return false; + }; + + PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { + if (type.isPrimitive()) { + return type; + } + + if (type.isError()) { + return type; + } + + if (typeParameterArgumentMap[type.pullSymbolID]) { + return typeParameterArgumentMap[type.pullSymbolID]; + } + + type._resolveDeclaredSymbol(); + if (type.isTypeParameter()) { + return this.instantiateTypeParameter(type, typeParameterArgumentMap); + } + + if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { + return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); + } + + return type; + }; + + 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 rootSignature = signature.getRootSymbol(); + var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); + TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); + + var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiatedSignature) { + return instantiatedSignature; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); + + 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) { + for (var j = 0; j < parameters.length; j++) { + parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); + parameter.setRootSymbol(parameters[j]); + + if (parameters[j].isOptional) { + parameter.isOptional = true; + } + if (parameters[j].isVarArg) { + parameter.isVarArg = true; + instantiatedSignature.hasVarArgs = true; + } + instantiatedSignature.addParameter(parameter, parameter.isOptional); + + parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); + } + } + + return instantiatedSignature; + }; + PullTypeResolver.globalTypeCheckPhase = 0; + return PullTypeResolver; + })(); + TypeScript.PullTypeResolver = PullTypeResolver; + + var TypeComparisonInfo = (function () { + function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { + this.onlyCaptureFirstError = false; + this.flags = 0 /* SuccessfulComparison */; + this.message = ""; + this.stringConstantVal = null; + this.indent = 1; + if (sourceComparisonInfo) { + this.flags = sourceComparisonInfo.flags; + this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; + this.stringConstantVal = sourceComparisonInfo.stringConstantVal; + this.indent = sourceComparisonInfo.indent; + if (!useSameIndent) { + this.indent++; + } + } + } + TypeComparisonInfo.prototype.indentString = function () { + var result = ""; + + for (var i = 0; i < this.indent; i++) { + result += "\t"; + } + + return result; + }; + + TypeComparisonInfo.prototype.addMessage = function (message) { + if (!this.onlyCaptureFirstError && this.message) { + this.message = this.message + TypeScript.newLine() + this.indentString() + message; + } else { + this.message = this.indentString() + message; + } + }; + return TypeComparisonInfo; + })(); + TypeScript.TypeComparisonInfo = TypeComparisonInfo; + + function getPropertyAssignmentNameTextFromIdentifier(identifier) { + if (identifier.kind() === 11 /* IdentifierName */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 14 /* StringLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else if (identifier.kind() === 13 /* NumericLiteral */) { + return { actualText: identifier.text(), memberName: identifier.valueText() }; + } else { + throw TypeScript.Errors.invalidOperation(); + } + } + TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; + + function isTypesOnlyLocation(ast) { + while (ast && ast.parent) { + switch (ast.parent.kind()) { + case 244 /* TypeAnnotation */: + return true; + case 127 /* TypeQuery */: + return false; + case 125 /* ConstructorType */: + var constructorType = ast.parent; + if (constructorType.type === ast) { + return true; + } + break; + case 123 /* FunctionType */: + var functionType = ast.parent; + if (functionType.type === ast) { + return true; + } + break; + case 239 /* Constraint */: + var constraint = ast.parent; + if (constraint.type === ast) { + return true; + } + break; + case 220 /* CastExpression */: + var castExpression = ast.parent; + return castExpression.type === ast; + case 230 /* ExtendsHeritageClause */: + case 231 /* ImplementsHeritageClause */: + return true; + case 228 /* TypeArgumentList */: + return true; + case 131 /* ClassDeclaration */: + case 128 /* InterfaceDeclaration */: + case 130 /* ModuleDeclaration */: + case 129 /* FunctionDeclaration */: + case 145 /* MethodSignature */: + case 212 /* MemberAccessExpression */: + case 242 /* Parameter */: + return false; + } + + ast = ast.parent; + } + + return false; + } + TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + TypeScript.declCacheHit = 0; + TypeScript.declCacheMiss = 0; + TypeScript.symbolCacheHit = 0; + TypeScript.symbolCacheMiss = 0; + + var sentinalEmptyArray = []; + + var SemanticInfoChain = (function () { + function SemanticInfoChain(compiler, logger) { + this.compiler = compiler; + this.logger = logger; + this.documents = []; + this.fileNameToDocument = TypeScript.createIntrinsicsObject(); + this.anyTypeDecl = null; + this.booleanTypeDecl = null; + this.numberTypeDecl = null; + this.stringTypeDecl = null; + this.nullTypeDecl = null; + this.undefinedTypeDecl = null; + this.voidTypeDecl = null; + this.undefinedValueDecl = null; + this.anyTypeSymbol = null; + this.booleanTypeSymbol = null; + this.numberTypeSymbol = null; + this.stringTypeSymbol = null; + this.nullTypeSymbol = null; + this.undefinedTypeSymbol = null; + this.voidTypeSymbol = null; + this.undefinedValueSymbol = null; + this.emptyTypeSymbol = null; + this.astSymbolMap = []; + this.astAliasSymbolMap = []; + this.astCallResolutionDataMap = []; + this.declSymbolMap = []; + this.declSignatureSymbolMap = []; + this.declCache = null; + this.symbolCache = null; + this.fileNameToDiagnostics = null; + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + 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); + 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 */, 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 || null; + }; + + SemanticInfoChain.prototype.lineMap = function (fileName) { + return this.getDocument(fileName).lineMap(); + }; + + SemanticInfoChain.prototype.fileNames = function () { + if (this._fileNames === null) { + this._fileNames = this.documents.slice(1).map(function (s) { + return s.fileName; + }); + } + + return this._fileNames; + }; + + SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { + newSymbol.addDeclaration(decl); + decl.setSymbol(newSymbol); + newSymbol.setResolved(); + + return newSymbol; + }; + + SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { + var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { + var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); + newSymbol.type = type; + return this.bindPrimitiveSymbol(decl, newSymbol); + }; + + SemanticInfoChain.prototype.resetGlobalSymbols = function () { + this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); + this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); + this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); + this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); + this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); + this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); + this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); + this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); + + var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); + var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); + emptyTypeDecl.setSymbol(emptyTypeSymbol); + emptyTypeSymbol.addDeclaration(emptyTypeDecl); + emptyTypeSymbol.setResolved(); + this.emptyTypeSymbol = emptyTypeSymbol; + }; + + SemanticInfoChain.prototype.addDocument = function (document) { + var fileName = document.fileName; + + var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (existingIndex < 0) { + this.documents.push(document); + } else { + this.documents[existingIndex] = document; + } + + this.fileNameToDocument[fileName] = document; + + this.invalidate(); + }; + + SemanticInfoChain.prototype.removeDocument = function (fileName) { + TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); + var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { + return u.fileName === fileName; + }); + if (index > 0) { + this.fileNameToDocument[fileName] = undefined; + this.documents.splice(index, 1); + this.invalidate(); + } + }; + + SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { + var cacheID = ""; + + for (var i = 0; i < declPath.length; i++) { + cacheID += "#" + declPath[i]; + } + + return cacheID + "#" + declKind.toString(); + }; + + SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { + var cacheID = this.getDeclPathCacheID([name], kind); + + var symbol = this.symbolCache[cacheID]; + + if (!symbol) { + for (var i = 0, n = this.documents.length; i < n; i++) { + var topLevelDecl = this.documents[i].topLevelDecl(); + + var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); + if (symbol) { + break; + } + + if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { + return null; + } + } + + if (symbol) { + this.symbolCache[cacheID] = symbol; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { + var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; + + var foundDecls = topLevelDecl.searchChildDecls(name, kind); + + for (var j = 0; j < foundDecls.length; j++) { + var foundDecl = foundDecls[j]; + + if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { + break; + } + + var symbol = foundDecls[j].getSymbol(); + if (symbol) { + return symbol; + } + } + + return null; + }; + + SemanticInfoChain.prototype.findExternalModule = function (id) { + id = TypeScript.normalizePath(id); + + var tsFile = id + ".ts"; + var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); + symbol = this.symbolCache[tsCacheID]; + if (symbol != undefined) { + return symbol; + } + + 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 isTsFile = document.fileName === tsFile; + if (isTsFile || document.fileName === dtsFile) { + var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; + symbol = dynamicModuleDecl.getSymbol(); + + 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 null; + }; + + SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { + var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); + + var symbol = this.symbolCache[cacheID]; + if (symbol == undefined) { + symbol = null; + for (var i = 0; i < this.documents.length; i++) { + var document = this.documents[i]; + var topLevelDecl = document.topLevelDecl(); + + if (!topLevelDecl.isExternalModule()) { + var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); + if (dynamicModules.length) { + symbol = dynamicModules[0].getSymbol(); + break; + } + } + } + + this.symbolCache[cacheID] = symbol; + } + + return symbol; + }; + + SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { + var cacheID = this.getDeclPathCacheID(declPath, declKind); + + if (declPath.length) { + var cachedDecls = this.declCache[cacheID]; + + if (cachedDecls && cachedDecls.length) { + TypeScript.declCacheHit++; + return cachedDecls; + } + } + + TypeScript.declCacheMiss++; + + var declsToSearch = this.topLevelDecls(); + + var decls = TypeScript.sentinelEmptyArray; + var path; + var foundDecls = TypeScript.sentinelEmptyArray; + + 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, kind); + + for (var k = 0; k < foundDecls.length; k++) { + if (decls === TypeScript.sentinelEmptyArray) { + decls = []; + } + decls[decls.length] = foundDecls[k]; + } + } + + declsToSearch = decls; + + if (!declsToSearch) { + break; + } + } + + if (decls.length) { + this.declCache[cacheID] = decls; + } + + return decls; + }; + + SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { + var declString = []; + + for (var i = 0, n = declPath.length; i < n; i++) { + if (declPath[i].kind & 1 /* Script */) { + continue; + } + + declString.push(declPath[i].name); + } + + return this.findDecls(declString, declKind); + }; + + SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { + var cacheID = this.getDeclPathCacheID(declPath, declType); + + if (declPath.length) { + var cachedSymbol = this.symbolCache[cacheID]; + + if (cachedSymbol) { + TypeScript.symbolCacheHit++; + return cachedSymbol; + } + } + + TypeScript.symbolCacheMiss++; + + var decls = this.findDecls(declPath, declType); + var symbol = null; + + if (decls.length) { + 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; + } + } + + return symbol; + }; + + SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { + var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); + var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); + + if (!this.symbolCache[cacheID1]) { + this.symbolCache[cacheID1] = symbol; + } + + if (!this.symbolCache[cacheID2]) { + this.symbolCache[cacheID2] = symbol; + } + }; + + SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { + if (typeof oldSettings === "undefined") { oldSettings = null; } + if (typeof newSettings === "undefined") { newSettings = null; } + TypeScript.PullTypeResolver.globalTypeCheckPhase++; + + var cleanStart = new Date().getTime(); + + this.astSymbolMap.length = 0; + this.astAliasSymbolMap.length = 0; + this.astCallResolutionDataMap.length = 0; + + this.declCache = TypeScript.createIntrinsicsObject(); + this.symbolCache = TypeScript.createIntrinsicsObject(); + this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); + this._binder = null; + this._resolver = null; + this._topLevelDecls = null; + this._fileNames = null; + + this.declSymbolMap.length = 0; + this.declSignatureSymbolMap.length = 0; + + if (oldSettings && newSettings) { + if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { + for (var i = 1, n = this.documents.length; i < n; i++) { + this.documents[i].invalidate(); + } + } + } + + TypeScript.pullSymbolID = 0; + + this.resetGlobalSymbols(); + + var cleanEnd = new Date().getTime(); + }; + + SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { + return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); + }; + + SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { + this.astSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForAST = function (ast) { + return this.astSymbolMap[ast.syntaxID()] || null; + }; + + SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { + this.astAliasSymbolMap[ast.syntaxID()] = symbol; + }; + + SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { + return this.astAliasSymbolMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { + return this.astCallResolutionDataMap[ast.syntaxID()]; + }; + + SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { + if (callResolutionData) { + this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; + } + }; + + SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { + this.declSymbolMap[decl.declID] = symbol; + }; + + SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { + return this.declSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { + this.declSignatureSymbolMap[decl.declID] = signatureSymbol; + }; + + SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { + return this.declSignatureSymbolMap[decl.declID]; + }; + + SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { + var fileName = diagnostic.fileName(); + var diagnostics = this.fileNameToDiagnostics[fileName]; + if (!diagnostics) { + diagnostics = []; + this.fileNameToDiagnostics[fileName] = diagnostics; + } + + diagnostics.push(diagnostic); + }; + + SemanticInfoChain.prototype.getDiagnostics = function (fileName) { + var diagnostics = this.fileNameToDiagnostics[fileName]; + return diagnostics || []; + }; + + SemanticInfoChain.prototype.getBinder = function () { + if (!this._binder) { + this._binder = new TypeScript.PullSymbolBinder(this); + } + + return this._binder; + }; + + SemanticInfoChain.prototype.getResolver = function () { + if (!this._resolver) { + this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); + } + + return this._resolver; + }; + + SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); + indexParameterSymbol.type = indexParamType; + indexSignature.addParameter(indexParameterSymbol); + indexSignature.returnType = returnType; + indexSignature.setResolved(); + indexParameterSymbol.setResolved(); + + containingSymbol.addIndexSignature(indexSignature); + + 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); + indexParameterSymbol.addDeclaration(indexParamDecl); + }; + + SemanticInfoChain.prototype.getDeclForAST = function (ast) { + var document = this.getDocument(ast.fileName()); + + if (document) { + return document._getDeclForAST(ast); + } + + return null; + }; + + SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { + return this.getDocument(ast.fileName()).getEnclosingDecl(ast); + }; + + SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { + this.getDocument(decl.fileName())._setDeclForAST(ast, decl); + }; + + SemanticInfoChain.prototype.getASTForDecl = function (decl) { + var document = this.getDocument(decl.fileName()); + if (document) { + return document._getASTForDecl(decl); + } + + return null; + }; + + SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { + this.getDocument(decl.fileName())._setASTForDecl(decl, ast); + }; + + SemanticInfoChain.prototype.topLevelDecl = function (fileName) { + var document = this.getDocument(fileName); + if (document) { + return document.topLevelDecl(); + } + + return null; + }; + + SemanticInfoChain.prototype.topLevelDecls = function () { + if (!this._topLevelDecls) { + this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { + return u.topLevelDecl(); + }); + } + + return this._topLevelDecls; + }; + + 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, 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; + })(); + TypeScript.SemanticInfoChain = SemanticInfoChain; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var DeclCollectionContext = (function () { + function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { + this.document = document; + this.semanticInfoChain = semanticInfoChain; + this.propagateEnumConstants = propagateEnumConstants; + this.isDeclareFile = false; + this.parentChain = []; + } + DeclCollectionContext.prototype.getParent = function () { + return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; + }; + + DeclCollectionContext.prototype.pushParent = function (parentDecl) { + if (parentDecl) { + this.parentChain[this.parentChain.length] = parentDecl; + } + }; + + DeclCollectionContext.prototype.popParent = function () { + this.parentChain.length--; + }; + return DeclCollectionContext; + })(); + + function containingModuleHasExportAssignment(ast) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = ast; + return moduleDecl.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } else if (ast.kind() === 120 /* SourceUnit */) { + var sourceUnit = ast; + return sourceUnit.moduleElements.any(function (m) { + return m.kind() === 134 /* ExportAssignment */; + }); + } + + ast = ast.parent; + } + + return false; + } + + function isParsingAmbientModule(ast, context) { + ast = ast.parent; + while (ast) { + if (ast.kind() === 130 /* ModuleDeclaration */) { + if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { + return true; + } + } + + ast = ast.parent; + } + + return false; + } + + function preCollectImportDecls(ast, context) { + var importDecl = ast; + var declFlags = 0 /* None */; + + var parent = context.getParent(); + + if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { + declFlags |= 1 /* Exported */; + } + + 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 fileName = sourceUnit.fileName(); + + var isExternalModule = context.document.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); + + context.isDeclareFile = context.document.isDeclareFile(); + + context.pushParent(decl); + + if (isExternalModule) { + var declFlags = 1 /* Exported */; + if (TypeScript.isDTSFile(fileName)) { + declFlags |= 8 /* Ambient */; + } + + var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); + var kind = 32 /* DynamicModule */; + var valueText = TypeScript.quoteStr(fileName); + + var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); + + context.semanticInfoChain.setASTForDecl(decl, sourceUnit); + + context.semanticInfoChain.setDeclForAST(sourceUnit, decl); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, sourceUnit, context); + } + + context.pushParent(decl); + } + } + + function preCollectEnumDecls(enumDecl, context) { + var declFlags = 0 /* None */; + var enumName = enumDecl.identifier.valueText(); + + if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + declFlags |= 4096 /* Enum */; + var kind = 64 /* Enum */; + + var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); + context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); + context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); + + var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); + enumDeclaration.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); + + context.pushParent(enumDeclaration); + } + + function createEnumElementDecls(propertyDecl, context) { + var parent = context.getParent(); + + var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function preCollectModuleDecls(moduleDecl, context) { + var declFlags = 0 /* None */; + + var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); + + var isDynamic = moduleDecl.stringLiteral !== null; + + if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; + + 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()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); + } + + context.pushParent(decl); + } else { + var moduleNames = getModuleNames(moduleDecl.name); + for (var i = 0, n = moduleNames.length; i < n; i++) { + var moduleName = moduleNames[i]; + + var specificFlags = declFlags; + if (i > 0) { + specificFlags |= 1 /* Exported */; + } + + var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); + + context.semanticInfoChain.setDeclForAST(moduleDecl, decl); + context.semanticInfoChain.setDeclForAST(moduleName, decl); + context.semanticInfoChain.setASTForDecl(decl, moduleName); + + if (moduleContainsExecutableCode) { + createModuleVariableDecl(decl, moduleName, context); + } + + context.pushParent(decl); + } + } + } + + function getModuleNames(name, result) { + result = result || []; + + if (name.kind() === 121 /* QualifiedName */) { + getModuleNames(name.left, result); + result.push(name.right); + } else { + result.push(name); + } + + return result; + } + TypeScript.getModuleNames = getModuleNames; + + 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.setValueDecl(valueDecl); + context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); + } + + function containsExecutableCode(members) { + for (var i = 0, n = members.childCount(); i < n; i++) { + var member = members.childAt(i); + + if (member.kind() === 130 /* ModuleDeclaration */) { + var moduleDecl = member; + + if (containsExecutableCode(moduleDecl.moduleElements)) { + return true; + } + } else if (member.kind() === 133 /* ImportDeclaration */) { + if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { + return true; + } + } else if (member.kind() !== 128 /* InterfaceDeclaration */) { + return true; + } + } + + return false; + } + + function preCollectClassDecls(classDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + var parent = context.getParent(); + + 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); + + decl.setValueDecl(constructorDecl); + + context.semanticInfoChain.setDeclForAST(classDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, classDecl); + context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); + + context.pushParent(decl); + } + + function preCollectObjectTypeDecls(objectType, context) { + if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { + return; + } + + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setDeclForAST(objectType, decl); + context.semanticInfoChain.setASTForDecl(decl, objectType); + + context.pushParent(decl); + } + + function preCollectInterfaceDecls(interfaceDecl, context) { + var declFlags = 0 /* None */; + + if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { + declFlags |= 1 /* Exported */; + } + + var parent = context.getParent(); + + 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); + + context.pushParent(decl); + } + + function preCollectParameterDecl(argDecl, context) { + var declFlags = 0 /* None */; + + if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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 */) { + decl.setFlag(67108864 /* ConstructorParameter */); + } + + var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); + var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; + if (isPublicOrPrivate && isInConstructor) { + var parentsParent = context.parentChain[context.parentChain.length - 2]; + + 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 */) { + propDecl.setFlag(67108864 /* ConstructorParameter */); + } + + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setASTForDecl(propDecl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, propDecl); + } else { + context.semanticInfoChain.setASTForDecl(decl, argDecl); + context.semanticInfoChain.setDeclForAST(argDecl, decl); + } + + parent.addVariableDeclToGroup(decl); + } + + function preCollectTypeParameterDecl(typeParameterDecl, context) { + var declFlags = 0 /* None */; + + 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); + context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); + context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); + } + + function createPropertySignature(propertyDecl, context) { + var declFlags = 4 /* Public */; + var parent = context.getParent(); + var declType = 4096 /* Property */; + + if (propertyDecl.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(propertyDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyDecl); + } + + function createMemberVariableDeclaration(memberDecl, context) { + var declFlags = 0 /* None */; + var declType = 4096 /* Property */; + + if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + var parent = context.getParent(); + + 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); + } + + function createVariableDeclaration(varDecl, context) { + var declFlags = 0 /* None */; + var declType = 512 /* Variable */; + + var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); + if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + 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); + context.semanticInfoChain.setDeclForAST(varDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, varDecl); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectVarDecls(ast, context) { + if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { + return; + } + + var varDecl = ast; + createVariableDeclaration(varDecl, context); + } + + function createFunctionTypeDeclaration(functionTypeDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 16777216 /* FunctionType */; + + 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); + context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); + + context.pushParent(decl); + } + + function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 33554432 /* ConstructorType */; + + 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); + context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); + + context.pushParent(decl); + } + + function createFunctionDeclaration(funcDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 16384 /* Function */; + + if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { + declFlags |= 1 /* Exported */; + } + + if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { + declFlags |= 8 /* Ambient */; + } + + if (!funcDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + 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); + context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); + + context.pushParent(decl); + } + + function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { + if (typeof displayName === "undefined") { displayName = null; } + var declFlags = 0 /* None */; + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { + declFlags |= 8192 /* ArrowFunction */; + } + + var parent = context.getParent(); + + if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + var name = id ? id.text() : ""; + var displayNameText = displayName ? displayName.text() : ""; + var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); + context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); + + context.pushParent(decl); + + if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { + var simpleArrow = functionExpressionDeclAST; + var declFlags = 4 /* Public */; + + var parent = context.getParent(); + + if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { + declFlags |= 2097152 /* DeclaredInAWithBlock */; + } + + 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); + + parent.addVariableDeclToGroup(decl); + } + } + + function createMemberFunctionDeclaration(funcDecl, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + if (!funcDecl.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(funcDecl, decl); + context.semanticInfoChain.setASTForDecl(decl, funcDecl); + + context.pushParent(decl); + } + + function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 4194304 /* IndexSignature */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); + + context.pushParent(decl); + } + + function createCallSignatureDeclaration(callSignature, context) { + var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; + + if (!isChildOfObjectType) { + return; + } + + var declFlags = 2048 /* Signature */; + var declType = 1048576 /* CallSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(callSignature, decl); + context.semanticInfoChain.setASTForDecl(decl, callSignature); + + context.pushParent(decl); + } + + function createMethodSignatureDeclaration(method, context) { + var declFlags = 0 /* None */; + var declType = 65536 /* Method */; + + declFlags |= 4 /* Public */; + declFlags |= 2048 /* Signature */; + + if (method.questionToken !== null) { + declFlags |= 128 /* Optional */; + } + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(method, decl); + context.semanticInfoChain.setASTForDecl(decl, method); + + context.pushParent(decl); + } + + function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { + var declFlags = 2048 /* Signature */; + var declType = 2097152 /* ConstructSignature */; + + 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); + context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); + + context.pushParent(decl); + } + + function createClassConstructorDeclaration(constructorDeclAST, context) { + var declFlags = 0 /* None */; + var declType = 32768 /* ConstructorMethod */; + + if (!constructorDeclAST.block) { + declFlags |= 2048 /* Signature */; + } + + var parent = context.getParent(); + + if (parent) { + var parentFlags = parent.flags; + + if (parentFlags & 1 /* Exported */) { + declFlags |= 1 /* Exported */; + } + } + + var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); + + context.pushParent(decl); + } + + function createGetAccessorDeclaration(getAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 262144 /* GetAccessor */; + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); + + context.pushParent(decl); + } + + function createFunctionExpressionDeclaration(expression, context) { + createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); + } + + function createSetAccessorDeclaration(setAccessorDeclAST, context) { + var declFlags = 4 /* Public */; + var declType = 524288 /* SetAccessor */; + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { + declFlags |= 16 /* Static */; + } + + if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { + declFlags |= 2 /* Private */; + } else { + declFlags |= 4 /* Public */; + } + + 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); + context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); + context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); + + context.pushParent(decl); + } + + function preCollectCatchDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 268435456 /* CatchBlock */; + + 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); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + + var declFlags = 0 /* None */; + var declType = 1024 /* CatchVariable */; + + 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); + context.semanticInfoChain.setDeclForAST(ast.identifier, decl); + context.semanticInfoChain.setASTForDecl(decl, ast.identifier); + + if (parent) { + parent.addVariableDeclToGroup(decl); + } + } + + function preCollectWithDecls(ast, context) { + var declFlags = 0 /* None */; + var declType = 134217728 /* WithBlock */; + + var parent = context.getParent(); + + var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectObjectLiteralDecls(ast, context) { + var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); + + context.semanticInfoChain.setDeclForAST(ast, decl); + context.semanticInfoChain.setASTForDecl(decl, ast); + + context.pushParent(decl); + } + + function preCollectSimplePropertyAssignmentDecls(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()); + + context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); + context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); + } + + function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { + var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); + + 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); + + createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); + } + + function preCollectDecls(ast, context) { + switch (ast.kind()) { + case 120 /* SourceUnit */: + preCollectScriptDecls(ast, context); + break; + case 132 /* EnumDeclaration */: + preCollectEnumDecls(ast, context); + break; + case 243 /* EnumElement */: + createEnumElementDecls(ast, context); + break; + case 130 /* ModuleDeclaration */: + preCollectModuleDecls(ast, context); + break; + case 131 /* ClassDeclaration */: + preCollectClassDecls(ast, context); + break; + case 128 /* InterfaceDeclaration */: + preCollectInterfaceDecls(ast, context); + break; + case 122 /* ObjectType */: + preCollectObjectTypeDecls(ast, context); + break; + case 242 /* Parameter */: + preCollectParameterDecl(ast, context); + break; + case 136 /* MemberVariableDeclaration */: + createMemberVariableDeclaration(ast, context); + break; + case 141 /* PropertySignature */: + createPropertySignature(ast, context); + break; + case 225 /* VariableDeclarator */: + preCollectVarDecls(ast, context); + break; + case 137 /* ConstructorDeclaration */: + createClassConstructorDeclaration(ast, context); + break; + case 139 /* GetAccessor */: + createGetAccessorDeclaration(ast, context); + break; + case 140 /* SetAccessor */: + createSetAccessorDeclaration(ast, context); + break; + case 222 /* FunctionExpression */: + createFunctionExpressionDeclaration(ast, context); + break; + case 135 /* MemberFunctionDeclaration */: + createMemberFunctionDeclaration(ast, context); + break; + case 144 /* IndexSignature */: + createIndexSignatureDeclaration(ast, context); + break; + case 123 /* FunctionType */: + createFunctionTypeDeclaration(ast, context); + break; + case 125 /* ConstructorType */: + createConstructorTypeDeclaration(ast, context); + break; + case 142 /* CallSignature */: + createCallSignatureDeclaration(ast, context); + break; + case 143 /* ConstructSignature */: + createConstructSignatureDeclaration(ast, context); + break; + case 145 /* MethodSignature */: + createMethodSignatureDeclaration(ast, context); + break; + case 129 /* FunctionDeclaration */: + createFunctionDeclaration(ast, context); + break; + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + createAnyFunctionExpressionDeclaration(ast, null, context); + break; + case 133 /* ImportDeclaration */: + preCollectImportDecls(ast, context); + break; + case 238 /* TypeParameter */: + preCollectTypeParameterDecl(ast, context); + break; + case 236 /* CatchClause */: + preCollectCatchDecls(ast, context); + break; + case 163 /* WithStatement */: + preCollectWithDecls(ast, context); + break; + case 215 /* ObjectLiteralExpression */: + preCollectObjectLiteralDecls(ast, context); + break; + case 240 /* SimplePropertyAssignment */: + preCollectSimplePropertyAssignmentDecls(ast, context); + break; + case 241 /* FunctionPropertyAssignment */: + preCollectFunctionPropertyAssignmentDecls(ast, context); + break; + } + } + + function isContainer(decl) { + return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; + } + + function getInitializationFlag(decl) { + if (decl.kind & 4 /* Container */) { + return 32768 /* InitializedModule */; + } else if (decl.kind & 32 /* DynamicModule */) { + return 65536 /* InitializedDynamicModule */; + } + + return 0 /* None */; + } + + function hasInitializationFlag(decl) { + var kind = decl.kind; + + if (kind & 4 /* Container */) { + return (decl.flags & 32768 /* InitializedModule */) !== 0; + } else if (kind & 32 /* DynamicModule */) { + return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; + } + + return false; + } + + function postCollectDecls(ast, context) { + var currentDecl = context.getParent(); + + if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { + if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { + return; + } + } + + if (ast.kind() === 130 /* ModuleDeclaration */) { + var moduleDeclaration = ast; + if (moduleDeclaration.stringLiteral) { + TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); + context.popParent(); + } else { + var moduleNames = getModuleNames(moduleDeclaration.name); + for (var i = moduleNames.length - 1; i >= 0; i--) { + var moduleName = moduleNames[i]; + TypeScript.Debug.assert(currentDecl.ast() === moduleName); + context.popParent(); + currentDecl = context.getParent(); + } + } + } + + if (ast.kind() === 132 /* EnumDeclaration */) { + computeEnumElementConstantValues(ast, currentDecl, context); + } + + while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { + context.popParent(); + currentDecl = context.getParent(); + } + } + + function computeEnumElementConstantValues(ast, enumDecl, context) { + TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); + + var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); + var inConstantSection = !isAmbientEnum; + var currentConstantValue = 0; + var enumMemberDecls = enumDecl.getChildDecls(); + + for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { + var enumElement = ast.enumElements.nonSeparatorAt(i); + var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { + return context.semanticInfoChain.getASTForDecl(d) === enumElement; + }); + + TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); + + if (enumElement.equalsValueClause === null) { + if (inConstantSection) { + enumElementDecl.constantValue = currentConstantValue; + currentConstantValue++; + } + } else { + enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); + if (enumElementDecl.constantValue !== null && !isAmbientEnum) { + inConstantSection = true; + currentConstantValue = enumElementDecl.constantValue + 1; + } else { + inConstantSection = false; + } + } + + TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); + } + } + + function computeEnumElementConstantValue(expression, enumMemberDecls, context) { + TypeScript.Debug.assert(expression); + + if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { + var token; + switch (expression.kind()) { + case 164 /* PlusExpression */: + case 165 /* NegateExpression */: + token = expression.operand; + break; + default: + token = expression; + } + + var value = token.value(); + return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; + } else if (context.propagateEnumConstants) { + switch (expression.kind()) { + case 11 /* IdentifierName */: + var name = expression; + var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { + return d.name === name.valueText(); + }); + + return matchingEnumElement ? matchingEnumElement.constantValue : null; + + case 202 /* LeftShiftExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left << right; + + case 189 /* BitwiseOrExpression */: + var binaryExpression = expression; + var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); + var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); + if (left === null || right === null) { + return null; + } + + return left | right; + } + + return null; + } else { + return null; + } + } + + (function (DeclarationCreator) { + function create(document, semanticInfoChain, compilationSettings) { + var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); + + TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); + + return declCollectionContext.getParent(); + } + DeclarationCreator.create = create; + })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); + var DeclarationCreator = TypeScript.DeclarationCreator; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var PullSymbolBinder = (function () { + 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 */) { + return null; + } + + var parent = parentDecl.getSymbol(); + + if (!parent && parentDecl && !parentDecl.hasBeenBound()) { + this.bindDeclToPullSymbol(parentDecl); + } + + parent = parentDecl.getSymbol(); + if (parent) { + var parentDeclKind = parentDecl.kind; + if (parentDeclKind === 262144 /* GetAccessor */) { + parent = parent.getGetter(); + } else if (parentDeclKind === 524288 /* SetAccessor */) { + parent = parent.getSetter(); + } + } + + if (parent) { + if (returnInstanceType && parent.isType() && parent.isContainer()) { + var instanceSymbol = parent.getInstanceSymbol(); + + if (instanceSymbol) { + return instanceSymbol.type; + } + } + + return parent.type; + } + + return null; + }; + + PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { + if (!searchGlobally) { + var parentDecl = startingDecl.getParentDecl(); + return parentDecl.searchChildDecls(startingDecl.name, declKind); + } + + var contextSymbolPath = startingDecl.getParentPath(); + + if (contextSymbolPath.length) { + var copyOfContextSymbolPath = []; + + for (var i = 0; i < contextSymbolPath.length; i++) { + if (contextSymbolPath[i].kind & 1 /* Script */) { + continue; + } + copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; + } + + return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); + } + }; + + PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { + var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; + var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; + var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; + var name = decl.name; + if (parent) { + var isExported = (decl.flags & 1 /* Exported */) !== 0; + + var prevSymbol = null; + if (lookingForValue) { + prevSymbol = parent.findContainedNonMember(name); + } else if (lookingForType) { + prevSymbol = parent.findContainedNonMemberType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); + } + var prevIsExported = !prevSymbol; + if (!prevSymbol) { + if (lookingForValue) { + prevSymbol = parent.findMember(name, false); + } else if (lookingForType) { + prevSymbol = parent.findNestedType(name, searchKind); + } else if (lookingForContainer) { + prevSymbol = parent.findNestedContainer(name, searchKind); + } + } + + if (isExported && prevIsExported) { + return prevSymbol; + } + if (prevSymbol) { + var prevDecls = prevSymbol.getDeclarations(); + var lastPrevDecl = prevDecls[prevDecls.length - 1]; + var parentDecl = decl.getParentDecl(); + var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); + if (parentDecl !== prevParentDecl) { + return null; + } + + return prevSymbol; + } + } else { + var parentDecl = decl.getParentDecl(); + if (parentDecl && parentDecl.kind === 1 /* Script */) { + return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); + } else { + var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); + return prevDecls[0] && prevDecls[0].getSymbol(); + } + } + + return null; + }; + + PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { + if (typeof reportError === "undefined") { reportError = true; } + 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 (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()]); + } + return false; + } + + 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; + + var enumContainerSymbol = null; + var enumInstanceSymbol = null; + var moduleInstanceTypeSymbol = null; + + var enumInstanceDecl = enumContainerDecl.getValueDecl(); + + var enumDeclKind = enumContainerDecl.kind; + + var parent = this.getParent(enumContainerDecl); + var parentInstanceSymbol = this.getParent(enumContainerDecl, true); + var parentDecl = enumContainerDecl.getParentDecl(); + var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); + + var isExported = enumContainerDecl.flags & 1 /* Exported */; + + var createdNewSymbol = false; + + enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); + + if (enumContainerSymbol) { + if (enumContainerSymbol.kind !== enumDeclKind) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); + enumContainerSymbol = null; + } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { + enumContainerSymbol = null; + } + } + + if (enumContainerSymbol) { + enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); + } else { + enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); + } + } + + enumContainerSymbol.addDeclaration(enumContainerDecl); + enumContainerDecl.setSymbol(enumContainerSymbol); + + this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); + this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); + + if (!enumInstanceSymbol) { + var variableSymbol = null; + if (parentInstanceSymbol) { + if (isExported) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + } + } else { + variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); + + if (!variableSymbol) { + variableSymbol = parentInstanceSymbol.findMember(enumName, false); + } + } + + if (variableSymbol) { + var declarations = variableSymbol.getDeclarations(); + + if (declarations.length) { + var variableSymbolParentDecl = declarations[0].getParentDecl(); + + if (parentDecl !== variableSymbolParentDecl) { + variableSymbol = null; + } + } + } + } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { + var siblingDecls = parentDecl.getChildDecls(); + var augmentedDecl = null; + + for (var i = 0; i < siblingDecls.length; i++) { + if (siblingDecls[i] === enumContainerDecl) { + break; + } + + if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { + augmentedDecl = siblingDecls[i]; + break; + } + } + + if (augmentedDecl) { + variableSymbol = augmentedDecl.getSymbol(); + + if (variableSymbol) { + if (variableSymbol.isContainer()) { + variableSymbol = variableSymbol.getInstanceSymbol(); + } else if (variableSymbol && variableSymbol.isType()) { + variableSymbol = variableSymbol.getConstructorMethod(); + } + } + } + } + + if (variableSymbol) { + enumInstanceSymbol = variableSymbol; + moduleInstanceTypeSymbol = variableSymbol.type; + } else { + enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); + } + + enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); + + if (!moduleInstanceTypeSymbol) { + moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + enumInstanceSymbol.type = moduleInstanceTypeSymbol; + } + + moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); + + if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { + moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); + } + } + + if (createdNewSymbol && parent) { + if (enumContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(enumContainerSymbol); + } else { + parent.addEnclosedNonMemberType(enumContainerSymbol); + } + } + + if (createdNewSymbol) { + this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); + } + var valueDecl = enumContainerDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + }; + + 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(); + + enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); + }; + + 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(); + + 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); + if (!moduleDeclAST) { + TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); + TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); + + moduleDeclAST = moduleNameAST; + } + + var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); + var searchKind = 164 /* SomeContainer */; + var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; + + if (parent && moduleKind === 32 /* DynamicModule */) { + this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); + } + + var createdNewSymbol = false; + + moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); + + if (moduleContainerTypeSymbol) { + if (moduleContainerTypeSymbol.kind !== moduleKind) { + if (isInitializedModule) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); + } + + moduleContainerTypeSymbol = null; + } 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) { + moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); + } + } + + moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); + moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); + + this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); + this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); + + var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); + + var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); + + if (createdNewSymbol) { + if (parent) { + if (moduleContainerDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); + } else { + parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); + } + } + } + + if (currentModuleValueDecl) { + currentModuleValueDecl.ensureSymbolIsBound(); + + 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); + } + } + + if (!instanceSymbol.type) { + instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + } + + moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); + + if (!instanceSymbol.type.getAssociatedContainerType()) { + instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { + var declFlags = importDeclaration.flags; + var declKind = importDeclaration.kind; + var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); + + var isExported = false; + var importSymbol = null; + var declName = importDeclaration.name; + var parentHadSymbol = false; + var parent = this.getParent(importDeclaration); + + importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); + + if (importSymbol) { + parentHadSymbol = true; + } + + if (importSymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); + importSymbol = null; + } + + if (!importSymbol) { + importSymbol = new TypeScript.PullTypeAliasSymbol(declName); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); + } + } + + importSymbol.addDeclaration(importDeclaration); + importDeclaration.setSymbol(importSymbol); + + this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); + + if (parent && !parentHadSymbol) { + if (declFlags & 1 /* Exported */) { + parent.addEnclosedMemberContainer(importSymbol); + } else { + parent.addEnclosedNonMemberContainer(importSymbol); + } + } + }; + + 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; + + var constructorSymbol = null; + var constructorTypeSymbol = null; + + 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, 58728795 /* SomeType */, parent); + + if (classSymbol && classSymbol.kind === 16 /* Interface */) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); + classSymbol = null; + } + + classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); + } + + classSymbol.addDeclaration(classDecl); + + classDecl.setSymbol(classSymbol); + + this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); + this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); + + if (parent) { + if (classDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(classSymbol); + } else { + parent.addEnclosedNonMemberType(classSymbol); + } + } + + 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; + + if (!constructorSymbol) { + var siblingValueDecls = null; + if (parentDecl) { + siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); + + if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { + constructorSymbol = siblingValueDecls[0].getSymbol(); + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + constructorSymbol.setIsSynthesized(); + constructorSymbol.type = constructorTypeSymbol; + } + + classSymbol.setConstructorMethod(constructorSymbol); + classSymbol.setHasDefaultConstructor(); + } + + if (constructorSymbol.getIsSynthesized()) { + constructorSymbol.addDeclaration(classDecl.getValueDecl()); + constructorTypeSymbol.addDeclaration(classDecl); + } else { + classSymbol.setHasDefaultConstructor(false); + } + + constructorTypeSymbol.setAssociatedContainerType(classSymbol); + + var valueDecl = classDecl.getValueDecl(); + + if (valueDecl) { + valueDecl.ensureSymbolIsBound(); + } + + this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); + }; + + PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { + var interfaceName = interfaceDecl.name; + var interfaceSymbol = null; + + var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); + var createdNewSymbol = false; + var parent = this.getParent(interfaceDecl); + + var acceptableSharedKind = 16 /* Interface */; + + interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); + + if (interfaceSymbol) { + if (!(interfaceSymbol.kind & acceptableSharedKind)) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); + interfaceSymbol = null; + } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { + interfaceSymbol = null; + } + } + + if (!interfaceSymbol) { + interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); + createdNewSymbol = true; + + if (!parent) { + this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); + } + } + + interfaceSymbol.addDeclaration(interfaceDecl); + interfaceDecl.setSymbol(interfaceSymbol); + + if (createdNewSymbol) { + if (parent) { + if (interfaceDecl.flags & 1 /* Exported */) { + parent.addEnclosedMemberType(interfaceSymbol); + } else { + parent.addEnclosedNonMemberType(interfaceSymbol); + } + } + } + + var typeParameters = interfaceDecl.getTypeParameters(); + var typeParameter; + var typeParameterDecls = null; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + interfaceSymbol.addTypeParameter(typeParameter); + } else { + typeParameterDecls = typeParameter.getDeclarations(); + + for (var j = 0; j < typeParameterDecls.length; j++) { + var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); + + if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + + break; + } + } + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + }; + + PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { + var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); + + var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); + + objectSymbol.addDeclaration(objectDecl); + objectDecl.setSymbol(objectSymbol); + + this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); + + var childDecls = objectDecl.getChildDecls(); + + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + }; + + PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { + var declKind = constructorTypeDeclaration.kind; + var declFlags = constructorTypeDeclaration.flags; + var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + + var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + + constructorTypeDeclaration.setSymbol(constructorTypeSymbol); + constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); + + var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); + if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { + signature.hasVarArgs = true; + } + + signature.addDeclaration(constructorTypeDeclaration); + constructorTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); + + var typeParameters = constructorTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + 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; + + var variableSymbol = null; + + var declName = variableDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(variableDeclaration, true); + + 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; + variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); + + if (!variableSymbol && isModuleValue) { + variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); + } + + if (variableSymbol && !variableSymbol.isType()) { + parentHadSymbol = true; + } + + var decl; + var decls; + var ast; + var members; + + if (variableSymbol) { + var prevKind = variableSymbol.kind; + var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); + var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); + var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); + var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); + 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 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 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.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 || 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); + variableSymbol = null; + parentHadSymbol = false; + } + } + + if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { + variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); + } + } + + if ((declFlags & 118784 /* ImplicitVariable */) === 0) { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + if (!parent && parentDecl.kind === 1 /* Script */) { + this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); + } + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); + this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); + } else if (!parentHadSymbol) { + if (isClassConstructorVariable) { + var classTypeSymbol = variableSymbol; + + if (parent) { + members = parent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { + classTypeSymbol = members[i]; + break; + } + } + } + + if (!classTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + classTypeSymbol = containerDecl.getSymbol(); + if (!classTypeSymbol) { + classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); + } + } + + if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { + classTypeSymbol = null; + } + + if (classTypeSymbol && classTypeSymbol.isClass()) { + variableSymbol = classTypeSymbol.getConstructorMethod(); + variableDeclaration.setSymbol(variableSymbol); + + decls = classTypeSymbol.getDeclarations(); + + if (decls.length) { + decl = decls[decls.length - 1]; + ast = this.semanticInfoChain.getASTForDecl(decl); + } + } else { + if (!variableSymbol) { + variableSymbol = new TypeScript.PullSymbol(declName, declKind); + } + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + } + } else if (declFlags & 102400 /* SomeInitializedModule */) { + var moduleContainerTypeSymbol = null; + var moduleParent = this.getParent(variableDeclaration); + + if (moduleParent) { + members = moduleParent.getMembers(); + + for (var i = 0; i < members.length; i++) { + if ((members[i].name === declName) && (members[i].isContainer())) { + moduleContainerTypeSymbol = members[i]; + break; + } + } + } + + if (!moduleContainerTypeSymbol) { + var containerDecl = variableDeclaration.getContainerDecl(); + moduleContainerTypeSymbol = containerDecl.getSymbol(); + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); + + if (!moduleContainerTypeSymbol) { + moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); + } + } + } + + if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { + moduleContainerTypeSymbol = null; + } + + 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); + } + variableDeclaration.setSymbol(variableSymbol); + } else { + TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); + } + } + } else { + if (!variableSymbol.hasDeclaration(variableDeclaration)) { + variableSymbol.addDeclaration(variableDeclaration); + } + 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); + } else { + parent.addEnclosedNonMember(variableSymbol); + } + } + }; + + PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { + var declFlags = variableDeclaration.flags; + var declKind = variableDeclaration.kind; + var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); + + var declName = variableDeclaration.name; + + var variableSymbol = new TypeScript.PullSymbol(declName, declKind); + + variableSymbol.addDeclaration(variableDeclaration); + variableDeclaration.setSymbol(variableSymbol); + + variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; + + this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); + }; + + PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + var propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { + var declFlags = propertyDeclaration.flags; + var declKind = propertyDeclaration.kind; + + var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); + var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; + + var isStatic = false; + var isOptional = false; + + var propertySymbol = null; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { + isOptional = true; + } + + var declName = propertyDeclaration.name; + + var parentHadSymbol = false; + + var parent = this.getParent(propertyDeclaration, true); + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + propertySymbol = parent.findMember(declName, false); + + if (propertySymbol) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); + } + + if (propertySymbol) { + parentHadSymbol = true; + } + + var classTypeSymbol; + + if (!parentHadSymbol) { + propertySymbol = new TypeScript.PullSymbol(declName, declKind); + } + + propertySymbol.addDeclaration(propertyDeclaration); + propertyDeclaration.setSymbol(propertySymbol); + + this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); + this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); + + if (isOptional) { + propertySymbol.isOptional = true; + } + + if (parent && !parentHadSymbol) { + parent.addMember(propertySymbol); + } + }; + + PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { + var parameters = []; + var params = TypeScript.createIntrinsicsObject(); + var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); + + if (parameterList) { + for (var i = 0, n = parameterList.length; i < n; i++) { + var argDecl = parameterList.astAt(i); + var id = parameterList.identifierAt(i); + var decl = this.semanticInfoChain.getDeclForAST(argDecl); + var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); + var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); + + if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { + parameterSymbol.isVarArg = 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); + + if (signatureSymbol.isDefinition()) { + funcType.addEnclosedNonMember(parameterSymbol); + } + } + } + }; + + PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { + var declKind = functionDeclaration.kind; + var declFlags = functionDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = functionDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(functionDeclaration, true); + + var parentDecl = functionDeclaration.getParentDecl(); + var parentHadSymbol = false; + + var functionSymbol = null; + var functionTypeSymbol = null; + + functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); + + if (functionSymbol) { + 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); + functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); + } + } + + if (functionSymbol) { + functionTypeSymbol = functionSymbol.type; + parentHadSymbol = true; + } + + if (!functionSymbol) { + functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + } + + if (!functionTypeSymbol) { + functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionSymbol.type = functionTypeSymbol; + functionTypeSymbol.setFunctionSymbol(functionSymbol); + } + + functionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionDeclaration); + functionTypeSymbol.addDeclaration(functionDeclaration); + + this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); + + if (parent && !parentHadSymbol) { + if (isExported) { + parent.addMember(functionSymbol); + } else { + parent.addEnclosedNonMember(functionSymbol); + } + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(functionDeclaration); + functionDeclaration.setSignatureSymbol(signature); + + if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { + signature.hasVarArgs = true; + } + + var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); + + var typeParameters = functionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { + var declKind = functionExpressionDeclaration.kind; + var declFlags = functionExpressionDeclaration.flags; + var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); + + 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + functionTypeSymbol.setFunctionSymbol(functionSymbol); + + functionSymbol.type = functionTypeSymbol; + + functionExpressionDeclaration.setSymbol(functionSymbol); + functionSymbol.addDeclaration(functionExpressionDeclaration); + functionTypeSymbol.addDeclaration(functionExpressionDeclaration); + + var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; + if (name) { + this.semanticInfoChain.setSymbolForAST(name, functionSymbol); + } + + this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); + + if (parameters.lastParameterIsRest()) { + signature.hasVarArgs = true; + } + + var typeParameters = functionExpressionDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionExpressionDeclaration); + functionExpressionDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { + var declKind = functionTypeDeclaration.kind; + var declFlags = functionTypeDeclaration.flags; + var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); + + var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + + functionTypeDeclaration.setSymbol(functionTypeSymbol); + functionTypeSymbol.addDeclaration(functionTypeDeclaration); + this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = functionTypeDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = signature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + signature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(functionTypeDeclaration); + functionTypeDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); + + functionTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { + var declKind = methodDeclaration.kind; + var declFlags = methodDeclaration.flags; + var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); + + var isPrivate = (declFlags & 2 /* Private */) !== 0; + var isStatic = (declFlags & 16 /* Static */) !== 0; + var isOptional = (declFlags & 128 /* Optional */) !== 0; + + var methodName = methodDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(methodDeclaration, true); + var parentHadSymbol = false; + + var methodSymbol = null; + var methodTypeSymbol = null; + + if (parent.isClass() && isStatic) { + parent = parent.getConstructorMethod().type; + } + + methodSymbol = parent.findMember(methodName, false); + + if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); + methodSymbol = null; + } + + if (methodSymbol) { + methodTypeSymbol = methodSymbol.type; + parentHadSymbol = true; + } + + if (!methodSymbol) { + methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); + } + + if (!methodTypeSymbol) { + methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + methodSymbol.type = methodTypeSymbol; + methodTypeSymbol.setFunctionSymbol(methodSymbol); + } + + methodDeclaration.setSymbol(methodSymbol); + methodSymbol.addDeclaration(methodDeclaration); + methodTypeSymbol.addDeclaration(methodDeclaration); + + var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; + + TypeScript.Debug.assert(nameAST); + + this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); + this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); + + if (isOptional) { + methodSymbol.isOptional = true; + } + + if (!parentHadSymbol) { + parent.addMember(methodSymbol); + } + + var sigKind = 1048576 /* CallSignature */; + + var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); + + var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); + if (TypeScript.lastParameterIsRest(parameterList)) { + signature.hasVarArgs = true; + } + + var typeParameters = methodDeclaration.getTypeParameters(); + var typeParameter; + var typeParameterName; + var typeParameterAST; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameterName = typeParameters[i].name; + typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); + + typeParameter = signature.findTypeParameter(typeParameterName); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); + signature.addTypeParameter(typeParameter); + } else { + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + signature.addDeclaration(methodDeclaration); + methodDeclaration.setSignatureSymbol(signature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); + methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { + var prototypeStr = "prototype"; + + var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); + if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { + 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], this.semanticInfoChain); + + prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); + prototypeSymbol.setIsSynthesized(); + prototypeSymbol.addDeclaration(prototypeDecl); + prototypeSymbol.type = classTypeSymbol; + constructorTypeSymbol.addMember(prototypeSymbol); + + if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { + var resolver = this.semanticInfoChain.getResolver(); + prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); + } + prototypeSymbol.setResolved(); + } + }; + + PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { + var declKind = constructorDeclaration.kind; + var declFlags = constructorDeclaration.flags; + var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); + + var constructorName = constructorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + + var parent = this.getParent(constructorDeclaration, true); + + var parentHadSymbol = false; + + var constructorSymbol = parent.getConstructorMethod(); + var constructorTypeSymbol = null; + + if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { + var hasDefinitionSignature = false; + var constructorSigs = constructorSymbol.type.getConstructSignatures(); + + for (var i = 0; i < constructorSigs.length; i++) { + if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { + hasDefinitionSignature = true; + break; + } + } + + if (hasDefinitionSignature) { + this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); + + constructorSymbol = null; + } + } + + if (constructorSymbol) { + constructorTypeSymbol = constructorSymbol.type; + } else { + constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); + constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); + } + + parent.setConstructorMethod(constructorSymbol); + constructorSymbol.type = constructorTypeSymbol; + + constructorDeclaration.setSymbol(constructorSymbol); + constructorSymbol.addDeclaration(constructorDeclaration); + constructorTypeSymbol.addDeclaration(constructorDeclaration); + constructorSymbol.setIsSynthesized(false); + this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); + constructSignature.returnType = parent; + constructSignature.addTypeParametersFromReturnType(); + + constructSignature.addDeclaration(constructorDeclaration); + constructorDeclaration.setSignatureSymbol(constructSignature); + + this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + constructorTypeSymbol.appendConstructSignature(constructSignature); + }; + + PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { + var parent = this.getParent(constructSignatureDeclaration, true); + var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + + var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); + + if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { + constructSignature.hasVarArgs = true; + } + + var typeParameters = constructSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + constructSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + constructSignature.addDeclaration(constructSignatureDeclaration); + constructSignatureDeclaration.setSignatureSymbol(constructSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); + parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { + var parent = this.getParent(callSignatureDeclaration, true); + var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + + var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); + + if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { + callSignature.hasVarArgs = true; + } + + var typeParameters = callSignatureDeclaration.getTypeParameters(); + var typeParameter; + + for (var i = 0; i < typeParameters.length; i++) { + typeParameter = callSignature.findTypeParameter(typeParameters[i].name); + + if (!typeParameter) { + typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); + + callSignature.addTypeParameter(typeParameter); + } else { + var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); + this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); + } + + typeParameter.addDeclaration(typeParameters[i]); + typeParameters[i].setSymbol(typeParameter); + } + + callSignature.addDeclaration(callSignatureDeclaration); + callSignatureDeclaration.setSignatureSymbol(callSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); + + var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); + parent.insertCallSignatureAtIndex(callSignature, signatureIndex); + }; + + PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { + var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); + + indexSignature.addDeclaration(indexSignatureDeclaration); + indexSignatureDeclaration.setSignatureSymbol(indexSignature); + + var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); + this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); + + this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); + + var parent = this.getParent(indexSignatureDeclaration); + parent.addIndexSignature(indexSignature); + indexSignature.setContainer(parent); + }; + + PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { + var declKind = getAccessorDeclaration.kind; + var declFlags = getAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = getAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(getAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var getterSymbol = null; + var getterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + getterSymbol = accessorSymbol.getGetter(); + + if (getterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + getterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + } + + if (accessorSymbol && getterSymbol) { + getterTypeSymbol = getterSymbol.type; + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!getterSymbol) { + getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + getterTypeSymbol.setFunctionSymbol(getterSymbol); + + getterSymbol.type = getterTypeSymbol; + + accessorSymbol.setGetter(getterSymbol); + } + + getAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(getAccessorDeclaration); + getterSymbol.addDeclaration(getAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(getAccessorDeclaration); + getAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); + + getterTypeSymbol.appendCallSignature(signature); + }; + + PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { + var declKind = setAccessorDeclaration.kind; + var declFlags = setAccessorDeclaration.flags; + var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); + + var isExported = (declFlags & 1 /* Exported */) !== 0; + + var funcName = setAccessorDeclaration.name; + + var isSignature = (declFlags & 2048 /* Signature */) !== 0; + var isStatic = false; + + if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { + isStatic = true; + } + + var parent = this.getParent(setAccessorDeclaration, true); + var parentHadSymbol = false; + + var accessorSymbol = null; + var setterSymbol = null; + var setterTypeSymbol = null; + + if (isStatic) { + parent = parent.getConstructorMethod().type; + } + + accessorSymbol = parent.findMember(funcName, false); + + if (accessorSymbol) { + if (!accessorSymbol.isAccessor()) { + this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); + accessorSymbol = null; + } else { + setterSymbol = accessorSymbol.getSetter(); + + if (setterSymbol) { + this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); + accessorSymbol = null; + setterSymbol = null; + } + } + } + + if (accessorSymbol) { + parentHadSymbol = true; + + if (setterSymbol) { + setterTypeSymbol = setterSymbol.type; + } + } + + if (!accessorSymbol) { + accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); + } + + if (!setterSymbol) { + setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); + setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); + setterTypeSymbol.setFunctionSymbol(setterSymbol); + + setterSymbol.type = setterTypeSymbol; + + accessorSymbol.setSetter(setterSymbol); + } + + setAccessorDeclaration.setSymbol(accessorSymbol); + accessorSymbol.addDeclaration(setAccessorDeclaration); + setterSymbol.addDeclaration(setAccessorDeclaration); + + var nameAST = funcDeclAST.propertyName; + this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); + this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); + + if (!parentHadSymbol) { + parent.addMember(accessorSymbol); + } + + var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); + + signature.addDeclaration(setAccessorDeclaration); + setAccessorDeclaration.setSignatureSymbol(signature); + + this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { + this.bindAllDeclsToPullSymbol(decl); + } + }; + + 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) { + case 1 /* Script */: + var childDecls = decl.getChildDecls(); + for (var i = 0; i < childDecls.length; i++) { + this.bindDeclToPullSymbol(childDecls[i]); + } + break; + + case 64 /* Enum */: + this.bindEnumDeclarationToPullSymbol(decl); + break; + + case 32 /* DynamicModule */: + case 4 /* Container */: + this.bindModuleDeclarationToPullSymbol(decl); + break; + + case 16 /* Interface */: + this.bindInterfaceDeclarationToPullSymbol(decl); + break; + + case 8 /* Class */: + this.bindClassDeclarationToPullSymbol(decl); + break; + + case 16384 /* Function */: + this.bindFunctionDeclarationToPullSymbol(decl); + break; + + case 512 /* Variable */: + this.bindVariableDeclarationToPullSymbol(decl); + break; + + case 1024 /* CatchVariable */: + this.bindCatchVariableToPullSymbol(decl); + break; + + case 67108864 /* EnumMember */: + this.bindEnumMemberDeclarationToPullSymbol(decl); + break; + + case 4096 /* Property */: + this.bindPropertyDeclarationToPullSymbol(decl); + break; + + case 65536 /* Method */: + this.bindMethodDeclarationToPullSymbol(decl); + break; + + case 32768 /* ConstructorMethod */: + this.bindConstructorDeclarationToPullSymbol(decl); + break; + + case 1048576 /* CallSignature */: + this.bindCallSignatureDeclarationToPullSymbol(decl); + break; + + case 2097152 /* ConstructSignature */: + this.bindConstructSignatureDeclarationToPullSymbol(decl); + break; + + case 4194304 /* IndexSignature */: + this.bindIndexSignatureDeclarationToPullSymbol(decl); + break; + + case 262144 /* GetAccessor */: + this.bindGetAccessorDeclarationToPullSymbol(decl); + break; + + case 524288 /* SetAccessor */: + this.bindSetAccessorDeclarationToPullSymbol(decl); + break; + + case 8388608 /* ObjectType */: + this.bindObjectTypeDeclarationToPullSymbol(decl); + break; + + case 16777216 /* FunctionType */: + this.bindFunctionTypeDeclarationToPullSymbol(decl); + break; + + case 33554432 /* ConstructorType */: + this.bindConstructorTypeDeclarationToPullSymbol(decl); + break; + + case 131072 /* FunctionExpression */: + this.bindFunctionExpressionToPullSymbol(decl); + break; + + case 128 /* TypeAlias */: + this.bindImportDeclaration(decl); + break; + + case 2048 /* Parameter */: + case 8192 /* TypeParameter */: + decl.getParentDecl().getSymbol(); + break; + + case 268435456 /* CatchBlock */: + case 134217728 /* WithBlock */: + break; + + default: + TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); + } + + TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); + this.declsBeingBound.pop(); + }; + return PullSymbolBinder; + })(); + TypeScript.PullSymbolBinder = PullSymbolBinder; +})(TypeScript || (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(); + + if (!funcSymbol) { + funcSymbol = functionDecl.getSignatureSymbol(); + } + + var functionSignature = null; + var typeSymbolWithAllSignatures = null; + if (funcSymbol.isSignature()) { + functionSignature = funcSymbol; + var parent = functionDecl.getParentDecl(); + typeSymbolWithAllSignatures = parent.getSymbol().type; + } else { + functionSignature = functionDecl.getSignatureSymbol(); + typeSymbolWithAllSignatures = funcSymbol.type; + } + var signatures; + + if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { + signatures = typeSymbolWithAllSignatures.getConstructSignatures(); + } else if (functionDecl.kind === 4194304 /* IndexSignature */) { + signatures = typeSymbolWithAllSignatures.getIndexSignatures(); + } else { + signatures = typeSymbolWithAllSignatures.getCallSignatures(); + } + + return { + signature: functionSignature, + allSignatures: signatures + }; + } + PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; + + function getAccessorSymbol(getterOrSetter, semanticInfoChain) { + var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); + var getterOrSetterSymbol = functionDecl.getSymbol(); + + return getterOrSetterSymbol; + } + PullHelpers.getAccessorSymbol = getAccessorSymbol; + + function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { + var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); + var result = { + getter: null, + setter: null + }; + var getter = accessorSymbol.getGetter(); + if (getter) { + var getterDecl = getter.getDeclarations()[0]; + result.getter = semanticInfoChain.getASTForDecl(getterDecl); + } + var setter = accessorSymbol.getSetter(); + if (setter) { + var setterDecl = setter.getDeclarations()[0]; + result.setter = semanticInfoChain.getASTForDecl(setterDecl); + } + + return result; + } + PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; + + function symbolIsEnum(source) { + return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; + } + PullHelpers.symbolIsEnum = symbolIsEnum; + + function symbolIsModule(symbol) { + return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); + } + PullHelpers.symbolIsModule = symbolIsModule; + + function isOneDeclarationOfKind(symbol, kind) { + var decls = symbol.getDeclarations(); + for (var i = 0; i < decls.length; i++) { + if (decls[i].kind === kind) { + return true; + } + } + + return false; + } + + function isNameNumeric(name) { + return isFinite(+name); + } + PullHelpers.isNameNumeric = isNameNumeric; + + function typeSymbolsAreIdentical(a, b) { + if (a.isTypeReference() && !a.getIsSpecialized()) { + a = a.referencedTypeSymbol; + } + + if (b.isTypeReference() && !b.getIsSpecialized()) { + b = b.referencedTypeSymbol; + } + + return a === b; + } + PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; + + function getRootType(type) { + var rootType = type.getRootSymbol(); + + while (true) { + if (type === rootType) { + return type; + } + + type = rootType; + rootType = type.getRootSymbol(); + } + } + PullHelpers.getRootType = getRootType; + + function isSymbolLocal(symbol) { + var container = symbol.getContainer(); + if (container) { + var containerKind = container.kind; + if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { + return true; + } + + if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { + return true; + } + } + + 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; + +var TypeScript; +(function (TypeScript) { + TypeScript.fileResolutionTime = 0; + TypeScript.fileResolutionIOTime = 0; + TypeScript.fileResolutionScanImportsTime = 0; + TypeScript.fileResolutionImportFileSearchTime = 0; + TypeScript.fileResolutionGetDefaultLibraryTime = 0; + TypeScript.sourceCharactersCompiled = 0; + TypeScript.syntaxTreeParseTime = 0; + TypeScript.syntaxDiagnosticsTime = 0; + TypeScript.astTranslationTime = 0; + TypeScript.typeCheckTime = 0; + + TypeScript.compilerResolvePathTime = 0; + TypeScript.compilerDirectoryNameTime = 0; + TypeScript.compilerDirectoryExistsTime = 0; + TypeScript.compilerFileExistsTime = 0; + + TypeScript.emitTime = 0; + TypeScript.emitWriteFileTime = 0; + + TypeScript.declarationEmitTime = 0; + TypeScript.declarationEmitIsExternallyVisibleTime = 0; + TypeScript.declarationEmitTypeSignatureTime = 0; + TypeScript.declarationEmitGetBoundDeclTypeTime = 0; + TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; + TypeScript.declarationEmitGetBaseTypeTime = 0; + TypeScript.declarationEmitGetAccessorFunctionTime = 0; + TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; + TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; + + TypeScript.ioHostResolvePathTime = 0; + TypeScript.ioHostDirectoryNameTime = 0; + 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(emitOutputResult) { + if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } + this.outputFiles = []; + this.emitOutputResult = emitOutputResult; + } + return EmitOutput; + })(); + TypeScript.EmitOutput = EmitOutput; + + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); + var OutputFileType = TypeScript.OutputFileType; + + var OutputFile = (function () { + function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { + if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } + this.name = name; + this.writeByteOrderMark = writeByteOrderMark; + this.text = text; + this.fileType = fileType; + this.sourceMapEntries = sourceMapEntries; + } + return OutputFile; + })(); + TypeScript.OutputFile = OutputFile; + + var CompileResult = (function () { + function CompileResult() { + this.diagnostics = []; + this.outputFiles = []; + } + CompileResult.fromDiagnostics = function (diagnostics) { + var result = new CompileResult(); + result.diagnostics = diagnostics; + return result; + }; + + CompileResult.fromOutputFiles = function (outputFiles) { + var result = new CompileResult(); + result.outputFiles = outputFiles; + return result; + }; + return CompileResult; + })(); + TypeScript.CompileResult = CompileResult; + + var TypeScriptCompiler = (function () { + function TypeScriptCompiler(logger, _settings) { + if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } + if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } + this.logger = logger; + this._settings = _settings; + this.semanticInfoChain = null; + this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); + } + TypeScriptCompiler.prototype.compilationSettings = function () { + return this._settings; + }; + + TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { + var oldSettings = this._settings; + this._settings = newSettings; + + if (!compareDataObjects(oldSettings, newSettings)) { + this.semanticInfoChain.invalidate(oldSettings, newSettings); + } + }; + + TypeScriptCompiler.prototype.getDocument = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.semanticInfoChain.getDocument(fileName); + }; + + TypeScriptCompiler.prototype.cleanupSemanticCache = function () { + this.semanticInfoChain.invalidate(); + }; + + TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { + if (typeof referencedFiles === "undefined") { referencedFiles = []; } + fileName = TypeScript.switchToForwardSlashes(fileName); + + TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); + + var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); + + this.semanticInfoChain.addDocument(document); + }; + + TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); + + this.semanticInfoChain.addDocument(updatedDocument); + }; + + TypeScriptCompiler.prototype.removeFile = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + this.semanticInfoChain.removeDocument(fileName); + }; + + TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { + if (document.emitToOwnOutputFile()) { + var updatedFileName = document.fileName; + if (emitOptions.outputDirectory() !== "") { + updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); + updatedFileName = emitOptions.outputDirectory() + updatedFileName; + } + return extensionChanger(updatedFileName, false); + } else { + return extensionChanger(emitOptions.sharedOutputFile(), true); + } + }; + + TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { + var printReason = false; + + if (document.emitToOwnOutputFile()) { + var result = document.byteOrderMark !== 0 /* None */; + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + } + return result; + } else { + var fileNames = this.fileNames(); + + var result = false; + for (var i = 0, n = fileNames.length; i < n; i++) { + var document = this.getDocument(fileNames[i]); + + if (document.isExternalModule()) { + continue; + } + + if (document.byteOrderMark !== 0 /* None */) { + if (printReason) { + TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); + result = true; + } else { + return true; + } + } + } + + return result; + } + }; + + TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScript.getDeclareFilePath(fileName); + }; + + TypeScriptCompiler.prototype._shouldEmit = function (document) { + return !document.isDeclareFile(); + }; + + TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { + if (!this.compilationSettings().generateDeclarationFiles()) { + return false; + } + + return this._shouldEmit(document); + }; + + TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); + + if (declarationEmitter) { + declarationEmitter.document = document; + } else { + var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); + declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); + } + + declarationEmitter.emitDeclarations(sourceUnit); + return declarationEmitter; + }; + + TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmitDeclarations(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFile()); + } + } else { + sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var sharedEmitter = null; + var fileNames = this.fileNames(); + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileNames[i]); + + sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); + } + + TypeScript.declarationEmitTime += new Date().getTime() - start; + + return emitOutput; + }; + + TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocumentDeclarations(document, emitOptions, function (file) { + return emitOutput.outputFiles.push(file); + }, null); + return emitOutput; + } else { + return this.emitAllDeclarations(resolvePath); + } + }; + + 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; + } else { + var splitFname = fileName.split("."); + splitFname.pop(); + return splitFname.join(".") + extension; + } + }; + + TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { + return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); + }; + + TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { + var sourceUnit = document.sourceUnit(); + TypeScript.Debug.assert(this._shouldEmit(document)); + + var typeScriptFileName = document.fileName; + if (!emitter) { + var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); + var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); + + emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); + + if (this.compilationSettings().mapSourceFiles()) { + var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); + emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); + } + } else if (this.compilationSettings().mapSourceFiles()) { + emitter.setSourceMapperNewSourceFile(document); + } + + emitter.setDocument(document); + emitter.emitJavascript(sourceUnit, false); + + return emitter; + }; + + TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { + if (this._shouldEmit(document)) { + if (document.emitToOwnOutputFile()) { + var singleEmitter = this.emitDocumentWorker(document, emitOptions); + if (singleEmitter) { + onSingleFileEmitComplete(singleEmitter.getOutputFiles()); + } + } else { + sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); + } + } + + return sharedEmitter; + }; + + TypeScriptCompiler.prototype.emitAll = function (resolvePath) { + var start = new Date().getTime(); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var fileNames = this.fileNames(); + var sharedEmitter = null; + + for (var i = 0, n = fileNames.length; i < n; i++) { + var fileName = fileNames[i]; + + var document = this.getDocument(fileName); + + sharedEmitter = this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, sharedEmitter); + } + + if (sharedEmitter) { + emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); + } + + TypeScript.emitTime += new Date().getTime() - start; + return emitOutput; + }; + + TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { + fileName = TypeScript.switchToForwardSlashes(fileName); + var emitOutput = new EmitOutput(); + + var emitOptions = new TypeScript.EmitOptions(this, resolvePath); + if (emitOptions.diagnostic()) { + emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; + return emitOutput; + } + + var document = this.getDocument(fileName); + + if (document.emitToOwnOutputFile()) { + this._emitDocument(document, emitOptions, function (files) { + return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); + }, null); + return emitOutput; + } else { + return this.emitAll(resolvePath); + } + }; + + TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { + if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } + return new CompilerIterator(this, resolvePath, continueOnDiagnostics); + }; + + TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + return this.getDocument(fileName).diagnostics(); + }; + + TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { + return this.getDocument(fileName).syntaxTree(); + }; + + TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { + return this.getDocument(fileName).sourceUnit(); + }; + + TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { + fileName = TypeScript.switchToForwardSlashes(fileName); + + var document = this.getDocument(fileName); + + var startTime = (new Date()).getTime(); + TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); + var endTime = (new Date()).getTime(); + + TypeScript.typeCheckTime += endTime - startTime; + + var errors = this.semanticInfoChain.getDiagnostics(fileName); + + errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); + errors.sort(function (d1, d2) { + if (d1.fileName() < d2.fileName()) { + return -1; + } else if (d1.fileName() > d2.fileName()) { + return 1; + } + + if (d1.start() < d2.start()) { + return -1; + } else if (d1.start() > d2.start()) { + return 1; + } + + var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; + var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; + if (code1 < code2) { + return -1; + } else if (code1 > code2) { + return 1; + } + + return 0; + }); + + 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++) { + this.getSemanticDiagnostics(fileNames[i]); + } + }; + + TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { + if (!decl) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var ast = this.semanticInfoChain.getASTForDecl(decl); + if (!ast) { + return null; + } + + var enclosingDecl = resolver.getEnclosingDecl(decl); + if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { + return this.getSymbolOfDeclaration(enclosingDecl); + } + + return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); + }; + + TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { + var scriptName = document.fileName; + + var enclosingDecl = null; + var enclosingDeclAST = null; + var inContextuallyTypedAssignment = false; + var inWithBlock = false; + + var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); + + if (!ast) { + return null; + } + + var path = this.getASTPath(ast); + + for (var i = 0, n = path.length; i < n; i++) { + var current = path[i]; + + switch (current.kind()) { + case 222 /* FunctionExpression */: + case 219 /* SimpleArrowFunctionExpression */: + case 218 /* ParenthesizedArrowFunctionExpression */: + if (propagateContextualTypes) { + resolver.resolveAST(current, true, resolutionContext); + } + break; + + case 136 /* MemberVariableDeclaration */: + var memberVariable = current; + inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); + break; + + case 225 /* VariableDeclarator */: + var variableDeclarator = current; + inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; + + this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); + break; + + case 213 /* InvocationExpression */: + case 216 /* ObjectCreationExpression */: + if (propagateContextualTypes) { + var isNew = current.kind() === 216 /* ObjectCreationExpression */; + var callExpression = current; + var contextualType = null; + + if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); + } + + if (callResolutionResults.actualParametersContextTypeSymbols) { + var argExpression = path[i + 3]; + if (argExpression) { + for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { + if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { + var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; + if (callContextualType) { + contextualType = callContextualType; + break; + } + } + } + } + } + } else { + if (isNew) { + resolver.resolveObjectCreationExpression(callExpression, resolutionContext); + } else { + resolver.resolveInvocationExpression(callExpression, resolutionContext); + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 214 /* ArrayLiteralExpression */: + if (propagateContextualTypes) { + var contextualType = null; + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { + contextualType = currentContextualType.getElementType(); + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 215 /* ObjectLiteralExpression */: + if (propagateContextualTypes) { + var objectLiteralExpression = current; + var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); + resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); + + var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; + if (memeberAST) { + var contextualType = null; + var memberDecls = objectLiteralExpression.propertyAssignments; + if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { + for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { + if (memberDecls.nonSeparatorAt(j) === memeberAST) { + var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; + if (memberContextualType) { + contextualType = memberContextualType; + break; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + } + + break; + + case 174 /* AssignmentExpression */: + if (propagateContextualTypes) { + var assignmentExpression = current; + var contextualType = null; + + if (path[i + 1] && path[i + 1] === assignmentExpression.right) { + var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; + if (leftType) { + inContextuallyTypedAssignment = true; + contextualType = leftType; + } + } + + 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; + + case 150 /* ReturnStatement */: + if (propagateContextualTypes) { + var returnStatement = current; + var contextualType = null; + + if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { + var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); + if (typeAnnotation) { + var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); + if (returnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = returnTypeSymbol; + } + } else { + var currentContextualType = resolutionContext.getContextualType(); + if (currentContextualType && currentContextualType.isFunction()) { + var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); + var currentContextualTypeSignatureSymbol = contextualSignatures[0]; + var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; + if (currentContextualTypeReturnTypeSymbol) { + inContextuallyTypedAssignment = true; + contextualType = currentContextualTypeReturnTypeSymbol; + } + } + } + } + + resolutionContext.pushNewContextualType(contextualType); + } + + break; + + case 122 /* ObjectType */: + if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { + resolver.resolveAST(current, false, resolutionContext); + } + + break; + + case 163 /* WithStatement */: + inWithBlock = true; + break; + + case 146 /* Block */: + inContextuallyTypedAssignment = false; + break; + } + + var decl = this.semanticInfoChain.getDeclForAST(current); + if (decl) { + enclosingDecl = decl; + enclosingDeclAST = current; + } + } + + if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { + if (ast.parent.kind() === 212 /* MemberAccessExpression */) { + if (ast.parent.name === ast) { + ast = ast.parent; + } + } else if (ast.parent.kind() === 121 /* QualifiedName */) { + if (ast.parent.right === ast) { + ast = ast.parent; + } + } + } + + return { + ast: ast, + enclosingDecl: enclosingDecl, + resolutionContext: resolutionContext, + inContextuallyTypedAssignment: inContextuallyTypedAssignment, + inWithBlock: inWithBlock + }; + }; + + TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { + if (inContextuallyTypedAssignment) { + if (propagateContextualTypes) { + resolver.resolveAST(assigningAST, false, resolutionContext); + var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); + + var contextualType = null; + if (varSymbol && inContextuallyTypedAssignment) { + contextualType = varSymbol.type; + } + + resolutionContext.pushNewContextualType(contextualType); + + if (init) { + resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); + } + } + } + }; + + TypeScriptCompiler.prototype.getASTPath = function (ast) { + var result = []; + + while (ast) { + result.unshift(ast); + ast = ast.parent; + } + + return result; + }; + + TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + ast = context.ast; + 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()]); + return null; + } + + if (symbol.isTypeReference()) { + symbol = symbol.getReferencedTypeSymbol(); + } + + var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); + + return { + symbol: symbol, + aliasSymbol: aliasSymbol, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { + if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { + return null; + } + + var isNew = ast.kind() === 216 /* ObjectCreationExpression */; + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); + + if (isNew) { + resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); + } else { + resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); + } + + return { + targetSymbol: callResolutionResults.targetSymbol, + resolvedSignatures: callResolutionResults.resolvedSignatures, + candidateSignature: callResolutionResults.candidateSignature, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), + isConstructorCall: isNew + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); + if (!symbols) { + return null; + } + + return { + symbols: symbols, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, false); + if (!context || context.inWithBlock) { + return null; + } + + return resolver.getVisibleDecls(context.enclosingDecl); + }; + + TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { + if (ast.kind() !== 215 /* ObjectLiteralExpression */) { + return null; + } + + var resolver = this.semanticInfoChain.getResolver(); + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); + + return { + symbols: members, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { + var resolver = this.semanticInfoChain.getResolver(); + + var context = this.extractResolutionContextFromAST(resolver, ast, document, true); + if (!context || context.inWithBlock) { + return null; + } + + var astForDecl = decl.ast(); + if (!astForDecl) { + return null; + } + + var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); + if (!astForDeclContext) { + return null; + } + + var symbol = decl.getSymbol(); + resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); + symbol.setUnresolved(); + + return { + symbol: symbol, + aliasSymbol: null, + ast: ast, + enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) + }; + }; + + TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { + return this.semanticInfoChain.topLevelDecl(fileName); + }; + + TypeScriptCompiler.prototype.getDeclForAST = function (ast) { + return this.semanticInfoChain.getDeclForAST(ast); + }; + + TypeScriptCompiler.prototype.fileNames = function () { + return this.semanticInfoChain.fileNames(); + }; + + 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; + + var CompilerPhase; + (function (CompilerPhase) { + CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; + CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; + CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; + CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; + CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; + })(CompilerPhase || (CompilerPhase = {})); + + var CompilerIterator = (function () { + function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { + if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } + this.compiler = compiler; + this.resolvePath = resolvePath; + this.continueOnDiagnostics = continueOnDiagnostics; + this.index = -1; + this.fileNames = null; + this._current = null; + this._emitOptions = null; + this._sharedEmitter = null; + this._sharedDeclarationEmitter = null; + this.hadSyntacticDiagnostics = false; + this.hadSemanticDiagnostics = false; + this.hadEmitDiagnostics = false; + this.fileNames = compiler.fileNames(); + this.compilerPhase = startingPhase; + } + CompilerIterator.prototype.current = function () { + return this._current; + }; + + CompilerIterator.prototype.moveNext = function () { + this._current = null; + + while (this.moveNextInternal()) { + if (this._current) { + return true; + } + } + + return false; + }; + + CompilerIterator.prototype.moveNextInternal = function () { + this.index++; + + while (this.shouldMoveToNextPhase()) { + this.index = 0; + this.compilerPhase++; + } + + if (this.compilerPhase > 4 /* DeclarationEmit */) { + return false; + } + + switch (this.compilerPhase) { + case 0 /* Syntax */: + return this.moveNextSyntaxPhase(); + case 1 /* Semantics */: + return this.moveNextSemanticsPhase(); + case 2 /* EmitOptionsValidation */: + return this.moveNextEmitOptionsValidationPhase(); + case 3 /* Emit */: + return this.moveNextEmitPhase(); + case 4 /* DeclarationEmit */: + return this.moveNextDeclarationEmitPhase(); + } + }; + + CompilerIterator.prototype.shouldMoveToNextPhase = function () { + switch (this.compilerPhase) { + case 2 /* EmitOptionsValidation */: + return this.index === 1; + + case 0 /* Syntax */: + case 1 /* Semantics */: + return this.index === this.fileNames.length; + + case 3 /* Emit */: + case 4 /* DeclarationEmit */: + return this.index === (this.fileNames.length + 1); + } + + return false; + }; + + CompilerIterator.prototype.moveNextSyntaxPhase = function () { + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + + var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSyntacticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextSemanticsPhase = function () { + if (this.hadSyntacticDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); + var fileName = this.fileNames[this.index]; + var diagnostics = this.compiler.getSemanticDiagnostics(fileName); + if (diagnostics.length) { + if (!this.continueOnDiagnostics) { + this.hadSemanticDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics(diagnostics); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + + if (!this._emitOptions) { + this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); + } + + if (this._emitOptions.diagnostic()) { + if (!this.continueOnDiagnostics) { + this.hadEmitDiagnostics = true; + } + + this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); + } + + return true; + }; + + CompilerIterator.prototype.moveNextEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(this._emitOptions); + + if (this.hadEmitDiagnostics) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { + _this._current = CompileResult.fromOutputFiles(outputFiles); + }, this._sharedEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedEmitter) { + this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); + } + + return true; + }; + + CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { + var _this = this; + TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); + TypeScript.Debug.assert(!this.hadEmitDiagnostics); + if (this.hadSemanticDiagnostics) { + return false; + } + + if (!this.compiler.compilationSettings().generateDeclarationFiles()) { + return false; + } + + TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); + if (this.index < this.fileNames.length) { + var fileName = this.fileNames[this.index]; + var document = this.compiler.getDocument(fileName); + + this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { + _this._current = CompileResult.fromOutputFiles([file]); + }, this._sharedDeclarationEmitter); + return true; + } + + if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { + this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); + } + + return true; + }; + return CompilerIterator; + })(); + + function compareDataObjects(dst, src) { + for (var e in dst) { + if (typeof dst[e] === "object") { + if (!compareDataObjects(dst[e], src[e])) + return false; + } else if (typeof dst[e] !== "function") { + if (dst[e] !== src[e]) + return false; + } + } + return true; + } + TypeScript.compareDataObjects = compareDataObjects; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (GenerativeTypeClassification) { + GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; + GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; + GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; + GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; + })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); + var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; + + var PullTypeReferenceSymbol = (function (_super) { + __extends(PullTypeReferenceSymbol, _super); + function PullTypeReferenceSymbol(referencedTypeSymbol) { + _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); + this.referencedTypeSymbol = referencedTypeSymbol; + this.isResolved = true; + + TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); + + this.setRootSymbol(referencedTypeSymbol); + + this.typeReference = this; + } + PullTypeReferenceSymbol.createTypeReference = function (type) { + if (type.isTypeReference()) { + return type; + } + + var typeReference = type.typeReference; + + if (!typeReference) { + typeReference = new PullTypeReferenceSymbol(type); + type.typeReference = typeReference; + } + + return typeReference; + }; + + PullTypeReferenceSymbol.prototype.isTypeReference = function () { + return true; + }; + + PullTypeReferenceSymbol.prototype.setResolved = function () { + }; + + PullTypeReferenceSymbol.prototype.setUnresolved = function () { + }; + PullTypeReferenceSymbol.prototype.invalidate = function () { + }; + + PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { + this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); + }; + + PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol; + }; + + PullTypeReferenceSymbol.prototype._getResolver = function () { + return this.referencedTypeSymbol._getResolver(); + }; + + PullTypeReferenceSymbol.prototype.hasMembers = function () { + return this.referencedTypeSymbol.hasMembers(); + }; + + PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); + }; + + PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + return this.referencedTypeSymbol.getAssociatedContainerType(); + }; + + PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getFunctionSymbol(); + }; + PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); + }; + + PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); + }; + PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); + }; + + PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); + }; + PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); + }; + PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); + }; + PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMember(name); + }; + + PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); + }; + + PullTypeReferenceSymbol.prototype.getMembers = function () { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getMembers(); + }; + + PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { + if (typeof hasOne === "undefined") { hasOne = true; } + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); + }; + PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getHasDefaultConstructor(); + }; + PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructorMethod(); + }; + PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); + }; + PullTypeReferenceSymbol.prototype.getTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.isGeneric = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isGeneric(); + }; + + PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getSpecialization(substitutingTypes); + }; + PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getKnownSpecializations(); + }; + PullTypeReferenceSymbol.prototype.getTypeArguments = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArguments(); + }; + PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); + }; + + PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { + TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); + }; + 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"); + }; + + PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getCallSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getConstructSignatures(); + }; + PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.hasOwnIndexSignatures(); + }; + PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getIndexSignatures(); + }; + + PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { + this.referencedTypeSymbol.addImplementedType(implementedType); + }; + PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getImplementedTypes(); + }; + PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { + this.referencedTypeSymbol.addExtendedType(extendedType); + }; + PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getExtendedTypes(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExtendsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExtendThisType(); + }; + PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { + this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); + }; + PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); + }; + + PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { + this.ensureReferencedTypeIsResolved(); + return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); + }; + + PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findMember(name, lookInParent); + }; + PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedType(name, kind); + }; + PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { + if (typeof kind === "undefined") { kind = 0 /* None */; } + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findNestedContainer(name, kind); + }; + PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + }; + + PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { + this.ensureReferencedTypeIsResolved(); + + return this.referencedTypeSymbol.findTypeParameter(name); + }; + + PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { + return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); + }; + return PullTypeReferenceSymbol; + })(TypeScript.PullTypeSymbol); + TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; + + TypeScript.nSpecializationsCreated = 0; + TypeScript.nSpecializedSignaturesCreated = 0; + TypeScript.nSpecializedTypeParameterCreated = 0; + + var PullInstantiatedTypeReferenceSymbol = (function (_super) { + __extends(PullInstantiatedTypeReferenceSymbol, _super); + 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 = undefined; + this._instantiatedConstructorMethod = null; + this._instantiatedAssociatedContainerType = null; + this._isArray = undefined; + this._generativeTypeClassification = []; + + TypeScript.nSpecializationsCreated++; + } + PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { + return !this.isInstanceReferenceType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { + if (!this.isNamedTypeSymbol()) { + return 0 /* Unknown */; + } + + 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()); + } + return this._isArray; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { + if (!this.isArrayNamedTypeReference()) { + return null; + } + + var typeArguments = this.getTypeArguments(); + return typeArguments ? typeArguments[0] : null; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.getIsSpecialized()) { + return this; + } + + return this.referencedTypeSymbol; + }; + + 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); + if (instantiation) { + return instantiation; + } + + TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); + typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; + + 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; + } + } + + if (isInstanceReferenceType) { + typeParameterArgumentMap = []; + } + } + + instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); + + rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); + + return instantiation; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { + return this.getRootSymbol().isGeneric(); + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { + return this._typeParameterArgumentMap; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { + if (this.isInstanceReferenceType) { + return this.getTypeParameters(); + } + + if (this._typeArgumentReferences === undefined) { + var typeParameters = this.referencedTypeSymbol.getTypeParameters(); + + if (typeParameters.length) { + var typeArgument = null; + var typeArguments = []; + + for (var i = 0; i < typeParameters.length; i++) { + typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; + + if (!typeArgument) { + TypeScript.Debug.fail("type argument count mismatch"); + } + + if (typeArgument) { + typeArguments[typeArguments.length] = typeArgument; + } + } + + this._typeArgumentReferences = typeArguments; + } else { + this._typeArgumentReferences = null; + } + } + + return this._typeArgumentReferences; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { + 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(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getMembers(); + } + + if (!this._instantiatedMembers) { + var referencedMembers = this.referencedTypeSymbol.getMembers(); + var referencedMember = null; + var instantiatedMember = null; + + this._instantiatedMembers = []; + + for (var i = 0; i < referencedMembers.length; i++) { + referencedMember = referencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (!this._instantiatedMemberNameCache[referencedMember.name]) { + this.populateInstantiatedMemberFromReferencedMember(referencedMember); + } + + this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; + } + } + + return this._instantiatedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { + if (typeof lookInParent === "undefined") { lookInParent = true; } + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.findMember(name, lookInParent); + } + + var memberSymbol = this._instantiatedMemberNameCache[name]; + + if (!memberSymbol) { + var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); + + if (referencedMemberSymbol) { + this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); + memberSymbol = this._instantiatedMemberNameCache[name]; + } else { + memberSymbol = null; + } + } + + return memberSymbol; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + } + + var requestedMembers = []; + var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); + + if (!this._allInstantiatedMemberNameCache) { + this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); + + var members = this.getMembers(); + + for (var i = 0; i < members.length; i++) { + this._allInstantiatedMemberNameCache[members[i].name] = members[i]; + } + } + + var referencedMember = null; + var requestedMember = null; + + for (var i = 0; i < allReferencedMembers.length; i++) { + referencedMember = allReferencedMembers[i]; + + this._getResolver().resolveDeclaredSymbol(referencedMember); + + if (this._allInstantiatedMemberNameCache[referencedMember.name]) { + requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; + } else { + if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; + requestedMembers[requestedMembers.length] = referencedMember; + } else { + requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); + requestedMember.setRootSymbol(referencedMember); + + requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); + requestedMember.isOptional = referencedMember.isOptional; + + this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; + requestedMembers[requestedMembers.length] = requestedMember; + } + } + } + + return requestedMembers; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructorMethod(); + } + + 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); + } + + return this._instantiatedConstructorMethod; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { + if (!this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getAssociatedContainerType(); + } + + if (!this._instantiatedAssociatedContainerType) { + var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); + + if (referencedAssociatedContainerType) { + this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); + } + } + + return this._instantiatedAssociatedContainerType; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getCallSignatures(); + } + + if (this._instantiatedCallSignatures) { + return this._instantiatedCallSignatures; + } + + var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); + this._instantiatedCallSignatures = []; + + for (var i = 0; i < referencedCallSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); + + if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; + } else { + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); + this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedCallSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getConstructSignatures(); + } + + if (this._instantiatedConstructSignatures) { + return this._instantiatedConstructSignatures; + } + + var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); + this._instantiatedConstructSignatures = []; + + for (var i = 0; i < referencedConstructSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); + + if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; + } else { + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); + this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedConstructSignatures; + }; + + PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { + this.ensureReferencedTypeIsResolved(); + + if (this.isInstanceReferenceType) { + return this.referencedTypeSymbol.getIndexSignatures(); + } + + if (this._instantiatedIndexSignatures) { + return this._instantiatedIndexSignatures; + } + + var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); + this._instantiatedIndexSignatures = []; + + for (var i = 0; i < referencedIndexSignatures.length; i++) { + this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); + + if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; + } else { + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); + this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; + } + } + + return this._instantiatedIndexSignatures; + }; + 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) { + var SyntaxTreeToAstVisitor = (function () { + function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { + this.fileName = fileName; + this.lineMap = lineMap; + this.compilationSettings = compilationSettings; + this.position = 0; + this.previousTokenTrailingComments = null; + } + SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { + var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); + return syntaxTree.sourceUnit().accept(visitor); + }; + + SyntaxTreeToAstVisitor.prototype.movePast = function (element) { + if (element !== null) { + this.position += element.fullWidth(); + } + }; + + SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { + if (element2 !== null) { + this.position += TypeScript.Syntax.childOffset(element1, element2); + } + }; + + SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { + var firstToken = node.firstToken(); + var lastToken = node.lastToken(); + + this.setSpan(ast, fullStart, node, firstToken, lastToken); + ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); + ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); + }; + + SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { + if (element === null) { + return null; + } + + if (element.fullWidth() === 0) { + return new TypeScript.ASTSpan(-1, -1); + } + + var leadingTriviaWidth = element.leadingTriviaWidth(); + var trailingTriviaWidth = element.trailingTriviaWidth(); + + var start = fullStart + leadingTriviaWidth; + var end = fullStart + element.fullWidth() - trailingTriviaWidth; + + return new TypeScript.ASTSpan(start, end); + }; + + SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { + if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } + if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } + var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; + var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; + + var desiredMinChar = fullStart + leadingTriviaWidth; + var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; + + this.setSpanExplicit(span, desiredMinChar, desiredLimChar); + + span._trailingTriviaWidth = trailingTriviaWidth; + }; + + SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + span._start = start; + span._end = end; + }; + + SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { + var start = this.position; + var array = new Array(node.childCount()); + + for (var i = 0, n = node.childCount(); i < n; i++) { + array[i] = node.childAt(i).accept(this); + } + + var result = new TypeScript.ISyntaxList2(this.fileName, array); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var start = this.position; + var array = new Array(list.nonSeparatorCount()); + + for (var i = 0, n = list.childCount(); i < n; i++) { + if (i % 2 === 0) { + array[i / 2] = list.childAt(i).accept(this); + this.previousTokenTrailingComments = null; + } else { + var separatorToken = list.childAt(i); + this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); + this.movePast(separatorToken); + } + } + + var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); + this.setSpan(result, start, list); + + result.setPostComments(this.previousTokenTrailingComments); + this.previousTokenTrailingComments = null; + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { + var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); + + return comment; + }; + + SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { + var result = []; + + for (var i = 0, n = triviaList.count(); i < n; i++) { + var trivia = triviaList.syntaxTriviaAt(i); + + if (trivia.isComment()) { + var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); + result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); + } + + commentStartPosition += trivia.fullWidth(); + } + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { + if (comments1 === null) { + return comments2; + } + + if (comments2 === null) { + return comments1; + } + + return comments1.concat(comments2); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { + if (token === null) { + return null; + } + + var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; + + var previousTokenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + + return this.mergeComments(previousTokenTrailingComments, preComments); + }; + + SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { + if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(token.trailingTrivia(), commentStartPosition); + }; + + SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { + if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { + return null; + } + + return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); + }; + + SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { + return this.visitToken(token); + }; + + SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { + var fullStart = this.position; + + var result = this.visitTokenWorker(token); + + this.movePast(token); + + var start = fullStart + token.leadingTriviaWidth(); + this.setSpanExplicit(result, start, start + token.width()); + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { + switch (token.tokenKind) { + case 60 /* AnyKeyword */: + return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); + case 61 /* BooleanKeyword */: + return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); + case 67 /* NumberKeyword */: + return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); + case 69 /* StringKeyword */: + return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); + case 41 /* VoidKeyword */: + return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); + case 35 /* ThisKeyword */: + return new TypeScript.ThisExpression(token.text(), token.valueText()); + case 50 /* SuperKeyword */: + return new TypeScript.SuperExpression(token.text(), token.valueText()); + case 37 /* TrueKeyword */: + return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); + case 24 /* FalseKeyword */: + return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); + case 32 /* NullKeyword */: + return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); + case 14 /* StringLiteral */: + return new TypeScript.StringLiteral(token.text(), token.valueText()); + case 12 /* RegularExpressionLiteral */: + return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); + case 13 /* NumericLiteral */: + var fullStart = this.position; + var preComments = this.convertTokenLeadingComments(token, fullStart); + + var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); + + result.setPreComments(preComments); + return result; + case 11 /* IdentifierName */: + return new TypeScript.Identifier(token.text()); + default: + throw TypeScript.Errors.invalidOperation(); + } + }; + + SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { + var start = this.position; + TypeScript.Debug.assert(start === 0); + + var bod = this.visitSyntaxList(node.moduleElements); + 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; + }; + + SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { + var start = this.position; + + this.moveTo(node, node.stringLiteral); + var stringLiteral = node.stringLiteral.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ExternalModuleReference(stringLiteral); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { + var start = this.position; + var moduleName = node.moduleName.accept(this); + + var result = new TypeScript.ModuleNameModuleReference(moduleName); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + this.movePast(node.openBraceToken); + var members = this.visitSyntaxList(node.classElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { + var result = null; + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { + result = result || []; + result.push(1 /* Exported */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + result = result || []; + result.push(8 /* Ambient */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { + result = result || []; + result.push(16 /* Static */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { + result = result || []; + result.push(4 /* Public */); + } + + if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { + result = result || []; + result.push(2 /* Private */); + } + + return result || TypeScript.sentinelEmptyArray; + }; + + SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; + + var body = this.visitObjectType(node.body); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { + var start = this.position; + + this.movePast(node.extendsOrImplementsKeyword); + var typeNames = this.visitSeparatedSyntaxList(node.typeNames); + + var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { + var start = this.position; + + var modifiers = this.visitModifiers(node.modifiers); + + this.moveTo(node, node.moduleKeyword); + this.movePast(node.moduleKeyword); + + var moduleName = node.name ? node.name.accept(this) : null; + var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; + + this.movePast(node.openBraceToken); + + var moduleElements = this.visitSyntaxList(node.moduleElements); + + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + this.movePast(node.openBraceToken); + + var enumElements = this.visitSeparatedSyntaxList(node.enumElements); + + this.movePast(node.closeBraceToken); + + var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { + var start = this.position; + + var memberName = this.visitToken(node.propertyName); + + var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.EnumElement(memberName, value); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.equalsToken); + var alias = node.moduleReference.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.ImportDeclaration(modifiers, name, alias); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { + var start = this.position; + + this.moveTo(node, node.identifier); + var name = this.visitIdentifier(node.identifier); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExportAssignment(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclaration); + + var declaration = node.variableDeclaration.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.VariableStatement(modifiers, declaration); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarators); + var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); + + var result = new TypeScript.VariableDeclaration(variableDecls); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { + var start = this.position; + var propertyName = this.visitToken(node.propertyName); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; + + var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { + var start = this.position; + var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); + + this.movePast(node.equalsToken); + var value = node.value.accept(this); + value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); + + var result = new TypeScript.EqualsValueClause(value); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var start = this.position; + + this.movePast(node.operatorToken); + var operand = node.operand.accept(this); + + var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var start = this.position; + var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); + this.movePast(node.openBracketToken); + + var expressions = this.visitSeparatedSyntaxList(node.expressions); + + var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayLiteralExpression(expressions); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { + var start = this.position; + + var result = new TypeScript.OmittedExpression(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var start = this.position; + + var openParenToken = node.openParenToken; + var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + + this.movePast(openParenToken); + + var expr = node.expression.accept(this); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var start = this.position; + + var identifier = node.identifier.accept(this); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var start = this.position; + + var callSignature = this.visitCallSignature(node.callSignature); + this.movePast(node.equalsGreaterThanToken); + + var block = node.block ? this.visitBlock(node.block) : null; + var expression = node.expression ? node.expression.accept(this) : null; + + var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitType = function (type) { + return type ? type.accept(this) : null; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { + var start = this.position; + this.movePast(node.typeOfKeyword); + var name = node.name.accept(this); + + var result = new TypeScript.TypeQuery(name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { + var start = this.position; + var left = this.visitType(node.left); + this.movePast(node.dotToken); + var right = this.visitIdentifier(node.right); + + var result = new TypeScript.QualifiedName(left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeArgumentList(typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { + var start = this.position; + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + this.movePast(node.equalsGreaterThanToken); + var returnType = this.visitType(node.type); + + var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { + var start = this.position; + + this.movePast(node.openBraceToken); + var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectType(typeMembers); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.type); + this.movePast(node.openBracketToken); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ArrayType(underlying); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { + var start = this.position; + + var underlying = this.visitType(node.name); + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + var result = new TypeScript.GenericType(underlying, typeArguments); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.colonToken); + var type = this.visitType(node.type); + + var result = new TypeScript.TypeAnnotation(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + this.movePast(node.openBraceToken); + var statements = this.visitSyntaxList(node.statements); + var closeBracePosition = this.position; + + var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); + var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { + var start = this.position; + + var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); + + this.moveTo(node, node.identifier); + var identifier = this.visitIdentifier(node.identifier); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; + + var modifiers = this.visitModifiers(node.modifiers); + + var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.dotToken); + var name = this.visitIdentifier(node.name); + + var result = new TypeScript.MemberAccessExpression(expression, name); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var start = this.position; + + var operand = node.operand.accept(this); + this.movePast(node.operatorToken); + + var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + this.movePast(node.openBracketToken); + var argumentExpression = node.argumentExpression.accept(this); + this.movePast(node.closeBracketToken); + + var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { + var start = this.position; + + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.InvocationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { + if (node === null) { + return null; + } + + var start = this.position; + + var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); + + this.movePast(node.openParenToken); + + 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()); + } + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { + var start = this.position; + + var left = node.left.accept(this); + this.movePast(node.operatorToken); + var right = node.right.accept(this); + + var result = new TypeScript.BinaryExpression(node.kind(), left, right); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { + var start = this.position; + + var condition = node.condition.accept(this); + this.movePast(node.questionToken); + var whenTrue = node.whenTrue.accept(this); + this.movePast(node.colonToken); + var whenFalse = node.whenFalse.accept(this); + + var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.ConstructSignature(callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + + var callSignature = this.visitCallSignature(node.callSignature); + + var result = new TypeScript.MethodSignature(name, questionToken, callSignature); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { + var start = this.position; + + this.movePast(node.openBracketToken); + + var parameter = node.parameter.accept(this); + + this.movePast(node.closeBracketToken); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.IndexSignature(parameter, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { + var start = this.position; + + var name = this.visitToken(node.propertyName); + + var questionToken = this.createTokenSpan(this.position, node.questionToken); + this.movePast(node.questionToken); + var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + + var openParenToken = node.openParenToken; + + this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); + var openParenTrailingComments = null; + if (node.parameters.childCount() === 0) { + openParenTrailingComments = this.previousTokenTrailingComments; + this.previousTokenTrailingComments = null; + } + + this.movePast(node.openParenToken); + var parameters = this.visitSeparatedSyntaxList(node.parameters); + this.movePast(node.closeParenToken); + + var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { + var start = this.position; + + var typeParameters = this.visitTypeParameterList(node.typeParameterList); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { + if (!node) { + return null; + } + + var start = this.position; + this.movePast(node.lessThanToken); + var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); + this.movePast(node.greaterThanToken); + + var result = new TypeScript.TypeParameterList(typeParameters); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + var constraint = node.constraint ? node.constraint.accept(this) : null; + + var result = new TypeScript.TypeParameter(identifier, constraint); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { + var start = this.position; + this.movePast(node.extendsKeyword); + var type = this.visitType(node.type); + + var result = new TypeScript.Constraint(type); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var thenBod = node.statement.accept(this); + var elseBod = node.elseClause ? node.elseClause.accept(this) : null; + + var result = new TypeScript.IfStatement(condition, thenBod, elseBod); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { + var start = this.position; + + this.movePast(node.elseKeyword); + var statement = node.statement.accept(this); + + var result = new TypeScript.ElseClause(statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var expression = node.expression.accept(this); + + var semicolonPosition = this.position; + + var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ExpressionStatement(expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var start = this.position; + + 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(callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.indexSignature); + var indexSignature = node.indexSignature.accept(this); + + this.movePast(node.semicolonToken); + + var result = new TypeScript.IndexMemberDeclaration(indexSignature); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? this.visitBlock(node.block) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var returnType = this.visitTypeAnnotation(node.typeAnnotation); + + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { + var start = this.position; + + this.moveTo(node, node.propertyName); + var name = this.visitToken(node.propertyName); + var parameters = this.visitParameterList(node.parameterList); + var block = node.block ? node.block.accept(this) : null; + var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var start = this.position; + + this.moveTo(node, node.variableDeclarator); + var variableDeclarator = node.variableDeclarator.accept(this); + this.movePast(node.semicolonToken); + + var modifiers = this.visitModifiers(node.modifiers); + var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { + var start = this.position; + + this.movePast(node.throwKeyword); + var expression = node.expression.accept(this); + this.movePast(node.semicolonToken); + + var result = new TypeScript.ThrowStatement(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { + var start = this.position; + + this.movePast(node.returnKeyword); + var expression = node.expression ? node.expression.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ReturnStatement(expression); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var start = this.position; + + this.movePast(node.newKeyword); + var expression = node.expression.accept(this); + var argumentList = this.visitArgumentList(node.argumentList); + + var result = new TypeScript.ObjectCreationExpression(expression, argumentList); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { + var start = this.position; + + this.movePast(node.switchKeyword); + this.movePast(node.openParenToken); + var expression = node.expression.accept(this); + + var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); + this.movePast(node.closeParenToken); + this.movePast(node.openBraceToken); + var switchClauses = this.visitSyntaxList(node.switchClauses); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.caseKeyword); + var expression = node.expression.accept(this); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.CaseSwitchClause(expression, statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var start = this.position; + + this.movePast(node.defaultKeyword); + this.movePast(node.colonToken); + var statements = this.visitSyntaxList(node.statements); + + var result = new TypeScript.DefaultSwitchClause(statements); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { + var start = this.position; + + this.movePast(node.breakKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.BreakStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { + var start = this.position; + + this.movePast(node.continueKeyword); + var identifier = node.identifier ? node.identifier.accept(this) : null; + this.movePast(node.semicolonToken); + + var result = new TypeScript.ContinueStatement(identifier); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var initializer = node.initializer ? node.initializer.accept(this) : null; + + this.movePast(node.firstSemicolonToken); + var cond = node.condition ? node.condition.accept(this) : null; + this.movePast(node.secondSemicolonToken); + var incr = node.incrementor ? node.incrementor.accept(this) : null; + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { + var start = this.position; + + this.movePast(node.forKeyword); + this.movePast(node.openParenToken); + var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; + var left = node.left ? node.left.accept(this) : null; + + this.movePast(node.inKeyword); + var expression = node.expression.accept(this); + this.movePast(node.closeParenToken); + var body = node.statement.accept(this); + + var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WhileStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { + var start = this.position; + + this.moveTo(node, node.condition); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.WithStatement(condition, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { + var start = this.position; + + this.movePast(node.lessThanToken); + var castTerm = this.visitType(node.type); + this.movePast(node.greaterThanToken); + var expression = node.expression.accept(this); + + var result = new TypeScript.CastExpression(castTerm, expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var start = this.position; + + var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); + this.movePast(node.openBraceToken); + + var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); + + var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); + this.movePast(node.closeBraceToken); + + var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var start = this.position; + + var preComments = this.convertTokenLeadingComments(node.firstToken(), start); + var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); + + var propertyName = node.propertyName.accept(this); + + var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); + + this.movePast(node.colonToken); + var expression = node.expression.accept(this); + expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); + + var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); + this.setSpan(result, start, node); + + result.setPreComments(preComments); + result.setPostComments(postComments); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var start = this.position; + + var propertyName = node.propertyName.accept(this); + var callSignature = this.visitCallSignature(node.callSignature); + var block = this.visitBlock(node.block); + + var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { + var start = this.position; + + this.movePast(node.functionKeyword); + var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); + + var callSignature = this.visitCallSignature(node.callSignature); + var block = node.block ? node.block.accept(this) : null; + + var result = new TypeScript.FunctionExpression(name, callSignature, block); + this.setCommentsAndSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { + var start = this.position; + + this.movePast(node.semicolonToken); + + var result = new TypeScript.EmptyStatement(); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { + var start = this.position; + + this.movePast(node.tryKeyword); + var tryBody = node.block.accept(this); + + var catchClause = null; + if (node.catchClause !== null) { + catchClause = node.catchClause.accept(this); + } + + var finallyBody = null; + if (node.finallyClause !== null) { + finallyBody = node.finallyClause.accept(this); + } + + var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { + var start = this.position; + + this.movePast(node.catchKeyword); + this.movePast(node.openParenToken); + var identifier = this.visitIdentifier(node.identifier); + var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); + this.movePast(node.closeParenToken); + var block = node.block.accept(this); + + var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { + var start = this.position; + this.movePast(node.finallyKeyword); + var block = node.block.accept(this); + + var result = new TypeScript.FinallyClause(block); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { + var start = this.position; + + var identifier = this.visitIdentifier(node.identifier); + this.movePast(node.colonToken); + var statement = node.statement.accept(this); + + var result = new TypeScript.LabeledStatement(identifier, statement); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { + var start = this.position; + + this.movePast(node.doKeyword); + var statement = node.statement.accept(this); + var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); + + this.movePast(node.whileKeyword); + this.movePast(node.openParenToken); + var condition = node.condition.accept(this); + this.movePast(node.closeParenToken); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DoStatement(statement, whileKeyword, condition); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { + var start = this.position; + + this.movePast(node.typeOfKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.TypeOfExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { + var start = this.position; + + this.movePast(node.deleteKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.DeleteExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { + var start = this.position; + + this.movePast(node.voidKeyword); + var expression = node.expression.accept(this); + + var result = new TypeScript.VoidExpression(expression); + this.setSpan(result, start, node); + + return result; + }; + + SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { + var start = this.position; + + this.movePast(node.debuggerKeyword); + this.movePast(node.semicolonToken); + + var result = new TypeScript.DebuggerStatement(); + this.setSpan(result, start, node); + + return result; + }; + return SyntaxTreeToAstVisitor; + })(); + TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; + + function applyDelta(ast, delta) { + if (ast) { + if (ast._start !== -1) { + ast._start += delta; + } + + if (ast._end !== -1) { + ast._end += delta; + } + } + } + + function applyDeltaToComments(comments, delta) { + if (comments && comments.length > 0) { + for (var i = 0; i < comments.length; i++) { + var comment = comments[i]; + applyDelta(comment, delta); + } + } + } + + var SyntaxTreeToIncrementalAstVisitor = (function (_super) { + __extends(SyntaxTreeToIncrementalAstVisitor, _super); + function SyntaxTreeToIncrementalAstVisitor() { + _super.apply(this, arguments); + } + SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { + if (delta === 0) { + return; + } + + var pre = function (cur) { + applyDelta(cur, delta); + applyDeltaToComments(cur.preComments(), delta); + applyDeltaToComments(cur.postComments(), delta); + + switch (cur.kind()) { + case 146 /* Block */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 226 /* ArgumentList */: + applyDelta(cur.closeParenToken, delta); + break; + + case 130 /* ModuleDeclaration */: + applyDelta(cur.endingToken, delta); + break; + + case 131 /* ClassDeclaration */: + applyDelta(cur.closeBraceToken, delta); + break; + + case 161 /* DoStatement */: + applyDelta(cur.whileKeyword, delta); + break; + + case 151 /* SwitchStatement */: + applyDelta(cur.closeParenToken, delta); + break; + } + }; + + TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { + if (span._start !== -1) { + var delta = start - span._start; + this.applyDelta(span, delta); + + span._end = end; + } else { + _super.prototype.setSpanExplicit.call(this, span, start, end); + } + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { + if (this.previousTokenTrailingComments !== null) { + return null; + } + + var result = element._ast; + if (!result) { + return null; + } + + var start = this.position; + this.movePast(element); + this.setSpan(result, start, element); + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { + element._ast = ast; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { + var result = this.getAndMovePastAST(list); + if (!result) { + result = _super.prototype.visitSeparatedSyntaxList.call(this, list); + + if (list.childCount() > 0) { + this.setAST(list, result); + } + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { + var result = this.getAndMovePastAST(token); + + if (!result) { + result = _super.prototype.visitToken.call(this, token); + this.setAST(token, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitClassDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInterfaceDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitHeritageClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitModuleDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitImportDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExportAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPrefixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitOmittedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + var result = _super.prototype.visitQualifiedName.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitArrayType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGenericType.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBlock.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPostfixUnaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitElementAccessExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitInvocationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBinaryExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConditionalExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMethodSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIndexSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitPropertySignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCallSignature.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeParameter.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitIfStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitExpressionStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitConstructorDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitGetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSetAccessor.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitMemberVariableDeclaration.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitThrowStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitReturnStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectCreationExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSwitchStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCaseSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDefaultSwitchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitBreakStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitContinueStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitForInStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWhileStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitWithStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCastExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitObjectLiteralExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitSimplePropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitFunctionExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitEmptyStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTryStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitCatchClause.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitLabeledStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDoStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitTypeOfExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDeleteExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitVoidExpression.call(this, node); + this.setAST(node, result); + } + + return result; + }; + + SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { + var result = this.getAndMovePastAST(node); + if (!result) { + result = _super.prototype.visitDebuggerStatement.call(this, node); + this.setAST(node, result); + } + + return result; + }; + return SyntaxTreeToIncrementalAstVisitor; + })(SyntaxTreeToAstVisitor); +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ASTSpan = (function () { + function ASTSpan(_start, _end) { + this._start = _start; + this._end = _end; + } + ASTSpan.prototype.start = function () { + return this._start; + }; + + ASTSpan.prototype.end = function () { + return this._end; + }; + return ASTSpan; + })(); + TypeScript.ASTSpan = ASTSpan; + + var astID = 0; + + function structuralEqualsNotIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, false); + } + TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; + + function structuralEqualsIncludingPosition(ast1, ast2) { + return structuralEquals(ast1, ast2, true); + } + TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; + + function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, false); + } + + function commentStructuralEqualsIncludingPosition(ast1, ast2) { + return commentStructuralEquals(ast1, ast2, true); + } + + function structuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); + } + + function commentStructuralEquals(ast1, ast2, includingPosition) { + if (ast1 === ast2) { + return true; + } + + return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); + } + + function astArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); + } + + function commentArrayStructuralEquals(array1, array2, includingPosition) { + return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); + } + + var AST = (function () { + function AST() { + this.parent = null; + this._start = -1; + this._end = -1; + this._trailingTriviaWidth = 0; + this._astID = astID++; + this._preComments = null; + this._postComments = null; + } + AST.prototype.syntaxID = function () { + return this._astID; + }; + + AST.prototype.start = function () { + return this._start; + }; + + AST.prototype.end = function () { + return this._end; + }; + + AST.prototype.trailingTriviaWidth = function () { + return this._trailingTriviaWidth; + }; + + AST.prototype.fileName = function () { + return this.parent.fileName(); + }; + + AST.prototype.kind = function () { + throw TypeScript.Errors.abstract(); + }; + + AST.prototype.preComments = function () { + return this._preComments; + }; + + AST.prototype.postComments = function () { + return this._postComments; + }; + + AST.prototype.setPreComments = function (comments) { + if (comments && comments.length) { + this._preComments = comments; + } else if (this._preComments) { + this._preComments = null; + } + }; + + AST.prototype.setPostComments = function (comments) { + if (comments && comments.length) { + this._postComments = comments; + } else if (this._postComments) { + this._postComments = null; + } + }; + + AST.prototype.width = function () { + return this.end() - this.start(); + }; + + AST.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); + }; + + AST.prototype.isExpression = function () { + return false; + }; + return AST; + })(); + TypeScript.AST = AST; + + var ISyntaxList2 = (function (_super) { + __extends(ISyntaxList2, _super); + function ISyntaxList2(_fileName, members) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISyntaxList2.prototype.childCount = function () { + return this.members.length; + }; + + ISyntaxList2.prototype.childAt = function (index) { + return this.members[index]; + }; + + ISyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISyntaxList2.prototype.kind = function () { + return 1 /* List */; + }; + + ISyntaxList2.prototype.firstOrDefault = function (func) { + return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.lastOrDefault = function (func) { + return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); + }; + + ISyntaxList2.prototype.any = function (func) { + return TypeScript.ArrayUtilities.any(this.members, func); + }; + + ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISyntaxList2; + })(AST); + TypeScript.ISyntaxList2 = ISyntaxList2; + + var ISeparatedSyntaxList2 = (function (_super) { + __extends(ISeparatedSyntaxList2, _super); + function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { + _super.call(this); + this._fileName = _fileName; + this.members = members; + this._separatorCount = _separatorCount; + + for (var i = 0, n = members.length; i < n; i++) { + members[i].parent = this; + } + } + ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { + return this.members.length; + }; + + ISeparatedSyntaxList2.prototype.separatorCount = function () { + return this._separatorCount; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { + return this.members[index]; + }; + + ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { + for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { + if (this.nonSeparatorAt(i) === ast) { + return i; + } + } + + return -1; + }; + + ISeparatedSyntaxList2.prototype.fileName = function () { + return this._fileName; + }; + + ISeparatedSyntaxList2.prototype.kind = function () { + return 2 /* SeparatedList */; + }; + + ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); + }; + return ISeparatedSyntaxList2; + })(AST); + TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; + + var SourceUnit = (function (_super) { + __extends(SourceUnit, _super); + function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { + _super.call(this); + this.moduleElements = moduleElements; + this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; + this._fileName = _fileName; + moduleElements && (moduleElements.parent = this); + } + SourceUnit.prototype.fileName = function () { + return this._fileName; + }; + + SourceUnit.prototype.kind = function () { + return 120 /* SourceUnit */; + }; + + SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return SourceUnit; + })(AST); + TypeScript.SourceUnit = SourceUnit; + + var Identifier = (function (_super) { + __extends(Identifier, _super); + function Identifier(_text) { + _super.call(this); + this._text = _text; + this._valueText = null; + } + Identifier.prototype.text = function () { + return this._text; + }; + Identifier.prototype.valueText = function () { + if (!this._valueText) { + var text = this._text; + if (text === "__proto__") { + this._valueText = "#__proto__"; + } else { + this._valueText = TypeScript.Syntax.massageEscapes(text); + } + } + + return this._valueText; + }; + + Identifier.prototype.kind = function () { + return 11 /* IdentifierName */; + }; + + 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; + + var LiteralExpression = (function (_super) { + __extends(LiteralExpression, _super); + function LiteralExpression(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + LiteralExpression.prototype.text = function () { + return this._text; + }; + + LiteralExpression.prototype.valueText = function () { + return this._valueText; + }; + + LiteralExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ThisExpression = (function (_super) { + __extends(ThisExpression, _super); + function ThisExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + ThisExpression.prototype.text = function () { + return this._text; + }; + + ThisExpression.prototype.valueText = function () { + return this._valueText; + }; + + ThisExpression.prototype.kind = function () { + return 35 /* ThisKeyword */; + }; + + 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; + + var SuperExpression = (function (_super) { + __extends(SuperExpression, _super); + function SuperExpression(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + SuperExpression.prototype.text = function () { + return this._text; + }; + + SuperExpression.prototype.valueText = function () { + return this._valueText; + }; + + SuperExpression.prototype.kind = function () { + return 50 /* SuperKeyword */; + }; + + 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; + + var NumericLiteral = (function (_super) { + __extends(NumericLiteral, _super); + function NumericLiteral(_value, _text, _valueText) { + _super.call(this); + this._value = _value; + this._text = _text; + this._valueText = _valueText; + } + NumericLiteral.prototype.text = function () { + return this._text; + }; + NumericLiteral.prototype.valueText = function () { + return this._valueText; + }; + NumericLiteral.prototype.value = function () { + return this._value; + }; + + NumericLiteral.prototype.kind = function () { + return 13 /* NumericLiteral */; + }; + + 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; + + var RegularExpressionLiteral = (function (_super) { + __extends(RegularExpressionLiteral, _super); + function RegularExpressionLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + } + RegularExpressionLiteral.prototype.text = function () { + return this._text; + }; + + RegularExpressionLiteral.prototype.valueText = function () { + return this._valueText; + }; + + RegularExpressionLiteral.prototype.kind = function () { + return 12 /* RegularExpressionLiteral */; + }; + + RegularExpressionLiteral.prototype.isExpression = function () { + return true; + }; + return RegularExpressionLiteral; + })(AST); + TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; + + var StringLiteral = (function (_super) { + __extends(StringLiteral, _super); + function StringLiteral(_text, _valueText) { + _super.call(this); + this._text = _text; + this._valueText = _valueText; + this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; + } + StringLiteral.prototype.text = function () { + return this._text; + }; + StringLiteral.prototype.valueText = function () { + return this._valueText; + }; + + StringLiteral.prototype.kind = function () { + return 14 /* StringLiteral */; + }; + + 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; + + var TypeAnnotation = (function (_super) { + __extends(TypeAnnotation, _super); + function TypeAnnotation(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + TypeAnnotation.prototype.kind = function () { + return 244 /* TypeAnnotation */; + }; + return TypeAnnotation; + })(AST); + TypeScript.TypeAnnotation = TypeAnnotation; + + var BuiltInType = (function (_super) { + __extends(BuiltInType, _super); + function BuiltInType(_nodeType, _text, _valueText) { + _super.call(this); + this._nodeType = _nodeType; + this._text = _text; + this._valueText = _valueText; + } + BuiltInType.prototype.text = function () { + return this._text; + }; + + BuiltInType.prototype.valueText = function () { + return this._valueText; + }; + + BuiltInType.prototype.kind = function () { + return this._nodeType; + }; + return BuiltInType; + })(AST); + TypeScript.BuiltInType = BuiltInType; + + var ExternalModuleReference = (function (_super) { + __extends(ExternalModuleReference, _super); + function ExternalModuleReference(stringLiteral) { + _super.call(this); + this.stringLiteral = stringLiteral; + stringLiteral && (stringLiteral.parent = this); + } + ExternalModuleReference.prototype.kind = function () { + return 245 /* ExternalModuleReference */; + }; + return ExternalModuleReference; + })(AST); + TypeScript.ExternalModuleReference = ExternalModuleReference; + + var ModuleNameModuleReference = (function (_super) { + __extends(ModuleNameModuleReference, _super); + function ModuleNameModuleReference(moduleName) { + _super.call(this); + this.moduleName = moduleName; + moduleName && (moduleName.parent = this); + } + ModuleNameModuleReference.prototype.kind = function () { + return 246 /* ModuleNameModuleReference */; + }; + return ModuleNameModuleReference; + })(AST); + TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; + + var ImportDeclaration = (function (_super) { + __extends(ImportDeclaration, _super); + function ImportDeclaration(modifiers, identifier, moduleReference) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.moduleReference = moduleReference; + identifier && (identifier.parent = this); + moduleReference && (moduleReference.parent = this); + } + ImportDeclaration.prototype.kind = function () { + return 133 /* ImportDeclaration */; + }; + + ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); + }; + return ImportDeclaration; + })(AST); + TypeScript.ImportDeclaration = ImportDeclaration; + + var ExportAssignment = (function (_super) { + __extends(ExportAssignment, _super); + function ExportAssignment(identifier) { + _super.call(this); + this.identifier = identifier; + identifier && (identifier.parent = this); + } + ExportAssignment.prototype.kind = function () { + return 134 /* ExportAssignment */; + }; + + ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); + }; + return ExportAssignment; + })(AST); + TypeScript.ExportAssignment = ExportAssignment; + + var TypeParameterList = (function (_super) { + __extends(TypeParameterList, _super); + function TypeParameterList(typeParameters) { + _super.call(this); + this.typeParameters = typeParameters; + typeParameters && (typeParameters.parent = this); + } + TypeParameterList.prototype.kind = function () { + return 229 /* TypeParameterList */; + }; + return TypeParameterList; + })(AST); + TypeScript.TypeParameterList = TypeParameterList; + + var ClassDeclaration = (function (_super) { + __extends(ClassDeclaration, _super); + function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.classElements = classElements; + this.closeBraceToken = closeBraceToken; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + heritageClauses && (heritageClauses.parent = this); + classElements && (classElements.parent = this); + } + ClassDeclaration.prototype.kind = function () { + return 131 /* ClassDeclaration */; + }; + + ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return ClassDeclaration; + })(AST); + TypeScript.ClassDeclaration = ClassDeclaration; + + var InterfaceDeclaration = (function (_super) { + __extends(InterfaceDeclaration, _super); + function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.typeParameterList = typeParameterList; + this.heritageClauses = heritageClauses; + this.body = body; + identifier && (identifier.parent = this); + typeParameterList && (typeParameterList.parent = this); + body && (body.parent = this); + heritageClauses && (heritageClauses.parent = this); + } + InterfaceDeclaration.prototype.kind = function () { + return 128 /* InterfaceDeclaration */; + }; + + InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); + }; + return InterfaceDeclaration; + })(AST); + TypeScript.InterfaceDeclaration = InterfaceDeclaration; + + var HeritageClause = (function (_super) { + __extends(HeritageClause, _super); + function HeritageClause(_nodeType, typeNames) { + _super.call(this); + this._nodeType = _nodeType; + this.typeNames = typeNames; + typeNames && (typeNames.parent = this); + } + HeritageClause.prototype.kind = function () { + return this._nodeType; + }; + + HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); + }; + return HeritageClause; + })(AST); + TypeScript.HeritageClause = HeritageClause; + + var ModuleDeclaration = (function (_super) { + __extends(ModuleDeclaration, _super); + function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { + _super.call(this); + this.modifiers = modifiers; + this.name = name; + this.stringLiteral = stringLiteral; + this.moduleElements = moduleElements; + this.endingToken = endingToken; + name && (name.parent = this); + stringLiteral && (stringLiteral.parent = this); + moduleElements && (moduleElements.parent = this); + } + ModuleDeclaration.prototype.kind = function () { + return 130 /* ModuleDeclaration */; + }; + + ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); + }; + return ModuleDeclaration; + })(AST); + TypeScript.ModuleDeclaration = ModuleDeclaration; + + var FunctionDeclaration = (function (_super) { + __extends(FunctionDeclaration, _super); + function FunctionDeclaration(modifiers, identifier, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionDeclaration.prototype.kind = function () { + return 129 /* FunctionDeclaration */; + }; + + FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); + }; + return FunctionDeclaration; + })(AST); + TypeScript.FunctionDeclaration = FunctionDeclaration; + + var VariableStatement = (function (_super) { + __extends(VariableStatement, _super); + function VariableStatement(modifiers, declaration) { + _super.call(this); + this.modifiers = modifiers; + this.declaration = declaration; + declaration && (declaration.parent = this); + } + VariableStatement.prototype.kind = function () { + return 148 /* VariableStatement */; + }; + + VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); + }; + return VariableStatement; + })(AST); + TypeScript.VariableStatement = VariableStatement; + + var VariableDeclaration = (function (_super) { + __extends(VariableDeclaration, _super); + function VariableDeclaration(declarators) { + _super.call(this); + this.declarators = declarators; + declarators && (declarators.parent = this); + } + VariableDeclaration.prototype.kind = function () { + return 224 /* VariableDeclaration */; + }; + + VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); + }; + return VariableDeclaration; + })(AST); + TypeScript.VariableDeclaration = VariableDeclaration; + + var VariableDeclarator = (function (_super) { + __extends(VariableDeclarator, _super); + function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + VariableDeclarator.prototype.kind = function () { + return 225 /* VariableDeclarator */; + }; + return VariableDeclarator; + })(AST); + TypeScript.VariableDeclarator = VariableDeclarator; + + var EqualsValueClause = (function (_super) { + __extends(EqualsValueClause, _super); + function EqualsValueClause(value) { + _super.call(this); + this.value = value; + value && (value.parent = this); + } + EqualsValueClause.prototype.kind = function () { + return 232 /* EqualsValueClause */; + }; + return EqualsValueClause; + })(AST); + TypeScript.EqualsValueClause = EqualsValueClause; + + var PrefixUnaryExpression = (function (_super) { + __extends(PrefixUnaryExpression, _super); + function PrefixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PrefixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ArrayLiteralExpression = (function (_super) { + __extends(ArrayLiteralExpression, _super); + function ArrayLiteralExpression(expressions) { + _super.call(this); + this.expressions = expressions; + expressions && (expressions.parent = this); + } + ArrayLiteralExpression.prototype.kind = function () { + return 214 /* ArrayLiteralExpression */; + }; + + 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; + + var OmittedExpression = (function (_super) { + __extends(OmittedExpression, _super); + function OmittedExpression() { + _super.apply(this, arguments); + } + OmittedExpression.prototype.kind = function () { + return 223 /* OmittedExpression */; + }; + + 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; + + var ParenthesizedExpression = (function (_super) { + __extends(ParenthesizedExpression, _super); + function ParenthesizedExpression(openParenTrailingComments, expression) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.expression = expression; + expression && (expression.parent = this); + } + ParenthesizedExpression.prototype.kind = function () { + return 217 /* ParenthesizedExpression */; + }; + + 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; + + var SimpleArrowFunctionExpression = (function (_super) { + __extends(SimpleArrowFunctionExpression, _super); + function SimpleArrowFunctionExpression(identifier, block, expression) { + _super.call(this); + this.identifier = identifier; + this.block = block; + this.expression = expression; + identifier && (identifier.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + SimpleArrowFunctionExpression.prototype.kind = function () { + return 219 /* SimpleArrowFunctionExpression */; + }; + + SimpleArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return SimpleArrowFunctionExpression; + })(AST); + TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; + + var ParenthesizedArrowFunctionExpression = (function (_super) { + __extends(ParenthesizedArrowFunctionExpression, _super); + function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + this.expression = expression; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + expression && (expression.parent = this); + } + ParenthesizedArrowFunctionExpression.prototype.kind = function () { + return 218 /* ParenthesizedArrowFunctionExpression */; + }; + + ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { + return true; + }; + return ParenthesizedArrowFunctionExpression; + })(AST); + TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; + + var QualifiedName = (function (_super) { + __extends(QualifiedName, _super); + function QualifiedName(left, right) { + _super.call(this); + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + QualifiedName.prototype.kind = function () { + return 121 /* QualifiedName */; + }; + + QualifiedName.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); + }; + return QualifiedName; + })(AST); + TypeScript.QualifiedName = QualifiedName; + + var ParameterList = (function (_super) { + __extends(ParameterList, _super); + function ParameterList(openParenTrailingComments, parameters) { + _super.call(this); + this.openParenTrailingComments = openParenTrailingComments; + this.parameters = parameters; + parameters && (parameters.parent = this); + } + ParameterList.prototype.kind = function () { + return 227 /* ParameterList */; + }; + return ParameterList; + })(AST); + TypeScript.ParameterList = ParameterList; + + var ConstructorType = (function (_super) { + __extends(ConstructorType, _super); + function ConstructorType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + ConstructorType.prototype.kind = function () { + return 125 /* ConstructorType */; + }; + return ConstructorType; + })(AST); + TypeScript.ConstructorType = ConstructorType; + + var FunctionType = (function (_super) { + __extends(FunctionType, _super); + function FunctionType(typeParameterList, parameterList, type) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.type = type; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + type && (type.parent = this); + } + FunctionType.prototype.kind = function () { + return 123 /* FunctionType */; + }; + return FunctionType; + })(AST); + TypeScript.FunctionType = FunctionType; + + var ObjectType = (function (_super) { + __extends(ObjectType, _super); + function ObjectType(typeMembers) { + _super.call(this); + this.typeMembers = typeMembers; + typeMembers && (typeMembers.parent = this); + } + ObjectType.prototype.kind = function () { + return 122 /* ObjectType */; + }; + + ObjectType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); + }; + return ObjectType; + })(AST); + TypeScript.ObjectType = ObjectType; + + var ArrayType = (function (_super) { + __extends(ArrayType, _super); + function ArrayType(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + ArrayType.prototype.kind = function () { + return 124 /* ArrayType */; + }; + + ArrayType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); + }; + return ArrayType; + })(AST); + TypeScript.ArrayType = ArrayType; + + var TypeArgumentList = (function (_super) { + __extends(TypeArgumentList, _super); + function TypeArgumentList(typeArguments) { + _super.call(this); + this.typeArguments = typeArguments; + typeArguments && (typeArguments.parent = this); + } + TypeArgumentList.prototype.kind = function () { + return 228 /* TypeArgumentList */; + }; + return TypeArgumentList; + })(AST); + TypeScript.TypeArgumentList = TypeArgumentList; + + var GenericType = (function (_super) { + __extends(GenericType, _super); + function GenericType(name, typeArgumentList) { + _super.call(this); + this.name = name; + this.typeArgumentList = typeArgumentList; + name && (name.parent = this); + typeArgumentList && (typeArgumentList.parent = this); + } + GenericType.prototype.kind = function () { + return 126 /* GenericType */; + }; + + GenericType.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); + }; + return GenericType; + })(AST); + TypeScript.GenericType = GenericType; + + var TypeQuery = (function (_super) { + __extends(TypeQuery, _super); + function TypeQuery(name) { + _super.call(this); + this.name = name; + name && (name.parent = this); + } + TypeQuery.prototype.kind = function () { + return 127 /* TypeQuery */; + }; + + TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); + }; + return TypeQuery; + })(AST); + TypeScript.TypeQuery = TypeQuery; + + var Block = (function (_super) { + __extends(Block, _super); + function Block(statements, closeBraceLeadingComments, closeBraceToken) { + _super.call(this); + this.statements = statements; + this.closeBraceLeadingComments = closeBraceLeadingComments; + this.closeBraceToken = closeBraceToken; + statements && (statements.parent = this); + } + Block.prototype.kind = function () { + return 146 /* Block */; + }; + + Block.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return Block; + })(AST); + TypeScript.Block = Block; + + var Parameter = (function (_super) { + __extends(Parameter, _super); + function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + _super.call(this); + this.dotDotDotToken = dotDotDotToken; + this.modifiers = modifiers; + this.identifier = identifier; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + this.equalsValueClause = equalsValueClause; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + Parameter.prototype.kind = function () { + return 242 /* Parameter */; + }; + return Parameter; + })(AST); + TypeScript.Parameter = Parameter; + + var MemberAccessExpression = (function (_super) { + __extends(MemberAccessExpression, _super); + function MemberAccessExpression(expression, name) { + _super.call(this); + this.expression = expression; + this.name = name; + expression && (expression.parent = this); + name && (name.parent = this); + } + MemberAccessExpression.prototype.kind = function () { + return 212 /* MemberAccessExpression */; + }; + + 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; + + var PostfixUnaryExpression = (function (_super) { + __extends(PostfixUnaryExpression, _super); + function PostfixUnaryExpression(_nodeType, operand) { + _super.call(this); + this._nodeType = _nodeType; + this.operand = operand; + operand && (operand.parent = this); + } + PostfixUnaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ElementAccessExpression = (function (_super) { + __extends(ElementAccessExpression, _super); + function ElementAccessExpression(expression, argumentExpression) { + _super.call(this); + this.expression = expression; + this.argumentExpression = argumentExpression; + expression && (expression.parent = this); + argumentExpression && (argumentExpression.parent = this); + } + ElementAccessExpression.prototype.kind = function () { + return 221 /* ElementAccessExpression */; + }; + + 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; + + var InvocationExpression = (function (_super) { + __extends(InvocationExpression, _super); + function InvocationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + InvocationExpression.prototype.kind = function () { + return 213 /* InvocationExpression */; + }; + + 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) { + _super.call(this); + this.typeArgumentList = typeArgumentList; + this.closeParenToken = closeParenToken; + this.arguments = _arguments; + + typeArgumentList && (typeArgumentList.parent = this); + _arguments && (_arguments.parent = this); + } + ArgumentList.prototype.kind = function () { + return 226 /* ArgumentList */; + }; + return ArgumentList; + })(AST); + TypeScript.ArgumentList = ArgumentList; + + var BinaryExpression = (function (_super) { + __extends(BinaryExpression, _super); + function BinaryExpression(_nodeType, left, right) { + _super.call(this); + this._nodeType = _nodeType; + this.left = left; + this.right = right; + left && (left.parent = this); + right && (right.parent = this); + } + BinaryExpression.prototype.kind = function () { + return this._nodeType; + }; + + 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; + + var ConditionalExpression = (function (_super) { + __extends(ConditionalExpression, _super); + function ConditionalExpression(condition, whenTrue, whenFalse) { + _super.call(this); + this.condition = condition; + this.whenTrue = whenTrue; + this.whenFalse = whenFalse; + condition && (condition.parent = this); + whenTrue && (whenTrue.parent = this); + whenFalse && (whenFalse.parent = this); + } + ConditionalExpression.prototype.kind = function () { + return 186 /* ConditionalExpression */; + }; + + 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; + + var ConstructSignature = (function (_super) { + __extends(ConstructSignature, _super); + function ConstructSignature(callSignature) { + _super.call(this); + this.callSignature = callSignature; + callSignature && (callSignature.parent = this); + } + ConstructSignature.prototype.kind = function () { + return 143 /* ConstructSignature */; + }; + return ConstructSignature; + })(AST); + TypeScript.ConstructSignature = ConstructSignature; + + var MethodSignature = (function (_super) { + __extends(MethodSignature, _super); + function MethodSignature(propertyName, questionToken, callSignature) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.callSignature = callSignature; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + } + MethodSignature.prototype.kind = function () { + return 145 /* MethodSignature */; + }; + return MethodSignature; + })(AST); + TypeScript.MethodSignature = MethodSignature; + + var IndexSignature = (function (_super) { + __extends(IndexSignature, _super); + function IndexSignature(parameter, typeAnnotation) { + _super.call(this); + this.parameter = parameter; + this.typeAnnotation = typeAnnotation; + parameter && (parameter.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + IndexSignature.prototype.kind = function () { + return 144 /* IndexSignature */; + }; + return IndexSignature; + })(AST); + TypeScript.IndexSignature = IndexSignature; + + var PropertySignature = (function (_super) { + __extends(PropertySignature, _super); + function PropertySignature(propertyName, questionToken, typeAnnotation) { + _super.call(this); + this.propertyName = propertyName; + this.questionToken = questionToken; + this.typeAnnotation = typeAnnotation; + propertyName && (propertyName.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + PropertySignature.prototype.kind = function () { + return 141 /* PropertySignature */; + }; + return PropertySignature; + })(AST); + TypeScript.PropertySignature = PropertySignature; + + var CallSignature = (function (_super) { + __extends(CallSignature, _super); + function CallSignature(typeParameterList, parameterList, typeAnnotation) { + _super.call(this); + this.typeParameterList = typeParameterList; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + typeParameterList && (typeParameterList.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + } + CallSignature.prototype.kind = function () { + return 142 /* CallSignature */; + }; + return CallSignature; + })(AST); + TypeScript.CallSignature = CallSignature; + + var TypeParameter = (function (_super) { + __extends(TypeParameter, _super); + function TypeParameter(identifier, constraint) { + _super.call(this); + this.identifier = identifier; + this.constraint = constraint; + identifier && (identifier.parent = this); + constraint && (constraint.parent = this); + } + TypeParameter.prototype.kind = function () { + return 238 /* TypeParameter */; + }; + + TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); + }; + return TypeParameter; + })(AST); + TypeScript.TypeParameter = TypeParameter; + + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint(type) { + _super.call(this); + this.type = type; + type && (type.parent = this); + } + Constraint.prototype.kind = function () { + return 239 /* Constraint */; + }; + return Constraint; + })(AST); + TypeScript.Constraint = Constraint; + + var ElseClause = (function (_super) { + __extends(ElseClause, _super); + function ElseClause(statement) { + _super.call(this); + this.statement = statement; + statement && (statement.parent = this); + } + ElseClause.prototype.kind = function () { + return 235 /* ElseClause */; + }; + + ElseClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ElseClause; + })(AST); + TypeScript.ElseClause = ElseClause; + + var IfStatement = (function (_super) { + __extends(IfStatement, _super); + function IfStatement(condition, statement, elseClause) { + _super.call(this); + this.condition = condition; + this.statement = statement; + this.elseClause = elseClause; + condition && (condition.parent = this); + statement && (statement.parent = this); + elseClause && (elseClause.parent = this); + } + IfStatement.prototype.kind = function () { + return 147 /* IfStatement */; + }; + + IfStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); + }; + return IfStatement; + })(AST); + TypeScript.IfStatement = IfStatement; + + var ExpressionStatement = (function (_super) { + __extends(ExpressionStatement, _super); + function ExpressionStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ExpressionStatement.prototype.kind = function () { + return 149 /* ExpressionStatement */; + }; + + ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ExpressionStatement; + })(AST); + TypeScript.ExpressionStatement = ExpressionStatement; + + var ConstructorDeclaration = (function (_super) { + __extends(ConstructorDeclaration, _super); + function ConstructorDeclaration(callSignature, block) { + _super.call(this); + this.callSignature = callSignature; + this.block = block; + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + ConstructorDeclaration.prototype.kind = function () { + return 137 /* ConstructorDeclaration */; + }; + return ConstructorDeclaration; + })(AST); + TypeScript.ConstructorDeclaration = ConstructorDeclaration; + + var MemberFunctionDeclaration = (function (_super) { + __extends(MemberFunctionDeclaration, _super); + function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + MemberFunctionDeclaration.prototype.kind = function () { + return 135 /* MemberFunctionDeclaration */; + }; + return MemberFunctionDeclaration; + })(AST); + TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; + + var GetAccessor = (function (_super) { + __extends(GetAccessor, _super); + function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.typeAnnotation = typeAnnotation; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + GetAccessor.prototype.kind = function () { + return 139 /* GetAccessor */; + }; + return GetAccessor; + })(AST); + TypeScript.GetAccessor = GetAccessor; + + var SetAccessor = (function (_super) { + __extends(SetAccessor, _super); + function SetAccessor(modifiers, propertyName, parameterList, block) { + _super.call(this); + this.modifiers = modifiers; + this.propertyName = propertyName; + this.parameterList = parameterList; + this.block = block; + propertyName && (propertyName.parent = this); + parameterList && (parameterList.parent = this); + block && (block.parent = this); + } + SetAccessor.prototype.kind = function () { + return 140 /* SetAccessor */; + }; + return SetAccessor; + })(AST); + TypeScript.SetAccessor = SetAccessor; + + var MemberVariableDeclaration = (function (_super) { + __extends(MemberVariableDeclaration, _super); + function MemberVariableDeclaration(modifiers, variableDeclarator) { + _super.call(this); + this.modifiers = modifiers; + this.variableDeclarator = variableDeclarator; + variableDeclarator && (variableDeclarator.parent = this); + } + MemberVariableDeclaration.prototype.kind = function () { + return 136 /* MemberVariableDeclaration */; + }; + return MemberVariableDeclaration; + })(AST); + TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; + + var IndexMemberDeclaration = (function (_super) { + __extends(IndexMemberDeclaration, _super); + function IndexMemberDeclaration(indexSignature) { + _super.call(this); + this.indexSignature = indexSignature; + indexSignature && (indexSignature.parent = this); + } + IndexMemberDeclaration.prototype.kind = function () { + return 138 /* IndexMemberDeclaration */; + }; + return IndexMemberDeclaration; + })(AST); + TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; + + var ThrowStatement = (function (_super) { + __extends(ThrowStatement, _super); + function ThrowStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ThrowStatement.prototype.kind = function () { + return 157 /* ThrowStatement */; + }; + + ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ThrowStatement; + })(AST); + TypeScript.ThrowStatement = ThrowStatement; + + var ReturnStatement = (function (_super) { + __extends(ReturnStatement, _super); + function ReturnStatement(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + ReturnStatement.prototype.kind = function () { + return 150 /* ReturnStatement */; + }; + + ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return ReturnStatement; + })(AST); + TypeScript.ReturnStatement = ReturnStatement; + + var ObjectCreationExpression = (function (_super) { + __extends(ObjectCreationExpression, _super); + function ObjectCreationExpression(expression, argumentList) { + _super.call(this); + this.expression = expression; + this.argumentList = argumentList; + expression && (expression.parent = this); + argumentList && (argumentList.parent = this); + } + ObjectCreationExpression.prototype.kind = function () { + return 216 /* ObjectCreationExpression */; + }; + + 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; + + var SwitchStatement = (function (_super) { + __extends(SwitchStatement, _super); + function SwitchStatement(expression, closeParenToken, switchClauses) { + _super.call(this); + this.expression = expression; + this.closeParenToken = closeParenToken; + this.switchClauses = switchClauses; + expression && (expression.parent = this); + switchClauses && (switchClauses.parent = this); + } + SwitchStatement.prototype.kind = function () { + return 151 /* SwitchStatement */; + }; + + SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); + }; + return SwitchStatement; + })(AST); + TypeScript.SwitchStatement = SwitchStatement; + + var CaseSwitchClause = (function (_super) { + __extends(CaseSwitchClause, _super); + function CaseSwitchClause(expression, statements) { + _super.call(this); + this.expression = expression; + this.statements = statements; + expression && (expression.parent = this); + statements && (statements.parent = this); + } + CaseSwitchClause.prototype.kind = function () { + return 233 /* CaseSwitchClause */; + }; + + CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return CaseSwitchClause; + })(AST); + TypeScript.CaseSwitchClause = CaseSwitchClause; + + var DefaultSwitchClause = (function (_super) { + __extends(DefaultSwitchClause, _super); + function DefaultSwitchClause(statements) { + _super.call(this); + this.statements = statements; + statements && (statements.parent = this); + } + DefaultSwitchClause.prototype.kind = function () { + return 234 /* DefaultSwitchClause */; + }; + + DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); + }; + return DefaultSwitchClause; + })(AST); + TypeScript.DefaultSwitchClause = DefaultSwitchClause; + + var BreakStatement = (function (_super) { + __extends(BreakStatement, _super); + function BreakStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + BreakStatement.prototype.kind = function () { + return 152 /* BreakStatement */; + }; + + BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return BreakStatement; + })(AST); + TypeScript.BreakStatement = BreakStatement; + + var ContinueStatement = (function (_super) { + __extends(ContinueStatement, _super); + function ContinueStatement(identifier) { + _super.call(this); + this.identifier = identifier; + } + ContinueStatement.prototype.kind = function () { + return 153 /* ContinueStatement */; + }; + + ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return ContinueStatement; + })(AST); + TypeScript.ContinueStatement = ContinueStatement; + + var ForStatement = (function (_super) { + __extends(ForStatement, _super); + function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.initializer = initializer; + this.condition = condition; + this.incrementor = incrementor; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + initializer && (initializer.parent = this); + condition && (condition.parent = this); + incrementor && (incrementor.parent = this); + statement && (statement.parent = this); + } + ForStatement.prototype.kind = function () { + return 154 /* ForStatement */; + }; + + ForStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForStatement; + })(AST); + TypeScript.ForStatement = ForStatement; + + var ForInStatement = (function (_super) { + __extends(ForInStatement, _super); + function ForInStatement(variableDeclaration, left, expression, statement) { + _super.call(this); + this.variableDeclaration = variableDeclaration; + this.left = left; + this.expression = expression; + this.statement = statement; + variableDeclaration && (variableDeclaration.parent = this); + left && (left.parent = this); + expression && (expression.parent = this); + statement && (statement.parent = this); + } + ForInStatement.prototype.kind = function () { + return 155 /* ForInStatement */; + }; + + ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return ForInStatement; + })(AST); + TypeScript.ForInStatement = ForInStatement; + + var WhileStatement = (function (_super) { + __extends(WhileStatement, _super); + function WhileStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WhileStatement.prototype.kind = function () { + return 158 /* WhileStatement */; + }; + + WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WhileStatement; + })(AST); + TypeScript.WhileStatement = WhileStatement; + + var WithStatement = (function (_super) { + __extends(WithStatement, _super); + function WithStatement(condition, statement) { + _super.call(this); + this.condition = condition; + this.statement = statement; + condition && (condition.parent = this); + statement && (statement.parent = this); + } + WithStatement.prototype.kind = function () { + return 163 /* WithStatement */; + }; + + WithStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return WithStatement; + })(AST); + TypeScript.WithStatement = WithStatement; + + var EnumDeclaration = (function (_super) { + __extends(EnumDeclaration, _super); + function EnumDeclaration(modifiers, identifier, enumElements) { + _super.call(this); + this.modifiers = modifiers; + this.identifier = identifier; + this.enumElements = enumElements; + identifier && (identifier.parent = this); + enumElements && (enumElements.parent = this); + } + EnumDeclaration.prototype.kind = function () { + return 132 /* EnumDeclaration */; + }; + return EnumDeclaration; + })(AST); + TypeScript.EnumDeclaration = EnumDeclaration; + + var EnumElement = (function (_super) { + __extends(EnumElement, _super); + function EnumElement(propertyName, equalsValueClause) { + _super.call(this); + this.propertyName = propertyName; + this.equalsValueClause = equalsValueClause; + propertyName && (propertyName.parent = this); + equalsValueClause && (equalsValueClause.parent = this); + } + EnumElement.prototype.kind = function () { + return 243 /* EnumElement */; + }; + return EnumElement; + })(AST); + TypeScript.EnumElement = EnumElement; + + var CastExpression = (function (_super) { + __extends(CastExpression, _super); + function CastExpression(type, expression) { + _super.call(this); + this.type = type; + this.expression = expression; + type && (type.parent = this); + expression && (expression.parent = this); + } + CastExpression.prototype.kind = function () { + return 220 /* CastExpression */; + }; + + 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; + + var ObjectLiteralExpression = (function (_super) { + __extends(ObjectLiteralExpression, _super); + function ObjectLiteralExpression(propertyAssignments) { + _super.call(this); + this.propertyAssignments = propertyAssignments; + propertyAssignments && (propertyAssignments.parent = this); + } + ObjectLiteralExpression.prototype.kind = function () { + return 215 /* ObjectLiteralExpression */; + }; + + 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; + + var SimplePropertyAssignment = (function (_super) { + __extends(SimplePropertyAssignment, _super); + function SimplePropertyAssignment(propertyName, expression) { + _super.call(this); + this.propertyName = propertyName; + this.expression = expression; + propertyName && (propertyName.parent = this); + expression && (expression.parent = this); + } + SimplePropertyAssignment.prototype.kind = function () { + return 240 /* SimplePropertyAssignment */; + }; + return SimplePropertyAssignment; + })(AST); + TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; + + var FunctionPropertyAssignment = (function (_super) { + __extends(FunctionPropertyAssignment, _super); + function FunctionPropertyAssignment(propertyName, callSignature, block) { + _super.call(this); + this.propertyName = propertyName; + this.callSignature = callSignature; + this.block = block; + propertyName && (propertyName.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionPropertyAssignment.prototype.kind = function () { + return 241 /* FunctionPropertyAssignment */; + }; + return FunctionPropertyAssignment; + })(AST); + TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; + + var FunctionExpression = (function (_super) { + __extends(FunctionExpression, _super); + function FunctionExpression(identifier, callSignature, block) { + _super.call(this); + this.identifier = identifier; + this.callSignature = callSignature; + this.block = block; + identifier && (identifier.parent = this); + callSignature && (callSignature.parent = this); + block && (block.parent = this); + } + FunctionExpression.prototype.kind = function () { + return 222 /* FunctionExpression */; + }; + + FunctionExpression.prototype.isExpression = function () { + return true; + }; + return FunctionExpression; + })(AST); + TypeScript.FunctionExpression = FunctionExpression; + + var EmptyStatement = (function (_super) { + __extends(EmptyStatement, _super); + function EmptyStatement() { + _super.apply(this, arguments); + } + EmptyStatement.prototype.kind = function () { + return 156 /* EmptyStatement */; + }; + + EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition); + }; + return EmptyStatement; + })(AST); + TypeScript.EmptyStatement = EmptyStatement; + + var TryStatement = (function (_super) { + __extends(TryStatement, _super); + function TryStatement(block, catchClause, finallyClause) { + _super.call(this); + this.block = block; + this.catchClause = catchClause; + this.finallyClause = finallyClause; + block && (block.parent = this); + catchClause && (catchClause.parent = this); + finallyClause && (finallyClause.parent = this); + } + TryStatement.prototype.kind = function () { + return 159 /* TryStatement */; + }; + + TryStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); + }; + return TryStatement; + })(AST); + TypeScript.TryStatement = TryStatement; + + var CatchClause = (function (_super) { + __extends(CatchClause, _super); + function CatchClause(identifier, typeAnnotation, block) { + _super.call(this); + this.identifier = identifier; + this.typeAnnotation = typeAnnotation; + this.block = block; + identifier && (identifier.parent = this); + typeAnnotation && (typeAnnotation.parent = this); + block && (block.parent = this); + } + CatchClause.prototype.kind = function () { + return 236 /* CatchClause */; + }; + + CatchClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return CatchClause; + })(AST); + TypeScript.CatchClause = CatchClause; + + var FinallyClause = (function (_super) { + __extends(FinallyClause, _super); + function FinallyClause(block) { + _super.call(this); + this.block = block; + block && (block.parent = this); + } + FinallyClause.prototype.kind = function () { + return 237 /* FinallyClause */; + }; + + FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); + }; + return FinallyClause; + })(AST); + TypeScript.FinallyClause = FinallyClause; + + var LabeledStatement = (function (_super) { + __extends(LabeledStatement, _super); + function LabeledStatement(identifier, statement) { + _super.call(this); + this.identifier = identifier; + this.statement = statement; + identifier && (identifier.parent = this); + statement && (statement.parent = this); + } + LabeledStatement.prototype.kind = function () { + return 160 /* LabeledStatement */; + }; + + LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); + }; + return LabeledStatement; + })(AST); + TypeScript.LabeledStatement = LabeledStatement; + + var DoStatement = (function (_super) { + __extends(DoStatement, _super); + function DoStatement(statement, whileKeyword, condition) { + _super.call(this); + this.statement = statement; + this.whileKeyword = whileKeyword; + this.condition = condition; + statement && (statement.parent = this); + condition && (condition.parent = this); + } + DoStatement.prototype.kind = function () { + return 161 /* DoStatement */; + }; + + DoStatement.prototype.structuralEquals = function (ast, includingPosition) { + return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); + }; + return DoStatement; + })(AST); + TypeScript.DoStatement = DoStatement; + + var TypeOfExpression = (function (_super) { + __extends(TypeOfExpression, _super); + function TypeOfExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + TypeOfExpression.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + + 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; + + var DeleteExpression = (function (_super) { + __extends(DeleteExpression, _super); + function DeleteExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + DeleteExpression.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + + 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; + + var VoidExpression = (function (_super) { + __extends(VoidExpression, _super); + function VoidExpression(expression) { + _super.call(this); + this.expression = expression; + expression && (expression.parent = this); + } + VoidExpression.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + + 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; + + var DebuggerStatement = (function (_super) { + __extends(DebuggerStatement, _super); + function DebuggerStatement() { + _super.apply(this, arguments); + } + DebuggerStatement.prototype.kind = function () { + return 162 /* DebuggerStatement */; + }; + return DebuggerStatement; + })(AST); + TypeScript.DebuggerStatement = DebuggerStatement; + + var Comment = (function () { + function Comment(_trivia, endsLine, _start, _end) { + this._trivia = _trivia; + this.endsLine = endsLine; + this._start = _start; + this._end = _end; + } + Comment.prototype.start = function () { + return this._start; + }; + + Comment.prototype.end = function () { + return this._end; + }; + + Comment.prototype.fullText = function () { + return this._trivia.fullText(); + }; + + Comment.prototype.kind = function () { + return this._trivia.kind(); + }; + + Comment.prototype.structuralEquals = function (ast, includingPosition) { + if (includingPosition) { + if (this.start() !== ast.start() || this.end() !== ast.end()) { + return false; + } + } + + return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; + }; + return Comment; + })(); + TypeScript.Comment = Comment; +})(TypeScript || (TypeScript = {})); From d04312d809868e69d7a08b77f4cf4d569ab48d1f Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 09:33:40 +0900 Subject: [PATCH 204/240] Modified the version of TypeScript in test runner (0.9.7) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 46226fb2da..0119109e94 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.7-66c2df" + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7" } } From d76b9833b2013a4f1de152f83e68eeb88c0a3b76 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 09:34:14 +0900 Subject: [PATCH 205/240] Removed unreleased TypeScript versions --- .../tests/typescript/0.9.5-beta/lib.d.ts | 14202 ---- .../tests/typescript/0.9.5-beta/tsc | 2 - .../tests/typescript/0.9.5-beta/tsc.js | 60908 --------------- .../tests/typescript/0.9.5-beta/typescript.js | 59585 --------------- .../tests/typescript/0.9.7-59a846/lib.d.ts | 14931 ---- .../tests/typescript/0.9.7-59a846/tsc | 2 - .../tests/typescript/0.9.7-59a846/tsc.js | 62781 --------------- .../typescript/0.9.7-59a846/typescript.js | 61371 --------------- .../tests/typescript/0.9.7-66c2df/lib.d.ts | 14931 ---- .../tests/typescript/0.9.7-66c2df/tsc | 2 - .../tests/typescript/0.9.7-66c2df/tsc.js | 62790 ---------------- .../typescript/0.9.7-66c2df/typescript.js | 61380 --------------- 12 files changed, 412885 deletions(-) delete mode 100644 _infrastructure/tests/typescript/0.9.5-beta/lib.d.ts delete mode 100644 _infrastructure/tests/typescript/0.9.5-beta/tsc delete mode 100644 _infrastructure/tests/typescript/0.9.5-beta/tsc.js delete mode 100644 _infrastructure/tests/typescript/0.9.5-beta/typescript.js delete mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts delete mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/tsc delete mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/tsc.js delete mode 100644 _infrastructure/tests/typescript/0.9.7-59a846/typescript.js delete mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts delete mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/tsc delete mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/tsc.js delete mode 100644 _infrastructure/tests/typescript/0.9.7-66c2df/typescript.js diff --git a/_infrastructure/tests/typescript/0.9.5-beta/lib.d.ts b/_infrastructure/tests/typescript/0.9.5-beta/lib.d.ts deleted file mode 100644 index b0b5c96dd3..0000000000 --- a/_infrastructure/tests/typescript/0.9.5-beta/lib.d.ts +++ /dev/null @@ -1,14202 +0,0 @@ -/* ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -/// - -///////////////////////////// -/// ECMAScript APIs -///////////////////////////// - -declare var NaN: number; -declare var Infinity: number; - -/** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ -declare function eval(x: string): any; - -/** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ -declare function parseInt(s: string, radix?: number): number; - -/** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ -declare function parseFloat(string: string): number; - -/** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ -declare function isNaN(number: number): boolean; - -/** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ -declare function isFinite(number: number): boolean; - -/** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ -declare function decodeURI(encodedURI: string): string; - -/** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ -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; - -/** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ -declare function encodeURIComponent(uriComponent: string): string; - -interface PropertyDescriptor { - configurable?: boolean; - enumerable?: boolean; - value?: any; - writable?: boolean; - get? (): any; - set? (v: any): void; -} - -interface PropertyDescriptorMap { - [s: string]: PropertyDescriptor; -} - -interface Object { - /** Returns a string representation of an object. */ - toString(): string; - - /** Returns a date converted to a string using the current locale. */ - toLocaleString(): string; - - /** Returns the primitive value of the specified object. */ - valueOf(): Object; - - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: string): boolean; - - /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ - isPrototypeOf(v: Object): boolean; - - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - propertyIsEnumerable(v: string): boolean; -} - -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { - new (value?: any): Object; - (): any; - (value: any): any; - - /** A reference to the prototype for a class of objects. */ - prototype: Object; - - /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ - getPrototypeOf(o: any): any; - - /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; - - /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ - getOwnPropertyNames(o: any): string[]; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ - create(o: any, properties?: PropertyDescriptorMap): any; - - /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ - defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; - - /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ - defineProperties(o: any, properties: PropertyDescriptorMap): any; - - /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - seal(o: any): any; - - /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(o: any): any; - - /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ - preventExtensions(o: any): any; - - /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ - isSealed(o: any): boolean; - - /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ - isFrozen(o: any): boolean; - - /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ - isExtensible(o: any): boolean; - - /** - * Returns the names of the enumerable properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: any): string[]; -} - -/** - * Creates a new function. - */ -interface Function { - /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ - apply(thisArg: any, argArray?: any): any; - - /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ - call(thisArg: any, ...argArray: any[]): any; - - /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ - bind(thisArg: any, ...argArray: any[]): any; - - prototype: any; - length: number; - - // Non-standard extensions - arguments: any; - caller: Function; -} - -declare var Function: { - /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ - new (...args: string[]): Function; - (...args: string[]): Function; - prototype: Function; -} - -interface IArguments { - [index: number]: any; - length: number; - callee: Function; -} - -interface String { - /** Returns a string representation of a string. */ - toString(): string; - - /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ - charAt(pos: number): string; - - /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ - charCodeAt(index: number): number; - - /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ - concat(...strings: string[]): string; - - /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ - indexOf(searchString: string, position?: number): number; - - /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ - lastIndexOf(searchString: string, position?: number): number; - - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ - localeCompare(that: string): number; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - match(regexp: string): string[]; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. - */ - match(regexp: RegExp): string[]; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: string, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: RegExp, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: string): number; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: RegExp): number; - - /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ - slice(start: number, end?: number): string; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: string, limit?: number): string[]; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: RegExp, limit?: number): string[]; - - /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index number indicating the beginning of the substring. - * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ - substring(start: number, end?: number): string; - - /** Converts all the alphabetic characters in a string to lowercase. */ - toLowerCase(): string; - - /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; - - /** Converts all the alphabetic characters in a string to uppercase. */ - toUpperCase(): string; - - /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; - - /** Removes the leading and trailing white space and line terminator characters from a string. */ - trim(): string; - - /** Returns the length of a String object. */ - length: number; - - // IE extensions - /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ - substr(from: number, length?: number): string; - - [index: number]: string; -} - -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { - new (value?: any): String; - (value?: any): string; - prototype: String; - fromCharCode(...codes: number[]): string; -} - -interface Boolean { -} -declare var Boolean: { - new (value?: any): Boolean; - (value?: any): boolean; - prototype: Boolean; -} - -interface Number { - /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. - */ - toString(radix?: number): string; - - /** - * Returns a string representing a number in fixed-point notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toFixed(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented in exponential notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toExponential(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. - * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. - */ - toPrecision(precision?: number): string; -} - -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { - new (value?: any): Number; - (value?: any): number; - prototype: Number; - - /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; - - /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; - - /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ - NaN: number; - - /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ - NEGATIVE_INFINITY: number; - - /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ - POSITIVE_INFINITY: number; -} - -interface Math { - /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; - /** The natural logarithm of 10. */ - LN10: number; - /** The natural logarithm of 2. */ - LN2: number; - /** The base-2 logarithm of e. */ - LOG2E: number; - /** The base-10 logarithm of e. */ - LOG10E: number; - /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; - /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; - /** The square root of 2. */ - SQRT2: number; - /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ - abs(x: number): number; - /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ - acos(x: number): number; - /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ - asin(x: number): number; - /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ - atan(x: number): number; - /** - * Returns the angle (in radians) from the X axis to a point (y,x). - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ - atan2(y: number, x: number): number; - /** - * Returns the smallest number greater than or equal to its numeric argument. - * @param x A numeric expression. - */ - ceil(x: number): number; - /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - cos(x: number): number; - /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ - exp(x: number): number; - /** - * Returns the greatest number less than or equal to its numeric argument. - * @param x A numeric expression. - */ - floor(x: number): number; - /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ - log(x: number): number; - /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - max(...values: number[]): number; - /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - min(...values: number[]): number; - /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ - pow(x: number, y: number): number; - /** Returns a pseudorandom number between 0 and 1. */ - random(): number; - /** - * Returns a supplied numeric expression rounded to the nearest number. - * @param x The value to be rounded to the nearest number. - */ - round(x: number): number; - /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - sin(x: number): number; - /** - * Returns the square root of a number. - * @param x A numeric expression. - */ - sqrt(x: number): number; - /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - tan(x: number): number; -} -/** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; - -/** Enables basic storage and retrieval of dates and times. */ -interface Date { - /** Returns a string representation of a date. The format of the string depends on the locale. */ - toString(): string; - /** Returns a date as a string value. */ - toDateString(): string; - /** Returns a time as a string value. */ - toTimeString(): string; - /** Returns a value as a string value appropriate to the host environment's current locale. */ - toLocaleString(): string; - /** Returns a date as a string value appropriate to the host environment's current locale. */ - toLocaleDateString(): string; - /** Returns a time as a string value appropriate to the host environment's current locale. */ - toLocaleTimeString(): string; - /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ - valueOf(): number; - /** Gets the time value in milliseconds. */ - getTime(): number; - /** Gets the year, using local time. */ - getFullYear(): number; - /** Gets the year using Universal Coordinated Time (UTC). */ - getUTCFullYear(): number; - /** Gets the month, using local time. */ - getMonth(): number; - /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ - getUTCMonth(): number; - /** Gets the day-of-the-month, using local time. */ - getDate(): number; - /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ - getUTCDate(): number; - /** Gets the day of the week, using local time. */ - getDay(): number; - /** Gets the day of the week using Universal Coordinated Time (UTC). */ - getUTCDay(): number; - /** Gets the hours in a date, using local time. */ - getHours(): number; - /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ - getUTCHours(): number; - /** Gets the minutes of a Date object, using local time. */ - getMinutes(): number; - /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ - getUTCMinutes(): number; - /** Gets the seconds of a Date object, using local time. */ - getSeconds(): number; - /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCSeconds(): number; - /** Gets the milliseconds of a Date, using local time. */ - getMilliseconds(): number; - /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCMilliseconds(): number; - /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ - getTimezoneOffset(): number; - /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ - setTime(time: number): void; - /** - * 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; - /** - * 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; - - /** - * 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; - /** - * 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; - /** - * 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; - /** - * 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; - /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setHours(hours: number, min?: number, sec?: number, ms?: number): void; - /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setUTCHours(hours: number, min?: number, sec?: number, ms?: number): void; - /** - * 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; - /** - * 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; - /** - * 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; - /** - * 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; - /** - * 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; - /** - * 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; - /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ - toUTCString(): string; - /** Returns a date as a string value in ISO format. */ - toISOString(): string; - /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ - toJSON(key?: any): string; -} - -declare var Date: { - new (): Date; - new (value: number): Date; - new (value: string): Date; - new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; - (): string; - prototype: Date; - /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ - parse(s: string): number; - /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an number between 0 and 11 (January to December). - * @param date The date as an number between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. - * @param ms An number from 0 to 999 that specifies the milliseconds. - */ - UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; - now(): number; -} - -interface RegExpExecArray { - [index: number]: string; - length: number; - - index: number; - input: string; - - toString(): string; - toLocaleString(): string; - concat(...items: string[][]): string[]; - join(separator?: string): string; - pop(): string; - push(...items: string[]): number; - reverse(): string[]; - shift(): 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[]; - unshift(...items: string[]): number; - - indexOf(searchElement: string, fromIndex?: number): number; - lastIndexOf(searchElement: string, fromIndex?: number): number; - every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; - map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; - filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; - reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; - reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; -} - - -interface RegExp { - /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ - 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. - */ - test(string: string): boolean; - - /** 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; - - /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; - - /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; - - lastIndex: number; - - // Non-standard extensions - compile(): RegExp; -} -declare var RegExp: { - new (pattern: string, flags?: string): RegExp; - (pattern: string, flags?: string): RegExp; - - // Non-standard extensions - $1: string; - $2: string; - $3: string; - $4: string; - $5: string; - $6: string; - $7: string; - $8: string; - $9: string; - lastMatch: string; -} - -interface Error { - name: string; - message: string; -} -declare var Error: { - new (message?: string): Error; - (message?: string): Error; - prototype: Error; -} - -interface EvalError extends Error { -} -declare var EvalError: { - new (message?: string): EvalError; - (message?: string): EvalError; - prototype: EvalError; -} - -interface RangeError extends Error { -} -declare var RangeError: { - new (message?: string): RangeError; - (message?: string): RangeError; - prototype: RangeError; -} - -interface ReferenceError extends Error { -} -declare var ReferenceError: { - new (message?: string): ReferenceError; - (message?: string): ReferenceError; - prototype: ReferenceError; -} - -interface SyntaxError extends Error { -} -declare var SyntaxError: { - new (message?: string): SyntaxError; - (message?: string): SyntaxError; - prototype: SyntaxError; -} - -interface TypeError extends Error { -} -declare var TypeError: { - new (message?: string): TypeError; - (message?: string): TypeError; - prototype: TypeError; -} - -interface URIError extends Error { -} -declare var URIError: { - new (message?: string): URIError; - (message?: string): URIError; - prototype: URIError; -} - -interface JSON { - /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ - parse(text: string, reviver?: (key: any, value: any) => any): any; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - */ - stringify(value: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - */ - stringify(value: any, replacer: (key: string, value: any) => any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - */ - stringify(value: any, replacer: any[]): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: any[], space: any): string; -} -/** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ -declare var JSON: JSON; - - -///////////////////////////// -/// ECMAScript Array API (specially handled by compiler) -///////////////////////////// - -interface Array { - /** - * Returns a string representation of an array. - */ - toString(): string; - toLocaleString(): string; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** - * Removes the last element from an array and returns it. - */ - pop(): T; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(...items: T[]): number; - /** - * Reverses the elements in an Array. - */ - reverse(): T[]; - /** - * Removes the first element from an array and returns it. - */ - shift(): T; - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start: number, end?: number): T[]; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - */ - splice(start: number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ - splice(start: number, deleteCount: number, ...items: T[]): T[]; - - /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ - unshift(...items: T[]): number; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ - indexOf(searchElement: T, fromIndex?: number): number; - - /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ - lastIndexOf(searchElement: T, fromIndex?: number): number; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; - - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ - length: number; - - [n: number]: T; -} -declare var Array: { - new(arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; -} - - -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; -} - -declare var ArrayBuffer: { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; -} - -interface ArrayBufferView { - buffer: ArrayBuffer; - byteOffset: number; - byteLength: number; -} - -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int8Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; -} -declare var Int8Array: { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; -} -declare var Uint8Array: { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 16-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; -} -declare var Int16Array: { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; -} -declare var Uint16Array: { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; -} -declare var Int32Array: { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; -} -declare var Uint32Array: { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Float32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; -} -declare var Float32Array: { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Float64Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float64Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; -} -declare var Float64Array: { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - BYTES_PER_ELEMENT: number; -} - -/** - * You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer. - */ -interface DataView extends ArrayBufferView { - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian?: boolean): number; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; -} -declare var DataView: { - prototype: DataView; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; -} - -///////////////////////////// -/// IE11 ECMAScript Extensions -///////////////////////////// - -interface Map { - clear(): void; - delete(key: K): boolean; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): Map; - size: number; -} -declare var Map: { - new (): Map; -} - -interface WeakMap { - clear(): void; - delete(key: K): boolean; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): WeakMap; -} -declare var WeakMap: { - new (): WeakMap; -} - -interface Set { - add(value: T): Set; - clear(): void; - delete(value: T): boolean; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; - has(value: T): boolean; - size: number; -} -declare var Set: { - new (): Set; -} - -declare module Intl { - - interface CollatorOptions { - usage?: string; - localeMatcher?: string; - numeric?: boolean; - caseFirst?: string; - sensitivity?: string; - ignorePunctuation?: boolean; - } - - interface ResolvedCollatorOptions { - locale: string; - usage: string; - sensitivity: string; - ignorePunctuation: boolean; - collation: string; - caseFirst: string; - numeric: boolean; - } - - interface Collator { - compare(x: string, y: string): number; - resolvedOptions(): ResolvedCollatorOptions; - } - var Collator: { - new (locales?: string[], options?: CollatorOptions): Collator; - new (locale?: string, options?: CollatorOptions): Collator; - (locales?: string[], options?: CollatorOptions): Collator; - (locale?: string, options?: CollatorOptions): Collator; - supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; - supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; - } - - interface NumberFormatOptions { - localeMatcher?: string; - style?: string; - currency?: string; - currencyDisplay?: string; - useGrouping?: boolean; - } - - interface ResolvedNumberFormatOptions { - locale: string; - numberingSystem: string; - style: string; - currency?: string; - currencyDisplay?: string; - minimumintegerDigits: number; - minimumFractionDigits: number; - maximumFractionDigits: number; - minimumSignificantDigits?: number; - maximumSignificantDigits?: number; - useGrouping: boolean; - } - - interface NumberFormat { - format(value: number): string; - resolvedOptions(): ResolvedNumberFormatOptions; - } - var NumberFormat: { - new (locales?: string[], options?: NumberFormatOptions): Collator; - new (locale?: string, options?: NumberFormatOptions): Collator; - (locales?: string[], options?: NumberFormatOptions): Collator; - (locale?: string, options?: NumberFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; - } - - interface DateTimeFormatOptions { - localeMatcher?: string; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - formatMatcher?: string; - hour12: boolean; - } - - interface ResolvedDateTimeFormatOptions { - locale: string; - calendar: string; - numberingSystem: string; - timeZone: string; - hour12?: boolean; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - } - - interface DateTimeFormat { - format(date: number): string; - resolvedOptions(): ResolvedDateTimeFormatOptions; - } - var DateTimeFormat: { - new (locales?: string[], options?: DateTimeFormatOptions): Collator; - new (locale?: string, options?: DateTimeFormatOptions): Collator; - (locales?: string[], options?: DateTimeFormatOptions): Collator; - (locale?: string, options?: DateTimeFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; - } -} - -interface String { - localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; - localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; -} - -interface Number { - 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; -} - - -///////////////////////////// -/// IE9 DOM APIs -///////////////////////////// - -interface PositionOptions { - enableHighAccuracy?: boolean; - timeout?: number; - maximumAge?: number; -} - -interface NavigatorID { - appVersion: string; - appName: string; - userAgent: string; - platform: string; -} - -interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the amount of space between cells in a table. - */ - cellSpacing: string; - /** - * Retrieves the tFoot object of the table. - */ - tFoot: HTMLTableSectionElement; - /** - * Sets or retrieves the way the border frame around the table is displayed. - */ - frame: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Sets or retrieves which dividing lines (inner borders) are displayed. - */ - rules: string; - /** - * Sets or retrieves the number of columns in the table. - */ - cols: number; - /** - * Sets or retrieves a description and/or structure of the object. - */ - summary: string; - /** - * Retrieves the caption object of a table. - */ - caption: HTMLTableCaptionElement; - /** - * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. - */ - tBodies: HTMLCollection; - /** - * Retrieves the tHead object of the table. - */ - tHead: HTMLTableSectionElement; - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Retrieves a collection of all cells in the table row or in the entire table. - */ - cells: HTMLCollection; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the amount of space between the border of the cell and the content of the cell. - */ - cellPadding: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Creates an empty tBody element in the table. - */ - createTBody(): HTMLElement; - /** - * Deletes the caption element and its contents from the table. - */ - deleteCaption(): void; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; - /** - * Deletes the tFoot element and its contents from the table. - */ - deleteTFoot(): void; - /** - * Returns the tHead element object if successful, or null otherwise. - */ - createTHead(): HTMLElement; - /** - * Deletes the tHead element and its contents from the table. - */ - deleteTHead(): void; - /** - * Creates an empty caption element in the table. - */ - createCaption(): HTMLElement; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): Object; - /** - * Creates an empty tFoot element in the table. - */ - createTFoot(): HTMLElement; -} -declare var HTMLTableElement: { - prototype: HTMLTableElement; - new (): HTMLTableElement; -} - -interface TreeWalker { - whatToShow: number; - filter: NodeFilter; - root: Node; - currentNode: Node; - expandEntityReferences: boolean; - previousSibling(): Node; - lastChild(): Node; - nextSibling(): Node; - nextNode(): Node; - parentNode(): Node; - firstChild(): Node; - previousNode(): Node; -} -declare var TreeWalker: { - prototype: TreeWalker; - new (): TreeWalker; -} - -interface GetSVGDocument { - getSVGDocument(): Document; -} - -interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticRel: { - prototype: SVGPathSegCurvetoQuadraticRel; - new (): SVGPathSegCurvetoQuadraticRel; -} - -interface Performance { - navigation: PerformanceNavigation; - timing: PerformanceTiming; - getEntriesByType(entryType: string): any; - toJSON(): any; - getMeasures(measureName?: string): any; - clearMarks(markName?: string): void; - getMarks(markName?: string): any; - clearResourceTimings(): void; - mark(markName: string): void; - measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - getEntriesByName(name: string, entryType?: string): any; - getEntries(): any; - clearMeasures(measureName?: string): void; - setResourceTimingBufferSize(maxSize: number): void; -} -declare var Performance: { - prototype: Performance; - new (): Performance; -} - -interface MSDataBindingTableExtensions { - dataPageSize: number; - nextPage(): void; - firstPage(): void; - refresh(): void; - previousPage(): void; - lastPage(): void; -} - -interface CompositionEvent extends UIEvent { - data: string; - locale: string; - initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; -} -declare var CompositionEvent: { - prototype: CompositionEvent; - new (): CompositionEvent; -} - -interface WindowTimers { - clearTimeout(handle: number): void; - setTimeout(handler: any, timeout?: any, ...args: any[]): number; - clearInterval(handle: number): void; - setInterval(handler: any, timeout?: any, ...args: any[]): number; -} - -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { - orientType: SVGAnimatedEnumeration; - markerUnits: SVGAnimatedEnumeration; - markerWidth: SVGAnimatedLength; - markerHeight: SVGAnimatedLength; - orientAngle: SVGAnimatedAngle; - refY: SVGAnimatedLength; - refX: SVGAnimatedLength; - setOrientToAngle(angle: SVGAngle): void; - setOrientToAuto(): void; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} -declare var SVGMarkerElement: { - prototype: SVGMarkerElement; - new (): SVGMarkerElement; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} - -interface CSSStyleDeclaration { - backgroundAttachment: string; - visibility: string; - textAlignLast: string; - borderRightStyle: string; - counterIncrement: string; - orphans: string; - cssText: string; - borderStyle: string; - pointerEvents: string; - borderTopColor: string; - markerEnd: string; - textIndent: string; - listStyleImage: string; - cursor: string; - listStylePosition: string; - wordWrap: string; - borderTopStyle: string; - alignmentBaseline: string; - opacity: string; - direction: string; - strokeMiterlimit: string; - maxWidth: string; - color: string; - clip: string; - borderRightWidth: string; - verticalAlign: string; - overflow: string; - mask: string; - borderLeftStyle: string; - emptyCells: string; - stopOpacity: string; - paddingRight: string; - parentRule: CSSRule; - background: string; - boxSizing: string; - textJustify: string; - height: string; - paddingTop: string; - length: number; - right: string; - baselineShift: string; - borderLeft: string; - widows: string; - lineHeight: string; - left: string; - textUnderlinePosition: string; - glyphOrientationHorizontal: string; - display: string; - textAnchor: string; - cssFloat: string; - strokeDasharray: string; - rubyAlign: string; - fontSizeAdjust: string; - borderLeftColor: string; - backgroundImage: string; - listStyleType: string; - strokeWidth: string; - textOverflow: string; - fillRule: string; - borderBottomColor: string; - zIndex: string; - position: string; - listStyle: string; - msTransformOrigin: string; - dominantBaseline: string; - overflowY: string; - fill: string; - captionSide: string; - borderCollapse: string; - boxShadow: string; - quotes: string; - tableLayout: string; - unicodeBidi: string; - borderBottomWidth: string; - backgroundSize: string; - textDecoration: string; - strokeDashoffset: string; - fontSize: string; - border: string; - pageBreakBefore: string; - borderTopRightRadius: string; - msTransform: string; - borderBottomLeftRadius: string; - textTransform: string; - rubyPosition: string; - strokeLinejoin: string; - clipPath: string; - borderRightColor: string; - fontFamily: string; - clear: string; - content: string; - backgroundClip: string; - marginBottom: string; - counterReset: string; - outlineWidth: string; - marginRight: string; - paddingLeft: string; - borderBottom: string; - wordBreak: string; - marginTop: string; - top: string; - fontWeight: string; - borderRight: string; - width: string; - kerning: string; - pageBreakAfter: string; - borderBottomStyle: string; - fontStretch: string; - padding: string; - strokeOpacity: string; - markerStart: string; - bottom: string; - borderLeftWidth: string; - clipRule: string; - backgroundPosition: string; - backgroundColor: string; - pageBreakInside: string; - backgroundOrigin: string; - strokeLinecap: string; - borderTopWidth: string; - outlineStyle: string; - borderTop: string; - outlineColor: string; - paddingBottom: string; - marginLeft: string; - font: string; - outline: string; - wordSpacing: string; - maxHeight: string; - fillOpacity: string; - letterSpacing: string; - borderSpacing: string; - backgroundRepeat: string; - borderRadius: string; - borderWidth: string; - borderBottomRightRadius: string; - whiteSpace: string; - fontStyle: string; - minWidth: string; - stopColor: string; - borderTopLeftRadius: string; - borderColor: string; - marker: string; - glyphOrientationVertical: string; - markerMid: string; - fontVariant: string; - minHeight: string; - stroke: string; - rubyOverhang: string; - overflowX: string; - textAlign: string; - margin: string; - getPropertyPriority(propertyName: string): string; - getPropertyValue(propertyName: string): string; - removeProperty(propertyName: string): string; - item(index: number): string; - [index: number]: string; - setProperty(propertyName: string, value: string, priority?: string): void; -} -declare var CSSStyleDeclaration: { - prototype: CSSStyleDeclaration; - new (): CSSStyleDeclaration; -} - -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGGElement: { - prototype: SVGGElement; - new (): SVGGElement; -} - -interface MSStyleCSSProperties extends MSCSSProperties { - pixelWidth: number; - posHeight: number; - posLeft: number; - pixelTop: number; - pixelBottom: number; - textDecorationNone: boolean; - pixelLeft: number; - posTop: number; - posBottom: number; - textDecorationOverline: boolean; - posWidth: number; - textDecorationLineThrough: boolean; - pixelHeight: number; - textDecorationBlink: boolean; - posRight: number; - pixelRight: number; - textDecorationUnderline: boolean; -} -declare var MSStyleCSSProperties: { - prototype: MSStyleCSSProperties; - new (): MSStyleCSSProperties; -} - -interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils { -} -declare var Navigator: { - prototype: Navigator; - new (): Navigator; -} - -interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothAbs: { - prototype: SVGPathSegCurvetoCubicSmoothAbs; - new (): SVGPathSegCurvetoCubicSmoothAbs; -} - -interface SVGZoomEvent extends UIEvent { - zoomRectScreen: SVGRect; - previousScale: number; - newScale: number; - previousTranslate: SVGPoint; - newTranslate: SVGPoint; -} -declare var SVGZoomEvent: { - prototype: SVGZoomEvent; - new (): SVGZoomEvent; -} - -interface NodeSelector { - querySelectorAll(selectors: string): NodeList; - querySelector(selectors: string): Element; -} - -interface HTMLTableDataCellElement extends HTMLTableCellElement { -} -declare var HTMLTableDataCellElement: { - prototype: HTMLTableDataCellElement; - new (): HTMLTableDataCellElement; -} - -interface HTMLBaseElement extends HTMLElement { - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Gets or sets the baseline URL on which relative links are based. - */ - href: string; -} -declare var HTMLBaseElement: { - prototype: HTMLBaseElement; - new (): HTMLBaseElement; -} - -interface ClientRect { - left: number; - width: number; - right: number; - top: number; - bottom: number; - height: number; -} -declare var ClientRect: { - prototype: ClientRect; - new (): ClientRect; -} - -interface PositionErrorCallback { - (error: PositionError): void; -} - -interface DOMImplementation { - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; - createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; - hasFeature(feature: string, version?: string): boolean; - createHTMLDocument(title: string): Document; -} -declare var DOMImplementation: { - prototype: DOMImplementation; - new (): DOMImplementation; -} - -interface SVGUnitTypes { - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} -declare var SVGUnitTypes: { - prototype: SVGUnitTypes; - new (): SVGUnitTypes; - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} - -interface Element extends Node, NodeSelector, ElementTraversal { - scrollTop: number; - clientLeft: number; - scrollLeft: number; - tagName: string; - clientWidth: number; - scrollWidth: number; - clientHeight: number; - clientTop: number; - scrollHeight: number; - getAttribute(name?: string): string; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - hasAttributeNS(namespaceURI: string, localName: string): boolean; - getBoundingClientRect(): ClientRect; - getAttributeNS(namespaceURI: string, localName: string): string; - getAttributeNodeNS(namespaceURI: string, localName: string): Attr; - setAttributeNodeNS(newAttr: Attr): Attr; - msMatchesSelector(selectors: string): boolean; - hasAttribute(name: string): boolean; - removeAttribute(name?: string): void; - setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; - getAttributeNode(name: string): Attr; - fireEvent(eventName: string, eventObj?: any): boolean; - getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; - getElementsByTagName(name: "area"): NodeListOf; - getElementsByTagName(name: "article"): NodeListOf; - getElementsByTagName(name: "aside"): NodeListOf; - getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; - getElementsByTagName(name: "base"): NodeListOf; - getElementsByTagName(name: "bdi"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; - getElementsByTagName(name: "body"): NodeListOf; - getElementsByTagName(name: "br"): NodeListOf; - getElementsByTagName(name: "button"): NodeListOf; - getElementsByTagName(name: "canvas"): NodeListOf; - getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; - getElementsByTagName(name: "col"): NodeListOf; - getElementsByTagName(name: "colgroup"): NodeListOf; - getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; - getElementsByTagName(name: "del"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; - getElementsByTagName(name: "div"): NodeListOf; - getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; - getElementsByTagName(name: "embed"): NodeListOf; - getElementsByTagName(name: "fieldset"): NodeListOf; - getElementsByTagName(name: "figcaption"): NodeListOf; - getElementsByTagName(name: "figure"): NodeListOf; - getElementsByTagName(name: "footer"): NodeListOf; - getElementsByTagName(name: "form"): NodeListOf; - getElementsByTagName(name: "h1"): NodeListOf; - getElementsByTagName(name: "h2"): NodeListOf; - getElementsByTagName(name: "h3"): NodeListOf; - getElementsByTagName(name: "h4"): NodeListOf; - getElementsByTagName(name: "h5"): NodeListOf; - getElementsByTagName(name: "h6"): NodeListOf; - getElementsByTagName(name: "head"): NodeListOf; - getElementsByTagName(name: "header"): NodeListOf; - getElementsByTagName(name: "hgroup"): NodeListOf; - getElementsByTagName(name: "hr"): NodeListOf; - getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; - getElementsByTagName(name: "iframe"): NodeListOf; - getElementsByTagName(name: "img"): NodeListOf; - getElementsByTagName(name: "input"): NodeListOf; - getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "label"): NodeListOf; - getElementsByTagName(name: "legend"): NodeListOf; - getElementsByTagName(name: "li"): NodeListOf; - getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "main"): NodeListOf; - getElementsByTagName(name: "map"): NodeListOf; - getElementsByTagName(name: "mark"): NodeListOf; - getElementsByTagName(name: "menu"): NodeListOf; - getElementsByTagName(name: "meta"): NodeListOf; - getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "noscript"): NodeListOf; - getElementsByTagName(name: "object"): NodeListOf; - getElementsByTagName(name: "ol"): NodeListOf; - getElementsByTagName(name: "optgroup"): NodeListOf; - getElementsByTagName(name: "option"): NodeListOf; - getElementsByTagName(name: "p"): NodeListOf; - getElementsByTagName(name: "param"): NodeListOf; - getElementsByTagName(name: "pre"): NodeListOf; - getElementsByTagName(name: "progress"): NodeListOf; - getElementsByTagName(name: "q"): NodeListOf; - getElementsByTagName(name: "rp"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; - getElementsByTagName(name: "script"): NodeListOf; - getElementsByTagName(name: "section"): NodeListOf; - getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; - getElementsByTagName(name: "source"): NodeListOf; - getElementsByTagName(name: "span"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; - getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "summary"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; - getElementsByTagName(name: "table"): NodeListOf; - getElementsByTagName(name: "tbody"): NodeListOf; - getElementsByTagName(name: "td"): NodeListOf; - getElementsByTagName(name: "textarea"): NodeListOf; - getElementsByTagName(name: "tfoot"): NodeListOf; - getElementsByTagName(name: "th"): NodeListOf; - getElementsByTagName(name: "thead"): NodeListOf; - getElementsByTagName(name: "title"): NodeListOf; - getElementsByTagName(name: "tr"): NodeListOf; - getElementsByTagName(name: "track"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; - getElementsByTagName(name: "ul"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; - getElementsByTagName(name: "video"): NodeListOf; - getElementsByTagName(name: "wbr"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getClientRects(): ClientRectList; - setAttributeNode(newAttr: Attr): Attr; - removeAttributeNode(oldAttr: Attr): Attr; - setAttribute(name?: string, value?: string): void; - removeAttributeNS(namespaceURI: string, localName: string): void; -} -declare var Element: { - prototype: Element; - new (): Element; -} - -interface HTMLNextIdElement extends HTMLElement { - n: string; -} -declare var HTMLNextIdElement: { - prototype: HTMLNextIdElement; - new (): HTMLNextIdElement; -} - -interface SVGPathSegMovetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoRel: { - prototype: SVGPathSegMovetoRel; - new (): SVGPathSegMovetoRel; -} - -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLineElement: { - prototype: SVGLineElement; - new (): SVGLineElement; -} - -interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; -} -declare var HTMLParagraphElement: { - prototype: HTMLParagraphElement; - new (): HTMLParagraphElement; -} - -interface HTMLAreasCollection extends HTMLCollection { - /** - * Removes an element from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: any): void; -} -declare var HTMLAreasCollection: { - prototype: HTMLAreasCollection; - new (): HTMLAreasCollection; -} - -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGDescElement: { - prototype: SVGDescElement; - new (): SVGDescElement; -} - -interface Node extends EventTarget { - nodeType: number; - previousSibling: Node; - localName: string; - namespaceURI: string; - textContent: string; - parentNode: Node; - nextSibling: Node; - nodeValue: string; - lastChild: Node; - childNodes: NodeList; - nodeName: string; - ownerDocument: Document; - attributes: NamedNodeMap; - firstChild: Node; - prefix: string; - removeChild(oldChild: Node): Node; - appendChild(newChild: Node): Node; - isSupported(feature: string, version: string): boolean; - isEqualNode(arg: Node): boolean; - lookupPrefix(namespaceURI: string): string; - isDefaultNamespace(namespaceURI: string): boolean; - compareDocumentPosition(other: Node): number; - normalize(): void; - isSameNode(other: Node): boolean; - hasAttributes(): boolean; - lookupNamespaceURI(prefix: string): string; - cloneNode(deep?: boolean): Node; - hasChildNodes(): boolean; - replaceChild(newChild: Node, oldChild: Node): Node; - insertBefore(newChild: Node, refChild?: Node): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} -declare var Node: { - prototype: Node; - new (): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} - -interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothRel: { - prototype: SVGPathSegCurvetoQuadraticSmoothRel; - new (): SVGPathSegCurvetoQuadraticSmoothRel; -} - -interface DOML2DeprecatedListSpaceReduction { - compact: boolean; -} - -interface MSScriptHost { -} -declare var MSScriptHost: { - prototype: MSScriptHost; - new (): MSScriptHost; -} - -interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - clipPathUnits: SVGAnimatedEnumeration; -} -declare var SVGClipPathElement: { - prototype: SVGClipPathElement; - new (): SVGClipPathElement; -} - -interface MouseEvent extends UIEvent { - toElement: Element; - layerY: number; - fromElement: Element; - which: number; - pageX: number; - offsetY: number; - x: number; - y: number; - metaKey: boolean; - altKey: boolean; - ctrlKey: boolean; - offsetX: number; - screenX: number; - clientY: number; - shiftKey: boolean; - layerX: number; - screenY: number; - relatedTarget: EventTarget; - button: number; - pageY: number; - buttons: number; - clientX: number; - initMouseEvent(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): void; - getModifierState(keyArg: string): boolean; -} -declare var MouseEvent: { - prototype: MouseEvent; - new (): MouseEvent; -} - -interface RangeException { - code: number; - message: string; - toString(): string; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} -declare var RangeException: { - prototype: RangeException; - new (): RangeException; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} - -interface SVGTextPositioningElement extends SVGTextContentElement { - y: SVGAnimatedLengthList; - rotate: SVGAnimatedNumberList; - dy: SVGAnimatedLengthList; - x: SVGAnimatedLengthList; - dx: SVGAnimatedLengthList; -} -declare var SVGTextPositioningElement: { - prototype: SVGTextPositioningElement; - new (): SVGTextPositioningElement; -} - -interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - width: number; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - object: string; - form: HTMLFormElement; - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. - */ - contentDocument: Document; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - /** - * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. - */ - declare: boolean; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; -} -declare var HTMLAppletElement: { - prototype: HTMLAppletElement; - new (): HTMLAppletElement; -} - -interface TextMetrics { - width: number; -} -declare var TextMetrics: { - prototype: TextMetrics; - new (): TextMetrics; -} - -interface DocumentEvent { - createEvent(eventInterface: string): Event; -} - -interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * The starting number. - */ - start: number; -} -declare var HTMLOListElement: { - prototype: HTMLOListElement; - new (): HTMLOListElement; -} - -interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalRel: { - prototype: SVGPathSegLinetoVerticalRel; - new (): SVGPathSegLinetoVerticalRel; -} - -interface SVGAnimatedString { - animVal: string; - baseVal: string; -} -declare var SVGAnimatedString: { - prototype: SVGAnimatedString; - new (): SVGAnimatedString; -} - -interface CDATASection extends Text { -} -declare var CDATASection: { - prototype: CDATASection; - new (): CDATASection; -} - -interface StyleMedia { - type: string; - matchMedium(mediaquery: string): boolean; -} -declare var StyleMedia: { - prototype: StyleMedia; - new (): StyleMedia; -} - -interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { - options: HTMLSelectElement; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the number of rows in the list box. - */ - size: number; - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the index of the selected option in a select object. - */ - selectedIndex: number; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Retrieves the type of select control based on the value of the MULTIPLE attribute. - */ - type: string; - /** - * Removes an element from the collection. - * @param index Number that specifies the zero-based index of the element to remove from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. - * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. - */ - add(element: HTMLElement, before?: any): void; - /** - * Retrieves a select object or an object from an options collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Retrieves a select object or an object from an options collection. - * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. - */ - namedItem(name: string): any; - [name: string]: any; -} -declare var HTMLSelectElement: { - prototype: HTMLSelectElement; - new (): HTMLSelectElement; -} - -interface TextRange { - boundingLeft: number; - htmlText: string; - offsetLeft: number; - boundingWidth: number; - boundingHeight: number; - boundingTop: number; - text: string; - offsetTop: number; - moveToPoint(x: number, y: number): void; - queryCommandValue(cmdID: string): any; - getBookmark(): string; - move(unit: string, count?: number): number; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(fStart?: boolean): void; - findText(string: string, count?: number, flags?: number): boolean; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - getBoundingClientRect(): ClientRect; - moveToBookmark(bookmark: string): boolean; - isEqual(range: TextRange): boolean; - duplicate(): TextRange; - collapse(start?: boolean): void; - queryCommandText(cmdID: string): string; - select(): void; - pasteHTML(html: string): void; - inRange(range: TextRange): boolean; - moveEnd(unit: string, count?: number): number; - getClientRects(): ClientRectList; - moveStart(unit: string, count?: number): number; - parentElement(): Element; - queryCommandState(cmdID: string): boolean; - compareEndPoints(how: string, sourceRange: TextRange): number; - execCommandShowHelp(cmdID: string): boolean; - moveToElementText(element: Element): void; - expand(Unit: string): boolean; - queryCommandSupported(cmdID: string): boolean; - setEndPoint(how: string, SourceRange: TextRange): void; - queryCommandEnabled(cmdID: string): boolean; -} -declare var TextRange: { - prototype: TextRange; - new (): TextRange; -} - -interface SVGTests { - requiredFeatures: SVGStringList; - requiredExtensions: SVGStringList; - systemLanguage: SVGStringList; - hasExtension(extension: string): boolean; -} - -interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLBlockElement: { - prototype: HTMLBlockElement; - new (): HTMLBlockElement; -} - -interface CSSStyleSheet extends StyleSheet { - owningElement: Element; - imports: StyleSheetList; - isAlternate: boolean; - rules: MSCSSRuleList; - isPrefAlternate: boolean; - readOnly: boolean; - cssText: string; - ownerRule: CSSRule; - href: string; - cssRules: CSSRuleList; - id: string; - pages: StyleSheetPageList; - addImport(bstrURL: string, lIndex?: number): number; - addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; - insertRule(rule: string, index?: number): number; - removeRule(lIndex: number): void; - deleteRule(index?: number): void; - addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; - removeImport(lIndex: number): void; -} -declare var CSSStyleSheet: { - prototype: CSSStyleSheet; - new (): CSSStyleSheet; -} - -interface MSSelection { - type: string; - typeDetail: string; - createRange(): TextRange; - clear(): void; - createRangeCollection(): TextRangeCollection; - empty(): void; -} -declare var MSSelection: { - prototype: MSSelection; - new (): MSSelection; -} - -interface HTMLMetaElement extends HTMLElement { - /** - * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. - */ - httpEquiv: string; - /** - * Sets or retrieves the value specified in the content attribute of the meta object. - */ - name: string; - /** - * Gets or sets meta-information to associate with httpEquiv or name. - */ - content: string; - /** - * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. - */ - url: string; - /** - * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. - */ - scheme: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; -} -declare var HTMLMetaElement: { - prototype: HTMLMetaElement; - new (): HTMLMetaElement; -} - -interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { - patternUnits: SVGAnimatedEnumeration; - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - patternContentUnits: SVGAnimatedEnumeration; - patternTransform: SVGAnimatedTransformList; - height: SVGAnimatedLength; -} -declare var SVGPatternElement: { - prototype: SVGPatternElement; - new (): SVGPatternElement; -} - -interface SVGAnimatedAngle { - animVal: SVGAngle; - baseVal: SVGAngle; -} -declare var SVGAnimatedAngle: { - prototype: SVGAnimatedAngle; - new (): SVGAnimatedAngle; -} - -interface Selection { - isCollapsed: boolean; - anchorNode: Node; - focusNode: Node; - anchorOffset: number; - focusOffset: number; - rangeCount: number; - addRange(range: Range): void; - collapseToEnd(): void; - toString(): string; - selectAllChildren(parentNode: Node): void; - getRangeAt(index: number): Range; - collapse(parentNode: Node, offset: number): void; - removeAllRanges(): void; - collapseToStart(): void; - deleteFromDocument(): void; - removeRange(range: Range): void; -} -declare var Selection: { - prototype: Selection; - new (): Selection; -} - -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { - type: string; -} -declare var SVGScriptElement: { - prototype: SVGScriptElement; - new (): SVGScriptElement; -} - -interface HTMLDDElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDDElement: { - prototype: HTMLDDElement; - new (): HTMLDDElement; -} - -interface MSDataBindingRecordSetReadonlyExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface CSSStyleRule extends CSSRule { - selectorText: string; - style: MSStyleCSSProperties; - readOnly: boolean; -} -declare var CSSStyleRule: { - prototype: CSSStyleRule; - new (): CSSStyleRule; -} - -interface NodeIterator { - whatToShow: number; - filter: NodeFilter; - root: Node; - expandEntityReferences: boolean; - nextNode(): Node; - detach(): void; - previousNode(): Node; -} -declare var NodeIterator: { - prototype: NodeIterator; - new (): NodeIterator; -} - -interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { - viewTarget: SVGStringList; -} -declare var SVGViewElement: { - prototype: SVGViewElement; - new (): SVGViewElement; -} - -interface HTMLLinkElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; -} -declare var HTMLLinkElement: { - prototype: HTMLLinkElement; - new (): HTMLLinkElement; -} - -interface SVGLocatable { - farthestViewportElement: SVGElement; - nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getTransformToElement(element: SVGElement): SVGMatrix; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; -} - -interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; -} -declare var HTMLFontElement: { - prototype: HTMLFontElement; - new (): HTMLFontElement; -} - -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGTitleElement: { - prototype: SVGTitleElement; - new (): SVGTitleElement; -} - -interface ControlRangeCollection { - length: number; - queryCommandValue(cmdID: string): any; - remove(index: number): void; - add(item: Element): void; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(varargStart?: any): void; - item(index: number): Element; - [index: number]: Element; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - addElement(item: Element): void; - queryCommandState(cmdID: string): boolean; - queryCommandSupported(cmdID: string): boolean; - queryCommandEnabled(cmdID: string): boolean; - queryCommandText(cmdID: string): string; - select(): void; -} -declare var ControlRangeCollection: { - prototype: ControlRangeCollection; - new (): 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; - new (): MSNamespaceInfo; -} - -interface WindowSessionStorage { - sessionStorage: Storage; -} - -interface SVGAnimatedTransformList { - animVal: SVGTransformList; - baseVal: SVGTransformList; -} -declare var SVGAnimatedTransformList: { - prototype: SVGAnimatedTransformList; - new (): SVGAnimatedTransformList; -} - -interface HTMLTableCaptionElement extends HTMLElement { - /** - * Sets or retrieves the alignment of the caption or legend. - */ - align: string; - /** - * Sets or retrieves whether the caption appears at the top or bottom of the table. - */ - vAlign: string; -} -declare var HTMLTableCaptionElement: { - prototype: HTMLTableCaptionElement; - new (): HTMLTableCaptionElement; -} - -interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; - create(): HTMLOptionElement; -} -declare var HTMLOptionElement: { - prototype: HTMLOptionElement; - new (): HTMLOptionElement; -} - -interface HTMLMapElement extends HTMLElement { - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Retrieves a collection of the area objects defined for the given map object. - */ - areas: HTMLAreasCollection; -} -declare var HTMLMapElement: { - prototype: HTMLMapElement; - new (): HTMLMapElement; -} - -interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { - type: string; -} -declare var HTMLMenuElement: { - prototype: HTMLMenuElement; - new (): HTMLMenuElement; -} - -interface MouseWheelEvent extends MouseEvent { - wheelDelta: number; - initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; -} -declare var MouseWheelEvent: { - prototype: MouseWheelEvent; - new (): MouseWheelEvent; -} - -interface SVGFitToViewBox { - viewBox: SVGAnimatedRect; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} - -interface SVGPointList { - numberOfItems: number; - replaceItem(newItem: SVGPoint, index: number): SVGPoint; - getItem(index: number): SVGPoint; - clear(): void; - appendItem(newItem: SVGPoint): SVGPoint; - initialize(newItem: SVGPoint): SVGPoint; - removeItem(index: number): SVGPoint; - insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; -} -declare var SVGPointList: { - prototype: SVGPointList; - new (): SVGPointList; -} - -interface SVGAnimatedLengthList { - animVal: SVGLengthList; - baseVal: SVGLengthList; -} -declare var SVGAnimatedLengthList: { - prototype: SVGAnimatedLengthList; - new (): 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; - focus(): void; - scrollTo(x?: number, y?: number): void; - print(): void; - prompt(message?: string, defaul?: string): string; - toString(): string; - open(url?: string, target?: string, features?: string, replace?: boolean): Window; - scrollBy(x?: number, y?: number): void; - confirm(message?: string): boolean; - close(): void; - postMessage(message: any, targetOrigin: string, ports?: any): void; - showModalDialog(url?: string, argument?: any, options?: any): any; - blur(): void; - getSelection(): Selection; - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Window: { - prototype: Window; - new (): Window; -} - -interface SVGAnimatedPreserveAspectRatio { - animVal: SVGPreserveAspectRatio; - baseVal: SVGPreserveAspectRatio; -} -declare var SVGAnimatedPreserveAspectRatio: { - prototype: SVGAnimatedPreserveAspectRatio; - new (): SVGAnimatedPreserveAspectRatio; -} - -interface MSSiteModeEvent extends Event { - buttonID: number; - actionURL: string; -} -declare var MSSiteModeEvent: { - prototype: MSSiteModeEvent; - new (): MSSiteModeEvent; -} - -interface DOML2DeprecatedTextFlowControl { - clear: string; -} - -interface StyleSheetPageList { - length: number; - item(index: number): CSSPageRule; - [index: number]: CSSPageRule; -} -declare var StyleSheetPageList: { - prototype: StyleSheetPageList; - new (): StyleSheetPageList; -} - -interface MSCSSProperties extends CSSStyleDeclaration { - scrollbarShadowColor: string; - scrollbarHighlightColor: string; - layoutGridChar: string; - layoutGridType: string; - textAutospace: string; - textKashidaSpace: string; - writingMode: string; - scrollbarFaceColor: string; - backgroundPositionY: string; - lineBreak: string; - imeMode: string; - msBlockProgression: string; - layoutGridLine: string; - scrollbarBaseColor: string; - layoutGrid: string; - layoutFlow: string; - textKashida: string; - filter: string; - zoom: string; - scrollbarArrowColor: string; - behavior: string; - backgroundPositionX: string; - accelerator: string; - layoutGridMode: string; - textJustifyTrim: string; - scrollbar3dLightColor: string; - msInterpolationMode: string; - scrollbarTrackColor: string; - scrollbarDarkShadowColor: string; - styleFloat: string; - getAttribute(attributeName: string, flags?: number): any; - setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; - removeAttribute(attributeName: string, flags?: number): boolean; -} -declare var MSCSSProperties: { - prototype: MSCSSProperties; - new (): MSCSSProperties; -} - -interface HTMLCollection extends MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Retrieves an object from various collections. - */ - item(nameOrIndex?: any, optionalIndex?: any): Element; - /** - * Retrieves a select object or an object from an options collection. - */ - namedItem(name: string): Element; - [name: number]: Element; -} -declare var HTMLCollection: { - prototype: HTMLCollection; - new (): HTMLCollection; -} - -interface SVGExternalResourcesRequired { - externalResourcesRequired: SVGAnimatedBoolean; -} - -interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * The original height of the image resource before sizing. - */ - naturalHeight: number; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * The original width of the image resource before sizing. - */ - naturalWidth: number; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: number; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. - */ - longDesc: string; - /** - * Contains the hypertext reference (HREF) of the URL. - */ - href: string; - /** - * Sets or retrieves whether the image is a server-side image map. - */ - isMap: boolean; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - create(): HTMLImageElement; -} -declare var HTMLImageElement: { - prototype: HTMLImageElement; - new (): HTMLImageElement; -} - -interface HTMLAreaElement extends HTMLElement { - /** - * Sets or retrieves the protocol portion of a URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Sets or retrieves the host name part of the location or URL. - */ - hostname: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Sets or retrieves the file name or path specified by the object. - */ - pathname: string; - /** - * Sets or retrieves the hostname and port number of the location or URL. - */ - host: string; - /** - * Sets or retrieves the subsection of the href property that follows the number sign (#). - */ - hash: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or gets whether clicks in this region cause action. - */ - noHref: boolean; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAreaElement: { - prototype: HTMLAreaElement; - new (): HTMLAreaElement; -} - -interface EventTarget { - removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - dispatchEvent(evt: Event): boolean; -} - -interface SVGAngle { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} -declare var SVGAngle: { - prototype: SVGAngle; - new (): SVGAngle; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} - -interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the default or selected value of the control. - */ - value: string; - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets the classification and default behavior of the button. - */ - type: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; -} -declare var HTMLButtonElement: { - prototype: HTMLButtonElement; - new (): HTMLButtonElement; -} - -interface HTMLSourceElement extends HTMLElement { - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the intended media type of the media source. - */ - media: string; - /** - * Gets or sets the MIME type of a media resource. - */ - type: string; -} -declare var HTMLSourceElement: { - prototype: HTMLSourceElement; - new (): HTMLSourceElement; -} - -interface CanvasGradient { - addColorStop(offset: number, color: string): void; -} -declare var CanvasGradient: { - prototype: CanvasGradient; - new (): CanvasGradient; -} - -interface KeyboardEvent extends UIEvent { - location: number; - keyCode: number; - shiftKey: boolean; - which: number; - locale: string; - key: string; - altKey: boolean; - metaKey: boolean; - char: string; - ctrlKey: boolean; - repeat: boolean; - charCode: number; - getModifierState(keyArg: string): boolean; - initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} -declare var KeyboardEvent: { - prototype: KeyboardEvent; - new (): KeyboardEvent; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} - -interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions { - /** - * Retrieves the collection of user agents and versions declared in the X-UA-Compatible - */ - compatible: MSCompatibleInfoCollection; - /** - * Fires when the user presses a key. - * @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. - */ - implementation: DOMImplementation; - /** - * Fires when the user resets a form. - * @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. - */ - scripts: HTMLCollection; - - /** - * Fires when the user presses the F1 key while the browser is the active window. - * @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. - */ - charset: string; - - /** - * Fires for an element just prior to setting focus on that element. - * @param ev The focus event - */ - 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. - */ - vlinkColor: string; - - /** - * Occurs when the seek operation ends. - * @param ev The event. - */ - 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; - - /** - * Contains the title of the document. - */ - title: string; - - /** - * Retrieves a collection of namespace objects. - */ - namespaces: MSNamespaceInfoCollection; - - /** - * Gets the default character set from the current regional language settings. - */ - defaultCharset: string; - - /** - * Retrieves a collection of all embed objects in the document. - */ - embeds: HTMLCollection; - - /** - * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. - */ - styleSheets: StyleSheetList; - - /** - * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. - */ - frames: Window; - - /** - * Occurs when the duration attribute is updated. - * @param ev The event. - */ - 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. - */ - all: HTMLCollection; - - /** - * Retrieves a collection, in source order, of all form objects in the document. - */ - forms: HTMLCollection; - - /** - * Fires when the object loses the input focus. - * @param ev The focus event. - */ - 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. - */ - dir: string; - - /** - * Occurs when the media element is reset to its initial state. - * @param ev The event. - */ - 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. - */ - designMode: string; - - /** - * Occurs when the current playback position is moved. - * @param ev The event. - */ - 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. - * @param ev The UI Event - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event - */ - 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; - - /** - * Occurs when Internet Explorer begins looking for media data. - * @param ev The event. - */ - 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. - */ - URLUnencoded: string; - - defaultView: Window; - - /** - * Fires when the user is about to make a control selection of the object. - * @param ev The event. - */ - 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. - * @param ev The drag event. - */ - 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. - */ - inputEncoding: string; - - /** - * Gets the object that has the focus when the parent document has focus. - */ - activeElement: Element; - - /** - * Fires when the contents of the object or selection have changed. - * @param ev The event. - */ - 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. - */ - links: HTMLCollection; - - /** - * Retrieves an autogenerated, unique identifier for the object. - */ - uniqueID: string; - - /** - * Sets or gets the URL for the current document. - */ - URL: string; - - /** - * Fires immediately before the object is set as the active element. - * @param ev The event. - */ - 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. - */ - documentMode: number; - - characterSet: string; - - /** - * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. - */ - 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. - * @param ev The event. - */ - 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; - - /** - * Occurs if the load operation has been intentionally halted. - * @param ev The event. - */ - 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. - */ - rootElement: SVGSVGElement; - - /** - * Retrieves a value that indicates the current state of the object. - */ - readyState: string; - - /** - * Gets the URL of the location that referred the user to the current page. - */ - referrer: string; - - /** - * Sets or gets the color of all active links in the document. - */ - alinkColor: string; - - /** - * Fires on a databound object when an error occurs while updating the associated data in the data source object. - * @param ev The event. - */ - 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. - */ - parentWindow: Window; - - /** - * Fires when the user moves the mouse pointer outside the boundaries of the object. - * @param ev The mouse event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The mouse event - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - */ - xmlVersion: string; - - msCapsLockWarningOff: boolean; - - /** - * Fires when a property changes on the object. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - */ - doctype: DocumentType; - - /** - * Fires on the target element continuously while the user drags the object over a valid drop target. - * @param ev The event. - */ - 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. - */ - bgColor: string; - - /** - * Fires on the source object when the user starts to drag a text selection or selected object. - * @param ev The event. - */ - 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. - * @param ev The mouse event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The mouse event. - */ - 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. - */ - linkColor: string; - - /** - * Occurs when playback is paused. - * @param ev The event. - */ - 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. - * @param ev The mouse event. - */ - 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 - * @param ev The mouse event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - */ - applets: HTMLCollection; - - /** - * Specifies the beginning and end of the document body. - */ - body: HTMLElement; - - /** - * Sets or gets the security domain of the document. - */ - domain: string; - - xmlStandalone: boolean; - - /** - * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. - */ - selection: MSSelection; - - /** - * Occurs when the download has stopped. - * @param ev The event. - */ - 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. - * @param ev The mouse event. - */ - 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. - */ - documentElement: HTMLElement; - - /** - * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The mouse event. - */ - 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. - * @param ev The mouse event. - */ - 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. - * @param ev The event. - */ - 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; - - /** - * Fires when an error occurs during object loading. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - */ - images: HTMLCollection; - - /** - * Contains information about the current URL. - */ - location: Location; - - /** - * Fires when the user aborts the download. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event - */ - 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. - */ - lastModified: string; - - /** - * Fires when the user presses an alphanumeric key. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - */ - fgColor: string; - - /** - * Occurs to indicate the current playback position. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event - */ - 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. - */ - compatMode: string; - - /** - * Fires when the user repositions the scroll box in the scroll bar on the object. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param ev The event. - */ - 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. - * @param commandId String that specifies a command identifier. - */ - queryCommandValue(commandId: string): string; - - adoptNode(source: Node): Node; - - /** - * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. - * @param commandId String that specifies a command identifier. - */ - queryCommandIndeterm(commandId: string): boolean; - - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - createProcessingInstruction(target: string, data: string): ProcessingInstruction; - - /** - * Executes a command on the current document, current selection, or the given range. - * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. - * @param showUI Display the user interface, defaults to false. - * @param value Value to assign. - */ - execCommand(commandId: string, showUI?: boolean, value?: any): boolean; - - /** - * Returns the element for the specified x coordinate and the specified y coordinate. - * @param x The x-offset - * @param y The y-offset - */ - elementFromPoint(x: number, y: number): Element; - createCDATASection(data: string): CDATASection; - - /** - * Retrieves the string associated with a command. - * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. - */ - queryCommandText(commandId: string): string; - - /** - * Writes one or more HTML expressions to a document in the specified window. - * @param content Specifies the text and HTML tags to write. - */ - write(...content: string[]): void; - - /** - * Allows updating the print settings for the page. - */ - updateSettings(): void; - - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "a"): HTMLAnchorElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "abbr"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "address"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "area"): HTMLAreaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "article"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "aside"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "audio"): HTMLAudioElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "b"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "base"): HTMLBaseElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "bdi"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "bdo"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "blockquote"): HTMLQuoteElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "body"): HTMLBodyElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "br"): HTMLBRElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "button"): HTMLButtonElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "canvas"): HTMLCanvasElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "caption"): HTMLTableCaptionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "cite"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "code"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "col"): HTMLTableColElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "colgroup"): HTMLTableColElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "datalist"): HTMLDataListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dd"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "del"): HTMLModElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dfn"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "div"): HTMLDivElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dl"): HTMLDListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dt"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "em"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "embed"): HTMLEmbedElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "fieldset"): HTMLFieldSetElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "figcaption"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "figure"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "footer"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "form"): HTMLFormElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h1"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h2"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h3"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h4"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h5"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h6"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "head"): HTMLHeadElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "header"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "hgroup"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "hr"): HTMLHRElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "html"): HTMLHtmlElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "i"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "iframe"): HTMLIFrameElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "img"): HTMLImageElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "input"): HTMLInputElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ins"): HTMLModElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "kbd"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "label"): HTMLLabelElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "legend"): HTMLLegendElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "li"): HTMLLIElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "link"): HTMLLinkElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "main"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "map"): HTMLMapElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "mark"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "menu"): HTMLMenuElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "meta"): HTMLMetaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "nav"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "noscript"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "object"): HTMLObjectElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ol"): HTMLOListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "optgroup"): HTMLOptGroupElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "option"): HTMLOptionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "p"): HTMLParagraphElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "param"): HTMLParamElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "pre"): HTMLPreElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "progress"): HTMLProgressElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "q"): HTMLQuoteElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "rp"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "rt"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ruby"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "s"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "samp"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "script"): HTMLScriptElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "section"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "select"): HTMLSelectElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "small"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "source"): HTMLSourceElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "span"): HTMLSpanElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "strong"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "style"): HTMLStyleElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "sub"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "summary"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "sup"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "table"): HTMLTableElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tbody"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "td"): HTMLTableDataCellElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "textarea"): HTMLTextAreaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tfoot"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "th"): HTMLTableHeaderCellElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "thead"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "title"): HTMLTitleElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tr"): HTMLTableRowElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "track"): HTMLTrackElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "u"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ul"): HTMLUListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "var"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "video"): HTMLVideoElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "wbr"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: string): HTMLElement; - - /** - * Removes mouse capture from the object in the current document. - */ - releaseCapture(): void; - - /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. - * @param content The text and HTML tags to write. - */ - writeln(...content: string[]): void; - createElementNS(namespaceURI: string, qualifiedName: string): Element; - - /** - * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. - * @param url Specifies a MIME type for the document. - * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. - * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. - * @param replace Specifies whether the existing entry for the document is replaced in the history list. - */ - open(url?: string, name?: string, features?: string, replace?: boolean): any; - - /** - * Returns a Boolean value that indicates whether the current command is supported on the current range. - * @param commandId Specifies a command identifier. - */ - queryCommandSupported(commandId: string): boolean; - - /** - * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. - * @param filter A custom NodeFilter function to use. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; - createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; - - /** - * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. - * @param commandId Specifies a command identifier. - */ - queryCommandEnabled(commandId: string): boolean; - - /** - * Causes the element to receive the focus and executes the code specified by the onfocus event. - */ - focus(): void; - - /** - * Closes an output stream and forces the sent data to display. - */ - close(): void; - - getElementsByClassName(classNames: string): NodeList; - importNode(importedNode: Node, deep: boolean): Node; - - /** - * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. - */ - createRange(): Range; - - /** - * Fires a specified event on the object. - * @param eventName Specifies the name of the event to fire. - * @param eventObj Object that specifies the event object from which to obtain event object properties. - */ - fireEvent(eventName: string, eventObj?: any): boolean; - - /** - * Creates a comment object with the specified data. - * @param data Sets the comment object's data. - */ - createComment(data: string): Comment; - - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "a"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "abbr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "address"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "area"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "article"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "aside"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "audio"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "b"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "base"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "bdi"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "bdo"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "blockquote"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "body"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "br"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "button"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "canvas"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "caption"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "cite"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "code"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "col"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "colgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "datalist"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dd"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "del"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dfn"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "div"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dl"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dt"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "em"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "embed"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "fieldset"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "figcaption"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "figure"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "footer"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "form"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h1"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h2"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h3"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h4"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h5"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h6"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "head"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "header"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "hgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "hr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "html"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "i"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "iframe"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "img"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "input"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ins"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "kbd"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "label"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "legend"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "li"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "link"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "main"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "map"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "mark"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "menu"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "meta"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "nav"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "noscript"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "object"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ol"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "optgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "option"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "p"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "param"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "pre"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "progress"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "q"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "rp"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "rt"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ruby"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "s"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "samp"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "script"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "section"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "select"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "small"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "source"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "span"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "strong"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "style"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "sub"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "summary"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "sup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "table"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tbody"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "td"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "textarea"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tfoot"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "th"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "thead"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "title"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "track"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "u"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ul"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "var"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "video"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "wbr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: string): NodeList; - - /** - * Creates a new document. - */ - createDocumentFragment(): DocumentFragment; - - /** - * Creates a style sheet for the document. - * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. - * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. - */ - createStyleSheet(href?: string, index?: number): CSSStyleSheet; - - /** - * Gets a collection of objects based on the value of the NAME or ID attribute. - * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. - */ - getElementsByName(elementName: string): NodeList; - - /** - * Returns a Boolean value that indicates the current state of the command. - * @param commandId String that specifies a command identifier. - */ - queryCommandState(commandId: string): boolean; - - /** - * Gets a value indicating whether the object currently has focus. - */ - hasFocus(): boolean; - - /** - * Displays help information for the given command identifier. - * @param commandId Displays help information for the given command identifier. - */ - execCommandShowHelp(commandId: string): boolean; - - /** - * Creates an attribute object with a specified name. - * @param name String that sets the attribute object's name. - */ - createAttribute(name: string): Attr; - - /** - * Creates a text string from the specified value. - * @param data String that specifies the nodeValue property of the text node. - */ - createTextNode(data: string): Text; - - /** - * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list - * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; - - /** - * Generates an event object to pass event context information when you use the fireEvent method. - * @param eventObj An object that specifies an existing event object on which to base the new object. - */ - createEventObject(eventObj?: any): MSEventObj; - - /** - * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. - */ - getSelection(): Selection; - - /** - * Returns a reference to the first object with the specified value of the ID or NAME attribute. - * @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: { - prototype: Document; - new (): Document; -} - -interface MessageEvent extends Event { - source: Window; - origin: string; - data: any; - initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; -} -declare var MessageEvent: { - prototype: MessageEvent; - new (): 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; - new (): SVGElement; -} - -interface HTMLScriptElement extends HTMLElement { - /** - * Sets or retrieves the status of the script. - */ - defer: boolean; - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; - /** - * Retrieves the URL to an external file that contains the source code or data. - */ - src: string; - /** - * Sets or retrieves the object that is bound to the event script. - */ - htmlFor: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the MIME type for the associated scripting engine. - */ - type: string; - /** - * Sets or retrieves the event for which the script is written. - */ - event: string; -} -declare var HTMLScriptElement: { - prototype: HTMLScriptElement; - new (): HTMLScriptElement; -} - -interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Retrieves the position of the object in the rows collection for the table. - */ - rowIndex: number; - /** - * Retrieves a collection of all cells in the table row. - */ - cells: HTMLCollection; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Retrieves the position of the object in the collection. - */ - sectionRowIndex: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified cell from the table row, as well as from the cells collection. - * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. - */ - deleteCell(index?: number): void; - /** - * Creates a new cell in the table row, and adds the cell to the cells collection. - * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. - */ - insertCell(index?: number): HTMLElement; -} -declare var HTMLTableRowElement: { - prototype: HTMLTableRowElement; - new (): HTMLTableRowElement; -} - -interface CanvasRenderingContext2D { - miterLimit: number; - font: string; - globalCompositeOperation: string; - msFillRule: string; - lineCap: string; - msImageSmoothingEnabled: boolean; - lineDashOffset: number; - shadowColor: string; - lineJoin: string; - shadowOffsetX: number; - lineWidth: number; - canvas: HTMLCanvasElement; - strokeStyle: any; - globalAlpha: number; - shadowOffsetY: number; - fillStyle: any; - shadowBlur: number; - textAlign: string; - textBaseline: string; - restore(): void; - setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - save(): void; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - measureText(text: string): TextMetrics; - isPointInPath(x: number, y: number, fillRule?: string): boolean; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; - rotate(angle: number): void; - fillText(text: string, x: number, y: number, maxWidth?: number): void; - translate(x: number, y: number): void; - scale(x: number, y: number): void; - createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - lineTo(x: number, y: number): void; - getLineDash(): Array; - fill(fillRule?: string): void; - createImageData(imageDataOrSw: any, sh?: number): ImageData; - createPattern(image: HTMLElement, repetition: string): CanvasPattern; - closePath(): void; - rect(x: number, y: number, w: number, h: number): void; - clip(fillRule?: string): void; - clearRect(x: number, y: number, w: number, h: number): void; - moveTo(x: number, y: number): void; - getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; - fillRect(x: number, y: number, w: number, h: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; - strokeRect(x: number, y: number, w: number, h: number): void; - setLineDash(segments: Array): void; - strokeText(text: string, x: number, y: number, maxWidth?: number): void; - beginPath(): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; - createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; -} -declare var CanvasRenderingContext2D: { - prototype: CanvasRenderingContext2D; - new (): CanvasRenderingContext2D; -} - -interface MSCSSRuleList { - length: number; - item(index?: number): CSSStyleRule; - [index: number]: CSSStyleRule; -} -declare var MSCSSRuleList: { - prototype: MSCSSRuleList; - new (): MSCSSRuleList; -} - -interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalAbs: { - prototype: SVGPathSegLinetoHorizontalAbs; - new (): SVGPathSegLinetoHorizontalAbs; -} - -interface SVGPathSegArcAbs extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcAbs: { - prototype: SVGPathSegArcAbs; - new (): SVGPathSegArcAbs; -} - -interface SVGTransformList { - numberOfItems: number; - getItem(index: number): SVGTransform; - consolidate(): SVGTransform; - clear(): void; - appendItem(newItem: SVGTransform): SVGTransform; - initialize(newItem: SVGTransform): SVGTransform; - removeItem(index: number): SVGTransform; - insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; - replaceItem(newItem: SVGTransform, index: number): SVGTransform; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; -} -declare var SVGTransformList: { - prototype: SVGTransformList; - new (): SVGTransformList; -} - -interface HTMLHtmlElement extends HTMLElement { - /** - * Sets or retrieves the DTD version that governs the current document. - */ - version: string; -} -declare var HTMLHtmlElement: { - prototype: HTMLHtmlElement; - new (): HTMLHtmlElement; -} - -interface SVGPathSegClosePath extends SVGPathSeg { -} -declare var SVGPathSegClosePath: { - prototype: SVGPathSegClosePath; - new (): SVGPathSegClosePath; -} - -interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * 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; - new (): HTMLFrameElement; -} - -interface SVGAnimatedLength { - animVal: SVGLength; - baseVal: SVGLength; -} -declare var SVGAnimatedLength: { - prototype: SVGAnimatedLength; - new (): SVGAnimatedLength; -} - -interface SVGAnimatedPoints { - points: SVGPointList; - animatedPoints: SVGPointList; -} - -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGDefsElement: { - prototype: SVGDefsElement; - new (): SVGDefsElement; -} - -interface HTMLQuoteElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLQuoteElement: { - prototype: HTMLQuoteElement; - new (): HTMLQuoteElement; -} - -interface CSSMediaRule extends CSSRule { - media: MediaList; - cssRules: CSSRuleList; - insertRule(rule: string, index?: number): number; - deleteRule(index?: number): void; -} -declare var CSSMediaRule: { - prototype: CSSMediaRule; - new (): CSSMediaRule; -} - -interface WindowModal { - dialogArguments: any; - returnValue: any; -} - -interface XMLHttpRequest extends EventTarget { - responseBody: any; - status: number; - readyState: number; - 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; - abort(): void; - 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; - OPENED: number; - HEADERS_RECEIVED: number; -} -declare var XMLHttpRequest: { - prototype: XMLHttpRequest; - new (): XMLHttpRequest; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; -} - -interface HTMLTableHeaderCellElement extends HTMLTableCellElement { - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; -} -declare var HTMLTableHeaderCellElement: { - prototype: HTMLTableHeaderCellElement; - new (): HTMLTableHeaderCellElement; -} - -interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { -} -declare var HTMLDListElement: { - prototype: HTMLDListElement; - new (): HTMLDListElement; -} - -interface MSDataBindingExtensions { - dataSrc: string; - dataFormatAs: string; - dataFld: string; -} - -interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalRel: { - prototype: SVGPathSegLinetoHorizontalRel; - new (): SVGPathSegLinetoHorizontalRel; -} - -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - ry: SVGAnimatedLength; - cx: SVGAnimatedLength; - rx: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGEllipseElement: { - prototype: SVGEllipseElement; - new (): SVGEllipseElement; -} - -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - target: SVGAnimatedString; -} -declare var SVGAElement: { - prototype: SVGAElement; - new (): SVGAElement; -} - -interface SVGStylable { - className: SVGAnimatedString; - style: CSSStyleDeclaration; -} - -interface SVGTransformable extends SVGLocatable { - transform: SVGAnimatedTransformList; -} - -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. - */ - borderColor: any; - /** - * Sets or retrieves the frame heights of the object. - */ - rows: string; - /** - * Sets or retrieves the frame widths of the object. - */ - cols: string; - /** - * 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. - */ - frameSpacing: any; - /** - * 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; - new (): HTMLFrameSetElement; -} - -interface Screen { - width: number; - deviceXDPI: number; - fontSmoothingEnabled: boolean; - bufferDepth: number; - logicalXDPI: number; - systemXDPI: number; - availHeight: number; - height: number; - logicalYDPI: number; - systemYDPI: number; - updateInterval: number; - colorDepth: number; - availWidth: number; - deviceYDPI: number; - pixelDepth: number; -} -declare var Screen: { - prototype: Screen; - new (): Screen; -} - -interface Coordinates { - altitudeAccuracy: number; - longitude: number; - latitude: number; - speed: number; - heading: number; - altitude: number; - accuracy: number; -} -declare var Coordinates: { - prototype: Coordinates; - new (): Coordinates; -} - -interface NavigatorGeolocation { - geolocation: Geolocation; -} - -interface NavigatorContentUtils { -} - -interface EventListener { - (evt: Event): void; -} - -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface DataTransfer { - effectAllowed: string; - dropEffect: string; - clearData(format?: string): boolean; - setData(format: string, data: string): boolean; - getData(format: string): string; -} -declare var DataTransfer: { - prototype: DataTransfer; - new (): DataTransfer; -} - -interface FocusEvent extends UIEvent { - relatedTarget: EventTarget; - initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; -} -declare var FocusEvent: { - prototype: FocusEvent; - new (): FocusEvent; -} - -interface Range { - startOffset: number; - collapsed: boolean; - endOffset: number; - startContainer: Node; - endContainer: Node; - commonAncestorContainer: Node; - setStart(refNode: Node, offset: number): void; - setEndBefore(refNode: Node): void; - setStartBefore(refNode: Node): void; - selectNode(refNode: Node): void; - detach(): void; - getBoundingClientRect(): ClientRect; - toString(): string; - compareBoundaryPoints(how: number, sourceRange: Range): number; - insertNode(newNode: Node): void; - collapse(toStart: boolean): void; - selectNodeContents(refNode: Node): void; - cloneContents(): DocumentFragment; - setEnd(refNode: Node, offset: number): void; - cloneRange(): Range; - getClientRects(): ClientRectList; - surroundContents(newParent: Node): void; - deleteContents(): void; - setStartAfter(refNode: Node): void; - extractContents(): DocumentFragment; - setEndAfter(refNode: Node): void; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} -declare var Range: { - prototype: Range; - new (): Range; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} - -interface SVGPoint { - y: number; - x: number; - matrixTransform(matrix: SVGMatrix): SVGPoint; -} -declare var SVGPoint: { - prototype: SVGPoint; - new (): SVGPoint; -} - -interface MSPluginsCollection { - length: number; - refresh(reload?: boolean): void; -} -declare var MSPluginsCollection: { - prototype: MSPluginsCollection; - new (): MSPluginsCollection; -} - -interface SVGAnimatedNumberList { - animVal: SVGNumberList; - baseVal: SVGNumberList; -} -declare var SVGAnimatedNumberList: { - prototype: SVGAnimatedNumberList; - new (): SVGAnimatedNumberList; -} - -interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { - width: SVGAnimatedLength; - 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; - getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; - unpauseAnimations(): void; - createSVGRect(): SVGRect; - checkIntersection(element: SVGElement, rect: SVGRect): boolean; - unsuspendRedrawAll(): void; - pauseAnimations(): void; - suspendRedraw(maxWaitMilliseconds: number): number; - deselectAll(): void; - createSVGAngle(): SVGAngle; - getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; - createSVGTransform(): SVGTransform; - unsuspendRedraw(suspendHandleID: number): void; - forceRedraw(): void; - getCurrentTime(): number; - checkEnclosure(element: SVGElement, rect: SVGRect): boolean; - createSVGMatrix(): SVGMatrix; - createSVGPoint(): SVGPoint; - createSVGNumber(): SVGNumber; - 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; - new (): SVGSVGElement; -} - -interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the object to which the given label object is assigned. - */ - htmlFor: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLabelElement: { - prototype: HTMLLabelElement; - new (): HTMLLabelElement; -} - -interface MSResourceMetadata { - protocol: string; - fileSize: string; - fileUpdatedDate: string; - nameProp: string; - fileCreatedDate: string; - fileModifiedDate: string; - mimeType: string; -} - -interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLegendElement: { - prototype: HTMLLegendElement; - new (): HTMLLegendElement; -} - -interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLDirectoryElement: { - prototype: HTMLDirectoryElement; - new (): HTMLDirectoryElement; -} - -interface SVGAnimatedInteger { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedInteger: { - prototype: SVGAnimatedInteger; - new (): SVGAnimatedInteger; -} - -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { -} -declare var SVGTextElement: { - prototype: SVGTextElement; - new (): SVGTextElement; -} - -interface SVGTSpanElement extends SVGTextPositioningElement { -} -declare var SVGTSpanElement: { - prototype: SVGTSpanElement; - new (): SVGTSpanElement; -} - -interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * Sets or retrieves the value of a list item. - */ - value: number; -} -declare var HTMLLIElement: { - prototype: HTMLLIElement; - new (): HTMLLIElement; -} - -interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalAbs: { - prototype: SVGPathSegLinetoVerticalAbs; - new (): SVGPathSegLinetoVerticalAbs; -} - -interface MSStorageExtensions { - remainingSpace: number; -} - -interface SVGStyleElement extends SVGElement, SVGLangSpace { - media: string; - type: string; - title: string; -} -declare var SVGStyleElement: { - prototype: SVGStyleElement; - new (): SVGStyleElement; -} - -interface MSCurrentStyleCSSProperties extends MSCSSProperties { - blockDirection: string; - clipBottom: string; - clipLeft: string; - clipRight: string; - clipTop: string; - hasLayout: string; -} -declare var MSCurrentStyleCSSProperties: { - prototype: MSCurrentStyleCSSProperties; - new (): MSCurrentStyleCSSProperties; -} - -interface MSHTMLCollectionExtensions { - urns(urn: any): Object; - tags(tagName: any): Object; -} - -interface Storage extends MSStorageExtensions { - length: number; - getItem(key: string): any; - [key: string]: any; - setItem(key: string, data: string): void; - clear(): void; - removeItem(key: string): void; - key(index: number): string; - [index: number]: any; -} -declare var Storage: { - prototype: Storage; - new (): Storage; -} - -interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Sets or retrieves the horizontal margin for the object. - */ - hspace: number; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; - /** - * 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; - new (): HTMLIFrameElement; -} - -interface TextRangeCollection { - length: number; - item(index: number): TextRange; - [index: number]: TextRange; -} -declare var TextRangeCollection: { - prototype: TextRangeCollection; - new (): 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; - new (): HTMLBodyElement; -} - -interface DocumentType extends Node { - name: string; - notations: NamedNodeMap; - systemId: string; - internalSubset: string; - entities: NamedNodeMap; - publicId: string; -} -declare var DocumentType: { - prototype: DocumentType; - new (): DocumentType; -} - -interface SVGRadialGradientElement extends SVGGradientElement { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; - fx: SVGAnimatedLength; - fy: SVGAnimatedLength; -} -declare var SVGRadialGradientElement: { - prototype: SVGRadialGradientElement; - new (): SVGRadialGradientElement; -} - -interface MutationEvent extends Event { - newValue: string; - attrChange: number; - attrName: string; - prevValue: string; - relatedNode: Node; - initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} -declare var MutationEvent: { - prototype: MutationEvent; - new (): MutationEvent; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} - -interface DragEvent extends MouseEvent { - dataTransfer: DataTransfer; - initDragEvent(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, dataTransferArg: DataTransfer): void; -} -declare var DragEvent: { - prototype: DragEvent; - new (): DragEvent; -} - -interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): Object; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; -} -declare var HTMLTableSectionElement: { - prototype: HTMLTableSectionElement; - new (): HTMLTableSectionElement; -} - -interface DOML2DeprecatedListNumberingAndBulletStyle { - type: string; -} - -interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - status: boolean; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - indeterminate: boolean; - readOnly: boolean; - size: number; - loop: number; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. - */ - vrml: string; - /** - * Sets or retrieves a lower resolution image to display. - */ - lowsrc: string; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Sets or retrieves a comma-separated list of content types. - */ - accept: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - defaultChecked: boolean; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Returns the value of the data at the cursor's current position. - */ - value: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - dynsrc: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - checked: boolean; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - start: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Makes the selection equal to the current object. - */ - select(): void; -} -declare var HTMLInputElement: { - prototype: HTMLInputElement; - new (): HTMLInputElement; -} - -interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Contains the protocol of the URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Contains the hostname of a URL. - */ - hostname: string; - /** - * Contains the pathname of the URL. - */ - pathname: string; - Methods: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - protocolLong: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Contains the hostname and port values of the URL. - */ - host: string; - /** - * Contains the anchor portion of the URL including the hash sign (#). - */ - hash: string; - nameProp: string; - urn: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - type: string; - mimeType: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAnchorElement: { - prototype: HTMLAnchorElement; - new (): HTMLAnchorElement; -} - -interface HTMLParamElement extends HTMLElement { - /** - * Sets or retrieves the value of an input parameter for an element. - */ - value: string; - /** - * Sets or retrieves the name of an input parameter for an element. - */ - name: string; - /** - * Sets or retrieves the content type of the resource designated by the value attribute. - */ - type: string; - /** - * Sets or retrieves the data type of the value attribute. - */ - valueType: string; -} -declare var HTMLParamElement: { - prototype: HTMLParamElement; - new (): HTMLParamElement; -} - -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGImageElement: { - prototype: SVGImageElement; - new (): SVGImageElement; -} - -interface SVGAnimatedNumber { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedNumber: { - prototype: SVGAnimatedNumber; - new (): SVGAnimatedNumber; -} - -interface PerformanceTiming { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - msFirstPaint: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - toJSON(): any; -} -declare var PerformanceTiming: { - prototype: PerformanceTiming; - new (): PerformanceTiming; -} - -interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or gets a value that you can use to implement your own width functionality for the object. - */ - width: number; - /** - * Indicates a citation by rendering text in italic type. - */ - cite: string; -} -declare var HTMLPreElement: { - prototype: HTMLPreElement; - new (): HTMLPreElement; -} - -interface EventException { - code: number; - message: string; - toString(): string; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} -declare var EventException: { - prototype: EventException; - new (): EventException; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} - -interface MSNavigatorDoNotTrack { - msDoNotTrack: string; -} - -interface NavigatorOnLine { - onLine: boolean; -} - -interface WindowLocalStorage { - localStorage: Storage; -} - -interface SVGMetadataElement extends SVGElement { -} -declare var SVGMetadataElement: { - prototype: SVGMetadataElement; - new (): SVGMetadataElement; -} - -interface SVGPathSegArcRel extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcRel: { - prototype: SVGPathSegArcRel; - new (): SVGPathSegArcRel; -} - -interface SVGPathSegMovetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoAbs: { - prototype: SVGPathSegMovetoAbs; - new (): SVGPathSegMovetoAbs; -} - -interface SVGStringList { - numberOfItems: number; - replaceItem(newItem: string, index: number): string; - getItem(index: number): string; - clear(): void; - appendItem(newItem: string): string; - initialize(newItem: string): string; - removeItem(index: number): string; - insertItemBefore(newItem: string, index: number): string; -} -declare var SVGStringList: { - prototype: SVGStringList; - new (): 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; - new (): XDomainRequest; -} - -interface DOML2DeprecatedBackgroundColorStyle { - bgColor: any; -} - -interface ElementTraversal { - childElementCount: number; - previousElementSibling: Element; - lastElementChild: Element; - nextElementSibling: Element; - firstElementChild: Element; -} - -interface SVGLength { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} -declare var SVGLength: { - prototype: SVGLength; - new (): SVGLength; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} - -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolygonElement: { - prototype: SVGPolygonElement; - new (): SVGPolygonElement; -} - -interface HTMLPhraseElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLPhraseElement: { - prototype: HTMLPhraseElement; - new (): HTMLPhraseElement; -} - -interface NavigatorStorageUtils { -} - -interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicRel: { - prototype: SVGPathSegCurvetoCubicRel; - new (): SVGPathSegCurvetoCubicRel; -} - -interface MSEventObj extends Event { - nextPage: string; - keyCode: number; - toElement: Element; - returnValue: any; - dataFld: string; - y: number; - dataTransfer: DataTransfer; - propertyName: string; - url: string; - offsetX: number; - recordset: Object; - screenX: number; - buttonID: number; - wheelDelta: number; - reason: number; - origin: string; - data: string; - srcFilter: Object; - boundElements: HTMLCollection; - cancelBubble: boolean; - altLeft: boolean; - behaviorCookie: number; - bookmarks: BookmarkCollection; - type: string; - repeat: boolean; - srcElement: Element; - source: Window; - fromElement: Element; - offsetY: number; - x: number; - behaviorPart: number; - qualifier: string; - altKey: boolean; - ctrlKey: boolean; - clientY: number; - shiftKey: boolean; - shiftLeft: boolean; - contentOverflow: boolean; - screenY: number; - ctrlLeft: boolean; - button: number; - srcUrn: string; - clientX: number; - actionURL: string; - getAttribute(strAttributeName: string, lFlags?: number): any; - setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; - removeAttribute(strAttributeName: string, lFlags?: number): boolean; -} -declare var MSEventObj: { - prototype: MSEventObj; - new (): MSEventObj; -} - -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - textLength: SVGAnimatedLength; - lengthAdjust: SVGAnimatedEnumeration; - getCharNumAtPosition(point: SVGPoint): number; - getStartPositionOfChar(charnum: number): SVGPoint; - getExtentOfChar(charnum: number): SVGRect; - getComputedTextLength(): number; - getSubStringLength(charnum: number, nchars: number): number; - selectSubString(charnum: number, nchars: number): void; - getNumberOfChars(): number; - getRotationOfChar(charnum: number): number; - getEndPositionOfChar(charnum: number): SVGPoint; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} -declare var SVGTextContentElement: { - prototype: SVGTextContentElement; - new (): SVGTextContentElement; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} - -interface DOML2DeprecatedColorProperty { - color: string; -} - -interface HTMLCanvasElement extends HTMLElement { - /** - * Gets or sets the width of a canvas element on a document. - */ - width: number; - /** - * Gets or sets the height of a canvas element on a document. - */ - height: number; - /** - * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. - * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. - * @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: string, ...args: any[]): any; -} -declare var HTMLCanvasElement: { - prototype: HTMLCanvasElement; - new (): HTMLCanvasElement; -} - -interface Location { - hash: string; - protocol: string; - search: string; - href: string; - hostname: string; - port: string; - pathname: string; - host: string; - reload(flag?: boolean): void; - replace(url: string): void; - assign(url: string): void; - toString(): string; -} -declare var Location: { - prototype: Location; - new (): Location; -} - -interface HTMLTitleElement extends HTMLElement { - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; -} -declare var HTMLTitleElement: { - prototype: HTMLTitleElement; - new (): HTMLTitleElement; -} - -interface HTMLStyleElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Retrieves the CSS language in which the style sheet is written. - */ - type: string; -} -declare var HTMLStyleElement: { - prototype: HTMLStyleElement; - new (): HTMLStyleElement; -} - -interface PerformanceEntry { - name: string; - startTime: number; - duration: number; - entryType: string; -} -declare var PerformanceEntry: { - prototype: PerformanceEntry; - new (): PerformanceEntry; -} - -interface SVGTransform { - type: number; - angle: number; - matrix: SVGMatrix; - setTranslate(tx: number, ty: number): void; - setScale(sx: number, sy: number): void; - setMatrix(matrix: SVGMatrix): void; - setSkewY(angle: number): void; - setRotate(angle: number, cx: number, cy: number): void; - setSkewX(angle: number): void; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} -declare var SVGTransform: { - prototype: SVGTransform; - new (): SVGTransform; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} - -interface UIEvent extends Event { - detail: number; - view: Window; - initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; -} -declare var UIEvent: { - prototype: UIEvent; - new (): UIEvent; -} - -interface SVGURIReference { - href: SVGAnimatedString; -} - -interface SVGPathSeg { - pathSegType: number; - pathSegTypeAsLetter: string; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} -declare var SVGPathSeg: { - prototype: SVGPathSeg; - new (): SVGPathSeg; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} - -interface WheelEvent extends MouseEvent { - deltaZ: number; - deltaX: number; - deltaMode: number; - deltaY: number; - initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} -declare var WheelEvent: { - prototype: WheelEvent; - new (): WheelEvent; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} - -interface MSEventAttachmentTarget { - attachEvent(event: string, listener: EventListener): boolean; - detachEvent(event: string, listener: EventListener): void; -} - -interface SVGNumber { - value: number; -} -declare var SVGNumber: { - prototype: SVGNumber; - new (): SVGNumber; -} - -interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - getPathSegAtLength(distance: number): number; - getPointAtLength(distance: number): SVGPoint; - createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; - createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; - createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; - createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; - createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; - createSVGPathSegClosePath(): SVGPathSegClosePath; - createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; - createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; - createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; - createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; - createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; - createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; - createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; - createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; - createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; - getTotalLength(): number; - createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; - createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; - createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; - createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; -} -declare var SVGPathElement: { - prototype: SVGPathElement; - new (): SVGPathElement; -} - -interface MSCompatibleInfo { - version: string; - userAgent: string; -} -declare var MSCompatibleInfo: { - prototype: MSCompatibleInfo; - new (): MSCompatibleInfo; -} - -interface Text extends CharacterData, MSNodeExtensions { - wholeText: string; - splitText(offset: number): Text; - replaceWholeText(content: string): Text; -} -declare var Text: { - prototype: Text; - new (): Text; -} - -interface SVGAnimatedRect { - animVal: SVGRect; - baseVal: SVGRect; -} -declare var SVGAnimatedRect: { - prototype: SVGAnimatedRect; - new (): SVGAnimatedRect; -} - -interface CSSNamespaceRule extends CSSRule { - namespaceURI: string; - prefix: string; -} -declare var CSSNamespaceRule: { - prototype: CSSNamespaceRule; - new (): CSSNamespaceRule; -} - -interface SVGPathSegList { - numberOfItems: number; - replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; - getItem(index: number): SVGPathSeg; - clear(): void; - appendItem(newItem: SVGPathSeg): SVGPathSeg; - initialize(newItem: SVGPathSeg): SVGPathSeg; - removeItem(index: number): SVGPathSeg; - insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; -} -declare var SVGPathSegList: { - prototype: SVGPathSegList; - new (): SVGPathSegList; -} - -interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { -} -declare var HTMLUnknownElement: { - prototype: HTMLUnknownElement; - new (): HTMLUnknownElement; -} - -interface HTMLAudioElement extends HTMLMediaElement { -} -declare var HTMLAudioElement: { - prototype: HTMLAudioElement; - new (): HTMLAudioElement; -} - -interface MSImageResourceExtensions { - dynsrc: string; - vrml: string; - lowsrc: string; - start: string; - loop: number; -} - -interface PositionError { - code: number; - message: string; - toString(): string; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} -declare var PositionError: { - prototype: PositionError; - new (): PositionError; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} - -interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves a list of header cells that provide information for the object. - */ - headers: string; - /** - * Retrieves the position of the object in the cells collection of a row. - */ - cellIndex: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the number columns in the table that the object should span. - */ - colSpan: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. - */ - axis: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; - /** - * Sets or retrieves abbreviated text for the object. - */ - abbr: string; - /** - * Sets or retrieves how many rows in a table the cell should span. - */ - rowSpan: number; - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; -} -declare var HTMLTableCellElement: { - prototype: HTMLTableCellElement; - new (): HTMLTableCellElement; -} - -interface SVGElementInstance extends EventTarget { - previousSibling: SVGElementInstance; - parentNode: SVGElementInstance; - lastChild: SVGElementInstance; - nextSibling: SVGElementInstance; - childNodes: SVGElementInstanceList; - correspondingUseElement: SVGUseElement; - correspondingElement: SVGElement; - firstChild: SVGElementInstance; -} -declare var SVGElementInstance: { - prototype: SVGElementInstance; - new (): SVGElementInstance; -} - -interface MSNamespaceInfoCollection { - length: number; - add(namespace?: string, urn?: string, implementationUrl?: any): Object; - item(index: any): Object; - [index: string]: Object; -} -declare var MSNamespaceInfoCollection: { - prototype: MSNamespaceInfoCollection; - new (): MSNamespaceInfoCollection; -} - -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGCircleElement: { - prototype: SVGCircleElement; - new (): SVGCircleElement; -} - -interface StyleSheetList { - length: number; - item(index?: number): StyleSheet; - [index: number]: StyleSheet; -} -declare var StyleSheetList: { - prototype: StyleSheetList; - new (): StyleSheetList; -} - -interface CSSImportRule extends CSSRule { - styleSheet: CSSStyleSheet; - href: string; - media: MediaList; -} -declare var CSSImportRule: { - prototype: CSSImportRule; - new (): CSSImportRule; -} - -interface CustomEvent extends Event { - detail: Object; - initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: Object): void; -} -declare var CustomEvent: { - prototype: CustomEvent; - new (): CustomEvent; -} - -interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; - /** - * Sets or retrieves the font size of the object. - */ - size: number; -} -declare var HTMLBaseFontElement: { - prototype: HTMLBaseFontElement; - new (): HTMLBaseFontElement; -} - -interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves or sets the text in the entry field of the textArea element. - */ - value: string; - /** - * Sets or retrieves the value indicating whether the control is selected. - */ - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: number; - /** - * Sets or retrieves the width of the object. - */ - cols: number; - /** - * Sets or retrieves the value indicated whether the content of the object is read-only. - */ - readOnly: boolean; - /** - * Sets or retrieves how to handle wordwrapping in the object. - */ - wrap: string; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Retrieves the type of control. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Highlights the input area of a form element. - */ - select(): void; -} -declare var HTMLTextAreaElement: { - prototype: HTMLTextAreaElement; - new (): HTMLTextAreaElement; -} - -interface Geolocation { - clearWatch(watchId: number): void; - getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; - watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; -} -declare var Geolocation: { - prototype: Geolocation; - new (): Geolocation; -} - -interface DOML2DeprecatedMarginStyle { - vspace: number; - hspace: number; -} - -interface MSWindowModeless { - dialogTop: any; - dialogLeft: any; - dialogWidth: any; - dialogHeight: any; - menuArguments: any; -} - -interface DOML2DeprecatedAlignmentStyle { - align: string; -} - -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; - scrollDelay: number; - behavior: string; - height: string; - loop: number; - 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; - new (): HTMLMarqueeElement; -} - -interface SVGRect { - y: number; - width: number; - x: number; - height: number; -} -declare var SVGRect: { - prototype: SVGRect; - new (): SVGRect; -} - -interface MSNodeExtensions { - swapNode(otherNode: Node): Node; - removeNode(deep?: boolean): Node; - replaceNode(replacement: Node): Node; -} - -interface History { - length: number; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; -} -declare var History: { - prototype: History; - new (): History; -} - -interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicAbs: { - prototype: SVGPathSegCurvetoCubicAbs; - new (): SVGPathSegCurvetoCubicAbs; -} - -interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticAbs: { - prototype: SVGPathSegCurvetoQuadraticAbs; - new (): SVGPathSegCurvetoQuadraticAbs; -} - -interface TimeRanges { - length: number; - start(index: number): number; - end(index: number): number; -} -declare var TimeRanges: { - prototype: TimeRanges; - new (): TimeRanges; -} - -interface CSSRule { - cssText: string; - parentStyleSheet: CSSStyleSheet; - parentRule: CSSRule; - type: number; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} -declare var CSSRule: { - prototype: CSSRule; - new (): CSSRule; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} - -interface SVGPathSegLinetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoAbs: { - prototype: SVGPathSegLinetoAbs; - new (): SVGPathSegLinetoAbs; -} - -interface HTMLModElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLModElement: { - prototype: HTMLModElement; - new (): HTMLModElement; -} - -interface SVGMatrix { - e: number; - c: number; - a: number; - b: number; - d: number; - f: number; - multiply(secondMatrix: SVGMatrix): SVGMatrix; - flipY(): SVGMatrix; - skewY(angle: number): SVGMatrix; - inverse(): SVGMatrix; - scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; - rotate(angle: number): SVGMatrix; - flipX(): SVGMatrix; - translate(x: number, y: number): SVGMatrix; - scale(scaleFactor: number): SVGMatrix; - rotateFromVector(x: number, y: number): SVGMatrix; - skewX(angle: number): SVGMatrix; -} -declare var SVGMatrix: { - prototype: SVGMatrix; - new (): SVGMatrix; -} - -interface MSPopupWindow { - document: Document; - isOpen: boolean; - show(x: number, y: number, w: number, h: number, element?: any): void; - hide(): void; -} -declare var MSPopupWindow: { - prototype: MSPopupWindow; - new (): MSPopupWindow; -} - -interface BeforeUnloadEvent extends Event { - returnValue: string; -} -declare var BeforeUnloadEvent: { - prototype: BeforeUnloadEvent; - new (): BeforeUnloadEvent; -} - -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - animatedInstanceRoot: SVGElementInstance; - instanceRoot: SVGElementInstance; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGUseElement: { - prototype: SVGUseElement; - new (): SVGUseElement; -} - -interface Event { - timeStamp: number; - defaultPrevented: boolean; - isTrusted: boolean; - currentTarget: EventTarget; - cancelBubble: boolean; - target: EventTarget; - eventPhase: number; - cancelable: boolean; - type: string; - srcElement: Element; - bubbles: boolean; - initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; - stopPropagation(): void; - stopImmediatePropagation(): void; - preventDefault(): void; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} -declare var Event: { - prototype: Event; - new (): Event; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} - -interface ImageData { - width: number; - data: Uint8Array; - height: number; -} -declare var ImageData: { - prototype: ImageData; - new (): ImageData; -} - -interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves the alignment of the object relative to the display or table. - */ - align: string; - /** - * Sets or retrieves the number of columns in the group. - */ - span: number; -} -declare var HTMLTableColElement: { - prototype: HTMLTableColElement; - new (): HTMLTableColElement; -} - -interface SVGException { - code: number; - message: string; - toString(): string; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} -declare var SVGException: { - prototype: SVGException; - new (): SVGException; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} - -interface SVGLinearGradientElement extends SVGGradientElement { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLinearGradientElement: { - prototype: SVGLinearGradientElement; - new (): SVGLinearGradientElement; -} - -interface HTMLTableAlignment { - /** - * Sets or retrieves a value that you can use to implement your own ch functionality for the object. - */ - ch: string; - /** - * Sets or retrieves how text and other content are vertically aligned within the object that contains them. - */ - vAlign: string; - /** - * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. - */ - chOff: string; -} - -interface SVGAnimatedEnumeration { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedEnumeration: { - prototype: SVGAnimatedEnumeration; - new (): SVGAnimatedEnumeration; -} - -interface DOML2DeprecatedSizeProperty { - size: number; -} - -interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLUListElement: { - prototype: HTMLUListElement; - new (): HTMLUListElement; -} - -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - ry: SVGAnimatedLength; - rx: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGRectElement: { - prototype: SVGRectElement; - new (): SVGRectElement; -} - -interface ErrorEventHandler { - (event: Event, source: string, fileno: number, columnNumber: number): void; - (message: any, uri: string, lineNumber: number, columnNumber?: number): boolean; -} - -interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDivElement: { - prototype: HTMLDivElement; - new (): HTMLDivElement; -} - -interface DOML2DeprecatedBorderStyle { - border: string; -} - -interface NamedNodeMap { - length: number; - removeNamedItemNS(namespaceURI: string, localName: string): Attr; - item(index: number): Attr; - [index: number]: Attr; - removeNamedItem(name: string): Attr; - getNamedItem(name: string): Attr; - setNamedItem(arg: Attr): Attr; - getNamedItemNS(namespaceURI: string, localName: string): Attr; - setNamedItemNS(arg: Attr): Attr; -} -declare var NamedNodeMap: { - prototype: NamedNodeMap; - new (): NamedNodeMap; -} - -interface MediaList { - length: number; - mediaText: string; - deleteMedium(oldMedium: string): void; - appendMedium(newMedium: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var MediaList: { - prototype: MediaList; - new (): MediaList; -} - -interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothAbs: { - prototype: SVGPathSegCurvetoQuadraticSmoothAbs; - new (): SVGPathSegCurvetoQuadraticSmoothAbs; -} - -interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothRel: { - prototype: SVGPathSegCurvetoCubicSmoothRel; - new (): SVGPathSegCurvetoCubicSmoothRel; -} - -interface SVGLengthList { - numberOfItems: number; - replaceItem(newItem: SVGLength, index: number): SVGLength; - getItem(index: number): SVGLength; - clear(): void; - appendItem(newItem: SVGLength): SVGLength; - initialize(newItem: SVGLength): SVGLength; - removeItem(index: number): SVGLength; - insertItemBefore(newItem: SVGLength, index: number): SVGLength; -} -declare var SVGLengthList: { - prototype: SVGLengthList; - new (): SVGLengthList; -} - -interface ProcessingInstruction extends Node { - target: string; - data: string; -} -declare var ProcessingInstruction: { - prototype: ProcessingInstruction; - new (): 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; - item(index: any): any; - resizeTo(x?: number, y?: number): void; - createPopup(arguments?: any): MSPopupWindow; - toStaticHTML(html: string): string; - execScript(code: string, language?: string): any; - msWriteProfilerMark(profilerMarkName: string): void; - 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 { - length: number; - item(index: number): string; -} -declare var MSBehaviorUrnsCollection: { - prototype: MSBehaviorUrnsCollection; - new (): MSBehaviorUrnsCollection; -} - -interface CSSFontFaceRule extends CSSRule { - style: CSSStyleDeclaration; -} -declare var CSSFontFaceRule: { - prototype: CSSFontFaceRule; - new (): CSSFontFaceRule; -} - -interface DOML2DeprecatedBackgroundStyle { - background: string; -} - -interface TextEvent extends UIEvent { - inputMethod: number; - data: string; - locale: string; - initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} -declare var TextEvent: { - prototype: TextEvent; - new (): TextEvent; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} - -interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { -} -declare var DocumentFragment: { - prototype: DocumentFragment; - new (): DocumentFragment; -} - -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolylineElement: { - prototype: SVGPolylineElement; - new (): SVGPolylineElement; -} - -interface SVGAnimatedPathData { - pathSegList: SVGPathSegList; -} - -interface Position { - timestamp: number; - coords: Coordinates; -} -declare var Position: { - prototype: Position; - new (): Position; -} - -interface BookmarkCollection { - length: number; - item(index: number): any; - [index: number]: any; -} -declare var BookmarkCollection: { - prototype: BookmarkCollection; - new (): BookmarkCollection; -} - -interface PerformanceMark extends PerformanceEntry { -} -declare var PerformanceMark: { - prototype: PerformanceMark; - new (): PerformanceMark; -} - -interface CSSPageRule extends CSSRule { - pseudoClass: string; - selectorText: string; - selector: string; - style: CSSStyleDeclaration; -} -declare var CSSPageRule: { - prototype: CSSPageRule; - new (): CSSPageRule; -} - -interface HTMLBRElement extends HTMLElement { - /** - * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. - */ - clear: string; -} -declare var HTMLBRElement: { - prototype: HTMLBRElement; - new (): HTMLBRElement; -} - -interface MSNavigatorExtensions { - userLanguage: string; - plugins: MSPluginsCollection; - cookieEnabled: boolean; - appCodeName: string; - cpuClass: string; - appMinorVersion: string; - connectionSpeed: number; - browserLanguage: string; - mimeTypes: MSMimeTypesCollection; - systemLanguage: string; - javaEnabled(): boolean; - taintEnabled(): boolean; -} - -interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { -} -declare var HTMLSpanElement: { - prototype: HTMLSpanElement; - new (): HTMLSpanElement; -} - -interface HTMLHeadElement extends HTMLElement { - profile: string; -} -declare var HTMLHeadElement: { - prototype: HTMLHeadElement; - new (): HTMLHeadElement; -} - -interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; -} -declare var HTMLHeadingElement: { - prototype: HTMLHeadingElement; - new (): HTMLHeadingElement; -} - -interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. - */ - acceptCharset: string; - /** - * Sets or retrieves the encoding type for the form. - */ - enctype: string; - /** - * Retrieves a collection, in source order, of all controls in a given form. - */ - elements: HTMLCollection; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves how to send the form data to the server. - */ - method: string; - /** - * Sets or retrieves the MIME encoding for the form. - */ - encoding: string; - /** - * Fires when the user resets a form. - */ - reset(): void; - /** - * Retrieves a form object or an object from an elements collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Fires when a FORM is about to be submitted. - */ - submit(): void; - /** - * Retrieves a form object or an object from an elements collection. - */ - namedItem(name: string): any; - [name: string]: any; -} -declare var HTMLFormElement: { - prototype: HTMLFormElement; - new (): HTMLFormElement; -} - -interface SVGZoomAndPan { - zoomAndPan: number; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} -declare var SVGZoomAndPan: { - prototype: SVGZoomAndPan; - new (): SVGZoomAndPan; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} - -interface HTMLMediaElement extends HTMLElement { - /** - * Gets the earliest possible position, in seconds, that the playback can begin. - */ - initialTime: number; - /** - * Gets TimeRanges for the current media resource that has been played. - */ - played: TimeRanges; - /** - * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. - */ - currentSrc: string; - readyState: any; - /** - * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. - */ - autobuffer: boolean; - /** - * Gets or sets a flag to specify whether playback should restart after it completes. - */ - loop: boolean; - /** - * Gets information about whether the playback has ended or not. - */ - ended: boolean; - /** - * Gets a collection of buffered time ranges. - */ - buffered: TimeRanges; - /** - * Returns an object representing the current error state of the audio or video element. - */ - error: MediaError; - /** - * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. - */ - seekable: TimeRanges; - /** - * Gets or sets a value that indicates whether to start playing the media automatically. - */ - autoplay: boolean; - /** - * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). - */ - controls: boolean; - /** - * Gets or sets the volume level for audio portions of the media element. - */ - volume: number; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. - */ - playbackRate: number; - /** - * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. - */ - duration: number; - /** - * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. - */ - muted: boolean; - /** - * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. - */ - defaultPlaybackRate: number; - /** - * Gets a flag that specifies whether playback is paused. - */ - paused: boolean; - /** - * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. - */ - seeking: boolean; - /** - * Gets or sets the current playback position, in seconds. - */ - currentTime: number; - /** - * Gets or sets the current playback position, in seconds. - */ - preload: string; - /** - * Gets the current network activity for the element. - */ - networkState: number; - /** - * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. - */ - pause(): void; - /** - * Loads and starts playback of a media resource. - */ - play(): void; - /** - * Fires immediately after the client loads the object. - */ - load(): void; - /** - * Returns a string that specifies whether the client can play a given media resource type. - */ - canPlayType(type: string): string; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} -declare var HTMLMediaElement: { - prototype: HTMLMediaElement; - new (): HTMLMediaElement; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} - -interface ElementCSSInlineStyle { - runtimeStyle: MSStyleCSSProperties; - currentStyle: MSCurrentStyleCSSProperties; - doScroll(component?: any): void; - componentFromPoint(x: number, y: number): string; -} - -interface DOMParser { - parseFromString(source: string, mimeType: string): Document; -} -declare var DOMParser: { - prototype: DOMParser; - new (): DOMParser; -} - -interface MSMimeTypesCollection { - length: number; -} -declare var MSMimeTypesCollection: { - prototype: MSMimeTypesCollection; - new (): MSMimeTypesCollection; -} - -interface StyleSheet { - disabled: boolean; - ownerNode: Node; - parentStyleSheet: StyleSheet; - href: string; - media: MediaList; - type: string; - title: string; -} -declare var StyleSheet: { - prototype: StyleSheet; - new (): StyleSheet; -} - -interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { - startOffset: SVGAnimatedLength; - method: SVGAnimatedEnumeration; - spacing: SVGAnimatedEnumeration; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} -declare var SVGTextPathElement: { - prototype: SVGTextPathElement; - new (): SVGTextPathElement; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} - -interface HTMLDTElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDTElement: { - prototype: HTMLDTElement; - new (): HTMLDTElement; -} - -interface NodeList { - length: number; - item(index: number): Node; - [index: number]: Node; -} -declare var NodeList: { - prototype: NodeList; - new (): NodeList; -} - -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - -interface XMLSerializer { - serializeToString(target: Node): string; -} -declare var XMLSerializer: { - prototype: XMLSerializer; - new (): XMLSerializer; -} - -interface PerformanceMeasure extends PerformanceEntry { -} -declare var PerformanceMeasure: { - prototype: PerformanceMeasure; - new (): PerformanceMeasure; -} - -interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { - spreadMethod: SVGAnimatedEnumeration; - gradientTransform: SVGAnimatedTransformList; - gradientUnits: SVGAnimatedEnumeration; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} -declare var SVGGradientElement: { - prototype: SVGGradientElement; - new (): SVGGradientElement; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} - -interface NodeFilter { - acceptNode(n: Node): number; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} -declare var NodeFilter: { - prototype: NodeFilter; - new (): NodeFilter; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} - -interface SVGNumberList { - numberOfItems: number; - replaceItem(newItem: SVGNumber, index: number): SVGNumber; - getItem(index: number): SVGNumber; - clear(): void; - appendItem(newItem: SVGNumber): SVGNumber; - initialize(newItem: SVGNumber): SVGNumber; - removeItem(index: number): SVGNumber; - insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; -} -declare var SVGNumberList: { - prototype: SVGNumberList; - new (): SVGNumberList; -} - -interface MediaError { - code: number; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} -declare var MediaError: { - prototype: MediaError; - new (): MediaError; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} - -interface HTMLFieldSetElement extends HTMLElement { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLFieldSetElement: { - prototype: HTMLFieldSetElement; - new (): HTMLFieldSetElement; -} - -interface HTMLBGSoundElement extends HTMLElement { - /** - * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. - */ - balance: any; - /** - * Sets or gets the volume setting for the sound. - */ - volume: any; - /** - * Sets or gets the URL of a sound to play. - */ - src: string; - /** - * Sets or retrieves the number of times a sound or video clip will loop when activated. - */ - loop: number; -} -declare var HTMLBGSoundElement: { - prototype: HTMLBGSoundElement; - new (): 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; - setCapture(containerCapture?: boolean): void; - focus(): void; - getAdjacentText(where: string): string; - insertAdjacentText(where: string, text: string): void; - getElementsByClassName(classNames: string): NodeList; - setActive(): void; - removeFilter(filter: Object): void; - blur(): void; - clearAttributes(): void; - releaseCapture(): void; - createControlRange(): ControlRangeCollection; - removeBehavior(cookie: number): boolean; - contains(child: HTMLElement): boolean; - click(): void; - insertAdjacentElement(position: string, insertedElement: Element): Element; - mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; - replaceAdjacentText(where: string, newText: string): string; - 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; - new (): HTMLElement; -} - -interface Comment extends CharacterData { - text: string; -} -declare var Comment: { - prototype: Comment; - new (): Comment; -} - -interface PerformanceResourceTiming extends PerformanceEntry { - redirectStart: number; - redirectEnd: number; - domainLookupEnd: number; - responseStart: number; - domainLookupStart: number; - fetchStart: number; - requestStart: number; - connectEnd: number; - connectStart: number; - initiatorType: string; - responseEnd: number; -} -declare var PerformanceResourceTiming: { - prototype: PerformanceResourceTiming; - new (): PerformanceResourceTiming; -} - -interface CanvasPattern { -} -declare var CanvasPattern: { - prototype: CanvasPattern; - new (): CanvasPattern; -} - -interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. - */ - noShade: boolean; -} -declare var HTMLHRElement: { - prototype: HTMLHRElement; - new (): HTMLHRElement; -} - -interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - /** - * Retrieves the contained object. - */ - object: Object; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL of the file containing the compiled Java class. - */ - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - declare: boolean; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; -} -declare var HTMLObjectElement: { - prototype: HTMLObjectElement; - new (): HTMLObjectElement; -} - -interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Retrieves the palette used for the embedded document. - */ - palette: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Retrieves the URL of the plug-in used to view an embedded document. - */ - pluginspage: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the height and width units of the embed object. - */ - units: string; -} -declare var HTMLEmbedElement: { - prototype: HTMLEmbedElement; - new (): HTMLEmbedElement; -} - -interface StorageEvent extends Event { - oldValue: any; - newValue: any; - url: string; - storageArea: Storage; - key: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; -} -declare var StorageEvent: { - prototype: StorageEvent; - new (): StorageEvent; -} - -interface CharacterData extends Node { - length: number; - data: string; - deleteData(offset: number, count: number): void; - replaceData(offset: number, count: number, arg: string): void; - appendData(arg: string): void; - insertData(offset: number, arg: string): void; - substringData(offset: number, count: number): string; -} -declare var CharacterData: { - prototype: CharacterData; - new (): CharacterData; -} - -interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; -} -declare var HTMLOptGroupElement: { - prototype: HTMLOptGroupElement; - new (): HTMLOptGroupElement; -} - -interface HTMLIsIndexElement extends HTMLElement { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - prompt: string; -} -declare var HTMLIsIndexElement: { - prototype: HTMLIsIndexElement; - new (): HTMLIsIndexElement; -} - -interface SVGPathSegLinetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoRel: { - prototype: SVGPathSegLinetoRel; - new (): SVGPathSegLinetoRel; -} - -interface DOMException { - code: number; - message: string; - toString(): string; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} -declare var DOMException: { - prototype: DOMException; - new (): DOMException; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} - -interface SVGAnimatedBoolean { - animVal: boolean; - baseVal: boolean; -} -declare var SVGAnimatedBoolean: { - prototype: SVGAnimatedBoolean; - new (): SVGAnimatedBoolean; -} - -interface MSCompatibleInfoCollection { - length: number; - item(index: number): MSCompatibleInfo; -} -declare var MSCompatibleInfoCollection: { - prototype: MSCompatibleInfoCollection; - new (): MSCompatibleInfoCollection; -} - -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGSwitchElement: { - prototype: SVGSwitchElement; - new (): SVGSwitchElement; -} - -interface SVGPreserveAspectRatio { - align: number; - meetOrSlice: number; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} -declare var SVGPreserveAspectRatio: { - prototype: SVGPreserveAspectRatio; - new (): SVGPreserveAspectRatio; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} - -interface Attr extends Node { - expando: boolean; - specified: boolean; - ownerElement: Element; - value: string; - name: string; -} -declare var Attr: { - prototype: Attr; - new (): Attr; -} - -interface PerformanceNavigation { - redirectCount: number; - type: number; - toJSON(): any; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} -declare var PerformanceNavigation: { - prototype: PerformanceNavigation; - new (): PerformanceNavigation; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} - -interface SVGStopElement extends SVGElement, SVGStylable { - offset: SVGAnimatedNumber; -} -declare var SVGStopElement: { - prototype: SVGStopElement; - new (): SVGStopElement; -} - -interface PositionCallback { - (position: Position): void; -} - -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { -} -declare var SVGSymbolElement: { - prototype: SVGSymbolElement; - new (): SVGSymbolElement; -} - -interface SVGElementInstanceList { - length: number; - item(index: number): SVGElementInstance; -} -declare var SVGElementInstanceList: { - prototype: SVGElementInstanceList; - new (): SVGElementInstanceList; -} - -interface CSSRuleList { - length: number; - item(index: number): CSSRule; - [index: number]: CSSRule; -} -declare var CSSRuleList: { - prototype: CSSRuleList; - new (): CSSRuleList; -} - -interface MSDataBindingRecordSetExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface LinkStyle { - styleSheet: StyleSheet; - sheet: StyleSheet; -} - -interface HTMLVideoElement extends HTMLMediaElement { - /** - * Gets or sets the width of the video element. - */ - width: number; - /** - * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoWidth: number; - /** - * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoHeight: number; - /** - * Gets or sets the height of the video element. - */ - height: number; - /** - * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. - */ - poster: string; -} -declare var HTMLVideoElement: { - prototype: HTMLVideoElement; - new (): HTMLVideoElement; -} - -interface ClientRectList { - length: number; - item(index: number): ClientRect; - [index: number]: ClientRect; -} -declare var ClientRectList: { - prototype: ClientRectList; - new (): ClientRectList; -} - -interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - maskUnits: SVGAnimatedEnumeration; - maskContentUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGMaskElement: { - prototype: SVGMaskElement; - new (): SVGMaskElement; -} - -interface External { -} -declare var External: { - prototype: External; - new (): External; -} - -declare var Audio: { new (src?: string): HTMLAudioElement; }; -declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; -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; -declare function focus(): void; -declare function scrollTo(x?: number, y?: number): void; -declare function print(): void; -declare function prompt(message?: string, defaul?: string): string; -declare function toString(): string; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; -declare function scrollBy(x?: number, y?: number): void; -declare function confirm(message?: string): boolean; -declare function close(): void; -declare function postMessage(message: any, targetOrigin: string, ports?: any): void; -declare function showModalDialog(url?: string, argument?: any, options?: any): any; -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; -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; -declare function item(index: any): any; -declare function resizeTo(x?: number, y?: number): void; -declare function createPopup(arguments?: any): MSPopupWindow; -declare function toStaticHTML(html: string): string; -declare function execScript(code: string, language?: string): any; -declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function moveTo(x?: number, y?: number): void; -declare function moveBy(x?: number, y?: number): void; -declare function showHelp(url: string, helpArg?: any, features?: string): void; -declare var sessionStorage: Storage; -declare function clearTimeout(handle: number): void; -declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; -declare function clearInterval(handle: number): void; -declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; - - -///////////////////////////// -/// IE10 DOM APIs -///////////////////////////// - - - -interface ObjectURLOptions { - oneTimeOnly?: boolean; -} - -interface HTMLBodyElement { - onpopstate: (ev: PopStateEvent) => any; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; -} - -interface MSGestureEvent extends UIEvent { - offsetY: number; - translationY: number; - velocityExpansion: number; - velocityY: number; - velocityAngular: number; - translationX: number; - velocityX: number; - hwTimestamp: number; - offsetX: number; - screenX: number; - rotation: number; - expansion: number; - clientY: number; - screenY: number; - scale: number; - gestureObject: any; - clientX: number; - initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} -declare var MSGestureEvent: { - prototype: MSGestureEvent; - new (): MSGestureEvent; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} - -interface HTMLAnchorElement { - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; -} - -interface HTMLInputElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a FileList object on a file type input object. - */ - files: FileList; - /** - * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. - */ - max: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. - */ - step: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Returns the input field value as a number. - */ - valueAsNumber: number; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Specifies the ID of a pre-defined datalist of options for an input element. - */ - list: HTMLElement; - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. - */ - min: string; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Gets or sets a string containing a regular expression that the user's input must match. - */ - pattern: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. - * @param n Value to decrement the value by. - */ - stepDown(n?: number): void; - /** - * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. - * @param n Value to increment the value by. - */ - stepUp(n?: number): void; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface ErrorEvent extends Event { - colno: number; - filename: string; - 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; - width: SVGAnimatedLength; - filterResX: SVGAnimatedInteger; - filterUnits: SVGAnimatedEnumeration; - primitiveUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - 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; - addPointer(pointerId: number): void; - stop(): void; -} -declare var MSGesture: { - prototype: MSGesture; - new (): 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; - pauseOnExit: boolean; - 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; - new (): TextTrackCue; -} - -interface MSStreamReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; -} -declare var MSStreamReader: { - prototype: MSStreamReader; - new (): MSStreamReader; -} - -interface DOMTokenList { - length: number; - contains(token: string): boolean; - remove(token: string): void; - toggle(token: string): boolean; - add(token: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var DOMTokenList: { - prototype: DOMTokenList; - new (): DOMTokenList; -} - -interface EventException { - name: string; -} - -interface Performance { - now(): number; -} - -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; - mode: SVGAnimatedEnumeration; - in1: SVGAnimatedString; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - 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; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} - -interface WindowTimers extends WindowTimersExtension { -} -declare var WindowTimers: { - prototype: WindowTimers; - new (): WindowTimers; -} - -interface CSSStyleDeclaration { - animationFillMode: string; - floodColor: string; - animationIterationCount: string; - textShadow: string; - backfaceVisibility: string; - msAnimationIterationCount: string; - animationDelay: string; - animationTimingFunction: string; - columnWidth: any; - msScrollSnapX: string; - columnRuleColor: any; - columnRuleWidth: any; - transitionDelay: string; - transition: string; - msFlowFrom: string; - msScrollSnapType: string; - msContentZoomSnapType: string; - msGridColumns: string; - msAnimationName: string; - msGridRowAlign: string; - msContentZoomChaining: string; - msGridColumn: any; - msHyphenateLimitZone: any; - msScrollRails: string; - msAnimationDelay: string; - enableBackground: string; - msWrapThrough: string; - columnRuleStyle: string; - msAnimation: string; - msFlexFlow: string; - msScrollSnapY: string; - msHyphenateLimitLines: any; - msTouchAction: string; - msScrollLimit: string; - animation: string; - transform: string; - filter: string; - colorInterpolationFilters: string; - transitionTimingFunction: string; - msBackfaceVisibility: string; - animationPlayState: string; - transformOrigin: string; - msScrollLimitYMin: any; - msFontFeatureSettings: string; - msContentZoomLimitMin: any; - columnGap: any; - transitionProperty: string; - msAnimationDuration: string; - msAnimationFillMode: string; - msFlexDirection: string; - msTransitionDuration: string; - fontFeatureSettings: string; - breakBefore: string; - msFlexWrap: string; - perspective: string; - msFlowInto: string; - msTransformStyle: string; - msScrollTranslation: string; - msTransitionProperty: string; - msUserSelect: string; - msOverflowStyle: string; - msScrollSnapPointsY: string; - animationDirection: string; - animationDuration: string; - msFlex: string; - msTransitionTimingFunction: string; - animationName: string; - columnRule: string; - msGridColumnSpan: any; - msFlexNegative: string; - columnFill: string; - msGridRow: any; - msFlexOrder: string; - msFlexItemAlign: string; - msFlexPositive: string; - msContentZoomLimitMax: any; - msScrollLimitYMax: any; - msGridColumnAlign: string; - perspectiveOrigin: string; - lightingColor: string; - columns: string; - msScrollChaining: string; - msHyphenateLimitChars: string; - msTouchSelect: string; - floodOpacity: string; - msAnimationDirection: string; - msAnimationPlayState: string; - columnSpan: string; - msContentZooming: string; - msPerspective: string; - msFlexPack: string; - msScrollSnapPointsX: string; - msContentZoomSnapPoints: string; - msGridRowSpan: any; - msContentZoomSnap: string; - msScrollLimitXMin: any; - breakInside: string; - msHighContrastAdjust: string; - msFlexLinePack: string; - msGridRows: string; - transitionDuration: string; - msHyphens: string; - breakAfter: string; - msTransition: string; - msPerspectiveOrigin: string; - msContentZoomLimit: string; - msScrollLimitXMax: any; - msFlexAlign: string; - msWrapMargin: any; - columnCount: any; - msAnimationTimingFunction: string; - msTransitionDelay: string; - transformStyle: string; - msWrapFlow: string; - msFlexPreferredSize: string; -} - -interface MessageChannel { - port2: MessagePort; - port1: MessagePort; -} -declare var MessageChannel: { - prototype: MessageChannel; - new (): MessageChannel; -} - -interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} -declare var SVGFEMergeElement: { - prototype: SVGFEMergeElement; - new (): SVGFEMergeElement; -} - -interface Navigator extends MSFileSaver { - msMaxTouchPoints: number; - msPointerEnabled: boolean; - msManipulationViewsEnabled: boolean; - msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; -} - -interface TransitionEvent extends Event { - propertyName: string; - 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; - media: string; - 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; - reason: string; - 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; - CLOSED: number; -} -declare var WebSocket: { - prototype: WebSocket; - new (url: string): WebSocket; - new (url: string, prototcol: string): WebSocket; - new (url: string, prototcol: string[]): WebSocket; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; -} - -interface SVGFEPointLightElement extends SVGElement { - y: SVGAnimatedNumber; - x: SVGAnimatedNumber; - z: SVGAnimatedNumber; -} -declare var SVGFEPointLightElement: { - prototype: SVGFEPointLightElement; - new (): SVGFEPointLightElement; -} - -interface ProgressEvent extends Event { - loaded: number; - lengthComputable: boolean; - 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; - name: string; - transaction: IDBTransaction; - keyPath: string; - count(key?: any): IDBRequest; - add(value: any, key?: any): IDBRequest; - clear(): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; - put(value: any, key?: any): IDBRequest; - openCursor(range?: any, direction?: string): IDBRequest; - deleteIndex(indexName: string): void; - index(name: string): IDBIndex; - get(key: any): IDBRequest; - delete(key: any): IDBRequest; -} -declare var IDBObjectStore: { - prototype: IDBObjectStore; - new (): IDBObjectStore; -} - -interface HTMLCanvasElement { - /** - * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. - */ - msToBlob(): Blob; -} - -interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - stdDeviationX: SVGAnimatedNumber; - in1: SVGAnimatedString; - stdDeviationY: SVGAnimatedNumber; - setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; -} -declare var SVGFEGaussianBlurElement: { - prototype: SVGFEGaussianBlurElement; - new (): SVGFEGaussianBlurElement; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - result: SVGAnimatedString; -} - -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; - name: string; - keyPath: string; - objectStore: IDBObjectStore; - count(key?: any): IDBRequest; - getKey(key: any): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - get(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; -} -declare var IDBIndex: { - prototype: IDBIndex; - new (): IDBIndex; -} - -interface WheelEvent { - getCurrentPoint(element: Element): void; -} - -interface FileList { - length: number; - item(index: number): File; - [index: number]: File; -} -declare var FileList: { - prototype: FileList; - new (): FileList; -} - -interface IDBCursor { - source: any; - direction: string; - key: any; - primaryKey: any; - advance(count: number): void; - 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 { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - in1: SVGAnimatedString; - 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; - createObjectURL(object: any, options?: ObjectURLOptions): string; -} -declare var URL: URL; - -interface RangeException { - name: string; -} - -interface IDBCursorWithValue extends IDBCursor { - value: any; -} -declare var IDBCursorWithValue: { - prototype: IDBCursorWithValue; - new (): IDBCursorWithValue; -} - -interface HTMLTextAreaElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -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 { - msIndexedDB: IDBFactory; - indexedDB: IDBFactory; -} - -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; -} - -interface History { - state: any; - replaceState(statedata: any, title: string, url?: string): void; - pushState(statedata: any, title: string, url?: string): void; -} - -interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - radiusX: SVGAnimatedNumber; - radiusY: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - 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; -} - -interface HTMLSelectElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface CSSRule { - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - VIEWPORT_RULE: number; -} -//declare var CSSRule: { -// prototype: CSSRule; -// KEYFRAMES_RULE: number; -// KEYFRAME_RULE: number; -// VIEWPORT_RULE: number; -//} - -interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncRElement: { - prototype: SVGFEFuncRElement; - new (): SVGFEFuncRElement; -} - -interface WindowTimersExtension { - msSetImmediate(expression: any, ...args: any[]): number; - clearImmediate(handle: number): void; - msClearImmediate(handle: number): void; - setImmediate(expression: any, ...args: any[]): number; -} - -interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - xChannelSelector: SVGAnimatedEnumeration; - yChannelSelector: SVGAnimatedEnumeration; - scale: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} -declare var SVGFEDisplacementMapElement: { - prototype: SVGFEDisplacementMapElement; - new (): SVGFEDisplacementMapElement; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} - -interface AnimationEvent extends Event { - animationName: string; - 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; - slope: SVGAnimatedNumber; - type: SVGAnimatedEnumeration; - exponent: SVGAnimatedNumber; - amplitude: SVGAnimatedNumber; - intercept: SVGAnimatedNumber; - offset: SVGAnimatedNumber; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - 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; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} - -interface MSRangeCollection { - length: number; - 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; -} - -interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncBElement: { - prototype: SVGFEFuncBElement; - new (): SVGFEFuncBElement; -} - -interface IDBKeyRange { - upper: any; - upperOpen: boolean; - lower: any; - lowerOpen: boolean; - bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - only(value: any): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; -} -declare var IDBKeyRange: { - prototype: IDBKeyRange; - new (): IDBKeyRange; -} - -interface WindowConsole { - console: Console; -} - -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 { - kind: string; - language: string; - id: string; - label: string; - enabled: boolean; -} -declare var AudioTrack: { - prototype: AudioTrack; - new (): AudioTrack; -} - -interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - orderY: SVGAnimatedInteger; - kernelUnitLengthY: SVGAnimatedNumber; - orderX: SVGAnimatedInteger; - preserveAlpha: SVGAnimatedBoolean; - kernelMatrix: SVGAnimatedNumberList; - edgeMode: SVGAnimatedEnumeration; - kernelUnitLengthX: SVGAnimatedNumber; - bias: SVGAnimatedNumber; - targetX: SVGAnimatedInteger; - targetY: SVGAnimatedInteger; - divisor: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} -declare var SVGFEConvolveMatrixElement: { - prototype: SVGFEConvolveMatrixElement; - new (): SVGFEConvolveMatrixElement; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} - -interface TextTrackCueList { - length: number; - item(index: number): TextTrackCue; - [index: number]: TextTrackCue; - getCueById(id: string): TextTrackCue; -} -declare var TextTrackCueList: { - prototype: TextTrackCueList; - new (): TextTrackCueList; -} - -interface CSSKeyframesRule extends CSSRule { - name: string; - cssRules: CSSRuleList; - findRule(rule: string): CSSKeyframeRule; - 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; - msIsStaticHTML(html: string): boolean; - msMatchMedia(mediaQuery: string): MediaQueryList; - requestAnimationFrame(callback: FrameRequestCallback): number; - msRequestAnimationFrame(callback: FrameRequestCallback): number; -} - -interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - baseFrequencyX: SVGAnimatedNumber; - numOctaves: SVGAnimatedInteger; - type: SVGAnimatedEnumeration; - baseFrequencyY: SVGAnimatedNumber; - stitchTiles: SVGAnimatedEnumeration; - seed: SVGAnimatedNumber; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} -declare var SVGFETurbulenceElement: { - prototype: SVGFETurbulenceElement; - new (): SVGFETurbulenceElement; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} - -interface TextTrackList { - length: number; - 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; - type: SVGAnimatedEnumeration; - values: SVGAnimatedNumberList; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - 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; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} - -interface Console { - info(message?: any, ...optionalParams: any[]): void; - profile(reportName?: string): void; - assert(test?: boolean, message?: string, ...optionalParams: any[]): void; - msIsIndependentlyComposed(element: Element): boolean; - clear(): void; - dir(value?: any, ...optionalParams: any[]): void; - warn(message?: any, ...optionalParams: any[]): void; - error(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - profileEnd(): void; -} -declare var Console: { - prototype: Console; - new (): Console; -} - -interface SVGFESpotLightElement extends SVGElement { - pointsAtY: SVGAnimatedNumber; - y: SVGAnimatedNumber; - limitingConeAngle: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - x: SVGAnimatedNumber; - pointsAtZ: SVGAnimatedNumber; - z: SVGAnimatedNumber; - pointsAtX: SVGAnimatedNumber; -} -declare var SVGFESpotLightElement: { - prototype: SVGFESpotLightElement; - new (): SVGFESpotLightElement; -} - -interface HTMLImageElement { - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; -} - -interface WindowBase64 { - btoa(rawString: string): string; - atob(encodedString: string): string; -} - -interface IDBDatabase extends EventTarget { - version: string; - 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 { - length: number; - contains(str: string): boolean; - item(index: number): string; - [index: number]: string; -} -declare var DOMStringList: { - prototype: DOMStringList; - new (): DOMStringList; -} - -interface HTMLButtonElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -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 { - /** - * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. - */ - value: number; - /** - * Defines the maximum, or "done" value for a progress element. - */ - max: number; - /** - * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). - */ - position: number; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLProgressElement: { - prototype: HTMLProgressElement; - new (): HTMLProgressElement; -} - -interface MSLaunchUriCallback { - (): void; -} - -interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - dy: SVGAnimatedNumber; - in1: SVGAnimatedString; - dx: SVGAnimatedNumber; -} -declare var SVGFEOffsetElement: { - prototype: SVGFEOffsetElement; - new (): SVGFEOffsetElement; -} - -interface HTMLFormElement { - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Designates a form that is not validated when submitted. - */ - noValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; -} - -interface MSUnsafeFunctionCallback { - (): any; -} - -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; -} - -interface MessageEvent extends Event { - ports: any; -} - -interface HTMLScriptElement { - async: boolean; -} - -interface HTMLMediaElement { - /** - * Specifies the purpose of the audio or video media, such as background audio or alerts. - */ - msAudioCategory: string; - /** - * Specifies whether or not to enable low-latency playback on the media element. - */ - msRealTime: boolean; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - textTracks: TextTrackList; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Returns an AudioTrackList object with the audio tracks for a given video element. - */ - audioTracks: AudioTrackList; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; - /** - * Specifies the output device id that the audio will be sent to. - */ - msAudioDeviceType: string; - /** - * Clears all effects from the media pipeline. - */ - msClearEffects(): void; - /** - * Specifies the media protection manager for a given media pipeline. - */ - msSetMediaProtectionManager(mediaProtectionManager?: any): void; - /** - * Inserts the specified audio effect into media pipeline. - */ - msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; -} - -interface TextTrack extends EventTarget { - language: string; - mode: any; - readyState: number; - 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; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} -declare var TextTrack: { - prototype: TextTrack; - new (): TextTrack; - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} - -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} - -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; - start(): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MessagePort: { - prototype: MessagePort; - new (): MessagePort; -} - -interface FileReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; -} -declare var FileReader: { - prototype: FileReader; - new (): FileReader; -} - -interface BlobPropertyBag { - type?: string; - endings?: string; -} - -interface Blob { - type: string; - size: number; - msDetachStream(): any; - slice(start?: number, end?: number, contentType?: string): Blob; - close(): void; - msClose(): void; -} -declare var Blob: { - prototype: Blob; - new (blobParts?: any[], options?: BlobPropertyBag): 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; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} -declare var ApplicationCache: { - prototype: ApplicationCache; - new (): ApplicationCache; - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} - -interface FrameRequestCallback { - (time: number): void; -} - -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; - msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; -} - -interface MSStream { - type: string; - msDetachStream(): any; - msClose(): void; -} -declare var MSStream: { - prototype: MSStream; - new (): MSStream; -} - -interface MediaError { - msExtendedCode: number; -} - -interface HTMLFieldSetElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new (): 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; -} - -interface DataTransfer { - types: DOMStringList; - files: FileList; -} - -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; -} - -interface HTMLObjectElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface MSPointerEvent 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; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} -declare var MSPointerEvent: { - prototype: MSPointerEvent; - new (): MSPointerEvent; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} - -interface DOMException { - name: string; - INVALID_NODE_TYPE_ERR: number; - DATA_CLONE_ERR: number; - TIMEOUT_ERR: number; -} -//declare var DOMException: { -// prototype: DOMException; -// INVALID_NODE_TYPE_ERR: number; -// DATA_CLONE_ERR: number; -// TIMEOUT_ERR: number; -//} - -interface MSManipulationEvent extends UIEvent { - lastState: number; - currentState: number; - initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - 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; -} - -interface FormData { - append(name: any, value: any, blobName?: string): void; -} -declare var FormData: { - prototype: FormData; - new (form?: HTMLFormElement): 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 { - operator: SVGAnimatedEnumeration; - in2: SVGAnimatedString; - k2: SVGAnimatedNumber; - k1: SVGAnimatedNumber; - k3: SVGAnimatedNumber; - in1: SVGAnimatedString; - k4: SVGAnimatedNumber; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - 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; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} - -interface ValidityState { - customError: boolean; - valueMissing: boolean; - stepMismatch: boolean; - rangeUnderflow: boolean; - rangeOverflow: boolean; - typeMismatch: boolean; - patternMismatch: boolean; - tooLong: boolean; - valid: boolean; -} -declare var ValidityState: { - prototype: ValidityState; - new (): ValidityState; -} - -interface HTMLTrackElement extends HTMLElement { - kind: string; - src: string; - srclang: string; - track: TextTrack; - label: string; - default: boolean; -} -declare var HTMLTrackElement: { - prototype: HTMLTrackElement; - new (): HTMLTrackElement; -} - -interface MSApp { - createFileFromStorageFile(storageFile: any): File; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - terminateApp(exceptionObject: any): void; - createDataPackage(object: any): any; - execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; - getHtmlPrintDocumentSource(htmlDoc: any): any; - addPublicLocalApplicationUri(uri: string): void; - createDataPackageFromSelection(): any; -} -declare var MSApp: MSApp; - -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; - surfaceScale: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - diffuseConstant: SVGAnimatedNumber; -} -declare var SVGFEDiffuseLightingElement: { - prototype: SVGFEDiffuseLightingElement; - new (): SVGFEDiffuseLightingElement; -} - -interface MSCSSMatrix { - m24: number; - m34: number; - a: number; - d: number; - m32: number; - m41: number; - m11: number; - f: number; - e: number; - m23: number; - m14: number; - m33: number; - m22: number; - m21: number; - c: number; - m12: number; - b: number; - m42: number; - m31: number; - m43: number; - m13: number; - m44: number; - multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; - skewY(angle: number): MSCSSMatrix; - setMatrixValue(value: string): void; - inverse(): MSCSSMatrix; - rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; - toString(): string; - rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; - translate(x: number, y: number, z?: number): MSCSSMatrix; - scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; - skewX(angle: number): MSCSSMatrix; -} -declare var MSCSSMatrix: { - prototype: MSCSSMatrix; - new (text?: string): 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; - new (stringUrl: string): Worker; -} - -interface HTMLIFrameElement { - sandbox: DOMSettableTokenList; -} - -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; -declare function msIsStaticHTML(html: string): boolean; -declare function msMatchMedia(mediaQuery: string): MediaQueryList; -declare function requestAnimationFrame(callback: FrameRequestCallback): number; -declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; -declare function btoa(rawString: string): string; -declare function atob(encodedString: string): string; -declare var msIndexedDB: IDBFactory; -declare var indexedDB: IDBFactory; -declare var console: Console; - -///////////////////////////// -/// IE11 APIs -///////////////////////////// - - - -interface StoreExceptionsInformation extends ExceptionInformation { - siteName?: string; - explanationString?: string; - detailURI?: string; -} - -interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { - arrayOfDomainStrings?: Array; -} - -interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { - arrayOfDomainStrings?: Array; -} - -interface AlgorithmParameters { -} - -interface MutationObserverInit { - childList?: boolean; - attributes?: boolean; - characterData?: boolean; - subtree?: boolean; - attributeOldValue?: boolean; - characterDataOldValue?: boolean; - attributeFilter?: Array; -} - -interface ExceptionInformation { - domain?: string; -} - -interface MsZoomToOptions { - contentX?: number; - contentY?: number; - viewportX?: string; - viewportY?: string; - scaleFactor?: number; - animate?: string; -} - -interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; -} - -interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; -} - -interface Algorithm { - name?: string; - params?: AlgorithmParameters; -} - -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 { - (...args: any[]): any; -} - -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; -} - -interface SubtleCrypto { - unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; - encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; - importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; - verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; - deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; - exportKey(format: string, key: Key): KeyOperation; - generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - 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 { - creationTime: number; - totalVideoFrames: number; - droppedVideoFrames: number; -} -declare var VideoPlaybackQuality: { - prototype: VideoPlaybackQuality; - new (): VideoPlaybackQuality; -} - -interface Window { - 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; - 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 { - algorithm: Algorithm; - type: string; - 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 { - y: number; - x: number; - z: number; -} -declare var DeviceAcceleration: { - prototype: DeviceAcceleration; - new (): DeviceAcceleration; -} - -interface Console { - count(countTitle?: string): void; - groupEnd(): void; - time(timerName?: string): void; - timeEnd(timerName?: string): void; - trace(): void; - group(groupTitle?: string): void; - dirxml(value: any): void; - debug(message?: string, ...optionalParams: any[]): void; - groupCollapsed(groupTitle?: string): void; - select(element: Element): void; -} - -interface MSNavigatorDoNotTrack { - removeSiteSpecificTrackingException(args: ExceptionInformation): boolean; - removeWebWideTrackingException(args: ExceptionInformation): boolean; - 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; -} - -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; -} -declare var HTMLAllCollection: { - prototype: HTMLAllCollection; - new (): HTMLAllCollection; -} - -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 CSSStyleDeclaration { - alignItems: string; - borderImageSource: string; - flexBasis: string; - borderImageWidth: string; - borderImageRepeat: string; - order: string; - flex: string; - alignContent: string; - msImeAlign: string; - flexShrink: string; - flexGrow: string; - borderImageSlice: string; - flexWrap: string; - borderImageOutset: string; - flexDirection: string; - flexFlow: string; - borderImage: string; - justifyContent: string; - alignSelf: string; - 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; - previousSibling: Node; - addedNodes: NodeList; - attributeName: string; - removedNodes: NodeList; - target: Node; - nextSibling: Node; - attributeNamespace: string; - type: string; -} -declare var MutationRecord: { - prototype: MutationRecord; - new (): MutationRecord; -} - -interface Document extends MSDocumentExtensions { - 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; -} - -interface MimeTypeArray { - length: number; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(type: string): Plugin; -} -declare var MimeTypeArray: { - prototype: MimeTypeArray; - new (): MimeTypeArray; -} - -interface HTMLMediaElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - 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. - */ - msKeys: MSMediaKeys; - msGraphicsTrustStatus: MSGraphicsTrust; - msSetMediaKeys(mediaKeys: MSMediaKeys): void; - addTextTrack(kind: string, label?: string, language?: string): TextTrack; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface TextTrack { - addCue(cue: TextTrackCue): void; - removeCue(cue: TextTrackCue): void; -} - -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; - alpha: number; - absolute: boolean; - 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; - createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; - isTypeSupported(keySystem: string, type?: string): boolean; -} -declare var MSMediaKeys: { - prototype: MSMediaKeys; - new (): MSMediaKeys; -} - -interface MSHTMLWebViewElement extends HTMLElement { - documentTitle: string; - width: number; - src: string; - canGoForward: boolean; - height: number; - canGoBack: boolean; - navigateWithHttpRequestMessage(requestMessage: any): void; - goBack(): void; - navigate(uri: string): void; - stop(): void; - navigateToString(contents: string): void; - captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; - capturePreviewToBlobAsync(): MSWebViewAsyncOperation; - refresh(): void; - goForward(): void; - navigateToLocalStreamUri(source: string, streamResolver: any): void; - 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 { - onmspointerenter: (ev: any) => any; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - onmspointerleave: (ev: any) => any; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - msZoomTo(args: MsZoomToOptions): void; - msGetUntransformedBounds(): ClientRect; - msRequestFullscreen(): void; -} - -interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; -} - -interface XMLHttpRequest { - msCaching: string; - msCachingEnabled(): boolean; - overrideMimeType(mime: string): void; -} - -interface SourceBuffer extends EventTarget { - updating: boolean; - appendWindowStart: number; - appendWindowEnd: number; - buffered: TimeRanges; - timestampOffset: number; - audioTracks: AudioTrackList; - appendBuffer(data: ArrayBuffer): void; - remove(start: number, end: number): void; - 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 { - gamma: number; - alpha: number; - beta: number; -} -declare var DeviceRotationRate: { - prototype: DeviceRotationRate; - new (): DeviceRotationRate; -} - -interface PluginArray { - length: number; - refresh(reload?: boolean): void; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(name: string): Plugin; -} -declare var PluginArray: { - prototype: PluginArray; - new (): PluginArray; -} - -interface MSMediaKeyError { - systemCode: number; - code: number; - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - 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; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - MS_MEDIA_KEYERR_CLIENT: number; -} - -interface Plugin { - length: number; - filename: string; - version: string; - name: string; - description: string; - item(index: number): MimeType; - [index: number]: MimeType; - namedItem(type: string): MimeType; -} -declare var Plugin: { - prototype: Plugin; - new (): Plugin; -} - -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; - activeSourceBuffers: SourceBufferList; - addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; - isTypeSupported(type: string): boolean; - removeSourceBuffer(sourceBuffer: SourceBuffer): void; -} -declare var MediaSource: { - prototype: MediaSource; - new (): MediaSource; -} - -interface MediaError { - MS_MEDIA_ERR_ENCRYPTED: number; -} -//declare var MediaError: { -// prototype: MediaError; -// MS_MEDIA_ERR_ENCRYPTED: number; -//} - -interface SourceBufferList extends EventTarget { - length: number; - 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; - acceleration: DeviceAcceleration; - interval: number; - 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; - suffixes: string; - type: string; - description: string; -} -declare var MimeType: { - prototype: MimeType; - new (): MimeType; -} - -interface MSDocumentExtensions { - captureEvents(): void; - releaseEvents(): void; -} - -interface HTMLElement { - dataset: DOMStringMap; - hidden: boolean; - msGetInputContext(): MSInputMethodContext; -} - -interface MutationObserver { - observe(target: Node, options: MutationObserverInit): void; - takeRecords(): MutationRecord[]; - disconnect(): void; -} -declare var MutationObserver: { - prototype: MutationObserver; - new (callback: (arr: MutationRecord[], observer: MutationObserver)=>any): MutationObserver; -} - -interface AudioTrackList { - onremovetrack: (ev: PluginArray) => any; - //addEventListener(type: "removetrack", listener: (ev: PluginArray) => any, useCapture?: boolean): void; -} - -interface HTMLObjectElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; -} - -interface HTMLEmbedElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; -} - -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; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; -} -declare var MSWebViewAsyncOperation: { - prototype: MSWebViewAsyncOperation; - new (): MSWebViewAsyncOperation; - ERROR: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; -} - -interface ScriptNotifyEvent extends Event { - value: string; - callingUri: string; -} -declare var ScriptNotifyEvent: { - prototype: ScriptNotifyEvent; - new (): ScriptNotifyEvent; -} - -interface PerformanceNavigationTiming extends PerformanceEntry { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - redirectCount: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - 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; - MS_MANIPULATION_STATE_COMMITTED: number; - MS_MANIPULATION_STATE_PRESELECT: number; - MS_MANIPULATION_STATE_DRAGGING: number; - 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; -// MS_MANIPULATION_STATE_DRAGGING: number; -// MS_MANIPULATION_STATE_CANCELLED: number; -//} - -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; - performanceCounter: number; - averagePaintTime: number; - activeNetworkRequestCount: number; - paintRequestsPerSecond: number; - repositionWindow(x: number, y: number): void; - getRecentMemoryUsage(last: number): any; - getMemoryUsage(): number; - resizeWindow(width: number, height: number): void; - getProcessCpuUsage(): number; - removeEventListener(eventType: string, callback: (ev: any) => any): void; - getRecentCpuUsage(last: number): any; - addEventListener(eventType: string, callback: (ev: any) => any): void; - 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; -} - -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; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - createNewView(uri: string): MSAppView; - getCurrentPriority(): string; - NORMAL: string; - HIGH: string; - IDLE: string; - 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; - keySystem: string; - close(): void; - update(key: Uint8Array): void; -} -declare var MSMediaKeySession: { - prototype: MSMediaKeySession; - new (): MSMediaKeySession; -} - -interface HTMLVideoElement { - videoPlaybackQuality: 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 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 function addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - - -///////////////////////////// -/// WorkerGlobalScope APIs -///////////////////////////// -// TODO: These are only available in a Web Worker - should be in a separate lib file -declare function importScripts(...urls: string[]): void; - - -///////////////////////////// -/// Windows Script Host APIS -///////////////////////////// -declare var ActiveXObject: { new (s: string): any; }; - -interface ITextWriter { - Write(s: string): void; - WriteLine(s: string): void; - Close(): void; -} - -declare var WScript: { - Echo(s: any): void; - StdErr: ITextWriter; - StdOut: ITextWriter; - Arguments: { length: number; Item(n: number): string; }; - ScriptFullName: string; - Quit(exitCode?: number): number; -} diff --git a/_infrastructure/tests/typescript/0.9.5-beta/tsc b/_infrastructure/tests/typescript/0.9.5-beta/tsc deleted file mode 100644 index 3c0dab574f..0000000000 --- a/_infrastructure/tests/typescript/0.9.5-beta/tsc +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -require('./tsc.js') diff --git a/_infrastructure/tests/typescript/0.9.5-beta/tsc.js b/_infrastructure/tests/typescript/0.9.5-beta/tsc.js deleted file mode 100644 index a31675a5ad..0000000000 --- a/_infrastructure/tests/typescript/0.9.5-beta/tsc.js +++ /dev/null @@ -1,60908 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - TypeScript.DiagnosticCode = { - error_TS_0_1: "error TS{0}: {1}", - warning_TS_0_1: "warning TS{0}: {1}", - Unrecognized_escape_sequence: "Unrecognized escape sequence.", - Unexpected_character_0: "Unexpected character {0}.", - Missing_close_quote_character: "Missing close quote character.", - Identifier_expected: "Identifier expected.", - _0_keyword_expected: "'{0}' keyword expected.", - _0_expected: "'{0}' expected.", - Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", - Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", - Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", - Trailing_separator_not_allowed: "Trailing separator not allowed.", - AsteriskSlash_expected: "'*/' expected.", - public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", - Unexpected_token: "Unexpected token.", - Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", - Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", - Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", - Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", - Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", - Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", - Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", - Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", - Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", - Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", - Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", - extends_clause_already_seen: "'extends' clause already seen.", - extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", - Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", - implements_clause_already_seen: "'implements' clause already seen.", - Accessibility_modifier_already_seen: "Accessibility modifier already seen.", - _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", - _0_modifier_already_seen: "'{0}' modifier already seen.", - _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", - Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", - super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", - Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", - Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", - 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.", - Function_implementation_expected: "Function implementation expected.", - Constructor_implementation_expected: "Constructor implementation expected.", - Function_overload_name_must_be_0: "Function overload name must be '{0}'.", - _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", - declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", - declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", - Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", - Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", - set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", - set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", - set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", - set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", - get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", - Modifiers_cannot_appear_here: "Modifiers cannot appear here.", - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", - Class_name_cannot_be_0: "Class name cannot be '{0}'.", - Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", - Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", - Module_name_cannot_be_0: "Module name cannot be '{0}'.", - Enum_member_must_have_initializer: "Enum member must have initializer.", - Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", - Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", - Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", - Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", - module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", - constructor_function_accessor_or_variable: "constructor, function, accessor or variable", - statement: "statement", - case_or_default_clause: "case or default clause", - identifier: "identifier", - call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", - expression: "expression", - type_name: "type name", - property_or_accessor: "property or accessor", - parameter: "parameter", - type: "type", - type_parameter: "type parameter", - 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.", - 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.", - super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", - Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", - Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", - Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", - Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", - Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", - Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", - Getter_0_already_declared: "Getter '{0}' already declared.", - Setter_0_already_declared: "Setter '{0}' already declared.", - Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", - Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", - Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", - Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", - Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", - Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", - Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", - Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", - Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", - Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", - Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", - Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", - Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", - Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", - Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", - Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", - Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", - Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", - Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", - Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", - Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", - Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", - A_class_may_only_extend_another_class: "A class may only extend another class.", - A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", - An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", - Unable_to_resolve_type: "Unable to resolve type.", - Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", - Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", - Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", - Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", - Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", - Invalid_new_expression: "Invalid 'new' expression.", - Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", - Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", - Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", - Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", - Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", - Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", - The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", - 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.", - 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.", - _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.", - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", - Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", - 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.", - 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.", - 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.", - Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", - Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", - Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", - All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", - Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", - this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", - Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", - Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", - Duplicate_overload_call_signature: "Duplicate overload call signature.", - Duplicate_overload_construct_signature: "Duplicate overload construct signature.", - Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", - Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", - Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", - 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.", - 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.", - Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", - A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", - Rest_parameters_must_be_array_types: "Rest parameters must be array types.", - Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", - 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}", - 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.", - 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.", - Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", - Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", - Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", - 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}'.", - 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}", - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", - Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", - All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", - super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", - Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", - Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", - Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", - Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", - Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", - continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", - break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", - Jump_target_not_found: "Jump target not found.", - Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", - TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", - TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", - TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", - TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", - TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", - TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", - 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.", - 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}", - Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", - Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", - Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", - Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", - Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", - Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - 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.", - _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_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}", - 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.", - Could_not_find_file_0: "Could not find file: '{0}'.", - A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", - Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", - Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", - Emit_Error_0: "Emit Error: {0}.", - Cannot_read_file_0_1: "Cannot read file '{0}': {1}", - Unsupported_file_encoding: "Unsupported file encoding.", - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", - Unsupported_locale_0: "Unsupported locale: '{0}'.", - Execution_Failed_NL: "Execution Failed.{NL}", - Invalid_call_to_up: "Invalid call to 'up'", - Invalid_call_to_down: "Invalid call to 'down'", - Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", - Unknown_option_0: "Unknown option '{0}'", - Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", - Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", - Could_not_delete_file_0: "Could not delete file '{0}'", - Could_not_create_directory_0: "Could not create directory '{0}'", - Error_while_executing_file_0: "Error while executing file '{0}': ", - Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", - Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", - Option_0_specified_without_1: "Option '{0}' specified without '{1}'", - codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", - Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", - Generates_corresponding_0_file: "Generates corresponding {0} file.", - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", - Watch_input_files: "Watch input files.", - Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", - Do_not_emit_comments_to_output: "Do not emit comments to output.", - Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", - Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", - Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", - Print_this_message: "Print this message.", - Print_the_compiler_s_version_0: "Print the compiler's version: {0}", - Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", - Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", - Syntax_0: "Syntax: {0}", - options: "options", - file1: "file", - Examples: "Examples:", - Options: "Options:", - Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", - Version_0: "Version {0}", - Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", - NL_Recompiling_0: "{NL}Recompiling ({0}):", - STRING: "STRING", - KIND: "KIND", - file2: "FILE", - VERSION: "VERSION", - LOCATION: "LOCATION", - DIRECTORY: "DIRECTORY", - NUMBER: "NUMBER", - Specify_the_codepage_to_use_when_opening_source_files: "Specify the codepage to use when opening source files.", - 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})", - Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", - Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", - Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", - Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", - Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", - new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", - _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", - Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", - 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." - }; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - return false; - } - - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0, n = array1.length; i < n; i++) { - if (!equals(array1[i], array2[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.distinct = function (array, equalsFn) { - var result = []; - - for (var i = 0, n = array.length; i < n; i++) { - var current = array[i]; - for (var j = 0; j < result.length; j++) { - if (equalsFn(result[j], current)) { - break; - } - } - - if (j === result.length) { - result.push(current); - } - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.lastOrDefault = function (array, predicate) { - for (var i = array.length - 1; i >= 0; i--) { - var v = array[i]; - if (predicate(v, i)) { - return v; - } - } - - return null; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value, i)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.first = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (!func || func(value, i)) { - return value; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = new Array(values.length); - - for (var i = 0; i < values.length; i++) { - result[i] = func(values[i]); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = new Array(); - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - var low = 0; - var high = array.length - 1; - - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - - if (midValue === value) { - return middle; - } else if (midValue > value) { - high = middle - 1; - } else { - low = middle + 1; - } - } - - return ~low; - }; - - ArrayUtilities.createArray = function (length, defaultValue) { - var result = new Array(length); - for (var i = 0; i < length; i++) { - result[i] = defaultValue; - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - - ArrayUtilities.indexOf = function (array, predicate) { - for (var i = 0, n = array.length; i < n; i++) { - if (predicate(array[i])) { - return i; - } - } - - return -1; - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitVector) { - var pool = []; - var Constants; - (function (Constants) { - Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; - Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; - - Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; - - Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; - Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; - - Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; - Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; - Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; - })(Constants || (Constants = {})); - - var BitVectorImpl = (function () { - function BitVectorImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.bits = []; - } - BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; - }; - - BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; - }; - - BitVectorImpl.prototype.valueAt = function (index) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return undefined; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { - return true; - } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { - return false; - } else { - return undefined; - } - } else { - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return false; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { - return true; - } else { - return false; - } - } - }; - - BitVectorImpl.prototype.setValueAt = function (index, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); - - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === undefined) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - - var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); - encoded = encoded & clearMask; - - if (value === true) { - encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); - } else if (value === false) { - encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } else { - TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); - - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === false) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - - encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); - - if (value) { - encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } - }; - - BitVectorImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - this.bits.length = 0; - pool.push(this); - }; - return BitVectorImpl; - })(); - - function getBitVector(allowUndefinedValues) { - if (pool.length === 0) { - return new BitVectorImpl(allowUndefinedValues); - } - - var vector = pool.pop(); - vector.isReleased = false; - vector.allowUndefinedValues = allowUndefinedValues; - - return vector; - } - BitVector.getBitVector = getBitVector; - })(TypeScript.BitVector || (TypeScript.BitVector = {})); - var BitVector = TypeScript.BitVector; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitMatrix) { - var pool = []; - - var BitMatrixImpl = (function () { - function BitMatrixImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.vectors = []; - } - BitMatrixImpl.prototype.valueAt = function (x, y) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - return this.allowUndefinedValues ? undefined : false; - } - - return vector.valueAt(y); - }; - - BitMatrixImpl.prototype.setValueAt = function (x, y, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - if (value === undefined) { - return; - } - - vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); - this.vectors[x] = vector; - } - - vector.setValueAt(y, value); - }; - - BitMatrixImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - - for (var name in this.vectors) { - if (this.vectors.hasOwnProperty(name)) { - var vector = this.vectors[name]; - vector.release(); - } - } - - this.vectors.length = 0; - pool.push(this); - }; - return BitMatrixImpl; - })(); - - function getBitMatrix(allowUndefinedValues) { - if (pool.length === 0) { - return new BitMatrixImpl(allowUndefinedValues); - } - - var matrix = pool.pop(); - matrix.isReleased = false; - matrix.allowUndefinedValues = allowUndefinedValues; - - return matrix; - } - BitMatrix.getBitMatrix = getBitMatrix; - })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); - var BitMatrix = TypeScript.BitMatrix; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); - var AssertionLevel = TypeScript.AssertionLevel; - - var Debug = (function () { - function Debug() { - } - Debug.shouldAssert = function (level) { - return this.currentAssertionLevel >= level; - }; - - Debug.assert = function (expression, message, verboseDebugInfo) { - if (typeof message === "undefined") { message = ""; } - if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); - } - - throw new Error("Debug Failure. False expression: " + message + verboseDebugString); - } - }; - - Debug.fail = function (message) { - Debug.assert(false, message); - }; - Debug.currentAssertionLevel = 0 /* None */; - return Debug; - })(); - TypeScript.Debug = Debug; -})(TypeScript || (TypeScript = {})); -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; - this._fileName = fileName; - this._lineMap = lineMap; - this._start = start; - this._length = length; - } - Diagnostic.prototype.toJSON = function (key) { - var result = {}; - result.start = this.start(); - result.length = this.length(); - - result.diagnosticCode = this._diagnosticKey; - - 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; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.additionalLocations = function () { - return []; - }; - - 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 v1 === v2; - }); - }; - - Diagnostic.prototype.info = function () { - return getDiagnosticInfoFromKey(this.diagnosticKey()); - }; - return Diagnostic; - })(); - TypeScript.Diagnostic = Diagnostic; - - function newLine() { - return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; - } - TypeScript.newLine = newLine; - - function getLargestIndex(diagnostic) { - var largest = -1; - var regex = /\{(\d+)\}/g; - - var match; - while ((match = regex.exec(diagnostic)) != null) { - var val = parseInt(match[1]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromKey(diagnosticKey) { - var result = TypeScript.diagnosticInformationMap[diagnosticKey]; - TypeScript.Debug.assert(result); - return result; - } - - function getLocalizedText(diagnosticKey, args) { - if (TypeScript.LocalizedDiagnosticMessages) { - } - - var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; - TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); - - var actualCount = args ? args.length : 0; - - var expectedCount = 1 + getLargestIndex(diagnosticKey); - - if (expectedCount !== actualCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); - } - - var valueCount = 1 + getLargestIndex(diagnosticMessageText); - if (valueCount !== expectedCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); - } - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return TypeScript.newLine(); - }); - - return diagnosticMessageText; - } - TypeScript.getLocalizedText = getLocalizedText; - - function getDiagnosticMessage(diagnosticKey, args) { - var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); - var diagnosticMessageText = getLocalizedText(diagnosticKey, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + ". " + message); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error("Invalid operation: " + message); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2StringHashCode = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft == 1) { - h ^= key.charCodeAt(index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, - 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, - 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, - 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, - 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, - 4166287, 4999559, 5999471, 7199369]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 1024; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash) { - this.hash = hash; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode >= 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', "Key was already in table."); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && key === e.Key) { - return e; - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count >= (this.entries.length / 2)) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - return new HashTable(capacity, hash); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - TypeScript.nodeMakeDirectoryTime = 0; - TypeScript.nodeCreateBufferTime = 0; - TypeScript.nodeWriteFileSyncTime = 0; - - (function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; - })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); - var ByteOrderMark = TypeScript.ByteOrderMark; - - var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this.contents = contents; - this.byteOrderMark = byteOrderMark; - } - return FileInformation; - })(); - TypeScript.FileInformation = FileInformation; - - TypeScript.Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - newLine: "\r\n", - currentDirectory: function () { - return WScript.CreateObject("WScript.Shell").CurrentDirectory; - }, - supportsCodePage: function () { - return WScript.ReadFile; - }, - readFile: function (path, codepage) { - try { - if (codepage !== null && this.supportsCodePage()) { - try { - var contents = WScript.ReadFile(path, codepage); - return new FileInformation(contents, 0 /* None */); - } catch (e) { - } - } - - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - var message; - if (err.number === -2147024809) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); - } - - throw new Error(message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - var _os = require('os'); - - return { - newLine: _os.EOL, - currentDirectory: function () { - return process.cwd(); - }, - supportsCodePage: function () { - return false; - }, - readFile: function (file, codepage) { - if (codepage !== null) { - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); - } - - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 509); - } - } - var start = new Date().getTime(); - mkdirRecursiveSync(_path.dirname(path)); - TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - - var start = new Date().getTime(); - - var chunkLength = 4 * 1024; - var fileDescriptor = _fs.openSync(path, "w"); - try { - for (var index = 0; index < contents.length; index += chunkLength) { - var bufferStart = new Date().getTime(); - var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); - TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; - - _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); - } - } finally { - _fs.closeSync(fileDescriptor); - } - - TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IntegerUtilities) { - function integerDivide(numerator, denominator) { - return (numerator / denominator) >> 0; - } - IntegerUtilities.integerDivide = integerDivide; - - function integerMultiplyLow32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - } - IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; - - function integerMultiplyHigh32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - } - IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; - - function isInteger(text) { - return /^[0-9]+$/.test(text); - } - IntegerUtilities.isInteger = isInteger; - - function isHexInteger(text) { - return /^0(x|X)[0-9a-fA-F]+$/.test(text); - } - IntegerUtilities.isHexInteger = isHexInteger; - })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); - var IntegerUtilities = TypeScript.IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_computeLineStarts, length) { - this._computeLineStarts = _computeLineStarts; - this.length = length; - this._lineStarts = null; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this.lineStarts(), length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - if (this._lineStarts === null) { - this._lineStarts = this._computeLineStarts(); - } - - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - LineMap.empty = new LineMap(function () { - return [0]; - }, 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { - return e; - } - } - - return null; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - if (text.length !== length) { - return false; - } - - var s = start; - for (var i = 0; i < length; i++) { - if (text.charCodeAt(i) !== array[s]) { - return false; - } - - s++; - } - - return true; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticInformationMap = { - "error TS{0}: {1}": { - "code": 0, - "category": 3 /* NoPrefix */ - }, - "warning TS{0}: {1}": { - "code": 1, - "category": 3 /* NoPrefix */ - }, - "Unrecognized escape sequence.": { - "code": 1000, - "category": 1 /* Error */ - }, - "Unexpected character {0}.": { - "code": 1001, - "category": 1 /* Error */ - }, - "Missing close quote character.": { - "code": 1002, - "category": 1 /* Error */ - }, - "Identifier expected.": { - "code": 1003, - "category": 1 /* Error */ - }, - "'{0}' keyword expected.": { - "code": 1004, - "category": 1 /* Error */ - }, - "'{0}' expected.": { - "code": 1005, - "category": 1 /* Error */ - }, - "Identifier expected; '{0}' is a keyword.": { - "code": 1006, - "category": 1 /* Error */ - }, - "Automatic semicolon insertion not allowed.": { - "code": 1007, - "category": 1 /* Error */ - }, - "Unexpected token; '{0}' expected.": { - "code": 1008, - "category": 1 /* Error */ - }, - "Trailing separator not allowed.": { - "code": 1009, - "category": 1 /* Error */ - }, - "'*/' expected.": { - "code": 1010, - "category": 1 /* Error */ - }, - "'public' or 'private' modifier must precede 'static'.": { - "code": 1011, - "category": 1 /* Error */ - }, - "Unexpected token.": { - "code": 1012, - "category": 1 /* Error */ - }, - "Catch clause parameter cannot have a type annotation.": { - "code": 1013, - "category": 1 /* Error */ - }, - "Rest parameter must be last in list.": { - "code": 1014, - "category": 1 /* Error */ - }, - "Parameter cannot have question mark and initializer.": { - "code": 1015, - "category": 1 /* Error */ - }, - "Required parameter cannot follow optional parameter.": { - "code": 1016, - "category": 1 /* Error */ - }, - "Index signatures cannot have rest parameters.": { - "code": 1017, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have accessibility modifiers.": { - "code": 1018, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have a question mark.": { - "code": 1019, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have an initializer.": { - "code": 1020, - "category": 1 /* Error */ - }, - "Index signature must have a type annotation.": { - "code": 1021, - "category": 1 /* Error */ - }, - "Index signature parameter must have a type annotation.": { - "code": 1022, - "category": 1 /* Error */ - }, - "Index signature parameter type must be 'string' or 'number'.": { - "code": 1023, - "category": 1 /* Error */ - }, - "'extends' clause already seen.": { - "code": 1024, - "category": 1 /* Error */ - }, - "'extends' clause must precede 'implements' clause.": { - "code": 1025, - "category": 1 /* Error */ - }, - "Classes can only extend a single class.": { - "code": 1026, - "category": 1 /* Error */ - }, - "'implements' clause already seen.": { - "code": 1027, - "category": 1 /* Error */ - }, - "Accessibility modifier already seen.": { - "code": 1028, - "category": 1 /* Error */ - }, - "'{0}' modifier must precede '{1}' modifier.": { - "code": 1029, - "category": 1 /* Error */ - }, - "'{0}' modifier already seen.": { - "code": 1030, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a class element.": { - "code": 1031, - "category": 1 /* Error */ - }, - "Interface declaration cannot have 'implements' clause.": { - "code": 1032, - "category": 1 /* Error */ - }, - "'super' invocation cannot have type arguments.": { - "code": 1034, - "category": 1 /* Error */ - }, - "Only ambient modules can use quoted names.": { - "code": 1035, - "category": 1 /* Error */ - }, - "Statements are not allowed in ambient contexts.": { - "code": 1036, - "category": 1 /* Error */ - }, - "Implementations are not allowed in ambient contexts.": { - "code": 1037, - "category": 1 /* Error */ - }, - "'declare' modifier not allowed for code already in an ambient context.": { - "code": 1038, - "category": 1 /* Error */ - }, - "Initializers are not allowed in ambient contexts.": { - "code": 1039, - "category": 1 /* Error */ - }, - "Parameter property declarations can only be used in constructors.": { - "code": 1040, - "category": 1 /* Error */ - }, - "Function implementation expected.": { - "code": 1041, - "category": 1 /* Error */ - }, - "Constructor implementation expected.": { - "code": 1042, - "category": 1 /* Error */ - }, - "Function overload name must be '{0}'.": { - "code": 1043, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a module element.": { - "code": 1044, - "category": 1 /* Error */ - }, - "'declare' modifier cannot appear on an interface declaration.": { - "code": 1045, - "category": 1 /* Error */ - }, - "'declare' modifier required for top level element.": { - "code": 1046, - "category": 1 /* Error */ - }, - "Rest parameter cannot be optional.": { - "code": 1047, - "category": 1 /* Error */ - }, - "Rest parameter cannot have an initializer.": { - "code": 1048, - "category": 1 /* Error */ - }, - "'set' accessor must have one and only one parameter.": { - "code": 1049, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot be optional.": { - "code": 1051, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot have an initializer.": { - "code": 1052, - "category": 1 /* Error */ - }, - "'set' accessor cannot have rest parameter.": { - "code": 1053, - "category": 1 /* Error */ - }, - "'get' accessor cannot have parameters.": { - "code": 1054, - "category": 1 /* Error */ - }, - "Modifiers cannot appear here.": { - "code": 1055, - "category": 1 /* Error */ - }, - "Accessors are only available when targeting ECMAScript 5 and higher.": { - "code": 1056, - "category": 1 /* Error */ - }, - "Class name cannot be '{0}'.": { - "code": 1057, - "category": 1 /* Error */ - }, - "Interface name cannot be '{0}'.": { - "code": 1058, - "category": 1 /* Error */ - }, - "Enum name cannot be '{0}'.": { - "code": 1059, - "category": 1 /* Error */ - }, - "Module name cannot be '{0}'.": { - "code": 1060, - "category": 1 /* Error */ - }, - "Enum member must have initializer.": { - "code": 1061, - "category": 1 /* Error */ - }, - "Export assignment cannot be used in internal modules.": { - "code": 1063, - "category": 1 /* Error */ - }, - "Export assignment not allowed in module with exported element.": { - "code": 1064, - "category": 1 /* Error */ - }, - "Module cannot have multiple export assignments.": { - "code": 1065, - "category": 1 /* Error */ - }, - "Ambient enum elements can only have integer literal initializers.": { - "code": 1066, - "category": 1 /* Error */ - }, - "module, class, interface, enum, import or statement": { - "code": 1067, - "category": 3 /* NoPrefix */ - }, - "constructor, function, accessor or variable": { - "code": 1068, - "category": 3 /* NoPrefix */ - }, - "statement": { - "code": 1069, - "category": 3 /* NoPrefix */ - }, - "case or default clause": { - "code": 1070, - "category": 3 /* NoPrefix */ - }, - "identifier": { - "code": 1071, - "category": 3 /* NoPrefix */ - }, - "call, construct, index, property or function signature": { - "code": 1072, - "category": 3 /* NoPrefix */ - }, - "expression": { - "code": 1073, - "category": 3 /* NoPrefix */ - }, - "type name": { - "code": 1074, - "category": 3 /* NoPrefix */ - }, - "property or accessor": { - "code": 1075, - "category": 3 /* NoPrefix */ - }, - "parameter": { - "code": 1076, - "category": 3 /* NoPrefix */ - }, - "type": { - "code": 1077, - "category": 3 /* NoPrefix */ - }, - "type parameter": { - "code": 1078, - "category": 3 /* NoPrefix */ - }, - "'declare' modifier not allowed on import declaration.": { - "code": 1079, - "category": 1 /* Error */ - }, - "Function overload must be static.": { - "code": 1080, - "category": 1 /* Error */ - }, - "Function overload must not be static.": { - "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 */ - }, - "Invalid 'reference' directive syntax.": { - "code": 1084, - "category": 1 /* Error */ - }, - "Octal literals are not available when targeting ECMAScript 5 and higher.": { - "code": 1085, - "category": 1 /* Error */ - }, - "Accessors are not allowed in ambient contexts.": { - "code": 1086, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a constructor declaration.": { - "code": 1089, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a parameter.": { - "code": 1090, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'.": { - "code": 2000, - "category": 1 /* Error */ - }, - "The name '{0}' does not exist in the current scope.": { - "code": 2001, - "category": 1 /* Error */ - }, - "The name '{0}' does not refer to a value.": { - "code": 2002, - "category": 1 /* Error */ - }, - "'super' can only be used inside a class instance method.": { - "code": 2003, - "category": 1 /* Error */ - }, - "The left-hand side of an assignment expression must be a variable, property or indexer.": { - "code": 2004, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable. Did you mean to include 'new'?": { - "code": 2161, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable.": { - "code": 2006, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not newable.": { - "code": 2007, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not indexable by type '{1}'.": { - "code": 2008, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { - "code": 2009, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { - "code": 2010, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}'.": { - "code": 2011, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}':{NL}{2}": { - "code": 2012, - "category": 1 /* Error */ - }, - "Expected var, class, interface, or module.": { - "code": 2013, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to type '{1}'.": { - "code": 2014, - "category": 1 /* Error */ - }, - "Getter '{0}' already declared.": { - "code": 2015, - "category": 1 /* Error */ - }, - "Setter '{0}' already declared.": { - "code": 2016, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends private class '{1}'.": { - "code": 2018, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements private interface '{1}'.": { - "code": 2019, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends private interface '{1}'.": { - "code": 2020, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends class from inaccessible module {1}.": { - "code": 2021, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements interface from inaccessible module {1}.": { - "code": 2022, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends interface from inaccessible module {1}.": { - "code": 2023, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2024, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2025, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2026, - "category": 1 /* Error */ - }, - "Exported variable '{0}' has or is using private type '{1}'.": { - "code": 2027, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2028, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2029, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2030, - "category": 1 /* Error */ - }, - "Exported variable '{0}' is using inaccessible module {1}.": { - "code": 2031, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { - "code": 2032, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { - "code": 2033, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { - "code": 2034, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2035, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2036, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2037, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2038, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2039, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2040, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { - "code": 2041, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { - "code": 2042, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { - "code": 2043, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2044, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2045, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2046, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2047, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2048, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2049, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class has or is using private type '{0}'.": { - "code": 2050, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class has or is using private type '{0}'.": { - "code": 2051, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface has or is using private type '{0}'.": { - "code": 2052, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface has or is using private type '{0}'.": { - "code": 2053, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface has or is using private type '{0}'.": { - "code": 2054, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class has or is using private type '{0}'.": { - "code": 2055, - "category": 1 /* Error */ - }, - "Return type of public method from exported class has or is using private type '{0}'.": { - "code": 2056, - "category": 1 /* Error */ - }, - "Return type of method from exported interface has or is using private type '{0}'.": { - "code": 2057, - "category": 1 /* Error */ - }, - "Return type of exported function has or is using private type '{0}'.": { - "code": 2058, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class is using inaccessible module {0}.": { - "code": 2059, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class is using inaccessible module {0}.": { - "code": 2060, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface is using inaccessible module {0}.": { - "code": 2061, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface is using inaccessible module {0}.": { - "code": 2062, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface is using inaccessible module {0}.": { - "code": 2063, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class is using inaccessible module {0}.": { - "code": 2064, - "category": 1 /* Error */ - }, - "Return type of public method from exported class is using inaccessible module {0}.": { - "code": 2065, - "category": 1 /* Error */ - }, - "Return type of method from exported interface is using inaccessible module {0}.": { - "code": 2066, - "category": 1 /* Error */ - }, - "Return type of exported function is using inaccessible module {0}.": { - "code": 2067, - "category": 1 /* Error */ - }, - "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { - "code": 2068, - "category": 1 /* Error */ - }, - "A parameter list must follow a generic type argument list. '(' expected.": { - "code": 2069, - "category": 1 /* Error */ - }, - "Multiple constructor implementations are not allowed.": { - "code": 2070, - "category": 1 /* Error */ - }, - "Unable to resolve external module '{0}'.": { - "code": 2071, - "category": 1 /* Error */ - }, - "Module cannot be aliased to a non-module type.": { - "code": 2072, - "category": 1 /* Error */ - }, - "A class may only extend another class.": { - "code": 2073, - "category": 1 /* Error */ - }, - "A class may only implement another class or interface.": { - "code": 2074, - "category": 1 /* Error */ - }, - "An interface may only extend another class or interface.": { - "code": 2075, - "category": 1 /* Error */ - }, - "Unable to resolve type.": { - "code": 2077, - "category": 1 /* Error */ - }, - "Unable to resolve type of '{0}'.": { - "code": 2078, - "category": 1 /* Error */ - }, - "Unable to resolve type parameter constraint.": { - "code": 2079, - "category": 1 /* Error */ - }, - "Type parameter constraint cannot be a primitive type.": { - "code": 2080, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target.": { - "code": 2081, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target:{NL}{0}": { - "code": 2082, - "category": 1 /* Error */ - }, - "Invalid 'new' expression.": { - "code": 2083, - "category": 1 /* Error */ - }, - "Call signatures used in a 'new' expression must have a 'void' return type.": { - "code": 2084, - "category": 1 /* Error */ - }, - "Could not select overload for 'new' expression.": { - "code": 2085, - "category": 1 /* Error */ - }, - "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { - "code": 2086, - "category": 1 /* Error */ - }, - "Could not select overload for 'call' expression.": { - "code": 2087, - "category": 1 /* Error */ - }, - "Cannot invoke an expression whose type lacks a call signature.": { - "code": 2088, - "category": 1 /* Error */ - }, - "Calls to 'super' are only valid inside a class.": { - "code": 2089, - "category": 1 /* Error */ - }, - "Generic type '{0}' requires {1} type argument(s).": { - "code": 2090, - "category": 1 /* Error */ - }, - "Type of array literal cannot be determined. Best common type could not be found for array elements.": { - "code": 2092, - "category": 1 /* Error */ - }, - "Could not find enclosing symbol for dotted name '{0}'.": { - "code": 2093, - "category": 1 /* Error */ - }, - "The property '{0}' does not exist on value of type '{1}'.": { - "code": 2094, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}'.": { - "code": 2095, - "category": 1 /* Error */ - }, - "'get' and 'set' accessor must have the same type.": { - "code": 2096, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in current location.": { - "code": 2097, - "category": 1 /* Error */ - }, - "Static methods cannot reference class type parameters.": { - "code": 2099, - "category": 1 /* Error */ - }, - "Class '{0}' is recursively referenced as a base type of itself.": { - "code": 2100, - "category": 1 /* Error */ - }, - "Interface '{0}' is recursively referenced as a base type of itself.": { - "code": 2101, - "category": 1 /* Error */ - }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { - "code": 2102, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in non-derived classes.": { - "code": 2103, - "category": 1 /* Error */ - }, - "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { - "code": 2104, - "category": 1 /* Error */ - }, - "Constructors for derived classes must contain a 'super' call.": { - "code": 2105, - "category": 1 /* Error */ - }, - "Super calls are not permitted outside constructors or in local functions inside constructors.": { - "code": 2106, - "category": 1 /* Error */ - }, - "'{0}.{1}' is inaccessible.": { - "code": 2107, - "category": 1 /* Error */ - }, - "'this' cannot be referenced within module bodies.": { - "code": 2108, - "category": 1 /* Error */ - }, - "Invalid '+' expression - types not known to support the addition operator.": { - "code": 2111, - "category": 1 /* Error */ - }, - "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2112, - "category": 1 /* Error */ - }, - "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2113, - "category": 1 /* Error */ - }, - "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { - "code": 2114, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement cannot use a type annotation.": { - "code": 2115, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { - "code": 2116, - "category": 1 /* Error */ - }, - "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { - "code": 2117, - "category": 1 /* Error */ - }, - "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { - "code": 2118, - "category": 1 /* Error */ - }, - "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { - "code": 2119, - "category": 1 /* Error */ - }, - "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { - "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.": { - "code": 2121, - "category": 1 /* Error */ - }, - "Setters cannot return a value.": { - "code": 2122, - "category": 1 /* Error */ - }, - "Tried to query type of uninitialized module '{0}'.": { - "code": 2123, - "category": 1 /* Error */ - }, - "Tried to set variable type to uninitialized module type '{0}'.": { - "code": 2124, - "category": 1 /* Error */ - }, - "Function '{0}' declared a non-void return type, but has no return expression.": { - "code": 2125, - "category": 1 /* Error */ - }, - "Getters must return a value.": { - "code": 2126, - "category": 1 /* Error */ - }, - "Getter and setter accessors do not agree in visibility.": { - "code": 2127, - "category": 1 /* Error */ - }, - "Invalid left-hand side of assignment expression.": { - "code": 2130, - "category": 1 /* Error */ - }, - "Function declared a non-void return type, but has no return expression.": { - "code": 2131, - "category": 1 /* Error */ - }, - "Cannot resolve return type reference.": { - "code": 2132, - "category": 1 /* Error */ - }, - "Constructors cannot have a return type of 'void'.": { - "code": 2133, - "category": 1 /* Error */ - }, - "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { - "code": 2134, - "category": 1 /* Error */ - }, - "All symbols within a with block will be resolved to 'any'.": { - "code": 2135, - "category": 1 /* Error */ - }, - "Import declarations in an internal module cannot reference an external module.": { - "code": 2136, - "category": 1 /* Error */ - }, - "Class {0} declares interface {1} but does not implement it:{NL}{2}": { - "code": 2137, - "category": 1 /* Error */ - }, - "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { - "code": 2138, - "category": 1 /* Error */ - }, - "The operand of an increment or decrement operator must be a variable, property or indexer.": { - "code": 2139, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in static initializers in a class body.": { - "code": 2140, - "category": 1 /* Error */ - }, - "Class '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2141, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2142, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { - "code": 2143, - "category": 1 /* Error */ - }, - "Duplicate overload signature for '{0}'.": { - "code": 2144, - "category": 1 /* Error */ - }, - "Duplicate constructor overload signature.": { - "code": 2145, - "category": 1 /* Error */ - }, - "Duplicate overload call signature.": { - "code": 2146, - "category": 1 /* Error */ - }, - "Duplicate overload construct signature.": { - "code": 2147, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition.": { - "code": 2148, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition:{NL}{0}": { - "code": 2149, - "category": 1 /* Error */ - }, - "Overload signatures must all be public or private.": { - "code": 2150, - "category": 1 /* Error */ - }, - "Overload signatures must all be exported or not exported.": { - "code": 2151, - "category": 1 /* Error */ - }, - "Overload signatures must all be ambient or non-ambient.": { - "code": 2152, - "category": 1 /* Error */ - }, - "Overload signatures must all be optional or required.": { - "code": 2153, - "category": 1 /* Error */ - }, - "Specialized overload signature is not subtype of any non-specialized signature.": { - "code": 2154, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in constructor arguments.": { - "code": 2155, - "category": 1 /* Error */ - }, - "Instance member cannot be accessed off a class.": { - "code": 2157, - "category": 1 /* Error */ - }, - "Untyped function calls may not accept type arguments.": { - "code": 2158, - "category": 1 /* Error */ - }, - "Non-generic functions may not accept type arguments.": { - "code": 2159, - "category": 1 /* Error */ - }, - "A generic type may not reference itself with a wrapped form of its own type parameters.": { - "code": 2160, - "category": 1 /* Error */ - }, - "Rest parameters must be array types.": { - "code": 2162, - "category": 1 /* Error */ - }, - "Overload signature implementation cannot use specialized type.": { - "code": 2163, - "category": 1 /* Error */ - }, - "Export assignments may only be used at the top-level of external modules.": { - "code": 2164, - "category": 1 /* Error */ - }, - "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2165, - "category": 1 /* Error */ - }, - "Only public methods of the base class are accessible via the 'super' keyword.": { - "code": 2166, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.": { - "code": 2167, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}": { - "code": 2168, - "category": 1 /* Error */ - }, - "All numerically named properties must be subtypes of numeric indexer type '{0}'.": { - "code": 2169, - "category": 1 /* Error */ - }, - "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}": { - "code": 2170, - "category": 1 /* Error */ - }, - "All named properties must be subtypes of string indexer type '{0}'.": { - "code": 2171, - "category": 1 /* Error */ - }, - "All named properties must be subtypes of string indexer type '{0}':{NL}{1}": { - "code": 2172, - "category": 1 /* Error */ - }, - "Generic type references must include all type arguments.": { - "code": 2173, - "category": 1 /* Error */ - }, - "Default arguments are not allowed in an overload parameter.": { - "code": 2174, - "category": 1 /* Error */ - }, - "Overloads cannot differ only by return type.": { - "code": 2175, - "category": 1 /* Error */ - }, - "Function expression declared a non-void return type, but has no return expression.": { - "code": 2176, - "category": 1 /* Error */ - }, - "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2177, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}' in module '{1}'.": { - "code": 2178, - "category": 1 /* Error */ - }, - "Unable to resolve module reference '{0}'.": { - "code": 2179, - "category": 1 /* Error */ - }, - "Could not find module '{0}' in module '{1}'.": { - "code": 2180, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { - "code": 2181, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { - "code": 2182, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { - "code": 2183, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { - "code": 2184, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { - "code": 2185, - "category": 1 /* Error */ - }, - "Type reference '{0}' in extends clause does not reference constructor function for '{1}'.": { - "code": 2186, - "category": 1 /* Error */ - }, - "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { - "code": 2187, - "category": 1 /* Error */ - }, - "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { - "code": 2188, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { - "code": 2189, - "category": 1 /* Error */ - }, - "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { - "code": 2190, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot be reopened.": { - "code": 2191, - "category": 1 /* Error */ - }, - "All declarations of merged declaration '{0}' must be exported or not exported.": { - "code": 2192, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in constructor arguments.": { - "code": 2193, - "category": 1 /* Error */ - }, - "Return type of constructor signature must be assignable to the instance type of the class.": { - "code": 2194, - "category": 1 /* Error */ - }, - "Ambient external module declaration must be defined in global context.": { - "code": 2195, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot specify relative module name.": { - "code": 2196, - "category": 1 /* Error */ - }, - "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { - "code": 2197, - "category": 1 /* Error */ - }, - "Could not find the best common type of types of all return statement expressions.": { - "code": 2198, - "category": 1 /* Error */ - }, - "Import declaration cannot refer to external module reference when --noResolve option is set.": { - "code": 2199, - "category": 1 /* Error */ - }, - "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { - "code": 2200, - "category": 1 /* Error */ - }, - "'continue' statement can only be used within an enclosing iteration statement.": { - "code": 2201, - "category": 1 /* Error */ - }, - "'break' statement can only be used within an enclosing iteration or switch statement.": { - "code": 2202, - "category": 1 /* Error */ - }, - "Jump target not found.": { - "code": 2203, - "category": 1 /* Error */ - }, - "Jump target cannot cross function boundary.": { - "code": 2204, - "category": 1 /* Error */ - }, - "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { - "code": 2205, - "category": 1 /* Error */ - }, - "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { - "code": 2206, - "category": 1 /* Error */ - }, - "Expression resolves to '_super' that compiler uses to capture base class reference.": { - "code": 2207, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2208, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2209, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2210, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2211, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2212, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2213, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2214, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2215, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2216, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2217, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2218, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2219, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { - "code": 2220, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2221, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { - "code": 2222, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2223, - "category": 1 /* Error */ - }, - "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { - "code": 2224, - "category": 1 /* Error */ - }, - "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { - "code": 2225, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { - "code": 2226, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { - "code": 2227, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { - "code": 2228, - "category": 1 /* Error */ - }, - "Type '{0}' is missing property '{1}' from type '{2}'.": { - "code": 4000, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { - "code": 4001, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { - "code": 4002, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { - "code": 4003, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { - "code": 4004, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' define property '{2}' as private.": { - "code": 4005, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4006, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4007, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a call signature, but type '{1}' lacks one.": { - "code": 4008, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4009, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4010, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { - "code": 4011, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4012, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4013, - "category": 3 /* NoPrefix */ - }, - "Call signature expects {0} or fewer parameters.": { - "code": 4014, - "category": 3 /* NoPrefix */ - }, - "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { - "code": 4015, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4016, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4017, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { - "code": 4018, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { - "code": 4019, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { - "code": 4020, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { - "code": 4021, - "category": 3 /* NoPrefix */ - }, - "Type reference cannot refer to container '{0}'.": { - "code": 4022, - "category": 1 /* Error */ - }, - "Type reference must refer to type.": { - "code": 4023, - "category": 1 /* Error */ - }, - "Enums with multiple declarations must provide an initializer for the first enum element.": { - "code": 4024, - "category": 1 /* Error */ - }, - " (+ {0} overload(s))": { - "code": 4025, - "category": 2 /* Message */ - }, - "Variable declaration cannot have the same name as an import declaration.": { - "code": 4026, - "category": 1 /* Error */ - }, - "Signature expected {0} type arguments, got {1} instead.": { - "code": 4027, - "category": 1 /* Error */ - }, - "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { - "code": 4028, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in inifinitely 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.": { - "code": 4030, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in inifinitely 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.": { - "code": 4032, - "category": 3 /* NoPrefix */ - }, - "Types of string indexer of types '{0}' and '{1}' are not identical.": { - "code": 4033, - "category": 3 /* NoPrefix */ - }, - "Types of number indexer of types '{0}' and '{1}' are not identical.": { - "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}": { - "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}": { - "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}": { - "code": 4037, - "category": 3 /* NoPrefix */ - }, - "Current host does not support '{0}' option.": { - "code": 5001, - "category": 1 /* Error */ - }, - "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { - "code": 5002, - "category": 1 /* Error */ - }, - "Module code generation '{0}' not supported.": { - "code": 5003, - "category": 1 /* Error */ - }, - "Could not find file: '{0}'.": { - "code": 5004, - "category": 1 /* Error */ - }, - "A file cannot have a reference to itself.": { - "code": 5006, - "category": 1 /* Error */ - }, - "Cannot resolve referenced file: '{0}'.": { - "code": 5007, - "category": 1 /* Error */ - }, - "Cannot find the common subdirectory path for the input files.": { - "code": 5009, - "category": 1 /* Error */ - }, - "Emit Error: {0}.": { - "code": 5011, - "category": 1 /* Error */ - }, - "Cannot read file '{0}': {1}": { - "code": 5012, - "category": 1 /* Error */ - }, - "Unsupported file encoding.": { - "code": 5013, - "category": 3 /* NoPrefix */ - }, - "Locale must be of the form or -. For example '{0}' or '{1}'.": { - "code": 5014, - "category": 1 /* Error */ - }, - "Unsupported locale: '{0}'.": { - "code": 5015, - "category": 1 /* Error */ - }, - "Execution Failed.{NL}": { - "code": 5016, - "category": 1 /* Error */ - }, - "Invalid call to 'up'": { - "code": 5019, - "category": 1 /* Error */ - }, - "Invalid call to 'down'": { - "code": 5020, - "category": 1 /* Error */ - }, - "Base64 value '{0}' finished with a continuation bit.": { - "code": 5021, - "category": 1 /* Error */ - }, - "Unknown option '{0}'": { - "code": 5023, - "category": 1 /* Error */ - }, - "Expected {0} arguments to message, got {1} instead.": { - "code": 5024, - "category": 1 /* Error */ - }, - "Expected the message '{0}' to have {1} arguments, but it had {2}": { - "code": 5025, - "category": 1 /* Error */ - }, - "Could not delete file '{0}'": { - "code": 5034, - "category": 1 /* Error */ - }, - "Could not create directory '{0}'": { - "code": 5035, - "category": 1 /* Error */ - }, - "Error while executing file '{0}': ": { - "code": 5036, - "category": 1 /* Error */ - }, - "Cannot compile external modules unless the '--module' flag is provided.": { - "code": 5037, - "category": 1 /* Error */ - }, - "Option mapRoot cannot be specified without specifying sourcemap option.": { - "code": 5038, - "category": 1 /* Error */ - }, - "Option sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5039, - "category": 1 /* Error */ - }, - "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5040, - "category": 1 /* Error */ - }, - "Option '{0}' specified without '{1}'": { - "code": 5041, - "category": 1 /* Error */ - }, - "'codepage' option not supported on current platform.": { - "code": 5042, - "category": 1 /* Error */ - }, - "Concatenate and emit output to single file.": { - "code": 6001, - "category": 2 /* Message */ - }, - "Generates corresponding {0} file.": { - "code": 6002, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate map files instead of generated locations.": { - "code": 6003, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate TypeScript files instead of source locations.": { - "code": 6004, - "category": 2 /* Message */ - }, - "Watch input files.": { - "code": 6005, - "category": 2 /* Message */ - }, - "Redirect output structure to the directory.": { - "code": 6006, - "category": 2 /* Message */ - }, - "Do not emit comments to output.": { - "code": 6009, - "category": 2 /* Message */ - }, - "Skip resolution and preprocessing.": { - "code": 6010, - "category": 2 /* Message */ - }, - "Specify ECMAScript target version: '{0}' (default), or '{1}'": { - "code": 6015, - "category": 2 /* Message */ - }, - "Specify module code generation: '{0}' or '{1}'": { - "code": 6016, - "category": 2 /* Message */ - }, - "Print this message.": { - "code": 6017, - "category": 2 /* Message */ - }, - "Print the compiler's version: {0}": { - "code": 6019, - "category": 2 /* Message */ - }, - "Allow use of deprecated '{0}' keyword when referencing an external module.": { - "code": 6021, - "category": 2 /* Message */ - }, - "Specify locale for errors and messages. For example '{0}' or '{1}'": { - "code": 6022, - "category": 2 /* Message */ - }, - "Syntax: {0}": { - "code": 6023, - "category": 2 /* Message */ - }, - "options": { - "code": 6024, - "category": 2 /* Message */ - }, - "file1": { - "code": 6025, - "category": 2 /* Message */ - }, - "Examples:": { - "code": 6026, - "category": 2 /* Message */ - }, - "Options:": { - "code": 6027, - "category": 2 /* Message */ - }, - "Insert command line options and files from a file.": { - "code": 6030, - "category": 2 /* Message */ - }, - "Version {0}": { - "code": 6029, - "category": 2 /* Message */ - }, - "Use the '{0}' flag to see options.": { - "code": 6031, - "category": 2 /* Message */ - }, - "{NL}Recompiling ({0}):": { - "code": 6032, - "category": 2 /* Message */ - }, - "STRING": { - "code": 6033, - "category": 2 /* Message */ - }, - "KIND": { - "code": 6034, - "category": 2 /* Message */ - }, - "file2": { - "code": 6035, - "category": 2 /* Message */ - }, - "VERSION": { - "code": 6036, - "category": 2 /* Message */ - }, - "LOCATION": { - "code": 6037, - "category": 2 /* Message */ - }, - "DIRECTORY": { - "code": 6038, - "category": 2 /* Message */ - }, - "NUMBER": { - "code": 6039, - "category": 2 /* Message */ - }, - "Specify the codepage to use when opening source files.": { - "code": 6040, - "category": 2 /* Message */ - }, - "This version of the Javascript runtime does not support the '{0}' function.": { - "code": 7000, - "category": 1 /* Error */ - }, - "Unknown rule.": { - "code": 7002, - "category": 1 /* Error */ - }, - "Invalid line number ({0})": { - "code": 7003, - "category": 1 /* Error */ - }, - "Warn on expressions and declarations with an implied 'any' type.": { - "code": 7004, - "category": 2 /* Message */ - }, - "Variable '{0}' implicitly has an 'any' type.": { - "code": 7005, - "category": 1 /* Error */ - }, - "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { - "code": 7006, - "category": 1 /* Error */ - }, - "Parameter '{0}' of function type implicitly has an 'any' type.": { - "code": 7007, - "category": 1 /* Error */ - }, - "Member '{0}' of object type implicitly has an 'any' type.": { - "code": 7008, - "category": 1 /* Error */ - }, - "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { - "code": 7009, - "category": 1 /* Error */ - }, - "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7010, - "category": 1 /* Error */ - }, - "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7011, - "category": 1 /* Error */ - }, - "Parameter '{0}' of lambda function implicitly has an 'any' type.": { - "code": 7012, - "category": 1 /* Error */ - }, - "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7013, - "category": 1 /* Error */ - }, - "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7014, - "category": 1 /* Error */ - }, - "Array Literal implicitly has an 'any' type from widening.": { - "code": 7015, - "category": 1 /* Error */ - }, - "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.": { - "code": 7016, - "category": 1 /* Error */ - } - }; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - this._lineStartPositions = null; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - if (!this._lineStartPositions) { - this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); - } - - return this._lineStartPositions; - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LineMap1) { - function fromSimpleText(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return text.charCodeAt(index); - }, length: text.length() }); - }, text.length()); - } - LineMap1.fromSimpleText = fromSimpleText; - - function fromScriptSnapshot(scriptSnapshot) { - return new TypeScript.LineMap(function () { - return scriptSnapshot.getLineStartPositions(); - }, scriptSnapshot.getLength()); - } - LineMap1.fromScriptSnapshot = fromScriptSnapshot; - - function fromString(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts(text); - }, text.length); - } - LineMap1.fromString = fromString; - })(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) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - if (text === null) { - throw TypeScript.Errors.argumentNull('text'); - } - TypeScript.Debug.assert(lineBreakLength >= 0); - TypeScript.Debug.assert(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this._lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this._lineStarts(); - }, this.length()); - }; - - TextBase.prototype._lineStarts = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this._lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - this._lazyLineStarts = null; - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.substr = function (start, length, intern) { - var startInOriginalText = this.span.start() + start; - return this.text.substr(startInOriginalText, length, intern); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SubText.prototype._lineStarts = function () { - var _this = this; - if (!this._lazyLineStarts) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return _this.charCodeAt(index); - }, length: this.length() }); - } - - return this._lazyLineStarts; - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - this._lazyLineStarts = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - - StringText.prototype._lineStarts = function () { - if (this._lazyLineStarts === null) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); - } - - return this._lazyLineStarts; - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap1.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - this._lineMap = null; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - if (!this._lineMap) { - this._lineMap = TypeScript.LineMap1.fromString(this.value); - } - - return this._lineMap; - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this.scriptSnapshot.getLineStartPositions(); - }, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length; - - if (0 === length) { - var result = new Array(); - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = new Array(); - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (length < 0) { - TypeScript.Errors.argument("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Debug.assert(start >= 0); - TypeScript.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - var change0 = changes[0]; - - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - - oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - CharacterInfo.isOctalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 55 /* _7 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - - SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { - this._languageVersion = languageVersion; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - } - ParseOptions.prototype.toJSON = function (key) { - return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; - }; - - ParseOptions.prototype.languageVersion = function () { - return this._languageVersion; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; - - SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; - SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; - - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - - SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; - SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 62 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 63 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 64 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 65 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 67 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 66 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 68 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 69 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 70 /* OpenBraceToken */, - "}": 71 /* CloseBraceToken */, - "(": 72 /* OpenParenToken */, - ")": 73 /* CloseParenToken */, - "[": 74 /* OpenBracketToken */, - "]": 75 /* CloseBracketToken */, - ".": 76 /* DotToken */, - "...": 77 /* DotDotDotToken */, - ";": 78 /* SemicolonToken */, - ",": 79 /* CommaToken */, - "<": 80 /* LessThanToken */, - ">": 81 /* GreaterThanToken */, - "<=": 82 /* LessThanEqualsToken */, - ">=": 83 /* GreaterThanEqualsToken */, - "==": 84 /* EqualsEqualsToken */, - "=>": 85 /* EqualsGreaterThanToken */, - "!=": 86 /* ExclamationEqualsToken */, - "===": 87 /* EqualsEqualsEqualsToken */, - "!==": 88 /* ExclamationEqualsEqualsToken */, - "+": 89 /* PlusToken */, - "-": 90 /* MinusToken */, - "*": 91 /* AsteriskToken */, - "%": 92 /* PercentToken */, - "++": 93 /* PlusPlusToken */, - "--": 94 /* MinusMinusToken */, - "<<": 95 /* LessThanLessThanToken */, - ">>": 96 /* GreaterThanGreaterThanToken */, - ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 98 /* AmpersandToken */, - "|": 99 /* BarToken */, - "^": 100 /* CaretToken */, - "!": 101 /* ExclamationToken */, - "~": 102 /* TildeToken */, - "&&": 103 /* AmpersandAmpersandToken */, - "||": 104 /* BarBarToken */, - "?": 105 /* QuestionToken */, - ":": 106 /* ColonToken */, - "=": 107 /* EqualsToken */, - "+=": 108 /* PlusEqualsToken */, - "-=": 109 /* MinusEqualsToken */, - "*=": 110 /* AsteriskEqualsToken */, - "%=": 111 /* PercentEqualsToken */, - "<<=": 112 /* LessThanLessThanEqualsToken */, - ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 115 /* AmpersandEqualsToken */, - "|=": 116 /* BarEqualsToken */, - "^=": 117 /* CaretEqualsToken */, - "/": 118 /* SlashToken */, - "/=": 119 /* SlashEqualsToken */ - }; - - var kindToText = new Array(); - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[62 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 89 /* PlusToken */: - return 164 /* PlusExpression */; - case 90 /* MinusToken */: - return 165 /* NegateExpression */; - case 102 /* TildeToken */: - return 166 /* BitwiseNotExpression */; - case 101 /* ExclamationToken */: - return 167 /* LogicalNotExpression */; - case 93 /* PlusPlusToken */: - return 168 /* PreIncrementExpression */; - case 94 /* MinusMinusToken */: - return 169 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 93 /* PlusPlusToken */: - return 210 /* PostIncrementExpression */; - case 94 /* MinusMinusToken */: - return 211 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 91 /* AsteriskToken */: - return 205 /* MultiplyExpression */; - - case 118 /* SlashToken */: - return 206 /* DivideExpression */; - - case 92 /* PercentToken */: - return 207 /* ModuloExpression */; - - case 89 /* PlusToken */: - return 208 /* AddExpression */; - - case 90 /* MinusToken */: - return 209 /* SubtractExpression */; - - case 95 /* LessThanLessThanToken */: - return 202 /* LeftShiftExpression */; - - case 96 /* GreaterThanGreaterThanToken */: - return 203 /* SignedRightShiftExpression */; - - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - return 204 /* UnsignedRightShiftExpression */; - - case 80 /* LessThanToken */: - return 196 /* LessThanExpression */; - - case 81 /* GreaterThanToken */: - return 197 /* GreaterThanExpression */; - - case 82 /* LessThanEqualsToken */: - return 198 /* LessThanOrEqualExpression */; - - case 83 /* GreaterThanEqualsToken */: - return 199 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 200 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 201 /* InExpression */; - - case 84 /* EqualsEqualsToken */: - return 192 /* EqualsWithTypeConversionExpression */; - - case 86 /* ExclamationEqualsToken */: - return 193 /* NotEqualsWithTypeConversionExpression */; - - case 87 /* EqualsEqualsEqualsToken */: - return 194 /* EqualsExpression */; - - case 88 /* ExclamationEqualsEqualsToken */: - return 195 /* NotEqualsExpression */; - - case 98 /* AmpersandToken */: - return 191 /* BitwiseAndExpression */; - - case 100 /* CaretToken */: - return 190 /* BitwiseExclusiveOrExpression */; - - case 99 /* BarToken */: - return 189 /* BitwiseOrExpression */; - - case 103 /* AmpersandAmpersandToken */: - return 188 /* LogicalAndExpression */; - - case 104 /* BarBarToken */: - return 187 /* LogicalOrExpression */; - - case 116 /* BarEqualsToken */: - return 182 /* OrAssignmentExpression */; - - case 115 /* AmpersandEqualsToken */: - return 180 /* AndAssignmentExpression */; - - case 117 /* CaretEqualsToken */: - return 181 /* ExclusiveOrAssignmentExpression */; - - case 112 /* LessThanLessThanEqualsToken */: - return 183 /* LeftShiftAssignmentExpression */; - - case 113 /* GreaterThanGreaterThanEqualsToken */: - return 184 /* SignedRightShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 185 /* UnsignedRightShiftAssignmentExpression */; - - case 108 /* PlusEqualsToken */: - return 175 /* AddAssignmentExpression */; - - case 109 /* MinusEqualsToken */: - return 176 /* SubtractAssignmentExpression */; - - case 110 /* AsteriskEqualsToken */: - return 177 /* MultiplyAssignmentExpression */; - - case 119 /* SlashEqualsToken */: - return 178 /* DivideAssignmentExpression */; - - case 111 /* PercentEqualsToken */: - return 179 /* ModuloAssignmentExpression */; - - case 107 /* EqualsToken */: - return 174 /* AssignmentExpression */; - - case 79 /* CommaToken */: - return 173 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function getOperatorTokenFromBinaryExpression(tokenKind) { - switch (tokenKind) { - case 205 /* MultiplyExpression */: - return 91 /* AsteriskToken */; - - case 206 /* DivideExpression */: - return 118 /* SlashToken */; - - case 207 /* ModuloExpression */: - return 92 /* PercentToken */; - - case 208 /* AddExpression */: - return 89 /* PlusToken */; - - case 209 /* SubtractExpression */: - return 90 /* MinusToken */; - - case 202 /* LeftShiftExpression */: - return 95 /* LessThanLessThanToken */; - - case 203 /* SignedRightShiftExpression */: - return 96 /* GreaterThanGreaterThanToken */; - - case 204 /* UnsignedRightShiftExpression */: - return 97 /* GreaterThanGreaterThanGreaterThanToken */; - - case 196 /* LessThanExpression */: - return 80 /* LessThanToken */; - - case 197 /* GreaterThanExpression */: - return 81 /* GreaterThanToken */; - - case 198 /* LessThanOrEqualExpression */: - return 82 /* LessThanEqualsToken */; - - case 199 /* GreaterThanOrEqualExpression */: - return 83 /* GreaterThanEqualsToken */; - - case 200 /* InstanceOfExpression */: - return 30 /* InstanceOfKeyword */; - - case 201 /* InExpression */: - return 29 /* InKeyword */; - - case 192 /* EqualsWithTypeConversionExpression */: - return 84 /* EqualsEqualsToken */; - - case 193 /* NotEqualsWithTypeConversionExpression */: - return 86 /* ExclamationEqualsToken */; - - case 194 /* EqualsExpression */: - return 87 /* EqualsEqualsEqualsToken */; - - case 195 /* NotEqualsExpression */: - return 88 /* ExclamationEqualsEqualsToken */; - - case 191 /* BitwiseAndExpression */: - return 98 /* AmpersandToken */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 100 /* CaretToken */; - - case 189 /* BitwiseOrExpression */: - return 99 /* BarToken */; - - case 188 /* LogicalAndExpression */: - return 103 /* AmpersandAmpersandToken */; - - case 187 /* LogicalOrExpression */: - return 104 /* BarBarToken */; - - case 182 /* OrAssignmentExpression */: - return 116 /* BarEqualsToken */; - - case 180 /* AndAssignmentExpression */: - return 115 /* AmpersandEqualsToken */; - - case 181 /* ExclusiveOrAssignmentExpression */: - return 117 /* CaretEqualsToken */; - - case 183 /* LeftShiftAssignmentExpression */: - return 112 /* LessThanLessThanEqualsToken */; - - case 184 /* SignedRightShiftAssignmentExpression */: - return 113 /* GreaterThanGreaterThanEqualsToken */; - - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - - case 175 /* AddAssignmentExpression */: - return 108 /* PlusEqualsToken */; - - case 176 /* SubtractAssignmentExpression */: - return 109 /* MinusEqualsToken */; - - case 177 /* MultiplyAssignmentExpression */: - return 110 /* AsteriskEqualsToken */; - - case 178 /* DivideAssignmentExpression */: - return 119 /* SlashEqualsToken */; - - case 179 /* ModuloAssignmentExpression */: - return 111 /* PercentEqualsToken */; - - case 174 /* AssignmentExpression */: - return 107 /* EqualsToken */; - - case 173 /* CommaExpression */: - return 79 /* CommaToken */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; - - function isAnyDivideToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - isIdentifierPartCharacter[character] = true; - isNumericLiteralStart[character] = true; - } - } - - isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); - var end = this.slidingWindow.absoluteIndex(); - - var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); - - var isVariableWidthKeyword = (kindAndFlags & -2147483648 /* IsVariableWidthKeyword */) !== 0; - var kind = kindAndFlags & ~-2147483648 /* IsVariableWidthKeyword */; - - var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo, isVariableWidthKeyword); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, 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); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } else { - var width = end - start; - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(text, start, isTrailing); - }; - - Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { - var trivia = new Array(); - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.slidingWindow.absoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(diagnostics); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(79 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(106 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(78 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(102 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(72 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(73 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(105 /* QuestionToken */); - } - - if (isNumericLiteralStart[character]) { - return this.scanNumericLiteral(diagnostics); - } - - if (isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifierOrKeyword(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var slidingWindow = this.slidingWindow; - var window = slidingWindow.window; - - var startIndex = slidingWindow.currentRelativeItemIndex; - var endIndex = slidingWindow.windowCount; - var currentIndex = startIndex; - var character = 0; - - while (currentIndex < endIndex) { - character = window[currentIndex]; - if (!isIdentifierPartCharacter[character]) { - break; - } - - currentIndex++; - } - - if (currentIndex === endIndex) { - return 0 /* None */; - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - return 0 /* None */; - } else { - var kind; - var identifierLength = currentIndex - startIndex; - if (isKeywordStartCharacter[firstCharacter]) { - kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); - } else { - kind = 11 /* IdentifierName */; - } - - slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); - - return kind; - } - }; - - Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - var sawUnicodeEscape = false; - - do { - var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); - sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - var length = this.slidingWindow.absoluteIndex() - startIndex; - var text = this.text.substr(startIndex, length, false); - var valueText = TypeScript.Syntax.massageEscapes(text); - - var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); - if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { - if (sawUnicodeEscape) { - return keywordKind | -2147483648 /* IsVariableWidthKeyword */; - } else { - return keywordKind; - } - } - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function (diagnostics) { - if (this.isHexNumericLiteral()) { - this.scanHexNumericLiteral(); - } else if (this.isOctalNumericLiteral()) { - this.scanOctalNumericLiteral(diagnostics); - } else { - this.scanDecimalNumericLiteral(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isOctalNumericLiteral = function () { - return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); - }; - - Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { - var position = this.absoluteIndex(); - - while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.languageVersion() >= 1 /* EcmaScript5 */) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); - } - }; - - Scanner.prototype.scanDecimalDigits = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - this.scanDecimalDigits(); - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - this.scanDecimalDigits(); - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - var nextChar1 = this.slidingWindow.peekItemN(1); - - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { - var nextChar2 = this.slidingWindow.peekItemN(2); - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } - } - } - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 82 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* LessThanLessThanEqualsToken */; - } else { - return 95 /* LessThanLessThanToken */; - } - } else { - return 80 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 104 /* BarBarToken */; - } else { - return 99 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* CaretEqualsToken */; - } else { - return 100 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 115 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 103 /* AmpersandAmpersandToken */; - } else { - return 98 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* PercentEqualsToken */; - } else { - return 92 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* MinusMinusToken */; - } else { - return 90 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 108 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 93 /* PlusPlusToken */; - } else { - return 89 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* AsteriskEqualsToken */; - } else { - return 91 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 87 /* EqualsEqualsEqualsToken */; - } else { - return 84 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 85 /* EqualsGreaterThanToken */; - } else { - return 107 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function (diagnostics) { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(diagnostics); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 77 /* DotDotDotToken */; - } else { - return 76 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 119 /* SlashEqualsToken */; - } else { - return 118 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 12 /* RegularExpressionLiteral */; - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* ExclamationEqualsEqualsToken */; - } else { - return 86 /* ExclamationEqualsToken */; - } - } else { - return 101 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - break; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - break; - - default: - break; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - this.scanUnicodeOrHexEscape(errors); - return true; - } - } - - this.slidingWindow.moveToNextItem(); - return false; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); - var errors = new Array(); - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 121 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 124 /* ArrayType */: - return parent.type === nodeOrToken; - case 220 /* CastExpression */: - return parent.type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - case 228 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return TypeScript.Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullEnd; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullEnd = positionedToken.fullEnd(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullEnd) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); - } - - fullEnd -= triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function findSkippedTokenOnLeft(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - - function isIntegerLiteral(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - Syntax.isIntegerLiteral = isIntegerLiteral; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - 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.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - 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.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = new Array(); - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return nodeOrToken.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - element.insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - element.insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - var firstToken = this.firstToken(); - return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.trailingTrivia = function () { - var lastToken = this.lastToken(); - return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - result.parsedInStrictMode = true; - } - - 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]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - var start = positionedToken.start(); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isExpression = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.requireKeyword = requireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.requireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { - return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { - return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.importKeyword; - case 2: - return this.identifier; - case 3: - return this.equalsToken; - case 4: - return this.moduleReference; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - - this._kind = kind; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.kind = function () { - return this._kind; - }; - - HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { - if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.name = name; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.name; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withName = function (name) { - return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { - if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.callSignature = callSignature; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 123 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeQuerySyntax = (function (_super) { - __extends(TypeQuerySyntax, _super); - function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.name = name; - } - TypeQuerySyntax.prototype.accept = function (visitor) { - return visitor.visitTypeQuery(this); - }; - - TypeQuerySyntax.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuerySyntax.prototype.childCount = function () { - return 2; - }; - - TypeQuerySyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeQuerySyntax.prototype.isType = function () { - return true; - }; - - TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { - if (this.typeOfKeyword === typeOfKeyword && this.name === name) { - return this; - } - - return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); - }; - - TypeQuerySyntax.create1 = function (name) { - return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); - }; - - TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.name); - }; - - TypeQuerySyntax.prototype.withName = function (name) { - return this.update(this.typeOfKeyword, name); - }; - - TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeQuerySyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeQuerySyntax = TypeQuerySyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 146 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.modifiers; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifiers = function (modifiers) { - return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.arguments = arguments; - this.closeParenToken = closeParenToken; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 142 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 227 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 239 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.constructorKeyword = constructorKeyword; - this.parameterList = parameterList; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.constructorKeyword; - case 2: - return this.parameterList; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - 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) { - return this; - } - - return new ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); - }; - - ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, constructorKeyword, parameterList, null, null, false); - }; - - ConstructorDeclarationSyntax.create1 = function () { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(62 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.constructorKeyword, parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var GetAccessorSyntax = (function (_super) { - __extends(GetAccessorSyntax, _super); - function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.getKeyword = getKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - } - GetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessor(this); - }; - - GetAccessorSyntax.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - - GetAccessorSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - GetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - GetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetAccessorSyntax.create1 = function (propertyName) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GetAccessorSyntax = GetAccessorSyntax; - - var SetAccessorSyntax = (function (_super) { - __extends(SetAccessorSyntax, _super); - function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.setKeyword = setKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - SetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessor(this); - }; - - SetAccessorSyntax.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - - SetAccessorSyntax.prototype.childCount = function () { - return 5; - }; - - SetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - SetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetAccessorSyntax.create1 = function (propertyName) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SetAccessorSyntax = SetAccessorSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var IndexMemberDeclarationSyntax = (function (_super) { - __extends(IndexMemberDeclarationSyntax, _super); - function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.indexSignature = indexSignature; - this.semicolonToken = semicolonToken; - } - IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexMemberDeclaration(this); - }; - - IndexMemberDeclarationSyntax.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - - IndexMemberDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.indexSignature; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexMemberDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { - if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { - return this; - } - - return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); - }; - - IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); - }; - - IndexMemberDeclarationSyntax.create1 = function (indexSignature) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { - return this.update(this.modifiers, indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.indexSignature, semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexMemberDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - this.colonToken = colonToken; - this.statements = statements; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - this.colonToken = colonToken; - this.statements = statements; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.doKeyword = doKeyword; - this.statement = statement; - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeQuery = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - 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)); - }; - - SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var dedentThisTrivia = dedentNextWhitespace; - dedentNextWhitespace = false; - - if (dedentThisTrivia) { - if (trivia.kind() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - var indentNextTrivia = true; - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var indentThisTrivia = indentNextTrivia; - indentNextTrivia = false; - - switch (trivia.kind()) { - case 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._textOrWidth = textOrWidth; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - 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); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - 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 */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function isExpression(token) { - switch (token.tokenKind) { - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - return true; - } - - return false; - } - Syntax.isExpression = isExpression; - - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - case 13 /* carriageReturn */: - var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) == 10 /* lineFeed */) { - i++; - } - continue; - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - Syntax.massageEscapes = massageEscapes; - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - return regularExpressionValue(text); - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function regularExpressionValue(text) { - try { - var lastSlash = text.lastIndexOf("/"); - var body = text.substring(1, lastSlash); - var flags = text.substring(lastSlash + 1); - return new RegExp(body, flags); - } catch (e) { - return null; - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - EmptyToken.prototype.isExpression = function () { - return isExpression(this); - }; - - EmptyToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - - RealizedToken.prototype.isExpression = function () { - return isExpression(this); - }; - - RealizedToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var AbstractTrivia = (function () { - function AbstractTrivia(_kind) { - this._kind = _kind; - } - AbstractTrivia.prototype.fullWidth = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.fullText = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.toJSON = function (key) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === this._kind) { - result.kind = name; - break; - } - } - - if (this.isSkippedToken()) { - result.skippedToken = this.skippedToken(); - } else { - result.text = this.fullText(); - } - return result; - }; - - AbstractTrivia.prototype.kind = function () { - return this._kind; - }; - - AbstractTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - AbstractTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - AbstractTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - AbstractTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - AbstractTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return AbstractTrivia; - })(); - - var NormalTrivia = (function (_super) { - __extends(NormalTrivia, _super); - function NormalTrivia(kind, _text) { - _super.call(this, kind); - this._text = _text; - } - NormalTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - NormalTrivia.prototype.fullText = function () { - return this._text; - }; - - NormalTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return NormalTrivia; - })(AbstractTrivia); - - var SkippedTokenTrivia = (function (_super) { - __extends(SkippedTokenTrivia, _super); - function SkippedTokenTrivia(_skippedToken) { - _super.call(this, 8 /* SkippedTokenTrivia */); - this._skippedToken = _skippedToken; - } - SkippedTokenTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SkippedTokenTrivia.prototype.fullText = function () { - return this.skippedToken().fullText(); - }; - - SkippedTokenTrivia.prototype.skippedToken = function () { - return this._skippedToken; - }; - return SkippedTokenTrivia; - })(AbstractTrivia); - - var DeferredTrivia = (function (_super) { - __extends(DeferredTrivia, _super); - function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { - _super.call(this, kind); - this._text = _text; - this._fullStart = _fullStart; - this._fullWidth = _fullWidth; - this._fullText = null; - } - DeferredTrivia.prototype.fullWidth = function () { - return this._fullWidth; - }; - - DeferredTrivia.prototype.fullText = function () { - if (!this._fullText) { - this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); - this._text = null; - } - - return this._fullText; - }; - - DeferredTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return DeferredTrivia; - })(AbstractTrivia); - - function deferredTrivia(kind, text, fullStart, fullWidth) { - return new DeferredTrivia(kind, text, fullStart, fullWidth); - } - Syntax.deferredTrivia = deferredTrivia; - - function trivia(kind, text) { - return new NormalTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SkippedTokenTrivia(token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - this.trivia[i].collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 228 /* TypeArgumentList */: - case 229 /* TypeParameterList */: - case 220 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - return SyntaxUtilities.getExportKeyword(moduleElement) !== null; - }; - - SyntaxUtilities.getExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - case 133 /* ImportDeclaration */: - return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); - default: - return null; - } - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeQuery = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.requireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.name); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeQuery = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.name); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitList(node.modifiers); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.constructorKeyword); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.indexSignature); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - - - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - var result = this.currentToken(); - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - - return result; - }; - return SyntaxCursor; - })(); - - - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); - } - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { - this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 69 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return this.eatToken(78 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); - } - - return semicolonToken; - } - - return this.eatToken(78 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= 15 /* FirstKeyword */) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 173 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 186 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 187 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 188 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 189 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 191 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 167 /* LogicalNotExpression */: - case 170 /* DeleteExpression */: - case 171 /* TypeOfExpression */: - case 172 /* VoidExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); - } - } - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - var modifierCount = this.modifierCount(); - return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - var modifierCount = this.modifierCount(); - if (this.isImportDeclaration(modifierCount)) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration(modifierCount)) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration(modifierCount)) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration(modifierCount)) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration(modifierCount)) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(inErrorRecovery)) { - return this.parseStatement(inErrorRecovery); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var modifiers = this.parseModifiers(); - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 80 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - - return typeArgumentList; - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 72 /* OpenParenToken */: - case 76 /* DotToken */: - - case 73 /* CloseParenToken */: - case 75 /* CloseBracketToken */: - case 106 /* ColonToken */: - case 78 /* SemicolonToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - case 84 /* EqualsEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: - case 103 /* AmpersandAmpersandToken */: - case 104 /* BarBarToken */: - case 100 /* CaretToken */: - case 98 /* AmpersandToken */: - case 99 /* BarToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { - var dotToken = this.eatToken(76 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 63 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isAccessor = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 64 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var getKeyword = this.eatKeyword(64 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var setKeyword = this.eatKeyword(68 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(false); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexMemberDeclaration()) { - return this.parseIndexMemberDeclaration(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */ && this.peekToken(index + 1).tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var modifiers = this.parseModifiers(); - var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var parameterList = this.parseParameterList(); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(modifiers, constructorKeyword, parameterList, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 78 /* SemicolonToken */: - case 107 /* EqualsToken */: - case 106 /* ColonToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.isIndexMemberDeclaration = function () { - var index = this.modifierCount(); - return this.isIndexSignature(index); - }; - - ParserImpl.prototype.parseIndexMemberDeclaration = function () { - var modifiers = this.parseModifiers(); - var indexSignature = this.parseIndexSignature(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - if (callSignature.lastToken()) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature(0)) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(inErrorRecovery)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(inErrorRecovery)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function (tokenIndex) { - return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isIdentifier(this.currentToken())) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - - break; - - case 28 /* IfKeyword */: - case 70 /* OpenBraceToken */: - case 33 /* ReturnKeyword */: - case 34 /* SwitchKeyword */: - case 36 /* ThrowKeyword */: - case 15 /* BreakKeyword */: - case 18 /* ContinueKeyword */: - case 26 /* ForKeyword */: - case 42 /* WhileKeyword */: - case 43 /* WithKeyword */: - case 22 /* DoKeyword */: - case 38 /* TryKeyword */: - case 19 /* DebuggerKeyword */: - return true; - } - - if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { - return false; - } - - return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); - }; - - ParserImpl.prototype.parseStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 28 /* IfKeyword */: - return this.parseIfStatement(); - case 70 /* OpenBraceToken */: - return this.parseBlock(false, false); - case 33 /* ReturnKeyword */: - return this.parseReturnStatement(); - case 34 /* SwitchKeyword */: - return this.parseSwitchStatement(); - case 36 /* ThrowKeyword */: - return this.parseThrowStatement(); - case 15 /* BreakKeyword */: - return this.parseBreakStatement(); - case 18 /* ContinueKeyword */: - return this.parseContinueStatement(); - case 26 /* ForKeyword */: - return this.parseForOrForInStatement(); - case 42 /* WhileKeyword */: - return this.parseWhileStatement(); - case 43 /* WithKeyword */: - return this.parseWithStatement(); - case 22 /* DoKeyword */: - return this.parseDoStatement(); - case 38 /* TryKeyword */: - return this.parseTryStatement(); - case 19 /* DebuggerKeyword */: - return this.parseDebuggerStatement(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement(currentToken)) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { - return this.parseEmptyStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(false); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function (currentToken) { - return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(106 /* ColonToken */); - var statement = this.parseStatement(false); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return currentToken.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(78 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { - return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function (currentToken) { - var kind = currentToken.tokenKind; - if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 79 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function (currentToken) { - switch (currentToken.tokenKind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - - case 74 /* OpenBracketToken */: - - case 72 /* OpenParenToken */: - - case 80 /* LessThanToken */: - - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - - case 70 /* OpenBraceToken */: - - case 85 /* EqualsGreaterThanToken */: - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - - case 31 /* NewKeyword */: - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - - case 27 /* FunctionKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(false); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 225 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(token0); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(107 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpressionOrLower = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpressionOrLower(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeOfExpression(); - } else if (currentTokenKind === 41 /* VoidKeyword */) { - return this.parseVoidExpression(); - } else if (currentTokenKind === 21 /* DeleteKeyword */) { - return this.parseDeleteExpression(); - } else if (currentTokenKind === 80 /* LessThanToken */) { - return this.parseCastExpression(); - } else { - return this.parsePostfixExpressionOrLower(); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - if (precedence <= 2 /* AssignmentExpressionPrecedence */) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } - - var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); - if (parethesizedArrowFunction !== null) { - return parethesizedArrowFunction; - } - } - - var leftOperand = this.parseUnaryExpressionOrLower(); - return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(105 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(106 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 81 /* GreaterThanToken */) { - if (storage[1] === 81 /* GreaterThanToken */) { - if (storage[2] === 107 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 107 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 107 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } - - var expression = this.parsePrimaryExpression(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - return this.parseMemberExpressionRest(expression, false, inObjectCreation); - }; - - ParserImpl.prototype.parseCallExpressionOrLower = function () { - var expression; - if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { - expression = this.eatKeyword(50 /* SuperKeyword */); - - var currentTokenKind = this.currentToken().tokenKind; - if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - } - } else { - expression = this.parseMemberExpressionOrLower(false); - } - - return this.parseMemberExpressionRest(expression, true, false); - }; - - ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 72 /* OpenParenToken */: - if (!allowArguments) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 80 /* LessThanToken */: - if (!allowArguments) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 74 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 76 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseCallExpressionOrLower(); - } - }; - - ParserImpl.prototype.parsePostfixExpressionOrLower = function () { - var expression = this.parseLeftHandSideExpressionOrLower(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - } - - return expression; - }; - - ParserImpl.prototype.tryParseGenericArgumentList = function () { - var rewindPoint = this.getRewindPoint(); - - var typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; - var isDot = token0.tokenKind === 76 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - - var argumentList = null; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - - if (isDot) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); - } else { - return this.parseArgumentList(typeArgumentList); - } - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - if (this.currentToken().tokenKind === 80 /* LessThanToken */) { - return this.tryParseGenericArgumentList(); - } - - if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { - return this.parseArgumentList(null); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var _arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - _arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parsePrimaryExpression = function () { - var currentToken = this.currentToken(); - - if (this.isIdentifier(currentToken)) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 74 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 70 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 72 /* OpenParenToken */: - return this.parseParenthesizedExpression(); - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 75 /* CloseBracketToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseObjectCreationExpressionOrLower(true); - var argumentList = this.tryParseArgumentList(); - - var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); - return this.parseMemberExpressionRest(result, true, false); - }; - - ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseMemberExpressionOrLower(inObjectCreation); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(80 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedExpression = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { - return null; - } - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - - this.releaseRewindPoint(rewindPoint); - return arrowFunction; - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.tryParseArrowFunctionBlock = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { - return this.parseBlock(true, false); - } else { - return null; - } - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 70 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 73 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; - } - - if (token1.tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - token2 = this.peekToken(2); - if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { - if (this.isIdentifier(token2)) { - return true; - } - } - - if (!this.isIdentifier(token1)) { - return false; - } - - if (token2.tokenKind === 106 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 105 /* QuestionToken */) { - if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 79 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 106 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { - if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(true); - } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(106 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - return this.eatKeyword(35 /* ThisKeyword */); - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var lessThanToken = this.eatToken(80 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameters = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); - - return typeParameterList; - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(106 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 39 /* TypeOfKeyword */: - - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - - case 70 /* OpenBraceToken */: - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - - case 31 /* NewKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseType = function () { - 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 */) { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.isTypeQuery = function () { - return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; - }; - - ParserImpl.prototype.parseTypeQuery = function () { - var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); - var name = this.parseName(); - - return this.factory.typeQuery(typeOfKeyword, name); - }; - - ParserImpl.prototype.parseNonArrayType = function (currentToken) { - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - return this.eatAnyToken(); - - case 70 /* OpenBraceToken */: - return this.parseObjectType(); - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - return this.parseFunctionType(); - - case 31 /* NewKeyword */: - return this.parseConstructorType(); - } - - return this.parseNameOrGenericType(); - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - var tokenKind = token.tokenKind; - if (tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { - if (this.isIdentifier(token)) { - var nextTokenKind = this.peekToken(1).tokenKind; - switch (nextTokenKind) { - case 73 /* CloseParenToken */: - case 106 /* ColonToken */: - case 107 /* EqualsToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); - - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { - modifierArray.push(this.eatAnyToken()); - continue; - } - - break; - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { - if ((this.listParsingState & state) !== 0) { - if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { - return true; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType, inErrorRecovery); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 79 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 78 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 75 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 70 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 79 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - var currentToken = this.currentToken(); - if (this.isExpression(currentToken)) { - return true; - } - - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.parseStatement(inErrorRecovery); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(inErrorRecovery); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); - - case 16 /* SwitchClause_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 32 /* Block_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); - - case 131072 /* ParameterList_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, options) { - var source = new NormalParserSource(fileName, text, options.languageVersion()); - - return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.inObjectLiteralExpression = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { - return true; - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { - if (parameter.modifiers.childCount() > 0) { - var modifiers = parameter.modifiers; - var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - - if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { - if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); - return true; - } else { - if (modifierIndex > 0) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - 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) { - 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); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); - return true; - } else if (parameter.modifiers.childCount() > 0) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - } else { - inFunctionOverloadChain = false; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var isInStaticOverloadChain = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - var isStaticOverload = null; - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - 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 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; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - 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; - } - } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { - var constructorDeclaration = classElement; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 121 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "boolean": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { - var getKeywordFullStart = this.childFullStart(node, getKeyword); - if (parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { - if (this.checkIndexMemberModifiers(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIndexMemberDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { - if (node.modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(node, node.modifiers); - this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { - if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { - var savedInObjectLiteralExpression = this.inObjectLiteralExpression; - this.inObjectLiteralExpression = true; - _super.prototype.visitObjectLiteralExpression.call(this, node); - this.inObjectLiteralExpression = savedInObjectLiteralExpression; - }; - - GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { - var setKeywordFullStart = this.childFullStart(node, setKeyword); - if (parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); - return true; - } - - var parameterListFullStart = this.childFullStart(node, parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); - var parameter = parameterList.parameters.childAt(0); - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - var seenComputedValue = 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) { - 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; - } - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitEnumElement = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - var expression = node.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(expression)) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); - this.skip(node); - return; - } - } - - _super.prototype.visitEnumElement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (node.stringLiteral === null) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); - } - } - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); - return true; - } - }; - - GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitImportDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); - this.skip(node); - return; - } - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForInStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock || this.inObjectLiteralExpression) { - if (modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclarator.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { - var currentElementFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var child = modifiers.childAt(i); - if (child.kind() !== 57 /* PublicKeyword */) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); - return true; - } - - currentElementFullStart += child.fullWidth(); - } - - 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); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { - this._compiler = _compiler; - this._semanticInfoChain = _semanticInfoChain; - this.fileName = fileName; - this.referencedFiles = referencedFiles; - this._scriptSnapshot = _scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._syntaxTree = _syntaxTree; - this._topLevelDecl = _topLevelDecl; - this._diagnostics = null; - this._bloomFilter = null; - this._sourceUnit = null; - this._lineMap = null; - this._declASTMap = []; - this._astDeclMap = []; - this._isExternalModule = undefined; - this._amdDependencies = undefined; - } - Document.prototype.invalidate = function () { - this._declASTMap.length = 0; - this._astDeclMap.length = 0; - this._topLevelDecl = null; - - this._syntaxTree = null; - this._sourceUnit = null; - this._diagnostics = null; - this._bloomFilter = null; - }; - - Document.prototype.isDeclareFile = function () { - return TypeScript.isDTSFile(this.fileName); - }; - - Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { - var start = new Date().getTime(); - this._diagnostics = syntaxTree.diagnostics(); - TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; - - this._lineMap = syntaxTree.lineMap(); - - var sourceUnit = syntaxTree.sourceUnit(); - var leadingComments = this.getLeadingComments(sourceUnit); - - this._isExternalModule = this.hasImplicitImport(leadingComments) || this.hasTopLevelImportOrExport(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); - } - } - } - - return result; - }; - - Document.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(comment); - - if (match) { - return true; - } - - return false; - }; - - Document.prototype.hasTopLevelImportOrExport = function (node) { - var firstToken; - - 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; - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return true; - } - } - } - - return false; - }; - - Document.prototype.sourceUnit = function () { - if (!this._sourceUnit) { - var start = new Date().getTime(); - var syntaxTree = this.syntaxTree(); - this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); - TypeScript.astTranslationTime += new Date().getTime() - start; - - if (!this.isOpen) { - this._syntaxTree = null; - } - } - - return this._sourceUnit; - }; - - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._diagnostics); - } - - return this._diagnostics; - }; - - Document.prototype.lineMap = function () { - if (this._lineMap === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._lineMap); - } - - return this._lineMap; - }; - - Document.prototype.isExternalModule = function () { - if (this._isExternalModule === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._isExternalModule !== undefined); - } - - return this._isExternalModule; - }; - - Document.prototype.amdDependencies = function () { - if (this._amdDependencies === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._amdDependencies !== undefined); - } - - return this._amdDependencies; - }; - - Document.prototype.syntaxTree = function () { - var result = this._syntaxTree; - if (!result) { - var start = new Date().getTime(); - - result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); - - TypeScript.syntaxTreeParseTime += new Date().getTime() - start; - - if (this.isOpen || !this._sourceUnit) { - this._syntaxTree = result; - } - } - - this.cacheSyntaxTreeInfo(result); - return result; - }; - - Document.prototype.bloomFilter = function () { - if (!this._bloomFilter) { - var identifiers = TypeScript.createIntrinsicsObject(); - var pre = function (cur) { - if (TypeScript.isValidAstNode(cur)) { - if (cur.kind() === 11 /* IdentifierName */) { - var nodeText = cur.valueText(); - - identifiers[nodeText] = true; - } - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); - - var identifierCount = 0; - for (var name in identifiers) { - if (identifiers[name]) { - identifierCount++; - } - } - - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - } - return this._bloomFilter; - }; - - Document.prototype.emitToOwnOutputFile = function () { - return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { - var oldSyntaxTree = this._syntaxTree; - - if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { - var oldText = this._scriptSnapshot; - var newText = scriptSnapshot; - - TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); - var newTextPrefix = newText.getText(0, textChangeRange.span().start()); - TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); - - var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); - var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); - TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); - }; - - Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); - }; - - Document.prototype.topLevelDecl = function () { - if (this._topLevelDecl === null) { - this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); - } - - return this._topLevelDecl; - }; - - Document.prototype._getDeclForAST = function (ast) { - this.topLevelDecl(); - return this._astDeclMap[ast.syntaxID()]; - }; - - Document.prototype.getEnclosingDecl = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - return this._getDeclForAST(ast); - } - - ast = ast.parent; - var decl = null; - while (ast) { - decl = this._getDeclForAST(ast); - - if (decl) { - break; - } - - ast = ast.parent; - } - - return decl._getEnclosingDeclFromParentDecl(); - }; - - Document.prototype._setDeclForAST = function (ast, decl) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._astDeclMap[ast.syntaxID()] = decl; - }; - - Document.prototype._getASTForDecl = function (decl) { - return this._declASTMap[decl.declID]; - }; - - Document.prototype._setASTForDecl = function (decl, ast) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._declASTMap[decl.declID] = ast; - }; - return Document; - })(); - TypeScript.Document = Document; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var proto = "__proto__"; - - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - - this[proto] = null; - this[proto] = undefined; - } - return BlockIntrinsics; - })(); - - function createIntrinsicsObject() { - return new BlockIntrinsics(); - } - TypeScript.createIntrinsicsObject = createIntrinsicsObject; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = createIntrinsicsObject(); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (!fn(k, this.table[k], context)) { - return false; - } - } - } - - return true; - }; - - StringHashTable.prototype.some = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (fn(k, this.table[k], context)) { - return true; - } - } - } - - return false; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - - StringHashTable.prototype.remove = function (key) { - if (this.table[key] !== undefined) { - this.table[key] = undefined; - this.itemCount--; - } - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(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 moduleIsElided(declaration) { - return TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) || moduleMembersAreElided(declaration.moduleElements); - } - TypeScript.moduleIsElided = moduleIsElided; - - 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)) { - 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; - } - } - - return importSymbol.isUsedAsValue(); - } - - return false; - } - TypeScript.importDeclarationIsElided = importDeclarationIsElided; - - function isValidAstNode(ast) { - if (!ast) - return false; - - if (ast.start() === -1 || ast.end() === -1) - return false; - - 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; - - 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(); - - 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); - } - } - }; - - TypeScript.getAstWalkerFactory().walk(script, pre); - return top; - } - TypeScript.getAstAtPosition = getAstAtPosition; - - function getExtendsHeritageClause(clauses) { - if (!clauses) { - return null; - } - - return clauses.firstOrDefault(function (c) { - return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 230 /* ExtendsHeritageClause */; - }); - } - TypeScript.getExtendsHeritageClause = getExtendsHeritageClause; - - function getImplementsHeritageClause(clauses) { - if (!clauses) { - return null; - } - - 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; - - 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; - } - } - - return false; - } - TypeScript.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { - return false; - } - if (ast.kind() !== 11 /* IdentifierName */) { - return false; - } - - 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) { - return { - length: 1, - lastParameterIsRest: function () { - return false; - }, - ast: id, - astAt: function (index) { - return id; - }, - identifierAt: function (index) { - return id; - }, - typeAt: function (index) { - return null; - }, - initializerAt: function (index) { - return null; - }, - isOptionalAt: function (index) { - return false; - } - }; - } - Parameters.fromIdentifier = fromIdentifier; - - function fromParameter(parameter) { - return { - length: 1, - lastParameterIsRest: function () { - return parameter.dotDotDotToken !== null; - }, - ast: parameter, - astAt: function (index) { - return parameter; - }, - identifierAt: function (index) { - return parameter.identifier; - }, - typeAt: function (index) { - return TypeScript.getType(parameter); - }, - initializerAt: function (index) { - return parameter.equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(parameter); - } - }; - } - Parameters.fromParameter = fromParameter; - - function parameterIsOptional(parameter) { - return parameter.questionToken !== null || parameter.equalsValueClause !== null; - } - - function fromParameterList(list) { - return { - length: list.parameters.nonSeparatorCount(), - lastParameterIsRest: function () { - return TypeScript.lastParameterIsRest(list); - }, - ast: list.parameters, - astAt: function (index) { - return list.parameters.nonSeparatorAt(index); - }, - identifierAt: function (index) { - return list.parameters.nonSeparatorAt(index).identifier; - }, - typeAt: function (index) { - return TypeScript.getType(list.parameters.nonSeparatorAt(index)); - }, - initializerAt: function (index) { - return list.parameters.nonSeparatorAt(index).equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(list.parameters.nonSeparatorAt(index)); - } - }; - } - Parameters.fromParameterList = fromParameterList; - })(TypeScript.Parameters || (TypeScript.Parameters = {})); - var Parameters = TypeScript.Parameters; - - 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; - } - } - TypeScript.isDeclarationAST = isDeclarationAST; - - 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; - } - - break; - } - - 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; - } - - 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); - - return nameIndex === (moduleNames.length - 1); - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function walkListChildren(preAst, walker) { - for (var i = 0, n = preAst.childCount(); i < n; i++) { - walker.walk(preAst.childAt(i)); - } - } - - function walkThrowStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkPrefixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkPostfixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkDeleteExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkTypeArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArguments); - } - - function walkTypeOfExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkVoidExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArgumentList); - walker.walk(preAst.arguments); - } - - function walkArrayLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.expressions); - } - - function walkSimplePropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.expression); - } - - function walkFunctionPropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkGetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkSeparatedListChildren(preAst, walker) { - for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { - walker.walk(preAst.nonSeparatorAt(i)); - } - } - - function walkSetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkObjectLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.propertyAssignments); - } - - function walkCastExpressionChildren(preAst, walker) { - walker.walk(preAst.type); - walker.walk(preAst.expression); - } - - function walkParenthesizedExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkElementAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentExpression); - } - - function walkMemberAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.name); - } - - function walkQualifiedNameChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkBinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkEqualsValueClauseChildren(preAst, walker) { - walker.walk(preAst.value); - } - - function walkTypeParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.constraint); - } - - function walkTypeParameterListChildren(preAst, walker) { - walker.walk(preAst.typeParameters); - } - - function walkGenericTypeChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.typeArgumentList); - } - - function walkTypeAnnotationChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkTypeQueryChildren(preAst, walker) { - walker.walk(preAst.name); - } - - function walkInvocationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkObjectCreationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkTrinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.whenTrue); - walker.walk(preAst.whenFalse); - } - - function walkFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFunctionTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkMemberFunctionDeclarationChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFuncDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkIndexMemberDeclarationChildren(preAst, walker) { - walker.walk(preAst.indexSignature); - } - - function walkIndexSignatureChildren(preAst, walker) { - walker.walk(preAst.parameter); - walker.walk(preAst.typeAnnotation); - } - - function walkCallSignatureChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - } - - function walkConstraintChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkConstructorTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkConstructSignatureChildren(preAst, walker) { - walker.walk(preAst.callSignature); - } - - function walkParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkParameterListChildren(preAst, walker) { - walker.walk(preAst.parameters); - } - - function walkPropertySignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - } - - function walkVariableDeclaratorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkMemberVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarator); - } - - function walkMethodSignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - } - - function walkReturnStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkForStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.initializer); - walker.walk(preAst.condition); - walker.walk(preAst.incrementor); - walker.walk(preAst.statement); - } - - function walkForInStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.left); - walker.walk(preAst.expression); - walker.walk(preAst.statement); - } - - function walkIfStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - walker.walk(preAst.elseClause); - } - - function walkElseClauseChildren(preAst, walker) { - walker.walk(preAst.statement); - } - - function walkWhileStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkDoStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkBlockChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.declarators); - } - - function walkCaseSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.statements); - } - - function walkDefaultSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkSwitchStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.switchClauses); - } - - function walkTryStatementChildren(preAst, walker) { - walker.walk(preAst.block); - walker.walk(preAst.catchClause); - walker.walk(preAst.finallyClause); - } - - function walkCatchClauseChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkExternalModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.stringLiteral); - } - - function walkFinallyClauseChildren(preAst, walker) { - walker.walk(preAst.block); - } - - function walkClassDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.classElements); - } - - function walkScriptChildren(preAst, walker) { - walker.walk(preAst.moduleElements); - } - - function walkHeritageClauseChildren(preAst, walker) { - walker.walk(preAst.typeNames); - } - - function walkInterfaceDeclerationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.body); - } - - function walkObjectTypeChildren(preAst, walker) { - walker.walk(preAst.typeMembers); - } - - function walkArrayTypeChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkModuleDeclarationChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.stringLiteral); - walker.walk(preAst.moduleElements); - } - - function walkModuleNameModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.moduleName); - } - - function walkEnumDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.enumElements); - } - - function walkEnumElementChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.equalsValueClause); - } - - function walkImportDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.moduleReference); - } - - function walkExportAssignmentChildren(preAst, walker) { - walker.walk(preAst.identifier); - } - - function walkWithStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkExpressionStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkLabeledStatementChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.statement); - } - - function walkVariableStatementChildren(preAst, walker) { - walker.walk(preAst.declaration); - } - - var childrenWalkers = new Array(246 /* Last */ + 1); - - for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { - childrenWalkers[i] = null; - } - for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { - childrenWalkers[i] = null; - } - - childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; - childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[60 /* AnyKeyword */] = null; - childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; - childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; - childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; - childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; - childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; - childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[146 /* Block */] = walkBlockChildren; - childrenWalkers[61 /* BooleanKeyword */] = null; - childrenWalkers[152 /* BreakStatement */] = null; - childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; - childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; - childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; - childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; - childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; - childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; - childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; - childrenWalkers[239 /* Constraint */] = walkConstraintChildren; - childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; - childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; - childrenWalkers[153 /* ContinueStatement */] = null; - childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; - childrenWalkers[162 /* DebuggerStatement */] = null; - childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; - childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; - childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; - childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; - childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; - childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; - childrenWalkers[156 /* EmptyStatement */] = null; - childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; - childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; - childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; - childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; - childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; - childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; - childrenWalkers[24 /* FalseKeyword */] = null; - childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; - childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; - childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; - childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; - childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; - childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; - childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; - childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; - childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; - childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; - childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; - childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; - childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; - childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; - childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; - childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; - childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; - childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; - childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[1 /* List */] = walkListChildren; - childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; - childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; - childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; - childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; - childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; - childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; - childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; - childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; - childrenWalkers[11 /* IdentifierName */] = null; - childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[0 /* None */] = null; - childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[32 /* NullKeyword */] = null; - childrenWalkers[67 /* NumberKeyword */] = null; - childrenWalkers[13 /* NumericLiteral */] = null; - childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; - childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; - childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; - childrenWalkers[223 /* OmittedExpression */] = null; - childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[242 /* Parameter */] = walkParameterChildren; - childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; - childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; - childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; - childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; - childrenWalkers[12 /* RegularExpressionLiteral */] = null; - childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; - childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; - childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; - childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; - childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; - childrenWalkers[14 /* StringLiteral */] = null; - childrenWalkers[69 /* StringKeyword */] = null; - childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; - childrenWalkers[50 /* SuperKeyword */] = null; - childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; - childrenWalkers[35 /* ThisKeyword */] = null; - childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; - childrenWalkers[3 /* TriviaList */] = null; - childrenWalkers[37 /* TrueKeyword */] = null; - childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; - childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; - childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; - childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; - childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; - childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; - childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; - childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; - childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; - childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; - childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; - childrenWalkers[41 /* VoidKeyword */] = null; - childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; - childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; - - for (var e in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { - TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); - } - } - - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - this.stopWalking = false; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var SimplePreAstWalker = (function () { - function SimplePreAstWalker(pre, state) { - this.pre = pre; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePreAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - }; - return SimplePreAstWalker; - })(); - - var SimplePrePostAstWalker = (function () { - function SimplePrePostAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePrePostAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - - this.post(ast, this.state); - }; - return SimplePrePostAstWalker; - })(); - - var NormalAstWalker = (function () { - function NormalAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - NormalAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - if (this.options.stopWalking) { - return; - } - - this.pre(ast, this); - - if (this.options.stopWalking) { - return; - } - - if (this.options.goChildren) { - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - } else { - this.options.goChildren = true; - } - - if (this.post) { - this.post(ast, this); - } - }; - return NormalAstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { - new NormalAstWalker(pre, post, state).walk(ast); - }; - - AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { - if (post) { - new SimplePrePostAstWalker(pre, post, state).walk(ast); - } else { - new SimplePreAstWalker(pre, state).walk(ast); - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory = new AstWalkerFactory(); - - function getAstWalkerFactory() { - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapEntry = (function () { - function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { - this.emittedFile = emittedFile; - this.emittedLine = emittedLine; - this.emittedColumn = emittedColumn; - this.sourceFile = sourceFile; - this.sourceLine = sourceLine; - this.sourceColumn = sourceColumn; - this.sourceName = sourceName; - TypeScript.Debug.assert(isFinite(emittedLine)); - TypeScript.Debug.assert(isFinite(emittedColumn)); - TypeScript.Debug.assert(isFinite(sourceColumn)); - TypeScript.Debug.assert(isFinite(sourceLine)); - } - return SourceMapEntry; - })(); - TypeScript.SourceMapEntry = SourceMapEntry; - - var SourceMapper = (function () { - function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.names = []; - this.mappingLevel = []; - this.tsFilePaths = []; - this.allSourceMappings = []; - this.sourceMapEntries = []; - this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); - this.setNewSourceFile(document, emitOptions); - } - SourceMapper.prototype.getOutputFile = function () { - var result = this.sourceMapOut.getOutputFile(); - result.sourceMapEntries = this.sourceMapEntries; - - return result; - }; - - SourceMapper.prototype.increaseMappingLevel = function (ast) { - this.mappingLevel.push(ast); - }; - - SourceMapper.prototype.decreaseMappingLevel = function (ast) { - TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); - var expectedAst = this.mappingLevel.pop(); - var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; - var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; - TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); - }; - - SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { - var sourceMappings = []; - this.allSourceMappings.push(sourceMappings); - this.currentMappings = [sourceMappings]; - this.currentNameIndex = []; - - this.setNewSourceFilePath(document, emitOptions); - }; - - SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { - var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); - var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; - this.jsFileName = prettyJsFileName; - - if (emitOptions.sourceMapRootDirectory()) { - this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); - if (document.emitToOwnOutputFile()) { - this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); - } - - if (TypeScript.isRelative(this.sourceMapDirectory)) { - this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; - this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); - this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); - } else { - this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; - } - } else { - this.sourceMapPath = prettyMapFileName; - this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); - } - this.sourceRoot = emitOptions.sourceRootDirectory(); - }; - - SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { - var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); - if (emitOptions.sourceRootDirectory()) { - tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); - } else { - tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); - } - this.tsFilePaths.push(tsFilePath); - }; - - SourceMapper.prototype.emitSourceMapping = function () { - var _this = this; - TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { - return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); - }).join(', ')); - - this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); - - var mappingsString = ""; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); - prevSourceIndex = sourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); - prevNameIndex = nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - for (var i = 0; i < sourceMappings.length; i++) { - var sourceMapping = sourceMappings[i]; - recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); - recordSourceMappingSiblings(sourceMapping.childMappings); - recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); - } - }; - - recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); - } - - this.sourceMapOut.Write(JSON.stringify({ - version: 3, - file: this.jsFileName, - sourceRoot: this.sourceRoot, - sources: this.tsFilePaths, - names: this.names, - mappings: mappingsString - })); - - this.sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compiler, resolvePath) { - this.resolvePath = resolvePath; - this._diagnostic = null; - this._settings = null; - this._commonDirectoryPath = ""; - this._sharedOutputFile = ""; - this._sourceRootDirectory = ""; - this._sourceMapRootDirectory = ""; - this._outputDirectory = ""; - 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.mapSourceFiles()) { - if (settings.mapRoot()) { - if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } else { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } else if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } - - this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); - this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); - - if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { - if (settings.outFileOption()) { - this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); - } - - if (settings.outDirOption()) { - this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); - } - - if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { - this.determineCommonDirectoryPath(compiler); - } - } - } - EmitOptions.prototype.diagnostic = function () { - return this._diagnostic; - }; - - EmitOptions.prototype.commonDirectoryPath = function () { - return this._commonDirectoryPath; - }; - EmitOptions.prototype.sharedOutputFile = function () { - return this._sharedOutputFile; - }; - EmitOptions.prototype.sourceRootDirectory = function () { - return this._sourceRootDirectory; - }; - EmitOptions.prototype.sourceMapRootDirectory = function () { - return this._sourceMapRootDirectory; - }; - EmitOptions.prototype.outputDirectory = function () { - return this._outputDirectory; - }; - - EmitOptions.prototype.compilationSettings = function () { - return this._settings; - }; - - EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = compiler.fileNames(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = compiler.getDocument(fileNames[i]); - var sourceUnit = document.sourceUnit(); - - if (!document.isDeclareFile()) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - if (this._outputDirectory || this._sourceRootDirectory || (this._sourceMapRootDirectory && (!this._sharedOutputFile || compiler._isDynamicModuleCompilation()))) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_find_the_common_subdirectory_path_for_the_input_files, null); - return; - } - - return; - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - function lastParameterIsRest(parameterList) { - var parameters = parameterList.parameters; - return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; - } - TypeScript.lastParameterIsRest = lastParameterIsRest; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.inArrowFunction = false; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.declStack = []; - this.exportAssignmentIdentifier = null; - this.inWithBlock = false; - this.document = null; - this.copyrightElement = null; - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setExportAssignmentIdentifier = function (id) { - this.exportAssignmentIdentifier = id; - }; - - Emitter.prototype.getExportAssignmentIdentifier = function () { - return this.exportAssignmentIdentifier; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.shouldEmitImportDeclaration = function (importDeclAST) { - return TypeScript.importDeclarationIsElided(importDeclAST, this.semanticInfoChain, this.emitOptions.compilationSettings()); - }; - - 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 */; - - this.emitComments(importDeclAST, true); - - var importSymbol = importDecl.getSymbol(); - - var parentSymbol = importSymbol.getContainer(); - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; - - var needsPropertyAssignment = false; - var usePropertyAssignmentInsteadOfVarDecl = false; - var moduleNamePrefix; - - 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 */)) { - needsPropertyAssignment = true; - } else { - usePropertyAssignmentInsteadOfVarDecl = true; - } - } - - if (this.emitState.container === 2 /* DynamicModule */) { - moduleNamePrefix = "exports."; - } else { - moduleNamePrefix = this.moduleName + "."; - } - } - - if (isAmdCodeGen && isExternalModuleReference) { - needsPropertyAssignment = true; - } else { - this.recordSourceMappingStart(importDeclAST); - if (usePropertyAssignmentInsteadOfVarDecl) { - this.writeToOutput(moduleNamePrefix); - } else { - this.writeToOutput("var "); - } - this.writeToOutput(importDeclAST.identifier.text() + " = "); - var aliasAST = importDeclAST.moduleReference; - - if (isExternalModuleReference) { - this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); - } else { - this.emitJavascript(aliasAST.moduleName, false); - } - - this.recordSourceMappingEnd(importDeclAST); - this.writeToOutput(";"); - - if (needsPropertyAssignment) { - this.writeLineToOutput(""); - this.emitIndent(); - } - } - - if (needsPropertyAssignment) { - this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); - this.writeToOutput(";"); - } - this.emitComments(importDeclAST, false); - }; - - Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { - this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); - }; - - Emitter.prototype.setSourceMapperNewSourceFile = function (document) { - this.sourceMapper.setNewSourceFile(document, this.emitOptions); - }; - - Emitter.prototype.updateLineAndColumn = function (s) { - var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); - if (lineNumbers.length > 1) { - this.emitState.line += lineNumbers.length - 1; - this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; - } else { - this.emitState.column += s.length; - } - }; - - Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { - this.recordSourceMappingStart(astSpan); - this.writeToOutput(s); - this.recordSourceMappingEnd(astSpan); - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - this.updateLineAndColumn(s); - }; - - Emitter.prototype.writeLineToOutput = function (s, force) { - if (typeof force === "undefined") { force = false; } - if (!force && s === "" && this.emitState.column === 0) { - return; - } - - this.outfile.WriteLine(s); - this.updateLineAndColumn(s); - this.emitState.column = 0; - this.emitState.line++; - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - return this.indenter.getIndent(); - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitComment = function (comment, trailing, first) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var text = getTrimmedTextLines(comment); - var emitColumn = this.emitState.column; - - if (emitColumn === 0) { - this.emitIndent(); - } else if (trailing && first) { - this.writeToOutput(" "); - } - - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingEnd(comment); - this.writeToOutput(" "); - return; - } - } else { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } - - if (!trailing && emitColumn != 0) { - this.emitIndent(); - } - }; - - Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - if (typeof onlyPinnedOrTripleSlashComments === "undefined") { onlyPinnedOrTripleSlashComments = false; } - var _this = this; - if (ast && ast.kind() !== 146 /* Block */) { - if (ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ || ast.parent.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - return; - } - } - - if (pre) { - var preComments = ast.preComments(); - - if (preComments && ast === this.copyrightElement) { - var copyrightComments = this.getCopyrightComments(); - preComments = preComments.slice(copyrightComments.length); - } - - if (onlyPinnedOrTripleSlashComments) { - preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { - return _this.isPinnedOrTripleSlash(c); - }); - } - - this.emitCommentsArray(preComments, false); - } else { - this.emitCommentsArray(ast.postComments(), true); - } - }; - - Emitter.prototype.isPinnedOrTripleSlash = function (comment) { - var fullText = comment.fullText(); - if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { - return true; - } else { - return fullText.indexOf("/*!") === 0; - } - }; - - Emitter.prototype.emitCommentsArray = function (comments, trailing) { - if (!this.emitOptions.compilationSettings().removeComments() && comments) { - for (var i = 0, n = comments.length; i < n; i++) { - this.emitComment(comments[i], trailing, i === 0); - } - } - }; - - Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { - this.recordSourceMappingStart(objectLiteral); - - this.writeToOutput("{"); - this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); - this.writeToOutput("}"); - - this.recordSourceMappingEnd(objectLiteral); - }; - - Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { - this.recordSourceMappingStart(arrayLiteral); - - this.writeToOutput("["); - this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); - this.writeToOutput("]"); - - this.recordSourceMappingEnd(arrayLiteral); - }; - - Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { - this.recordSourceMappingStart(objectCreationExpression); - this.writeToOutput("new "); - var target = objectCreationExpression.expression; - - this.emit(target); - if (objectCreationExpression.argumentList) { - this.recordSourceMappingStart(objectCreationExpression.argumentList); - this.writeToOutput("("); - this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); - this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); - this.recordSourceMappingEnd(objectCreationExpression.argumentList); - } - - this.recordSourceMappingEnd(objectCreationExpression); - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); - if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - if (pullDecl.kind === 67108864 /* EnumMember */) { - return pullDecl; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - var propertyName = dotExpr.name; - var boundDecl = this.getConstantDecl(dotExpr); - if (boundDecl) { - var value = boundDecl.constantValue; - if (value !== null) { - this.recordSourceMappingStart(dotExpr); - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.text(); - comment += " */"; - this.writeToOutput(comment); - this.recordSourceMappingEnd(dotExpr); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitInvocationExpression = function (callNode) { - this.recordSourceMappingStart(callNode); - var target = callNode.expression; - var args = callNode.argumentList.arguments; - - if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { - this.emit(target); - this.writeToOutput(".call"); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitThis(); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - } else { - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - - this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); - this.recordSourceMappingEnd(args); - this.recordSourceMappingEnd(callNode); - }; - - Emitter.prototype.emitParameterList = function (list) { - this.writeToOutput("("); - this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.Parameters.fromParameterList(list)); - this.writeToOutput(")"); - }; - - Emitter.prototype.emitFunctionParameters = function (parameters) { - var argsLen = 0; - - if (parameters) { - this.emitComments(parameters.ast, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = parameters.length; - var printLen = argsLen; - if (parameters.lastParameterIsRest()) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = parameters.astAt(i); - this.emit(arg); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(parameters.ast, false); - } - }; - - Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { - this.writeLineToOutput(" {"); - if (name) { - this.recordSourceMappingNameStart(name); - } - - this.indenter.increaseIndent(); - - if (parameterList) { - this.emitDefaultValueAssignments(parameterList); - this.emitRestParameterInitializer(parameterList); - } - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - if (block) { - this.emitList(block.statements); - this.emitCommentsArray(block.closeBraceLeadingComments, false); - } else { - this.emitIndent(); - this.emitCommentsArray(bodyExpression.preComments(), false); - this.writeToOutput("return "); - this.emit(bodyExpression); - this.writeLineToOutput(";"); - this.emitCommentsArray(bodyExpression.postComments(), true); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - - if (block) { - this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); - } else { - this.writeToOutputWithSourceMapRecord("}", bodyExpression); - } - - if (name) { - this.recordSourceMappingNameEnd(); - } - }; - - Emitter.prototype.emitDefaultValueAssignments = function (parameters) { - var n = parameters.length; - if (parameters.lastParameterIsRest()) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = parameters.astAt(i); - var id = parameters.identifierAt(i); - var equalsValueClause = parameters.initializerAt(i); - if (equalsValueClause) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.emitJavascript(equalsValueClause, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (parameters) { - if (parameters.lastParameterIsRest()) { - var n = parameters.length; - var lastArg = parameters.astAt(n - 1); - var id = parameters.identifierAt(n - 1); - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); - this.writeToOutput(" "); - this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); - this.writeToOutput("; "); - this.writeToOutputWithSourceMapRecord("_i++", lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - var result = []; - - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - var queue = dynamicModuleDecl.getChildDecls(); - - for (var i = 0, n = queue.length; i < n; i++) { - var decl = queue[i]; - - if (decl.kind & 128 /* TypeAlias */) { - var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.type; - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { - var importList = ""; - var dependencyList = ""; - - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.isUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += importStatementDecl.name; - dependencyList += importStatementAST.moduleReference.stringLiteral.text(); - } - } - } - - var amdDependencies = this.document.amdDependencies(); - for (var i = 0; i < amdDependencies.length; i++) { - dependencyList += ", \"" + amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); - } - - var decl = this.semanticInfoChain.getDeclForAST(ast); - if (decl) { - return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); - } - - return false; - }; - - Emitter.prototype.emitEnum = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - this.moduleName = moduleDecl.identifier.text(); - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.identifier); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(this.moduleName); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitSeparatedList(moduleDecl.enumElements); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { - return moduleDecl; - } else if (changeNameIfAnyDeclarationInContext) { - var symbol = moduleDecl.getSymbol(); - if (symbol) { - var otherDecls = symbol.getDeclarations(); - for (var i = 0; i < otherDecls.length; i++) { - if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { - return otherDecls[i]; - } - } - } - } - - return null; - }; - - Emitter.prototype.hasChildNameCollision = function (moduleName, childDecls) { - var _this = this; - return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - if (childDecl.name == moduleName) { - var childAST = _this.semanticInfoChain.getASTForDecl(childDecl); - if (_this.shouldEmit(childAST)) { - return true; - } - } - return false; - }); - }; - - Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - var moduleName = moduleDecl.name; - var moduleDisplayName = moduleDecl.getDisplayName(); - - moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl) { - var childDecls = moduleDecl.getChildDecls(); - - while (this.hasChildNameCollision(moduleName, childDecls)) { - moduleName = "_" + moduleName; - moduleDisplayName = "_" + moduleDisplayName; - } - } - - return moduleDisplayName; - }; - - Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { - if (moduleDecl.stringLiteral) { - this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); - } - }; - - Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.isLastNameOfModule(moduleDecl, moduleName); - - if (isLastName) { - this.emitComments(moduleDecl, true); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - - if (moduleDecl.stringLiteral) { - this.moduleName = moduleDecl.stringLiteral.valueText(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - } else { - this.moduleName = moduleName.text(); - } - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleName); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleName); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - - this.moduleName = this.getModuleName(pullDecl); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(moduleName.text()); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - if (moduleName === moduleDecl.stringLiteral) { - this.emitList(moduleDecl.moduleElements); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - var nameIndex = moduleNames.indexOf(moduleName); - TypeScript.Debug.assert(nameIndex >= 0); - - if (isLastName) { - this.emitList(moduleDecl.moduleElements); - } else { - this.emitIndent(); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); - this.writeLineToOutput(""); - } - } - - this.moduleName = moduleName.text(); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - - if (isLastName) { - this.emitComments(moduleDecl, false); - } - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - var name = varDecl.propertyName.text(); - var quoted = TypeScript.isQuoted(name); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.writeToOutput(']'); - - if (varDecl.equalsValueClause) { - this.emit(varDecl.equalsValueClause); - } else if (pullDecl.constantValue !== null) { - this.writeToOutput(' = '); - this.writeToOutput(pullDecl.constantValue.toString()); - } else { - this.writeToOutput(' = null'); - } - - this.writeToOutput('] = '); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - this.writeToOutput(';'); - }; - - Emitter.prototype.emitElementAccessExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("["); - this.emit(expression.argumentExpression); - this.writeToOutput("]"); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.Parameters.fromIdentifier(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); - }; - - Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = true; - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(arrowFunction); - - var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); - this.pushDecl(pullDecl); - - this.emitComments(arrowFunction, true); - - this.recordSourceMappingStart(arrowFunction); - this.writeToOutput("function "); - this.writeToOutput("("); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); - - this.recordSourceMappingEnd(arrowFunction); - - this.recordSourceMappingEnd(arrowFunction); - - this.emitComments(arrowFunction, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConstructor = function (funcDecl) { - if (!funcDecl.block) { - return; - } - var temp = this.setContainer(4 /* Constructor */); - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - this.writeToOutput(this.thisClassNode.identifier.text()); - this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.parameterList); - this.emitFunctionParameters(parameters); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart("constructor"); - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(parameters); - this.emitRestParameterInitializer(parameters); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - this.emitConstructorStatements(funcDecl); - this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - }; - - Emitter.prototype.emitGetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("get "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, TypeScript.Parameters.fromParameterList(accessor.parameterList), accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitSetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("set "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(accessor.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitFunctionExpression = function (funcDecl) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - this.writeToOutput(funcDecl.identifier.text()); - this.recordSourceMappingEnd(funcDecl.identifier); - } - - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (funcDecl.block === null) { - return; - } - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier.text(); - - this.recordSourceMappingStart(funcDecl); - - var printName = funcDecl.identifier !== null; - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (printName) { - var id = funcDecl.identifier.text(); - if (id) { - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - } - this.writeToOutput(id); - if (funcDecl.identifier) { - this.recordSourceMappingEnd(funcDecl.identifier); - } - } - } - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - if (funcDecl.block) { - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - this.recordSourceMappingStart(this.currentVariableDeclaration); - if (varDecl.equalsValueClause) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - this.emitJavascript(varDecl.equalsValueClause, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.currentVariableDeclaration) { - this.writeToOutput("var "); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.nonSeparatorAt(0); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - - this.emitComments(declaration, true); - - var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); - var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; - if (!isAmbientWithoutInit) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.currentVariableDeclaration = declaration; - - for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { - var declarator = declaration.declarators.nonSeparatorAt(i); - - if (i > 0) { - this.writeToOutput(", "); - } - - this.emit(declarator); - } - this.currentVariableDeclaration = prevVariableDeclaration; - - this.recordSourceMappingEnd(declaration); - } - - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { - TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); - - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - - if (quotedOrNumber) { - this.writeToOutput("this["); - } else { - this.writeToOutput("this."); - } - - this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); - - if (quotedOrNumber) { - this.writeToOutput("]"); - } - - if (varDecl.variableDeclarator.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.variableDeclarator.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(this.currentVariableDeclaration); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.propertyName.text(); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); - - if (parentIsModule) { - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - - if (varDecl.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.currentVariableDeclaration = undefined; - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { - var decl = pullSymbol.getDeclarations()[0]; - var parentDecl = decl.getParentDecl(); - var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; - - var enclosingContextDeclPath = this.declStack; - var commonNodeIndex = -1; - - if (enclosingContextDeclPath.length) { - for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { - var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; - for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { - var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; - if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { - commonNodeIndex = i; - break; - } - } - - if (commonNodeIndex >= 0) { - break; - } - } - } - - var startingIndex = symbolContainerDeclPath.length - 1; - for (var i = startingIndex - 1; i > commonNodeIndex; i--) { - if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { - startingIndex = i; - } else { - break; - } - } - return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; - }; - - Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { - for (var i = startingIndex; i <= lastIndex; i++) { - if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.getModuleName(declPath[i], true) + "."); - } - } - }; - - Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { - var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); - var potentialDeclPath = declPathInfo.potentialPath; - var startingIndex = declPathInfo.startingIndex; - - this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); - }; - - Emitter.prototype.getSymbolForEmit = function (ast) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); - var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); - if (pullSymbol && pullSymbolAlias) { - var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - - if (pullSymbol == symbolToCompare) { - pullSymbol = pullSymbolAlias; - pullSymbolAlias = null; - } - } - return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (name.text().length > 0) { - var symbolForEmit = this.getSymbolForEmit(name); - var pullSymbol = symbolForEmit.symbol; - if (!pullSymbol) { - pullSymbol = this.semanticInfoChain.anyTypeSymbol; - } - var pullSymbolAlias = symbolForEmit.aliasSymbol; - var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.kind; - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } - } - } - - this.writeToOutput(name.text()); - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var nameIndex = -1; - if (name) { - if (this.sourceMapper.currentNameIndex.length > 0) { - var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { - break; - } - } - - if (nameIndex == -1) { - nameIndex = this.sourceMapper.names.length; - this.sourceMapper.names.push(name); - } - } - this.sourceMapper.currentNameIndex.push(nameIndex); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - var lineCol = { line: -1, character: -1 }; - var sourceMapping = new TypeScript.SourceMapping(); - sourceMapping.start.emittedColumn = this.emitState.column; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap(); - lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); - - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - this.sourceMapper.increaseMappingLevel(ast); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); - - this.sourceMapper.decreaseMappingLevel(ast); - } - }; - - Emitter.prototype.getOutputFiles = function () { - var result = []; - if (this.sourceMapper !== null) { - this.sourceMapper.emitSourceMapping(); - result.push(this.sourceMapper.getOutputFile()); - } - - result.push(this.outfile.getOutputFile()); - return result; - }; - - 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); - var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); - if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { - this.emitIndent(); - this.recordSourceMappingStart(parameter); - this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); - this.writeToOutput(" = "); - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(parameter); - } - } - } - - for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { - if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = this.thisClassNode.classElements.childAt(i); - if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitIndent(); - this.emitMemberVariableDeclaration(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.isOnSameLine = function (pos1, pos2) { - var lineMap = this.document.lineMap(); - return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); - }; - - Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { - if (list === null || list.nonSeparatorCount() === 0) { - return; - } - - var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); - - if (preserveNewLines) { - this.indenter.increaseIndent(); - } - - if (startLine) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(buffer); - } - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - var emitNode = list.nonSeparatorAt(i); - - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); - if (startLine) { - this.writeLineToOutput(","); - } else { - this.writeToOutput(", "); - } - } - } - - if (preserveNewLines) { - this.indenter.decreaseIndent(); - } - - if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(buffer); - } - }; - - Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.nonSeparatorAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.kind() === 14 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { - return; - } - - var lineMap = this.document.lineMap(); - var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput("", true); - } - }; - - Emitter.prototype.getCopyrightComments = function () { - var preComments = this.copyrightElement.preComments(); - if (preComments) { - var lineMap = this.document.lineMap(); - - var copyrightComments = []; - var lastComment = null; - - for (var i = 0, n = preComments.length; i < n; i++) { - var comment = preComments[i]; - - if (lastComment) { - var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); - var commentLine = lineMap.getLineNumberFromPosition(comment.start()); - - if (commentLine >= lastCommentLine + 2) { - return copyrightComments; - } - } - - copyrightComments.push(comment); - lastComment = comment; - } - - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(copyrightComments).end()); - var astLine = lineMap.getLineNumberFromPosition(this.copyrightElement.start()); - if (astLine >= lastCommentLine + 2) { - return copyrightComments; - } - } - - return []; - }; - - Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - var list = script.moduleElements; - if (list.childCount() > 0) { - var firstElement = list.childAt(0); - - this.copyrightElement = firstElement; - this.emitCommentsArray(this.getCopyrightComments(), false); - } - }; - - Emitter.prototype.emitScriptElements = function (sourceUnit) { - var list = sourceUnit.moduleElements; - - this.emitPossibleCopyrightHeaders(sourceUnit); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var node = list.childAt(i); - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(sourceUnit); - - var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.scriptIsElided(sourceUnit); - if (isNonElidedExternalModule) { - this.recordSourceMappingStart(sourceUnit); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } - - if (isExternalModule) { - var temp = this.setContainer(2 /* DynamicModule */); - - var svModuleName = this.moduleName; - this.moduleName = sourceUnit.fileName(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - - this.setExportAssignmentIdentifier(null); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); - - if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { - this.writeCaptureThisStatement(sourceUnit); - } - - this.pushDecl(externalModule); - } - - this.emitList(list, true, i, n); - - if (isExternalModule) { - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - - if (isNonElidedExternalModule) { - var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); - var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.emitIndent(); - this.writeToOutput("module.exports = " + exportAssignmentIdentifier + ";"); - } - - this.recordSourceMappingEnd(sourceUnit); - this.writeLineToOutput(""); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - this.popDecl(externalModule); - } - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = TypeScript.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - this.emit(ast); - }; - - Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { - if (funcDecl.kind() !== 139 /* GetAccessor */) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - - this.writeToOutput("Object.defineProperty(" + className); - if (isProto) { - this.writeToOutput(".prototype, "); - } else { - this.writeToOutput(", "); - } - - var functionName = name.text(); - if (TypeScript.isQuoted(functionName)) { - this.writeToOutput(functionName); - } else { - this.writeToOutput('"' + functionName + '"'); - } - - this.writeLineToOutput(", {"); - - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.emitComments(accessors.getter, true); - this.writeToOutput("get: "); - this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.emitComments(accessors.setter, true); - this.writeToOutput("set: "); - this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.identifier.text(); - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses) !== null; - var baseTypeReference = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseTypeReference = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); - this.emitIndent(); - this.writeLineToOutput("__extends(" + className + ", _super);"); - } - - this.emitIndent(); - - var constrDecl = getLastConstructor(classDecl); - - if (constrDecl) { - this.emit(constrDecl); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeLineToOutput("_super.apply(this, arguments);"); - } - - if (this.shouldCaptureThis(classDecl)) { - this.writeCaptureThisStatement(classDecl); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.emitJavascript(baseTypeReference, false); - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 139 /* GetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var getter = memberDecl; - this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 140 /* SetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var setter = memberDecl; - this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { - var memberFunction = memberDecl; - - if (memberFunction.block) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - - this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); - lastEmittedMember = memberDecl; - } - } - } - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = memberDecl; - - if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); - } else { - this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); - } - - this.emit(varDecl.variableDeclarator.equalsValueClause); - - this.recordSourceMappingEnd(varDecl); - this.writeLineToOutput(";"); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - var functionName = funcDecl.propertyName.text(); - - this.writeToOutput(classDecl.identifier.text()); - - if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - this.writeToOutput(".prototype"); - } - - if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput("[" + functionName + "] = "); - } else { - this.writeToOutput("." + functionName + " = "); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - - this.writeLineToOutput(";"); - }; - - Emitter.prototype.requiresExtendsBlock = function (moduleElements) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - - if (moduleElement.kind() === 130 /* ModuleDeclaration */) { - var moduleAST = moduleElement; - - if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { - return true; - } - } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { - var classDeclaration = moduleElement; - - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitPrologue = function (sourceUnit) { - if (!this.extendsPrologueEmitted) { - if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(sourceUnit)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitThis = function () { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.kind() === 146 /* Block */) { - this.emit(node); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitLiteralExpression = function (expression) { - switch (expression.kind()) { - case 32 /* NullKeyword */: - this.writeToOutputWithSourceMapRecord("null", expression); - break; - case 24 /* FalseKeyword */: - this.writeToOutputWithSourceMapRecord("false", expression); - break; - case 37 /* TrueKeyword */: - this.writeToOutputWithSourceMapRecord("true", expression); - break; - default: - throw TypeScript.Errors.abstract(); - } - }; - - Emitter.prototype.emitThisExpression = function (expression) { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutputWithSourceMapRecord("_this", expression); - } else { - this.writeToOutputWithSourceMapRecord("this", expression); - } - }; - - Emitter.prototype.emitSuperExpression = function (expression) { - this.writeToOutputWithSourceMapRecord("_super.prototype", expression); - }; - - Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { - if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { - this.emit(parenthesizedExpression.expression); - } else { - this.recordSourceMappingStart(parenthesizedExpression); - this.writeToOutput("("); - this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); - this.emit(parenthesizedExpression.expression); - this.writeToOutput(")"); - this.recordSourceMappingEnd(parenthesizedExpression); - } - }; - - Emitter.prototype.emitCastExpression = function (expression) { - this.emit(expression.expression); - }; - - Emitter.prototype.emitPrefixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 167 /* LogicalNotExpression */: - this.writeToOutput("!"); - this.emit(expression.operand); - break; - case 166 /* BitwiseNotExpression */: - this.writeToOutput("~"); - this.emit(expression.operand); - break; - case 165 /* NegateExpression */: - this.writeToOutput("-"); - if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 164 /* PlusExpression */: - this.writeToOutput("+"); - if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 168 /* PreIncrementExpression */: - this.writeToOutput("++"); - this.emit(expression.operand); - break; - case 169 /* PreDecrementExpression */: - this.writeToOutput("--"); - this.emit(expression.operand); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitPostfixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 210 /* PostIncrementExpression */: - this.emit(expression.operand); - this.writeToOutput("++"); - break; - case 211 /* PostDecrementExpression */: - this.emit(expression.operand); - this.writeToOutput("--"); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitTypeOfExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("typeof "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDeleteExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("delete "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitVoidExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("void "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { - var memberExpressionNodeType = expression.expression.kind(); - - 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 */) { - return this.canEmitDottedNameMemberAccessExpression(expression.expression); - } - - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { - this.recordSourceMappingStart(expression); - if (expression.expression.kind() == 212 /* MemberAccessExpression */) { - this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); - } else { - this.emitComments(expression.expression, true); - this.recordSourceMappingStart(expression.expression); - - this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); - - this.writeToOutput(expression.expression.text()); - - this.recordSourceMappingEnd(expression.expression); - this.emitComments(expression.expression, false); - } - - this.writeToOutput("."); - this.emitName(expression.name, false); - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { - this.emitComments(expression, true); - - if (lastIndex - startingIndex < 1) { - startingIndex = lastIndex - 1; - TypeScript.Debug.assert(startingIndex >= 0); - } - - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); - this.emitComments(expression, false); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { - var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; - - var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); - }; - - Emitter.prototype.emitMemberAccessExpression = function (expression) { - if (!this.tryEmitConstant(expression)) { - if (this.canEmitDottedNameMemberAccessExpression(expression)) { - this.emitDottedNameMemberAccessExpression(expression); - } else { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("."); - this.emitName(expression.name, false); - this.recordSourceMappingEnd(expression); - } - } - }; - - Emitter.prototype.emitQualifiedName = function (name) { - this.recordSourceMappingStart(name); - - this.emit(name.left); - this.writeToOutput("."); - this.emitName(name.right, false); - - this.recordSourceMappingEnd(name); - }; - - Emitter.prototype.emitBinaryExpression = function (expression) { - this.recordSourceMappingStart(expression); - switch (expression.kind()) { - case 173 /* CommaExpression */: - this.emit(expression.left); - this.writeToOutput(", "); - this.emit(expression.right); - break; - default: { - this.emit(expression.left); - var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); - if (binOp === "instanceof") { - this.writeToOutput(" instanceof "); - } else if (binOp === "in") { - this.writeToOutput(" in "); - } else { - this.writeToOutput(" " + binOp + " "); - } - this.emit(expression.right); - } - } - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimplePropertyAssignment = function (property) { - this.recordSourceMappingStart(property); - this.emit(property.propertyName); - this.writeToOutput(": "); - this.emit(property.expression); - this.recordSourceMappingEnd(property); - }; - - Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { - this.recordSourceMappingStart(funcProp); - - this.emit(funcProp.propertyName); - this.writeToOutput(": "); - - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); - - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - var funcName = funcProp.propertyName; - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcProp); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(funcProp.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); - - this.recordSourceMappingEnd(funcProp); - - this.recordSourceMappingEnd(funcProp); - - this.emitComments(funcProp, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - this.recordSourceMappingEnd(funcProp); - }; - - Emitter.prototype.emitConditionalExpression = function (expression) { - this.emit(expression.condition); - this.writeToOutput(" ? "); - this.emit(expression.whenTrue); - this.writeToOutput(" : "); - this.emit(expression.whenFalse); - }; - - Emitter.prototype.emitThrowStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("throw "); - this.emit(statement.expression); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitExpressionStatement = function (statement) { - var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; - - this.recordSourceMappingStart(statement); - if (isArrowExpression) { - this.writeToOutput("("); - } - - this.emit(statement.expression); - - if (isArrowExpression) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitLabeledStatement = function (statement) { - this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); - this.writeLineToOutput(":"); - this.emitJavascript(statement.statement, true); - }; - - Emitter.prototype.emitBlock = function (block) { - this.recordSourceMappingStart(block); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - if (block.statements) { - this.emitList(block.statements); - } - this.emitCommentsArray(block.closeBraceLeadingComments, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(block); - }; - - Emitter.prototype.emitBreakStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("break"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitContinueStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("continue"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitWhileStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("while ("); - this.emit(statement.condition); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitDoStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("do"); - this.emitBlockOrStatement(statement.statement); - this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); - this.writeToOutput('('); - this.emit(statement.condition); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitIfStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("if ("); - this.emit(statement.condition); - this.writeToOutput(")"); - - this.emitBlockOrStatement(statement.statement); - - if (statement.elseClause) { - if (statement.statement.kind() !== 146 /* Block */) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - - this.emit(statement.elseClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitElseClause = function (elseClause) { - if (elseClause.statement.kind() === 147 /* IfStatement */) { - this.writeToOutput("else "); - this.emit(elseClause.statement); - } else { - this.writeToOutput("else"); - this.emitBlockOrStatement(elseClause.statement); - } - }; - - Emitter.prototype.emitReturnStatement = function (statement) { - this.recordSourceMappingStart(statement); - if (statement.expression) { - this.writeToOutput("return "); - this.emit(statement.expression); - } else { - this.writeToOutput("return"); - } - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitForInStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.left) { - this.emit(statement.left); - } else { - this.emit(statement.variableDeclaration); - } - this.writeToOutput(" in "); - this.emit(statement.expression); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitForStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.variableDeclaration) { - this.emit(statement.variableDeclaration); - } else if (statement.initializer) { - this.emit(statement.initializer); - } - - this.writeToOutput("; "); - this.emitJavascript(statement.condition, false); - this.writeToOutput(";"); - if (statement.incrementor) { - this.writeToOutput(" "); - this.emitJavascript(statement.incrementor, false); - } - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitWithStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("with ("); - if (statement.condition) { - this.emit(statement.condition); - } - - this.writeToOutput(")"); - var prevInWithBlock = this.inWithBlock; - this.inWithBlock = true; - this.emitBlockOrStatement(statement.statement); - this.inWithBlock = prevInWithBlock; - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitSwitchStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("switch ("); - this.emit(statement.expression); - this.recordSourceMappingStart(statement.closeParenToken); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement.closeParenToken); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - this.emitList(statement.switchClauses, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCaseSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("case "); - this.emit(clause.expression); - this.writeToOutput(":"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitSwitchClauseBody = function (body) { - if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { - this.emit(body.childAt(0)); - this.writeLineToOutput(""); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emit(body); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitDefaultSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("default:"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitTryStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("try "); - this.emit(statement.block); - this.emitJavascript(statement.catchClause, false); - - if (statement.finallyClause) { - this.emit(statement.finallyClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCatchClause = function (clause) { - this.writeToOutput(" "); - this.recordSourceMappingStart(clause); - this.writeToOutput("catch ("); - this.emit(clause.identifier); - this.writeToOutput(")"); - this.emit(clause.block); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitFinallyClause = function (clause) { - this.writeToOutput(" finally"); - this.emit(clause.block); - }; - - Emitter.prototype.emitDebuggerStatement = function (statement) { - this.writeToOutputWithSourceMapRecord("debugger", statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitNumericLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitRegularExpressionLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitStringLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitEqualsValueClause = function (clause) { - this.writeToOutput(" = "); - this.emit(clause.value); - }; - - Emitter.prototype.emitParameter = function (parameter) { - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); - }; - - Emitter.prototype.emitConstructorDeclaration = function (declaration) { - if (declaration.block) { - this.emitConstructor(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { - return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); - }; - - Emitter.prototype.emitFunctionDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { - this.emitFunction(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.emitSourceUnit = function (sourceUnit) { - if (!this.document.isDeclareFile()) { - var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); - this.pushDecl(pullDecl); - this.emitScriptElements(sourceUnit); - this.popDecl(pullDecl); - } - }; - - Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.enumIsElided(declaration); - }; - - Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.enumIsElided(declaration)) { - this.emitComments(declaration, true); - this.emitEnum(declaration); - this.emitComments(declaration, false); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.moduleIsElided(declaration); - }; - - Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.moduleIsElided(declaration)) { - this.emitModuleDeclarationWorker(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); - }; - - Emitter.prototype.emitClassDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { - this.emitClass(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { - return declaration.preComments() !== null; - }; - - Emitter.prototype.emitInterfaceDeclaration = function (declaration) { - this.emitComments(declaration, true, true); - }; - - Emitter.prototype.firstVariableDeclarator = function (statement) { - return statement.declaration.declarators.nonSeparatorAt(0); - }; - - Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { - return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; - }; - - Emitter.prototype.shouldEmitVariableStatement = function (statement) { - return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); - }; - - Emitter.prototype.emitVariableStatement = function (statement) { - if (this.isNotAmbientOrHasInitializer(statement)) { - this.emitComments(statement, true); - this.emit(statement.declaration); - this.writeToOutput(";"); - this.emitComments(statement, false); - } else { - this.emitComments(statement, true, true); - } - }; - - Emitter.prototype.emitGenericType = function (type) { - this.emit(type.name); - }; - - Emitter.prototype.shouldEmit = function (ast) { - if (!ast) { - return false; - } - - switch (ast.kind()) { - case 133 /* ImportDeclaration */: - return this.shouldEmitImportDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.shouldEmitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.shouldEmitInterfaceDeclaration(ast); - case 129 /* FunctionDeclaration */: - return this.shouldEmitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.shouldEmitModuleDeclaration(ast); - case 148 /* VariableStatement */: - return this.shouldEmitVariableStatement(ast); - case 223 /* OmittedExpression */: - return false; - case 132 /* EnumDeclaration */: - return this.shouldEmitEnumDeclaration(ast); - } - - return true; - }; - - Emitter.prototype.emit = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 2 /* SeparatedList */: - return this.emitSeparatedList(ast); - case 1 /* List */: - return this.emitList(ast); - case 120 /* SourceUnit */: - return this.emitSourceUnit(ast); - case 133 /* ImportDeclaration */: - return this.emitImportDeclaration(ast); - case 134 /* ExportAssignment */: - return this.setExportAssignmentIdentifier(ast.identifier.text()); - case 131 /* ClassDeclaration */: - return this.emitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitInterfaceDeclaration(ast); - case 11 /* IdentifierName */: - return this.emitName(ast, true); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast); - case 219 /* SimpleArrowFunctionExpression */: - return this.emitSimpleArrowFunctionExpression(ast); - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.emitParenthesizedArrowFunctionExpression(ast); - case 129 /* FunctionDeclaration */: - return this.emitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitModuleDeclaration(ast); - case 224 /* VariableDeclaration */: - return this.emitVariableDeclaration(ast); - case 126 /* GenericType */: - return this.emitGenericType(ast); - case 137 /* ConstructorDeclaration */: - return this.emitConstructorDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitEnumDeclaration(ast); - case 243 /* EnumElement */: - return this.emitEnumElement(ast); - case 222 /* FunctionExpression */: - return this.emitFunctionExpression(ast); - case 148 /* VariableStatement */: - return this.emitVariableStatement(ast); - } - - this.emitComments(ast, true); - this.emitWorker(ast); - this.emitComments(ast, false); - }; - - Emitter.prototype.emitWorker = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 13 /* NumericLiteral */: - return this.emitNumericLiteral(ast); - case 12 /* RegularExpressionLiteral */: - return this.emitRegularExpressionLiteral(ast); - case 14 /* StringLiteral */: - return this.emitStringLiteral(ast); - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 37 /* TrueKeyword */: - return this.emitLiteralExpression(ast); - case 35 /* ThisKeyword */: - return this.emitThisExpression(ast); - case 50 /* SuperKeyword */: - return this.emitSuperExpression(ast); - case 217 /* ParenthesizedExpression */: - return this.emitParenthesizedExpression(ast); - case 214 /* ArrayLiteralExpression */: - return this.emitArrayLiteralExpression(ast); - case 211 /* PostDecrementExpression */: - case 210 /* PostIncrementExpression */: - return this.emitPostfixUnaryExpression(ast); - case 167 /* LogicalNotExpression */: - case 166 /* BitwiseNotExpression */: - case 165 /* NegateExpression */: - case 164 /* PlusExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.emitPrefixUnaryExpression(ast); - case 213 /* InvocationExpression */: - return this.emitInvocationExpression(ast); - case 221 /* ElementAccessExpression */: - return this.emitElementAccessExpression(ast); - case 212 /* MemberAccessExpression */: - return this.emitMemberAccessExpression(ast); - case 121 /* QualifiedName */: - return this.emitQualifiedName(ast); - case 173 /* CommaExpression */: - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* LogicalOrExpression */: - case 188 /* LogicalAndExpression */: - case 189 /* BitwiseOrExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 191 /* BitwiseAndExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return this.emitBinaryExpression(ast); - case 186 /* ConditionalExpression */: - return this.emitConditionalExpression(ast); - case 232 /* EqualsValueClause */: - return this.emitEqualsValueClause(ast); - case 242 /* Parameter */: - return this.emitParameter(ast); - case 146 /* Block */: - return this.emitBlock(ast); - case 235 /* ElseClause */: - return this.emitElseClause(ast); - case 147 /* IfStatement */: - return this.emitIfStatement(ast); - case 149 /* ExpressionStatement */: - return this.emitExpressionStatement(ast); - case 139 /* GetAccessor */: - return this.emitGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitSetAccessor(ast); - case 157 /* ThrowStatement */: - return this.emitThrowStatement(ast); - case 150 /* ReturnStatement */: - return this.emitReturnStatement(ast); - case 216 /* ObjectCreationExpression */: - return this.emitObjectCreationExpression(ast); - case 151 /* SwitchStatement */: - return this.emitSwitchStatement(ast); - case 233 /* CaseSwitchClause */: - return this.emitCaseSwitchClause(ast); - case 234 /* DefaultSwitchClause */: - return this.emitDefaultSwitchClause(ast); - case 152 /* BreakStatement */: - return this.emitBreakStatement(ast); - case 153 /* ContinueStatement */: - return this.emitContinueStatement(ast); - case 154 /* ForStatement */: - return this.emitForStatement(ast); - case 155 /* ForInStatement */: - return this.emitForInStatement(ast); - case 158 /* WhileStatement */: - return this.emitWhileStatement(ast); - case 163 /* WithStatement */: - return this.emitWithStatement(ast); - case 220 /* CastExpression */: - return this.emitCastExpression(ast); - case 215 /* ObjectLiteralExpression */: - return this.emitObjectLiteralExpression(ast); - case 240 /* SimplePropertyAssignment */: - return this.emitSimplePropertyAssignment(ast); - case 241 /* FunctionPropertyAssignment */: - return this.emitFunctionPropertyAssignment(ast); - case 156 /* EmptyStatement */: - return this.writeToOutputWithSourceMapRecord(";", ast); - case 159 /* TryStatement */: - return this.emitTryStatement(ast); - case 236 /* CatchClause */: - return this.emitCatchClause(ast); - case 237 /* FinallyClause */: - return this.emitFinallyClause(ast); - case 160 /* LabeledStatement */: - return this.emitLabeledStatement(ast); - case 161 /* DoStatement */: - return this.emitDoStatement(ast); - case 171 /* TypeOfExpression */: - return this.emitTypeOfExpression(ast); - case 170 /* DeleteExpression */: - return this.emitDeleteExpression(ast); - case 172 /* VoidExpression */: - return this.emitVoidExpression(ast); - case 162 /* DebuggerStatement */: - return this.emitDebuggerStatement(ast); - } - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; - - function getLastConstructor(classDecl) { - return classDecl.classElements.lastOrDefault(function (e) { - return e.kind() === 137 /* ConstructorDeclaration */; - }); - } - TypeScript.getLastConstructor = getLastConstructor; - - function getTrimmedTextLines(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - return comment.fullText().split("\n").map(function (s) { - return s.trim(); - }); - } else { - return [comment.fullText().trim()]; - } - } - TypeScript.getTrimmedTextLines = getTrimmedTextLines; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += memberName.text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripStartAndEndQuotes(str) { - var firstCharCode = str && str.charCodeAt(0); - if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - return str.substring(1, str.length - 1); - } - - return str; - } - TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; - - function isSingleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isDoubleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; - } - TypeScript.isDoubleQuoted = isDoubleQuoted; - - function isQuoted(str) { - return isDoubleQuoted(str) || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - var switchToForwardSlashesRegEx = /\\/g; - function switchToForwardSlashes(path) { - return path.replace(switchToForwardSlashesRegEx, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { - if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { - absoluteModPath = "file:///" + absoluteModPath; - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function changePathToDTS(modPath) { - return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.length > 0 && path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function convertToDirectoryPath(dirPath) { - if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { - dirPath += "/"; - } - - return dirPath; - } - TypeScript.convertToDirectoryPath = convertToDirectoryPath; - - var normalizePathRegEx = /^\\\\[^\\]/; - function normalizePath(path) { - if (normalizePathRegEx.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - function isNoDefaultLibMatch(comment) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - return isNoDefaultLibRegex.exec(comment); - } - - TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; - - function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { - var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } - } - } - - return null; - } - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - var start = new Date().getTime(); - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 107 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 72 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionScanImportsTime += totalTime; - } - - function processTripleSlashDirectives(fileName, lineMap, firstToken) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - var diagnostics = []; - var referencedFiles = []; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - var isNoDefaultLib = isNoDefaultLibMatch(triviaText); - if (isNoDefaultLib) { - noDefaultLib = isNoDefaultLib[3] === "true"; - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; - } - - function preProcessFile(fileName, sourceText, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); - - scannerDiagnostics.length = 0; - return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); - } - TypeScript.getParseOptions = getParseOptions; - - function getReferencedFiles(fileName, sourceText) { - return preProcessFile(fileName, sourceText, false).referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ReferenceResolutionResult = (function () { - function ReferenceResolutionResult() { - this.resolvedFiles = []; - this.diagnostics = []; - this.seenNoDefaultLibTag = false; - } - return ReferenceResolutionResult; - })(); - TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; - - var ReferenceLocation = (function () { - function ReferenceLocation(filePath, lineMap, position, length, isImported) { - this.filePath = filePath; - this.lineMap = lineMap; - this.position = position; - this.length = length; - this.isImported = isImported; - } - return ReferenceLocation; - })(); - - var ReferenceResolver = (function () { - function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { - this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this.inputFileNames = inputFileNames; - this.host = host; - this.visited = {}; - } - ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { - var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); - return resolver.resolveInputFiles(); - }; - - ReferenceResolver.prototype.resolveInputFiles = function () { - var _this = this; - var result = new ReferenceResolutionResult(); - - if (!this.inputFileNames || this.inputFileNames.length <= 0) { - return result; - } - - var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); - this.inputFileNames.forEach(function (fileName) { - return _this.resolveIncludedFile(fileName, referenceLocation, result); - }); - - return result; - }; - - ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { - var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); - - if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); - } - - return normalizedPath; - } - - if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { - var dtsFile = normalizedPath + ".d.ts"; - var tsFile = normalizedPath + ".ts"; - - if (this.host.fileExists(dtsFile)) { - normalizedPath = dtsFile; - } else { - normalizedPath = tsFile; - } - } - - if (!this.host.fileExists(normalizedPath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); - } - - return normalizedPath; - } - - return this.resolveFile(normalizedPath, resolutionResult); - }; - - ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { - var isRelativePath = TypeScript.isRelative(path); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); - - if (isRelativePath || isRootedPath) { - return this.resolveIncludedFile(path, referenceLocation, resolutionResult); - } else { - var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); - var searchFilePath = null; - var dtsFileName = path + ".d.ts"; - var tsFilePath = path + ".ts"; - - var start = new Date().getTime(); - - do { - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - parentDirectory = this.host.getParentDirectory(parentDirectory); - } while(parentDirectory); - - TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; - - if (!searchFilePath) { - return path; - } - - return this.resolveFile(searchFilePath, resolutionResult); - } - }; - - ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { - var _this = this; - var visitedPath = this.isVisited(normalizedPath); - if (!visitedPath) { - this.recordVisitedFile(normalizedPath); - - var start = new Date().getTime(); - var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionIOTime += totalTime; - - var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); - var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); - resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); - - if (preprocessedFileInformation.isLibFile) { - resolutionResult.seenNoDefaultLibTag = true; - } - - var normalizedReferencePaths = []; - preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); - var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); - normalizedReferencePaths.push(normalizedReferencePath); - }); - - var normalizedImportPaths = []; - for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { - var fileImport = preprocessedFileInformation.importedFiles[i]; - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); - var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); - normalizedImportPaths.push(normalizedImportPath); - } - - resolutionResult.resolvedFiles.push({ - path: normalizedPath, - referencedFiles: normalizedReferencePaths, - importedFiles: normalizedImportPaths - }); - } else { - normalizedPath = visitedPath; - } - - return normalizedPath; - }; - - ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { - var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; - var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); - return normalizedPath; - }; - - ReferenceResolver.prototype.getUniqueFileId = function (filePath) { - return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); - }; - - ReferenceResolver.prototype.recordVisitedFile = function (filePath) { - this.visited[this.getUniqueFileId(filePath)] = filePath; - }; - - ReferenceResolver.prototype.isVisited = function (filePath) { - return this.visited[this.getUniqueFileId(filePath)]; - }; - - ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { - if (!filePath1 || !filePath2) { - return false; - } - - if (this.useCaseSensitiveFileResolution) { - return filePath1 === filePath2; - } else { - return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); - } - }; - return ReferenceResolver; - })(); - TypeScript.ReferenceResolver = ReferenceResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(name, writeByteOrderMark, outputFileType) { - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.outputFileType = outputFileType; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += TypeScript.newLine(); - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - }; - - TextWriter.prototype.getOutputFile = function () { - return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.document = document; - this.compiler = compiler; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.emittedReferencePaths = false; - this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); - } - DeclarationEmitter.prototype.getOutputFile = function () { - return this.declFile.getOutputFile(); - }; - - DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { - this.emitDeclarationsForSourceUnit(sourceUnit); - }; - - DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.emitDeclarationsForAST(list.childAt(i)); - } - }; - - DeclarationEmitter.prototype.emitSeparatedList = function (list) { - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.emitDeclarationsForAST(list.nonSeparatorAt(i)); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { - switch (ast.kind()) { - case 148 /* VariableStatement */: - return this.emitDeclarationsForVariableStatement(ast); - case 141 /* PropertySignature */: - return this.emitPropertySignature(ast); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast, true, true); - case 136 /* MemberVariableDeclaration */: - return this.emitDeclarationsForMemberVariableDeclaration(ast); - case 137 /* ConstructorDeclaration */: - return this.emitDeclarationsForConstructorDeclaration(ast); - case 139 /* GetAccessor */: - return this.emitDeclarationsForGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitDeclarationsForSetAccessor(ast); - case 138 /* IndexMemberDeclaration */: - return this.emitIndexMemberDeclaration(ast); - case 144 /* IndexSignature */: - return this.emitIndexSignature(ast); - case 142 /* CallSignature */: - return this.emitCallSignature(ast); - case 143 /* ConstructSignature */: - return this.emitConstructSignature(ast); - case 145 /* MethodSignature */: - return this.emitMethodSignature(ast); - case 129 /* FunctionDeclaration */: - return this.emitDeclarationsForFunctionDeclaration(ast); - case 135 /* MemberFunctionDeclaration */: - return this.emitMemberFunctionDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.emitDeclarationsForClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitDeclarationsForInterfaceDeclaration(ast); - case 133 /* ImportDeclaration */: - return this.emitDeclarationsForImportDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitDeclarationsForModuleDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitDeclarationsForEnumDeclaration(ast); - case 134 /* ExportAssignment */: - return this.emitDeclarationsForExportAssignment(ast); - } - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - return this.indenter.getIndent(); - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { - var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { - var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - var start = new Date().getTime(); - var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); - var result = declSymbol && declSymbol.isExternallyVisible(); - TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; - - return result; - } - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { - var result = this.getIndentString(); - var pullFlags = pullDecl.flags; - - if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); - - var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); - var container = this.getEnclosingContainer(declAST); - - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.isAnyNameOfModule(container, declAST)) { - container = this.getEnclosingContainer(container); - } - - var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); - - if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (isExternalModule || container.kind() == 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString != "import") { - result += "declare "; - } - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { - this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { - var declarationContainerAst = this.getEnclosingContainer(ast); - - var start = new Date().getTime(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); - - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = TypeScript.getTrimmedTextLines(comment); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.docComments(astOrSymbol); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { - var start = new Date().getTime(); - var decl = this.semanticInfoChain.getDeclForAST(boundDecl); - var pullSymbol = decl.getSymbol(); - TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; - - var type = pullSymbol.type; - TypeScript.Debug.assert(type); - - this.declFile.Write(": "); - this.emitTypeSignature(boundDecl, type); - }; - - DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { - this.emitDeclarationComments(varDecl); - this.emitIndent(); - this.declFile.Write(varDecl.propertyName.text()); - if (varDecl.questionToken) { - this.declFile.Write("?"); - } - - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - if (isFirstVarInList) { - this.emitDeclFlags(varDecl, "var"); - } - - this.declFile.Write(varDecl.propertyName.text()); - - if (!TypeScript.hasModifier(TypeScript.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - if (isLastVarInList) { - this.declFile.WriteLine(";"); - } else { - this.declFile.Write(", "); - } - } - }; - - DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { - if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } - this.declFile.Write("static "); - } else { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } else { - this.declFile.Write("public "); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(varDecl.modifiers); - ; - - this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); - - if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - this.declFile.WriteLine(";"); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { - this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); - }; - - 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); - } - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(id.text()); - if (isOptional) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (!isPrivate) { - this.emitTypeOfVariableDeclaratorOrParameter(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var start = new Date().getTime(); - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - var signatures = funcTypeSymbol.getCallSignatures(); - var result = signatures && signatures.length > 1; - - return result; - }; - - DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("constructor"); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitParameterList = function (isPrivate, parameterList) { - this.declFile.Write("("); - this.emitParameters(isPrivate, TypeScript.Parameters.fromParameterList(parameterList)); - this.declFile.Write(")"); - }; - - DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { - var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); - var argsLen = parameterList.length; - if (hasLastParameterRestParameter) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - - if (hasLastParameterRestParameter) { - if (parameterList.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - var index = parameterList.length - 1; - this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); - } - }; - - DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitDeclFlags(funcDecl, "function"); - var id = funcDecl.propertyName.text(); - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); - - this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); - - if (!isPrivate) { - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - this.emitDeclarationComments(funcDecl); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); - - this.emitIndent(); - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("new"); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write(funcDecl.propertyName.text()); - if (funcDecl.questionToken) { - this.declFile.Write("? "); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - if (funcDecl.block) { - var funcTypeSymbol = funcSymbol.type; - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - var id = funcDecl.identifier.text(); - this.emitDeclFlags(funcDecl, "function"); - if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { - this.declFile.Write(id); - } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { - this.declFile.Write("new"); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { - this.emitDeclarationsForAST(funcDecl.indexSignature); - }; - - DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("["); - this.emitParameters(false, TypeScript.Parameters.fromParameter(funcDecl.parameter)); - this.declFile.Write("]"); - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { - if (bases && (bases.nonSeparatorCount() > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.nonSeparatorCount(); - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - var base = bases.nonSeparatorAt(i); - var baseType = this.semanticInfoChain.getSymbolForAST(base); - this.emitTypeSignature(base, baseType); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var start = new Date().getTime(); - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - var comments = []; - if (accessors.getter) { - comments = comments.concat(TypeScript.docComments(accessors.getter)); - } - if (accessors.setter) { - comments = comments.concat(TypeScript.docComments(accessors.setter)); - } - - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { - var start = new Date().getTime(); - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { - return; - } - - var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); - this.emitAccessorDeclarationComments(funcDecl); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(modifiers); - this.declFile.Write(name.text()); - if (!isPrivate) { - this.declFile.Write(" : "); - var type = accessorSymbol.type; - this.emitTypeSignature(funcDecl, type); - } - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - if (funcDecl.parameterList) { - var argsLen = funcDecl.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.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()); - - if (!TypeScript.hasModifier(parameter.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(parameter); - } - this.declFile.WriteLine(";"); - } - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { - if (!this.canEmitDeclarations(classDecl)) { - return; - } - - var className = classDecl.identifier.text(); - this.emitDeclarationComments(classDecl); - var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.emitDeclFlags(classDecl, "class"); - this.declFile.Write(className); - - this.emitTypeParameters(classDecl.typeParameterList); - this.emitHeritageClauses(classDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - var constructorDecl = TypeScript.getLastConstructor(classDecl); - if (constructorDecl) { - this.emitClassMembersFromConstructorDefinition(constructorDecl); - } - - this.emitDeclarationsForList(classDecl.classElements); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { - if (clauses) { - for (var i = 0, n = clauses.childCount(); i < n; i++) { - this.emitHeritageClause(clauses.childAt(i)); - } - } - }; - - DeclarationEmitter.prototype.emitHeritageClause = function (clause) { - this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); - }; - - DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getEnclosingContainer(typeParams); - - var start = new Date().getTime(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); - var containerSymbol = containerDecl.getSymbol(); - TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; - - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArgumentsOrTypeParameters(); - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { - if (!this.canEmitDeclarations(interfaceDecl)) { - return; - } - - var interfaceName = interfaceDecl.identifier.text(); - this.emitDeclarationComments(interfaceDecl); - var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); - this.emitDeclFlags(interfaceDecl, "interface"); - this.declFile.Write(interfaceName); - - this.emitTypeParameters(interfaceDecl.typeParameterList); - this.emitHeritageClauses(interfaceDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - - this.emitSeparatedList(interfaceDecl.body.typeMembers); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); - var importSymbol = importDecl.getSymbol(); - var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); - - if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - if (isExportedImportDecl) { - this.declFile.Write("export "); - } - this.declFile.Write("import "); - this.declFile.Write(importDeclAST.identifier.text() + " = "); - if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); - } else { - this.declFile.WriteLine(this.getFullName(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; - } - - this.emitDeclarationComments(moduleDecl); - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclFlags(moduleDecl, "enum"); - this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.enumElements.nonSeparatorCount(); - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); - var enumElement = memberDecl; - var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); - this.emitDeclarationComments(enumElement); - this.emitIndent(); - this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue != null) { - this.declFile.Write(" = " + enumElementDecl.constantValue); - } - this.declFile.WriteLine(","); - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclarationComments(moduleDecl); - - var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); - this.emitDeclFlags(name, "module"); - - if (moduleDecl.stringLiteral) { - this.declFile.Write(moduleDecl.stringLiteral.text()); - } else { - this.declFile.Write(this.getFullName(moduleDecl.name)); - } - - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - - this.emitDeclarationsForList(moduleDecl.moduleElements); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write(ast.identifier.text()); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { - if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { - return reference; - } - - var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); - var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); - return resolvedReferencePath; - }; - - DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { - if (this.emittedReferencePaths) { - return; - } - - var documents = []; - if (this.document.emitToOwnOutputFile()) { - var scriptReferences = this.document.referencedFiles; - var addedGlobalDocument = false; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { - documents = documents.concat(document); - - if (!document.isDeclareFile() && document.isExternalModule()) { - addedGlobalDocument = true; - } - } - } - } else { - var fileNames = this.compiler.fileNames(); - for (var i = 0; i < fileNames.length; i++) { - var doc = this.compiler.getDocument(fileNames[i]); - if (!doc.isDeclareFile() && !doc.isExternalModule()) { - var scriptReferences = doc.referencedFiles; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.isDeclareFile() || document.isExternalModule())) { - for (var k = 0; k < documents.length; k++) { - if (documents[k] == document) { - break; - } - } - - if (k == documents.length) { - documents = documents.concat(document); - } - } - } - } - } - } - - var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; - for (var i = 0; i < documents.length; i++) { - var document = documents[i]; - var declFileName; - if (document.isDeclareFile()) { - declFileName = document.fileName; - } else { - declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } - - declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); - this.declFile.WriteLine('/// '); - } - - this.emittedReferencePaths = true; - }; - - DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { - this.emitReferencePaths(sourceUnit); - this.emitDeclarationsForList(sourceUnit.moduleElements); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - if (keys[name]) { - this.add(name); - } - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length != array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] != array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateEnumConstants = false; - this.removeComments = false; - this.watch = false; - this.noResolve = false; - this.allowAutomaticSemicolonInsertion = true; - this.noImplicitAny = false; - this.noLib = false; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Unspecified */; - this.outFileOption = ""; - this.outDirOption = ""; - this.mapSourceFiles = false; - this.mapRoot = ""; - this.sourceRoot = ""; - this.generateDeclarationFiles = false; - this.useCaseSensitiveFileResolution = false; - this.gatherDiagnostics = false; - this.codepage = null; - } - 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) { - this._propagateEnumConstants = propagateEnumConstants; - this._removeComments = removeComments; - this._watch = watch; - this._noResolve = noResolve; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._noImplicitAny = noImplicitAny; - this._noLib = noLib; - this._codeGenTarget = codeGenTarget; - this._moduleGenTarget = moduleGenTarget; - this._outFileOption = outFileOption; - this._outDirOption = outDirOption; - this._mapSourceFiles = mapSourceFiles; - this._mapRoot = mapRoot; - this._sourceRoot = sourceRoot; - this._generateDeclarationFiles = generateDeclarationFiles; - this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this._gatherDiagnostics = gatherDiagnostics; - this._codepage = codepage; - } - ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { - return this._propagateEnumConstants; - }; - ImmutableCompilationSettings.prototype.removeComments = function () { - return this._removeComments; - }; - ImmutableCompilationSettings.prototype.watch = function () { - return this._watch; - }; - ImmutableCompilationSettings.prototype.noResolve = function () { - return this._noResolve; - }; - ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - ImmutableCompilationSettings.prototype.noImplicitAny = function () { - return this._noImplicitAny; - }; - ImmutableCompilationSettings.prototype.noLib = function () { - return this._noLib; - }; - ImmutableCompilationSettings.prototype.codeGenTarget = function () { - return this._codeGenTarget; - }; - ImmutableCompilationSettings.prototype.moduleGenTarget = function () { - return this._moduleGenTarget; - }; - ImmutableCompilationSettings.prototype.outFileOption = function () { - return this._outFileOption; - }; - ImmutableCompilationSettings.prototype.outDirOption = function () { - return this._outDirOption; - }; - ImmutableCompilationSettings.prototype.mapSourceFiles = function () { - return this._mapSourceFiles; - }; - ImmutableCompilationSettings.prototype.mapRoot = function () { - return this._mapRoot; - }; - ImmutableCompilationSettings.prototype.sourceRoot = function () { - return this._sourceRoot; - }; - ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { - return this._generateDeclarationFiles; - }; - ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { - return this._useCaseSensitiveFileResolution; - }; - ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { - return this._gatherDiagnostics; - }; - ImmutableCompilationSettings.prototype.codepage = function () { - return this._codepage; - }; - - ImmutableCompilationSettings.defaultSettings = function () { - if (!ImmutableCompilationSettings._defaultSettings) { - ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); - } - - return ImmutableCompilationSettings._defaultSettings; - }; - - 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); - }; - - ImmutableCompilationSettings.prototype.toCompilationSettings = function () { - var result = new CompilationSettings(); - - for (var name in this) { - if (this.hasOwnProperty(name) && TypeScript.StringUtilities.startsWith(name, "_")) { - result[name.substr(1)] = this[name]; - } - } - - return result; - }; - return ImmutableCompilationSettings; - })(); - TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; - - PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; - - PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; - - PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; - - PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - function hasModifier(modifiers, flag) { - for (var i = 0, n = modifiers.length; i < n; i++) { - if (TypeScript.hasFlag(modifiers[i], flag)) { - return true; - } - } - - return false; - } - TypeScript.hasModifier = hasModifier; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; - PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; - - 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["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullDeclID = 0; - var sentinelEmptyPullDeclArray = []; - - var PullDecl = (function () { - function PullDecl(declName, displayName, kind, declFlags, span) { - this.declID = TypeScript.pullDeclID++; - this.flags = 0 /* None */; - this.declGroups = null; - this.childDecls = null; - this.typeParameters = null; - this.synthesizedValDecl = null; - this.childDeclTypeCache = null; - this.childDeclValueCache = null; - this.childDeclNamespaceCache = null; - this.childDeclTypeParameterCache = null; - this.name = declName; - this.kind = kind; - this.flags = declFlags; - this.span = span; - - if (displayName !== this.name) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.fileName = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentPath = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.semanticInfoChain = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.isExternalModule = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getEnclosingDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { - var decl = this; - while (decl) { - switch (decl.kind) { - default: - return decl; - case 512 /* Variable */: - case 8192 /* TypeParameter */: - case 2048 /* Parameter */: - case 128 /* TypeAlias */: - case 67108864 /* EnumMember */: - } - - decl = decl.getParentDecl(); - } - - TypeScript.Debug.fail(); - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.name : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (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(); - binder.bindDeclToPullSymbol(this); - } - }; - - PullDecl.prototype.getSymbol = function () { - if (this.kind == 1 /* Script */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.semanticInfoChain().getSymbolForDecl(this); - }; - - PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain().getSymbolForDecl(this); - return !!symbol; - }; - - PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain().setSignatureSymbolForDecl(this, signatureSymbol); - }; - - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(true); - - return this.semanticInfoChain().getSignatureSymbolForDecl(this); - }; - - PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain().getSignatureSymbolForDecl(this); - return !!signatureSymbol; - }; - - PullDecl.prototype.setFlags = function (flags) { - this.flags = flags; - }; - - PullDecl.prototype.setFlag = function (flags) { - this.flags |= flags; - }; - - PullDecl.prototype.getSpan = function () { - return this.span; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - }; - - 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.getChildDeclCache = function (declKind) { - if (declKind === 8192 /* TypeParameter */) { - if (!this.childDeclTypeParameterCache) { - this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeParameterCache; - } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { - if (!this.childDeclNamespaceCache) { - this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728539 /* SomeType */)) { - if (!this.childDeclTypeCache) { - this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeCache; - } else { - if (!this.childDeclValueCache) { - this.childDeclValueCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclValueCache; - } - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.kind === 8192 /* TypeParameter */) { - if (!this.typeParameters) { - this.typeParameters = []; - } - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - if (!this.childDecls) { - this.childDecls = []; - } - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.name; - - if (!(childDecl.kind & 7340032 /* SomeSignature */)) { - var cache = this.getChildDeclCache(childDecl.kind); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - } - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cacheVal = null; - - if (searchKind & 58728539 /* SomeType */) { - cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; - } else if (searchKind & 164 /* SomeContainer */) { - cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; - } else { - cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; - } - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & 58728539 /* SomeType */) { - cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; - - if (cacheVal) { - return cacheVal; - } - } - - return sentinelEmptyPullDeclArray; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls ? this.childDecls : sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters ? this.typeParameters : sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - if (!this.declGroups) { - this.declGroups = TypeScript.createIntrinsicsObject(); - } - - var declGroup = this.declGroups[decl.name]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.name); - declGroup.addDecl(decl); - this.declGroups[decl.name] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = null; - - if (this.declGroups) { - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - if (declGroups === null) { - declGroups = []; - } - - declGroups.push(this.declGroups[declName].getDecls()); - } - } - } - - return declGroups ? declGroups : sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.hasBeenBound = function () { - return this.hasSymbol() || this.hasSignatureSymbol(); - }; - - PullDecl.prototype.isSynthesized = function () { - return false; - }; - - PullDecl.prototype.ast = function () { - var semanticInfoChain = this.semanticInfoChain(); - return semanticInfoChain ? semanticInfoChain.getASTForDecl(this) : null; - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - 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; - this._isExternalModule = isExternalModule; - this._fileName = fileName; - } - RootPullDecl.prototype.fileName = function () { - return this._fileName; - }; - - RootPullDecl.prototype.getParentPath = function () { - return [this]; - }; - - RootPullDecl.prototype.getParentDecl = function () { - return null; - }; - - RootPullDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - - RootPullDecl.prototype.isExternalModule = function () { - return this._isExternalModule; - }; - - RootPullDecl.prototype.getEnclosingDecl = function () { - return this; - }; - return RootPullDecl; - })(PullDecl); - TypeScript.RootPullDecl = RootPullDecl; - - var NormalPullDecl = (function (_super) { - __extends(NormalPullDecl, _super); - function NormalPullDecl(declName, displayName, kind, declFlags, parentDecl, span, addToParent) { - if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, span); - this.parentDecl = null; - this.parentPath = null; - - this.parentDecl = parentDecl; - if (addToParent) { - parentDecl.addChildDecl(this); - } - } - NormalPullDecl.prototype.fileName = function () { - return this.parentDecl ? this.parentDecl.fileName() : ""; - }; - - NormalPullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - NormalPullDecl.prototype.getParentPath = function () { - if (!this.parentPath) { - var path = [this]; - var parentDecl = this.parentDecl; - - while (parentDecl) { - if (parentDecl && path[path.length - 1] != parentDecl && !(parentDecl.kind & 256 /* ObjectLiteral */)) { - path.unshift(parentDecl); - } - - parentDecl = parentDecl.getParentDecl(); - } - - this.parentPath = path; - } - - return this.parentPath; - }; - - NormalPullDecl.prototype.semanticInfoChain = function () { - var parent = this.getParentDecl(); - return parent ? parent.semanticInfoChain() : null; - }; - - NormalPullDecl.prototype.isExternalModule = function () { - return false; - }; - - NormalPullDecl.prototype.getEnclosingDecl = function () { - return this.parentDecl && this.parentDecl._getEnclosingDeclFromParentDecl(); - }; - 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); - this.constantValue = null; - } - return PullEnumElementDecl; - })(NormalPullDecl); - TypeScript.PullEnumElementDecl = PullEnumElementDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, span, displayName) { - if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl, span); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(NormalPullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - 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; - } - PullSynthesizedDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - - PullSynthesizedDecl.prototype.isSynthesized = function () { - return true; - }; - return PullSynthesizedDecl; - })(NormalPullDecl); - TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.name === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (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._container = null; - this.type = null; - this._declarations = null; - this.isResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isVarArg = false; - this.rootSymbol = null; - this._enclosingSignature = null; - this._docComments = null; - this.isPrinting = false; - this.name = name; - this.kind = declKind; - } - PullSymbol.prototype.isAny = function () { - return false; - }; - - PullSymbol.prototype.isType = function () { - return (this.kind & 58728539 /* SomeType */) != 0; - }; - - PullSymbol.prototype.isTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) != 0; - }; - - PullSymbol.prototype.isArrayNamedTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.kind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isInterface = function () { - return this.kind === 16 /* Interface */; - }; - - PullSymbol.prototype.isMethod = function () { - return this.kind === 65536 /* Method */; - }; - - PullSymbol.prototype.isProperty = function () { - return this.kind === 4096 /* Property */; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { - if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } - if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } - var scopeDeclarations = scopeSymbol.getDeclarations(); - var scopeSymbolAliasesToLookIn = []; - - for (var i = 0; i < scopeDeclarations.length; i++) { - var scopeDecl = scopeDeclarations[i]; - if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { - visitedScopeDeclarations.push(scopeDecl); - - var childDecls = scopeDecl.getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - var childDecl = childDecls[j]; - if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { - var symbol = childDecl.getSymbol(); - - if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { - aliasSymbols.push(symbol); - return aliasSymbols; - } - - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind == 32 /* DynamicModule */))) { - scopeSymbolAliasesToLookIn.push(symbol); - } - } - } - } - } - - for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { - var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; - - aliasSymbols.push(scopeSymbolAlias); - var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); - if (result) { - return result; - } - - aliasSymbols.pop(); - } - - return null; - }; - - PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { - var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); - return symbols; - } - - return null; - }; - - PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { - if (aliasSymbol) { - if (aliasSymbol.assignedValue()) { - return false; - } - - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() != aliasSymbol.assignedContainer()) { - return false; - } - - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind != 32 /* DynamicModule */) { - return false; - } - - return true; - } - - return false; - }; - - PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { - if (scopeSymbol) { - 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); - return internalAliases[0]; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { - if (!skipInternalAlias) { - var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); - if (internalAlias) { - return aliasNameGetter(internalAlias); - } - } - - var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); - - if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - var aliasFullName = ""; - for (var i = 1, symbolsLen = externalAliases.length; i < symbolsLen; i++) { - aliasFullName = aliasFullName + "." + aliasPartsNameGetter(externalAliases[i]); - } - return aliasNameGetter(externalAliases[0]) + aliasFullName; - } - - return null; - }; - - PullSymbol.prototype._getResolver = function () { - TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain().getResolver(); - }; - - PullSymbol.prototype._resolveDeclaredSymbol = function () { - return this._getResolver().resolveDeclaredSymbol(this); - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getName(); - }); - if (aliasName != null) { - return aliasName; - } - - return this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getDisplayName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getDisplayName(); - }, skipInternalAliasName); - if (aliasDisplayName != null) { - return aliasDisplayName; - } - - var decls = this.getDeclarations(); - var name = decls.length && decls[0].getDisplayName(); - - return (name && name.length) ? name : this.name; - }; - - PullSymbol.prototype.getIsSpecialized = function () { - return false; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - PullSymbol.prototype.setIsSynthesized = function (value) { - if (typeof value === "undefined") { value = true; } - this.isSynthesized = value; - }; - - PullSymbol.prototype.getIsSynthesized = function () { - return this.isSynthesized; - }; - - PullSymbol.prototype.setEnclosingSignature = function (signature) { - this._enclosingSignature = signature; - }; - - PullSymbol.prototype.getEnclosingSignature = function () { - return this._enclosingSignature; - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - if (!this._declarations) { - this._declarations = [decl]; - } else { - this._declarations[this._declarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this._declarations) { - this._declarations = []; - } - - return this._declarations; - }; - - PullSymbol.prototype.hasDeclaration = function (decl) { - if (!this._declarations) { - return false; - } - - return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { - return eachDecl === decl; - }); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - if (this.rootSymbol) { - return; - } - - this._container = containerSymbol; - }; - - PullSymbol.prototype.getContainer = function () { - if (this.rootSymbol) { - return this.rootSymbol.getContainer(); - } - - return this._container; - }; - - PullSymbol.prototype.setResolved = function () { - this.isResolved = true; - this.inResolution = false; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.isResolved = false; - this.inResolution = false; - }; - - PullSymbol.prototype.anyDeclHasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (TypeScript.hasFlag(declarations[i].flags, flag)) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!TypeScript.hasFlag(declarations[i].flags, flag)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = node.getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - var nodeKind = node.kind; - if (nodeKind == 2048 /* Parameter */) { - break; - } else { - node = node.getContainer(); - } - } - return path; - }; - - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } - - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } - - 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; - } - } - } - if (commonNodeIndex >= 0) { - break; - } - } - - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); - } else { - return aPath; - } - }; - - PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var str = this.getNameAndTypeName(scopeSymbol); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var path = this.pathToRoot(); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName != null) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName != null) { - fullName = aliasFullName + "." + fullName; - break; - } - - var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findCommonAncestorPath(scopeSymbol); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName != null) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].kind; - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName != null) { - fullName = aliasFullName + "." + fullName; - break; - } - - if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.type; - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - 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 */) { - var signatures = type.getCallSignatures(); - 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); - return typeName; - } - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.type; - var nameStr = this.getDisplayName(scopeSymbol); - if (type) { - nameStr = nameStr + (this.isOptional ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return TypeScript.MemberName.create(nameStr); - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - - inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); - - var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); - inIsExternallyVisibleSymbols.pop(); - - return result; - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.kind; - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.rootSymbol) { - return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); - } - - if (this.isType()) { - var associatedContainerSymbol = this.getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.anyDeclHasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - var decls = this.getDeclarations(); - if (decls.length) { - var parentDecl = decls[0].getParentDecl(); - if (parentDecl) { - var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind == 1 /* Script */) { - return true; - } - - return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); - } - } - - return true; - } - - 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 */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { - var ast = decl.ast(); - - if (ast) { - var enclosingModuleDeclaration = TypeScript.getEnclosingModuleDeclaration(ast); - if (TypeScript.isLastNameOfModule(enclosingModuleDeclaration, ast)) { - return TypeScript.docComments(enclosingModuleDeclaration); - } - - if (ast.kind() != 130 /* ModuleDeclaration */ || decl.kind != 512 /* Variable */) { - return TypeScript.docComments(ast); - } - } - - return []; - }; - - PullSymbol.prototype.getDocCommentArray = function (symbol) { - var docComments = []; - if (!symbol) { - return docComments; - } - - 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 */) { - continue; - } - docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); - } - return docComments; - }; - - PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { - if (classSymbol.getHasDefaultConstructor()) { - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); - } - } - - return classSymbol.type.getConstructSignatures()[0]; - }; - - PullSymbol.prototype.getDocCommentText = function (comments) { - var docCommentText = new Array(); - for (var c = 0; c < comments.length; c++) { - var commentText = this.getDocCommentTextValue(comments[c]); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - PullSymbol.prototype.getDocCommentTextValue = function (comment) { - return this.cleanJSDocComment(comment.fullText()); - }; - - PullSymbol.prototype.docComments = function (useConstructorAsClass) { - var decls = this.getDeclarations(); - 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 */) { - var classSymbol = this.returnType; - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - docComments = extendedTypes[0].getConstructorMethod().docComments(); - } else { - docComments = ""; - } - } else if (this.kind == 2048 /* Parameter */) { - var parameterComments = []; - - var funcContainer = this.getEnclosingSignature(); - var funcDocComments = this.getDocCommentArray(funcContainer); - var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); - if (paramComment != "") { - parameterComments.push(paramComment); - } - - var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); - if (paramSelfComment != "") { - parameterComments.push(paramSelfComment); - } - docComments = parameterComments.join("\n"); - } else { - var getSymbolComments = true; - if (this.kind == 16777216 /* FunctionType */) { - var functionSymbol = this.getFunctionSymbol(); - - if (functionSymbol) { - docComments = functionSymbol._docComments || ""; - getSymbolComments = false; - } else { - var declarationList = this.getDeclarations(); - if (declarationList.length > 0) { - docComments = declarationList[0].getSymbol()._docComments || ""; - getSymbolComments = false; - } - } - } - if (getSymbolComments) { - docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments == "") { - if (this.kind == 1048576 /* CallSignature */) { - var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length == 1) { - docComments = callTypeSymbol.docComments(); - } - } - } - } - } - - this._docComments = docComments; - } - - return this._docComments; - }; - - PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].fullText(); - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!this.isSpaceChar(commentContents, j)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - - PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = new Array(); - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.start; - for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.end); - } - - var newCleanPos = this.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - PullSymbol.prototype.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = this.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - start: nonSpaceIndex, - end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - function PullSignatureSymbol(kind) { - _super.call(this, "", kind); - this._memberTypeParameterNameCache = null; - this._stringConstantOverload = undefined; - this.parameters = TypeScript.sentinelEmptyArray; - this.typeParameters = null; - this.returnType = null; - this.functionType = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this.hasAGenericParameter = false; - this.hasBeenChecked = false; - this.inWrapCheck = false; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return false; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - return this.hasAGenericParameter || (this.typeParameters && this.typeParameters.length != 0); - }; - - PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { - if (typeof isOptional === "undefined") { isOptional = false; } - if (this.parameters == TypeScript.sentinelEmptyArray) { - this.parameters = []; - } - - this.parameters[this.parameters.length] = parameter; - this.hasOptionalParam = isOptional; - - if (!parameter.getEnclosingSignature()) { - parameter.setEnclosingSignature(this); - } - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this.typeParameters) { - this.typeParameters = []; - } - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - this.typeParameters[this.typeParameters.length] = typeParameter; - - this._memberTypeParameterNameCache[typeParameter.getName()] = typeParameter; - }; - - PullSignatureSymbol.prototype.getTypeParameters = function () { - if (!this.typeParameters) { - this.typeParameters = []; - } - - return this.typeParameters; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - 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]; - } - } - } - - memberSymbol = this._memberTypeParameterNameCache[name]; - - return memberSymbol; - }; - - PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { - if (this._stringConstantOverload === undefined) { - var params = this.parameters; - this._stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].type; - if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { - this._stringConstantOverload = true; - } - } - } - - return this._stringConstantOverload; - }; - - PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { - var allMemberNames = new TypeScript.MemberNameArray(); - var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - if (!signatures) { - return result; - } - - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.parameters; - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].type; - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].isVarArg; - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - if (this.returnType) { - builder.add(this.returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - return builder; - }; - - PullSignatureSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { - var signature = this; - if (signature.inWrapCheck) { - return false; - } - - signature.inWrapCheck = true; - - 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; - } - } - } - - signature.inWrapCheck = false; - - return wrapsSomeTypeParameter; - }; - - PullSignatureSymbol.prototype.wrapsSomeNestedTypeIntoInfiniteExpansion = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - if (this.inWrapCheck) { - return isCheckingTypeArgumentList; - } - - if (knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID) != undefined) { - return knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID); - } - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, isCheckingTypeArgumentList); - - this.inWrapCheck = true; - - var wrapsSomeWrappedTypeParameter = false; - - if (this.returnType && this.returnType._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - wrapsSomeWrappedTypeParameter = true; - } - - if (!wrapsSomeWrappedTypeParameter) { - 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; - } - } - } - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, wrapsSomeWrappedTypeParameter); - - this.inWrapCheck = false; - - return wrapsSomeWrappedTypeParameter; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol(name, kind) { - _super.call(this, name, kind); - this._members = TypeScript.sentinelEmptyArray; - this._enclosedMemberTypes = null; - this._enclosedMemberContainers = null; - this._typeParameters = null; - this._specializedVersionsOfThisType = null; - this._arrayVersionOfThisType = null; - this._implementedTypes = null; - this._extendedTypes = null; - this._typesThatExplicitlyImplementThisType = null; - this._typesThatExtendThisType = null; - this._callSignatures = null; - this._allCallSignatures = null; - this._constructSignatures = null; - this._indexSignatures = null; - this._allIndexSignatures = null; - this._memberNameCache = null; - this._enclosedTypeNameCache = null; - this._enclosedContainerCache = null; - this._typeParameterNameCache = null; - this._containedNonMemberNameCache = null; - this._containedNonMemberTypeNameCache = null; - this._containedNonMemberContainerCache = null; - this._simpleInstantiationCache = null; - this._complexInstantiationCache = null; - this._hasGenericSignature = false; - this._hasGenericMember = false; - this._hasBaseTypeConflict = false; - this._knownBaseTypeCount = 0; - this._associatedContainerTypeSymbol = null; - this._constructorMethod = null; - this._hasDefaultConstructor = false; - this._functionSymbol = null; - this._inMemberTypeNameEx = false; - this.inSymbolPrivacyCheck = false; - this.inWrapCheck = false; - this.typeReference = null; - this._isArrayNamedTypeReference = undefined; - this.type = this; - } - PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArrayNamedTypeReference === undefined) { - this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); - } - - return this._isArrayNamedTypeReference; - }; - - 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) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.kind == 8 /* Class */ || (this._constructorMethod != null); - }; - PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) != 0; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return this.kind == 33554432 /* ConstructorType */; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - PullTypeSymbol.prototype.isEnum = function () { - return this.kind == 64 /* Enum */; - }; - - PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { - return null; - }; - - PullTypeSymbol.prototype.isObject = function () { - return TypeScript.hasFlag(this.kind, 8 /* Class */ | 33554432 /* ConstructorType */ | 64 /* Enum */ | 16777216 /* FunctionType */ | 16 /* Interface */ | 8388608 /* ObjectType */); - }; - - PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { - return this._knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this._knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this._knownBaseTypeCount++; - }; - - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.hasMembers = function () { - if (this._members != TypeScript.sentinelEmptyArray) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this._hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this._hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this._hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this._hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this._associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this._associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this._arrayVersionOfThisType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - return null; - }; - - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this._arrayVersionOfThisType = arrayType; - }; - - PullTypeSymbol.prototype.getFunctionSymbol = function () { - return this._functionSymbol; - }; - - PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { - if (symbol) { - this._functionSymbol = symbol; - } - }; - - PullTypeSymbol.prototype.findContainedNonMember = function (name) { - if (!this._containedNonMemberNameCache) { - return null; - } - - return this._containedNonMemberNameCache[name]; - }; - - PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberTypeNameCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberContainerCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol) { - if (!memberSymbol) { - return; - } - - memberSymbol.setContainer(this); - - if (!this._memberNameCache) { - this._memberNameCache = TypeScript.createIntrinsicsObject(); - } - - if (this._members === TypeScript.sentinelEmptyArray) { - this._members = []; - } - - this._members.push(memberSymbol); - this._memberNameCache[memberSymbol.name] = memberSymbol; - }; - - PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - if (!enclosedType) { - return; - } - - enclosedType.setContainer(this); - - if (!this._enclosedTypeNameCache) { - this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberTypes) { - this._enclosedMemberTypes = []; - } - - this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; - this._enclosedTypeNameCache[enclosedType.name] = enclosedType; - }; - - PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - if (!enclosedContainer) { - return; - } - - enclosedContainer.setContainer(this); - - if (!this._enclosedContainerCache) { - this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberContainers) { - this._enclosedMemberContainers = []; - } - - this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; - this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; - }; - - PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - if (!enclosedNonMember) { - return; - } - - enclosedNonMember.setContainer(this); - - if (!this._containedNonMemberNameCache) { - this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - if (!enclosedNonMemberType) { - return; - } - - enclosedNonMemberType.setContainer(this); - - if (!this._containedNonMemberTypeNameCache) { - this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - if (!enclosedNonMemberContainer) { - return; - } - - enclosedNonMemberContainer.setContainer(this); - - if (!this._containedNonMemberContainerCache) { - this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; - }; - - PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!typeParameter) { - return; - } - - if (!typeParameter.getContainer()) { - typeParameter.setContainer(this); - } - - if (!this._typeParameterNameCache) { - this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._typeParameters) { - this._typeParameters = []; - } - - this._typeParameters[this._typeParameters.length] = typeParameter; - 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; - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this._hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this._hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this._constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this._constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - if (!this._typeParameters) { - return TypeScript.sentinelEmptyArray; - } - - return this._typeParameters; - }; - - 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; - } - - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { - if (!this._simpleInstantiationCache) { - this._simpleInstantiationCache = []; - } - - this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID] = specializedVersionOfThisType; - } else { - if (!this._complexInstantiationCache) { - this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); - } - - this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; - } - - if (!this._specializedVersionsOfThisType) { - this._specializedVersionsOfThisType = []; - } - - this._specializedVersionsOfThisType.push(specializedVersionOfThisType); - }; - - PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return null; - } - - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { - if (!this._simpleInstantiationCache) { - return null; - } - - var result = this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID]; - return result ? result : null; - } else { - if (!this._complexInstantiationCache) { - return null; - } - - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)]; - return result ? result : null; - } - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - if (!this._specializedVersionsOfThisType) { - return TypeScript.sentinelEmptyArray; - } - - return this._specializedVersionsOfThisType; - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return null; - }; - - PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeParameters(); - }; - - PullTypeSymbol.prototype.addCallSignature = function (callSignature) { - if (!this._callSignatures) { - this._callSignatures = []; - } - - this._callSignatures[this._callSignatures.length] = callSignature; - - if (callSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - callSignature.functionType = this; - }; - - PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { - if (!this._constructSignatures) { - this._constructSignatures = []; - } - - this._constructSignatures[this._constructSignatures.length] = constructSignature; - - if (constructSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - constructSignature.functionType = this; - }; - - PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { - if (!this._indexSignatures) { - this._indexSignatures = []; - } - - this._indexSignatures[this._indexSignatures.length] = indexSignature; - - if (indexSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - 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.getCallSignatures = function () { - if (this._allCallSignatures) { - return this._allCallSignatures; - } - - var signatures = []; - - if (this._callSignatures) { - signatures = signatures.concat(this._callSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this.addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); - } - } - - this._allCallSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return this._constructSignatures !== null; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function () { - var signatures = []; - - if (this._constructSignatures) { - signatures = signatures.concat(this._constructSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this.addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); - } - } - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return this._indexSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnIndexSignatures = function () { - return this._indexSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function () { - if (this._allIndexSignatures) { - return this._allIndexSignatures; - } - - var signatures = []; - - if (this._indexSignatures) { - signatures = signatures.concat(this._indexSignatures); - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this.addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); - } - } - - this._allIndexSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.addImplementedType = function (implementedType) { - if (!implementedType) { - return; - } - - if (!this._implementedTypes) { - this._implementedTypes = []; - } - - this._implementedTypes[this._implementedTypes.length] = implementedType; - - implementedType.addTypeThatExplicitlyImplementsThisType(this); - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - if (!this._implementedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._implementedTypes; - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!extendedType) { - return; - } - - if (!this._extendedTypes) { - this._extendedTypes = []; - } - - this._extendedTypes[this._extendedTypes.length] = extendedType; - - extendedType.addTypeThatExtendsThisType(this); - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - if (!this._extendedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._extendedTypes; - }; - - PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - return this._typesThatExtendThisType; - }; - - PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - return this._typesThatExplicitlyImplementThisType; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { - return true; - } - - if (TypeScript.ArrayUtilities.contains(visited, this)) { - return true; - } - - visited.push(this); - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - visited.pop(); - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.kind === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - var memberSymbol = null; - - if (this._memberNameCache) { - memberSymbol = this._memberNameCache[name]; - } - - if (memberSymbol || !lookInParent) { - return memberSymbol; - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return null; - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedTypeNameCache) { - return null; - } - - memberSymbol = this._enclosedTypeNameCache[name]; - - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedContainerCache) { - return null; - } - - memberSymbol = this._enclosedContainerCache[name]; - - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - var allMembers = []; - - 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 */))) { - allMembers[allMembers.length] = member; - } - } - } - - if (this._extendedTypes) { - var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; - - for (var i = 0, n = this._extendedTypes.length; i < n; i++) { - var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - if (this.isContainer()) { - if (this._enclosedMemberTypes) { - for (var i = 0; i < this._enclosedMemberTypes.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberTypes[i]; - } - } - if (this._enclosedMemberContainers) { - for (var i = 0; i < this._enclosedMemberContainers.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberContainers[i]; - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - if (!this._typeParameterNameCache) { - return null; - } - - return this._typeParameterNameCache[name]; - }; - - PullTypeSymbol.prototype.setResolved = function () { - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArgumentsOrTypeParameters(); - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); - }; - - 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 != "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); - return s; - }; - - PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - if (this.isArrayNamedTypeReference()) { - 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, "", "[]"); - } - - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - if (skipTypeParametersInName) { - return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); - } else { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - - var typars = this.getTypeArgumentsOrTypeParameters(); - builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - } - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getTypeOfSymbol = function () { - var associatedContainerType = this.getAssociatedContainerType(); - if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { - return associatedContainerType; - } - - var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind == 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return functionSymbol; - } - - return null; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var typeOfSymbol = this.getTypeOfSymbol(); - if (typeOfSymbol) { - var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); - return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); - } - - if (this._inMemberTypeNameEx) { - return TypeScript.MemberName.create("any"); - } - - this._inMemberTypeNameEx = true; - - var allMemberNames = new TypeScript.MemberNameArray(); - 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()) { - var methodCallSignatures = members[i].type.getCallSignatures(); - var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); - ; - var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); - allMemberNames.addAll(methodMemberNames); - } else { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - if (memberTypeName.isArray() && memberTypeName.delim === delim) { - allMemberNames.addAll(memberTypeName.entries); - } else { - allMemberNames.add(memberTypeName); - } - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - this._inMemberTypeNameEx = false; - - return allMemberNames; - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - return 2 /* Closed */; - }; - - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { - var type = this; - - var wrapsSomeTypeParameter = false; - - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID]) { - return true; - } - - var constraint = type.getConstraint(); - - if (constraint && constraint.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return true; - } - - return false; - } - - if (type.inWrapCheck) { - return wrapsSomeTypeParameter; - } - - type.inWrapCheck = true; - - if (!wrapsSomeTypeParameter) { - var typeArguments = type.getTypeArguments(); - - if (type.isGeneric() && !typeArguments) { - typeArguments = type.getTypeParameters(); - } - - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } - } - - 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 (!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; - } - } - } - } - - type.inWrapCheck = false; - - return wrapsSomeTypeParameter; - }; - - 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.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; - } - } - - 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()) { - return false; - } - - this.inWrapCheck = true; - - 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; - }; - - PullTypeSymbol.prototype._wrapsSomeNestedTypeIntoInfiniteExpansionWorker = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - var typeArguments = this.getTypeArguments(); - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i]._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, true, knownWrapMap)) { - return true; - } - } - } - - if (this.anyRootTypeBeingWrapped(typeBeingWrapped)) { - if (isCheckingTypeArgumentList && this.isTypeReference() && !this.getIsSpecialized()) { - 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 PullTypeSymbol; - })(PullSymbol); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - - this.isResolved = true; - } - PullPrimitiveTypeSymbol.prototype.isAny = function () { - return this.name === "any"; - }; - - PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { - return false; - }; - - PullPrimitiveTypeSymbol.prototype.setUnresolved = function () { - }; - return PullPrimitiveTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(anyType, name) { - _super.call(this, name); - this.anyType = anyType; - - this.isResolved = true; - } - PullErrorTypeSymbol.prototype.isError = function () { - return true; - }; - - PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullContainerSymbol = (function (_super) { - __extends(PullContainerSymbol, _super); - function PullContainerSymbol(name, kind) { - _super.call(this, name, kind); - this.instanceSymbol = null; - this.assignedValue = null; - this.assignedType = null; - this.assignedContainer = null; - } - PullContainerSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this.assignedValue = symbol; - }; - - PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { - return this.assignedValue; - }; - - PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this.assignedType = type; - }; - - PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this.assignedType; - }; - - PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this.assignedContainer = container; - }; - - PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this.assignedContainer; - }; - - PullContainerSymbol.prototype.hasExportAssignment = function () { - return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; - }; - - PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (!containerSymbol.isAlias() && containerSymbol.type == symbol) { - return true; - } - - var moduleSymbol = containerSymbol; - var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - - PullContainerSymbol.prototype.getInstanceType = function () { - return this.instanceSymbol ? this.instanceSymbol.type : null; - }; - return PullContainerSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerSymbol = PullContainerSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 128 /* TypeAlias */); - this._assignedValue = null; - this._assignedType = null; - this._assignedContainer = null; - this._isUsedAsValue = false; - this._typeUsedExternally = false; - this.retrievingExportAssignment = false; - } - PullTypeAliasSymbol.prototype.typeUsedExternally = function () { - this._resolveDeclaredSymbol(); - return this._typeUsedExternally; - }; - - PullTypeAliasSymbol.prototype.isUsedAsValue = function () { - this._resolveDeclaredSymbol(); - return this._isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function (value) { - this._typeUsedExternally = value; - }; - - PullTypeAliasSymbol.prototype.setIsUsedAsValue = function (value) { - this._isUsedAsValue = value; - - 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.assignedValue = function () { - this._resolveDeclaredSymbol(); - return this._assignedValue; - }; - - PullTypeAliasSymbol.prototype.assignedType = function () { - this._resolveDeclaredSymbol(); - return this._assignedType; - }; - - PullTypeAliasSymbol.prototype.assignedContainer = function () { - this._resolveDeclaredSymbol(); - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { - this._assignedValue = symbol; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (this._assignedValue) { - return this._assignedValue; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { - this._assignedType = type; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedType) { - if (this._assignedType.isAlias()) { - this.retrievingExportAssignment = true; - var sym = this._assignedType.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - } else if (this._assignedType != this._assignedContainer) { - return this._assignedType; - } - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { - this._assignedContainer = container; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this._assignedType) { - return this._assignedType.getMembers(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this._assignedType) { - return this._assignedType.getCallSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this._assignedType) { - return this._assignedType.getConstructSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this._assignedType) { - return this._assignedType.getIndexSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this._assignedType) { - return this._assignedType.findMember(name, true); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedContainer(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { - if (this._assignedType) { - return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); - } - - return TypeScript.sentinelEmptyArray; - }; - return PullTypeAliasSymbol; - })(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) { - _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; - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - return this._constraint; - }; - - PullTypeParameterSymbol.prototype.getCallSignatures = function () { - if (this._constraint) { - return this._constraint.getCallSignatures(); - } - - return _super.prototype.getCallSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getConstructSignatures = function () { - if (this._constraint) { - return this._constraint.getConstructSignatures(); - } - - return _super.prototype.getConstructSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getIndexSignatures = function () { - if (this._constraint) { - return this._constraint.getIndexSignatures(); - } - - return _super.prototype.getIndexSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this._getterSymbol = null; - this._setterSymbol = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - if (!setter) { - return; - } - - this._setterSymbol = setter; - }; - - PullAccessorSymbol.prototype.getSetter = function () { - return this._setterSymbol; - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - if (!getter) { - return; - } - - this._getterSymbol = getter; - }; - - PullAccessorSymbol.prototype.getGetter = function () { - return this._getterSymbol; - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - function getIDForTypeSubstitutions(types) { - 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 + "#"; - } - } - } - - 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]); - } - } - } - - if (structure !== "") { - return "{" + structure + "}"; - } - - 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]); - } - } - - structure += ")" + getIDForTypeSubstitutions([signature.returnType]); - return structure; - } - - (function (GetAllMembersVisiblity) { - GetAllMembersVisiblity[GetAllMembersVisiblity["all"] = 0] = "all"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; - })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); - var GetAllMembersVisiblity = TypeScript.GetAllMembersVisiblity; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CandidateInferenceInfo = (function () { - function CandidateInferenceInfo() { - this.typeParameter = null; - this.isFixed = false; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - if (!this.isFixed) { - this.inferenceCandidates[this.inferenceCandidates.length] = candidate; - } - }; - return CandidateInferenceInfo; - })(); - TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; - - var ArgumentInferenceContext = (function () { - function ArgumentInferenceContext(resolver, argumentsOrParameters) { - 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; - } - } - ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { - return true; - } else { - this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); - return false; - } - }; - - ArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache.release(); - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - }; - - ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.pullSymbolID]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.pullSymbolID] = info; - } - }; - - ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.pullSymbolID]; - }; - - ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { - var info = this.getInferenceInfo(param); - - if (info) { - if (candidate) { - info.addCandidate(candidate); - } - - if (!info.isFixed) { - info.isFixed = fix; - } - } - }; - - ArgumentInferenceContext.prototype.getInferenceArgumentCount = function () { - if (this.fixedParameterTypes) { - return this.fixedParameterTypes.length; - } else { - return this.argumentASTs.nonSeparatorCount(); - } - }; - - 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; - - var results = []; - - var unfit = false; - - 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; - } - - 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 }; - } - } - - return { results: results, unfit: unfit }; - }; - return ArgumentInferenceContext; - })(); - TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; - - var PullContextualTypeContext = (function () { - function PullContextualTypeContext(contextualType, provisional, substitutions) { - this.contextualType = contextualType; - this.provisional = provisional; - this.substitutions = substitutions; - this.provisionallyTypedSymbols = []; - this.hasProvisionalErrors = false; - this.astSymbolMap = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].setUnresolved(); - } - }; - - PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { - if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } - if (typeof fileName === "undefined") { fileName = null; } - this.resolver = resolver; - this.inTypeCheck = inTypeCheck; - this.fileName = fileName; - this.contextStack = []; - this.typeCheckedNodes = null; - this.inBaseTypeResolution = false; - if (inTypeCheck) { - TypeScript.Debug.assert(fileName, "A file name must be provided if you are typechecking"); - this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); - } - } - PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { - if (!this.inProvisionalResolution()) { - this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); - } - }; - - PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { - 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.popContextualType = function () { - var tc = this.contextStack.pop(); - - tc.invalidateProvisionallyTypedSymbols(); - - if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; - } - - return tc; - }; - - PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { - 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]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - if (type.isTypeParameter() && type.getConstraint()) { - type = type.getConstraint(); - } - - var substitution = this.findSubstitution(type); - - return substitution ? substitution : type; - } - - return null; - }; - - PullTypeResolutionContext.prototype.inProvisionalResolution = function () { - return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { - var substitution = this.findSubstitution(type); - - symbol.type = substitution ? substitution : type; - - if (this.contextStack.length && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); - } - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { - if (diagnostic) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; - } else if (this.inTypeCheck && this.resolver) { - this.resolver.semanticInfoChain.addDiagnostic(diagnostic); - } - } - }; - - PullTypeResolutionContext.prototype.typeCheck = function () { - return this.inTypeCheck && !this.inProvisionalResolution(); - }; - - PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { - this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); - }; - - PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - var typeContext = this.contextStack[i]; - if (!typeContext.provisional) { - break; - } - - var symbol = typeContext.getSymbolForAST(ast); - if (symbol) { - return symbol; - } - } - - return null; - }; - return PullTypeResolutionContext; - })(); - TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OverloadApplicabilityStatus; - (function (OverloadApplicabilityStatus) { - OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; - })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - this.diagnosticsFromOverloadResolution = []; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var MemberWithBaseOrigin = (function () { - function MemberWithBaseOrigin(memberSymbol, baseOrigin) { - this.memberSymbol = memberSymbol; - this.baseOrigin = baseOrigin; - } - return MemberWithBaseOrigin; - })(); - - var SignatureWithBaseOrigin = (function () { - function SignatureWithBaseOrigin(signature, baseOrigin) { - this.signature = signature; - this.baseOrigin = baseOrigin; - } - return SignatureWithBaseOrigin; - })(); - - var InheritedIndexSignatureInfo = (function () { - function InheritedIndexSignatureInfo() { - } - 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 = {})); - - function getCompilerReservedName(name) { - var nameText = name.valueText(); - var index = CompilerReservedNames[nameText]; - return CompilerReservedNames[index] ? index : undefined; - } - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this._cachedAnyTypeArgs = null; - this.typeCheckCallBacks = []; - this.postTypeCheckWorkitems = []; - this._cachedFunctionArgumentsSymbol = null; - this.assignableCache = TypeScript.BitMatrix.getBitMatrix(true); - this.subtypeCache = TypeScript.BitMatrix.getBitMatrix(true); - this.identicalCache = TypeScript.BitMatrix.getBitMatrix(true); - } - PullTypeResolver.prototype.cachedArrayInterfaceType = function () { - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); - } - - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getArrayNamedType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); - } - - if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedRegExpInterfaceType; - }; - - 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.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, new TypeScript.TextSpan(0, 0), this.semanticInfoChain); - functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); - this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - } - - return this._cachedFunctionArgumentsSymbol; - }; - - PullTypeResolver.prototype.setTypeChecked = function (ast, context) { - context.setTypeChecked(ast); - }; - - PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { - return context.canTypeCheckAST(ast); - }; - - PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { - if (context && context.inProvisionalResolution()) { - context.setSymbolForAST(ast, symbol); - } else { - this.semanticInfoChain.setSymbolForAST(ast, symbol); - } - }; - - PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { - var symbol = this.semanticInfoChain.getSymbolForAST(ast); - - if (!symbol) { - if (context && context.inProvisionalResolution()) { - symbol = context.getSymbolForAST(ast); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { - if (typeof name === "undefined") { name = null; } - return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = decl.getParentPath(); - - if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) != 0; - var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; - - if (isContainer && containerType) { - if (symbol.anyDeclHasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent) { - var member = null; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - } - - if (parent.kind & 164 /* SomeContainer */) { - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - member = childDecls[0].getSymbol(); - - if (!member) { - member = childDecls[0].getSignatureSymbol(); - } - return this.getExportedMemberSymbol(member, parent); - } - - if ((declSearchKind & 58728539 /* SomeType */) != 0 || (declSearchKind & 68147712 /* SomeValue */) != 0) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, 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) { - var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); - if (typeSymbol) { - return typeSymbol; - } - } else { - var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); - if (valueSymbol) { - return valueSymbol; - } - } - } - } - } - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - var instanceType = null; - var childSymbol = null; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - return childDecls[0].getSymbol(); - } - - 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); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().type; - - var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } else if ((declSearchKind & (58728539 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.kind & 1032192 /* SomeFunction */) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - 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; - } - } - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - - return symbol; - }; - - PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - var declKind = decl.kind; - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = decl.getFunctionExpressionName(); - if (functionExpressionName) { - result.push(decl); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - } - } - - var topLevelDecls = this.semanticInfoChain.topLevelDecls(); - for (var i = 0, n = topLevelDecls.length; i < n; i++) { - var topLevelDecl = topLevelDecls[i]; - if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { - continue; - } - - if (!topLevelDecl.isExternalModule()) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.kind & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - 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 */)) { - return null; - } - - var lhsType = lhs.type; - if (!lhsType) { - return null; - } - - this.resolveDeclaredSymbol(lhsType, context); - - if (lhsType.isContainer() && lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - while (lhsType.isTypeParameter()) { - lhsType = lhsType.getConstraint(); - if (!lhsType) { - return null; - } - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - var memberVisibilty = 2 /* externallyVisible */; - var containerSymbol = lhsType; - if (containerSymbol.kind === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = enclosingDecl.getParentPath(); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { - memberVisibilty = 1 /* internallyVisible */; - break; - } - } - } - } - - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - var members = []; - - if (lhsType.isContainer()) { - var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); - if (exportedAssignedContainerSymbol) { - lhsType = exportedAssignedContainerSymbol; - } - } - - if (lhsType.isTypeParameter()) { - var constraint = lhsType.getConstraint(); - - if (constraint) { - lhsType = constraint; - members = lhsType.getAllMembers(declSearchKind, 2 /* externallyVisible */); - } - } else { - if (lhs.kind == 67108864 /* EnumMember */) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - 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); - } - - 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); - } - } - } - - if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { - members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, 2 /* externallyVisible */)); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { - var originalIdText = idText; - var symbol = null; - - if (TypeScript.isRelative(originalIdText)) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - symbol = this.semanticInfoChain.findExternalModule(path + idText); - } else { - idText = originalIdText; - - symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); - - if (!symbol) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - symbol = this.semanticInfoChain.findExternalModule(path + idText); - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { - if (!symbol || symbol.isResolved || symbol.isTypeReference()) { - return symbol; - } - - if (!context) { - context = new TypeScript.PullTypeResolutionContext(this); - } - - return this.resolveDeclaredSymbolWorker(symbol, context); - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { - if (!symbol || symbol.isResolved) { - return symbol; - } - - if (symbol.inResolution) { - if (!symbol.type && !symbol.isType()) { - symbol.type = this.semanticInfoChain.anyTypeSymbol; - } - - return symbol; - } - - var decls = symbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - var ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return symbol; - } - - if (ast.kind() === 11 /* IdentifierName */ && ast.parent && ast.parent.kind() === 236 /* CatchClause */) { - return symbol; - } - - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(ast); - var resolvedSymbol; - if (TypeScript.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); - } - - if (decl.kind == 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { - symbol.type = resolvedSymbol.type; - symbol.setResolved(); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveOtherDeclarations = function (astName, context) { - 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); - } - } - } - }; - - PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { - var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); - var moduleSymbol = enclosingDecl.getSymbol(); - this.ensureAllSymbolsAreBound(moduleSymbol); - - this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); - this.resolveAST(sourceUnit.moduleElements, false, context); - - if (this.canTypeCheckAST(sourceUnit, context)) { - this.typeCheckSourceUnit(sourceUnit, context); - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.typeCheckSourceUnit = function (sourceUnit, context) { - this.setTypeChecked(sourceUnit, context); - - this.resolveAST(sourceUnit.moduleElements, false, context); - }; - - PullTypeResolver.prototype.resolveEnumDeclaration = function (ast, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - containerSymbol.setResolved(); - - this.resolveOtherDeclarations(ast, context); - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckEnumDeclaration(ast, context); - } - - return containerSymbol; - }; - - PullTypeResolver.prototype.typeCheckEnumDeclaration = function (ast, context) { - 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.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { - var result; - - if (ast.stringLiteral) { - result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckModuleDeclaration(ast, context); - } - - return result; - }; - - PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { - if (containerSymbol) { - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - }; - - PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - this.ensureAllSymbolsAreBound(containerSymbol); - - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, context); - } - - var isLastName = TypeScript.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); - if (isLastName) { - this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); - } else if (sourceUnitAST) { - this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); - } - - containerSymbol.setResolved(); - - if (moduleDeclNameAST) { - this.resolveOtherDeclarations(moduleDeclNameAST, context); - } - - return containerSymbol; - }; - - 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 */) { - this.resolveExportAssignmentStatement(moduleElement, context); - return; - } - } - }; - - PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - var containerSymbol = containerDecl.getSymbol(); - - return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); - }; - - PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { - if (ast.stringLiteral) { - this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - }; - - PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { - this.setTypeChecked(ast, context); - - if (TypeScript.isLastNameOfModule(ast, astName)) { - this.resolveAST(ast.moduleElements, false, context); - } - - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - this.validateVariableDeclarationGroups(containerDecl, context); - - if (ast.stringLiteral) { - if (TypeScript.isRelative(ast.stringLiteral.valueText())) { - this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); - } - } - - if (!TypeScript.moduleIsElided(ast) && !ast.stringLiteral) { - this.checkNameForCompilerGeneratedDeclarationCollision(astName, true, astName, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckModuleDeclaration = function (ast, context) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() == 11 /* IdentifierName */) { - return true; - } else if (term.kind() == 121 /* QualifiedName */) { - var binex = term; - - if (binex.right.kind() == 11 /* IdentifierName */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { - if (!type.isGeneric()) { - return type; - } - - var typeParameters = type.getTypeArgumentsOrTypeParameters(); - - var typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); - } - - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) != null; - - if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - 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++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - var wasInBaseTypeResolution = context.startBaseTypeResolution(); - - if (!typeDeclIsClass && !hasVisited) { - typeDeclSymbol.resetKnownBaseTypeCount(); - } - - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); - if (extendsClause) { - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - - if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - } - } - } - - var implementsClause = TypeScript.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()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); - var implementedType = this.resolveTypeReference(implementedTypeAST, context); - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - - if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addImplementedType(implementedType); - } - } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - - if (wasInBaseTypeResolution) { - typeDeclSymbol.inResolution = false; - - this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() == 131 /* ClassDeclaration */) { - _this.resolveClassDeclaration(classOrInterface, context); - } else { - _this.resolveInterfaceDeclaration(classOrInterface, context); - } - }); - - 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); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - 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); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.type; - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - var parentConstructor = parentType ? parentType.getConstructorMethod() : null; - - if (parentConstructor) { - this.resolveDeclaredSymbol(parentConstructor, context); - var parentConstructorType = parentConstructor.type; - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - - if (!parentConstructSignatures.length) { - parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - parentConstructSignature.returnType = parentType; - parentConstructorType.addConstructSignature(parentConstructSignature); - parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - - var parentTypeParameters = parentConstructorType.getTypeParameters(); - - for (var i = 0; i < parentTypeParameters.length; i++) { - parentConstructSignature.addTypeParameter(parentTypeParameters[i]); - } - - parentConstructSignatures = [parentConstructSignature]; - } - - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.parameters; - - constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - - 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); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - constructorTypeSymbol.addConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructorSignature.addTypeParameter(typeParameters[i]); - } - } - } - - if (!classDeclSymbol.isResolved) { - return classDeclSymbol; - } - - if (parentType) { - var parentConstructorSymbol = parentType.getConstructorMethod(); - - if (parentConstructorSymbol) { - var parentConstructorTypeSymbol = parentConstructorSymbol.type; - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - } - - this.resolveOtherDeclarations(classDeclAST, context); - } - - if (this.canTypeCheckAST(classDeclAST, context)) { - this.typeCheckClassDeclaration(classDeclAST, context); - } - - return classDeclSymbol; - }; - - 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); - }); - } - }; - - PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { - this.setTypeChecked(classDeclAST, context); - - var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - - this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); - this.resolveAST(classDeclAST.classElements, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); - this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); - - if (!classDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { - this.checkThisCaptureVariableCollides(classDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { - var callSignatures = typeSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); - - if (interfaceDeclSymbol.isResolved) { - this.resolveOtherDeclarations(interfaceDeclAST, context); - - if (this.canTypeCheckAST(interfaceDeclAST, context)) { - this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); - } - } - - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { - this.setTypeChecked(interfaceDeclAST, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); - this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); - - if (!interfaceDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(interfaceDeclSymbol, interfaceDecl, context); - } - }; - - PullTypeResolver.prototype.filterSymbol = function (symbol, kind, enclosingDecl, context) { - if (symbol) { - if (symbol.kind & kind) { - return symbol; - } - - if (symbol.isAlias()) { - this.resolveDeclaredSymbol(symbol, context); - - var alias = symbol; - if (kind & 164 /* SomeContainer */) { - return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728539 /* SomeType */) { - return alias.getExportAssignedTypeSymbol(); - } else if (kind & 68147712 /* SomeValue */) { - return alias.getExportAssignedValueSymbol(); - } - } - } - return null; - }; - - PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getMemberSymbol(symbolName, kind, pullTypeSymbol); - - return { - symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), - aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null - }; - }; - - PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { - var rhsName = identifier.valueText(); - if (rhsName.length === 0) { - return null; - } - - var moduleTypeSymbol = moduleSymbol.type; - var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); - var containerSymbol = memberSymbol.symbol; - var valueSymbol = null; - var typeSymbol = null; - var aliasSymbol = null; - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; - aliasSymbol = memberSymbol.aliasSymbol; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - aliasSymbol = containerSymbol; - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return null; - } - - if (!valueSymbol) { - if (moduleTypeSymbol.getInstanceSymbol()) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); - valueSymbol = memberSymbol.symbol; - if (valueSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - } - - if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728539 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); - typeSymbol = memberSymbol.symbol; - if (typeSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); - return null; - } - - if (!typeSymbol && containerSymbol) { - typeSymbol = containerSymbol; - } - - return { - valueSymbol: valueSymbol, - typeSymbol: typeSymbol, - containerSymbol: containerSymbol, - aliasSymbol: aliasSymbol - }; - }; - - 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"); - - var moduleSymbol = null; - var moduleName; - - if (moduleNameExpr.kind() == 121 /* QualifiedName */) { - var dottedNameAST = moduleNameExpr; - var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleContainer) { - moduleName = dottedNameAST.right.valueText(); - - moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; - if (!moduleSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); - } - } - } else { - var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); - var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); - - if (text.length > 0) { - var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); - moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); - if (moduleSymbol) { - this.semanticInfoChain.setSymbolForAST(moduleNameExpr, moduleSymbol); - if (resolvedModuleNameSymbol.isAlias()) { - this.semanticInfoChain.setAliasSymbolForAST(moduleNameExpr, resolvedModuleNameSymbol); - } - } else { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameExpr, TypeScript.DiagnosticCode.Unable_to_resolve_module_reference_0, [valueText]); - } - } - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - - var moduleReference = importStatementAST.moduleReference; - - var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; - - var declPath = enclosingDecl.getParentPath(); - var aliasedType = null; - - if (aliasExpr.kind() === 11 /* IdentifierName */ || aliasExpr.kind() === 14 /* StringLiteral */) { - var moduleSymbol = this.resolveModuleReference(importDecl, aliasExpr, enclosingDecl, context, declPath); - if (moduleSymbol) { - aliasedType = moduleSymbol.type; - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); - if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { - var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); - var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); - var instanceSymbol = aliasedType.getInstanceSymbol(); - - 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; - } - } else if (aliasExpr.kind() == 121 /* QualifiedName */) { - var importDeclSymbol = importDecl.getSymbol(); - var dottedNameAST = aliasExpr; - var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleSymbol) { - var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); - if (identifierResolution) { - importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); - 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); - } - - return aliasedType; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasedType = null; - - if (importDeclSymbol.isResolved) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - var declPath = enclosingDecl.getParentPath(); - - aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); - - 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; - } - } else { - aliasedType = this.resolveInternalModuleReference(importStatementAST, context); - } - - 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.isContainer()) { - importDeclSymbol.setAssignedContainerSymbol(aliasedType); - } - importDeclSymbol.setAssignedTypeSymbol(aliasedType); - - this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); - } - - importDeclSymbol.setResolved(); - - this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(importDeclSymbol.assignedType(), context); - this.resolveDeclaredSymbol(importDeclSymbol.assignedContainer(), context); - - if (this.canTypeCheckAST(importStatementAST, context)) { - this.typeCheckImportDeclaration(importStatementAST, context); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { - var _this = this; - this.setTypeChecked(importStatementAST, context); - - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (this.compilationSettings.noResolve()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); - } - - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - if (enclosingDecl.kind === 32 /* DynamicModule */) { - var ast = TypeScript.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)); - } - } - } - } - - var checkPrivacy; - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind == 32 /* DynamicModule */) { - checkPrivacy = true; - } - } else { - checkPrivacy = true; - } - - if (checkPrivacy) { - var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); - - this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { - var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - - 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; - - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - - if (valueSymbol) { - this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { - var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - } - - if (getCompilerReservedName(importStatementAST.identifier)) { - this.postTypeCheckWorkitems.push(importStatementAST); - } - }; - - PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - if (TypeScript.importDeclarationIsElided(importStatementAST, this.semanticInfoChain)) { - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context, true); - } - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { - var id = exportAssignmentAST.identifier.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && parentSymbol.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); - return this.semanticInfoChain.anyTypeSymbol; - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - - var aliasSymbol = containerSymbol; - var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(true); - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728539 /* SomeType */); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (valueSymbol) { - parentSymbol.setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - parentSymbol.setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - parentSymbol.setExportAssignedContainerSymbol(containerSymbol); - } - - this.resolveDeclaredSymbol(valueSymbol, context); - this.resolveDeclaredSymbol(typeSymbol, context); - this.resolveDeclaredSymbol(containerSymbol, context); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - var funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); - } - } - - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.setTypeChecked(funcDeclAST, context); - this.typeCheckFunctionOverloads(funcDeclAST, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.getType(argDeclAST), context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = 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 (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [paramSymbol.type])); - } else { - context.setTypeInContext(paramSymbol, paramSymbol.type); - } - } 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()])); - } - } - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - var contextualType = contextParam && contextParam.type; - var isImplicitAny = false; - - if (typeExpr) { - var typeRef = this.resolveTypeReference(typeExpr, context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); - typeRef = this.getNewErrorTypeSymbol(); - } - - contextualType = typeRef || contextualType; - } - if (contextualType) { - context.setTypeInContext(paramSymbol, contextualType); - } else if (paramSymbol.isVarArg && this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); - isImplicitAny = true; - } - - var canTypeCheckAST = this.canTypeCheckAST(argDeclAST, context); - if (equalsValueClause && (canTypeCheckAST || !contextualType)) { - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - } - - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - } - - if (!initExprSymbol || !initExprSymbol.type) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); - - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); - } - } else { - var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.widenType(initTypeSymbol, equalsValueClause, context)); - isImplicitAny = initTypeSymbol !== paramSymbol.type; - } else { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); - } - } - } - } - } - - if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - isImplicitAny = true; - } - - if (isImplicitAny && this.compilationSettings.noImplicitAny()) { - var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); - if (functionExpressionName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); - } - } - - if (canTypeCheckAST) { - this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context, immediateThisCheck) { - var compilerReservedName = getCompilerReservedName(name); - if (compilerReservedName) { - switch (compilerReservedName) { - case 1 /* _this */: - if (immediateThisCheck) { - this.checkThisCaptureVariableCollides(astWithName, isDeclaration, context); - } else { - this.postTypeCheckWorkitems.push(astWithName); - } - return; - - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; - - case 3 /* arguments */: - this.checkArgumentsCollides(astWithName, context); - return; - - case 4 /* _i */: - if (isDeclaration) { - this.checkIndexOfRestArgumentInitializationCollides(astWithName, 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()); - } - } - }; - - PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { - var enclosingAST = this.getASTForDecl(someFunctionDecl); - var nodeType = enclosingAST.kind(); - - 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); - } 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 */) { - var constructorDeclaration = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.getParentDecl().flags, 8 /* Ambient */) && constructorDeclaration.block && TypeScript.lastParameterIsRest(constructorDeclaration.parameterList); - } else if (nodeType == 218 /* ParenthesizedArrowFunctionExpression */) { - var arrowFunctionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(arrowFunctionExpression.callSignature.parameterList); - } else if (nodeType === 222 /* FunctionExpression */) { - var functionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); - } - - return false; - }; - - PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); - } - } - } - }; - - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, context) { - if (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)); - } - } - } - }; - - PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(name); - if (TypeScript.isAnyNameOfModule(enclosingModule, name)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - if (enclosingDecl && enclosingDecl.kind == 32 /* DynamicModule */) { - var decl = this.semanticInfoChain.getDeclForAST(ast); - - if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - var nameText = name.valueText(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); - } - } - }; - - PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { - var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); - TypeScript.Debug.assert(interfaceDecl); - - var interfaceSymbol = interfaceDecl.getSymbol(); - TypeScript.Debug.assert(interfaceSymbol); - - if (objectType.typeMembers) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = objectType.typeMembers; - - for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { - memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); - memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); - - memberType = memberSymbol.type; - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - if (this.canTypeCheckAST(objectType, context)) { - this.typeCheckObjectTypeTypeReference(objectType, context); - } - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { - this.setTypeChecked(objectType, context); - var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); - var objectTypeSymbol = objectTypeDecl.getSymbol(); - - this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); - }; - - PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { - return this.resolveTypeReference(typeAnnotation.type, context); - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { - if (typeRef === null) { - return null; - } - - TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); - - var aliasType = null; - var type = this.computeTypeReferenceSymbol(typeRef, context); - - if (type.kind == 4 /* Container */) { - var container = type; - var instanceSymbol = container.getInstanceSymbol(); - - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind == 32768 /* ConstructorMethod */)) { - type = instanceSymbol.type.getAssociatedContainerType(); - } - } - - if (type && type.isAlias()) { - aliasType = type; - type = aliasType.getExportAssignedTypeSymbol(); - } - - if (type && !type.isGeneric()) { - if (aliasType) { - this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); - } - } - - if (type && !type.isError()) { - if ((type.kind & 58728539 /* 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 { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); - } - } - } - - if (this.canTypeCheckAST(typeRef, context)) { - this.setTypeChecked(typeRef, context); - } - - return type; - }; - - PullTypeResolver.prototype.computeTypeReferenceSymbol = function (term, context) { - switch (term.kind()) { - case 60 /* AnyKeyword */: - return this.semanticInfoChain.anyTypeSymbol; - case 61 /* BooleanKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - case 67 /* NumberKeyword */: - return this.semanticInfoChain.numberTypeSymbol; - case 69 /* StringKeyword */: - return this.semanticInfoChain.stringTypeSymbol; - case 41 /* VoidKeyword */: - return this.semanticInfoChain.voidTypeSymbol; - } - - var typeDeclSymbol = null; - - if (term.kind() === 11 /* IdentifierName */) { - typeDeclSymbol = this.resolveTypeNameExpression(term, context); - } else if (term.kind() === 123 /* FunctionType */) { - var functionType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); - } else if (term.kind() === 125 /* ConstructorType */) { - var constructorType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); - } else if (term.kind() === 122 /* ObjectType */) { - typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); - } else if (term.kind() === 126 /* GenericType */) { - typeDeclSymbol = this.resolveGenericTypeReference(term, context); - } else if (term.kind() === 121 /* QualifiedName */) { - typeDeclSymbol = this.resolveQualifiedName(term, context); - } else if (term.kind() === 14 /* StringLiteral */) { - 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()); - typeDeclSymbol.addDeclaration(decl); - } else if (term.kind() === 127 /* TypeQuery */) { - var typeQuery = term; - - var typeQueryTerm = typeQuery.name; - - var valueSymbol = this.resolveAST(typeQueryTerm, false, context); - - if (valueSymbol && valueSymbol.isAlias()) { - if (valueSymbol.assignedValue()) { - valueSymbol = valueSymbol.assignedValue(); - } else { - var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); - valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; - } - } - - if (valueSymbol) { - typeDeclSymbol = valueSymbol.type; - } 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; - } else { - throw TypeScript.Errors.invalidOperation("unknown type"); - } - - if (!typeDeclSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); - return this.getNewErrorTypeSymbol(); - } - - if (typeDeclSymbol.isError()) { - return typeDeclSymbol; - } - - if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); - typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); - } - - return typeDeclSymbol; - }; - - 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); - }; - - PullTypeResolver.prototype.resolveMemberVariableDeclaration = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.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); - }; - - PullTypeResolver.prototype.resolveVariableDeclarator = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveParameterList = function (list, context) { - return this.resolveSeparatedList(list.parameters, context); - }; - - PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { - var enumDeclaration = enumElement.parent.parent; - var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); - var symbol = decl.getSymbol(); - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { - if (this.canTypeCheckAST(clause, context)) { - this.setTypeChecked(clause, context); - } - - return this.resolveAST(clause.value, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - - if (enclosingDecl && decl.kind == 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved) { - var declType = declSymbol.type; - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved) { - valSymbol.type = declType; - valSymbol.setResolved(); - } - } - } else { - if (declSymbol.inResolution) { - declSymbol.type = this.semanticInfoChain.anyTypeSymbol; - declSymbol.setResolved(); - return declSymbol; - } - - if (!declSymbol.type || !declSymbol.type.isError()) { - declSymbol.startResolving(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - if (!hasTypeExpr) { - this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - } - - if (!(hasTypeExpr || init)) { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.isVarArg) { - defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.type = defaultType; - } - } - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - } - } - - if (this.canTypeCheckAST(varDeclOrParameter, context)) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (varDeclOrParameter.kind() === 243 /* EnumElement */) { - var result = this.getEnumTypeSymbol(varDeclOrParameter, context); - declSymbol.type = result; - return result; - } - - if (!typeExpr) { - return null; - } - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; - - var typeExprSymbol = this.resolveTypeReference(typeExpr, context); - - if (!typeExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - declSymbol.type = this.getNewErrorTypeSymbol(); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, typeExprSymbol); - } - } else { - if (typeExprSymbol == this.semanticInfoChain.anyTypeSymbol) { - decl.setFlag(16777216 /* IsAnnotatedWithAny */); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - typeExprSymbol = typeExprSymbol.type; - - if (typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { - var instanceSymbol = typeExprSymbol.getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(); - } else { - typeExprSymbol = instanceSymbol.type; - } - } - } - } 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(); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.type = typeExprSymbol; - } - - if (typeExprSymbol.kind == 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { - typeExprSymbol.setFunctionSymbol(declSymbol); - } - } - - return typeExprSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { - if (!init) { - return null; - } - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - if (typeExprSymbol) { - context.pushContextualType(typeExprSymbol, context.inProvisionalResolution(), null); - } - - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; - - var initExprSymbol = this.resolveAST(init, typeExprSymbol != null, context); - - if (typeExprSymbol) { - context.popContextualType(); - } - - if (!initExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - } else { - var initTypeSymbol = initExprSymbol.type; - var widenedInitTypeSymbol = this.widenType(initTypeSymbol, init.value, context); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, widenedInitTypeSymbol); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); - } - - if (this.compilationSettings.noImplicitAny()) { - 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; - }; - - PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.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); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckParameter = function (parameter, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var _this = this; - this.setTypeChecked(varDeclOrParameter, context); - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - - if (hasTypeExpr || init) { - if (typeExprSymbol && typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = typeExprSymbol.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol; - } - } - } - - initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); - } - } - } - } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = 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])); - } else if (wrapperDecl.kind === 65536 /* Method */) { - var parentDecl = wrapperDecl.getParentDecl(); - - if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); - } 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 */) { - 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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } - } - } - - 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)); - } - } - 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 */)) { - this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); - } - }; - - PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { - return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; - }; - - 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 */) { - var enclosingAST = this.getASTForDecl(enclosingDecl); - if (enclosingAST.kind() !== 218 /* ParenthesizedArrowFunctionExpression */ && enclosingAST.kind() !== 219 /* SimpleArrowFunctionExpression */) { - var block = enclosingDecl.kind == 65536 /* Method */ ? enclosingAST.block : enclosingAST.block; - if (!block) { - return; - } - } - } - - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - if (parents.length) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); - } - } - }; - - PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { - if (isDeclaration) { - var decl = this.semanticInfoChain.getDeclForAST(_thisAST); - if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - return; - } - } - - var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.isAnyNameOfModule(enclosingModule, _thisAST)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - var declPath = enclosingDecl.getParentPath(); - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - continue; - } - - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); - } - break; - } - } - }; - - PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { - this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - var typeParameterDecl = this.semanticInfoChain.getDeclForAST(typeParameterAST); - var typeParameterSymbol = typeParameterDecl.getSymbol(); - - if (typeParameterSymbol.isResolved || typeParameterSymbol.inResolution) { - if (typeParameterSymbol.isResolved && this.canTypeCheckAST(typeParameterAST, context)) { - this.typeCheckTypeParameterDeclaration(typeParameterAST, context); - } - return typeParameterSymbol; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - 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); - }; - - PullTypeResolver.prototype.resolveConstraint = function (constraint, context) { - if (this.canTypeCheckAST(constraint, context)) { - this.setTypeChecked(constraint, context); - } - - return this.resolveTypeReference(constraint.type, context); - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatementsExpressions = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, walker) { - var go = true; - - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); - go = false; - break; - - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, walker) { - switch (ast.kind()) { - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - if (block) { - TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - } else { - returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - } - - if (!returnStatementsExpressions.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var returnExpressionSymbols = []; - var returnExpressions = []; - - for (var i = 0; i < returnStatementsExpressions.length; i++) { - var returnExpression = returnStatementsExpressions[i].expression; - if (returnExpression) { - var returnType = this.resolveAST(returnExpression, useContextualType, context).type; - - if (returnType.isError()) { - signature.returnType = returnType; - return; - } else { - if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { - this.setSymbolForAST(returnExpression.parent, returnType, context); - } - } - - returnExpressionSymbols.push(returnType); - returnExpressions.push(returnExpression); - } - } - - if (!returnExpressionSymbols.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].type; - } - }; - - var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); - 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); - signature.returnType = newReturnType; - - if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); - } - - if (this.compilationSettings.noImplicitAny()) { - if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { - var functionName = enclosingDecl.name; - if (functionName == "") { - functionName = enclosingDecl.getFunctionExpressionName(); - } - - if (functionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } - - if (!functionSymbol.type && functionSymbol.isAccessor()) { - functionSymbol.type = signature.returnType; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - 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); - } - } - - 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)); - } 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)); - } - } - } - - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { - var _this = this; - if (constructorDecl.block) { - var foundSuperCall = false; - var pre = function (ast, walker) { - if (_this.isSuperInvocationExpression(ast)) { - foundSuperCall = true; - walker.options.stopWalking = true; - } - }; - - TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); - return foundSuperCall; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckFunctionExpression = function (funcDecl, context) { - this.typeCheckAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.getType(funcDecl), funcDecl.block, null, context); - }; - - PullTypeResolver.prototype.typeCheckCallSignature = function (funcDecl, context) { - this.typeCheckFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.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); - }; - - PullTypeResolver.prototype.typeCheckFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(parameters, false, context); - - this.resolveAST(block, false, context); - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.Parameters.fromParameterList(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])); - } - } - - if (funcDecl.kind === 16384 /* Function */) { - this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); - } - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.typeCheckIndexSignature = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - this.resolveAST(funcDeclAST.parameter, false, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameter(funcDeclAST.parameter), TypeScript.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 stringIndexSignature = allIndexSignatures.stringSignature; - var numberIndexSignature = allIndexSignatures.numericSignature; - var isNumericIndexer = numberIndexSignature === signature; - - 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)) { - 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])); - } 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)])); - } - } - } - - var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); - for (var i = 0; i < allMembers.length; i++) { - var member = allMembers[i]; - var name = member.name; - if (name || (member.kind === 4096 /* Property */ && name === "")) { - if (!allMembers[i].isResolved) { - _this.resolveDeclaredSymbol(allMembers[i], context); - } - - if (parentSymbol !== allMembers[i].getContainer()) { - var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); - var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; - var onlyStringIndexerIsPresent = !numberIndexSignature; - - if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { - var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsSubtypeOfTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { - _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); - } - } - } - } - } - }); - }; - - PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { - this.checkThisCaptureVariableCollides(funcDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { - var returnTypeSymbol = null; - - if (returnTypeAnnotation) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - } else { - var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } - - return returnTypeSymbol; - }; - - 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); - }; - - PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.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); - }; - - PullTypeResolver.prototype.resolveMethodSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.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); - }; - - 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); - }; - - PullTypeResolver.prototype.resolveSimpleArrowFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, null, TypeScript.Parameters.fromIdentifier(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); - }; - - PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - return funcSymbol; - } - - if (!signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (signature.isGeneric()) { - if (funcSymbol) { - funcSymbol.type.setHasGenericSignature(); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveIndexSignature(ast.indexSignature, context); - }; - - PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - return funcSymbol; - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.getType(funcDeclAST), context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameter) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - this.resolveParameter(funcDeclAST.parameter, context); - context.inTypeCheck = prevInTypeCheck; - } - - if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } 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) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - return funcSymbol; - } - - if (isConstructor && !signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (returnTypeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { - if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { - 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; - if (funcDeclASTName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } - } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { - if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.getType(getterFunctionDeclarationAst), context); - } - - return null; - }; - - 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 null; - }; - - PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - - if (accessorSymbol.inResolution) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - accessorSymbol.setResolved(); - - return accessorSymbol; - } - - if (accessorSymbol.isResolved) { - if (!accessorSymbol.type) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else { - var getterSymbol = accessorSymbol.getGetter(); - var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; - var hasGetter = getterSymbol !== null; - - var setterSymbol = accessorSymbol.getSetter(); - var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; - var hasSetter = setterSymbol !== null; - - var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); - var getterHasTypeAnnotation = getterAnnotatedType !== null; - - var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); - var setterHasTypeAnnotation = setterAnnotatedType !== null; - - accessorSymbol.startResolving(); - - if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); - } - - if (hasSetter) { - setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); - } - - if (hasGetter && hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - var getterSig = getterSymbol.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { - getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; - getterSig.returnType = setterSuppliedTypeSymbol; - } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { - setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; - - if (setterHasParameters) { - setterParameters[0].type = getterSuppliedTypeSymbol; - } - } - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { - accessorSymbol.type = this.getNewErrorTypeSymbol(); - } else { - accessorSymbol.type = getterSuppliedTypeSymbol; - } - } else if (hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - - accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; - } else { - var getterSig = getterSymbol.type.getCallSignatures()[0]; - accessorSymbol.type = getterSig.returnType; - } - - accessorSymbol.setResolved(); - } - - if (this.canTypeCheckAST(funcDeclAst, context)) { - this.typeCheckAccessorDeclaration(funcDeclAst, context); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { - this.setTypeChecked(funcDeclAst, context); - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - var getterSymbol = accessorSymbol.getGetter(); - var setterSymbol = accessorSymbol.getSetter(); - - var isGetter = funcDeclAst.kind() == 139 /* GetAccessor */; - if (isGetter) { - var getterFunctionDeclarationAst = funcDeclAst; - context.pushContextualType(getterSymbol.type, context.inProvisionalResolution(), null); - this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popContextualType(); - } else { - var setterFunctionDeclarationAst = funcDeclAst; - this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); - } - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.type; - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return getterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - signature.setResolved(); - - return getterSymbol; - } - - signature.startResolving(); - - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - if (!setterAnnotatedType) { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } else { - signature.returnType = setterAnnotatedType; - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return getterSymbol; - }; - - PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - if (getter && setter) { - var getterAST = getter.getDeclarations()[0].ast(); - var setterAST = setter.getDeclarations()[0].ast(); - - if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { - var setterSig = setter.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - - var getter = accessorSymbol.getGetter(); - var getterSig = getter.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterParameters[0].type; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); - } - } - } - }; - - PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - 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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); - } - - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); - var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - 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); - }; - - PullTypeResolver.hasSetAccessorParameterTypeAnnotation = function (setAccessor) { - return setAccessor.parameterList && setAccessor.parameterList.parameters.nonSeparatorCount() > 0 && setAccessor.parameterList.parameters.nonSeparatorAt(0).typeAnnotation != null; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.type; - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return setterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - signature.setResolved(); - return setterSymbol; - } - - signature.startResolving(); - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - } - - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - - if (signature.hasAGenericParameter) { - setterTypeSymbol.setHasGenericSignature(); - } - - if (!hadError) { - signature.setResolved(); - } - } - - return setterSymbol; - }; - - PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; - - var getter = accessorSymbol.getGetter(); - - var funcNameAST = funcDeclAST.propertyName; - - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); - var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - if (getterIsPrivate != setterIsPrivate) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); - } - - this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); - } else { - if (this.compilationSettings.noImplicitAny()) { - var setterFunctionDeclarationAst = funcDeclAST; - 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); - }; - - PullTypeResolver.prototype.resolveList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.childCount(); i < n; i++) { - this.resolveAST(list.childAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.resolveAST(list.nonSeparatorAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLogicalOperation(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { - this.setTypeChecked(binex, context); - - var leftType = this.resolveAST(binex.left, false, context).type; - var rightType = this.resolveAST(binex.right, false, context).type; - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(binex); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ - TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), - leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); - } - }; - - PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.operand, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckUnaryArithmeticOperation(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckPostfixUnaryExpression(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { - return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); - }; - - PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - if (nodeType == 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { - return; - } - - TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { - if (this.canTypeCheckAST(binaryExpression, context)) { - this.typeCheckBinaryArithmeticExpression(binaryExpression, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); - - var lhsType = lhsSymbol.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } - - if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } - - var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); - var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); - - if (!rhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!lhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (lhsIsFit && rhsIsFit) { - switch (binaryExpression.kind()) { - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - if (!this.isReference(binaryExpression.left, lhsSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); - } - } - }; - - PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInstanceOfExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); - var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - var isValidRHS = this.isAnyOrEquivalent(rhsType) || this.typeIsSubtypeOfFunction(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)); - } - }; - - PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { - if (this.canTypeCheckAST(commaExpression, context)) { - this.setTypeChecked(commaExpression, context); - - this.resolveAST(commaExpression.left, false, context); - } - - var rhsType = this.resolveAST(commaExpression.right, false, context).type; - - return this.resolveAST(commaExpression.right, false, context).type; - }; - - PullTypeResolver.prototype.resolveInExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; - - var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); - - if (!isValidLHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); - } - - 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)); - } - }; - - PullTypeResolver.prototype.resolveForStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.variableDeclaration, false, context); - this.resolveAST(ast.initializer, false, context); - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.incrementor, false, context); - this.resolveAST(ast.statement, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { - if (this.canTypeCheckAST(forInStatement, context)) { - this.typeCheckForInStatement(forInStatement, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - 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)); - } - - var varSym = this.getSymbolForAST(varDecl, context); - } - - 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)); - } - - 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)); - } - - this.resolveAST(forInStatement.statement, false, context); - }; - - PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWhileStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckDoStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckIfStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - this.resolveAST(ast.elseClause, false, context); - }; - - PullTypeResolver.prototype.resolveElseClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckElseClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveBlock = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.statements, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declaration, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declarators, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWithStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var withStatement = ast; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); - }; - - PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckTryStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var tryStatement = ast; - - this.resolveAST(tryStatement.block, false, context); - this.resolveAST(tryStatement.catchClause, false, context); - this.resolveAST(tryStatement.finallyClause, false, context); - }; - - PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckCatchClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - - var catchDecl = this.semanticInfoChain.getDeclForAST(ast); - this.validateVariableDeclarationGroups(catchDecl, context); - }; - - PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckFinallyClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - }; - - PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - while (enclosingDecl) { - if (enclosingDecl.kind & 1032192 /* SomeFunction */) { - return enclosingDecl; - } - - enclosingDecl = enclosingDecl.getParentDecl(); - } - - return null; - }; - - PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var isContextuallyTyped = false; - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); - if (returnTypeAnnotationSymbol) { - isContextuallyTyped = true; - context.pushContextualType(returnTypeAnnotationSymbol, context.inProvisionalResolution(), null); - } - } 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 currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - isContextuallyTyped = true; - context.pushContextualType(currentContextualTypeReturnTypeSymbol, context.inProvisionalResolution(), null); - } - } - } - } - - var result = this.resolveAST(expression, isContextuallyTyped, context).type; - if (isContextuallyTyped) { - context.popContextualType(); - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { - if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { - var classDecl = enclosingFunction.getParentDecl(); - if (classDecl) { - var classSymbol = classDecl.getSymbol(); - this.resolveDeclaredSymbol(classSymbol, context); - - var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); - if (!isAssignable) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); - } - } - } - - if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); - } - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); - if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { - var signatureSymbol = enclosingFunction.getSignatureSymbol(); - var sigReturnType = signatureSymbol.returnType; - - if (expressionType && sigReturnType) { - 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); - - var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); - } - } - } - } - } - }; - - PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { - var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var returnType = this.getSymbolForAST(returnAST, context); - var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); - if (!returnType || canTypeCheckAST) { - var returnExpr = returnAST.expression; - - var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); - - if (!returnType) { - returnType = resolvedReturnType; - this.setSymbolForAST(returnAST, resolvedReturnType, context); - } - - if (returnExpr && canTypeCheckAST) { - this.setTypeChecked(returnExpr, context); - this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); - } - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSwitchStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var expressionType = this.resolveAST(ast.expression, false, context).type; - - for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { - var switchClause = ast.switchClauses.childAt(i); - if (switchClause.kind() === 233 /* CaseSwitchClause */) { - var caseSwitchClause = switchClause; - - var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; - this.resolveAST(caseSwitchClause.statements, false, context); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); - } - } - } else { - var defaultSwitchClause = switchClause; - this.resolveAST(defaultSwitchClause.statements, false, context); - } - } - }; - - PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLabeledStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var labelIdentifier = ast.identifier.valueText(); - - 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])); - } - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { - switch (statement.kind()) { - case 160 /* LabeledStatement */: - return this.labelIsOnContinuableConstruct(statement.statement); - - case 158 /* WhileStatement */: - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 161 /* DoStatement */: - return true; - - default: - return false; - } - }; - - PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckContinueStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.isIterationStatement = function (ast) { - switch (ast.kind()) { - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 158 /* WhileStatement */: - case 161 /* DoStatement */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { - switch (ast.kind()) { - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 129 /* FunctionDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 241 /* FunctionPropertyAssignment */: - case 137 /* ConstructorDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.inSwitchStatement = function (ast) { - while (ast) { - if (ast.kind() === 151 /* SwitchStatement */) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inIterationStatement = function (ast) { - while (ast) { - if (this.isIterationStatement(ast)) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { - var result = []; - - ast = ast.parent; - while (ast) { - if (ast.kind() === 160 /* LabeledStatement */) { - var labeledStatement = ast; - if (breakable) { - result.push(labeledStatement.identifier.valueText()); - } else { - if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement.identifier.valueText()); - } - } - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - break; - } - - ast = ast.parent; - } - - return result; - }; - - 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)); - } else if (ast.identifier) { - var continuableLabels = this.getEnclosingLabels(ast, false, false); - - if (!TypeScript.ArrayUtilities.contains(continuableLabels, ast.identifier.valueText())) { - var continuableLabels = this.getEnclosingLabels(ast, false, true); - - if (TypeScript.ArrayUtilities.contains(continuableLabels, 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)); - } - } - } - }; - - PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckBreakStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - if (ast.identifier) { - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - if (!TypeScript.ArrayUtilities.contains(breakableLabels, ast.identifier.valueText())) { - var breakableLabels = this.getEnclosingLabels(ast, true, true); - if (TypeScript.ArrayUtilities.contains(breakableLabels, 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)); - } - }; - - PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { - if (!ast) { - return; - } - - var symbol = this.getSymbolForAST(ast, context); - if (symbol && symbol.isResolved) { - this.typeCheckAST(ast, isContextuallyTyped, context); - return symbol; - } - - var nodeType = ast.kind(); - - switch (nodeType) { - case 124 /* ArrayType */: - case 126 /* GenericType */: - case 122 /* ObjectType */: - case 127 /* TypeQuery */: - case 125 /* ConstructorType */: - case 123 /* FunctionType */: - return this.resolveTypeReference(ast, context); - - case 1 /* List */: - return this.resolveList(ast, context); - - case 2 /* SeparatedList */: - return this.resolveSeparatedList(ast, context); - - case 120 /* SourceUnit */: - return this.resolveSourceUnit(ast, context); - - case 132 /* EnumDeclaration */: - return this.resolveEnumDeclaration(ast, context); - - case 130 /* ModuleDeclaration */: - return this.resolveModuleDeclaration(ast, context); - - case 128 /* InterfaceDeclaration */: - return this.resolveInterfaceDeclaration(ast, context); - - case 131 /* ClassDeclaration */: - return this.resolveClassDeclaration(ast, context); - - case 224 /* VariableDeclaration */: - return this.resolveVariableDeclarationList(ast, context); - - case 136 /* MemberVariableDeclaration */: - return this.resolveMemberVariableDeclaration(ast, context); - - case 225 /* VariableDeclarator */: - return this.resolveVariableDeclarator(ast, context); - - case 141 /* PropertySignature */: - return this.resolvePropertySignature(ast, context); - - case 227 /* ParameterList */: - return this.resolveParameterList(ast, context); - - case 242 /* Parameter */: - return this.resolveParameter(ast, context); - - case 243 /* EnumElement */: - return this.resolveEnumElement(ast, context); - - case 232 /* EqualsValueClause */: - return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); - - case 238 /* TypeParameter */: - return this.resolveTypeParameterDeclaration(ast, context); - - case 239 /* Constraint */: - return this.resolveConstraint(ast, context); - - 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); - - case 241 /* FunctionPropertyAssignment */: - 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); - - case 121 /* QualifiedName */: - return this.resolveQualifiedName(ast, context); - - case 137 /* ConstructorDeclaration */: - return this.resolveConstructorDeclaration(ast, context); - - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return this.resolveAccessorDeclaration(ast, context); - - case 138 /* IndexMemberDeclaration */: - return this.resolveIndexMemberDeclaration(ast, context); - - case 144 /* IndexSignature */: - return this.resolveIndexSignature(ast, context); - - case 135 /* MemberFunctionDeclaration */: - return this.resolveMemberFunctionDeclaration(ast, context); - - case 142 /* CallSignature */: - return this.resolveCallSignature(ast, context); - - case 143 /* ConstructSignature */: - return this.resolveConstructSignature(ast, context); - - case 145 /* MethodSignature */: - return this.resolveMethodSignature(ast, context); - - case 129 /* FunctionDeclaration */: - return this.resolveAnyFunctionDeclaration(ast, context); - - case 222 /* FunctionExpression */: - return this.resolveFunctionExpression(ast, isContextuallyTyped, context); - - case 219 /* SimpleArrowFunctionExpression */: - return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 214 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - - case 35 /* ThisKeyword */: - return this.resolveThisExpression(ast, context); - - case 50 /* SuperKeyword */: - return this.resolveSuperExpression(ast, context); - - case 213 /* InvocationExpression */: - return this.resolveInvocationExpression(ast, context); - - case 216 /* ObjectCreationExpression */: - return this.resolveObjectCreationExpression(ast, context); - - 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; - - case 14 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 32 /* NullKeyword */: - return this.semanticInfoChain.nullTypeSymbol; - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 172 /* VoidExpression */: - return this.resolveVoidExpression(ast, context); - - case 174 /* AssignmentExpression */: - return this.resolveAssignmentExpression(ast, context); - - case 167 /* LogicalNotExpression */: - return this.resolveLogicalNotExpression(ast, context); - - case 193 /* NotEqualsWithTypeConversionExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 197 /* GreaterThanExpression */: - return this.resolveLogicalOperation(ast, context); - - case 208 /* AddExpression */: - case 175 /* AddAssignmentExpression */: - return this.resolveBinaryAdditionOperation(ast, context); - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.resolveUnaryArithmeticOperation(ast, context); - - case 210 /* PostIncrementExpression */: - case 211 /* PostDecrementExpression */: - return this.resolvePostfixUnaryExpression(ast, context); - - case 209 /* SubtractExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 189 /* BitwiseOrExpression */: - case 191 /* BitwiseAndExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - return this.resolveBinaryArithmeticExpression(ast, context); - - case 221 /* ElementAccessExpression */: - return this.resolveElementAccessExpression(ast, context); - - case 187 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); - - case 188 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, context); - - case 171 /* TypeOfExpression */: - return this.resolveTypeOfExpression(ast, context); - - case 157 /* ThrowStatement */: - return this.resolveThrowStatement(ast, context); - - case 170 /* DeleteExpression */: - return this.resolveDeleteExpression(ast, context); - - case 186 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, isContextuallyTyped, context); - - case 12 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 217 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, context); - - case 149 /* ExpressionStatement */: - return this.resolveExpressionStatement(ast, context); - - case 200 /* InstanceOfExpression */: - return this.resolveInstanceOfExpression(ast, context); - - case 173 /* CommaExpression */: - return this.resolveCommaExpression(ast, context); - - 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); - } - - return this.semanticInfoChain.anyTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { - if (!this.canTypeCheckAST(ast, context)) { - return; - } - - var nodeType = ast.kind(); - switch (nodeType) { - case 120 /* SourceUnit */: - this.typeCheckSourceUnit(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.typeCheckEnumDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.typeCheckModuleDeclaration(ast, context); - return; - - case 128 /* InterfaceDeclaration */: - this.typeCheckInterfaceDeclaration(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.typeCheckClassDeclaration(ast, context); - return; - - case 243 /* EnumElement */: - this.typeCheckEnumElement(ast, context); - return; - - case 136 /* MemberVariableDeclaration */: - this.typeCheckMemberVariableDeclaration(ast, context); - return; - - case 225 /* VariableDeclarator */: - this.typeCheckVariableDeclarator(ast, context); - return; - - case 141 /* PropertySignature */: - this.typeCheckPropertySignature(ast, context); - return; - - case 242 /* Parameter */: - this.typeCheckParameter(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.typeCheckImportDeclaration(ast, context); - return; - - case 215 /* ObjectLiteralExpression */: - this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 241 /* FunctionPropertyAssignment */: - this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); - return; - - case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - this.resolveTypeNameExpression(ast, context); - } else { - this.resolveNameExpression(ast, context); - } - return; - - case 212 /* MemberAccessExpression */: - this.resolveMemberAccessExpression(ast, context); - return; - - case 121 /* QualifiedName */: - this.resolveQualifiedName(ast, context); - return; - - case 222 /* FunctionExpression */: - this.typeCheckFunctionExpression(ast, context); - break; - - case 144 /* IndexSignature */: - this.typeCheckIndexSignature(ast, context); - break; - - case 142 /* CallSignature */: - this.typeCheckCallSignature(ast, context); - break; - - case 143 /* ConstructSignature */: - this.typeCheckConstructSignature(ast, context); - break; - - 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); - return; - } - - case 219 /* SimpleArrowFunctionExpression */: - this.typeCheckSimpleArrowFunctionExpression(ast, context); - return; - - case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, context); - return; - - case 214 /* ArrayLiteralExpression */: - this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 213 /* InvocationExpression */: - this.typeCheckInvocationExpression(ast, context); - return; - - case 216 /* ObjectCreationExpression */: - this.typeCheckObjectCreationExpression(ast, context); - return; - - case 150 /* ReturnStatement */: - this.resolveReturnStatement(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); - } - }; - - PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { - while (this.postTypeCheckWorkitems.length) { - var ast = this.postTypeCheckWorkitems.pop(); - this.postTypeCheck(ast, context); - } - }; - - PullTypeResolver.prototype.postTypeCheck = function (ast, context) { - var nodeType = ast.kind(); - - switch (nodeType) { - case 242 /* Parameter */: - case 225 /* VariableDeclarator */: - this.postTypeCheckVariableDeclaratorOrParameter(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.postTypeCheckClassDeclaration(ast, context); - return; - - case 129 /* FunctionDeclaration */: - this.postTypeCheckFunctionDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.postTypeCheckModuleDeclaration(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.postTypeCheckEnumDeclaration(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.postTypeCheckImportDeclaration(ast, context); - return; - - case 11 /* IdentifierName */: - this.postTypeCheckNameExpression(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); - } - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return this.cachedRegExpInterfaceType(); - } else { - return this.semanticInfoChain.anyTypeSymbol; - } - }; - - PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { - this.checkThisCaptureVariableCollides(nameAST, false, context); - }; - - PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { - this.setTypeChecked(nameAST, context); - this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { - var nameSymbol = this.getSymbolForAST(nameAST, context); - 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); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - 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; - } - } - - return false; - }; - - PullTypeResolver.prototype.computeNameExpression = function (nameAST, context, reportDiagnostics) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var nameSymbol = null; - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - if (TypeScript.isDeclarationASTOrDeclarationNameAST(nameAST)) { - nameSymbol = this.semanticInfoChain.getDeclForAST(nameAST.parent).getSymbol(); - } - - var declPath = enclosingDecl.getParentPath(); - - if (!nameSymbol) { - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - - 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 (!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); - } - } - - var nameDeclaration = nameSymbol.getDeclarations()[0]; - var nameParentDecl = nameDeclaration.getParentDecl(); - if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { - var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); - var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - - var parameterList = TypeScript.getParameterList(enclosingFunctionAST); - - if (currentParameterIndex >= 0) { - var foundMatchingParameter = false; - if (parameterList) { - for (var i = 0; i <= currentParameterIndex; i++) { - var candidateParameter = parameterList.parameters.nonSeparatorAt(i); - if (candidateParameter && candidateParameter.identifier.valueText() === id) { - foundMatchingParameter = true; - } - } - } - - if (!foundMatchingParameter) { - 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); - } - } - } - - var aliasSymbol = null; - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(true); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); - - var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - if (aliasSymbol) { - this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.getParameterList(funcDecl); - if (parameterList) { - while (parameter && parameter.parent) { - if (parameter.parent.parent === parameterList) { - return parameterList.parameters.nonSeparatorIndexOf(parameter); - } - - parameter = parameter.parent; - } - } - - return -1; - }; - - PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { - var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol != null; - - if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheckDottedNameAST) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); - } - - this.resolveDeclaredSymbol(symbol, context); - - if (symbol && (symbol.type != this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(dottedNameAST, symbol, context); - this.setSymbolForAST(name, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { - var rhsName = name.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var lhs = this.resolveAST(expression, false, context); - var lhsType = lhs.type; - - if (lhs.isAlias()) { - if (!this.inTypeQuery(expression)) { - lhs.setIsUsedAsValue(true); - } - lhsType = lhs.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - if (lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (!lhsType) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); - return this.getNewErrorTypeSymbol(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { - var instanceSymbol = lhsType.getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.type; - } - } - - if (lhsType.isTypeParameter()) { - lhsType = this.substituteUpperBoundForType(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); - - 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 */) { - var container = lhsType; - var associatedInstance = container.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.type; - - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getMemberSymbol(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)])); - return this.getNewErrorTypeSymbol(rhsName); - } - } - - if (checkSuperPrivateAndStaticAccess) { - this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { - var typeNameSymbol = this.getSymbolForAST(nameAST, context); - - if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.setTypeChecked(nameAST, context); - } - typeNameSymbol = this.computeTypeNameExpression(nameAST, context); - this.setSymbolForAST(nameAST, typeNameSymbol, context); - } - - this.resolveDeclaredSymbol(typeNameSymbol, context); - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - var declPath = enclosingDecl.getParentPath(); - - var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728539 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728539 /* SomeType */ : 164 /* SomeContainer */; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } - - var typeNameSymbolAlias = null; - if (typeNameSymbol.isAlias()) { - typeNameSymbolAlias = typeNameSymbol; - this.resolveDeclaredSymbol(typeNameSymbol, context); - - var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); - - this.resolveDeclaredSymbol(aliasedType, context); - } - - if (typeNameSymbol.isTypeParameter()) { - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */) && (enclosingDecl.flags & 16 /* Static */)) { - 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)); - return this.getNewErrorTypeSymbol(); - } - } - } - - if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { - typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); - } - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.isLeftSideOfQualifiedName = function (ast) { - return ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.left === ast; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; - - if (genericTypeSymbol.isError()) { - return genericTypeSymbol; - } - - if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { - this.resolveDeclaredSymbol(genericTypeSymbol, context); - } - - if (genericTypeSymbol.isAlias()) { - genericTypeSymbol = genericTypeSymbol.getExportAssignedTypeSymbol(); - } - - var typeArgs = []; - - if (genericTypeAST.typeArgumentList && genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - - if (typeArgs[i].isError()) { - typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - var typeParameters = genericTypeSymbol.getTypeParameters(); - - 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(); - } - - if (!genericTypeSymbol.isResolved) { - var typeDecls = genericTypeSymbol.getDeclarations(); - var childDecls = null; - - for (var i = 0; i < typeDecls.length; i++) { - childDecls = typeDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - - var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); - - var typeConstraint = null; - var upperBound = null; - - typeParameters = specializedSymbol.getTypeParameters(); - - var typeConstraintSubstitutionMap = []; - var typeArg = null; - - var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < typeParameters.length; i++) { - typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - for (var id in instantiatedSubstitutionMap) { - typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; - } - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); - } - - if (typeArg.isTypeParameter()) { - upperBound = typeArg.getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - 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)])); - } - } - } - - return specializedSymbol; - }; - - PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { - if (this.inTypeQuery(dottedNameAST)) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; - } - - var symbol = this.getSymbolForAST(dottedNameAST, context); - if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheck) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeQualifiedName(dottedNameAST, context); - this.setSymbolForAST(dottedNameAST, symbol, context); - } - - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.computeQualifiedName = function (dottedNameAST, context) { - var rhsName = dottedNameAST.right.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); - var lhs = this.resolveAST(dottedNameAST.left, false, context); - - var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; - - if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { - if (lhs.isAlias()) { - lhs.setIsUsedAsValue(true); - } - } - - if (!lhsType) { - return this.getNewErrorTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - 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); - - if (!childTypeSymbol && lhsType.isContainer()) { - var exportedContainer = lhsType.getExportAssignedContainerSymbol(); - - if (exportedContainer) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.kind & 164 /* SomeContainer */) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().type; - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); - } - } - } - - if (!childTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - - return childTypeSymbol; - }; - - PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { - if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { - return false; - } - - if (returnTypeAnnotation) { - return false; - } - - if (parameters) { - for (var i = 0, n = parameters.length; i < n; i++) { - if (parameters.typeAt(i)) { - return false; - } - } - } - - var contextualFunctionTypeSymbol = context.getContextualType(); - - if (contextualFunctionTypeSymbol) { - this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); - var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length == 1; - if (!exactlyOneCallSignature) { - return false; - } - - var callSignatureIsGeneric = callSignatures[0].typeParameters && callSignatures[0].typeParameters.length > 0; - return !callSignatureIsGeneric; - } - - return false; - }; - - PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { - var funcDeclSymbol = null; - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { - return funcDeclSymbol; - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - TypeScript.Debug.assert(funcDeclSymbol); - - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - funcDeclSymbol.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - var assigningFunctionSignature = null; - if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { - 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); - } - } - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.returnType; - - if (returnType) { - context.pushContextualType(returnType, context.inProvisionalResolution(), null); - - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popContextualType(); - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - var functionExpressionName = functionDecl.getFunctionExpressionName(); - - if (functionExpressionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); - } - } - - context.setTypeInContext(funcDeclSymbol, funcDeclType); - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, null, arrowFunction.block, arrowFunction.expression, context); - }; - - PullTypeResolver.prototype.typeCheckParenthesizedArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, arrowFunction.callSignature.typeParameterList, TypeScript.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, context); - }; - - PullTypeResolver.prototype.typeCheckAnyFunctionExpression = function (funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcDeclSymbol = functionDecl.getSymbol(); - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - var returnTypeSymbol = signature.returnType; - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - context.pushContextualType(null, context.inProvisionalResolution(), 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; - - 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.validateVariableDeclarationGroups(functionDecl, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { - var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); - var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; - - if (this.canTypeCheckAST(thisExpression, context)) { - this.typeCheckThisExpression(thisExpression, context, enclosingDecl); - } - - return thisTypeSymbol; - }; - - PullTypeResolver.prototype.inTypeArgumentList = function (ast) { - var previous = null; - var current = ast; - - while (current) { - switch (current.kind()) { - case 126 /* GenericType */: - var genericType = current; - if (genericType.typeArgumentList === previous) { - return true; - } - break; - - case 226 /* ArgumentList */: - var argumentList = current; - return argumentList.typeArgumentList === previous; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { - while (ast) { - switch (ast.kind()) { - case 230 /* ExtendsHeritageClause */: - var heritageClause = ast; - - return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inTypeQuery = function (ast) { - while (ast) { - switch (ast.kind()) { - case 127 /* TypeQuery */: - return true; - case 129 /* FunctionDeclaration */: - case 213 /* InvocationExpression */: - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 213 /* InvocationExpression */: - var invocationExpression = current; - if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - break; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inConstructorParameterList = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 137 /* ConstructorDeclaration */: - var constructorDecl = current; - return previous === constructorDecl.parameterList; - - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.isFunctionOrNonArrowFunctionExpression = function (decl) { - if (decl.kind === 16384 /* Function */) { - return true; - } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { - this.checkForThisCaptureInArrowFunction(thisExpression); - - if (this.inConstructorParameterList(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); - return; - } - - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - return; - } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - if (currentDecl.getParentDecl() === null) { - return; - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_within_module_bodies)); - 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)); - } - - return; - } else if (currentDecl.kind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); - } - - return; - } - } - }; - - PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var isStaticContext = false; - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declFlags & 16 /* Static */) { - isStaticContext = true; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - return null; - } else if (declKind === 16384 /* Function */) { - return null; - } else if (declKind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(ast)) { - return this.getNewErrorTypeSymbol(); - } else { - var classSymbol = decl.getSymbol(); - if (isStaticContext) { - var constructorSymbol = classSymbol.getConstructorMethod(); - return constructorSymbol.type; - } else { - return classSymbol; - } - } - } - } - } - - return null; - }; - - PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { - return true; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - var superType = this.semanticInfoChain.anyTypeSymbol; - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); - - if (classSymbol) { - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - superType = parents[0]; - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSuperExpression(ast, context, enclosingDecl); - } - - return superType; - }; - - PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { - this.setTypeChecked(ast, context); - - this.checkForThisCaptureInArrowFunction(ast); - - var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; - var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; - TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); - - if (isSuperPropertyAccess) { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 8 /* Class */) { - if (!this.enclosingClassIsDerived(currentDecl)) { - 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 if (this.inStaticMemberVariableDeclaration(ast)) { - break; - } - - 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; - } - - return; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); - } - }; - - PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { - return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); - }; - - 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); - }; - - PullTypeResolver.prototype.typeCheckFunctionPropertyAssignment = function (funcProp, isContextuallyTyped, context) { - this.typeCheckAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.getType(funcProp), funcProp.block, null, context); - }; - - PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, isContextuallyTyped, context, additionalResults) { - var symbol = this.getSymbolForAST(expressionAST, context); - - if (!symbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { - if (this.canTypeCheckAST(expressionAST, context)) { - this.setTypeChecked(expressionAST, context); - } - symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); - this.setSymbolForAST(expressionAST, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { - var boundMemberSymbols = []; - var memberSymbol; - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var id = this.getPropertyAssignmentName(propertyAssignment); - var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); - - var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; - var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); - TypeScript.Debug.assert(decl); - - if (propertyAssignment.kind() == 240 /* SimplePropertyAssignment */) { - if (!isUsingExistingSymbol) { - memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - } else { - memberSymbol = decl.getSymbol(); - } - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - memberSymbol = decl.getSymbol(); - } else { - TypeScript.Debug.assert(isAccessor); - memberSymbol = decl.getSymbol(); - } - - if (!isUsingExistingSymbol && !isAccessor) { - if (objectLiteralTypeSymbol.findMember(memberSymbol.name, true)) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(propertyAssignment, TypeScript.DiagnosticCode.Duplicate_identifier_0, [assignmentText.actualText])); - } - - objectLiteralTypeSymbol.addMember(memberSymbol); - } - - boundMemberSymbols.push(memberSymbol); - } - - return boundMemberSymbols; - }; - - PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var acceptedContextualType = false; - var assigningSymbol = null; - - var id = this.getPropertyAssignmentName(propertyAssignment); - var memberSymbol = boundMemberSymbols[i]; - - if (objectLiteralContextualType) { - assigningSymbol = this.getMemberSymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); - - if (!assigningSymbol) { - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - assigningSymbol = numericIndexerSignature; - } else if (stringIndexerSignature) { - assigningSymbol = stringIndexerSignature; - } - } - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - - var contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.pushContextualType(contextualMemberType, pullTypeContext.inProvisionalResolution(), null); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = contextualMemberType; - } - } - } - - var propertySymbol = this.resolveAST(propertyAssignment, contextualMemberType != null, pullTypeContext); - var memberExpr = this.widenType(propertySymbol.type, propertyAssignment, pullTypeContext); - - if (memberExpr.type) { - if (memberExpr.type.isGeneric()) { - objectLiteralTypeSymbol.setHasGenericMember(); - } - - if (stringIndexerSignature) { - allMemberTypes.push(memberExpr.type); - } - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberExpr.type); - } - } - - if (acceptedContextualType) { - pullTypeContext.popContextualType(); - } - - var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!isUsingExistingSymbol) { - if (isAccessor) { - this.setSymbolForAST(id, memberExpr, pullTypeContext); - } else { - pullTypeContext.setTypeInContext(memberSymbol, memberExpr.type); - memberSymbol.setResolved(); - - this.setSymbolForAST(id, memberSymbol, pullTypeContext); - } - } - } - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { - var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); - TypeScript.Debug.assert(objectLitDecl); - - var typeSymbol = this.getSymbolForAST(objectLitAST, context); - var isUsingExistingSymbol = !!typeSymbol; - - if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); - typeSymbol.addDeclaration(objectLitDecl); - this.setSymbolForAST(objectLitAST, typeSymbol, context); - objectLitDecl.setSymbol(typeSymbol); - } - - var propertyAssignments = objectLitAST.propertyAssignments; - var contextualType = null; - - if (isContextuallyTyped) { - contextualType = context.getContextualType(); - this.resolveDeclaredSymbol(contextualType, context); - } - - var stringIndexerSignature = null; - var numericIndexerSignature = null; - var allMemberTypes = null; - var allNumericMemberTypes = null; - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); - - stringIndexerSignature = indexSignatures.stringSignature; - numericIndexerSignature = indexSignatures.numericSignature; - - if (stringIndexerSignature) { - allMemberTypes = [stringIndexerSignature.returnType]; - } - - if (numericIndexerSignature) { - allNumericMemberTypes = [numericIndexerSignature.returnType]; - } - } - - if (propertyAssignments) { - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); - - this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); - - if (!isUsingExistingSymbol) { - this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); - this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); - } - } - - typeSymbol.setResolved(); - return typeSymbol; - }; - - PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { - return propertyAssignment.propertyName; - } else { - TypeScript.Debug.assert(false); - } - }; - - PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { - if (contextualIndexSignature) { - var typeCollection = { - getLength: function () { - return indexerTypeCandidates.length; - }, - getTypeAtIndex: function (index) { - return indexerTypeCandidates[index]; - } - }; - var decl = objectLiteralSymbol.getDeclarations()[0]; - var indexerReturnType = this.widenType(this.findBestCommonType(typeCollection, 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); - } - } - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { - var symbol = this.getSymbolForAST(arrayLit, context); - if (!symbol || this.canTypeCheckAST(arrayLit, context)) { - if (this.canTypeCheckAST(arrayLit, context)) { - this.setTypeChecked(arrayLit, context); - } - symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); - this.setSymbolForAST(arrayLit, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { - var elements = arrayLit.expressions; - var elementType = null; - var elementTypes = []; - var comparisonInfo = new TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, context); - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); - if (indexSignatures.numericSignature) { - contextualElementType = indexSignatures.numericSignature.returnType; - } - } - } - - if (elements) { - if (contextualElementType) { - context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); - } - - for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { - elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); - } - - if (contextualElementType) { - context.popContextualType(); - } - } - - if (elementTypes.length) { - elementType = elementTypes[0]; - } - var collection; - if (contextualElementType) { - if (!elementType) { - elementType = contextualElementType; - } - - collection = { - getLength: function () { - return elements.nonSeparatorCount() + 1; - }, - getTypeAtIndex: function (index) { - return index === 0 ? contextualElementType : elementTypes[index - 1]; - } - }; - } else { - collection = { - getLength: function () { - return elements.nonSeparatorCount(); - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - } - - elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; - - if (!elementType) { - 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; - }; - - PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { - var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); - - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); - } - - return symbolAndDiagnostic.symbol; - }; - - PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { - this.setTypeChecked(callEx, context); - context.postDiagnostic(symbolAndDiagnostic.diagnostic); - }; - - PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; - - var targetTypeSymbol = targetSymbol.type; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return { symbol: targetTypeSymbol }; - } - - var elementType = targetTypeSymbol.getElementType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return { symbol: elementType }; - } - - 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); - - if (member) { - this.resolveDeclaredSymbol(member, context); - - return { symbol: member.type }; - } - } - - if (targetTypeSymbol == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - targetTypeSymbol = this.cachedStringInterfaceType(); - } - - var signatures = this.getBothKindsOfIndexSignatures(targetTypeSymbol, context); - - var stringSignature = signatures.stringSignature; - var numberSignature = signatures.numericSignature; - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; - } 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) { - return { symbol: this.semanticInfoChain.anyTypeSymbol }; - } else { - return { - symbol: this.getNewErrorTypeSymbol(), - diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) - }; - } - }; - - PullTypeResolver.prototype.getBothKindsOfIndexSignatures = function (enclosingType, context) { - var signatures = enclosingType.getIndexSignatures(); - - var stringSignature = null; - var numberSignature = null; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - if (!signature.isResolved) { - this.resolveDeclaredSymbol(signature, context); - } - - paramSymbols = signature.parameters; - - if (paramSymbols.length) { - paramType = paramSymbols[0].type; - - if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signature; - continue; - } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { - numberSignature = signature; - continue; - } - } - } - - return { - numericSignature: numberSignature, - stringSignature: stringSignature - }; - }; - - PullTypeResolver.prototype.resolveBinaryAdditionOperation = function (binaryExpression, context) { - var lhsExpression = this.resolveAST(binaryExpression.left, false, context); - var lhsType = lhsExpression.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - 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; - } else { - rhsType = this.semanticInfoChain.anyTypeSymbol; - } - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (exprType) { - if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { - if (!this.isReference(binaryExpression.left, lhsExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, exprType, lhsType, context); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); - } - } - - if (!exprType) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { - return this.findBestCommonType({ - getLength: function () { - return 2; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - } - } - }, context); - }; - - PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { - return this.findBestCommonType({ - getLength: function () { - return 3; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - case 2: - return type3; - } - } - }, context); - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - } - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - 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); - } else { - var leftType = this.resolveAST(binex.left, false, context).type; - - context.pushContextualType(leftType, context.inProvisionalResolution(), null); - var rightType = this.resolveAST(binex.right, true, context).type; - context.popContextualType(); - - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - - this.resolveAST(binex.left, false, context); - } - - return this.resolveAST(binex.right, false, context).type; - }; - - PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); - } else { - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { - var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; - var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; - - var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); - - var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); - - if (this.canTypeCheckAST(trinex, context)) { - this.setTypeChecked(trinex, context); - this.resolveAST(trinex.condition, false, context); - - if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); - } - } - } - - if (!conditionalTypesAreValid) { - return this.getNewErrorTypeSymbol(); - } - - return expressionType; - }; - - 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)) { - return true; - } - } else { - if (this.typesAreIdentical(expressionType, leftType) || this.typesAreIdentical(expressionType, rightType)) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveAST(ast.expression, false, context); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - if (symbol != this.semanticInfoChain.anyTypeSymbol) { - this.setSymbolForAST(callEx, symbol, context); - } - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckInvocationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - var targetSymbol = this.resolveAST(callEx.expression, false, context); - - if (callEx.argumentList.arguments) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - - var len = callEx.argumentList.arguments.nonSeparatorCount(); - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var targetTypeSymbol = targetSymbol.type; - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); - return this.getNewErrorTypeSymbol(); - } - } - - return this.semanticInfoChain.anyTypeSymbol; - } - - var isSuperCall = false; - - if (callEx.expression.kind() === 50 /* SuperKeyword */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = targetTypeSymbol.getConstructorMethod(); - this.resolveDeclaredSymbol(targetSymbol, context); - targetTypeSymbol = targetSymbol.type; - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); - this.resolveAST(callEx.argumentList.arguments, false, context); - - return this.getNewErrorTypeSymbol(); - } - } - - var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - - 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 couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (callEx.argumentList.typeArgumentList) { - typeArgs = []; - - 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); - } - } - } else if (isSuperCall && targetTypeSymbol.isGeneric()) { - typeArgs = targetTypeSymbol.getTypeArguments(); - } - - var triedToInferTypeArgs = false; - - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var beforeResolutionSignatures = signatures; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - 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 (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; - } - } - } - } else { - if (triedToInferTypeArgs) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; - } - } - - if (couldNotAssignToConstraint) { - continue; - } - - specializedSignature = this.instantiateSignature(signatures[i], typeReplacementMap, true); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = signatures[i]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - - var errorCondition = null; - if (!signatures.length) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (!couldNotFindGenericOverload) { - if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(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); - } - return this.semanticInfoChain.anyTypeSymbol; - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); - } else if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList != null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!signatures.length) { - return errorCondition; - } - - signature = signatures[0]; - } - - if (!signature.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); - } - - var returnType = isSuperCall ? this.semanticInfoChain.voidTypeSymbol : signature.returnType; - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - this.setSymbolForAST(callEx, symbol, context); - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckObjectCreationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - this.resolveAST(callEx.expression, false, context); - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (callEx.argumentList) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - var len = callEx.argumentList.arguments.nonSeparatorCount(); - - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { - if (!context.inProvisionalResolution()) { - additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); - } - context.postDiagnostic(diagnostic); - }; - - PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; - - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var typeArgs = null; - var typeReplacementMap = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - return targetTypeSymbol; - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - - if (this.compilationSettings.noImplicitAny()) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); - } - } - - if (constructSignatures.length) { - if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - typeArgs = []; - - 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); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var triedToInferTypeArgs; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric()) { - typeParameters = constructSignatures[i].getTypeParameters(); - - 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 && callEx.argumentList.arguments && callEx.argumentList.arguments.nonSeparatorCount()) { - inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], new TypeScript.ArgumentInferenceContext(this, callEx.argumentList.arguments), new TypeComparisonInfo(), context); - triedToInferTypeArgs = true; - } else { - inferredTypeArgs = []; - } - - 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; - } - } - } - } else { - if (triedToInferTypeArgs) { - continue; - } else { - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; - } - } - } - - if (couldNotAssignToConstraint) { - continue; - } - - specializedSignature = this.instantiateSignature(constructSignatures[i], typeReplacementMap, true); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList != null, context, diagnostics); - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - - if (!constructSignatures.length) { - if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var errorCondition = null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!constructSignatures.length) { - return errorCondition; - } - - signature = constructSignatures[0]; - } - - returnType = signature.returnType; - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (typeArgs && typeArgs.length) { - returnType = this.createInstantiatedType(returnType, typeArgs); - } else { - returnType = this.instantiateTypeToAny(returnType, context); - } - } - - if (usedCallSignaturesInstead) { - 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(); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.returnType; - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList && callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - } else if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); - - return this.getNewErrorTypeSymbol(); - }; - - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureA, signatureB, context) { - var typeReplacementMap = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters = signatureA.getTypeParameters(); - var typeConstraint = null; - - var fixedParameterTypes = []; - - 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 enclosingTypeParameterMap; - - if (functionTypeA) { - enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - if (functionTypeB) { - enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - 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(); - - 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); - }; - - PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { - var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; - - if (this.canTypeCheckAST(assertionExpression, context)) { - this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); - } - - return typeAssertionType; - }; - - PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { - this.setTypeChecked(assertionExpression, context); - - context.pushContextualType(typeAssertionType, context.inProvisionalResolution(), null); - var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popContextualType(); - - 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); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(assertionExpression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { - var leftExpr = this.resolveAST(binaryExpression.left, false, context); - var leftType = leftExpr.type; - - context.pushContextualType(leftType, context.inProvisionalResolution(), null); - var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popContextualType(); - - rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (!this.isReference(binaryExpression.left, leftExpr)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } else { - this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); - } - } - - return rightType; - }; - - PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { - var typeToReturn = type; - if (typeToReturn && typeToReturn.isAlias()) { - typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); - } - - if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { - var instanceTypeSymbol = typeToReturn.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); - typeToReturn = null; - } else { - typeToReturn = instanceTypeSymbol; - } - } - - return typeToReturn; - }; - - PullTypeResolver.prototype.widenType = function (type, ast, context) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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 type; - }; - - PullTypeResolver.prototype.findBestCommonType = function (collection, context, comparisonInfo) { - var len = collection.getLength(); - - for (var i = 0; i < len; i++) { - var candidateType = collection.getTypeAtIndex(i); - if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { - return candidateType; - } - } - - return this.semanticInfoChain.emptyTypeSymbol; - }; - - PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { - for (var i = 0; i < collection.getLength(); i++) { - var otherType = collection.getTypeAtIndex(i); - 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)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, t1EnclosingType, t2EnclosingType, val) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - 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); - } - } - - return this.typesAreIdentical(t1, t2, val); - }; - - PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - 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 (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - if (t1.isTypeParameter() != t2.isTypeParameter()) { - return false; - } else if (t1.isTypeParameter()) { - var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return false; - } - } - - 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()) { - return false; - } - - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, false); - - 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); - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getMemberSymbol(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)) { - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { - if (sg1 === sg2) { - return true; - } - - if (!sg1 || !sg2) { - return false; - } - - 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)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { - if (!type || !type.isTypeParameter()) { - return type; - } - - var constraint = type.getConstraint(); - - if (constraint && (constraint != type)) { - return this.substituteUpperBoundForType(constraint); - } - - return type; - }; - - PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { - var decls1 = symbol1.getDeclarations(); - 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 false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - 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.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.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, ast, context) { - if (source.getCallSignatures().length || source.getConstructSignatures().length) { - return true; - } - - return this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(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.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.getSymbolForRelationshipCheck = function (symbol) { - if (symbol && symbol.isTypeReference()) { - return symbol.getReferencedTypeSymbol(); - } - - return symbol; - }; - - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, sourceEnclosingType, targetEnclosingType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - 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 */) { - return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - } - } - - return this.sourceIsRelatableToTarget(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - var sourceSubstitution = 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; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } - } - - if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - 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) { - return true; - } - - return false; - } else if (source == this.semanticInfoChain.voidTypeSymbol) { - if (target == this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return assignableTo; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { - return false; - } - - if (source.getIsSpecialized() && target.getIsSpecialized()) { - if (TypeScript.PullHelpers.getRootType(source) == TypeScript.PullHelpers.getRootType(target)) { - var sourceTypeArguments = source.getTypeArguments(); - var targetTypeArguments = target.getTypeArguments(); - - if (sourceTypeArguments && targetTypeArguments) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, false); - - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - break; - } - } - - if (i == sourceTypeArguments.length) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); - return true; - } else { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - } - } - } - } - - if (sourceSubstitution.isPrimitive() || target.isPrimitive()) { - return false; - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter() && (source === sourceSubstitution)) { - return this.typesAreIdentical(target, source); - } else { - if (isComparingInstantiatedSignatures) { - target = this.substituteUpperBoundForType(target); - } else { - return this.typesAreIdentical(target, sourceSubstitution); - } - } - } - - 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); - return false; - } - - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - var sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); - - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - - 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)])); - } - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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)])); - } - return false; - } - - var comparisonInfoTypeArgumentsCheck = null; - 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)) { - 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]); - } 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)]); - } - comparisonInfo.addMessage(message); - } - } - } - } - - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingTypesAreIdentical = function (sourceType, targetType) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); - - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference != targetTypeNamedTypeReference) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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])) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - } - } - - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetPropIsPrivate = targetProp.anyDeclHasFlag(2 /* Private */); - var sourcePropIsPrivate = sourceProp.anyDeclHasFlag(2 /* Private */); - - if (targetPropIsPrivate != sourcePropIsPrivate) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - 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)])); - } 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)])); - } - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - } - return false; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (!targetDecl.isEqual(sourceDecl)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - - 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()])); - } - - return false; - } - } - - if (sourceProp.isOptional && !targetProp.isOptional) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - 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)])); - } - return false; - } - - this.resolveDeclaredSymbol(sourceProp, context); - - var sourcePropType = sourceProp.type; - var targetPropType = targetProp.type; - - if (comparisonCache.valueAt(sourcePropType.pullSymbolID, targetPropType.pullSymbolID)) { - return true; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, source, target, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures)) { - return true; - } - - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - 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]); - } 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)]); - } - comparisonInfo.addMessage(message); - } - - return false; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignatures(target, context); - var targetStringSig = targetIndexSigs.stringSignature; - var targetNumberSig = targetIndexSigs.numericSignature; - - if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignatures(source, context); - var sourceStringSig = sourceIndexSigs.stringSignature; - var sourceNumberSig = sourceIndexSigs.numericSignature; - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - } else if (sourceStringSig) { - comparable = this.sourceIsAssignableToTarget(sourceStringSig.returnType, targetNumberSig.returnType, ast, context, comparisonInfoSignatuesTypeCheck); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - var mSig = null; - var nSig = null; - var foundMatch = false; - - var targetExcludeDefinition = targetSG.length > 1; - var sourceExcludeDefinition = sourceSG.length > 1; - for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { - mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { - continue; - } - - if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - foundMatch = true; - break; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var sourceParameters = sourceSig.parameters; - var targetParameters = targetSig.parameters; - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetVarArgCount = targetSig.nonOptionalParamCount; - var sourceVarArgCount = sourceSig.nonOptionalParamCount; - - if (sourceVarArgCount > targetVarArgCount) { - if (comparisonInfo) { - comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetVarArgCount])); - } - 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; - } - } - - comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, false); - - 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 (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - - return false; - } - } - - 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; - } - - 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 (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { - var _this = this; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeComparisonInfo(); - var args = application.argumentList ? application.argumentList.arguments : null; - - var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { - if (hasOverloads && signature.isDefinition()) { - return false; - } - - if (haveTypeArgumentsAtCallSite && !signature.isGeneric()) { - return false; - } - - return _this.overloadHasCorrectArity(signature, args); - }); - - var firstAssignableButNotSupertypeSignature = null; - var firstAssignableWithProvisionalErrorsSignature = null; - - for (var i = 0; i < initialCandidates.length; i++) { - var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); - if (applicability === 3 /* Subtype */) { - return initialCandidates[i]; - } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { - firstAssignableButNotSupertypeSignature = initialCandidates[i]; - } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { - firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; - } - } - - if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { - return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; - } else { - var target = this.getCallTargetErrorSpanAST(application); - if (comparisonInfo.message) { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); - } else { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); - } - } - - return null; - }; - - PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { - return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; - }; - - PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { - if (args == null) { - return signature.nonOptionalParamCount === 0; - } - - var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); - if (numberOfArgs < signature.nonOptionalParamCount) { - return false; - } - if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { - if (args === null) { - return 3 /* Subtype */; - } - - var isInVarArg = false; - var parameters = signature.parameters; - var paramType = null; - - var overloadApplicability = 3 /* Subtype */; - - for (var i = 0; i < args.nonSeparatorCount(); i++) { - if (!isInVarArg) { - this.resolveDeclaredSymbol(parameters[i], context); - - if (parameters[i].isVarArg) { - paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); - isInVarArg = true; - } else { - paramType = parameters[i].type; - } - } - - var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); - - if (statusOfCurrentArgument === 0 /* NotAssignable */) { - return 0 /* NotAssignable */; - } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { - overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; - } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { - overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; - } - } - - return overloadApplicability; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType.isAny()) { - return 3 /* Subtype */; - } else if (paramType.isError()) { - 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); - } 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); - } 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); - } else if (arg.kind() === 215 /* ObjectLiteralExpression */) { - return this.overloadIsApplicableForObjectLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else if (arg.kind() === 214 /* ArrayLiteralExpression */) { - return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else { - return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); - } - }; - - PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { - if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushContextualType(paramType, true, null); - - 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(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushContextualType(paramType, true, null); - var argSym = this.resolveObjectLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType === this.cachedArrayInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushContextualType(paramType, true, null); - var argSym = this.resolveArrayLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - var argSym = this.resolveAST(arg, false, context); - - if (argSym.type.isAlias()) { - var aliasSym = argSym.type; - argSym = aliasSym.getExportAssignedTypeSymbol(); - } - - comparisonInfo.stringConstantVal = arg; - return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { - var tempComparisonInfo = new TypeComparisonInfo(); - tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; - if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { - return 3 /* Subtype */; - } - - if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { - return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; - } - - if (!comparisonInfo.message) { - var enclosingSymbol = this.getEnclosingSymbolForAST(arg); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); - } - - return 0 /* NotAssignable */; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, argContext, comparisonInfo, context) { - var cxt = null; - - 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; - } - } - } - - 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; - } - } - } - } - - return resultTypes; - }; - - PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { - var enclosingDecl = this.getEnclosingDeclForAST(args); - var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); - return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; - }; - - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, expressionTypeEnclosingType, parameterTypeEnclosingType, shouldFix, 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); - return; - } - } - this.relateTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - }; - - PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { - if (!expressionType || !parameterType) { - return; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType.isTypeParameter()) { - argContext.addCandidateForInference(parameterType, expressionType, shouldFix); - 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); - - 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); - } - } - } - }; - - PullTypeResolver.prototype.relateInifinitelyExpandingTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { - if (!expressionType || !parameterType) { - return; - } - - var expressionTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(expressionType); - var parameterTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(parameterType); - if (expressionTypeNamedTypeReference != parameterTypeNamedTypeReference) { - return; - } - - var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); - - if (expressionTypeTypeArguments && parameterTypeParameters && expressionTypeTypeArguments.length === parameterTypeParameters.length) { - for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - } - } - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var expressionParams = expressionSignature.parameters; - var expressionReturnType = expressionSignature.returnType; - - var parameterParams = parameterSignature.parameters; - var parameterReturnType = parameterSignature.returnType; - - var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; - - 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); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - 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); - if (objectMember) { - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, objectType, parameterType, shouldFix, argContext, context); - } - } - - parameterSignatures = parameterType.getCallSignatures(); - objectSignatures = objectType.getCallSignatures(); - - if ((parameterSignatures.length == 1) && (objectSignatures.length == 1) && !objectSignatures[0].isGeneric() && (parameterSignatures[0].nonOptionalParamCount >= objectSignatures[0].nonOptionalParamCount)) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[0], parameterSignatures[0], 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); - - if (parameterIndexSignatures.stringSignature && objectIndexSignatures.stringSignature) { - this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.stringSignature, parameterIndexSignatures.stringSignature, argContext, context); - } - if (parameterIndexSignatures.numericSignature && objectIndexSignatures.numericSignature) { - this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.numericSignature, parameterIndexSignatures.numericSignature, argContext, context); - } - }; - - PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, context) { - var argElement = argArrayType.getElementType(); - var paramElement = parameterArrayType.getElementType(); - - this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, context); - }; - - PullTypeResolver.prototype.instantiateTypeToAny = function (typeToSpecialize, context) { - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!typeParameters.length) { - return typeToSpecialize; - } - - var typeArguments = null; - - 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) { - typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; - } else { - typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; - } - } - - var type = this.createInstantiatedType(typeToSpecialize, typeArguments); - - return type; - }; - - PullTypeResolver.typeCheck = function (compilationSettings, semanticInfoChain, document) { - var sourceUnit = document.sourceUnit(); - - var resolver = semanticInfoChain.getResolver(); - var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); - - if (resolver.canTypeCheckAST(sourceUnit, context)) { - resolver.resolveAST(sourceUnit, false, context); - resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); - - while (resolver.typeCheckCallBacks.length) { - var callBack = resolver.typeCheckCallBacks.pop(); - callBack(context); - } - - resolver.processPostTypeCheckWorkItems(context); - } - }; - - 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(); - } - } - - 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 name = decl.name; - - 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; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckFunctionOverloads = function (funcDecl, context, signature, allSignatures) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - 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)) { - 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)); - } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); - } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); - } else { - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved) { - this.resolveDeclaredSymbol(allSignatures[i], context); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - if (this.signatureIsSubtypeOfTarget(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)); - } - } - } else if (definitionSignature && definitionSignature != signature) { - var comparisonInfo = new TypeComparisonInfo(); - - if (!definitionSignature.isResolved) { - this.resolveDeclaredSymbol(definitionSignature, context); - } - - if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature != signatureForVisibilityCheck) { - var errorCode; - - 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; - } - - if (errorCode) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); - } - } - }; - - PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { - if (!symbol || symbol.kind === 2 /* Primitive */) { - return; - } - - if (symbol.isType()) { - var typeSymbol = symbol; - var isNamedType = typeSymbol.isNamedTypeSymbol(); - - if (typeSymbol.isArrayNamedTypeReference()) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); - return; - } - - if (!isNamedType) { - var typeOfSymbol = typeSymbol.getTypeOfSymbol(); - if (typeOfSymbol) { - this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); - return; - } - } - - if (typeSymbol.inSymbolPrivacyCheck) { - return; - } - - typeSymbol.inSymbolPrivacyCheck = true; - - var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); - if (typars) { - for (var i = 0; i < typars.length; i++) { - this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); - } - } - - if (!isNamedType) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind == 8192 /* TypeParameter */) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); - } - - typeSymbol.inSymbolPrivacyCheck = false; - - if (!isNamedType) { - return; - } - } - - if (declSymbol.isExternallyVisible()) { - var symbolIsVisible = symbol.isExternallyVisible(); - - 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]) { - 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); - break; - } - } - symbol = symbolPath[symbolPath.length - 1]; - } - } else if (symbol.kind == 128 /* TypeAlias */) { - var aliasSymbol = symbol; - symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(true); - } - - if (!symbolIsVisible) { - privacyErrorReporter(symbol); - } - } - }; - - PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length > 1 && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); - } - - var params = signature.parameters; - for (var j = 0; j < params.length; j++) { - var paramType = params[j].type; - this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); - } - - var returnType = signature.returnType; - this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); - } - }; - - PullTypeResolver.prototype.typeParameterOfTypeDeclarationPrivacyErrorReporter = function (classOrInterface, indexOfTypeParameter, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - 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()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; - } - } - - var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { - var typeSymbol = symbol; - var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isProperty = declSymbol.kind === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; - } - } else { - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return; - } - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; - var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; - var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.kind == 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); - var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); - this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { - return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); - }); - } - } - - if (!isGetter && !isIndexSignature) { - var funcParams = functionSignature.parameters; - for (var i = 0; i < funcParams.length; i++) { - this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); - }); - } - } - - if (!isSetter) { - this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); - }); - } - }; - - PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else if (!isGetter) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var parameter = parameters.astAt(argIndex); - - var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { - var _this = this; - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var messageCode = null; - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; - } - } - - if (messageCode) { - var messageArguments = [typeSymbolName]; - var reportOnFuncDecl = false; - - if (returnTypeAnnotation) { - var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); - } - } - - if (block) { - var reportErrorOnReturnExpressions = function (ast, walker) { - var go = true; - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - } - } - }; - - PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { - TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); - - var classSymbol = classDecl.getSymbol(); - return classSymbol.getExtendedTypes().length > 0; - }; - - PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { - if (ast.kind() === 213 /* InvocationExpression */) { - var invocationExpression = ast; - if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { - if (node && node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - if (this.isSuperInvocationExpression(expressionStatement.expression)) { - return true; - } - } - return false; - }; - - PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { - if (block && block.statements && block.statements.childCount() > 0) { - return block.statements.childAt(0); - } - - return null; - }; - - PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { - TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); - - if (constructorDecl) { - var enclosingClass = constructorDecl.getParentDecl(); - - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.kind === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.kind() === 242 /* Parameter */) { - return true; - } - - if (ast.kind() === 136 /* MemberVariableDeclaration */) { - var variableDeclarator = ast; - if (variableDeclarator.variableDeclarator.equalsValueClause) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { - var enclosingDecl = this.getEnclosingDeclForAST(expression); - - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var inArrowFunction = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - inArrowFunction = true; - continue; - } - - if (inArrowFunction) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - var constructorSymbol = decl.getSymbol().getConstructorMethod(); - var constructorDecls = constructorSymbol.getDeclarations(); - for (var i = 0; i < constructorDecls.length; i++) { - constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; - } - } - break; - } - } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { - break; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignatures(containerType, context); - var stringSignature = indexSignatures.stringSignature; - var numberSignature = indexSignatures.numericSignature; - - if (stringSignature || numberSignature) { - var members = containerTypeDecl.getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { - var memberSymbol = member.getSymbol(); - var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); - if (relevantSignature) { - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsSubtypeOfTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { - this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); - } - } - } - } - } - }; - - PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { - if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { - return numberIndexSignature; - } else if (stringIndexSignature) { - return stringIndexSignature; - } - - return null; - }; - - PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { - 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])); - } 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)])); - } - } 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])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.kind; - var extendedMemberKind = extendedTypeMember.kind; - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { - var typeMembers = typeSymbol.getMembers(); - - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - var foundError1 = false; - var foundError2 = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].name; - var extendedTypeProp = extendedType.findMember(propName, true); - if (extendedTypeProp) { - this.resolveDeclaredSymbol(extendedTypeProp, context); - foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); - - if (!foundError1) { - foundError2 = !this.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); - } - - if (foundError1 || foundError2) { - foundError = true; - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = typeSymbol.getConstructorMethod().type; - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = extendedType.getConstructorMethod().type; - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].name; - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved) { - 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); - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; - } else { - if (extendedType.isClass()) { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; - } else { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - } - } - } - - if (foundError) { - var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (valueDeclAST, typeSymbol, enclosingDecl, context) { - var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - var valueSymbol = this.computeNameExpression(valueDeclAST, context, false); - var valueSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - - this.semanticInfoChain.setAliasSymbolForAST(valueDeclAST, typeSymbolAlias); - - if (typeSymbolAlias && valueSymbolAlias) { - return typeSymbolAlias != valueSymbolAlias; - } - - if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { - return true; - } - - var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; - - if (associatedContainerType) { - return associatedContainerType != typeSymbol.getRootSymbol(); - } - - return true; - }; - - PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - - var baseType = this.resolveTypeReference(baseDeclAST, context).type; - - if (!baseType) { - return; - } - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (!baseType.isError()) { - if (isExtendedType) { - if (typeDeclIsClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); - } - } - return; - } else if (typeDeclIsClass && isExtendedType && baseDeclAST.kind() == 11 /* IdentifierName */) { - 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)])); - } - } - - if (baseType.hasBase(typeSymbol)) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); - return; - } - - if (isExtendedType) { - this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); - } else { - TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - - this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); - } - - this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { - return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); - }); - }; - - PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { - var _this = this; - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.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); - } - } - - if (typeSymbol.isClass()) { - if (implementsClause) { - for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); - } - } - } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { - var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { - return decl.ast().heritageClauses !== null; - }).ast(); - if (classOrInterface === firstInterfaceASTWithExtendsClause) { - this.typeCheckCallBacks.push(function (context) { - _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); - }); - } - } - }; - - PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { - var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); - - var inheritedMembersMap = TypeScript.createIntrinsicsObject(); - var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); - - var typeHasOwnNumberIndexer = false; - var typeHasOwnStringIndexer = false; - - if (typeSymbol.hasOwnIndexSignatures()) { - var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); - for (var i = 0; i < ownIndexSignatures.length; i++) { - if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { - typeHasOwnNumberIndexer = true; - } else { - typeHasOwnStringIndexer = true; - } - } - } - 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)) { - return; - } - } - - if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { - return; - } - - this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, inheritedMembersMap, context); - }; - - PullTypeResolver.prototype.checkNamedPropertyTypeIdentityBetweenBases = 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]; - var memberName = member.name; - - if (interfaceSymbol.findMember(memberName, false)) { - continue; - } - - 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()]); - 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; - } - } else { - inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); - } - } - - return false; - }; - - PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { - if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { - return false; - } - - var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { - var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; - - var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - var parameterTypeIsNumber = !parameterTypeIsString; - if (parameterTypeIsString && derivedTypeHasOwnStringSignature || parameterTypeIsNumber && derivedTypeHasOwnNumberSignature) { - continue; - } - - if (parameterTypeIsString) { - if (allInheritedSignatures.stringSignatureWithBaseOrigin) { - if (allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.stringSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { - 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; - } - } else { - allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } else if (parameterTypeIsNumber) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.numberSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { - 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; - } - } else { - allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { - if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; - var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; - for (var memberName in inheritedMembers) { - var memberWithBaseOrigin = inheritedMembers[memberName]; - if (!memberWithBaseOrigin) { - continue; - } - - var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); - if (!relevantSignature) { - continue; - } - - var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; - var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; - - if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { - continue; - } - - var memberIsSubtype = this.sourceIsSubtypeOfTarget(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]); - - 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]); - - 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])); - } - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var signatureIsSubtype = this.sourceIsSubtypeOfTarget(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, [ - 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, [ - interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), - inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.isReference = function (ast, astSymbol) { - if (ast.kind() === 217 /* ParenthesizedExpression */) { - return this.isReference(ast.expression, astSymbol); - } - - if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { - return false; - } - - if (ast.kind() === 11 /* IdentifierName */) { - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { - return false; - } - - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { - return false; - } - - if (astSymbol.kind === 32768 /* ConstructorMethod */) { - return false; - } - } - - if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { - if (resolvedName) { - if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { - return this.semanticInfoChain.getEnclosingDecl(ast); - }; - - PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - return enclosingDecl ? enclosingDecl.getSymbol() : null; - }; - - PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { - if (resolvedName) { - if (resolvedName.anyDeclHasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var memberClass = memberContainer.getDeclarations()[0].ast(); - TypeScript.Debug.assert(memberClass); - - var containingClass = this.getEnclosingClassDeclaration(name); - - if (!containingClass || containingClass !== memberClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } - if (type.isPrimitive()) { - return type; - } - - if (type.isError()) { - return type; - } - - if (typeParameterArgumentMap[type.pullSymbolID]) { - return typeParameterArgumentMap[type.pullSymbolID]; - } - - if (type.isTypeParameter() && type.isFunctionTypeParameter()) { - return type; - } - - type._resolveDeclaredSymbol(); - if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - - return type; - }; - - PullTypeResolver.prototype.instantiateSignature = function (signature, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } - if (!signature.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return signature; - } - - var typeArguments = []; - - 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); - } - - instantiatedSignature.returnType = this.instantiateType((signature.returnType || this.semanticInfoChain.anyTypeSymbol), typeParameterArgumentMap, instantiateFunctionTypeParameters); - - if (instantiateFunctionTypeParameters) { - instantiatedSignature.functionType = this.instantiateType(signature.functionType, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - - var parameters = signature.parameters; - var parameter = null; - - if (parameters) { - for (var j = 0; j < parameters.length; j++) { - parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].isOptional) { - parameter.isOptional = true; - } - if (parameters[j].isVarArg) { - parameter.isVarArg = true; - instantiatedSignature.hasVarArgs = true; - } - instantiatedSignature.addParameter(parameter, parameter.isOptional); - - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - } - - return instantiatedSignature; - }; - PullTypeResolver.globalTypeCheckPhase = 0; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; - - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent + 1; - } - } - TypeComparisonInfo.prototype.indentString = function () { - var result = ""; - - for (var i = 0; i < this.indent; i++) { - result += "\t"; - } - - return result; - }; - - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = this.message + TypeScript.newLine() + this.indentString() + message; - } else { - this.message = this.indentString() + message; - } - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - function getPropertyAssignmentNameTextFromIdentifier(identifier) { - if (identifier.kind() === 11 /* IdentifierName */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 14 /* StringLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 13 /* NumericLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; - - function isTypesOnlyLocation(ast) { - while (ast && ast.parent) { - switch (ast.parent.kind()) { - case 244 /* TypeAnnotation */: - return true; - case 127 /* TypeQuery */: - return false; - case 125 /* ConstructorType */: - var constructorType = ast.parent; - if (constructorType.type === ast) { - return true; - } - break; - case 123 /* FunctionType */: - var functionType = ast.parent; - if (functionType.type === ast) { - return true; - } - break; - case 239 /* Constraint */: - var constraint = ast.parent; - if (constraint.type === ast) { - return true; - } - break; - case 220 /* CastExpression */: - var castExpression = ast.parent; - return castExpression.type === ast; - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - return true; - case 228 /* TypeArgumentList */: - return true; - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 130 /* ModuleDeclaration */: - case 129 /* FunctionDeclaration */: - case 145 /* MethodSignature */: - case 212 /* MemberAccessExpression */: - case 242 /* Parameter */: - return false; - } - - ast = ast.parent; - } - - return false; - } - TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var sentinalEmptyArray = []; - - var SemanticInfoChain = (function () { - function SemanticInfoChain(compiler, logger) { - this.compiler = compiler; - this.logger = logger; - this.documents = []; - this.fileNameToDocument = TypeScript.createIntrinsicsObject(); - this.anyTypeDecl = null; - this.booleanTypeDecl = null; - this.numberTypeDecl = null; - this.stringTypeDecl = null; - this.nullTypeDecl = null; - this.undefinedTypeDecl = null; - this.voidTypeDecl = null; - this.undefinedValueDecl = null; - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.voidTypeSymbol = null; - this.undefinedValueSymbol = null; - this.emptyTypeSymbol = null; - this.astSymbolMap = []; - this.astAliasSymbolMap = []; - this.astCallResolutionDataMap = []; - this.declSymbolMap = []; - this.declSignatureSymbolMap = []; - this.declCache = null; - this.symbolCache = null; - this.fileNameToDiagnostics = null; - this._binder = null; - 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); - 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.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.invalidate(); - } - SemanticInfoChain.prototype.getDocument = function (fileName) { - var document = this.fileNameToDocument[fileName]; - return document ? document : null; - }; - - SemanticInfoChain.prototype.lineMap = function (fileName) { - return this.getDocument(fileName).lineMap(); - }; - - SemanticInfoChain.prototype.fileNames = function () { - if (this._fileNames === null) { - this._fileNames = this.documents.slice(1).map(function (s) { - return s.fileName; - }); - } - - return this._fileNames; - }; - - SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { - newSymbol.addDeclaration(decl); - decl.setSymbol(newSymbol); - newSymbol.setResolved(); - - return newSymbol; - }; - - SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { - var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { - var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); - newSymbol.type = type; - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.resetGlobalSymbols = function () { - this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); - this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); - this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); - this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); - this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); - this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); - 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 emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - emptyTypeDecl.setSymbol(emptyTypeSymbol); - emptyTypeSymbol.addDeclaration(emptyTypeDecl); - emptyTypeSymbol.setResolved(); - this.emptyTypeSymbol = emptyTypeSymbol; - }; - - SemanticInfoChain.prototype.addDocument = function (document) { - var fileName = document.fileName; - - var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (existingIndex < 0) { - this.documents.push(document); - } else { - this.documents[existingIndex] = document; - } - - this.fileNameToDocument[fileName] = document; - - this.invalidate(); - }; - - SemanticInfoChain.prototype.removeDocument = function (fileName) { - TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); - var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (index > 0) { - this.fileNameToDocument[fileName] = undefined; - this.documents.splice(index, 1); - this.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { - var cacheID = this.getDeclPathCacheID([name], kind); - - var symbol = this.symbolCache[cacheID]; - - if (!symbol) { - for (var i = 0, n = this.documents.length; i < n; i++) { - var topLevelDecl = this.documents[i].topLevelDecl(); - - var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); - if (symbol) { - break; - } - - if (doNotGoPastThisDecl && topLevelDecl.name == doNotGoPastThisDecl.fileName()) { - return null; - } - } - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { - var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; - - var foundDecls = topLevelDecl.searchChildDecls(name, kind); - - for (var j = 0; j < foundDecls.length; j++) { - var foundDecl = foundDecls[j]; - - if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { - break; - } - - var symbol = foundDecls[j].getSymbol(); - if (symbol) { - return symbol; - } - } - - return null; - }; - - 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]; - if (symbol != undefined) { - return symbol; - } - - symbol = null; - 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 dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - symbol = dynamicModuleDecl.getSymbol(); - this.symbolCache[dtsCacheID] = isDtsFile ? symbol : null; - this.symbolCache[tsCacheID] = !TypeScript.isDTSFile ? symbol : null; - return symbol; - } - } - } - - this.symbolCache[dtsCacheID] = null; - this.symbolCache[tsCacheID] = null; - - return symbol; - }; - - SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { - var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); - - var symbol = this.symbolCache[cacheID]; - if (symbol == undefined) { - symbol = null; - for (var i = 0; i < this.documents.length; i++) { - var document = this.documents[i]; - var topLevelDecl = document.topLevelDecl(); - - if (!topLevelDecl.isExternalModule()) { - var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); - if (dynamicModules.length) { - symbol = dynamicModules[0].getSymbol(); - break; - } - } - } - - this.symbolCache[cacheID] = symbol; - } - - return symbol; - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.topLevelDecls(); - - 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; - - for (var j = 0; j < declsToSearch.length; j++) { - foundDecls = declsToSearch[j].searchChildDecls(path, declKind); - - for (var k = 0; k < foundDecls.length; k++) { - if (decls == TypeScript.sentinelEmptyArray) { - decls = []; - } - decls[decls.length] = foundDecls[k]; - } - - if (foundDecls.length && !keepSearching) { - break; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { - var declString = []; - - for (var i = 0, n = declPath.length; i < n; i++) { - if (declPath[i].kind & 1 /* Script */) { - continue; - } - - declString.push(declPath[i].name); - } - - return this.findDecls(declString, declKind); - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - symbol = decls[0].getSymbol(); - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - } - }; - - SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { - if (typeof oldSettings === "undefined") { oldSettings = null; } - if (typeof newSettings === "undefined") { newSettings = null; } - TypeScript.PullTypeResolver.globalTypeCheckPhase++; - - var cleanStart = new Date().getTime(); - - this.astSymbolMap.length = 0; - this.astAliasSymbolMap.length = 0; - this.astCallResolutionDataMap.length = 0; - - this.declCache = TypeScript.createIntrinsicsObject(); - this.symbolCache = TypeScript.createIntrinsicsObject(); - this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - - this.declSymbolMap.length = 0; - this.declSignatureSymbolMap.length = 0; - - if (oldSettings && newSettings) { - if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { - for (var i = 1, n = this.documents.length; i < n; i++) { - this.documents[i].invalidate(); - } - } - } - - TypeScript.pullSymbolID = 0; - TypeScript.globalTyvarID = 0; - - this.resetGlobalSymbols(); - - var cleanEnd = new Date().getTime(); - }; - - SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() != after.propagateEnumConstants(); - }; - - SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { - this.astAliasSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { - return this.astAliasSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { - return this.astCallResolutionDataMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { - if (callResolutionData) { - this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap[decl.declID] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { - this.declSignatureSymbolMap[decl.declID] = signatureSymbol; - }; - - SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { - return this.declSignatureSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { - var fileName = diagnostic.fileName(); - var diagnostics = this.fileNameToDiagnostics[fileName]; - if (!diagnostics) { - diagnostics = []; - this.fileNameToDiagnostics[fileName] = diagnostics; - } - - diagnostics.push(diagnostic); - }; - - SemanticInfoChain.prototype.getDiagnostics = function (fileName) { - var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics ? diagnostics : []; - }; - - SemanticInfoChain.prototype.getBinder = function () { - if (!this._binder) { - this._binder = new TypeScript.PullSymbolBinder(this); - } - - return this._binder; - }; - - SemanticInfoChain.prototype.getResolver = function () { - if (!this._resolver) { - this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); - } - - return this._resolver; - }; - - SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); - indexParameterSymbol.type = indexParamType; - indexSignature.addParameter(indexParameterSymbol); - indexSignature.returnType = returnType; - indexSignature.setResolved(); - indexParameterSymbol.setResolved(); - - 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()); - indexSigDecl.setSignatureSymbol(indexSignature); - indexParamDecl.setSymbol(indexParameterSymbol); - indexSignature.addDeclaration(indexSigDecl); - indexParameterSymbol.addDeclaration(indexParamDecl); - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast) { - var document = this.getDocument(ast.fileName()); - - if (document) { - return document._getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { - return this.getDocument(ast.fileName()).getEnclosingDecl(ast); - }; - - SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { - this.getDocument(decl.fileName())._setDeclForAST(ast, decl); - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var document = this.getDocument(decl.fileName()); - if (document) { - return document._getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { - this.getDocument(decl.fileName())._setASTForDecl(decl, ast); - }; - - SemanticInfoChain.prototype.topLevelDecl = function (fileName) { - var document = this.getDocument(fileName); - if (document) { - return document.topLevelDecl(); - } - - return null; - }; - - SemanticInfoChain.prototype.topLevelDecls = function () { - if (!this._topLevelDecls) { - this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { - return u.topLevelDecl(); - }); - } - - 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.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); - }; - return SemanticInfoChain; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { - this.document = document; - this.semanticInfoChain = semanticInfoChain; - this.propagateEnumConstants = propagateEnumConstants; - this.isDeclareFile = false; - this.parentChain = []; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - - function containingModuleHasExportAssignment(ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = ast; - return moduleDecl.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } else if (ast.kind() === 120 /* SourceUnit */) { - var sourceUnit = ast; - return sourceUnit.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } - - ast = ast.parent; - } - - return false; - } - - function isParsingAmbientModule(ast, context) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { - return true; - } - } - - ast = ast.parent; - } - - return false; - } - - function preCollectImportDecls(ast, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(importDecl.start(), importDecl.end()); - - var parent = context.getParent(); - - if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { - declFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(importDecl.identifier.valueText(), importDecl.identifier.text(), 128 /* TypeAlias */, declFlags, parent, span); - 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); - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.isDeclareFile = context.document.isDeclareFile(); - - context.pushParent(decl); - - if (isExternalModule) { - var declFlags = 1 /* Exported */; - if (TypeScript.isDTSFile(fileName)) { - declFlags |= 8 /* Ambient */; - } - - 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); - - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, sourceUnit, context); - } - - context.pushParent(decl); - } - } - - 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 */; - } - - if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - declFlags |= 4096 /* Enum */; - 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); - 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()); - enumDeclaration.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); - - context.pushParent(enumDeclaration); - } - - 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); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function preCollectModuleDecls(moduleDecl, context) { - var declFlags = 0 /* None */; - - var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); - - var isDynamic = moduleDecl.stringLiteral !== null; - - if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - 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); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); - } - - context.pushParent(decl); - } else { - var moduleNames = getModuleNames(moduleDecl.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - var moduleName = moduleNames[i]; - - var specificFlags = declFlags; - if (i > 0) { - specificFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent(), span); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleName, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleName); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleName, context); - } - - context.pushParent(decl); - } - } - } - - function getModuleNames(name, result) { - result = result || []; - - if (name.kind() === 121 /* QualifiedName */) { - getModuleNames(name.left, result); - result.push(name.right); - } else { - result.push(name); - } - - return result; - } - TypeScript.getModuleNames = getModuleNames; - - 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()); - decl.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); - } - - function containsExecutableCode(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); - - if (member.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = member; - - if (containsExecutableCode(moduleDecl.moduleElements)) { - return true; - } - } else if (member.kind() !== 128 /* InterfaceDeclaration */ && member.kind() !== 133 /* ImportDeclaration */) { - return true; - } - } - - return false; - } - - 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 */; - } - - if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { - 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 constructorDecl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, parent, span); - - decl.setValueDecl(constructorDecl); - - context.semanticInfoChain.setDeclForAST(classDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, classDecl); - context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); - - context.pushParent(decl); - } - - function preCollectObjectTypeDecls(objectType, context) { - if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { - return; - } - - 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); - context.semanticInfoChain.setDeclForAST(objectType, decl); - context.semanticInfoChain.setASTForDecl(decl, objectType); - - context.pushParent(decl); - } - - function preCollectInterfaceDecls(interfaceDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { - 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); - context.semanticInfoChain.setDeclForAST(interfaceDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, interfaceDecl); - - context.pushParent(decl); - } - - function preCollectParameterDecl(argDecl, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - 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); - - if (argDecl.equalsValueClause) { - parent.flags |= 33554432 /* HasDefaultArgs */; - } - - if (parent.kind == 32768 /* ConstructorMethod */) { - decl.setFlag(67108864 /* ConstructorParameter */); - } - - var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); - 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); - propDecl.setValueDecl(decl); - decl.setFlag(8388608 /* PropertyParameter */); - propDecl.setFlag(8388608 /* PropertyParameter */); - - if (parent.kind == 32768 /* ConstructorMethod */) { - propDecl.setFlag(67108864 /* ConstructorParameter */); - } - - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setASTForDecl(propDecl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, decl); - } - - parent.addVariableDeclToGroup(decl); - } - - 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); - context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); - context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); - } - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = 4096 /* Property */; - - if (propertyDecl.questionToken !== null) { - 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); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { - 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); - context.semanticInfoChain.setDeclForAST(memberDecl, decl); - context.semanticInfoChain.setDeclForAST(memberDecl.variableDeclarator, decl); - context.semanticInfoChain.setASTForDecl(decl, memberDecl); - } - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 512 /* Variable */; - - var modifiers = TypeScript.getVariableDeclaratorModifiers(varDecl); - if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { - 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); - context.semanticInfoChain.setDeclForAST(varDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, varDecl); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectVarDecls(ast, context) { - if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { - return; - } - - var varDecl = ast; - createVariableDeclaration(varDecl, context); - } - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); - - context.pushParent(decl); - } - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); - - context.pushParent(decl); - } - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - if (!funcDeclAST.block) { - 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); - context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); - - context.pushParent(decl); - } - - function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { - if (typeof displayName === "undefined") { displayName = null; } - var declFlags = 0 /* None */; - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - 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 */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = id ? id.text() : ""; - var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, span, displayNameText); - context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); - - context.pushParent(decl); - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrow = functionExpressionDeclAST; - var declFlags = 4 /* Public */; - - var parent = context.getParent(); - - if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { - 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); - - context.semanticInfoChain.setASTForDecl(decl, simpleArrow.identifier); - context.semanticInfoChain.setDeclForAST(simpleArrow.identifier, decl); - - parent.addVariableDeclToGroup(decl); - } - } - - function createMemberFunctionDeclaration(funcDecl, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!funcDecl.block) { - 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); - context.semanticInfoChain.setDeclForAST(funcDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDecl); - - context.pushParent(decl); - } - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); - - context.pushParent(decl); - } - - function createCallSignatureDeclaration(callSignature, context) { - var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; - - if (!isChildOfObjectType) { - return; - } - - 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); - context.semanticInfoChain.setDeclForAST(callSignature, decl); - context.semanticInfoChain.setASTForDecl(decl, callSignature); - - context.pushParent(decl); - } - - function createMethodSignatureDeclaration(method, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - declFlags |= 4 /* Public */; - declFlags |= 2048 /* Signature */; - - if (method.questionToken !== null) { - 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); - context.semanticInfoChain.setDeclForAST(method, decl); - context.semanticInfoChain.setASTForDecl(decl, method); - - context.pushParent(decl); - } - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); - - context.pushParent(decl); - } - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.start(), constructorDeclAST.end()); - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.flags; - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent, span); - context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); - - context.pushParent(decl); - } - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - 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); - context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); - - context.pushParent(decl); - } - - function createFunctionExpressionDeclaration(expression, context) { - createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); - } - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - 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); - context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); - - context.pushParent(decl); - } - - function preCollectCatchDecls(ast, context) { - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - - 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); - context.semanticInfoChain.setDeclForAST(ast.identifier, decl); - context.semanticInfoChain.setASTForDecl(decl, ast.identifier); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectWithDecls(ast, context) { - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - 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); - - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectSimplePropertyAssignmentDecls(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); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - } - - 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); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - - createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); - } - - function preCollectDecls(ast, context) { - switch (ast.kind()) { - case 120 /* SourceUnit */: - preCollectScriptDecls(ast, context); - break; - case 132 /* EnumDeclaration */: - preCollectEnumDecls(ast, context); - break; - case 243 /* EnumElement */: - createEnumElementDecls(ast, context); - break; - case 130 /* ModuleDeclaration */: - preCollectModuleDecls(ast, context); - break; - case 131 /* ClassDeclaration */: - preCollectClassDecls(ast, context); - break; - case 128 /* InterfaceDeclaration */: - preCollectInterfaceDecls(ast, context); - break; - case 122 /* ObjectType */: - preCollectObjectTypeDecls(ast, context); - break; - case 242 /* Parameter */: - preCollectParameterDecl(ast, context); - break; - case 136 /* MemberVariableDeclaration */: - createMemberVariableDeclaration(ast, context); - break; - case 141 /* PropertySignature */: - createPropertySignature(ast, context); - break; - case 225 /* VariableDeclarator */: - preCollectVarDecls(ast, context); - break; - case 137 /* ConstructorDeclaration */: - createClassConstructorDeclaration(ast, context); - break; - case 139 /* GetAccessor */: - createGetAccessorDeclaration(ast, context); - break; - case 140 /* SetAccessor */: - createSetAccessorDeclaration(ast, context); - break; - case 222 /* FunctionExpression */: - createFunctionExpressionDeclaration(ast, context); - break; - case 135 /* MemberFunctionDeclaration */: - createMemberFunctionDeclaration(ast, context); - break; - case 144 /* IndexSignature */: - createIndexSignatureDeclaration(ast, context); - break; - case 123 /* FunctionType */: - createFunctionTypeDeclaration(ast, context); - break; - case 125 /* ConstructorType */: - createConstructorTypeDeclaration(ast, context); - break; - case 142 /* CallSignature */: - createCallSignatureDeclaration(ast, context); - break; - case 143 /* ConstructSignature */: - createConstructSignatureDeclaration(ast, context); - break; - case 145 /* MethodSignature */: - createMethodSignatureDeclaration(ast, context); - break; - case 129 /* FunctionDeclaration */: - createFunctionDeclaration(ast, context); - break; - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - createAnyFunctionExpressionDeclaration(ast, null, context); - break; - case 133 /* ImportDeclaration */: - preCollectImportDecls(ast, context); - break; - case 238 /* TypeParameter */: - preCollectTypeParameterDecl(ast, context); - break; - case 236 /* CatchClause */: - preCollectCatchDecls(ast, context); - break; - case 163 /* WithStatement */: - preCollectWithDecls(ast, context); - break; - case 215 /* ObjectLiteralExpression */: - preCollectObjectLiteralDecls(ast, context); - break; - case 240 /* SimplePropertyAssignment */: - preCollectSimplePropertyAssignmentDecls(ast, context); - break; - case 241 /* FunctionPropertyAssignment */: - preCollectFunctionPropertyAssignmentDecls(ast, context); - break; - } - } - - function isContainer(decl) { - return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.kind & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.kind & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.kind; - - if (kind & 4 /* Container */) { - return (decl.flags & 32768 /* InitializedModule */) !== 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, context) { - var currentDecl = context.getParent(); - - if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { - if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - return; - } - } - - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDeclaration = ast; - if (moduleDeclaration.stringLiteral) { - TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); - context.popParent(); - } else { - var moduleNames = getModuleNames(moduleDeclaration.name); - for (var i = moduleNames.length - 1; i >= 0; i--) { - var moduleName = moduleNames[i]; - TypeScript.Debug.assert(currentDecl.ast() === moduleName); - context.popParent(); - currentDecl = context.getParent(); - } - } - } - - if (ast.kind() === 132 /* EnumDeclaration */) { - computeEnumElementConstantValues(ast, currentDecl, context); - } - - while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { - context.popParent(); - currentDecl = context.getParent(); - } - } - - function computeEnumElementConstantValues(ast, enumDecl, context) { - TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); - - var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); - var inConstantSection = !isAmbientEnum; - var currentConstantValue = 0; - var enumMemberDecls = enumDecl.getChildDecls(); - - for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { - var enumElement = ast.enumElements.nonSeparatorAt(i); - var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { - return context.semanticInfoChain.getASTForDecl(d) === enumElement; - }); - - TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); - - if (enumElement.equalsValueClause === null) { - if (inConstantSection) { - enumElementDecl.constantValue = currentConstantValue; - currentConstantValue++; - } - } else { - enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); - if (enumElementDecl.constantValue !== null && !isAmbientEnum) { - inConstantSection = true; - currentConstantValue = enumElementDecl.constantValue + 1; - } else { - inConstantSection = false; - } - } - - TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); - } - } - - function computeEnumElementConstantValue(expression, enumMemberDecls, context) { - TypeScript.Debug.assert(expression); - - if (TypeScript.isIntegerLiteralAST(expression)) { - var token; - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - token = expression.operand; - break; - default: - token = expression; - } - - var value = token.value(); - return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; - } else if (context.propagateEnumConstants) { - switch (expression.kind()) { - case 11 /* IdentifierName */: - var name = expression; - var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { - return d.name === name.valueText(); - }); - - return matchingEnumElement ? matchingEnumElement.constantValue : null; - - case 202 /* LeftShiftExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left << right; - - case 189 /* BitwiseOrExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left | right; - } - - return null; - } else { - return null; - } - } - - (function (DeclarationCreator) { - function create(document, semanticInfoChain, compilationSettings) { - var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); - - TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); - - return declCollectionContext.getParent(); - } - DeclarationCreator.create = create; - })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); - var DeclarationCreator = TypeScript.DeclarationCreator; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBinder = (function () { - function PullSymbolBinder(semanticInfoChain) { - this.semanticInfoChain = semanticInfoChain; - this.declsBeingBound = []; - } - PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { - if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } - var parentDecl = decl.getParentDecl(); - - if (parentDecl.kind == 1 /* Script */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.hasBeenBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - if (parent) { - var parentDeclKind = parentDecl.kind; - if (parentDeclKind == 262144 /* GetAccessor */) { - parent = parent.getGetter(); - } else if (parentDeclKind == 524288 /* SetAccessor */) { - parent = parent.getSetter(); - } - } - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = parent.getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.type; - } - } - - return parent.type; - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.name, declKind); - } - - var contextSymbolPath = startingDecl.getParentPath(); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].kind & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - }; - - PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { - var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728539 /* SomeType */) !== 0; - var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; - var name = decl.name; - if (parent) { - var isExported = (decl.flags & 1 /* Exported */) !== 0; - - var prevSymbol = null; - if (lookingForValue) { - prevSymbol = parent.findContainedNonMember(name); - } else if (lookingForType) { - prevSymbol = parent.findContainedNonMemberType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); - } - var prevIsExported = !prevSymbol; - if (!prevSymbol) { - if (lookingForValue) { - prevSymbol = parent.findMember(name, false); - } else if (lookingForType) { - prevSymbol = parent.findNestedType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findNestedContainer(name, searchKind); - } - } - - if (isExported && prevIsExported) { - return prevSymbol; - } - if (prevSymbol) { - var prevDecls = prevSymbol.getDeclarations(); - var lastPrevDecl = prevDecls[prevDecls.length - 1]; - var parentDecl = decl.getParentDecl(); - var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); - if (parentDecl !== prevParentDecl) { - return null; - } - - return prevSymbol; - } - } else { - var parentDecl = decl.getParentDecl(); - if (parentDecl && parentDecl.kind === 1 /* Script */) { - return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); - } else { - var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); - return prevDecls[0] && prevDecls[0].getSymbol(); - } - } - - return null; - }; - - PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { - if (typeof reportError === "undefined") { reportError = true; } - 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 (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()]); - } - return false; - } - - return true; - }; - - PullSymbolBinder.prototype.bindEnumDeclarationToPullSymbol = function (enumContainerDecl) { - var enumName = enumContainerDecl.name; - - var enumContainerSymbol = null; - var enumInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var enumInstanceDecl = enumContainerDecl.getValueDecl(); - - var enumDeclKind = enumContainerDecl.kind; - - var parent = this.getParent(enumContainerDecl); - var parentInstanceSymbol = this.getParent(enumContainerDecl, true); - var parentDecl = enumContainerDecl.getParentDecl(); - var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); - - var isExported = enumContainerDecl.flags & 1 /* Exported */; - var isInitializedModule = (enumContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; - - var createdNewSymbol = false; - - enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); - - if (enumContainerSymbol) { - if (enumContainerSymbol.kind !== enumDeclKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(enumAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [enumContainerDecl.getDisplayName()]); - } - enumContainerSymbol = null; - } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { - enumContainerSymbol = null; - } - } - - if (enumContainerSymbol) { - enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); - } else { - enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); - } - } - - enumContainerSymbol.addDeclaration(enumContainerDecl); - enumContainerDecl.setSymbol(enumContainerSymbol); - - this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); - this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - - if (!enumInstanceSymbol && isInitializedModule) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] == enumContainerDecl) { - break; - } - - if ((siblingDecls[i].name == enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol) { - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - enumInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); - } - - enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - enumInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); - } - } - - 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); - } else { - parent.addEnclosedNonMemberType(enumContainerSymbol); - } - } - - this.bindEnumIndexerDeclsToPullSymbols(enumContainerDecl, 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 */); - - syntheticIndexerParameterSymbol.type = this.semanticInfoChain.numberTypeSymbol; - syntheticIndexerParameterSymbol.setResolved(); - - var syntheticIndexerSignatureSymbol = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - syntheticIndexerSignatureSymbol.addParameter(syntheticIndexerParameterSymbol); - syntheticIndexerSignatureSymbol.returnType = this.semanticInfoChain.stringTypeSymbol; - syntheticIndexerSignatureSymbol.setResolved(); - - var enumContainerInstanceTypeSymbol = enumContainerSymbol.getInstanceSymbol().type; - enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); - - indexSigDecl.setSignatureSymbol(syntheticIndexerSignatureSymbol); - indexParamDecl.setSymbol(syntheticIndexerParameterSymbol); - - syntheticIndexerSignatureSymbol.addDeclaration(indexSigDecl); - syntheticIndexerParameterSymbol.addDeclaration(indexParamDecl); - }; - - 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); - if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleContainerDecl.kind === 32 /* DynamicModule */); - TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); - - moduleDeclAST = moduleNameAST; - } - - var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); - var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; - - if (parent && moduleKind == 32 /* DynamicModule */) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); - } - - var createdNewSymbol = false; - - moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); - - if (moduleContainerTypeSymbol) { - if (moduleContainerTypeSymbol.kind !== moduleKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [moduleContainerDecl.getDisplayName()]); - } - - moduleContainerTypeSymbol = null; - } 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 { - moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - 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 moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - - if (createdNewSymbol) { - if (parent) { - if (moduleContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); - } else { - parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); - } - } - } - - var valueDecl = moduleContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - - if (!valueDecl.hasSymbol()) { - valueDecl.setSymbol(moduleInstanceSymbol); - if (!moduleInstanceSymbol.hasDeclaration(valueDecl)) { - moduleInstanceSymbol.addDeclaration(valueDecl); - } - } - } - - var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.kind, true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.flags; - var declKind = importDeclaration.kind; - var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); - - var isExported = false; - var importSymbol = null; - var declName = importDeclaration.name; - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(importDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [importDeclaration.getDisplayName()]); - importSymbol = null; - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(importSymbol); - } else { - parent.addEnclosedNonMemberContainer(importSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { - var className = classDecl.name; - var classSymbol = null; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - var classAST = this.semanticInfoChain.getASTForDecl(classDecl); - - var parent = this.getParent(classDecl); - var parentDecl = classDecl.getParentDecl(); - var isExported = classDecl.flags & 1 /* Exported */; - var isGeneric = false; - - classSymbol = this.getExistingSymbol(classDecl, 58728539 /* SomeType */, parent); - - if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDiagnosticFromAST(classAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [classDecl.getDisplayName()]); - classSymbol = null; - } - - var decls; - - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); - this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); - - if (parent) { - if (classDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(classSymbol); - } else { - parent.addEnclosedNonMemberType(classSymbol); - } - } - - constructorSymbol = classSymbol.getConstructorMethod(); - constructorTypeSymbol = constructorSymbol ? constructorSymbol.type : null; - - if (!constructorSymbol) { - var siblingValueDecls = null; - if (parentDecl) { - siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); - - if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { - constructorSymbol = siblingValueDecls[0].getSymbol(); - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - constructorSymbol.setIsSynthesized(); - constructorSymbol.type = constructorTypeSymbol; - } - - classSymbol.setConstructorMethod(constructorSymbol); - classSymbol.setHasDefaultConstructor(); - } - - if (constructorSymbol.getIsSynthesized()) { - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - constructorTypeSymbol.addDeclaration(classDecl); - } else { - classSymbol.setHasDefaultConstructor(false); - } - - 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); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.name; - var interfaceSymbol = null; - - var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728539 /* SomeType */, parent); - - if (interfaceSymbol) { - if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDiagnosticFromAST(interfaceAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [interfaceDecl.getDisplayName()]); - interfaceSymbol = null; - } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { - interfaceSymbol = null; - } - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - if (interfaceDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(interfaceSymbol); - } else { - parent.addEnclosedNonMemberType(interfaceSymbol); - } - } - } - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); - - interfaceSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - - break; - } - } - } - - 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) { - var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.kind; - var declFlags = constructorTypeDeclaration.flags; - var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); - - var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - signature.hasVarArgs = true; - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - constructorTypeSymbol.addConstructSignature(signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); - - constructorTypeSymbol.addConstructorTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var varDeclAST = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var variableSymbol = null; - - var declName = variableDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - 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; - - variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var decl; - var decls; - var ast; - var members; - - if (variableSymbol) { - var prevKind = variableSymbol.kind; - var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); - var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); - var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); - var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - var prevIsFunction = prevKind == 16384 /* Function */; - var prevIsAmbient = variableSymbol.allDeclsHaveFlag(8 /* Ambient */); - 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 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()])); - 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); - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } else { - this.checkThatExportsMatch(variableDeclaration, variableSymbol); - variableSymbol = null; - parentHadSymbol = false; - } - } - - if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } - } - - if ((declFlags & 118784 /* ImplicitVariable */) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - if (!parent && parentDecl.kind === 1 /* Script */) { - this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); - } - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfoChain.setSymbolForAST(varDeclAST.propertyName, variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - 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(); - } - } - } - } - - if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728539 /* SomeType */, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfoChain.getASTForDecl(decl); - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else if (declFlags & 102400 /* SomeInitializedModule */) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - 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(); - } - } - } - } - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - if (moduleContainerTypeSymbol) { - variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - variableDeclaration.setSymbol(variableSymbol); - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - variableDeclaration.setSymbol(variableSymbol); - } - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addMember(variableSymbol); - } else { - 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) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var declName = variableDeclaration.name; - - var variableSymbol = new TypeScript.PullSymbol(declName, declKind); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - - this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); - }; - - PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - var propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - - var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; - - var isStatic = false; - var isOptional = false; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); - - if (isOptional) { - propertySymbol.isOptional = true; - } - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { - var parameters = []; - var params = TypeScript.createIntrinsicsObject(); - var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); - - if (parameterList) { - for (var i = 0, n = parameterList.length; i < n; i++) { - var argDecl = parameterList.astAt(i); - var id = parameterList.identifierAt(i); - var decl = this.semanticInfoChain.getDeclForAST(argDecl); - var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); - var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); - - if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { - 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) { - if (isProperty) { - decl.ensureSymbolIsBound(); - var valDecl = decl.getValueDecl(); - - if (valDecl) { - valDecl.setSymbol(parameterSymbol); - parameterSymbol.addDeclaration(valDecl); - } - } else { - parameterSymbol.addDeclaration(decl); - decl.setSymbol(parameterSymbol); - } - } - - signatureSymbol.addParameter(parameterSymbol, parameterSymbol.isOptional); - - if (signatureSymbol.isDefinition()) { - funcType.addEnclosedNonMember(parameterSymbol); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.kind; - var declFlags = functionDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - 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; - if (!acceptableRedeclaration) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [functionDeclaration.getDisplayName()]); - functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); - } - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.type; - parentHadSymbol = true; - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionSymbol.type = functionTypeSymbol; - functionTypeSymbol.setFunctionSymbol(functionSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol); - } else { - parent.addEnclosedNonMember(functionSymbol); - } - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { - signature.hasVarArgs = true; - } - - var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - 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(); - } - } - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.kind; - 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 funcExpAST = ast; - - 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); - - functionSymbol.type = functionTypeSymbol; - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; - if (name) { - this.semanticInfoChain.setSymbolForAST(name, functionSymbol); - } - - this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - - var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (parameters.lastParameterIsRest()) { - signature.hasVarArgs = true; - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - - functionTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.kind; - var declFlags = functionTypeDeclaration.flags; - var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcTypeAST, TypeScript.Parameters.fromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - - functionTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.kind; - var declFlags = methodDeclaration.flags; - var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - 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()]); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.type; - parentHadSymbol = true; - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - methodSymbol.type = methodTypeSymbol; - methodTypeSymbol.setFunctionSymbol(methodSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - - var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; - - TypeScript.Debug.assert(nameAST); - - this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); - this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); - - if (isOptional) { - methodSymbol.isOptional = true; - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol); - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); - - var parameterList = TypeScript.getParameterList(methodAST); - if (TypeScript.lastParameterIsRest(parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].name; - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); - signature.addTypeParameter(typeParameter); - } else { - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.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(); - } - } - }; - - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (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()])); - } - - 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); - - prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - prototypeSymbol.setIsSynthesized(); - prototypeSymbol.addDeclaration(prototypeDecl); - prototypeSymbol.type = classTypeSymbol; - constructorTypeSymbol.addMember(prototypeSymbol); - - if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { - var resolver = this.semanticInfoChain.getResolver(); - prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); - } - prototypeSymbol.setResolved(); - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.kind; - var declFlags = constructorDeclaration.flags; - var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { - var hasDefinitionSignature = false; - var constructorSigs = constructorSymbol.type.getConstructSignatures(); - - for (var i = 0; i < constructorSigs.length; i++) { - if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { - hasDefinitionSignature = true; - break; - } - } - - if (hasDefinitionSignature) { - this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); - - constructorSymbol = null; - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.type = constructorTypeSymbol; - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - constructorSymbol.setIsSynthesized(false); - this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - - var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - - constructSignature.returnType = parent; - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, TypeScript.Parameters.fromParameterList(constructorAST.parameterList), constructorTypeSymbol, constructSignature); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructSignature.addTypeParameter(typeParameters[i]); - } - - if (TypeScript.lastParameterIsRest(constructorAST.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); - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - constructSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(funcDecl)), null, constructSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - - parent.addConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { - callSignature.hasVarArgs = true; - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - callSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), null, callSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - - parent.addCallSignature(callSignature); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameter(funcDecl.parameter), null, indexSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); - - var parent = this.getParent(indexSignatureDeclaration); - parent.addIndexSignature(indexSignature); - indexSignature.setContainer(parent); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.kind; - var declFlags = getAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.type; - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - getterTypeSymbol.setFunctionSymbol(getterSymbol); - - getterSymbol.type = getterTypeSymbol; - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - - getterTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.kind; - var declFlags = setAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - - if (setterSymbol) { - setterTypeSymbol = setterSymbol.type; - } - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - setterTypeSymbol.setFunctionSymbol(setterSymbol); - - setterSymbol.type = setterTypeSymbol; - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), setterTypeSymbol, signature); - - setterTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl) { - if (decl.hasBeenBound()) { - return; - } - - if (this.declsBeingBound.indexOf(decl.declID) >= 0) { - return; - } - - this.declsBeingBound.push(decl.declID); - - switch (decl.kind) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - this.bindEnumDeclarationToPullSymbol(decl); - break; - - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 512 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 1024 /* CatchVariable */: - this.bindCatchVariableToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - this.bindEnumMemberDeclarationToPullSymbol(decl); - break; - - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 128 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - decl.getParentDecl().getSymbol(); - break; - - case 268435456 /* CatchBlock */: - case 134217728 /* WithBlock */: - break; - - default: - TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); - } - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); - this.declsBeingBound.pop(); - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullHelpers) { - function getSignatureForFuncDecl(functionDecl) { - var funcDecl = functionDecl.ast(); - var funcSymbol = functionDecl.getSymbol(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().type; - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.type; - } - var signatures; - - if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (functionDecl.kind === 4194304 /* IndexSignature */) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; - } - PullHelpers.symbolIsEnum = symbolIsEnum; - - function symbolIsModule(symbol) { - return symbol && (symbol.kind == 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); - } - PullHelpers.symbolIsModule = symbolIsModule; - - function isOneDeclarationOfKind(symbol, kind) { - var decls = symbol.getDeclarations(); - for (var i = 0; i < decls.length; i++) { - if (decls[i].kind === kind) { - return true; - } - } - - return false; - } - - function isNameNumeric(name) { - return isFinite(+name); - } - PullHelpers.isNameNumeric = isNameNumeric; - - function typeSymbolsAreIdentical(a, b) { - if (a.isTypeReference() && !a.getIsSpecialized()) { - a = a.referencedTypeSymbol; - } - - if (b.isTypeReference() && !b.getIsSpecialized()) { - b = b.referencedTypeSymbol; - } - - return a == b; - } - PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; - - function getRootType(type) { - var rootType = type.getRootSymbol(); - - while (true) { - if (type == rootType) { - return type; - } - - type = rootType; - rootType = type.getRootSymbol(); - } - } - PullHelpers.getRootType = getRootType; - - function isSymbolLocal(symbol) { - var container = symbol.getContainer(); - if (container) { - var containerKind = container.kind; - if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { - return true; - } - - if (containerKind == 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */)) { - return true; - } - } - - return false; - } - PullHelpers.isSymbolLocal = isSymbolLocal; - })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); - var PullHelpers = TypeScript.PullHelpers; -})(TypeScript || (TypeScript = {})); -if (Error) - Error.stackTraceLimit = 1000; - -var TypeScript; -(function (TypeScript) { - TypeScript.fileResolutionTime = 0; - TypeScript.fileResolutionIOTime = 0; - TypeScript.fileResolutionScanImportsTime = 0; - TypeScript.fileResolutionImportFileSearchTime = 0; - TypeScript.fileResolutionGetDefaultLibraryTime = 0; - TypeScript.sourceCharactersCompiled = 0; - TypeScript.syntaxTreeParseTime = 0; - TypeScript.syntaxDiagnosticsTime = 0; - TypeScript.astTranslationTime = 0; - TypeScript.typeCheckTime = 0; - - TypeScript.compilerResolvePathTime = 0; - TypeScript.compilerDirectoryNameTime = 0; - TypeScript.compilerDirectoryExistsTime = 0; - TypeScript.compilerFileExistsTime = 0; - - TypeScript.emitTime = 0; - TypeScript.emitWriteFileTime = 0; - - TypeScript.declarationEmitTime = 0; - TypeScript.declarationEmitIsExternallyVisibleTime = 0; - TypeScript.declarationEmitTypeSignatureTime = 0; - TypeScript.declarationEmitGetBoundDeclTypeTime = 0; - TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; - TypeScript.declarationEmitGetBaseTypeTime = 0; - TypeScript.declarationEmitGetAccessorFunctionTime = 0; - TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; - TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; - - TypeScript.ioHostResolvePathTime = 0; - TypeScript.ioHostDirectoryNameTime = 0; - TypeScript.ioHostCreateDirectoryStructureTime = 0; - TypeScript.ioHostWriteFileTime = 0; - - var EmitOutput = (function () { - function EmitOutput() { - this.outputFiles = []; - this.diagnostics = []; - } - return EmitOutput; - })(); - TypeScript.EmitOutput = EmitOutput; - - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); - var OutputFileType = TypeScript.OutputFileType; - - var OutputFile = (function () { - function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { - if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.text = text; - this.fileType = fileType; - this.sourceMapEntries = sourceMapEntries; - } - return OutputFile; - })(); - TypeScript.OutputFile = OutputFile; - - var CompileResult = (function () { - function CompileResult() { - this.diagnostics = []; - this.outputFiles = []; - } - CompileResult.fromDiagnostics = function (diagnostics) { - var result = new CompileResult(); - result.diagnostics = diagnostics; - return result; - }; - - CompileResult.fromOutputFiles = function (outputFiles) { - var result = new CompileResult(); - result.outputFiles = outputFiles; - return result; - }; - return CompileResult; - })(); - TypeScript.CompileResult = CompileResult; - - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, _settings) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } - this.logger = logger; - this._settings = _settings; - this.semanticInfoChain = null; - this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); - } - TypeScriptCompiler.prototype.compilationSettings = function () { - return this._settings; - }; - - TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { - var oldSettings = this._settings; - this._settings = newSettings; - - if (!compareDataObjects(oldSettings, newSettings)) { - this.semanticInfoChain.invalidate(oldSettings, newSettings); - } - }; - - TypeScriptCompiler.prototype.getDocument = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.semanticInfoChain.getDocument(fileName); - }; - - TypeScriptCompiler.prototype.cleanupSemanticCache = function () { - this.semanticInfoChain.invalidate(); - }; - - TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - fileName = TypeScript.switchToForwardSlashes(fileName); - - TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); - - var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); - - this.semanticInfoChain.addDocument(document); - }; - - TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); - - this.semanticInfoChain.addDocument(updatedDocument); - }; - - TypeScriptCompiler.prototype.removeFile = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - 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; - if (emitOptions.outputDirectory() !== "") { - updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); - updatedFileName = emitOptions.outputDirectory() + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(emitOptions.sharedOutputFile(), true); - } - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - var printReason = false; - - if (document.emitToOwnOutputFile()) { - var result = document.byteOrderMark !== 0 /* None */; - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - } - return result; - } else { - var fileNames = this.fileNames(); - - var result = false; - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - - if (document.isExternalModule()) { - continue; - } - - if (document.byteOrderMark !== 0 /* None */) { - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - result = true; - } else { - return true; - } - } - } - - return result; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype._shouldEmit = function (document) { - return !document.isDeclareFile(); - }; - - TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { - if (!this.compilationSettings().generateDeclarationFiles()) { - return false; - } - - return this._shouldEmit(document); - }; - - TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); - - if (declarationEmitter) { - declarationEmitter.document = document; - } else { - var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); - } - - declarationEmitter.emitDeclarations(sourceUnit); - return declarationEmitter; - }; - - TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmitDeclarations(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFile()); - } - } else { - sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var sharedEmitter = null; - var fileNames = this.fileNames(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileNames[i]); - - sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); - } - - TypeScript.declarationEmitTime += new Date().getTime() - start; - - return emitOutput; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, null); - return emitOutput; - } else { - return this.emitAllDeclarations(resolvePath); - } - }; - - TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { - if (wholeFileNameReplaced) { - return fileName; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmit(document)); - - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); - var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); - - if (this.compilationSettings().mapSourceFiles()) { - var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); - emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); - } - } else if (this.compilationSettings().mapSourceFiles()) { - emitter.setSourceMapperNewSourceFile(document); - } - - emitter.setDocument(document); - emitter.emitJavascript(sourceUnit, false); - - return emitter; - }; - - TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmit(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFiles()); - } - } else { - sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var fileNames = this.fileNames(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - sharedEmitter = this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); - } - - TypeScript.emitTime += new Date().getTime() - start; - return emitOutput; - }; - - TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, null); - return emitOutput; - } else { - return this.emitAll(resolvePath); - } - }; - - TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { - if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } - return new CompilerIterator(this, resolvePath, continueOnDiagnostics); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - - TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { - return this.getDocument(fileName).sourceUnit(); - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - - var startTime = (new Date()).getTime(); - TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); - var endTime = (new Date()).getTime(); - - TypeScript.typeCheckTime += endTime - startTime; - - var errors = this.semanticInfoChain.getDiagnostics(fileName); - - errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); - errors.sort(function (d1, d2) { - if (d1.fileName() < d2.fileName()) { - return -1; - } else if (d1.fileName() > d2.fileName()) { - return 1; - } - - if (d1.start() < d2.start()) { - return -1; - } else if (d1.start() > d2.start()) { - return 1; - } - - var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; - var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; - if (code1 < code2) { - return -1; - } else if (code1 > code2) { - return 1; - } - - return 0; - }); - - return errors; - }; - - TypeScriptCompiler.prototype.resolveAllFiles = function () { - var fileNames = this.fileNames(); - for (var i = 0, n = fileNames.length; i < n; i++) { - this.getSemanticDiagnostics(fileNames[i]); - } - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var ast = this.semanticInfoChain.getASTForDecl(decl); - if (!ast) { - return null; - } - - var enclosingDecl = resolver.getEnclosingDecl(decl); - if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { - return this.getSymbolOfDeclaration(enclosingDecl); - } - - return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { - var scriptName = document.fileName; - - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - var inWithBlock = false; - - var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); - - if (!ast) { - return null; - } - - var path = this.getASTPath(ast); - - for (var i = 0, n = path.length; i < n; i++) { - var current = path[i]; - - switch (current.kind()) { - case 222 /* FunctionExpression */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - if (propagateContextualTypes) { - resolver.resolveAST(current, true, resolutionContext); - } - break; - - case 136 /* MemberVariableDeclaration */: - var memberVariable = current; - inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); - break; - - case 225 /* VariableDeclarator */: - var variableDeclarator = current; - inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); - break; - - case 213 /* InvocationExpression */: - case 216 /* ObjectCreationExpression */: - if (propagateContextualTypes) { - var isNew = current.kind() === 216 /* ObjectCreationExpression */; - var callExpression = current; - 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); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = path[i + 3]; - if (argExpression) { - for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { - if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext); - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 214 /* ArrayLiteralExpression */: - if (propagateContextualTypes) { - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 215 /* ObjectLiteralExpression */: - if (propagateContextualTypes) { - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.propertyAssignments; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { - if (memberDecls.nonSeparatorAt(j) === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - } - - break; - - case 174 /* AssignmentExpression */: - if (propagateContextualTypes) { - var assignmentExpression = current; - var contextualType = null; - - if (path[i + 1] && path[i + 1] === assignmentExpression.right) { - var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 150 /* ReturnStatement */: - if (propagateContextualTypes) { - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 122 /* ObjectType */: - if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { - resolver.resolveAST(current, false, resolutionContext); - } - - break; - - case 163 /* WithStatement */: - inWithBlock = true; - break; - } - - var decl = this.semanticInfoChain.getDeclForAST(current); - if (decl) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { - if (ast.parent.kind() === 212 /* MemberAccessExpression */) { - if (ast.parent.name === ast) { - ast = ast.parent; - } - } else if (ast.parent.kind() === 121 /* QualifiedName */) { - if (ast.parent.right === ast) { - ast = ast.parent; - } - } - } - - return { - ast: ast, - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment, - inWithBlock: inWithBlock - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { - if (inContextuallyTypedAssignment) { - if (propagateContextualTypes) { - resolver.resolveAST(assigningAST, false, resolutionContext); - var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.type; - } - - resolutionContext.pushContextualType(contextualType, false, null); - - if (init) { - resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); - } - } - } - }; - - TypeScriptCompiler.prototype.getASTPath = function (ast) { - var result = []; - - while (ast) { - result.unshift(ast); - ast = ast.parent; - } - - return result; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - ast = context.ast; - 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()]); - return null; - } - - if (symbol.isTypeReference()) { - symbol = symbol.getReferencedTypeSymbol(); - } - - var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); - - return { - symbol: symbol, - aliasSymbol: aliasSymbol, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { - if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { - return null; - } - - var isNew = ast.kind() === 216 /* ObjectCreationExpression */; - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, false); - if (!context || context.inWithBlock) { - return null; - } - - return resolver.getVisibleDecls(context.enclosingDecl); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { - if (ast.kind() !== 215 /* ObjectLiteralExpression */) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var astForDecl = decl.ast(); - if (!astForDecl) { - return null; - } - - var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); - if (!astForDeclContext) { - return null; - } - - var symbol = decl.getSymbol(); - resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - aliasSymbol: null, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - - TypeScriptCompiler.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast); - }; - - TypeScriptCompiler.prototype.fileNames = function () { - return this.semanticInfoChain.fileNames(); - }; - - TypeScriptCompiler.prototype.topLevelDecl = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - return TypeScriptCompiler; - })(); - TypeScript.TypeScriptCompiler = TypeScriptCompiler; - - var CompilerPhase; - (function (CompilerPhase) { - CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; - CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; - CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; - CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; - CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; - })(CompilerPhase || (CompilerPhase = {})); - - var CompilerIterator = (function () { - function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { - if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } - this.compiler = compiler; - this.resolvePath = resolvePath; - this.continueOnDiagnostics = continueOnDiagnostics; - this.index = -1; - this.fileNames = null; - this._current = null; - this._emitOptions = null; - this._sharedEmitter = null; - this._sharedDeclarationEmitter = null; - this.hadSyntacticDiagnostics = false; - this.hadSemanticDiagnostics = false; - this.hadEmitDiagnostics = false; - this.fileNames = compiler.fileNames(); - this.compilerPhase = startingPhase; - } - CompilerIterator.prototype.current = function () { - return this._current; - }; - - CompilerIterator.prototype.moveNext = function () { - this._current = null; - - while (this.moveNextInternal()) { - if (this._current) { - return true; - } - } - - return false; - }; - - CompilerIterator.prototype.moveNextInternal = function () { - this.index++; - - while (this.shouldMoveToNextPhase()) { - this.index = 0; - this.compilerPhase++; - } - - if (this.compilerPhase > 4 /* DeclarationEmit */) { - return false; - } - - switch (this.compilerPhase) { - case 0 /* Syntax */: - return this.moveNextSyntaxPhase(); - case 1 /* Semantics */: - return this.moveNextSemanticsPhase(); - case 2 /* EmitOptionsValidation */: - return this.moveNextEmitOptionsValidationPhase(); - case 3 /* Emit */: - return this.moveNextEmitPhase(); - case 4 /* DeclarationEmit */: - return this.moveNextDeclarationEmitPhase(); - } - }; - - CompilerIterator.prototype.shouldMoveToNextPhase = function () { - switch (this.compilerPhase) { - case 2 /* EmitOptionsValidation */: - return this.index === 1; - - case 0 /* Syntax */: - case 1 /* Semantics */: - return this.index == this.fileNames.length; - - case 3 /* Emit */: - case 4 /* DeclarationEmit */: - return this.index == (this.fileNames.length + 1); - } - - return false; - }; - - CompilerIterator.prototype.moveNextSyntaxPhase = function () { - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - - var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSyntacticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextSemanticsPhase = function () { - if (this.hadSyntacticDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - var diagnostics = this.compiler.getSemanticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSemanticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - - if (!this._emitOptions) { - this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); - } - - if (this._emitOptions.diagnostic()) { - if (!this.continueOnDiagnostics) { - this.hadEmitDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(this._emitOptions); - - if (this.hadEmitDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { - _this._current = CompileResult.fromOutputFiles(outputFiles); - }, this._sharedEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedEmitter) { - this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); - } - - return true; - }; - - CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(!this.hadEmitDiagnostics); - if (this.hadSemanticDiagnostics) { - return false; - } - - if (!this.compiler.compilationSettings().generateDeclarationFiles()) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { - _this._current = CompileResult.fromOutputFiles([file]); - }, this._sharedDeclarationEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { - this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); - } - - return true; - }; - return CompilerIterator; - })(); - - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] == "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } else if (typeof dst[e] != "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - TypeScript.compareDataObjects = compareDataObjects; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (GenerativeTypeClassification) { - GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; - GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; - GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; - GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; - })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); - var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; - - var PullTypeReferenceSymbol = (function (_super) { - __extends(PullTypeReferenceSymbol, _super); - function PullTypeReferenceSymbol(referencedTypeSymbol) { - _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); - this.referencedTypeSymbol = referencedTypeSymbol; - this.isResolved = true; - - TypeScript.Debug.assert(referencedTypeSymbol != null, "Type root symbol may not be null"); - - this.setRootSymbol(referencedTypeSymbol); - - this.typeReference = this; - } - PullTypeReferenceSymbol.createTypeReference = function (type) { - if (type.isTypeReference()) { - return type; - } - - var typeReference = type.typeReference; - - if (!typeReference) { - typeReference = new PullTypeReferenceSymbol(type); - type.typeReference = typeReference; - } - - return typeReference; - }; - - PullTypeReferenceSymbol.prototype.isTypeReference = function () { - return true; - }; - - PullTypeReferenceSymbol.prototype.setResolved = function () { - }; - - PullTypeReferenceSymbol.prototype.setUnresolved = function () { - }; - PullTypeReferenceSymbol.prototype.invalidate = function () { - }; - - PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { - this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); - }; - - PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol; - }; - - PullTypeReferenceSymbol.prototype._getResolver = function () { - return this.referencedTypeSymbol._getResolver(); - }; - - PullTypeReferenceSymbol.prototype.hasMembers = function () { - return this.referencedTypeSymbol.hasMembers(); - }; - - PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); - }; - - PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - return this.referencedTypeSymbol.getAssociatedContainerType(); - }; - - PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getFunctionSymbol(); - }; - PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); - }; - - PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); - }; - PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); - }; - - PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); - }; - PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMember(name); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); - }; - - PullTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getMembers(); - }; - - PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); - }; - PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getHasDefaultConstructor(); - }; - PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructorMethod(); - }; - PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); - }; - PullTypeReferenceSymbol.prototype.getTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.isGeneric = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isGeneric(); - }; - - PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getSpecialization(substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getKnownSpecializations(); - }; - PullTypeReferenceSymbol.prototype.getTypeArguments = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArguments(); - }; - PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.addCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addCallSignature"); - }; - PullTypeReferenceSymbol.prototype.addConstructSignature = function (constructSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructSignature"); - }; - PullTypeReferenceSymbol.prototype.addIndexSignature = function (indexSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addIndexSignature"); - }; - - PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnIndexSignatures(); - }; - PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getIndexSignatures(); - }; - - PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { - this.referencedTypeSymbol.addImplementedType(implementedType); - }; - PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getImplementedTypes(); - }; - PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { - this.referencedTypeSymbol.addExtendedType(extendedType); - }; - PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getExtendedTypes(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExtendsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExtendThisType(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - this.ensureReferencedTypeIsResolved(); - 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); - }; - - PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findMember(name, lookInParent); - }; - PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedType(name, kind); - }; - PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedContainer(name, kind); - }; - PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - }; - - PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findTypeParameter(name); - }; - - PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); - }; - return PullTypeReferenceSymbol; - })(TypeScript.PullTypeSymbol); - TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - - var PullInstantiatedTypeReferenceSymbol = (function (_super) { - __extends(PullInstantiatedTypeReferenceSymbol, _super); - function PullInstantiatedTypeReferenceSymbol(referencedTypeSymbol, _typeParameterArgumentMap) { - _super.call(this, referencedTypeSymbol); - this.referencedTypeSymbol = referencedTypeSymbol; - this._typeParameterArgumentMap = _typeParameterArgumentMap; - this._instantiatedMembers = null; - this._allInstantiatedMemberNameCache = null; - this._instantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - this._instantiatedCallSignatures = null; - this._instantiatedConstructSignatures = null; - this._instantiatedIndexSignatures = null; - this._typeArgumentReferences = null; - this._instantiatedConstructorMethod = null; - this._instantiatedAssociatedContainerType = null; - this._isArray = undefined; - this.isInstanceReferenceType = false; - this._generativeTypeClassification = 0 /* Unknown */; - - TypeScript.nSpecializationsCreated++; - } - PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { - return !this.isInstanceReferenceType; - }; - - 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 */; - } - } - } - } - - return this._generativeTypeClassification; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArray === undefined) { - this._isArray = this.getRootSymbol().isArrayNamedTypeReference() || (this.getRootSymbol() == this._getResolver().getArrayNamedType()); - } - return this._isArray; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { - if (!this.isArrayNamedTypeReference()) { - return null; - } - - var typeArguments = this.getTypeArguments(); - - if (typeArguments != null) { - return typeArguments[0]; - } - - return null; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.getIsSpecialized()) { - return this; - } - - return this.referencedTypeSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.create = function (resolver, type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } - TypeScript.Debug.assert(resolver); - - 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; - } - } - } - } - - if (!instantiateFunctionTypeParameters) { - var instantiation = rootType.getSpecialization(reconstructedTypeArgumentList); - - 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 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) { - 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); - - if (!instantiateFunctionTypeParameters) { - rootType.addSpecialization(instantiation, reconstructedTypeArgumentList); - } - - if (isReferencedType) { - instantiation.isInstanceReferenceType = true; - } - - return instantiation; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return !!this.referencedTypeSymbol.getTypeParameters().length; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { - return this._typeParameterArgumentMap; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { - if (this.isInstanceReferenceType) { - return this.getTypeParameters(); - } - - if (!this._typeArgumentReferences) { - var typeParameters = this.referencedTypeSymbol.getTypeParameters(); - - if (typeParameters.length) { - var typeArgument = null; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; - - if (!typeArgument) { - TypeScript.Debug.fail("type argument count mismatch"); - } - - if (typeArgument) { - typeArguments[typeArguments.length] = typeArgument; - } - } - - this._typeArgumentReferences = typeArguments; - } - } - - return this._typeArgumentReferences; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeArguments(); - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getMembers(); - } - - if (!this._instantiatedMembers) { - var referencedMembers = this.referencedTypeSymbol.getMembers(); - var referencedMember = null; - var instantiatedMember = null; - - this._instantiatedMembers = []; - - for (var i = 0; i < referencedMembers.length; i++) { - referencedMember = referencedMembers[i]; - - 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._instantiatedMembers[this._instantiatedMembers.length] = instantiatedMember; - } - } - - return this._instantiatedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.findMember(name, lookInParent); - } - - var memberSymbol = this._instantiatedMemberNameCache[name]; - - if (!memberSymbol) { - 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; - } else { - memberSymbol = null; - } - } - - return memberSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - } - - var requestedMembers = []; - var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - - if (!this._allInstantiatedMemberNameCache) { - this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - - var members = this.getMembers(); - - for (var i = 0; i < members.length; i++) { - this._allInstantiatedMemberNameCache[members[i].name] = members[i]; - } - } - - var referencedMember = null; - var requestedMember = null; - - for (var i = 0; i < allReferencedMembers.length; i++) { - referencedMember = allReferencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (this._allInstantiatedMemberNameCache[referencedMember.name]) { - requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; - } else { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; - requestedMembers[requestedMembers.length] = referencedMember; - } else { - requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - requestedMember.setRootSymbol(referencedMember); - - requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - requestedMember.isOptional = referencedMember.isOptional; - - this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; - requestedMembers[requestedMembers.length] = requestedMember; - } - } - } - - return requestedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructorMethod(); - } - - if (!this._instantiatedConstructorMethod) { - var referencedConstructorMethod = this.referencedTypeSymbol.getConstructorMethod(); - this._instantiatedConstructorMethod = new TypeScript.PullSymbol(referencedConstructorMethod.name, referencedConstructorMethod.kind); - this._instantiatedConstructorMethod.type = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedConstructorMethod.type, this._typeParameterArgumentMap); - } - - return this._instantiatedConstructorMethod; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - if (!this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAssociatedContainerType(); - } - - if (!this._instantiatedAssociatedContainerType) { - var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); - - if (referencedAssociatedContainerType) { - this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); - } - } - - return this._instantiatedAssociatedContainerType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getCallSignatures(); - } - - if (this._instantiatedCallSignatures) { - return this._instantiatedCallSignatures; - } - - var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); - this._instantiatedCallSignatures = []; - - for (var i = 0; i < referencedCallSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); - - if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; - } else { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedCallSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructSignatures(); - } - - if (this._instantiatedConstructSignatures) { - return this._instantiatedConstructSignatures; - } - - var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); - this._instantiatedConstructSignatures = []; - - for (var i = 0; i < referencedConstructSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); - - if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; - } else { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedConstructSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getIndexSignatures(); - } - - if (this._instantiatedIndexSignatures) { - return this._instantiatedIndexSignatures; - } - - var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); - this._instantiatedIndexSignatures = []; - - for (var i = 0; i < referencedIndexSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); - - if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; - } else { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.previousTokenTrailingComments = null; - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { - var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { - var firstToken = node.firstToken(); - var lastToken = node.lastToken(); - - this.setSpan(ast, fullStart, node, firstToken, lastToken); - ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); - ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); - }; - - SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { - if (element === null) { - return null; - } - - if (element.fullWidth() === 0) { - return new TypeScript.ASTSpan(-1, -1); - } - - var leadingTriviaWidth = element.leadingTriviaWidth(); - var trailingTriviaWidth = element.trailingTriviaWidth(); - - var start = fullStart + leadingTriviaWidth; - var end = fullStart + element.fullWidth() - trailingTriviaWidth; - - return new TypeScript.ASTSpan(start, end); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { - if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } - if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } - var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; - var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; - - var desiredMinChar = fullStart + leadingTriviaWidth; - var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span._trailingTriviaWidth = trailingTriviaWidth; - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - span._start = start; - span._end = end; - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { - var start = this.position; - var array = new Array(node.childCount()); - - for (var i = 0, n = node.childCount(); i < n; i++) { - array[i] = node.childAt(i).accept(this); - } - - var result = new TypeScript.ISyntaxList2(this.fileName, array); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var array = new Array(list.nonSeparatorCount()); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - array[i / 2] = list.childAt(i).accept(this); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); - this.setSpan(result, start, list); - - result.setPostComments(this.previousTokenTrailingComments); - this.previousTokenTrailingComments = null; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { - if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); - }; - - SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { - return this.visitToken(token); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - var fullStart = this.position; - - var result = this.visitTokenWorker(token); - - this.movePast(token); - - var start = fullStart + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { - switch (token.tokenKind) { - case 60 /* AnyKeyword */: - return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); - case 61 /* BooleanKeyword */: - return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); - case 67 /* NumberKeyword */: - return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); - case 69 /* StringKeyword */: - return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); - case 41 /* VoidKeyword */: - return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); - case 35 /* ThisKeyword */: - return new TypeScript.ThisExpression(token.text(), token.valueText()); - case 50 /* SuperKeyword */: - return new TypeScript.SuperExpression(token.text(), token.valueText()); - case 37 /* TrueKeyword */: - return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); - case 24 /* FalseKeyword */: - return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); - case 32 /* NullKeyword */: - return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); - case 14 /* StringLiteral */: - return new TypeScript.StringLiteral(token.text(), token.valueText()); - case 12 /* RegularExpressionLiteral */: - return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); - case 13 /* NumericLiteral */: - var fullStart = this.position; - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); - - result.setPreComments(preComments); - return result; - case 11 /* IdentifierName */: - return new TypeScript.Identifier(token.text()); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { - var start = this.position; - TypeScript.Debug.assert(start === 0); - - var bod = this.visitSyntaxList(node.moduleElements); - - var result = new TypeScript.SourceUnit(bod, this.fileName); - this.setSpanExplicit(result, start, start + node.fullWidth()); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { - var start = this.position; - - this.moveTo(node, node.stringLiteral); - var stringLiteral = node.stringLiteral.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ExternalModuleReference(stringLiteral); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { - var start = this.position; - var moduleName = node.moduleName.accept(this); - - var result = new TypeScript.ModuleNameModuleReference(moduleName); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - this.movePast(node.openBraceToken); - var members = this.visitSyntaxList(node.classElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { - var result = null; - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { - result = result || []; - result.push(1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - result = result || []; - result.push(8 /* Ambient */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { - result = result || []; - result.push(16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { - result = result || []; - result.push(4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { - result = result || []; - result.push(2 /* Private */); - } - - return result || TypeScript.sentinelEmptyArray; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - var body = this.visitObjectType(node.body); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - var start = this.position; - - this.movePast(node.extendsOrImplementsKeyword); - var typeNames = this.visitSeparatedSyntaxList(node.typeNames); - - var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - var start = this.position; - - var modifiers = this.visitModifiers(node.modifiers); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - - var moduleName = node.name ? node.name.accept(this) : null; - var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; - - this.movePast(node.openBraceToken); - - var moduleElements = this.visitSyntaxList(node.moduleElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - this.movePast(node.openBraceToken); - - var enumElements = this.visitSeparatedSyntaxList(node.enumElements); - - this.movePast(node.closeBraceToken); - - var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - var start = this.position; - - var memberName = this.visitToken(node.propertyName); - - var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.EnumElement(memberName, value); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ImportDeclaration(modifiers, name, alias); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExportAssignment(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.VariableStatement(modifiers, declaration); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - var start = this.position; - var propertyName = this.visitToken(node.propertyName); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - var start = this.position; - var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var value = node.value.accept(this); - value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); - - var result = new TypeScript.EqualsValueClause(value); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var start = this.position; - - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var start = this.position; - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayLiteralExpression(expressions); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - var start = this.position; - - var result = new TypeScript.OmittedExpression(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var start = this.position; - - var openParenToken = node.openParenToken; - var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(openParenToken); - - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var start = this.position; - - var identifier = node.identifier.accept(this); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var start = this.position; - - var callSignature = this.visitCallSignature(node.callSignature); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - return type ? type.accept(this) : null; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { - var start = this.position; - this.movePast(node.typeOfKeyword); - var name = node.name.accept(this); - - var result = new TypeScript.TypeQuery(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - var start = this.position; - var left = this.visitType(node.left); - this.movePast(node.dotToken); - var right = this.visitIdentifier(node.right); - - var result = new TypeScript.QualifiedName(left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeArgumentList(typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - var start = this.position; - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - var start = this.position; - - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectType(typeMembers); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayType(underlying); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.name); - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - var result = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.colonToken); - var type = this.visitType(node.type); - - var result = new TypeScript.TypeAnnotation(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - - var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - var start = this.position; - - var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.visitIdentifier(node.name); - - var result = new TypeScript.MemberAccessExpression(expression, name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var start = this.position; - - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.InvocationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - this.movePast(node.openParenToken); - - 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()); - } - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ArgumentList(typeArguments, arguments, closeParenToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - var start = this.position; - - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - var result = new TypeScript.BinaryExpression(node.kind(), left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - var start = this.position; - - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.ConstructSignature(callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.MethodSignature(name, questionToken, callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - var start = this.position; - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.IndexSignature(parameter, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - var openParenToken = node.openParenToken; - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - var openParenTrailingComments = null; - if (node.parameters.childCount() === 0) { - openParenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - } - - this.movePast(node.openParenToken); - var parameters = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - var start = this.position; - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeParameterList(typeParameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - var result = new TypeScript.TypeParameter(identifier, constraint); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - var start = this.position; - this.movePast(node.extendsKeyword); - var type = this.visitType(node.type); - - var result = new TypeScript.Constraint(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - var result = new TypeScript.IfStatement(condition, thenBod, elseBod); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - var start = this.position; - - this.movePast(node.elseKeyword); - var statement = node.statement.accept(this); - - var result = new TypeScript.ElseClause(statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var expression = node.expression.accept(this); - - var semicolonPosition = this.position; - - var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExpressionStatement(expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.parameterList); - var parameters = this.visitParameterList(node.parameterList); - - var block = node.block ? node.block.accept(this) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.ConstructorDeclaration(parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.indexSignature); - var indexSignature = node.indexSignature.accept(this); - - this.movePast(node.semicolonToken); - - var result = new TypeScript.IndexMemberDeclaration(indexSignature); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarator); - var variableDeclarator = node.variableDeclarator.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - var start = this.position; - - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ThrowStatement(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - var start = this.position; - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ReturnStatement(expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.ObjectCreationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - var start = this.position; - - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - this.movePast(node.openBraceToken); - var switchClauses = this.visitSyntaxList(node.switchClauses); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.CaseSwitchClause(expression, statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.DefaultSwitchClause(statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - var start = this.position; - - this.movePast(node.breakKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.BreakStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - var start = this.position; - - this.movePast(node.continueKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ContinueStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var initializer = node.initializer ? node.initializer.accept(this) : null; - - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var left = node.left ? node.left.accept(this) : null; - - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WhileStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WithStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - var start = this.position; - - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - var result = new TypeScript.CastExpression(castTerm, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var start = this.position; - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); - - var propertyName = node.propertyName.accept(this); - - var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var expression = node.expression.accept(this); - expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); - - var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var start = this.position; - - var propertyName = node.propertyName.accept(this); - var callSignature = this.visitCallSignature(node.callSignature); - var block = this.visitBlock(node.block); - - var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - var start = this.position; - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? node.block.accept(this) : null; - - var result = new TypeScript.FunctionExpression(name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - var start = this.position; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.EmptyStatement(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - var start = this.position; - - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - var start = this.position; - - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.visitIdentifier(node.identifier); - var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - var start = this.position; - this.movePast(node.finallyKeyword); - var block = node.block.accept(this); - - var result = new TypeScript.FinallyClause(block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.LabeledStatement(identifier, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - var start = this.position; - - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DoStatement(statement, whileKeyword, condition); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - var start = this.position; - - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.TypeOfExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - var start = this.position; - - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.DeleteExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - var start = this.position; - - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.VoidExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - var start = this.position; - - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DebuggerStatement(); - this.setSpan(result, start, node); - - return result; - }; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; - - function applyDelta(ast, delta) { - if (ast) { - if (ast._start !== -1) { - ast._start += delta; - } - - if (ast._end !== -1) { - ast._end += delta; - } - } - } - - function applyDeltaToComments(comments, delta) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment, delta); - } - } - } - - var SyntaxTreeToIncrementalAstVisitor = (function (_super) { - __extends(SyntaxTreeToIncrementalAstVisitor, _super); - function SyntaxTreeToIncrementalAstVisitor() { - _super.apply(this, arguments); - } - SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { - if (delta === 0) { - return; - } - - var pre = function (cur) { - applyDelta(cur, delta); - applyDeltaToComments(cur.preComments(), delta); - applyDeltaToComments(cur.postComments(), delta); - - switch (cur.kind()) { - case 146 /* Block */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 226 /* ArgumentList */: - applyDelta(cur.closeParenToken, delta); - break; - - case 130 /* ModuleDeclaration */: - applyDelta(cur.endingToken, delta); - break; - - case 131 /* ClassDeclaration */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 161 /* DoStatement */: - applyDelta(cur.whileKeyword, delta); - break; - - case 151 /* SwitchStatement */: - applyDelta(cur.closeParenToken, delta); - break; - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span._start !== -1) { - var delta = start - span._start; - this.applyDelta(span, delta); - - span._end = end; - } else { - _super.prototype.setSpanExplicit.call(this, span, start, end); - } - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - var result = element._ast; - if (!result) { - return null; - } - - var start = this.position; - this.movePast(element); - this.setSpan(result, start, element); - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { - element._ast = ast; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSeparatedSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { - var result = this.getAndMovePastAST(token); - - if (!result) { - result = _super.prototype.visitToken.call(this, token); - this.setAST(token, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitClassDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInterfaceDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitHeritageClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitModuleDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitImportDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExportAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPrefixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitOmittedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - var result = _super.prototype.visitQualifiedName.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGenericType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBlock.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPostfixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitElementAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInvocationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBinaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConditionalExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMethodSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIndexSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPropertySignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCallSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIfStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExpressionStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberVariableDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitThrowStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitReturnStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectCreationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSwitchStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCaseSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDefaultSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBreakStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitContinueStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForInStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWhileStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWithStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCastExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimplePropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitEmptyStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTryStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCatchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitLabeledStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDoStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeOfExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDeleteExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitVoidExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDebuggerStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - return SyntaxTreeToIncrementalAstVisitor; - })(SyntaxTreeToAstVisitor); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan(_start, _end) { - this._start = _start; - this._end = _end; - } - ASTSpan.prototype.start = function () { - return this._start; - }; - - ASTSpan.prototype.end = function () { - return this._end; - }; - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - var astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, false); - } - - function commentStructuralEqualsIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, true); - } - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); - } - - function commentStructuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - function commentArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST() { - this.parent = null; - this._start = -1; - this._end = -1; - this._trailingTriviaWidth = 0; - this._astID = astID++; - this._preComments = null; - this._postComments = null; - } - AST.prototype.syntaxID = function () { - return this._astID; - }; - - AST.prototype.start = function () { - return this._start; - }; - - AST.prototype.end = function () { - return this._end; - }; - - AST.prototype.trailingTriviaWidth = function () { - return this._trailingTriviaWidth; - }; - - AST.prototype.fileName = function () { - return this.parent.fileName(); - }; - - AST.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - AST.prototype.preComments = function () { - return this._preComments; - }; - - AST.prototype.postComments = function () { - return this._postComments; - }; - - AST.prototype.setPreComments = function (comments) { - if (comments && comments.length) { - this._preComments = comments; - } else if (this._preComments) { - this._preComments = null; - } - }; - - AST.prototype.setPostComments = function (comments) { - if (comments && comments.length) { - this._postComments = comments; - } else if (this._postComments) { - this._postComments = null; - } - }; - - AST.prototype.width = function () { - return this.end() - this.start(); - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); - }; - return AST; - })(); - TypeScript.AST = AST; - - var ISyntaxList2 = (function (_super) { - __extends(ISyntaxList2, _super); - function ISyntaxList2(_fileName, members) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISyntaxList2.prototype.childCount = function () { - return this.members.length; - }; - - ISyntaxList2.prototype.childAt = function (index) { - return this.members[index]; - }; - - ISyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISyntaxList2.prototype.kind = function () { - return 1 /* List */; - }; - - ISyntaxList2.prototype.firstOrDefault = function (func) { - return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.lastOrDefault = function (func) { - return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.any = function (func) { - return TypeScript.ArrayUtilities.any(this.members, func); - }; - - ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISyntaxList2; - })(AST); - TypeScript.ISyntaxList2 = ISyntaxList2; - - var ISeparatedSyntaxList2 = (function (_super) { - __extends(ISeparatedSyntaxList2, _super); - function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - this._separatorCount = _separatorCount; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { - return this.members.length; - }; - - ISeparatedSyntaxList2.prototype.separatorCount = function () { - return this._separatorCount; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { - return this.members[index]; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i) === ast) { - return i; - } - } - - return -1; - }; - - ISeparatedSyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISeparatedSyntaxList2.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISeparatedSyntaxList2; - })(AST); - TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; - - var SourceUnit = (function (_super) { - __extends(SourceUnit, _super); - function SourceUnit(moduleElements, _fileName) { - _super.call(this); - this.moduleElements = moduleElements; - this._fileName = _fileName; - moduleElements && (moduleElements.parent = this); - } - SourceUnit.prototype.fileName = function () { - return this._fileName; - }; - - SourceUnit.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return SourceUnit; - })(AST); - TypeScript.SourceUnit = SourceUnit; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(_text) { - _super.call(this); - this._text = _text; - this._valueText = null; - } - Identifier.prototype.text = function () { - return this._text; - }; - Identifier.prototype.valueText = function () { - if (!this._valueText) { - var text = this._text; - if (text === "__proto__") { - this._valueText = "#__proto__"; - } else { - this._valueText = TypeScript.Syntax.massageEscapes(text); - } - } - - return this._valueText; - }; - - Identifier.prototype.kind = function () { - return 11 /* IdentifierName */; - }; - - Identifier.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; - }; - return Identifier; - })(AST); - TypeScript.Identifier = Identifier; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - LiteralExpression.prototype.text = function () { - return this._text; - }; - - LiteralExpression.prototype.valueText = function () { - return this._valueText; - }; - - LiteralExpression.prototype.kind = function () { - return this._nodeType; - }; - - LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return LiteralExpression; - })(AST); - TypeScript.LiteralExpression = LiteralExpression; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - ThisExpression.prototype.text = function () { - return this._text; - }; - - ThisExpression.prototype.valueText = function () { - return this._valueText; - }; - - ThisExpression.prototype.kind = function () { - return 35 /* ThisKeyword */; - }; - - ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ThisExpression; - })(AST); - TypeScript.ThisExpression = ThisExpression; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - SuperExpression.prototype.text = function () { - return this._text; - }; - - SuperExpression.prototype.valueText = function () { - return this._valueText; - }; - - SuperExpression.prototype.kind = function () { - return 50 /* SuperKeyword */; - }; - - SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return SuperExpression; - })(AST); - TypeScript.SuperExpression = SuperExpression; - - var NumericLiteral = (function (_super) { - __extends(NumericLiteral, _super); - function NumericLiteral(_value, _text, _valueText) { - _super.call(this); - this._value = _value; - this._text = _text; - this._valueText = _valueText; - } - NumericLiteral.prototype.text = function () { - return this._text; - }; - NumericLiteral.prototype.valueText = function () { - return this._valueText; - }; - NumericLiteral.prototype.value = function () { - return this._value; - }; - - NumericLiteral.prototype.kind = function () { - return 13 /* NumericLiteral */; - }; - - 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; - }; - return NumericLiteral; - })(AST); - TypeScript.NumericLiteral = NumericLiteral; - - var RegularExpressionLiteral = (function (_super) { - __extends(RegularExpressionLiteral, _super); - function RegularExpressionLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - RegularExpressionLiteral.prototype.text = function () { - return this._text; - }; - - RegularExpressionLiteral.prototype.valueText = function () { - return this._valueText; - }; - - RegularExpressionLiteral.prototype.kind = function () { - return 12 /* RegularExpressionLiteral */; - }; - return RegularExpressionLiteral; - })(AST); - TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; - } - StringLiteral.prototype.text = function () { - return this._text; - }; - StringLiteral.prototype.valueText = function () { - return this._valueText; - }; - - StringLiteral.prototype.kind = function () { - return 14 /* StringLiteral */; - }; - - StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; - }; - return StringLiteral; - })(AST); - TypeScript.StringLiteral = StringLiteral; - - var TypeAnnotation = (function (_super) { - __extends(TypeAnnotation, _super); - function TypeAnnotation(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - TypeAnnotation.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - return TypeAnnotation; - })(AST); - TypeScript.TypeAnnotation = TypeAnnotation; - - var BuiltInType = (function (_super) { - __extends(BuiltInType, _super); - function BuiltInType(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - BuiltInType.prototype.text = function () { - return this._text; - }; - - BuiltInType.prototype.valueText = function () { - return this._valueText; - }; - - BuiltInType.prototype.kind = function () { - return this._nodeType; - }; - return BuiltInType; - })(AST); - TypeScript.BuiltInType = BuiltInType; - - var ExternalModuleReference = (function (_super) { - __extends(ExternalModuleReference, _super); - function ExternalModuleReference(stringLiteral) { - _super.call(this); - this.stringLiteral = stringLiteral; - stringLiteral && (stringLiteral.parent = this); - } - ExternalModuleReference.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - return ExternalModuleReference; - })(AST); - TypeScript.ExternalModuleReference = ExternalModuleReference; - - var ModuleNameModuleReference = (function (_super) { - __extends(ModuleNameModuleReference, _super); - function ModuleNameModuleReference(moduleName) { - _super.call(this); - this.moduleName = moduleName; - moduleName && (moduleName.parent = this); - } - ModuleNameModuleReference.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - return ModuleNameModuleReference; - })(AST); - TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(modifiers, identifier, moduleReference) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.moduleReference = moduleReference; - identifier && (identifier.parent = this); - moduleReference && (moduleReference.parent = this); - } - ImportDeclaration.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(identifier) { - _super.call(this); - this.identifier = identifier; - identifier && (identifier.parent = this); - } - ExportAssignment.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var TypeParameterList = (function (_super) { - __extends(TypeParameterList, _super); - function TypeParameterList(typeParameters) { - _super.call(this); - this.typeParameters = typeParameters; - typeParameters && (typeParameters.parent = this); - } - TypeParameterList.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - return TypeParameterList; - })(AST); - TypeScript.TypeParameterList = TypeParameterList; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - heritageClauses && (heritageClauses.parent = this); - classElements && (classElements.parent = this); - } - ClassDeclaration.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return ClassDeclaration; - })(AST); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - body && (body.parent = this); - heritageClauses && (heritageClauses.parent = this); - } - InterfaceDeclaration.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return InterfaceDeclaration; - })(AST); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var HeritageClause = (function (_super) { - __extends(HeritageClause, _super); - function HeritageClause(_nodeType, typeNames) { - _super.call(this); - this._nodeType = _nodeType; - this.typeNames = typeNames; - typeNames && (typeNames.parent = this); - } - HeritageClause.prototype.kind = function () { - return this._nodeType; - }; - - HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); - }; - return HeritageClause; - })(AST); - TypeScript.HeritageClause = HeritageClause; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { - _super.call(this); - this.modifiers = modifiers; - this.name = name; - this.stringLiteral = stringLiteral; - this.moduleElements = moduleElements; - this.endingToken = endingToken; - name && (name.parent = this); - stringLiteral && (stringLiteral.parent = this); - moduleElements && (moduleElements.parent = this); - } - ModuleDeclaration.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return ModuleDeclaration; - })(AST); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(modifiers, identifier, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionDeclaration.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(modifiers, declaration) { - _super.call(this); - this.modifiers = modifiers; - this.declaration = declaration; - declaration && (declaration.parent = this); - } - VariableStatement.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(AST); - TypeScript.VariableStatement = VariableStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this); - this.declarators = declarators; - declarators && (declarators.parent = this); - } - VariableDeclaration.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - VariableDeclarator.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - return VariableDeclarator; - })(AST); - TypeScript.VariableDeclarator = VariableDeclarator; - - var EqualsValueClause = (function (_super) { - __extends(EqualsValueClause, _super); - function EqualsValueClause(value) { - _super.call(this); - this.value = value; - value && (value.parent = this); - } - EqualsValueClause.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - return EqualsValueClause; - })(AST); - TypeScript.EqualsValueClause = EqualsValueClause; - - var PrefixUnaryExpression = (function (_super) { - __extends(PrefixUnaryExpression, _super); - function PrefixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PrefixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - PrefixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); - }; - return PrefixUnaryExpression; - })(AST); - TypeScript.PrefixUnaryExpression = PrefixUnaryExpression; - - var ArrayLiteralExpression = (function (_super) { - __extends(ArrayLiteralExpression, _super); - function ArrayLiteralExpression(expressions) { - _super.call(this); - this.expressions = expressions; - expressions && (expressions.parent = this); - } - ArrayLiteralExpression.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expressions, ast.expressions, includingPosition); - }; - return ArrayLiteralExpression; - })(AST); - TypeScript.ArrayLiteralExpression = ArrayLiteralExpression; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.apply(this, arguments); - } - OmittedExpression.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return OmittedExpression; - })(AST); - TypeScript.OmittedExpression = OmittedExpression; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(openParenTrailingComments, expression) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.expression = expression; - expression && (expression.parent = this); - } - ParenthesizedExpression.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ParenthesizedExpression; - })(AST); - TypeScript.ParenthesizedExpression = ParenthesizedExpression; - - var SimpleArrowFunctionExpression = (function (_super) { - __extends(SimpleArrowFunctionExpression, _super); - function SimpleArrowFunctionExpression(identifier, block, expression) { - _super.call(this); - this.identifier = identifier; - this.block = block; - this.expression = expression; - identifier && (identifier.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - SimpleArrowFunctionExpression.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - return SimpleArrowFunctionExpression; - })(AST); - TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; - - var ParenthesizedArrowFunctionExpression = (function (_super) { - __extends(ParenthesizedArrowFunctionExpression, _super); - function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - this.expression = expression; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - ParenthesizedArrowFunctionExpression.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - return ParenthesizedArrowFunctionExpression; - })(AST); - TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; - - var QualifiedName = (function (_super) { - __extends(QualifiedName, _super); - function QualifiedName(left, right) { - _super.call(this); - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - QualifiedName.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedName.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); - }; - return QualifiedName; - })(AST); - TypeScript.QualifiedName = QualifiedName; - - var ParameterList = (function (_super) { - __extends(ParameterList, _super); - function ParameterList(openParenTrailingComments, parameters) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.parameters = parameters; - parameters && (parameters.parent = this); - } - ParameterList.prototype.kind = function () { - return 227 /* ParameterList */; - }; - return ParameterList; - })(AST); - TypeScript.ParameterList = ParameterList; - - var ConstructorType = (function (_super) { - __extends(ConstructorType, _super); - function ConstructorType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - ConstructorType.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - return ConstructorType; - })(AST); - TypeScript.ConstructorType = ConstructorType; - - var FunctionType = (function (_super) { - __extends(FunctionType, _super); - function FunctionType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - FunctionType.prototype.kind = function () { - return 123 /* FunctionType */; - }; - return FunctionType; - })(AST); - TypeScript.FunctionType = FunctionType; - - var ObjectType = (function (_super) { - __extends(ObjectType, _super); - function ObjectType(typeMembers) { - _super.call(this); - this.typeMembers = typeMembers; - typeMembers && (typeMembers.parent = this); - } - ObjectType.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); - }; - return ObjectType; - })(AST); - TypeScript.ObjectType = ObjectType; - - var ArrayType = (function (_super) { - __extends(ArrayType, _super); - function ArrayType(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - ArrayType.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); - }; - return ArrayType; - })(AST); - TypeScript.ArrayType = ArrayType; - - var TypeArgumentList = (function (_super) { - __extends(TypeArgumentList, _super); - function TypeArgumentList(typeArguments) { - _super.call(this); - this.typeArguments = typeArguments; - typeArguments && (typeArguments.parent = this); - } - TypeArgumentList.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - return TypeArgumentList; - })(AST); - TypeScript.TypeArgumentList = TypeArgumentList; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArgumentList) { - _super.call(this); - this.name = name; - this.typeArgumentList = typeArgumentList; - name && (name.parent = this); - typeArgumentList && (typeArgumentList.parent = this); - } - GenericType.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeQuery = (function (_super) { - __extends(TypeQuery, _super); - function TypeQuery(name) { - _super.call(this); - this.name = name; - name && (name.parent = this); - } - TypeQuery.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); - }; - return TypeQuery; - })(AST); - TypeScript.TypeQuery = TypeQuery; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements, closeBraceLeadingComments, closeBraceToken) { - _super.call(this); - this.statements = statements; - this.closeBraceLeadingComments = closeBraceLeadingComments; - this.closeBraceToken = closeBraceToken; - statements && (statements.parent = this); - } - Block.prototype.kind = function () { - return 146 /* Block */; - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(AST); - TypeScript.Block = Block; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - _super.call(this); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - Parameter.prototype.kind = function () { - return 242 /* Parameter */; - }; - return Parameter; - })(AST); - TypeScript.Parameter = Parameter; - - var MemberAccessExpression = (function (_super) { - __extends(MemberAccessExpression, _super); - function MemberAccessExpression(expression, name) { - _super.call(this); - this.expression = expression; - this.name = name; - expression && (expression.parent = this); - name && (name.parent = this); - } - MemberAccessExpression.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - 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); - }; - return MemberAccessExpression; - })(AST); - TypeScript.MemberAccessExpression = MemberAccessExpression; - - var PostfixUnaryExpression = (function (_super) { - __extends(PostfixUnaryExpression, _super); - function PostfixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PostfixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - PostfixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); - }; - return PostfixUnaryExpression; - })(AST); - TypeScript.PostfixUnaryExpression = PostfixUnaryExpression; - - var ElementAccessExpression = (function (_super) { - __extends(ElementAccessExpression, _super); - function ElementAccessExpression(expression, argumentExpression) { - _super.call(this); - this.expression = expression; - this.argumentExpression = argumentExpression; - expression && (expression.parent = this); - argumentExpression && (argumentExpression.parent = this); - } - ElementAccessExpression.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - 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); - }; - return ElementAccessExpression; - })(AST); - TypeScript.ElementAccessExpression = ElementAccessExpression; - - var InvocationExpression = (function (_super) { - __extends(InvocationExpression, _super); - function InvocationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - InvocationExpression.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - 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); - }; - return InvocationExpression; - })(AST); - TypeScript.InvocationExpression = InvocationExpression; - - var ArgumentList = (function (_super) { - __extends(ArgumentList, _super); - function ArgumentList(typeArgumentList, arguments, closeParenToken) { - _super.call(this); - this.typeArgumentList = typeArgumentList; - this.arguments = arguments; - this.closeParenToken = closeParenToken; - typeArgumentList && (typeArgumentList.parent = this); - arguments && (arguments.parent = this); - } - ArgumentList.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - return ArgumentList; - })(AST); - TypeScript.ArgumentList = ArgumentList; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(_nodeType, left, right) { - _super.call(this); - this._nodeType = _nodeType; - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - BinaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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); - }; - return BinaryExpression; - })(AST); - TypeScript.BinaryExpression = BinaryExpression; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(condition, whenTrue, whenFalse) { - _super.call(this); - this.condition = condition; - this.whenTrue = whenTrue; - this.whenFalse = whenFalse; - condition && (condition.parent = this); - whenTrue && (whenTrue.parent = this); - whenFalse && (whenFalse.parent = this); - } - ConditionalExpression.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - 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); - }; - return ConditionalExpression; - })(AST); - TypeScript.ConditionalExpression = ConditionalExpression; - - var ConstructSignature = (function (_super) { - __extends(ConstructSignature, _super); - function ConstructSignature(callSignature) { - _super.call(this); - this.callSignature = callSignature; - callSignature && (callSignature.parent = this); - } - ConstructSignature.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - return ConstructSignature; - })(AST); - TypeScript.ConstructSignature = ConstructSignature; - - var MethodSignature = (function (_super) { - __extends(MethodSignature, _super); - function MethodSignature(propertyName, questionToken, callSignature) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - } - MethodSignature.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - return MethodSignature; - })(AST); - TypeScript.MethodSignature = MethodSignature; - - var IndexSignature = (function (_super) { - __extends(IndexSignature, _super); - function IndexSignature(parameter, typeAnnotation) { - _super.call(this); - this.parameter = parameter; - this.typeAnnotation = typeAnnotation; - parameter && (parameter.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - IndexSignature.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - return IndexSignature; - })(AST); - TypeScript.IndexSignature = IndexSignature; - - var PropertySignature = (function (_super) { - __extends(PropertySignature, _super); - function PropertySignature(propertyName, questionToken, typeAnnotation) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - PropertySignature.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - return PropertySignature; - })(AST); - TypeScript.PropertySignature = PropertySignature; - - var CallSignature = (function (_super) { - __extends(CallSignature, _super); - function CallSignature(typeParameterList, parameterList, typeAnnotation) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - CallSignature.prototype.kind = function () { - return 142 /* CallSignature */; - }; - return CallSignature; - })(AST); - TypeScript.CallSignature = CallSignature; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(identifier, constraint) { - _super.call(this); - this.identifier = identifier; - this.constraint = constraint; - identifier && (identifier.parent = this); - constraint && (constraint.parent = this); - } - TypeParameter.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var Constraint = (function (_super) { - __extends(Constraint, _super); - function Constraint(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - Constraint.prototype.kind = function () { - return 239 /* Constraint */; - }; - return Constraint; - })(AST); - TypeScript.Constraint = Constraint; - - var ElseClause = (function (_super) { - __extends(ElseClause, _super); - function ElseClause(statement) { - _super.call(this); - this.statement = statement; - statement && (statement.parent = this); - } - ElseClause.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ElseClause; - })(AST); - TypeScript.ElseClause = ElseClause; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(condition, statement, elseClause) { - _super.call(this); - this.condition = condition; - this.statement = statement; - this.elseClause = elseClause; - condition && (condition.parent = this); - statement && (statement.parent = this); - elseClause && (elseClause.parent = this); - } - IfStatement.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); - }; - return IfStatement; - })(AST); - TypeScript.IfStatement = IfStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ExpressionStatement.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(AST); - TypeScript.ExpressionStatement = ExpressionStatement; - - var ConstructorDeclaration = (function (_super) { - __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(parameterList, block) { - _super.call(this); - this.parameterList = parameterList; - this.block = block; - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - ConstructorDeclaration.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - return ConstructorDeclaration; - })(AST); - TypeScript.ConstructorDeclaration = ConstructorDeclaration; - - var MemberFunctionDeclaration = (function (_super) { - __extends(MemberFunctionDeclaration, _super); - function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - MemberFunctionDeclaration.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - return MemberFunctionDeclaration; - })(AST); - TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; - - var GetAccessor = (function (_super) { - __extends(GetAccessor, _super); - function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - GetAccessor.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - return GetAccessor; - })(AST); - TypeScript.GetAccessor = GetAccessor; - - var SetAccessor = (function (_super) { - __extends(SetAccessor, _super); - function SetAccessor(modifiers, propertyName, parameterList, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - SetAccessor.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - return SetAccessor; - })(AST); - TypeScript.SetAccessor = SetAccessor; - - var MemberVariableDeclaration = (function (_super) { - __extends(MemberVariableDeclaration, _super); - function MemberVariableDeclaration(modifiers, variableDeclarator) { - _super.call(this); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - variableDeclarator && (variableDeclarator.parent = this); - } - MemberVariableDeclaration.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - return MemberVariableDeclaration; - })(AST); - TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; - - var IndexMemberDeclaration = (function (_super) { - __extends(IndexMemberDeclaration, _super); - function IndexMemberDeclaration(indexSignature) { - _super.call(this); - this.indexSignature = indexSignature; - indexSignature && (indexSignature.parent = this); - } - IndexMemberDeclaration.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - return IndexMemberDeclaration; - })(AST); - TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ThrowStatement.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(AST); - TypeScript.ThrowStatement = ThrowStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ReturnStatement.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ReturnStatement; - })(AST); - TypeScript.ReturnStatement = ReturnStatement; - - var ObjectCreationExpression = (function (_super) { - __extends(ObjectCreationExpression, _super); - function ObjectCreationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - ObjectCreationExpression.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - 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); - }; - return ObjectCreationExpression; - })(AST); - TypeScript.ObjectCreationExpression = ObjectCreationExpression; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(expression, closeParenToken, switchClauses) { - _super.call(this); - this.expression = expression; - this.closeParenToken = closeParenToken; - this.switchClauses = switchClauses; - expression && (expression.parent = this); - switchClauses && (switchClauses.parent = this); - } - SwitchStatement.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return SwitchStatement; - })(AST); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseSwitchClause = (function (_super) { - __extends(CaseSwitchClause, _super); - function CaseSwitchClause(expression, statements) { - _super.call(this); - this.expression = expression; - this.statements = statements; - expression && (expression.parent = this); - statements && (statements.parent = this); - } - CaseSwitchClause.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return CaseSwitchClause; - })(AST); - TypeScript.CaseSwitchClause = CaseSwitchClause; - - var DefaultSwitchClause = (function (_super) { - __extends(DefaultSwitchClause, _super); - function DefaultSwitchClause(statements) { - _super.call(this); - this.statements = statements; - statements && (statements.parent = this); - } - DefaultSwitchClause.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return DefaultSwitchClause; - })(AST); - TypeScript.DefaultSwitchClause = DefaultSwitchClause; - - var BreakStatement = (function (_super) { - __extends(BreakStatement, _super); - function BreakStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - BreakStatement.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return BreakStatement; - })(AST); - TypeScript.BreakStatement = BreakStatement; - - var ContinueStatement = (function (_super) { - __extends(ContinueStatement, _super); - function ContinueStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - ContinueStatement.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ContinueStatement; - })(AST); - TypeScript.ContinueStatement = ContinueStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.condition = condition; - this.incrementor = incrementor; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - initializer && (initializer.parent = this); - condition && (condition.parent = this); - incrementor && (incrementor.parent = this); - statement && (statement.parent = this); - } - ForStatement.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForStatement; - })(AST); - TypeScript.ForStatement = ForStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(variableDeclaration, left, expression, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.left = left; - this.expression = expression; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - left && (left.parent = this); - expression && (expression.parent = this); - statement && (statement.parent = this); - } - ForInStatement.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForInStatement; - })(AST); - TypeScript.ForInStatement = ForInStatement; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WhileStatement.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WhileStatement; - })(AST); - TypeScript.WhileStatement = WhileStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WithStatement.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WithStatement; - })(AST); - TypeScript.WithStatement = WithStatement; - - var EnumDeclaration = (function (_super) { - __extends(EnumDeclaration, _super); - function EnumDeclaration(modifiers, identifier, enumElements) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.enumElements = enumElements; - identifier && (identifier.parent = this); - enumElements && (enumElements.parent = this); - } - EnumDeclaration.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - return EnumDeclaration; - })(AST); - TypeScript.EnumDeclaration = EnumDeclaration; - - var EnumElement = (function (_super) { - __extends(EnumElement, _super); - function EnumElement(propertyName, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - EnumElement.prototype.kind = function () { - return 243 /* EnumElement */; - }; - return EnumElement; - })(AST); - TypeScript.EnumElement = EnumElement; - - var CastExpression = (function (_super) { - __extends(CastExpression, _super); - function CastExpression(type, expression) { - _super.call(this); - this.type = type; - this.expression = expression; - type && (type.parent = this); - expression && (expression.parent = this); - } - CastExpression.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - 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); - }; - return CastExpression; - })(AST); - TypeScript.CastExpression = CastExpression; - - var ObjectLiteralExpression = (function (_super) { - __extends(ObjectLiteralExpression, _super); - function ObjectLiteralExpression(propertyAssignments) { - _super.call(this); - this.propertyAssignments = propertyAssignments; - propertyAssignments && (propertyAssignments.parent = this); - } - ObjectLiteralExpression.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.propertyAssignments, ast.propertyAssignments, includingPosition); - }; - return ObjectLiteralExpression; - })(AST); - TypeScript.ObjectLiteralExpression = ObjectLiteralExpression; - - var SimplePropertyAssignment = (function (_super) { - __extends(SimplePropertyAssignment, _super); - function SimplePropertyAssignment(propertyName, expression) { - _super.call(this); - this.propertyName = propertyName; - this.expression = expression; - propertyName && (propertyName.parent = this); - expression && (expression.parent = this); - } - SimplePropertyAssignment.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - return SimplePropertyAssignment; - })(AST); - TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; - - var FunctionPropertyAssignment = (function (_super) { - __extends(FunctionPropertyAssignment, _super); - function FunctionPropertyAssignment(propertyName, callSignature, block) { - _super.call(this); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionPropertyAssignment.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - return FunctionPropertyAssignment; - })(AST); - TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; - - var FunctionExpression = (function (_super) { - __extends(FunctionExpression, _super); - function FunctionExpression(identifier, callSignature, block) { - _super.call(this); - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionExpression.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - return FunctionExpression; - })(AST); - TypeScript.FunctionExpression = FunctionExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.apply(this, arguments); - } - EmptyStatement.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(AST); - TypeScript.EmptyStatement = EmptyStatement; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(block, catchClause, finallyClause) { - _super.call(this); - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - block && (block.parent = this); - catchClause && (catchClause.parent = this); - finallyClause && (finallyClause.parent = this); - } - TryStatement.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); - }; - return TryStatement; - })(AST); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(identifier, typeAnnotation, block) { - _super.call(this); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.block = block; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - CatchClause.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var FinallyClause = (function (_super) { - __extends(FinallyClause, _super); - function FinallyClause(block) { - _super.call(this); - this.block = block; - block && (block.parent = this); - } - FinallyClause.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return FinallyClause; - })(AST); - TypeScript.FinallyClause = FinallyClause; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this); - this.identifier = identifier; - this.statement = statement; - identifier && (identifier.parent = this); - statement && (statement.parent = this); - } - LabeledStatement.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(AST); - TypeScript.LabeledStatement = LabeledStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(statement, whileKeyword, condition) { - _super.call(this); - this.statement = statement; - this.whileKeyword = whileKeyword; - this.condition = condition; - statement && (statement.parent = this); - condition && (condition.parent = this); - } - DoStatement.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); - }; - return DoStatement; - })(AST); - TypeScript.DoStatement = DoStatement; - - var TypeOfExpression = (function (_super) { - __extends(TypeOfExpression, _super); - function TypeOfExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - TypeOfExpression.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return TypeOfExpression; - })(AST); - TypeScript.TypeOfExpression = TypeOfExpression; - - var DeleteExpression = (function (_super) { - __extends(DeleteExpression, _super); - function DeleteExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - DeleteExpression.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return DeleteExpression; - })(AST); - TypeScript.DeleteExpression = DeleteExpression; - - var VoidExpression = (function (_super) { - __extends(VoidExpression, _super); - function VoidExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - VoidExpression.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return VoidExpression; - })(AST); - TypeScript.VoidExpression = VoidExpression; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.apply(this, arguments); - } - DebuggerStatement.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - return DebuggerStatement; - })(AST); - TypeScript.DebuggerStatement = DebuggerStatement; - - var Comment = (function () { - function Comment(_trivia, endsLine, _start, _end) { - this._trivia = _trivia; - this.endsLine = endsLine; - this._start = _start; - this._end = _end; - } - Comment.prototype.start = function () { - return this._start; - }; - - Comment.prototype.end = function () { - return this._end; - }; - - Comment.prototype.fullText = function () { - return this._trivia.fullText(); - }; - - Comment.prototype.kind = function () { - return this._trivia.kind(); - }; - - Comment.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; - }; - 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) { - (function (IOUtils) { - function createDirectoryStructure(ioHost, dirName) { - if (ioHost.directoryExists(dirName)) { - return; - } - - var parentDirectory = ioHost.dirName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(ioHost, parentDirectory); - } - ioHost.createDirectory(dirName); - } - - function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { - var start = new Date().getTime(); - var path = ioHost.resolvePath(fileName); - TypeScript.ioHostResolvePathTime += new Date().getTime() - start; - - var start = new Date().getTime(); - var dirName = ioHost.dirName(path); - TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start; - - var start = new Date().getTime(); - createDirectoryStructure(ioHost, dirName); - TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start; - - var start = new Date().getTime(); - ioHost.writeFile(path, contents, writeByteOrderMark); - TypeScript.ioHostWriteFileTime += new Date().getTime() - start; - } - IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; - - function throwIOError(message, error) { - var errorMessage = message; - if (error && error.message) { - errorMessage += (" " + error.message); - } - throw new Error(errorMessage); - } - IOUtils.throwIOError = throwIOError; - - function combine(prefix, suffix) { - return prefix + "/" + suffix; - } - IOUtils.combine = combine; - - var BufferedTextWriter = (function () { - function BufferedTextWriter(writer, capacity) { - if (typeof capacity === "undefined") { capacity = 1024; } - this.writer = writer; - this.capacity = capacity; - this.buffer = ""; - } - BufferedTextWriter.prototype.Write = function (str) { - this.buffer += str; - if (this.buffer.length >= this.capacity) { - this.writer.Write(this.buffer); - this.buffer = ""; - } - }; - BufferedTextWriter.prototype.WriteLine = function (str) { - this.Write(str + '\r\n'); - }; - BufferedTextWriter.prototype.Close = function () { - this.writer.Write(this.buffer); - this.writer.Close(); - this.buffer = null; - }; - return BufferedTextWriter; - })(); - IOUtils.BufferedTextWriter = BufferedTextWriter; - })(TypeScript.IOUtils || (TypeScript.IOUtils = {})); - var IOUtils = TypeScript.IOUtils; - - TypeScript.IO = (function () { - function getWindowsScriptHostIO() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - readFile: function (path, codepage) { - return TypeScript.Environment.readFile(path, codepage); - }, - writeFile: function (path, contents, writeByteOrderMark) { - TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - dirName: function (path) { - return fso.GetParentFolderName(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; - - while (true) { - if (fso.FileExists(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); - - if (rootPath == "") { - return null; - } else { - path = fso.BuildPath(rootPath, partialFilePath); - } - } - } - }, - deleteFile: function (path) { - try { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - fso.CreateFolder(path); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); - } - }, - dir: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "/" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - print: function (str) { - WScript.StdOut.Write(str); - }, - printLine: function (str) { - WScript.Echo(str); - }, - arguments: args, - stderr: WScript.StdErr, - stdout: WScript.StdOut, - watchFile: null, - run: function (source, fileName) { - try { - eval(source); - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Error_while_executing_file_0, [fileName]), e); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - quit: function (exitCode) { - if (typeof exitCode === "undefined") { exitCode = 0; } - try { - WScript.Quit(exitCode); - } catch (e) { - } - } - }; - } - ; - - function getNodeIO() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - readFile: function (file, codepage) { - return TypeScript.Environment.readFile(file, codepage); - }, - writeFile: function (path, contents, writeByteOrderMark) { - TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); - } - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - dir: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - try { - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "/" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "/" + files[i]); - } - } - } catch (err) { - } - - return paths; - } - - return filesInFolder(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - _fs.mkdirSync(path); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - dirName: function (path) { - var dirPath = _path.dirname(path); - - if (dirPath === path) { - dirPath = null; - } - - return dirPath; - }, - findFile: function (rootPath, partialFilePath) { - var path = rootPath + "/" + partialFilePath; - - while (true) { - if (_fs.existsSync(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - var parentPath = _path.resolve(rootPath, ".."); - - if (rootPath === parentPath) { - return null; - } else { - rootPath = parentPath; - path = _path.resolve(rootPath, partialFilePath); - } - } - } - }, - print: function (str) { - process.stdout.write(str); - }, - printLine: function (str) { - process.stdout.write(str + '\n'); - }, - arguments: process.argv.slice(2), - stderr: { - Write: function (str) { - process.stderr.write(str); - }, - WriteLine: function (str) { - process.stderr.write(str + '\n'); - }, - Close: function () { - } - }, - stdout: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - }, - watchFile: function (fileName, callback) { - var firstRun = true; - var processingChange = false; - - var fileChanged = function (curr, prev) { - if (!firstRun) { - if (curr.mtime < prev.mtime) { - return; - } - - _fs.unwatchFile(fileName, fileChanged); - if (!processingChange) { - processingChange = true; - callback(fileName); - setTimeout(function () { - processingChange = false; - }, 100); - } - } - firstRun = false; - _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); - }; - - fileChanged(); - return { - fileName: fileName, - close: function () { - _fs.unwatchFile(fileName, fileChanged); - } - }; - }, - run: function (source, fileName) { - require.main.fileName = fileName; - require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); - require.main._compile(source, fileName); - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - quit: function (code) { - var stderrFlushed = process.stderr.write(''); - var stdoutFlushed = process.stdout.write(''); - process.stderr.on('drain', function () { - stderrFlushed = true; - if (stdoutFlushed) { - process.exit(code); - } - }); - process.stdout.on('drain', function () { - stdoutFlushed = true; - if (stderrFlushed) { - process.exit(code); - } - }); - setTimeout(function () { - process.exit(code); - }, 5); - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") - return getWindowsScriptHostIO(); - else if (typeof module !== 'undefined' && module.exports) - return getNodeIO(); - else - return null; - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OptionsParser = (function () { - function OptionsParser(host, version) { - this.host = host; - this.version = version; - this.DEFAULT_SHORT_FLAG = "-"; - this.DEFAULT_LONG_FLAG = "--"; - this.printedVersion = false; - this.unnamed = []; - this.options = []; - } - OptionsParser.prototype.findOption = function (arg) { - var upperCaseArg = arg && arg.toUpperCase(); - - for (var i = 0; i < this.options.length; i++) { - var current = this.options[i]; - - if (upperCaseArg === (current.short && current.short.toUpperCase()) || upperCaseArg === (current.name && current.name.toUpperCase())) { - return current; - } - } - - return null; - }; - - OptionsParser.prototype.printUsage = function () { - this.printVersion(); - - var optionsWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.options, null); - var fileWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.file1, null); - var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]"; - var syntaxHelp = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Syntax_0, [tscSyntax]); - this.host.printLine(syntaxHelp); - this.host.printLine(""); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Examples, null) + " tsc hello.ts"); - this.host.printLine(" tsc --out foo.js foo.ts"); - this.host.printLine(" tsc @args.txt"); - this.host.printLine(""); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Options, null)); - - var output = []; - var maxLength = 0; - var i = 0; - - this.options = this.options.sort(function (a, b) { - var aName = a.name.toLowerCase(); - var bName = b.name.toLowerCase(); - - if (aName > bName) { - return 1; - } else if (aName < bName) { - return -1; - } else { - return 0; - } - }); - - for (i = 0; i < this.options.length; i++) { - var option = this.options[i]; - - if (option.experimental) { - continue; - } - - if (!option.usage) { - break; - } - - var usageString = " "; - var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : ""; - - if (option.short) { - usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; - } - - usageString += this.DEFAULT_LONG_FLAG + option.name + type; - - output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]); - - if (usageString.length > maxLength) { - maxLength = usageString.length; - } - } - - var fileDescription = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null); - output.push([" @<" + fileWord + ">", fileDescription]); - - for (i = 0; i < output.length; i++) { - this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); - } - }; - - OptionsParser.prototype.printVersion = function () { - if (!this.printedVersion) { - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Version_0, [this.version])); - this.printedVersion = true; - } - }; - - OptionsParser.prototype.option = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = false; - - this.options.push(config); - }; - - OptionsParser.prototype.flag = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = true; - - this.options.push(config); - }; - - OptionsParser.prototype.parseString = function (argString) { - var position = 0; - var tokens = argString.match(/\s+|"|[^\s"]+/g); - - function peek() { - return tokens[position]; - } - - function consume() { - return tokens[position++]; - } - - function consumeQuotedString() { - var value = ''; - consume(); - - var token = peek(); - - while (token && token !== '"') { - consume(); - - value += token; - - token = peek(); - } - - consume(); - - return value; - } - - var args = []; - var currentArg = ''; - - while (position < tokens.length) { - var token = peek(); - - if (token === '"') { - currentArg += consumeQuotedString(); - } else if (token.match(/\s/)) { - if (currentArg.length > 0) { - args.push(currentArg); - currentArg = ''; - } - - consume(); - } else { - consume(); - currentArg += token; - } - } - - if (currentArg.length > 0) { - args.push(currentArg); - } - - this.parse(args); - }; - - OptionsParser.prototype.parse = function (args) { - var position = 0; - - function consume() { - return args[position++]; - } - - while (position < args.length) { - var current = consume(); - var match = current.match(/^(--?|@)(.*)/); - var value = null; - - if (match) { - if (match[1] === '@') { - this.parseString(this.host.readFile(match[2], null).contents); - } else { - var arg = match[2]; - var option = this.findOption(arg); - - if (option === null) { - this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_option_0, [arg])); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); - } else { - if (!option.flag) { - value = consume(); - if (value === undefined) { - this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Option_0_specified_without_1, [arg, TypeScript.getLocalizedText(option.type, null)])); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); - continue; - } - } - - option.set(value); - } - } - } else { - this.unnamed.push(current); - } - } - }; - return OptionsParser; - })(); - TypeScript.OptionsParser = OptionsParser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceFile = (function () { - function SourceFile(scriptSnapshot, byteOrderMark) { - this.scriptSnapshot = scriptSnapshot; - this.byteOrderMark = byteOrderMark; - } - return SourceFile; - })(); - - var DiagnosticsLogger = (function () { - function DiagnosticsLogger(ioHost) { - this.ioHost = ioHost; - } - DiagnosticsLogger.prototype.information = function () { - return false; - }; - DiagnosticsLogger.prototype.debug = function () { - return false; - }; - DiagnosticsLogger.prototype.warning = function () { - return false; - }; - DiagnosticsLogger.prototype.error = function () { - return false; - }; - DiagnosticsLogger.prototype.fatal = function () { - return false; - }; - DiagnosticsLogger.prototype.log = function (s) { - this.ioHost.stdout.WriteLine(s); - }; - return DiagnosticsLogger; - })(); - - var BatchCompiler = (function () { - function BatchCompiler(ioHost) { - this.ioHost = ioHost; - this.compilerVersion = "0.9.5.0"; - this.inputFiles = []; - this.resolvedFiles = []; - this.fileNameToSourceFile = new TypeScript.StringHashTable(); - this.hasErrors = false; - this.logger = null; - this.fileExistsCache = TypeScript.createIntrinsicsObject(); - this.resolvePathCache = TypeScript.createIntrinsicsObject(); - } - BatchCompiler.prototype.batchCompile = function () { - var _this = this; - var start = new Date().getTime(); - - TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { - _this.ioHost.printLine(s); - } }; - - if (this.parseOptions()) { - this.logger = this.compilationSettings.gatherDiagnostics() ? new DiagnosticsLogger(this.ioHost) : new TypeScript.NullLogger(); - - if (this.compilationSettings.watch()) { - this.watchFiles(); - return; - } - - this.resolve(); - - this.compile(); - - if (this.compilationSettings.gatherDiagnostics()) { - this.logger.log(""); - this.logger.log("File resolution time: " + TypeScript.fileResolutionTime); - this.logger.log(" file read: " + TypeScript.fileResolutionIOTime); - this.logger.log(" scan imports: " + TypeScript.fileResolutionScanImportsTime); - this.logger.log(" import search: " + TypeScript.fileResolutionImportFileSearchTime); - this.logger.log(" get lib.d.ts: " + TypeScript.fileResolutionGetDefaultLibraryTime); - - this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime); - this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime); - this.logger.log("AST translation time: " + TypeScript.astTranslationTime); - this.logger.log(""); - this.logger.log("Type check time: " + TypeScript.typeCheckTime); - this.logger.log(""); - this.logger.log("Emit time: " + TypeScript.emitTime); - this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime); - - this.logger.log("Total number of symbols created: " + TypeScript.pullSymbolID); - this.logger.log("Specialized types created: " + TypeScript.nSpecializationsCreated); - this.logger.log("Specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); - - this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime); - this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime); - this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime); - this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime); - this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime); - this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime); - this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime); - this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime); - this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime); - - this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime); - - this.logger.log("Compiler resolve path time: " + TypeScript.compilerResolvePathTime); - this.logger.log("Compiler directory name time: " + TypeScript.compilerDirectoryNameTime); - this.logger.log("Compiler directory exists time: " + TypeScript.compilerDirectoryExistsTime); - this.logger.log("Compiler file exists time: " + TypeScript.compilerFileExistsTime); - - this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime); - this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime); - this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime); - this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime); - - this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime); - this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime); - this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime); - } - } - - this.ioHost.quit(this.hasErrors ? 1 : 0); - }; - - BatchCompiler.prototype.resolve = function () { - var _this = this; - var includeDefaultLibrary = !this.compilationSettings.noLib(); - var resolvedFiles = []; - - var start = new Date().getTime(); - - if (!this.compilationSettings.noResolve()) { - var resolutionResults = TypeScript.ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings.useCaseSensitiveFileResolution()); - resolvedFiles = resolutionResults.resolvedFiles; - - includeDefaultLibrary = !this.compilationSettings.noLib() && !resolutionResults.seenNoDefaultLibTag; - - resolutionResults.diagnostics.forEach(function (d) { - return _this.addDiagnostic(d); - }); - } else { - for (var i = 0, n = this.inputFiles.length; i < n; i++) { - var inputFile = this.inputFiles[i]; - var referencedFiles = []; - var importedFiles = []; - - if (this.compilationSettings.generateDeclarationFiles()) { - var references = TypeScript.getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile)); - for (var j = 0; j < references.length; j++) { - referencedFiles.push(references[j].path); - } - - inputFile = this.resolvePath(inputFile); - } - - resolvedFiles.push({ - path: inputFile, - referencedFiles: referencedFiles, - importedFiles: importedFiles - }); - } - } - - var defaultLibStart = new Date().getTime(); - if (includeDefaultLibrary) { - var libraryResolvedFile = { - path: this.getDefaultLibraryFilePath(), - referencedFiles: [], - importedFiles: [] - }; - - resolvedFiles = [libraryResolvedFile].concat(resolvedFiles); - } - TypeScript.fileResolutionGetDefaultLibraryTime += new Date().getTime() - defaultLibStart; - - this.resolvedFiles = resolvedFiles; - - TypeScript.fileResolutionTime = new Date().getTime() - start; - }; - - BatchCompiler.prototype.compile = function () { - var _this = this; - var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); - - this.resolvedFiles.forEach(function (resolvedFile) { - var sourceFile = _this.getSourceFile(resolvedFile.path); - compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, false, resolvedFile.referencedFiles); - }); - - for (var it = compiler.compile(function (path) { - return _this.resolvePath(path); - }); it.moveNext();) { - var result = it.current(); - - result.diagnostics.forEach(function (d) { - return _this.addDiagnostic(d); - }); - if (!this.tryWriteOutputFiles(result.outputFiles)) { - return; - } - } - }; - - BatchCompiler.prototype.parseOptions = function () { - var _this = this; - var opts = new TypeScript.OptionsParser(this.ioHost, this.compilerVersion); - - var mutableSettings = new TypeScript.CompilationSettings(); - opts.option('out', { - usage: { - locCode: TypeScript.DiagnosticCode.Concatenate_and_emit_output_to_single_file, - args: null - }, - type: TypeScript.DiagnosticCode.file2, - set: function (str) { - mutableSettings.outFileOption = str; - } - }); - - opts.option('outDir', { - usage: { - locCode: TypeScript.DiagnosticCode.Redirect_output_structure_to_the_directory, - args: null - }, - type: TypeScript.DiagnosticCode.DIRECTORY, - set: function (str) { - mutableSettings.outDirOption = str; - } - }); - - opts.flag('sourcemap', { - usage: { - locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, - args: ['.map'] - }, - set: function () { - mutableSettings.mapSourceFiles = true; - } - }); - - opts.option('mapRoot', { - usage: { - locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - args: null - }, - type: TypeScript.DiagnosticCode.LOCATION, - set: function (str) { - mutableSettings.mapRoot = str; - } - }); - - opts.option('sourceRoot', { - usage: { - locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - args: null - }, - type: TypeScript.DiagnosticCode.LOCATION, - set: function (str) { - mutableSettings.sourceRoot = str; - } - }); - - opts.flag('declaration', { - usage: { - locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, - args: ['.d.ts'] - }, - set: function () { - mutableSettings.generateDeclarationFiles = true; - } - }, 'd'); - - if (this.ioHost.watchFile) { - opts.flag('watch', { - usage: { - locCode: TypeScript.DiagnosticCode.Watch_input_files, - args: null - }, - set: function () { - mutableSettings.watch = true; - } - }, 'w'); - } - - opts.flag('propagateEnumConstants', { - experimental: true, - set: function () { - mutableSettings.propagateEnumConstants = true; - } - }); - - opts.flag('removeComments', { - usage: { - locCode: TypeScript.DiagnosticCode.Do_not_emit_comments_to_output, - args: null - }, - set: function () { - mutableSettings.removeComments = true; - } - }); - - opts.flag('noResolve', { - usage: { - locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, - args: null - }, - set: function () { - mutableSettings.noResolve = true; - } - }); - - opts.flag('noLib', { - experimental: true, - set: function () { - mutableSettings.noLib = true; - } - }); - - opts.flag('diagnostics', { - experimental: true, - set: function () { - mutableSettings.gatherDiagnostics = true; - } - }); - - opts.option('target', { - usage: { - locCode: TypeScript.DiagnosticCode.Specify_ECMAScript_target_version_0_default_or_1, - args: ['ES3', 'ES5'] - }, - type: TypeScript.DiagnosticCode.VERSION, - set: function (type) { - type = type.toLowerCase(); - - if (type === 'es3') { - mutableSettings.codeGenTarget = 0 /* EcmaScript3 */; - } else if (type === 'es5') { - mutableSettings.codeGenTarget = 1 /* EcmaScript5 */; - } else { - _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2, [type, "ES3", "ES5"])); - } - } - }, 't'); - - opts.option('module', { - usage: { - locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1, - args: ['commonjs', 'amd'] - }, - type: TypeScript.DiagnosticCode.KIND, - set: function (type) { - type = type.toLowerCase(); - - if (type === 'commonjs') { - mutableSettings.moduleGenTarget = 1 /* Synchronous */; - } else if (type === 'amd') { - mutableSettings.moduleGenTarget = 2 /* Asynchronous */; - } else { - _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type])); - } - } - }, 'm'); - - var needsHelp = false; - opts.flag('help', { - usage: { - locCode: TypeScript.DiagnosticCode.Print_this_message, - args: null - }, - set: function () { - needsHelp = true; - } - }, 'h'); - - opts.flag('useCaseSensitiveFileResolution', { - experimental: true, - set: function () { - mutableSettings.useCaseSensitiveFileResolution = true; - } - }); - var shouldPrintVersionOnly = false; - opts.flag('version', { - usage: { - locCode: TypeScript.DiagnosticCode.Print_the_compiler_s_version_0, - args: [this.compilerVersion] - }, - set: function () { - shouldPrintVersionOnly = true; - } - }, 'v'); - - var locale = null; - opts.option('locale', { - experimental: true, - usage: { - locCode: TypeScript.DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1, - args: ['en', 'ja-jp'] - }, - type: TypeScript.DiagnosticCode.STRING, - set: function (value) { - locale = value; - } - }); - - opts.flag('noImplicitAny', { - usage: { - locCode: TypeScript.DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, - args: null - }, - set: function () { - mutableSettings.noImplicitAny = true; - } - }); - - if (TypeScript.Environment.supportsCodePage()) { - opts.option('codepage', { - usage: { - locCode: TypeScript.DiagnosticCode.Specify_the_codepage_to_use_when_opening_source_files, - args: null - }, - type: TypeScript.DiagnosticCode.NUMBER, - set: function (arg) { - mutableSettings.codepage = parseInt(arg, 10); - } - }); - } - - opts.parse(this.ioHost.arguments); - - this.compilationSettings = TypeScript.ImmutableCompilationSettings.fromCompilationSettings(mutableSettings); - - if (locale) { - if (!this.setLocale(locale)) { - return false; - } - } - - this.inputFiles.push.apply(this.inputFiles, opts.unnamed); - - if (this.inputFiles.length === 0 || needsHelp) { - opts.printUsage(); - return false; - } else if (shouldPrintVersionOnly) { - opts.printVersion(); - } - - return !this.hasErrors; - }; - - BatchCompiler.prototype.setLocale = function (locale) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); - if (!matchResult) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp'])); - return false; - } - - var language = matchResult[1]; - var territory = matchResult[3]; - - if (!this.setLanguageAndTerritory(language, territory) && !this.setLanguageAndTerritory(language, null)) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Unsupported_locale_0, [locale])); - return false; - } - - return true; - }; - - BatchCompiler.prototype.setLanguageAndTerritory = function (language, territory) { - var compilerFilePath = this.ioHost.getExecutingFilePath(); - var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); - - var filePath = TypeScript.IOUtils.combine(containingDirectoryPath, language); - if (territory) { - filePath = filePath + "-" + territory; - } - - filePath = this.resolvePath(TypeScript.IOUtils.combine(filePath, "diagnosticMessages.generated.json")); - - if (!this.fileExists(filePath)) { - return false; - } - - var fileContents = this.ioHost.readFile(filePath, this.compilationSettings.codepage()); - TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents); - return true; - }; - - BatchCompiler.prototype.watchFiles = function () { - var _this = this; - if (!this.ioHost.watchFile) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]'])); - return; - } - - var lastResolvedFileSet = []; - var watchers = {}; - var firstTime = true; - - var addWatcher = function (fileName) { - if (!watchers[fileName]) { - var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); - watchers[fileName] = watcher; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); - } - }; - - var removeWatcher = function (fileName) { - if (watchers[fileName]) { - watchers[fileName].close(); - delete watchers[fileName]; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); - } - }; - - var onWatchedFileChange = function () { - _this.hasErrors = false; - - _this.fileNameToSourceFile = new TypeScript.StringHashTable(); - - _this.resolve(); - - var oldFiles = lastResolvedFileSet; - var newFiles = _this.resolvedFiles.map(function (resolvedFile) { - return resolvedFile.path; - }).sort(); - - var i = 0, j = 0; - while (i < oldFiles.length && j < newFiles.length) { - var compareResult = oldFiles[i].localeCompare(newFiles[j]); - if (compareResult === 0) { - i++; - j++; - } else if (compareResult < 0) { - removeWatcher(oldFiles[i]); - i++; - } else { - addWatcher(newFiles[j]); - j++; - } - } - - for (var k = i; k < oldFiles.length; k++) { - removeWatcher(oldFiles[k]); - } - - for (k = j; k < newFiles.length; k++) { - addWatcher(newFiles[k]); - } - - lastResolvedFileSet = newFiles; - - if (!firstTime) { - var fileNames = ""; - for (var k = 0; k < lastResolvedFileSet.length; k++) { - fileNames += TypeScript.Environment.newLine + " " + lastResolvedFileSet[k]; - } - _this.ioHost.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.NL_Recompiling_0, [fileNames])); - } else { - firstTime = false; - } - - _this.compile(); - }; - - this.ioHost.stderr = this.ioHost.stdout; - - onWatchedFileChange(); - }; - - BatchCompiler.prototype.getSourceFile = function (fileName) { - var sourceFile = this.fileNameToSourceFile.lookup(fileName); - if (!sourceFile) { - var fileInformation; - - try { - fileInformation = this.ioHost.readFile(fileName, this.compilationSettings.codepage()); - } catch (e) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message])); - fileInformation = new TypeScript.FileInformation("", 0 /* None */); - } - - var snapshot = TypeScript.ScriptSnapshot.fromString(fileInformation.contents); - var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark); - this.fileNameToSourceFile.add(fileName, sourceFile); - } - - return sourceFile; - }; - - BatchCompiler.prototype.getDefaultLibraryFilePath = function () { - var compilerFilePath = this.ioHost.getExecutingFilePath(); - var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); - var libraryFilePath = this.resolvePath(TypeScript.IOUtils.combine(containingDirectoryPath, "lib.d.ts")); - - return libraryFilePath; - }; - - BatchCompiler.prototype.getScriptSnapshot = function (fileName) { - return this.getSourceFile(fileName).scriptSnapshot; - }; - - BatchCompiler.prototype.resolveRelativePath = function (path, directory) { - var start = new Date().getTime(); - - var unQuotedPath = TypeScript.stripStartAndEndQuotes(path); - var normalizedPath; - - if (TypeScript.isRooted(unQuotedPath) || !directory) { - normalizedPath = unQuotedPath; - } else { - normalizedPath = TypeScript.IOUtils.combine(directory, unQuotedPath); - } - - normalizedPath = this.resolvePath(normalizedPath); - - normalizedPath = TypeScript.switchToForwardSlashes(normalizedPath); - - return normalizedPath; - }; - - BatchCompiler.prototype.fileExists = function (path) { - var exists = this.fileExistsCache[path]; - if (exists === undefined) { - var start = new Date().getTime(); - exists = this.ioHost.fileExists(path); - this.fileExistsCache[path] = exists; - TypeScript.compilerFileExistsTime += new Date().getTime() - start; - } - - return exists; - }; - - BatchCompiler.prototype.getParentDirectory = function (path) { - var start = new Date().getTime(); - var result = this.ioHost.dirName(path); - TypeScript.compilerDirectoryNameTime += new Date().getTime() - start; - - return result; - }; - - BatchCompiler.prototype.addDiagnostic = function (diagnostic) { - var diagnosticInfo = diagnostic.info(); - if (diagnosticInfo.category === 1 /* Error */) { - this.hasErrors = true; - } - - if (diagnostic.fileName()) { - this.ioHost.stderr.Write(diagnostic.fileName() + "(" + (diagnostic.line() + 1) + "," + (diagnostic.character() + 1) + "): "); - } - - this.ioHost.stderr.WriteLine(diagnostic.message()); - }; - - BatchCompiler.prototype.tryWriteOutputFiles = function (outputFiles) { - for (var i = 0, n = outputFiles.length; i < n; i++) { - var outputFile = outputFiles[i]; - - try { - this.writeFile(outputFile.name, outputFile.text, outputFile.writeByteOrderMark); - } catch (e) { - this.addDiagnostic(new TypeScript.Diagnostic(outputFile.name, null, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])); - return false; - } - } - - return true; - }; - - BatchCompiler.prototype.writeFile = function (fileName, contents, writeByteOrderMark) { - var start = new Date().getTime(); - TypeScript.IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark); - TypeScript.emitWriteFileTime += new Date().getTime() - start; - }; - - BatchCompiler.prototype.directoryExists = function (path) { - var start = new Date().getTime(); - var result = this.ioHost.directoryExists(path); - TypeScript.compilerDirectoryExistsTime += new Date().getTime() - start; - return result; - }; - - BatchCompiler.prototype.resolvePath = function (path) { - var cachedValue = this.resolvePathCache[path]; - if (!cachedValue) { - var start = new Date().getTime(); - cachedValue = this.ioHost.resolvePath(path); - this.resolvePathCache[path] = cachedValue; - TypeScript.compilerResolvePathTime += new Date().getTime() - start; - } - - return cachedValue; - }; - return BatchCompiler; - })(); - TypeScript.BatchCompiler = BatchCompiler; - - var batch = new TypeScript.BatchCompiler(TypeScript.IO); - batch.batchCompile(); -})(TypeScript || (TypeScript = {})); diff --git a/_infrastructure/tests/typescript/0.9.5-beta/typescript.js b/_infrastructure/tests/typescript/0.9.5-beta/typescript.js deleted file mode 100644 index 667affcf14..0000000000 --- a/_infrastructure/tests/typescript/0.9.5-beta/typescript.js +++ /dev/null @@ -1,59585 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - TypeScript.DiagnosticCode = { - error_TS_0_1: "error TS{0}: {1}", - warning_TS_0_1: "warning TS{0}: {1}", - Unrecognized_escape_sequence: "Unrecognized escape sequence.", - Unexpected_character_0: "Unexpected character {0}.", - Missing_close_quote_character: "Missing close quote character.", - Identifier_expected: "Identifier expected.", - _0_keyword_expected: "'{0}' keyword expected.", - _0_expected: "'{0}' expected.", - Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", - Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", - Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", - Trailing_separator_not_allowed: "Trailing separator not allowed.", - AsteriskSlash_expected: "'*/' expected.", - public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", - Unexpected_token: "Unexpected token.", - Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", - Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", - Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", - Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", - Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", - Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", - Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", - Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", - Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", - Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", - Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", - extends_clause_already_seen: "'extends' clause already seen.", - extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", - Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", - implements_clause_already_seen: "'implements' clause already seen.", - Accessibility_modifier_already_seen: "Accessibility modifier already seen.", - _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", - _0_modifier_already_seen: "'{0}' modifier already seen.", - _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", - Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", - super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", - Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", - Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", - 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.", - Function_implementation_expected: "Function implementation expected.", - Constructor_implementation_expected: "Constructor implementation expected.", - Function_overload_name_must_be_0: "Function overload name must be '{0}'.", - _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", - declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", - declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", - Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", - Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", - set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", - set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", - set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", - set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", - get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", - Modifiers_cannot_appear_here: "Modifiers cannot appear here.", - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", - Class_name_cannot_be_0: "Class name cannot be '{0}'.", - Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", - Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", - Module_name_cannot_be_0: "Module name cannot be '{0}'.", - Enum_member_must_have_initializer: "Enum member must have initializer.", - Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", - Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", - Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", - Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", - module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", - constructor_function_accessor_or_variable: "constructor, function, accessor or variable", - statement: "statement", - case_or_default_clause: "case or default clause", - identifier: "identifier", - call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", - expression: "expression", - type_name: "type name", - property_or_accessor: "property or accessor", - parameter: "parameter", - type: "type", - type_parameter: "type parameter", - 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.", - 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.", - super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", - Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", - Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", - Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", - Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", - Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", - Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", - Getter_0_already_declared: "Getter '{0}' already declared.", - Setter_0_already_declared: "Setter '{0}' already declared.", - Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", - Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", - Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", - Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", - Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", - Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", - Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", - Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", - Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", - Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", - Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", - Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", - Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", - Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", - Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", - Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", - Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", - Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", - Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", - Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", - Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", - Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", - A_class_may_only_extend_another_class: "A class may only extend another class.", - A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", - An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", - Unable_to_resolve_type: "Unable to resolve type.", - Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", - Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", - Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", - Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", - Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", - Invalid_new_expression: "Invalid 'new' expression.", - Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", - Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", - Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", - Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", - Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", - Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", - The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", - 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.", - 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.", - _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.", - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", - Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", - 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.", - 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.", - 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.", - Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", - Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", - Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", - All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", - Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", - this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", - Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", - Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", - Duplicate_overload_call_signature: "Duplicate overload call signature.", - Duplicate_overload_construct_signature: "Duplicate overload construct signature.", - Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", - Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", - Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", - 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.", - 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.", - Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", - A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", - Rest_parameters_must_be_array_types: "Rest parameters must be array types.", - Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", - 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}", - 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.", - 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.", - Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", - Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", - Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", - 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}'.", - 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}", - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", - Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", - All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", - super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", - Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", - Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", - Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", - Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", - Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", - continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", - break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", - Jump_target_not_found: "Jump target not found.", - Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", - TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", - TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", - TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", - TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", - TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", - TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", - 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.", - 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}", - Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", - Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", - Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", - Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", - Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", - Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - 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.", - _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_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}", - 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.", - Could_not_find_file_0: "Could not find file: '{0}'.", - A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", - Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", - Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", - Emit_Error_0: "Emit Error: {0}.", - Cannot_read_file_0_1: "Cannot read file '{0}': {1}", - Unsupported_file_encoding: "Unsupported file encoding.", - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", - Unsupported_locale_0: "Unsupported locale: '{0}'.", - Execution_Failed_NL: "Execution Failed.{NL}", - Invalid_call_to_up: "Invalid call to 'up'", - Invalid_call_to_down: "Invalid call to 'down'", - Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", - Unknown_option_0: "Unknown option '{0}'", - Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", - Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", - Could_not_delete_file_0: "Could not delete file '{0}'", - Could_not_create_directory_0: "Could not create directory '{0}'", - Error_while_executing_file_0: "Error while executing file '{0}': ", - Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", - Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", - Option_0_specified_without_1: "Option '{0}' specified without '{1}'", - codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", - Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", - Generates_corresponding_0_file: "Generates corresponding {0} file.", - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", - Watch_input_files: "Watch input files.", - Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", - Do_not_emit_comments_to_output: "Do not emit comments to output.", - Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", - Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", - Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", - Print_this_message: "Print this message.", - Print_the_compiler_s_version_0: "Print the compiler's version: {0}", - Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", - Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", - Syntax_0: "Syntax: {0}", - options: "options", - file1: "file", - Examples: "Examples:", - Options: "Options:", - Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", - Version_0: "Version {0}", - Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", - NL_Recompiling_0: "{NL}Recompiling ({0}):", - STRING: "STRING", - KIND: "KIND", - file2: "FILE", - VERSION: "VERSION", - LOCATION: "LOCATION", - DIRECTORY: "DIRECTORY", - NUMBER: "NUMBER", - Specify_the_codepage_to_use_when_opening_source_files: "Specify the codepage to use when opening source files.", - 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})", - Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", - Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", - Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", - Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", - Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", - new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", - _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", - Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", - 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." - }; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - return false; - } - - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0, n = array1.length; i < n; i++) { - if (!equals(array1[i], array2[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.distinct = function (array, equalsFn) { - var result = []; - - for (var i = 0, n = array.length; i < n; i++) { - var current = array[i]; - for (var j = 0; j < result.length; j++) { - if (equalsFn(result[j], current)) { - break; - } - } - - if (j === result.length) { - result.push(current); - } - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.lastOrDefault = function (array, predicate) { - for (var i = array.length - 1; i >= 0; i--) { - var v = array[i]; - if (predicate(v, i)) { - return v; - } - } - - return null; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value, i)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.first = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (!func || func(value, i)) { - return value; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = new Array(values.length); - - for (var i = 0; i < values.length; i++) { - result[i] = func(values[i]); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = new Array(); - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - var low = 0; - var high = array.length - 1; - - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - - if (midValue === value) { - return middle; - } else if (midValue > value) { - high = middle - 1; - } else { - low = middle + 1; - } - } - - return ~low; - }; - - ArrayUtilities.createArray = function (length, defaultValue) { - var result = new Array(length); - for (var i = 0; i < length; i++) { - result[i] = defaultValue; - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - - ArrayUtilities.indexOf = function (array, predicate) { - for (var i = 0, n = array.length; i < n; i++) { - if (predicate(array[i])) { - return i; - } - } - - return -1; - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitVector) { - var pool = []; - var Constants; - (function (Constants) { - Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; - Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; - - Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; - - Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; - Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; - - Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; - Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; - Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; - })(Constants || (Constants = {})); - - var BitVectorImpl = (function () { - function BitVectorImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.bits = []; - } - BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; - }; - - BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; - }; - - BitVectorImpl.prototype.valueAt = function (index) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return undefined; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { - return true; - } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { - return false; - } else { - return undefined; - } - } else { - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return false; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { - return true; - } else { - return false; - } - } - }; - - BitVectorImpl.prototype.setValueAt = function (index, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); - - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === undefined) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - - var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); - encoded = encoded & clearMask; - - if (value === true) { - encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); - } else if (value === false) { - encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } else { - TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); - - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === false) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - - encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); - - if (value) { - encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } - }; - - BitVectorImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - this.bits.length = 0; - pool.push(this); - }; - return BitVectorImpl; - })(); - - function getBitVector(allowUndefinedValues) { - if (pool.length === 0) { - return new BitVectorImpl(allowUndefinedValues); - } - - var vector = pool.pop(); - vector.isReleased = false; - vector.allowUndefinedValues = allowUndefinedValues; - - return vector; - } - BitVector.getBitVector = getBitVector; - })(TypeScript.BitVector || (TypeScript.BitVector = {})); - var BitVector = TypeScript.BitVector; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitMatrix) { - var pool = []; - - var BitMatrixImpl = (function () { - function BitMatrixImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.vectors = []; - } - BitMatrixImpl.prototype.valueAt = function (x, y) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - return this.allowUndefinedValues ? undefined : false; - } - - return vector.valueAt(y); - }; - - BitMatrixImpl.prototype.setValueAt = function (x, y, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - if (value === undefined) { - return; - } - - vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); - this.vectors[x] = vector; - } - - vector.setValueAt(y, value); - }; - - BitMatrixImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - - for (var name in this.vectors) { - if (this.vectors.hasOwnProperty(name)) { - var vector = this.vectors[name]; - vector.release(); - } - } - - this.vectors.length = 0; - pool.push(this); - }; - return BitMatrixImpl; - })(); - - function getBitMatrix(allowUndefinedValues) { - if (pool.length === 0) { - return new BitMatrixImpl(allowUndefinedValues); - } - - var matrix = pool.pop(); - matrix.isReleased = false; - matrix.allowUndefinedValues = allowUndefinedValues; - - return matrix; - } - BitMatrix.getBitMatrix = getBitMatrix; - })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); - var BitMatrix = TypeScript.BitMatrix; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); - var AssertionLevel = TypeScript.AssertionLevel; - - var Debug = (function () { - function Debug() { - } - Debug.shouldAssert = function (level) { - return this.currentAssertionLevel >= level; - }; - - Debug.assert = function (expression, message, verboseDebugInfo) { - if (typeof message === "undefined") { message = ""; } - if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); - } - - throw new Error("Debug Failure. False expression: " + message + verboseDebugString); - } - }; - - Debug.fail = function (message) { - Debug.assert(false, message); - }; - Debug.currentAssertionLevel = 0 /* None */; - return Debug; - })(); - TypeScript.Debug = Debug; -})(TypeScript || (TypeScript = {})); -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; - this._fileName = fileName; - this._lineMap = lineMap; - this._start = start; - this._length = length; - } - Diagnostic.prototype.toJSON = function (key) { - var result = {}; - result.start = this.start(); - result.length = this.length(); - - result.diagnosticCode = this._diagnosticKey; - - 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; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.additionalLocations = function () { - return []; - }; - - 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 v1 === v2; - }); - }; - - Diagnostic.prototype.info = function () { - return getDiagnosticInfoFromKey(this.diagnosticKey()); - }; - return Diagnostic; - })(); - TypeScript.Diagnostic = Diagnostic; - - function newLine() { - return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; - } - TypeScript.newLine = newLine; - - function getLargestIndex(diagnostic) { - var largest = -1; - var regex = /\{(\d+)\}/g; - - var match; - while ((match = regex.exec(diagnostic)) != null) { - var val = parseInt(match[1]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromKey(diagnosticKey) { - var result = TypeScript.diagnosticInformationMap[diagnosticKey]; - TypeScript.Debug.assert(result); - return result; - } - - function getLocalizedText(diagnosticKey, args) { - if (TypeScript.LocalizedDiagnosticMessages) { - } - - var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; - TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); - - var actualCount = args ? args.length : 0; - - var expectedCount = 1 + getLargestIndex(diagnosticKey); - - if (expectedCount !== actualCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); - } - - var valueCount = 1 + getLargestIndex(diagnosticMessageText); - if (valueCount !== expectedCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); - } - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return TypeScript.newLine(); - }); - - return diagnosticMessageText; - } - TypeScript.getLocalizedText = getLocalizedText; - - function getDiagnosticMessage(diagnosticKey, args) { - var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); - var diagnosticMessageText = getLocalizedText(diagnosticKey, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + ". " + message); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error("Invalid operation: " + message); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2StringHashCode = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft == 1) { - h ^= key.charCodeAt(index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, - 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, - 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, - 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, - 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, - 4166287, 4999559, 5999471, 7199369]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 1024; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash) { - this.hash = hash; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode >= 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', "Key was already in table."); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && key === e.Key) { - return e; - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count >= (this.entries.length / 2)) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - return new HashTable(capacity, hash); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - TypeScript.nodeMakeDirectoryTime = 0; - TypeScript.nodeCreateBufferTime = 0; - TypeScript.nodeWriteFileSyncTime = 0; - - (function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; - })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); - var ByteOrderMark = TypeScript.ByteOrderMark; - - var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this.contents = contents; - this.byteOrderMark = byteOrderMark; - } - return FileInformation; - })(); - TypeScript.FileInformation = FileInformation; - - TypeScript.Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - newLine: "\r\n", - currentDirectory: function () { - return WScript.CreateObject("WScript.Shell").CurrentDirectory; - }, - supportsCodePage: function () { - return WScript.ReadFile; - }, - readFile: function (path, codepage) { - try { - if (codepage !== null && this.supportsCodePage()) { - try { - var contents = WScript.ReadFile(path, codepage); - return new FileInformation(contents, 0 /* None */); - } catch (e) { - } - } - - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - var message; - if (err.number === -2147024809) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); - } - - throw new Error(message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - var _os = require('os'); - - return { - newLine: _os.EOL, - currentDirectory: function () { - return process.cwd(); - }, - supportsCodePage: function () { - return false; - }, - readFile: function (file, codepage) { - if (codepage !== null) { - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); - } - - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 509); - } - } - var start = new Date().getTime(); - mkdirRecursiveSync(_path.dirname(path)); - TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - - var start = new Date().getTime(); - - var chunkLength = 4 * 1024; - var fileDescriptor = _fs.openSync(path, "w"); - try { - for (var index = 0; index < contents.length; index += chunkLength) { - var bufferStart = new Date().getTime(); - var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); - TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; - - _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); - } - } finally { - _fs.closeSync(fileDescriptor); - } - - TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IntegerUtilities) { - function integerDivide(numerator, denominator) { - return (numerator / denominator) >> 0; - } - IntegerUtilities.integerDivide = integerDivide; - - function integerMultiplyLow32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - } - IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; - - function integerMultiplyHigh32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - } - IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; - - function isInteger(text) { - return /^[0-9]+$/.test(text); - } - IntegerUtilities.isInteger = isInteger; - - function isHexInteger(text) { - return /^0(x|X)[0-9a-fA-F]+$/.test(text); - } - IntegerUtilities.isHexInteger = isHexInteger; - })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); - var IntegerUtilities = TypeScript.IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_computeLineStarts, length) { - this._computeLineStarts = _computeLineStarts; - this.length = length; - this._lineStarts = null; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this.lineStarts(), length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - if (this._lineStarts === null) { - this._lineStarts = this._computeLineStarts(); - } - - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - LineMap.empty = new LineMap(function () { - return [0]; - }, 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { - return e; - } - } - - return null; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - if (text.length !== length) { - return false; - } - - var s = start; - for (var i = 0; i < length; i++) { - if (text.charCodeAt(i) !== array[s]) { - return false; - } - - s++; - } - - return true; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticInformationMap = { - "error TS{0}: {1}": { - "code": 0, - "category": 3 /* NoPrefix */ - }, - "warning TS{0}: {1}": { - "code": 1, - "category": 3 /* NoPrefix */ - }, - "Unrecognized escape sequence.": { - "code": 1000, - "category": 1 /* Error */ - }, - "Unexpected character {0}.": { - "code": 1001, - "category": 1 /* Error */ - }, - "Missing close quote character.": { - "code": 1002, - "category": 1 /* Error */ - }, - "Identifier expected.": { - "code": 1003, - "category": 1 /* Error */ - }, - "'{0}' keyword expected.": { - "code": 1004, - "category": 1 /* Error */ - }, - "'{0}' expected.": { - "code": 1005, - "category": 1 /* Error */ - }, - "Identifier expected; '{0}' is a keyword.": { - "code": 1006, - "category": 1 /* Error */ - }, - "Automatic semicolon insertion not allowed.": { - "code": 1007, - "category": 1 /* Error */ - }, - "Unexpected token; '{0}' expected.": { - "code": 1008, - "category": 1 /* Error */ - }, - "Trailing separator not allowed.": { - "code": 1009, - "category": 1 /* Error */ - }, - "'*/' expected.": { - "code": 1010, - "category": 1 /* Error */ - }, - "'public' or 'private' modifier must precede 'static'.": { - "code": 1011, - "category": 1 /* Error */ - }, - "Unexpected token.": { - "code": 1012, - "category": 1 /* Error */ - }, - "Catch clause parameter cannot have a type annotation.": { - "code": 1013, - "category": 1 /* Error */ - }, - "Rest parameter must be last in list.": { - "code": 1014, - "category": 1 /* Error */ - }, - "Parameter cannot have question mark and initializer.": { - "code": 1015, - "category": 1 /* Error */ - }, - "Required parameter cannot follow optional parameter.": { - "code": 1016, - "category": 1 /* Error */ - }, - "Index signatures cannot have rest parameters.": { - "code": 1017, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have accessibility modifiers.": { - "code": 1018, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have a question mark.": { - "code": 1019, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have an initializer.": { - "code": 1020, - "category": 1 /* Error */ - }, - "Index signature must have a type annotation.": { - "code": 1021, - "category": 1 /* Error */ - }, - "Index signature parameter must have a type annotation.": { - "code": 1022, - "category": 1 /* Error */ - }, - "Index signature parameter type must be 'string' or 'number'.": { - "code": 1023, - "category": 1 /* Error */ - }, - "'extends' clause already seen.": { - "code": 1024, - "category": 1 /* Error */ - }, - "'extends' clause must precede 'implements' clause.": { - "code": 1025, - "category": 1 /* Error */ - }, - "Classes can only extend a single class.": { - "code": 1026, - "category": 1 /* Error */ - }, - "'implements' clause already seen.": { - "code": 1027, - "category": 1 /* Error */ - }, - "Accessibility modifier already seen.": { - "code": 1028, - "category": 1 /* Error */ - }, - "'{0}' modifier must precede '{1}' modifier.": { - "code": 1029, - "category": 1 /* Error */ - }, - "'{0}' modifier already seen.": { - "code": 1030, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a class element.": { - "code": 1031, - "category": 1 /* Error */ - }, - "Interface declaration cannot have 'implements' clause.": { - "code": 1032, - "category": 1 /* Error */ - }, - "'super' invocation cannot have type arguments.": { - "code": 1034, - "category": 1 /* Error */ - }, - "Only ambient modules can use quoted names.": { - "code": 1035, - "category": 1 /* Error */ - }, - "Statements are not allowed in ambient contexts.": { - "code": 1036, - "category": 1 /* Error */ - }, - "Implementations are not allowed in ambient contexts.": { - "code": 1037, - "category": 1 /* Error */ - }, - "'declare' modifier not allowed for code already in an ambient context.": { - "code": 1038, - "category": 1 /* Error */ - }, - "Initializers are not allowed in ambient contexts.": { - "code": 1039, - "category": 1 /* Error */ - }, - "Parameter property declarations can only be used in constructors.": { - "code": 1040, - "category": 1 /* Error */ - }, - "Function implementation expected.": { - "code": 1041, - "category": 1 /* Error */ - }, - "Constructor implementation expected.": { - "code": 1042, - "category": 1 /* Error */ - }, - "Function overload name must be '{0}'.": { - "code": 1043, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a module element.": { - "code": 1044, - "category": 1 /* Error */ - }, - "'declare' modifier cannot appear on an interface declaration.": { - "code": 1045, - "category": 1 /* Error */ - }, - "'declare' modifier required for top level element.": { - "code": 1046, - "category": 1 /* Error */ - }, - "Rest parameter cannot be optional.": { - "code": 1047, - "category": 1 /* Error */ - }, - "Rest parameter cannot have an initializer.": { - "code": 1048, - "category": 1 /* Error */ - }, - "'set' accessor must have one and only one parameter.": { - "code": 1049, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot be optional.": { - "code": 1051, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot have an initializer.": { - "code": 1052, - "category": 1 /* Error */ - }, - "'set' accessor cannot have rest parameter.": { - "code": 1053, - "category": 1 /* Error */ - }, - "'get' accessor cannot have parameters.": { - "code": 1054, - "category": 1 /* Error */ - }, - "Modifiers cannot appear here.": { - "code": 1055, - "category": 1 /* Error */ - }, - "Accessors are only available when targeting ECMAScript 5 and higher.": { - "code": 1056, - "category": 1 /* Error */ - }, - "Class name cannot be '{0}'.": { - "code": 1057, - "category": 1 /* Error */ - }, - "Interface name cannot be '{0}'.": { - "code": 1058, - "category": 1 /* Error */ - }, - "Enum name cannot be '{0}'.": { - "code": 1059, - "category": 1 /* Error */ - }, - "Module name cannot be '{0}'.": { - "code": 1060, - "category": 1 /* Error */ - }, - "Enum member must have initializer.": { - "code": 1061, - "category": 1 /* Error */ - }, - "Export assignment cannot be used in internal modules.": { - "code": 1063, - "category": 1 /* Error */ - }, - "Export assignment not allowed in module with exported element.": { - "code": 1064, - "category": 1 /* Error */ - }, - "Module cannot have multiple export assignments.": { - "code": 1065, - "category": 1 /* Error */ - }, - "Ambient enum elements can only have integer literal initializers.": { - "code": 1066, - "category": 1 /* Error */ - }, - "module, class, interface, enum, import or statement": { - "code": 1067, - "category": 3 /* NoPrefix */ - }, - "constructor, function, accessor or variable": { - "code": 1068, - "category": 3 /* NoPrefix */ - }, - "statement": { - "code": 1069, - "category": 3 /* NoPrefix */ - }, - "case or default clause": { - "code": 1070, - "category": 3 /* NoPrefix */ - }, - "identifier": { - "code": 1071, - "category": 3 /* NoPrefix */ - }, - "call, construct, index, property or function signature": { - "code": 1072, - "category": 3 /* NoPrefix */ - }, - "expression": { - "code": 1073, - "category": 3 /* NoPrefix */ - }, - "type name": { - "code": 1074, - "category": 3 /* NoPrefix */ - }, - "property or accessor": { - "code": 1075, - "category": 3 /* NoPrefix */ - }, - "parameter": { - "code": 1076, - "category": 3 /* NoPrefix */ - }, - "type": { - "code": 1077, - "category": 3 /* NoPrefix */ - }, - "type parameter": { - "code": 1078, - "category": 3 /* NoPrefix */ - }, - "'declare' modifier not allowed on import declaration.": { - "code": 1079, - "category": 1 /* Error */ - }, - "Function overload must be static.": { - "code": 1080, - "category": 1 /* Error */ - }, - "Function overload must not be static.": { - "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 */ - }, - "Invalid 'reference' directive syntax.": { - "code": 1084, - "category": 1 /* Error */ - }, - "Octal literals are not available when targeting ECMAScript 5 and higher.": { - "code": 1085, - "category": 1 /* Error */ - }, - "Accessors are not allowed in ambient contexts.": { - "code": 1086, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a constructor declaration.": { - "code": 1089, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a parameter.": { - "code": 1090, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'.": { - "code": 2000, - "category": 1 /* Error */ - }, - "The name '{0}' does not exist in the current scope.": { - "code": 2001, - "category": 1 /* Error */ - }, - "The name '{0}' does not refer to a value.": { - "code": 2002, - "category": 1 /* Error */ - }, - "'super' can only be used inside a class instance method.": { - "code": 2003, - "category": 1 /* Error */ - }, - "The left-hand side of an assignment expression must be a variable, property or indexer.": { - "code": 2004, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable. Did you mean to include 'new'?": { - "code": 2161, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable.": { - "code": 2006, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not newable.": { - "code": 2007, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not indexable by type '{1}'.": { - "code": 2008, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { - "code": 2009, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { - "code": 2010, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}'.": { - "code": 2011, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}':{NL}{2}": { - "code": 2012, - "category": 1 /* Error */ - }, - "Expected var, class, interface, or module.": { - "code": 2013, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to type '{1}'.": { - "code": 2014, - "category": 1 /* Error */ - }, - "Getter '{0}' already declared.": { - "code": 2015, - "category": 1 /* Error */ - }, - "Setter '{0}' already declared.": { - "code": 2016, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends private class '{1}'.": { - "code": 2018, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements private interface '{1}'.": { - "code": 2019, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends private interface '{1}'.": { - "code": 2020, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends class from inaccessible module {1}.": { - "code": 2021, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements interface from inaccessible module {1}.": { - "code": 2022, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends interface from inaccessible module {1}.": { - "code": 2023, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2024, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2025, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2026, - "category": 1 /* Error */ - }, - "Exported variable '{0}' has or is using private type '{1}'.": { - "code": 2027, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2028, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2029, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2030, - "category": 1 /* Error */ - }, - "Exported variable '{0}' is using inaccessible module {1}.": { - "code": 2031, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { - "code": 2032, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { - "code": 2033, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { - "code": 2034, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2035, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2036, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2037, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2038, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2039, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2040, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { - "code": 2041, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { - "code": 2042, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { - "code": 2043, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2044, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2045, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2046, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2047, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2048, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2049, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class has or is using private type '{0}'.": { - "code": 2050, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class has or is using private type '{0}'.": { - "code": 2051, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface has or is using private type '{0}'.": { - "code": 2052, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface has or is using private type '{0}'.": { - "code": 2053, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface has or is using private type '{0}'.": { - "code": 2054, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class has or is using private type '{0}'.": { - "code": 2055, - "category": 1 /* Error */ - }, - "Return type of public method from exported class has or is using private type '{0}'.": { - "code": 2056, - "category": 1 /* Error */ - }, - "Return type of method from exported interface has or is using private type '{0}'.": { - "code": 2057, - "category": 1 /* Error */ - }, - "Return type of exported function has or is using private type '{0}'.": { - "code": 2058, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class is using inaccessible module {0}.": { - "code": 2059, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class is using inaccessible module {0}.": { - "code": 2060, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface is using inaccessible module {0}.": { - "code": 2061, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface is using inaccessible module {0}.": { - "code": 2062, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface is using inaccessible module {0}.": { - "code": 2063, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class is using inaccessible module {0}.": { - "code": 2064, - "category": 1 /* Error */ - }, - "Return type of public method from exported class is using inaccessible module {0}.": { - "code": 2065, - "category": 1 /* Error */ - }, - "Return type of method from exported interface is using inaccessible module {0}.": { - "code": 2066, - "category": 1 /* Error */ - }, - "Return type of exported function is using inaccessible module {0}.": { - "code": 2067, - "category": 1 /* Error */ - }, - "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { - "code": 2068, - "category": 1 /* Error */ - }, - "A parameter list must follow a generic type argument list. '(' expected.": { - "code": 2069, - "category": 1 /* Error */ - }, - "Multiple constructor implementations are not allowed.": { - "code": 2070, - "category": 1 /* Error */ - }, - "Unable to resolve external module '{0}'.": { - "code": 2071, - "category": 1 /* Error */ - }, - "Module cannot be aliased to a non-module type.": { - "code": 2072, - "category": 1 /* Error */ - }, - "A class may only extend another class.": { - "code": 2073, - "category": 1 /* Error */ - }, - "A class may only implement another class or interface.": { - "code": 2074, - "category": 1 /* Error */ - }, - "An interface may only extend another class or interface.": { - "code": 2075, - "category": 1 /* Error */ - }, - "Unable to resolve type.": { - "code": 2077, - "category": 1 /* Error */ - }, - "Unable to resolve type of '{0}'.": { - "code": 2078, - "category": 1 /* Error */ - }, - "Unable to resolve type parameter constraint.": { - "code": 2079, - "category": 1 /* Error */ - }, - "Type parameter constraint cannot be a primitive type.": { - "code": 2080, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target.": { - "code": 2081, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target:{NL}{0}": { - "code": 2082, - "category": 1 /* Error */ - }, - "Invalid 'new' expression.": { - "code": 2083, - "category": 1 /* Error */ - }, - "Call signatures used in a 'new' expression must have a 'void' return type.": { - "code": 2084, - "category": 1 /* Error */ - }, - "Could not select overload for 'new' expression.": { - "code": 2085, - "category": 1 /* Error */ - }, - "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { - "code": 2086, - "category": 1 /* Error */ - }, - "Could not select overload for 'call' expression.": { - "code": 2087, - "category": 1 /* Error */ - }, - "Cannot invoke an expression whose type lacks a call signature.": { - "code": 2088, - "category": 1 /* Error */ - }, - "Calls to 'super' are only valid inside a class.": { - "code": 2089, - "category": 1 /* Error */ - }, - "Generic type '{0}' requires {1} type argument(s).": { - "code": 2090, - "category": 1 /* Error */ - }, - "Type of array literal cannot be determined. Best common type could not be found for array elements.": { - "code": 2092, - "category": 1 /* Error */ - }, - "Could not find enclosing symbol for dotted name '{0}'.": { - "code": 2093, - "category": 1 /* Error */ - }, - "The property '{0}' does not exist on value of type '{1}'.": { - "code": 2094, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}'.": { - "code": 2095, - "category": 1 /* Error */ - }, - "'get' and 'set' accessor must have the same type.": { - "code": 2096, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in current location.": { - "code": 2097, - "category": 1 /* Error */ - }, - "Static methods cannot reference class type parameters.": { - "code": 2099, - "category": 1 /* Error */ - }, - "Class '{0}' is recursively referenced as a base type of itself.": { - "code": 2100, - "category": 1 /* Error */ - }, - "Interface '{0}' is recursively referenced as a base type of itself.": { - "code": 2101, - "category": 1 /* Error */ - }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { - "code": 2102, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in non-derived classes.": { - "code": 2103, - "category": 1 /* Error */ - }, - "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { - "code": 2104, - "category": 1 /* Error */ - }, - "Constructors for derived classes must contain a 'super' call.": { - "code": 2105, - "category": 1 /* Error */ - }, - "Super calls are not permitted outside constructors or in local functions inside constructors.": { - "code": 2106, - "category": 1 /* Error */ - }, - "'{0}.{1}' is inaccessible.": { - "code": 2107, - "category": 1 /* Error */ - }, - "'this' cannot be referenced within module bodies.": { - "code": 2108, - "category": 1 /* Error */ - }, - "Invalid '+' expression - types not known to support the addition operator.": { - "code": 2111, - "category": 1 /* Error */ - }, - "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2112, - "category": 1 /* Error */ - }, - "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2113, - "category": 1 /* Error */ - }, - "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { - "code": 2114, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement cannot use a type annotation.": { - "code": 2115, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { - "code": 2116, - "category": 1 /* Error */ - }, - "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { - "code": 2117, - "category": 1 /* Error */ - }, - "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { - "code": 2118, - "category": 1 /* Error */ - }, - "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { - "code": 2119, - "category": 1 /* Error */ - }, - "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { - "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.": { - "code": 2121, - "category": 1 /* Error */ - }, - "Setters cannot return a value.": { - "code": 2122, - "category": 1 /* Error */ - }, - "Tried to query type of uninitialized module '{0}'.": { - "code": 2123, - "category": 1 /* Error */ - }, - "Tried to set variable type to uninitialized module type '{0}'.": { - "code": 2124, - "category": 1 /* Error */ - }, - "Function '{0}' declared a non-void return type, but has no return expression.": { - "code": 2125, - "category": 1 /* Error */ - }, - "Getters must return a value.": { - "code": 2126, - "category": 1 /* Error */ - }, - "Getter and setter accessors do not agree in visibility.": { - "code": 2127, - "category": 1 /* Error */ - }, - "Invalid left-hand side of assignment expression.": { - "code": 2130, - "category": 1 /* Error */ - }, - "Function declared a non-void return type, but has no return expression.": { - "code": 2131, - "category": 1 /* Error */ - }, - "Cannot resolve return type reference.": { - "code": 2132, - "category": 1 /* Error */ - }, - "Constructors cannot have a return type of 'void'.": { - "code": 2133, - "category": 1 /* Error */ - }, - "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { - "code": 2134, - "category": 1 /* Error */ - }, - "All symbols within a with block will be resolved to 'any'.": { - "code": 2135, - "category": 1 /* Error */ - }, - "Import declarations in an internal module cannot reference an external module.": { - "code": 2136, - "category": 1 /* Error */ - }, - "Class {0} declares interface {1} but does not implement it:{NL}{2}": { - "code": 2137, - "category": 1 /* Error */ - }, - "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { - "code": 2138, - "category": 1 /* Error */ - }, - "The operand of an increment or decrement operator must be a variable, property or indexer.": { - "code": 2139, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in static initializers in a class body.": { - "code": 2140, - "category": 1 /* Error */ - }, - "Class '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2141, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2142, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { - "code": 2143, - "category": 1 /* Error */ - }, - "Duplicate overload signature for '{0}'.": { - "code": 2144, - "category": 1 /* Error */ - }, - "Duplicate constructor overload signature.": { - "code": 2145, - "category": 1 /* Error */ - }, - "Duplicate overload call signature.": { - "code": 2146, - "category": 1 /* Error */ - }, - "Duplicate overload construct signature.": { - "code": 2147, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition.": { - "code": 2148, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition:{NL}{0}": { - "code": 2149, - "category": 1 /* Error */ - }, - "Overload signatures must all be public or private.": { - "code": 2150, - "category": 1 /* Error */ - }, - "Overload signatures must all be exported or not exported.": { - "code": 2151, - "category": 1 /* Error */ - }, - "Overload signatures must all be ambient or non-ambient.": { - "code": 2152, - "category": 1 /* Error */ - }, - "Overload signatures must all be optional or required.": { - "code": 2153, - "category": 1 /* Error */ - }, - "Specialized overload signature is not subtype of any non-specialized signature.": { - "code": 2154, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in constructor arguments.": { - "code": 2155, - "category": 1 /* Error */ - }, - "Instance member cannot be accessed off a class.": { - "code": 2157, - "category": 1 /* Error */ - }, - "Untyped function calls may not accept type arguments.": { - "code": 2158, - "category": 1 /* Error */ - }, - "Non-generic functions may not accept type arguments.": { - "code": 2159, - "category": 1 /* Error */ - }, - "A generic type may not reference itself with a wrapped form of its own type parameters.": { - "code": 2160, - "category": 1 /* Error */ - }, - "Rest parameters must be array types.": { - "code": 2162, - "category": 1 /* Error */ - }, - "Overload signature implementation cannot use specialized type.": { - "code": 2163, - "category": 1 /* Error */ - }, - "Export assignments may only be used at the top-level of external modules.": { - "code": 2164, - "category": 1 /* Error */ - }, - "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2165, - "category": 1 /* Error */ - }, - "Only public methods of the base class are accessible via the 'super' keyword.": { - "code": 2166, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}'.": { - "code": 2167, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be a subtype of string indexer type '{1}':{NL}{2}": { - "code": 2168, - "category": 1 /* Error */ - }, - "All numerically named properties must be subtypes of numeric indexer type '{0}'.": { - "code": 2169, - "category": 1 /* Error */ - }, - "All numerically named properties must be subtypes of numeric indexer type '{0}':{NL}{1}": { - "code": 2170, - "category": 1 /* Error */ - }, - "All named properties must be subtypes of string indexer type '{0}'.": { - "code": 2171, - "category": 1 /* Error */ - }, - "All named properties must be subtypes of string indexer type '{0}':{NL}{1}": { - "code": 2172, - "category": 1 /* Error */ - }, - "Generic type references must include all type arguments.": { - "code": 2173, - "category": 1 /* Error */ - }, - "Default arguments are not allowed in an overload parameter.": { - "code": 2174, - "category": 1 /* Error */ - }, - "Overloads cannot differ only by return type.": { - "code": 2175, - "category": 1 /* Error */ - }, - "Function expression declared a non-void return type, but has no return expression.": { - "code": 2176, - "category": 1 /* Error */ - }, - "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2177, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}' in module '{1}'.": { - "code": 2178, - "category": 1 /* Error */ - }, - "Unable to resolve module reference '{0}'.": { - "code": 2179, - "category": 1 /* Error */ - }, - "Could not find module '{0}' in module '{1}'.": { - "code": 2180, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { - "code": 2181, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { - "code": 2182, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { - "code": 2183, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { - "code": 2184, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { - "code": 2185, - "category": 1 /* Error */ - }, - "Type reference '{0}' in extends clause does not reference constructor function for '{1}'.": { - "code": 2186, - "category": 1 /* Error */ - }, - "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { - "code": 2187, - "category": 1 /* Error */ - }, - "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { - "code": 2188, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { - "code": 2189, - "category": 1 /* Error */ - }, - "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { - "code": 2190, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot be reopened.": { - "code": 2191, - "category": 1 /* Error */ - }, - "All declarations of merged declaration '{0}' must be exported or not exported.": { - "code": 2192, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in constructor arguments.": { - "code": 2193, - "category": 1 /* Error */ - }, - "Return type of constructor signature must be assignable to the instance type of the class.": { - "code": 2194, - "category": 1 /* Error */ - }, - "Ambient external module declaration must be defined in global context.": { - "code": 2195, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot specify relative module name.": { - "code": 2196, - "category": 1 /* Error */ - }, - "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { - "code": 2197, - "category": 1 /* Error */ - }, - "Could not find the best common type of types of all return statement expressions.": { - "code": 2198, - "category": 1 /* Error */ - }, - "Import declaration cannot refer to external module reference when --noResolve option is set.": { - "code": 2199, - "category": 1 /* Error */ - }, - "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { - "code": 2200, - "category": 1 /* Error */ - }, - "'continue' statement can only be used within an enclosing iteration statement.": { - "code": 2201, - "category": 1 /* Error */ - }, - "'break' statement can only be used within an enclosing iteration or switch statement.": { - "code": 2202, - "category": 1 /* Error */ - }, - "Jump target not found.": { - "code": 2203, - "category": 1 /* Error */ - }, - "Jump target cannot cross function boundary.": { - "code": 2204, - "category": 1 /* Error */ - }, - "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { - "code": 2205, - "category": 1 /* Error */ - }, - "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { - "code": 2206, - "category": 1 /* Error */ - }, - "Expression resolves to '_super' that compiler uses to capture base class reference.": { - "code": 2207, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2208, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2209, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2210, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2211, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2212, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2213, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2214, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2215, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2216, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2217, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2218, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2219, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { - "code": 2220, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2221, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { - "code": 2222, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2223, - "category": 1 /* Error */ - }, - "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { - "code": 2224, - "category": 1 /* Error */ - }, - "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { - "code": 2225, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { - "code": 2226, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { - "code": 2227, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { - "code": 2228, - "category": 1 /* Error */ - }, - "Type '{0}' is missing property '{1}' from type '{2}'.": { - "code": 4000, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { - "code": 4001, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { - "code": 4002, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { - "code": 4003, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { - "code": 4004, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' define property '{2}' as private.": { - "code": 4005, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4006, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4007, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a call signature, but type '{1}' lacks one.": { - "code": 4008, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4009, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4010, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { - "code": 4011, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4012, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4013, - "category": 3 /* NoPrefix */ - }, - "Call signature expects {0} or fewer parameters.": { - "code": 4014, - "category": 3 /* NoPrefix */ - }, - "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { - "code": 4015, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4016, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4017, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { - "code": 4018, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { - "code": 4019, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { - "code": 4020, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { - "code": 4021, - "category": 3 /* NoPrefix */ - }, - "Type reference cannot refer to container '{0}'.": { - "code": 4022, - "category": 1 /* Error */ - }, - "Type reference must refer to type.": { - "code": 4023, - "category": 1 /* Error */ - }, - "Enums with multiple declarations must provide an initializer for the first enum element.": { - "code": 4024, - "category": 1 /* Error */ - }, - " (+ {0} overload(s))": { - "code": 4025, - "category": 2 /* Message */ - }, - "Variable declaration cannot have the same name as an import declaration.": { - "code": 4026, - "category": 1 /* Error */ - }, - "Signature expected {0} type arguments, got {1} instead.": { - "code": 4027, - "category": 1 /* Error */ - }, - "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { - "code": 4028, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in inifinitely 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.": { - "code": 4030, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in inifinitely 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.": { - "code": 4032, - "category": 3 /* NoPrefix */ - }, - "Types of string indexer of types '{0}' and '{1}' are not identical.": { - "code": 4033, - "category": 3 /* NoPrefix */ - }, - "Types of number indexer of types '{0}' and '{1}' are not identical.": { - "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}": { - "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}": { - "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}": { - "code": 4037, - "category": 3 /* NoPrefix */ - }, - "Current host does not support '{0}' option.": { - "code": 5001, - "category": 1 /* Error */ - }, - "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { - "code": 5002, - "category": 1 /* Error */ - }, - "Module code generation '{0}' not supported.": { - "code": 5003, - "category": 1 /* Error */ - }, - "Could not find file: '{0}'.": { - "code": 5004, - "category": 1 /* Error */ - }, - "A file cannot have a reference to itself.": { - "code": 5006, - "category": 1 /* Error */ - }, - "Cannot resolve referenced file: '{0}'.": { - "code": 5007, - "category": 1 /* Error */ - }, - "Cannot find the common subdirectory path for the input files.": { - "code": 5009, - "category": 1 /* Error */ - }, - "Emit Error: {0}.": { - "code": 5011, - "category": 1 /* Error */ - }, - "Cannot read file '{0}': {1}": { - "code": 5012, - "category": 1 /* Error */ - }, - "Unsupported file encoding.": { - "code": 5013, - "category": 3 /* NoPrefix */ - }, - "Locale must be of the form or -. For example '{0}' or '{1}'.": { - "code": 5014, - "category": 1 /* Error */ - }, - "Unsupported locale: '{0}'.": { - "code": 5015, - "category": 1 /* Error */ - }, - "Execution Failed.{NL}": { - "code": 5016, - "category": 1 /* Error */ - }, - "Invalid call to 'up'": { - "code": 5019, - "category": 1 /* Error */ - }, - "Invalid call to 'down'": { - "code": 5020, - "category": 1 /* Error */ - }, - "Base64 value '{0}' finished with a continuation bit.": { - "code": 5021, - "category": 1 /* Error */ - }, - "Unknown option '{0}'": { - "code": 5023, - "category": 1 /* Error */ - }, - "Expected {0} arguments to message, got {1} instead.": { - "code": 5024, - "category": 1 /* Error */ - }, - "Expected the message '{0}' to have {1} arguments, but it had {2}": { - "code": 5025, - "category": 1 /* Error */ - }, - "Could not delete file '{0}'": { - "code": 5034, - "category": 1 /* Error */ - }, - "Could not create directory '{0}'": { - "code": 5035, - "category": 1 /* Error */ - }, - "Error while executing file '{0}': ": { - "code": 5036, - "category": 1 /* Error */ - }, - "Cannot compile external modules unless the '--module' flag is provided.": { - "code": 5037, - "category": 1 /* Error */ - }, - "Option mapRoot cannot be specified without specifying sourcemap option.": { - "code": 5038, - "category": 1 /* Error */ - }, - "Option sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5039, - "category": 1 /* Error */ - }, - "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5040, - "category": 1 /* Error */ - }, - "Option '{0}' specified without '{1}'": { - "code": 5041, - "category": 1 /* Error */ - }, - "'codepage' option not supported on current platform.": { - "code": 5042, - "category": 1 /* Error */ - }, - "Concatenate and emit output to single file.": { - "code": 6001, - "category": 2 /* Message */ - }, - "Generates corresponding {0} file.": { - "code": 6002, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate map files instead of generated locations.": { - "code": 6003, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate TypeScript files instead of source locations.": { - "code": 6004, - "category": 2 /* Message */ - }, - "Watch input files.": { - "code": 6005, - "category": 2 /* Message */ - }, - "Redirect output structure to the directory.": { - "code": 6006, - "category": 2 /* Message */ - }, - "Do not emit comments to output.": { - "code": 6009, - "category": 2 /* Message */ - }, - "Skip resolution and preprocessing.": { - "code": 6010, - "category": 2 /* Message */ - }, - "Specify ECMAScript target version: '{0}' (default), or '{1}'": { - "code": 6015, - "category": 2 /* Message */ - }, - "Specify module code generation: '{0}' or '{1}'": { - "code": 6016, - "category": 2 /* Message */ - }, - "Print this message.": { - "code": 6017, - "category": 2 /* Message */ - }, - "Print the compiler's version: {0}": { - "code": 6019, - "category": 2 /* Message */ - }, - "Allow use of deprecated '{0}' keyword when referencing an external module.": { - "code": 6021, - "category": 2 /* Message */ - }, - "Specify locale for errors and messages. For example '{0}' or '{1}'": { - "code": 6022, - "category": 2 /* Message */ - }, - "Syntax: {0}": { - "code": 6023, - "category": 2 /* Message */ - }, - "options": { - "code": 6024, - "category": 2 /* Message */ - }, - "file1": { - "code": 6025, - "category": 2 /* Message */ - }, - "Examples:": { - "code": 6026, - "category": 2 /* Message */ - }, - "Options:": { - "code": 6027, - "category": 2 /* Message */ - }, - "Insert command line options and files from a file.": { - "code": 6030, - "category": 2 /* Message */ - }, - "Version {0}": { - "code": 6029, - "category": 2 /* Message */ - }, - "Use the '{0}' flag to see options.": { - "code": 6031, - "category": 2 /* Message */ - }, - "{NL}Recompiling ({0}):": { - "code": 6032, - "category": 2 /* Message */ - }, - "STRING": { - "code": 6033, - "category": 2 /* Message */ - }, - "KIND": { - "code": 6034, - "category": 2 /* Message */ - }, - "file2": { - "code": 6035, - "category": 2 /* Message */ - }, - "VERSION": { - "code": 6036, - "category": 2 /* Message */ - }, - "LOCATION": { - "code": 6037, - "category": 2 /* Message */ - }, - "DIRECTORY": { - "code": 6038, - "category": 2 /* Message */ - }, - "NUMBER": { - "code": 6039, - "category": 2 /* Message */ - }, - "Specify the codepage to use when opening source files.": { - "code": 6040, - "category": 2 /* Message */ - }, - "This version of the Javascript runtime does not support the '{0}' function.": { - "code": 7000, - "category": 1 /* Error */ - }, - "Unknown rule.": { - "code": 7002, - "category": 1 /* Error */ - }, - "Invalid line number ({0})": { - "code": 7003, - "category": 1 /* Error */ - }, - "Warn on expressions and declarations with an implied 'any' type.": { - "code": 7004, - "category": 2 /* Message */ - }, - "Variable '{0}' implicitly has an 'any' type.": { - "code": 7005, - "category": 1 /* Error */ - }, - "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { - "code": 7006, - "category": 1 /* Error */ - }, - "Parameter '{0}' of function type implicitly has an 'any' type.": { - "code": 7007, - "category": 1 /* Error */ - }, - "Member '{0}' of object type implicitly has an 'any' type.": { - "code": 7008, - "category": 1 /* Error */ - }, - "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { - "code": 7009, - "category": 1 /* Error */ - }, - "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7010, - "category": 1 /* Error */ - }, - "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7011, - "category": 1 /* Error */ - }, - "Parameter '{0}' of lambda function implicitly has an 'any' type.": { - "code": 7012, - "category": 1 /* Error */ - }, - "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7013, - "category": 1 /* Error */ - }, - "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7014, - "category": 1 /* Error */ - }, - "Array Literal implicitly has an 'any' type from widening.": { - "code": 7015, - "category": 1 /* Error */ - }, - "'{0}', which lacks 'get' accessor and parameter type annotation on 'set' accessor, implicitly has an 'any' type.": { - "code": 7016, - "category": 1 /* Error */ - } - }; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - this._lineStartPositions = null; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - if (!this._lineStartPositions) { - this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); - } - - return this._lineStartPositions; - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LineMap1) { - function fromSimpleText(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return text.charCodeAt(index); - }, length: text.length() }); - }, text.length()); - } - LineMap1.fromSimpleText = fromSimpleText; - - function fromScriptSnapshot(scriptSnapshot) { - return new TypeScript.LineMap(function () { - return scriptSnapshot.getLineStartPositions(); - }, scriptSnapshot.getLength()); - } - LineMap1.fromScriptSnapshot = fromScriptSnapshot; - - function fromString(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts(text); - }, text.length); - } - LineMap1.fromString = fromString; - })(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) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - if (text === null) { - throw TypeScript.Errors.argumentNull('text'); - } - TypeScript.Debug.assert(lineBreakLength >= 0); - TypeScript.Debug.assert(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this._lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this._lineStarts(); - }, this.length()); - }; - - TextBase.prototype._lineStarts = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this._lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - this._lazyLineStarts = null; - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.substr = function (start, length, intern) { - var startInOriginalText = this.span.start() + start; - return this.text.substr(startInOriginalText, length, intern); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SubText.prototype._lineStarts = function () { - var _this = this; - if (!this._lazyLineStarts) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return _this.charCodeAt(index); - }, length: this.length() }); - } - - return this._lazyLineStarts; - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - this._lazyLineStarts = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - - StringText.prototype._lineStarts = function () { - if (this._lazyLineStarts === null) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); - } - - return this._lazyLineStarts; - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap1.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - this._lineMap = null; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - if (!this._lineMap) { - this._lineMap = TypeScript.LineMap1.fromString(this.value); - } - - return this._lineMap; - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this.scriptSnapshot.getLineStartPositions(); - }, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length; - - if (0 === length) { - var result = new Array(); - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = new Array(); - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (length < 0) { - TypeScript.Errors.argument("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Debug.assert(start >= 0); - TypeScript.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - var change0 = changes[0]; - - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - - oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - CharacterInfo.isOctalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 55 /* _7 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - - SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { - this._languageVersion = languageVersion; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - } - ParseOptions.prototype.toJSON = function (key) { - return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; - }; - - ParseOptions.prototype.languageVersion = function () { - return this._languageVersion; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; - - SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; - SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; - - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - - SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; - SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 62 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 63 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 64 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 65 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 67 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 66 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 68 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 69 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 70 /* OpenBraceToken */, - "}": 71 /* CloseBraceToken */, - "(": 72 /* OpenParenToken */, - ")": 73 /* CloseParenToken */, - "[": 74 /* OpenBracketToken */, - "]": 75 /* CloseBracketToken */, - ".": 76 /* DotToken */, - "...": 77 /* DotDotDotToken */, - ";": 78 /* SemicolonToken */, - ",": 79 /* CommaToken */, - "<": 80 /* LessThanToken */, - ">": 81 /* GreaterThanToken */, - "<=": 82 /* LessThanEqualsToken */, - ">=": 83 /* GreaterThanEqualsToken */, - "==": 84 /* EqualsEqualsToken */, - "=>": 85 /* EqualsGreaterThanToken */, - "!=": 86 /* ExclamationEqualsToken */, - "===": 87 /* EqualsEqualsEqualsToken */, - "!==": 88 /* ExclamationEqualsEqualsToken */, - "+": 89 /* PlusToken */, - "-": 90 /* MinusToken */, - "*": 91 /* AsteriskToken */, - "%": 92 /* PercentToken */, - "++": 93 /* PlusPlusToken */, - "--": 94 /* MinusMinusToken */, - "<<": 95 /* LessThanLessThanToken */, - ">>": 96 /* GreaterThanGreaterThanToken */, - ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 98 /* AmpersandToken */, - "|": 99 /* BarToken */, - "^": 100 /* CaretToken */, - "!": 101 /* ExclamationToken */, - "~": 102 /* TildeToken */, - "&&": 103 /* AmpersandAmpersandToken */, - "||": 104 /* BarBarToken */, - "?": 105 /* QuestionToken */, - ":": 106 /* ColonToken */, - "=": 107 /* EqualsToken */, - "+=": 108 /* PlusEqualsToken */, - "-=": 109 /* MinusEqualsToken */, - "*=": 110 /* AsteriskEqualsToken */, - "%=": 111 /* PercentEqualsToken */, - "<<=": 112 /* LessThanLessThanEqualsToken */, - ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 115 /* AmpersandEqualsToken */, - "|=": 116 /* BarEqualsToken */, - "^=": 117 /* CaretEqualsToken */, - "/": 118 /* SlashToken */, - "/=": 119 /* SlashEqualsToken */ - }; - - var kindToText = new Array(); - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[62 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 89 /* PlusToken */: - return 164 /* PlusExpression */; - case 90 /* MinusToken */: - return 165 /* NegateExpression */; - case 102 /* TildeToken */: - return 166 /* BitwiseNotExpression */; - case 101 /* ExclamationToken */: - return 167 /* LogicalNotExpression */; - case 93 /* PlusPlusToken */: - return 168 /* PreIncrementExpression */; - case 94 /* MinusMinusToken */: - return 169 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 93 /* PlusPlusToken */: - return 210 /* PostIncrementExpression */; - case 94 /* MinusMinusToken */: - return 211 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 91 /* AsteriskToken */: - return 205 /* MultiplyExpression */; - - case 118 /* SlashToken */: - return 206 /* DivideExpression */; - - case 92 /* PercentToken */: - return 207 /* ModuloExpression */; - - case 89 /* PlusToken */: - return 208 /* AddExpression */; - - case 90 /* MinusToken */: - return 209 /* SubtractExpression */; - - case 95 /* LessThanLessThanToken */: - return 202 /* LeftShiftExpression */; - - case 96 /* GreaterThanGreaterThanToken */: - return 203 /* SignedRightShiftExpression */; - - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - return 204 /* UnsignedRightShiftExpression */; - - case 80 /* LessThanToken */: - return 196 /* LessThanExpression */; - - case 81 /* GreaterThanToken */: - return 197 /* GreaterThanExpression */; - - case 82 /* LessThanEqualsToken */: - return 198 /* LessThanOrEqualExpression */; - - case 83 /* GreaterThanEqualsToken */: - return 199 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 200 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 201 /* InExpression */; - - case 84 /* EqualsEqualsToken */: - return 192 /* EqualsWithTypeConversionExpression */; - - case 86 /* ExclamationEqualsToken */: - return 193 /* NotEqualsWithTypeConversionExpression */; - - case 87 /* EqualsEqualsEqualsToken */: - return 194 /* EqualsExpression */; - - case 88 /* ExclamationEqualsEqualsToken */: - return 195 /* NotEqualsExpression */; - - case 98 /* AmpersandToken */: - return 191 /* BitwiseAndExpression */; - - case 100 /* CaretToken */: - return 190 /* BitwiseExclusiveOrExpression */; - - case 99 /* BarToken */: - return 189 /* BitwiseOrExpression */; - - case 103 /* AmpersandAmpersandToken */: - return 188 /* LogicalAndExpression */; - - case 104 /* BarBarToken */: - return 187 /* LogicalOrExpression */; - - case 116 /* BarEqualsToken */: - return 182 /* OrAssignmentExpression */; - - case 115 /* AmpersandEqualsToken */: - return 180 /* AndAssignmentExpression */; - - case 117 /* CaretEqualsToken */: - return 181 /* ExclusiveOrAssignmentExpression */; - - case 112 /* LessThanLessThanEqualsToken */: - return 183 /* LeftShiftAssignmentExpression */; - - case 113 /* GreaterThanGreaterThanEqualsToken */: - return 184 /* SignedRightShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 185 /* UnsignedRightShiftAssignmentExpression */; - - case 108 /* PlusEqualsToken */: - return 175 /* AddAssignmentExpression */; - - case 109 /* MinusEqualsToken */: - return 176 /* SubtractAssignmentExpression */; - - case 110 /* AsteriskEqualsToken */: - return 177 /* MultiplyAssignmentExpression */; - - case 119 /* SlashEqualsToken */: - return 178 /* DivideAssignmentExpression */; - - case 111 /* PercentEqualsToken */: - return 179 /* ModuloAssignmentExpression */; - - case 107 /* EqualsToken */: - return 174 /* AssignmentExpression */; - - case 79 /* CommaToken */: - return 173 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function getOperatorTokenFromBinaryExpression(tokenKind) { - switch (tokenKind) { - case 205 /* MultiplyExpression */: - return 91 /* AsteriskToken */; - - case 206 /* DivideExpression */: - return 118 /* SlashToken */; - - case 207 /* ModuloExpression */: - return 92 /* PercentToken */; - - case 208 /* AddExpression */: - return 89 /* PlusToken */; - - case 209 /* SubtractExpression */: - return 90 /* MinusToken */; - - case 202 /* LeftShiftExpression */: - return 95 /* LessThanLessThanToken */; - - case 203 /* SignedRightShiftExpression */: - return 96 /* GreaterThanGreaterThanToken */; - - case 204 /* UnsignedRightShiftExpression */: - return 97 /* GreaterThanGreaterThanGreaterThanToken */; - - case 196 /* LessThanExpression */: - return 80 /* LessThanToken */; - - case 197 /* GreaterThanExpression */: - return 81 /* GreaterThanToken */; - - case 198 /* LessThanOrEqualExpression */: - return 82 /* LessThanEqualsToken */; - - case 199 /* GreaterThanOrEqualExpression */: - return 83 /* GreaterThanEqualsToken */; - - case 200 /* InstanceOfExpression */: - return 30 /* InstanceOfKeyword */; - - case 201 /* InExpression */: - return 29 /* InKeyword */; - - case 192 /* EqualsWithTypeConversionExpression */: - return 84 /* EqualsEqualsToken */; - - case 193 /* NotEqualsWithTypeConversionExpression */: - return 86 /* ExclamationEqualsToken */; - - case 194 /* EqualsExpression */: - return 87 /* EqualsEqualsEqualsToken */; - - case 195 /* NotEqualsExpression */: - return 88 /* ExclamationEqualsEqualsToken */; - - case 191 /* BitwiseAndExpression */: - return 98 /* AmpersandToken */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 100 /* CaretToken */; - - case 189 /* BitwiseOrExpression */: - return 99 /* BarToken */; - - case 188 /* LogicalAndExpression */: - return 103 /* AmpersandAmpersandToken */; - - case 187 /* LogicalOrExpression */: - return 104 /* BarBarToken */; - - case 182 /* OrAssignmentExpression */: - return 116 /* BarEqualsToken */; - - case 180 /* AndAssignmentExpression */: - return 115 /* AmpersandEqualsToken */; - - case 181 /* ExclusiveOrAssignmentExpression */: - return 117 /* CaretEqualsToken */; - - case 183 /* LeftShiftAssignmentExpression */: - return 112 /* LessThanLessThanEqualsToken */; - - case 184 /* SignedRightShiftAssignmentExpression */: - return 113 /* GreaterThanGreaterThanEqualsToken */; - - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - - case 175 /* AddAssignmentExpression */: - return 108 /* PlusEqualsToken */; - - case 176 /* SubtractAssignmentExpression */: - return 109 /* MinusEqualsToken */; - - case 177 /* MultiplyAssignmentExpression */: - return 110 /* AsteriskEqualsToken */; - - case 178 /* DivideAssignmentExpression */: - return 119 /* SlashEqualsToken */; - - case 179 /* ModuloAssignmentExpression */: - return 111 /* PercentEqualsToken */; - - case 174 /* AssignmentExpression */: - return 107 /* EqualsToken */; - - case 173 /* CommaExpression */: - return 79 /* CommaToken */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; - - function isAnyDivideToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - isIdentifierPartCharacter[character] = true; - isNumericLiteralStart[character] = true; - } - } - - isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); - var end = this.slidingWindow.absoluteIndex(); - - var trailingTriviaInfo = this.scanTriviaInfo(diagnostics, true); - - var isVariableWidthKeyword = (kindAndFlags & -2147483648 /* IsVariableWidthKeyword */) !== 0; - var kind = kindAndFlags & ~-2147483648 /* IsVariableWidthKeyword */; - - var token = this.createToken(fullStart, leadingTriviaInfo, start, kind, end, trailingTriviaInfo, isVariableWidthKeyword); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - Scanner.prototype.createToken = function (fullStart, leadingTriviaInfo, start, kind, end, 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); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } else { - var width = end - start; - if (leadingTriviaInfo === 0) { - if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithNoTrivia(this.text, fullStart, kind, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(this.text, fullStart, kind, width, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(this.text, fullStart, kind, leadingTriviaInfo, width, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(text, start, isTrailing); - }; - - Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { - var trivia = new Array(); - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.slidingWindow.absoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(diagnostics); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(79 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(106 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(78 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(102 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(72 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(73 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(105 /* QuestionToken */); - } - - if (isNumericLiteralStart[character]) { - return this.scanNumericLiteral(diagnostics); - } - - if (isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifierOrKeyword(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var slidingWindow = this.slidingWindow; - var window = slidingWindow.window; - - var startIndex = slidingWindow.currentRelativeItemIndex; - var endIndex = slidingWindow.windowCount; - var currentIndex = startIndex; - var character = 0; - - while (currentIndex < endIndex) { - character = window[currentIndex]; - if (!isIdentifierPartCharacter[character]) { - break; - } - - currentIndex++; - } - - if (currentIndex === endIndex) { - return 0 /* None */; - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - return 0 /* None */; - } else { - var kind; - var identifierLength = currentIndex - startIndex; - if (isKeywordStartCharacter[firstCharacter]) { - kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); - } else { - kind = 11 /* IdentifierName */; - } - - slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); - - return kind; - } - }; - - Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - var sawUnicodeEscape = false; - - do { - var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); - sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - var length = this.slidingWindow.absoluteIndex() - startIndex; - var text = this.text.substr(startIndex, length, false); - var valueText = TypeScript.Syntax.massageEscapes(text); - - var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); - if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { - if (sawUnicodeEscape) { - return keywordKind | -2147483648 /* IsVariableWidthKeyword */; - } else { - return keywordKind; - } - } - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function (diagnostics) { - if (this.isHexNumericLiteral()) { - this.scanHexNumericLiteral(); - } else if (this.isOctalNumericLiteral()) { - this.scanOctalNumericLiteral(diagnostics); - } else { - this.scanDecimalNumericLiteral(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isOctalNumericLiteral = function () { - return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); - }; - - Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { - var position = this.absoluteIndex(); - - while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.languageVersion() >= 1 /* EcmaScript5 */) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); - } - }; - - Scanner.prototype.scanDecimalDigits = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - this.scanDecimalDigits(); - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - this.scanDecimalDigits(); - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - var nextChar1 = this.slidingWindow.peekItemN(1); - - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { - var nextChar2 = this.slidingWindow.peekItemN(2); - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } - } - } - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 82 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* LessThanLessThanEqualsToken */; - } else { - return 95 /* LessThanLessThanToken */; - } - } else { - return 80 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 104 /* BarBarToken */; - } else { - return 99 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* CaretEqualsToken */; - } else { - return 100 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 115 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 103 /* AmpersandAmpersandToken */; - } else { - return 98 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* PercentEqualsToken */; - } else { - return 92 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* MinusMinusToken */; - } else { - return 90 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 108 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 93 /* PlusPlusToken */; - } else { - return 89 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* AsteriskEqualsToken */; - } else { - return 91 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 87 /* EqualsEqualsEqualsToken */; - } else { - return 84 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 85 /* EqualsGreaterThanToken */; - } else { - return 107 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function (diagnostics) { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(diagnostics); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 77 /* DotDotDotToken */; - } else { - return 76 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 119 /* SlashEqualsToken */; - } else { - return 118 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 12 /* RegularExpressionLiteral */; - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* ExclamationEqualsEqualsToken */; - } else { - return 86 /* ExclamationEqualsToken */; - } - } else { - return 101 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - break; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - break; - - default: - break; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - this.scanUnicodeOrHexEscape(errors); - return true; - } - } - - this.slidingWindow.moveToNextItem(); - return false; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); - var errors = new Array(); - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 121 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 124 /* ArrayType */: - return parent.type === nodeOrToken; - case 220 /* CastExpression */: - return parent.type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - case 228 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return TypeScript.Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullEnd; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullEnd = positionedToken.fullEnd(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullEnd) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); - } - - fullEnd -= triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function findSkippedTokenOnLeft(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - - function isIntegerLiteral(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - Syntax.isIntegerLiteral = isIntegerLiteral; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - 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.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - 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.memberFunctionDeclaration = function (modifiers, propertyName, callSignature, block, semicolonToken) { - return new TypeScript.MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = new Array(); - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return nodeOrToken.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - element.insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - element.insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - var firstToken = this.firstToken(); - return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.trailingTrivia = function () { - var lastToken = this.lastToken(); - return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - result.parsedInStrictMode = true; - } - - 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]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - var start = positionedToken.start(); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isExpression = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.requireKeyword = requireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.requireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { - return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { - return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.importKeyword; - case 2: - return this.identifier; - case 3: - return this.equalsToken; - case 4: - return this.moduleReference; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - - this._kind = kind; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.kind = function () { - return this._kind; - }; - - HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { - if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.name = name; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.name; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withName = function (name) { - return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { - if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.callSignature = callSignature; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 123 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeQuerySyntax = (function (_super) { - __extends(TypeQuerySyntax, _super); - function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.name = name; - } - TypeQuerySyntax.prototype.accept = function (visitor) { - return visitor.visitTypeQuery(this); - }; - - TypeQuerySyntax.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuerySyntax.prototype.childCount = function () { - return 2; - }; - - TypeQuerySyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeQuerySyntax.prototype.isType = function () { - return true; - }; - - TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { - if (this.typeOfKeyword === typeOfKeyword && this.name === name) { - return this; - } - - return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); - }; - - TypeQuerySyntax.create1 = function (name) { - return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); - }; - - TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.name); - }; - - TypeQuerySyntax.prototype.withName = function (name) { - return this.update(this.typeOfKeyword, name); - }; - - TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeQuerySyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeQuerySyntax = TypeQuerySyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 146 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.modifiers; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifiers = function (modifiers) { - return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.arguments = arguments; - this.closeParenToken = closeParenToken; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 142 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 227 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 239 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.constructorKeyword = constructorKeyword; - this.parameterList = parameterList; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.constructorKeyword; - case 2: - return this.parameterList; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - 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) { - return this; - } - - return new ConstructorDeclarationSyntax(modifiers, constructorKeyword, parameterList, block, semicolonToken, this.parsedInStrictMode()); - }; - - ConstructorDeclarationSyntax.create = function (constructorKeyword, parameterList) { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, constructorKeyword, parameterList, null, null, false); - }; - - ConstructorDeclarationSyntax.create1 = function () { - return new ConstructorDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(62 /* ConstructorKeyword */), ParameterListSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.constructorKeyword, parameterList, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.parameterList, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var GetAccessorSyntax = (function (_super) { - __extends(GetAccessorSyntax, _super); - function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.getKeyword = getKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - } - GetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessor(this); - }; - - GetAccessorSyntax.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - - GetAccessorSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - GetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - GetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetAccessorSyntax.create1 = function (propertyName) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GetAccessorSyntax = GetAccessorSyntax; - - var SetAccessorSyntax = (function (_super) { - __extends(SetAccessorSyntax, _super); - function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.setKeyword = setKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - SetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessor(this); - }; - - SetAccessorSyntax.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - - SetAccessorSyntax.prototype.childCount = function () { - return 5; - }; - - SetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - SetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetAccessorSyntax.create1 = function (propertyName) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SetAccessorSyntax = SetAccessorSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var IndexMemberDeclarationSyntax = (function (_super) { - __extends(IndexMemberDeclarationSyntax, _super); - function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.indexSignature = indexSignature; - this.semicolonToken = semicolonToken; - } - IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexMemberDeclaration(this); - }; - - IndexMemberDeclarationSyntax.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - - IndexMemberDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.indexSignature; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexMemberDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { - if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { - return this; - } - - return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); - }; - - IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); - }; - - IndexMemberDeclarationSyntax.create1 = function (indexSignature) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { - return this.update(this.modifiers, indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.indexSignature, semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexMemberDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - this.colonToken = colonToken; - this.statements = statements; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - this.colonToken = colonToken; - this.statements = statements; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.doKeyword = doKeyword; - this.statement = statement; - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeQuery = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - 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)); - }; - - SyntaxRewriter.prototype.visitMemberFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var dedentThisTrivia = dedentNextWhitespace; - dedentNextWhitespace = false; - - if (dedentThisTrivia) { - if (trivia.kind() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - var indentNextTrivia = true; - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var indentThisTrivia = indentNextTrivia; - indentNextTrivia = false; - - switch (trivia.kind()) { - case 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(sourceText, fullStart, kind, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._textOrWidth = textOrWidth; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._sourceText, this._fullStart, this.tokenKind, this._textOrWidth); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, textOrWidth, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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; - }; - - 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; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._sourceText.substr(this._fullStart, this.fullWidth(), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.width(); - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(sourceText, fullStart, kind, leadingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width(); - }; - 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); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(sourceText, fullStart, kind, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._sourceText, this._fullStart, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - function FixedWidthTokenWithLeadingAndTrailingTrivia(sourceText, fullStart, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._sourceText = sourceText; - this._fullStart = fullStart; - 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); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo) + this.width() + getTriviaWidth(this._trailingTriviaInfo); - }; - 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); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this._fullStart, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(this._sourceText, this.end(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - 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 */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function isExpression(token) { - switch (token.tokenKind) { - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - return true; - } - - return false; - } - Syntax.isExpression = isExpression; - - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - case 13 /* carriageReturn */: - var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) == 10 /* lineFeed */) { - i++; - } - continue; - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - Syntax.massageEscapes = massageEscapes; - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - return regularExpressionValue(text); - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function regularExpressionValue(text) { - try { - var lastSlash = text.lastIndexOf("/"); - var body = text.substring(1, lastSlash); - var flags = text.substring(lastSlash + 1); - return new RegExp(body, flags); - } catch (e) { - return null; - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - EmptyToken.prototype.isExpression = function () { - return isExpression(this); - }; - - EmptyToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - - RealizedToken.prototype.isExpression = function () { - return isExpression(this); - }; - - RealizedToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var AbstractTrivia = (function () { - function AbstractTrivia(_kind) { - this._kind = _kind; - } - AbstractTrivia.prototype.fullWidth = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.fullText = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.toJSON = function (key) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === this._kind) { - result.kind = name; - break; - } - } - - if (this.isSkippedToken()) { - result.skippedToken = this.skippedToken(); - } else { - result.text = this.fullText(); - } - return result; - }; - - AbstractTrivia.prototype.kind = function () { - return this._kind; - }; - - AbstractTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - AbstractTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - AbstractTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - AbstractTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - AbstractTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return AbstractTrivia; - })(); - - var NormalTrivia = (function (_super) { - __extends(NormalTrivia, _super); - function NormalTrivia(kind, _text) { - _super.call(this, kind); - this._text = _text; - } - NormalTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - NormalTrivia.prototype.fullText = function () { - return this._text; - }; - - NormalTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return NormalTrivia; - })(AbstractTrivia); - - var SkippedTokenTrivia = (function (_super) { - __extends(SkippedTokenTrivia, _super); - function SkippedTokenTrivia(_skippedToken) { - _super.call(this, 8 /* SkippedTokenTrivia */); - this._skippedToken = _skippedToken; - } - SkippedTokenTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SkippedTokenTrivia.prototype.fullText = function () { - return this.skippedToken().fullText(); - }; - - SkippedTokenTrivia.prototype.skippedToken = function () { - return this._skippedToken; - }; - return SkippedTokenTrivia; - })(AbstractTrivia); - - var DeferredTrivia = (function (_super) { - __extends(DeferredTrivia, _super); - function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { - _super.call(this, kind); - this._text = _text; - this._fullStart = _fullStart; - this._fullWidth = _fullWidth; - this._fullText = null; - } - DeferredTrivia.prototype.fullWidth = function () { - return this._fullWidth; - }; - - DeferredTrivia.prototype.fullText = function () { - if (!this._fullText) { - this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); - this._text = null; - } - - return this._fullText; - }; - - DeferredTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return DeferredTrivia; - })(AbstractTrivia); - - function deferredTrivia(kind, text, fullStart, fullWidth) { - return new DeferredTrivia(kind, text, fullStart, fullWidth); - } - Syntax.deferredTrivia = deferredTrivia; - - function trivia(kind, text) { - return new NormalTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SkippedTokenTrivia(token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - this.trivia[i].collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 228 /* TypeArgumentList */: - case 229 /* TypeParameterList */: - case 220 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - return SyntaxUtilities.getExportKeyword(moduleElement) !== null; - }; - - SyntaxUtilities.getExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - case 133 /* ImportDeclaration */: - return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); - default: - return null; - } - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeQuery = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.requireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.name); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeQuery = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.name); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitList(node.modifiers); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.constructorKeyword); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.indexSignature); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - - - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeArgumentList_Types] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - var result = this.currentToken(); - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - - return result; - }; - return SyntaxCursor; - })(); - - - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); - } - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { - this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 69 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return this.eatToken(78 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); - } - - return semicolonToken; - } - - return this.eatToken(78 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= 15 /* FirstKeyword */) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 173 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 186 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 187 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 188 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 189 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 191 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 167 /* LogicalNotExpression */: - case 170 /* DeleteExpression */: - case 171 /* TypeOfExpression */: - case 172 /* VoidExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); - } - } - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - var modifierCount = this.modifierCount(); - return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - var modifierCount = this.modifierCount(); - if (this.isImportDeclaration(modifierCount)) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration(modifierCount)) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration(modifierCount)) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration(modifierCount)) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration(modifierCount)) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(inErrorRecovery)) { - return this.parseStatement(inErrorRecovery); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var modifiers = this.parseModifiers(); - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 80 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - - return typeArgumentList; - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 72 /* OpenParenToken */: - case 76 /* DotToken */: - - case 73 /* CloseParenToken */: - case 75 /* CloseBracketToken */: - case 106 /* ColonToken */: - case 78 /* SemicolonToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - case 84 /* EqualsEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: - case 103 /* AmpersandAmpersandToken */: - case 104 /* BarBarToken */: - case 100 /* CaretToken */: - case 98 /* AmpersandToken */: - case 99 /* BarToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { - var dotToken = this.eatToken(76 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 63 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isAccessor = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 64 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var getKeyword = this.eatKeyword(64 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var setKeyword = this.eatKeyword(68 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(false); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexMemberDeclaration()) { - return this.parseIndexMemberDeclaration(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */ && this.peekToken(index + 1).tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var modifiers = this.parseModifiers(); - var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var parameterList = this.parseParameterList(); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(modifiers, constructorKeyword, parameterList, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 78 /* SemicolonToken */: - case 107 /* EqualsToken */: - case 106 /* ColonToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.isIndexMemberDeclaration = function () { - var index = this.modifierCount(); - return this.isIndexSignature(index); - }; - - ParserImpl.prototype.parseIndexMemberDeclaration = function () { - var modifiers = this.parseModifiers(); - var indexSignature = this.parseIndexSignature(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - if (callSignature.lastToken()) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature(0)) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(inErrorRecovery)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(inErrorRecovery)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function (tokenIndex) { - return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isIdentifier(this.currentToken())) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - - break; - - case 28 /* IfKeyword */: - case 70 /* OpenBraceToken */: - case 33 /* ReturnKeyword */: - case 34 /* SwitchKeyword */: - case 36 /* ThrowKeyword */: - case 15 /* BreakKeyword */: - case 18 /* ContinueKeyword */: - case 26 /* ForKeyword */: - case 42 /* WhileKeyword */: - case 43 /* WithKeyword */: - case 22 /* DoKeyword */: - case 38 /* TryKeyword */: - case 19 /* DebuggerKeyword */: - return true; - } - - if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { - return false; - } - - return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); - }; - - ParserImpl.prototype.parseStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 28 /* IfKeyword */: - return this.parseIfStatement(); - case 70 /* OpenBraceToken */: - return this.parseBlock(false, false); - case 33 /* ReturnKeyword */: - return this.parseReturnStatement(); - case 34 /* SwitchKeyword */: - return this.parseSwitchStatement(); - case 36 /* ThrowKeyword */: - return this.parseThrowStatement(); - case 15 /* BreakKeyword */: - return this.parseBreakStatement(); - case 18 /* ContinueKeyword */: - return this.parseContinueStatement(); - case 26 /* ForKeyword */: - return this.parseForOrForInStatement(); - case 42 /* WhileKeyword */: - return this.parseWhileStatement(); - case 43 /* WithKeyword */: - return this.parseWithStatement(); - case 22 /* DoKeyword */: - return this.parseDoStatement(); - case 38 /* TryKeyword */: - return this.parseTryStatement(); - case 19 /* DebuggerKeyword */: - return this.parseDebuggerStatement(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement(currentToken)) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { - return this.parseEmptyStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(false); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function (currentToken) { - return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(106 /* ColonToken */); - var statement = this.parseStatement(false); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return currentToken.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(78 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { - return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function (currentToken) { - var kind = currentToken.tokenKind; - if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 79 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function (currentToken) { - switch (currentToken.tokenKind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - - case 74 /* OpenBracketToken */: - - case 72 /* OpenParenToken */: - - case 80 /* LessThanToken */: - - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - - case 70 /* OpenBraceToken */: - - case 85 /* EqualsGreaterThanToken */: - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - - case 31 /* NewKeyword */: - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - - case 27 /* FunctionKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(false); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 225 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(token0); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(107 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpressionOrLower = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpressionOrLower(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeOfExpression(); - } else if (currentTokenKind === 41 /* VoidKeyword */) { - return this.parseVoidExpression(); - } else if (currentTokenKind === 21 /* DeleteKeyword */) { - return this.parseDeleteExpression(); - } else if (currentTokenKind === 80 /* LessThanToken */) { - return this.parseCastExpression(); - } else { - return this.parsePostfixExpressionOrLower(); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - if (precedence <= 2 /* AssignmentExpressionPrecedence */) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } - - var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); - if (parethesizedArrowFunction !== null) { - return parethesizedArrowFunction; - } - } - - var leftOperand = this.parseUnaryExpressionOrLower(); - return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(105 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(106 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 81 /* GreaterThanToken */) { - if (storage[1] === 81 /* GreaterThanToken */) { - if (storage[2] === 107 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 107 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 107 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } - - var expression = this.parsePrimaryExpression(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - return this.parseMemberExpressionRest(expression, false, inObjectCreation); - }; - - ParserImpl.prototype.parseCallExpressionOrLower = function () { - var expression; - if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { - expression = this.eatKeyword(50 /* SuperKeyword */); - - var currentTokenKind = this.currentToken().tokenKind; - if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - } - } else { - expression = this.parseMemberExpressionOrLower(false); - } - - return this.parseMemberExpressionRest(expression, true, false); - }; - - ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 72 /* OpenParenToken */: - if (!allowArguments) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 80 /* LessThanToken */: - if (!allowArguments) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 74 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 76 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseCallExpressionOrLower(); - } - }; - - ParserImpl.prototype.parsePostfixExpressionOrLower = function () { - var expression = this.parseLeftHandSideExpressionOrLower(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - } - - return expression; - }; - - ParserImpl.prototype.tryParseGenericArgumentList = function () { - var rewindPoint = this.getRewindPoint(); - - var typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; - var isDot = token0.tokenKind === 76 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - - var argumentList = null; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - - if (isDot) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); - } else { - return this.parseArgumentList(typeArgumentList); - } - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - if (this.currentToken().tokenKind === 80 /* LessThanToken */) { - return this.tryParseGenericArgumentList(); - } - - if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { - return this.parseArgumentList(null); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var _arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - _arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parsePrimaryExpression = function () { - var currentToken = this.currentToken(); - - if (this.isIdentifier(currentToken)) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 74 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 70 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 72 /* OpenParenToken */: - return this.parseParenthesizedExpression(); - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 75 /* CloseBracketToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseObjectCreationExpressionOrLower(true); - var argumentList = this.tryParseArgumentList(); - - var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); - return this.parseMemberExpressionRest(result, true, false); - }; - - ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseMemberExpressionOrLower(inObjectCreation); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(80 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedExpression = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { - return null; - } - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - - this.releaseRewindPoint(rewindPoint); - return arrowFunction; - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.tryParseArrowFunctionBlock = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { - return this.parseBlock(true, false); - } else { - return null; - } - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 70 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 73 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; - } - - if (token1.tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - token2 = this.peekToken(2); - if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { - if (this.isIdentifier(token2)) { - return true; - } - } - - if (!this.isIdentifier(token1)) { - return false; - } - - if (token2.tokenKind === 106 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 105 /* QuestionToken */) { - if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 79 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 106 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { - if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(true); - } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(106 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - return this.eatKeyword(35 /* ThisKeyword */); - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var lessThanToken = this.eatToken(80 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameters = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); - - return typeParameterList; - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(106 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 39 /* TypeOfKeyword */: - - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - - case 70 /* OpenBraceToken */: - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - - case 31 /* NewKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseType = function () { - 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 */) { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.isTypeQuery = function () { - return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; - }; - - ParserImpl.prototype.parseTypeQuery = function () { - var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); - var name = this.parseName(); - - return this.factory.typeQuery(typeOfKeyword, name); - }; - - ParserImpl.prototype.parseNonArrayType = function (currentToken) { - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - return this.eatAnyToken(); - - case 70 /* OpenBraceToken */: - return this.parseObjectType(); - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - return this.parseFunctionType(); - - case 31 /* NewKeyword */: - return this.parseConstructorType(); - } - - return this.parseNameOrGenericType(); - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - var tokenKind = token.tokenKind; - if (tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { - if (this.isIdentifier(token)) { - var nextTokenKind = this.peekToken(1).tokenKind; - switch (nextTokenKind) { - case 73 /* CloseParenToken */: - case 106 /* ColonToken */: - case 107 /* EqualsToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); - - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { - modifierArray.push(this.eatAnyToken()); - continue; - } - - break; - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - for (var state = 262144 /* LastListParsingState */; state >= 1 /* FirstListParsingState */; state >>= 1) { - if ((this.listParsingState & state) !== 0) { - if (this.isExpectedListTerminator(state) || this.isExpectedListItem(state, true)) { - return true; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType, inErrorRecovery); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 79 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 78 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 75 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 70 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 79 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - var currentToken = this.currentToken(); - if (this.isExpression(currentToken)) { - return true; - } - - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.parseStatement(inErrorRecovery); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(inErrorRecovery); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); - - case 16 /* SwitchClause_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 32 /* Block_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); - - case 131072 /* ParameterList_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, options) { - var source = new NormalParserSource(fileName, text, options.languageVersion()); - - return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.inObjectLiteralExpression = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { - return true; - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { - if (parameter.modifiers.childCount() > 0) { - var modifiers = parameter.modifiers; - var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - - if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { - if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); - return true; - } else { - if (modifierIndex > 0) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - 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) { - 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); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); - return true; - } else if (parameter.modifiers.childCount() > 0) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - if (lastElement && inFunctionOverloadChain) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - } else { - inFunctionOverloadChain = false; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var isInStaticOverloadChain = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - var isStaticOverload = null; - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - 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 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; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - 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; - } - } else if (classElement.kind() === 137 /* ConstructorDeclaration */) { - var constructorDeclaration = classElement; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 121 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "boolean": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { - var getKeywordFullStart = this.childFullStart(node, getKeyword); - if (parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { - if (this.checkIndexMemberModifiers(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIndexMemberDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { - if (node.modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(node, node.modifiers); - this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { - if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { - var savedInObjectLiteralExpression = this.inObjectLiteralExpression; - this.inObjectLiteralExpression = true; - _super.prototype.visitObjectLiteralExpression.call(this, node); - this.inObjectLiteralExpression = savedInObjectLiteralExpression; - }; - - GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { - var setKeywordFullStart = this.childFullStart(node, setKeyword); - if (parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); - return true; - } - - var parameterListFullStart = this.childFullStart(node, parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); - var parameter = parameterList.parameters.childAt(0); - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - var seenComputedValue = 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) { - 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; - } - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitEnumElement = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - var expression = node.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(expression)) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); - this.skip(node); - return; - } - } - - _super.prototype.visitEnumElement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (node.stringLiteral === null) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); - } - } - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); - return true; - } - }; - - GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitImportDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); - this.skip(node); - return; - } - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForInStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock || this.inObjectLiteralExpression) { - if (modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclarator.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { - var currentElementFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var child = modifiers.childAt(i); - if (child.kind() !== 57 /* PublicKeyword */) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); - return true; - } - - currentElementFullStart += child.fullWidth(); - } - - 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); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { - this._compiler = _compiler; - this._semanticInfoChain = _semanticInfoChain; - this.fileName = fileName; - this.referencedFiles = referencedFiles; - this._scriptSnapshot = _scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._syntaxTree = _syntaxTree; - this._topLevelDecl = _topLevelDecl; - this._diagnostics = null; - this._bloomFilter = null; - this._sourceUnit = null; - this._lineMap = null; - this._declASTMap = []; - this._astDeclMap = []; - this._isExternalModule = undefined; - this._amdDependencies = undefined; - } - Document.prototype.invalidate = function () { - this._declASTMap.length = 0; - this._astDeclMap.length = 0; - this._topLevelDecl = null; - - this._syntaxTree = null; - this._sourceUnit = null; - this._diagnostics = null; - this._bloomFilter = null; - }; - - Document.prototype.isDeclareFile = function () { - return TypeScript.isDTSFile(this.fileName); - }; - - Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { - var start = new Date().getTime(); - this._diagnostics = syntaxTree.diagnostics(); - TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; - - this._lineMap = syntaxTree.lineMap(); - - var sourceUnit = syntaxTree.sourceUnit(); - var leadingComments = this.getLeadingComments(sourceUnit); - - this._isExternalModule = this.hasImplicitImport(leadingComments) || this.hasTopLevelImportOrExport(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); - } - } - } - - return result; - }; - - Document.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(comment); - - if (match) { - return true; - } - - return false; - }; - - Document.prototype.hasTopLevelImportOrExport = function (node) { - var firstToken; - - 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; - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return true; - } - } - } - - return false; - }; - - Document.prototype.sourceUnit = function () { - if (!this._sourceUnit) { - var start = new Date().getTime(); - var syntaxTree = this.syntaxTree(); - this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); - TypeScript.astTranslationTime += new Date().getTime() - start; - - if (!this.isOpen) { - this._syntaxTree = null; - } - } - - return this._sourceUnit; - }; - - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._diagnostics); - } - - return this._diagnostics; - }; - - Document.prototype.lineMap = function () { - if (this._lineMap === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._lineMap); - } - - return this._lineMap; - }; - - Document.prototype.isExternalModule = function () { - if (this._isExternalModule === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._isExternalModule !== undefined); - } - - return this._isExternalModule; - }; - - Document.prototype.amdDependencies = function () { - if (this._amdDependencies === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._amdDependencies !== undefined); - } - - return this._amdDependencies; - }; - - Document.prototype.syntaxTree = function () { - var result = this._syntaxTree; - if (!result) { - var start = new Date().getTime(); - - result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); - - TypeScript.syntaxTreeParseTime += new Date().getTime() - start; - - if (this.isOpen || !this._sourceUnit) { - this._syntaxTree = result; - } - } - - this.cacheSyntaxTreeInfo(result); - return result; - }; - - Document.prototype.bloomFilter = function () { - if (!this._bloomFilter) { - var identifiers = TypeScript.createIntrinsicsObject(); - var pre = function (cur) { - if (TypeScript.isValidAstNode(cur)) { - if (cur.kind() === 11 /* IdentifierName */) { - var nodeText = cur.valueText(); - - identifiers[nodeText] = true; - } - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); - - var identifierCount = 0; - for (var name in identifiers) { - if (identifiers[name]) { - identifierCount++; - } - } - - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - } - return this._bloomFilter; - }; - - Document.prototype.emitToOwnOutputFile = function () { - return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { - var oldSyntaxTree = this._syntaxTree; - - if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { - var oldText = this._scriptSnapshot; - var newText = scriptSnapshot; - - TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); - var newTextPrefix = newText.getText(0, textChangeRange.span().start()); - TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); - - var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); - var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); - TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); - }; - - Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); - }; - - Document.prototype.topLevelDecl = function () { - if (this._topLevelDecl === null) { - this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); - } - - return this._topLevelDecl; - }; - - Document.prototype._getDeclForAST = function (ast) { - this.topLevelDecl(); - return this._astDeclMap[ast.syntaxID()]; - }; - - Document.prototype.getEnclosingDecl = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - return this._getDeclForAST(ast); - } - - ast = ast.parent; - var decl = null; - while (ast) { - decl = this._getDeclForAST(ast); - - if (decl) { - break; - } - - ast = ast.parent; - } - - return decl._getEnclosingDeclFromParentDecl(); - }; - - Document.prototype._setDeclForAST = function (ast, decl) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._astDeclMap[ast.syntaxID()] = decl; - }; - - Document.prototype._getASTForDecl = function (decl) { - return this._declASTMap[decl.declID]; - }; - - Document.prototype._setASTForDecl = function (decl, ast) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._declASTMap[decl.declID] = ast; - }; - return Document; - })(); - TypeScript.Document = Document; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var proto = "__proto__"; - - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - - this[proto] = null; - this[proto] = undefined; - } - return BlockIntrinsics; - })(); - - function createIntrinsicsObject() { - return new BlockIntrinsics(); - } - TypeScript.createIntrinsicsObject = createIntrinsicsObject; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = createIntrinsicsObject(); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (!fn(k, this.table[k], context)) { - return false; - } - } - } - - return true; - }; - - StringHashTable.prototype.some = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (fn(k, this.table[k], context)) { - return true; - } - } - } - - return false; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - - StringHashTable.prototype.remove = function (key) { - if (this.table[key] !== undefined) { - this.table[key] = undefined; - this.itemCount--; - } - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(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 moduleIsElided(declaration) { - return TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) || moduleMembersAreElided(declaration.moduleElements); - } - TypeScript.moduleIsElided = moduleIsElided; - - 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)) { - 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; - } - } - - return importSymbol.isUsedAsValue(); - } - - return false; - } - TypeScript.importDeclarationIsElided = importDeclarationIsElided; - - function isValidAstNode(ast) { - if (!ast) - return false; - - if (ast.start() === -1 || ast.end() === -1) - return false; - - 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; - - 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(); - - 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); - } - } - }; - - TypeScript.getAstWalkerFactory().walk(script, pre); - return top; - } - TypeScript.getAstAtPosition = getAstAtPosition; - - function getExtendsHeritageClause(clauses) { - if (!clauses) { - return null; - } - - return clauses.firstOrDefault(function (c) { - return c.typeNames.nonSeparatorCount() > 0 && c.kind() === 230 /* ExtendsHeritageClause */; - }); - } - TypeScript.getExtendsHeritageClause = getExtendsHeritageClause; - - function getImplementsHeritageClause(clauses) { - if (!clauses) { - return null; - } - - 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; - - 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; - } - } - - return false; - } - TypeScript.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { - return false; - } - if (ast.kind() !== 11 /* IdentifierName */) { - return false; - } - - 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) { - return { - length: 1, - lastParameterIsRest: function () { - return false; - }, - ast: id, - astAt: function (index) { - return id; - }, - identifierAt: function (index) { - return id; - }, - typeAt: function (index) { - return null; - }, - initializerAt: function (index) { - return null; - }, - isOptionalAt: function (index) { - return false; - } - }; - } - Parameters.fromIdentifier = fromIdentifier; - - function fromParameter(parameter) { - return { - length: 1, - lastParameterIsRest: function () { - return parameter.dotDotDotToken !== null; - }, - ast: parameter, - astAt: function (index) { - return parameter; - }, - identifierAt: function (index) { - return parameter.identifier; - }, - typeAt: function (index) { - return TypeScript.getType(parameter); - }, - initializerAt: function (index) { - return parameter.equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(parameter); - } - }; - } - Parameters.fromParameter = fromParameter; - - function parameterIsOptional(parameter) { - return parameter.questionToken !== null || parameter.equalsValueClause !== null; - } - - function fromParameterList(list) { - return { - length: list.parameters.nonSeparatorCount(), - lastParameterIsRest: function () { - return TypeScript.lastParameterIsRest(list); - }, - ast: list.parameters, - astAt: function (index) { - return list.parameters.nonSeparatorAt(index); - }, - identifierAt: function (index) { - return list.parameters.nonSeparatorAt(index).identifier; - }, - typeAt: function (index) { - return TypeScript.getType(list.parameters.nonSeparatorAt(index)); - }, - initializerAt: function (index) { - return list.parameters.nonSeparatorAt(index).equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(list.parameters.nonSeparatorAt(index)); - } - }; - } - Parameters.fromParameterList = fromParameterList; - })(TypeScript.Parameters || (TypeScript.Parameters = {})); - var Parameters = TypeScript.Parameters; - - 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; - } - } - TypeScript.isDeclarationAST = isDeclarationAST; - - 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; - } - - break; - } - - 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; - } - - 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); - - return nameIndex === (moduleNames.length - 1); - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function walkListChildren(preAst, walker) { - for (var i = 0, n = preAst.childCount(); i < n; i++) { - walker.walk(preAst.childAt(i)); - } - } - - function walkThrowStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkPrefixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkPostfixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkDeleteExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkTypeArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArguments); - } - - function walkTypeOfExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkVoidExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArgumentList); - walker.walk(preAst.arguments); - } - - function walkArrayLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.expressions); - } - - function walkSimplePropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.expression); - } - - function walkFunctionPropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkGetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkSeparatedListChildren(preAst, walker) { - for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { - walker.walk(preAst.nonSeparatorAt(i)); - } - } - - function walkSetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkObjectLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.propertyAssignments); - } - - function walkCastExpressionChildren(preAst, walker) { - walker.walk(preAst.type); - walker.walk(preAst.expression); - } - - function walkParenthesizedExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkElementAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentExpression); - } - - function walkMemberAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.name); - } - - function walkQualifiedNameChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkBinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkEqualsValueClauseChildren(preAst, walker) { - walker.walk(preAst.value); - } - - function walkTypeParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.constraint); - } - - function walkTypeParameterListChildren(preAst, walker) { - walker.walk(preAst.typeParameters); - } - - function walkGenericTypeChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.typeArgumentList); - } - - function walkTypeAnnotationChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkTypeQueryChildren(preAst, walker) { - walker.walk(preAst.name); - } - - function walkInvocationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkObjectCreationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkTrinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.whenTrue); - walker.walk(preAst.whenFalse); - } - - function walkFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFunctionTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkMemberFunctionDeclarationChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFuncDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkIndexMemberDeclarationChildren(preAst, walker) { - walker.walk(preAst.indexSignature); - } - - function walkIndexSignatureChildren(preAst, walker) { - walker.walk(preAst.parameter); - walker.walk(preAst.typeAnnotation); - } - - function walkCallSignatureChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - } - - function walkConstraintChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkConstructorTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkConstructSignatureChildren(preAst, walker) { - walker.walk(preAst.callSignature); - } - - function walkParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkParameterListChildren(preAst, walker) { - walker.walk(preAst.parameters); - } - - function walkPropertySignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - } - - function walkVariableDeclaratorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkMemberVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarator); - } - - function walkMethodSignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - } - - function walkReturnStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkForStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.initializer); - walker.walk(preAst.condition); - walker.walk(preAst.incrementor); - walker.walk(preAst.statement); - } - - function walkForInStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.left); - walker.walk(preAst.expression); - walker.walk(preAst.statement); - } - - function walkIfStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - walker.walk(preAst.elseClause); - } - - function walkElseClauseChildren(preAst, walker) { - walker.walk(preAst.statement); - } - - function walkWhileStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkDoStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkBlockChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.declarators); - } - - function walkCaseSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.statements); - } - - function walkDefaultSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkSwitchStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.switchClauses); - } - - function walkTryStatementChildren(preAst, walker) { - walker.walk(preAst.block); - walker.walk(preAst.catchClause); - walker.walk(preAst.finallyClause); - } - - function walkCatchClauseChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkExternalModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.stringLiteral); - } - - function walkFinallyClauseChildren(preAst, walker) { - walker.walk(preAst.block); - } - - function walkClassDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.classElements); - } - - function walkScriptChildren(preAst, walker) { - walker.walk(preAst.moduleElements); - } - - function walkHeritageClauseChildren(preAst, walker) { - walker.walk(preAst.typeNames); - } - - function walkInterfaceDeclerationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.body); - } - - function walkObjectTypeChildren(preAst, walker) { - walker.walk(preAst.typeMembers); - } - - function walkArrayTypeChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkModuleDeclarationChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.stringLiteral); - walker.walk(preAst.moduleElements); - } - - function walkModuleNameModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.moduleName); - } - - function walkEnumDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.enumElements); - } - - function walkEnumElementChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.equalsValueClause); - } - - function walkImportDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.moduleReference); - } - - function walkExportAssignmentChildren(preAst, walker) { - walker.walk(preAst.identifier); - } - - function walkWithStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkExpressionStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkLabeledStatementChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.statement); - } - - function walkVariableStatementChildren(preAst, walker) { - walker.walk(preAst.declaration); - } - - var childrenWalkers = new Array(246 /* Last */ + 1); - - for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { - childrenWalkers[i] = null; - } - for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { - childrenWalkers[i] = null; - } - - childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; - childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[60 /* AnyKeyword */] = null; - childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; - childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; - childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; - childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; - childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; - childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[146 /* Block */] = walkBlockChildren; - childrenWalkers[61 /* BooleanKeyword */] = null; - childrenWalkers[152 /* BreakStatement */] = null; - childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; - childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; - childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; - childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; - childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; - childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; - childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; - childrenWalkers[239 /* Constraint */] = walkConstraintChildren; - childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; - childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; - childrenWalkers[153 /* ContinueStatement */] = null; - childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; - childrenWalkers[162 /* DebuggerStatement */] = null; - childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; - childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; - childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; - childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; - childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; - childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; - childrenWalkers[156 /* EmptyStatement */] = null; - childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; - childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; - childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; - childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; - childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; - childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; - childrenWalkers[24 /* FalseKeyword */] = null; - childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; - childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; - childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; - childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; - childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; - childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; - childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; - childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; - childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; - childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; - childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; - childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; - childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; - childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; - childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; - childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; - childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; - childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; - childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[1 /* List */] = walkListChildren; - childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; - childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; - childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; - childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; - childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; - childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; - childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; - childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; - childrenWalkers[11 /* IdentifierName */] = null; - childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[0 /* None */] = null; - childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[32 /* NullKeyword */] = null; - childrenWalkers[67 /* NumberKeyword */] = null; - childrenWalkers[13 /* NumericLiteral */] = null; - childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; - childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; - childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; - childrenWalkers[223 /* OmittedExpression */] = null; - childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[242 /* Parameter */] = walkParameterChildren; - childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; - childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; - childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; - childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; - childrenWalkers[12 /* RegularExpressionLiteral */] = null; - childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; - childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; - childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; - childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; - childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; - childrenWalkers[14 /* StringLiteral */] = null; - childrenWalkers[69 /* StringKeyword */] = null; - childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; - childrenWalkers[50 /* SuperKeyword */] = null; - childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; - childrenWalkers[35 /* ThisKeyword */] = null; - childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; - childrenWalkers[3 /* TriviaList */] = null; - childrenWalkers[37 /* TrueKeyword */] = null; - childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; - childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; - childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; - childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; - childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; - childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; - childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; - childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; - childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; - childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; - childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; - childrenWalkers[41 /* VoidKeyword */] = null; - childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; - childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; - - for (var e in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { - TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); - } - } - - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - this.stopWalking = false; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var SimplePreAstWalker = (function () { - function SimplePreAstWalker(pre, state) { - this.pre = pre; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePreAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - }; - return SimplePreAstWalker; - })(); - - var SimplePrePostAstWalker = (function () { - function SimplePrePostAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePrePostAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - - this.post(ast, this.state); - }; - return SimplePrePostAstWalker; - })(); - - var NormalAstWalker = (function () { - function NormalAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - NormalAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - if (this.options.stopWalking) { - return; - } - - this.pre(ast, this); - - if (this.options.stopWalking) { - return; - } - - if (this.options.goChildren) { - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - } else { - this.options.goChildren = true; - } - - if (this.post) { - this.post(ast, this); - } - }; - return NormalAstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { - new NormalAstWalker(pre, post, state).walk(ast); - }; - - AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { - if (post) { - new SimplePrePostAstWalker(pre, post, state).walk(ast); - } else { - new SimplePreAstWalker(pre, state).walk(ast); - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory = new AstWalkerFactory(); - - function getAstWalkerFactory() { - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapEntry = (function () { - function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { - this.emittedFile = emittedFile; - this.emittedLine = emittedLine; - this.emittedColumn = emittedColumn; - this.sourceFile = sourceFile; - this.sourceLine = sourceLine; - this.sourceColumn = sourceColumn; - this.sourceName = sourceName; - TypeScript.Debug.assert(isFinite(emittedLine)); - TypeScript.Debug.assert(isFinite(emittedColumn)); - TypeScript.Debug.assert(isFinite(sourceColumn)); - TypeScript.Debug.assert(isFinite(sourceLine)); - } - return SourceMapEntry; - })(); - TypeScript.SourceMapEntry = SourceMapEntry; - - var SourceMapper = (function () { - function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.names = []; - this.mappingLevel = []; - this.tsFilePaths = []; - this.allSourceMappings = []; - this.sourceMapEntries = []; - this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); - this.setNewSourceFile(document, emitOptions); - } - SourceMapper.prototype.getOutputFile = function () { - var result = this.sourceMapOut.getOutputFile(); - result.sourceMapEntries = this.sourceMapEntries; - - return result; - }; - - SourceMapper.prototype.increaseMappingLevel = function (ast) { - this.mappingLevel.push(ast); - }; - - SourceMapper.prototype.decreaseMappingLevel = function (ast) { - TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); - var expectedAst = this.mappingLevel.pop(); - var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; - var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; - TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); - }; - - SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { - var sourceMappings = []; - this.allSourceMappings.push(sourceMappings); - this.currentMappings = [sourceMappings]; - this.currentNameIndex = []; - - this.setNewSourceFilePath(document, emitOptions); - }; - - SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { - var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); - var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; - this.jsFileName = prettyJsFileName; - - if (emitOptions.sourceMapRootDirectory()) { - this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); - if (document.emitToOwnOutputFile()) { - this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); - } - - if (TypeScript.isRelative(this.sourceMapDirectory)) { - this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; - this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); - this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); - } else { - this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; - } - } else { - this.sourceMapPath = prettyMapFileName; - this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); - } - this.sourceRoot = emitOptions.sourceRootDirectory(); - }; - - SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { - var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); - if (emitOptions.sourceRootDirectory()) { - tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); - } else { - tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); - } - this.tsFilePaths.push(tsFilePath); - }; - - SourceMapper.prototype.emitSourceMapping = function () { - var _this = this; - TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { - return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); - }).join(', ')); - - this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); - - var mappingsString = ""; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); - prevSourceIndex = sourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); - prevNameIndex = nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - for (var i = 0; i < sourceMappings.length; i++) { - var sourceMapping = sourceMappings[i]; - recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); - recordSourceMappingSiblings(sourceMapping.childMappings); - recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); - } - }; - - recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); - } - - this.sourceMapOut.Write(JSON.stringify({ - version: 3, - file: this.jsFileName, - sourceRoot: this.sourceRoot, - sources: this.tsFilePaths, - names: this.names, - mappings: mappingsString - })); - - this.sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compiler, resolvePath) { - this.resolvePath = resolvePath; - this._diagnostic = null; - this._settings = null; - this._commonDirectoryPath = ""; - this._sharedOutputFile = ""; - this._sourceRootDirectory = ""; - this._sourceMapRootDirectory = ""; - this._outputDirectory = ""; - 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.mapSourceFiles()) { - if (settings.mapRoot()) { - if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } else { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } else if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } - - this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); - this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); - - if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { - if (settings.outFileOption()) { - this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); - } - - if (settings.outDirOption()) { - this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); - } - - if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { - this.determineCommonDirectoryPath(compiler); - } - } - } - EmitOptions.prototype.diagnostic = function () { - return this._diagnostic; - }; - - EmitOptions.prototype.commonDirectoryPath = function () { - return this._commonDirectoryPath; - }; - EmitOptions.prototype.sharedOutputFile = function () { - return this._sharedOutputFile; - }; - EmitOptions.prototype.sourceRootDirectory = function () { - return this._sourceRootDirectory; - }; - EmitOptions.prototype.sourceMapRootDirectory = function () { - return this._sourceMapRootDirectory; - }; - EmitOptions.prototype.outputDirectory = function () { - return this._outputDirectory; - }; - - EmitOptions.prototype.compilationSettings = function () { - return this._settings; - }; - - EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = compiler.fileNames(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = compiler.getDocument(fileNames[i]); - var sourceUnit = document.sourceUnit(); - - if (!document.isDeclareFile()) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - if (this._outputDirectory || this._sourceRootDirectory || (this._sourceMapRootDirectory && (!this._sharedOutputFile || compiler._isDynamicModuleCompilation()))) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_find_the_common_subdirectory_path_for_the_input_files, null); - return; - } - - return; - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - function lastParameterIsRest(parameterList) { - var parameters = parameterList.parameters; - return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; - } - TypeScript.lastParameterIsRest = lastParameterIsRest; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.inArrowFunction = false; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.declStack = []; - this.exportAssignmentIdentifier = null; - this.inWithBlock = false; - this.document = null; - this.copyrightElement = null; - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setExportAssignmentIdentifier = function (id) { - this.exportAssignmentIdentifier = id; - }; - - Emitter.prototype.getExportAssignmentIdentifier = function () { - return this.exportAssignmentIdentifier; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.shouldEmitImportDeclaration = function (importDeclAST) { - return TypeScript.importDeclarationIsElided(importDeclAST, this.semanticInfoChain, this.emitOptions.compilationSettings()); - }; - - 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 */; - - this.emitComments(importDeclAST, true); - - var importSymbol = importDecl.getSymbol(); - - var parentSymbol = importSymbol.getContainer(); - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; - - var needsPropertyAssignment = false; - var usePropertyAssignmentInsteadOfVarDecl = false; - var moduleNamePrefix; - - 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 */)) { - needsPropertyAssignment = true; - } else { - usePropertyAssignmentInsteadOfVarDecl = true; - } - } - - if (this.emitState.container === 2 /* DynamicModule */) { - moduleNamePrefix = "exports."; - } else { - moduleNamePrefix = this.moduleName + "."; - } - } - - if (isAmdCodeGen && isExternalModuleReference) { - needsPropertyAssignment = true; - } else { - this.recordSourceMappingStart(importDeclAST); - if (usePropertyAssignmentInsteadOfVarDecl) { - this.writeToOutput(moduleNamePrefix); - } else { - this.writeToOutput("var "); - } - this.writeToOutput(importDeclAST.identifier.text() + " = "); - var aliasAST = importDeclAST.moduleReference; - - if (isExternalModuleReference) { - this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); - } else { - this.emitJavascript(aliasAST.moduleName, false); - } - - this.recordSourceMappingEnd(importDeclAST); - this.writeToOutput(";"); - - if (needsPropertyAssignment) { - this.writeLineToOutput(""); - this.emitIndent(); - } - } - - if (needsPropertyAssignment) { - this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); - this.writeToOutput(";"); - } - this.emitComments(importDeclAST, false); - }; - - Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { - this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); - }; - - Emitter.prototype.setSourceMapperNewSourceFile = function (document) { - this.sourceMapper.setNewSourceFile(document, this.emitOptions); - }; - - Emitter.prototype.updateLineAndColumn = function (s) { - var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); - if (lineNumbers.length > 1) { - this.emitState.line += lineNumbers.length - 1; - this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; - } else { - this.emitState.column += s.length; - } - }; - - Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { - this.recordSourceMappingStart(astSpan); - this.writeToOutput(s); - this.recordSourceMappingEnd(astSpan); - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - this.updateLineAndColumn(s); - }; - - Emitter.prototype.writeLineToOutput = function (s, force) { - if (typeof force === "undefined") { force = false; } - if (!force && s === "" && this.emitState.column === 0) { - return; - } - - this.outfile.WriteLine(s); - this.updateLineAndColumn(s); - this.emitState.column = 0; - this.emitState.line++; - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - return this.indenter.getIndent(); - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitComment = function (comment, trailing, first) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var text = getTrimmedTextLines(comment); - var emitColumn = this.emitState.column; - - if (emitColumn === 0) { - this.emitIndent(); - } else if (trailing && first) { - this.writeToOutput(" "); - } - - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingEnd(comment); - this.writeToOutput(" "); - return; - } - } else { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } - - if (!trailing && emitColumn != 0) { - this.emitIndent(); - } - }; - - Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - if (typeof onlyPinnedOrTripleSlashComments === "undefined") { onlyPinnedOrTripleSlashComments = false; } - var _this = this; - if (ast && ast.kind() !== 146 /* Block */) { - if (ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ || ast.parent.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - return; - } - } - - if (pre) { - var preComments = ast.preComments(); - - if (preComments && ast === this.copyrightElement) { - var copyrightComments = this.getCopyrightComments(); - preComments = preComments.slice(copyrightComments.length); - } - - if (onlyPinnedOrTripleSlashComments) { - preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { - return _this.isPinnedOrTripleSlash(c); - }); - } - - this.emitCommentsArray(preComments, false); - } else { - this.emitCommentsArray(ast.postComments(), true); - } - }; - - Emitter.prototype.isPinnedOrTripleSlash = function (comment) { - var fullText = comment.fullText(); - if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { - return true; - } else { - return fullText.indexOf("/*!") === 0; - } - }; - - Emitter.prototype.emitCommentsArray = function (comments, trailing) { - if (!this.emitOptions.compilationSettings().removeComments() && comments) { - for (var i = 0, n = comments.length; i < n; i++) { - this.emitComment(comments[i], trailing, i === 0); - } - } - }; - - Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { - this.recordSourceMappingStart(objectLiteral); - - this.writeToOutput("{"); - this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); - this.writeToOutput("}"); - - this.recordSourceMappingEnd(objectLiteral); - }; - - Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { - this.recordSourceMappingStart(arrayLiteral); - - this.writeToOutput("["); - this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); - this.writeToOutput("]"); - - this.recordSourceMappingEnd(arrayLiteral); - }; - - Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { - this.recordSourceMappingStart(objectCreationExpression); - this.writeToOutput("new "); - var target = objectCreationExpression.expression; - - this.emit(target); - if (objectCreationExpression.argumentList) { - this.recordSourceMappingStart(objectCreationExpression.argumentList); - this.writeToOutput("("); - this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); - this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); - this.recordSourceMappingEnd(objectCreationExpression.argumentList); - } - - this.recordSourceMappingEnd(objectCreationExpression); - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); - if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - if (pullDecl.kind === 67108864 /* EnumMember */) { - return pullDecl; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - var propertyName = dotExpr.name; - var boundDecl = this.getConstantDecl(dotExpr); - if (boundDecl) { - var value = boundDecl.constantValue; - if (value !== null) { - this.recordSourceMappingStart(dotExpr); - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.text(); - comment += " */"; - this.writeToOutput(comment); - this.recordSourceMappingEnd(dotExpr); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitInvocationExpression = function (callNode) { - this.recordSourceMappingStart(callNode); - var target = callNode.expression; - var args = callNode.argumentList.arguments; - - if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { - this.emit(target); - this.writeToOutput(".call"); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitThis(); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - } else { - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - - this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); - this.recordSourceMappingEnd(args); - this.recordSourceMappingEnd(callNode); - }; - - Emitter.prototype.emitParameterList = function (list) { - this.writeToOutput("("); - this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.Parameters.fromParameterList(list)); - this.writeToOutput(")"); - }; - - Emitter.prototype.emitFunctionParameters = function (parameters) { - var argsLen = 0; - - if (parameters) { - this.emitComments(parameters.ast, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = parameters.length; - var printLen = argsLen; - if (parameters.lastParameterIsRest()) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = parameters.astAt(i); - this.emit(arg); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(parameters.ast, false); - } - }; - - Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { - this.writeLineToOutput(" {"); - if (name) { - this.recordSourceMappingNameStart(name); - } - - this.indenter.increaseIndent(); - - if (parameterList) { - this.emitDefaultValueAssignments(parameterList); - this.emitRestParameterInitializer(parameterList); - } - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - if (block) { - this.emitList(block.statements); - this.emitCommentsArray(block.closeBraceLeadingComments, false); - } else { - this.emitIndent(); - this.emitCommentsArray(bodyExpression.preComments(), false); - this.writeToOutput("return "); - this.emit(bodyExpression); - this.writeLineToOutput(";"); - this.emitCommentsArray(bodyExpression.postComments(), true); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - - if (block) { - this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); - } else { - this.writeToOutputWithSourceMapRecord("}", bodyExpression); - } - - if (name) { - this.recordSourceMappingNameEnd(); - } - }; - - Emitter.prototype.emitDefaultValueAssignments = function (parameters) { - var n = parameters.length; - if (parameters.lastParameterIsRest()) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = parameters.astAt(i); - var id = parameters.identifierAt(i); - var equalsValueClause = parameters.initializerAt(i); - if (equalsValueClause) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.emitJavascript(equalsValueClause, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (parameters) { - if (parameters.lastParameterIsRest()) { - var n = parameters.length; - var lastArg = parameters.astAt(n - 1); - var id = parameters.identifierAt(n - 1); - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); - this.writeToOutput(" "); - this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); - this.writeToOutput("; "); - this.writeToOutputWithSourceMapRecord("_i++", lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - var result = []; - - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - var queue = dynamicModuleDecl.getChildDecls(); - - for (var i = 0, n = queue.length; i < n; i++) { - var decl = queue[i]; - - if (decl.kind & 128 /* TypeAlias */) { - var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.type; - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { - var importList = ""; - var dependencyList = ""; - - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.isUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += importStatementDecl.name; - dependencyList += importStatementAST.moduleReference.stringLiteral.text(); - } - } - } - - var amdDependencies = this.document.amdDependencies(); - for (var i = 0; i < amdDependencies.length; i++) { - dependencyList += ", \"" + amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); - } - - var decl = this.semanticInfoChain.getDeclForAST(ast); - if (decl) { - return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); - } - - return false; - }; - - Emitter.prototype.emitEnum = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - this.moduleName = moduleDecl.identifier.text(); - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.identifier); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(this.moduleName); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitSeparatedList(moduleDecl.enumElements); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { - return moduleDecl; - } else if (changeNameIfAnyDeclarationInContext) { - var symbol = moduleDecl.getSymbol(); - if (symbol) { - var otherDecls = symbol.getDeclarations(); - for (var i = 0; i < otherDecls.length; i++) { - if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { - return otherDecls[i]; - } - } - } - } - - return null; - }; - - Emitter.prototype.hasChildNameCollision = function (moduleName, childDecls) { - var _this = this; - return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - if (childDecl.name == moduleName) { - var childAST = _this.semanticInfoChain.getASTForDecl(childDecl); - if (_this.shouldEmit(childAST)) { - return true; - } - } - return false; - }); - }; - - Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - var moduleName = moduleDecl.name; - var moduleDisplayName = moduleDecl.getDisplayName(); - - moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl) { - var childDecls = moduleDecl.getChildDecls(); - - while (this.hasChildNameCollision(moduleName, childDecls)) { - moduleName = "_" + moduleName; - moduleDisplayName = "_" + moduleDisplayName; - } - } - - return moduleDisplayName; - }; - - Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { - if (moduleDecl.stringLiteral) { - this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); - } - }; - - Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.isLastNameOfModule(moduleDecl, moduleName); - - if (isLastName) { - this.emitComments(moduleDecl, true); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - - if (moduleDecl.stringLiteral) { - this.moduleName = moduleDecl.stringLiteral.valueText(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - } else { - this.moduleName = moduleName.text(); - } - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleName); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleName); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - - this.moduleName = this.getModuleName(pullDecl); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(moduleName.text()); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - if (moduleName === moduleDecl.stringLiteral) { - this.emitList(moduleDecl.moduleElements); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - var nameIndex = moduleNames.indexOf(moduleName); - TypeScript.Debug.assert(nameIndex >= 0); - - if (isLastName) { - this.emitList(moduleDecl.moduleElements); - } else { - this.emitIndent(); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); - this.writeLineToOutput(""); - } - } - - this.moduleName = moduleName.text(); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - - if (isLastName) { - this.emitComments(moduleDecl, false); - } - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - var name = varDecl.propertyName.text(); - var quoted = TypeScript.isQuoted(name); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.writeToOutput(']'); - - if (varDecl.equalsValueClause) { - this.emit(varDecl.equalsValueClause); - } else if (pullDecl.constantValue !== null) { - this.writeToOutput(' = '); - this.writeToOutput(pullDecl.constantValue.toString()); - } else { - this.writeToOutput(' = null'); - } - - this.writeToOutput('] = '); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - this.writeToOutput(';'); - }; - - Emitter.prototype.emitElementAccessExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("["); - this.emit(expression.argumentExpression); - this.writeToOutput("]"); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.Parameters.fromIdentifier(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); - }; - - Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = true; - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(arrowFunction); - - var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); - this.pushDecl(pullDecl); - - this.emitComments(arrowFunction, true); - - this.recordSourceMappingStart(arrowFunction); - this.writeToOutput("function "); - this.writeToOutput("("); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); - - this.recordSourceMappingEnd(arrowFunction); - - this.recordSourceMappingEnd(arrowFunction); - - this.emitComments(arrowFunction, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConstructor = function (funcDecl) { - if (!funcDecl.block) { - return; - } - var temp = this.setContainer(4 /* Constructor */); - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - this.writeToOutput(this.thisClassNode.identifier.text()); - this.writeToOutput("("); - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.parameterList); - this.emitFunctionParameters(parameters); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart("constructor"); - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(parameters); - this.emitRestParameterInitializer(parameters); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - this.emitConstructorStatements(funcDecl); - this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - }; - - Emitter.prototype.emitGetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("get "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, TypeScript.Parameters.fromParameterList(accessor.parameterList), accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitSetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("set "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(accessor.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitFunctionExpression = function (funcDecl) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - this.writeToOutput(funcDecl.identifier.text()); - this.recordSourceMappingEnd(funcDecl.identifier); - } - - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (funcDecl.block === null) { - return; - } - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier.text(); - - this.recordSourceMappingStart(funcDecl); - - var printName = funcDecl.identifier !== null; - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (printName) { - var id = funcDecl.identifier.text(); - if (id) { - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - } - this.writeToOutput(id); - if (funcDecl.identifier) { - this.recordSourceMappingEnd(funcDecl.identifier); - } - } - } - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - if (funcDecl.block) { - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - this.recordSourceMappingStart(this.currentVariableDeclaration); - if (varDecl.equalsValueClause) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - this.emitJavascript(varDecl.equalsValueClause, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.currentVariableDeclaration) { - this.writeToOutput("var "); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.nonSeparatorAt(0); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - - this.emitComments(declaration, true); - - var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); - var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; - if (!isAmbientWithoutInit) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.currentVariableDeclaration = declaration; - - for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { - var declarator = declaration.declarators.nonSeparatorAt(i); - - if (i > 0) { - this.writeToOutput(", "); - } - - this.emit(declarator); - } - this.currentVariableDeclaration = prevVariableDeclaration; - - this.recordSourceMappingEnd(declaration); - } - - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { - TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); - - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - - if (quotedOrNumber) { - this.writeToOutput("this["); - } else { - this.writeToOutput("this."); - } - - this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); - - if (quotedOrNumber) { - this.writeToOutput("]"); - } - - if (varDecl.variableDeclarator.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.variableDeclarator.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(this.currentVariableDeclaration); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.propertyName.text(); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); - - if (parentIsModule) { - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - - if (varDecl.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.currentVariableDeclaration = undefined; - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { - var decl = pullSymbol.getDeclarations()[0]; - var parentDecl = decl.getParentDecl(); - var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; - - var enclosingContextDeclPath = this.declStack; - var commonNodeIndex = -1; - - if (enclosingContextDeclPath.length) { - for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { - var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; - for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { - var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; - if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { - commonNodeIndex = i; - break; - } - } - - if (commonNodeIndex >= 0) { - break; - } - } - } - - var startingIndex = symbolContainerDeclPath.length - 1; - for (var i = startingIndex - 1; i > commonNodeIndex; i--) { - if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { - startingIndex = i; - } else { - break; - } - } - return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; - }; - - Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { - for (var i = startingIndex; i <= lastIndex; i++) { - if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.getModuleName(declPath[i], true) + "."); - } - } - }; - - Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { - var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); - var potentialDeclPath = declPathInfo.potentialPath; - var startingIndex = declPathInfo.startingIndex; - - this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); - }; - - Emitter.prototype.getSymbolForEmit = function (ast) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); - var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); - if (pullSymbol && pullSymbolAlias) { - var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - - if (pullSymbol == symbolToCompare) { - pullSymbol = pullSymbolAlias; - pullSymbolAlias = null; - } - } - return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (name.text().length > 0) { - var symbolForEmit = this.getSymbolForEmit(name); - var pullSymbol = symbolForEmit.symbol; - if (!pullSymbol) { - pullSymbol = this.semanticInfoChain.anyTypeSymbol; - } - var pullSymbolAlias = symbolForEmit.aliasSymbol; - var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() == this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.kind; - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } - } - } - - this.writeToOutput(name.text()); - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var nameIndex = -1; - if (name) { - if (this.sourceMapper.currentNameIndex.length > 0) { - var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { - break; - } - } - - if (nameIndex == -1) { - nameIndex = this.sourceMapper.names.length; - this.sourceMapper.names.push(name); - } - } - this.sourceMapper.currentNameIndex.push(nameIndex); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - var lineCol = { line: -1, character: -1 }; - var sourceMapping = new TypeScript.SourceMapping(); - sourceMapping.start.emittedColumn = this.emitState.column; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap(); - lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); - - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - this.sourceMapper.increaseMappingLevel(ast); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); - - this.sourceMapper.decreaseMappingLevel(ast); - } - }; - - Emitter.prototype.getOutputFiles = function () { - var result = []; - if (this.sourceMapper !== null) { - this.sourceMapper.emitSourceMapping(); - result.push(this.sourceMapper.getOutputFile()); - } - - result.push(this.outfile.getOutputFile()); - return result; - }; - - 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); - var parameterDecl = this.semanticInfoChain.getDeclForAST(parameter); - if (TypeScript.hasFlag(parameterDecl.flags, 8388608 /* PropertyParameter */)) { - this.emitIndent(); - this.recordSourceMappingStart(parameter); - this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); - this.writeToOutput(" = "); - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(parameter); - } - } - } - - for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { - if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = this.thisClassNode.classElements.childAt(i); - if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitIndent(); - this.emitMemberVariableDeclaration(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.isOnSameLine = function (pos1, pos2) { - var lineMap = this.document.lineMap(); - return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); - }; - - Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { - if (list === null || list.nonSeparatorCount() === 0) { - return; - } - - var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); - - if (preserveNewLines) { - this.indenter.increaseIndent(); - } - - if (startLine) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(buffer); - } - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - var emitNode = list.nonSeparatorAt(i); - - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); - if (startLine) { - this.writeLineToOutput(","); - } else { - this.writeToOutput(", "); - } - } - } - - if (preserveNewLines) { - this.indenter.decreaseIndent(); - } - - if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(buffer); - } - }; - - Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.nonSeparatorAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.kind() === 14 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { - return; - } - - var lineMap = this.document.lineMap(); - var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput("", true); - } - }; - - Emitter.prototype.getCopyrightComments = function () { - var preComments = this.copyrightElement.preComments(); - if (preComments) { - var lineMap = this.document.lineMap(); - - var copyrightComments = []; - var lastComment = null; - - for (var i = 0, n = preComments.length; i < n; i++) { - var comment = preComments[i]; - - if (lastComment) { - var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); - var commentLine = lineMap.getLineNumberFromPosition(comment.start()); - - if (commentLine >= lastCommentLine + 2) { - return copyrightComments; - } - } - - copyrightComments.push(comment); - lastComment = comment; - } - - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(copyrightComments).end()); - var astLine = lineMap.getLineNumberFromPosition(this.copyrightElement.start()); - if (astLine >= lastCommentLine + 2) { - return copyrightComments; - } - } - - return []; - }; - - Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - var list = script.moduleElements; - if (list.childCount() > 0) { - var firstElement = list.childAt(0); - - this.copyrightElement = firstElement; - this.emitCommentsArray(this.getCopyrightComments(), false); - } - }; - - Emitter.prototype.emitScriptElements = function (sourceUnit) { - var list = sourceUnit.moduleElements; - - this.emitPossibleCopyrightHeaders(sourceUnit); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var node = list.childAt(i); - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(sourceUnit); - - var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.scriptIsElided(sourceUnit); - if (isNonElidedExternalModule) { - this.recordSourceMappingStart(sourceUnit); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } - - if (isExternalModule) { - var temp = this.setContainer(2 /* DynamicModule */); - - var svModuleName = this.moduleName; - this.moduleName = sourceUnit.fileName(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - - this.setExportAssignmentIdentifier(null); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); - - if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { - this.writeCaptureThisStatement(sourceUnit); - } - - this.pushDecl(externalModule); - } - - this.emitList(list, true, i, n); - - if (isExternalModule) { - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - - if (isNonElidedExternalModule) { - var exportAssignmentIdentifier = this.getExportAssignmentIdentifier(); - var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeLineToOutput("return " + exportAssignmentIdentifier + ";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifier && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.emitIndent(); - this.writeToOutput("module.exports = " + exportAssignmentIdentifier + ";"); - } - - this.recordSourceMappingEnd(sourceUnit); - this.writeLineToOutput(""); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - this.popDecl(externalModule); - } - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = TypeScript.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - this.emit(ast); - }; - - Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { - if (funcDecl.kind() !== 139 /* GetAccessor */) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - - this.writeToOutput("Object.defineProperty(" + className); - if (isProto) { - this.writeToOutput(".prototype, "); - } else { - this.writeToOutput(", "); - } - - var functionName = name.text(); - if (TypeScript.isQuoted(functionName)) { - this.writeToOutput(functionName); - } else { - this.writeToOutput('"' + functionName + '"'); - } - - this.writeLineToOutput(", {"); - - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.emitComments(accessors.getter, true); - this.writeToOutput("get: "); - this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.emitComments(accessors.setter, true); - this.writeToOutput("set: "); - this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.identifier.text(); - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses) !== null; - var baseTypeReference = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseTypeReference = TypeScript.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); - this.emitIndent(); - this.writeLineToOutput("__extends(" + className + ", _super);"); - } - - this.emitIndent(); - - var constrDecl = getLastConstructor(classDecl); - - if (constrDecl) { - this.emit(constrDecl); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeLineToOutput("_super.apply(this, arguments);"); - } - - if (this.shouldCaptureThis(classDecl)) { - this.writeCaptureThisStatement(classDecl); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.emitJavascript(baseTypeReference, false); - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 139 /* GetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var getter = memberDecl; - this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 140 /* SetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var setter = memberDecl; - this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { - var memberFunction = memberDecl; - - if (memberFunction.block) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - - this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); - lastEmittedMember = memberDecl; - } - } - } - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = memberDecl; - - if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); - } else { - this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); - } - - this.emit(varDecl.variableDeclarator.equalsValueClause); - - this.recordSourceMappingEnd(varDecl); - this.writeLineToOutput(";"); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - var functionName = funcDecl.propertyName.text(); - - this.writeToOutput(classDecl.identifier.text()); - - if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - this.writeToOutput(".prototype"); - } - - if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput("[" + functionName + "] = "); - } else { - this.writeToOutput("." + functionName + " = "); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - - this.writeLineToOutput(";"); - }; - - Emitter.prototype.requiresExtendsBlock = function (moduleElements) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - - if (moduleElement.kind() === 130 /* ModuleDeclaration */) { - var moduleAST = moduleElement; - - if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { - return true; - } - } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { - var classDeclaration = moduleElement; - - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitPrologue = function (sourceUnit) { - if (!this.extendsPrologueEmitted) { - if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(sourceUnit)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitThis = function () { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.kind() === 146 /* Block */) { - this.emit(node); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitLiteralExpression = function (expression) { - switch (expression.kind()) { - case 32 /* NullKeyword */: - this.writeToOutputWithSourceMapRecord("null", expression); - break; - case 24 /* FalseKeyword */: - this.writeToOutputWithSourceMapRecord("false", expression); - break; - case 37 /* TrueKeyword */: - this.writeToOutputWithSourceMapRecord("true", expression); - break; - default: - throw TypeScript.Errors.abstract(); - } - }; - - Emitter.prototype.emitThisExpression = function (expression) { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutputWithSourceMapRecord("_this", expression); - } else { - this.writeToOutputWithSourceMapRecord("this", expression); - } - }; - - Emitter.prototype.emitSuperExpression = function (expression) { - this.writeToOutputWithSourceMapRecord("_super.prototype", expression); - }; - - Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { - if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { - this.emit(parenthesizedExpression.expression); - } else { - this.recordSourceMappingStart(parenthesizedExpression); - this.writeToOutput("("); - this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); - this.emit(parenthesizedExpression.expression); - this.writeToOutput(")"); - this.recordSourceMappingEnd(parenthesizedExpression); - } - }; - - Emitter.prototype.emitCastExpression = function (expression) { - this.emit(expression.expression); - }; - - Emitter.prototype.emitPrefixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 167 /* LogicalNotExpression */: - this.writeToOutput("!"); - this.emit(expression.operand); - break; - case 166 /* BitwiseNotExpression */: - this.writeToOutput("~"); - this.emit(expression.operand); - break; - case 165 /* NegateExpression */: - this.writeToOutput("-"); - if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 164 /* PlusExpression */: - this.writeToOutput("+"); - if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 168 /* PreIncrementExpression */: - this.writeToOutput("++"); - this.emit(expression.operand); - break; - case 169 /* PreDecrementExpression */: - this.writeToOutput("--"); - this.emit(expression.operand); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitPostfixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 210 /* PostIncrementExpression */: - this.emit(expression.operand); - this.writeToOutput("++"); - break; - case 211 /* PostDecrementExpression */: - this.emit(expression.operand); - this.writeToOutput("--"); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitTypeOfExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("typeof "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDeleteExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("delete "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitVoidExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("void "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { - var memberExpressionNodeType = expression.expression.kind(); - - 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 */) { - return this.canEmitDottedNameMemberAccessExpression(expression.expression); - } - - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { - this.recordSourceMappingStart(expression); - if (expression.expression.kind() == 212 /* MemberAccessExpression */) { - this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); - } else { - this.emitComments(expression.expression, true); - this.recordSourceMappingStart(expression.expression); - - this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); - - this.writeToOutput(expression.expression.text()); - - this.recordSourceMappingEnd(expression.expression); - this.emitComments(expression.expression, false); - } - - this.writeToOutput("."); - this.emitName(expression.name, false); - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { - this.emitComments(expression, true); - - if (lastIndex - startingIndex < 1) { - startingIndex = lastIndex - 1; - TypeScript.Debug.assert(startingIndex >= 0); - } - - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); - this.emitComments(expression, false); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { - var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; - - var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); - }; - - Emitter.prototype.emitMemberAccessExpression = function (expression) { - if (!this.tryEmitConstant(expression)) { - if (this.canEmitDottedNameMemberAccessExpression(expression)) { - this.emitDottedNameMemberAccessExpression(expression); - } else { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("."); - this.emitName(expression.name, false); - this.recordSourceMappingEnd(expression); - } - } - }; - - Emitter.prototype.emitQualifiedName = function (name) { - this.recordSourceMappingStart(name); - - this.emit(name.left); - this.writeToOutput("."); - this.emitName(name.right, false); - - this.recordSourceMappingEnd(name); - }; - - Emitter.prototype.emitBinaryExpression = function (expression) { - this.recordSourceMappingStart(expression); - switch (expression.kind()) { - case 173 /* CommaExpression */: - this.emit(expression.left); - this.writeToOutput(", "); - this.emit(expression.right); - break; - default: { - this.emit(expression.left); - var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); - if (binOp === "instanceof") { - this.writeToOutput(" instanceof "); - } else if (binOp === "in") { - this.writeToOutput(" in "); - } else { - this.writeToOutput(" " + binOp + " "); - } - this.emit(expression.right); - } - } - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimplePropertyAssignment = function (property) { - this.recordSourceMappingStart(property); - this.emit(property.propertyName); - this.writeToOutput(": "); - this.emit(property.expression); - this.recordSourceMappingEnd(property); - }; - - Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { - this.recordSourceMappingStart(funcProp); - - this.emit(funcProp.propertyName); - this.writeToOutput(": "); - - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); - - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - var funcName = funcProp.propertyName; - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcProp); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.Parameters.fromParameterList(funcProp.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); - - this.recordSourceMappingEnd(funcProp); - - this.recordSourceMappingEnd(funcProp); - - this.emitComments(funcProp, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - this.recordSourceMappingEnd(funcProp); - }; - - Emitter.prototype.emitConditionalExpression = function (expression) { - this.emit(expression.condition); - this.writeToOutput(" ? "); - this.emit(expression.whenTrue); - this.writeToOutput(" : "); - this.emit(expression.whenFalse); - }; - - Emitter.prototype.emitThrowStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("throw "); - this.emit(statement.expression); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitExpressionStatement = function (statement) { - var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; - - this.recordSourceMappingStart(statement); - if (isArrowExpression) { - this.writeToOutput("("); - } - - this.emit(statement.expression); - - if (isArrowExpression) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitLabeledStatement = function (statement) { - this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); - this.writeLineToOutput(":"); - this.emitJavascript(statement.statement, true); - }; - - Emitter.prototype.emitBlock = function (block) { - this.recordSourceMappingStart(block); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - if (block.statements) { - this.emitList(block.statements); - } - this.emitCommentsArray(block.closeBraceLeadingComments, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(block); - }; - - Emitter.prototype.emitBreakStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("break"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitContinueStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("continue"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitWhileStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("while ("); - this.emit(statement.condition); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitDoStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("do"); - this.emitBlockOrStatement(statement.statement); - this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); - this.writeToOutput('('); - this.emit(statement.condition); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitIfStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("if ("); - this.emit(statement.condition); - this.writeToOutput(")"); - - this.emitBlockOrStatement(statement.statement); - - if (statement.elseClause) { - if (statement.statement.kind() !== 146 /* Block */) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - - this.emit(statement.elseClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitElseClause = function (elseClause) { - if (elseClause.statement.kind() === 147 /* IfStatement */) { - this.writeToOutput("else "); - this.emit(elseClause.statement); - } else { - this.writeToOutput("else"); - this.emitBlockOrStatement(elseClause.statement); - } - }; - - Emitter.prototype.emitReturnStatement = function (statement) { - this.recordSourceMappingStart(statement); - if (statement.expression) { - this.writeToOutput("return "); - this.emit(statement.expression); - } else { - this.writeToOutput("return"); - } - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitForInStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.left) { - this.emit(statement.left); - } else { - this.emit(statement.variableDeclaration); - } - this.writeToOutput(" in "); - this.emit(statement.expression); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitForStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.variableDeclaration) { - this.emit(statement.variableDeclaration); - } else if (statement.initializer) { - this.emit(statement.initializer); - } - - this.writeToOutput("; "); - this.emitJavascript(statement.condition, false); - this.writeToOutput(";"); - if (statement.incrementor) { - this.writeToOutput(" "); - this.emitJavascript(statement.incrementor, false); - } - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitWithStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("with ("); - if (statement.condition) { - this.emit(statement.condition); - } - - this.writeToOutput(")"); - var prevInWithBlock = this.inWithBlock; - this.inWithBlock = true; - this.emitBlockOrStatement(statement.statement); - this.inWithBlock = prevInWithBlock; - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitSwitchStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("switch ("); - this.emit(statement.expression); - this.recordSourceMappingStart(statement.closeParenToken); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement.closeParenToken); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - this.emitList(statement.switchClauses, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCaseSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("case "); - this.emit(clause.expression); - this.writeToOutput(":"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitSwitchClauseBody = function (body) { - if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { - this.emit(body.childAt(0)); - this.writeLineToOutput(""); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emit(body); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitDefaultSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("default:"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitTryStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("try "); - this.emit(statement.block); - this.emitJavascript(statement.catchClause, false); - - if (statement.finallyClause) { - this.emit(statement.finallyClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCatchClause = function (clause) { - this.writeToOutput(" "); - this.recordSourceMappingStart(clause); - this.writeToOutput("catch ("); - this.emit(clause.identifier); - this.writeToOutput(")"); - this.emit(clause.block); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitFinallyClause = function (clause) { - this.writeToOutput(" finally"); - this.emit(clause.block); - }; - - Emitter.prototype.emitDebuggerStatement = function (statement) { - this.writeToOutputWithSourceMapRecord("debugger", statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitNumericLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitRegularExpressionLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitStringLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitEqualsValueClause = function (clause) { - this.writeToOutput(" = "); - this.emit(clause.value); - }; - - Emitter.prototype.emitParameter = function (parameter) { - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); - }; - - Emitter.prototype.emitConstructorDeclaration = function (declaration) { - if (declaration.block) { - this.emitConstructor(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { - return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); - }; - - Emitter.prototype.emitFunctionDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { - this.emitFunction(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.emitSourceUnit = function (sourceUnit) { - if (!this.document.isDeclareFile()) { - var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); - this.pushDecl(pullDecl); - this.emitScriptElements(sourceUnit); - this.popDecl(pullDecl); - } - }; - - Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.enumIsElided(declaration); - }; - - Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.enumIsElided(declaration)) { - this.emitComments(declaration, true); - this.emitEnum(declaration); - this.emitComments(declaration, false); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.moduleIsElided(declaration); - }; - - Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.moduleIsElided(declaration)) { - this.emitModuleDeclarationWorker(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); - }; - - Emitter.prototype.emitClassDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { - this.emitClass(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { - return declaration.preComments() !== null; - }; - - Emitter.prototype.emitInterfaceDeclaration = function (declaration) { - this.emitComments(declaration, true, true); - }; - - Emitter.prototype.firstVariableDeclarator = function (statement) { - return statement.declaration.declarators.nonSeparatorAt(0); - }; - - Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { - return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; - }; - - Emitter.prototype.shouldEmitVariableStatement = function (statement) { - return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); - }; - - Emitter.prototype.emitVariableStatement = function (statement) { - if (this.isNotAmbientOrHasInitializer(statement)) { - this.emitComments(statement, true); - this.emit(statement.declaration); - this.writeToOutput(";"); - this.emitComments(statement, false); - } else { - this.emitComments(statement, true, true); - } - }; - - Emitter.prototype.emitGenericType = function (type) { - this.emit(type.name); - }; - - Emitter.prototype.shouldEmit = function (ast) { - if (!ast) { - return false; - } - - switch (ast.kind()) { - case 133 /* ImportDeclaration */: - return this.shouldEmitImportDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.shouldEmitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.shouldEmitInterfaceDeclaration(ast); - case 129 /* FunctionDeclaration */: - return this.shouldEmitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.shouldEmitModuleDeclaration(ast); - case 148 /* VariableStatement */: - return this.shouldEmitVariableStatement(ast); - case 223 /* OmittedExpression */: - return false; - case 132 /* EnumDeclaration */: - return this.shouldEmitEnumDeclaration(ast); - } - - return true; - }; - - Emitter.prototype.emit = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 2 /* SeparatedList */: - return this.emitSeparatedList(ast); - case 1 /* List */: - return this.emitList(ast); - case 120 /* SourceUnit */: - return this.emitSourceUnit(ast); - case 133 /* ImportDeclaration */: - return this.emitImportDeclaration(ast); - case 134 /* ExportAssignment */: - return this.setExportAssignmentIdentifier(ast.identifier.text()); - case 131 /* ClassDeclaration */: - return this.emitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitInterfaceDeclaration(ast); - case 11 /* IdentifierName */: - return this.emitName(ast, true); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast); - case 219 /* SimpleArrowFunctionExpression */: - return this.emitSimpleArrowFunctionExpression(ast); - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.emitParenthesizedArrowFunctionExpression(ast); - case 129 /* FunctionDeclaration */: - return this.emitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitModuleDeclaration(ast); - case 224 /* VariableDeclaration */: - return this.emitVariableDeclaration(ast); - case 126 /* GenericType */: - return this.emitGenericType(ast); - case 137 /* ConstructorDeclaration */: - return this.emitConstructorDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitEnumDeclaration(ast); - case 243 /* EnumElement */: - return this.emitEnumElement(ast); - case 222 /* FunctionExpression */: - return this.emitFunctionExpression(ast); - case 148 /* VariableStatement */: - return this.emitVariableStatement(ast); - } - - this.emitComments(ast, true); - this.emitWorker(ast); - this.emitComments(ast, false); - }; - - Emitter.prototype.emitWorker = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 13 /* NumericLiteral */: - return this.emitNumericLiteral(ast); - case 12 /* RegularExpressionLiteral */: - return this.emitRegularExpressionLiteral(ast); - case 14 /* StringLiteral */: - return this.emitStringLiteral(ast); - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 37 /* TrueKeyword */: - return this.emitLiteralExpression(ast); - case 35 /* ThisKeyword */: - return this.emitThisExpression(ast); - case 50 /* SuperKeyword */: - return this.emitSuperExpression(ast); - case 217 /* ParenthesizedExpression */: - return this.emitParenthesizedExpression(ast); - case 214 /* ArrayLiteralExpression */: - return this.emitArrayLiteralExpression(ast); - case 211 /* PostDecrementExpression */: - case 210 /* PostIncrementExpression */: - return this.emitPostfixUnaryExpression(ast); - case 167 /* LogicalNotExpression */: - case 166 /* BitwiseNotExpression */: - case 165 /* NegateExpression */: - case 164 /* PlusExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.emitPrefixUnaryExpression(ast); - case 213 /* InvocationExpression */: - return this.emitInvocationExpression(ast); - case 221 /* ElementAccessExpression */: - return this.emitElementAccessExpression(ast); - case 212 /* MemberAccessExpression */: - return this.emitMemberAccessExpression(ast); - case 121 /* QualifiedName */: - return this.emitQualifiedName(ast); - case 173 /* CommaExpression */: - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* LogicalOrExpression */: - case 188 /* LogicalAndExpression */: - case 189 /* BitwiseOrExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 191 /* BitwiseAndExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return this.emitBinaryExpression(ast); - case 186 /* ConditionalExpression */: - return this.emitConditionalExpression(ast); - case 232 /* EqualsValueClause */: - return this.emitEqualsValueClause(ast); - case 242 /* Parameter */: - return this.emitParameter(ast); - case 146 /* Block */: - return this.emitBlock(ast); - case 235 /* ElseClause */: - return this.emitElseClause(ast); - case 147 /* IfStatement */: - return this.emitIfStatement(ast); - case 149 /* ExpressionStatement */: - return this.emitExpressionStatement(ast); - case 139 /* GetAccessor */: - return this.emitGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitSetAccessor(ast); - case 157 /* ThrowStatement */: - return this.emitThrowStatement(ast); - case 150 /* ReturnStatement */: - return this.emitReturnStatement(ast); - case 216 /* ObjectCreationExpression */: - return this.emitObjectCreationExpression(ast); - case 151 /* SwitchStatement */: - return this.emitSwitchStatement(ast); - case 233 /* CaseSwitchClause */: - return this.emitCaseSwitchClause(ast); - case 234 /* DefaultSwitchClause */: - return this.emitDefaultSwitchClause(ast); - case 152 /* BreakStatement */: - return this.emitBreakStatement(ast); - case 153 /* ContinueStatement */: - return this.emitContinueStatement(ast); - case 154 /* ForStatement */: - return this.emitForStatement(ast); - case 155 /* ForInStatement */: - return this.emitForInStatement(ast); - case 158 /* WhileStatement */: - return this.emitWhileStatement(ast); - case 163 /* WithStatement */: - return this.emitWithStatement(ast); - case 220 /* CastExpression */: - return this.emitCastExpression(ast); - case 215 /* ObjectLiteralExpression */: - return this.emitObjectLiteralExpression(ast); - case 240 /* SimplePropertyAssignment */: - return this.emitSimplePropertyAssignment(ast); - case 241 /* FunctionPropertyAssignment */: - return this.emitFunctionPropertyAssignment(ast); - case 156 /* EmptyStatement */: - return this.writeToOutputWithSourceMapRecord(";", ast); - case 159 /* TryStatement */: - return this.emitTryStatement(ast); - case 236 /* CatchClause */: - return this.emitCatchClause(ast); - case 237 /* FinallyClause */: - return this.emitFinallyClause(ast); - case 160 /* LabeledStatement */: - return this.emitLabeledStatement(ast); - case 161 /* DoStatement */: - return this.emitDoStatement(ast); - case 171 /* TypeOfExpression */: - return this.emitTypeOfExpression(ast); - case 170 /* DeleteExpression */: - return this.emitDeleteExpression(ast); - case 172 /* VoidExpression */: - return this.emitVoidExpression(ast); - case 162 /* DebuggerStatement */: - return this.emitDebuggerStatement(ast); - } - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; - - function getLastConstructor(classDecl) { - return classDecl.classElements.lastOrDefault(function (e) { - return e.kind() === 137 /* ConstructorDeclaration */; - }); - } - TypeScript.getLastConstructor = getLastConstructor; - - function getTrimmedTextLines(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - return comment.fullText().split("\n").map(function (s) { - return s.trim(); - }); - } else { - return [comment.fullText().trim()]; - } - } - TypeScript.getTrimmedTextLines = getTrimmedTextLines; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += memberName.text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripStartAndEndQuotes(str) { - var firstCharCode = str && str.charCodeAt(0); - if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - return str.substring(1, str.length - 1); - } - - return str; - } - TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; - - function isSingleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isDoubleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; - } - TypeScript.isDoubleQuoted = isDoubleQuoted; - - function isQuoted(str) { - return isDoubleQuoted(str) || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - var switchToForwardSlashesRegEx = /\\/g; - function switchToForwardSlashes(path) { - return path.replace(switchToForwardSlashesRegEx, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { - if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { - absoluteModPath = "file:///" + absoluteModPath; - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function changePathToDTS(modPath) { - return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.length > 0 && path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function convertToDirectoryPath(dirPath) { - if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { - dirPath += "/"; - } - - return dirPath; - } - TypeScript.convertToDirectoryPath = convertToDirectoryPath; - - var normalizePathRegEx = /^\\\\[^\\]/; - function normalizePath(path) { - if (normalizePathRegEx.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - function isNoDefaultLibMatch(comment) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - return isNoDefaultLibRegex.exec(comment); - } - - TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; - - function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { - var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } - } - } - - return null; - } - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - var start = new Date().getTime(); - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 107 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 72 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionScanImportsTime += totalTime; - } - - function processTripleSlashDirectives(fileName, lineMap, firstToken) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - var diagnostics = []; - var referencedFiles = []; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - var isNoDefaultLib = isNoDefaultLibMatch(triviaText); - if (isNoDefaultLib) { - noDefaultLib = isNoDefaultLib[3] === "true"; - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; - } - - function preProcessFile(fileName, sourceText, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); - - scannerDiagnostics.length = 0; - return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); - } - TypeScript.getParseOptions = getParseOptions; - - function getReferencedFiles(fileName, sourceText) { - return preProcessFile(fileName, sourceText, false).referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ReferenceResolutionResult = (function () { - function ReferenceResolutionResult() { - this.resolvedFiles = []; - this.diagnostics = []; - this.seenNoDefaultLibTag = false; - } - return ReferenceResolutionResult; - })(); - TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; - - var ReferenceLocation = (function () { - function ReferenceLocation(filePath, lineMap, position, length, isImported) { - this.filePath = filePath; - this.lineMap = lineMap; - this.position = position; - this.length = length; - this.isImported = isImported; - } - return ReferenceLocation; - })(); - - var ReferenceResolver = (function () { - function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { - this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this.inputFileNames = inputFileNames; - this.host = host; - this.visited = {}; - } - ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { - var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); - return resolver.resolveInputFiles(); - }; - - ReferenceResolver.prototype.resolveInputFiles = function () { - var _this = this; - var result = new ReferenceResolutionResult(); - - if (!this.inputFileNames || this.inputFileNames.length <= 0) { - return result; - } - - var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); - this.inputFileNames.forEach(function (fileName) { - return _this.resolveIncludedFile(fileName, referenceLocation, result); - }); - - return result; - }; - - ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { - var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); - - if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); - } - - return normalizedPath; - } - - if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { - var dtsFile = normalizedPath + ".d.ts"; - var tsFile = normalizedPath + ".ts"; - - if (this.host.fileExists(dtsFile)) { - normalizedPath = dtsFile; - } else { - normalizedPath = tsFile; - } - } - - if (!this.host.fileExists(normalizedPath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); - } - - return normalizedPath; - } - - return this.resolveFile(normalizedPath, resolutionResult); - }; - - ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { - var isRelativePath = TypeScript.isRelative(path); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); - - if (isRelativePath || isRootedPath) { - return this.resolveIncludedFile(path, referenceLocation, resolutionResult); - } else { - var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); - var searchFilePath = null; - var dtsFileName = path + ".d.ts"; - var tsFilePath = path + ".ts"; - - var start = new Date().getTime(); - - do { - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - parentDirectory = this.host.getParentDirectory(parentDirectory); - } while(parentDirectory); - - TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; - - if (!searchFilePath) { - return path; - } - - return this.resolveFile(searchFilePath, resolutionResult); - } - }; - - ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { - var _this = this; - var visitedPath = this.isVisited(normalizedPath); - if (!visitedPath) { - this.recordVisitedFile(normalizedPath); - - var start = new Date().getTime(); - var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionIOTime += totalTime; - - var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); - var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); - resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); - - if (preprocessedFileInformation.isLibFile) { - resolutionResult.seenNoDefaultLibTag = true; - } - - var normalizedReferencePaths = []; - preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); - var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); - normalizedReferencePaths.push(normalizedReferencePath); - }); - - var normalizedImportPaths = []; - for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { - var fileImport = preprocessedFileInformation.importedFiles[i]; - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); - var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); - normalizedImportPaths.push(normalizedImportPath); - } - - resolutionResult.resolvedFiles.push({ - path: normalizedPath, - referencedFiles: normalizedReferencePaths, - importedFiles: normalizedImportPaths - }); - } else { - normalizedPath = visitedPath; - } - - return normalizedPath; - }; - - ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { - var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; - var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); - return normalizedPath; - }; - - ReferenceResolver.prototype.getUniqueFileId = function (filePath) { - return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); - }; - - ReferenceResolver.prototype.recordVisitedFile = function (filePath) { - this.visited[this.getUniqueFileId(filePath)] = filePath; - }; - - ReferenceResolver.prototype.isVisited = function (filePath) { - return this.visited[this.getUniqueFileId(filePath)]; - }; - - ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { - if (!filePath1 || !filePath2) { - return false; - } - - if (this.useCaseSensitiveFileResolution) { - return filePath1 === filePath2; - } else { - return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); - } - }; - return ReferenceResolver; - })(); - TypeScript.ReferenceResolver = ReferenceResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(name, writeByteOrderMark, outputFileType) { - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.outputFileType = outputFileType; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += TypeScript.newLine(); - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - }; - - TextWriter.prototype.getOutputFile = function () { - return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.document = document; - this.compiler = compiler; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.emittedReferencePaths = false; - this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); - } - DeclarationEmitter.prototype.getOutputFile = function () { - return this.declFile.getOutputFile(); - }; - - DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { - this.emitDeclarationsForSourceUnit(sourceUnit); - }; - - DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.emitDeclarationsForAST(list.childAt(i)); - } - }; - - DeclarationEmitter.prototype.emitSeparatedList = function (list) { - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.emitDeclarationsForAST(list.nonSeparatorAt(i)); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { - switch (ast.kind()) { - case 148 /* VariableStatement */: - return this.emitDeclarationsForVariableStatement(ast); - case 141 /* PropertySignature */: - return this.emitPropertySignature(ast); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast, true, true); - case 136 /* MemberVariableDeclaration */: - return this.emitDeclarationsForMemberVariableDeclaration(ast); - case 137 /* ConstructorDeclaration */: - return this.emitDeclarationsForConstructorDeclaration(ast); - case 139 /* GetAccessor */: - return this.emitDeclarationsForGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitDeclarationsForSetAccessor(ast); - case 138 /* IndexMemberDeclaration */: - return this.emitIndexMemberDeclaration(ast); - case 144 /* IndexSignature */: - return this.emitIndexSignature(ast); - case 142 /* CallSignature */: - return this.emitCallSignature(ast); - case 143 /* ConstructSignature */: - return this.emitConstructSignature(ast); - case 145 /* MethodSignature */: - return this.emitMethodSignature(ast); - case 129 /* FunctionDeclaration */: - return this.emitDeclarationsForFunctionDeclaration(ast); - case 135 /* MemberFunctionDeclaration */: - return this.emitMemberFunctionDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.emitDeclarationsForClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitDeclarationsForInterfaceDeclaration(ast); - case 133 /* ImportDeclaration */: - return this.emitDeclarationsForImportDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitDeclarationsForModuleDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitDeclarationsForEnumDeclaration(ast); - case 134 /* ExportAssignment */: - return this.emitDeclarationsForExportAssignment(ast); - } - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - return this.indenter.getIndent(); - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { - var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { - var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - var start = new Date().getTime(); - var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); - var result = declSymbol && declSymbol.isExternallyVisible(); - TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; - - return result; - } - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { - var result = this.getIndentString(); - var pullFlags = pullDecl.flags; - - if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); - - var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); - var container = this.getEnclosingContainer(declAST); - - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.isAnyNameOfModule(container, declAST)) { - container = this.getEnclosingContainer(container); - } - - var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); - - if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (isExternalModule || container.kind() == 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString != "import") { - result += "declare "; - } - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { - this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { - var declarationContainerAst = this.getEnclosingContainer(ast); - - var start = new Date().getTime(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); - - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = TypeScript.getTrimmedTextLines(comment); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.docComments(astOrSymbol); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { - var start = new Date().getTime(); - var decl = this.semanticInfoChain.getDeclForAST(boundDecl); - var pullSymbol = decl.getSymbol(); - TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; - - var type = pullSymbol.type; - TypeScript.Debug.assert(type); - - this.declFile.Write(": "); - this.emitTypeSignature(boundDecl, type); - }; - - DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { - this.emitDeclarationComments(varDecl); - this.emitIndent(); - this.declFile.Write(varDecl.propertyName.text()); - if (varDecl.questionToken) { - this.declFile.Write("?"); - } - - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - if (isFirstVarInList) { - this.emitDeclFlags(varDecl, "var"); - } - - this.declFile.Write(varDecl.propertyName.text()); - - if (!TypeScript.hasModifier(TypeScript.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - if (isLastVarInList) { - this.declFile.WriteLine(";"); - } else { - this.declFile.Write(", "); - } - } - }; - - DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { - if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } - this.declFile.Write("static "); - } else { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } else { - this.declFile.Write("public "); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(varDecl.modifiers); - ; - - this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); - - if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - this.declFile.WriteLine(";"); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { - this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); - }; - - 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); - } - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(id.text()); - if (isOptional) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (!isPrivate) { - this.emitTypeOfVariableDeclaratorOrParameter(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var start = new Date().getTime(); - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - var signatures = funcTypeSymbol.getCallSignatures(); - var result = signatures && signatures.length > 1; - - return result; - }; - - DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("constructor"); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitParameterList = function (isPrivate, parameterList) { - this.declFile.Write("("); - this.emitParameters(isPrivate, TypeScript.Parameters.fromParameterList(parameterList)); - this.declFile.Write(")"); - }; - - DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { - var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); - var argsLen = parameterList.length; - if (hasLastParameterRestParameter) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - - if (hasLastParameterRestParameter) { - if (parameterList.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - var index = parameterList.length - 1; - this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); - } - }; - - DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitDeclFlags(funcDecl, "function"); - var id = funcDecl.propertyName.text(); - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); - - this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); - - if (!isPrivate) { - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - this.emitDeclarationComments(funcDecl); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); - - this.emitIndent(); - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("new"); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write(funcDecl.propertyName.text()); - if (funcDecl.questionToken) { - this.declFile.Write("? "); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - if (funcDecl.block) { - var funcTypeSymbol = funcSymbol.type; - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - var id = funcDecl.identifier.text(); - this.emitDeclFlags(funcDecl, "function"); - if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { - this.declFile.Write(id); - } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { - this.declFile.Write("new"); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { - this.emitDeclarationsForAST(funcDecl.indexSignature); - }; - - DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("["); - this.emitParameters(false, TypeScript.Parameters.fromParameter(funcDecl.parameter)); - this.declFile.Write("]"); - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { - if (bases && (bases.nonSeparatorCount() > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.nonSeparatorCount(); - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - var base = bases.nonSeparatorAt(i); - var baseType = this.semanticInfoChain.getSymbolForAST(base); - this.emitTypeSignature(base, baseType); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var start = new Date().getTime(); - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - var comments = []; - if (accessors.getter) { - comments = comments.concat(TypeScript.docComments(accessors.getter)); - } - if (accessors.setter) { - comments = comments.concat(TypeScript.docComments(accessors.setter)); - } - - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { - var start = new Date().getTime(); - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { - return; - } - - var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); - this.emitAccessorDeclarationComments(funcDecl); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(modifiers); - this.declFile.Write(name.text()); - if (!isPrivate) { - this.declFile.Write(" : "); - var type = accessorSymbol.type; - this.emitTypeSignature(funcDecl, type); - } - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - if (funcDecl.parameterList) { - var argsLen = funcDecl.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.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()); - - if (!TypeScript.hasModifier(parameter.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(parameter); - } - this.declFile.WriteLine(";"); - } - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { - if (!this.canEmitDeclarations(classDecl)) { - return; - } - - var className = classDecl.identifier.text(); - this.emitDeclarationComments(classDecl); - var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.emitDeclFlags(classDecl, "class"); - this.declFile.Write(className); - - this.emitTypeParameters(classDecl.typeParameterList); - this.emitHeritageClauses(classDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - var constructorDecl = TypeScript.getLastConstructor(classDecl); - if (constructorDecl) { - this.emitClassMembersFromConstructorDefinition(constructorDecl); - } - - this.emitDeclarationsForList(classDecl.classElements); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { - if (clauses) { - for (var i = 0, n = clauses.childCount(); i < n; i++) { - this.emitHeritageClause(clauses.childAt(i)); - } - } - }; - - DeclarationEmitter.prototype.emitHeritageClause = function (clause) { - this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); - }; - - DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getEnclosingContainer(typeParams); - - var start = new Date().getTime(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); - var containerSymbol = containerDecl.getSymbol(); - TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; - - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArgumentsOrTypeParameters(); - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { - if (!this.canEmitDeclarations(interfaceDecl)) { - return; - } - - var interfaceName = interfaceDecl.identifier.text(); - this.emitDeclarationComments(interfaceDecl); - var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); - this.emitDeclFlags(interfaceDecl, "interface"); - this.declFile.Write(interfaceName); - - this.emitTypeParameters(interfaceDecl.typeParameterList); - this.emitHeritageClauses(interfaceDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - - this.emitSeparatedList(interfaceDecl.body.typeMembers); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); - var importSymbol = importDecl.getSymbol(); - var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); - - if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - if (isExportedImportDecl) { - this.declFile.Write("export "); - } - this.declFile.Write("import "); - this.declFile.Write(importDeclAST.identifier.text() + " = "); - if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); - } else { - this.declFile.WriteLine(this.getFullName(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; - } - - this.emitDeclarationComments(moduleDecl); - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclFlags(moduleDecl, "enum"); - this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.enumElements.nonSeparatorCount(); - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); - var enumElement = memberDecl; - var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); - this.emitDeclarationComments(enumElement); - this.emitIndent(); - this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue != null) { - this.declFile.Write(" = " + enumElementDecl.constantValue); - } - this.declFile.WriteLine(","); - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclarationComments(moduleDecl); - - var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); - this.emitDeclFlags(name, "module"); - - if (moduleDecl.stringLiteral) { - this.declFile.Write(moduleDecl.stringLiteral.text()); - } else { - this.declFile.Write(this.getFullName(moduleDecl.name)); - } - - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - - this.emitDeclarationsForList(moduleDecl.moduleElements); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write(ast.identifier.text()); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { - if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { - return reference; - } - - var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); - var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); - return resolvedReferencePath; - }; - - DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { - if (this.emittedReferencePaths) { - return; - } - - var documents = []; - if (this.document.emitToOwnOutputFile()) { - var scriptReferences = this.document.referencedFiles; - var addedGlobalDocument = false; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { - documents = documents.concat(document); - - if (!document.isDeclareFile() && document.isExternalModule()) { - addedGlobalDocument = true; - } - } - } - } else { - var fileNames = this.compiler.fileNames(); - for (var i = 0; i < fileNames.length; i++) { - var doc = this.compiler.getDocument(fileNames[i]); - if (!doc.isDeclareFile() && !doc.isExternalModule()) { - var scriptReferences = doc.referencedFiles; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.isDeclareFile() || document.isExternalModule())) { - for (var k = 0; k < documents.length; k++) { - if (documents[k] == document) { - break; - } - } - - if (k == documents.length) { - documents = documents.concat(document); - } - } - } - } - } - } - - var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; - for (var i = 0; i < documents.length; i++) { - var document = documents[i]; - var declFileName; - if (document.isDeclareFile()) { - declFileName = document.fileName; - } else { - declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } - - declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); - this.declFile.WriteLine('/// '); - } - - this.emittedReferencePaths = true; - }; - - DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { - this.emitReferencePaths(sourceUnit); - this.emitDeclarationsForList(sourceUnit.moduleElements); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - if (keys[name]) { - this.add(name); - } - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount == filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length != array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] != array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateEnumConstants = false; - this.removeComments = false; - this.watch = false; - this.noResolve = false; - this.allowAutomaticSemicolonInsertion = true; - this.noImplicitAny = false; - this.noLib = false; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Unspecified */; - this.outFileOption = ""; - this.outDirOption = ""; - this.mapSourceFiles = false; - this.mapRoot = ""; - this.sourceRoot = ""; - this.generateDeclarationFiles = false; - this.useCaseSensitiveFileResolution = false; - this.gatherDiagnostics = false; - this.codepage = null; - } - 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) { - this._propagateEnumConstants = propagateEnumConstants; - this._removeComments = removeComments; - this._watch = watch; - this._noResolve = noResolve; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._noImplicitAny = noImplicitAny; - this._noLib = noLib; - this._codeGenTarget = codeGenTarget; - this._moduleGenTarget = moduleGenTarget; - this._outFileOption = outFileOption; - this._outDirOption = outDirOption; - this._mapSourceFiles = mapSourceFiles; - this._mapRoot = mapRoot; - this._sourceRoot = sourceRoot; - this._generateDeclarationFiles = generateDeclarationFiles; - this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this._gatherDiagnostics = gatherDiagnostics; - this._codepage = codepage; - } - ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { - return this._propagateEnumConstants; - }; - ImmutableCompilationSettings.prototype.removeComments = function () { - return this._removeComments; - }; - ImmutableCompilationSettings.prototype.watch = function () { - return this._watch; - }; - ImmutableCompilationSettings.prototype.noResolve = function () { - return this._noResolve; - }; - ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - ImmutableCompilationSettings.prototype.noImplicitAny = function () { - return this._noImplicitAny; - }; - ImmutableCompilationSettings.prototype.noLib = function () { - return this._noLib; - }; - ImmutableCompilationSettings.prototype.codeGenTarget = function () { - return this._codeGenTarget; - }; - ImmutableCompilationSettings.prototype.moduleGenTarget = function () { - return this._moduleGenTarget; - }; - ImmutableCompilationSettings.prototype.outFileOption = function () { - return this._outFileOption; - }; - ImmutableCompilationSettings.prototype.outDirOption = function () { - return this._outDirOption; - }; - ImmutableCompilationSettings.prototype.mapSourceFiles = function () { - return this._mapSourceFiles; - }; - ImmutableCompilationSettings.prototype.mapRoot = function () { - return this._mapRoot; - }; - ImmutableCompilationSettings.prototype.sourceRoot = function () { - return this._sourceRoot; - }; - ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { - return this._generateDeclarationFiles; - }; - ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { - return this._useCaseSensitiveFileResolution; - }; - ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { - return this._gatherDiagnostics; - }; - ImmutableCompilationSettings.prototype.codepage = function () { - return this._codepage; - }; - - ImmutableCompilationSettings.defaultSettings = function () { - if (!ImmutableCompilationSettings._defaultSettings) { - ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); - } - - return ImmutableCompilationSettings._defaultSettings; - }; - - 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); - }; - - ImmutableCompilationSettings.prototype.toCompilationSettings = function () { - var result = new CompilationSettings(); - - for (var name in this) { - if (this.hasOwnProperty(name) && TypeScript.StringUtilities.startsWith(name, "_")) { - result[name.substr(1)] = this[name]; - } - } - - return result; - }; - return ImmutableCompilationSettings; - })(); - TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; - - PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; - - PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; - - PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; - - PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - function hasModifier(modifiers, flag) { - for (var i = 0, n = modifiers.length; i < n; i++) { - if (TypeScript.hasFlag(modifiers[i], flag)) { - return true; - } - } - - return false; - } - TypeScript.hasModifier = hasModifier; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; - PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; - - 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["AcceptableAlias"] = PullElementKind.Variable | PullElementKind.SomeFunction | PullElementKind.Class | PullElementKind.Interface | PullElementKind.Enum | PullElementKind.Container | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "AcceptableAlias"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullDeclID = 0; - var sentinelEmptyPullDeclArray = []; - - var PullDecl = (function () { - function PullDecl(declName, displayName, kind, declFlags, span) { - this.declID = TypeScript.pullDeclID++; - this.flags = 0 /* None */; - this.declGroups = null; - this.childDecls = null; - this.typeParameters = null; - this.synthesizedValDecl = null; - this.childDeclTypeCache = null; - this.childDeclValueCache = null; - this.childDeclNamespaceCache = null; - this.childDeclTypeParameterCache = null; - this.name = declName; - this.kind = kind; - this.flags = declFlags; - this.span = span; - - if (displayName !== this.name) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.fileName = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentPath = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.semanticInfoChain = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.isExternalModule = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getEnclosingDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { - var decl = this; - while (decl) { - switch (decl.kind) { - default: - return decl; - case 512 /* Variable */: - case 8192 /* TypeParameter */: - case 2048 /* Parameter */: - case 128 /* TypeAlias */: - case 67108864 /* EnumMember */: - } - - decl = decl.getParentDecl(); - } - - TypeScript.Debug.fail(); - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.name : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (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(); - binder.bindDeclToPullSymbol(this); - } - }; - - PullDecl.prototype.getSymbol = function () { - if (this.kind == 1 /* Script */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.semanticInfoChain().getSymbolForDecl(this); - }; - - PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain().getSymbolForDecl(this); - return !!symbol; - }; - - PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain().setSignatureSymbolForDecl(this, signatureSymbol); - }; - - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(true); - - return this.semanticInfoChain().getSignatureSymbolForDecl(this); - }; - - PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain().getSignatureSymbolForDecl(this); - return !!signatureSymbol; - }; - - PullDecl.prototype.setFlags = function (flags) { - this.flags = flags; - }; - - PullDecl.prototype.setFlag = function (flags) { - this.flags |= flags; - }; - - PullDecl.prototype.getSpan = function () { - return this.span; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - }; - - 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.getChildDeclCache = function (declKind) { - if (declKind === 8192 /* TypeParameter */) { - if (!this.childDeclTypeParameterCache) { - this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeParameterCache; - } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { - if (!this.childDeclNamespaceCache) { - this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728539 /* SomeType */)) { - if (!this.childDeclTypeCache) { - this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeCache; - } else { - if (!this.childDeclValueCache) { - this.childDeclValueCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclValueCache; - } - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.kind === 8192 /* TypeParameter */) { - if (!this.typeParameters) { - this.typeParameters = []; - } - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - if (!this.childDecls) { - this.childDecls = []; - } - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.name; - - if (!(childDecl.kind & 7340032 /* SomeSignature */)) { - var cache = this.getChildDeclCache(childDecl.kind); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - } - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cacheVal = null; - - if (searchKind & 58728539 /* SomeType */) { - cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; - } else if (searchKind & 164 /* SomeContainer */) { - cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; - } else { - cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; - } - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & 58728539 /* SomeType */) { - cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; - - if (cacheVal) { - return cacheVal; - } - } - - return sentinelEmptyPullDeclArray; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls ? this.childDecls : sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters ? this.typeParameters : sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - if (!this.declGroups) { - this.declGroups = TypeScript.createIntrinsicsObject(); - } - - var declGroup = this.declGroups[decl.name]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.name); - declGroup.addDecl(decl); - this.declGroups[decl.name] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = null; - - if (this.declGroups) { - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - if (declGroups === null) { - declGroups = []; - } - - declGroups.push(this.declGroups[declName].getDecls()); - } - } - } - - return declGroups ? declGroups : sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.hasBeenBound = function () { - return this.hasSymbol() || this.hasSignatureSymbol(); - }; - - PullDecl.prototype.isSynthesized = function () { - return false; - }; - - PullDecl.prototype.ast = function () { - var semanticInfoChain = this.semanticInfoChain(); - return semanticInfoChain ? semanticInfoChain.getASTForDecl(this) : null; - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - 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; - this._isExternalModule = isExternalModule; - this._fileName = fileName; - } - RootPullDecl.prototype.fileName = function () { - return this._fileName; - }; - - RootPullDecl.prototype.getParentPath = function () { - return [this]; - }; - - RootPullDecl.prototype.getParentDecl = function () { - return null; - }; - - RootPullDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - - RootPullDecl.prototype.isExternalModule = function () { - return this._isExternalModule; - }; - - RootPullDecl.prototype.getEnclosingDecl = function () { - return this; - }; - return RootPullDecl; - })(PullDecl); - TypeScript.RootPullDecl = RootPullDecl; - - var NormalPullDecl = (function (_super) { - __extends(NormalPullDecl, _super); - function NormalPullDecl(declName, displayName, kind, declFlags, parentDecl, span, addToParent) { - if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, span); - this.parentDecl = null; - this.parentPath = null; - - this.parentDecl = parentDecl; - if (addToParent) { - parentDecl.addChildDecl(this); - } - } - NormalPullDecl.prototype.fileName = function () { - return this.parentDecl ? this.parentDecl.fileName() : ""; - }; - - NormalPullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - NormalPullDecl.prototype.getParentPath = function () { - if (!this.parentPath) { - var path = [this]; - var parentDecl = this.parentDecl; - - while (parentDecl) { - if (parentDecl && path[path.length - 1] != parentDecl && !(parentDecl.kind & 256 /* ObjectLiteral */)) { - path.unshift(parentDecl); - } - - parentDecl = parentDecl.getParentDecl(); - } - - this.parentPath = path; - } - - return this.parentPath; - }; - - NormalPullDecl.prototype.semanticInfoChain = function () { - var parent = this.getParentDecl(); - return parent ? parent.semanticInfoChain() : null; - }; - - NormalPullDecl.prototype.isExternalModule = function () { - return false; - }; - - NormalPullDecl.prototype.getEnclosingDecl = function () { - return this.parentDecl && this.parentDecl._getEnclosingDeclFromParentDecl(); - }; - 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); - this.constantValue = null; - } - return PullEnumElementDecl; - })(NormalPullDecl); - TypeScript.PullEnumElementDecl = PullEnumElementDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, span, displayName) { - if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl, span); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(NormalPullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - 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; - } - PullSynthesizedDecl.prototype.semanticInfoChain = function () { - return this._semanticInfoChain; - }; - - PullSynthesizedDecl.prototype.isSynthesized = function () { - return true; - }; - return PullSynthesizedDecl; - })(NormalPullDecl); - TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.name === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (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._container = null; - this.type = null; - this._declarations = null; - this.isResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isVarArg = false; - this.rootSymbol = null; - this._enclosingSignature = null; - this._docComments = null; - this.isPrinting = false; - this.name = name; - this.kind = declKind; - } - PullSymbol.prototype.isAny = function () { - return false; - }; - - PullSymbol.prototype.isType = function () { - return (this.kind & 58728539 /* SomeType */) != 0; - }; - - PullSymbol.prototype.isTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) != 0; - }; - - PullSymbol.prototype.isArrayNamedTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.kind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isInterface = function () { - return this.kind === 16 /* Interface */; - }; - - PullSymbol.prototype.isMethod = function () { - return this.kind === 65536 /* Method */; - }; - - PullSymbol.prototype.isProperty = function () { - return this.kind === 4096 /* Property */; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { - if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } - if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } - var scopeDeclarations = scopeSymbol.getDeclarations(); - var scopeSymbolAliasesToLookIn = []; - - for (var i = 0; i < scopeDeclarations.length; i++) { - var scopeDecl = scopeDeclarations[i]; - if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { - visitedScopeDeclarations.push(scopeDecl); - - var childDecls = scopeDecl.getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - var childDecl = childDecls[j]; - if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { - var symbol = childDecl.getSymbol(); - - if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { - aliasSymbols.push(symbol); - return aliasSymbols; - } - - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind == 32 /* DynamicModule */))) { - scopeSymbolAliasesToLookIn.push(symbol); - } - } - } - } - } - - for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { - var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; - - aliasSymbols.push(scopeSymbolAlias); - var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); - if (result) { - return result; - } - - aliasSymbols.pop(); - } - - return null; - }; - - PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { - var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); - return symbols; - } - - return null; - }; - - PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { - if (aliasSymbol) { - if (aliasSymbol.assignedValue()) { - return false; - } - - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() != aliasSymbol.assignedContainer()) { - return false; - } - - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind != 32 /* DynamicModule */) { - return false; - } - - return true; - } - - return false; - }; - - PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { - if (scopeSymbol) { - 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); - return internalAliases[0]; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { - if (!skipInternalAlias) { - var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); - if (internalAlias) { - return aliasNameGetter(internalAlias); - } - } - - var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); - - if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - var aliasFullName = ""; - for (var i = 1, symbolsLen = externalAliases.length; i < symbolsLen; i++) { - aliasFullName = aliasFullName + "." + aliasPartsNameGetter(externalAliases[i]); - } - return aliasNameGetter(externalAliases[0]) + aliasFullName; - } - - return null; - }; - - PullSymbol.prototype._getResolver = function () { - TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain().getResolver(); - }; - - PullSymbol.prototype._resolveDeclaredSymbol = function () { - return this._getResolver().resolveDeclaredSymbol(this); - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getName(); - }); - if (aliasName != null) { - return aliasName; - } - - return this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getDisplayName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getDisplayName(); - }, skipInternalAliasName); - if (aliasDisplayName != null) { - return aliasDisplayName; - } - - var decls = this.getDeclarations(); - var name = decls.length && decls[0].getDisplayName(); - - return (name && name.length) ? name : this.name; - }; - - PullSymbol.prototype.getIsSpecialized = function () { - return false; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - PullSymbol.prototype.setIsSynthesized = function (value) { - if (typeof value === "undefined") { value = true; } - this.isSynthesized = value; - }; - - PullSymbol.prototype.getIsSynthesized = function () { - return this.isSynthesized; - }; - - PullSymbol.prototype.setEnclosingSignature = function (signature) { - this._enclosingSignature = signature; - }; - - PullSymbol.prototype.getEnclosingSignature = function () { - return this._enclosingSignature; - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - if (!this._declarations) { - this._declarations = [decl]; - } else { - this._declarations[this._declarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this._declarations) { - this._declarations = []; - } - - return this._declarations; - }; - - PullSymbol.prototype.hasDeclaration = function (decl) { - if (!this._declarations) { - return false; - } - - return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { - return eachDecl === decl; - }); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - if (this.rootSymbol) { - return; - } - - this._container = containerSymbol; - }; - - PullSymbol.prototype.getContainer = function () { - if (this.rootSymbol) { - return this.rootSymbol.getContainer(); - } - - return this._container; - }; - - PullSymbol.prototype.setResolved = function () { - this.isResolved = true; - this.inResolution = false; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.isResolved = false; - this.inResolution = false; - }; - - PullSymbol.prototype.anyDeclHasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (TypeScript.hasFlag(declarations[i].flags, flag)) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!TypeScript.hasFlag(declarations[i].flags, flag)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = node.getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - var nodeKind = node.kind; - if (nodeKind == 2048 /* Parameter */) { - break; - } else { - node = node.getContainer(); - } - } - return path; - }; - - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } - - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } - - 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; - } - } - } - if (commonNodeIndex >= 0) { - break; - } - } - - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); - } else { - return aPath; - } - }; - - PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var str = this.getNameAndTypeName(scopeSymbol); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var path = this.pathToRoot(); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName != null) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName != null) { - fullName = aliasFullName + "." + fullName; - break; - } - - var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind == 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findCommonAncestorPath(scopeSymbol); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName != null) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].kind; - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName != null) { - fullName = aliasFullName + "." + fullName; - break; - } - - if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.type; - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - 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 */) { - var signatures = type.getCallSignatures(); - 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); - return typeName; - } - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.type; - var nameStr = this.getDisplayName(scopeSymbol); - if (type) { - nameStr = nameStr + (this.isOptional ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return TypeScript.MemberName.create(nameStr); - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - - inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); - - var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); - inIsExternallyVisibleSymbols.pop(); - - return result; - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.kind; - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.rootSymbol) { - return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); - } - - if (this.isType()) { - var associatedContainerSymbol = this.getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.anyDeclHasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - var decls = this.getDeclarations(); - if (decls.length) { - var parentDecl = decls[0].getParentDecl(); - if (parentDecl) { - var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind == 1 /* Script */) { - return true; - } - - return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); - } - } - - return true; - } - - 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 */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { - var ast = decl.ast(); - - if (ast) { - var enclosingModuleDeclaration = TypeScript.getEnclosingModuleDeclaration(ast); - if (TypeScript.isLastNameOfModule(enclosingModuleDeclaration, ast)) { - return TypeScript.docComments(enclosingModuleDeclaration); - } - - if (ast.kind() != 130 /* ModuleDeclaration */ || decl.kind != 512 /* Variable */) { - return TypeScript.docComments(ast); - } - } - - return []; - }; - - PullSymbol.prototype.getDocCommentArray = function (symbol) { - var docComments = []; - if (!symbol) { - return docComments; - } - - 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 */) { - continue; - } - docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); - } - return docComments; - }; - - PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { - if (classSymbol.getHasDefaultConstructor()) { - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); - } - } - - return classSymbol.type.getConstructSignatures()[0]; - }; - - PullSymbol.prototype.getDocCommentText = function (comments) { - var docCommentText = new Array(); - for (var c = 0; c < comments.length; c++) { - var commentText = this.getDocCommentTextValue(comments[c]); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - PullSymbol.prototype.getDocCommentTextValue = function (comment) { - return this.cleanJSDocComment(comment.fullText()); - }; - - PullSymbol.prototype.docComments = function (useConstructorAsClass) { - var decls = this.getDeclarations(); - 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 */) { - var classSymbol = this.returnType; - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - docComments = extendedTypes[0].getConstructorMethod().docComments(); - } else { - docComments = ""; - } - } else if (this.kind == 2048 /* Parameter */) { - var parameterComments = []; - - var funcContainer = this.getEnclosingSignature(); - var funcDocComments = this.getDocCommentArray(funcContainer); - var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); - if (paramComment != "") { - parameterComments.push(paramComment); - } - - var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); - if (paramSelfComment != "") { - parameterComments.push(paramSelfComment); - } - docComments = parameterComments.join("\n"); - } else { - var getSymbolComments = true; - if (this.kind == 16777216 /* FunctionType */) { - var functionSymbol = this.getFunctionSymbol(); - - if (functionSymbol) { - docComments = functionSymbol._docComments || ""; - getSymbolComments = false; - } else { - var declarationList = this.getDeclarations(); - if (declarationList.length > 0) { - docComments = declarationList[0].getSymbol()._docComments || ""; - getSymbolComments = false; - } - } - } - if (getSymbolComments) { - docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments == "") { - if (this.kind == 1048576 /* CallSignature */) { - var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length == 1) { - docComments = callTypeSymbol.docComments(); - } - } - } - } - } - - this._docComments = docComments; - } - - return this._docComments; - }; - - PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].fullText(); - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!this.isSpaceChar(commentContents, j)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - - PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = new Array(); - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.start; - for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.end); - } - - var newCleanPos = this.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - PullSymbol.prototype.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = this.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - start: nonSpaceIndex, - end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - function PullSignatureSymbol(kind) { - _super.call(this, "", kind); - this._memberTypeParameterNameCache = null; - this._stringConstantOverload = undefined; - this.parameters = TypeScript.sentinelEmptyArray; - this.typeParameters = null; - this.returnType = null; - this.functionType = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this.hasAGenericParameter = false; - this.hasBeenChecked = false; - this.inWrapCheck = false; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return false; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - return this.hasAGenericParameter || (this.typeParameters && this.typeParameters.length != 0); - }; - - PullSignatureSymbol.prototype.addParameter = function (parameter, isOptional) { - if (typeof isOptional === "undefined") { isOptional = false; } - if (this.parameters == TypeScript.sentinelEmptyArray) { - this.parameters = []; - } - - this.parameters[this.parameters.length] = parameter; - this.hasOptionalParam = isOptional; - - if (!parameter.getEnclosingSignature()) { - parameter.setEnclosingSignature(this); - } - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this.typeParameters) { - this.typeParameters = []; - } - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - this.typeParameters[this.typeParameters.length] = typeParameter; - - this._memberTypeParameterNameCache[typeParameter.getName()] = typeParameter; - }; - - PullSignatureSymbol.prototype.getTypeParameters = function () { - if (!this.typeParameters) { - this.typeParameters = []; - } - - return this.typeParameters; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - 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]; - } - } - } - - memberSymbol = this._memberTypeParameterNameCache[name]; - - return memberSymbol; - }; - - PullSignatureSymbol.prototype.isStringConstantOverloadSignature = function () { - if (this._stringConstantOverload === undefined) { - var params = this.parameters; - this._stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].type; - if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { - this._stringConstantOverload = true; - } - } - } - - return this._stringConstantOverload; - }; - - PullSignatureSymbol.getSignatureTypeMemberName = function (candidateSignature, signatures, scopeSymbol) { - var allMemberNames = new TypeScript.MemberNameArray(); - var signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(signatures, "", false, false, scopeSymbol, true, candidateSignature); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - if (!signatures) { - return result; - } - - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.parameters; - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].type; - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].isVarArg; - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - if (this.returnType) { - builder.add(this.returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - return builder; - }; - - PullSignatureSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { - var signature = this; - if (signature.inWrapCheck) { - return false; - } - - signature.inWrapCheck = true; - - 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; - } - } - } - - signature.inWrapCheck = false; - - return wrapsSomeTypeParameter; - }; - - PullSignatureSymbol.prototype.wrapsSomeNestedTypeIntoInfiniteExpansion = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - if (this.inWrapCheck) { - return isCheckingTypeArgumentList; - } - - if (knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID) != undefined) { - return knownWrapMap.valueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID); - } - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, isCheckingTypeArgumentList); - - this.inWrapCheck = true; - - var wrapsSomeWrappedTypeParameter = false; - - if (this.returnType && this.returnType._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap)) { - wrapsSomeWrappedTypeParameter = true; - } - - if (!wrapsSomeWrappedTypeParameter) { - 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; - } - } - } - - knownWrapMap.setValueAt(this.pullSymbolID, typeBeingWrapped.pullSymbolID, wrapsSomeWrappedTypeParameter); - - this.inWrapCheck = false; - - return wrapsSomeWrappedTypeParameter; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol(name, kind) { - _super.call(this, name, kind); - this._members = TypeScript.sentinelEmptyArray; - this._enclosedMemberTypes = null; - this._enclosedMemberContainers = null; - this._typeParameters = null; - this._specializedVersionsOfThisType = null; - this._arrayVersionOfThisType = null; - this._implementedTypes = null; - this._extendedTypes = null; - this._typesThatExplicitlyImplementThisType = null; - this._typesThatExtendThisType = null; - this._callSignatures = null; - this._allCallSignatures = null; - this._constructSignatures = null; - this._indexSignatures = null; - this._allIndexSignatures = null; - this._memberNameCache = null; - this._enclosedTypeNameCache = null; - this._enclosedContainerCache = null; - this._typeParameterNameCache = null; - this._containedNonMemberNameCache = null; - this._containedNonMemberTypeNameCache = null; - this._containedNonMemberContainerCache = null; - this._simpleInstantiationCache = null; - this._complexInstantiationCache = null; - this._hasGenericSignature = false; - this._hasGenericMember = false; - this._hasBaseTypeConflict = false; - this._knownBaseTypeCount = 0; - this._associatedContainerTypeSymbol = null; - this._constructorMethod = null; - this._hasDefaultConstructor = false; - this._functionSymbol = null; - this._inMemberTypeNameEx = false; - this.inSymbolPrivacyCheck = false; - this.inWrapCheck = false; - this.typeReference = null; - this._isArrayNamedTypeReference = undefined; - this.type = this; - } - PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArrayNamedTypeReference === undefined) { - this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); - } - - return this._isArrayNamedTypeReference; - }; - - 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) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.kind == 8 /* Class */ || (this._constructorMethod != null); - }; - PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) != 0; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return this.kind == 33554432 /* ConstructorType */; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - PullTypeSymbol.prototype.isEnum = function () { - return this.kind == 64 /* Enum */; - }; - - PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { - return null; - }; - - PullTypeSymbol.prototype.isObject = function () { - return TypeScript.hasFlag(this.kind, 8 /* Class */ | 33554432 /* ConstructorType */ | 64 /* Enum */ | 16777216 /* FunctionType */ | 16 /* Interface */ | 8388608 /* ObjectType */); - }; - - PullTypeSymbol.prototype.getKnownBaseTypeCount = function () { - return this._knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this._knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this._knownBaseTypeCount++; - }; - - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.hasMembers = function () { - if (this._members != TypeScript.sentinelEmptyArray) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this._hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this._hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this._hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this._hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this._associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this._associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this._arrayVersionOfThisType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - return null; - }; - - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this._arrayVersionOfThisType = arrayType; - }; - - PullTypeSymbol.prototype.getFunctionSymbol = function () { - return this._functionSymbol; - }; - - PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { - if (symbol) { - this._functionSymbol = symbol; - } - }; - - PullTypeSymbol.prototype.findContainedNonMember = function (name) { - if (!this._containedNonMemberNameCache) { - return null; - } - - return this._containedNonMemberNameCache[name]; - }; - - PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberTypeNameCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberContainerCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - - if (nonMemberSymbol && kind != 0 /* None */) { - nonMemberSymbol = ((nonMemberSymbol.kind & kind) != 0) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol) { - if (!memberSymbol) { - return; - } - - memberSymbol.setContainer(this); - - if (!this._memberNameCache) { - this._memberNameCache = TypeScript.createIntrinsicsObject(); - } - - if (this._members === TypeScript.sentinelEmptyArray) { - this._members = []; - } - - this._members.push(memberSymbol); - this._memberNameCache[memberSymbol.name] = memberSymbol; - }; - - PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - if (!enclosedType) { - return; - } - - enclosedType.setContainer(this); - - if (!this._enclosedTypeNameCache) { - this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberTypes) { - this._enclosedMemberTypes = []; - } - - this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; - this._enclosedTypeNameCache[enclosedType.name] = enclosedType; - }; - - PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - if (!enclosedContainer) { - return; - } - - enclosedContainer.setContainer(this); - - if (!this._enclosedContainerCache) { - this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberContainers) { - this._enclosedMemberContainers = []; - } - - this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; - this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; - }; - - PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - if (!enclosedNonMember) { - return; - } - - enclosedNonMember.setContainer(this); - - if (!this._containedNonMemberNameCache) { - this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - if (!enclosedNonMemberType) { - return; - } - - enclosedNonMemberType.setContainer(this); - - if (!this._containedNonMemberTypeNameCache) { - this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - if (!enclosedNonMemberContainer) { - return; - } - - enclosedNonMemberContainer.setContainer(this); - - if (!this._containedNonMemberContainerCache) { - this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; - }; - - PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!typeParameter) { - return; - } - - if (!typeParameter.getContainer()) { - typeParameter.setContainer(this); - } - - if (!this._typeParameterNameCache) { - this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._typeParameters) { - this._typeParameters = []; - } - - this._typeParameters[this._typeParameters.length] = typeParameter; - 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; - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this._hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this._hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this._constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this._constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - if (!this._typeParameters) { - return TypeScript.sentinelEmptyArray; - } - - return this._typeParameters; - }; - - 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; - } - - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { - if (!this._simpleInstantiationCache) { - this._simpleInstantiationCache = []; - } - - this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID] = specializedVersionOfThisType; - } else { - if (!this._complexInstantiationCache) { - this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); - } - - this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)] = specializedVersionOfThisType; - } - - if (!this._specializedVersionsOfThisType) { - this._specializedVersionsOfThisType = []; - } - - this._specializedVersionsOfThisType.push(specializedVersionOfThisType); - }; - - PullTypeSymbol.prototype.getSpecialization = function (substitutingTypes) { - if (!substitutingTypes || !substitutingTypes.length) { - return null; - } - - if (this.canUseSimpleInstantiationCache(substitutingTypes)) { - if (!this._simpleInstantiationCache) { - return null; - } - - var result = this._simpleInstantiationCache[substitutingTypes[0].pullSymbolID]; - return result ? result : null; - } else { - if (!this._complexInstantiationCache) { - return null; - } - - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(substitutingTypes)]; - return result ? result : null; - } - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - if (!this._specializedVersionsOfThisType) { - return TypeScript.sentinelEmptyArray; - } - - return this._specializedVersionsOfThisType; - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return null; - }; - - PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeParameters(); - }; - - PullTypeSymbol.prototype.addCallSignature = function (callSignature) { - if (!this._callSignatures) { - this._callSignatures = []; - } - - this._callSignatures[this._callSignatures.length] = callSignature; - - if (callSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - callSignature.functionType = this; - }; - - PullTypeSymbol.prototype.addConstructSignature = function (constructSignature) { - if (!this._constructSignatures) { - this._constructSignatures = []; - } - - this._constructSignatures[this._constructSignatures.length] = constructSignature; - - if (constructSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - constructSignature.functionType = this; - }; - - PullTypeSymbol.prototype.addIndexSignature = function (indexSignature) { - if (!this._indexSignatures) { - this._indexSignatures = []; - } - - this._indexSignatures[this._indexSignatures.length] = indexSignature; - - if (indexSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - 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.getCallSignatures = function () { - if (this._allCallSignatures) { - return this._allCallSignatures; - } - - var signatures = []; - - if (this._callSignatures) { - signatures = signatures.concat(this._callSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this.addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); - } - } - - this._allCallSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return this._constructSignatures !== null; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function () { - var signatures = []; - - if (this._constructSignatures) { - signatures = signatures.concat(this._constructSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this.addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); - } - } - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return this._indexSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnIndexSignatures = function () { - return this._indexSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function () { - if (this._allIndexSignatures) { - return this._allIndexSignatures; - } - - var signatures = []; - - if (this._indexSignatures) { - signatures = signatures.concat(this._indexSignatures); - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this.addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); - } - } - - this._allIndexSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.addImplementedType = function (implementedType) { - if (!implementedType) { - return; - } - - if (!this._implementedTypes) { - this._implementedTypes = []; - } - - this._implementedTypes[this._implementedTypes.length] = implementedType; - - implementedType.addTypeThatExplicitlyImplementsThisType(this); - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - if (!this._implementedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._implementedTypes; - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!extendedType) { - return; - } - - if (!this._extendedTypes) { - this._extendedTypes = []; - } - - this._extendedTypes[this._extendedTypes.length] = extendedType; - - extendedType.addTypeThatExtendsThisType(this); - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - if (!this._extendedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._extendedTypes; - }; - - PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - return this._typesThatExtendThisType; - }; - - PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - return this._typesThatExplicitlyImplementThisType; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { - return true; - } - - if (TypeScript.ArrayUtilities.contains(visited, this)) { - return true; - } - - visited.push(this); - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - visited.pop(); - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.kind === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - var memberSymbol = null; - - if (this._memberNameCache) { - memberSymbol = this._memberNameCache[name]; - } - - if (memberSymbol || !lookInParent) { - return memberSymbol; - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return null; - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedTypeNameCache) { - return null; - } - - memberSymbol = this._enclosedTypeNameCache[name]; - - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedContainerCache) { - return null; - } - - memberSymbol = this._enclosedContainerCache[name]; - - if (memberSymbol && kind != 0 /* None */) { - memberSymbol = ((memberSymbol.kind & kind) != 0) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - var allMembers = []; - - 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 */))) { - allMembers[allMembers.length] = member; - } - } - } - - if (this._extendedTypes) { - var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; - - for (var i = 0, n = this._extendedTypes.length; i < n; i++) { - var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - if (this.isContainer()) { - if (this._enclosedMemberTypes) { - for (var i = 0; i < this._enclosedMemberTypes.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberTypes[i]; - } - } - if (this._enclosedMemberContainers) { - for (var i = 0; i < this._enclosedMemberContainers.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberContainers[i]; - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - if (!this._typeParameterNameCache) { - return null; - } - - return this._typeParameterNameCache[name]; - }; - - PullTypeSymbol.prototype.setResolved = function () { - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArgumentsOrTypeParameters(); - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); - }; - - 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 != "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); - return s; - }; - - PullTypeSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - if (this.isArrayNamedTypeReference()) { - 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, "", "[]"); - } - - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - if (skipTypeParametersInName) { - return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); - } else { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - - var typars = this.getTypeArgumentsOrTypeParameters(); - builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - } - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getTypeOfSymbol = function () { - var associatedContainerType = this.getAssociatedContainerType(); - if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { - return associatedContainerType; - } - - var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind == 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return functionSymbol; - } - - return null; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var typeOfSymbol = this.getTypeOfSymbol(); - if (typeOfSymbol) { - var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); - return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); - } - - if (this._inMemberTypeNameEx) { - return TypeScript.MemberName.create("any"); - } - - this._inMemberTypeNameEx = true; - - var allMemberNames = new TypeScript.MemberNameArray(); - 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()) { - var methodCallSignatures = members[i].type.getCallSignatures(); - var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); - ; - var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); - allMemberNames.addAll(methodMemberNames); - } else { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - if (memberTypeName.isArray() && memberTypeName.delim === delim) { - allMemberNames.addAll(memberTypeName.entries); - } else { - allMemberNames.add(memberTypeName); - } - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - this._inMemberTypeNameEx = false; - - return allMemberNames; - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - return 2 /* Closed */; - }; - - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap) { - var type = this; - - var wrapsSomeTypeParameter = false; - - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID]) { - return true; - } - - var constraint = type.getConstraint(); - - if (constraint && constraint.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return true; - } - - return false; - } - - if (type.inWrapCheck) { - return wrapsSomeTypeParameter; - } - - type.inWrapCheck = true; - - if (!wrapsSomeTypeParameter) { - var typeArguments = type.getTypeArguments(); - - if (type.isGeneric() && !typeArguments) { - typeArguments = type.getTypeParameters(); - } - - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i].wrapsSomeTypeParameter(typeParameterArgumentMap)) { - wrapsSomeTypeParameter = true; - break; - } - } - } - } - - 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 (!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; - } - } - } - } - - type.inWrapCheck = false; - - return wrapsSomeTypeParameter; - }; - - 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.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; - } - } - - 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()) { - return false; - } - - this.inWrapCheck = true; - - 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; - }; - - PullTypeSymbol.prototype._wrapsSomeNestedTypeIntoInfiniteExpansionWorker = function (typeBeingWrapped, isCheckingTypeArgumentList, knownWrapMap) { - var typeArguments = this.getTypeArguments(); - if (typeArguments) { - for (var i = 0; i < typeArguments.length; i++) { - if (typeArguments[i]._wrapsSomeNestedTypeIntoInfiniteExpansionRecurse(typeBeingWrapped, true, knownWrapMap)) { - return true; - } - } - } - - if (this.anyRootTypeBeingWrapped(typeBeingWrapped)) { - if (isCheckingTypeArgumentList && this.isTypeReference() && !this.getIsSpecialized()) { - 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 PullTypeSymbol; - })(PullSymbol); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - - this.isResolved = true; - } - PullPrimitiveTypeSymbol.prototype.isAny = function () { - return this.name === "any"; - }; - - PullPrimitiveTypeSymbol.prototype.isStringConstant = function () { - return false; - }; - - PullPrimitiveTypeSymbol.prototype.setUnresolved = function () { - }; - return PullPrimitiveTypeSymbol; - })(PullTypeSymbol); - TypeScript.PullPrimitiveTypeSymbol = PullPrimitiveTypeSymbol; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(anyType, name) { - _super.call(this, name); - this.anyType = anyType; - - this.isResolved = true; - } - PullErrorTypeSymbol.prototype.isError = function () { - return true; - }; - - PullErrorTypeSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this.anyType.getName(scopeSymbol, useConstraintInName); - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullContainerSymbol = (function (_super) { - __extends(PullContainerSymbol, _super); - function PullContainerSymbol(name, kind) { - _super.call(this, name, kind); - this.instanceSymbol = null; - this.assignedValue = null; - this.assignedType = null; - this.assignedContainer = null; - } - PullContainerSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this.assignedValue = symbol; - }; - - PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { - return this.assignedValue; - }; - - PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this.assignedType = type; - }; - - PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this.assignedType; - }; - - PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this.assignedContainer = container; - }; - - PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this.assignedContainer; - }; - - PullContainerSymbol.prototype.hasExportAssignment = function () { - return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; - }; - - PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (!containerSymbol.isAlias() && containerSymbol.type == symbol) { - return true; - } - - var moduleSymbol = containerSymbol; - var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol == symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - - PullContainerSymbol.prototype.getInstanceType = function () { - return this.instanceSymbol ? this.instanceSymbol.type : null; - }; - return PullContainerSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerSymbol = PullContainerSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 128 /* TypeAlias */); - this._assignedValue = null; - this._assignedType = null; - this._assignedContainer = null; - this._isUsedAsValue = false; - this._typeUsedExternally = false; - this.retrievingExportAssignment = false; - } - PullTypeAliasSymbol.prototype.typeUsedExternally = function () { - this._resolveDeclaredSymbol(); - return this._typeUsedExternally; - }; - - PullTypeAliasSymbol.prototype.isUsedAsValue = function () { - this._resolveDeclaredSymbol(); - return this._isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function (value) { - this._typeUsedExternally = value; - }; - - PullTypeAliasSymbol.prototype.setIsUsedAsValue = function (value) { - this._isUsedAsValue = value; - - 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.assignedValue = function () { - this._resolveDeclaredSymbol(); - return this._assignedValue; - }; - - PullTypeAliasSymbol.prototype.assignedType = function () { - this._resolveDeclaredSymbol(); - return this._assignedType; - }; - - PullTypeAliasSymbol.prototype.assignedContainer = function () { - this._resolveDeclaredSymbol(); - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { - this._assignedValue = symbol; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (this._assignedValue) { - return this._assignedValue; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { - this._assignedType = type; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedType) { - if (this._assignedType.isAlias()) { - this.retrievingExportAssignment = true; - var sym = this._assignedType.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - } else if (this._assignedType != this._assignedContainer) { - return this._assignedType; - } - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { - this._assignedContainer = container; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this._assignedType) { - return this._assignedType.getMembers(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this._assignedType) { - return this._assignedType.getCallSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this._assignedType) { - return this._assignedType.getConstructSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this._assignedType) { - return this._assignedType.getIndexSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this._assignedType) { - return this._assignedType.findMember(name, true); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedContainer(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { - if (this._assignedType) { - return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); - } - - return TypeScript.sentinelEmptyArray; - }; - return PullTypeAliasSymbol; - })(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) { - _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; - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - return this._constraint; - }; - - PullTypeParameterSymbol.prototype.getCallSignatures = function () { - if (this._constraint) { - return this._constraint.getCallSignatures(); - } - - return _super.prototype.getCallSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getConstructSignatures = function () { - if (this._constraint) { - return this._constraint.getConstructSignatures(); - } - - return _super.prototype.getConstructSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getIndexSignatures = function () { - if (this._constraint) { - return this._constraint.getIndexSignatures(); - } - - return _super.prototype.getIndexSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this._getterSymbol = null; - this._setterSymbol = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - if (!setter) { - return; - } - - this._setterSymbol = setter; - }; - - PullAccessorSymbol.prototype.getSetter = function () { - return this._setterSymbol; - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - if (!getter) { - return; - } - - this._getterSymbol = getter; - }; - - PullAccessorSymbol.prototype.getGetter = function () { - return this._getterSymbol; - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - function getIDForTypeSubstitutions(types) { - 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 + "#"; - } - } - } - - 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]); - } - } - } - - if (structure !== "") { - return "{" + structure + "}"; - } - - 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]); - } - } - - structure += ")" + getIDForTypeSubstitutions([signature.returnType]); - return structure; - } - - (function (GetAllMembersVisiblity) { - GetAllMembersVisiblity[GetAllMembersVisiblity["all"] = 0] = "all"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; - })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); - var GetAllMembersVisiblity = TypeScript.GetAllMembersVisiblity; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CandidateInferenceInfo = (function () { - function CandidateInferenceInfo() { - this.typeParameter = null; - this.isFixed = false; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - if (!this.isFixed) { - this.inferenceCandidates[this.inferenceCandidates.length] = candidate; - } - }; - return CandidateInferenceInfo; - })(); - TypeScript.CandidateInferenceInfo = CandidateInferenceInfo; - - var ArgumentInferenceContext = (function () { - function ArgumentInferenceContext(resolver, argumentsOrParameters) { - 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; - } - } - ArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { - return true; - } else { - this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); - return false; - } - }; - - ArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache.release(); - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - }; - - ArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.pullSymbolID]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.pullSymbolID] = info; - } - }; - - ArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.pullSymbolID]; - }; - - ArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate, fix) { - var info = this.getInferenceInfo(param); - - if (info) { - if (candidate) { - info.addCandidate(candidate); - } - - if (!info.isFixed) { - info.isFixed = fix; - } - } - }; - - ArgumentInferenceContext.prototype.getInferenceArgumentCount = function () { - if (this.fixedParameterTypes) { - return this.fixedParameterTypes.length; - } else { - return this.argumentASTs.nonSeparatorCount(); - } - }; - - 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; - - var results = []; - - var unfit = false; - - 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; - } - - 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 }; - } - } - - return { results: results, unfit: unfit }; - }; - return ArgumentInferenceContext; - })(); - TypeScript.ArgumentInferenceContext = ArgumentInferenceContext; - - var PullContextualTypeContext = (function () { - function PullContextualTypeContext(contextualType, provisional, substitutions) { - this.contextualType = contextualType; - this.provisional = provisional; - this.substitutions = substitutions; - this.provisionallyTypedSymbols = []; - this.hasProvisionalErrors = false; - this.astSymbolMap = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].setUnresolved(); - } - }; - - PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { - if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } - if (typeof fileName === "undefined") { fileName = null; } - this.resolver = resolver; - this.inTypeCheck = inTypeCheck; - this.fileName = fileName; - this.contextStack = []; - this.typeCheckedNodes = null; - this.inBaseTypeResolution = false; - if (inTypeCheck) { - TypeScript.Debug.assert(fileName, "A file name must be provided if you are typechecking"); - this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); - } - } - PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { - if (!this.inProvisionalResolution()) { - this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); - } - }; - - PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { - 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.popContextualType = function () { - var tc = this.contextStack.pop(); - - tc.invalidateProvisionallyTypedSymbols(); - - if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; - } - - return tc; - }; - - PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { - 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]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - if (type.isTypeParameter() && type.getConstraint()) { - type = type.getConstraint(); - } - - var substitution = this.findSubstitution(type); - - return substitution ? substitution : type; - } - - return null; - }; - - PullTypeResolutionContext.prototype.inProvisionalResolution = function () { - return (!this.contextStack.length ? false : this.contextStack[this.contextStack.length - 1].provisional); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, type) { - var substitution = this.findSubstitution(type); - - symbol.type = substitution ? substitution : type; - - if (this.contextStack.length && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].recordProvisionallyTypedSymbol(symbol); - } - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { - if (diagnostic) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; - } else if (this.inTypeCheck && this.resolver) { - this.resolver.semanticInfoChain.addDiagnostic(diagnostic); - } - } - }; - - PullTypeResolutionContext.prototype.typeCheck = function () { - return this.inTypeCheck && !this.inProvisionalResolution(); - }; - - PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { - this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); - }; - - PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - var typeContext = this.contextStack[i]; - if (!typeContext.provisional) { - break; - } - - var symbol = typeContext.getSymbolForAST(ast); - if (symbol) { - return symbol; - } - } - - return null; - }; - return PullTypeResolutionContext; - })(); - TypeScript.PullTypeResolutionContext = PullTypeResolutionContext; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OverloadApplicabilityStatus; - (function (OverloadApplicabilityStatus) { - OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; - })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - this.diagnosticsFromOverloadResolution = []; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var MemberWithBaseOrigin = (function () { - function MemberWithBaseOrigin(memberSymbol, baseOrigin) { - this.memberSymbol = memberSymbol; - this.baseOrigin = baseOrigin; - } - return MemberWithBaseOrigin; - })(); - - var SignatureWithBaseOrigin = (function () { - function SignatureWithBaseOrigin(signature, baseOrigin) { - this.signature = signature; - this.baseOrigin = baseOrigin; - } - return SignatureWithBaseOrigin; - })(); - - var InheritedIndexSignatureInfo = (function () { - function InheritedIndexSignatureInfo() { - } - 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 = {})); - - function getCompilerReservedName(name) { - var nameText = name.valueText(); - var index = CompilerReservedNames[nameText]; - return CompilerReservedNames[index] ? index : undefined; - } - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this._cachedAnyTypeArgs = null; - this.typeCheckCallBacks = []; - this.postTypeCheckWorkitems = []; - this._cachedFunctionArgumentsSymbol = null; - this.assignableCache = TypeScript.BitMatrix.getBitMatrix(true); - this.subtypeCache = TypeScript.BitMatrix.getBitMatrix(true); - this.identicalCache = TypeScript.BitMatrix.getBitMatrix(true); - } - PullTypeResolver.prototype.cachedArrayInterfaceType = function () { - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.getSymbolFromDeclPath("Array", [], 16 /* Interface */); - } - - if (!this._cachedArrayInterfaceType) { - this._cachedArrayInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getArrayNamedType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */); - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */); - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */); - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */); - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */); - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */); - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */); - } - - if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedRegExpInterfaceType; - }; - - 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.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, new TypeScript.TextSpan(0, 0), this.semanticInfoChain); - functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); - this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - } - - return this._cachedFunctionArgumentsSymbol; - }; - - PullTypeResolver.prototype.setTypeChecked = function (ast, context) { - context.setTypeChecked(ast); - }; - - PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { - return context.canTypeCheckAST(ast); - }; - - PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { - if (context && context.inProvisionalResolution()) { - context.setSymbolForAST(ast, symbol); - } else { - this.semanticInfoChain.setSymbolForAST(ast, symbol); - } - }; - - PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { - var symbol = this.semanticInfoChain.getSymbolForAST(ast); - - if (!symbol) { - if (context && context.inProvisionalResolution()) { - symbol = context.getSymbolForAST(ast); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { - if (typeof name === "undefined") { name = null; } - return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = decl.getParentPath(); - - if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) != 0; - var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; - - if (isContainer && containerType) { - if (symbol.anyDeclHasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getMemberSymbol = function (symbolName, declSearchKind, parent) { - var member = null; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728539 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - } - - if (parent.kind & 164 /* SomeContainer */) { - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - member = childDecls[0].getSymbol(); - - if (!member) { - member = childDecls[0].getSignatureSymbol(); - } - return this.getExportedMemberSymbol(member, parent); - } - - if ((declSearchKind & 58728539 /* SomeType */) != 0 || (declSearchKind & 68147712 /* SomeValue */) != 0) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, 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) { - var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); - if (typeSymbol) { - return typeSymbol; - } - } else { - var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); - if (valueSymbol) { - return valueSymbol; - } - } - } - } - } - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - var instanceType = null; - var childSymbol = null; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (pathDeclKind & (4 /* Container */ | 32 /* DynamicModule */)) { - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - return childDecls[0].getSymbol(); - } - - 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); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().type; - - var childSymbol = this.getMemberSymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } else if ((declSearchKind & (58728539 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.kind & 1032192 /* SomeFunction */) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - 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; - } - } - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - - return symbol; - }; - - PullTypeResolver.prototype.getVisibleDeclsFromDeclPath = function (declPath, declSearchKind) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - var declKind = decl.kind; - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = decl.getFunctionExpressionName(); - if (functionExpressionName) { - result.push(decl); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - } - } - - var topLevelDecls = this.semanticInfoChain.topLevelDecls(); - for (var i = 0, n = topLevelDecls.length; i < n; i++) { - var topLevelDecl = topLevelDecls[i]; - if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { - continue; - } - - if (!topLevelDecl.isExternalModule()) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.kind & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - 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 */)) { - return null; - } - - var lhsType = lhs.type; - if (!lhsType) { - return null; - } - - this.resolveDeclaredSymbol(lhsType, context); - - if (lhsType.isContainer() && lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - while (lhsType.isTypeParameter()) { - lhsType = lhsType.getConstraint(); - if (!lhsType) { - return null; - } - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - var memberVisibilty = 2 /* externallyVisible */; - var containerSymbol = lhsType; - if (containerSymbol.kind === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = enclosingDecl.getParentPath(); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { - memberVisibilty = 1 /* internallyVisible */; - break; - } - } - } - } - - var declSearchKind = 58728539 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - var members = []; - - if (lhsType.isContainer()) { - var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); - if (exportedAssignedContainerSymbol) { - lhsType = exportedAssignedContainerSymbol; - } - } - - if (lhsType.isTypeParameter()) { - var constraint = lhsType.getConstraint(); - - if (constraint) { - lhsType = constraint; - members = lhsType.getAllMembers(declSearchKind, 2 /* externallyVisible */); - } - } else { - if (lhs.kind == 67108864 /* EnumMember */) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - 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); - } - - 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); - } - } - } - - if ((lhsType.getCallSignatures().length || lhsType.getConstructSignatures().length) && this.cachedFunctionInterfaceType()) { - members = members.concat(this.cachedFunctionInterfaceType().getAllMembers(declSearchKind, 2 /* externallyVisible */)); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { - var originalIdText = idText; - var symbol = null; - - if (TypeScript.isRelative(originalIdText)) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - symbol = this.semanticInfoChain.findExternalModule(path + idText); - } else { - idText = originalIdText; - - symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); - - if (!symbol) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - symbol = this.semanticInfoChain.findExternalModule(path + idText); - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { - if (!symbol || symbol.isResolved || symbol.isTypeReference()) { - return symbol; - } - - if (!context) { - context = new TypeScript.PullTypeResolutionContext(this); - } - - return this.resolveDeclaredSymbolWorker(symbol, context); - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { - if (!symbol || symbol.isResolved) { - return symbol; - } - - if (symbol.inResolution) { - if (!symbol.type && !symbol.isType()) { - symbol.type = this.semanticInfoChain.anyTypeSymbol; - } - - return symbol; - } - - var decls = symbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - var ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return symbol; - } - - if (ast.kind() === 11 /* IdentifierName */ && ast.parent && ast.parent.kind() === 236 /* CatchClause */) { - return symbol; - } - - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(ast); - var resolvedSymbol; - if (TypeScript.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); - } - - if (decl.kind == 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { - symbol.type = resolvedSymbol.type; - symbol.setResolved(); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveOtherDeclarations = function (astName, context) { - 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); - } - } - } - }; - - PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { - var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); - var moduleSymbol = enclosingDecl.getSymbol(); - this.ensureAllSymbolsAreBound(moduleSymbol); - - this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); - this.resolveAST(sourceUnit.moduleElements, false, context); - - if (this.canTypeCheckAST(sourceUnit, context)) { - this.typeCheckSourceUnit(sourceUnit, context); - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.typeCheckSourceUnit = function (sourceUnit, context) { - this.setTypeChecked(sourceUnit, context); - - this.resolveAST(sourceUnit.moduleElements, false, context); - }; - - PullTypeResolver.prototype.resolveEnumDeclaration = function (ast, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - containerSymbol.setResolved(); - - this.resolveOtherDeclarations(ast, context); - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckEnumDeclaration(ast, context); - } - - return containerSymbol; - }; - - PullTypeResolver.prototype.typeCheckEnumDeclaration = function (ast, context) { - 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.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.resolveModuleDeclaration = function (ast, context) { - var result; - - if (ast.stringLiteral) { - result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckModuleDeclaration(ast, context); - } - - return result; - }; - - PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { - if (containerSymbol) { - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - }; - - PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - this.ensureAllSymbolsAreBound(containerSymbol); - - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, context); - } - - var isLastName = TypeScript.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); - if (isLastName) { - this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); - } else if (sourceUnitAST) { - this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); - } - - containerSymbol.setResolved(); - - if (moduleDeclNameAST) { - this.resolveOtherDeclarations(moduleDeclNameAST, context); - } - - return containerSymbol; - }; - - 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 */) { - this.resolveExportAssignmentStatement(moduleElement, context); - return; - } - } - }; - - PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - var containerSymbol = containerDecl.getSymbol(); - - return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); - }; - - PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { - if (ast.stringLiteral) { - this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - }; - - PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { - this.setTypeChecked(ast, context); - - if (TypeScript.isLastNameOfModule(ast, astName)) { - this.resolveAST(ast.moduleElements, false, context); - } - - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - this.validateVariableDeclarationGroups(containerDecl, context); - - if (ast.stringLiteral) { - if (TypeScript.isRelative(ast.stringLiteral.valueText())) { - this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); - } - } - - if (!TypeScript.moduleIsElided(ast) && !ast.stringLiteral) { - this.checkNameForCompilerGeneratedDeclarationCollision(astName, true, astName, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckModuleDeclaration = function (ast, context) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() == 11 /* IdentifierName */) { - return true; - } else if (term.kind() == 121 /* QualifiedName */) { - var binex = term; - - if (binex.right.kind() == 11 /* IdentifierName */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { - if (!type.isGeneric()) { - return type; - } - - var typeParameters = type.getTypeArgumentsOrTypeParameters(); - - var typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); - } - - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) != null; - - if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - 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++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - var wasInBaseTypeResolution = context.startBaseTypeResolution(); - - if (!typeDeclIsClass && !hasVisited) { - typeDeclSymbol.resetKnownBaseTypeCount(); - } - - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); - if (extendsClause) { - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - - if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - } - } - } - - var implementsClause = TypeScript.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()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); - var implementedType = this.resolveTypeReference(implementedTypeAST, context); - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - - if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addImplementedType(implementedType); - } - } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - - if (wasInBaseTypeResolution) { - typeDeclSymbol.inResolution = false; - - this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() == 131 /* ClassDeclaration */) { - _this.resolveClassDeclaration(classOrInterface, context); - } else { - _this.resolveInterfaceDeclaration(classOrInterface, context); - } - }); - - 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); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - 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); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.type; - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - var parentConstructor = parentType ? parentType.getConstructorMethod() : null; - - if (parentConstructor) { - this.resolveDeclaredSymbol(parentConstructor, context); - var parentConstructorType = parentConstructor.type; - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - - if (!parentConstructSignatures.length) { - parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - parentConstructSignature.returnType = parentType; - parentConstructorType.addConstructSignature(parentConstructSignature); - parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - - var parentTypeParameters = parentConstructorType.getTypeParameters(); - - for (var i = 0; i < parentTypeParameters.length; i++) { - parentConstructSignature.addTypeParameter(parentTypeParameters[i]); - } - - parentConstructSignatures = [parentConstructSignature]; - } - - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.parameters; - - constructorSignature = parentConstructSignature.isDefinition() ? new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - - 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); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - constructorTypeSymbol.addConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructorSignature.addTypeParameter(typeParameters[i]); - } - } - } - - if (!classDeclSymbol.isResolved) { - return classDeclSymbol; - } - - if (parentType) { - var parentConstructorSymbol = parentType.getConstructorMethod(); - - if (parentConstructorSymbol) { - var parentConstructorTypeSymbol = parentConstructorSymbol.type; - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - } - - this.resolveOtherDeclarations(classDeclAST, context); - } - - if (this.canTypeCheckAST(classDeclAST, context)) { - this.typeCheckClassDeclaration(classDeclAST, context); - } - - return classDeclSymbol; - }; - - 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); - }); - } - }; - - PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { - this.setTypeChecked(classDeclAST, context); - - var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - - this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); - this.resolveAST(classDeclAST.classElements, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); - this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); - - if (!classDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { - this.checkThisCaptureVariableCollides(classDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { - var callSignatures = typeSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); - - if (interfaceDeclSymbol.isResolved) { - this.resolveOtherDeclarations(interfaceDeclAST, context); - - if (this.canTypeCheckAST(interfaceDeclAST, context)) { - this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); - } - } - - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { - this.setTypeChecked(interfaceDeclAST, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); - this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); - - if (!interfaceDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(interfaceDeclSymbol, interfaceDecl, context); - } - }; - - PullTypeResolver.prototype.filterSymbol = function (symbol, kind, enclosingDecl, context) { - if (symbol) { - if (symbol.kind & kind) { - return symbol; - } - - if (symbol.isAlias()) { - this.resolveDeclaredSymbol(symbol, context); - - var alias = symbol; - if (kind & 164 /* SomeContainer */) { - return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728539 /* SomeType */) { - return alias.getExportAssignedTypeSymbol(); - } else if (kind & 68147712 /* SomeValue */) { - return alias.getExportAssignedValueSymbol(); - } - } - } - return null; - }; - - PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getMemberSymbol(symbolName, kind, pullTypeSymbol); - - return { - symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), - aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null - }; - }; - - PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { - var rhsName = identifier.valueText(); - if (rhsName.length === 0) { - return null; - } - - var moduleTypeSymbol = moduleSymbol.type; - var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); - var containerSymbol = memberSymbol.symbol; - var valueSymbol = null; - var typeSymbol = null; - var aliasSymbol = null; - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; - aliasSymbol = memberSymbol.aliasSymbol; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - aliasSymbol = containerSymbol; - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return null; - } - - if (!valueSymbol) { - if (moduleTypeSymbol.getInstanceSymbol()) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); - valueSymbol = memberSymbol.symbol; - if (valueSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - } - - if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728539 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); - typeSymbol = memberSymbol.symbol; - if (typeSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); - return null; - } - - if (!typeSymbol && containerSymbol) { - typeSymbol = containerSymbol; - } - - return { - valueSymbol: valueSymbol, - typeSymbol: typeSymbol, - containerSymbol: containerSymbol, - aliasSymbol: aliasSymbol - }; - }; - - 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"); - - var moduleSymbol = null; - var moduleName; - - if (moduleNameExpr.kind() == 121 /* QualifiedName */) { - var dottedNameAST = moduleNameExpr; - var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleContainer) { - moduleName = dottedNameAST.right.valueText(); - - moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; - if (!moduleSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); - } - } - } else { - var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); - var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); - - if (text.length > 0) { - var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); - moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); - if (moduleSymbol) { - this.semanticInfoChain.setSymbolForAST(moduleNameExpr, moduleSymbol); - if (resolvedModuleNameSymbol.isAlias()) { - this.semanticInfoChain.setAliasSymbolForAST(moduleNameExpr, resolvedModuleNameSymbol); - } - } else { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameExpr, TypeScript.DiagnosticCode.Unable_to_resolve_module_reference_0, [valueText]); - } - } - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - - var moduleReference = importStatementAST.moduleReference; - - var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; - - var declPath = enclosingDecl.getParentPath(); - var aliasedType = null; - - if (aliasExpr.kind() === 11 /* IdentifierName */ || aliasExpr.kind() === 14 /* StringLiteral */) { - var moduleSymbol = this.resolveModuleReference(importDecl, aliasExpr, enclosingDecl, context, declPath); - if (moduleSymbol) { - aliasedType = moduleSymbol.type; - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); - if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { - var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); - var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); - var instanceSymbol = aliasedType.getInstanceSymbol(); - - 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; - } - } else if (aliasExpr.kind() == 121 /* QualifiedName */) { - var importDeclSymbol = importDecl.getSymbol(); - var dottedNameAST = aliasExpr; - var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleSymbol) { - var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); - if (identifierResolution) { - importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); - 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); - } - - return aliasedType; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasedType = null; - - if (importDeclSymbol.isResolved) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - var declPath = enclosingDecl.getParentPath(); - - aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); - - 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; - } - } else { - aliasedType = this.resolveInternalModuleReference(importStatementAST, context); - } - - 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.isContainer()) { - importDeclSymbol.setAssignedContainerSymbol(aliasedType); - } - importDeclSymbol.setAssignedTypeSymbol(aliasedType); - - this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); - } - - importDeclSymbol.setResolved(); - - this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(importDeclSymbol.assignedType(), context); - this.resolveDeclaredSymbol(importDeclSymbol.assignedContainer(), context); - - if (this.canTypeCheckAST(importStatementAST, context)) { - this.typeCheckImportDeclaration(importStatementAST, context); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { - var _this = this; - this.setTypeChecked(importStatementAST, context); - - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (this.compilationSettings.noResolve()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); - } - - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - if (enclosingDecl.kind === 32 /* DynamicModule */) { - var ast = TypeScript.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)); - } - } - } - } - - var checkPrivacy; - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind == 32 /* DynamicModule */) { - checkPrivacy = true; - } - } else { - checkPrivacy = true; - } - - if (checkPrivacy) { - var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); - - this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { - var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - - 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; - - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - - if (valueSymbol) { - this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { - var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - } - - if (getCompilerReservedName(importStatementAST.identifier)) { - this.postTypeCheckWorkitems.push(importStatementAST); - } - }; - - PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - if (TypeScript.importDeclarationIsElided(importStatementAST, this.semanticInfoChain)) { - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context, true); - } - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { - var id = exportAssignmentAST.identifier.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && parentSymbol.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); - return this.semanticInfoChain.anyTypeSymbol; - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) != 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind == 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - - var aliasSymbol = containerSymbol; - var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(true); - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728539 /* SomeType */); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (valueSymbol) { - parentSymbol.setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - parentSymbol.setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - parentSymbol.setExportAssignedContainerSymbol(containerSymbol); - } - - this.resolveDeclaredSymbol(valueSymbol, context); - this.resolveDeclaredSymbol(typeSymbol, context); - this.resolveDeclaredSymbol(containerSymbol, context); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - var funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); - } - } - - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.setTypeChecked(funcDeclAST, context); - this.typeCheckFunctionOverloads(funcDeclAST, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.getType(argDeclAST), context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = 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 (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [paramSymbol.type])); - } else { - context.setTypeInContext(paramSymbol, paramSymbol.type); - } - } 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()])); - } - } - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - var contextualType = contextParam && contextParam.type; - var isImplicitAny = false; - - if (typeExpr) { - var typeRef = this.resolveTypeReference(typeExpr, context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); - typeRef = this.getNewErrorTypeSymbol(); - } - - contextualType = typeRef || contextualType; - } - if (contextualType) { - context.setTypeInContext(paramSymbol, contextualType); - } else if (paramSymbol.isVarArg && this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); - isImplicitAny = true; - } - - var canTypeCheckAST = this.canTypeCheckAST(argDeclAST, context); - if (equalsValueClause && (canTypeCheckAST || !contextualType)) { - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - } - - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - } - - if (!initExprSymbol || !initExprSymbol.type) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); - - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); - } - } else { - var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.widenType(initTypeSymbol, equalsValueClause, context)); - isImplicitAny = initTypeSymbol !== paramSymbol.type; - } else { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); - } - } - } - } - } - - if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - isImplicitAny = true; - } - - if (isImplicitAny && this.compilationSettings.noImplicitAny()) { - var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); - if (functionExpressionName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); - } - } - - if (canTypeCheckAST) { - this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context, immediateThisCheck) { - var compilerReservedName = getCompilerReservedName(name); - if (compilerReservedName) { - switch (compilerReservedName) { - case 1 /* _this */: - if (immediateThisCheck) { - this.checkThisCaptureVariableCollides(astWithName, isDeclaration, context); - } else { - this.postTypeCheckWorkitems.push(astWithName); - } - return; - - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; - - case 3 /* arguments */: - this.checkArgumentsCollides(astWithName, context); - return; - - case 4 /* _i */: - if (isDeclaration) { - this.checkIndexOfRestArgumentInitializationCollides(astWithName, 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()); - } - } - }; - - PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { - var enclosingAST = this.getASTForDecl(someFunctionDecl); - var nodeType = enclosingAST.kind(); - - 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); - } 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 */) { - var constructorDeclaration = enclosingAST; - return !TypeScript.hasFlag(someFunctionDecl.getParentDecl().flags, 8 /* Ambient */) && constructorDeclaration.block && TypeScript.lastParameterIsRest(constructorDeclaration.parameterList); - } else if (nodeType == 218 /* ParenthesizedArrowFunctionExpression */) { - var arrowFunctionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(arrowFunctionExpression.callSignature.parameterList); - } else if (nodeType === 222 /* FunctionExpression */) { - var functionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); - } - - return false; - }; - - PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); - } - } - } - }; - - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, context) { - if (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)); - } - } - } - }; - - PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(name); - if (TypeScript.isAnyNameOfModule(enclosingModule, name)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - if (enclosingDecl && enclosingDecl.kind == 32 /* DynamicModule */) { - var decl = this.semanticInfoChain.getDeclForAST(ast); - - if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - var nameText = name.valueText(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); - } - } - }; - - PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { - var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); - TypeScript.Debug.assert(interfaceDecl); - - var interfaceSymbol = interfaceDecl.getSymbol(); - TypeScript.Debug.assert(interfaceSymbol); - - if (objectType.typeMembers) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = objectType.typeMembers; - - for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { - memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); - memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); - - memberType = memberSymbol.type; - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - if (this.canTypeCheckAST(objectType, context)) { - this.typeCheckObjectTypeTypeReference(objectType, context); - } - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { - this.setTypeChecked(objectType, context); - var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); - var objectTypeSymbol = objectTypeDecl.getSymbol(); - - this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); - }; - - PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { - return this.resolveTypeReference(typeAnnotation.type, context); - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { - if (typeRef === null) { - return null; - } - - TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); - - var aliasType = null; - var type = this.computeTypeReferenceSymbol(typeRef, context); - - if (type.kind == 4 /* Container */) { - var container = type; - var instanceSymbol = container.getInstanceSymbol(); - - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind == 32768 /* ConstructorMethod */)) { - type = instanceSymbol.type.getAssociatedContainerType(); - } - } - - if (type && type.isAlias()) { - aliasType = type; - type = aliasType.getExportAssignedTypeSymbol(); - } - - if (type && !type.isGeneric()) { - if (aliasType) { - this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); - } - } - - if (type && !type.isError()) { - if ((type.kind & 58728539 /* 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 { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); - } - } - } - - if (this.canTypeCheckAST(typeRef, context)) { - this.setTypeChecked(typeRef, context); - } - - return type; - }; - - PullTypeResolver.prototype.computeTypeReferenceSymbol = function (term, context) { - switch (term.kind()) { - case 60 /* AnyKeyword */: - return this.semanticInfoChain.anyTypeSymbol; - case 61 /* BooleanKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - case 67 /* NumberKeyword */: - return this.semanticInfoChain.numberTypeSymbol; - case 69 /* StringKeyword */: - return this.semanticInfoChain.stringTypeSymbol; - case 41 /* VoidKeyword */: - return this.semanticInfoChain.voidTypeSymbol; - } - - var typeDeclSymbol = null; - - if (term.kind() === 11 /* IdentifierName */) { - typeDeclSymbol = this.resolveTypeNameExpression(term, context); - } else if (term.kind() === 123 /* FunctionType */) { - var functionType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); - } else if (term.kind() === 125 /* ConstructorType */) { - var constructorType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); - } else if (term.kind() === 122 /* ObjectType */) { - typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); - } else if (term.kind() === 126 /* GenericType */) { - typeDeclSymbol = this.resolveGenericTypeReference(term, context); - } else if (term.kind() === 121 /* QualifiedName */) { - typeDeclSymbol = this.resolveQualifiedName(term, context); - } else if (term.kind() === 14 /* StringLiteral */) { - 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()); - typeDeclSymbol.addDeclaration(decl); - } else if (term.kind() === 127 /* TypeQuery */) { - var typeQuery = term; - - var typeQueryTerm = typeQuery.name; - - var valueSymbol = this.resolveAST(typeQueryTerm, false, context); - - if (valueSymbol && valueSymbol.isAlias()) { - if (valueSymbol.assignedValue()) { - valueSymbol = valueSymbol.assignedValue(); - } else { - var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); - valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; - } - } - - if (valueSymbol) { - typeDeclSymbol = valueSymbol.type; - } 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; - } else { - throw TypeScript.Errors.invalidOperation("unknown type"); - } - - if (!typeDeclSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); - return this.getNewErrorTypeSymbol(); - } - - if (typeDeclSymbol.isError()) { - return typeDeclSymbol; - } - - if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); - typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); - } - - return typeDeclSymbol; - }; - - 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); - }; - - PullTypeResolver.prototype.resolveMemberVariableDeclaration = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, varDecl.modifiers, varDecl.variableDeclarator.propertyName, TypeScript.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); - }; - - PullTypeResolver.prototype.resolveVariableDeclarator = function (varDecl, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveParameterList = function (list, context) { - return this.resolveSeparatedList(list.parameters, context); - }; - - PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { - var enumDeclaration = enumElement.parent.parent; - var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); - var symbol = decl.getSymbol(); - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { - if (this.canTypeCheckAST(clause, context)) { - this.setTypeChecked(clause, context); - } - - return this.resolveAST(clause.value, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - - if (enclosingDecl && decl.kind == 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved) { - var declType = declSymbol.type; - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved) { - valSymbol.type = declType; - valSymbol.setResolved(); - } - } - } else { - if (declSymbol.inResolution) { - declSymbol.type = this.semanticInfoChain.anyTypeSymbol; - declSymbol.setResolved(); - return declSymbol; - } - - if (!declSymbol.type || !declSymbol.type.isError()) { - declSymbol.startResolving(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - if (!hasTypeExpr) { - this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - } - - if (!(hasTypeExpr || init)) { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.isVarArg) { - defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.type = defaultType; - } - } - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - } - } - - if (this.canTypeCheckAST(varDeclOrParameter, context)) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (varDeclOrParameter.kind() === 243 /* EnumElement */) { - var result = this.getEnumTypeSymbol(varDeclOrParameter, context); - declSymbol.type = result; - return result; - } - - if (!typeExpr) { - return null; - } - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; - - var typeExprSymbol = this.resolveTypeReference(typeExpr, context); - - if (!typeExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - declSymbol.type = this.getNewErrorTypeSymbol(); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, typeExprSymbol); - } - } else { - if (typeExprSymbol == this.semanticInfoChain.anyTypeSymbol) { - decl.setFlag(16777216 /* IsAnnotatedWithAny */); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - typeExprSymbol = typeExprSymbol.type; - - if (typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { - var instanceSymbol = typeExprSymbol.getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(); - } else { - typeExprSymbol = instanceSymbol.type; - } - } - } - } 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(); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.type = typeExprSymbol; - } - - if (typeExprSymbol.kind == 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { - typeExprSymbol.setFunctionSymbol(declSymbol); - } - } - - return typeExprSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { - if (!init) { - return null; - } - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - if (typeExprSymbol) { - context.pushContextualType(typeExprSymbol, context.inProvisionalResolution(), null); - } - - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl ? wrapperDecl : enclosingDecl; - - var initExprSymbol = this.resolveAST(init, typeExprSymbol != null, context); - - if (typeExprSymbol) { - context.popContextualType(); - } - - if (!initExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - } else { - var initTypeSymbol = initExprSymbol.type; - var widenedInitTypeSymbol = this.widenType(initTypeSymbol, init.value, context); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, widenedInitTypeSymbol); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); - } - - if (this.compilationSettings.noImplicitAny()) { - 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; - }; - - PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.sentinelEmptyArray, varDecl.propertyName, TypeScript.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); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDecl, TypeScript.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckParameter = function (parameter, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var _this = this; - this.setTypeChecked(varDeclOrParameter, context); - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - - if (hasTypeExpr || init) { - if (typeExprSymbol && typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = typeExprSymbol.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol; - } - } - } - - initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); - } - } - } - } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = 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])); - } else if (wrapperDecl.kind === 65536 /* Method */) { - var parentDecl = wrapperDecl.getParentDecl(); - - if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); - } 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 */) { - 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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } - } - } - - 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)); - } - } - 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 */)) { - this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); - } - }; - - PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { - return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; - }; - - 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 */) { - var enclosingAST = this.getASTForDecl(enclosingDecl); - if (enclosingAST.kind() !== 218 /* ParenthesizedArrowFunctionExpression */ && enclosingAST.kind() !== 219 /* SimpleArrowFunctionExpression */) { - var block = enclosingDecl.kind == 65536 /* Method */ ? enclosingAST.block : enclosingAST.block; - if (!block) { - return; - } - } - } - - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - if (parents.length) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); - } - } - }; - - PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { - if (isDeclaration) { - var decl = this.semanticInfoChain.getDeclForAST(_thisAST); - if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - return; - } - } - - var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - - var enclosingModule = TypeScript.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.isAnyNameOfModule(enclosingModule, _thisAST)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - var declPath = enclosingDecl.getParentPath(); - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - continue; - } - - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); - } - break; - } - } - }; - - PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { - this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - var typeParameterDecl = this.semanticInfoChain.getDeclForAST(typeParameterAST); - var typeParameterSymbol = typeParameterDecl.getSymbol(); - - if (typeParameterSymbol.isResolved || typeParameterSymbol.inResolution) { - if (typeParameterSymbol.isResolved && this.canTypeCheckAST(typeParameterAST, context)) { - this.typeCheckTypeParameterDeclaration(typeParameterAST, context); - } - return typeParameterSymbol; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - 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); - }; - - PullTypeResolver.prototype.resolveConstraint = function (constraint, context) { - if (this.canTypeCheckAST(constraint, context)) { - this.setTypeChecked(constraint, context); - } - - return this.resolveTypeReference(constraint.type, context); - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatementsExpressions = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, walker) { - var go = true; - - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); - go = false; - break; - - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, walker) { - switch (ast.kind()) { - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - if (block) { - TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - } else { - returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - } - - if (!returnStatementsExpressions.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var returnExpressionSymbols = []; - var returnExpressions = []; - - for (var i = 0; i < returnStatementsExpressions.length; i++) { - var returnExpression = returnStatementsExpressions[i].expression; - if (returnExpression) { - var returnType = this.resolveAST(returnExpression, useContextualType, context).type; - - if (returnType.isError()) { - signature.returnType = returnType; - return; - } else { - if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { - this.setSymbolForAST(returnExpression.parent, returnType, context); - } - } - - returnExpressionSymbols.push(returnType); - returnExpressions.push(returnExpression); - } - } - - if (!returnExpressionSymbols.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].type; - } - }; - - var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); - 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); - signature.returnType = newReturnType; - - if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); - } - - if (this.compilationSettings.noImplicitAny()) { - if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { - var functionName = enclosingDecl.name; - if (functionName == "") { - functionName = enclosingDecl.getFunctionExpressionName(); - } - - if (functionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } - - if (!functionSymbol.type && functionSymbol.isAccessor()) { - functionSymbol.type = signature.returnType; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - 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); - } - } - - 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)); - } 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)); - } - } - } - - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { - var _this = this; - if (constructorDecl.block) { - var foundSuperCall = false; - var pre = function (ast, walker) { - if (_this.isSuperInvocationExpression(ast)) { - foundSuperCall = true; - walker.options.stopWalking = true; - } - }; - - TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); - return foundSuperCall; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckFunctionExpression = function (funcDecl, context) { - this.typeCheckAnyFunctionExpression(funcDecl, funcDecl.callSignature.typeParameterList, TypeScript.getType(funcDecl), funcDecl.block, null, context); - }; - - PullTypeResolver.prototype.typeCheckCallSignature = function (funcDecl, context) { - this.typeCheckFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.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); - }; - - PullTypeResolver.prototype.typeCheckFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(parameters, false, context); - - this.resolveAST(block, false, context); - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.Parameters.fromParameterList(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])); - } - } - - if (funcDecl.kind === 16384 /* Function */) { - this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); - } - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.typeCheckIndexSignature = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - this.resolveAST(funcDeclAST.parameter, false, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, false, null, TypeScript.Parameters.fromParameter(funcDeclAST.parameter), TypeScript.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 stringIndexSignature = allIndexSignatures.stringSignature; - var numberIndexSignature = allIndexSignatures.numericSignature; - var isNumericIndexer = numberIndexSignature === signature; - - 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)) { - 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])); - } 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)])); - } - } - } - - var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); - for (var i = 0; i < allMembers.length; i++) { - var member = allMembers[i]; - var name = member.name; - if (name || (member.kind === 4096 /* Property */ && name === "")) { - if (!allMembers[i].isResolved) { - _this.resolveDeclaredSymbol(allMembers[i], context); - } - - if (parentSymbol !== allMembers[i].getContainer()) { - var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); - var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; - var onlyStringIndexerIsPresent = !numberIndexSignature; - - if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { - var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsSubtypeOfTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { - _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); - } - } - } - } - } - }); - }; - - PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { - this.checkThisCaptureVariableCollides(funcDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { - var returnTypeSymbol = null; - - if (returnTypeAnnotation) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - } else { - var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } - - return returnTypeSymbol; - }; - - 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); - }; - - PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.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); - }; - - PullTypeResolver.prototype.resolveMethodSignature = function (funcDecl, context) { - return this.resolveFunctionDeclaration(funcDecl, false, funcDecl.propertyName, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.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); - }; - - 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); - }; - - PullTypeResolver.prototype.resolveSimpleArrowFunctionExpression = function (funcDecl, isContextuallyTyped, context) { - return this.resolveAnyFunctionExpression(funcDecl, null, TypeScript.Parameters.fromIdentifier(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); - }; - - PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - return funcSymbol; - } - - if (!signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (signature.isGeneric()) { - if (funcSymbol) { - funcSymbol.type.setHasGenericSignature(); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveIndexSignature(ast.indexSignature, context); - }; - - PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - return funcSymbol; - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.getType(funcDeclAST), context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameter) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - this.resolveParameter(funcDeclAST.parameter, context); - context.inTypeCheck = prevInTypeCheck; - } - - if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } 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) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - return funcSymbol; - } - - if (isConstructor && !signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (returnTypeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { - if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { - 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; - if (funcDeclASTName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } - } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { - if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.getType(getterFunctionDeclarationAst), context); - } - - return null; - }; - - 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 null; - }; - - PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - - if (accessorSymbol.inResolution) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - accessorSymbol.setResolved(); - - return accessorSymbol; - } - - if (accessorSymbol.isResolved) { - if (!accessorSymbol.type) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else { - var getterSymbol = accessorSymbol.getGetter(); - var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; - var hasGetter = getterSymbol !== null; - - var setterSymbol = accessorSymbol.getSetter(); - var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; - var hasSetter = setterSymbol !== null; - - var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); - var getterHasTypeAnnotation = getterAnnotatedType !== null; - - var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); - var setterHasTypeAnnotation = setterAnnotatedType !== null; - - accessorSymbol.startResolving(); - - if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); - } - - if (hasSetter) { - setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); - } - - if (hasGetter && hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - var getterSig = getterSymbol.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { - getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; - getterSig.returnType = setterSuppliedTypeSymbol; - } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { - setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; - - if (setterHasParameters) { - setterParameters[0].type = getterSuppliedTypeSymbol; - } - } - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { - accessorSymbol.type = this.getNewErrorTypeSymbol(); - } else { - accessorSymbol.type = getterSuppliedTypeSymbol; - } - } else if (hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - - accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; - } else { - var getterSig = getterSymbol.type.getCallSignatures()[0]; - accessorSymbol.type = getterSig.returnType; - } - - accessorSymbol.setResolved(); - } - - if (this.canTypeCheckAST(funcDeclAst, context)) { - this.typeCheckAccessorDeclaration(funcDeclAst, context); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { - this.setTypeChecked(funcDeclAst, context); - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - var getterSymbol = accessorSymbol.getGetter(); - var setterSymbol = accessorSymbol.getSetter(); - - var isGetter = funcDeclAst.kind() == 139 /* GetAccessor */; - if (isGetter) { - var getterFunctionDeclarationAst = funcDeclAst; - context.pushContextualType(getterSymbol.type, context.inProvisionalResolution(), null); - this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popContextualType(); - } else { - var setterFunctionDeclarationAst = funcDeclAst; - this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); - } - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.type; - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return getterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - signature.setResolved(); - - return getterSymbol; - } - - signature.startResolving(); - - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - if (!setterAnnotatedType) { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } else { - signature.returnType = setterAnnotatedType; - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return getterSymbol; - }; - - PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - if (getter && setter) { - var getterAST = getter.getDeclarations()[0].ast(); - var setterAST = setter.getDeclarations()[0].ast(); - - if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { - var setterSig = setter.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - - var getter = accessorSymbol.getGetter(); - var getterSig = getter.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterParameters[0].type; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); - } - } - } - }; - - PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.getType(funcDeclAST), context); - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - 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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); - } - - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); - var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - 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); - }; - - PullTypeResolver.hasSetAccessorParameterTypeAnnotation = function (setAccessor) { - return setAccessor.parameterList && setAccessor.parameterList.parameters.nonSeparatorCount() > 0 && setAccessor.parameterList.parameters.nonSeparatorAt(0).typeAnnotation != null; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.type; - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return setterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - signature.setResolved(); - return setterSymbol; - } - - signature.startResolving(); - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - } - - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - - if (signature.hasAGenericParameter) { - setterTypeSymbol.setHasGenericSignature(); - } - - if (!hadError) { - signature.setResolved(); - } - } - - return setterSymbol; - }; - - PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) != 0; - - var getter = accessorSymbol.getGetter(); - - var funcNameAST = funcDeclAST.propertyName; - - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); - var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - if (getterIsPrivate != setterIsPrivate) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); - } - - this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); - } else { - if (this.compilationSettings.noImplicitAny()) { - var setterFunctionDeclarationAst = funcDeclAST; - 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); - }; - - PullTypeResolver.prototype.resolveList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.childCount(); i < n; i++) { - this.resolveAST(list.childAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.resolveAST(list.nonSeparatorAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLogicalOperation(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { - this.setTypeChecked(binex, context); - - var leftType = this.resolveAST(binex.left, false, context).type; - var rightType = this.resolveAST(binex.right, false, context).type; - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(binex); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ - TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), - leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); - } - }; - - PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.operand, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckUnaryArithmeticOperation(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckPostfixUnaryExpression(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { - return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); - }; - - PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - if (nodeType == 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { - return; - } - - TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { - if (this.canTypeCheckAST(binaryExpression, context)) { - this.typeCheckBinaryArithmeticExpression(binaryExpression, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); - - var lhsType = lhsSymbol.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } - - if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } - - var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); - var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); - - if (!rhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!lhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (lhsIsFit && rhsIsFit) { - switch (binaryExpression.kind()) { - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - if (!this.isReference(binaryExpression.left, lhsSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); - } - } - }; - - PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInstanceOfExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); - var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - var isValidRHS = this.isAnyOrEquivalent(rhsType) || this.typeIsSubtypeOfFunction(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)); - } - }; - - PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { - if (this.canTypeCheckAST(commaExpression, context)) { - this.setTypeChecked(commaExpression, context); - - this.resolveAST(commaExpression.left, false, context); - } - - var rhsType = this.resolveAST(commaExpression.right, false, context).type; - - return this.resolveAST(commaExpression.right, false, context).type; - }; - - PullTypeResolver.prototype.resolveInExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; - - var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); - - if (!isValidLHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); - } - - 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)); - } - }; - - PullTypeResolver.prototype.resolveForStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.variableDeclaration, false, context); - this.resolveAST(ast.initializer, false, context); - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.incrementor, false, context); - this.resolveAST(ast.statement, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { - if (this.canTypeCheckAST(forInStatement, context)) { - this.typeCheckForInStatement(forInStatement, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - 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)); - } - - var varSym = this.getSymbolForAST(varDecl, context); - } - - 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)); - } - - 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)); - } - - this.resolveAST(forInStatement.statement, false, context); - }; - - PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWhileStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckDoStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckIfStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - this.resolveAST(ast.elseClause, false, context); - }; - - PullTypeResolver.prototype.resolveElseClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckElseClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveBlock = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.statements, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declaration, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declarators, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWithStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var withStatement = ast; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); - }; - - PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckTryStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var tryStatement = ast; - - this.resolveAST(tryStatement.block, false, context); - this.resolveAST(tryStatement.catchClause, false, context); - this.resolveAST(tryStatement.finallyClause, false, context); - }; - - PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckCatchClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - - var catchDecl = this.semanticInfoChain.getDeclForAST(ast); - this.validateVariableDeclarationGroups(catchDecl, context); - }; - - PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckFinallyClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - }; - - PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - while (enclosingDecl) { - if (enclosingDecl.kind & 1032192 /* SomeFunction */) { - return enclosingDecl; - } - - enclosingDecl = enclosingDecl.getParentDecl(); - } - - return null; - }; - - PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var isContextuallyTyped = false; - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); - if (returnTypeAnnotationSymbol) { - isContextuallyTyped = true; - context.pushContextualType(returnTypeAnnotationSymbol, context.inProvisionalResolution(), null); - } - } 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 currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - isContextuallyTyped = true; - context.pushContextualType(currentContextualTypeReturnTypeSymbol, context.inProvisionalResolution(), null); - } - } - } - } - - var result = this.resolveAST(expression, isContextuallyTyped, context).type; - if (isContextuallyTyped) { - context.popContextualType(); - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { - if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { - var classDecl = enclosingFunction.getParentDecl(); - if (classDecl) { - var classSymbol = classDecl.getSymbol(); - this.resolveDeclaredSymbol(classSymbol, context); - - var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); - if (!isAssignable) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); - } - } - } - - if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); - } - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.getType(enclosingDeclAST); - if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { - var signatureSymbol = enclosingFunction.getSignatureSymbol(); - var sigReturnType = signatureSymbol.returnType; - - if (expressionType && sigReturnType) { - 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); - - var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); - } - } - } - } - } - }; - - PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { - var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var returnType = this.getSymbolForAST(returnAST, context); - var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); - if (!returnType || canTypeCheckAST) { - var returnExpr = returnAST.expression; - - var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); - - if (!returnType) { - returnType = resolvedReturnType; - this.setSymbolForAST(returnAST, resolvedReturnType, context); - } - - if (returnExpr && canTypeCheckAST) { - this.setTypeChecked(returnExpr, context); - this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); - } - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSwitchStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var expressionType = this.resolveAST(ast.expression, false, context).type; - - for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { - var switchClause = ast.switchClauses.childAt(i); - if (switchClause.kind() === 233 /* CaseSwitchClause */) { - var caseSwitchClause = switchClause; - - var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; - this.resolveAST(caseSwitchClause.statements, false, context); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); - } - } - } else { - var defaultSwitchClause = switchClause; - this.resolveAST(defaultSwitchClause.statements, false, context); - } - } - }; - - PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLabeledStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var labelIdentifier = ast.identifier.valueText(); - - 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])); - } - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { - switch (statement.kind()) { - case 160 /* LabeledStatement */: - return this.labelIsOnContinuableConstruct(statement.statement); - - case 158 /* WhileStatement */: - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 161 /* DoStatement */: - return true; - - default: - return false; - } - }; - - PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckContinueStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.isIterationStatement = function (ast) { - switch (ast.kind()) { - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 158 /* WhileStatement */: - case 161 /* DoStatement */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { - switch (ast.kind()) { - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 129 /* FunctionDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 241 /* FunctionPropertyAssignment */: - case 137 /* ConstructorDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.inSwitchStatement = function (ast) { - while (ast) { - if (ast.kind() === 151 /* SwitchStatement */) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inIterationStatement = function (ast) { - while (ast) { - if (this.isIterationStatement(ast)) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { - var result = []; - - ast = ast.parent; - while (ast) { - if (ast.kind() === 160 /* LabeledStatement */) { - var labeledStatement = ast; - if (breakable) { - result.push(labeledStatement.identifier.valueText()); - } else { - if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement.identifier.valueText()); - } - } - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - break; - } - - ast = ast.parent; - } - - return result; - }; - - 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)); - } else if (ast.identifier) { - var continuableLabels = this.getEnclosingLabels(ast, false, false); - - if (!TypeScript.ArrayUtilities.contains(continuableLabels, ast.identifier.valueText())) { - var continuableLabels = this.getEnclosingLabels(ast, false, true); - - if (TypeScript.ArrayUtilities.contains(continuableLabels, 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)); - } - } - } - }; - - PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckBreakStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - if (ast.identifier) { - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - if (!TypeScript.ArrayUtilities.contains(breakableLabels, ast.identifier.valueText())) { - var breakableLabels = this.getEnclosingLabels(ast, true, true); - if (TypeScript.ArrayUtilities.contains(breakableLabels, 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)); - } - }; - - PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { - if (!ast) { - return; - } - - var symbol = this.getSymbolForAST(ast, context); - if (symbol && symbol.isResolved) { - this.typeCheckAST(ast, isContextuallyTyped, context); - return symbol; - } - - var nodeType = ast.kind(); - - switch (nodeType) { - case 124 /* ArrayType */: - case 126 /* GenericType */: - case 122 /* ObjectType */: - case 127 /* TypeQuery */: - case 125 /* ConstructorType */: - case 123 /* FunctionType */: - return this.resolveTypeReference(ast, context); - - case 1 /* List */: - return this.resolveList(ast, context); - - case 2 /* SeparatedList */: - return this.resolveSeparatedList(ast, context); - - case 120 /* SourceUnit */: - return this.resolveSourceUnit(ast, context); - - case 132 /* EnumDeclaration */: - return this.resolveEnumDeclaration(ast, context); - - case 130 /* ModuleDeclaration */: - return this.resolveModuleDeclaration(ast, context); - - case 128 /* InterfaceDeclaration */: - return this.resolveInterfaceDeclaration(ast, context); - - case 131 /* ClassDeclaration */: - return this.resolveClassDeclaration(ast, context); - - case 224 /* VariableDeclaration */: - return this.resolveVariableDeclarationList(ast, context); - - case 136 /* MemberVariableDeclaration */: - return this.resolveMemberVariableDeclaration(ast, context); - - case 225 /* VariableDeclarator */: - return this.resolveVariableDeclarator(ast, context); - - case 141 /* PropertySignature */: - return this.resolvePropertySignature(ast, context); - - case 227 /* ParameterList */: - return this.resolveParameterList(ast, context); - - case 242 /* Parameter */: - return this.resolveParameter(ast, context); - - case 243 /* EnumElement */: - return this.resolveEnumElement(ast, context); - - case 232 /* EqualsValueClause */: - return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); - - case 238 /* TypeParameter */: - return this.resolveTypeParameterDeclaration(ast, context); - - case 239 /* Constraint */: - return this.resolveConstraint(ast, context); - - 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); - - case 241 /* FunctionPropertyAssignment */: - 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); - - case 121 /* QualifiedName */: - return this.resolveQualifiedName(ast, context); - - case 137 /* ConstructorDeclaration */: - return this.resolveConstructorDeclaration(ast, context); - - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return this.resolveAccessorDeclaration(ast, context); - - case 138 /* IndexMemberDeclaration */: - return this.resolveIndexMemberDeclaration(ast, context); - - case 144 /* IndexSignature */: - return this.resolveIndexSignature(ast, context); - - case 135 /* MemberFunctionDeclaration */: - return this.resolveMemberFunctionDeclaration(ast, context); - - case 142 /* CallSignature */: - return this.resolveCallSignature(ast, context); - - case 143 /* ConstructSignature */: - return this.resolveConstructSignature(ast, context); - - case 145 /* MethodSignature */: - return this.resolveMethodSignature(ast, context); - - case 129 /* FunctionDeclaration */: - return this.resolveAnyFunctionDeclaration(ast, context); - - case 222 /* FunctionExpression */: - return this.resolveFunctionExpression(ast, isContextuallyTyped, context); - - case 219 /* SimpleArrowFunctionExpression */: - return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 214 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - - case 35 /* ThisKeyword */: - return this.resolveThisExpression(ast, context); - - case 50 /* SuperKeyword */: - return this.resolveSuperExpression(ast, context); - - case 213 /* InvocationExpression */: - return this.resolveInvocationExpression(ast, context); - - case 216 /* ObjectCreationExpression */: - return this.resolveObjectCreationExpression(ast, context); - - 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; - - case 14 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 32 /* NullKeyword */: - return this.semanticInfoChain.nullTypeSymbol; - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 172 /* VoidExpression */: - return this.resolveVoidExpression(ast, context); - - case 174 /* AssignmentExpression */: - return this.resolveAssignmentExpression(ast, context); - - case 167 /* LogicalNotExpression */: - return this.resolveLogicalNotExpression(ast, context); - - case 193 /* NotEqualsWithTypeConversionExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 197 /* GreaterThanExpression */: - return this.resolveLogicalOperation(ast, context); - - case 208 /* AddExpression */: - case 175 /* AddAssignmentExpression */: - return this.resolveBinaryAdditionOperation(ast, context); - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.resolveUnaryArithmeticOperation(ast, context); - - case 210 /* PostIncrementExpression */: - case 211 /* PostDecrementExpression */: - return this.resolvePostfixUnaryExpression(ast, context); - - case 209 /* SubtractExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 189 /* BitwiseOrExpression */: - case 191 /* BitwiseAndExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - return this.resolveBinaryArithmeticExpression(ast, context); - - case 221 /* ElementAccessExpression */: - return this.resolveElementAccessExpression(ast, context); - - case 187 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); - - case 188 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, context); - - case 171 /* TypeOfExpression */: - return this.resolveTypeOfExpression(ast, context); - - case 157 /* ThrowStatement */: - return this.resolveThrowStatement(ast, context); - - case 170 /* DeleteExpression */: - return this.resolveDeleteExpression(ast, context); - - case 186 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, isContextuallyTyped, context); - - case 12 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 217 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, context); - - case 149 /* ExpressionStatement */: - return this.resolveExpressionStatement(ast, context); - - case 200 /* InstanceOfExpression */: - return this.resolveInstanceOfExpression(ast, context); - - case 173 /* CommaExpression */: - return this.resolveCommaExpression(ast, context); - - 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); - } - - return this.semanticInfoChain.anyTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { - if (!this.canTypeCheckAST(ast, context)) { - return; - } - - var nodeType = ast.kind(); - switch (nodeType) { - case 120 /* SourceUnit */: - this.typeCheckSourceUnit(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.typeCheckEnumDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.typeCheckModuleDeclaration(ast, context); - return; - - case 128 /* InterfaceDeclaration */: - this.typeCheckInterfaceDeclaration(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.typeCheckClassDeclaration(ast, context); - return; - - case 243 /* EnumElement */: - this.typeCheckEnumElement(ast, context); - return; - - case 136 /* MemberVariableDeclaration */: - this.typeCheckMemberVariableDeclaration(ast, context); - return; - - case 225 /* VariableDeclarator */: - this.typeCheckVariableDeclarator(ast, context); - return; - - case 141 /* PropertySignature */: - this.typeCheckPropertySignature(ast, context); - return; - - case 242 /* Parameter */: - this.typeCheckParameter(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.typeCheckImportDeclaration(ast, context); - return; - - case 215 /* ObjectLiteralExpression */: - this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 241 /* FunctionPropertyAssignment */: - this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); - return; - - case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - this.resolveTypeNameExpression(ast, context); - } else { - this.resolveNameExpression(ast, context); - } - return; - - case 212 /* MemberAccessExpression */: - this.resolveMemberAccessExpression(ast, context); - return; - - case 121 /* QualifiedName */: - this.resolveQualifiedName(ast, context); - return; - - case 222 /* FunctionExpression */: - this.typeCheckFunctionExpression(ast, context); - break; - - case 144 /* IndexSignature */: - this.typeCheckIndexSignature(ast, context); - break; - - case 142 /* CallSignature */: - this.typeCheckCallSignature(ast, context); - break; - - case 143 /* ConstructSignature */: - this.typeCheckConstructSignature(ast, context); - break; - - 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); - return; - } - - case 219 /* SimpleArrowFunctionExpression */: - this.typeCheckSimpleArrowFunctionExpression(ast, context); - return; - - case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, context); - return; - - case 214 /* ArrayLiteralExpression */: - this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 213 /* InvocationExpression */: - this.typeCheckInvocationExpression(ast, context); - return; - - case 216 /* ObjectCreationExpression */: - this.typeCheckObjectCreationExpression(ast, context); - return; - - case 150 /* ReturnStatement */: - this.resolveReturnStatement(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); - } - }; - - PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { - while (this.postTypeCheckWorkitems.length) { - var ast = this.postTypeCheckWorkitems.pop(); - this.postTypeCheck(ast, context); - } - }; - - PullTypeResolver.prototype.postTypeCheck = function (ast, context) { - var nodeType = ast.kind(); - - switch (nodeType) { - case 242 /* Parameter */: - case 225 /* VariableDeclarator */: - this.postTypeCheckVariableDeclaratorOrParameter(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.postTypeCheckClassDeclaration(ast, context); - return; - - case 129 /* FunctionDeclaration */: - this.postTypeCheckFunctionDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.postTypeCheckModuleDeclaration(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.postTypeCheckEnumDeclaration(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.postTypeCheckImportDeclaration(ast, context); - return; - - case 11 /* IdentifierName */: - this.postTypeCheckNameExpression(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); - } - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return this.cachedRegExpInterfaceType(); - } else { - return this.semanticInfoChain.anyTypeSymbol; - } - }; - - PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { - this.checkThisCaptureVariableCollides(nameAST, false, context); - }; - - PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { - this.setTypeChecked(nameAST, context); - this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { - var nameSymbol = this.getSymbolForAST(nameAST, context); - 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); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - 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; - } - } - - return false; - }; - - PullTypeResolver.prototype.computeNameExpression = function (nameAST, context, reportDiagnostics) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var nameSymbol = null; - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - if (TypeScript.isDeclarationASTOrDeclarationNameAST(nameAST)) { - nameSymbol = this.semanticInfoChain.getDeclForAST(nameAST.parent).getSymbol(); - } - - var declPath = enclosingDecl.getParentPath(); - - if (!nameSymbol) { - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - - 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 (!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); - } - } - - var nameDeclaration = nameSymbol.getDeclarations()[0]; - var nameParentDecl = nameDeclaration.getParentDecl(); - if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { - var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); - var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - - var parameterList = TypeScript.getParameterList(enclosingFunctionAST); - - if (currentParameterIndex >= 0) { - var foundMatchingParameter = false; - if (parameterList) { - for (var i = 0; i <= currentParameterIndex; i++) { - var candidateParameter = parameterList.parameters.nonSeparatorAt(i); - if (candidateParameter && candidateParameter.identifier.valueText() === id) { - foundMatchingParameter = true; - } - } - } - - if (!foundMatchingParameter) { - 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); - } - } - } - - var aliasSymbol = null; - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(true); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); - - var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - if (aliasSymbol) { - this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.getParameterList(funcDecl); - if (parameterList) { - while (parameter && parameter.parent) { - if (parameter.parent.parent === parameterList) { - return parameterList.parameters.nonSeparatorIndexOf(parameter); - } - - parameter = parameter.parent; - } - } - - return -1; - }; - - PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { - var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol != null; - - if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheckDottedNameAST) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); - } - - this.resolveDeclaredSymbol(symbol, context); - - if (symbol && (symbol.type != this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(dottedNameAST, symbol, context); - this.setSymbolForAST(name, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { - var rhsName = name.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var lhs = this.resolveAST(expression, false, context); - var lhsType = lhs.type; - - if (lhs.isAlias()) { - if (!this.inTypeQuery(expression)) { - lhs.setIsUsedAsValue(true); - } - lhsType = lhs.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - if (lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (!lhsType) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); - return this.getNewErrorTypeSymbol(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType != lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { - var instanceSymbol = lhsType.getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.type; - } - } - - if (lhsType.isTypeParameter()) { - lhsType = this.substituteUpperBoundForType(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); - - 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 */) { - var container = lhsType; - var associatedInstance = container.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.type; - - nameSymbol = this.getMemberSymbol(rhsName, 68147712 /* SomeValue */, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getMemberSymbol(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)])); - return this.getNewErrorTypeSymbol(rhsName); - } - } - - if (checkSuperPrivateAndStaticAccess) { - this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { - var typeNameSymbol = this.getSymbolForAST(nameAST, context); - - if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.setTypeChecked(nameAST, context); - } - typeNameSymbol = this.computeTypeNameExpression(nameAST, context); - this.setSymbolForAST(nameAST, typeNameSymbol, context); - } - - this.resolveDeclaredSymbol(typeNameSymbol, context); - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - var declPath = enclosingDecl.getParentPath(); - - var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728539 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728539 /* SomeType */ : 164 /* SomeContainer */; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } - - var typeNameSymbolAlias = null; - if (typeNameSymbol.isAlias()) { - typeNameSymbolAlias = typeNameSymbol; - this.resolveDeclaredSymbol(typeNameSymbol, context); - - var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); - - this.resolveDeclaredSymbol(aliasedType, context); - } - - if (typeNameSymbol.isTypeParameter()) { - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */) && (enclosingDecl.flags & 16 /* Static */)) { - 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)); - return this.getNewErrorTypeSymbol(); - } - } - } - - if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { - typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); - } - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.isLeftSideOfQualifiedName = function (ast) { - return ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.left === ast; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; - - if (genericTypeSymbol.isError()) { - return genericTypeSymbol; - } - - if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { - this.resolveDeclaredSymbol(genericTypeSymbol, context); - } - - if (genericTypeSymbol.isAlias()) { - genericTypeSymbol = genericTypeSymbol.getExportAssignedTypeSymbol(); - } - - var typeArgs = []; - - if (genericTypeAST.typeArgumentList && genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - - if (typeArgs[i].isError()) { - typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - var typeParameters = genericTypeSymbol.getTypeParameters(); - - 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(); - } - - if (!genericTypeSymbol.isResolved) { - var typeDecls = genericTypeSymbol.getDeclarations(); - var childDecls = null; - - for (var i = 0; i < typeDecls.length; i++) { - childDecls = typeDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - - var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); - - var typeConstraint = null; - var upperBound = null; - - typeParameters = specializedSymbol.getTypeParameters(); - - var typeConstraintSubstitutionMap = []; - var typeArg = null; - - var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < typeParameters.length; i++) { - typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - for (var id in instantiatedSubstitutionMap) { - typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; - } - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] == typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); - } - - if (typeArg.isTypeParameter()) { - upperBound = typeArg.getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - 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)])); - } - } - } - - return specializedSymbol; - }; - - PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { - if (this.inTypeQuery(dottedNameAST)) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; - } - - var symbol = this.getSymbolForAST(dottedNameAST, context); - if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheck) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeQualifiedName(dottedNameAST, context); - this.setSymbolForAST(dottedNameAST, symbol, context); - } - - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.computeQualifiedName = function (dottedNameAST, context) { - var rhsName = dottedNameAST.right.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); - var lhs = this.resolveAST(dottedNameAST.left, false, context); - - var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; - - if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { - if (lhs.isAlias()) { - lhs.setIsUsedAsValue(true); - } - } - - if (!lhsType) { - return this.getNewErrorTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - 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); - - if (!childTypeSymbol && lhsType.isContainer()) { - var exportedContainer = lhsType.getExportAssignedContainerSymbol(); - - if (exportedContainer) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.kind & 164 /* SomeContainer */) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().type; - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getMemberSymbol(rhsName, memberKind, lhsType); - } - } - } - - if (!childTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - - return childTypeSymbol; - }; - - PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { - if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { - return false; - } - - if (returnTypeAnnotation) { - return false; - } - - if (parameters) { - for (var i = 0, n = parameters.length; i < n; i++) { - if (parameters.typeAt(i)) { - return false; - } - } - } - - var contextualFunctionTypeSymbol = context.getContextualType(); - - if (contextualFunctionTypeSymbol) { - this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); - var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length == 1; - if (!exactlyOneCallSignature) { - return false; - } - - var callSignatureIsGeneric = callSignatures[0].typeParameters && callSignatures[0].typeParameters.length > 0; - return !callSignatureIsGeneric; - } - - return false; - }; - - PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { - var funcDeclSymbol = null; - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { - return funcDeclSymbol; - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - TypeScript.Debug.assert(funcDeclSymbol); - - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - funcDeclSymbol.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - var assigningFunctionSignature = null; - if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { - 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); - } - } - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.returnType; - - if (returnType) { - context.pushContextualType(returnType, context.inProvisionalResolution(), null); - - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popContextualType(); - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - var functionExpressionName = functionDecl.getFunctionExpressionName(); - - if (functionExpressionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); - } - } - - context.setTypeInContext(funcDeclSymbol, funcDeclType); - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, null, arrowFunction.block, arrowFunction.expression, context); - }; - - PullTypeResolver.prototype.typeCheckParenthesizedArrowFunctionExpression = function (arrowFunction, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, arrowFunction.callSignature.typeParameterList, TypeScript.getType(arrowFunction), arrowFunction.block, arrowFunction.expression, context); - }; - - PullTypeResolver.prototype.typeCheckAnyFunctionExpression = function (funcDeclAST, typeParameters, returnTypeAnnotation, block, bodyExpression, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcDeclSymbol = functionDecl.getSymbol(); - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - var returnTypeSymbol = signature.returnType; - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - context.pushContextualType(null, context.inProvisionalResolution(), 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; - - 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.validateVariableDeclarationGroups(functionDecl, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { - var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); - var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; - - if (this.canTypeCheckAST(thisExpression, context)) { - this.typeCheckThisExpression(thisExpression, context, enclosingDecl); - } - - return thisTypeSymbol; - }; - - PullTypeResolver.prototype.inTypeArgumentList = function (ast) { - var previous = null; - var current = ast; - - while (current) { - switch (current.kind()) { - case 126 /* GenericType */: - var genericType = current; - if (genericType.typeArgumentList === previous) { - return true; - } - break; - - case 226 /* ArgumentList */: - var argumentList = current; - return argumentList.typeArgumentList === previous; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { - while (ast) { - switch (ast.kind()) { - case 230 /* ExtendsHeritageClause */: - var heritageClause = ast; - - return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inTypeQuery = function (ast) { - while (ast) { - switch (ast.kind()) { - case 127 /* TypeQuery */: - return true; - case 129 /* FunctionDeclaration */: - case 213 /* InvocationExpression */: - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 213 /* InvocationExpression */: - var invocationExpression = current; - if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - break; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inConstructorParameterList = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 137 /* ConstructorDeclaration */: - var constructorDecl = current; - return previous === constructorDecl.parameterList; - - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.isFunctionOrNonArrowFunctionExpression = function (decl) { - if (decl.kind === 16384 /* Function */) { - return true; - } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { - this.checkForThisCaptureInArrowFunction(thisExpression); - - if (this.inConstructorParameterList(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); - return; - } - - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - return; - } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - if (currentDecl.getParentDecl() === null) { - return; - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_within_module_bodies)); - 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)); - } - - return; - } else if (currentDecl.kind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); - } - - return; - } - } - }; - - PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var isStaticContext = false; - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declFlags & 16 /* Static */) { - isStaticContext = true; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - return null; - } else if (declKind === 16384 /* Function */) { - return null; - } else if (declKind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(ast)) { - return this.getNewErrorTypeSymbol(); - } else { - var classSymbol = decl.getSymbol(); - if (isStaticContext) { - var constructorSymbol = classSymbol.getConstructorMethod(); - return constructorSymbol.type; - } else { - return classSymbol; - } - } - } - } - } - - return null; - }; - - PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { - return true; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - var superType = this.semanticInfoChain.anyTypeSymbol; - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); - - if (classSymbol) { - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - superType = parents[0]; - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSuperExpression(ast, context, enclosingDecl); - } - - return superType; - }; - - PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { - this.setTypeChecked(ast, context); - - this.checkForThisCaptureInArrowFunction(ast); - - var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; - var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; - TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); - - if (isSuperPropertyAccess) { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 8 /* Class */) { - if (!this.enclosingClassIsDerived(currentDecl)) { - 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 if (this.inStaticMemberVariableDeclaration(ast)) { - break; - } - - 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; - } - - return; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); - } - }; - - PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { - return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); - }; - - 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); - }; - - PullTypeResolver.prototype.typeCheckFunctionPropertyAssignment = function (funcProp, isContextuallyTyped, context) { - this.typeCheckAnyFunctionExpression(funcProp, funcProp.callSignature.typeParameterList, TypeScript.getType(funcProp), funcProp.block, null, context); - }; - - PullTypeResolver.prototype.resolveObjectLiteralExpression = function (expressionAST, isContextuallyTyped, context, additionalResults) { - var symbol = this.getSymbolForAST(expressionAST, context); - - if (!symbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { - if (this.canTypeCheckAST(expressionAST, context)) { - this.setTypeChecked(expressionAST, context); - } - symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); - this.setSymbolForAST(expressionAST, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { - var boundMemberSymbols = []; - var memberSymbol; - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var id = this.getPropertyAssignmentName(propertyAssignment); - var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); - - var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; - var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); - TypeScript.Debug.assert(decl); - - if (propertyAssignment.kind() == 240 /* SimplePropertyAssignment */) { - if (!isUsingExistingSymbol) { - memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - } else { - memberSymbol = decl.getSymbol(); - } - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - memberSymbol = decl.getSymbol(); - } else { - TypeScript.Debug.assert(isAccessor); - memberSymbol = decl.getSymbol(); - } - - if (!isUsingExistingSymbol && !isAccessor) { - if (objectLiteralTypeSymbol.findMember(memberSymbol.name, true)) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(propertyAssignment, TypeScript.DiagnosticCode.Duplicate_identifier_0, [assignmentText.actualText])); - } - - objectLiteralTypeSymbol.addMember(memberSymbol); - } - - boundMemberSymbols.push(memberSymbol); - } - - return boundMemberSymbols; - }; - - PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var acceptedContextualType = false; - var assigningSymbol = null; - - var id = this.getPropertyAssignmentName(propertyAssignment); - var memberSymbol = boundMemberSymbols[i]; - - if (objectLiteralContextualType) { - assigningSymbol = this.getMemberSymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); - - if (!assigningSymbol) { - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - assigningSymbol = numericIndexerSignature; - } else if (stringIndexerSignature) { - assigningSymbol = stringIndexerSignature; - } - } - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - - var contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.pushContextualType(contextualMemberType, pullTypeContext.inProvisionalResolution(), null); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = contextualMemberType; - } - } - } - - var propertySymbol = this.resolveAST(propertyAssignment, contextualMemberType != null, pullTypeContext); - var memberExpr = this.widenType(propertySymbol.type, propertyAssignment, pullTypeContext); - - if (memberExpr.type) { - if (memberExpr.type.isGeneric()) { - objectLiteralTypeSymbol.setHasGenericMember(); - } - - if (stringIndexerSignature) { - allMemberTypes.push(memberExpr.type); - } - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberExpr.type); - } - } - - if (acceptedContextualType) { - pullTypeContext.popContextualType(); - } - - var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!isUsingExistingSymbol) { - if (isAccessor) { - this.setSymbolForAST(id, memberExpr, pullTypeContext); - } else { - pullTypeContext.setTypeInContext(memberSymbol, memberExpr.type); - memberSymbol.setResolved(); - - this.setSymbolForAST(id, memberSymbol, pullTypeContext); - } - } - } - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { - var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); - TypeScript.Debug.assert(objectLitDecl); - - var typeSymbol = this.getSymbolForAST(objectLitAST, context); - var isUsingExistingSymbol = !!typeSymbol; - - if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 16 /* Interface */); - typeSymbol.addDeclaration(objectLitDecl); - this.setSymbolForAST(objectLitAST, typeSymbol, context); - objectLitDecl.setSymbol(typeSymbol); - } - - var propertyAssignments = objectLitAST.propertyAssignments; - var contextualType = null; - - if (isContextuallyTyped) { - contextualType = context.getContextualType(); - this.resolveDeclaredSymbol(contextualType, context); - } - - var stringIndexerSignature = null; - var numericIndexerSignature = null; - var allMemberTypes = null; - var allNumericMemberTypes = null; - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); - - stringIndexerSignature = indexSignatures.stringSignature; - numericIndexerSignature = indexSignatures.numericSignature; - - if (stringIndexerSignature) { - allMemberTypes = [stringIndexerSignature.returnType]; - } - - if (numericIndexerSignature) { - allNumericMemberTypes = [numericIndexerSignature.returnType]; - } - } - - if (propertyAssignments) { - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); - - this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); - - if (!isUsingExistingSymbol) { - this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); - this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); - } - } - - typeSymbol.setResolved(); - return typeSymbol; - }; - - PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { - return propertyAssignment.propertyName; - } else { - TypeScript.Debug.assert(false); - } - }; - - PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { - if (contextualIndexSignature) { - var typeCollection = { - getLength: function () { - return indexerTypeCandidates.length; - }, - getTypeAtIndex: function (index) { - return indexerTypeCandidates[index]; - } - }; - var decl = objectLiteralSymbol.getDeclarations()[0]; - var indexerReturnType = this.widenType(this.findBestCommonType(typeCollection, 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); - } - } - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { - var symbol = this.getSymbolForAST(arrayLit, context); - if (!symbol || this.canTypeCheckAST(arrayLit, context)) { - if (this.canTypeCheckAST(arrayLit, context)) { - this.setTypeChecked(arrayLit, context); - } - symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); - this.setSymbolForAST(arrayLit, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { - var elements = arrayLit.expressions; - var elementType = null; - var elementTypes = []; - var comparisonInfo = new TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, context); - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignatures(contextualType, context); - if (indexSignatures.numericSignature) { - contextualElementType = indexSignatures.numericSignature.returnType; - } - } - } - - if (elements) { - if (contextualElementType) { - context.pushContextualType(contextualElementType, context.inProvisionalResolution(), null); - } - - for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { - elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); - } - - if (contextualElementType) { - context.popContextualType(); - } - } - - if (elementTypes.length) { - elementType = elementTypes[0]; - } - var collection; - if (contextualElementType) { - if (!elementType) { - elementType = contextualElementType; - } - - collection = { - getLength: function () { - return elements.nonSeparatorCount() + 1; - }, - getTypeAtIndex: function (index) { - return index === 0 ? contextualElementType : elementTypes[index - 1]; - } - }; - } else { - collection = { - getLength: function () { - return elements.nonSeparatorCount(); - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - } - - elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; - - if (!elementType) { - 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; - }; - - PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { - var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); - - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); - } - - return symbolAndDiagnostic.symbol; - }; - - PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { - this.setTypeChecked(callEx, context); - context.postDiagnostic(symbolAndDiagnostic.diagnostic); - }; - - PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; - - var targetTypeSymbol = targetSymbol.type; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return { symbol: targetTypeSymbol }; - } - - var elementType = targetTypeSymbol.getElementType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return { symbol: elementType }; - } - - 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); - - if (member) { - this.resolveDeclaredSymbol(member, context); - - return { symbol: member.type }; - } - } - - if (targetTypeSymbol == this.semanticInfoChain.stringTypeSymbol && this.cachedStringInterfaceType()) { - targetTypeSymbol = this.cachedStringInterfaceType(); - } - - var signatures = this.getBothKindsOfIndexSignatures(targetTypeSymbol, context); - - var stringSignature = signatures.stringSignature; - var numberSignature = signatures.numericSignature; - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; - } 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) { - return { symbol: this.semanticInfoChain.anyTypeSymbol }; - } else { - return { - symbol: this.getNewErrorTypeSymbol(), - diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) - }; - } - }; - - PullTypeResolver.prototype.getBothKindsOfIndexSignatures = function (enclosingType, context) { - var signatures = enclosingType.getIndexSignatures(); - - var stringSignature = null; - var numberSignature = null; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - if (!signature.isResolved) { - this.resolveDeclaredSymbol(signature, context); - } - - paramSymbols = signature.parameters; - - if (paramSymbols.length) { - paramType = paramSymbols[0].type; - - if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signature; - continue; - } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { - numberSignature = signature; - continue; - } - } - } - - return { - numericSignature: numberSignature, - stringSignature: stringSignature - }; - }; - - PullTypeResolver.prototype.resolveBinaryAdditionOperation = function (binaryExpression, context) { - var lhsExpression = this.resolveAST(binaryExpression.left, false, context); - var lhsType = lhsExpression.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - 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; - } else { - rhsType = this.semanticInfoChain.anyTypeSymbol; - } - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (exprType) { - if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { - if (!this.isReference(binaryExpression.left, lhsExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, exprType, lhsType, context); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); - } - } - - if (!exprType) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { - return this.findBestCommonType({ - getLength: function () { - return 2; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - } - } - }, context); - }; - - PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { - return this.findBestCommonType({ - getLength: function () { - return 3; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - case 2: - return type3; - } - } - }, context); - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - } - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - 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); - } else { - var leftType = this.resolveAST(binex.left, false, context).type; - - context.pushContextualType(leftType, context.inProvisionalResolution(), null); - var rightType = this.resolveAST(binex.right, true, context).type; - context.popContextualType(); - - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - - this.resolveAST(binex.left, false, context); - } - - return this.resolveAST(binex.right, false, context).type; - }; - - PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); - } else { - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { - var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; - var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; - - var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); - - var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); - - if (this.canTypeCheckAST(trinex, context)) { - this.setTypeChecked(trinex, context); - this.resolveAST(trinex.condition, false, context); - - if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); - } - } - } - - if (!conditionalTypesAreValid) { - return this.getNewErrorTypeSymbol(); - } - - return expressionType; - }; - - 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)) { - return true; - } - } else { - if (this.typesAreIdentical(expressionType, leftType) || this.typesAreIdentical(expressionType, rightType)) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveAST(ast.expression, false, context); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - if (symbol != this.semanticInfoChain.anyTypeSymbol) { - this.setSymbolForAST(callEx, symbol, context); - } - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckInvocationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - var targetSymbol = this.resolveAST(callEx.expression, false, context); - - if (callEx.argumentList.arguments) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - - var len = callEx.argumentList.arguments.nonSeparatorCount(); - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var targetTypeSymbol = targetSymbol.type; - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); - return this.getNewErrorTypeSymbol(); - } - } - - return this.semanticInfoChain.anyTypeSymbol; - } - - var isSuperCall = false; - - if (callEx.expression.kind() === 50 /* SuperKeyword */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = targetTypeSymbol.getConstructorMethod(); - this.resolveDeclaredSymbol(targetSymbol, context); - targetTypeSymbol = targetSymbol.type; - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); - this.resolveAST(callEx.argumentList.arguments, false, context); - - return this.getNewErrorTypeSymbol(); - } - } - - var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - - 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 couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (callEx.argumentList.typeArgumentList) { - typeArgs = []; - - 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); - } - } - } else if (isSuperCall && targetTypeSymbol.isGeneric()) { - typeArgs = targetTypeSymbol.getTypeArguments(); - } - - var triedToInferTypeArgs = false; - - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var beforeResolutionSignatures = signatures; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - 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 (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; - } - } - } - } else { - if (triedToInferTypeArgs) { - continue; - } - - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; - } - } - - if (couldNotAssignToConstraint) { - continue; - } - - specializedSignature = this.instantiateSignature(signatures[i], typeReplacementMap, true); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = signatures[i]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - - var errorCondition = null; - if (!signatures.length) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (!couldNotFindGenericOverload) { - if (this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(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); - } - return this.semanticInfoChain.anyTypeSymbol; - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); - } else if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList != null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!signatures.length) { - return errorCondition; - } - - signature = signatures[0]; - } - - if (!signature.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); - } - - var returnType = isSuperCall ? this.semanticInfoChain.voidTypeSymbol : signature.returnType; - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - this.setSymbolForAST(callEx, symbol, context); - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckObjectCreationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData != additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - this.resolveAST(callEx.expression, false, context); - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (callEx.argumentList) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - var len = callEx.argumentList.arguments.nonSeparatorCount(); - - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { - if (!context.inProvisionalResolution()) { - additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); - } - context.postDiagnostic(diagnostic); - }; - - PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; - - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var typeArgs = null; - var typeReplacementMap = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - return targetTypeSymbol; - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - - if (this.compilationSettings.noImplicitAny()) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); - } - } - - if (constructSignatures.length) { - if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - typeArgs = []; - - 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); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var triedToInferTypeArgs; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric()) { - typeParameters = constructSignatures[i].getTypeParameters(); - - 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 && callEx.argumentList.arguments && callEx.argumentList.arguments.nonSeparatorCount()) { - inferredTypeArgs = this.inferArgumentTypesForSignature(constructSignatures[i], new TypeScript.ArgumentInferenceContext(this, callEx.argumentList.arguments), new TypeComparisonInfo(), context); - triedToInferTypeArgs = true; - } else { - inferredTypeArgs = []; - } - - 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; - } - } - } - } else { - if (triedToInferTypeArgs) { - continue; - } else { - for (var j = 0; j < typeParameters.length; j++) { - typeReplacementMap[typeParameters[j].pullSymbolID] = this.semanticInfoChain.emptyTypeSymbol; - } - } - } - - if (couldNotAssignToConstraint) { - continue; - } - - specializedSignature = this.instantiateSignature(constructSignatures[i], typeReplacementMap, true); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } - } else { - if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList != null, context, diagnostics); - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - - if (!constructSignatures.length) { - if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var errorCondition = null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!constructSignatures.length) { - return errorCondition; - } - - signature = constructSignatures[0]; - } - - returnType = signature.returnType; - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (typeArgs && typeArgs.length) { - returnType = this.createInstantiatedType(returnType, typeArgs); - } else { - returnType = this.instantiateTypeToAny(returnType, context); - } - } - - if (usedCallSignaturesInstead) { - 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(); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.returnType; - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList && callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushContextualType(contextualType, context.inProvisionalResolution(), null); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType != null, context); - - if (contextualType) { - context.popContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - } else if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); - - return this.getNewErrorTypeSymbol(); - }; - - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureA, signatureB, context) { - var typeReplacementMap = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters = signatureA.getTypeParameters(); - var typeConstraint = null; - - var fixedParameterTypes = []; - - 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 enclosingTypeParameterMap; - - if (functionTypeA) { - enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - if (functionTypeB) { - enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - 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(); - - 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); - }; - - PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { - var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; - - if (this.canTypeCheckAST(assertionExpression, context)) { - this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); - } - - return typeAssertionType; - }; - - PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { - this.setTypeChecked(assertionExpression, context); - - context.pushContextualType(typeAssertionType, context.inProvisionalResolution(), null); - var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popContextualType(); - - 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); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(assertionExpression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { - var leftExpr = this.resolveAST(binaryExpression.left, false, context); - var leftType = leftExpr.type; - - context.pushContextualType(leftType, context.inProvisionalResolution(), null); - var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popContextualType(); - - rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (!this.isReference(binaryExpression.left, leftExpr)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } else { - this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); - } - } - - return rightType; - }; - - PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { - var typeToReturn = type; - if (typeToReturn && typeToReturn.isAlias()) { - typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); - } - - if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { - var instanceTypeSymbol = typeToReturn.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); - typeToReturn = null; - } else { - typeToReturn = instanceTypeSymbol; - } - } - - return typeToReturn; - }; - - PullTypeResolver.prototype.widenType = function (type, ast, context) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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 type; - }; - - PullTypeResolver.prototype.findBestCommonType = function (collection, context, comparisonInfo) { - var len = collection.getLength(); - - for (var i = 0; i < len; i++) { - var candidateType = collection.getTypeAtIndex(i); - if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { - return candidateType; - } - } - - return this.semanticInfoChain.emptyTypeSymbol; - }; - - PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { - for (var i = 0; i < collection.getLength(); i++) { - var otherType = collection.getTypeAtIndex(i); - 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)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, t1EnclosingType, t2EnclosingType, val) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - 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); - } - } - - return this.typesAreIdentical(t1, t2, val); - }; - - PullTypeResolver.prototype.typesAreIdentical = function (t1, t2, val) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - 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 (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - if (t1.isTypeParameter() != t2.isTypeParameter()) { - return false; - } else if (t1.isTypeParameter()) { - var t1ParentDeclaration = t1.getDeclarations()[0].getParentDecl(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return false; - } - } - - 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()) { - return false; - } - - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, false); - - 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); - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getMemberSymbol(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)) { - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs)) { - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, undefined); - return false; - } - - this.identicalCache.setValueAt(t1.pullSymbolID, t2.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.signatureGroupsAreIdentical = function (sg1, sg2) { - if (sg1 === sg2) { - return true; - } - - if (!sg1 || !sg2) { - return false; - } - - 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)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.substituteUpperBoundForType = function (type) { - if (!type || !type.isTypeParameter()) { - return type; - } - - var constraint = type.getConstraint(); - - if (constraint && (constraint != type)) { - return this.substituteUpperBoundForType(constraint); - } - - return type; - }; - - PullTypeResolver.prototype.symbolsShareDeclaration = function (symbol1, symbol2) { - var decls1 = symbol1.getDeclarations(); - 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 false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - 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.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.sourceCallSignaturesAreSubtypeOfTargetCallSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceCallSignaturesAreRelatableToTargetCallSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceConstructSignaturesAreRelatableToTargetConstructSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIndexSignaturesAreRelatableToTargetIndexSignatures(source, target, false, this.subtypeCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.typeIsSubtypeOfFunction = function (source, ast, context) { - if (source.getCallSignatures().length || source.getConstructSignatures().length) { - return true; - } - - return this.cachedFunctionInterfaceType() && this.sourceIsSubtypeOfTarget(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.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.getSymbolForRelationshipCheck = function (symbol) { - if (symbol && symbol.isTypeReference()) { - return symbol.getReferencedTypeSymbol(); - } - - return symbol; - }; - - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, sourceEnclosingType, targetEnclosingType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - 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 */) { - return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - } - } - - return this.sourceIsRelatableToTarget(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - }; - - PullTypeResolver.prototype.sourceIsRelatableToTarget = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - var sourceSubstitution = 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; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } - } - - if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - 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) { - return true; - } - - return false; - } else if (source == this.semanticInfoChain.voidTypeSymbol) { - if (target == this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return assignableTo; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { - return false; - } - - if (source.getIsSpecialized() && target.getIsSpecialized()) { - if (TypeScript.PullHelpers.getRootType(source) == TypeScript.PullHelpers.getRootType(target)) { - var sourceTypeArguments = source.getTypeArguments(); - var targetTypeArguments = target.getTypeArguments(); - - if (sourceTypeArguments && targetTypeArguments) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, false); - - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTarget(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - break; - } - } - - if (i == sourceTypeArguments.length) { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); - return true; - } else { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - } - } - } - } - - if (sourceSubstitution.isPrimitive() || target.isPrimitive()) { - return false; - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter() && (source === sourceSubstitution)) { - return this.typesAreIdentical(target, source); - } else { - if (isComparingInstantiatedSignatures) { - target = this.substituteUpperBoundForType(target); - } else { - return this.typesAreIdentical(target, sourceSubstitution); - } - } - } - - 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); - return false; - } - - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - var sourceProp = this.getMemberSymbol(targetProp.name, 68147712 /* SomeValue */, 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); - - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - - 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)])); - } - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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)])); - } - return false; - } - - var comparisonInfoTypeArgumentsCheck = null; - 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)) { - 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]); - } 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)]); - } - comparisonInfo.addMessage(message); - } - } - } - } - - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingTypesAreIdentical = function (sourceType, targetType) { - var widenedTargetType = this.widenType(targetType); - var widenedSourceType = this.widenType(sourceType); - - if ((widenedSourceType != this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType != this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference != targetTypeNamedTypeReference) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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])) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - } - } - - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - PullTypeResolver.prototype.sourcePropertyIsRelatableToTargetProperty = function (source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetPropIsPrivate = targetProp.anyDeclHasFlag(2 /* Private */); - var sourcePropIsPrivate = sourceProp.anyDeclHasFlag(2 /* Private */); - - if (targetPropIsPrivate != sourcePropIsPrivate) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - 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)])); - } 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)])); - } - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - } - return false; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (!targetDecl.isEqual(sourceDecl)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - - 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()])); - } - - return false; - } - } - - if (sourceProp.isOptional && !targetProp.isOptional) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - 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)])); - } - return false; - } - - this.resolveDeclaredSymbol(sourceProp, context); - - var sourcePropType = sourceProp.type; - var targetPropType = targetProp.type; - - if (comparisonCache.valueAt(sourcePropType.pullSymbolID, targetPropType.pullSymbolID)) { - return true; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, source, target, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures)) { - return true; - } - - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - 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]); - } 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)]); - } - comparisonInfo.addMessage(message); - } - - return false; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignatures(target, context); - var targetStringSig = targetIndexSigs.stringSignature; - var targetNumberSig = targetIndexSigs.numericSignature; - - if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignatures(source, context); - var sourceStringSig = sourceIndexSigs.stringSignature; - var sourceNumberSig = sourceIndexSigs.numericSignature; - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - comparable = this.signatureIsAssignableToTarget(sourceStringSig, targetStringSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - comparable = this.signatureIsAssignableToTarget(sourceNumberSig, targetNumberSig, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - } else if (sourceStringSig) { - comparable = this.sourceIsAssignableToTarget(sourceStringSig.returnType, targetNumberSig.returnType, ast, context, comparisonInfoSignatuesTypeCheck); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - var mSig = null; - var nSig = null; - var foundMatch = false; - - var targetExcludeDefinition = targetSG.length > 1; - var sourceExcludeDefinition = sourceSG.length > 1; - for (var iMSig = 0; iMSig < targetSG.length; iMSig++) { - mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { - continue; - } - - if (this.signatureIsRelatableToTarget(nSig, mSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - foundMatch = true; - break; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - return false; - } - - return true; - }; - - PullTypeResolver.prototype.signatureIsRelatableToTarget = function (sourceSig, targetSig, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var sourceParameters = sourceSig.parameters; - var targetParameters = targetSig.parameters; - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetVarArgCount = targetSig.nonOptionalParamCount; - var sourceVarArgCount = sourceSig.nonOptionalParamCount; - - if (sourceVarArgCount > targetVarArgCount) { - if (comparisonInfo) { - comparisonInfo.flags |= 3 /* SourceSignatureHasTooManyParameters */; - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signature_expects_0_or_fewer_parameters, [targetVarArgCount])); - } - 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; - } - } - - comparisonCache.setValueAt(sourceSig.pullSymbolID, targetSig.pullSymbolID, false); - - 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 (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - - return false; - } - } - - 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; - } - - 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 (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { - var _this = this; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeComparisonInfo(); - var args = application.argumentList ? application.argumentList.arguments : null; - - var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { - if (hasOverloads && signature.isDefinition()) { - return false; - } - - if (haveTypeArgumentsAtCallSite && !signature.isGeneric()) { - return false; - } - - return _this.overloadHasCorrectArity(signature, args); - }); - - var firstAssignableButNotSupertypeSignature = null; - var firstAssignableWithProvisionalErrorsSignature = null; - - for (var i = 0; i < initialCandidates.length; i++) { - var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); - if (applicability === 3 /* Subtype */) { - return initialCandidates[i]; - } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { - firstAssignableButNotSupertypeSignature = initialCandidates[i]; - } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { - firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; - } - } - - if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { - return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; - } else { - var target = this.getCallTargetErrorSpanAST(application); - if (comparisonInfo.message) { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); - } else { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); - } - } - - return null; - }; - - PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { - return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; - }; - - PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { - if (args == null) { - return signature.nonOptionalParamCount === 0; - } - - var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); - if (numberOfArgs < signature.nonOptionalParamCount) { - return false; - } - if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { - if (args === null) { - return 3 /* Subtype */; - } - - var isInVarArg = false; - var parameters = signature.parameters; - var paramType = null; - - var overloadApplicability = 3 /* Subtype */; - - for (var i = 0; i < args.nonSeparatorCount(); i++) { - if (!isInVarArg) { - this.resolveDeclaredSymbol(parameters[i], context); - - if (parameters[i].isVarArg) { - paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); - isInVarArg = true; - } else { - paramType = parameters[i].type; - } - } - - var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); - - if (statusOfCurrentArgument === 0 /* NotAssignable */) { - return 0 /* NotAssignable */; - } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { - overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; - } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { - overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; - } - } - - return overloadApplicability; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType.isAny()) { - return 3 /* Subtype */; - } else if (paramType.isError()) { - 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); - } 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); - } 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); - } else if (arg.kind() === 215 /* ObjectLiteralExpression */) { - return this.overloadIsApplicableForObjectLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else if (arg.kind() === 214 /* ArrayLiteralExpression */) { - return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else { - return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); - } - }; - - PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { - if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushContextualType(paramType, true, null); - - 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(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushContextualType(paramType, true, null); - var argSym = this.resolveObjectLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType === this.cachedArrayInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushContextualType(paramType, true, null); - var argSym = this.resolveArrayLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - var argSym = this.resolveAST(arg, false, context); - - if (argSym.type.isAlias()) { - var aliasSym = argSym.type; - argSym = aliasSym.getExportAssignedTypeSymbol(); - } - - comparisonInfo.stringConstantVal = arg; - return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { - var tempComparisonInfo = new TypeComparisonInfo(); - tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; - if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { - return 3 /* Subtype */; - } - - if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { - return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; - } - - if (!comparisonInfo.message) { - var enclosingSymbol = this.getEnclosingSymbolForAST(arg); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); - } - - return 0 /* NotAssignable */; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (signature, argContext, comparisonInfo, context) { - var cxt = null; - - 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; - } - } - } - - 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; - } - } - } - } - - return resultTypes; - }; - - PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { - var enclosingDecl = this.getEnclosingDeclForAST(args); - var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); - return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; - }; - - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, expressionTypeEnclosingType, parameterTypeEnclosingType, shouldFix, 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); - return; - } - } - this.relateTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - }; - - PullTypeResolver.prototype.relateTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { - if (!expressionType || !parameterType) { - return; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType.isTypeParameter()) { - argContext.addCandidateForInference(parameterType, expressionType, shouldFix); - 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); - - 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); - } - } - } - }; - - PullTypeResolver.prototype.relateInifinitelyExpandingTypeToTypeParameters = function (expressionType, parameterType, shouldFix, argContext, context) { - if (!expressionType || !parameterType) { - return; - } - - var expressionTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(expressionType); - var parameterTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(parameterType); - if (expressionTypeNamedTypeReference != parameterTypeNamedTypeReference) { - return; - } - - var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeParameters = parameterType.getTypeParameters(); - - if (expressionTypeTypeArguments && parameterTypeParameters && expressionTypeTypeArguments.length === parameterTypeParameters.length) { - for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, shouldFix, argContext, context); - } - } - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var expressionParams = expressionSignature.parameters; - var expressionReturnType = expressionSignature.returnType; - - var parameterParams = parameterSignature.parameters; - var parameterReturnType = parameterSignature.returnType; - - var len = parameterParams.length < expressionParams.length ? parameterParams.length : expressionParams.length; - - 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); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, shouldFix, argContext, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - 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); - if (objectMember) { - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, objectType, parameterType, shouldFix, argContext, context); - } - } - - parameterSignatures = parameterType.getCallSignatures(); - objectSignatures = objectType.getCallSignatures(); - - if ((parameterSignatures.length == 1) && (objectSignatures.length == 1) && !objectSignatures[0].isGeneric() && (parameterSignatures[0].nonOptionalParamCount >= objectSignatures[0].nonOptionalParamCount)) { - this.relateFunctionSignatureToTypeParameters(objectSignatures[0], parameterSignatures[0], 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); - - if (parameterIndexSignatures.stringSignature && objectIndexSignatures.stringSignature) { - this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.stringSignature, parameterIndexSignatures.stringSignature, argContext, context); - } - if (parameterIndexSignatures.numericSignature && objectIndexSignatures.numericSignature) { - this.relateFunctionSignatureToTypeParameters(objectIndexSignatures.numericSignature, parameterIndexSignatures.numericSignature, argContext, context); - } - }; - - PullTypeResolver.prototype.relateArrayTypeToTypeParameters = function (argArrayType, parameterArrayType, shouldFix, argContext, context) { - var argElement = argArrayType.getElementType(); - var paramElement = parameterArrayType.getElementType(); - - this.relateTypeToTypeParameters(argElement, paramElement, shouldFix, argContext, context); - }; - - PullTypeResolver.prototype.instantiateTypeToAny = function (typeToSpecialize, context) { - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!typeParameters.length) { - return typeToSpecialize; - } - - var typeArguments = null; - - 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) { - typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; - } else { - typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; - } - } - - var type = this.createInstantiatedType(typeToSpecialize, typeArguments); - - return type; - }; - - PullTypeResolver.typeCheck = function (compilationSettings, semanticInfoChain, document) { - var sourceUnit = document.sourceUnit(); - - var resolver = semanticInfoChain.getResolver(); - var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); - - if (resolver.canTypeCheckAST(sourceUnit, context)) { - resolver.resolveAST(sourceUnit, false, context); - resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); - - while (resolver.typeCheckCallBacks.length) { - var callBack = resolver.typeCheckCallBacks.pop(); - callBack(context); - } - - resolver.processPostTypeCheckWorkItems(context); - } - }; - - 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(); - } - } - - 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 name = decl.name; - - 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; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckFunctionOverloads = function (funcDecl, context, signature, allSignatures) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - 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)) { - 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)); - } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); - } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); - } else { - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved) { - this.resolveDeclaredSymbol(allSignatures[i], context); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - if (this.signatureIsSubtypeOfTarget(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)); - } - } - } else if (definitionSignature && definitionSignature != signature) { - var comparisonInfo = new TypeComparisonInfo(); - - if (!definitionSignature.isResolved) { - this.resolveDeclaredSymbol(definitionSignature, context); - } - - if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature != signatureForVisibilityCheck) { - var errorCode; - - 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; - } - - if (errorCode) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); - } - } - }; - - PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { - if (!symbol || symbol.kind === 2 /* Primitive */) { - return; - } - - if (symbol.isType()) { - var typeSymbol = symbol; - var isNamedType = typeSymbol.isNamedTypeSymbol(); - - if (typeSymbol.isArrayNamedTypeReference()) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); - return; - } - - if (!isNamedType) { - var typeOfSymbol = typeSymbol.getTypeOfSymbol(); - if (typeOfSymbol) { - this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); - return; - } - } - - if (typeSymbol.inSymbolPrivacyCheck) { - return; - } - - typeSymbol.inSymbolPrivacyCheck = true; - - var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); - if (typars) { - for (var i = 0; i < typars.length; i++) { - this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); - } - } - - if (!isNamedType) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind == 8192 /* TypeParameter */) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); - } - - typeSymbol.inSymbolPrivacyCheck = false; - - if (!isNamedType) { - return; - } - } - - if (declSymbol.isExternallyVisible()) { - var symbolIsVisible = symbol.isExternallyVisible(); - - 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]) { - 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); - break; - } - } - symbol = symbolPath[symbolPath.length - 1]; - } - } else if (symbol.kind == 128 /* TypeAlias */) { - var aliasSymbol = symbol; - symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(true); - } - - if (!symbolIsVisible) { - privacyErrorReporter(symbol); - } - } - }; - - PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length > 1 && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); - } - - var params = signature.parameters; - for (var j = 0; j < params.length; j++) { - var paramType = params[j].type; - this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); - } - - var returnType = signature.returnType; - this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); - } - }; - - PullTypeResolver.prototype.typeParameterOfTypeDeclarationPrivacyErrorReporter = function (classOrInterface, indexOfTypeParameter, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - 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()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; - } - } - - var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { - var typeSymbol = symbol; - var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isProperty = declSymbol.kind === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; - } - } else { - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return; - } - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; - var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; - var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.kind == 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); - var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); - this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { - return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); - }); - } - } - - if (!isGetter && !isIndexSignature) { - var funcParams = functionSignature.parameters; - for (var i = 0; i < funcParams.length; i++) { - this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); - }); - } - } - - if (!isSetter) { - this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); - }); - } - }; - - PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else if (!isGetter) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var parameter = parameters.astAt(argIndex); - - var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { - var _this = this; - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var messageCode = null; - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; - } - } - - if (messageCode) { - var messageArguments = [typeSymbolName]; - var reportOnFuncDecl = false; - - if (returnTypeAnnotation) { - var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); - } - } - - if (block) { - var reportErrorOnReturnExpressions = function (ast, walker) { - var go = true; - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - } - } - }; - - PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { - TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); - - var classSymbol = classDecl.getSymbol(); - return classSymbol.getExtendedTypes().length > 0; - }; - - PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { - if (ast.kind() === 213 /* InvocationExpression */) { - var invocationExpression = ast; - if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { - if (node && node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - if (this.isSuperInvocationExpression(expressionStatement.expression)) { - return true; - } - } - return false; - }; - - PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { - if (block && block.statements && block.statements.childCount() > 0) { - return block.statements.childAt(0); - } - - return null; - }; - - PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { - TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); - - if (constructorDecl) { - var enclosingClass = constructorDecl.getParentDecl(); - - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.kind === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.kind() === 242 /* Parameter */) { - return true; - } - - if (ast.kind() === 136 /* MemberVariableDeclaration */) { - var variableDeclarator = ast; - if (variableDeclarator.variableDeclarator.equalsValueClause) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { - var enclosingDecl = this.getEnclosingDeclForAST(expression); - - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var inArrowFunction = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - inArrowFunction = true; - continue; - } - - if (inArrowFunction) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - var constructorSymbol = decl.getSymbol().getConstructorMethod(); - var constructorDecls = constructorSymbol.getDeclarations(); - for (var i = 0; i < constructorDecls.length; i++) { - constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; - } - } - break; - } - } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { - break; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignatures(containerType, context); - var stringSignature = indexSignatures.stringSignature; - var numberSignature = indexSignatures.numericSignature; - - if (stringSignature || numberSignature) { - var members = containerTypeDecl.getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { - var memberSymbol = member.getSymbol(); - var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); - if (relevantSignature) { - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsSubtypeOfTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { - this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); - } - } - } - } - } - }; - - PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { - if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { - return numberIndexSignature; - } else if (stringIndexSignature) { - return stringIndexSignature; - } - - return null; - }; - - PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { - 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])); - } 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)])); - } - } 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])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(astForError, TypeScript.DiagnosticCode.All_named_properties_must_be_subtypes_of_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.kind; - var extendedMemberKind = extendedTypeMember.kind; - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { - var typeMembers = typeSymbol.getMembers(); - - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - var foundError1 = false; - var foundError2 = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].name; - var extendedTypeProp = extendedType.findMember(propName, true); - if (extendedTypeProp) { - this.resolveDeclaredSymbol(extendedTypeProp, context); - foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); - - if (!foundError1) { - foundError2 = !this.sourcePropertyIsSubtypeOfTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); - } - - if (foundError1 || foundError2) { - foundError = true; - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = typeSymbol.getConstructorMethod().type; - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = extendedType.getConstructorMethod().type; - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].name; - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved) { - 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); - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; - } else { - if (extendedType.isClass()) { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; - } else { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreSubtypeOfTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceCallSignaturesAreSubtypeOfTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceConstructSignaturesAreSubtypeOfTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceIndexSignaturesAreSubtypeOfTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - } - } - } - - if (foundError) { - var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.hasClassTypeSymbolConflictAsValue = function (valueDeclAST, typeSymbol, enclosingDecl, context) { - var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - var valueSymbol = this.computeNameExpression(valueDeclAST, context, false); - var valueSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - - this.semanticInfoChain.setAliasSymbolForAST(valueDeclAST, typeSymbolAlias); - - if (typeSymbolAlias && valueSymbolAlias) { - return typeSymbolAlias != valueSymbolAlias; - } - - if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { - return true; - } - - var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; - - if (associatedContainerType) { - return associatedContainerType != typeSymbol.getRootSymbol(); - } - - return true; - }; - - PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - - var baseType = this.resolveTypeReference(baseDeclAST, context).type; - - if (!baseType) { - return; - } - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (!baseType.isError()) { - if (isExtendedType) { - if (typeDeclIsClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); - } - } - return; - } else if (typeDeclIsClass && isExtendedType && baseDeclAST.kind() == 11 /* IdentifierName */) { - 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)])); - } - } - - if (baseType.hasBase(typeSymbol)) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); - return; - } - - if (isExtendedType) { - this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); - } else { - TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - - this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); - } - - this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { - return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); - }); - }; - - PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { - var _this = this; - var extendsClause = TypeScript.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.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); - } - } - - if (typeSymbol.isClass()) { - if (implementsClause) { - for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); - } - } - } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { - var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { - return decl.ast().heritageClauses !== null; - }).ast(); - if (classOrInterface === firstInterfaceASTWithExtendsClause) { - this.typeCheckCallBacks.push(function (context) { - _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); - }); - } - } - }; - - PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { - var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); - - var inheritedMembersMap = TypeScript.createIntrinsicsObject(); - var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); - - var typeHasOwnNumberIndexer = false; - var typeHasOwnStringIndexer = false; - - if (typeSymbol.hasOwnIndexSignatures()) { - var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); - for (var i = 0; i < ownIndexSignatures.length; i++) { - if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { - typeHasOwnNumberIndexer = true; - } else { - typeHasOwnStringIndexer = true; - } - } - } - 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)) { - return; - } - } - - if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { - return; - } - - this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, inheritedMembersMap, context); - }; - - PullTypeResolver.prototype.checkNamedPropertyTypeIdentityBetweenBases = 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]; - var memberName = member.name; - - if (interfaceSymbol.findMember(memberName, false)) { - continue; - } - - 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()]); - 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; - } - } else { - inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); - } - } - - return false; - }; - - PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { - if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { - return false; - } - - var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { - var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; - - var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - var parameterTypeIsNumber = !parameterTypeIsString; - if (parameterTypeIsString && derivedTypeHasOwnStringSignature || parameterTypeIsNumber && derivedTypeHasOwnNumberSignature) { - continue; - } - - if (parameterTypeIsString) { - if (allInheritedSignatures.stringSignatureWithBaseOrigin) { - if (allInheritedSignatures.stringSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.stringSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { - 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; - } - } else { - allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } else if (parameterTypeIsNumber) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin.baseOrigin !== baseTypeSymbol && !this.typesAreIdentical(allInheritedSignatures.numberSignatureWithBaseOrigin.signature.returnType, currentInheritedSignature.returnType)) { - 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; - } - } else { - allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { - if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; - var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; - for (var memberName in inheritedMembers) { - var memberWithBaseOrigin = inheritedMembers[memberName]; - if (!memberWithBaseOrigin) { - continue; - } - - var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); - if (!relevantSignature) { - continue; - } - - var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; - var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; - - if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { - continue; - } - - var memberIsSubtype = this.sourceIsSubtypeOfTarget(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]); - - 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]); - - 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])); - } - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var signatureIsSubtype = this.sourceIsSubtypeOfTarget(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, [ - 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, [ - interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), - inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.isReference = function (ast, astSymbol) { - if (ast.kind() === 217 /* ParenthesizedExpression */) { - return this.isReference(ast.expression, astSymbol); - } - - if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { - return false; - } - - if (ast.kind() === 11 /* IdentifierName */) { - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { - return false; - } - - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { - return false; - } - - if (astSymbol.kind === 32768 /* ConstructorMethod */) { - return false; - } - } - - if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { - if (resolvedName) { - if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { - return this.semanticInfoChain.getEnclosingDecl(ast); - }; - - PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - return enclosingDecl ? enclosingDecl.getSymbol() : null; - }; - - PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { - if (resolvedName) { - if (resolvedName.anyDeclHasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var memberClass = memberContainer.getDeclarations()[0].ast(); - TypeScript.Debug.assert(memberClass); - - var containingClass = this.getEnclosingClassDeclaration(name); - - if (!containingClass || containingClass !== memberClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } - if (type.isPrimitive()) { - return type; - } - - if (type.isError()) { - return type; - } - - if (typeParameterArgumentMap[type.pullSymbolID]) { - return typeParameterArgumentMap[type.pullSymbolID]; - } - - if (type.isTypeParameter() && type.isFunctionTypeParameter()) { - return type; - } - - type._resolveDeclaredSymbol(); - if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - - return type; - }; - - PullTypeResolver.prototype.instantiateSignature = function (signature, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } - if (!signature.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return signature; - } - - var typeArguments = []; - - 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); - } - - instantiatedSignature.returnType = this.instantiateType((signature.returnType || this.semanticInfoChain.anyTypeSymbol), typeParameterArgumentMap, instantiateFunctionTypeParameters); - - if (instantiateFunctionTypeParameters) { - instantiatedSignature.functionType = this.instantiateType(signature.functionType, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - - var parameters = signature.parameters; - var parameter = null; - - if (parameters) { - for (var j = 0; j < parameters.length; j++) { - parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].isOptional) { - parameter.isOptional = true; - } - if (parameters[j].isVarArg) { - parameter.isVarArg = true; - instantiatedSignature.hasVarArgs = true; - } - instantiatedSignature.addParameter(parameter, parameter.isOptional); - - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap, instantiateFunctionTypeParameters); - } - } - - return instantiatedSignature; - }; - PullTypeResolver.globalTypeCheckPhase = 0; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; - - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent + 1; - } - } - TypeComparisonInfo.prototype.indentString = function () { - var result = ""; - - for (var i = 0; i < this.indent; i++) { - result += "\t"; - } - - return result; - }; - - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = this.message + TypeScript.newLine() + this.indentString() + message; - } else { - this.message = this.indentString() + message; - } - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - function getPropertyAssignmentNameTextFromIdentifier(identifier) { - if (identifier.kind() === 11 /* IdentifierName */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 14 /* StringLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 13 /* NumericLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; - - function isTypesOnlyLocation(ast) { - while (ast && ast.parent) { - switch (ast.parent.kind()) { - case 244 /* TypeAnnotation */: - return true; - case 127 /* TypeQuery */: - return false; - case 125 /* ConstructorType */: - var constructorType = ast.parent; - if (constructorType.type === ast) { - return true; - } - break; - case 123 /* FunctionType */: - var functionType = ast.parent; - if (functionType.type === ast) { - return true; - } - break; - case 239 /* Constraint */: - var constraint = ast.parent; - if (constraint.type === ast) { - return true; - } - break; - case 220 /* CastExpression */: - var castExpression = ast.parent; - return castExpression.type === ast; - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - return true; - case 228 /* TypeArgumentList */: - return true; - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 130 /* ModuleDeclaration */: - case 129 /* FunctionDeclaration */: - case 145 /* MethodSignature */: - case 212 /* MemberAccessExpression */: - case 242 /* Parameter */: - return false; - } - - ast = ast.parent; - } - - return false; - } - TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var sentinalEmptyArray = []; - - var SemanticInfoChain = (function () { - function SemanticInfoChain(compiler, logger) { - this.compiler = compiler; - this.logger = logger; - this.documents = []; - this.fileNameToDocument = TypeScript.createIntrinsicsObject(); - this.anyTypeDecl = null; - this.booleanTypeDecl = null; - this.numberTypeDecl = null; - this.stringTypeDecl = null; - this.nullTypeDecl = null; - this.undefinedTypeDecl = null; - this.voidTypeDecl = null; - this.undefinedValueDecl = null; - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.voidTypeSymbol = null; - this.undefinedValueSymbol = null; - this.emptyTypeSymbol = null; - this.astSymbolMap = []; - this.astAliasSymbolMap = []; - this.astCallResolutionDataMap = []; - this.declSymbolMap = []; - this.declSignatureSymbolMap = []; - this.declCache = null; - this.symbolCache = null; - this.fileNameToDiagnostics = null; - this._binder = null; - 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); - 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.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.invalidate(); - } - SemanticInfoChain.prototype.getDocument = function (fileName) { - var document = this.fileNameToDocument[fileName]; - return document ? document : null; - }; - - SemanticInfoChain.prototype.lineMap = function (fileName) { - return this.getDocument(fileName).lineMap(); - }; - - SemanticInfoChain.prototype.fileNames = function () { - if (this._fileNames === null) { - this._fileNames = this.documents.slice(1).map(function (s) { - return s.fileName; - }); - } - - return this._fileNames; - }; - - SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { - newSymbol.addDeclaration(decl); - decl.setSymbol(newSymbol); - newSymbol.setResolved(); - - return newSymbol; - }; - - SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { - var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { - var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); - newSymbol.type = type; - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.resetGlobalSymbols = function () { - this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); - this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); - this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); - this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); - this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); - this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); - 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 emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - emptyTypeDecl.setSymbol(emptyTypeSymbol); - emptyTypeSymbol.addDeclaration(emptyTypeDecl); - emptyTypeSymbol.setResolved(); - this.emptyTypeSymbol = emptyTypeSymbol; - }; - - SemanticInfoChain.prototype.addDocument = function (document) { - var fileName = document.fileName; - - var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (existingIndex < 0) { - this.documents.push(document); - } else { - this.documents[existingIndex] = document; - } - - this.fileNameToDocument[fileName] = document; - - this.invalidate(); - }; - - SemanticInfoChain.prototype.removeDocument = function (fileName) { - TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); - var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (index > 0) { - this.fileNameToDocument[fileName] = undefined; - this.documents.splice(index, 1); - this.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { - var cacheID = this.getDeclPathCacheID([name], kind); - - var symbol = this.symbolCache[cacheID]; - - if (!symbol) { - for (var i = 0, n = this.documents.length; i < n; i++) { - var topLevelDecl = this.documents[i].topLevelDecl(); - - var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); - if (symbol) { - break; - } - - if (doNotGoPastThisDecl && topLevelDecl.name == doNotGoPastThisDecl.fileName()) { - return null; - } - } - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { - var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; - - var foundDecls = topLevelDecl.searchChildDecls(name, kind); - - for (var j = 0; j < foundDecls.length; j++) { - var foundDecl = foundDecls[j]; - - if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { - break; - } - - var symbol = foundDecls[j].getSymbol(); - if (symbol) { - return symbol; - } - } - - return null; - }; - - 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]; - if (symbol != undefined) { - return symbol; - } - - symbol = null; - 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 dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - symbol = dynamicModuleDecl.getSymbol(); - this.symbolCache[dtsCacheID] = isDtsFile ? symbol : null; - this.symbolCache[tsCacheID] = !TypeScript.isDTSFile ? symbol : null; - return symbol; - } - } - } - - this.symbolCache[dtsCacheID] = null; - this.symbolCache[tsCacheID] = null; - - return symbol; - }; - - SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { - var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); - - var symbol = this.symbolCache[cacheID]; - if (symbol == undefined) { - symbol = null; - for (var i = 0; i < this.documents.length; i++) { - var document = this.documents[i]; - var topLevelDecl = document.topLevelDecl(); - - if (!topLevelDecl.isExternalModule()) { - var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); - if (dynamicModules.length) { - symbol = dynamicModules[0].getSymbol(); - break; - } - } - } - - this.symbolCache[cacheID] = symbol; - } - - return symbol; - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.topLevelDecls(); - - 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; - - for (var j = 0; j < declsToSearch.length; j++) { - foundDecls = declsToSearch[j].searchChildDecls(path, declKind); - - for (var k = 0; k < foundDecls.length; k++) { - if (decls == TypeScript.sentinelEmptyArray) { - decls = []; - } - decls[decls.length] = foundDecls[k]; - } - - if (foundDecls.length && !keepSearching) { - break; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { - var declString = []; - - for (var i = 0, n = declPath.length; i < n; i++) { - if (declPath[i].kind & 1 /* Script */) { - continue; - } - - declString.push(declPath[i].name); - } - - return this.findDecls(declString, declKind); - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - symbol = decls[0].getSymbol(); - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - } - }; - - SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { - if (typeof oldSettings === "undefined") { oldSettings = null; } - if (typeof newSettings === "undefined") { newSettings = null; } - TypeScript.PullTypeResolver.globalTypeCheckPhase++; - - var cleanStart = new Date().getTime(); - - this.astSymbolMap.length = 0; - this.astAliasSymbolMap.length = 0; - this.astCallResolutionDataMap.length = 0; - - this.declCache = TypeScript.createIntrinsicsObject(); - this.symbolCache = TypeScript.createIntrinsicsObject(); - this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - - this.declSymbolMap.length = 0; - this.declSignatureSymbolMap.length = 0; - - if (oldSettings && newSettings) { - if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { - for (var i = 1, n = this.documents.length; i < n; i++) { - this.documents[i].invalidate(); - } - } - } - - TypeScript.pullSymbolID = 0; - TypeScript.globalTyvarID = 0; - - this.resetGlobalSymbols(); - - var cleanEnd = new Date().getTime(); - }; - - SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() != after.propagateEnumConstants(); - }; - - SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { - this.astAliasSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { - return this.astAliasSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { - return this.astCallResolutionDataMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { - if (callResolutionData) { - this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap[decl.declID] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { - this.declSignatureSymbolMap[decl.declID] = signatureSymbol; - }; - - SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { - return this.declSignatureSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { - var fileName = diagnostic.fileName(); - var diagnostics = this.fileNameToDiagnostics[fileName]; - if (!diagnostics) { - diagnostics = []; - this.fileNameToDiagnostics[fileName] = diagnostics; - } - - diagnostics.push(diagnostic); - }; - - SemanticInfoChain.prototype.getDiagnostics = function (fileName) { - var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics ? diagnostics : []; - }; - - SemanticInfoChain.prototype.getBinder = function () { - if (!this._binder) { - this._binder = new TypeScript.PullSymbolBinder(this); - } - - return this._binder; - }; - - SemanticInfoChain.prototype.getResolver = function () { - if (!this._resolver) { - this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); - } - - return this._resolver; - }; - - SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); - indexParameterSymbol.type = indexParamType; - indexSignature.addParameter(indexParameterSymbol); - indexSignature.returnType = returnType; - indexSignature.setResolved(); - indexParameterSymbol.setResolved(); - - 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()); - indexSigDecl.setSignatureSymbol(indexSignature); - indexParamDecl.setSymbol(indexParameterSymbol); - indexSignature.addDeclaration(indexSigDecl); - indexParameterSymbol.addDeclaration(indexParamDecl); - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast) { - var document = this.getDocument(ast.fileName()); - - if (document) { - return document._getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { - return this.getDocument(ast.fileName()).getEnclosingDecl(ast); - }; - - SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { - this.getDocument(decl.fileName())._setDeclForAST(ast, decl); - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var document = this.getDocument(decl.fileName()); - if (document) { - return document._getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { - this.getDocument(decl.fileName())._setASTForDecl(decl, ast); - }; - - SemanticInfoChain.prototype.topLevelDecl = function (fileName) { - var document = this.getDocument(fileName); - if (document) { - return document.topLevelDecl(); - } - - return null; - }; - - SemanticInfoChain.prototype.topLevelDecls = function () { - if (!this._topLevelDecls) { - this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { - return u.topLevelDecl(); - }); - } - - 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.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); - }; - return SemanticInfoChain; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { - this.document = document; - this.semanticInfoChain = semanticInfoChain; - this.propagateEnumConstants = propagateEnumConstants; - this.isDeclareFile = false; - this.parentChain = []; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - - function containingModuleHasExportAssignment(ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = ast; - return moduleDecl.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } else if (ast.kind() === 120 /* SourceUnit */) { - var sourceUnit = ast; - return sourceUnit.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } - - ast = ast.parent; - } - - return false; - } - - function isParsingAmbientModule(ast, context) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { - return true; - } - } - - ast = ast.parent; - } - - return false; - } - - function preCollectImportDecls(ast, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - var span = TypeScript.TextSpan.fromBounds(importDecl.start(), importDecl.end()); - - var parent = context.getParent(); - - if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { - declFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(importDecl.identifier.valueText(), importDecl.identifier.text(), 128 /* TypeAlias */, declFlags, parent, span); - 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); - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.isDeclareFile = context.document.isDeclareFile(); - - context.pushParent(decl); - - if (isExternalModule) { - var declFlags = 1 /* Exported */; - if (TypeScript.isDTSFile(fileName)) { - declFlags |= 8 /* Ambient */; - } - - 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); - - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, sourceUnit, context); - } - - context.pushParent(decl); - } - } - - 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 */; - } - - if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - declFlags |= 4096 /* Enum */; - 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); - 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()); - enumDeclaration.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); - - context.pushParent(enumDeclaration); - } - - 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); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function preCollectModuleDecls(moduleDecl, context) { - var declFlags = 0 /* None */; - - var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); - - var isDynamic = moduleDecl.stringLiteral !== null; - - if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - 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); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); - } - - context.pushParent(decl); - } else { - var moduleNames = getModuleNames(moduleDecl.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - var moduleName = moduleNames[i]; - - var specificFlags = declFlags; - if (i > 0) { - specificFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent(), span); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleName, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleName); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleName, context); - } - - context.pushParent(decl); - } - } - } - - function getModuleNames(name, result) { - result = result || []; - - if (name.kind() === 121 /* QualifiedName */) { - getModuleNames(name.left, result); - result.push(name.right); - } else { - result.push(name); - } - - return result; - } - TypeScript.getModuleNames = getModuleNames; - - 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()); - decl.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); - } - - function containsExecutableCode(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); - - if (member.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = member; - - if (containsExecutableCode(moduleDecl.moduleElements)) { - return true; - } - } else if (member.kind() !== 128 /* InterfaceDeclaration */ && member.kind() !== 133 /* ImportDeclaration */) { - return true; - } - } - - return false; - } - - 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 */; - } - - if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { - 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 constructorDecl = new TypeScript.NormalPullDecl(classDecl.identifier.valueText(), classDecl.identifier.text(), constructorDeclKind, declFlags | 16384 /* ClassConstructorVariable */, parent, span); - - decl.setValueDecl(constructorDecl); - - context.semanticInfoChain.setDeclForAST(classDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, classDecl); - context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); - - context.pushParent(decl); - } - - function preCollectObjectTypeDecls(objectType, context) { - if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { - return; - } - - 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); - context.semanticInfoChain.setDeclForAST(objectType, decl); - context.semanticInfoChain.setASTForDecl(decl, objectType); - - context.pushParent(decl); - } - - function preCollectInterfaceDecls(interfaceDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { - 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); - context.semanticInfoChain.setDeclForAST(interfaceDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, interfaceDecl); - - context.pushParent(decl); - } - - function preCollectParameterDecl(argDecl, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - 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); - - if (argDecl.equalsValueClause) { - parent.flags |= 33554432 /* HasDefaultArgs */; - } - - if (parent.kind == 32768 /* ConstructorMethod */) { - decl.setFlag(67108864 /* ConstructorParameter */); - } - - var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); - 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); - propDecl.setValueDecl(decl); - decl.setFlag(8388608 /* PropertyParameter */); - propDecl.setFlag(8388608 /* PropertyParameter */); - - if (parent.kind == 32768 /* ConstructorMethod */) { - propDecl.setFlag(67108864 /* ConstructorParameter */); - } - - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setASTForDecl(propDecl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, decl); - } - - parent.addVariableDeclToGroup(decl); - } - - 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); - context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); - context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); - } - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = 4096 /* Property */; - - if (propertyDecl.questionToken !== null) { - 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); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { - 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); - context.semanticInfoChain.setDeclForAST(memberDecl, decl); - context.semanticInfoChain.setDeclForAST(memberDecl.variableDeclarator, decl); - context.semanticInfoChain.setASTForDecl(decl, memberDecl); - } - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 512 /* Variable */; - - var modifiers = TypeScript.getVariableDeclaratorModifiers(varDecl); - if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { - 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); - context.semanticInfoChain.setDeclForAST(varDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, varDecl); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectVarDecls(ast, context) { - if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { - return; - } - - var varDecl = ast; - createVariableDeclaration(varDecl, context); - } - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); - - context.pushParent(decl); - } - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); - - context.pushParent(decl); - } - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - if (!funcDeclAST.block) { - 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); - context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); - - context.pushParent(decl); - } - - function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { - if (typeof displayName === "undefined") { displayName = null; } - var declFlags = 0 /* None */; - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - 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 */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = id ? id.text() : ""; - var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, span, displayNameText); - context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); - - context.pushParent(decl); - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrow = functionExpressionDeclAST; - var declFlags = 4 /* Public */; - - var parent = context.getParent(); - - if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { - 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); - - context.semanticInfoChain.setASTForDecl(decl, simpleArrow.identifier); - context.semanticInfoChain.setDeclForAST(simpleArrow.identifier, decl); - - parent.addVariableDeclToGroup(decl); - } - } - - function createMemberFunctionDeclaration(funcDecl, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!funcDecl.block) { - 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); - context.semanticInfoChain.setDeclForAST(funcDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDecl); - - context.pushParent(decl); - } - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); - - context.pushParent(decl); - } - - function createCallSignatureDeclaration(callSignature, context) { - var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; - - if (!isChildOfObjectType) { - return; - } - - 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); - context.semanticInfoChain.setDeclForAST(callSignature, decl); - context.semanticInfoChain.setASTForDecl(decl, callSignature); - - context.pushParent(decl); - } - - function createMethodSignatureDeclaration(method, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - declFlags |= 4 /* Public */; - declFlags |= 2048 /* Signature */; - - if (method.questionToken !== null) { - 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); - context.semanticInfoChain.setDeclForAST(method, decl); - context.semanticInfoChain.setASTForDecl(decl, method); - - context.pushParent(decl); - } - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - 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); - context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); - - context.pushParent(decl); - } - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var span = TypeScript.TextSpan.fromBounds(constructorDeclAST.start(), constructorDeclAST.end()); - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.flags; - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent, span); - context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); - - context.pushParent(decl); - } - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - 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); - context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); - - context.pushParent(decl); - } - - function createFunctionExpressionDeclaration(expression, context) { - createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); - } - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - 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); - context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); - - context.pushParent(decl); - } - - function preCollectCatchDecls(ast, context) { - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - - 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); - context.semanticInfoChain.setDeclForAST(ast.identifier, decl); - context.semanticInfoChain.setASTForDecl(decl, ast.identifier); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectWithDecls(ast, context) { - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - 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); - - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectSimplePropertyAssignmentDecls(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); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - } - - 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); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - - createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); - } - - function preCollectDecls(ast, context) { - switch (ast.kind()) { - case 120 /* SourceUnit */: - preCollectScriptDecls(ast, context); - break; - case 132 /* EnumDeclaration */: - preCollectEnumDecls(ast, context); - break; - case 243 /* EnumElement */: - createEnumElementDecls(ast, context); - break; - case 130 /* ModuleDeclaration */: - preCollectModuleDecls(ast, context); - break; - case 131 /* ClassDeclaration */: - preCollectClassDecls(ast, context); - break; - case 128 /* InterfaceDeclaration */: - preCollectInterfaceDecls(ast, context); - break; - case 122 /* ObjectType */: - preCollectObjectTypeDecls(ast, context); - break; - case 242 /* Parameter */: - preCollectParameterDecl(ast, context); - break; - case 136 /* MemberVariableDeclaration */: - createMemberVariableDeclaration(ast, context); - break; - case 141 /* PropertySignature */: - createPropertySignature(ast, context); - break; - case 225 /* VariableDeclarator */: - preCollectVarDecls(ast, context); - break; - case 137 /* ConstructorDeclaration */: - createClassConstructorDeclaration(ast, context); - break; - case 139 /* GetAccessor */: - createGetAccessorDeclaration(ast, context); - break; - case 140 /* SetAccessor */: - createSetAccessorDeclaration(ast, context); - break; - case 222 /* FunctionExpression */: - createFunctionExpressionDeclaration(ast, context); - break; - case 135 /* MemberFunctionDeclaration */: - createMemberFunctionDeclaration(ast, context); - break; - case 144 /* IndexSignature */: - createIndexSignatureDeclaration(ast, context); - break; - case 123 /* FunctionType */: - createFunctionTypeDeclaration(ast, context); - break; - case 125 /* ConstructorType */: - createConstructorTypeDeclaration(ast, context); - break; - case 142 /* CallSignature */: - createCallSignatureDeclaration(ast, context); - break; - case 143 /* ConstructSignature */: - createConstructSignatureDeclaration(ast, context); - break; - case 145 /* MethodSignature */: - createMethodSignatureDeclaration(ast, context); - break; - case 129 /* FunctionDeclaration */: - createFunctionDeclaration(ast, context); - break; - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - createAnyFunctionExpressionDeclaration(ast, null, context); - break; - case 133 /* ImportDeclaration */: - preCollectImportDecls(ast, context); - break; - case 238 /* TypeParameter */: - preCollectTypeParameterDecl(ast, context); - break; - case 236 /* CatchClause */: - preCollectCatchDecls(ast, context); - break; - case 163 /* WithStatement */: - preCollectWithDecls(ast, context); - break; - case 215 /* ObjectLiteralExpression */: - preCollectObjectLiteralDecls(ast, context); - break; - case 240 /* SimplePropertyAssignment */: - preCollectSimplePropertyAssignmentDecls(ast, context); - break; - case 241 /* FunctionPropertyAssignment */: - preCollectFunctionPropertyAssignmentDecls(ast, context); - break; - } - } - - function isContainer(decl) { - return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.kind & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.kind & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.kind; - - if (kind & 4 /* Container */) { - return (decl.flags & 32768 /* InitializedModule */) !== 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, context) { - var currentDecl = context.getParent(); - - if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { - if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - return; - } - } - - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDeclaration = ast; - if (moduleDeclaration.stringLiteral) { - TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); - context.popParent(); - } else { - var moduleNames = getModuleNames(moduleDeclaration.name); - for (var i = moduleNames.length - 1; i >= 0; i--) { - var moduleName = moduleNames[i]; - TypeScript.Debug.assert(currentDecl.ast() === moduleName); - context.popParent(); - currentDecl = context.getParent(); - } - } - } - - if (ast.kind() === 132 /* EnumDeclaration */) { - computeEnumElementConstantValues(ast, currentDecl, context); - } - - while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { - context.popParent(); - currentDecl = context.getParent(); - } - } - - function computeEnumElementConstantValues(ast, enumDecl, context) { - TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); - - var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); - var inConstantSection = !isAmbientEnum; - var currentConstantValue = 0; - var enumMemberDecls = enumDecl.getChildDecls(); - - for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { - var enumElement = ast.enumElements.nonSeparatorAt(i); - var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { - return context.semanticInfoChain.getASTForDecl(d) === enumElement; - }); - - TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); - - if (enumElement.equalsValueClause === null) { - if (inConstantSection) { - enumElementDecl.constantValue = currentConstantValue; - currentConstantValue++; - } - } else { - enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); - if (enumElementDecl.constantValue !== null && !isAmbientEnum) { - inConstantSection = true; - currentConstantValue = enumElementDecl.constantValue + 1; - } else { - inConstantSection = false; - } - } - - TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); - } - } - - function computeEnumElementConstantValue(expression, enumMemberDecls, context) { - TypeScript.Debug.assert(expression); - - if (TypeScript.isIntegerLiteralAST(expression)) { - var token; - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - token = expression.operand; - break; - default: - token = expression; - } - - var value = token.value(); - return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; - } else if (context.propagateEnumConstants) { - switch (expression.kind()) { - case 11 /* IdentifierName */: - var name = expression; - var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { - return d.name === name.valueText(); - }); - - return matchingEnumElement ? matchingEnumElement.constantValue : null; - - case 202 /* LeftShiftExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left << right; - - case 189 /* BitwiseOrExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left | right; - } - - return null; - } else { - return null; - } - } - - (function (DeclarationCreator) { - function create(document, semanticInfoChain, compilationSettings) { - var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); - - TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); - - return declCollectionContext.getParent(); - } - DeclarationCreator.create = create; - })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); - var DeclarationCreator = TypeScript.DeclarationCreator; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBinder = (function () { - function PullSymbolBinder(semanticInfoChain) { - this.semanticInfoChain = semanticInfoChain; - this.declsBeingBound = []; - } - PullSymbolBinder.prototype.getParent = function (decl, returnInstanceType) { - if (typeof returnInstanceType === "undefined") { returnInstanceType = false; } - var parentDecl = decl.getParentDecl(); - - if (parentDecl.kind == 1 /* Script */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.hasBeenBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - if (parent) { - var parentDeclKind = parentDecl.kind; - if (parentDeclKind == 262144 /* GetAccessor */) { - parent = parent.getGetter(); - } else if (parentDeclKind == 524288 /* SetAccessor */) { - parent = parent.getSetter(); - } - } - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = parent.getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.type; - } - } - - return parent.type; - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.name, declKind); - } - - var contextSymbolPath = startingDecl.getParentPath(); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].kind & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - }; - - PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { - var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728539 /* SomeType */) !== 0; - var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; - var name = decl.name; - if (parent) { - var isExported = (decl.flags & 1 /* Exported */) !== 0; - - var prevSymbol = null; - if (lookingForValue) { - prevSymbol = parent.findContainedNonMember(name); - } else if (lookingForType) { - prevSymbol = parent.findContainedNonMemberType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); - } - var prevIsExported = !prevSymbol; - if (!prevSymbol) { - if (lookingForValue) { - prevSymbol = parent.findMember(name, false); - } else if (lookingForType) { - prevSymbol = parent.findNestedType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findNestedContainer(name, searchKind); - } - } - - if (isExported && prevIsExported) { - return prevSymbol; - } - if (prevSymbol) { - var prevDecls = prevSymbol.getDeclarations(); - var lastPrevDecl = prevDecls[prevDecls.length - 1]; - var parentDecl = decl.getParentDecl(); - var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); - if (parentDecl !== prevParentDecl) { - return null; - } - - return prevSymbol; - } - } else { - var parentDecl = decl.getParentDecl(); - if (parentDecl && parentDecl.kind === 1 /* Script */) { - return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); - } else { - var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); - return prevDecls[0] && prevDecls[0].getSymbol(); - } - } - - return null; - }; - - PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { - if (typeof reportError === "undefined") { reportError = true; } - 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 (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()]); - } - return false; - } - - return true; - }; - - PullSymbolBinder.prototype.bindEnumDeclarationToPullSymbol = function (enumContainerDecl) { - var enumName = enumContainerDecl.name; - - var enumContainerSymbol = null; - var enumInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var enumInstanceDecl = enumContainerDecl.getValueDecl(); - - var enumDeclKind = enumContainerDecl.kind; - - var parent = this.getParent(enumContainerDecl); - var parentInstanceSymbol = this.getParent(enumContainerDecl, true); - var parentDecl = enumContainerDecl.getParentDecl(); - var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); - - var isExported = enumContainerDecl.flags & 1 /* Exported */; - var isInitializedModule = (enumContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; - - var createdNewSymbol = false; - - enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); - - if (enumContainerSymbol) { - if (enumContainerSymbol.kind !== enumDeclKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(enumAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [enumContainerDecl.getDisplayName()]); - } - enumContainerSymbol = null; - } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { - enumContainerSymbol = null; - } - } - - if (enumContainerSymbol) { - enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); - } else { - enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); - } - } - - enumContainerSymbol.addDeclaration(enumContainerDecl); - enumContainerDecl.setSymbol(enumContainerSymbol); - - this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); - this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - - if (!enumInstanceSymbol && isInitializedModule) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] == enumContainerDecl) { - break; - } - - if ((siblingDecls[i].name == enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol) { - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - enumInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); - } - - enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - enumInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); - } - } - - 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); - } else { - parent.addEnclosedNonMemberType(enumContainerSymbol); - } - } - - this.bindEnumIndexerDeclsToPullSymbols(enumContainerDecl, 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 */); - - syntheticIndexerParameterSymbol.type = this.semanticInfoChain.numberTypeSymbol; - syntheticIndexerParameterSymbol.setResolved(); - - var syntheticIndexerSignatureSymbol = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - syntheticIndexerSignatureSymbol.addParameter(syntheticIndexerParameterSymbol); - syntheticIndexerSignatureSymbol.returnType = this.semanticInfoChain.stringTypeSymbol; - syntheticIndexerSignatureSymbol.setResolved(); - - var enumContainerInstanceTypeSymbol = enumContainerSymbol.getInstanceSymbol().type; - enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); - - indexSigDecl.setSignatureSymbol(syntheticIndexerSignatureSymbol); - indexParamDecl.setSymbol(syntheticIndexerParameterSymbol); - - syntheticIndexerSignatureSymbol.addDeclaration(indexSigDecl); - syntheticIndexerParameterSymbol.addDeclaration(indexParamDecl); - }; - - 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); - if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleContainerDecl.kind === 32 /* DynamicModule */); - TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); - - moduleDeclAST = moduleNameAST; - } - - var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); - var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) != 0; - - if (parent && moduleKind == 32 /* DynamicModule */) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); - } - - var createdNewSymbol = false; - - moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); - - if (moduleContainerTypeSymbol) { - if (moduleContainerTypeSymbol.kind !== moduleKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [moduleContainerDecl.getDisplayName()]); - } - - moduleContainerTypeSymbol = null; - } 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 { - moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - 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 moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - - if (createdNewSymbol) { - if (parent) { - if (moduleContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); - } else { - parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); - } - } - } - - var valueDecl = moduleContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - - if (!valueDecl.hasSymbol()) { - valueDecl.setSymbol(moduleInstanceSymbol); - if (!moduleInstanceSymbol.hasDeclaration(valueDecl)) { - moduleInstanceSymbol.addDeclaration(valueDecl); - } - } - } - - var otherDecls = this.findDeclsInContext(moduleContainerDecl, moduleContainerDecl.kind, true); - - if (otherDecls && otherDecls.length) { - for (var i = 0; i < otherDecls.length; i++) { - otherDecls[i].ensureSymbolIsBound(); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.flags; - var declKind = importDeclaration.kind; - var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); - - var isExported = false; - var importSymbol = null; - var declName = importDeclaration.name; - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(importDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [importDeclaration.getDisplayName()]); - importSymbol = null; - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(importSymbol); - } else { - parent.addEnclosedNonMemberContainer(importSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindClassDeclarationToPullSymbol = function (classDecl) { - var className = classDecl.name; - var classSymbol = null; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - var classAST = this.semanticInfoChain.getASTForDecl(classDecl); - - var parent = this.getParent(classDecl); - var parentDecl = classDecl.getParentDecl(); - var isExported = classDecl.flags & 1 /* Exported */; - var isGeneric = false; - - classSymbol = this.getExistingSymbol(classDecl, 58728539 /* SomeType */, parent); - - if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDiagnosticFromAST(classAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [classDecl.getDisplayName()]); - classSymbol = null; - } - - var decls; - - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); - this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); - - if (parent) { - if (classDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(classSymbol); - } else { - parent.addEnclosedNonMemberType(classSymbol); - } - } - - constructorSymbol = classSymbol.getConstructorMethod(); - constructorTypeSymbol = constructorSymbol ? constructorSymbol.type : null; - - if (!constructorSymbol) { - var siblingValueDecls = null; - if (parentDecl) { - siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); - - if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { - constructorSymbol = siblingValueDecls[0].getSymbol(); - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - constructorSymbol.setIsSynthesized(); - constructorSymbol.type = constructorTypeSymbol; - } - - classSymbol.setConstructorMethod(constructorSymbol); - classSymbol.setHasDefaultConstructor(); - } - - if (constructorSymbol.getIsSynthesized()) { - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - constructorTypeSymbol.addDeclaration(classDecl); - } else { - classSymbol.setHasDefaultConstructor(false); - } - - 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); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.name; - var interfaceSymbol = null; - - var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728539 /* SomeType */, parent); - - if (interfaceSymbol) { - if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDiagnosticFromAST(interfaceAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [interfaceDecl.getDisplayName()]); - interfaceSymbol = null; - } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { - interfaceSymbol = null; - } - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - if (interfaceDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(interfaceSymbol); - } else { - parent.addEnclosedNonMemberType(interfaceSymbol); - } - } - } - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); - - interfaceSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - - break; - } - } - } - - 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) { - var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.kind; - var declFlags = constructorTypeDeclaration.flags; - var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); - - var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - signature.hasVarArgs = true; - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - constructorTypeSymbol.addConstructSignature(signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, false); - - constructorTypeSymbol.addConstructorTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindVariableDeclarationToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var varDeclAST = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var variableSymbol = null; - - var declName = variableDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - 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; - - variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var decl; - var decls; - var ast; - var members; - - if (variableSymbol) { - var prevKind = variableSymbol.kind; - var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); - var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); - var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); - var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - var prevIsFunction = prevKind == 16384 /* Function */; - var prevIsAmbient = variableSymbol.allDeclsHaveFlag(8 /* Ambient */); - 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 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()])); - 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); - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } else { - this.checkThatExportsMatch(variableDeclaration, variableSymbol); - variableSymbol = null; - parentHadSymbol = false; - } - } - - if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } - } - - if ((declFlags & 118784 /* ImplicitVariable */) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - if (!parent && parentDecl.kind === 1 /* Script */) { - this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); - } - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfoChain.setSymbolForAST(varDeclAST.propertyName, variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - 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(); - } - } - } - } - - if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728539 /* SomeType */, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfoChain.getASTForDecl(decl); - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else if (declFlags & 102400 /* SomeInitializedModule */) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - 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(); - } - } - } - } - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - if (moduleContainerTypeSymbol) { - variableSymbol = moduleContainerTypeSymbol.getInstanceSymbol(); - - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - variableDeclaration.setSymbol(variableSymbol); - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - variableDeclaration.setSymbol(variableSymbol); - } - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addMember(variableSymbol); - } else { - 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) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var declName = variableDeclaration.name; - - var variableSymbol = new TypeScript.PullSymbol(declName, declKind); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - - this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); - }; - - PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - var propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - - var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; - - var isStatic = false; - var isOptional = false; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDiagnostic(TypeScript.diagnosticFromDecl(propertyDeclaration, TypeScript.DiagnosticCode.Duplicate_identifier_0, [propertyDeclaration.getDisplayName()])); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); - - if (isOptional) { - propertySymbol.isOptional = true; - } - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { - var parameters = []; - var params = TypeScript.createIntrinsicsObject(); - var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); - - if (parameterList) { - for (var i = 0, n = parameterList.length; i < n; i++) { - var argDecl = parameterList.astAt(i); - var id = parameterList.identifierAt(i); - var decl = this.semanticInfoChain.getDeclForAST(argDecl); - var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); - var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); - - if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { - 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) { - if (isProperty) { - decl.ensureSymbolIsBound(); - var valDecl = decl.getValueDecl(); - - if (valDecl) { - valDecl.setSymbol(parameterSymbol); - parameterSymbol.addDeclaration(valDecl); - } - } else { - parameterSymbol.addDeclaration(decl); - decl.setSymbol(parameterSymbol); - } - } - - signatureSymbol.addParameter(parameterSymbol, parameterSymbol.isOptional); - - if (signatureSymbol.isDefinition()) { - funcType.addEnclosedNonMember(parameterSymbol); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.kind; - var declFlags = functionDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - 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; - if (!acceptableRedeclaration) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [functionDeclaration.getDisplayName()]); - functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); - } - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.type; - parentHadSymbol = true; - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionSymbol.type = functionTypeSymbol; - functionTypeSymbol.setFunctionSymbol(functionSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol); - } else { - parent.addEnclosedNonMember(functionSymbol); - } - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { - signature.hasVarArgs = true; - } - - var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - 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(); - } - } - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.kind; - 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 funcExpAST = ast; - - 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); - - functionSymbol.type = functionTypeSymbol; - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; - if (name) { - this.semanticInfoChain.setSymbolForAST(name, functionSymbol); - } - - this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - - var signature = new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (parameters.lastParameterIsRest()) { - signature.hasVarArgs = true; - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - - functionTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.kind; - var declFlags = functionTypeDeclaration.flags; - var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcTypeAST, TypeScript.Parameters.fromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - - functionTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.kind; - var declFlags = methodDeclaration.flags; - var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - 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()]); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.type; - parentHadSymbol = true; - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - methodSymbol.type = methodTypeSymbol; - methodTypeSymbol.setFunctionSymbol(methodSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - - var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; - - TypeScript.Debug.assert(nameAST); - - this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); - this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); - - if (isOptional) { - methodSymbol.isOptional = true; - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol); - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(sigKind) : new TypeScript.PullDefinitionSignatureSymbol(sigKind); - - var parameterList = TypeScript.getParameterList(methodAST); - if (TypeScript.lastParameterIsRest(parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].name; - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName, true); - signature.addTypeParameter(typeParameter); - } else { - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.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(); - } - } - }; - - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (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()])); - } - - 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); - - prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - prototypeSymbol.setIsSynthesized(); - prototypeSymbol.addDeclaration(prototypeDecl); - prototypeSymbol.type = classTypeSymbol; - constructorTypeSymbol.addMember(prototypeSymbol); - - if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { - var resolver = this.semanticInfoChain.getResolver(); - prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); - } - prototypeSymbol.setResolved(); - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.kind; - var declFlags = constructorDeclaration.flags; - var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { - var hasDefinitionSignature = false; - var constructorSigs = constructorSymbol.type.getConstructSignatures(); - - for (var i = 0; i < constructorSigs.length; i++) { - if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { - hasDefinitionSignature = true; - break; - } - } - - if (hasDefinitionSignature) { - this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); - - constructorSymbol = null; - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.type = constructorTypeSymbol; - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - constructorSymbol.setIsSynthesized(false); - this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - - var constructSignature = isSignature ? new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */) : new TypeScript.PullDefinitionSignatureSymbol(2097152 /* ConstructSignature */); - - constructSignature.returnType = parent; - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, TypeScript.Parameters.fromParameterList(constructorAST.parameterList), constructorTypeSymbol, constructSignature); - - var typeParameters = constructorTypeSymbol.getTypeParameters(); - - for (var i = 0; i < typeParameters.length; i++) { - constructSignature.addTypeParameter(typeParameters[i]); - } - - if (TypeScript.lastParameterIsRest(constructorAST.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); - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - constructSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(TypeScript.getParameterList(funcDecl)), null, constructSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - - parent.addConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { - callSignature.hasVarArgs = true; - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name, true); - - callSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameterList(funcDecl.parameterList), null, callSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - - parent.addCallSignature(callSignature); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.Parameters.fromParameter(funcDecl.parameter), null, indexSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); - - var parent = this.getParent(indexSignatureDeclaration); - parent.addIndexSignature(indexSignature); - indexSignature.setContainer(parent); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.kind; - var declFlags = getAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.type; - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - getterTypeSymbol.setFunctionSymbol(getterSymbol); - - getterSymbol.type = getterTypeSymbol; - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - - getterTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.kind; - var declFlags = setAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - - if (setterSymbol) { - setterTypeSymbol = setterSymbol.type; - } - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - setterTypeSymbol.setFunctionSymbol(setterSymbol); - - setterSymbol.type = setterTypeSymbol; - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = isSignature ? new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */) : new TypeScript.PullDefinitionSignatureSymbol(1048576 /* CallSignature */); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.Parameters.fromParameterList(funcDeclAST.parameterList), setterTypeSymbol, signature); - - setterTypeSymbol.addCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindDeclToPullSymbol = function (decl) { - if (decl.hasBeenBound()) { - return; - } - - if (this.declsBeingBound.indexOf(decl.declID) >= 0) { - return; - } - - this.declsBeingBound.push(decl.declID); - - switch (decl.kind) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - this.bindEnumDeclarationToPullSymbol(decl); - break; - - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 512 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 1024 /* CatchVariable */: - this.bindCatchVariableToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - this.bindEnumMemberDeclarationToPullSymbol(decl); - break; - - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 128 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - decl.getParentDecl().getSymbol(); - break; - - case 268435456 /* CatchBlock */: - case 134217728 /* WithBlock */: - break; - - default: - TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); - } - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); - this.declsBeingBound.pop(); - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullHelpers) { - function getSignatureForFuncDecl(functionDecl) { - var funcDecl = functionDecl.ast(); - var funcSymbol = functionDecl.getSymbol(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().type; - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.type; - } - var signatures; - - if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (functionDecl.kind === 4194304 /* IndexSignature */) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; - } - PullHelpers.symbolIsEnum = symbolIsEnum; - - function symbolIsModule(symbol) { - return symbol && (symbol.kind == 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); - } - PullHelpers.symbolIsModule = symbolIsModule; - - function isOneDeclarationOfKind(symbol, kind) { - var decls = symbol.getDeclarations(); - for (var i = 0; i < decls.length; i++) { - if (decls[i].kind === kind) { - return true; - } - } - - return false; - } - - function isNameNumeric(name) { - return isFinite(+name); - } - PullHelpers.isNameNumeric = isNameNumeric; - - function typeSymbolsAreIdentical(a, b) { - if (a.isTypeReference() && !a.getIsSpecialized()) { - a = a.referencedTypeSymbol; - } - - if (b.isTypeReference() && !b.getIsSpecialized()) { - b = b.referencedTypeSymbol; - } - - return a == b; - } - PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; - - function getRootType(type) { - var rootType = type.getRootSymbol(); - - while (true) { - if (type == rootType) { - return type; - } - - type = rootType; - rootType = type.getRootSymbol(); - } - } - PullHelpers.getRootType = getRootType; - - function isSymbolLocal(symbol) { - var container = symbol.getContainer(); - if (container) { - var containerKind = container.kind; - if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { - return true; - } - - if (containerKind == 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */)) { - return true; - } - } - - return false; - } - PullHelpers.isSymbolLocal = isSymbolLocal; - })(TypeScript.PullHelpers || (TypeScript.PullHelpers = {})); - var PullHelpers = TypeScript.PullHelpers; -})(TypeScript || (TypeScript = {})); -if (Error) - Error.stackTraceLimit = 1000; - -var TypeScript; -(function (TypeScript) { - TypeScript.fileResolutionTime = 0; - TypeScript.fileResolutionIOTime = 0; - TypeScript.fileResolutionScanImportsTime = 0; - TypeScript.fileResolutionImportFileSearchTime = 0; - TypeScript.fileResolutionGetDefaultLibraryTime = 0; - TypeScript.sourceCharactersCompiled = 0; - TypeScript.syntaxTreeParseTime = 0; - TypeScript.syntaxDiagnosticsTime = 0; - TypeScript.astTranslationTime = 0; - TypeScript.typeCheckTime = 0; - - TypeScript.compilerResolvePathTime = 0; - TypeScript.compilerDirectoryNameTime = 0; - TypeScript.compilerDirectoryExistsTime = 0; - TypeScript.compilerFileExistsTime = 0; - - TypeScript.emitTime = 0; - TypeScript.emitWriteFileTime = 0; - - TypeScript.declarationEmitTime = 0; - TypeScript.declarationEmitIsExternallyVisibleTime = 0; - TypeScript.declarationEmitTypeSignatureTime = 0; - TypeScript.declarationEmitGetBoundDeclTypeTime = 0; - TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; - TypeScript.declarationEmitGetBaseTypeTime = 0; - TypeScript.declarationEmitGetAccessorFunctionTime = 0; - TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; - TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; - - TypeScript.ioHostResolvePathTime = 0; - TypeScript.ioHostDirectoryNameTime = 0; - TypeScript.ioHostCreateDirectoryStructureTime = 0; - TypeScript.ioHostWriteFileTime = 0; - - var EmitOutput = (function () { - function EmitOutput() { - this.outputFiles = []; - this.diagnostics = []; - } - return EmitOutput; - })(); - TypeScript.EmitOutput = EmitOutput; - - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); - var OutputFileType = TypeScript.OutputFileType; - - var OutputFile = (function () { - function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { - if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.text = text; - this.fileType = fileType; - this.sourceMapEntries = sourceMapEntries; - } - return OutputFile; - })(); - TypeScript.OutputFile = OutputFile; - - var CompileResult = (function () { - function CompileResult() { - this.diagnostics = []; - this.outputFiles = []; - } - CompileResult.fromDiagnostics = function (diagnostics) { - var result = new CompileResult(); - result.diagnostics = diagnostics; - return result; - }; - - CompileResult.fromOutputFiles = function (outputFiles) { - var result = new CompileResult(); - result.outputFiles = outputFiles; - return result; - }; - return CompileResult; - })(); - TypeScript.CompileResult = CompileResult; - - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, _settings) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } - this.logger = logger; - this._settings = _settings; - this.semanticInfoChain = null; - this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); - } - TypeScriptCompiler.prototype.compilationSettings = function () { - return this._settings; - }; - - TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { - var oldSettings = this._settings; - this._settings = newSettings; - - if (!compareDataObjects(oldSettings, newSettings)) { - this.semanticInfoChain.invalidate(oldSettings, newSettings); - } - }; - - TypeScriptCompiler.prototype.getDocument = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.semanticInfoChain.getDocument(fileName); - }; - - TypeScriptCompiler.prototype.cleanupSemanticCache = function () { - this.semanticInfoChain.invalidate(); - }; - - TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - fileName = TypeScript.switchToForwardSlashes(fileName); - - TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); - - var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); - - this.semanticInfoChain.addDocument(document); - }; - - TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); - - this.semanticInfoChain.addDocument(updatedDocument); - }; - - TypeScriptCompiler.prototype.removeFile = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - 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; - if (emitOptions.outputDirectory() !== "") { - updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); - updatedFileName = emitOptions.outputDirectory() + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(emitOptions.sharedOutputFile(), true); - } - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - var printReason = false; - - if (document.emitToOwnOutputFile()) { - var result = document.byteOrderMark !== 0 /* None */; - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - } - return result; - } else { - var fileNames = this.fileNames(); - - var result = false; - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - - if (document.isExternalModule()) { - continue; - } - - if (document.byteOrderMark !== 0 /* None */) { - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - result = true; - } else { - return true; - } - } - } - - return result; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype._shouldEmit = function (document) { - return !document.isDeclareFile(); - }; - - TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { - if (!this.compilationSettings().generateDeclarationFiles()) { - return false; - } - - return this._shouldEmit(document); - }; - - TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); - - if (declarationEmitter) { - declarationEmitter.document = document; - } else { - var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); - } - - declarationEmitter.emitDeclarations(sourceUnit); - return declarationEmitter; - }; - - TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmitDeclarations(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFile()); - } - } else { - sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var sharedEmitter = null; - var fileNames = this.fileNames(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileNames[i]); - - sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); - } - - TypeScript.declarationEmitTime += new Date().getTime() - start; - - return emitOutput; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, null); - return emitOutput; - } else { - return this.emitAllDeclarations(resolvePath); - } - }; - - TypeScriptCompiler.mapToFileNameExtension = function (extension, fileName, wholeFileNameReplaced) { - if (wholeFileNameReplaced) { - return fileName; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmit(document)); - - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); - var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); - - if (this.compilationSettings().mapSourceFiles()) { - var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); - emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); - } - } else if (this.compilationSettings().mapSourceFiles()) { - emitter.setSourceMapperNewSourceFile(document); - } - - emitter.setDocument(document); - emitter.emitJavascript(sourceUnit, false); - - return emitter; - }; - - TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmit(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFiles()); - } - } else { - sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var fileNames = this.fileNames(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - sharedEmitter = this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); - } - - TypeScript.emitTime += new Date().getTime() - start; - return emitOutput; - }; - - TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.diagnostics.push(emitOptions.diagnostic()); - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, null); - return emitOutput; - } else { - return this.emitAll(resolvePath); - } - }; - - TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { - if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } - return new CompilerIterator(this, resolvePath, continueOnDiagnostics); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - - TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { - return this.getDocument(fileName).sourceUnit(); - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - - var startTime = (new Date()).getTime(); - TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); - var endTime = (new Date()).getTime(); - - TypeScript.typeCheckTime += endTime - startTime; - - var errors = this.semanticInfoChain.getDiagnostics(fileName); - - errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); - errors.sort(function (d1, d2) { - if (d1.fileName() < d2.fileName()) { - return -1; - } else if (d1.fileName() > d2.fileName()) { - return 1; - } - - if (d1.start() < d2.start()) { - return -1; - } else if (d1.start() > d2.start()) { - return 1; - } - - var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; - var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; - if (code1 < code2) { - return -1; - } else if (code1 > code2) { - return 1; - } - - return 0; - }); - - return errors; - }; - - TypeScriptCompiler.prototype.resolveAllFiles = function () { - var fileNames = this.fileNames(); - for (var i = 0, n = fileNames.length; i < n; i++) { - this.getSemanticDiagnostics(fileNames[i]); - } - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var ast = this.semanticInfoChain.getASTForDecl(decl); - if (!ast) { - return null; - } - - var enclosingDecl = resolver.getEnclosingDecl(decl); - if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { - return this.getSymbolOfDeclaration(enclosingDecl); - } - - return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { - var scriptName = document.fileName; - - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - var inWithBlock = false; - - var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); - - if (!ast) { - return null; - } - - var path = this.getASTPath(ast); - - for (var i = 0, n = path.length; i < n; i++) { - var current = path[i]; - - switch (current.kind()) { - case 222 /* FunctionExpression */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - if (propagateContextualTypes) { - resolver.resolveAST(current, true, resolutionContext); - } - break; - - case 136 /* MemberVariableDeclaration */: - var memberVariable = current; - inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); - break; - - case 225 /* VariableDeclarator */: - var variableDeclarator = current; - inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); - break; - - case 213 /* InvocationExpression */: - case 216 /* ObjectCreationExpression */: - if (propagateContextualTypes) { - var isNew = current.kind() === 216 /* ObjectCreationExpression */; - var callExpression = current; - 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); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = path[i + 3]; - if (argExpression) { - for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { - if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext); - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 214 /* ArrayLiteralExpression */: - if (propagateContextualTypes) { - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 215 /* ObjectLiteralExpression */: - if (propagateContextualTypes) { - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.propertyAssignments; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { - if (memberDecls.nonSeparatorAt(j) === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - } - - break; - - case 174 /* AssignmentExpression */: - if (propagateContextualTypes) { - var assignmentExpression = current; - var contextualType = null; - - if (path[i + 1] && path[i + 1] === assignmentExpression.right) { - var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 150 /* ReturnStatement */: - if (propagateContextualTypes) { - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var currentContextualTypeSignatureSymbol = currentContextualType.getDeclarations()[0].getSignatureSymbol(); - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushContextualType(contextualType, false, null); - } - - break; - - case 122 /* ObjectType */: - if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { - resolver.resolveAST(current, false, resolutionContext); - } - - break; - - case 163 /* WithStatement */: - inWithBlock = true; - break; - } - - var decl = this.semanticInfoChain.getDeclForAST(current); - if (decl) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { - if (ast.parent.kind() === 212 /* MemberAccessExpression */) { - if (ast.parent.name === ast) { - ast = ast.parent; - } - } else if (ast.parent.kind() === 121 /* QualifiedName */) { - if (ast.parent.right === ast) { - ast = ast.parent; - } - } - } - - return { - ast: ast, - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment, - inWithBlock: inWithBlock - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { - if (inContextuallyTypedAssignment) { - if (propagateContextualTypes) { - resolver.resolveAST(assigningAST, false, resolutionContext); - var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.type; - } - - resolutionContext.pushContextualType(contextualType, false, null); - - if (init) { - resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); - } - } - } - }; - - TypeScriptCompiler.prototype.getASTPath = function (ast) { - var result = []; - - while (ast) { - result.unshift(ast); - ast = ast.parent; - } - - return result; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - ast = context.ast; - 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()]); - return null; - } - - if (symbol.isTypeReference()) { - symbol = symbol.getReferencedTypeSymbol(); - } - - var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); - - return { - symbol: symbol, - aliasSymbol: aliasSymbol, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { - if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { - return null; - } - - var isNew = ast.kind() === 216 /* ObjectCreationExpression */; - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, false); - if (!context || context.inWithBlock) { - return null; - } - - return resolver.getVisibleDecls(context.enclosingDecl); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { - if (ast.kind() !== 215 /* ObjectLiteralExpression */) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var astForDecl = decl.ast(); - if (!astForDecl) { - return null; - } - - var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); - if (!astForDeclContext) { - return null; - } - - var symbol = decl.getSymbol(); - resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - aliasSymbol: null, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - - TypeScriptCompiler.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast); - }; - - TypeScriptCompiler.prototype.fileNames = function () { - return this.semanticInfoChain.fileNames(); - }; - - TypeScriptCompiler.prototype.topLevelDecl = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - return TypeScriptCompiler; - })(); - TypeScript.TypeScriptCompiler = TypeScriptCompiler; - - var CompilerPhase; - (function (CompilerPhase) { - CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; - CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; - CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; - CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; - CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; - })(CompilerPhase || (CompilerPhase = {})); - - var CompilerIterator = (function () { - function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { - if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } - this.compiler = compiler; - this.resolvePath = resolvePath; - this.continueOnDiagnostics = continueOnDiagnostics; - this.index = -1; - this.fileNames = null; - this._current = null; - this._emitOptions = null; - this._sharedEmitter = null; - this._sharedDeclarationEmitter = null; - this.hadSyntacticDiagnostics = false; - this.hadSemanticDiagnostics = false; - this.hadEmitDiagnostics = false; - this.fileNames = compiler.fileNames(); - this.compilerPhase = startingPhase; - } - CompilerIterator.prototype.current = function () { - return this._current; - }; - - CompilerIterator.prototype.moveNext = function () { - this._current = null; - - while (this.moveNextInternal()) { - if (this._current) { - return true; - } - } - - return false; - }; - - CompilerIterator.prototype.moveNextInternal = function () { - this.index++; - - while (this.shouldMoveToNextPhase()) { - this.index = 0; - this.compilerPhase++; - } - - if (this.compilerPhase > 4 /* DeclarationEmit */) { - return false; - } - - switch (this.compilerPhase) { - case 0 /* Syntax */: - return this.moveNextSyntaxPhase(); - case 1 /* Semantics */: - return this.moveNextSemanticsPhase(); - case 2 /* EmitOptionsValidation */: - return this.moveNextEmitOptionsValidationPhase(); - case 3 /* Emit */: - return this.moveNextEmitPhase(); - case 4 /* DeclarationEmit */: - return this.moveNextDeclarationEmitPhase(); - } - }; - - CompilerIterator.prototype.shouldMoveToNextPhase = function () { - switch (this.compilerPhase) { - case 2 /* EmitOptionsValidation */: - return this.index === 1; - - case 0 /* Syntax */: - case 1 /* Semantics */: - return this.index == this.fileNames.length; - - case 3 /* Emit */: - case 4 /* DeclarationEmit */: - return this.index == (this.fileNames.length + 1); - } - - return false; - }; - - CompilerIterator.prototype.moveNextSyntaxPhase = function () { - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - - var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSyntacticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextSemanticsPhase = function () { - if (this.hadSyntacticDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - var diagnostics = this.compiler.getSemanticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSemanticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - - if (!this._emitOptions) { - this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); - } - - if (this._emitOptions.diagnostic()) { - if (!this.continueOnDiagnostics) { - this.hadEmitDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(this._emitOptions); - - if (this.hadEmitDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { - _this._current = CompileResult.fromOutputFiles(outputFiles); - }, this._sharedEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedEmitter) { - this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); - } - - return true; - }; - - CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(!this.hadEmitDiagnostics); - if (this.hadSemanticDiagnostics) { - return false; - } - - if (!this.compiler.compilationSettings().generateDeclarationFiles()) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { - _this._current = CompileResult.fromOutputFiles([file]); - }, this._sharedDeclarationEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { - this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); - } - - return true; - }; - return CompilerIterator; - })(); - - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] == "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } else if (typeof dst[e] != "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - TypeScript.compareDataObjects = compareDataObjects; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (GenerativeTypeClassification) { - GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; - GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; - GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; - GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; - })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); - var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; - - var PullTypeReferenceSymbol = (function (_super) { - __extends(PullTypeReferenceSymbol, _super); - function PullTypeReferenceSymbol(referencedTypeSymbol) { - _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); - this.referencedTypeSymbol = referencedTypeSymbol; - this.isResolved = true; - - TypeScript.Debug.assert(referencedTypeSymbol != null, "Type root symbol may not be null"); - - this.setRootSymbol(referencedTypeSymbol); - - this.typeReference = this; - } - PullTypeReferenceSymbol.createTypeReference = function (type) { - if (type.isTypeReference()) { - return type; - } - - var typeReference = type.typeReference; - - if (!typeReference) { - typeReference = new PullTypeReferenceSymbol(type); - type.typeReference = typeReference; - } - - return typeReference; - }; - - PullTypeReferenceSymbol.prototype.isTypeReference = function () { - return true; - }; - - PullTypeReferenceSymbol.prototype.setResolved = function () { - }; - - PullTypeReferenceSymbol.prototype.setUnresolved = function () { - }; - PullTypeReferenceSymbol.prototype.invalidate = function () { - }; - - PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { - this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); - }; - - PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol; - }; - - PullTypeReferenceSymbol.prototype._getResolver = function () { - return this.referencedTypeSymbol._getResolver(); - }; - - PullTypeReferenceSymbol.prototype.hasMembers = function () { - return this.referencedTypeSymbol.hasMembers(); - }; - - PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); - }; - - PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - return this.referencedTypeSymbol.getAssociatedContainerType(); - }; - - PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getFunctionSymbol(); - }; - PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); - }; - - PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); - }; - PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); - }; - - PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); - }; - PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMember(name); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); - }; - - PullTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getMembers(); - }; - - PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); - }; - PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getHasDefaultConstructor(); - }; - PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructorMethod(); - }; - PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); - }; - PullTypeReferenceSymbol.prototype.getTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.isGeneric = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isGeneric(); - }; - - PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getSpecialization(substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getKnownSpecializations(); - }; - PullTypeReferenceSymbol.prototype.getTypeArguments = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArguments(); - }; - PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.addCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addCallSignature"); - }; - PullTypeReferenceSymbol.prototype.addConstructSignature = function (constructSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructSignature"); - }; - PullTypeReferenceSymbol.prototype.addIndexSignature = function (indexSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addIndexSignature"); - }; - - PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnIndexSignatures(); - }; - PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getIndexSignatures(); - }; - - PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { - this.referencedTypeSymbol.addImplementedType(implementedType); - }; - PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getImplementedTypes(); - }; - PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { - this.referencedTypeSymbol.addExtendedType(extendedType); - }; - PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getExtendedTypes(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExtendsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExtendThisType(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - this.ensureReferencedTypeIsResolved(); - 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); - }; - - PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findMember(name, lookInParent); - }; - PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedType(name, kind); - }; - PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedContainer(name, kind); - }; - PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - }; - - PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findTypeParameter(name); - }; - - PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); - }; - return PullTypeReferenceSymbol; - })(TypeScript.PullTypeSymbol); - TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - - var PullInstantiatedTypeReferenceSymbol = (function (_super) { - __extends(PullInstantiatedTypeReferenceSymbol, _super); - function PullInstantiatedTypeReferenceSymbol(referencedTypeSymbol, _typeParameterArgumentMap) { - _super.call(this, referencedTypeSymbol); - this.referencedTypeSymbol = referencedTypeSymbol; - this._typeParameterArgumentMap = _typeParameterArgumentMap; - this._instantiatedMembers = null; - this._allInstantiatedMemberNameCache = null; - this._instantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - this._instantiatedCallSignatures = null; - this._instantiatedConstructSignatures = null; - this._instantiatedIndexSignatures = null; - this._typeArgumentReferences = null; - this._instantiatedConstructorMethod = null; - this._instantiatedAssociatedContainerType = null; - this._isArray = undefined; - this.isInstanceReferenceType = false; - this._generativeTypeClassification = 0 /* Unknown */; - - TypeScript.nSpecializationsCreated++; - } - PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { - return !this.isInstanceReferenceType; - }; - - 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 */; - } - } - } - } - - return this._generativeTypeClassification; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArray === undefined) { - this._isArray = this.getRootSymbol().isArrayNamedTypeReference() || (this.getRootSymbol() == this._getResolver().getArrayNamedType()); - } - return this._isArray; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { - if (!this.isArrayNamedTypeReference()) { - return null; - } - - var typeArguments = this.getTypeArguments(); - - if (typeArguments != null) { - return typeArguments[0]; - } - - return null; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.getIsSpecialized()) { - return this; - } - - return this.referencedTypeSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.create = function (resolver, type, typeParameterArgumentMap, instantiateFunctionTypeParameters) { - if (typeof instantiateFunctionTypeParameters === "undefined") { instantiateFunctionTypeParameters = false; } - TypeScript.Debug.assert(resolver); - - 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; - } - } - } - } - - if (!instantiateFunctionTypeParameters) { - var instantiation = rootType.getSpecialization(reconstructedTypeArgumentList); - - 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 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) { - 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); - - if (!instantiateFunctionTypeParameters) { - rootType.addSpecialization(instantiation, reconstructedTypeArgumentList); - } - - if (isReferencedType) { - instantiation.isInstanceReferenceType = true; - } - - return instantiation; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return !!this.referencedTypeSymbol.getTypeParameters().length; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { - return this._typeParameterArgumentMap; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { - if (this.isInstanceReferenceType) { - return this.getTypeParameters(); - } - - if (!this._typeArgumentReferences) { - var typeParameters = this.referencedTypeSymbol.getTypeParameters(); - - if (typeParameters.length) { - var typeArgument = null; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; - - if (!typeArgument) { - TypeScript.Debug.fail("type argument count mismatch"); - } - - if (typeArgument) { - typeArguments[typeArguments.length] = typeArgument; - } - } - - this._typeArgumentReferences = typeArguments; - } - } - - return this._typeArgumentReferences; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeArguments(); - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getMembers(); - } - - if (!this._instantiatedMembers) { - var referencedMembers = this.referencedTypeSymbol.getMembers(); - var referencedMember = null; - var instantiatedMember = null; - - this._instantiatedMembers = []; - - for (var i = 0; i < referencedMembers.length; i++) { - referencedMember = referencedMembers[i]; - - 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._instantiatedMembers[this._instantiatedMembers.length] = instantiatedMember; - } - } - - return this._instantiatedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.findMember(name, lookInParent); - } - - var memberSymbol = this._instantiatedMemberNameCache[name]; - - if (!memberSymbol) { - 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; - } else { - memberSymbol = null; - } - } - - return memberSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - } - - var requestedMembers = []; - var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - - if (!this._allInstantiatedMemberNameCache) { - this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - - var members = this.getMembers(); - - for (var i = 0; i < members.length; i++) { - this._allInstantiatedMemberNameCache[members[i].name] = members[i]; - } - } - - var referencedMember = null; - var requestedMember = null; - - for (var i = 0; i < allReferencedMembers.length; i++) { - referencedMember = allReferencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (this._allInstantiatedMemberNameCache[referencedMember.name]) { - requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; - } else { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; - requestedMembers[requestedMembers.length] = referencedMember; - } else { - requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - requestedMember.setRootSymbol(referencedMember); - - requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - requestedMember.isOptional = referencedMember.isOptional; - - this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; - requestedMembers[requestedMembers.length] = requestedMember; - } - } - } - - return requestedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructorMethod(); - } - - if (!this._instantiatedConstructorMethod) { - var referencedConstructorMethod = this.referencedTypeSymbol.getConstructorMethod(); - this._instantiatedConstructorMethod = new TypeScript.PullSymbol(referencedConstructorMethod.name, referencedConstructorMethod.kind); - this._instantiatedConstructorMethod.type = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedConstructorMethod.type, this._typeParameterArgumentMap); - } - - return this._instantiatedConstructorMethod; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - if (!this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAssociatedContainerType(); - } - - if (!this._instantiatedAssociatedContainerType) { - var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); - - if (referencedAssociatedContainerType) { - this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); - } - } - - return this._instantiatedAssociatedContainerType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getCallSignatures(); - } - - if (this._instantiatedCallSignatures) { - return this._instantiatedCallSignatures; - } - - var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); - this._instantiatedCallSignatures = []; - - for (var i = 0; i < referencedCallSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); - - if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; - } else { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedCallSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructSignatures(); - } - - if (this._instantiatedConstructSignatures) { - return this._instantiatedConstructSignatures; - } - - var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); - this._instantiatedConstructSignatures = []; - - for (var i = 0; i < referencedConstructSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); - - if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; - } else { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedConstructSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getIndexSignatures(); - } - - if (this._instantiatedIndexSignatures) { - return this._instantiatedIndexSignatures; - } - - var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); - this._instantiatedIndexSignatures = []; - - for (var i = 0; i < referencedIndexSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); - - if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; - } else { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.previousTokenTrailingComments = null; - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { - var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { - var firstToken = node.firstToken(); - var lastToken = node.lastToken(); - - this.setSpan(ast, fullStart, node, firstToken, lastToken); - ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); - ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); - }; - - SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { - if (element === null) { - return null; - } - - if (element.fullWidth() === 0) { - return new TypeScript.ASTSpan(-1, -1); - } - - var leadingTriviaWidth = element.leadingTriviaWidth(); - var trailingTriviaWidth = element.trailingTriviaWidth(); - - var start = fullStart + leadingTriviaWidth; - var end = fullStart + element.fullWidth() - trailingTriviaWidth; - - return new TypeScript.ASTSpan(start, end); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { - if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } - if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } - var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; - var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; - - var desiredMinChar = fullStart + leadingTriviaWidth; - var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span._trailingTriviaWidth = trailingTriviaWidth; - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - span._start = start; - span._end = end; - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { - var start = this.position; - var array = new Array(node.childCount()); - - for (var i = 0, n = node.childCount(); i < n; i++) { - array[i] = node.childAt(i).accept(this); - } - - var result = new TypeScript.ISyntaxList2(this.fileName, array); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var array = new Array(list.nonSeparatorCount()); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - array[i / 2] = list.childAt(i).accept(this); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); - this.setSpan(result, start, list); - - result.setPostComments(this.previousTokenTrailingComments); - this.previousTokenTrailingComments = null; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { - if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); - }; - - SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { - return this.visitToken(token); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - var fullStart = this.position; - - var result = this.visitTokenWorker(token); - - this.movePast(token); - - var start = fullStart + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { - switch (token.tokenKind) { - case 60 /* AnyKeyword */: - return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); - case 61 /* BooleanKeyword */: - return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); - case 67 /* NumberKeyword */: - return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); - case 69 /* StringKeyword */: - return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); - case 41 /* VoidKeyword */: - return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); - case 35 /* ThisKeyword */: - return new TypeScript.ThisExpression(token.text(), token.valueText()); - case 50 /* SuperKeyword */: - return new TypeScript.SuperExpression(token.text(), token.valueText()); - case 37 /* TrueKeyword */: - return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); - case 24 /* FalseKeyword */: - return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); - case 32 /* NullKeyword */: - return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); - case 14 /* StringLiteral */: - return new TypeScript.StringLiteral(token.text(), token.valueText()); - case 12 /* RegularExpressionLiteral */: - return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); - case 13 /* NumericLiteral */: - var fullStart = this.position; - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); - - result.setPreComments(preComments); - return result; - case 11 /* IdentifierName */: - return new TypeScript.Identifier(token.text()); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { - var start = this.position; - TypeScript.Debug.assert(start === 0); - - var bod = this.visitSyntaxList(node.moduleElements); - - var result = new TypeScript.SourceUnit(bod, this.fileName); - this.setSpanExplicit(result, start, start + node.fullWidth()); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { - var start = this.position; - - this.moveTo(node, node.stringLiteral); - var stringLiteral = node.stringLiteral.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ExternalModuleReference(stringLiteral); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { - var start = this.position; - var moduleName = node.moduleName.accept(this); - - var result = new TypeScript.ModuleNameModuleReference(moduleName); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - this.movePast(node.openBraceToken); - var members = this.visitSyntaxList(node.classElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { - var result = null; - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { - result = result || []; - result.push(1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - result = result || []; - result.push(8 /* Ambient */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { - result = result || []; - result.push(16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { - result = result || []; - result.push(4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { - result = result || []; - result.push(2 /* Private */); - } - - return result || TypeScript.sentinelEmptyArray; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - var body = this.visitObjectType(node.body); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - var start = this.position; - - this.movePast(node.extendsOrImplementsKeyword); - var typeNames = this.visitSeparatedSyntaxList(node.typeNames); - - var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - var start = this.position; - - var modifiers = this.visitModifiers(node.modifiers); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - - var moduleName = node.name ? node.name.accept(this) : null; - var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; - - this.movePast(node.openBraceToken); - - var moduleElements = this.visitSyntaxList(node.moduleElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - this.movePast(node.openBraceToken); - - var enumElements = this.visitSeparatedSyntaxList(node.enumElements); - - this.movePast(node.closeBraceToken); - - var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - var start = this.position; - - var memberName = this.visitToken(node.propertyName); - - var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.EnumElement(memberName, value); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ImportDeclaration(modifiers, name, alias); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExportAssignment(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.VariableStatement(modifiers, declaration); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - var start = this.position; - var propertyName = this.visitToken(node.propertyName); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - var start = this.position; - var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var value = node.value.accept(this); - value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); - - var result = new TypeScript.EqualsValueClause(value); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var start = this.position; - - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var start = this.position; - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayLiteralExpression(expressions); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - var start = this.position; - - var result = new TypeScript.OmittedExpression(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var start = this.position; - - var openParenToken = node.openParenToken; - var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(openParenToken); - - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var start = this.position; - - var identifier = node.identifier.accept(this); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var start = this.position; - - var callSignature = this.visitCallSignature(node.callSignature); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - return type ? type.accept(this) : null; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { - var start = this.position; - this.movePast(node.typeOfKeyword); - var name = node.name.accept(this); - - var result = new TypeScript.TypeQuery(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - var start = this.position; - var left = this.visitType(node.left); - this.movePast(node.dotToken); - var right = this.visitIdentifier(node.right); - - var result = new TypeScript.QualifiedName(left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeArgumentList(typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - var start = this.position; - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - var start = this.position; - - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectType(typeMembers); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayType(underlying); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.name); - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - var result = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.colonToken); - var type = this.visitType(node.type); - - var result = new TypeScript.TypeAnnotation(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - - var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - var start = this.position; - - var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.visitIdentifier(node.name); - - var result = new TypeScript.MemberAccessExpression(expression, name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var start = this.position; - - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.InvocationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - this.movePast(node.openParenToken); - - 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()); - } - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ArgumentList(typeArguments, arguments, closeParenToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - var start = this.position; - - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - var result = new TypeScript.BinaryExpression(node.kind(), left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - var start = this.position; - - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.ConstructSignature(callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.MethodSignature(name, questionToken, callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - var start = this.position; - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.IndexSignature(parameter, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - var openParenToken = node.openParenToken; - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - var openParenTrailingComments = null; - if (node.parameters.childCount() === 0) { - openParenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - } - - this.movePast(node.openParenToken); - var parameters = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - var start = this.position; - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeParameterList(typeParameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - var result = new TypeScript.TypeParameter(identifier, constraint); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - var start = this.position; - this.movePast(node.extendsKeyword); - var type = this.visitType(node.type); - - var result = new TypeScript.Constraint(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - var result = new TypeScript.IfStatement(condition, thenBod, elseBod); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - var start = this.position; - - this.movePast(node.elseKeyword); - var statement = node.statement.accept(this); - - var result = new TypeScript.ElseClause(statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var expression = node.expression.accept(this); - - var semicolonPosition = this.position; - - var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExpressionStatement(expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.parameterList); - var parameters = this.visitParameterList(node.parameterList); - - var block = node.block ? node.block.accept(this) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.ConstructorDeclaration(parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.indexSignature); - var indexSignature = node.indexSignature.accept(this); - - this.movePast(node.semicolonToken); - - var result = new TypeScript.IndexMemberDeclaration(indexSignature); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarator); - var variableDeclarator = node.variableDeclarator.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - var start = this.position; - - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ThrowStatement(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - var start = this.position; - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ReturnStatement(expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.ObjectCreationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - var start = this.position; - - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - this.movePast(node.openBraceToken); - var switchClauses = this.visitSyntaxList(node.switchClauses); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.CaseSwitchClause(expression, statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.DefaultSwitchClause(statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - var start = this.position; - - this.movePast(node.breakKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.BreakStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - var start = this.position; - - this.movePast(node.continueKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ContinueStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var initializer = node.initializer ? node.initializer.accept(this) : null; - - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var left = node.left ? node.left.accept(this) : null; - - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WhileStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WithStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - var start = this.position; - - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - var result = new TypeScript.CastExpression(castTerm, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var start = this.position; - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); - - var propertyName = node.propertyName.accept(this); - - var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var expression = node.expression.accept(this); - expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); - - var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var start = this.position; - - var propertyName = node.propertyName.accept(this); - var callSignature = this.visitCallSignature(node.callSignature); - var block = this.visitBlock(node.block); - - var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - var start = this.position; - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? node.block.accept(this) : null; - - var result = new TypeScript.FunctionExpression(name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - var start = this.position; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.EmptyStatement(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - var start = this.position; - - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - var start = this.position; - - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.visitIdentifier(node.identifier); - var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - var start = this.position; - this.movePast(node.finallyKeyword); - var block = node.block.accept(this); - - var result = new TypeScript.FinallyClause(block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.LabeledStatement(identifier, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - var start = this.position; - - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DoStatement(statement, whileKeyword, condition); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - var start = this.position; - - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.TypeOfExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - var start = this.position; - - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.DeleteExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - var start = this.position; - - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.VoidExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - var start = this.position; - - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DebuggerStatement(); - this.setSpan(result, start, node); - - return result; - }; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; - - function applyDelta(ast, delta) { - if (ast) { - if (ast._start !== -1) { - ast._start += delta; - } - - if (ast._end !== -1) { - ast._end += delta; - } - } - } - - function applyDeltaToComments(comments, delta) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment, delta); - } - } - } - - var SyntaxTreeToIncrementalAstVisitor = (function (_super) { - __extends(SyntaxTreeToIncrementalAstVisitor, _super); - function SyntaxTreeToIncrementalAstVisitor() { - _super.apply(this, arguments); - } - SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { - if (delta === 0) { - return; - } - - var pre = function (cur) { - applyDelta(cur, delta); - applyDeltaToComments(cur.preComments(), delta); - applyDeltaToComments(cur.postComments(), delta); - - switch (cur.kind()) { - case 146 /* Block */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 226 /* ArgumentList */: - applyDelta(cur.closeParenToken, delta); - break; - - case 130 /* ModuleDeclaration */: - applyDelta(cur.endingToken, delta); - break; - - case 131 /* ClassDeclaration */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 161 /* DoStatement */: - applyDelta(cur.whileKeyword, delta); - break; - - case 151 /* SwitchStatement */: - applyDelta(cur.closeParenToken, delta); - break; - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span._start !== -1) { - var delta = start - span._start; - this.applyDelta(span, delta); - - span._end = end; - } else { - _super.prototype.setSpanExplicit.call(this, span, start, end); - } - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - var result = element._ast; - if (!result) { - return null; - } - - var start = this.position; - this.movePast(element); - this.setSpan(result, start, element); - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { - element._ast = ast; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSeparatedSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { - var result = this.getAndMovePastAST(token); - - if (!result) { - result = _super.prototype.visitToken.call(this, token); - this.setAST(token, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitClassDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInterfaceDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitHeritageClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitModuleDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitImportDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExportAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPrefixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitOmittedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - var result = _super.prototype.visitQualifiedName.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGenericType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBlock.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPostfixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitElementAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInvocationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBinaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConditionalExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMethodSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIndexSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPropertySignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCallSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIfStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExpressionStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberVariableDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitThrowStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitReturnStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectCreationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSwitchStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCaseSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDefaultSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBreakStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitContinueStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForInStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWhileStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWithStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCastExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimplePropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitEmptyStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTryStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCatchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitLabeledStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDoStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeOfExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDeleteExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitVoidExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDebuggerStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - return SyntaxTreeToIncrementalAstVisitor; - })(SyntaxTreeToAstVisitor); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan(_start, _end) { - this._start = _start; - this._end = _end; - } - ASTSpan.prototype.start = function () { - return this._start; - }; - - ASTSpan.prototype.end = function () { - return this._end; - }; - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - var astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, false); - } - - function commentStructuralEqualsIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, true); - } - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); - } - - function commentStructuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - function commentArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST() { - this.parent = null; - this._start = -1; - this._end = -1; - this._trailingTriviaWidth = 0; - this._astID = astID++; - this._preComments = null; - this._postComments = null; - } - AST.prototype.syntaxID = function () { - return this._astID; - }; - - AST.prototype.start = function () { - return this._start; - }; - - AST.prototype.end = function () { - return this._end; - }; - - AST.prototype.trailingTriviaWidth = function () { - return this._trailingTriviaWidth; - }; - - AST.prototype.fileName = function () { - return this.parent.fileName(); - }; - - AST.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - AST.prototype.preComments = function () { - return this._preComments; - }; - - AST.prototype.postComments = function () { - return this._postComments; - }; - - AST.prototype.setPreComments = function (comments) { - if (comments && comments.length) { - this._preComments = comments; - } else if (this._preComments) { - this._preComments = null; - } - }; - - AST.prototype.setPostComments = function (comments) { - if (comments && comments.length) { - this._postComments = comments; - } else if (this._postComments) { - this._postComments = null; - } - }; - - AST.prototype.width = function () { - return this.end() - this.start(); - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); - }; - return AST; - })(); - TypeScript.AST = AST; - - var ISyntaxList2 = (function (_super) { - __extends(ISyntaxList2, _super); - function ISyntaxList2(_fileName, members) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISyntaxList2.prototype.childCount = function () { - return this.members.length; - }; - - ISyntaxList2.prototype.childAt = function (index) { - return this.members[index]; - }; - - ISyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISyntaxList2.prototype.kind = function () { - return 1 /* List */; - }; - - ISyntaxList2.prototype.firstOrDefault = function (func) { - return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.lastOrDefault = function (func) { - return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.any = function (func) { - return TypeScript.ArrayUtilities.any(this.members, func); - }; - - ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISyntaxList2; - })(AST); - TypeScript.ISyntaxList2 = ISyntaxList2; - - var ISeparatedSyntaxList2 = (function (_super) { - __extends(ISeparatedSyntaxList2, _super); - function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - this._separatorCount = _separatorCount; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { - return this.members.length; - }; - - ISeparatedSyntaxList2.prototype.separatorCount = function () { - return this._separatorCount; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { - return this.members[index]; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i) === ast) { - return i; - } - } - - return -1; - }; - - ISeparatedSyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISeparatedSyntaxList2.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISeparatedSyntaxList2; - })(AST); - TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; - - var SourceUnit = (function (_super) { - __extends(SourceUnit, _super); - function SourceUnit(moduleElements, _fileName) { - _super.call(this); - this.moduleElements = moduleElements; - this._fileName = _fileName; - moduleElements && (moduleElements.parent = this); - } - SourceUnit.prototype.fileName = function () { - return this._fileName; - }; - - SourceUnit.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return SourceUnit; - })(AST); - TypeScript.SourceUnit = SourceUnit; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(_text) { - _super.call(this); - this._text = _text; - this._valueText = null; - } - Identifier.prototype.text = function () { - return this._text; - }; - Identifier.prototype.valueText = function () { - if (!this._valueText) { - var text = this._text; - if (text === "__proto__") { - this._valueText = "#__proto__"; - } else { - this._valueText = TypeScript.Syntax.massageEscapes(text); - } - } - - return this._valueText; - }; - - Identifier.prototype.kind = function () { - return 11 /* IdentifierName */; - }; - - Identifier.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; - }; - return Identifier; - })(AST); - TypeScript.Identifier = Identifier; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - LiteralExpression.prototype.text = function () { - return this._text; - }; - - LiteralExpression.prototype.valueText = function () { - return this._valueText; - }; - - LiteralExpression.prototype.kind = function () { - return this._nodeType; - }; - - LiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return LiteralExpression; - })(AST); - TypeScript.LiteralExpression = LiteralExpression; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - ThisExpression.prototype.text = function () { - return this._text; - }; - - ThisExpression.prototype.valueText = function () { - return this._valueText; - }; - - ThisExpression.prototype.kind = function () { - return 35 /* ThisKeyword */; - }; - - ThisExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ThisExpression; - })(AST); - TypeScript.ThisExpression = ThisExpression; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - SuperExpression.prototype.text = function () { - return this._text; - }; - - SuperExpression.prototype.valueText = function () { - return this._valueText; - }; - - SuperExpression.prototype.kind = function () { - return 50 /* SuperKeyword */; - }; - - SuperExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return SuperExpression; - })(AST); - TypeScript.SuperExpression = SuperExpression; - - var NumericLiteral = (function (_super) { - __extends(NumericLiteral, _super); - function NumericLiteral(_value, _text, _valueText) { - _super.call(this); - this._value = _value; - this._text = _text; - this._valueText = _valueText; - } - NumericLiteral.prototype.text = function () { - return this._text; - }; - NumericLiteral.prototype.valueText = function () { - return this._valueText; - }; - NumericLiteral.prototype.value = function () { - return this._value; - }; - - NumericLiteral.prototype.kind = function () { - return 13 /* NumericLiteral */; - }; - - 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; - }; - return NumericLiteral; - })(AST); - TypeScript.NumericLiteral = NumericLiteral; - - var RegularExpressionLiteral = (function (_super) { - __extends(RegularExpressionLiteral, _super); - function RegularExpressionLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - RegularExpressionLiteral.prototype.text = function () { - return this._text; - }; - - RegularExpressionLiteral.prototype.valueText = function () { - return this._valueText; - }; - - RegularExpressionLiteral.prototype.kind = function () { - return 12 /* RegularExpressionLiteral */; - }; - return RegularExpressionLiteral; - })(AST); - TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; - } - StringLiteral.prototype.text = function () { - return this._text; - }; - StringLiteral.prototype.valueText = function () { - return this._valueText; - }; - - StringLiteral.prototype.kind = function () { - return 14 /* StringLiteral */; - }; - - StringLiteral.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && this._text === ast._text; - }; - return StringLiteral; - })(AST); - TypeScript.StringLiteral = StringLiteral; - - var TypeAnnotation = (function (_super) { - __extends(TypeAnnotation, _super); - function TypeAnnotation(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - TypeAnnotation.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - return TypeAnnotation; - })(AST); - TypeScript.TypeAnnotation = TypeAnnotation; - - var BuiltInType = (function (_super) { - __extends(BuiltInType, _super); - function BuiltInType(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - BuiltInType.prototype.text = function () { - return this._text; - }; - - BuiltInType.prototype.valueText = function () { - return this._valueText; - }; - - BuiltInType.prototype.kind = function () { - return this._nodeType; - }; - return BuiltInType; - })(AST); - TypeScript.BuiltInType = BuiltInType; - - var ExternalModuleReference = (function (_super) { - __extends(ExternalModuleReference, _super); - function ExternalModuleReference(stringLiteral) { - _super.call(this); - this.stringLiteral = stringLiteral; - stringLiteral && (stringLiteral.parent = this); - } - ExternalModuleReference.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - return ExternalModuleReference; - })(AST); - TypeScript.ExternalModuleReference = ExternalModuleReference; - - var ModuleNameModuleReference = (function (_super) { - __extends(ModuleNameModuleReference, _super); - function ModuleNameModuleReference(moduleName) { - _super.call(this); - this.moduleName = moduleName; - moduleName && (moduleName.parent = this); - } - ModuleNameModuleReference.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - return ModuleNameModuleReference; - })(AST); - TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(modifiers, identifier, moduleReference) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.moduleReference = moduleReference; - identifier && (identifier.parent = this); - moduleReference && (moduleReference.parent = this); - } - ImportDeclaration.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(identifier) { - _super.call(this); - this.identifier = identifier; - identifier && (identifier.parent = this); - } - ExportAssignment.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var TypeParameterList = (function (_super) { - __extends(TypeParameterList, _super); - function TypeParameterList(typeParameters) { - _super.call(this); - this.typeParameters = typeParameters; - typeParameters && (typeParameters.parent = this); - } - TypeParameterList.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - return TypeParameterList; - })(AST); - TypeScript.TypeParameterList = TypeParameterList; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - heritageClauses && (heritageClauses.parent = this); - classElements && (classElements.parent = this); - } - ClassDeclaration.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return ClassDeclaration; - })(AST); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - body && (body.parent = this); - heritageClauses && (heritageClauses.parent = this); - } - InterfaceDeclaration.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return InterfaceDeclaration; - })(AST); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var HeritageClause = (function (_super) { - __extends(HeritageClause, _super); - function HeritageClause(_nodeType, typeNames) { - _super.call(this); - this._nodeType = _nodeType; - this.typeNames = typeNames; - typeNames && (typeNames.parent = this); - } - HeritageClause.prototype.kind = function () { - return this._nodeType; - }; - - HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); - }; - return HeritageClause; - })(AST); - TypeScript.HeritageClause = HeritageClause; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { - _super.call(this); - this.modifiers = modifiers; - this.name = name; - this.stringLiteral = stringLiteral; - this.moduleElements = moduleElements; - this.endingToken = endingToken; - name && (name.parent = this); - stringLiteral && (stringLiteral.parent = this); - moduleElements && (moduleElements.parent = this); - } - ModuleDeclaration.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return ModuleDeclaration; - })(AST); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(modifiers, identifier, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionDeclaration.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(modifiers, declaration) { - _super.call(this); - this.modifiers = modifiers; - this.declaration = declaration; - declaration && (declaration.parent = this); - } - VariableStatement.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(AST); - TypeScript.VariableStatement = VariableStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this); - this.declarators = declarators; - declarators && (declarators.parent = this); - } - VariableDeclaration.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - VariableDeclarator.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - return VariableDeclarator; - })(AST); - TypeScript.VariableDeclarator = VariableDeclarator; - - var EqualsValueClause = (function (_super) { - __extends(EqualsValueClause, _super); - function EqualsValueClause(value) { - _super.call(this); - this.value = value; - value && (value.parent = this); - } - EqualsValueClause.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - return EqualsValueClause; - })(AST); - TypeScript.EqualsValueClause = EqualsValueClause; - - var PrefixUnaryExpression = (function (_super) { - __extends(PrefixUnaryExpression, _super); - function PrefixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PrefixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - PrefixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); - }; - return PrefixUnaryExpression; - })(AST); - TypeScript.PrefixUnaryExpression = PrefixUnaryExpression; - - var ArrayLiteralExpression = (function (_super) { - __extends(ArrayLiteralExpression, _super); - function ArrayLiteralExpression(expressions) { - _super.call(this); - this.expressions = expressions; - expressions && (expressions.parent = this); - } - ArrayLiteralExpression.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expressions, ast.expressions, includingPosition); - }; - return ArrayLiteralExpression; - })(AST); - TypeScript.ArrayLiteralExpression = ArrayLiteralExpression; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.apply(this, arguments); - } - OmittedExpression.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return OmittedExpression; - })(AST); - TypeScript.OmittedExpression = OmittedExpression; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(openParenTrailingComments, expression) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.expression = expression; - expression && (expression.parent = this); - } - ParenthesizedExpression.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ParenthesizedExpression; - })(AST); - TypeScript.ParenthesizedExpression = ParenthesizedExpression; - - var SimpleArrowFunctionExpression = (function (_super) { - __extends(SimpleArrowFunctionExpression, _super); - function SimpleArrowFunctionExpression(identifier, block, expression) { - _super.call(this); - this.identifier = identifier; - this.block = block; - this.expression = expression; - identifier && (identifier.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - SimpleArrowFunctionExpression.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - return SimpleArrowFunctionExpression; - })(AST); - TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; - - var ParenthesizedArrowFunctionExpression = (function (_super) { - __extends(ParenthesizedArrowFunctionExpression, _super); - function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - this.expression = expression; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - ParenthesizedArrowFunctionExpression.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - return ParenthesizedArrowFunctionExpression; - })(AST); - TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; - - var QualifiedName = (function (_super) { - __extends(QualifiedName, _super); - function QualifiedName(left, right) { - _super.call(this); - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - QualifiedName.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedName.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); - }; - return QualifiedName; - })(AST); - TypeScript.QualifiedName = QualifiedName; - - var ParameterList = (function (_super) { - __extends(ParameterList, _super); - function ParameterList(openParenTrailingComments, parameters) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.parameters = parameters; - parameters && (parameters.parent = this); - } - ParameterList.prototype.kind = function () { - return 227 /* ParameterList */; - }; - return ParameterList; - })(AST); - TypeScript.ParameterList = ParameterList; - - var ConstructorType = (function (_super) { - __extends(ConstructorType, _super); - function ConstructorType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - ConstructorType.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - return ConstructorType; - })(AST); - TypeScript.ConstructorType = ConstructorType; - - var FunctionType = (function (_super) { - __extends(FunctionType, _super); - function FunctionType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - FunctionType.prototype.kind = function () { - return 123 /* FunctionType */; - }; - return FunctionType; - })(AST); - TypeScript.FunctionType = FunctionType; - - var ObjectType = (function (_super) { - __extends(ObjectType, _super); - function ObjectType(typeMembers) { - _super.call(this); - this.typeMembers = typeMembers; - typeMembers && (typeMembers.parent = this); - } - ObjectType.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); - }; - return ObjectType; - })(AST); - TypeScript.ObjectType = ObjectType; - - var ArrayType = (function (_super) { - __extends(ArrayType, _super); - function ArrayType(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - ArrayType.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); - }; - return ArrayType; - })(AST); - TypeScript.ArrayType = ArrayType; - - var TypeArgumentList = (function (_super) { - __extends(TypeArgumentList, _super); - function TypeArgumentList(typeArguments) { - _super.call(this); - this.typeArguments = typeArguments; - typeArguments && (typeArguments.parent = this); - } - TypeArgumentList.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - return TypeArgumentList; - })(AST); - TypeScript.TypeArgumentList = TypeArgumentList; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArgumentList) { - _super.call(this); - this.name = name; - this.typeArgumentList = typeArgumentList; - name && (name.parent = this); - typeArgumentList && (typeArgumentList.parent = this); - } - GenericType.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeQuery = (function (_super) { - __extends(TypeQuery, _super); - function TypeQuery(name) { - _super.call(this); - this.name = name; - name && (name.parent = this); - } - TypeQuery.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); - }; - return TypeQuery; - })(AST); - TypeScript.TypeQuery = TypeQuery; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements, closeBraceLeadingComments, closeBraceToken) { - _super.call(this); - this.statements = statements; - this.closeBraceLeadingComments = closeBraceLeadingComments; - this.closeBraceToken = closeBraceToken; - statements && (statements.parent = this); - } - Block.prototype.kind = function () { - return 146 /* Block */; - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(AST); - TypeScript.Block = Block; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - _super.call(this); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - Parameter.prototype.kind = function () { - return 242 /* Parameter */; - }; - return Parameter; - })(AST); - TypeScript.Parameter = Parameter; - - var MemberAccessExpression = (function (_super) { - __extends(MemberAccessExpression, _super); - function MemberAccessExpression(expression, name) { - _super.call(this); - this.expression = expression; - this.name = name; - expression && (expression.parent = this); - name && (name.parent = this); - } - MemberAccessExpression.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - 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); - }; - return MemberAccessExpression; - })(AST); - TypeScript.MemberAccessExpression = MemberAccessExpression; - - var PostfixUnaryExpression = (function (_super) { - __extends(PostfixUnaryExpression, _super); - function PostfixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PostfixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - PostfixUnaryExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.operand, ast.operand, includingPosition); - }; - return PostfixUnaryExpression; - })(AST); - TypeScript.PostfixUnaryExpression = PostfixUnaryExpression; - - var ElementAccessExpression = (function (_super) { - __extends(ElementAccessExpression, _super); - function ElementAccessExpression(expression, argumentExpression) { - _super.call(this); - this.expression = expression; - this.argumentExpression = argumentExpression; - expression && (expression.parent = this); - argumentExpression && (argumentExpression.parent = this); - } - ElementAccessExpression.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - 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); - }; - return ElementAccessExpression; - })(AST); - TypeScript.ElementAccessExpression = ElementAccessExpression; - - var InvocationExpression = (function (_super) { - __extends(InvocationExpression, _super); - function InvocationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - InvocationExpression.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - 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); - }; - return InvocationExpression; - })(AST); - TypeScript.InvocationExpression = InvocationExpression; - - var ArgumentList = (function (_super) { - __extends(ArgumentList, _super); - function ArgumentList(typeArgumentList, arguments, closeParenToken) { - _super.call(this); - this.typeArgumentList = typeArgumentList; - this.arguments = arguments; - this.closeParenToken = closeParenToken; - typeArgumentList && (typeArgumentList.parent = this); - arguments && (arguments.parent = this); - } - ArgumentList.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - return ArgumentList; - })(AST); - TypeScript.ArgumentList = ArgumentList; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(_nodeType, left, right) { - _super.call(this); - this._nodeType = _nodeType; - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - BinaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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); - }; - return BinaryExpression; - })(AST); - TypeScript.BinaryExpression = BinaryExpression; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(condition, whenTrue, whenFalse) { - _super.call(this); - this.condition = condition; - this.whenTrue = whenTrue; - this.whenFalse = whenFalse; - condition && (condition.parent = this); - whenTrue && (whenTrue.parent = this); - whenFalse && (whenFalse.parent = this); - } - ConditionalExpression.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - 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); - }; - return ConditionalExpression; - })(AST); - TypeScript.ConditionalExpression = ConditionalExpression; - - var ConstructSignature = (function (_super) { - __extends(ConstructSignature, _super); - function ConstructSignature(callSignature) { - _super.call(this); - this.callSignature = callSignature; - callSignature && (callSignature.parent = this); - } - ConstructSignature.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - return ConstructSignature; - })(AST); - TypeScript.ConstructSignature = ConstructSignature; - - var MethodSignature = (function (_super) { - __extends(MethodSignature, _super); - function MethodSignature(propertyName, questionToken, callSignature) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - } - MethodSignature.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - return MethodSignature; - })(AST); - TypeScript.MethodSignature = MethodSignature; - - var IndexSignature = (function (_super) { - __extends(IndexSignature, _super); - function IndexSignature(parameter, typeAnnotation) { - _super.call(this); - this.parameter = parameter; - this.typeAnnotation = typeAnnotation; - parameter && (parameter.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - IndexSignature.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - return IndexSignature; - })(AST); - TypeScript.IndexSignature = IndexSignature; - - var PropertySignature = (function (_super) { - __extends(PropertySignature, _super); - function PropertySignature(propertyName, questionToken, typeAnnotation) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - PropertySignature.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - return PropertySignature; - })(AST); - TypeScript.PropertySignature = PropertySignature; - - var CallSignature = (function (_super) { - __extends(CallSignature, _super); - function CallSignature(typeParameterList, parameterList, typeAnnotation) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - CallSignature.prototype.kind = function () { - return 142 /* CallSignature */; - }; - return CallSignature; - })(AST); - TypeScript.CallSignature = CallSignature; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(identifier, constraint) { - _super.call(this); - this.identifier = identifier; - this.constraint = constraint; - identifier && (identifier.parent = this); - constraint && (constraint.parent = this); - } - TypeParameter.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var Constraint = (function (_super) { - __extends(Constraint, _super); - function Constraint(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - Constraint.prototype.kind = function () { - return 239 /* Constraint */; - }; - return Constraint; - })(AST); - TypeScript.Constraint = Constraint; - - var ElseClause = (function (_super) { - __extends(ElseClause, _super); - function ElseClause(statement) { - _super.call(this); - this.statement = statement; - statement && (statement.parent = this); - } - ElseClause.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ElseClause; - })(AST); - TypeScript.ElseClause = ElseClause; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(condition, statement, elseClause) { - _super.call(this); - this.condition = condition; - this.statement = statement; - this.elseClause = elseClause; - condition && (condition.parent = this); - statement && (statement.parent = this); - elseClause && (elseClause.parent = this); - } - IfStatement.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); - }; - return IfStatement; - })(AST); - TypeScript.IfStatement = IfStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ExpressionStatement.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(AST); - TypeScript.ExpressionStatement = ExpressionStatement; - - var ConstructorDeclaration = (function (_super) { - __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(parameterList, block) { - _super.call(this); - this.parameterList = parameterList; - this.block = block; - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - ConstructorDeclaration.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - return ConstructorDeclaration; - })(AST); - TypeScript.ConstructorDeclaration = ConstructorDeclaration; - - var MemberFunctionDeclaration = (function (_super) { - __extends(MemberFunctionDeclaration, _super); - function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - MemberFunctionDeclaration.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - return MemberFunctionDeclaration; - })(AST); - TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; - - var GetAccessor = (function (_super) { - __extends(GetAccessor, _super); - function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - GetAccessor.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - return GetAccessor; - })(AST); - TypeScript.GetAccessor = GetAccessor; - - var SetAccessor = (function (_super) { - __extends(SetAccessor, _super); - function SetAccessor(modifiers, propertyName, parameterList, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - SetAccessor.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - return SetAccessor; - })(AST); - TypeScript.SetAccessor = SetAccessor; - - var MemberVariableDeclaration = (function (_super) { - __extends(MemberVariableDeclaration, _super); - function MemberVariableDeclaration(modifiers, variableDeclarator) { - _super.call(this); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - variableDeclarator && (variableDeclarator.parent = this); - } - MemberVariableDeclaration.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - return MemberVariableDeclaration; - })(AST); - TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; - - var IndexMemberDeclaration = (function (_super) { - __extends(IndexMemberDeclaration, _super); - function IndexMemberDeclaration(indexSignature) { - _super.call(this); - this.indexSignature = indexSignature; - indexSignature && (indexSignature.parent = this); - } - IndexMemberDeclaration.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - return IndexMemberDeclaration; - })(AST); - TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ThrowStatement.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(AST); - TypeScript.ThrowStatement = ThrowStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ReturnStatement.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ReturnStatement; - })(AST); - TypeScript.ReturnStatement = ReturnStatement; - - var ObjectCreationExpression = (function (_super) { - __extends(ObjectCreationExpression, _super); - function ObjectCreationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - ObjectCreationExpression.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - 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); - }; - return ObjectCreationExpression; - })(AST); - TypeScript.ObjectCreationExpression = ObjectCreationExpression; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(expression, closeParenToken, switchClauses) { - _super.call(this); - this.expression = expression; - this.closeParenToken = closeParenToken; - this.switchClauses = switchClauses; - expression && (expression.parent = this); - switchClauses && (switchClauses.parent = this); - } - SwitchStatement.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return SwitchStatement; - })(AST); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseSwitchClause = (function (_super) { - __extends(CaseSwitchClause, _super); - function CaseSwitchClause(expression, statements) { - _super.call(this); - this.expression = expression; - this.statements = statements; - expression && (expression.parent = this); - statements && (statements.parent = this); - } - CaseSwitchClause.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return CaseSwitchClause; - })(AST); - TypeScript.CaseSwitchClause = CaseSwitchClause; - - var DefaultSwitchClause = (function (_super) { - __extends(DefaultSwitchClause, _super); - function DefaultSwitchClause(statements) { - _super.call(this); - this.statements = statements; - statements && (statements.parent = this); - } - DefaultSwitchClause.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return DefaultSwitchClause; - })(AST); - TypeScript.DefaultSwitchClause = DefaultSwitchClause; - - var BreakStatement = (function (_super) { - __extends(BreakStatement, _super); - function BreakStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - BreakStatement.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return BreakStatement; - })(AST); - TypeScript.BreakStatement = BreakStatement; - - var ContinueStatement = (function (_super) { - __extends(ContinueStatement, _super); - function ContinueStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - ContinueStatement.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ContinueStatement; - })(AST); - TypeScript.ContinueStatement = ContinueStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.condition = condition; - this.incrementor = incrementor; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - initializer && (initializer.parent = this); - condition && (condition.parent = this); - incrementor && (incrementor.parent = this); - statement && (statement.parent = this); - } - ForStatement.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForStatement; - })(AST); - TypeScript.ForStatement = ForStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(variableDeclaration, left, expression, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.left = left; - this.expression = expression; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - left && (left.parent = this); - expression && (expression.parent = this); - statement && (statement.parent = this); - } - ForInStatement.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForInStatement; - })(AST); - TypeScript.ForInStatement = ForInStatement; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WhileStatement.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WhileStatement; - })(AST); - TypeScript.WhileStatement = WhileStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WithStatement.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WithStatement; - })(AST); - TypeScript.WithStatement = WithStatement; - - var EnumDeclaration = (function (_super) { - __extends(EnumDeclaration, _super); - function EnumDeclaration(modifiers, identifier, enumElements) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.enumElements = enumElements; - identifier && (identifier.parent = this); - enumElements && (enumElements.parent = this); - } - EnumDeclaration.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - return EnumDeclaration; - })(AST); - TypeScript.EnumDeclaration = EnumDeclaration; - - var EnumElement = (function (_super) { - __extends(EnumElement, _super); - function EnumElement(propertyName, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - EnumElement.prototype.kind = function () { - return 243 /* EnumElement */; - }; - return EnumElement; - })(AST); - TypeScript.EnumElement = EnumElement; - - var CastExpression = (function (_super) { - __extends(CastExpression, _super); - function CastExpression(type, expression) { - _super.call(this); - this.type = type; - this.expression = expression; - type && (type.parent = this); - expression && (expression.parent = this); - } - CastExpression.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - 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); - }; - return CastExpression; - })(AST); - TypeScript.CastExpression = CastExpression; - - var ObjectLiteralExpression = (function (_super) { - __extends(ObjectLiteralExpression, _super); - function ObjectLiteralExpression(propertyAssignments) { - _super.call(this); - this.propertyAssignments = propertyAssignments; - propertyAssignments && (propertyAssignments.parent = this); - } - ObjectLiteralExpression.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.propertyAssignments, ast.propertyAssignments, includingPosition); - }; - return ObjectLiteralExpression; - })(AST); - TypeScript.ObjectLiteralExpression = ObjectLiteralExpression; - - var SimplePropertyAssignment = (function (_super) { - __extends(SimplePropertyAssignment, _super); - function SimplePropertyAssignment(propertyName, expression) { - _super.call(this); - this.propertyName = propertyName; - this.expression = expression; - propertyName && (propertyName.parent = this); - expression && (expression.parent = this); - } - SimplePropertyAssignment.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - return SimplePropertyAssignment; - })(AST); - TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; - - var FunctionPropertyAssignment = (function (_super) { - __extends(FunctionPropertyAssignment, _super); - function FunctionPropertyAssignment(propertyName, callSignature, block) { - _super.call(this); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionPropertyAssignment.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - return FunctionPropertyAssignment; - })(AST); - TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; - - var FunctionExpression = (function (_super) { - __extends(FunctionExpression, _super); - function FunctionExpression(identifier, callSignature, block) { - _super.call(this); - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionExpression.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - return FunctionExpression; - })(AST); - TypeScript.FunctionExpression = FunctionExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.apply(this, arguments); - } - EmptyStatement.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(AST); - TypeScript.EmptyStatement = EmptyStatement; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(block, catchClause, finallyClause) { - _super.call(this); - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - block && (block.parent = this); - catchClause && (catchClause.parent = this); - finallyClause && (finallyClause.parent = this); - } - TryStatement.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); - }; - return TryStatement; - })(AST); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(identifier, typeAnnotation, block) { - _super.call(this); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.block = block; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - CatchClause.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var FinallyClause = (function (_super) { - __extends(FinallyClause, _super); - function FinallyClause(block) { - _super.call(this); - this.block = block; - block && (block.parent = this); - } - FinallyClause.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return FinallyClause; - })(AST); - TypeScript.FinallyClause = FinallyClause; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this); - this.identifier = identifier; - this.statement = statement; - identifier && (identifier.parent = this); - statement && (statement.parent = this); - } - LabeledStatement.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(AST); - TypeScript.LabeledStatement = LabeledStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(statement, whileKeyword, condition) { - _super.call(this); - this.statement = statement; - this.whileKeyword = whileKeyword; - this.condition = condition; - statement && (statement.parent = this); - condition && (condition.parent = this); - } - DoStatement.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); - }; - return DoStatement; - })(AST); - TypeScript.DoStatement = DoStatement; - - var TypeOfExpression = (function (_super) { - __extends(TypeOfExpression, _super); - function TypeOfExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - TypeOfExpression.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return TypeOfExpression; - })(AST); - TypeScript.TypeOfExpression = TypeOfExpression; - - var DeleteExpression = (function (_super) { - __extends(DeleteExpression, _super); - function DeleteExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - DeleteExpression.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return DeleteExpression; - })(AST); - TypeScript.DeleteExpression = DeleteExpression; - - var VoidExpression = (function (_super) { - __extends(VoidExpression, _super); - function VoidExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - VoidExpression.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpression.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return VoidExpression; - })(AST); - TypeScript.VoidExpression = VoidExpression; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.apply(this, arguments); - } - DebuggerStatement.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - return DebuggerStatement; - })(AST); - TypeScript.DebuggerStatement = DebuggerStatement; - - var Comment = (function () { - function Comment(_trivia, endsLine, _start, _end) { - this._trivia = _trivia; - this.endsLine = endsLine; - this._start = _start; - this._end = _end; - } - Comment.prototype.start = function () { - return this._start; - }; - - Comment.prototype.end = function () { - return this._end; - }; - - Comment.prototype.fullText = function () { - return this._trivia.fullText(); - }; - - Comment.prototype.kind = function () { - return this._trivia.kind(); - }; - - Comment.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; - }; - 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/_infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts b/_infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts deleted file mode 100644 index 94c477fd4a..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-59a846/lib.d.ts +++ /dev/null @@ -1,14931 +0,0 @@ -/* ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -/// - -///////////////////////////// -/// ECMAScript APIs -///////////////////////////// - -declare var NaN: number; -declare var Infinity: number; - -/** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ -declare function eval(x: string): any; - -/** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ -declare function parseInt(s: string, radix?: number): number; - -/** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ -declare function parseFloat(string: string): number; - -/** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ -declare function isNaN(number: number): boolean; - -/** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ -declare function isFinite(number: number): boolean; - -/** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ -declare function decodeURI(encodedURI: string): string; - -/** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ -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; - -/** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ -declare function encodeURIComponent(uriComponent: string): string; - -interface PropertyDescriptor { - configurable?: boolean; - enumerable?: boolean; - value?: any; - writable?: boolean; - get? (): any; - set? (v: any): void; -} - -interface PropertyDescriptorMap { - [s: string]: PropertyDescriptor; -} - -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; - - /** Returns the primitive value of the specified object. */ - valueOf(): Object; - - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: string): boolean; - - /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ - isPrototypeOf(v: Object): boolean; - - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - propertyIsEnumerable(v: string): boolean; -} - -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { - new (value?: any): Object; - (): any; - (value: any): any; - - /** A reference to the prototype for a class of objects. */ - prototype: Object; - - /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ - getPrototypeOf(o: any): any; - - /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; - - /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ - getOwnPropertyNames(o: any): string[]; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ - create(o: any, properties?: PropertyDescriptorMap): any; - - /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ - defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; - - /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ - defineProperties(o: any, properties: PropertyDescriptorMap): any; - - /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - seal(o: any): any; - - /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(o: any): any; - - /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ - preventExtensions(o: any): any; - - /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ - isSealed(o: any): boolean; - - /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ - isFrozen(o: any): boolean; - - /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ - isExtensible(o: any): boolean; - - /** - * Returns the names of the enumerable properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: any): string[]; -} - -/** - * Creates a new function. - */ -interface Function { - /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ - apply(thisArg: any, argArray?: any): any; - - /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ - call(thisArg: any, ...argArray: any[]): any; - - /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ - bind(thisArg: any, ...argArray: any[]): any; - - prototype: any; - length: number; - - // Non-standard extensions - arguments: any; - caller: Function; -} - -declare var Function: { - /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ - new (...args: string[]): Function; - (...args: string[]): Function; - prototype: Function; -} - -interface IArguments { - [index: number]: any; - length: number; - callee: Function; -} - -interface String { - /** Returns a string representation of a string. */ - toString(): string; - - /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ - charAt(pos: number): string; - - /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ - charCodeAt(index: number): number; - - /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ - concat(...strings: string[]): string; - - /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ - indexOf(searchString: string, position?: number): number; - - /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ - lastIndexOf(searchString: string, position?: number): number; - - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ - localeCompare(that: string): number; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - match(regexp: string): string[]; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. - */ - match(regexp: RegExp): string[]; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: string, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: RegExp, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: string): number; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: RegExp): number; - - /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ - slice(start?: number, end?: number): string; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: string, limit?: number): string[]; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: RegExp, limit?: number): string[]; - - /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index number indicating the beginning of the substring. - * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ - substring(start: number, end?: number): string; - - /** Converts all the alphabetic characters in a string to lowercase. */ - toLowerCase(): string; - - /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; - - /** Converts all the alphabetic characters in a string to uppercase. */ - toUpperCase(): string; - - /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; - - /** Removes the leading and trailing white space and line terminator characters from a string. */ - trim(): string; - - /** Returns the length of a String object. */ - length: number; - - // IE extensions - /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ - substr(from: number, length?: number): string; - - [index: number]: string; -} - -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { - new (value?: any): String; - (value?: any): string; - prototype: String; - fromCharCode(...codes: number[]): string; -} - -interface Boolean { -} -declare var Boolean: { - new (value?: any): Boolean; - (value?: any): boolean; - prototype: Boolean; -} - -interface Number { - /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. - */ - toString(radix?: number): string; - - /** - * Returns a string representing a number in fixed-point notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toFixed(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented in exponential notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toExponential(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. - * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. - */ - toPrecision(precision?: number): string; -} - -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { - new (value?: any): Number; - (value?: any): number; - prototype: Number; - - /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; - - /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; - - /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ - NaN: number; - - /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ - NEGATIVE_INFINITY: number; - - /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ - POSITIVE_INFINITY: number; -} - -interface Math { - /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; - /** The natural logarithm of 10. */ - LN10: number; - /** The natural logarithm of 2. */ - LN2: number; - /** The base-2 logarithm of e. */ - LOG2E: number; - /** The base-10 logarithm of e. */ - LOG10E: number; - /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; - /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; - /** The square root of 2. */ - SQRT2: number; - /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ - abs(x: number): number; - /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ - acos(x: number): number; - /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ - asin(x: number): number; - /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ - atan(x: number): number; - /** - * Returns the angle (in radians) from the X axis to a point (y,x). - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ - atan2(y: number, x: number): number; - /** - * Returns the smallest number greater than or equal to its numeric argument. - * @param x A numeric expression. - */ - ceil(x: number): number; - /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - cos(x: number): number; - /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ - exp(x: number): number; - /** - * Returns the greatest number less than or equal to its numeric argument. - * @param x A numeric expression. - */ - floor(x: number): number; - /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ - log(x: number): number; - /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - max(...values: number[]): number; - /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - min(...values: number[]): number; - /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ - pow(x: number, y: number): number; - /** Returns a pseudorandom number between 0 and 1. */ - random(): number; - /** - * Returns a supplied numeric expression rounded to the nearest number. - * @param x The value to be rounded to the nearest number. - */ - round(x: number): number; - /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - sin(x: number): number; - /** - * Returns the square root of a number. - * @param x A numeric expression. - */ - sqrt(x: number): number; - /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - tan(x: number): number; -} -/** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; - -/** Enables basic storage and retrieval of dates and times. */ -interface Date { - /** Returns a string representation of a date. The format of the string depends on the locale. */ - toString(): string; - /** Returns a date as a string value. */ - toDateString(): string; - /** Returns a time as a string value. */ - toTimeString(): string; - /** Returns a value as a string value appropriate to the host environment's current locale. */ - toLocaleString(): string; - /** Returns a date as a string value appropriate to the host environment's current locale. */ - toLocaleDateString(): string; - /** Returns a time as a string value appropriate to the host environment's current locale. */ - toLocaleTimeString(): string; - /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ - valueOf(): number; - /** Gets the time value in milliseconds. */ - getTime(): number; - /** Gets the year, using local time. */ - getFullYear(): number; - /** Gets the year using Universal Coordinated Time (UTC). */ - getUTCFullYear(): number; - /** Gets the month, using local time. */ - getMonth(): number; - /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ - getUTCMonth(): number; - /** Gets the day-of-the-month, using local time. */ - getDate(): number; - /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ - getUTCDate(): number; - /** Gets the day of the week, using local time. */ - getDay(): number; - /** Gets the day of the week using Universal Coordinated Time (UTC). */ - getUTCDay(): number; - /** Gets the hours in a date, using local time. */ - getHours(): number; - /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ - getUTCHours(): number; - /** Gets the minutes of a Date object, using local time. */ - getMinutes(): number; - /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ - getUTCMinutes(): number; - /** Gets the seconds of a Date object, using local time. */ - getSeconds(): number; - /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCSeconds(): number; - /** Gets the milliseconds of a Date, using local time. */ - getMilliseconds(): number; - /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCMilliseconds(): number; - /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ - getTimezoneOffset(): number; - /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ - 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): 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): 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): 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): 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): 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): number; - /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setHours(hours: number, min?: number, sec?: number, ms?: number): number; - /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - 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): 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): 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): 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): 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): 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): 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. */ - toISOString(): string; - /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ - toJSON(key?: any): string; -} - -declare var Date: { - new (): Date; - new (value: number): Date; - new (value: string): Date; - new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; - (): string; - prototype: Date; - /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ - parse(s: string): number; - /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an number between 0 and 11 (January to December). - * @param date The date as an number between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. - * @param ms An number from 0 to 999 that specifies the milliseconds. - */ - UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; - now(): number; -} - -interface RegExpExecArray { - [index: number]: string; - length: number; - - index: number; - input: string; - - toString(): string; - toLocaleString(): string; - concat(...items: string[][]): string[]; - join(separator?: string): string; - pop(): string; - push(...items: string[]): number; - reverse(): string[]; - shift(): 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[]; - unshift(...items: string[]): number; - - indexOf(searchElement: string, fromIndex?: number): number; - lastIndexOf(searchElement: string, fromIndex?: number): number; - every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; - map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; - filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; - reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; - reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; -} - - -interface RegExp { - /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ - 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. - */ - test(string: string): boolean; - - /** 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; - - /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; - - /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; - - lastIndex: number; - - // Non-standard extensions - compile(): RegExp; -} -declare var RegExp: { - new (pattern: string, flags?: string): RegExp; - (pattern: string, flags?: string): RegExp; - - // Non-standard extensions - $1: string; - $2: string; - $3: string; - $4: string; - $5: string; - $6: string; - $7: string; - $8: string; - $9: string; - lastMatch: string; -} - -interface Error { - name: string; - message: string; -} -declare var Error: { - new (message?: string): Error; - (message?: string): Error; - prototype: Error; -} - -interface EvalError extends Error { -} -declare var EvalError: { - new (message?: string): EvalError; - (message?: string): EvalError; - prototype: EvalError; -} - -interface RangeError extends Error { -} -declare var RangeError: { - new (message?: string): RangeError; - (message?: string): RangeError; - prototype: RangeError; -} - -interface ReferenceError extends Error { -} -declare var ReferenceError: { - new (message?: string): ReferenceError; - (message?: string): ReferenceError; - prototype: ReferenceError; -} - -interface SyntaxError extends Error { -} -declare var SyntaxError: { - new (message?: string): SyntaxError; - (message?: string): SyntaxError; - prototype: SyntaxError; -} - -interface TypeError extends Error { -} -declare var TypeError: { - new (message?: string): TypeError; - (message?: string): TypeError; - prototype: TypeError; -} - -interface URIError extends Error { -} -declare var URIError: { - new (message?: string): URIError; - (message?: string): URIError; - prototype: URIError; -} - -interface JSON { - /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ - parse(text: string, reviver?: (key: any, value: any) => any): any; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - */ - stringify(value: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - */ - stringify(value: any, replacer: (key: string, value: any) => any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - */ - stringify(value: any, replacer: any[]): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: any[], space: any): string; -} -/** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ -declare var JSON: JSON; - - -///////////////////////////// -/// ECMAScript Array API (specially handled by compiler) -///////////////////////////// - -interface Array { - /** - * Returns a string representation of an array. - */ - toString(): string; - toLocaleString(): string; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** - * Removes the last element from an array and returns it. - */ - pop(): T; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(...items: T[]): number; - /** - * Reverses the elements in an Array. - */ - reverse(): T[]; - /** - * Removes the first element from an array and returns it. - */ - shift(): T; - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): T[]; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - */ - splice(start: number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ - splice(start: number, deleteCount: number, ...items: T[]): T[]; - - /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ - unshift(...items: T[]): number; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ - indexOf(searchElement: T, fromIndex?: number): number; - - /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ - lastIndexOf(searchElement: T, fromIndex?: number): number; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; - - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ - length: number; - - [n: number]: T; -} -declare var Array: { - new (arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; -} - - -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; -} - -declare var ArrayBuffer: { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; -} - -interface ArrayBufferView { - buffer: ArrayBuffer; - byteOffset: number; - byteLength: number; -} - -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int8Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; -} -declare var Int8Array: { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; -} -declare var Uint8Array: { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 16-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; -} -declare var Int16Array: { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; -} -declare var Uint16Array: { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; -} -declare var Int32Array: { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; -} -declare var Uint32Array: { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Float32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; -} -declare var Float32Array: { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Float64Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float64Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; -} -declare var Float64Array: { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - BYTES_PER_ELEMENT: number; -} - -/** - * You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer. - */ -interface DataView extends ArrayBufferView { - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian?: boolean): number; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; -} -declare var DataView: { - prototype: DataView; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; -} - -///////////////////////////// -/// IE11 ECMAScript Extensions -///////////////////////////// - -interface Map { - clear(): void; - delete(key: K): boolean; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): Map; - size: number; -} -declare var Map: { - new (): Map; -} - -interface WeakMap { - clear(): void; - delete(key: K): boolean; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): WeakMap; -} -declare var WeakMap: { - new (): WeakMap; -} - -interface Set { - add(value: T): Set; - clear(): void; - delete(value: T): boolean; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; - has(value: T): boolean; - size: number; -} -declare var Set: { - new (): Set; -} - -declare module Intl { - - interface CollatorOptions { - usage?: string; - localeMatcher?: string; - numeric?: boolean; - caseFirst?: string; - sensitivity?: string; - ignorePunctuation?: boolean; - } - - interface ResolvedCollatorOptions { - locale: string; - usage: string; - sensitivity: string; - ignorePunctuation: boolean; - collation: string; - caseFirst: string; - numeric: boolean; - } - - interface Collator { - compare(x: string, y: string): number; - resolvedOptions(): ResolvedCollatorOptions; - } - var Collator: { - new (locales?: string[], options?: CollatorOptions): Collator; - new (locale?: string, options?: CollatorOptions): Collator; - (locales?: string[], options?: CollatorOptions): Collator; - (locale?: string, options?: CollatorOptions): Collator; - supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; - supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; - } - - interface NumberFormatOptions { - localeMatcher?: string; - style?: string; - currency?: string; - currencyDisplay?: string; - useGrouping?: boolean; - } - - interface ResolvedNumberFormatOptions { - locale: string; - numberingSystem: string; - style: string; - currency?: string; - currencyDisplay?: string; - minimumintegerDigits: number; - minimumFractionDigits: number; - maximumFractionDigits: number; - minimumSignificantDigits?: number; - maximumSignificantDigits?: number; - useGrouping: boolean; - } - - interface NumberFormat { - format(value: number): string; - resolvedOptions(): ResolvedNumberFormatOptions; - } - var NumberFormat: { - new (locales?: string[], options?: NumberFormatOptions): Collator; - new (locale?: string, options?: NumberFormatOptions): Collator; - (locales?: string[], options?: NumberFormatOptions): Collator; - (locale?: string, options?: NumberFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; - } - - interface DateTimeFormatOptions { - localeMatcher?: string; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - formatMatcher?: string; - hour12: boolean; - } - - interface ResolvedDateTimeFormatOptions { - locale: string; - calendar: string; - numberingSystem: string; - timeZone: string; - hour12?: boolean; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - } - - interface DateTimeFormat { - format(date: number): string; - resolvedOptions(): ResolvedDateTimeFormatOptions; - } - var DateTimeFormat: { - new (locales?: string[], options?: DateTimeFormatOptions): Collator; - new (locale?: string, options?: DateTimeFormatOptions): Collator; - (locales?: string[], options?: DateTimeFormatOptions): Collator; - (locale?: string, options?: DateTimeFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; - } -} - -interface String { - localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; - localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; -} - -interface Number { - 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; -} - - -///////////////////////////// -/// IE9 DOM APIs -///////////////////////////// - -interface PositionOptions { - enableHighAccuracy?: boolean; - timeout?: number; - maximumAge?: number; -} - -interface NavigatorID { - appVersion: string; - appName: string; - userAgent: string; - platform: string; -} - -interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the amount of space between cells in a table. - */ - cellSpacing: string; - /** - * Retrieves the tFoot object of the table. - */ - tFoot: HTMLTableSectionElement; - /** - * Sets or retrieves the way the border frame around the table is displayed. - */ - frame: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Sets or retrieves which dividing lines (inner borders) are displayed. - */ - rules: string; - /** - * Sets or retrieves the number of columns in the table. - */ - cols: number; - /** - * Sets or retrieves a description and/or structure of the object. - */ - summary: string; - /** - * Retrieves the caption object of a table. - */ - caption: HTMLTableCaptionElement; - /** - * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. - */ - tBodies: HTMLCollection; - /** - * Retrieves the tHead object of the table. - */ - tHead: HTMLTableSectionElement; - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Retrieves a collection of all cells in the table row or in the entire table. - */ - cells: HTMLCollection; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the amount of space between the border of the cell and the content of the cell. - */ - cellPadding: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Creates an empty tBody element in the table. - */ - createTBody(): HTMLElement; - /** - * Deletes the caption element and its contents from the table. - */ - deleteCaption(): void; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; - /** - * Deletes the tFoot element and its contents from the table. - */ - deleteTFoot(): void; - /** - * Returns the tHead element object if successful, or null otherwise. - */ - createTHead(): HTMLElement; - /** - * Deletes the tHead element and its contents from the table. - */ - deleteTHead(): void; - /** - * Creates an empty caption element in the table. - */ - createCaption(): HTMLElement; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): Object; - /** - * Creates an empty tFoot element in the table. - */ - createTFoot(): HTMLElement; -} -declare var HTMLTableElement: { - prototype: HTMLTableElement; - new (): HTMLTableElement; -} - -interface TreeWalker { - whatToShow: number; - filter: NodeFilter; - root: Node; - currentNode: Node; - expandEntityReferences: boolean; - previousSibling(): Node; - lastChild(): Node; - nextSibling(): Node; - nextNode(): Node; - parentNode(): Node; - firstChild(): Node; - previousNode(): Node; -} -declare var TreeWalker: { - prototype: TreeWalker; - new (): TreeWalker; -} - -interface GetSVGDocument { - getSVGDocument(): Document; -} - -interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticRel: { - prototype: SVGPathSegCurvetoQuadraticRel; - new (): SVGPathSegCurvetoQuadraticRel; -} - -interface Performance { - navigation: PerformanceNavigation; - timing: PerformanceTiming; - getEntriesByType(entryType: string): any; - toJSON(): any; - getMeasures(measureName?: string): any; - clearMarks(markName?: string): void; - getMarks(markName?: string): any; - clearResourceTimings(): void; - mark(markName: string): void; - measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - getEntriesByName(name: string, entryType?: string): any; - getEntries(): any; - clearMeasures(measureName?: string): void; - setResourceTimingBufferSize(maxSize: number): void; -} -declare var Performance: { - prototype: Performance; - new (): Performance; -} - -interface MSDataBindingTableExtensions { - dataPageSize: number; - nextPage(): void; - firstPage(): void; - refresh(): void; - previousPage(): void; - lastPage(): void; -} - -interface CompositionEvent extends UIEvent { - data: string; - locale: string; - initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; -} -declare var CompositionEvent: { - prototype: CompositionEvent; - new (): CompositionEvent; -} - -interface WindowTimers { - clearTimeout(handle: number): void; - setTimeout(handler: any, timeout?: any, ...args: any[]): number; - clearInterval(handle: number): void; - setInterval(handler: any, timeout?: any, ...args: any[]): number; -} - -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { - orientType: SVGAnimatedEnumeration; - markerUnits: SVGAnimatedEnumeration; - markerWidth: SVGAnimatedLength; - markerHeight: SVGAnimatedLength; - orientAngle: SVGAnimatedAngle; - refY: SVGAnimatedLength; - refX: SVGAnimatedLength; - setOrientToAngle(angle: SVGAngle): void; - setOrientToAuto(): void; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} -declare var SVGMarkerElement: { - prototype: SVGMarkerElement; - new (): SVGMarkerElement; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} - -interface CSSStyleDeclaration { - backgroundAttachment: string; - visibility: string; - textAlignLast: string; - borderRightStyle: string; - counterIncrement: string; - orphans: string; - cssText: string; - borderStyle: string; - pointerEvents: string; - borderTopColor: string; - markerEnd: string; - textIndent: string; - listStyleImage: string; - cursor: string; - listStylePosition: string; - wordWrap: string; - borderTopStyle: string; - alignmentBaseline: string; - opacity: string; - direction: string; - strokeMiterlimit: string; - maxWidth: string; - color: string; - clip: string; - borderRightWidth: string; - verticalAlign: string; - overflow: string; - mask: string; - borderLeftStyle: string; - emptyCells: string; - stopOpacity: string; - paddingRight: string; - parentRule: CSSRule; - background: string; - boxSizing: string; - textJustify: string; - height: string; - paddingTop: string; - length: number; - right: string; - baselineShift: string; - borderLeft: string; - widows: string; - lineHeight: string; - left: string; - textUnderlinePosition: string; - glyphOrientationHorizontal: string; - display: string; - textAnchor: string; - cssFloat: string; - strokeDasharray: string; - rubyAlign: string; - fontSizeAdjust: string; - borderLeftColor: string; - backgroundImage: string; - listStyleType: string; - strokeWidth: string; - textOverflow: string; - fillRule: string; - borderBottomColor: string; - zIndex: string; - position: string; - listStyle: string; - msTransformOrigin: string; - dominantBaseline: string; - overflowY: string; - fill: string; - captionSide: string; - borderCollapse: string; - boxShadow: string; - quotes: string; - tableLayout: string; - unicodeBidi: string; - borderBottomWidth: string; - backgroundSize: string; - textDecoration: string; - strokeDashoffset: string; - fontSize: string; - border: string; - pageBreakBefore: string; - borderTopRightRadius: string; - msTransform: string; - borderBottomLeftRadius: string; - textTransform: string; - rubyPosition: string; - strokeLinejoin: string; - clipPath: string; - borderRightColor: string; - fontFamily: string; - clear: string; - content: string; - backgroundClip: string; - marginBottom: string; - counterReset: string; - outlineWidth: string; - marginRight: string; - paddingLeft: string; - borderBottom: string; - wordBreak: string; - marginTop: string; - top: string; - fontWeight: string; - borderRight: string; - width: string; - kerning: string; - pageBreakAfter: string; - borderBottomStyle: string; - fontStretch: string; - padding: string; - strokeOpacity: string; - markerStart: string; - bottom: string; - borderLeftWidth: string; - clipRule: string; - backgroundPosition: string; - backgroundColor: string; - pageBreakInside: string; - backgroundOrigin: string; - strokeLinecap: string; - borderTopWidth: string; - outlineStyle: string; - borderTop: string; - outlineColor: string; - paddingBottom: string; - marginLeft: string; - font: string; - outline: string; - wordSpacing: string; - maxHeight: string; - fillOpacity: string; - letterSpacing: string; - borderSpacing: string; - backgroundRepeat: string; - borderRadius: string; - borderWidth: string; - borderBottomRightRadius: string; - whiteSpace: string; - fontStyle: string; - minWidth: string; - stopColor: string; - borderTopLeftRadius: string; - borderColor: string; - marker: string; - glyphOrientationVertical: string; - markerMid: string; - fontVariant: string; - minHeight: string; - stroke: string; - rubyOverhang: string; - overflowX: string; - textAlign: string; - margin: string; - getPropertyPriority(propertyName: string): string; - getPropertyValue(propertyName: string): string; - removeProperty(propertyName: string): string; - item(index: number): string; - [index: number]: string; - setProperty(propertyName: string, value: string, priority?: string): void; -} -declare var CSSStyleDeclaration: { - prototype: CSSStyleDeclaration; - new (): CSSStyleDeclaration; -} - -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGGElement: { - prototype: SVGGElement; - new (): SVGGElement; -} - -interface MSStyleCSSProperties extends MSCSSProperties { - pixelWidth: number; - posHeight: number; - posLeft: number; - pixelTop: number; - pixelBottom: number; - textDecorationNone: boolean; - pixelLeft: number; - posTop: number; - posBottom: number; - textDecorationOverline: boolean; - posWidth: number; - textDecorationLineThrough: boolean; - pixelHeight: number; - textDecorationBlink: boolean; - posRight: number; - pixelRight: number; - textDecorationUnderline: boolean; -} -declare var MSStyleCSSProperties: { - prototype: MSStyleCSSProperties; - new (): MSStyleCSSProperties; -} - -interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils { -} -declare var Navigator: { - prototype: Navigator; - new (): Navigator; -} - -interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothAbs: { - prototype: SVGPathSegCurvetoCubicSmoothAbs; - new (): SVGPathSegCurvetoCubicSmoothAbs; -} - -interface SVGZoomEvent extends UIEvent { - zoomRectScreen: SVGRect; - previousScale: number; - newScale: number; - previousTranslate: SVGPoint; - newTranslate: SVGPoint; -} -declare var SVGZoomEvent: { - prototype: SVGZoomEvent; - new (): SVGZoomEvent; -} - -interface NodeSelector { - querySelectorAll(selectors: string): NodeList; - querySelector(selectors: string): Element; -} - -interface HTMLTableDataCellElement extends HTMLTableCellElement { -} -declare var HTMLTableDataCellElement: { - prototype: HTMLTableDataCellElement; - new (): HTMLTableDataCellElement; -} - -interface HTMLBaseElement extends HTMLElement { - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Gets or sets the baseline URL on which relative links are based. - */ - href: string; -} -declare var HTMLBaseElement: { - prototype: HTMLBaseElement; - new (): HTMLBaseElement; -} - -interface ClientRect { - left: number; - width: number; - right: number; - top: number; - bottom: number; - height: number; -} -declare var ClientRect: { - prototype: ClientRect; - new (): ClientRect; -} - -interface PositionErrorCallback { - (error: PositionError): void; -} - -interface DOMImplementation { - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; - createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; - hasFeature(feature: string, version?: string): boolean; - createHTMLDocument(title: string): Document; -} -declare var DOMImplementation: { - prototype: DOMImplementation; - new (): DOMImplementation; -} - -interface SVGUnitTypes { - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} -declare var SVGUnitTypes: { - prototype: SVGUnitTypes; - new (): SVGUnitTypes; - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} - -interface Element extends Node, NodeSelector, ElementTraversal { - scrollTop: number; - clientLeft: number; - scrollLeft: number; - tagName: string; - clientWidth: number; - scrollWidth: number; - clientHeight: number; - clientTop: number; - scrollHeight: number; - getAttribute(name?: string): string; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - hasAttributeNS(namespaceURI: string, localName: string): boolean; - getBoundingClientRect(): ClientRect; - getAttributeNS(namespaceURI: string, localName: string): string; - getAttributeNodeNS(namespaceURI: string, localName: string): Attr; - setAttributeNodeNS(newAttr: Attr): Attr; - msMatchesSelector(selectors: string): boolean; - hasAttribute(name: string): boolean; - removeAttribute(name?: string): void; - setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; - getAttributeNode(name: string): Attr; - fireEvent(eventName: string, eventObj?: any): boolean; - getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; - getElementsByTagName(name: "area"): NodeListOf; - getElementsByTagName(name: "article"): NodeListOf; - getElementsByTagName(name: "aside"): NodeListOf; - getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; - getElementsByTagName(name: "base"): NodeListOf; - getElementsByTagName(name: "bdi"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; - getElementsByTagName(name: "body"): NodeListOf; - getElementsByTagName(name: "br"): NodeListOf; - getElementsByTagName(name: "button"): NodeListOf; - getElementsByTagName(name: "canvas"): NodeListOf; - getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; - getElementsByTagName(name: "col"): NodeListOf; - getElementsByTagName(name: "colgroup"): NodeListOf; - getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; - getElementsByTagName(name: "del"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; - getElementsByTagName(name: "div"): NodeListOf; - getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; - getElementsByTagName(name: "embed"): NodeListOf; - getElementsByTagName(name: "fieldset"): NodeListOf; - getElementsByTagName(name: "figcaption"): NodeListOf; - getElementsByTagName(name: "figure"): NodeListOf; - getElementsByTagName(name: "footer"): NodeListOf; - getElementsByTagName(name: "form"): NodeListOf; - getElementsByTagName(name: "h1"): NodeListOf; - getElementsByTagName(name: "h2"): NodeListOf; - getElementsByTagName(name: "h3"): NodeListOf; - getElementsByTagName(name: "h4"): NodeListOf; - getElementsByTagName(name: "h5"): NodeListOf; - getElementsByTagName(name: "h6"): NodeListOf; - getElementsByTagName(name: "head"): NodeListOf; - getElementsByTagName(name: "header"): NodeListOf; - getElementsByTagName(name: "hgroup"): NodeListOf; - getElementsByTagName(name: "hr"): NodeListOf; - getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; - getElementsByTagName(name: "iframe"): NodeListOf; - getElementsByTagName(name: "img"): NodeListOf; - getElementsByTagName(name: "input"): NodeListOf; - getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "label"): NodeListOf; - getElementsByTagName(name: "legend"): NodeListOf; - getElementsByTagName(name: "li"): NodeListOf; - getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "main"): NodeListOf; - getElementsByTagName(name: "map"): NodeListOf; - getElementsByTagName(name: "mark"): NodeListOf; - getElementsByTagName(name: "menu"): NodeListOf; - getElementsByTagName(name: "meta"): NodeListOf; - getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "noscript"): NodeListOf; - getElementsByTagName(name: "object"): NodeListOf; - getElementsByTagName(name: "ol"): NodeListOf; - getElementsByTagName(name: "optgroup"): NodeListOf; - getElementsByTagName(name: "option"): NodeListOf; - getElementsByTagName(name: "p"): NodeListOf; - getElementsByTagName(name: "param"): NodeListOf; - getElementsByTagName(name: "pre"): NodeListOf; - getElementsByTagName(name: "progress"): NodeListOf; - getElementsByTagName(name: "q"): NodeListOf; - getElementsByTagName(name: "rp"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; - getElementsByTagName(name: "script"): NodeListOf; - getElementsByTagName(name: "section"): NodeListOf; - getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; - getElementsByTagName(name: "source"): NodeListOf; - getElementsByTagName(name: "span"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; - getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "summary"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; - getElementsByTagName(name: "table"): NodeListOf; - getElementsByTagName(name: "tbody"): NodeListOf; - getElementsByTagName(name: "td"): NodeListOf; - getElementsByTagName(name: "textarea"): NodeListOf; - getElementsByTagName(name: "tfoot"): NodeListOf; - getElementsByTagName(name: "th"): NodeListOf; - getElementsByTagName(name: "thead"): NodeListOf; - getElementsByTagName(name: "title"): NodeListOf; - getElementsByTagName(name: "tr"): NodeListOf; - getElementsByTagName(name: "track"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; - getElementsByTagName(name: "ul"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; - getElementsByTagName(name: "video"): NodeListOf; - getElementsByTagName(name: "wbr"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getClientRects(): ClientRectList; - setAttributeNode(newAttr: Attr): Attr; - removeAttributeNode(oldAttr: Attr): Attr; - setAttribute(name?: string, value?: string): void; - removeAttributeNS(namespaceURI: string, localName: string): void; -} -declare var Element: { - prototype: Element; - new (): Element; -} - -interface HTMLNextIdElement extends HTMLElement { - n: string; -} -declare var HTMLNextIdElement: { - prototype: HTMLNextIdElement; - new (): HTMLNextIdElement; -} - -interface SVGPathSegMovetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoRel: { - prototype: SVGPathSegMovetoRel; - new (): SVGPathSegMovetoRel; -} - -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLineElement: { - prototype: SVGLineElement; - new (): SVGLineElement; -} - -interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; -} -declare var HTMLParagraphElement: { - prototype: HTMLParagraphElement; - new (): HTMLParagraphElement; -} - -interface HTMLAreasCollection extends HTMLCollection { - /** - * Removes an element from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: any): void; -} -declare var HTMLAreasCollection: { - prototype: HTMLAreasCollection; - new (): HTMLAreasCollection; -} - -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGDescElement: { - prototype: SVGDescElement; - new (): SVGDescElement; -} - -interface Node extends EventTarget { - nodeType: number; - previousSibling: Node; - localName: string; - namespaceURI: string; - textContent: string; - parentNode: Node; - nextSibling: Node; - nodeValue: string; - lastChild: Node; - childNodes: NodeList; - nodeName: string; - ownerDocument: Document; - attributes: NamedNodeMap; - firstChild: Node; - prefix: string; - removeChild(oldChild: Node): Node; - appendChild(newChild: Node): Node; - isSupported(feature: string, version: string): boolean; - isEqualNode(arg: Node): boolean; - lookupPrefix(namespaceURI: string): string; - isDefaultNamespace(namespaceURI: string): boolean; - compareDocumentPosition(other: Node): number; - normalize(): void; - isSameNode(other: Node): boolean; - hasAttributes(): boolean; - lookupNamespaceURI(prefix: string): string; - cloneNode(deep?: boolean): Node; - hasChildNodes(): boolean; - replaceChild(newChild: Node, oldChild: Node): Node; - insertBefore(newChild: Node, refChild?: Node): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} -declare var Node: { - prototype: Node; - new (): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} - -interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothRel: { - prototype: SVGPathSegCurvetoQuadraticSmoothRel; - new (): SVGPathSegCurvetoQuadraticSmoothRel; -} - -interface DOML2DeprecatedListSpaceReduction { - compact: boolean; -} - -interface MSScriptHost { -} -declare var MSScriptHost: { - prototype: MSScriptHost; - new (): MSScriptHost; -} - -interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - clipPathUnits: SVGAnimatedEnumeration; -} -declare var SVGClipPathElement: { - prototype: SVGClipPathElement; - new (): SVGClipPathElement; -} - -interface MouseEvent extends UIEvent { - toElement: Element; - layerY: number; - fromElement: Element; - which: number; - pageX: number; - offsetY: number; - x: number; - y: number; - metaKey: boolean; - altKey: boolean; - ctrlKey: boolean; - offsetX: number; - screenX: number; - clientY: number; - shiftKey: boolean; - layerX: number; - screenY: number; - relatedTarget: EventTarget; - button: number; - pageY: number; - buttons: number; - clientX: number; - initMouseEvent(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): void; - getModifierState(keyArg: string): boolean; -} -declare var MouseEvent: { - prototype: MouseEvent; - new (): MouseEvent; -} - -interface RangeException { - code: number; - message: string; - toString(): string; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} -declare var RangeException: { - prototype: RangeException; - new (): RangeException; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} - -interface SVGTextPositioningElement extends SVGTextContentElement { - y: SVGAnimatedLengthList; - rotate: SVGAnimatedNumberList; - dy: SVGAnimatedLengthList; - x: SVGAnimatedLengthList; - dx: SVGAnimatedLengthList; -} -declare var SVGTextPositioningElement: { - prototype: SVGTextPositioningElement; - new (): SVGTextPositioningElement; -} - -interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - width: number; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - object: string; - form: HTMLFormElement; - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. - */ - contentDocument: Document; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - /** - * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. - */ - declare: boolean; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; -} -declare var HTMLAppletElement: { - prototype: HTMLAppletElement; - new (): HTMLAppletElement; -} - -interface TextMetrics { - width: number; -} -declare var TextMetrics: { - prototype: TextMetrics; - new (): TextMetrics; -} - -interface DocumentEvent { - createEvent(eventInterface: string): Event; -} - -interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * The starting number. - */ - start: number; -} -declare var HTMLOListElement: { - prototype: HTMLOListElement; - new (): HTMLOListElement; -} - -interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalRel: { - prototype: SVGPathSegLinetoVerticalRel; - new (): SVGPathSegLinetoVerticalRel; -} - -interface SVGAnimatedString { - animVal: string; - baseVal: string; -} -declare var SVGAnimatedString: { - prototype: SVGAnimatedString; - new (): SVGAnimatedString; -} - -interface CDATASection extends Text { -} -declare var CDATASection: { - prototype: CDATASection; - new (): CDATASection; -} - -interface StyleMedia { - type: string; - matchMedium(mediaquery: string): boolean; -} -declare var StyleMedia: { - prototype: StyleMedia; - new (): StyleMedia; -} - -interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { - options: HTMLSelectElement; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the number of rows in the list box. - */ - size: number; - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the index of the selected option in a select object. - */ - selectedIndex: number; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Retrieves the type of select control based on the value of the MULTIPLE attribute. - */ - type: string; - /** - * Removes an element from the collection. - * @param index Number that specifies the zero-based index of the element to remove from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. - * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. - */ - add(element: HTMLElement, before?: any): void; - /** - * Retrieves a select object or an object from an options collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Retrieves a select object or an object from an options collection. - * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. - */ - namedItem(name: string): any; - [name: string]: any; -} -declare var HTMLSelectElement: { - prototype: HTMLSelectElement; - new (): HTMLSelectElement; -} - -interface TextRange { - boundingLeft: number; - htmlText: string; - offsetLeft: number; - boundingWidth: number; - boundingHeight: number; - boundingTop: number; - text: string; - offsetTop: number; - moveToPoint(x: number, y: number): void; - queryCommandValue(cmdID: string): any; - getBookmark(): string; - move(unit: string, count?: number): number; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(fStart?: boolean): void; - findText(string: string, count?: number, flags?: number): boolean; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - getBoundingClientRect(): ClientRect; - moveToBookmark(bookmark: string): boolean; - isEqual(range: TextRange): boolean; - duplicate(): TextRange; - collapse(start?: boolean): void; - queryCommandText(cmdID: string): string; - select(): void; - pasteHTML(html: string): void; - inRange(range: TextRange): boolean; - moveEnd(unit: string, count?: number): number; - getClientRects(): ClientRectList; - moveStart(unit: string, count?: number): number; - parentElement(): Element; - queryCommandState(cmdID: string): boolean; - compareEndPoints(how: string, sourceRange: TextRange): number; - execCommandShowHelp(cmdID: string): boolean; - moveToElementText(element: Element): void; - expand(Unit: string): boolean; - queryCommandSupported(cmdID: string): boolean; - setEndPoint(how: string, SourceRange: TextRange): void; - queryCommandEnabled(cmdID: string): boolean; -} -declare var TextRange: { - prototype: TextRange; - new (): TextRange; -} - -interface SVGTests { - requiredFeatures: SVGStringList; - requiredExtensions: SVGStringList; - systemLanguage: SVGStringList; - hasExtension(extension: string): boolean; -} - -interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLBlockElement: { - prototype: HTMLBlockElement; - new (): HTMLBlockElement; -} - -interface CSSStyleSheet extends StyleSheet { - owningElement: Element; - imports: StyleSheetList; - isAlternate: boolean; - rules: MSCSSRuleList; - isPrefAlternate: boolean; - readOnly: boolean; - cssText: string; - ownerRule: CSSRule; - href: string; - cssRules: CSSRuleList; - id: string; - pages: StyleSheetPageList; - addImport(bstrURL: string, lIndex?: number): number; - addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; - insertRule(rule: string, index?: number): number; - removeRule(lIndex: number): void; - deleteRule(index?: number): void; - addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; - removeImport(lIndex: number): void; -} -declare var CSSStyleSheet: { - prototype: CSSStyleSheet; - new (): CSSStyleSheet; -} - -interface MSSelection { - type: string; - typeDetail: string; - createRange(): TextRange; - clear(): void; - createRangeCollection(): TextRangeCollection; - empty(): void; -} -declare var MSSelection: { - prototype: MSSelection; - new (): MSSelection; -} - -interface HTMLMetaElement extends HTMLElement { - /** - * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. - */ - httpEquiv: string; - /** - * Sets or retrieves the value specified in the content attribute of the meta object. - */ - name: string; - /** - * Gets or sets meta-information to associate with httpEquiv or name. - */ - content: string; - /** - * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. - */ - url: string; - /** - * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. - */ - scheme: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; -} -declare var HTMLMetaElement: { - prototype: HTMLMetaElement; - new (): HTMLMetaElement; -} - -interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { - patternUnits: SVGAnimatedEnumeration; - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - patternContentUnits: SVGAnimatedEnumeration; - patternTransform: SVGAnimatedTransformList; - height: SVGAnimatedLength; -} -declare var SVGPatternElement: { - prototype: SVGPatternElement; - new (): SVGPatternElement; -} - -interface SVGAnimatedAngle { - animVal: SVGAngle; - baseVal: SVGAngle; -} -declare var SVGAnimatedAngle: { - prototype: SVGAnimatedAngle; - new (): SVGAnimatedAngle; -} - -interface Selection { - isCollapsed: boolean; - anchorNode: Node; - focusNode: Node; - anchorOffset: number; - focusOffset: number; - rangeCount: number; - addRange(range: Range): void; - collapseToEnd(): void; - toString(): string; - selectAllChildren(parentNode: Node): void; - getRangeAt(index: number): Range; - collapse(parentNode: Node, offset: number): void; - removeAllRanges(): void; - collapseToStart(): void; - deleteFromDocument(): void; - removeRange(range: Range): void; -} -declare var Selection: { - prototype: Selection; - new (): Selection; -} - -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { - type: string; -} -declare var SVGScriptElement: { - prototype: SVGScriptElement; - new (): SVGScriptElement; -} - -interface HTMLDDElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDDElement: { - prototype: HTMLDDElement; - new (): HTMLDDElement; -} - -interface MSDataBindingRecordSetReadonlyExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface CSSStyleRule extends CSSRule { - selectorText: string; - style: MSStyleCSSProperties; - readOnly: boolean; -} -declare var CSSStyleRule: { - prototype: CSSStyleRule; - new (): CSSStyleRule; -} - -interface NodeIterator { - whatToShow: number; - filter: NodeFilter; - root: Node; - expandEntityReferences: boolean; - nextNode(): Node; - detach(): void; - previousNode(): Node; -} -declare var NodeIterator: { - prototype: NodeIterator; - new (): NodeIterator; -} - -interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { - viewTarget: SVGStringList; -} -declare var SVGViewElement: { - prototype: SVGViewElement; - new (): SVGViewElement; -} - -interface HTMLLinkElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; -} -declare var HTMLLinkElement: { - prototype: HTMLLinkElement; - new (): HTMLLinkElement; -} - -interface SVGLocatable { - farthestViewportElement: SVGElement; - nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getTransformToElement(element: SVGElement): SVGMatrix; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; -} - -interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; -} -declare var HTMLFontElement: { - prototype: HTMLFontElement; - new (): HTMLFontElement; -} - -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGTitleElement: { - prototype: SVGTitleElement; - new (): SVGTitleElement; -} - -interface ControlRangeCollection { - length: number; - queryCommandValue(cmdID: string): any; - remove(index: number): void; - add(item: Element): void; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(varargStart?: any): void; - item(index: number): Element; - [index: number]: Element; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - addElement(item: Element): void; - queryCommandState(cmdID: string): boolean; - queryCommandSupported(cmdID: string): boolean; - queryCommandEnabled(cmdID: string): boolean; - queryCommandText(cmdID: string): string; - select(): void; -} -declare var ControlRangeCollection: { - prototype: ControlRangeCollection; - new (): ControlRangeCollection; -} - -interface MSNamespaceInfo extends MSEventAttachmentTarget { - urn: string; - onreadystatechange: (ev: Event) => any; - name: string; - readyState: string; - doImport(implementationUrl: string): void; -} -declare var MSNamespaceInfo: { - prototype: MSNamespaceInfo; - new (): MSNamespaceInfo; -} - -interface WindowSessionStorage { - sessionStorage: Storage; -} - -interface SVGAnimatedTransformList { - animVal: SVGTransformList; - baseVal: SVGTransformList; -} -declare var SVGAnimatedTransformList: { - prototype: SVGAnimatedTransformList; - new (): SVGAnimatedTransformList; -} - -interface HTMLTableCaptionElement extends HTMLElement { - /** - * Sets or retrieves the alignment of the caption or legend. - */ - align: string; - /** - * Sets or retrieves whether the caption appears at the top or bottom of the table. - */ - vAlign: string; -} -declare var HTMLTableCaptionElement: { - prototype: HTMLTableCaptionElement; - new (): HTMLTableCaptionElement; -} - -interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; - create(): HTMLOptionElement; -} -declare var HTMLOptionElement: { - prototype: HTMLOptionElement; - new (): HTMLOptionElement; -} - -interface HTMLMapElement extends HTMLElement { - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Retrieves a collection of the area objects defined for the given map object. - */ - areas: HTMLAreasCollection; -} -declare var HTMLMapElement: { - prototype: HTMLMapElement; - new (): HTMLMapElement; -} - -interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { - type: string; -} -declare var HTMLMenuElement: { - prototype: HTMLMenuElement; - new (): HTMLMenuElement; -} - -interface MouseWheelEvent extends MouseEvent { - wheelDelta: number; - initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; -} -declare var MouseWheelEvent: { - prototype: MouseWheelEvent; - new (): MouseWheelEvent; -} - -interface SVGFitToViewBox { - viewBox: SVGAnimatedRect; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} - -interface SVGPointList { - numberOfItems: number; - replaceItem(newItem: SVGPoint, index: number): SVGPoint; - getItem(index: number): SVGPoint; - clear(): void; - appendItem(newItem: SVGPoint): SVGPoint; - initialize(newItem: SVGPoint): SVGPoint; - removeItem(index: number): SVGPoint; - insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; -} -declare var SVGPointList: { - prototype: SVGPointList; - new (): SVGPointList; -} - -interface SVGAnimatedLengthList { - animVal: SVGLengthList; - baseVal: SVGLengthList; -} -declare var SVGAnimatedLengthList: { - prototype: SVGAnimatedLengthList; - new (): SVGAnimatedLengthList; -} - -interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers { - ondragend: (ev: DragEvent) => any; - onkeydown: (ev: KeyboardEvent) => any; - ondragover: (ev: DragEvent) => any; - onkeyup: (ev: KeyboardEvent) => any; - onreset: (ev: Event) => any; - onmouseup: (ev: MouseEvent) => any; - ondragstart: (ev: DragEvent) => any; - ondrag: (ev: DragEvent) => any; - screenX: number; - onmouseover: (ev: MouseEvent) => any; - ondragleave: (ev: DragEvent) => any; - history: History; - pageXOffset: number; - name: string; - onafterprint: (ev: Event) => any; - onpause: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - top: Window; - onmousedown: (ev: MouseEvent) => any; - onseeked: (ev: Event) => any; - opener: Window; - onclick: (ev: MouseEvent) => any; - innerHeight: number; - onwaiting: (ev: Event) => any; - ononline: (ev: Event) => any; - ondurationchange: (ev: Event) => any; - frames: Window; - onblur: (ev: FocusEvent) => any; - onemptied: (ev: Event) => any; - onseeking: (ev: Event) => any; - oncanplay: (ev: Event) => any; - outerWidth: number; - onstalled: (ev: Event) => any; - onmousemove: (ev: MouseEvent) => any; - innerWidth: number; - onoffline: (ev: Event) => any; - length: number; - screen: Screen; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onratechange: (ev: Event) => any; - onstorage: (ev: StorageEvent) => any; - onloadstart: (ev: Event) => any; - ondragenter: (ev: DragEvent) => any; - onsubmit: (ev: Event) => any; - self: Window; - document: Document; - onprogress: (ev: any) => any; - ondblclick: (ev: MouseEvent) => any; - pageYOffset: number; - oncontextmenu: (ev: MouseEvent) => any; - onchange: (ev: Event) => any; - onloadedmetadata: (ev: Event) => any; - onplay: (ev: Event) => any; - onerror: ErrorEventHandler; - onplaying: (ev: Event) => any; - parent: Window; - location: Location; - oncanplaythrough: (ev: Event) => any; - onabort: (ev: UIEvent) => any; - onreadystatechange: (ev: Event) => any; - outerHeight: number; - onkeypress: (ev: KeyboardEvent) => any; - frameElement: Element; - onloadeddata: (ev: Event) => any; - onsuspend: (ev: Event) => any; - window: Window; - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - ontimeupdate: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - onselect: (ev: UIEvent) => any; - navigator: Navigator; - styleMedia: StyleMedia; - ondrop: (ev: DragEvent) => any; - onmouseout: (ev: MouseEvent) => any; - onended: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onunload: (ev: Event) => any; - onscroll: (ev: UIEvent) => any; - screenY: number; - onmousewheel: (ev: MouseWheelEvent) => any; - onload: (ev: Event) => any; - onvolumechange: (ev: Event) => any; - oninput: (ev: Event) => any; - performance: Performance; - alert(message?: any): void; - scroll(x?: number, y?: number): void; - focus(): void; - scrollTo(x?: number, y?: number): void; - print(): void; - prompt(message?: string, defaul?: string): string; - toString(): string; - open(url?: string, target?: string, features?: string, replace?: boolean): Window; - scrollBy(x?: number, y?: number): void; - confirm(message?: string): boolean; - close(): void; - postMessage(message: any, targetOrigin: string, ports?: any): void; - showModalDialog(url?: string, argument?: any, options?: any): any; - blur(): void; - getSelection(): Selection; - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -} -declare var Window: { - prototype: Window; - new (): Window; -} - -interface SVGAnimatedPreserveAspectRatio { - animVal: SVGPreserveAspectRatio; - baseVal: SVGPreserveAspectRatio; -} -declare var SVGAnimatedPreserveAspectRatio: { - prototype: SVGAnimatedPreserveAspectRatio; - new (): SVGAnimatedPreserveAspectRatio; -} - -interface MSSiteModeEvent extends Event { - buttonID: number; - actionURL: string; -} -declare var MSSiteModeEvent: { - prototype: MSSiteModeEvent; - new (): MSSiteModeEvent; -} - -interface DOML2DeprecatedTextFlowControl { - clear: string; -} - -interface StyleSheetPageList { - length: number; - item(index: number): CSSPageRule; - [index: number]: CSSPageRule; -} -declare var StyleSheetPageList: { - prototype: StyleSheetPageList; - new (): StyleSheetPageList; -} - -interface MSCSSProperties extends CSSStyleDeclaration { - scrollbarShadowColor: string; - scrollbarHighlightColor: string; - layoutGridChar: string; - layoutGridType: string; - textAutospace: string; - textKashidaSpace: string; - writingMode: string; - scrollbarFaceColor: string; - backgroundPositionY: string; - lineBreak: string; - imeMode: string; - msBlockProgression: string; - layoutGridLine: string; - scrollbarBaseColor: string; - layoutGrid: string; - layoutFlow: string; - textKashida: string; - filter: string; - zoom: string; - scrollbarArrowColor: string; - behavior: string; - backgroundPositionX: string; - accelerator: string; - layoutGridMode: string; - textJustifyTrim: string; - scrollbar3dLightColor: string; - msInterpolationMode: string; - scrollbarTrackColor: string; - scrollbarDarkShadowColor: string; - styleFloat: string; - getAttribute(attributeName: string, flags?: number): any; - setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; - removeAttribute(attributeName: string, flags?: number): boolean; -} -declare var MSCSSProperties: { - prototype: MSCSSProperties; - new (): MSCSSProperties; -} - -interface HTMLCollection extends MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Retrieves an object from various collections. - */ - item(nameOrIndex?: any, optionalIndex?: any): Element; - /** - * Retrieves a select object or an object from an options collection. - */ - namedItem(name: string): Element; - [name: number]: Element; -} -declare var HTMLCollection: { - prototype: HTMLCollection; - new (): HTMLCollection; -} - -interface SVGExternalResourcesRequired { - externalResourcesRequired: SVGAnimatedBoolean; -} - -interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * The original height of the image resource before sizing. - */ - naturalHeight: number; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * The original width of the image resource before sizing. - */ - naturalWidth: number; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: number; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. - */ - longDesc: string; - /** - * Contains the hypertext reference (HREF) of the URL. - */ - href: string; - /** - * Sets or retrieves whether the image is a server-side image map. - */ - isMap: boolean; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - create(): HTMLImageElement; -} -declare var HTMLImageElement: { - prototype: HTMLImageElement; - new (): HTMLImageElement; -} - -interface HTMLAreaElement extends HTMLElement { - /** - * Sets or retrieves the protocol portion of a URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Sets or retrieves the host name part of the location or URL. - */ - hostname: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Sets or retrieves the file name or path specified by the object. - */ - pathname: string; - /** - * Sets or retrieves the hostname and port number of the location or URL. - */ - host: string; - /** - * Sets or retrieves the subsection of the href property that follows the number sign (#). - */ - hash: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or gets whether clicks in this region cause action. - */ - noHref: boolean; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAreaElement: { - prototype: HTMLAreaElement; - new (): HTMLAreaElement; -} - -interface EventTarget { - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - dispatchEvent(evt: Event): boolean; -} - -interface SVGAngle { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} -declare var SVGAngle: { - prototype: SVGAngle; - new (): SVGAngle; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} - -interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the default or selected value of the control. - */ - value: string; - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets the classification and default behavior of the button. - */ - type: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; -} -declare var HTMLButtonElement: { - prototype: HTMLButtonElement; - new (): HTMLButtonElement; -} - -interface HTMLSourceElement extends HTMLElement { - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the intended media type of the media source. - */ - media: string; - /** - * Gets or sets the MIME type of a media resource. - */ - type: string; -} -declare var HTMLSourceElement: { - prototype: HTMLSourceElement; - new (): HTMLSourceElement; -} - -interface CanvasGradient { - addColorStop(offset: number, color: string): void; -} -declare var CanvasGradient: { - prototype: CanvasGradient; - new (): CanvasGradient; -} - -interface KeyboardEvent extends UIEvent { - location: number; - keyCode: number; - shiftKey: boolean; - which: number; - locale: string; - key: string; - altKey: boolean; - metaKey: boolean; - char: string; - ctrlKey: boolean; - repeat: boolean; - charCode: number; - getModifierState(keyArg: string): boolean; - initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} -declare var KeyboardEvent: { - prototype: KeyboardEvent; - new (): KeyboardEvent; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} - -interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions { - /** - * Retrieves the collection of user agents and versions declared in the X-UA-Compatible - */ - compatible: MSCompatibleInfoCollection; - /** - * Fires when the user presses a key. - * @param ev The keyboard event - */ - onkeydown: (ev: KeyboardEvent) => any; - /** - * Fires when the user releases a key. - * @param ev The keyboard event - */ - onkeyup: (ev: KeyboardEvent) => any; - - /** - * Gets the implementation object of the current document. - */ - implementation: DOMImplementation; - /** - * Fires when the user resets a form. - * @param ev The event. - */ - onreset: (ev: Event) => any; - - /** - * Retrieves a collection of all script objects in the document. - */ - scripts: HTMLCollection; - - /** - * Fires when the user presses the F1 key while the browser is the active window. - * @param ev The event. - */ - onhelp: (ev: Event) => any; - - /** - * 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; - - /** - * Gets or sets the character set used to encode the object. - */ - charset: string; - - /** - * Fires for an element just prior to setting focus on that element. - * @param ev The focus event - */ - onfocusin: (ev: FocusEvent) => any; - - - /** - * Sets or gets the color of the links that the user has visited. - */ - vlinkColor: string; - - /** - * Occurs when the seek operation ends. - * @param ev The event. - */ - onseeked: (ev: Event) => any; - - security: string; - - /** - * Contains the title of the document. - */ - title: string; - - /** - * Retrieves a collection of namespace objects. - */ - namespaces: MSNamespaceInfoCollection; - - /** - * Gets the default character set from the current regional language settings. - */ - defaultCharset: string; - - /** - * Retrieves a collection of all embed objects in the document. - */ - embeds: HTMLCollection; - - /** - * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. - */ - styleSheets: StyleSheetList; - - /** - * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. - */ - frames: Window; - - /** - * Occurs when the duration attribute is updated. - * @param ev The event. - */ - ondurationchange: (ev: Event) => any; - - - /** - * Returns a reference to the collection of elements contained by the object. - */ - all: HTMLCollection; - - /** - * Retrieves a collection, in source order, of all form objects in the document. - */ - forms: HTMLCollection; - - /** - * Fires when the object loses the input focus. - * @param ev The focus event. - */ - onblur: (ev: FocusEvent) => any; - - - /** - * Sets or retrieves a value that indicates the reading order of the object. - */ - dir: string; - - /** - * Occurs when the media element is reset to its initial state. - * @param ev The event. - */ - onemptied: (ev: Event) => any; - - - /** - * Sets or gets a value that indicates whether the document can be edited. - */ - designMode: string; - - /** - * Occurs when the current playback position is moved. - * @param ev The event. - */ - onseeking: (ev: Event) => any; - - - /** - * Fires when the activeElement is changed from the current object to another object in the parent document. - * @param ev The UI Event - */ - ondeactivate: (ev: UIEvent) => any; - - - /** - * Occurs when playback is possible, but would require further buffering. - * @param ev The event. - */ - oncanplay: (ev: Event) => any; - - - /** - * Fires when the data set exposed by a data source object changes. - * @param ev The event. - */ - ondatasetchanged: (ev: MSEventObj) => any; - - - /** - * Fires when rows are about to be deleted from the recordset. - * @param ev The event - */ - onrowsdelete: (ev: MSEventObj) => any; - - Script: MSScriptHost; - - /** - * Occurs when Internet Explorer begins looking for media data. - * @param ev The event. - */ - onloadstart: (ev: Event) => any; - - - /** - * Gets the URL for the document, stripped of any character encoding. - */ - URLUnencoded: string; - - defaultView: Window; - - /** - * Fires when the user is about to make a control selection of the object. - * @param ev The event. - */ - oncontrolselect: (ev: MSEventObj) => any; - - - /** - * Fires on the target element when the user drags the object to a valid drop target. - * @param ev The drag event. - */ - ondragenter: (ev: DragEvent) => any; - - onsubmit: (ev: Event) => any; - - /** - * Returns the character encoding used to create the webpage that is loaded into the document object. - */ - inputEncoding: string; - - /** - * Gets the object that has the focus when the parent document has focus. - */ - activeElement: Element; - - /** - * Fires when the contents of the object or selection have changed. - * @param ev The event. - */ - onchange: (ev: Event) => any; - - - /** - * Retrieves a collection of all a objects that specify the href property and all area objects in the document. - */ - links: HTMLCollection; - - /** - * Retrieves an autogenerated, unique identifier for the object. - */ - uniqueID: string; - - /** - * Sets or gets the URL for the current document. - */ - URL: string; - - /** - * Fires immediately before the object is set as the active element. - * @param ev The event. - */ - onbeforeactivate: (ev: UIEvent) => any; - - head: HTMLHeadElement; - cookie: string; - xmlEncoding: string; - oncanplaythrough: (ev: Event) => any; - - /** - * Retrieves the document compatibility mode of the document. - */ - documentMode: number; - - characterSet: string; - - /** - * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. - */ - anchors: HTMLCollection; - - onbeforeupdate: (ev: MSEventObj) => any; - - /** - * Fires to indicate that all data is available from the data source object. - * @param ev The event. - */ - ondatasetcomplete: (ev: MSEventObj) => any; - - plugins: HTMLCollection; - - /** - * Occurs if the load operation has been intentionally halted. - * @param ev The event. - */ - onsuspend: (ev: Event) => any; - - - /** - * Gets the root svg element in the document hierarchy. - */ - rootElement: SVGSVGElement; - - /** - * Retrieves a value that indicates the current state of the object. - */ - readyState: string; - - /** - * Gets the URL of the location that referred the user to the current page. - */ - referrer: string; - - /** - * Sets or gets the color of all active links in the document. - */ - alinkColor: string; - - /** - * Fires on a databound object when an error occurs while updating the associated data in the data source object. - * @param ev The event. - */ - onerrorupdate: (ev: MSEventObj) => any; - - - /** - * Gets a reference to the container object of the window. - */ - parentWindow: Window; - - /** - * Fires when the user moves the mouse pointer outside the boundaries of the object. - * @param ev The mouse event. - */ - onmouseout: (ev: MouseEvent) => any; - - - /** - * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. - * @param ev The event. - */ - onmsthumbnailclick: (ev: MSSiteModeEvent) => any; - - - /** - * Fires when the wheel button is rotated. - * @param ev The mouse event - */ - onmousewheel: (ev: MouseWheelEvent) => any; - - - /** - * Occurs when the volume is changed, or playback is muted or unmuted. - * @param ev The event. - */ - onvolumechange: (ev: Event) => any; - - - /** - * Fires when data changes in the data provider. - * @param ev The event. - */ - oncellchange: (ev: MSEventObj) => any; - - - /** - * Fires just before the data source control changes the current row in the object. - * @param ev The event. - */ - onrowexit: (ev: MSEventObj) => any; - - - /** - * Fires just after new rows are inserted in the current recordset. - * @param ev The event. - */ - onrowsinserted: (ev: MSEventObj) => any; - - - /** - * Gets or sets the version attribute specified in the declaration of an XML document. - */ - xmlVersion: string; - - msCapsLockWarningOff: boolean; - - /** - * Fires when a property changes on the object. - * @param ev The event. - */ - onpropertychange: (ev: MSEventObj) => any; - - - /** - * Fires on the source object when the user releases the mouse at the close of a drag operation. - * @param ev The event. - */ - ondragend: (ev: DragEvent) => any; - - - /** - * Gets an object representing the document type declaration associated with the current document. - */ - doctype: DocumentType; - - /** - * Fires on the target element continuously while the user drags the object over a valid drop target. - * @param ev The event. - */ - ondragover: (ev: DragEvent) => any; - - - /** - * Deprecated. Sets or retrieves a value that indicates the background color behind the object. - */ - bgColor: string; - - /** - * Fires on the source object when the user starts to drag a text selection or selected object. - * @param ev The event. - */ - ondragstart: (ev: DragEvent) => any; - - - /** - * Fires when the user releases a mouse button while the mouse is over the object. - * @param ev The mouse event. - */ - onmouseup: (ev: MouseEvent) => any; - - - /** - * Fires on the source object continuously during a drag operation. - * @param ev The event. - */ - ondrag: (ev: DragEvent) => any; - - - /** - * Fires when the user moves the mouse pointer into the object. - * @param ev The mouse event. - */ - onmouseover: (ev: MouseEvent) => any; - - - /** - * Sets or gets the color of the document links. - */ - linkColor: string; - - /** - * Occurs when playback is paused. - * @param ev The event. - */ - onpause: (ev: Event) => any; - - - /** - * Fires when the user clicks the object with either mouse button. - * @param ev The mouse event. - */ - onmousedown: (ev: MouseEvent) => any; - - - /** - * Fires when the user clicks the left mouse button on the object - * @param ev The mouse event. - */ - onclick: (ev: MouseEvent) => any; - - - /** - * Occurs when playback stops because the next frame of a video resource is not available. - * @param ev The event. - */ - onwaiting: (ev: Event) => any; - - - /** - * Fires when the user clicks the Stop button or leaves the Web page. - * @param ev The event. - */ - onstop: (ev: Event) => any; - - /** - * false (false)[rolls - */ - - /** - * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. - * @param ev The event. - */ - onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; - - - /** - * Retrieves a collection of all applet objects in the document. - */ - applets: HTMLCollection; - - /** - * Specifies the beginning and end of the document body. - */ - body: HTMLElement; - - /** - * Sets or gets the security domain of the document. - */ - domain: string; - - xmlStandalone: boolean; - - /** - * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. - */ - selection: MSSelection; - - /** - * Occurs when the download has stopped. - * @param ev The event. - */ - onstalled: (ev: Event) => any; - - - /** - * Fires when the user moves the mouse over the object. - * @param ev The mouse event. - */ - onmousemove: (ev: MouseEvent) => any; - - - /** - * Gets a reference to the root node of the document. - */ - documentElement: HTMLElement; - - /** - * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. - * @param ev The event. - */ - onbeforeeditfocus: (ev: MSEventObj) => any; - - - /** - * Occurs when the playback rate is increased or decreased. - * @param ev The event. - */ - onratechange: (ev: Event) => any; - - - /** - * Occurs to indicate progress while downloading media data. - * @param ev The event. - */ - onprogress: (ev: any) => any; - - - /** - * Fires when the user double-clicks the object. - * @param ev The mouse event. - */ - ondblclick: (ev: MouseEvent) => any; - - - /** - * Fires when the user clicks the right mouse button in the client area, opening the context menu. - * @param ev The mouse event. - */ - oncontextmenu: (ev: MouseEvent) => any; - - - /** - * Occurs when the duration and dimensions of the media have been determined. - * @param ev The event. - */ - onloadedmetadata: (ev: Event) => any; - - media: string; - - /** - * Fires when an error occurs during object loading. - * @param ev The event. - */ - onerror: (ev: Event) => any; - - - /** - * Occurs when the play method is requested. - * @param ev The event. - */ - onplay: (ev: Event) => any; - - onafterupdate: (ev: MSEventObj) => any; - - /** - * Occurs when the audio or video has started playing. - * @param ev The event. - */ - onplaying: (ev: Event) => any; - - - /** - * Retrieves a collection, in source order, of img objects in the document. - */ - images: HTMLCollection; - - /** - * Contains information about the current URL. - */ - location: Location; - - /** - * Fires when the user aborts the download. - * @param ev The event. - */ - onabort: (ev: UIEvent) => any; - - - /** - * Fires for the current element with focus immediately after moving focus to another element. - * @param ev The event. - */ - onfocusout: (ev: FocusEvent) => any; - - - /** - * Fires when the selection state of a document changes. - * @param ev The event. - */ - onselectionchange: (ev: Event) => any; - - - /** - * Fires when a local DOM Storage area is written to disk. - * @param ev The event. - */ - onstoragecommit: (ev: StorageEvent) => any; - - - /** - * Fires periodically as data arrives from data source objects that asynchronously transmit their data. - * @param ev The event. - */ - ondataavailable: (ev: MSEventObj) => any; - - - /** - * Fires when the state of the object has changed. - * @param ev The event - */ - onreadystatechange: (ev: Event) => any; - - - /** - * Gets the date that the page was last modified, if the page supplies one. - */ - lastModified: string; - - /** - * Fires when the user presses an alphanumeric key. - * @param ev The event. - */ - onkeypress: (ev: KeyboardEvent) => any; - - - /** - * Occurs when media data is loaded at the current playback position. - * @param ev The event. - */ - onloadeddata: (ev: Event) => any; - - - /** - * Fires immediately before the activeElement is changed from the current object to another object in the parent document. - * @param ev The event. - */ - onbeforedeactivate: (ev: UIEvent) => any; - - - /** - * Fires when the object is set as the active element. - * @param ev The event. - */ - onactivate: (ev: UIEvent) => any; - - - onselectstart: (ev: Event) => any; - - /** - * Fires when the object receives focus. - * @param ev The event. - */ - onfocus: (ev: FocusEvent) => any; - - - /** - * Sets or gets the foreground (text) color of the document. - */ - fgColor: string; - - /** - * Occurs to indicate the current playback position. - * @param ev The event. - */ - ontimeupdate: (ev: Event) => any; - - - /** - * Fires when the current selection changes. - * @param ev The event. - */ - onselect: (ev: UIEvent) => any; - - ondrop: (ev: DragEvent) => any; - - /** - * Occurs when the end of playback is reached. - * @param ev The event - */ - onended: (ev: Event) => any; - - - /** - * Gets a value that indicates whether standards-compliant mode is switched on for the object. - */ - compatMode: string; - - /** - * Fires when the user repositions the scroll box in the scroll bar on the object. - * @param ev The event. - */ - onscroll: (ev: UIEvent) => any; - - - /** - * Fires to indicate that the current row has changed in the data source and new data values are available on the object. - * @param ev The event. - */ - onrowenter: (ev: MSEventObj) => any; - - - /** - * Fires immediately after the browser loads the object. - * @param ev The event. - */ - onload: (ev: Event) => any; - - oninput: (ev: Event) => any; - - /** - * Returns the current value of the document, range, or current selection for the given command. - * @param commandId String that specifies a command identifier. - */ - queryCommandValue(commandId: string): string; - - adoptNode(source: Node): Node; - - /** - * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. - * @param commandId String that specifies a command identifier. - */ - queryCommandIndeterm(commandId: string): boolean; - - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - createProcessingInstruction(target: string, data: string): ProcessingInstruction; - - /** - * Executes a command on the current document, current selection, or the given range. - * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. - * @param showUI Display the user interface, defaults to false. - * @param value Value to assign. - */ - execCommand(commandId: string, showUI?: boolean, value?: any): boolean; - - /** - * Returns the element for the specified x coordinate and the specified y coordinate. - * @param x The x-offset - * @param y The y-offset - */ - elementFromPoint(x: number, y: number): Element; - createCDATASection(data: string): CDATASection; - - /** - * Retrieves the string associated with a command. - * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. - */ - queryCommandText(commandId: string): string; - - /** - * Writes one or more HTML expressions to a document in the specified window. - * @param content Specifies the text and HTML tags to write. - */ - write(...content: string[]): void; - - /** - * Allows updating the print settings for the page. - */ - updateSettings(): void; - - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "a"): HTMLAnchorElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "abbr"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "address"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "area"): HTMLAreaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "article"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "aside"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "audio"): HTMLAudioElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "b"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "base"): HTMLBaseElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "bdi"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "bdo"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "blockquote"): HTMLQuoteElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "body"): HTMLBodyElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "br"): HTMLBRElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "button"): HTMLButtonElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "canvas"): HTMLCanvasElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "caption"): HTMLTableCaptionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "cite"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "code"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "col"): HTMLTableColElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "colgroup"): HTMLTableColElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "datalist"): HTMLDataListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dd"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "del"): HTMLModElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dfn"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "div"): HTMLDivElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dl"): HTMLDListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dt"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "em"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "embed"): HTMLEmbedElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "fieldset"): HTMLFieldSetElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "figcaption"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "figure"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "footer"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "form"): HTMLFormElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h1"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h2"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h3"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h4"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h5"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h6"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "head"): HTMLHeadElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "header"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "hgroup"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "hr"): HTMLHRElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "html"): HTMLHtmlElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "i"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "iframe"): HTMLIFrameElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "img"): HTMLImageElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "input"): HTMLInputElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ins"): HTMLModElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "kbd"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "label"): HTMLLabelElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "legend"): HTMLLegendElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "li"): HTMLLIElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "link"): HTMLLinkElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "main"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "map"): HTMLMapElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "mark"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "menu"): HTMLMenuElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "meta"): HTMLMetaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "nav"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "noscript"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "object"): HTMLObjectElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ol"): HTMLOListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "optgroup"): HTMLOptGroupElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "option"): HTMLOptionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "p"): HTMLParagraphElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "param"): HTMLParamElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "pre"): HTMLPreElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "progress"): HTMLProgressElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "q"): HTMLQuoteElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "rp"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "rt"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ruby"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "s"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "samp"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "script"): HTMLScriptElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "section"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "select"): HTMLSelectElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "small"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "source"): HTMLSourceElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "span"): HTMLSpanElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "strong"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "style"): HTMLStyleElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "sub"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "summary"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "sup"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "table"): HTMLTableElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tbody"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "td"): HTMLTableDataCellElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "textarea"): HTMLTextAreaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tfoot"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "th"): HTMLTableHeaderCellElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "thead"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "title"): HTMLTitleElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tr"): HTMLTableRowElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "track"): HTMLTrackElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "u"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ul"): HTMLUListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "var"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "video"): HTMLVideoElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "wbr"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: string): HTMLElement; - - /** - * Removes mouse capture from the object in the current document. - */ - releaseCapture(): void; - - /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. - * @param content The text and HTML tags to write. - */ - writeln(...content: string[]): void; - createElementNS(namespaceURI: string, qualifiedName: string): Element; - - /** - * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. - * @param url Specifies a MIME type for the document. - * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. - * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. - * @param replace Specifies whether the existing entry for the document is replaced in the history list. - */ - open(url?: string, name?: string, features?: string, replace?: boolean): any; - - /** - * Returns a Boolean value that indicates whether the current command is supported on the current range. - * @param commandId Specifies a command identifier. - */ - queryCommandSupported(commandId: string): boolean; - - /** - * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. - * @param filter A custom NodeFilter function to use. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; - createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; - - /** - * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. - * @param commandId Specifies a command identifier. - */ - queryCommandEnabled(commandId: string): boolean; - - /** - * Causes the element to receive the focus and executes the code specified by the onfocus event. - */ - focus(): void; - - /** - * Closes an output stream and forces the sent data to display. - */ - close(): void; - - getElementsByClassName(classNames: string): NodeList; - importNode(importedNode: Node, deep: boolean): Node; - - /** - * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. - */ - createRange(): Range; - - /** - * Fires a specified event on the object. - * @param eventName Specifies the name of the event to fire. - * @param eventObj Object that specifies the event object from which to obtain event object properties. - */ - fireEvent(eventName: string, eventObj?: any): boolean; - - /** - * Creates a comment object with the specified data. - * @param data Sets the comment object's data. - */ - createComment(data: string): Comment; - - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "a"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "abbr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "address"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "area"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "article"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "aside"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "audio"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "b"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "base"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "bdi"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "bdo"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "blockquote"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "body"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "br"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "button"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "canvas"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "caption"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "cite"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "code"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "col"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "colgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "datalist"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dd"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "del"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dfn"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "div"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dl"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dt"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "em"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "embed"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "fieldset"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "figcaption"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "figure"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "footer"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "form"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h1"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h2"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h3"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h4"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h5"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h6"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "head"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "header"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "hgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "hr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "html"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "i"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "iframe"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "img"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "input"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ins"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "kbd"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "label"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "legend"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "li"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "link"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "main"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "map"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "mark"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "menu"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "meta"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "nav"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "noscript"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "object"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ol"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "optgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "option"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "p"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "param"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "pre"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "progress"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "q"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "rp"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "rt"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ruby"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "s"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "samp"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "script"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "section"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "select"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "small"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "source"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "span"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "strong"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "style"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "sub"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "summary"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "sup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "table"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tbody"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "td"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "textarea"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tfoot"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "th"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "thead"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "title"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "track"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "u"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ul"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "var"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "video"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "wbr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: string): NodeList; - - /** - * Creates a new document. - */ - createDocumentFragment(): DocumentFragment; - - /** - * Creates a style sheet for the document. - * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. - * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. - */ - createStyleSheet(href?: string, index?: number): CSSStyleSheet; - - /** - * Gets a collection of objects based on the value of the NAME or ID attribute. - * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. - */ - getElementsByName(elementName: string): NodeList; - - /** - * Returns a Boolean value that indicates the current state of the command. - * @param commandId String that specifies a command identifier. - */ - queryCommandState(commandId: string): boolean; - - /** - * Gets a value indicating whether the object currently has focus. - */ - hasFocus(): boolean; - - /** - * Displays help information for the given command identifier. - * @param commandId Displays help information for the given command identifier. - */ - execCommandShowHelp(commandId: string): boolean; - - /** - * Creates an attribute object with a specified name. - * @param name String that sets the attribute object's name. - */ - createAttribute(name: string): Attr; - - /** - * Creates a text string from the specified value. - * @param data String that specifies the nodeValue property of the text node. - */ - createTextNode(data: string): Text; - - /** - * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list - * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; - - /** - * Generates an event object to pass event context information when you use the fireEvent method. - * @param eventObj An object that specifies an existing event object on which to base the new object. - */ - createEventObject(eventObj?: any): MSEventObj; - - /** - * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. - */ - getSelection(): Selection; - - /** - * Returns a reference to the first object with the specified value of the ID or NAME attribute. - * @param elementId String that specifies the ID value. Case-insensitive. - */ - getElementById(elementId: string): HTMLElement; -} - -declare var Document: { - prototype: Document; - new (): Document; -} - -interface MessageEvent extends Event { - source: Window; - origin: string; - data: any; - initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; -} -declare var MessageEvent: { - prototype: MessageEvent; - new (): MessageEvent; -} - -interface SVGElement extends Element { - onmouseover: (ev: MouseEvent) => any; - viewportElement: SVGElement; - onmousemove: (ev: MouseEvent) => any; - onmouseout: (ev: MouseEvent) => any; - ondblclick: (ev: MouseEvent) => any; - onfocusout: (ev: FocusEvent) => any; - onfocusin: (ev: FocusEvent) => any; - xmlbase: string; - onmousedown: (ev: MouseEvent) => any; - onload: (ev: Event) => any; - onmouseup: (ev: MouseEvent) => any; - onclick: (ev: MouseEvent) => any; - ownerSVGElement: SVGSVGElement; - id: string; -} -declare var SVGElement: { - prototype: SVGElement; - new (): SVGElement; -} - -interface HTMLScriptElement extends HTMLElement { - /** - * Sets or retrieves the status of the script. - */ - defer: boolean; - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; - /** - * Retrieves the URL to an external file that contains the source code or data. - */ - src: string; - /** - * Sets or retrieves the object that is bound to the event script. - */ - htmlFor: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the MIME type for the associated scripting engine. - */ - type: string; - /** - * Sets or retrieves the event for which the script is written. - */ - event: string; -} -declare var HTMLScriptElement: { - prototype: HTMLScriptElement; - new (): HTMLScriptElement; -} - -interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Retrieves the position of the object in the rows collection for the table. - */ - rowIndex: number; - /** - * Retrieves a collection of all cells in the table row. - */ - cells: HTMLCollection; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Retrieves the position of the object in the collection. - */ - sectionRowIndex: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified cell from the table row, as well as from the cells collection. - * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. - */ - deleteCell(index?: number): void; - /** - * Creates a new cell in the table row, and adds the cell to the cells collection. - * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. - */ - insertCell(index?: number): HTMLElement; -} -declare var HTMLTableRowElement: { - prototype: HTMLTableRowElement; - new (): HTMLTableRowElement; -} - -interface CanvasRenderingContext2D { - miterLimit: number; - font: string; - globalCompositeOperation: string; - msFillRule: string; - lineCap: string; - msImageSmoothingEnabled: boolean; - lineDashOffset: number; - shadowColor: string; - lineJoin: string; - shadowOffsetX: number; - lineWidth: number; - canvas: HTMLCanvasElement; - strokeStyle: any; - globalAlpha: number; - shadowOffsetY: number; - fillStyle: any; - shadowBlur: number; - textAlign: string; - textBaseline: string; - restore(): void; - setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - save(): void; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - measureText(text: string): TextMetrics; - isPointInPath(x: number, y: number, fillRule?: string): boolean; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; - rotate(angle: number): void; - fillText(text: string, x: number, y: number, maxWidth?: number): void; - translate(x: number, y: number): void; - scale(x: number, y: number): void; - createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - lineTo(x: number, y: number): void; - getLineDash(): Array; - fill(fillRule?: string): void; - createImageData(imageDataOrSw: any, sh?: number): ImageData; - createPattern(image: HTMLElement, repetition: string): CanvasPattern; - closePath(): void; - rect(x: number, y: number, w: number, h: number): void; - clip(fillRule?: string): void; - clearRect(x: number, y: number, w: number, h: number): void; - moveTo(x: number, y: number): void; - getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; - fillRect(x: number, y: number, w: number, h: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; - strokeRect(x: number, y: number, w: number, h: number): void; - setLineDash(segments: Array): void; - strokeText(text: string, x: number, y: number, maxWidth?: number): void; - beginPath(): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; - createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; -} -declare var CanvasRenderingContext2D: { - prototype: CanvasRenderingContext2D; - new (): CanvasRenderingContext2D; -} - -interface MSCSSRuleList { - length: number; - item(index?: number): CSSStyleRule; - [index: number]: CSSStyleRule; -} -declare var MSCSSRuleList: { - prototype: MSCSSRuleList; - new (): MSCSSRuleList; -} - -interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalAbs: { - prototype: SVGPathSegLinetoHorizontalAbs; - new (): SVGPathSegLinetoHorizontalAbs; -} - -interface SVGPathSegArcAbs extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcAbs: { - prototype: SVGPathSegArcAbs; - new (): SVGPathSegArcAbs; -} - -interface SVGTransformList { - numberOfItems: number; - getItem(index: number): SVGTransform; - consolidate(): SVGTransform; - clear(): void; - appendItem(newItem: SVGTransform): SVGTransform; - initialize(newItem: SVGTransform): SVGTransform; - removeItem(index: number): SVGTransform; - insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; - replaceItem(newItem: SVGTransform, index: number): SVGTransform; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; -} -declare var SVGTransformList: { - prototype: SVGTransformList; - new (): SVGTransformList; -} - -interface HTMLHtmlElement extends HTMLElement { - /** - * Sets or retrieves the DTD version that governs the current document. - */ - version: string; -} -declare var HTMLHtmlElement: { - prototype: HTMLHtmlElement; - new (): HTMLHtmlElement; -} - -interface SVGPathSegClosePath extends SVGPathSeg { -} -declare var SVGPathSegClosePath: { - prototype: SVGPathSegClosePath; - new (): SVGPathSegClosePath; -} - -interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * Raised when the object has been completely received from the server. - */ - onload: (ev: Event) => any; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; -} -declare var HTMLFrameElement: { - prototype: HTMLFrameElement; - new (): HTMLFrameElement; -} - -interface SVGAnimatedLength { - animVal: SVGLength; - baseVal: SVGLength; -} -declare var SVGAnimatedLength: { - prototype: SVGAnimatedLength; - new (): SVGAnimatedLength; -} - -interface SVGAnimatedPoints { - points: SVGPointList; - animatedPoints: SVGPointList; -} - -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGDefsElement: { - prototype: SVGDefsElement; - new (): SVGDefsElement; -} - -interface HTMLQuoteElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLQuoteElement: { - prototype: HTMLQuoteElement; - new (): HTMLQuoteElement; -} - -interface CSSMediaRule extends CSSRule { - media: MediaList; - cssRules: CSSRuleList; - insertRule(rule: string, index?: number): number; - deleteRule(index?: number): void; -} -declare var CSSMediaRule: { - prototype: CSSMediaRule; - new (): CSSMediaRule; -} - -interface WindowModal { - dialogArguments: any; - returnValue: any; -} - -interface XMLHttpRequest extends EventTarget { - responseBody: any; - status: number; - readyState: number; - responseText: string; - responseXML: Document; - ontimeout: (ev: Event) => any; - statusText: string; - onreadystatechange: (ev: Event) => any; - timeout: number; - onload: (ev: Event) => any; - open(method: string, url: string, async?: boolean, user?: string, password?: string): void; - create(): XMLHttpRequest; - send(data?: any): void; - abort(): void; - getAllResponseHeaders(): string; - setRequestHeader(header: string, value: string): void; - getResponseHeader(header: string): string; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; -} -declare var XMLHttpRequest: { - prototype: XMLHttpRequest; - new (): XMLHttpRequest; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; -} - -interface HTMLTableHeaderCellElement extends HTMLTableCellElement { - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; -} -declare var HTMLTableHeaderCellElement: { - prototype: HTMLTableHeaderCellElement; - new (): HTMLTableHeaderCellElement; -} - -interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { -} -declare var HTMLDListElement: { - prototype: HTMLDListElement; - new (): HTMLDListElement; -} - -interface MSDataBindingExtensions { - dataSrc: string; - dataFormatAs: string; - dataFld: string; -} - -interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalRel: { - prototype: SVGPathSegLinetoHorizontalRel; - new (): SVGPathSegLinetoHorizontalRel; -} - -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - ry: SVGAnimatedLength; - cx: SVGAnimatedLength; - rx: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGEllipseElement: { - prototype: SVGEllipseElement; - new (): SVGEllipseElement; -} - -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - target: SVGAnimatedString; -} -declare var SVGAElement: { - prototype: SVGAElement; - new (): SVGAElement; -} - -interface SVGStylable { - className: SVGAnimatedString; - style: CSSStyleDeclaration; -} - -interface SVGTransformable extends SVGLocatable { - transform: SVGAnimatedTransformList; -} - -interface HTMLFrameSetElement extends HTMLElement { - ononline: (ev: Event) => any; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the frame heights of the object. - */ - rows: string; - /** - * Sets or retrieves the frame widths of the object. - */ - cols: string; - /** - * Fires when the object loses the input focus. - */ - onblur: (ev: FocusEvent) => any; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Fires when the object receives focus. - */ - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - onerror: (ev: Event) => any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - onresize: (ev: UIEvent) => any; - name: string; - onafterprint: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - onoffline: (ev: Event) => any; - border: string; - onunload: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onload: (ev: Event) => any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onstorage: (ev: StorageEvent) => any; -} -declare var HTMLFrameSetElement: { - prototype: HTMLFrameSetElement; - new (): HTMLFrameSetElement; -} - -interface Screen { - width: number; - deviceXDPI: number; - fontSmoothingEnabled: boolean; - bufferDepth: number; - logicalXDPI: number; - systemXDPI: number; - availHeight: number; - height: number; - logicalYDPI: number; - systemYDPI: number; - updateInterval: number; - colorDepth: number; - availWidth: number; - deviceYDPI: number; - pixelDepth: number; -} -declare var Screen: { - prototype: Screen; - new (): Screen; -} - -interface Coordinates { - altitudeAccuracy: number; - longitude: number; - latitude: number; - speed: number; - heading: number; - altitude: number; - accuracy: number; -} -declare var Coordinates: { - prototype: Coordinates; - new (): Coordinates; -} - -interface NavigatorGeolocation { - geolocation: Geolocation; -} - -interface NavigatorContentUtils { -} - -interface EventListener { - (evt: Event): void; -} - -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface DataTransfer { - effectAllowed: string; - dropEffect: string; - clearData(format?: string): boolean; - setData(format: string, data: string): boolean; - getData(format: string): string; -} -declare var DataTransfer: { - prototype: DataTransfer; - new (): DataTransfer; -} - -interface FocusEvent extends UIEvent { - relatedTarget: EventTarget; - initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; -} -declare var FocusEvent: { - prototype: FocusEvent; - new (): FocusEvent; -} - -interface Range { - startOffset: number; - collapsed: boolean; - endOffset: number; - startContainer: Node; - endContainer: Node; - commonAncestorContainer: Node; - setStart(refNode: Node, offset: number): void; - setEndBefore(refNode: Node): void; - setStartBefore(refNode: Node): void; - selectNode(refNode: Node): void; - detach(): void; - getBoundingClientRect(): ClientRect; - toString(): string; - compareBoundaryPoints(how: number, sourceRange: Range): number; - insertNode(newNode: Node): void; - collapse(toStart: boolean): void; - selectNodeContents(refNode: Node): void; - cloneContents(): DocumentFragment; - setEnd(refNode: Node, offset: number): void; - cloneRange(): Range; - getClientRects(): ClientRectList; - surroundContents(newParent: Node): void; - deleteContents(): void; - setStartAfter(refNode: Node): void; - extractContents(): DocumentFragment; - setEndAfter(refNode: Node): void; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} -declare var Range: { - prototype: Range; - new (): Range; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} - -interface SVGPoint { - y: number; - x: number; - matrixTransform(matrix: SVGMatrix): SVGPoint; -} -declare var SVGPoint: { - prototype: SVGPoint; - new (): SVGPoint; -} - -interface MSPluginsCollection { - length: number; - refresh(reload?: boolean): void; -} -declare var MSPluginsCollection: { - prototype: MSPluginsCollection; - new (): MSPluginsCollection; -} - -interface SVGAnimatedNumberList { - animVal: SVGNumberList; - baseVal: SVGNumberList; -} -declare var SVGAnimatedNumberList: { - prototype: SVGAnimatedNumberList; - new (): SVGAnimatedNumberList; -} - -interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { - width: SVGAnimatedLength; - x: SVGAnimatedLength; - contentStyleType: string; - onzoom: (ev: any) => any; - y: SVGAnimatedLength; - viewport: SVGRect; - onerror: (ev: Event) => any; - pixelUnitToMillimeterY: number; - onresize: (ev: UIEvent) => any; - screenPixelToMillimeterY: number; - height: SVGAnimatedLength; - onabort: (ev: UIEvent) => any; - contentScriptType: string; - pixelUnitToMillimeterX: number; - currentTranslate: SVGPoint; - onunload: (ev: Event) => any; - currentScale: number; - onscroll: (ev: UIEvent) => any; - screenPixelToMillimeterX: number; - setCurrentTime(seconds: number): void; - createSVGLength(): SVGLength; - getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; - unpauseAnimations(): void; - createSVGRect(): SVGRect; - checkIntersection(element: SVGElement, rect: SVGRect): boolean; - unsuspendRedrawAll(): void; - pauseAnimations(): void; - suspendRedraw(maxWaitMilliseconds: number): number; - deselectAll(): void; - createSVGAngle(): SVGAngle; - getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; - createSVGTransform(): SVGTransform; - unsuspendRedraw(suspendHandleID: number): void; - forceRedraw(): void; - getCurrentTime(): number; - checkEnclosure(element: SVGElement, rect: SVGRect): boolean; - createSVGMatrix(): SVGMatrix; - createSVGPoint(): SVGPoint; - createSVGNumber(): SVGNumber; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; - getElementById(elementId: string): Element; -} -declare var SVGSVGElement: { - prototype: SVGSVGElement; - new (): SVGSVGElement; -} - -interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the object to which the given label object is assigned. - */ - htmlFor: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLabelElement: { - prototype: HTMLLabelElement; - new (): HTMLLabelElement; -} - -interface MSResourceMetadata { - protocol: string; - fileSize: string; - fileUpdatedDate: string; - nameProp: string; - fileCreatedDate: string; - fileModifiedDate: string; - mimeType: string; -} - -interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLegendElement: { - prototype: HTMLLegendElement; - new (): HTMLLegendElement; -} - -interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLDirectoryElement: { - prototype: HTMLDirectoryElement; - new (): HTMLDirectoryElement; -} - -interface SVGAnimatedInteger { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedInteger: { - prototype: SVGAnimatedInteger; - new (): SVGAnimatedInteger; -} - -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { -} -declare var SVGTextElement: { - prototype: SVGTextElement; - new (): SVGTextElement; -} - -interface SVGTSpanElement extends SVGTextPositioningElement { -} -declare var SVGTSpanElement: { - prototype: SVGTSpanElement; - new (): SVGTSpanElement; -} - -interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * Sets or retrieves the value of a list item. - */ - value: number; -} -declare var HTMLLIElement: { - prototype: HTMLLIElement; - new (): HTMLLIElement; -} - -interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalAbs: { - prototype: SVGPathSegLinetoVerticalAbs; - new (): SVGPathSegLinetoVerticalAbs; -} - -interface MSStorageExtensions { - remainingSpace: number; -} - -interface SVGStyleElement extends SVGElement, SVGLangSpace { - media: string; - type: string; - title: string; -} -declare var SVGStyleElement: { - prototype: SVGStyleElement; - new (): SVGStyleElement; -} - -interface MSCurrentStyleCSSProperties extends MSCSSProperties { - blockDirection: string; - clipBottom: string; - clipLeft: string; - clipRight: string; - clipTop: string; - hasLayout: string; -} -declare var MSCurrentStyleCSSProperties: { - prototype: MSCurrentStyleCSSProperties; - new (): MSCurrentStyleCSSProperties; -} - -interface MSHTMLCollectionExtensions { - urns(urn: any): Object; - tags(tagName: any): Object; -} - -interface Storage extends MSStorageExtensions { - length: number; - getItem(key: string): any; - [key: string]: any; - setItem(key: string, data: string): void; - clear(): void; - removeItem(key: string): void; - key(index: number): string; - [index: number]: any; -} -declare var Storage: { - prototype: Storage; - new (): Storage; -} - -interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Sets or retrieves the horizontal margin for the object. - */ - hspace: number; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; - /** - * Raised when the object has been completely received from the server. - */ - onload: (ev: Event) => any; -} -declare var HTMLIFrameElement: { - prototype: HTMLIFrameElement; - new (): HTMLIFrameElement; -} - -interface TextRangeCollection { - length: number; - item(index: number): TextRange; - [index: number]: TextRange; -} -declare var TextRangeCollection: { - prototype: TextRangeCollection; - new (): TextRangeCollection; -} - -interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - scroll: string; - ononline: (ev: Event) => any; - onblur: (ev: FocusEvent) => any; - noWrap: boolean; - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - text: any; - onerror: (ev: Event) => any; - bgProperties: string; - onresize: (ev: UIEvent) => any; - link: any; - aLink: any; - bottomMargin: any; - topMargin: any; - onafterprint: (ev: Event) => any; - vLink: any; - onbeforeprint: (ev: Event) => any; - onoffline: (ev: Event) => any; - onunload: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onload: (ev: Event) => any; - rightMargin: any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - leftMargin: any; - onstorage: (ev: StorageEvent) => any; - createTextRange(): TextRange; -} -declare var HTMLBodyElement: { - prototype: HTMLBodyElement; - new (): HTMLBodyElement; -} - -interface DocumentType extends Node { - name: string; - notations: NamedNodeMap; - systemId: string; - internalSubset: string; - entities: NamedNodeMap; - publicId: string; -} -declare var DocumentType: { - prototype: DocumentType; - new (): DocumentType; -} - -interface SVGRadialGradientElement extends SVGGradientElement { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; - fx: SVGAnimatedLength; - fy: SVGAnimatedLength; -} -declare var SVGRadialGradientElement: { - prototype: SVGRadialGradientElement; - new (): SVGRadialGradientElement; -} - -interface MutationEvent extends Event { - newValue: string; - attrChange: number; - attrName: string; - prevValue: string; - relatedNode: Node; - initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} -declare var MutationEvent: { - prototype: MutationEvent; - new (): MutationEvent; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} - -interface DragEvent extends MouseEvent { - dataTransfer: DataTransfer; - initDragEvent(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, dataTransferArg: DataTransfer): void; -} -declare var DragEvent: { - prototype: DragEvent; - new (): DragEvent; -} - -interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): Object; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; -} -declare var HTMLTableSectionElement: { - prototype: HTMLTableSectionElement; - new (): HTMLTableSectionElement; -} - -interface DOML2DeprecatedListNumberingAndBulletStyle { - type: string; -} - -interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - status: boolean; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - indeterminate: boolean; - readOnly: boolean; - size: number; - loop: number; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. - */ - vrml: string; - /** - * Sets or retrieves a lower resolution image to display. - */ - lowsrc: string; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Sets or retrieves a comma-separated list of content types. - */ - accept: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - defaultChecked: boolean; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Returns the value of the data at the cursor's current position. - */ - value: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - dynsrc: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - checked: boolean; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - start: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Makes the selection equal to the current object. - */ - select(): void; -} -declare var HTMLInputElement: { - prototype: HTMLInputElement; - new (): HTMLInputElement; -} - -interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Contains the protocol of the URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Contains the hostname of a URL. - */ - hostname: string; - /** - * Contains the pathname of the URL. - */ - pathname: string; - Methods: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - protocolLong: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Contains the hostname and port values of the URL. - */ - host: string; - /** - * Contains the anchor portion of the URL including the hash sign (#). - */ - hash: string; - nameProp: string; - urn: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - type: string; - mimeType: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAnchorElement: { - prototype: HTMLAnchorElement; - new (): HTMLAnchorElement; -} - -interface HTMLParamElement extends HTMLElement { - /** - * Sets or retrieves the value of an input parameter for an element. - */ - value: string; - /** - * Sets or retrieves the name of an input parameter for an element. - */ - name: string; - /** - * Sets or retrieves the content type of the resource designated by the value attribute. - */ - type: string; - /** - * Sets or retrieves the data type of the value attribute. - */ - valueType: string; -} -declare var HTMLParamElement: { - prototype: HTMLParamElement; - new (): HTMLParamElement; -} - -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGImageElement: { - prototype: SVGImageElement; - new (): SVGImageElement; -} - -interface SVGAnimatedNumber { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedNumber: { - prototype: SVGAnimatedNumber; - new (): SVGAnimatedNumber; -} - -interface PerformanceTiming { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - msFirstPaint: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - toJSON(): any; -} -declare var PerformanceTiming: { - prototype: PerformanceTiming; - new (): PerformanceTiming; -} - -interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or gets a value that you can use to implement your own width functionality for the object. - */ - width: number; - /** - * Indicates a citation by rendering text in italic type. - */ - cite: string; -} -declare var HTMLPreElement: { - prototype: HTMLPreElement; - new (): HTMLPreElement; -} - -interface EventException { - code: number; - message: string; - toString(): string; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} -declare var EventException: { - prototype: EventException; - new (): EventException; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} - -interface MSNavigatorDoNotTrack { - msDoNotTrack: string; -} - -interface NavigatorOnLine { - onLine: boolean; -} - -interface WindowLocalStorage { - localStorage: Storage; -} - -interface SVGMetadataElement extends SVGElement { -} -declare var SVGMetadataElement: { - prototype: SVGMetadataElement; - new (): SVGMetadataElement; -} - -interface SVGPathSegArcRel extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcRel: { - prototype: SVGPathSegArcRel; - new (): SVGPathSegArcRel; -} - -interface SVGPathSegMovetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoAbs: { - prototype: SVGPathSegMovetoAbs; - new (): SVGPathSegMovetoAbs; -} - -interface SVGStringList { - numberOfItems: number; - replaceItem(newItem: string, index: number): string; - getItem(index: number): string; - clear(): void; - appendItem(newItem: string): string; - initialize(newItem: string): string; - removeItem(index: number): string; - insertItemBefore(newItem: string, index: number): string; -} -declare var SVGStringList: { - prototype: SVGStringList; - new (): SVGStringList; -} - -interface XDomainRequest { - timeout: number; - onerror: (ev: Event) => any; - onload: (ev: Event) => any; - onprogress: (ev: any) => any; - ontimeout: (ev: Event) => any; - responseText: string; - contentType: string; - open(method: string, url: string): void; - create(): XDomainRequest; - abort(): void; - send(data?: any): void; -} -declare var XDomainRequest: { - prototype: XDomainRequest; - new (): XDomainRequest; -} - -interface DOML2DeprecatedBackgroundColorStyle { - bgColor: any; -} - -interface ElementTraversal { - childElementCount: number; - previousElementSibling: Element; - lastElementChild: Element; - nextElementSibling: Element; - firstElementChild: Element; -} - -interface SVGLength { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} -declare var SVGLength: { - prototype: SVGLength; - new (): SVGLength; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} - -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolygonElement: { - prototype: SVGPolygonElement; - new (): SVGPolygonElement; -} - -interface HTMLPhraseElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLPhraseElement: { - prototype: HTMLPhraseElement; - new (): HTMLPhraseElement; -} - -interface NavigatorStorageUtils { -} - -interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicRel: { - prototype: SVGPathSegCurvetoCubicRel; - new (): SVGPathSegCurvetoCubicRel; -} - -interface MSEventObj extends Event { - nextPage: string; - keyCode: number; - toElement: Element; - returnValue: any; - dataFld: string; - y: number; - dataTransfer: DataTransfer; - propertyName: string; - url: string; - offsetX: number; - recordset: Object; - screenX: number; - buttonID: number; - wheelDelta: number; - reason: number; - origin: string; - data: string; - srcFilter: Object; - boundElements: HTMLCollection; - cancelBubble: boolean; - altLeft: boolean; - behaviorCookie: number; - bookmarks: BookmarkCollection; - type: string; - repeat: boolean; - srcElement: Element; - source: Window; - fromElement: Element; - offsetY: number; - x: number; - behaviorPart: number; - qualifier: string; - altKey: boolean; - ctrlKey: boolean; - clientY: number; - shiftKey: boolean; - shiftLeft: boolean; - contentOverflow: boolean; - screenY: number; - ctrlLeft: boolean; - button: number; - srcUrn: string; - clientX: number; - actionURL: string; - getAttribute(strAttributeName: string, lFlags?: number): any; - setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; - removeAttribute(strAttributeName: string, lFlags?: number): boolean; -} -declare var MSEventObj: { - prototype: MSEventObj; - new (): MSEventObj; -} - -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - textLength: SVGAnimatedLength; - lengthAdjust: SVGAnimatedEnumeration; - getCharNumAtPosition(point: SVGPoint): number; - getStartPositionOfChar(charnum: number): SVGPoint; - getExtentOfChar(charnum: number): SVGRect; - getComputedTextLength(): number; - getSubStringLength(charnum: number, nchars: number): number; - selectSubString(charnum: number, nchars: number): void; - getNumberOfChars(): number; - getRotationOfChar(charnum: number): number; - getEndPositionOfChar(charnum: number): SVGPoint; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} -declare var SVGTextContentElement: { - prototype: SVGTextContentElement; - new (): SVGTextContentElement; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} - -interface DOML2DeprecatedColorProperty { - color: string; -} - -interface HTMLCanvasElement extends HTMLElement { - /** - * Gets or sets the width of a canvas element on a document. - */ - width: number; - /** - * Gets or sets the height of a canvas element on a document. - */ - height: number; - /** - * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. - * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. - * @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: { - prototype: HTMLCanvasElement; - new (): HTMLCanvasElement; -} - -interface Location { - hash: string; - protocol: string; - search: string; - href: string; - hostname: string; - port: string; - pathname: string; - host: string; - reload(flag?: boolean): void; - replace(url: string): void; - assign(url: string): void; - toString(): string; -} -declare var Location: { - prototype: Location; - new (): Location; -} - -interface HTMLTitleElement extends HTMLElement { - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; -} -declare var HTMLTitleElement: { - prototype: HTMLTitleElement; - new (): HTMLTitleElement; -} - -interface HTMLStyleElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Retrieves the CSS language in which the style sheet is written. - */ - type: string; -} -declare var HTMLStyleElement: { - prototype: HTMLStyleElement; - new (): HTMLStyleElement; -} - -interface PerformanceEntry { - name: string; - startTime: number; - duration: number; - entryType: string; -} -declare var PerformanceEntry: { - prototype: PerformanceEntry; - new (): PerformanceEntry; -} - -interface SVGTransform { - type: number; - angle: number; - matrix: SVGMatrix; - setTranslate(tx: number, ty: number): void; - setScale(sx: number, sy: number): void; - setMatrix(matrix: SVGMatrix): void; - setSkewY(angle: number): void; - setRotate(angle: number, cx: number, cy: number): void; - setSkewX(angle: number): void; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} -declare var SVGTransform: { - prototype: SVGTransform; - new (): SVGTransform; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} - -interface UIEvent extends Event { - detail: number; - view: Window; - initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; -} -declare var UIEvent: { - prototype: UIEvent; - new (): UIEvent; -} - -interface SVGURIReference { - href: SVGAnimatedString; -} - -interface SVGPathSeg { - pathSegType: number; - pathSegTypeAsLetter: string; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} -declare var SVGPathSeg: { - prototype: SVGPathSeg; - new (): SVGPathSeg; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} - -interface WheelEvent extends MouseEvent { - deltaZ: number; - deltaX: number; - deltaMode: number; - deltaY: number; - initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} -declare var WheelEvent: { - prototype: WheelEvent; - new (): WheelEvent; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} - -interface MSEventAttachmentTarget { - attachEvent(event: string, listener: EventListener): boolean; - detachEvent(event: string, listener: EventListener): void; -} - -interface SVGNumber { - value: number; -} -declare var SVGNumber: { - prototype: SVGNumber; - new (): SVGNumber; -} - -interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - getPathSegAtLength(distance: number): number; - getPointAtLength(distance: number): SVGPoint; - createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; - createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; - createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; - createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; - createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; - createSVGPathSegClosePath(): SVGPathSegClosePath; - createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; - createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; - createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; - createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; - createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; - createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; - createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; - createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; - createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; - getTotalLength(): number; - createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; - createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; - createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; - createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; -} -declare var SVGPathElement: { - prototype: SVGPathElement; - new (): SVGPathElement; -} - -interface MSCompatibleInfo { - version: string; - userAgent: string; -} -declare var MSCompatibleInfo: { - prototype: MSCompatibleInfo; - new (): MSCompatibleInfo; -} - -interface Text extends CharacterData, MSNodeExtensions { - wholeText: string; - splitText(offset: number): Text; - replaceWholeText(content: string): Text; -} -declare var Text: { - prototype: Text; - new (): Text; -} - -interface SVGAnimatedRect { - animVal: SVGRect; - baseVal: SVGRect; -} -declare var SVGAnimatedRect: { - prototype: SVGAnimatedRect; - new (): SVGAnimatedRect; -} - -interface CSSNamespaceRule extends CSSRule { - namespaceURI: string; - prefix: string; -} -declare var CSSNamespaceRule: { - prototype: CSSNamespaceRule; - new (): CSSNamespaceRule; -} - -interface SVGPathSegList { - numberOfItems: number; - replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; - getItem(index: number): SVGPathSeg; - clear(): void; - appendItem(newItem: SVGPathSeg): SVGPathSeg; - initialize(newItem: SVGPathSeg): SVGPathSeg; - removeItem(index: number): SVGPathSeg; - insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; -} -declare var SVGPathSegList: { - prototype: SVGPathSegList; - new (): SVGPathSegList; -} - -interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { -} -declare var HTMLUnknownElement: { - prototype: HTMLUnknownElement; - new (): HTMLUnknownElement; -} - -interface HTMLAudioElement extends HTMLMediaElement { -} -declare var HTMLAudioElement: { - prototype: HTMLAudioElement; - new (): HTMLAudioElement; -} - -interface MSImageResourceExtensions { - dynsrc: string; - vrml: string; - lowsrc: string; - start: string; - loop: number; -} - -interface PositionError { - code: number; - message: string; - toString(): string; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} -declare var PositionError: { - prototype: PositionError; - new (): PositionError; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} - -interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves a list of header cells that provide information for the object. - */ - headers: string; - /** - * Retrieves the position of the object in the cells collection of a row. - */ - cellIndex: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the number columns in the table that the object should span. - */ - colSpan: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. - */ - axis: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; - /** - * Sets or retrieves abbreviated text for the object. - */ - abbr: string; - /** - * Sets or retrieves how many rows in a table the cell should span. - */ - rowSpan: number; - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; -} -declare var HTMLTableCellElement: { - prototype: HTMLTableCellElement; - new (): HTMLTableCellElement; -} - -interface SVGElementInstance extends EventTarget { - previousSibling: SVGElementInstance; - parentNode: SVGElementInstance; - lastChild: SVGElementInstance; - nextSibling: SVGElementInstance; - childNodes: SVGElementInstanceList; - correspondingUseElement: SVGUseElement; - correspondingElement: SVGElement; - firstChild: SVGElementInstance; -} -declare var SVGElementInstance: { - prototype: SVGElementInstance; - new (): SVGElementInstance; -} - -interface MSNamespaceInfoCollection { - length: number; - add(namespace?: string, urn?: string, implementationUrl?: any): Object; - item(index: any): Object; - [index: string]: Object; -} -declare var MSNamespaceInfoCollection: { - prototype: MSNamespaceInfoCollection; - new (): MSNamespaceInfoCollection; -} - -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGCircleElement: { - prototype: SVGCircleElement; - new (): SVGCircleElement; -} - -interface StyleSheetList { - length: number; - item(index?: number): StyleSheet; - [index: number]: StyleSheet; -} -declare var StyleSheetList: { - prototype: StyleSheetList; - new (): StyleSheetList; -} - -interface CSSImportRule extends CSSRule { - styleSheet: CSSStyleSheet; - href: string; - media: MediaList; -} -declare var CSSImportRule: { - prototype: CSSImportRule; - new (): CSSImportRule; -} - -interface CustomEvent extends Event { - detail: any; - initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; -} -declare var CustomEvent: { - prototype: CustomEvent; - new (): CustomEvent; -} - -interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; - /** - * Sets or retrieves the font size of the object. - */ - size: number; -} -declare var HTMLBaseFontElement: { - prototype: HTMLBaseFontElement; - new (): HTMLBaseFontElement; -} - -interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves or sets the text in the entry field of the textArea element. - */ - value: string; - /** - * Sets or retrieves the value indicating whether the control is selected. - */ - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: number; - /** - * Sets or retrieves the width of the object. - */ - cols: number; - /** - * Sets or retrieves the value indicated whether the content of the object is read-only. - */ - readOnly: boolean; - /** - * Sets or retrieves how to handle wordwrapping in the object. - */ - wrap: string; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Retrieves the type of control. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Highlights the input area of a form element. - */ - select(): void; -} -declare var HTMLTextAreaElement: { - prototype: HTMLTextAreaElement; - new (): HTMLTextAreaElement; -} - -interface Geolocation { - clearWatch(watchId: number): void; - getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; - watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; -} -declare var Geolocation: { - prototype: Geolocation; - new (): Geolocation; -} - -interface DOML2DeprecatedMarginStyle { - vspace: number; - hspace: number; -} - -interface MSWindowModeless { - dialogTop: any; - dialogLeft: any; - dialogWidth: any; - dialogHeight: any; - menuArguments: any; -} - -interface DOML2DeprecatedAlignmentStyle { - align: string; -} - -interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { - width: string; - onbounce: (ev: Event) => any; - vspace: number; - trueSpeed: boolean; - scrollAmount: number; - scrollDelay: number; - behavior: string; - height: string; - loop: number; - direction: string; - hspace: number; - onstart: (ev: Event) => any; - onfinish: (ev: Event) => any; - stop(): void; - start(): void; -} -declare var HTMLMarqueeElement: { - prototype: HTMLMarqueeElement; - new (): HTMLMarqueeElement; -} - -interface SVGRect { - y: number; - width: number; - x: number; - height: number; -} -declare var SVGRect: { - prototype: SVGRect; - new (): SVGRect; -} - -interface MSNodeExtensions { - swapNode(otherNode: Node): Node; - removeNode(deep?: boolean): Node; - replaceNode(replacement: Node): Node; -} - -interface History { - length: number; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; -} -declare var History: { - prototype: History; - new (): History; -} - -interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicAbs: { - prototype: SVGPathSegCurvetoCubicAbs; - new (): SVGPathSegCurvetoCubicAbs; -} - -interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticAbs: { - prototype: SVGPathSegCurvetoQuadraticAbs; - new (): SVGPathSegCurvetoQuadraticAbs; -} - -interface TimeRanges { - length: number; - start(index: number): number; - end(index: number): number; -} -declare var TimeRanges: { - prototype: TimeRanges; - new (): TimeRanges; -} - -interface CSSRule { - cssText: string; - parentStyleSheet: CSSStyleSheet; - parentRule: CSSRule; - type: number; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} -declare var CSSRule: { - prototype: CSSRule; - new (): CSSRule; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} - -interface SVGPathSegLinetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoAbs: { - prototype: SVGPathSegLinetoAbs; - new (): SVGPathSegLinetoAbs; -} - -interface HTMLModElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLModElement: { - prototype: HTMLModElement; - new (): HTMLModElement; -} - -interface SVGMatrix { - e: number; - c: number; - a: number; - b: number; - d: number; - f: number; - multiply(secondMatrix: SVGMatrix): SVGMatrix; - flipY(): SVGMatrix; - skewY(angle: number): SVGMatrix; - inverse(): SVGMatrix; - scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; - rotate(angle: number): SVGMatrix; - flipX(): SVGMatrix; - translate(x: number, y: number): SVGMatrix; - scale(scaleFactor: number): SVGMatrix; - rotateFromVector(x: number, y: number): SVGMatrix; - skewX(angle: number): SVGMatrix; -} -declare var SVGMatrix: { - prototype: SVGMatrix; - new (): SVGMatrix; -} - -interface MSPopupWindow { - document: Document; - isOpen: boolean; - show(x: number, y: number, w: number, h: number, element?: any): void; - hide(): void; -} -declare var MSPopupWindow: { - prototype: MSPopupWindow; - new (): MSPopupWindow; -} - -interface BeforeUnloadEvent extends Event { - returnValue: string; -} -declare var BeforeUnloadEvent: { - prototype: BeforeUnloadEvent; - new (): BeforeUnloadEvent; -} - -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - animatedInstanceRoot: SVGElementInstance; - instanceRoot: SVGElementInstance; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGUseElement: { - prototype: SVGUseElement; - new (): SVGUseElement; -} - -interface Event { - timeStamp: number; - defaultPrevented: boolean; - isTrusted: boolean; - currentTarget: EventTarget; - cancelBubble: boolean; - target: EventTarget; - eventPhase: number; - cancelable: boolean; - type: string; - srcElement: Element; - bubbles: boolean; - initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; - stopPropagation(): void; - stopImmediatePropagation(): void; - preventDefault(): void; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} -declare var Event: { - prototype: Event; - new (): Event; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} - -interface ImageData { - width: number; - data: Uint8Array; - height: number; -} -declare var ImageData: { - prototype: ImageData; - new (): ImageData; -} - -interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves the alignment of the object relative to the display or table. - */ - align: string; - /** - * Sets or retrieves the number of columns in the group. - */ - span: number; -} -declare var HTMLTableColElement: { - prototype: HTMLTableColElement; - new (): HTMLTableColElement; -} - -interface SVGException { - code: number; - message: string; - toString(): string; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} -declare var SVGException: { - prototype: SVGException; - new (): SVGException; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} - -interface SVGLinearGradientElement extends SVGGradientElement { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLinearGradientElement: { - prototype: SVGLinearGradientElement; - new (): SVGLinearGradientElement; -} - -interface HTMLTableAlignment { - /** - * Sets or retrieves a value that you can use to implement your own ch functionality for the object. - */ - ch: string; - /** - * Sets or retrieves how text and other content are vertically aligned within the object that contains them. - */ - vAlign: string; - /** - * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. - */ - chOff: string; -} - -interface SVGAnimatedEnumeration { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedEnumeration: { - prototype: SVGAnimatedEnumeration; - new (): SVGAnimatedEnumeration; -} - -interface DOML2DeprecatedSizeProperty { - size: number; -} - -interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLUListElement: { - prototype: HTMLUListElement; - new (): HTMLUListElement; -} - -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - ry: SVGAnimatedLength; - rx: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGRectElement: { - prototype: SVGRectElement; - new (): SVGRectElement; -} - -interface ErrorEventHandler { - (event: Event, source: string, fileno: number, columnNumber: number): void; - (message: any, uri: string, lineNumber: number, columnNumber?: number): void; -} - -interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDivElement: { - prototype: HTMLDivElement; - new (): HTMLDivElement; -} - -interface DOML2DeprecatedBorderStyle { - border: string; -} - -interface NamedNodeMap { - length: number; - removeNamedItemNS(namespaceURI: string, localName: string): Attr; - item(index: number): Attr; - [index: number]: Attr; - removeNamedItem(name: string): Attr; - getNamedItem(name: string): Attr; - setNamedItem(arg: Attr): Attr; - getNamedItemNS(namespaceURI: string, localName: string): Attr; - setNamedItemNS(arg: Attr): Attr; -} -declare var NamedNodeMap: { - prototype: NamedNodeMap; - new (): NamedNodeMap; -} - -interface MediaList { - length: number; - mediaText: string; - deleteMedium(oldMedium: string): void; - appendMedium(newMedium: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var MediaList: { - prototype: MediaList; - new (): MediaList; -} - -interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothAbs: { - prototype: SVGPathSegCurvetoQuadraticSmoothAbs; - new (): SVGPathSegCurvetoQuadraticSmoothAbs; -} - -interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothRel: { - prototype: SVGPathSegCurvetoCubicSmoothRel; - new (): SVGPathSegCurvetoCubicSmoothRel; -} - -interface SVGLengthList { - numberOfItems: number; - replaceItem(newItem: SVGLength, index: number): SVGLength; - getItem(index: number): SVGLength; - clear(): void; - appendItem(newItem: SVGLength): SVGLength; - initialize(newItem: SVGLength): SVGLength; - removeItem(index: number): SVGLength; - insertItemBefore(newItem: SVGLength, index: number): SVGLength; -} -declare var SVGLengthList: { - prototype: SVGLengthList; - new (): SVGLengthList; -} - -interface ProcessingInstruction extends Node { - target: string; - data: string; -} -declare var ProcessingInstruction: { - prototype: ProcessingInstruction; - new (): ProcessingInstruction; -} - -interface MSWindowExtensions { - status: string; - onmouseleave: (ev: MouseEvent) => any; - screenLeft: number; - offscreenBuffering: any; - maxConnectionsPerServer: number; - onmouseenter: (ev: MouseEvent) => any; - clipboardData: DataTransfer; - defaultStatus: string; - clientInformation: Navigator; - closed: boolean; - onhelp: (ev: Event) => any; - external: External; - event: MSEventObj; - onfocusout: (ev: FocusEvent) => any; - screenTop: number; - onfocusin: (ev: FocusEvent) => any; - showModelessDialog(url?: string, argument?: any, options?: any): Window; - navigate(url: string): void; - resizeBy(x?: number, y?: number): void; - item(index: any): any; - resizeTo(x?: number, y?: number): void; - createPopup(arguments?: any): MSPopupWindow; - toStaticHTML(html: string): string; - execScript(code: string, language?: string): any; - msWriteProfilerMark(profilerMarkName: string): void; - moveTo(x?: number, y?: number): void; - moveBy(x?: number, y?: number): void; - showHelp(url: string, helpArg?: any, features?: string): void; -} - -interface MSBehaviorUrnsCollection { - length: number; - item(index: number): string; -} -declare var MSBehaviorUrnsCollection: { - prototype: MSBehaviorUrnsCollection; - new (): MSBehaviorUrnsCollection; -} - -interface CSSFontFaceRule extends CSSRule { - style: CSSStyleDeclaration; -} -declare var CSSFontFaceRule: { - prototype: CSSFontFaceRule; - new (): CSSFontFaceRule; -} - -interface DOML2DeprecatedBackgroundStyle { - background: string; -} - -interface TextEvent extends UIEvent { - inputMethod: number; - data: string; - locale: string; - initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} -declare var TextEvent: { - prototype: TextEvent; - new (): TextEvent; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} - -interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { -} -declare var DocumentFragment: { - prototype: DocumentFragment; - new (): DocumentFragment; -} - -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolylineElement: { - prototype: SVGPolylineElement; - new (): SVGPolylineElement; -} - -interface SVGAnimatedPathData { - pathSegList: SVGPathSegList; -} - -interface Position { - timestamp: number; - coords: Coordinates; -} -declare var Position: { - prototype: Position; - new (): Position; -} - -interface BookmarkCollection { - length: number; - item(index: number): any; - [index: number]: any; -} -declare var BookmarkCollection: { - prototype: BookmarkCollection; - new (): BookmarkCollection; -} - -interface PerformanceMark extends PerformanceEntry { -} -declare var PerformanceMark: { - prototype: PerformanceMark; - new (): PerformanceMark; -} - -interface CSSPageRule extends CSSRule { - pseudoClass: string; - selectorText: string; - selector: string; - style: CSSStyleDeclaration; -} -declare var CSSPageRule: { - prototype: CSSPageRule; - new (): CSSPageRule; -} - -interface HTMLBRElement extends HTMLElement { - /** - * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. - */ - clear: string; -} -declare var HTMLBRElement: { - prototype: HTMLBRElement; - new (): HTMLBRElement; -} - -interface MSNavigatorExtensions { - userLanguage: string; - plugins: MSPluginsCollection; - cookieEnabled: boolean; - appCodeName: string; - cpuClass: string; - appMinorVersion: string; - connectionSpeed: number; - browserLanguage: string; - mimeTypes: MSMimeTypesCollection; - systemLanguage: string; - javaEnabled(): boolean; - taintEnabled(): boolean; -} - -interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { -} -declare var HTMLSpanElement: { - prototype: HTMLSpanElement; - new (): HTMLSpanElement; -} - -interface HTMLHeadElement extends HTMLElement { - profile: string; -} -declare var HTMLHeadElement: { - prototype: HTMLHeadElement; - new (): HTMLHeadElement; -} - -interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; -} -declare var HTMLHeadingElement: { - prototype: HTMLHeadingElement; - new (): HTMLHeadingElement; -} - -interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. - */ - acceptCharset: string; - /** - * Sets or retrieves the encoding type for the form. - */ - enctype: string; - /** - * Retrieves a collection, in source order, of all controls in a given form. - */ - elements: HTMLCollection; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves how to send the form data to the server. - */ - method: string; - /** - * Sets or retrieves the MIME encoding for the form. - */ - encoding: string; - /** - * Fires when the user resets a form. - */ - reset(): void; - /** - * Retrieves a form object or an object from an elements collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Fires when a FORM is about to be submitted. - */ - submit(): void; - /** - * Retrieves a form object or an object from an elements collection. - */ - namedItem(name: string): any; - [name: string]: any; -} -declare var HTMLFormElement: { - prototype: HTMLFormElement; - new (): HTMLFormElement; -} - -interface SVGZoomAndPan { - zoomAndPan: number; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} -declare var SVGZoomAndPan: { - prototype: SVGZoomAndPan; - new (): SVGZoomAndPan; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} - -interface HTMLMediaElement extends HTMLElement { - /** - * Gets the earliest possible position, in seconds, that the playback can begin. - */ - initialTime: number; - /** - * Gets TimeRanges for the current media resource that has been played. - */ - played: TimeRanges; - /** - * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. - */ - currentSrc: string; - readyState: any; - /** - * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. - */ - autobuffer: boolean; - /** - * Gets or sets a flag to specify whether playback should restart after it completes. - */ - loop: boolean; - /** - * Gets information about whether the playback has ended or not. - */ - ended: boolean; - /** - * Gets a collection of buffered time ranges. - */ - buffered: TimeRanges; - /** - * Returns an object representing the current error state of the audio or video element. - */ - error: MediaError; - /** - * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. - */ - seekable: TimeRanges; - /** - * Gets or sets a value that indicates whether to start playing the media automatically. - */ - autoplay: boolean; - /** - * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). - */ - controls: boolean; - /** - * Gets or sets the volume level for audio portions of the media element. - */ - volume: number; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. - */ - playbackRate: number; - /** - * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. - */ - duration: number; - /** - * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. - */ - muted: boolean; - /** - * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. - */ - defaultPlaybackRate: number; - /** - * Gets a flag that specifies whether playback is paused. - */ - paused: boolean; - /** - * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. - */ - seeking: boolean; - /** - * Gets or sets the current playback position, in seconds. - */ - currentTime: number; - /** - * Gets or sets the current playback position, in seconds. - */ - preload: string; - /** - * Gets the current network activity for the element. - */ - networkState: number; - /** - * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. - */ - pause(): void; - /** - * Loads and starts playback of a media resource. - */ - play(): void; - /** - * Fires immediately after the client loads the object. - */ - load(): void; - /** - * Returns a string that specifies whether the client can play a given media resource type. - */ - canPlayType(type: string): string; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} -declare var HTMLMediaElement: { - prototype: HTMLMediaElement; - new (): HTMLMediaElement; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} - -interface ElementCSSInlineStyle { - runtimeStyle: MSStyleCSSProperties; - currentStyle: MSCurrentStyleCSSProperties; - doScroll(component?: any): void; - componentFromPoint(x: number, y: number): string; -} - -interface DOMParser { - parseFromString(source: string, mimeType: string): Document; -} -declare var DOMParser: { - prototype: DOMParser; - new (): DOMParser; -} - -interface MSMimeTypesCollection { - length: number; -} -declare var MSMimeTypesCollection: { - prototype: MSMimeTypesCollection; - new (): MSMimeTypesCollection; -} - -interface StyleSheet { - disabled: boolean; - ownerNode: Node; - parentStyleSheet: StyleSheet; - href: string; - media: MediaList; - type: string; - title: string; -} -declare var StyleSheet: { - prototype: StyleSheet; - new (): StyleSheet; -} - -interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { - startOffset: SVGAnimatedLength; - method: SVGAnimatedEnumeration; - spacing: SVGAnimatedEnumeration; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} -declare var SVGTextPathElement: { - prototype: SVGTextPathElement; - new (): SVGTextPathElement; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} - -interface HTMLDTElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDTElement: { - prototype: HTMLDTElement; - new (): HTMLDTElement; -} - -interface NodeList { - length: number; - item(index: number): Node; - [index: number]: Node; -} -declare var NodeList: { - prototype: NodeList; - new (): NodeList; -} - -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - -interface XMLSerializer { - serializeToString(target: Node): string; -} -declare var XMLSerializer: { - prototype: XMLSerializer; - new (): XMLSerializer; -} - -interface PerformanceMeasure extends PerformanceEntry { -} -declare var PerformanceMeasure: { - prototype: PerformanceMeasure; - new (): PerformanceMeasure; -} - -interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { - spreadMethod: SVGAnimatedEnumeration; - gradientTransform: SVGAnimatedTransformList; - gradientUnits: SVGAnimatedEnumeration; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} -declare var SVGGradientElement: { - prototype: SVGGradientElement; - new (): SVGGradientElement; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} - -interface NodeFilter { - acceptNode(n: Node): number; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} -declare var NodeFilter: { - prototype: NodeFilter; - new (): NodeFilter; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} - -interface SVGNumberList { - numberOfItems: number; - replaceItem(newItem: SVGNumber, index: number): SVGNumber; - getItem(index: number): SVGNumber; - clear(): void; - appendItem(newItem: SVGNumber): SVGNumber; - initialize(newItem: SVGNumber): SVGNumber; - removeItem(index: number): SVGNumber; - insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; -} -declare var SVGNumberList: { - prototype: SVGNumberList; - new (): SVGNumberList; -} - -interface MediaError { - code: number; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} -declare var MediaError: { - prototype: MediaError; - new (): MediaError; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} - -interface HTMLFieldSetElement extends HTMLElement { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLFieldSetElement: { - prototype: HTMLFieldSetElement; - new (): HTMLFieldSetElement; -} - -interface HTMLBGSoundElement extends HTMLElement { - /** - * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. - */ - balance: any; - /** - * Sets or gets the volume setting for the sound. - */ - volume: any; - /** - * Sets or gets the URL of a sound to play. - */ - src: string; - /** - * Sets or retrieves the number of times a sound or video clip will loop when activated. - */ - loop: number; -} -declare var HTMLBGSoundElement: { - prototype: HTMLBGSoundElement; - new (): HTMLBGSoundElement; -} - -interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { - onmouseleave: (ev: MouseEvent) => any; - onbeforecut: (ev: DragEvent) => any; - onkeydown: (ev: KeyboardEvent) => any; - onmove: (ev: MSEventObj) => any; - onkeyup: (ev: KeyboardEvent) => any; - onreset: (ev: Event) => any; - onhelp: (ev: Event) => any; - ondragleave: (ev: DragEvent) => any; - className: string; - onfocusin: (ev: FocusEvent) => any; - onseeked: (ev: Event) => any; - recordNumber: any; - title: string; - parentTextEdit: Element; - outerHTML: string; - ondurationchange: (ev: Event) => any; - offsetHeight: number; - all: HTMLCollection; - onblur: (ev: FocusEvent) => any; - dir: string; - onemptied: (ev: Event) => any; - onseeking: (ev: Event) => any; - oncanplay: (ev: Event) => any; - ondeactivate: (ev: UIEvent) => any; - ondatasetchanged: (ev: MSEventObj) => any; - onrowsdelete: (ev: MSEventObj) => any; - sourceIndex: number; - onloadstart: (ev: Event) => any; - onlosecapture: (ev: MSEventObj) => any; - ondragenter: (ev: DragEvent) => any; - oncontrolselect: (ev: MSEventObj) => any; - onsubmit: (ev: Event) => any; - behaviorUrns: MSBehaviorUrnsCollection; - scopeName: string; - onchange: (ev: Event) => any; - id: string; - onlayoutcomplete: (ev: MSEventObj) => any; - uniqueID: string; - onbeforeactivate: (ev: UIEvent) => any; - oncanplaythrough: (ev: Event) => any; - onbeforeupdate: (ev: MSEventObj) => any; - onfilterchange: (ev: MSEventObj) => any; - offsetParent: Element; - ondatasetcomplete: (ev: MSEventObj) => any; - onsuspend: (ev: Event) => any; - readyState: any; - onmouseenter: (ev: MouseEvent) => any; - innerText: string; - onerrorupdate: (ev: MSEventObj) => any; - onmouseout: (ev: MouseEvent) => any; - parentElement: HTMLElement; - onmousewheel: (ev: MouseWheelEvent) => any; - onvolumechange: (ev: Event) => any; - oncellchange: (ev: MSEventObj) => any; - onrowexit: (ev: MSEventObj) => any; - onrowsinserted: (ev: MSEventObj) => any; - onpropertychange: (ev: MSEventObj) => any; - filters: Object; - children: HTMLCollection; - ondragend: (ev: DragEvent) => any; - onbeforepaste: (ev: DragEvent) => any; - ondragover: (ev: DragEvent) => any; - offsetTop: number; - onmouseup: (ev: MouseEvent) => any; - ondragstart: (ev: DragEvent) => any; - onbeforecopy: (ev: DragEvent) => any; - ondrag: (ev: DragEvent) => any; - innerHTML: string; - onmouseover: (ev: MouseEvent) => any; - lang: string; - uniqueNumber: number; - onpause: (ev: Event) => any; - tagUrn: string; - onmousedown: (ev: MouseEvent) => any; - onclick: (ev: MouseEvent) => any; - onwaiting: (ev: Event) => any; - onresizestart: (ev: MSEventObj) => any; - offsetLeft: number; - isTextEdit: boolean; - isDisabled: boolean; - onpaste: (ev: DragEvent) => any; - canHaveHTML: boolean; - onmoveend: (ev: MSEventObj) => any; - language: string; - onstalled: (ev: Event) => any; - onmousemove: (ev: MouseEvent) => any; - style: MSStyleCSSProperties; - isContentEditable: boolean; - onbeforeeditfocus: (ev: MSEventObj) => any; - onratechange: (ev: Event) => any; - contentEditable: string; - tabIndex: number; - document: Document; - onprogress: (ev: any) => any; - ondblclick: (ev: MouseEvent) => any; - oncontextmenu: (ev: MouseEvent) => any; - onloadedmetadata: (ev: Event) => any; - onafterupdate: (ev: MSEventObj) => any; - onerror: (ev: Event) => any; - onplay: (ev: Event) => any; - onresizeend: (ev: MSEventObj) => any; - onplaying: (ev: Event) => any; - isMultiLine: boolean; - onfocusout: (ev: FocusEvent) => any; - onabort: (ev: UIEvent) => any; - ondataavailable: (ev: MSEventObj) => any; - hideFocus: boolean; - onreadystatechange: (ev: Event) => any; - onkeypress: (ev: KeyboardEvent) => any; - onloadeddata: (ev: Event) => any; - onbeforedeactivate: (ev: UIEvent) => any; - outerText: string; - disabled: boolean; - onactivate: (ev: UIEvent) => any; - accessKey: string; - onmovestart: (ev: MSEventObj) => any; - onselectstart: (ev: Event) => any; - onfocus: (ev: FocusEvent) => any; - ontimeupdate: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - oncut: (ev: DragEvent) => any; - onselect: (ev: UIEvent) => any; - ondrop: (ev: DragEvent) => any; - offsetWidth: number; - oncopy: (ev: DragEvent) => any; - onended: (ev: Event) => any; - onscroll: (ev: UIEvent) => any; - onrowenter: (ev: MSEventObj) => any; - onload: (ev: Event) => any; - canHaveChildren: boolean; - oninput: (ev: Event) => any; - dragDrop(): boolean; - scrollIntoView(top?: boolean): void; - addFilter(filter: Object): void; - setCapture(containerCapture?: boolean): void; - focus(): void; - getAdjacentText(where: string): string; - insertAdjacentText(where: string, text: string): void; - getElementsByClassName(classNames: string): NodeList; - setActive(): void; - removeFilter(filter: Object): void; - blur(): void; - clearAttributes(): void; - releaseCapture(): void; - createControlRange(): ControlRangeCollection; - removeBehavior(cookie: number): boolean; - contains(child: HTMLElement): boolean; - click(): void; - insertAdjacentElement(position: string, insertedElement: Element): Element; - mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; - replaceAdjacentText(where: string, newText: string): string; - applyElement(apply: Element, where?: string): Element; - addBehavior(bstrUrl: string, factory?: any): number; - insertAdjacentHTML(where: string, html: string): void; -} -declare var HTMLElement: { - prototype: HTMLElement; - new (): HTMLElement; -} - -interface Comment extends CharacterData { - text: string; -} -declare var Comment: { - prototype: Comment; - new (): Comment; -} - -interface PerformanceResourceTiming extends PerformanceEntry { - redirectStart: number; - redirectEnd: number; - domainLookupEnd: number; - responseStart: number; - domainLookupStart: number; - fetchStart: number; - requestStart: number; - connectEnd: number; - connectStart: number; - initiatorType: string; - responseEnd: number; -} -declare var PerformanceResourceTiming: { - prototype: PerformanceResourceTiming; - new (): PerformanceResourceTiming; -} - -interface CanvasPattern { -} -declare var CanvasPattern: { - prototype: CanvasPattern; - new (): CanvasPattern; -} - -interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. - */ - noShade: boolean; -} -declare var HTMLHRElement: { - prototype: HTMLHRElement; - new (): HTMLHRElement; -} - -interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - /** - * Retrieves the contained object. - */ - object: Object; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL of the file containing the compiled Java class. - */ - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - declare: boolean; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; -} -declare var HTMLObjectElement: { - prototype: HTMLObjectElement; - new (): HTMLObjectElement; -} - -interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Retrieves the palette used for the embedded document. - */ - palette: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Retrieves the URL of the plug-in used to view an embedded document. - */ - pluginspage: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the height and width units of the embed object. - */ - units: string; -} -declare var HTMLEmbedElement: { - prototype: HTMLEmbedElement; - new (): HTMLEmbedElement; -} - -interface StorageEvent extends Event { - oldValue: any; - newValue: any; - url: string; - storageArea: Storage; - key: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; -} -declare var StorageEvent: { - prototype: StorageEvent; - new (): StorageEvent; -} - -interface CharacterData extends Node { - length: number; - data: string; - deleteData(offset: number, count: number): void; - replaceData(offset: number, count: number, arg: string): void; - appendData(arg: string): void; - insertData(offset: number, arg: string): void; - substringData(offset: number, count: number): string; -} -declare var CharacterData: { - prototype: CharacterData; - new (): CharacterData; -} - -interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; -} -declare var HTMLOptGroupElement: { - prototype: HTMLOptGroupElement; - new (): HTMLOptGroupElement; -} - -interface HTMLIsIndexElement extends HTMLElement { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - prompt: string; -} -declare var HTMLIsIndexElement: { - prototype: HTMLIsIndexElement; - new (): HTMLIsIndexElement; -} - -interface SVGPathSegLinetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoRel: { - prototype: SVGPathSegLinetoRel; - new (): SVGPathSegLinetoRel; -} - -interface DOMException { - code: number; - message: string; - toString(): string; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} -declare var DOMException: { - prototype: DOMException; - new (): DOMException; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} - -interface SVGAnimatedBoolean { - animVal: boolean; - baseVal: boolean; -} -declare var SVGAnimatedBoolean: { - prototype: SVGAnimatedBoolean; - new (): SVGAnimatedBoolean; -} - -interface MSCompatibleInfoCollection { - length: number; - item(index: number): MSCompatibleInfo; -} -declare var MSCompatibleInfoCollection: { - prototype: MSCompatibleInfoCollection; - new (): MSCompatibleInfoCollection; -} - -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGSwitchElement: { - prototype: SVGSwitchElement; - new (): SVGSwitchElement; -} - -interface SVGPreserveAspectRatio { - align: number; - meetOrSlice: number; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} -declare var SVGPreserveAspectRatio: { - prototype: SVGPreserveAspectRatio; - new (): SVGPreserveAspectRatio; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} - -interface Attr extends Node { - expando: boolean; - specified: boolean; - ownerElement: Element; - value: string; - name: string; -} -declare var Attr: { - prototype: Attr; - new (): Attr; -} - -interface PerformanceNavigation { - redirectCount: number; - type: number; - toJSON(): any; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} -declare var PerformanceNavigation: { - prototype: PerformanceNavigation; - new (): PerformanceNavigation; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} - -interface SVGStopElement extends SVGElement, SVGStylable { - offset: SVGAnimatedNumber; -} -declare var SVGStopElement: { - prototype: SVGStopElement; - new (): SVGStopElement; -} - -interface PositionCallback { - (position: Position): void; -} - -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { -} -declare var SVGSymbolElement: { - prototype: SVGSymbolElement; - new (): SVGSymbolElement; -} - -interface SVGElementInstanceList { - length: number; - item(index: number): SVGElementInstance; -} -declare var SVGElementInstanceList: { - prototype: SVGElementInstanceList; - new (): SVGElementInstanceList; -} - -interface CSSRuleList { - length: number; - item(index: number): CSSRule; - [index: number]: CSSRule; -} -declare var CSSRuleList: { - prototype: CSSRuleList; - new (): CSSRuleList; -} - -interface MSDataBindingRecordSetExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface LinkStyle { - styleSheet: StyleSheet; - sheet: StyleSheet; -} - -interface HTMLVideoElement extends HTMLMediaElement { - /** - * Gets or sets the width of the video element. - */ - width: number; - /** - * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoWidth: number; - /** - * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoHeight: number; - /** - * Gets or sets the height of the video element. - */ - height: number; - /** - * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. - */ - poster: string; -} -declare var HTMLVideoElement: { - prototype: HTMLVideoElement; - new (): HTMLVideoElement; -} - -interface ClientRectList { - length: number; - item(index: number): ClientRect; - [index: number]: ClientRect; -} -declare var ClientRectList: { - prototype: ClientRectList; - new (): ClientRectList; -} - -interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - maskUnits: SVGAnimatedEnumeration; - maskContentUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGMaskElement: { - prototype: SVGMaskElement; - new (): SVGMaskElement; -} - -interface External { -} -declare var External: { - prototype: External; - new (): External; -} - -declare var Audio: { new (src?: string): HTMLAudioElement; }; -declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; -declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; - -declare var ondragend: (ev: DragEvent) => any; -declare var onkeydown: (ev: KeyboardEvent) => any; -declare var ondragover: (ev: DragEvent) => any; -declare var onkeyup: (ev: KeyboardEvent) => any; -declare var onreset: (ev: Event) => any; -declare var onmouseup: (ev: MouseEvent) => any; -declare var ondragstart: (ev: DragEvent) => any; -declare var ondrag: (ev: DragEvent) => any; -declare var screenX: number; -declare var onmouseover: (ev: MouseEvent) => any; -declare var ondragleave: (ev: DragEvent) => any; -declare var history: History; -declare var pageXOffset: number; -declare var name: string; -declare var onafterprint: (ev: Event) => any; -declare var onpause: (ev: Event) => any; -declare var onbeforeprint: (ev: Event) => any; -declare var top: Window; -declare var onmousedown: (ev: MouseEvent) => any; -declare var onseeked: (ev: Event) => any; -declare var opener: Window; -declare var onclick: (ev: MouseEvent) => any; -declare var innerHeight: number; -declare var onwaiting: (ev: Event) => any; -declare var ononline: (ev: Event) => any; -declare var ondurationchange: (ev: Event) => any; -declare var frames: Window; -declare var onblur: (ev: FocusEvent) => any; -declare var onemptied: (ev: Event) => any; -declare var onseeking: (ev: Event) => any; -declare var oncanplay: (ev: Event) => any; -declare var outerWidth: number; -declare var onstalled: (ev: Event) => any; -declare var onmousemove: (ev: MouseEvent) => any; -declare var innerWidth: number; -declare var onoffline: (ev: Event) => any; -declare var length: number; -declare var screen: Screen; -declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; -declare var onratechange: (ev: Event) => any; -declare var onstorage: (ev: StorageEvent) => any; -declare var onloadstart: (ev: Event) => any; -declare var ondragenter: (ev: DragEvent) => any; -declare var onsubmit: (ev: Event) => any; -declare var self: Window; -declare var document: Document; -declare var onprogress: (ev: any) => any; -declare var ondblclick: (ev: MouseEvent) => any; -declare var pageYOffset: number; -declare var oncontextmenu: (ev: MouseEvent) => any; -declare var onchange: (ev: Event) => any; -declare var onloadedmetadata: (ev: Event) => any; -declare var onplay: (ev: Event) => any; -declare var onerror: ErrorEventHandler; -declare var onplaying: (ev: Event) => any; -declare var parent: Window; -declare var location: Location; -declare var oncanplaythrough: (ev: Event) => any; -declare var onabort: (ev: UIEvent) => any; -declare var onreadystatechange: (ev: Event) => any; -declare var outerHeight: number; -declare var onkeypress: (ev: KeyboardEvent) => any; -declare var frameElement: Element; -declare var onloadeddata: (ev: Event) => any; -declare var onsuspend: (ev: Event) => any; -declare var window: Window; -declare var onfocus: (ev: FocusEvent) => any; -declare var onmessage: (ev: MessageEvent) => any; -declare var ontimeupdate: (ev: Event) => any; -declare var onresize: (ev: UIEvent) => any; -declare var onselect: (ev: UIEvent) => any; -declare var navigator: Navigator; -declare var styleMedia: StyleMedia; -declare var ondrop: (ev: DragEvent) => any; -declare var onmouseout: (ev: MouseEvent) => any; -declare var onended: (ev: Event) => any; -declare var onhashchange: (ev: Event) => any; -declare var onunload: (ev: Event) => any; -declare var onscroll: (ev: UIEvent) => any; -declare var screenY: number; -declare var onmousewheel: (ev: MouseWheelEvent) => any; -declare var onload: (ev: Event) => any; -declare var onvolumechange: (ev: Event) => any; -declare var oninput: (ev: Event) => any; -declare var performance: Performance; -declare function alert(message?: any): void; -declare function scroll(x?: number, y?: number): void; -declare function focus(): void; -declare function scrollTo(x?: number, y?: number): void; -declare function print(): void; -declare function prompt(message?: string, defaul?: string): string; -declare function toString(): string; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; -declare function scrollBy(x?: number, y?: number): void; -declare function confirm(message?: string): boolean; -declare function close(): void; -declare function postMessage(message: any, targetOrigin: string, ports?: any): void; -declare function showModalDialog(url?: string, argument?: any, options?: any): any; -declare function blur(): void; -declare function getSelection(): Selection; -declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -declare function dispatchEvent(evt: Event): boolean; -declare function attachEvent(event: string, listener: EventListener): boolean; -declare function detachEvent(event: string, listener: EventListener): void; -declare var localStorage: Storage; -declare var status: string; -declare var onmouseleave: (ev: MouseEvent) => any; -declare var screenLeft: number; -declare var offscreenBuffering: any; -declare var maxConnectionsPerServer: number; -declare var onmouseenter: (ev: MouseEvent) => any; -declare var clipboardData: DataTransfer; -declare var defaultStatus: string; -declare var clientInformation: Navigator; -declare var closed: boolean; -declare var onhelp: (ev: Event) => any; -declare var external: External; -declare var event: MSEventObj; -declare var onfocusout: (ev: FocusEvent) => any; -declare var screenTop: number; -declare var onfocusin: (ev: FocusEvent) => any; -declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; -declare function navigate(url: string): void; -declare function resizeBy(x?: number, y?: number): void; -declare function item(index: any): any; -declare function resizeTo(x?: number, y?: number): void; -declare function createPopup(arguments?: any): MSPopupWindow; -declare function toStaticHTML(html: string): string; -declare function execScript(code: string, language?: string): any; -declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function moveTo(x?: number, y?: number): void; -declare function moveBy(x?: number, y?: number): void; -declare function showHelp(url: string, helpArg?: any, features?: string): void; -declare var sessionStorage: Storage; -declare function clearTimeout(handle: number): void; -declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; -declare function clearInterval(handle: number): void; -declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; - - -///////////////////////////// -/// IE10 DOM APIs -///////////////////////////// - - -interface ObjectURLOptions { - oneTimeOnly?: boolean; -} - -interface HTMLBodyElement { - onpopstate: (ev: PopStateEvent) => any; -} - -interface MSGestureEvent extends UIEvent { - offsetY: number; - translationY: number; - velocityExpansion: number; - velocityY: number; - velocityAngular: number; - translationX: number; - velocityX: number; - hwTimestamp: number; - offsetX: number; - screenX: number; - rotation: number; - expansion: number; - clientY: number; - screenY: number; - scale: number; - gestureObject: any; - clientX: number; - initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} -declare var MSGestureEvent: { - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} - -interface HTMLAnchorElement { - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; -} - -interface HTMLInputElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a FileList object on a file type input object. - */ - files: FileList; - /** - * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. - */ - max: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. - */ - step: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Returns the input field value as a number. - */ - valueAsNumber: number; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Specifies the ID of a pre-defined datalist of options for an input element. - */ - list: HTMLElement; - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. - */ - min: string; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Gets or sets a string containing a regular expression that the user's input must match. - */ - pattern: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. - * @param n Value to decrement the value by. - */ - stepDown(n?: number): void; - /** - * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. - * @param n Value to increment the value by. - */ - stepUp(n?: number): void; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -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; -} - -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - filterResX: SVGAnimatedInteger; - filterUnits: SVGAnimatedEnumeration; - primitiveUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - filterResY: SVGAnimatedInteger; - setFilterRes(filterResX: number, filterResY: number): void; -} - -interface TrackEvent extends Event { - track: any; -} - -interface SVGFEMergeNodeElement extends SVGElement { - in1: SVGAnimatedString; -} - -interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} - -interface MSGesture { - target: Element; - addPointer(pointerId: number): void; - stop(): void; -} -declare var MSGesture: { - prototype: MSGesture; - new (): MSGesture; -} - -interface TextTrackCue extends EventTarget { - onenter: (ev: Event) => any; - track: TextTrack; - endTime: number; - text: string; - pauseOnExit: boolean; - id: string; - startTime: number; - onexit: (ev: Event) => any; - getCueAsHTML(): DocumentFragment; -} -declare var TextTrackCue: { - prototype: TextTrackCue; - new (): TextTrackCue; -} - -interface MSStreamReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; -} -declare var MSStreamReader: { - prototype: MSStreamReader; - new (): MSStreamReader; -} - -interface DOMTokenList { - length: number; - contains(token: string): boolean; - remove(token: string): void; - toggle(token: string): boolean; - add(token: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} - -interface EventException { - name: string; -} - -interface Performance { - now(): number; -} - -interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { -} - -interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} - -interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - mode: SVGAnimatedEnumeration; - in1: SVGAnimatedString; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} -declare var SVGFEBlendElement: { - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} - -interface WindowTimers extends WindowTimersExtension { -} - -interface CSSStyleDeclaration { - animationFillMode: string; - floodColor: string; - animationIterationCount: string; - textShadow: string; - backfaceVisibility: string; - msAnimationIterationCount: string; - animationDelay: string; - animationTimingFunction: string; - columnWidth: any; - msScrollSnapX: string; - columnRuleColor: any; - columnRuleWidth: any; - transitionDelay: string; - transition: string; - msFlowFrom: string; - msScrollSnapType: string; - msContentZoomSnapType: string; - msGridColumns: string; - msAnimationName: string; - msGridRowAlign: string; - msContentZoomChaining: string; - msGridColumn: any; - msHyphenateLimitZone: any; - msScrollRails: string; - msAnimationDelay: string; - enableBackground: string; - msWrapThrough: string; - columnRuleStyle: string; - msAnimation: string; - msFlexFlow: string; - msScrollSnapY: string; - msHyphenateLimitLines: any; - msTouchAction: string; - msScrollLimit: string; - animation: string; - transform: string; - filter: string; - colorInterpolationFilters: string; - transitionTimingFunction: string; - msBackfaceVisibility: string; - animationPlayState: string; - transformOrigin: string; - msScrollLimitYMin: any; - msFontFeatureSettings: string; - msContentZoomLimitMin: any; - columnGap: any; - transitionProperty: string; - msAnimationDuration: string; - msAnimationFillMode: string; - msFlexDirection: string; - msTransitionDuration: string; - fontFeatureSettings: string; - breakBefore: string; - msFlexWrap: string; - perspective: string; - msFlowInto: string; - msTransformStyle: string; - msScrollTranslation: string; - msTransitionProperty: string; - msUserSelect: string; - msOverflowStyle: string; - msScrollSnapPointsY: string; - animationDirection: string; - animationDuration: string; - msFlex: string; - msTransitionTimingFunction: string; - animationName: string; - columnRule: string; - msGridColumnSpan: any; - msFlexNegative: string; - columnFill: string; - msGridRow: any; - msFlexOrder: string; - msFlexItemAlign: string; - msFlexPositive: string; - msContentZoomLimitMax: any; - msScrollLimitYMax: any; - msGridColumnAlign: string; - perspectiveOrigin: string; - lightingColor: string; - columns: string; - msScrollChaining: string; - msHyphenateLimitChars: string; - msTouchSelect: string; - floodOpacity: string; - msAnimationDirection: string; - msAnimationPlayState: string; - columnSpan: string; - msContentZooming: string; - msPerspective: string; - msFlexPack: string; - msScrollSnapPointsX: string; - msContentZoomSnapPoints: string; - msGridRowSpan: any; - msContentZoomSnap: string; - msScrollLimitXMin: any; - breakInside: string; - msHighContrastAdjust: string; - msFlexLinePack: string; - msGridRows: string; - transitionDuration: string; - msHyphens: string; - breakAfter: string; - msTransition: string; - msPerspectiveOrigin: string; - msContentZoomLimit: string; - msScrollLimitXMax: any; - msFlexAlign: string; - msWrapMargin: any; - columnCount: any; - msAnimationTimingFunction: string; - msTransitionDelay: string; - transformStyle: string; - msWrapFlow: string; - msFlexPreferredSize: string; -} - -interface MessageChannel { - port2: MessagePort; - port1: MessagePort; -} -declare var MessageChannel: { - prototype: MessageChannel; - new (): MessageChannel; -} - -interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} - -interface Navigator extends MSFileSaver { - msMaxTouchPoints: number; - msPointerEnabled: boolean; - msManipulationViewsEnabled: boolean; - msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; -} - -interface TransitionEvent extends Event { - propertyName: string; - elapsedTime: number; - initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; -} - -interface MediaQueryList { - matches: boolean; - media: string; - addListener(listener: MediaQueryListListener): void; - removeListener(listener: MediaQueryListListener): void; -} - -interface DOMError { - name: string; - toString(): string; -} - -interface CloseEvent extends Event { - wasClean: boolean; - reason: string; - code: number; - initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; -} - -interface WebSocket extends EventTarget { - protocol: string; - readyState: number; - bufferedAmount: number; - onopen: (ev: Event) => any; - extensions: string; - onmessage: (ev: any) => any; - onclose: (ev: CloseEvent) => any; - onerror: (ev: ErrorEvent) => any; - binaryType: string; - url: string; - close(code?: number, reason?: string): void; - send(data: any): void; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; -} -declare var WebSocket: { - prototype: WebSocket; - new (url: string): WebSocket; - new (url: string, prototcol: string): WebSocket; - new (url: string, prototcol: string[]): WebSocket; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; -} - -interface SVGFEPointLightElement extends SVGElement { - y: SVGAnimatedNumber; - x: SVGAnimatedNumber; - z: SVGAnimatedNumber; -} - -interface ProgressEvent extends Event { - loaded: number; - lengthComputable: boolean; - total: number; - initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; -} - -interface IDBObjectStore { - indexNames: DOMStringList; - name: string; - transaction: IDBTransaction; - keyPath: string; - count(key?: any): IDBRequest; - add(value: any, key?: any): IDBRequest; - clear(): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; - put(value: any, key?: any): IDBRequest; - openCursor(range?: any, direction?: string): IDBRequest; - deleteIndex(indexName: string): void; - index(name: string): IDBIndex; - get(key: any): IDBRequest; - delete(key: any): IDBRequest; -} - -interface HTMLCanvasElement { - /** - * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. - */ - msToBlob(): Blob; -} - -interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - stdDeviationX: SVGAnimatedNumber; - in1: SVGAnimatedString; - stdDeviationY: SVGAnimatedNumber; - setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - result: SVGAnimatedString; -} - -interface Element { - msRegionOverflow: string; - onmspointerdown: (ev: any) => any; - onmsgotpointercapture: (ev: any) => any; - onmsgesturedoubletap: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - onmsinertiastart: (ev: any) => any; - onmslostpointercapture: (ev: any) => any; - onmspointerover: (ev: any) => any; - msContentZoomFactor: number; - onmspointerup: (ev: any) => any; - msGetRegionContent(): MSRangeCollection; - msReleasePointerCapture(pointerId: number): void; - msSetPointerCapture(pointerId: number): void; -} - -interface IDBVersionChangeEvent extends Event { - newVersion: number; - oldVersion: number; -} - -interface IDBIndex { - unique: boolean; - name: string; - keyPath: string; - objectStore: IDBObjectStore; - count(key?: any): IDBRequest; - getKey(key: any): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - get(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; -} - -interface WheelEvent { - getCurrentPoint(element: Element): void; -} - -interface FileList { - length: number; - item(index: number): File; - [index: number]: File; -} - -interface IDBCursor { - source: any; - direction: string; - key: any; - primaryKey: any; - advance(count: number): void; - delete(): IDBRequest; - continue(key?: any): void; - update(value: any): IDBRequest; -} - -interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - specularConstant: SVGAnimatedNumber; -} - -interface File extends Blob { - lastModifiedDate: any; - name: string; -} - -interface URL { - revokeObjectURL(url: string): void; - createObjectURL(object: any, options?: ObjectURLOptions): string; -} -declare var URL: URL; - -interface RangeException { - name: string; -} - -interface IDBCursorWithValue extends IDBCursor { - value: any; -} - -interface HTMLTextAreaElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface XMLHttpRequestEventTarget extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: any) => any; - ontimeout: (ev: any) => any; - onabort: (ev: any) => any; - onloadstart: (ev: any) => any; - onloadend: (ev: ProgressEvent) => any; -} - -interface IDBEnvironment { - msIndexedDB: IDBFactory; - indexedDB: IDBFactory; -} - -interface AudioTrackList extends EventTarget { - length: number; - onchange: (ev: any) => any; - onaddtrack: (ev: TrackEvent) => any; - getTrackById(id: string): AudioTrack; - item(index: number): AudioTrack; - [index: number]: AudioTrack; -} - -interface MSBaseReader extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - readyState: number; - onabort: (ev: any) => any; - onloadend: (ev: ProgressEvent) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: any) => any; - onloadstart: (ev: any) => any; - result: any; - abort(): void; - LOADING: number; - EMPTY: number; - DONE: number; -} - -interface History { - state: any; - replaceState(statedata: any, title: string, url?: string): void; - pushState(statedata: any, title: string, url?: string): void; -} - -interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - radiusX: SVGAnimatedNumber; - radiusY: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} -declare var SVGFEMorphologyElement: { - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} - -interface HTMLSelectElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface CSSRule { - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - VIEWPORT_RULE: number; -} -//declare var CSSRule: { -// KEYFRAMES_RULE: number; -// KEYFRAME_RULE: number; -// VIEWPORT_RULE: number; -//} - -interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { -} - -interface WindowTimersExtension { - msSetImmediate(expression: any, ...args: any[]): number; - clearImmediate(handle: number): void; - msClearImmediate(handle: number): void; - setImmediate(expression: any, ...args: any[]): number; -} - -interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - xChannelSelector: SVGAnimatedEnumeration; - yChannelSelector: SVGAnimatedEnumeration; - scale: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} -declare var SVGFEDisplacementMapElement: { - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} - -interface AnimationEvent extends Event { - animationName: string; - elapsedTime: number; - initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; -} - -interface SVGComponentTransferFunctionElement extends SVGElement { - tableValues: SVGAnimatedNumberList; - slope: SVGAnimatedNumber; - type: SVGAnimatedEnumeration; - exponent: SVGAnimatedNumber; - amplitude: SVGAnimatedNumber; - intercept: SVGAnimatedNumber; - offset: SVGAnimatedNumber; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} -declare var SVGComponentTransferFunctionElement: { - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} - -interface MSRangeCollection { - length: number; - item(index: number): Range; - [index: number]: Range; -} - -interface SVGFEDistantLightElement extends SVGElement { - azimuth: SVGAnimatedNumber; - elevation: SVGAnimatedNumber; -} - -interface SVGException { - name: string; -} - -interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { -} - -interface IDBKeyRange { - upper: any; - upperOpen: boolean; - lower: any; - lowerOpen: boolean; - bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - only(value: any): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; -} - -interface WindowConsole { - console: Console; -} - -interface IDBTransaction extends EventTarget { - oncomplete: (ev: Event) => any; - db: IDBDatabase; - mode: string; - error: DOMError; - onerror: (ev: ErrorEvent) => any; - onabort: (ev: any) => any; - abort(): void; - objectStore(name: string): IDBObjectStore; -} - -interface AudioTrack { - kind: string; - language: string; - id: string; - label: string; - enabled: boolean; -} - -interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - orderY: SVGAnimatedInteger; - kernelUnitLengthY: SVGAnimatedNumber; - orderX: SVGAnimatedInteger; - preserveAlpha: SVGAnimatedBoolean; - kernelMatrix: SVGAnimatedNumberList; - edgeMode: SVGAnimatedEnumeration; - kernelUnitLengthX: SVGAnimatedNumber; - bias: SVGAnimatedNumber; - targetX: SVGAnimatedInteger; - targetY: SVGAnimatedInteger; - divisor: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} -declare var SVGFEConvolveMatrixElement: { - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} - -interface TextTrackCueList { - length: number; - item(index: number): TextTrackCue; - [index: number]: TextTrackCue; - getCueById(id: string): TextTrackCue; -} - -interface CSSKeyframesRule extends CSSRule { - name: string; - cssRules: CSSRuleList; - findRule(rule: string): CSSKeyframeRule; - deleteRule(rule: string): void; - appendRule(rule: string): void; -} - -interface Window extends WindowBase64, IDBEnvironment, WindowConsole { - onmspointerdown: (ev: any) => any; - animationStartTime: number; - onmsgesturedoubletap: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - msAnimationStartTime: number; - applicationCache: ApplicationCache; - onmsinertiastart: (ev: any) => any; - onmspointerover: (ev: any) => any; - onpopstate: (ev: PopStateEvent) => any; - onmspointerup: (ev: any) => any; - msCancelRequestAnimationFrame(handle: number): void; - matchMedia(mediaQuery: string): MediaQueryList; - cancelAnimationFrame(handle: number): void; - msIsStaticHTML(html: string): boolean; - msMatchMedia(mediaQuery: string): MediaQueryList; - requestAnimationFrame(callback: FrameRequestCallback): number; - msRequestAnimationFrame(callback: FrameRequestCallback): number; -} - -interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - baseFrequencyX: SVGAnimatedNumber; - numOctaves: SVGAnimatedInteger; - type: SVGAnimatedEnumeration; - baseFrequencyY: SVGAnimatedNumber; - stitchTiles: SVGAnimatedEnumeration; - seed: SVGAnimatedNumber; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} -declare var SVGFETurbulenceElement: { - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} - -interface TextTrackList { - length: number; - item(index: number): TextTrack; - [index: number]: TextTrack; -} - -interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { -} - -interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - type: SVGAnimatedEnumeration; - values: SVGAnimatedNumberList; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} -declare var SVGFEColorMatrixElement: { - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} - -interface Console { - info(message?: any, ...optionalParams: any[]): void; - profile(reportName?: string): void; - assert(test?: boolean, message?: string, ...optionalParams: any[]): void; - msIsIndependentlyComposed(element: Element): boolean; - clear(): void; - dir(value?: any, ...optionalParams: any[]): void; - warn(message?: any, ...optionalParams: any[]): void; - error(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - profileEnd(): void; -} - -interface SVGFESpotLightElement extends SVGElement { - pointsAtY: SVGAnimatedNumber; - y: SVGAnimatedNumber; - limitingConeAngle: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - x: SVGAnimatedNumber; - pointsAtZ: SVGAnimatedNumber; - z: SVGAnimatedNumber; - pointsAtX: SVGAnimatedNumber; -} - -interface HTMLImageElement { - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; -} - -interface WindowBase64 { - btoa(rawString: string): string; - atob(encodedString: string): string; -} - -interface IDBDatabase extends EventTarget { - version: string; - name: string; - objectStoreNames: DOMStringList; - onerror: (ev: ErrorEvent) => any; - onabort: (ev: any) => any; - createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; - close(): void; - transaction(storeNames: any, mode?: string): IDBTransaction; - deleteObjectStore(name: string): void; -} - -interface DOMStringList { - length: number; - contains(str: string): boolean; - item(index: number): string; - [index: number]: string; -} - -interface HTMLButtonElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface IDBOpenDBRequest extends IDBRequest { - onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - onblocked: (ev: Event) => any; -} - -interface HTMLProgressElement extends HTMLElement { - /** - * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. - */ - value: number; - /** - * Defines the maximum, or "done" value for a progress element. - */ - max: number; - /** - * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). - */ - position: number; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} - -interface MSLaunchUriCallback { - (): void; -} - -interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - dy: SVGAnimatedNumber; - in1: SVGAnimatedString; - dx: SVGAnimatedNumber; -} - -interface HTMLFormElement { - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Designates a form that is not validated when submitted. - */ - noValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; -} - -interface MSUnsafeFunctionCallback { - (): any; -} - -interface Document { - onmspointerdown: (ev: any) => any; - msHidden: boolean; - msVisibilityState: string; - onmsgesturedoubletap: (ev: any) => any; - visibilityState: string; - onmsmanipulationstatechanged: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmscontentzoom: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - onmsinertiastart: (ev: any) => any; - msCSSOMElementFloatMetrics: boolean; - onmspointerover: (ev: any) => any; - hidden: boolean; - onmspointerup: (ev: any) => any; - msElementsFromPoint(x: number, y: number): NodeList; - msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - clear(): void; -} - -interface MessageEvent extends Event { - ports: any; -} - -interface HTMLScriptElement { - async: boolean; -} - -interface HTMLMediaElement { - /** - * Specifies the purpose of the audio or video media, such as background audio or alerts. - */ - msAudioCategory: string; - /** - * Specifies whether or not to enable low-latency playback on the media element. - */ - msRealTime: boolean; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - textTracks: TextTrackList; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Returns an AudioTrackList object with the audio tracks for a given video element. - */ - audioTracks: AudioTrackList; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; - /** - * Specifies the output device id that the audio will be sent to. - */ - msAudioDeviceType: string; - /** - * Clears all effects from the media pipeline. - */ - msClearEffects(): void; - /** - * Specifies the media protection manager for a given media pipeline. - */ - msSetMediaProtectionManager(mediaProtectionManager?: any): void; - /** - * Inserts the specified audio effect into media pipeline. - */ - msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; -} - -interface TextTrack extends EventTarget { - language: string; - mode: any; - readyState: number; - activeCues: TextTrackCueList; - cues: TextTrackCueList; - oncuechange: (ev: Event) => any; - kind: string; - onload: (ev: any) => any; - onerror: (ev: ErrorEvent) => any; - label: string; - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} -declare var TextTrack: { - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} - -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} - -interface IDBRequest extends EventTarget { - source: any; - onsuccess: (ev: Event) => any; - error: DOMError; - transaction: IDBTransaction; - onerror: (ev: ErrorEvent) => any; - readyState: string; - result: any; -} - -interface MessagePort extends EventTarget { - onmessage: (ev: any) => any; - close(): void; - postMessage(message?: any, ports?: any): void; - start(): void; -} - -interface FileReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; -} -declare var FileReader: { - prototype: FileReader; - new (): FileReader; -} - -interface BlobPropertyBag { - type?: string; - endings?: string; -} - -interface Blob { - type: string; - size: number; - msDetachStream(): any; - slice(start?: number, end?: number, contentType?: string): Blob; - msClose(): void; -} -declare var Blob: { - prototype: Blob; - new (blobParts?: any[], options?: BlobPropertyBag): Blob; -} - -interface ApplicationCache extends EventTarget { - status: number; - ondownloading: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - onupdateready: (ev: Event) => any; - oncached: (ev: Event) => any; - onobsolete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onchecking: (ev: Event) => any; - onnoupdate: (ev: Event) => any; - swapCache(): void; - abort(): void; - update(): void; - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} -declare var ApplicationCache: { - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} - -interface FrameRequestCallback { - (time: number): void; -} - -interface XMLHttpRequest { - response: any; - withCredentials: boolean; - onprogress: (ev: ProgressEvent) => any; - onabort: (ev: any) => any; - responseType: string; - onloadend: (ev: ProgressEvent) => any; - upload: XMLHttpRequestEventTarget; - onerror: (ev: ErrorEvent) => any; - onloadstart: (ev: any) => any; -} - -interface PopStateEvent extends Event { - state: any; - initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; -} - -interface CSSKeyframeRule extends CSSRule { - keyText: string; - style: CSSStyleDeclaration; -} - -interface MSFileSaver { - msSaveBlob(blob: any, defaultName?: string): boolean; - msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; -} - -interface MSStream { - type: string; - msDetachStream(): any; - msClose(): void; -} - -interface MediaError { - msExtendedCode: number; -} - -interface HTMLFieldSetElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new (): MSBlobBuilder; -} - -interface HTMLElement { - onmscontentzoom: (ev: any) => any; - oncuechange: (ev: Event) => any; - spellcheck: boolean; - classList: DOMTokenList; - onmsmanipulationstatechanged: (ev: any) => any; - draggable: boolean; -} - -interface DataTransfer { - types: DOMStringList; - files: FileList; -} - -interface DOMSettableTokenList extends DOMTokenList { - value: string; -} - -interface IDBFactory { - open(name: string, version?: number): IDBOpenDBRequest; - cmp(first: any, second: any): number; - deleteDatabase(name: string): IDBOpenDBRequest; -} - -interface Range { - createContextualFragment(fragment: string): DocumentFragment; -} - -interface HTMLObjectElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface MSPointerEvent 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; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} -declare var MSPointerEvent: { - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} - -interface DOMException { - name: string; - INVALID_NODE_TYPE_ERR: number; - DATA_CLONE_ERR: number; - TIMEOUT_ERR: number; -} -//declare var DOMException: { -// INVALID_NODE_TYPE_ERR: number; -// DATA_CLONE_ERR: number; -// TIMEOUT_ERR: number; -//} - -interface MSManipulationEvent extends UIEvent { - lastState: number; - currentState: number; - initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; -} -declare var MSManipulationEvent: { - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; -} - -interface FormData { - append(name: any, value: any, blobName?: string): void; -} -declare var FormData: { - prototype: FormData; - new (form?: HTMLFormElement): FormData; -} - -interface HTMLDataListElement extends HTMLElement { - options: HTMLCollection; -} - -interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} - -interface AbstractWorker extends EventTarget { - onerror: (ev: ErrorEvent) => any; -} - -interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - in2: SVGAnimatedString; - k2: SVGAnimatedNumber; - k1: SVGAnimatedNumber; - k3: SVGAnimatedNumber; - in1: SVGAnimatedString; - k4: SVGAnimatedNumber; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} -declare var SVGFECompositeElement: { - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} - -interface ValidityState { - customError: boolean; - valueMissing: boolean; - stepMismatch: boolean; - rangeUnderflow: boolean; - rangeOverflow: boolean; - typeMismatch: boolean; - patternMismatch: boolean; - tooLong: boolean; - valid: boolean; -} - -interface HTMLTrackElement extends HTMLElement { - kind: string; - src: string; - srclang: string; - track: TextTrack; - label: string; - default: boolean; -} - -interface MSApp { - createFileFromStorageFile(storageFile: any): File; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - terminateApp(exceptionObject: any): void; - createDataPackage(object: any): any; - execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; - getHtmlPrintDocumentSource(htmlDoc: any): any; - addPublicLocalApplicationUri(uri: string): void; - createDataPackageFromSelection(): any; -} -declare var MSApp: MSApp; - -interface HTMLVideoElement { - msIsStereo3D: boolean; - msStereo3DPackingMode: string; - onMSVideoOptimalLayoutChanged: (ev: any) => any; - onMSVideoFrameStepCompleted: (ev: any) => any; - msStereo3DRenderMode: string; - msIsLayoutOptimalForPlayback: boolean; - msHorizontalMirror: boolean; - onMSVideoFormatChanged: (ev: any) => any; - msZoom: boolean; - msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; - msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; - msFrameStep(forward: boolean): void; -} - -interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} - -interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - diffuseConstant: SVGAnimatedNumber; -} - -interface MSCSSMatrix { - m24: number; - m34: number; - a: number; - d: number; - m32: number; - m41: number; - m11: number; - f: number; - e: number; - m23: number; - m14: number; - m33: number; - m22: number; - m21: number; - c: number; - m12: number; - b: number; - m42: number; - m31: number; - m43: number; - m13: number; - m44: number; - multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; - skewY(angle: number): MSCSSMatrix; - setMatrixValue(value: string): void; - inverse(): MSCSSMatrix; - rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; - toString(): string; - rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; - translate(x: number, y: number, z?: number): MSCSSMatrix; - scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; - skewX(angle: number): MSCSSMatrix; -} -declare var MSCSSMatrix: { - prototype: MSCSSMatrix; - new (text?: string): MSCSSMatrix; -} - -interface Worker extends AbstractWorker { - onmessage: (ev: any) => any; - postMessage(message: any, ports?: any): void; - terminate(): void; -} -declare var Worker: { - prototype: Worker; - new (stringUrl: string): Worker; -} - -interface HTMLIFrameElement { - sandbox: DOMSettableTokenList; -} - -declare var onmspointerdown: (ev: any) => any; -declare var animationStartTime: number; -declare var onmsgesturedoubletap: (ev: any) => any; -declare var onmspointerhover: (ev: any) => any; -declare var onmsgesturehold: (ev: any) => any; -declare var onmspointermove: (ev: any) => any; -declare var onmsgesturechange: (ev: any) => any; -declare var onmsgesturestart: (ev: any) => any; -declare var onmspointercancel: (ev: any) => any; -declare var onmsgestureend: (ev: any) => any; -declare var onmsgesturetap: (ev: any) => any; -declare var onmspointerout: (ev: any) => any; -declare var msAnimationStartTime: number; -declare var applicationCache: ApplicationCache; -declare var onmsinertiastart: (ev: any) => any; -declare var onmspointerover: (ev: any) => any; -declare var onpopstate: (ev: PopStateEvent) => any; -declare var onmspointerup: (ev: any) => any; -declare function msCancelRequestAnimationFrame(handle: number): void; -declare function matchMedia(mediaQuery: string): MediaQueryList; -declare function cancelAnimationFrame(handle: number): void; -declare function msIsStaticHTML(html: string): boolean; -declare function msMatchMedia(mediaQuery: string): MediaQueryList; -declare function requestAnimationFrame(callback: FrameRequestCallback): number; -declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; -declare function btoa(rawString: string): string; -declare function atob(encodedString: string): string; -declare var msIndexedDB: IDBFactory; -declare var indexedDB: IDBFactory; -declare var console: Console; - - -///////////////////////////// -/// IE11 DOM APIs -///////////////////////////// - - -interface StoreExceptionsInformation extends ExceptionInformation { - siteName?: string; - explanationString?: string; - detailURI?: string; -} - -interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { - arrayOfDomainStrings?: Array; -} - -interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { - arrayOfDomainStrings?: Array; -} - -interface AlgorithmParameters { -} - -interface MutationObserverInit { - childList?: boolean; - attributes?: boolean; - characterData?: boolean; - subtree?: boolean; - attributeOldValue?: boolean; - characterDataOldValue?: boolean; - attributeFilter?: Array; -} - -interface ExceptionInformation { - domain?: string; -} - -interface MsZoomToOptions { - contentX?: number; - contentY?: number; - viewportX?: string; - viewportY?: string; - scaleFactor?: number; - animate?: string; -} - -interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; -} - -interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; -} - -interface Algorithm { - name?: string; - params?: AlgorithmParameters; -} - -interface NavigatorID { - product: string; - vendor: string; -} - -interface HTMLBodyElement { - onpageshow: (ev: PageTransitionEvent) => any; - onpagehide: (ev: PageTransitionEvent) => any; -} - -interface MSExecAtPriorityFunctionCallback { - (...args: any[]): any; -} - -interface MSWindowExtensions { - captureEvents(): void; - releaseEvents(): void; -} - -interface MSGraphicsTrust { - status: string; - constrictionActive: boolean; -} - -interface AudioTrack { - sourceBuffer: SourceBuffer; -} - -interface DragEvent { - msConvertURL(file: File, targetType: string, targetURL?: string): void; -} - -interface SubtleCrypto { - unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; - encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; - importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; - verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; - deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; - exportKey(format: string, key: Key): KeyOperation; - generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; - decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; -} - -interface Crypto extends RandomSource { - subtle: SubtleCrypto; -} - -interface VideoPlaybackQuality { - totalFrameDelay: number; - creationTime: number; - totalVideoFrames: number; - droppedVideoFrames: number; -} - -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 extends GlobalEventHandlers { - onpageshow: (ev: PageTransitionEvent) => any; - ondevicemotion: (ev: DeviceMotionEvent) => any; - devicePixelRatio: number; - msCrypto: Crypto; - ondeviceorientation: (ev: DeviceOrientationEvent) => any; - doNotTrack: string; - onmspointerenter: (ev: any) => any; - onpagehide: (ev: PageTransitionEvent) => any; - onmspointerleave: (ev: any) => any; -} - -interface Key { - algorithm: Algorithm; - type: string; - extractable: boolean; - keyUsage: string[]; -} - -interface TextTrackList extends EventTarget { - onaddtrack: (ev: any) => any; -} - -interface DeviceAcceleration { - y: number; - x: number; - z: number; -} - -interface Console { - count(countTitle?: string): void; - groupEnd(): void; - time(timerName?: string): void; - timeEnd(timerName?: string): void; - trace(): void; - group(groupTitle?: string): void; - dirxml(value: any): void; - debug(message?: string, ...optionalParams: any[]): void; - groupCollapsed(groupTitle?: string): void; - select(element: Element): void; -} - -interface MSNavigatorDoNotTrack { - removeSiteSpecificTrackingException(args: ExceptionInformation): void; - removeWebWideTrackingException(args: ExceptionInformation): void; - storeWebWideTrackingException(args: StoreExceptionsInformation): void; - storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; - confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; - confirmWebWideTrackingException(args: ExceptionInformation): boolean; -} - -interface HTMLImageElement { - crossOrigin: string; - msPlayToPreferredSourceUri: string; -} - -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; - //[name: string]: Element; -} - -interface MSNavigatorExtensions { - language: string; -} - -interface AesGcmEncryptResult { - ciphertext: ArrayBuffer; - tag: ArrayBuffer; -} - -interface HTMLSourceElement { - msKeySystem: string; -} - -interface CSSStyleDeclaration { - alignItems: string; - borderImageSource: string; - flexBasis: string; - borderImageWidth: string; - borderImageRepeat: string; - order: string; - flex: string; - alignContent: string; - msImeAlign: string; - flexShrink: string; - flexGrow: string; - borderImageSlice: string; - flexWrap: string; - borderImageOutset: string; - flexDirection: string; - touchAction: string; - flexFlow: string; - borderImage: string; - justifyContent: string; - alignSelf: string; - msTextCombineHorizontal: string; -} - -interface NavigationCompletedEvent extends NavigationEvent { - webErrorStatus: number; - isSuccess: boolean; -} - -interface MutationRecord { - oldValue: string; - previousSibling: Node; - addedNodes: NodeList; - attributeName: string; - removedNodes: NodeList; - target: Node; - nextSibling: Node; - attributeNamespace: string; - type: string; -} - -interface Navigator { - pointerEnabled: boolean; - maxTouchPoints: number; -} - -interface Document extends MSDocumentExtensions, GlobalEventHandlers { - msFullscreenEnabled: boolean; - onmsfullscreenerror: (ev: any) => any; - onmspointerenter: (ev: any) => any; - msFullscreenElement: Element; - onmsfullscreenchange: (ev: any) => any; - onmspointerleave: (ev: any) => any; - msExitFullscreen(): void; -} - -interface MimeTypeArray { - length: number; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(type: string): Plugin; - //[type: string]: Plugin; -} - -interface HTMLMediaElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; - /** - * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. - */ - msKeys: MSMediaKeys; - msGraphicsTrustStatus: MSGraphicsTrust; - msSetMediaKeys(mediaKeys: MSMediaKeys): void; - addTextTrack(kind: string, label?: string, language?: string): TextTrack; -} - -interface TextTrack { - addCue(cue: TextTrackCue): void; - removeCue(cue: TextTrackCue): void; -} - -interface KeyOperation extends EventTarget { - oncomplete: (ev: any) => any; - onerror: (ev: any) => any; - result: any; -} - -interface DOMStringMap { -} - -interface DeviceOrientationEvent extends Event { - gamma: number; - alpha: number; - absolute: boolean; - beta: number; - initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; -} - -interface MSMediaKeys { - keySystem: string; - createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; - isTypeSupported(keySystem: string, type?: string): boolean; -} -declare var MSMediaKeys: { - prototype: MSMediaKeys; - new (): MSMediaKeys; -} - -interface MSMediaKeyMessageEvent extends Event { - destinationURL: string; - message: Uint8Array; -} - -interface MSHTMLWebViewElement extends HTMLElement { - documentTitle: string; - width: number; - src: string; - canGoForward: boolean; - height: number; - canGoBack: boolean; - navigateWithHttpRequestMessage(requestMessage: any): void; - goBack(): void; - navigate(uri: string): void; - stop(): void; - navigateToString(contents: string): void; - captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; - capturePreviewToBlobAsync(): MSWebViewAsyncOperation; - refresh(): void; - goForward(): void; - navigateToLocalStreamUri(source: string, streamResolver: any): void; - invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; - buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; -} - -interface NavigationEvent extends Event { - uri: string; -} - -interface Element extends GlobalEventHandlers { - onlostpointercapture: (ev: PointerEvent) => any; - onmspointerenter: (ev: any) => any; - ongotpointercapture: (ev: PointerEvent) => any; - onmspointerleave: (ev: any) => any; - msZoomTo(args: MsZoomToOptions): void; - setPointerCapture(pointerId: number): void; - msGetUntransformedBounds(): ClientRect; - releasePointerCapture(pointerId: number): void; - msRequestFullscreen(): void; -} - -interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; -} - -interface XMLHttpRequest { - msCaching: string; - msCachingEnabled(): boolean; - overrideMimeType(mime: string): void; -} - -interface SourceBuffer extends EventTarget { - updating: boolean; - appendWindowStart: number; - appendWindowEnd: number; - buffered: TimeRanges; - timestampOffset: number; - audioTracks: AudioTrackList; - appendBuffer(data: ArrayBuffer): void; - remove(start: number, end: number): void; - abort(): void; - appendStream(stream: MSStream, maxSize?: number): void; -} - -interface MSInputMethodContext extends EventTarget { - oncandidatewindowshow: (ev: any) => any; - target: HTMLElement; - compositionStartOffset: number; - oncandidatewindowhide: (ev: any) => any; - oncandidatewindowupdate: (ev: any) => any; - compositionEndOffset: number; - getCompositionAlternatives(): string[]; - getCandidateWindowClientRect(): ClientRect; - hasComposition(): boolean; - isCandidateWindowVisible(): boolean; -} - -interface DeviceRotationRate { - gamma: number; - alpha: number; - beta: number; -} - -interface PluginArray { - length: number; - refresh(reload?: boolean): void; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(name: string): Plugin; - //[name: string]: Plugin; -} - -interface MSMediaKeyError { - systemCode: number; - code: number; - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - MS_MEDIA_KEYERR_CLIENT: number; -} -declare var MSMediaKeyError: { - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - MS_MEDIA_KEYERR_CLIENT: number; -} - -interface Plugin { - length: number; - filename: string; - version: string; - name: string; - description: string; - item(index: number): MimeType; - [index: number]: MimeType; - namedItem(type: string): MimeType; - //[type: string]: MimeType; -} - -interface HTMLFrameSetElement { - onpageshow: (ev: PageTransitionEvent) => any; - onpagehide: (ev: PageTransitionEvent) => any; -} - -interface Screen extends EventTarget { - msOrientation: string; - onmsorientationchange: (ev: any) => any; - msLockOrientation(orientations: string[]): boolean; - msUnlockOrientation(): void; -} - -interface MediaSource extends EventTarget { - sourceBuffers: SourceBufferList; - duration: number; - readyState: string; - activeSourceBuffers: SourceBufferList; - addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; - isTypeSupported(type: string): boolean; - removeSourceBuffer(sourceBuffer: SourceBuffer): void; -} -declare var MediaSource: { - prototype: MediaSource; - new (): MediaSource; -} - -interface MediaError { - MS_MEDIA_ERR_ENCRYPTED: number; -} -//declare var MediaError: { -// MS_MEDIA_ERR_ENCRYPTED: number; -//} - -interface SourceBufferList extends EventTarget { - length: number; - item(index: number): SourceBuffer; - [index: number]: SourceBuffer; -} - -interface XMLDocument extends Document { -} - -interface DeviceMotionEvent extends Event { - rotationRate: DeviceRotationRate; - acceleration: DeviceAcceleration; - interval: number; - accelerationIncludingGravity: DeviceAcceleration; - initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; -} - -interface MimeType { - enabledPlugin: Plugin; - suffixes: string; - type: string; - description: string; -} - -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 { - captureEvents(): void; - releaseEvents(): void; -} - -interface HTMLElement { - dataset: DOMStringMap; - hidden: boolean; - msGetInputContext(): MSInputMethodContext; -} - -interface MutationObserver { - observe(target: Node, options: MutationObserverInit): void; - takeRecords(): MutationRecord[]; - disconnect(): void; -} -declare var MutationObserver: { - prototype: MutationObserver; - new (): MutationObserver; -} - -interface AudioTrackList { - onremovetrack: (ev: PluginArray) => any; -} - -interface HTMLObjectElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * 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. - */ - msPlayToSource: any; -} - -interface HTMLEmbedElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * 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. - */ - msPlayToSource: any; -} - -interface MSWebViewAsyncOperation extends EventTarget { - target: MSHTMLWebViewElement; - oncomplete: (ev: any) => any; - error: DOMError; - onerror: (ev: any) => any; - readyState: number; - type: number; - result: any; - start(): void; - ERROR: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; -} -declare var MSWebViewAsyncOperation: { - ERROR: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; -} - -interface ScriptNotifyEvent extends Event { - value: string; - callingUri: string; -} - -interface PerformanceNavigationTiming extends PerformanceEntry { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - redirectCount: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - type: string; -} - -interface MSMediaKeyNeededEvent extends Event { - initData: Uint8Array; -} - -interface MSManipulationEvent { - MS_MANIPULATION_STATE_SELECTING: number; - MS_MANIPULATION_STATE_COMMITTED: number; - MS_MANIPULATION_STATE_PRESELECT: number; - MS_MANIPULATION_STATE_DRAGGING: number; - MS_MANIPULATION_STATE_CANCELLED: number; -} -//declare var MSManipulationEvent: { -// MS_MANIPULATION_STATE_SELECTING: number; -// MS_MANIPULATION_STATE_COMMITTED: number; -// MS_MANIPULATION_STATE_PRESELECT: number; -// MS_MANIPULATION_STATE_DRAGGING: number; -// MS_MANIPULATION_STATE_CANCELLED: number; -//} - -interface LongRunningScriptDetectedEvent extends Event { - stopPageScriptExecution: boolean; - executionTime: number; -} - -interface MSAppView { - viewId: number; - close(): void; - postMessage(message: any, targetOrigin: string, ports?: any): void; -} - -interface PerfWidgetExternal { - maxCpuSpeed: 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; -} - -interface PageTransitionEvent extends Event { - persisted: boolean; -} - -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; -} - -interface HTMLDocument extends Document { -} - -interface KeyPair { - privateKey: Key; - publicKey: Key; -} - -interface MSApp { - getViewOpener(): MSAppView; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - createNewView(uri: string): MSAppView; - getCurrentPriority(): string; - NORMAL: string; - HIGH: string; - IDLE: string; - CURRENT: string; -} -//declare var MSApp: { -// NORMAL: string; -// HIGH: string; -// IDLE: string; -// CURRENT: string; -//} - -interface MSMediaKeySession extends EventTarget { - sessionId: string; - error: MSMediaKeyError; - keySystem: string; - close(): void; - update(key: Uint8Array): void; -} - -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 { - getVideoPlaybackQuality(): VideoPlaybackQuality; -} - -interface UnviewableContentIdentifiedEvent extends NavigationEvent { - referrer: string; -} - -interface CryptoOperation extends EventTarget { - algorithm: Algorithm; - oncomplete: (ev: any) => any; - onerror: (ev: any) => any; - onprogress: (ev: any) => any; - onabort: (ev: any) => any; - key: Key; - result: any; - abort(): void; - finish(): void; - process(buffer: ArrayBufferView): void; -} - -declare var onpageshow: (ev: PageTransitionEvent) => any; -declare var ondevicemotion: (ev: DeviceMotionEvent) => any; -declare var devicePixelRatio: number; -declare var msCrypto: Crypto; -declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; -declare var doNotTrack: string; -declare var onmspointerenter: (ev: any) => any; -declare var onpagehide: (ev: PageTransitionEvent) => any; -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; - - -///////////////////////////// -/// WorkerGlobalScope APIs -///////////////////////////// -// TODO: These are only available in a Web Worker - should be in a separate lib file -declare function importScripts(...urls: string[]): void; - - -///////////////////////////// -/// Windows Script Host APIS -///////////////////////////// -declare var ActiveXObject: { new (s: string): any; }; - -interface ITextWriter { - Write(s: string): void; - WriteLine(s: string): void; - Close(): void; -} - -declare var WScript: { - Echo(s: any): void; - StdErr: ITextWriter; - StdOut: ITextWriter; - Arguments: { length: number; Item(n: number): string; }; - ScriptFullName: string; - Quit(exitCode?: number): number; -} diff --git a/_infrastructure/tests/typescript/0.9.7-59a846/tsc b/_infrastructure/tests/typescript/0.9.7-59a846/tsc deleted file mode 100644 index 3c0dab574f..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-59a846/tsc +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -require('./tsc.js') diff --git a/_infrastructure/tests/typescript/0.9.7-59a846/tsc.js b/_infrastructure/tests/typescript/0.9.7-59a846/tsc.js deleted file mode 100644 index 37eafa1aed..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-59a846/tsc.js +++ /dev/null @@ -1,62781 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - TypeScript.DiagnosticCode = { - error_TS_0_1: "error TS{0}: {1}", - warning_TS_0_1: "warning TS{0}: {1}", - Unrecognized_escape_sequence: "Unrecognized escape sequence.", - Unexpected_character_0: "Unexpected character {0}.", - Missing_close_quote_character: "Missing close quote character.", - Identifier_expected: "Identifier expected.", - _0_keyword_expected: "'{0}' keyword expected.", - _0_expected: "'{0}' expected.", - Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", - Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", - Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", - Trailing_separator_not_allowed: "Trailing separator not allowed.", - AsteriskSlash_expected: "'*/' expected.", - public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", - Unexpected_token: "Unexpected token.", - Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", - Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", - Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", - Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", - Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", - Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", - Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", - Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", - Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", - Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", - Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", - extends_clause_already_seen: "'extends' clause already seen.", - extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", - Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", - implements_clause_already_seen: "'implements' clause already seen.", - Accessibility_modifier_already_seen: "Accessibility modifier already seen.", - _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", - _0_modifier_already_seen: "'{0}' modifier already seen.", - _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", - Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", - super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", - Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", - Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", - 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_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}'.", - _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", - declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", - declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", - Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", - Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", - set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", - set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", - set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", - set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", - get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", - Modifiers_cannot_appear_here: "Modifiers cannot appear here.", - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", - Class_name_cannot_be_0: "Class name cannot be '{0}'.", - Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", - Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", - Module_name_cannot_be_0: "Module name cannot be '{0}'.", - Enum_member_must_have_initializer: "Enum member must have initializer.", - Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", - Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", - Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", - Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", - module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", - constructor_function_accessor_or_variable: "constructor, function, accessor or variable", - statement: "statement", - case_or_default_clause: "case or default clause", - identifier: "identifier", - call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", - expression: "expression", - type_name: "type name", - property_or_accessor: "property or accessor", - parameter: "parameter", - type: "type", - type_parameter: "type parameter", - 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_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.", - super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", - Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", - Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", - Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", - Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", - Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", - Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", - Getter_0_already_declared: "Getter '{0}' already declared.", - Setter_0_already_declared: "Setter '{0}' already declared.", - Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", - Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", - Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", - Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", - Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", - Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", - Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", - Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", - Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", - Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", - Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", - Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", - Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", - Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", - Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", - Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", - Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", - Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", - Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", - Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", - Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", - Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", - A_class_may_only_extend_another_class: "A class may only extend another class.", - A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", - An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", - Unable_to_resolve_type: "Unable to resolve type.", - Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", - Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", - Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", - Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", - Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", - Invalid_new_expression: "Invalid 'new' expression.", - Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", - Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", - Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", - Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", - Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", - Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", - The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", - 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_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.", - _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.", - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", - Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", - 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_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}'.", - 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.", - Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", - Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", - Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", - All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", - Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", - this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", - Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", - Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", - Duplicate_overload_call_signature: "Duplicate overload call signature.", - Duplicate_overload_construct_signature: "Duplicate overload construct signature.", - Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", - Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", - Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", - 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_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.", - Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", - A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", - Rest_parameters_must_be_array_types: "Rest parameters must be array types.", - Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", - 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_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_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.", - Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", - Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", - Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", - 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_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}", - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", - Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", - All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", - super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", - Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", - Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", - Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", - Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", - Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", - continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", - break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", - Jump_target_not_found: "Jump target not found.", - Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", - TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", - TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", - TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", - TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", - TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", - TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", - 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}", - Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", - Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", - Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", - Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", - Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", - Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - 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.", - 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_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_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.", - Could_not_find_file_0: "Could not find file: '{0}'.", - A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", - Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", - Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", - Emit_Error_0: "Emit Error: {0}.", - Cannot_read_file_0_1: "Cannot read file '{0}': {1}", - Unsupported_file_encoding: "Unsupported file encoding.", - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", - Unsupported_locale_0: "Unsupported locale: '{0}'.", - Execution_Failed_NL: "Execution Failed.{NL}", - Invalid_call_to_up: "Invalid call to 'up'", - Invalid_call_to_down: "Invalid call to 'down'", - Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", - Unknown_option_0: "Unknown option '{0}'", - Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", - Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", - Could_not_delete_file_0: "Could not delete file '{0}'", - Could_not_create_directory_0: "Could not create directory '{0}'", - Error_while_executing_file_0: "Error while executing file '{0}': ", - Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", - Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", - Option_0_specified_without_1: "Option '{0}' specified without '{1}'", - codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", - Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", - Generates_corresponding_0_file: "Generates corresponding {0} file.", - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", - Watch_input_files: "Watch input files.", - Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", - Do_not_emit_comments_to_output: "Do not emit comments to output.", - Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", - Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", - Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", - Print_this_message: "Print this message.", - Print_the_compiler_s_version_0: "Print the compiler's version: {0}", - Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", - Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", - Syntax_0: "Syntax: {0}", - options: "options", - file1: "file", - Examples: "Examples:", - Options: "Options:", - Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", - Version_0: "Version {0}", - Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", - NL_Recompiling_0: "{NL}Recompiling ({0}):", - STRING: "STRING", - KIND: "KIND", - file2: "FILE", - VERSION: "VERSION", - LOCATION: "LOCATION", - 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})", - Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", - Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", - Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", - Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", - Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", - new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", - _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", - Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", - 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.", - 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; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - return false; - } - - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0, n = array1.length; i < n; i++) { - if (!equals(array1[i], array2[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.distinct = function (array, equalsFn) { - var result = []; - - for (var i = 0, n = array.length; i < n; i++) { - var current = array[i]; - for (var j = 0; j < result.length; j++) { - if (equalsFn(result[j], current)) { - break; - } - } - - if (j === result.length) { - result.push(current); - } - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.lastOrDefault = function (array, predicate) { - for (var i = array.length - 1; i >= 0; i--) { - var v = array[i]; - if (predicate(v, i)) { - return v; - } - } - - return null; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value, i)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.first = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (!func || func(value, i)) { - return value; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = new Array(values.length); - - for (var i = 0; i < values.length; i++) { - result[i] = func(values[i]); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = new Array(); - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - var low = 0; - var high = array.length - 1; - - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - - if (midValue === value) { - return middle; - } else if (midValue > value) { - high = middle - 1; - } else { - low = middle + 1; - } - } - - return ~low; - }; - - ArrayUtilities.createArray = function (length, defaultValue) { - var result = new Array(length); - for (var i = 0; i < length; i++) { - result[i] = defaultValue; - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - - ArrayUtilities.indexOf = function (array, predicate) { - for (var i = 0, n = array.length; i < n; i++) { - if (predicate(array[i])) { - return i; - } - } - - return -1; - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitVector) { - var pool = []; - var Constants; - (function (Constants) { - Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; - Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; - - Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; - - Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; - Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; - - Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; - Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; - Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; - })(Constants || (Constants = {})); - - var BitVectorImpl = (function () { - function BitVectorImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.bits = []; - } - BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; - }; - - BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; - }; - - BitVectorImpl.prototype.valueAt = function (index) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return undefined; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { - return true; - } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { - return false; - } else { - return undefined; - } - } else { - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return false; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { - return true; - } else { - return false; - } - } - }; - - BitVectorImpl.prototype.setValueAt = function (index, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); - - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === undefined) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - - var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); - encoded = encoded & clearMask; - - if (value === true) { - encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); - } else if (value === false) { - encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } else { - TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); - - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === false) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - - encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); - - if (value) { - encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } - }; - - BitVectorImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - this.bits.length = 0; - pool.push(this); - }; - return BitVectorImpl; - })(); - - function getBitVector(allowUndefinedValues) { - if (pool.length === 0) { - return new BitVectorImpl(allowUndefinedValues); - } - - var vector = pool.pop(); - vector.isReleased = false; - vector.allowUndefinedValues = allowUndefinedValues; - - return vector; - } - BitVector.getBitVector = getBitVector; - })(TypeScript.BitVector || (TypeScript.BitVector = {})); - var BitVector = TypeScript.BitVector; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitMatrix) { - var pool = []; - - var BitMatrixImpl = (function () { - function BitMatrixImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.vectors = []; - } - BitMatrixImpl.prototype.valueAt = function (x, y) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - return this.allowUndefinedValues ? undefined : false; - } - - return vector.valueAt(y); - }; - - BitMatrixImpl.prototype.setValueAt = function (x, y, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - if (value === undefined) { - return; - } - - vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); - this.vectors[x] = vector; - } - - vector.setValueAt(y, value); - }; - - BitMatrixImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - - for (var name in this.vectors) { - if (this.vectors.hasOwnProperty(name)) { - var vector = this.vectors[name]; - vector.release(); - } - } - - this.vectors.length = 0; - pool.push(this); - }; - return BitMatrixImpl; - })(); - - function getBitMatrix(allowUndefinedValues) { - if (pool.length === 0) { - return new BitMatrixImpl(allowUndefinedValues); - } - - var matrix = pool.pop(); - matrix.isReleased = false; - matrix.allowUndefinedValues = allowUndefinedValues; - - return matrix; - } - BitMatrix.getBitMatrix = getBitMatrix; - })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); - var BitMatrix = TypeScript.BitMatrix; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); - var AssertionLevel = TypeScript.AssertionLevel; - - var Debug = (function () { - function Debug() { - } - Debug.shouldAssert = function (level) { - return this.currentAssertionLevel >= level; - }; - - Debug.assert = function (expression, message, verboseDebugInfo) { - if (typeof message === "undefined") { message = ""; } - if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); - } - - throw new Error("Debug Failure. False expression: " + message + verboseDebugString); - } - }; - - Debug.fail = function (message) { - Debug.assert(false, message); - }; - Debug.currentAssertionLevel = 0 /* None */; - return Debug; - })(); - 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 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(); - result.length = this.length(); - - result.diagnosticCode = this._diagnosticKey; - - var _arguments = this.arguments(); - if (_arguments && _arguments.length > 0) { - result.arguments = _arguments; - } - - return result; - }; - - Diagnostic.prototype.diagnosticKey = function () { - return this._diagnosticKey; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.additionalLocations = function () { - return this._additionalLocations || []; - }; - - Diagnostic.equals = function (diagnostic1, diagnostic2) { - return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { - return v1 === v2; - }); - }; - - Diagnostic.prototype.info = function () { - return getDiagnosticInfoFromKey(this.diagnosticKey()); - }; - return Diagnostic; - })(Location); - TypeScript.Diagnostic = Diagnostic; - - function newLine() { - return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; - } - TypeScript.newLine = newLine; - - function getLargestIndex(diagnostic) { - var largest = -1; - var regex = /\{(\d+)\}/g; - - var match; - while (match = regex.exec(diagnostic)) { - var val = parseInt(match[1]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromKey(diagnosticKey) { - var result = TypeScript.diagnosticInformationMap[diagnosticKey]; - TypeScript.Debug.assert(result); - return result; - } - - function getLocalizedText(diagnosticKey, args) { - if (TypeScript.LocalizedDiagnosticMessages) { - } - - var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; - TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); - - var actualCount = args ? args.length : 0; - - var expectedCount = 1 + getLargestIndex(diagnosticKey); - - if (expectedCount !== actualCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); - } - - var valueCount = 1 + getLargestIndex(diagnosticMessageText); - if (valueCount !== expectedCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); - } - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return TypeScript.newLine(); - }); - - return diagnosticMessageText; - } - TypeScript.getLocalizedText = getLocalizedText; - - function getDiagnosticMessage(diagnosticKey, args) { - var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); - var diagnosticMessageText = getLocalizedText(diagnosticKey, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + ". " + message); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error("Invalid operation: " + message); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2StringHashCode = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key.charCodeAt(index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, - 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, - 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, - 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, - 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, - 4166287, 4999559, 5999471, 7199369]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 1024; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash) { - this.hash = hash; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode >= 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', "Key was already in table."); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && key === e.Key) { - return e; - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count >= (this.entries.length / 2)) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - return new HashTable(capacity, hash); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - TypeScript.nodeMakeDirectoryTime = 0; - TypeScript.nodeCreateBufferTime = 0; - TypeScript.nodeWriteFileSyncTime = 0; - - (function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; - })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); - var ByteOrderMark = TypeScript.ByteOrderMark; - - var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this.contents = contents; - this.byteOrderMark = byteOrderMark; - } - return FileInformation; - })(); - TypeScript.FileInformation = FileInformation; - - TypeScript.Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - newLine: "\r\n", - currentDirectory: function () { - return WScript.CreateObject("WScript.Shell").CurrentDirectory; - }, - supportsCodePage: function () { - return WScript.ReadFile; - }, - readFile: function (path, codepage) { - try { - if (codepage !== null && this.supportsCodePage()) { - try { - var contents = WScript.ReadFile(path, codepage); - return new FileInformation(contents, 0 /* None */); - } catch (e) { - } - } - - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - var message; - if (err.number === -2147024809) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); - } - - throw new Error(message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - var _os = require('os'); - - return { - newLine: _os.EOL, - currentDirectory: function () { - return process.cwd(); - }, - supportsCodePage: function () { - return false; - }, - readFile: function (file, codepage) { - if (codepage !== null) { - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); - } - - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 509); - } - } - var start = new Date().getTime(); - mkdirRecursiveSync(_path.dirname(path)); - TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - - var start = new Date().getTime(); - - var chunkLength = 4 * 1024; - var fileDescriptor = _fs.openSync(path, "w"); - try { - for (var index = 0; index < contents.length; index += chunkLength) { - var bufferStart = new Date().getTime(); - var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); - TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; - - _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); - } - } finally { - _fs.closeSync(fileDescriptor); - } - - TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IntegerUtilities) { - function integerDivide(numerator, denominator) { - return (numerator / denominator) >> 0; - } - IntegerUtilities.integerDivide = integerDivide; - - function integerMultiplyLow32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - } - IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; - - function integerMultiplyHigh32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - } - IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; - - function isInteger(text) { - return /^[0-9]+$/.test(text); - } - IntegerUtilities.isInteger = isInteger; - - function isHexInteger(text) { - return /^0(x|X)[0-9a-fA-F]+$/.test(text); - } - IntegerUtilities.isHexInteger = isHexInteger; - })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); - var IntegerUtilities = TypeScript.IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_computeLineStarts, length) { - this._computeLineStarts = _computeLineStarts; - this.length = length; - this._lineStarts = null; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this.lineStarts(), length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - if (this._lineStarts === null) { - this._lineStarts = this._computeLineStarts(); - } - - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - LineMap.empty = new LineMap(function () { - return [0]; - }, 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { - return e; - } - } - - return null; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - if (text.length !== length) { - return false; - } - - var s = start; - for (var i = 0; i < length; i++) { - if (text.charCodeAt(i) !== array[s]) { - return false; - } - - s++; - } - - return true; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticInformationMap = { - "error TS{0}: {1}": { - "code": 0, - "category": 3 /* NoPrefix */ - }, - "warning TS{0}: {1}": { - "code": 1, - "category": 3 /* NoPrefix */ - }, - "Unrecognized escape sequence.": { - "code": 1000, - "category": 1 /* Error */ - }, - "Unexpected character {0}.": { - "code": 1001, - "category": 1 /* Error */ - }, - "Missing close quote character.": { - "code": 1002, - "category": 1 /* Error */ - }, - "Identifier expected.": { - "code": 1003, - "category": 1 /* Error */ - }, - "'{0}' keyword expected.": { - "code": 1004, - "category": 1 /* Error */ - }, - "'{0}' expected.": { - "code": 1005, - "category": 1 /* Error */ - }, - "Identifier expected; '{0}' is a keyword.": { - "code": 1006, - "category": 1 /* Error */ - }, - "Automatic semicolon insertion not allowed.": { - "code": 1007, - "category": 1 /* Error */ - }, - "Unexpected token; '{0}' expected.": { - "code": 1008, - "category": 1 /* Error */ - }, - "Trailing separator not allowed.": { - "code": 1009, - "category": 1 /* Error */ - }, - "'*/' expected.": { - "code": 1010, - "category": 1 /* Error */ - }, - "'public' or 'private' modifier must precede 'static'.": { - "code": 1011, - "category": 1 /* Error */ - }, - "Unexpected token.": { - "code": 1012, - "category": 1 /* Error */ - }, - "Catch clause parameter cannot have a type annotation.": { - "code": 1013, - "category": 1 /* Error */ - }, - "Rest parameter must be last in list.": { - "code": 1014, - "category": 1 /* Error */ - }, - "Parameter cannot have question mark and initializer.": { - "code": 1015, - "category": 1 /* Error */ - }, - "Required parameter cannot follow optional parameter.": { - "code": 1016, - "category": 1 /* Error */ - }, - "Index signatures cannot have rest parameters.": { - "code": 1017, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have accessibility modifiers.": { - "code": 1018, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have a question mark.": { - "code": 1019, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have an initializer.": { - "code": 1020, - "category": 1 /* Error */ - }, - "Index signature must have a type annotation.": { - "code": 1021, - "category": 1 /* Error */ - }, - "Index signature parameter must have a type annotation.": { - "code": 1022, - "category": 1 /* Error */ - }, - "Index signature parameter type must be 'string' or 'number'.": { - "code": 1023, - "category": 1 /* Error */ - }, - "'extends' clause already seen.": { - "code": 1024, - "category": 1 /* Error */ - }, - "'extends' clause must precede 'implements' clause.": { - "code": 1025, - "category": 1 /* Error */ - }, - "Classes can only extend a single class.": { - "code": 1026, - "category": 1 /* Error */ - }, - "'implements' clause already seen.": { - "code": 1027, - "category": 1 /* Error */ - }, - "Accessibility modifier already seen.": { - "code": 1028, - "category": 1 /* Error */ - }, - "'{0}' modifier must precede '{1}' modifier.": { - "code": 1029, - "category": 1 /* Error */ - }, - "'{0}' modifier already seen.": { - "code": 1030, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a class element.": { - "code": 1031, - "category": 1 /* Error */ - }, - "Interface declaration cannot have 'implements' clause.": { - "code": 1032, - "category": 1 /* Error */ - }, - "'super' invocation cannot have type arguments.": { - "code": 1034, - "category": 1 /* Error */ - }, - "Only ambient modules can use quoted names.": { - "code": 1035, - "category": 1 /* Error */ - }, - "Statements are not allowed in ambient contexts.": { - "code": 1036, - "category": 1 /* Error */ - }, - "Implementations are not allowed in ambient contexts.": { - "code": 1037, - "category": 1 /* Error */ - }, - "'declare' modifier not allowed for code already in an ambient context.": { - "code": 1038, - "category": 1 /* Error */ - }, - "Initializers are not allowed in ambient contexts.": { - "code": 1039, - "category": 1 /* Error */ - }, - "Parameter property declarations can only be used in a non-ambient constructor declaration.": { - "code": 1040, - "category": 1 /* Error */ - }, - "Function implementation expected.": { - "code": 1041, - "category": 1 /* Error */ - }, - "Constructor implementation expected.": { - "code": 1042, - "category": 1 /* Error */ - }, - "Function overload name must be '{0}'.": { - "code": 1043, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a module element.": { - "code": 1044, - "category": 1 /* Error */ - }, - "'declare' modifier cannot appear on an interface declaration.": { - "code": 1045, - "category": 1 /* Error */ - }, - "'declare' modifier required for top level element.": { - "code": 1046, - "category": 1 /* Error */ - }, - "Rest parameter cannot be optional.": { - "code": 1047, - "category": 1 /* Error */ - }, - "Rest parameter cannot have an initializer.": { - "code": 1048, - "category": 1 /* Error */ - }, - "'set' accessor must have one and only one parameter.": { - "code": 1049, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot be optional.": { - "code": 1051, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot have an initializer.": { - "code": 1052, - "category": 1 /* Error */ - }, - "'set' accessor cannot have rest parameter.": { - "code": 1053, - "category": 1 /* Error */ - }, - "'get' accessor cannot have parameters.": { - "code": 1054, - "category": 1 /* Error */ - }, - "Modifiers cannot appear here.": { - "code": 1055, - "category": 1 /* Error */ - }, - "Accessors are only available when targeting ECMAScript 5 and higher.": { - "code": 1056, - "category": 1 /* Error */ - }, - "Class name cannot be '{0}'.": { - "code": 1057, - "category": 1 /* Error */ - }, - "Interface name cannot be '{0}'.": { - "code": 1058, - "category": 1 /* Error */ - }, - "Enum name cannot be '{0}'.": { - "code": 1059, - "category": 1 /* Error */ - }, - "Module name cannot be '{0}'.": { - "code": 1060, - "category": 1 /* Error */ - }, - "Enum member must have initializer.": { - "code": 1061, - "category": 1 /* Error */ - }, - "Export assignment cannot be used in internal modules.": { - "code": 1063, - "category": 1 /* Error */ - }, - "Export assignment not allowed in module with exported element.": { - "code": 1064, - "category": 1 /* Error */ - }, - "Module cannot have multiple export assignments.": { - "code": 1065, - "category": 1 /* Error */ - }, - "Ambient enum elements can only have integer literal initializers.": { - "code": 1066, - "category": 1 /* Error */ - }, - "module, class, interface, enum, import or statement": { - "code": 1067, - "category": 3 /* NoPrefix */ - }, - "constructor, function, accessor or variable": { - "code": 1068, - "category": 3 /* NoPrefix */ - }, - "statement": { - "code": 1069, - "category": 3 /* NoPrefix */ - }, - "case or default clause": { - "code": 1070, - "category": 3 /* NoPrefix */ - }, - "identifier": { - "code": 1071, - "category": 3 /* NoPrefix */ - }, - "call, construct, index, property or function signature": { - "code": 1072, - "category": 3 /* NoPrefix */ - }, - "expression": { - "code": 1073, - "category": 3 /* NoPrefix */ - }, - "type name": { - "code": 1074, - "category": 3 /* NoPrefix */ - }, - "property or accessor": { - "code": 1075, - "category": 3 /* NoPrefix */ - }, - "parameter": { - "code": 1076, - "category": 3 /* NoPrefix */ - }, - "type": { - "code": 1077, - "category": 3 /* NoPrefix */ - }, - "type parameter": { - "code": 1078, - "category": 3 /* NoPrefix */ - }, - "'declare' modifier not allowed on import declaration.": { - "code": 1079, - "category": 1 /* Error */ - }, - "Function overload must be static.": { - "code": 1080, - "category": 1 /* Error */ - }, - "Function overload must not be static.": { - "code": 1081, - "category": 1 /* Error */ - }, - "Parameter property declarations cannot be used in a constructor overload.": { - "code": 1083, - "category": 1 /* Error */ - }, - "Invalid 'reference' directive syntax.": { - "code": 1084, - "category": 1 /* Error */ - }, - "Octal literals are not available when targeting ECMAScript 5 and higher.": { - "code": 1085, - "category": 1 /* Error */ - }, - "Accessors are not allowed in ambient contexts.": { - "code": 1086, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a constructor declaration.": { - "code": 1089, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a parameter.": { - "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 */ - }, - "The name '{0}' does not exist in the current scope.": { - "code": 2001, - "category": 1 /* Error */ - }, - "The name '{0}' does not refer to a value.": { - "code": 2002, - "category": 1 /* Error */ - }, - "'super' can only be used inside a class instance method.": { - "code": 2003, - "category": 1 /* Error */ - }, - "The left-hand side of an assignment expression must be a variable, property or indexer.": { - "code": 2004, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable. Did you mean to include 'new'?": { - "code": 2161, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable.": { - "code": 2006, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not newable.": { - "code": 2007, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not indexable by type '{1}'.": { - "code": 2008, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { - "code": 2009, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { - "code": 2010, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}'.": { - "code": 2011, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}':{NL}{2}": { - "code": 2012, - "category": 1 /* Error */ - }, - "Expected var, class, interface, or module.": { - "code": 2013, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to type '{1}'.": { - "code": 2014, - "category": 1 /* Error */ - }, - "Getter '{0}' already declared.": { - "code": 2015, - "category": 1 /* Error */ - }, - "Setter '{0}' already declared.": { - "code": 2016, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends private class '{1}'.": { - "code": 2018, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements private interface '{1}'.": { - "code": 2019, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends private interface '{1}'.": { - "code": 2020, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends class from inaccessible module {1}.": { - "code": 2021, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements interface from inaccessible module {1}.": { - "code": 2022, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends interface from inaccessible module {1}.": { - "code": 2023, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2024, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2025, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2026, - "category": 1 /* Error */ - }, - "Exported variable '{0}' has or is using private type '{1}'.": { - "code": 2027, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2028, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2029, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2030, - "category": 1 /* Error */ - }, - "Exported variable '{0}' is using inaccessible module {1}.": { - "code": 2031, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { - "code": 2032, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { - "code": 2033, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { - "code": 2034, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2035, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2036, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2037, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2038, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2039, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2040, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { - "code": 2041, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { - "code": 2042, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { - "code": 2043, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2044, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2045, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2046, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2047, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2048, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2049, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class has or is using private type '{0}'.": { - "code": 2050, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class has or is using private type '{0}'.": { - "code": 2051, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface has or is using private type '{0}'.": { - "code": 2052, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface has or is using private type '{0}'.": { - "code": 2053, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface has or is using private type '{0}'.": { - "code": 2054, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class has or is using private type '{0}'.": { - "code": 2055, - "category": 1 /* Error */ - }, - "Return type of public method from exported class has or is using private type '{0}'.": { - "code": 2056, - "category": 1 /* Error */ - }, - "Return type of method from exported interface has or is using private type '{0}'.": { - "code": 2057, - "category": 1 /* Error */ - }, - "Return type of exported function has or is using private type '{0}'.": { - "code": 2058, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class is using inaccessible module {0}.": { - "code": 2059, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class is using inaccessible module {0}.": { - "code": 2060, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface is using inaccessible module {0}.": { - "code": 2061, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface is using inaccessible module {0}.": { - "code": 2062, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface is using inaccessible module {0}.": { - "code": 2063, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class is using inaccessible module {0}.": { - "code": 2064, - "category": 1 /* Error */ - }, - "Return type of public method from exported class is using inaccessible module {0}.": { - "code": 2065, - "category": 1 /* Error */ - }, - "Return type of method from exported interface is using inaccessible module {0}.": { - "code": 2066, - "category": 1 /* Error */ - }, - "Return type of exported function is using inaccessible module {0}.": { - "code": 2067, - "category": 1 /* Error */ - }, - "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { - "code": 2068, - "category": 1 /* Error */ - }, - "A parameter list must follow a generic type argument list. '(' expected.": { - "code": 2069, - "category": 1 /* Error */ - }, - "Multiple constructor implementations are not allowed.": { - "code": 2070, - "category": 1 /* Error */ - }, - "Unable to resolve external module '{0}'.": { - "code": 2071, - "category": 1 /* Error */ - }, - "Module cannot be aliased to a non-module type.": { - "code": 2072, - "category": 1 /* Error */ - }, - "A class may only extend another class.": { - "code": 2073, - "category": 1 /* Error */ - }, - "A class may only implement another class or interface.": { - "code": 2074, - "category": 1 /* Error */ - }, - "An interface may only extend another class or interface.": { - "code": 2075, - "category": 1 /* Error */ - }, - "Unable to resolve type.": { - "code": 2077, - "category": 1 /* Error */ - }, - "Unable to resolve type of '{0}'.": { - "code": 2078, - "category": 1 /* Error */ - }, - "Unable to resolve type parameter constraint.": { - "code": 2079, - "category": 1 /* Error */ - }, - "Type parameter constraint cannot be a primitive type.": { - "code": 2080, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target.": { - "code": 2081, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target:{NL}{0}": { - "code": 2082, - "category": 1 /* Error */ - }, - "Invalid 'new' expression.": { - "code": 2083, - "category": 1 /* Error */ - }, - "Call signatures used in a 'new' expression must have a 'void' return type.": { - "code": 2084, - "category": 1 /* Error */ - }, - "Could not select overload for 'new' expression.": { - "code": 2085, - "category": 1 /* Error */ - }, - "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { - "code": 2086, - "category": 1 /* Error */ - }, - "Could not select overload for 'call' expression.": { - "code": 2087, - "category": 1 /* Error */ - }, - "Cannot invoke an expression whose type lacks a call signature.": { - "code": 2088, - "category": 1 /* Error */ - }, - "Calls to 'super' are only valid inside a class.": { - "code": 2089, - "category": 1 /* Error */ - }, - "Generic type '{0}' requires {1} type argument(s).": { - "code": 2090, - "category": 1 /* Error */ - }, - "Type of array literal cannot be determined. Best common type could not be found for array elements.": { - "code": 2092, - "category": 1 /* Error */ - }, - "Could not find enclosing symbol for dotted name '{0}'.": { - "code": 2093, - "category": 1 /* Error */ - }, - "The property '{0}' does not exist on value of type '{1}'.": { - "code": 2094, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}'.": { - "code": 2095, - "category": 1 /* Error */ - }, - "'get' and 'set' accessor must have the same type.": { - "code": 2096, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in current location.": { - "code": 2097, - "category": 1 /* Error */ - }, - "Static members cannot reference class type parameters.": { - "code": 2099, - "category": 1 /* Error */ - }, - "Class '{0}' is recursively referenced as a base type of itself.": { - "code": 2100, - "category": 1 /* Error */ - }, - "Interface '{0}' is recursively referenced as a base type of itself.": { - "code": 2101, - "category": 1 /* Error */ - }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { - "code": 2102, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in non-derived classes.": { - "code": 2103, - "category": 1 /* Error */ - }, - "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { - "code": 2104, - "category": 1 /* Error */ - }, - "Constructors for derived classes must contain a 'super' call.": { - "code": 2105, - "category": 1 /* Error */ - }, - "Super calls are not permitted outside constructors or in local functions inside constructors.": { - "code": 2106, - "category": 1 /* Error */ - }, - "'{0}.{1}' is inaccessible.": { - "code": 2107, - "category": 1 /* Error */ - }, - "'this' cannot be referenced within module bodies.": { - "code": 2108, - "category": 1 /* Error */ - }, - "Invalid '+' expression - types not known to support the addition operator.": { - "code": 2111, - "category": 1 /* Error */ - }, - "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2112, - "category": 1 /* Error */ - }, - "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2113, - "category": 1 /* Error */ - }, - "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { - "code": 2114, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement cannot use a type annotation.": { - "code": 2115, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { - "code": 2116, - "category": 1 /* Error */ - }, - "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { - "code": 2117, - "category": 1 /* Error */ - }, - "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { - "code": 2118, - "category": 1 /* Error */ - }, - "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { - "code": 2119, - "category": 1 /* Error */ - }, - "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { - "code": 2120, - "category": 1 /* Error */ - }, - "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 */ - }, - "Setters cannot return a value.": { - "code": 2122, - "category": 1 /* Error */ - }, - "Tried to query type of uninitialized module '{0}'.": { - "code": 2123, - "category": 1 /* Error */ - }, - "Tried to set variable type to uninitialized module type '{0}'.": { - "code": 2124, - "category": 1 /* Error */ - }, - "Type '{0}' does not have type parameters.": { - "code": 2125, - "category": 1 /* Error */ - }, - "Getters must return a value.": { - "code": 2126, - "category": 1 /* Error */ - }, - "Getter and setter accessors do not agree in visibility.": { - "code": 2127, - "category": 1 /* Error */ - }, - "Invalid left-hand side of assignment expression.": { - "code": 2130, - "category": 1 /* Error */ - }, - "Function declared a non-void return type, but has no return expression.": { - "code": 2131, - "category": 1 /* Error */ - }, - "Cannot resolve return type reference.": { - "code": 2132, - "category": 1 /* Error */ - }, - "Constructors cannot have a return type of 'void'.": { - "code": 2133, - "category": 1 /* Error */ - }, - "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { - "code": 2134, - "category": 1 /* Error */ - }, - "All symbols within a with block will be resolved to 'any'.": { - "code": 2135, - "category": 1 /* Error */ - }, - "Import declarations in an internal module cannot reference an external module.": { - "code": 2136, - "category": 1 /* Error */ - }, - "Class {0} declares interface {1} but does not implement it:{NL}{2}": { - "code": 2137, - "category": 1 /* Error */ - }, - "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { - "code": 2138, - "category": 1 /* Error */ - }, - "The operand of an increment or decrement operator must be a variable, property or indexer.": { - "code": 2139, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in static initializers in a class body.": { - "code": 2140, - "category": 1 /* Error */ - }, - "Class '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2141, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2142, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { - "code": 2143, - "category": 1 /* Error */ - }, - "Duplicate overload signature for '{0}'.": { - "code": 2144, - "category": 1 /* Error */ - }, - "Duplicate constructor overload signature.": { - "code": 2145, - "category": 1 /* Error */ - }, - "Duplicate overload call signature.": { - "code": 2146, - "category": 1 /* Error */ - }, - "Duplicate overload construct signature.": { - "code": 2147, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition.": { - "code": 2148, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition:{NL}{0}": { - "code": 2149, - "category": 1 /* Error */ - }, - "Overload signatures must all be public or private.": { - "code": 2150, - "category": 1 /* Error */ - }, - "Overload signatures must all be exported or not exported.": { - "code": 2151, - "category": 1 /* Error */ - }, - "Overload signatures must all be ambient or non-ambient.": { - "code": 2152, - "category": 1 /* Error */ - }, - "Overload signatures must all be optional or required.": { - "code": 2153, - "category": 1 /* Error */ - }, - "Specialized overload signature is not assignable to any non-specialized signature.": { - "code": 2154, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in constructor arguments.": { - "code": 2155, - "category": 1 /* Error */ - }, - "Instance member cannot be accessed off a class.": { - "code": 2157, - "category": 1 /* Error */ - }, - "Untyped function calls may not accept type arguments.": { - "code": 2158, - "category": 1 /* Error */ - }, - "Non-generic functions may not accept type arguments.": { - "code": 2159, - "category": 1 /* Error */ - }, - "A generic type may not reference itself with a wrapped form of its own type parameters.": { - "code": 2160, - "category": 1 /* Error */ - }, - "Rest parameters must be array types.": { - "code": 2162, - "category": 1 /* Error */ - }, - "Overload signature implementation cannot use specialized type.": { - "code": 2163, - "category": 1 /* Error */ - }, - "Export assignments may only be used at the top-level of external modules.": { - "code": 2164, - "category": 1 /* Error */ - }, - "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2165, - "category": 1 /* Error */ - }, - "Only public methods of the base class are accessible via the 'super' keyword.": { - "code": 2166, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { - "code": 2167, - "category": 1 /* Error */ - }, - "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 assignable to numeric indexer type '{0}'.": { - "code": 2169, - "category": 1 /* Error */ - }, - "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { - "code": 2170, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}'.": { - "code": 2171, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { - "code": 2172, - "category": 1 /* Error */ - }, - "Generic type references must include all type arguments.": { - "code": 2173, - "category": 1 /* Error */ - }, - "Default arguments are only allowed in implementation.": { - "code": 2174, - "category": 1 /* Error */ - }, - "Overloads cannot differ only by return type.": { - "code": 2175, - "category": 1 /* Error */ - }, - "Function expression declared a non-void return type, but has no return expression.": { - "code": 2176, - "category": 1 /* Error */ - }, - "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2177, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}' in module '{1}'.": { - "code": 2178, - "category": 1 /* Error */ - }, - "Unable to resolve module reference '{0}'.": { - "code": 2179, - "category": 1 /* Error */ - }, - "Could not find module '{0}' in module '{1}'.": { - "code": 2180, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { - "code": 2181, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { - "code": 2182, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { - "code": 2183, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { - "code": 2184, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { - "code": 2185, - "category": 1 /* Error */ - }, - "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { - "code": 2186, - "category": 1 /* Error */ - }, - "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { - "code": 2187, - "category": 1 /* Error */ - }, - "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { - "code": 2188, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { - "code": 2189, - "category": 1 /* Error */ - }, - "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { - "code": 2190, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot be reopened.": { - "code": 2191, - "category": 1 /* Error */ - }, - "All declarations of merged declaration '{0}' must be exported or not exported.": { - "code": 2192, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in constructor arguments.": { - "code": 2193, - "category": 1 /* Error */ - }, - "Return type of constructor signature must be assignable to the instance type of the class.": { - "code": 2194, - "category": 1 /* Error */ - }, - "Ambient external module declaration must be defined in global context.": { - "code": 2195, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot specify relative module name.": { - "code": 2196, - "category": 1 /* Error */ - }, - "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { - "code": 2197, - "category": 1 /* Error */ - }, - "Could not find the best common type of types of all return statement expressions.": { - "code": 2198, - "category": 1 /* Error */ - }, - "Import declaration cannot refer to external module reference when --noResolve option is set.": { - "code": 2199, - "category": 1 /* Error */ - }, - "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { - "code": 2200, - "category": 1 /* Error */ - }, - "'continue' statement can only be used within an enclosing iteration statement.": { - "code": 2201, - "category": 1 /* Error */ - }, - "'break' statement can only be used within an enclosing iteration or switch statement.": { - "code": 2202, - "category": 1 /* Error */ - }, - "Jump target not found.": { - "code": 2203, - "category": 1 /* Error */ - }, - "Jump target cannot cross function boundary.": { - "code": 2204, - "category": 1 /* Error */ - }, - "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { - "code": 2205, - "category": 1 /* Error */ - }, - "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { - "code": 2206, - "category": 1 /* Error */ - }, - "Expression resolves to '_super' that compiler uses to capture base class reference.": { - "code": 2207, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2208, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2209, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2210, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2211, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2212, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2213, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2214, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2215, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2216, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2217, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2218, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2219, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { - "code": 2220, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2221, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { - "code": 2222, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2223, - "category": 1 /* Error */ - }, - "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { - "code": 2224, - "category": 1 /* Error */ - }, - "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { - "code": 2225, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { - "code": 2226, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { - "code": 2227, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { - "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 */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { - "code": 4001, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { - "code": 4002, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { - "code": 4003, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { - "code": 4004, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' define property '{2}' as private.": { - "code": 4005, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4006, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4007, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a call signature, but type '{1}' lacks one.": { - "code": 4008, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4009, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4010, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { - "code": 4011, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4012, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4013, - "category": 3 /* NoPrefix */ - }, - "Call signature expects {0} or fewer parameters.": { - "code": 4014, - "category": 3 /* NoPrefix */ - }, - "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { - "code": 4015, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4016, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4017, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { - "code": 4018, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { - "code": 4019, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { - "code": 4020, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { - "code": 4021, - "category": 3 /* NoPrefix */ - }, - "Type reference cannot refer to container '{0}'.": { - "code": 4022, - "category": 1 /* Error */ - }, - "Type reference must refer to type.": { - "code": 4023, - "category": 1 /* Error */ - }, - "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { - "code": 4024, - "category": 1 /* Error */ - }, - " (+ {0} overload(s))": { - "code": 4025, - "category": 2 /* Message */ - }, - "Variable declaration cannot have the same name as an import declaration.": { - "code": 4026, - "category": 1 /* Error */ - }, - "Signature expected {0} type arguments, got {1} instead.": { - "code": 4027, - "category": 1 /* Error */ - }, - "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { - "code": 4028, - "category": 3 /* NoPrefix */ - }, - "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 infinitely expanding type reference have incompatible type arguments.": { - "code": 4030, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { - "code": 4031, - "category": 3 /* NoPrefix */ - }, - "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { - "code": 4032, - "category": 3 /* NoPrefix */ - }, - "Types of string indexer of types '{0}' and '{1}' are not identical.": { - "code": 4033, - "category": 3 /* NoPrefix */ - }, - "Types of number indexer of types '{0}' and '{1}' are not identical.": { - "code": 4034, - "category": 3 /* NoPrefix */ - }, - "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 assignable to string indexer type in type '{2}'.{NL}{3}": { - "code": 4036, - "category": 3 /* NoPrefix */ - }, - "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 */ - }, - "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { - "code": 5002, - "category": 1 /* Error */ - }, - "Module code generation '{0}' not supported.": { - "code": 5003, - "category": 1 /* Error */ - }, - "Could not find file: '{0}'.": { - "code": 5004, - "category": 1 /* Error */ - }, - "A file cannot have a reference to itself.": { - "code": 5006, - "category": 1 /* Error */ - }, - "Cannot resolve referenced file: '{0}'.": { - "code": 5007, - "category": 1 /* Error */ - }, - "Cannot find the common subdirectory path for the input files.": { - "code": 5009, - "category": 1 /* Error */ - }, - "Emit Error: {0}.": { - "code": 5011, - "category": 1 /* Error */ - }, - "Cannot read file '{0}': {1}": { - "code": 5012, - "category": 1 /* Error */ - }, - "Unsupported file encoding.": { - "code": 5013, - "category": 3 /* NoPrefix */ - }, - "Locale must be of the form or -. For example '{0}' or '{1}'.": { - "code": 5014, - "category": 1 /* Error */ - }, - "Unsupported locale: '{0}'.": { - "code": 5015, - "category": 1 /* Error */ - }, - "Execution Failed.{NL}": { - "code": 5016, - "category": 1 /* Error */ - }, - "Invalid call to 'up'": { - "code": 5019, - "category": 1 /* Error */ - }, - "Invalid call to 'down'": { - "code": 5020, - "category": 1 /* Error */ - }, - "Base64 value '{0}' finished with a continuation bit.": { - "code": 5021, - "category": 1 /* Error */ - }, - "Unknown option '{0}'": { - "code": 5023, - "category": 1 /* Error */ - }, - "Expected {0} arguments to message, got {1} instead.": { - "code": 5024, - "category": 1 /* Error */ - }, - "Expected the message '{0}' to have {1} arguments, but it had {2}": { - "code": 5025, - "category": 1 /* Error */ - }, - "Could not delete file '{0}'": { - "code": 5034, - "category": 1 /* Error */ - }, - "Could not create directory '{0}'": { - "code": 5035, - "category": 1 /* Error */ - }, - "Error while executing file '{0}': ": { - "code": 5036, - "category": 1 /* Error */ - }, - "Cannot compile external modules unless the '--module' flag is provided.": { - "code": 5037, - "category": 1 /* Error */ - }, - "Option mapRoot cannot be specified without specifying sourcemap option.": { - "code": 5038, - "category": 1 /* Error */ - }, - "Option sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5039, - "category": 1 /* Error */ - }, - "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5040, - "category": 1 /* Error */ - }, - "Option '{0}' specified without '{1}'": { - "code": 5041, - "category": 1 /* Error */ - }, - "'codepage' option not supported on current platform.": { - "code": 5042, - "category": 1 /* Error */ - }, - "Concatenate and emit output to single file.": { - "code": 6001, - "category": 2 /* Message */ - }, - "Generates corresponding {0} file.": { - "code": 6002, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate map files instead of generated locations.": { - "code": 6003, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate TypeScript files instead of source locations.": { - "code": 6004, - "category": 2 /* Message */ - }, - "Watch input files.": { - "code": 6005, - "category": 2 /* Message */ - }, - "Redirect output structure to the directory.": { - "code": 6006, - "category": 2 /* Message */ - }, - "Do not emit comments to output.": { - "code": 6009, - "category": 2 /* Message */ - }, - "Skip resolution and preprocessing.": { - "code": 6010, - "category": 2 /* Message */ - }, - "Specify ECMAScript target version: '{0}' (default), or '{1}'": { - "code": 6015, - "category": 2 /* Message */ - }, - "Specify module code generation: '{0}' or '{1}'": { - "code": 6016, - "category": 2 /* Message */ - }, - "Print this message.": { - "code": 6017, - "category": 2 /* Message */ - }, - "Print the compiler's version: {0}": { - "code": 6019, - "category": 2 /* Message */ - }, - "Allow use of deprecated '{0}' keyword when referencing an external module.": { - "code": 6021, - "category": 2 /* Message */ - }, - "Specify locale for errors and messages. For example '{0}' or '{1}'": { - "code": 6022, - "category": 2 /* Message */ - }, - "Syntax: {0}": { - "code": 6023, - "category": 2 /* Message */ - }, - "options": { - "code": 6024, - "category": 2 /* Message */ - }, - "file1": { - "code": 6025, - "category": 2 /* Message */ - }, - "Examples:": { - "code": 6026, - "category": 2 /* Message */ - }, - "Options:": { - "code": 6027, - "category": 2 /* Message */ - }, - "Insert command line options and files from a file.": { - "code": 6030, - "category": 2 /* Message */ - }, - "Version {0}": { - "code": 6029, - "category": 2 /* Message */ - }, - "Use the '{0}' flag to see options.": { - "code": 6031, - "category": 2 /* Message */ - }, - "{NL}Recompiling ({0}):": { - "code": 6032, - "category": 2 /* Message */ - }, - "STRING": { - "code": 6033, - "category": 2 /* Message */ - }, - "KIND": { - "code": 6034, - "category": 2 /* Message */ - }, - "file2": { - "code": 6035, - "category": 2 /* Message */ - }, - "VERSION": { - "code": 6036, - "category": 2 /* Message */ - }, - "LOCATION": { - "code": 6037, - "category": 2 /* Message */ - }, - "DIRECTORY": { - "code": 6038, - "category": 2 /* Message */ - }, - "NUMBER": { - "code": 6039, - "category": 2 /* Message */ - }, - "Specify the codepage to use when opening source files.": { - "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 */ - }, - "Unknown rule.": { - "code": 7002, - "category": 1 /* Error */ - }, - "Invalid line number ({0})": { - "code": 7003, - "category": 1 /* Error */ - }, - "Warn on expressions and declarations with an implied 'any' type.": { - "code": 7004, - "category": 2 /* Message */ - }, - "Variable '{0}' implicitly has an 'any' type.": { - "code": 7005, - "category": 1 /* Error */ - }, - "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { - "code": 7006, - "category": 1 /* Error */ - }, - "Parameter '{0}' of function type implicitly has an 'any' type.": { - "code": 7007, - "category": 1 /* Error */ - }, - "Member '{0}' of object type implicitly has an 'any' type.": { - "code": 7008, - "category": 1 /* Error */ - }, - "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { - "code": 7009, - "category": 1 /* Error */ - }, - "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7010, - "category": 1 /* Error */ - }, - "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7011, - "category": 1 /* Error */ - }, - "Parameter '{0}' of lambda function implicitly has an 'any' type.": { - "code": 7012, - "category": 1 /* Error */ - }, - "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7013, - "category": 1 /* Error */ - }, - "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7014, - "category": 1 /* Error */ - }, - "Array Literal implicitly has an 'any' type from widening.": { - "code": 7015, - "category": 1 /* Error */ - }, - "'{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 = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - this._lineStartPositions = null; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - if (!this._lineStartPositions) { - this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); - } - - return this._lineStartPositions; - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LineMap1) { - function fromSimpleText(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return text.charCodeAt(index); - }, length: text.length() }); - }, text.length()); - } - LineMap1.fromSimpleText = fromSimpleText; - - function fromScriptSnapshot(scriptSnapshot) { - return new TypeScript.LineMap(function () { - return scriptSnapshot.getLineStartPositions(); - }, scriptSnapshot.getLength()); - } - LineMap1.fromScriptSnapshot = fromScriptSnapshot; - - function fromString(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts(text); - }, text.length); - } - LineMap1.fromString = fromString; - })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); - var LineMap1 = TypeScript.LineMap1; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextFactory) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - if (text === null) { - throw TypeScript.Errors.argumentNull('text'); - } - TypeScript.Debug.assert(lineBreakLength >= 0); - TypeScript.Debug.assert(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this._lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this._lineStarts(); - }, this.length()); - }; - - TextBase.prototype._lineStarts = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this._lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - this._lazyLineStarts = null; - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.substr = function (start, length, intern) { - var startInOriginalText = this.span.start() + start; - return this.text.substr(startInOriginalText, length, intern); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SubText.prototype._lineStarts = function () { - var _this = this; - if (!this._lazyLineStarts) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return _this.charCodeAt(index); - }, length: this.length() }); - } - - return this._lazyLineStarts; - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - this._lazyLineStarts = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - - StringText.prototype._lineStarts = function () { - if (this._lazyLineStarts === null) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); - } - - return this._lazyLineStarts; - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap1.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - this._lineMap = null; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - if (!this._lineMap) { - this._lineMap = TypeScript.LineMap1.fromString(this.value); - } - - return this._lineMap; - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this.scriptSnapshot.getLineStartPositions(); - }, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length; - - if (0 === length) { - var result = new Array(); - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = new Array(); - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (length < 0) { - TypeScript.Errors.argument("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Debug.assert(start >= 0); - TypeScript.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - var change0 = changes[0]; - - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - - oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - CharacterInfo.isOctalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 55 /* _7 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - - SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { - this._languageVersion = languageVersion; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - } - ParseOptions.prototype.toJSON = function (key) { - return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; - }; - - ParseOptions.prototype.languageVersion = function () { - return this._languageVersion; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; - - SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; - SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; - - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - - SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; - SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 62 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 63 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 64 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 65 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 67 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 66 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 68 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 69 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 70 /* OpenBraceToken */, - "}": 71 /* CloseBraceToken */, - "(": 72 /* OpenParenToken */, - ")": 73 /* CloseParenToken */, - "[": 74 /* OpenBracketToken */, - "]": 75 /* CloseBracketToken */, - ".": 76 /* DotToken */, - "...": 77 /* DotDotDotToken */, - ";": 78 /* SemicolonToken */, - ",": 79 /* CommaToken */, - "<": 80 /* LessThanToken */, - ">": 81 /* GreaterThanToken */, - "<=": 82 /* LessThanEqualsToken */, - ">=": 83 /* GreaterThanEqualsToken */, - "==": 84 /* EqualsEqualsToken */, - "=>": 85 /* EqualsGreaterThanToken */, - "!=": 86 /* ExclamationEqualsToken */, - "===": 87 /* EqualsEqualsEqualsToken */, - "!==": 88 /* ExclamationEqualsEqualsToken */, - "+": 89 /* PlusToken */, - "-": 90 /* MinusToken */, - "*": 91 /* AsteriskToken */, - "%": 92 /* PercentToken */, - "++": 93 /* PlusPlusToken */, - "--": 94 /* MinusMinusToken */, - "<<": 95 /* LessThanLessThanToken */, - ">>": 96 /* GreaterThanGreaterThanToken */, - ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 98 /* AmpersandToken */, - "|": 99 /* BarToken */, - "^": 100 /* CaretToken */, - "!": 101 /* ExclamationToken */, - "~": 102 /* TildeToken */, - "&&": 103 /* AmpersandAmpersandToken */, - "||": 104 /* BarBarToken */, - "?": 105 /* QuestionToken */, - ":": 106 /* ColonToken */, - "=": 107 /* EqualsToken */, - "+=": 108 /* PlusEqualsToken */, - "-=": 109 /* MinusEqualsToken */, - "*=": 110 /* AsteriskEqualsToken */, - "%=": 111 /* PercentEqualsToken */, - "<<=": 112 /* LessThanLessThanEqualsToken */, - ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 115 /* AmpersandEqualsToken */, - "|=": 116 /* BarEqualsToken */, - "^=": 117 /* CaretEqualsToken */, - "/": 118 /* SlashToken */, - "/=": 119 /* SlashEqualsToken */ - }; - - var kindToText = new Array(); - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[62 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 89 /* PlusToken */: - return 164 /* PlusExpression */; - case 90 /* MinusToken */: - return 165 /* NegateExpression */; - case 102 /* TildeToken */: - return 166 /* BitwiseNotExpression */; - case 101 /* ExclamationToken */: - return 167 /* LogicalNotExpression */; - case 93 /* PlusPlusToken */: - return 168 /* PreIncrementExpression */; - case 94 /* MinusMinusToken */: - return 169 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 93 /* PlusPlusToken */: - return 210 /* PostIncrementExpression */; - case 94 /* MinusMinusToken */: - return 211 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 91 /* AsteriskToken */: - return 205 /* MultiplyExpression */; - - case 118 /* SlashToken */: - return 206 /* DivideExpression */; - - case 92 /* PercentToken */: - return 207 /* ModuloExpression */; - - case 89 /* PlusToken */: - return 208 /* AddExpression */; - - case 90 /* MinusToken */: - return 209 /* SubtractExpression */; - - case 95 /* LessThanLessThanToken */: - return 202 /* LeftShiftExpression */; - - case 96 /* GreaterThanGreaterThanToken */: - return 203 /* SignedRightShiftExpression */; - - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - return 204 /* UnsignedRightShiftExpression */; - - case 80 /* LessThanToken */: - return 196 /* LessThanExpression */; - - case 81 /* GreaterThanToken */: - return 197 /* GreaterThanExpression */; - - case 82 /* LessThanEqualsToken */: - return 198 /* LessThanOrEqualExpression */; - - case 83 /* GreaterThanEqualsToken */: - return 199 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 200 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 201 /* InExpression */; - - case 84 /* EqualsEqualsToken */: - return 192 /* EqualsWithTypeConversionExpression */; - - case 86 /* ExclamationEqualsToken */: - return 193 /* NotEqualsWithTypeConversionExpression */; - - case 87 /* EqualsEqualsEqualsToken */: - return 194 /* EqualsExpression */; - - case 88 /* ExclamationEqualsEqualsToken */: - return 195 /* NotEqualsExpression */; - - case 98 /* AmpersandToken */: - return 191 /* BitwiseAndExpression */; - - case 100 /* CaretToken */: - return 190 /* BitwiseExclusiveOrExpression */; - - case 99 /* BarToken */: - return 189 /* BitwiseOrExpression */; - - case 103 /* AmpersandAmpersandToken */: - return 188 /* LogicalAndExpression */; - - case 104 /* BarBarToken */: - return 187 /* LogicalOrExpression */; - - case 116 /* BarEqualsToken */: - return 182 /* OrAssignmentExpression */; - - case 115 /* AmpersandEqualsToken */: - return 180 /* AndAssignmentExpression */; - - case 117 /* CaretEqualsToken */: - return 181 /* ExclusiveOrAssignmentExpression */; - - case 112 /* LessThanLessThanEqualsToken */: - return 183 /* LeftShiftAssignmentExpression */; - - case 113 /* GreaterThanGreaterThanEqualsToken */: - return 184 /* SignedRightShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 185 /* UnsignedRightShiftAssignmentExpression */; - - case 108 /* PlusEqualsToken */: - return 175 /* AddAssignmentExpression */; - - case 109 /* MinusEqualsToken */: - return 176 /* SubtractAssignmentExpression */; - - case 110 /* AsteriskEqualsToken */: - return 177 /* MultiplyAssignmentExpression */; - - case 119 /* SlashEqualsToken */: - return 178 /* DivideAssignmentExpression */; - - case 111 /* PercentEqualsToken */: - return 179 /* ModuloAssignmentExpression */; - - case 107 /* EqualsToken */: - return 174 /* AssignmentExpression */; - - case 79 /* CommaToken */: - return 173 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function getOperatorTokenFromBinaryExpression(tokenKind) { - switch (tokenKind) { - case 205 /* MultiplyExpression */: - return 91 /* AsteriskToken */; - - case 206 /* DivideExpression */: - return 118 /* SlashToken */; - - case 207 /* ModuloExpression */: - return 92 /* PercentToken */; - - case 208 /* AddExpression */: - return 89 /* PlusToken */; - - case 209 /* SubtractExpression */: - return 90 /* MinusToken */; - - case 202 /* LeftShiftExpression */: - return 95 /* LessThanLessThanToken */; - - case 203 /* SignedRightShiftExpression */: - return 96 /* GreaterThanGreaterThanToken */; - - case 204 /* UnsignedRightShiftExpression */: - return 97 /* GreaterThanGreaterThanGreaterThanToken */; - - case 196 /* LessThanExpression */: - return 80 /* LessThanToken */; - - case 197 /* GreaterThanExpression */: - return 81 /* GreaterThanToken */; - - case 198 /* LessThanOrEqualExpression */: - return 82 /* LessThanEqualsToken */; - - case 199 /* GreaterThanOrEqualExpression */: - return 83 /* GreaterThanEqualsToken */; - - case 200 /* InstanceOfExpression */: - return 30 /* InstanceOfKeyword */; - - case 201 /* InExpression */: - return 29 /* InKeyword */; - - case 192 /* EqualsWithTypeConversionExpression */: - return 84 /* EqualsEqualsToken */; - - case 193 /* NotEqualsWithTypeConversionExpression */: - return 86 /* ExclamationEqualsToken */; - - case 194 /* EqualsExpression */: - return 87 /* EqualsEqualsEqualsToken */; - - case 195 /* NotEqualsExpression */: - return 88 /* ExclamationEqualsEqualsToken */; - - case 191 /* BitwiseAndExpression */: - return 98 /* AmpersandToken */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 100 /* CaretToken */; - - case 189 /* BitwiseOrExpression */: - return 99 /* BarToken */; - - case 188 /* LogicalAndExpression */: - return 103 /* AmpersandAmpersandToken */; - - case 187 /* LogicalOrExpression */: - return 104 /* BarBarToken */; - - case 182 /* OrAssignmentExpression */: - return 116 /* BarEqualsToken */; - - case 180 /* AndAssignmentExpression */: - return 115 /* AmpersandEqualsToken */; - - case 181 /* ExclusiveOrAssignmentExpression */: - return 117 /* CaretEqualsToken */; - - case 183 /* LeftShiftAssignmentExpression */: - return 112 /* LessThanLessThanEqualsToken */; - - case 184 /* SignedRightShiftAssignmentExpression */: - return 113 /* GreaterThanGreaterThanEqualsToken */; - - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - - case 175 /* AddAssignmentExpression */: - return 108 /* PlusEqualsToken */; - - case 176 /* SubtractAssignmentExpression */: - return 109 /* MinusEqualsToken */; - - case 177 /* MultiplyAssignmentExpression */: - return 110 /* AsteriskEqualsToken */; - - case 178 /* DivideAssignmentExpression */: - return 119 /* SlashEqualsToken */; - - case 179 /* ModuloAssignmentExpression */: - return 111 /* PercentEqualsToken */; - - case 174 /* AssignmentExpression */: - return 107 /* EqualsToken */; - - case 173 /* CommaExpression */: - return 79 /* CommaToken */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; - - function isAnyDivideToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - isIdentifierPartCharacter[character] = true; - isNumericLiteralStart[character] = true; - } - } - - isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); - 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - 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 { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - 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(fullText, kind); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(text, start, isTrailing); - }; - - Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { - var trivia = new Array(); - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.slidingWindow.absoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(diagnostics); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(79 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(106 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(78 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(102 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(72 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(73 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(105 /* QuestionToken */); - } - - if (isNumericLiteralStart[character]) { - return this.scanNumericLiteral(diagnostics); - } - - if (isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifierOrKeyword(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var slidingWindow = this.slidingWindow; - var window = slidingWindow.window; - - var startIndex = slidingWindow.currentRelativeItemIndex; - var endIndex = slidingWindow.windowCount; - var currentIndex = startIndex; - var character = 0; - - while (currentIndex < endIndex) { - character = window[currentIndex]; - if (!isIdentifierPartCharacter[character]) { - break; - } - - currentIndex++; - } - - if (currentIndex === endIndex) { - return 0 /* None */; - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - return 0 /* None */; - } else { - var kind; - var identifierLength = currentIndex - startIndex; - if (isKeywordStartCharacter[firstCharacter]) { - kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); - } else { - kind = 11 /* IdentifierName */; - } - - slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); - - return kind; - } - }; - - Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - var sawUnicodeEscape = false; - - do { - var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); - sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - var length = this.slidingWindow.absoluteIndex() - startIndex; - var text = this.text.substr(startIndex, length, false); - var valueText = TypeScript.Syntax.massageEscapes(text); - - var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); - if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { - if (sawUnicodeEscape) { - return keywordKind | -2147483648 /* IsVariableWidthKeyword */; - } else { - return keywordKind; - } - } - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function (diagnostics) { - if (this.isHexNumericLiteral()) { - this.scanHexNumericLiteral(); - } else if (this.isOctalNumericLiteral()) { - this.scanOctalNumericLiteral(diagnostics); - } else { - this.scanDecimalNumericLiteral(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isOctalNumericLiteral = function () { - return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); - }; - - Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { - var position = this.absoluteIndex(); - - while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.languageVersion() >= 1 /* EcmaScript5 */) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); - } - }; - - Scanner.prototype.scanDecimalDigits = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - this.scanDecimalDigits(); - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - this.scanDecimalDigits(); - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - var nextChar1 = this.slidingWindow.peekItemN(1); - - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { - var nextChar2 = this.slidingWindow.peekItemN(2); - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } - } - } - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 82 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* LessThanLessThanEqualsToken */; - } else { - return 95 /* LessThanLessThanToken */; - } - } else { - return 80 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 104 /* BarBarToken */; - } else { - return 99 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* CaretEqualsToken */; - } else { - return 100 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 115 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 103 /* AmpersandAmpersandToken */; - } else { - return 98 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* PercentEqualsToken */; - } else { - return 92 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* MinusMinusToken */; - } else { - return 90 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 108 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 93 /* PlusPlusToken */; - } else { - return 89 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* AsteriskEqualsToken */; - } else { - return 91 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 87 /* EqualsEqualsEqualsToken */; - } else { - return 84 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 85 /* EqualsGreaterThanToken */; - } else { - return 107 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function (diagnostics) { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(diagnostics); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 77 /* DotDotDotToken */; - } else { - return 76 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 119 /* SlashEqualsToken */; - } else { - return 118 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 12 /* RegularExpressionLiteral */; - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* ExclamationEqualsEqualsToken */; - } else { - return 86 /* ExclamationEqualsToken */; - } - } else { - return 101 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - break; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - break; - - default: - break; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - this.scanUnicodeOrHexEscape(errors); - return true; - } - } - - this.slidingWindow.moveToNextItem(); - return false; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); - var errors = new Array(); - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 121 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 124 /* ArrayType */: - return parent.type === nodeOrToken; - case 220 /* CastExpression */: - return parent.type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - case 228 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return TypeScript.Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullEnd; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullEnd = positionedToken.fullEnd(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullEnd) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); - } - - fullEnd -= triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function findSkippedTokenOnLeft(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - - function isIntegerLiteral(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - Syntax.isIntegerLiteral = isIntegerLiteral; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = new Array(); - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return nodeOrToken.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - element.insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - element.insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - var firstToken = this.firstToken(); - return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.trailingTrivia = function () { - var lastToken = this.lastToken(); - return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - 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 === thisAsIndexable[name]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - var start = positionedToken.start(); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isExpression = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.requireKeyword = requireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.requireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { - return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { - return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.importKeyword; - case 2: - return this.identifier; - case 3: - return this.equalsToken; - case 4: - return this.moduleReference; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - - this._kind = kind; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.kind = function () { - return this._kind; - }; - - HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { - if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.name = name; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.name; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withName = function (name) { - return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { - if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.callSignature = callSignature; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 123 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeQuerySyntax = (function (_super) { - __extends(TypeQuerySyntax, _super); - function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.name = name; - } - TypeQuerySyntax.prototype.accept = function (visitor) { - return visitor.visitTypeQuery(this); - }; - - TypeQuerySyntax.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuerySyntax.prototype.childCount = function () { - return 2; - }; - - TypeQuerySyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeQuerySyntax.prototype.isType = function () { - return true; - }; - - TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { - if (this.typeOfKeyword === typeOfKeyword && this.name === name) { - return this; - } - - return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); - }; - - TypeQuerySyntax.create1 = function (name) { - return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); - }; - - TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.name); - }; - - TypeQuerySyntax.prototype.withName = function (name) { - return this.update(this.typeOfKeyword, name); - }; - - TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeQuerySyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeQuerySyntax = TypeQuerySyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 146 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.modifiers; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifiers = function (modifiers) { - return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - - this.arguments = _arguments; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 142 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 227 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 239 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.constructorKeyword = constructorKeyword; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.constructorKeyword; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - 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 */), CallSignatureSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var GetAccessorSyntax = (function (_super) { - __extends(GetAccessorSyntax, _super); - function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.getKeyword = getKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - } - GetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessor(this); - }; - - GetAccessorSyntax.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - - GetAccessorSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - GetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - GetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetAccessorSyntax.create1 = function (propertyName) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GetAccessorSyntax = GetAccessorSyntax; - - var SetAccessorSyntax = (function (_super) { - __extends(SetAccessorSyntax, _super); - function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.setKeyword = setKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - SetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessor(this); - }; - - SetAccessorSyntax.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - - SetAccessorSyntax.prototype.childCount = function () { - return 5; - }; - - SetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - SetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetAccessorSyntax.create1 = function (propertyName) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SetAccessorSyntax = SetAccessorSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var IndexMemberDeclarationSyntax = (function (_super) { - __extends(IndexMemberDeclarationSyntax, _super); - function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.indexSignature = indexSignature; - this.semicolonToken = semicolonToken; - } - IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexMemberDeclaration(this); - }; - - IndexMemberDeclarationSyntax.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - - IndexMemberDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.indexSignature; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexMemberDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { - if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { - return this; - } - - return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); - }; - - IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); - }; - - IndexMemberDeclarationSyntax.create1 = function (indexSignature) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { - return this.update(this.modifiers, indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.indexSignature, semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexMemberDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - this.colonToken = colonToken; - this.statements = statements; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - this.colonToken = colonToken; - this.statements = statements; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.doKeyword = doKeyword; - this.statement = statement; - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeQuery = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - 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) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var dedentThisTrivia = dedentNextWhitespace; - dedentNextWhitespace = false; - - if (dedentThisTrivia) { - if (trivia.kind() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - var indentNextTrivia = true; - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var indentThisTrivia = indentNextTrivia; - indentNextTrivia = false; - - switch (trivia.kind()) { - case 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(fullText, kind) { - this._fullText = fullText; - this.tokenKind = kind; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithNoTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - token.trailingTrivia().collectTextElements(elements); - } - - function getTriviaWidth(value) { - return value >>> 2 /* TriviaFullWidthShift */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function isExpression(token) { - switch (token.tokenKind) { - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - return true; - } - - return false; - } - Syntax.isExpression = isExpression; - - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - case 13 /* carriageReturn */: - var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { - i++; - } - continue; - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - Syntax.massageEscapes = massageEscapes; - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - return regularExpressionValue(text); - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function regularExpressionValue(text) { - try { - var lastSlash = text.lastIndexOf("/"); - var body = text.substring(1, lastSlash); - var flags = text.substring(lastSlash + 1); - return new RegExp(body, flags); - } catch (e) { - return null; - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - EmptyToken.prototype.isExpression = function () { - return isExpression(this); - }; - - EmptyToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - - RealizedToken.prototype.isExpression = function () { - return isExpression(this); - }; - - RealizedToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var AbstractTrivia = (function () { - function AbstractTrivia(_kind) { - this._kind = _kind; - } - AbstractTrivia.prototype.fullWidth = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.fullText = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.toJSON = function (key) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === this._kind) { - result.kind = name; - break; - } - } - - if (this.isSkippedToken()) { - result.skippedToken = this.skippedToken(); - } else { - result.text = this.fullText(); - } - return result; - }; - - AbstractTrivia.prototype.kind = function () { - return this._kind; - }; - - AbstractTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - AbstractTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - AbstractTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - AbstractTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - AbstractTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return AbstractTrivia; - })(); - - var NormalTrivia = (function (_super) { - __extends(NormalTrivia, _super); - function NormalTrivia(kind, _text) { - _super.call(this, kind); - this._text = _text; - } - NormalTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - NormalTrivia.prototype.fullText = function () { - return this._text; - }; - - NormalTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return NormalTrivia; - })(AbstractTrivia); - - var SkippedTokenTrivia = (function (_super) { - __extends(SkippedTokenTrivia, _super); - function SkippedTokenTrivia(_skippedToken) { - _super.call(this, 8 /* SkippedTokenTrivia */); - this._skippedToken = _skippedToken; - } - SkippedTokenTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SkippedTokenTrivia.prototype.fullText = function () { - return this.skippedToken().fullText(); - }; - - SkippedTokenTrivia.prototype.skippedToken = function () { - return this._skippedToken; - }; - return SkippedTokenTrivia; - })(AbstractTrivia); - - var DeferredTrivia = (function (_super) { - __extends(DeferredTrivia, _super); - function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { - _super.call(this, kind); - this._text = _text; - this._fullStart = _fullStart; - this._fullWidth = _fullWidth; - this._fullText = null; - } - DeferredTrivia.prototype.fullWidth = function () { - return this._fullWidth; - }; - - DeferredTrivia.prototype.fullText = function () { - if (!this._fullText) { - this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); - this._text = null; - } - - return this._fullText; - }; - - DeferredTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return DeferredTrivia; - })(AbstractTrivia); - - function deferredTrivia(kind, text, fullStart, fullWidth) { - return new DeferredTrivia(kind, text, fullStart, fullWidth); - } - Syntax.deferredTrivia = deferredTrivia; - - function trivia(kind, text) { - return new NormalTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SkippedTokenTrivia(token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - this.trivia[i].collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 228 /* TypeArgumentList */: - case 229 /* TypeParameterList */: - case 220 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - return SyntaxUtilities.getExportKeyword(moduleElement) !== null; - }; - - SyntaxUtilities.getExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - case 133 /* ImportDeclaration */: - return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); - default: - return null; - } - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeQuery = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.requireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.name); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeQuery = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.name); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitList(node.modifiers); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.constructorKeyword); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.indexSignature); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - - - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - var result = this.currentToken(); - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - - return result; - }; - return SyntaxCursor; - })(); - - - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); - } - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { - this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 69 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return this.eatToken(78 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); - } - - return semicolonToken; - } - - return this.eatToken(78 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= 15 /* FirstKeyword */) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 173 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 186 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 187 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 188 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 189 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 191 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 167 /* LogicalNotExpression */: - case 170 /* DeleteExpression */: - case 171 /* TypeOfExpression */: - case 172 /* VoidExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); - } - } - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - var modifierCount = this.modifierCount(); - return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - var modifierCount = this.modifierCount(); - if (this.isImportDeclaration(modifierCount)) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration(modifierCount)) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration(modifierCount)) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration(modifierCount)) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration(modifierCount)) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(inErrorRecovery)) { - return this.parseStatement(inErrorRecovery); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var modifiers = this.parseModifiers(); - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 80 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - - return typeArgumentList; - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 72 /* OpenParenToken */: - case 76 /* DotToken */: - - case 73 /* CloseParenToken */: - case 75 /* CloseBracketToken */: - case 106 /* ColonToken */: - case 78 /* SemicolonToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - case 84 /* EqualsEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: - case 103 /* AmpersandAmpersandToken */: - case 104 /* BarBarToken */: - case 100 /* CaretToken */: - case 98 /* AmpersandToken */: - case 99 /* BarToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { - var dotToken = this.eatToken(76 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 63 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isAccessor = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 64 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var getKeyword = this.eatKeyword(64 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var setKeyword = this.eatKeyword(68 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(false); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexMemberDeclaration()) { - return this.parseIndexMemberDeclaration(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var modifiers = this.parseModifiers(); - var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var callSignature = this.parseCallSignature(false); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 78 /* SemicolonToken */: - case 107 /* EqualsToken */: - case 106 /* ColonToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.isIndexMemberDeclaration = function () { - var index = this.modifierCount(); - return this.isIndexSignature(index); - }; - - ParserImpl.prototype.parseIndexMemberDeclaration = function () { - var modifiers = this.parseModifiers(); - var indexSignature = this.parseIndexSignature(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - if (callSignature.lastToken()) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature(0)) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(inErrorRecovery)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(inErrorRecovery)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function (tokenIndex) { - return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isIdentifier(this.currentToken())) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - - break; - - case 28 /* IfKeyword */: - case 70 /* OpenBraceToken */: - case 33 /* ReturnKeyword */: - case 34 /* SwitchKeyword */: - case 36 /* ThrowKeyword */: - case 15 /* BreakKeyword */: - case 18 /* ContinueKeyword */: - case 26 /* ForKeyword */: - case 42 /* WhileKeyword */: - case 43 /* WithKeyword */: - case 22 /* DoKeyword */: - case 38 /* TryKeyword */: - case 19 /* DebuggerKeyword */: - return true; - } - - if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { - return false; - } - - return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); - }; - - ParserImpl.prototype.parseStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 28 /* IfKeyword */: - return this.parseIfStatement(); - case 70 /* OpenBraceToken */: - return this.parseBlock(false, false); - case 33 /* ReturnKeyword */: - return this.parseReturnStatement(); - case 34 /* SwitchKeyword */: - return this.parseSwitchStatement(); - case 36 /* ThrowKeyword */: - return this.parseThrowStatement(); - case 15 /* BreakKeyword */: - return this.parseBreakStatement(); - case 18 /* ContinueKeyword */: - return this.parseContinueStatement(); - case 26 /* ForKeyword */: - return this.parseForOrForInStatement(); - case 42 /* WhileKeyword */: - return this.parseWhileStatement(); - case 43 /* WithKeyword */: - return this.parseWithStatement(); - case 22 /* DoKeyword */: - return this.parseDoStatement(); - case 38 /* TryKeyword */: - return this.parseTryStatement(); - case 19 /* DebuggerKeyword */: - return this.parseDebuggerStatement(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement(currentToken)) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { - return this.parseEmptyStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(false); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function (currentToken) { - return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(106 /* ColonToken */); - var statement = this.parseStatement(false); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return currentToken.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(78 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { - return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function (currentToken) { - var kind = currentToken.tokenKind; - if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 79 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function (currentToken) { - switch (currentToken.tokenKind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - - case 74 /* OpenBracketToken */: - - case 72 /* OpenParenToken */: - - case 80 /* LessThanToken */: - - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - - case 70 /* OpenBraceToken */: - - case 85 /* EqualsGreaterThanToken */: - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - - case 31 /* NewKeyword */: - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - - case 27 /* FunctionKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(false); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 225 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(token0); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(107 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpressionOrLower = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpressionOrLower(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeOfExpression(); - } else if (currentTokenKind === 41 /* VoidKeyword */) { - return this.parseVoidExpression(); - } else if (currentTokenKind === 21 /* DeleteKeyword */) { - return this.parseDeleteExpression(); - } else if (currentTokenKind === 80 /* LessThanToken */) { - return this.parseCastExpression(); - } else { - return this.parsePostfixExpressionOrLower(); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - if (precedence <= 2 /* AssignmentExpressionPrecedence */) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } - - var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); - if (parethesizedArrowFunction !== null) { - return parethesizedArrowFunction; - } - } - - var leftOperand = this.parseUnaryExpressionOrLower(); - return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(105 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(106 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 81 /* GreaterThanToken */) { - if (storage[1] === 81 /* GreaterThanToken */) { - if (storage[2] === 107 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 107 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 107 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } - - var expression = this.parsePrimaryExpression(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - return this.parseMemberExpressionRest(expression, false, inObjectCreation); - }; - - ParserImpl.prototype.parseCallExpressionOrLower = function () { - var expression; - if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { - expression = this.eatKeyword(50 /* SuperKeyword */); - - var currentTokenKind = this.currentToken().tokenKind; - if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - } - } else { - expression = this.parseMemberExpressionOrLower(false); - } - - return this.parseMemberExpressionRest(expression, true, false); - }; - - ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 72 /* OpenParenToken */: - if (!allowArguments) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 80 /* LessThanToken */: - if (!allowArguments) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 74 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 76 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseCallExpressionOrLower(); - } - }; - - ParserImpl.prototype.parsePostfixExpressionOrLower = function () { - var expression = this.parseLeftHandSideExpressionOrLower(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - } - - return expression; - }; - - ParserImpl.prototype.tryParseGenericArgumentList = function () { - var rewindPoint = this.getRewindPoint(); - - var typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; - var isDot = token0.tokenKind === 76 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - - var argumentList = null; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - - if (isDot) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); - } else { - return this.parseArgumentList(typeArgumentList); - } - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - if (this.currentToken().tokenKind === 80 /* LessThanToken */) { - return this.tryParseGenericArgumentList(); - } - - if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { - return this.parseArgumentList(null); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var _arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - _arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parsePrimaryExpression = function () { - var currentToken = this.currentToken(); - - if (this.isIdentifier(currentToken)) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 74 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 70 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 72 /* OpenParenToken */: - return this.parseParenthesizedExpression(); - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 75 /* CloseBracketToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseObjectCreationExpressionOrLower(true); - var argumentList = this.tryParseArgumentList(); - - var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); - return this.parseMemberExpressionRest(result, true, false); - }; - - ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseMemberExpressionOrLower(inObjectCreation); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(80 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedExpression = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { - return null; - } - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - - this.releaseRewindPoint(rewindPoint); - return arrowFunction; - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.tryParseArrowFunctionBlock = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { - return this.parseBlock(true, false); - } else { - return null; - } - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 70 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 73 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; - } - - if (token1.tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - token2 = this.peekToken(2); - if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { - if (this.isIdentifier(token2)) { - return true; - } - } - - if (!this.isIdentifier(token1)) { - return false; - } - - if (token2.tokenKind === 106 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 105 /* QuestionToken */) { - if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 79 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 106 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { - if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(true); - } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(106 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - return this.eatKeyword(35 /* ThisKeyword */); - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var lessThanToken = this.eatToken(80 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameters = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); - - return typeParameterList; - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(106 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 39 /* TypeOfKeyword */: - - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - - case 70 /* OpenBraceToken */: - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - - case 31 /* NewKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - var type = this.parseNonArrayType(currentToken); - - while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.isTypeQuery = function () { - return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; - }; - - ParserImpl.prototype.parseTypeQuery = function () { - var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); - var name = this.parseName(); - - return this.factory.typeQuery(typeOfKeyword, name); - }; - - ParserImpl.prototype.parseNonArrayType = function (currentToken) { - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - return this.eatAnyToken(); - - case 70 /* OpenBraceToken */: - return this.parseObjectType(); - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - return this.parseFunctionType(); - - case 31 /* NewKeyword */: - return this.parseConstructorType(); - - case 39 /* TypeOfKeyword */: - return this.parseTypeQuery(); - } - - return this.parseNameOrGenericType(); - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - var tokenKind = token.tokenKind; - if (tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { - if (this.isIdentifier(token)) { - var nextTokenKind = this.peekToken(1).tokenKind; - switch (nextTokenKind) { - case 73 /* CloseParenToken */: - case 106 /* ColonToken */: - case 107 /* EqualsToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); - - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { - modifierArray.push(this.eatAnyToken()); - continue; - } - - break; - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - 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; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType, inErrorRecovery); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 79 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 78 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 75 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 70 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 79 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - var currentToken = this.currentToken(); - if (this.isExpression(currentToken)) { - return true; - } - - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.parseStatement(inErrorRecovery); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(inErrorRecovery); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); - - case 16 /* SwitchClause_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 32 /* Block_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); - - case 131072 /* ParameterList_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, options) { - var source = new NormalParserSource(fileName, text, options.languageVersion()); - - return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.inObjectLiteralExpression = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { - return true; - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { - if (parameter.modifiers.childCount() > 0) { - var modifiers = parameter.modifiers; - var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - - if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { - if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); - return true; - } else { - if (modifierIndex > 0) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - 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.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; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); - return true; - } else if (parameter.modifiers.childCount() > 0) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - 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; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var isInStaticOverloadChain = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - var isStaticOverload = null; - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - 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) { - 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; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); - isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); - - 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; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 121 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "boolean": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { - var getKeywordFullStart = this.childFullStart(node, getKeyword); - if (parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { - if (this.checkIndexMemberModifiers(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIndexMemberDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { - if (node.modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(node, node.modifiers); - this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { - if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { - var savedInObjectLiteralExpression = this.inObjectLiteralExpression; - this.inObjectLiteralExpression = true; - _super.prototype.visitObjectLiteralExpression.call(this, node); - this.inObjectLiteralExpression = savedInObjectLiteralExpression; - }; - - GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { - var setKeywordFullStart = this.childFullStart(node, setKeyword); - if (parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); - return true; - } - - var parameterListFullStart = this.childFullStart(node, parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); - var parameter = parameterList.parameters.childAt(0); - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - 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 && previousValueWasComputed) { - this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); - return true; - } - - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitEnumElement = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - var expression = node.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(expression)) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); - this.skip(node); - return; - } - } - - _super.prototype.visitEnumElement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (node.stringLiteral === null) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); - } - } - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); - return true; - } - }; - - GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitImportDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); - this.skip(node); - return; - } - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { - this.skip(node); - return; - } - - _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); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock || this.inObjectLiteralExpression) { - if (modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclarator.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { - this.skip(node); - return; - } - - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { - var currentElementFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var child = modifiers.childAt(i); - if (child.kind() !== 57 /* PublicKeyword */) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); - return true; - } - - currentElementFullStart += child.fullWidth(); - } - - 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); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - if (logger.information()) { - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - } - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { - this._compiler = _compiler; - this._semanticInfoChain = _semanticInfoChain; - this.fileName = fileName; - this.referencedFiles = referencedFiles; - this._scriptSnapshot = _scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._syntaxTree = _syntaxTree; - this._topLevelDecl = _topLevelDecl; - this._diagnostics = null; - this._bloomFilter = null; - this._sourceUnit = null; - this._lineMap = null; - this._declASTMap = []; - this._astDeclMap = []; - this._amdDependencies = undefined; - this._externalModuleIndicatorSpan = undefined; - } - Document.prototype.invalidate = function () { - this._declASTMap.length = 0; - this._astDeclMap.length = 0; - this._topLevelDecl = null; - - this._syntaxTree = null; - this._sourceUnit = null; - this._diagnostics = null; - this._bloomFilter = null; - }; - - Document.prototype.isDeclareFile = function () { - return TypeScript.isDTSFile(this.fileName); - }; - - Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { - var start = new Date().getTime(); - this._diagnostics = syntaxTree.diagnostics(); - TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; - - this._lineMap = syntaxTree.lineMap(); - - var sourceUnit = syntaxTree.sourceUnit(); - var leadingTrivia = sourceUnit.leadingTrivia(); - - this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); - - var amdDependencies = []; - 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); - } - } - } - - this._amdDependencies = amdDependencies; - }; - - Document.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(trivia.fullText()); - - if (match) { - return new TypeScript.TextSpan(position, trivia.fullWidth()); - } - - return null; - }; - - 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); - } - } - - position += moduleElement.fullWidth(); - } - - return null; - ; - }; - - Document.prototype.sourceUnit = function () { - if (!this._sourceUnit) { - var start = new Date().getTime(); - var syntaxTree = this.syntaxTree(); - this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); - TypeScript.astTranslationTime += new Date().getTime() - start; - - if (!this.isOpen) { - this._syntaxTree = null; - } - } - - return this._sourceUnit; - }; - - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._diagnostics); - } - - return this._diagnostics; - }; - - Document.prototype.lineMap = function () { - if (this._lineMap === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._lineMap); - } - - return this._lineMap; - }; - - Document.prototype.isExternalModule = function () { - return this.externalModuleIndicatorSpan() !== null; - }; - - Document.prototype.externalModuleIndicatorSpan = function () { - if (this._externalModuleIndicatorSpan === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); - } - - return this._externalModuleIndicatorSpan; - }; - - Document.prototype.amdDependencies = function () { - if (this._amdDependencies === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._amdDependencies !== undefined); - } - - return this._amdDependencies; - }; - - Document.prototype.syntaxTree = function () { - var result = this._syntaxTree; - if (!result) { - var start = new Date().getTime(); - - result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); - - TypeScript.syntaxTreeParseTime += new Date().getTime() - start; - - if (this.isOpen || !this._sourceUnit) { - this._syntaxTree = result; - } - } - - this.cacheSyntaxTreeInfo(result); - return result; - }; - - Document.prototype.bloomFilter = function () { - if (!this._bloomFilter) { - var identifiers = TypeScript.createIntrinsicsObject(); - var pre = function (cur) { - if (TypeScript.ASTHelpers.isValidAstNode(cur)) { - if (cur.kind() === 11 /* IdentifierName */) { - var nodeText = cur.valueText(); - - identifiers[nodeText] = true; - } - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); - - var identifierCount = 0; - for (var name in identifiers) { - if (identifiers[name]) { - identifierCount++; - } - } - - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - } - return this._bloomFilter; - }; - - Document.prototype.emitToOwnOutputFile = function () { - return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { - var oldSyntaxTree = this._syntaxTree; - - if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { - var oldText = this._scriptSnapshot; - var newText = scriptSnapshot; - - TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); - var newTextPrefix = newText.getText(0, textChangeRange.span().start()); - TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); - - var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); - var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); - TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); - }; - - Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); - }; - - Document.prototype.topLevelDecl = function () { - if (this._topLevelDecl === null) { - this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); - } - - return this._topLevelDecl; - }; - - Document.prototype._getDeclForAST = function (ast) { - this.topLevelDecl(); - return this._astDeclMap[ast.syntaxID()]; - }; - - Document.prototype.getEnclosingDecl = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - return this._getDeclForAST(ast); - } - - ast = ast.parent; - var decl = null; - while (ast) { - decl = this._getDeclForAST(ast); - - if (decl) { - break; - } - - ast = ast.parent; - } - - return decl._getEnclosingDeclFromParentDecl(); - }; - - Document.prototype._setDeclForAST = function (ast, decl) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._astDeclMap[ast.syntaxID()] = decl; - }; - - Document.prototype._getASTForDecl = function (decl) { - return this._declASTMap[decl.declID]; - }; - - Document.prototype._setASTForDecl = function (decl, ast) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._declASTMap[decl.declID] = ast; - }; - return Document; - })(); - TypeScript.Document = Document; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var proto = "__proto__"; - - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - - this[proto] = null; - this[proto] = undefined; - } - return BlockIntrinsics; - })(); - - function createIntrinsicsObject() { - return new BlockIntrinsics(); - } - TypeScript.createIntrinsicsObject = createIntrinsicsObject; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = createIntrinsicsObject(); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (!fn(k, this.table[k], context)) { - return false; - } - } - } - - return true; - }; - - StringHashTable.prototype.some = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (fn(k, this.table[k], context)) { - return true; - } - } - } - - return false; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - - StringHashTable.prototype.remove = function (key) { - if (this.table[key] !== undefined) { - this.table[key] = undefined; - this.itemCount--; - } - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(StringHashTable); - TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (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); - } - ASTHelpers.moduleIsElided = moduleIsElided; - - 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)) { - 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; - } - ASTHelpers.enumIsElided = enumIsElided; - - function isValidAstNode(ast) { - if (!ast) - return false; - - if (ast.start() === -1 || ast.end() === -1) - return false; - - return true; - } - ASTHelpers.isValidAstNode = isValidAstNode; - - 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; - - 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) { - top = cur; - } - } - } - } - - 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; - } - } - - return false; - } - ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { - return false; - } - if (ast.kind() !== 11 /* IdentifierName */) { - return false; - } - - 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); - } - 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; - } - - current = current.parent; - } - 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; - } - - return null; - } - ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; - - 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; - } - 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; - - function parametersFromIdentifier(id) { - return { - length: 1, - lastParameterIsRest: function () { - return false; - }, - ast: id, - astAt: function (index) { - return id; - }, - identifierAt: function (index) { - return id; - }, - typeAt: function (index) { - return null; - }, - initializerAt: function (index) { - return null; - }, - isOptionalAt: function (index) { - return false; - } - }; - } - ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; - - function parametersFromParameter(parameter) { - return { - length: 1, - lastParameterIsRest: function () { - return parameter.dotDotDotToken !== null; - }, - ast: parameter, - astAt: function (index) { - return parameter; - }, - identifierAt: function (index) { - return parameter.identifier; - }, - typeAt: function (index) { - return getType(parameter); - }, - initializerAt: function (index) { - return parameter.equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(parameter); - } - }; - } - ASTHelpers.parametersFromParameter = parametersFromParameter; - - function parameterIsOptional(parameter) { - return parameter.questionToken !== null || parameter.equalsValueClause !== null; - } - - function parametersFromParameterList(list) { - return { - length: list.parameters.nonSeparatorCount(), - lastParameterIsRest: function () { - return TypeScript.lastParameterIsRest(list); - }, - ast: list.parameters, - astAt: function (index) { - return list.parameters.nonSeparatorAt(index); - }, - identifierAt: function (index) { - return list.parameters.nonSeparatorAt(index).identifier; - }, - typeAt: function (index) { - return getType(list.parameters.nonSeparatorAt(index)); - }, - initializerAt: function (index) { - return list.parameters.nonSeparatorAt(index).equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(list.parameters.nonSeparatorAt(index)); - } - }; - } - ASTHelpers.parametersFromParameterList = parametersFromParameterList; - - 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; - } - } - ASTHelpers.isDeclarationAST = isDeclarationAST; - - 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; - } - - 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; - } - - ast = ast.parent; - } - - return null; - } - ASTHelpers.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); - - 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 { - TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); - var dotExpr = name; - return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); - } - } - ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; - })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); - var ASTHelpers = TypeScript.ASTHelpers; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function walkListChildren(preAst, walker) { - for (var i = 0, n = preAst.childCount(); i < n; i++) { - walker.walk(preAst.childAt(i)); - } - } - - function walkThrowStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkPrefixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkPostfixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkDeleteExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkTypeArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArguments); - } - - function walkTypeOfExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkVoidExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArgumentList); - walker.walk(preAst.arguments); - } - - function walkArrayLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.expressions); - } - - function walkSimplePropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.expression); - } - - function walkFunctionPropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkGetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkSeparatedListChildren(preAst, walker) { - for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { - walker.walk(preAst.nonSeparatorAt(i)); - } - } - - function walkSetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkObjectLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.propertyAssignments); - } - - function walkCastExpressionChildren(preAst, walker) { - walker.walk(preAst.type); - walker.walk(preAst.expression); - } - - function walkParenthesizedExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkElementAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentExpression); - } - - function walkMemberAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.name); - } - - function walkQualifiedNameChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkBinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkEqualsValueClauseChildren(preAst, walker) { - walker.walk(preAst.value); - } - - function walkTypeParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.constraint); - } - - function walkTypeParameterListChildren(preAst, walker) { - walker.walk(preAst.typeParameters); - } - - function walkGenericTypeChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.typeArgumentList); - } - - function walkTypeAnnotationChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkTypeQueryChildren(preAst, walker) { - walker.walk(preAst.name); - } - - function walkInvocationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkObjectCreationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkTrinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.whenTrue); - walker.walk(preAst.whenFalse); - } - - function walkFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFunctionTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkMemberFunctionDeclarationChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFuncDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkIndexMemberDeclarationChildren(preAst, walker) { - walker.walk(preAst.indexSignature); - } - - function walkIndexSignatureChildren(preAst, walker) { - walker.walk(preAst.parameter); - walker.walk(preAst.typeAnnotation); - } - - function walkCallSignatureChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - } - - function walkConstraintChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkConstructorTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkConstructSignatureChildren(preAst, walker) { - walker.walk(preAst.callSignature); - } - - function walkParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkParameterListChildren(preAst, walker) { - walker.walk(preAst.parameters); - } - - function walkPropertySignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - } - - function walkVariableDeclaratorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkMemberVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarator); - } - - function walkMethodSignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - } - - function walkReturnStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkForStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.initializer); - walker.walk(preAst.condition); - walker.walk(preAst.incrementor); - walker.walk(preAst.statement); - } - - function walkForInStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.left); - walker.walk(preAst.expression); - walker.walk(preAst.statement); - } - - function walkIfStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - walker.walk(preAst.elseClause); - } - - function walkElseClauseChildren(preAst, walker) { - walker.walk(preAst.statement); - } - - function walkWhileStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkDoStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkBlockChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.declarators); - } - - function walkCaseSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.statements); - } - - function walkDefaultSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkSwitchStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.switchClauses); - } - - function walkTryStatementChildren(preAst, walker) { - walker.walk(preAst.block); - walker.walk(preAst.catchClause); - walker.walk(preAst.finallyClause); - } - - function walkCatchClauseChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkExternalModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.stringLiteral); - } - - function walkFinallyClauseChildren(preAst, walker) { - walker.walk(preAst.block); - } - - function walkClassDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.classElements); - } - - function walkScriptChildren(preAst, walker) { - walker.walk(preAst.moduleElements); - } - - function walkHeritageClauseChildren(preAst, walker) { - walker.walk(preAst.typeNames); - } - - function walkInterfaceDeclerationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.body); - } - - function walkObjectTypeChildren(preAst, walker) { - walker.walk(preAst.typeMembers); - } - - function walkArrayTypeChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkModuleDeclarationChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.stringLiteral); - walker.walk(preAst.moduleElements); - } - - function walkModuleNameModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.moduleName); - } - - function walkEnumDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.enumElements); - } - - function walkEnumElementChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.equalsValueClause); - } - - function walkImportDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.moduleReference); - } - - function walkExportAssignmentChildren(preAst, walker) { - walker.walk(preAst.identifier); - } - - function walkWithStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkExpressionStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkLabeledStatementChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.statement); - } - - function walkVariableStatementChildren(preAst, walker) { - walker.walk(preAst.declaration); - } - - var childrenWalkers = new Array(246 /* Last */ + 1); - - for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { - childrenWalkers[i] = null; - } - for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { - childrenWalkers[i] = null; - } - - childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; - childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[60 /* AnyKeyword */] = null; - childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; - childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; - childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; - childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; - childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; - childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[146 /* Block */] = walkBlockChildren; - childrenWalkers[61 /* BooleanKeyword */] = null; - childrenWalkers[152 /* BreakStatement */] = null; - childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; - childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; - childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; - childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; - childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; - childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; - childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; - childrenWalkers[239 /* Constraint */] = walkConstraintChildren; - childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; - childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; - childrenWalkers[153 /* ContinueStatement */] = null; - childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; - childrenWalkers[162 /* DebuggerStatement */] = null; - childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; - childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; - childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; - childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; - childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; - childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; - childrenWalkers[156 /* EmptyStatement */] = null; - childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; - childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; - childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; - childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; - childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; - childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; - childrenWalkers[24 /* FalseKeyword */] = null; - childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; - childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; - childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; - childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; - childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; - childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; - childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; - childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; - childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; - childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; - childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; - childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; - childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; - childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; - childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; - childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; - childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; - childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; - childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[1 /* List */] = walkListChildren; - childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; - childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; - childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; - childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; - childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; - childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; - childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; - childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; - childrenWalkers[11 /* IdentifierName */] = null; - childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[0 /* None */] = null; - childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[32 /* NullKeyword */] = null; - childrenWalkers[67 /* NumberKeyword */] = null; - childrenWalkers[13 /* NumericLiteral */] = null; - childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; - childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; - childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; - childrenWalkers[223 /* OmittedExpression */] = null; - childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[242 /* Parameter */] = walkParameterChildren; - childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; - childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; - childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; - childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; - childrenWalkers[12 /* RegularExpressionLiteral */] = null; - childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; - childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; - childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; - childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; - childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; - childrenWalkers[14 /* StringLiteral */] = null; - childrenWalkers[69 /* StringKeyword */] = null; - childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; - childrenWalkers[50 /* SuperKeyword */] = null; - childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; - childrenWalkers[35 /* ThisKeyword */] = null; - childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; - childrenWalkers[3 /* TriviaList */] = null; - childrenWalkers[37 /* TrueKeyword */] = null; - childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; - childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; - childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; - childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; - childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; - childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; - childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; - childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; - childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; - childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; - childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; - childrenWalkers[41 /* VoidKeyword */] = null; - childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; - childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; - - for (var e in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { - TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); - } - } - - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - this.stopWalking = false; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var SimplePreAstWalker = (function () { - function SimplePreAstWalker(pre, state) { - this.pre = pre; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePreAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - }; - return SimplePreAstWalker; - })(); - - var SimplePrePostAstWalker = (function () { - function SimplePrePostAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePrePostAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - - this.post(ast, this.state); - }; - return SimplePrePostAstWalker; - })(); - - var NormalAstWalker = (function () { - function NormalAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - NormalAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - if (this.options.stopWalking) { - return; - } - - this.pre(ast, this); - - if (this.options.stopWalking) { - return; - } - - if (this.options.goChildren) { - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - } else { - this.options.goChildren = true; - } - - if (this.post) { - this.post(ast, this); - } - }; - return NormalAstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { - new NormalAstWalker(pre, post, state).walk(ast); - }; - - AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { - if (post) { - new SimplePrePostAstWalker(pre, post, state).walk(ast); - } else { - new SimplePreAstWalker(pre, state).walk(ast); - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory = new AstWalkerFactory(); - - function getAstWalkerFactory() { - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapEntry = (function () { - function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { - this.emittedFile = emittedFile; - this.emittedLine = emittedLine; - this.emittedColumn = emittedColumn; - this.sourceFile = sourceFile; - this.sourceLine = sourceLine; - this.sourceColumn = sourceColumn; - this.sourceName = sourceName; - TypeScript.Debug.assert(isFinite(emittedLine)); - TypeScript.Debug.assert(isFinite(emittedColumn)); - TypeScript.Debug.assert(isFinite(sourceColumn)); - TypeScript.Debug.assert(isFinite(sourceLine)); - } - return SourceMapEntry; - })(); - TypeScript.SourceMapEntry = SourceMapEntry; - - var SourceMapper = (function () { - function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.names = []; - this.mappingLevel = []; - this.tsFilePaths = []; - this.allSourceMappings = []; - this.sourceMapEntries = []; - this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); - this.setNewSourceFile(document, emitOptions); - } - SourceMapper.prototype.getOutputFile = function () { - var result = this.sourceMapOut.getOutputFile(); - result.sourceMapEntries = this.sourceMapEntries; - - return result; - }; - - SourceMapper.prototype.increaseMappingLevel = function (ast) { - this.mappingLevel.push(ast); - }; - - SourceMapper.prototype.decreaseMappingLevel = function (ast) { - TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); - var expectedAst = this.mappingLevel.pop(); - var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; - var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; - TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); - }; - - SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { - var sourceMappings = []; - this.allSourceMappings.push(sourceMappings); - this.currentMappings = [sourceMappings]; - this.currentNameIndex = []; - - this.setNewSourceFilePath(document, emitOptions); - }; - - SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { - var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); - var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; - this.jsFileName = prettyJsFileName; - - if (emitOptions.sourceMapRootDirectory()) { - this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); - if (document.emitToOwnOutputFile()) { - this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); - } - - if (TypeScript.isRelative(this.sourceMapDirectory)) { - this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; - this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); - this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); - } else { - this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; - } - } else { - this.sourceMapPath = prettyMapFileName; - this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); - } - this.sourceRoot = emitOptions.sourceRootDirectory(); - }; - - SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { - var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); - if (emitOptions.sourceRootDirectory()) { - tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); - } else { - tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); - } - this.tsFilePaths.push(tsFilePath); - }; - - SourceMapper.prototype.emitSourceMapping = function () { - var _this = this; - TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { - return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); - }).join(', ')); - - this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); - - var mappingsString = ""; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); - prevSourceIndex = sourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); - prevNameIndex = nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - for (var i = 0; i < sourceMappings.length; i++) { - var sourceMapping = sourceMappings[i]; - recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); - recordSourceMappingSiblings(sourceMapping.childMappings); - recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); - } - }; - - recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); - } - - this.sourceMapOut.Write(JSON.stringify({ - version: 3, - file: this.jsFileName, - sourceRoot: this.sourceRoot, - sources: this.tsFilePaths, - names: this.names, - mappings: mappingsString - })); - - this.sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compiler, resolvePath) { - this.resolvePath = resolvePath; - this._diagnostic = null; - this._settings = null; - this._commonDirectoryPath = ""; - this._sharedOutputFile = ""; - this._sourceRootDirectory = ""; - this._sourceMapRootDirectory = ""; - this._outputDirectory = ""; - var settings = compiler.compilationSettings(); - this._settings = settings; - - 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()) { - if (settings.mapRoot()) { - if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } else { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } else if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } - - this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); - this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); - - if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { - if (settings.outFileOption()) { - this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); - } - - if (settings.outDirOption()) { - this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); - } - - if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { - this.determineCommonDirectoryPath(compiler); - } - } - } - EmitOptions.prototype.diagnostic = function () { - return this._diagnostic; - }; - - EmitOptions.prototype.commonDirectoryPath = function () { - return this._commonDirectoryPath; - }; - EmitOptions.prototype.sharedOutputFile = function () { - return this._sharedOutputFile; - }; - EmitOptions.prototype.sourceRootDirectory = function () { - return this._sourceRootDirectory; - }; - EmitOptions.prototype.sourceMapRootDirectory = function () { - return this._sourceMapRootDirectory; - }; - EmitOptions.prototype.outputDirectory = function () { - return this._outputDirectory; - }; - - EmitOptions.prototype.compilationSettings = function () { - return this._settings; - }; - - EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = compiler.fileNames(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = compiler.getDocument(fileNames[i]); - var sourceUnit = document.sourceUnit(); - - if (!document.isDeclareFile()) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - 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; - } - - return; - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - function lastParameterIsRest(parameterList) { - var parameters = parameterList.parameters; - return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; - } - TypeScript.lastParameterIsRest = lastParameterIsRest; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.inArrowFunction = false; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.declStack = []; - this.exportAssignment = null; - this.inWithBlock = false; - this.document = null; - this.detachedCommentsElement = null; - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setExportAssignment = function (exportAssignment) { - this.exportAssignment = exportAssignment; - }; - - Emitter.prototype.getExportAssignment = function () { - return this.exportAssignment; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.shouldEmitImportDeclaration = 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 */; - - 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 */; - - this.emitComments(importDeclAST, true); - - var importSymbol = importDecl.getSymbol(); - - var parentSymbol = importSymbol.getContainer(); - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; - - var needsPropertyAssignment = false; - var usePropertyAssignmentInsteadOfVarDecl = false; - var moduleNamePrefix; - - 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 */)) { - needsPropertyAssignment = true; - } else { - usePropertyAssignmentInsteadOfVarDecl = true; - } - } - - if (this.emitState.container === 2 /* DynamicModule */) { - moduleNamePrefix = "exports."; - } else { - moduleNamePrefix = this.moduleName + "."; - } - } - - if (isAmdCodeGen && isExternalModuleReference) { - needsPropertyAssignment = true; - } else { - this.recordSourceMappingStart(importDeclAST); - if (usePropertyAssignmentInsteadOfVarDecl) { - this.writeToOutput(moduleNamePrefix); - } else { - this.writeToOutput("var "); - } - this.writeToOutput(importDeclAST.identifier.text() + " = "); - var aliasAST = importDeclAST.moduleReference; - - if (isExternalModuleReference) { - this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); - } else { - this.emitJavascript(aliasAST.moduleName, false); - } - - this.recordSourceMappingEnd(importDeclAST); - this.writeToOutput(";"); - - if (needsPropertyAssignment) { - this.writeLineToOutput(""); - this.emitIndent(); - } - } - - if (needsPropertyAssignment) { - this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); - this.writeToOutput(";"); - } - this.emitComments(importDeclAST, false); - }; - - Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { - this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); - }; - - Emitter.prototype.setSourceMapperNewSourceFile = function (document) { - this.sourceMapper.setNewSourceFile(document, this.emitOptions); - }; - - Emitter.prototype.updateLineAndColumn = function (s) { - var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); - if (lineNumbers.length > 1) { - this.emitState.line += lineNumbers.length - 1; - this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; - } else { - this.emitState.column += s.length; - } - }; - - Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { - this.recordSourceMappingStart(astSpan); - this.writeToOutput(s); - this.recordSourceMappingEnd(astSpan); - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - this.updateLineAndColumn(s); - }; - - Emitter.prototype.writeLineToOutput = function (s, force) { - if (typeof force === "undefined") { force = false; } - if (!force && s === "" && this.emitState.column === 0) { - return; - } - - this.outfile.WriteLine(s); - this.updateLineAndColumn(s); - this.emitState.column = 0; - this.emitState.line++; - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - return this.indenter.getIndent(); - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitComment = function (comment, trailing, first) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var text = getTrimmedTextLines(comment); - var emitColumn = this.emitState.column; - - if (emitColumn === 0) { - this.emitIndent(); - } else if (trailing && first) { - this.writeToOutput(" "); - } - - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingEnd(comment); - this.writeToOutput(" "); - return; - } - } else { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } - - if (!trailing && emitColumn !== 0) { - this.emitIndent(); - } - }; - - Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - 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; - } - } - - if (pre) { - var preComments = ast.preComments(); - - if (preComments && ast === this.detachedCommentsElement) { - var detachedComments = this.getDetachedComments(ast); - preComments = preComments.slice(detachedComments.length); - this.detachedCommentsElement = null; - } - - if (preComments && onlyPinnedOrTripleSlashComments) { - preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { - return _this.isPinnedOrTripleSlash(c); - }); - } - - this.emitCommentsArray(preComments, false); - } else { - this.emitCommentsArray(ast.postComments(), true); - } - }; - - Emitter.prototype.isPinnedOrTripleSlash = function (comment) { - var fullText = comment.fullText(); - if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { - return true; - } else { - return fullText.indexOf("/*!") === 0; - } - }; - - Emitter.prototype.emitCommentsArray = function (comments, trailing) { - if (!this.emitOptions.compilationSettings().removeComments() && comments) { - for (var i = 0, n = comments.length; i < n; i++) { - this.emitComment(comments[i], trailing, i === 0); - } - } - }; - - Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { - this.recordSourceMappingStart(objectLiteral); - - this.writeToOutput("{"); - this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); - this.writeToOutput("}"); - - this.recordSourceMappingEnd(objectLiteral); - }; - - Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { - this.recordSourceMappingStart(arrayLiteral); - - this.writeToOutput("["); - this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); - this.writeToOutput("]"); - - this.recordSourceMappingEnd(arrayLiteral); - }; - - Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { - this.recordSourceMappingStart(objectCreationExpression); - this.writeToOutput("new "); - var target = objectCreationExpression.expression; - - this.emit(target); - if (objectCreationExpression.argumentList) { - this.recordSourceMappingStart(objectCreationExpression.argumentList); - this.writeToOutput("("); - this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); - this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); - this.recordSourceMappingEnd(objectCreationExpression.argumentList); - } - - this.recordSourceMappingEnd(objectCreationExpression); - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); - if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - if (pullDecl.kind === 67108864 /* EnumMember */) { - return pullDecl; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - var propertyName = dotExpr.name; - var boundDecl = this.getConstantDecl(dotExpr); - if (boundDecl) { - var value = boundDecl.constantValue; - if (value !== null) { - this.recordSourceMappingStart(dotExpr); - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.text(); - comment += " */"; - this.writeToOutput(comment); - this.recordSourceMappingEnd(dotExpr); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitInvocationExpression = function (callNode) { - this.recordSourceMappingStart(callNode); - var target = callNode.expression; - var args = callNode.argumentList.arguments; - - if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { - this.emit(target); - this.writeToOutput(".call"); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitThis(); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - } else { - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - - this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); - this.recordSourceMappingEnd(args); - this.recordSourceMappingEnd(callNode); - }; - - Emitter.prototype.emitParameterList = function (list) { - this.writeToOutput("("); - this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); - this.writeToOutput(")"); - }; - - Emitter.prototype.emitFunctionParameters = function (parameters) { - var argsLen = 0; - - if (parameters) { - this.emitComments(parameters.ast, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = parameters.length; - var printLen = argsLen; - if (parameters.lastParameterIsRest()) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = parameters.astAt(i); - this.emit(arg); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(parameters.ast, false); - } - }; - - Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { - this.writeLineToOutput(" {"); - if (name) { - this.recordSourceMappingNameStart(name); - } - - this.indenter.increaseIndent(); - - 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); - } else { - this.emitIndent(); - this.emitCommentsArray(bodyExpression.preComments(), false); - this.writeToOutput("return "); - this.emit(bodyExpression); - this.writeLineToOutput(";"); - this.emitCommentsArray(bodyExpression.postComments(), true); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - - if (block) { - this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); - } else { - this.writeToOutputWithSourceMapRecord("}", bodyExpression); - } - - if (name) { - this.recordSourceMappingNameEnd(); - } - }; - - Emitter.prototype.emitDefaultValueAssignments = function (parameters) { - var n = parameters.length; - if (parameters.lastParameterIsRest()) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = parameters.astAt(i); - var id = parameters.identifierAt(i); - var equalsValueClause = parameters.initializerAt(i); - if (equalsValueClause) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.emitJavascript(equalsValueClause, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (parameters) { - if (parameters.lastParameterIsRest()) { - var n = parameters.length; - var lastArg = parameters.astAt(n - 1); - var id = parameters.identifierAt(n - 1); - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); - this.writeToOutput(" "); - this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); - this.writeToOutput("; "); - this.writeToOutputWithSourceMapRecord("_i++", lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - var result = []; - - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - var queue = dynamicModuleDecl.getChildDecls(); - - for (var i = 0, n = queue.length; i < n; i++) { - var decl = queue[i]; - - if (decl.kind & 128 /* TypeAlias */) { - var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.type; - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { - var importList = ""; - var dependencyList = ""; - - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.isUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += importStatementDecl.name; - dependencyList += importStatementAST.moduleReference.stringLiteral.text(); - } - } - } - - var amdDependencies = this.document.amdDependencies(); - for (var i = 0; i < amdDependencies.length; i++) { - dependencyList += ", \"" + amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); - } - - var decl = this.semanticInfoChain.getDeclForAST(ast); - if (decl) { - return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); - } - - return false; - }; - - Emitter.prototype.emitEnum = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - this.moduleName = moduleDecl.identifier.text(); - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.identifier); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(this.moduleName); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitSeparatedList(moduleDecl.enumElements); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { - return moduleDecl; - } else if (changeNameIfAnyDeclarationInContext) { - var symbol = moduleDecl.getSymbol(); - if (symbol) { - var otherDecls = symbol.getDeclarations(); - for (var i = 0; i < otherDecls.length; i++) { - if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { - return otherDecls[i]; - } - } - } - } - - return null; - }; - - Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { - var _this = this; - var childDecls = parentDecl.getChildDecls(); - return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - 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; - } - } - return false; - }); - }; - - Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - var moduleName = moduleDecl.name; - var moduleDisplayName = moduleDecl.getDisplayName(); - - moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { - while (this.hasChildNameCollision(moduleName, moduleDecl)) { - moduleName = "_" + moduleName; - moduleDisplayName = "_" + moduleDisplayName; - } - } - - return moduleDisplayName; - }; - - Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { - if (moduleDecl.stringLiteral) { - this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); - } - }; - - Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); - - if (isLastName) { - this.emitComments(moduleDecl, true); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - - if (moduleDecl.stringLiteral) { - this.moduleName = moduleDecl.stringLiteral.valueText(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - } else { - this.moduleName = moduleName.text(); - } - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleName); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleName); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - - this.moduleName = this.getModuleName(pullDecl); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(moduleName.text()); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - if (moduleName === moduleDecl.stringLiteral) { - this.emitList(moduleDecl.moduleElements); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - var nameIndex = moduleNames.indexOf(moduleName); - TypeScript.Debug.assert(nameIndex >= 0); - - if (isLastName) { - this.emitList(moduleDecl.moduleElements); - } else { - this.emitIndent(); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); - this.writeLineToOutput(""); - } - } - - this.moduleName = moduleName.text(); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - - if (isLastName) { - this.emitComments(moduleDecl, false); - } - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - var name = varDecl.propertyName.text(); - var quoted = TypeScript.isQuoted(name); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.writeToOutput(']'); - - if (varDecl.equalsValueClause) { - this.emit(varDecl.equalsValueClause); - } else if (pullDecl.constantValue !== null) { - this.writeToOutput(' = '); - this.writeToOutput(pullDecl.constantValue.toString()); - } else { - this.writeToOutput(' = null'); - } - - this.writeToOutput('] = '); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - this.writeToOutput(';'); - }; - - Emitter.prototype.emitElementAccessExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("["); - this.emit(expression.argumentExpression); - this.writeToOutput("]"); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = true; - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(arrowFunction); - - var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); - this.pushDecl(pullDecl); - - this.emitComments(arrowFunction, true); - - this.recordSourceMappingStart(arrowFunction); - this.writeToOutput("function "); - this.writeToOutput("("); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); - - this.recordSourceMappingEnd(arrowFunction); - - this.recordSourceMappingEnd(arrowFunction); - - this.emitComments(arrowFunction, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConstructor = function (funcDecl) { - if (!funcDecl.block) { - return; - } - var temp = this.setContainer(4 /* Constructor */); - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - this.writeToOutput(this.thisClassNode.identifier.text()); - this.writeToOutput("("); - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart("constructor"); - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(parameters); - this.emitRestParameterInitializer(parameters); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - this.emitConstructorStatements(funcDecl); - this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - }; - - Emitter.prototype.emitGetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("get "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitSetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("set "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitFunctionExpression = function (funcDecl) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - this.writeToOutput(funcDecl.identifier.text()); - this.recordSourceMappingEnd(funcDecl.identifier); - } - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (funcDecl.block === null) { - return; - } - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier.text(); - - this.recordSourceMappingStart(funcDecl); - - var printName = funcDecl.identifier !== null; - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (printName) { - var id = funcDecl.identifier.text(); - if (id) { - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - } - this.writeToOutput(id); - if (funcDecl.identifier) { - this.recordSourceMappingEnd(funcDecl.identifier); - } - } - } - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - if (funcDecl.block) { - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - this.recordSourceMappingStart(this.currentVariableDeclaration); - if (varDecl.equalsValueClause) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - this.emitJavascript(varDecl.equalsValueClause, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.currentVariableDeclaration) { - this.writeToOutput("var "); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.nonSeparatorAt(0); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - - this.emitComments(declaration, true); - - var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); - var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; - if (!isAmbientWithoutInit) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.currentVariableDeclaration = declaration; - - for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { - var declarator = declaration.declarators.nonSeparatorAt(i); - - if (i > 0) { - this.writeToOutput(", "); - } - - this.emit(declarator); - } - this.currentVariableDeclaration = prevVariableDeclaration; - - this.recordSourceMappingEnd(declaration); - } - - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { - TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); - - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - - if (quotedOrNumber) { - this.writeToOutput("this["); - } else { - this.writeToOutput("this."); - } - - this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); - - if (quotedOrNumber) { - this.writeToOutput("]"); - } - - if (varDecl.variableDeclarator.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.variableDeclarator.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(this.currentVariableDeclaration); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.propertyName.text(); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); - - if (parentIsModule) { - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - - if (varDecl.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.currentVariableDeclaration = undefined; - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { - var decl = pullSymbol.getDeclarations()[0]; - var parentDecl = decl.getParentDecl(); - var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; - - var enclosingContextDeclPath = this.declStack; - var commonNodeIndex = -1; - - if (enclosingContextDeclPath.length) { - for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { - var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; - for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { - var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; - if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { - commonNodeIndex = i; - break; - } - } - - if (commonNodeIndex >= 0) { - break; - } - } - } - - var startingIndex = symbolContainerDeclPath.length - 1; - for (var i = startingIndex - 1; i > commonNodeIndex; i--) { - if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { - startingIndex = i; - } else { - break; - } - } - return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; - }; - - Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { - for (var i = startingIndex; i <= lastIndex; i++) { - if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.getModuleName(declPath[i], true) + "."); - } - } - }; - - Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { - var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); - var potentialDeclPath = declPathInfo.potentialPath; - var startingIndex = declPathInfo.startingIndex; - - this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); - }; - - Emitter.prototype.getSymbolForEmit = function (ast) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); - var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); - if (pullSymbol && pullSymbolAlias) { - var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - - if (pullSymbol === symbolToCompare) { - pullSymbol = pullSymbolAlias; - pullSymbolAlias = null; - } - } - return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (name.text().length > 0) { - var symbolForEmit = this.getSymbolForEmit(name); - var pullSymbol = symbolForEmit.symbol; - if (!pullSymbol) { - pullSymbol = this.semanticInfoChain.anyTypeSymbol; - } - var pullSymbolAlias = symbolForEmit.aliasSymbol; - var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.kind; - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } - } - } - - this.writeToOutput(name.text()); - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var nameIndex = -1; - if (name) { - if (this.sourceMapper.currentNameIndex.length > 0) { - var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { - break; - } - } - - if (nameIndex === -1) { - nameIndex = this.sourceMapper.names.length; - this.sourceMapper.names.push(name); - } - } - this.sourceMapper.currentNameIndex.push(nameIndex); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (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; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap(); - lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); - - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - this.sourceMapper.increaseMappingLevel(ast); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); - - this.sourceMapper.decreaseMappingLevel(ast); - } - }; - - Emitter.prototype.getOutputFiles = function () { - var result = []; - if (this.sourceMapper !== null) { - this.sourceMapper.emitSourceMapping(); - result.push(this.sourceMapper.getOutputFile()); - } - - result.push(this.outfile.getOutputFile()); - return result; - }; - - Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { - var constructorDecl = getLastConstructor(this.thisClassNode); - - 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(); - this.recordSourceMappingStart(parameter); - this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); - this.writeToOutput(" = "); - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(parameter); - } - } - } - - for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { - if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = this.thisClassNode.classElements.childAt(i); - if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitIndent(); - this.emitMemberVariableDeclaration(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.isOnSameLine = function (pos1, pos2) { - var lineMap = this.document.lineMap(); - return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); - }; - - Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { - if (list === null || list.nonSeparatorCount() === 0) { - return; - } - - var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); - - if (preserveNewLines) { - this.indenter.increaseIndent(); - } - - if (startLine) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(buffer); - } - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - var emitNode = list.nonSeparatorAt(i); - - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); - if (startLine) { - this.writeLineToOutput(","); - } else { - this.writeToOutput(", "); - } - } - } - - if (preserveNewLines) { - this.indenter.decreaseIndent(); - } - - if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(buffer); - } - }; - - Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.nonSeparatorAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.kind() === 14 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { - return; - } - - var lineMap = this.document.lineMap(); - var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput("", true); - } - }; - - Emitter.prototype.getDetachedComments = function (element) { - var preComments = element.preComments(); - if (preComments) { - var lineMap = this.document.lineMap(); - - var detachedComments = []; - var lastComment = null; - - for (var i = 0, n = preComments.length; i < n; i++) { - var comment = preComments[i]; - - if (lastComment) { - var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); - var commentLine = lineMap.getLineNumberFromPosition(comment.start()); - - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - detachedComments.push(comment); - lastComment = comment; - } - - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); - var astLine = lineMap.getLineNumberFromPosition(element.start()); - if (astLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - return []; - }; - - Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - this.emitDetachedComments(script.moduleElements); - }; - - Emitter.prototype.emitDetachedComments = function (list) { - if (list.childCount() > 0) { - var firstElement = list.childAt(0); - - this.detachedCommentsElement = firstElement; - this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); - } - }; - - Emitter.prototype.emitScriptElements = function (sourceUnit) { - var list = sourceUnit.moduleElements; - - this.emitPossibleCopyrightHeaders(sourceUnit); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var node = list.childAt(i); - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(sourceUnit); - - var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); - if (isNonElidedExternalModule) { - this.recordSourceMappingStart(sourceUnit); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } - - if (isExternalModule) { - var temp = this.setContainer(2 /* DynamicModule */); - - var svModuleName = this.moduleName; - this.moduleName = sourceUnit.fileName(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - - this.setExportAssignment(null); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); - - if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { - this.writeCaptureThisStatement(sourceUnit); - } - - this.pushDecl(externalModule); - } - - this.emitList(list, true, i, n); - - if (isExternalModule) { - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - - if (isNonElidedExternalModule) { - var exportAssignment = this.getExportAssignment(); - var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; - var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); - this.writeLineToOutput(";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(sourceUnit); - this.writeLineToOutput(""); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - this.popDecl(externalModule); - } - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - this.emit(ast); - }; - - Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { - if (funcDecl.kind() !== 139 /* GetAccessor */) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - - this.writeToOutput("Object.defineProperty(" + className); - if (isProto) { - this.writeToOutput(".prototype, "); - } else { - this.writeToOutput(", "); - } - - var functionName = name.text(); - if (TypeScript.isQuoted(functionName)) { - this.writeToOutput(functionName); - } else { - this.writeToOutput('"' + functionName + '"'); - } - - this.writeLineToOutput(", {"); - - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.emitComments(accessors.getter, true); - this.writeToOutput("get: "); - this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.emitComments(accessors.setter, true); - this.writeToOutput("set: "); - this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.identifier.text(); - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; - var baseTypeReference = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); - this.writeLineToOutput(";"); - } - - this.emitIndent(); - - var constrDecl = getLastConstructor(classDecl); - - if (constrDecl) { - this.emit(constrDecl); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); - this.writeLineToOutput(";"); - } - - if (this.shouldCaptureThis(classDecl)) { - this.writeCaptureThisStatement(classDecl); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.writeLineToOutput(""); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.emitJavascript(baseTypeReference, false); - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 139 /* GetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var getter = memberDecl; - this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 140 /* SetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var setter = memberDecl; - this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { - var memberFunction = memberDecl; - - if (memberFunction.block) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - - this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); - lastEmittedMember = memberDecl; - } - } - } - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = memberDecl; - - if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); - } else { - this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); - } - - this.emit(varDecl.variableDeclarator.equalsValueClause); - - this.recordSourceMappingEnd(varDecl); - this.writeLineToOutput(";"); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - var functionName = funcDecl.propertyName.text(); - - this.writeToOutput(classDecl.identifier.text()); - - if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - this.writeToOutput(".prototype"); - } - - if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput("[" + functionName + "] = "); - } else { - this.writeToOutput("." + functionName + " = "); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - - this.writeLineToOutput(";"); - }; - - Emitter.prototype.requiresExtendsBlock = function (moduleElements) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - - if (moduleElement.kind() === 130 /* ModuleDeclaration */) { - var moduleAST = moduleElement; - - if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { - return true; - } - } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { - var classDeclaration = moduleElement; - - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitPrologue = function (sourceUnit) { - if (!this.extendsPrologueEmitted) { - if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(sourceUnit)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitThis = function () { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.kind() === 146 /* Block */) { - this.emit(node); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitLiteralExpression = function (expression) { - switch (expression.kind()) { - case 32 /* NullKeyword */: - this.writeToOutputWithSourceMapRecord("null", expression); - break; - case 24 /* FalseKeyword */: - this.writeToOutputWithSourceMapRecord("false", expression); - break; - case 37 /* TrueKeyword */: - this.writeToOutputWithSourceMapRecord("true", expression); - break; - default: - throw TypeScript.Errors.abstract(); - } - }; - - Emitter.prototype.emitThisExpression = function (expression) { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutputWithSourceMapRecord("_this", expression); - } else { - this.writeToOutputWithSourceMapRecord("this", expression); - } - }; - - Emitter.prototype.emitSuperExpression = function (expression) { - this.writeToOutputWithSourceMapRecord("_super.prototype", expression); - }; - - Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { - if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { - this.emit(parenthesizedExpression.expression); - } else { - this.recordSourceMappingStart(parenthesizedExpression); - this.writeToOutput("("); - this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); - this.emit(parenthesizedExpression.expression); - this.writeToOutput(")"); - this.recordSourceMappingEnd(parenthesizedExpression); - } - }; - - Emitter.prototype.emitCastExpression = function (expression) { - this.emit(expression.expression); - }; - - Emitter.prototype.emitPrefixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 167 /* LogicalNotExpression */: - this.writeToOutput("!"); - this.emit(expression.operand); - break; - case 166 /* BitwiseNotExpression */: - this.writeToOutput("~"); - this.emit(expression.operand); - break; - case 165 /* NegateExpression */: - this.writeToOutput("-"); - if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 164 /* PlusExpression */: - this.writeToOutput("+"); - if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 168 /* PreIncrementExpression */: - this.writeToOutput("++"); - this.emit(expression.operand); - break; - case 169 /* PreDecrementExpression */: - this.writeToOutput("--"); - this.emit(expression.operand); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitPostfixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 210 /* PostIncrementExpression */: - this.emit(expression.operand); - this.writeToOutput("++"); - break; - case 211 /* PostDecrementExpression */: - this.emit(expression.operand); - this.writeToOutput("--"); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitTypeOfExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("typeof "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDeleteExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("delete "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitVoidExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("void "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { - var memberExpressionNodeType = expression.expression.kind(); - - 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 */) { - return this.canEmitDottedNameMemberAccessExpression(expression.expression); - } - - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { - this.recordSourceMappingStart(expression); - if (expression.expression.kind() === 212 /* MemberAccessExpression */) { - this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); - } else { - this.emitComments(expression.expression, true); - this.recordSourceMappingStart(expression.expression); - - this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); - - this.writeToOutput(expression.expression.text()); - - this.recordSourceMappingEnd(expression.expression); - this.emitComments(expression.expression, false); - } - - this.writeToOutput("."); - this.emitName(expression.name, false); - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { - this.emitComments(expression, true); - - if (lastIndex - startingIndex < 1) { - startingIndex = lastIndex - 1; - TypeScript.Debug.assert(startingIndex >= 0); - } - - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); - this.emitComments(expression, false); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { - var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; - - var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); - }; - - Emitter.prototype.emitMemberAccessExpression = function (expression) { - if (!this.tryEmitConstant(expression)) { - if (this.canEmitDottedNameMemberAccessExpression(expression)) { - this.emitDottedNameMemberAccessExpression(expression); - } else { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("."); - this.emitName(expression.name, false); - this.recordSourceMappingEnd(expression); - } - } - }; - - Emitter.prototype.emitQualifiedName = function (name) { - this.recordSourceMappingStart(name); - - this.emit(name.left); - this.writeToOutput("."); - this.emitName(name.right, false); - - this.recordSourceMappingEnd(name); - }; - - Emitter.prototype.emitBinaryExpression = function (expression) { - this.recordSourceMappingStart(expression); - switch (expression.kind()) { - case 173 /* CommaExpression */: - this.emit(expression.left); - this.writeToOutput(", "); - this.emit(expression.right); - break; - default: { - this.emit(expression.left); - var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); - if (binOp === "instanceof") { - this.writeToOutput(" instanceof "); - } else if (binOp === "in") { - this.writeToOutput(" in "); - } else { - this.writeToOutput(" " + binOp + " "); - } - this.emit(expression.right); - } - } - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimplePropertyAssignment = function (property) { - this.recordSourceMappingStart(property); - this.emit(property.propertyName); - this.writeToOutput(": "); - this.emit(property.expression); - this.recordSourceMappingEnd(property); - }; - - Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { - this.recordSourceMappingStart(funcProp); - - this.emit(funcProp.propertyName); - this.writeToOutput(": "); - - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); - - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - var funcName = funcProp.propertyName; - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcProp); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); - - this.recordSourceMappingEnd(funcProp); - - this.recordSourceMappingEnd(funcProp); - - this.emitComments(funcProp, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConditionalExpression = function (expression) { - this.emit(expression.condition); - this.writeToOutput(" ? "); - this.emit(expression.whenTrue); - this.writeToOutput(" : "); - this.emit(expression.whenFalse); - }; - - Emitter.prototype.emitThrowStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("throw "); - this.emit(statement.expression); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitExpressionStatement = function (statement) { - var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; - - this.recordSourceMappingStart(statement); - if (isArrowExpression) { - this.writeToOutput("("); - } - - this.emit(statement.expression); - - if (isArrowExpression) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitLabeledStatement = function (statement) { - this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); - this.writeLineToOutput(":"); - this.emitJavascript(statement.statement, true); - }; - - Emitter.prototype.emitBlock = function (block) { - this.recordSourceMappingStart(block); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - if (block.statements) { - this.emitList(block.statements); - } - this.emitCommentsArray(block.closeBraceLeadingComments, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(block); - }; - - Emitter.prototype.emitBreakStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("break"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitContinueStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("continue"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitWhileStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("while ("); - this.emit(statement.condition); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitDoStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("do"); - this.emitBlockOrStatement(statement.statement); - this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); - this.writeToOutput('('); - this.emit(statement.condition); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitIfStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("if ("); - this.emit(statement.condition); - this.writeToOutput(")"); - - this.emitBlockOrStatement(statement.statement); - - if (statement.elseClause) { - if (statement.statement.kind() !== 146 /* Block */) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - - this.emit(statement.elseClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitElseClause = function (elseClause) { - if (elseClause.statement.kind() === 147 /* IfStatement */) { - this.writeToOutput("else "); - this.emit(elseClause.statement); - } else { - this.writeToOutput("else"); - this.emitBlockOrStatement(elseClause.statement); - } - }; - - Emitter.prototype.emitReturnStatement = function (statement) { - this.recordSourceMappingStart(statement); - if (statement.expression) { - this.writeToOutput("return "); - this.emit(statement.expression); - } else { - this.writeToOutput("return"); - } - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitForInStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.left) { - this.emit(statement.left); - } else { - this.emit(statement.variableDeclaration); - } - this.writeToOutput(" in "); - this.emit(statement.expression); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitForStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.variableDeclaration) { - this.emit(statement.variableDeclaration); - } else if (statement.initializer) { - this.emit(statement.initializer); - } - - this.writeToOutput("; "); - this.emitJavascript(statement.condition, false); - this.writeToOutput(";"); - if (statement.incrementor) { - this.writeToOutput(" "); - this.emitJavascript(statement.incrementor, false); - } - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitWithStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("with ("); - if (statement.condition) { - this.emit(statement.condition); - } - - this.writeToOutput(")"); - var prevInWithBlock = this.inWithBlock; - this.inWithBlock = true; - this.emitBlockOrStatement(statement.statement); - this.inWithBlock = prevInWithBlock; - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitSwitchStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("switch ("); - this.emit(statement.expression); - this.recordSourceMappingStart(statement.closeParenToken); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement.closeParenToken); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - this.emitList(statement.switchClauses, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCaseSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("case "); - this.emit(clause.expression); - this.writeToOutput(":"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitSwitchClauseBody = function (body) { - if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { - this.emit(body.childAt(0)); - this.writeLineToOutput(""); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emit(body); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitDefaultSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("default:"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitTryStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("try "); - this.emit(statement.block); - this.emitJavascript(statement.catchClause, false); - - if (statement.finallyClause) { - this.emit(statement.finallyClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCatchClause = function (clause) { - this.writeToOutput(" "); - this.recordSourceMappingStart(clause); - this.writeToOutput("catch ("); - this.emit(clause.identifier); - this.writeToOutput(")"); - this.emit(clause.block); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitFinallyClause = function (clause) { - this.writeToOutput(" finally"); - this.emit(clause.block); - }; - - Emitter.prototype.emitDebuggerStatement = function (statement) { - this.writeToOutputWithSourceMapRecord("debugger", statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitNumericLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitRegularExpressionLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitStringLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitEqualsValueClause = function (clause) { - this.writeToOutput(" = "); - this.emit(clause.value); - }; - - Emitter.prototype.emitParameter = function (parameter) { - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); - }; - - Emitter.prototype.emitConstructorDeclaration = function (declaration) { - if (declaration.block) { - this.emitConstructor(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { - return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); - }; - - Emitter.prototype.emitFunctionDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { - this.emitFunction(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.emitSourceUnit = function (sourceUnit) { - if (!this.document.isDeclareFile()) { - var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); - this.pushDecl(pullDecl); - this.emitScriptElements(sourceUnit); - this.popDecl(pullDecl); - - this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); - } - }; - - Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); - }; - - Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { - this.emitComments(declaration, true); - this.emitEnum(declaration); - this.emitComments(declaration, false); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); - }; - - Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { - this.emitModuleDeclarationWorker(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); - }; - - Emitter.prototype.emitClassDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { - this.emitClass(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { - return declaration.preComments() !== null; - }; - - Emitter.prototype.emitInterfaceDeclaration = function (declaration) { - this.emitComments(declaration, true, true); - }; - - Emitter.prototype.firstVariableDeclarator = function (statement) { - return statement.declaration.declarators.nonSeparatorAt(0); - }; - - Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { - return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; - }; - - Emitter.prototype.shouldEmitVariableStatement = function (statement) { - return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); - }; - - Emitter.prototype.emitVariableStatement = function (statement) { - if (this.isNotAmbientOrHasInitializer(statement)) { - this.emitComments(statement, true); - this.emit(statement.declaration); - this.writeToOutput(";"); - this.emitComments(statement, false); - } else { - this.emitComments(statement, true, true); - } - }; - - Emitter.prototype.emitGenericType = function (type) { - this.emit(type.name); - }; - - Emitter.prototype.shouldEmit = function (ast) { - if (!ast) { - return false; - } - - switch (ast.kind()) { - case 133 /* ImportDeclaration */: - return this.shouldEmitImportDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.shouldEmitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.shouldEmitInterfaceDeclaration(ast); - case 129 /* FunctionDeclaration */: - return this.shouldEmitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.shouldEmitModuleDeclaration(ast); - case 148 /* VariableStatement */: - return this.shouldEmitVariableStatement(ast); - case 223 /* OmittedExpression */: - return false; - case 132 /* EnumDeclaration */: - return this.shouldEmitEnumDeclaration(ast); - } - - return true; - }; - - Emitter.prototype.emit = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 2 /* SeparatedList */: - return this.emitSeparatedList(ast); - case 1 /* List */: - return this.emitList(ast); - case 120 /* SourceUnit */: - return this.emitSourceUnit(ast); - case 133 /* ImportDeclaration */: - return this.emitImportDeclaration(ast); - case 134 /* ExportAssignment */: - return this.setExportAssignment(ast); - case 131 /* ClassDeclaration */: - return this.emitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitInterfaceDeclaration(ast); - case 11 /* IdentifierName */: - return this.emitName(ast, true); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast); - case 219 /* SimpleArrowFunctionExpression */: - return this.emitSimpleArrowFunctionExpression(ast); - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.emitParenthesizedArrowFunctionExpression(ast); - case 129 /* FunctionDeclaration */: - return this.emitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitModuleDeclaration(ast); - case 224 /* VariableDeclaration */: - return this.emitVariableDeclaration(ast); - case 126 /* GenericType */: - return this.emitGenericType(ast); - case 137 /* ConstructorDeclaration */: - return this.emitConstructorDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitEnumDeclaration(ast); - case 243 /* EnumElement */: - return this.emitEnumElement(ast); - case 222 /* FunctionExpression */: - return this.emitFunctionExpression(ast); - case 148 /* VariableStatement */: - return this.emitVariableStatement(ast); - } - - this.emitComments(ast, true); - this.emitWorker(ast); - this.emitComments(ast, false); - }; - - Emitter.prototype.emitWorker = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 13 /* NumericLiteral */: - return this.emitNumericLiteral(ast); - case 12 /* RegularExpressionLiteral */: - return this.emitRegularExpressionLiteral(ast); - case 14 /* StringLiteral */: - return this.emitStringLiteral(ast); - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 37 /* TrueKeyword */: - return this.emitLiteralExpression(ast); - case 35 /* ThisKeyword */: - return this.emitThisExpression(ast); - case 50 /* SuperKeyword */: - return this.emitSuperExpression(ast); - case 217 /* ParenthesizedExpression */: - return this.emitParenthesizedExpression(ast); - case 214 /* ArrayLiteralExpression */: - return this.emitArrayLiteralExpression(ast); - case 211 /* PostDecrementExpression */: - case 210 /* PostIncrementExpression */: - return this.emitPostfixUnaryExpression(ast); - case 167 /* LogicalNotExpression */: - case 166 /* BitwiseNotExpression */: - case 165 /* NegateExpression */: - case 164 /* PlusExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.emitPrefixUnaryExpression(ast); - case 213 /* InvocationExpression */: - return this.emitInvocationExpression(ast); - case 221 /* ElementAccessExpression */: - return this.emitElementAccessExpression(ast); - case 212 /* MemberAccessExpression */: - return this.emitMemberAccessExpression(ast); - case 121 /* QualifiedName */: - return this.emitQualifiedName(ast); - case 173 /* CommaExpression */: - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* LogicalOrExpression */: - case 188 /* LogicalAndExpression */: - case 189 /* BitwiseOrExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 191 /* BitwiseAndExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return this.emitBinaryExpression(ast); - case 186 /* ConditionalExpression */: - return this.emitConditionalExpression(ast); - case 232 /* EqualsValueClause */: - return this.emitEqualsValueClause(ast); - case 242 /* Parameter */: - return this.emitParameter(ast); - case 146 /* Block */: - return this.emitBlock(ast); - case 235 /* ElseClause */: - return this.emitElseClause(ast); - case 147 /* IfStatement */: - return this.emitIfStatement(ast); - case 149 /* ExpressionStatement */: - return this.emitExpressionStatement(ast); - case 139 /* GetAccessor */: - return this.emitGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitSetAccessor(ast); - case 157 /* ThrowStatement */: - return this.emitThrowStatement(ast); - case 150 /* ReturnStatement */: - return this.emitReturnStatement(ast); - case 216 /* ObjectCreationExpression */: - return this.emitObjectCreationExpression(ast); - case 151 /* SwitchStatement */: - return this.emitSwitchStatement(ast); - case 233 /* CaseSwitchClause */: - return this.emitCaseSwitchClause(ast); - case 234 /* DefaultSwitchClause */: - return this.emitDefaultSwitchClause(ast); - case 152 /* BreakStatement */: - return this.emitBreakStatement(ast); - case 153 /* ContinueStatement */: - return this.emitContinueStatement(ast); - case 154 /* ForStatement */: - return this.emitForStatement(ast); - case 155 /* ForInStatement */: - return this.emitForInStatement(ast); - case 158 /* WhileStatement */: - return this.emitWhileStatement(ast); - case 163 /* WithStatement */: - return this.emitWithStatement(ast); - case 220 /* CastExpression */: - return this.emitCastExpression(ast); - case 215 /* ObjectLiteralExpression */: - return this.emitObjectLiteralExpression(ast); - case 240 /* SimplePropertyAssignment */: - return this.emitSimplePropertyAssignment(ast); - case 241 /* FunctionPropertyAssignment */: - return this.emitFunctionPropertyAssignment(ast); - case 156 /* EmptyStatement */: - return this.writeToOutputWithSourceMapRecord(";", ast); - case 159 /* TryStatement */: - return this.emitTryStatement(ast); - case 236 /* CatchClause */: - return this.emitCatchClause(ast); - case 237 /* FinallyClause */: - return this.emitFinallyClause(ast); - case 160 /* LabeledStatement */: - return this.emitLabeledStatement(ast); - case 161 /* DoStatement */: - return this.emitDoStatement(ast); - case 171 /* TypeOfExpression */: - return this.emitTypeOfExpression(ast); - case 170 /* DeleteExpression */: - return this.emitDeleteExpression(ast); - case 172 /* VoidExpression */: - return this.emitVoidExpression(ast); - case 162 /* DebuggerStatement */: - return this.emitDebuggerStatement(ast); - } - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; - - function getLastConstructor(classDecl) { - return classDecl.classElements.lastOrDefault(function (e) { - return e.kind() === 137 /* ConstructorDeclaration */; - }); - } - TypeScript.getLastConstructor = getLastConstructor; - - function getTrimmedTextLines(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - return comment.fullText().split("\n").map(function (s) { - return s.trim(); - }); - } else { - return [comment.fullText().trim()]; - } - } - TypeScript.getTrimmedTextLines = getTrimmedTextLines; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += memberName.text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripStartAndEndQuotes(str) { - var firstCharCode = str && str.charCodeAt(0); - if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - return str.substring(1, str.length - 1); - } - - return str; - } - TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; - - function isSingleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isDoubleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; - } - TypeScript.isDoubleQuoted = isDoubleQuoted; - - function isQuoted(str) { - return isDoubleQuoted(str) || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - var switchToForwardSlashesRegEx = /\\/g; - function switchToForwardSlashes(path) { - return path.replace(switchToForwardSlashesRegEx, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { - if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { - absoluteModPath = "file:///" + absoluteModPath; - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function changePathToDTS(modPath) { - return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.length > 0 && path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function convertToDirectoryPath(dirPath) { - if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { - dirPath += "/"; - } - - return dirPath; - } - TypeScript.convertToDirectoryPath = convertToDirectoryPath; - - var normalizePathRegEx = /^\\\\[^\\]/; - function normalizePath(path) { - if (normalizePathRegEx.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - function isNoDefaultLibMatch(comment) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - return isNoDefaultLibRegex.exec(comment); - } - - TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; - - function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { - var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } - } - } - - return null; - } - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - var start = new Date().getTime(); - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 107 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 72 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionScanImportsTime += totalTime; - } - - function processTripleSlashDirectives(fileName, lineMap, firstToken) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - var diagnostics = []; - var referencedFiles = []; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - var isNoDefaultLib = isNoDefaultLibMatch(triviaText); - if (isNoDefaultLib) { - noDefaultLib = isNoDefaultLib[3] === "true"; - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; - } - - function preProcessFile(fileName, sourceText, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); - - scannerDiagnostics.length = 0; - return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); - } - TypeScript.getParseOptions = getParseOptions; - - function getReferencedFiles(fileName, sourceText) { - return preProcessFile(fileName, sourceText, false).referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ReferenceResolutionResult = (function () { - function ReferenceResolutionResult() { - this.resolvedFiles = []; - this.diagnostics = []; - this.seenNoDefaultLibTag = false; - } - return ReferenceResolutionResult; - })(); - TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; - - var ReferenceLocation = (function () { - function ReferenceLocation(filePath, lineMap, position, length, isImported) { - this.filePath = filePath; - this.lineMap = lineMap; - this.position = position; - this.length = length; - this.isImported = isImported; - } - return ReferenceLocation; - })(); - - var ReferenceResolver = (function () { - function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { - this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this.inputFileNames = inputFileNames; - this.host = host; - this.visited = {}; - } - ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { - var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); - return resolver.resolveInputFiles(); - }; - - ReferenceResolver.prototype.resolveInputFiles = function () { - var _this = this; - var result = new ReferenceResolutionResult(); - - if (!this.inputFileNames || this.inputFileNames.length <= 0) { - return result; - } - - var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); - this.inputFileNames.forEach(function (fileName) { - return _this.resolveIncludedFile(fileName, referenceLocation, result); - }); - - return result; - }; - - ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { - var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); - - if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); - } - - return normalizedPath; - } - - if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { - var dtsFile = normalizedPath + ".d.ts"; - var tsFile = normalizedPath + ".ts"; - - if (this.host.fileExists(tsFile)) { - normalizedPath = tsFile; - } else { - normalizedPath = dtsFile; - } - } - - if (!this.host.fileExists(normalizedPath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); - } - - return normalizedPath; - } - - return this.resolveFile(normalizedPath, resolutionResult); - }; - - ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { - var isRelativePath = TypeScript.isRelative(path); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); - - if (isRelativePath || isRootedPath) { - return this.resolveIncludedFile(path, referenceLocation, resolutionResult); - } else { - var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); - var searchFilePath = null; - var dtsFileName = path + ".d.ts"; - var tsFilePath = path + ".ts"; - - var start = new Date().getTime(); - - do { - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - parentDirectory = this.host.getParentDirectory(parentDirectory); - } while(parentDirectory); - - TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; - - if (!searchFilePath) { - return path; - } - - return this.resolveFile(searchFilePath, resolutionResult); - } - }; - - ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { - var _this = this; - var visitedPath = this.isVisited(normalizedPath); - if (!visitedPath) { - this.recordVisitedFile(normalizedPath); - - var start = new Date().getTime(); - var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionIOTime += totalTime; - - var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); - var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); - resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); - - if (preprocessedFileInformation.isLibFile) { - resolutionResult.seenNoDefaultLibTag = true; - } - - var normalizedReferencePaths = []; - preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); - var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); - normalizedReferencePaths.push(normalizedReferencePath); - }); - - var normalizedImportPaths = []; - for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { - var fileImport = preprocessedFileInformation.importedFiles[i]; - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); - var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); - normalizedImportPaths.push(normalizedImportPath); - } - - resolutionResult.resolvedFiles.push({ - path: normalizedPath, - referencedFiles: normalizedReferencePaths, - importedFiles: normalizedImportPaths - }); - } else { - normalizedPath = visitedPath; - } - - return normalizedPath; - }; - - ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { - var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; - var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); - return normalizedPath; - }; - - ReferenceResolver.prototype.getUniqueFileId = function (filePath) { - return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); - }; - - ReferenceResolver.prototype.recordVisitedFile = function (filePath) { - this.visited[this.getUniqueFileId(filePath)] = filePath; - }; - - ReferenceResolver.prototype.isVisited = function (filePath) { - return this.visited[this.getUniqueFileId(filePath)]; - }; - - ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { - if (!filePath1 || !filePath2) { - return false; - } - - if (this.useCaseSensitiveFileResolution) { - return filePath1 === filePath2; - } else { - return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); - } - }; - return ReferenceResolver; - })(); - TypeScript.ReferenceResolver = ReferenceResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(name, writeByteOrderMark, outputFileType) { - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.outputFileType = outputFileType; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += TypeScript.newLine(); - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - }; - - TextWriter.prototype.getOutputFile = function () { - return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.document = document; - this.compiler = compiler; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.emittedReferencePaths = false; - this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); - } - DeclarationEmitter.prototype.getOutputFile = function () { - return this.declFile.getOutputFile(); - }; - - DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { - this.emitDeclarationsForSourceUnit(sourceUnit); - }; - - DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.emitDeclarationsForAST(list.childAt(i)); - } - }; - - DeclarationEmitter.prototype.emitSeparatedList = function (list) { - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.emitDeclarationsForAST(list.nonSeparatorAt(i)); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { - switch (ast.kind()) { - case 148 /* VariableStatement */: - return this.emitDeclarationsForVariableStatement(ast); - case 141 /* PropertySignature */: - return this.emitPropertySignature(ast); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast, true, true); - case 136 /* MemberVariableDeclaration */: - return this.emitDeclarationsForMemberVariableDeclaration(ast); - case 137 /* ConstructorDeclaration */: - return this.emitDeclarationsForConstructorDeclaration(ast); - case 139 /* GetAccessor */: - return this.emitDeclarationsForGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitDeclarationsForSetAccessor(ast); - case 138 /* IndexMemberDeclaration */: - return this.emitIndexMemberDeclaration(ast); - case 144 /* IndexSignature */: - return this.emitIndexSignature(ast); - case 142 /* CallSignature */: - return this.emitCallSignature(ast); - case 143 /* ConstructSignature */: - return this.emitConstructSignature(ast); - case 145 /* MethodSignature */: - return this.emitMethodSignature(ast); - case 129 /* FunctionDeclaration */: - return this.emitDeclarationsForFunctionDeclaration(ast); - case 135 /* MemberFunctionDeclaration */: - return this.emitMemberFunctionDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.emitDeclarationsForClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitDeclarationsForInterfaceDeclaration(ast); - case 133 /* ImportDeclaration */: - return this.emitDeclarationsForImportDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitDeclarationsForModuleDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitDeclarationsForEnumDeclaration(ast); - case 134 /* ExportAssignment */: - return this.emitDeclarationsForExportAssignment(ast); - } - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - return this.indenter.getIndent(); - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { - var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { - var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - var start = new Date().getTime(); - var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); - var result = declSymbol && declSymbol.isExternallyVisible(); - TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; - - return result; - } - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { - var result = this.getIndentString(); - var pullFlags = pullDecl.flags; - - if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); - - var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); - var container = this.getEnclosingContainer(declAST); - - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { - container = this.getEnclosingContainer(container); - } - - var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); - - if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (isExternalModule || container.kind() === 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString !== "import") { - result += "declare "; - } - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { - this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { - var declarationContainerAst = this.getEnclosingContainer(ast); - - var start = new Date().getTime(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); - - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - - var isNotAGenericType = ast.kind() !== 126 /* GenericType */; - - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = TypeScript.getTrimmedTextLines(comment); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { - var start = new Date().getTime(); - var decl = this.semanticInfoChain.getDeclForAST(boundDecl); - var pullSymbol = decl.getSymbol(); - TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; - - var type = pullSymbol.type; - TypeScript.Debug.assert(type); - - this.declFile.Write(": "); - this.emitTypeSignature(boundDecl, type); - }; - - DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { - this.emitDeclarationComments(varDecl); - this.emitIndent(); - this.declFile.Write(varDecl.propertyName.text()); - if (varDecl.questionToken) { - this.declFile.Write("?"); - } - - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - if (isFirstVarInList) { - this.emitDeclFlags(varDecl, "var"); - } - - this.declFile.Write(varDecl.propertyName.text()); - - if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - if (isLastVarInList) { - this.declFile.WriteLine(";"); - } else { - this.declFile.Write(", "); - } - } - }; - - DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { - if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } - this.declFile.Write("static "); - } else { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } else { - this.declFile.Write("public "); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(varDecl.modifiers); - ; - - this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); - - if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - this.declFile.WriteLine(";"); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { - this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); - }; - - 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); - } - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(id.text()); - if (isOptional) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (!isPrivate) { - this.emitTypeOfVariableDeclaratorOrParameter(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var start = new Date().getTime(); - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - var signatures = funcTypeSymbol.getCallSignatures(); - var result = signatures && signatures.length > 1; - - return result; - }; - - DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("constructor"); - - this.declFile.Write("("); - 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.ASTHelpers.parametersFromParameterList(parameterList)); - this.declFile.Write(")"); - }; - - DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { - var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); - var argsLen = parameterList.length; - if (hasLastParameterRestParameter) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - - if (hasLastParameterRestParameter) { - if (parameterList.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - var index = parameterList.length - 1; - this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); - } - }; - - DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitDeclFlags(funcDecl, "function"); - var id = funcDecl.propertyName.text(); - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); - - this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); - - if (!isPrivate) { - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - this.emitDeclarationComments(funcDecl); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); - - this.emitIndent(); - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("new"); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write(funcDecl.propertyName.text()); - if (funcDecl.questionToken) { - this.declFile.Write("? "); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - if (funcDecl.block) { - var funcTypeSymbol = funcSymbol.type; - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - var id = funcDecl.identifier.text(); - this.emitDeclFlags(funcDecl, "function"); - if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { - this.declFile.Write(id); - } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { - this.declFile.Write("new"); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { - this.emitDeclarationsForAST(funcDecl.indexSignature); - }; - - DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("["); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); - this.declFile.Write("]"); - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { - if (bases && (bases.nonSeparatorCount() > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.nonSeparatorCount(); - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - var base = bases.nonSeparatorAt(i); - var baseType = this.semanticInfoChain.getSymbolForAST(base); - this.emitTypeSignature(base, baseType); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var start = new Date().getTime(); - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - var comments = []; - if (accessors.getter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); - } - if (accessors.setter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); - } - - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { - var start = new Date().getTime(); - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { - return; - } - - var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); - this.emitAccessorDeclarationComments(funcDecl); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(modifiers); - this.declFile.Write(name.text()); - if (!isPrivate) { - this.declFile.Write(" : "); - var type = accessorSymbol.type; - this.emitTypeSignature(funcDecl, type); - } - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { - argsLen--; - } - - 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(";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { - if (!this.canEmitDeclarations(classDecl)) { - return; - } - - var className = classDecl.identifier.text(); - this.emitDeclarationComments(classDecl); - var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.emitDeclFlags(classDecl, "class"); - this.declFile.Write(className); - - this.emitTypeParameters(classDecl.typeParameterList); - this.emitHeritageClauses(classDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - var constructorDecl = TypeScript.getLastConstructor(classDecl); - if (constructorDecl) { - this.emitClassMembersFromConstructorDefinition(constructorDecl); - } - - this.emitDeclarationsForList(classDecl.classElements); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { - if (clauses) { - for (var i = 0, n = clauses.childCount(); i < n; i++) { - this.emitHeritageClause(clauses.childAt(i)); - } - } - }; - - DeclarationEmitter.prototype.emitHeritageClause = function (clause) { - this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); - }; - - DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getEnclosingContainer(typeParams); - - var start = new Date().getTime(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); - var containerSymbol = containerDecl.getSymbol(); - TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; - - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArgumentsOrTypeParameters(); - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { - if (!this.canEmitDeclarations(interfaceDecl)) { - return; - } - - var interfaceName = interfaceDecl.identifier.text(); - this.emitDeclarationComments(interfaceDecl); - var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); - this.emitDeclFlags(interfaceDecl, "interface"); - this.declFile.Write(interfaceName); - - this.emitTypeParameters(interfaceDecl.typeParameterList); - this.emitHeritageClauses(interfaceDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - - this.emitSeparatedList(interfaceDecl.body.typeMembers); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); - var importSymbol = importDecl.getSymbol(); - var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); - - if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - if (isExportedImportDecl) { - this.declFile.Write("export "); - } - this.declFile.Write("import "); - this.declFile.Write(importDeclAST.identifier.text() + " = "); - if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); - } else { - this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - this.emitDeclarationComments(moduleDecl); - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclFlags(moduleDecl, "enum"); - this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.enumElements.nonSeparatorCount(); - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); - var enumElement = memberDecl; - var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); - this.emitDeclarationComments(enumElement); - this.emitIndent(); - this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue !== null) { - this.declFile.Write(" = " + enumElementDecl.constantValue); - } - this.declFile.WriteLine(","); - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclarationComments(moduleDecl); - - var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); - this.emitDeclFlags(name, "module"); - - if (moduleDecl.stringLiteral) { - this.declFile.Write(moduleDecl.stringLiteral.text()); - } else { - this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); - } - - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - - this.emitDeclarationsForList(moduleDecl.moduleElements); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write(ast.identifier.text()); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { - if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { - return reference; - } - - var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); - var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); - return resolvedReferencePath; - }; - - DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { - if (this.emittedReferencePaths) { - return; - } - - var documents = []; - if (this.document.emitToOwnOutputFile()) { - var scriptReferences = this.document.referencedFiles; - var addedGlobalDocument = false; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { - documents = documents.concat(document); - - if (!document.isDeclareFile() && document.isExternalModule()) { - addedGlobalDocument = true; - } - } - } - } else { - var fileNames = this.compiler.fileNames(); - for (var i = 0; i < fileNames.length; i++) { - var doc = this.compiler.getDocument(fileNames[i]); - if (!doc.isDeclareFile() && !doc.isExternalModule()) { - var scriptReferences = doc.referencedFiles; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.isDeclareFile() || document.isExternalModule())) { - for (var k = 0; k < documents.length; k++) { - if (documents[k] === document) { - break; - } - } - - if (k === documents.length) { - documents = documents.concat(document); - } - } - } - } - } - } - - var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; - for (var i = 0; i < documents.length; i++) { - var document = documents[i]; - var declFileName; - if (document.isDeclareFile()) { - declFileName = document.fileName; - } else { - declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } - - declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); - this.declFile.WriteLine('/// '); - } - - this.emittedReferencePaths = true; - }; - - DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { - this.emitReferencePaths(sourceUnit); - this.emitDeclarationsForList(sourceUnit.moduleElements); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - if (keys[name]) { - this.add(name); - } - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] !== array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateEnumConstants = false; - this.removeComments = false; - this.watch = false; - this.noResolve = false; - this.allowAutomaticSemicolonInsertion = true; - this.noImplicitAny = false; - this.noLib = false; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Unspecified */; - this.outFileOption = ""; - this.outDirOption = ""; - this.mapSourceFiles = false; - this.mapRoot = ""; - this.sourceRoot = ""; - this.generateDeclarationFiles = false; - 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, createFileLog) { - this._propagateEnumConstants = propagateEnumConstants; - this._removeComments = removeComments; - this._watch = watch; - this._noResolve = noResolve; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._noImplicitAny = noImplicitAny; - this._noLib = noLib; - this._codeGenTarget = codeGenTarget; - this._moduleGenTarget = moduleGenTarget; - this._outFileOption = outFileOption; - this._outDirOption = outDirOption; - this._mapSourceFiles = mapSourceFiles; - this._mapRoot = mapRoot; - this._sourceRoot = sourceRoot; - this._generateDeclarationFiles = generateDeclarationFiles; - this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this._gatherDiagnostics = gatherDiagnostics; - this._codepage = codepage; - this._createFileLog = createFileLog; - } - ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { - return this._propagateEnumConstants; - }; - ImmutableCompilationSettings.prototype.removeComments = function () { - return this._removeComments; - }; - ImmutableCompilationSettings.prototype.watch = function () { - return this._watch; - }; - ImmutableCompilationSettings.prototype.noResolve = function () { - return this._noResolve; - }; - ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - ImmutableCompilationSettings.prototype.noImplicitAny = function () { - return this._noImplicitAny; - }; - ImmutableCompilationSettings.prototype.noLib = function () { - return this._noLib; - }; - ImmutableCompilationSettings.prototype.codeGenTarget = function () { - return this._codeGenTarget; - }; - ImmutableCompilationSettings.prototype.moduleGenTarget = function () { - return this._moduleGenTarget; - }; - ImmutableCompilationSettings.prototype.outFileOption = function () { - return this._outFileOption; - }; - ImmutableCompilationSettings.prototype.outDirOption = function () { - return this._outDirOption; - }; - ImmutableCompilationSettings.prototype.mapSourceFiles = function () { - return this._mapSourceFiles; - }; - ImmutableCompilationSettings.prototype.mapRoot = function () { - return this._mapRoot; - }; - ImmutableCompilationSettings.prototype.sourceRoot = function () { - return this._sourceRoot; - }; - ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { - return this._generateDeclarationFiles; - }; - ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { - return this._useCaseSensitiveFileResolution; - }; - ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { - return this._gatherDiagnostics; - }; - ImmutableCompilationSettings.prototype.codepage = function () { - return this._codepage; - }; - ImmutableCompilationSettings.prototype.createFileLog = function () { - return this._createFileLog; - }; - - ImmutableCompilationSettings.defaultSettings = function () { - if (!ImmutableCompilationSettings._defaultSettings) { - ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); - } - - return ImmutableCompilationSettings._defaultSettings; - }; - - 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, 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, "_")) { - resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; - } - } - - return result; - }; - return ImmutableCompilationSettings; - })(); - TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; - - PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; - - PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; - - PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; - - PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - function hasModifier(modifiers, flag) { - for (var i = 0, n = modifiers.length; i < n; i++) { - if (TypeScript.hasFlag(modifiers[i], flag)) { - return true; - } - } - - return false; - } - TypeScript.hasModifier = hasModifier; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; - PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; - - 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.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"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var pullDeclID = 0; - var sentinelEmptyPullDeclArray = []; - - var PullDecl = (function () { - 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; - this.childDeclTypeParameterCache = null; - this.name = declName; - this.kind = kind; - this.flags = declFlags; - this.semanticInfoChain = semanticInfoChain; - - if (displayName !== this.name) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.fileName = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentPath = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.isExternalModule = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getEnclosingDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { - var decl = this; - while (decl) { - switch (decl.kind) { - default: - return decl; - case 512 /* Variable */: - case 8192 /* TypeParameter */: - case 2048 /* Parameter */: - case 128 /* TypeAlias */: - case 67108864 /* EnumMember */: - } - - decl = decl.getParentDecl(); - } - - TypeScript.Debug.fail(); - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.name : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (symbol) { - this.semanticInfoChain.setSymbolForDecl(this, symbol); - }; - - 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 */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.semanticInfoChain.getSymbolForDecl(this); - }; - - PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain.getSymbolForDecl(this); - return !!symbol; - }; - - PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); - }; - - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(); - return this.semanticInfoChain.getSignatureSymbolForDecl(this); - }; - - PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); - return !!signatureSymbol; - }; - - PullDecl.prototype.setFlags = function (flags) { - this.flags = flags; - }; - - PullDecl.prototype.setFlag = function (flags) { - this.flags |= flags; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - valDecl.containerDecl = this; - }; - - PullDecl.prototype.getValueDecl = function () { - return this.synthesizedValDecl; - }; - - PullDecl.prototype.getContainerDecl = function () { - return this.containerDecl; - }; - - PullDecl.prototype.getChildDeclCache = function (declKind) { - if (declKind === 8192 /* TypeParameter */) { - if (!this.childDeclTypeParameterCache) { - this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeParameterCache; - } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { - if (!this.childDeclNamespaceCache) { - this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { - if (!this.childDeclTypeCache) { - this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeCache; - } else { - if (!this.childDeclValueCache) { - this.childDeclValueCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclValueCache; - } - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.kind === 8192 /* TypeParameter */) { - if (!this.typeParameters) { - this.typeParameters = []; - } - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - if (!this.childDecls) { - this.childDecls = []; - } - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.name; - - if (!(childDecl.kind & 7340032 /* SomeSignature */)) { - var cache = this.getChildDeclCache(childDecl.kind); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - } - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cacheVal = null; - - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; - } else if (searchKind & 164 /* SomeContainer */) { - cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; - } else { - cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; - } - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; - - if (cacheVal) { - return cacheVal; - } - } - - return sentinelEmptyPullDeclArray; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - if (!this.declGroups) { - this.declGroups = TypeScript.createIntrinsicsObject(); - } - - var declGroup = this.declGroups[decl.name]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.name); - declGroup.addDecl(decl); - this.declGroups[decl.name] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = null; - - if (this.declGroups) { - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - if (declGroups === null) { - declGroups = []; - } - - declGroups.push(this.declGroups[declName].getDecls()); - } - } - } - - return declGroups || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.hasBeenBound = function () { - return this.hasSymbol() || this.hasSignatureSymbol(); - }; - - PullDecl.prototype.isSynthesized = function () { - return false; - }; - - PullDecl.prototype.ast = function () { - return this.semanticInfoChain.getASTForDecl(this); - }; - - PullDecl.prototype.isRootDecl = function () { - throw TypeScript.Errors.abstract(); - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - var RootPullDecl = (function (_super) { - __extends(RootPullDecl, _super); - 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; - } - RootPullDecl.prototype.fileName = function () { - return this._fileName; - }; - - RootPullDecl.prototype.getParentPath = function () { - return [this]; - }; - - RootPullDecl.prototype.getParentDecl = function () { - return null; - }; - - RootPullDecl.prototype.isExternalModule = function () { - return this._isExternalModule; - }; - - 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, addToParent) { - if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); - this.parentDecl = null; - this.parentPath = null; - - this.parentDecl = parentDecl; - 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._rootDecl.fileName(); - }; - - NormalPullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - NormalPullDecl.prototype.getParentPath = function () { - if (!this.parentPath) { - var path = [this]; - var parentDecl = this.parentDecl; - - while (parentDecl) { - if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { - path.unshift(parentDecl); - } - - parentDecl = parentDecl.getParentDecl(); - } - - this.parentPath = path; - } - - return this.parentPath; - }; - - NormalPullDecl.prototype.isExternalModule = function () { - return false; - }; - - 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) { - _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); - this.constantValue = null; - } - return PullEnumElementDecl; - })(NormalPullDecl); - TypeScript.PullEnumElementDecl = PullEnumElementDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { - if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(NormalPullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - var PullSynthesizedDecl = (function (_super) { - __extends(PullSynthesizedDecl, _super); - function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { - _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); - this.semanticInfoChain = semanticInfoChain; - } - PullSynthesizedDecl.prototype.isSynthesized = function () { - return true; - }; - - PullSynthesizedDecl.prototype.fileName = function () { - return this._rootDecl ? this._rootDecl.fileName() : ""; - }; - return PullSynthesizedDecl; - })(NormalPullDecl); - TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.name === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullSymbolID = 0; - TypeScript.sentinelEmptyArray = []; - - var PullSymbol = (function () { - function PullSymbol(name, declKind) { - this.pullSymbolID = ++TypeScript.pullSymbolID; - this._container = null; - this.type = null; - this._declarations = null; - this.isResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isVarArg = false; - this.rootSymbol = null; - this._enclosingSignature = null; - this._docComments = null; - this.isPrinting = false; - this.name = name; - this.kind = declKind; - } - PullSymbol.prototype.isAny = function () { - return false; - }; - - PullSymbol.prototype.isType = function () { - return (this.kind & 58728795 /* SomeType */) !== 0; - }; - - PullSymbol.prototype.isTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) !== 0; - }; - - PullSymbol.prototype.isArrayNamedTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.kind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isInterface = function () { - return this.kind === 16 /* Interface */; - }; - - PullSymbol.prototype.isMethod = function () { - return this.kind === 65536 /* Method */; - }; - - PullSymbol.prototype.isProperty = function () { - return this.kind === 4096 /* Property */; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { - if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } - if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } - var scopeDeclarations = scopeSymbol.getDeclarations(); - var scopeSymbolAliasesToLookIn = []; - - for (var i = 0; i < scopeDeclarations.length; i++) { - var scopeDecl = scopeDeclarations[i]; - if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { - visitedScopeDeclarations.push(scopeDecl); - - var childDecls = scopeDecl.getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - var childDecl = childDecls[j]; - if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { - var symbol = childDecl.getSymbol(); - - if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { - aliasSymbols.push(symbol); - return aliasSymbols; - } - - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { - scopeSymbolAliasesToLookIn.push(symbol); - } - } - } - } - } - - for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { - var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; - - aliasSymbols.push(scopeSymbolAlias); - var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); - if (result) { - return result; - } - - aliasSymbols.pop(); - } - - return null; - }; - - PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { - var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); - return symbols; - } - - return null; - }; - - PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { - if (aliasSymbol) { - if (aliasSymbol.assignedValue()) { - return false; - } - - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { - return false; - } - - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { - return false; - } - - return true; - } - - return false; - }; - - PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { - if (scopeSymbol) { - 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); - return internalAliases[0]; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { - if (!skipInternalAlias) { - var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); - if (internalAlias) { - return aliasNameGetter(internalAlias); - } - } - - var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); - - if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - 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 aliasFullName; - } - - return null; - }; - - PullSymbol.prototype._getResolver = function () { - TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain.getResolver(); - }; - - PullSymbol.prototype._resolveDeclaredSymbol = function () { - return this._getResolver().resolveDeclaredSymbol(this); - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getName(); - }); - return aliasName || this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getDisplayName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getDisplayName(); - }, skipInternalAliasName); - if (aliasDisplayName) { - return aliasDisplayName; - } - - var decls = this.getDeclarations(); - var name = decls.length && decls[0].getDisplayName(); - - return (name && name.length) ? name : this.name; - }; - - PullSymbol.prototype.getIsSpecialized = function () { - return false; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - 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; - }; - - PullSymbol.prototype.setEnclosingSignature = function (signature) { - this._enclosingSignature = signature; - }; - - PullSymbol.prototype.getEnclosingSignature = function () { - return this._enclosingSignature; - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - if (!this._declarations) { - this._declarations = [decl]; - } else { - this._declarations[this._declarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this._declarations) { - this._declarations = []; - } - - return this._declarations; - }; - - PullSymbol.prototype.hasDeclaration = function (decl) { - if (!this._declarations) { - return false; - } - - return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { - return eachDecl === decl; - }); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - if (this.rootSymbol) { - return; - } - - this._container = containerSymbol; - }; - - PullSymbol.prototype.getContainer = function () { - if (this.rootSymbol) { - return this.rootSymbol.getContainer(); - } - - return this._container; - }; - - PullSymbol.prototype.setResolved = function () { - this.isResolved = true; - this.inResolution = false; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.isResolved = false; - this.inResolution = false; - }; - - PullSymbol.prototype.anyDeclHasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (TypeScript.hasFlag(declarations[i].flags, flag)) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!TypeScript.hasFlag(declarations[i].flags, flag)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = node.getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - var nodeKind = node.kind; - if (nodeKind === 2048 /* Parameter */) { - break; - } else { - node = node.getContainer(); - } - } - return path; - }; - - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } - - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } - - 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; - } - } - } - if (commonNodeIndex >= 0) { - break; - } - } - - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); - } else { - return aPath; - } - }; - - PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var str = this.getNameAndTypeName(scopeSymbol); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var _this = this; - var path = this.pathToRoot(); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol === _this ? null : symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findCommonAncestorPath(scopeSymbol); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].kind; - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.type; - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - 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 */) { - var signatures = type.getCallSignatures(); - 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); - return typeName; - } - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.type; - var nameStr = this.getDisplayName(scopeSymbol); - if (type) { - nameStr = nameStr + (this.isOptional ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return TypeScript.MemberName.create(nameStr); - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - - inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); - - var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); - inIsExternallyVisibleSymbols.pop(); - - return result; - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.kind; - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.rootSymbol) { - return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); - } - - if (this.isType()) { - var associatedContainerSymbol = this.getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.anyDeclHasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - var decls = this.getDeclarations(); - if (decls.length) { - var parentDecl = decls[0].getParentDecl(); - if (parentDecl) { - var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind === 1 /* Script */) { - return true; - } - - return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); - } - } - - return true; - } - - 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 */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { - var ast = decl.ast(); - - if (ast) { - 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.ASTHelpers.docComments(ast); - } - } - - return []; - }; - - PullSymbol.prototype.getDocCommentArray = function (symbol) { - var docComments = []; - if (!symbol) { - return docComments; - } - - 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 */) { - continue; - } - docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); - } - return docComments; - }; - - PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { - if (classSymbol.getHasDefaultConstructor()) { - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); - } - } - - return classSymbol.type.getConstructSignatures()[0]; - }; - - PullSymbol.prototype.getDocCommentText = function (comments) { - var docCommentText = new Array(); - for (var c = 0; c < comments.length; c++) { - var commentText = this.getDocCommentTextValue(comments[c]); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - PullSymbol.prototype.getDocCommentTextValue = function (comment) { - return this.cleanJSDocComment(comment.fullText()); - }; - - PullSymbol.prototype.docComments = function (useConstructorAsClass) { - var decls = this.getDeclarations(); - 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 */) { - var classSymbol = this.returnType; - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - docComments = extendedTypes[0].getConstructorMethod().docComments(); - } else { - docComments = ""; - } - } else if (this.kind === 2048 /* Parameter */) { - var parameterComments = []; - - var funcContainer = this.getEnclosingSignature(); - var funcDocComments = this.getDocCommentArray(funcContainer); - var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); - if (paramComment != "") { - parameterComments.push(paramComment); - } - - var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); - if (paramSelfComment != "") { - parameterComments.push(paramSelfComment); - } - docComments = parameterComments.join("\n"); - } else { - var getSymbolComments = true; - if (this.kind === 16777216 /* FunctionType */) { - var functionSymbol = this.getFunctionSymbol(); - - if (functionSymbol) { - docComments = functionSymbol._docComments || ""; - getSymbolComments = false; - } else { - var declarationList = this.getDeclarations(); - if (declarationList.length > 0) { - docComments = declarationList[0].getSymbol()._docComments || ""; - getSymbolComments = false; - } - } - } - if (getSymbolComments) { - docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments === "") { - if (this.kind === 1048576 /* CallSignature */) { - var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { - docComments = callTypeSymbol.docComments(); - } - } - } - } - } - - this._docComments = docComments; - } - - return this._docComments; - }; - - PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].fullText(); - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!this.isSpaceChar(commentContents, j)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - - PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = new Array(); - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.start; - for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.end); - } - - var newCleanPos = this.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - PullSymbol.prototype.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = this.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - start: nonSpaceIndex, - end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - 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.returnType = null; - this.functionType = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this._allowedToReferenceTypeParameters = null; - this._instantiationCache = null; - this.hasBeenChecked = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return this._isDefinition; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - 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) { - this.parameters = []; - } - - this.parameters[this.parameters.length] = parameter; - this.hasOptionalParam = isOptional; - - if (!parameter.getEnclosingSignature()) { - parameter.setEnclosingSignature(this); - } - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this._typeParameters) { - this._typeParameters = []; - } - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - 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 = []; - } - - return this._typeParameters; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - - for (var i = 0; i < this.getTypeParameters().length; i++) { - this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; - } - } - - memberSymbol = this._memberTypeParameterNameCache[name]; - - 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; - this._stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].type; - if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { - this._stringConstantOverload = true; - } - } - } - - 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); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - if (!signatures) { - return result; - } - - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.parameters; - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].type; - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].isVarArg; - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - if (this.returnType) { - builder.add(this.returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - 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 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 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 wrappingTypeParameterID; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { - if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - - var parameters = this.parameters; - - for (var i = 0; i < parameters.length; i++) { - if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - } - - return false; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol(name, kind) { - _super.call(this, name, kind); - this._members = TypeScript.sentinelEmptyArray; - this._enclosedMemberTypes = null; - this._enclosedMemberContainers = null; - this._typeParameters = null; - this._allowedToReferenceTypeParameters = null; - this._specializedVersionsOfThisType = null; - this._arrayVersionOfThisType = null; - this._implementedTypes = null; - this._extendedTypes = null; - this._typesThatExplicitlyImplementThisType = null; - this._typesThatExtendThisType = null; - this._callSignatures = null; - this._allCallSignatures = null; - this._constructSignatures = null; - this._indexSignatures = null; - this._allIndexSignatures = null; - this._allIndexSignaturesOfAugmentedType = null; - this._memberNameCache = null; - this._enclosedTypeNameCache = null; - this._enclosedContainerCache = null; - this._typeParameterNameCache = null; - this._containedNonMemberNameCache = null; - this._containedNonMemberTypeNameCache = null; - this._containedNonMemberContainerCache = null; - this._simpleInstantiationCache = null; - this._complexInstantiationCache = null; - this._hasGenericSignature = false; - this._hasGenericMember = false; - this._hasBaseTypeConflict = false; - this._knownBaseTypeCount = 0; - this._associatedContainerTypeSymbol = null; - this._constructorMethod = null; - this._hasDefaultConstructor = false; - this._functionSymbol = null; - this._inMemberTypeNameEx = false; - this.inSymbolPrivacyCheck = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - this.typeReference = null; - this._widenedType = null; - this._isArrayNamedTypeReference = undefined; - this.type = this; - } - PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArrayNamedTypeReference === undefined) { - this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); - } - - return this._isArrayNamedTypeReference; - }; - - PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { - var typeArgs = this.getTypeArguments(); - if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { - var declaration = this.getDeclarations()[0]; - - if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.kind === 8 /* Class */ || (this._constructorMethod !== null); - }; - PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return this.kind === 33554432 /* ConstructorType */; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - PullTypeSymbol.prototype.isEnum = function () { - return this.kind === 64 /* Enum */; - }; - - PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { - return null; - }; - - PullTypeSymbol.prototype.isObject = function () { - 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 () { - return this._knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this._knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this._knownBaseTypeCount++; - }; - - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.hasMembers = function () { - if (this._members !== TypeScript.sentinelEmptyArray) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this._hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this._hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this._hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this._hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this._associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this._associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this._arrayVersionOfThisType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - return null; - }; - - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this._arrayVersionOfThisType = arrayType; - }; - - PullTypeSymbol.prototype.getFunctionSymbol = function () { - return this._functionSymbol; - }; - - PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { - if (symbol) { - this._functionSymbol = symbol; - } - }; - - PullTypeSymbol.prototype.findContainedNonMember = function (name) { - if (!this._containedNonMemberNameCache) { - return null; - } - - return this._containedNonMemberNameCache[name]; - }; - - PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberTypeNameCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberContainerCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol) { - if (!memberSymbol) { - return; - } - - memberSymbol.setContainer(this); - - if (!this._memberNameCache) { - this._memberNameCache = TypeScript.createIntrinsicsObject(); - } - - if (this._members === TypeScript.sentinelEmptyArray) { - this._members = []; - } - - this._members.push(memberSymbol); - this._memberNameCache[memberSymbol.name] = memberSymbol; - }; - - PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - if (!enclosedType) { - return; - } - - enclosedType.setContainer(this); - - if (!this._enclosedTypeNameCache) { - this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberTypes) { - this._enclosedMemberTypes = []; - } - - this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; - this._enclosedTypeNameCache[enclosedType.name] = enclosedType; - }; - - PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - if (!enclosedContainer) { - return; - } - - enclosedContainer.setContainer(this); - - if (!this._enclosedContainerCache) { - this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberContainers) { - this._enclosedMemberContainers = []; - } - - this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; - this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; - }; - - PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - if (!enclosedNonMember) { - return; - } - - enclosedNonMember.setContainer(this); - - if (!this._containedNonMemberNameCache) { - this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - if (!enclosedNonMemberType) { - return; - } - - enclosedNonMemberType.setContainer(this); - - if (!this._containedNonMemberTypeNameCache) { - this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - if (!enclosedNonMemberContainer) { - return; - } - - enclosedNonMemberContainer.setContainer(this); - - if (!this._containedNonMemberContainerCache) { - this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; - }; - - PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!typeParameter) { - return; - } - - if (!typeParameter.getContainer()) { - typeParameter.setContainer(this); - } - - if (!this._typeParameterNameCache) { - this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._typeParameters) { - this._typeParameters = []; - } - - this._typeParameters[this._typeParameters.length] = typeParameter; - this._typeParameterNameCache[typeParameter.getName()] = typeParameter; - }; - - PullTypeSymbol.prototype.getMembers = function () { - return this._members; - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this._hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this._hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this._constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this._constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - if (!this._typeParameters) { - return TypeScript.sentinelEmptyArray; - } - - 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 (typeArgumentMap) { - if (this.isTypeParameter()) { - return true; - } - - 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; - } else { - if (!this._complexInstantiationCache) { - this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); - } - - this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; - } - - if (!this._specializedVersionsOfThisType) { - this._specializedVersionsOfThisType = []; - } - - this._specializedVersionsOfThisType.push(specializedVersionOfThisType); - }; - - PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { - if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { - if (!this._simpleInstantiationCache) { - return null; - } - - var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; - return result || null; - } else { - if (!this._complexInstantiationCache) { - return null; - } - - if (this.getAllowedToReferenceTypeParameters().length == 0) { - return this; - } - - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; - return result || null; - } - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - if (!this._specializedVersionsOfThisType) { - return TypeScript.sentinelEmptyArray; - } - - return this._specializedVersionsOfThisType; - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return null; - }; - - PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeParameters(); - }; - - PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { - if (!this._callSignatures) { - this._callSignatures = []; - } - - if (callSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - callSignature.functionType = this; - }; - - 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 = []; - } - - if (constructSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - 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 = []; - } - - this._indexSignatures[this._indexSignatures.length] = indexSignature; - - if (indexSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - indexSignature.functionType = this; - }; - - 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; - } - - var signatures = []; - - if (this._callSignatures) { - signatures = signatures.concat(this._callSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); - } - } - - this._allCallSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return this._constructSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnConstructSignatures = function () { - return this._constructSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function () { - var signatures = []; - - if (this._constructSignatures) { - signatures = signatures.concat(this._constructSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); - } - } - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return this._indexSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnIndexSignatures = function () { - return this._indexSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function () { - if (this._allIndexSignatures) { - return this._allIndexSignatures; - } - - var signatures = []; - - if (this._indexSignatures) { - signatures = signatures.concat(this._indexSignatures); - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); - } - } - - this._allIndexSignatures = signatures; - - 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; - } - - if (!this._implementedTypes) { - this._implementedTypes = []; - } - - this._implementedTypes[this._implementedTypes.length] = implementedType; - - implementedType.addTypeThatExplicitlyImplementsThisType(this); - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - if (!this._implementedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._implementedTypes; - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!extendedType) { - return; - } - - if (!this._extendedTypes) { - this._extendedTypes = []; - } - - this._extendedTypes[this._extendedTypes.length] = extendedType; - - extendedType.addTypeThatExtendsThisType(this); - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - if (!this._extendedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._extendedTypes; - }; - - PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - return this._typesThatExtendThisType; - }; - - PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - return this._typesThatExplicitlyImplementThisType; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { - return true; - } - - if (TypeScript.ArrayUtilities.contains(visited, this)) { - return true; - } - - visited.push(this); - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - visited.pop(); - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.kind === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - var memberSymbol = null; - - if (this._memberNameCache) { - memberSymbol = this._memberNameCache[name]; - } - - if (memberSymbol || !lookInParent) { - return memberSymbol; - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return null; - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedTypeNameCache) { - return null; - } - - memberSymbol = this._enclosedTypeNameCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedContainerCache) { - return null; - } - - memberSymbol = this._enclosedContainerCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - var allMembers = []; - - 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 */))) { - allMembers[allMembers.length] = member; - } - } - } - - if (this._extendedTypes) { - var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; - - for (var i = 0, n = this._extendedTypes.length; i < n; i++) { - var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - if (this.isContainer()) { - if (this._enclosedMemberTypes) { - for (var i = 0; i < this._enclosedMemberTypes.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberTypes[i]; - } - } - if (this._enclosedMemberContainers) { - for (var i = 0; i < this._enclosedMemberContainers.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberContainers[i]; - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - if (!this._typeParameterNameCache) { - return null; - } - - return this._typeParameterNameCache[name]; - }; - - PullTypeSymbol.prototype.setResolved = function () { - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArgumentsOrTypeParameters(); - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); - }; - - 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 !== "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); - return s; - }; - - 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, "", "[]"); - } - - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - if (skipTypeParametersInName) { - return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); - } else { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - - var typars = this.getTypeArgumentsOrTypeParameters(); - builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - } - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getTypeOfSymbol = function () { - var associatedContainerType = this.getAssociatedContainerType(); - if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { - return associatedContainerType; - } - - var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; - } - - return null; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var typeOfSymbol = this.getTypeOfSymbol(); - if (typeOfSymbol) { - var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); - return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); - } - - if (this._inMemberTypeNameEx) { - return TypeScript.MemberName.create("any"); - } - - this._inMemberTypeNameEx = true; - - var allMemberNames = new TypeScript.MemberNameArray(); - 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()) { - var methodCallSignatures = members[i].type.getCallSignatures(); - var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); - ; - var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); - allMemberNames.addAll(methodMemberNames); - } else { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - if (memberTypeName.isArray() && memberTypeName.delim === delim) { - allMemberNames.addAll(memberTypeName.entries); - } else { - allMemberNames.add(memberTypeName); - } - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - this._inMemberTypeNameEx = false; - - return allMemberNames; - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - return 2 /* Closed */; - }; - - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; - }; - - PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - var type = this; - - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { - return type.pullSymbolID; - } - - var constraint = type.getConstraint(); - var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; - return wrappingTypeParameterID; - } - - if (type.inWrapCheck) { - return 0; - } - - 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; - - var typeArguments = type.getTypeArguments(); - - if (type.isGeneric() && !typeArguments) { - typeArguments = type.getTypeParameters(); - } - - if (typeArguments) { - for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { - wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); - } - } - } - - 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); - } - - wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); - } - - if (!skipTypeArgumentCheck) { - type.inWrapCheck = false; - } - - return wrappingTypeParameterID; - }; - - 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - 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(); - for (var i = 0; i < typeArguments.length; i++) { - if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { - continue; - } - - if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { - return true; - } - } - - 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); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - - this.isResolved = true; - } - PullPrimitiveTypeSymbol.prototype.isAny = function () { - 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 () { - return false; - }; - - 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; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(_anyType, name) { - _super.call(this, name); - 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); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullContainerSymbol = (function (_super) { - __extends(PullContainerSymbol, _super); - function PullContainerSymbol(name, kind) { - _super.call(this, name, kind); - this.instanceSymbol = null; - this.assignedValue = null; - this.assignedType = null; - this.assignedContainer = null; - } - PullContainerSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this.assignedValue = symbol; - }; - - PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { - return this.assignedValue; - }; - - PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this.assignedType = type; - }; - - PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this.assignedType; - }; - - PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this.assignedContainer = container; - }; - - PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this.assignedContainer; - }; - - PullContainerSymbol.prototype.hasExportAssignment = function () { - return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; - }; - - PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { - return true; - } - - var moduleSymbol = containerSymbol; - var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - - PullContainerSymbol.prototype.getInstanceType = function () { - return this.instanceSymbol ? this.instanceSymbol.type : null; - }; - return PullContainerSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerSymbol = PullContainerSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 128 /* TypeAlias */); - this._assignedValue = null; - this._assignedType = null; - 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; - }; - - PullTypeAliasSymbol.prototype.isUsedAsValue = function () { - this._resolveDeclaredSymbol(); - return this._isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { - this._typeUsedExternally = true; - }; - - PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { - this._isUsedInExportAlias = true; - if (this.linkedAliasSymbols) { - this.linkedAliasSymbols.forEach(function (s) { - return s.setIsUsedInExportedAlias(); - }); - } - }; - - 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(); - }); - } - }; - - PullTypeAliasSymbol.prototype.assignedValue = function () { - this._resolveDeclaredSymbol(); - return this._assignedValue; - }; - - PullTypeAliasSymbol.prototype.assignedType = function () { - this._resolveDeclaredSymbol(); - return this._assignedType; - }; - - PullTypeAliasSymbol.prototype.assignedContainer = function () { - this._resolveDeclaredSymbol(); - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { - this._assignedValue = symbol; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (this._assignedValue) { - return this._assignedValue; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { - this._assignedType = type; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedType) { - if (this._assignedType.isAlias()) { - this.retrievingExportAssignment = true; - var sym = this._assignedType.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - } else if (this._assignedType !== this._assignedContainer) { - return this._assignedType; - } - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { - this._assignedContainer = container; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this._assignedType) { - return this._assignedType.getMembers(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this._assignedType) { - return this._assignedType.getCallSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this._assignedType) { - return this._assignedType.getConstructSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this._assignedType) { - return this._assignedType.getIndexSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this._assignedType) { - return this._assignedType.findMember(name, true); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedContainer(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { - if (this._assignedType) { - return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); - } - - return TypeScript.sentinelEmptyArray; - }; - return PullTypeAliasSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - - var PullTypeParameterSymbol = (function (_super) { - __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name) { - _super.call(this, name, 8192 /* TypeParameter */); - this._constraint = null; - } - PullTypeParameterSymbol.prototype.isTypeParameter = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { - this._constraint = constraintType; - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - 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(); - } - - return _super.prototype.getCallSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getConstructSignatures = function () { - if (this._constraint) { - return this._constraint.getConstructSignatures(); - } - - return _super.prototype.getConstructSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getIndexSignatures = function () { - if (this._constraint) { - return this._constraint.getIndexSignatures(); - } - - return _super.prototype.getIndexSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this._getterSymbol = null; - this._setterSymbol = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - if (!setter) { - return; - } - - this._setterSymbol = setter; - }; - - PullAccessorSymbol.prototype.getSetter = function () { - return this._setterSymbol; - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - if (!getter) { - return; - } - - this._getterSymbol = getter; - }; - - PullAccessorSymbol.prototype.getGetter = function () { - return this._getterSymbol; - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { - var substitution = ""; - var members = null; - - 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 getIDForTypeSubstitutionsOfType(type) { - var structure; - if (type.isError()) { - structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); - } else if (!type.isNamedTypeSymbol()) { - structure = getIDForTypeSubstitutionsFromObjectType(type); - } - - if (!structure) { - structure = type.pullSymbolID + "#"; - } - - return structure; - } - - function getIDForTypeSubstitutionsFromObjectType(type) { - if (type.isResolved) { - var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); - TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); - } - - return null; - } - - var GetIDForTypeSubStitutionWalker = (function () { - function GetIDForTypeSubStitutionWalker() { - this.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"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; - })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); - 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._inferredTypeAfterFixing = null; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - 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 TypeArgumentInferenceContext = (function () { - function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { - this.resolver = resolver; - this.context = context; - this.signatureBeingInferred = signatureBeingInferred; - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - this.candidateCache = []; - var typeParameters = signatureBeingInferred.getTypeParameters(); - for (var i = 0; i < typeParameters.length; i++) { - this.addInferenceRoot(typeParameters[i]); - } - } - TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { - return true; - } else { - this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); - return false; - } - }; - - TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache.release(); - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - }; - - TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.pullSymbolID]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.pullSymbolID] = info; - } - }; - - TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.pullSymbolID]; - }; - - TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { - var info = this.getInferenceInfo(param); - - if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { - info.addCandidate(candidate); - } - }; - - 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); - } - }; - - 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]; - - info.fixTypeParameter(this.resolver, this.context); - - for (var i = 0; i < results.length; i++) { - if (results[i].type === info.typeParameter) { - results[i].type = info._inferredTypeAfterFixing; - } - } - - results.push(info._inferredTypeAfterFixing); - } - - return results; - }; - - TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { - throw TypeScript.Errors.abstract(); - }; - return TypeArgumentInferenceContext; - })(); - 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, isInferentiallyTyping, typeArgumentInferenceContext) { - this.contextualType = contextualType; - this.provisional = provisional; - this.isInferentiallyTyping = isInferentiallyTyping; - this.typeArgumentInferenceContext = typeArgumentInferenceContext; - this.provisionallyTypedSymbols = []; - this.hasProvisionalErrors = false; - this.astSymbolMap = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].setUnresolved(); - } - }; - - PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { - if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } - if (typeof fileName === "undefined") { fileName = null; } - this.resolver = resolver; - this.inTypeCheck = inTypeCheck; - 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"); - this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); - } - } - PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { - if (!this.inProvisionalResolution()) { - this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); - } - }; - - PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { - return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); - }; - - PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); - }; - - 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(); - - if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; - } - - return tc; - }; - - PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { - return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; - }; - - PullTypeResolutionContext.prototype.getContextualType = function () { - var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - 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); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); - } - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { - if (diagnostic) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; - } else if (this.inTypeCheck && this.resolver) { - this.resolver.semanticInfoChain.addDiagnostic(diagnostic); - } - } - }; - - PullTypeResolutionContext.prototype.typeCheck = function () { - return this.inTypeCheck && !this.inProvisionalResolution(); - }; - - PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { - this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); - }; - - PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - var typeContext = this.contextStack[i]; - if (!typeContext.provisional) { - break; - } - - var symbol = typeContext.getSymbolForAST(ast); - if (symbol) { - return symbol; - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OverloadApplicabilityStatus; - (function (OverloadApplicabilityStatus) { - OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; - })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - this.diagnosticsFromOverloadResolution = []; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var MemberWithBaseOrigin = (function () { - function MemberWithBaseOrigin(memberSymbol, baseOrigin) { - this.memberSymbol = memberSymbol; - this.baseOrigin = baseOrigin; - } - return MemberWithBaseOrigin; - })(); - - var SignatureWithBaseOrigin = (function () { - function SignatureWithBaseOrigin(signature, baseOrigin) { - this.signature = signature; - this.baseOrigin = baseOrigin; - } - return SignatureWithBaseOrigin; - })(); - - var InheritedIndexSignatureInfo = (function () { - function InheritedIndexSignatureInfo() { - } - return InheritedIndexSignatureInfo; - })(); - - 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(); - return CompilerReservedName[nameText]; - } - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this._cachedAnyTypeArgs = null; - this.typeCheckCallBacks = []; - this.postTypeCheckWorkitems = []; - this._cachedFunctionArgumentsSymbol = null; - 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 */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getArrayNamedType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedRegExpInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { - if (!this._cachedFunctionArgumentsSymbol) { - this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); - this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; - this._cachedFunctionArgumentsSymbol.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); - functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); - this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - } - - 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); - }; - - PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { - return context.canTypeCheckAST(ast); - }; - - PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { - if (context && context.inProvisionalResolution()) { - context.setSymbolForAST(ast, symbol); - } else { - this.semanticInfoChain.setSymbolForAST(ast, symbol); - } - }; - - PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { - var symbol = this.semanticInfoChain.getSymbolForAST(ast); - - if (!symbol) { - if (context && context.inProvisionalResolution()) { - symbol = context.getSymbolForAST(ast); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { - if (typeof name === "undefined") { name = null; } - return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = decl.getParentPath(); - - if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; - var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; - - if (isContainer && containerType) { - if (symbol.anyDeclHasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - 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 & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - } - - if (parent.kind & 164 /* SomeContainer */) { - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - member = childDecls[0].getSymbol(); - - if (!member) { - member = childDecls[0].getSignatureSymbol(); - } - return this.getExportedMemberSymbol(member, parent); - } - - if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); - if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { - var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); - if (aliasSymbol) { - if ((declSearchKind & 58728795 /* SomeType */) !== 0) { - var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); - if (typeSymbol) { - return typeSymbol; - } - } else { - var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - return valueSymbol; - } - } - - return aliasSymbol; - } - } - } - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var _this = this; - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - 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; - - if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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(); - - if (instanceSymbol) { - instanceType = instanceSymbol.type; - - childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().type; - - var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.kind & 1032192 /* SomeFunction */) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - return candidateSymbol; - } - - var alias = tryFindAlias(decl); - if (alias) { - return alias; - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - if (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) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - var declKind = decl.kind; - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = decl.getFunctionExpressionName(); - if (functionExpressionName) { - result.push(decl); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - } - } - - var topLevelDecls = this.semanticInfoChain.topLevelDecls(); - for (var i = 0, n = topLevelDecls.length; i < n; i++) { - var topLevelDecl = topLevelDecls[i]; - if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { - continue; - } - - if (!topLevelDecl.isExternalModule()) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.kind & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - 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 */ || lhs.kind === 64 /* Enum */)) { - return null; - } - - var lhsType = lhs.type; - if (!lhsType) { - return null; - } - - this.resolveDeclaredSymbol(lhsType, context); - - if (lhsType.isContainer() && lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - var memberVisibilty = 2 /* externallyVisible */; - var containerSymbol = lhsType; - if (containerSymbol.kind === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = enclosingDecl.getParentPath(); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { - memberVisibilty = 1 /* internallyVisible */; - break; - } - } - } - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - var members = []; - - if (lhsType.isContainer()) { - var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); - if (exportedAssignedContainerSymbol) { - lhsType = exportedAssignedContainerSymbol; - } - } - - lhsType = this.getApparentType(lhsType); - - 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); - } - - 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 */)); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { - var originalIdText = idText; - var symbol = null; - - if (TypeScript.isRelative(originalIdText)) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - symbol = this.semanticInfoChain.findExternalModule(path + idText); - } else { - idText = originalIdText; - - symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); - - if (!symbol) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - symbol = this.semanticInfoChain.findExternalModule(path + idText); - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { - if (!symbol || symbol.isResolved || symbol.isTypeReference()) { - return symbol; - } - - if (!context) { - context = new TypeScript.PullTypeResolutionContext(this); - } - - return this.resolveDeclaredSymbolWorker(symbol, context); - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { - if (!symbol || symbol.isResolved) { - return symbol; - } - - if (symbol.inResolution) { - if (!symbol.type && !symbol.isType()) { - symbol.type = this.semanticInfoChain.anyTypeSymbol; - } - - return symbol; - } - - var decls = symbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - var ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { - return symbol; - } - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); - var resolvedSymbol; - 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 */); - resolvedSymbol = this.resolveAST(ast, false, context); - } - - if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { - symbol.type = resolvedSymbol.type; - symbol.setResolved(); - } - } - - 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(); - this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { - return _this.resolveOtherDecl(otherDecl, context); - }); - }; - - PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { - var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); - var moduleSymbol = enclosingDecl.getSymbol(); - this.ensureAllSymbolsAreBound(moduleSymbol); - - this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); - this.resolveAST(sourceUnit.moduleElements, false, context); - - if (this.canTypeCheckAST(sourceUnit, context)) { - this.typeCheckSourceUnit(sourceUnit, context); - } - - return moduleSymbol; - }; - - 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) { - var containerDecl = this.semanticInfoChain.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - containerSymbol.setResolved(); - - this.resolveOtherDeclarations(ast, context); - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckEnumDeclaration(ast, context); - } - - return containerSymbol; - }; - - 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); - - this.typeCheckCallBacks.push(function (context) { - return _this.checkInitializersInEnumDeclarations(containerDecl, context); - }); - - if (!TypeScript.ASTHelpers.enumIsElided(ast)) { - this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { - 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; - - if (ast.stringLiteral) { - result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckModuleDeclaration(ast, context); - } - - return result; - }; - - PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { - if (containerSymbol) { - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - }; - - PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - this.ensureAllSymbolsAreBound(containerSymbol); - - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, context); - } - - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); - if (isLastName) { - this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); - } else if (sourceUnitAST) { - this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); - } - - containerSymbol.setResolved(); - - if (moduleDeclNameAST) { - this.resolveOtherDeclarations(moduleDeclNameAST, context); - } - - return containerSymbol; - }; - - 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 */) { - this.resolveExportAssignmentStatement(moduleElement, context); - return; - } - } - }; - - PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - var containerSymbol = containerDecl.getSymbol(); - - return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); - }; - - PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { - if (ast.stringLiteral) { - this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - }; - - PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { - var _this = this; - this.setTypeChecked(ast, context); - - if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { - this.resolveAST(ast.moduleElements, false, context); - } - - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - this.validateVariableDeclarationGroups(containerDecl, context); - - if (ast.stringLiteral) { - if (TypeScript.isRelative(ast.stringLiteral.valueText())) { - this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); - } - } - - 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) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() === 11 /* IdentifierName */) { - return true; - } else if (term.kind() === 121 /* QualifiedName */) { - var binex = term; - - if (binex.right.kind() === 11 /* IdentifierName */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { - if (!type.isGeneric()) { - return type; - } - - var typeParameters = type.getTypeArgumentsOrTypeParameters(); - - var typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); - } - - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; - - if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - var wasResolving = typeDeclSymbol.inResolution; - typeDeclSymbol.startResolving(); - - var typeRefDecls = typeDeclSymbol.getDeclarations(); - - for (var i = 0; i < typeRefDecls.length; i++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); - if (extendsClause) { - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - - if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - } - } - } - - 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()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); - var implementedType = this.resolveTypeReference(implementedTypeAST, context); - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - - if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addImplementedType(implementedType); - } - } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - - if (wasInBaseTypeResolution) { - typeDeclSymbol.inResolution = false; - - this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - _this.resolveClassDeclaration(classOrInterface, context); - } else { - _this.resolveInterfaceDeclaration(classOrInterface, context); - } - }); - - return typeDeclSymbol; - } - - this.setSymbolForAST(name, typeDeclSymbol, context); - this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - 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); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.type; - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - var parentConstructor = parentType ? parentType.getConstructorMethod() : null; - - if (parentConstructor) { - this.resolveDeclaredSymbol(parentConstructor, context); - var parentConstructorType = parentConstructor.type; - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - - if (!parentConstructSignatures.length) { - parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - parentConstructSignature.returnType = parentType; - parentConstructSignature.addTypeParametersFromReturnType(); - parentConstructorType.appendConstructSignature(parentConstructSignature); - parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - parentConstructSignatures = [parentConstructSignature]; - } - - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.parameters; - - 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); - } - - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - constructorSignature.addTypeParametersFromReturnType(); - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } - - if (!classDeclSymbol.isResolved) { - return classDeclSymbol; - } - - if (parentType) { - var parentConstructorSymbol = parentType.getConstructorMethod(); - - if (parentConstructorSymbol) { - var parentConstructorTypeSymbol = parentConstructorSymbol.type; - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - } - - this.resolveOtherDeclarations(classDeclAST, context); - } - - if (this.canTypeCheckAST(classDeclAST, context)) { - this.typeCheckClassDeclaration(classDeclAST, context); - } - - return classDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { - var _this = this; - 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); - }); - } - } - }; - - PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { - this.setTypeChecked(classDeclAST, context); - - var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - - this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); - this.resolveAST(classDeclAST.classElements, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); - this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); - - if (!classDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); - } - - this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); - }; - - PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { - this.checkThisCaptureVariableCollides(classDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { - var callSignatures = typeSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); - - if (interfaceDeclSymbol.isResolved) { - this.resolveOtherDeclarations(interfaceDeclAST, context); - - if (this.canTypeCheckAST(interfaceDeclAST, context)) { - this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); - } - } - - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { - this.setTypeChecked(interfaceDeclAST, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); - this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); - - 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) { - if (symbol) { - if (symbol.kind & kind) { - return symbol; - } - - if (symbol.isAlias()) { - this.resolveDeclaredSymbol(symbol, context); - - var alias = symbol; - if (kind & 164 /* SomeContainer */) { - return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728795 /* SomeType */) { - return alias.getExportAssignedTypeSymbol(); - } else if (kind & 68147712 /* SomeValue */) { - return alias.getExportAssignedValueSymbol(); - } - } - } - return null; - }; - - PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); - - return { - symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), - aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null - }; - }; - - PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { - var rhsName = identifier.valueText(); - if (rhsName.length === 0) { - return null; - } - - var moduleTypeSymbol = moduleSymbol.type; - var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); - var containerSymbol = memberSymbol.symbol; - var valueSymbol = null; - var typeSymbol = null; - var aliasSymbol = null; - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - aliasSymbol = memberSymbol.aliasSymbol; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - aliasSymbol = containerSymbol; - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return null; - } - - if (!valueSymbol) { - if (moduleTypeSymbol.getInstanceSymbol()) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); - valueSymbol = memberSymbol.symbol; - if (valueSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - } - - if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); - typeSymbol = memberSymbol.symbol; - if (typeSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); - return null; - } - - if (!typeSymbol && containerSymbol) { - typeSymbol = containerSymbol; - } - - return { - valueSymbol: valueSymbol, - typeSymbol: typeSymbol, - containerSymbol: containerSymbol, - aliasSymbol: aliasSymbol - }; - }; - - 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"); - - var moduleSymbol = null; - var moduleName; - - if (moduleNameExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = moduleNameExpr; - var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleContainer) { - moduleName = dottedNameAST.right.valueText(); - - moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; - if (!moduleSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); - } - } - } else { - var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); - var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); - - if (text.length > 0) { - var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); - moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); - if (moduleSymbol) { - 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]); - } - } - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - - var moduleReference = importStatementAST.moduleReference; - - var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; - - 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); - if (moduleSymbol) { - aliasedType = moduleSymbol.type; - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); - if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { - var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); - var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); - var instanceSymbol = aliasedType.getInstanceSymbol(); - - 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 { - importDeclSymbol.setAssignedValueSymbol(valueSymbol); - } - } - } else { - aliasedType = this.getNewErrorTypeSymbol(); - } - } else if (aliasExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = aliasExpr; - var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleSymbol) { - var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); - if (identifierResolution) { - importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); - importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); - importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); - return null; - } - } - } - - if (!aliasedType) { - importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); - } - - return aliasedType; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasedType = null; - - if (importDeclSymbol.isResolved) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - var declPath = enclosingDecl.getParentPath(); - - aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); - - if (!aliasedType) { - var path = importStatementAST.moduleReference.stringLiteral.text(); - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); - aliasedType = this.getNewErrorTypeSymbol(); - } - } else { - aliasedType = this.resolveInternalModuleReference(importStatementAST, context); - } - - if (aliasedType) { - if (!aliasedType.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); - if (!aliasedType.isError()) { - aliasedType = this.getNewErrorTypeSymbol(); - } - } - - if (aliasedType.isContainer()) { - importDeclSymbol.setAssignedContainerSymbol(aliasedType); - } - importDeclSymbol.setAssignedTypeSymbol(aliasedType); - - this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); - } - - importDeclSymbol.setResolved(); - - this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); - 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); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { - var _this = this; - this.setTypeChecked(importStatementAST, context); - - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (this.compilationSettings.noResolve()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); - } - - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - if (enclosingDecl.kind === 32 /* DynamicModule */) { - 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)); - } - } - } - } - - var checkPrivacy; - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind === 32 /* DynamicModule */) { - checkPrivacy = true; - } - } else { - checkPrivacy = true; - } - - if (checkPrivacy) { - var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); - - this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { - var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - - 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; - - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - - if (valueSymbol) { - this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { - var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - } - - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); - }; - - PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - 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); - } - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { - var id = exportAssignmentAST.identifier.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && parentSymbol.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); - return this.semanticInfoChain.anyTypeSymbol; - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - - var aliasSymbol = containerSymbol; - var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - } - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (valueSymbol) { - parentSymbol.setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - parentSymbol.setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - parentSymbol.setExportAssignedContainerSymbol(containerSymbol); - } - - this.resolveDeclaredSymbol(valueSymbol, context); - this.resolveDeclaredSymbol(typeSymbol, context); - this.resolveDeclaredSymbol(containerSymbol, context); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - var funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); - } - } - - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.setTypeChecked(funcDeclAST, context); - this.typeCheckFunctionOverloads(funcDeclAST, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - 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) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); - } else { - 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 (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(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - var contextualType = contextParam && contextParam.type; - var isImplicitAny = false; - - if (typeExpr) { - var typeRef = this.resolveTypeReference(typeExpr, context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); - typeRef = this.getNewErrorTypeSymbol(); - } - - contextualType = typeRef || contextualType; - } - if (contextualType) { - if (context.isInferentiallyTyping()) { - contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); - } - context.setTypeInContext(paramSymbol, contextualType); - } 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.propagateContextualType(contextualType); - } - - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - } - - if (!initExprSymbol || !initExprSymbol.type) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); - - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); - } - } else { - var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); - if (!contextualType) { - context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); - isImplicitAny = initTypeSymbol !== paramSymbol.type; - } else { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); - } - } - } - } - } - - if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - isImplicitAny = true; - } - - if (isImplicitAny && this.compilationSettings.noImplicitAny()) { - var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); - if (functionExpressionName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); - } - } - - if (canTypeCheckAST) { - this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { - var compilerReservedName = getCompilerReservedName(name); - switch (compilerReservedName) { - case 1 /* _this */: - this.postTypeCheckWorkitems.push(astWithName); - return; - - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; - - case 3 /* arguments */: - this.checkArgumentsCollides(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; - } - }; - - PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { - var enclosingAST = this.getASTForDecl(someFunctionDecl); - var nodeType = enclosingAST.kind(); - - 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); - } 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 */) { - var constructorDeclaration = enclosingAST; - 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 */) { - var functionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); - } - - return false; - }; - - PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); - } - } - } - }; - - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { - if (!isDeclaration || ast.kind() === 242 /* Parameter */) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - 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)); - } - } - } - } - }; - - PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { - var decl = this.semanticInfoChain.getDeclForAST(ast); - - if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - var nameText = name.valueText(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); - } - } - }; - - PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { - var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); - TypeScript.Debug.assert(interfaceDecl); - - var interfaceSymbol = interfaceDecl.getSymbol(); - TypeScript.Debug.assert(interfaceSymbol); - - if (objectType.typeMembers) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = objectType.typeMembers; - - for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { - memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); - memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); - - memberType = memberSymbol.type; - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - if (this.canTypeCheckAST(objectType, context)) { - this.typeCheckObjectTypeTypeReference(objectType, context); - } - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { - this.setTypeChecked(objectType, context); - var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); - var objectTypeSymbol = objectTypeDecl.getSymbol(); - - this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); - this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); - }; - - PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { - return this.resolveTypeReference(typeAnnotation.type, context); - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { - if (typeRef === null) { - return null; - } - - TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); - - var aliasType = null; - var type = this.computeTypeReferenceSymbol(typeRef, context); - - if (type.kind === 4 /* Container */) { - var container = type; - var instanceSymbol = container.getInstanceSymbol(); - - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { - type = instanceSymbol.type.getAssociatedContainerType(); - } - } - - if (type && type.isAlias()) { - aliasType = type; - type = aliasType.getExportAssignedTypeSymbol(); - } - - if (type && !type.isGeneric()) { - if (aliasType) { - this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); - } - } - - if (type && !type.isError()) { - 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 { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); - } - } - } - - if (this.canTypeCheckAST(typeRef, context)) { - this.setTypeChecked(typeRef, context); - } - - 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 */: - return this.semanticInfoChain.anyTypeSymbol; - case 61 /* BooleanKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - case 67 /* NumberKeyword */: - return this.semanticInfoChain.numberTypeSymbol; - case 69 /* StringKeyword */: - return this.semanticInfoChain.stringTypeSymbol; - case 41 /* VoidKeyword */: - return this.semanticInfoChain.voidTypeSymbol; - } - - var typeDeclSymbol = null; - - if (term.kind() === 11 /* IdentifierName */) { - typeDeclSymbol = this.resolveTypeNameExpression(term, context); - } else if (term.kind() === 123 /* FunctionType */) { - var functionType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); - } else if (term.kind() === 125 /* ConstructorType */) { - var constructorType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); - } else if (term.kind() === 122 /* ObjectType */) { - typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); - } else if (term.kind() === 126 /* GenericType */) { - typeDeclSymbol = this.resolveGenericTypeReference(term, context); - } else if (term.kind() === 121 /* QualifiedName */) { - typeDeclSymbol = this.resolveQualifiedName(term, context); - } else if (term.kind() === 14 /* StringLiteral */) { - 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, enclosingDecl.semanticInfoChain); - typeDeclSymbol.addDeclaration(decl); - } else if (term.kind() === 127 /* TypeQuery */) { - var typeQuery = term; - - var typeQueryTerm = typeQuery.name; - - var valueSymbol = this.resolveAST(typeQueryTerm, false, context); - - if (valueSymbol && valueSymbol.isAlias()) { - if (valueSymbol.assignedValue()) { - valueSymbol = valueSymbol.assignedValue(); - } else { - var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); - valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; - } - } - - if (valueSymbol) { - typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); - } else { - typeDeclSymbol = this.getNewErrorTypeSymbol(); - } - } else if (term.kind() === 124 /* ArrayType */) { - var arrayType = term; - var underlying = this.resolveTypeReference(arrayType.type, context); - typeDeclSymbol = this.getArrayType(underlying); - } else { - throw TypeScript.Errors.invalidOperation("unknown type"); - } - - if (!typeDeclSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); - return this.getNewErrorTypeSymbol(); - } - - if (typeDeclSymbol.isError()) { - return typeDeclSymbol; - } - - if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); - typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); - } - - return typeDeclSymbol; - }; - - PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { - 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveParameterList = function (list, context) { - return this.resolveSeparatedList(list.parameters, context); - }; - - PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { - var enumDeclaration = enumElement.parent.parent; - var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); - var symbol = decl.getSymbol(); - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { - if (this.canTypeCheckAST(clause, context)) { - this.setTypeChecked(clause, context); - } - - return this.resolveAST(clause.value, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - - if (enclosingDecl && decl.kind === 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved) { - var declType = declSymbol.type; - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved) { - valSymbol.type = declType; - valSymbol.setResolved(); - } - } - } else { - if (declSymbol.inResolution) { - declSymbol.type = this.semanticInfoChain.anyTypeSymbol; - declSymbol.setResolved(); - return declSymbol; - } - - if (!declSymbol.type || !declSymbol.type.isError()) { - declSymbol.startResolving(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - if (!hasTypeExpr) { - this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - } - - if (!(hasTypeExpr || init)) { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { - defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.type = defaultType; - } - } - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - } - } - - if (this.canTypeCheckAST(varDeclOrParameter, context)) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (varDeclOrParameter.kind() === 243 /* EnumElement */) { - var result = this.getEnumTypeSymbol(varDeclOrParameter, context); - declSymbol.type = result; - return result; - } - - if (!typeExpr) { - return null; - } - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var typeExprSymbol = this.resolveTypeReference(typeExpr, context); - - if (!typeExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - declSymbol.type = this.getNewErrorTypeSymbol(); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, typeExprSymbol); - } - } else { - if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { - decl.setFlag(16777216 /* IsAnnotatedWithAny */); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - typeExprSymbol = typeExprSymbol.type; - - if (typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { - var instanceSymbol = typeExprSymbol.getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(); - } else { - typeExprSymbol = instanceSymbol.type; - } - } - } - } 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(); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.type = typeExprSymbol; - } - - if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { - typeExprSymbol.setFunctionSymbol(declSymbol); - } - } - - return typeExprSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { - if (!init) { - return null; - } - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - if (typeExprSymbol) { - context.pushNewContextualType(typeExprSymbol); - } - - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); - - if (typeExprSymbol) { - context.popAnyContextualType(); - } - - if (!initExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - } else { - var initTypeSymbol = initExprSymbol.type; - - if (!hasTypeExpr) { - var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); - context.setTypeInContext(declSymbol, widenedInitTypeSymbol); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); - } - - if (this.compilationSettings.noImplicitAny()) { - 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 initTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var _this = this; - this.setTypeChecked(varDeclOrParameter, context); - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - - if (hasTypeExpr || init) { - if (typeExprSymbol && typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = typeExprSymbol.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol; - } - } - } - - initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); - } - } - } - } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { - var wrapperDecl = this.getEnclosingDecl(decl); - 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])); - } else if (wrapperDecl.kind === 65536 /* Method */) { - var parentDecl = wrapperDecl.getParentDecl(); - - if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); - } 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 (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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } - } - } - - 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_only_allowed_in_implementation)); - } - } - 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 */)) { - this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); - } - }; - - PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { - return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; - }; - - PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { - var enclosingDecl = this.getEnclosingDeclForAST(superAST); - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); - - if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { - 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; - if (!block) { - return; - } - } - } - - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - if (parents.length) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); - } - } - }; - - PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { - if (isDeclaration) { - var decl = this.semanticInfoChain.getDeclForAST(_thisAST); - if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - return; - } - } - - var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - var declPath = enclosingDecl.getParentPath(); - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - continue; - } - - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); - } - break; - } - } - }; - - PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { - this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - 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) { - return; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - typeParameterSymbol.setResolved(); - }; - - PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { - this.setTypeChecked(typeParameterAST, 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) { - if (this.canTypeCheckAST(constraint, context)) { - this.setTypeChecked(constraint, context); - } - - return this.resolveTypeReference(constraint.type, context); - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatementsExpressions = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, walker) { - var go = true; - - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 215 /* ObjectLiteralExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); - go = false; - break; - - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, walker) { - switch (ast.kind()) { - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - if (block) { - TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - } else { - returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - } - - if (!returnStatementsExpressions.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var returnExpressionSymbols = []; - var returnExpressions = []; - - for (var i = 0; i < returnStatementsExpressions.length; i++) { - var returnExpression = returnStatementsExpressions[i].expression; - if (returnExpression) { - var returnType = this.resolveAST(returnExpression, useContextualType, context).type; - - if (returnType.isError()) { - signature.returnType = returnType; - return; - } else { - if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { - this.setSymbolForAST(returnExpression.parent, returnType, context); - } - } - - returnExpressionSymbols.push(returnType); - returnExpressions.push(returnExpression); - } - } - - if (!returnExpressionSymbols.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].type; - } - }; - - var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); - var returnType = bestCommonReturnType; - var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - - if (returnType) { - var previousReturnType = returnType; - var newReturnType = returnType.widenedType(this, returnExpression, context); - signature.returnType = newReturnType; - - if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); - } - - if (this.compilationSettings.noImplicitAny()) { - if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { - var functionName = enclosingDecl.name; - if (functionName === "") { - functionName = enclosingDecl.getFunctionExpressionName(); - } - - if (functionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } - - if (!functionSymbol.type && functionSymbol.isAccessor()) { - functionSymbol.type = signature.returnType; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { - var _this = this; - if (constructorDecl.block) { - var foundSuperCall = false; - var pre = function (ast, walker) { - if (_this.isSuperInvocationExpression(ast)) { - foundSuperCall = true; - walker.options.stopWalking = true; - } - }; - - TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); - return foundSuperCall; - } - - return false; - }; - - 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); - }; - - PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { - this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(parameters, false, context); - - this.resolveAST(block, false, context); - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); - - if (funcDecl.kind === 16384 /* Function */) { - this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); - } - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - this.resolveAST(funcDeclAST.parameter, false, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); - var stringIndexSignature = allIndexSignatures.stringSignature; - var numberIndexSignature = allIndexSignatures.numericSignature; - var isNumericIndexer = numberIndexSignature === signature; - - if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { - var comparisonInfo = new TypeComparisonInfo(); - - 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); - } - } - } - - var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); - for (var i = 0; i < allMembers.length; i++) { - var member = allMembers[i]; - var name = member.name; - if (name || (member.kind === 4096 /* Property */ && name === "")) { - if (!allMembers[i].isResolved) { - _this.resolveDeclaredSymbol(allMembers[i], context); - } - - if (parentSymbol !== allMembers[i].getContainer()) { - var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); - var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; - var onlyStringIndexerIsPresent = !numberIndexSignature; - - if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { - var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { - _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); - } - } - } - } - } - }); - }; - - PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { - this.checkThisCaptureVariableCollides(funcDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { - var returnTypeSymbol = null; - - if (returnTypeAnnotation) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - } else { - var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } - - return returnTypeSymbol; - }; - - 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - return funcSymbol; - } - - if (!signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - 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(); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveIndexSignature(ast.indexSignature, context); - }; - - PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - return funcSymbol; - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameter) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - this.resolveParameter(funcDeclAST.parameter, context); - context.inTypeCheck = prevInTypeCheck; - } - - if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - return funcSymbol; - } - - if (isConstructor && !signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (returnTypeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { - if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { - 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; - if (funcDeclASTName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } - } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { - if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); - } - - return null; - }; - - 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.ASTHelpers.getType(parameter), context); - } - - return null; - }; - - PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - - if (accessorSymbol.inResolution) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - accessorSymbol.setResolved(); - - return accessorSymbol; - } - - if (accessorSymbol.isResolved) { - if (!accessorSymbol.type) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else { - var getterSymbol = accessorSymbol.getGetter(); - var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; - var hasGetter = getterSymbol !== null; - - var setterSymbol = accessorSymbol.getSetter(); - var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; - var hasSetter = setterSymbol !== null; - - var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); - var getterHasTypeAnnotation = getterAnnotatedType !== null; - - var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); - var setterHasTypeAnnotation = setterAnnotatedType !== null; - - accessorSymbol.startResolving(); - - if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); - } - - if (hasSetter) { - setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); - } - - if (hasGetter && hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - var getterSig = getterSymbol.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { - getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; - getterSig.returnType = setterSuppliedTypeSymbol; - } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { - setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; - - if (setterHasParameters) { - setterParameters[0].type = getterSuppliedTypeSymbol; - } - } - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - accessorSymbol.type = this.getNewErrorTypeSymbol(); - } else { - accessorSymbol.type = getterSuppliedTypeSymbol; - } - } else if (hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - - accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; - } else { - var getterSig = getterSymbol.type.getCallSignatures()[0]; - accessorSymbol.type = getterSig.returnType; - } - - accessorSymbol.setResolved(); - } - - if (this.canTypeCheckAST(funcDeclAst, context)) { - this.typeCheckAccessorDeclaration(funcDeclAst, context); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { - this.setTypeChecked(funcDeclAst, context); - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - var getterSymbol = accessorSymbol.getGetter(); - var setterSymbol = accessorSymbol.getSetter(); - - var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; - if (isGetter) { - var getterFunctionDeclarationAst = funcDeclAst; - context.pushNewContextualType(getterSymbol.type); - this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popAnyContextualType(); - } else { - var setterFunctionDeclarationAst = funcDeclAst; - this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); - } - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.type; - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return getterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - signature.setResolved(); - - return getterSymbol; - } - - signature.startResolving(); - - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - if (!setterAnnotatedType) { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } else { - signature.returnType = setterAnnotatedType; - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return getterSymbol; - }; - - PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - if (getter && setter) { - var getterAST = getter.getDeclarations()[0].ast(); - var setterAST = setter.getDeclarations()[0].ast(); - - if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { - var setterSig = setter.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - - var getter = accessorSymbol.getGetter(); - var getterSig = getter.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterParameters[0].type; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); - } - } - } - }; - - PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - var funcNameAST = funcDeclAST.propertyName; - - if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); - } - - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); - var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - 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.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; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.type; - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return setterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - signature.setResolved(); - return setterSymbol; - } - - signature.startResolving(); - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - } - - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - - if (!hadError) { - signature.setResolved(); - } - } - - return setterSymbol; - }; - - PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - - var getter = accessorSymbol.getGetter(); - - var funcNameAST = funcDeclAST.propertyName; - - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); - var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - if (getterIsPrivate !== setterIsPrivate) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); - } - - this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); - } else { - if (this.compilationSettings.noImplicitAny()) { - var setterFunctionDeclarationAst = funcDeclAST; - 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); - }; - - PullTypeResolver.prototype.resolveList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.childCount(); i < n; i++) { - this.resolveAST(list.childAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.resolveAST(list.nonSeparatorAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLogicalOperation(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { - this.setTypeChecked(binex, context); - - var leftType = this.resolveAST(binex.left, false, context).type; - var rightType = this.resolveAST(binex.right, false, context).type; - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(binex); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ - TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), - leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); - } - }; - - PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.operand, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckUnaryArithmeticOperation(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckPostfixUnaryExpression(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { - return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); - }; - - PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { - return; - } - - TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { - if (this.canTypeCheckAST(binaryExpression, context)) { - this.typeCheckBinaryArithmeticExpression(binaryExpression, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); - - var lhsType = lhsSymbol.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } - - if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } - - var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); - var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); - - if (!rhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!lhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (lhsIsFit && rhsIsFit) { - switch (binaryExpression.kind()) { - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - if (!this.isReference(binaryExpression.left, lhsSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); - } - } - }; - - PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInstanceOfExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); - var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - 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_of_a_type_assignable_to_the_Function_interface_type)); - } - }; - - PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { - if (this.canTypeCheckAST(commaExpression, context)) { - this.setTypeChecked(commaExpression, context); - - this.resolveAST(commaExpression.left, false, context); - } - - return this.resolveAST(commaExpression.right, false, context).type; - }; - - PullTypeResolver.prototype.resolveInExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; - - var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); - - if (!isValidLHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); - } - - if (!isValidRHS) { - 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)); - } - }; - - PullTypeResolver.prototype.resolveForStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.variableDeclaration, false, context); - this.resolveAST(ast.initializer, false, context); - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.incrementor, false, context); - this.resolveAST(ast.statement, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { - if (this.canTypeCheckAST(forInStatement, context)) { - this.typeCheckForInStatement(forInStatement, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { - this.setTypeChecked(forInStatement, context); - - if (forInStatement.variableDeclaration) { - var declaration = forInStatement.variableDeclaration; - - 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); - - 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 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)); - } - - this.resolveAST(forInStatement.statement, false, context); - }; - - PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWhileStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckDoStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckIfStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - this.resolveAST(ast.elseClause, false, context); - }; - - PullTypeResolver.prototype.resolveElseClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckElseClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveBlock = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.statements, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declaration, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declarators, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWithStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var withStatement = ast; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); - }; - - PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckTryStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var tryStatement = ast; - - this.resolveAST(tryStatement.block, false, context); - this.resolveAST(tryStatement.catchClause, false, context); - this.resolveAST(tryStatement.finallyClause, false, context); - }; - - PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckCatchClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - - var catchDecl = this.semanticInfoChain.getDeclForAST(ast); - this.validateVariableDeclarationGroups(catchDecl, context); - }; - - PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckFinallyClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - }; - - PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - while (enclosingDecl) { - if (enclosingDecl.kind & 1032192 /* SomeFunction */) { - return enclosingDecl; - } - - enclosingDecl = enclosingDecl.getParentDecl(); - } - - return null; - }; - - PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var isContextuallyTyped = false; - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); - if (returnTypeAnnotationSymbol) { - isContextuallyTyped = true; - context.pushNewContextualType(returnTypeAnnotationSymbol); - } - } else { - var currentContextualType = context.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - isContextuallyTyped = true; - context.propagateContextualType(currentContextualTypeReturnTypeSymbol); - } - } - } - } - - var result = this.resolveAST(expression, isContextuallyTyped, context).type; - if (isContextuallyTyped) { - context.popAnyContextualType(); - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { - if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { - var classDecl = enclosingFunction.getParentDecl(); - if (classDecl) { - var classSymbol = classDecl.getSymbol(); - this.resolveDeclaredSymbol(classSymbol, context); - - var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); - if (!isAssignable) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); - } - } - } - - if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); - } - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { - var signatureSymbol = enclosingFunction.getSignatureSymbol(); - var sigReturnType = signatureSymbol.returnType; - - if (expressionType && sigReturnType) { - var comparisonInfo = new TypeComparisonInfo(); - var upperBound = null; - - this.resolveDeclaredSymbol(expressionType, context); - this.resolveDeclaredSymbol(sigReturnType, context); - - var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); - } - } - } - } - } - }; - - PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { - var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var returnType = this.getSymbolForAST(returnAST, context); - var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); - if (!returnType || canTypeCheckAST) { - var returnExpr = returnAST.expression; - - var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); - - if (!returnType) { - returnType = resolvedReturnType; - this.setSymbolForAST(returnAST, resolvedReturnType, context); - } - - if (returnExpr && canTypeCheckAST) { - this.setTypeChecked(returnExpr, context); - this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); - } - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSwitchStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var expressionType = this.resolveAST(ast.expression, false, context).type; - - for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { - var switchClause = ast.switchClauses.childAt(i); - if (switchClause.kind() === 233 /* CaseSwitchClause */) { - var caseSwitchClause = switchClause; - - var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; - this.resolveAST(caseSwitchClause.statements, false, context); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); - } - } - } else { - var defaultSwitchClause = switchClause; - this.resolveAST(defaultSwitchClause.statements, false, context); - } - } - }; - - PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLabeledStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var labelIdentifier = ast.identifier.valueText(); - - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - 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); - }; - - PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { - switch (statement.kind()) { - case 160 /* LabeledStatement */: - return this.labelIsOnContinuableConstruct(statement.statement); - - case 158 /* WhileStatement */: - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 161 /* DoStatement */: - return true; - - default: - return false; - } - }; - - PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckContinueStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.isIterationStatement = function (ast) { - switch (ast.kind()) { - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 158 /* WhileStatement */: - case 161 /* DoStatement */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { - switch (ast.kind()) { - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 129 /* FunctionDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 241 /* FunctionPropertyAssignment */: - case 137 /* ConstructorDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.inSwitchStatement = function (ast) { - while (ast) { - if (ast.kind() === 151 /* SwitchStatement */) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { - while (ast) { - if (this.isIterationStatement(ast)) { - return true; - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { - var result = []; - - ast = ast.parent; - while (ast) { - if (ast.kind() === 160 /* LabeledStatement */) { - var labeledStatement = ast; - if (breakable) { - result.push(labeledStatement); - } else { - if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement); - } - } - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - break; - } - - ast = ast.parent; - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - 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.any(continuableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var continuableLabels = this.getEnclosingLabels(ast, false, true); - - 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)); - } - } - } - }; - - PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckBreakStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - if (ast.identifier) { - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var breakableLabels = this.getEnclosingLabels(ast, true, true); - 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, 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)); - } - } - }; - - PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { - if (!ast) { - return; - } - - var symbol = this.getSymbolForAST(ast, context); - if (symbol && symbol.isResolved) { - this.typeCheckAST(ast, isContextuallyTyped, context); - return symbol; - } - - if (ast.isExpression() && !isTypesOnlyLocation(ast)) { - return this.resolveExpressionAST(ast, isContextuallyTyped, context); - } - - var nodeType = ast.kind(); - - switch (nodeType) { - case 124 /* ArrayType */: - case 126 /* GenericType */: - case 122 /* ObjectType */: - case 127 /* TypeQuery */: - case 125 /* ConstructorType */: - case 123 /* FunctionType */: - return this.resolveTypeReference(ast, context); - - case 1 /* List */: - return this.resolveList(ast, context); - - case 2 /* SeparatedList */: - return this.resolveSeparatedList(ast, context); - - case 120 /* SourceUnit */: - return this.resolveSourceUnit(ast, context); - - case 132 /* EnumDeclaration */: - return this.resolveEnumDeclaration(ast, context); - - case 130 /* ModuleDeclaration */: - return this.resolveModuleDeclaration(ast, context); - - case 128 /* InterfaceDeclaration */: - return this.resolveInterfaceDeclaration(ast, context); - - case 131 /* ClassDeclaration */: - return this.resolveClassDeclaration(ast, context); - - case 224 /* VariableDeclaration */: - return this.resolveVariableDeclarationList(ast, context); - - case 136 /* MemberVariableDeclaration */: - return this.resolveMemberVariableDeclaration(ast, context); - - case 225 /* VariableDeclarator */: - return this.resolveVariableDeclarator(ast, context); - - case 141 /* PropertySignature */: - return this.resolvePropertySignature(ast, context); - - case 227 /* ParameterList */: - return this.resolveParameterList(ast, context); - - case 242 /* Parameter */: - return this.resolveParameter(ast, context); - - case 243 /* EnumElement */: - return this.resolveEnumElement(ast, context); - - case 232 /* EqualsValueClause */: - return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); - - case 238 /* TypeParameter */: - return this.resolveTypeParameterDeclaration(ast, context); - - case 239 /* Constraint */: - return this.resolveConstraint(ast, context); - - case 133 /* ImportDeclaration */: - return this.resolveImportDeclaration(ast, context); - - case 240 /* SimplePropertyAssignment */: - return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); - - case 241 /* FunctionPropertyAssignment */: - return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); - - case 11 /* IdentifierName */: - TypeScript.Debug.assert(isTypesOnlyLocation(ast)); - return this.resolveTypeNameExpression(ast, context); - - case 121 /* QualifiedName */: - return this.resolveQualifiedName(ast, context); - - case 137 /* ConstructorDeclaration */: - return this.resolveConstructorDeclaration(ast, context); - - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return this.resolveAccessorDeclaration(ast, context); - - case 138 /* IndexMemberDeclaration */: - return this.resolveIndexMemberDeclaration(ast, context); - - case 144 /* IndexSignature */: - return this.resolveIndexSignature(ast, context); - - case 135 /* MemberFunctionDeclaration */: - return this.resolveMemberFunctionDeclaration(ast, context); - - case 142 /* CallSignature */: - return this.resolveCallSignature(ast, context); - - case 143 /* ConstructSignature */: - return this.resolveConstructSignature(ast, context); - - case 145 /* MethodSignature */: - return this.resolveMethodSignature(ast, context); - - 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); - - case 219 /* SimpleArrowFunctionExpression */: - return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 214 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - - case 35 /* ThisKeyword */: - return this.resolveThisExpression(ast, context); - - case 50 /* SuperKeyword */: - return this.resolveSuperExpression(ast, context); - - case 213 /* InvocationExpression */: - return this.resolveInvocationExpression(ast, context); - - case 216 /* ObjectCreationExpression */: - return this.resolveObjectCreationExpression(ast, context); - - case 220 /* CastExpression */: - return this.resolveCastExpression(ast, context); - - case 13 /* NumericLiteral */: - return this.semanticInfoChain.numberTypeSymbol; - - case 14 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 32 /* NullKeyword */: - return this.semanticInfoChain.nullTypeSymbol; - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 172 /* VoidExpression */: - return this.resolveVoidExpression(ast, context); - - case 174 /* AssignmentExpression */: - return this.resolveAssignmentExpression(ast, context); - - case 167 /* LogicalNotExpression */: - return this.resolveLogicalNotExpression(ast, context); - - case 193 /* NotEqualsWithTypeConversionExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 197 /* GreaterThanExpression */: - return this.resolveLogicalOperation(ast, context); - - case 208 /* AddExpression */: - case 175 /* AddAssignmentExpression */: - return this.resolveBinaryAdditionOperation(ast, context); - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.resolveUnaryArithmeticOperation(ast, context); - - case 210 /* PostIncrementExpression */: - case 211 /* PostDecrementExpression */: - return this.resolvePostfixUnaryExpression(ast, context); - - case 209 /* SubtractExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 189 /* BitwiseOrExpression */: - case 191 /* BitwiseAndExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - return this.resolveBinaryArithmeticExpression(ast, context); - - case 221 /* ElementAccessExpression */: - return this.resolveElementAccessExpression(ast, context); - - case 187 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); - - case 188 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, context); - - case 171 /* TypeOfExpression */: - return this.resolveTypeOfExpression(ast, context); - - case 170 /* DeleteExpression */: - return this.resolveDeleteExpression(ast, context); - - case 186 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, isContextuallyTyped, context); - - case 12 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 217 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, context); - - case 200 /* InstanceOfExpression */: - return this.resolveInstanceOfExpression(ast, context); - - case 173 /* CommaExpression */: - return this.resolveCommaExpression(ast, context); - - case 201 /* InExpression */: - return this.resolveInExpression(ast, context); - - case 223 /* OmittedExpression */: - return this.semanticInfoChain.undefinedTypeSymbol; - } - - TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); - }; - - PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { - if (!this.canTypeCheckAST(ast, context)) { - return; - } - - var nodeType = ast.kind(); - switch (nodeType) { - case 120 /* SourceUnit */: - this.typeCheckSourceUnit(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.typeCheckEnumDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.typeCheckModuleDeclaration(ast, context); - return; - - case 128 /* InterfaceDeclaration */: - this.typeCheckInterfaceDeclaration(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.typeCheckClassDeclaration(ast, context); - return; - - case 243 /* EnumElement */: - this.typeCheckEnumElement(ast, context); - return; - - case 136 /* MemberVariableDeclaration */: - this.typeCheckMemberVariableDeclaration(ast, context); - return; - - case 225 /* VariableDeclarator */: - this.typeCheckVariableDeclarator(ast, context); - return; - - case 141 /* PropertySignature */: - this.typeCheckPropertySignature(ast, context); - return; - - case 242 /* Parameter */: - this.typeCheckParameter(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.typeCheckImportDeclaration(ast, context); - return; - - case 215 /* ObjectLiteralExpression */: - this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 241 /* FunctionPropertyAssignment */: - this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); - return; - - case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - this.resolveTypeNameExpression(ast, context); - } else { - this.resolveNameExpression(ast, context); - } - return; - - case 212 /* MemberAccessExpression */: - this.resolveMemberAccessExpression(ast, context); - return; - - case 121 /* QualifiedName */: - this.resolveQualifiedName(ast, context); - return; - - case 222 /* FunctionExpression */: - 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); - break; - - case 142 /* CallSignature */: - this.typeCheckCallSignature(ast, context); - return; - - case 143 /* ConstructSignature */: - this.typeCheckConstructSignature(ast, context); - return; - - case 129 /* FunctionDeclaration */: { - var funcDecl = ast; - 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, isContextuallyTyped, context); - return; - - case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - return; - - case 214 /* ArrayLiteralExpression */: - this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 213 /* InvocationExpression */: - this.typeCheckInvocationExpression(ast, context); - return; - - case 216 /* ObjectCreationExpression */: - this.typeCheckObjectCreationExpression(ast, context); - return; - - case 150 /* ReturnStatement */: - this.resolveReturnStatement(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); - } - }; - - PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { - while (this.postTypeCheckWorkitems.length) { - var ast = this.postTypeCheckWorkitems.pop(); - this.postTypeCheck(ast, context); - } - }; - - PullTypeResolver.prototype.postTypeCheck = function (ast, context) { - var nodeType = ast.kind(); - - switch (nodeType) { - case 242 /* Parameter */: - case 225 /* VariableDeclarator */: - this.postTypeCheckVariableDeclaratorOrParameter(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.postTypeCheckClassDeclaration(ast, context); - return; - - case 129 /* FunctionDeclaration */: - this.postTypeCheckFunctionDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.postTypeCheckModuleDeclaration(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.postTypeCheckEnumDeclaration(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.postTypeCheckImportDeclaration(ast, context); - return; - - case 11 /* IdentifierName */: - this.postTypeCheckNameExpression(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); - } - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return this.cachedRegExpInterfaceType(); - } else { - return this.semanticInfoChain.anyTypeSymbol; - } - }; - - PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { - this.checkThisCaptureVariableCollides(nameAST, false, context); - }; - - PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { - this.setTypeChecked(nameAST, context); - this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { - var nameSymbol = this.getSymbolForAST(nameAST, context); - var foundCached = nameSymbol !== null; - - if (!foundCached || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.typeCheckNameExpression(nameAST, context); - } - nameSymbol = this.computeNameExpression(nameAST, context); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(nameAST, nameSymbol, context); - } - - return nameSymbol; - }; - - 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.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; - } - - var nameSymbol = null; - var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; - - if (!this.isInEnumDecl(enclosingDecl)) { - searchKind = searchKind & ~(67108864 /* EnumMember */); - } - - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); - } - - 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) { - 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]; - var nameParentDecl = nameDeclaration.getParentDecl(); - if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { - var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); - var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - - var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); - - if (currentParameterIndex >= 0) { - var matchingParameter; - if (parameterList) { - for (var i = 0; i <= currentParameterIndex; i++) { - var candidateParameter = parameterList.parameters.nonSeparatorAt(i); - if (candidateParameter && candidateParameter.identifier.valueText() === id) { - matchingParameter = candidateParameter; - break; - } - } - } - - 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); - } - } - } - - var aliasSymbol = null; - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); - - var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - if (aliasSymbol) { - this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); - if (parameterList) { - while (parameter && parameter.parent) { - if (parameter.parent.parent === parameterList) { - return parameterList.parameters.nonSeparatorIndexOf(parameter); - } - - parameter = parameter.parent; - } - } - - return -1; - }; - - PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { - var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol !== null; - - if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheckDottedNameAST) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); - } - - this.resolveDeclaredSymbol(symbol, context); - - if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(dottedNameAST, symbol, context); - this.setSymbolForAST(name, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { - var rhsName = name.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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)) { - lhsAlias.setIsUsedAsValue(); - } - lhsType = lhsAlias.getExportAssignedTypeSymbol(); - } - - if (lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (!lhsType) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); - return this.getNewErrorTypeSymbol(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType !== lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { - var instanceSymbol = lhsType.getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.type; - } - } - - var originalLhsTypeForErrorReporting = lhsType; - - lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); - - if (!nameSymbol) { - if (lhsType.kind === 32 /* DynamicModule */) { - var container = lhsType; - var associatedInstance = container.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.type; - - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); - } - } - - 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - } - - if (checkSuperPrivateAndStaticAccess) { - this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { - var typeNameSymbol = this.getSymbolForAST(nameAST, context); - - if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.setTypeChecked(nameAST, context); - } - typeNameSymbol = this.computeTypeNameExpression(nameAST, context); - this.setSymbolForAST(nameAST, typeNameSymbol, context); - } - - this.resolveDeclaredSymbol(typeNameSymbol, context); - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - var declPath = enclosingDecl.getParentPath(); - - var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } - - var typeNameSymbolAlias = null; - if (typeNameSymbol.isAlias()) { - typeNameSymbolAlias = typeNameSymbol; - this.resolveDeclaredSymbol(typeNameSymbol, context); - - var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); - - this.resolveDeclaredSymbol(aliasedType, context); - } - - if (typeNameSymbol.isTypeParameter()) { - if (this.isInStaticMemberContext(enclosingDecl)) { - var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - - if (parentDecl.kind === 8 /* Class */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); - return this.getNewErrorTypeSymbol(); - } - } - } - - if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { - typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); - } - - 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; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; - - if (genericTypeSymbol.isError()) { - return genericTypeSymbol; - } - - if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { - this.resolveDeclaredSymbol(genericTypeSymbol, context); - } - - 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()) { - for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - - if (typeArgs[i].isError()) { - typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - 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(); - } - - if (!genericTypeSymbol.isResolved) { - var typeDecls = genericTypeSymbol.getDeclarations(); - var childDecls = null; - - for (var i = 0; i < typeDecls.length; i++) { - childDecls = typeDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - - var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); - - var typeConstraint = null; - var upperBound = null; - - typeParameters = specializedSymbol.getTypeParameters(); - - var typeConstraintSubstitutionMap = []; - var typeArg = null; - - var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < typeParameters.length; i++) { - typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - for (var id in instantiatedSubstitutionMap) { - typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; - } - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] === typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); - } - - if (typeArg.isTypeParameter()) { - upperBound = typeArg.getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - 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)])); - } - } - } - - return specializedSymbol; - }; - - PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { - if (this.inTypeQuery(dottedNameAST)) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; - } - - var symbol = this.getSymbolForAST(dottedNameAST, context); - if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheck) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeQualifiedName(dottedNameAST, context); - this.setSymbolForAST(dottedNameAST, symbol, context); - } - - this.resolveDeclaredSymbol(symbol, context); - - 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) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); - var lhs = this.resolveAST(dottedNameAST.left, false, context); - - var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; - - if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { - if (lhs.isAlias()) { - lhs.setIsUsedAsValue(); - } - } - - if (!lhsType) { - return this.getNewErrorTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); - var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; - - 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.kind & 164 /* SomeContainer */) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().type; - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); - } - } - } - - if (!childTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - - return childTypeSymbol; - }; - - PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { - if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { - return false; - } - - if (returnTypeAnnotation) { - return false; - } - - if (parameters) { - for (var i = 0, n = parameters.length; i < n; i++) { - if (parameters.typeAt(i)) { - return false; - } - } - } - - var contextualFunctionTypeSymbol = context.getContextualType(); - - if (contextualFunctionTypeSymbol) { - this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); - var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; - if (!exactlyOneCallSignature) { - return false; - } - - var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; - return !callSignatureIsGeneric; - } - - return false; - }; - - PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { - var funcDeclSymbol = null; - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { - return funcDeclSymbol; - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - TypeScript.Debug.assert(funcDeclSymbol); - - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - funcDeclSymbol.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - var assigningFunctionSignature = null; - if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { - assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; - } - - this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.returnType; - - if (returnType) { - context.propagateContextualType(returnType); - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popAnyContextualType(); - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - var functionExpressionName = functionDecl.getFunctionExpressionName(); - - if (functionExpressionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); - } - } - - context.setTypeInContext(funcDeclSymbol, funcDeclType); - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); - } - - return funcDeclSymbol; - }; - - 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcDeclSymbol = functionDecl.getSymbol(); - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - var returnTypeSymbol = signature.returnType; - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - 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.popAnyContextualType(); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); - - this.validateVariableDeclarationGroups(functionDecl, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { - var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); - var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; - - if (this.canTypeCheckAST(thisExpression, context)) { - this.typeCheckThisExpression(thisExpression, context, enclosingDecl); - } - - return thisTypeSymbol; - }; - - PullTypeResolver.prototype.inTypeArgumentList = function (ast) { - var previous = null; - var current = ast; - - while (current) { - switch (current.kind()) { - case 126 /* GenericType */: - var genericType = current; - if (genericType.typeArgumentList === previous) { - return true; - } - break; - - case 226 /* ArgumentList */: - var argumentList = current; - return argumentList.typeArgumentList === previous; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { - while (ast) { - switch (ast.kind()) { - case 230 /* ExtendsHeritageClause */: - var heritageClause = ast; - - return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inTypeQuery = function (ast) { - while (ast) { - switch (ast.kind()) { - case 127 /* TypeQuery */: - return true; - case 129 /* FunctionDeclaration */: - case 213 /* InvocationExpression */: - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 213 /* InvocationExpression */: - var invocationExpression = current; - if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - break; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inConstructorParameterList = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 142 /* CallSignature */: - var callSignature = current; - if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { - return true; - } - - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - 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 */) { - return true; - } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { - this.checkForThisCaptureInArrowFunction(thisExpression); - - if (this.inConstructorParameterList(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); - return; - } - - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { - return; - } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - if (currentDecl.getParentDecl() === null) { - return; - } else { - 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)); - } - - return; - } else if (currentDecl.kind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); - } - - return; - } - } - }; - - PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var isStaticContext = false; - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declFlags & 16 /* Static */) { - isStaticContext = true; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - return null; - } else if (declKind === 16384 /* Function */) { - return null; - } else if (declKind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(ast)) { - return this.getNewErrorTypeSymbol(); - } else { - var classSymbol = decl.getSymbol(); - if (isStaticContext) { - var constructorSymbol = classSymbol.getConstructorMethod(); - return constructorSymbol.type; - } else { - return classSymbol; - } - } - } - } - } - - return null; - }; - - PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { - return true; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - var superType = this.semanticInfoChain.anyTypeSymbol; - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); - - if (classSymbol) { - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - superType = parents[0]; - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSuperExpression(ast, context, enclosingDecl); - } - - return superType; - }; - - PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { - this.setTypeChecked(ast, context); - - this.checkForThisCaptureInArrowFunction(ast); - - var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; - var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; - TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); - - if (isSuperPropertyAccess) { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 8 /* Class */) { - if (!this.enclosingClassIsDerived(currentDecl)) { - 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 if (this.inStaticMemberVariableDeclaration(ast)) { - break; - } - - 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; - } - - return; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); - } - }; - - PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { - return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { - if (this.canTypeCheckAST(expressionAST, context)) { - this.setTypeChecked(expressionAST, context); - } - symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); - this.setSymbolForAST(expressionAST, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { - var boundMemberSymbols = []; - var memberSymbol; - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var id = this.getPropertyAssignmentName(propertyAssignment); - var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); - - var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; - var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); - TypeScript.Debug.assert(decl); - - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - if (!isUsingExistingSymbol) { - memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - } else { - memberSymbol = decl.getSymbol(); - } - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - memberSymbol = decl.getSymbol(); - } else { - TypeScript.Debug.assert(isAccessor); - memberSymbol = decl.getSymbol(); - } - - if (!isUsingExistingSymbol && !isAccessor) { - var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); - if (existingMember) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); - } - - objectLiteralTypeSymbol.addMember(memberSymbol); - } - - boundMemberSymbols.push(memberSymbol); - } - - return boundMemberSymbols; - }; - - PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var acceptedContextualType = false; - var assigningSymbol = null; - - var id = this.getPropertyAssignmentName(propertyAssignment); - var memberSymbol = boundMemberSymbols[i]; - var contextualMemberType = null; - - if (objectLiteralContextualType) { - assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); - - if (!assigningSymbol) { - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - assigningSymbol = numericIndexerSignature; - } else if (stringIndexerSignature) { - assigningSymbol = stringIndexerSignature; - } - } - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - - contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.propagateContextualType(contextualMemberType); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = contextualMemberType; - } - } - } - - var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; - - if (memberSymbolType) { - if (memberSymbolType.isGeneric()) { - objectLiteralTypeSymbol.setHasGenericMember(); - } - - if (stringIndexerSignature) { - allMemberTypes.push(memberSymbolType); - } - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberSymbolType); - } - } - - if (acceptedContextualType) { - pullTypeContext.popAnyContextualType(); - } - - var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!memberSymbol.isResolved) { - if (isAccessor) { - this.setSymbolForAST(id, memberSymbolType, pullTypeContext); - } else { - pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); - memberSymbol.setResolved(); - - this.setSymbolForAST(id, memberSymbol, pullTypeContext); - } - } - } - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { - var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); - TypeScript.Debug.assert(objectLitDecl); - - var typeSymbol = this.getSymbolForAST(objectLitAST, context); - var isUsingExistingSymbol = !!typeSymbol; - - if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); - typeSymbol.addDeclaration(objectLitDecl); - this.setSymbolForAST(objectLitAST, typeSymbol, context); - objectLitDecl.setSymbol(typeSymbol); - } - - var propertyAssignments = objectLitAST.propertyAssignments; - var contextualType = null; - - if (isContextuallyTyped) { - contextualType = context.getContextualType(); - this.resolveDeclaredSymbol(contextualType, context); - } - - var stringIndexerSignature = null; - var numericIndexerSignature = null; - var allMemberTypes = null; - var allNumericMemberTypes = null; - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - - stringIndexerSignature = indexSignatures.stringSignature; - numericIndexerSignature = indexSignatures.numericSignature; - - var inInferentialTyping = context.isInferentiallyTyping(); - if (stringIndexerSignature) { - allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; - } - - if (numericIndexerSignature) { - allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; - } - } - - if (propertyAssignments) { - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); - - this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); - - if (!isUsingExistingSymbol) { - this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); - this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); - } - } - - typeSymbol.setResolved(); - return typeSymbol; - }; - - PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { - return propertyAssignment.propertyName; - } else { - TypeScript.Debug.assert(false); - } - }; - - PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { - if (contextualIndexSignature) { - var typeCollection = { - getLength: function () { - return indexerTypeCandidates.length; - }, - getTypeAtIndex: function (index) { - return indexerTypeCandidates[index]; - } - }; - var decl = objectLiteralSymbol.getDeclarations()[0]; - 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); - } - } - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { - var symbol = this.getSymbolForAST(arrayLit, context); - if (!symbol || this.canTypeCheckAST(arrayLit, context)) { - if (this.canTypeCheckAST(arrayLit, context)) { - this.setTypeChecked(arrayLit, context); - } - symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); - this.setSymbolForAST(arrayLit, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { - var elements = arrayLit.expressions; - var elementType = null; - var elementTypes = []; - var comparisonInfo = new TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, context); - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - if (indexSignatures.numericSignature) { - contextualElementType = indexSignatures.numericSignature.returnType; - } - } - } - - if (elements) { - if (contextualElementType) { - context.propagateContextualType(contextualElementType); - } - - for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { - elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); - } - - if (contextualElementType) { - context.popAnyContextualType(); - } - } - - if (elementTypes.length) { - elementType = elementTypes[0]; - } - var collection; - - if (contextualElementType && !context.isInferentiallyTyping()) { - if (!elementType) { - elementType = contextualElementType; - } - - collection = { - getLength: function () { - return elements.nonSeparatorCount() + 1; - }, - getTypeAtIndex: function (index) { - return index === 0 ? contextualElementType : elementTypes[index - 1]; - } - }; - } else { - collection = { - getLength: function () { - return elements.nonSeparatorCount(); - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - } - - elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; - - if (!elementType) { - elementType = this.semanticInfoChain.undefinedTypeSymbol; - } - - return this.getArrayType(elementType); - }; - - PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { - var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); - - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); - } - - return symbolAndDiagnostic.symbol; - }; - - PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { - this.setTypeChecked(callEx, context); - context.postDiagnostic(symbolAndDiagnostic.diagnostic); - }; - - PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; - - var targetTypeSymbol = targetSymbol.type; - - targetTypeSymbol = this.getApparentType(targetTypeSymbol); - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return { symbol: targetTypeSymbol }; - } - - var elementType = targetTypeSymbol.getElementType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return { symbol: elementType }; - } - - 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); - - if (member) { - this.resolveDeclaredSymbol(member, context); - - return { symbol: member.type }; - } - } - - var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); - - var stringSignature = signatures.stringSignature; - var numberSignature = signatures.numericSignature; - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; - } 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 { - symbol: this.getNewErrorTypeSymbol(), - diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) - }; - } - }; - - 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; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - if (!signature.isResolved) { - this.resolveDeclaredSymbol(signature, context); - } - - paramSymbols = signature.parameters; - - if (paramSymbols.length) { - paramType = paramSymbols[0].type; - - if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signature; - continue; - } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { - numberSignature = signature; - continue; - } - } - } - - return { - numericSignature: numberSignature, - stringSignature: stringSignature - }; - }; - - 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; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { - rhsType = this.semanticInfoChain.numberTypeSymbol; - } - - 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 { - lhsType = rhsType; - } - } else if (isRhsTypeNullOrUndefined) { - rhsType = lhsType; - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (exprType) { - if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { - if (!this.isReference(binaryExpression.left, lhsExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, exprType, lhsType, context); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); - } - } - - if (!exprType) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { - return this.findBestCommonType({ - getLength: function () { - return 2; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - } - } - }, context); - }; - - PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { - return this.findBestCommonType({ - getLength: function () { - return 3; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - case 2: - return type3; - } - } - }, context); - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - } - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; - var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; - - 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.pushNewContextualType(leftType); - var rightType = this.resolveAST(binex.right, true, context).type; - context.popAnyContextualType(); - - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - - this.resolveAST(binex.left, false, context); - } - - return this.resolveAST(binex.right, false, context).type; - }; - - PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped && !context.isInferentiallyTyping()) { - var contextualType = context.getContextualType(); - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); - } else { - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { - var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; - var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; - - var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); - - var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); - - if (this.canTypeCheckAST(trinex, context)) { - this.setTypeChecked(trinex, context); - this.resolveAST(trinex.condition, false, context); - - if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); - } - } - } - - if (!conditionalTypesAreValid) { - return this.getNewErrorTypeSymbol(); - } - - return expressionType; - }; - - PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { - return true; - } - } else { - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveAST(ast.expression, false, context); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - if (symbol !== this.semanticInfoChain.anyTypeSymbol) { - this.setSymbolForAST(callEx, symbol, context); - } - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckInvocationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - var targetSymbol = this.resolveAST(callEx.expression, false, context); - - if (callEx.argumentList.arguments) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - - var len = callEx.argumentList.arguments.nonSeparatorCount(); - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var targetTypeSymbol = targetSymbol.type; - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); - return this.getNewErrorTypeSymbol(); - } - } - - return this.semanticInfoChain.anyTypeSymbol; - } - - var isSuperCall = false; - - if (callEx.expression.kind() === 50 /* SuperKeyword */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = targetTypeSymbol.getConstructorMethod(); - this.resolveDeclaredSymbol(targetSymbol, context); - targetTypeSymbol = targetSymbol.type; - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); - this.resolveAST(callEx.argumentList.arguments, false, context); - - return this.getNewErrorTypeSymbol(); - } - } - - var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - - 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 explicitTypeArgs = null; - var couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - var triedToInferTypeArgs = false; - - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var beforeResolutionSignatures = signatures; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - couldNotAssignToConstraint = false; - - if (signatures[i].isGeneric() && typeParameters.length) { - if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { - explicitTypeArgs = signatures[i].returnType.getTypeArguments(); - } - - 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, 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; - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - - var errorCondition = null; - if (!signatures.length) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (!couldNotFindGenericOverload) { - 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); - } - return this.semanticInfoChain.anyTypeSymbol; - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); - } else if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!signatures.length) { - return errorCondition; - } - - signature = signatures[0]; - } - - 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 (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; - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - this.setSymbolForAST(callEx, symbol, context); - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckObjectCreationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - this.resolveAST(callEx.expression, false, context); - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (callEx.argumentList) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - var len = callEx.argumentList.arguments.nonSeparatorCount(); - - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { - if (!context.inProvisionalResolution()) { - additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); - } - context.postDiagnostic(diagnostic); - }; - - PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { - var _this = this; - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; - - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var explicitTypeArgs = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - return targetTypeSymbol; - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - - if (this.compilationSettings.noImplicitAny()) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); - } - } - - if (constructSignatures.length) { - if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var triedToInferTypeArgs; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric()) { - typeParameters = constructSignatures[i].getTypeParameters(); - - 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, explicitTypeArgs.length]); - continue; - } - } 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 { - inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { - return typeParameter.getDefaultConstraint(_this.semanticInfoChain); - }); - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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(constructSignatures[i], typeReplacementMap); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } else { - if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - - if (!constructSignatures.length) { - if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var errorCondition = null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!constructSignatures.length) { - return errorCondition; - } - - signature = constructSignatures[0]; - } - - returnType = signature.returnType; - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (explicitTypeArgs && explicitTypeArgs.length) { - returnType = this.createInstantiatedType(returnType, explicitTypeArgs); - } else { - returnType = this.instantiateTypeToAny(returnType, context); - } - } - - if (usedCallSignaturesInstead) { - 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(); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.returnType; - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList && callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - } else if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); - - return this.getNewErrorTypeSymbol(); - }; - - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { - var typeReplacementMap = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters = signatureAToInstantiate.getTypeParameters(); - var typeConstraint = null; - - var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); - inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); - - var functionTypeA = signatureAToInstantiate.functionType; - var functionTypeB = contextualSignatureB.functionType; - var enclosingTypeParameterMap; - - if (functionTypeA) { - enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - if (functionTypeB) { - enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); - - return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); - }; - - PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { - var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; - - if (this.canTypeCheckAST(assertionExpression, context)) { - this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); - } - - return typeAssertionType; - }; - - PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { - this.setTypeChecked(assertionExpression, context); - - context.pushNewContextualType(typeAssertionType); - var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popAnyContextualType(); - - this.resolveDeclaredSymbol(typeAssertionType, context); - this.resolveDeclaredSymbol(exprType, context); - - var comparisonInfo = new TypeComparisonInfo(); - - 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); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { - var leftExpr = this.resolveAST(binaryExpression.left, false, context); - var leftType = leftExpr.type; - - context.pushNewContextualType(leftType); - var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popAnyContextualType(); - - rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (!this.isReference(binaryExpression.left, leftExpr)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } else { - this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); - } - } - - return rightType; - }; - - PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { - var typeToReturn = type; - if (typeToReturn && typeToReturn.isAlias()) { - typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); - } - - if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { - var instanceTypeSymbol = typeToReturn.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); - typeToReturn = null; - } else { - typeToReturn = instanceTypeSymbol; - } - } - - return typeToReturn; - }; - - PullTypeResolver.prototype.widenType = function (type, ast, context) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (type.isArrayNamedTypeReference()) { - 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(); - - for (var i = 0; i < len; i++) { - var candidateType = collection.getTypeAtIndex(i); - if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { - return candidateType; - } - } - - return this.semanticInfoChain.emptyTypeSymbol; - }; - - PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { - for (var i = 0; i < collection.getLength(); i++) { - var otherType = collection.getTypeAtIndex(i); - if (candidateType === otherType) { - continue; - } - - if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - if (t1 && t2) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); - } - } - - return this.typesAreIdentical(t1, t2, context); - }; - - 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); - - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - return false; - } - - if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { - return false; - } - - if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - 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(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return false; - } - } - - if (t1.isPrimitive() !== t2.isPrimitive()) { - return 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) { - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); - - if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { - return false; - } - - return true; - }; - - 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; - } - - if (!sg1 || !sg2) { - return false; - } - - if (sg1.length !== sg2.length) { - return false; - } - - 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; - } - } - - return true; - }; - - 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; - } - - if (tp1 && tp2 && (tp1.length !== tp2.length)) { - return false; - } - - 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) { - var decls1 = symbol1.getDeclarations(); - var decls2 = symbol2.getDeclarations(); - - if (decls1.length && decls2.length) { - return decls1[0] === decls2[0]; - } - - return false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { - if (source.isFunctionType()) { - return true; - } - - return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); - }; - - 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.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) { - if (symbol && symbol.isTypeReference()) { - return symbol.getReferencedTypeSymbol(); - } - - return symbol; - }; - - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - if (source && target) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - } - } - - 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); - - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - var sourceApparentType = this.getApparentType(source); - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } - - if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - 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) { - return true; - } - - return false; - } else if (source === this.semanticInfoChain.voidTypeSymbol) { - if (target === this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return assignableTo; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { - return false; - } - - if (source.getIsSpecialized() && target.getIsSpecialized()) { - 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, true); - - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { - break; - } - } - - if (i === sourceTypeArguments.length) { - return true; - } else { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - } - } - } - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter()) { - if (!source.getConstraint()) { - return this.typesAreIdentical(target, source, context); - } else { - return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); - } - } else { - if (isComparingInstantiatedSignatures) { - target = target.getBaseConstraint(this.semanticInfoChain); - } else { - return this.typesAreIdentical(target, sourceApparentType, context); - } - } - } - - 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; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - - var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); - - this.resolveDeclaredSymbol(targetProp, context); - - var targetPropType = targetProp.type; - - 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = targetType.widenedType(this, null, context); - var widenedSourceType = sourceType.widenedType(this, null, context); - - if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - - 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var comparisonInfoTypeArgumentsCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); - } - 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_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_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, isRelatable); - return isRelatable; - }; - - 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)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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++) { - 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; - } - } - } - - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - 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 (comparisonInfo) { - var names = getNames(true); - var code; - if (targetPropIsPrivate) { - 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 { - 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; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (targetDecl !== sourceDecl) { - if (comparisonInfo) { - var names = getNames(true); - - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - 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; - } - } - - if (sourceProp.isOptional && !targetProp.isOptional) { - if (comparisonInfo) { - 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); - } - return false; - } - - this.resolveDeclaredSymbol(sourceProp, context); - - var sourcePropType = sourceProp.type; - var targetPropType = targetProp.type; - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - context.walkMemberTypes(targetProp.name); - var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); - context.postWalkMemberTypes(); - - if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - var names = getNames(false); - if (comparisonInfoPropertyTypeCheck && 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 { - 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 isSourcePropertyRelatableToTargetProperty; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); - var targetStringSig = targetIndexSigs.stringSignature; - var targetNumberSig = targetIndexSigs.numericSignature; - - if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); - var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); - var sourceStringSig = sourceIndexSigs.stringSignature; - var sourceNumberSig = sourceIndexSigs.numericSignature; - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - 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++) { - var mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - var nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { - continue; - } - - 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; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - - if (comparisonInfo && sigsCompared == 1) { - comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; - } - - return false; - } - - return true; - }; - - 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; - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; - var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; - - 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, [targetParameters.length])); - } - return false; - } - - if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { - return true; - } - - 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) { - context.walkReturnTypes(); - var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - context.postWalkReturnTypes(); - if (!returnTypesAreRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - - return false; - } - } - - 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 (!areParametersRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - } - - return areParametersRelatable; - }); - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { - var _this = this; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeComparisonInfo(); - var args = application.argumentList ? application.argumentList.arguments : null; - - var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { - if (hasOverloads && signature.isDefinition()) { - return false; - } - - var rootSignature = signature.getRootSymbol(); - if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { - return false; - } - - return _this.overloadHasCorrectArity(signature, args); - }); - - var firstAssignableButNotSupertypeSignature = null; - var firstAssignableWithProvisionalErrorsSignature = null; - - for (var i = 0; i < initialCandidates.length; i++) { - var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); - if (applicability === 3 /* Subtype */) { - return initialCandidates[i]; - } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { - firstAssignableButNotSupertypeSignature = initialCandidates[i]; - } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { - firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; - } - } - - if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { - return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; - } else { - var target = this.getCallTargetErrorSpanAST(application); - if (comparisonInfo.message) { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); - } else { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); - } - } - - return null; - }; - - PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { - return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; - }; - - PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { - if (args == null) { - return signature.nonOptionalParamCount === 0; - } - - var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); - if (numberOfArgs < signature.nonOptionalParamCount) { - return false; - } - if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { - if (args === null) { - return 3 /* Subtype */; - } - - var isInVarArg = false; - var parameters = signature.parameters; - var paramType = null; - - var overloadApplicability = 3 /* Subtype */; - - for (var i = 0; i < args.nonSeparatorCount(); i++) { - if (!isInVarArg) { - this.resolveDeclaredSymbol(parameters[i], context); - - if (parameters[i].isVarArg) { - paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); - isInVarArg = true; - } else { - paramType = parameters[i].type; - } - } - - var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); - - if (statusOfCurrentArgument === 0 /* NotAssignable */) { - return 0 /* NotAssignable */; - } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { - overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; - } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { - overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; - } - } - - return overloadApplicability; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType.isAny()) { - return 3 /* Subtype */; - } else if (paramType.isError()) { - return 1 /* AssignableButWithProvisionalErrors */; - } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrowFunction = arg; - 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.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.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 */) { - return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else { - return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); - } - }; - - PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { - if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - 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.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveObjectLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType === this.cachedArrayInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveArrayLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - var argSym = this.resolveAST(arg, false, context); - - if (argSym.type.isAlias()) { - var aliasSym = argSym.type; - argSym = aliasSym.getExportAssignedTypeSymbol(); - } - - comparisonInfo.stringConstantVal = arg; - return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { - var tempComparisonInfo = new TypeComparisonInfo(); - tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; - if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { - return 3 /* Subtype */; - } - - if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { - return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; - } - - if (!comparisonInfo.message) { - var enclosingSymbol = this.getEnclosingSymbolForAST(arg); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); - } - - return 0 /* NotAssignable */; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { - var inferenceResultTypes = argContext.inferTypeArguments(); - var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); - TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); - - 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 (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 inferenceResultTypes; - }; - - PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { - var enclosingDecl = this.getEnclosingDeclForAST(args); - var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); - return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; - }; - - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { - if (expressionType && parameterType) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); - return; - } - } - this.relateTypeToTypeParameters(expressionType, parameterType, 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; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType.isTypeParameter()) { - var typeParameter = parameterType; - argContext.addCandidateForInference(typeParameter, expressionType); - return; - } - - if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { - return; - } - - 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.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) { - return; - } - - var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeArguments = parameterType.getTypeArguments(); - - if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { - for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); - } - } - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var _this = this; - var expressionReturnType = expressionSignature.returnType; - var parameterReturnType = parameterSignature.returnType; - - parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { - context.walkParameterTypes(i); - _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); - context.postWalkParameterTypes(); - return true; - }); - - context.walkReturnTypes(); - this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); - context.postWalkReturnTypes(); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - return; - } - - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); - if (objectMember) { - this.resolveDeclaredSymbol(objectMember); - this.resolveDeclaredSymbol(parameterTypeMembers[i]); - context.walkMemberTypes(parameterTypeMembers[i].name); - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); - context.postWalkMemberTypes(); - } - } - - this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); - - this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; - } - - 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) { - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!typeParameters.length) { - return typeToSpecialize; - } - - var typeArguments = null; - - 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) { - typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; - } else { - typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; - } - } - - var type = this.createInstantiatedType(typeToSpecialize, typeArguments); - - 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(); - - var resolver = semanticInfoChain.getResolver(); - var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); - - if (resolver.canTypeCheckAST(sourceUnit, context)) { - resolver.resolveAST(sourceUnit, false, context); - resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); - - while (resolver.typeCheckCallBacks.length) { - var callBack = resolver.typeCheckCallBacks.pop(); - callBack(context); - } - - resolver.processPostTypeCheckWorkItems(context); - } - }; - - PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { - var _this = this; - this.scanVariableDeclarationGroups(enclosingDecl, function (_) { - }, function (subsequentDecl, firstSymbol) { - if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { - return; - } - - var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); - - var symbol = subsequentDecl.getSymbol(); - var symbolType = symbol.type; - var firstSymbolType = firstSymbol.type; - - 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) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i] === signature) { - break; - } - - 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)); - } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); - } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); - } else { - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved) { - this.resolveDeclaredSymbol(allSignatures[i], context); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - 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_assignable_to_any_non_specialized_signature)); - } - } - } else if (definitionSignature && definitionSignature !== signature) { - var comparisonInfo = new TypeComparisonInfo(); - - if (!definitionSignature.isResolved) { - this.resolveDeclaredSymbol(definitionSignature, context); - } - - if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { - var errorCode; - - 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; - } - - if (errorCode) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); - } - } - }; - - PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { - if (!symbol || symbol.kind === 2 /* Primitive */) { - return; - } - - if (symbol.isType()) { - var typeSymbol = symbol; - var isNamedType = typeSymbol.isNamedTypeSymbol(); - - if (typeSymbol.isArrayNamedTypeReference()) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); - return; - } - - if (!isNamedType) { - var typeOfSymbol = typeSymbol.getTypeOfSymbol(); - if (typeOfSymbol) { - this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); - return; - } - } - - if (typeSymbol.inSymbolPrivacyCheck) { - return; - } - - typeSymbol.inSymbolPrivacyCheck = true; - - var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); - if (typars) { - for (var i = 0; i < typars.length; i++) { - this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); - } - } - - if (!isNamedType) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind === 8192 /* TypeParameter */) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); - } - - typeSymbol.inSymbolPrivacyCheck = false; - - if (!isNamedType) { - return; - } - } - - if (declSymbol.isExternallyVisible()) { - var symbolIsVisible = symbol.isExternallyVisible(); - - 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]) { - 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(); - break; - } - } - symbol = symbolPath[symbolPath.length - 1]; - } - } else if (symbol.kind === 128 /* TypeAlias */) { - var aliasSymbol = symbol; - symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(); - } - - if (!symbolIsVisible) { - privacyErrorReporter(symbol); - } - } - }; - - PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length > 1 && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); - } - - var params = signature.parameters; - for (var j = 0; j < params.length; j++) { - var paramType = params[j].type; - this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); - } - - var returnType = signature.returnType; - this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); - } - }; - - 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; - var messageCode; - - var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; - } - } - - var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { - var typeSymbol = symbol; - var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isProperty = declSymbol.kind === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; - } - } else { - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return; - } - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; - var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; - var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); - var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); - this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { - return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); - }); - } - } - - if (!isGetter && !isIndexSignature) { - var funcParams = functionSignature.parameters; - for (var i = 0; i < funcParams.length; i++) { - this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); - }); - } - } - - if (!isSetter) { - this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); - }); - } - }; - - PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else if (!isGetter) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var parameter = parameters.astAt(argIndex); - - var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { - var _this = this; - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var messageCode = null; - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; - } - } - - if (messageCode) { - var messageArguments = [typeSymbolName]; - var reportOnFuncDecl = false; - - if (returnTypeAnnotation) { - var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); - } - } - - if (block) { - var reportErrorOnReturnExpressions = function (ast, walker) { - var go = true; - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - } - } - }; - - PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { - TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); - - var classSymbol = classDecl.getSymbol(); - return classSymbol.getExtendedTypes().length > 0; - }; - - PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { - if (ast.kind() === 213 /* InvocationExpression */) { - var invocationExpression = ast; - if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { - if (node && node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - if (this.isSuperInvocationExpression(expressionStatement.expression)) { - return true; - } - } - return false; - }; - - PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { - if (block && block.statements && block.statements.childCount() > 0) { - return block.statements.childAt(0); - } - - return null; - }; - - PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { - TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); - - if (constructorDecl) { - var enclosingClass = constructorDecl.getParentDecl(); - - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.kind === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.kind() === 242 /* Parameter */) { - return true; - } - - if (ast.kind() === 136 /* MemberVariableDeclaration */) { - var variableDeclarator = ast; - if (variableDeclarator.variableDeclarator.equalsValueClause) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { - var enclosingDecl = this.getEnclosingDeclForAST(expression); - - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var inArrowFunction = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - inArrowFunction = true; - continue; - } - - if (inArrowFunction) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - var constructorSymbol = decl.getSymbol().getConstructorMethod(); - var constructorDecls = constructorSymbol.getDeclarations(); - for (var i = 0; i < constructorDecls.length; i++) { - constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; - } - } - break; - } - } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { - break; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); - var stringSignature = indexSignatures.stringSignature; - var numberSignature = indexSignatures.numericSignature; - - if (stringSignature || numberSignature) { - var members = containerTypeDecl.getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { - var memberSymbol = member.getSymbol(); - var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); - if (relevantSignature) { - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { - this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); - } - } - } - } - } - }; - - PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { - if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { - return numberIndexSignature; - } else if (stringIndexSignature) { - return stringIndexSignature; - } - - return null; - }; - - PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { - 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.kind; - var extendedMemberKind = extendedTypeMember.kind; - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { - var typeMembers = typeSymbol.getMembers(); - - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - var foundError1 = false; - var foundError2 = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].name; - var extendedTypeProp = extendedType.findMember(propName, true); - if (extendedTypeProp) { - this.resolveDeclaredSymbol(extendedTypeProp, context); - foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); - - if (!foundError1) { - foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); - } - - if (foundError1 || foundError2) { - foundError = true; - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = typeSymbol.getConstructorMethod().type; - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = extendedType.getConstructorMethod().type; - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].name; - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved) { - this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); - } - - if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; - } else { - if (extendedType.isClass()) { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; - } else { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - } - } - } - - if (foundError) { - var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { - var prevInTypeCheck = context.inTypeCheck; - context.inTypeCheck = false; - - var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - - 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; - } - - if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { - return true; - } - - var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; - - if (associatedContainerType) { - return associatedContainerType !== typeSymbol.getRootSymbol(); - } - - return true; - }; - - PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - - var baseType = this.resolveTypeReference(baseDeclAST, context).type; - - if (!baseType) { - return; - } - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (!baseType.isError()) { - if (isExtendedType) { - if (typeDeclIsClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); - } - } - return; - } else if (typeDeclIsClass && isExtendedType) { - if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { - 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)])); - } - } - - if (baseType.hasBase(typeSymbol)) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); - return; - } - - if (isExtendedType) { - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); - }); - } else { - TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); - }); - } - - this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { - return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); - }); - }; - - PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { - var _this = this; - var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); - if (!extendsClause && !implementsClause) { - return; - } - - if (extendsClause) { - for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); - } - } - - if (typeSymbol.isClass()) { - if (implementsClause) { - for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); - } - } - } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { - var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { - return decl.ast().heritageClauses !== null; - }).ast(); - if (classOrInterface === firstInterfaceASTWithExtendsClause) { - this.typeCheckCallBacks.push(function (context) { - _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); - }); - } - } - }; - - PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { - var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); - - var inheritedMembersMap = TypeScript.createIntrinsicsObject(); - var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); - - var typeHasOwnNumberIndexer = false; - var typeHasOwnStringIndexer = false; - - if (typeSymbol.hasOwnIndexSignatures()) { - var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); - for (var i = 0; i < ownIndexSignatures.length; i++) { - if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { - typeHasOwnNumberIndexer = true; - } else { - typeHasOwnStringIndexer = true; - } - } - } - var baseTypes = typeSymbol.getExtendedTypes(); - for (var i = 0; i < baseTypes.length; i++) { - if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { - return; - } - } - - if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { - return; - } - - this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; - var memberName = member.name; - - if (interfaceSymbol.findMember(memberName, false)) { - continue; - } - - this.resolveDeclaredSymbol(member, context); - - if (inheritedMembersMap[memberName]) { - var prevMember = inheritedMembersMap[memberName]; - 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; - } - } else { - inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); - } - } - - return false; - }; - - PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { - if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { - return false; - } - - var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { - var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; - - var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - 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, 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; - } - } else { - allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } else if (parameterTypeIsNumber) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - 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; - } - } else { - allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { - if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; - var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; - for (var memberName in inheritedMembers) { - var memberWithBaseOrigin = inheritedMembers[memberName]; - if (!memberWithBaseOrigin) { - continue; - } - - var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); - if (!relevantSignature) { - continue; - } - - var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; - var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; - - if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { - continue; - } - - 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_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_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])); - } - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - 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_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, [ - interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), - inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.isReference = function (ast, astSymbol) { - if (ast.kind() === 217 /* ParenthesizedExpression */) { - return this.isReference(ast.expression, astSymbol); - } - - if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { - return false; - } - - if (ast.kind() === 11 /* IdentifierName */) { - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { - return false; - } - - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { - return false; - } - - if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { - return false; - } - } - - if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { - if (resolvedName) { - if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { - return this.semanticInfoChain.getEnclosingDecl(ast); - }; - - PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - return enclosingDecl ? enclosingDecl.getSymbol() : null; - }; - - PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { - if (resolvedName) { - if (resolvedName.anyDeclHasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var memberClass = memberContainer.getDeclarations()[0].ast(); - TypeScript.Debug.assert(memberClass); - - var containingClass = this.getEnclosingClassDeclaration(name); - - if (!containingClass || containingClass !== memberClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { - if (type.isPrimitive()) { - return type; - } - - if (type.isError()) { - return type; - } - - if (typeParameterArgumentMap[type.pullSymbolID]) { - return typeParameterArgumentMap[type.pullSymbolID]; - } - - type._resolveDeclaredSymbol(); - if (type.isTypeParameter()) { - return this.instantiateTypeParameter(type, typeParameterArgumentMap); - } - - if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - } - - return type; - }; - - 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 rootSignature = signature.getRootSymbol(); - var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); - TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); - - var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiatedSignature) { - return instantiatedSignature; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); - - 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) { - for (var j = 0; j < parameters.length; j++) { - parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].isOptional) { - parameter.isOptional = true; - } - if (parameters[j].isVarArg) { - parameter.isVarArg = true; - instantiatedSignature.hasVarArgs = true; - } - instantiatedSignature.addParameter(parameter, parameter.isOptional); - - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); - } - } - - return instantiatedSignature; - }; - PullTypeResolver.globalTypeCheckPhase = 0; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; - - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent; - if (!useSameIndent) { - this.indent++; - } - } - } - TypeComparisonInfo.prototype.indentString = function () { - var result = ""; - - for (var i = 0; i < this.indent; i++) { - result += "\t"; - } - - return result; - }; - - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = this.message + TypeScript.newLine() + this.indentString() + message; - } else { - this.message = this.indentString() + message; - } - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - function getPropertyAssignmentNameTextFromIdentifier(identifier) { - if (identifier.kind() === 11 /* IdentifierName */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 14 /* StringLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 13 /* NumericLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; - - function isTypesOnlyLocation(ast) { - while (ast && ast.parent) { - switch (ast.parent.kind()) { - case 244 /* TypeAnnotation */: - return true; - case 127 /* TypeQuery */: - return false; - case 125 /* ConstructorType */: - var constructorType = ast.parent; - if (constructorType.type === ast) { - return true; - } - break; - case 123 /* FunctionType */: - var functionType = ast.parent; - if (functionType.type === ast) { - return true; - } - break; - case 239 /* Constraint */: - var constraint = ast.parent; - if (constraint.type === ast) { - return true; - } - break; - case 220 /* CastExpression */: - var castExpression = ast.parent; - return castExpression.type === ast; - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - return true; - case 228 /* TypeArgumentList */: - return true; - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 130 /* ModuleDeclaration */: - case 129 /* FunctionDeclaration */: - case 145 /* MethodSignature */: - case 212 /* MemberAccessExpression */: - case 242 /* Parameter */: - return false; - } - - ast = ast.parent; - } - - return false; - } - TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var sentinalEmptyArray = []; - - var SemanticInfoChain = (function () { - function SemanticInfoChain(compiler, logger) { - this.compiler = compiler; - this.logger = logger; - this.documents = []; - this.fileNameToDocument = TypeScript.createIntrinsicsObject(); - this.anyTypeDecl = null; - this.booleanTypeDecl = null; - this.numberTypeDecl = null; - this.stringTypeDecl = null; - this.nullTypeDecl = null; - this.undefinedTypeDecl = null; - this.voidTypeDecl = null; - this.undefinedValueDecl = null; - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.voidTypeSymbol = null; - this.undefinedValueSymbol = null; - this.emptyTypeSymbol = null; - this.astSymbolMap = []; - this.astAliasSymbolMap = []; - this.astCallResolutionDataMap = []; - this.declSymbolMap = []; - this.declSignatureSymbolMap = []; - this.declCache = null; - this.symbolCache = null; - this.fileNameToDiagnostics = null; - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - 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); - 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 */, 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 || null; - }; - - SemanticInfoChain.prototype.lineMap = function (fileName) { - return this.getDocument(fileName).lineMap(); - }; - - SemanticInfoChain.prototype.fileNames = function () { - if (this._fileNames === null) { - this._fileNames = this.documents.slice(1).map(function (s) { - return s.fileName; - }); - } - - return this._fileNames; - }; - - SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { - newSymbol.addDeclaration(decl); - decl.setSymbol(newSymbol); - newSymbol.setResolved(); - - return newSymbol; - }; - - SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { - var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { - var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); - newSymbol.type = type; - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.resetGlobalSymbols = function () { - this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); - this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); - this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); - this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); - this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); - this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); - this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); - this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); - - var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); - var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - emptyTypeDecl.setSymbol(emptyTypeSymbol); - emptyTypeSymbol.addDeclaration(emptyTypeDecl); - emptyTypeSymbol.setResolved(); - this.emptyTypeSymbol = emptyTypeSymbol; - }; - - SemanticInfoChain.prototype.addDocument = function (document) { - var fileName = document.fileName; - - var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (existingIndex < 0) { - this.documents.push(document); - } else { - this.documents[existingIndex] = document; - } - - this.fileNameToDocument[fileName] = document; - - this.invalidate(); - }; - - SemanticInfoChain.prototype.removeDocument = function (fileName) { - TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); - var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (index > 0) { - this.fileNameToDocument[fileName] = undefined; - this.documents.splice(index, 1); - this.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { - var cacheID = this.getDeclPathCacheID([name], kind); - - var symbol = this.symbolCache[cacheID]; - - if (!symbol) { - for (var i = 0, n = this.documents.length; i < n; i++) { - var topLevelDecl = this.documents[i].topLevelDecl(); - - var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); - if (symbol) { - break; - } - - if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { - return null; - } - } - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { - var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; - - var foundDecls = topLevelDecl.searchChildDecls(name, kind); - - for (var j = 0; j < foundDecls.length; j++) { - var foundDecl = foundDecls[j]; - - if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { - break; - } - - var symbol = foundDecls[j].getSymbol(); - if (symbol) { - return symbol; - } - } - - return null; - }; - - SemanticInfoChain.prototype.findExternalModule = function (id) { - id = TypeScript.normalizePath(id); - - var tsFile = id + ".ts"; - var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); - symbol = this.symbolCache[tsCacheID]; - if (symbol != undefined) { - return symbol; - } - - 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 isTsFile = document.fileName === tsFile; - if (isTsFile || document.fileName === dtsFile) { - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - symbol = dynamicModuleDecl.getSymbol(); - - 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 null; - }; - - SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { - var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); - - var symbol = this.symbolCache[cacheID]; - if (symbol == undefined) { - symbol = null; - for (var i = 0; i < this.documents.length; i++) { - var document = this.documents[i]; - var topLevelDecl = document.topLevelDecl(); - - if (!topLevelDecl.isExternalModule()) { - var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); - if (dynamicModules.length) { - symbol = dynamicModules[0].getSymbol(); - break; - } - } - } - - this.symbolCache[cacheID] = symbol; - } - - return symbol; - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.topLevelDecls(); - - var decls = TypeScript.sentinelEmptyArray; - var path; - var foundDecls = TypeScript.sentinelEmptyArray; - - 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, kind); - - for (var k = 0; k < foundDecls.length; k++) { - if (decls === TypeScript.sentinelEmptyArray) { - decls = []; - } - decls[decls.length] = foundDecls[k]; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { - var declString = []; - - for (var i = 0, n = declPath.length; i < n; i++) { - if (declPath[i].kind & 1 /* Script */) { - continue; - } - - declString.push(declPath[i].name); - } - - return this.findDecls(declString, declKind); - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - 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; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - } - }; - - SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { - if (typeof oldSettings === "undefined") { oldSettings = null; } - if (typeof newSettings === "undefined") { newSettings = null; } - TypeScript.PullTypeResolver.globalTypeCheckPhase++; - - var cleanStart = new Date().getTime(); - - this.astSymbolMap.length = 0; - this.astAliasSymbolMap.length = 0; - this.astCallResolutionDataMap.length = 0; - - this.declCache = TypeScript.createIntrinsicsObject(); - this.symbolCache = TypeScript.createIntrinsicsObject(); - this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - - this.declSymbolMap.length = 0; - this.declSignatureSymbolMap.length = 0; - - if (oldSettings && newSettings) { - if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { - for (var i = 1, n = this.documents.length; i < n; i++) { - this.documents[i].invalidate(); - } - } - } - - TypeScript.pullSymbolID = 0; - - this.resetGlobalSymbols(); - - var cleanEnd = new Date().getTime(); - }; - - SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); - }; - - SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()] || null; - }; - - SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { - this.astAliasSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { - return this.astAliasSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { - return this.astCallResolutionDataMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { - if (callResolutionData) { - this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap[decl.declID] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { - this.declSignatureSymbolMap[decl.declID] = signatureSymbol; - }; - - SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { - return this.declSignatureSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { - var fileName = diagnostic.fileName(); - var diagnostics = this.fileNameToDiagnostics[fileName]; - if (!diagnostics) { - diagnostics = []; - this.fileNameToDiagnostics[fileName] = diagnostics; - } - - diagnostics.push(diagnostic); - }; - - SemanticInfoChain.prototype.getDiagnostics = function (fileName) { - var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics || []; - }; - - SemanticInfoChain.prototype.getBinder = function () { - if (!this._binder) { - this._binder = new TypeScript.PullSymbolBinder(this); - } - - return this._binder; - }; - - SemanticInfoChain.prototype.getResolver = function () { - if (!this._resolver) { - this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); - } - - return this._resolver; - }; - - SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); - indexParameterSymbol.type = indexParamType; - indexSignature.addParameter(indexParameterSymbol); - indexSignature.returnType = returnType; - indexSignature.setResolved(); - indexParameterSymbol.setResolved(); - - containingSymbol.addIndexSignature(indexSignature); - - 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); - indexParameterSymbol.addDeclaration(indexParamDecl); - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast) { - var document = this.getDocument(ast.fileName()); - - if (document) { - return document._getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { - return this.getDocument(ast.fileName()).getEnclosingDecl(ast); - }; - - SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { - this.getDocument(decl.fileName())._setDeclForAST(ast, decl); - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var document = this.getDocument(decl.fileName()); - if (document) { - return document._getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { - this.getDocument(decl.fileName())._setASTForDecl(decl, ast); - }; - - SemanticInfoChain.prototype.topLevelDecl = function (fileName) { - var document = this.getDocument(fileName); - if (document) { - return document.topLevelDecl(); - } - - return null; - }; - - SemanticInfoChain.prototype.topLevelDecls = function () { - if (!this._topLevelDecls) { - this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { - return u.topLevelDecl(); - }); - } - - return this._topLevelDecls; - }; - - 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, 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; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { - this.document = document; - this.semanticInfoChain = semanticInfoChain; - this.propagateEnumConstants = propagateEnumConstants; - this.isDeclareFile = false; - this.parentChain = []; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - - function containingModuleHasExportAssignment(ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = ast; - return moduleDecl.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } else if (ast.kind() === 120 /* SourceUnit */) { - var sourceUnit = ast; - return sourceUnit.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } - - ast = ast.parent; - } - - return false; - } - - function isParsingAmbientModule(ast, context) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { - return true; - } - } - - ast = ast.parent; - } - - return false; - } - - function preCollectImportDecls(ast, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - - var parent = context.getParent(); - - if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { - declFlags |= 1 /* Exported */; - } - - 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 fileName = sourceUnit.fileName(); - - var isExternalModule = context.document.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); - - context.isDeclareFile = context.document.isDeclareFile(); - - context.pushParent(decl); - - if (isExternalModule) { - var declFlags = 1 /* Exported */; - if (TypeScript.isDTSFile(fileName)) { - declFlags |= 8 /* Ambient */; - } - - var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); - var kind = 32 /* DynamicModule */; - var valueText = TypeScript.quoteStr(fileName); - - var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); - - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, sourceUnit, context); - } - - context.pushParent(decl); - } - } - - function preCollectEnumDecls(enumDecl, context) { - var declFlags = 0 /* None */; - var enumName = enumDecl.identifier.valueText(); - - if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - declFlags |= 4096 /* Enum */; - var kind = 64 /* Enum */; - - var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); - context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); - context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); - - var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); - enumDeclaration.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); - - context.pushParent(enumDeclaration); - } - - function createEnumElementDecls(propertyDecl, context) { - var parent = context.getParent(); - - var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function preCollectModuleDecls(moduleDecl, context) { - var declFlags = 0 /* None */; - - var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); - - var isDynamic = moduleDecl.stringLiteral !== null; - - if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - - 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()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); - } - - context.pushParent(decl); - } else { - var moduleNames = getModuleNames(moduleDecl.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - var moduleName = moduleNames[i]; - - var specificFlags = declFlags; - if (i > 0) { - specificFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleName, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleName); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleName, context); - } - - context.pushParent(decl); - } - } - } - - function getModuleNames(name, result) { - result = result || []; - - if (name.kind() === 121 /* QualifiedName */) { - getModuleNames(name.left, result); - result.push(name.right); - } else { - result.push(name); - } - - return result; - } - TypeScript.getModuleNames = getModuleNames; - - 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.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); - } - - function containsExecutableCode(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); - - if (member.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = member; - - if (containsExecutableCode(moduleDecl.moduleElements)) { - return true; - } - } else if (member.kind() === 133 /* ImportDeclaration */) { - if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { - return true; - } - } else if (member.kind() !== 128 /* InterfaceDeclaration */) { - return true; - } - } - - return false; - } - - function preCollectClassDecls(classDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var parent = context.getParent(); - - 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); - - decl.setValueDecl(constructorDecl); - - context.semanticInfoChain.setDeclForAST(classDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, classDecl); - context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); - - context.pushParent(decl); - } - - function preCollectObjectTypeDecls(objectType, context) { - if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { - return; - } - - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setDeclForAST(objectType, decl); - context.semanticInfoChain.setASTForDecl(decl, objectType); - - context.pushParent(decl); - } - - function preCollectInterfaceDecls(interfaceDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { - declFlags |= 1 /* Exported */; - } - - var parent = context.getParent(); - - 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); - - context.pushParent(decl); - } - - function preCollectParameterDecl(argDecl, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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 */) { - decl.setFlag(67108864 /* ConstructorParameter */); - } - - var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); - var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; - if (isPublicOrPrivate && isInConstructor) { - var parentsParent = context.parentChain[context.parentChain.length - 2]; - - 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 */) { - propDecl.setFlag(67108864 /* ConstructorParameter */); - } - - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setASTForDecl(propDecl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, decl); - } - - parent.addVariableDeclToGroup(decl); - } - - function preCollectTypeParameterDecl(typeParameterDecl, context) { - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); - context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); - } - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = 4096 /* Property */; - - if (propertyDecl.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - var parent = context.getParent(); - - 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); - } - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 512 /* Variable */; - - var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); - if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - 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); - context.semanticInfoChain.setDeclForAST(varDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, varDecl); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectVarDecls(ast, context) { - if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { - return; - } - - var varDecl = ast; - createVariableDeclaration(varDecl, context); - } - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 16777216 /* FunctionType */; - - 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); - context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); - - context.pushParent(decl); - } - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 33554432 /* ConstructorType */; - - 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); - context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); - - context.pushParent(decl); - } - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - if (!funcDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - 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); - context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); - - context.pushParent(decl); - } - - function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { - if (typeof displayName === "undefined") { displayName = null; } - var declFlags = 0 /* None */; - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - declFlags |= 8192 /* ArrowFunction */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = id ? id.text() : ""; - var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); - context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); - - context.pushParent(decl); - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrow = functionExpressionDeclAST; - var declFlags = 4 /* Public */; - - var parent = context.getParent(); - - if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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); - - parent.addVariableDeclToGroup(decl); - } - } - - function createMemberFunctionDeclaration(funcDecl, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!funcDecl.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(funcDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDecl); - - context.pushParent(decl); - } - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 4194304 /* IndexSignature */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); - - context.pushParent(decl); - } - - function createCallSignatureDeclaration(callSignature, context) { - var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; - - if (!isChildOfObjectType) { - return; - } - - var declFlags = 2048 /* Signature */; - var declType = 1048576 /* CallSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(callSignature, decl); - context.semanticInfoChain.setASTForDecl(decl, callSignature); - - context.pushParent(decl); - } - - function createMethodSignatureDeclaration(method, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - declFlags |= 4 /* Public */; - declFlags |= 2048 /* Signature */; - - if (method.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(method, decl); - context.semanticInfoChain.setASTForDecl(decl, method); - - context.pushParent(decl); - } - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 2097152 /* ConstructSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); - - context.pushParent(decl); - } - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.flags; - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); - - context.pushParent(decl); - } - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); - - context.pushParent(decl); - } - - function createFunctionExpressionDeclaration(expression, context) { - createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); - } - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); - - context.pushParent(decl); - } - - function preCollectCatchDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 268435456 /* CatchBlock */; - - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - - var declFlags = 0 /* None */; - var declType = 1024 /* CatchVariable */; - - 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); - context.semanticInfoChain.setDeclForAST(ast.identifier, decl); - context.semanticInfoChain.setASTForDecl(decl, ast.identifier); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectWithDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 134217728 /* WithBlock */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectObjectLiteralDecls(ast, context) { - var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); - - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectSimplePropertyAssignmentDecls(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()); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - } - - function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { - var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); - - 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); - - createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); - } - - function preCollectDecls(ast, context) { - switch (ast.kind()) { - case 120 /* SourceUnit */: - preCollectScriptDecls(ast, context); - break; - case 132 /* EnumDeclaration */: - preCollectEnumDecls(ast, context); - break; - case 243 /* EnumElement */: - createEnumElementDecls(ast, context); - break; - case 130 /* ModuleDeclaration */: - preCollectModuleDecls(ast, context); - break; - case 131 /* ClassDeclaration */: - preCollectClassDecls(ast, context); - break; - case 128 /* InterfaceDeclaration */: - preCollectInterfaceDecls(ast, context); - break; - case 122 /* ObjectType */: - preCollectObjectTypeDecls(ast, context); - break; - case 242 /* Parameter */: - preCollectParameterDecl(ast, context); - break; - case 136 /* MemberVariableDeclaration */: - createMemberVariableDeclaration(ast, context); - break; - case 141 /* PropertySignature */: - createPropertySignature(ast, context); - break; - case 225 /* VariableDeclarator */: - preCollectVarDecls(ast, context); - break; - case 137 /* ConstructorDeclaration */: - createClassConstructorDeclaration(ast, context); - break; - case 139 /* GetAccessor */: - createGetAccessorDeclaration(ast, context); - break; - case 140 /* SetAccessor */: - createSetAccessorDeclaration(ast, context); - break; - case 222 /* FunctionExpression */: - createFunctionExpressionDeclaration(ast, context); - break; - case 135 /* MemberFunctionDeclaration */: - createMemberFunctionDeclaration(ast, context); - break; - case 144 /* IndexSignature */: - createIndexSignatureDeclaration(ast, context); - break; - case 123 /* FunctionType */: - createFunctionTypeDeclaration(ast, context); - break; - case 125 /* ConstructorType */: - createConstructorTypeDeclaration(ast, context); - break; - case 142 /* CallSignature */: - createCallSignatureDeclaration(ast, context); - break; - case 143 /* ConstructSignature */: - createConstructSignatureDeclaration(ast, context); - break; - case 145 /* MethodSignature */: - createMethodSignatureDeclaration(ast, context); - break; - case 129 /* FunctionDeclaration */: - createFunctionDeclaration(ast, context); - break; - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - createAnyFunctionExpressionDeclaration(ast, null, context); - break; - case 133 /* ImportDeclaration */: - preCollectImportDecls(ast, context); - break; - case 238 /* TypeParameter */: - preCollectTypeParameterDecl(ast, context); - break; - case 236 /* CatchClause */: - preCollectCatchDecls(ast, context); - break; - case 163 /* WithStatement */: - preCollectWithDecls(ast, context); - break; - case 215 /* ObjectLiteralExpression */: - preCollectObjectLiteralDecls(ast, context); - break; - case 240 /* SimplePropertyAssignment */: - preCollectSimplePropertyAssignmentDecls(ast, context); - break; - case 241 /* FunctionPropertyAssignment */: - preCollectFunctionPropertyAssignmentDecls(ast, context); - break; - } - } - - function isContainer(decl) { - return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.kind & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.kind & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.kind; - - if (kind & 4 /* Container */) { - return (decl.flags & 32768 /* InitializedModule */) !== 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, context) { - var currentDecl = context.getParent(); - - if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { - if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - return; - } - } - - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDeclaration = ast; - if (moduleDeclaration.stringLiteral) { - TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); - context.popParent(); - } else { - var moduleNames = getModuleNames(moduleDeclaration.name); - for (var i = moduleNames.length - 1; i >= 0; i--) { - var moduleName = moduleNames[i]; - TypeScript.Debug.assert(currentDecl.ast() === moduleName); - context.popParent(); - currentDecl = context.getParent(); - } - } - } - - if (ast.kind() === 132 /* EnumDeclaration */) { - computeEnumElementConstantValues(ast, currentDecl, context); - } - - while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { - context.popParent(); - currentDecl = context.getParent(); - } - } - - function computeEnumElementConstantValues(ast, enumDecl, context) { - TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); - - var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); - var inConstantSection = !isAmbientEnum; - var currentConstantValue = 0; - var enumMemberDecls = enumDecl.getChildDecls(); - - for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { - var enumElement = ast.enumElements.nonSeparatorAt(i); - var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { - return context.semanticInfoChain.getASTForDecl(d) === enumElement; - }); - - TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); - - if (enumElement.equalsValueClause === null) { - if (inConstantSection) { - enumElementDecl.constantValue = currentConstantValue; - currentConstantValue++; - } - } else { - enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); - if (enumElementDecl.constantValue !== null && !isAmbientEnum) { - inConstantSection = true; - currentConstantValue = enumElementDecl.constantValue + 1; - } else { - inConstantSection = false; - } - } - - TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); - } - } - - function computeEnumElementConstantValue(expression, enumMemberDecls, context) { - TypeScript.Debug.assert(expression); - - if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { - var token; - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - token = expression.operand; - break; - default: - token = expression; - } - - var value = token.value(); - return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; - } else if (context.propagateEnumConstants) { - switch (expression.kind()) { - case 11 /* IdentifierName */: - var name = expression; - var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { - return d.name === name.valueText(); - }); - - return matchingEnumElement ? matchingEnumElement.constantValue : null; - - case 202 /* LeftShiftExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left << right; - - case 189 /* BitwiseOrExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left | right; - } - - return null; - } else { - return null; - } - } - - (function (DeclarationCreator) { - function create(document, semanticInfoChain, compilationSettings) { - var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); - - TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); - - return declCollectionContext.getParent(); - } - DeclarationCreator.create = create; - })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); - var DeclarationCreator = TypeScript.DeclarationCreator; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBinder = (function () { - 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 */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.hasBeenBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - if (parent) { - var parentDeclKind = parentDecl.kind; - if (parentDeclKind === 262144 /* GetAccessor */) { - parent = parent.getGetter(); - } else if (parentDeclKind === 524288 /* SetAccessor */) { - parent = parent.getSetter(); - } - } - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = parent.getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.type; - } - } - - return parent.type; - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.name, declKind); - } - - var contextSymbolPath = startingDecl.getParentPath(); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].kind & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - }; - - PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { - var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; - var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; - var name = decl.name; - if (parent) { - var isExported = (decl.flags & 1 /* Exported */) !== 0; - - var prevSymbol = null; - if (lookingForValue) { - prevSymbol = parent.findContainedNonMember(name); - } else if (lookingForType) { - prevSymbol = parent.findContainedNonMemberType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); - } - var prevIsExported = !prevSymbol; - if (!prevSymbol) { - if (lookingForValue) { - prevSymbol = parent.findMember(name, false); - } else if (lookingForType) { - prevSymbol = parent.findNestedType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findNestedContainer(name, searchKind); - } - } - - if (isExported && prevIsExported) { - return prevSymbol; - } - if (prevSymbol) { - var prevDecls = prevSymbol.getDeclarations(); - var lastPrevDecl = prevDecls[prevDecls.length - 1]; - var parentDecl = decl.getParentDecl(); - var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); - if (parentDecl !== prevParentDecl) { - return null; - } - - return prevSymbol; - } - } else { - var parentDecl = decl.getParentDecl(); - if (parentDecl && parentDecl.kind === 1 /* Script */) { - return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); - } else { - var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); - return prevDecls[0] && prevDecls[0].getSymbol(); - } - } - - return null; - }; - - PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { - if (typeof reportError === "undefined") { reportError = true; } - 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 (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()]); - } - return false; - } - - 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; - - var enumContainerSymbol = null; - var enumInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var enumInstanceDecl = enumContainerDecl.getValueDecl(); - - var enumDeclKind = enumContainerDecl.kind; - - var parent = this.getParent(enumContainerDecl); - var parentInstanceSymbol = this.getParent(enumContainerDecl, true); - var parentDecl = enumContainerDecl.getParentDecl(); - var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); - - var isExported = enumContainerDecl.flags & 1 /* Exported */; - - var createdNewSymbol = false; - - enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); - - if (enumContainerSymbol) { - if (enumContainerSymbol.kind !== enumDeclKind) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); - enumContainerSymbol = null; - } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { - enumContainerSymbol = null; - } - } - - if (enumContainerSymbol) { - enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); - } else { - enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); - } - } - - enumContainerSymbol.addDeclaration(enumContainerDecl); - enumContainerDecl.setSymbol(enumContainerSymbol); - - this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); - this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - - if (!enumInstanceSymbol) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] === enumContainerDecl) { - break; - } - - if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol) { - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - enumInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); - } - - enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - enumInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); - } - } - - if (createdNewSymbol && parent) { - if (enumContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(enumContainerSymbol); - } else { - parent.addEnclosedNonMemberType(enumContainerSymbol); - } - } - - if (createdNewSymbol) { - this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); - } - var valueDecl = enumContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - }; - - 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(); - - enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); - }; - - 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(); - - 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); - if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); - TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); - - moduleDeclAST = moduleNameAST; - } - - var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); - var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; - - if (parent && moduleKind === 32 /* DynamicModule */) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); - } - - var createdNewSymbol = false; - - moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); - - if (moduleContainerTypeSymbol) { - if (moduleContainerTypeSymbol.kind !== moduleKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); - } - - moduleContainerTypeSymbol = null; - } 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) { - moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); - this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); - - var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); - - var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - - if (createdNewSymbol) { - if (parent) { - if (moduleContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); - } else { - parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); - } - } - } - - if (currentModuleValueDecl) { - currentModuleValueDecl.ensureSymbolIsBound(); - - 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); - } - } - - if (!instanceSymbol.type) { - instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - } - - moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); - - if (!instanceSymbol.type.getAssociatedContainerType()) { - instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.flags; - var declKind = importDeclaration.kind; - var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); - - var isExported = false; - var importSymbol = null; - var declName = importDeclaration.name; - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); - importSymbol = null; - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(importSymbol); - } else { - parent.addEnclosedNonMemberContainer(importSymbol); - } - } - }; - - 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; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - 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, 58728795 /* SomeType */, parent); - - if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); - classSymbol = null; - } - - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); - this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); - - if (parent) { - if (classDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(classSymbol); - } else { - parent.addEnclosedNonMemberType(classSymbol); - } - } - - 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; - - if (!constructorSymbol) { - var siblingValueDecls = null; - if (parentDecl) { - siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); - - if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { - constructorSymbol = siblingValueDecls[0].getSymbol(); - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - constructorSymbol.setIsSynthesized(); - constructorSymbol.type = constructorTypeSymbol; - } - - classSymbol.setConstructorMethod(constructorSymbol); - classSymbol.setHasDefaultConstructor(); - } - - if (constructorSymbol.getIsSynthesized()) { - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - constructorTypeSymbol.addDeclaration(classDecl); - } else { - classSymbol.setHasDefaultConstructor(false); - } - - constructorTypeSymbol.setAssociatedContainerType(classSymbol); - - var valueDecl = classDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.name; - var interfaceSymbol = null; - - var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); - - if (interfaceSymbol) { - if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); - interfaceSymbol = null; - } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { - interfaceSymbol = null; - } - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - if (interfaceDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(interfaceSymbol); - } else { - parent.addEnclosedNonMemberType(interfaceSymbol); - } - } - } - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - interfaceSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - - break; - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { - var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.kind; - var declFlags = constructorTypeDeclaration.flags; - var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); - - var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - signature.hasVarArgs = true; - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - 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; - - var variableSymbol = null; - - var declName = variableDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - 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; - variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); - - if (!variableSymbol && isModuleValue) { - variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); - } - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var decl; - var decls; - var ast; - var members; - - if (variableSymbol) { - var prevKind = variableSymbol.kind; - var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); - var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); - var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); - var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - 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 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 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.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 || 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); - variableSymbol = null; - parentHadSymbol = false; - } - } - - if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } - } - - if ((declFlags & 118784 /* ImplicitVariable */) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - if (!parent && parentDecl.kind === 1 /* Script */) { - this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); - } - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - if (!classTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - classTypeSymbol = containerDecl.getSymbol(); - if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfoChain.getASTForDecl(decl); - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else if (declFlags & 102400 /* SomeInitializedModule */) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - if (!moduleContainerTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - moduleContainerTypeSymbol = containerDecl.getSymbol(); - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - 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); - } - variableDeclaration.setSymbol(variableSymbol); - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - 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); - } else { - parent.addEnclosedNonMember(variableSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var declName = variableDeclaration.name; - - var variableSymbol = new TypeScript.PullSymbol(declName, declKind); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - - this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); - }; - - PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - var propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - - var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; - - var isStatic = false; - var isOptional = false; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); - - if (isOptional) { - propertySymbol.isOptional = true; - } - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { - var parameters = []; - var params = TypeScript.createIntrinsicsObject(); - var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); - - if (parameterList) { - for (var i = 0, n = parameterList.length; i < n; i++) { - var argDecl = parameterList.astAt(i); - var id = parameterList.identifierAt(i); - var decl = this.semanticInfoChain.getDeclForAST(argDecl); - var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); - var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); - - if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { - parameterSymbol.isVarArg = 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); - - if (signatureSymbol.isDefinition()) { - funcType.addEnclosedNonMember(parameterSymbol); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.kind; - var declFlags = functionDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); - - if (functionSymbol) { - 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); - functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); - } - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.type; - parentHadSymbol = true; - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionSymbol.type = functionTypeSymbol; - functionTypeSymbol.setFunctionSymbol(functionSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol); - } else { - parent.addEnclosedNonMember(functionSymbol); - } - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { - signature.hasVarArgs = true; - } - - var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.kind; - var declFlags = functionExpressionDeclaration.flags; - var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); - - 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionTypeSymbol.setFunctionSymbol(functionSymbol); - - functionSymbol.type = functionTypeSymbol; - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; - if (name) { - this.semanticInfoChain.setSymbolForAST(name, functionSymbol); - } - - this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); - - if (parameters.lastParameterIsRest()) { - signature.hasVarArgs = true; - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.kind; - var declFlags = functionTypeDeclaration.flags; - var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.kind; - var declFlags = methodDeclaration.flags; - var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - methodSymbol = parent.findMember(methodName, false); - - if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.type; - parentHadSymbol = true; - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - methodSymbol.type = methodTypeSymbol; - methodTypeSymbol.setFunctionSymbol(methodSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - - var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; - - TypeScript.Debug.assert(nameAST); - - this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); - this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); - - if (isOptional) { - methodSymbol.isOptional = true; - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol); - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); - - var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); - if (TypeScript.lastParameterIsRest(parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].name; - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); - signature.addTypeParameter(typeParameter); - } else { - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); - methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { - var prototypeStr = "prototype"; - - var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); - if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { - 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], this.semanticInfoChain); - - prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - prototypeSymbol.setIsSynthesized(); - prototypeSymbol.addDeclaration(prototypeDecl); - prototypeSymbol.type = classTypeSymbol; - constructorTypeSymbol.addMember(prototypeSymbol); - - if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { - var resolver = this.semanticInfoChain.getResolver(); - prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); - } - prototypeSymbol.setResolved(); - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.kind; - var declFlags = constructorDeclaration.flags; - var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { - var hasDefinitionSignature = false; - var constructorSigs = constructorSymbol.type.getConstructSignatures(); - - for (var i = 0; i < constructorSigs.length; i++) { - if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { - hasDefinitionSignature = true; - break; - } - } - - if (hasDefinitionSignature) { - this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); - - constructorSymbol = null; - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.type = constructorTypeSymbol; - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - constructorSymbol.setIsSynthesized(false); - this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); - constructSignature.returnType = parent; - constructSignature.addTypeParametersFromReturnType(); - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - constructorTypeSymbol.appendConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - constructSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); - parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { - callSignature.hasVarArgs = true; - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - callSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); - parent.insertCallSignatureAtIndex(callSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); - - var parent = this.getParent(indexSignatureDeclaration); - parent.addIndexSignature(indexSignature); - indexSignature.setContainer(parent); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.kind; - var declFlags = getAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.type; - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - getterTypeSymbol.setFunctionSymbol(getterSymbol); - - getterSymbol.type = getterTypeSymbol; - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - - getterTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.kind; - var declFlags = setAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - - if (setterSymbol) { - setterTypeSymbol = setterSymbol.type; - } - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - setterTypeSymbol.setFunctionSymbol(setterSymbol); - - setterSymbol.type = setterTypeSymbol; - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { - this.bindAllDeclsToPullSymbol(decl); - } - }; - - 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) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - this.bindEnumDeclarationToPullSymbol(decl); - break; - - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 512 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 1024 /* CatchVariable */: - this.bindCatchVariableToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - this.bindEnumMemberDeclarationToPullSymbol(decl); - break; - - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 128 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - decl.getParentDecl().getSymbol(); - break; - - case 268435456 /* CatchBlock */: - case 134217728 /* WithBlock */: - break; - - default: - TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); - } - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); - this.declsBeingBound.pop(); - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (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(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().type; - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.type; - } - var signatures; - - if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (functionDecl.kind === 4194304 /* IndexSignature */) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; - } - PullHelpers.symbolIsEnum = symbolIsEnum; - - function symbolIsModule(symbol) { - return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); - } - PullHelpers.symbolIsModule = symbolIsModule; - - function isOneDeclarationOfKind(symbol, kind) { - var decls = symbol.getDeclarations(); - for (var i = 0; i < decls.length; i++) { - if (decls[i].kind === kind) { - return true; - } - } - - return false; - } - - function isNameNumeric(name) { - return isFinite(+name); - } - PullHelpers.isNameNumeric = isNameNumeric; - - function typeSymbolsAreIdentical(a, b) { - if (a.isTypeReference() && !a.getIsSpecialized()) { - a = a.referencedTypeSymbol; - } - - if (b.isTypeReference() && !b.getIsSpecialized()) { - b = b.referencedTypeSymbol; - } - - return a === b; - } - PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; - - function getRootType(type) { - var rootType = type.getRootSymbol(); - - while (true) { - if (type === rootType) { - return type; - } - - type = rootType; - rootType = type.getRootSymbol(); - } - } - PullHelpers.getRootType = getRootType; - - function isSymbolLocal(symbol) { - var container = symbol.getContainer(); - if (container) { - var containerKind = container.kind; - if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { - return true; - } - - if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { - return true; - } - } - - 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; - -var TypeScript; -(function (TypeScript) { - TypeScript.fileResolutionTime = 0; - TypeScript.fileResolutionIOTime = 0; - TypeScript.fileResolutionScanImportsTime = 0; - TypeScript.fileResolutionImportFileSearchTime = 0; - TypeScript.fileResolutionGetDefaultLibraryTime = 0; - TypeScript.sourceCharactersCompiled = 0; - TypeScript.syntaxTreeParseTime = 0; - TypeScript.syntaxDiagnosticsTime = 0; - TypeScript.astTranslationTime = 0; - TypeScript.typeCheckTime = 0; - - TypeScript.compilerResolvePathTime = 0; - TypeScript.compilerDirectoryNameTime = 0; - TypeScript.compilerDirectoryExistsTime = 0; - TypeScript.compilerFileExistsTime = 0; - - TypeScript.emitTime = 0; - TypeScript.emitWriteFileTime = 0; - - TypeScript.declarationEmitTime = 0; - TypeScript.declarationEmitIsExternallyVisibleTime = 0; - TypeScript.declarationEmitTypeSignatureTime = 0; - TypeScript.declarationEmitGetBoundDeclTypeTime = 0; - TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; - TypeScript.declarationEmitGetBaseTypeTime = 0; - TypeScript.declarationEmitGetAccessorFunctionTime = 0; - TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; - TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; - - TypeScript.ioHostResolvePathTime = 0; - TypeScript.ioHostDirectoryNameTime = 0; - 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(emitOutputResult) { - if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } - this.outputFiles = []; - this.emitOutputResult = emitOutputResult; - } - return EmitOutput; - })(); - TypeScript.EmitOutput = EmitOutput; - - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); - var OutputFileType = TypeScript.OutputFileType; - - var OutputFile = (function () { - function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { - if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.text = text; - this.fileType = fileType; - this.sourceMapEntries = sourceMapEntries; - } - return OutputFile; - })(); - TypeScript.OutputFile = OutputFile; - - var CompileResult = (function () { - function CompileResult() { - this.diagnostics = []; - this.outputFiles = []; - } - CompileResult.fromDiagnostics = function (diagnostics) { - var result = new CompileResult(); - result.diagnostics = diagnostics; - return result; - }; - - CompileResult.fromOutputFiles = function (outputFiles) { - var result = new CompileResult(); - result.outputFiles = outputFiles; - return result; - }; - return CompileResult; - })(); - TypeScript.CompileResult = CompileResult; - - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, _settings) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } - this.logger = logger; - this._settings = _settings; - this.semanticInfoChain = null; - this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); - } - TypeScriptCompiler.prototype.compilationSettings = function () { - return this._settings; - }; - - TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { - var oldSettings = this._settings; - this._settings = newSettings; - - if (!compareDataObjects(oldSettings, newSettings)) { - this.semanticInfoChain.invalidate(oldSettings, newSettings); - } - }; - - TypeScriptCompiler.prototype.getDocument = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.semanticInfoChain.getDocument(fileName); - }; - - TypeScriptCompiler.prototype.cleanupSemanticCache = function () { - this.semanticInfoChain.invalidate(); - }; - - TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - fileName = TypeScript.switchToForwardSlashes(fileName); - - TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); - - var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); - - this.semanticInfoChain.addDocument(document); - }; - - TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); - - this.semanticInfoChain.addDocument(updatedDocument); - }; - - TypeScriptCompiler.prototype.removeFile = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - this.semanticInfoChain.removeDocument(fileName); - }; - - TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { - if (document.emitToOwnOutputFile()) { - var updatedFileName = document.fileName; - if (emitOptions.outputDirectory() !== "") { - updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); - updatedFileName = emitOptions.outputDirectory() + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(emitOptions.sharedOutputFile(), true); - } - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - var printReason = false; - - if (document.emitToOwnOutputFile()) { - var result = document.byteOrderMark !== 0 /* None */; - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - } - return result; - } else { - var fileNames = this.fileNames(); - - var result = false; - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - - if (document.isExternalModule()) { - continue; - } - - if (document.byteOrderMark !== 0 /* None */) { - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - result = true; - } else { - return true; - } - } - } - - return result; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype._shouldEmit = function (document) { - return !document.isDeclareFile(); - }; - - TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { - if (!this.compilationSettings().generateDeclarationFiles()) { - return false; - } - - return this._shouldEmit(document); - }; - - TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); - - if (declarationEmitter) { - declarationEmitter.document = document; - } else { - var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); - } - - declarationEmitter.emitDeclarations(sourceUnit); - return declarationEmitter; - }; - - TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmitDeclarations(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFile()); - } - } else { - sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var sharedEmitter = null; - var fileNames = this.fileNames(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileNames[i]); - - sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); - } - - TypeScript.declarationEmitTime += new Date().getTime() - start; - - return emitOutput; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, null); - return emitOutput; - } else { - return this.emitAllDeclarations(resolvePath); - } - }; - - 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; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmit(document)); - - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); - var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); - - if (this.compilationSettings().mapSourceFiles()) { - var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); - emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); - } - } else if (this.compilationSettings().mapSourceFiles()) { - emitter.setSourceMapperNewSourceFile(document); - } - - emitter.setDocument(document); - emitter.emitJavascript(sourceUnit, false); - - return emitter; - }; - - TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmit(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFiles()); - } - } else { - sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var fileNames = this.fileNames(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - sharedEmitter = this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); - } - - TypeScript.emitTime += new Date().getTime() - start; - return emitOutput; - }; - - TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, null); - return emitOutput; - } else { - return this.emitAll(resolvePath); - } - }; - - TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { - if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } - return new CompilerIterator(this, resolvePath, continueOnDiagnostics); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - - TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { - return this.getDocument(fileName).sourceUnit(); - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - - var startTime = (new Date()).getTime(); - TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); - var endTime = (new Date()).getTime(); - - TypeScript.typeCheckTime += endTime - startTime; - - var errors = this.semanticInfoChain.getDiagnostics(fileName); - - errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); - errors.sort(function (d1, d2) { - if (d1.fileName() < d2.fileName()) { - return -1; - } else if (d1.fileName() > d2.fileName()) { - return 1; - } - - if (d1.start() < d2.start()) { - return -1; - } else if (d1.start() > d2.start()) { - return 1; - } - - var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; - var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; - if (code1 < code2) { - return -1; - } else if (code1 > code2) { - return 1; - } - - return 0; - }); - - 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++) { - this.getSemanticDiagnostics(fileNames[i]); - } - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var ast = this.semanticInfoChain.getASTForDecl(decl); - if (!ast) { - return null; - } - - var enclosingDecl = resolver.getEnclosingDecl(decl); - if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { - return this.getSymbolOfDeclaration(enclosingDecl); - } - - return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { - var scriptName = document.fileName; - - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - var inWithBlock = false; - - var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); - - if (!ast) { - return null; - } - - var path = this.getASTPath(ast); - - for (var i = 0, n = path.length; i < n; i++) { - var current = path[i]; - - switch (current.kind()) { - case 222 /* FunctionExpression */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - if (propagateContextualTypes) { - resolver.resolveAST(current, true, resolutionContext); - } - break; - - case 136 /* MemberVariableDeclaration */: - var memberVariable = current; - inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); - break; - - case 225 /* VariableDeclarator */: - var variableDeclarator = current; - inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); - break; - - case 213 /* InvocationExpression */: - case 216 /* ObjectCreationExpression */: - if (propagateContextualTypes) { - var isNew = current.kind() === 216 /* ObjectCreationExpression */; - var callExpression = current; - var contextualType = null; - - if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = path[i + 3]; - if (argExpression) { - for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { - if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext); - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 214 /* ArrayLiteralExpression */: - if (propagateContextualTypes) { - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 215 /* ObjectLiteralExpression */: - if (propagateContextualTypes) { - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.propertyAssignments; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { - if (memberDecls.nonSeparatorAt(j) === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - } - - break; - - case 174 /* AssignmentExpression */: - if (propagateContextualTypes) { - var assignmentExpression = current; - var contextualType = null; - - if (path[i + 1] && path[i + 1] === assignmentExpression.right) { - var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - 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; - - case 150 /* ReturnStatement */: - if (propagateContextualTypes) { - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 122 /* ObjectType */: - if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { - resolver.resolveAST(current, false, resolutionContext); - } - - break; - - case 163 /* WithStatement */: - inWithBlock = true; - break; - - case 146 /* Block */: - inContextuallyTypedAssignment = false; - break; - } - - var decl = this.semanticInfoChain.getDeclForAST(current); - if (decl) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { - if (ast.parent.kind() === 212 /* MemberAccessExpression */) { - if (ast.parent.name === ast) { - ast = ast.parent; - } - } else if (ast.parent.kind() === 121 /* QualifiedName */) { - if (ast.parent.right === ast) { - ast = ast.parent; - } - } - } - - return { - ast: ast, - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment, - inWithBlock: inWithBlock - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { - if (inContextuallyTypedAssignment) { - if (propagateContextualTypes) { - resolver.resolveAST(assigningAST, false, resolutionContext); - var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.type; - } - - resolutionContext.pushNewContextualType(contextualType); - - if (init) { - resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); - } - } - } - }; - - TypeScriptCompiler.prototype.getASTPath = function (ast) { - var result = []; - - while (ast) { - result.unshift(ast); - ast = ast.parent; - } - - return result; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - ast = context.ast; - 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()]); - return null; - } - - if (symbol.isTypeReference()) { - symbol = symbol.getReferencedTypeSymbol(); - } - - var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); - - return { - symbol: symbol, - aliasSymbol: aliasSymbol, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { - if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { - return null; - } - - var isNew = ast.kind() === 216 /* ObjectCreationExpression */; - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, false); - if (!context || context.inWithBlock) { - return null; - } - - return resolver.getVisibleDecls(context.enclosingDecl); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { - if (ast.kind() !== 215 /* ObjectLiteralExpression */) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var astForDecl = decl.ast(); - if (!astForDecl) { - return null; - } - - var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); - if (!astForDeclContext) { - return null; - } - - var symbol = decl.getSymbol(); - resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - aliasSymbol: null, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - - TypeScriptCompiler.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast); - }; - - TypeScriptCompiler.prototype.fileNames = function () { - return this.semanticInfoChain.fileNames(); - }; - - 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; - - var CompilerPhase; - (function (CompilerPhase) { - CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; - CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; - CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; - CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; - CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; - })(CompilerPhase || (CompilerPhase = {})); - - var CompilerIterator = (function () { - function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { - if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } - this.compiler = compiler; - this.resolvePath = resolvePath; - this.continueOnDiagnostics = continueOnDiagnostics; - this.index = -1; - this.fileNames = null; - this._current = null; - this._emitOptions = null; - this._sharedEmitter = null; - this._sharedDeclarationEmitter = null; - this.hadSyntacticDiagnostics = false; - this.hadSemanticDiagnostics = false; - this.hadEmitDiagnostics = false; - this.fileNames = compiler.fileNames(); - this.compilerPhase = startingPhase; - } - CompilerIterator.prototype.current = function () { - return this._current; - }; - - CompilerIterator.prototype.moveNext = function () { - this._current = null; - - while (this.moveNextInternal()) { - if (this._current) { - return true; - } - } - - return false; - }; - - CompilerIterator.prototype.moveNextInternal = function () { - this.index++; - - while (this.shouldMoveToNextPhase()) { - this.index = 0; - this.compilerPhase++; - } - - if (this.compilerPhase > 4 /* DeclarationEmit */) { - return false; - } - - switch (this.compilerPhase) { - case 0 /* Syntax */: - return this.moveNextSyntaxPhase(); - case 1 /* Semantics */: - return this.moveNextSemanticsPhase(); - case 2 /* EmitOptionsValidation */: - return this.moveNextEmitOptionsValidationPhase(); - case 3 /* Emit */: - return this.moveNextEmitPhase(); - case 4 /* DeclarationEmit */: - return this.moveNextDeclarationEmitPhase(); - } - }; - - CompilerIterator.prototype.shouldMoveToNextPhase = function () { - switch (this.compilerPhase) { - case 2 /* EmitOptionsValidation */: - return this.index === 1; - - case 0 /* Syntax */: - case 1 /* Semantics */: - return this.index === this.fileNames.length; - - case 3 /* Emit */: - case 4 /* DeclarationEmit */: - return this.index === (this.fileNames.length + 1); - } - - return false; - }; - - CompilerIterator.prototype.moveNextSyntaxPhase = function () { - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - - var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSyntacticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextSemanticsPhase = function () { - if (this.hadSyntacticDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - var diagnostics = this.compiler.getSemanticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSemanticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - - if (!this._emitOptions) { - this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); - } - - if (this._emitOptions.diagnostic()) { - if (!this.continueOnDiagnostics) { - this.hadEmitDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(this._emitOptions); - - if (this.hadEmitDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { - _this._current = CompileResult.fromOutputFiles(outputFiles); - }, this._sharedEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedEmitter) { - this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); - } - - return true; - }; - - CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(!this.hadEmitDiagnostics); - if (this.hadSemanticDiagnostics) { - return false; - } - - if (!this.compiler.compilationSettings().generateDeclarationFiles()) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { - _this._current = CompileResult.fromOutputFiles([file]); - }, this._sharedDeclarationEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { - this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); - } - - return true; - }; - return CompilerIterator; - })(); - - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - TypeScript.compareDataObjects = compareDataObjects; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (GenerativeTypeClassification) { - GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; - GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; - GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; - GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; - })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); - var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; - - var PullTypeReferenceSymbol = (function (_super) { - __extends(PullTypeReferenceSymbol, _super); - function PullTypeReferenceSymbol(referencedTypeSymbol) { - _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); - this.referencedTypeSymbol = referencedTypeSymbol; - this.isResolved = true; - - TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); - - this.setRootSymbol(referencedTypeSymbol); - - this.typeReference = this; - } - PullTypeReferenceSymbol.createTypeReference = function (type) { - if (type.isTypeReference()) { - return type; - } - - var typeReference = type.typeReference; - - if (!typeReference) { - typeReference = new PullTypeReferenceSymbol(type); - type.typeReference = typeReference; - } - - return typeReference; - }; - - PullTypeReferenceSymbol.prototype.isTypeReference = function () { - return true; - }; - - PullTypeReferenceSymbol.prototype.setResolved = function () { - }; - - PullTypeReferenceSymbol.prototype.setUnresolved = function () { - }; - PullTypeReferenceSymbol.prototype.invalidate = function () { - }; - - PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { - this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); - }; - - PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol; - }; - - PullTypeReferenceSymbol.prototype._getResolver = function () { - return this.referencedTypeSymbol._getResolver(); - }; - - PullTypeReferenceSymbol.prototype.hasMembers = function () { - return this.referencedTypeSymbol.hasMembers(); - }; - - PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); - }; - - PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - return this.referencedTypeSymbol.getAssociatedContainerType(); - }; - - PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getFunctionSymbol(); - }; - PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); - }; - - PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); - }; - PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); - }; - - PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); - }; - PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMember(name); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); - }; - - PullTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getMembers(); - }; - - PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); - }; - PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getHasDefaultConstructor(); - }; - PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructorMethod(); - }; - PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); - }; - PullTypeReferenceSymbol.prototype.getTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.isGeneric = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isGeneric(); - }; - - PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getSpecialization(substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getKnownSpecializations(); - }; - PullTypeReferenceSymbol.prototype.getTypeArguments = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArguments(); - }; - PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); - }; - 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"); - }; - - PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnIndexSignatures(); - }; - PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getIndexSignatures(); - }; - - PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { - this.referencedTypeSymbol.addImplementedType(implementedType); - }; - PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getImplementedTypes(); - }; - PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { - this.referencedTypeSymbol.addExtendedType(extendedType); - }; - PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getExtendedTypes(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExtendsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExtendThisType(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); - }; - - PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); - }; - - PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findMember(name, lookInParent); - }; - PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedType(name, kind); - }; - PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedContainer(name, kind); - }; - PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - }; - - PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findTypeParameter(name); - }; - - PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); - }; - return PullTypeReferenceSymbol; - })(TypeScript.PullTypeSymbol); - TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - TypeScript.nSpecializedTypeParameterCreated = 0; - - var PullInstantiatedTypeReferenceSymbol = (function (_super) { - __extends(PullInstantiatedTypeReferenceSymbol, _super); - 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 = undefined; - this._instantiatedConstructorMethod = null; - this._instantiatedAssociatedContainerType = null; - this._isArray = undefined; - this._generativeTypeClassification = []; - - TypeScript.nSpecializationsCreated++; - } - PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { - return !this.isInstanceReferenceType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - if (!this.isNamedTypeSymbol()) { - return 0 /* Unknown */; - } - - 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()); - } - return this._isArray; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { - if (!this.isArrayNamedTypeReference()) { - return null; - } - - var typeArguments = this.getTypeArguments(); - return typeArguments ? typeArguments[0] : null; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.getIsSpecialized()) { - return this; - } - - return this.referencedTypeSymbol; - }; - - 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiation) { - return instantiation; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - 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; - } - } - - if (isInstanceReferenceType) { - typeParameterArgumentMap = []; - } - } - - instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); - - rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); - - return instantiation; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return this.getRootSymbol().isGeneric(); - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { - return this._typeParameterArgumentMap; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { - if (this.isInstanceReferenceType) { - return this.getTypeParameters(); - } - - if (this._typeArgumentReferences === undefined) { - var typeParameters = this.referencedTypeSymbol.getTypeParameters(); - - if (typeParameters.length) { - var typeArgument = null; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; - - if (!typeArgument) { - TypeScript.Debug.fail("type argument count mismatch"); - } - - if (typeArgument) { - typeArguments[typeArguments.length] = typeArgument; - } - } - - this._typeArgumentReferences = typeArguments; - } else { - this._typeArgumentReferences = null; - } - } - - return this._typeArgumentReferences; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - 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(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getMembers(); - } - - if (!this._instantiatedMembers) { - var referencedMembers = this.referencedTypeSymbol.getMembers(); - var referencedMember = null; - var instantiatedMember = null; - - this._instantiatedMembers = []; - - for (var i = 0; i < referencedMembers.length; i++) { - referencedMember = referencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (!this._instantiatedMemberNameCache[referencedMember.name]) { - this.populateInstantiatedMemberFromReferencedMember(referencedMember); - } - - this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; - } - } - - return this._instantiatedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.findMember(name, lookInParent); - } - - var memberSymbol = this._instantiatedMemberNameCache[name]; - - if (!memberSymbol) { - var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); - - if (referencedMemberSymbol) { - this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); - memberSymbol = this._instantiatedMemberNameCache[name]; - } else { - memberSymbol = null; - } - } - - return memberSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - } - - var requestedMembers = []; - var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - - if (!this._allInstantiatedMemberNameCache) { - this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - - var members = this.getMembers(); - - for (var i = 0; i < members.length; i++) { - this._allInstantiatedMemberNameCache[members[i].name] = members[i]; - } - } - - var referencedMember = null; - var requestedMember = null; - - for (var i = 0; i < allReferencedMembers.length; i++) { - referencedMember = allReferencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (this._allInstantiatedMemberNameCache[referencedMember.name]) { - requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; - } else { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; - requestedMembers[requestedMembers.length] = referencedMember; - } else { - requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - requestedMember.setRootSymbol(referencedMember); - - requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - requestedMember.isOptional = referencedMember.isOptional; - - this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; - requestedMembers[requestedMembers.length] = requestedMember; - } - } - } - - return requestedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructorMethod(); - } - - 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); - } - - return this._instantiatedConstructorMethod; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - if (!this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAssociatedContainerType(); - } - - if (!this._instantiatedAssociatedContainerType) { - var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); - - if (referencedAssociatedContainerType) { - this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); - } - } - - return this._instantiatedAssociatedContainerType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getCallSignatures(); - } - - if (this._instantiatedCallSignatures) { - return this._instantiatedCallSignatures; - } - - var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); - this._instantiatedCallSignatures = []; - - for (var i = 0; i < referencedCallSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); - - if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; - } else { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedCallSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructSignatures(); - } - - if (this._instantiatedConstructSignatures) { - return this._instantiatedConstructSignatures; - } - - var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); - this._instantiatedConstructSignatures = []; - - for (var i = 0; i < referencedConstructSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); - - if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; - } else { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedConstructSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getIndexSignatures(); - } - - if (this._instantiatedIndexSignatures) { - return this._instantiatedIndexSignatures; - } - - var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); - this._instantiatedIndexSignatures = []; - - for (var i = 0; i < referencedIndexSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); - - if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; - } else { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedIndexSignatures; - }; - 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) { - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.previousTokenTrailingComments = null; - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { - var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { - var firstToken = node.firstToken(); - var lastToken = node.lastToken(); - - this.setSpan(ast, fullStart, node, firstToken, lastToken); - ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); - ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); - }; - - SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { - if (element === null) { - return null; - } - - if (element.fullWidth() === 0) { - return new TypeScript.ASTSpan(-1, -1); - } - - var leadingTriviaWidth = element.leadingTriviaWidth(); - var trailingTriviaWidth = element.trailingTriviaWidth(); - - var start = fullStart + leadingTriviaWidth; - var end = fullStart + element.fullWidth() - trailingTriviaWidth; - - return new TypeScript.ASTSpan(start, end); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { - if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } - if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } - var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; - var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; - - var desiredMinChar = fullStart + leadingTriviaWidth; - var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span._trailingTriviaWidth = trailingTriviaWidth; - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - span._start = start; - span._end = end; - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { - var start = this.position; - var array = new Array(node.childCount()); - - for (var i = 0, n = node.childCount(); i < n; i++) { - array[i] = node.childAt(i).accept(this); - } - - var result = new TypeScript.ISyntaxList2(this.fileName, array); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var array = new Array(list.nonSeparatorCount()); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - array[i / 2] = list.childAt(i).accept(this); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); - this.setSpan(result, start, list); - - result.setPostComments(this.previousTokenTrailingComments); - this.previousTokenTrailingComments = null; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { - if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); - }; - - SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { - return this.visitToken(token); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - var fullStart = this.position; - - var result = this.visitTokenWorker(token); - - this.movePast(token); - - var start = fullStart + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { - switch (token.tokenKind) { - case 60 /* AnyKeyword */: - return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); - case 61 /* BooleanKeyword */: - return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); - case 67 /* NumberKeyword */: - return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); - case 69 /* StringKeyword */: - return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); - case 41 /* VoidKeyword */: - return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); - case 35 /* ThisKeyword */: - return new TypeScript.ThisExpression(token.text(), token.valueText()); - case 50 /* SuperKeyword */: - return new TypeScript.SuperExpression(token.text(), token.valueText()); - case 37 /* TrueKeyword */: - return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); - case 24 /* FalseKeyword */: - return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); - case 32 /* NullKeyword */: - return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); - case 14 /* StringLiteral */: - return new TypeScript.StringLiteral(token.text(), token.valueText()); - case 12 /* RegularExpressionLiteral */: - return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); - case 13 /* NumericLiteral */: - var fullStart = this.position; - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); - - result.setPreComments(preComments); - return result; - case 11 /* IdentifierName */: - return new TypeScript.Identifier(token.text()); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { - var start = this.position; - TypeScript.Debug.assert(start === 0); - - var bod = this.visitSyntaxList(node.moduleElements); - 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; - }; - - SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { - var start = this.position; - - this.moveTo(node, node.stringLiteral); - var stringLiteral = node.stringLiteral.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ExternalModuleReference(stringLiteral); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { - var start = this.position; - var moduleName = node.moduleName.accept(this); - - var result = new TypeScript.ModuleNameModuleReference(moduleName); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - this.movePast(node.openBraceToken); - var members = this.visitSyntaxList(node.classElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { - var result = null; - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { - result = result || []; - result.push(1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - result = result || []; - result.push(8 /* Ambient */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { - result = result || []; - result.push(16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { - result = result || []; - result.push(4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { - result = result || []; - result.push(2 /* Private */); - } - - return result || TypeScript.sentinelEmptyArray; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - var body = this.visitObjectType(node.body); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - var start = this.position; - - this.movePast(node.extendsOrImplementsKeyword); - var typeNames = this.visitSeparatedSyntaxList(node.typeNames); - - var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - var start = this.position; - - var modifiers = this.visitModifiers(node.modifiers); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - - var moduleName = node.name ? node.name.accept(this) : null; - var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; - - this.movePast(node.openBraceToken); - - var moduleElements = this.visitSyntaxList(node.moduleElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - this.movePast(node.openBraceToken); - - var enumElements = this.visitSeparatedSyntaxList(node.enumElements); - - this.movePast(node.closeBraceToken); - - var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - var start = this.position; - - var memberName = this.visitToken(node.propertyName); - - var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.EnumElement(memberName, value); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ImportDeclaration(modifiers, name, alias); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExportAssignment(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.VariableStatement(modifiers, declaration); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - var start = this.position; - var propertyName = this.visitToken(node.propertyName); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - var start = this.position; - var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var value = node.value.accept(this); - value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); - - var result = new TypeScript.EqualsValueClause(value); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var start = this.position; - - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var start = this.position; - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayLiteralExpression(expressions); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - var start = this.position; - - var result = new TypeScript.OmittedExpression(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var start = this.position; - - var openParenToken = node.openParenToken; - var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(openParenToken); - - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var start = this.position; - - var identifier = node.identifier.accept(this); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var start = this.position; - - var callSignature = this.visitCallSignature(node.callSignature); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - return type ? type.accept(this) : null; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { - var start = this.position; - this.movePast(node.typeOfKeyword); - var name = node.name.accept(this); - - var result = new TypeScript.TypeQuery(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - var start = this.position; - var left = this.visitType(node.left); - this.movePast(node.dotToken); - var right = this.visitIdentifier(node.right); - - var result = new TypeScript.QualifiedName(left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeArgumentList(typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - var start = this.position; - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - var start = this.position; - - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectType(typeMembers); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayType(underlying); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.name); - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - var result = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.colonToken); - var type = this.visitType(node.type); - - var result = new TypeScript.TypeAnnotation(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - - var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - var start = this.position; - - var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.visitIdentifier(node.name); - - var result = new TypeScript.MemberAccessExpression(expression, name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var start = this.position; - - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.InvocationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - this.movePast(node.openParenToken); - - 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()); - } - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - var start = this.position; - - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - var result = new TypeScript.BinaryExpression(node.kind(), left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - var start = this.position; - - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.ConstructSignature(callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.MethodSignature(name, questionToken, callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - var start = this.position; - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.IndexSignature(parameter, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - var openParenToken = node.openParenToken; - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - var openParenTrailingComments = null; - if (node.parameters.childCount() === 0) { - openParenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - } - - this.movePast(node.openParenToken); - var parameters = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - var start = this.position; - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeParameterList(typeParameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - var result = new TypeScript.TypeParameter(identifier, constraint); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - var start = this.position; - this.movePast(node.extendsKeyword); - var type = this.visitType(node.type); - - var result = new TypeScript.Constraint(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - var result = new TypeScript.IfStatement(condition, thenBod, elseBod); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - var start = this.position; - - this.movePast(node.elseKeyword); - var statement = node.statement.accept(this); - - var result = new TypeScript.ElseClause(statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var expression = node.expression.accept(this); - - var semicolonPosition = this.position; - - var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExpressionStatement(expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var start = this.position; - - 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(callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.indexSignature); - var indexSignature = node.indexSignature.accept(this); - - this.movePast(node.semicolonToken); - - var result = new TypeScript.IndexMemberDeclaration(indexSignature); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarator); - var variableDeclarator = node.variableDeclarator.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - var start = this.position; - - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ThrowStatement(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - var start = this.position; - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ReturnStatement(expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.ObjectCreationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - var start = this.position; - - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - this.movePast(node.openBraceToken); - var switchClauses = this.visitSyntaxList(node.switchClauses); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.CaseSwitchClause(expression, statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.DefaultSwitchClause(statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - var start = this.position; - - this.movePast(node.breakKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.BreakStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - var start = this.position; - - this.movePast(node.continueKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ContinueStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var initializer = node.initializer ? node.initializer.accept(this) : null; - - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var left = node.left ? node.left.accept(this) : null; - - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WhileStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WithStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - var start = this.position; - - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - var result = new TypeScript.CastExpression(castTerm, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var start = this.position; - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); - - var propertyName = node.propertyName.accept(this); - - var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var expression = node.expression.accept(this); - expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); - - var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var start = this.position; - - var propertyName = node.propertyName.accept(this); - var callSignature = this.visitCallSignature(node.callSignature); - var block = this.visitBlock(node.block); - - var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - var start = this.position; - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? node.block.accept(this) : null; - - var result = new TypeScript.FunctionExpression(name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - var start = this.position; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.EmptyStatement(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - var start = this.position; - - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - var start = this.position; - - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.visitIdentifier(node.identifier); - var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - var start = this.position; - this.movePast(node.finallyKeyword); - var block = node.block.accept(this); - - var result = new TypeScript.FinallyClause(block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.LabeledStatement(identifier, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - var start = this.position; - - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DoStatement(statement, whileKeyword, condition); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - var start = this.position; - - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.TypeOfExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - var start = this.position; - - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.DeleteExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - var start = this.position; - - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.VoidExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - var start = this.position; - - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DebuggerStatement(); - this.setSpan(result, start, node); - - return result; - }; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; - - function applyDelta(ast, delta) { - if (ast) { - if (ast._start !== -1) { - ast._start += delta; - } - - if (ast._end !== -1) { - ast._end += delta; - } - } - } - - function applyDeltaToComments(comments, delta) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment, delta); - } - } - } - - var SyntaxTreeToIncrementalAstVisitor = (function (_super) { - __extends(SyntaxTreeToIncrementalAstVisitor, _super); - function SyntaxTreeToIncrementalAstVisitor() { - _super.apply(this, arguments); - } - SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { - if (delta === 0) { - return; - } - - var pre = function (cur) { - applyDelta(cur, delta); - applyDeltaToComments(cur.preComments(), delta); - applyDeltaToComments(cur.postComments(), delta); - - switch (cur.kind()) { - case 146 /* Block */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 226 /* ArgumentList */: - applyDelta(cur.closeParenToken, delta); - break; - - case 130 /* ModuleDeclaration */: - applyDelta(cur.endingToken, delta); - break; - - case 131 /* ClassDeclaration */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 161 /* DoStatement */: - applyDelta(cur.whileKeyword, delta); - break; - - case 151 /* SwitchStatement */: - applyDelta(cur.closeParenToken, delta); - break; - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span._start !== -1) { - var delta = start - span._start; - this.applyDelta(span, delta); - - span._end = end; - } else { - _super.prototype.setSpanExplicit.call(this, span, start, end); - } - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - var result = element._ast; - if (!result) { - return null; - } - - var start = this.position; - this.movePast(element); - this.setSpan(result, start, element); - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { - element._ast = ast; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSeparatedSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { - var result = this.getAndMovePastAST(token); - - if (!result) { - result = _super.prototype.visitToken.call(this, token); - this.setAST(token, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitClassDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInterfaceDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitHeritageClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitModuleDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitImportDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExportAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPrefixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitOmittedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - var result = _super.prototype.visitQualifiedName.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGenericType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBlock.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPostfixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitElementAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInvocationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBinaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConditionalExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMethodSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIndexSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPropertySignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCallSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIfStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExpressionStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberVariableDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitThrowStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitReturnStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectCreationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSwitchStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCaseSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDefaultSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBreakStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitContinueStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForInStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWhileStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWithStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCastExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimplePropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitEmptyStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTryStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCatchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitLabeledStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDoStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeOfExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDeleteExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitVoidExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDebuggerStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - return SyntaxTreeToIncrementalAstVisitor; - })(SyntaxTreeToAstVisitor); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan(_start, _end) { - this._start = _start; - this._end = _end; - } - ASTSpan.prototype.start = function () { - return this._start; - }; - - ASTSpan.prototype.end = function () { - return this._end; - }; - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - var astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, false); - } - - function commentStructuralEqualsIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, true); - } - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); - } - - function commentStructuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - function commentArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST() { - this.parent = null; - this._start = -1; - this._end = -1; - this._trailingTriviaWidth = 0; - this._astID = astID++; - this._preComments = null; - this._postComments = null; - } - AST.prototype.syntaxID = function () { - return this._astID; - }; - - AST.prototype.start = function () { - return this._start; - }; - - AST.prototype.end = function () { - return this._end; - }; - - AST.prototype.trailingTriviaWidth = function () { - return this._trailingTriviaWidth; - }; - - AST.prototype.fileName = function () { - return this.parent.fileName(); - }; - - AST.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - AST.prototype.preComments = function () { - return this._preComments; - }; - - AST.prototype.postComments = function () { - return this._postComments; - }; - - AST.prototype.setPreComments = function (comments) { - if (comments && comments.length) { - this._preComments = comments; - } else if (this._preComments) { - this._preComments = null; - } - }; - - AST.prototype.setPostComments = function (comments) { - if (comments && comments.length) { - this._postComments = comments; - } else if (this._postComments) { - this._postComments = null; - } - }; - - AST.prototype.width = function () { - return this.end() - this.start(); - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); - }; - - AST.prototype.isExpression = function () { - return false; - }; - return AST; - })(); - TypeScript.AST = AST; - - var ISyntaxList2 = (function (_super) { - __extends(ISyntaxList2, _super); - function ISyntaxList2(_fileName, members) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISyntaxList2.prototype.childCount = function () { - return this.members.length; - }; - - ISyntaxList2.prototype.childAt = function (index) { - return this.members[index]; - }; - - ISyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISyntaxList2.prototype.kind = function () { - return 1 /* List */; - }; - - ISyntaxList2.prototype.firstOrDefault = function (func) { - return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.lastOrDefault = function (func) { - return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.any = function (func) { - return TypeScript.ArrayUtilities.any(this.members, func); - }; - - ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISyntaxList2; - })(AST); - TypeScript.ISyntaxList2 = ISyntaxList2; - - var ISeparatedSyntaxList2 = (function (_super) { - __extends(ISeparatedSyntaxList2, _super); - function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - this._separatorCount = _separatorCount; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { - return this.members.length; - }; - - ISeparatedSyntaxList2.prototype.separatorCount = function () { - return this._separatorCount; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { - return this.members[index]; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i) === ast) { - return i; - } - } - - return -1; - }; - - ISeparatedSyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISeparatedSyntaxList2.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISeparatedSyntaxList2; - })(AST); - TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; - - var SourceUnit = (function (_super) { - __extends(SourceUnit, _super); - function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { - _super.call(this); - this.moduleElements = moduleElements; - this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; - this._fileName = _fileName; - moduleElements && (moduleElements.parent = this); - } - SourceUnit.prototype.fileName = function () { - return this._fileName; - }; - - SourceUnit.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return SourceUnit; - })(AST); - TypeScript.SourceUnit = SourceUnit; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(_text) { - _super.call(this); - this._text = _text; - this._valueText = null; - } - Identifier.prototype.text = function () { - return this._text; - }; - Identifier.prototype.valueText = function () { - if (!this._valueText) { - var text = this._text; - if (text === "__proto__") { - this._valueText = "#__proto__"; - } else { - this._valueText = TypeScript.Syntax.massageEscapes(text); - } - } - - return this._valueText; - }; - - Identifier.prototype.kind = function () { - return 11 /* IdentifierName */; - }; - - 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; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - LiteralExpression.prototype.text = function () { - return this._text; - }; - - LiteralExpression.prototype.valueText = function () { - return this._valueText; - }; - - LiteralExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - ThisExpression.prototype.text = function () { - return this._text; - }; - - ThisExpression.prototype.valueText = function () { - return this._valueText; - }; - - ThisExpression.prototype.kind = function () { - return 35 /* ThisKeyword */; - }; - - 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; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - SuperExpression.prototype.text = function () { - return this._text; - }; - - SuperExpression.prototype.valueText = function () { - return this._valueText; - }; - - SuperExpression.prototype.kind = function () { - return 50 /* SuperKeyword */; - }; - - 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; - - var NumericLiteral = (function (_super) { - __extends(NumericLiteral, _super); - function NumericLiteral(_value, _text, _valueText) { - _super.call(this); - this._value = _value; - this._text = _text; - this._valueText = _valueText; - } - NumericLiteral.prototype.text = function () { - return this._text; - }; - NumericLiteral.prototype.valueText = function () { - return this._valueText; - }; - NumericLiteral.prototype.value = function () { - return this._value; - }; - - NumericLiteral.prototype.kind = function () { - return 13 /* NumericLiteral */; - }; - - 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; - - var RegularExpressionLiteral = (function (_super) { - __extends(RegularExpressionLiteral, _super); - function RegularExpressionLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - RegularExpressionLiteral.prototype.text = function () { - return this._text; - }; - - RegularExpressionLiteral.prototype.valueText = function () { - return this._valueText; - }; - - RegularExpressionLiteral.prototype.kind = function () { - return 12 /* RegularExpressionLiteral */; - }; - - RegularExpressionLiteral.prototype.isExpression = function () { - return true; - }; - return RegularExpressionLiteral; - })(AST); - TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; - } - StringLiteral.prototype.text = function () { - return this._text; - }; - StringLiteral.prototype.valueText = function () { - return this._valueText; - }; - - StringLiteral.prototype.kind = function () { - return 14 /* StringLiteral */; - }; - - 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; - - var TypeAnnotation = (function (_super) { - __extends(TypeAnnotation, _super); - function TypeAnnotation(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - TypeAnnotation.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - return TypeAnnotation; - })(AST); - TypeScript.TypeAnnotation = TypeAnnotation; - - var BuiltInType = (function (_super) { - __extends(BuiltInType, _super); - function BuiltInType(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - BuiltInType.prototype.text = function () { - return this._text; - }; - - BuiltInType.prototype.valueText = function () { - return this._valueText; - }; - - BuiltInType.prototype.kind = function () { - return this._nodeType; - }; - return BuiltInType; - })(AST); - TypeScript.BuiltInType = BuiltInType; - - var ExternalModuleReference = (function (_super) { - __extends(ExternalModuleReference, _super); - function ExternalModuleReference(stringLiteral) { - _super.call(this); - this.stringLiteral = stringLiteral; - stringLiteral && (stringLiteral.parent = this); - } - ExternalModuleReference.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - return ExternalModuleReference; - })(AST); - TypeScript.ExternalModuleReference = ExternalModuleReference; - - var ModuleNameModuleReference = (function (_super) { - __extends(ModuleNameModuleReference, _super); - function ModuleNameModuleReference(moduleName) { - _super.call(this); - this.moduleName = moduleName; - moduleName && (moduleName.parent = this); - } - ModuleNameModuleReference.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - return ModuleNameModuleReference; - })(AST); - TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(modifiers, identifier, moduleReference) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.moduleReference = moduleReference; - identifier && (identifier.parent = this); - moduleReference && (moduleReference.parent = this); - } - ImportDeclaration.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(identifier) { - _super.call(this); - this.identifier = identifier; - identifier && (identifier.parent = this); - } - ExportAssignment.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var TypeParameterList = (function (_super) { - __extends(TypeParameterList, _super); - function TypeParameterList(typeParameters) { - _super.call(this); - this.typeParameters = typeParameters; - typeParameters && (typeParameters.parent = this); - } - TypeParameterList.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - return TypeParameterList; - })(AST); - TypeScript.TypeParameterList = TypeParameterList; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - heritageClauses && (heritageClauses.parent = this); - classElements && (classElements.parent = this); - } - ClassDeclaration.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return ClassDeclaration; - })(AST); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - body && (body.parent = this); - heritageClauses && (heritageClauses.parent = this); - } - InterfaceDeclaration.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return InterfaceDeclaration; - })(AST); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var HeritageClause = (function (_super) { - __extends(HeritageClause, _super); - function HeritageClause(_nodeType, typeNames) { - _super.call(this); - this._nodeType = _nodeType; - this.typeNames = typeNames; - typeNames && (typeNames.parent = this); - } - HeritageClause.prototype.kind = function () { - return this._nodeType; - }; - - HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); - }; - return HeritageClause; - })(AST); - TypeScript.HeritageClause = HeritageClause; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { - _super.call(this); - this.modifiers = modifiers; - this.name = name; - this.stringLiteral = stringLiteral; - this.moduleElements = moduleElements; - this.endingToken = endingToken; - name && (name.parent = this); - stringLiteral && (stringLiteral.parent = this); - moduleElements && (moduleElements.parent = this); - } - ModuleDeclaration.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return ModuleDeclaration; - })(AST); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(modifiers, identifier, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionDeclaration.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(modifiers, declaration) { - _super.call(this); - this.modifiers = modifiers; - this.declaration = declaration; - declaration && (declaration.parent = this); - } - VariableStatement.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(AST); - TypeScript.VariableStatement = VariableStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this); - this.declarators = declarators; - declarators && (declarators.parent = this); - } - VariableDeclaration.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - VariableDeclarator.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - return VariableDeclarator; - })(AST); - TypeScript.VariableDeclarator = VariableDeclarator; - - var EqualsValueClause = (function (_super) { - __extends(EqualsValueClause, _super); - function EqualsValueClause(value) { - _super.call(this); - this.value = value; - value && (value.parent = this); - } - EqualsValueClause.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - return EqualsValueClause; - })(AST); - TypeScript.EqualsValueClause = EqualsValueClause; - - var PrefixUnaryExpression = (function (_super) { - __extends(PrefixUnaryExpression, _super); - function PrefixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PrefixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ArrayLiteralExpression = (function (_super) { - __extends(ArrayLiteralExpression, _super); - function ArrayLiteralExpression(expressions) { - _super.call(this); - this.expressions = expressions; - expressions && (expressions.parent = this); - } - ArrayLiteralExpression.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - 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; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.apply(this, arguments); - } - OmittedExpression.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - 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; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(openParenTrailingComments, expression) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.expression = expression; - expression && (expression.parent = this); - } - ParenthesizedExpression.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - 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; - - var SimpleArrowFunctionExpression = (function (_super) { - __extends(SimpleArrowFunctionExpression, _super); - function SimpleArrowFunctionExpression(identifier, block, expression) { - _super.call(this); - this.identifier = identifier; - this.block = block; - this.expression = expression; - identifier && (identifier.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - SimpleArrowFunctionExpression.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return SimpleArrowFunctionExpression; - })(AST); - TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; - - var ParenthesizedArrowFunctionExpression = (function (_super) { - __extends(ParenthesizedArrowFunctionExpression, _super); - function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - this.expression = expression; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - ParenthesizedArrowFunctionExpression.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return ParenthesizedArrowFunctionExpression; - })(AST); - TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; - - var QualifiedName = (function (_super) { - __extends(QualifiedName, _super); - function QualifiedName(left, right) { - _super.call(this); - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - QualifiedName.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedName.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); - }; - return QualifiedName; - })(AST); - TypeScript.QualifiedName = QualifiedName; - - var ParameterList = (function (_super) { - __extends(ParameterList, _super); - function ParameterList(openParenTrailingComments, parameters) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.parameters = parameters; - parameters && (parameters.parent = this); - } - ParameterList.prototype.kind = function () { - return 227 /* ParameterList */; - }; - return ParameterList; - })(AST); - TypeScript.ParameterList = ParameterList; - - var ConstructorType = (function (_super) { - __extends(ConstructorType, _super); - function ConstructorType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - ConstructorType.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - return ConstructorType; - })(AST); - TypeScript.ConstructorType = ConstructorType; - - var FunctionType = (function (_super) { - __extends(FunctionType, _super); - function FunctionType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - FunctionType.prototype.kind = function () { - return 123 /* FunctionType */; - }; - return FunctionType; - })(AST); - TypeScript.FunctionType = FunctionType; - - var ObjectType = (function (_super) { - __extends(ObjectType, _super); - function ObjectType(typeMembers) { - _super.call(this); - this.typeMembers = typeMembers; - typeMembers && (typeMembers.parent = this); - } - ObjectType.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); - }; - return ObjectType; - })(AST); - TypeScript.ObjectType = ObjectType; - - var ArrayType = (function (_super) { - __extends(ArrayType, _super); - function ArrayType(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - ArrayType.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); - }; - return ArrayType; - })(AST); - TypeScript.ArrayType = ArrayType; - - var TypeArgumentList = (function (_super) { - __extends(TypeArgumentList, _super); - function TypeArgumentList(typeArguments) { - _super.call(this); - this.typeArguments = typeArguments; - typeArguments && (typeArguments.parent = this); - } - TypeArgumentList.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - return TypeArgumentList; - })(AST); - TypeScript.TypeArgumentList = TypeArgumentList; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArgumentList) { - _super.call(this); - this.name = name; - this.typeArgumentList = typeArgumentList; - name && (name.parent = this); - typeArgumentList && (typeArgumentList.parent = this); - } - GenericType.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeQuery = (function (_super) { - __extends(TypeQuery, _super); - function TypeQuery(name) { - _super.call(this); - this.name = name; - name && (name.parent = this); - } - TypeQuery.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); - }; - return TypeQuery; - })(AST); - TypeScript.TypeQuery = TypeQuery; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements, closeBraceLeadingComments, closeBraceToken) { - _super.call(this); - this.statements = statements; - this.closeBraceLeadingComments = closeBraceLeadingComments; - this.closeBraceToken = closeBraceToken; - statements && (statements.parent = this); - } - Block.prototype.kind = function () { - return 146 /* Block */; - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(AST); - TypeScript.Block = Block; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - _super.call(this); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - Parameter.prototype.kind = function () { - return 242 /* Parameter */; - }; - return Parameter; - })(AST); - TypeScript.Parameter = Parameter; - - var MemberAccessExpression = (function (_super) { - __extends(MemberAccessExpression, _super); - function MemberAccessExpression(expression, name) { - _super.call(this); - this.expression = expression; - this.name = name; - expression && (expression.parent = this); - name && (name.parent = this); - } - MemberAccessExpression.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - 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; - - var PostfixUnaryExpression = (function (_super) { - __extends(PostfixUnaryExpression, _super); - function PostfixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PostfixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ElementAccessExpression = (function (_super) { - __extends(ElementAccessExpression, _super); - function ElementAccessExpression(expression, argumentExpression) { - _super.call(this); - this.expression = expression; - this.argumentExpression = argumentExpression; - expression && (expression.parent = this); - argumentExpression && (argumentExpression.parent = this); - } - ElementAccessExpression.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - 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; - - var InvocationExpression = (function (_super) { - __extends(InvocationExpression, _super); - function InvocationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - InvocationExpression.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - 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) { - _super.call(this); - this.typeArgumentList = typeArgumentList; - this.closeParenToken = closeParenToken; - this.arguments = _arguments; - - typeArgumentList && (typeArgumentList.parent = this); - _arguments && (_arguments.parent = this); - } - ArgumentList.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - return ArgumentList; - })(AST); - TypeScript.ArgumentList = ArgumentList; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(_nodeType, left, right) { - _super.call(this); - this._nodeType = _nodeType; - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - BinaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(condition, whenTrue, whenFalse) { - _super.call(this); - this.condition = condition; - this.whenTrue = whenTrue; - this.whenFalse = whenFalse; - condition && (condition.parent = this); - whenTrue && (whenTrue.parent = this); - whenFalse && (whenFalse.parent = this); - } - ConditionalExpression.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - 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; - - var ConstructSignature = (function (_super) { - __extends(ConstructSignature, _super); - function ConstructSignature(callSignature) { - _super.call(this); - this.callSignature = callSignature; - callSignature && (callSignature.parent = this); - } - ConstructSignature.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - return ConstructSignature; - })(AST); - TypeScript.ConstructSignature = ConstructSignature; - - var MethodSignature = (function (_super) { - __extends(MethodSignature, _super); - function MethodSignature(propertyName, questionToken, callSignature) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - } - MethodSignature.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - return MethodSignature; - })(AST); - TypeScript.MethodSignature = MethodSignature; - - var IndexSignature = (function (_super) { - __extends(IndexSignature, _super); - function IndexSignature(parameter, typeAnnotation) { - _super.call(this); - this.parameter = parameter; - this.typeAnnotation = typeAnnotation; - parameter && (parameter.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - IndexSignature.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - return IndexSignature; - })(AST); - TypeScript.IndexSignature = IndexSignature; - - var PropertySignature = (function (_super) { - __extends(PropertySignature, _super); - function PropertySignature(propertyName, questionToken, typeAnnotation) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - PropertySignature.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - return PropertySignature; - })(AST); - TypeScript.PropertySignature = PropertySignature; - - var CallSignature = (function (_super) { - __extends(CallSignature, _super); - function CallSignature(typeParameterList, parameterList, typeAnnotation) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - CallSignature.prototype.kind = function () { - return 142 /* CallSignature */; - }; - return CallSignature; - })(AST); - TypeScript.CallSignature = CallSignature; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(identifier, constraint) { - _super.call(this); - this.identifier = identifier; - this.constraint = constraint; - identifier && (identifier.parent = this); - constraint && (constraint.parent = this); - } - TypeParameter.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var Constraint = (function (_super) { - __extends(Constraint, _super); - function Constraint(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - Constraint.prototype.kind = function () { - return 239 /* Constraint */; - }; - return Constraint; - })(AST); - TypeScript.Constraint = Constraint; - - var ElseClause = (function (_super) { - __extends(ElseClause, _super); - function ElseClause(statement) { - _super.call(this); - this.statement = statement; - statement && (statement.parent = this); - } - ElseClause.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ElseClause; - })(AST); - TypeScript.ElseClause = ElseClause; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(condition, statement, elseClause) { - _super.call(this); - this.condition = condition; - this.statement = statement; - this.elseClause = elseClause; - condition && (condition.parent = this); - statement && (statement.parent = this); - elseClause && (elseClause.parent = this); - } - IfStatement.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); - }; - return IfStatement; - })(AST); - TypeScript.IfStatement = IfStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ExpressionStatement.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(AST); - TypeScript.ExpressionStatement = ExpressionStatement; - - var ConstructorDeclaration = (function (_super) { - __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(callSignature, block) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - ConstructorDeclaration.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - return ConstructorDeclaration; - })(AST); - TypeScript.ConstructorDeclaration = ConstructorDeclaration; - - var MemberFunctionDeclaration = (function (_super) { - __extends(MemberFunctionDeclaration, _super); - function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - MemberFunctionDeclaration.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - return MemberFunctionDeclaration; - })(AST); - TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; - - var GetAccessor = (function (_super) { - __extends(GetAccessor, _super); - function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - GetAccessor.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - return GetAccessor; - })(AST); - TypeScript.GetAccessor = GetAccessor; - - var SetAccessor = (function (_super) { - __extends(SetAccessor, _super); - function SetAccessor(modifiers, propertyName, parameterList, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - SetAccessor.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - return SetAccessor; - })(AST); - TypeScript.SetAccessor = SetAccessor; - - var MemberVariableDeclaration = (function (_super) { - __extends(MemberVariableDeclaration, _super); - function MemberVariableDeclaration(modifiers, variableDeclarator) { - _super.call(this); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - variableDeclarator && (variableDeclarator.parent = this); - } - MemberVariableDeclaration.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - return MemberVariableDeclaration; - })(AST); - TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; - - var IndexMemberDeclaration = (function (_super) { - __extends(IndexMemberDeclaration, _super); - function IndexMemberDeclaration(indexSignature) { - _super.call(this); - this.indexSignature = indexSignature; - indexSignature && (indexSignature.parent = this); - } - IndexMemberDeclaration.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - return IndexMemberDeclaration; - })(AST); - TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ThrowStatement.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(AST); - TypeScript.ThrowStatement = ThrowStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ReturnStatement.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ReturnStatement; - })(AST); - TypeScript.ReturnStatement = ReturnStatement; - - var ObjectCreationExpression = (function (_super) { - __extends(ObjectCreationExpression, _super); - function ObjectCreationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - ObjectCreationExpression.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - 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; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(expression, closeParenToken, switchClauses) { - _super.call(this); - this.expression = expression; - this.closeParenToken = closeParenToken; - this.switchClauses = switchClauses; - expression && (expression.parent = this); - switchClauses && (switchClauses.parent = this); - } - SwitchStatement.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return SwitchStatement; - })(AST); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseSwitchClause = (function (_super) { - __extends(CaseSwitchClause, _super); - function CaseSwitchClause(expression, statements) { - _super.call(this); - this.expression = expression; - this.statements = statements; - expression && (expression.parent = this); - statements && (statements.parent = this); - } - CaseSwitchClause.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return CaseSwitchClause; - })(AST); - TypeScript.CaseSwitchClause = CaseSwitchClause; - - var DefaultSwitchClause = (function (_super) { - __extends(DefaultSwitchClause, _super); - function DefaultSwitchClause(statements) { - _super.call(this); - this.statements = statements; - statements && (statements.parent = this); - } - DefaultSwitchClause.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return DefaultSwitchClause; - })(AST); - TypeScript.DefaultSwitchClause = DefaultSwitchClause; - - var BreakStatement = (function (_super) { - __extends(BreakStatement, _super); - function BreakStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - BreakStatement.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return BreakStatement; - })(AST); - TypeScript.BreakStatement = BreakStatement; - - var ContinueStatement = (function (_super) { - __extends(ContinueStatement, _super); - function ContinueStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - ContinueStatement.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ContinueStatement; - })(AST); - TypeScript.ContinueStatement = ContinueStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.condition = condition; - this.incrementor = incrementor; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - initializer && (initializer.parent = this); - condition && (condition.parent = this); - incrementor && (incrementor.parent = this); - statement && (statement.parent = this); - } - ForStatement.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForStatement; - })(AST); - TypeScript.ForStatement = ForStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(variableDeclaration, left, expression, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.left = left; - this.expression = expression; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - left && (left.parent = this); - expression && (expression.parent = this); - statement && (statement.parent = this); - } - ForInStatement.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForInStatement; - })(AST); - TypeScript.ForInStatement = ForInStatement; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WhileStatement.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WhileStatement; - })(AST); - TypeScript.WhileStatement = WhileStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WithStatement.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WithStatement; - })(AST); - TypeScript.WithStatement = WithStatement; - - var EnumDeclaration = (function (_super) { - __extends(EnumDeclaration, _super); - function EnumDeclaration(modifiers, identifier, enumElements) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.enumElements = enumElements; - identifier && (identifier.parent = this); - enumElements && (enumElements.parent = this); - } - EnumDeclaration.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - return EnumDeclaration; - })(AST); - TypeScript.EnumDeclaration = EnumDeclaration; - - var EnumElement = (function (_super) { - __extends(EnumElement, _super); - function EnumElement(propertyName, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - EnumElement.prototype.kind = function () { - return 243 /* EnumElement */; - }; - return EnumElement; - })(AST); - TypeScript.EnumElement = EnumElement; - - var CastExpression = (function (_super) { - __extends(CastExpression, _super); - function CastExpression(type, expression) { - _super.call(this); - this.type = type; - this.expression = expression; - type && (type.parent = this); - expression && (expression.parent = this); - } - CastExpression.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - 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; - - var ObjectLiteralExpression = (function (_super) { - __extends(ObjectLiteralExpression, _super); - function ObjectLiteralExpression(propertyAssignments) { - _super.call(this); - this.propertyAssignments = propertyAssignments; - propertyAssignments && (propertyAssignments.parent = this); - } - ObjectLiteralExpression.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - 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; - - var SimplePropertyAssignment = (function (_super) { - __extends(SimplePropertyAssignment, _super); - function SimplePropertyAssignment(propertyName, expression) { - _super.call(this); - this.propertyName = propertyName; - this.expression = expression; - propertyName && (propertyName.parent = this); - expression && (expression.parent = this); - } - SimplePropertyAssignment.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - return SimplePropertyAssignment; - })(AST); - TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; - - var FunctionPropertyAssignment = (function (_super) { - __extends(FunctionPropertyAssignment, _super); - function FunctionPropertyAssignment(propertyName, callSignature, block) { - _super.call(this); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionPropertyAssignment.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - return FunctionPropertyAssignment; - })(AST); - TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; - - var FunctionExpression = (function (_super) { - __extends(FunctionExpression, _super); - function FunctionExpression(identifier, callSignature, block) { - _super.call(this); - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionExpression.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpression.prototype.isExpression = function () { - return true; - }; - return FunctionExpression; - })(AST); - TypeScript.FunctionExpression = FunctionExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.apply(this, arguments); - } - EmptyStatement.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(AST); - TypeScript.EmptyStatement = EmptyStatement; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(block, catchClause, finallyClause) { - _super.call(this); - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - block && (block.parent = this); - catchClause && (catchClause.parent = this); - finallyClause && (finallyClause.parent = this); - } - TryStatement.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); - }; - return TryStatement; - })(AST); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(identifier, typeAnnotation, block) { - _super.call(this); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.block = block; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - CatchClause.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var FinallyClause = (function (_super) { - __extends(FinallyClause, _super); - function FinallyClause(block) { - _super.call(this); - this.block = block; - block && (block.parent = this); - } - FinallyClause.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return FinallyClause; - })(AST); - TypeScript.FinallyClause = FinallyClause; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this); - this.identifier = identifier; - this.statement = statement; - identifier && (identifier.parent = this); - statement && (statement.parent = this); - } - LabeledStatement.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(AST); - TypeScript.LabeledStatement = LabeledStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(statement, whileKeyword, condition) { - _super.call(this); - this.statement = statement; - this.whileKeyword = whileKeyword; - this.condition = condition; - statement && (statement.parent = this); - condition && (condition.parent = this); - } - DoStatement.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); - }; - return DoStatement; - })(AST); - TypeScript.DoStatement = DoStatement; - - var TypeOfExpression = (function (_super) { - __extends(TypeOfExpression, _super); - function TypeOfExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - TypeOfExpression.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - 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; - - var DeleteExpression = (function (_super) { - __extends(DeleteExpression, _super); - function DeleteExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - DeleteExpression.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - 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; - - var VoidExpression = (function (_super) { - __extends(VoidExpression, _super); - function VoidExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - VoidExpression.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - 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; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.apply(this, arguments); - } - DebuggerStatement.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - return DebuggerStatement; - })(AST); - TypeScript.DebuggerStatement = DebuggerStatement; - - var Comment = (function () { - function Comment(_trivia, endsLine, _start, _end) { - this._trivia = _trivia; - this.endsLine = endsLine; - this._start = _start; - this._end = _end; - } - Comment.prototype.start = function () { - return this._start; - }; - - Comment.prototype.end = function () { - return this._end; - }; - - Comment.prototype.fullText = function () { - return this._trivia.fullText(); - }; - - Comment.prototype.kind = function () { - return this._trivia.kind(); - }; - - Comment.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; - }; - return Comment; - })(); - TypeScript.Comment = Comment; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IOUtils) { - function createDirectoryStructure(ioHost, dirName) { - if (ioHost.directoryExists(dirName)) { - return; - } - - var parentDirectory = ioHost.dirName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(ioHost, parentDirectory); - } - ioHost.createDirectory(dirName); - } - - function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { - var start = new Date().getTime(); - var path = ioHost.resolvePath(fileName); - TypeScript.ioHostResolvePathTime += new Date().getTime() - start; - - var start = new Date().getTime(); - var dirName = ioHost.dirName(path); - TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start; - - var start = new Date().getTime(); - createDirectoryStructure(ioHost, dirName); - TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start; - - var start = new Date().getTime(); - ioHost.writeFile(path, contents, writeByteOrderMark); - TypeScript.ioHostWriteFileTime += new Date().getTime() - start; - } - IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; - - function throwIOError(message, error) { - var errorMessage = message; - if (error && error.message) { - errorMessage += (" " + error.message); - } - throw new Error(errorMessage); - } - IOUtils.throwIOError = throwIOError; - - function combine(prefix, suffix) { - return prefix + "/" + suffix; - } - IOUtils.combine = combine; - - var BufferedTextWriter = (function () { - function BufferedTextWriter(writer, capacity) { - if (typeof capacity === "undefined") { capacity = 1024; } - this.writer = writer; - this.capacity = capacity; - this.buffer = ""; - } - BufferedTextWriter.prototype.Write = function (str) { - this.buffer += str; - if (this.buffer.length >= this.capacity) { - this.writer.Write(this.buffer); - this.buffer = ""; - } - }; - BufferedTextWriter.prototype.WriteLine = function (str) { - this.Write(str + '\r\n'); - }; - BufferedTextWriter.prototype.Close = function () { - this.writer.Write(this.buffer); - this.writer.Close(); - this.buffer = null; - }; - return BufferedTextWriter; - })(); - IOUtils.BufferedTextWriter = BufferedTextWriter; - })(TypeScript.IOUtils || (TypeScript.IOUtils = {})); - var IOUtils = TypeScript.IOUtils; - - TypeScript.IO = (function () { - function getWindowsScriptHostIO() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - 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); - }, - writeFile: function (path, contents, writeByteOrderMark) { - TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - dirName: function (path) { - return fso.GetParentFolderName(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; - - while (true) { - if (fso.FileExists(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); - - if (rootPath == "") { - return null; - } else { - path = fso.BuildPath(rootPath, partialFilePath); - } - } - } - }, - deleteFile: function (path) { - try { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - fso.CreateFolder(path); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); - } - }, - dir: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "/" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - print: function (str) { - WScript.StdOut.Write(str); - }, - printLine: function (str) { - WScript.Echo(str); - }, - arguments: args, - stderr: WScript.StdErr, - stdout: WScript.StdOut, - watchFile: null, - run: function (source, fileName) { - try { - eval(source); - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Error_while_executing_file_0, [fileName]), e); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - quit: function (exitCode) { - if (typeof exitCode === "undefined") { exitCode = 0; } - try { - WScript.Quit(exitCode); - } catch (e) { - } - } - }; - } - ; - - function getNodeIO() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - appendFile: function (path, content) { - _fs.appendFileSync(path, content); - }, - readFile: function (file, codepage) { - return TypeScript.Environment.readFile(file, codepage); - }, - writeFile: function (path, contents, writeByteOrderMark) { - TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); - } - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - dir: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - try { - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "/" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "/" + files[i]); - } - } - } catch (err) { - } - - return paths; - } - - return filesInFolder(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - _fs.mkdirSync(path); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - dirName: function (path) { - var dirPath = _path.dirname(path); - - if (dirPath === path) { - dirPath = null; - } - - return dirPath; - }, - findFile: function (rootPath, partialFilePath) { - var path = rootPath + "/" + partialFilePath; - - while (true) { - if (_fs.existsSync(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - var parentPath = _path.resolve(rootPath, ".."); - - if (rootPath === parentPath) { - return null; - } else { - rootPath = parentPath; - path = _path.resolve(rootPath, partialFilePath); - } - } - } - }, - print: function (str) { - process.stdout.write(str); - }, - printLine: function (str) { - process.stdout.write(str + '\n'); - }, - arguments: process.argv.slice(2), - stderr: { - Write: function (str) { - process.stderr.write(str); - }, - WriteLine: function (str) { - process.stderr.write(str + '\n'); - }, - Close: function () { - } - }, - stdout: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - }, - watchFile: function (fileName, callback) { - var firstRun = true; - var processingChange = false; - - var fileChanged = function (curr, prev) { - if (!firstRun) { - if (curr.mtime < prev.mtime) { - return; - } - - _fs.unwatchFile(fileName, fileChanged); - if (!processingChange) { - processingChange = true; - callback(fileName); - setTimeout(function () { - processingChange = false; - }, 100); - } - } - firstRun = false; - _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); - }; - - fileChanged(); - return { - fileName: fileName, - close: function () { - _fs.unwatchFile(fileName, fileChanged); - } - }; - }, - run: function (source, fileName) { - require.main.fileName = fileName; - require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); - require.main._compile(source, fileName); - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - quit: function (code) { - var stderrFlushed = process.stderr.write(''); - var stdoutFlushed = process.stdout.write(''); - process.stderr.on('drain', function () { - stderrFlushed = true; - if (stdoutFlushed) { - process.exit(code); - } - }); - process.stdout.on('drain', function () { - stdoutFlushed = true; - if (stderrFlushed) { - process.exit(code); - } - }); - setTimeout(function () { - process.exit(code); - }, 5); - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") - return getWindowsScriptHostIO(); - else if (typeof module !== 'undefined' && module.exports) - return getNodeIO(); - else - return null; - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OptionsParser = (function () { - function OptionsParser(host, version) { - this.host = host; - this.version = version; - this.DEFAULT_SHORT_FLAG = "-"; - this.DEFAULT_LONG_FLAG = "--"; - this.printedVersion = false; - this.unnamed = []; - this.options = []; - } - OptionsParser.prototype.findOption = function (arg) { - var upperCaseArg = arg && arg.toUpperCase(); - - for (var i = 0; i < this.options.length; i++) { - var current = this.options[i]; - - if (upperCaseArg === (current.short && current.short.toUpperCase()) || upperCaseArg === (current.name && current.name.toUpperCase())) { - return current; - } - } - - return null; - }; - - OptionsParser.prototype.printUsage = function () { - this.printVersion(); - - var optionsWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.options, null); - var fileWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.file1, null); - var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]"; - var syntaxHelp = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Syntax_0, [tscSyntax]); - this.host.printLine(syntaxHelp); - this.host.printLine(""); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Examples, null) + " tsc hello.ts"); - this.host.printLine(" tsc --out foo.js foo.ts"); - this.host.printLine(" tsc @args.txt"); - this.host.printLine(""); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Options, null)); - - var output = []; - var maxLength = 0; - var i = 0; - - this.options = this.options.sort(function (a, b) { - var aName = a.name.toLowerCase(); - var bName = b.name.toLowerCase(); - - if (aName > bName) { - return 1; - } else if (aName < bName) { - return -1; - } else { - return 0; - } - }); - - for (i = 0; i < this.options.length; i++) { - var option = this.options[i]; - - if (option.experimental) { - continue; - } - - if (!option.usage) { - break; - } - - var usageString = " "; - var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : ""; - - if (option.short) { - usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; - } - - usageString += this.DEFAULT_LONG_FLAG + option.name + type; - - output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]); - - if (usageString.length > maxLength) { - maxLength = usageString.length; - } - } - - var fileDescription = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null); - output.push([" @<" + fileWord + ">", fileDescription]); - - for (i = 0; i < output.length; i++) { - this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); - } - }; - - OptionsParser.prototype.printVersion = function () { - if (!this.printedVersion) { - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Version_0, [this.version])); - this.printedVersion = true; - } - }; - - OptionsParser.prototype.option = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = false; - - this.options.push(config); - }; - - OptionsParser.prototype.flag = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = true; - - this.options.push(config); - }; - - OptionsParser.prototype.parseString = function (argString) { - var position = 0; - var tokens = argString.match(/\s+|"|[^\s"]+/g); - - function peek() { - return tokens[position]; - } - - function consume() { - return tokens[position++]; - } - - function consumeQuotedString() { - var value = ''; - consume(); - - var token = peek(); - - while (token && token !== '"') { - consume(); - - value += token; - - token = peek(); - } - - consume(); - - return value; - } - - var args = []; - var currentArg = ''; - - while (position < tokens.length) { - var token = peek(); - - if (token === '"') { - currentArg += consumeQuotedString(); - } else if (token.match(/\s/)) { - if (currentArg.length > 0) { - args.push(currentArg); - currentArg = ''; - } - - consume(); - } else { - consume(); - currentArg += token; - } - } - - if (currentArg.length > 0) { - args.push(currentArg); - } - - this.parse(args); - }; - - OptionsParser.prototype.parse = function (args) { - var position = 0; - - function consume() { - return args[position++]; - } - - while (position < args.length) { - var current = consume(); - var match = current.match(/^(--?|@)(.*)/); - var value = null; - - if (match) { - if (match[1] === '@') { - this.parseString(this.host.readFile(match[2], null).contents); - } else { - var arg = match[2]; - var option = this.findOption(arg); - - if (option === null) { - this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_option_0, [arg])); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); - } else { - if (!option.flag) { - value = consume(); - if (value === undefined) { - this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Option_0_specified_without_1, [arg, TypeScript.getLocalizedText(option.type, null)])); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); - continue; - } - } - - option.set(value); - } - } - } else { - this.unnamed.push(current); - } - } - }; - return OptionsParser; - })(); - TypeScript.OptionsParser = OptionsParser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceFile = (function () { - function SourceFile(scriptSnapshot, byteOrderMark) { - this.scriptSnapshot = scriptSnapshot; - this.byteOrderMark = byteOrderMark; - } - return SourceFile; - })(); - - var DiagnosticsLogger = (function () { - function DiagnosticsLogger(ioHost) { - this.ioHost = ioHost; - } - DiagnosticsLogger.prototype.information = function () { - return false; - }; - DiagnosticsLogger.prototype.debug = function () { - return false; - }; - DiagnosticsLogger.prototype.warning = function () { - return false; - }; - DiagnosticsLogger.prototype.error = function () { - return false; - }; - DiagnosticsLogger.prototype.fatal = function () { - return false; - }; - DiagnosticsLogger.prototype.log = function (s) { - this.ioHost.stdout.WriteLine(s); - }; - 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.7.0"; - this.inputFiles = []; - this.resolvedFiles = []; - this.fileNameToSourceFile = new TypeScript.StringHashTable(); - this.hasErrors = false; - this.logger = null; - this.fileExistsCache = TypeScript.createIntrinsicsObject(); - this.resolvePathCache = TypeScript.createIntrinsicsObject(); - } - BatchCompiler.prototype.batchCompile = function () { - var _this = this; - var start = new Date().getTime(); - - TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { - _this.ioHost.printLine(s); - } }; - - if (this.parseOptions()) { - 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(); - return; - } - - this.resolve(); - - 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); - this.logger.log(" file read: " + TypeScript.fileResolutionIOTime); - this.logger.log(" scan imports: " + TypeScript.fileResolutionScanImportsTime); - this.logger.log(" import search: " + TypeScript.fileResolutionImportFileSearchTime); - this.logger.log(" get lib.d.ts: " + TypeScript.fileResolutionGetDefaultLibraryTime); - - this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime); - this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime); - this.logger.log("AST translation time: " + TypeScript.astTranslationTime); - this.logger.log(""); - this.logger.log("Type check time: " + TypeScript.typeCheckTime); - this.logger.log(""); - this.logger.log("Emit time: " + TypeScript.emitTime); - this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime); - - this.logger.log("Total number of symbols created: " + TypeScript.pullSymbolID); - this.logger.log("Specialized types created: " + TypeScript.nSpecializationsCreated); - this.logger.log("Specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); - - this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime); - this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime); - this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime); - this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime); - this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime); - this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime); - this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime); - this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime); - this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime); - - this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime); - - this.logger.log("Compiler resolve path time: " + TypeScript.compilerResolvePathTime); - this.logger.log("Compiler directory name time: " + TypeScript.compilerDirectoryNameTime); - this.logger.log("Compiler directory exists time: " + TypeScript.compilerDirectoryExistsTime); - this.logger.log("Compiler file exists time: " + TypeScript.compilerFileExistsTime); - - this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime); - this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime); - this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime); - this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime); - - this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime); - this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime); - this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime); - } - } - - this.ioHost.quit(this.hasErrors ? 1 : 0); - }; - - BatchCompiler.prototype.resolve = function () { - var _this = this; - var includeDefaultLibrary = !this.compilationSettings.noLib(); - var resolvedFiles = []; - - var start = new Date().getTime(); - - if (!this.compilationSettings.noResolve()) { - var resolutionResults = TypeScript.ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings.useCaseSensitiveFileResolution()); - resolvedFiles = resolutionResults.resolvedFiles; - - includeDefaultLibrary = !this.compilationSettings.noLib() && !resolutionResults.seenNoDefaultLibTag; - - resolutionResults.diagnostics.forEach(function (d) { - return _this.addDiagnostic(d); - }); - } else { - for (var i = 0, n = this.inputFiles.length; i < n; i++) { - var inputFile = this.inputFiles[i]; - var referencedFiles = []; - var importedFiles = []; - - if (this.compilationSettings.generateDeclarationFiles()) { - var references = TypeScript.getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile)); - for (var j = 0; j < references.length; j++) { - referencedFiles.push(references[j].path); - } - - inputFile = this.resolvePath(inputFile); - } - - resolvedFiles.push({ - path: inputFile, - referencedFiles: referencedFiles, - importedFiles: importedFiles - }); - } - } - - var defaultLibStart = new Date().getTime(); - if (includeDefaultLibrary) { - var libraryResolvedFile = { - path: this.getDefaultLibraryFilePath(), - referencedFiles: [], - importedFiles: [] - }; - - resolvedFiles = [libraryResolvedFile].concat(resolvedFiles); - } - TypeScript.fileResolutionGetDefaultLibraryTime += new Date().getTime() - defaultLibStart; - - this.resolvedFiles = resolvedFiles; - - TypeScript.fileResolutionTime = new Date().getTime() - start; - }; - - BatchCompiler.prototype.compile = function () { - var _this = this; - var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); - - this.resolvedFiles.forEach(function (resolvedFile) { - var sourceFile = _this.getSourceFile(resolvedFile.path); - compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, false, resolvedFile.referencedFiles); - }); - - for (var it = compiler.compile(function (path) { - return _this.resolvePath(path); - }); it.moveNext();) { - var result = it.current(); - - result.diagnostics.forEach(function (d) { - return _this.addDiagnostic(d); - }); - if (!this.tryWriteOutputFiles(result.outputFiles)) { - return; - } - } - }; - - BatchCompiler.prototype.parseOptions = function () { - var _this = this; - var opts = new TypeScript.OptionsParser(this.ioHost, this.compilerVersion); - - var mutableSettings = new TypeScript.CompilationSettings(); - opts.option('out', { - usage: { - locCode: TypeScript.DiagnosticCode.Concatenate_and_emit_output_to_single_file, - args: null - }, - type: TypeScript.DiagnosticCode.file2, - set: function (str) { - mutableSettings.outFileOption = str; - } - }); - - opts.option('outDir', { - usage: { - locCode: TypeScript.DiagnosticCode.Redirect_output_structure_to_the_directory, - args: null - }, - type: TypeScript.DiagnosticCode.DIRECTORY, - set: function (str) { - mutableSettings.outDirOption = str; - } - }); - - opts.flag('sourcemap', { - usage: { - locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, - args: ['.map'] - }, - set: function () { - mutableSettings.mapSourceFiles = true; - } - }); - - opts.option('mapRoot', { - usage: { - locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - args: null - }, - type: TypeScript.DiagnosticCode.LOCATION, - set: function (str) { - mutableSettings.mapRoot = str; - } - }); - - opts.option('sourceRoot', { - usage: { - locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - args: null - }, - type: TypeScript.DiagnosticCode.LOCATION, - set: function (str) { - mutableSettings.sourceRoot = str; - } - }); - - opts.flag('declaration', { - usage: { - locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, - args: ['.d.ts'] - }, - set: function () { - mutableSettings.generateDeclarationFiles = true; - } - }, 'd'); - - if (this.ioHost.watchFile) { - opts.flag('watch', { - usage: { - locCode: TypeScript.DiagnosticCode.Watch_input_files, - args: null - }, - set: function () { - mutableSettings.watch = true; - } - }, 'w'); - } - - opts.flag('propagateEnumConstants', { - experimental: true, - set: function () { - mutableSettings.propagateEnumConstants = true; - } - }); - - opts.flag('removeComments', { - usage: { - locCode: TypeScript.DiagnosticCode.Do_not_emit_comments_to_output, - args: null - }, - set: function () { - mutableSettings.removeComments = true; - } - }); - - opts.flag('noResolve', { - experimental: true, - usage: { - locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, - args: null - }, - set: function () { - mutableSettings.noResolve = true; - } - }); - - opts.flag('noLib', { - experimental: true, - set: function () { - mutableSettings.noLib = true; - } - }); - - opts.flag('diagnostics', { - experimental: true, - set: function () { - mutableSettings.gatherDiagnostics = true; - } - }); - - 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, - args: ['ES3', 'ES5'] - }, - type: TypeScript.DiagnosticCode.VERSION, - set: function (type) { - type = type.toLowerCase(); - - if (type === 'es3') { - mutableSettings.codeGenTarget = 0 /* EcmaScript3 */; - } else if (type === 'es5') { - mutableSettings.codeGenTarget = 1 /* EcmaScript5 */; - } else { - _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2, [type, "ES3", "ES5"])); - } - } - }, 't'); - - opts.option('module', { - usage: { - locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1, - args: ['commonjs', 'amd'] - }, - type: TypeScript.DiagnosticCode.KIND, - set: function (type) { - type = type.toLowerCase(); - - if (type === 'commonjs') { - mutableSettings.moduleGenTarget = 1 /* Synchronous */; - } else if (type === 'amd') { - mutableSettings.moduleGenTarget = 2 /* Asynchronous */; - } else { - _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type])); - } - } - }, 'm'); - - var needsHelp = false; - opts.flag('help', { - usage: { - locCode: TypeScript.DiagnosticCode.Print_this_message, - args: null - }, - set: function () { - needsHelp = true; - } - }, 'h'); - - opts.flag('useCaseSensitiveFileResolution', { - experimental: true, - set: function () { - mutableSettings.useCaseSensitiveFileResolution = true; - } - }); - var shouldPrintVersionOnly = false; - opts.flag('version', { - usage: { - locCode: TypeScript.DiagnosticCode.Print_the_compiler_s_version_0, - args: [this.compilerVersion] - }, - set: function () { - shouldPrintVersionOnly = true; - } - }, 'v'); - - var locale = null; - opts.option('locale', { - experimental: true, - usage: { - locCode: TypeScript.DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1, - args: ['en', 'ja-jp'] - }, - type: TypeScript.DiagnosticCode.STRING, - set: function (value) { - locale = value; - } - }); - - opts.flag('noImplicitAny', { - usage: { - locCode: TypeScript.DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, - args: null - }, - set: function () { - mutableSettings.noImplicitAny = true; - } - }); - - if (TypeScript.Environment.supportsCodePage()) { - opts.option('codepage', { - usage: { - locCode: TypeScript.DiagnosticCode.Specify_the_codepage_to_use_when_opening_source_files, - args: null - }, - type: TypeScript.DiagnosticCode.NUMBER, - set: function (arg) { - mutableSettings.codepage = parseInt(arg, 10); - } - }); - } - - opts.parse(this.ioHost.arguments); - - this.compilationSettings = TypeScript.ImmutableCompilationSettings.fromCompilationSettings(mutableSettings); - - if (locale) { - if (!this.setLocale(locale)) { - return false; - } - } - - this.inputFiles.push.apply(this.inputFiles, opts.unnamed); - - if (shouldPrintVersionOnly) { - opts.printVersion(); - return false; - } else if (this.inputFiles.length === 0 || needsHelp) { - opts.printUsage(); - return false; - } - - return !this.hasErrors; - }; - - BatchCompiler.prototype.setLocale = function (locale) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); - if (!matchResult) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp'])); - return false; - } - - var language = matchResult[1]; - var territory = matchResult[3]; - - if (!this.setLanguageAndTerritory(language, territory) && !this.setLanguageAndTerritory(language, null)) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Unsupported_locale_0, [locale])); - return false; - } - - return true; - }; - - BatchCompiler.prototype.setLanguageAndTerritory = function (language, territory) { - var compilerFilePath = this.ioHost.getExecutingFilePath(); - var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); - - var filePath = TypeScript.IOUtils.combine(containingDirectoryPath, language); - if (territory) { - filePath = filePath + "-" + territory; - } - - filePath = this.resolvePath(TypeScript.IOUtils.combine(filePath, "diagnosticMessages.generated.json")); - - if (!this.fileExists(filePath)) { - return false; - } - - var fileContents = this.ioHost.readFile(filePath, this.compilationSettings.codepage()); - TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents); - return true; - }; - - BatchCompiler.prototype.watchFiles = function () { - var _this = this; - if (!this.ioHost.watchFile) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]'])); - return; - } - - var lastResolvedFileSet = []; - var watchers = {}; - var firstTime = true; - - var addWatcher = function (fileName) { - if (!watchers[fileName]) { - var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); - watchers[fileName] = watcher; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); - } - }; - - var removeWatcher = function (fileName) { - if (watchers[fileName]) { - watchers[fileName].close(); - delete watchers[fileName]; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); - } - }; - - var onWatchedFileChange = function () { - _this.hasErrors = false; - - _this.fileNameToSourceFile = new TypeScript.StringHashTable(); - - _this.resolve(); - - var oldFiles = lastResolvedFileSet; - var newFiles = _this.resolvedFiles.map(function (resolvedFile) { - return resolvedFile.path; - }).sort(); - - var i = 0, j = 0; - while (i < oldFiles.length && j < newFiles.length) { - var compareResult = oldFiles[i].localeCompare(newFiles[j]); - if (compareResult === 0) { - i++; - j++; - } else if (compareResult < 0) { - removeWatcher(oldFiles[i]); - i++; - } else { - addWatcher(newFiles[j]); - j++; - } - } - - for (var k = i; k < oldFiles.length; k++) { - removeWatcher(oldFiles[k]); - } - - for (k = j; k < newFiles.length; k++) { - addWatcher(newFiles[k]); - } - - lastResolvedFileSet = newFiles; - - if (!firstTime) { - var fileNames = ""; - for (var k = 0; k < lastResolvedFileSet.length; k++) { - fileNames += TypeScript.Environment.newLine + " " + lastResolvedFileSet[k]; - } - _this.ioHost.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.NL_Recompiling_0, [fileNames])); - } else { - firstTime = false; - } - - _this.compile(); - }; - - this.ioHost.stderr = this.ioHost.stdout; - - onWatchedFileChange(); - }; - - BatchCompiler.prototype.getSourceFile = function (fileName) { - var sourceFile = this.fileNameToSourceFile.lookup(fileName); - if (!sourceFile) { - var fileInformation; - - try { - fileInformation = this.ioHost.readFile(fileName, this.compilationSettings.codepage()); - } catch (e) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message])); - fileInformation = new TypeScript.FileInformation("", 0 /* None */); - } - - var snapshot = TypeScript.ScriptSnapshot.fromString(fileInformation.contents); - var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark); - this.fileNameToSourceFile.add(fileName, sourceFile); - } - - return sourceFile; - }; - - BatchCompiler.prototype.getDefaultLibraryFilePath = function () { - var compilerFilePath = this.ioHost.getExecutingFilePath(); - var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); - var libraryFilePath = this.resolvePath(TypeScript.IOUtils.combine(containingDirectoryPath, "lib.d.ts")); - - return libraryFilePath; - }; - - BatchCompiler.prototype.getScriptSnapshot = function (fileName) { - return this.getSourceFile(fileName).scriptSnapshot; - }; - - BatchCompiler.prototype.resolveRelativePath = function (path, directory) { - var start = new Date().getTime(); - - var unQuotedPath = TypeScript.stripStartAndEndQuotes(path); - var normalizedPath; - - if (TypeScript.isRooted(unQuotedPath) || !directory) { - normalizedPath = unQuotedPath; - } else { - normalizedPath = TypeScript.IOUtils.combine(directory, unQuotedPath); - } - - normalizedPath = this.resolvePath(normalizedPath); - - normalizedPath = TypeScript.switchToForwardSlashes(normalizedPath); - - return normalizedPath; - }; - - BatchCompiler.prototype.fileExists = function (path) { - var exists = this.fileExistsCache[path]; - if (exists === undefined) { - var start = new Date().getTime(); - exists = this.ioHost.fileExists(path); - this.fileExistsCache[path] = exists; - TypeScript.compilerFileExistsTime += new Date().getTime() - start; - } - - return exists; - }; - - BatchCompiler.prototype.getParentDirectory = function (path) { - var start = new Date().getTime(); - var result = this.ioHost.dirName(path); - TypeScript.compilerDirectoryNameTime += new Date().getTime() - start; - - return result; - }; - - BatchCompiler.prototype.addDiagnostic = function (diagnostic) { - var diagnosticInfo = diagnostic.info(); - if (diagnosticInfo.category === 1 /* Error */) { - this.hasErrors = true; - } - - this.ioHost.stderr.Write(TypeScript.TypeScriptCompiler.getFullDiagnosticText(diagnostic)); - }; - - BatchCompiler.prototype.tryWriteOutputFiles = function (outputFiles) { - for (var i = 0, n = outputFiles.length; i < n; i++) { - var outputFile = outputFiles[i]; - - try { - this.writeFile(outputFile.name, outputFile.text, outputFile.writeByteOrderMark); - } catch (e) { - this.addDiagnostic(new TypeScript.Diagnostic(outputFile.name, null, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])); - return false; - } - } - - return true; - }; - - BatchCompiler.prototype.writeFile = function (fileName, contents, writeByteOrderMark) { - var start = new Date().getTime(); - TypeScript.IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark); - TypeScript.emitWriteFileTime += new Date().getTime() - start; - }; - - BatchCompiler.prototype.directoryExists = function (path) { - var start = new Date().getTime(); - var result = this.ioHost.directoryExists(path); - TypeScript.compilerDirectoryExistsTime += new Date().getTime() - start; - return result; - }; - - BatchCompiler.prototype.resolvePath = function (path) { - var cachedValue = this.resolvePathCache[path]; - if (!cachedValue) { - var start = new Date().getTime(); - cachedValue = this.ioHost.resolvePath(path); - this.resolvePathCache[path] = cachedValue; - TypeScript.compilerResolvePathTime += new Date().getTime() - start; - } - - return cachedValue; - }; - return BatchCompiler; - })(); - TypeScript.BatchCompiler = BatchCompiler; - - var batch = new TypeScript.BatchCompiler(TypeScript.IO); - batch.batchCompile(); -})(TypeScript || (TypeScript = {})); diff --git a/_infrastructure/tests/typescript/0.9.7-59a846/typescript.js b/_infrastructure/tests/typescript/0.9.7-59a846/typescript.js deleted file mode 100644 index 0a4100df0e..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-59a846/typescript.js +++ /dev/null @@ -1,61371 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - TypeScript.DiagnosticCode = { - error_TS_0_1: "error TS{0}: {1}", - warning_TS_0_1: "warning TS{0}: {1}", - Unrecognized_escape_sequence: "Unrecognized escape sequence.", - Unexpected_character_0: "Unexpected character {0}.", - Missing_close_quote_character: "Missing close quote character.", - Identifier_expected: "Identifier expected.", - _0_keyword_expected: "'{0}' keyword expected.", - _0_expected: "'{0}' expected.", - Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", - Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", - Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", - Trailing_separator_not_allowed: "Trailing separator not allowed.", - AsteriskSlash_expected: "'*/' expected.", - public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", - Unexpected_token: "Unexpected token.", - Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", - Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", - Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", - Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", - Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", - Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", - Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", - Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", - Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", - Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", - Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", - extends_clause_already_seen: "'extends' clause already seen.", - extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", - Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", - implements_clause_already_seen: "'implements' clause already seen.", - Accessibility_modifier_already_seen: "Accessibility modifier already seen.", - _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", - _0_modifier_already_seen: "'{0}' modifier already seen.", - _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", - Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", - super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", - Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", - Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", - 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_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}'.", - _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", - declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", - declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", - Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", - Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", - set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", - set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", - set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", - set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", - get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", - Modifiers_cannot_appear_here: "Modifiers cannot appear here.", - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", - Class_name_cannot_be_0: "Class name cannot be '{0}'.", - Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", - Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", - Module_name_cannot_be_0: "Module name cannot be '{0}'.", - Enum_member_must_have_initializer: "Enum member must have initializer.", - Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", - Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", - Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", - Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", - module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", - constructor_function_accessor_or_variable: "constructor, function, accessor or variable", - statement: "statement", - case_or_default_clause: "case or default clause", - identifier: "identifier", - call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", - expression: "expression", - type_name: "type name", - property_or_accessor: "property or accessor", - parameter: "parameter", - type: "type", - type_parameter: "type parameter", - 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_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.", - super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", - Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", - Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", - Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", - Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", - Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", - Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", - Getter_0_already_declared: "Getter '{0}' already declared.", - Setter_0_already_declared: "Setter '{0}' already declared.", - Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", - Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", - Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", - Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", - Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", - Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", - Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", - Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", - Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", - Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", - Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", - Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", - Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", - Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", - Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", - Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", - Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", - Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", - Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", - Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", - Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", - Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", - A_class_may_only_extend_another_class: "A class may only extend another class.", - A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", - An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", - Unable_to_resolve_type: "Unable to resolve type.", - Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", - Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", - Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", - Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", - Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", - Invalid_new_expression: "Invalid 'new' expression.", - Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", - Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", - Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", - Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", - Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", - Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", - The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", - 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_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.", - _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.", - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", - Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", - 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_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}'.", - 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.", - Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", - Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", - Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", - All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", - Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", - this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", - Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", - Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", - Duplicate_overload_call_signature: "Duplicate overload call signature.", - Duplicate_overload_construct_signature: "Duplicate overload construct signature.", - Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", - Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", - Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", - 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_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.", - Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", - A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", - Rest_parameters_must_be_array_types: "Rest parameters must be array types.", - Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", - 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_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_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.", - Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", - Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", - Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", - 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_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}", - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", - Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", - All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", - super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", - Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", - Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", - Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", - Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", - Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", - continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", - break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", - Jump_target_not_found: "Jump target not found.", - Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", - TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", - TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", - TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", - TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", - TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", - TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", - 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}", - Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", - Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", - Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", - Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", - Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", - Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - 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.", - 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_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_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.", - Could_not_find_file_0: "Could not find file: '{0}'.", - A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", - Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", - Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", - Emit_Error_0: "Emit Error: {0}.", - Cannot_read_file_0_1: "Cannot read file '{0}': {1}", - Unsupported_file_encoding: "Unsupported file encoding.", - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", - Unsupported_locale_0: "Unsupported locale: '{0}'.", - Execution_Failed_NL: "Execution Failed.{NL}", - Invalid_call_to_up: "Invalid call to 'up'", - Invalid_call_to_down: "Invalid call to 'down'", - Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", - Unknown_option_0: "Unknown option '{0}'", - Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", - Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", - Could_not_delete_file_0: "Could not delete file '{0}'", - Could_not_create_directory_0: "Could not create directory '{0}'", - Error_while_executing_file_0: "Error while executing file '{0}': ", - Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", - Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", - Option_0_specified_without_1: "Option '{0}' specified without '{1}'", - codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", - Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", - Generates_corresponding_0_file: "Generates corresponding {0} file.", - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", - Watch_input_files: "Watch input files.", - Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", - Do_not_emit_comments_to_output: "Do not emit comments to output.", - Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", - Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", - Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", - Print_this_message: "Print this message.", - Print_the_compiler_s_version_0: "Print the compiler's version: {0}", - Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", - Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", - Syntax_0: "Syntax: {0}", - options: "options", - file1: "file", - Examples: "Examples:", - Options: "Options:", - Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", - Version_0: "Version {0}", - Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", - NL_Recompiling_0: "{NL}Recompiling ({0}):", - STRING: "STRING", - KIND: "KIND", - file2: "FILE", - VERSION: "VERSION", - LOCATION: "LOCATION", - 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})", - Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", - Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", - Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", - Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", - Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", - new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", - _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", - Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", - 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.", - 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; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - return false; - } - - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0, n = array1.length; i < n; i++) { - if (!equals(array1[i], array2[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.distinct = function (array, equalsFn) { - var result = []; - - for (var i = 0, n = array.length; i < n; i++) { - var current = array[i]; - for (var j = 0; j < result.length; j++) { - if (equalsFn(result[j], current)) { - break; - } - } - - if (j === result.length) { - result.push(current); - } - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.lastOrDefault = function (array, predicate) { - for (var i = array.length - 1; i >= 0; i--) { - var v = array[i]; - if (predicate(v, i)) { - return v; - } - } - - return null; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value, i)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.first = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (!func || func(value, i)) { - return value; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = new Array(values.length); - - for (var i = 0; i < values.length; i++) { - result[i] = func(values[i]); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = new Array(); - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - var low = 0; - var high = array.length - 1; - - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - - if (midValue === value) { - return middle; - } else if (midValue > value) { - high = middle - 1; - } else { - low = middle + 1; - } - } - - return ~low; - }; - - ArrayUtilities.createArray = function (length, defaultValue) { - var result = new Array(length); - for (var i = 0; i < length; i++) { - result[i] = defaultValue; - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - - ArrayUtilities.indexOf = function (array, predicate) { - for (var i = 0, n = array.length; i < n; i++) { - if (predicate(array[i])) { - return i; - } - } - - return -1; - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitVector) { - var pool = []; - var Constants; - (function (Constants) { - Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; - Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; - - Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; - - Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; - Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; - - Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; - Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; - Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; - })(Constants || (Constants = {})); - - var BitVectorImpl = (function () { - function BitVectorImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.bits = []; - } - BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; - }; - - BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; - }; - - BitVectorImpl.prototype.valueAt = function (index) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return undefined; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { - return true; - } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { - return false; - } else { - return undefined; - } - } else { - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return false; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { - return true; - } else { - return false; - } - } - }; - - BitVectorImpl.prototype.setValueAt = function (index, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); - - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === undefined) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - - var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); - encoded = encoded & clearMask; - - if (value === true) { - encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); - } else if (value === false) { - encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } else { - TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); - - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === false) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - - encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); - - if (value) { - encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } - }; - - BitVectorImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - this.bits.length = 0; - pool.push(this); - }; - return BitVectorImpl; - })(); - - function getBitVector(allowUndefinedValues) { - if (pool.length === 0) { - return new BitVectorImpl(allowUndefinedValues); - } - - var vector = pool.pop(); - vector.isReleased = false; - vector.allowUndefinedValues = allowUndefinedValues; - - return vector; - } - BitVector.getBitVector = getBitVector; - })(TypeScript.BitVector || (TypeScript.BitVector = {})); - var BitVector = TypeScript.BitVector; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitMatrix) { - var pool = []; - - var BitMatrixImpl = (function () { - function BitMatrixImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.vectors = []; - } - BitMatrixImpl.prototype.valueAt = function (x, y) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - return this.allowUndefinedValues ? undefined : false; - } - - return vector.valueAt(y); - }; - - BitMatrixImpl.prototype.setValueAt = function (x, y, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - if (value === undefined) { - return; - } - - vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); - this.vectors[x] = vector; - } - - vector.setValueAt(y, value); - }; - - BitMatrixImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - - for (var name in this.vectors) { - if (this.vectors.hasOwnProperty(name)) { - var vector = this.vectors[name]; - vector.release(); - } - } - - this.vectors.length = 0; - pool.push(this); - }; - return BitMatrixImpl; - })(); - - function getBitMatrix(allowUndefinedValues) { - if (pool.length === 0) { - return new BitMatrixImpl(allowUndefinedValues); - } - - var matrix = pool.pop(); - matrix.isReleased = false; - matrix.allowUndefinedValues = allowUndefinedValues; - - return matrix; - } - BitMatrix.getBitMatrix = getBitMatrix; - })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); - var BitMatrix = TypeScript.BitMatrix; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); - var AssertionLevel = TypeScript.AssertionLevel; - - var Debug = (function () { - function Debug() { - } - Debug.shouldAssert = function (level) { - return this.currentAssertionLevel >= level; - }; - - Debug.assert = function (expression, message, verboseDebugInfo) { - if (typeof message === "undefined") { message = ""; } - if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); - } - - throw new Error("Debug Failure. False expression: " + message + verboseDebugString); - } - }; - - Debug.fail = function (message) { - Debug.assert(false, message); - }; - Debug.currentAssertionLevel = 0 /* None */; - return Debug; - })(); - 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 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(); - result.length = this.length(); - - result.diagnosticCode = this._diagnosticKey; - - var _arguments = this.arguments(); - if (_arguments && _arguments.length > 0) { - result.arguments = _arguments; - } - - return result; - }; - - Diagnostic.prototype.diagnosticKey = function () { - return this._diagnosticKey; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.additionalLocations = function () { - return this._additionalLocations || []; - }; - - Diagnostic.equals = function (diagnostic1, diagnostic2) { - return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { - return v1 === v2; - }); - }; - - Diagnostic.prototype.info = function () { - return getDiagnosticInfoFromKey(this.diagnosticKey()); - }; - return Diagnostic; - })(Location); - TypeScript.Diagnostic = Diagnostic; - - function newLine() { - return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; - } - TypeScript.newLine = newLine; - - function getLargestIndex(diagnostic) { - var largest = -1; - var regex = /\{(\d+)\}/g; - - var match; - while (match = regex.exec(diagnostic)) { - var val = parseInt(match[1]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromKey(diagnosticKey) { - var result = TypeScript.diagnosticInformationMap[diagnosticKey]; - TypeScript.Debug.assert(result); - return result; - } - - function getLocalizedText(diagnosticKey, args) { - if (TypeScript.LocalizedDiagnosticMessages) { - } - - var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; - TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); - - var actualCount = args ? args.length : 0; - - var expectedCount = 1 + getLargestIndex(diagnosticKey); - - if (expectedCount !== actualCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); - } - - var valueCount = 1 + getLargestIndex(diagnosticMessageText); - if (valueCount !== expectedCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); - } - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return TypeScript.newLine(); - }); - - return diagnosticMessageText; - } - TypeScript.getLocalizedText = getLocalizedText; - - function getDiagnosticMessage(diagnosticKey, args) { - var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); - var diagnosticMessageText = getLocalizedText(diagnosticKey, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + ". " + message); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error("Invalid operation: " + message); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2StringHashCode = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key.charCodeAt(index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, - 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, - 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, - 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, - 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, - 4166287, 4999559, 5999471, 7199369]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 1024; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash) { - this.hash = hash; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode >= 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', "Key was already in table."); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && key === e.Key) { - return e; - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count >= (this.entries.length / 2)) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - return new HashTable(capacity, hash); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - TypeScript.nodeMakeDirectoryTime = 0; - TypeScript.nodeCreateBufferTime = 0; - TypeScript.nodeWriteFileSyncTime = 0; - - (function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; - })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); - var ByteOrderMark = TypeScript.ByteOrderMark; - - var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this.contents = contents; - this.byteOrderMark = byteOrderMark; - } - return FileInformation; - })(); - TypeScript.FileInformation = FileInformation; - - TypeScript.Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - newLine: "\r\n", - currentDirectory: function () { - return WScript.CreateObject("WScript.Shell").CurrentDirectory; - }, - supportsCodePage: function () { - return WScript.ReadFile; - }, - readFile: function (path, codepage) { - try { - if (codepage !== null && this.supportsCodePage()) { - try { - var contents = WScript.ReadFile(path, codepage); - return new FileInformation(contents, 0 /* None */); - } catch (e) { - } - } - - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - var message; - if (err.number === -2147024809) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); - } - - throw new Error(message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - var _os = require('os'); - - return { - newLine: _os.EOL, - currentDirectory: function () { - return process.cwd(); - }, - supportsCodePage: function () { - return false; - }, - readFile: function (file, codepage) { - if (codepage !== null) { - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); - } - - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 509); - } - } - var start = new Date().getTime(); - mkdirRecursiveSync(_path.dirname(path)); - TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - - var start = new Date().getTime(); - - var chunkLength = 4 * 1024; - var fileDescriptor = _fs.openSync(path, "w"); - try { - for (var index = 0; index < contents.length; index += chunkLength) { - var bufferStart = new Date().getTime(); - var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); - TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; - - _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); - } - } finally { - _fs.closeSync(fileDescriptor); - } - - TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IntegerUtilities) { - function integerDivide(numerator, denominator) { - return (numerator / denominator) >> 0; - } - IntegerUtilities.integerDivide = integerDivide; - - function integerMultiplyLow32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - } - IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; - - function integerMultiplyHigh32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - } - IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; - - function isInteger(text) { - return /^[0-9]+$/.test(text); - } - IntegerUtilities.isInteger = isInteger; - - function isHexInteger(text) { - return /^0(x|X)[0-9a-fA-F]+$/.test(text); - } - IntegerUtilities.isHexInteger = isHexInteger; - })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); - var IntegerUtilities = TypeScript.IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_computeLineStarts, length) { - this._computeLineStarts = _computeLineStarts; - this.length = length; - this._lineStarts = null; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this.lineStarts(), length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - if (this._lineStarts === null) { - this._lineStarts = this._computeLineStarts(); - } - - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - LineMap.empty = new LineMap(function () { - return [0]; - }, 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { - return e; - } - } - - return null; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - if (text.length !== length) { - return false; - } - - var s = start; - for (var i = 0; i < length; i++) { - if (text.charCodeAt(i) !== array[s]) { - return false; - } - - s++; - } - - return true; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticInformationMap = { - "error TS{0}: {1}": { - "code": 0, - "category": 3 /* NoPrefix */ - }, - "warning TS{0}: {1}": { - "code": 1, - "category": 3 /* NoPrefix */ - }, - "Unrecognized escape sequence.": { - "code": 1000, - "category": 1 /* Error */ - }, - "Unexpected character {0}.": { - "code": 1001, - "category": 1 /* Error */ - }, - "Missing close quote character.": { - "code": 1002, - "category": 1 /* Error */ - }, - "Identifier expected.": { - "code": 1003, - "category": 1 /* Error */ - }, - "'{0}' keyword expected.": { - "code": 1004, - "category": 1 /* Error */ - }, - "'{0}' expected.": { - "code": 1005, - "category": 1 /* Error */ - }, - "Identifier expected; '{0}' is a keyword.": { - "code": 1006, - "category": 1 /* Error */ - }, - "Automatic semicolon insertion not allowed.": { - "code": 1007, - "category": 1 /* Error */ - }, - "Unexpected token; '{0}' expected.": { - "code": 1008, - "category": 1 /* Error */ - }, - "Trailing separator not allowed.": { - "code": 1009, - "category": 1 /* Error */ - }, - "'*/' expected.": { - "code": 1010, - "category": 1 /* Error */ - }, - "'public' or 'private' modifier must precede 'static'.": { - "code": 1011, - "category": 1 /* Error */ - }, - "Unexpected token.": { - "code": 1012, - "category": 1 /* Error */ - }, - "Catch clause parameter cannot have a type annotation.": { - "code": 1013, - "category": 1 /* Error */ - }, - "Rest parameter must be last in list.": { - "code": 1014, - "category": 1 /* Error */ - }, - "Parameter cannot have question mark and initializer.": { - "code": 1015, - "category": 1 /* Error */ - }, - "Required parameter cannot follow optional parameter.": { - "code": 1016, - "category": 1 /* Error */ - }, - "Index signatures cannot have rest parameters.": { - "code": 1017, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have accessibility modifiers.": { - "code": 1018, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have a question mark.": { - "code": 1019, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have an initializer.": { - "code": 1020, - "category": 1 /* Error */ - }, - "Index signature must have a type annotation.": { - "code": 1021, - "category": 1 /* Error */ - }, - "Index signature parameter must have a type annotation.": { - "code": 1022, - "category": 1 /* Error */ - }, - "Index signature parameter type must be 'string' or 'number'.": { - "code": 1023, - "category": 1 /* Error */ - }, - "'extends' clause already seen.": { - "code": 1024, - "category": 1 /* Error */ - }, - "'extends' clause must precede 'implements' clause.": { - "code": 1025, - "category": 1 /* Error */ - }, - "Classes can only extend a single class.": { - "code": 1026, - "category": 1 /* Error */ - }, - "'implements' clause already seen.": { - "code": 1027, - "category": 1 /* Error */ - }, - "Accessibility modifier already seen.": { - "code": 1028, - "category": 1 /* Error */ - }, - "'{0}' modifier must precede '{1}' modifier.": { - "code": 1029, - "category": 1 /* Error */ - }, - "'{0}' modifier already seen.": { - "code": 1030, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a class element.": { - "code": 1031, - "category": 1 /* Error */ - }, - "Interface declaration cannot have 'implements' clause.": { - "code": 1032, - "category": 1 /* Error */ - }, - "'super' invocation cannot have type arguments.": { - "code": 1034, - "category": 1 /* Error */ - }, - "Only ambient modules can use quoted names.": { - "code": 1035, - "category": 1 /* Error */ - }, - "Statements are not allowed in ambient contexts.": { - "code": 1036, - "category": 1 /* Error */ - }, - "Implementations are not allowed in ambient contexts.": { - "code": 1037, - "category": 1 /* Error */ - }, - "'declare' modifier not allowed for code already in an ambient context.": { - "code": 1038, - "category": 1 /* Error */ - }, - "Initializers are not allowed in ambient contexts.": { - "code": 1039, - "category": 1 /* Error */ - }, - "Parameter property declarations can only be used in a non-ambient constructor declaration.": { - "code": 1040, - "category": 1 /* Error */ - }, - "Function implementation expected.": { - "code": 1041, - "category": 1 /* Error */ - }, - "Constructor implementation expected.": { - "code": 1042, - "category": 1 /* Error */ - }, - "Function overload name must be '{0}'.": { - "code": 1043, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a module element.": { - "code": 1044, - "category": 1 /* Error */ - }, - "'declare' modifier cannot appear on an interface declaration.": { - "code": 1045, - "category": 1 /* Error */ - }, - "'declare' modifier required for top level element.": { - "code": 1046, - "category": 1 /* Error */ - }, - "Rest parameter cannot be optional.": { - "code": 1047, - "category": 1 /* Error */ - }, - "Rest parameter cannot have an initializer.": { - "code": 1048, - "category": 1 /* Error */ - }, - "'set' accessor must have one and only one parameter.": { - "code": 1049, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot be optional.": { - "code": 1051, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot have an initializer.": { - "code": 1052, - "category": 1 /* Error */ - }, - "'set' accessor cannot have rest parameter.": { - "code": 1053, - "category": 1 /* Error */ - }, - "'get' accessor cannot have parameters.": { - "code": 1054, - "category": 1 /* Error */ - }, - "Modifiers cannot appear here.": { - "code": 1055, - "category": 1 /* Error */ - }, - "Accessors are only available when targeting ECMAScript 5 and higher.": { - "code": 1056, - "category": 1 /* Error */ - }, - "Class name cannot be '{0}'.": { - "code": 1057, - "category": 1 /* Error */ - }, - "Interface name cannot be '{0}'.": { - "code": 1058, - "category": 1 /* Error */ - }, - "Enum name cannot be '{0}'.": { - "code": 1059, - "category": 1 /* Error */ - }, - "Module name cannot be '{0}'.": { - "code": 1060, - "category": 1 /* Error */ - }, - "Enum member must have initializer.": { - "code": 1061, - "category": 1 /* Error */ - }, - "Export assignment cannot be used in internal modules.": { - "code": 1063, - "category": 1 /* Error */ - }, - "Export assignment not allowed in module with exported element.": { - "code": 1064, - "category": 1 /* Error */ - }, - "Module cannot have multiple export assignments.": { - "code": 1065, - "category": 1 /* Error */ - }, - "Ambient enum elements can only have integer literal initializers.": { - "code": 1066, - "category": 1 /* Error */ - }, - "module, class, interface, enum, import or statement": { - "code": 1067, - "category": 3 /* NoPrefix */ - }, - "constructor, function, accessor or variable": { - "code": 1068, - "category": 3 /* NoPrefix */ - }, - "statement": { - "code": 1069, - "category": 3 /* NoPrefix */ - }, - "case or default clause": { - "code": 1070, - "category": 3 /* NoPrefix */ - }, - "identifier": { - "code": 1071, - "category": 3 /* NoPrefix */ - }, - "call, construct, index, property or function signature": { - "code": 1072, - "category": 3 /* NoPrefix */ - }, - "expression": { - "code": 1073, - "category": 3 /* NoPrefix */ - }, - "type name": { - "code": 1074, - "category": 3 /* NoPrefix */ - }, - "property or accessor": { - "code": 1075, - "category": 3 /* NoPrefix */ - }, - "parameter": { - "code": 1076, - "category": 3 /* NoPrefix */ - }, - "type": { - "code": 1077, - "category": 3 /* NoPrefix */ - }, - "type parameter": { - "code": 1078, - "category": 3 /* NoPrefix */ - }, - "'declare' modifier not allowed on import declaration.": { - "code": 1079, - "category": 1 /* Error */ - }, - "Function overload must be static.": { - "code": 1080, - "category": 1 /* Error */ - }, - "Function overload must not be static.": { - "code": 1081, - "category": 1 /* Error */ - }, - "Parameter property declarations cannot be used in a constructor overload.": { - "code": 1083, - "category": 1 /* Error */ - }, - "Invalid 'reference' directive syntax.": { - "code": 1084, - "category": 1 /* Error */ - }, - "Octal literals are not available when targeting ECMAScript 5 and higher.": { - "code": 1085, - "category": 1 /* Error */ - }, - "Accessors are not allowed in ambient contexts.": { - "code": 1086, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a constructor declaration.": { - "code": 1089, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a parameter.": { - "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 */ - }, - "The name '{0}' does not exist in the current scope.": { - "code": 2001, - "category": 1 /* Error */ - }, - "The name '{0}' does not refer to a value.": { - "code": 2002, - "category": 1 /* Error */ - }, - "'super' can only be used inside a class instance method.": { - "code": 2003, - "category": 1 /* Error */ - }, - "The left-hand side of an assignment expression must be a variable, property or indexer.": { - "code": 2004, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable. Did you mean to include 'new'?": { - "code": 2161, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable.": { - "code": 2006, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not newable.": { - "code": 2007, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not indexable by type '{1}'.": { - "code": 2008, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { - "code": 2009, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { - "code": 2010, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}'.": { - "code": 2011, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}':{NL}{2}": { - "code": 2012, - "category": 1 /* Error */ - }, - "Expected var, class, interface, or module.": { - "code": 2013, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to type '{1}'.": { - "code": 2014, - "category": 1 /* Error */ - }, - "Getter '{0}' already declared.": { - "code": 2015, - "category": 1 /* Error */ - }, - "Setter '{0}' already declared.": { - "code": 2016, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends private class '{1}'.": { - "code": 2018, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements private interface '{1}'.": { - "code": 2019, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends private interface '{1}'.": { - "code": 2020, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends class from inaccessible module {1}.": { - "code": 2021, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements interface from inaccessible module {1}.": { - "code": 2022, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends interface from inaccessible module {1}.": { - "code": 2023, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2024, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2025, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2026, - "category": 1 /* Error */ - }, - "Exported variable '{0}' has or is using private type '{1}'.": { - "code": 2027, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2028, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2029, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2030, - "category": 1 /* Error */ - }, - "Exported variable '{0}' is using inaccessible module {1}.": { - "code": 2031, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { - "code": 2032, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { - "code": 2033, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { - "code": 2034, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2035, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2036, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2037, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2038, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2039, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2040, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { - "code": 2041, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { - "code": 2042, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { - "code": 2043, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2044, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2045, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2046, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2047, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2048, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2049, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class has or is using private type '{0}'.": { - "code": 2050, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class has or is using private type '{0}'.": { - "code": 2051, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface has or is using private type '{0}'.": { - "code": 2052, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface has or is using private type '{0}'.": { - "code": 2053, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface has or is using private type '{0}'.": { - "code": 2054, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class has or is using private type '{0}'.": { - "code": 2055, - "category": 1 /* Error */ - }, - "Return type of public method from exported class has or is using private type '{0}'.": { - "code": 2056, - "category": 1 /* Error */ - }, - "Return type of method from exported interface has or is using private type '{0}'.": { - "code": 2057, - "category": 1 /* Error */ - }, - "Return type of exported function has or is using private type '{0}'.": { - "code": 2058, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class is using inaccessible module {0}.": { - "code": 2059, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class is using inaccessible module {0}.": { - "code": 2060, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface is using inaccessible module {0}.": { - "code": 2061, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface is using inaccessible module {0}.": { - "code": 2062, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface is using inaccessible module {0}.": { - "code": 2063, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class is using inaccessible module {0}.": { - "code": 2064, - "category": 1 /* Error */ - }, - "Return type of public method from exported class is using inaccessible module {0}.": { - "code": 2065, - "category": 1 /* Error */ - }, - "Return type of method from exported interface is using inaccessible module {0}.": { - "code": 2066, - "category": 1 /* Error */ - }, - "Return type of exported function is using inaccessible module {0}.": { - "code": 2067, - "category": 1 /* Error */ - }, - "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { - "code": 2068, - "category": 1 /* Error */ - }, - "A parameter list must follow a generic type argument list. '(' expected.": { - "code": 2069, - "category": 1 /* Error */ - }, - "Multiple constructor implementations are not allowed.": { - "code": 2070, - "category": 1 /* Error */ - }, - "Unable to resolve external module '{0}'.": { - "code": 2071, - "category": 1 /* Error */ - }, - "Module cannot be aliased to a non-module type.": { - "code": 2072, - "category": 1 /* Error */ - }, - "A class may only extend another class.": { - "code": 2073, - "category": 1 /* Error */ - }, - "A class may only implement another class or interface.": { - "code": 2074, - "category": 1 /* Error */ - }, - "An interface may only extend another class or interface.": { - "code": 2075, - "category": 1 /* Error */ - }, - "Unable to resolve type.": { - "code": 2077, - "category": 1 /* Error */ - }, - "Unable to resolve type of '{0}'.": { - "code": 2078, - "category": 1 /* Error */ - }, - "Unable to resolve type parameter constraint.": { - "code": 2079, - "category": 1 /* Error */ - }, - "Type parameter constraint cannot be a primitive type.": { - "code": 2080, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target.": { - "code": 2081, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target:{NL}{0}": { - "code": 2082, - "category": 1 /* Error */ - }, - "Invalid 'new' expression.": { - "code": 2083, - "category": 1 /* Error */ - }, - "Call signatures used in a 'new' expression must have a 'void' return type.": { - "code": 2084, - "category": 1 /* Error */ - }, - "Could not select overload for 'new' expression.": { - "code": 2085, - "category": 1 /* Error */ - }, - "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { - "code": 2086, - "category": 1 /* Error */ - }, - "Could not select overload for 'call' expression.": { - "code": 2087, - "category": 1 /* Error */ - }, - "Cannot invoke an expression whose type lacks a call signature.": { - "code": 2088, - "category": 1 /* Error */ - }, - "Calls to 'super' are only valid inside a class.": { - "code": 2089, - "category": 1 /* Error */ - }, - "Generic type '{0}' requires {1} type argument(s).": { - "code": 2090, - "category": 1 /* Error */ - }, - "Type of array literal cannot be determined. Best common type could not be found for array elements.": { - "code": 2092, - "category": 1 /* Error */ - }, - "Could not find enclosing symbol for dotted name '{0}'.": { - "code": 2093, - "category": 1 /* Error */ - }, - "The property '{0}' does not exist on value of type '{1}'.": { - "code": 2094, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}'.": { - "code": 2095, - "category": 1 /* Error */ - }, - "'get' and 'set' accessor must have the same type.": { - "code": 2096, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in current location.": { - "code": 2097, - "category": 1 /* Error */ - }, - "Static members cannot reference class type parameters.": { - "code": 2099, - "category": 1 /* Error */ - }, - "Class '{0}' is recursively referenced as a base type of itself.": { - "code": 2100, - "category": 1 /* Error */ - }, - "Interface '{0}' is recursively referenced as a base type of itself.": { - "code": 2101, - "category": 1 /* Error */ - }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { - "code": 2102, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in non-derived classes.": { - "code": 2103, - "category": 1 /* Error */ - }, - "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { - "code": 2104, - "category": 1 /* Error */ - }, - "Constructors for derived classes must contain a 'super' call.": { - "code": 2105, - "category": 1 /* Error */ - }, - "Super calls are not permitted outside constructors or in local functions inside constructors.": { - "code": 2106, - "category": 1 /* Error */ - }, - "'{0}.{1}' is inaccessible.": { - "code": 2107, - "category": 1 /* Error */ - }, - "'this' cannot be referenced within module bodies.": { - "code": 2108, - "category": 1 /* Error */ - }, - "Invalid '+' expression - types not known to support the addition operator.": { - "code": 2111, - "category": 1 /* Error */ - }, - "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2112, - "category": 1 /* Error */ - }, - "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2113, - "category": 1 /* Error */ - }, - "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { - "code": 2114, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement cannot use a type annotation.": { - "code": 2115, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { - "code": 2116, - "category": 1 /* Error */ - }, - "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { - "code": 2117, - "category": 1 /* Error */ - }, - "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { - "code": 2118, - "category": 1 /* Error */ - }, - "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { - "code": 2119, - "category": 1 /* Error */ - }, - "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { - "code": 2120, - "category": 1 /* Error */ - }, - "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 */ - }, - "Setters cannot return a value.": { - "code": 2122, - "category": 1 /* Error */ - }, - "Tried to query type of uninitialized module '{0}'.": { - "code": 2123, - "category": 1 /* Error */ - }, - "Tried to set variable type to uninitialized module type '{0}'.": { - "code": 2124, - "category": 1 /* Error */ - }, - "Type '{0}' does not have type parameters.": { - "code": 2125, - "category": 1 /* Error */ - }, - "Getters must return a value.": { - "code": 2126, - "category": 1 /* Error */ - }, - "Getter and setter accessors do not agree in visibility.": { - "code": 2127, - "category": 1 /* Error */ - }, - "Invalid left-hand side of assignment expression.": { - "code": 2130, - "category": 1 /* Error */ - }, - "Function declared a non-void return type, but has no return expression.": { - "code": 2131, - "category": 1 /* Error */ - }, - "Cannot resolve return type reference.": { - "code": 2132, - "category": 1 /* Error */ - }, - "Constructors cannot have a return type of 'void'.": { - "code": 2133, - "category": 1 /* Error */ - }, - "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { - "code": 2134, - "category": 1 /* Error */ - }, - "All symbols within a with block will be resolved to 'any'.": { - "code": 2135, - "category": 1 /* Error */ - }, - "Import declarations in an internal module cannot reference an external module.": { - "code": 2136, - "category": 1 /* Error */ - }, - "Class {0} declares interface {1} but does not implement it:{NL}{2}": { - "code": 2137, - "category": 1 /* Error */ - }, - "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { - "code": 2138, - "category": 1 /* Error */ - }, - "The operand of an increment or decrement operator must be a variable, property or indexer.": { - "code": 2139, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in static initializers in a class body.": { - "code": 2140, - "category": 1 /* Error */ - }, - "Class '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2141, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2142, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { - "code": 2143, - "category": 1 /* Error */ - }, - "Duplicate overload signature for '{0}'.": { - "code": 2144, - "category": 1 /* Error */ - }, - "Duplicate constructor overload signature.": { - "code": 2145, - "category": 1 /* Error */ - }, - "Duplicate overload call signature.": { - "code": 2146, - "category": 1 /* Error */ - }, - "Duplicate overload construct signature.": { - "code": 2147, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition.": { - "code": 2148, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition:{NL}{0}": { - "code": 2149, - "category": 1 /* Error */ - }, - "Overload signatures must all be public or private.": { - "code": 2150, - "category": 1 /* Error */ - }, - "Overload signatures must all be exported or not exported.": { - "code": 2151, - "category": 1 /* Error */ - }, - "Overload signatures must all be ambient or non-ambient.": { - "code": 2152, - "category": 1 /* Error */ - }, - "Overload signatures must all be optional or required.": { - "code": 2153, - "category": 1 /* Error */ - }, - "Specialized overload signature is not assignable to any non-specialized signature.": { - "code": 2154, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in constructor arguments.": { - "code": 2155, - "category": 1 /* Error */ - }, - "Instance member cannot be accessed off a class.": { - "code": 2157, - "category": 1 /* Error */ - }, - "Untyped function calls may not accept type arguments.": { - "code": 2158, - "category": 1 /* Error */ - }, - "Non-generic functions may not accept type arguments.": { - "code": 2159, - "category": 1 /* Error */ - }, - "A generic type may not reference itself with a wrapped form of its own type parameters.": { - "code": 2160, - "category": 1 /* Error */ - }, - "Rest parameters must be array types.": { - "code": 2162, - "category": 1 /* Error */ - }, - "Overload signature implementation cannot use specialized type.": { - "code": 2163, - "category": 1 /* Error */ - }, - "Export assignments may only be used at the top-level of external modules.": { - "code": 2164, - "category": 1 /* Error */ - }, - "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2165, - "category": 1 /* Error */ - }, - "Only public methods of the base class are accessible via the 'super' keyword.": { - "code": 2166, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { - "code": 2167, - "category": 1 /* Error */ - }, - "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 assignable to numeric indexer type '{0}'.": { - "code": 2169, - "category": 1 /* Error */ - }, - "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { - "code": 2170, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}'.": { - "code": 2171, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { - "code": 2172, - "category": 1 /* Error */ - }, - "Generic type references must include all type arguments.": { - "code": 2173, - "category": 1 /* Error */ - }, - "Default arguments are only allowed in implementation.": { - "code": 2174, - "category": 1 /* Error */ - }, - "Overloads cannot differ only by return type.": { - "code": 2175, - "category": 1 /* Error */ - }, - "Function expression declared a non-void return type, but has no return expression.": { - "code": 2176, - "category": 1 /* Error */ - }, - "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2177, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}' in module '{1}'.": { - "code": 2178, - "category": 1 /* Error */ - }, - "Unable to resolve module reference '{0}'.": { - "code": 2179, - "category": 1 /* Error */ - }, - "Could not find module '{0}' in module '{1}'.": { - "code": 2180, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { - "code": 2181, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { - "code": 2182, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { - "code": 2183, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { - "code": 2184, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { - "code": 2185, - "category": 1 /* Error */ - }, - "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { - "code": 2186, - "category": 1 /* Error */ - }, - "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { - "code": 2187, - "category": 1 /* Error */ - }, - "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { - "code": 2188, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { - "code": 2189, - "category": 1 /* Error */ - }, - "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { - "code": 2190, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot be reopened.": { - "code": 2191, - "category": 1 /* Error */ - }, - "All declarations of merged declaration '{0}' must be exported or not exported.": { - "code": 2192, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in constructor arguments.": { - "code": 2193, - "category": 1 /* Error */ - }, - "Return type of constructor signature must be assignable to the instance type of the class.": { - "code": 2194, - "category": 1 /* Error */ - }, - "Ambient external module declaration must be defined in global context.": { - "code": 2195, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot specify relative module name.": { - "code": 2196, - "category": 1 /* Error */ - }, - "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { - "code": 2197, - "category": 1 /* Error */ - }, - "Could not find the best common type of types of all return statement expressions.": { - "code": 2198, - "category": 1 /* Error */ - }, - "Import declaration cannot refer to external module reference when --noResolve option is set.": { - "code": 2199, - "category": 1 /* Error */ - }, - "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { - "code": 2200, - "category": 1 /* Error */ - }, - "'continue' statement can only be used within an enclosing iteration statement.": { - "code": 2201, - "category": 1 /* Error */ - }, - "'break' statement can only be used within an enclosing iteration or switch statement.": { - "code": 2202, - "category": 1 /* Error */ - }, - "Jump target not found.": { - "code": 2203, - "category": 1 /* Error */ - }, - "Jump target cannot cross function boundary.": { - "code": 2204, - "category": 1 /* Error */ - }, - "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { - "code": 2205, - "category": 1 /* Error */ - }, - "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { - "code": 2206, - "category": 1 /* Error */ - }, - "Expression resolves to '_super' that compiler uses to capture base class reference.": { - "code": 2207, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2208, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2209, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2210, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2211, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2212, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2213, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2214, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2215, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2216, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2217, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2218, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2219, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { - "code": 2220, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2221, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { - "code": 2222, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2223, - "category": 1 /* Error */ - }, - "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { - "code": 2224, - "category": 1 /* Error */ - }, - "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { - "code": 2225, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { - "code": 2226, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { - "code": 2227, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { - "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 */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { - "code": 4001, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { - "code": 4002, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { - "code": 4003, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { - "code": 4004, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' define property '{2}' as private.": { - "code": 4005, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4006, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4007, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a call signature, but type '{1}' lacks one.": { - "code": 4008, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4009, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4010, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { - "code": 4011, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4012, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4013, - "category": 3 /* NoPrefix */ - }, - "Call signature expects {0} or fewer parameters.": { - "code": 4014, - "category": 3 /* NoPrefix */ - }, - "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { - "code": 4015, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4016, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4017, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { - "code": 4018, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { - "code": 4019, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { - "code": 4020, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { - "code": 4021, - "category": 3 /* NoPrefix */ - }, - "Type reference cannot refer to container '{0}'.": { - "code": 4022, - "category": 1 /* Error */ - }, - "Type reference must refer to type.": { - "code": 4023, - "category": 1 /* Error */ - }, - "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { - "code": 4024, - "category": 1 /* Error */ - }, - " (+ {0} overload(s))": { - "code": 4025, - "category": 2 /* Message */ - }, - "Variable declaration cannot have the same name as an import declaration.": { - "code": 4026, - "category": 1 /* Error */ - }, - "Signature expected {0} type arguments, got {1} instead.": { - "code": 4027, - "category": 1 /* Error */ - }, - "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { - "code": 4028, - "category": 3 /* NoPrefix */ - }, - "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 infinitely expanding type reference have incompatible type arguments.": { - "code": 4030, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { - "code": 4031, - "category": 3 /* NoPrefix */ - }, - "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { - "code": 4032, - "category": 3 /* NoPrefix */ - }, - "Types of string indexer of types '{0}' and '{1}' are not identical.": { - "code": 4033, - "category": 3 /* NoPrefix */ - }, - "Types of number indexer of types '{0}' and '{1}' are not identical.": { - "code": 4034, - "category": 3 /* NoPrefix */ - }, - "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 assignable to string indexer type in type '{2}'.{NL}{3}": { - "code": 4036, - "category": 3 /* NoPrefix */ - }, - "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 */ - }, - "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { - "code": 5002, - "category": 1 /* Error */ - }, - "Module code generation '{0}' not supported.": { - "code": 5003, - "category": 1 /* Error */ - }, - "Could not find file: '{0}'.": { - "code": 5004, - "category": 1 /* Error */ - }, - "A file cannot have a reference to itself.": { - "code": 5006, - "category": 1 /* Error */ - }, - "Cannot resolve referenced file: '{0}'.": { - "code": 5007, - "category": 1 /* Error */ - }, - "Cannot find the common subdirectory path for the input files.": { - "code": 5009, - "category": 1 /* Error */ - }, - "Emit Error: {0}.": { - "code": 5011, - "category": 1 /* Error */ - }, - "Cannot read file '{0}': {1}": { - "code": 5012, - "category": 1 /* Error */ - }, - "Unsupported file encoding.": { - "code": 5013, - "category": 3 /* NoPrefix */ - }, - "Locale must be of the form or -. For example '{0}' or '{1}'.": { - "code": 5014, - "category": 1 /* Error */ - }, - "Unsupported locale: '{0}'.": { - "code": 5015, - "category": 1 /* Error */ - }, - "Execution Failed.{NL}": { - "code": 5016, - "category": 1 /* Error */ - }, - "Invalid call to 'up'": { - "code": 5019, - "category": 1 /* Error */ - }, - "Invalid call to 'down'": { - "code": 5020, - "category": 1 /* Error */ - }, - "Base64 value '{0}' finished with a continuation bit.": { - "code": 5021, - "category": 1 /* Error */ - }, - "Unknown option '{0}'": { - "code": 5023, - "category": 1 /* Error */ - }, - "Expected {0} arguments to message, got {1} instead.": { - "code": 5024, - "category": 1 /* Error */ - }, - "Expected the message '{0}' to have {1} arguments, but it had {2}": { - "code": 5025, - "category": 1 /* Error */ - }, - "Could not delete file '{0}'": { - "code": 5034, - "category": 1 /* Error */ - }, - "Could not create directory '{0}'": { - "code": 5035, - "category": 1 /* Error */ - }, - "Error while executing file '{0}': ": { - "code": 5036, - "category": 1 /* Error */ - }, - "Cannot compile external modules unless the '--module' flag is provided.": { - "code": 5037, - "category": 1 /* Error */ - }, - "Option mapRoot cannot be specified without specifying sourcemap option.": { - "code": 5038, - "category": 1 /* Error */ - }, - "Option sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5039, - "category": 1 /* Error */ - }, - "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5040, - "category": 1 /* Error */ - }, - "Option '{0}' specified without '{1}'": { - "code": 5041, - "category": 1 /* Error */ - }, - "'codepage' option not supported on current platform.": { - "code": 5042, - "category": 1 /* Error */ - }, - "Concatenate and emit output to single file.": { - "code": 6001, - "category": 2 /* Message */ - }, - "Generates corresponding {0} file.": { - "code": 6002, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate map files instead of generated locations.": { - "code": 6003, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate TypeScript files instead of source locations.": { - "code": 6004, - "category": 2 /* Message */ - }, - "Watch input files.": { - "code": 6005, - "category": 2 /* Message */ - }, - "Redirect output structure to the directory.": { - "code": 6006, - "category": 2 /* Message */ - }, - "Do not emit comments to output.": { - "code": 6009, - "category": 2 /* Message */ - }, - "Skip resolution and preprocessing.": { - "code": 6010, - "category": 2 /* Message */ - }, - "Specify ECMAScript target version: '{0}' (default), or '{1}'": { - "code": 6015, - "category": 2 /* Message */ - }, - "Specify module code generation: '{0}' or '{1}'": { - "code": 6016, - "category": 2 /* Message */ - }, - "Print this message.": { - "code": 6017, - "category": 2 /* Message */ - }, - "Print the compiler's version: {0}": { - "code": 6019, - "category": 2 /* Message */ - }, - "Allow use of deprecated '{0}' keyword when referencing an external module.": { - "code": 6021, - "category": 2 /* Message */ - }, - "Specify locale for errors and messages. For example '{0}' or '{1}'": { - "code": 6022, - "category": 2 /* Message */ - }, - "Syntax: {0}": { - "code": 6023, - "category": 2 /* Message */ - }, - "options": { - "code": 6024, - "category": 2 /* Message */ - }, - "file1": { - "code": 6025, - "category": 2 /* Message */ - }, - "Examples:": { - "code": 6026, - "category": 2 /* Message */ - }, - "Options:": { - "code": 6027, - "category": 2 /* Message */ - }, - "Insert command line options and files from a file.": { - "code": 6030, - "category": 2 /* Message */ - }, - "Version {0}": { - "code": 6029, - "category": 2 /* Message */ - }, - "Use the '{0}' flag to see options.": { - "code": 6031, - "category": 2 /* Message */ - }, - "{NL}Recompiling ({0}):": { - "code": 6032, - "category": 2 /* Message */ - }, - "STRING": { - "code": 6033, - "category": 2 /* Message */ - }, - "KIND": { - "code": 6034, - "category": 2 /* Message */ - }, - "file2": { - "code": 6035, - "category": 2 /* Message */ - }, - "VERSION": { - "code": 6036, - "category": 2 /* Message */ - }, - "LOCATION": { - "code": 6037, - "category": 2 /* Message */ - }, - "DIRECTORY": { - "code": 6038, - "category": 2 /* Message */ - }, - "NUMBER": { - "code": 6039, - "category": 2 /* Message */ - }, - "Specify the codepage to use when opening source files.": { - "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 */ - }, - "Unknown rule.": { - "code": 7002, - "category": 1 /* Error */ - }, - "Invalid line number ({0})": { - "code": 7003, - "category": 1 /* Error */ - }, - "Warn on expressions and declarations with an implied 'any' type.": { - "code": 7004, - "category": 2 /* Message */ - }, - "Variable '{0}' implicitly has an 'any' type.": { - "code": 7005, - "category": 1 /* Error */ - }, - "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { - "code": 7006, - "category": 1 /* Error */ - }, - "Parameter '{0}' of function type implicitly has an 'any' type.": { - "code": 7007, - "category": 1 /* Error */ - }, - "Member '{0}' of object type implicitly has an 'any' type.": { - "code": 7008, - "category": 1 /* Error */ - }, - "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { - "code": 7009, - "category": 1 /* Error */ - }, - "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7010, - "category": 1 /* Error */ - }, - "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7011, - "category": 1 /* Error */ - }, - "Parameter '{0}' of lambda function implicitly has an 'any' type.": { - "code": 7012, - "category": 1 /* Error */ - }, - "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7013, - "category": 1 /* Error */ - }, - "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7014, - "category": 1 /* Error */ - }, - "Array Literal implicitly has an 'any' type from widening.": { - "code": 7015, - "category": 1 /* Error */ - }, - "'{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 = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - this._lineStartPositions = null; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - if (!this._lineStartPositions) { - this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); - } - - return this._lineStartPositions; - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LineMap1) { - function fromSimpleText(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return text.charCodeAt(index); - }, length: text.length() }); - }, text.length()); - } - LineMap1.fromSimpleText = fromSimpleText; - - function fromScriptSnapshot(scriptSnapshot) { - return new TypeScript.LineMap(function () { - return scriptSnapshot.getLineStartPositions(); - }, scriptSnapshot.getLength()); - } - LineMap1.fromScriptSnapshot = fromScriptSnapshot; - - function fromString(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts(text); - }, text.length); - } - LineMap1.fromString = fromString; - })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); - var LineMap1 = TypeScript.LineMap1; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextFactory) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - if (text === null) { - throw TypeScript.Errors.argumentNull('text'); - } - TypeScript.Debug.assert(lineBreakLength >= 0); - TypeScript.Debug.assert(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this._lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this._lineStarts(); - }, this.length()); - }; - - TextBase.prototype._lineStarts = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this._lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - this._lazyLineStarts = null; - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.substr = function (start, length, intern) { - var startInOriginalText = this.span.start() + start; - return this.text.substr(startInOriginalText, length, intern); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SubText.prototype._lineStarts = function () { - var _this = this; - if (!this._lazyLineStarts) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return _this.charCodeAt(index); - }, length: this.length() }); - } - - return this._lazyLineStarts; - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - this._lazyLineStarts = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - - StringText.prototype._lineStarts = function () { - if (this._lazyLineStarts === null) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); - } - - return this._lazyLineStarts; - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap1.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - this._lineMap = null; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - if (!this._lineMap) { - this._lineMap = TypeScript.LineMap1.fromString(this.value); - } - - return this._lineMap; - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this.scriptSnapshot.getLineStartPositions(); - }, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length; - - if (0 === length) { - var result = new Array(); - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = new Array(); - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (length < 0) { - TypeScript.Errors.argument("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Debug.assert(start >= 0); - TypeScript.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - var change0 = changes[0]; - - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - - oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - CharacterInfo.isOctalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 55 /* _7 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - - SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { - this._languageVersion = languageVersion; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - } - ParseOptions.prototype.toJSON = function (key) { - return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; - }; - - ParseOptions.prototype.languageVersion = function () { - return this._languageVersion; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; - - SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; - SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; - - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - - SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; - SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 62 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 63 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 64 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 65 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 67 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 66 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 68 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 69 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 70 /* OpenBraceToken */, - "}": 71 /* CloseBraceToken */, - "(": 72 /* OpenParenToken */, - ")": 73 /* CloseParenToken */, - "[": 74 /* OpenBracketToken */, - "]": 75 /* CloseBracketToken */, - ".": 76 /* DotToken */, - "...": 77 /* DotDotDotToken */, - ";": 78 /* SemicolonToken */, - ",": 79 /* CommaToken */, - "<": 80 /* LessThanToken */, - ">": 81 /* GreaterThanToken */, - "<=": 82 /* LessThanEqualsToken */, - ">=": 83 /* GreaterThanEqualsToken */, - "==": 84 /* EqualsEqualsToken */, - "=>": 85 /* EqualsGreaterThanToken */, - "!=": 86 /* ExclamationEqualsToken */, - "===": 87 /* EqualsEqualsEqualsToken */, - "!==": 88 /* ExclamationEqualsEqualsToken */, - "+": 89 /* PlusToken */, - "-": 90 /* MinusToken */, - "*": 91 /* AsteriskToken */, - "%": 92 /* PercentToken */, - "++": 93 /* PlusPlusToken */, - "--": 94 /* MinusMinusToken */, - "<<": 95 /* LessThanLessThanToken */, - ">>": 96 /* GreaterThanGreaterThanToken */, - ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 98 /* AmpersandToken */, - "|": 99 /* BarToken */, - "^": 100 /* CaretToken */, - "!": 101 /* ExclamationToken */, - "~": 102 /* TildeToken */, - "&&": 103 /* AmpersandAmpersandToken */, - "||": 104 /* BarBarToken */, - "?": 105 /* QuestionToken */, - ":": 106 /* ColonToken */, - "=": 107 /* EqualsToken */, - "+=": 108 /* PlusEqualsToken */, - "-=": 109 /* MinusEqualsToken */, - "*=": 110 /* AsteriskEqualsToken */, - "%=": 111 /* PercentEqualsToken */, - "<<=": 112 /* LessThanLessThanEqualsToken */, - ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 115 /* AmpersandEqualsToken */, - "|=": 116 /* BarEqualsToken */, - "^=": 117 /* CaretEqualsToken */, - "/": 118 /* SlashToken */, - "/=": 119 /* SlashEqualsToken */ - }; - - var kindToText = new Array(); - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[62 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 89 /* PlusToken */: - return 164 /* PlusExpression */; - case 90 /* MinusToken */: - return 165 /* NegateExpression */; - case 102 /* TildeToken */: - return 166 /* BitwiseNotExpression */; - case 101 /* ExclamationToken */: - return 167 /* LogicalNotExpression */; - case 93 /* PlusPlusToken */: - return 168 /* PreIncrementExpression */; - case 94 /* MinusMinusToken */: - return 169 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 93 /* PlusPlusToken */: - return 210 /* PostIncrementExpression */; - case 94 /* MinusMinusToken */: - return 211 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 91 /* AsteriskToken */: - return 205 /* MultiplyExpression */; - - case 118 /* SlashToken */: - return 206 /* DivideExpression */; - - case 92 /* PercentToken */: - return 207 /* ModuloExpression */; - - case 89 /* PlusToken */: - return 208 /* AddExpression */; - - case 90 /* MinusToken */: - return 209 /* SubtractExpression */; - - case 95 /* LessThanLessThanToken */: - return 202 /* LeftShiftExpression */; - - case 96 /* GreaterThanGreaterThanToken */: - return 203 /* SignedRightShiftExpression */; - - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - return 204 /* UnsignedRightShiftExpression */; - - case 80 /* LessThanToken */: - return 196 /* LessThanExpression */; - - case 81 /* GreaterThanToken */: - return 197 /* GreaterThanExpression */; - - case 82 /* LessThanEqualsToken */: - return 198 /* LessThanOrEqualExpression */; - - case 83 /* GreaterThanEqualsToken */: - return 199 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 200 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 201 /* InExpression */; - - case 84 /* EqualsEqualsToken */: - return 192 /* EqualsWithTypeConversionExpression */; - - case 86 /* ExclamationEqualsToken */: - return 193 /* NotEqualsWithTypeConversionExpression */; - - case 87 /* EqualsEqualsEqualsToken */: - return 194 /* EqualsExpression */; - - case 88 /* ExclamationEqualsEqualsToken */: - return 195 /* NotEqualsExpression */; - - case 98 /* AmpersandToken */: - return 191 /* BitwiseAndExpression */; - - case 100 /* CaretToken */: - return 190 /* BitwiseExclusiveOrExpression */; - - case 99 /* BarToken */: - return 189 /* BitwiseOrExpression */; - - case 103 /* AmpersandAmpersandToken */: - return 188 /* LogicalAndExpression */; - - case 104 /* BarBarToken */: - return 187 /* LogicalOrExpression */; - - case 116 /* BarEqualsToken */: - return 182 /* OrAssignmentExpression */; - - case 115 /* AmpersandEqualsToken */: - return 180 /* AndAssignmentExpression */; - - case 117 /* CaretEqualsToken */: - return 181 /* ExclusiveOrAssignmentExpression */; - - case 112 /* LessThanLessThanEqualsToken */: - return 183 /* LeftShiftAssignmentExpression */; - - case 113 /* GreaterThanGreaterThanEqualsToken */: - return 184 /* SignedRightShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 185 /* UnsignedRightShiftAssignmentExpression */; - - case 108 /* PlusEqualsToken */: - return 175 /* AddAssignmentExpression */; - - case 109 /* MinusEqualsToken */: - return 176 /* SubtractAssignmentExpression */; - - case 110 /* AsteriskEqualsToken */: - return 177 /* MultiplyAssignmentExpression */; - - case 119 /* SlashEqualsToken */: - return 178 /* DivideAssignmentExpression */; - - case 111 /* PercentEqualsToken */: - return 179 /* ModuloAssignmentExpression */; - - case 107 /* EqualsToken */: - return 174 /* AssignmentExpression */; - - case 79 /* CommaToken */: - return 173 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function getOperatorTokenFromBinaryExpression(tokenKind) { - switch (tokenKind) { - case 205 /* MultiplyExpression */: - return 91 /* AsteriskToken */; - - case 206 /* DivideExpression */: - return 118 /* SlashToken */; - - case 207 /* ModuloExpression */: - return 92 /* PercentToken */; - - case 208 /* AddExpression */: - return 89 /* PlusToken */; - - case 209 /* SubtractExpression */: - return 90 /* MinusToken */; - - case 202 /* LeftShiftExpression */: - return 95 /* LessThanLessThanToken */; - - case 203 /* SignedRightShiftExpression */: - return 96 /* GreaterThanGreaterThanToken */; - - case 204 /* UnsignedRightShiftExpression */: - return 97 /* GreaterThanGreaterThanGreaterThanToken */; - - case 196 /* LessThanExpression */: - return 80 /* LessThanToken */; - - case 197 /* GreaterThanExpression */: - return 81 /* GreaterThanToken */; - - case 198 /* LessThanOrEqualExpression */: - return 82 /* LessThanEqualsToken */; - - case 199 /* GreaterThanOrEqualExpression */: - return 83 /* GreaterThanEqualsToken */; - - case 200 /* InstanceOfExpression */: - return 30 /* InstanceOfKeyword */; - - case 201 /* InExpression */: - return 29 /* InKeyword */; - - case 192 /* EqualsWithTypeConversionExpression */: - return 84 /* EqualsEqualsToken */; - - case 193 /* NotEqualsWithTypeConversionExpression */: - return 86 /* ExclamationEqualsToken */; - - case 194 /* EqualsExpression */: - return 87 /* EqualsEqualsEqualsToken */; - - case 195 /* NotEqualsExpression */: - return 88 /* ExclamationEqualsEqualsToken */; - - case 191 /* BitwiseAndExpression */: - return 98 /* AmpersandToken */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 100 /* CaretToken */; - - case 189 /* BitwiseOrExpression */: - return 99 /* BarToken */; - - case 188 /* LogicalAndExpression */: - return 103 /* AmpersandAmpersandToken */; - - case 187 /* LogicalOrExpression */: - return 104 /* BarBarToken */; - - case 182 /* OrAssignmentExpression */: - return 116 /* BarEqualsToken */; - - case 180 /* AndAssignmentExpression */: - return 115 /* AmpersandEqualsToken */; - - case 181 /* ExclusiveOrAssignmentExpression */: - return 117 /* CaretEqualsToken */; - - case 183 /* LeftShiftAssignmentExpression */: - return 112 /* LessThanLessThanEqualsToken */; - - case 184 /* SignedRightShiftAssignmentExpression */: - return 113 /* GreaterThanGreaterThanEqualsToken */; - - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - - case 175 /* AddAssignmentExpression */: - return 108 /* PlusEqualsToken */; - - case 176 /* SubtractAssignmentExpression */: - return 109 /* MinusEqualsToken */; - - case 177 /* MultiplyAssignmentExpression */: - return 110 /* AsteriskEqualsToken */; - - case 178 /* DivideAssignmentExpression */: - return 119 /* SlashEqualsToken */; - - case 179 /* ModuloAssignmentExpression */: - return 111 /* PercentEqualsToken */; - - case 174 /* AssignmentExpression */: - return 107 /* EqualsToken */; - - case 173 /* CommaExpression */: - return 79 /* CommaToken */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; - - function isAnyDivideToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - isIdentifierPartCharacter[character] = true; - isNumericLiteralStart[character] = true; - } - } - - isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); - 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - 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 { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - 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(fullText, kind); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(text, start, isTrailing); - }; - - Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { - var trivia = new Array(); - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.slidingWindow.absoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(diagnostics); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(79 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(106 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(78 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(102 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(72 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(73 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(105 /* QuestionToken */); - } - - if (isNumericLiteralStart[character]) { - return this.scanNumericLiteral(diagnostics); - } - - if (isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifierOrKeyword(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var slidingWindow = this.slidingWindow; - var window = slidingWindow.window; - - var startIndex = slidingWindow.currentRelativeItemIndex; - var endIndex = slidingWindow.windowCount; - var currentIndex = startIndex; - var character = 0; - - while (currentIndex < endIndex) { - character = window[currentIndex]; - if (!isIdentifierPartCharacter[character]) { - break; - } - - currentIndex++; - } - - if (currentIndex === endIndex) { - return 0 /* None */; - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - return 0 /* None */; - } else { - var kind; - var identifierLength = currentIndex - startIndex; - if (isKeywordStartCharacter[firstCharacter]) { - kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); - } else { - kind = 11 /* IdentifierName */; - } - - slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); - - return kind; - } - }; - - Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - var sawUnicodeEscape = false; - - do { - var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); - sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - var length = this.slidingWindow.absoluteIndex() - startIndex; - var text = this.text.substr(startIndex, length, false); - var valueText = TypeScript.Syntax.massageEscapes(text); - - var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); - if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { - if (sawUnicodeEscape) { - return keywordKind | -2147483648 /* IsVariableWidthKeyword */; - } else { - return keywordKind; - } - } - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function (diagnostics) { - if (this.isHexNumericLiteral()) { - this.scanHexNumericLiteral(); - } else if (this.isOctalNumericLiteral()) { - this.scanOctalNumericLiteral(diagnostics); - } else { - this.scanDecimalNumericLiteral(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isOctalNumericLiteral = function () { - return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); - }; - - Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { - var position = this.absoluteIndex(); - - while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.languageVersion() >= 1 /* EcmaScript5 */) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); - } - }; - - Scanner.prototype.scanDecimalDigits = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - this.scanDecimalDigits(); - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - this.scanDecimalDigits(); - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - var nextChar1 = this.slidingWindow.peekItemN(1); - - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { - var nextChar2 = this.slidingWindow.peekItemN(2); - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } - } - } - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 82 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* LessThanLessThanEqualsToken */; - } else { - return 95 /* LessThanLessThanToken */; - } - } else { - return 80 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 104 /* BarBarToken */; - } else { - return 99 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* CaretEqualsToken */; - } else { - return 100 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 115 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 103 /* AmpersandAmpersandToken */; - } else { - return 98 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* PercentEqualsToken */; - } else { - return 92 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* MinusMinusToken */; - } else { - return 90 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 108 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 93 /* PlusPlusToken */; - } else { - return 89 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* AsteriskEqualsToken */; - } else { - return 91 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 87 /* EqualsEqualsEqualsToken */; - } else { - return 84 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 85 /* EqualsGreaterThanToken */; - } else { - return 107 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function (diagnostics) { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(diagnostics); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 77 /* DotDotDotToken */; - } else { - return 76 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 119 /* SlashEqualsToken */; - } else { - return 118 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 12 /* RegularExpressionLiteral */; - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* ExclamationEqualsEqualsToken */; - } else { - return 86 /* ExclamationEqualsToken */; - } - } else { - return 101 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - break; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - break; - - default: - break; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - this.scanUnicodeOrHexEscape(errors); - return true; - } - } - - this.slidingWindow.moveToNextItem(); - return false; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); - var errors = new Array(); - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 121 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 124 /* ArrayType */: - return parent.type === nodeOrToken; - case 220 /* CastExpression */: - return parent.type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - case 228 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return TypeScript.Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullEnd; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullEnd = positionedToken.fullEnd(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullEnd) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); - } - - fullEnd -= triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function findSkippedTokenOnLeft(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - - function isIntegerLiteral(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - Syntax.isIntegerLiteral = isIntegerLiteral; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = new Array(); - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return nodeOrToken.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - element.insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - element.insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - var firstToken = this.firstToken(); - return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.trailingTrivia = function () { - var lastToken = this.lastToken(); - return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - 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 === thisAsIndexable[name]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - var start = positionedToken.start(); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isExpression = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.requireKeyword = requireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.requireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { - return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { - return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.importKeyword; - case 2: - return this.identifier; - case 3: - return this.equalsToken; - case 4: - return this.moduleReference; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - - this._kind = kind; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.kind = function () { - return this._kind; - }; - - HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { - if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.name = name; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.name; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withName = function (name) { - return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { - if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.callSignature = callSignature; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 123 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeQuerySyntax = (function (_super) { - __extends(TypeQuerySyntax, _super); - function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.name = name; - } - TypeQuerySyntax.prototype.accept = function (visitor) { - return visitor.visitTypeQuery(this); - }; - - TypeQuerySyntax.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuerySyntax.prototype.childCount = function () { - return 2; - }; - - TypeQuerySyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeQuerySyntax.prototype.isType = function () { - return true; - }; - - TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { - if (this.typeOfKeyword === typeOfKeyword && this.name === name) { - return this; - } - - return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); - }; - - TypeQuerySyntax.create1 = function (name) { - return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); - }; - - TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.name); - }; - - TypeQuerySyntax.prototype.withName = function (name) { - return this.update(this.typeOfKeyword, name); - }; - - TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeQuerySyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeQuerySyntax = TypeQuerySyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 146 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.modifiers; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifiers = function (modifiers) { - return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - - this.arguments = _arguments; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 142 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 227 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 239 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.constructorKeyword = constructorKeyword; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.constructorKeyword; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - 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 */), CallSignatureSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var GetAccessorSyntax = (function (_super) { - __extends(GetAccessorSyntax, _super); - function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.getKeyword = getKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - } - GetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessor(this); - }; - - GetAccessorSyntax.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - - GetAccessorSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - GetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - GetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetAccessorSyntax.create1 = function (propertyName) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GetAccessorSyntax = GetAccessorSyntax; - - var SetAccessorSyntax = (function (_super) { - __extends(SetAccessorSyntax, _super); - function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.setKeyword = setKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - SetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessor(this); - }; - - SetAccessorSyntax.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - - SetAccessorSyntax.prototype.childCount = function () { - return 5; - }; - - SetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - SetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetAccessorSyntax.create1 = function (propertyName) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SetAccessorSyntax = SetAccessorSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var IndexMemberDeclarationSyntax = (function (_super) { - __extends(IndexMemberDeclarationSyntax, _super); - function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.indexSignature = indexSignature; - this.semicolonToken = semicolonToken; - } - IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexMemberDeclaration(this); - }; - - IndexMemberDeclarationSyntax.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - - IndexMemberDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.indexSignature; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexMemberDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { - if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { - return this; - } - - return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); - }; - - IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); - }; - - IndexMemberDeclarationSyntax.create1 = function (indexSignature) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { - return this.update(this.modifiers, indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.indexSignature, semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexMemberDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - this.colonToken = colonToken; - this.statements = statements; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - this.colonToken = colonToken; - this.statements = statements; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.doKeyword = doKeyword; - this.statement = statement; - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeQuery = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - 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) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var dedentThisTrivia = dedentNextWhitespace; - dedentNextWhitespace = false; - - if (dedentThisTrivia) { - if (trivia.kind() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - var indentNextTrivia = true; - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var indentThisTrivia = indentNextTrivia; - indentNextTrivia = false; - - switch (trivia.kind()) { - case 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(fullText, kind) { - this._fullText = fullText; - this.tokenKind = kind; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithNoTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - token.trailingTrivia().collectTextElements(elements); - } - - function getTriviaWidth(value) { - return value >>> 2 /* TriviaFullWidthShift */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function isExpression(token) { - switch (token.tokenKind) { - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - return true; - } - - return false; - } - Syntax.isExpression = isExpression; - - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - case 13 /* carriageReturn */: - var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { - i++; - } - continue; - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - Syntax.massageEscapes = massageEscapes; - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - return regularExpressionValue(text); - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function regularExpressionValue(text) { - try { - var lastSlash = text.lastIndexOf("/"); - var body = text.substring(1, lastSlash); - var flags = text.substring(lastSlash + 1); - return new RegExp(body, flags); - } catch (e) { - return null; - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - EmptyToken.prototype.isExpression = function () { - return isExpression(this); - }; - - EmptyToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - - RealizedToken.prototype.isExpression = function () { - return isExpression(this); - }; - - RealizedToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var AbstractTrivia = (function () { - function AbstractTrivia(_kind) { - this._kind = _kind; - } - AbstractTrivia.prototype.fullWidth = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.fullText = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.toJSON = function (key) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === this._kind) { - result.kind = name; - break; - } - } - - if (this.isSkippedToken()) { - result.skippedToken = this.skippedToken(); - } else { - result.text = this.fullText(); - } - return result; - }; - - AbstractTrivia.prototype.kind = function () { - return this._kind; - }; - - AbstractTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - AbstractTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - AbstractTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - AbstractTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - AbstractTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return AbstractTrivia; - })(); - - var NormalTrivia = (function (_super) { - __extends(NormalTrivia, _super); - function NormalTrivia(kind, _text) { - _super.call(this, kind); - this._text = _text; - } - NormalTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - NormalTrivia.prototype.fullText = function () { - return this._text; - }; - - NormalTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return NormalTrivia; - })(AbstractTrivia); - - var SkippedTokenTrivia = (function (_super) { - __extends(SkippedTokenTrivia, _super); - function SkippedTokenTrivia(_skippedToken) { - _super.call(this, 8 /* SkippedTokenTrivia */); - this._skippedToken = _skippedToken; - } - SkippedTokenTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SkippedTokenTrivia.prototype.fullText = function () { - return this.skippedToken().fullText(); - }; - - SkippedTokenTrivia.prototype.skippedToken = function () { - return this._skippedToken; - }; - return SkippedTokenTrivia; - })(AbstractTrivia); - - var DeferredTrivia = (function (_super) { - __extends(DeferredTrivia, _super); - function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { - _super.call(this, kind); - this._text = _text; - this._fullStart = _fullStart; - this._fullWidth = _fullWidth; - this._fullText = null; - } - DeferredTrivia.prototype.fullWidth = function () { - return this._fullWidth; - }; - - DeferredTrivia.prototype.fullText = function () { - if (!this._fullText) { - this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); - this._text = null; - } - - return this._fullText; - }; - - DeferredTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return DeferredTrivia; - })(AbstractTrivia); - - function deferredTrivia(kind, text, fullStart, fullWidth) { - return new DeferredTrivia(kind, text, fullStart, fullWidth); - } - Syntax.deferredTrivia = deferredTrivia; - - function trivia(kind, text) { - return new NormalTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SkippedTokenTrivia(token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - this.trivia[i].collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 228 /* TypeArgumentList */: - case 229 /* TypeParameterList */: - case 220 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - return SyntaxUtilities.getExportKeyword(moduleElement) !== null; - }; - - SyntaxUtilities.getExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - case 133 /* ImportDeclaration */: - return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); - default: - return null; - } - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeQuery = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.requireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.name); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeQuery = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.name); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitList(node.modifiers); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.constructorKeyword); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.indexSignature); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - - - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - var result = this.currentToken(); - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - - return result; - }; - return SyntaxCursor; - })(); - - - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); - } - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { - this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 69 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return this.eatToken(78 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); - } - - return semicolonToken; - } - - return this.eatToken(78 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= 15 /* FirstKeyword */) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 173 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 186 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 187 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 188 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 189 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 191 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 167 /* LogicalNotExpression */: - case 170 /* DeleteExpression */: - case 171 /* TypeOfExpression */: - case 172 /* VoidExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); - } - } - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - var modifierCount = this.modifierCount(); - return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - var modifierCount = this.modifierCount(); - if (this.isImportDeclaration(modifierCount)) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration(modifierCount)) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration(modifierCount)) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration(modifierCount)) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration(modifierCount)) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(inErrorRecovery)) { - return this.parseStatement(inErrorRecovery); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var modifiers = this.parseModifiers(); - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 80 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - - return typeArgumentList; - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 72 /* OpenParenToken */: - case 76 /* DotToken */: - - case 73 /* CloseParenToken */: - case 75 /* CloseBracketToken */: - case 106 /* ColonToken */: - case 78 /* SemicolonToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - case 84 /* EqualsEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: - case 103 /* AmpersandAmpersandToken */: - case 104 /* BarBarToken */: - case 100 /* CaretToken */: - case 98 /* AmpersandToken */: - case 99 /* BarToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { - var dotToken = this.eatToken(76 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 63 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isAccessor = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 64 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var getKeyword = this.eatKeyword(64 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var setKeyword = this.eatKeyword(68 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(false); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexMemberDeclaration()) { - return this.parseIndexMemberDeclaration(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var modifiers = this.parseModifiers(); - var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var callSignature = this.parseCallSignature(false); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 78 /* SemicolonToken */: - case 107 /* EqualsToken */: - case 106 /* ColonToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.isIndexMemberDeclaration = function () { - var index = this.modifierCount(); - return this.isIndexSignature(index); - }; - - ParserImpl.prototype.parseIndexMemberDeclaration = function () { - var modifiers = this.parseModifiers(); - var indexSignature = this.parseIndexSignature(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - if (callSignature.lastToken()) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature(0)) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(inErrorRecovery)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(inErrorRecovery)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function (tokenIndex) { - return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isIdentifier(this.currentToken())) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - - break; - - case 28 /* IfKeyword */: - case 70 /* OpenBraceToken */: - case 33 /* ReturnKeyword */: - case 34 /* SwitchKeyword */: - case 36 /* ThrowKeyword */: - case 15 /* BreakKeyword */: - case 18 /* ContinueKeyword */: - case 26 /* ForKeyword */: - case 42 /* WhileKeyword */: - case 43 /* WithKeyword */: - case 22 /* DoKeyword */: - case 38 /* TryKeyword */: - case 19 /* DebuggerKeyword */: - return true; - } - - if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { - return false; - } - - return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); - }; - - ParserImpl.prototype.parseStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 28 /* IfKeyword */: - return this.parseIfStatement(); - case 70 /* OpenBraceToken */: - return this.parseBlock(false, false); - case 33 /* ReturnKeyword */: - return this.parseReturnStatement(); - case 34 /* SwitchKeyword */: - return this.parseSwitchStatement(); - case 36 /* ThrowKeyword */: - return this.parseThrowStatement(); - case 15 /* BreakKeyword */: - return this.parseBreakStatement(); - case 18 /* ContinueKeyword */: - return this.parseContinueStatement(); - case 26 /* ForKeyword */: - return this.parseForOrForInStatement(); - case 42 /* WhileKeyword */: - return this.parseWhileStatement(); - case 43 /* WithKeyword */: - return this.parseWithStatement(); - case 22 /* DoKeyword */: - return this.parseDoStatement(); - case 38 /* TryKeyword */: - return this.parseTryStatement(); - case 19 /* DebuggerKeyword */: - return this.parseDebuggerStatement(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement(currentToken)) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { - return this.parseEmptyStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(false); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function (currentToken) { - return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(106 /* ColonToken */); - var statement = this.parseStatement(false); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return currentToken.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(78 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { - return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function (currentToken) { - var kind = currentToken.tokenKind; - if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 79 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function (currentToken) { - switch (currentToken.tokenKind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - - case 74 /* OpenBracketToken */: - - case 72 /* OpenParenToken */: - - case 80 /* LessThanToken */: - - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - - case 70 /* OpenBraceToken */: - - case 85 /* EqualsGreaterThanToken */: - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - - case 31 /* NewKeyword */: - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - - case 27 /* FunctionKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(false); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 225 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(token0); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(107 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpressionOrLower = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpressionOrLower(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeOfExpression(); - } else if (currentTokenKind === 41 /* VoidKeyword */) { - return this.parseVoidExpression(); - } else if (currentTokenKind === 21 /* DeleteKeyword */) { - return this.parseDeleteExpression(); - } else if (currentTokenKind === 80 /* LessThanToken */) { - return this.parseCastExpression(); - } else { - return this.parsePostfixExpressionOrLower(); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - if (precedence <= 2 /* AssignmentExpressionPrecedence */) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } - - var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); - if (parethesizedArrowFunction !== null) { - return parethesizedArrowFunction; - } - } - - var leftOperand = this.parseUnaryExpressionOrLower(); - return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(105 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(106 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 81 /* GreaterThanToken */) { - if (storage[1] === 81 /* GreaterThanToken */) { - if (storage[2] === 107 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 107 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 107 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } - - var expression = this.parsePrimaryExpression(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - return this.parseMemberExpressionRest(expression, false, inObjectCreation); - }; - - ParserImpl.prototype.parseCallExpressionOrLower = function () { - var expression; - if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { - expression = this.eatKeyword(50 /* SuperKeyword */); - - var currentTokenKind = this.currentToken().tokenKind; - if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - } - } else { - expression = this.parseMemberExpressionOrLower(false); - } - - return this.parseMemberExpressionRest(expression, true, false); - }; - - ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 72 /* OpenParenToken */: - if (!allowArguments) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 80 /* LessThanToken */: - if (!allowArguments) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 74 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 76 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseCallExpressionOrLower(); - } - }; - - ParserImpl.prototype.parsePostfixExpressionOrLower = function () { - var expression = this.parseLeftHandSideExpressionOrLower(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - } - - return expression; - }; - - ParserImpl.prototype.tryParseGenericArgumentList = function () { - var rewindPoint = this.getRewindPoint(); - - var typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; - var isDot = token0.tokenKind === 76 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - - var argumentList = null; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - - if (isDot) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); - } else { - return this.parseArgumentList(typeArgumentList); - } - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - if (this.currentToken().tokenKind === 80 /* LessThanToken */) { - return this.tryParseGenericArgumentList(); - } - - if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { - return this.parseArgumentList(null); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var _arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - _arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parsePrimaryExpression = function () { - var currentToken = this.currentToken(); - - if (this.isIdentifier(currentToken)) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 74 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 70 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 72 /* OpenParenToken */: - return this.parseParenthesizedExpression(); - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 75 /* CloseBracketToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseObjectCreationExpressionOrLower(true); - var argumentList = this.tryParseArgumentList(); - - var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); - return this.parseMemberExpressionRest(result, true, false); - }; - - ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseMemberExpressionOrLower(inObjectCreation); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(80 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedExpression = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { - return null; - } - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - - this.releaseRewindPoint(rewindPoint); - return arrowFunction; - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.tryParseArrowFunctionBlock = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { - return this.parseBlock(true, false); - } else { - return null; - } - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 70 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 73 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; - } - - if (token1.tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - token2 = this.peekToken(2); - if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { - if (this.isIdentifier(token2)) { - return true; - } - } - - if (!this.isIdentifier(token1)) { - return false; - } - - if (token2.tokenKind === 106 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 105 /* QuestionToken */) { - if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 79 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 106 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { - if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(true); - } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(106 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - return this.eatKeyword(35 /* ThisKeyword */); - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var lessThanToken = this.eatToken(80 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameters = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); - - return typeParameterList; - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(106 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 39 /* TypeOfKeyword */: - - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - - case 70 /* OpenBraceToken */: - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - - case 31 /* NewKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - var type = this.parseNonArrayType(currentToken); - - while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.isTypeQuery = function () { - return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; - }; - - ParserImpl.prototype.parseTypeQuery = function () { - var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); - var name = this.parseName(); - - return this.factory.typeQuery(typeOfKeyword, name); - }; - - ParserImpl.prototype.parseNonArrayType = function (currentToken) { - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - return this.eatAnyToken(); - - case 70 /* OpenBraceToken */: - return this.parseObjectType(); - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - return this.parseFunctionType(); - - case 31 /* NewKeyword */: - return this.parseConstructorType(); - - case 39 /* TypeOfKeyword */: - return this.parseTypeQuery(); - } - - return this.parseNameOrGenericType(); - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - var tokenKind = token.tokenKind; - if (tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { - if (this.isIdentifier(token)) { - var nextTokenKind = this.peekToken(1).tokenKind; - switch (nextTokenKind) { - case 73 /* CloseParenToken */: - case 106 /* ColonToken */: - case 107 /* EqualsToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); - - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { - modifierArray.push(this.eatAnyToken()); - continue; - } - - break; - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - 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; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType, inErrorRecovery); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 79 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 78 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 75 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 70 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 79 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - var currentToken = this.currentToken(); - if (this.isExpression(currentToken)) { - return true; - } - - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.parseStatement(inErrorRecovery); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(inErrorRecovery); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); - - case 16 /* SwitchClause_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 32 /* Block_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); - - case 131072 /* ParameterList_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, options) { - var source = new NormalParserSource(fileName, text, options.languageVersion()); - - return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.inObjectLiteralExpression = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { - return true; - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { - if (parameter.modifiers.childCount() > 0) { - var modifiers = parameter.modifiers; - var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - - if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { - if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); - return true; - } else { - if (modifierIndex > 0) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - 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.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; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); - return true; - } else if (parameter.modifiers.childCount() > 0) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - 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; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var isInStaticOverloadChain = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - var isStaticOverload = null; - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - 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) { - 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; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); - isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); - - 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; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 121 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "boolean": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { - var getKeywordFullStart = this.childFullStart(node, getKeyword); - if (parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { - if (this.checkIndexMemberModifiers(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIndexMemberDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { - if (node.modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(node, node.modifiers); - this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { - if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { - var savedInObjectLiteralExpression = this.inObjectLiteralExpression; - this.inObjectLiteralExpression = true; - _super.prototype.visitObjectLiteralExpression.call(this, node); - this.inObjectLiteralExpression = savedInObjectLiteralExpression; - }; - - GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { - var setKeywordFullStart = this.childFullStart(node, setKeyword); - if (parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); - return true; - } - - var parameterListFullStart = this.childFullStart(node, parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); - var parameter = parameterList.parameters.childAt(0); - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - 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 && previousValueWasComputed) { - this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); - return true; - } - - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitEnumElement = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - var expression = node.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(expression)) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); - this.skip(node); - return; - } - } - - _super.prototype.visitEnumElement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (node.stringLiteral === null) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); - } - } - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); - return true; - } - }; - - GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitImportDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); - this.skip(node); - return; - } - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { - this.skip(node); - return; - } - - _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); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock || this.inObjectLiteralExpression) { - if (modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclarator.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { - this.skip(node); - return; - } - - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { - var currentElementFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var child = modifiers.childAt(i); - if (child.kind() !== 57 /* PublicKeyword */) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); - return true; - } - - currentElementFullStart += child.fullWidth(); - } - - 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); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - if (logger.information()) { - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - } - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { - this._compiler = _compiler; - this._semanticInfoChain = _semanticInfoChain; - this.fileName = fileName; - this.referencedFiles = referencedFiles; - this._scriptSnapshot = _scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._syntaxTree = _syntaxTree; - this._topLevelDecl = _topLevelDecl; - this._diagnostics = null; - this._bloomFilter = null; - this._sourceUnit = null; - this._lineMap = null; - this._declASTMap = []; - this._astDeclMap = []; - this._amdDependencies = undefined; - this._externalModuleIndicatorSpan = undefined; - } - Document.prototype.invalidate = function () { - this._declASTMap.length = 0; - this._astDeclMap.length = 0; - this._topLevelDecl = null; - - this._syntaxTree = null; - this._sourceUnit = null; - this._diagnostics = null; - this._bloomFilter = null; - }; - - Document.prototype.isDeclareFile = function () { - return TypeScript.isDTSFile(this.fileName); - }; - - Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { - var start = new Date().getTime(); - this._diagnostics = syntaxTree.diagnostics(); - TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; - - this._lineMap = syntaxTree.lineMap(); - - var sourceUnit = syntaxTree.sourceUnit(); - var leadingTrivia = sourceUnit.leadingTrivia(); - - this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); - - var amdDependencies = []; - 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); - } - } - } - - this._amdDependencies = amdDependencies; - }; - - Document.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(trivia.fullText()); - - if (match) { - return new TypeScript.TextSpan(position, trivia.fullWidth()); - } - - return null; - }; - - 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); - } - } - - position += moduleElement.fullWidth(); - } - - return null; - ; - }; - - Document.prototype.sourceUnit = function () { - if (!this._sourceUnit) { - var start = new Date().getTime(); - var syntaxTree = this.syntaxTree(); - this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); - TypeScript.astTranslationTime += new Date().getTime() - start; - - if (!this.isOpen) { - this._syntaxTree = null; - } - } - - return this._sourceUnit; - }; - - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._diagnostics); - } - - return this._diagnostics; - }; - - Document.prototype.lineMap = function () { - if (this._lineMap === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._lineMap); - } - - return this._lineMap; - }; - - Document.prototype.isExternalModule = function () { - return this.externalModuleIndicatorSpan() !== null; - }; - - Document.prototype.externalModuleIndicatorSpan = function () { - if (this._externalModuleIndicatorSpan === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); - } - - return this._externalModuleIndicatorSpan; - }; - - Document.prototype.amdDependencies = function () { - if (this._amdDependencies === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._amdDependencies !== undefined); - } - - return this._amdDependencies; - }; - - Document.prototype.syntaxTree = function () { - var result = this._syntaxTree; - if (!result) { - var start = new Date().getTime(); - - result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); - - TypeScript.syntaxTreeParseTime += new Date().getTime() - start; - - if (this.isOpen || !this._sourceUnit) { - this._syntaxTree = result; - } - } - - this.cacheSyntaxTreeInfo(result); - return result; - }; - - Document.prototype.bloomFilter = function () { - if (!this._bloomFilter) { - var identifiers = TypeScript.createIntrinsicsObject(); - var pre = function (cur) { - if (TypeScript.ASTHelpers.isValidAstNode(cur)) { - if (cur.kind() === 11 /* IdentifierName */) { - var nodeText = cur.valueText(); - - identifiers[nodeText] = true; - } - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); - - var identifierCount = 0; - for (var name in identifiers) { - if (identifiers[name]) { - identifierCount++; - } - } - - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - } - return this._bloomFilter; - }; - - Document.prototype.emitToOwnOutputFile = function () { - return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { - var oldSyntaxTree = this._syntaxTree; - - if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { - var oldText = this._scriptSnapshot; - var newText = scriptSnapshot; - - TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); - var newTextPrefix = newText.getText(0, textChangeRange.span().start()); - TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); - - var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); - var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); - TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); - }; - - Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); - }; - - Document.prototype.topLevelDecl = function () { - if (this._topLevelDecl === null) { - this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); - } - - return this._topLevelDecl; - }; - - Document.prototype._getDeclForAST = function (ast) { - this.topLevelDecl(); - return this._astDeclMap[ast.syntaxID()]; - }; - - Document.prototype.getEnclosingDecl = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - return this._getDeclForAST(ast); - } - - ast = ast.parent; - var decl = null; - while (ast) { - decl = this._getDeclForAST(ast); - - if (decl) { - break; - } - - ast = ast.parent; - } - - return decl._getEnclosingDeclFromParentDecl(); - }; - - Document.prototype._setDeclForAST = function (ast, decl) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._astDeclMap[ast.syntaxID()] = decl; - }; - - Document.prototype._getASTForDecl = function (decl) { - return this._declASTMap[decl.declID]; - }; - - Document.prototype._setASTForDecl = function (decl, ast) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._declASTMap[decl.declID] = ast; - }; - return Document; - })(); - TypeScript.Document = Document; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var proto = "__proto__"; - - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - - this[proto] = null; - this[proto] = undefined; - } - return BlockIntrinsics; - })(); - - function createIntrinsicsObject() { - return new BlockIntrinsics(); - } - TypeScript.createIntrinsicsObject = createIntrinsicsObject; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = createIntrinsicsObject(); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (!fn(k, this.table[k], context)) { - return false; - } - } - } - - return true; - }; - - StringHashTable.prototype.some = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (fn(k, this.table[k], context)) { - return true; - } - } - } - - return false; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - - StringHashTable.prototype.remove = function (key) { - if (this.table[key] !== undefined) { - this.table[key] = undefined; - this.itemCount--; - } - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(StringHashTable); - TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (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); - } - ASTHelpers.moduleIsElided = moduleIsElided; - - 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)) { - 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; - } - ASTHelpers.enumIsElided = enumIsElided; - - function isValidAstNode(ast) { - if (!ast) - return false; - - if (ast.start() === -1 || ast.end() === -1) - return false; - - return true; - } - ASTHelpers.isValidAstNode = isValidAstNode; - - 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; - - 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) { - top = cur; - } - } - } - } - - 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; - } - } - - return false; - } - ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { - return false; - } - if (ast.kind() !== 11 /* IdentifierName */) { - return false; - } - - 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); - } - 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; - } - - current = current.parent; - } - 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; - } - - return null; - } - ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; - - 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; - } - 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; - - function parametersFromIdentifier(id) { - return { - length: 1, - lastParameterIsRest: function () { - return false; - }, - ast: id, - astAt: function (index) { - return id; - }, - identifierAt: function (index) { - return id; - }, - typeAt: function (index) { - return null; - }, - initializerAt: function (index) { - return null; - }, - isOptionalAt: function (index) { - return false; - } - }; - } - ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; - - function parametersFromParameter(parameter) { - return { - length: 1, - lastParameterIsRest: function () { - return parameter.dotDotDotToken !== null; - }, - ast: parameter, - astAt: function (index) { - return parameter; - }, - identifierAt: function (index) { - return parameter.identifier; - }, - typeAt: function (index) { - return getType(parameter); - }, - initializerAt: function (index) { - return parameter.equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(parameter); - } - }; - } - ASTHelpers.parametersFromParameter = parametersFromParameter; - - function parameterIsOptional(parameter) { - return parameter.questionToken !== null || parameter.equalsValueClause !== null; - } - - function parametersFromParameterList(list) { - return { - length: list.parameters.nonSeparatorCount(), - lastParameterIsRest: function () { - return TypeScript.lastParameterIsRest(list); - }, - ast: list.parameters, - astAt: function (index) { - return list.parameters.nonSeparatorAt(index); - }, - identifierAt: function (index) { - return list.parameters.nonSeparatorAt(index).identifier; - }, - typeAt: function (index) { - return getType(list.parameters.nonSeparatorAt(index)); - }, - initializerAt: function (index) { - return list.parameters.nonSeparatorAt(index).equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(list.parameters.nonSeparatorAt(index)); - } - }; - } - ASTHelpers.parametersFromParameterList = parametersFromParameterList; - - 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; - } - } - ASTHelpers.isDeclarationAST = isDeclarationAST; - - 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; - } - - 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; - } - - ast = ast.parent; - } - - return null; - } - ASTHelpers.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); - - 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 { - TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); - var dotExpr = name; - return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); - } - } - ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; - })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); - var ASTHelpers = TypeScript.ASTHelpers; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function walkListChildren(preAst, walker) { - for (var i = 0, n = preAst.childCount(); i < n; i++) { - walker.walk(preAst.childAt(i)); - } - } - - function walkThrowStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkPrefixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkPostfixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkDeleteExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkTypeArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArguments); - } - - function walkTypeOfExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkVoidExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArgumentList); - walker.walk(preAst.arguments); - } - - function walkArrayLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.expressions); - } - - function walkSimplePropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.expression); - } - - function walkFunctionPropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkGetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkSeparatedListChildren(preAst, walker) { - for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { - walker.walk(preAst.nonSeparatorAt(i)); - } - } - - function walkSetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkObjectLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.propertyAssignments); - } - - function walkCastExpressionChildren(preAst, walker) { - walker.walk(preAst.type); - walker.walk(preAst.expression); - } - - function walkParenthesizedExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkElementAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentExpression); - } - - function walkMemberAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.name); - } - - function walkQualifiedNameChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkBinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkEqualsValueClauseChildren(preAst, walker) { - walker.walk(preAst.value); - } - - function walkTypeParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.constraint); - } - - function walkTypeParameterListChildren(preAst, walker) { - walker.walk(preAst.typeParameters); - } - - function walkGenericTypeChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.typeArgumentList); - } - - function walkTypeAnnotationChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkTypeQueryChildren(preAst, walker) { - walker.walk(preAst.name); - } - - function walkInvocationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkObjectCreationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkTrinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.whenTrue); - walker.walk(preAst.whenFalse); - } - - function walkFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFunctionTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkMemberFunctionDeclarationChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFuncDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkIndexMemberDeclarationChildren(preAst, walker) { - walker.walk(preAst.indexSignature); - } - - function walkIndexSignatureChildren(preAst, walker) { - walker.walk(preAst.parameter); - walker.walk(preAst.typeAnnotation); - } - - function walkCallSignatureChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - } - - function walkConstraintChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkConstructorTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkConstructSignatureChildren(preAst, walker) { - walker.walk(preAst.callSignature); - } - - function walkParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkParameterListChildren(preAst, walker) { - walker.walk(preAst.parameters); - } - - function walkPropertySignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - } - - function walkVariableDeclaratorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkMemberVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarator); - } - - function walkMethodSignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - } - - function walkReturnStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkForStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.initializer); - walker.walk(preAst.condition); - walker.walk(preAst.incrementor); - walker.walk(preAst.statement); - } - - function walkForInStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.left); - walker.walk(preAst.expression); - walker.walk(preAst.statement); - } - - function walkIfStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - walker.walk(preAst.elseClause); - } - - function walkElseClauseChildren(preAst, walker) { - walker.walk(preAst.statement); - } - - function walkWhileStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkDoStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkBlockChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.declarators); - } - - function walkCaseSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.statements); - } - - function walkDefaultSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkSwitchStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.switchClauses); - } - - function walkTryStatementChildren(preAst, walker) { - walker.walk(preAst.block); - walker.walk(preAst.catchClause); - walker.walk(preAst.finallyClause); - } - - function walkCatchClauseChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkExternalModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.stringLiteral); - } - - function walkFinallyClauseChildren(preAst, walker) { - walker.walk(preAst.block); - } - - function walkClassDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.classElements); - } - - function walkScriptChildren(preAst, walker) { - walker.walk(preAst.moduleElements); - } - - function walkHeritageClauseChildren(preAst, walker) { - walker.walk(preAst.typeNames); - } - - function walkInterfaceDeclerationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.body); - } - - function walkObjectTypeChildren(preAst, walker) { - walker.walk(preAst.typeMembers); - } - - function walkArrayTypeChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkModuleDeclarationChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.stringLiteral); - walker.walk(preAst.moduleElements); - } - - function walkModuleNameModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.moduleName); - } - - function walkEnumDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.enumElements); - } - - function walkEnumElementChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.equalsValueClause); - } - - function walkImportDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.moduleReference); - } - - function walkExportAssignmentChildren(preAst, walker) { - walker.walk(preAst.identifier); - } - - function walkWithStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkExpressionStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkLabeledStatementChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.statement); - } - - function walkVariableStatementChildren(preAst, walker) { - walker.walk(preAst.declaration); - } - - var childrenWalkers = new Array(246 /* Last */ + 1); - - for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { - childrenWalkers[i] = null; - } - for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { - childrenWalkers[i] = null; - } - - childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; - childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[60 /* AnyKeyword */] = null; - childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; - childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; - childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; - childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; - childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; - childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[146 /* Block */] = walkBlockChildren; - childrenWalkers[61 /* BooleanKeyword */] = null; - childrenWalkers[152 /* BreakStatement */] = null; - childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; - childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; - childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; - childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; - childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; - childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; - childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; - childrenWalkers[239 /* Constraint */] = walkConstraintChildren; - childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; - childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; - childrenWalkers[153 /* ContinueStatement */] = null; - childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; - childrenWalkers[162 /* DebuggerStatement */] = null; - childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; - childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; - childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; - childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; - childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; - childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; - childrenWalkers[156 /* EmptyStatement */] = null; - childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; - childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; - childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; - childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; - childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; - childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; - childrenWalkers[24 /* FalseKeyword */] = null; - childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; - childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; - childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; - childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; - childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; - childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; - childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; - childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; - childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; - childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; - childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; - childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; - childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; - childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; - childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; - childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; - childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; - childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; - childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[1 /* List */] = walkListChildren; - childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; - childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; - childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; - childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; - childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; - childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; - childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; - childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; - childrenWalkers[11 /* IdentifierName */] = null; - childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[0 /* None */] = null; - childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[32 /* NullKeyword */] = null; - childrenWalkers[67 /* NumberKeyword */] = null; - childrenWalkers[13 /* NumericLiteral */] = null; - childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; - childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; - childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; - childrenWalkers[223 /* OmittedExpression */] = null; - childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[242 /* Parameter */] = walkParameterChildren; - childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; - childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; - childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; - childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; - childrenWalkers[12 /* RegularExpressionLiteral */] = null; - childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; - childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; - childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; - childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; - childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; - childrenWalkers[14 /* StringLiteral */] = null; - childrenWalkers[69 /* StringKeyword */] = null; - childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; - childrenWalkers[50 /* SuperKeyword */] = null; - childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; - childrenWalkers[35 /* ThisKeyword */] = null; - childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; - childrenWalkers[3 /* TriviaList */] = null; - childrenWalkers[37 /* TrueKeyword */] = null; - childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; - childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; - childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; - childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; - childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; - childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; - childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; - childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; - childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; - childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; - childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; - childrenWalkers[41 /* VoidKeyword */] = null; - childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; - childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; - - for (var e in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { - TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); - } - } - - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - this.stopWalking = false; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var SimplePreAstWalker = (function () { - function SimplePreAstWalker(pre, state) { - this.pre = pre; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePreAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - }; - return SimplePreAstWalker; - })(); - - var SimplePrePostAstWalker = (function () { - function SimplePrePostAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePrePostAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - - this.post(ast, this.state); - }; - return SimplePrePostAstWalker; - })(); - - var NormalAstWalker = (function () { - function NormalAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - NormalAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - if (this.options.stopWalking) { - return; - } - - this.pre(ast, this); - - if (this.options.stopWalking) { - return; - } - - if (this.options.goChildren) { - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - } else { - this.options.goChildren = true; - } - - if (this.post) { - this.post(ast, this); - } - }; - return NormalAstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { - new NormalAstWalker(pre, post, state).walk(ast); - }; - - AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { - if (post) { - new SimplePrePostAstWalker(pre, post, state).walk(ast); - } else { - new SimplePreAstWalker(pre, state).walk(ast); - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory = new AstWalkerFactory(); - - function getAstWalkerFactory() { - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapEntry = (function () { - function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { - this.emittedFile = emittedFile; - this.emittedLine = emittedLine; - this.emittedColumn = emittedColumn; - this.sourceFile = sourceFile; - this.sourceLine = sourceLine; - this.sourceColumn = sourceColumn; - this.sourceName = sourceName; - TypeScript.Debug.assert(isFinite(emittedLine)); - TypeScript.Debug.assert(isFinite(emittedColumn)); - TypeScript.Debug.assert(isFinite(sourceColumn)); - TypeScript.Debug.assert(isFinite(sourceLine)); - } - return SourceMapEntry; - })(); - TypeScript.SourceMapEntry = SourceMapEntry; - - var SourceMapper = (function () { - function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.names = []; - this.mappingLevel = []; - this.tsFilePaths = []; - this.allSourceMappings = []; - this.sourceMapEntries = []; - this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); - this.setNewSourceFile(document, emitOptions); - } - SourceMapper.prototype.getOutputFile = function () { - var result = this.sourceMapOut.getOutputFile(); - result.sourceMapEntries = this.sourceMapEntries; - - return result; - }; - - SourceMapper.prototype.increaseMappingLevel = function (ast) { - this.mappingLevel.push(ast); - }; - - SourceMapper.prototype.decreaseMappingLevel = function (ast) { - TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); - var expectedAst = this.mappingLevel.pop(); - var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; - var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; - TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); - }; - - SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { - var sourceMappings = []; - this.allSourceMappings.push(sourceMappings); - this.currentMappings = [sourceMappings]; - this.currentNameIndex = []; - - this.setNewSourceFilePath(document, emitOptions); - }; - - SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { - var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); - var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; - this.jsFileName = prettyJsFileName; - - if (emitOptions.sourceMapRootDirectory()) { - this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); - if (document.emitToOwnOutputFile()) { - this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); - } - - if (TypeScript.isRelative(this.sourceMapDirectory)) { - this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; - this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); - this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); - } else { - this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; - } - } else { - this.sourceMapPath = prettyMapFileName; - this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); - } - this.sourceRoot = emitOptions.sourceRootDirectory(); - }; - - SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { - var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); - if (emitOptions.sourceRootDirectory()) { - tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); - } else { - tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); - } - this.tsFilePaths.push(tsFilePath); - }; - - SourceMapper.prototype.emitSourceMapping = function () { - var _this = this; - TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { - return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); - }).join(', ')); - - this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); - - var mappingsString = ""; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); - prevSourceIndex = sourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); - prevNameIndex = nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - for (var i = 0; i < sourceMappings.length; i++) { - var sourceMapping = sourceMappings[i]; - recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); - recordSourceMappingSiblings(sourceMapping.childMappings); - recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); - } - }; - - recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); - } - - this.sourceMapOut.Write(JSON.stringify({ - version: 3, - file: this.jsFileName, - sourceRoot: this.sourceRoot, - sources: this.tsFilePaths, - names: this.names, - mappings: mappingsString - })); - - this.sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compiler, resolvePath) { - this.resolvePath = resolvePath; - this._diagnostic = null; - this._settings = null; - this._commonDirectoryPath = ""; - this._sharedOutputFile = ""; - this._sourceRootDirectory = ""; - this._sourceMapRootDirectory = ""; - this._outputDirectory = ""; - var settings = compiler.compilationSettings(); - this._settings = settings; - - 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()) { - if (settings.mapRoot()) { - if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } else { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } else if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } - - this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); - this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); - - if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { - if (settings.outFileOption()) { - this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); - } - - if (settings.outDirOption()) { - this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); - } - - if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { - this.determineCommonDirectoryPath(compiler); - } - } - } - EmitOptions.prototype.diagnostic = function () { - return this._diagnostic; - }; - - EmitOptions.prototype.commonDirectoryPath = function () { - return this._commonDirectoryPath; - }; - EmitOptions.prototype.sharedOutputFile = function () { - return this._sharedOutputFile; - }; - EmitOptions.prototype.sourceRootDirectory = function () { - return this._sourceRootDirectory; - }; - EmitOptions.prototype.sourceMapRootDirectory = function () { - return this._sourceMapRootDirectory; - }; - EmitOptions.prototype.outputDirectory = function () { - return this._outputDirectory; - }; - - EmitOptions.prototype.compilationSettings = function () { - return this._settings; - }; - - EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = compiler.fileNames(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = compiler.getDocument(fileNames[i]); - var sourceUnit = document.sourceUnit(); - - if (!document.isDeclareFile()) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - 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; - } - - return; - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - function lastParameterIsRest(parameterList) { - var parameters = parameterList.parameters; - return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; - } - TypeScript.lastParameterIsRest = lastParameterIsRest; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.inArrowFunction = false; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.declStack = []; - this.exportAssignment = null; - this.inWithBlock = false; - this.document = null; - this.detachedCommentsElement = null; - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setExportAssignment = function (exportAssignment) { - this.exportAssignment = exportAssignment; - }; - - Emitter.prototype.getExportAssignment = function () { - return this.exportAssignment; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.shouldEmitImportDeclaration = 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 */; - - 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 */; - - this.emitComments(importDeclAST, true); - - var importSymbol = importDecl.getSymbol(); - - var parentSymbol = importSymbol.getContainer(); - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; - - var needsPropertyAssignment = false; - var usePropertyAssignmentInsteadOfVarDecl = false; - var moduleNamePrefix; - - 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 */)) { - needsPropertyAssignment = true; - } else { - usePropertyAssignmentInsteadOfVarDecl = true; - } - } - - if (this.emitState.container === 2 /* DynamicModule */) { - moduleNamePrefix = "exports."; - } else { - moduleNamePrefix = this.moduleName + "."; - } - } - - if (isAmdCodeGen && isExternalModuleReference) { - needsPropertyAssignment = true; - } else { - this.recordSourceMappingStart(importDeclAST); - if (usePropertyAssignmentInsteadOfVarDecl) { - this.writeToOutput(moduleNamePrefix); - } else { - this.writeToOutput("var "); - } - this.writeToOutput(importDeclAST.identifier.text() + " = "); - var aliasAST = importDeclAST.moduleReference; - - if (isExternalModuleReference) { - this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); - } else { - this.emitJavascript(aliasAST.moduleName, false); - } - - this.recordSourceMappingEnd(importDeclAST); - this.writeToOutput(";"); - - if (needsPropertyAssignment) { - this.writeLineToOutput(""); - this.emitIndent(); - } - } - - if (needsPropertyAssignment) { - this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); - this.writeToOutput(";"); - } - this.emitComments(importDeclAST, false); - }; - - Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { - this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); - }; - - Emitter.prototype.setSourceMapperNewSourceFile = function (document) { - this.sourceMapper.setNewSourceFile(document, this.emitOptions); - }; - - Emitter.prototype.updateLineAndColumn = function (s) { - var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); - if (lineNumbers.length > 1) { - this.emitState.line += lineNumbers.length - 1; - this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; - } else { - this.emitState.column += s.length; - } - }; - - Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { - this.recordSourceMappingStart(astSpan); - this.writeToOutput(s); - this.recordSourceMappingEnd(astSpan); - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - this.updateLineAndColumn(s); - }; - - Emitter.prototype.writeLineToOutput = function (s, force) { - if (typeof force === "undefined") { force = false; } - if (!force && s === "" && this.emitState.column === 0) { - return; - } - - this.outfile.WriteLine(s); - this.updateLineAndColumn(s); - this.emitState.column = 0; - this.emitState.line++; - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - return this.indenter.getIndent(); - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitComment = function (comment, trailing, first) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var text = getTrimmedTextLines(comment); - var emitColumn = this.emitState.column; - - if (emitColumn === 0) { - this.emitIndent(); - } else if (trailing && first) { - this.writeToOutput(" "); - } - - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingEnd(comment); - this.writeToOutput(" "); - return; - } - } else { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } - - if (!trailing && emitColumn !== 0) { - this.emitIndent(); - } - }; - - Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - 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; - } - } - - if (pre) { - var preComments = ast.preComments(); - - if (preComments && ast === this.detachedCommentsElement) { - var detachedComments = this.getDetachedComments(ast); - preComments = preComments.slice(detachedComments.length); - this.detachedCommentsElement = null; - } - - if (preComments && onlyPinnedOrTripleSlashComments) { - preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { - return _this.isPinnedOrTripleSlash(c); - }); - } - - this.emitCommentsArray(preComments, false); - } else { - this.emitCommentsArray(ast.postComments(), true); - } - }; - - Emitter.prototype.isPinnedOrTripleSlash = function (comment) { - var fullText = comment.fullText(); - if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { - return true; - } else { - return fullText.indexOf("/*!") === 0; - } - }; - - Emitter.prototype.emitCommentsArray = function (comments, trailing) { - if (!this.emitOptions.compilationSettings().removeComments() && comments) { - for (var i = 0, n = comments.length; i < n; i++) { - this.emitComment(comments[i], trailing, i === 0); - } - } - }; - - Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { - this.recordSourceMappingStart(objectLiteral); - - this.writeToOutput("{"); - this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); - this.writeToOutput("}"); - - this.recordSourceMappingEnd(objectLiteral); - }; - - Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { - this.recordSourceMappingStart(arrayLiteral); - - this.writeToOutput("["); - this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); - this.writeToOutput("]"); - - this.recordSourceMappingEnd(arrayLiteral); - }; - - Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { - this.recordSourceMappingStart(objectCreationExpression); - this.writeToOutput("new "); - var target = objectCreationExpression.expression; - - this.emit(target); - if (objectCreationExpression.argumentList) { - this.recordSourceMappingStart(objectCreationExpression.argumentList); - this.writeToOutput("("); - this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); - this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); - this.recordSourceMappingEnd(objectCreationExpression.argumentList); - } - - this.recordSourceMappingEnd(objectCreationExpression); - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); - if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - if (pullDecl.kind === 67108864 /* EnumMember */) { - return pullDecl; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - var propertyName = dotExpr.name; - var boundDecl = this.getConstantDecl(dotExpr); - if (boundDecl) { - var value = boundDecl.constantValue; - if (value !== null) { - this.recordSourceMappingStart(dotExpr); - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.text(); - comment += " */"; - this.writeToOutput(comment); - this.recordSourceMappingEnd(dotExpr); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitInvocationExpression = function (callNode) { - this.recordSourceMappingStart(callNode); - var target = callNode.expression; - var args = callNode.argumentList.arguments; - - if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { - this.emit(target); - this.writeToOutput(".call"); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitThis(); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - } else { - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - - this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); - this.recordSourceMappingEnd(args); - this.recordSourceMappingEnd(callNode); - }; - - Emitter.prototype.emitParameterList = function (list) { - this.writeToOutput("("); - this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); - this.writeToOutput(")"); - }; - - Emitter.prototype.emitFunctionParameters = function (parameters) { - var argsLen = 0; - - if (parameters) { - this.emitComments(parameters.ast, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = parameters.length; - var printLen = argsLen; - if (parameters.lastParameterIsRest()) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = parameters.astAt(i); - this.emit(arg); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(parameters.ast, false); - } - }; - - Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { - this.writeLineToOutput(" {"); - if (name) { - this.recordSourceMappingNameStart(name); - } - - this.indenter.increaseIndent(); - - 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); - } else { - this.emitIndent(); - this.emitCommentsArray(bodyExpression.preComments(), false); - this.writeToOutput("return "); - this.emit(bodyExpression); - this.writeLineToOutput(";"); - this.emitCommentsArray(bodyExpression.postComments(), true); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - - if (block) { - this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); - } else { - this.writeToOutputWithSourceMapRecord("}", bodyExpression); - } - - if (name) { - this.recordSourceMappingNameEnd(); - } - }; - - Emitter.prototype.emitDefaultValueAssignments = function (parameters) { - var n = parameters.length; - if (parameters.lastParameterIsRest()) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = parameters.astAt(i); - var id = parameters.identifierAt(i); - var equalsValueClause = parameters.initializerAt(i); - if (equalsValueClause) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.emitJavascript(equalsValueClause, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (parameters) { - if (parameters.lastParameterIsRest()) { - var n = parameters.length; - var lastArg = parameters.astAt(n - 1); - var id = parameters.identifierAt(n - 1); - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); - this.writeToOutput(" "); - this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); - this.writeToOutput("; "); - this.writeToOutputWithSourceMapRecord("_i++", lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - var result = []; - - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - var queue = dynamicModuleDecl.getChildDecls(); - - for (var i = 0, n = queue.length; i < n; i++) { - var decl = queue[i]; - - if (decl.kind & 128 /* TypeAlias */) { - var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.type; - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { - var importList = ""; - var dependencyList = ""; - - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.isUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += importStatementDecl.name; - dependencyList += importStatementAST.moduleReference.stringLiteral.text(); - } - } - } - - var amdDependencies = this.document.amdDependencies(); - for (var i = 0; i < amdDependencies.length; i++) { - dependencyList += ", \"" + amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); - } - - var decl = this.semanticInfoChain.getDeclForAST(ast); - if (decl) { - return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); - } - - return false; - }; - - Emitter.prototype.emitEnum = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - this.moduleName = moduleDecl.identifier.text(); - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.identifier); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(this.moduleName); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitSeparatedList(moduleDecl.enumElements); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { - return moduleDecl; - } else if (changeNameIfAnyDeclarationInContext) { - var symbol = moduleDecl.getSymbol(); - if (symbol) { - var otherDecls = symbol.getDeclarations(); - for (var i = 0; i < otherDecls.length; i++) { - if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { - return otherDecls[i]; - } - } - } - } - - return null; - }; - - Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { - var _this = this; - var childDecls = parentDecl.getChildDecls(); - return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - 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; - } - } - return false; - }); - }; - - Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - var moduleName = moduleDecl.name; - var moduleDisplayName = moduleDecl.getDisplayName(); - - moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { - while (this.hasChildNameCollision(moduleName, moduleDecl)) { - moduleName = "_" + moduleName; - moduleDisplayName = "_" + moduleDisplayName; - } - } - - return moduleDisplayName; - }; - - Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { - if (moduleDecl.stringLiteral) { - this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); - } - }; - - Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); - - if (isLastName) { - this.emitComments(moduleDecl, true); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - - if (moduleDecl.stringLiteral) { - this.moduleName = moduleDecl.stringLiteral.valueText(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - } else { - this.moduleName = moduleName.text(); - } - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleName); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleName); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - - this.moduleName = this.getModuleName(pullDecl); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(moduleName.text()); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - if (moduleName === moduleDecl.stringLiteral) { - this.emitList(moduleDecl.moduleElements); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - var nameIndex = moduleNames.indexOf(moduleName); - TypeScript.Debug.assert(nameIndex >= 0); - - if (isLastName) { - this.emitList(moduleDecl.moduleElements); - } else { - this.emitIndent(); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); - this.writeLineToOutput(""); - } - } - - this.moduleName = moduleName.text(); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - - if (isLastName) { - this.emitComments(moduleDecl, false); - } - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - var name = varDecl.propertyName.text(); - var quoted = TypeScript.isQuoted(name); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.writeToOutput(']'); - - if (varDecl.equalsValueClause) { - this.emit(varDecl.equalsValueClause); - } else if (pullDecl.constantValue !== null) { - this.writeToOutput(' = '); - this.writeToOutput(pullDecl.constantValue.toString()); - } else { - this.writeToOutput(' = null'); - } - - this.writeToOutput('] = '); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - this.writeToOutput(';'); - }; - - Emitter.prototype.emitElementAccessExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("["); - this.emit(expression.argumentExpression); - this.writeToOutput("]"); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = true; - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(arrowFunction); - - var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); - this.pushDecl(pullDecl); - - this.emitComments(arrowFunction, true); - - this.recordSourceMappingStart(arrowFunction); - this.writeToOutput("function "); - this.writeToOutput("("); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); - - this.recordSourceMappingEnd(arrowFunction); - - this.recordSourceMappingEnd(arrowFunction); - - this.emitComments(arrowFunction, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConstructor = function (funcDecl) { - if (!funcDecl.block) { - return; - } - var temp = this.setContainer(4 /* Constructor */); - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - this.writeToOutput(this.thisClassNode.identifier.text()); - this.writeToOutput("("); - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart("constructor"); - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(parameters); - this.emitRestParameterInitializer(parameters); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - this.emitConstructorStatements(funcDecl); - this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - }; - - Emitter.prototype.emitGetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("get "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitSetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("set "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitFunctionExpression = function (funcDecl) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - this.writeToOutput(funcDecl.identifier.text()); - this.recordSourceMappingEnd(funcDecl.identifier); - } - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (funcDecl.block === null) { - return; - } - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier.text(); - - this.recordSourceMappingStart(funcDecl); - - var printName = funcDecl.identifier !== null; - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (printName) { - var id = funcDecl.identifier.text(); - if (id) { - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - } - this.writeToOutput(id); - if (funcDecl.identifier) { - this.recordSourceMappingEnd(funcDecl.identifier); - } - } - } - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - if (funcDecl.block) { - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - this.recordSourceMappingStart(this.currentVariableDeclaration); - if (varDecl.equalsValueClause) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - this.emitJavascript(varDecl.equalsValueClause, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.currentVariableDeclaration) { - this.writeToOutput("var "); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.nonSeparatorAt(0); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - - this.emitComments(declaration, true); - - var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); - var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; - if (!isAmbientWithoutInit) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.currentVariableDeclaration = declaration; - - for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { - var declarator = declaration.declarators.nonSeparatorAt(i); - - if (i > 0) { - this.writeToOutput(", "); - } - - this.emit(declarator); - } - this.currentVariableDeclaration = prevVariableDeclaration; - - this.recordSourceMappingEnd(declaration); - } - - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { - TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); - - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - - if (quotedOrNumber) { - this.writeToOutput("this["); - } else { - this.writeToOutput("this."); - } - - this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); - - if (quotedOrNumber) { - this.writeToOutput("]"); - } - - if (varDecl.variableDeclarator.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.variableDeclarator.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(this.currentVariableDeclaration); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.propertyName.text(); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); - - if (parentIsModule) { - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - - if (varDecl.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.currentVariableDeclaration = undefined; - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { - var decl = pullSymbol.getDeclarations()[0]; - var parentDecl = decl.getParentDecl(); - var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; - - var enclosingContextDeclPath = this.declStack; - var commonNodeIndex = -1; - - if (enclosingContextDeclPath.length) { - for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { - var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; - for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { - var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; - if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { - commonNodeIndex = i; - break; - } - } - - if (commonNodeIndex >= 0) { - break; - } - } - } - - var startingIndex = symbolContainerDeclPath.length - 1; - for (var i = startingIndex - 1; i > commonNodeIndex; i--) { - if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { - startingIndex = i; - } else { - break; - } - } - return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; - }; - - Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { - for (var i = startingIndex; i <= lastIndex; i++) { - if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.getModuleName(declPath[i], true) + "."); - } - } - }; - - Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { - var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); - var potentialDeclPath = declPathInfo.potentialPath; - var startingIndex = declPathInfo.startingIndex; - - this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); - }; - - Emitter.prototype.getSymbolForEmit = function (ast) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); - var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); - if (pullSymbol && pullSymbolAlias) { - var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - - if (pullSymbol === symbolToCompare) { - pullSymbol = pullSymbolAlias; - pullSymbolAlias = null; - } - } - return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (name.text().length > 0) { - var symbolForEmit = this.getSymbolForEmit(name); - var pullSymbol = symbolForEmit.symbol; - if (!pullSymbol) { - pullSymbol = this.semanticInfoChain.anyTypeSymbol; - } - var pullSymbolAlias = symbolForEmit.aliasSymbol; - var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.kind; - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } - } - } - - this.writeToOutput(name.text()); - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var nameIndex = -1; - if (name) { - if (this.sourceMapper.currentNameIndex.length > 0) { - var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { - break; - } - } - - if (nameIndex === -1) { - nameIndex = this.sourceMapper.names.length; - this.sourceMapper.names.push(name); - } - } - this.sourceMapper.currentNameIndex.push(nameIndex); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (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; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap(); - lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); - - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - this.sourceMapper.increaseMappingLevel(ast); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); - - this.sourceMapper.decreaseMappingLevel(ast); - } - }; - - Emitter.prototype.getOutputFiles = function () { - var result = []; - if (this.sourceMapper !== null) { - this.sourceMapper.emitSourceMapping(); - result.push(this.sourceMapper.getOutputFile()); - } - - result.push(this.outfile.getOutputFile()); - return result; - }; - - Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { - var constructorDecl = getLastConstructor(this.thisClassNode); - - 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(); - this.recordSourceMappingStart(parameter); - this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); - this.writeToOutput(" = "); - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(parameter); - } - } - } - - for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { - if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = this.thisClassNode.classElements.childAt(i); - if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitIndent(); - this.emitMemberVariableDeclaration(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.isOnSameLine = function (pos1, pos2) { - var lineMap = this.document.lineMap(); - return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); - }; - - Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { - if (list === null || list.nonSeparatorCount() === 0) { - return; - } - - var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); - - if (preserveNewLines) { - this.indenter.increaseIndent(); - } - - if (startLine) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(buffer); - } - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - var emitNode = list.nonSeparatorAt(i); - - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); - if (startLine) { - this.writeLineToOutput(","); - } else { - this.writeToOutput(", "); - } - } - } - - if (preserveNewLines) { - this.indenter.decreaseIndent(); - } - - if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(buffer); - } - }; - - Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.nonSeparatorAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.kind() === 14 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { - return; - } - - var lineMap = this.document.lineMap(); - var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput("", true); - } - }; - - Emitter.prototype.getDetachedComments = function (element) { - var preComments = element.preComments(); - if (preComments) { - var lineMap = this.document.lineMap(); - - var detachedComments = []; - var lastComment = null; - - for (var i = 0, n = preComments.length; i < n; i++) { - var comment = preComments[i]; - - if (lastComment) { - var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); - var commentLine = lineMap.getLineNumberFromPosition(comment.start()); - - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - detachedComments.push(comment); - lastComment = comment; - } - - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); - var astLine = lineMap.getLineNumberFromPosition(element.start()); - if (astLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - return []; - }; - - Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - this.emitDetachedComments(script.moduleElements); - }; - - Emitter.prototype.emitDetachedComments = function (list) { - if (list.childCount() > 0) { - var firstElement = list.childAt(0); - - this.detachedCommentsElement = firstElement; - this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); - } - }; - - Emitter.prototype.emitScriptElements = function (sourceUnit) { - var list = sourceUnit.moduleElements; - - this.emitPossibleCopyrightHeaders(sourceUnit); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var node = list.childAt(i); - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(sourceUnit); - - var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); - if (isNonElidedExternalModule) { - this.recordSourceMappingStart(sourceUnit); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } - - if (isExternalModule) { - var temp = this.setContainer(2 /* DynamicModule */); - - var svModuleName = this.moduleName; - this.moduleName = sourceUnit.fileName(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - - this.setExportAssignment(null); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); - - if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { - this.writeCaptureThisStatement(sourceUnit); - } - - this.pushDecl(externalModule); - } - - this.emitList(list, true, i, n); - - if (isExternalModule) { - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - - if (isNonElidedExternalModule) { - var exportAssignment = this.getExportAssignment(); - var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; - var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); - this.writeLineToOutput(";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(sourceUnit); - this.writeLineToOutput(""); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - this.popDecl(externalModule); - } - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - this.emit(ast); - }; - - Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { - if (funcDecl.kind() !== 139 /* GetAccessor */) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - - this.writeToOutput("Object.defineProperty(" + className); - if (isProto) { - this.writeToOutput(".prototype, "); - } else { - this.writeToOutput(", "); - } - - var functionName = name.text(); - if (TypeScript.isQuoted(functionName)) { - this.writeToOutput(functionName); - } else { - this.writeToOutput('"' + functionName + '"'); - } - - this.writeLineToOutput(", {"); - - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.emitComments(accessors.getter, true); - this.writeToOutput("get: "); - this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.emitComments(accessors.setter, true); - this.writeToOutput("set: "); - this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.identifier.text(); - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; - var baseTypeReference = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); - this.writeLineToOutput(";"); - } - - this.emitIndent(); - - var constrDecl = getLastConstructor(classDecl); - - if (constrDecl) { - this.emit(constrDecl); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); - this.writeLineToOutput(";"); - } - - if (this.shouldCaptureThis(classDecl)) { - this.writeCaptureThisStatement(classDecl); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.writeLineToOutput(""); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.emitJavascript(baseTypeReference, false); - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 139 /* GetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var getter = memberDecl; - this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 140 /* SetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var setter = memberDecl; - this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { - var memberFunction = memberDecl; - - if (memberFunction.block) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - - this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); - lastEmittedMember = memberDecl; - } - } - } - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = memberDecl; - - if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); - } else { - this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); - } - - this.emit(varDecl.variableDeclarator.equalsValueClause); - - this.recordSourceMappingEnd(varDecl); - this.writeLineToOutput(";"); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - var functionName = funcDecl.propertyName.text(); - - this.writeToOutput(classDecl.identifier.text()); - - if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - this.writeToOutput(".prototype"); - } - - if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput("[" + functionName + "] = "); - } else { - this.writeToOutput("." + functionName + " = "); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - - this.writeLineToOutput(";"); - }; - - Emitter.prototype.requiresExtendsBlock = function (moduleElements) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - - if (moduleElement.kind() === 130 /* ModuleDeclaration */) { - var moduleAST = moduleElement; - - if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { - return true; - } - } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { - var classDeclaration = moduleElement; - - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitPrologue = function (sourceUnit) { - if (!this.extendsPrologueEmitted) { - if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(sourceUnit)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitThis = function () { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.kind() === 146 /* Block */) { - this.emit(node); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitLiteralExpression = function (expression) { - switch (expression.kind()) { - case 32 /* NullKeyword */: - this.writeToOutputWithSourceMapRecord("null", expression); - break; - case 24 /* FalseKeyword */: - this.writeToOutputWithSourceMapRecord("false", expression); - break; - case 37 /* TrueKeyword */: - this.writeToOutputWithSourceMapRecord("true", expression); - break; - default: - throw TypeScript.Errors.abstract(); - } - }; - - Emitter.prototype.emitThisExpression = function (expression) { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutputWithSourceMapRecord("_this", expression); - } else { - this.writeToOutputWithSourceMapRecord("this", expression); - } - }; - - Emitter.prototype.emitSuperExpression = function (expression) { - this.writeToOutputWithSourceMapRecord("_super.prototype", expression); - }; - - Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { - if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { - this.emit(parenthesizedExpression.expression); - } else { - this.recordSourceMappingStart(parenthesizedExpression); - this.writeToOutput("("); - this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); - this.emit(parenthesizedExpression.expression); - this.writeToOutput(")"); - this.recordSourceMappingEnd(parenthesizedExpression); - } - }; - - Emitter.prototype.emitCastExpression = function (expression) { - this.emit(expression.expression); - }; - - Emitter.prototype.emitPrefixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 167 /* LogicalNotExpression */: - this.writeToOutput("!"); - this.emit(expression.operand); - break; - case 166 /* BitwiseNotExpression */: - this.writeToOutput("~"); - this.emit(expression.operand); - break; - case 165 /* NegateExpression */: - this.writeToOutput("-"); - if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 164 /* PlusExpression */: - this.writeToOutput("+"); - if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 168 /* PreIncrementExpression */: - this.writeToOutput("++"); - this.emit(expression.operand); - break; - case 169 /* PreDecrementExpression */: - this.writeToOutput("--"); - this.emit(expression.operand); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitPostfixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 210 /* PostIncrementExpression */: - this.emit(expression.operand); - this.writeToOutput("++"); - break; - case 211 /* PostDecrementExpression */: - this.emit(expression.operand); - this.writeToOutput("--"); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitTypeOfExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("typeof "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDeleteExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("delete "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitVoidExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("void "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { - var memberExpressionNodeType = expression.expression.kind(); - - 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 */) { - return this.canEmitDottedNameMemberAccessExpression(expression.expression); - } - - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { - this.recordSourceMappingStart(expression); - if (expression.expression.kind() === 212 /* MemberAccessExpression */) { - this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); - } else { - this.emitComments(expression.expression, true); - this.recordSourceMappingStart(expression.expression); - - this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); - - this.writeToOutput(expression.expression.text()); - - this.recordSourceMappingEnd(expression.expression); - this.emitComments(expression.expression, false); - } - - this.writeToOutput("."); - this.emitName(expression.name, false); - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { - this.emitComments(expression, true); - - if (lastIndex - startingIndex < 1) { - startingIndex = lastIndex - 1; - TypeScript.Debug.assert(startingIndex >= 0); - } - - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); - this.emitComments(expression, false); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { - var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; - - var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); - }; - - Emitter.prototype.emitMemberAccessExpression = function (expression) { - if (!this.tryEmitConstant(expression)) { - if (this.canEmitDottedNameMemberAccessExpression(expression)) { - this.emitDottedNameMemberAccessExpression(expression); - } else { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("."); - this.emitName(expression.name, false); - this.recordSourceMappingEnd(expression); - } - } - }; - - Emitter.prototype.emitQualifiedName = function (name) { - this.recordSourceMappingStart(name); - - this.emit(name.left); - this.writeToOutput("."); - this.emitName(name.right, false); - - this.recordSourceMappingEnd(name); - }; - - Emitter.prototype.emitBinaryExpression = function (expression) { - this.recordSourceMappingStart(expression); - switch (expression.kind()) { - case 173 /* CommaExpression */: - this.emit(expression.left); - this.writeToOutput(", "); - this.emit(expression.right); - break; - default: { - this.emit(expression.left); - var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); - if (binOp === "instanceof") { - this.writeToOutput(" instanceof "); - } else if (binOp === "in") { - this.writeToOutput(" in "); - } else { - this.writeToOutput(" " + binOp + " "); - } - this.emit(expression.right); - } - } - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimplePropertyAssignment = function (property) { - this.recordSourceMappingStart(property); - this.emit(property.propertyName); - this.writeToOutput(": "); - this.emit(property.expression); - this.recordSourceMappingEnd(property); - }; - - Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { - this.recordSourceMappingStart(funcProp); - - this.emit(funcProp.propertyName); - this.writeToOutput(": "); - - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); - - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - var funcName = funcProp.propertyName; - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcProp); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); - - this.recordSourceMappingEnd(funcProp); - - this.recordSourceMappingEnd(funcProp); - - this.emitComments(funcProp, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConditionalExpression = function (expression) { - this.emit(expression.condition); - this.writeToOutput(" ? "); - this.emit(expression.whenTrue); - this.writeToOutput(" : "); - this.emit(expression.whenFalse); - }; - - Emitter.prototype.emitThrowStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("throw "); - this.emit(statement.expression); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitExpressionStatement = function (statement) { - var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; - - this.recordSourceMappingStart(statement); - if (isArrowExpression) { - this.writeToOutput("("); - } - - this.emit(statement.expression); - - if (isArrowExpression) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitLabeledStatement = function (statement) { - this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); - this.writeLineToOutput(":"); - this.emitJavascript(statement.statement, true); - }; - - Emitter.prototype.emitBlock = function (block) { - this.recordSourceMappingStart(block); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - if (block.statements) { - this.emitList(block.statements); - } - this.emitCommentsArray(block.closeBraceLeadingComments, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(block); - }; - - Emitter.prototype.emitBreakStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("break"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitContinueStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("continue"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitWhileStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("while ("); - this.emit(statement.condition); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitDoStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("do"); - this.emitBlockOrStatement(statement.statement); - this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); - this.writeToOutput('('); - this.emit(statement.condition); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitIfStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("if ("); - this.emit(statement.condition); - this.writeToOutput(")"); - - this.emitBlockOrStatement(statement.statement); - - if (statement.elseClause) { - if (statement.statement.kind() !== 146 /* Block */) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - - this.emit(statement.elseClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitElseClause = function (elseClause) { - if (elseClause.statement.kind() === 147 /* IfStatement */) { - this.writeToOutput("else "); - this.emit(elseClause.statement); - } else { - this.writeToOutput("else"); - this.emitBlockOrStatement(elseClause.statement); - } - }; - - Emitter.prototype.emitReturnStatement = function (statement) { - this.recordSourceMappingStart(statement); - if (statement.expression) { - this.writeToOutput("return "); - this.emit(statement.expression); - } else { - this.writeToOutput("return"); - } - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitForInStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.left) { - this.emit(statement.left); - } else { - this.emit(statement.variableDeclaration); - } - this.writeToOutput(" in "); - this.emit(statement.expression); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitForStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.variableDeclaration) { - this.emit(statement.variableDeclaration); - } else if (statement.initializer) { - this.emit(statement.initializer); - } - - this.writeToOutput("; "); - this.emitJavascript(statement.condition, false); - this.writeToOutput(";"); - if (statement.incrementor) { - this.writeToOutput(" "); - this.emitJavascript(statement.incrementor, false); - } - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitWithStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("with ("); - if (statement.condition) { - this.emit(statement.condition); - } - - this.writeToOutput(")"); - var prevInWithBlock = this.inWithBlock; - this.inWithBlock = true; - this.emitBlockOrStatement(statement.statement); - this.inWithBlock = prevInWithBlock; - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitSwitchStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("switch ("); - this.emit(statement.expression); - this.recordSourceMappingStart(statement.closeParenToken); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement.closeParenToken); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - this.emitList(statement.switchClauses, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCaseSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("case "); - this.emit(clause.expression); - this.writeToOutput(":"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitSwitchClauseBody = function (body) { - if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { - this.emit(body.childAt(0)); - this.writeLineToOutput(""); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emit(body); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitDefaultSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("default:"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitTryStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("try "); - this.emit(statement.block); - this.emitJavascript(statement.catchClause, false); - - if (statement.finallyClause) { - this.emit(statement.finallyClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCatchClause = function (clause) { - this.writeToOutput(" "); - this.recordSourceMappingStart(clause); - this.writeToOutput("catch ("); - this.emit(clause.identifier); - this.writeToOutput(")"); - this.emit(clause.block); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitFinallyClause = function (clause) { - this.writeToOutput(" finally"); - this.emit(clause.block); - }; - - Emitter.prototype.emitDebuggerStatement = function (statement) { - this.writeToOutputWithSourceMapRecord("debugger", statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitNumericLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitRegularExpressionLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitStringLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitEqualsValueClause = function (clause) { - this.writeToOutput(" = "); - this.emit(clause.value); - }; - - Emitter.prototype.emitParameter = function (parameter) { - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); - }; - - Emitter.prototype.emitConstructorDeclaration = function (declaration) { - if (declaration.block) { - this.emitConstructor(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { - return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); - }; - - Emitter.prototype.emitFunctionDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { - this.emitFunction(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.emitSourceUnit = function (sourceUnit) { - if (!this.document.isDeclareFile()) { - var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); - this.pushDecl(pullDecl); - this.emitScriptElements(sourceUnit); - this.popDecl(pullDecl); - - this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); - } - }; - - Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); - }; - - Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { - this.emitComments(declaration, true); - this.emitEnum(declaration); - this.emitComments(declaration, false); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); - }; - - Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { - this.emitModuleDeclarationWorker(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); - }; - - Emitter.prototype.emitClassDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { - this.emitClass(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { - return declaration.preComments() !== null; - }; - - Emitter.prototype.emitInterfaceDeclaration = function (declaration) { - this.emitComments(declaration, true, true); - }; - - Emitter.prototype.firstVariableDeclarator = function (statement) { - return statement.declaration.declarators.nonSeparatorAt(0); - }; - - Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { - return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; - }; - - Emitter.prototype.shouldEmitVariableStatement = function (statement) { - return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); - }; - - Emitter.prototype.emitVariableStatement = function (statement) { - if (this.isNotAmbientOrHasInitializer(statement)) { - this.emitComments(statement, true); - this.emit(statement.declaration); - this.writeToOutput(";"); - this.emitComments(statement, false); - } else { - this.emitComments(statement, true, true); - } - }; - - Emitter.prototype.emitGenericType = function (type) { - this.emit(type.name); - }; - - Emitter.prototype.shouldEmit = function (ast) { - if (!ast) { - return false; - } - - switch (ast.kind()) { - case 133 /* ImportDeclaration */: - return this.shouldEmitImportDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.shouldEmitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.shouldEmitInterfaceDeclaration(ast); - case 129 /* FunctionDeclaration */: - return this.shouldEmitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.shouldEmitModuleDeclaration(ast); - case 148 /* VariableStatement */: - return this.shouldEmitVariableStatement(ast); - case 223 /* OmittedExpression */: - return false; - case 132 /* EnumDeclaration */: - return this.shouldEmitEnumDeclaration(ast); - } - - return true; - }; - - Emitter.prototype.emit = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 2 /* SeparatedList */: - return this.emitSeparatedList(ast); - case 1 /* List */: - return this.emitList(ast); - case 120 /* SourceUnit */: - return this.emitSourceUnit(ast); - case 133 /* ImportDeclaration */: - return this.emitImportDeclaration(ast); - case 134 /* ExportAssignment */: - return this.setExportAssignment(ast); - case 131 /* ClassDeclaration */: - return this.emitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitInterfaceDeclaration(ast); - case 11 /* IdentifierName */: - return this.emitName(ast, true); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast); - case 219 /* SimpleArrowFunctionExpression */: - return this.emitSimpleArrowFunctionExpression(ast); - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.emitParenthesizedArrowFunctionExpression(ast); - case 129 /* FunctionDeclaration */: - return this.emitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitModuleDeclaration(ast); - case 224 /* VariableDeclaration */: - return this.emitVariableDeclaration(ast); - case 126 /* GenericType */: - return this.emitGenericType(ast); - case 137 /* ConstructorDeclaration */: - return this.emitConstructorDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitEnumDeclaration(ast); - case 243 /* EnumElement */: - return this.emitEnumElement(ast); - case 222 /* FunctionExpression */: - return this.emitFunctionExpression(ast); - case 148 /* VariableStatement */: - return this.emitVariableStatement(ast); - } - - this.emitComments(ast, true); - this.emitWorker(ast); - this.emitComments(ast, false); - }; - - Emitter.prototype.emitWorker = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 13 /* NumericLiteral */: - return this.emitNumericLiteral(ast); - case 12 /* RegularExpressionLiteral */: - return this.emitRegularExpressionLiteral(ast); - case 14 /* StringLiteral */: - return this.emitStringLiteral(ast); - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 37 /* TrueKeyword */: - return this.emitLiteralExpression(ast); - case 35 /* ThisKeyword */: - return this.emitThisExpression(ast); - case 50 /* SuperKeyword */: - return this.emitSuperExpression(ast); - case 217 /* ParenthesizedExpression */: - return this.emitParenthesizedExpression(ast); - case 214 /* ArrayLiteralExpression */: - return this.emitArrayLiteralExpression(ast); - case 211 /* PostDecrementExpression */: - case 210 /* PostIncrementExpression */: - return this.emitPostfixUnaryExpression(ast); - case 167 /* LogicalNotExpression */: - case 166 /* BitwiseNotExpression */: - case 165 /* NegateExpression */: - case 164 /* PlusExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.emitPrefixUnaryExpression(ast); - case 213 /* InvocationExpression */: - return this.emitInvocationExpression(ast); - case 221 /* ElementAccessExpression */: - return this.emitElementAccessExpression(ast); - case 212 /* MemberAccessExpression */: - return this.emitMemberAccessExpression(ast); - case 121 /* QualifiedName */: - return this.emitQualifiedName(ast); - case 173 /* CommaExpression */: - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* LogicalOrExpression */: - case 188 /* LogicalAndExpression */: - case 189 /* BitwiseOrExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 191 /* BitwiseAndExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return this.emitBinaryExpression(ast); - case 186 /* ConditionalExpression */: - return this.emitConditionalExpression(ast); - case 232 /* EqualsValueClause */: - return this.emitEqualsValueClause(ast); - case 242 /* Parameter */: - return this.emitParameter(ast); - case 146 /* Block */: - return this.emitBlock(ast); - case 235 /* ElseClause */: - return this.emitElseClause(ast); - case 147 /* IfStatement */: - return this.emitIfStatement(ast); - case 149 /* ExpressionStatement */: - return this.emitExpressionStatement(ast); - case 139 /* GetAccessor */: - return this.emitGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitSetAccessor(ast); - case 157 /* ThrowStatement */: - return this.emitThrowStatement(ast); - case 150 /* ReturnStatement */: - return this.emitReturnStatement(ast); - case 216 /* ObjectCreationExpression */: - return this.emitObjectCreationExpression(ast); - case 151 /* SwitchStatement */: - return this.emitSwitchStatement(ast); - case 233 /* CaseSwitchClause */: - return this.emitCaseSwitchClause(ast); - case 234 /* DefaultSwitchClause */: - return this.emitDefaultSwitchClause(ast); - case 152 /* BreakStatement */: - return this.emitBreakStatement(ast); - case 153 /* ContinueStatement */: - return this.emitContinueStatement(ast); - case 154 /* ForStatement */: - return this.emitForStatement(ast); - case 155 /* ForInStatement */: - return this.emitForInStatement(ast); - case 158 /* WhileStatement */: - return this.emitWhileStatement(ast); - case 163 /* WithStatement */: - return this.emitWithStatement(ast); - case 220 /* CastExpression */: - return this.emitCastExpression(ast); - case 215 /* ObjectLiteralExpression */: - return this.emitObjectLiteralExpression(ast); - case 240 /* SimplePropertyAssignment */: - return this.emitSimplePropertyAssignment(ast); - case 241 /* FunctionPropertyAssignment */: - return this.emitFunctionPropertyAssignment(ast); - case 156 /* EmptyStatement */: - return this.writeToOutputWithSourceMapRecord(";", ast); - case 159 /* TryStatement */: - return this.emitTryStatement(ast); - case 236 /* CatchClause */: - return this.emitCatchClause(ast); - case 237 /* FinallyClause */: - return this.emitFinallyClause(ast); - case 160 /* LabeledStatement */: - return this.emitLabeledStatement(ast); - case 161 /* DoStatement */: - return this.emitDoStatement(ast); - case 171 /* TypeOfExpression */: - return this.emitTypeOfExpression(ast); - case 170 /* DeleteExpression */: - return this.emitDeleteExpression(ast); - case 172 /* VoidExpression */: - return this.emitVoidExpression(ast); - case 162 /* DebuggerStatement */: - return this.emitDebuggerStatement(ast); - } - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; - - function getLastConstructor(classDecl) { - return classDecl.classElements.lastOrDefault(function (e) { - return e.kind() === 137 /* ConstructorDeclaration */; - }); - } - TypeScript.getLastConstructor = getLastConstructor; - - function getTrimmedTextLines(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - return comment.fullText().split("\n").map(function (s) { - return s.trim(); - }); - } else { - return [comment.fullText().trim()]; - } - } - TypeScript.getTrimmedTextLines = getTrimmedTextLines; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += memberName.text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripStartAndEndQuotes(str) { - var firstCharCode = str && str.charCodeAt(0); - if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - return str.substring(1, str.length - 1); - } - - return str; - } - TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; - - function isSingleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isDoubleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; - } - TypeScript.isDoubleQuoted = isDoubleQuoted; - - function isQuoted(str) { - return isDoubleQuoted(str) || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - var switchToForwardSlashesRegEx = /\\/g; - function switchToForwardSlashes(path) { - return path.replace(switchToForwardSlashesRegEx, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { - if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { - absoluteModPath = "file:///" + absoluteModPath; - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function changePathToDTS(modPath) { - return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.length > 0 && path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function convertToDirectoryPath(dirPath) { - if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { - dirPath += "/"; - } - - return dirPath; - } - TypeScript.convertToDirectoryPath = convertToDirectoryPath; - - var normalizePathRegEx = /^\\\\[^\\]/; - function normalizePath(path) { - if (normalizePathRegEx.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - function isNoDefaultLibMatch(comment) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - return isNoDefaultLibRegex.exec(comment); - } - - TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; - - function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { - var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } - } - } - - return null; - } - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - var start = new Date().getTime(); - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 107 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 72 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionScanImportsTime += totalTime; - } - - function processTripleSlashDirectives(fileName, lineMap, firstToken) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - var diagnostics = []; - var referencedFiles = []; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - var isNoDefaultLib = isNoDefaultLibMatch(triviaText); - if (isNoDefaultLib) { - noDefaultLib = isNoDefaultLib[3] === "true"; - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; - } - - function preProcessFile(fileName, sourceText, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); - - scannerDiagnostics.length = 0; - return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); - } - TypeScript.getParseOptions = getParseOptions; - - function getReferencedFiles(fileName, sourceText) { - return preProcessFile(fileName, sourceText, false).referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ReferenceResolutionResult = (function () { - function ReferenceResolutionResult() { - this.resolvedFiles = []; - this.diagnostics = []; - this.seenNoDefaultLibTag = false; - } - return ReferenceResolutionResult; - })(); - TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; - - var ReferenceLocation = (function () { - function ReferenceLocation(filePath, lineMap, position, length, isImported) { - this.filePath = filePath; - this.lineMap = lineMap; - this.position = position; - this.length = length; - this.isImported = isImported; - } - return ReferenceLocation; - })(); - - var ReferenceResolver = (function () { - function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { - this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this.inputFileNames = inputFileNames; - this.host = host; - this.visited = {}; - } - ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { - var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); - return resolver.resolveInputFiles(); - }; - - ReferenceResolver.prototype.resolveInputFiles = function () { - var _this = this; - var result = new ReferenceResolutionResult(); - - if (!this.inputFileNames || this.inputFileNames.length <= 0) { - return result; - } - - var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); - this.inputFileNames.forEach(function (fileName) { - return _this.resolveIncludedFile(fileName, referenceLocation, result); - }); - - return result; - }; - - ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { - var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); - - if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); - } - - return normalizedPath; - } - - if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { - var dtsFile = normalizedPath + ".d.ts"; - var tsFile = normalizedPath + ".ts"; - - if (this.host.fileExists(tsFile)) { - normalizedPath = tsFile; - } else { - normalizedPath = dtsFile; - } - } - - if (!this.host.fileExists(normalizedPath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); - } - - return normalizedPath; - } - - return this.resolveFile(normalizedPath, resolutionResult); - }; - - ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { - var isRelativePath = TypeScript.isRelative(path); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); - - if (isRelativePath || isRootedPath) { - return this.resolveIncludedFile(path, referenceLocation, resolutionResult); - } else { - var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); - var searchFilePath = null; - var dtsFileName = path + ".d.ts"; - var tsFilePath = path + ".ts"; - - var start = new Date().getTime(); - - do { - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - parentDirectory = this.host.getParentDirectory(parentDirectory); - } while(parentDirectory); - - TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; - - if (!searchFilePath) { - return path; - } - - return this.resolveFile(searchFilePath, resolutionResult); - } - }; - - ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { - var _this = this; - var visitedPath = this.isVisited(normalizedPath); - if (!visitedPath) { - this.recordVisitedFile(normalizedPath); - - var start = new Date().getTime(); - var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionIOTime += totalTime; - - var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); - var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); - resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); - - if (preprocessedFileInformation.isLibFile) { - resolutionResult.seenNoDefaultLibTag = true; - } - - var normalizedReferencePaths = []; - preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); - var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); - normalizedReferencePaths.push(normalizedReferencePath); - }); - - var normalizedImportPaths = []; - for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { - var fileImport = preprocessedFileInformation.importedFiles[i]; - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); - var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); - normalizedImportPaths.push(normalizedImportPath); - } - - resolutionResult.resolvedFiles.push({ - path: normalizedPath, - referencedFiles: normalizedReferencePaths, - importedFiles: normalizedImportPaths - }); - } else { - normalizedPath = visitedPath; - } - - return normalizedPath; - }; - - ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { - var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; - var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); - return normalizedPath; - }; - - ReferenceResolver.prototype.getUniqueFileId = function (filePath) { - return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); - }; - - ReferenceResolver.prototype.recordVisitedFile = function (filePath) { - this.visited[this.getUniqueFileId(filePath)] = filePath; - }; - - ReferenceResolver.prototype.isVisited = function (filePath) { - return this.visited[this.getUniqueFileId(filePath)]; - }; - - ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { - if (!filePath1 || !filePath2) { - return false; - } - - if (this.useCaseSensitiveFileResolution) { - return filePath1 === filePath2; - } else { - return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); - } - }; - return ReferenceResolver; - })(); - TypeScript.ReferenceResolver = ReferenceResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(name, writeByteOrderMark, outputFileType) { - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.outputFileType = outputFileType; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += TypeScript.newLine(); - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - }; - - TextWriter.prototype.getOutputFile = function () { - return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.document = document; - this.compiler = compiler; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.emittedReferencePaths = false; - this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); - } - DeclarationEmitter.prototype.getOutputFile = function () { - return this.declFile.getOutputFile(); - }; - - DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { - this.emitDeclarationsForSourceUnit(sourceUnit); - }; - - DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.emitDeclarationsForAST(list.childAt(i)); - } - }; - - DeclarationEmitter.prototype.emitSeparatedList = function (list) { - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.emitDeclarationsForAST(list.nonSeparatorAt(i)); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { - switch (ast.kind()) { - case 148 /* VariableStatement */: - return this.emitDeclarationsForVariableStatement(ast); - case 141 /* PropertySignature */: - return this.emitPropertySignature(ast); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast, true, true); - case 136 /* MemberVariableDeclaration */: - return this.emitDeclarationsForMemberVariableDeclaration(ast); - case 137 /* ConstructorDeclaration */: - return this.emitDeclarationsForConstructorDeclaration(ast); - case 139 /* GetAccessor */: - return this.emitDeclarationsForGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitDeclarationsForSetAccessor(ast); - case 138 /* IndexMemberDeclaration */: - return this.emitIndexMemberDeclaration(ast); - case 144 /* IndexSignature */: - return this.emitIndexSignature(ast); - case 142 /* CallSignature */: - return this.emitCallSignature(ast); - case 143 /* ConstructSignature */: - return this.emitConstructSignature(ast); - case 145 /* MethodSignature */: - return this.emitMethodSignature(ast); - case 129 /* FunctionDeclaration */: - return this.emitDeclarationsForFunctionDeclaration(ast); - case 135 /* MemberFunctionDeclaration */: - return this.emitMemberFunctionDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.emitDeclarationsForClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitDeclarationsForInterfaceDeclaration(ast); - case 133 /* ImportDeclaration */: - return this.emitDeclarationsForImportDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitDeclarationsForModuleDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitDeclarationsForEnumDeclaration(ast); - case 134 /* ExportAssignment */: - return this.emitDeclarationsForExportAssignment(ast); - } - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - return this.indenter.getIndent(); - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { - var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { - var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - var start = new Date().getTime(); - var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); - var result = declSymbol && declSymbol.isExternallyVisible(); - TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; - - return result; - } - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { - var result = this.getIndentString(); - var pullFlags = pullDecl.flags; - - if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); - - var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); - var container = this.getEnclosingContainer(declAST); - - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { - container = this.getEnclosingContainer(container); - } - - var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); - - if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (isExternalModule || container.kind() === 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString !== "import") { - result += "declare "; - } - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { - this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { - var declarationContainerAst = this.getEnclosingContainer(ast); - - var start = new Date().getTime(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); - - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - - var isNotAGenericType = ast.kind() !== 126 /* GenericType */; - - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = TypeScript.getTrimmedTextLines(comment); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { - var start = new Date().getTime(); - var decl = this.semanticInfoChain.getDeclForAST(boundDecl); - var pullSymbol = decl.getSymbol(); - TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; - - var type = pullSymbol.type; - TypeScript.Debug.assert(type); - - this.declFile.Write(": "); - this.emitTypeSignature(boundDecl, type); - }; - - DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { - this.emitDeclarationComments(varDecl); - this.emitIndent(); - this.declFile.Write(varDecl.propertyName.text()); - if (varDecl.questionToken) { - this.declFile.Write("?"); - } - - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - if (isFirstVarInList) { - this.emitDeclFlags(varDecl, "var"); - } - - this.declFile.Write(varDecl.propertyName.text()); - - if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - if (isLastVarInList) { - this.declFile.WriteLine(";"); - } else { - this.declFile.Write(", "); - } - } - }; - - DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { - if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } - this.declFile.Write("static "); - } else { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } else { - this.declFile.Write("public "); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(varDecl.modifiers); - ; - - this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); - - if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - this.declFile.WriteLine(";"); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { - this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); - }; - - 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); - } - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(id.text()); - if (isOptional) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (!isPrivate) { - this.emitTypeOfVariableDeclaratorOrParameter(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var start = new Date().getTime(); - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - var signatures = funcTypeSymbol.getCallSignatures(); - var result = signatures && signatures.length > 1; - - return result; - }; - - DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("constructor"); - - this.declFile.Write("("); - 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.ASTHelpers.parametersFromParameterList(parameterList)); - this.declFile.Write(")"); - }; - - DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { - var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); - var argsLen = parameterList.length; - if (hasLastParameterRestParameter) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - - if (hasLastParameterRestParameter) { - if (parameterList.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - var index = parameterList.length - 1; - this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); - } - }; - - DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitDeclFlags(funcDecl, "function"); - var id = funcDecl.propertyName.text(); - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); - - this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); - - if (!isPrivate) { - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - this.emitDeclarationComments(funcDecl); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); - - this.emitIndent(); - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("new"); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write(funcDecl.propertyName.text()); - if (funcDecl.questionToken) { - this.declFile.Write("? "); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - if (funcDecl.block) { - var funcTypeSymbol = funcSymbol.type; - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - var id = funcDecl.identifier.text(); - this.emitDeclFlags(funcDecl, "function"); - if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { - this.declFile.Write(id); - } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { - this.declFile.Write("new"); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { - this.emitDeclarationsForAST(funcDecl.indexSignature); - }; - - DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("["); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); - this.declFile.Write("]"); - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { - if (bases && (bases.nonSeparatorCount() > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.nonSeparatorCount(); - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - var base = bases.nonSeparatorAt(i); - var baseType = this.semanticInfoChain.getSymbolForAST(base); - this.emitTypeSignature(base, baseType); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var start = new Date().getTime(); - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - var comments = []; - if (accessors.getter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); - } - if (accessors.setter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); - } - - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { - var start = new Date().getTime(); - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { - return; - } - - var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); - this.emitAccessorDeclarationComments(funcDecl); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(modifiers); - this.declFile.Write(name.text()); - if (!isPrivate) { - this.declFile.Write(" : "); - var type = accessorSymbol.type; - this.emitTypeSignature(funcDecl, type); - } - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { - argsLen--; - } - - 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(";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { - if (!this.canEmitDeclarations(classDecl)) { - return; - } - - var className = classDecl.identifier.text(); - this.emitDeclarationComments(classDecl); - var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.emitDeclFlags(classDecl, "class"); - this.declFile.Write(className); - - this.emitTypeParameters(classDecl.typeParameterList); - this.emitHeritageClauses(classDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - var constructorDecl = TypeScript.getLastConstructor(classDecl); - if (constructorDecl) { - this.emitClassMembersFromConstructorDefinition(constructorDecl); - } - - this.emitDeclarationsForList(classDecl.classElements); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { - if (clauses) { - for (var i = 0, n = clauses.childCount(); i < n; i++) { - this.emitHeritageClause(clauses.childAt(i)); - } - } - }; - - DeclarationEmitter.prototype.emitHeritageClause = function (clause) { - this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); - }; - - DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getEnclosingContainer(typeParams); - - var start = new Date().getTime(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); - var containerSymbol = containerDecl.getSymbol(); - TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; - - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArgumentsOrTypeParameters(); - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { - if (!this.canEmitDeclarations(interfaceDecl)) { - return; - } - - var interfaceName = interfaceDecl.identifier.text(); - this.emitDeclarationComments(interfaceDecl); - var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); - this.emitDeclFlags(interfaceDecl, "interface"); - this.declFile.Write(interfaceName); - - this.emitTypeParameters(interfaceDecl.typeParameterList); - this.emitHeritageClauses(interfaceDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - - this.emitSeparatedList(interfaceDecl.body.typeMembers); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); - var importSymbol = importDecl.getSymbol(); - var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); - - if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - if (isExportedImportDecl) { - this.declFile.Write("export "); - } - this.declFile.Write("import "); - this.declFile.Write(importDeclAST.identifier.text() + " = "); - if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); - } else { - this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - this.emitDeclarationComments(moduleDecl); - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclFlags(moduleDecl, "enum"); - this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.enumElements.nonSeparatorCount(); - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); - var enumElement = memberDecl; - var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); - this.emitDeclarationComments(enumElement); - this.emitIndent(); - this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue !== null) { - this.declFile.Write(" = " + enumElementDecl.constantValue); - } - this.declFile.WriteLine(","); - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclarationComments(moduleDecl); - - var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); - this.emitDeclFlags(name, "module"); - - if (moduleDecl.stringLiteral) { - this.declFile.Write(moduleDecl.stringLiteral.text()); - } else { - this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); - } - - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - - this.emitDeclarationsForList(moduleDecl.moduleElements); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write(ast.identifier.text()); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { - if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { - return reference; - } - - var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); - var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); - return resolvedReferencePath; - }; - - DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { - if (this.emittedReferencePaths) { - return; - } - - var documents = []; - if (this.document.emitToOwnOutputFile()) { - var scriptReferences = this.document.referencedFiles; - var addedGlobalDocument = false; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { - documents = documents.concat(document); - - if (!document.isDeclareFile() && document.isExternalModule()) { - addedGlobalDocument = true; - } - } - } - } else { - var fileNames = this.compiler.fileNames(); - for (var i = 0; i < fileNames.length; i++) { - var doc = this.compiler.getDocument(fileNames[i]); - if (!doc.isDeclareFile() && !doc.isExternalModule()) { - var scriptReferences = doc.referencedFiles; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.isDeclareFile() || document.isExternalModule())) { - for (var k = 0; k < documents.length; k++) { - if (documents[k] === document) { - break; - } - } - - if (k === documents.length) { - documents = documents.concat(document); - } - } - } - } - } - } - - var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; - for (var i = 0; i < documents.length; i++) { - var document = documents[i]; - var declFileName; - if (document.isDeclareFile()) { - declFileName = document.fileName; - } else { - declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } - - declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); - this.declFile.WriteLine('/// '); - } - - this.emittedReferencePaths = true; - }; - - DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { - this.emitReferencePaths(sourceUnit); - this.emitDeclarationsForList(sourceUnit.moduleElements); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - if (keys[name]) { - this.add(name); - } - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] !== array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateEnumConstants = false; - this.removeComments = false; - this.watch = false; - this.noResolve = false; - this.allowAutomaticSemicolonInsertion = true; - this.noImplicitAny = false; - this.noLib = false; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Unspecified */; - this.outFileOption = ""; - this.outDirOption = ""; - this.mapSourceFiles = false; - this.mapRoot = ""; - this.sourceRoot = ""; - this.generateDeclarationFiles = false; - 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, createFileLog) { - this._propagateEnumConstants = propagateEnumConstants; - this._removeComments = removeComments; - this._watch = watch; - this._noResolve = noResolve; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._noImplicitAny = noImplicitAny; - this._noLib = noLib; - this._codeGenTarget = codeGenTarget; - this._moduleGenTarget = moduleGenTarget; - this._outFileOption = outFileOption; - this._outDirOption = outDirOption; - this._mapSourceFiles = mapSourceFiles; - this._mapRoot = mapRoot; - this._sourceRoot = sourceRoot; - this._generateDeclarationFiles = generateDeclarationFiles; - this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this._gatherDiagnostics = gatherDiagnostics; - this._codepage = codepage; - this._createFileLog = createFileLog; - } - ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { - return this._propagateEnumConstants; - }; - ImmutableCompilationSettings.prototype.removeComments = function () { - return this._removeComments; - }; - ImmutableCompilationSettings.prototype.watch = function () { - return this._watch; - }; - ImmutableCompilationSettings.prototype.noResolve = function () { - return this._noResolve; - }; - ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - ImmutableCompilationSettings.prototype.noImplicitAny = function () { - return this._noImplicitAny; - }; - ImmutableCompilationSettings.prototype.noLib = function () { - return this._noLib; - }; - ImmutableCompilationSettings.prototype.codeGenTarget = function () { - return this._codeGenTarget; - }; - ImmutableCompilationSettings.prototype.moduleGenTarget = function () { - return this._moduleGenTarget; - }; - ImmutableCompilationSettings.prototype.outFileOption = function () { - return this._outFileOption; - }; - ImmutableCompilationSettings.prototype.outDirOption = function () { - return this._outDirOption; - }; - ImmutableCompilationSettings.prototype.mapSourceFiles = function () { - return this._mapSourceFiles; - }; - ImmutableCompilationSettings.prototype.mapRoot = function () { - return this._mapRoot; - }; - ImmutableCompilationSettings.prototype.sourceRoot = function () { - return this._sourceRoot; - }; - ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { - return this._generateDeclarationFiles; - }; - ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { - return this._useCaseSensitiveFileResolution; - }; - ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { - return this._gatherDiagnostics; - }; - ImmutableCompilationSettings.prototype.codepage = function () { - return this._codepage; - }; - ImmutableCompilationSettings.prototype.createFileLog = function () { - return this._createFileLog; - }; - - ImmutableCompilationSettings.defaultSettings = function () { - if (!ImmutableCompilationSettings._defaultSettings) { - ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); - } - - return ImmutableCompilationSettings._defaultSettings; - }; - - 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, 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, "_")) { - resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; - } - } - - return result; - }; - return ImmutableCompilationSettings; - })(); - TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; - - PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; - - PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; - - PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; - - PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - function hasModifier(modifiers, flag) { - for (var i = 0, n = modifiers.length; i < n; i++) { - if (TypeScript.hasFlag(modifiers[i], flag)) { - return true; - } - } - - return false; - } - TypeScript.hasModifier = hasModifier; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; - PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; - - 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.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"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var pullDeclID = 0; - var sentinelEmptyPullDeclArray = []; - - var PullDecl = (function () { - 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; - this.childDeclTypeParameterCache = null; - this.name = declName; - this.kind = kind; - this.flags = declFlags; - this.semanticInfoChain = semanticInfoChain; - - if (displayName !== this.name) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.fileName = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentPath = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.isExternalModule = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getEnclosingDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { - var decl = this; - while (decl) { - switch (decl.kind) { - default: - return decl; - case 512 /* Variable */: - case 8192 /* TypeParameter */: - case 2048 /* Parameter */: - case 128 /* TypeAlias */: - case 67108864 /* EnumMember */: - } - - decl = decl.getParentDecl(); - } - - TypeScript.Debug.fail(); - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.name : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (symbol) { - this.semanticInfoChain.setSymbolForDecl(this, symbol); - }; - - 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 */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.semanticInfoChain.getSymbolForDecl(this); - }; - - PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain.getSymbolForDecl(this); - return !!symbol; - }; - - PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); - }; - - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(); - return this.semanticInfoChain.getSignatureSymbolForDecl(this); - }; - - PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); - return !!signatureSymbol; - }; - - PullDecl.prototype.setFlags = function (flags) { - this.flags = flags; - }; - - PullDecl.prototype.setFlag = function (flags) { - this.flags |= flags; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - valDecl.containerDecl = this; - }; - - PullDecl.prototype.getValueDecl = function () { - return this.synthesizedValDecl; - }; - - PullDecl.prototype.getContainerDecl = function () { - return this.containerDecl; - }; - - PullDecl.prototype.getChildDeclCache = function (declKind) { - if (declKind === 8192 /* TypeParameter */) { - if (!this.childDeclTypeParameterCache) { - this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeParameterCache; - } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { - if (!this.childDeclNamespaceCache) { - this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { - if (!this.childDeclTypeCache) { - this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeCache; - } else { - if (!this.childDeclValueCache) { - this.childDeclValueCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclValueCache; - } - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.kind === 8192 /* TypeParameter */) { - if (!this.typeParameters) { - this.typeParameters = []; - } - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - if (!this.childDecls) { - this.childDecls = []; - } - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.name; - - if (!(childDecl.kind & 7340032 /* SomeSignature */)) { - var cache = this.getChildDeclCache(childDecl.kind); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - } - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cacheVal = null; - - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; - } else if (searchKind & 164 /* SomeContainer */) { - cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; - } else { - cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; - } - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; - - if (cacheVal) { - return cacheVal; - } - } - - return sentinelEmptyPullDeclArray; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - if (!this.declGroups) { - this.declGroups = TypeScript.createIntrinsicsObject(); - } - - var declGroup = this.declGroups[decl.name]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.name); - declGroup.addDecl(decl); - this.declGroups[decl.name] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = null; - - if (this.declGroups) { - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - if (declGroups === null) { - declGroups = []; - } - - declGroups.push(this.declGroups[declName].getDecls()); - } - } - } - - return declGroups || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.hasBeenBound = function () { - return this.hasSymbol() || this.hasSignatureSymbol(); - }; - - PullDecl.prototype.isSynthesized = function () { - return false; - }; - - PullDecl.prototype.ast = function () { - return this.semanticInfoChain.getASTForDecl(this); - }; - - PullDecl.prototype.isRootDecl = function () { - throw TypeScript.Errors.abstract(); - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - var RootPullDecl = (function (_super) { - __extends(RootPullDecl, _super); - 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; - } - RootPullDecl.prototype.fileName = function () { - return this._fileName; - }; - - RootPullDecl.prototype.getParentPath = function () { - return [this]; - }; - - RootPullDecl.prototype.getParentDecl = function () { - return null; - }; - - RootPullDecl.prototype.isExternalModule = function () { - return this._isExternalModule; - }; - - 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, addToParent) { - if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); - this.parentDecl = null; - this.parentPath = null; - - this.parentDecl = parentDecl; - 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._rootDecl.fileName(); - }; - - NormalPullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - NormalPullDecl.prototype.getParentPath = function () { - if (!this.parentPath) { - var path = [this]; - var parentDecl = this.parentDecl; - - while (parentDecl) { - if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { - path.unshift(parentDecl); - } - - parentDecl = parentDecl.getParentDecl(); - } - - this.parentPath = path; - } - - return this.parentPath; - }; - - NormalPullDecl.prototype.isExternalModule = function () { - return false; - }; - - 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) { - _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); - this.constantValue = null; - } - return PullEnumElementDecl; - })(NormalPullDecl); - TypeScript.PullEnumElementDecl = PullEnumElementDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { - if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(NormalPullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - var PullSynthesizedDecl = (function (_super) { - __extends(PullSynthesizedDecl, _super); - function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { - _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); - this.semanticInfoChain = semanticInfoChain; - } - PullSynthesizedDecl.prototype.isSynthesized = function () { - return true; - }; - - PullSynthesizedDecl.prototype.fileName = function () { - return this._rootDecl ? this._rootDecl.fileName() : ""; - }; - return PullSynthesizedDecl; - })(NormalPullDecl); - TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.name === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullSymbolID = 0; - TypeScript.sentinelEmptyArray = []; - - var PullSymbol = (function () { - function PullSymbol(name, declKind) { - this.pullSymbolID = ++TypeScript.pullSymbolID; - this._container = null; - this.type = null; - this._declarations = null; - this.isResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isVarArg = false; - this.rootSymbol = null; - this._enclosingSignature = null; - this._docComments = null; - this.isPrinting = false; - this.name = name; - this.kind = declKind; - } - PullSymbol.prototype.isAny = function () { - return false; - }; - - PullSymbol.prototype.isType = function () { - return (this.kind & 58728795 /* SomeType */) !== 0; - }; - - PullSymbol.prototype.isTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) !== 0; - }; - - PullSymbol.prototype.isArrayNamedTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.kind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isInterface = function () { - return this.kind === 16 /* Interface */; - }; - - PullSymbol.prototype.isMethod = function () { - return this.kind === 65536 /* Method */; - }; - - PullSymbol.prototype.isProperty = function () { - return this.kind === 4096 /* Property */; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { - if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } - if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } - var scopeDeclarations = scopeSymbol.getDeclarations(); - var scopeSymbolAliasesToLookIn = []; - - for (var i = 0; i < scopeDeclarations.length; i++) { - var scopeDecl = scopeDeclarations[i]; - if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { - visitedScopeDeclarations.push(scopeDecl); - - var childDecls = scopeDecl.getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - var childDecl = childDecls[j]; - if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { - var symbol = childDecl.getSymbol(); - - if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { - aliasSymbols.push(symbol); - return aliasSymbols; - } - - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { - scopeSymbolAliasesToLookIn.push(symbol); - } - } - } - } - } - - for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { - var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; - - aliasSymbols.push(scopeSymbolAlias); - var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); - if (result) { - return result; - } - - aliasSymbols.pop(); - } - - return null; - }; - - PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { - var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); - return symbols; - } - - return null; - }; - - PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { - if (aliasSymbol) { - if (aliasSymbol.assignedValue()) { - return false; - } - - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { - return false; - } - - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { - return false; - } - - return true; - } - - return false; - }; - - PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { - if (scopeSymbol) { - 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); - return internalAliases[0]; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { - if (!skipInternalAlias) { - var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); - if (internalAlias) { - return aliasNameGetter(internalAlias); - } - } - - var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); - - if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - 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 aliasFullName; - } - - return null; - }; - - PullSymbol.prototype._getResolver = function () { - TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain.getResolver(); - }; - - PullSymbol.prototype._resolveDeclaredSymbol = function () { - return this._getResolver().resolveDeclaredSymbol(this); - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getName(); - }); - return aliasName || this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getDisplayName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getDisplayName(); - }, skipInternalAliasName); - if (aliasDisplayName) { - return aliasDisplayName; - } - - var decls = this.getDeclarations(); - var name = decls.length && decls[0].getDisplayName(); - - return (name && name.length) ? name : this.name; - }; - - PullSymbol.prototype.getIsSpecialized = function () { - return false; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - 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; - }; - - PullSymbol.prototype.setEnclosingSignature = function (signature) { - this._enclosingSignature = signature; - }; - - PullSymbol.prototype.getEnclosingSignature = function () { - return this._enclosingSignature; - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - if (!this._declarations) { - this._declarations = [decl]; - } else { - this._declarations[this._declarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this._declarations) { - this._declarations = []; - } - - return this._declarations; - }; - - PullSymbol.prototype.hasDeclaration = function (decl) { - if (!this._declarations) { - return false; - } - - return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { - return eachDecl === decl; - }); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - if (this.rootSymbol) { - return; - } - - this._container = containerSymbol; - }; - - PullSymbol.prototype.getContainer = function () { - if (this.rootSymbol) { - return this.rootSymbol.getContainer(); - } - - return this._container; - }; - - PullSymbol.prototype.setResolved = function () { - this.isResolved = true; - this.inResolution = false; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.isResolved = false; - this.inResolution = false; - }; - - PullSymbol.prototype.anyDeclHasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (TypeScript.hasFlag(declarations[i].flags, flag)) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!TypeScript.hasFlag(declarations[i].flags, flag)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = node.getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - var nodeKind = node.kind; - if (nodeKind === 2048 /* Parameter */) { - break; - } else { - node = node.getContainer(); - } - } - return path; - }; - - PullSymbol.prototype.findCommonAncestorPath = function (b) { - var aPath = this.pathToRoot(); - if (aPath.length === 1) { - return aPath; - } - - var bPath; - if (b) { - bPath = b.pathToRoot(); - } else { - return aPath; - } - - 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; - } - } - } - if (commonNodeIndex >= 0) { - break; - } - } - - if (commonNodeIndex >= 0) { - return aPath.slice(0, commonNodeIndex); - } else { - return aPath; - } - }; - - PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var str = this.getNameAndTypeName(scopeSymbol); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var _this = this; - var path = this.pathToRoot(); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol === _this ? null : symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findCommonAncestorPath(scopeSymbol); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].kind; - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.type; - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - 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 */) { - var signatures = type.getCallSignatures(); - 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); - return typeName; - } - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.type; - var nameStr = this.getDisplayName(scopeSymbol); - if (type) { - nameStr = nameStr + (this.isOptional ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return TypeScript.MemberName.create(nameStr); - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - - inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); - - var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); - inIsExternallyVisibleSymbols.pop(); - - return result; - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.kind; - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.rootSymbol) { - return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); - } - - if (this.isType()) { - var associatedContainerSymbol = this.getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.anyDeclHasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - var decls = this.getDeclarations(); - if (decls.length) { - var parentDecl = decls[0].getParentDecl(); - if (parentDecl) { - var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind === 1 /* Script */) { - return true; - } - - return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); - } - } - - return true; - } - - 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 */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { - var ast = decl.ast(); - - if (ast) { - 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.ASTHelpers.docComments(ast); - } - } - - return []; - }; - - PullSymbol.prototype.getDocCommentArray = function (symbol) { - var docComments = []; - if (!symbol) { - return docComments; - } - - 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 */) { - continue; - } - docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); - } - return docComments; - }; - - PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { - if (classSymbol.getHasDefaultConstructor()) { - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); - } - } - - return classSymbol.type.getConstructSignatures()[0]; - }; - - PullSymbol.prototype.getDocCommentText = function (comments) { - var docCommentText = new Array(); - for (var c = 0; c < comments.length; c++) { - var commentText = this.getDocCommentTextValue(comments[c]); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - PullSymbol.prototype.getDocCommentTextValue = function (comment) { - return this.cleanJSDocComment(comment.fullText()); - }; - - PullSymbol.prototype.docComments = function (useConstructorAsClass) { - var decls = this.getDeclarations(); - 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 */) { - var classSymbol = this.returnType; - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - docComments = extendedTypes[0].getConstructorMethod().docComments(); - } else { - docComments = ""; - } - } else if (this.kind === 2048 /* Parameter */) { - var parameterComments = []; - - var funcContainer = this.getEnclosingSignature(); - var funcDocComments = this.getDocCommentArray(funcContainer); - var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); - if (paramComment != "") { - parameterComments.push(paramComment); - } - - var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); - if (paramSelfComment != "") { - parameterComments.push(paramSelfComment); - } - docComments = parameterComments.join("\n"); - } else { - var getSymbolComments = true; - if (this.kind === 16777216 /* FunctionType */) { - var functionSymbol = this.getFunctionSymbol(); - - if (functionSymbol) { - docComments = functionSymbol._docComments || ""; - getSymbolComments = false; - } else { - var declarationList = this.getDeclarations(); - if (declarationList.length > 0) { - docComments = declarationList[0].getSymbol()._docComments || ""; - getSymbolComments = false; - } - } - } - if (getSymbolComments) { - docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments === "") { - if (this.kind === 1048576 /* CallSignature */) { - var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { - docComments = callTypeSymbol.docComments(); - } - } - } - } - } - - this._docComments = docComments; - } - - return this._docComments; - }; - - PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].fullText(); - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!this.isSpaceChar(commentContents, j)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - - PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = new Array(); - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.start; - for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.end); - } - - var newCleanPos = this.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - PullSymbol.prototype.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = this.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - start: nonSpaceIndex, - end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - 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.returnType = null; - this.functionType = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this._allowedToReferenceTypeParameters = null; - this._instantiationCache = null; - this.hasBeenChecked = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return this._isDefinition; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - 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) { - this.parameters = []; - } - - this.parameters[this.parameters.length] = parameter; - this.hasOptionalParam = isOptional; - - if (!parameter.getEnclosingSignature()) { - parameter.setEnclosingSignature(this); - } - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this._typeParameters) { - this._typeParameters = []; - } - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - 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 = []; - } - - return this._typeParameters; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - - for (var i = 0; i < this.getTypeParameters().length; i++) { - this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; - } - } - - memberSymbol = this._memberTypeParameterNameCache[name]; - - 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; - this._stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].type; - if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { - this._stringConstantOverload = true; - } - } - } - - 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); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - if (!signatures) { - return result; - } - - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.parameters; - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].type; - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].isVarArg; - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - if (this.returnType) { - builder.add(this.returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - 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 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 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 wrappingTypeParameterID; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { - if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - - var parameters = this.parameters; - - for (var i = 0; i < parameters.length; i++) { - if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - } - - return false; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol(name, kind) { - _super.call(this, name, kind); - this._members = TypeScript.sentinelEmptyArray; - this._enclosedMemberTypes = null; - this._enclosedMemberContainers = null; - this._typeParameters = null; - this._allowedToReferenceTypeParameters = null; - this._specializedVersionsOfThisType = null; - this._arrayVersionOfThisType = null; - this._implementedTypes = null; - this._extendedTypes = null; - this._typesThatExplicitlyImplementThisType = null; - this._typesThatExtendThisType = null; - this._callSignatures = null; - this._allCallSignatures = null; - this._constructSignatures = null; - this._indexSignatures = null; - this._allIndexSignatures = null; - this._allIndexSignaturesOfAugmentedType = null; - this._memberNameCache = null; - this._enclosedTypeNameCache = null; - this._enclosedContainerCache = null; - this._typeParameterNameCache = null; - this._containedNonMemberNameCache = null; - this._containedNonMemberTypeNameCache = null; - this._containedNonMemberContainerCache = null; - this._simpleInstantiationCache = null; - this._complexInstantiationCache = null; - this._hasGenericSignature = false; - this._hasGenericMember = false; - this._hasBaseTypeConflict = false; - this._knownBaseTypeCount = 0; - this._associatedContainerTypeSymbol = null; - this._constructorMethod = null; - this._hasDefaultConstructor = false; - this._functionSymbol = null; - this._inMemberTypeNameEx = false; - this.inSymbolPrivacyCheck = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - this.typeReference = null; - this._widenedType = null; - this._isArrayNamedTypeReference = undefined; - this.type = this; - } - PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArrayNamedTypeReference === undefined) { - this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); - } - - return this._isArrayNamedTypeReference; - }; - - PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { - var typeArgs = this.getTypeArguments(); - if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { - var declaration = this.getDeclarations()[0]; - - if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.kind === 8 /* Class */ || (this._constructorMethod !== null); - }; - PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return this.kind === 33554432 /* ConstructorType */; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - PullTypeSymbol.prototype.isEnum = function () { - return this.kind === 64 /* Enum */; - }; - - PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { - return null; - }; - - PullTypeSymbol.prototype.isObject = function () { - 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 () { - return this._knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this._knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this._knownBaseTypeCount++; - }; - - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.hasMembers = function () { - if (this._members !== TypeScript.sentinelEmptyArray) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this._hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this._hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this._hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this._hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this._associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this._associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this._arrayVersionOfThisType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - return null; - }; - - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this._arrayVersionOfThisType = arrayType; - }; - - PullTypeSymbol.prototype.getFunctionSymbol = function () { - return this._functionSymbol; - }; - - PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { - if (symbol) { - this._functionSymbol = symbol; - } - }; - - PullTypeSymbol.prototype.findContainedNonMember = function (name) { - if (!this._containedNonMemberNameCache) { - return null; - } - - return this._containedNonMemberNameCache[name]; - }; - - PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberTypeNameCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberContainerCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol) { - if (!memberSymbol) { - return; - } - - memberSymbol.setContainer(this); - - if (!this._memberNameCache) { - this._memberNameCache = TypeScript.createIntrinsicsObject(); - } - - if (this._members === TypeScript.sentinelEmptyArray) { - this._members = []; - } - - this._members.push(memberSymbol); - this._memberNameCache[memberSymbol.name] = memberSymbol; - }; - - PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - if (!enclosedType) { - return; - } - - enclosedType.setContainer(this); - - if (!this._enclosedTypeNameCache) { - this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberTypes) { - this._enclosedMemberTypes = []; - } - - this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; - this._enclosedTypeNameCache[enclosedType.name] = enclosedType; - }; - - PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - if (!enclosedContainer) { - return; - } - - enclosedContainer.setContainer(this); - - if (!this._enclosedContainerCache) { - this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberContainers) { - this._enclosedMemberContainers = []; - } - - this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; - this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; - }; - - PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - if (!enclosedNonMember) { - return; - } - - enclosedNonMember.setContainer(this); - - if (!this._containedNonMemberNameCache) { - this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - if (!enclosedNonMemberType) { - return; - } - - enclosedNonMemberType.setContainer(this); - - if (!this._containedNonMemberTypeNameCache) { - this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - if (!enclosedNonMemberContainer) { - return; - } - - enclosedNonMemberContainer.setContainer(this); - - if (!this._containedNonMemberContainerCache) { - this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; - }; - - PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!typeParameter) { - return; - } - - if (!typeParameter.getContainer()) { - typeParameter.setContainer(this); - } - - if (!this._typeParameterNameCache) { - this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._typeParameters) { - this._typeParameters = []; - } - - this._typeParameters[this._typeParameters.length] = typeParameter; - this._typeParameterNameCache[typeParameter.getName()] = typeParameter; - }; - - PullTypeSymbol.prototype.getMembers = function () { - return this._members; - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this._hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this._hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this._constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this._constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - if (!this._typeParameters) { - return TypeScript.sentinelEmptyArray; - } - - 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 (typeArgumentMap) { - if (this.isTypeParameter()) { - return true; - } - - 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; - } else { - if (!this._complexInstantiationCache) { - this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); - } - - this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; - } - - if (!this._specializedVersionsOfThisType) { - this._specializedVersionsOfThisType = []; - } - - this._specializedVersionsOfThisType.push(specializedVersionOfThisType); - }; - - PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { - if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { - if (!this._simpleInstantiationCache) { - return null; - } - - var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; - return result || null; - } else { - if (!this._complexInstantiationCache) { - return null; - } - - if (this.getAllowedToReferenceTypeParameters().length == 0) { - return this; - } - - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; - return result || null; - } - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - if (!this._specializedVersionsOfThisType) { - return TypeScript.sentinelEmptyArray; - } - - return this._specializedVersionsOfThisType; - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return null; - }; - - PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeParameters(); - }; - - PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { - if (!this._callSignatures) { - this._callSignatures = []; - } - - if (callSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - callSignature.functionType = this; - }; - - 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 = []; - } - - if (constructSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - 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 = []; - } - - this._indexSignatures[this._indexSignatures.length] = indexSignature; - - if (indexSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - indexSignature.functionType = this; - }; - - 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; - } - - var signatures = []; - - if (this._callSignatures) { - signatures = signatures.concat(this._callSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); - } - } - - this._allCallSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return this._constructSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnConstructSignatures = function () { - return this._constructSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function () { - var signatures = []; - - if (this._constructSignatures) { - signatures = signatures.concat(this._constructSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); - } - } - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return this._indexSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnIndexSignatures = function () { - return this._indexSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function () { - if (this._allIndexSignatures) { - return this._allIndexSignatures; - } - - var signatures = []; - - if (this._indexSignatures) { - signatures = signatures.concat(this._indexSignatures); - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); - } - } - - this._allIndexSignatures = signatures; - - 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; - } - - if (!this._implementedTypes) { - this._implementedTypes = []; - } - - this._implementedTypes[this._implementedTypes.length] = implementedType; - - implementedType.addTypeThatExplicitlyImplementsThisType(this); - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - if (!this._implementedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._implementedTypes; - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!extendedType) { - return; - } - - if (!this._extendedTypes) { - this._extendedTypes = []; - } - - this._extendedTypes[this._extendedTypes.length] = extendedType; - - extendedType.addTypeThatExtendsThisType(this); - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - if (!this._extendedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._extendedTypes; - }; - - PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - return this._typesThatExtendThisType; - }; - - PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - return this._typesThatExplicitlyImplementThisType; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { - return true; - } - - if (TypeScript.ArrayUtilities.contains(visited, this)) { - return true; - } - - visited.push(this); - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - visited.pop(); - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.kind === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - var memberSymbol = null; - - if (this._memberNameCache) { - memberSymbol = this._memberNameCache[name]; - } - - if (memberSymbol || !lookInParent) { - return memberSymbol; - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return null; - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedTypeNameCache) { - return null; - } - - memberSymbol = this._enclosedTypeNameCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedContainerCache) { - return null; - } - - memberSymbol = this._enclosedContainerCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - var allMembers = []; - - 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 */))) { - allMembers[allMembers.length] = member; - } - } - } - - if (this._extendedTypes) { - var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; - - for (var i = 0, n = this._extendedTypes.length; i < n; i++) { - var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - if (this.isContainer()) { - if (this._enclosedMemberTypes) { - for (var i = 0; i < this._enclosedMemberTypes.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberTypes[i]; - } - } - if (this._enclosedMemberContainers) { - for (var i = 0; i < this._enclosedMemberContainers.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberContainers[i]; - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - if (!this._typeParameterNameCache) { - return null; - } - - return this._typeParameterNameCache[name]; - }; - - PullTypeSymbol.prototype.setResolved = function () { - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArgumentsOrTypeParameters(); - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); - }; - - 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 !== "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); - return s; - }; - - 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, "", "[]"); - } - - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - if (skipTypeParametersInName) { - return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); - } else { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - - var typars = this.getTypeArgumentsOrTypeParameters(); - builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - } - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getTypeOfSymbol = function () { - var associatedContainerType = this.getAssociatedContainerType(); - if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { - return associatedContainerType; - } - - var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; - } - - return null; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var typeOfSymbol = this.getTypeOfSymbol(); - if (typeOfSymbol) { - var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); - return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); - } - - if (this._inMemberTypeNameEx) { - return TypeScript.MemberName.create("any"); - } - - this._inMemberTypeNameEx = true; - - var allMemberNames = new TypeScript.MemberNameArray(); - 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()) { - var methodCallSignatures = members[i].type.getCallSignatures(); - var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); - ; - var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); - allMemberNames.addAll(methodMemberNames); - } else { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - if (memberTypeName.isArray() && memberTypeName.delim === delim) { - allMemberNames.addAll(memberTypeName.entries); - } else { - allMemberNames.add(memberTypeName); - } - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - this._inMemberTypeNameEx = false; - - return allMemberNames; - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - return 2 /* Closed */; - }; - - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; - }; - - PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - var type = this; - - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { - return type.pullSymbolID; - } - - var constraint = type.getConstraint(); - var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; - return wrappingTypeParameterID; - } - - if (type.inWrapCheck) { - return 0; - } - - 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; - - var typeArguments = type.getTypeArguments(); - - if (type.isGeneric() && !typeArguments) { - typeArguments = type.getTypeParameters(); - } - - if (typeArguments) { - for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { - wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); - } - } - } - - 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); - } - - wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); - } - - if (!skipTypeArgumentCheck) { - type.inWrapCheck = false; - } - - return wrappingTypeParameterID; - }; - - 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - 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(); - for (var i = 0; i < typeArguments.length; i++) { - if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { - continue; - } - - if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { - return true; - } - } - - 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); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - - this.isResolved = true; - } - PullPrimitiveTypeSymbol.prototype.isAny = function () { - 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 () { - return false; - }; - - 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; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(_anyType, name) { - _super.call(this, name); - 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); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullContainerSymbol = (function (_super) { - __extends(PullContainerSymbol, _super); - function PullContainerSymbol(name, kind) { - _super.call(this, name, kind); - this.instanceSymbol = null; - this.assignedValue = null; - this.assignedType = null; - this.assignedContainer = null; - } - PullContainerSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this.assignedValue = symbol; - }; - - PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { - return this.assignedValue; - }; - - PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this.assignedType = type; - }; - - PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this.assignedType; - }; - - PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this.assignedContainer = container; - }; - - PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this.assignedContainer; - }; - - PullContainerSymbol.prototype.hasExportAssignment = function () { - return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; - }; - - PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { - return true; - } - - var moduleSymbol = containerSymbol; - var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - - PullContainerSymbol.prototype.getInstanceType = function () { - return this.instanceSymbol ? this.instanceSymbol.type : null; - }; - return PullContainerSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerSymbol = PullContainerSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 128 /* TypeAlias */); - this._assignedValue = null; - this._assignedType = null; - 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; - }; - - PullTypeAliasSymbol.prototype.isUsedAsValue = function () { - this._resolveDeclaredSymbol(); - return this._isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { - this._typeUsedExternally = true; - }; - - PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { - this._isUsedInExportAlias = true; - if (this.linkedAliasSymbols) { - this.linkedAliasSymbols.forEach(function (s) { - return s.setIsUsedInExportedAlias(); - }); - } - }; - - 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(); - }); - } - }; - - PullTypeAliasSymbol.prototype.assignedValue = function () { - this._resolveDeclaredSymbol(); - return this._assignedValue; - }; - - PullTypeAliasSymbol.prototype.assignedType = function () { - this._resolveDeclaredSymbol(); - return this._assignedType; - }; - - PullTypeAliasSymbol.prototype.assignedContainer = function () { - this._resolveDeclaredSymbol(); - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { - this._assignedValue = symbol; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (this._assignedValue) { - return this._assignedValue; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { - this._assignedType = type; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedType) { - if (this._assignedType.isAlias()) { - this.retrievingExportAssignment = true; - var sym = this._assignedType.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - } else if (this._assignedType !== this._assignedContainer) { - return this._assignedType; - } - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { - this._assignedContainer = container; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this._assignedType) { - return this._assignedType.getMembers(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this._assignedType) { - return this._assignedType.getCallSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this._assignedType) { - return this._assignedType.getConstructSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this._assignedType) { - return this._assignedType.getIndexSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this._assignedType) { - return this._assignedType.findMember(name, true); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedContainer(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { - if (this._assignedType) { - return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); - } - - return TypeScript.sentinelEmptyArray; - }; - return PullTypeAliasSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - - var PullTypeParameterSymbol = (function (_super) { - __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name) { - _super.call(this, name, 8192 /* TypeParameter */); - this._constraint = null; - } - PullTypeParameterSymbol.prototype.isTypeParameter = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { - this._constraint = constraintType; - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - 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(); - } - - return _super.prototype.getCallSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getConstructSignatures = function () { - if (this._constraint) { - return this._constraint.getConstructSignatures(); - } - - return _super.prototype.getConstructSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getIndexSignatures = function () { - if (this._constraint) { - return this._constraint.getIndexSignatures(); - } - - return _super.prototype.getIndexSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this._getterSymbol = null; - this._setterSymbol = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - if (!setter) { - return; - } - - this._setterSymbol = setter; - }; - - PullAccessorSymbol.prototype.getSetter = function () { - return this._setterSymbol; - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - if (!getter) { - return; - } - - this._getterSymbol = getter; - }; - - PullAccessorSymbol.prototype.getGetter = function () { - return this._getterSymbol; - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { - var substitution = ""; - var members = null; - - 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 getIDForTypeSubstitutionsOfType(type) { - var structure; - if (type.isError()) { - structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); - } else if (!type.isNamedTypeSymbol()) { - structure = getIDForTypeSubstitutionsFromObjectType(type); - } - - if (!structure) { - structure = type.pullSymbolID + "#"; - } - - return structure; - } - - function getIDForTypeSubstitutionsFromObjectType(type) { - if (type.isResolved) { - var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); - TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); - } - - return null; - } - - var GetIDForTypeSubStitutionWalker = (function () { - function GetIDForTypeSubStitutionWalker() { - this.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"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; - })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); - 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._inferredTypeAfterFixing = null; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - 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 TypeArgumentInferenceContext = (function () { - function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { - this.resolver = resolver; - this.context = context; - this.signatureBeingInferred = signatureBeingInferred; - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - this.candidateCache = []; - var typeParameters = signatureBeingInferred.getTypeParameters(); - for (var i = 0; i < typeParameters.length; i++) { - this.addInferenceRoot(typeParameters[i]); - } - } - TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { - return true; - } else { - this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); - return false; - } - }; - - TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache.release(); - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - }; - - TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.pullSymbolID]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.pullSymbolID] = info; - } - }; - - TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.pullSymbolID]; - }; - - TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { - var info = this.getInferenceInfo(param); - - if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { - info.addCandidate(candidate); - } - }; - - 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); - } - }; - - 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]; - - info.fixTypeParameter(this.resolver, this.context); - - for (var i = 0; i < results.length; i++) { - if (results[i].type === info.typeParameter) { - results[i].type = info._inferredTypeAfterFixing; - } - } - - results.push(info._inferredTypeAfterFixing); - } - - return results; - }; - - TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { - throw TypeScript.Errors.abstract(); - }; - return TypeArgumentInferenceContext; - })(); - 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, isInferentiallyTyping, typeArgumentInferenceContext) { - this.contextualType = contextualType; - this.provisional = provisional; - this.isInferentiallyTyping = isInferentiallyTyping; - this.typeArgumentInferenceContext = typeArgumentInferenceContext; - this.provisionallyTypedSymbols = []; - this.hasProvisionalErrors = false; - this.astSymbolMap = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].setUnresolved(); - } - }; - - PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { - if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } - if (typeof fileName === "undefined") { fileName = null; } - this.resolver = resolver; - this.inTypeCheck = inTypeCheck; - 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"); - this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); - } - } - PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { - if (!this.inProvisionalResolution()) { - this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); - } - }; - - PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { - return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); - }; - - PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); - }; - - 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(); - - if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; - } - - return tc; - }; - - PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { - return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; - }; - - PullTypeResolutionContext.prototype.getContextualType = function () { - var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - 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); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); - } - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { - if (diagnostic) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; - } else if (this.inTypeCheck && this.resolver) { - this.resolver.semanticInfoChain.addDiagnostic(diagnostic); - } - } - }; - - PullTypeResolutionContext.prototype.typeCheck = function () { - return this.inTypeCheck && !this.inProvisionalResolution(); - }; - - PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { - this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); - }; - - PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - var typeContext = this.contextStack[i]; - if (!typeContext.provisional) { - break; - } - - var symbol = typeContext.getSymbolForAST(ast); - if (symbol) { - return symbol; - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OverloadApplicabilityStatus; - (function (OverloadApplicabilityStatus) { - OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; - })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - this.diagnosticsFromOverloadResolution = []; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var MemberWithBaseOrigin = (function () { - function MemberWithBaseOrigin(memberSymbol, baseOrigin) { - this.memberSymbol = memberSymbol; - this.baseOrigin = baseOrigin; - } - return MemberWithBaseOrigin; - })(); - - var SignatureWithBaseOrigin = (function () { - function SignatureWithBaseOrigin(signature, baseOrigin) { - this.signature = signature; - this.baseOrigin = baseOrigin; - } - return SignatureWithBaseOrigin; - })(); - - var InheritedIndexSignatureInfo = (function () { - function InheritedIndexSignatureInfo() { - } - return InheritedIndexSignatureInfo; - })(); - - 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(); - return CompilerReservedName[nameText]; - } - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this._cachedAnyTypeArgs = null; - this.typeCheckCallBacks = []; - this.postTypeCheckWorkitems = []; - this._cachedFunctionArgumentsSymbol = null; - 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 */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getArrayNamedType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedRegExpInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { - if (!this._cachedFunctionArgumentsSymbol) { - this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); - this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; - this._cachedFunctionArgumentsSymbol.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); - functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); - this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - } - - 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); - }; - - PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { - return context.canTypeCheckAST(ast); - }; - - PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { - if (context && context.inProvisionalResolution()) { - context.setSymbolForAST(ast, symbol); - } else { - this.semanticInfoChain.setSymbolForAST(ast, symbol); - } - }; - - PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { - var symbol = this.semanticInfoChain.getSymbolForAST(ast); - - if (!symbol) { - if (context && context.inProvisionalResolution()) { - symbol = context.getSymbolForAST(ast); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { - if (typeof name === "undefined") { name = null; } - return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = decl.getParentPath(); - - if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; - var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; - - if (isContainer && containerType) { - if (symbol.anyDeclHasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - 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 & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - } - - if (parent.kind & 164 /* SomeContainer */) { - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - member = childDecls[0].getSymbol(); - - if (!member) { - member = childDecls[0].getSignatureSymbol(); - } - return this.getExportedMemberSymbol(member, parent); - } - - if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); - if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { - var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); - if (aliasSymbol) { - if ((declSearchKind & 58728795 /* SomeType */) !== 0) { - var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); - if (typeSymbol) { - return typeSymbol; - } - } else { - var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - return valueSymbol; - } - } - - return aliasSymbol; - } - } - } - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var _this = this; - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - 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; - - if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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(); - - if (instanceSymbol) { - instanceType = instanceSymbol.type; - - childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().type; - - var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.kind & 1032192 /* SomeFunction */) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - return candidateSymbol; - } - - var alias = tryFindAlias(decl); - if (alias) { - return alias; - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - if (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) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - var declKind = decl.kind; - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = decl.getFunctionExpressionName(); - if (functionExpressionName) { - result.push(decl); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - } - } - - var topLevelDecls = this.semanticInfoChain.topLevelDecls(); - for (var i = 0, n = topLevelDecls.length; i < n; i++) { - var topLevelDecl = topLevelDecls[i]; - if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { - continue; - } - - if (!topLevelDecl.isExternalModule()) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.kind & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - 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 */ || lhs.kind === 64 /* Enum */)) { - return null; - } - - var lhsType = lhs.type; - if (!lhsType) { - return null; - } - - this.resolveDeclaredSymbol(lhsType, context); - - if (lhsType.isContainer() && lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - var memberVisibilty = 2 /* externallyVisible */; - var containerSymbol = lhsType; - if (containerSymbol.kind === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = enclosingDecl.getParentPath(); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { - memberVisibilty = 1 /* internallyVisible */; - break; - } - } - } - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - var members = []; - - if (lhsType.isContainer()) { - var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); - if (exportedAssignedContainerSymbol) { - lhsType = exportedAssignedContainerSymbol; - } - } - - lhsType = this.getApparentType(lhsType); - - 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); - } - - 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 */)); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { - var originalIdText = idText; - var symbol = null; - - if (TypeScript.isRelative(originalIdText)) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - symbol = this.semanticInfoChain.findExternalModule(path + idText); - } else { - idText = originalIdText; - - symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); - - if (!symbol) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - symbol = this.semanticInfoChain.findExternalModule(path + idText); - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { - if (!symbol || symbol.isResolved || symbol.isTypeReference()) { - return symbol; - } - - if (!context) { - context = new TypeScript.PullTypeResolutionContext(this); - } - - return this.resolveDeclaredSymbolWorker(symbol, context); - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { - if (!symbol || symbol.isResolved) { - return symbol; - } - - if (symbol.inResolution) { - if (!symbol.type && !symbol.isType()) { - symbol.type = this.semanticInfoChain.anyTypeSymbol; - } - - return symbol; - } - - var decls = symbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - var ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { - return symbol; - } - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); - var resolvedSymbol; - 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 */); - resolvedSymbol = this.resolveAST(ast, false, context); - } - - if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { - symbol.type = resolvedSymbol.type; - symbol.setResolved(); - } - } - - 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(); - this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { - return _this.resolveOtherDecl(otherDecl, context); - }); - }; - - PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { - var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); - var moduleSymbol = enclosingDecl.getSymbol(); - this.ensureAllSymbolsAreBound(moduleSymbol); - - this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); - this.resolveAST(sourceUnit.moduleElements, false, context); - - if (this.canTypeCheckAST(sourceUnit, context)) { - this.typeCheckSourceUnit(sourceUnit, context); - } - - return moduleSymbol; - }; - - 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) { - var containerDecl = this.semanticInfoChain.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - containerSymbol.setResolved(); - - this.resolveOtherDeclarations(ast, context); - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckEnumDeclaration(ast, context); - } - - return containerSymbol; - }; - - 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); - - this.typeCheckCallBacks.push(function (context) { - return _this.checkInitializersInEnumDeclarations(containerDecl, context); - }); - - if (!TypeScript.ASTHelpers.enumIsElided(ast)) { - this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { - 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; - - if (ast.stringLiteral) { - result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckModuleDeclaration(ast, context); - } - - return result; - }; - - PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { - if (containerSymbol) { - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - }; - - PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - this.ensureAllSymbolsAreBound(containerSymbol); - - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, context); - } - - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); - if (isLastName) { - this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); - } else if (sourceUnitAST) { - this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); - } - - containerSymbol.setResolved(); - - if (moduleDeclNameAST) { - this.resolveOtherDeclarations(moduleDeclNameAST, context); - } - - return containerSymbol; - }; - - 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 */) { - this.resolveExportAssignmentStatement(moduleElement, context); - return; - } - } - }; - - PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - var containerSymbol = containerDecl.getSymbol(); - - return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); - }; - - PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { - if (ast.stringLiteral) { - this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - }; - - PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { - var _this = this; - this.setTypeChecked(ast, context); - - if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { - this.resolveAST(ast.moduleElements, false, context); - } - - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - this.validateVariableDeclarationGroups(containerDecl, context); - - if (ast.stringLiteral) { - if (TypeScript.isRelative(ast.stringLiteral.valueText())) { - this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); - } - } - - 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) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() === 11 /* IdentifierName */) { - return true; - } else if (term.kind() === 121 /* QualifiedName */) { - var binex = term; - - if (binex.right.kind() === 11 /* IdentifierName */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { - if (!type.isGeneric()) { - return type; - } - - var typeParameters = type.getTypeArgumentsOrTypeParameters(); - - var typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); - } - - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; - - if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - var wasResolving = typeDeclSymbol.inResolution; - typeDeclSymbol.startResolving(); - - var typeRefDecls = typeDeclSymbol.getDeclarations(); - - for (var i = 0; i < typeRefDecls.length; i++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); - if (extendsClause) { - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - - if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - } - } - } - - 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()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); - var implementedType = this.resolveTypeReference(implementedTypeAST, context); - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - - if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addImplementedType(implementedType); - } - } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - - if (wasInBaseTypeResolution) { - typeDeclSymbol.inResolution = false; - - this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - _this.resolveClassDeclaration(classOrInterface, context); - } else { - _this.resolveInterfaceDeclaration(classOrInterface, context); - } - }); - - return typeDeclSymbol; - } - - this.setSymbolForAST(name, typeDeclSymbol, context); - this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - 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); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.type; - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - var parentConstructor = parentType ? parentType.getConstructorMethod() : null; - - if (parentConstructor) { - this.resolveDeclaredSymbol(parentConstructor, context); - var parentConstructorType = parentConstructor.type; - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - - if (!parentConstructSignatures.length) { - parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - parentConstructSignature.returnType = parentType; - parentConstructSignature.addTypeParametersFromReturnType(); - parentConstructorType.appendConstructSignature(parentConstructSignature); - parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - parentConstructSignatures = [parentConstructSignature]; - } - - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.parameters; - - 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); - } - - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - constructorSignature.addTypeParametersFromReturnType(); - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } - - if (!classDeclSymbol.isResolved) { - return classDeclSymbol; - } - - if (parentType) { - var parentConstructorSymbol = parentType.getConstructorMethod(); - - if (parentConstructorSymbol) { - var parentConstructorTypeSymbol = parentConstructorSymbol.type; - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - } - - this.resolveOtherDeclarations(classDeclAST, context); - } - - if (this.canTypeCheckAST(classDeclAST, context)) { - this.typeCheckClassDeclaration(classDeclAST, context); - } - - return classDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { - var _this = this; - 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); - }); - } - } - }; - - PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { - this.setTypeChecked(classDeclAST, context); - - var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - - this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); - this.resolveAST(classDeclAST.classElements, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); - this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); - - if (!classDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); - } - - this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); - }; - - PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { - this.checkThisCaptureVariableCollides(classDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { - var callSignatures = typeSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); - - if (interfaceDeclSymbol.isResolved) { - this.resolveOtherDeclarations(interfaceDeclAST, context); - - if (this.canTypeCheckAST(interfaceDeclAST, context)) { - this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); - } - } - - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { - this.setTypeChecked(interfaceDeclAST, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); - this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); - - 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) { - if (symbol) { - if (symbol.kind & kind) { - return symbol; - } - - if (symbol.isAlias()) { - this.resolveDeclaredSymbol(symbol, context); - - var alias = symbol; - if (kind & 164 /* SomeContainer */) { - return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728795 /* SomeType */) { - return alias.getExportAssignedTypeSymbol(); - } else if (kind & 68147712 /* SomeValue */) { - return alias.getExportAssignedValueSymbol(); - } - } - } - return null; - }; - - PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); - - return { - symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), - aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null - }; - }; - - PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { - var rhsName = identifier.valueText(); - if (rhsName.length === 0) { - return null; - } - - var moduleTypeSymbol = moduleSymbol.type; - var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); - var containerSymbol = memberSymbol.symbol; - var valueSymbol = null; - var typeSymbol = null; - var aliasSymbol = null; - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - aliasSymbol = memberSymbol.aliasSymbol; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - aliasSymbol = containerSymbol; - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return null; - } - - if (!valueSymbol) { - if (moduleTypeSymbol.getInstanceSymbol()) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); - valueSymbol = memberSymbol.symbol; - if (valueSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - } - - if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); - typeSymbol = memberSymbol.symbol; - if (typeSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); - return null; - } - - if (!typeSymbol && containerSymbol) { - typeSymbol = containerSymbol; - } - - return { - valueSymbol: valueSymbol, - typeSymbol: typeSymbol, - containerSymbol: containerSymbol, - aliasSymbol: aliasSymbol - }; - }; - - 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"); - - var moduleSymbol = null; - var moduleName; - - if (moduleNameExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = moduleNameExpr; - var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleContainer) { - moduleName = dottedNameAST.right.valueText(); - - moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; - if (!moduleSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); - } - } - } else { - var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); - var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); - - if (text.length > 0) { - var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); - moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); - if (moduleSymbol) { - 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]); - } - } - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - - var moduleReference = importStatementAST.moduleReference; - - var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; - - 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); - if (moduleSymbol) { - aliasedType = moduleSymbol.type; - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); - if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { - var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); - var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); - var instanceSymbol = aliasedType.getInstanceSymbol(); - - 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 { - importDeclSymbol.setAssignedValueSymbol(valueSymbol); - } - } - } else { - aliasedType = this.getNewErrorTypeSymbol(); - } - } else if (aliasExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = aliasExpr; - var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleSymbol) { - var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); - if (identifierResolution) { - importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); - importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); - importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); - return null; - } - } - } - - if (!aliasedType) { - importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); - } - - return aliasedType; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasedType = null; - - if (importDeclSymbol.isResolved) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - var declPath = enclosingDecl.getParentPath(); - - aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); - - if (!aliasedType) { - var path = importStatementAST.moduleReference.stringLiteral.text(); - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); - aliasedType = this.getNewErrorTypeSymbol(); - } - } else { - aliasedType = this.resolveInternalModuleReference(importStatementAST, context); - } - - if (aliasedType) { - if (!aliasedType.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); - if (!aliasedType.isError()) { - aliasedType = this.getNewErrorTypeSymbol(); - } - } - - if (aliasedType.isContainer()) { - importDeclSymbol.setAssignedContainerSymbol(aliasedType); - } - importDeclSymbol.setAssignedTypeSymbol(aliasedType); - - this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); - } - - importDeclSymbol.setResolved(); - - this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); - 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); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { - var _this = this; - this.setTypeChecked(importStatementAST, context); - - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (this.compilationSettings.noResolve()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); - } - - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - if (enclosingDecl.kind === 32 /* DynamicModule */) { - 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)); - } - } - } - } - - var checkPrivacy; - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind === 32 /* DynamicModule */) { - checkPrivacy = true; - } - } else { - checkPrivacy = true; - } - - if (checkPrivacy) { - var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); - - this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { - var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - - 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; - - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - - if (valueSymbol) { - this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { - var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - } - - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); - }; - - PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - 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); - } - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { - var id = exportAssignmentAST.identifier.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && parentSymbol.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); - return this.semanticInfoChain.anyTypeSymbol; - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - - var aliasSymbol = containerSymbol; - var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - } - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (valueSymbol) { - parentSymbol.setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - parentSymbol.setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - parentSymbol.setExportAssignedContainerSymbol(containerSymbol); - } - - this.resolveDeclaredSymbol(valueSymbol, context); - this.resolveDeclaredSymbol(typeSymbol, context); - this.resolveDeclaredSymbol(containerSymbol, context); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - var funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); - } - } - - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.setTypeChecked(funcDeclAST, context); - this.typeCheckFunctionOverloads(funcDeclAST, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - 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) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); - } else { - 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 (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(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - var contextualType = contextParam && contextParam.type; - var isImplicitAny = false; - - if (typeExpr) { - var typeRef = this.resolveTypeReference(typeExpr, context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); - typeRef = this.getNewErrorTypeSymbol(); - } - - contextualType = typeRef || contextualType; - } - if (contextualType) { - if (context.isInferentiallyTyping()) { - contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); - } - context.setTypeInContext(paramSymbol, contextualType); - } 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.propagateContextualType(contextualType); - } - - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - } - - if (!initExprSymbol || !initExprSymbol.type) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); - - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); - } - } else { - var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); - if (!contextualType) { - context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); - isImplicitAny = initTypeSymbol !== paramSymbol.type; - } else { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); - } - } - } - } - } - - if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - isImplicitAny = true; - } - - if (isImplicitAny && this.compilationSettings.noImplicitAny()) { - var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); - if (functionExpressionName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); - } - } - - if (canTypeCheckAST) { - this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { - var compilerReservedName = getCompilerReservedName(name); - switch (compilerReservedName) { - case 1 /* _this */: - this.postTypeCheckWorkitems.push(astWithName); - return; - - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; - - case 3 /* arguments */: - this.checkArgumentsCollides(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; - } - }; - - PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { - var enclosingAST = this.getASTForDecl(someFunctionDecl); - var nodeType = enclosingAST.kind(); - - 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); - } 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 */) { - var constructorDeclaration = enclosingAST; - 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 */) { - var functionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); - } - - return false; - }; - - PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); - } - } - } - }; - - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { - if (!isDeclaration || ast.kind() === 242 /* Parameter */) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - 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)); - } - } - } - } - }; - - PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { - var decl = this.semanticInfoChain.getDeclForAST(ast); - - if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - var nameText = name.valueText(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); - } - } - }; - - PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { - var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); - TypeScript.Debug.assert(interfaceDecl); - - var interfaceSymbol = interfaceDecl.getSymbol(); - TypeScript.Debug.assert(interfaceSymbol); - - if (objectType.typeMembers) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = objectType.typeMembers; - - for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { - memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); - memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); - - memberType = memberSymbol.type; - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - if (this.canTypeCheckAST(objectType, context)) { - this.typeCheckObjectTypeTypeReference(objectType, context); - } - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { - this.setTypeChecked(objectType, context); - var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); - var objectTypeSymbol = objectTypeDecl.getSymbol(); - - this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); - this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); - }; - - PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { - return this.resolveTypeReference(typeAnnotation.type, context); - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { - if (typeRef === null) { - return null; - } - - TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); - - var aliasType = null; - var type = this.computeTypeReferenceSymbol(typeRef, context); - - if (type.kind === 4 /* Container */) { - var container = type; - var instanceSymbol = container.getInstanceSymbol(); - - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { - type = instanceSymbol.type.getAssociatedContainerType(); - } - } - - if (type && type.isAlias()) { - aliasType = type; - type = aliasType.getExportAssignedTypeSymbol(); - } - - if (type && !type.isGeneric()) { - if (aliasType) { - this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); - } - } - - if (type && !type.isError()) { - 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 { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); - } - } - } - - if (this.canTypeCheckAST(typeRef, context)) { - this.setTypeChecked(typeRef, context); - } - - 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 */: - return this.semanticInfoChain.anyTypeSymbol; - case 61 /* BooleanKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - case 67 /* NumberKeyword */: - return this.semanticInfoChain.numberTypeSymbol; - case 69 /* StringKeyword */: - return this.semanticInfoChain.stringTypeSymbol; - case 41 /* VoidKeyword */: - return this.semanticInfoChain.voidTypeSymbol; - } - - var typeDeclSymbol = null; - - if (term.kind() === 11 /* IdentifierName */) { - typeDeclSymbol = this.resolveTypeNameExpression(term, context); - } else if (term.kind() === 123 /* FunctionType */) { - var functionType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); - } else if (term.kind() === 125 /* ConstructorType */) { - var constructorType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); - } else if (term.kind() === 122 /* ObjectType */) { - typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); - } else if (term.kind() === 126 /* GenericType */) { - typeDeclSymbol = this.resolveGenericTypeReference(term, context); - } else if (term.kind() === 121 /* QualifiedName */) { - typeDeclSymbol = this.resolveQualifiedName(term, context); - } else if (term.kind() === 14 /* StringLiteral */) { - 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, enclosingDecl.semanticInfoChain); - typeDeclSymbol.addDeclaration(decl); - } else if (term.kind() === 127 /* TypeQuery */) { - var typeQuery = term; - - var typeQueryTerm = typeQuery.name; - - var valueSymbol = this.resolveAST(typeQueryTerm, false, context); - - if (valueSymbol && valueSymbol.isAlias()) { - if (valueSymbol.assignedValue()) { - valueSymbol = valueSymbol.assignedValue(); - } else { - var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); - valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; - } - } - - if (valueSymbol) { - typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); - } else { - typeDeclSymbol = this.getNewErrorTypeSymbol(); - } - } else if (term.kind() === 124 /* ArrayType */) { - var arrayType = term; - var underlying = this.resolveTypeReference(arrayType.type, context); - typeDeclSymbol = this.getArrayType(underlying); - } else { - throw TypeScript.Errors.invalidOperation("unknown type"); - } - - if (!typeDeclSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); - return this.getNewErrorTypeSymbol(); - } - - if (typeDeclSymbol.isError()) { - return typeDeclSymbol; - } - - if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); - typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); - } - - return typeDeclSymbol; - }; - - PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { - 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveParameterList = function (list, context) { - return this.resolveSeparatedList(list.parameters, context); - }; - - PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { - var enumDeclaration = enumElement.parent.parent; - var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); - var symbol = decl.getSymbol(); - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { - if (this.canTypeCheckAST(clause, context)) { - this.setTypeChecked(clause, context); - } - - return this.resolveAST(clause.value, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - - if (enclosingDecl && decl.kind === 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved) { - var declType = declSymbol.type; - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved) { - valSymbol.type = declType; - valSymbol.setResolved(); - } - } - } else { - if (declSymbol.inResolution) { - declSymbol.type = this.semanticInfoChain.anyTypeSymbol; - declSymbol.setResolved(); - return declSymbol; - } - - if (!declSymbol.type || !declSymbol.type.isError()) { - declSymbol.startResolving(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - if (!hasTypeExpr) { - this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - } - - if (!(hasTypeExpr || init)) { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { - defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.type = defaultType; - } - } - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - } - } - - if (this.canTypeCheckAST(varDeclOrParameter, context)) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (varDeclOrParameter.kind() === 243 /* EnumElement */) { - var result = this.getEnumTypeSymbol(varDeclOrParameter, context); - declSymbol.type = result; - return result; - } - - if (!typeExpr) { - return null; - } - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var typeExprSymbol = this.resolveTypeReference(typeExpr, context); - - if (!typeExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - declSymbol.type = this.getNewErrorTypeSymbol(); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, typeExprSymbol); - } - } else { - if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { - decl.setFlag(16777216 /* IsAnnotatedWithAny */); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - typeExprSymbol = typeExprSymbol.type; - - if (typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { - var instanceSymbol = typeExprSymbol.getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(); - } else { - typeExprSymbol = instanceSymbol.type; - } - } - } - } 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(); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.type = typeExprSymbol; - } - - if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { - typeExprSymbol.setFunctionSymbol(declSymbol); - } - } - - return typeExprSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { - if (!init) { - return null; - } - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - if (typeExprSymbol) { - context.pushNewContextualType(typeExprSymbol); - } - - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); - - if (typeExprSymbol) { - context.popAnyContextualType(); - } - - if (!initExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - } else { - var initTypeSymbol = initExprSymbol.type; - - if (!hasTypeExpr) { - var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); - context.setTypeInContext(declSymbol, widenedInitTypeSymbol); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); - } - - if (this.compilationSettings.noImplicitAny()) { - 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 initTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var _this = this; - this.setTypeChecked(varDeclOrParameter, context); - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - - if (hasTypeExpr || init) { - if (typeExprSymbol && typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = typeExprSymbol.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol; - } - } - } - - initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); - } - } - } - } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { - var wrapperDecl = this.getEnclosingDecl(decl); - 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])); - } else if (wrapperDecl.kind === 65536 /* Method */) { - var parentDecl = wrapperDecl.getParentDecl(); - - if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); - } 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 (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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } - } - } - - 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_only_allowed_in_implementation)); - } - } - 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 */)) { - this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); - } - }; - - PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { - return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; - }; - - PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { - var enclosingDecl = this.getEnclosingDeclForAST(superAST); - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); - - if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { - 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; - if (!block) { - return; - } - } - } - - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - if (parents.length) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); - } - } - }; - - PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { - if (isDeclaration) { - var decl = this.semanticInfoChain.getDeclForAST(_thisAST); - if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - return; - } - } - - var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - var declPath = enclosingDecl.getParentPath(); - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - continue; - } - - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); - } - break; - } - } - }; - - PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { - this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - 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) { - return; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - typeParameterSymbol.setResolved(); - }; - - PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { - this.setTypeChecked(typeParameterAST, 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) { - if (this.canTypeCheckAST(constraint, context)) { - this.setTypeChecked(constraint, context); - } - - return this.resolveTypeReference(constraint.type, context); - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatementsExpressions = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, walker) { - var go = true; - - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 215 /* ObjectLiteralExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); - go = false; - break; - - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, walker) { - switch (ast.kind()) { - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - if (block) { - TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - } else { - returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - } - - if (!returnStatementsExpressions.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var returnExpressionSymbols = []; - var returnExpressions = []; - - for (var i = 0; i < returnStatementsExpressions.length; i++) { - var returnExpression = returnStatementsExpressions[i].expression; - if (returnExpression) { - var returnType = this.resolveAST(returnExpression, useContextualType, context).type; - - if (returnType.isError()) { - signature.returnType = returnType; - return; - } else { - if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { - this.setSymbolForAST(returnExpression.parent, returnType, context); - } - } - - returnExpressionSymbols.push(returnType); - returnExpressions.push(returnExpression); - } - } - - if (!returnExpressionSymbols.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].type; - } - }; - - var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); - var returnType = bestCommonReturnType; - var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - - if (returnType) { - var previousReturnType = returnType; - var newReturnType = returnType.widenedType(this, returnExpression, context); - signature.returnType = newReturnType; - - if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); - } - - if (this.compilationSettings.noImplicitAny()) { - if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { - var functionName = enclosingDecl.name; - if (functionName === "") { - functionName = enclosingDecl.getFunctionExpressionName(); - } - - if (functionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } - - if (!functionSymbol.type && functionSymbol.isAccessor()) { - functionSymbol.type = signature.returnType; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { - var _this = this; - if (constructorDecl.block) { - var foundSuperCall = false; - var pre = function (ast, walker) { - if (_this.isSuperInvocationExpression(ast)) { - foundSuperCall = true; - walker.options.stopWalking = true; - } - }; - - TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); - return foundSuperCall; - } - - return false; - }; - - 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); - }; - - PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { - this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(parameters, false, context); - - this.resolveAST(block, false, context); - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); - - if (funcDecl.kind === 16384 /* Function */) { - this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); - } - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - this.resolveAST(funcDeclAST.parameter, false, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); - var stringIndexSignature = allIndexSignatures.stringSignature; - var numberIndexSignature = allIndexSignatures.numericSignature; - var isNumericIndexer = numberIndexSignature === signature; - - if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { - var comparisonInfo = new TypeComparisonInfo(); - - 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); - } - } - } - - var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); - for (var i = 0; i < allMembers.length; i++) { - var member = allMembers[i]; - var name = member.name; - if (name || (member.kind === 4096 /* Property */ && name === "")) { - if (!allMembers[i].isResolved) { - _this.resolveDeclaredSymbol(allMembers[i], context); - } - - if (parentSymbol !== allMembers[i].getContainer()) { - var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); - var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; - var onlyStringIndexerIsPresent = !numberIndexSignature; - - if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { - var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { - _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); - } - } - } - } - } - }); - }; - - PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { - this.checkThisCaptureVariableCollides(funcDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { - var returnTypeSymbol = null; - - if (returnTypeAnnotation) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - } else { - var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } - - return returnTypeSymbol; - }; - - 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - return funcSymbol; - } - - if (!signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - 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(); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveIndexSignature(ast.indexSignature, context); - }; - - PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - return funcSymbol; - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameter) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - this.resolveParameter(funcDeclAST.parameter, context); - context.inTypeCheck = prevInTypeCheck; - } - - if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - return funcSymbol; - } - - if (isConstructor && !signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (returnTypeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { - if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { - 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; - if (funcDeclASTName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } - } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { - if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); - } - - return null; - }; - - 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.ASTHelpers.getType(parameter), context); - } - - return null; - }; - - PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - - if (accessorSymbol.inResolution) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - accessorSymbol.setResolved(); - - return accessorSymbol; - } - - if (accessorSymbol.isResolved) { - if (!accessorSymbol.type) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else { - var getterSymbol = accessorSymbol.getGetter(); - var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; - var hasGetter = getterSymbol !== null; - - var setterSymbol = accessorSymbol.getSetter(); - var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; - var hasSetter = setterSymbol !== null; - - var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); - var getterHasTypeAnnotation = getterAnnotatedType !== null; - - var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); - var setterHasTypeAnnotation = setterAnnotatedType !== null; - - accessorSymbol.startResolving(); - - if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); - } - - if (hasSetter) { - setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); - } - - if (hasGetter && hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - var getterSig = getterSymbol.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { - getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; - getterSig.returnType = setterSuppliedTypeSymbol; - } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { - setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; - - if (setterHasParameters) { - setterParameters[0].type = getterSuppliedTypeSymbol; - } - } - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - accessorSymbol.type = this.getNewErrorTypeSymbol(); - } else { - accessorSymbol.type = getterSuppliedTypeSymbol; - } - } else if (hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - - accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; - } else { - var getterSig = getterSymbol.type.getCallSignatures()[0]; - accessorSymbol.type = getterSig.returnType; - } - - accessorSymbol.setResolved(); - } - - if (this.canTypeCheckAST(funcDeclAst, context)) { - this.typeCheckAccessorDeclaration(funcDeclAst, context); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { - this.setTypeChecked(funcDeclAst, context); - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - var getterSymbol = accessorSymbol.getGetter(); - var setterSymbol = accessorSymbol.getSetter(); - - var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; - if (isGetter) { - var getterFunctionDeclarationAst = funcDeclAst; - context.pushNewContextualType(getterSymbol.type); - this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popAnyContextualType(); - } else { - var setterFunctionDeclarationAst = funcDeclAst; - this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); - } - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.type; - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return getterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - signature.setResolved(); - - return getterSymbol; - } - - signature.startResolving(); - - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - if (!setterAnnotatedType) { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } else { - signature.returnType = setterAnnotatedType; - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return getterSymbol; - }; - - PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - if (getter && setter) { - var getterAST = getter.getDeclarations()[0].ast(); - var setterAST = setter.getDeclarations()[0].ast(); - - if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { - var setterSig = setter.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - - var getter = accessorSymbol.getGetter(); - var getterSig = getter.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterParameters[0].type; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); - } - } - } - }; - - PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - var funcNameAST = funcDeclAST.propertyName; - - if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); - } - - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); - var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - 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.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; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.type; - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return setterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - signature.setResolved(); - return setterSymbol; - } - - signature.startResolving(); - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - } - - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - - if (!hadError) { - signature.setResolved(); - } - } - - return setterSymbol; - }; - - PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - - var getter = accessorSymbol.getGetter(); - - var funcNameAST = funcDeclAST.propertyName; - - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); - var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - if (getterIsPrivate !== setterIsPrivate) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); - } - - this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); - } else { - if (this.compilationSettings.noImplicitAny()) { - var setterFunctionDeclarationAst = funcDeclAST; - 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); - }; - - PullTypeResolver.prototype.resolveList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.childCount(); i < n; i++) { - this.resolveAST(list.childAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.resolveAST(list.nonSeparatorAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLogicalOperation(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { - this.setTypeChecked(binex, context); - - var leftType = this.resolveAST(binex.left, false, context).type; - var rightType = this.resolveAST(binex.right, false, context).type; - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(binex); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ - TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), - leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); - } - }; - - PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.operand, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckUnaryArithmeticOperation(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckPostfixUnaryExpression(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { - return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); - }; - - PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { - return; - } - - TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { - if (this.canTypeCheckAST(binaryExpression, context)) { - this.typeCheckBinaryArithmeticExpression(binaryExpression, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); - - var lhsType = lhsSymbol.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } - - if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } - - var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); - var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); - - if (!rhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!lhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (lhsIsFit && rhsIsFit) { - switch (binaryExpression.kind()) { - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - if (!this.isReference(binaryExpression.left, lhsSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); - } - } - }; - - PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInstanceOfExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); - var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - 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_of_a_type_assignable_to_the_Function_interface_type)); - } - }; - - PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { - if (this.canTypeCheckAST(commaExpression, context)) { - this.setTypeChecked(commaExpression, context); - - this.resolveAST(commaExpression.left, false, context); - } - - return this.resolveAST(commaExpression.right, false, context).type; - }; - - PullTypeResolver.prototype.resolveInExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; - - var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); - - if (!isValidLHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); - } - - if (!isValidRHS) { - 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)); - } - }; - - PullTypeResolver.prototype.resolveForStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.variableDeclaration, false, context); - this.resolveAST(ast.initializer, false, context); - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.incrementor, false, context); - this.resolveAST(ast.statement, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { - if (this.canTypeCheckAST(forInStatement, context)) { - this.typeCheckForInStatement(forInStatement, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { - this.setTypeChecked(forInStatement, context); - - if (forInStatement.variableDeclaration) { - var declaration = forInStatement.variableDeclaration; - - 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); - - 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 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)); - } - - this.resolveAST(forInStatement.statement, false, context); - }; - - PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWhileStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckDoStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckIfStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - this.resolveAST(ast.elseClause, false, context); - }; - - PullTypeResolver.prototype.resolveElseClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckElseClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveBlock = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.statements, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declaration, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declarators, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWithStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var withStatement = ast; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); - }; - - PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckTryStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var tryStatement = ast; - - this.resolveAST(tryStatement.block, false, context); - this.resolveAST(tryStatement.catchClause, false, context); - this.resolveAST(tryStatement.finallyClause, false, context); - }; - - PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckCatchClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - - var catchDecl = this.semanticInfoChain.getDeclForAST(ast); - this.validateVariableDeclarationGroups(catchDecl, context); - }; - - PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckFinallyClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - }; - - PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - while (enclosingDecl) { - if (enclosingDecl.kind & 1032192 /* SomeFunction */) { - return enclosingDecl; - } - - enclosingDecl = enclosingDecl.getParentDecl(); - } - - return null; - }; - - PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var isContextuallyTyped = false; - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); - if (returnTypeAnnotationSymbol) { - isContextuallyTyped = true; - context.pushNewContextualType(returnTypeAnnotationSymbol); - } - } else { - var currentContextualType = context.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - isContextuallyTyped = true; - context.propagateContextualType(currentContextualTypeReturnTypeSymbol); - } - } - } - } - - var result = this.resolveAST(expression, isContextuallyTyped, context).type; - if (isContextuallyTyped) { - context.popAnyContextualType(); - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { - if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { - var classDecl = enclosingFunction.getParentDecl(); - if (classDecl) { - var classSymbol = classDecl.getSymbol(); - this.resolveDeclaredSymbol(classSymbol, context); - - var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); - if (!isAssignable) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); - } - } - } - - if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); - } - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { - var signatureSymbol = enclosingFunction.getSignatureSymbol(); - var sigReturnType = signatureSymbol.returnType; - - if (expressionType && sigReturnType) { - var comparisonInfo = new TypeComparisonInfo(); - var upperBound = null; - - this.resolveDeclaredSymbol(expressionType, context); - this.resolveDeclaredSymbol(sigReturnType, context); - - var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); - } - } - } - } - } - }; - - PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { - var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var returnType = this.getSymbolForAST(returnAST, context); - var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); - if (!returnType || canTypeCheckAST) { - var returnExpr = returnAST.expression; - - var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); - - if (!returnType) { - returnType = resolvedReturnType; - this.setSymbolForAST(returnAST, resolvedReturnType, context); - } - - if (returnExpr && canTypeCheckAST) { - this.setTypeChecked(returnExpr, context); - this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); - } - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSwitchStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var expressionType = this.resolveAST(ast.expression, false, context).type; - - for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { - var switchClause = ast.switchClauses.childAt(i); - if (switchClause.kind() === 233 /* CaseSwitchClause */) { - var caseSwitchClause = switchClause; - - var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; - this.resolveAST(caseSwitchClause.statements, false, context); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); - } - } - } else { - var defaultSwitchClause = switchClause; - this.resolveAST(defaultSwitchClause.statements, false, context); - } - } - }; - - PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLabeledStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var labelIdentifier = ast.identifier.valueText(); - - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - 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); - }; - - PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { - switch (statement.kind()) { - case 160 /* LabeledStatement */: - return this.labelIsOnContinuableConstruct(statement.statement); - - case 158 /* WhileStatement */: - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 161 /* DoStatement */: - return true; - - default: - return false; - } - }; - - PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckContinueStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.isIterationStatement = function (ast) { - switch (ast.kind()) { - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 158 /* WhileStatement */: - case 161 /* DoStatement */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { - switch (ast.kind()) { - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 129 /* FunctionDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 241 /* FunctionPropertyAssignment */: - case 137 /* ConstructorDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.inSwitchStatement = function (ast) { - while (ast) { - if (ast.kind() === 151 /* SwitchStatement */) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { - while (ast) { - if (this.isIterationStatement(ast)) { - return true; - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { - var result = []; - - ast = ast.parent; - while (ast) { - if (ast.kind() === 160 /* LabeledStatement */) { - var labeledStatement = ast; - if (breakable) { - result.push(labeledStatement); - } else { - if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement); - } - } - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - break; - } - - ast = ast.parent; - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - 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.any(continuableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var continuableLabels = this.getEnclosingLabels(ast, false, true); - - 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)); - } - } - } - }; - - PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckBreakStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - if (ast.identifier) { - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var breakableLabels = this.getEnclosingLabels(ast, true, true); - 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, 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)); - } - } - }; - - PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { - if (!ast) { - return; - } - - var symbol = this.getSymbolForAST(ast, context); - if (symbol && symbol.isResolved) { - this.typeCheckAST(ast, isContextuallyTyped, context); - return symbol; - } - - if (ast.isExpression() && !isTypesOnlyLocation(ast)) { - return this.resolveExpressionAST(ast, isContextuallyTyped, context); - } - - var nodeType = ast.kind(); - - switch (nodeType) { - case 124 /* ArrayType */: - case 126 /* GenericType */: - case 122 /* ObjectType */: - case 127 /* TypeQuery */: - case 125 /* ConstructorType */: - case 123 /* FunctionType */: - return this.resolveTypeReference(ast, context); - - case 1 /* List */: - return this.resolveList(ast, context); - - case 2 /* SeparatedList */: - return this.resolveSeparatedList(ast, context); - - case 120 /* SourceUnit */: - return this.resolveSourceUnit(ast, context); - - case 132 /* EnumDeclaration */: - return this.resolveEnumDeclaration(ast, context); - - case 130 /* ModuleDeclaration */: - return this.resolveModuleDeclaration(ast, context); - - case 128 /* InterfaceDeclaration */: - return this.resolveInterfaceDeclaration(ast, context); - - case 131 /* ClassDeclaration */: - return this.resolveClassDeclaration(ast, context); - - case 224 /* VariableDeclaration */: - return this.resolveVariableDeclarationList(ast, context); - - case 136 /* MemberVariableDeclaration */: - return this.resolveMemberVariableDeclaration(ast, context); - - case 225 /* VariableDeclarator */: - return this.resolveVariableDeclarator(ast, context); - - case 141 /* PropertySignature */: - return this.resolvePropertySignature(ast, context); - - case 227 /* ParameterList */: - return this.resolveParameterList(ast, context); - - case 242 /* Parameter */: - return this.resolveParameter(ast, context); - - case 243 /* EnumElement */: - return this.resolveEnumElement(ast, context); - - case 232 /* EqualsValueClause */: - return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); - - case 238 /* TypeParameter */: - return this.resolveTypeParameterDeclaration(ast, context); - - case 239 /* Constraint */: - return this.resolveConstraint(ast, context); - - case 133 /* ImportDeclaration */: - return this.resolveImportDeclaration(ast, context); - - case 240 /* SimplePropertyAssignment */: - return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); - - case 241 /* FunctionPropertyAssignment */: - return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); - - case 11 /* IdentifierName */: - TypeScript.Debug.assert(isTypesOnlyLocation(ast)); - return this.resolveTypeNameExpression(ast, context); - - case 121 /* QualifiedName */: - return this.resolveQualifiedName(ast, context); - - case 137 /* ConstructorDeclaration */: - return this.resolveConstructorDeclaration(ast, context); - - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return this.resolveAccessorDeclaration(ast, context); - - case 138 /* IndexMemberDeclaration */: - return this.resolveIndexMemberDeclaration(ast, context); - - case 144 /* IndexSignature */: - return this.resolveIndexSignature(ast, context); - - case 135 /* MemberFunctionDeclaration */: - return this.resolveMemberFunctionDeclaration(ast, context); - - case 142 /* CallSignature */: - return this.resolveCallSignature(ast, context); - - case 143 /* ConstructSignature */: - return this.resolveConstructSignature(ast, context); - - case 145 /* MethodSignature */: - return this.resolveMethodSignature(ast, context); - - 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); - - case 219 /* SimpleArrowFunctionExpression */: - return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 214 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - - case 35 /* ThisKeyword */: - return this.resolveThisExpression(ast, context); - - case 50 /* SuperKeyword */: - return this.resolveSuperExpression(ast, context); - - case 213 /* InvocationExpression */: - return this.resolveInvocationExpression(ast, context); - - case 216 /* ObjectCreationExpression */: - return this.resolveObjectCreationExpression(ast, context); - - case 220 /* CastExpression */: - return this.resolveCastExpression(ast, context); - - case 13 /* NumericLiteral */: - return this.semanticInfoChain.numberTypeSymbol; - - case 14 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 32 /* NullKeyword */: - return this.semanticInfoChain.nullTypeSymbol; - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 172 /* VoidExpression */: - return this.resolveVoidExpression(ast, context); - - case 174 /* AssignmentExpression */: - return this.resolveAssignmentExpression(ast, context); - - case 167 /* LogicalNotExpression */: - return this.resolveLogicalNotExpression(ast, context); - - case 193 /* NotEqualsWithTypeConversionExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 197 /* GreaterThanExpression */: - return this.resolveLogicalOperation(ast, context); - - case 208 /* AddExpression */: - case 175 /* AddAssignmentExpression */: - return this.resolveBinaryAdditionOperation(ast, context); - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.resolveUnaryArithmeticOperation(ast, context); - - case 210 /* PostIncrementExpression */: - case 211 /* PostDecrementExpression */: - return this.resolvePostfixUnaryExpression(ast, context); - - case 209 /* SubtractExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 189 /* BitwiseOrExpression */: - case 191 /* BitwiseAndExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - return this.resolveBinaryArithmeticExpression(ast, context); - - case 221 /* ElementAccessExpression */: - return this.resolveElementAccessExpression(ast, context); - - case 187 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); - - case 188 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, context); - - case 171 /* TypeOfExpression */: - return this.resolveTypeOfExpression(ast, context); - - case 170 /* DeleteExpression */: - return this.resolveDeleteExpression(ast, context); - - case 186 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, isContextuallyTyped, context); - - case 12 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 217 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, context); - - case 200 /* InstanceOfExpression */: - return this.resolveInstanceOfExpression(ast, context); - - case 173 /* CommaExpression */: - return this.resolveCommaExpression(ast, context); - - case 201 /* InExpression */: - return this.resolveInExpression(ast, context); - - case 223 /* OmittedExpression */: - return this.semanticInfoChain.undefinedTypeSymbol; - } - - TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); - }; - - PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { - if (!this.canTypeCheckAST(ast, context)) { - return; - } - - var nodeType = ast.kind(); - switch (nodeType) { - case 120 /* SourceUnit */: - this.typeCheckSourceUnit(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.typeCheckEnumDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.typeCheckModuleDeclaration(ast, context); - return; - - case 128 /* InterfaceDeclaration */: - this.typeCheckInterfaceDeclaration(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.typeCheckClassDeclaration(ast, context); - return; - - case 243 /* EnumElement */: - this.typeCheckEnumElement(ast, context); - return; - - case 136 /* MemberVariableDeclaration */: - this.typeCheckMemberVariableDeclaration(ast, context); - return; - - case 225 /* VariableDeclarator */: - this.typeCheckVariableDeclarator(ast, context); - return; - - case 141 /* PropertySignature */: - this.typeCheckPropertySignature(ast, context); - return; - - case 242 /* Parameter */: - this.typeCheckParameter(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.typeCheckImportDeclaration(ast, context); - return; - - case 215 /* ObjectLiteralExpression */: - this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 241 /* FunctionPropertyAssignment */: - this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); - return; - - case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - this.resolveTypeNameExpression(ast, context); - } else { - this.resolveNameExpression(ast, context); - } - return; - - case 212 /* MemberAccessExpression */: - this.resolveMemberAccessExpression(ast, context); - return; - - case 121 /* QualifiedName */: - this.resolveQualifiedName(ast, context); - return; - - case 222 /* FunctionExpression */: - 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); - break; - - case 142 /* CallSignature */: - this.typeCheckCallSignature(ast, context); - return; - - case 143 /* ConstructSignature */: - this.typeCheckConstructSignature(ast, context); - return; - - case 129 /* FunctionDeclaration */: { - var funcDecl = ast; - 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, isContextuallyTyped, context); - return; - - case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - return; - - case 214 /* ArrayLiteralExpression */: - this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 213 /* InvocationExpression */: - this.typeCheckInvocationExpression(ast, context); - return; - - case 216 /* ObjectCreationExpression */: - this.typeCheckObjectCreationExpression(ast, context); - return; - - case 150 /* ReturnStatement */: - this.resolveReturnStatement(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); - } - }; - - PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { - while (this.postTypeCheckWorkitems.length) { - var ast = this.postTypeCheckWorkitems.pop(); - this.postTypeCheck(ast, context); - } - }; - - PullTypeResolver.prototype.postTypeCheck = function (ast, context) { - var nodeType = ast.kind(); - - switch (nodeType) { - case 242 /* Parameter */: - case 225 /* VariableDeclarator */: - this.postTypeCheckVariableDeclaratorOrParameter(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.postTypeCheckClassDeclaration(ast, context); - return; - - case 129 /* FunctionDeclaration */: - this.postTypeCheckFunctionDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.postTypeCheckModuleDeclaration(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.postTypeCheckEnumDeclaration(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.postTypeCheckImportDeclaration(ast, context); - return; - - case 11 /* IdentifierName */: - this.postTypeCheckNameExpression(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); - } - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return this.cachedRegExpInterfaceType(); - } else { - return this.semanticInfoChain.anyTypeSymbol; - } - }; - - PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { - this.checkThisCaptureVariableCollides(nameAST, false, context); - }; - - PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { - this.setTypeChecked(nameAST, context); - this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { - var nameSymbol = this.getSymbolForAST(nameAST, context); - var foundCached = nameSymbol !== null; - - if (!foundCached || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.typeCheckNameExpression(nameAST, context); - } - nameSymbol = this.computeNameExpression(nameAST, context); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(nameAST, nameSymbol, context); - } - - return nameSymbol; - }; - - 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.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; - } - - var nameSymbol = null; - var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; - - if (!this.isInEnumDecl(enclosingDecl)) { - searchKind = searchKind & ~(67108864 /* EnumMember */); - } - - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); - } - - 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) { - 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]; - var nameParentDecl = nameDeclaration.getParentDecl(); - if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { - var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); - var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - - var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); - - if (currentParameterIndex >= 0) { - var matchingParameter; - if (parameterList) { - for (var i = 0; i <= currentParameterIndex; i++) { - var candidateParameter = parameterList.parameters.nonSeparatorAt(i); - if (candidateParameter && candidateParameter.identifier.valueText() === id) { - matchingParameter = candidateParameter; - break; - } - } - } - - 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); - } - } - } - - var aliasSymbol = null; - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); - - var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - if (aliasSymbol) { - this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); - if (parameterList) { - while (parameter && parameter.parent) { - if (parameter.parent.parent === parameterList) { - return parameterList.parameters.nonSeparatorIndexOf(parameter); - } - - parameter = parameter.parent; - } - } - - return -1; - }; - - PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { - var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol !== null; - - if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheckDottedNameAST) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); - } - - this.resolveDeclaredSymbol(symbol, context); - - if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(dottedNameAST, symbol, context); - this.setSymbolForAST(name, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { - var rhsName = name.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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)) { - lhsAlias.setIsUsedAsValue(); - } - lhsType = lhsAlias.getExportAssignedTypeSymbol(); - } - - if (lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (!lhsType) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); - return this.getNewErrorTypeSymbol(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType !== lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { - var instanceSymbol = lhsType.getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.type; - } - } - - var originalLhsTypeForErrorReporting = lhsType; - - lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); - - if (!nameSymbol) { - if (lhsType.kind === 32 /* DynamicModule */) { - var container = lhsType; - var associatedInstance = container.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.type; - - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); - } - } - - 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - } - - if (checkSuperPrivateAndStaticAccess) { - this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { - var typeNameSymbol = this.getSymbolForAST(nameAST, context); - - if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.setTypeChecked(nameAST, context); - } - typeNameSymbol = this.computeTypeNameExpression(nameAST, context); - this.setSymbolForAST(nameAST, typeNameSymbol, context); - } - - this.resolveDeclaredSymbol(typeNameSymbol, context); - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - var declPath = enclosingDecl.getParentPath(); - - var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } - - var typeNameSymbolAlias = null; - if (typeNameSymbol.isAlias()) { - typeNameSymbolAlias = typeNameSymbol; - this.resolveDeclaredSymbol(typeNameSymbol, context); - - var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); - - this.resolveDeclaredSymbol(aliasedType, context); - } - - if (typeNameSymbol.isTypeParameter()) { - if (this.isInStaticMemberContext(enclosingDecl)) { - var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - - if (parentDecl.kind === 8 /* Class */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); - return this.getNewErrorTypeSymbol(); - } - } - } - - if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { - typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); - } - - 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; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; - - if (genericTypeSymbol.isError()) { - return genericTypeSymbol; - } - - if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { - this.resolveDeclaredSymbol(genericTypeSymbol, context); - } - - 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()) { - for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - - if (typeArgs[i].isError()) { - typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - 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(); - } - - if (!genericTypeSymbol.isResolved) { - var typeDecls = genericTypeSymbol.getDeclarations(); - var childDecls = null; - - for (var i = 0; i < typeDecls.length; i++) { - childDecls = typeDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - - var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); - - var typeConstraint = null; - var upperBound = null; - - typeParameters = specializedSymbol.getTypeParameters(); - - var typeConstraintSubstitutionMap = []; - var typeArg = null; - - var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < typeParameters.length; i++) { - typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - for (var id in instantiatedSubstitutionMap) { - typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; - } - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] === typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); - } - - if (typeArg.isTypeParameter()) { - upperBound = typeArg.getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - 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)])); - } - } - } - - return specializedSymbol; - }; - - PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { - if (this.inTypeQuery(dottedNameAST)) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; - } - - var symbol = this.getSymbolForAST(dottedNameAST, context); - if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheck) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeQualifiedName(dottedNameAST, context); - this.setSymbolForAST(dottedNameAST, symbol, context); - } - - this.resolveDeclaredSymbol(symbol, context); - - 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) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); - var lhs = this.resolveAST(dottedNameAST.left, false, context); - - var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; - - if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { - if (lhs.isAlias()) { - lhs.setIsUsedAsValue(); - } - } - - if (!lhsType) { - return this.getNewErrorTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); - var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; - - 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.kind & 164 /* SomeContainer */) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().type; - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); - } - } - } - - if (!childTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - - return childTypeSymbol; - }; - - PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { - if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { - return false; - } - - if (returnTypeAnnotation) { - return false; - } - - if (parameters) { - for (var i = 0, n = parameters.length; i < n; i++) { - if (parameters.typeAt(i)) { - return false; - } - } - } - - var contextualFunctionTypeSymbol = context.getContextualType(); - - if (contextualFunctionTypeSymbol) { - this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); - var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; - if (!exactlyOneCallSignature) { - return false; - } - - var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; - return !callSignatureIsGeneric; - } - - return false; - }; - - PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { - var funcDeclSymbol = null; - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { - return funcDeclSymbol; - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - TypeScript.Debug.assert(funcDeclSymbol); - - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - funcDeclSymbol.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - var assigningFunctionSignature = null; - if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { - assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; - } - - this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.returnType; - - if (returnType) { - context.propagateContextualType(returnType); - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popAnyContextualType(); - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - var functionExpressionName = functionDecl.getFunctionExpressionName(); - - if (functionExpressionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); - } - } - - context.setTypeInContext(funcDeclSymbol, funcDeclType); - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); - } - - return funcDeclSymbol; - }; - - 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcDeclSymbol = functionDecl.getSymbol(); - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - var returnTypeSymbol = signature.returnType; - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - 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.popAnyContextualType(); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); - - this.validateVariableDeclarationGroups(functionDecl, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { - var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); - var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; - - if (this.canTypeCheckAST(thisExpression, context)) { - this.typeCheckThisExpression(thisExpression, context, enclosingDecl); - } - - return thisTypeSymbol; - }; - - PullTypeResolver.prototype.inTypeArgumentList = function (ast) { - var previous = null; - var current = ast; - - while (current) { - switch (current.kind()) { - case 126 /* GenericType */: - var genericType = current; - if (genericType.typeArgumentList === previous) { - return true; - } - break; - - case 226 /* ArgumentList */: - var argumentList = current; - return argumentList.typeArgumentList === previous; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { - while (ast) { - switch (ast.kind()) { - case 230 /* ExtendsHeritageClause */: - var heritageClause = ast; - - return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inTypeQuery = function (ast) { - while (ast) { - switch (ast.kind()) { - case 127 /* TypeQuery */: - return true; - case 129 /* FunctionDeclaration */: - case 213 /* InvocationExpression */: - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 213 /* InvocationExpression */: - var invocationExpression = current; - if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - break; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inConstructorParameterList = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 142 /* CallSignature */: - var callSignature = current; - if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { - return true; - } - - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - 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 */) { - return true; - } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { - this.checkForThisCaptureInArrowFunction(thisExpression); - - if (this.inConstructorParameterList(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); - return; - } - - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { - return; - } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - if (currentDecl.getParentDecl() === null) { - return; - } else { - 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)); - } - - return; - } else if (currentDecl.kind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); - } - - return; - } - } - }; - - PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var isStaticContext = false; - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declFlags & 16 /* Static */) { - isStaticContext = true; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - return null; - } else if (declKind === 16384 /* Function */) { - return null; - } else if (declKind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(ast)) { - return this.getNewErrorTypeSymbol(); - } else { - var classSymbol = decl.getSymbol(); - if (isStaticContext) { - var constructorSymbol = classSymbol.getConstructorMethod(); - return constructorSymbol.type; - } else { - return classSymbol; - } - } - } - } - } - - return null; - }; - - PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { - return true; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - var superType = this.semanticInfoChain.anyTypeSymbol; - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); - - if (classSymbol) { - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - superType = parents[0]; - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSuperExpression(ast, context, enclosingDecl); - } - - return superType; - }; - - PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { - this.setTypeChecked(ast, context); - - this.checkForThisCaptureInArrowFunction(ast); - - var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; - var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; - TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); - - if (isSuperPropertyAccess) { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 8 /* Class */) { - if (!this.enclosingClassIsDerived(currentDecl)) { - 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 if (this.inStaticMemberVariableDeclaration(ast)) { - break; - } - - 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; - } - - return; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Super_calls_are_not_permitted_outside_constructors_or_in_local_functions_inside_constructors)); - } - }; - - PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { - return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { - if (this.canTypeCheckAST(expressionAST, context)) { - this.setTypeChecked(expressionAST, context); - } - symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); - this.setSymbolForAST(expressionAST, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { - var boundMemberSymbols = []; - var memberSymbol; - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var id = this.getPropertyAssignmentName(propertyAssignment); - var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); - - var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; - var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); - TypeScript.Debug.assert(decl); - - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - if (!isUsingExistingSymbol) { - memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - } else { - memberSymbol = decl.getSymbol(); - } - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - memberSymbol = decl.getSymbol(); - } else { - TypeScript.Debug.assert(isAccessor); - memberSymbol = decl.getSymbol(); - } - - if (!isUsingExistingSymbol && !isAccessor) { - var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); - if (existingMember) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); - } - - objectLiteralTypeSymbol.addMember(memberSymbol); - } - - boundMemberSymbols.push(memberSymbol); - } - - return boundMemberSymbols; - }; - - PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var acceptedContextualType = false; - var assigningSymbol = null; - - var id = this.getPropertyAssignmentName(propertyAssignment); - var memberSymbol = boundMemberSymbols[i]; - var contextualMemberType = null; - - if (objectLiteralContextualType) { - assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); - - if (!assigningSymbol) { - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - assigningSymbol = numericIndexerSignature; - } else if (stringIndexerSignature) { - assigningSymbol = stringIndexerSignature; - } - } - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - - contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.propagateContextualType(contextualMemberType); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = contextualMemberType; - } - } - } - - var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; - - if (memberSymbolType) { - if (memberSymbolType.isGeneric()) { - objectLiteralTypeSymbol.setHasGenericMember(); - } - - if (stringIndexerSignature) { - allMemberTypes.push(memberSymbolType); - } - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberSymbolType); - } - } - - if (acceptedContextualType) { - pullTypeContext.popAnyContextualType(); - } - - var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!memberSymbol.isResolved) { - if (isAccessor) { - this.setSymbolForAST(id, memberSymbolType, pullTypeContext); - } else { - pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); - memberSymbol.setResolved(); - - this.setSymbolForAST(id, memberSymbol, pullTypeContext); - } - } - } - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { - var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); - TypeScript.Debug.assert(objectLitDecl); - - var typeSymbol = this.getSymbolForAST(objectLitAST, context); - var isUsingExistingSymbol = !!typeSymbol; - - if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); - typeSymbol.addDeclaration(objectLitDecl); - this.setSymbolForAST(objectLitAST, typeSymbol, context); - objectLitDecl.setSymbol(typeSymbol); - } - - var propertyAssignments = objectLitAST.propertyAssignments; - var contextualType = null; - - if (isContextuallyTyped) { - contextualType = context.getContextualType(); - this.resolveDeclaredSymbol(contextualType, context); - } - - var stringIndexerSignature = null; - var numericIndexerSignature = null; - var allMemberTypes = null; - var allNumericMemberTypes = null; - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - - stringIndexerSignature = indexSignatures.stringSignature; - numericIndexerSignature = indexSignatures.numericSignature; - - var inInferentialTyping = context.isInferentiallyTyping(); - if (stringIndexerSignature) { - allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; - } - - if (numericIndexerSignature) { - allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; - } - } - - if (propertyAssignments) { - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); - - this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); - - if (!isUsingExistingSymbol) { - this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); - this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); - } - } - - typeSymbol.setResolved(); - return typeSymbol; - }; - - PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { - return propertyAssignment.propertyName; - } else { - TypeScript.Debug.assert(false); - } - }; - - PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { - if (contextualIndexSignature) { - var typeCollection = { - getLength: function () { - return indexerTypeCandidates.length; - }, - getTypeAtIndex: function (index) { - return indexerTypeCandidates[index]; - } - }; - var decl = objectLiteralSymbol.getDeclarations()[0]; - 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); - } - } - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { - var symbol = this.getSymbolForAST(arrayLit, context); - if (!symbol || this.canTypeCheckAST(arrayLit, context)) { - if (this.canTypeCheckAST(arrayLit, context)) { - this.setTypeChecked(arrayLit, context); - } - symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); - this.setSymbolForAST(arrayLit, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { - var elements = arrayLit.expressions; - var elementType = null; - var elementTypes = []; - var comparisonInfo = new TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, context); - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - if (indexSignatures.numericSignature) { - contextualElementType = indexSignatures.numericSignature.returnType; - } - } - } - - if (elements) { - if (contextualElementType) { - context.propagateContextualType(contextualElementType); - } - - for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { - elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); - } - - if (contextualElementType) { - context.popAnyContextualType(); - } - } - - if (elementTypes.length) { - elementType = elementTypes[0]; - } - var collection; - - if (contextualElementType && !context.isInferentiallyTyping()) { - if (!elementType) { - elementType = contextualElementType; - } - - collection = { - getLength: function () { - return elements.nonSeparatorCount() + 1; - }, - getTypeAtIndex: function (index) { - return index === 0 ? contextualElementType : elementTypes[index - 1]; - } - }; - } else { - collection = { - getLength: function () { - return elements.nonSeparatorCount(); - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - } - - elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; - - if (!elementType) { - elementType = this.semanticInfoChain.undefinedTypeSymbol; - } - - return this.getArrayType(elementType); - }; - - PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { - var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); - - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); - } - - return symbolAndDiagnostic.symbol; - }; - - PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { - this.setTypeChecked(callEx, context); - context.postDiagnostic(symbolAndDiagnostic.diagnostic); - }; - - PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; - - var targetTypeSymbol = targetSymbol.type; - - targetTypeSymbol = this.getApparentType(targetTypeSymbol); - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return { symbol: targetTypeSymbol }; - } - - var elementType = targetTypeSymbol.getElementType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return { symbol: elementType }; - } - - 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); - - if (member) { - this.resolveDeclaredSymbol(member, context); - - return { symbol: member.type }; - } - } - - var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); - - var stringSignature = signatures.stringSignature; - var numberSignature = signatures.numericSignature; - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; - } 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 { - symbol: this.getNewErrorTypeSymbol(), - diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) - }; - } - }; - - 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; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - if (!signature.isResolved) { - this.resolveDeclaredSymbol(signature, context); - } - - paramSymbols = signature.parameters; - - if (paramSymbols.length) { - paramType = paramSymbols[0].type; - - if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signature; - continue; - } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { - numberSignature = signature; - continue; - } - } - } - - return { - numericSignature: numberSignature, - stringSignature: stringSignature - }; - }; - - 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; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { - rhsType = this.semanticInfoChain.numberTypeSymbol; - } - - 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 { - lhsType = rhsType; - } - } else if (isRhsTypeNullOrUndefined) { - rhsType = lhsType; - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (exprType) { - if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { - if (!this.isReference(binaryExpression.left, lhsExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, exprType, lhsType, context); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); - } - } - - if (!exprType) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { - return this.findBestCommonType({ - getLength: function () { - return 2; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - } - } - }, context); - }; - - PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { - return this.findBestCommonType({ - getLength: function () { - return 3; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - case 2: - return type3; - } - } - }, context); - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - } - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; - var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; - - 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.pushNewContextualType(leftType); - var rightType = this.resolveAST(binex.right, true, context).type; - context.popAnyContextualType(); - - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - - this.resolveAST(binex.left, false, context); - } - - return this.resolveAST(binex.right, false, context).type; - }; - - PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped && !context.isInferentiallyTyping()) { - var contextualType = context.getContextualType(); - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); - } else { - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { - var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; - var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; - - var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); - - var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); - - if (this.canTypeCheckAST(trinex, context)) { - this.setTypeChecked(trinex, context); - this.resolveAST(trinex.condition, false, context); - - if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); - } - } - } - - if (!conditionalTypesAreValid) { - return this.getNewErrorTypeSymbol(); - } - - return expressionType; - }; - - PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { - return true; - } - } else { - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveAST(ast.expression, false, context); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - if (symbol !== this.semanticInfoChain.anyTypeSymbol) { - this.setSymbolForAST(callEx, symbol, context); - } - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckInvocationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - var targetSymbol = this.resolveAST(callEx.expression, false, context); - - if (callEx.argumentList.arguments) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - - var len = callEx.argumentList.arguments.nonSeparatorCount(); - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var targetTypeSymbol = targetSymbol.type; - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); - return this.getNewErrorTypeSymbol(); - } - } - - return this.semanticInfoChain.anyTypeSymbol; - } - - var isSuperCall = false; - - if (callEx.expression.kind() === 50 /* SuperKeyword */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = targetTypeSymbol.getConstructorMethod(); - this.resolveDeclaredSymbol(targetSymbol, context); - targetTypeSymbol = targetSymbol.type; - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); - this.resolveAST(callEx.argumentList.arguments, false, context); - - return this.getNewErrorTypeSymbol(); - } - } - - var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - - 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 explicitTypeArgs = null; - var couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - var triedToInferTypeArgs = false; - - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var beforeResolutionSignatures = signatures; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - couldNotAssignToConstraint = false; - - if (signatures[i].isGeneric() && typeParameters.length) { - if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { - explicitTypeArgs = signatures[i].returnType.getTypeArguments(); - } - - 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, 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; - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - - var errorCondition = null; - if (!signatures.length) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (!couldNotFindGenericOverload) { - 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); - } - return this.semanticInfoChain.anyTypeSymbol; - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); - } else if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!signatures.length) { - return errorCondition; - } - - signature = signatures[0]; - } - - 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 (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; - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - this.setSymbolForAST(callEx, symbol, context); - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckObjectCreationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - this.resolveAST(callEx.expression, false, context); - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (callEx.argumentList) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - var len = callEx.argumentList.arguments.nonSeparatorCount(); - - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { - if (!context.inProvisionalResolution()) { - additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); - } - context.postDiagnostic(diagnostic); - }; - - PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { - var _this = this; - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; - - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var explicitTypeArgs = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - return targetTypeSymbol; - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - - if (this.compilationSettings.noImplicitAny()) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); - } - } - - if (constructSignatures.length) { - if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var triedToInferTypeArgs; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric()) { - typeParameters = constructSignatures[i].getTypeParameters(); - - 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, explicitTypeArgs.length]); - continue; - } - } 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 { - inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { - return typeParameter.getDefaultConstraint(_this.semanticInfoChain); - }); - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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(constructSignatures[i], typeReplacementMap); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } else { - if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - - if (!constructSignatures.length) { - if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var errorCondition = null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!constructSignatures.length) { - return errorCondition; - } - - signature = constructSignatures[0]; - } - - returnType = signature.returnType; - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (explicitTypeArgs && explicitTypeArgs.length) { - returnType = this.createInstantiatedType(returnType, explicitTypeArgs); - } else { - returnType = this.instantiateTypeToAny(returnType, context); - } - } - - if (usedCallSignaturesInstead) { - 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(); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.returnType; - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList && callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - } else if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); - - return this.getNewErrorTypeSymbol(); - }; - - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { - var typeReplacementMap = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters = signatureAToInstantiate.getTypeParameters(); - var typeConstraint = null; - - var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); - inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); - - var functionTypeA = signatureAToInstantiate.functionType; - var functionTypeB = contextualSignatureB.functionType; - var enclosingTypeParameterMap; - - if (functionTypeA) { - enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - if (functionTypeB) { - enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); - - return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); - }; - - PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { - var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; - - if (this.canTypeCheckAST(assertionExpression, context)) { - this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); - } - - return typeAssertionType; - }; - - PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { - this.setTypeChecked(assertionExpression, context); - - context.pushNewContextualType(typeAssertionType); - var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popAnyContextualType(); - - this.resolveDeclaredSymbol(typeAssertionType, context); - this.resolveDeclaredSymbol(exprType, context); - - var comparisonInfo = new TypeComparisonInfo(); - - 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); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { - var leftExpr = this.resolveAST(binaryExpression.left, false, context); - var leftType = leftExpr.type; - - context.pushNewContextualType(leftType); - var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popAnyContextualType(); - - rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (!this.isReference(binaryExpression.left, leftExpr)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } else { - this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); - } - } - - return rightType; - }; - - PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { - var typeToReturn = type; - if (typeToReturn && typeToReturn.isAlias()) { - typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); - } - - if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { - var instanceTypeSymbol = typeToReturn.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); - typeToReturn = null; - } else { - typeToReturn = instanceTypeSymbol; - } - } - - return typeToReturn; - }; - - PullTypeResolver.prototype.widenType = function (type, ast, context) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (type.isArrayNamedTypeReference()) { - 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(); - - for (var i = 0; i < len; i++) { - var candidateType = collection.getTypeAtIndex(i); - if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { - return candidateType; - } - } - - return this.semanticInfoChain.emptyTypeSymbol; - }; - - PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { - for (var i = 0; i < collection.getLength(); i++) { - var otherType = collection.getTypeAtIndex(i); - if (candidateType === otherType) { - continue; - } - - if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - if (t1 && t2) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); - } - } - - return this.typesAreIdentical(t1, t2, context); - }; - - 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); - - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - return false; - } - - if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { - return false; - } - - if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - 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(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return false; - } - } - - if (t1.isPrimitive() !== t2.isPrimitive()) { - return 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) { - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); - - if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { - return false; - } - - return true; - }; - - 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; - } - - if (!sg1 || !sg2) { - return false; - } - - if (sg1.length !== sg2.length) { - return false; - } - - 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; - } - } - - return true; - }; - - 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; - } - - if (tp1 && tp2 && (tp1.length !== tp2.length)) { - return false; - } - - 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) { - var decls1 = symbol1.getDeclarations(); - var decls2 = symbol2.getDeclarations(); - - if (decls1.length && decls2.length) { - return decls1[0] === decls2[0]; - } - - return false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { - if (source.isFunctionType()) { - return true; - } - - return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); - }; - - 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.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) { - if (symbol && symbol.isTypeReference()) { - return symbol.getReferencedTypeSymbol(); - } - - return symbol; - }; - - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - if (source && target) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - } - } - - 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); - - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - var sourceApparentType = this.getApparentType(source); - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } - - if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - 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) { - return true; - } - - return false; - } else if (source === this.semanticInfoChain.voidTypeSymbol) { - if (target === this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return assignableTo; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { - return false; - } - - if (source.getIsSpecialized() && target.getIsSpecialized()) { - 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, true); - - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { - break; - } - } - - if (i === sourceTypeArguments.length) { - return true; - } else { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - } - } - } - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter()) { - if (!source.getConstraint()) { - return this.typesAreIdentical(target, source, context); - } else { - return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); - } - } else { - if (isComparingInstantiatedSignatures) { - target = target.getBaseConstraint(this.semanticInfoChain); - } else { - return this.typesAreIdentical(target, sourceApparentType, context); - } - } - } - - 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; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - - var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); - - this.resolveDeclaredSymbol(targetProp, context); - - var targetPropType = targetProp.type; - - 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = targetType.widenedType(this, null, context); - var widenedSourceType = sourceType.widenedType(this, null, context); - - if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - - 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var comparisonInfoTypeArgumentsCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); - } - 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_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_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, isRelatable); - return isRelatable; - }; - - 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)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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++) { - 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; - } - } - } - - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - 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 (comparisonInfo) { - var names = getNames(true); - var code; - if (targetPropIsPrivate) { - 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 { - 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; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (targetDecl !== sourceDecl) { - if (comparisonInfo) { - var names = getNames(true); - - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - 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; - } - } - - if (sourceProp.isOptional && !targetProp.isOptional) { - if (comparisonInfo) { - 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); - } - return false; - } - - this.resolveDeclaredSymbol(sourceProp, context); - - var sourcePropType = sourceProp.type; - var targetPropType = targetProp.type; - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - context.walkMemberTypes(targetProp.name); - var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); - context.postWalkMemberTypes(); - - if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - var names = getNames(false); - if (comparisonInfoPropertyTypeCheck && 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 { - 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 isSourcePropertyRelatableToTargetProperty; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); - var targetStringSig = targetIndexSigs.stringSignature; - var targetNumberSig = targetIndexSigs.numericSignature; - - if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); - var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); - var sourceStringSig = sourceIndexSigs.stringSignature; - var sourceNumberSig = sourceIndexSigs.numericSignature; - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - 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++) { - var mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - var nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { - continue; - } - - 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; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - - if (comparisonInfo && sigsCompared == 1) { - comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; - } - - return false; - } - - return true; - }; - - 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; - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; - var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; - - 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, [targetParameters.length])); - } - return false; - } - - if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { - return true; - } - - 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) { - context.walkReturnTypes(); - var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - context.postWalkReturnTypes(); - if (!returnTypesAreRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - - return false; - } - } - - 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 (!areParametersRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - } - - return areParametersRelatable; - }); - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { - var _this = this; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeComparisonInfo(); - var args = application.argumentList ? application.argumentList.arguments : null; - - var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { - if (hasOverloads && signature.isDefinition()) { - return false; - } - - var rootSignature = signature.getRootSymbol(); - if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { - return false; - } - - return _this.overloadHasCorrectArity(signature, args); - }); - - var firstAssignableButNotSupertypeSignature = null; - var firstAssignableWithProvisionalErrorsSignature = null; - - for (var i = 0; i < initialCandidates.length; i++) { - var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); - if (applicability === 3 /* Subtype */) { - return initialCandidates[i]; - } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { - firstAssignableButNotSupertypeSignature = initialCandidates[i]; - } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { - firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; - } - } - - if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { - return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; - } else { - var target = this.getCallTargetErrorSpanAST(application); - if (comparisonInfo.message) { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); - } else { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); - } - } - - return null; - }; - - PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { - return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; - }; - - PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { - if (args == null) { - return signature.nonOptionalParamCount === 0; - } - - var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); - if (numberOfArgs < signature.nonOptionalParamCount) { - return false; - } - if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { - if (args === null) { - return 3 /* Subtype */; - } - - var isInVarArg = false; - var parameters = signature.parameters; - var paramType = null; - - var overloadApplicability = 3 /* Subtype */; - - for (var i = 0; i < args.nonSeparatorCount(); i++) { - if (!isInVarArg) { - this.resolveDeclaredSymbol(parameters[i], context); - - if (parameters[i].isVarArg) { - paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); - isInVarArg = true; - } else { - paramType = parameters[i].type; - } - } - - var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); - - if (statusOfCurrentArgument === 0 /* NotAssignable */) { - return 0 /* NotAssignable */; - } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { - overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; - } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { - overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; - } - } - - return overloadApplicability; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType.isAny()) { - return 3 /* Subtype */; - } else if (paramType.isError()) { - return 1 /* AssignableButWithProvisionalErrors */; - } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrowFunction = arg; - 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.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.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 */) { - return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else { - return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); - } - }; - - PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { - if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - 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.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveObjectLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType === this.cachedArrayInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveArrayLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - var argSym = this.resolveAST(arg, false, context); - - if (argSym.type.isAlias()) { - var aliasSym = argSym.type; - argSym = aliasSym.getExportAssignedTypeSymbol(); - } - - comparisonInfo.stringConstantVal = arg; - return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { - var tempComparisonInfo = new TypeComparisonInfo(); - tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; - if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { - return 3 /* Subtype */; - } - - if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { - return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; - } - - if (!comparisonInfo.message) { - var enclosingSymbol = this.getEnclosingSymbolForAST(arg); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); - } - - return 0 /* NotAssignable */; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { - var inferenceResultTypes = argContext.inferTypeArguments(); - var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); - TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); - - 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 (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 inferenceResultTypes; - }; - - PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { - var enclosingDecl = this.getEnclosingDeclForAST(args); - var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); - return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; - }; - - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { - if (expressionType && parameterType) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); - return; - } - } - this.relateTypeToTypeParameters(expressionType, parameterType, 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; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType.isTypeParameter()) { - var typeParameter = parameterType; - argContext.addCandidateForInference(typeParameter, expressionType); - return; - } - - if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { - return; - } - - 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.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) { - return; - } - - var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeArguments = parameterType.getTypeArguments(); - - if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { - for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); - } - } - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var _this = this; - var expressionReturnType = expressionSignature.returnType; - var parameterReturnType = parameterSignature.returnType; - - parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { - context.walkParameterTypes(i); - _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); - context.postWalkParameterTypes(); - return true; - }); - - context.walkReturnTypes(); - this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); - context.postWalkReturnTypes(); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - return; - } - - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); - if (objectMember) { - this.resolveDeclaredSymbol(objectMember); - this.resolveDeclaredSymbol(parameterTypeMembers[i]); - context.walkMemberTypes(parameterTypeMembers[i].name); - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); - context.postWalkMemberTypes(); - } - } - - this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); - - this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; - } - - 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) { - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!typeParameters.length) { - return typeToSpecialize; - } - - var typeArguments = null; - - 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) { - typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; - } else { - typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; - } - } - - var type = this.createInstantiatedType(typeToSpecialize, typeArguments); - - 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(); - - var resolver = semanticInfoChain.getResolver(); - var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); - - if (resolver.canTypeCheckAST(sourceUnit, context)) { - resolver.resolveAST(sourceUnit, false, context); - resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); - - while (resolver.typeCheckCallBacks.length) { - var callBack = resolver.typeCheckCallBacks.pop(); - callBack(context); - } - - resolver.processPostTypeCheckWorkItems(context); - } - }; - - PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { - var _this = this; - this.scanVariableDeclarationGroups(enclosingDecl, function (_) { - }, function (subsequentDecl, firstSymbol) { - if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { - return; - } - - var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); - - var symbol = subsequentDecl.getSymbol(); - var symbolType = symbol.type; - var firstSymbolType = firstSymbol.type; - - 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) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i] === signature) { - break; - } - - 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)); - } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); - } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); - } else { - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved) { - this.resolveDeclaredSymbol(allSignatures[i], context); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - 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_assignable_to_any_non_specialized_signature)); - } - } - } else if (definitionSignature && definitionSignature !== signature) { - var comparisonInfo = new TypeComparisonInfo(); - - if (!definitionSignature.isResolved) { - this.resolveDeclaredSymbol(definitionSignature, context); - } - - if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { - var errorCode; - - 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; - } - - if (errorCode) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); - } - } - }; - - PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { - if (!symbol || symbol.kind === 2 /* Primitive */) { - return; - } - - if (symbol.isType()) { - var typeSymbol = symbol; - var isNamedType = typeSymbol.isNamedTypeSymbol(); - - if (typeSymbol.isArrayNamedTypeReference()) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); - return; - } - - if (!isNamedType) { - var typeOfSymbol = typeSymbol.getTypeOfSymbol(); - if (typeOfSymbol) { - this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); - return; - } - } - - if (typeSymbol.inSymbolPrivacyCheck) { - return; - } - - typeSymbol.inSymbolPrivacyCheck = true; - - var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); - if (typars) { - for (var i = 0; i < typars.length; i++) { - this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); - } - } - - if (!isNamedType) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind === 8192 /* TypeParameter */) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); - } - - typeSymbol.inSymbolPrivacyCheck = false; - - if (!isNamedType) { - return; - } - } - - if (declSymbol.isExternallyVisible()) { - var symbolIsVisible = symbol.isExternallyVisible(); - - 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]) { - 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(); - break; - } - } - symbol = symbolPath[symbolPath.length - 1]; - } - } else if (symbol.kind === 128 /* TypeAlias */) { - var aliasSymbol = symbol; - symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(); - } - - if (!symbolIsVisible) { - privacyErrorReporter(symbol); - } - } - }; - - PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length > 1 && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); - } - - var params = signature.parameters; - for (var j = 0; j < params.length; j++) { - var paramType = params[j].type; - this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); - } - - var returnType = signature.returnType; - this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); - } - }; - - 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; - var messageCode; - - var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; - } - } - - var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { - var typeSymbol = symbol; - var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isProperty = declSymbol.kind === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; - } - } else { - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return; - } - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; - var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; - var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); - var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); - this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { - return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); - }); - } - } - - if (!isGetter && !isIndexSignature) { - var funcParams = functionSignature.parameters; - for (var i = 0; i < funcParams.length; i++) { - this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); - }); - } - } - - if (!isSetter) { - this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); - }); - } - }; - - PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else if (!isGetter) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var parameter = parameters.astAt(argIndex); - - var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { - var _this = this; - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var messageCode = null; - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; - } - } - - if (messageCode) { - var messageArguments = [typeSymbolName]; - var reportOnFuncDecl = false; - - if (returnTypeAnnotation) { - var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); - } - } - - if (block) { - var reportErrorOnReturnExpressions = function (ast, walker) { - var go = true; - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - } - } - }; - - PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { - TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); - - var classSymbol = classDecl.getSymbol(); - return classSymbol.getExtendedTypes().length > 0; - }; - - PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { - if (ast.kind() === 213 /* InvocationExpression */) { - var invocationExpression = ast; - if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { - if (node && node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - if (this.isSuperInvocationExpression(expressionStatement.expression)) { - return true; - } - } - return false; - }; - - PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { - if (block && block.statements && block.statements.childCount() > 0) { - return block.statements.childAt(0); - } - - return null; - }; - - PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { - TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); - - if (constructorDecl) { - var enclosingClass = constructorDecl.getParentDecl(); - - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.kind === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.kind() === 242 /* Parameter */) { - return true; - } - - if (ast.kind() === 136 /* MemberVariableDeclaration */) { - var variableDeclarator = ast; - if (variableDeclarator.variableDeclarator.equalsValueClause) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { - var enclosingDecl = this.getEnclosingDeclForAST(expression); - - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var inArrowFunction = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - inArrowFunction = true; - continue; - } - - if (inArrowFunction) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - var constructorSymbol = decl.getSymbol().getConstructorMethod(); - var constructorDecls = constructorSymbol.getDeclarations(); - for (var i = 0; i < constructorDecls.length; i++) { - constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; - } - } - break; - } - } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { - break; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); - var stringSignature = indexSignatures.stringSignature; - var numberSignature = indexSignatures.numericSignature; - - if (stringSignature || numberSignature) { - var members = containerTypeDecl.getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { - var memberSymbol = member.getSymbol(); - var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); - if (relevantSignature) { - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { - this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); - } - } - } - } - } - }; - - PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { - if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { - return numberIndexSignature; - } else if (stringIndexSignature) { - return stringIndexSignature; - } - - return null; - }; - - PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { - 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.kind; - var extendedMemberKind = extendedTypeMember.kind; - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { - var typeMembers = typeSymbol.getMembers(); - - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - var foundError1 = false; - var foundError2 = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].name; - var extendedTypeProp = extendedType.findMember(propName, true); - if (extendedTypeProp) { - this.resolveDeclaredSymbol(extendedTypeProp, context); - foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); - - if (!foundError1) { - foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); - } - - if (foundError1 || foundError2) { - foundError = true; - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = typeSymbol.getConstructorMethod().type; - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = extendedType.getConstructorMethod().type; - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].name; - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved) { - this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); - } - - if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; - } else { - if (extendedType.isClass()) { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; - } else { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - } - } - } - - if (foundError) { - var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { - var prevInTypeCheck = context.inTypeCheck; - context.inTypeCheck = false; - - var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - - 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; - } - - if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { - return true; - } - - var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; - - if (associatedContainerType) { - return associatedContainerType !== typeSymbol.getRootSymbol(); - } - - return true; - }; - - PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - - var baseType = this.resolveTypeReference(baseDeclAST, context).type; - - if (!baseType) { - return; - } - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (!baseType.isError()) { - if (isExtendedType) { - if (typeDeclIsClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); - } - } - return; - } else if (typeDeclIsClass && isExtendedType) { - if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { - 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)])); - } - } - - if (baseType.hasBase(typeSymbol)) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); - return; - } - - if (isExtendedType) { - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); - }); - } else { - TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); - }); - } - - this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { - return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); - }); - }; - - PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { - var _this = this; - var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); - if (!extendsClause && !implementsClause) { - return; - } - - if (extendsClause) { - for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); - } - } - - if (typeSymbol.isClass()) { - if (implementsClause) { - for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); - } - } - } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { - var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { - return decl.ast().heritageClauses !== null; - }).ast(); - if (classOrInterface === firstInterfaceASTWithExtendsClause) { - this.typeCheckCallBacks.push(function (context) { - _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); - }); - } - } - }; - - PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { - var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); - - var inheritedMembersMap = TypeScript.createIntrinsicsObject(); - var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); - - var typeHasOwnNumberIndexer = false; - var typeHasOwnStringIndexer = false; - - if (typeSymbol.hasOwnIndexSignatures()) { - var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); - for (var i = 0; i < ownIndexSignatures.length; i++) { - if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { - typeHasOwnNumberIndexer = true; - } else { - typeHasOwnStringIndexer = true; - } - } - } - var baseTypes = typeSymbol.getExtendedTypes(); - for (var i = 0; i < baseTypes.length; i++) { - if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { - return; - } - } - - if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { - return; - } - - this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; - var memberName = member.name; - - if (interfaceSymbol.findMember(memberName, false)) { - continue; - } - - this.resolveDeclaredSymbol(member, context); - - if (inheritedMembersMap[memberName]) { - var prevMember = inheritedMembersMap[memberName]; - 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; - } - } else { - inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); - } - } - - return false; - }; - - PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { - if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { - return false; - } - - var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { - var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; - - var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - 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, 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; - } - } else { - allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } else if (parameterTypeIsNumber) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - 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; - } - } else { - allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { - if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; - var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; - for (var memberName in inheritedMembers) { - var memberWithBaseOrigin = inheritedMembers[memberName]; - if (!memberWithBaseOrigin) { - continue; - } - - var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); - if (!relevantSignature) { - continue; - } - - var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; - var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; - - if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { - continue; - } - - 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_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_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])); - } - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - 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_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, [ - interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), - inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.isReference = function (ast, astSymbol) { - if (ast.kind() === 217 /* ParenthesizedExpression */) { - return this.isReference(ast.expression, astSymbol); - } - - if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { - return false; - } - - if (ast.kind() === 11 /* IdentifierName */) { - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { - return false; - } - - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { - return false; - } - - if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { - return false; - } - } - - if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { - if (resolvedName) { - if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { - return this.semanticInfoChain.getEnclosingDecl(ast); - }; - - PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - return enclosingDecl ? enclosingDecl.getSymbol() : null; - }; - - PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { - if (resolvedName) { - if (resolvedName.anyDeclHasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var memberClass = memberContainer.getDeclarations()[0].ast(); - TypeScript.Debug.assert(memberClass); - - var containingClass = this.getEnclosingClassDeclaration(name); - - if (!containingClass || containingClass !== memberClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { - if (type.isPrimitive()) { - return type; - } - - if (type.isError()) { - return type; - } - - if (typeParameterArgumentMap[type.pullSymbolID]) { - return typeParameterArgumentMap[type.pullSymbolID]; - } - - type._resolveDeclaredSymbol(); - if (type.isTypeParameter()) { - return this.instantiateTypeParameter(type, typeParameterArgumentMap); - } - - if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - } - - return type; - }; - - 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 rootSignature = signature.getRootSymbol(); - var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); - TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); - - var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiatedSignature) { - return instantiatedSignature; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); - - 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) { - for (var j = 0; j < parameters.length; j++) { - parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].isOptional) { - parameter.isOptional = true; - } - if (parameters[j].isVarArg) { - parameter.isVarArg = true; - instantiatedSignature.hasVarArgs = true; - } - instantiatedSignature.addParameter(parameter, parameter.isOptional); - - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); - } - } - - return instantiatedSignature; - }; - PullTypeResolver.globalTypeCheckPhase = 0; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; - - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent; - if (!useSameIndent) { - this.indent++; - } - } - } - TypeComparisonInfo.prototype.indentString = function () { - var result = ""; - - for (var i = 0; i < this.indent; i++) { - result += "\t"; - } - - return result; - }; - - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = this.message + TypeScript.newLine() + this.indentString() + message; - } else { - this.message = this.indentString() + message; - } - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - function getPropertyAssignmentNameTextFromIdentifier(identifier) { - if (identifier.kind() === 11 /* IdentifierName */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 14 /* StringLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 13 /* NumericLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; - - function isTypesOnlyLocation(ast) { - while (ast && ast.parent) { - switch (ast.parent.kind()) { - case 244 /* TypeAnnotation */: - return true; - case 127 /* TypeQuery */: - return false; - case 125 /* ConstructorType */: - var constructorType = ast.parent; - if (constructorType.type === ast) { - return true; - } - break; - case 123 /* FunctionType */: - var functionType = ast.parent; - if (functionType.type === ast) { - return true; - } - break; - case 239 /* Constraint */: - var constraint = ast.parent; - if (constraint.type === ast) { - return true; - } - break; - case 220 /* CastExpression */: - var castExpression = ast.parent; - return castExpression.type === ast; - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - return true; - case 228 /* TypeArgumentList */: - return true; - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 130 /* ModuleDeclaration */: - case 129 /* FunctionDeclaration */: - case 145 /* MethodSignature */: - case 212 /* MemberAccessExpression */: - case 242 /* Parameter */: - return false; - } - - ast = ast.parent; - } - - return false; - } - TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var sentinalEmptyArray = []; - - var SemanticInfoChain = (function () { - function SemanticInfoChain(compiler, logger) { - this.compiler = compiler; - this.logger = logger; - this.documents = []; - this.fileNameToDocument = TypeScript.createIntrinsicsObject(); - this.anyTypeDecl = null; - this.booleanTypeDecl = null; - this.numberTypeDecl = null; - this.stringTypeDecl = null; - this.nullTypeDecl = null; - this.undefinedTypeDecl = null; - this.voidTypeDecl = null; - this.undefinedValueDecl = null; - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.voidTypeSymbol = null; - this.undefinedValueSymbol = null; - this.emptyTypeSymbol = null; - this.astSymbolMap = []; - this.astAliasSymbolMap = []; - this.astCallResolutionDataMap = []; - this.declSymbolMap = []; - this.declSignatureSymbolMap = []; - this.declCache = null; - this.symbolCache = null; - this.fileNameToDiagnostics = null; - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - 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); - 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 */, 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 || null; - }; - - SemanticInfoChain.prototype.lineMap = function (fileName) { - return this.getDocument(fileName).lineMap(); - }; - - SemanticInfoChain.prototype.fileNames = function () { - if (this._fileNames === null) { - this._fileNames = this.documents.slice(1).map(function (s) { - return s.fileName; - }); - } - - return this._fileNames; - }; - - SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { - newSymbol.addDeclaration(decl); - decl.setSymbol(newSymbol); - newSymbol.setResolved(); - - return newSymbol; - }; - - SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { - var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { - var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); - newSymbol.type = type; - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.resetGlobalSymbols = function () { - this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); - this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); - this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); - this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); - this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); - this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); - this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); - this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); - - var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); - var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - emptyTypeDecl.setSymbol(emptyTypeSymbol); - emptyTypeSymbol.addDeclaration(emptyTypeDecl); - emptyTypeSymbol.setResolved(); - this.emptyTypeSymbol = emptyTypeSymbol; - }; - - SemanticInfoChain.prototype.addDocument = function (document) { - var fileName = document.fileName; - - var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (existingIndex < 0) { - this.documents.push(document); - } else { - this.documents[existingIndex] = document; - } - - this.fileNameToDocument[fileName] = document; - - this.invalidate(); - }; - - SemanticInfoChain.prototype.removeDocument = function (fileName) { - TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); - var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (index > 0) { - this.fileNameToDocument[fileName] = undefined; - this.documents.splice(index, 1); - this.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { - var cacheID = this.getDeclPathCacheID([name], kind); - - var symbol = this.symbolCache[cacheID]; - - if (!symbol) { - for (var i = 0, n = this.documents.length; i < n; i++) { - var topLevelDecl = this.documents[i].topLevelDecl(); - - var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); - if (symbol) { - break; - } - - if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { - return null; - } - } - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { - var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; - - var foundDecls = topLevelDecl.searchChildDecls(name, kind); - - for (var j = 0; j < foundDecls.length; j++) { - var foundDecl = foundDecls[j]; - - if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { - break; - } - - var symbol = foundDecls[j].getSymbol(); - if (symbol) { - return symbol; - } - } - - return null; - }; - - SemanticInfoChain.prototype.findExternalModule = function (id) { - id = TypeScript.normalizePath(id); - - var tsFile = id + ".ts"; - var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); - symbol = this.symbolCache[tsCacheID]; - if (symbol != undefined) { - return symbol; - } - - 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 isTsFile = document.fileName === tsFile; - if (isTsFile || document.fileName === dtsFile) { - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - symbol = dynamicModuleDecl.getSymbol(); - - 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 null; - }; - - SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { - var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); - - var symbol = this.symbolCache[cacheID]; - if (symbol == undefined) { - symbol = null; - for (var i = 0; i < this.documents.length; i++) { - var document = this.documents[i]; - var topLevelDecl = document.topLevelDecl(); - - if (!topLevelDecl.isExternalModule()) { - var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); - if (dynamicModules.length) { - symbol = dynamicModules[0].getSymbol(); - break; - } - } - } - - this.symbolCache[cacheID] = symbol; - } - - return symbol; - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.topLevelDecls(); - - var decls = TypeScript.sentinelEmptyArray; - var path; - var foundDecls = TypeScript.sentinelEmptyArray; - - 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, kind); - - for (var k = 0; k < foundDecls.length; k++) { - if (decls === TypeScript.sentinelEmptyArray) { - decls = []; - } - decls[decls.length] = foundDecls[k]; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { - var declString = []; - - for (var i = 0, n = declPath.length; i < n; i++) { - if (declPath[i].kind & 1 /* Script */) { - continue; - } - - declString.push(declPath[i].name); - } - - return this.findDecls(declString, declKind); - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - 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; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - } - }; - - SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { - if (typeof oldSettings === "undefined") { oldSettings = null; } - if (typeof newSettings === "undefined") { newSettings = null; } - TypeScript.PullTypeResolver.globalTypeCheckPhase++; - - var cleanStart = new Date().getTime(); - - this.astSymbolMap.length = 0; - this.astAliasSymbolMap.length = 0; - this.astCallResolutionDataMap.length = 0; - - this.declCache = TypeScript.createIntrinsicsObject(); - this.symbolCache = TypeScript.createIntrinsicsObject(); - this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - - this.declSymbolMap.length = 0; - this.declSignatureSymbolMap.length = 0; - - if (oldSettings && newSettings) { - if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { - for (var i = 1, n = this.documents.length; i < n; i++) { - this.documents[i].invalidate(); - } - } - } - - TypeScript.pullSymbolID = 0; - - this.resetGlobalSymbols(); - - var cleanEnd = new Date().getTime(); - }; - - SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); - }; - - SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()] || null; - }; - - SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { - this.astAliasSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { - return this.astAliasSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { - return this.astCallResolutionDataMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { - if (callResolutionData) { - this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap[decl.declID] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { - this.declSignatureSymbolMap[decl.declID] = signatureSymbol; - }; - - SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { - return this.declSignatureSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { - var fileName = diagnostic.fileName(); - var diagnostics = this.fileNameToDiagnostics[fileName]; - if (!diagnostics) { - diagnostics = []; - this.fileNameToDiagnostics[fileName] = diagnostics; - } - - diagnostics.push(diagnostic); - }; - - SemanticInfoChain.prototype.getDiagnostics = function (fileName) { - var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics || []; - }; - - SemanticInfoChain.prototype.getBinder = function () { - if (!this._binder) { - this._binder = new TypeScript.PullSymbolBinder(this); - } - - return this._binder; - }; - - SemanticInfoChain.prototype.getResolver = function () { - if (!this._resolver) { - this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); - } - - return this._resolver; - }; - - SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); - indexParameterSymbol.type = indexParamType; - indexSignature.addParameter(indexParameterSymbol); - indexSignature.returnType = returnType; - indexSignature.setResolved(); - indexParameterSymbol.setResolved(); - - containingSymbol.addIndexSignature(indexSignature); - - 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); - indexParameterSymbol.addDeclaration(indexParamDecl); - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast) { - var document = this.getDocument(ast.fileName()); - - if (document) { - return document._getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { - return this.getDocument(ast.fileName()).getEnclosingDecl(ast); - }; - - SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { - this.getDocument(decl.fileName())._setDeclForAST(ast, decl); - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var document = this.getDocument(decl.fileName()); - if (document) { - return document._getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { - this.getDocument(decl.fileName())._setASTForDecl(decl, ast); - }; - - SemanticInfoChain.prototype.topLevelDecl = function (fileName) { - var document = this.getDocument(fileName); - if (document) { - return document.topLevelDecl(); - } - - return null; - }; - - SemanticInfoChain.prototype.topLevelDecls = function () { - if (!this._topLevelDecls) { - this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { - return u.topLevelDecl(); - }); - } - - return this._topLevelDecls; - }; - - 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, 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; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { - this.document = document; - this.semanticInfoChain = semanticInfoChain; - this.propagateEnumConstants = propagateEnumConstants; - this.isDeclareFile = false; - this.parentChain = []; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - - function containingModuleHasExportAssignment(ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = ast; - return moduleDecl.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } else if (ast.kind() === 120 /* SourceUnit */) { - var sourceUnit = ast; - return sourceUnit.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } - - ast = ast.parent; - } - - return false; - } - - function isParsingAmbientModule(ast, context) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { - return true; - } - } - - ast = ast.parent; - } - - return false; - } - - function preCollectImportDecls(ast, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - - var parent = context.getParent(); - - if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { - declFlags |= 1 /* Exported */; - } - - 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 fileName = sourceUnit.fileName(); - - var isExternalModule = context.document.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); - - context.isDeclareFile = context.document.isDeclareFile(); - - context.pushParent(decl); - - if (isExternalModule) { - var declFlags = 1 /* Exported */; - if (TypeScript.isDTSFile(fileName)) { - declFlags |= 8 /* Ambient */; - } - - var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); - var kind = 32 /* DynamicModule */; - var valueText = TypeScript.quoteStr(fileName); - - var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); - - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, sourceUnit, context); - } - - context.pushParent(decl); - } - } - - function preCollectEnumDecls(enumDecl, context) { - var declFlags = 0 /* None */; - var enumName = enumDecl.identifier.valueText(); - - if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - declFlags |= 4096 /* Enum */; - var kind = 64 /* Enum */; - - var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); - context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); - context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); - - var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); - enumDeclaration.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); - - context.pushParent(enumDeclaration); - } - - function createEnumElementDecls(propertyDecl, context) { - var parent = context.getParent(); - - var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function preCollectModuleDecls(moduleDecl, context) { - var declFlags = 0 /* None */; - - var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); - - var isDynamic = moduleDecl.stringLiteral !== null; - - if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - - 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()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); - } - - context.pushParent(decl); - } else { - var moduleNames = getModuleNames(moduleDecl.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - var moduleName = moduleNames[i]; - - var specificFlags = declFlags; - if (i > 0) { - specificFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleName, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleName); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleName, context); - } - - context.pushParent(decl); - } - } - } - - function getModuleNames(name, result) { - result = result || []; - - if (name.kind() === 121 /* QualifiedName */) { - getModuleNames(name.left, result); - result.push(name.right); - } else { - result.push(name); - } - - return result; - } - TypeScript.getModuleNames = getModuleNames; - - 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.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); - } - - function containsExecutableCode(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); - - if (member.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = member; - - if (containsExecutableCode(moduleDecl.moduleElements)) { - return true; - } - } else if (member.kind() === 133 /* ImportDeclaration */) { - if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { - return true; - } - } else if (member.kind() !== 128 /* InterfaceDeclaration */) { - return true; - } - } - - return false; - } - - function preCollectClassDecls(classDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var parent = context.getParent(); - - 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); - - decl.setValueDecl(constructorDecl); - - context.semanticInfoChain.setDeclForAST(classDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, classDecl); - context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); - - context.pushParent(decl); - } - - function preCollectObjectTypeDecls(objectType, context) { - if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { - return; - } - - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setDeclForAST(objectType, decl); - context.semanticInfoChain.setASTForDecl(decl, objectType); - - context.pushParent(decl); - } - - function preCollectInterfaceDecls(interfaceDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { - declFlags |= 1 /* Exported */; - } - - var parent = context.getParent(); - - 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); - - context.pushParent(decl); - } - - function preCollectParameterDecl(argDecl, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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 */) { - decl.setFlag(67108864 /* ConstructorParameter */); - } - - var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); - var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; - if (isPublicOrPrivate && isInConstructor) { - var parentsParent = context.parentChain[context.parentChain.length - 2]; - - 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 */) { - propDecl.setFlag(67108864 /* ConstructorParameter */); - } - - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setASTForDecl(propDecl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, decl); - } - - parent.addVariableDeclToGroup(decl); - } - - function preCollectTypeParameterDecl(typeParameterDecl, context) { - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); - context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); - } - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = 4096 /* Property */; - - if (propertyDecl.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - var parent = context.getParent(); - - 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); - } - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 512 /* Variable */; - - var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); - if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - 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); - context.semanticInfoChain.setDeclForAST(varDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, varDecl); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectVarDecls(ast, context) { - if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { - return; - } - - var varDecl = ast; - createVariableDeclaration(varDecl, context); - } - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 16777216 /* FunctionType */; - - 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); - context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); - - context.pushParent(decl); - } - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 33554432 /* ConstructorType */; - - 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); - context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); - - context.pushParent(decl); - } - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - if (!funcDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - 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); - context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); - - context.pushParent(decl); - } - - function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { - if (typeof displayName === "undefined") { displayName = null; } - var declFlags = 0 /* None */; - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - declFlags |= 8192 /* ArrowFunction */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = id ? id.text() : ""; - var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); - context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); - - context.pushParent(decl); - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrow = functionExpressionDeclAST; - var declFlags = 4 /* Public */; - - var parent = context.getParent(); - - if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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); - - parent.addVariableDeclToGroup(decl); - } - } - - function createMemberFunctionDeclaration(funcDecl, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!funcDecl.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(funcDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDecl); - - context.pushParent(decl); - } - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 4194304 /* IndexSignature */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); - - context.pushParent(decl); - } - - function createCallSignatureDeclaration(callSignature, context) { - var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; - - if (!isChildOfObjectType) { - return; - } - - var declFlags = 2048 /* Signature */; - var declType = 1048576 /* CallSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(callSignature, decl); - context.semanticInfoChain.setASTForDecl(decl, callSignature); - - context.pushParent(decl); - } - - function createMethodSignatureDeclaration(method, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - declFlags |= 4 /* Public */; - declFlags |= 2048 /* Signature */; - - if (method.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(method, decl); - context.semanticInfoChain.setASTForDecl(decl, method); - - context.pushParent(decl); - } - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 2097152 /* ConstructSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); - - context.pushParent(decl); - } - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.flags; - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); - - context.pushParent(decl); - } - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); - - context.pushParent(decl); - } - - function createFunctionExpressionDeclaration(expression, context) { - createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); - } - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); - - context.pushParent(decl); - } - - function preCollectCatchDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 268435456 /* CatchBlock */; - - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - - var declFlags = 0 /* None */; - var declType = 1024 /* CatchVariable */; - - 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); - context.semanticInfoChain.setDeclForAST(ast.identifier, decl); - context.semanticInfoChain.setASTForDecl(decl, ast.identifier); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectWithDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 134217728 /* WithBlock */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectObjectLiteralDecls(ast, context) { - var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); - - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectSimplePropertyAssignmentDecls(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()); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - } - - function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { - var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); - - 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); - - createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); - } - - function preCollectDecls(ast, context) { - switch (ast.kind()) { - case 120 /* SourceUnit */: - preCollectScriptDecls(ast, context); - break; - case 132 /* EnumDeclaration */: - preCollectEnumDecls(ast, context); - break; - case 243 /* EnumElement */: - createEnumElementDecls(ast, context); - break; - case 130 /* ModuleDeclaration */: - preCollectModuleDecls(ast, context); - break; - case 131 /* ClassDeclaration */: - preCollectClassDecls(ast, context); - break; - case 128 /* InterfaceDeclaration */: - preCollectInterfaceDecls(ast, context); - break; - case 122 /* ObjectType */: - preCollectObjectTypeDecls(ast, context); - break; - case 242 /* Parameter */: - preCollectParameterDecl(ast, context); - break; - case 136 /* MemberVariableDeclaration */: - createMemberVariableDeclaration(ast, context); - break; - case 141 /* PropertySignature */: - createPropertySignature(ast, context); - break; - case 225 /* VariableDeclarator */: - preCollectVarDecls(ast, context); - break; - case 137 /* ConstructorDeclaration */: - createClassConstructorDeclaration(ast, context); - break; - case 139 /* GetAccessor */: - createGetAccessorDeclaration(ast, context); - break; - case 140 /* SetAccessor */: - createSetAccessorDeclaration(ast, context); - break; - case 222 /* FunctionExpression */: - createFunctionExpressionDeclaration(ast, context); - break; - case 135 /* MemberFunctionDeclaration */: - createMemberFunctionDeclaration(ast, context); - break; - case 144 /* IndexSignature */: - createIndexSignatureDeclaration(ast, context); - break; - case 123 /* FunctionType */: - createFunctionTypeDeclaration(ast, context); - break; - case 125 /* ConstructorType */: - createConstructorTypeDeclaration(ast, context); - break; - case 142 /* CallSignature */: - createCallSignatureDeclaration(ast, context); - break; - case 143 /* ConstructSignature */: - createConstructSignatureDeclaration(ast, context); - break; - case 145 /* MethodSignature */: - createMethodSignatureDeclaration(ast, context); - break; - case 129 /* FunctionDeclaration */: - createFunctionDeclaration(ast, context); - break; - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - createAnyFunctionExpressionDeclaration(ast, null, context); - break; - case 133 /* ImportDeclaration */: - preCollectImportDecls(ast, context); - break; - case 238 /* TypeParameter */: - preCollectTypeParameterDecl(ast, context); - break; - case 236 /* CatchClause */: - preCollectCatchDecls(ast, context); - break; - case 163 /* WithStatement */: - preCollectWithDecls(ast, context); - break; - case 215 /* ObjectLiteralExpression */: - preCollectObjectLiteralDecls(ast, context); - break; - case 240 /* SimplePropertyAssignment */: - preCollectSimplePropertyAssignmentDecls(ast, context); - break; - case 241 /* FunctionPropertyAssignment */: - preCollectFunctionPropertyAssignmentDecls(ast, context); - break; - } - } - - function isContainer(decl) { - return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.kind & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.kind & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.kind; - - if (kind & 4 /* Container */) { - return (decl.flags & 32768 /* InitializedModule */) !== 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, context) { - var currentDecl = context.getParent(); - - if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { - if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - return; - } - } - - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDeclaration = ast; - if (moduleDeclaration.stringLiteral) { - TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); - context.popParent(); - } else { - var moduleNames = getModuleNames(moduleDeclaration.name); - for (var i = moduleNames.length - 1; i >= 0; i--) { - var moduleName = moduleNames[i]; - TypeScript.Debug.assert(currentDecl.ast() === moduleName); - context.popParent(); - currentDecl = context.getParent(); - } - } - } - - if (ast.kind() === 132 /* EnumDeclaration */) { - computeEnumElementConstantValues(ast, currentDecl, context); - } - - while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { - context.popParent(); - currentDecl = context.getParent(); - } - } - - function computeEnumElementConstantValues(ast, enumDecl, context) { - TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); - - var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); - var inConstantSection = !isAmbientEnum; - var currentConstantValue = 0; - var enumMemberDecls = enumDecl.getChildDecls(); - - for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { - var enumElement = ast.enumElements.nonSeparatorAt(i); - var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { - return context.semanticInfoChain.getASTForDecl(d) === enumElement; - }); - - TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); - - if (enumElement.equalsValueClause === null) { - if (inConstantSection) { - enumElementDecl.constantValue = currentConstantValue; - currentConstantValue++; - } - } else { - enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); - if (enumElementDecl.constantValue !== null && !isAmbientEnum) { - inConstantSection = true; - currentConstantValue = enumElementDecl.constantValue + 1; - } else { - inConstantSection = false; - } - } - - TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); - } - } - - function computeEnumElementConstantValue(expression, enumMemberDecls, context) { - TypeScript.Debug.assert(expression); - - if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { - var token; - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - token = expression.operand; - break; - default: - token = expression; - } - - var value = token.value(); - return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; - } else if (context.propagateEnumConstants) { - switch (expression.kind()) { - case 11 /* IdentifierName */: - var name = expression; - var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { - return d.name === name.valueText(); - }); - - return matchingEnumElement ? matchingEnumElement.constantValue : null; - - case 202 /* LeftShiftExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left << right; - - case 189 /* BitwiseOrExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left | right; - } - - return null; - } else { - return null; - } - } - - (function (DeclarationCreator) { - function create(document, semanticInfoChain, compilationSettings) { - var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); - - TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); - - return declCollectionContext.getParent(); - } - DeclarationCreator.create = create; - })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); - var DeclarationCreator = TypeScript.DeclarationCreator; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBinder = (function () { - 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 */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.hasBeenBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - if (parent) { - var parentDeclKind = parentDecl.kind; - if (parentDeclKind === 262144 /* GetAccessor */) { - parent = parent.getGetter(); - } else if (parentDeclKind === 524288 /* SetAccessor */) { - parent = parent.getSetter(); - } - } - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = parent.getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.type; - } - } - - return parent.type; - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.name, declKind); - } - - var contextSymbolPath = startingDecl.getParentPath(); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].kind & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - }; - - PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { - var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; - var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; - var name = decl.name; - if (parent) { - var isExported = (decl.flags & 1 /* Exported */) !== 0; - - var prevSymbol = null; - if (lookingForValue) { - prevSymbol = parent.findContainedNonMember(name); - } else if (lookingForType) { - prevSymbol = parent.findContainedNonMemberType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); - } - var prevIsExported = !prevSymbol; - if (!prevSymbol) { - if (lookingForValue) { - prevSymbol = parent.findMember(name, false); - } else if (lookingForType) { - prevSymbol = parent.findNestedType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findNestedContainer(name, searchKind); - } - } - - if (isExported && prevIsExported) { - return prevSymbol; - } - if (prevSymbol) { - var prevDecls = prevSymbol.getDeclarations(); - var lastPrevDecl = prevDecls[prevDecls.length - 1]; - var parentDecl = decl.getParentDecl(); - var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); - if (parentDecl !== prevParentDecl) { - return null; - } - - return prevSymbol; - } - } else { - var parentDecl = decl.getParentDecl(); - if (parentDecl && parentDecl.kind === 1 /* Script */) { - return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); - } else { - var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); - return prevDecls[0] && prevDecls[0].getSymbol(); - } - } - - return null; - }; - - PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { - if (typeof reportError === "undefined") { reportError = true; } - 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 (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()]); - } - return false; - } - - 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; - - var enumContainerSymbol = null; - var enumInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var enumInstanceDecl = enumContainerDecl.getValueDecl(); - - var enumDeclKind = enumContainerDecl.kind; - - var parent = this.getParent(enumContainerDecl); - var parentInstanceSymbol = this.getParent(enumContainerDecl, true); - var parentDecl = enumContainerDecl.getParentDecl(); - var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); - - var isExported = enumContainerDecl.flags & 1 /* Exported */; - - var createdNewSymbol = false; - - enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); - - if (enumContainerSymbol) { - if (enumContainerSymbol.kind !== enumDeclKind) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); - enumContainerSymbol = null; - } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { - enumContainerSymbol = null; - } - } - - if (enumContainerSymbol) { - enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); - } else { - enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); - } - } - - enumContainerSymbol.addDeclaration(enumContainerDecl); - enumContainerDecl.setSymbol(enumContainerSymbol); - - this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); - this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - - if (!enumInstanceSymbol) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] === enumContainerDecl) { - break; - } - - if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol) { - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - enumInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); - } - - enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - enumInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); - } - } - - if (createdNewSymbol && parent) { - if (enumContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(enumContainerSymbol); - } else { - parent.addEnclosedNonMemberType(enumContainerSymbol); - } - } - - if (createdNewSymbol) { - this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); - } - var valueDecl = enumContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - }; - - 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(); - - enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); - }; - - 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(); - - 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); - if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); - TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); - - moduleDeclAST = moduleNameAST; - } - - var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); - var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; - - if (parent && moduleKind === 32 /* DynamicModule */) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); - } - - var createdNewSymbol = false; - - moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); - - if (moduleContainerTypeSymbol) { - if (moduleContainerTypeSymbol.kind !== moduleKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); - } - - moduleContainerTypeSymbol = null; - } 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) { - moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); - this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); - - var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); - - var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - - if (createdNewSymbol) { - if (parent) { - if (moduleContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); - } else { - parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); - } - } - } - - if (currentModuleValueDecl) { - currentModuleValueDecl.ensureSymbolIsBound(); - - 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); - } - } - - if (!instanceSymbol.type) { - instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - } - - moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); - - if (!instanceSymbol.type.getAssociatedContainerType()) { - instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.flags; - var declKind = importDeclaration.kind; - var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); - - var isExported = false; - var importSymbol = null; - var declName = importDeclaration.name; - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); - importSymbol = null; - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(importSymbol); - } else { - parent.addEnclosedNonMemberContainer(importSymbol); - } - } - }; - - 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; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - 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, 58728795 /* SomeType */, parent); - - if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); - classSymbol = null; - } - - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); - this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); - - if (parent) { - if (classDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(classSymbol); - } else { - parent.addEnclosedNonMemberType(classSymbol); - } - } - - 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; - - if (!constructorSymbol) { - var siblingValueDecls = null; - if (parentDecl) { - siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); - - if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { - constructorSymbol = siblingValueDecls[0].getSymbol(); - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - constructorSymbol.setIsSynthesized(); - constructorSymbol.type = constructorTypeSymbol; - } - - classSymbol.setConstructorMethod(constructorSymbol); - classSymbol.setHasDefaultConstructor(); - } - - if (constructorSymbol.getIsSynthesized()) { - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - constructorTypeSymbol.addDeclaration(classDecl); - } else { - classSymbol.setHasDefaultConstructor(false); - } - - constructorTypeSymbol.setAssociatedContainerType(classSymbol); - - var valueDecl = classDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.name; - var interfaceSymbol = null; - - var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); - - if (interfaceSymbol) { - if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); - interfaceSymbol = null; - } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { - interfaceSymbol = null; - } - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - if (interfaceDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(interfaceSymbol); - } else { - parent.addEnclosedNonMemberType(interfaceSymbol); - } - } - } - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - interfaceSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - - break; - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { - var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.kind; - var declFlags = constructorTypeDeclaration.flags; - var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); - - var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - signature.hasVarArgs = true; - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - 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; - - var variableSymbol = null; - - var declName = variableDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - 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; - variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); - - if (!variableSymbol && isModuleValue) { - variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); - } - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var decl; - var decls; - var ast; - var members; - - if (variableSymbol) { - var prevKind = variableSymbol.kind; - var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); - var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); - var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); - var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - 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 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 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.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 || 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); - variableSymbol = null; - parentHadSymbol = false; - } - } - - if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } - } - - if ((declFlags & 118784 /* ImplicitVariable */) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - if (!parent && parentDecl.kind === 1 /* Script */) { - this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); - } - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - if (!classTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - classTypeSymbol = containerDecl.getSymbol(); - if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfoChain.getASTForDecl(decl); - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else if (declFlags & 102400 /* SomeInitializedModule */) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - if (!moduleContainerTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - moduleContainerTypeSymbol = containerDecl.getSymbol(); - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - 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); - } - variableDeclaration.setSymbol(variableSymbol); - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - 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); - } else { - parent.addEnclosedNonMember(variableSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var declName = variableDeclaration.name; - - var variableSymbol = new TypeScript.PullSymbol(declName, declKind); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - - this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); - }; - - PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - var propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - - var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; - - var isStatic = false; - var isOptional = false; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); - - if (isOptional) { - propertySymbol.isOptional = true; - } - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { - var parameters = []; - var params = TypeScript.createIntrinsicsObject(); - var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); - - if (parameterList) { - for (var i = 0, n = parameterList.length; i < n; i++) { - var argDecl = parameterList.astAt(i); - var id = parameterList.identifierAt(i); - var decl = this.semanticInfoChain.getDeclForAST(argDecl); - var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); - var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); - - if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { - parameterSymbol.isVarArg = 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); - - if (signatureSymbol.isDefinition()) { - funcType.addEnclosedNonMember(parameterSymbol); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.kind; - var declFlags = functionDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); - - if (functionSymbol) { - 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); - functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); - } - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.type; - parentHadSymbol = true; - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionSymbol.type = functionTypeSymbol; - functionTypeSymbol.setFunctionSymbol(functionSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol); - } else { - parent.addEnclosedNonMember(functionSymbol); - } - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { - signature.hasVarArgs = true; - } - - var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.kind; - var declFlags = functionExpressionDeclaration.flags; - var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); - - 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionTypeSymbol.setFunctionSymbol(functionSymbol); - - functionSymbol.type = functionTypeSymbol; - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; - if (name) { - this.semanticInfoChain.setSymbolForAST(name, functionSymbol); - } - - this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); - - if (parameters.lastParameterIsRest()) { - signature.hasVarArgs = true; - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.kind; - var declFlags = functionTypeDeclaration.flags; - var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.kind; - var declFlags = methodDeclaration.flags; - var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - methodSymbol = parent.findMember(methodName, false); - - if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.type; - parentHadSymbol = true; - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - methodSymbol.type = methodTypeSymbol; - methodTypeSymbol.setFunctionSymbol(methodSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - - var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; - - TypeScript.Debug.assert(nameAST); - - this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); - this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); - - if (isOptional) { - methodSymbol.isOptional = true; - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol); - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); - - var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); - if (TypeScript.lastParameterIsRest(parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].name; - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); - signature.addTypeParameter(typeParameter); - } else { - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); - methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { - var prototypeStr = "prototype"; - - var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); - if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { - 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], this.semanticInfoChain); - - prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - prototypeSymbol.setIsSynthesized(); - prototypeSymbol.addDeclaration(prototypeDecl); - prototypeSymbol.type = classTypeSymbol; - constructorTypeSymbol.addMember(prototypeSymbol); - - if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { - var resolver = this.semanticInfoChain.getResolver(); - prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); - } - prototypeSymbol.setResolved(); - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.kind; - var declFlags = constructorDeclaration.flags; - var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { - var hasDefinitionSignature = false; - var constructorSigs = constructorSymbol.type.getConstructSignatures(); - - for (var i = 0; i < constructorSigs.length; i++) { - if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { - hasDefinitionSignature = true; - break; - } - } - - if (hasDefinitionSignature) { - this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); - - constructorSymbol = null; - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.type = constructorTypeSymbol; - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - constructorSymbol.setIsSynthesized(false); - this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); - constructSignature.returnType = parent; - constructSignature.addTypeParametersFromReturnType(); - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - constructorTypeSymbol.appendConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - constructSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); - parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { - callSignature.hasVarArgs = true; - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - callSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); - parent.insertCallSignatureAtIndex(callSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); - - var parent = this.getParent(indexSignatureDeclaration); - parent.addIndexSignature(indexSignature); - indexSignature.setContainer(parent); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.kind; - var declFlags = getAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.type; - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - getterTypeSymbol.setFunctionSymbol(getterSymbol); - - getterSymbol.type = getterTypeSymbol; - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - - getterTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.kind; - var declFlags = setAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - - if (setterSymbol) { - setterTypeSymbol = setterSymbol.type; - } - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - setterTypeSymbol.setFunctionSymbol(setterSymbol); - - setterSymbol.type = setterTypeSymbol; - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { - this.bindAllDeclsToPullSymbol(decl); - } - }; - - 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) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - this.bindEnumDeclarationToPullSymbol(decl); - break; - - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 512 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 1024 /* CatchVariable */: - this.bindCatchVariableToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - this.bindEnumMemberDeclarationToPullSymbol(decl); - break; - - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 128 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - decl.getParentDecl().getSymbol(); - break; - - case 268435456 /* CatchBlock */: - case 134217728 /* WithBlock */: - break; - - default: - TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); - } - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); - this.declsBeingBound.pop(); - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (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(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().type; - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.type; - } - var signatures; - - if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (functionDecl.kind === 4194304 /* IndexSignature */) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; - } - PullHelpers.symbolIsEnum = symbolIsEnum; - - function symbolIsModule(symbol) { - return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); - } - PullHelpers.symbolIsModule = symbolIsModule; - - function isOneDeclarationOfKind(symbol, kind) { - var decls = symbol.getDeclarations(); - for (var i = 0; i < decls.length; i++) { - if (decls[i].kind === kind) { - return true; - } - } - - return false; - } - - function isNameNumeric(name) { - return isFinite(+name); - } - PullHelpers.isNameNumeric = isNameNumeric; - - function typeSymbolsAreIdentical(a, b) { - if (a.isTypeReference() && !a.getIsSpecialized()) { - a = a.referencedTypeSymbol; - } - - if (b.isTypeReference() && !b.getIsSpecialized()) { - b = b.referencedTypeSymbol; - } - - return a === b; - } - PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; - - function getRootType(type) { - var rootType = type.getRootSymbol(); - - while (true) { - if (type === rootType) { - return type; - } - - type = rootType; - rootType = type.getRootSymbol(); - } - } - PullHelpers.getRootType = getRootType; - - function isSymbolLocal(symbol) { - var container = symbol.getContainer(); - if (container) { - var containerKind = container.kind; - if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { - return true; - } - - if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { - return true; - } - } - - 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; - -var TypeScript; -(function (TypeScript) { - TypeScript.fileResolutionTime = 0; - TypeScript.fileResolutionIOTime = 0; - TypeScript.fileResolutionScanImportsTime = 0; - TypeScript.fileResolutionImportFileSearchTime = 0; - TypeScript.fileResolutionGetDefaultLibraryTime = 0; - TypeScript.sourceCharactersCompiled = 0; - TypeScript.syntaxTreeParseTime = 0; - TypeScript.syntaxDiagnosticsTime = 0; - TypeScript.astTranslationTime = 0; - TypeScript.typeCheckTime = 0; - - TypeScript.compilerResolvePathTime = 0; - TypeScript.compilerDirectoryNameTime = 0; - TypeScript.compilerDirectoryExistsTime = 0; - TypeScript.compilerFileExistsTime = 0; - - TypeScript.emitTime = 0; - TypeScript.emitWriteFileTime = 0; - - TypeScript.declarationEmitTime = 0; - TypeScript.declarationEmitIsExternallyVisibleTime = 0; - TypeScript.declarationEmitTypeSignatureTime = 0; - TypeScript.declarationEmitGetBoundDeclTypeTime = 0; - TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; - TypeScript.declarationEmitGetBaseTypeTime = 0; - TypeScript.declarationEmitGetAccessorFunctionTime = 0; - TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; - TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; - - TypeScript.ioHostResolvePathTime = 0; - TypeScript.ioHostDirectoryNameTime = 0; - 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(emitOutputResult) { - if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } - this.outputFiles = []; - this.emitOutputResult = emitOutputResult; - } - return EmitOutput; - })(); - TypeScript.EmitOutput = EmitOutput; - - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); - var OutputFileType = TypeScript.OutputFileType; - - var OutputFile = (function () { - function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { - if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.text = text; - this.fileType = fileType; - this.sourceMapEntries = sourceMapEntries; - } - return OutputFile; - })(); - TypeScript.OutputFile = OutputFile; - - var CompileResult = (function () { - function CompileResult() { - this.diagnostics = []; - this.outputFiles = []; - } - CompileResult.fromDiagnostics = function (diagnostics) { - var result = new CompileResult(); - result.diagnostics = diagnostics; - return result; - }; - - CompileResult.fromOutputFiles = function (outputFiles) { - var result = new CompileResult(); - result.outputFiles = outputFiles; - return result; - }; - return CompileResult; - })(); - TypeScript.CompileResult = CompileResult; - - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, _settings) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } - this.logger = logger; - this._settings = _settings; - this.semanticInfoChain = null; - this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); - } - TypeScriptCompiler.prototype.compilationSettings = function () { - return this._settings; - }; - - TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { - var oldSettings = this._settings; - this._settings = newSettings; - - if (!compareDataObjects(oldSettings, newSettings)) { - this.semanticInfoChain.invalidate(oldSettings, newSettings); - } - }; - - TypeScriptCompiler.prototype.getDocument = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.semanticInfoChain.getDocument(fileName); - }; - - TypeScriptCompiler.prototype.cleanupSemanticCache = function () { - this.semanticInfoChain.invalidate(); - }; - - TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - fileName = TypeScript.switchToForwardSlashes(fileName); - - TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); - - var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); - - this.semanticInfoChain.addDocument(document); - }; - - TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); - - this.semanticInfoChain.addDocument(updatedDocument); - }; - - TypeScriptCompiler.prototype.removeFile = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - this.semanticInfoChain.removeDocument(fileName); - }; - - TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { - if (document.emitToOwnOutputFile()) { - var updatedFileName = document.fileName; - if (emitOptions.outputDirectory() !== "") { - updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); - updatedFileName = emitOptions.outputDirectory() + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(emitOptions.sharedOutputFile(), true); - } - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - var printReason = false; - - if (document.emitToOwnOutputFile()) { - var result = document.byteOrderMark !== 0 /* None */; - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - } - return result; - } else { - var fileNames = this.fileNames(); - - var result = false; - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - - if (document.isExternalModule()) { - continue; - } - - if (document.byteOrderMark !== 0 /* None */) { - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - result = true; - } else { - return true; - } - } - } - - return result; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype._shouldEmit = function (document) { - return !document.isDeclareFile(); - }; - - TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { - if (!this.compilationSettings().generateDeclarationFiles()) { - return false; - } - - return this._shouldEmit(document); - }; - - TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); - - if (declarationEmitter) { - declarationEmitter.document = document; - } else { - var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); - } - - declarationEmitter.emitDeclarations(sourceUnit); - return declarationEmitter; - }; - - TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmitDeclarations(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFile()); - } - } else { - sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var sharedEmitter = null; - var fileNames = this.fileNames(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileNames[i]); - - sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); - } - - TypeScript.declarationEmitTime += new Date().getTime() - start; - - return emitOutput; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, null); - return emitOutput; - } else { - return this.emitAllDeclarations(resolvePath); - } - }; - - 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; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmit(document)); - - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); - var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); - - if (this.compilationSettings().mapSourceFiles()) { - var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); - emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); - } - } else if (this.compilationSettings().mapSourceFiles()) { - emitter.setSourceMapperNewSourceFile(document); - } - - emitter.setDocument(document); - emitter.emitJavascript(sourceUnit, false); - - return emitter; - }; - - TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmit(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFiles()); - } - } else { - sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var fileNames = this.fileNames(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - sharedEmitter = this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); - } - - TypeScript.emitTime += new Date().getTime() - start; - return emitOutput; - }; - - TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, null); - return emitOutput; - } else { - return this.emitAll(resolvePath); - } - }; - - TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { - if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } - return new CompilerIterator(this, resolvePath, continueOnDiagnostics); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - - TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { - return this.getDocument(fileName).sourceUnit(); - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - - var startTime = (new Date()).getTime(); - TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); - var endTime = (new Date()).getTime(); - - TypeScript.typeCheckTime += endTime - startTime; - - var errors = this.semanticInfoChain.getDiagnostics(fileName); - - errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); - errors.sort(function (d1, d2) { - if (d1.fileName() < d2.fileName()) { - return -1; - } else if (d1.fileName() > d2.fileName()) { - return 1; - } - - if (d1.start() < d2.start()) { - return -1; - } else if (d1.start() > d2.start()) { - return 1; - } - - var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; - var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; - if (code1 < code2) { - return -1; - } else if (code1 > code2) { - return 1; - } - - return 0; - }); - - 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++) { - this.getSemanticDiagnostics(fileNames[i]); - } - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var ast = this.semanticInfoChain.getASTForDecl(decl); - if (!ast) { - return null; - } - - var enclosingDecl = resolver.getEnclosingDecl(decl); - if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { - return this.getSymbolOfDeclaration(enclosingDecl); - } - - return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { - var scriptName = document.fileName; - - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - var inWithBlock = false; - - var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); - - if (!ast) { - return null; - } - - var path = this.getASTPath(ast); - - for (var i = 0, n = path.length; i < n; i++) { - var current = path[i]; - - switch (current.kind()) { - case 222 /* FunctionExpression */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - if (propagateContextualTypes) { - resolver.resolveAST(current, true, resolutionContext); - } - break; - - case 136 /* MemberVariableDeclaration */: - var memberVariable = current; - inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); - break; - - case 225 /* VariableDeclarator */: - var variableDeclarator = current; - inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); - break; - - case 213 /* InvocationExpression */: - case 216 /* ObjectCreationExpression */: - if (propagateContextualTypes) { - var isNew = current.kind() === 216 /* ObjectCreationExpression */; - var callExpression = current; - var contextualType = null; - - if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = path[i + 3]; - if (argExpression) { - for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { - if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext); - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 214 /* ArrayLiteralExpression */: - if (propagateContextualTypes) { - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 215 /* ObjectLiteralExpression */: - if (propagateContextualTypes) { - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.propertyAssignments; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { - if (memberDecls.nonSeparatorAt(j) === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - } - - break; - - case 174 /* AssignmentExpression */: - if (propagateContextualTypes) { - var assignmentExpression = current; - var contextualType = null; - - if (path[i + 1] && path[i + 1] === assignmentExpression.right) { - var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - 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; - - case 150 /* ReturnStatement */: - if (propagateContextualTypes) { - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 122 /* ObjectType */: - if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { - resolver.resolveAST(current, false, resolutionContext); - } - - break; - - case 163 /* WithStatement */: - inWithBlock = true; - break; - - case 146 /* Block */: - inContextuallyTypedAssignment = false; - break; - } - - var decl = this.semanticInfoChain.getDeclForAST(current); - if (decl) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { - if (ast.parent.kind() === 212 /* MemberAccessExpression */) { - if (ast.parent.name === ast) { - ast = ast.parent; - } - } else if (ast.parent.kind() === 121 /* QualifiedName */) { - if (ast.parent.right === ast) { - ast = ast.parent; - } - } - } - - return { - ast: ast, - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment, - inWithBlock: inWithBlock - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { - if (inContextuallyTypedAssignment) { - if (propagateContextualTypes) { - resolver.resolveAST(assigningAST, false, resolutionContext); - var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.type; - } - - resolutionContext.pushNewContextualType(contextualType); - - if (init) { - resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); - } - } - } - }; - - TypeScriptCompiler.prototype.getASTPath = function (ast) { - var result = []; - - while (ast) { - result.unshift(ast); - ast = ast.parent; - } - - return result; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - ast = context.ast; - 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()]); - return null; - } - - if (symbol.isTypeReference()) { - symbol = symbol.getReferencedTypeSymbol(); - } - - var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); - - return { - symbol: symbol, - aliasSymbol: aliasSymbol, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { - if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { - return null; - } - - var isNew = ast.kind() === 216 /* ObjectCreationExpression */; - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, false); - if (!context || context.inWithBlock) { - return null; - } - - return resolver.getVisibleDecls(context.enclosingDecl); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { - if (ast.kind() !== 215 /* ObjectLiteralExpression */) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var astForDecl = decl.ast(); - if (!astForDecl) { - return null; - } - - var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); - if (!astForDeclContext) { - return null; - } - - var symbol = decl.getSymbol(); - resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - aliasSymbol: null, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - - TypeScriptCompiler.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast); - }; - - TypeScriptCompiler.prototype.fileNames = function () { - return this.semanticInfoChain.fileNames(); - }; - - 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; - - var CompilerPhase; - (function (CompilerPhase) { - CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; - CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; - CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; - CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; - CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; - })(CompilerPhase || (CompilerPhase = {})); - - var CompilerIterator = (function () { - function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { - if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } - this.compiler = compiler; - this.resolvePath = resolvePath; - this.continueOnDiagnostics = continueOnDiagnostics; - this.index = -1; - this.fileNames = null; - this._current = null; - this._emitOptions = null; - this._sharedEmitter = null; - this._sharedDeclarationEmitter = null; - this.hadSyntacticDiagnostics = false; - this.hadSemanticDiagnostics = false; - this.hadEmitDiagnostics = false; - this.fileNames = compiler.fileNames(); - this.compilerPhase = startingPhase; - } - CompilerIterator.prototype.current = function () { - return this._current; - }; - - CompilerIterator.prototype.moveNext = function () { - this._current = null; - - while (this.moveNextInternal()) { - if (this._current) { - return true; - } - } - - return false; - }; - - CompilerIterator.prototype.moveNextInternal = function () { - this.index++; - - while (this.shouldMoveToNextPhase()) { - this.index = 0; - this.compilerPhase++; - } - - if (this.compilerPhase > 4 /* DeclarationEmit */) { - return false; - } - - switch (this.compilerPhase) { - case 0 /* Syntax */: - return this.moveNextSyntaxPhase(); - case 1 /* Semantics */: - return this.moveNextSemanticsPhase(); - case 2 /* EmitOptionsValidation */: - return this.moveNextEmitOptionsValidationPhase(); - case 3 /* Emit */: - return this.moveNextEmitPhase(); - case 4 /* DeclarationEmit */: - return this.moveNextDeclarationEmitPhase(); - } - }; - - CompilerIterator.prototype.shouldMoveToNextPhase = function () { - switch (this.compilerPhase) { - case 2 /* EmitOptionsValidation */: - return this.index === 1; - - case 0 /* Syntax */: - case 1 /* Semantics */: - return this.index === this.fileNames.length; - - case 3 /* Emit */: - case 4 /* DeclarationEmit */: - return this.index === (this.fileNames.length + 1); - } - - return false; - }; - - CompilerIterator.prototype.moveNextSyntaxPhase = function () { - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - - var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSyntacticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextSemanticsPhase = function () { - if (this.hadSyntacticDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - var diagnostics = this.compiler.getSemanticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSemanticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - - if (!this._emitOptions) { - this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); - } - - if (this._emitOptions.diagnostic()) { - if (!this.continueOnDiagnostics) { - this.hadEmitDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(this._emitOptions); - - if (this.hadEmitDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { - _this._current = CompileResult.fromOutputFiles(outputFiles); - }, this._sharedEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedEmitter) { - this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); - } - - return true; - }; - - CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(!this.hadEmitDiagnostics); - if (this.hadSemanticDiagnostics) { - return false; - } - - if (!this.compiler.compilationSettings().generateDeclarationFiles()) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { - _this._current = CompileResult.fromOutputFiles([file]); - }, this._sharedDeclarationEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { - this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); - } - - return true; - }; - return CompilerIterator; - })(); - - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - TypeScript.compareDataObjects = compareDataObjects; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (GenerativeTypeClassification) { - GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; - GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; - GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; - GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; - })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); - var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; - - var PullTypeReferenceSymbol = (function (_super) { - __extends(PullTypeReferenceSymbol, _super); - function PullTypeReferenceSymbol(referencedTypeSymbol) { - _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); - this.referencedTypeSymbol = referencedTypeSymbol; - this.isResolved = true; - - TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); - - this.setRootSymbol(referencedTypeSymbol); - - this.typeReference = this; - } - PullTypeReferenceSymbol.createTypeReference = function (type) { - if (type.isTypeReference()) { - return type; - } - - var typeReference = type.typeReference; - - if (!typeReference) { - typeReference = new PullTypeReferenceSymbol(type); - type.typeReference = typeReference; - } - - return typeReference; - }; - - PullTypeReferenceSymbol.prototype.isTypeReference = function () { - return true; - }; - - PullTypeReferenceSymbol.prototype.setResolved = function () { - }; - - PullTypeReferenceSymbol.prototype.setUnresolved = function () { - }; - PullTypeReferenceSymbol.prototype.invalidate = function () { - }; - - PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { - this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); - }; - - PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol; - }; - - PullTypeReferenceSymbol.prototype._getResolver = function () { - return this.referencedTypeSymbol._getResolver(); - }; - - PullTypeReferenceSymbol.prototype.hasMembers = function () { - return this.referencedTypeSymbol.hasMembers(); - }; - - PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); - }; - - PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - return this.referencedTypeSymbol.getAssociatedContainerType(); - }; - - PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getFunctionSymbol(); - }; - PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); - }; - - PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); - }; - PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); - }; - - PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); - }; - PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMember(name); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); - }; - - PullTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getMembers(); - }; - - PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); - }; - PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getHasDefaultConstructor(); - }; - PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructorMethod(); - }; - PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); - }; - PullTypeReferenceSymbol.prototype.getTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.isGeneric = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isGeneric(); - }; - - PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getSpecialization(substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getKnownSpecializations(); - }; - PullTypeReferenceSymbol.prototype.getTypeArguments = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArguments(); - }; - PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); - }; - 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"); - }; - - PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnIndexSignatures(); - }; - PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getIndexSignatures(); - }; - - PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { - this.referencedTypeSymbol.addImplementedType(implementedType); - }; - PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getImplementedTypes(); - }; - PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { - this.referencedTypeSymbol.addExtendedType(extendedType); - }; - PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getExtendedTypes(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExtendsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExtendThisType(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); - }; - - PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); - }; - - PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findMember(name, lookInParent); - }; - PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedType(name, kind); - }; - PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedContainer(name, kind); - }; - PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - }; - - PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findTypeParameter(name); - }; - - PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); - }; - return PullTypeReferenceSymbol; - })(TypeScript.PullTypeSymbol); - TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - TypeScript.nSpecializedTypeParameterCreated = 0; - - var PullInstantiatedTypeReferenceSymbol = (function (_super) { - __extends(PullInstantiatedTypeReferenceSymbol, _super); - 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 = undefined; - this._instantiatedConstructorMethod = null; - this._instantiatedAssociatedContainerType = null; - this._isArray = undefined; - this._generativeTypeClassification = []; - - TypeScript.nSpecializationsCreated++; - } - PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { - return !this.isInstanceReferenceType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - if (!this.isNamedTypeSymbol()) { - return 0 /* Unknown */; - } - - 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()); - } - return this._isArray; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { - if (!this.isArrayNamedTypeReference()) { - return null; - } - - var typeArguments = this.getTypeArguments(); - return typeArguments ? typeArguments[0] : null; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.getIsSpecialized()) { - return this; - } - - return this.referencedTypeSymbol; - }; - - 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiation) { - return instantiation; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - 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; - } - } - - if (isInstanceReferenceType) { - typeParameterArgumentMap = []; - } - } - - instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); - - rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); - - return instantiation; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return this.getRootSymbol().isGeneric(); - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { - return this._typeParameterArgumentMap; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { - if (this.isInstanceReferenceType) { - return this.getTypeParameters(); - } - - if (this._typeArgumentReferences === undefined) { - var typeParameters = this.referencedTypeSymbol.getTypeParameters(); - - if (typeParameters.length) { - var typeArgument = null; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; - - if (!typeArgument) { - TypeScript.Debug.fail("type argument count mismatch"); - } - - if (typeArgument) { - typeArguments[typeArguments.length] = typeArgument; - } - } - - this._typeArgumentReferences = typeArguments; - } else { - this._typeArgumentReferences = null; - } - } - - return this._typeArgumentReferences; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - 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(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getMembers(); - } - - if (!this._instantiatedMembers) { - var referencedMembers = this.referencedTypeSymbol.getMembers(); - var referencedMember = null; - var instantiatedMember = null; - - this._instantiatedMembers = []; - - for (var i = 0; i < referencedMembers.length; i++) { - referencedMember = referencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (!this._instantiatedMemberNameCache[referencedMember.name]) { - this.populateInstantiatedMemberFromReferencedMember(referencedMember); - } - - this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; - } - } - - return this._instantiatedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.findMember(name, lookInParent); - } - - var memberSymbol = this._instantiatedMemberNameCache[name]; - - if (!memberSymbol) { - var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); - - if (referencedMemberSymbol) { - this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); - memberSymbol = this._instantiatedMemberNameCache[name]; - } else { - memberSymbol = null; - } - } - - return memberSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - } - - var requestedMembers = []; - var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - - if (!this._allInstantiatedMemberNameCache) { - this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - - var members = this.getMembers(); - - for (var i = 0; i < members.length; i++) { - this._allInstantiatedMemberNameCache[members[i].name] = members[i]; - } - } - - var referencedMember = null; - var requestedMember = null; - - for (var i = 0; i < allReferencedMembers.length; i++) { - referencedMember = allReferencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (this._allInstantiatedMemberNameCache[referencedMember.name]) { - requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; - } else { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; - requestedMembers[requestedMembers.length] = referencedMember; - } else { - requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - requestedMember.setRootSymbol(referencedMember); - - requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - requestedMember.isOptional = referencedMember.isOptional; - - this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; - requestedMembers[requestedMembers.length] = requestedMember; - } - } - } - - return requestedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructorMethod(); - } - - 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); - } - - return this._instantiatedConstructorMethod; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - if (!this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAssociatedContainerType(); - } - - if (!this._instantiatedAssociatedContainerType) { - var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); - - if (referencedAssociatedContainerType) { - this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); - } - } - - return this._instantiatedAssociatedContainerType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getCallSignatures(); - } - - if (this._instantiatedCallSignatures) { - return this._instantiatedCallSignatures; - } - - var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); - this._instantiatedCallSignatures = []; - - for (var i = 0; i < referencedCallSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); - - if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; - } else { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedCallSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructSignatures(); - } - - if (this._instantiatedConstructSignatures) { - return this._instantiatedConstructSignatures; - } - - var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); - this._instantiatedConstructSignatures = []; - - for (var i = 0; i < referencedConstructSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); - - if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; - } else { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedConstructSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getIndexSignatures(); - } - - if (this._instantiatedIndexSignatures) { - return this._instantiatedIndexSignatures; - } - - var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); - this._instantiatedIndexSignatures = []; - - for (var i = 0; i < referencedIndexSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); - - if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; - } else { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedIndexSignatures; - }; - 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) { - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.previousTokenTrailingComments = null; - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { - var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { - var firstToken = node.firstToken(); - var lastToken = node.lastToken(); - - this.setSpan(ast, fullStart, node, firstToken, lastToken); - ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); - ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); - }; - - SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { - if (element === null) { - return null; - } - - if (element.fullWidth() === 0) { - return new TypeScript.ASTSpan(-1, -1); - } - - var leadingTriviaWidth = element.leadingTriviaWidth(); - var trailingTriviaWidth = element.trailingTriviaWidth(); - - var start = fullStart + leadingTriviaWidth; - var end = fullStart + element.fullWidth() - trailingTriviaWidth; - - return new TypeScript.ASTSpan(start, end); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { - if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } - if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } - var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; - var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; - - var desiredMinChar = fullStart + leadingTriviaWidth; - var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span._trailingTriviaWidth = trailingTriviaWidth; - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - span._start = start; - span._end = end; - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { - var start = this.position; - var array = new Array(node.childCount()); - - for (var i = 0, n = node.childCount(); i < n; i++) { - array[i] = node.childAt(i).accept(this); - } - - var result = new TypeScript.ISyntaxList2(this.fileName, array); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var array = new Array(list.nonSeparatorCount()); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - array[i / 2] = list.childAt(i).accept(this); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); - this.setSpan(result, start, list); - - result.setPostComments(this.previousTokenTrailingComments); - this.previousTokenTrailingComments = null; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { - if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); - }; - - SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { - return this.visitToken(token); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - var fullStart = this.position; - - var result = this.visitTokenWorker(token); - - this.movePast(token); - - var start = fullStart + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { - switch (token.tokenKind) { - case 60 /* AnyKeyword */: - return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); - case 61 /* BooleanKeyword */: - return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); - case 67 /* NumberKeyword */: - return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); - case 69 /* StringKeyword */: - return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); - case 41 /* VoidKeyword */: - return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); - case 35 /* ThisKeyword */: - return new TypeScript.ThisExpression(token.text(), token.valueText()); - case 50 /* SuperKeyword */: - return new TypeScript.SuperExpression(token.text(), token.valueText()); - case 37 /* TrueKeyword */: - return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); - case 24 /* FalseKeyword */: - return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); - case 32 /* NullKeyword */: - return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); - case 14 /* StringLiteral */: - return new TypeScript.StringLiteral(token.text(), token.valueText()); - case 12 /* RegularExpressionLiteral */: - return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); - case 13 /* NumericLiteral */: - var fullStart = this.position; - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); - - result.setPreComments(preComments); - return result; - case 11 /* IdentifierName */: - return new TypeScript.Identifier(token.text()); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { - var start = this.position; - TypeScript.Debug.assert(start === 0); - - var bod = this.visitSyntaxList(node.moduleElements); - 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; - }; - - SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { - var start = this.position; - - this.moveTo(node, node.stringLiteral); - var stringLiteral = node.stringLiteral.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ExternalModuleReference(stringLiteral); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { - var start = this.position; - var moduleName = node.moduleName.accept(this); - - var result = new TypeScript.ModuleNameModuleReference(moduleName); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - this.movePast(node.openBraceToken); - var members = this.visitSyntaxList(node.classElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { - var result = null; - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { - result = result || []; - result.push(1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - result = result || []; - result.push(8 /* Ambient */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { - result = result || []; - result.push(16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { - result = result || []; - result.push(4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { - result = result || []; - result.push(2 /* Private */); - } - - return result || TypeScript.sentinelEmptyArray; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - var body = this.visitObjectType(node.body); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - var start = this.position; - - this.movePast(node.extendsOrImplementsKeyword); - var typeNames = this.visitSeparatedSyntaxList(node.typeNames); - - var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - var start = this.position; - - var modifiers = this.visitModifiers(node.modifiers); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - - var moduleName = node.name ? node.name.accept(this) : null; - var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; - - this.movePast(node.openBraceToken); - - var moduleElements = this.visitSyntaxList(node.moduleElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - this.movePast(node.openBraceToken); - - var enumElements = this.visitSeparatedSyntaxList(node.enumElements); - - this.movePast(node.closeBraceToken); - - var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - var start = this.position; - - var memberName = this.visitToken(node.propertyName); - - var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.EnumElement(memberName, value); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ImportDeclaration(modifiers, name, alias); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExportAssignment(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.VariableStatement(modifiers, declaration); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - var start = this.position; - var propertyName = this.visitToken(node.propertyName); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - var start = this.position; - var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var value = node.value.accept(this); - value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); - - var result = new TypeScript.EqualsValueClause(value); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var start = this.position; - - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var start = this.position; - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayLiteralExpression(expressions); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - var start = this.position; - - var result = new TypeScript.OmittedExpression(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var start = this.position; - - var openParenToken = node.openParenToken; - var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(openParenToken); - - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var start = this.position; - - var identifier = node.identifier.accept(this); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var start = this.position; - - var callSignature = this.visitCallSignature(node.callSignature); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - return type ? type.accept(this) : null; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { - var start = this.position; - this.movePast(node.typeOfKeyword); - var name = node.name.accept(this); - - var result = new TypeScript.TypeQuery(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - var start = this.position; - var left = this.visitType(node.left); - this.movePast(node.dotToken); - var right = this.visitIdentifier(node.right); - - var result = new TypeScript.QualifiedName(left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeArgumentList(typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - var start = this.position; - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - var start = this.position; - - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectType(typeMembers); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayType(underlying); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.name); - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - var result = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.colonToken); - var type = this.visitType(node.type); - - var result = new TypeScript.TypeAnnotation(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - - var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - var start = this.position; - - var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.visitIdentifier(node.name); - - var result = new TypeScript.MemberAccessExpression(expression, name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var start = this.position; - - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.InvocationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - this.movePast(node.openParenToken); - - 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()); - } - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - var start = this.position; - - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - var result = new TypeScript.BinaryExpression(node.kind(), left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - var start = this.position; - - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.ConstructSignature(callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.MethodSignature(name, questionToken, callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - var start = this.position; - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.IndexSignature(parameter, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - var openParenToken = node.openParenToken; - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - var openParenTrailingComments = null; - if (node.parameters.childCount() === 0) { - openParenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - } - - this.movePast(node.openParenToken); - var parameters = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - var start = this.position; - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeParameterList(typeParameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - var result = new TypeScript.TypeParameter(identifier, constraint); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - var start = this.position; - this.movePast(node.extendsKeyword); - var type = this.visitType(node.type); - - var result = new TypeScript.Constraint(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - var result = new TypeScript.IfStatement(condition, thenBod, elseBod); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - var start = this.position; - - this.movePast(node.elseKeyword); - var statement = node.statement.accept(this); - - var result = new TypeScript.ElseClause(statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var expression = node.expression.accept(this); - - var semicolonPosition = this.position; - - var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExpressionStatement(expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var start = this.position; - - 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(callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.indexSignature); - var indexSignature = node.indexSignature.accept(this); - - this.movePast(node.semicolonToken); - - var result = new TypeScript.IndexMemberDeclaration(indexSignature); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarator); - var variableDeclarator = node.variableDeclarator.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - var start = this.position; - - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ThrowStatement(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - var start = this.position; - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ReturnStatement(expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.ObjectCreationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - var start = this.position; - - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - this.movePast(node.openBraceToken); - var switchClauses = this.visitSyntaxList(node.switchClauses); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.CaseSwitchClause(expression, statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.DefaultSwitchClause(statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - var start = this.position; - - this.movePast(node.breakKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.BreakStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - var start = this.position; - - this.movePast(node.continueKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ContinueStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var initializer = node.initializer ? node.initializer.accept(this) : null; - - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var left = node.left ? node.left.accept(this) : null; - - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WhileStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WithStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - var start = this.position; - - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - var result = new TypeScript.CastExpression(castTerm, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var start = this.position; - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); - - var propertyName = node.propertyName.accept(this); - - var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var expression = node.expression.accept(this); - expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); - - var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var start = this.position; - - var propertyName = node.propertyName.accept(this); - var callSignature = this.visitCallSignature(node.callSignature); - var block = this.visitBlock(node.block); - - var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - var start = this.position; - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? node.block.accept(this) : null; - - var result = new TypeScript.FunctionExpression(name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - var start = this.position; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.EmptyStatement(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - var start = this.position; - - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - var start = this.position; - - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.visitIdentifier(node.identifier); - var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - var start = this.position; - this.movePast(node.finallyKeyword); - var block = node.block.accept(this); - - var result = new TypeScript.FinallyClause(block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.LabeledStatement(identifier, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - var start = this.position; - - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DoStatement(statement, whileKeyword, condition); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - var start = this.position; - - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.TypeOfExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - var start = this.position; - - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.DeleteExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - var start = this.position; - - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.VoidExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - var start = this.position; - - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DebuggerStatement(); - this.setSpan(result, start, node); - - return result; - }; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; - - function applyDelta(ast, delta) { - if (ast) { - if (ast._start !== -1) { - ast._start += delta; - } - - if (ast._end !== -1) { - ast._end += delta; - } - } - } - - function applyDeltaToComments(comments, delta) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment, delta); - } - } - } - - var SyntaxTreeToIncrementalAstVisitor = (function (_super) { - __extends(SyntaxTreeToIncrementalAstVisitor, _super); - function SyntaxTreeToIncrementalAstVisitor() { - _super.apply(this, arguments); - } - SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { - if (delta === 0) { - return; - } - - var pre = function (cur) { - applyDelta(cur, delta); - applyDeltaToComments(cur.preComments(), delta); - applyDeltaToComments(cur.postComments(), delta); - - switch (cur.kind()) { - case 146 /* Block */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 226 /* ArgumentList */: - applyDelta(cur.closeParenToken, delta); - break; - - case 130 /* ModuleDeclaration */: - applyDelta(cur.endingToken, delta); - break; - - case 131 /* ClassDeclaration */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 161 /* DoStatement */: - applyDelta(cur.whileKeyword, delta); - break; - - case 151 /* SwitchStatement */: - applyDelta(cur.closeParenToken, delta); - break; - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span._start !== -1) { - var delta = start - span._start; - this.applyDelta(span, delta); - - span._end = end; - } else { - _super.prototype.setSpanExplicit.call(this, span, start, end); - } - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - var result = element._ast; - if (!result) { - return null; - } - - var start = this.position; - this.movePast(element); - this.setSpan(result, start, element); - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { - element._ast = ast; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSeparatedSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { - var result = this.getAndMovePastAST(token); - - if (!result) { - result = _super.prototype.visitToken.call(this, token); - this.setAST(token, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitClassDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInterfaceDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitHeritageClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitModuleDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitImportDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExportAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPrefixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitOmittedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - var result = _super.prototype.visitQualifiedName.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGenericType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBlock.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPostfixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitElementAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInvocationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBinaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConditionalExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMethodSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIndexSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPropertySignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCallSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIfStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExpressionStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberVariableDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitThrowStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitReturnStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectCreationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSwitchStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCaseSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDefaultSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBreakStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitContinueStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForInStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWhileStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWithStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCastExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimplePropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitEmptyStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTryStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCatchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitLabeledStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDoStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeOfExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDeleteExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitVoidExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDebuggerStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - return SyntaxTreeToIncrementalAstVisitor; - })(SyntaxTreeToAstVisitor); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan(_start, _end) { - this._start = _start; - this._end = _end; - } - ASTSpan.prototype.start = function () { - return this._start; - }; - - ASTSpan.prototype.end = function () { - return this._end; - }; - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - var astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, false); - } - - function commentStructuralEqualsIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, true); - } - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); - } - - function commentStructuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - function commentArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST() { - this.parent = null; - this._start = -1; - this._end = -1; - this._trailingTriviaWidth = 0; - this._astID = astID++; - this._preComments = null; - this._postComments = null; - } - AST.prototype.syntaxID = function () { - return this._astID; - }; - - AST.prototype.start = function () { - return this._start; - }; - - AST.prototype.end = function () { - return this._end; - }; - - AST.prototype.trailingTriviaWidth = function () { - return this._trailingTriviaWidth; - }; - - AST.prototype.fileName = function () { - return this.parent.fileName(); - }; - - AST.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - AST.prototype.preComments = function () { - return this._preComments; - }; - - AST.prototype.postComments = function () { - return this._postComments; - }; - - AST.prototype.setPreComments = function (comments) { - if (comments && comments.length) { - this._preComments = comments; - } else if (this._preComments) { - this._preComments = null; - } - }; - - AST.prototype.setPostComments = function (comments) { - if (comments && comments.length) { - this._postComments = comments; - } else if (this._postComments) { - this._postComments = null; - } - }; - - AST.prototype.width = function () { - return this.end() - this.start(); - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); - }; - - AST.prototype.isExpression = function () { - return false; - }; - return AST; - })(); - TypeScript.AST = AST; - - var ISyntaxList2 = (function (_super) { - __extends(ISyntaxList2, _super); - function ISyntaxList2(_fileName, members) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISyntaxList2.prototype.childCount = function () { - return this.members.length; - }; - - ISyntaxList2.prototype.childAt = function (index) { - return this.members[index]; - }; - - ISyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISyntaxList2.prototype.kind = function () { - return 1 /* List */; - }; - - ISyntaxList2.prototype.firstOrDefault = function (func) { - return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.lastOrDefault = function (func) { - return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.any = function (func) { - return TypeScript.ArrayUtilities.any(this.members, func); - }; - - ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISyntaxList2; - })(AST); - TypeScript.ISyntaxList2 = ISyntaxList2; - - var ISeparatedSyntaxList2 = (function (_super) { - __extends(ISeparatedSyntaxList2, _super); - function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - this._separatorCount = _separatorCount; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { - return this.members.length; - }; - - ISeparatedSyntaxList2.prototype.separatorCount = function () { - return this._separatorCount; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { - return this.members[index]; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i) === ast) { - return i; - } - } - - return -1; - }; - - ISeparatedSyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISeparatedSyntaxList2.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISeparatedSyntaxList2; - })(AST); - TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; - - var SourceUnit = (function (_super) { - __extends(SourceUnit, _super); - function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { - _super.call(this); - this.moduleElements = moduleElements; - this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; - this._fileName = _fileName; - moduleElements && (moduleElements.parent = this); - } - SourceUnit.prototype.fileName = function () { - return this._fileName; - }; - - SourceUnit.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return SourceUnit; - })(AST); - TypeScript.SourceUnit = SourceUnit; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(_text) { - _super.call(this); - this._text = _text; - this._valueText = null; - } - Identifier.prototype.text = function () { - return this._text; - }; - Identifier.prototype.valueText = function () { - if (!this._valueText) { - var text = this._text; - if (text === "__proto__") { - this._valueText = "#__proto__"; - } else { - this._valueText = TypeScript.Syntax.massageEscapes(text); - } - } - - return this._valueText; - }; - - Identifier.prototype.kind = function () { - return 11 /* IdentifierName */; - }; - - 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; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - LiteralExpression.prototype.text = function () { - return this._text; - }; - - LiteralExpression.prototype.valueText = function () { - return this._valueText; - }; - - LiteralExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - ThisExpression.prototype.text = function () { - return this._text; - }; - - ThisExpression.prototype.valueText = function () { - return this._valueText; - }; - - ThisExpression.prototype.kind = function () { - return 35 /* ThisKeyword */; - }; - - 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; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - SuperExpression.prototype.text = function () { - return this._text; - }; - - SuperExpression.prototype.valueText = function () { - return this._valueText; - }; - - SuperExpression.prototype.kind = function () { - return 50 /* SuperKeyword */; - }; - - 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; - - var NumericLiteral = (function (_super) { - __extends(NumericLiteral, _super); - function NumericLiteral(_value, _text, _valueText) { - _super.call(this); - this._value = _value; - this._text = _text; - this._valueText = _valueText; - } - NumericLiteral.prototype.text = function () { - return this._text; - }; - NumericLiteral.prototype.valueText = function () { - return this._valueText; - }; - NumericLiteral.prototype.value = function () { - return this._value; - }; - - NumericLiteral.prototype.kind = function () { - return 13 /* NumericLiteral */; - }; - - 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; - - var RegularExpressionLiteral = (function (_super) { - __extends(RegularExpressionLiteral, _super); - function RegularExpressionLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - RegularExpressionLiteral.prototype.text = function () { - return this._text; - }; - - RegularExpressionLiteral.prototype.valueText = function () { - return this._valueText; - }; - - RegularExpressionLiteral.prototype.kind = function () { - return 12 /* RegularExpressionLiteral */; - }; - - RegularExpressionLiteral.prototype.isExpression = function () { - return true; - }; - return RegularExpressionLiteral; - })(AST); - TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; - } - StringLiteral.prototype.text = function () { - return this._text; - }; - StringLiteral.prototype.valueText = function () { - return this._valueText; - }; - - StringLiteral.prototype.kind = function () { - return 14 /* StringLiteral */; - }; - - 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; - - var TypeAnnotation = (function (_super) { - __extends(TypeAnnotation, _super); - function TypeAnnotation(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - TypeAnnotation.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - return TypeAnnotation; - })(AST); - TypeScript.TypeAnnotation = TypeAnnotation; - - var BuiltInType = (function (_super) { - __extends(BuiltInType, _super); - function BuiltInType(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - BuiltInType.prototype.text = function () { - return this._text; - }; - - BuiltInType.prototype.valueText = function () { - return this._valueText; - }; - - BuiltInType.prototype.kind = function () { - return this._nodeType; - }; - return BuiltInType; - })(AST); - TypeScript.BuiltInType = BuiltInType; - - var ExternalModuleReference = (function (_super) { - __extends(ExternalModuleReference, _super); - function ExternalModuleReference(stringLiteral) { - _super.call(this); - this.stringLiteral = stringLiteral; - stringLiteral && (stringLiteral.parent = this); - } - ExternalModuleReference.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - return ExternalModuleReference; - })(AST); - TypeScript.ExternalModuleReference = ExternalModuleReference; - - var ModuleNameModuleReference = (function (_super) { - __extends(ModuleNameModuleReference, _super); - function ModuleNameModuleReference(moduleName) { - _super.call(this); - this.moduleName = moduleName; - moduleName && (moduleName.parent = this); - } - ModuleNameModuleReference.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - return ModuleNameModuleReference; - })(AST); - TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(modifiers, identifier, moduleReference) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.moduleReference = moduleReference; - identifier && (identifier.parent = this); - moduleReference && (moduleReference.parent = this); - } - ImportDeclaration.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(identifier) { - _super.call(this); - this.identifier = identifier; - identifier && (identifier.parent = this); - } - ExportAssignment.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var TypeParameterList = (function (_super) { - __extends(TypeParameterList, _super); - function TypeParameterList(typeParameters) { - _super.call(this); - this.typeParameters = typeParameters; - typeParameters && (typeParameters.parent = this); - } - TypeParameterList.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - return TypeParameterList; - })(AST); - TypeScript.TypeParameterList = TypeParameterList; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - heritageClauses && (heritageClauses.parent = this); - classElements && (classElements.parent = this); - } - ClassDeclaration.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return ClassDeclaration; - })(AST); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - body && (body.parent = this); - heritageClauses && (heritageClauses.parent = this); - } - InterfaceDeclaration.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return InterfaceDeclaration; - })(AST); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var HeritageClause = (function (_super) { - __extends(HeritageClause, _super); - function HeritageClause(_nodeType, typeNames) { - _super.call(this); - this._nodeType = _nodeType; - this.typeNames = typeNames; - typeNames && (typeNames.parent = this); - } - HeritageClause.prototype.kind = function () { - return this._nodeType; - }; - - HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); - }; - return HeritageClause; - })(AST); - TypeScript.HeritageClause = HeritageClause; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { - _super.call(this); - this.modifiers = modifiers; - this.name = name; - this.stringLiteral = stringLiteral; - this.moduleElements = moduleElements; - this.endingToken = endingToken; - name && (name.parent = this); - stringLiteral && (stringLiteral.parent = this); - moduleElements && (moduleElements.parent = this); - } - ModuleDeclaration.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return ModuleDeclaration; - })(AST); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(modifiers, identifier, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionDeclaration.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(modifiers, declaration) { - _super.call(this); - this.modifiers = modifiers; - this.declaration = declaration; - declaration && (declaration.parent = this); - } - VariableStatement.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(AST); - TypeScript.VariableStatement = VariableStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this); - this.declarators = declarators; - declarators && (declarators.parent = this); - } - VariableDeclaration.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - VariableDeclarator.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - return VariableDeclarator; - })(AST); - TypeScript.VariableDeclarator = VariableDeclarator; - - var EqualsValueClause = (function (_super) { - __extends(EqualsValueClause, _super); - function EqualsValueClause(value) { - _super.call(this); - this.value = value; - value && (value.parent = this); - } - EqualsValueClause.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - return EqualsValueClause; - })(AST); - TypeScript.EqualsValueClause = EqualsValueClause; - - var PrefixUnaryExpression = (function (_super) { - __extends(PrefixUnaryExpression, _super); - function PrefixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PrefixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ArrayLiteralExpression = (function (_super) { - __extends(ArrayLiteralExpression, _super); - function ArrayLiteralExpression(expressions) { - _super.call(this); - this.expressions = expressions; - expressions && (expressions.parent = this); - } - ArrayLiteralExpression.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - 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; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.apply(this, arguments); - } - OmittedExpression.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - 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; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(openParenTrailingComments, expression) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.expression = expression; - expression && (expression.parent = this); - } - ParenthesizedExpression.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - 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; - - var SimpleArrowFunctionExpression = (function (_super) { - __extends(SimpleArrowFunctionExpression, _super); - function SimpleArrowFunctionExpression(identifier, block, expression) { - _super.call(this); - this.identifier = identifier; - this.block = block; - this.expression = expression; - identifier && (identifier.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - SimpleArrowFunctionExpression.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return SimpleArrowFunctionExpression; - })(AST); - TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; - - var ParenthesizedArrowFunctionExpression = (function (_super) { - __extends(ParenthesizedArrowFunctionExpression, _super); - function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - this.expression = expression; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - ParenthesizedArrowFunctionExpression.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return ParenthesizedArrowFunctionExpression; - })(AST); - TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; - - var QualifiedName = (function (_super) { - __extends(QualifiedName, _super); - function QualifiedName(left, right) { - _super.call(this); - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - QualifiedName.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedName.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); - }; - return QualifiedName; - })(AST); - TypeScript.QualifiedName = QualifiedName; - - var ParameterList = (function (_super) { - __extends(ParameterList, _super); - function ParameterList(openParenTrailingComments, parameters) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.parameters = parameters; - parameters && (parameters.parent = this); - } - ParameterList.prototype.kind = function () { - return 227 /* ParameterList */; - }; - return ParameterList; - })(AST); - TypeScript.ParameterList = ParameterList; - - var ConstructorType = (function (_super) { - __extends(ConstructorType, _super); - function ConstructorType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - ConstructorType.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - return ConstructorType; - })(AST); - TypeScript.ConstructorType = ConstructorType; - - var FunctionType = (function (_super) { - __extends(FunctionType, _super); - function FunctionType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - FunctionType.prototype.kind = function () { - return 123 /* FunctionType */; - }; - return FunctionType; - })(AST); - TypeScript.FunctionType = FunctionType; - - var ObjectType = (function (_super) { - __extends(ObjectType, _super); - function ObjectType(typeMembers) { - _super.call(this); - this.typeMembers = typeMembers; - typeMembers && (typeMembers.parent = this); - } - ObjectType.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); - }; - return ObjectType; - })(AST); - TypeScript.ObjectType = ObjectType; - - var ArrayType = (function (_super) { - __extends(ArrayType, _super); - function ArrayType(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - ArrayType.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); - }; - return ArrayType; - })(AST); - TypeScript.ArrayType = ArrayType; - - var TypeArgumentList = (function (_super) { - __extends(TypeArgumentList, _super); - function TypeArgumentList(typeArguments) { - _super.call(this); - this.typeArguments = typeArguments; - typeArguments && (typeArguments.parent = this); - } - TypeArgumentList.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - return TypeArgumentList; - })(AST); - TypeScript.TypeArgumentList = TypeArgumentList; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArgumentList) { - _super.call(this); - this.name = name; - this.typeArgumentList = typeArgumentList; - name && (name.parent = this); - typeArgumentList && (typeArgumentList.parent = this); - } - GenericType.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeQuery = (function (_super) { - __extends(TypeQuery, _super); - function TypeQuery(name) { - _super.call(this); - this.name = name; - name && (name.parent = this); - } - TypeQuery.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); - }; - return TypeQuery; - })(AST); - TypeScript.TypeQuery = TypeQuery; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements, closeBraceLeadingComments, closeBraceToken) { - _super.call(this); - this.statements = statements; - this.closeBraceLeadingComments = closeBraceLeadingComments; - this.closeBraceToken = closeBraceToken; - statements && (statements.parent = this); - } - Block.prototype.kind = function () { - return 146 /* Block */; - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(AST); - TypeScript.Block = Block; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - _super.call(this); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - Parameter.prototype.kind = function () { - return 242 /* Parameter */; - }; - return Parameter; - })(AST); - TypeScript.Parameter = Parameter; - - var MemberAccessExpression = (function (_super) { - __extends(MemberAccessExpression, _super); - function MemberAccessExpression(expression, name) { - _super.call(this); - this.expression = expression; - this.name = name; - expression && (expression.parent = this); - name && (name.parent = this); - } - MemberAccessExpression.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - 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; - - var PostfixUnaryExpression = (function (_super) { - __extends(PostfixUnaryExpression, _super); - function PostfixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PostfixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ElementAccessExpression = (function (_super) { - __extends(ElementAccessExpression, _super); - function ElementAccessExpression(expression, argumentExpression) { - _super.call(this); - this.expression = expression; - this.argumentExpression = argumentExpression; - expression && (expression.parent = this); - argumentExpression && (argumentExpression.parent = this); - } - ElementAccessExpression.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - 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; - - var InvocationExpression = (function (_super) { - __extends(InvocationExpression, _super); - function InvocationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - InvocationExpression.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - 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) { - _super.call(this); - this.typeArgumentList = typeArgumentList; - this.closeParenToken = closeParenToken; - this.arguments = _arguments; - - typeArgumentList && (typeArgumentList.parent = this); - _arguments && (_arguments.parent = this); - } - ArgumentList.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - return ArgumentList; - })(AST); - TypeScript.ArgumentList = ArgumentList; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(_nodeType, left, right) { - _super.call(this); - this._nodeType = _nodeType; - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - BinaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(condition, whenTrue, whenFalse) { - _super.call(this); - this.condition = condition; - this.whenTrue = whenTrue; - this.whenFalse = whenFalse; - condition && (condition.parent = this); - whenTrue && (whenTrue.parent = this); - whenFalse && (whenFalse.parent = this); - } - ConditionalExpression.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - 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; - - var ConstructSignature = (function (_super) { - __extends(ConstructSignature, _super); - function ConstructSignature(callSignature) { - _super.call(this); - this.callSignature = callSignature; - callSignature && (callSignature.parent = this); - } - ConstructSignature.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - return ConstructSignature; - })(AST); - TypeScript.ConstructSignature = ConstructSignature; - - var MethodSignature = (function (_super) { - __extends(MethodSignature, _super); - function MethodSignature(propertyName, questionToken, callSignature) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - } - MethodSignature.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - return MethodSignature; - })(AST); - TypeScript.MethodSignature = MethodSignature; - - var IndexSignature = (function (_super) { - __extends(IndexSignature, _super); - function IndexSignature(parameter, typeAnnotation) { - _super.call(this); - this.parameter = parameter; - this.typeAnnotation = typeAnnotation; - parameter && (parameter.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - IndexSignature.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - return IndexSignature; - })(AST); - TypeScript.IndexSignature = IndexSignature; - - var PropertySignature = (function (_super) { - __extends(PropertySignature, _super); - function PropertySignature(propertyName, questionToken, typeAnnotation) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - PropertySignature.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - return PropertySignature; - })(AST); - TypeScript.PropertySignature = PropertySignature; - - var CallSignature = (function (_super) { - __extends(CallSignature, _super); - function CallSignature(typeParameterList, parameterList, typeAnnotation) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - CallSignature.prototype.kind = function () { - return 142 /* CallSignature */; - }; - return CallSignature; - })(AST); - TypeScript.CallSignature = CallSignature; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(identifier, constraint) { - _super.call(this); - this.identifier = identifier; - this.constraint = constraint; - identifier && (identifier.parent = this); - constraint && (constraint.parent = this); - } - TypeParameter.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var Constraint = (function (_super) { - __extends(Constraint, _super); - function Constraint(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - Constraint.prototype.kind = function () { - return 239 /* Constraint */; - }; - return Constraint; - })(AST); - TypeScript.Constraint = Constraint; - - var ElseClause = (function (_super) { - __extends(ElseClause, _super); - function ElseClause(statement) { - _super.call(this); - this.statement = statement; - statement && (statement.parent = this); - } - ElseClause.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ElseClause; - })(AST); - TypeScript.ElseClause = ElseClause; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(condition, statement, elseClause) { - _super.call(this); - this.condition = condition; - this.statement = statement; - this.elseClause = elseClause; - condition && (condition.parent = this); - statement && (statement.parent = this); - elseClause && (elseClause.parent = this); - } - IfStatement.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); - }; - return IfStatement; - })(AST); - TypeScript.IfStatement = IfStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ExpressionStatement.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(AST); - TypeScript.ExpressionStatement = ExpressionStatement; - - var ConstructorDeclaration = (function (_super) { - __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(callSignature, block) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - ConstructorDeclaration.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - return ConstructorDeclaration; - })(AST); - TypeScript.ConstructorDeclaration = ConstructorDeclaration; - - var MemberFunctionDeclaration = (function (_super) { - __extends(MemberFunctionDeclaration, _super); - function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - MemberFunctionDeclaration.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - return MemberFunctionDeclaration; - })(AST); - TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; - - var GetAccessor = (function (_super) { - __extends(GetAccessor, _super); - function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - GetAccessor.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - return GetAccessor; - })(AST); - TypeScript.GetAccessor = GetAccessor; - - var SetAccessor = (function (_super) { - __extends(SetAccessor, _super); - function SetAccessor(modifiers, propertyName, parameterList, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - SetAccessor.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - return SetAccessor; - })(AST); - TypeScript.SetAccessor = SetAccessor; - - var MemberVariableDeclaration = (function (_super) { - __extends(MemberVariableDeclaration, _super); - function MemberVariableDeclaration(modifiers, variableDeclarator) { - _super.call(this); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - variableDeclarator && (variableDeclarator.parent = this); - } - MemberVariableDeclaration.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - return MemberVariableDeclaration; - })(AST); - TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; - - var IndexMemberDeclaration = (function (_super) { - __extends(IndexMemberDeclaration, _super); - function IndexMemberDeclaration(indexSignature) { - _super.call(this); - this.indexSignature = indexSignature; - indexSignature && (indexSignature.parent = this); - } - IndexMemberDeclaration.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - return IndexMemberDeclaration; - })(AST); - TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ThrowStatement.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(AST); - TypeScript.ThrowStatement = ThrowStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ReturnStatement.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ReturnStatement; - })(AST); - TypeScript.ReturnStatement = ReturnStatement; - - var ObjectCreationExpression = (function (_super) { - __extends(ObjectCreationExpression, _super); - function ObjectCreationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - ObjectCreationExpression.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - 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; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(expression, closeParenToken, switchClauses) { - _super.call(this); - this.expression = expression; - this.closeParenToken = closeParenToken; - this.switchClauses = switchClauses; - expression && (expression.parent = this); - switchClauses && (switchClauses.parent = this); - } - SwitchStatement.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return SwitchStatement; - })(AST); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseSwitchClause = (function (_super) { - __extends(CaseSwitchClause, _super); - function CaseSwitchClause(expression, statements) { - _super.call(this); - this.expression = expression; - this.statements = statements; - expression && (expression.parent = this); - statements && (statements.parent = this); - } - CaseSwitchClause.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return CaseSwitchClause; - })(AST); - TypeScript.CaseSwitchClause = CaseSwitchClause; - - var DefaultSwitchClause = (function (_super) { - __extends(DefaultSwitchClause, _super); - function DefaultSwitchClause(statements) { - _super.call(this); - this.statements = statements; - statements && (statements.parent = this); - } - DefaultSwitchClause.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return DefaultSwitchClause; - })(AST); - TypeScript.DefaultSwitchClause = DefaultSwitchClause; - - var BreakStatement = (function (_super) { - __extends(BreakStatement, _super); - function BreakStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - BreakStatement.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return BreakStatement; - })(AST); - TypeScript.BreakStatement = BreakStatement; - - var ContinueStatement = (function (_super) { - __extends(ContinueStatement, _super); - function ContinueStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - ContinueStatement.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ContinueStatement; - })(AST); - TypeScript.ContinueStatement = ContinueStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.condition = condition; - this.incrementor = incrementor; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - initializer && (initializer.parent = this); - condition && (condition.parent = this); - incrementor && (incrementor.parent = this); - statement && (statement.parent = this); - } - ForStatement.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForStatement; - })(AST); - TypeScript.ForStatement = ForStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(variableDeclaration, left, expression, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.left = left; - this.expression = expression; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - left && (left.parent = this); - expression && (expression.parent = this); - statement && (statement.parent = this); - } - ForInStatement.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForInStatement; - })(AST); - TypeScript.ForInStatement = ForInStatement; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WhileStatement.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WhileStatement; - })(AST); - TypeScript.WhileStatement = WhileStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WithStatement.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WithStatement; - })(AST); - TypeScript.WithStatement = WithStatement; - - var EnumDeclaration = (function (_super) { - __extends(EnumDeclaration, _super); - function EnumDeclaration(modifiers, identifier, enumElements) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.enumElements = enumElements; - identifier && (identifier.parent = this); - enumElements && (enumElements.parent = this); - } - EnumDeclaration.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - return EnumDeclaration; - })(AST); - TypeScript.EnumDeclaration = EnumDeclaration; - - var EnumElement = (function (_super) { - __extends(EnumElement, _super); - function EnumElement(propertyName, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - EnumElement.prototype.kind = function () { - return 243 /* EnumElement */; - }; - return EnumElement; - })(AST); - TypeScript.EnumElement = EnumElement; - - var CastExpression = (function (_super) { - __extends(CastExpression, _super); - function CastExpression(type, expression) { - _super.call(this); - this.type = type; - this.expression = expression; - type && (type.parent = this); - expression && (expression.parent = this); - } - CastExpression.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - 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; - - var ObjectLiteralExpression = (function (_super) { - __extends(ObjectLiteralExpression, _super); - function ObjectLiteralExpression(propertyAssignments) { - _super.call(this); - this.propertyAssignments = propertyAssignments; - propertyAssignments && (propertyAssignments.parent = this); - } - ObjectLiteralExpression.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - 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; - - var SimplePropertyAssignment = (function (_super) { - __extends(SimplePropertyAssignment, _super); - function SimplePropertyAssignment(propertyName, expression) { - _super.call(this); - this.propertyName = propertyName; - this.expression = expression; - propertyName && (propertyName.parent = this); - expression && (expression.parent = this); - } - SimplePropertyAssignment.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - return SimplePropertyAssignment; - })(AST); - TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; - - var FunctionPropertyAssignment = (function (_super) { - __extends(FunctionPropertyAssignment, _super); - function FunctionPropertyAssignment(propertyName, callSignature, block) { - _super.call(this); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionPropertyAssignment.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - return FunctionPropertyAssignment; - })(AST); - TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; - - var FunctionExpression = (function (_super) { - __extends(FunctionExpression, _super); - function FunctionExpression(identifier, callSignature, block) { - _super.call(this); - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionExpression.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpression.prototype.isExpression = function () { - return true; - }; - return FunctionExpression; - })(AST); - TypeScript.FunctionExpression = FunctionExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.apply(this, arguments); - } - EmptyStatement.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(AST); - TypeScript.EmptyStatement = EmptyStatement; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(block, catchClause, finallyClause) { - _super.call(this); - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - block && (block.parent = this); - catchClause && (catchClause.parent = this); - finallyClause && (finallyClause.parent = this); - } - TryStatement.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); - }; - return TryStatement; - })(AST); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(identifier, typeAnnotation, block) { - _super.call(this); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.block = block; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - CatchClause.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var FinallyClause = (function (_super) { - __extends(FinallyClause, _super); - function FinallyClause(block) { - _super.call(this); - this.block = block; - block && (block.parent = this); - } - FinallyClause.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return FinallyClause; - })(AST); - TypeScript.FinallyClause = FinallyClause; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this); - this.identifier = identifier; - this.statement = statement; - identifier && (identifier.parent = this); - statement && (statement.parent = this); - } - LabeledStatement.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(AST); - TypeScript.LabeledStatement = LabeledStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(statement, whileKeyword, condition) { - _super.call(this); - this.statement = statement; - this.whileKeyword = whileKeyword; - this.condition = condition; - statement && (statement.parent = this); - condition && (condition.parent = this); - } - DoStatement.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); - }; - return DoStatement; - })(AST); - TypeScript.DoStatement = DoStatement; - - var TypeOfExpression = (function (_super) { - __extends(TypeOfExpression, _super); - function TypeOfExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - TypeOfExpression.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - 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; - - var DeleteExpression = (function (_super) { - __extends(DeleteExpression, _super); - function DeleteExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - DeleteExpression.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - 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; - - var VoidExpression = (function (_super) { - __extends(VoidExpression, _super); - function VoidExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - VoidExpression.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - 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; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.apply(this, arguments); - } - DebuggerStatement.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - return DebuggerStatement; - })(AST); - TypeScript.DebuggerStatement = DebuggerStatement; - - var Comment = (function () { - function Comment(_trivia, endsLine, _start, _end) { - this._trivia = _trivia; - this.endsLine = endsLine; - this._start = _start; - this._end = _end; - } - Comment.prototype.start = function () { - return this._start; - }; - - Comment.prototype.end = function () { - return this._end; - }; - - Comment.prototype.fullText = function () { - return this._trivia.fullText(); - }; - - Comment.prototype.kind = function () { - return this._trivia.kind(); - }; - - Comment.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; - }; - return Comment; - })(); - TypeScript.Comment = Comment; -})(TypeScript || (TypeScript = {})); diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts b/_infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts deleted file mode 100644 index 94c477fd4a..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-66c2df/lib.d.ts +++ /dev/null @@ -1,14931 +0,0 @@ -/* ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -/// - -///////////////////////////// -/// ECMAScript APIs -///////////////////////////// - -declare var NaN: number; -declare var Infinity: number; - -/** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ -declare function eval(x: string): any; - -/** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ -declare function parseInt(s: string, radix?: number): number; - -/** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ -declare function parseFloat(string: string): number; - -/** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ -declare function isNaN(number: number): boolean; - -/** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ -declare function isFinite(number: number): boolean; - -/** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ -declare function decodeURI(encodedURI: string): string; - -/** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ -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; - -/** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ -declare function encodeURIComponent(uriComponent: string): string; - -interface PropertyDescriptor { - configurable?: boolean; - enumerable?: boolean; - value?: any; - writable?: boolean; - get? (): any; - set? (v: any): void; -} - -interface PropertyDescriptorMap { - [s: string]: PropertyDescriptor; -} - -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; - - /** Returns the primitive value of the specified object. */ - valueOf(): Object; - - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: string): boolean; - - /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ - isPrototypeOf(v: Object): boolean; - - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - propertyIsEnumerable(v: string): boolean; -} - -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: { - new (value?: any): Object; - (): any; - (value: any): any; - - /** A reference to the prototype for a class of objects. */ - prototype: Object; - - /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ - getPrototypeOf(o: any): any; - - /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; - - /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ - getOwnPropertyNames(o: any): string[]; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ - create(o: any, properties?: PropertyDescriptorMap): any; - - /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ - defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; - - /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ - defineProperties(o: any, properties: PropertyDescriptorMap): any; - - /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - seal(o: any): any; - - /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(o: any): any; - - /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ - preventExtensions(o: any): any; - - /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ - isSealed(o: any): boolean; - - /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ - isFrozen(o: any): boolean; - - /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ - isExtensible(o: any): boolean; - - /** - * Returns the names of the enumerable properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: any): string[]; -} - -/** - * Creates a new function. - */ -interface Function { - /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ - apply(thisArg: any, argArray?: any): any; - - /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ - call(thisArg: any, ...argArray: any[]): any; - - /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ - bind(thisArg: any, ...argArray: any[]): any; - - prototype: any; - length: number; - - // Non-standard extensions - arguments: any; - caller: Function; -} - -declare var Function: { - /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ - new (...args: string[]): Function; - (...args: string[]): Function; - prototype: Function; -} - -interface IArguments { - [index: number]: any; - length: number; - callee: Function; -} - -interface String { - /** Returns a string representation of a string. */ - toString(): string; - - /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ - charAt(pos: number): string; - - /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ - charCodeAt(index: number): number; - - /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ - concat(...strings: string[]): string; - - /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ - indexOf(searchString: string, position?: number): number; - - /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ - lastIndexOf(searchString: string, position?: number): number; - - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ - localeCompare(that: string): number; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - match(regexp: string): string[]; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. - */ - match(regexp: RegExp): string[]; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: string, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: RegExp, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: string): number; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: RegExp): number; - - /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ - slice(start?: number, end?: number): string; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: string, limit?: number): string[]; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: RegExp, limit?: number): string[]; - - /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index number indicating the beginning of the substring. - * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ - substring(start: number, end?: number): string; - - /** Converts all the alphabetic characters in a string to lowercase. */ - toLowerCase(): string; - - /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; - - /** Converts all the alphabetic characters in a string to uppercase. */ - toUpperCase(): string; - - /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; - - /** Removes the leading and trailing white space and line terminator characters from a string. */ - trim(): string; - - /** Returns the length of a String object. */ - length: number; - - // IE extensions - /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ - substr(from: number, length?: number): string; - - [index: number]: string; -} - -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: { - new (value?: any): String; - (value?: any): string; - prototype: String; - fromCharCode(...codes: number[]): string; -} - -interface Boolean { -} -declare var Boolean: { - new (value?: any): Boolean; - (value?: any): boolean; - prototype: Boolean; -} - -interface Number { - /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. - */ - toString(radix?: number): string; - - /** - * Returns a string representing a number in fixed-point notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toFixed(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented in exponential notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toExponential(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. - * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. - */ - toPrecision(precision?: number): string; -} - -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: { - new (value?: any): Number; - (value?: any): number; - prototype: Number; - - /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; - - /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; - - /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ - NaN: number; - - /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ - NEGATIVE_INFINITY: number; - - /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ - POSITIVE_INFINITY: number; -} - -interface Math { - /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; - /** The natural logarithm of 10. */ - LN10: number; - /** The natural logarithm of 2. */ - LN2: number; - /** The base-2 logarithm of e. */ - LOG2E: number; - /** The base-10 logarithm of e. */ - LOG10E: number; - /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; - /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; - /** The square root of 2. */ - SQRT2: number; - /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ - abs(x: number): number; - /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ - acos(x: number): number; - /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ - asin(x: number): number; - /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ - atan(x: number): number; - /** - * Returns the angle (in radians) from the X axis to a point (y,x). - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ - atan2(y: number, x: number): number; - /** - * Returns the smallest number greater than or equal to its numeric argument. - * @param x A numeric expression. - */ - ceil(x: number): number; - /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - cos(x: number): number; - /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ - exp(x: number): number; - /** - * Returns the greatest number less than or equal to its numeric argument. - * @param x A numeric expression. - */ - floor(x: number): number; - /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ - log(x: number): number; - /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - max(...values: number[]): number; - /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - min(...values: number[]): number; - /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ - pow(x: number, y: number): number; - /** Returns a pseudorandom number between 0 and 1. */ - random(): number; - /** - * Returns a supplied numeric expression rounded to the nearest number. - * @param x The value to be rounded to the nearest number. - */ - round(x: number): number; - /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - sin(x: number): number; - /** - * Returns the square root of a number. - * @param x A numeric expression. - */ - sqrt(x: number): number; - /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - tan(x: number): number; -} -/** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; - -/** Enables basic storage and retrieval of dates and times. */ -interface Date { - /** Returns a string representation of a date. The format of the string depends on the locale. */ - toString(): string; - /** Returns a date as a string value. */ - toDateString(): string; - /** Returns a time as a string value. */ - toTimeString(): string; - /** Returns a value as a string value appropriate to the host environment's current locale. */ - toLocaleString(): string; - /** Returns a date as a string value appropriate to the host environment's current locale. */ - toLocaleDateString(): string; - /** Returns a time as a string value appropriate to the host environment's current locale. */ - toLocaleTimeString(): string; - /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ - valueOf(): number; - /** Gets the time value in milliseconds. */ - getTime(): number; - /** Gets the year, using local time. */ - getFullYear(): number; - /** Gets the year using Universal Coordinated Time (UTC). */ - getUTCFullYear(): number; - /** Gets the month, using local time. */ - getMonth(): number; - /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ - getUTCMonth(): number; - /** Gets the day-of-the-month, using local time. */ - getDate(): number; - /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ - getUTCDate(): number; - /** Gets the day of the week, using local time. */ - getDay(): number; - /** Gets the day of the week using Universal Coordinated Time (UTC). */ - getUTCDay(): number; - /** Gets the hours in a date, using local time. */ - getHours(): number; - /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ - getUTCHours(): number; - /** Gets the minutes of a Date object, using local time. */ - getMinutes(): number; - /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ - getUTCMinutes(): number; - /** Gets the seconds of a Date object, using local time. */ - getSeconds(): number; - /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCSeconds(): number; - /** Gets the milliseconds of a Date, using local time. */ - getMilliseconds(): number; - /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCMilliseconds(): number; - /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ - getTimezoneOffset(): number; - /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ - 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): 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): 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): 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): 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): 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): number; - /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setHours(hours: number, min?: number, sec?: number, ms?: number): number; - /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - 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): 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): 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): 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): 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): 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): 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. */ - toISOString(): string; - /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ - toJSON(key?: any): string; -} - -declare var Date: { - new (): Date; - new (value: number): Date; - new (value: string): Date; - new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; - (): string; - prototype: Date; - /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ - parse(s: string): number; - /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an number between 0 and 11 (January to December). - * @param date The date as an number between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. - * @param ms An number from 0 to 999 that specifies the milliseconds. - */ - UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; - now(): number; -} - -interface RegExpExecArray { - [index: number]: string; - length: number; - - index: number; - input: string; - - toString(): string; - toLocaleString(): string; - concat(...items: string[][]): string[]; - join(separator?: string): string; - pop(): string; - push(...items: string[]): number; - reverse(): string[]; - shift(): 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[]; - unshift(...items: string[]): number; - - indexOf(searchElement: string, fromIndex?: number): number; - lastIndexOf(searchElement: string, fromIndex?: number): number; - every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; - map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; - filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; - reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; - reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; -} - - -interface RegExp { - /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ - 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. - */ - test(string: string): boolean; - - /** 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; - - /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; - - /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; - - lastIndex: number; - - // Non-standard extensions - compile(): RegExp; -} -declare var RegExp: { - new (pattern: string, flags?: string): RegExp; - (pattern: string, flags?: string): RegExp; - - // Non-standard extensions - $1: string; - $2: string; - $3: string; - $4: string; - $5: string; - $6: string; - $7: string; - $8: string; - $9: string; - lastMatch: string; -} - -interface Error { - name: string; - message: string; -} -declare var Error: { - new (message?: string): Error; - (message?: string): Error; - prototype: Error; -} - -interface EvalError extends Error { -} -declare var EvalError: { - new (message?: string): EvalError; - (message?: string): EvalError; - prototype: EvalError; -} - -interface RangeError extends Error { -} -declare var RangeError: { - new (message?: string): RangeError; - (message?: string): RangeError; - prototype: RangeError; -} - -interface ReferenceError extends Error { -} -declare var ReferenceError: { - new (message?: string): ReferenceError; - (message?: string): ReferenceError; - prototype: ReferenceError; -} - -interface SyntaxError extends Error { -} -declare var SyntaxError: { - new (message?: string): SyntaxError; - (message?: string): SyntaxError; - prototype: SyntaxError; -} - -interface TypeError extends Error { -} -declare var TypeError: { - new (message?: string): TypeError; - (message?: string): TypeError; - prototype: TypeError; -} - -interface URIError extends Error { -} -declare var URIError: { - new (message?: string): URIError; - (message?: string): URIError; - prototype: URIError; -} - -interface JSON { - /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ - parse(text: string, reviver?: (key: any, value: any) => any): any; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - */ - stringify(value: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - */ - stringify(value: any, replacer: (key: string, value: any) => any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - */ - stringify(value: any, replacer: any[]): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: any[], space: any): string; -} -/** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ -declare var JSON: JSON; - - -///////////////////////////// -/// ECMAScript Array API (specially handled by compiler) -///////////////////////////// - -interface Array { - /** - * Returns a string representation of an array. - */ - toString(): string; - toLocaleString(): string; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** - * Removes the last element from an array and returns it. - */ - pop(): T; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(...items: T[]): number; - /** - * Reverses the elements in an Array. - */ - reverse(): T[]; - /** - * Removes the first element from an array and returns it. - */ - shift(): T; - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): T[]; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - */ - splice(start: number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ - splice(start: number, deleteCount: number, ...items: T[]): T[]; - - /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ - unshift(...items: T[]): number; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ - indexOf(searchElement: T, fromIndex?: number): number; - - /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ - lastIndexOf(searchElement: T, fromIndex?: number): number; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; - - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ - length: number; - - [n: number]: T; -} -declare var Array: { - new (arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; -} - - -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ -interface ArrayBuffer { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; -} - -declare var ArrayBuffer: { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; -} - -interface ArrayBufferView { - buffer: ArrayBuffer; - byteOffset: number; - byteLength: number; -} - -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int8Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; -} -declare var Int8Array: { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint8Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; -} -declare var Uint8Array: { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 16-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; -} -declare var Int16Array: { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint16Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; -} -declare var Uint16Array: { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; -} -declare var Int32Array: { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Uint32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; -} -declare var Uint32Array: { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Float32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; -} -declare var Float32Array: { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Float64Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float64Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; -} -declare var Float64Array: { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - BYTES_PER_ELEMENT: number; -} - -/** - * You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer. - */ -interface DataView extends ArrayBufferView { - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian?: boolean): number; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; -} -declare var DataView: { - prototype: DataView; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; -} - -///////////////////////////// -/// IE11 ECMAScript Extensions -///////////////////////////// - -interface Map { - clear(): void; - delete(key: K): boolean; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): Map; - size: number; -} -declare var Map: { - new (): Map; -} - -interface WeakMap { - clear(): void; - delete(key: K): boolean; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): WeakMap; -} -declare var WeakMap: { - new (): WeakMap; -} - -interface Set { - add(value: T): Set; - clear(): void; - delete(value: T): boolean; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; - has(value: T): boolean; - size: number; -} -declare var Set: { - new (): Set; -} - -declare module Intl { - - interface CollatorOptions { - usage?: string; - localeMatcher?: string; - numeric?: boolean; - caseFirst?: string; - sensitivity?: string; - ignorePunctuation?: boolean; - } - - interface ResolvedCollatorOptions { - locale: string; - usage: string; - sensitivity: string; - ignorePunctuation: boolean; - collation: string; - caseFirst: string; - numeric: boolean; - } - - interface Collator { - compare(x: string, y: string): number; - resolvedOptions(): ResolvedCollatorOptions; - } - var Collator: { - new (locales?: string[], options?: CollatorOptions): Collator; - new (locale?: string, options?: CollatorOptions): Collator; - (locales?: string[], options?: CollatorOptions): Collator; - (locale?: string, options?: CollatorOptions): Collator; - supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; - supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; - } - - interface NumberFormatOptions { - localeMatcher?: string; - style?: string; - currency?: string; - currencyDisplay?: string; - useGrouping?: boolean; - } - - interface ResolvedNumberFormatOptions { - locale: string; - numberingSystem: string; - style: string; - currency?: string; - currencyDisplay?: string; - minimumintegerDigits: number; - minimumFractionDigits: number; - maximumFractionDigits: number; - minimumSignificantDigits?: number; - maximumSignificantDigits?: number; - useGrouping: boolean; - } - - interface NumberFormat { - format(value: number): string; - resolvedOptions(): ResolvedNumberFormatOptions; - } - var NumberFormat: { - new (locales?: string[], options?: NumberFormatOptions): Collator; - new (locale?: string, options?: NumberFormatOptions): Collator; - (locales?: string[], options?: NumberFormatOptions): Collator; - (locale?: string, options?: NumberFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; - } - - interface DateTimeFormatOptions { - localeMatcher?: string; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - formatMatcher?: string; - hour12: boolean; - } - - interface ResolvedDateTimeFormatOptions { - locale: string; - calendar: string; - numberingSystem: string; - timeZone: string; - hour12?: boolean; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - } - - interface DateTimeFormat { - format(date: number): string; - resolvedOptions(): ResolvedDateTimeFormatOptions; - } - var DateTimeFormat: { - new (locales?: string[], options?: DateTimeFormatOptions): Collator; - new (locale?: string, options?: DateTimeFormatOptions): Collator; - (locales?: string[], options?: DateTimeFormatOptions): Collator; - (locale?: string, options?: DateTimeFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; - } -} - -interface String { - localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; - localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; -} - -interface Number { - 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; -} - - -///////////////////////////// -/// IE9 DOM APIs -///////////////////////////// - -interface PositionOptions { - enableHighAccuracy?: boolean; - timeout?: number; - maximumAge?: number; -} - -interface NavigatorID { - appVersion: string; - appName: string; - userAgent: string; - platform: string; -} - -interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the amount of space between cells in a table. - */ - cellSpacing: string; - /** - * Retrieves the tFoot object of the table. - */ - tFoot: HTMLTableSectionElement; - /** - * Sets or retrieves the way the border frame around the table is displayed. - */ - frame: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Sets or retrieves which dividing lines (inner borders) are displayed. - */ - rules: string; - /** - * Sets or retrieves the number of columns in the table. - */ - cols: number; - /** - * Sets or retrieves a description and/or structure of the object. - */ - summary: string; - /** - * Retrieves the caption object of a table. - */ - caption: HTMLTableCaptionElement; - /** - * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. - */ - tBodies: HTMLCollection; - /** - * Retrieves the tHead object of the table. - */ - tHead: HTMLTableSectionElement; - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Retrieves a collection of all cells in the table row or in the entire table. - */ - cells: HTMLCollection; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the amount of space between the border of the cell and the content of the cell. - */ - cellPadding: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Creates an empty tBody element in the table. - */ - createTBody(): HTMLElement; - /** - * Deletes the caption element and its contents from the table. - */ - deleteCaption(): void; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; - /** - * Deletes the tFoot element and its contents from the table. - */ - deleteTFoot(): void; - /** - * Returns the tHead element object if successful, or null otherwise. - */ - createTHead(): HTMLElement; - /** - * Deletes the tHead element and its contents from the table. - */ - deleteTHead(): void; - /** - * Creates an empty caption element in the table. - */ - createCaption(): HTMLElement; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): Object; - /** - * Creates an empty tFoot element in the table. - */ - createTFoot(): HTMLElement; -} -declare var HTMLTableElement: { - prototype: HTMLTableElement; - new (): HTMLTableElement; -} - -interface TreeWalker { - whatToShow: number; - filter: NodeFilter; - root: Node; - currentNode: Node; - expandEntityReferences: boolean; - previousSibling(): Node; - lastChild(): Node; - nextSibling(): Node; - nextNode(): Node; - parentNode(): Node; - firstChild(): Node; - previousNode(): Node; -} -declare var TreeWalker: { - prototype: TreeWalker; - new (): TreeWalker; -} - -interface GetSVGDocument { - getSVGDocument(): Document; -} - -interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticRel: { - prototype: SVGPathSegCurvetoQuadraticRel; - new (): SVGPathSegCurvetoQuadraticRel; -} - -interface Performance { - navigation: PerformanceNavigation; - timing: PerformanceTiming; - getEntriesByType(entryType: string): any; - toJSON(): any; - getMeasures(measureName?: string): any; - clearMarks(markName?: string): void; - getMarks(markName?: string): any; - clearResourceTimings(): void; - mark(markName: string): void; - measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - getEntriesByName(name: string, entryType?: string): any; - getEntries(): any; - clearMeasures(measureName?: string): void; - setResourceTimingBufferSize(maxSize: number): void; -} -declare var Performance: { - prototype: Performance; - new (): Performance; -} - -interface MSDataBindingTableExtensions { - dataPageSize: number; - nextPage(): void; - firstPage(): void; - refresh(): void; - previousPage(): void; - lastPage(): void; -} - -interface CompositionEvent extends UIEvent { - data: string; - locale: string; - initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; -} -declare var CompositionEvent: { - prototype: CompositionEvent; - new (): CompositionEvent; -} - -interface WindowTimers { - clearTimeout(handle: number): void; - setTimeout(handler: any, timeout?: any, ...args: any[]): number; - clearInterval(handle: number): void; - setInterval(handler: any, timeout?: any, ...args: any[]): number; -} - -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { - orientType: SVGAnimatedEnumeration; - markerUnits: SVGAnimatedEnumeration; - markerWidth: SVGAnimatedLength; - markerHeight: SVGAnimatedLength; - orientAngle: SVGAnimatedAngle; - refY: SVGAnimatedLength; - refX: SVGAnimatedLength; - setOrientToAngle(angle: SVGAngle): void; - setOrientToAuto(): void; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} -declare var SVGMarkerElement: { - prototype: SVGMarkerElement; - new (): SVGMarkerElement; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} - -interface CSSStyleDeclaration { - backgroundAttachment: string; - visibility: string; - textAlignLast: string; - borderRightStyle: string; - counterIncrement: string; - orphans: string; - cssText: string; - borderStyle: string; - pointerEvents: string; - borderTopColor: string; - markerEnd: string; - textIndent: string; - listStyleImage: string; - cursor: string; - listStylePosition: string; - wordWrap: string; - borderTopStyle: string; - alignmentBaseline: string; - opacity: string; - direction: string; - strokeMiterlimit: string; - maxWidth: string; - color: string; - clip: string; - borderRightWidth: string; - verticalAlign: string; - overflow: string; - mask: string; - borderLeftStyle: string; - emptyCells: string; - stopOpacity: string; - paddingRight: string; - parentRule: CSSRule; - background: string; - boxSizing: string; - textJustify: string; - height: string; - paddingTop: string; - length: number; - right: string; - baselineShift: string; - borderLeft: string; - widows: string; - lineHeight: string; - left: string; - textUnderlinePosition: string; - glyphOrientationHorizontal: string; - display: string; - textAnchor: string; - cssFloat: string; - strokeDasharray: string; - rubyAlign: string; - fontSizeAdjust: string; - borderLeftColor: string; - backgroundImage: string; - listStyleType: string; - strokeWidth: string; - textOverflow: string; - fillRule: string; - borderBottomColor: string; - zIndex: string; - position: string; - listStyle: string; - msTransformOrigin: string; - dominantBaseline: string; - overflowY: string; - fill: string; - captionSide: string; - borderCollapse: string; - boxShadow: string; - quotes: string; - tableLayout: string; - unicodeBidi: string; - borderBottomWidth: string; - backgroundSize: string; - textDecoration: string; - strokeDashoffset: string; - fontSize: string; - border: string; - pageBreakBefore: string; - borderTopRightRadius: string; - msTransform: string; - borderBottomLeftRadius: string; - textTransform: string; - rubyPosition: string; - strokeLinejoin: string; - clipPath: string; - borderRightColor: string; - fontFamily: string; - clear: string; - content: string; - backgroundClip: string; - marginBottom: string; - counterReset: string; - outlineWidth: string; - marginRight: string; - paddingLeft: string; - borderBottom: string; - wordBreak: string; - marginTop: string; - top: string; - fontWeight: string; - borderRight: string; - width: string; - kerning: string; - pageBreakAfter: string; - borderBottomStyle: string; - fontStretch: string; - padding: string; - strokeOpacity: string; - markerStart: string; - bottom: string; - borderLeftWidth: string; - clipRule: string; - backgroundPosition: string; - backgroundColor: string; - pageBreakInside: string; - backgroundOrigin: string; - strokeLinecap: string; - borderTopWidth: string; - outlineStyle: string; - borderTop: string; - outlineColor: string; - paddingBottom: string; - marginLeft: string; - font: string; - outline: string; - wordSpacing: string; - maxHeight: string; - fillOpacity: string; - letterSpacing: string; - borderSpacing: string; - backgroundRepeat: string; - borderRadius: string; - borderWidth: string; - borderBottomRightRadius: string; - whiteSpace: string; - fontStyle: string; - minWidth: string; - stopColor: string; - borderTopLeftRadius: string; - borderColor: string; - marker: string; - glyphOrientationVertical: string; - markerMid: string; - fontVariant: string; - minHeight: string; - stroke: string; - rubyOverhang: string; - overflowX: string; - textAlign: string; - margin: string; - getPropertyPriority(propertyName: string): string; - getPropertyValue(propertyName: string): string; - removeProperty(propertyName: string): string; - item(index: number): string; - [index: number]: string; - setProperty(propertyName: string, value: string, priority?: string): void; -} -declare var CSSStyleDeclaration: { - prototype: CSSStyleDeclaration; - new (): CSSStyleDeclaration; -} - -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGGElement: { - prototype: SVGGElement; - new (): SVGGElement; -} - -interface MSStyleCSSProperties extends MSCSSProperties { - pixelWidth: number; - posHeight: number; - posLeft: number; - pixelTop: number; - pixelBottom: number; - textDecorationNone: boolean; - pixelLeft: number; - posTop: number; - posBottom: number; - textDecorationOverline: boolean; - posWidth: number; - textDecorationLineThrough: boolean; - pixelHeight: number; - textDecorationBlink: boolean; - posRight: number; - pixelRight: number; - textDecorationUnderline: boolean; -} -declare var MSStyleCSSProperties: { - prototype: MSStyleCSSProperties; - new (): MSStyleCSSProperties; -} - -interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils { -} -declare var Navigator: { - prototype: Navigator; - new (): Navigator; -} - -interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothAbs: { - prototype: SVGPathSegCurvetoCubicSmoothAbs; - new (): SVGPathSegCurvetoCubicSmoothAbs; -} - -interface SVGZoomEvent extends UIEvent { - zoomRectScreen: SVGRect; - previousScale: number; - newScale: number; - previousTranslate: SVGPoint; - newTranslate: SVGPoint; -} -declare var SVGZoomEvent: { - prototype: SVGZoomEvent; - new (): SVGZoomEvent; -} - -interface NodeSelector { - querySelectorAll(selectors: string): NodeList; - querySelector(selectors: string): Element; -} - -interface HTMLTableDataCellElement extends HTMLTableCellElement { -} -declare var HTMLTableDataCellElement: { - prototype: HTMLTableDataCellElement; - new (): HTMLTableDataCellElement; -} - -interface HTMLBaseElement extends HTMLElement { - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Gets or sets the baseline URL on which relative links are based. - */ - href: string; -} -declare var HTMLBaseElement: { - prototype: HTMLBaseElement; - new (): HTMLBaseElement; -} - -interface ClientRect { - left: number; - width: number; - right: number; - top: number; - bottom: number; - height: number; -} -declare var ClientRect: { - prototype: ClientRect; - new (): ClientRect; -} - -interface PositionErrorCallback { - (error: PositionError): void; -} - -interface DOMImplementation { - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; - createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; - hasFeature(feature: string, version?: string): boolean; - createHTMLDocument(title: string): Document; -} -declare var DOMImplementation: { - prototype: DOMImplementation; - new (): DOMImplementation; -} - -interface SVGUnitTypes { - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} -declare var SVGUnitTypes: { - prototype: SVGUnitTypes; - new (): SVGUnitTypes; - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} - -interface Element extends Node, NodeSelector, ElementTraversal { - scrollTop: number; - clientLeft: number; - scrollLeft: number; - tagName: string; - clientWidth: number; - scrollWidth: number; - clientHeight: number; - clientTop: number; - scrollHeight: number; - getAttribute(name?: string): string; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - hasAttributeNS(namespaceURI: string, localName: string): boolean; - getBoundingClientRect(): ClientRect; - getAttributeNS(namespaceURI: string, localName: string): string; - getAttributeNodeNS(namespaceURI: string, localName: string): Attr; - setAttributeNodeNS(newAttr: Attr): Attr; - msMatchesSelector(selectors: string): boolean; - hasAttribute(name: string): boolean; - removeAttribute(name?: string): void; - setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; - getAttributeNode(name: string): Attr; - fireEvent(eventName: string, eventObj?: any): boolean; - getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; - getElementsByTagName(name: "area"): NodeListOf; - getElementsByTagName(name: "article"): NodeListOf; - getElementsByTagName(name: "aside"): NodeListOf; - getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; - getElementsByTagName(name: "base"): NodeListOf; - getElementsByTagName(name: "bdi"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; - getElementsByTagName(name: "body"): NodeListOf; - getElementsByTagName(name: "br"): NodeListOf; - getElementsByTagName(name: "button"): NodeListOf; - getElementsByTagName(name: "canvas"): NodeListOf; - getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; - getElementsByTagName(name: "col"): NodeListOf; - getElementsByTagName(name: "colgroup"): NodeListOf; - getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; - getElementsByTagName(name: "del"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; - getElementsByTagName(name: "div"): NodeListOf; - getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; - getElementsByTagName(name: "embed"): NodeListOf; - getElementsByTagName(name: "fieldset"): NodeListOf; - getElementsByTagName(name: "figcaption"): NodeListOf; - getElementsByTagName(name: "figure"): NodeListOf; - getElementsByTagName(name: "footer"): NodeListOf; - getElementsByTagName(name: "form"): NodeListOf; - getElementsByTagName(name: "h1"): NodeListOf; - getElementsByTagName(name: "h2"): NodeListOf; - getElementsByTagName(name: "h3"): NodeListOf; - getElementsByTagName(name: "h4"): NodeListOf; - getElementsByTagName(name: "h5"): NodeListOf; - getElementsByTagName(name: "h6"): NodeListOf; - getElementsByTagName(name: "head"): NodeListOf; - getElementsByTagName(name: "header"): NodeListOf; - getElementsByTagName(name: "hgroup"): NodeListOf; - getElementsByTagName(name: "hr"): NodeListOf; - getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; - getElementsByTagName(name: "iframe"): NodeListOf; - getElementsByTagName(name: "img"): NodeListOf; - getElementsByTagName(name: "input"): NodeListOf; - getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "label"): NodeListOf; - getElementsByTagName(name: "legend"): NodeListOf; - getElementsByTagName(name: "li"): NodeListOf; - getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "main"): NodeListOf; - getElementsByTagName(name: "map"): NodeListOf; - getElementsByTagName(name: "mark"): NodeListOf; - getElementsByTagName(name: "menu"): NodeListOf; - getElementsByTagName(name: "meta"): NodeListOf; - getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "noscript"): NodeListOf; - getElementsByTagName(name: "object"): NodeListOf; - getElementsByTagName(name: "ol"): NodeListOf; - getElementsByTagName(name: "optgroup"): NodeListOf; - getElementsByTagName(name: "option"): NodeListOf; - getElementsByTagName(name: "p"): NodeListOf; - getElementsByTagName(name: "param"): NodeListOf; - getElementsByTagName(name: "pre"): NodeListOf; - getElementsByTagName(name: "progress"): NodeListOf; - getElementsByTagName(name: "q"): NodeListOf; - getElementsByTagName(name: "rp"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; - getElementsByTagName(name: "script"): NodeListOf; - getElementsByTagName(name: "section"): NodeListOf; - getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; - getElementsByTagName(name: "source"): NodeListOf; - getElementsByTagName(name: "span"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; - getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "summary"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; - getElementsByTagName(name: "table"): NodeListOf; - getElementsByTagName(name: "tbody"): NodeListOf; - getElementsByTagName(name: "td"): NodeListOf; - getElementsByTagName(name: "textarea"): NodeListOf; - getElementsByTagName(name: "tfoot"): NodeListOf; - getElementsByTagName(name: "th"): NodeListOf; - getElementsByTagName(name: "thead"): NodeListOf; - getElementsByTagName(name: "title"): NodeListOf; - getElementsByTagName(name: "tr"): NodeListOf; - getElementsByTagName(name: "track"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; - getElementsByTagName(name: "ul"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; - getElementsByTagName(name: "video"): NodeListOf; - getElementsByTagName(name: "wbr"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getClientRects(): ClientRectList; - setAttributeNode(newAttr: Attr): Attr; - removeAttributeNode(oldAttr: Attr): Attr; - setAttribute(name?: string, value?: string): void; - removeAttributeNS(namespaceURI: string, localName: string): void; -} -declare var Element: { - prototype: Element; - new (): Element; -} - -interface HTMLNextIdElement extends HTMLElement { - n: string; -} -declare var HTMLNextIdElement: { - prototype: HTMLNextIdElement; - new (): HTMLNextIdElement; -} - -interface SVGPathSegMovetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoRel: { - prototype: SVGPathSegMovetoRel; - new (): SVGPathSegMovetoRel; -} - -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLineElement: { - prototype: SVGLineElement; - new (): SVGLineElement; -} - -interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; -} -declare var HTMLParagraphElement: { - prototype: HTMLParagraphElement; - new (): HTMLParagraphElement; -} - -interface HTMLAreasCollection extends HTMLCollection { - /** - * Removes an element from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: any): void; -} -declare var HTMLAreasCollection: { - prototype: HTMLAreasCollection; - new (): HTMLAreasCollection; -} - -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGDescElement: { - prototype: SVGDescElement; - new (): SVGDescElement; -} - -interface Node extends EventTarget { - nodeType: number; - previousSibling: Node; - localName: string; - namespaceURI: string; - textContent: string; - parentNode: Node; - nextSibling: Node; - nodeValue: string; - lastChild: Node; - childNodes: NodeList; - nodeName: string; - ownerDocument: Document; - attributes: NamedNodeMap; - firstChild: Node; - prefix: string; - removeChild(oldChild: Node): Node; - appendChild(newChild: Node): Node; - isSupported(feature: string, version: string): boolean; - isEqualNode(arg: Node): boolean; - lookupPrefix(namespaceURI: string): string; - isDefaultNamespace(namespaceURI: string): boolean; - compareDocumentPosition(other: Node): number; - normalize(): void; - isSameNode(other: Node): boolean; - hasAttributes(): boolean; - lookupNamespaceURI(prefix: string): string; - cloneNode(deep?: boolean): Node; - hasChildNodes(): boolean; - replaceChild(newChild: Node, oldChild: Node): Node; - insertBefore(newChild: Node, refChild?: Node): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} -declare var Node: { - prototype: Node; - new (): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} - -interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothRel: { - prototype: SVGPathSegCurvetoQuadraticSmoothRel; - new (): SVGPathSegCurvetoQuadraticSmoothRel; -} - -interface DOML2DeprecatedListSpaceReduction { - compact: boolean; -} - -interface MSScriptHost { -} -declare var MSScriptHost: { - prototype: MSScriptHost; - new (): MSScriptHost; -} - -interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - clipPathUnits: SVGAnimatedEnumeration; -} -declare var SVGClipPathElement: { - prototype: SVGClipPathElement; - new (): SVGClipPathElement; -} - -interface MouseEvent extends UIEvent { - toElement: Element; - layerY: number; - fromElement: Element; - which: number; - pageX: number; - offsetY: number; - x: number; - y: number; - metaKey: boolean; - altKey: boolean; - ctrlKey: boolean; - offsetX: number; - screenX: number; - clientY: number; - shiftKey: boolean; - layerX: number; - screenY: number; - relatedTarget: EventTarget; - button: number; - pageY: number; - buttons: number; - clientX: number; - initMouseEvent(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): void; - getModifierState(keyArg: string): boolean; -} -declare var MouseEvent: { - prototype: MouseEvent; - new (): MouseEvent; -} - -interface RangeException { - code: number; - message: string; - toString(): string; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} -declare var RangeException: { - prototype: RangeException; - new (): RangeException; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} - -interface SVGTextPositioningElement extends SVGTextContentElement { - y: SVGAnimatedLengthList; - rotate: SVGAnimatedNumberList; - dy: SVGAnimatedLengthList; - x: SVGAnimatedLengthList; - dx: SVGAnimatedLengthList; -} -declare var SVGTextPositioningElement: { - prototype: SVGTextPositioningElement; - new (): SVGTextPositioningElement; -} - -interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - width: number; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - object: string; - form: HTMLFormElement; - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. - */ - contentDocument: Document; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - /** - * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. - */ - declare: boolean; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; -} -declare var HTMLAppletElement: { - prototype: HTMLAppletElement; - new (): HTMLAppletElement; -} - -interface TextMetrics { - width: number; -} -declare var TextMetrics: { - prototype: TextMetrics; - new (): TextMetrics; -} - -interface DocumentEvent { - createEvent(eventInterface: string): Event; -} - -interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * The starting number. - */ - start: number; -} -declare var HTMLOListElement: { - prototype: HTMLOListElement; - new (): HTMLOListElement; -} - -interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalRel: { - prototype: SVGPathSegLinetoVerticalRel; - new (): SVGPathSegLinetoVerticalRel; -} - -interface SVGAnimatedString { - animVal: string; - baseVal: string; -} -declare var SVGAnimatedString: { - prototype: SVGAnimatedString; - new (): SVGAnimatedString; -} - -interface CDATASection extends Text { -} -declare var CDATASection: { - prototype: CDATASection; - new (): CDATASection; -} - -interface StyleMedia { - type: string; - matchMedium(mediaquery: string): boolean; -} -declare var StyleMedia: { - prototype: StyleMedia; - new (): StyleMedia; -} - -interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { - options: HTMLSelectElement; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the number of rows in the list box. - */ - size: number; - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the index of the selected option in a select object. - */ - selectedIndex: number; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Retrieves the type of select control based on the value of the MULTIPLE attribute. - */ - type: string; - /** - * Removes an element from the collection. - * @param index Number that specifies the zero-based index of the element to remove from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. - * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. - */ - add(element: HTMLElement, before?: any): void; - /** - * Retrieves a select object or an object from an options collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Retrieves a select object or an object from an options collection. - * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. - */ - namedItem(name: string): any; - [name: string]: any; -} -declare var HTMLSelectElement: { - prototype: HTMLSelectElement; - new (): HTMLSelectElement; -} - -interface TextRange { - boundingLeft: number; - htmlText: string; - offsetLeft: number; - boundingWidth: number; - boundingHeight: number; - boundingTop: number; - text: string; - offsetTop: number; - moveToPoint(x: number, y: number): void; - queryCommandValue(cmdID: string): any; - getBookmark(): string; - move(unit: string, count?: number): number; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(fStart?: boolean): void; - findText(string: string, count?: number, flags?: number): boolean; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - getBoundingClientRect(): ClientRect; - moveToBookmark(bookmark: string): boolean; - isEqual(range: TextRange): boolean; - duplicate(): TextRange; - collapse(start?: boolean): void; - queryCommandText(cmdID: string): string; - select(): void; - pasteHTML(html: string): void; - inRange(range: TextRange): boolean; - moveEnd(unit: string, count?: number): number; - getClientRects(): ClientRectList; - moveStart(unit: string, count?: number): number; - parentElement(): Element; - queryCommandState(cmdID: string): boolean; - compareEndPoints(how: string, sourceRange: TextRange): number; - execCommandShowHelp(cmdID: string): boolean; - moveToElementText(element: Element): void; - expand(Unit: string): boolean; - queryCommandSupported(cmdID: string): boolean; - setEndPoint(how: string, SourceRange: TextRange): void; - queryCommandEnabled(cmdID: string): boolean; -} -declare var TextRange: { - prototype: TextRange; - new (): TextRange; -} - -interface SVGTests { - requiredFeatures: SVGStringList; - requiredExtensions: SVGStringList; - systemLanguage: SVGStringList; - hasExtension(extension: string): boolean; -} - -interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLBlockElement: { - prototype: HTMLBlockElement; - new (): HTMLBlockElement; -} - -interface CSSStyleSheet extends StyleSheet { - owningElement: Element; - imports: StyleSheetList; - isAlternate: boolean; - rules: MSCSSRuleList; - isPrefAlternate: boolean; - readOnly: boolean; - cssText: string; - ownerRule: CSSRule; - href: string; - cssRules: CSSRuleList; - id: string; - pages: StyleSheetPageList; - addImport(bstrURL: string, lIndex?: number): number; - addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; - insertRule(rule: string, index?: number): number; - removeRule(lIndex: number): void; - deleteRule(index?: number): void; - addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; - removeImport(lIndex: number): void; -} -declare var CSSStyleSheet: { - prototype: CSSStyleSheet; - new (): CSSStyleSheet; -} - -interface MSSelection { - type: string; - typeDetail: string; - createRange(): TextRange; - clear(): void; - createRangeCollection(): TextRangeCollection; - empty(): void; -} -declare var MSSelection: { - prototype: MSSelection; - new (): MSSelection; -} - -interface HTMLMetaElement extends HTMLElement { - /** - * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. - */ - httpEquiv: string; - /** - * Sets or retrieves the value specified in the content attribute of the meta object. - */ - name: string; - /** - * Gets or sets meta-information to associate with httpEquiv or name. - */ - content: string; - /** - * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. - */ - url: string; - /** - * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. - */ - scheme: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; -} -declare var HTMLMetaElement: { - prototype: HTMLMetaElement; - new (): HTMLMetaElement; -} - -interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { - patternUnits: SVGAnimatedEnumeration; - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - patternContentUnits: SVGAnimatedEnumeration; - patternTransform: SVGAnimatedTransformList; - height: SVGAnimatedLength; -} -declare var SVGPatternElement: { - prototype: SVGPatternElement; - new (): SVGPatternElement; -} - -interface SVGAnimatedAngle { - animVal: SVGAngle; - baseVal: SVGAngle; -} -declare var SVGAnimatedAngle: { - prototype: SVGAnimatedAngle; - new (): SVGAnimatedAngle; -} - -interface Selection { - isCollapsed: boolean; - anchorNode: Node; - focusNode: Node; - anchorOffset: number; - focusOffset: number; - rangeCount: number; - addRange(range: Range): void; - collapseToEnd(): void; - toString(): string; - selectAllChildren(parentNode: Node): void; - getRangeAt(index: number): Range; - collapse(parentNode: Node, offset: number): void; - removeAllRanges(): void; - collapseToStart(): void; - deleteFromDocument(): void; - removeRange(range: Range): void; -} -declare var Selection: { - prototype: Selection; - new (): Selection; -} - -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { - type: string; -} -declare var SVGScriptElement: { - prototype: SVGScriptElement; - new (): SVGScriptElement; -} - -interface HTMLDDElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDDElement: { - prototype: HTMLDDElement; - new (): HTMLDDElement; -} - -interface MSDataBindingRecordSetReadonlyExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface CSSStyleRule extends CSSRule { - selectorText: string; - style: MSStyleCSSProperties; - readOnly: boolean; -} -declare var CSSStyleRule: { - prototype: CSSStyleRule; - new (): CSSStyleRule; -} - -interface NodeIterator { - whatToShow: number; - filter: NodeFilter; - root: Node; - expandEntityReferences: boolean; - nextNode(): Node; - detach(): void; - previousNode(): Node; -} -declare var NodeIterator: { - prototype: NodeIterator; - new (): NodeIterator; -} - -interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { - viewTarget: SVGStringList; -} -declare var SVGViewElement: { - prototype: SVGViewElement; - new (): SVGViewElement; -} - -interface HTMLLinkElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; -} -declare var HTMLLinkElement: { - prototype: HTMLLinkElement; - new (): HTMLLinkElement; -} - -interface SVGLocatable { - farthestViewportElement: SVGElement; - nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getTransformToElement(element: SVGElement): SVGMatrix; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; -} - -interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; -} -declare var HTMLFontElement: { - prototype: HTMLFontElement; - new (): HTMLFontElement; -} - -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGTitleElement: { - prototype: SVGTitleElement; - new (): SVGTitleElement; -} - -interface ControlRangeCollection { - length: number; - queryCommandValue(cmdID: string): any; - remove(index: number): void; - add(item: Element): void; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(varargStart?: any): void; - item(index: number): Element; - [index: number]: Element; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - addElement(item: Element): void; - queryCommandState(cmdID: string): boolean; - queryCommandSupported(cmdID: string): boolean; - queryCommandEnabled(cmdID: string): boolean; - queryCommandText(cmdID: string): string; - select(): void; -} -declare var ControlRangeCollection: { - prototype: ControlRangeCollection; - new (): ControlRangeCollection; -} - -interface MSNamespaceInfo extends MSEventAttachmentTarget { - urn: string; - onreadystatechange: (ev: Event) => any; - name: string; - readyState: string; - doImport(implementationUrl: string): void; -} -declare var MSNamespaceInfo: { - prototype: MSNamespaceInfo; - new (): MSNamespaceInfo; -} - -interface WindowSessionStorage { - sessionStorage: Storage; -} - -interface SVGAnimatedTransformList { - animVal: SVGTransformList; - baseVal: SVGTransformList; -} -declare var SVGAnimatedTransformList: { - prototype: SVGAnimatedTransformList; - new (): SVGAnimatedTransformList; -} - -interface HTMLTableCaptionElement extends HTMLElement { - /** - * Sets or retrieves the alignment of the caption or legend. - */ - align: string; - /** - * Sets or retrieves whether the caption appears at the top or bottom of the table. - */ - vAlign: string; -} -declare var HTMLTableCaptionElement: { - prototype: HTMLTableCaptionElement; - new (): HTMLTableCaptionElement; -} - -interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; - create(): HTMLOptionElement; -} -declare var HTMLOptionElement: { - prototype: HTMLOptionElement; - new (): HTMLOptionElement; -} - -interface HTMLMapElement extends HTMLElement { - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Retrieves a collection of the area objects defined for the given map object. - */ - areas: HTMLAreasCollection; -} -declare var HTMLMapElement: { - prototype: HTMLMapElement; - new (): HTMLMapElement; -} - -interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { - type: string; -} -declare var HTMLMenuElement: { - prototype: HTMLMenuElement; - new (): HTMLMenuElement; -} - -interface MouseWheelEvent extends MouseEvent { - wheelDelta: number; - initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; -} -declare var MouseWheelEvent: { - prototype: MouseWheelEvent; - new (): MouseWheelEvent; -} - -interface SVGFitToViewBox { - viewBox: SVGAnimatedRect; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} - -interface SVGPointList { - numberOfItems: number; - replaceItem(newItem: SVGPoint, index: number): SVGPoint; - getItem(index: number): SVGPoint; - clear(): void; - appendItem(newItem: SVGPoint): SVGPoint; - initialize(newItem: SVGPoint): SVGPoint; - removeItem(index: number): SVGPoint; - insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; -} -declare var SVGPointList: { - prototype: SVGPointList; - new (): SVGPointList; -} - -interface SVGAnimatedLengthList { - animVal: SVGLengthList; - baseVal: SVGLengthList; -} -declare var SVGAnimatedLengthList: { - prototype: SVGAnimatedLengthList; - new (): SVGAnimatedLengthList; -} - -interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers { - ondragend: (ev: DragEvent) => any; - onkeydown: (ev: KeyboardEvent) => any; - ondragover: (ev: DragEvent) => any; - onkeyup: (ev: KeyboardEvent) => any; - onreset: (ev: Event) => any; - onmouseup: (ev: MouseEvent) => any; - ondragstart: (ev: DragEvent) => any; - ondrag: (ev: DragEvent) => any; - screenX: number; - onmouseover: (ev: MouseEvent) => any; - ondragleave: (ev: DragEvent) => any; - history: History; - pageXOffset: number; - name: string; - onafterprint: (ev: Event) => any; - onpause: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - top: Window; - onmousedown: (ev: MouseEvent) => any; - onseeked: (ev: Event) => any; - opener: Window; - onclick: (ev: MouseEvent) => any; - innerHeight: number; - onwaiting: (ev: Event) => any; - ononline: (ev: Event) => any; - ondurationchange: (ev: Event) => any; - frames: Window; - onblur: (ev: FocusEvent) => any; - onemptied: (ev: Event) => any; - onseeking: (ev: Event) => any; - oncanplay: (ev: Event) => any; - outerWidth: number; - onstalled: (ev: Event) => any; - onmousemove: (ev: MouseEvent) => any; - innerWidth: number; - onoffline: (ev: Event) => any; - length: number; - screen: Screen; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onratechange: (ev: Event) => any; - onstorage: (ev: StorageEvent) => any; - onloadstart: (ev: Event) => any; - ondragenter: (ev: DragEvent) => any; - onsubmit: (ev: Event) => any; - self: Window; - document: Document; - onprogress: (ev: any) => any; - ondblclick: (ev: MouseEvent) => any; - pageYOffset: number; - oncontextmenu: (ev: MouseEvent) => any; - onchange: (ev: Event) => any; - onloadedmetadata: (ev: Event) => any; - onplay: (ev: Event) => any; - onerror: ErrorEventHandler; - onplaying: (ev: Event) => any; - parent: Window; - location: Location; - oncanplaythrough: (ev: Event) => any; - onabort: (ev: UIEvent) => any; - onreadystatechange: (ev: Event) => any; - outerHeight: number; - onkeypress: (ev: KeyboardEvent) => any; - frameElement: Element; - onloadeddata: (ev: Event) => any; - onsuspend: (ev: Event) => any; - window: Window; - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - ontimeupdate: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - onselect: (ev: UIEvent) => any; - navigator: Navigator; - styleMedia: StyleMedia; - ondrop: (ev: DragEvent) => any; - onmouseout: (ev: MouseEvent) => any; - onended: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onunload: (ev: Event) => any; - onscroll: (ev: UIEvent) => any; - screenY: number; - onmousewheel: (ev: MouseWheelEvent) => any; - onload: (ev: Event) => any; - onvolumechange: (ev: Event) => any; - oninput: (ev: Event) => any; - performance: Performance; - alert(message?: any): void; - scroll(x?: number, y?: number): void; - focus(): void; - scrollTo(x?: number, y?: number): void; - print(): void; - prompt(message?: string, defaul?: string): string; - toString(): string; - open(url?: string, target?: string, features?: string, replace?: boolean): Window; - scrollBy(x?: number, y?: number): void; - confirm(message?: string): boolean; - close(): void; - postMessage(message: any, targetOrigin: string, ports?: any): void; - showModalDialog(url?: string, argument?: any, options?: any): any; - blur(): void; - getSelection(): Selection; - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -} -declare var Window: { - prototype: Window; - new (): Window; -} - -interface SVGAnimatedPreserveAspectRatio { - animVal: SVGPreserveAspectRatio; - baseVal: SVGPreserveAspectRatio; -} -declare var SVGAnimatedPreserveAspectRatio: { - prototype: SVGAnimatedPreserveAspectRatio; - new (): SVGAnimatedPreserveAspectRatio; -} - -interface MSSiteModeEvent extends Event { - buttonID: number; - actionURL: string; -} -declare var MSSiteModeEvent: { - prototype: MSSiteModeEvent; - new (): MSSiteModeEvent; -} - -interface DOML2DeprecatedTextFlowControl { - clear: string; -} - -interface StyleSheetPageList { - length: number; - item(index: number): CSSPageRule; - [index: number]: CSSPageRule; -} -declare var StyleSheetPageList: { - prototype: StyleSheetPageList; - new (): StyleSheetPageList; -} - -interface MSCSSProperties extends CSSStyleDeclaration { - scrollbarShadowColor: string; - scrollbarHighlightColor: string; - layoutGridChar: string; - layoutGridType: string; - textAutospace: string; - textKashidaSpace: string; - writingMode: string; - scrollbarFaceColor: string; - backgroundPositionY: string; - lineBreak: string; - imeMode: string; - msBlockProgression: string; - layoutGridLine: string; - scrollbarBaseColor: string; - layoutGrid: string; - layoutFlow: string; - textKashida: string; - filter: string; - zoom: string; - scrollbarArrowColor: string; - behavior: string; - backgroundPositionX: string; - accelerator: string; - layoutGridMode: string; - textJustifyTrim: string; - scrollbar3dLightColor: string; - msInterpolationMode: string; - scrollbarTrackColor: string; - scrollbarDarkShadowColor: string; - styleFloat: string; - getAttribute(attributeName: string, flags?: number): any; - setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; - removeAttribute(attributeName: string, flags?: number): boolean; -} -declare var MSCSSProperties: { - prototype: MSCSSProperties; - new (): MSCSSProperties; -} - -interface HTMLCollection extends MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Retrieves an object from various collections. - */ - item(nameOrIndex?: any, optionalIndex?: any): Element; - /** - * Retrieves a select object or an object from an options collection. - */ - namedItem(name: string): Element; - [name: number]: Element; -} -declare var HTMLCollection: { - prototype: HTMLCollection; - new (): HTMLCollection; -} - -interface SVGExternalResourcesRequired { - externalResourcesRequired: SVGAnimatedBoolean; -} - -interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * The original height of the image resource before sizing. - */ - naturalHeight: number; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * The original width of the image resource before sizing. - */ - naturalWidth: number; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: number; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. - */ - longDesc: string; - /** - * Contains the hypertext reference (HREF) of the URL. - */ - href: string; - /** - * Sets or retrieves whether the image is a server-side image map. - */ - isMap: boolean; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - create(): HTMLImageElement; -} -declare var HTMLImageElement: { - prototype: HTMLImageElement; - new (): HTMLImageElement; -} - -interface HTMLAreaElement extends HTMLElement { - /** - * Sets or retrieves the protocol portion of a URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Sets or retrieves the host name part of the location or URL. - */ - hostname: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Sets or retrieves the file name or path specified by the object. - */ - pathname: string; - /** - * Sets or retrieves the hostname and port number of the location or URL. - */ - host: string; - /** - * Sets or retrieves the subsection of the href property that follows the number sign (#). - */ - hash: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or gets whether clicks in this region cause action. - */ - noHref: boolean; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAreaElement: { - prototype: HTMLAreaElement; - new (): HTMLAreaElement; -} - -interface EventTarget { - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - dispatchEvent(evt: Event): boolean; -} - -interface SVGAngle { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} -declare var SVGAngle: { - prototype: SVGAngle; - new (): SVGAngle; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} - -interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the default or selected value of the control. - */ - value: string; - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets the classification and default behavior of the button. - */ - type: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; -} -declare var HTMLButtonElement: { - prototype: HTMLButtonElement; - new (): HTMLButtonElement; -} - -interface HTMLSourceElement extends HTMLElement { - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the intended media type of the media source. - */ - media: string; - /** - * Gets or sets the MIME type of a media resource. - */ - type: string; -} -declare var HTMLSourceElement: { - prototype: HTMLSourceElement; - new (): HTMLSourceElement; -} - -interface CanvasGradient { - addColorStop(offset: number, color: string): void; -} -declare var CanvasGradient: { - prototype: CanvasGradient; - new (): CanvasGradient; -} - -interface KeyboardEvent extends UIEvent { - location: number; - keyCode: number; - shiftKey: boolean; - which: number; - locale: string; - key: string; - altKey: boolean; - metaKey: boolean; - char: string; - ctrlKey: boolean; - repeat: boolean; - charCode: number; - getModifierState(keyArg: string): boolean; - initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} -declare var KeyboardEvent: { - prototype: KeyboardEvent; - new (): KeyboardEvent; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} - -interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions { - /** - * Retrieves the collection of user agents and versions declared in the X-UA-Compatible - */ - compatible: MSCompatibleInfoCollection; - /** - * Fires when the user presses a key. - * @param ev The keyboard event - */ - onkeydown: (ev: KeyboardEvent) => any; - /** - * Fires when the user releases a key. - * @param ev The keyboard event - */ - onkeyup: (ev: KeyboardEvent) => any; - - /** - * Gets the implementation object of the current document. - */ - implementation: DOMImplementation; - /** - * Fires when the user resets a form. - * @param ev The event. - */ - onreset: (ev: Event) => any; - - /** - * Retrieves a collection of all script objects in the document. - */ - scripts: HTMLCollection; - - /** - * Fires when the user presses the F1 key while the browser is the active window. - * @param ev The event. - */ - onhelp: (ev: Event) => any; - - /** - * 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; - - /** - * Gets or sets the character set used to encode the object. - */ - charset: string; - - /** - * Fires for an element just prior to setting focus on that element. - * @param ev The focus event - */ - onfocusin: (ev: FocusEvent) => any; - - - /** - * Sets or gets the color of the links that the user has visited. - */ - vlinkColor: string; - - /** - * Occurs when the seek operation ends. - * @param ev The event. - */ - onseeked: (ev: Event) => any; - - security: string; - - /** - * Contains the title of the document. - */ - title: string; - - /** - * Retrieves a collection of namespace objects. - */ - namespaces: MSNamespaceInfoCollection; - - /** - * Gets the default character set from the current regional language settings. - */ - defaultCharset: string; - - /** - * Retrieves a collection of all embed objects in the document. - */ - embeds: HTMLCollection; - - /** - * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. - */ - styleSheets: StyleSheetList; - - /** - * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. - */ - frames: Window; - - /** - * Occurs when the duration attribute is updated. - * @param ev The event. - */ - ondurationchange: (ev: Event) => any; - - - /** - * Returns a reference to the collection of elements contained by the object. - */ - all: HTMLCollection; - - /** - * Retrieves a collection, in source order, of all form objects in the document. - */ - forms: HTMLCollection; - - /** - * Fires when the object loses the input focus. - * @param ev The focus event. - */ - onblur: (ev: FocusEvent) => any; - - - /** - * Sets or retrieves a value that indicates the reading order of the object. - */ - dir: string; - - /** - * Occurs when the media element is reset to its initial state. - * @param ev The event. - */ - onemptied: (ev: Event) => any; - - - /** - * Sets or gets a value that indicates whether the document can be edited. - */ - designMode: string; - - /** - * Occurs when the current playback position is moved. - * @param ev The event. - */ - onseeking: (ev: Event) => any; - - - /** - * Fires when the activeElement is changed from the current object to another object in the parent document. - * @param ev The UI Event - */ - ondeactivate: (ev: UIEvent) => any; - - - /** - * Occurs when playback is possible, but would require further buffering. - * @param ev The event. - */ - oncanplay: (ev: Event) => any; - - - /** - * Fires when the data set exposed by a data source object changes. - * @param ev The event. - */ - ondatasetchanged: (ev: MSEventObj) => any; - - - /** - * Fires when rows are about to be deleted from the recordset. - * @param ev The event - */ - onrowsdelete: (ev: MSEventObj) => any; - - Script: MSScriptHost; - - /** - * Occurs when Internet Explorer begins looking for media data. - * @param ev The event. - */ - onloadstart: (ev: Event) => any; - - - /** - * Gets the URL for the document, stripped of any character encoding. - */ - URLUnencoded: string; - - defaultView: Window; - - /** - * Fires when the user is about to make a control selection of the object. - * @param ev The event. - */ - oncontrolselect: (ev: MSEventObj) => any; - - - /** - * Fires on the target element when the user drags the object to a valid drop target. - * @param ev The drag event. - */ - ondragenter: (ev: DragEvent) => any; - - onsubmit: (ev: Event) => any; - - /** - * Returns the character encoding used to create the webpage that is loaded into the document object. - */ - inputEncoding: string; - - /** - * Gets the object that has the focus when the parent document has focus. - */ - activeElement: Element; - - /** - * Fires when the contents of the object or selection have changed. - * @param ev The event. - */ - onchange: (ev: Event) => any; - - - /** - * Retrieves a collection of all a objects that specify the href property and all area objects in the document. - */ - links: HTMLCollection; - - /** - * Retrieves an autogenerated, unique identifier for the object. - */ - uniqueID: string; - - /** - * Sets or gets the URL for the current document. - */ - URL: string; - - /** - * Fires immediately before the object is set as the active element. - * @param ev The event. - */ - onbeforeactivate: (ev: UIEvent) => any; - - head: HTMLHeadElement; - cookie: string; - xmlEncoding: string; - oncanplaythrough: (ev: Event) => any; - - /** - * Retrieves the document compatibility mode of the document. - */ - documentMode: number; - - characterSet: string; - - /** - * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. - */ - anchors: HTMLCollection; - - onbeforeupdate: (ev: MSEventObj) => any; - - /** - * Fires to indicate that all data is available from the data source object. - * @param ev The event. - */ - ondatasetcomplete: (ev: MSEventObj) => any; - - plugins: HTMLCollection; - - /** - * Occurs if the load operation has been intentionally halted. - * @param ev The event. - */ - onsuspend: (ev: Event) => any; - - - /** - * Gets the root svg element in the document hierarchy. - */ - rootElement: SVGSVGElement; - - /** - * Retrieves a value that indicates the current state of the object. - */ - readyState: string; - - /** - * Gets the URL of the location that referred the user to the current page. - */ - referrer: string; - - /** - * Sets or gets the color of all active links in the document. - */ - alinkColor: string; - - /** - * Fires on a databound object when an error occurs while updating the associated data in the data source object. - * @param ev The event. - */ - onerrorupdate: (ev: MSEventObj) => any; - - - /** - * Gets a reference to the container object of the window. - */ - parentWindow: Window; - - /** - * Fires when the user moves the mouse pointer outside the boundaries of the object. - * @param ev The mouse event. - */ - onmouseout: (ev: MouseEvent) => any; - - - /** - * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. - * @param ev The event. - */ - onmsthumbnailclick: (ev: MSSiteModeEvent) => any; - - - /** - * Fires when the wheel button is rotated. - * @param ev The mouse event - */ - onmousewheel: (ev: MouseWheelEvent) => any; - - - /** - * Occurs when the volume is changed, or playback is muted or unmuted. - * @param ev The event. - */ - onvolumechange: (ev: Event) => any; - - - /** - * Fires when data changes in the data provider. - * @param ev The event. - */ - oncellchange: (ev: MSEventObj) => any; - - - /** - * Fires just before the data source control changes the current row in the object. - * @param ev The event. - */ - onrowexit: (ev: MSEventObj) => any; - - - /** - * Fires just after new rows are inserted in the current recordset. - * @param ev The event. - */ - onrowsinserted: (ev: MSEventObj) => any; - - - /** - * Gets or sets the version attribute specified in the declaration of an XML document. - */ - xmlVersion: string; - - msCapsLockWarningOff: boolean; - - /** - * Fires when a property changes on the object. - * @param ev The event. - */ - onpropertychange: (ev: MSEventObj) => any; - - - /** - * Fires on the source object when the user releases the mouse at the close of a drag operation. - * @param ev The event. - */ - ondragend: (ev: DragEvent) => any; - - - /** - * Gets an object representing the document type declaration associated with the current document. - */ - doctype: DocumentType; - - /** - * Fires on the target element continuously while the user drags the object over a valid drop target. - * @param ev The event. - */ - ondragover: (ev: DragEvent) => any; - - - /** - * Deprecated. Sets or retrieves a value that indicates the background color behind the object. - */ - bgColor: string; - - /** - * Fires on the source object when the user starts to drag a text selection or selected object. - * @param ev The event. - */ - ondragstart: (ev: DragEvent) => any; - - - /** - * Fires when the user releases a mouse button while the mouse is over the object. - * @param ev The mouse event. - */ - onmouseup: (ev: MouseEvent) => any; - - - /** - * Fires on the source object continuously during a drag operation. - * @param ev The event. - */ - ondrag: (ev: DragEvent) => any; - - - /** - * Fires when the user moves the mouse pointer into the object. - * @param ev The mouse event. - */ - onmouseover: (ev: MouseEvent) => any; - - - /** - * Sets or gets the color of the document links. - */ - linkColor: string; - - /** - * Occurs when playback is paused. - * @param ev The event. - */ - onpause: (ev: Event) => any; - - - /** - * Fires when the user clicks the object with either mouse button. - * @param ev The mouse event. - */ - onmousedown: (ev: MouseEvent) => any; - - - /** - * Fires when the user clicks the left mouse button on the object - * @param ev The mouse event. - */ - onclick: (ev: MouseEvent) => any; - - - /** - * Occurs when playback stops because the next frame of a video resource is not available. - * @param ev The event. - */ - onwaiting: (ev: Event) => any; - - - /** - * Fires when the user clicks the Stop button or leaves the Web page. - * @param ev The event. - */ - onstop: (ev: Event) => any; - - /** - * false (false)[rolls - */ - - /** - * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. - * @param ev The event. - */ - onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; - - - /** - * Retrieves a collection of all applet objects in the document. - */ - applets: HTMLCollection; - - /** - * Specifies the beginning and end of the document body. - */ - body: HTMLElement; - - /** - * Sets or gets the security domain of the document. - */ - domain: string; - - xmlStandalone: boolean; - - /** - * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. - */ - selection: MSSelection; - - /** - * Occurs when the download has stopped. - * @param ev The event. - */ - onstalled: (ev: Event) => any; - - - /** - * Fires when the user moves the mouse over the object. - * @param ev The mouse event. - */ - onmousemove: (ev: MouseEvent) => any; - - - /** - * Gets a reference to the root node of the document. - */ - documentElement: HTMLElement; - - /** - * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. - * @param ev The event. - */ - onbeforeeditfocus: (ev: MSEventObj) => any; - - - /** - * Occurs when the playback rate is increased or decreased. - * @param ev The event. - */ - onratechange: (ev: Event) => any; - - - /** - * Occurs to indicate progress while downloading media data. - * @param ev The event. - */ - onprogress: (ev: any) => any; - - - /** - * Fires when the user double-clicks the object. - * @param ev The mouse event. - */ - ondblclick: (ev: MouseEvent) => any; - - - /** - * Fires when the user clicks the right mouse button in the client area, opening the context menu. - * @param ev The mouse event. - */ - oncontextmenu: (ev: MouseEvent) => any; - - - /** - * Occurs when the duration and dimensions of the media have been determined. - * @param ev The event. - */ - onloadedmetadata: (ev: Event) => any; - - media: string; - - /** - * Fires when an error occurs during object loading. - * @param ev The event. - */ - onerror: (ev: Event) => any; - - - /** - * Occurs when the play method is requested. - * @param ev The event. - */ - onplay: (ev: Event) => any; - - onafterupdate: (ev: MSEventObj) => any; - - /** - * Occurs when the audio or video has started playing. - * @param ev The event. - */ - onplaying: (ev: Event) => any; - - - /** - * Retrieves a collection, in source order, of img objects in the document. - */ - images: HTMLCollection; - - /** - * Contains information about the current URL. - */ - location: Location; - - /** - * Fires when the user aborts the download. - * @param ev The event. - */ - onabort: (ev: UIEvent) => any; - - - /** - * Fires for the current element with focus immediately after moving focus to another element. - * @param ev The event. - */ - onfocusout: (ev: FocusEvent) => any; - - - /** - * Fires when the selection state of a document changes. - * @param ev The event. - */ - onselectionchange: (ev: Event) => any; - - - /** - * Fires when a local DOM Storage area is written to disk. - * @param ev The event. - */ - onstoragecommit: (ev: StorageEvent) => any; - - - /** - * Fires periodically as data arrives from data source objects that asynchronously transmit their data. - * @param ev The event. - */ - ondataavailable: (ev: MSEventObj) => any; - - - /** - * Fires when the state of the object has changed. - * @param ev The event - */ - onreadystatechange: (ev: Event) => any; - - - /** - * Gets the date that the page was last modified, if the page supplies one. - */ - lastModified: string; - - /** - * Fires when the user presses an alphanumeric key. - * @param ev The event. - */ - onkeypress: (ev: KeyboardEvent) => any; - - - /** - * Occurs when media data is loaded at the current playback position. - * @param ev The event. - */ - onloadeddata: (ev: Event) => any; - - - /** - * Fires immediately before the activeElement is changed from the current object to another object in the parent document. - * @param ev The event. - */ - onbeforedeactivate: (ev: UIEvent) => any; - - - /** - * Fires when the object is set as the active element. - * @param ev The event. - */ - onactivate: (ev: UIEvent) => any; - - - onselectstart: (ev: Event) => any; - - /** - * Fires when the object receives focus. - * @param ev The event. - */ - onfocus: (ev: FocusEvent) => any; - - - /** - * Sets or gets the foreground (text) color of the document. - */ - fgColor: string; - - /** - * Occurs to indicate the current playback position. - * @param ev The event. - */ - ontimeupdate: (ev: Event) => any; - - - /** - * Fires when the current selection changes. - * @param ev The event. - */ - onselect: (ev: UIEvent) => any; - - ondrop: (ev: DragEvent) => any; - - /** - * Occurs when the end of playback is reached. - * @param ev The event - */ - onended: (ev: Event) => any; - - - /** - * Gets a value that indicates whether standards-compliant mode is switched on for the object. - */ - compatMode: string; - - /** - * Fires when the user repositions the scroll box in the scroll bar on the object. - * @param ev The event. - */ - onscroll: (ev: UIEvent) => any; - - - /** - * Fires to indicate that the current row has changed in the data source and new data values are available on the object. - * @param ev The event. - */ - onrowenter: (ev: MSEventObj) => any; - - - /** - * Fires immediately after the browser loads the object. - * @param ev The event. - */ - onload: (ev: Event) => any; - - oninput: (ev: Event) => any; - - /** - * Returns the current value of the document, range, or current selection for the given command. - * @param commandId String that specifies a command identifier. - */ - queryCommandValue(commandId: string): string; - - adoptNode(source: Node): Node; - - /** - * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. - * @param commandId String that specifies a command identifier. - */ - queryCommandIndeterm(commandId: string): boolean; - - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - createProcessingInstruction(target: string, data: string): ProcessingInstruction; - - /** - * Executes a command on the current document, current selection, or the given range. - * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. - * @param showUI Display the user interface, defaults to false. - * @param value Value to assign. - */ - execCommand(commandId: string, showUI?: boolean, value?: any): boolean; - - /** - * Returns the element for the specified x coordinate and the specified y coordinate. - * @param x The x-offset - * @param y The y-offset - */ - elementFromPoint(x: number, y: number): Element; - createCDATASection(data: string): CDATASection; - - /** - * Retrieves the string associated with a command. - * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. - */ - queryCommandText(commandId: string): string; - - /** - * Writes one or more HTML expressions to a document in the specified window. - * @param content Specifies the text and HTML tags to write. - */ - write(...content: string[]): void; - - /** - * Allows updating the print settings for the page. - */ - updateSettings(): void; - - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "a"): HTMLAnchorElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "abbr"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "address"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "area"): HTMLAreaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "article"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "aside"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "audio"): HTMLAudioElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "b"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "base"): HTMLBaseElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "bdi"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "bdo"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "blockquote"): HTMLQuoteElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "body"): HTMLBodyElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "br"): HTMLBRElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "button"): HTMLButtonElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "canvas"): HTMLCanvasElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "caption"): HTMLTableCaptionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "cite"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "code"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "col"): HTMLTableColElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "colgroup"): HTMLTableColElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "datalist"): HTMLDataListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dd"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "del"): HTMLModElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dfn"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "div"): HTMLDivElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dl"): HTMLDListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "dt"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "em"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "embed"): HTMLEmbedElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "fieldset"): HTMLFieldSetElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "figcaption"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "figure"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "footer"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "form"): HTMLFormElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h1"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h2"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h3"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h4"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h5"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "h6"): HTMLHeadingElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "head"): HTMLHeadElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "header"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "hgroup"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "hr"): HTMLHRElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "html"): HTMLHtmlElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "i"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "iframe"): HTMLIFrameElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "img"): HTMLImageElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "input"): HTMLInputElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ins"): HTMLModElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "kbd"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "label"): HTMLLabelElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "legend"): HTMLLegendElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "li"): HTMLLIElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "link"): HTMLLinkElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "main"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "map"): HTMLMapElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "mark"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "menu"): HTMLMenuElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "meta"): HTMLMetaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "nav"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "noscript"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "object"): HTMLObjectElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ol"): HTMLOListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "optgroup"): HTMLOptGroupElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "option"): HTMLOptionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "p"): HTMLParagraphElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "param"): HTMLParamElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "pre"): HTMLPreElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "progress"): HTMLProgressElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "q"): HTMLQuoteElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "rp"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "rt"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ruby"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "s"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "samp"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "script"): HTMLScriptElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "section"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "select"): HTMLSelectElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "small"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "source"): HTMLSourceElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "span"): HTMLSpanElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "strong"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "style"): HTMLStyleElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "sub"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "summary"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "sup"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "table"): HTMLTableElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tbody"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "td"): HTMLTableDataCellElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "textarea"): HTMLTextAreaElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tfoot"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "th"): HTMLTableHeaderCellElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "thead"): HTMLTableSectionElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "title"): HTMLTitleElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "tr"): HTMLTableRowElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "track"): HTMLTrackElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "u"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "ul"): HTMLUListElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "var"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "video"): HTMLVideoElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "wbr"): HTMLElement; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: string): HTMLElement; - - /** - * Removes mouse capture from the object in the current document. - */ - releaseCapture(): void; - - /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. - * @param content The text and HTML tags to write. - */ - writeln(...content: string[]): void; - createElementNS(namespaceURI: string, qualifiedName: string): Element; - - /** - * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. - * @param url Specifies a MIME type for the document. - * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. - * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. - * @param replace Specifies whether the existing entry for the document is replaced in the history list. - */ - open(url?: string, name?: string, features?: string, replace?: boolean): any; - - /** - * Returns a Boolean value that indicates whether the current command is supported on the current range. - * @param commandId Specifies a command identifier. - */ - queryCommandSupported(commandId: string): boolean; - - /** - * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. - * @param filter A custom NodeFilter function to use. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; - createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; - - /** - * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. - * @param commandId Specifies a command identifier. - */ - queryCommandEnabled(commandId: string): boolean; - - /** - * Causes the element to receive the focus and executes the code specified by the onfocus event. - */ - focus(): void; - - /** - * Closes an output stream and forces the sent data to display. - */ - close(): void; - - getElementsByClassName(classNames: string): NodeList; - importNode(importedNode: Node, deep: boolean): Node; - - /** - * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. - */ - createRange(): Range; - - /** - * Fires a specified event on the object. - * @param eventName Specifies the name of the event to fire. - * @param eventObj Object that specifies the event object from which to obtain event object properties. - */ - fireEvent(eventName: string, eventObj?: any): boolean; - - /** - * Creates a comment object with the specified data. - * @param data Sets the comment object's data. - */ - createComment(data: string): Comment; - - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "a"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "abbr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "address"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "area"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "article"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "aside"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "audio"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "b"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "base"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "bdi"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "bdo"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "blockquote"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "body"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "br"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "button"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "canvas"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "caption"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "cite"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "code"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "col"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "colgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "datalist"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dd"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "del"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dfn"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "div"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dl"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "dt"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "em"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "embed"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "fieldset"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "figcaption"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "figure"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "footer"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "form"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h1"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h2"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h3"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h4"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h5"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "h6"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "head"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "header"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "hgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "hr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "html"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "i"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "iframe"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "img"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "input"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ins"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "kbd"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "label"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "legend"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "li"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "link"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "main"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "map"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "mark"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "menu"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "meta"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "nav"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "noscript"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "object"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ol"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "optgroup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "option"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "p"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "param"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "pre"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "progress"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "q"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "rp"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "rt"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ruby"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "s"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "samp"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "script"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "section"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "select"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "small"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "source"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "span"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "strong"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "style"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "sub"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "summary"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "sup"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "table"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tbody"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "td"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "textarea"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tfoot"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "th"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "thead"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "title"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "tr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "track"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "u"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "ul"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "var"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "video"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "wbr"): NodeListOf; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: string): NodeList; - - /** - * Creates a new document. - */ - createDocumentFragment(): DocumentFragment; - - /** - * Creates a style sheet for the document. - * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. - * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. - */ - createStyleSheet(href?: string, index?: number): CSSStyleSheet; - - /** - * Gets a collection of objects based on the value of the NAME or ID attribute. - * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. - */ - getElementsByName(elementName: string): NodeList; - - /** - * Returns a Boolean value that indicates the current state of the command. - * @param commandId String that specifies a command identifier. - */ - queryCommandState(commandId: string): boolean; - - /** - * Gets a value indicating whether the object currently has focus. - */ - hasFocus(): boolean; - - /** - * Displays help information for the given command identifier. - * @param commandId Displays help information for the given command identifier. - */ - execCommandShowHelp(commandId: string): boolean; - - /** - * Creates an attribute object with a specified name. - * @param name String that sets the attribute object's name. - */ - createAttribute(name: string): Attr; - - /** - * Creates a text string from the specified value. - * @param data String that specifies the nodeValue property of the text node. - */ - createTextNode(data: string): Text; - - /** - * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list - * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; - - /** - * Generates an event object to pass event context information when you use the fireEvent method. - * @param eventObj An object that specifies an existing event object on which to base the new object. - */ - createEventObject(eventObj?: any): MSEventObj; - - /** - * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. - */ - getSelection(): Selection; - - /** - * Returns a reference to the first object with the specified value of the ID or NAME attribute. - * @param elementId String that specifies the ID value. Case-insensitive. - */ - getElementById(elementId: string): HTMLElement; -} - -declare var Document: { - prototype: Document; - new (): Document; -} - -interface MessageEvent extends Event { - source: Window; - origin: string; - data: any; - initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; -} -declare var MessageEvent: { - prototype: MessageEvent; - new (): MessageEvent; -} - -interface SVGElement extends Element { - onmouseover: (ev: MouseEvent) => any; - viewportElement: SVGElement; - onmousemove: (ev: MouseEvent) => any; - onmouseout: (ev: MouseEvent) => any; - ondblclick: (ev: MouseEvent) => any; - onfocusout: (ev: FocusEvent) => any; - onfocusin: (ev: FocusEvent) => any; - xmlbase: string; - onmousedown: (ev: MouseEvent) => any; - onload: (ev: Event) => any; - onmouseup: (ev: MouseEvent) => any; - onclick: (ev: MouseEvent) => any; - ownerSVGElement: SVGSVGElement; - id: string; -} -declare var SVGElement: { - prototype: SVGElement; - new (): SVGElement; -} - -interface HTMLScriptElement extends HTMLElement { - /** - * Sets or retrieves the status of the script. - */ - defer: boolean; - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; - /** - * Retrieves the URL to an external file that contains the source code or data. - */ - src: string; - /** - * Sets or retrieves the object that is bound to the event script. - */ - htmlFor: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the MIME type for the associated scripting engine. - */ - type: string; - /** - * Sets or retrieves the event for which the script is written. - */ - event: string; -} -declare var HTMLScriptElement: { - prototype: HTMLScriptElement; - new (): HTMLScriptElement; -} - -interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Retrieves the position of the object in the rows collection for the table. - */ - rowIndex: number; - /** - * Retrieves a collection of all cells in the table row. - */ - cells: HTMLCollection; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Retrieves the position of the object in the collection. - */ - sectionRowIndex: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified cell from the table row, as well as from the cells collection. - * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. - */ - deleteCell(index?: number): void; - /** - * Creates a new cell in the table row, and adds the cell to the cells collection. - * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. - */ - insertCell(index?: number): HTMLElement; -} -declare var HTMLTableRowElement: { - prototype: HTMLTableRowElement; - new (): HTMLTableRowElement; -} - -interface CanvasRenderingContext2D { - miterLimit: number; - font: string; - globalCompositeOperation: string; - msFillRule: string; - lineCap: string; - msImageSmoothingEnabled: boolean; - lineDashOffset: number; - shadowColor: string; - lineJoin: string; - shadowOffsetX: number; - lineWidth: number; - canvas: HTMLCanvasElement; - strokeStyle: any; - globalAlpha: number; - shadowOffsetY: number; - fillStyle: any; - shadowBlur: number; - textAlign: string; - textBaseline: string; - restore(): void; - setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - save(): void; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - measureText(text: string): TextMetrics; - isPointInPath(x: number, y: number, fillRule?: string): boolean; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; - rotate(angle: number): void; - fillText(text: string, x: number, y: number, maxWidth?: number): void; - translate(x: number, y: number): void; - scale(x: number, y: number): void; - createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - lineTo(x: number, y: number): void; - getLineDash(): Array; - fill(fillRule?: string): void; - createImageData(imageDataOrSw: any, sh?: number): ImageData; - createPattern(image: HTMLElement, repetition: string): CanvasPattern; - closePath(): void; - rect(x: number, y: number, w: number, h: number): void; - clip(fillRule?: string): void; - clearRect(x: number, y: number, w: number, h: number): void; - moveTo(x: number, y: number): void; - getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; - fillRect(x: number, y: number, w: number, h: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; - strokeRect(x: number, y: number, w: number, h: number): void; - setLineDash(segments: Array): void; - strokeText(text: string, x: number, y: number, maxWidth?: number): void; - beginPath(): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; - createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; -} -declare var CanvasRenderingContext2D: { - prototype: CanvasRenderingContext2D; - new (): CanvasRenderingContext2D; -} - -interface MSCSSRuleList { - length: number; - item(index?: number): CSSStyleRule; - [index: number]: CSSStyleRule; -} -declare var MSCSSRuleList: { - prototype: MSCSSRuleList; - new (): MSCSSRuleList; -} - -interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalAbs: { - prototype: SVGPathSegLinetoHorizontalAbs; - new (): SVGPathSegLinetoHorizontalAbs; -} - -interface SVGPathSegArcAbs extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcAbs: { - prototype: SVGPathSegArcAbs; - new (): SVGPathSegArcAbs; -} - -interface SVGTransformList { - numberOfItems: number; - getItem(index: number): SVGTransform; - consolidate(): SVGTransform; - clear(): void; - appendItem(newItem: SVGTransform): SVGTransform; - initialize(newItem: SVGTransform): SVGTransform; - removeItem(index: number): SVGTransform; - insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; - replaceItem(newItem: SVGTransform, index: number): SVGTransform; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; -} -declare var SVGTransformList: { - prototype: SVGTransformList; - new (): SVGTransformList; -} - -interface HTMLHtmlElement extends HTMLElement { - /** - * Sets or retrieves the DTD version that governs the current document. - */ - version: string; -} -declare var HTMLHtmlElement: { - prototype: HTMLHtmlElement; - new (): HTMLHtmlElement; -} - -interface SVGPathSegClosePath extends SVGPathSeg { -} -declare var SVGPathSegClosePath: { - prototype: SVGPathSegClosePath; - new (): SVGPathSegClosePath; -} - -interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * Raised when the object has been completely received from the server. - */ - onload: (ev: Event) => any; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; -} -declare var HTMLFrameElement: { - prototype: HTMLFrameElement; - new (): HTMLFrameElement; -} - -interface SVGAnimatedLength { - animVal: SVGLength; - baseVal: SVGLength; -} -declare var SVGAnimatedLength: { - prototype: SVGAnimatedLength; - new (): SVGAnimatedLength; -} - -interface SVGAnimatedPoints { - points: SVGPointList; - animatedPoints: SVGPointList; -} - -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGDefsElement: { - prototype: SVGDefsElement; - new (): SVGDefsElement; -} - -interface HTMLQuoteElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLQuoteElement: { - prototype: HTMLQuoteElement; - new (): HTMLQuoteElement; -} - -interface CSSMediaRule extends CSSRule { - media: MediaList; - cssRules: CSSRuleList; - insertRule(rule: string, index?: number): number; - deleteRule(index?: number): void; -} -declare var CSSMediaRule: { - prototype: CSSMediaRule; - new (): CSSMediaRule; -} - -interface WindowModal { - dialogArguments: any; - returnValue: any; -} - -interface XMLHttpRequest extends EventTarget { - responseBody: any; - status: number; - readyState: number; - responseText: string; - responseXML: Document; - ontimeout: (ev: Event) => any; - statusText: string; - onreadystatechange: (ev: Event) => any; - timeout: number; - onload: (ev: Event) => any; - open(method: string, url: string, async?: boolean, user?: string, password?: string): void; - create(): XMLHttpRequest; - send(data?: any): void; - abort(): void; - getAllResponseHeaders(): string; - setRequestHeader(header: string, value: string): void; - getResponseHeader(header: string): string; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; -} -declare var XMLHttpRequest: { - prototype: XMLHttpRequest; - new (): XMLHttpRequest; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; -} - -interface HTMLTableHeaderCellElement extends HTMLTableCellElement { - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; -} -declare var HTMLTableHeaderCellElement: { - prototype: HTMLTableHeaderCellElement; - new (): HTMLTableHeaderCellElement; -} - -interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { -} -declare var HTMLDListElement: { - prototype: HTMLDListElement; - new (): HTMLDListElement; -} - -interface MSDataBindingExtensions { - dataSrc: string; - dataFormatAs: string; - dataFld: string; -} - -interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalRel: { - prototype: SVGPathSegLinetoHorizontalRel; - new (): SVGPathSegLinetoHorizontalRel; -} - -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - ry: SVGAnimatedLength; - cx: SVGAnimatedLength; - rx: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGEllipseElement: { - prototype: SVGEllipseElement; - new (): SVGEllipseElement; -} - -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - target: SVGAnimatedString; -} -declare var SVGAElement: { - prototype: SVGAElement; - new (): SVGAElement; -} - -interface SVGStylable { - className: SVGAnimatedString; - style: CSSStyleDeclaration; -} - -interface SVGTransformable extends SVGLocatable { - transform: SVGAnimatedTransformList; -} - -interface HTMLFrameSetElement extends HTMLElement { - ononline: (ev: Event) => any; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the frame heights of the object. - */ - rows: string; - /** - * Sets or retrieves the frame widths of the object. - */ - cols: string; - /** - * Fires when the object loses the input focus. - */ - onblur: (ev: FocusEvent) => any; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Fires when the object receives focus. - */ - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - onerror: (ev: Event) => any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - onresize: (ev: UIEvent) => any; - name: string; - onafterprint: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - onoffline: (ev: Event) => any; - border: string; - onunload: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onload: (ev: Event) => any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onstorage: (ev: StorageEvent) => any; -} -declare var HTMLFrameSetElement: { - prototype: HTMLFrameSetElement; - new (): HTMLFrameSetElement; -} - -interface Screen { - width: number; - deviceXDPI: number; - fontSmoothingEnabled: boolean; - bufferDepth: number; - logicalXDPI: number; - systemXDPI: number; - availHeight: number; - height: number; - logicalYDPI: number; - systemYDPI: number; - updateInterval: number; - colorDepth: number; - availWidth: number; - deviceYDPI: number; - pixelDepth: number; -} -declare var Screen: { - prototype: Screen; - new (): Screen; -} - -interface Coordinates { - altitudeAccuracy: number; - longitude: number; - latitude: number; - speed: number; - heading: number; - altitude: number; - accuracy: number; -} -declare var Coordinates: { - prototype: Coordinates; - new (): Coordinates; -} - -interface NavigatorGeolocation { - geolocation: Geolocation; -} - -interface NavigatorContentUtils { -} - -interface EventListener { - (evt: Event): void; -} - -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface DataTransfer { - effectAllowed: string; - dropEffect: string; - clearData(format?: string): boolean; - setData(format: string, data: string): boolean; - getData(format: string): string; -} -declare var DataTransfer: { - prototype: DataTransfer; - new (): DataTransfer; -} - -interface FocusEvent extends UIEvent { - relatedTarget: EventTarget; - initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; -} -declare var FocusEvent: { - prototype: FocusEvent; - new (): FocusEvent; -} - -interface Range { - startOffset: number; - collapsed: boolean; - endOffset: number; - startContainer: Node; - endContainer: Node; - commonAncestorContainer: Node; - setStart(refNode: Node, offset: number): void; - setEndBefore(refNode: Node): void; - setStartBefore(refNode: Node): void; - selectNode(refNode: Node): void; - detach(): void; - getBoundingClientRect(): ClientRect; - toString(): string; - compareBoundaryPoints(how: number, sourceRange: Range): number; - insertNode(newNode: Node): void; - collapse(toStart: boolean): void; - selectNodeContents(refNode: Node): void; - cloneContents(): DocumentFragment; - setEnd(refNode: Node, offset: number): void; - cloneRange(): Range; - getClientRects(): ClientRectList; - surroundContents(newParent: Node): void; - deleteContents(): void; - setStartAfter(refNode: Node): void; - extractContents(): DocumentFragment; - setEndAfter(refNode: Node): void; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} -declare var Range: { - prototype: Range; - new (): Range; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} - -interface SVGPoint { - y: number; - x: number; - matrixTransform(matrix: SVGMatrix): SVGPoint; -} -declare var SVGPoint: { - prototype: SVGPoint; - new (): SVGPoint; -} - -interface MSPluginsCollection { - length: number; - refresh(reload?: boolean): void; -} -declare var MSPluginsCollection: { - prototype: MSPluginsCollection; - new (): MSPluginsCollection; -} - -interface SVGAnimatedNumberList { - animVal: SVGNumberList; - baseVal: SVGNumberList; -} -declare var SVGAnimatedNumberList: { - prototype: SVGAnimatedNumberList; - new (): SVGAnimatedNumberList; -} - -interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { - width: SVGAnimatedLength; - x: SVGAnimatedLength; - contentStyleType: string; - onzoom: (ev: any) => any; - y: SVGAnimatedLength; - viewport: SVGRect; - onerror: (ev: Event) => any; - pixelUnitToMillimeterY: number; - onresize: (ev: UIEvent) => any; - screenPixelToMillimeterY: number; - height: SVGAnimatedLength; - onabort: (ev: UIEvent) => any; - contentScriptType: string; - pixelUnitToMillimeterX: number; - currentTranslate: SVGPoint; - onunload: (ev: Event) => any; - currentScale: number; - onscroll: (ev: UIEvent) => any; - screenPixelToMillimeterX: number; - setCurrentTime(seconds: number): void; - createSVGLength(): SVGLength; - getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; - unpauseAnimations(): void; - createSVGRect(): SVGRect; - checkIntersection(element: SVGElement, rect: SVGRect): boolean; - unsuspendRedrawAll(): void; - pauseAnimations(): void; - suspendRedraw(maxWaitMilliseconds: number): number; - deselectAll(): void; - createSVGAngle(): SVGAngle; - getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; - createSVGTransform(): SVGTransform; - unsuspendRedraw(suspendHandleID: number): void; - forceRedraw(): void; - getCurrentTime(): number; - checkEnclosure(element: SVGElement, rect: SVGRect): boolean; - createSVGMatrix(): SVGMatrix; - createSVGPoint(): SVGPoint; - createSVGNumber(): SVGNumber; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; - getElementById(elementId: string): Element; -} -declare var SVGSVGElement: { - prototype: SVGSVGElement; - new (): SVGSVGElement; -} - -interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the object to which the given label object is assigned. - */ - htmlFor: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLabelElement: { - prototype: HTMLLabelElement; - new (): HTMLLabelElement; -} - -interface MSResourceMetadata { - protocol: string; - fileSize: string; - fileUpdatedDate: string; - nameProp: string; - fileCreatedDate: string; - fileModifiedDate: string; - mimeType: string; -} - -interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLegendElement: { - prototype: HTMLLegendElement; - new (): HTMLLegendElement; -} - -interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLDirectoryElement: { - prototype: HTMLDirectoryElement; - new (): HTMLDirectoryElement; -} - -interface SVGAnimatedInteger { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedInteger: { - prototype: SVGAnimatedInteger; - new (): SVGAnimatedInteger; -} - -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { -} -declare var SVGTextElement: { - prototype: SVGTextElement; - new (): SVGTextElement; -} - -interface SVGTSpanElement extends SVGTextPositioningElement { -} -declare var SVGTSpanElement: { - prototype: SVGTSpanElement; - new (): SVGTSpanElement; -} - -interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * Sets or retrieves the value of a list item. - */ - value: number; -} -declare var HTMLLIElement: { - prototype: HTMLLIElement; - new (): HTMLLIElement; -} - -interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalAbs: { - prototype: SVGPathSegLinetoVerticalAbs; - new (): SVGPathSegLinetoVerticalAbs; -} - -interface MSStorageExtensions { - remainingSpace: number; -} - -interface SVGStyleElement extends SVGElement, SVGLangSpace { - media: string; - type: string; - title: string; -} -declare var SVGStyleElement: { - prototype: SVGStyleElement; - new (): SVGStyleElement; -} - -interface MSCurrentStyleCSSProperties extends MSCSSProperties { - blockDirection: string; - clipBottom: string; - clipLeft: string; - clipRight: string; - clipTop: string; - hasLayout: string; -} -declare var MSCurrentStyleCSSProperties: { - prototype: MSCurrentStyleCSSProperties; - new (): MSCurrentStyleCSSProperties; -} - -interface MSHTMLCollectionExtensions { - urns(urn: any): Object; - tags(tagName: any): Object; -} - -interface Storage extends MSStorageExtensions { - length: number; - getItem(key: string): any; - [key: string]: any; - setItem(key: string, data: string): void; - clear(): void; - removeItem(key: string): void; - key(index: number): string; - [index: number]: any; -} -declare var Storage: { - prototype: Storage; - new (): Storage; -} - -interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Sets or retrieves the horizontal margin for the object. - */ - hspace: number; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; - /** - * Raised when the object has been completely received from the server. - */ - onload: (ev: Event) => any; -} -declare var HTMLIFrameElement: { - prototype: HTMLIFrameElement; - new (): HTMLIFrameElement; -} - -interface TextRangeCollection { - length: number; - item(index: number): TextRange; - [index: number]: TextRange; -} -declare var TextRangeCollection: { - prototype: TextRangeCollection; - new (): TextRangeCollection; -} - -interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - scroll: string; - ononline: (ev: Event) => any; - onblur: (ev: FocusEvent) => any; - noWrap: boolean; - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - text: any; - onerror: (ev: Event) => any; - bgProperties: string; - onresize: (ev: UIEvent) => any; - link: any; - aLink: any; - bottomMargin: any; - topMargin: any; - onafterprint: (ev: Event) => any; - vLink: any; - onbeforeprint: (ev: Event) => any; - onoffline: (ev: Event) => any; - onunload: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onload: (ev: Event) => any; - rightMargin: any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - leftMargin: any; - onstorage: (ev: StorageEvent) => any; - createTextRange(): TextRange; -} -declare var HTMLBodyElement: { - prototype: HTMLBodyElement; - new (): HTMLBodyElement; -} - -interface DocumentType extends Node { - name: string; - notations: NamedNodeMap; - systemId: string; - internalSubset: string; - entities: NamedNodeMap; - publicId: string; -} -declare var DocumentType: { - prototype: DocumentType; - new (): DocumentType; -} - -interface SVGRadialGradientElement extends SVGGradientElement { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; - fx: SVGAnimatedLength; - fy: SVGAnimatedLength; -} -declare var SVGRadialGradientElement: { - prototype: SVGRadialGradientElement; - new (): SVGRadialGradientElement; -} - -interface MutationEvent extends Event { - newValue: string; - attrChange: number; - attrName: string; - prevValue: string; - relatedNode: Node; - initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} -declare var MutationEvent: { - prototype: MutationEvent; - new (): MutationEvent; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} - -interface DragEvent extends MouseEvent { - dataTransfer: DataTransfer; - initDragEvent(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, dataTransferArg: DataTransfer): void; -} -declare var DragEvent: { - prototype: DragEvent; - new (): DragEvent; -} - -interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): Object; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; -} -declare var HTMLTableSectionElement: { - prototype: HTMLTableSectionElement; - new (): HTMLTableSectionElement; -} - -interface DOML2DeprecatedListNumberingAndBulletStyle { - type: string; -} - -interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - status: boolean; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - indeterminate: boolean; - readOnly: boolean; - size: number; - loop: number; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. - */ - vrml: string; - /** - * Sets or retrieves a lower resolution image to display. - */ - lowsrc: string; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Sets or retrieves a comma-separated list of content types. - */ - accept: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - defaultChecked: boolean; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Returns the value of the data at the cursor's current position. - */ - value: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - dynsrc: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - checked: boolean; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - start: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Makes the selection equal to the current object. - */ - select(): void; -} -declare var HTMLInputElement: { - prototype: HTMLInputElement; - new (): HTMLInputElement; -} - -interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Contains the protocol of the URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Contains the hostname of a URL. - */ - hostname: string; - /** - * Contains the pathname of the URL. - */ - pathname: string; - Methods: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - protocolLong: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Contains the hostname and port values of the URL. - */ - host: string; - /** - * Contains the anchor portion of the URL including the hash sign (#). - */ - hash: string; - nameProp: string; - urn: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - type: string; - mimeType: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAnchorElement: { - prototype: HTMLAnchorElement; - new (): HTMLAnchorElement; -} - -interface HTMLParamElement extends HTMLElement { - /** - * Sets or retrieves the value of an input parameter for an element. - */ - value: string; - /** - * Sets or retrieves the name of an input parameter for an element. - */ - name: string; - /** - * Sets or retrieves the content type of the resource designated by the value attribute. - */ - type: string; - /** - * Sets or retrieves the data type of the value attribute. - */ - valueType: string; -} -declare var HTMLParamElement: { - prototype: HTMLParamElement; - new (): HTMLParamElement; -} - -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGImageElement: { - prototype: SVGImageElement; - new (): SVGImageElement; -} - -interface SVGAnimatedNumber { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedNumber: { - prototype: SVGAnimatedNumber; - new (): SVGAnimatedNumber; -} - -interface PerformanceTiming { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - msFirstPaint: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - toJSON(): any; -} -declare var PerformanceTiming: { - prototype: PerformanceTiming; - new (): PerformanceTiming; -} - -interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or gets a value that you can use to implement your own width functionality for the object. - */ - width: number; - /** - * Indicates a citation by rendering text in italic type. - */ - cite: string; -} -declare var HTMLPreElement: { - prototype: HTMLPreElement; - new (): HTMLPreElement; -} - -interface EventException { - code: number; - message: string; - toString(): string; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} -declare var EventException: { - prototype: EventException; - new (): EventException; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} - -interface MSNavigatorDoNotTrack { - msDoNotTrack: string; -} - -interface NavigatorOnLine { - onLine: boolean; -} - -interface WindowLocalStorage { - localStorage: Storage; -} - -interface SVGMetadataElement extends SVGElement { -} -declare var SVGMetadataElement: { - prototype: SVGMetadataElement; - new (): SVGMetadataElement; -} - -interface SVGPathSegArcRel extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcRel: { - prototype: SVGPathSegArcRel; - new (): SVGPathSegArcRel; -} - -interface SVGPathSegMovetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoAbs: { - prototype: SVGPathSegMovetoAbs; - new (): SVGPathSegMovetoAbs; -} - -interface SVGStringList { - numberOfItems: number; - replaceItem(newItem: string, index: number): string; - getItem(index: number): string; - clear(): void; - appendItem(newItem: string): string; - initialize(newItem: string): string; - removeItem(index: number): string; - insertItemBefore(newItem: string, index: number): string; -} -declare var SVGStringList: { - prototype: SVGStringList; - new (): SVGStringList; -} - -interface XDomainRequest { - timeout: number; - onerror: (ev: Event) => any; - onload: (ev: Event) => any; - onprogress: (ev: any) => any; - ontimeout: (ev: Event) => any; - responseText: string; - contentType: string; - open(method: string, url: string): void; - create(): XDomainRequest; - abort(): void; - send(data?: any): void; -} -declare var XDomainRequest: { - prototype: XDomainRequest; - new (): XDomainRequest; -} - -interface DOML2DeprecatedBackgroundColorStyle { - bgColor: any; -} - -interface ElementTraversal { - childElementCount: number; - previousElementSibling: Element; - lastElementChild: Element; - nextElementSibling: Element; - firstElementChild: Element; -} - -interface SVGLength { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} -declare var SVGLength: { - prototype: SVGLength; - new (): SVGLength; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} - -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolygonElement: { - prototype: SVGPolygonElement; - new (): SVGPolygonElement; -} - -interface HTMLPhraseElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLPhraseElement: { - prototype: HTMLPhraseElement; - new (): HTMLPhraseElement; -} - -interface NavigatorStorageUtils { -} - -interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicRel: { - prototype: SVGPathSegCurvetoCubicRel; - new (): SVGPathSegCurvetoCubicRel; -} - -interface MSEventObj extends Event { - nextPage: string; - keyCode: number; - toElement: Element; - returnValue: any; - dataFld: string; - y: number; - dataTransfer: DataTransfer; - propertyName: string; - url: string; - offsetX: number; - recordset: Object; - screenX: number; - buttonID: number; - wheelDelta: number; - reason: number; - origin: string; - data: string; - srcFilter: Object; - boundElements: HTMLCollection; - cancelBubble: boolean; - altLeft: boolean; - behaviorCookie: number; - bookmarks: BookmarkCollection; - type: string; - repeat: boolean; - srcElement: Element; - source: Window; - fromElement: Element; - offsetY: number; - x: number; - behaviorPart: number; - qualifier: string; - altKey: boolean; - ctrlKey: boolean; - clientY: number; - shiftKey: boolean; - shiftLeft: boolean; - contentOverflow: boolean; - screenY: number; - ctrlLeft: boolean; - button: number; - srcUrn: string; - clientX: number; - actionURL: string; - getAttribute(strAttributeName: string, lFlags?: number): any; - setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; - removeAttribute(strAttributeName: string, lFlags?: number): boolean; -} -declare var MSEventObj: { - prototype: MSEventObj; - new (): MSEventObj; -} - -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - textLength: SVGAnimatedLength; - lengthAdjust: SVGAnimatedEnumeration; - getCharNumAtPosition(point: SVGPoint): number; - getStartPositionOfChar(charnum: number): SVGPoint; - getExtentOfChar(charnum: number): SVGRect; - getComputedTextLength(): number; - getSubStringLength(charnum: number, nchars: number): number; - selectSubString(charnum: number, nchars: number): void; - getNumberOfChars(): number; - getRotationOfChar(charnum: number): number; - getEndPositionOfChar(charnum: number): SVGPoint; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} -declare var SVGTextContentElement: { - prototype: SVGTextContentElement; - new (): SVGTextContentElement; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} - -interface DOML2DeprecatedColorProperty { - color: string; -} - -interface HTMLCanvasElement extends HTMLElement { - /** - * Gets or sets the width of a canvas element on a document. - */ - width: number; - /** - * Gets or sets the height of a canvas element on a document. - */ - height: number; - /** - * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. - * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. - * @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: { - prototype: HTMLCanvasElement; - new (): HTMLCanvasElement; -} - -interface Location { - hash: string; - protocol: string; - search: string; - href: string; - hostname: string; - port: string; - pathname: string; - host: string; - reload(flag?: boolean): void; - replace(url: string): void; - assign(url: string): void; - toString(): string; -} -declare var Location: { - prototype: Location; - new (): Location; -} - -interface HTMLTitleElement extends HTMLElement { - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; -} -declare var HTMLTitleElement: { - prototype: HTMLTitleElement; - new (): HTMLTitleElement; -} - -interface HTMLStyleElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Retrieves the CSS language in which the style sheet is written. - */ - type: string; -} -declare var HTMLStyleElement: { - prototype: HTMLStyleElement; - new (): HTMLStyleElement; -} - -interface PerformanceEntry { - name: string; - startTime: number; - duration: number; - entryType: string; -} -declare var PerformanceEntry: { - prototype: PerformanceEntry; - new (): PerformanceEntry; -} - -interface SVGTransform { - type: number; - angle: number; - matrix: SVGMatrix; - setTranslate(tx: number, ty: number): void; - setScale(sx: number, sy: number): void; - setMatrix(matrix: SVGMatrix): void; - setSkewY(angle: number): void; - setRotate(angle: number, cx: number, cy: number): void; - setSkewX(angle: number): void; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} -declare var SVGTransform: { - prototype: SVGTransform; - new (): SVGTransform; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} - -interface UIEvent extends Event { - detail: number; - view: Window; - initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; -} -declare var UIEvent: { - prototype: UIEvent; - new (): UIEvent; -} - -interface SVGURIReference { - href: SVGAnimatedString; -} - -interface SVGPathSeg { - pathSegType: number; - pathSegTypeAsLetter: string; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} -declare var SVGPathSeg: { - prototype: SVGPathSeg; - new (): SVGPathSeg; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} - -interface WheelEvent extends MouseEvent { - deltaZ: number; - deltaX: number; - deltaMode: number; - deltaY: number; - initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} -declare var WheelEvent: { - prototype: WheelEvent; - new (): WheelEvent; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} - -interface MSEventAttachmentTarget { - attachEvent(event: string, listener: EventListener): boolean; - detachEvent(event: string, listener: EventListener): void; -} - -interface SVGNumber { - value: number; -} -declare var SVGNumber: { - prototype: SVGNumber; - new (): SVGNumber; -} - -interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - getPathSegAtLength(distance: number): number; - getPointAtLength(distance: number): SVGPoint; - createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; - createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; - createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; - createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; - createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; - createSVGPathSegClosePath(): SVGPathSegClosePath; - createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; - createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; - createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; - createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; - createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; - createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; - createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; - createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; - createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; - getTotalLength(): number; - createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; - createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; - createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; - createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; -} -declare var SVGPathElement: { - prototype: SVGPathElement; - new (): SVGPathElement; -} - -interface MSCompatibleInfo { - version: string; - userAgent: string; -} -declare var MSCompatibleInfo: { - prototype: MSCompatibleInfo; - new (): MSCompatibleInfo; -} - -interface Text extends CharacterData, MSNodeExtensions { - wholeText: string; - splitText(offset: number): Text; - replaceWholeText(content: string): Text; -} -declare var Text: { - prototype: Text; - new (): Text; -} - -interface SVGAnimatedRect { - animVal: SVGRect; - baseVal: SVGRect; -} -declare var SVGAnimatedRect: { - prototype: SVGAnimatedRect; - new (): SVGAnimatedRect; -} - -interface CSSNamespaceRule extends CSSRule { - namespaceURI: string; - prefix: string; -} -declare var CSSNamespaceRule: { - prototype: CSSNamespaceRule; - new (): CSSNamespaceRule; -} - -interface SVGPathSegList { - numberOfItems: number; - replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; - getItem(index: number): SVGPathSeg; - clear(): void; - appendItem(newItem: SVGPathSeg): SVGPathSeg; - initialize(newItem: SVGPathSeg): SVGPathSeg; - removeItem(index: number): SVGPathSeg; - insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; -} -declare var SVGPathSegList: { - prototype: SVGPathSegList; - new (): SVGPathSegList; -} - -interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { -} -declare var HTMLUnknownElement: { - prototype: HTMLUnknownElement; - new (): HTMLUnknownElement; -} - -interface HTMLAudioElement extends HTMLMediaElement { -} -declare var HTMLAudioElement: { - prototype: HTMLAudioElement; - new (): HTMLAudioElement; -} - -interface MSImageResourceExtensions { - dynsrc: string; - vrml: string; - lowsrc: string; - start: string; - loop: number; -} - -interface PositionError { - code: number; - message: string; - toString(): string; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} -declare var PositionError: { - prototype: PositionError; - new (): PositionError; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} - -interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves a list of header cells that provide information for the object. - */ - headers: string; - /** - * Retrieves the position of the object in the cells collection of a row. - */ - cellIndex: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the number columns in the table that the object should span. - */ - colSpan: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. - */ - axis: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; - /** - * Sets or retrieves abbreviated text for the object. - */ - abbr: string; - /** - * Sets or retrieves how many rows in a table the cell should span. - */ - rowSpan: number; - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; -} -declare var HTMLTableCellElement: { - prototype: HTMLTableCellElement; - new (): HTMLTableCellElement; -} - -interface SVGElementInstance extends EventTarget { - previousSibling: SVGElementInstance; - parentNode: SVGElementInstance; - lastChild: SVGElementInstance; - nextSibling: SVGElementInstance; - childNodes: SVGElementInstanceList; - correspondingUseElement: SVGUseElement; - correspondingElement: SVGElement; - firstChild: SVGElementInstance; -} -declare var SVGElementInstance: { - prototype: SVGElementInstance; - new (): SVGElementInstance; -} - -interface MSNamespaceInfoCollection { - length: number; - add(namespace?: string, urn?: string, implementationUrl?: any): Object; - item(index: any): Object; - [index: string]: Object; -} -declare var MSNamespaceInfoCollection: { - prototype: MSNamespaceInfoCollection; - new (): MSNamespaceInfoCollection; -} - -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGCircleElement: { - prototype: SVGCircleElement; - new (): SVGCircleElement; -} - -interface StyleSheetList { - length: number; - item(index?: number): StyleSheet; - [index: number]: StyleSheet; -} -declare var StyleSheetList: { - prototype: StyleSheetList; - new (): StyleSheetList; -} - -interface CSSImportRule extends CSSRule { - styleSheet: CSSStyleSheet; - href: string; - media: MediaList; -} -declare var CSSImportRule: { - prototype: CSSImportRule; - new (): CSSImportRule; -} - -interface CustomEvent extends Event { - detail: any; - initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; -} -declare var CustomEvent: { - prototype: CustomEvent; - new (): CustomEvent; -} - -interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; - /** - * Sets or retrieves the font size of the object. - */ - size: number; -} -declare var HTMLBaseFontElement: { - prototype: HTMLBaseFontElement; - new (): HTMLBaseFontElement; -} - -interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves or sets the text in the entry field of the textArea element. - */ - value: string; - /** - * Sets or retrieves the value indicating whether the control is selected. - */ - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: number; - /** - * Sets or retrieves the width of the object. - */ - cols: number; - /** - * Sets or retrieves the value indicated whether the content of the object is read-only. - */ - readOnly: boolean; - /** - * Sets or retrieves how to handle wordwrapping in the object. - */ - wrap: string; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Retrieves the type of control. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Highlights the input area of a form element. - */ - select(): void; -} -declare var HTMLTextAreaElement: { - prototype: HTMLTextAreaElement; - new (): HTMLTextAreaElement; -} - -interface Geolocation { - clearWatch(watchId: number): void; - getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; - watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; -} -declare var Geolocation: { - prototype: Geolocation; - new (): Geolocation; -} - -interface DOML2DeprecatedMarginStyle { - vspace: number; - hspace: number; -} - -interface MSWindowModeless { - dialogTop: any; - dialogLeft: any; - dialogWidth: any; - dialogHeight: any; - menuArguments: any; -} - -interface DOML2DeprecatedAlignmentStyle { - align: string; -} - -interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { - width: string; - onbounce: (ev: Event) => any; - vspace: number; - trueSpeed: boolean; - scrollAmount: number; - scrollDelay: number; - behavior: string; - height: string; - loop: number; - direction: string; - hspace: number; - onstart: (ev: Event) => any; - onfinish: (ev: Event) => any; - stop(): void; - start(): void; -} -declare var HTMLMarqueeElement: { - prototype: HTMLMarqueeElement; - new (): HTMLMarqueeElement; -} - -interface SVGRect { - y: number; - width: number; - x: number; - height: number; -} -declare var SVGRect: { - prototype: SVGRect; - new (): SVGRect; -} - -interface MSNodeExtensions { - swapNode(otherNode: Node): Node; - removeNode(deep?: boolean): Node; - replaceNode(replacement: Node): Node; -} - -interface History { - length: number; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; -} -declare var History: { - prototype: History; - new (): History; -} - -interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicAbs: { - prototype: SVGPathSegCurvetoCubicAbs; - new (): SVGPathSegCurvetoCubicAbs; -} - -interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticAbs: { - prototype: SVGPathSegCurvetoQuadraticAbs; - new (): SVGPathSegCurvetoQuadraticAbs; -} - -interface TimeRanges { - length: number; - start(index: number): number; - end(index: number): number; -} -declare var TimeRanges: { - prototype: TimeRanges; - new (): TimeRanges; -} - -interface CSSRule { - cssText: string; - parentStyleSheet: CSSStyleSheet; - parentRule: CSSRule; - type: number; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} -declare var CSSRule: { - prototype: CSSRule; - new (): CSSRule; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; -} - -interface SVGPathSegLinetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoAbs: { - prototype: SVGPathSegLinetoAbs; - new (): SVGPathSegLinetoAbs; -} - -interface HTMLModElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLModElement: { - prototype: HTMLModElement; - new (): HTMLModElement; -} - -interface SVGMatrix { - e: number; - c: number; - a: number; - b: number; - d: number; - f: number; - multiply(secondMatrix: SVGMatrix): SVGMatrix; - flipY(): SVGMatrix; - skewY(angle: number): SVGMatrix; - inverse(): SVGMatrix; - scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; - rotate(angle: number): SVGMatrix; - flipX(): SVGMatrix; - translate(x: number, y: number): SVGMatrix; - scale(scaleFactor: number): SVGMatrix; - rotateFromVector(x: number, y: number): SVGMatrix; - skewX(angle: number): SVGMatrix; -} -declare var SVGMatrix: { - prototype: SVGMatrix; - new (): SVGMatrix; -} - -interface MSPopupWindow { - document: Document; - isOpen: boolean; - show(x: number, y: number, w: number, h: number, element?: any): void; - hide(): void; -} -declare var MSPopupWindow: { - prototype: MSPopupWindow; - new (): MSPopupWindow; -} - -interface BeforeUnloadEvent extends Event { - returnValue: string; -} -declare var BeforeUnloadEvent: { - prototype: BeforeUnloadEvent; - new (): BeforeUnloadEvent; -} - -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - animatedInstanceRoot: SVGElementInstance; - instanceRoot: SVGElementInstance; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGUseElement: { - prototype: SVGUseElement; - new (): SVGUseElement; -} - -interface Event { - timeStamp: number; - defaultPrevented: boolean; - isTrusted: boolean; - currentTarget: EventTarget; - cancelBubble: boolean; - target: EventTarget; - eventPhase: number; - cancelable: boolean; - type: string; - srcElement: Element; - bubbles: boolean; - initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; - stopPropagation(): void; - stopImmediatePropagation(): void; - preventDefault(): void; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} -declare var Event: { - prototype: Event; - new (): Event; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} - -interface ImageData { - width: number; - data: Uint8Array; - height: number; -} -declare var ImageData: { - prototype: ImageData; - new (): ImageData; -} - -interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves the alignment of the object relative to the display or table. - */ - align: string; - /** - * Sets or retrieves the number of columns in the group. - */ - span: number; -} -declare var HTMLTableColElement: { - prototype: HTMLTableColElement; - new (): HTMLTableColElement; -} - -interface SVGException { - code: number; - message: string; - toString(): string; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} -declare var SVGException: { - prototype: SVGException; - new (): SVGException; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} - -interface SVGLinearGradientElement extends SVGGradientElement { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLinearGradientElement: { - prototype: SVGLinearGradientElement; - new (): SVGLinearGradientElement; -} - -interface HTMLTableAlignment { - /** - * Sets or retrieves a value that you can use to implement your own ch functionality for the object. - */ - ch: string; - /** - * Sets or retrieves how text and other content are vertically aligned within the object that contains them. - */ - vAlign: string; - /** - * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. - */ - chOff: string; -} - -interface SVGAnimatedEnumeration { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedEnumeration: { - prototype: SVGAnimatedEnumeration; - new (): SVGAnimatedEnumeration; -} - -interface DOML2DeprecatedSizeProperty { - size: number; -} - -interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLUListElement: { - prototype: HTMLUListElement; - new (): HTMLUListElement; -} - -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - ry: SVGAnimatedLength; - rx: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGRectElement: { - prototype: SVGRectElement; - new (): SVGRectElement; -} - -interface ErrorEventHandler { - (event: Event, source: string, fileno: number, columnNumber: number): void; - (message: any, uri: string, lineNumber: number, columnNumber?: number): void; -} - -interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDivElement: { - prototype: HTMLDivElement; - new (): HTMLDivElement; -} - -interface DOML2DeprecatedBorderStyle { - border: string; -} - -interface NamedNodeMap { - length: number; - removeNamedItemNS(namespaceURI: string, localName: string): Attr; - item(index: number): Attr; - [index: number]: Attr; - removeNamedItem(name: string): Attr; - getNamedItem(name: string): Attr; - setNamedItem(arg: Attr): Attr; - getNamedItemNS(namespaceURI: string, localName: string): Attr; - setNamedItemNS(arg: Attr): Attr; -} -declare var NamedNodeMap: { - prototype: NamedNodeMap; - new (): NamedNodeMap; -} - -interface MediaList { - length: number; - mediaText: string; - deleteMedium(oldMedium: string): void; - appendMedium(newMedium: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var MediaList: { - prototype: MediaList; - new (): MediaList; -} - -interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothAbs: { - prototype: SVGPathSegCurvetoQuadraticSmoothAbs; - new (): SVGPathSegCurvetoQuadraticSmoothAbs; -} - -interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothRel: { - prototype: SVGPathSegCurvetoCubicSmoothRel; - new (): SVGPathSegCurvetoCubicSmoothRel; -} - -interface SVGLengthList { - numberOfItems: number; - replaceItem(newItem: SVGLength, index: number): SVGLength; - getItem(index: number): SVGLength; - clear(): void; - appendItem(newItem: SVGLength): SVGLength; - initialize(newItem: SVGLength): SVGLength; - removeItem(index: number): SVGLength; - insertItemBefore(newItem: SVGLength, index: number): SVGLength; -} -declare var SVGLengthList: { - prototype: SVGLengthList; - new (): SVGLengthList; -} - -interface ProcessingInstruction extends Node { - target: string; - data: string; -} -declare var ProcessingInstruction: { - prototype: ProcessingInstruction; - new (): ProcessingInstruction; -} - -interface MSWindowExtensions { - status: string; - onmouseleave: (ev: MouseEvent) => any; - screenLeft: number; - offscreenBuffering: any; - maxConnectionsPerServer: number; - onmouseenter: (ev: MouseEvent) => any; - clipboardData: DataTransfer; - defaultStatus: string; - clientInformation: Navigator; - closed: boolean; - onhelp: (ev: Event) => any; - external: External; - event: MSEventObj; - onfocusout: (ev: FocusEvent) => any; - screenTop: number; - onfocusin: (ev: FocusEvent) => any; - showModelessDialog(url?: string, argument?: any, options?: any): Window; - navigate(url: string): void; - resizeBy(x?: number, y?: number): void; - item(index: any): any; - resizeTo(x?: number, y?: number): void; - createPopup(arguments?: any): MSPopupWindow; - toStaticHTML(html: string): string; - execScript(code: string, language?: string): any; - msWriteProfilerMark(profilerMarkName: string): void; - moveTo(x?: number, y?: number): void; - moveBy(x?: number, y?: number): void; - showHelp(url: string, helpArg?: any, features?: string): void; -} - -interface MSBehaviorUrnsCollection { - length: number; - item(index: number): string; -} -declare var MSBehaviorUrnsCollection: { - prototype: MSBehaviorUrnsCollection; - new (): MSBehaviorUrnsCollection; -} - -interface CSSFontFaceRule extends CSSRule { - style: CSSStyleDeclaration; -} -declare var CSSFontFaceRule: { - prototype: CSSFontFaceRule; - new (): CSSFontFaceRule; -} - -interface DOML2DeprecatedBackgroundStyle { - background: string; -} - -interface TextEvent extends UIEvent { - inputMethod: number; - data: string; - locale: string; - initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} -declare var TextEvent: { - prototype: TextEvent; - new (): TextEvent; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} - -interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { -} -declare var DocumentFragment: { - prototype: DocumentFragment; - new (): DocumentFragment; -} - -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolylineElement: { - prototype: SVGPolylineElement; - new (): SVGPolylineElement; -} - -interface SVGAnimatedPathData { - pathSegList: SVGPathSegList; -} - -interface Position { - timestamp: number; - coords: Coordinates; -} -declare var Position: { - prototype: Position; - new (): Position; -} - -interface BookmarkCollection { - length: number; - item(index: number): any; - [index: number]: any; -} -declare var BookmarkCollection: { - prototype: BookmarkCollection; - new (): BookmarkCollection; -} - -interface PerformanceMark extends PerformanceEntry { -} -declare var PerformanceMark: { - prototype: PerformanceMark; - new (): PerformanceMark; -} - -interface CSSPageRule extends CSSRule { - pseudoClass: string; - selectorText: string; - selector: string; - style: CSSStyleDeclaration; -} -declare var CSSPageRule: { - prototype: CSSPageRule; - new (): CSSPageRule; -} - -interface HTMLBRElement extends HTMLElement { - /** - * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. - */ - clear: string; -} -declare var HTMLBRElement: { - prototype: HTMLBRElement; - new (): HTMLBRElement; -} - -interface MSNavigatorExtensions { - userLanguage: string; - plugins: MSPluginsCollection; - cookieEnabled: boolean; - appCodeName: string; - cpuClass: string; - appMinorVersion: string; - connectionSpeed: number; - browserLanguage: string; - mimeTypes: MSMimeTypesCollection; - systemLanguage: string; - javaEnabled(): boolean; - taintEnabled(): boolean; -} - -interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { -} -declare var HTMLSpanElement: { - prototype: HTMLSpanElement; - new (): HTMLSpanElement; -} - -interface HTMLHeadElement extends HTMLElement { - profile: string; -} -declare var HTMLHeadElement: { - prototype: HTMLHeadElement; - new (): HTMLHeadElement; -} - -interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; -} -declare var HTMLHeadingElement: { - prototype: HTMLHeadingElement; - new (): HTMLHeadingElement; -} - -interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. - */ - acceptCharset: string; - /** - * Sets or retrieves the encoding type for the form. - */ - enctype: string; - /** - * Retrieves a collection, in source order, of all controls in a given form. - */ - elements: HTMLCollection; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves how to send the form data to the server. - */ - method: string; - /** - * Sets or retrieves the MIME encoding for the form. - */ - encoding: string; - /** - * Fires when the user resets a form. - */ - reset(): void; - /** - * Retrieves a form object or an object from an elements collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Fires when a FORM is about to be submitted. - */ - submit(): void; - /** - * Retrieves a form object or an object from an elements collection. - */ - namedItem(name: string): any; - [name: string]: any; -} -declare var HTMLFormElement: { - prototype: HTMLFormElement; - new (): HTMLFormElement; -} - -interface SVGZoomAndPan { - zoomAndPan: number; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} -declare var SVGZoomAndPan: { - prototype: SVGZoomAndPan; - new (): SVGZoomAndPan; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} - -interface HTMLMediaElement extends HTMLElement { - /** - * Gets the earliest possible position, in seconds, that the playback can begin. - */ - initialTime: number; - /** - * Gets TimeRanges for the current media resource that has been played. - */ - played: TimeRanges; - /** - * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. - */ - currentSrc: string; - readyState: any; - /** - * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. - */ - autobuffer: boolean; - /** - * Gets or sets a flag to specify whether playback should restart after it completes. - */ - loop: boolean; - /** - * Gets information about whether the playback has ended or not. - */ - ended: boolean; - /** - * Gets a collection of buffered time ranges. - */ - buffered: TimeRanges; - /** - * Returns an object representing the current error state of the audio or video element. - */ - error: MediaError; - /** - * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. - */ - seekable: TimeRanges; - /** - * Gets or sets a value that indicates whether to start playing the media automatically. - */ - autoplay: boolean; - /** - * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). - */ - controls: boolean; - /** - * Gets or sets the volume level for audio portions of the media element. - */ - volume: number; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. - */ - playbackRate: number; - /** - * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. - */ - duration: number; - /** - * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. - */ - muted: boolean; - /** - * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. - */ - defaultPlaybackRate: number; - /** - * Gets a flag that specifies whether playback is paused. - */ - paused: boolean; - /** - * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. - */ - seeking: boolean; - /** - * Gets or sets the current playback position, in seconds. - */ - currentTime: number; - /** - * Gets or sets the current playback position, in seconds. - */ - preload: string; - /** - * Gets the current network activity for the element. - */ - networkState: number; - /** - * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. - */ - pause(): void; - /** - * Loads and starts playback of a media resource. - */ - play(): void; - /** - * Fires immediately after the client loads the object. - */ - load(): void; - /** - * Returns a string that specifies whether the client can play a given media resource type. - */ - canPlayType(type: string): string; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} -declare var HTMLMediaElement: { - prototype: HTMLMediaElement; - new (): HTMLMediaElement; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} - -interface ElementCSSInlineStyle { - runtimeStyle: MSStyleCSSProperties; - currentStyle: MSCurrentStyleCSSProperties; - doScroll(component?: any): void; - componentFromPoint(x: number, y: number): string; -} - -interface DOMParser { - parseFromString(source: string, mimeType: string): Document; -} -declare var DOMParser: { - prototype: DOMParser; - new (): DOMParser; -} - -interface MSMimeTypesCollection { - length: number; -} -declare var MSMimeTypesCollection: { - prototype: MSMimeTypesCollection; - new (): MSMimeTypesCollection; -} - -interface StyleSheet { - disabled: boolean; - ownerNode: Node; - parentStyleSheet: StyleSheet; - href: string; - media: MediaList; - type: string; - title: string; -} -declare var StyleSheet: { - prototype: StyleSheet; - new (): StyleSheet; -} - -interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { - startOffset: SVGAnimatedLength; - method: SVGAnimatedEnumeration; - spacing: SVGAnimatedEnumeration; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} -declare var SVGTextPathElement: { - prototype: SVGTextPathElement; - new (): SVGTextPathElement; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} - -interface HTMLDTElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDTElement: { - prototype: HTMLDTElement; - new (): HTMLDTElement; -} - -interface NodeList { - length: number; - item(index: number): Node; - [index: number]: Node; -} -declare var NodeList: { - prototype: NodeList; - new (): NodeList; -} - -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - -interface XMLSerializer { - serializeToString(target: Node): string; -} -declare var XMLSerializer: { - prototype: XMLSerializer; - new (): XMLSerializer; -} - -interface PerformanceMeasure extends PerformanceEntry { -} -declare var PerformanceMeasure: { - prototype: PerformanceMeasure; - new (): PerformanceMeasure; -} - -interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { - spreadMethod: SVGAnimatedEnumeration; - gradientTransform: SVGAnimatedTransformList; - gradientUnits: SVGAnimatedEnumeration; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} -declare var SVGGradientElement: { - prototype: SVGGradientElement; - new (): SVGGradientElement; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} - -interface NodeFilter { - acceptNode(n: Node): number; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} -declare var NodeFilter: { - prototype: NodeFilter; - new (): NodeFilter; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} - -interface SVGNumberList { - numberOfItems: number; - replaceItem(newItem: SVGNumber, index: number): SVGNumber; - getItem(index: number): SVGNumber; - clear(): void; - appendItem(newItem: SVGNumber): SVGNumber; - initialize(newItem: SVGNumber): SVGNumber; - removeItem(index: number): SVGNumber; - insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; -} -declare var SVGNumberList: { - prototype: SVGNumberList; - new (): SVGNumberList; -} - -interface MediaError { - code: number; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} -declare var MediaError: { - prototype: MediaError; - new (): MediaError; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; -} - -interface HTMLFieldSetElement extends HTMLElement { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLFieldSetElement: { - prototype: HTMLFieldSetElement; - new (): HTMLFieldSetElement; -} - -interface HTMLBGSoundElement extends HTMLElement { - /** - * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. - */ - balance: any; - /** - * Sets or gets the volume setting for the sound. - */ - volume: any; - /** - * Sets or gets the URL of a sound to play. - */ - src: string; - /** - * Sets or retrieves the number of times a sound or video clip will loop when activated. - */ - loop: number; -} -declare var HTMLBGSoundElement: { - prototype: HTMLBGSoundElement; - new (): HTMLBGSoundElement; -} - -interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { - onmouseleave: (ev: MouseEvent) => any; - onbeforecut: (ev: DragEvent) => any; - onkeydown: (ev: KeyboardEvent) => any; - onmove: (ev: MSEventObj) => any; - onkeyup: (ev: KeyboardEvent) => any; - onreset: (ev: Event) => any; - onhelp: (ev: Event) => any; - ondragleave: (ev: DragEvent) => any; - className: string; - onfocusin: (ev: FocusEvent) => any; - onseeked: (ev: Event) => any; - recordNumber: any; - title: string; - parentTextEdit: Element; - outerHTML: string; - ondurationchange: (ev: Event) => any; - offsetHeight: number; - all: HTMLCollection; - onblur: (ev: FocusEvent) => any; - dir: string; - onemptied: (ev: Event) => any; - onseeking: (ev: Event) => any; - oncanplay: (ev: Event) => any; - ondeactivate: (ev: UIEvent) => any; - ondatasetchanged: (ev: MSEventObj) => any; - onrowsdelete: (ev: MSEventObj) => any; - sourceIndex: number; - onloadstart: (ev: Event) => any; - onlosecapture: (ev: MSEventObj) => any; - ondragenter: (ev: DragEvent) => any; - oncontrolselect: (ev: MSEventObj) => any; - onsubmit: (ev: Event) => any; - behaviorUrns: MSBehaviorUrnsCollection; - scopeName: string; - onchange: (ev: Event) => any; - id: string; - onlayoutcomplete: (ev: MSEventObj) => any; - uniqueID: string; - onbeforeactivate: (ev: UIEvent) => any; - oncanplaythrough: (ev: Event) => any; - onbeforeupdate: (ev: MSEventObj) => any; - onfilterchange: (ev: MSEventObj) => any; - offsetParent: Element; - ondatasetcomplete: (ev: MSEventObj) => any; - onsuspend: (ev: Event) => any; - readyState: any; - onmouseenter: (ev: MouseEvent) => any; - innerText: string; - onerrorupdate: (ev: MSEventObj) => any; - onmouseout: (ev: MouseEvent) => any; - parentElement: HTMLElement; - onmousewheel: (ev: MouseWheelEvent) => any; - onvolumechange: (ev: Event) => any; - oncellchange: (ev: MSEventObj) => any; - onrowexit: (ev: MSEventObj) => any; - onrowsinserted: (ev: MSEventObj) => any; - onpropertychange: (ev: MSEventObj) => any; - filters: Object; - children: HTMLCollection; - ondragend: (ev: DragEvent) => any; - onbeforepaste: (ev: DragEvent) => any; - ondragover: (ev: DragEvent) => any; - offsetTop: number; - onmouseup: (ev: MouseEvent) => any; - ondragstart: (ev: DragEvent) => any; - onbeforecopy: (ev: DragEvent) => any; - ondrag: (ev: DragEvent) => any; - innerHTML: string; - onmouseover: (ev: MouseEvent) => any; - lang: string; - uniqueNumber: number; - onpause: (ev: Event) => any; - tagUrn: string; - onmousedown: (ev: MouseEvent) => any; - onclick: (ev: MouseEvent) => any; - onwaiting: (ev: Event) => any; - onresizestart: (ev: MSEventObj) => any; - offsetLeft: number; - isTextEdit: boolean; - isDisabled: boolean; - onpaste: (ev: DragEvent) => any; - canHaveHTML: boolean; - onmoveend: (ev: MSEventObj) => any; - language: string; - onstalled: (ev: Event) => any; - onmousemove: (ev: MouseEvent) => any; - style: MSStyleCSSProperties; - isContentEditable: boolean; - onbeforeeditfocus: (ev: MSEventObj) => any; - onratechange: (ev: Event) => any; - contentEditable: string; - tabIndex: number; - document: Document; - onprogress: (ev: any) => any; - ondblclick: (ev: MouseEvent) => any; - oncontextmenu: (ev: MouseEvent) => any; - onloadedmetadata: (ev: Event) => any; - onafterupdate: (ev: MSEventObj) => any; - onerror: (ev: Event) => any; - onplay: (ev: Event) => any; - onresizeend: (ev: MSEventObj) => any; - onplaying: (ev: Event) => any; - isMultiLine: boolean; - onfocusout: (ev: FocusEvent) => any; - onabort: (ev: UIEvent) => any; - ondataavailable: (ev: MSEventObj) => any; - hideFocus: boolean; - onreadystatechange: (ev: Event) => any; - onkeypress: (ev: KeyboardEvent) => any; - onloadeddata: (ev: Event) => any; - onbeforedeactivate: (ev: UIEvent) => any; - outerText: string; - disabled: boolean; - onactivate: (ev: UIEvent) => any; - accessKey: string; - onmovestart: (ev: MSEventObj) => any; - onselectstart: (ev: Event) => any; - onfocus: (ev: FocusEvent) => any; - ontimeupdate: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - oncut: (ev: DragEvent) => any; - onselect: (ev: UIEvent) => any; - ondrop: (ev: DragEvent) => any; - offsetWidth: number; - oncopy: (ev: DragEvent) => any; - onended: (ev: Event) => any; - onscroll: (ev: UIEvent) => any; - onrowenter: (ev: MSEventObj) => any; - onload: (ev: Event) => any; - canHaveChildren: boolean; - oninput: (ev: Event) => any; - dragDrop(): boolean; - scrollIntoView(top?: boolean): void; - addFilter(filter: Object): void; - setCapture(containerCapture?: boolean): void; - focus(): void; - getAdjacentText(where: string): string; - insertAdjacentText(where: string, text: string): void; - getElementsByClassName(classNames: string): NodeList; - setActive(): void; - removeFilter(filter: Object): void; - blur(): void; - clearAttributes(): void; - releaseCapture(): void; - createControlRange(): ControlRangeCollection; - removeBehavior(cookie: number): boolean; - contains(child: HTMLElement): boolean; - click(): void; - insertAdjacentElement(position: string, insertedElement: Element): Element; - mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; - replaceAdjacentText(where: string, newText: string): string; - applyElement(apply: Element, where?: string): Element; - addBehavior(bstrUrl: string, factory?: any): number; - insertAdjacentHTML(where: string, html: string): void; -} -declare var HTMLElement: { - prototype: HTMLElement; - new (): HTMLElement; -} - -interface Comment extends CharacterData { - text: string; -} -declare var Comment: { - prototype: Comment; - new (): Comment; -} - -interface PerformanceResourceTiming extends PerformanceEntry { - redirectStart: number; - redirectEnd: number; - domainLookupEnd: number; - responseStart: number; - domainLookupStart: number; - fetchStart: number; - requestStart: number; - connectEnd: number; - connectStart: number; - initiatorType: string; - responseEnd: number; -} -declare var PerformanceResourceTiming: { - prototype: PerformanceResourceTiming; - new (): PerformanceResourceTiming; -} - -interface CanvasPattern { -} -declare var CanvasPattern: { - prototype: CanvasPattern; - new (): CanvasPattern; -} - -interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. - */ - noShade: boolean; -} -declare var HTMLHRElement: { - prototype: HTMLHRElement; - new (): HTMLHRElement; -} - -interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - /** - * Retrieves the contained object. - */ - object: Object; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL of the file containing the compiled Java class. - */ - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - declare: boolean; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; -} -declare var HTMLObjectElement: { - prototype: HTMLObjectElement; - new (): HTMLObjectElement; -} - -interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Retrieves the palette used for the embedded document. - */ - palette: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Retrieves the URL of the plug-in used to view an embedded document. - */ - pluginspage: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the height and width units of the embed object. - */ - units: string; -} -declare var HTMLEmbedElement: { - prototype: HTMLEmbedElement; - new (): HTMLEmbedElement; -} - -interface StorageEvent extends Event { - oldValue: any; - newValue: any; - url: string; - storageArea: Storage; - key: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; -} -declare var StorageEvent: { - prototype: StorageEvent; - new (): StorageEvent; -} - -interface CharacterData extends Node { - length: number; - data: string; - deleteData(offset: number, count: number): void; - replaceData(offset: number, count: number, arg: string): void; - appendData(arg: string): void; - insertData(offset: number, arg: string): void; - substringData(offset: number, count: number): string; -} -declare var CharacterData: { - prototype: CharacterData; - new (): CharacterData; -} - -interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; -} -declare var HTMLOptGroupElement: { - prototype: HTMLOptGroupElement; - new (): HTMLOptGroupElement; -} - -interface HTMLIsIndexElement extends HTMLElement { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - prompt: string; -} -declare var HTMLIsIndexElement: { - prototype: HTMLIsIndexElement; - new (): HTMLIsIndexElement; -} - -interface SVGPathSegLinetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoRel: { - prototype: SVGPathSegLinetoRel; - new (): SVGPathSegLinetoRel; -} - -interface DOMException { - code: number; - message: string; - toString(): string; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} -declare var DOMException: { - prototype: DOMException; - new (): DOMException; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; -} - -interface SVGAnimatedBoolean { - animVal: boolean; - baseVal: boolean; -} -declare var SVGAnimatedBoolean: { - prototype: SVGAnimatedBoolean; - new (): SVGAnimatedBoolean; -} - -interface MSCompatibleInfoCollection { - length: number; - item(index: number): MSCompatibleInfo; -} -declare var MSCompatibleInfoCollection: { - prototype: MSCompatibleInfoCollection; - new (): MSCompatibleInfoCollection; -} - -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGSwitchElement: { - prototype: SVGSwitchElement; - new (): SVGSwitchElement; -} - -interface SVGPreserveAspectRatio { - align: number; - meetOrSlice: number; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} -declare var SVGPreserveAspectRatio: { - prototype: SVGPreserveAspectRatio; - new (): SVGPreserveAspectRatio; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} - -interface Attr extends Node { - expando: boolean; - specified: boolean; - ownerElement: Element; - value: string; - name: string; -} -declare var Attr: { - prototype: Attr; - new (): Attr; -} - -interface PerformanceNavigation { - redirectCount: number; - type: number; - toJSON(): any; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} -declare var PerformanceNavigation: { - prototype: PerformanceNavigation; - new (): PerformanceNavigation; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} - -interface SVGStopElement extends SVGElement, SVGStylable { - offset: SVGAnimatedNumber; -} -declare var SVGStopElement: { - prototype: SVGStopElement; - new (): SVGStopElement; -} - -interface PositionCallback { - (position: Position): void; -} - -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { -} -declare var SVGSymbolElement: { - prototype: SVGSymbolElement; - new (): SVGSymbolElement; -} - -interface SVGElementInstanceList { - length: number; - item(index: number): SVGElementInstance; -} -declare var SVGElementInstanceList: { - prototype: SVGElementInstanceList; - new (): SVGElementInstanceList; -} - -interface CSSRuleList { - length: number; - item(index: number): CSSRule; - [index: number]: CSSRule; -} -declare var CSSRuleList: { - prototype: CSSRuleList; - new (): CSSRuleList; -} - -interface MSDataBindingRecordSetExtensions { - recordset: Object; - namedRecordset(dataMember: string, hierarchy?: any): Object; -} - -interface LinkStyle { - styleSheet: StyleSheet; - sheet: StyleSheet; -} - -interface HTMLVideoElement extends HTMLMediaElement { - /** - * Gets or sets the width of the video element. - */ - width: number; - /** - * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoWidth: number; - /** - * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoHeight: number; - /** - * Gets or sets the height of the video element. - */ - height: number; - /** - * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. - */ - poster: string; -} -declare var HTMLVideoElement: { - prototype: HTMLVideoElement; - new (): HTMLVideoElement; -} - -interface ClientRectList { - length: number; - item(index: number): ClientRect; - [index: number]: ClientRect; -} -declare var ClientRectList: { - prototype: ClientRectList; - new (): ClientRectList; -} - -interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - maskUnits: SVGAnimatedEnumeration; - maskContentUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGMaskElement: { - prototype: SVGMaskElement; - new (): SVGMaskElement; -} - -interface External { -} -declare var External: { - prototype: External; - new (): External; -} - -declare var Audio: { new (src?: string): HTMLAudioElement; }; -declare var Option: { new (text?: string, value?: string, defaultSelected?: boolean, selected?: boolean): HTMLOptionElement; }; -declare var Image: { new (width?: number, height?: number): HTMLImageElement; }; - -declare var ondragend: (ev: DragEvent) => any; -declare var onkeydown: (ev: KeyboardEvent) => any; -declare var ondragover: (ev: DragEvent) => any; -declare var onkeyup: (ev: KeyboardEvent) => any; -declare var onreset: (ev: Event) => any; -declare var onmouseup: (ev: MouseEvent) => any; -declare var ondragstart: (ev: DragEvent) => any; -declare var ondrag: (ev: DragEvent) => any; -declare var screenX: number; -declare var onmouseover: (ev: MouseEvent) => any; -declare var ondragleave: (ev: DragEvent) => any; -declare var history: History; -declare var pageXOffset: number; -declare var name: string; -declare var onafterprint: (ev: Event) => any; -declare var onpause: (ev: Event) => any; -declare var onbeforeprint: (ev: Event) => any; -declare var top: Window; -declare var onmousedown: (ev: MouseEvent) => any; -declare var onseeked: (ev: Event) => any; -declare var opener: Window; -declare var onclick: (ev: MouseEvent) => any; -declare var innerHeight: number; -declare var onwaiting: (ev: Event) => any; -declare var ononline: (ev: Event) => any; -declare var ondurationchange: (ev: Event) => any; -declare var frames: Window; -declare var onblur: (ev: FocusEvent) => any; -declare var onemptied: (ev: Event) => any; -declare var onseeking: (ev: Event) => any; -declare var oncanplay: (ev: Event) => any; -declare var outerWidth: number; -declare var onstalled: (ev: Event) => any; -declare var onmousemove: (ev: MouseEvent) => any; -declare var innerWidth: number; -declare var onoffline: (ev: Event) => any; -declare var length: number; -declare var screen: Screen; -declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; -declare var onratechange: (ev: Event) => any; -declare var onstorage: (ev: StorageEvent) => any; -declare var onloadstart: (ev: Event) => any; -declare var ondragenter: (ev: DragEvent) => any; -declare var onsubmit: (ev: Event) => any; -declare var self: Window; -declare var document: Document; -declare var onprogress: (ev: any) => any; -declare var ondblclick: (ev: MouseEvent) => any; -declare var pageYOffset: number; -declare var oncontextmenu: (ev: MouseEvent) => any; -declare var onchange: (ev: Event) => any; -declare var onloadedmetadata: (ev: Event) => any; -declare var onplay: (ev: Event) => any; -declare var onerror: ErrorEventHandler; -declare var onplaying: (ev: Event) => any; -declare var parent: Window; -declare var location: Location; -declare var oncanplaythrough: (ev: Event) => any; -declare var onabort: (ev: UIEvent) => any; -declare var onreadystatechange: (ev: Event) => any; -declare var outerHeight: number; -declare var onkeypress: (ev: KeyboardEvent) => any; -declare var frameElement: Element; -declare var onloadeddata: (ev: Event) => any; -declare var onsuspend: (ev: Event) => any; -declare var window: Window; -declare var onfocus: (ev: FocusEvent) => any; -declare var onmessage: (ev: MessageEvent) => any; -declare var ontimeupdate: (ev: Event) => any; -declare var onresize: (ev: UIEvent) => any; -declare var onselect: (ev: UIEvent) => any; -declare var navigator: Navigator; -declare var styleMedia: StyleMedia; -declare var ondrop: (ev: DragEvent) => any; -declare var onmouseout: (ev: MouseEvent) => any; -declare var onended: (ev: Event) => any; -declare var onhashchange: (ev: Event) => any; -declare var onunload: (ev: Event) => any; -declare var onscroll: (ev: UIEvent) => any; -declare var screenY: number; -declare var onmousewheel: (ev: MouseWheelEvent) => any; -declare var onload: (ev: Event) => any; -declare var onvolumechange: (ev: Event) => any; -declare var oninput: (ev: Event) => any; -declare var performance: Performance; -declare function alert(message?: any): void; -declare function scroll(x?: number, y?: number): void; -declare function focus(): void; -declare function scrollTo(x?: number, y?: number): void; -declare function print(): void; -declare function prompt(message?: string, defaul?: string): string; -declare function toString(): string; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; -declare function scrollBy(x?: number, y?: number): void; -declare function confirm(message?: string): boolean; -declare function close(): void; -declare function postMessage(message: any, targetOrigin: string, ports?: any): void; -declare function showModalDialog(url?: string, argument?: any, options?: any): any; -declare function blur(): void; -declare function getSelection(): Selection; -declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -declare function dispatchEvent(evt: Event): boolean; -declare function attachEvent(event: string, listener: EventListener): boolean; -declare function detachEvent(event: string, listener: EventListener): void; -declare var localStorage: Storage; -declare var status: string; -declare var onmouseleave: (ev: MouseEvent) => any; -declare var screenLeft: number; -declare var offscreenBuffering: any; -declare var maxConnectionsPerServer: number; -declare var onmouseenter: (ev: MouseEvent) => any; -declare var clipboardData: DataTransfer; -declare var defaultStatus: string; -declare var clientInformation: Navigator; -declare var closed: boolean; -declare var onhelp: (ev: Event) => any; -declare var external: External; -declare var event: MSEventObj; -declare var onfocusout: (ev: FocusEvent) => any; -declare var screenTop: number; -declare var onfocusin: (ev: FocusEvent) => any; -declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; -declare function navigate(url: string): void; -declare function resizeBy(x?: number, y?: number): void; -declare function item(index: any): any; -declare function resizeTo(x?: number, y?: number): void; -declare function createPopup(arguments?: any): MSPopupWindow; -declare function toStaticHTML(html: string): string; -declare function execScript(code: string, language?: string): any; -declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function moveTo(x?: number, y?: number): void; -declare function moveBy(x?: number, y?: number): void; -declare function showHelp(url: string, helpArg?: any, features?: string): void; -declare var sessionStorage: Storage; -declare function clearTimeout(handle: number): void; -declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; -declare function clearInterval(handle: number): void; -declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; - - -///////////////////////////// -/// IE10 DOM APIs -///////////////////////////// - - -interface ObjectURLOptions { - oneTimeOnly?: boolean; -} - -interface HTMLBodyElement { - onpopstate: (ev: PopStateEvent) => any; -} - -interface MSGestureEvent extends UIEvent { - offsetY: number; - translationY: number; - velocityExpansion: number; - velocityY: number; - velocityAngular: number; - translationX: number; - velocityX: number; - hwTimestamp: number; - offsetX: number; - screenX: number; - rotation: number; - expansion: number; - clientY: number; - screenY: number; - scale: number; - gestureObject: any; - clientX: number; - initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} -declare var MSGestureEvent: { - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} - -interface HTMLAnchorElement { - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; -} - -interface HTMLInputElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a FileList object on a file type input object. - */ - files: FileList; - /** - * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. - */ - max: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. - */ - step: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Returns the input field value as a number. - */ - valueAsNumber: number; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Specifies the ID of a pre-defined datalist of options for an input element. - */ - list: HTMLElement; - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. - */ - min: string; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Gets or sets a string containing a regular expression that the user's input must match. - */ - pattern: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. - * @param n Value to decrement the value by. - */ - stepDown(n?: number): void; - /** - * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. - * @param n Value to increment the value by. - */ - stepUp(n?: number): void; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -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; -} - -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - filterResX: SVGAnimatedInteger; - filterUnits: SVGAnimatedEnumeration; - primitiveUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - filterResY: SVGAnimatedInteger; - setFilterRes(filterResX: number, filterResY: number): void; -} - -interface TrackEvent extends Event { - track: any; -} - -interface SVGFEMergeNodeElement extends SVGElement { - in1: SVGAnimatedString; -} - -interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} - -interface MSGesture { - target: Element; - addPointer(pointerId: number): void; - stop(): void; -} -declare var MSGesture: { - prototype: MSGesture; - new (): MSGesture; -} - -interface TextTrackCue extends EventTarget { - onenter: (ev: Event) => any; - track: TextTrack; - endTime: number; - text: string; - pauseOnExit: boolean; - id: string; - startTime: number; - onexit: (ev: Event) => any; - getCueAsHTML(): DocumentFragment; -} -declare var TextTrackCue: { - prototype: TextTrackCue; - new (): TextTrackCue; -} - -interface MSStreamReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; -} -declare var MSStreamReader: { - prototype: MSStreamReader; - new (): MSStreamReader; -} - -interface DOMTokenList { - length: number; - contains(token: string): boolean; - remove(token: string): void; - toggle(token: string): boolean; - add(token: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} - -interface EventException { - name: string; -} - -interface Performance { - now(): number; -} - -interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { -} - -interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} - -interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - mode: SVGAnimatedEnumeration; - in1: SVGAnimatedString; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} -declare var SVGFEBlendElement: { - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} - -interface WindowTimers extends WindowTimersExtension { -} - -interface CSSStyleDeclaration { - animationFillMode: string; - floodColor: string; - animationIterationCount: string; - textShadow: string; - backfaceVisibility: string; - msAnimationIterationCount: string; - animationDelay: string; - animationTimingFunction: string; - columnWidth: any; - msScrollSnapX: string; - columnRuleColor: any; - columnRuleWidth: any; - transitionDelay: string; - transition: string; - msFlowFrom: string; - msScrollSnapType: string; - msContentZoomSnapType: string; - msGridColumns: string; - msAnimationName: string; - msGridRowAlign: string; - msContentZoomChaining: string; - msGridColumn: any; - msHyphenateLimitZone: any; - msScrollRails: string; - msAnimationDelay: string; - enableBackground: string; - msWrapThrough: string; - columnRuleStyle: string; - msAnimation: string; - msFlexFlow: string; - msScrollSnapY: string; - msHyphenateLimitLines: any; - msTouchAction: string; - msScrollLimit: string; - animation: string; - transform: string; - filter: string; - colorInterpolationFilters: string; - transitionTimingFunction: string; - msBackfaceVisibility: string; - animationPlayState: string; - transformOrigin: string; - msScrollLimitYMin: any; - msFontFeatureSettings: string; - msContentZoomLimitMin: any; - columnGap: any; - transitionProperty: string; - msAnimationDuration: string; - msAnimationFillMode: string; - msFlexDirection: string; - msTransitionDuration: string; - fontFeatureSettings: string; - breakBefore: string; - msFlexWrap: string; - perspective: string; - msFlowInto: string; - msTransformStyle: string; - msScrollTranslation: string; - msTransitionProperty: string; - msUserSelect: string; - msOverflowStyle: string; - msScrollSnapPointsY: string; - animationDirection: string; - animationDuration: string; - msFlex: string; - msTransitionTimingFunction: string; - animationName: string; - columnRule: string; - msGridColumnSpan: any; - msFlexNegative: string; - columnFill: string; - msGridRow: any; - msFlexOrder: string; - msFlexItemAlign: string; - msFlexPositive: string; - msContentZoomLimitMax: any; - msScrollLimitYMax: any; - msGridColumnAlign: string; - perspectiveOrigin: string; - lightingColor: string; - columns: string; - msScrollChaining: string; - msHyphenateLimitChars: string; - msTouchSelect: string; - floodOpacity: string; - msAnimationDirection: string; - msAnimationPlayState: string; - columnSpan: string; - msContentZooming: string; - msPerspective: string; - msFlexPack: string; - msScrollSnapPointsX: string; - msContentZoomSnapPoints: string; - msGridRowSpan: any; - msContentZoomSnap: string; - msScrollLimitXMin: any; - breakInside: string; - msHighContrastAdjust: string; - msFlexLinePack: string; - msGridRows: string; - transitionDuration: string; - msHyphens: string; - breakAfter: string; - msTransition: string; - msPerspectiveOrigin: string; - msContentZoomLimit: string; - msScrollLimitXMax: any; - msFlexAlign: string; - msWrapMargin: any; - columnCount: any; - msAnimationTimingFunction: string; - msTransitionDelay: string; - transformStyle: string; - msWrapFlow: string; - msFlexPreferredSize: string; -} - -interface MessageChannel { - port2: MessagePort; - port1: MessagePort; -} -declare var MessageChannel: { - prototype: MessageChannel; - new (): MessageChannel; -} - -interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} - -interface Navigator extends MSFileSaver { - msMaxTouchPoints: number; - msPointerEnabled: boolean; - msManipulationViewsEnabled: boolean; - msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; -} - -interface TransitionEvent extends Event { - propertyName: string; - elapsedTime: number; - initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; -} - -interface MediaQueryList { - matches: boolean; - media: string; - addListener(listener: MediaQueryListListener): void; - removeListener(listener: MediaQueryListListener): void; -} - -interface DOMError { - name: string; - toString(): string; -} - -interface CloseEvent extends Event { - wasClean: boolean; - reason: string; - code: number; - initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; -} - -interface WebSocket extends EventTarget { - protocol: string; - readyState: number; - bufferedAmount: number; - onopen: (ev: Event) => any; - extensions: string; - onmessage: (ev: any) => any; - onclose: (ev: CloseEvent) => any; - onerror: (ev: ErrorEvent) => any; - binaryType: string; - url: string; - close(code?: number, reason?: string): void; - send(data: any): void; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; -} -declare var WebSocket: { - prototype: WebSocket; - new (url: string): WebSocket; - new (url: string, prototcol: string): WebSocket; - new (url: string, prototcol: string[]): WebSocket; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; -} - -interface SVGFEPointLightElement extends SVGElement { - y: SVGAnimatedNumber; - x: SVGAnimatedNumber; - z: SVGAnimatedNumber; -} - -interface ProgressEvent extends Event { - loaded: number; - lengthComputable: boolean; - total: number; - initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; -} - -interface IDBObjectStore { - indexNames: DOMStringList; - name: string; - transaction: IDBTransaction; - keyPath: string; - count(key?: any): IDBRequest; - add(value: any, key?: any): IDBRequest; - clear(): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; - put(value: any, key?: any): IDBRequest; - openCursor(range?: any, direction?: string): IDBRequest; - deleteIndex(indexName: string): void; - index(name: string): IDBIndex; - get(key: any): IDBRequest; - delete(key: any): IDBRequest; -} - -interface HTMLCanvasElement { - /** - * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. - */ - msToBlob(): Blob; -} - -interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - stdDeviationX: SVGAnimatedNumber; - in1: SVGAnimatedString; - stdDeviationY: SVGAnimatedNumber; - setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - result: SVGAnimatedString; -} - -interface Element { - msRegionOverflow: string; - onmspointerdown: (ev: any) => any; - onmsgotpointercapture: (ev: any) => any; - onmsgesturedoubletap: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - onmsinertiastart: (ev: any) => any; - onmslostpointercapture: (ev: any) => any; - onmspointerover: (ev: any) => any; - msContentZoomFactor: number; - onmspointerup: (ev: any) => any; - msGetRegionContent(): MSRangeCollection; - msReleasePointerCapture(pointerId: number): void; - msSetPointerCapture(pointerId: number): void; -} - -interface IDBVersionChangeEvent extends Event { - newVersion: number; - oldVersion: number; -} - -interface IDBIndex { - unique: boolean; - name: string; - keyPath: string; - objectStore: IDBObjectStore; - count(key?: any): IDBRequest; - getKey(key: any): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - get(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; -} - -interface WheelEvent { - getCurrentPoint(element: Element): void; -} - -interface FileList { - length: number; - item(index: number): File; - [index: number]: File; -} - -interface IDBCursor { - source: any; - direction: string; - key: any; - primaryKey: any; - advance(count: number): void; - delete(): IDBRequest; - continue(key?: any): void; - update(value: any): IDBRequest; -} - -interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - specularConstant: SVGAnimatedNumber; -} - -interface File extends Blob { - lastModifiedDate: any; - name: string; -} - -interface URL { - revokeObjectURL(url: string): void; - createObjectURL(object: any, options?: ObjectURLOptions): string; -} -declare var URL: URL; - -interface RangeException { - name: string; -} - -interface IDBCursorWithValue extends IDBCursor { - value: any; -} - -interface HTMLTextAreaElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface XMLHttpRequestEventTarget extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: any) => any; - ontimeout: (ev: any) => any; - onabort: (ev: any) => any; - onloadstart: (ev: any) => any; - onloadend: (ev: ProgressEvent) => any; -} - -interface IDBEnvironment { - msIndexedDB: IDBFactory; - indexedDB: IDBFactory; -} - -interface AudioTrackList extends EventTarget { - length: number; - onchange: (ev: any) => any; - onaddtrack: (ev: TrackEvent) => any; - getTrackById(id: string): AudioTrack; - item(index: number): AudioTrack; - [index: number]: AudioTrack; -} - -interface MSBaseReader extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - readyState: number; - onabort: (ev: any) => any; - onloadend: (ev: ProgressEvent) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: any) => any; - onloadstart: (ev: any) => any; - result: any; - abort(): void; - LOADING: number; - EMPTY: number; - DONE: number; -} - -interface History { - state: any; - replaceState(statedata: any, title: string, url?: string): void; - pushState(statedata: any, title: string, url?: string): void; -} - -interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - radiusX: SVGAnimatedNumber; - radiusY: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} -declare var SVGFEMorphologyElement: { - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} - -interface HTMLSelectElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface CSSRule { - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - VIEWPORT_RULE: number; -} -//declare var CSSRule: { -// KEYFRAMES_RULE: number; -// KEYFRAME_RULE: number; -// VIEWPORT_RULE: number; -//} - -interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { -} - -interface WindowTimersExtension { - msSetImmediate(expression: any, ...args: any[]): number; - clearImmediate(handle: number): void; - msClearImmediate(handle: number): void; - setImmediate(expression: any, ...args: any[]): number; -} - -interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - xChannelSelector: SVGAnimatedEnumeration; - yChannelSelector: SVGAnimatedEnumeration; - scale: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} -declare var SVGFEDisplacementMapElement: { - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} - -interface AnimationEvent extends Event { - animationName: string; - elapsedTime: number; - initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; -} - -interface SVGComponentTransferFunctionElement extends SVGElement { - tableValues: SVGAnimatedNumberList; - slope: SVGAnimatedNumber; - type: SVGAnimatedEnumeration; - exponent: SVGAnimatedNumber; - amplitude: SVGAnimatedNumber; - intercept: SVGAnimatedNumber; - offset: SVGAnimatedNumber; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} -declare var SVGComponentTransferFunctionElement: { - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} - -interface MSRangeCollection { - length: number; - item(index: number): Range; - [index: number]: Range; -} - -interface SVGFEDistantLightElement extends SVGElement { - azimuth: SVGAnimatedNumber; - elevation: SVGAnimatedNumber; -} - -interface SVGException { - name: string; -} - -interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { -} - -interface IDBKeyRange { - upper: any; - upperOpen: boolean; - lower: any; - lowerOpen: boolean; - bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - only(value: any): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; -} - -interface WindowConsole { - console: Console; -} - -interface IDBTransaction extends EventTarget { - oncomplete: (ev: Event) => any; - db: IDBDatabase; - mode: string; - error: DOMError; - onerror: (ev: ErrorEvent) => any; - onabort: (ev: any) => any; - abort(): void; - objectStore(name: string): IDBObjectStore; -} - -interface AudioTrack { - kind: string; - language: string; - id: string; - label: string; - enabled: boolean; -} - -interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - orderY: SVGAnimatedInteger; - kernelUnitLengthY: SVGAnimatedNumber; - orderX: SVGAnimatedInteger; - preserveAlpha: SVGAnimatedBoolean; - kernelMatrix: SVGAnimatedNumberList; - edgeMode: SVGAnimatedEnumeration; - kernelUnitLengthX: SVGAnimatedNumber; - bias: SVGAnimatedNumber; - targetX: SVGAnimatedInteger; - targetY: SVGAnimatedInteger; - divisor: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} -declare var SVGFEConvolveMatrixElement: { - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} - -interface TextTrackCueList { - length: number; - item(index: number): TextTrackCue; - [index: number]: TextTrackCue; - getCueById(id: string): TextTrackCue; -} - -interface CSSKeyframesRule extends CSSRule { - name: string; - cssRules: CSSRuleList; - findRule(rule: string): CSSKeyframeRule; - deleteRule(rule: string): void; - appendRule(rule: string): void; -} - -interface Window extends WindowBase64, IDBEnvironment, WindowConsole { - onmspointerdown: (ev: any) => any; - animationStartTime: number; - onmsgesturedoubletap: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - msAnimationStartTime: number; - applicationCache: ApplicationCache; - onmsinertiastart: (ev: any) => any; - onmspointerover: (ev: any) => any; - onpopstate: (ev: PopStateEvent) => any; - onmspointerup: (ev: any) => any; - msCancelRequestAnimationFrame(handle: number): void; - matchMedia(mediaQuery: string): MediaQueryList; - cancelAnimationFrame(handle: number): void; - msIsStaticHTML(html: string): boolean; - msMatchMedia(mediaQuery: string): MediaQueryList; - requestAnimationFrame(callback: FrameRequestCallback): number; - msRequestAnimationFrame(callback: FrameRequestCallback): number; -} - -interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - baseFrequencyX: SVGAnimatedNumber; - numOctaves: SVGAnimatedInteger; - type: SVGAnimatedEnumeration; - baseFrequencyY: SVGAnimatedNumber; - stitchTiles: SVGAnimatedEnumeration; - seed: SVGAnimatedNumber; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} -declare var SVGFETurbulenceElement: { - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} - -interface TextTrackList { - length: number; - item(index: number): TextTrack; - [index: number]: TextTrack; -} - -interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { -} - -interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - type: SVGAnimatedEnumeration; - values: SVGAnimatedNumberList; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} -declare var SVGFEColorMatrixElement: { - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} - -interface Console { - info(message?: any, ...optionalParams: any[]): void; - profile(reportName?: string): void; - assert(test?: boolean, message?: string, ...optionalParams: any[]): void; - msIsIndependentlyComposed(element: Element): boolean; - clear(): void; - dir(value?: any, ...optionalParams: any[]): void; - warn(message?: any, ...optionalParams: any[]): void; - error(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - profileEnd(): void; -} - -interface SVGFESpotLightElement extends SVGElement { - pointsAtY: SVGAnimatedNumber; - y: SVGAnimatedNumber; - limitingConeAngle: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - x: SVGAnimatedNumber; - pointsAtZ: SVGAnimatedNumber; - z: SVGAnimatedNumber; - pointsAtX: SVGAnimatedNumber; -} - -interface HTMLImageElement { - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; -} - -interface WindowBase64 { - btoa(rawString: string): string; - atob(encodedString: string): string; -} - -interface IDBDatabase extends EventTarget { - version: string; - name: string; - objectStoreNames: DOMStringList; - onerror: (ev: ErrorEvent) => any; - onabort: (ev: any) => any; - createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; - close(): void; - transaction(storeNames: any, mode?: string): IDBTransaction; - deleteObjectStore(name: string): void; -} - -interface DOMStringList { - length: number; - contains(str: string): boolean; - item(index: number): string; - [index: number]: string; -} - -interface HTMLButtonElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface IDBOpenDBRequest extends IDBRequest { - onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - onblocked: (ev: Event) => any; -} - -interface HTMLProgressElement extends HTMLElement { - /** - * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. - */ - value: number; - /** - * Defines the maximum, or "done" value for a progress element. - */ - max: number; - /** - * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). - */ - position: number; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} - -interface MSLaunchUriCallback { - (): void; -} - -interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - dy: SVGAnimatedNumber; - in1: SVGAnimatedString; - dx: SVGAnimatedNumber; -} - -interface HTMLFormElement { - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Designates a form that is not validated when submitted. - */ - noValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; -} - -interface MSUnsafeFunctionCallback { - (): any; -} - -interface Document { - onmspointerdown: (ev: any) => any; - msHidden: boolean; - msVisibilityState: string; - onmsgesturedoubletap: (ev: any) => any; - visibilityState: string; - onmsmanipulationstatechanged: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmscontentzoom: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - onmsinertiastart: (ev: any) => any; - msCSSOMElementFloatMetrics: boolean; - onmspointerover: (ev: any) => any; - hidden: boolean; - onmspointerup: (ev: any) => any; - msElementsFromPoint(x: number, y: number): NodeList; - msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - clear(): void; -} - -interface MessageEvent extends Event { - ports: any; -} - -interface HTMLScriptElement { - async: boolean; -} - -interface HTMLMediaElement { - /** - * Specifies the purpose of the audio or video media, such as background audio or alerts. - */ - msAudioCategory: string; - /** - * Specifies whether or not to enable low-latency playback on the media element. - */ - msRealTime: boolean; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - textTracks: TextTrackList; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Returns an AudioTrackList object with the audio tracks for a given video element. - */ - audioTracks: AudioTrackList; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; - /** - * Specifies the output device id that the audio will be sent to. - */ - msAudioDeviceType: string; - /** - * Clears all effects from the media pipeline. - */ - msClearEffects(): void; - /** - * Specifies the media protection manager for a given media pipeline. - */ - msSetMediaProtectionManager(mediaProtectionManager?: any): void; - /** - * Inserts the specified audio effect into media pipeline. - */ - msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; -} - -interface TextTrack extends EventTarget { - language: string; - mode: any; - readyState: number; - activeCues: TextTrackCueList; - cues: TextTrackCueList; - oncuechange: (ev: Event) => any; - kind: string; - onload: (ev: any) => any; - onerror: (ev: ErrorEvent) => any; - label: string; - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} -declare var TextTrack: { - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} - -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} - -interface IDBRequest extends EventTarget { - source: any; - onsuccess: (ev: Event) => any; - error: DOMError; - transaction: IDBTransaction; - onerror: (ev: ErrorEvent) => any; - readyState: string; - result: any; -} - -interface MessagePort extends EventTarget { - onmessage: (ev: any) => any; - close(): void; - postMessage(message?: any, ports?: any): void; - start(): void; -} - -interface FileReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; -} -declare var FileReader: { - prototype: FileReader; - new (): FileReader; -} - -interface BlobPropertyBag { - type?: string; - endings?: string; -} - -interface Blob { - type: string; - size: number; - msDetachStream(): any; - slice(start?: number, end?: number, contentType?: string): Blob; - msClose(): void; -} -declare var Blob: { - prototype: Blob; - new (blobParts?: any[], options?: BlobPropertyBag): Blob; -} - -interface ApplicationCache extends EventTarget { - status: number; - ondownloading: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - onupdateready: (ev: Event) => any; - oncached: (ev: Event) => any; - onobsolete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onchecking: (ev: Event) => any; - onnoupdate: (ev: Event) => any; - swapCache(): void; - abort(): void; - update(): void; - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} -declare var ApplicationCache: { - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} - -interface FrameRequestCallback { - (time: number): void; -} - -interface XMLHttpRequest { - response: any; - withCredentials: boolean; - onprogress: (ev: ProgressEvent) => any; - onabort: (ev: any) => any; - responseType: string; - onloadend: (ev: ProgressEvent) => any; - upload: XMLHttpRequestEventTarget; - onerror: (ev: ErrorEvent) => any; - onloadstart: (ev: any) => any; -} - -interface PopStateEvent extends Event { - state: any; - initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; -} - -interface CSSKeyframeRule extends CSSRule { - keyText: string; - style: CSSStyleDeclaration; -} - -interface MSFileSaver { - msSaveBlob(blob: any, defaultName?: string): boolean; - msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; -} - -interface MSStream { - type: string; - msDetachStream(): any; - msClose(): void; -} - -interface MediaError { - msExtendedCode: number; -} - -interface HTMLFieldSetElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new (): MSBlobBuilder; -} - -interface HTMLElement { - onmscontentzoom: (ev: any) => any; - oncuechange: (ev: Event) => any; - spellcheck: boolean; - classList: DOMTokenList; - onmsmanipulationstatechanged: (ev: any) => any; - draggable: boolean; -} - -interface DataTransfer { - types: DOMStringList; - files: FileList; -} - -interface DOMSettableTokenList extends DOMTokenList { - value: string; -} - -interface IDBFactory { - open(name: string, version?: number): IDBOpenDBRequest; - cmp(first: any, second: any): number; - deleteDatabase(name: string): IDBOpenDBRequest; -} - -interface Range { - createContextualFragment(fragment: string): DocumentFragment; -} - -interface HTMLObjectElement { - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} - -interface MSPointerEvent 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; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} -declare var MSPointerEvent: { - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} - -interface DOMException { - name: string; - INVALID_NODE_TYPE_ERR: number; - DATA_CLONE_ERR: number; - TIMEOUT_ERR: number; -} -//declare var DOMException: { -// INVALID_NODE_TYPE_ERR: number; -// DATA_CLONE_ERR: number; -// TIMEOUT_ERR: number; -//} - -interface MSManipulationEvent extends UIEvent { - lastState: number; - currentState: number; - initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; -} -declare var MSManipulationEvent: { - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; -} - -interface FormData { - append(name: any, value: any, blobName?: string): void; -} -declare var FormData: { - prototype: FormData; - new (form?: HTMLFormElement): FormData; -} - -interface HTMLDataListElement extends HTMLElement { - options: HTMLCollection; -} - -interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} - -interface AbstractWorker extends EventTarget { - onerror: (ev: ErrorEvent) => any; -} - -interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - in2: SVGAnimatedString; - k2: SVGAnimatedNumber; - k1: SVGAnimatedNumber; - k3: SVGAnimatedNumber; - in1: SVGAnimatedString; - k4: SVGAnimatedNumber; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} -declare var SVGFECompositeElement: { - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} - -interface ValidityState { - customError: boolean; - valueMissing: boolean; - stepMismatch: boolean; - rangeUnderflow: boolean; - rangeOverflow: boolean; - typeMismatch: boolean; - patternMismatch: boolean; - tooLong: boolean; - valid: boolean; -} - -interface HTMLTrackElement extends HTMLElement { - kind: string; - src: string; - srclang: string; - track: TextTrack; - label: string; - default: boolean; -} - -interface MSApp { - createFileFromStorageFile(storageFile: any): File; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - terminateApp(exceptionObject: any): void; - createDataPackage(object: any): any; - execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; - getHtmlPrintDocumentSource(htmlDoc: any): any; - addPublicLocalApplicationUri(uri: string): void; - createDataPackageFromSelection(): any; -} -declare var MSApp: MSApp; - -interface HTMLVideoElement { - msIsStereo3D: boolean; - msStereo3DPackingMode: string; - onMSVideoOptimalLayoutChanged: (ev: any) => any; - onMSVideoFrameStepCompleted: (ev: any) => any; - msStereo3DRenderMode: string; - msIsLayoutOptimalForPlayback: boolean; - msHorizontalMirror: boolean; - onMSVideoFormatChanged: (ev: any) => any; - msZoom: boolean; - msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; - msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; - msFrameStep(forward: boolean): void; -} - -interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} - -interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - diffuseConstant: SVGAnimatedNumber; -} - -interface MSCSSMatrix { - m24: number; - m34: number; - a: number; - d: number; - m32: number; - m41: number; - m11: number; - f: number; - e: number; - m23: number; - m14: number; - m33: number; - m22: number; - m21: number; - c: number; - m12: number; - b: number; - m42: number; - m31: number; - m43: number; - m13: number; - m44: number; - multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; - skewY(angle: number): MSCSSMatrix; - setMatrixValue(value: string): void; - inverse(): MSCSSMatrix; - rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; - toString(): string; - rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; - translate(x: number, y: number, z?: number): MSCSSMatrix; - scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; - skewX(angle: number): MSCSSMatrix; -} -declare var MSCSSMatrix: { - prototype: MSCSSMatrix; - new (text?: string): MSCSSMatrix; -} - -interface Worker extends AbstractWorker { - onmessage: (ev: any) => any; - postMessage(message: any, ports?: any): void; - terminate(): void; -} -declare var Worker: { - prototype: Worker; - new (stringUrl: string): Worker; -} - -interface HTMLIFrameElement { - sandbox: DOMSettableTokenList; -} - -declare var onmspointerdown: (ev: any) => any; -declare var animationStartTime: number; -declare var onmsgesturedoubletap: (ev: any) => any; -declare var onmspointerhover: (ev: any) => any; -declare var onmsgesturehold: (ev: any) => any; -declare var onmspointermove: (ev: any) => any; -declare var onmsgesturechange: (ev: any) => any; -declare var onmsgesturestart: (ev: any) => any; -declare var onmspointercancel: (ev: any) => any; -declare var onmsgestureend: (ev: any) => any; -declare var onmsgesturetap: (ev: any) => any; -declare var onmspointerout: (ev: any) => any; -declare var msAnimationStartTime: number; -declare var applicationCache: ApplicationCache; -declare var onmsinertiastart: (ev: any) => any; -declare var onmspointerover: (ev: any) => any; -declare var onpopstate: (ev: PopStateEvent) => any; -declare var onmspointerup: (ev: any) => any; -declare function msCancelRequestAnimationFrame(handle: number): void; -declare function matchMedia(mediaQuery: string): MediaQueryList; -declare function cancelAnimationFrame(handle: number): void; -declare function msIsStaticHTML(html: string): boolean; -declare function msMatchMedia(mediaQuery: string): MediaQueryList; -declare function requestAnimationFrame(callback: FrameRequestCallback): number; -declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; -declare function btoa(rawString: string): string; -declare function atob(encodedString: string): string; -declare var msIndexedDB: IDBFactory; -declare var indexedDB: IDBFactory; -declare var console: Console; - - -///////////////////////////// -/// IE11 DOM APIs -///////////////////////////// - - -interface StoreExceptionsInformation extends ExceptionInformation { - siteName?: string; - explanationString?: string; - detailURI?: string; -} - -interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { - arrayOfDomainStrings?: Array; -} - -interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { - arrayOfDomainStrings?: Array; -} - -interface AlgorithmParameters { -} - -interface MutationObserverInit { - childList?: boolean; - attributes?: boolean; - characterData?: boolean; - subtree?: boolean; - attributeOldValue?: boolean; - characterDataOldValue?: boolean; - attributeFilter?: Array; -} - -interface ExceptionInformation { - domain?: string; -} - -interface MsZoomToOptions { - contentX?: number; - contentY?: number; - viewportX?: string; - viewportY?: string; - scaleFactor?: number; - animate?: string; -} - -interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; -} - -interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; -} - -interface Algorithm { - name?: string; - params?: AlgorithmParameters; -} - -interface NavigatorID { - product: string; - vendor: string; -} - -interface HTMLBodyElement { - onpageshow: (ev: PageTransitionEvent) => any; - onpagehide: (ev: PageTransitionEvent) => any; -} - -interface MSExecAtPriorityFunctionCallback { - (...args: any[]): any; -} - -interface MSWindowExtensions { - captureEvents(): void; - releaseEvents(): void; -} - -interface MSGraphicsTrust { - status: string; - constrictionActive: boolean; -} - -interface AudioTrack { - sourceBuffer: SourceBuffer; -} - -interface DragEvent { - msConvertURL(file: File, targetType: string, targetURL?: string): void; -} - -interface SubtleCrypto { - unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; - encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; - importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; - verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; - deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; - exportKey(format: string, key: Key): KeyOperation; - generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; - decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; -} - -interface Crypto extends RandomSource { - subtle: SubtleCrypto; -} - -interface VideoPlaybackQuality { - totalFrameDelay: number; - creationTime: number; - totalVideoFrames: number; - droppedVideoFrames: number; -} - -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 extends GlobalEventHandlers { - onpageshow: (ev: PageTransitionEvent) => any; - ondevicemotion: (ev: DeviceMotionEvent) => any; - devicePixelRatio: number; - msCrypto: Crypto; - ondeviceorientation: (ev: DeviceOrientationEvent) => any; - doNotTrack: string; - onmspointerenter: (ev: any) => any; - onpagehide: (ev: PageTransitionEvent) => any; - onmspointerleave: (ev: any) => any; -} - -interface Key { - algorithm: Algorithm; - type: string; - extractable: boolean; - keyUsage: string[]; -} - -interface TextTrackList extends EventTarget { - onaddtrack: (ev: any) => any; -} - -interface DeviceAcceleration { - y: number; - x: number; - z: number; -} - -interface Console { - count(countTitle?: string): void; - groupEnd(): void; - time(timerName?: string): void; - timeEnd(timerName?: string): void; - trace(): void; - group(groupTitle?: string): void; - dirxml(value: any): void; - debug(message?: string, ...optionalParams: any[]): void; - groupCollapsed(groupTitle?: string): void; - select(element: Element): void; -} - -interface MSNavigatorDoNotTrack { - removeSiteSpecificTrackingException(args: ExceptionInformation): void; - removeWebWideTrackingException(args: ExceptionInformation): void; - storeWebWideTrackingException(args: StoreExceptionsInformation): void; - storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; - confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; - confirmWebWideTrackingException(args: ExceptionInformation): boolean; -} - -interface HTMLImageElement { - crossOrigin: string; - msPlayToPreferredSourceUri: string; -} - -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; - //[name: string]: Element; -} - -interface MSNavigatorExtensions { - language: string; -} - -interface AesGcmEncryptResult { - ciphertext: ArrayBuffer; - tag: ArrayBuffer; -} - -interface HTMLSourceElement { - msKeySystem: string; -} - -interface CSSStyleDeclaration { - alignItems: string; - borderImageSource: string; - flexBasis: string; - borderImageWidth: string; - borderImageRepeat: string; - order: string; - flex: string; - alignContent: string; - msImeAlign: string; - flexShrink: string; - flexGrow: string; - borderImageSlice: string; - flexWrap: string; - borderImageOutset: string; - flexDirection: string; - touchAction: string; - flexFlow: string; - borderImage: string; - justifyContent: string; - alignSelf: string; - msTextCombineHorizontal: string; -} - -interface NavigationCompletedEvent extends NavigationEvent { - webErrorStatus: number; - isSuccess: boolean; -} - -interface MutationRecord { - oldValue: string; - previousSibling: Node; - addedNodes: NodeList; - attributeName: string; - removedNodes: NodeList; - target: Node; - nextSibling: Node; - attributeNamespace: string; - type: string; -} - -interface Navigator { - pointerEnabled: boolean; - maxTouchPoints: number; -} - -interface Document extends MSDocumentExtensions, GlobalEventHandlers { - msFullscreenEnabled: boolean; - onmsfullscreenerror: (ev: any) => any; - onmspointerenter: (ev: any) => any; - msFullscreenElement: Element; - onmsfullscreenchange: (ev: any) => any; - onmspointerleave: (ev: any) => any; - msExitFullscreen(): void; -} - -interface MimeTypeArray { - length: number; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(type: string): Plugin; - //[type: string]: Plugin; -} - -interface HTMLMediaElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; - /** - * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. - */ - msKeys: MSMediaKeys; - msGraphicsTrustStatus: MSGraphicsTrust; - msSetMediaKeys(mediaKeys: MSMediaKeys): void; - addTextTrack(kind: string, label?: string, language?: string): TextTrack; -} - -interface TextTrack { - addCue(cue: TextTrackCue): void; - removeCue(cue: TextTrackCue): void; -} - -interface KeyOperation extends EventTarget { - oncomplete: (ev: any) => any; - onerror: (ev: any) => any; - result: any; -} - -interface DOMStringMap { -} - -interface DeviceOrientationEvent extends Event { - gamma: number; - alpha: number; - absolute: boolean; - beta: number; - initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; -} - -interface MSMediaKeys { - keySystem: string; - createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; - isTypeSupported(keySystem: string, type?: string): boolean; -} -declare var MSMediaKeys: { - prototype: MSMediaKeys; - new (): MSMediaKeys; -} - -interface MSMediaKeyMessageEvent extends Event { - destinationURL: string; - message: Uint8Array; -} - -interface MSHTMLWebViewElement extends HTMLElement { - documentTitle: string; - width: number; - src: string; - canGoForward: boolean; - height: number; - canGoBack: boolean; - navigateWithHttpRequestMessage(requestMessage: any): void; - goBack(): void; - navigate(uri: string): void; - stop(): void; - navigateToString(contents: string): void; - captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; - capturePreviewToBlobAsync(): MSWebViewAsyncOperation; - refresh(): void; - goForward(): void; - navigateToLocalStreamUri(source: string, streamResolver: any): void; - invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; - buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; -} - -interface NavigationEvent extends Event { - uri: string; -} - -interface Element extends GlobalEventHandlers { - onlostpointercapture: (ev: PointerEvent) => any; - onmspointerenter: (ev: any) => any; - ongotpointercapture: (ev: PointerEvent) => any; - onmspointerleave: (ev: any) => any; - msZoomTo(args: MsZoomToOptions): void; - setPointerCapture(pointerId: number): void; - msGetUntransformedBounds(): ClientRect; - releasePointerCapture(pointerId: number): void; - msRequestFullscreen(): void; -} - -interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; -} - -interface XMLHttpRequest { - msCaching: string; - msCachingEnabled(): boolean; - overrideMimeType(mime: string): void; -} - -interface SourceBuffer extends EventTarget { - updating: boolean; - appendWindowStart: number; - appendWindowEnd: number; - buffered: TimeRanges; - timestampOffset: number; - audioTracks: AudioTrackList; - appendBuffer(data: ArrayBuffer): void; - remove(start: number, end: number): void; - abort(): void; - appendStream(stream: MSStream, maxSize?: number): void; -} - -interface MSInputMethodContext extends EventTarget { - oncandidatewindowshow: (ev: any) => any; - target: HTMLElement; - compositionStartOffset: number; - oncandidatewindowhide: (ev: any) => any; - oncandidatewindowupdate: (ev: any) => any; - compositionEndOffset: number; - getCompositionAlternatives(): string[]; - getCandidateWindowClientRect(): ClientRect; - hasComposition(): boolean; - isCandidateWindowVisible(): boolean; -} - -interface DeviceRotationRate { - gamma: number; - alpha: number; - beta: number; -} - -interface PluginArray { - length: number; - refresh(reload?: boolean): void; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(name: string): Plugin; - //[name: string]: Plugin; -} - -interface MSMediaKeyError { - systemCode: number; - code: number; - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - MS_MEDIA_KEYERR_CLIENT: number; -} -declare var MSMediaKeyError: { - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - MS_MEDIA_KEYERR_CLIENT: number; -} - -interface Plugin { - length: number; - filename: string; - version: string; - name: string; - description: string; - item(index: number): MimeType; - [index: number]: MimeType; - namedItem(type: string): MimeType; - //[type: string]: MimeType; -} - -interface HTMLFrameSetElement { - onpageshow: (ev: PageTransitionEvent) => any; - onpagehide: (ev: PageTransitionEvent) => any; -} - -interface Screen extends EventTarget { - msOrientation: string; - onmsorientationchange: (ev: any) => any; - msLockOrientation(orientations: string[]): boolean; - msUnlockOrientation(): void; -} - -interface MediaSource extends EventTarget { - sourceBuffers: SourceBufferList; - duration: number; - readyState: string; - activeSourceBuffers: SourceBufferList; - addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; - isTypeSupported(type: string): boolean; - removeSourceBuffer(sourceBuffer: SourceBuffer): void; -} -declare var MediaSource: { - prototype: MediaSource; - new (): MediaSource; -} - -interface MediaError { - MS_MEDIA_ERR_ENCRYPTED: number; -} -//declare var MediaError: { -// MS_MEDIA_ERR_ENCRYPTED: number; -//} - -interface SourceBufferList extends EventTarget { - length: number; - item(index: number): SourceBuffer; - [index: number]: SourceBuffer; -} - -interface XMLDocument extends Document { -} - -interface DeviceMotionEvent extends Event { - rotationRate: DeviceRotationRate; - acceleration: DeviceAcceleration; - interval: number; - accelerationIncludingGravity: DeviceAcceleration; - initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; -} - -interface MimeType { - enabledPlugin: Plugin; - suffixes: string; - type: string; - description: string; -} - -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 { - captureEvents(): void; - releaseEvents(): void; -} - -interface HTMLElement { - dataset: DOMStringMap; - hidden: boolean; - msGetInputContext(): MSInputMethodContext; -} - -interface MutationObserver { - observe(target: Node, options: MutationObserverInit): void; - takeRecords(): MutationRecord[]; - disconnect(): void; -} -declare var MutationObserver: { - prototype: MutationObserver; - new (): MutationObserver; -} - -interface AudioTrackList { - onremovetrack: (ev: PluginArray) => any; -} - -interface HTMLObjectElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * 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. - */ - msPlayToSource: any; -} - -interface HTMLEmbedElement { - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * 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. - */ - msPlayToSource: any; -} - -interface MSWebViewAsyncOperation extends EventTarget { - target: MSHTMLWebViewElement; - oncomplete: (ev: any) => any; - error: DOMError; - onerror: (ev: any) => any; - readyState: number; - type: number; - result: any; - start(): void; - ERROR: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; -} -declare var MSWebViewAsyncOperation: { - ERROR: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; -} - -interface ScriptNotifyEvent extends Event { - value: string; - callingUri: string; -} - -interface PerformanceNavigationTiming extends PerformanceEntry { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - redirectCount: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - type: string; -} - -interface MSMediaKeyNeededEvent extends Event { - initData: Uint8Array; -} - -interface MSManipulationEvent { - MS_MANIPULATION_STATE_SELECTING: number; - MS_MANIPULATION_STATE_COMMITTED: number; - MS_MANIPULATION_STATE_PRESELECT: number; - MS_MANIPULATION_STATE_DRAGGING: number; - MS_MANIPULATION_STATE_CANCELLED: number; -} -//declare var MSManipulationEvent: { -// MS_MANIPULATION_STATE_SELECTING: number; -// MS_MANIPULATION_STATE_COMMITTED: number; -// MS_MANIPULATION_STATE_PRESELECT: number; -// MS_MANIPULATION_STATE_DRAGGING: number; -// MS_MANIPULATION_STATE_CANCELLED: number; -//} - -interface LongRunningScriptDetectedEvent extends Event { - stopPageScriptExecution: boolean; - executionTime: number; -} - -interface MSAppView { - viewId: number; - close(): void; - postMessage(message: any, targetOrigin: string, ports?: any): void; -} - -interface PerfWidgetExternal { - maxCpuSpeed: 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; -} - -interface PageTransitionEvent extends Event { - persisted: boolean; -} - -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; -} - -interface HTMLDocument extends Document { -} - -interface KeyPair { - privateKey: Key; - publicKey: Key; -} - -interface MSApp { - getViewOpener(): MSAppView; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - createNewView(uri: string): MSAppView; - getCurrentPriority(): string; - NORMAL: string; - HIGH: string; - IDLE: string; - CURRENT: string; -} -//declare var MSApp: { -// NORMAL: string; -// HIGH: string; -// IDLE: string; -// CURRENT: string; -//} - -interface MSMediaKeySession extends EventTarget { - sessionId: string; - error: MSMediaKeyError; - keySystem: string; - close(): void; - update(key: Uint8Array): void; -} - -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 { - getVideoPlaybackQuality(): VideoPlaybackQuality; -} - -interface UnviewableContentIdentifiedEvent extends NavigationEvent { - referrer: string; -} - -interface CryptoOperation extends EventTarget { - algorithm: Algorithm; - oncomplete: (ev: any) => any; - onerror: (ev: any) => any; - onprogress: (ev: any) => any; - onabort: (ev: any) => any; - key: Key; - result: any; - abort(): void; - finish(): void; - process(buffer: ArrayBufferView): void; -} - -declare var onpageshow: (ev: PageTransitionEvent) => any; -declare var ondevicemotion: (ev: DeviceMotionEvent) => any; -declare var devicePixelRatio: number; -declare var msCrypto: Crypto; -declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; -declare var doNotTrack: string; -declare var onmspointerenter: (ev: any) => any; -declare var onpagehide: (ev: PageTransitionEvent) => any; -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; - - -///////////////////////////// -/// WorkerGlobalScope APIs -///////////////////////////// -// TODO: These are only available in a Web Worker - should be in a separate lib file -declare function importScripts(...urls: string[]): void; - - -///////////////////////////// -/// Windows Script Host APIS -///////////////////////////// -declare var ActiveXObject: { new (s: string): any; }; - -interface ITextWriter { - Write(s: string): void; - WriteLine(s: string): void; - Close(): void; -} - -declare var WScript: { - Echo(s: any): void; - StdErr: ITextWriter; - StdOut: ITextWriter; - Arguments: { length: number; Item(n: number): string; }; - ScriptFullName: string; - Quit(exitCode?: number): number; -} diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/tsc b/_infrastructure/tests/typescript/0.9.7-66c2df/tsc deleted file mode 100644 index 3c0dab574f..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-66c2df/tsc +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -require('./tsc.js') diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/tsc.js b/_infrastructure/tests/typescript/0.9.7-66c2df/tsc.js deleted file mode 100644 index 01bea509c4..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-66c2df/tsc.js +++ /dev/null @@ -1,62790 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - TypeScript.DiagnosticCode = { - error_TS_0_1: "error TS{0}: {1}", - warning_TS_0_1: "warning TS{0}: {1}", - Unrecognized_escape_sequence: "Unrecognized escape sequence.", - Unexpected_character_0: "Unexpected character {0}.", - Missing_close_quote_character: "Missing close quote character.", - Identifier_expected: "Identifier expected.", - _0_keyword_expected: "'{0}' keyword expected.", - _0_expected: "'{0}' expected.", - Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", - Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", - Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", - Trailing_separator_not_allowed: "Trailing separator not allowed.", - AsteriskSlash_expected: "'*/' expected.", - public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", - Unexpected_token: "Unexpected token.", - Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", - Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", - Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", - Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", - Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", - Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", - Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", - Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", - Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", - Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", - Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", - extends_clause_already_seen: "'extends' clause already seen.", - extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", - Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", - implements_clause_already_seen: "'implements' clause already seen.", - Accessibility_modifier_already_seen: "Accessibility modifier already seen.", - _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", - _0_modifier_already_seen: "'{0}' modifier already seen.", - _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", - Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", - super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", - Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", - Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", - 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_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}'.", - _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", - declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", - declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", - Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", - Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", - set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", - set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", - set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", - set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", - get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", - Modifiers_cannot_appear_here: "Modifiers cannot appear here.", - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", - Class_name_cannot_be_0: "Class name cannot be '{0}'.", - Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", - Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", - Module_name_cannot_be_0: "Module name cannot be '{0}'.", - Enum_member_must_have_initializer: "Enum member must have initializer.", - Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", - Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", - Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", - Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", - module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", - constructor_function_accessor_or_variable: "constructor, function, accessor or variable", - statement: "statement", - case_or_default_clause: "case or default clause", - identifier: "identifier", - call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", - expression: "expression", - type_name: "type name", - property_or_accessor: "property or accessor", - parameter: "parameter", - type: "type", - type_parameter: "type parameter", - 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_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.", - super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", - Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", - Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", - Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", - Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", - Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", - Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", - Getter_0_already_declared: "Getter '{0}' already declared.", - Setter_0_already_declared: "Setter '{0}' already declared.", - Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", - Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", - Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", - Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", - Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", - Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", - Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", - Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", - Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", - Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", - Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", - Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", - Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", - Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", - Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", - Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", - Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", - Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", - Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", - Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", - Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", - Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", - A_class_may_only_extend_another_class: "A class may only extend another class.", - A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", - An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", - Unable_to_resolve_type: "Unable to resolve type.", - Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", - Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", - Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", - Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", - Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", - Invalid_new_expression: "Invalid 'new' expression.", - Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", - Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", - Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", - Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", - Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", - Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", - The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", - 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_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_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.", - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", - Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", - 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_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}'.", - 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.", - Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", - Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", - Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", - All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", - Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", - this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", - Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", - Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", - Duplicate_overload_call_signature: "Duplicate overload call signature.", - Duplicate_overload_construct_signature: "Duplicate overload construct signature.", - Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", - Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", - Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", - 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_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.", - Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", - A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", - Rest_parameters_must_be_array_types: "Rest parameters must be array types.", - Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", - 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_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_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.", - Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", - Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", - Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", - 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_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}", - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", - Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", - All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", - super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", - Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", - Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", - Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", - Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", - Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", - continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", - break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", - Jump_target_not_found: "Jump target not found.", - Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", - TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", - TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", - TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", - TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", - TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", - TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", - 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}", - Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", - Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", - Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", - Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", - Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", - Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - 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.", - 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_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_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.", - Could_not_find_file_0: "Could not find file: '{0}'.", - A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", - Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", - Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", - Emit_Error_0: "Emit Error: {0}.", - Cannot_read_file_0_1: "Cannot read file '{0}': {1}", - Unsupported_file_encoding: "Unsupported file encoding.", - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", - Unsupported_locale_0: "Unsupported locale: '{0}'.", - Execution_Failed_NL: "Execution Failed.{NL}", - Invalid_call_to_up: "Invalid call to 'up'", - Invalid_call_to_down: "Invalid call to 'down'", - Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", - Unknown_option_0: "Unknown option '{0}'", - Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", - Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", - Could_not_delete_file_0: "Could not delete file '{0}'", - Could_not_create_directory_0: "Could not create directory '{0}'", - Error_while_executing_file_0: "Error while executing file '{0}': ", - Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", - Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", - Option_0_specified_without_1: "Option '{0}' specified without '{1}'", - codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", - Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", - Generates_corresponding_0_file: "Generates corresponding {0} file.", - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", - Watch_input_files: "Watch input files.", - Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", - Do_not_emit_comments_to_output: "Do not emit comments to output.", - Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", - Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", - Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", - Print_this_message: "Print this message.", - Print_the_compiler_s_version_0: "Print the compiler's version: {0}", - Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", - Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", - Syntax_0: "Syntax: {0}", - options: "options", - file1: "file", - Examples: "Examples:", - Options: "Options:", - Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", - Version_0: "Version {0}", - Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", - NL_Recompiling_0: "{NL}Recompiling ({0}):", - STRING: "STRING", - KIND: "KIND", - file2: "FILE", - VERSION: "VERSION", - LOCATION: "LOCATION", - 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})", - Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", - Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", - Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", - Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", - Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", - new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", - _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", - Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", - 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.", - 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; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - return false; - } - - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0, n = array1.length; i < n; i++) { - if (!equals(array1[i], array2[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.distinct = function (array, equalsFn) { - var result = []; - - for (var i = 0, n = array.length; i < n; i++) { - var current = array[i]; - for (var j = 0; j < result.length; j++) { - if (equalsFn(result[j], current)) { - break; - } - } - - if (j === result.length) { - result.push(current); - } - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.lastOrDefault = function (array, predicate) { - for (var i = array.length - 1; i >= 0; i--) { - var v = array[i]; - if (predicate(v, i)) { - return v; - } - } - - return null; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value, i)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.first = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (!func || func(value, i)) { - return value; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = new Array(values.length); - - for (var i = 0; i < values.length; i++) { - result[i] = func(values[i]); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = new Array(); - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - var low = 0; - var high = array.length - 1; - - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - - if (midValue === value) { - return middle; - } else if (midValue > value) { - high = middle - 1; - } else { - low = middle + 1; - } - } - - return ~low; - }; - - ArrayUtilities.createArray = function (length, defaultValue) { - var result = new Array(length); - for (var i = 0; i < length; i++) { - result[i] = defaultValue; - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - - ArrayUtilities.indexOf = function (array, predicate) { - for (var i = 0, n = array.length; i < n; i++) { - if (predicate(array[i])) { - return i; - } - } - - return -1; - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitVector) { - var pool = []; - var Constants; - (function (Constants) { - Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; - Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; - - Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; - - Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; - Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; - - Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; - Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; - Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; - })(Constants || (Constants = {})); - - var BitVectorImpl = (function () { - function BitVectorImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.bits = []; - } - BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; - }; - - BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; - }; - - BitVectorImpl.prototype.valueAt = function (index) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return undefined; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { - return true; - } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { - return false; - } else { - return undefined; - } - } else { - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return false; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { - return true; - } else { - return false; - } - } - }; - - BitVectorImpl.prototype.setValueAt = function (index, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); - - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === undefined) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - - var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); - encoded = encoded & clearMask; - - if (value === true) { - encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); - } else if (value === false) { - encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } else { - TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); - - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === false) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - - encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); - - if (value) { - encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } - }; - - BitVectorImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - this.bits.length = 0; - pool.push(this); - }; - return BitVectorImpl; - })(); - - function getBitVector(allowUndefinedValues) { - if (pool.length === 0) { - return new BitVectorImpl(allowUndefinedValues); - } - - var vector = pool.pop(); - vector.isReleased = false; - vector.allowUndefinedValues = allowUndefinedValues; - - return vector; - } - BitVector.getBitVector = getBitVector; - })(TypeScript.BitVector || (TypeScript.BitVector = {})); - var BitVector = TypeScript.BitVector; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitMatrix) { - var pool = []; - - var BitMatrixImpl = (function () { - function BitMatrixImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.vectors = []; - } - BitMatrixImpl.prototype.valueAt = function (x, y) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - return this.allowUndefinedValues ? undefined : false; - } - - return vector.valueAt(y); - }; - - BitMatrixImpl.prototype.setValueAt = function (x, y, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - if (value === undefined) { - return; - } - - vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); - this.vectors[x] = vector; - } - - vector.setValueAt(y, value); - }; - - BitMatrixImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - - for (var name in this.vectors) { - if (this.vectors.hasOwnProperty(name)) { - var vector = this.vectors[name]; - vector.release(); - } - } - - this.vectors.length = 0; - pool.push(this); - }; - return BitMatrixImpl; - })(); - - function getBitMatrix(allowUndefinedValues) { - if (pool.length === 0) { - return new BitMatrixImpl(allowUndefinedValues); - } - - var matrix = pool.pop(); - matrix.isReleased = false; - matrix.allowUndefinedValues = allowUndefinedValues; - - return matrix; - } - BitMatrix.getBitMatrix = getBitMatrix; - })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); - var BitMatrix = TypeScript.BitMatrix; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); - var AssertionLevel = TypeScript.AssertionLevel; - - var Debug = (function () { - function Debug() { - } - Debug.shouldAssert = function (level) { - return this.currentAssertionLevel >= level; - }; - - Debug.assert = function (expression, message, verboseDebugInfo) { - if (typeof message === "undefined") { message = ""; } - if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); - } - - throw new Error("Debug Failure. False expression: " + message + verboseDebugString); - } - }; - - Debug.fail = function (message) { - Debug.assert(false, message); - }; - Debug.currentAssertionLevel = 0 /* None */; - return Debug; - })(); - 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 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(); - result.length = this.length(); - - result.diagnosticCode = this._diagnosticKey; - - var _arguments = this.arguments(); - if (_arguments && _arguments.length > 0) { - result.arguments = _arguments; - } - - return result; - }; - - Diagnostic.prototype.diagnosticKey = function () { - return this._diagnosticKey; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.additionalLocations = function () { - return this._additionalLocations || []; - }; - - Diagnostic.equals = function (diagnostic1, diagnostic2) { - return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { - return v1 === v2; - }); - }; - - Diagnostic.prototype.info = function () { - return getDiagnosticInfoFromKey(this.diagnosticKey()); - }; - return Diagnostic; - })(Location); - TypeScript.Diagnostic = Diagnostic; - - function newLine() { - return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; - } - TypeScript.newLine = newLine; - - function getLargestIndex(diagnostic) { - var largest = -1; - var regex = /\{(\d+)\}/g; - - var match; - while (match = regex.exec(diagnostic)) { - var val = parseInt(match[1]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromKey(diagnosticKey) { - var result = TypeScript.diagnosticInformationMap[diagnosticKey]; - TypeScript.Debug.assert(result); - return result; - } - - function getLocalizedText(diagnosticKey, args) { - if (TypeScript.LocalizedDiagnosticMessages) { - } - - var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; - TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); - - var actualCount = args ? args.length : 0; - - var expectedCount = 1 + getLargestIndex(diagnosticKey); - - if (expectedCount !== actualCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); - } - - var valueCount = 1 + getLargestIndex(diagnosticMessageText); - if (valueCount !== expectedCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); - } - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return TypeScript.newLine(); - }); - - return diagnosticMessageText; - } - TypeScript.getLocalizedText = getLocalizedText; - - function getDiagnosticMessage(diagnosticKey, args) { - var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); - var diagnosticMessageText = getLocalizedText(diagnosticKey, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + ". " + message); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error("Invalid operation: " + message); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2StringHashCode = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key.charCodeAt(index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, - 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, - 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, - 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, - 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, - 4166287, 4999559, 5999471, 7199369]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 1024; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash) { - this.hash = hash; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode >= 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', "Key was already in table."); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && key === e.Key) { - return e; - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count >= (this.entries.length / 2)) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - return new HashTable(capacity, hash); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - TypeScript.nodeMakeDirectoryTime = 0; - TypeScript.nodeCreateBufferTime = 0; - TypeScript.nodeWriteFileSyncTime = 0; - - (function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; - })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); - var ByteOrderMark = TypeScript.ByteOrderMark; - - var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this.contents = contents; - this.byteOrderMark = byteOrderMark; - } - return FileInformation; - })(); - TypeScript.FileInformation = FileInformation; - - TypeScript.Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - newLine: "\r\n", - currentDirectory: function () { - return WScript.CreateObject("WScript.Shell").CurrentDirectory; - }, - supportsCodePage: function () { - return WScript.ReadFile; - }, - readFile: function (path, codepage) { - try { - if (codepage !== null && this.supportsCodePage()) { - try { - var contents = WScript.ReadFile(path, codepage); - return new FileInformation(contents, 0 /* None */); - } catch (e) { - } - } - - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - var message; - if (err.number === -2147024809) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); - } - - throw new Error(message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - var _os = require('os'); - - return { - newLine: _os.EOL, - currentDirectory: function () { - return process.cwd(); - }, - supportsCodePage: function () { - return false; - }, - readFile: function (file, codepage) { - if (codepage !== null) { - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); - } - - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 509); - } - } - var start = new Date().getTime(); - mkdirRecursiveSync(_path.dirname(path)); - TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - - var start = new Date().getTime(); - - var chunkLength = 4 * 1024; - var fileDescriptor = _fs.openSync(path, "w"); - try { - for (var index = 0; index < contents.length; index += chunkLength) { - var bufferStart = new Date().getTime(); - var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); - TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; - - _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); - } - } finally { - _fs.closeSync(fileDescriptor); - } - - TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IntegerUtilities) { - function integerDivide(numerator, denominator) { - return (numerator / denominator) >> 0; - } - IntegerUtilities.integerDivide = integerDivide; - - function integerMultiplyLow32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - } - IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; - - function integerMultiplyHigh32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - } - IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; - - function isInteger(text) { - return /^[0-9]+$/.test(text); - } - IntegerUtilities.isInteger = isInteger; - - function isHexInteger(text) { - return /^0(x|X)[0-9a-fA-F]+$/.test(text); - } - IntegerUtilities.isHexInteger = isHexInteger; - })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); - var IntegerUtilities = TypeScript.IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_computeLineStarts, length) { - this._computeLineStarts = _computeLineStarts; - this.length = length; - this._lineStarts = null; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this.lineStarts(), length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - if (this._lineStarts === null) { - this._lineStarts = this._computeLineStarts(); - } - - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - LineMap.empty = new LineMap(function () { - return [0]; - }, 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { - return e; - } - } - - return null; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - if (text.length !== length) { - return false; - } - - var s = start; - for (var i = 0; i < length; i++) { - if (text.charCodeAt(i) !== array[s]) { - return false; - } - - s++; - } - - return true; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticInformationMap = { - "error TS{0}: {1}": { - "code": 0, - "category": 3 /* NoPrefix */ - }, - "warning TS{0}: {1}": { - "code": 1, - "category": 3 /* NoPrefix */ - }, - "Unrecognized escape sequence.": { - "code": 1000, - "category": 1 /* Error */ - }, - "Unexpected character {0}.": { - "code": 1001, - "category": 1 /* Error */ - }, - "Missing close quote character.": { - "code": 1002, - "category": 1 /* Error */ - }, - "Identifier expected.": { - "code": 1003, - "category": 1 /* Error */ - }, - "'{0}' keyword expected.": { - "code": 1004, - "category": 1 /* Error */ - }, - "'{0}' expected.": { - "code": 1005, - "category": 1 /* Error */ - }, - "Identifier expected; '{0}' is a keyword.": { - "code": 1006, - "category": 1 /* Error */ - }, - "Automatic semicolon insertion not allowed.": { - "code": 1007, - "category": 1 /* Error */ - }, - "Unexpected token; '{0}' expected.": { - "code": 1008, - "category": 1 /* Error */ - }, - "Trailing separator not allowed.": { - "code": 1009, - "category": 1 /* Error */ - }, - "'*/' expected.": { - "code": 1010, - "category": 1 /* Error */ - }, - "'public' or 'private' modifier must precede 'static'.": { - "code": 1011, - "category": 1 /* Error */ - }, - "Unexpected token.": { - "code": 1012, - "category": 1 /* Error */ - }, - "Catch clause parameter cannot have a type annotation.": { - "code": 1013, - "category": 1 /* Error */ - }, - "Rest parameter must be last in list.": { - "code": 1014, - "category": 1 /* Error */ - }, - "Parameter cannot have question mark and initializer.": { - "code": 1015, - "category": 1 /* Error */ - }, - "Required parameter cannot follow optional parameter.": { - "code": 1016, - "category": 1 /* Error */ - }, - "Index signatures cannot have rest parameters.": { - "code": 1017, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have accessibility modifiers.": { - "code": 1018, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have a question mark.": { - "code": 1019, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have an initializer.": { - "code": 1020, - "category": 1 /* Error */ - }, - "Index signature must have a type annotation.": { - "code": 1021, - "category": 1 /* Error */ - }, - "Index signature parameter must have a type annotation.": { - "code": 1022, - "category": 1 /* Error */ - }, - "Index signature parameter type must be 'string' or 'number'.": { - "code": 1023, - "category": 1 /* Error */ - }, - "'extends' clause already seen.": { - "code": 1024, - "category": 1 /* Error */ - }, - "'extends' clause must precede 'implements' clause.": { - "code": 1025, - "category": 1 /* Error */ - }, - "Classes can only extend a single class.": { - "code": 1026, - "category": 1 /* Error */ - }, - "'implements' clause already seen.": { - "code": 1027, - "category": 1 /* Error */ - }, - "Accessibility modifier already seen.": { - "code": 1028, - "category": 1 /* Error */ - }, - "'{0}' modifier must precede '{1}' modifier.": { - "code": 1029, - "category": 1 /* Error */ - }, - "'{0}' modifier already seen.": { - "code": 1030, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a class element.": { - "code": 1031, - "category": 1 /* Error */ - }, - "Interface declaration cannot have 'implements' clause.": { - "code": 1032, - "category": 1 /* Error */ - }, - "'super' invocation cannot have type arguments.": { - "code": 1034, - "category": 1 /* Error */ - }, - "Only ambient modules can use quoted names.": { - "code": 1035, - "category": 1 /* Error */ - }, - "Statements are not allowed in ambient contexts.": { - "code": 1036, - "category": 1 /* Error */ - }, - "Implementations are not allowed in ambient contexts.": { - "code": 1037, - "category": 1 /* Error */ - }, - "'declare' modifier not allowed for code already in an ambient context.": { - "code": 1038, - "category": 1 /* Error */ - }, - "Initializers are not allowed in ambient contexts.": { - "code": 1039, - "category": 1 /* Error */ - }, - "Parameter property declarations can only be used in a non-ambient constructor declaration.": { - "code": 1040, - "category": 1 /* Error */ - }, - "Function implementation expected.": { - "code": 1041, - "category": 1 /* Error */ - }, - "Constructor implementation expected.": { - "code": 1042, - "category": 1 /* Error */ - }, - "Function overload name must be '{0}'.": { - "code": 1043, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a module element.": { - "code": 1044, - "category": 1 /* Error */ - }, - "'declare' modifier cannot appear on an interface declaration.": { - "code": 1045, - "category": 1 /* Error */ - }, - "'declare' modifier required for top level element.": { - "code": 1046, - "category": 1 /* Error */ - }, - "Rest parameter cannot be optional.": { - "code": 1047, - "category": 1 /* Error */ - }, - "Rest parameter cannot have an initializer.": { - "code": 1048, - "category": 1 /* Error */ - }, - "'set' accessor must have one and only one parameter.": { - "code": 1049, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot be optional.": { - "code": 1051, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot have an initializer.": { - "code": 1052, - "category": 1 /* Error */ - }, - "'set' accessor cannot have rest parameter.": { - "code": 1053, - "category": 1 /* Error */ - }, - "'get' accessor cannot have parameters.": { - "code": 1054, - "category": 1 /* Error */ - }, - "Modifiers cannot appear here.": { - "code": 1055, - "category": 1 /* Error */ - }, - "Accessors are only available when targeting ECMAScript 5 and higher.": { - "code": 1056, - "category": 1 /* Error */ - }, - "Class name cannot be '{0}'.": { - "code": 1057, - "category": 1 /* Error */ - }, - "Interface name cannot be '{0}'.": { - "code": 1058, - "category": 1 /* Error */ - }, - "Enum name cannot be '{0}'.": { - "code": 1059, - "category": 1 /* Error */ - }, - "Module name cannot be '{0}'.": { - "code": 1060, - "category": 1 /* Error */ - }, - "Enum member must have initializer.": { - "code": 1061, - "category": 1 /* Error */ - }, - "Export assignment cannot be used in internal modules.": { - "code": 1063, - "category": 1 /* Error */ - }, - "Export assignment not allowed in module with exported element.": { - "code": 1064, - "category": 1 /* Error */ - }, - "Module cannot have multiple export assignments.": { - "code": 1065, - "category": 1 /* Error */ - }, - "Ambient enum elements can only have integer literal initializers.": { - "code": 1066, - "category": 1 /* Error */ - }, - "module, class, interface, enum, import or statement": { - "code": 1067, - "category": 3 /* NoPrefix */ - }, - "constructor, function, accessor or variable": { - "code": 1068, - "category": 3 /* NoPrefix */ - }, - "statement": { - "code": 1069, - "category": 3 /* NoPrefix */ - }, - "case or default clause": { - "code": 1070, - "category": 3 /* NoPrefix */ - }, - "identifier": { - "code": 1071, - "category": 3 /* NoPrefix */ - }, - "call, construct, index, property or function signature": { - "code": 1072, - "category": 3 /* NoPrefix */ - }, - "expression": { - "code": 1073, - "category": 3 /* NoPrefix */ - }, - "type name": { - "code": 1074, - "category": 3 /* NoPrefix */ - }, - "property or accessor": { - "code": 1075, - "category": 3 /* NoPrefix */ - }, - "parameter": { - "code": 1076, - "category": 3 /* NoPrefix */ - }, - "type": { - "code": 1077, - "category": 3 /* NoPrefix */ - }, - "type parameter": { - "code": 1078, - "category": 3 /* NoPrefix */ - }, - "'declare' modifier not allowed on import declaration.": { - "code": 1079, - "category": 1 /* Error */ - }, - "Function overload must be static.": { - "code": 1080, - "category": 1 /* Error */ - }, - "Function overload must not be static.": { - "code": 1081, - "category": 1 /* Error */ - }, - "Parameter property declarations cannot be used in a constructor overload.": { - "code": 1083, - "category": 1 /* Error */ - }, - "Invalid 'reference' directive syntax.": { - "code": 1084, - "category": 1 /* Error */ - }, - "Octal literals are not available when targeting ECMAScript 5 and higher.": { - "code": 1085, - "category": 1 /* Error */ - }, - "Accessors are not allowed in ambient contexts.": { - "code": 1086, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a constructor declaration.": { - "code": 1089, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a parameter.": { - "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 */ - }, - "The name '{0}' does not exist in the current scope.": { - "code": 2001, - "category": 1 /* Error */ - }, - "The name '{0}' does not refer to a value.": { - "code": 2002, - "category": 1 /* Error */ - }, - "'super' can only be used inside a class instance method.": { - "code": 2003, - "category": 1 /* Error */ - }, - "The left-hand side of an assignment expression must be a variable, property or indexer.": { - "code": 2004, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable. Did you mean to include 'new'?": { - "code": 2161, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable.": { - "code": 2006, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not newable.": { - "code": 2007, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not indexable by type '{1}'.": { - "code": 2008, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { - "code": 2009, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { - "code": 2010, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}'.": { - "code": 2011, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}':{NL}{2}": { - "code": 2012, - "category": 1 /* Error */ - }, - "Expected var, class, interface, or module.": { - "code": 2013, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to type '{1}'.": { - "code": 2014, - "category": 1 /* Error */ - }, - "Getter '{0}' already declared.": { - "code": 2015, - "category": 1 /* Error */ - }, - "Setter '{0}' already declared.": { - "code": 2016, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends private class '{1}'.": { - "code": 2018, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements private interface '{1}'.": { - "code": 2019, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends private interface '{1}'.": { - "code": 2020, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends class from inaccessible module {1}.": { - "code": 2021, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements interface from inaccessible module {1}.": { - "code": 2022, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends interface from inaccessible module {1}.": { - "code": 2023, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2024, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2025, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2026, - "category": 1 /* Error */ - }, - "Exported variable '{0}' has or is using private type '{1}'.": { - "code": 2027, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2028, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2029, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2030, - "category": 1 /* Error */ - }, - "Exported variable '{0}' is using inaccessible module {1}.": { - "code": 2031, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { - "code": 2032, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { - "code": 2033, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { - "code": 2034, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2035, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2036, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2037, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2038, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2039, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2040, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { - "code": 2041, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { - "code": 2042, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { - "code": 2043, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2044, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2045, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2046, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2047, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2048, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2049, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class has or is using private type '{0}'.": { - "code": 2050, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class has or is using private type '{0}'.": { - "code": 2051, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface has or is using private type '{0}'.": { - "code": 2052, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface has or is using private type '{0}'.": { - "code": 2053, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface has or is using private type '{0}'.": { - "code": 2054, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class has or is using private type '{0}'.": { - "code": 2055, - "category": 1 /* Error */ - }, - "Return type of public method from exported class has or is using private type '{0}'.": { - "code": 2056, - "category": 1 /* Error */ - }, - "Return type of method from exported interface has or is using private type '{0}'.": { - "code": 2057, - "category": 1 /* Error */ - }, - "Return type of exported function has or is using private type '{0}'.": { - "code": 2058, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class is using inaccessible module {0}.": { - "code": 2059, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class is using inaccessible module {0}.": { - "code": 2060, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface is using inaccessible module {0}.": { - "code": 2061, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface is using inaccessible module {0}.": { - "code": 2062, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface is using inaccessible module {0}.": { - "code": 2063, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class is using inaccessible module {0}.": { - "code": 2064, - "category": 1 /* Error */ - }, - "Return type of public method from exported class is using inaccessible module {0}.": { - "code": 2065, - "category": 1 /* Error */ - }, - "Return type of method from exported interface is using inaccessible module {0}.": { - "code": 2066, - "category": 1 /* Error */ - }, - "Return type of exported function is using inaccessible module {0}.": { - "code": 2067, - "category": 1 /* Error */ - }, - "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { - "code": 2068, - "category": 1 /* Error */ - }, - "A parameter list must follow a generic type argument list. '(' expected.": { - "code": 2069, - "category": 1 /* Error */ - }, - "Multiple constructor implementations are not allowed.": { - "code": 2070, - "category": 1 /* Error */ - }, - "Unable to resolve external module '{0}'.": { - "code": 2071, - "category": 1 /* Error */ - }, - "Module cannot be aliased to a non-module type.": { - "code": 2072, - "category": 1 /* Error */ - }, - "A class may only extend another class.": { - "code": 2073, - "category": 1 /* Error */ - }, - "A class may only implement another class or interface.": { - "code": 2074, - "category": 1 /* Error */ - }, - "An interface may only extend another class or interface.": { - "code": 2075, - "category": 1 /* Error */ - }, - "Unable to resolve type.": { - "code": 2077, - "category": 1 /* Error */ - }, - "Unable to resolve type of '{0}'.": { - "code": 2078, - "category": 1 /* Error */ - }, - "Unable to resolve type parameter constraint.": { - "code": 2079, - "category": 1 /* Error */ - }, - "Type parameter constraint cannot be a primitive type.": { - "code": 2080, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target.": { - "code": 2081, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target:{NL}{0}": { - "code": 2082, - "category": 1 /* Error */ - }, - "Invalid 'new' expression.": { - "code": 2083, - "category": 1 /* Error */ - }, - "Call signatures used in a 'new' expression must have a 'void' return type.": { - "code": 2084, - "category": 1 /* Error */ - }, - "Could not select overload for 'new' expression.": { - "code": 2085, - "category": 1 /* Error */ - }, - "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { - "code": 2086, - "category": 1 /* Error */ - }, - "Could not select overload for 'call' expression.": { - "code": 2087, - "category": 1 /* Error */ - }, - "Cannot invoke an expression whose type lacks a call signature.": { - "code": 2088, - "category": 1 /* Error */ - }, - "Calls to 'super' are only valid inside a class.": { - "code": 2089, - "category": 1 /* Error */ - }, - "Generic type '{0}' requires {1} type argument(s).": { - "code": 2090, - "category": 1 /* Error */ - }, - "Type of array literal cannot be determined. Best common type could not be found for array elements.": { - "code": 2092, - "category": 1 /* Error */ - }, - "Could not find enclosing symbol for dotted name '{0}'.": { - "code": 2093, - "category": 1 /* Error */ - }, - "The property '{0}' does not exist on value of type '{1}'.": { - "code": 2094, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}'.": { - "code": 2095, - "category": 1 /* Error */ - }, - "'get' and 'set' accessor must have the same type.": { - "code": 2096, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in current location.": { - "code": 2097, - "category": 1 /* Error */ - }, - "Static members cannot reference class type parameters.": { - "code": 2099, - "category": 1 /* Error */ - }, - "Class '{0}' is recursively referenced as a base type of itself.": { - "code": 2100, - "category": 1 /* Error */ - }, - "Interface '{0}' is recursively referenced as a base type of itself.": { - "code": 2101, - "category": 1 /* Error */ - }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { - "code": 2102, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in non-derived classes.": { - "code": 2103, - "category": 1 /* Error */ - }, - "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { - "code": 2104, - "category": 1 /* Error */ - }, - "Constructors for derived classes must contain a 'super' call.": { - "code": 2105, - "category": 1 /* Error */ - }, - "Super calls are not permitted outside constructors or in nested functions inside constructors.": { - "code": 2106, - "category": 1 /* Error */ - }, - "'{0}.{1}' is inaccessible.": { - "code": 2107, - "category": 1 /* Error */ - }, - "'this' cannot be referenced within module bodies.": { - "code": 2108, - "category": 1 /* Error */ - }, - "Invalid '+' expression - types not known to support the addition operator.": { - "code": 2111, - "category": 1 /* Error */ - }, - "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2112, - "category": 1 /* Error */ - }, - "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2113, - "category": 1 /* Error */ - }, - "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { - "code": 2114, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement cannot use a type annotation.": { - "code": 2115, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { - "code": 2116, - "category": 1 /* Error */ - }, - "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { - "code": 2117, - "category": 1 /* Error */ - }, - "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { - "code": 2118, - "category": 1 /* Error */ - }, - "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { - "code": 2119, - "category": 1 /* Error */ - }, - "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { - "code": 2120, - "category": 1 /* Error */ - }, - "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 */ - }, - "Setters cannot return a value.": { - "code": 2122, - "category": 1 /* Error */ - }, - "Tried to query type of uninitialized module '{0}'.": { - "code": 2123, - "category": 1 /* Error */ - }, - "Tried to set variable type to uninitialized module type '{0}'.": { - "code": 2124, - "category": 1 /* Error */ - }, - "Type '{0}' does not have type parameters.": { - "code": 2125, - "category": 1 /* Error */ - }, - "Getters must return a value.": { - "code": 2126, - "category": 1 /* Error */ - }, - "Getter and setter accessors do not agree in visibility.": { - "code": 2127, - "category": 1 /* Error */ - }, - "Invalid left-hand side of assignment expression.": { - "code": 2130, - "category": 1 /* Error */ - }, - "Function declared a non-void return type, but has no return expression.": { - "code": 2131, - "category": 1 /* Error */ - }, - "Cannot resolve return type reference.": { - "code": 2132, - "category": 1 /* Error */ - }, - "Constructors cannot have a return type of 'void'.": { - "code": 2133, - "category": 1 /* Error */ - }, - "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { - "code": 2134, - "category": 1 /* Error */ - }, - "All symbols within a with block will be resolved to 'any'.": { - "code": 2135, - "category": 1 /* Error */ - }, - "Import declarations in an internal module cannot reference an external module.": { - "code": 2136, - "category": 1 /* Error */ - }, - "Class {0} declares interface {1} but does not implement it:{NL}{2}": { - "code": 2137, - "category": 1 /* Error */ - }, - "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { - "code": 2138, - "category": 1 /* Error */ - }, - "The operand of an increment or decrement operator must be a variable, property or indexer.": { - "code": 2139, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in static initializers in a class body.": { - "code": 2140, - "category": 1 /* Error */ - }, - "Class '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2141, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2142, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { - "code": 2143, - "category": 1 /* Error */ - }, - "Duplicate overload signature for '{0}'.": { - "code": 2144, - "category": 1 /* Error */ - }, - "Duplicate constructor overload signature.": { - "code": 2145, - "category": 1 /* Error */ - }, - "Duplicate overload call signature.": { - "code": 2146, - "category": 1 /* Error */ - }, - "Duplicate overload construct signature.": { - "code": 2147, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition.": { - "code": 2148, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition:{NL}{0}": { - "code": 2149, - "category": 1 /* Error */ - }, - "Overload signatures must all be public or private.": { - "code": 2150, - "category": 1 /* Error */ - }, - "Overload signatures must all be exported or not exported.": { - "code": 2151, - "category": 1 /* Error */ - }, - "Overload signatures must all be ambient or non-ambient.": { - "code": 2152, - "category": 1 /* Error */ - }, - "Overload signatures must all be optional or required.": { - "code": 2153, - "category": 1 /* Error */ - }, - "Specialized overload signature is not assignable to any non-specialized signature.": { - "code": 2154, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in constructor arguments.": { - "code": 2155, - "category": 1 /* Error */ - }, - "Instance member cannot be accessed off a class.": { - "code": 2157, - "category": 1 /* Error */ - }, - "Untyped function calls may not accept type arguments.": { - "code": 2158, - "category": 1 /* Error */ - }, - "Non-generic functions may not accept type arguments.": { - "code": 2159, - "category": 1 /* Error */ - }, - "A generic type may not reference itself with a wrapped form of its own type parameters.": { - "code": 2160, - "category": 1 /* Error */ - }, - "Rest parameters must be array types.": { - "code": 2162, - "category": 1 /* Error */ - }, - "Overload signature implementation cannot use specialized type.": { - "code": 2163, - "category": 1 /* Error */ - }, - "Export assignments may only be used at the top-level of external modules.": { - "code": 2164, - "category": 1 /* Error */ - }, - "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2165, - "category": 1 /* Error */ - }, - "Only public methods of the base class are accessible via the 'super' keyword.": { - "code": 2166, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { - "code": 2167, - "category": 1 /* Error */ - }, - "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 assignable to numeric indexer type '{0}'.": { - "code": 2169, - "category": 1 /* Error */ - }, - "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { - "code": 2170, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}'.": { - "code": 2171, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { - "code": 2172, - "category": 1 /* Error */ - }, - "Generic type references must include all type arguments.": { - "code": 2173, - "category": 1 /* Error */ - }, - "Default arguments are only allowed in implementation.": { - "code": 2174, - "category": 1 /* Error */ - }, - "Overloads cannot differ only by return type.": { - "code": 2175, - "category": 1 /* Error */ - }, - "Function expression declared a non-void return type, but has no return expression.": { - "code": 2176, - "category": 1 /* Error */ - }, - "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2177, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}' in module '{1}'.": { - "code": 2178, - "category": 1 /* Error */ - }, - "Unable to resolve module reference '{0}'.": { - "code": 2179, - "category": 1 /* Error */ - }, - "Could not find module '{0}' in module '{1}'.": { - "code": 2180, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { - "code": 2181, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { - "code": 2182, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { - "code": 2183, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { - "code": 2184, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { - "code": 2185, - "category": 1 /* Error */ - }, - "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { - "code": 2186, - "category": 1 /* Error */ - }, - "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { - "code": 2187, - "category": 1 /* Error */ - }, - "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { - "code": 2188, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { - "code": 2189, - "category": 1 /* Error */ - }, - "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { - "code": 2190, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot be reopened.": { - "code": 2191, - "category": 1 /* Error */ - }, - "All declarations of merged declaration '{0}' must be exported or not exported.": { - "code": 2192, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in constructor arguments.": { - "code": 2193, - "category": 1 /* Error */ - }, - "Return type of constructor signature must be assignable to the instance type of the class.": { - "code": 2194, - "category": 1 /* Error */ - }, - "Ambient external module declaration must be defined in global context.": { - "code": 2195, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot specify relative module name.": { - "code": 2196, - "category": 1 /* Error */ - }, - "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { - "code": 2197, - "category": 1 /* Error */ - }, - "Could not find the best common type of types of all return statement expressions.": { - "code": 2198, - "category": 1 /* Error */ - }, - "Import declaration cannot refer to external module reference when --noResolve option is set.": { - "code": 2199, - "category": 1 /* Error */ - }, - "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { - "code": 2200, - "category": 1 /* Error */ - }, - "'continue' statement can only be used within an enclosing iteration statement.": { - "code": 2201, - "category": 1 /* Error */ - }, - "'break' statement can only be used within an enclosing iteration or switch statement.": { - "code": 2202, - "category": 1 /* Error */ - }, - "Jump target not found.": { - "code": 2203, - "category": 1 /* Error */ - }, - "Jump target cannot cross function boundary.": { - "code": 2204, - "category": 1 /* Error */ - }, - "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { - "code": 2205, - "category": 1 /* Error */ - }, - "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { - "code": 2206, - "category": 1 /* Error */ - }, - "Expression resolves to '_super' that compiler uses to capture base class reference.": { - "code": 2207, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2208, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2209, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2210, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2211, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2212, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2213, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2214, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2215, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2216, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2217, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2218, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2219, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { - "code": 2220, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2221, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { - "code": 2222, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2223, - "category": 1 /* Error */ - }, - "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { - "code": 2224, - "category": 1 /* Error */ - }, - "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { - "code": 2225, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { - "code": 2226, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { - "code": 2227, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { - "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 */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { - "code": 4001, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { - "code": 4002, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { - "code": 4003, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { - "code": 4004, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' define property '{2}' as private.": { - "code": 4005, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4006, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4007, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a call signature, but type '{1}' lacks one.": { - "code": 4008, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4009, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4010, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { - "code": 4011, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4012, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4013, - "category": 3 /* NoPrefix */ - }, - "Call signature expects {0} or fewer parameters.": { - "code": 4014, - "category": 3 /* NoPrefix */ - }, - "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { - "code": 4015, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4016, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4017, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { - "code": 4018, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { - "code": 4019, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { - "code": 4020, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { - "code": 4021, - "category": 3 /* NoPrefix */ - }, - "Type reference cannot refer to container '{0}'.": { - "code": 4022, - "category": 1 /* Error */ - }, - "Type reference must refer to type.": { - "code": 4023, - "category": 1 /* Error */ - }, - "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { - "code": 4024, - "category": 1 /* Error */ - }, - " (+ {0} overload(s))": { - "code": 4025, - "category": 2 /* Message */ - }, - "Variable declaration cannot have the same name as an import declaration.": { - "code": 4026, - "category": 1 /* Error */ - }, - "Signature expected {0} type arguments, got {1} instead.": { - "code": 4027, - "category": 1 /* Error */ - }, - "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { - "code": 4028, - "category": 3 /* NoPrefix */ - }, - "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 infinitely expanding type reference have incompatible type arguments.": { - "code": 4030, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { - "code": 4031, - "category": 3 /* NoPrefix */ - }, - "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { - "code": 4032, - "category": 3 /* NoPrefix */ - }, - "Types of string indexer of types '{0}' and '{1}' are not identical.": { - "code": 4033, - "category": 3 /* NoPrefix */ - }, - "Types of number indexer of types '{0}' and '{1}' are not identical.": { - "code": 4034, - "category": 3 /* NoPrefix */ - }, - "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 assignable to string indexer type in type '{2}'.{NL}{3}": { - "code": 4036, - "category": 3 /* NoPrefix */ - }, - "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 */ - }, - "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { - "code": 5002, - "category": 1 /* Error */ - }, - "Module code generation '{0}' not supported.": { - "code": 5003, - "category": 1 /* Error */ - }, - "Could not find file: '{0}'.": { - "code": 5004, - "category": 1 /* Error */ - }, - "A file cannot have a reference to itself.": { - "code": 5006, - "category": 1 /* Error */ - }, - "Cannot resolve referenced file: '{0}'.": { - "code": 5007, - "category": 1 /* Error */ - }, - "Cannot find the common subdirectory path for the input files.": { - "code": 5009, - "category": 1 /* Error */ - }, - "Emit Error: {0}.": { - "code": 5011, - "category": 1 /* Error */ - }, - "Cannot read file '{0}': {1}": { - "code": 5012, - "category": 1 /* Error */ - }, - "Unsupported file encoding.": { - "code": 5013, - "category": 3 /* NoPrefix */ - }, - "Locale must be of the form or -. For example '{0}' or '{1}'.": { - "code": 5014, - "category": 1 /* Error */ - }, - "Unsupported locale: '{0}'.": { - "code": 5015, - "category": 1 /* Error */ - }, - "Execution Failed.{NL}": { - "code": 5016, - "category": 1 /* Error */ - }, - "Invalid call to 'up'": { - "code": 5019, - "category": 1 /* Error */ - }, - "Invalid call to 'down'": { - "code": 5020, - "category": 1 /* Error */ - }, - "Base64 value '{0}' finished with a continuation bit.": { - "code": 5021, - "category": 1 /* Error */ - }, - "Unknown option '{0}'": { - "code": 5023, - "category": 1 /* Error */ - }, - "Expected {0} arguments to message, got {1} instead.": { - "code": 5024, - "category": 1 /* Error */ - }, - "Expected the message '{0}' to have {1} arguments, but it had {2}": { - "code": 5025, - "category": 1 /* Error */ - }, - "Could not delete file '{0}'": { - "code": 5034, - "category": 1 /* Error */ - }, - "Could not create directory '{0}'": { - "code": 5035, - "category": 1 /* Error */ - }, - "Error while executing file '{0}': ": { - "code": 5036, - "category": 1 /* Error */ - }, - "Cannot compile external modules unless the '--module' flag is provided.": { - "code": 5037, - "category": 1 /* Error */ - }, - "Option mapRoot cannot be specified without specifying sourcemap option.": { - "code": 5038, - "category": 1 /* Error */ - }, - "Option sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5039, - "category": 1 /* Error */ - }, - "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5040, - "category": 1 /* Error */ - }, - "Option '{0}' specified without '{1}'": { - "code": 5041, - "category": 1 /* Error */ - }, - "'codepage' option not supported on current platform.": { - "code": 5042, - "category": 1 /* Error */ - }, - "Concatenate and emit output to single file.": { - "code": 6001, - "category": 2 /* Message */ - }, - "Generates corresponding {0} file.": { - "code": 6002, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate map files instead of generated locations.": { - "code": 6003, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate TypeScript files instead of source locations.": { - "code": 6004, - "category": 2 /* Message */ - }, - "Watch input files.": { - "code": 6005, - "category": 2 /* Message */ - }, - "Redirect output structure to the directory.": { - "code": 6006, - "category": 2 /* Message */ - }, - "Do not emit comments to output.": { - "code": 6009, - "category": 2 /* Message */ - }, - "Skip resolution and preprocessing.": { - "code": 6010, - "category": 2 /* Message */ - }, - "Specify ECMAScript target version: '{0}' (default), or '{1}'": { - "code": 6015, - "category": 2 /* Message */ - }, - "Specify module code generation: '{0}' or '{1}'": { - "code": 6016, - "category": 2 /* Message */ - }, - "Print this message.": { - "code": 6017, - "category": 2 /* Message */ - }, - "Print the compiler's version: {0}": { - "code": 6019, - "category": 2 /* Message */ - }, - "Allow use of deprecated '{0}' keyword when referencing an external module.": { - "code": 6021, - "category": 2 /* Message */ - }, - "Specify locale for errors and messages. For example '{0}' or '{1}'": { - "code": 6022, - "category": 2 /* Message */ - }, - "Syntax: {0}": { - "code": 6023, - "category": 2 /* Message */ - }, - "options": { - "code": 6024, - "category": 2 /* Message */ - }, - "file1": { - "code": 6025, - "category": 2 /* Message */ - }, - "Examples:": { - "code": 6026, - "category": 2 /* Message */ - }, - "Options:": { - "code": 6027, - "category": 2 /* Message */ - }, - "Insert command line options and files from a file.": { - "code": 6030, - "category": 2 /* Message */ - }, - "Version {0}": { - "code": 6029, - "category": 2 /* Message */ - }, - "Use the '{0}' flag to see options.": { - "code": 6031, - "category": 2 /* Message */ - }, - "{NL}Recompiling ({0}):": { - "code": 6032, - "category": 2 /* Message */ - }, - "STRING": { - "code": 6033, - "category": 2 /* Message */ - }, - "KIND": { - "code": 6034, - "category": 2 /* Message */ - }, - "file2": { - "code": 6035, - "category": 2 /* Message */ - }, - "VERSION": { - "code": 6036, - "category": 2 /* Message */ - }, - "LOCATION": { - "code": 6037, - "category": 2 /* Message */ - }, - "DIRECTORY": { - "code": 6038, - "category": 2 /* Message */ - }, - "NUMBER": { - "code": 6039, - "category": 2 /* Message */ - }, - "Specify the codepage to use when opening source files.": { - "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 */ - }, - "Unknown rule.": { - "code": 7002, - "category": 1 /* Error */ - }, - "Invalid line number ({0})": { - "code": 7003, - "category": 1 /* Error */ - }, - "Warn on expressions and declarations with an implied 'any' type.": { - "code": 7004, - "category": 2 /* Message */ - }, - "Variable '{0}' implicitly has an 'any' type.": { - "code": 7005, - "category": 1 /* Error */ - }, - "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { - "code": 7006, - "category": 1 /* Error */ - }, - "Parameter '{0}' of function type implicitly has an 'any' type.": { - "code": 7007, - "category": 1 /* Error */ - }, - "Member '{0}' of object type implicitly has an 'any' type.": { - "code": 7008, - "category": 1 /* Error */ - }, - "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { - "code": 7009, - "category": 1 /* Error */ - }, - "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7010, - "category": 1 /* Error */ - }, - "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7011, - "category": 1 /* Error */ - }, - "Parameter '{0}' of lambda function implicitly has an 'any' type.": { - "code": 7012, - "category": 1 /* Error */ - }, - "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7013, - "category": 1 /* Error */ - }, - "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7014, - "category": 1 /* Error */ - }, - "Array Literal implicitly has an 'any' type from widening.": { - "code": 7015, - "category": 1 /* Error */ - }, - "'{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 = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - this._lineStartPositions = null; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - if (!this._lineStartPositions) { - this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); - } - - return this._lineStartPositions; - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LineMap1) { - function fromSimpleText(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return text.charCodeAt(index); - }, length: text.length() }); - }, text.length()); - } - LineMap1.fromSimpleText = fromSimpleText; - - function fromScriptSnapshot(scriptSnapshot) { - return new TypeScript.LineMap(function () { - return scriptSnapshot.getLineStartPositions(); - }, scriptSnapshot.getLength()); - } - LineMap1.fromScriptSnapshot = fromScriptSnapshot; - - function fromString(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts(text); - }, text.length); - } - LineMap1.fromString = fromString; - })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); - var LineMap1 = TypeScript.LineMap1; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextFactory) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - if (text === null) { - throw TypeScript.Errors.argumentNull('text'); - } - TypeScript.Debug.assert(lineBreakLength >= 0); - TypeScript.Debug.assert(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this._lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this._lineStarts(); - }, this.length()); - }; - - TextBase.prototype._lineStarts = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this._lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - this._lazyLineStarts = null; - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.substr = function (start, length, intern) { - var startInOriginalText = this.span.start() + start; - return this.text.substr(startInOriginalText, length, intern); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SubText.prototype._lineStarts = function () { - var _this = this; - if (!this._lazyLineStarts) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return _this.charCodeAt(index); - }, length: this.length() }); - } - - return this._lazyLineStarts; - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - this._lazyLineStarts = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - - StringText.prototype._lineStarts = function () { - if (this._lazyLineStarts === null) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); - } - - return this._lazyLineStarts; - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap1.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - this._lineMap = null; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - if (!this._lineMap) { - this._lineMap = TypeScript.LineMap1.fromString(this.value); - } - - return this._lineMap; - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this.scriptSnapshot.getLineStartPositions(); - }, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length; - - if (0 === length) { - var result = new Array(); - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = new Array(); - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (length < 0) { - TypeScript.Errors.argument("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Debug.assert(start >= 0); - TypeScript.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - var change0 = changes[0]; - - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - - oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - CharacterInfo.isOctalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 55 /* _7 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - - SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { - this._languageVersion = languageVersion; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - } - ParseOptions.prototype.toJSON = function (key) { - return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; - }; - - ParseOptions.prototype.languageVersion = function () { - return this._languageVersion; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; - - SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; - SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; - - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - - SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; - SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 62 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 63 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 64 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 65 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 67 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 66 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 68 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 69 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 70 /* OpenBraceToken */, - "}": 71 /* CloseBraceToken */, - "(": 72 /* OpenParenToken */, - ")": 73 /* CloseParenToken */, - "[": 74 /* OpenBracketToken */, - "]": 75 /* CloseBracketToken */, - ".": 76 /* DotToken */, - "...": 77 /* DotDotDotToken */, - ";": 78 /* SemicolonToken */, - ",": 79 /* CommaToken */, - "<": 80 /* LessThanToken */, - ">": 81 /* GreaterThanToken */, - "<=": 82 /* LessThanEqualsToken */, - ">=": 83 /* GreaterThanEqualsToken */, - "==": 84 /* EqualsEqualsToken */, - "=>": 85 /* EqualsGreaterThanToken */, - "!=": 86 /* ExclamationEqualsToken */, - "===": 87 /* EqualsEqualsEqualsToken */, - "!==": 88 /* ExclamationEqualsEqualsToken */, - "+": 89 /* PlusToken */, - "-": 90 /* MinusToken */, - "*": 91 /* AsteriskToken */, - "%": 92 /* PercentToken */, - "++": 93 /* PlusPlusToken */, - "--": 94 /* MinusMinusToken */, - "<<": 95 /* LessThanLessThanToken */, - ">>": 96 /* GreaterThanGreaterThanToken */, - ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 98 /* AmpersandToken */, - "|": 99 /* BarToken */, - "^": 100 /* CaretToken */, - "!": 101 /* ExclamationToken */, - "~": 102 /* TildeToken */, - "&&": 103 /* AmpersandAmpersandToken */, - "||": 104 /* BarBarToken */, - "?": 105 /* QuestionToken */, - ":": 106 /* ColonToken */, - "=": 107 /* EqualsToken */, - "+=": 108 /* PlusEqualsToken */, - "-=": 109 /* MinusEqualsToken */, - "*=": 110 /* AsteriskEqualsToken */, - "%=": 111 /* PercentEqualsToken */, - "<<=": 112 /* LessThanLessThanEqualsToken */, - ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 115 /* AmpersandEqualsToken */, - "|=": 116 /* BarEqualsToken */, - "^=": 117 /* CaretEqualsToken */, - "/": 118 /* SlashToken */, - "/=": 119 /* SlashEqualsToken */ - }; - - var kindToText = new Array(); - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[62 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 89 /* PlusToken */: - return 164 /* PlusExpression */; - case 90 /* MinusToken */: - return 165 /* NegateExpression */; - case 102 /* TildeToken */: - return 166 /* BitwiseNotExpression */; - case 101 /* ExclamationToken */: - return 167 /* LogicalNotExpression */; - case 93 /* PlusPlusToken */: - return 168 /* PreIncrementExpression */; - case 94 /* MinusMinusToken */: - return 169 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 93 /* PlusPlusToken */: - return 210 /* PostIncrementExpression */; - case 94 /* MinusMinusToken */: - return 211 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 91 /* AsteriskToken */: - return 205 /* MultiplyExpression */; - - case 118 /* SlashToken */: - return 206 /* DivideExpression */; - - case 92 /* PercentToken */: - return 207 /* ModuloExpression */; - - case 89 /* PlusToken */: - return 208 /* AddExpression */; - - case 90 /* MinusToken */: - return 209 /* SubtractExpression */; - - case 95 /* LessThanLessThanToken */: - return 202 /* LeftShiftExpression */; - - case 96 /* GreaterThanGreaterThanToken */: - return 203 /* SignedRightShiftExpression */; - - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - return 204 /* UnsignedRightShiftExpression */; - - case 80 /* LessThanToken */: - return 196 /* LessThanExpression */; - - case 81 /* GreaterThanToken */: - return 197 /* GreaterThanExpression */; - - case 82 /* LessThanEqualsToken */: - return 198 /* LessThanOrEqualExpression */; - - case 83 /* GreaterThanEqualsToken */: - return 199 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 200 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 201 /* InExpression */; - - case 84 /* EqualsEqualsToken */: - return 192 /* EqualsWithTypeConversionExpression */; - - case 86 /* ExclamationEqualsToken */: - return 193 /* NotEqualsWithTypeConversionExpression */; - - case 87 /* EqualsEqualsEqualsToken */: - return 194 /* EqualsExpression */; - - case 88 /* ExclamationEqualsEqualsToken */: - return 195 /* NotEqualsExpression */; - - case 98 /* AmpersandToken */: - return 191 /* BitwiseAndExpression */; - - case 100 /* CaretToken */: - return 190 /* BitwiseExclusiveOrExpression */; - - case 99 /* BarToken */: - return 189 /* BitwiseOrExpression */; - - case 103 /* AmpersandAmpersandToken */: - return 188 /* LogicalAndExpression */; - - case 104 /* BarBarToken */: - return 187 /* LogicalOrExpression */; - - case 116 /* BarEqualsToken */: - return 182 /* OrAssignmentExpression */; - - case 115 /* AmpersandEqualsToken */: - return 180 /* AndAssignmentExpression */; - - case 117 /* CaretEqualsToken */: - return 181 /* ExclusiveOrAssignmentExpression */; - - case 112 /* LessThanLessThanEqualsToken */: - return 183 /* LeftShiftAssignmentExpression */; - - case 113 /* GreaterThanGreaterThanEqualsToken */: - return 184 /* SignedRightShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 185 /* UnsignedRightShiftAssignmentExpression */; - - case 108 /* PlusEqualsToken */: - return 175 /* AddAssignmentExpression */; - - case 109 /* MinusEqualsToken */: - return 176 /* SubtractAssignmentExpression */; - - case 110 /* AsteriskEqualsToken */: - return 177 /* MultiplyAssignmentExpression */; - - case 119 /* SlashEqualsToken */: - return 178 /* DivideAssignmentExpression */; - - case 111 /* PercentEqualsToken */: - return 179 /* ModuloAssignmentExpression */; - - case 107 /* EqualsToken */: - return 174 /* AssignmentExpression */; - - case 79 /* CommaToken */: - return 173 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function getOperatorTokenFromBinaryExpression(tokenKind) { - switch (tokenKind) { - case 205 /* MultiplyExpression */: - return 91 /* AsteriskToken */; - - case 206 /* DivideExpression */: - return 118 /* SlashToken */; - - case 207 /* ModuloExpression */: - return 92 /* PercentToken */; - - case 208 /* AddExpression */: - return 89 /* PlusToken */; - - case 209 /* SubtractExpression */: - return 90 /* MinusToken */; - - case 202 /* LeftShiftExpression */: - return 95 /* LessThanLessThanToken */; - - case 203 /* SignedRightShiftExpression */: - return 96 /* GreaterThanGreaterThanToken */; - - case 204 /* UnsignedRightShiftExpression */: - return 97 /* GreaterThanGreaterThanGreaterThanToken */; - - case 196 /* LessThanExpression */: - return 80 /* LessThanToken */; - - case 197 /* GreaterThanExpression */: - return 81 /* GreaterThanToken */; - - case 198 /* LessThanOrEqualExpression */: - return 82 /* LessThanEqualsToken */; - - case 199 /* GreaterThanOrEqualExpression */: - return 83 /* GreaterThanEqualsToken */; - - case 200 /* InstanceOfExpression */: - return 30 /* InstanceOfKeyword */; - - case 201 /* InExpression */: - return 29 /* InKeyword */; - - case 192 /* EqualsWithTypeConversionExpression */: - return 84 /* EqualsEqualsToken */; - - case 193 /* NotEqualsWithTypeConversionExpression */: - return 86 /* ExclamationEqualsToken */; - - case 194 /* EqualsExpression */: - return 87 /* EqualsEqualsEqualsToken */; - - case 195 /* NotEqualsExpression */: - return 88 /* ExclamationEqualsEqualsToken */; - - case 191 /* BitwiseAndExpression */: - return 98 /* AmpersandToken */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 100 /* CaretToken */; - - case 189 /* BitwiseOrExpression */: - return 99 /* BarToken */; - - case 188 /* LogicalAndExpression */: - return 103 /* AmpersandAmpersandToken */; - - case 187 /* LogicalOrExpression */: - return 104 /* BarBarToken */; - - case 182 /* OrAssignmentExpression */: - return 116 /* BarEqualsToken */; - - case 180 /* AndAssignmentExpression */: - return 115 /* AmpersandEqualsToken */; - - case 181 /* ExclusiveOrAssignmentExpression */: - return 117 /* CaretEqualsToken */; - - case 183 /* LeftShiftAssignmentExpression */: - return 112 /* LessThanLessThanEqualsToken */; - - case 184 /* SignedRightShiftAssignmentExpression */: - return 113 /* GreaterThanGreaterThanEqualsToken */; - - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - - case 175 /* AddAssignmentExpression */: - return 108 /* PlusEqualsToken */; - - case 176 /* SubtractAssignmentExpression */: - return 109 /* MinusEqualsToken */; - - case 177 /* MultiplyAssignmentExpression */: - return 110 /* AsteriskEqualsToken */; - - case 178 /* DivideAssignmentExpression */: - return 119 /* SlashEqualsToken */; - - case 179 /* ModuloAssignmentExpression */: - return 111 /* PercentEqualsToken */; - - case 174 /* AssignmentExpression */: - return 107 /* EqualsToken */; - - case 173 /* CommaExpression */: - return 79 /* CommaToken */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; - - function isAnyDivideToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - isIdentifierPartCharacter[character] = true; - isNumericLiteralStart[character] = true; - } - } - - isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); - 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - 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 { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - 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(fullText, kind); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(text, start, isTrailing); - }; - - Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { - var trivia = new Array(); - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.slidingWindow.absoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(diagnostics); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(79 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(106 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(78 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(102 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(72 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(73 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(105 /* QuestionToken */); - } - - if (isNumericLiteralStart[character]) { - return this.scanNumericLiteral(diagnostics); - } - - if (isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifierOrKeyword(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var slidingWindow = this.slidingWindow; - var window = slidingWindow.window; - - var startIndex = slidingWindow.currentRelativeItemIndex; - var endIndex = slidingWindow.windowCount; - var currentIndex = startIndex; - var character = 0; - - while (currentIndex < endIndex) { - character = window[currentIndex]; - if (!isIdentifierPartCharacter[character]) { - break; - } - - currentIndex++; - } - - if (currentIndex === endIndex) { - return 0 /* None */; - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - return 0 /* None */; - } else { - var kind; - var identifierLength = currentIndex - startIndex; - if (isKeywordStartCharacter[firstCharacter]) { - kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); - } else { - kind = 11 /* IdentifierName */; - } - - slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); - - return kind; - } - }; - - Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - var sawUnicodeEscape = false; - - do { - var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); - sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - var length = this.slidingWindow.absoluteIndex() - startIndex; - var text = this.text.substr(startIndex, length, false); - var valueText = TypeScript.Syntax.massageEscapes(text); - - var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); - if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { - if (sawUnicodeEscape) { - return keywordKind | -2147483648 /* IsVariableWidthKeyword */; - } else { - return keywordKind; - } - } - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function (diagnostics) { - if (this.isHexNumericLiteral()) { - this.scanHexNumericLiteral(); - } else if (this.isOctalNumericLiteral()) { - this.scanOctalNumericLiteral(diagnostics); - } else { - this.scanDecimalNumericLiteral(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isOctalNumericLiteral = function () { - return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); - }; - - Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { - var position = this.absoluteIndex(); - - while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.languageVersion() >= 1 /* EcmaScript5 */) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); - } - }; - - Scanner.prototype.scanDecimalDigits = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - this.scanDecimalDigits(); - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - this.scanDecimalDigits(); - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - var nextChar1 = this.slidingWindow.peekItemN(1); - - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { - var nextChar2 = this.slidingWindow.peekItemN(2); - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } - } - } - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 82 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* LessThanLessThanEqualsToken */; - } else { - return 95 /* LessThanLessThanToken */; - } - } else { - return 80 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 104 /* BarBarToken */; - } else { - return 99 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* CaretEqualsToken */; - } else { - return 100 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 115 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 103 /* AmpersandAmpersandToken */; - } else { - return 98 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* PercentEqualsToken */; - } else { - return 92 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* MinusMinusToken */; - } else { - return 90 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 108 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 93 /* PlusPlusToken */; - } else { - return 89 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* AsteriskEqualsToken */; - } else { - return 91 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 87 /* EqualsEqualsEqualsToken */; - } else { - return 84 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 85 /* EqualsGreaterThanToken */; - } else { - return 107 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function (diagnostics) { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(diagnostics); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 77 /* DotDotDotToken */; - } else { - return 76 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 119 /* SlashEqualsToken */; - } else { - return 118 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 12 /* RegularExpressionLiteral */; - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* ExclamationEqualsEqualsToken */; - } else { - return 86 /* ExclamationEqualsToken */; - } - } else { - return 101 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - break; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - break; - - default: - break; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - this.scanUnicodeOrHexEscape(errors); - return true; - } - } - - this.slidingWindow.moveToNextItem(); - return false; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); - var errors = new Array(); - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 121 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 124 /* ArrayType */: - return parent.type === nodeOrToken; - case 220 /* CastExpression */: - return parent.type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - case 228 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return TypeScript.Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullEnd; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullEnd = positionedToken.fullEnd(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullEnd) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); - } - - fullEnd -= triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function findSkippedTokenOnLeft(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - - function isIntegerLiteral(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - Syntax.isIntegerLiteral = isIntegerLiteral; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = new Array(); - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return nodeOrToken.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - element.insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - element.insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - var firstToken = this.firstToken(); - return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.trailingTrivia = function () { - var lastToken = this.lastToken(); - return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - 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 === thisAsIndexable[name]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - var start = positionedToken.start(); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isExpression = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.requireKeyword = requireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.requireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { - return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { - return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.importKeyword; - case 2: - return this.identifier; - case 3: - return this.equalsToken; - case 4: - return this.moduleReference; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - - this._kind = kind; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.kind = function () { - return this._kind; - }; - - HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { - if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.name = name; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.name; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withName = function (name) { - return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { - if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.callSignature = callSignature; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 123 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeQuerySyntax = (function (_super) { - __extends(TypeQuerySyntax, _super); - function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.name = name; - } - TypeQuerySyntax.prototype.accept = function (visitor) { - return visitor.visitTypeQuery(this); - }; - - TypeQuerySyntax.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuerySyntax.prototype.childCount = function () { - return 2; - }; - - TypeQuerySyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeQuerySyntax.prototype.isType = function () { - return true; - }; - - TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { - if (this.typeOfKeyword === typeOfKeyword && this.name === name) { - return this; - } - - return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); - }; - - TypeQuerySyntax.create1 = function (name) { - return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); - }; - - TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.name); - }; - - TypeQuerySyntax.prototype.withName = function (name) { - return this.update(this.typeOfKeyword, name); - }; - - TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeQuerySyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeQuerySyntax = TypeQuerySyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 146 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.modifiers; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifiers = function (modifiers) { - return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - - this.arguments = _arguments; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 142 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 227 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 239 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.constructorKeyword = constructorKeyword; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.constructorKeyword; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - 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 */), CallSignatureSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var GetAccessorSyntax = (function (_super) { - __extends(GetAccessorSyntax, _super); - function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.getKeyword = getKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - } - GetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessor(this); - }; - - GetAccessorSyntax.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - - GetAccessorSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - GetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - GetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetAccessorSyntax.create1 = function (propertyName) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GetAccessorSyntax = GetAccessorSyntax; - - var SetAccessorSyntax = (function (_super) { - __extends(SetAccessorSyntax, _super); - function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.setKeyword = setKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - SetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessor(this); - }; - - SetAccessorSyntax.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - - SetAccessorSyntax.prototype.childCount = function () { - return 5; - }; - - SetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - SetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetAccessorSyntax.create1 = function (propertyName) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SetAccessorSyntax = SetAccessorSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var IndexMemberDeclarationSyntax = (function (_super) { - __extends(IndexMemberDeclarationSyntax, _super); - function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.indexSignature = indexSignature; - this.semicolonToken = semicolonToken; - } - IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexMemberDeclaration(this); - }; - - IndexMemberDeclarationSyntax.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - - IndexMemberDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.indexSignature; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexMemberDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { - if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { - return this; - } - - return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); - }; - - IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); - }; - - IndexMemberDeclarationSyntax.create1 = function (indexSignature) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { - return this.update(this.modifiers, indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.indexSignature, semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexMemberDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - this.colonToken = colonToken; - this.statements = statements; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - this.colonToken = colonToken; - this.statements = statements; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.doKeyword = doKeyword; - this.statement = statement; - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeQuery = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - 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) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var dedentThisTrivia = dedentNextWhitespace; - dedentNextWhitespace = false; - - if (dedentThisTrivia) { - if (trivia.kind() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - var indentNextTrivia = true; - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var indentThisTrivia = indentNextTrivia; - indentNextTrivia = false; - - switch (trivia.kind()) { - case 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(fullText, kind) { - this._fullText = fullText; - this.tokenKind = kind; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithNoTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - token.trailingTrivia().collectTextElements(elements); - } - - function getTriviaWidth(value) { - return value >>> 2 /* TriviaFullWidthShift */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function isExpression(token) { - switch (token.tokenKind) { - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - return true; - } - - return false; - } - Syntax.isExpression = isExpression; - - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - case 13 /* carriageReturn */: - var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { - i++; - } - continue; - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - Syntax.massageEscapes = massageEscapes; - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - return regularExpressionValue(text); - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function regularExpressionValue(text) { - try { - var lastSlash = text.lastIndexOf("/"); - var body = text.substring(1, lastSlash); - var flags = text.substring(lastSlash + 1); - return new RegExp(body, flags); - } catch (e) { - return null; - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - EmptyToken.prototype.isExpression = function () { - return isExpression(this); - }; - - EmptyToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - - RealizedToken.prototype.isExpression = function () { - return isExpression(this); - }; - - RealizedToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var AbstractTrivia = (function () { - function AbstractTrivia(_kind) { - this._kind = _kind; - } - AbstractTrivia.prototype.fullWidth = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.fullText = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.toJSON = function (key) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === this._kind) { - result.kind = name; - break; - } - } - - if (this.isSkippedToken()) { - result.skippedToken = this.skippedToken(); - } else { - result.text = this.fullText(); - } - return result; - }; - - AbstractTrivia.prototype.kind = function () { - return this._kind; - }; - - AbstractTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - AbstractTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - AbstractTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - AbstractTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - AbstractTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return AbstractTrivia; - })(); - - var NormalTrivia = (function (_super) { - __extends(NormalTrivia, _super); - function NormalTrivia(kind, _text) { - _super.call(this, kind); - this._text = _text; - } - NormalTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - NormalTrivia.prototype.fullText = function () { - return this._text; - }; - - NormalTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return NormalTrivia; - })(AbstractTrivia); - - var SkippedTokenTrivia = (function (_super) { - __extends(SkippedTokenTrivia, _super); - function SkippedTokenTrivia(_skippedToken) { - _super.call(this, 8 /* SkippedTokenTrivia */); - this._skippedToken = _skippedToken; - } - SkippedTokenTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SkippedTokenTrivia.prototype.fullText = function () { - return this.skippedToken().fullText(); - }; - - SkippedTokenTrivia.prototype.skippedToken = function () { - return this._skippedToken; - }; - return SkippedTokenTrivia; - })(AbstractTrivia); - - var DeferredTrivia = (function (_super) { - __extends(DeferredTrivia, _super); - function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { - _super.call(this, kind); - this._text = _text; - this._fullStart = _fullStart; - this._fullWidth = _fullWidth; - this._fullText = null; - } - DeferredTrivia.prototype.fullWidth = function () { - return this._fullWidth; - }; - - DeferredTrivia.prototype.fullText = function () { - if (!this._fullText) { - this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); - this._text = null; - } - - return this._fullText; - }; - - DeferredTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return DeferredTrivia; - })(AbstractTrivia); - - function deferredTrivia(kind, text, fullStart, fullWidth) { - return new DeferredTrivia(kind, text, fullStart, fullWidth); - } - Syntax.deferredTrivia = deferredTrivia; - - function trivia(kind, text) { - return new NormalTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SkippedTokenTrivia(token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - this.trivia[i].collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 228 /* TypeArgumentList */: - case 229 /* TypeParameterList */: - case 220 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - return SyntaxUtilities.getExportKeyword(moduleElement) !== null; - }; - - SyntaxUtilities.getExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - case 133 /* ImportDeclaration */: - return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); - default: - return null; - } - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeQuery = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.requireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.name); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeQuery = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.name); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitList(node.modifiers); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.constructorKeyword); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.indexSignature); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - - - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - var result = this.currentToken(); - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - - return result; - }; - return SyntaxCursor; - })(); - - - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); - } - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { - this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 69 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return this.eatToken(78 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); - } - - return semicolonToken; - } - - return this.eatToken(78 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= 15 /* FirstKeyword */) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 173 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 186 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 187 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 188 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 189 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 191 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 167 /* LogicalNotExpression */: - case 170 /* DeleteExpression */: - case 171 /* TypeOfExpression */: - case 172 /* VoidExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); - } - } - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - var modifierCount = this.modifierCount(); - return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - var modifierCount = this.modifierCount(); - if (this.isImportDeclaration(modifierCount)) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration(modifierCount)) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration(modifierCount)) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration(modifierCount)) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration(modifierCount)) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(inErrorRecovery)) { - return this.parseStatement(inErrorRecovery); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var modifiers = this.parseModifiers(); - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 80 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - - return typeArgumentList; - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 72 /* OpenParenToken */: - case 76 /* DotToken */: - - case 73 /* CloseParenToken */: - case 75 /* CloseBracketToken */: - case 106 /* ColonToken */: - case 78 /* SemicolonToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - case 84 /* EqualsEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: - case 103 /* AmpersandAmpersandToken */: - case 104 /* BarBarToken */: - case 100 /* CaretToken */: - case 98 /* AmpersandToken */: - case 99 /* BarToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { - var dotToken = this.eatToken(76 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 63 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isAccessor = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 64 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var getKeyword = this.eatKeyword(64 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var setKeyword = this.eatKeyword(68 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(false); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexMemberDeclaration()) { - return this.parseIndexMemberDeclaration(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var modifiers = this.parseModifiers(); - var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var callSignature = this.parseCallSignature(false); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 78 /* SemicolonToken */: - case 107 /* EqualsToken */: - case 106 /* ColonToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.isIndexMemberDeclaration = function () { - var index = this.modifierCount(); - return this.isIndexSignature(index); - }; - - ParserImpl.prototype.parseIndexMemberDeclaration = function () { - var modifiers = this.parseModifiers(); - var indexSignature = this.parseIndexSignature(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - if (callSignature.lastToken()) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature(0)) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(inErrorRecovery)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(inErrorRecovery)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function (tokenIndex) { - return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isIdentifier(this.currentToken())) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - - break; - - case 28 /* IfKeyword */: - case 70 /* OpenBraceToken */: - case 33 /* ReturnKeyword */: - case 34 /* SwitchKeyword */: - case 36 /* ThrowKeyword */: - case 15 /* BreakKeyword */: - case 18 /* ContinueKeyword */: - case 26 /* ForKeyword */: - case 42 /* WhileKeyword */: - case 43 /* WithKeyword */: - case 22 /* DoKeyword */: - case 38 /* TryKeyword */: - case 19 /* DebuggerKeyword */: - return true; - } - - if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { - return false; - } - - return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); - }; - - ParserImpl.prototype.parseStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 28 /* IfKeyword */: - return this.parseIfStatement(); - case 70 /* OpenBraceToken */: - return this.parseBlock(false, false); - case 33 /* ReturnKeyword */: - return this.parseReturnStatement(); - case 34 /* SwitchKeyword */: - return this.parseSwitchStatement(); - case 36 /* ThrowKeyword */: - return this.parseThrowStatement(); - case 15 /* BreakKeyword */: - return this.parseBreakStatement(); - case 18 /* ContinueKeyword */: - return this.parseContinueStatement(); - case 26 /* ForKeyword */: - return this.parseForOrForInStatement(); - case 42 /* WhileKeyword */: - return this.parseWhileStatement(); - case 43 /* WithKeyword */: - return this.parseWithStatement(); - case 22 /* DoKeyword */: - return this.parseDoStatement(); - case 38 /* TryKeyword */: - return this.parseTryStatement(); - case 19 /* DebuggerKeyword */: - return this.parseDebuggerStatement(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement(currentToken)) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { - return this.parseEmptyStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(false); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function (currentToken) { - return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(106 /* ColonToken */); - var statement = this.parseStatement(false); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return currentToken.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(78 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { - return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function (currentToken) { - var kind = currentToken.tokenKind; - if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 79 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function (currentToken) { - switch (currentToken.tokenKind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - - case 74 /* OpenBracketToken */: - - case 72 /* OpenParenToken */: - - case 80 /* LessThanToken */: - - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - - case 70 /* OpenBraceToken */: - - case 85 /* EqualsGreaterThanToken */: - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - - case 31 /* NewKeyword */: - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - - case 27 /* FunctionKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(false); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 225 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(token0); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(107 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpressionOrLower = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpressionOrLower(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeOfExpression(); - } else if (currentTokenKind === 41 /* VoidKeyword */) { - return this.parseVoidExpression(); - } else if (currentTokenKind === 21 /* DeleteKeyword */) { - return this.parseDeleteExpression(); - } else if (currentTokenKind === 80 /* LessThanToken */) { - return this.parseCastExpression(); - } else { - return this.parsePostfixExpressionOrLower(); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - if (precedence <= 2 /* AssignmentExpressionPrecedence */) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } - - var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); - if (parethesizedArrowFunction !== null) { - return parethesizedArrowFunction; - } - } - - var leftOperand = this.parseUnaryExpressionOrLower(); - return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(105 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(106 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 81 /* GreaterThanToken */) { - if (storage[1] === 81 /* GreaterThanToken */) { - if (storage[2] === 107 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 107 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 107 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } - - var expression = this.parsePrimaryExpression(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - return this.parseMemberExpressionRest(expression, false, inObjectCreation); - }; - - ParserImpl.prototype.parseCallExpressionOrLower = function () { - var expression; - if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { - expression = this.eatKeyword(50 /* SuperKeyword */); - - var currentTokenKind = this.currentToken().tokenKind; - if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - } - } else { - expression = this.parseMemberExpressionOrLower(false); - } - - return this.parseMemberExpressionRest(expression, true, false); - }; - - ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 72 /* OpenParenToken */: - if (!allowArguments) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 80 /* LessThanToken */: - if (!allowArguments) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 74 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 76 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseCallExpressionOrLower(); - } - }; - - ParserImpl.prototype.parsePostfixExpressionOrLower = function () { - var expression = this.parseLeftHandSideExpressionOrLower(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - } - - return expression; - }; - - ParserImpl.prototype.tryParseGenericArgumentList = function () { - var rewindPoint = this.getRewindPoint(); - - var typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; - var isDot = token0.tokenKind === 76 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - - var argumentList = null; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - - if (isDot) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); - } else { - return this.parseArgumentList(typeArgumentList); - } - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - if (this.currentToken().tokenKind === 80 /* LessThanToken */) { - return this.tryParseGenericArgumentList(); - } - - if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { - return this.parseArgumentList(null); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var _arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - _arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parsePrimaryExpression = function () { - var currentToken = this.currentToken(); - - if (this.isIdentifier(currentToken)) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 74 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 70 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 72 /* OpenParenToken */: - return this.parseParenthesizedExpression(); - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 75 /* CloseBracketToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseObjectCreationExpressionOrLower(true); - var argumentList = this.tryParseArgumentList(); - - var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); - return this.parseMemberExpressionRest(result, true, false); - }; - - ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseMemberExpressionOrLower(inObjectCreation); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(80 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedExpression = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { - return null; - } - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - - this.releaseRewindPoint(rewindPoint); - return arrowFunction; - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.tryParseArrowFunctionBlock = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { - return this.parseBlock(true, false); - } else { - return null; - } - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 70 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 73 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; - } - - if (token1.tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - token2 = this.peekToken(2); - if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { - if (this.isIdentifier(token2)) { - return true; - } - } - - if (!this.isIdentifier(token1)) { - return false; - } - - if (token2.tokenKind === 106 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 105 /* QuestionToken */) { - if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 79 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 106 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { - if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(true); - } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(106 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - return this.eatKeyword(35 /* ThisKeyword */); - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var lessThanToken = this.eatToken(80 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameters = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); - - return typeParameterList; - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(106 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 39 /* TypeOfKeyword */: - - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - - case 70 /* OpenBraceToken */: - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - - case 31 /* NewKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - var type = this.parseNonArrayType(currentToken); - - while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.isTypeQuery = function () { - return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; - }; - - ParserImpl.prototype.parseTypeQuery = function () { - var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); - var name = this.parseName(); - - return this.factory.typeQuery(typeOfKeyword, name); - }; - - ParserImpl.prototype.parseNonArrayType = function (currentToken) { - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - return this.eatAnyToken(); - - case 70 /* OpenBraceToken */: - return this.parseObjectType(); - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - return this.parseFunctionType(); - - case 31 /* NewKeyword */: - return this.parseConstructorType(); - - case 39 /* TypeOfKeyword */: - return this.parseTypeQuery(); - } - - return this.parseNameOrGenericType(); - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - var tokenKind = token.tokenKind; - if (tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { - if (this.isIdentifier(token)) { - var nextTokenKind = this.peekToken(1).tokenKind; - switch (nextTokenKind) { - case 73 /* CloseParenToken */: - case 106 /* ColonToken */: - case 107 /* EqualsToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); - - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { - modifierArray.push(this.eatAnyToken()); - continue; - } - - break; - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - 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; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType, inErrorRecovery); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 79 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 78 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 75 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 70 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 79 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - var currentToken = this.currentToken(); - if (this.isExpression(currentToken)) { - return true; - } - - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.parseStatement(inErrorRecovery); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(inErrorRecovery); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); - - case 16 /* SwitchClause_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 32 /* Block_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); - - case 131072 /* ParameterList_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, options) { - var source = new NormalParserSource(fileName, text, options.languageVersion()); - - return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.inObjectLiteralExpression = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { - return true; - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { - if (parameter.modifiers.childCount() > 0) { - var modifiers = parameter.modifiers; - var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - - if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { - if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); - return true; - } else { - if (modifierIndex > 0) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - 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.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; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); - return true; - } else if (parameter.modifiers.childCount() > 0) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - 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; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var isInStaticOverloadChain = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - var isStaticOverload = null; - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - 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) { - 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; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); - isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); - - 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; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 121 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "boolean": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { - var getKeywordFullStart = this.childFullStart(node, getKeyword); - if (parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { - if (this.checkIndexMemberModifiers(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIndexMemberDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { - if (node.modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(node, node.modifiers); - this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { - if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { - var savedInObjectLiteralExpression = this.inObjectLiteralExpression; - this.inObjectLiteralExpression = true; - _super.prototype.visitObjectLiteralExpression.call(this, node); - this.inObjectLiteralExpression = savedInObjectLiteralExpression; - }; - - GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { - var setKeywordFullStart = this.childFullStart(node, setKeyword); - if (parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); - return true; - } - - var parameterListFullStart = this.childFullStart(node, parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); - var parameter = parameterList.parameters.childAt(0); - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - 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 && previousValueWasComputed) { - this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); - return true; - } - - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitEnumElement = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - var expression = node.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(expression)) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); - this.skip(node); - return; - } - } - - _super.prototype.visitEnumElement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (node.stringLiteral === null) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); - } - } - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); - return true; - } - }; - - GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitImportDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); - this.skip(node); - return; - } - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { - this.skip(node); - return; - } - - _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); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock || this.inObjectLiteralExpression) { - if (modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclarator.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { - this.skip(node); - return; - } - - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { - var currentElementFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var child = modifiers.childAt(i); - if (child.kind() !== 57 /* PublicKeyword */) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); - return true; - } - - currentElementFullStart += child.fullWidth(); - } - - 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); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - if (logger.information()) { - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - } - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { - this._compiler = _compiler; - this._semanticInfoChain = _semanticInfoChain; - this.fileName = fileName; - this.referencedFiles = referencedFiles; - this._scriptSnapshot = _scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._syntaxTree = _syntaxTree; - this._topLevelDecl = _topLevelDecl; - this._diagnostics = null; - this._bloomFilter = null; - this._sourceUnit = null; - this._lineMap = null; - this._declASTMap = []; - this._astDeclMap = []; - this._amdDependencies = undefined; - this._externalModuleIndicatorSpan = undefined; - } - Document.prototype.invalidate = function () { - this._declASTMap.length = 0; - this._astDeclMap.length = 0; - this._topLevelDecl = null; - - this._syntaxTree = null; - this._sourceUnit = null; - this._diagnostics = null; - this._bloomFilter = null; - }; - - Document.prototype.isDeclareFile = function () { - return TypeScript.isDTSFile(this.fileName); - }; - - Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { - var start = new Date().getTime(); - this._diagnostics = syntaxTree.diagnostics(); - TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; - - this._lineMap = syntaxTree.lineMap(); - - var sourceUnit = syntaxTree.sourceUnit(); - var leadingTrivia = sourceUnit.leadingTrivia(); - - this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); - - var amdDependencies = []; - 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); - } - } - } - - this._amdDependencies = amdDependencies; - }; - - Document.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(trivia.fullText()); - - if (match) { - return new TypeScript.TextSpan(position, trivia.fullWidth()); - } - - return null; - }; - - 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); - } - } - - position += moduleElement.fullWidth(); - } - - return null; - ; - }; - - Document.prototype.sourceUnit = function () { - if (!this._sourceUnit) { - var start = new Date().getTime(); - var syntaxTree = this.syntaxTree(); - this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); - TypeScript.astTranslationTime += new Date().getTime() - start; - - if (!this.isOpen) { - this._syntaxTree = null; - } - } - - return this._sourceUnit; - }; - - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._diagnostics); - } - - return this._diagnostics; - }; - - Document.prototype.lineMap = function () { - if (this._lineMap === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._lineMap); - } - - return this._lineMap; - }; - - Document.prototype.isExternalModule = function () { - return this.externalModuleIndicatorSpan() !== null; - }; - - Document.prototype.externalModuleIndicatorSpan = function () { - if (this._externalModuleIndicatorSpan === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); - } - - return this._externalModuleIndicatorSpan; - }; - - Document.prototype.amdDependencies = function () { - if (this._amdDependencies === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._amdDependencies !== undefined); - } - - return this._amdDependencies; - }; - - Document.prototype.syntaxTree = function () { - var result = this._syntaxTree; - if (!result) { - var start = new Date().getTime(); - - result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); - - TypeScript.syntaxTreeParseTime += new Date().getTime() - start; - - if (this.isOpen || !this._sourceUnit) { - this._syntaxTree = result; - } - } - - this.cacheSyntaxTreeInfo(result); - return result; - }; - - Document.prototype.bloomFilter = function () { - if (!this._bloomFilter) { - var identifiers = TypeScript.createIntrinsicsObject(); - var pre = function (cur) { - if (TypeScript.ASTHelpers.isValidAstNode(cur)) { - if (cur.kind() === 11 /* IdentifierName */) { - var nodeText = cur.valueText(); - - identifiers[nodeText] = true; - } - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); - - var identifierCount = 0; - for (var name in identifiers) { - if (identifiers[name]) { - identifierCount++; - } - } - - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - } - return this._bloomFilter; - }; - - Document.prototype.emitToOwnOutputFile = function () { - return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { - var oldSyntaxTree = this._syntaxTree; - - if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { - var oldText = this._scriptSnapshot; - var newText = scriptSnapshot; - - TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); - var newTextPrefix = newText.getText(0, textChangeRange.span().start()); - TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); - - var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); - var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); - TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); - }; - - Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); - }; - - Document.prototype.topLevelDecl = function () { - if (this._topLevelDecl === null) { - this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); - } - - return this._topLevelDecl; - }; - - Document.prototype._getDeclForAST = function (ast) { - this.topLevelDecl(); - return this._astDeclMap[ast.syntaxID()]; - }; - - Document.prototype.getEnclosingDecl = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - return this._getDeclForAST(ast); - } - - ast = ast.parent; - var decl = null; - while (ast) { - decl = this._getDeclForAST(ast); - - if (decl) { - break; - } - - ast = ast.parent; - } - - return decl._getEnclosingDeclFromParentDecl(); - }; - - Document.prototype._setDeclForAST = function (ast, decl) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._astDeclMap[ast.syntaxID()] = decl; - }; - - Document.prototype._getASTForDecl = function (decl) { - return this._declASTMap[decl.declID]; - }; - - Document.prototype._setASTForDecl = function (decl, ast) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._declASTMap[decl.declID] = ast; - }; - return Document; - })(); - TypeScript.Document = Document; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var proto = "__proto__"; - - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - - this[proto] = null; - this[proto] = undefined; - } - return BlockIntrinsics; - })(); - - function createIntrinsicsObject() { - return new BlockIntrinsics(); - } - TypeScript.createIntrinsicsObject = createIntrinsicsObject; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = createIntrinsicsObject(); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (!fn(k, this.table[k], context)) { - return false; - } - } - } - - return true; - }; - - StringHashTable.prototype.some = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (fn(k, this.table[k], context)) { - return true; - } - } - } - - return false; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - - StringHashTable.prototype.remove = function (key) { - if (this.table[key] !== undefined) { - this.table[key] = undefined; - this.itemCount--; - } - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(StringHashTable); - TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (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); - } - ASTHelpers.moduleIsElided = moduleIsElided; - - 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)) { - 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; - } - ASTHelpers.enumIsElided = enumIsElided; - - function isValidAstNode(ast) { - if (!ast) - return false; - - if (ast.start() === -1 || ast.end() === -1) - return false; - - return true; - } - ASTHelpers.isValidAstNode = isValidAstNode; - - 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; - - 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) { - top = cur; - } - } - } - } - - 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; - } - } - - return false; - } - ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { - return false; - } - if (ast.kind() !== 11 /* IdentifierName */) { - return false; - } - - 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); - } - 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; - } - - current = current.parent; - } - 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; - } - - return null; - } - ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; - - 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; - } - 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; - - function parametersFromIdentifier(id) { - return { - length: 1, - lastParameterIsRest: function () { - return false; - }, - ast: id, - astAt: function (index) { - return id; - }, - identifierAt: function (index) { - return id; - }, - typeAt: function (index) { - return null; - }, - initializerAt: function (index) { - return null; - }, - isOptionalAt: function (index) { - return false; - } - }; - } - ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; - - function parametersFromParameter(parameter) { - return { - length: 1, - lastParameterIsRest: function () { - return parameter.dotDotDotToken !== null; - }, - ast: parameter, - astAt: function (index) { - return parameter; - }, - identifierAt: function (index) { - return parameter.identifier; - }, - typeAt: function (index) { - return getType(parameter); - }, - initializerAt: function (index) { - return parameter.equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(parameter); - } - }; - } - ASTHelpers.parametersFromParameter = parametersFromParameter; - - function parameterIsOptional(parameter) { - return parameter.questionToken !== null || parameter.equalsValueClause !== null; - } - - function parametersFromParameterList(list) { - return { - length: list.parameters.nonSeparatorCount(), - lastParameterIsRest: function () { - return TypeScript.lastParameterIsRest(list); - }, - ast: list.parameters, - astAt: function (index) { - return list.parameters.nonSeparatorAt(index); - }, - identifierAt: function (index) { - return list.parameters.nonSeparatorAt(index).identifier; - }, - typeAt: function (index) { - return getType(list.parameters.nonSeparatorAt(index)); - }, - initializerAt: function (index) { - return list.parameters.nonSeparatorAt(index).equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(list.parameters.nonSeparatorAt(index)); - } - }; - } - ASTHelpers.parametersFromParameterList = parametersFromParameterList; - - 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; - } - } - ASTHelpers.isDeclarationAST = isDeclarationAST; - - 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; - } - - 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; - } - - ast = ast.parent; - } - - return null; - } - ASTHelpers.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); - - 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 { - TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); - var dotExpr = name; - return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); - } - } - ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; - })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); - var ASTHelpers = TypeScript.ASTHelpers; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function walkListChildren(preAst, walker) { - for (var i = 0, n = preAst.childCount(); i < n; i++) { - walker.walk(preAst.childAt(i)); - } - } - - function walkThrowStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkPrefixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkPostfixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkDeleteExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkTypeArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArguments); - } - - function walkTypeOfExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkVoidExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArgumentList); - walker.walk(preAst.arguments); - } - - function walkArrayLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.expressions); - } - - function walkSimplePropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.expression); - } - - function walkFunctionPropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkGetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkSeparatedListChildren(preAst, walker) { - for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { - walker.walk(preAst.nonSeparatorAt(i)); - } - } - - function walkSetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkObjectLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.propertyAssignments); - } - - function walkCastExpressionChildren(preAst, walker) { - walker.walk(preAst.type); - walker.walk(preAst.expression); - } - - function walkParenthesizedExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkElementAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentExpression); - } - - function walkMemberAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.name); - } - - function walkQualifiedNameChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkBinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkEqualsValueClauseChildren(preAst, walker) { - walker.walk(preAst.value); - } - - function walkTypeParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.constraint); - } - - function walkTypeParameterListChildren(preAst, walker) { - walker.walk(preAst.typeParameters); - } - - function walkGenericTypeChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.typeArgumentList); - } - - function walkTypeAnnotationChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkTypeQueryChildren(preAst, walker) { - walker.walk(preAst.name); - } - - function walkInvocationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkObjectCreationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkTrinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.whenTrue); - walker.walk(preAst.whenFalse); - } - - function walkFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFunctionTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkMemberFunctionDeclarationChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFuncDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkIndexMemberDeclarationChildren(preAst, walker) { - walker.walk(preAst.indexSignature); - } - - function walkIndexSignatureChildren(preAst, walker) { - walker.walk(preAst.parameter); - walker.walk(preAst.typeAnnotation); - } - - function walkCallSignatureChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - } - - function walkConstraintChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkConstructorTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkConstructSignatureChildren(preAst, walker) { - walker.walk(preAst.callSignature); - } - - function walkParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkParameterListChildren(preAst, walker) { - walker.walk(preAst.parameters); - } - - function walkPropertySignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - } - - function walkVariableDeclaratorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkMemberVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarator); - } - - function walkMethodSignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - } - - function walkReturnStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkForStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.initializer); - walker.walk(preAst.condition); - walker.walk(preAst.incrementor); - walker.walk(preAst.statement); - } - - function walkForInStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.left); - walker.walk(preAst.expression); - walker.walk(preAst.statement); - } - - function walkIfStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - walker.walk(preAst.elseClause); - } - - function walkElseClauseChildren(preAst, walker) { - walker.walk(preAst.statement); - } - - function walkWhileStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkDoStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkBlockChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.declarators); - } - - function walkCaseSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.statements); - } - - function walkDefaultSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkSwitchStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.switchClauses); - } - - function walkTryStatementChildren(preAst, walker) { - walker.walk(preAst.block); - walker.walk(preAst.catchClause); - walker.walk(preAst.finallyClause); - } - - function walkCatchClauseChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkExternalModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.stringLiteral); - } - - function walkFinallyClauseChildren(preAst, walker) { - walker.walk(preAst.block); - } - - function walkClassDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.classElements); - } - - function walkScriptChildren(preAst, walker) { - walker.walk(preAst.moduleElements); - } - - function walkHeritageClauseChildren(preAst, walker) { - walker.walk(preAst.typeNames); - } - - function walkInterfaceDeclerationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.body); - } - - function walkObjectTypeChildren(preAst, walker) { - walker.walk(preAst.typeMembers); - } - - function walkArrayTypeChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkModuleDeclarationChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.stringLiteral); - walker.walk(preAst.moduleElements); - } - - function walkModuleNameModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.moduleName); - } - - function walkEnumDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.enumElements); - } - - function walkEnumElementChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.equalsValueClause); - } - - function walkImportDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.moduleReference); - } - - function walkExportAssignmentChildren(preAst, walker) { - walker.walk(preAst.identifier); - } - - function walkWithStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkExpressionStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkLabeledStatementChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.statement); - } - - function walkVariableStatementChildren(preAst, walker) { - walker.walk(preAst.declaration); - } - - var childrenWalkers = new Array(246 /* Last */ + 1); - - for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { - childrenWalkers[i] = null; - } - for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { - childrenWalkers[i] = null; - } - - childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; - childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[60 /* AnyKeyword */] = null; - childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; - childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; - childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; - childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; - childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; - childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[146 /* Block */] = walkBlockChildren; - childrenWalkers[61 /* BooleanKeyword */] = null; - childrenWalkers[152 /* BreakStatement */] = null; - childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; - childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; - childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; - childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; - childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; - childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; - childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; - childrenWalkers[239 /* Constraint */] = walkConstraintChildren; - childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; - childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; - childrenWalkers[153 /* ContinueStatement */] = null; - childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; - childrenWalkers[162 /* DebuggerStatement */] = null; - childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; - childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; - childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; - childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; - childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; - childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; - childrenWalkers[156 /* EmptyStatement */] = null; - childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; - childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; - childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; - childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; - childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; - childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; - childrenWalkers[24 /* FalseKeyword */] = null; - childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; - childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; - childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; - childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; - childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; - childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; - childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; - childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; - childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; - childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; - childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; - childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; - childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; - childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; - childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; - childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; - childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; - childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; - childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[1 /* List */] = walkListChildren; - childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; - childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; - childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; - childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; - childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; - childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; - childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; - childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; - childrenWalkers[11 /* IdentifierName */] = null; - childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[0 /* None */] = null; - childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[32 /* NullKeyword */] = null; - childrenWalkers[67 /* NumberKeyword */] = null; - childrenWalkers[13 /* NumericLiteral */] = null; - childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; - childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; - childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; - childrenWalkers[223 /* OmittedExpression */] = null; - childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[242 /* Parameter */] = walkParameterChildren; - childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; - childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; - childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; - childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; - childrenWalkers[12 /* RegularExpressionLiteral */] = null; - childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; - childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; - childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; - childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; - childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; - childrenWalkers[14 /* StringLiteral */] = null; - childrenWalkers[69 /* StringKeyword */] = null; - childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; - childrenWalkers[50 /* SuperKeyword */] = null; - childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; - childrenWalkers[35 /* ThisKeyword */] = null; - childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; - childrenWalkers[3 /* TriviaList */] = null; - childrenWalkers[37 /* TrueKeyword */] = null; - childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; - childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; - childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; - childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; - childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; - childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; - childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; - childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; - childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; - childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; - childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; - childrenWalkers[41 /* VoidKeyword */] = null; - childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; - childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; - - for (var e in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { - TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); - } - } - - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - this.stopWalking = false; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var SimplePreAstWalker = (function () { - function SimplePreAstWalker(pre, state) { - this.pre = pre; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePreAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - }; - return SimplePreAstWalker; - })(); - - var SimplePrePostAstWalker = (function () { - function SimplePrePostAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePrePostAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - - this.post(ast, this.state); - }; - return SimplePrePostAstWalker; - })(); - - var NormalAstWalker = (function () { - function NormalAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - NormalAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - if (this.options.stopWalking) { - return; - } - - this.pre(ast, this); - - if (this.options.stopWalking) { - return; - } - - if (this.options.goChildren) { - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - } else { - this.options.goChildren = true; - } - - if (this.post) { - this.post(ast, this); - } - }; - return NormalAstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { - new NormalAstWalker(pre, post, state).walk(ast); - }; - - AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { - if (post) { - new SimplePrePostAstWalker(pre, post, state).walk(ast); - } else { - new SimplePreAstWalker(pre, state).walk(ast); - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory = new AstWalkerFactory(); - - function getAstWalkerFactory() { - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapEntry = (function () { - function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { - this.emittedFile = emittedFile; - this.emittedLine = emittedLine; - this.emittedColumn = emittedColumn; - this.sourceFile = sourceFile; - this.sourceLine = sourceLine; - this.sourceColumn = sourceColumn; - this.sourceName = sourceName; - TypeScript.Debug.assert(isFinite(emittedLine)); - TypeScript.Debug.assert(isFinite(emittedColumn)); - TypeScript.Debug.assert(isFinite(sourceColumn)); - TypeScript.Debug.assert(isFinite(sourceLine)); - } - return SourceMapEntry; - })(); - TypeScript.SourceMapEntry = SourceMapEntry; - - var SourceMapper = (function () { - function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.names = []; - this.mappingLevel = []; - this.tsFilePaths = []; - this.allSourceMappings = []; - this.sourceMapEntries = []; - this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); - this.setNewSourceFile(document, emitOptions); - } - SourceMapper.prototype.getOutputFile = function () { - var result = this.sourceMapOut.getOutputFile(); - result.sourceMapEntries = this.sourceMapEntries; - - return result; - }; - - SourceMapper.prototype.increaseMappingLevel = function (ast) { - this.mappingLevel.push(ast); - }; - - SourceMapper.prototype.decreaseMappingLevel = function (ast) { - TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); - var expectedAst = this.mappingLevel.pop(); - var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; - var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; - TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); - }; - - SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { - var sourceMappings = []; - this.allSourceMappings.push(sourceMappings); - this.currentMappings = [sourceMappings]; - this.currentNameIndex = []; - - this.setNewSourceFilePath(document, emitOptions); - }; - - SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { - var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); - var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; - this.jsFileName = prettyJsFileName; - - if (emitOptions.sourceMapRootDirectory()) { - this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); - if (document.emitToOwnOutputFile()) { - this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); - } - - if (TypeScript.isRelative(this.sourceMapDirectory)) { - this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; - this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); - this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); - } else { - this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; - } - } else { - this.sourceMapPath = prettyMapFileName; - this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); - } - this.sourceRoot = emitOptions.sourceRootDirectory(); - }; - - SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { - var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); - if (emitOptions.sourceRootDirectory()) { - tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); - } else { - tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); - } - this.tsFilePaths.push(tsFilePath); - }; - - SourceMapper.prototype.emitSourceMapping = function () { - var _this = this; - TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { - return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); - }).join(', ')); - - this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); - - var mappingsString = ""; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); - prevSourceIndex = sourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); - prevNameIndex = nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - for (var i = 0; i < sourceMappings.length; i++) { - var sourceMapping = sourceMappings[i]; - recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); - recordSourceMappingSiblings(sourceMapping.childMappings); - recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); - } - }; - - recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); - } - - this.sourceMapOut.Write(JSON.stringify({ - version: 3, - file: this.jsFileName, - sourceRoot: this.sourceRoot, - sources: this.tsFilePaths, - names: this.names, - mappings: mappingsString - })); - - this.sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compiler, resolvePath) { - this.resolvePath = resolvePath; - this._diagnostic = null; - this._settings = null; - this._commonDirectoryPath = ""; - this._sharedOutputFile = ""; - this._sourceRootDirectory = ""; - this._sourceMapRootDirectory = ""; - this._outputDirectory = ""; - var settings = compiler.compilationSettings(); - this._settings = settings; - - 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()) { - if (settings.mapRoot()) { - if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } else { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } else if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } - - this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); - this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); - - if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { - if (settings.outFileOption()) { - this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); - } - - if (settings.outDirOption()) { - this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); - } - - if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { - this.determineCommonDirectoryPath(compiler); - } - } - } - EmitOptions.prototype.diagnostic = function () { - return this._diagnostic; - }; - - EmitOptions.prototype.commonDirectoryPath = function () { - return this._commonDirectoryPath; - }; - EmitOptions.prototype.sharedOutputFile = function () { - return this._sharedOutputFile; - }; - EmitOptions.prototype.sourceRootDirectory = function () { - return this._sourceRootDirectory; - }; - EmitOptions.prototype.sourceMapRootDirectory = function () { - return this._sourceMapRootDirectory; - }; - EmitOptions.prototype.outputDirectory = function () { - return this._outputDirectory; - }; - - EmitOptions.prototype.compilationSettings = function () { - return this._settings; - }; - - EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = compiler.fileNames(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = compiler.getDocument(fileNames[i]); - var sourceUnit = document.sourceUnit(); - - if (!document.isDeclareFile()) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - 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; - } - - return; - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - function lastParameterIsRest(parameterList) { - var parameters = parameterList.parameters; - return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; - } - TypeScript.lastParameterIsRest = lastParameterIsRest; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.inArrowFunction = false; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.declStack = []; - this.exportAssignment = null; - this.inWithBlock = false; - this.document = null; - this.detachedCommentsElement = null; - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setExportAssignment = function (exportAssignment) { - this.exportAssignment = exportAssignment; - }; - - Emitter.prototype.getExportAssignment = function () { - return this.exportAssignment; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.shouldEmitImportDeclaration = 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 */; - - 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 */; - - this.emitComments(importDeclAST, true); - - var importSymbol = importDecl.getSymbol(); - - var parentSymbol = importSymbol.getContainer(); - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; - - var needsPropertyAssignment = false; - var usePropertyAssignmentInsteadOfVarDecl = false; - var moduleNamePrefix; - - 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 */)) { - needsPropertyAssignment = true; - } else { - usePropertyAssignmentInsteadOfVarDecl = true; - } - } - - if (this.emitState.container === 2 /* DynamicModule */) { - moduleNamePrefix = "exports."; - } else { - moduleNamePrefix = this.moduleName + "."; - } - } - - if (isAmdCodeGen && isExternalModuleReference) { - needsPropertyAssignment = true; - } else { - this.recordSourceMappingStart(importDeclAST); - if (usePropertyAssignmentInsteadOfVarDecl) { - this.writeToOutput(moduleNamePrefix); - } else { - this.writeToOutput("var "); - } - this.writeToOutput(importDeclAST.identifier.text() + " = "); - var aliasAST = importDeclAST.moduleReference; - - if (isExternalModuleReference) { - this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); - } else { - this.emitJavascript(aliasAST.moduleName, false); - } - - this.recordSourceMappingEnd(importDeclAST); - this.writeToOutput(";"); - - if (needsPropertyAssignment) { - this.writeLineToOutput(""); - this.emitIndent(); - } - } - - if (needsPropertyAssignment) { - this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); - this.writeToOutput(";"); - } - this.emitComments(importDeclAST, false); - }; - - Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { - this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); - }; - - Emitter.prototype.setSourceMapperNewSourceFile = function (document) { - this.sourceMapper.setNewSourceFile(document, this.emitOptions); - }; - - Emitter.prototype.updateLineAndColumn = function (s) { - var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); - if (lineNumbers.length > 1) { - this.emitState.line += lineNumbers.length - 1; - this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; - } else { - this.emitState.column += s.length; - } - }; - - Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { - this.recordSourceMappingStart(astSpan); - this.writeToOutput(s); - this.recordSourceMappingEnd(astSpan); - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - this.updateLineAndColumn(s); - }; - - Emitter.prototype.writeLineToOutput = function (s, force) { - if (typeof force === "undefined") { force = false; } - if (!force && s === "" && this.emitState.column === 0) { - return; - } - - this.outfile.WriteLine(s); - this.updateLineAndColumn(s); - this.emitState.column = 0; - this.emitState.line++; - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - return this.indenter.getIndent(); - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitComment = function (comment, trailing, first) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var text = getTrimmedTextLines(comment); - var emitColumn = this.emitState.column; - - if (emitColumn === 0) { - this.emitIndent(); - } else if (trailing && first) { - this.writeToOutput(" "); - } - - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingEnd(comment); - this.writeToOutput(" "); - return; - } - } else { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } - - if (!trailing && emitColumn !== 0) { - this.emitIndent(); - } - }; - - Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - 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; - } - } - - if (pre) { - var preComments = ast.preComments(); - - if (preComments && ast === this.detachedCommentsElement) { - var detachedComments = this.getDetachedComments(ast); - preComments = preComments.slice(detachedComments.length); - this.detachedCommentsElement = null; - } - - if (preComments && onlyPinnedOrTripleSlashComments) { - preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { - return _this.isPinnedOrTripleSlash(c); - }); - } - - this.emitCommentsArray(preComments, false); - } else { - this.emitCommentsArray(ast.postComments(), true); - } - }; - - Emitter.prototype.isPinnedOrTripleSlash = function (comment) { - var fullText = comment.fullText(); - if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { - return true; - } else { - return fullText.indexOf("/*!") === 0; - } - }; - - Emitter.prototype.emitCommentsArray = function (comments, trailing) { - if (!this.emitOptions.compilationSettings().removeComments() && comments) { - for (var i = 0, n = comments.length; i < n; i++) { - this.emitComment(comments[i], trailing, i === 0); - } - } - }; - - Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { - this.recordSourceMappingStart(objectLiteral); - - this.writeToOutput("{"); - this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); - this.writeToOutput("}"); - - this.recordSourceMappingEnd(objectLiteral); - }; - - Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { - this.recordSourceMappingStart(arrayLiteral); - - this.writeToOutput("["); - this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); - this.writeToOutput("]"); - - this.recordSourceMappingEnd(arrayLiteral); - }; - - Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { - this.recordSourceMappingStart(objectCreationExpression); - this.writeToOutput("new "); - var target = objectCreationExpression.expression; - - this.emit(target); - if (objectCreationExpression.argumentList) { - this.recordSourceMappingStart(objectCreationExpression.argumentList); - this.writeToOutput("("); - this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); - this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); - this.recordSourceMappingEnd(objectCreationExpression.argumentList); - } - - this.recordSourceMappingEnd(objectCreationExpression); - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); - if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - if (pullDecl.kind === 67108864 /* EnumMember */) { - return pullDecl; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - var propertyName = dotExpr.name; - var boundDecl = this.getConstantDecl(dotExpr); - if (boundDecl) { - var value = boundDecl.constantValue; - if (value !== null) { - this.recordSourceMappingStart(dotExpr); - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.text(); - comment += " */"; - this.writeToOutput(comment); - this.recordSourceMappingEnd(dotExpr); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitInvocationExpression = function (callNode) { - this.recordSourceMappingStart(callNode); - var target = callNode.expression; - var args = callNode.argumentList.arguments; - - if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { - this.emit(target); - this.writeToOutput(".call"); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitThis(); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - } else { - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - - this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); - this.recordSourceMappingEnd(args); - this.recordSourceMappingEnd(callNode); - }; - - Emitter.prototype.emitParameterList = function (list) { - this.writeToOutput("("); - this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); - this.writeToOutput(")"); - }; - - Emitter.prototype.emitFunctionParameters = function (parameters) { - var argsLen = 0; - - if (parameters) { - this.emitComments(parameters.ast, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = parameters.length; - var printLen = argsLen; - if (parameters.lastParameterIsRest()) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = parameters.astAt(i); - this.emit(arg); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(parameters.ast, false); - } - }; - - Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { - this.writeLineToOutput(" {"); - if (name) { - this.recordSourceMappingNameStart(name); - } - - this.indenter.increaseIndent(); - - 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); - } else { - this.emitIndent(); - this.emitCommentsArray(bodyExpression.preComments(), false); - this.writeToOutput("return "); - this.emit(bodyExpression); - this.writeLineToOutput(";"); - this.emitCommentsArray(bodyExpression.postComments(), true); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - - if (block) { - this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); - } else { - this.writeToOutputWithSourceMapRecord("}", bodyExpression); - } - - if (name) { - this.recordSourceMappingNameEnd(); - } - }; - - Emitter.prototype.emitDefaultValueAssignments = function (parameters) { - var n = parameters.length; - if (parameters.lastParameterIsRest()) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = parameters.astAt(i); - var id = parameters.identifierAt(i); - var equalsValueClause = parameters.initializerAt(i); - if (equalsValueClause) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.emitJavascript(equalsValueClause, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (parameters) { - if (parameters.lastParameterIsRest()) { - var n = parameters.length; - var lastArg = parameters.astAt(n - 1); - var id = parameters.identifierAt(n - 1); - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); - this.writeToOutput(" "); - this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); - this.writeToOutput("; "); - this.writeToOutputWithSourceMapRecord("_i++", lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - var result = []; - - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - var queue = dynamicModuleDecl.getChildDecls(); - - for (var i = 0, n = queue.length; i < n; i++) { - var decl = queue[i]; - - if (decl.kind & 128 /* TypeAlias */) { - var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.type; - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { - var importList = ""; - var dependencyList = ""; - - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.isUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += importStatementDecl.name; - dependencyList += importStatementAST.moduleReference.stringLiteral.text(); - } - } - } - - var amdDependencies = this.document.amdDependencies(); - for (var i = 0; i < amdDependencies.length; i++) { - dependencyList += ", \"" + amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); - } - - var decl = this.semanticInfoChain.getDeclForAST(ast); - if (decl) { - return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); - } - - return false; - }; - - Emitter.prototype.emitEnum = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - this.moduleName = moduleDecl.identifier.text(); - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.identifier); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(this.moduleName); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitSeparatedList(moduleDecl.enumElements); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { - return moduleDecl; - } else if (changeNameIfAnyDeclarationInContext) { - var symbol = moduleDecl.getSymbol(); - if (symbol) { - var otherDecls = symbol.getDeclarations(); - for (var i = 0; i < otherDecls.length; i++) { - if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { - return otherDecls[i]; - } - } - } - } - - return null; - }; - - Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { - var _this = this; - var childDecls = parentDecl.getChildDecls(); - return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - 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; - } - } - return false; - }); - }; - - Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - var moduleName = moduleDecl.name; - var moduleDisplayName = moduleDecl.getDisplayName(); - - moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { - while (this.hasChildNameCollision(moduleName, moduleDecl)) { - moduleName = "_" + moduleName; - moduleDisplayName = "_" + moduleDisplayName; - } - } - - return moduleDisplayName; - }; - - Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { - if (moduleDecl.stringLiteral) { - this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); - } - }; - - Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); - - if (isLastName) { - this.emitComments(moduleDecl, true); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - - if (moduleDecl.stringLiteral) { - this.moduleName = moduleDecl.stringLiteral.valueText(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - } else { - this.moduleName = moduleName.text(); - } - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleName); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleName); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - - this.moduleName = this.getModuleName(pullDecl); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(moduleName.text()); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - if (moduleName === moduleDecl.stringLiteral) { - this.emitList(moduleDecl.moduleElements); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - var nameIndex = moduleNames.indexOf(moduleName); - TypeScript.Debug.assert(nameIndex >= 0); - - if (isLastName) { - this.emitList(moduleDecl.moduleElements); - } else { - this.emitIndent(); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); - this.writeLineToOutput(""); - } - } - - this.moduleName = moduleName.text(); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - - if (isLastName) { - this.emitComments(moduleDecl, false); - } - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - var name = varDecl.propertyName.text(); - var quoted = TypeScript.isQuoted(name); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.writeToOutput(']'); - - if (varDecl.equalsValueClause) { - this.emit(varDecl.equalsValueClause); - } else if (pullDecl.constantValue !== null) { - this.writeToOutput(' = '); - this.writeToOutput(pullDecl.constantValue.toString()); - } else { - this.writeToOutput(' = null'); - } - - this.writeToOutput('] = '); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - this.writeToOutput(';'); - }; - - Emitter.prototype.emitElementAccessExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("["); - this.emit(expression.argumentExpression); - this.writeToOutput("]"); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = true; - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(arrowFunction); - - var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); - this.pushDecl(pullDecl); - - this.emitComments(arrowFunction, true); - - this.recordSourceMappingStart(arrowFunction); - this.writeToOutput("function "); - this.writeToOutput("("); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); - - this.recordSourceMappingEnd(arrowFunction); - - this.recordSourceMappingEnd(arrowFunction); - - this.emitComments(arrowFunction, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConstructor = function (funcDecl) { - if (!funcDecl.block) { - return; - } - var temp = this.setContainer(4 /* Constructor */); - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - this.writeToOutput(this.thisClassNode.identifier.text()); - this.writeToOutput("("); - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart("constructor"); - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(parameters); - this.emitRestParameterInitializer(parameters); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - this.emitConstructorStatements(funcDecl); - this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - }; - - Emitter.prototype.emitGetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("get "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitSetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("set "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitFunctionExpression = function (funcDecl) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - this.writeToOutput(funcDecl.identifier.text()); - this.recordSourceMappingEnd(funcDecl.identifier); - } - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (funcDecl.block === null) { - return; - } - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier.text(); - - this.recordSourceMappingStart(funcDecl); - - var printName = funcDecl.identifier !== null; - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (printName) { - var id = funcDecl.identifier.text(); - if (id) { - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - } - this.writeToOutput(id); - if (funcDecl.identifier) { - this.recordSourceMappingEnd(funcDecl.identifier); - } - } - } - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - if (funcDecl.block) { - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - this.recordSourceMappingStart(this.currentVariableDeclaration); - if (varDecl.equalsValueClause) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - this.emitJavascript(varDecl.equalsValueClause, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.currentVariableDeclaration) { - this.writeToOutput("var "); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.nonSeparatorAt(0); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - - this.emitComments(declaration, true); - - var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); - var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; - if (!isAmbientWithoutInit) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.currentVariableDeclaration = declaration; - - for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { - var declarator = declaration.declarators.nonSeparatorAt(i); - - if (i > 0) { - this.writeToOutput(", "); - } - - this.emit(declarator); - } - this.currentVariableDeclaration = prevVariableDeclaration; - - this.recordSourceMappingEnd(declaration); - } - - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { - TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); - - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - - if (quotedOrNumber) { - this.writeToOutput("this["); - } else { - this.writeToOutput("this."); - } - - this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); - - if (quotedOrNumber) { - this.writeToOutput("]"); - } - - if (varDecl.variableDeclarator.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.variableDeclarator.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(this.currentVariableDeclaration); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.propertyName.text(); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); - - if (parentIsModule) { - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - - if (varDecl.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.currentVariableDeclaration = undefined; - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { - var decl = pullSymbol.getDeclarations()[0]; - var parentDecl = decl.getParentDecl(); - var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; - - var enclosingContextDeclPath = this.declStack; - var commonNodeIndex = -1; - - if (enclosingContextDeclPath.length) { - for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { - var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; - for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { - var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; - if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { - commonNodeIndex = i; - break; - } - } - - if (commonNodeIndex >= 0) { - break; - } - } - } - - var startingIndex = symbolContainerDeclPath.length - 1; - for (var i = startingIndex - 1; i > commonNodeIndex; i--) { - if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { - startingIndex = i; - } else { - break; - } - } - return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; - }; - - Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { - for (var i = startingIndex; i <= lastIndex; i++) { - if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.getModuleName(declPath[i], true) + "."); - } - } - }; - - Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { - var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); - var potentialDeclPath = declPathInfo.potentialPath; - var startingIndex = declPathInfo.startingIndex; - - this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); - }; - - Emitter.prototype.getSymbolForEmit = function (ast) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); - var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); - if (pullSymbol && pullSymbolAlias) { - var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - - if (pullSymbol === symbolToCompare) { - pullSymbol = pullSymbolAlias; - pullSymbolAlias = null; - } - } - return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (name.text().length > 0) { - var symbolForEmit = this.getSymbolForEmit(name); - var pullSymbol = symbolForEmit.symbol; - if (!pullSymbol) { - pullSymbol = this.semanticInfoChain.anyTypeSymbol; - } - var pullSymbolAlias = symbolForEmit.aliasSymbol; - var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.kind; - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } - } - } - - this.writeToOutput(name.text()); - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var nameIndex = -1; - if (name) { - if (this.sourceMapper.currentNameIndex.length > 0) { - var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { - break; - } - } - - if (nameIndex === -1) { - nameIndex = this.sourceMapper.names.length; - this.sourceMapper.names.push(name); - } - } - this.sourceMapper.currentNameIndex.push(nameIndex); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (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; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap(); - lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); - - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - this.sourceMapper.increaseMappingLevel(ast); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); - - this.sourceMapper.decreaseMappingLevel(ast); - } - }; - - Emitter.prototype.getOutputFiles = function () { - var result = []; - if (this.sourceMapper !== null) { - this.sourceMapper.emitSourceMapping(); - result.push(this.sourceMapper.getOutputFile()); - } - - result.push(this.outfile.getOutputFile()); - return result; - }; - - Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { - var constructorDecl = getLastConstructor(this.thisClassNode); - - 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(); - this.recordSourceMappingStart(parameter); - this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); - this.writeToOutput(" = "); - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(parameter); - } - } - } - - for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { - if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = this.thisClassNode.classElements.childAt(i); - if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitIndent(); - this.emitMemberVariableDeclaration(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.isOnSameLine = function (pos1, pos2) { - var lineMap = this.document.lineMap(); - return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); - }; - - Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { - if (list === null || list.nonSeparatorCount() === 0) { - return; - } - - var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); - - if (preserveNewLines) { - this.indenter.increaseIndent(); - } - - if (startLine) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(buffer); - } - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - var emitNode = list.nonSeparatorAt(i); - - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); - if (startLine) { - this.writeLineToOutput(","); - } else { - this.writeToOutput(", "); - } - } - } - - if (preserveNewLines) { - this.indenter.decreaseIndent(); - } - - if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(buffer); - } - }; - - Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.nonSeparatorAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.kind() === 14 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { - return; - } - - var lineMap = this.document.lineMap(); - var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput("", true); - } - }; - - Emitter.prototype.getDetachedComments = function (element) { - var preComments = element.preComments(); - if (preComments) { - var lineMap = this.document.lineMap(); - - var detachedComments = []; - var lastComment = null; - - for (var i = 0, n = preComments.length; i < n; i++) { - var comment = preComments[i]; - - if (lastComment) { - var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); - var commentLine = lineMap.getLineNumberFromPosition(comment.start()); - - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - detachedComments.push(comment); - lastComment = comment; - } - - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); - var astLine = lineMap.getLineNumberFromPosition(element.start()); - if (astLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - return []; - }; - - Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - this.emitDetachedComments(script.moduleElements); - }; - - Emitter.prototype.emitDetachedComments = function (list) { - if (list.childCount() > 0) { - var firstElement = list.childAt(0); - - this.detachedCommentsElement = firstElement; - this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); - } - }; - - Emitter.prototype.emitScriptElements = function (sourceUnit) { - var list = sourceUnit.moduleElements; - - this.emitPossibleCopyrightHeaders(sourceUnit); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var node = list.childAt(i); - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(sourceUnit); - - var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); - if (isNonElidedExternalModule) { - this.recordSourceMappingStart(sourceUnit); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } - - if (isExternalModule) { - var temp = this.setContainer(2 /* DynamicModule */); - - var svModuleName = this.moduleName; - this.moduleName = sourceUnit.fileName(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - - this.setExportAssignment(null); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); - - if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { - this.writeCaptureThisStatement(sourceUnit); - } - - this.pushDecl(externalModule); - } - - this.emitList(list, true, i, n); - - if (isExternalModule) { - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - - if (isNonElidedExternalModule) { - var exportAssignment = this.getExportAssignment(); - var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; - var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); - this.writeLineToOutput(";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(sourceUnit); - this.writeLineToOutput(""); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - this.popDecl(externalModule); - } - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - this.emit(ast); - }; - - Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { - if (funcDecl.kind() !== 139 /* GetAccessor */) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - - this.writeToOutput("Object.defineProperty(" + className); - if (isProto) { - this.writeToOutput(".prototype, "); - } else { - this.writeToOutput(", "); - } - - var functionName = name.text(); - if (TypeScript.isQuoted(functionName)) { - this.writeToOutput(functionName); - } else { - this.writeToOutput('"' + functionName + '"'); - } - - this.writeLineToOutput(", {"); - - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.emitComments(accessors.getter, true); - this.writeToOutput("get: "); - this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.emitComments(accessors.setter, true); - this.writeToOutput("set: "); - this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.identifier.text(); - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; - var baseTypeReference = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); - this.writeLineToOutput(";"); - } - - this.emitIndent(); - - var constrDecl = getLastConstructor(classDecl); - - if (constrDecl) { - this.emit(constrDecl); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); - this.writeLineToOutput(";"); - } - - if (this.shouldCaptureThis(classDecl)) { - this.writeCaptureThisStatement(classDecl); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.writeLineToOutput(""); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.emitJavascript(baseTypeReference, false); - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 139 /* GetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var getter = memberDecl; - this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 140 /* SetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var setter = memberDecl; - this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { - var memberFunction = memberDecl; - - if (memberFunction.block) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - - this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); - lastEmittedMember = memberDecl; - } - } - } - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = memberDecl; - - if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); - } else { - this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); - } - - this.emit(varDecl.variableDeclarator.equalsValueClause); - - this.recordSourceMappingEnd(varDecl); - this.writeLineToOutput(";"); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - var functionName = funcDecl.propertyName.text(); - - this.writeToOutput(classDecl.identifier.text()); - - if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - this.writeToOutput(".prototype"); - } - - if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput("[" + functionName + "] = "); - } else { - this.writeToOutput("." + functionName + " = "); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - - this.writeLineToOutput(";"); - }; - - Emitter.prototype.requiresExtendsBlock = function (moduleElements) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - - if (moduleElement.kind() === 130 /* ModuleDeclaration */) { - var moduleAST = moduleElement; - - if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { - return true; - } - } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { - var classDeclaration = moduleElement; - - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitPrologue = function (sourceUnit) { - if (!this.extendsPrologueEmitted) { - if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(sourceUnit)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitThis = function () { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.kind() === 146 /* Block */) { - this.emit(node); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitLiteralExpression = function (expression) { - switch (expression.kind()) { - case 32 /* NullKeyword */: - this.writeToOutputWithSourceMapRecord("null", expression); - break; - case 24 /* FalseKeyword */: - this.writeToOutputWithSourceMapRecord("false", expression); - break; - case 37 /* TrueKeyword */: - this.writeToOutputWithSourceMapRecord("true", expression); - break; - default: - throw TypeScript.Errors.abstract(); - } - }; - - Emitter.prototype.emitThisExpression = function (expression) { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutputWithSourceMapRecord("_this", expression); - } else { - this.writeToOutputWithSourceMapRecord("this", expression); - } - }; - - Emitter.prototype.emitSuperExpression = function (expression) { - this.writeToOutputWithSourceMapRecord("_super.prototype", expression); - }; - - Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { - if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { - this.emit(parenthesizedExpression.expression); - } else { - this.recordSourceMappingStart(parenthesizedExpression); - this.writeToOutput("("); - this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); - this.emit(parenthesizedExpression.expression); - this.writeToOutput(")"); - this.recordSourceMappingEnd(parenthesizedExpression); - } - }; - - Emitter.prototype.emitCastExpression = function (expression) { - this.emit(expression.expression); - }; - - Emitter.prototype.emitPrefixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 167 /* LogicalNotExpression */: - this.writeToOutput("!"); - this.emit(expression.operand); - break; - case 166 /* BitwiseNotExpression */: - this.writeToOutput("~"); - this.emit(expression.operand); - break; - case 165 /* NegateExpression */: - this.writeToOutput("-"); - if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 164 /* PlusExpression */: - this.writeToOutput("+"); - if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 168 /* PreIncrementExpression */: - this.writeToOutput("++"); - this.emit(expression.operand); - break; - case 169 /* PreDecrementExpression */: - this.writeToOutput("--"); - this.emit(expression.operand); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitPostfixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 210 /* PostIncrementExpression */: - this.emit(expression.operand); - this.writeToOutput("++"); - break; - case 211 /* PostDecrementExpression */: - this.emit(expression.operand); - this.writeToOutput("--"); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitTypeOfExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("typeof "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDeleteExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("delete "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitVoidExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("void "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { - var memberExpressionNodeType = expression.expression.kind(); - - 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 */) { - return this.canEmitDottedNameMemberAccessExpression(expression.expression); - } - - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { - this.recordSourceMappingStart(expression); - if (expression.expression.kind() === 212 /* MemberAccessExpression */) { - this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); - } else { - this.emitComments(expression.expression, true); - this.recordSourceMappingStart(expression.expression); - - this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); - - this.writeToOutput(expression.expression.text()); - - this.recordSourceMappingEnd(expression.expression); - this.emitComments(expression.expression, false); - } - - this.writeToOutput("."); - this.emitName(expression.name, false); - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { - this.emitComments(expression, true); - - if (lastIndex - startingIndex < 1) { - startingIndex = lastIndex - 1; - TypeScript.Debug.assert(startingIndex >= 0); - } - - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); - this.emitComments(expression, false); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { - var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; - - var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); - }; - - Emitter.prototype.emitMemberAccessExpression = function (expression) { - if (!this.tryEmitConstant(expression)) { - if (this.canEmitDottedNameMemberAccessExpression(expression)) { - this.emitDottedNameMemberAccessExpression(expression); - } else { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("."); - this.emitName(expression.name, false); - this.recordSourceMappingEnd(expression); - } - } - }; - - Emitter.prototype.emitQualifiedName = function (name) { - this.recordSourceMappingStart(name); - - this.emit(name.left); - this.writeToOutput("."); - this.emitName(name.right, false); - - this.recordSourceMappingEnd(name); - }; - - Emitter.prototype.emitBinaryExpression = function (expression) { - this.recordSourceMappingStart(expression); - switch (expression.kind()) { - case 173 /* CommaExpression */: - this.emit(expression.left); - this.writeToOutput(", "); - this.emit(expression.right); - break; - default: { - this.emit(expression.left); - var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); - if (binOp === "instanceof") { - this.writeToOutput(" instanceof "); - } else if (binOp === "in") { - this.writeToOutput(" in "); - } else { - this.writeToOutput(" " + binOp + " "); - } - this.emit(expression.right); - } - } - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimplePropertyAssignment = function (property) { - this.recordSourceMappingStart(property); - this.emit(property.propertyName); - this.writeToOutput(": "); - this.emit(property.expression); - this.recordSourceMappingEnd(property); - }; - - Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { - this.recordSourceMappingStart(funcProp); - - this.emit(funcProp.propertyName); - this.writeToOutput(": "); - - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); - - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - var funcName = funcProp.propertyName; - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcProp); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); - - this.recordSourceMappingEnd(funcProp); - - this.recordSourceMappingEnd(funcProp); - - this.emitComments(funcProp, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConditionalExpression = function (expression) { - this.emit(expression.condition); - this.writeToOutput(" ? "); - this.emit(expression.whenTrue); - this.writeToOutput(" : "); - this.emit(expression.whenFalse); - }; - - Emitter.prototype.emitThrowStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("throw "); - this.emit(statement.expression); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitExpressionStatement = function (statement) { - var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; - - this.recordSourceMappingStart(statement); - if (isArrowExpression) { - this.writeToOutput("("); - } - - this.emit(statement.expression); - - if (isArrowExpression) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitLabeledStatement = function (statement) { - this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); - this.writeLineToOutput(":"); - this.emitJavascript(statement.statement, true); - }; - - Emitter.prototype.emitBlock = function (block) { - this.recordSourceMappingStart(block); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - if (block.statements) { - this.emitList(block.statements); - } - this.emitCommentsArray(block.closeBraceLeadingComments, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(block); - }; - - Emitter.prototype.emitBreakStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("break"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitContinueStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("continue"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitWhileStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("while ("); - this.emit(statement.condition); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitDoStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("do"); - this.emitBlockOrStatement(statement.statement); - this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); - this.writeToOutput('('); - this.emit(statement.condition); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitIfStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("if ("); - this.emit(statement.condition); - this.writeToOutput(")"); - - this.emitBlockOrStatement(statement.statement); - - if (statement.elseClause) { - if (statement.statement.kind() !== 146 /* Block */) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - - this.emit(statement.elseClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitElseClause = function (elseClause) { - if (elseClause.statement.kind() === 147 /* IfStatement */) { - this.writeToOutput("else "); - this.emit(elseClause.statement); - } else { - this.writeToOutput("else"); - this.emitBlockOrStatement(elseClause.statement); - } - }; - - Emitter.prototype.emitReturnStatement = function (statement) { - this.recordSourceMappingStart(statement); - if (statement.expression) { - this.writeToOutput("return "); - this.emit(statement.expression); - } else { - this.writeToOutput("return"); - } - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitForInStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.left) { - this.emit(statement.left); - } else { - this.emit(statement.variableDeclaration); - } - this.writeToOutput(" in "); - this.emit(statement.expression); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitForStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.variableDeclaration) { - this.emit(statement.variableDeclaration); - } else if (statement.initializer) { - this.emit(statement.initializer); - } - - this.writeToOutput("; "); - this.emitJavascript(statement.condition, false); - this.writeToOutput(";"); - if (statement.incrementor) { - this.writeToOutput(" "); - this.emitJavascript(statement.incrementor, false); - } - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitWithStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("with ("); - if (statement.condition) { - this.emit(statement.condition); - } - - this.writeToOutput(")"); - var prevInWithBlock = this.inWithBlock; - this.inWithBlock = true; - this.emitBlockOrStatement(statement.statement); - this.inWithBlock = prevInWithBlock; - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitSwitchStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("switch ("); - this.emit(statement.expression); - this.recordSourceMappingStart(statement.closeParenToken); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement.closeParenToken); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - this.emitList(statement.switchClauses, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCaseSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("case "); - this.emit(clause.expression); - this.writeToOutput(":"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitSwitchClauseBody = function (body) { - if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { - this.emit(body.childAt(0)); - this.writeLineToOutput(""); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emit(body); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitDefaultSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("default:"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitTryStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("try "); - this.emit(statement.block); - this.emitJavascript(statement.catchClause, false); - - if (statement.finallyClause) { - this.emit(statement.finallyClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCatchClause = function (clause) { - this.writeToOutput(" "); - this.recordSourceMappingStart(clause); - this.writeToOutput("catch ("); - this.emit(clause.identifier); - this.writeToOutput(")"); - this.emit(clause.block); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitFinallyClause = function (clause) { - this.writeToOutput(" finally"); - this.emit(clause.block); - }; - - Emitter.prototype.emitDebuggerStatement = function (statement) { - this.writeToOutputWithSourceMapRecord("debugger", statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitNumericLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitRegularExpressionLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitStringLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitEqualsValueClause = function (clause) { - this.writeToOutput(" = "); - this.emit(clause.value); - }; - - Emitter.prototype.emitParameter = function (parameter) { - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); - }; - - Emitter.prototype.emitConstructorDeclaration = function (declaration) { - if (declaration.block) { - this.emitConstructor(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { - return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); - }; - - Emitter.prototype.emitFunctionDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { - this.emitFunction(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.emitSourceUnit = function (sourceUnit) { - if (!this.document.isDeclareFile()) { - var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); - this.pushDecl(pullDecl); - this.emitScriptElements(sourceUnit); - this.popDecl(pullDecl); - - this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); - } - }; - - Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); - }; - - Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { - this.emitComments(declaration, true); - this.emitEnum(declaration); - this.emitComments(declaration, false); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); - }; - - Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { - this.emitModuleDeclarationWorker(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); - }; - - Emitter.prototype.emitClassDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { - this.emitClass(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { - return declaration.preComments() !== null; - }; - - Emitter.prototype.emitInterfaceDeclaration = function (declaration) { - this.emitComments(declaration, true, true); - }; - - Emitter.prototype.firstVariableDeclarator = function (statement) { - return statement.declaration.declarators.nonSeparatorAt(0); - }; - - Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { - return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; - }; - - Emitter.prototype.shouldEmitVariableStatement = function (statement) { - return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); - }; - - Emitter.prototype.emitVariableStatement = function (statement) { - if (this.isNotAmbientOrHasInitializer(statement)) { - this.emitComments(statement, true); - this.emit(statement.declaration); - this.writeToOutput(";"); - this.emitComments(statement, false); - } else { - this.emitComments(statement, true, true); - } - }; - - Emitter.prototype.emitGenericType = function (type) { - this.emit(type.name); - }; - - Emitter.prototype.shouldEmit = function (ast) { - if (!ast) { - return false; - } - - switch (ast.kind()) { - case 133 /* ImportDeclaration */: - return this.shouldEmitImportDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.shouldEmitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.shouldEmitInterfaceDeclaration(ast); - case 129 /* FunctionDeclaration */: - return this.shouldEmitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.shouldEmitModuleDeclaration(ast); - case 148 /* VariableStatement */: - return this.shouldEmitVariableStatement(ast); - case 223 /* OmittedExpression */: - return false; - case 132 /* EnumDeclaration */: - return this.shouldEmitEnumDeclaration(ast); - } - - return true; - }; - - Emitter.prototype.emit = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 2 /* SeparatedList */: - return this.emitSeparatedList(ast); - case 1 /* List */: - return this.emitList(ast); - case 120 /* SourceUnit */: - return this.emitSourceUnit(ast); - case 133 /* ImportDeclaration */: - return this.emitImportDeclaration(ast); - case 134 /* ExportAssignment */: - return this.setExportAssignment(ast); - case 131 /* ClassDeclaration */: - return this.emitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitInterfaceDeclaration(ast); - case 11 /* IdentifierName */: - return this.emitName(ast, true); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast); - case 219 /* SimpleArrowFunctionExpression */: - return this.emitSimpleArrowFunctionExpression(ast); - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.emitParenthesizedArrowFunctionExpression(ast); - case 129 /* FunctionDeclaration */: - return this.emitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitModuleDeclaration(ast); - case 224 /* VariableDeclaration */: - return this.emitVariableDeclaration(ast); - case 126 /* GenericType */: - return this.emitGenericType(ast); - case 137 /* ConstructorDeclaration */: - return this.emitConstructorDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitEnumDeclaration(ast); - case 243 /* EnumElement */: - return this.emitEnumElement(ast); - case 222 /* FunctionExpression */: - return this.emitFunctionExpression(ast); - case 148 /* VariableStatement */: - return this.emitVariableStatement(ast); - } - - this.emitComments(ast, true); - this.emitWorker(ast); - this.emitComments(ast, false); - }; - - Emitter.prototype.emitWorker = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 13 /* NumericLiteral */: - return this.emitNumericLiteral(ast); - case 12 /* RegularExpressionLiteral */: - return this.emitRegularExpressionLiteral(ast); - case 14 /* StringLiteral */: - return this.emitStringLiteral(ast); - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 37 /* TrueKeyword */: - return this.emitLiteralExpression(ast); - case 35 /* ThisKeyword */: - return this.emitThisExpression(ast); - case 50 /* SuperKeyword */: - return this.emitSuperExpression(ast); - case 217 /* ParenthesizedExpression */: - return this.emitParenthesizedExpression(ast); - case 214 /* ArrayLiteralExpression */: - return this.emitArrayLiteralExpression(ast); - case 211 /* PostDecrementExpression */: - case 210 /* PostIncrementExpression */: - return this.emitPostfixUnaryExpression(ast); - case 167 /* LogicalNotExpression */: - case 166 /* BitwiseNotExpression */: - case 165 /* NegateExpression */: - case 164 /* PlusExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.emitPrefixUnaryExpression(ast); - case 213 /* InvocationExpression */: - return this.emitInvocationExpression(ast); - case 221 /* ElementAccessExpression */: - return this.emitElementAccessExpression(ast); - case 212 /* MemberAccessExpression */: - return this.emitMemberAccessExpression(ast); - case 121 /* QualifiedName */: - return this.emitQualifiedName(ast); - case 173 /* CommaExpression */: - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* LogicalOrExpression */: - case 188 /* LogicalAndExpression */: - case 189 /* BitwiseOrExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 191 /* BitwiseAndExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return this.emitBinaryExpression(ast); - case 186 /* ConditionalExpression */: - return this.emitConditionalExpression(ast); - case 232 /* EqualsValueClause */: - return this.emitEqualsValueClause(ast); - case 242 /* Parameter */: - return this.emitParameter(ast); - case 146 /* Block */: - return this.emitBlock(ast); - case 235 /* ElseClause */: - return this.emitElseClause(ast); - case 147 /* IfStatement */: - return this.emitIfStatement(ast); - case 149 /* ExpressionStatement */: - return this.emitExpressionStatement(ast); - case 139 /* GetAccessor */: - return this.emitGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitSetAccessor(ast); - case 157 /* ThrowStatement */: - return this.emitThrowStatement(ast); - case 150 /* ReturnStatement */: - return this.emitReturnStatement(ast); - case 216 /* ObjectCreationExpression */: - return this.emitObjectCreationExpression(ast); - case 151 /* SwitchStatement */: - return this.emitSwitchStatement(ast); - case 233 /* CaseSwitchClause */: - return this.emitCaseSwitchClause(ast); - case 234 /* DefaultSwitchClause */: - return this.emitDefaultSwitchClause(ast); - case 152 /* BreakStatement */: - return this.emitBreakStatement(ast); - case 153 /* ContinueStatement */: - return this.emitContinueStatement(ast); - case 154 /* ForStatement */: - return this.emitForStatement(ast); - case 155 /* ForInStatement */: - return this.emitForInStatement(ast); - case 158 /* WhileStatement */: - return this.emitWhileStatement(ast); - case 163 /* WithStatement */: - return this.emitWithStatement(ast); - case 220 /* CastExpression */: - return this.emitCastExpression(ast); - case 215 /* ObjectLiteralExpression */: - return this.emitObjectLiteralExpression(ast); - case 240 /* SimplePropertyAssignment */: - return this.emitSimplePropertyAssignment(ast); - case 241 /* FunctionPropertyAssignment */: - return this.emitFunctionPropertyAssignment(ast); - case 156 /* EmptyStatement */: - return this.writeToOutputWithSourceMapRecord(";", ast); - case 159 /* TryStatement */: - return this.emitTryStatement(ast); - case 236 /* CatchClause */: - return this.emitCatchClause(ast); - case 237 /* FinallyClause */: - return this.emitFinallyClause(ast); - case 160 /* LabeledStatement */: - return this.emitLabeledStatement(ast); - case 161 /* DoStatement */: - return this.emitDoStatement(ast); - case 171 /* TypeOfExpression */: - return this.emitTypeOfExpression(ast); - case 170 /* DeleteExpression */: - return this.emitDeleteExpression(ast); - case 172 /* VoidExpression */: - return this.emitVoidExpression(ast); - case 162 /* DebuggerStatement */: - return this.emitDebuggerStatement(ast); - } - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; - - function getLastConstructor(classDecl) { - return classDecl.classElements.lastOrDefault(function (e) { - return e.kind() === 137 /* ConstructorDeclaration */; - }); - } - TypeScript.getLastConstructor = getLastConstructor; - - function getTrimmedTextLines(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - return comment.fullText().split("\n").map(function (s) { - return s.trim(); - }); - } else { - return [comment.fullText().trim()]; - } - } - TypeScript.getTrimmedTextLines = getTrimmedTextLines; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += memberName.text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripStartAndEndQuotes(str) { - var firstCharCode = str && str.charCodeAt(0); - if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - return str.substring(1, str.length - 1); - } - - return str; - } - TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; - - function isSingleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isDoubleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; - } - TypeScript.isDoubleQuoted = isDoubleQuoted; - - function isQuoted(str) { - return isDoubleQuoted(str) || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - var switchToForwardSlashesRegEx = /\\/g; - function switchToForwardSlashes(path) { - return path.replace(switchToForwardSlashesRegEx, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { - if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { - absoluteModPath = "file:///" + absoluteModPath; - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function changePathToDTS(modPath) { - return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.length > 0 && path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function convertToDirectoryPath(dirPath) { - if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { - dirPath += "/"; - } - - return dirPath; - } - TypeScript.convertToDirectoryPath = convertToDirectoryPath; - - var normalizePathRegEx = /^\\\\[^\\]/; - function normalizePath(path) { - if (normalizePathRegEx.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - function isNoDefaultLibMatch(comment) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - return isNoDefaultLibRegex.exec(comment); - } - - TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; - - function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { - var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } - } - } - - return null; - } - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - var start = new Date().getTime(); - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 107 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 72 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionScanImportsTime += totalTime; - } - - function processTripleSlashDirectives(fileName, lineMap, firstToken) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - var diagnostics = []; - var referencedFiles = []; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - var isNoDefaultLib = isNoDefaultLibMatch(triviaText); - if (isNoDefaultLib) { - noDefaultLib = isNoDefaultLib[3] === "true"; - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; - } - - function preProcessFile(fileName, sourceText, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); - - scannerDiagnostics.length = 0; - return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); - } - TypeScript.getParseOptions = getParseOptions; - - function getReferencedFiles(fileName, sourceText) { - return preProcessFile(fileName, sourceText, false).referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ReferenceResolutionResult = (function () { - function ReferenceResolutionResult() { - this.resolvedFiles = []; - this.diagnostics = []; - this.seenNoDefaultLibTag = false; - } - return ReferenceResolutionResult; - })(); - TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; - - var ReferenceLocation = (function () { - function ReferenceLocation(filePath, lineMap, position, length, isImported) { - this.filePath = filePath; - this.lineMap = lineMap; - this.position = position; - this.length = length; - this.isImported = isImported; - } - return ReferenceLocation; - })(); - - var ReferenceResolver = (function () { - function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { - this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this.inputFileNames = inputFileNames; - this.host = host; - this.visited = {}; - } - ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { - var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); - return resolver.resolveInputFiles(); - }; - - ReferenceResolver.prototype.resolveInputFiles = function () { - var _this = this; - var result = new ReferenceResolutionResult(); - - if (!this.inputFileNames || this.inputFileNames.length <= 0) { - return result; - } - - var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); - this.inputFileNames.forEach(function (fileName) { - return _this.resolveIncludedFile(fileName, referenceLocation, result); - }); - - return result; - }; - - ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { - var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); - - if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); - } - - return normalizedPath; - } - - if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { - var dtsFile = normalizedPath + ".d.ts"; - var tsFile = normalizedPath + ".ts"; - - if (this.host.fileExists(tsFile)) { - normalizedPath = tsFile; - } else { - normalizedPath = dtsFile; - } - } - - if (!this.host.fileExists(normalizedPath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); - } - - return normalizedPath; - } - - return this.resolveFile(normalizedPath, resolutionResult); - }; - - ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { - var isRelativePath = TypeScript.isRelative(path); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); - - if (isRelativePath || isRootedPath) { - return this.resolveIncludedFile(path, referenceLocation, resolutionResult); - } else { - var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); - var searchFilePath = null; - var dtsFileName = path + ".d.ts"; - var tsFilePath = path + ".ts"; - - var start = new Date().getTime(); - - do { - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - parentDirectory = this.host.getParentDirectory(parentDirectory); - } while(parentDirectory); - - TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; - - if (!searchFilePath) { - return path; - } - - return this.resolveFile(searchFilePath, resolutionResult); - } - }; - - ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { - var _this = this; - var visitedPath = this.isVisited(normalizedPath); - if (!visitedPath) { - this.recordVisitedFile(normalizedPath); - - var start = new Date().getTime(); - var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionIOTime += totalTime; - - var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); - var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); - resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); - - if (preprocessedFileInformation.isLibFile) { - resolutionResult.seenNoDefaultLibTag = true; - } - - var normalizedReferencePaths = []; - preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); - var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); - normalizedReferencePaths.push(normalizedReferencePath); - }); - - var normalizedImportPaths = []; - for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { - var fileImport = preprocessedFileInformation.importedFiles[i]; - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); - var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); - normalizedImportPaths.push(normalizedImportPath); - } - - resolutionResult.resolvedFiles.push({ - path: normalizedPath, - referencedFiles: normalizedReferencePaths, - importedFiles: normalizedImportPaths - }); - } else { - normalizedPath = visitedPath; - } - - return normalizedPath; - }; - - ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { - var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; - var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); - return normalizedPath; - }; - - ReferenceResolver.prototype.getUniqueFileId = function (filePath) { - return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); - }; - - ReferenceResolver.prototype.recordVisitedFile = function (filePath) { - this.visited[this.getUniqueFileId(filePath)] = filePath; - }; - - ReferenceResolver.prototype.isVisited = function (filePath) { - return this.visited[this.getUniqueFileId(filePath)]; - }; - - ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { - if (!filePath1 || !filePath2) { - return false; - } - - if (this.useCaseSensitiveFileResolution) { - return filePath1 === filePath2; - } else { - return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); - } - }; - return ReferenceResolver; - })(); - TypeScript.ReferenceResolver = ReferenceResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(name, writeByteOrderMark, outputFileType) { - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.outputFileType = outputFileType; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += TypeScript.newLine(); - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - }; - - TextWriter.prototype.getOutputFile = function () { - return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.document = document; - this.compiler = compiler; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.emittedReferencePaths = false; - this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); - } - DeclarationEmitter.prototype.getOutputFile = function () { - return this.declFile.getOutputFile(); - }; - - DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { - this.emitDeclarationsForSourceUnit(sourceUnit); - }; - - DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.emitDeclarationsForAST(list.childAt(i)); - } - }; - - DeclarationEmitter.prototype.emitSeparatedList = function (list) { - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.emitDeclarationsForAST(list.nonSeparatorAt(i)); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { - switch (ast.kind()) { - case 148 /* VariableStatement */: - return this.emitDeclarationsForVariableStatement(ast); - case 141 /* PropertySignature */: - return this.emitPropertySignature(ast); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast, true, true); - case 136 /* MemberVariableDeclaration */: - return this.emitDeclarationsForMemberVariableDeclaration(ast); - case 137 /* ConstructorDeclaration */: - return this.emitDeclarationsForConstructorDeclaration(ast); - case 139 /* GetAccessor */: - return this.emitDeclarationsForGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitDeclarationsForSetAccessor(ast); - case 138 /* IndexMemberDeclaration */: - return this.emitIndexMemberDeclaration(ast); - case 144 /* IndexSignature */: - return this.emitIndexSignature(ast); - case 142 /* CallSignature */: - return this.emitCallSignature(ast); - case 143 /* ConstructSignature */: - return this.emitConstructSignature(ast); - case 145 /* MethodSignature */: - return this.emitMethodSignature(ast); - case 129 /* FunctionDeclaration */: - return this.emitDeclarationsForFunctionDeclaration(ast); - case 135 /* MemberFunctionDeclaration */: - return this.emitMemberFunctionDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.emitDeclarationsForClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitDeclarationsForInterfaceDeclaration(ast); - case 133 /* ImportDeclaration */: - return this.emitDeclarationsForImportDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitDeclarationsForModuleDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitDeclarationsForEnumDeclaration(ast); - case 134 /* ExportAssignment */: - return this.emitDeclarationsForExportAssignment(ast); - } - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - return this.indenter.getIndent(); - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { - var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { - var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - var start = new Date().getTime(); - var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); - var result = declSymbol && declSymbol.isExternallyVisible(); - TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; - - return result; - } - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { - var result = this.getIndentString(); - var pullFlags = pullDecl.flags; - - if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); - - var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); - var container = this.getEnclosingContainer(declAST); - - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { - container = this.getEnclosingContainer(container); - } - - var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); - - if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (isExternalModule || container.kind() === 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString !== "import") { - result += "declare "; - } - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { - this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { - var declarationContainerAst = this.getEnclosingContainer(ast); - - var start = new Date().getTime(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); - - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - - var isNotAGenericType = ast.kind() !== 126 /* GenericType */; - - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = TypeScript.getTrimmedTextLines(comment); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { - var start = new Date().getTime(); - var decl = this.semanticInfoChain.getDeclForAST(boundDecl); - var pullSymbol = decl.getSymbol(); - TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; - - var type = pullSymbol.type; - TypeScript.Debug.assert(type); - - this.declFile.Write(": "); - this.emitTypeSignature(boundDecl, type); - }; - - DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { - this.emitDeclarationComments(varDecl); - this.emitIndent(); - this.declFile.Write(varDecl.propertyName.text()); - if (varDecl.questionToken) { - this.declFile.Write("?"); - } - - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - if (isFirstVarInList) { - this.emitDeclFlags(varDecl, "var"); - } - - this.declFile.Write(varDecl.propertyName.text()); - - if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - if (isLastVarInList) { - this.declFile.WriteLine(";"); - } else { - this.declFile.Write(", "); - } - } - }; - - DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { - if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } - this.declFile.Write("static "); - } else { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } else { - this.declFile.Write("public "); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(varDecl.modifiers); - ; - - this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); - - if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - this.declFile.WriteLine(";"); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { - this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); - }; - - 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); - } - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(id.text()); - if (isOptional) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (!isPrivate) { - this.emitTypeOfVariableDeclaratorOrParameter(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var start = new Date().getTime(); - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - var signatures = funcTypeSymbol.getCallSignatures(); - var result = signatures && signatures.length > 1; - - return result; - }; - - DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("constructor"); - - this.declFile.Write("("); - 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.ASTHelpers.parametersFromParameterList(parameterList)); - this.declFile.Write(")"); - }; - - DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { - var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); - var argsLen = parameterList.length; - if (hasLastParameterRestParameter) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - - if (hasLastParameterRestParameter) { - if (parameterList.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - var index = parameterList.length - 1; - this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); - } - }; - - DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitDeclFlags(funcDecl, "function"); - var id = funcDecl.propertyName.text(); - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); - - this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); - - if (!isPrivate) { - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - this.emitDeclarationComments(funcDecl); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); - - this.emitIndent(); - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("new"); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write(funcDecl.propertyName.text()); - if (funcDecl.questionToken) { - this.declFile.Write("? "); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - if (funcDecl.block) { - var funcTypeSymbol = funcSymbol.type; - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - var id = funcDecl.identifier.text(); - this.emitDeclFlags(funcDecl, "function"); - if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { - this.declFile.Write(id); - } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { - this.declFile.Write("new"); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { - this.emitDeclarationsForAST(funcDecl.indexSignature); - }; - - DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("["); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); - this.declFile.Write("]"); - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { - if (bases && (bases.nonSeparatorCount() > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.nonSeparatorCount(); - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - var base = bases.nonSeparatorAt(i); - var baseType = this.semanticInfoChain.getSymbolForAST(base); - this.emitTypeSignature(base, baseType); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var start = new Date().getTime(); - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - var comments = []; - if (accessors.getter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); - } - if (accessors.setter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); - } - - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { - var start = new Date().getTime(); - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { - return; - } - - var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); - this.emitAccessorDeclarationComments(funcDecl); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(modifiers); - this.declFile.Write(name.text()); - if (!isPrivate) { - this.declFile.Write(" : "); - var type = accessorSymbol.type; - this.emitTypeSignature(funcDecl, type); - } - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { - argsLen--; - } - - 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(";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { - if (!this.canEmitDeclarations(classDecl)) { - return; - } - - var className = classDecl.identifier.text(); - this.emitDeclarationComments(classDecl); - var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.emitDeclFlags(classDecl, "class"); - this.declFile.Write(className); - - this.emitTypeParameters(classDecl.typeParameterList); - this.emitHeritageClauses(classDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - var constructorDecl = TypeScript.getLastConstructor(classDecl); - if (constructorDecl) { - this.emitClassMembersFromConstructorDefinition(constructorDecl); - } - - this.emitDeclarationsForList(classDecl.classElements); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { - if (clauses) { - for (var i = 0, n = clauses.childCount(); i < n; i++) { - this.emitHeritageClause(clauses.childAt(i)); - } - } - }; - - DeclarationEmitter.prototype.emitHeritageClause = function (clause) { - this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); - }; - - DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getEnclosingContainer(typeParams); - - var start = new Date().getTime(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); - var containerSymbol = containerDecl.getSymbol(); - TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; - - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArgumentsOrTypeParameters(); - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { - if (!this.canEmitDeclarations(interfaceDecl)) { - return; - } - - var interfaceName = interfaceDecl.identifier.text(); - this.emitDeclarationComments(interfaceDecl); - var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); - this.emitDeclFlags(interfaceDecl, "interface"); - this.declFile.Write(interfaceName); - - this.emitTypeParameters(interfaceDecl.typeParameterList); - this.emitHeritageClauses(interfaceDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - - this.emitSeparatedList(interfaceDecl.body.typeMembers); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); - var importSymbol = importDecl.getSymbol(); - var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); - - if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - if (isExportedImportDecl) { - this.declFile.Write("export "); - } - this.declFile.Write("import "); - this.declFile.Write(importDeclAST.identifier.text() + " = "); - if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); - } else { - this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - this.emitDeclarationComments(moduleDecl); - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclFlags(moduleDecl, "enum"); - this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.enumElements.nonSeparatorCount(); - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); - var enumElement = memberDecl; - var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); - this.emitDeclarationComments(enumElement); - this.emitIndent(); - this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue !== null) { - this.declFile.Write(" = " + enumElementDecl.constantValue); - } - this.declFile.WriteLine(","); - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclarationComments(moduleDecl); - - var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); - this.emitDeclFlags(name, "module"); - - if (moduleDecl.stringLiteral) { - this.declFile.Write(moduleDecl.stringLiteral.text()); - } else { - this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); - } - - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - - this.emitDeclarationsForList(moduleDecl.moduleElements); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write(ast.identifier.text()); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { - if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { - return reference; - } - - var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); - var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); - return resolvedReferencePath; - }; - - DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { - if (this.emittedReferencePaths) { - return; - } - - var documents = []; - if (this.document.emitToOwnOutputFile()) { - var scriptReferences = this.document.referencedFiles; - var addedGlobalDocument = false; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { - documents = documents.concat(document); - - if (!document.isDeclareFile() && document.isExternalModule()) { - addedGlobalDocument = true; - } - } - } - } else { - var fileNames = this.compiler.fileNames(); - for (var i = 0; i < fileNames.length; i++) { - var doc = this.compiler.getDocument(fileNames[i]); - if (!doc.isDeclareFile() && !doc.isExternalModule()) { - var scriptReferences = doc.referencedFiles; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.isDeclareFile() || document.isExternalModule())) { - for (var k = 0; k < documents.length; k++) { - if (documents[k] === document) { - break; - } - } - - if (k === documents.length) { - documents = documents.concat(document); - } - } - } - } - } - } - - var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; - for (var i = 0; i < documents.length; i++) { - var document = documents[i]; - var declFileName; - if (document.isDeclareFile()) { - declFileName = document.fileName; - } else { - declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } - - declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); - this.declFile.WriteLine('/// '); - } - - this.emittedReferencePaths = true; - }; - - DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { - this.emitReferencePaths(sourceUnit); - this.emitDeclarationsForList(sourceUnit.moduleElements); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - if (keys[name]) { - this.add(name); - } - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] !== array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateEnumConstants = false; - this.removeComments = false; - this.watch = false; - this.noResolve = false; - this.allowAutomaticSemicolonInsertion = true; - this.noImplicitAny = false; - this.noLib = false; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Unspecified */; - this.outFileOption = ""; - this.outDirOption = ""; - this.mapSourceFiles = false; - this.mapRoot = ""; - this.sourceRoot = ""; - this.generateDeclarationFiles = false; - 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, createFileLog) { - this._propagateEnumConstants = propagateEnumConstants; - this._removeComments = removeComments; - this._watch = watch; - this._noResolve = noResolve; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._noImplicitAny = noImplicitAny; - this._noLib = noLib; - this._codeGenTarget = codeGenTarget; - this._moduleGenTarget = moduleGenTarget; - this._outFileOption = outFileOption; - this._outDirOption = outDirOption; - this._mapSourceFiles = mapSourceFiles; - this._mapRoot = mapRoot; - this._sourceRoot = sourceRoot; - this._generateDeclarationFiles = generateDeclarationFiles; - this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this._gatherDiagnostics = gatherDiagnostics; - this._codepage = codepage; - this._createFileLog = createFileLog; - } - ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { - return this._propagateEnumConstants; - }; - ImmutableCompilationSettings.prototype.removeComments = function () { - return this._removeComments; - }; - ImmutableCompilationSettings.prototype.watch = function () { - return this._watch; - }; - ImmutableCompilationSettings.prototype.noResolve = function () { - return this._noResolve; - }; - ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - ImmutableCompilationSettings.prototype.noImplicitAny = function () { - return this._noImplicitAny; - }; - ImmutableCompilationSettings.prototype.noLib = function () { - return this._noLib; - }; - ImmutableCompilationSettings.prototype.codeGenTarget = function () { - return this._codeGenTarget; - }; - ImmutableCompilationSettings.prototype.moduleGenTarget = function () { - return this._moduleGenTarget; - }; - ImmutableCompilationSettings.prototype.outFileOption = function () { - return this._outFileOption; - }; - ImmutableCompilationSettings.prototype.outDirOption = function () { - return this._outDirOption; - }; - ImmutableCompilationSettings.prototype.mapSourceFiles = function () { - return this._mapSourceFiles; - }; - ImmutableCompilationSettings.prototype.mapRoot = function () { - return this._mapRoot; - }; - ImmutableCompilationSettings.prototype.sourceRoot = function () { - return this._sourceRoot; - }; - ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { - return this._generateDeclarationFiles; - }; - ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { - return this._useCaseSensitiveFileResolution; - }; - ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { - return this._gatherDiagnostics; - }; - ImmutableCompilationSettings.prototype.codepage = function () { - return this._codepage; - }; - ImmutableCompilationSettings.prototype.createFileLog = function () { - return this._createFileLog; - }; - - ImmutableCompilationSettings.defaultSettings = function () { - if (!ImmutableCompilationSettings._defaultSettings) { - ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); - } - - return ImmutableCompilationSettings._defaultSettings; - }; - - 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, 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, "_")) { - resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; - } - } - - return result; - }; - return ImmutableCompilationSettings; - })(); - TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; - - PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; - - PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; - - PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; - - PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - function hasModifier(modifiers, flag) { - for (var i = 0, n = modifiers.length; i < n; i++) { - if (TypeScript.hasFlag(modifiers[i], flag)) { - return true; - } - } - - return false; - } - TypeScript.hasModifier = hasModifier; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; - PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; - - 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.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"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var pullDeclID = 0; - var sentinelEmptyPullDeclArray = []; - - var PullDecl = (function () { - 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; - this.childDeclTypeParameterCache = null; - this.name = declName; - this.kind = kind; - this.flags = declFlags; - this.semanticInfoChain = semanticInfoChain; - - if (displayName !== this.name) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.fileName = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentPath = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.isExternalModule = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getEnclosingDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { - var decl = this; - while (decl) { - switch (decl.kind) { - default: - return decl; - case 512 /* Variable */: - case 8192 /* TypeParameter */: - case 2048 /* Parameter */: - case 128 /* TypeAlias */: - case 67108864 /* EnumMember */: - } - - decl = decl.getParentDecl(); - } - - TypeScript.Debug.fail(); - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.name : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (symbol) { - this.semanticInfoChain.setSymbolForDecl(this, symbol); - }; - - 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 */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.semanticInfoChain.getSymbolForDecl(this); - }; - - PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain.getSymbolForDecl(this); - return !!symbol; - }; - - PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); - }; - - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(); - return this.semanticInfoChain.getSignatureSymbolForDecl(this); - }; - - PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); - return !!signatureSymbol; - }; - - PullDecl.prototype.setFlags = function (flags) { - this.flags = flags; - }; - - PullDecl.prototype.setFlag = function (flags) { - this.flags |= flags; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - valDecl.containerDecl = this; - }; - - PullDecl.prototype.getValueDecl = function () { - return this.synthesizedValDecl; - }; - - PullDecl.prototype.getContainerDecl = function () { - return this.containerDecl; - }; - - PullDecl.prototype.getChildDeclCache = function (declKind) { - if (declKind === 8192 /* TypeParameter */) { - if (!this.childDeclTypeParameterCache) { - this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeParameterCache; - } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { - if (!this.childDeclNamespaceCache) { - this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { - if (!this.childDeclTypeCache) { - this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeCache; - } else { - if (!this.childDeclValueCache) { - this.childDeclValueCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclValueCache; - } - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.kind === 8192 /* TypeParameter */) { - if (!this.typeParameters) { - this.typeParameters = []; - } - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - if (!this.childDecls) { - this.childDecls = []; - } - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.name; - - if (!(childDecl.kind & 7340032 /* SomeSignature */)) { - var cache = this.getChildDeclCache(childDecl.kind); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - } - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cacheVal = null; - - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; - } else if (searchKind & 164 /* SomeContainer */) { - cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; - } else { - cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; - } - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; - - if (cacheVal) { - return cacheVal; - } - } - - return sentinelEmptyPullDeclArray; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - if (!this.declGroups) { - this.declGroups = TypeScript.createIntrinsicsObject(); - } - - var declGroup = this.declGroups[decl.name]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.name); - declGroup.addDecl(decl); - this.declGroups[decl.name] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = null; - - if (this.declGroups) { - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - if (declGroups === null) { - declGroups = []; - } - - declGroups.push(this.declGroups[declName].getDecls()); - } - } - } - - return declGroups || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.hasBeenBound = function () { - return this.hasSymbol() || this.hasSignatureSymbol(); - }; - - PullDecl.prototype.isSynthesized = function () { - return false; - }; - - PullDecl.prototype.ast = function () { - return this.semanticInfoChain.getASTForDecl(this); - }; - - PullDecl.prototype.isRootDecl = function () { - throw TypeScript.Errors.abstract(); - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - var RootPullDecl = (function (_super) { - __extends(RootPullDecl, _super); - 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; - } - RootPullDecl.prototype.fileName = function () { - return this._fileName; - }; - - RootPullDecl.prototype.getParentPath = function () { - return [this]; - }; - - RootPullDecl.prototype.getParentDecl = function () { - return null; - }; - - RootPullDecl.prototype.isExternalModule = function () { - return this._isExternalModule; - }; - - 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, addToParent) { - if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); - this.parentDecl = null; - this.parentPath = null; - - this.parentDecl = parentDecl; - 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._rootDecl.fileName(); - }; - - NormalPullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - NormalPullDecl.prototype.getParentPath = function () { - if (!this.parentPath) { - var path = [this]; - var parentDecl = this.parentDecl; - - while (parentDecl) { - if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { - path.unshift(parentDecl); - } - - parentDecl = parentDecl.getParentDecl(); - } - - this.parentPath = path; - } - - return this.parentPath; - }; - - NormalPullDecl.prototype.isExternalModule = function () { - return false; - }; - - 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) { - _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); - this.constantValue = null; - } - return PullEnumElementDecl; - })(NormalPullDecl); - TypeScript.PullEnumElementDecl = PullEnumElementDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { - if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(NormalPullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - var PullSynthesizedDecl = (function (_super) { - __extends(PullSynthesizedDecl, _super); - function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { - _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); - this.semanticInfoChain = semanticInfoChain; - } - PullSynthesizedDecl.prototype.isSynthesized = function () { - return true; - }; - - PullSynthesizedDecl.prototype.fileName = function () { - return this._rootDecl ? this._rootDecl.fileName() : ""; - }; - return PullSynthesizedDecl; - })(NormalPullDecl); - TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.name === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullSymbolID = 0; - TypeScript.sentinelEmptyArray = []; - - var PullSymbol = (function () { - function PullSymbol(name, declKind) { - this.pullSymbolID = ++TypeScript.pullSymbolID; - this._container = null; - this.type = null; - this._declarations = null; - this.isResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isVarArg = false; - this.rootSymbol = null; - this._enclosingSignature = null; - this._docComments = null; - this.isPrinting = false; - this.name = name; - this.kind = declKind; - } - PullSymbol.prototype.isAny = function () { - return false; - }; - - PullSymbol.prototype.isType = function () { - return (this.kind & 58728795 /* SomeType */) !== 0; - }; - - PullSymbol.prototype.isTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) !== 0; - }; - - PullSymbol.prototype.isArrayNamedTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.kind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isInterface = function () { - return this.kind === 16 /* Interface */; - }; - - PullSymbol.prototype.isMethod = function () { - return this.kind === 65536 /* Method */; - }; - - PullSymbol.prototype.isProperty = function () { - return this.kind === 4096 /* Property */; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { - if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } - if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } - var scopeDeclarations = scopeSymbol.getDeclarations(); - var scopeSymbolAliasesToLookIn = []; - - for (var i = 0; i < scopeDeclarations.length; i++) { - var scopeDecl = scopeDeclarations[i]; - if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { - visitedScopeDeclarations.push(scopeDecl); - - var childDecls = scopeDecl.getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - var childDecl = childDecls[j]; - if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { - var symbol = childDecl.getSymbol(); - - if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { - aliasSymbols.push(symbol); - return aliasSymbols; - } - - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { - scopeSymbolAliasesToLookIn.push(symbol); - } - } - } - } - } - - for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { - var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; - - aliasSymbols.push(scopeSymbolAlias); - var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); - if (result) { - return result; - } - - aliasSymbols.pop(); - } - - return null; - }; - - PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { - var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); - return symbols; - } - - return null; - }; - - PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { - if (aliasSymbol) { - if (aliasSymbol.assignedValue()) { - return false; - } - - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { - return false; - } - - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { - return false; - } - - return true; - } - - return false; - }; - - PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { - if (scopeSymbol) { - 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); - return internalAliases[0]; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { - if (!skipInternalAlias) { - var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); - if (internalAlias) { - return aliasNameGetter(internalAlias); - } - } - - var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); - - if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - 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 aliasFullName; - } - - return null; - }; - - PullSymbol.prototype._getResolver = function () { - TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain.getResolver(); - }; - - PullSymbol.prototype._resolveDeclaredSymbol = function () { - return this._getResolver().resolveDeclaredSymbol(this); - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getName(); - }); - return aliasName || this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getDisplayName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getDisplayName(); - }, skipInternalAliasName); - if (aliasDisplayName) { - return aliasDisplayName; - } - - var decls = this.getDeclarations(); - var name = decls.length && decls[0].getDisplayName(); - - return (name && name.length) ? name : this.name; - }; - - PullSymbol.prototype.getIsSpecialized = function () { - return false; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - 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; - }; - - PullSymbol.prototype.setEnclosingSignature = function (signature) { - this._enclosingSignature = signature; - }; - - PullSymbol.prototype.getEnclosingSignature = function () { - return this._enclosingSignature; - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - if (!this._declarations) { - this._declarations = [decl]; - } else { - this._declarations[this._declarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this._declarations) { - this._declarations = []; - } - - return this._declarations; - }; - - PullSymbol.prototype.hasDeclaration = function (decl) { - if (!this._declarations) { - return false; - } - - return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { - return eachDecl === decl; - }); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - if (this.rootSymbol) { - return; - } - - this._container = containerSymbol; - }; - - PullSymbol.prototype.getContainer = function () { - if (this.rootSymbol) { - return this.rootSymbol.getContainer(); - } - - return this._container; - }; - - PullSymbol.prototype.setResolved = function () { - this.isResolved = true; - this.inResolution = false; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.isResolved = false; - this.inResolution = false; - }; - - PullSymbol.prototype.anyDeclHasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (TypeScript.hasFlag(declarations[i].flags, flag)) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!TypeScript.hasFlag(declarations[i].flags, flag)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = node.getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - var nodeKind = node.kind; - if (nodeKind === 2048 /* Parameter */) { - break; - } else { - node = node.getContainer(); - } - } - return path; - }; - - 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 memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); - if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { - return true; - } - - var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); - if (memberSymbol && memberSymbol != symbol) { - return true; - } - } - } - - 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 (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { - return thisPath.slice(0, thisCommonAncestorIndex); - } else { - return thisPath; - } - }; - - PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var str = this.getNameAndTypeName(scopeSymbol); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var _this = this; - var path = this.pathToRoot(); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol === _this ? null : symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].kind; - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.type; - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - 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 */) { - var signatures = type.getCallSignatures(); - 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); - return typeName; - } - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.type; - var nameStr = this.getDisplayName(scopeSymbol); - if (type) { - nameStr = nameStr + (this.isOptional ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return TypeScript.MemberName.create(nameStr); - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - - inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); - - var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); - inIsExternallyVisibleSymbols.pop(); - - return result; - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.kind; - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.rootSymbol) { - return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); - } - - if (this.isType()) { - var associatedContainerSymbol = this.getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.anyDeclHasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - var decls = this.getDeclarations(); - if (decls.length) { - var parentDecl = decls[0].getParentDecl(); - if (parentDecl) { - var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind === 1 /* Script */) { - return true; - } - - return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); - } - } - - return true; - } - - 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 */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { - var ast = decl.ast(); - - if (ast) { - 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.ASTHelpers.docComments(ast); - } - } - - return []; - }; - - PullSymbol.prototype.getDocCommentArray = function (symbol) { - var docComments = []; - if (!symbol) { - return docComments; - } - - 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 */) { - continue; - } - docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); - } - return docComments; - }; - - PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { - if (classSymbol.getHasDefaultConstructor()) { - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); - } - } - - return classSymbol.type.getConstructSignatures()[0]; - }; - - PullSymbol.prototype.getDocCommentText = function (comments) { - var docCommentText = new Array(); - for (var c = 0; c < comments.length; c++) { - var commentText = this.getDocCommentTextValue(comments[c]); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - PullSymbol.prototype.getDocCommentTextValue = function (comment) { - return this.cleanJSDocComment(comment.fullText()); - }; - - PullSymbol.prototype.docComments = function (useConstructorAsClass) { - var decls = this.getDeclarations(); - 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 */) { - var classSymbol = this.returnType; - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - docComments = extendedTypes[0].getConstructorMethod().docComments(); - } else { - docComments = ""; - } - } else if (this.kind === 2048 /* Parameter */) { - var parameterComments = []; - - var funcContainer = this.getEnclosingSignature(); - var funcDocComments = this.getDocCommentArray(funcContainer); - var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); - if (paramComment != "") { - parameterComments.push(paramComment); - } - - var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); - if (paramSelfComment != "") { - parameterComments.push(paramSelfComment); - } - docComments = parameterComments.join("\n"); - } else { - var getSymbolComments = true; - if (this.kind === 16777216 /* FunctionType */) { - var functionSymbol = this.getFunctionSymbol(); - - if (functionSymbol) { - docComments = functionSymbol._docComments || ""; - getSymbolComments = false; - } else { - var declarationList = this.getDeclarations(); - if (declarationList.length > 0) { - docComments = declarationList[0].getSymbol()._docComments || ""; - getSymbolComments = false; - } - } - } - if (getSymbolComments) { - docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments === "") { - if (this.kind === 1048576 /* CallSignature */) { - var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { - docComments = callTypeSymbol.docComments(); - } - } - } - } - } - - this._docComments = docComments; - } - - return this._docComments; - }; - - PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].fullText(); - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!this.isSpaceChar(commentContents, j)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - - PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = new Array(); - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.start; - for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.end); - } - - var newCleanPos = this.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - PullSymbol.prototype.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = this.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - start: nonSpaceIndex, - end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - 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.returnType = null; - this.functionType = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this._allowedToReferenceTypeParameters = null; - this._instantiationCache = null; - this.hasBeenChecked = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return this._isDefinition; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - 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) { - this.parameters = []; - } - - this.parameters[this.parameters.length] = parameter; - this.hasOptionalParam = isOptional; - - if (!parameter.getEnclosingSignature()) { - parameter.setEnclosingSignature(this); - } - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this._typeParameters) { - this._typeParameters = []; - } - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - 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 = []; - } - - return this._typeParameters; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - - for (var i = 0; i < this.getTypeParameters().length; i++) { - this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; - } - } - - memberSymbol = this._memberTypeParameterNameCache[name]; - - 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; - this._stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].type; - if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { - this._stringConstantOverload = true; - } - } - } - - 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); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - if (!signatures) { - return result; - } - - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.parameters; - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].type; - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].isVarArg; - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - if (this.returnType) { - builder.add(this.returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - 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 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 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 wrappingTypeParameterID; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { - if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - - var parameters = this.parameters; - - for (var i = 0; i < parameters.length; i++) { - if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - } - - return false; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol(name, kind) { - _super.call(this, name, kind); - this._members = TypeScript.sentinelEmptyArray; - this._enclosedMemberTypes = null; - this._enclosedMemberContainers = null; - this._typeParameters = null; - this._allowedToReferenceTypeParameters = null; - this._specializedVersionsOfThisType = null; - this._arrayVersionOfThisType = null; - this._implementedTypes = null; - this._extendedTypes = null; - this._typesThatExplicitlyImplementThisType = null; - this._typesThatExtendThisType = null; - this._callSignatures = null; - this._allCallSignatures = null; - this._constructSignatures = null; - this._indexSignatures = null; - this._allIndexSignatures = null; - this._allIndexSignaturesOfAugmentedType = null; - this._memberNameCache = null; - this._enclosedTypeNameCache = null; - this._enclosedContainerCache = null; - this._typeParameterNameCache = null; - this._containedNonMemberNameCache = null; - this._containedNonMemberTypeNameCache = null; - this._containedNonMemberContainerCache = null; - this._simpleInstantiationCache = null; - this._complexInstantiationCache = null; - this._hasGenericSignature = false; - this._hasGenericMember = false; - this._hasBaseTypeConflict = false; - this._knownBaseTypeCount = 0; - this._associatedContainerTypeSymbol = null; - this._constructorMethod = null; - this._hasDefaultConstructor = false; - this._functionSymbol = null; - this._inMemberTypeNameEx = false; - this.inSymbolPrivacyCheck = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - this.typeReference = null; - this._widenedType = null; - this._isArrayNamedTypeReference = undefined; - this.type = this; - } - PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArrayNamedTypeReference === undefined) { - this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); - } - - return this._isArrayNamedTypeReference; - }; - - PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { - var typeArgs = this.getTypeArguments(); - if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { - var declaration = this.getDeclarations()[0]; - - if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.kind === 8 /* Class */ || (this._constructorMethod !== null); - }; - PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return this.kind === 33554432 /* ConstructorType */; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - PullTypeSymbol.prototype.isEnum = function () { - return this.kind === 64 /* Enum */; - }; - - PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { - return null; - }; - - PullTypeSymbol.prototype.isObject = function () { - 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 () { - return this._knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this._knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this._knownBaseTypeCount++; - }; - - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.hasMembers = function () { - if (this._members !== TypeScript.sentinelEmptyArray) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this._hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this._hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this._hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this._hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this._associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this._associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this._arrayVersionOfThisType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - return null; - }; - - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this._arrayVersionOfThisType = arrayType; - }; - - PullTypeSymbol.prototype.getFunctionSymbol = function () { - return this._functionSymbol; - }; - - PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { - if (symbol) { - this._functionSymbol = symbol; - } - }; - - PullTypeSymbol.prototype.findContainedNonMember = function (name) { - if (!this._containedNonMemberNameCache) { - return null; - } - - return this._containedNonMemberNameCache[name]; - }; - - PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberTypeNameCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberContainerCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol) { - if (!memberSymbol) { - return; - } - - memberSymbol.setContainer(this); - - if (!this._memberNameCache) { - this._memberNameCache = TypeScript.createIntrinsicsObject(); - } - - if (this._members === TypeScript.sentinelEmptyArray) { - this._members = []; - } - - this._members.push(memberSymbol); - this._memberNameCache[memberSymbol.name] = memberSymbol; - }; - - PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - if (!enclosedType) { - return; - } - - enclosedType.setContainer(this); - - if (!this._enclosedTypeNameCache) { - this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberTypes) { - this._enclosedMemberTypes = []; - } - - this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; - this._enclosedTypeNameCache[enclosedType.name] = enclosedType; - }; - - PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - if (!enclosedContainer) { - return; - } - - enclosedContainer.setContainer(this); - - if (!this._enclosedContainerCache) { - this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberContainers) { - this._enclosedMemberContainers = []; - } - - this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; - this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; - }; - - PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - if (!enclosedNonMember) { - return; - } - - enclosedNonMember.setContainer(this); - - if (!this._containedNonMemberNameCache) { - this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - if (!enclosedNonMemberType) { - return; - } - - enclosedNonMemberType.setContainer(this); - - if (!this._containedNonMemberTypeNameCache) { - this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - if (!enclosedNonMemberContainer) { - return; - } - - enclosedNonMemberContainer.setContainer(this); - - if (!this._containedNonMemberContainerCache) { - this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; - }; - - PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!typeParameter) { - return; - } - - if (!typeParameter.getContainer()) { - typeParameter.setContainer(this); - } - - if (!this._typeParameterNameCache) { - this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._typeParameters) { - this._typeParameters = []; - } - - this._typeParameters[this._typeParameters.length] = typeParameter; - this._typeParameterNameCache[typeParameter.getName()] = typeParameter; - }; - - PullTypeSymbol.prototype.getMembers = function () { - return this._members; - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this._hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this._hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this._constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this._constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - if (!this._typeParameters) { - return TypeScript.sentinelEmptyArray; - } - - 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 (typeArgumentMap) { - if (this.isTypeParameter()) { - return true; - } - - 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; - } else { - if (!this._complexInstantiationCache) { - this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); - } - - this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; - } - - if (!this._specializedVersionsOfThisType) { - this._specializedVersionsOfThisType = []; - } - - this._specializedVersionsOfThisType.push(specializedVersionOfThisType); - }; - - PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { - if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { - if (!this._simpleInstantiationCache) { - return null; - } - - var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; - return result || null; - } else { - if (!this._complexInstantiationCache) { - return null; - } - - if (this.getAllowedToReferenceTypeParameters().length == 0) { - return this; - } - - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; - return result || null; - } - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - if (!this._specializedVersionsOfThisType) { - return TypeScript.sentinelEmptyArray; - } - - return this._specializedVersionsOfThisType; - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return null; - }; - - PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeParameters(); - }; - - PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { - if (!this._callSignatures) { - this._callSignatures = []; - } - - if (callSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - callSignature.functionType = this; - }; - - 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 = []; - } - - if (constructSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - 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 = []; - } - - this._indexSignatures[this._indexSignatures.length] = indexSignature; - - if (indexSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - indexSignature.functionType = this; - }; - - 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; - } - - var signatures = []; - - if (this._callSignatures) { - signatures = signatures.concat(this._callSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); - } - } - - this._allCallSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return this._constructSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnConstructSignatures = function () { - return this._constructSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function () { - var signatures = []; - - if (this._constructSignatures) { - signatures = signatures.concat(this._constructSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); - } - } - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return this._indexSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnIndexSignatures = function () { - return this._indexSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function () { - if (this._allIndexSignatures) { - return this._allIndexSignatures; - } - - var signatures = []; - - if (this._indexSignatures) { - signatures = signatures.concat(this._indexSignatures); - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); - } - } - - this._allIndexSignatures = signatures; - - 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; - } - - if (!this._implementedTypes) { - this._implementedTypes = []; - } - - this._implementedTypes[this._implementedTypes.length] = implementedType; - - implementedType.addTypeThatExplicitlyImplementsThisType(this); - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - if (!this._implementedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._implementedTypes; - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!extendedType) { - return; - } - - if (!this._extendedTypes) { - this._extendedTypes = []; - } - - this._extendedTypes[this._extendedTypes.length] = extendedType; - - extendedType.addTypeThatExtendsThisType(this); - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - if (!this._extendedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._extendedTypes; - }; - - PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - return this._typesThatExtendThisType; - }; - - PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - return this._typesThatExplicitlyImplementThisType; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { - return true; - } - - if (TypeScript.ArrayUtilities.contains(visited, this)) { - return true; - } - - visited.push(this); - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - visited.pop(); - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.kind === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - var memberSymbol = null; - - if (this._memberNameCache) { - memberSymbol = this._memberNameCache[name]; - } - - if (memberSymbol || !lookInParent) { - return memberSymbol; - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return null; - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedTypeNameCache) { - return null; - } - - memberSymbol = this._enclosedTypeNameCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedContainerCache) { - return null; - } - - memberSymbol = this._enclosedContainerCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - var allMembers = []; - - 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 */))) { - allMembers[allMembers.length] = member; - } - } - } - - if (this._extendedTypes) { - var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; - - for (var i = 0, n = this._extendedTypes.length; i < n; i++) { - var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - if (this.isContainer()) { - if (this._enclosedMemberTypes) { - for (var i = 0; i < this._enclosedMemberTypes.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberTypes[i]; - } - } - if (this._enclosedMemberContainers) { - for (var i = 0; i < this._enclosedMemberContainers.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberContainers[i]; - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - if (!this._typeParameterNameCache) { - return null; - } - - return this._typeParameterNameCache[name]; - }; - - PullTypeSymbol.prototype.setResolved = function () { - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArgumentsOrTypeParameters(); - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); - }; - - 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 !== "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); - return s; - }; - - 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, "", "[]"); - } - - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - if (skipTypeParametersInName) { - return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); - } else { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - - var typars = this.getTypeArgumentsOrTypeParameters(); - builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - } - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getTypeOfSymbol = function () { - var associatedContainerType = this.getAssociatedContainerType(); - if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { - return associatedContainerType; - } - - var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; - } - - return null; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var typeOfSymbol = this.getTypeOfSymbol(); - if (typeOfSymbol) { - var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); - return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); - } - - if (this._inMemberTypeNameEx) { - return TypeScript.MemberName.create("any"); - } - - this._inMemberTypeNameEx = true; - - var allMemberNames = new TypeScript.MemberNameArray(); - 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()) { - var methodCallSignatures = members[i].type.getCallSignatures(); - var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); - ; - var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); - allMemberNames.addAll(methodMemberNames); - } else { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - if (memberTypeName.isArray() && memberTypeName.delim === delim) { - allMemberNames.addAll(memberTypeName.entries); - } else { - allMemberNames.add(memberTypeName); - } - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - this._inMemberTypeNameEx = false; - - return allMemberNames; - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - return 2 /* Closed */; - }; - - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; - }; - - PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - var type = this; - - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { - return type.pullSymbolID; - } - - var constraint = type.getConstraint(); - var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; - return wrappingTypeParameterID; - } - - if (type.inWrapCheck) { - return 0; - } - - 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; - - var typeArguments = type.getTypeArguments(); - - if (type.isGeneric() && !typeArguments) { - typeArguments = type.getTypeParameters(); - } - - if (typeArguments) { - for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { - wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); - } - } - } - - 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); - } - - wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); - } - - if (!skipTypeArgumentCheck) { - type.inWrapCheck = false; - } - - return wrappingTypeParameterID; - }; - - 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - 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(); - for (var i = 0; i < typeArguments.length; i++) { - if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { - continue; - } - - if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { - return true; - } - } - - 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); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - - this.isResolved = true; - } - PullPrimitiveTypeSymbol.prototype.isAny = function () { - 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 () { - return false; - }; - - 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; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(_anyType, name) { - _super.call(this, name); - 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); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullContainerSymbol = (function (_super) { - __extends(PullContainerSymbol, _super); - function PullContainerSymbol(name, kind) { - _super.call(this, name, kind); - this.instanceSymbol = null; - this.assignedValue = null; - this.assignedType = null; - this.assignedContainer = null; - } - PullContainerSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this.assignedValue = symbol; - }; - - PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { - return this.assignedValue; - }; - - PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this.assignedType = type; - }; - - PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this.assignedType; - }; - - PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this.assignedContainer = container; - }; - - PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this.assignedContainer; - }; - - PullContainerSymbol.prototype.hasExportAssignment = function () { - return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; - }; - - PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { - return true; - } - - var moduleSymbol = containerSymbol; - var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - - PullContainerSymbol.prototype.getInstanceType = function () { - return this.instanceSymbol ? this.instanceSymbol.type : null; - }; - return PullContainerSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerSymbol = PullContainerSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 128 /* TypeAlias */); - this._assignedValue = null; - this._assignedType = null; - 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; - }; - - PullTypeAliasSymbol.prototype.isUsedAsValue = function () { - this._resolveDeclaredSymbol(); - return this._isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { - this._typeUsedExternally = true; - }; - - PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { - this._isUsedInExportAlias = true; - if (this.linkedAliasSymbols) { - this.linkedAliasSymbols.forEach(function (s) { - return s.setIsUsedInExportedAlias(); - }); - } - }; - - 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(); - }); - } - }; - - PullTypeAliasSymbol.prototype.assignedValue = function () { - this._resolveDeclaredSymbol(); - return this._assignedValue; - }; - - PullTypeAliasSymbol.prototype.assignedType = function () { - this._resolveDeclaredSymbol(); - return this._assignedType; - }; - - PullTypeAliasSymbol.prototype.assignedContainer = function () { - this._resolveDeclaredSymbol(); - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { - this._assignedValue = symbol; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (this._assignedValue) { - return this._assignedValue; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { - this._assignedType = type; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedType) { - if (this._assignedType.isAlias()) { - this.retrievingExportAssignment = true; - var sym = this._assignedType.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - } else if (this._assignedType !== this._assignedContainer) { - return this._assignedType; - } - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { - this._assignedContainer = container; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this._assignedType) { - return this._assignedType.getMembers(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this._assignedType) { - return this._assignedType.getCallSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this._assignedType) { - return this._assignedType.getConstructSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this._assignedType) { - return this._assignedType.getIndexSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this._assignedType) { - return this._assignedType.findMember(name, true); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedContainer(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { - if (this._assignedType) { - return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); - } - - return TypeScript.sentinelEmptyArray; - }; - return PullTypeAliasSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - - var PullTypeParameterSymbol = (function (_super) { - __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name) { - _super.call(this, name, 8192 /* TypeParameter */); - this._constraint = null; - } - PullTypeParameterSymbol.prototype.isTypeParameter = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { - this._constraint = constraintType; - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - 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(); - } - - return _super.prototype.getCallSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getConstructSignatures = function () { - if (this._constraint) { - return this._constraint.getConstructSignatures(); - } - - return _super.prototype.getConstructSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getIndexSignatures = function () { - if (this._constraint) { - return this._constraint.getIndexSignatures(); - } - - return _super.prototype.getIndexSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this._getterSymbol = null; - this._setterSymbol = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - if (!setter) { - return; - } - - this._setterSymbol = setter; - }; - - PullAccessorSymbol.prototype.getSetter = function () { - return this._setterSymbol; - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - if (!getter) { - return; - } - - this._getterSymbol = getter; - }; - - PullAccessorSymbol.prototype.getGetter = function () { - return this._getterSymbol; - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { - var substitution = ""; - var members = null; - - 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 getIDForTypeSubstitutionsOfType(type) { - var structure; - if (type.isError()) { - structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); - } else if (!type.isNamedTypeSymbol()) { - structure = getIDForTypeSubstitutionsFromObjectType(type); - } - - if (!structure) { - structure = type.pullSymbolID + "#"; - } - - return structure; - } - - function getIDForTypeSubstitutionsFromObjectType(type) { - if (type.isResolved) { - var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); - TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); - } - - return null; - } - - var GetIDForTypeSubStitutionWalker = (function () { - function GetIDForTypeSubStitutionWalker() { - this.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"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; - })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); - 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._inferredTypeAfterFixing = null; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - 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 TypeArgumentInferenceContext = (function () { - function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { - this.resolver = resolver; - this.context = context; - this.signatureBeingInferred = signatureBeingInferred; - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - this.candidateCache = []; - var typeParameters = signatureBeingInferred.getTypeParameters(); - for (var i = 0; i < typeParameters.length; i++) { - this.addInferenceRoot(typeParameters[i]); - } - } - TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { - return true; - } else { - this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); - return false; - } - }; - - TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache.release(); - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - }; - - TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.pullSymbolID]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.pullSymbolID] = info; - } - }; - - TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.pullSymbolID]; - }; - - TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { - var info = this.getInferenceInfo(param); - - if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { - info.addCandidate(candidate); - } - }; - - 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); - } - }; - - 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]; - - info.fixTypeParameter(this.resolver, this.context); - - for (var i = 0; i < results.length; i++) { - if (results[i].type === info.typeParameter) { - results[i].type = info._inferredTypeAfterFixing; - } - } - - results.push(info._inferredTypeAfterFixing); - } - - return results; - }; - - TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { - throw TypeScript.Errors.abstract(); - }; - return TypeArgumentInferenceContext; - })(); - 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, isInferentiallyTyping, typeArgumentInferenceContext) { - this.contextualType = contextualType; - this.provisional = provisional; - this.isInferentiallyTyping = isInferentiallyTyping; - this.typeArgumentInferenceContext = typeArgumentInferenceContext; - this.provisionallyTypedSymbols = []; - this.hasProvisionalErrors = false; - this.astSymbolMap = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].setUnresolved(); - } - }; - - PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { - if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } - if (typeof fileName === "undefined") { fileName = null; } - this.resolver = resolver; - this.inTypeCheck = inTypeCheck; - 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"); - this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); - } - } - PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { - if (!this.inProvisionalResolution()) { - this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); - } - }; - - PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { - return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); - }; - - PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); - }; - - 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(); - - if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; - } - - return tc; - }; - - PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { - return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; - }; - - PullTypeResolutionContext.prototype.getContextualType = function () { - var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - 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); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); - } - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { - if (diagnostic) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; - } else if (this.inTypeCheck && this.resolver) { - this.resolver.semanticInfoChain.addDiagnostic(diagnostic); - } - } - }; - - PullTypeResolutionContext.prototype.typeCheck = function () { - return this.inTypeCheck && !this.inProvisionalResolution(); - }; - - PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { - this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); - }; - - PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - var typeContext = this.contextStack[i]; - if (!typeContext.provisional) { - break; - } - - var symbol = typeContext.getSymbolForAST(ast); - if (symbol) { - return symbol; - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OverloadApplicabilityStatus; - (function (OverloadApplicabilityStatus) { - OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; - })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - this.diagnosticsFromOverloadResolution = []; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var MemberWithBaseOrigin = (function () { - function MemberWithBaseOrigin(memberSymbol, baseOrigin) { - this.memberSymbol = memberSymbol; - this.baseOrigin = baseOrigin; - } - return MemberWithBaseOrigin; - })(); - - var SignatureWithBaseOrigin = (function () { - function SignatureWithBaseOrigin(signature, baseOrigin) { - this.signature = signature; - this.baseOrigin = baseOrigin; - } - return SignatureWithBaseOrigin; - })(); - - var InheritedIndexSignatureInfo = (function () { - function InheritedIndexSignatureInfo() { - } - return InheritedIndexSignatureInfo; - })(); - - 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(); - return CompilerReservedName[nameText]; - } - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this._cachedAnyTypeArgs = null; - this.typeCheckCallBacks = []; - this.postTypeCheckWorkitems = []; - this._cachedFunctionArgumentsSymbol = null; - 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 */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getArrayNamedType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedRegExpInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { - if (!this._cachedFunctionArgumentsSymbol) { - this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); - this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; - this._cachedFunctionArgumentsSymbol.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); - functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); - this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - } - - 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); - }; - - PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { - return context.canTypeCheckAST(ast); - }; - - PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { - if (context && context.inProvisionalResolution()) { - context.setSymbolForAST(ast, symbol); - } else { - this.semanticInfoChain.setSymbolForAST(ast, symbol); - } - }; - - PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { - var symbol = this.semanticInfoChain.getSymbolForAST(ast); - - if (!symbol) { - if (context && context.inProvisionalResolution()) { - symbol = context.getSymbolForAST(ast); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { - if (typeof name === "undefined") { name = null; } - return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = decl.getParentPath(); - - if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; - var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; - - if (isContainer && containerType) { - if (symbol.anyDeclHasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - 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 & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - } - - if (parent.kind & 164 /* SomeContainer */) { - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - member = childDecls[0].getSymbol(); - - if (!member) { - member = childDecls[0].getSignatureSymbol(); - } - return this.getExportedMemberSymbol(member, parent); - } - - if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); - if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { - var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); - if (aliasSymbol) { - if ((declSearchKind & 58728795 /* SomeType */) !== 0) { - var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); - if (typeSymbol) { - return typeSymbol; - } - } else { - var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - return valueSymbol; - } - } - - return aliasSymbol; - } - } - } - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var _this = this; - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - 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; - - if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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(); - - if (instanceSymbol) { - instanceType = instanceSymbol.type; - - childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().type; - - var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.kind & 1032192 /* SomeFunction */) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - return candidateSymbol; - } - - var alias = tryFindAlias(decl); - if (alias) { - return alias; - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - if (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) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - var declKind = decl.kind; - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = decl.getFunctionExpressionName(); - if (functionExpressionName) { - result.push(decl); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - } - } - - var topLevelDecls = this.semanticInfoChain.topLevelDecls(); - for (var i = 0, n = topLevelDecls.length; i < n; i++) { - var topLevelDecl = topLevelDecls[i]; - if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { - continue; - } - - if (!topLevelDecl.isExternalModule()) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.kind & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - 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 */ || lhs.kind === 64 /* Enum */)) { - return null; - } - - var lhsType = lhs.type; - if (!lhsType) { - return null; - } - - this.resolveDeclaredSymbol(lhsType, context); - - if (lhsType.isContainer() && lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - var memberVisibilty = 2 /* externallyVisible */; - var containerSymbol = lhsType; - if (containerSymbol.kind === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = enclosingDecl.getParentPath(); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { - memberVisibilty = 1 /* internallyVisible */; - break; - } - } - } - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - var members = []; - - if (lhsType.isContainer()) { - var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); - if (exportedAssignedContainerSymbol) { - lhsType = exportedAssignedContainerSymbol; - } - } - - lhsType = this.getApparentType(lhsType); - - 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); - } - - 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 */)); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { - var originalIdText = idText; - var symbol = null; - - if (TypeScript.isRelative(originalIdText)) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - symbol = this.semanticInfoChain.findExternalModule(path + idText); - } else { - idText = originalIdText; - - symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); - - if (!symbol) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - symbol = this.semanticInfoChain.findExternalModule(path + idText); - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { - if (!symbol || symbol.isResolved || symbol.isTypeReference()) { - return symbol; - } - - if (!context) { - context = new TypeScript.PullTypeResolutionContext(this); - } - - return this.resolveDeclaredSymbolWorker(symbol, context); - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { - if (!symbol || symbol.isResolved) { - return symbol; - } - - if (symbol.inResolution) { - if (!symbol.type && !symbol.isType()) { - symbol.type = this.semanticInfoChain.anyTypeSymbol; - } - - return symbol; - } - - var decls = symbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - var ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { - return symbol; - } - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); - var resolvedSymbol; - 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 */); - resolvedSymbol = this.resolveAST(ast, false, context); - } - - if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { - symbol.type = resolvedSymbol.type; - symbol.setResolved(); - } - } - - 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(); - this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { - return _this.resolveOtherDecl(otherDecl, context); - }); - }; - - PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { - var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); - var moduleSymbol = enclosingDecl.getSymbol(); - this.ensureAllSymbolsAreBound(moduleSymbol); - - this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); - this.resolveAST(sourceUnit.moduleElements, false, context); - - if (this.canTypeCheckAST(sourceUnit, context)) { - this.typeCheckSourceUnit(sourceUnit, context); - } - - return moduleSymbol; - }; - - 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) { - var containerDecl = this.semanticInfoChain.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - containerSymbol.setResolved(); - - this.resolveOtherDeclarations(ast, context); - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckEnumDeclaration(ast, context); - } - - return containerSymbol; - }; - - 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); - - this.typeCheckCallBacks.push(function (context) { - return _this.checkInitializersInEnumDeclarations(containerDecl, context); - }); - - if (!TypeScript.ASTHelpers.enumIsElided(ast)) { - this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { - 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; - - if (ast.stringLiteral) { - result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckModuleDeclaration(ast, context); - } - - return result; - }; - - PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { - if (containerSymbol) { - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - }; - - PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - this.ensureAllSymbolsAreBound(containerSymbol); - - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, context); - } - - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); - if (isLastName) { - this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); - } else if (sourceUnitAST) { - this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); - } - - containerSymbol.setResolved(); - - if (moduleDeclNameAST) { - this.resolveOtherDeclarations(moduleDeclNameAST, context); - } - - return containerSymbol; - }; - - 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 */) { - this.resolveExportAssignmentStatement(moduleElement, context); - return; - } - } - }; - - PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - var containerSymbol = containerDecl.getSymbol(); - - return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); - }; - - PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { - if (ast.stringLiteral) { - this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - }; - - PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { - var _this = this; - this.setTypeChecked(ast, context); - - if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { - this.resolveAST(ast.moduleElements, false, context); - } - - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - this.validateVariableDeclarationGroups(containerDecl, context); - - if (ast.stringLiteral) { - if (TypeScript.isRelative(ast.stringLiteral.valueText())) { - this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); - } - } - - 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) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() === 11 /* IdentifierName */) { - return true; - } else if (term.kind() === 121 /* QualifiedName */) { - var binex = term; - - if (binex.right.kind() === 11 /* IdentifierName */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { - if (!type.isGeneric()) { - return type; - } - - var typeParameters = type.getTypeArgumentsOrTypeParameters(); - - var typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); - } - - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; - - if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - var wasResolving = typeDeclSymbol.inResolution; - typeDeclSymbol.startResolving(); - - var typeRefDecls = typeDeclSymbol.getDeclarations(); - - for (var i = 0; i < typeRefDecls.length; i++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); - if (extendsClause) { - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - - if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - } - } - } - - 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()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); - var implementedType = this.resolveTypeReference(implementedTypeAST, context); - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - - if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addImplementedType(implementedType); - } - } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - - if (wasInBaseTypeResolution) { - typeDeclSymbol.inResolution = false; - - this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - _this.resolveClassDeclaration(classOrInterface, context); - } else { - _this.resolveInterfaceDeclaration(classOrInterface, context); - } - }); - - return typeDeclSymbol; - } - - this.setSymbolForAST(name, typeDeclSymbol, context); - this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - 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); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.type; - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - var parentConstructor = parentType ? parentType.getConstructorMethod() : null; - - if (parentConstructor) { - this.resolveDeclaredSymbol(parentConstructor, context); - var parentConstructorType = parentConstructor.type; - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - - if (!parentConstructSignatures.length) { - parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - parentConstructSignature.returnType = parentType; - parentConstructSignature.addTypeParametersFromReturnType(); - parentConstructorType.appendConstructSignature(parentConstructSignature); - parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - parentConstructSignatures = [parentConstructSignature]; - } - - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.parameters; - - 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); - } - - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - constructorSignature.addTypeParametersFromReturnType(); - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } - - if (!classDeclSymbol.isResolved) { - return classDeclSymbol; - } - - if (parentType) { - var parentConstructorSymbol = parentType.getConstructorMethod(); - - if (parentConstructorSymbol) { - var parentConstructorTypeSymbol = parentConstructorSymbol.type; - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - } - - this.resolveOtherDeclarations(classDeclAST, context); - } - - if (this.canTypeCheckAST(classDeclAST, context)) { - this.typeCheckClassDeclaration(classDeclAST, context); - } - - return classDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { - var _this = this; - 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); - }); - } - } - }; - - PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { - this.setTypeChecked(classDeclAST, context); - - var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - - this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); - this.resolveAST(classDeclAST.classElements, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); - this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); - - if (!classDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); - } - - this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); - }; - - PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { - this.checkThisCaptureVariableCollides(classDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { - var callSignatures = typeSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); - - if (interfaceDeclSymbol.isResolved) { - this.resolveOtherDeclarations(interfaceDeclAST, context); - - if (this.canTypeCheckAST(interfaceDeclAST, context)) { - this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); - } - } - - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { - this.setTypeChecked(interfaceDeclAST, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); - this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); - - 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) { - if (symbol) { - if (symbol.kind & kind) { - return symbol; - } - - if (symbol.isAlias()) { - this.resolveDeclaredSymbol(symbol, context); - - var alias = symbol; - if (kind & 164 /* SomeContainer */) { - return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728795 /* SomeType */) { - return alias.getExportAssignedTypeSymbol(); - } else if (kind & 68147712 /* SomeValue */) { - return alias.getExportAssignedValueSymbol(); - } - } - } - return null; - }; - - PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); - - return { - symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), - aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null - }; - }; - - PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { - var rhsName = identifier.valueText(); - if (rhsName.length === 0) { - return null; - } - - var moduleTypeSymbol = moduleSymbol.type; - var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); - var containerSymbol = memberSymbol.symbol; - var valueSymbol = null; - var typeSymbol = null; - var aliasSymbol = null; - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - aliasSymbol = memberSymbol.aliasSymbol; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - aliasSymbol = containerSymbol; - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return null; - } - - if (!valueSymbol) { - if (moduleTypeSymbol.getInstanceSymbol()) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); - valueSymbol = memberSymbol.symbol; - if (valueSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - } - - if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); - typeSymbol = memberSymbol.symbol; - if (typeSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); - return null; - } - - if (!typeSymbol && containerSymbol) { - typeSymbol = containerSymbol; - } - - return { - valueSymbol: valueSymbol, - typeSymbol: typeSymbol, - containerSymbol: containerSymbol, - aliasSymbol: aliasSymbol - }; - }; - - 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"); - - var moduleSymbol = null; - var moduleName; - - if (moduleNameExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = moduleNameExpr; - var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleContainer) { - moduleName = dottedNameAST.right.valueText(); - - moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; - if (!moduleSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); - } - } - } else { - var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); - var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); - - if (text.length > 0) { - var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); - moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); - if (moduleSymbol) { - 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]); - } - } - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - - var moduleReference = importStatementAST.moduleReference; - - var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; - - 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); - if (moduleSymbol) { - aliasedType = moduleSymbol.type; - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); - if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { - var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); - var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); - var instanceSymbol = aliasedType.getInstanceSymbol(); - - 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 { - importDeclSymbol.setAssignedValueSymbol(valueSymbol); - } - } - } else { - aliasedType = this.getNewErrorTypeSymbol(); - } - } else if (aliasExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = aliasExpr; - var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleSymbol) { - var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); - if (identifierResolution) { - importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); - importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); - importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); - return null; - } - } - } - - if (!aliasedType) { - importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); - } - - return aliasedType; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasedType = null; - - if (importDeclSymbol.isResolved) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - var declPath = enclosingDecl.getParentPath(); - - aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); - - if (!aliasedType) { - var path = importStatementAST.moduleReference.stringLiteral.text(); - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); - aliasedType = this.getNewErrorTypeSymbol(); - } - } else { - aliasedType = this.resolveInternalModuleReference(importStatementAST, context); - } - - if (aliasedType) { - if (!aliasedType.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); - if (!aliasedType.isError()) { - aliasedType = this.getNewErrorTypeSymbol(); - } - } - - if (aliasedType.isContainer()) { - importDeclSymbol.setAssignedContainerSymbol(aliasedType); - } - importDeclSymbol.setAssignedTypeSymbol(aliasedType); - - this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); - } - - importDeclSymbol.setResolved(); - - this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); - 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); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { - var _this = this; - this.setTypeChecked(importStatementAST, context); - - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (this.compilationSettings.noResolve()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); - } - - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - if (enclosingDecl.kind === 32 /* DynamicModule */) { - 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)); - } - } - } - } - - var checkPrivacy; - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind === 32 /* DynamicModule */) { - checkPrivacy = true; - } - } else { - checkPrivacy = true; - } - - if (checkPrivacy) { - var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); - - this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { - var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - - 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; - - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - - if (valueSymbol) { - this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { - var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - } - - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); - }; - - PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - 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); - } - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { - var id = exportAssignmentAST.identifier.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && parentSymbol.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); - return this.semanticInfoChain.anyTypeSymbol; - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - - var aliasSymbol = containerSymbol; - var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - } - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (valueSymbol) { - parentSymbol.setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - parentSymbol.setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - parentSymbol.setExportAssignedContainerSymbol(containerSymbol); - } - - this.resolveDeclaredSymbol(valueSymbol, context); - this.resolveDeclaredSymbol(typeSymbol, context); - this.resolveDeclaredSymbol(containerSymbol, context); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - var funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); - } - } - - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.setTypeChecked(funcDeclAST, context); - this.typeCheckFunctionOverloads(funcDeclAST, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - 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) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); - } else { - 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 (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(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - var contextualType = contextParam && contextParam.type; - var isImplicitAny = false; - - if (typeExpr) { - var typeRef = this.resolveTypeReference(typeExpr, context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); - typeRef = this.getNewErrorTypeSymbol(); - } - - contextualType = typeRef || contextualType; - } - if (contextualType) { - if (context.isInferentiallyTyping()) { - contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); - } - context.setTypeInContext(paramSymbol, contextualType); - } 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.propagateContextualType(contextualType); - } - - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - } - - if (!initExprSymbol || !initExprSymbol.type) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); - - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); - } - } else { - var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); - if (!contextualType) { - context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); - isImplicitAny = initTypeSymbol !== paramSymbol.type; - } else { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); - } - } - } - } - } - - if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - isImplicitAny = true; - } - - if (isImplicitAny && this.compilationSettings.noImplicitAny()) { - var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); - if (functionExpressionName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); - } - } - - if (canTypeCheckAST) { - this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { - var compilerReservedName = getCompilerReservedName(name); - switch (compilerReservedName) { - case 1 /* _this */: - this.postTypeCheckWorkitems.push(astWithName); - return; - - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; - - case 3 /* arguments */: - this.checkArgumentsCollides(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; - } - }; - - PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { - var enclosingAST = this.getASTForDecl(someFunctionDecl); - var nodeType = enclosingAST.kind(); - - 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); - } 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 */) { - var constructorDeclaration = enclosingAST; - 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 */) { - var functionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); - } - - return false; - }; - - PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); - } - } - } - }; - - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { - if (!isDeclaration || ast.kind() === 242 /* Parameter */) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - 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)); - } - } - } - } - }; - - PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { - var decl = this.semanticInfoChain.getDeclForAST(ast); - - if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - var nameText = name.valueText(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); - } - } - }; - - PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { - var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); - TypeScript.Debug.assert(interfaceDecl); - - var interfaceSymbol = interfaceDecl.getSymbol(); - TypeScript.Debug.assert(interfaceSymbol); - - if (objectType.typeMembers) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = objectType.typeMembers; - - for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { - memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); - memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); - - memberType = memberSymbol.type; - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - if (this.canTypeCheckAST(objectType, context)) { - this.typeCheckObjectTypeTypeReference(objectType, context); - } - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { - this.setTypeChecked(objectType, context); - var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); - var objectTypeSymbol = objectTypeDecl.getSymbol(); - - this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); - this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); - }; - - PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { - return this.resolveTypeReference(typeAnnotation.type, context); - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { - if (typeRef === null) { - return null; - } - - TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); - - var aliasType = null; - var type = this.computeTypeReferenceSymbol(typeRef, context); - - if (type.kind === 4 /* Container */) { - var container = type; - var instanceSymbol = container.getInstanceSymbol(); - - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { - type = instanceSymbol.type.getAssociatedContainerType(); - } - } - - if (type && type.isAlias()) { - aliasType = type; - type = aliasType.getExportAssignedTypeSymbol(); - } - - if (type && !type.isGeneric()) { - if (aliasType) { - this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); - } - } - - if (type && !type.isError()) { - 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 { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); - } - } - } - - if (this.canTypeCheckAST(typeRef, context)) { - this.setTypeChecked(typeRef, context); - } - - 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 */: - return this.semanticInfoChain.anyTypeSymbol; - case 61 /* BooleanKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - case 67 /* NumberKeyword */: - return this.semanticInfoChain.numberTypeSymbol; - case 69 /* StringKeyword */: - return this.semanticInfoChain.stringTypeSymbol; - case 41 /* VoidKeyword */: - return this.semanticInfoChain.voidTypeSymbol; - } - - var typeDeclSymbol = null; - - if (term.kind() === 11 /* IdentifierName */) { - typeDeclSymbol = this.resolveTypeNameExpression(term, context); - } else if (term.kind() === 123 /* FunctionType */) { - var functionType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); - } else if (term.kind() === 125 /* ConstructorType */) { - var constructorType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); - } else if (term.kind() === 122 /* ObjectType */) { - typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); - } else if (term.kind() === 126 /* GenericType */) { - typeDeclSymbol = this.resolveGenericTypeReference(term, context); - } else if (term.kind() === 121 /* QualifiedName */) { - typeDeclSymbol = this.resolveQualifiedName(term, context); - } else if (term.kind() === 14 /* StringLiteral */) { - 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, enclosingDecl.semanticInfoChain); - typeDeclSymbol.addDeclaration(decl); - } else if (term.kind() === 127 /* TypeQuery */) { - var typeQuery = term; - - var typeQueryTerm = typeQuery.name; - - var valueSymbol = this.resolveAST(typeQueryTerm, false, context); - - if (valueSymbol && valueSymbol.isAlias()) { - if (valueSymbol.assignedValue()) { - valueSymbol = valueSymbol.assignedValue(); - } else { - var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); - valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; - } - } - - if (valueSymbol) { - typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); - } else { - typeDeclSymbol = this.getNewErrorTypeSymbol(); - } - } else if (term.kind() === 124 /* ArrayType */) { - var arrayType = term; - var underlying = this.resolveTypeReference(arrayType.type, context); - typeDeclSymbol = this.getArrayType(underlying); - } else { - throw TypeScript.Errors.invalidOperation("unknown type"); - } - - if (!typeDeclSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); - return this.getNewErrorTypeSymbol(); - } - - if (typeDeclSymbol.isError()) { - return typeDeclSymbol; - } - - if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); - typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); - } - - return typeDeclSymbol; - }; - - PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { - 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveParameterList = function (list, context) { - return this.resolveSeparatedList(list.parameters, context); - }; - - PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { - var enumDeclaration = enumElement.parent.parent; - var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); - var symbol = decl.getSymbol(); - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { - if (this.canTypeCheckAST(clause, context)) { - this.setTypeChecked(clause, context); - } - - return this.resolveAST(clause.value, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - - if (enclosingDecl && decl.kind === 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved) { - var declType = declSymbol.type; - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved) { - valSymbol.type = declType; - valSymbol.setResolved(); - } - } - } else { - if (declSymbol.inResolution) { - declSymbol.type = this.semanticInfoChain.anyTypeSymbol; - declSymbol.setResolved(); - return declSymbol; - } - - if (!declSymbol.type || !declSymbol.type.isError()) { - declSymbol.startResolving(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - if (!hasTypeExpr) { - this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - } - - if (!(hasTypeExpr || init)) { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { - defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.type = defaultType; - } - } - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - } - } - - if (this.canTypeCheckAST(varDeclOrParameter, context)) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (varDeclOrParameter.kind() === 243 /* EnumElement */) { - var result = this.getEnumTypeSymbol(varDeclOrParameter, context); - declSymbol.type = result; - return result; - } - - if (!typeExpr) { - return null; - } - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var typeExprSymbol = this.resolveTypeReference(typeExpr, context); - - if (!typeExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - declSymbol.type = this.getNewErrorTypeSymbol(); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, typeExprSymbol); - } - } else { - if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { - decl.setFlag(16777216 /* IsAnnotatedWithAny */); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - typeExprSymbol = typeExprSymbol.type; - - if (typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { - var instanceSymbol = typeExprSymbol.getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(); - } else { - typeExprSymbol = instanceSymbol.type; - } - } - } - } 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(); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.type = typeExprSymbol; - } - - if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { - typeExprSymbol.setFunctionSymbol(declSymbol); - } - } - - return typeExprSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { - if (!init) { - return null; - } - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - if (typeExprSymbol) { - context.pushNewContextualType(typeExprSymbol); - } - - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); - - if (typeExprSymbol) { - context.popAnyContextualType(); - } - - if (!initExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - } else { - var initTypeSymbol = initExprSymbol.type; - - if (!hasTypeExpr) { - var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); - context.setTypeInContext(declSymbol, widenedInitTypeSymbol); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); - } - - if (this.compilationSettings.noImplicitAny()) { - 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 initTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var _this = this; - this.setTypeChecked(varDeclOrParameter, context); - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - - if (hasTypeExpr || init) { - if (typeExprSymbol && typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = typeExprSymbol.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol; - } - } - } - - initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); - } - } - } - } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { - var wrapperDecl = this.getEnclosingDecl(decl); - 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])); - } else if (wrapperDecl.kind === 65536 /* Method */) { - var parentDecl = wrapperDecl.getParentDecl(); - - if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); - } 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 (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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } - } - } - - 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_only_allowed_in_implementation)); - } - } - 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 */)) { - this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); - } - }; - - PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { - return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; - }; - - PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { - var enclosingDecl = this.getEnclosingDeclForAST(superAST); - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); - - if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { - 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; - if (!block) { - return; - } - } - } - - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - if (parents.length) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); - } - } - }; - - PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { - if (isDeclaration) { - var decl = this.semanticInfoChain.getDeclForAST(_thisAST); - if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - return; - } - } - - var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - var declPath = enclosingDecl.getParentPath(); - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - continue; - } - - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); - } - break; - } - } - }; - - PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { - this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - 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) { - return; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - typeParameterSymbol.setResolved(); - }; - - PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { - this.setTypeChecked(typeParameterAST, 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) { - if (this.canTypeCheckAST(constraint, context)) { - this.setTypeChecked(constraint, context); - } - - return this.resolveTypeReference(constraint.type, context); - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatementsExpressions = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, walker) { - var go = true; - - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 215 /* ObjectLiteralExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); - go = false; - break; - - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, walker) { - switch (ast.kind()) { - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - if (block) { - TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - } else { - returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - } - - if (!returnStatementsExpressions.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var returnExpressionSymbols = []; - var returnExpressions = []; - - for (var i = 0; i < returnStatementsExpressions.length; i++) { - var returnExpression = returnStatementsExpressions[i].expression; - if (returnExpression) { - var returnType = this.resolveAST(returnExpression, useContextualType, context).type; - - if (returnType.isError()) { - signature.returnType = returnType; - return; - } else { - if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { - this.setSymbolForAST(returnExpression.parent, returnType, context); - } - } - - returnExpressionSymbols.push(returnType); - returnExpressions.push(returnExpression); - } - } - - if (!returnExpressionSymbols.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].type; - } - }; - - var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); - var returnType = bestCommonReturnType; - var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - - if (returnType) { - var previousReturnType = returnType; - var newReturnType = returnType.widenedType(this, returnExpression, context); - signature.returnType = newReturnType; - - if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); - } - - if (this.compilationSettings.noImplicitAny()) { - if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { - var functionName = enclosingDecl.name; - if (functionName === "") { - functionName = enclosingDecl.getFunctionExpressionName(); - } - - if (functionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } - - if (!functionSymbol.type && functionSymbol.isAccessor()) { - functionSymbol.type = signature.returnType; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { - var _this = this; - if (constructorDecl.block) { - var foundSuperCall = false; - var pre = function (ast, walker) { - 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; - } - } - }; - - TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); - return foundSuperCall; - } - - return false; - }; - - 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); - }; - - PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { - this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(parameters, false, context); - - this.resolveAST(block, false, context); - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); - - if (funcDecl.kind === 16384 /* Function */) { - this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); - } - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - this.resolveAST(funcDeclAST.parameter, false, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); - var stringIndexSignature = allIndexSignatures.stringSignature; - var numberIndexSignature = allIndexSignatures.numericSignature; - var isNumericIndexer = numberIndexSignature === signature; - - if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { - var comparisonInfo = new TypeComparisonInfo(); - - 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); - } - } - } - - var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); - for (var i = 0; i < allMembers.length; i++) { - var member = allMembers[i]; - var name = member.name; - if (name || (member.kind === 4096 /* Property */ && name === "")) { - if (!allMembers[i].isResolved) { - _this.resolveDeclaredSymbol(allMembers[i], context); - } - - if (parentSymbol !== allMembers[i].getContainer()) { - var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); - var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; - var onlyStringIndexerIsPresent = !numberIndexSignature; - - if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { - var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { - _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); - } - } - } - } - } - }); - }; - - PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { - this.checkThisCaptureVariableCollides(funcDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { - var returnTypeSymbol = null; - - if (returnTypeAnnotation) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - } else { - var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } - - return returnTypeSymbol; - }; - - 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - return funcSymbol; - } - - if (!signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - 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(); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveIndexSignature(ast.indexSignature, context); - }; - - PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - return funcSymbol; - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameter) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - this.resolveParameter(funcDeclAST.parameter, context); - context.inTypeCheck = prevInTypeCheck; - } - - if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - return funcSymbol; - } - - if (isConstructor && !signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (returnTypeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { - if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { - 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; - if (funcDeclASTName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } - } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { - if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); - } - - return null; - }; - - 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.ASTHelpers.getType(parameter), context); - } - - return null; - }; - - PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - - if (accessorSymbol.inResolution) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - accessorSymbol.setResolved(); - - return accessorSymbol; - } - - if (accessorSymbol.isResolved) { - if (!accessorSymbol.type) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else { - var getterSymbol = accessorSymbol.getGetter(); - var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; - var hasGetter = getterSymbol !== null; - - var setterSymbol = accessorSymbol.getSetter(); - var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; - var hasSetter = setterSymbol !== null; - - var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); - var getterHasTypeAnnotation = getterAnnotatedType !== null; - - var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); - var setterHasTypeAnnotation = setterAnnotatedType !== null; - - accessorSymbol.startResolving(); - - if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); - } - - if (hasSetter) { - setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); - } - - if (hasGetter && hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - var getterSig = getterSymbol.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { - getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; - getterSig.returnType = setterSuppliedTypeSymbol; - } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { - setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; - - if (setterHasParameters) { - setterParameters[0].type = getterSuppliedTypeSymbol; - } - } - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - accessorSymbol.type = this.getNewErrorTypeSymbol(); - } else { - accessorSymbol.type = getterSuppliedTypeSymbol; - } - } else if (hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - - accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; - } else { - var getterSig = getterSymbol.type.getCallSignatures()[0]; - accessorSymbol.type = getterSig.returnType; - } - - accessorSymbol.setResolved(); - } - - if (this.canTypeCheckAST(funcDeclAst, context)) { - this.typeCheckAccessorDeclaration(funcDeclAst, context); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { - this.setTypeChecked(funcDeclAst, context); - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - var getterSymbol = accessorSymbol.getGetter(); - var setterSymbol = accessorSymbol.getSetter(); - - var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; - if (isGetter) { - var getterFunctionDeclarationAst = funcDeclAst; - context.pushNewContextualType(getterSymbol.type); - this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popAnyContextualType(); - } else { - var setterFunctionDeclarationAst = funcDeclAst; - this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); - } - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.type; - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return getterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - signature.setResolved(); - - return getterSymbol; - } - - signature.startResolving(); - - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - if (!setterAnnotatedType) { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } else { - signature.returnType = setterAnnotatedType; - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return getterSymbol; - }; - - PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - if (getter && setter) { - var getterAST = getter.getDeclarations()[0].ast(); - var setterAST = setter.getDeclarations()[0].ast(); - - if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { - var setterSig = setter.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - - var getter = accessorSymbol.getGetter(); - var getterSig = getter.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterParameters[0].type; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); - } - } - } - }; - - PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - var funcNameAST = funcDeclAST.propertyName; - - if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); - } - - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); - var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - 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.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; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.type; - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return setterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - signature.setResolved(); - return setterSymbol; - } - - signature.startResolving(); - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - } - - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - - if (!hadError) { - signature.setResolved(); - } - } - - return setterSymbol; - }; - - PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - - var getter = accessorSymbol.getGetter(); - - var funcNameAST = funcDeclAST.propertyName; - - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); - var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - if (getterIsPrivate !== setterIsPrivate) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); - } - - this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); - } else { - if (this.compilationSettings.noImplicitAny()) { - var setterFunctionDeclarationAst = funcDeclAST; - 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); - }; - - PullTypeResolver.prototype.resolveList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.childCount(); i < n; i++) { - this.resolveAST(list.childAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.resolveAST(list.nonSeparatorAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLogicalOperation(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { - this.setTypeChecked(binex, context); - - var leftType = this.resolveAST(binex.left, false, context).type; - var rightType = this.resolveAST(binex.right, false, context).type; - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(binex); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ - TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), - leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); - } - }; - - PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.operand, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckUnaryArithmeticOperation(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckPostfixUnaryExpression(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { - return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); - }; - - PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { - return; - } - - TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { - if (this.canTypeCheckAST(binaryExpression, context)) { - this.typeCheckBinaryArithmeticExpression(binaryExpression, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); - - var lhsType = lhsSymbol.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } - - if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } - - var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); - var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); - - if (!rhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!lhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (lhsIsFit && rhsIsFit) { - switch (binaryExpression.kind()) { - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - if (!this.isReference(binaryExpression.left, lhsSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); - } - } - }; - - PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInstanceOfExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); - var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - 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_of_a_type_assignable_to_the_Function_interface_type)); - } - }; - - PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { - if (this.canTypeCheckAST(commaExpression, context)) { - this.setTypeChecked(commaExpression, context); - - this.resolveAST(commaExpression.left, false, context); - } - - return this.resolveAST(commaExpression.right, false, context).type; - }; - - PullTypeResolver.prototype.resolveInExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; - - var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); - - if (!isValidLHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); - } - - if (!isValidRHS) { - 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)); - } - }; - - PullTypeResolver.prototype.resolveForStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.variableDeclaration, false, context); - this.resolveAST(ast.initializer, false, context); - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.incrementor, false, context); - this.resolveAST(ast.statement, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { - if (this.canTypeCheckAST(forInStatement, context)) { - this.typeCheckForInStatement(forInStatement, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { - this.setTypeChecked(forInStatement, context); - - if (forInStatement.variableDeclaration) { - var declaration = forInStatement.variableDeclaration; - - 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); - - 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 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)); - } - - this.resolveAST(forInStatement.statement, false, context); - }; - - PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWhileStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckDoStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckIfStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - this.resolveAST(ast.elseClause, false, context); - }; - - PullTypeResolver.prototype.resolveElseClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckElseClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveBlock = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.statements, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declaration, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declarators, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWithStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var withStatement = ast; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); - }; - - PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckTryStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var tryStatement = ast; - - this.resolveAST(tryStatement.block, false, context); - this.resolveAST(tryStatement.catchClause, false, context); - this.resolveAST(tryStatement.finallyClause, false, context); - }; - - PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckCatchClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - - var catchDecl = this.semanticInfoChain.getDeclForAST(ast); - this.validateVariableDeclarationGroups(catchDecl, context); - }; - - PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckFinallyClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - }; - - PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - while (enclosingDecl) { - if (enclosingDecl.kind & 1032192 /* SomeFunction */) { - return enclosingDecl; - } - - enclosingDecl = enclosingDecl.getParentDecl(); - } - - return null; - }; - - PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var isContextuallyTyped = false; - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); - if (returnTypeAnnotationSymbol) { - isContextuallyTyped = true; - context.pushNewContextualType(returnTypeAnnotationSymbol); - } - } else { - var currentContextualType = context.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - isContextuallyTyped = true; - context.propagateContextualType(currentContextualTypeReturnTypeSymbol); - } - } - } - } - - var result = this.resolveAST(expression, isContextuallyTyped, context).type; - if (isContextuallyTyped) { - context.popAnyContextualType(); - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { - if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { - var classDecl = enclosingFunction.getParentDecl(); - if (classDecl) { - var classSymbol = classDecl.getSymbol(); - this.resolveDeclaredSymbol(classSymbol, context); - - var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); - if (!isAssignable) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); - } - } - } - - if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); - } - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { - var signatureSymbol = enclosingFunction.getSignatureSymbol(); - var sigReturnType = signatureSymbol.returnType; - - if (expressionType && sigReturnType) { - var comparisonInfo = new TypeComparisonInfo(); - var upperBound = null; - - this.resolveDeclaredSymbol(expressionType, context); - this.resolveDeclaredSymbol(sigReturnType, context); - - var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); - } - } - } - } - } - }; - - PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { - var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var returnType = this.getSymbolForAST(returnAST, context); - var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); - if (!returnType || canTypeCheckAST) { - var returnExpr = returnAST.expression; - - var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); - - if (!returnType) { - returnType = resolvedReturnType; - this.setSymbolForAST(returnAST, resolvedReturnType, context); - } - - if (returnExpr && canTypeCheckAST) { - this.setTypeChecked(returnExpr, context); - this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); - } - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSwitchStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var expressionType = this.resolveAST(ast.expression, false, context).type; - - for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { - var switchClause = ast.switchClauses.childAt(i); - if (switchClause.kind() === 233 /* CaseSwitchClause */) { - var caseSwitchClause = switchClause; - - var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; - this.resolveAST(caseSwitchClause.statements, false, context); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); - } - } - } else { - var defaultSwitchClause = switchClause; - this.resolveAST(defaultSwitchClause.statements, false, context); - } - } - }; - - PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLabeledStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var labelIdentifier = ast.identifier.valueText(); - - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - 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); - }; - - PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { - switch (statement.kind()) { - case 160 /* LabeledStatement */: - return this.labelIsOnContinuableConstruct(statement.statement); - - case 158 /* WhileStatement */: - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 161 /* DoStatement */: - return true; - - default: - return false; - } - }; - - PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckContinueStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.isIterationStatement = function (ast) { - switch (ast.kind()) { - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 158 /* WhileStatement */: - case 161 /* DoStatement */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { - switch (ast.kind()) { - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 129 /* FunctionDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 241 /* FunctionPropertyAssignment */: - case 137 /* ConstructorDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.inSwitchStatement = function (ast) { - while (ast) { - if (ast.kind() === 151 /* SwitchStatement */) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { - while (ast) { - if (this.isIterationStatement(ast)) { - return true; - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { - var result = []; - - ast = ast.parent; - while (ast) { - if (ast.kind() === 160 /* LabeledStatement */) { - var labeledStatement = ast; - if (breakable) { - result.push(labeledStatement); - } else { - if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement); - } - } - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - break; - } - - ast = ast.parent; - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - 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.any(continuableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var continuableLabels = this.getEnclosingLabels(ast, false, true); - - 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)); - } - } - } - }; - - PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckBreakStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - if (ast.identifier) { - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var breakableLabels = this.getEnclosingLabels(ast, true, true); - 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, 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)); - } - } - }; - - PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { - if (!ast) { - return; - } - - var symbol = this.getSymbolForAST(ast, context); - if (symbol && symbol.isResolved) { - this.typeCheckAST(ast, isContextuallyTyped, context); - return symbol; - } - - if (ast.isExpression() && !isTypesOnlyLocation(ast)) { - return this.resolveExpressionAST(ast, isContextuallyTyped, context); - } - - var nodeType = ast.kind(); - - switch (nodeType) { - case 124 /* ArrayType */: - case 126 /* GenericType */: - case 122 /* ObjectType */: - case 127 /* TypeQuery */: - case 125 /* ConstructorType */: - case 123 /* FunctionType */: - return this.resolveTypeReference(ast, context); - - case 1 /* List */: - return this.resolveList(ast, context); - - case 2 /* SeparatedList */: - return this.resolveSeparatedList(ast, context); - - case 120 /* SourceUnit */: - return this.resolveSourceUnit(ast, context); - - case 132 /* EnumDeclaration */: - return this.resolveEnumDeclaration(ast, context); - - case 130 /* ModuleDeclaration */: - return this.resolveModuleDeclaration(ast, context); - - case 128 /* InterfaceDeclaration */: - return this.resolveInterfaceDeclaration(ast, context); - - case 131 /* ClassDeclaration */: - return this.resolveClassDeclaration(ast, context); - - case 224 /* VariableDeclaration */: - return this.resolveVariableDeclarationList(ast, context); - - case 136 /* MemberVariableDeclaration */: - return this.resolveMemberVariableDeclaration(ast, context); - - case 225 /* VariableDeclarator */: - return this.resolveVariableDeclarator(ast, context); - - case 141 /* PropertySignature */: - return this.resolvePropertySignature(ast, context); - - case 227 /* ParameterList */: - return this.resolveParameterList(ast, context); - - case 242 /* Parameter */: - return this.resolveParameter(ast, context); - - case 243 /* EnumElement */: - return this.resolveEnumElement(ast, context); - - case 232 /* EqualsValueClause */: - return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); - - case 238 /* TypeParameter */: - return this.resolveTypeParameterDeclaration(ast, context); - - case 239 /* Constraint */: - return this.resolveConstraint(ast, context); - - case 133 /* ImportDeclaration */: - return this.resolveImportDeclaration(ast, context); - - case 240 /* SimplePropertyAssignment */: - return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); - - case 241 /* FunctionPropertyAssignment */: - return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); - - case 11 /* IdentifierName */: - TypeScript.Debug.assert(isTypesOnlyLocation(ast)); - return this.resolveTypeNameExpression(ast, context); - - case 121 /* QualifiedName */: - return this.resolveQualifiedName(ast, context); - - case 137 /* ConstructorDeclaration */: - return this.resolveConstructorDeclaration(ast, context); - - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return this.resolveAccessorDeclaration(ast, context); - - case 138 /* IndexMemberDeclaration */: - return this.resolveIndexMemberDeclaration(ast, context); - - case 144 /* IndexSignature */: - return this.resolveIndexSignature(ast, context); - - case 135 /* MemberFunctionDeclaration */: - return this.resolveMemberFunctionDeclaration(ast, context); - - case 142 /* CallSignature */: - return this.resolveCallSignature(ast, context); - - case 143 /* ConstructSignature */: - return this.resolveConstructSignature(ast, context); - - case 145 /* MethodSignature */: - return this.resolveMethodSignature(ast, context); - - 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); - - case 219 /* SimpleArrowFunctionExpression */: - return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 214 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - - case 35 /* ThisKeyword */: - return this.resolveThisExpression(ast, context); - - case 50 /* SuperKeyword */: - return this.resolveSuperExpression(ast, context); - - case 213 /* InvocationExpression */: - return this.resolveInvocationExpression(ast, context); - - case 216 /* ObjectCreationExpression */: - return this.resolveObjectCreationExpression(ast, context); - - case 220 /* CastExpression */: - return this.resolveCastExpression(ast, context); - - case 13 /* NumericLiteral */: - return this.semanticInfoChain.numberTypeSymbol; - - case 14 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 32 /* NullKeyword */: - return this.semanticInfoChain.nullTypeSymbol; - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 172 /* VoidExpression */: - return this.resolveVoidExpression(ast, context); - - case 174 /* AssignmentExpression */: - return this.resolveAssignmentExpression(ast, context); - - case 167 /* LogicalNotExpression */: - return this.resolveLogicalNotExpression(ast, context); - - case 193 /* NotEqualsWithTypeConversionExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 197 /* GreaterThanExpression */: - return this.resolveLogicalOperation(ast, context); - - case 208 /* AddExpression */: - case 175 /* AddAssignmentExpression */: - return this.resolveBinaryAdditionOperation(ast, context); - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.resolveUnaryArithmeticOperation(ast, context); - - case 210 /* PostIncrementExpression */: - case 211 /* PostDecrementExpression */: - return this.resolvePostfixUnaryExpression(ast, context); - - case 209 /* SubtractExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 189 /* BitwiseOrExpression */: - case 191 /* BitwiseAndExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - return this.resolveBinaryArithmeticExpression(ast, context); - - case 221 /* ElementAccessExpression */: - return this.resolveElementAccessExpression(ast, context); - - case 187 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); - - case 188 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, context); - - case 171 /* TypeOfExpression */: - return this.resolveTypeOfExpression(ast, context); - - case 170 /* DeleteExpression */: - return this.resolveDeleteExpression(ast, context); - - case 186 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, isContextuallyTyped, context); - - case 12 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 217 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, context); - - case 200 /* InstanceOfExpression */: - return this.resolveInstanceOfExpression(ast, context); - - case 173 /* CommaExpression */: - return this.resolveCommaExpression(ast, context); - - case 201 /* InExpression */: - return this.resolveInExpression(ast, context); - - case 223 /* OmittedExpression */: - return this.semanticInfoChain.undefinedTypeSymbol; - } - - TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); - }; - - PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { - if (!this.canTypeCheckAST(ast, context)) { - return; - } - - var nodeType = ast.kind(); - switch (nodeType) { - case 120 /* SourceUnit */: - this.typeCheckSourceUnit(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.typeCheckEnumDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.typeCheckModuleDeclaration(ast, context); - return; - - case 128 /* InterfaceDeclaration */: - this.typeCheckInterfaceDeclaration(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.typeCheckClassDeclaration(ast, context); - return; - - case 243 /* EnumElement */: - this.typeCheckEnumElement(ast, context); - return; - - case 136 /* MemberVariableDeclaration */: - this.typeCheckMemberVariableDeclaration(ast, context); - return; - - case 225 /* VariableDeclarator */: - this.typeCheckVariableDeclarator(ast, context); - return; - - case 141 /* PropertySignature */: - this.typeCheckPropertySignature(ast, context); - return; - - case 242 /* Parameter */: - this.typeCheckParameter(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.typeCheckImportDeclaration(ast, context); - return; - - case 215 /* ObjectLiteralExpression */: - this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 241 /* FunctionPropertyAssignment */: - this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); - return; - - case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - this.resolveTypeNameExpression(ast, context); - } else { - this.resolveNameExpression(ast, context); - } - return; - - case 212 /* MemberAccessExpression */: - this.resolveMemberAccessExpression(ast, context); - return; - - case 121 /* QualifiedName */: - this.resolveQualifiedName(ast, context); - return; - - case 222 /* FunctionExpression */: - 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); - break; - - case 142 /* CallSignature */: - this.typeCheckCallSignature(ast, context); - return; - - case 143 /* ConstructSignature */: - this.typeCheckConstructSignature(ast, context); - return; - - case 129 /* FunctionDeclaration */: { - var funcDecl = ast; - 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, isContextuallyTyped, context); - return; - - case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - return; - - case 214 /* ArrayLiteralExpression */: - this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 213 /* InvocationExpression */: - this.typeCheckInvocationExpression(ast, context); - return; - - case 216 /* ObjectCreationExpression */: - this.typeCheckObjectCreationExpression(ast, context); - return; - - case 150 /* ReturnStatement */: - this.resolveReturnStatement(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); - } - }; - - PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { - while (this.postTypeCheckWorkitems.length) { - var ast = this.postTypeCheckWorkitems.pop(); - this.postTypeCheck(ast, context); - } - }; - - PullTypeResolver.prototype.postTypeCheck = function (ast, context) { - var nodeType = ast.kind(); - - switch (nodeType) { - case 242 /* Parameter */: - case 225 /* VariableDeclarator */: - this.postTypeCheckVariableDeclaratorOrParameter(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.postTypeCheckClassDeclaration(ast, context); - return; - - case 129 /* FunctionDeclaration */: - this.postTypeCheckFunctionDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.postTypeCheckModuleDeclaration(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.postTypeCheckEnumDeclaration(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.postTypeCheckImportDeclaration(ast, context); - return; - - case 11 /* IdentifierName */: - this.postTypeCheckNameExpression(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); - } - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return this.cachedRegExpInterfaceType(); - } else { - return this.semanticInfoChain.anyTypeSymbol; - } - }; - - PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { - this.checkThisCaptureVariableCollides(nameAST, false, context); - }; - - PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { - this.setTypeChecked(nameAST, context); - this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { - var nameSymbol = this.getSymbolForAST(nameAST, context); - var foundCached = nameSymbol !== null; - - if (!foundCached || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.typeCheckNameExpression(nameAST, context); - } - nameSymbol = this.computeNameExpression(nameAST, context); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(nameAST, nameSymbol, context); - } - - return nameSymbol; - }; - - 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.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; - } - - var nameSymbol = null; - var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; - - if (!this.isInEnumDecl(enclosingDecl)) { - searchKind = searchKind & ~(67108864 /* EnumMember */); - } - - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); - } - - 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) { - 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]; - var nameParentDecl = nameDeclaration.getParentDecl(); - if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { - var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); - var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - - var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); - - if (currentParameterIndex >= 0) { - var matchingParameter; - if (parameterList) { - for (var i = 0; i <= currentParameterIndex; i++) { - var candidateParameter = parameterList.parameters.nonSeparatorAt(i); - if (candidateParameter && candidateParameter.identifier.valueText() === id) { - matchingParameter = candidateParameter; - break; - } - } - } - - 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); - } - } - } - - var aliasSymbol = null; - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); - - var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - if (aliasSymbol) { - this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); - if (parameterList) { - while (parameter && parameter.parent) { - if (parameter.parent.parent === parameterList) { - return parameterList.parameters.nonSeparatorIndexOf(parameter); - } - - parameter = parameter.parent; - } - } - - return -1; - }; - - PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { - var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol !== null; - - if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheckDottedNameAST) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); - } - - this.resolveDeclaredSymbol(symbol, context); - - if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(dottedNameAST, symbol, context); - this.setSymbolForAST(name, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { - var rhsName = name.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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)) { - lhsAlias.setIsUsedAsValue(); - } - lhsType = lhsAlias.getExportAssignedTypeSymbol(); - } - - if (lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (!lhsType) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); - return this.getNewErrorTypeSymbol(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType !== lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { - var instanceSymbol = lhsType.getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.type; - } - } - - var originalLhsTypeForErrorReporting = lhsType; - - lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); - - if (!nameSymbol) { - if (lhsType.kind === 32 /* DynamicModule */) { - var container = lhsType; - var associatedInstance = container.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.type; - - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); - } - } - - 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - } - - if (checkSuperPrivateAndStaticAccess) { - this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { - var typeNameSymbol = this.getSymbolForAST(nameAST, context); - - if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.setTypeChecked(nameAST, context); - } - typeNameSymbol = this.computeTypeNameExpression(nameAST, context); - this.setSymbolForAST(nameAST, typeNameSymbol, context); - } - - this.resolveDeclaredSymbol(typeNameSymbol, context); - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - var declPath = enclosingDecl.getParentPath(); - - var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } - - var typeNameSymbolAlias = null; - if (typeNameSymbol.isAlias()) { - typeNameSymbolAlias = typeNameSymbol; - this.resolveDeclaredSymbol(typeNameSymbol, context); - - var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); - - this.resolveDeclaredSymbol(aliasedType, context); - } - - if (typeNameSymbol.isTypeParameter()) { - if (this.isInStaticMemberContext(enclosingDecl)) { - var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - - if (parentDecl.kind === 8 /* Class */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); - return this.getNewErrorTypeSymbol(); - } - } - } - - if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { - typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); - } - - 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; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; - - if (genericTypeSymbol.isError()) { - return genericTypeSymbol; - } - - if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { - this.resolveDeclaredSymbol(genericTypeSymbol, context); - } - - 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()) { - for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - - if (typeArgs[i].isError()) { - typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - 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(); - } - - if (!genericTypeSymbol.isResolved) { - var typeDecls = genericTypeSymbol.getDeclarations(); - var childDecls = null; - - for (var i = 0; i < typeDecls.length; i++) { - childDecls = typeDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - - var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); - - var typeConstraint = null; - var upperBound = null; - - typeParameters = specializedSymbol.getTypeParameters(); - - var typeConstraintSubstitutionMap = []; - var typeArg = null; - - var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < typeParameters.length; i++) { - typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - for (var id in instantiatedSubstitutionMap) { - typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; - } - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] === typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); - } - - if (typeArg.isTypeParameter()) { - upperBound = typeArg.getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - 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)])); - } - } - } - - return specializedSymbol; - }; - - PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { - if (this.inTypeQuery(dottedNameAST)) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; - } - - var symbol = this.getSymbolForAST(dottedNameAST, context); - if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheck) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeQualifiedName(dottedNameAST, context); - this.setSymbolForAST(dottedNameAST, symbol, context); - } - - this.resolveDeclaredSymbol(symbol, context); - - 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) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); - var lhs = this.resolveAST(dottedNameAST.left, false, context); - - var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; - - if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { - if (lhs.isAlias()) { - lhs.setIsUsedAsValue(); - } - } - - if (!lhsType) { - return this.getNewErrorTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); - var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; - - 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.kind & 164 /* SomeContainer */) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().type; - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); - } - } - } - - if (!childTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - - return childTypeSymbol; - }; - - PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { - if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { - return false; - } - - if (returnTypeAnnotation) { - return false; - } - - if (parameters) { - for (var i = 0, n = parameters.length; i < n; i++) { - if (parameters.typeAt(i)) { - return false; - } - } - } - - var contextualFunctionTypeSymbol = context.getContextualType(); - - if (contextualFunctionTypeSymbol) { - this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); - var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; - if (!exactlyOneCallSignature) { - return false; - } - - var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; - return !callSignatureIsGeneric; - } - - return false; - }; - - PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { - var funcDeclSymbol = null; - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { - return funcDeclSymbol; - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - TypeScript.Debug.assert(funcDeclSymbol); - - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - funcDeclSymbol.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - var assigningFunctionSignature = null; - if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { - assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; - } - - this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.returnType; - - if (returnType) { - context.propagateContextualType(returnType); - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popAnyContextualType(); - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - var functionExpressionName = functionDecl.getFunctionExpressionName(); - - if (functionExpressionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); - } - } - - context.setTypeInContext(funcDeclSymbol, funcDeclType); - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); - } - - return funcDeclSymbol; - }; - - 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcDeclSymbol = functionDecl.getSymbol(); - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - var returnTypeSymbol = signature.returnType; - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - 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.popAnyContextualType(); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); - - this.validateVariableDeclarationGroups(functionDecl, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { - var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); - var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; - - if (this.canTypeCheckAST(thisExpression, context)) { - this.typeCheckThisExpression(thisExpression, context, enclosingDecl); - } - - return thisTypeSymbol; - }; - - PullTypeResolver.prototype.inTypeArgumentList = function (ast) { - var previous = null; - var current = ast; - - while (current) { - switch (current.kind()) { - case 126 /* GenericType */: - var genericType = current; - if (genericType.typeArgumentList === previous) { - return true; - } - break; - - case 226 /* ArgumentList */: - var argumentList = current; - return argumentList.typeArgumentList === previous; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { - while (ast) { - switch (ast.kind()) { - case 230 /* ExtendsHeritageClause */: - var heritageClause = ast; - - return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inTypeQuery = function (ast) { - while (ast) { - switch (ast.kind()) { - case 127 /* TypeQuery */: - return true; - case 129 /* FunctionDeclaration */: - case 213 /* InvocationExpression */: - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 213 /* InvocationExpression */: - var invocationExpression = current; - if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - break; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inConstructorParameterList = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 142 /* CallSignature */: - var callSignature = current; - if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { - return true; - } - - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - 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 */) { - return true; - } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { - this.checkForThisCaptureInArrowFunction(thisExpression); - - if (this.inConstructorParameterList(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); - return; - } - - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { - return; - } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - if (currentDecl.getParentDecl() === null) { - return; - } else { - 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)); - } - - return; - } else if (currentDecl.kind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); - } - - return; - } - } - }; - - PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var isStaticContext = false; - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declFlags & 16 /* Static */) { - isStaticContext = true; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - return null; - } else if (declKind === 16384 /* Function */) { - return null; - } else if (declKind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(ast)) { - return this.getNewErrorTypeSymbol(); - } else { - var classSymbol = decl.getSymbol(); - if (isStaticContext) { - var constructorSymbol = classSymbol.getConstructorMethod(); - return constructorSymbol.type; - } else { - return classSymbol; - } - } - } - } - } - - return null; - }; - - PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { - return true; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - var superType = this.semanticInfoChain.anyTypeSymbol; - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); - - if (classSymbol) { - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - superType = parents[0]; - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSuperExpression(ast, context, enclosingDecl); - } - - return superType; - }; - - PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { - this.setTypeChecked(ast, context); - - this.checkForThisCaptureInArrowFunction(ast); - - var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; - var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; - TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); - - if (isSuperPropertyAccess) { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 8 /* Class */) { - if (!this.enclosingClassIsDerived(currentDecl)) { - 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 if (this.inStaticMemberVariableDeclaration(ast)) { - break; - } - - 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 { - 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)); - } - } - }; - - PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { - return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { - if (this.canTypeCheckAST(expressionAST, context)) { - this.setTypeChecked(expressionAST, context); - } - symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); - this.setSymbolForAST(expressionAST, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { - var boundMemberSymbols = []; - var memberSymbol; - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var id = this.getPropertyAssignmentName(propertyAssignment); - var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); - - var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; - var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); - TypeScript.Debug.assert(decl); - - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - if (!isUsingExistingSymbol) { - memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - } else { - memberSymbol = decl.getSymbol(); - } - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - memberSymbol = decl.getSymbol(); - } else { - TypeScript.Debug.assert(isAccessor); - memberSymbol = decl.getSymbol(); - } - - if (!isUsingExistingSymbol && !isAccessor) { - var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); - if (existingMember) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); - } - - objectLiteralTypeSymbol.addMember(memberSymbol); - } - - boundMemberSymbols.push(memberSymbol); - } - - return boundMemberSymbols; - }; - - PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var acceptedContextualType = false; - var assigningSymbol = null; - - var id = this.getPropertyAssignmentName(propertyAssignment); - var memberSymbol = boundMemberSymbols[i]; - var contextualMemberType = null; - - if (objectLiteralContextualType) { - assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); - - if (!assigningSymbol) { - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - assigningSymbol = numericIndexerSignature; - } else if (stringIndexerSignature) { - assigningSymbol = stringIndexerSignature; - } - } - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - - contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.propagateContextualType(contextualMemberType); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = contextualMemberType; - } - } - } - - var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; - - if (memberSymbolType) { - if (memberSymbolType.isGeneric()) { - objectLiteralTypeSymbol.setHasGenericMember(); - } - - if (stringIndexerSignature) { - allMemberTypes.push(memberSymbolType); - } - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberSymbolType); - } - } - - if (acceptedContextualType) { - pullTypeContext.popAnyContextualType(); - } - - var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!memberSymbol.isResolved) { - if (isAccessor) { - this.setSymbolForAST(id, memberSymbolType, pullTypeContext); - } else { - pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); - memberSymbol.setResolved(); - - this.setSymbolForAST(id, memberSymbol, pullTypeContext); - } - } - } - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { - var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); - TypeScript.Debug.assert(objectLitDecl); - - var typeSymbol = this.getSymbolForAST(objectLitAST, context); - var isUsingExistingSymbol = !!typeSymbol; - - if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); - typeSymbol.addDeclaration(objectLitDecl); - this.setSymbolForAST(objectLitAST, typeSymbol, context); - objectLitDecl.setSymbol(typeSymbol); - } - - var propertyAssignments = objectLitAST.propertyAssignments; - var contextualType = null; - - if (isContextuallyTyped) { - contextualType = context.getContextualType(); - this.resolveDeclaredSymbol(contextualType, context); - } - - var stringIndexerSignature = null; - var numericIndexerSignature = null; - var allMemberTypes = null; - var allNumericMemberTypes = null; - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - - stringIndexerSignature = indexSignatures.stringSignature; - numericIndexerSignature = indexSignatures.numericSignature; - - var inInferentialTyping = context.isInferentiallyTyping(); - if (stringIndexerSignature) { - allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; - } - - if (numericIndexerSignature) { - allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; - } - } - - if (propertyAssignments) { - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); - - this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); - - if (!isUsingExistingSymbol) { - this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); - this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); - } - } - - typeSymbol.setResolved(); - return typeSymbol; - }; - - PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { - return propertyAssignment.propertyName; - } else { - TypeScript.Debug.assert(false); - } - }; - - PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { - if (contextualIndexSignature) { - var typeCollection = { - getLength: function () { - return indexerTypeCandidates.length; - }, - getTypeAtIndex: function (index) { - return indexerTypeCandidates[index]; - } - }; - var decl = objectLiteralSymbol.getDeclarations()[0]; - 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); - } - } - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { - var symbol = this.getSymbolForAST(arrayLit, context); - if (!symbol || this.canTypeCheckAST(arrayLit, context)) { - if (this.canTypeCheckAST(arrayLit, context)) { - this.setTypeChecked(arrayLit, context); - } - symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); - this.setSymbolForAST(arrayLit, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { - var elements = arrayLit.expressions; - var elementType = null; - var elementTypes = []; - var comparisonInfo = new TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, context); - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - if (indexSignatures.numericSignature) { - contextualElementType = indexSignatures.numericSignature.returnType; - } - } - } - - if (elements) { - if (contextualElementType) { - context.propagateContextualType(contextualElementType); - } - - for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { - elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); - } - - if (contextualElementType) { - context.popAnyContextualType(); - } - } - - if (elementTypes.length) { - elementType = elementTypes[0]; - } - var collection; - - if (contextualElementType && !context.isInferentiallyTyping()) { - if (!elementType) { - elementType = contextualElementType; - } - - collection = { - getLength: function () { - return elements.nonSeparatorCount() + 1; - }, - getTypeAtIndex: function (index) { - return index === 0 ? contextualElementType : elementTypes[index - 1]; - } - }; - } else { - collection = { - getLength: function () { - return elements.nonSeparatorCount(); - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - } - - elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; - - if (!elementType) { - elementType = this.semanticInfoChain.undefinedTypeSymbol; - } - - return this.getArrayType(elementType); - }; - - PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { - var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); - - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); - } - - return symbolAndDiagnostic.symbol; - }; - - PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { - this.setTypeChecked(callEx, context); - context.postDiagnostic(symbolAndDiagnostic.diagnostic); - }; - - PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; - - var targetTypeSymbol = targetSymbol.type; - - targetTypeSymbol = this.getApparentType(targetTypeSymbol); - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return { symbol: targetTypeSymbol }; - } - - var elementType = targetTypeSymbol.getElementType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return { symbol: elementType }; - } - - 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); - - if (member) { - this.resolveDeclaredSymbol(member, context); - - return { symbol: member.type }; - } - } - - var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); - - var stringSignature = signatures.stringSignature; - var numberSignature = signatures.numericSignature; - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; - } 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 { - symbol: this.getNewErrorTypeSymbol(), - diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) - }; - } - }; - - 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; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - if (!signature.isResolved) { - this.resolveDeclaredSymbol(signature, context); - } - - paramSymbols = signature.parameters; - - if (paramSymbols.length) { - paramType = paramSymbols[0].type; - - if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signature; - continue; - } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { - numberSignature = signature; - continue; - } - } - } - - return { - numericSignature: numberSignature, - stringSignature: stringSignature - }; - }; - - 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; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { - rhsType = this.semanticInfoChain.numberTypeSymbol; - } - - 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 { - lhsType = rhsType; - } - } else if (isRhsTypeNullOrUndefined) { - rhsType = lhsType; - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (exprType) { - if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { - if (!this.isReference(binaryExpression.left, lhsExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, exprType, lhsType, context); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); - } - } - - if (!exprType) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { - return this.findBestCommonType({ - getLength: function () { - return 2; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - } - } - }, context); - }; - - PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { - return this.findBestCommonType({ - getLength: function () { - return 3; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - case 2: - return type3; - } - } - }, context); - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - } - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; - var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; - - 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.pushNewContextualType(leftType); - var rightType = this.resolveAST(binex.right, true, context).type; - context.popAnyContextualType(); - - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - - this.resolveAST(binex.left, false, context); - } - - return this.resolveAST(binex.right, false, context).type; - }; - - PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped && !context.isInferentiallyTyping()) { - var contextualType = context.getContextualType(); - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); - } else { - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { - var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; - var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; - - var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); - - var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); - - if (this.canTypeCheckAST(trinex, context)) { - this.setTypeChecked(trinex, context); - this.resolveAST(trinex.condition, false, context); - - if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); - } - } - } - - if (!conditionalTypesAreValid) { - return this.getNewErrorTypeSymbol(); - } - - return expressionType; - }; - - PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { - return true; - } - } else { - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveAST(ast.expression, false, context); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - if (symbol !== this.semanticInfoChain.anyTypeSymbol) { - this.setSymbolForAST(callEx, symbol, context); - } - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckInvocationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - var targetSymbol = this.resolveAST(callEx.expression, false, context); - - if (callEx.argumentList.arguments) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - - var len = callEx.argumentList.arguments.nonSeparatorCount(); - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var targetTypeSymbol = targetSymbol.type; - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); - return this.getNewErrorTypeSymbol(); - } - } - - return this.semanticInfoChain.anyTypeSymbol; - } - - var isSuperCall = false; - - if (callEx.expression.kind() === 50 /* SuperKeyword */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = targetTypeSymbol.getConstructorMethod(); - this.resolveDeclaredSymbol(targetSymbol, context); - targetTypeSymbol = targetSymbol.type; - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); - this.resolveAST(callEx.argumentList.arguments, false, context); - - return this.getNewErrorTypeSymbol(); - } - } - - var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - - 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 explicitTypeArgs = null; - var couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - var triedToInferTypeArgs = false; - - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var beforeResolutionSignatures = signatures; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - couldNotAssignToConstraint = false; - - if (signatures[i].isGeneric() && typeParameters.length) { - if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { - explicitTypeArgs = signatures[i].returnType.getTypeArguments(); - } - - 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, 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; - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - - var errorCondition = null; - if (!signatures.length) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (!couldNotFindGenericOverload) { - 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); - } - return this.semanticInfoChain.anyTypeSymbol; - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); - } else if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!signatures.length) { - return errorCondition; - } - - signature = signatures[0]; - } - - 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 (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; - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - this.setSymbolForAST(callEx, symbol, context); - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckObjectCreationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - this.resolveAST(callEx.expression, false, context); - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (callEx.argumentList) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - var len = callEx.argumentList.arguments.nonSeparatorCount(); - - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { - if (!context.inProvisionalResolution()) { - additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); - } - context.postDiagnostic(diagnostic); - }; - - PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { - var _this = this; - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; - - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var explicitTypeArgs = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - return targetTypeSymbol; - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - - if (this.compilationSettings.noImplicitAny()) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); - } - } - - if (constructSignatures.length) { - if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var triedToInferTypeArgs; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric()) { - typeParameters = constructSignatures[i].getTypeParameters(); - - 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, explicitTypeArgs.length]); - continue; - } - } 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 { - inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { - return typeParameter.getDefaultConstraint(_this.semanticInfoChain); - }); - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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(constructSignatures[i], typeReplacementMap); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } else { - if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - - if (!constructSignatures.length) { - if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var errorCondition = null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!constructSignatures.length) { - return errorCondition; - } - - signature = constructSignatures[0]; - } - - returnType = signature.returnType; - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (explicitTypeArgs && explicitTypeArgs.length) { - returnType = this.createInstantiatedType(returnType, explicitTypeArgs); - } else { - returnType = this.instantiateTypeToAny(returnType, context); - } - } - - if (usedCallSignaturesInstead) { - 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(); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.returnType; - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList && callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - } else if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); - - return this.getNewErrorTypeSymbol(); - }; - - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { - var typeReplacementMap = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters = signatureAToInstantiate.getTypeParameters(); - var typeConstraint = null; - - var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); - inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); - - var functionTypeA = signatureAToInstantiate.functionType; - var functionTypeB = contextualSignatureB.functionType; - var enclosingTypeParameterMap; - - if (functionTypeA) { - enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - if (functionTypeB) { - enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); - - return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); - }; - - PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { - var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; - - if (this.canTypeCheckAST(assertionExpression, context)) { - this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); - } - - return typeAssertionType; - }; - - PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { - this.setTypeChecked(assertionExpression, context); - - context.pushNewContextualType(typeAssertionType); - var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popAnyContextualType(); - - this.resolveDeclaredSymbol(typeAssertionType, context); - this.resolveDeclaredSymbol(exprType, context); - - var comparisonInfo = new TypeComparisonInfo(); - - 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); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { - var leftExpr = this.resolveAST(binaryExpression.left, false, context); - var leftType = leftExpr.type; - - context.pushNewContextualType(leftType); - var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popAnyContextualType(); - - rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (!this.isReference(binaryExpression.left, leftExpr)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } else { - this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); - } - } - - return rightType; - }; - - PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { - var typeToReturn = type; - if (typeToReturn && typeToReturn.isAlias()) { - typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); - } - - if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { - var instanceTypeSymbol = typeToReturn.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); - typeToReturn = null; - } else { - typeToReturn = instanceTypeSymbol; - } - } - - return typeToReturn; - }; - - PullTypeResolver.prototype.widenType = function (type, ast, context) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (type.isArrayNamedTypeReference()) { - 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(); - - for (var i = 0; i < len; i++) { - var candidateType = collection.getTypeAtIndex(i); - if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { - return candidateType; - } - } - - return this.semanticInfoChain.emptyTypeSymbol; - }; - - PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { - for (var i = 0; i < collection.getLength(); i++) { - var otherType = collection.getTypeAtIndex(i); - if (candidateType === otherType) { - continue; - } - - if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - if (t1 && t2) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); - } - } - - return this.typesAreIdentical(t1, t2, context); - }; - - 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); - - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - return false; - } - - if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { - return false; - } - - if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - 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(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return false; - } - } - - if (t1.isPrimitive() !== t2.isPrimitive()) { - return 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) { - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); - - if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { - return false; - } - - return true; - }; - - 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; - } - - if (!sg1 || !sg2) { - return false; - } - - if (sg1.length !== sg2.length) { - return false; - } - - 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; - } - } - - return true; - }; - - 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; - } - - if (tp1 && tp2 && (tp1.length !== tp2.length)) { - return false; - } - - 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) { - var decls1 = symbol1.getDeclarations(); - var decls2 = symbol2.getDeclarations(); - - if (decls1.length && decls2.length) { - return decls1[0] === decls2[0]; - } - - return false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { - if (source.isFunctionType()) { - return true; - } - - return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); - }; - - 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.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) { - if (symbol && symbol.isTypeReference()) { - return symbol.getReferencedTypeSymbol(); - } - - return symbol; - }; - - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - if (source && target) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - } - } - - 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); - - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - var sourceApparentType = this.getApparentType(source); - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } - - if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - 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) { - return true; - } - - return false; - } else if (source === this.semanticInfoChain.voidTypeSymbol) { - if (target === this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return assignableTo; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { - return false; - } - - if (source.getIsSpecialized() && target.getIsSpecialized()) { - 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, true); - - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { - break; - } - } - - if (i === sourceTypeArguments.length) { - return true; - } else { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - } - } - } - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter()) { - if (!source.getConstraint()) { - return this.typesAreIdentical(target, source, context); - } else { - return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); - } - } else { - if (isComparingInstantiatedSignatures) { - target = target.getBaseConstraint(this.semanticInfoChain); - } else { - return this.typesAreIdentical(target, sourceApparentType, context); - } - } - } - - 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; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - - var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); - - this.resolveDeclaredSymbol(targetProp, context); - - var targetPropType = targetProp.type; - - 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = targetType.widenedType(this, null, context); - var widenedSourceType = sourceType.widenedType(this, null, context); - - if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - - 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var comparisonInfoTypeArgumentsCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); - } - 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_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_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, isRelatable); - return isRelatable; - }; - - 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)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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++) { - 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; - } - } - } - - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - 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 (comparisonInfo) { - var names = getNames(true); - var code; - if (targetPropIsPrivate) { - 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 { - 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; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (targetDecl !== sourceDecl) { - if (comparisonInfo) { - var names = getNames(true); - - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - 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; - } - } - - if (sourceProp.isOptional && !targetProp.isOptional) { - if (comparisonInfo) { - 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); - } - return false; - } - - this.resolveDeclaredSymbol(sourceProp, context); - - var sourcePropType = sourceProp.type; - var targetPropType = targetProp.type; - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - context.walkMemberTypes(targetProp.name); - var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); - context.postWalkMemberTypes(); - - if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - var names = getNames(false); - if (comparisonInfoPropertyTypeCheck && 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 { - 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 isSourcePropertyRelatableToTargetProperty; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); - var targetStringSig = targetIndexSigs.stringSignature; - var targetNumberSig = targetIndexSigs.numericSignature; - - if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); - var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); - var sourceStringSig = sourceIndexSigs.stringSignature; - var sourceNumberSig = sourceIndexSigs.numericSignature; - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - 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++) { - var mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - var nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { - continue; - } - - 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; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - - if (comparisonInfo && sigsCompared == 1) { - comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; - } - - return false; - } - - return true; - }; - - 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; - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; - var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; - - 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, [targetParameters.length])); - } - return false; - } - - if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { - return true; - } - - 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) { - context.walkReturnTypes(); - var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - context.postWalkReturnTypes(); - if (!returnTypesAreRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - - return false; - } - } - - 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 (!areParametersRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - } - - return areParametersRelatable; - }); - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { - var _this = this; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeComparisonInfo(); - var args = application.argumentList ? application.argumentList.arguments : null; - - var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { - if (hasOverloads && signature.isDefinition()) { - return false; - } - - var rootSignature = signature.getRootSymbol(); - if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { - return false; - } - - return _this.overloadHasCorrectArity(signature, args); - }); - - var firstAssignableButNotSupertypeSignature = null; - var firstAssignableWithProvisionalErrorsSignature = null; - - for (var i = 0; i < initialCandidates.length; i++) { - var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); - if (applicability === 3 /* Subtype */) { - return initialCandidates[i]; - } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { - firstAssignableButNotSupertypeSignature = initialCandidates[i]; - } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { - firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; - } - } - - if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { - return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; - } else { - var target = this.getCallTargetErrorSpanAST(application); - if (comparisonInfo.message) { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); - } else { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); - } - } - - return null; - }; - - PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { - return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; - }; - - PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { - if (args == null) { - return signature.nonOptionalParamCount === 0; - } - - var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); - if (numberOfArgs < signature.nonOptionalParamCount) { - return false; - } - if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { - if (args === null) { - return 3 /* Subtype */; - } - - var isInVarArg = false; - var parameters = signature.parameters; - var paramType = null; - - var overloadApplicability = 3 /* Subtype */; - - for (var i = 0; i < args.nonSeparatorCount(); i++) { - if (!isInVarArg) { - this.resolveDeclaredSymbol(parameters[i], context); - - if (parameters[i].isVarArg) { - paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); - isInVarArg = true; - } else { - paramType = parameters[i].type; - } - } - - var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); - - if (statusOfCurrentArgument === 0 /* NotAssignable */) { - return 0 /* NotAssignable */; - } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { - overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; - } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { - overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; - } - } - - return overloadApplicability; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType.isAny()) { - return 3 /* Subtype */; - } else if (paramType.isError()) { - return 1 /* AssignableButWithProvisionalErrors */; - } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrowFunction = arg; - 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.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.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 */) { - return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else { - return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); - } - }; - - PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { - if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - 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.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveObjectLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType === this.cachedArrayInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveArrayLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - var argSym = this.resolveAST(arg, false, context); - - if (argSym.type.isAlias()) { - var aliasSym = argSym.type; - argSym = aliasSym.getExportAssignedTypeSymbol(); - } - - comparisonInfo.stringConstantVal = arg; - return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { - var tempComparisonInfo = new TypeComparisonInfo(); - tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; - if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { - return 3 /* Subtype */; - } - - if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { - return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; - } - - if (!comparisonInfo.message) { - var enclosingSymbol = this.getEnclosingSymbolForAST(arg); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); - } - - return 0 /* NotAssignable */; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { - var inferenceResultTypes = argContext.inferTypeArguments(); - var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); - TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); - - 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 (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 inferenceResultTypes; - }; - - PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { - var enclosingDecl = this.getEnclosingDeclForAST(args); - var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); - return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; - }; - - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { - if (expressionType && parameterType) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); - return; - } - } - this.relateTypeToTypeParameters(expressionType, parameterType, 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; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType.isTypeParameter()) { - var typeParameter = parameterType; - argContext.addCandidateForInference(typeParameter, expressionType); - return; - } - - if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { - return; - } - - 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.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) { - return; - } - - var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeArguments = parameterType.getTypeArguments(); - - if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { - for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); - } - } - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var _this = this; - var expressionReturnType = expressionSignature.returnType; - var parameterReturnType = parameterSignature.returnType; - - parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { - context.walkParameterTypes(i); - _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); - context.postWalkParameterTypes(); - return true; - }); - - context.walkReturnTypes(); - this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); - context.postWalkReturnTypes(); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - return; - } - - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); - if (objectMember) { - this.resolveDeclaredSymbol(objectMember); - this.resolveDeclaredSymbol(parameterTypeMembers[i]); - context.walkMemberTypes(parameterTypeMembers[i].name); - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); - context.postWalkMemberTypes(); - } - } - - this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); - - this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; - } - - 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) { - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!typeParameters.length) { - return typeToSpecialize; - } - - var typeArguments = null; - - 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) { - typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; - } else { - typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; - } - } - - var type = this.createInstantiatedType(typeToSpecialize, typeArguments); - - 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(); - - var resolver = semanticInfoChain.getResolver(); - var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); - - if (resolver.canTypeCheckAST(sourceUnit, context)) { - resolver.resolveAST(sourceUnit, false, context); - resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); - - while (resolver.typeCheckCallBacks.length) { - var callBack = resolver.typeCheckCallBacks.pop(); - callBack(context); - } - - resolver.processPostTypeCheckWorkItems(context); - } - }; - - PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { - var _this = this; - this.scanVariableDeclarationGroups(enclosingDecl, function (_) { - }, function (subsequentDecl, firstSymbol) { - if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { - return; - } - - var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); - - var symbol = subsequentDecl.getSymbol(); - var symbolType = symbol.type; - var firstSymbolType = firstSymbol.type; - - 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) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i] === signature) { - break; - } - - 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)); - } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); - } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); - } else { - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved) { - this.resolveDeclaredSymbol(allSignatures[i], context); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - 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_assignable_to_any_non_specialized_signature)); - } - } - } else if (definitionSignature && definitionSignature !== signature) { - var comparisonInfo = new TypeComparisonInfo(); - - if (!definitionSignature.isResolved) { - this.resolveDeclaredSymbol(definitionSignature, context); - } - - if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { - var errorCode; - - 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; - } - - if (errorCode) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); - } - } - }; - - PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { - if (!symbol || symbol.kind === 2 /* Primitive */) { - return; - } - - if (symbol.isType()) { - var typeSymbol = symbol; - var isNamedType = typeSymbol.isNamedTypeSymbol(); - - if (typeSymbol.isArrayNamedTypeReference()) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); - return; - } - - if (!isNamedType) { - var typeOfSymbol = typeSymbol.getTypeOfSymbol(); - if (typeOfSymbol) { - this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); - return; - } - } - - if (typeSymbol.inSymbolPrivacyCheck) { - return; - } - - typeSymbol.inSymbolPrivacyCheck = true; - - var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); - if (typars) { - for (var i = 0; i < typars.length; i++) { - this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); - } - } - - if (!isNamedType) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind === 8192 /* TypeParameter */) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); - } - - typeSymbol.inSymbolPrivacyCheck = false; - - if (!isNamedType) { - return; - } - } - - if (declSymbol.isExternallyVisible()) { - var symbolIsVisible = symbol.isExternallyVisible(); - - 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]) { - 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(); - break; - } - } - symbol = symbolPath[symbolPath.length - 1]; - } - } else if (symbol.kind === 128 /* TypeAlias */) { - var aliasSymbol = symbol; - symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(); - } - - if (!symbolIsVisible) { - privacyErrorReporter(symbol); - } - } - }; - - PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length > 1 && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); - } - - var params = signature.parameters; - for (var j = 0; j < params.length; j++) { - var paramType = params[j].type; - this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); - } - - var returnType = signature.returnType; - this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); - } - }; - - 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; - var messageCode; - - var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; - } - } - - var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { - var typeSymbol = symbol; - var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isProperty = declSymbol.kind === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; - } - } else { - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return; - } - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; - var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; - var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); - var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); - this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { - return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); - }); - } - } - - if (!isGetter && !isIndexSignature) { - var funcParams = functionSignature.parameters; - for (var i = 0; i < funcParams.length; i++) { - this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); - }); - } - } - - if (!isSetter) { - this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); - }); - } - }; - - PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else if (!isGetter) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var parameter = parameters.astAt(argIndex); - - var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { - var _this = this; - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var messageCode = null; - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; - } - } - - if (messageCode) { - var messageArguments = [typeSymbolName]; - var reportOnFuncDecl = false; - - if (returnTypeAnnotation) { - var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); - } - } - - if (block) { - var reportErrorOnReturnExpressions = function (ast, walker) { - var go = true; - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - } - } - }; - - PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { - TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); - - var classSymbol = classDecl.getSymbol(); - return classSymbol.getExtendedTypes().length > 0; - }; - - PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { - if (ast.kind() === 213 /* InvocationExpression */) { - var invocationExpression = ast; - if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { - if (node && node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - if (this.isSuperInvocationExpression(expressionStatement.expression)) { - return true; - } - } - return false; - }; - - PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { - if (block && block.statements && block.statements.childCount() > 0) { - return block.statements.childAt(0); - } - - return null; - }; - - PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { - TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); - - if (constructorDecl) { - var enclosingClass = constructorDecl.getParentDecl(); - - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.kind === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.kind() === 242 /* Parameter */) { - return true; - } - - if (ast.kind() === 136 /* MemberVariableDeclaration */) { - var variableDeclarator = ast; - if (variableDeclarator.variableDeclarator.equalsValueClause) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { - var enclosingDecl = this.getEnclosingDeclForAST(expression); - - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var inArrowFunction = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - inArrowFunction = true; - continue; - } - - if (inArrowFunction) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - var constructorSymbol = decl.getSymbol().getConstructorMethod(); - var constructorDecls = constructorSymbol.getDeclarations(); - for (var i = 0; i < constructorDecls.length; i++) { - constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; - } - } - break; - } - } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { - break; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); - var stringSignature = indexSignatures.stringSignature; - var numberSignature = indexSignatures.numericSignature; - - if (stringSignature || numberSignature) { - var members = containerTypeDecl.getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { - var memberSymbol = member.getSymbol(); - var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); - if (relevantSignature) { - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { - this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); - } - } - } - } - } - }; - - PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { - if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { - return numberIndexSignature; - } else if (stringIndexSignature) { - return stringIndexSignature; - } - - return null; - }; - - PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { - 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.kind; - var extendedMemberKind = extendedTypeMember.kind; - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { - var typeMembers = typeSymbol.getMembers(); - - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - var foundError1 = false; - var foundError2 = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].name; - var extendedTypeProp = extendedType.findMember(propName, true); - if (extendedTypeProp) { - this.resolveDeclaredSymbol(extendedTypeProp, context); - foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); - - if (!foundError1) { - foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); - } - - if (foundError1 || foundError2) { - foundError = true; - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = typeSymbol.getConstructorMethod().type; - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = extendedType.getConstructorMethod().type; - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].name; - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved) { - this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); - } - - if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; - } else { - if (extendedType.isClass()) { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; - } else { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - } - } - } - - if (foundError) { - var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { - var prevInTypeCheck = context.inTypeCheck; - context.inTypeCheck = false; - - var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - - 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; - } - - if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { - return true; - } - - var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; - - if (associatedContainerType) { - return associatedContainerType !== typeSymbol.getRootSymbol(); - } - - return true; - }; - - PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - - var baseType = this.resolveTypeReference(baseDeclAST, context).type; - - if (!baseType) { - return; - } - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (!baseType.isError()) { - if (isExtendedType) { - if (typeDeclIsClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); - } - } - return; - } else if (typeDeclIsClass && isExtendedType) { - if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { - 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)])); - } - } - - if (baseType.hasBase(typeSymbol)) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); - return; - } - - if (isExtendedType) { - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); - }); - } else { - TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); - }); - } - - this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { - return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); - }); - }; - - PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { - var _this = this; - var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); - if (!extendsClause && !implementsClause) { - return; - } - - if (extendsClause) { - for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); - } - } - - if (typeSymbol.isClass()) { - if (implementsClause) { - for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); - } - } - } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { - var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { - return decl.ast().heritageClauses !== null; - }).ast(); - if (classOrInterface === firstInterfaceASTWithExtendsClause) { - this.typeCheckCallBacks.push(function (context) { - _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); - }); - } - } - }; - - PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { - var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); - - var inheritedMembersMap = TypeScript.createIntrinsicsObject(); - var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); - - var typeHasOwnNumberIndexer = false; - var typeHasOwnStringIndexer = false; - - if (typeSymbol.hasOwnIndexSignatures()) { - var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); - for (var i = 0; i < ownIndexSignatures.length; i++) { - if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { - typeHasOwnNumberIndexer = true; - } else { - typeHasOwnStringIndexer = true; - } - } - } - var baseTypes = typeSymbol.getExtendedTypes(); - for (var i = 0; i < baseTypes.length; i++) { - if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { - return; - } - } - - if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { - return; - } - - this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; - var memberName = member.name; - - if (interfaceSymbol.findMember(memberName, false)) { - continue; - } - - this.resolveDeclaredSymbol(member, context); - - if (inheritedMembersMap[memberName]) { - var prevMember = inheritedMembersMap[memberName]; - 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; - } - } else { - inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); - } - } - - return false; - }; - - PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { - if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { - return false; - } - - var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { - var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; - - var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - 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, 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; - } - } else { - allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } else if (parameterTypeIsNumber) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - 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; - } - } else { - allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { - if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; - var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; - for (var memberName in inheritedMembers) { - var memberWithBaseOrigin = inheritedMembers[memberName]; - if (!memberWithBaseOrigin) { - continue; - } - - var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); - if (!relevantSignature) { - continue; - } - - var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; - var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; - - if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { - continue; - } - - 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_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_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])); - } - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - 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_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, [ - interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), - inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.isReference = function (ast, astSymbol) { - if (ast.kind() === 217 /* ParenthesizedExpression */) { - return this.isReference(ast.expression, astSymbol); - } - - if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { - return false; - } - - if (ast.kind() === 11 /* IdentifierName */) { - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { - return false; - } - - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { - return false; - } - - if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { - return false; - } - } - - if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { - if (resolvedName) { - if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { - return this.semanticInfoChain.getEnclosingDecl(ast); - }; - - PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - return enclosingDecl ? enclosingDecl.getSymbol() : null; - }; - - PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { - if (resolvedName) { - if (resolvedName.anyDeclHasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var memberClass = memberContainer.getDeclarations()[0].ast(); - TypeScript.Debug.assert(memberClass); - - var containingClass = this.getEnclosingClassDeclaration(name); - - if (!containingClass || containingClass !== memberClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { - if (type.isPrimitive()) { - return type; - } - - if (type.isError()) { - return type; - } - - if (typeParameterArgumentMap[type.pullSymbolID]) { - return typeParameterArgumentMap[type.pullSymbolID]; - } - - type._resolveDeclaredSymbol(); - if (type.isTypeParameter()) { - return this.instantiateTypeParameter(type, typeParameterArgumentMap); - } - - if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - } - - return type; - }; - - 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 rootSignature = signature.getRootSymbol(); - var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); - TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); - - var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiatedSignature) { - return instantiatedSignature; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); - - 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) { - for (var j = 0; j < parameters.length; j++) { - parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].isOptional) { - parameter.isOptional = true; - } - if (parameters[j].isVarArg) { - parameter.isVarArg = true; - instantiatedSignature.hasVarArgs = true; - } - instantiatedSignature.addParameter(parameter, parameter.isOptional); - - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); - } - } - - return instantiatedSignature; - }; - PullTypeResolver.globalTypeCheckPhase = 0; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; - - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent; - if (!useSameIndent) { - this.indent++; - } - } - } - TypeComparisonInfo.prototype.indentString = function () { - var result = ""; - - for (var i = 0; i < this.indent; i++) { - result += "\t"; - } - - return result; - }; - - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = this.message + TypeScript.newLine() + this.indentString() + message; - } else { - this.message = this.indentString() + message; - } - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - function getPropertyAssignmentNameTextFromIdentifier(identifier) { - if (identifier.kind() === 11 /* IdentifierName */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 14 /* StringLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 13 /* NumericLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; - - function isTypesOnlyLocation(ast) { - while (ast && ast.parent) { - switch (ast.parent.kind()) { - case 244 /* TypeAnnotation */: - return true; - case 127 /* TypeQuery */: - return false; - case 125 /* ConstructorType */: - var constructorType = ast.parent; - if (constructorType.type === ast) { - return true; - } - break; - case 123 /* FunctionType */: - var functionType = ast.parent; - if (functionType.type === ast) { - return true; - } - break; - case 239 /* Constraint */: - var constraint = ast.parent; - if (constraint.type === ast) { - return true; - } - break; - case 220 /* CastExpression */: - var castExpression = ast.parent; - return castExpression.type === ast; - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - return true; - case 228 /* TypeArgumentList */: - return true; - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 130 /* ModuleDeclaration */: - case 129 /* FunctionDeclaration */: - case 145 /* MethodSignature */: - case 212 /* MemberAccessExpression */: - case 242 /* Parameter */: - return false; - } - - ast = ast.parent; - } - - return false; - } - TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var sentinalEmptyArray = []; - - var SemanticInfoChain = (function () { - function SemanticInfoChain(compiler, logger) { - this.compiler = compiler; - this.logger = logger; - this.documents = []; - this.fileNameToDocument = TypeScript.createIntrinsicsObject(); - this.anyTypeDecl = null; - this.booleanTypeDecl = null; - this.numberTypeDecl = null; - this.stringTypeDecl = null; - this.nullTypeDecl = null; - this.undefinedTypeDecl = null; - this.voidTypeDecl = null; - this.undefinedValueDecl = null; - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.voidTypeSymbol = null; - this.undefinedValueSymbol = null; - this.emptyTypeSymbol = null; - this.astSymbolMap = []; - this.astAliasSymbolMap = []; - this.astCallResolutionDataMap = []; - this.declSymbolMap = []; - this.declSignatureSymbolMap = []; - this.declCache = null; - this.symbolCache = null; - this.fileNameToDiagnostics = null; - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - 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); - 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 */, 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 || null; - }; - - SemanticInfoChain.prototype.lineMap = function (fileName) { - return this.getDocument(fileName).lineMap(); - }; - - SemanticInfoChain.prototype.fileNames = function () { - if (this._fileNames === null) { - this._fileNames = this.documents.slice(1).map(function (s) { - return s.fileName; - }); - } - - return this._fileNames; - }; - - SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { - newSymbol.addDeclaration(decl); - decl.setSymbol(newSymbol); - newSymbol.setResolved(); - - return newSymbol; - }; - - SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { - var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { - var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); - newSymbol.type = type; - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.resetGlobalSymbols = function () { - this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); - this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); - this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); - this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); - this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); - this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); - this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); - this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); - - var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); - var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - emptyTypeDecl.setSymbol(emptyTypeSymbol); - emptyTypeSymbol.addDeclaration(emptyTypeDecl); - emptyTypeSymbol.setResolved(); - this.emptyTypeSymbol = emptyTypeSymbol; - }; - - SemanticInfoChain.prototype.addDocument = function (document) { - var fileName = document.fileName; - - var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (existingIndex < 0) { - this.documents.push(document); - } else { - this.documents[existingIndex] = document; - } - - this.fileNameToDocument[fileName] = document; - - this.invalidate(); - }; - - SemanticInfoChain.prototype.removeDocument = function (fileName) { - TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); - var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (index > 0) { - this.fileNameToDocument[fileName] = undefined; - this.documents.splice(index, 1); - this.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { - var cacheID = this.getDeclPathCacheID([name], kind); - - var symbol = this.symbolCache[cacheID]; - - if (!symbol) { - for (var i = 0, n = this.documents.length; i < n; i++) { - var topLevelDecl = this.documents[i].topLevelDecl(); - - var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); - if (symbol) { - break; - } - - if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { - return null; - } - } - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { - var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; - - var foundDecls = topLevelDecl.searchChildDecls(name, kind); - - for (var j = 0; j < foundDecls.length; j++) { - var foundDecl = foundDecls[j]; - - if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { - break; - } - - var symbol = foundDecls[j].getSymbol(); - if (symbol) { - return symbol; - } - } - - return null; - }; - - SemanticInfoChain.prototype.findExternalModule = function (id) { - id = TypeScript.normalizePath(id); - - var tsFile = id + ".ts"; - var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); - symbol = this.symbolCache[tsCacheID]; - if (symbol != undefined) { - return symbol; - } - - 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 isTsFile = document.fileName === tsFile; - if (isTsFile || document.fileName === dtsFile) { - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - symbol = dynamicModuleDecl.getSymbol(); - - 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 null; - }; - - SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { - var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); - - var symbol = this.symbolCache[cacheID]; - if (symbol == undefined) { - symbol = null; - for (var i = 0; i < this.documents.length; i++) { - var document = this.documents[i]; - var topLevelDecl = document.topLevelDecl(); - - if (!topLevelDecl.isExternalModule()) { - var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); - if (dynamicModules.length) { - symbol = dynamicModules[0].getSymbol(); - break; - } - } - } - - this.symbolCache[cacheID] = symbol; - } - - return symbol; - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.topLevelDecls(); - - var decls = TypeScript.sentinelEmptyArray; - var path; - var foundDecls = TypeScript.sentinelEmptyArray; - - 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, kind); - - for (var k = 0; k < foundDecls.length; k++) { - if (decls === TypeScript.sentinelEmptyArray) { - decls = []; - } - decls[decls.length] = foundDecls[k]; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { - var declString = []; - - for (var i = 0, n = declPath.length; i < n; i++) { - if (declPath[i].kind & 1 /* Script */) { - continue; - } - - declString.push(declPath[i].name); - } - - return this.findDecls(declString, declKind); - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - 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; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - } - }; - - SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { - if (typeof oldSettings === "undefined") { oldSettings = null; } - if (typeof newSettings === "undefined") { newSettings = null; } - TypeScript.PullTypeResolver.globalTypeCheckPhase++; - - var cleanStart = new Date().getTime(); - - this.astSymbolMap.length = 0; - this.astAliasSymbolMap.length = 0; - this.astCallResolutionDataMap.length = 0; - - this.declCache = TypeScript.createIntrinsicsObject(); - this.symbolCache = TypeScript.createIntrinsicsObject(); - this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - - this.declSymbolMap.length = 0; - this.declSignatureSymbolMap.length = 0; - - if (oldSettings && newSettings) { - if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { - for (var i = 1, n = this.documents.length; i < n; i++) { - this.documents[i].invalidate(); - } - } - } - - TypeScript.pullSymbolID = 0; - - this.resetGlobalSymbols(); - - var cleanEnd = new Date().getTime(); - }; - - SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); - }; - - SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()] || null; - }; - - SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { - this.astAliasSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { - return this.astAliasSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { - return this.astCallResolutionDataMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { - if (callResolutionData) { - this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap[decl.declID] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { - this.declSignatureSymbolMap[decl.declID] = signatureSymbol; - }; - - SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { - return this.declSignatureSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { - var fileName = diagnostic.fileName(); - var diagnostics = this.fileNameToDiagnostics[fileName]; - if (!diagnostics) { - diagnostics = []; - this.fileNameToDiagnostics[fileName] = diagnostics; - } - - diagnostics.push(diagnostic); - }; - - SemanticInfoChain.prototype.getDiagnostics = function (fileName) { - var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics || []; - }; - - SemanticInfoChain.prototype.getBinder = function () { - if (!this._binder) { - this._binder = new TypeScript.PullSymbolBinder(this); - } - - return this._binder; - }; - - SemanticInfoChain.prototype.getResolver = function () { - if (!this._resolver) { - this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); - } - - return this._resolver; - }; - - SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); - indexParameterSymbol.type = indexParamType; - indexSignature.addParameter(indexParameterSymbol); - indexSignature.returnType = returnType; - indexSignature.setResolved(); - indexParameterSymbol.setResolved(); - - containingSymbol.addIndexSignature(indexSignature); - - 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); - indexParameterSymbol.addDeclaration(indexParamDecl); - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast) { - var document = this.getDocument(ast.fileName()); - - if (document) { - return document._getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { - return this.getDocument(ast.fileName()).getEnclosingDecl(ast); - }; - - SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { - this.getDocument(decl.fileName())._setDeclForAST(ast, decl); - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var document = this.getDocument(decl.fileName()); - if (document) { - return document._getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { - this.getDocument(decl.fileName())._setASTForDecl(decl, ast); - }; - - SemanticInfoChain.prototype.topLevelDecl = function (fileName) { - var document = this.getDocument(fileName); - if (document) { - return document.topLevelDecl(); - } - - return null; - }; - - SemanticInfoChain.prototype.topLevelDecls = function () { - if (!this._topLevelDecls) { - this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { - return u.topLevelDecl(); - }); - } - - return this._topLevelDecls; - }; - - 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, 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; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { - this.document = document; - this.semanticInfoChain = semanticInfoChain; - this.propagateEnumConstants = propagateEnumConstants; - this.isDeclareFile = false; - this.parentChain = []; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - - function containingModuleHasExportAssignment(ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = ast; - return moduleDecl.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } else if (ast.kind() === 120 /* SourceUnit */) { - var sourceUnit = ast; - return sourceUnit.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } - - ast = ast.parent; - } - - return false; - } - - function isParsingAmbientModule(ast, context) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { - return true; - } - } - - ast = ast.parent; - } - - return false; - } - - function preCollectImportDecls(ast, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - - var parent = context.getParent(); - - if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { - declFlags |= 1 /* Exported */; - } - - 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 fileName = sourceUnit.fileName(); - - var isExternalModule = context.document.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); - - context.isDeclareFile = context.document.isDeclareFile(); - - context.pushParent(decl); - - if (isExternalModule) { - var declFlags = 1 /* Exported */; - if (TypeScript.isDTSFile(fileName)) { - declFlags |= 8 /* Ambient */; - } - - var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); - var kind = 32 /* DynamicModule */; - var valueText = TypeScript.quoteStr(fileName); - - var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); - - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, sourceUnit, context); - } - - context.pushParent(decl); - } - } - - function preCollectEnumDecls(enumDecl, context) { - var declFlags = 0 /* None */; - var enumName = enumDecl.identifier.valueText(); - - if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - declFlags |= 4096 /* Enum */; - var kind = 64 /* Enum */; - - var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); - context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); - context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); - - var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); - enumDeclaration.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); - - context.pushParent(enumDeclaration); - } - - function createEnumElementDecls(propertyDecl, context) { - var parent = context.getParent(); - - var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function preCollectModuleDecls(moduleDecl, context) { - var declFlags = 0 /* None */; - - var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); - - var isDynamic = moduleDecl.stringLiteral !== null; - - if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - - 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()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); - } - - context.pushParent(decl); - } else { - var moduleNames = getModuleNames(moduleDecl.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - var moduleName = moduleNames[i]; - - var specificFlags = declFlags; - if (i > 0) { - specificFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleName, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleName); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleName, context); - } - - context.pushParent(decl); - } - } - } - - function getModuleNames(name, result) { - result = result || []; - - if (name.kind() === 121 /* QualifiedName */) { - getModuleNames(name.left, result); - result.push(name.right); - } else { - result.push(name); - } - - return result; - } - TypeScript.getModuleNames = getModuleNames; - - 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.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); - } - - function containsExecutableCode(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); - - if (member.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = member; - - if (containsExecutableCode(moduleDecl.moduleElements)) { - return true; - } - } else if (member.kind() === 133 /* ImportDeclaration */) { - if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { - return true; - } - } else if (member.kind() !== 128 /* InterfaceDeclaration */) { - return true; - } - } - - return false; - } - - function preCollectClassDecls(classDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var parent = context.getParent(); - - 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); - - decl.setValueDecl(constructorDecl); - - context.semanticInfoChain.setDeclForAST(classDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, classDecl); - context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); - - context.pushParent(decl); - } - - function preCollectObjectTypeDecls(objectType, context) { - if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { - return; - } - - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setDeclForAST(objectType, decl); - context.semanticInfoChain.setASTForDecl(decl, objectType); - - context.pushParent(decl); - } - - function preCollectInterfaceDecls(interfaceDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { - declFlags |= 1 /* Exported */; - } - - var parent = context.getParent(); - - 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); - - context.pushParent(decl); - } - - function preCollectParameterDecl(argDecl, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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 */) { - decl.setFlag(67108864 /* ConstructorParameter */); - } - - var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); - var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; - if (isPublicOrPrivate && isInConstructor) { - var parentsParent = context.parentChain[context.parentChain.length - 2]; - - 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 */) { - propDecl.setFlag(67108864 /* ConstructorParameter */); - } - - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setASTForDecl(propDecl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, decl); - } - - parent.addVariableDeclToGroup(decl); - } - - function preCollectTypeParameterDecl(typeParameterDecl, context) { - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); - context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); - } - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = 4096 /* Property */; - - if (propertyDecl.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - var parent = context.getParent(); - - 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); - } - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 512 /* Variable */; - - var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); - if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - 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); - context.semanticInfoChain.setDeclForAST(varDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, varDecl); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectVarDecls(ast, context) { - if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { - return; - } - - var varDecl = ast; - createVariableDeclaration(varDecl, context); - } - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 16777216 /* FunctionType */; - - 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); - context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); - - context.pushParent(decl); - } - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 33554432 /* ConstructorType */; - - 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); - context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); - - context.pushParent(decl); - } - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - if (!funcDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - 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); - context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); - - context.pushParent(decl); - } - - function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { - if (typeof displayName === "undefined") { displayName = null; } - var declFlags = 0 /* None */; - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - declFlags |= 8192 /* ArrowFunction */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = id ? id.text() : ""; - var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); - context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); - - context.pushParent(decl); - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrow = functionExpressionDeclAST; - var declFlags = 4 /* Public */; - - var parent = context.getParent(); - - if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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); - - parent.addVariableDeclToGroup(decl); - } - } - - function createMemberFunctionDeclaration(funcDecl, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!funcDecl.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(funcDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDecl); - - context.pushParent(decl); - } - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 4194304 /* IndexSignature */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); - - context.pushParent(decl); - } - - function createCallSignatureDeclaration(callSignature, context) { - var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; - - if (!isChildOfObjectType) { - return; - } - - var declFlags = 2048 /* Signature */; - var declType = 1048576 /* CallSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(callSignature, decl); - context.semanticInfoChain.setASTForDecl(decl, callSignature); - - context.pushParent(decl); - } - - function createMethodSignatureDeclaration(method, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - declFlags |= 4 /* Public */; - declFlags |= 2048 /* Signature */; - - if (method.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(method, decl); - context.semanticInfoChain.setASTForDecl(decl, method); - - context.pushParent(decl); - } - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 2097152 /* ConstructSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); - - context.pushParent(decl); - } - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.flags; - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); - - context.pushParent(decl); - } - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); - - context.pushParent(decl); - } - - function createFunctionExpressionDeclaration(expression, context) { - createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); - } - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); - - context.pushParent(decl); - } - - function preCollectCatchDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 268435456 /* CatchBlock */; - - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - - var declFlags = 0 /* None */; - var declType = 1024 /* CatchVariable */; - - 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); - context.semanticInfoChain.setDeclForAST(ast.identifier, decl); - context.semanticInfoChain.setASTForDecl(decl, ast.identifier); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectWithDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 134217728 /* WithBlock */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectObjectLiteralDecls(ast, context) { - var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); - - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectSimplePropertyAssignmentDecls(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()); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - } - - function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { - var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); - - 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); - - createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); - } - - function preCollectDecls(ast, context) { - switch (ast.kind()) { - case 120 /* SourceUnit */: - preCollectScriptDecls(ast, context); - break; - case 132 /* EnumDeclaration */: - preCollectEnumDecls(ast, context); - break; - case 243 /* EnumElement */: - createEnumElementDecls(ast, context); - break; - case 130 /* ModuleDeclaration */: - preCollectModuleDecls(ast, context); - break; - case 131 /* ClassDeclaration */: - preCollectClassDecls(ast, context); - break; - case 128 /* InterfaceDeclaration */: - preCollectInterfaceDecls(ast, context); - break; - case 122 /* ObjectType */: - preCollectObjectTypeDecls(ast, context); - break; - case 242 /* Parameter */: - preCollectParameterDecl(ast, context); - break; - case 136 /* MemberVariableDeclaration */: - createMemberVariableDeclaration(ast, context); - break; - case 141 /* PropertySignature */: - createPropertySignature(ast, context); - break; - case 225 /* VariableDeclarator */: - preCollectVarDecls(ast, context); - break; - case 137 /* ConstructorDeclaration */: - createClassConstructorDeclaration(ast, context); - break; - case 139 /* GetAccessor */: - createGetAccessorDeclaration(ast, context); - break; - case 140 /* SetAccessor */: - createSetAccessorDeclaration(ast, context); - break; - case 222 /* FunctionExpression */: - createFunctionExpressionDeclaration(ast, context); - break; - case 135 /* MemberFunctionDeclaration */: - createMemberFunctionDeclaration(ast, context); - break; - case 144 /* IndexSignature */: - createIndexSignatureDeclaration(ast, context); - break; - case 123 /* FunctionType */: - createFunctionTypeDeclaration(ast, context); - break; - case 125 /* ConstructorType */: - createConstructorTypeDeclaration(ast, context); - break; - case 142 /* CallSignature */: - createCallSignatureDeclaration(ast, context); - break; - case 143 /* ConstructSignature */: - createConstructSignatureDeclaration(ast, context); - break; - case 145 /* MethodSignature */: - createMethodSignatureDeclaration(ast, context); - break; - case 129 /* FunctionDeclaration */: - createFunctionDeclaration(ast, context); - break; - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - createAnyFunctionExpressionDeclaration(ast, null, context); - break; - case 133 /* ImportDeclaration */: - preCollectImportDecls(ast, context); - break; - case 238 /* TypeParameter */: - preCollectTypeParameterDecl(ast, context); - break; - case 236 /* CatchClause */: - preCollectCatchDecls(ast, context); - break; - case 163 /* WithStatement */: - preCollectWithDecls(ast, context); - break; - case 215 /* ObjectLiteralExpression */: - preCollectObjectLiteralDecls(ast, context); - break; - case 240 /* SimplePropertyAssignment */: - preCollectSimplePropertyAssignmentDecls(ast, context); - break; - case 241 /* FunctionPropertyAssignment */: - preCollectFunctionPropertyAssignmentDecls(ast, context); - break; - } - } - - function isContainer(decl) { - return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.kind & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.kind & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.kind; - - if (kind & 4 /* Container */) { - return (decl.flags & 32768 /* InitializedModule */) !== 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, context) { - var currentDecl = context.getParent(); - - if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { - if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - return; - } - } - - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDeclaration = ast; - if (moduleDeclaration.stringLiteral) { - TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); - context.popParent(); - } else { - var moduleNames = getModuleNames(moduleDeclaration.name); - for (var i = moduleNames.length - 1; i >= 0; i--) { - var moduleName = moduleNames[i]; - TypeScript.Debug.assert(currentDecl.ast() === moduleName); - context.popParent(); - currentDecl = context.getParent(); - } - } - } - - if (ast.kind() === 132 /* EnumDeclaration */) { - computeEnumElementConstantValues(ast, currentDecl, context); - } - - while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { - context.popParent(); - currentDecl = context.getParent(); - } - } - - function computeEnumElementConstantValues(ast, enumDecl, context) { - TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); - - var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); - var inConstantSection = !isAmbientEnum; - var currentConstantValue = 0; - var enumMemberDecls = enumDecl.getChildDecls(); - - for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { - var enumElement = ast.enumElements.nonSeparatorAt(i); - var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { - return context.semanticInfoChain.getASTForDecl(d) === enumElement; - }); - - TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); - - if (enumElement.equalsValueClause === null) { - if (inConstantSection) { - enumElementDecl.constantValue = currentConstantValue; - currentConstantValue++; - } - } else { - enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); - if (enumElementDecl.constantValue !== null && !isAmbientEnum) { - inConstantSection = true; - currentConstantValue = enumElementDecl.constantValue + 1; - } else { - inConstantSection = false; - } - } - - TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); - } - } - - function computeEnumElementConstantValue(expression, enumMemberDecls, context) { - TypeScript.Debug.assert(expression); - - if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { - var token; - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - token = expression.operand; - break; - default: - token = expression; - } - - var value = token.value(); - return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; - } else if (context.propagateEnumConstants) { - switch (expression.kind()) { - case 11 /* IdentifierName */: - var name = expression; - var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { - return d.name === name.valueText(); - }); - - return matchingEnumElement ? matchingEnumElement.constantValue : null; - - case 202 /* LeftShiftExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left << right; - - case 189 /* BitwiseOrExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left | right; - } - - return null; - } else { - return null; - } - } - - (function (DeclarationCreator) { - function create(document, semanticInfoChain, compilationSettings) { - var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); - - TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); - - return declCollectionContext.getParent(); - } - DeclarationCreator.create = create; - })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); - var DeclarationCreator = TypeScript.DeclarationCreator; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBinder = (function () { - 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 */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.hasBeenBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - if (parent) { - var parentDeclKind = parentDecl.kind; - if (parentDeclKind === 262144 /* GetAccessor */) { - parent = parent.getGetter(); - } else if (parentDeclKind === 524288 /* SetAccessor */) { - parent = parent.getSetter(); - } - } - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = parent.getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.type; - } - } - - return parent.type; - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.name, declKind); - } - - var contextSymbolPath = startingDecl.getParentPath(); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].kind & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - }; - - PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { - var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; - var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; - var name = decl.name; - if (parent) { - var isExported = (decl.flags & 1 /* Exported */) !== 0; - - var prevSymbol = null; - if (lookingForValue) { - prevSymbol = parent.findContainedNonMember(name); - } else if (lookingForType) { - prevSymbol = parent.findContainedNonMemberType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); - } - var prevIsExported = !prevSymbol; - if (!prevSymbol) { - if (lookingForValue) { - prevSymbol = parent.findMember(name, false); - } else if (lookingForType) { - prevSymbol = parent.findNestedType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findNestedContainer(name, searchKind); - } - } - - if (isExported && prevIsExported) { - return prevSymbol; - } - if (prevSymbol) { - var prevDecls = prevSymbol.getDeclarations(); - var lastPrevDecl = prevDecls[prevDecls.length - 1]; - var parentDecl = decl.getParentDecl(); - var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); - if (parentDecl !== prevParentDecl) { - return null; - } - - return prevSymbol; - } - } else { - var parentDecl = decl.getParentDecl(); - if (parentDecl && parentDecl.kind === 1 /* Script */) { - return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); - } else { - var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); - return prevDecls[0] && prevDecls[0].getSymbol(); - } - } - - return null; - }; - - PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { - if (typeof reportError === "undefined") { reportError = true; } - 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 (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()]); - } - return false; - } - - 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; - - var enumContainerSymbol = null; - var enumInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var enumInstanceDecl = enumContainerDecl.getValueDecl(); - - var enumDeclKind = enumContainerDecl.kind; - - var parent = this.getParent(enumContainerDecl); - var parentInstanceSymbol = this.getParent(enumContainerDecl, true); - var parentDecl = enumContainerDecl.getParentDecl(); - var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); - - var isExported = enumContainerDecl.flags & 1 /* Exported */; - - var createdNewSymbol = false; - - enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); - - if (enumContainerSymbol) { - if (enumContainerSymbol.kind !== enumDeclKind) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); - enumContainerSymbol = null; - } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { - enumContainerSymbol = null; - } - } - - if (enumContainerSymbol) { - enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); - } else { - enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); - } - } - - enumContainerSymbol.addDeclaration(enumContainerDecl); - enumContainerDecl.setSymbol(enumContainerSymbol); - - this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); - this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - - if (!enumInstanceSymbol) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] === enumContainerDecl) { - break; - } - - if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol) { - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - enumInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); - } - - enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - enumInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); - } - } - - if (createdNewSymbol && parent) { - if (enumContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(enumContainerSymbol); - } else { - parent.addEnclosedNonMemberType(enumContainerSymbol); - } - } - - if (createdNewSymbol) { - this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); - } - var valueDecl = enumContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - }; - - 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(); - - enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); - }; - - 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(); - - 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); - if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); - TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); - - moduleDeclAST = moduleNameAST; - } - - var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); - var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; - - if (parent && moduleKind === 32 /* DynamicModule */) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); - } - - var createdNewSymbol = false; - - moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); - - if (moduleContainerTypeSymbol) { - if (moduleContainerTypeSymbol.kind !== moduleKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); - } - - moduleContainerTypeSymbol = null; - } 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) { - moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); - this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); - - var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); - - var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - - if (createdNewSymbol) { - if (parent) { - if (moduleContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); - } else { - parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); - } - } - } - - if (currentModuleValueDecl) { - currentModuleValueDecl.ensureSymbolIsBound(); - - 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); - } - } - - if (!instanceSymbol.type) { - instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - } - - moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); - - if (!instanceSymbol.type.getAssociatedContainerType()) { - instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.flags; - var declKind = importDeclaration.kind; - var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); - - var isExported = false; - var importSymbol = null; - var declName = importDeclaration.name; - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); - importSymbol = null; - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(importSymbol); - } else { - parent.addEnclosedNonMemberContainer(importSymbol); - } - } - }; - - 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; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - 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, 58728795 /* SomeType */, parent); - - if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); - classSymbol = null; - } - - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); - this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); - - if (parent) { - if (classDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(classSymbol); - } else { - parent.addEnclosedNonMemberType(classSymbol); - } - } - - 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; - - if (!constructorSymbol) { - var siblingValueDecls = null; - if (parentDecl) { - siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); - - if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { - constructorSymbol = siblingValueDecls[0].getSymbol(); - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - constructorSymbol.setIsSynthesized(); - constructorSymbol.type = constructorTypeSymbol; - } - - classSymbol.setConstructorMethod(constructorSymbol); - classSymbol.setHasDefaultConstructor(); - } - - if (constructorSymbol.getIsSynthesized()) { - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - constructorTypeSymbol.addDeclaration(classDecl); - } else { - classSymbol.setHasDefaultConstructor(false); - } - - constructorTypeSymbol.setAssociatedContainerType(classSymbol); - - var valueDecl = classDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.name; - var interfaceSymbol = null; - - var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); - - if (interfaceSymbol) { - if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); - interfaceSymbol = null; - } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { - interfaceSymbol = null; - } - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - if (interfaceDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(interfaceSymbol); - } else { - parent.addEnclosedNonMemberType(interfaceSymbol); - } - } - } - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - interfaceSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - - break; - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { - var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.kind; - var declFlags = constructorTypeDeclaration.flags; - var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); - - var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - signature.hasVarArgs = true; - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - 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; - - var variableSymbol = null; - - var declName = variableDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - 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; - variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); - - if (!variableSymbol && isModuleValue) { - variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); - } - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var decl; - var decls; - var ast; - var members; - - if (variableSymbol) { - var prevKind = variableSymbol.kind; - var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); - var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); - var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); - var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - 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 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 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.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 || 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); - variableSymbol = null; - parentHadSymbol = false; - } - } - - if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } - } - - if ((declFlags & 118784 /* ImplicitVariable */) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - if (!parent && parentDecl.kind === 1 /* Script */) { - this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); - } - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - if (!classTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - classTypeSymbol = containerDecl.getSymbol(); - if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfoChain.getASTForDecl(decl); - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else if (declFlags & 102400 /* SomeInitializedModule */) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - if (!moduleContainerTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - moduleContainerTypeSymbol = containerDecl.getSymbol(); - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - 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); - } - variableDeclaration.setSymbol(variableSymbol); - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - 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); - } else { - parent.addEnclosedNonMember(variableSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var declName = variableDeclaration.name; - - var variableSymbol = new TypeScript.PullSymbol(declName, declKind); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - - this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); - }; - - PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - var propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - - var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; - - var isStatic = false; - var isOptional = false; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); - - if (isOptional) { - propertySymbol.isOptional = true; - } - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { - var parameters = []; - var params = TypeScript.createIntrinsicsObject(); - var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); - - if (parameterList) { - for (var i = 0, n = parameterList.length; i < n; i++) { - var argDecl = parameterList.astAt(i); - var id = parameterList.identifierAt(i); - var decl = this.semanticInfoChain.getDeclForAST(argDecl); - var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); - var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); - - if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { - parameterSymbol.isVarArg = 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); - - if (signatureSymbol.isDefinition()) { - funcType.addEnclosedNonMember(parameterSymbol); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.kind; - var declFlags = functionDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); - - if (functionSymbol) { - 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); - functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); - } - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.type; - parentHadSymbol = true; - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionSymbol.type = functionTypeSymbol; - functionTypeSymbol.setFunctionSymbol(functionSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol); - } else { - parent.addEnclosedNonMember(functionSymbol); - } - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { - signature.hasVarArgs = true; - } - - var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.kind; - var declFlags = functionExpressionDeclaration.flags; - var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); - - 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionTypeSymbol.setFunctionSymbol(functionSymbol); - - functionSymbol.type = functionTypeSymbol; - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; - if (name) { - this.semanticInfoChain.setSymbolForAST(name, functionSymbol); - } - - this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); - - if (parameters.lastParameterIsRest()) { - signature.hasVarArgs = true; - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.kind; - var declFlags = functionTypeDeclaration.flags; - var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.kind; - var declFlags = methodDeclaration.flags; - var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - methodSymbol = parent.findMember(methodName, false); - - if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.type; - parentHadSymbol = true; - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - methodSymbol.type = methodTypeSymbol; - methodTypeSymbol.setFunctionSymbol(methodSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - - var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; - - TypeScript.Debug.assert(nameAST); - - this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); - this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); - - if (isOptional) { - methodSymbol.isOptional = true; - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol); - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); - - var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); - if (TypeScript.lastParameterIsRest(parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].name; - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); - signature.addTypeParameter(typeParameter); - } else { - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); - methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { - var prototypeStr = "prototype"; - - var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); - if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { - 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], this.semanticInfoChain); - - prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - prototypeSymbol.setIsSynthesized(); - prototypeSymbol.addDeclaration(prototypeDecl); - prototypeSymbol.type = classTypeSymbol; - constructorTypeSymbol.addMember(prototypeSymbol); - - if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { - var resolver = this.semanticInfoChain.getResolver(); - prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); - } - prototypeSymbol.setResolved(); - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.kind; - var declFlags = constructorDeclaration.flags; - var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { - var hasDefinitionSignature = false; - var constructorSigs = constructorSymbol.type.getConstructSignatures(); - - for (var i = 0; i < constructorSigs.length; i++) { - if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { - hasDefinitionSignature = true; - break; - } - } - - if (hasDefinitionSignature) { - this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); - - constructorSymbol = null; - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.type = constructorTypeSymbol; - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - constructorSymbol.setIsSynthesized(false); - this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); - constructSignature.returnType = parent; - constructSignature.addTypeParametersFromReturnType(); - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - constructorTypeSymbol.appendConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - constructSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); - parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { - callSignature.hasVarArgs = true; - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - callSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); - parent.insertCallSignatureAtIndex(callSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); - - var parent = this.getParent(indexSignatureDeclaration); - parent.addIndexSignature(indexSignature); - indexSignature.setContainer(parent); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.kind; - var declFlags = getAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.type; - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - getterTypeSymbol.setFunctionSymbol(getterSymbol); - - getterSymbol.type = getterTypeSymbol; - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - - getterTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.kind; - var declFlags = setAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - - if (setterSymbol) { - setterTypeSymbol = setterSymbol.type; - } - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - setterTypeSymbol.setFunctionSymbol(setterSymbol); - - setterSymbol.type = setterTypeSymbol; - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { - this.bindAllDeclsToPullSymbol(decl); - } - }; - - 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) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - this.bindEnumDeclarationToPullSymbol(decl); - break; - - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 512 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 1024 /* CatchVariable */: - this.bindCatchVariableToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - this.bindEnumMemberDeclarationToPullSymbol(decl); - break; - - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 128 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - decl.getParentDecl().getSymbol(); - break; - - case 268435456 /* CatchBlock */: - case 134217728 /* WithBlock */: - break; - - default: - TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); - } - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); - this.declsBeingBound.pop(); - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (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(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().type; - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.type; - } - var signatures; - - if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (functionDecl.kind === 4194304 /* IndexSignature */) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; - } - PullHelpers.symbolIsEnum = symbolIsEnum; - - function symbolIsModule(symbol) { - return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); - } - PullHelpers.symbolIsModule = symbolIsModule; - - function isOneDeclarationOfKind(symbol, kind) { - var decls = symbol.getDeclarations(); - for (var i = 0; i < decls.length; i++) { - if (decls[i].kind === kind) { - return true; - } - } - - return false; - } - - function isNameNumeric(name) { - return isFinite(+name); - } - PullHelpers.isNameNumeric = isNameNumeric; - - function typeSymbolsAreIdentical(a, b) { - if (a.isTypeReference() && !a.getIsSpecialized()) { - a = a.referencedTypeSymbol; - } - - if (b.isTypeReference() && !b.getIsSpecialized()) { - b = b.referencedTypeSymbol; - } - - return a === b; - } - PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; - - function getRootType(type) { - var rootType = type.getRootSymbol(); - - while (true) { - if (type === rootType) { - return type; - } - - type = rootType; - rootType = type.getRootSymbol(); - } - } - PullHelpers.getRootType = getRootType; - - function isSymbolLocal(symbol) { - var container = symbol.getContainer(); - if (container) { - var containerKind = container.kind; - if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { - return true; - } - - if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { - return true; - } - } - - 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; - -var TypeScript; -(function (TypeScript) { - TypeScript.fileResolutionTime = 0; - TypeScript.fileResolutionIOTime = 0; - TypeScript.fileResolutionScanImportsTime = 0; - TypeScript.fileResolutionImportFileSearchTime = 0; - TypeScript.fileResolutionGetDefaultLibraryTime = 0; - TypeScript.sourceCharactersCompiled = 0; - TypeScript.syntaxTreeParseTime = 0; - TypeScript.syntaxDiagnosticsTime = 0; - TypeScript.astTranslationTime = 0; - TypeScript.typeCheckTime = 0; - - TypeScript.compilerResolvePathTime = 0; - TypeScript.compilerDirectoryNameTime = 0; - TypeScript.compilerDirectoryExistsTime = 0; - TypeScript.compilerFileExistsTime = 0; - - TypeScript.emitTime = 0; - TypeScript.emitWriteFileTime = 0; - - TypeScript.declarationEmitTime = 0; - TypeScript.declarationEmitIsExternallyVisibleTime = 0; - TypeScript.declarationEmitTypeSignatureTime = 0; - TypeScript.declarationEmitGetBoundDeclTypeTime = 0; - TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; - TypeScript.declarationEmitGetBaseTypeTime = 0; - TypeScript.declarationEmitGetAccessorFunctionTime = 0; - TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; - TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; - - TypeScript.ioHostResolvePathTime = 0; - TypeScript.ioHostDirectoryNameTime = 0; - 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(emitOutputResult) { - if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } - this.outputFiles = []; - this.emitOutputResult = emitOutputResult; - } - return EmitOutput; - })(); - TypeScript.EmitOutput = EmitOutput; - - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); - var OutputFileType = TypeScript.OutputFileType; - - var OutputFile = (function () { - function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { - if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.text = text; - this.fileType = fileType; - this.sourceMapEntries = sourceMapEntries; - } - return OutputFile; - })(); - TypeScript.OutputFile = OutputFile; - - var CompileResult = (function () { - function CompileResult() { - this.diagnostics = []; - this.outputFiles = []; - } - CompileResult.fromDiagnostics = function (diagnostics) { - var result = new CompileResult(); - result.diagnostics = diagnostics; - return result; - }; - - CompileResult.fromOutputFiles = function (outputFiles) { - var result = new CompileResult(); - result.outputFiles = outputFiles; - return result; - }; - return CompileResult; - })(); - TypeScript.CompileResult = CompileResult; - - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, _settings) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } - this.logger = logger; - this._settings = _settings; - this.semanticInfoChain = null; - this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); - } - TypeScriptCompiler.prototype.compilationSettings = function () { - return this._settings; - }; - - TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { - var oldSettings = this._settings; - this._settings = newSettings; - - if (!compareDataObjects(oldSettings, newSettings)) { - this.semanticInfoChain.invalidate(oldSettings, newSettings); - } - }; - - TypeScriptCompiler.prototype.getDocument = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.semanticInfoChain.getDocument(fileName); - }; - - TypeScriptCompiler.prototype.cleanupSemanticCache = function () { - this.semanticInfoChain.invalidate(); - }; - - TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - fileName = TypeScript.switchToForwardSlashes(fileName); - - TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); - - var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); - - this.semanticInfoChain.addDocument(document); - }; - - TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); - - this.semanticInfoChain.addDocument(updatedDocument); - }; - - TypeScriptCompiler.prototype.removeFile = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - this.semanticInfoChain.removeDocument(fileName); - }; - - TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { - if (document.emitToOwnOutputFile()) { - var updatedFileName = document.fileName; - if (emitOptions.outputDirectory() !== "") { - updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); - updatedFileName = emitOptions.outputDirectory() + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(emitOptions.sharedOutputFile(), true); - } - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - var printReason = false; - - if (document.emitToOwnOutputFile()) { - var result = document.byteOrderMark !== 0 /* None */; - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - } - return result; - } else { - var fileNames = this.fileNames(); - - var result = false; - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - - if (document.isExternalModule()) { - continue; - } - - if (document.byteOrderMark !== 0 /* None */) { - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - result = true; - } else { - return true; - } - } - } - - return result; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype._shouldEmit = function (document) { - return !document.isDeclareFile(); - }; - - TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { - if (!this.compilationSettings().generateDeclarationFiles()) { - return false; - } - - return this._shouldEmit(document); - }; - - TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); - - if (declarationEmitter) { - declarationEmitter.document = document; - } else { - var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); - } - - declarationEmitter.emitDeclarations(sourceUnit); - return declarationEmitter; - }; - - TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmitDeclarations(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFile()); - } - } else { - sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var sharedEmitter = null; - var fileNames = this.fileNames(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileNames[i]); - - sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); - } - - TypeScript.declarationEmitTime += new Date().getTime() - start; - - return emitOutput; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, null); - return emitOutput; - } else { - return this.emitAllDeclarations(resolvePath); - } - }; - - 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; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmit(document)); - - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); - var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); - - if (this.compilationSettings().mapSourceFiles()) { - var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); - emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); - } - } else if (this.compilationSettings().mapSourceFiles()) { - emitter.setSourceMapperNewSourceFile(document); - } - - emitter.setDocument(document); - emitter.emitJavascript(sourceUnit, false); - - return emitter; - }; - - TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmit(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFiles()); - } - } else { - sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var fileNames = this.fileNames(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - sharedEmitter = this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); - } - - TypeScript.emitTime += new Date().getTime() - start; - return emitOutput; - }; - - TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, null); - return emitOutput; - } else { - return this.emitAll(resolvePath); - } - }; - - TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { - if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } - return new CompilerIterator(this, resolvePath, continueOnDiagnostics); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - - TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { - return this.getDocument(fileName).sourceUnit(); - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - - var startTime = (new Date()).getTime(); - TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); - var endTime = (new Date()).getTime(); - - TypeScript.typeCheckTime += endTime - startTime; - - var errors = this.semanticInfoChain.getDiagnostics(fileName); - - errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); - errors.sort(function (d1, d2) { - if (d1.fileName() < d2.fileName()) { - return -1; - } else if (d1.fileName() > d2.fileName()) { - return 1; - } - - if (d1.start() < d2.start()) { - return -1; - } else if (d1.start() > d2.start()) { - return 1; - } - - var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; - var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; - if (code1 < code2) { - return -1; - } else if (code1 > code2) { - return 1; - } - - return 0; - }); - - 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++) { - this.getSemanticDiagnostics(fileNames[i]); - } - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var ast = this.semanticInfoChain.getASTForDecl(decl); - if (!ast) { - return null; - } - - var enclosingDecl = resolver.getEnclosingDecl(decl); - if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { - return this.getSymbolOfDeclaration(enclosingDecl); - } - - return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { - var scriptName = document.fileName; - - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - var inWithBlock = false; - - var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); - - if (!ast) { - return null; - } - - var path = this.getASTPath(ast); - - for (var i = 0, n = path.length; i < n; i++) { - var current = path[i]; - - switch (current.kind()) { - case 222 /* FunctionExpression */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - if (propagateContextualTypes) { - resolver.resolveAST(current, true, resolutionContext); - } - break; - - case 136 /* MemberVariableDeclaration */: - var memberVariable = current; - inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); - break; - - case 225 /* VariableDeclarator */: - var variableDeclarator = current; - inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); - break; - - case 213 /* InvocationExpression */: - case 216 /* ObjectCreationExpression */: - if (propagateContextualTypes) { - var isNew = current.kind() === 216 /* ObjectCreationExpression */; - var callExpression = current; - var contextualType = null; - - if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = path[i + 3]; - if (argExpression) { - for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { - if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext); - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 214 /* ArrayLiteralExpression */: - if (propagateContextualTypes) { - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 215 /* ObjectLiteralExpression */: - if (propagateContextualTypes) { - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.propertyAssignments; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { - if (memberDecls.nonSeparatorAt(j) === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - } - - break; - - case 174 /* AssignmentExpression */: - if (propagateContextualTypes) { - var assignmentExpression = current; - var contextualType = null; - - if (path[i + 1] && path[i + 1] === assignmentExpression.right) { - var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - 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; - - case 150 /* ReturnStatement */: - if (propagateContextualTypes) { - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 122 /* ObjectType */: - if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { - resolver.resolveAST(current, false, resolutionContext); - } - - break; - - case 163 /* WithStatement */: - inWithBlock = true; - break; - - case 146 /* Block */: - inContextuallyTypedAssignment = false; - break; - } - - var decl = this.semanticInfoChain.getDeclForAST(current); - if (decl) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { - if (ast.parent.kind() === 212 /* MemberAccessExpression */) { - if (ast.parent.name === ast) { - ast = ast.parent; - } - } else if (ast.parent.kind() === 121 /* QualifiedName */) { - if (ast.parent.right === ast) { - ast = ast.parent; - } - } - } - - return { - ast: ast, - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment, - inWithBlock: inWithBlock - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { - if (inContextuallyTypedAssignment) { - if (propagateContextualTypes) { - resolver.resolveAST(assigningAST, false, resolutionContext); - var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.type; - } - - resolutionContext.pushNewContextualType(contextualType); - - if (init) { - resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); - } - } - } - }; - - TypeScriptCompiler.prototype.getASTPath = function (ast) { - var result = []; - - while (ast) { - result.unshift(ast); - ast = ast.parent; - } - - return result; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - ast = context.ast; - 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()]); - return null; - } - - if (symbol.isTypeReference()) { - symbol = symbol.getReferencedTypeSymbol(); - } - - var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); - - return { - symbol: symbol, - aliasSymbol: aliasSymbol, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { - if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { - return null; - } - - var isNew = ast.kind() === 216 /* ObjectCreationExpression */; - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, false); - if (!context || context.inWithBlock) { - return null; - } - - return resolver.getVisibleDecls(context.enclosingDecl); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { - if (ast.kind() !== 215 /* ObjectLiteralExpression */) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var astForDecl = decl.ast(); - if (!astForDecl) { - return null; - } - - var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); - if (!astForDeclContext) { - return null; - } - - var symbol = decl.getSymbol(); - resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - aliasSymbol: null, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - - TypeScriptCompiler.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast); - }; - - TypeScriptCompiler.prototype.fileNames = function () { - return this.semanticInfoChain.fileNames(); - }; - - 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; - - var CompilerPhase; - (function (CompilerPhase) { - CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; - CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; - CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; - CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; - CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; - })(CompilerPhase || (CompilerPhase = {})); - - var CompilerIterator = (function () { - function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { - if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } - this.compiler = compiler; - this.resolvePath = resolvePath; - this.continueOnDiagnostics = continueOnDiagnostics; - this.index = -1; - this.fileNames = null; - this._current = null; - this._emitOptions = null; - this._sharedEmitter = null; - this._sharedDeclarationEmitter = null; - this.hadSyntacticDiagnostics = false; - this.hadSemanticDiagnostics = false; - this.hadEmitDiagnostics = false; - this.fileNames = compiler.fileNames(); - this.compilerPhase = startingPhase; - } - CompilerIterator.prototype.current = function () { - return this._current; - }; - - CompilerIterator.prototype.moveNext = function () { - this._current = null; - - while (this.moveNextInternal()) { - if (this._current) { - return true; - } - } - - return false; - }; - - CompilerIterator.prototype.moveNextInternal = function () { - this.index++; - - while (this.shouldMoveToNextPhase()) { - this.index = 0; - this.compilerPhase++; - } - - if (this.compilerPhase > 4 /* DeclarationEmit */) { - return false; - } - - switch (this.compilerPhase) { - case 0 /* Syntax */: - return this.moveNextSyntaxPhase(); - case 1 /* Semantics */: - return this.moveNextSemanticsPhase(); - case 2 /* EmitOptionsValidation */: - return this.moveNextEmitOptionsValidationPhase(); - case 3 /* Emit */: - return this.moveNextEmitPhase(); - case 4 /* DeclarationEmit */: - return this.moveNextDeclarationEmitPhase(); - } - }; - - CompilerIterator.prototype.shouldMoveToNextPhase = function () { - switch (this.compilerPhase) { - case 2 /* EmitOptionsValidation */: - return this.index === 1; - - case 0 /* Syntax */: - case 1 /* Semantics */: - return this.index === this.fileNames.length; - - case 3 /* Emit */: - case 4 /* DeclarationEmit */: - return this.index === (this.fileNames.length + 1); - } - - return false; - }; - - CompilerIterator.prototype.moveNextSyntaxPhase = function () { - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - - var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSyntacticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextSemanticsPhase = function () { - if (this.hadSyntacticDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - var diagnostics = this.compiler.getSemanticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSemanticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - - if (!this._emitOptions) { - this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); - } - - if (this._emitOptions.diagnostic()) { - if (!this.continueOnDiagnostics) { - this.hadEmitDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(this._emitOptions); - - if (this.hadEmitDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { - _this._current = CompileResult.fromOutputFiles(outputFiles); - }, this._sharedEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedEmitter) { - this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); - } - - return true; - }; - - CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(!this.hadEmitDiagnostics); - if (this.hadSemanticDiagnostics) { - return false; - } - - if (!this.compiler.compilationSettings().generateDeclarationFiles()) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { - _this._current = CompileResult.fromOutputFiles([file]); - }, this._sharedDeclarationEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { - this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); - } - - return true; - }; - return CompilerIterator; - })(); - - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - TypeScript.compareDataObjects = compareDataObjects; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (GenerativeTypeClassification) { - GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; - GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; - GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; - GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; - })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); - var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; - - var PullTypeReferenceSymbol = (function (_super) { - __extends(PullTypeReferenceSymbol, _super); - function PullTypeReferenceSymbol(referencedTypeSymbol) { - _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); - this.referencedTypeSymbol = referencedTypeSymbol; - this.isResolved = true; - - TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); - - this.setRootSymbol(referencedTypeSymbol); - - this.typeReference = this; - } - PullTypeReferenceSymbol.createTypeReference = function (type) { - if (type.isTypeReference()) { - return type; - } - - var typeReference = type.typeReference; - - if (!typeReference) { - typeReference = new PullTypeReferenceSymbol(type); - type.typeReference = typeReference; - } - - return typeReference; - }; - - PullTypeReferenceSymbol.prototype.isTypeReference = function () { - return true; - }; - - PullTypeReferenceSymbol.prototype.setResolved = function () { - }; - - PullTypeReferenceSymbol.prototype.setUnresolved = function () { - }; - PullTypeReferenceSymbol.prototype.invalidate = function () { - }; - - PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { - this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); - }; - - PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol; - }; - - PullTypeReferenceSymbol.prototype._getResolver = function () { - return this.referencedTypeSymbol._getResolver(); - }; - - PullTypeReferenceSymbol.prototype.hasMembers = function () { - return this.referencedTypeSymbol.hasMembers(); - }; - - PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); - }; - - PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - return this.referencedTypeSymbol.getAssociatedContainerType(); - }; - - PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getFunctionSymbol(); - }; - PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); - }; - - PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); - }; - PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); - }; - - PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); - }; - PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMember(name); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); - }; - - PullTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getMembers(); - }; - - PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); - }; - PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getHasDefaultConstructor(); - }; - PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructorMethod(); - }; - PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); - }; - PullTypeReferenceSymbol.prototype.getTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.isGeneric = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isGeneric(); - }; - - PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getSpecialization(substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getKnownSpecializations(); - }; - PullTypeReferenceSymbol.prototype.getTypeArguments = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArguments(); - }; - PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); - }; - 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"); - }; - - PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnIndexSignatures(); - }; - PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getIndexSignatures(); - }; - - PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { - this.referencedTypeSymbol.addImplementedType(implementedType); - }; - PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getImplementedTypes(); - }; - PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { - this.referencedTypeSymbol.addExtendedType(extendedType); - }; - PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getExtendedTypes(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExtendsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExtendThisType(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); - }; - - PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); - }; - - PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findMember(name, lookInParent); - }; - PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedType(name, kind); - }; - PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedContainer(name, kind); - }; - PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - }; - - PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findTypeParameter(name); - }; - - PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); - }; - return PullTypeReferenceSymbol; - })(TypeScript.PullTypeSymbol); - TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - TypeScript.nSpecializedTypeParameterCreated = 0; - - var PullInstantiatedTypeReferenceSymbol = (function (_super) { - __extends(PullInstantiatedTypeReferenceSymbol, _super); - 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 = undefined; - this._instantiatedConstructorMethod = null; - this._instantiatedAssociatedContainerType = null; - this._isArray = undefined; - this._generativeTypeClassification = []; - - TypeScript.nSpecializationsCreated++; - } - PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { - return !this.isInstanceReferenceType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - if (!this.isNamedTypeSymbol()) { - return 0 /* Unknown */; - } - - 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()); - } - return this._isArray; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { - if (!this.isArrayNamedTypeReference()) { - return null; - } - - var typeArguments = this.getTypeArguments(); - return typeArguments ? typeArguments[0] : null; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.getIsSpecialized()) { - return this; - } - - return this.referencedTypeSymbol; - }; - - 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiation) { - return instantiation; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - 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; - } - } - - if (isInstanceReferenceType) { - typeParameterArgumentMap = []; - } - } - - instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); - - rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); - - return instantiation; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return this.getRootSymbol().isGeneric(); - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { - return this._typeParameterArgumentMap; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { - if (this.isInstanceReferenceType) { - return this.getTypeParameters(); - } - - if (this._typeArgumentReferences === undefined) { - var typeParameters = this.referencedTypeSymbol.getTypeParameters(); - - if (typeParameters.length) { - var typeArgument = null; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; - - if (!typeArgument) { - TypeScript.Debug.fail("type argument count mismatch"); - } - - if (typeArgument) { - typeArguments[typeArguments.length] = typeArgument; - } - } - - this._typeArgumentReferences = typeArguments; - } else { - this._typeArgumentReferences = null; - } - } - - return this._typeArgumentReferences; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - 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(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getMembers(); - } - - if (!this._instantiatedMembers) { - var referencedMembers = this.referencedTypeSymbol.getMembers(); - var referencedMember = null; - var instantiatedMember = null; - - this._instantiatedMembers = []; - - for (var i = 0; i < referencedMembers.length; i++) { - referencedMember = referencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (!this._instantiatedMemberNameCache[referencedMember.name]) { - this.populateInstantiatedMemberFromReferencedMember(referencedMember); - } - - this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; - } - } - - return this._instantiatedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.findMember(name, lookInParent); - } - - var memberSymbol = this._instantiatedMemberNameCache[name]; - - if (!memberSymbol) { - var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); - - if (referencedMemberSymbol) { - this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); - memberSymbol = this._instantiatedMemberNameCache[name]; - } else { - memberSymbol = null; - } - } - - return memberSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - } - - var requestedMembers = []; - var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - - if (!this._allInstantiatedMemberNameCache) { - this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - - var members = this.getMembers(); - - for (var i = 0; i < members.length; i++) { - this._allInstantiatedMemberNameCache[members[i].name] = members[i]; - } - } - - var referencedMember = null; - var requestedMember = null; - - for (var i = 0; i < allReferencedMembers.length; i++) { - referencedMember = allReferencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (this._allInstantiatedMemberNameCache[referencedMember.name]) { - requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; - } else { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; - requestedMembers[requestedMembers.length] = referencedMember; - } else { - requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - requestedMember.setRootSymbol(referencedMember); - - requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - requestedMember.isOptional = referencedMember.isOptional; - - this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; - requestedMembers[requestedMembers.length] = requestedMember; - } - } - } - - return requestedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructorMethod(); - } - - 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); - } - - return this._instantiatedConstructorMethod; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - if (!this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAssociatedContainerType(); - } - - if (!this._instantiatedAssociatedContainerType) { - var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); - - if (referencedAssociatedContainerType) { - this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); - } - } - - return this._instantiatedAssociatedContainerType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getCallSignatures(); - } - - if (this._instantiatedCallSignatures) { - return this._instantiatedCallSignatures; - } - - var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); - this._instantiatedCallSignatures = []; - - for (var i = 0; i < referencedCallSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); - - if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; - } else { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedCallSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructSignatures(); - } - - if (this._instantiatedConstructSignatures) { - return this._instantiatedConstructSignatures; - } - - var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); - this._instantiatedConstructSignatures = []; - - for (var i = 0; i < referencedConstructSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); - - if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; - } else { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedConstructSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getIndexSignatures(); - } - - if (this._instantiatedIndexSignatures) { - return this._instantiatedIndexSignatures; - } - - var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); - this._instantiatedIndexSignatures = []; - - for (var i = 0; i < referencedIndexSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); - - if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; - } else { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedIndexSignatures; - }; - 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) { - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.previousTokenTrailingComments = null; - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { - var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { - var firstToken = node.firstToken(); - var lastToken = node.lastToken(); - - this.setSpan(ast, fullStart, node, firstToken, lastToken); - ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); - ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); - }; - - SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { - if (element === null) { - return null; - } - - if (element.fullWidth() === 0) { - return new TypeScript.ASTSpan(-1, -1); - } - - var leadingTriviaWidth = element.leadingTriviaWidth(); - var trailingTriviaWidth = element.trailingTriviaWidth(); - - var start = fullStart + leadingTriviaWidth; - var end = fullStart + element.fullWidth() - trailingTriviaWidth; - - return new TypeScript.ASTSpan(start, end); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { - if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } - if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } - var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; - var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; - - var desiredMinChar = fullStart + leadingTriviaWidth; - var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span._trailingTriviaWidth = trailingTriviaWidth; - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - span._start = start; - span._end = end; - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { - var start = this.position; - var array = new Array(node.childCount()); - - for (var i = 0, n = node.childCount(); i < n; i++) { - array[i] = node.childAt(i).accept(this); - } - - var result = new TypeScript.ISyntaxList2(this.fileName, array); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var array = new Array(list.nonSeparatorCount()); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - array[i / 2] = list.childAt(i).accept(this); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); - this.setSpan(result, start, list); - - result.setPostComments(this.previousTokenTrailingComments); - this.previousTokenTrailingComments = null; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { - if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); - }; - - SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { - return this.visitToken(token); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - var fullStart = this.position; - - var result = this.visitTokenWorker(token); - - this.movePast(token); - - var start = fullStart + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { - switch (token.tokenKind) { - case 60 /* AnyKeyword */: - return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); - case 61 /* BooleanKeyword */: - return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); - case 67 /* NumberKeyword */: - return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); - case 69 /* StringKeyword */: - return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); - case 41 /* VoidKeyword */: - return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); - case 35 /* ThisKeyword */: - return new TypeScript.ThisExpression(token.text(), token.valueText()); - case 50 /* SuperKeyword */: - return new TypeScript.SuperExpression(token.text(), token.valueText()); - case 37 /* TrueKeyword */: - return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); - case 24 /* FalseKeyword */: - return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); - case 32 /* NullKeyword */: - return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); - case 14 /* StringLiteral */: - return new TypeScript.StringLiteral(token.text(), token.valueText()); - case 12 /* RegularExpressionLiteral */: - return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); - case 13 /* NumericLiteral */: - var fullStart = this.position; - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); - - result.setPreComments(preComments); - return result; - case 11 /* IdentifierName */: - return new TypeScript.Identifier(token.text()); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { - var start = this.position; - TypeScript.Debug.assert(start === 0); - - var bod = this.visitSyntaxList(node.moduleElements); - 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; - }; - - SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { - var start = this.position; - - this.moveTo(node, node.stringLiteral); - var stringLiteral = node.stringLiteral.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ExternalModuleReference(stringLiteral); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { - var start = this.position; - var moduleName = node.moduleName.accept(this); - - var result = new TypeScript.ModuleNameModuleReference(moduleName); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - this.movePast(node.openBraceToken); - var members = this.visitSyntaxList(node.classElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { - var result = null; - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { - result = result || []; - result.push(1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - result = result || []; - result.push(8 /* Ambient */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { - result = result || []; - result.push(16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { - result = result || []; - result.push(4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { - result = result || []; - result.push(2 /* Private */); - } - - return result || TypeScript.sentinelEmptyArray; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - var body = this.visitObjectType(node.body); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - var start = this.position; - - this.movePast(node.extendsOrImplementsKeyword); - var typeNames = this.visitSeparatedSyntaxList(node.typeNames); - - var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - var start = this.position; - - var modifiers = this.visitModifiers(node.modifiers); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - - var moduleName = node.name ? node.name.accept(this) : null; - var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; - - this.movePast(node.openBraceToken); - - var moduleElements = this.visitSyntaxList(node.moduleElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - this.movePast(node.openBraceToken); - - var enumElements = this.visitSeparatedSyntaxList(node.enumElements); - - this.movePast(node.closeBraceToken); - - var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - var start = this.position; - - var memberName = this.visitToken(node.propertyName); - - var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.EnumElement(memberName, value); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ImportDeclaration(modifiers, name, alias); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExportAssignment(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.VariableStatement(modifiers, declaration); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - var start = this.position; - var propertyName = this.visitToken(node.propertyName); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - var start = this.position; - var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var value = node.value.accept(this); - value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); - - var result = new TypeScript.EqualsValueClause(value); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var start = this.position; - - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var start = this.position; - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayLiteralExpression(expressions); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - var start = this.position; - - var result = new TypeScript.OmittedExpression(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var start = this.position; - - var openParenToken = node.openParenToken; - var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(openParenToken); - - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var start = this.position; - - var identifier = node.identifier.accept(this); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var start = this.position; - - var callSignature = this.visitCallSignature(node.callSignature); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - return type ? type.accept(this) : null; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { - var start = this.position; - this.movePast(node.typeOfKeyword); - var name = node.name.accept(this); - - var result = new TypeScript.TypeQuery(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - var start = this.position; - var left = this.visitType(node.left); - this.movePast(node.dotToken); - var right = this.visitIdentifier(node.right); - - var result = new TypeScript.QualifiedName(left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeArgumentList(typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - var start = this.position; - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - var start = this.position; - - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectType(typeMembers); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayType(underlying); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.name); - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - var result = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.colonToken); - var type = this.visitType(node.type); - - var result = new TypeScript.TypeAnnotation(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - - var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - var start = this.position; - - var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.visitIdentifier(node.name); - - var result = new TypeScript.MemberAccessExpression(expression, name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var start = this.position; - - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.InvocationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - this.movePast(node.openParenToken); - - 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()); - } - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - var start = this.position; - - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - var result = new TypeScript.BinaryExpression(node.kind(), left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - var start = this.position; - - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.ConstructSignature(callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.MethodSignature(name, questionToken, callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - var start = this.position; - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.IndexSignature(parameter, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - var openParenToken = node.openParenToken; - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - var openParenTrailingComments = null; - if (node.parameters.childCount() === 0) { - openParenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - } - - this.movePast(node.openParenToken); - var parameters = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - var start = this.position; - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeParameterList(typeParameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - var result = new TypeScript.TypeParameter(identifier, constraint); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - var start = this.position; - this.movePast(node.extendsKeyword); - var type = this.visitType(node.type); - - var result = new TypeScript.Constraint(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - var result = new TypeScript.IfStatement(condition, thenBod, elseBod); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - var start = this.position; - - this.movePast(node.elseKeyword); - var statement = node.statement.accept(this); - - var result = new TypeScript.ElseClause(statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var expression = node.expression.accept(this); - - var semicolonPosition = this.position; - - var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExpressionStatement(expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var start = this.position; - - 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(callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.indexSignature); - var indexSignature = node.indexSignature.accept(this); - - this.movePast(node.semicolonToken); - - var result = new TypeScript.IndexMemberDeclaration(indexSignature); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarator); - var variableDeclarator = node.variableDeclarator.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - var start = this.position; - - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ThrowStatement(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - var start = this.position; - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ReturnStatement(expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.ObjectCreationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - var start = this.position; - - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - this.movePast(node.openBraceToken); - var switchClauses = this.visitSyntaxList(node.switchClauses); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.CaseSwitchClause(expression, statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.DefaultSwitchClause(statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - var start = this.position; - - this.movePast(node.breakKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.BreakStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - var start = this.position; - - this.movePast(node.continueKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ContinueStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var initializer = node.initializer ? node.initializer.accept(this) : null; - - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var left = node.left ? node.left.accept(this) : null; - - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WhileStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WithStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - var start = this.position; - - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - var result = new TypeScript.CastExpression(castTerm, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var start = this.position; - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); - - var propertyName = node.propertyName.accept(this); - - var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var expression = node.expression.accept(this); - expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); - - var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var start = this.position; - - var propertyName = node.propertyName.accept(this); - var callSignature = this.visitCallSignature(node.callSignature); - var block = this.visitBlock(node.block); - - var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - var start = this.position; - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? node.block.accept(this) : null; - - var result = new TypeScript.FunctionExpression(name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - var start = this.position; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.EmptyStatement(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - var start = this.position; - - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - var start = this.position; - - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.visitIdentifier(node.identifier); - var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - var start = this.position; - this.movePast(node.finallyKeyword); - var block = node.block.accept(this); - - var result = new TypeScript.FinallyClause(block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.LabeledStatement(identifier, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - var start = this.position; - - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DoStatement(statement, whileKeyword, condition); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - var start = this.position; - - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.TypeOfExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - var start = this.position; - - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.DeleteExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - var start = this.position; - - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.VoidExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - var start = this.position; - - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DebuggerStatement(); - this.setSpan(result, start, node); - - return result; - }; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; - - function applyDelta(ast, delta) { - if (ast) { - if (ast._start !== -1) { - ast._start += delta; - } - - if (ast._end !== -1) { - ast._end += delta; - } - } - } - - function applyDeltaToComments(comments, delta) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment, delta); - } - } - } - - var SyntaxTreeToIncrementalAstVisitor = (function (_super) { - __extends(SyntaxTreeToIncrementalAstVisitor, _super); - function SyntaxTreeToIncrementalAstVisitor() { - _super.apply(this, arguments); - } - SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { - if (delta === 0) { - return; - } - - var pre = function (cur) { - applyDelta(cur, delta); - applyDeltaToComments(cur.preComments(), delta); - applyDeltaToComments(cur.postComments(), delta); - - switch (cur.kind()) { - case 146 /* Block */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 226 /* ArgumentList */: - applyDelta(cur.closeParenToken, delta); - break; - - case 130 /* ModuleDeclaration */: - applyDelta(cur.endingToken, delta); - break; - - case 131 /* ClassDeclaration */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 161 /* DoStatement */: - applyDelta(cur.whileKeyword, delta); - break; - - case 151 /* SwitchStatement */: - applyDelta(cur.closeParenToken, delta); - break; - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span._start !== -1) { - var delta = start - span._start; - this.applyDelta(span, delta); - - span._end = end; - } else { - _super.prototype.setSpanExplicit.call(this, span, start, end); - } - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - var result = element._ast; - if (!result) { - return null; - } - - var start = this.position; - this.movePast(element); - this.setSpan(result, start, element); - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { - element._ast = ast; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSeparatedSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { - var result = this.getAndMovePastAST(token); - - if (!result) { - result = _super.prototype.visitToken.call(this, token); - this.setAST(token, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitClassDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInterfaceDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitHeritageClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitModuleDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitImportDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExportAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPrefixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitOmittedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - var result = _super.prototype.visitQualifiedName.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGenericType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBlock.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPostfixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitElementAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInvocationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBinaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConditionalExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMethodSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIndexSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPropertySignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCallSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIfStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExpressionStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberVariableDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitThrowStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitReturnStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectCreationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSwitchStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCaseSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDefaultSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBreakStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitContinueStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForInStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWhileStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWithStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCastExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimplePropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitEmptyStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTryStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCatchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitLabeledStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDoStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeOfExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDeleteExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitVoidExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDebuggerStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - return SyntaxTreeToIncrementalAstVisitor; - })(SyntaxTreeToAstVisitor); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan(_start, _end) { - this._start = _start; - this._end = _end; - } - ASTSpan.prototype.start = function () { - return this._start; - }; - - ASTSpan.prototype.end = function () { - return this._end; - }; - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - var astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, false); - } - - function commentStructuralEqualsIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, true); - } - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); - } - - function commentStructuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - function commentArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST() { - this.parent = null; - this._start = -1; - this._end = -1; - this._trailingTriviaWidth = 0; - this._astID = astID++; - this._preComments = null; - this._postComments = null; - } - AST.prototype.syntaxID = function () { - return this._astID; - }; - - AST.prototype.start = function () { - return this._start; - }; - - AST.prototype.end = function () { - return this._end; - }; - - AST.prototype.trailingTriviaWidth = function () { - return this._trailingTriviaWidth; - }; - - AST.prototype.fileName = function () { - return this.parent.fileName(); - }; - - AST.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - AST.prototype.preComments = function () { - return this._preComments; - }; - - AST.prototype.postComments = function () { - return this._postComments; - }; - - AST.prototype.setPreComments = function (comments) { - if (comments && comments.length) { - this._preComments = comments; - } else if (this._preComments) { - this._preComments = null; - } - }; - - AST.prototype.setPostComments = function (comments) { - if (comments && comments.length) { - this._postComments = comments; - } else if (this._postComments) { - this._postComments = null; - } - }; - - AST.prototype.width = function () { - return this.end() - this.start(); - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); - }; - - AST.prototype.isExpression = function () { - return false; - }; - return AST; - })(); - TypeScript.AST = AST; - - var ISyntaxList2 = (function (_super) { - __extends(ISyntaxList2, _super); - function ISyntaxList2(_fileName, members) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISyntaxList2.prototype.childCount = function () { - return this.members.length; - }; - - ISyntaxList2.prototype.childAt = function (index) { - return this.members[index]; - }; - - ISyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISyntaxList2.prototype.kind = function () { - return 1 /* List */; - }; - - ISyntaxList2.prototype.firstOrDefault = function (func) { - return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.lastOrDefault = function (func) { - return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.any = function (func) { - return TypeScript.ArrayUtilities.any(this.members, func); - }; - - ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISyntaxList2; - })(AST); - TypeScript.ISyntaxList2 = ISyntaxList2; - - var ISeparatedSyntaxList2 = (function (_super) { - __extends(ISeparatedSyntaxList2, _super); - function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - this._separatorCount = _separatorCount; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { - return this.members.length; - }; - - ISeparatedSyntaxList2.prototype.separatorCount = function () { - return this._separatorCount; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { - return this.members[index]; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i) === ast) { - return i; - } - } - - return -1; - }; - - ISeparatedSyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISeparatedSyntaxList2.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISeparatedSyntaxList2; - })(AST); - TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; - - var SourceUnit = (function (_super) { - __extends(SourceUnit, _super); - function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { - _super.call(this); - this.moduleElements = moduleElements; - this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; - this._fileName = _fileName; - moduleElements && (moduleElements.parent = this); - } - SourceUnit.prototype.fileName = function () { - return this._fileName; - }; - - SourceUnit.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return SourceUnit; - })(AST); - TypeScript.SourceUnit = SourceUnit; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(_text) { - _super.call(this); - this._text = _text; - this._valueText = null; - } - Identifier.prototype.text = function () { - return this._text; - }; - Identifier.prototype.valueText = function () { - if (!this._valueText) { - var text = this._text; - if (text === "__proto__") { - this._valueText = "#__proto__"; - } else { - this._valueText = TypeScript.Syntax.massageEscapes(text); - } - } - - return this._valueText; - }; - - Identifier.prototype.kind = function () { - return 11 /* IdentifierName */; - }; - - 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; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - LiteralExpression.prototype.text = function () { - return this._text; - }; - - LiteralExpression.prototype.valueText = function () { - return this._valueText; - }; - - LiteralExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - ThisExpression.prototype.text = function () { - return this._text; - }; - - ThisExpression.prototype.valueText = function () { - return this._valueText; - }; - - ThisExpression.prototype.kind = function () { - return 35 /* ThisKeyword */; - }; - - 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; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - SuperExpression.prototype.text = function () { - return this._text; - }; - - SuperExpression.prototype.valueText = function () { - return this._valueText; - }; - - SuperExpression.prototype.kind = function () { - return 50 /* SuperKeyword */; - }; - - 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; - - var NumericLiteral = (function (_super) { - __extends(NumericLiteral, _super); - function NumericLiteral(_value, _text, _valueText) { - _super.call(this); - this._value = _value; - this._text = _text; - this._valueText = _valueText; - } - NumericLiteral.prototype.text = function () { - return this._text; - }; - NumericLiteral.prototype.valueText = function () { - return this._valueText; - }; - NumericLiteral.prototype.value = function () { - return this._value; - }; - - NumericLiteral.prototype.kind = function () { - return 13 /* NumericLiteral */; - }; - - 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; - - var RegularExpressionLiteral = (function (_super) { - __extends(RegularExpressionLiteral, _super); - function RegularExpressionLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - RegularExpressionLiteral.prototype.text = function () { - return this._text; - }; - - RegularExpressionLiteral.prototype.valueText = function () { - return this._valueText; - }; - - RegularExpressionLiteral.prototype.kind = function () { - return 12 /* RegularExpressionLiteral */; - }; - - RegularExpressionLiteral.prototype.isExpression = function () { - return true; - }; - return RegularExpressionLiteral; - })(AST); - TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; - } - StringLiteral.prototype.text = function () { - return this._text; - }; - StringLiteral.prototype.valueText = function () { - return this._valueText; - }; - - StringLiteral.prototype.kind = function () { - return 14 /* StringLiteral */; - }; - - 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; - - var TypeAnnotation = (function (_super) { - __extends(TypeAnnotation, _super); - function TypeAnnotation(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - TypeAnnotation.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - return TypeAnnotation; - })(AST); - TypeScript.TypeAnnotation = TypeAnnotation; - - var BuiltInType = (function (_super) { - __extends(BuiltInType, _super); - function BuiltInType(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - BuiltInType.prototype.text = function () { - return this._text; - }; - - BuiltInType.prototype.valueText = function () { - return this._valueText; - }; - - BuiltInType.prototype.kind = function () { - return this._nodeType; - }; - return BuiltInType; - })(AST); - TypeScript.BuiltInType = BuiltInType; - - var ExternalModuleReference = (function (_super) { - __extends(ExternalModuleReference, _super); - function ExternalModuleReference(stringLiteral) { - _super.call(this); - this.stringLiteral = stringLiteral; - stringLiteral && (stringLiteral.parent = this); - } - ExternalModuleReference.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - return ExternalModuleReference; - })(AST); - TypeScript.ExternalModuleReference = ExternalModuleReference; - - var ModuleNameModuleReference = (function (_super) { - __extends(ModuleNameModuleReference, _super); - function ModuleNameModuleReference(moduleName) { - _super.call(this); - this.moduleName = moduleName; - moduleName && (moduleName.parent = this); - } - ModuleNameModuleReference.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - return ModuleNameModuleReference; - })(AST); - TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(modifiers, identifier, moduleReference) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.moduleReference = moduleReference; - identifier && (identifier.parent = this); - moduleReference && (moduleReference.parent = this); - } - ImportDeclaration.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(identifier) { - _super.call(this); - this.identifier = identifier; - identifier && (identifier.parent = this); - } - ExportAssignment.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var TypeParameterList = (function (_super) { - __extends(TypeParameterList, _super); - function TypeParameterList(typeParameters) { - _super.call(this); - this.typeParameters = typeParameters; - typeParameters && (typeParameters.parent = this); - } - TypeParameterList.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - return TypeParameterList; - })(AST); - TypeScript.TypeParameterList = TypeParameterList; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - heritageClauses && (heritageClauses.parent = this); - classElements && (classElements.parent = this); - } - ClassDeclaration.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return ClassDeclaration; - })(AST); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - body && (body.parent = this); - heritageClauses && (heritageClauses.parent = this); - } - InterfaceDeclaration.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return InterfaceDeclaration; - })(AST); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var HeritageClause = (function (_super) { - __extends(HeritageClause, _super); - function HeritageClause(_nodeType, typeNames) { - _super.call(this); - this._nodeType = _nodeType; - this.typeNames = typeNames; - typeNames && (typeNames.parent = this); - } - HeritageClause.prototype.kind = function () { - return this._nodeType; - }; - - HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); - }; - return HeritageClause; - })(AST); - TypeScript.HeritageClause = HeritageClause; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { - _super.call(this); - this.modifiers = modifiers; - this.name = name; - this.stringLiteral = stringLiteral; - this.moduleElements = moduleElements; - this.endingToken = endingToken; - name && (name.parent = this); - stringLiteral && (stringLiteral.parent = this); - moduleElements && (moduleElements.parent = this); - } - ModuleDeclaration.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return ModuleDeclaration; - })(AST); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(modifiers, identifier, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionDeclaration.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(modifiers, declaration) { - _super.call(this); - this.modifiers = modifiers; - this.declaration = declaration; - declaration && (declaration.parent = this); - } - VariableStatement.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(AST); - TypeScript.VariableStatement = VariableStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this); - this.declarators = declarators; - declarators && (declarators.parent = this); - } - VariableDeclaration.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - VariableDeclarator.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - return VariableDeclarator; - })(AST); - TypeScript.VariableDeclarator = VariableDeclarator; - - var EqualsValueClause = (function (_super) { - __extends(EqualsValueClause, _super); - function EqualsValueClause(value) { - _super.call(this); - this.value = value; - value && (value.parent = this); - } - EqualsValueClause.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - return EqualsValueClause; - })(AST); - TypeScript.EqualsValueClause = EqualsValueClause; - - var PrefixUnaryExpression = (function (_super) { - __extends(PrefixUnaryExpression, _super); - function PrefixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PrefixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ArrayLiteralExpression = (function (_super) { - __extends(ArrayLiteralExpression, _super); - function ArrayLiteralExpression(expressions) { - _super.call(this); - this.expressions = expressions; - expressions && (expressions.parent = this); - } - ArrayLiteralExpression.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - 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; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.apply(this, arguments); - } - OmittedExpression.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - 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; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(openParenTrailingComments, expression) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.expression = expression; - expression && (expression.parent = this); - } - ParenthesizedExpression.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - 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; - - var SimpleArrowFunctionExpression = (function (_super) { - __extends(SimpleArrowFunctionExpression, _super); - function SimpleArrowFunctionExpression(identifier, block, expression) { - _super.call(this); - this.identifier = identifier; - this.block = block; - this.expression = expression; - identifier && (identifier.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - SimpleArrowFunctionExpression.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return SimpleArrowFunctionExpression; - })(AST); - TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; - - var ParenthesizedArrowFunctionExpression = (function (_super) { - __extends(ParenthesizedArrowFunctionExpression, _super); - function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - this.expression = expression; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - ParenthesizedArrowFunctionExpression.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return ParenthesizedArrowFunctionExpression; - })(AST); - TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; - - var QualifiedName = (function (_super) { - __extends(QualifiedName, _super); - function QualifiedName(left, right) { - _super.call(this); - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - QualifiedName.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedName.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); - }; - return QualifiedName; - })(AST); - TypeScript.QualifiedName = QualifiedName; - - var ParameterList = (function (_super) { - __extends(ParameterList, _super); - function ParameterList(openParenTrailingComments, parameters) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.parameters = parameters; - parameters && (parameters.parent = this); - } - ParameterList.prototype.kind = function () { - return 227 /* ParameterList */; - }; - return ParameterList; - })(AST); - TypeScript.ParameterList = ParameterList; - - var ConstructorType = (function (_super) { - __extends(ConstructorType, _super); - function ConstructorType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - ConstructorType.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - return ConstructorType; - })(AST); - TypeScript.ConstructorType = ConstructorType; - - var FunctionType = (function (_super) { - __extends(FunctionType, _super); - function FunctionType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - FunctionType.prototype.kind = function () { - return 123 /* FunctionType */; - }; - return FunctionType; - })(AST); - TypeScript.FunctionType = FunctionType; - - var ObjectType = (function (_super) { - __extends(ObjectType, _super); - function ObjectType(typeMembers) { - _super.call(this); - this.typeMembers = typeMembers; - typeMembers && (typeMembers.parent = this); - } - ObjectType.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); - }; - return ObjectType; - })(AST); - TypeScript.ObjectType = ObjectType; - - var ArrayType = (function (_super) { - __extends(ArrayType, _super); - function ArrayType(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - ArrayType.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); - }; - return ArrayType; - })(AST); - TypeScript.ArrayType = ArrayType; - - var TypeArgumentList = (function (_super) { - __extends(TypeArgumentList, _super); - function TypeArgumentList(typeArguments) { - _super.call(this); - this.typeArguments = typeArguments; - typeArguments && (typeArguments.parent = this); - } - TypeArgumentList.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - return TypeArgumentList; - })(AST); - TypeScript.TypeArgumentList = TypeArgumentList; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArgumentList) { - _super.call(this); - this.name = name; - this.typeArgumentList = typeArgumentList; - name && (name.parent = this); - typeArgumentList && (typeArgumentList.parent = this); - } - GenericType.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeQuery = (function (_super) { - __extends(TypeQuery, _super); - function TypeQuery(name) { - _super.call(this); - this.name = name; - name && (name.parent = this); - } - TypeQuery.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); - }; - return TypeQuery; - })(AST); - TypeScript.TypeQuery = TypeQuery; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements, closeBraceLeadingComments, closeBraceToken) { - _super.call(this); - this.statements = statements; - this.closeBraceLeadingComments = closeBraceLeadingComments; - this.closeBraceToken = closeBraceToken; - statements && (statements.parent = this); - } - Block.prototype.kind = function () { - return 146 /* Block */; - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(AST); - TypeScript.Block = Block; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - _super.call(this); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - Parameter.prototype.kind = function () { - return 242 /* Parameter */; - }; - return Parameter; - })(AST); - TypeScript.Parameter = Parameter; - - var MemberAccessExpression = (function (_super) { - __extends(MemberAccessExpression, _super); - function MemberAccessExpression(expression, name) { - _super.call(this); - this.expression = expression; - this.name = name; - expression && (expression.parent = this); - name && (name.parent = this); - } - MemberAccessExpression.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - 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; - - var PostfixUnaryExpression = (function (_super) { - __extends(PostfixUnaryExpression, _super); - function PostfixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PostfixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ElementAccessExpression = (function (_super) { - __extends(ElementAccessExpression, _super); - function ElementAccessExpression(expression, argumentExpression) { - _super.call(this); - this.expression = expression; - this.argumentExpression = argumentExpression; - expression && (expression.parent = this); - argumentExpression && (argumentExpression.parent = this); - } - ElementAccessExpression.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - 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; - - var InvocationExpression = (function (_super) { - __extends(InvocationExpression, _super); - function InvocationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - InvocationExpression.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - 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) { - _super.call(this); - this.typeArgumentList = typeArgumentList; - this.closeParenToken = closeParenToken; - this.arguments = _arguments; - - typeArgumentList && (typeArgumentList.parent = this); - _arguments && (_arguments.parent = this); - } - ArgumentList.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - return ArgumentList; - })(AST); - TypeScript.ArgumentList = ArgumentList; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(_nodeType, left, right) { - _super.call(this); - this._nodeType = _nodeType; - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - BinaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(condition, whenTrue, whenFalse) { - _super.call(this); - this.condition = condition; - this.whenTrue = whenTrue; - this.whenFalse = whenFalse; - condition && (condition.parent = this); - whenTrue && (whenTrue.parent = this); - whenFalse && (whenFalse.parent = this); - } - ConditionalExpression.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - 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; - - var ConstructSignature = (function (_super) { - __extends(ConstructSignature, _super); - function ConstructSignature(callSignature) { - _super.call(this); - this.callSignature = callSignature; - callSignature && (callSignature.parent = this); - } - ConstructSignature.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - return ConstructSignature; - })(AST); - TypeScript.ConstructSignature = ConstructSignature; - - var MethodSignature = (function (_super) { - __extends(MethodSignature, _super); - function MethodSignature(propertyName, questionToken, callSignature) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - } - MethodSignature.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - return MethodSignature; - })(AST); - TypeScript.MethodSignature = MethodSignature; - - var IndexSignature = (function (_super) { - __extends(IndexSignature, _super); - function IndexSignature(parameter, typeAnnotation) { - _super.call(this); - this.parameter = parameter; - this.typeAnnotation = typeAnnotation; - parameter && (parameter.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - IndexSignature.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - return IndexSignature; - })(AST); - TypeScript.IndexSignature = IndexSignature; - - var PropertySignature = (function (_super) { - __extends(PropertySignature, _super); - function PropertySignature(propertyName, questionToken, typeAnnotation) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - PropertySignature.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - return PropertySignature; - })(AST); - TypeScript.PropertySignature = PropertySignature; - - var CallSignature = (function (_super) { - __extends(CallSignature, _super); - function CallSignature(typeParameterList, parameterList, typeAnnotation) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - CallSignature.prototype.kind = function () { - return 142 /* CallSignature */; - }; - return CallSignature; - })(AST); - TypeScript.CallSignature = CallSignature; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(identifier, constraint) { - _super.call(this); - this.identifier = identifier; - this.constraint = constraint; - identifier && (identifier.parent = this); - constraint && (constraint.parent = this); - } - TypeParameter.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var Constraint = (function (_super) { - __extends(Constraint, _super); - function Constraint(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - Constraint.prototype.kind = function () { - return 239 /* Constraint */; - }; - return Constraint; - })(AST); - TypeScript.Constraint = Constraint; - - var ElseClause = (function (_super) { - __extends(ElseClause, _super); - function ElseClause(statement) { - _super.call(this); - this.statement = statement; - statement && (statement.parent = this); - } - ElseClause.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ElseClause; - })(AST); - TypeScript.ElseClause = ElseClause; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(condition, statement, elseClause) { - _super.call(this); - this.condition = condition; - this.statement = statement; - this.elseClause = elseClause; - condition && (condition.parent = this); - statement && (statement.parent = this); - elseClause && (elseClause.parent = this); - } - IfStatement.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); - }; - return IfStatement; - })(AST); - TypeScript.IfStatement = IfStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ExpressionStatement.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(AST); - TypeScript.ExpressionStatement = ExpressionStatement; - - var ConstructorDeclaration = (function (_super) { - __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(callSignature, block) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - ConstructorDeclaration.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - return ConstructorDeclaration; - })(AST); - TypeScript.ConstructorDeclaration = ConstructorDeclaration; - - var MemberFunctionDeclaration = (function (_super) { - __extends(MemberFunctionDeclaration, _super); - function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - MemberFunctionDeclaration.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - return MemberFunctionDeclaration; - })(AST); - TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; - - var GetAccessor = (function (_super) { - __extends(GetAccessor, _super); - function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - GetAccessor.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - return GetAccessor; - })(AST); - TypeScript.GetAccessor = GetAccessor; - - var SetAccessor = (function (_super) { - __extends(SetAccessor, _super); - function SetAccessor(modifiers, propertyName, parameterList, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - SetAccessor.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - return SetAccessor; - })(AST); - TypeScript.SetAccessor = SetAccessor; - - var MemberVariableDeclaration = (function (_super) { - __extends(MemberVariableDeclaration, _super); - function MemberVariableDeclaration(modifiers, variableDeclarator) { - _super.call(this); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - variableDeclarator && (variableDeclarator.parent = this); - } - MemberVariableDeclaration.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - return MemberVariableDeclaration; - })(AST); - TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; - - var IndexMemberDeclaration = (function (_super) { - __extends(IndexMemberDeclaration, _super); - function IndexMemberDeclaration(indexSignature) { - _super.call(this); - this.indexSignature = indexSignature; - indexSignature && (indexSignature.parent = this); - } - IndexMemberDeclaration.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - return IndexMemberDeclaration; - })(AST); - TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ThrowStatement.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(AST); - TypeScript.ThrowStatement = ThrowStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ReturnStatement.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ReturnStatement; - })(AST); - TypeScript.ReturnStatement = ReturnStatement; - - var ObjectCreationExpression = (function (_super) { - __extends(ObjectCreationExpression, _super); - function ObjectCreationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - ObjectCreationExpression.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - 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; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(expression, closeParenToken, switchClauses) { - _super.call(this); - this.expression = expression; - this.closeParenToken = closeParenToken; - this.switchClauses = switchClauses; - expression && (expression.parent = this); - switchClauses && (switchClauses.parent = this); - } - SwitchStatement.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return SwitchStatement; - })(AST); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseSwitchClause = (function (_super) { - __extends(CaseSwitchClause, _super); - function CaseSwitchClause(expression, statements) { - _super.call(this); - this.expression = expression; - this.statements = statements; - expression && (expression.parent = this); - statements && (statements.parent = this); - } - CaseSwitchClause.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return CaseSwitchClause; - })(AST); - TypeScript.CaseSwitchClause = CaseSwitchClause; - - var DefaultSwitchClause = (function (_super) { - __extends(DefaultSwitchClause, _super); - function DefaultSwitchClause(statements) { - _super.call(this); - this.statements = statements; - statements && (statements.parent = this); - } - DefaultSwitchClause.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return DefaultSwitchClause; - })(AST); - TypeScript.DefaultSwitchClause = DefaultSwitchClause; - - var BreakStatement = (function (_super) { - __extends(BreakStatement, _super); - function BreakStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - BreakStatement.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return BreakStatement; - })(AST); - TypeScript.BreakStatement = BreakStatement; - - var ContinueStatement = (function (_super) { - __extends(ContinueStatement, _super); - function ContinueStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - ContinueStatement.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ContinueStatement; - })(AST); - TypeScript.ContinueStatement = ContinueStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.condition = condition; - this.incrementor = incrementor; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - initializer && (initializer.parent = this); - condition && (condition.parent = this); - incrementor && (incrementor.parent = this); - statement && (statement.parent = this); - } - ForStatement.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForStatement; - })(AST); - TypeScript.ForStatement = ForStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(variableDeclaration, left, expression, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.left = left; - this.expression = expression; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - left && (left.parent = this); - expression && (expression.parent = this); - statement && (statement.parent = this); - } - ForInStatement.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForInStatement; - })(AST); - TypeScript.ForInStatement = ForInStatement; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WhileStatement.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WhileStatement; - })(AST); - TypeScript.WhileStatement = WhileStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WithStatement.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WithStatement; - })(AST); - TypeScript.WithStatement = WithStatement; - - var EnumDeclaration = (function (_super) { - __extends(EnumDeclaration, _super); - function EnumDeclaration(modifiers, identifier, enumElements) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.enumElements = enumElements; - identifier && (identifier.parent = this); - enumElements && (enumElements.parent = this); - } - EnumDeclaration.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - return EnumDeclaration; - })(AST); - TypeScript.EnumDeclaration = EnumDeclaration; - - var EnumElement = (function (_super) { - __extends(EnumElement, _super); - function EnumElement(propertyName, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - EnumElement.prototype.kind = function () { - return 243 /* EnumElement */; - }; - return EnumElement; - })(AST); - TypeScript.EnumElement = EnumElement; - - var CastExpression = (function (_super) { - __extends(CastExpression, _super); - function CastExpression(type, expression) { - _super.call(this); - this.type = type; - this.expression = expression; - type && (type.parent = this); - expression && (expression.parent = this); - } - CastExpression.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - 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; - - var ObjectLiteralExpression = (function (_super) { - __extends(ObjectLiteralExpression, _super); - function ObjectLiteralExpression(propertyAssignments) { - _super.call(this); - this.propertyAssignments = propertyAssignments; - propertyAssignments && (propertyAssignments.parent = this); - } - ObjectLiteralExpression.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - 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; - - var SimplePropertyAssignment = (function (_super) { - __extends(SimplePropertyAssignment, _super); - function SimplePropertyAssignment(propertyName, expression) { - _super.call(this); - this.propertyName = propertyName; - this.expression = expression; - propertyName && (propertyName.parent = this); - expression && (expression.parent = this); - } - SimplePropertyAssignment.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - return SimplePropertyAssignment; - })(AST); - TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; - - var FunctionPropertyAssignment = (function (_super) { - __extends(FunctionPropertyAssignment, _super); - function FunctionPropertyAssignment(propertyName, callSignature, block) { - _super.call(this); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionPropertyAssignment.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - return FunctionPropertyAssignment; - })(AST); - TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; - - var FunctionExpression = (function (_super) { - __extends(FunctionExpression, _super); - function FunctionExpression(identifier, callSignature, block) { - _super.call(this); - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionExpression.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpression.prototype.isExpression = function () { - return true; - }; - return FunctionExpression; - })(AST); - TypeScript.FunctionExpression = FunctionExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.apply(this, arguments); - } - EmptyStatement.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(AST); - TypeScript.EmptyStatement = EmptyStatement; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(block, catchClause, finallyClause) { - _super.call(this); - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - block && (block.parent = this); - catchClause && (catchClause.parent = this); - finallyClause && (finallyClause.parent = this); - } - TryStatement.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); - }; - return TryStatement; - })(AST); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(identifier, typeAnnotation, block) { - _super.call(this); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.block = block; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - CatchClause.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var FinallyClause = (function (_super) { - __extends(FinallyClause, _super); - function FinallyClause(block) { - _super.call(this); - this.block = block; - block && (block.parent = this); - } - FinallyClause.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return FinallyClause; - })(AST); - TypeScript.FinallyClause = FinallyClause; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this); - this.identifier = identifier; - this.statement = statement; - identifier && (identifier.parent = this); - statement && (statement.parent = this); - } - LabeledStatement.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(AST); - TypeScript.LabeledStatement = LabeledStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(statement, whileKeyword, condition) { - _super.call(this); - this.statement = statement; - this.whileKeyword = whileKeyword; - this.condition = condition; - statement && (statement.parent = this); - condition && (condition.parent = this); - } - DoStatement.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); - }; - return DoStatement; - })(AST); - TypeScript.DoStatement = DoStatement; - - var TypeOfExpression = (function (_super) { - __extends(TypeOfExpression, _super); - function TypeOfExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - TypeOfExpression.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - 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; - - var DeleteExpression = (function (_super) { - __extends(DeleteExpression, _super); - function DeleteExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - DeleteExpression.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - 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; - - var VoidExpression = (function (_super) { - __extends(VoidExpression, _super); - function VoidExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - VoidExpression.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - 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; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.apply(this, arguments); - } - DebuggerStatement.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - return DebuggerStatement; - })(AST); - TypeScript.DebuggerStatement = DebuggerStatement; - - var Comment = (function () { - function Comment(_trivia, endsLine, _start, _end) { - this._trivia = _trivia; - this.endsLine = endsLine; - this._start = _start; - this._end = _end; - } - Comment.prototype.start = function () { - return this._start; - }; - - Comment.prototype.end = function () { - return this._end; - }; - - Comment.prototype.fullText = function () { - return this._trivia.fullText(); - }; - - Comment.prototype.kind = function () { - return this._trivia.kind(); - }; - - Comment.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; - }; - return Comment; - })(); - TypeScript.Comment = Comment; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IOUtils) { - function createDirectoryStructure(ioHost, dirName) { - if (ioHost.directoryExists(dirName)) { - return; - } - - var parentDirectory = ioHost.dirName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(ioHost, parentDirectory); - } - ioHost.createDirectory(dirName); - } - - function writeFileAndFolderStructure(ioHost, fileName, contents, writeByteOrderMark) { - var start = new Date().getTime(); - var path = ioHost.resolvePath(fileName); - TypeScript.ioHostResolvePathTime += new Date().getTime() - start; - - var start = new Date().getTime(); - var dirName = ioHost.dirName(path); - TypeScript.ioHostDirectoryNameTime += new Date().getTime() - start; - - var start = new Date().getTime(); - createDirectoryStructure(ioHost, dirName); - TypeScript.ioHostCreateDirectoryStructureTime += new Date().getTime() - start; - - var start = new Date().getTime(); - ioHost.writeFile(path, contents, writeByteOrderMark); - TypeScript.ioHostWriteFileTime += new Date().getTime() - start; - } - IOUtils.writeFileAndFolderStructure = writeFileAndFolderStructure; - - function throwIOError(message, error) { - var errorMessage = message; - if (error && error.message) { - errorMessage += (" " + error.message); - } - throw new Error(errorMessage); - } - IOUtils.throwIOError = throwIOError; - - function combine(prefix, suffix) { - return prefix + "/" + suffix; - } - IOUtils.combine = combine; - - var BufferedTextWriter = (function () { - function BufferedTextWriter(writer, capacity) { - if (typeof capacity === "undefined") { capacity = 1024; } - this.writer = writer; - this.capacity = capacity; - this.buffer = ""; - } - BufferedTextWriter.prototype.Write = function (str) { - this.buffer += str; - if (this.buffer.length >= this.capacity) { - this.writer.Write(this.buffer); - this.buffer = ""; - } - }; - BufferedTextWriter.prototype.WriteLine = function (str) { - this.Write(str + '\r\n'); - }; - BufferedTextWriter.prototype.Close = function () { - this.writer.Write(this.buffer); - this.writer.Close(); - this.buffer = null; - }; - return BufferedTextWriter; - })(); - IOUtils.BufferedTextWriter = BufferedTextWriter; - })(TypeScript.IOUtils || (TypeScript.IOUtils = {})); - var IOUtils = TypeScript.IOUtils; - - TypeScript.IO = (function () { - function getWindowsScriptHostIO() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - 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); - }, - writeFile: function (path, contents, writeByteOrderMark) { - TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - dirName: function (path) { - return fso.GetParentFolderName(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; - - while (true) { - if (fso.FileExists(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); - - if (rootPath == "") { - return null; - } else { - path = fso.BuildPath(rootPath, partialFilePath); - } - } - } - }, - deleteFile: function (path) { - try { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - fso.CreateFolder(path); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); - } - }, - dir: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "/" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - print: function (str) { - WScript.StdOut.Write(str); - }, - printLine: function (str) { - WScript.Echo(str); - }, - arguments: args, - stderr: WScript.StdErr, - stdout: WScript.StdOut, - watchFile: null, - run: function (source, fileName) { - try { - eval(source); - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Error_while_executing_file_0, [fileName]), e); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - quit: function (exitCode) { - if (typeof exitCode === "undefined") { exitCode = 0; } - try { - WScript.Quit(exitCode); - } catch (e) { - } - } - }; - } - ; - - function getNodeIO() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - appendFile: function (path, content) { - _fs.appendFileSync(path, content); - }, - readFile: function (file, codepage) { - return TypeScript.Environment.readFile(file, codepage); - }, - writeFile: function (path, contents, writeByteOrderMark) { - TypeScript.Environment.writeFile(path, contents, writeByteOrderMark); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_delete_file_0, [path]), e); - } - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - dir: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - try { - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "/" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "/" + files[i]); - } - } - } catch (err) { - } - - return paths; - } - - return filesInFolder(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - _fs.mkdirSync(path); - } - } catch (e) { - IOUtils.throwIOError(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_create_directory_0, [path]), e); - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - dirName: function (path) { - var dirPath = _path.dirname(path); - - if (dirPath === path) { - dirPath = null; - } - - return dirPath; - }, - findFile: function (rootPath, partialFilePath) { - var path = rootPath + "/" + partialFilePath; - - while (true) { - if (_fs.existsSync(path)) { - return { fileInformation: this.readFile(path), path: path }; - } else { - var parentPath = _path.resolve(rootPath, ".."); - - if (rootPath === parentPath) { - return null; - } else { - rootPath = parentPath; - path = _path.resolve(rootPath, partialFilePath); - } - } - } - }, - print: function (str) { - process.stdout.write(str); - }, - printLine: function (str) { - process.stdout.write(str + '\n'); - }, - arguments: process.argv.slice(2), - stderr: { - Write: function (str) { - process.stderr.write(str); - }, - WriteLine: function (str) { - process.stderr.write(str + '\n'); - }, - Close: function () { - } - }, - stdout: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - }, - watchFile: function (fileName, callback) { - var firstRun = true; - var processingChange = false; - - var fileChanged = function (curr, prev) { - if (!firstRun) { - if (curr.mtime < prev.mtime) { - return; - } - - _fs.unwatchFile(fileName, fileChanged); - if (!processingChange) { - processingChange = true; - callback(fileName); - setTimeout(function () { - processingChange = false; - }, 100); - } - } - firstRun = false; - _fs.watchFile(fileName, { persistent: true, interval: 500 }, fileChanged); - }; - - fileChanged(); - return { - fileName: fileName, - close: function () { - _fs.unwatchFile(fileName, fileChanged); - } - }; - }, - run: function (source, fileName) { - require.main.fileName = fileName; - require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName))); - require.main._compile(source, fileName); - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - quit: function (code) { - var stderrFlushed = process.stderr.write(''); - var stdoutFlushed = process.stdout.write(''); - process.stderr.on('drain', function () { - stderrFlushed = true; - if (stdoutFlushed) { - process.exit(code); - } - }); - process.stdout.on('drain', function () { - stdoutFlushed = true; - if (stderrFlushed) { - process.exit(code); - } - }); - setTimeout(function () { - process.exit(code); - }, 5); - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") - return getWindowsScriptHostIO(); - else if (typeof module !== 'undefined' && module.exports) - return getNodeIO(); - else - return null; - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OptionsParser = (function () { - function OptionsParser(host, version) { - this.host = host; - this.version = version; - this.DEFAULT_SHORT_FLAG = "-"; - this.DEFAULT_LONG_FLAG = "--"; - this.printedVersion = false; - this.unnamed = []; - this.options = []; - } - OptionsParser.prototype.findOption = function (arg) { - var upperCaseArg = arg && arg.toUpperCase(); - - for (var i = 0; i < this.options.length; i++) { - var current = this.options[i]; - - if (upperCaseArg === (current.short && current.short.toUpperCase()) || upperCaseArg === (current.name && current.name.toUpperCase())) { - return current; - } - } - - return null; - }; - - OptionsParser.prototype.printUsage = function () { - this.printVersion(); - - var optionsWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.options, null); - var fileWord = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.file1, null); - var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]"; - var syntaxHelp = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Syntax_0, [tscSyntax]); - this.host.printLine(syntaxHelp); - this.host.printLine(""); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Examples, null) + " tsc hello.ts"); - this.host.printLine(" tsc --out foo.js foo.ts"); - this.host.printLine(" tsc @args.txt"); - this.host.printLine(""); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Options, null)); - - var output = []; - var maxLength = 0; - var i = 0; - - this.options = this.options.sort(function (a, b) { - var aName = a.name.toLowerCase(); - var bName = b.name.toLowerCase(); - - if (aName > bName) { - return 1; - } else if (aName < bName) { - return -1; - } else { - return 0; - } - }); - - for (i = 0; i < this.options.length; i++) { - var option = this.options[i]; - - if (option.experimental) { - continue; - } - - if (!option.usage) { - break; - } - - var usageString = " "; - var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : ""; - - if (option.short) { - usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", "; - } - - usageString += this.DEFAULT_LONG_FLAG + option.name + type; - - output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]); - - if (usageString.length > maxLength) { - maxLength = usageString.length; - } - } - - var fileDescription = TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null); - output.push([" @<" + fileWord + ">", fileDescription]); - - for (i = 0; i < output.length; i++) { - this.host.printLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]); - } - }; - - OptionsParser.prototype.printVersion = function () { - if (!this.printedVersion) { - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Version_0, [this.version])); - this.printedVersion = true; - } - }; - - OptionsParser.prototype.option = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = false; - - this.options.push(config); - }; - - OptionsParser.prototype.flag = function (name, config, short) { - if (!config) { - config = short; - short = null; - } - - config.name = name; - config.short = short; - config.flag = true; - - this.options.push(config); - }; - - OptionsParser.prototype.parseString = function (argString) { - var position = 0; - var tokens = argString.match(/\s+|"|[^\s"]+/g); - - function peek() { - return tokens[position]; - } - - function consume() { - return tokens[position++]; - } - - function consumeQuotedString() { - var value = ''; - consume(); - - var token = peek(); - - while (token && token !== '"') { - consume(); - - value += token; - - token = peek(); - } - - consume(); - - return value; - } - - var args = []; - var currentArg = ''; - - while (position < tokens.length) { - var token = peek(); - - if (token === '"') { - currentArg += consumeQuotedString(); - } else if (token.match(/\s/)) { - if (currentArg.length > 0) { - args.push(currentArg); - currentArg = ''; - } - - consume(); - } else { - consume(); - currentArg += token; - } - } - - if (currentArg.length > 0) { - args.push(currentArg); - } - - this.parse(args); - }; - - OptionsParser.prototype.parse = function (args) { - var position = 0; - - function consume() { - return args[position++]; - } - - while (position < args.length) { - var current = consume(); - var match = current.match(/^(--?|@)(.*)/); - var value = null; - - if (match) { - if (match[1] === '@') { - this.parseString(this.host.readFile(match[2], null).contents); - } else { - var arg = match[2]; - var option = this.findOption(arg); - - if (option === null) { - this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_option_0, [arg])); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); - } else { - if (!option.flag) { - value = consume(); - if (value === undefined) { - this.host.printLine(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Option_0_specified_without_1, [arg, TypeScript.getLocalizedText(option.type, null)])); - this.host.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"])); - continue; - } - } - - option.set(value); - } - } - } else { - this.unnamed.push(current); - } - } - }; - return OptionsParser; - })(); - TypeScript.OptionsParser = OptionsParser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceFile = (function () { - function SourceFile(scriptSnapshot, byteOrderMark) { - this.scriptSnapshot = scriptSnapshot; - this.byteOrderMark = byteOrderMark; - } - return SourceFile; - })(); - - var DiagnosticsLogger = (function () { - function DiagnosticsLogger(ioHost) { - this.ioHost = ioHost; - } - DiagnosticsLogger.prototype.information = function () { - return false; - }; - DiagnosticsLogger.prototype.debug = function () { - return false; - }; - DiagnosticsLogger.prototype.warning = function () { - return false; - }; - DiagnosticsLogger.prototype.error = function () { - return false; - }; - DiagnosticsLogger.prototype.fatal = function () { - return false; - }; - DiagnosticsLogger.prototype.log = function (s) { - this.ioHost.stdout.WriteLine(s); - }; - 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.7.0"; - this.inputFiles = []; - this.resolvedFiles = []; - this.fileNameToSourceFile = new TypeScript.StringHashTable(); - this.hasErrors = false; - this.logger = null; - this.fileExistsCache = TypeScript.createIntrinsicsObject(); - this.resolvePathCache = TypeScript.createIntrinsicsObject(); - } - BatchCompiler.prototype.batchCompile = function () { - var _this = this; - var start = new Date().getTime(); - - TypeScript.CompilerDiagnostics.diagnosticWriter = { Alert: function (s) { - _this.ioHost.printLine(s); - } }; - - if (this.parseOptions()) { - 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(); - return; - } - - this.resolve(); - - 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); - this.logger.log(" file read: " + TypeScript.fileResolutionIOTime); - this.logger.log(" scan imports: " + TypeScript.fileResolutionScanImportsTime); - this.logger.log(" import search: " + TypeScript.fileResolutionImportFileSearchTime); - this.logger.log(" get lib.d.ts: " + TypeScript.fileResolutionGetDefaultLibraryTime); - - this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime); - this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime); - this.logger.log("AST translation time: " + TypeScript.astTranslationTime); - this.logger.log(""); - this.logger.log("Type check time: " + TypeScript.typeCheckTime); - this.logger.log(""); - this.logger.log("Emit time: " + TypeScript.emitTime); - this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime); - - this.logger.log("Total number of symbols created: " + TypeScript.pullSymbolID); - this.logger.log("Specialized types created: " + TypeScript.nSpecializationsCreated); - this.logger.log("Specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated); - - this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime); - this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime); - this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime); - this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime); - this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime); - this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime); - this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime); - this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime); - this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime); - - this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime); - - this.logger.log("Compiler resolve path time: " + TypeScript.compilerResolvePathTime); - this.logger.log("Compiler directory name time: " + TypeScript.compilerDirectoryNameTime); - this.logger.log("Compiler directory exists time: " + TypeScript.compilerDirectoryExistsTime); - this.logger.log("Compiler file exists time: " + TypeScript.compilerFileExistsTime); - - this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime); - this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime); - this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime); - this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime); - - this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime); - this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime); - this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime); - } - } - - this.ioHost.quit(this.hasErrors ? 1 : 0); - }; - - BatchCompiler.prototype.resolve = function () { - var _this = this; - var includeDefaultLibrary = !this.compilationSettings.noLib(); - var resolvedFiles = []; - - var start = new Date().getTime(); - - if (!this.compilationSettings.noResolve()) { - var resolutionResults = TypeScript.ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings.useCaseSensitiveFileResolution()); - resolvedFiles = resolutionResults.resolvedFiles; - - includeDefaultLibrary = !this.compilationSettings.noLib() && !resolutionResults.seenNoDefaultLibTag; - - resolutionResults.diagnostics.forEach(function (d) { - return _this.addDiagnostic(d); - }); - } else { - for (var i = 0, n = this.inputFiles.length; i < n; i++) { - var inputFile = this.inputFiles[i]; - var referencedFiles = []; - var importedFiles = []; - - if (this.compilationSettings.generateDeclarationFiles()) { - var references = TypeScript.getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile)); - for (var j = 0; j < references.length; j++) { - referencedFiles.push(references[j].path); - } - - inputFile = this.resolvePath(inputFile); - } - - resolvedFiles.push({ - path: inputFile, - referencedFiles: referencedFiles, - importedFiles: importedFiles - }); - } - } - - var defaultLibStart = new Date().getTime(); - if (includeDefaultLibrary) { - var libraryResolvedFile = { - path: this.getDefaultLibraryFilePath(), - referencedFiles: [], - importedFiles: [] - }; - - resolvedFiles = [libraryResolvedFile].concat(resolvedFiles); - } - TypeScript.fileResolutionGetDefaultLibraryTime += new Date().getTime() - defaultLibStart; - - this.resolvedFiles = resolvedFiles; - - TypeScript.fileResolutionTime = new Date().getTime() - start; - }; - - BatchCompiler.prototype.compile = function () { - var _this = this; - var compiler = new TypeScript.TypeScriptCompiler(this.logger, this.compilationSettings); - - this.resolvedFiles.forEach(function (resolvedFile) { - var sourceFile = _this.getSourceFile(resolvedFile.path); - compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, 0, false, resolvedFile.referencedFiles); - }); - - for (var it = compiler.compile(function (path) { - return _this.resolvePath(path); - }); it.moveNext();) { - var result = it.current(); - - result.diagnostics.forEach(function (d) { - return _this.addDiagnostic(d); - }); - if (!this.tryWriteOutputFiles(result.outputFiles)) { - return; - } - } - }; - - BatchCompiler.prototype.parseOptions = function () { - var _this = this; - var opts = new TypeScript.OptionsParser(this.ioHost, this.compilerVersion); - - var mutableSettings = new TypeScript.CompilationSettings(); - opts.option('out', { - usage: { - locCode: TypeScript.DiagnosticCode.Concatenate_and_emit_output_to_single_file, - args: null - }, - type: TypeScript.DiagnosticCode.file2, - set: function (str) { - mutableSettings.outFileOption = str; - } - }); - - opts.option('outDir', { - usage: { - locCode: TypeScript.DiagnosticCode.Redirect_output_structure_to_the_directory, - args: null - }, - type: TypeScript.DiagnosticCode.DIRECTORY, - set: function (str) { - mutableSettings.outDirOption = str; - } - }); - - opts.flag('sourcemap', { - usage: { - locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, - args: ['.map'] - }, - set: function () { - mutableSettings.mapSourceFiles = true; - } - }); - - opts.option('mapRoot', { - usage: { - locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - args: null - }, - type: TypeScript.DiagnosticCode.LOCATION, - set: function (str) { - mutableSettings.mapRoot = str; - } - }); - - opts.option('sourceRoot', { - usage: { - locCode: TypeScript.DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - args: null - }, - type: TypeScript.DiagnosticCode.LOCATION, - set: function (str) { - mutableSettings.sourceRoot = str; - } - }); - - opts.flag('declaration', { - usage: { - locCode: TypeScript.DiagnosticCode.Generates_corresponding_0_file, - args: ['.d.ts'] - }, - set: function () { - mutableSettings.generateDeclarationFiles = true; - } - }, 'd'); - - if (this.ioHost.watchFile) { - opts.flag('watch', { - usage: { - locCode: TypeScript.DiagnosticCode.Watch_input_files, - args: null - }, - set: function () { - mutableSettings.watch = true; - } - }, 'w'); - } - - opts.flag('propagateEnumConstants', { - experimental: true, - set: function () { - mutableSettings.propagateEnumConstants = true; - } - }); - - opts.flag('removeComments', { - usage: { - locCode: TypeScript.DiagnosticCode.Do_not_emit_comments_to_output, - args: null - }, - set: function () { - mutableSettings.removeComments = true; - } - }); - - opts.flag('noResolve', { - experimental: true, - usage: { - locCode: TypeScript.DiagnosticCode.Skip_resolution_and_preprocessing, - args: null - }, - set: function () { - mutableSettings.noResolve = true; - } - }); - - opts.flag('noLib', { - experimental: true, - set: function () { - mutableSettings.noLib = true; - } - }); - - opts.flag('diagnostics', { - experimental: true, - set: function () { - mutableSettings.gatherDiagnostics = true; - } - }); - - 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, - args: ['ES3', 'ES5'] - }, - type: TypeScript.DiagnosticCode.VERSION, - set: function (type) { - type = type.toLowerCase(); - - if (type === 'es3') { - mutableSettings.codeGenTarget = 0 /* EcmaScript3 */; - } else if (type === 'es5') { - mutableSettings.codeGenTarget = 1 /* EcmaScript5 */; - } else { - _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.ECMAScript_target_version_0_not_supported_Specify_a_valid_target_version_1_default_or_2, [type, "ES3", "ES5"])); - } - } - }, 't'); - - opts.option('module', { - usage: { - locCode: TypeScript.DiagnosticCode.Specify_module_code_generation_0_or_1, - args: ['commonjs', 'amd'] - }, - type: TypeScript.DiagnosticCode.KIND, - set: function (type) { - type = type.toLowerCase(); - - if (type === 'commonjs') { - mutableSettings.moduleGenTarget = 1 /* Synchronous */; - } else if (type === 'amd') { - mutableSettings.moduleGenTarget = 2 /* Asynchronous */; - } else { - _this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Module_code_generation_0_not_supported, [type])); - } - } - }, 'm'); - - var needsHelp = false; - opts.flag('help', { - usage: { - locCode: TypeScript.DiagnosticCode.Print_this_message, - args: null - }, - set: function () { - needsHelp = true; - } - }, 'h'); - - opts.flag('useCaseSensitiveFileResolution', { - experimental: true, - set: function () { - mutableSettings.useCaseSensitiveFileResolution = true; - } - }); - var shouldPrintVersionOnly = false; - opts.flag('version', { - usage: { - locCode: TypeScript.DiagnosticCode.Print_the_compiler_s_version_0, - args: [this.compilerVersion] - }, - set: function () { - shouldPrintVersionOnly = true; - } - }, 'v'); - - var locale = null; - opts.option('locale', { - experimental: true, - usage: { - locCode: TypeScript.DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1, - args: ['en', 'ja-jp'] - }, - type: TypeScript.DiagnosticCode.STRING, - set: function (value) { - locale = value; - } - }); - - opts.flag('noImplicitAny', { - usage: { - locCode: TypeScript.DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type, - args: null - }, - set: function () { - mutableSettings.noImplicitAny = true; - } - }); - - if (TypeScript.Environment.supportsCodePage()) { - opts.option('codepage', { - usage: { - locCode: TypeScript.DiagnosticCode.Specify_the_codepage_to_use_when_opening_source_files, - args: null - }, - type: TypeScript.DiagnosticCode.NUMBER, - set: function (arg) { - mutableSettings.codepage = parseInt(arg, 10); - } - }); - } - - opts.parse(this.ioHost.arguments); - - this.compilationSettings = TypeScript.ImmutableCompilationSettings.fromCompilationSettings(mutableSettings); - - if (locale) { - if (!this.setLocale(locale)) { - return false; - } - } - - this.inputFiles.push.apply(this.inputFiles, opts.unnamed); - - if (shouldPrintVersionOnly) { - opts.printVersion(); - return false; - } else if (this.inputFiles.length === 0 || needsHelp) { - opts.printUsage(); - return false; - } - - return !this.hasErrors; - }; - - BatchCompiler.prototype.setLocale = function (locale) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); - if (!matchResult) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp'])); - return false; - } - - var language = matchResult[1]; - var territory = matchResult[3]; - - if (!this.setLanguageAndTerritory(language, territory) && !this.setLanguageAndTerritory(language, null)) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Unsupported_locale_0, [locale])); - return false; - } - - return true; - }; - - BatchCompiler.prototype.setLanguageAndTerritory = function (language, territory) { - var compilerFilePath = this.ioHost.getExecutingFilePath(); - var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); - - var filePath = TypeScript.IOUtils.combine(containingDirectoryPath, language); - if (territory) { - filePath = filePath + "-" + territory; - } - - filePath = this.resolvePath(TypeScript.IOUtils.combine(filePath, "diagnosticMessages.generated.json")); - - if (!this.fileExists(filePath)) { - return false; - } - - var fileContents = this.ioHost.readFile(filePath, this.compilationSettings.codepage()); - TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents); - return true; - }; - - BatchCompiler.prototype.watchFiles = function () { - var _this = this; - if (!this.ioHost.watchFile) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]'])); - return; - } - - var lastResolvedFileSet = []; - var watchers = {}; - var firstTime = true; - - var addWatcher = function (fileName) { - if (!watchers[fileName]) { - var watcher = _this.ioHost.watchFile(fileName, onWatchedFileChange); - watchers[fileName] = watcher; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot watch file, it is already watched."); - } - }; - - var removeWatcher = function (fileName) { - if (watchers[fileName]) { - watchers[fileName].close(); - delete watchers[fileName]; - } else { - TypeScript.CompilerDiagnostics.debugPrint("Cannot stop watching file, it is not being watched."); - } - }; - - var onWatchedFileChange = function () { - _this.hasErrors = false; - - _this.fileNameToSourceFile = new TypeScript.StringHashTable(); - - _this.resolve(); - - var oldFiles = lastResolvedFileSet; - var newFiles = _this.resolvedFiles.map(function (resolvedFile) { - return resolvedFile.path; - }).sort(); - - var i = 0, j = 0; - while (i < oldFiles.length && j < newFiles.length) { - var compareResult = oldFiles[i].localeCompare(newFiles[j]); - if (compareResult === 0) { - i++; - j++; - } else if (compareResult < 0) { - removeWatcher(oldFiles[i]); - i++; - } else { - addWatcher(newFiles[j]); - j++; - } - } - - for (var k = i; k < oldFiles.length; k++) { - removeWatcher(oldFiles[k]); - } - - for (k = j; k < newFiles.length; k++) { - addWatcher(newFiles[k]); - } - - lastResolvedFileSet = newFiles; - - if (!firstTime) { - var fileNames = ""; - for (var k = 0; k < lastResolvedFileSet.length; k++) { - fileNames += TypeScript.Environment.newLine + " " + lastResolvedFileSet[k]; - } - _this.ioHost.printLine(TypeScript.getLocalizedText(TypeScript.DiagnosticCode.NL_Recompiling_0, [fileNames])); - } else { - firstTime = false; - } - - _this.compile(); - }; - - this.ioHost.stderr = this.ioHost.stdout; - - onWatchedFileChange(); - }; - - BatchCompiler.prototype.getSourceFile = function (fileName) { - var sourceFile = this.fileNameToSourceFile.lookup(fileName); - if (!sourceFile) { - var fileInformation; - - try { - fileInformation = this.ioHost.readFile(fileName, this.compilationSettings.codepage()); - } catch (e) { - this.addDiagnostic(new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message])); - fileInformation = new TypeScript.FileInformation("", 0 /* None */); - } - - var snapshot = TypeScript.ScriptSnapshot.fromString(fileInformation.contents); - var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark); - this.fileNameToSourceFile.add(fileName, sourceFile); - } - - return sourceFile; - }; - - BatchCompiler.prototype.getDefaultLibraryFilePath = function () { - var compilerFilePath = this.ioHost.getExecutingFilePath(); - var containingDirectoryPath = this.ioHost.dirName(compilerFilePath); - var libraryFilePath = this.resolvePath(TypeScript.IOUtils.combine(containingDirectoryPath, "lib.d.ts")); - - return libraryFilePath; - }; - - BatchCompiler.prototype.getScriptSnapshot = function (fileName) { - return this.getSourceFile(fileName).scriptSnapshot; - }; - - BatchCompiler.prototype.resolveRelativePath = function (path, directory) { - var start = new Date().getTime(); - - var unQuotedPath = TypeScript.stripStartAndEndQuotes(path); - var normalizedPath; - - if (TypeScript.isRooted(unQuotedPath) || !directory) { - normalizedPath = unQuotedPath; - } else { - normalizedPath = TypeScript.IOUtils.combine(directory, unQuotedPath); - } - - normalizedPath = this.resolvePath(normalizedPath); - - normalizedPath = TypeScript.switchToForwardSlashes(normalizedPath); - - return normalizedPath; - }; - - BatchCompiler.prototype.fileExists = function (path) { - var exists = this.fileExistsCache[path]; - if (exists === undefined) { - var start = new Date().getTime(); - exists = this.ioHost.fileExists(path); - this.fileExistsCache[path] = exists; - TypeScript.compilerFileExistsTime += new Date().getTime() - start; - } - - return exists; - }; - - BatchCompiler.prototype.getParentDirectory = function (path) { - var start = new Date().getTime(); - var result = this.ioHost.dirName(path); - TypeScript.compilerDirectoryNameTime += new Date().getTime() - start; - - return result; - }; - - BatchCompiler.prototype.addDiagnostic = function (diagnostic) { - var diagnosticInfo = diagnostic.info(); - if (diagnosticInfo.category === 1 /* Error */) { - this.hasErrors = true; - } - - this.ioHost.stderr.Write(TypeScript.TypeScriptCompiler.getFullDiagnosticText(diagnostic)); - }; - - BatchCompiler.prototype.tryWriteOutputFiles = function (outputFiles) { - for (var i = 0, n = outputFiles.length; i < n; i++) { - var outputFile = outputFiles[i]; - - try { - this.writeFile(outputFile.name, outputFile.text, outputFile.writeByteOrderMark); - } catch (e) { - this.addDiagnostic(new TypeScript.Diagnostic(outputFile.name, null, 0, 0, TypeScript.DiagnosticCode.Emit_Error_0, [e.message])); - return false; - } - } - - return true; - }; - - BatchCompiler.prototype.writeFile = function (fileName, contents, writeByteOrderMark) { - var start = new Date().getTime(); - TypeScript.IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark); - TypeScript.emitWriteFileTime += new Date().getTime() - start; - }; - - BatchCompiler.prototype.directoryExists = function (path) { - var start = new Date().getTime(); - var result = this.ioHost.directoryExists(path); - TypeScript.compilerDirectoryExistsTime += new Date().getTime() - start; - return result; - }; - - BatchCompiler.prototype.resolvePath = function (path) { - var cachedValue = this.resolvePathCache[path]; - if (!cachedValue) { - var start = new Date().getTime(); - cachedValue = this.ioHost.resolvePath(path); - this.resolvePathCache[path] = cachedValue; - TypeScript.compilerResolvePathTime += new Date().getTime() - start; - } - - return cachedValue; - }; - return BatchCompiler; - })(); - TypeScript.BatchCompiler = BatchCompiler; - - var batch = new TypeScript.BatchCompiler(TypeScript.IO); - batch.batchCompile(); -})(TypeScript || (TypeScript = {})); diff --git a/_infrastructure/tests/typescript/0.9.7-66c2df/typescript.js b/_infrastructure/tests/typescript/0.9.7-66c2df/typescript.js deleted file mode 100644 index 29ed8063a7..0000000000 --- a/_infrastructure/tests/typescript/0.9.7-66c2df/typescript.js +++ /dev/null @@ -1,61380 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -var TypeScript; -(function (TypeScript) { - TypeScript.DiagnosticCode = { - error_TS_0_1: "error TS{0}: {1}", - warning_TS_0_1: "warning TS{0}: {1}", - Unrecognized_escape_sequence: "Unrecognized escape sequence.", - Unexpected_character_0: "Unexpected character {0}.", - Missing_close_quote_character: "Missing close quote character.", - Identifier_expected: "Identifier expected.", - _0_keyword_expected: "'{0}' keyword expected.", - _0_expected: "'{0}' expected.", - Identifier_expected_0_is_a_keyword: "Identifier expected; '{0}' is a keyword.", - Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", - Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", - Trailing_separator_not_allowed: "Trailing separator not allowed.", - AsteriskSlash_expected: "'*/' expected.", - public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", - Unexpected_token: "Unexpected token.", - Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", - Rest_parameter_must_be_last_in_list: "Rest parameter must be last in list.", - Parameter_cannot_have_question_mark_and_initializer: "Parameter cannot have question mark and initializer.", - Required_parameter_cannot_follow_optional_parameter: "Required parameter cannot follow optional parameter.", - Index_signatures_cannot_have_rest_parameters: "Index signatures cannot have rest parameters.", - Index_signature_parameter_cannot_have_accessibility_modifiers: "Index signature parameter cannot have accessibility modifiers.", - Index_signature_parameter_cannot_have_a_question_mark: "Index signature parameter cannot have a question mark.", - Index_signature_parameter_cannot_have_an_initializer: "Index signature parameter cannot have an initializer.", - Index_signature_must_have_a_type_annotation: "Index signature must have a type annotation.", - Index_signature_parameter_must_have_a_type_annotation: "Index signature parameter must have a type annotation.", - Index_signature_parameter_type_must_be_string_or_number: "Index signature parameter type must be 'string' or 'number'.", - extends_clause_already_seen: "'extends' clause already seen.", - extends_clause_must_precede_implements_clause: "'extends' clause must precede 'implements' clause.", - Classes_can_only_extend_a_single_class: "Classes can only extend a single class.", - implements_clause_already_seen: "'implements' clause already seen.", - Accessibility_modifier_already_seen: "Accessibility modifier already seen.", - _0_modifier_must_precede_1_modifier: "'{0}' modifier must precede '{1}' modifier.", - _0_modifier_already_seen: "'{0}' modifier already seen.", - _0_modifier_cannot_appear_on_a_class_element: "'{0}' modifier cannot appear on a class element.", - Interface_declaration_cannot_have_implements_clause: "Interface declaration cannot have 'implements' clause.", - super_invocation_cannot_have_type_arguments: "'super' invocation cannot have type arguments.", - Only_ambient_modules_can_use_quoted_names: "Only ambient modules can use quoted names.", - Statements_are_not_allowed_in_ambient_contexts: "Statements are not allowed in ambient contexts.", - 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_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}'.", - _0_modifier_cannot_appear_on_a_module_element: "'{0}' modifier cannot appear on a module element.", - declare_modifier_cannot_appear_on_an_interface_declaration: "'declare' modifier cannot appear on an interface declaration.", - declare_modifier_required_for_top_level_element: "'declare' modifier required for top level element.", - Rest_parameter_cannot_be_optional: "Rest parameter cannot be optional.", - Rest_parameter_cannot_have_an_initializer: "Rest parameter cannot have an initializer.", - set_accessor_must_have_one_and_only_one_parameter: "'set' accessor must have one and only one parameter.", - set_accessor_parameter_cannot_be_optional: "'set' accessor parameter cannot be optional.", - set_accessor_parameter_cannot_have_an_initializer: "'set' accessor parameter cannot have an initializer.", - set_accessor_cannot_have_rest_parameter: "'set' accessor cannot have rest parameter.", - get_accessor_cannot_have_parameters: "'get' accessor cannot have parameters.", - Modifiers_cannot_appear_here: "Modifiers cannot appear here.", - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: "Accessors are only available when targeting ECMAScript 5 and higher.", - Class_name_cannot_be_0: "Class name cannot be '{0}'.", - Interface_name_cannot_be_0: "Interface name cannot be '{0}'.", - Enum_name_cannot_be_0: "Enum name cannot be '{0}'.", - Module_name_cannot_be_0: "Module name cannot be '{0}'.", - Enum_member_must_have_initializer: "Enum member must have initializer.", - Export_assignment_cannot_be_used_in_internal_modules: "Export assignment cannot be used in internal modules.", - Export_assignment_not_allowed_in_module_with_exported_element: "Export assignment not allowed in module with exported element.", - Module_cannot_have_multiple_export_assignments: "Module cannot have multiple export assignments.", - Ambient_enum_elements_can_only_have_integer_literal_initializers: "Ambient enum elements can only have integer literal initializers.", - module_class_interface_enum_import_or_statement: "module, class, interface, enum, import or statement", - constructor_function_accessor_or_variable: "constructor, function, accessor or variable", - statement: "statement", - case_or_default_clause: "case or default clause", - identifier: "identifier", - call_construct_index_property_or_function_signature: "call, construct, index, property or function signature", - expression: "expression", - type_name: "type name", - property_or_accessor: "property or accessor", - parameter: "parameter", - type: "type", - type_parameter: "type parameter", - 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_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.", - super_can_only_be_used_inside_a_class_instance_method: "'super' can only be used inside a class instance method.", - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_property_or_indexer: "The left-hand side of an assignment expression must be a variable, property or indexer.", - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: "Value of type '{0}' is not callable. Did you mean to include 'new'?", - Value_of_type_0_is_not_callable: "Value of type '{0}' is not callable.", - Value_of_type_0_is_not_newable: "Value of type '{0}' is not newable.", - Value_of_type_0_is_not_indexable_by_type_1: "Value of type '{0}' is not indexable by type '{1}'.", - Operator_0_cannot_be_applied_to_types_1_and_2: "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - Operator_0_cannot_be_applied_to_types_1_and_2_3: "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}", - Cannot_convert_0_to_1: "Cannot convert '{0}' to '{1}'.", - Cannot_convert_0_to_1_NL_2: "Cannot convert '{0}' to '{1}':{NL}{2}", - Expected_var_class_interface_or_module: "Expected var, class, interface, or module.", - Operator_0_cannot_be_applied_to_type_1: "Operator '{0}' cannot be applied to type '{1}'.", - Getter_0_already_declared: "Getter '{0}' already declared.", - Setter_0_already_declared: "Setter '{0}' already declared.", - Exported_class_0_extends_private_class_1: "Exported class '{0}' extends private class '{1}'.", - Exported_class_0_implements_private_interface_1: "Exported class '{0}' implements private interface '{1}'.", - Exported_interface_0_extends_private_interface_1: "Exported interface '{0}' extends private interface '{1}'.", - Exported_class_0_extends_class_from_inaccessible_module_1: "Exported class '{0}' extends class from inaccessible module {1}.", - Exported_class_0_implements_interface_from_inaccessible_module_1: "Exported class '{0}' implements interface from inaccessible module {1}.", - Exported_interface_0_extends_interface_from_inaccessible_module_1: "Exported interface '{0}' extends interface from inaccessible module {1}.", - Public_static_property_0_of_exported_class_has_or_is_using_private_type_1: "Public static property '{0}' of exported class has or is using private type '{1}'.", - Public_property_0_of_exported_class_has_or_is_using_private_type_1: "Public property '{0}' of exported class has or is using private type '{1}'.", - Property_0_of_exported_interface_has_or_is_using_private_type_1: "Property '{0}' of exported interface has or is using private type '{1}'.", - Exported_variable_0_has_or_is_using_private_type_1: "Exported variable '{0}' has or is using private type '{1}'.", - Public_static_property_0_of_exported_class_is_using_inaccessible_module_1: "Public static property '{0}' of exported class is using inaccessible module {1}.", - Public_property_0_of_exported_class_is_using_inaccessible_module_1: "Public property '{0}' of exported class is using inaccessible module {1}.", - Property_0_of_exported_interface_is_using_inaccessible_module_1: "Property '{0}' of exported interface is using inaccessible module {1}.", - Exported_variable_0_is_using_inaccessible_module_1: "Exported variable '{0}' is using inaccessible module {1}.", - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.", - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.", - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.", - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "Parameter '{0}' of public method from exported class has or is using private type '{1}'.", - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "Parameter '{0}' of method from exported interface has or is using private type '{1}'.", - Parameter_0_of_exported_function_has_or_is_using_private_type_1: "Parameter '{0}' of exported function has or is using private type '{1}'.", - Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.", - Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.", - Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}", - Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.", - Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "Parameter '{0}' of public method from exported class is using inaccessible module {1}.", - Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "Parameter '{0}' of method from exported interface is using inaccessible module {1}.", - Parameter_0_of_exported_function_is_using_inaccessible_module_1: "Parameter '{0}' of exported function is using inaccessible module {1}.", - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public static property getter from exported class has or is using private type '{0}'.", - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0: "Return type of public property getter from exported class has or is using private type '{0}'.", - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of constructor signature from exported interface has or is using private type '{0}'.", - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of call signature from exported interface has or is using private type '{0}'.", - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0: "Return type of index signature from exported interface has or is using private type '{0}'.", - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public static method from exported class has or is using private type '{0}'.", - Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0: "Return type of public method from exported class has or is using private type '{0}'.", - Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0: "Return type of method from exported interface has or is using private type '{0}'.", - Return_type_of_exported_function_has_or_is_using_private_type_0: "Return type of exported function has or is using private type '{0}'.", - Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public static property getter from exported class is using inaccessible module {0}.", - Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0: "Return type of public property getter from exported class is using inaccessible module {0}.", - Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of constructor signature from exported interface is using inaccessible module {0}.", - Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of call signature from exported interface is using inaccessible module {0}.", - Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0: "Return type of index signature from exported interface is using inaccessible module {0}.", - Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public static method from exported class is using inaccessible module {0}.", - Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0: "Return type of public method from exported class is using inaccessible module {0}.", - Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0: "Return type of method from exported interface is using inaccessible module {0}.", - Return_type_of_exported_function_is_using_inaccessible_module_0: "Return type of exported function is using inaccessible module {0}.", - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - A_parameter_list_must_follow_a_generic_type_argument_list_expected: "A parameter list must follow a generic type argument list. '(' expected.", - Multiple_constructor_implementations_are_not_allowed: "Multiple constructor implementations are not allowed.", - Unable_to_resolve_external_module_0: "Unable to resolve external module '{0}'.", - Module_cannot_be_aliased_to_a_non_module_type: "Module cannot be aliased to a non-module type.", - A_class_may_only_extend_another_class: "A class may only extend another class.", - A_class_may_only_implement_another_class_or_interface: "A class may only implement another class or interface.", - An_interface_may_only_extend_another_class_or_interface: "An interface may only extend another class or interface.", - Unable_to_resolve_type: "Unable to resolve type.", - Unable_to_resolve_type_of_0: "Unable to resolve type of '{0}'.", - Unable_to_resolve_type_parameter_constraint: "Unable to resolve type parameter constraint.", - Type_parameter_constraint_cannot_be_a_primitive_type: "Type parameter constraint cannot be a primitive type.", - Supplied_parameters_do_not_match_any_signature_of_call_target: "Supplied parameters do not match any signature of call target.", - Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0: "Supplied parameters do not match any signature of call target:{NL}{0}", - Invalid_new_expression: "Invalid 'new' expression.", - Call_signatures_used_in_a_new_expression_must_have_a_void_return_type: "Call signatures used in a 'new' expression must have a 'void' return type.", - Could_not_select_overload_for_new_expression: "Could not select overload for 'new' expression.", - Type_0_does_not_satisfy_the_constraint_1_for_type_parameter_2: "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.", - Could_not_select_overload_for_call_expression: "Could not select overload for 'call' expression.", - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: "Cannot invoke an expression whose type lacks a call signature.", - Calls_to_super_are_only_valid_inside_a_class: "Calls to 'super' are only valid inside a class.", - Generic_type_0_requires_1_type_argument_s: "Generic type '{0}' requires {1} type argument(s).", - Type_of_array_literal_cannot_be_determined_Best_common_type_could_not_be_found_for_array_elements: "Type of array literal cannot be determined. Best common type could not be found for array elements.", - Could_not_find_enclosing_symbol_for_dotted_name_0: "Could not find enclosing symbol for dotted name '{0}'.", - The_property_0_does_not_exist_on_value_of_type_1: "The property '{0}' does not exist on value of type '{1}'.", - 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_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_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.", - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type: "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.", - Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: "Variable declarations of a 'for' statement cannot use a type annotation.", - Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: "Variable declarations of a 'for' statement must be of types 'string' or 'any'.", - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.", - 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_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}'.", - 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.", - Function_declared_a_non_void_return_type_but_has_no_return_expression: "Function declared a non-void return type, but has no return expression.", - Cannot_resolve_return_type_reference: "Cannot resolve return type reference.", - Constructors_cannot_have_a_return_type_of_void: "Constructors cannot have a return type of 'void'.", - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", - All_symbols_within_a_with_block_will_be_resolved_to_any: "All symbols within a with block will be resolved to 'any'.", - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: "Import declarations in an internal module cannot reference an external module.", - Class_0_declares_interface_1_but_does_not_implement_it_NL_2: "Class {0} declares interface {1} but does not implement it:{NL}{2}", - Class_0_declares_class_1_as_an_interface_but_does_not_implement_it_NL_2: "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}", - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: "The operand of an increment or decrement operator must be a variable, property or indexer.", - this_cannot_be_referenced_in_static_initializers_in_a_class_body: "'this' cannot be referenced in static initializers in a class body.", - Class_0_cannot_extend_class_1_NL_2: "Class '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_class_1_NL_2: "Interface '{0}' cannot extend class '{1}':{NL}{2}", - Interface_0_cannot_extend_interface_1_NL_2: "Interface '{0}' cannot extend interface '{1}':{NL}{2}", - Duplicate_overload_signature_for_0: "Duplicate overload signature for '{0}'.", - Duplicate_constructor_overload_signature: "Duplicate constructor overload signature.", - Duplicate_overload_call_signature: "Duplicate overload call signature.", - Duplicate_overload_construct_signature: "Duplicate overload construct signature.", - Overload_signature_is_not_compatible_with_function_definition: "Overload signature is not compatible with function definition.", - Overload_signature_is_not_compatible_with_function_definition_NL_0: "Overload signature is not compatible with function definition:{NL}{0}", - Overload_signatures_must_all_be_public_or_private: "Overload signatures must all be public or private.", - 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_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.", - Non_generic_functions_may_not_accept_type_arguments: "Non-generic functions may not accept type arguments.", - A_generic_type_may_not_reference_itself_with_a_wrapped_form_of_its_own_type_parameters: "A generic type may not reference itself with a wrapped form of its own type parameters.", - Rest_parameters_must_be_array_types: "Rest parameters must be array types.", - Overload_signature_implementation_cannot_use_specialized_type: "Overload signature implementation cannot use specialized type.", - 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_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_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.", - Could_not_find_symbol_0_in_module_1: "Could not find symbol '{0}' in module '{1}'.", - Unable_to_resolve_module_reference_0: "Unable to resolve module reference '{0}'.", - Could_not_find_module_0_in_module_1: "Could not find module '{0}' in module '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1: "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.", - Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1: "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.", - 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_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}", - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", - Ambient_external_module_declaration_cannot_be_reopened: "Ambient external module declaration cannot be reopened.", - All_declarations_of_merged_declaration_0_must_be_exported_or_not_exported: "All declarations of merged declaration '{0}' must be exported or not exported.", - super_cannot_be_referenced_in_constructor_arguments: "'super' cannot be referenced in constructor arguments.", - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: "Return type of constructor signature must be assignable to the instance type of the class.", - Ambient_external_module_declaration_must_be_defined_in_global_context: "Ambient external module declaration must be defined in global context.", - Ambient_external_module_declaration_cannot_specify_relative_module_name: "Ambient external module declaration cannot specify relative module name.", - Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.", - Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions: "Could not find the best common type of types of all return statement expressions.", - Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set: "Import declaration cannot refer to external module reference when --noResolve option is set.", - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", - continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: "'continue' statement can only be used within an enclosing iteration statement.", - break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: "'break' statement can only be used within an enclosing iteration or switch statement.", - Jump_target_not_found: "Jump target not found.", - Jump_target_cannot_cross_function_boundary: "Jump target cannot cross function boundary.", - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: "Expression resolves to '_super' that compiler uses to capture base class reference.", - TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.", - TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_function_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported function has or is using private type '{1}'.", - TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}", - TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.", - TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.", - TypeParameter_0_of_exported_function_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported function is using inaccessible module {1}.", - TypeParameter_0_of_exported_class_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported class has or is using private type '{1}'.", - TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1: "TypeParameter '{0}' of exported interface has or is using private type '{1}'.", - TypeParameter_0_of_exported_class_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported class is using inaccessible module {1}.", - TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1: "TypeParameter '{0}' of exported interface is using inaccessible module {1}.", - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.", - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", - 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}", - Property_0_defined_as_private_in_type_1_is_defined_as_public_in_type_2: "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.", - Property_0_defined_as_public_in_type_1_is_defined_as_private_in_type_2: "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.", - Types_0_and_1_define_property_2_as_private: "Types '{0}' and '{1}' define property '{2}' as private.", - Call_signatures_of_types_0_and_1_are_incompatible: "Call signatures of types '{0}' and '{1}' are incompatible.", - Call_signatures_of_types_0_and_1_are_incompatible_NL_2: "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_call_signature_but_type_1_lacks_one: "Type '{0}' requires a call signature, but type '{1}' lacks one.", - Construct_signatures_of_types_0_and_1_are_incompatible: "Construct signatures of types '{0}' and '{1}' are incompatible.", - Construct_signatures_of_types_0_and_1_are_incompatible_NL_2: "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Type_0_requires_a_construct_signature_but_type_1_lacks_one: "Type '{0}' requires a construct signature, but type '{1}' lacks one.", - Index_signatures_of_types_0_and_1_are_incompatible: "Index signatures of types '{0}' and '{1}' are incompatible.", - Index_signatures_of_types_0_and_1_are_incompatible_NL_2: "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}", - Call_signature_expects_0_or_fewer_parameters: "Call signature expects {0} or fewer parameters.", - Could_not_apply_type_0_to_argument_1_which_is_of_type_2: "Could not apply type '{0}' to argument {1} which is of type '{2}'.", - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - Types_of_static_property_0_of_class_1_and_class_2_are_incompatible: "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.", - 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.", - 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_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_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.", - Could_not_find_file_0: "Could not find file: '{0}'.", - A_file_cannot_have_a_reference_to_itself: "A file cannot have a reference to itself.", - Cannot_resolve_referenced_file_0: "Cannot resolve referenced file: '{0}'.", - Cannot_find_the_common_subdirectory_path_for_the_input_files: "Cannot find the common subdirectory path for the input files.", - Emit_Error_0: "Emit Error: {0}.", - Cannot_read_file_0_1: "Cannot read file '{0}': {1}", - Unsupported_file_encoding: "Unsupported file encoding.", - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: "Locale must be of the form or -. For example '{0}' or '{1}'.", - Unsupported_locale_0: "Unsupported locale: '{0}'.", - Execution_Failed_NL: "Execution Failed.{NL}", - Invalid_call_to_up: "Invalid call to 'up'", - Invalid_call_to_down: "Invalid call to 'down'", - Base64_value_0_finished_with_a_continuation_bit: "Base64 value '{0}' finished with a continuation bit.", - Unknown_option_0: "Unknown option '{0}'", - Expected_0_arguments_to_message_got_1_instead: "Expected {0} arguments to message, got {1} instead.", - Expected_the_message_0_to_have_1_arguments_but_it_had_2: "Expected the message '{0}' to have {1} arguments, but it had {2}", - Could_not_delete_file_0: "Could not delete file '{0}'", - Could_not_create_directory_0: "Could not create directory '{0}'", - Error_while_executing_file_0: "Error while executing file '{0}': ", - Cannot_compile_external_modules_unless_the_module_flag_is_provided: "Cannot compile external modules unless the '--module' flag is provided.", - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option mapRoot cannot be specified without specifying sourcemap option.", - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Option sourceRoot cannot be specified without specifying sourcemap option.", - Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.", - Option_0_specified_without_1: "Option '{0}' specified without '{1}'", - codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.", - Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.", - Generates_corresponding_0_file: "Generates corresponding {0} file.", - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.", - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.", - Watch_input_files: "Watch input files.", - Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.", - Do_not_emit_comments_to_output: "Do not emit comments to output.", - Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.", - Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'", - Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'", - Print_this_message: "Print this message.", - Print_the_compiler_s_version_0: "Print the compiler's version: {0}", - Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.", - Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'", - Syntax_0: "Syntax: {0}", - options: "options", - file1: "file", - Examples: "Examples:", - Options: "Options:", - Insert_command_line_options_and_files_from_a_file: "Insert command line options and files from a file.", - Version_0: "Version {0}", - Use_the_0_flag_to_see_options: "Use the '{0}' flag to see options.", - NL_Recompiling_0: "{NL}Recompiling ({0}):", - STRING: "STRING", - KIND: "KIND", - file2: "FILE", - VERSION: "VERSION", - LOCATION: "LOCATION", - 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})", - Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.", - Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.", - Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.", - Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.", - Member_0_of_object_type_implicitly_has_an_any_type: "Member '{0}' of object type implicitly has an 'any' type.", - new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type: "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.", - _0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.", - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.", - Parameter_0_of_lambda_function_implicitly_has_an_any_type: "Parameter '{0}' of lambda function implicitly has an 'any' type.", - 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.", - 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; -(function (TypeScript) { - var ArrayUtilities = (function () { - function ArrayUtilities() { - } - ArrayUtilities.isArray = function (value) { - return Object.prototype.toString.apply(value, []) === '[object Array]'; - }; - - ArrayUtilities.sequenceEquals = function (array1, array2, equals) { - if (array1 === array2) { - return true; - } - - if (array1 === null || array2 === null) { - return false; - } - - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0, n = array1.length; i < n; i++) { - if (!equals(array1[i], array2[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.contains = function (array, value) { - for (var i = 0; i < array.length; i++) { - if (array[i] === value) { - return true; - } - } - - return false; - }; - - ArrayUtilities.groupBy = function (array, func) { - var result = {}; - - for (var i = 0, n = array.length; i < n; i++) { - var v = array[i]; - var k = func(v); - - var list = result[k] || []; - list.push(v); - result[k] = list; - } - - return result; - }; - - ArrayUtilities.distinct = function (array, equalsFn) { - var result = []; - - for (var i = 0, n = array.length; i < n; i++) { - var current = array[i]; - for (var j = 0; j < result.length; j++) { - if (equalsFn(result[j], current)) { - break; - } - } - - if (j === result.length) { - result.push(current); - } - } - - return result; - }; - - ArrayUtilities.min = function (array, func) { - var min = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next < min) { - min = next; - } - } - - return min; - }; - - ArrayUtilities.max = function (array, func) { - var max = func(array[0]); - - for (var i = 1; i < array.length; i++) { - var next = func(array[i]); - if (next > max) { - max = next; - } - } - - return max; - }; - - ArrayUtilities.last = function (array) { - if (array.length === 0) { - throw TypeScript.Errors.argumentOutOfRange('array'); - } - - return array[array.length - 1]; - }; - - ArrayUtilities.lastOrDefault = function (array, predicate) { - for (var i = array.length - 1; i >= 0; i--) { - var v = array[i]; - if (predicate(v, i)) { - return v; - } - } - - return null; - }; - - ArrayUtilities.firstOrDefault = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (func(value, i)) { - return value; - } - } - - return null; - }; - - ArrayUtilities.first = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - var value = array[i]; - if (!func || func(value, i)) { - return value; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ArrayUtilities.sum = function (array, func) { - var result = 0; - - for (var i = 0, n = array.length; i < n; i++) { - result += func(array[i]); - } - - return result; - }; - - ArrayUtilities.select = function (values, func) { - var result = new Array(values.length); - - for (var i = 0; i < values.length; i++) { - result[i] = func(values[i]); - } - - return result; - }; - - ArrayUtilities.where = function (values, func) { - var result = new Array(); - - for (var i = 0; i < values.length; i++) { - if (func(values[i])) { - result.push(values[i]); - } - } - - return result; - }; - - ArrayUtilities.any = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (func(array[i])) { - return true; - } - } - - return false; - }; - - ArrayUtilities.all = function (array, func) { - for (var i = 0, n = array.length; i < n; i++) { - if (!func(array[i])) { - return false; - } - } - - return true; - }; - - ArrayUtilities.binarySearch = function (array, value) { - var low = 0; - var high = array.length - 1; - - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - - if (midValue === value) { - return middle; - } else if (midValue > value) { - high = middle - 1; - } else { - low = middle + 1; - } - } - - return ~low; - }; - - ArrayUtilities.createArray = function (length, defaultValue) { - var result = new Array(length); - for (var i = 0; i < length; i++) { - result[i] = defaultValue; - } - - return result; - }; - - ArrayUtilities.grow = function (array, length, defaultValue) { - var count = length - array.length; - for (var i = 0; i < count; i++) { - array.push(defaultValue); - } - }; - - ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; - } - }; - - ArrayUtilities.indexOf = function (array, predicate) { - for (var i = 0, n = array.length; i < n; i++) { - if (predicate(array[i])) { - return i; - } - } - - return -1; - }; - return ArrayUtilities; - })(); - TypeScript.ArrayUtilities = ArrayUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitVector) { - var pool = []; - var Constants; - (function (Constants) { - Constants[Constants["MaxBitsPerEncodedNumber"] = 30] = "MaxBitsPerEncodedNumber"; - Constants[Constants["BitsPerEncodedBiStateValue"] = 1] = "BitsPerEncodedBiStateValue"; - - Constants[Constants["BitsPerEncodedTriStateValue"] = 2] = "BitsPerEncodedTriStateValue"; - - Constants[Constants["BiStateEncodedTrue"] = 1] = "BiStateEncodedTrue"; - Constants[Constants["BiStateClearBitsMask"] = 1] = "BiStateClearBitsMask"; - - Constants[Constants["TriStateEncodedFalse"] = 1] = "TriStateEncodedFalse"; - Constants[Constants["TriStateEncodedTrue"] = 2] = "TriStateEncodedTrue"; - Constants[Constants["TriStateClearBitsMask"] = 3] = "TriStateClearBitsMask"; - })(Constants || (Constants = {})); - - var BitVectorImpl = (function () { - function BitVectorImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.bits = []; - } - BitVectorImpl.prototype.computeTriStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeBiStateArrayIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index / encodedValuesPerNumber) >>> 0; - }; - - BitVectorImpl.prototype.computeTriStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 2 /* BitsPerEncodedTriStateValue */; - - return (index % encodedValuesPerNumber) * 2 /* BitsPerEncodedTriStateValue */; - }; - - BitVectorImpl.prototype.computeBiStateEncodedValueIndex = function (index) { - var encodedValuesPerNumber = 30 /* MaxBitsPerEncodedNumber */ / 1 /* BitsPerEncodedBiStateValue */; - - return (index % encodedValuesPerNumber) * 1 /* BitsPerEncodedBiStateValue */; - }; - - BitVectorImpl.prototype.valueAt = function (index) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return undefined; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - if (encoded & (2 /* TriStateEncodedTrue */ << bitIndex)) { - return true; - } else if (encoded & (1 /* TriStateEncodedFalse */ << bitIndex)) { - return false; - } else { - return undefined; - } - } else { - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - return false; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - if (encoded & (1 /* BiStateEncodedTrue */ << bitIndex)) { - return true; - } else { - return false; - } - } - }; - - BitVectorImpl.prototype.setValueAt = function (index, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - if (this.allowUndefinedValues) { - TypeScript.Debug.assert(value === true || value === false || value === undefined, "value must only be true, false or undefined."); - - var arrayIndex = this.computeTriStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === undefined) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeTriStateEncodedValueIndex(index); - - var clearMask = ~(3 /* TriStateClearBitsMask */ << bitIndex); - encoded = encoded & clearMask; - - if (value === true) { - encoded = encoded | (2 /* TriStateEncodedTrue */ << bitIndex); - } else if (value === false) { - encoded = encoded | (1 /* TriStateEncodedFalse */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } else { - TypeScript.Debug.assert(value === true || value === false, "value must only be true or false."); - - var arrayIndex = this.computeBiStateArrayIndex(index); - var encoded = this.bits[arrayIndex]; - if (encoded === undefined) { - if (value === false) { - return; - } - - encoded = 0; - } - - var bitIndex = this.computeBiStateEncodedValueIndex(index); - - encoded = encoded & ~(1 /* BiStateClearBitsMask */ << bitIndex); - - if (value) { - encoded = encoded | (1 /* BiStateEncodedTrue */ << bitIndex); - } - - this.bits[arrayIndex] = encoded; - } - }; - - BitVectorImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - this.bits.length = 0; - pool.push(this); - }; - return BitVectorImpl; - })(); - - function getBitVector(allowUndefinedValues) { - if (pool.length === 0) { - return new BitVectorImpl(allowUndefinedValues); - } - - var vector = pool.pop(); - vector.isReleased = false; - vector.allowUndefinedValues = allowUndefinedValues; - - return vector; - } - BitVector.getBitVector = getBitVector; - })(TypeScript.BitVector || (TypeScript.BitVector = {})); - var BitVector = TypeScript.BitVector; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (BitMatrix) { - var pool = []; - - var BitMatrixImpl = (function () { - function BitMatrixImpl(allowUndefinedValues) { - this.allowUndefinedValues = allowUndefinedValues; - this.isReleased = false; - this.vectors = []; - } - BitMatrixImpl.prototype.valueAt = function (x, y) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - return this.allowUndefinedValues ? undefined : false; - } - - return vector.valueAt(y); - }; - - BitMatrixImpl.prototype.setValueAt = function (x, y, value) { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - var vector = this.vectors[x]; - if (!vector) { - if (value === undefined) { - return; - } - - vector = TypeScript.BitVector.getBitVector(this.allowUndefinedValues); - this.vectors[x] = vector; - } - - vector.setValueAt(y, value); - }; - - BitMatrixImpl.prototype.release = function () { - TypeScript.Debug.assert(!this.isReleased, "Should not use a released bitvector"); - this.isReleased = true; - - for (var name in this.vectors) { - if (this.vectors.hasOwnProperty(name)) { - var vector = this.vectors[name]; - vector.release(); - } - } - - this.vectors.length = 0; - pool.push(this); - }; - return BitMatrixImpl; - })(); - - function getBitMatrix(allowUndefinedValues) { - if (pool.length === 0) { - return new BitMatrixImpl(allowUndefinedValues); - } - - var matrix = pool.pop(); - matrix.isReleased = false; - matrix.allowUndefinedValues = allowUndefinedValues; - - return matrix; - } - BitMatrix.getBitMatrix = getBitMatrix; - })(TypeScript.BitMatrix || (TypeScript.BitMatrix = {})); - var BitMatrix = TypeScript.BitMatrix; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Constants) { - Constants[Constants["Max31BitInteger"] = 1073741823] = "Max31BitInteger"; - Constants[Constants["Min31BitInteger"] = -1073741824] = "Min31BitInteger"; - })(TypeScript.Constants || (TypeScript.Constants = {})); - var Constants = TypeScript.Constants; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(TypeScript.AssertionLevel || (TypeScript.AssertionLevel = {})); - var AssertionLevel = TypeScript.AssertionLevel; - - var Debug = (function () { - function Debug() { - } - Debug.shouldAssert = function (level) { - return this.currentAssertionLevel >= level; - }; - - Debug.assert = function (expression, message, verboseDebugInfo) { - if (typeof message === "undefined") { message = ""; } - if (typeof verboseDebugInfo === "undefined") { verboseDebugInfo = null; } - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); - } - - throw new Error("Debug Failure. False expression: " + message + verboseDebugString); - } - }; - - Debug.fail = function (message) { - Debug.assert(false, message); - }; - Debug.currentAssertionLevel = 0 /* None */; - return Debug; - })(); - 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 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(); - result.length = this.length(); - - result.diagnosticCode = this._diagnosticKey; - - var _arguments = this.arguments(); - if (_arguments && _arguments.length > 0) { - result.arguments = _arguments; - } - - return result; - }; - - Diagnostic.prototype.diagnosticKey = function () { - return this._diagnosticKey; - }; - - Diagnostic.prototype.arguments = function () { - return this._arguments; - }; - - Diagnostic.prototype.text = function () { - return TypeScript.getLocalizedText(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.message = function () { - return TypeScript.getDiagnosticMessage(this._diagnosticKey, this._arguments); - }; - - Diagnostic.prototype.additionalLocations = function () { - return this._additionalLocations || []; - }; - - Diagnostic.equals = function (diagnostic1, diagnostic2) { - return Location.equals(diagnostic1, diagnostic2) && diagnostic1._diagnosticKey === diagnostic2._diagnosticKey && TypeScript.ArrayUtilities.sequenceEquals(diagnostic1._arguments, diagnostic2._arguments, function (v1, v2) { - return v1 === v2; - }); - }; - - Diagnostic.prototype.info = function () { - return getDiagnosticInfoFromKey(this.diagnosticKey()); - }; - return Diagnostic; - })(Location); - TypeScript.Diagnostic = Diagnostic; - - function newLine() { - return TypeScript.Environment ? TypeScript.Environment.newLine : "\r\n"; - } - TypeScript.newLine = newLine; - - function getLargestIndex(diagnostic) { - var largest = -1; - var regex = /\{(\d+)\}/g; - - var match; - while (match = regex.exec(diagnostic)) { - var val = parseInt(match[1]); - if (!isNaN(val) && val > largest) { - largest = val; - } - } - - return largest; - } - - function getDiagnosticInfoFromKey(diagnosticKey) { - var result = TypeScript.diagnosticInformationMap[diagnosticKey]; - TypeScript.Debug.assert(result); - return result; - } - - function getLocalizedText(diagnosticKey, args) { - if (TypeScript.LocalizedDiagnosticMessages) { - } - - var diagnosticMessageText = TypeScript.LocalizedDiagnosticMessages ? TypeScript.LocalizedDiagnosticMessages[diagnosticKey] : diagnosticKey; - TypeScript.Debug.assert(diagnosticMessageText !== undefined && diagnosticMessageText !== null); - - var actualCount = args ? args.length : 0; - - var expectedCount = 1 + getLargestIndex(diagnosticKey); - - if (expectedCount !== actualCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_0_arguments_to_message_got_1_instead, [expectedCount, actualCount])); - } - - var valueCount = 1 + getLargestIndex(diagnosticMessageText); - if (valueCount !== expectedCount) { - throw new Error(getLocalizedText(TypeScript.DiagnosticCode.Expected_the_message_0_to_have_1_arguments_but_it_had_2, [diagnosticMessageText, expectedCount, valueCount])); - } - - diagnosticMessageText = diagnosticMessageText.replace(/{(\d+)}/g, function (match, num) { - return typeof args[num] !== 'undefined' ? args[num] : match; - }); - - diagnosticMessageText = diagnosticMessageText.replace(/{(NL)}/g, function (match) { - return TypeScript.newLine(); - }); - - return diagnosticMessageText; - } - TypeScript.getLocalizedText = getLocalizedText; - - function getDiagnosticMessage(diagnosticKey, args) { - var diagnostic = getDiagnosticInfoFromKey(diagnosticKey); - var diagnosticMessageText = getLocalizedText(diagnosticKey, args); - - var message; - if (diagnostic.category === 1 /* Error */) { - message = getLocalizedText(TypeScript.DiagnosticCode.error_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else if (diagnostic.category === 0 /* Warning */) { - message = getLocalizedText(TypeScript.DiagnosticCode.warning_TS_0_1, [diagnostic.code, diagnosticMessageText]); - } else { - message = diagnosticMessageText; - } - - return message; - } - TypeScript.getDiagnosticMessage = getDiagnosticMessage; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Errors = (function () { - function Errors() { - } - Errors.argument = function (argument, message) { - return new Error("Invalid argument: " + argument + ". " + message); - }; - - Errors.argumentOutOfRange = function (argument) { - return new Error("Argument out of range: " + argument); - }; - - Errors.argumentNull = function (argument) { - return new Error("Argument null: " + argument); - }; - - Errors.abstract = function () { - return new Error("Operation not implemented properly by subclass."); - }; - - Errors.notYetImplemented = function () { - return new Error("Not yet implemented."); - }; - - Errors.invalidOperation = function (message) { - return new Error("Invalid operation: " + message); - }; - return Errors; - })(); - TypeScript.Errors = Errors; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Hash = (function () { - function Hash() { - } - Hash.computeFnv1aCharArrayHashCode = function (text, start, len) { - var hashCode = Hash.FNV_BASE; - var end = start + len; - - for (var i = start; i < end; i++) { - hashCode = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(hashCode ^ text[i], Hash.FNV_PRIME); - } - - return hashCode; - }; - - Hash.computeSimple31BitCharArrayHashCode = function (key, start, len) { - var hash = 0; - - for (var i = 0; i < len; i++) { - var ch = key[start + i]; - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeSimple31BitStringHashCode = function (key) { - var hash = 0; - - var start = 0; - var len = key.length; - - for (var i = 0; i < len; i++) { - var ch = key.charCodeAt(start + i); - - hash = ((((hash << 5) - hash) | 0) + ch) | 0; - } - - return hash & 0x7FFFFFFF; - }; - - Hash.computeMurmur2StringHashCode = function (key, seed) { - var m = 0x5bd1e995; - var r = 24; - - var numberOfCharsLeft = key.length; - var h = Math.abs(seed ^ numberOfCharsLeft); - - var index = 0; - while (numberOfCharsLeft >= 2) { - var c1 = key.charCodeAt(index); - var c2 = key.charCodeAt(index + 1); - - var k = Math.abs(c1 | (c2 << 16)); - - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - k ^= k >> r; - k = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(k, m); - - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= k; - - index += 2; - numberOfCharsLeft -= 2; - } - - if (numberOfCharsLeft === 1) { - h ^= key.charCodeAt(index); - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - } - - h ^= h >> 13; - h = TypeScript.IntegerUtilities.integerMultiplyLow32Bits(h, m); - h ^= h >> 15; - - return h; - }; - - Hash.getPrime = function (min) { - for (var i = 0; i < Hash.primes.length; i++) { - var num = Hash.primes[i]; - if (num >= min) { - return num; - } - } - - throw TypeScript.Errors.notYetImplemented(); - }; - - Hash.expandPrime = function (oldSize) { - var num = oldSize << 1; - if (num > 2146435069 && 2146435069 > oldSize) { - return 2146435069; - } - return Hash.getPrime(num); - }; - - Hash.combine = function (value, currentHash) { - return (((currentHash << 5) + currentHash) + value) & 0x7FFFFFFF; - }; - Hash.FNV_BASE = 2166136261; - Hash.FNV_PRIME = 16777619; - - Hash.primes = [ - 3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, - 631, 761, 919, 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, - 10103, 12143, 14591, 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, - 90523, 108631, 130363, 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, - 672827, 807403, 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, - 4166287, 4999559, 5999471, 7199369]; - return Hash; - })(); - TypeScript.Hash = Hash; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultHashTableCapacity = 1024; - - var HashTableEntry = (function () { - function HashTableEntry(Key, Value, HashCode, Next) { - this.Key = Key; - this.Value = Value; - this.HashCode = HashCode; - this.Next = Next; - } - return HashTableEntry; - })(); - - var HashTable = (function () { - function HashTable(capacity, hash) { - this.hash = hash; - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - HashTable.prototype.set = function (key, value) { - this.addOrSet(key, value, false); - }; - - HashTable.prototype.add = function (key, value) { - this.addOrSet(key, value, true); - }; - - HashTable.prototype.containsKey = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - return entry !== null; - }; - - HashTable.prototype.get = function (key) { - var hashCode = this.computeHashCode(key); - var entry = this.findEntry(key, hashCode); - - return entry === null ? null : entry.Value; - }; - - HashTable.prototype.computeHashCode = function (key) { - var hashCode = this.hash === null ? key.hashCode : this.hash(key); - - hashCode = hashCode & 0x7FFFFFFF; - TypeScript.Debug.assert(hashCode >= 0); - - return hashCode; - }; - - HashTable.prototype.addOrSet = function (key, value, throwOnExistingEntry) { - var hashCode = this.computeHashCode(key); - - var entry = this.findEntry(key, hashCode); - if (entry !== null) { - if (throwOnExistingEntry) { - throw TypeScript.Errors.argument('key', "Key was already in table."); - } - - entry.Key = key; - entry.Value = value; - return; - } - - return this.addEntry(key, value, hashCode); - }; - - HashTable.prototype.findEntry = function (key, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && key === e.Key) { - return e; - } - } - - return null; - }; - - HashTable.prototype.addEntry = function (key, value, hashCode) { - var index = hashCode % this.entries.length; - - var e = new HashTableEntry(key, value, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count >= (this.entries.length / 2)) { - this.grow(); - } - - this.count++; - return e.Key; - }; - - HashTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - return HashTable; - })(); - Collections.HashTable = HashTable; - - function createHashTable(capacity, hash) { - if (typeof capacity === "undefined") { capacity = Collections.DefaultHashTableCapacity; } - if (typeof hash === "undefined") { hash = null; } - return new HashTable(capacity, hash); - } - Collections.createHashTable = createHashTable; - - var currentHashCode = 1; - function identityHashCode(value) { - if (value.__hash === undefined) { - value.__hash = currentHashCode; - currentHashCode++; - } - - return value.__hash; - } - Collections.identityHashCode = identityHashCode; - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - TypeScript.nodeMakeDirectoryTime = 0; - TypeScript.nodeCreateBufferTime = 0; - TypeScript.nodeWriteFileSyncTime = 0; - - (function (ByteOrderMark) { - ByteOrderMark[ByteOrderMark["None"] = 0] = "None"; - ByteOrderMark[ByteOrderMark["Utf8"] = 1] = "Utf8"; - ByteOrderMark[ByteOrderMark["Utf16BigEndian"] = 2] = "Utf16BigEndian"; - ByteOrderMark[ByteOrderMark["Utf16LittleEndian"] = 3] = "Utf16LittleEndian"; - })(TypeScript.ByteOrderMark || (TypeScript.ByteOrderMark = {})); - var ByteOrderMark = TypeScript.ByteOrderMark; - - var FileInformation = (function () { - function FileInformation(contents, byteOrderMark) { - this.contents = contents; - this.byteOrderMark = byteOrderMark; - } - return FileInformation; - })(); - TypeScript.FileInformation = FileInformation; - - TypeScript.Environment = (function () { - function getWindowsScriptHostEnvironment() { - try { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - } catch (e) { - return null; - } - - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - newLine: "\r\n", - currentDirectory: function () { - return WScript.CreateObject("WScript.Shell").CurrentDirectory; - }, - supportsCodePage: function () { - return WScript.ReadFile; - }, - readFile: function (path, codepage) { - try { - if (codepage !== null && this.supportsCodePage()) { - try { - var contents = WScript.ReadFile(path, codepage); - return new FileInformation(contents, 0 /* None */); - } catch (e) { - } - } - - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - - streamObj.Charset = 'x-ansi'; - - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - - streamObj.Position = 0; - - var byteOrderMark = 0 /* None */; - - if (bomChar.charCodeAt(0) === 0xFE && bomChar.charCodeAt(1) === 0xFF) { - streamObj.Charset = 'unicode'; - byteOrderMark = 2 /* Utf16BigEndian */; - } else if (bomChar.charCodeAt(0) === 0xFF && bomChar.charCodeAt(1) === 0xFE) { - streamObj.Charset = 'unicode'; - byteOrderMark = 3 /* Utf16LittleEndian */; - } else if (bomChar.charCodeAt(0) === 0xEF && bomChar.charCodeAt(1) === 0xBB) { - streamObj.Charset = 'utf-8'; - byteOrderMark = 1 /* Utf8 */; - } else { - streamObj.Charset = 'utf-8'; - } - - var contents = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return new FileInformation(contents, byteOrderMark); - } catch (err) { - var message; - if (err.number === -2147024809) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unsupported_file_encoding, null); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Cannot_read_file_0_1, [path, err.message]); - } - - throw new Error(message); - } - }, - writeFile: function (path, contents, writeByteOrderMark) { - var textStream = getStreamObject(); - textStream.Charset = 'utf-8'; - textStream.Open(); - textStream.WriteText(contents, 0); - - if (!writeByteOrderMark) { - textStream.Position = 3; - } else { - textStream.Position = 0; - } - - var fileStream = getStreamObject(); - fileStream.Type = 1; - fileStream.Open(); - - textStream.CopyTo(fileStream); - - fileStream.Flush(); - fileStream.SaveToFile(path, 2); - fileStream.Close(); - - textStream.Flush(); - textStream.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - deleteFile: function (path) { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - listFiles: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - arguments: args, - standardOut: WScript.StdOut - }; - } - ; - - function getNodeEnvironment() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - var _os = require('os'); - - return { - newLine: _os.EOL, - currentDirectory: function () { - return process.cwd(); - }, - supportsCodePage: function () { - return false; - }, - readFile: function (file, codepage) { - if (codepage !== null) { - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.codepage_option_not_supported_on_current_platform, null)); - } - - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] === 0xFF) { - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return new FileInformation(buffer.toString("ucs2", 2), 2 /* Utf16BigEndian */); - } - break; - case 0xFF: - if (buffer[1] === 0xFE) { - return new FileInformation(buffer.toString("ucs2", 2), 3 /* Utf16LittleEndian */); - } - break; - case 0xEF: - if (buffer[1] === 0xBB) { - return new FileInformation(buffer.toString("utf8", 3), 1 /* Utf8 */); - } - } - - return new FileInformation(buffer.toString("utf8", 0), 0 /* None */); - }, - writeFile: function (path, contents, writeByteOrderMark) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - throw "\"" + path + "\" exists but isn't a directory."; - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 509); - } - } - var start = new Date().getTime(); - mkdirRecursiveSync(_path.dirname(path)); - TypeScript.nodeMakeDirectoryTime += new Date().getTime() - start; - - if (writeByteOrderMark) { - contents = '\uFEFF' + contents; - } - - var start = new Date().getTime(); - - var chunkLength = 4 * 1024; - var fileDescriptor = _fs.openSync(path, "w"); - try { - for (var index = 0; index < contents.length; index += chunkLength) { - var bufferStart = new Date().getTime(); - var buffer = new Buffer(contents.substr(index, chunkLength), "utf8"); - TypeScript.nodeCreateBufferTime += new Date().getTime() - bufferStart; - - _fs.writeSync(fileDescriptor, buffer, 0, buffer.length, null); - } - } finally { - _fs.closeSync(fileDescriptor); - } - - TypeScript.nodeWriteFileSyncTime += new Date().getTime() - start; - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - listFiles: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "\\" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "\\" + files[i])); - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "\\" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path); - }, - arguments: process.argv.slice(2), - standardOut: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - } - }; - } - ; - - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWindowsScriptHostEnvironment(); - } else if (typeof module !== 'undefined' && module.exports) { - return getNodeEnvironment(); - } else { - return null; - } - })(); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (IntegerUtilities) { - function integerDivide(numerator, denominator) { - return (numerator / denominator) >> 0; - } - IntegerUtilities.integerDivide = integerDivide; - - function integerMultiplyLow32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultLow32 = (((n1 & 0xffff0000) * n2) >>> 0) + (((n1 & 0x0000ffff) * n2) >>> 0) >>> 0; - return resultLow32; - } - IntegerUtilities.integerMultiplyLow32Bits = integerMultiplyLow32Bits; - - function integerMultiplyHigh32Bits(n1, n2) { - var n1Low16 = n1 & 0x0000ffff; - var n1High16 = n1 >>> 16; - - var n2Low16 = n2 & 0x0000ffff; - var n2High16 = n2 >>> 16; - - var resultHigh32 = n1High16 * n2High16 + ((((n1Low16 * n2Low16) >>> 17) + n1Low16 * n2High16) >>> 15); - return resultHigh32; - } - IntegerUtilities.integerMultiplyHigh32Bits = integerMultiplyHigh32Bits; - - function isInteger(text) { - return /^[0-9]+$/.test(text); - } - IntegerUtilities.isInteger = isInteger; - - function isHexInteger(text) { - return /^0(x|X)[0-9a-fA-F]+$/.test(text); - } - IntegerUtilities.isHexInteger = isHexInteger; - })(TypeScript.IntegerUtilities || (TypeScript.IntegerUtilities = {})); - var IntegerUtilities = TypeScript.IntegerUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineMap = (function () { - function LineMap(_computeLineStarts, length) { - this._computeLineStarts = _computeLineStarts; - this.length = length; - this._lineStarts = null; - } - LineMap.prototype.toJSON = function (key) { - return { lineStarts: this.lineStarts(), length: this.length }; - }; - - LineMap.prototype.equals = function (other) { - return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { - return v1 === v2; - }); - }; - - LineMap.prototype.lineStarts = function () { - if (this._lineStarts === null) { - this._lineStarts = this._computeLineStarts(); - } - - return this._lineStarts; - }; - - LineMap.prototype.lineCount = function () { - return this.lineStarts().length; - }; - - LineMap.prototype.getPosition = function (line, character) { - return this.lineStarts()[line] + character; - }; - - LineMap.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this.lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - LineMap.prototype.getLineStartPosition = function (lineNumber) { - return this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.fillLineAndCharacterFromPosition = function (position, lineAndCharacter) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - lineAndCharacter.line = lineNumber; - lineAndCharacter.character = position - this.lineStarts()[lineNumber]; - }; - - LineMap.prototype.getLineAndCharacterFromPosition = function (position) { - if (position < 0 || position > this.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this.lineStarts()[lineNumber]); - }; - LineMap.empty = new LineMap(function () { - return [0]; - }, 0); - return LineMap; - })(); - TypeScript.LineMap = LineMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var LineAndCharacter = (function () { - function LineAndCharacter(line, character) { - this._line = 0; - this._character = 0; - if (line < 0) { - throw TypeScript.Errors.argumentOutOfRange("line"); - } - - if (character < 0) { - throw TypeScript.Errors.argumentOutOfRange("character"); - } - - this._line = line; - this._character = character; - } - LineAndCharacter.prototype.line = function () { - return this._line; - }; - - LineAndCharacter.prototype.character = function () { - return this._character; - }; - return LineAndCharacter; - })(); - TypeScript.LineAndCharacter = LineAndCharacter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MathPrototype = (function () { - function MathPrototype() { - } - MathPrototype.max = function (a, b) { - return a >= b ? a : b; - }; - - MathPrototype.min = function (a, b) { - return a <= b ? a : b; - }; - return MathPrototype; - })(); - TypeScript.MathPrototype = MathPrototype; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Collections) { - Collections.DefaultStringTableCapacity = 256; - - var StringTableEntry = (function () { - function StringTableEntry(Text, HashCode, Next) { - this.Text = Text; - this.HashCode = HashCode; - this.Next = Next; - } - return StringTableEntry; - })(); - - var StringTable = (function () { - function StringTable(capacity) { - this.count = 0; - var size = TypeScript.Hash.getPrime(capacity); - this.entries = TypeScript.ArrayUtilities.createArray(size, null); - } - StringTable.prototype.addCharArray = function (key, start, len) { - var hashCode = TypeScript.Hash.computeSimple31BitCharArrayHashCode(key, start, len) & 0x7FFFFFFF; - - var entry = this.findCharArrayEntry(key, start, len, hashCode); - if (entry !== null) { - return entry.Text; - } - - var slice = key.slice(start, start + len); - return this.addEntry(TypeScript.StringUtilities.fromCharCodeArray(slice), hashCode); - }; - - StringTable.prototype.findCharArrayEntry = function (key, start, len, hashCode) { - for (var e = this.entries[hashCode % this.entries.length]; e !== null; e = e.Next) { - if (e.HashCode === hashCode && StringTable.textCharArrayEquals(e.Text, key, start, len)) { - return e; - } - } - - return null; - }; - - StringTable.prototype.addEntry = function (text, hashCode) { - var index = hashCode % this.entries.length; - - var e = new StringTableEntry(text, hashCode, this.entries[index]); - - this.entries[index] = e; - - if (this.count === this.entries.length) { - this.grow(); - } - - this.count++; - return e.Text; - }; - - StringTable.prototype.grow = function () { - var newSize = TypeScript.Hash.expandPrime(this.entries.length); - - var oldEntries = this.entries; - var newEntries = TypeScript.ArrayUtilities.createArray(newSize, null); - - this.entries = newEntries; - - for (var i = 0; i < oldEntries.length; i++) { - var e = oldEntries[i]; - while (e !== null) { - var newIndex = e.HashCode % newSize; - var tmp = e.Next; - e.Next = newEntries[newIndex]; - newEntries[newIndex] = e; - e = tmp; - } - } - }; - - StringTable.textCharArrayEquals = function (text, array, start, length) { - if (text.length !== length) { - return false; - } - - var s = start; - for (var i = 0; i < length; i++) { - if (text.charCodeAt(i) !== array[s]) { - return false; - } - - s++; - } - - return true; - }; - return StringTable; - })(); - Collections.StringTable = StringTable; - - Collections.DefaultStringTable = new StringTable(Collections.DefaultStringTableCapacity); - })(TypeScript.Collections || (TypeScript.Collections = {})); - var Collections = TypeScript.Collections; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var StringUtilities = (function () { - function StringUtilities() { - } - StringUtilities.isString = function (value) { - return Object.prototype.toString.apply(value, []) === '[object String]'; - }; - - StringUtilities.fromCharCodeArray = function (array) { - return String.fromCharCode.apply(null, array); - }; - - StringUtilities.endsWith = function (string, value) { - return string.substring(string.length - value.length, string.length) === value; - }; - - StringUtilities.startsWith = function (string, value) { - return string.substr(0, value.length) === value; - }; - - StringUtilities.copyTo = function (source, sourceIndex, destination, destinationIndex, count) { - for (var i = 0; i < count; i++) { - destination[destinationIndex + i] = source.charCodeAt(sourceIndex + i); - } - }; - - StringUtilities.repeat = function (value, count) { - return Array(count + 1).join(value); - }; - - StringUtilities.stringEquals = function (val1, val2) { - return val1 === val2; - }; - return StringUtilities; - })(); - TypeScript.StringUtilities = StringUtilities; -})(TypeScript || (TypeScript = {})); -var global = Function("return this").call(null); - -var TypeScript; -(function (TypeScript) { - var Clock; - (function (Clock) { - Clock.now; - Clock.resolution; - - if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") { - global['WScript'].InitializeProjection(); - - Clock.now = function () { - return TestUtilities.QueryPerformanceCounter(); - }; - - Clock.resolution = TestUtilities.QueryPerformanceFrequency(); - } else { - Clock.now = function () { - return Date.now(); - }; - - Clock.resolution = 1000; - } - })(Clock || (Clock = {})); - - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = Clock.now(); - }; - - Timer.prototype.end = function () { - this.time = (Clock.now() - this.startTime); - }; - return Timer; - })(); - TypeScript.Timer = Timer; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - DiagnosticCategory[DiagnosticCategory["NoPrefix"] = 3] = "NoPrefix"; - })(TypeScript.DiagnosticCategory || (TypeScript.DiagnosticCategory = {})); - var DiagnosticCategory = TypeScript.DiagnosticCategory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.diagnosticInformationMap = { - "error TS{0}: {1}": { - "code": 0, - "category": 3 /* NoPrefix */ - }, - "warning TS{0}: {1}": { - "code": 1, - "category": 3 /* NoPrefix */ - }, - "Unrecognized escape sequence.": { - "code": 1000, - "category": 1 /* Error */ - }, - "Unexpected character {0}.": { - "code": 1001, - "category": 1 /* Error */ - }, - "Missing close quote character.": { - "code": 1002, - "category": 1 /* Error */ - }, - "Identifier expected.": { - "code": 1003, - "category": 1 /* Error */ - }, - "'{0}' keyword expected.": { - "code": 1004, - "category": 1 /* Error */ - }, - "'{0}' expected.": { - "code": 1005, - "category": 1 /* Error */ - }, - "Identifier expected; '{0}' is a keyword.": { - "code": 1006, - "category": 1 /* Error */ - }, - "Automatic semicolon insertion not allowed.": { - "code": 1007, - "category": 1 /* Error */ - }, - "Unexpected token; '{0}' expected.": { - "code": 1008, - "category": 1 /* Error */ - }, - "Trailing separator not allowed.": { - "code": 1009, - "category": 1 /* Error */ - }, - "'*/' expected.": { - "code": 1010, - "category": 1 /* Error */ - }, - "'public' or 'private' modifier must precede 'static'.": { - "code": 1011, - "category": 1 /* Error */ - }, - "Unexpected token.": { - "code": 1012, - "category": 1 /* Error */ - }, - "Catch clause parameter cannot have a type annotation.": { - "code": 1013, - "category": 1 /* Error */ - }, - "Rest parameter must be last in list.": { - "code": 1014, - "category": 1 /* Error */ - }, - "Parameter cannot have question mark and initializer.": { - "code": 1015, - "category": 1 /* Error */ - }, - "Required parameter cannot follow optional parameter.": { - "code": 1016, - "category": 1 /* Error */ - }, - "Index signatures cannot have rest parameters.": { - "code": 1017, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have accessibility modifiers.": { - "code": 1018, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have a question mark.": { - "code": 1019, - "category": 1 /* Error */ - }, - "Index signature parameter cannot have an initializer.": { - "code": 1020, - "category": 1 /* Error */ - }, - "Index signature must have a type annotation.": { - "code": 1021, - "category": 1 /* Error */ - }, - "Index signature parameter must have a type annotation.": { - "code": 1022, - "category": 1 /* Error */ - }, - "Index signature parameter type must be 'string' or 'number'.": { - "code": 1023, - "category": 1 /* Error */ - }, - "'extends' clause already seen.": { - "code": 1024, - "category": 1 /* Error */ - }, - "'extends' clause must precede 'implements' clause.": { - "code": 1025, - "category": 1 /* Error */ - }, - "Classes can only extend a single class.": { - "code": 1026, - "category": 1 /* Error */ - }, - "'implements' clause already seen.": { - "code": 1027, - "category": 1 /* Error */ - }, - "Accessibility modifier already seen.": { - "code": 1028, - "category": 1 /* Error */ - }, - "'{0}' modifier must precede '{1}' modifier.": { - "code": 1029, - "category": 1 /* Error */ - }, - "'{0}' modifier already seen.": { - "code": 1030, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a class element.": { - "code": 1031, - "category": 1 /* Error */ - }, - "Interface declaration cannot have 'implements' clause.": { - "code": 1032, - "category": 1 /* Error */ - }, - "'super' invocation cannot have type arguments.": { - "code": 1034, - "category": 1 /* Error */ - }, - "Only ambient modules can use quoted names.": { - "code": 1035, - "category": 1 /* Error */ - }, - "Statements are not allowed in ambient contexts.": { - "code": 1036, - "category": 1 /* Error */ - }, - "Implementations are not allowed in ambient contexts.": { - "code": 1037, - "category": 1 /* Error */ - }, - "'declare' modifier not allowed for code already in an ambient context.": { - "code": 1038, - "category": 1 /* Error */ - }, - "Initializers are not allowed in ambient contexts.": { - "code": 1039, - "category": 1 /* Error */ - }, - "Parameter property declarations can only be used in a non-ambient constructor declaration.": { - "code": 1040, - "category": 1 /* Error */ - }, - "Function implementation expected.": { - "code": 1041, - "category": 1 /* Error */ - }, - "Constructor implementation expected.": { - "code": 1042, - "category": 1 /* Error */ - }, - "Function overload name must be '{0}'.": { - "code": 1043, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a module element.": { - "code": 1044, - "category": 1 /* Error */ - }, - "'declare' modifier cannot appear on an interface declaration.": { - "code": 1045, - "category": 1 /* Error */ - }, - "'declare' modifier required for top level element.": { - "code": 1046, - "category": 1 /* Error */ - }, - "Rest parameter cannot be optional.": { - "code": 1047, - "category": 1 /* Error */ - }, - "Rest parameter cannot have an initializer.": { - "code": 1048, - "category": 1 /* Error */ - }, - "'set' accessor must have one and only one parameter.": { - "code": 1049, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot be optional.": { - "code": 1051, - "category": 1 /* Error */ - }, - "'set' accessor parameter cannot have an initializer.": { - "code": 1052, - "category": 1 /* Error */ - }, - "'set' accessor cannot have rest parameter.": { - "code": 1053, - "category": 1 /* Error */ - }, - "'get' accessor cannot have parameters.": { - "code": 1054, - "category": 1 /* Error */ - }, - "Modifiers cannot appear here.": { - "code": 1055, - "category": 1 /* Error */ - }, - "Accessors are only available when targeting ECMAScript 5 and higher.": { - "code": 1056, - "category": 1 /* Error */ - }, - "Class name cannot be '{0}'.": { - "code": 1057, - "category": 1 /* Error */ - }, - "Interface name cannot be '{0}'.": { - "code": 1058, - "category": 1 /* Error */ - }, - "Enum name cannot be '{0}'.": { - "code": 1059, - "category": 1 /* Error */ - }, - "Module name cannot be '{0}'.": { - "code": 1060, - "category": 1 /* Error */ - }, - "Enum member must have initializer.": { - "code": 1061, - "category": 1 /* Error */ - }, - "Export assignment cannot be used in internal modules.": { - "code": 1063, - "category": 1 /* Error */ - }, - "Export assignment not allowed in module with exported element.": { - "code": 1064, - "category": 1 /* Error */ - }, - "Module cannot have multiple export assignments.": { - "code": 1065, - "category": 1 /* Error */ - }, - "Ambient enum elements can only have integer literal initializers.": { - "code": 1066, - "category": 1 /* Error */ - }, - "module, class, interface, enum, import or statement": { - "code": 1067, - "category": 3 /* NoPrefix */ - }, - "constructor, function, accessor or variable": { - "code": 1068, - "category": 3 /* NoPrefix */ - }, - "statement": { - "code": 1069, - "category": 3 /* NoPrefix */ - }, - "case or default clause": { - "code": 1070, - "category": 3 /* NoPrefix */ - }, - "identifier": { - "code": 1071, - "category": 3 /* NoPrefix */ - }, - "call, construct, index, property or function signature": { - "code": 1072, - "category": 3 /* NoPrefix */ - }, - "expression": { - "code": 1073, - "category": 3 /* NoPrefix */ - }, - "type name": { - "code": 1074, - "category": 3 /* NoPrefix */ - }, - "property or accessor": { - "code": 1075, - "category": 3 /* NoPrefix */ - }, - "parameter": { - "code": 1076, - "category": 3 /* NoPrefix */ - }, - "type": { - "code": 1077, - "category": 3 /* NoPrefix */ - }, - "type parameter": { - "code": 1078, - "category": 3 /* NoPrefix */ - }, - "'declare' modifier not allowed on import declaration.": { - "code": 1079, - "category": 1 /* Error */ - }, - "Function overload must be static.": { - "code": 1080, - "category": 1 /* Error */ - }, - "Function overload must not be static.": { - "code": 1081, - "category": 1 /* Error */ - }, - "Parameter property declarations cannot be used in a constructor overload.": { - "code": 1083, - "category": 1 /* Error */ - }, - "Invalid 'reference' directive syntax.": { - "code": 1084, - "category": 1 /* Error */ - }, - "Octal literals are not available when targeting ECMAScript 5 and higher.": { - "code": 1085, - "category": 1 /* Error */ - }, - "Accessors are not allowed in ambient contexts.": { - "code": 1086, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a constructor declaration.": { - "code": 1089, - "category": 1 /* Error */ - }, - "'{0}' modifier cannot appear on a parameter.": { - "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 */ - }, - "The name '{0}' does not exist in the current scope.": { - "code": 2001, - "category": 1 /* Error */ - }, - "The name '{0}' does not refer to a value.": { - "code": 2002, - "category": 1 /* Error */ - }, - "'super' can only be used inside a class instance method.": { - "code": 2003, - "category": 1 /* Error */ - }, - "The left-hand side of an assignment expression must be a variable, property or indexer.": { - "code": 2004, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable. Did you mean to include 'new'?": { - "code": 2161, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not callable.": { - "code": 2006, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not newable.": { - "code": 2007, - "category": 1 /* Error */ - }, - "Value of type '{0}' is not indexable by type '{1}'.": { - "code": 2008, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}'.": { - "code": 2009, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to types '{1}' and '{2}': {3}": { - "code": 2010, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}'.": { - "code": 2011, - "category": 1 /* Error */ - }, - "Cannot convert '{0}' to '{1}':{NL}{2}": { - "code": 2012, - "category": 1 /* Error */ - }, - "Expected var, class, interface, or module.": { - "code": 2013, - "category": 1 /* Error */ - }, - "Operator '{0}' cannot be applied to type '{1}'.": { - "code": 2014, - "category": 1 /* Error */ - }, - "Getter '{0}' already declared.": { - "code": 2015, - "category": 1 /* Error */ - }, - "Setter '{0}' already declared.": { - "code": 2016, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends private class '{1}'.": { - "code": 2018, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements private interface '{1}'.": { - "code": 2019, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends private interface '{1}'.": { - "code": 2020, - "category": 1 /* Error */ - }, - "Exported class '{0}' extends class from inaccessible module {1}.": { - "code": 2021, - "category": 1 /* Error */ - }, - "Exported class '{0}' implements interface from inaccessible module {1}.": { - "code": 2022, - "category": 1 /* Error */ - }, - "Exported interface '{0}' extends interface from inaccessible module {1}.": { - "code": 2023, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2024, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class has or is using private type '{1}'.": { - "code": 2025, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2026, - "category": 1 /* Error */ - }, - "Exported variable '{0}' has or is using private type '{1}'.": { - "code": 2027, - "category": 1 /* Error */ - }, - "Public static property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2028, - "category": 1 /* Error */ - }, - "Public property '{0}' of exported class is using inaccessible module {1}.": { - "code": 2029, - "category": 1 /* Error */ - }, - "Property '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2030, - "category": 1 /* Error */ - }, - "Exported variable '{0}' is using inaccessible module {1}.": { - "code": 2031, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class has or is using private type '{1}'.": { - "code": 2032, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class has or is using private type '{1}'.": { - "code": 2033, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class has or is using private type '{1}'.": { - "code": 2034, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2035, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2036, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2037, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2038, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2039, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2040, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor from exported class is using inaccessible module {1}.": { - "code": 2041, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static property setter from exported class is using inaccessible module {1}.": { - "code": 2042, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public property setter from exported class is using inaccessible module {1}.": { - "code": 2043, - "category": 1 /* Error */ - }, - "Parameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2044, - "category": 1 /* Error */ - }, - "Parameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2045, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2046, - "category": 1 /* Error */ - }, - "Parameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2047, - "category": 1 /* Error */ - }, - "Parameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2048, - "category": 1 /* Error */ - }, - "Parameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2049, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class has or is using private type '{0}'.": { - "code": 2050, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class has or is using private type '{0}'.": { - "code": 2051, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface has or is using private type '{0}'.": { - "code": 2052, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface has or is using private type '{0}'.": { - "code": 2053, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface has or is using private type '{0}'.": { - "code": 2054, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class has or is using private type '{0}'.": { - "code": 2055, - "category": 1 /* Error */ - }, - "Return type of public method from exported class has or is using private type '{0}'.": { - "code": 2056, - "category": 1 /* Error */ - }, - "Return type of method from exported interface has or is using private type '{0}'.": { - "code": 2057, - "category": 1 /* Error */ - }, - "Return type of exported function has or is using private type '{0}'.": { - "code": 2058, - "category": 1 /* Error */ - }, - "Return type of public static property getter from exported class is using inaccessible module {0}.": { - "code": 2059, - "category": 1 /* Error */ - }, - "Return type of public property getter from exported class is using inaccessible module {0}.": { - "code": 2060, - "category": 1 /* Error */ - }, - "Return type of constructor signature from exported interface is using inaccessible module {0}.": { - "code": 2061, - "category": 1 /* Error */ - }, - "Return type of call signature from exported interface is using inaccessible module {0}.": { - "code": 2062, - "category": 1 /* Error */ - }, - "Return type of index signature from exported interface is using inaccessible module {0}.": { - "code": 2063, - "category": 1 /* Error */ - }, - "Return type of public static method from exported class is using inaccessible module {0}.": { - "code": 2064, - "category": 1 /* Error */ - }, - "Return type of public method from exported class is using inaccessible module {0}.": { - "code": 2065, - "category": 1 /* Error */ - }, - "Return type of method from exported interface is using inaccessible module {0}.": { - "code": 2066, - "category": 1 /* Error */ - }, - "Return type of exported function is using inaccessible module {0}.": { - "code": 2067, - "category": 1 /* Error */ - }, - "'new T[]' cannot be used to create an array. Use 'new Array()' instead.": { - "code": 2068, - "category": 1 /* Error */ - }, - "A parameter list must follow a generic type argument list. '(' expected.": { - "code": 2069, - "category": 1 /* Error */ - }, - "Multiple constructor implementations are not allowed.": { - "code": 2070, - "category": 1 /* Error */ - }, - "Unable to resolve external module '{0}'.": { - "code": 2071, - "category": 1 /* Error */ - }, - "Module cannot be aliased to a non-module type.": { - "code": 2072, - "category": 1 /* Error */ - }, - "A class may only extend another class.": { - "code": 2073, - "category": 1 /* Error */ - }, - "A class may only implement another class or interface.": { - "code": 2074, - "category": 1 /* Error */ - }, - "An interface may only extend another class or interface.": { - "code": 2075, - "category": 1 /* Error */ - }, - "Unable to resolve type.": { - "code": 2077, - "category": 1 /* Error */ - }, - "Unable to resolve type of '{0}'.": { - "code": 2078, - "category": 1 /* Error */ - }, - "Unable to resolve type parameter constraint.": { - "code": 2079, - "category": 1 /* Error */ - }, - "Type parameter constraint cannot be a primitive type.": { - "code": 2080, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target.": { - "code": 2081, - "category": 1 /* Error */ - }, - "Supplied parameters do not match any signature of call target:{NL}{0}": { - "code": 2082, - "category": 1 /* Error */ - }, - "Invalid 'new' expression.": { - "code": 2083, - "category": 1 /* Error */ - }, - "Call signatures used in a 'new' expression must have a 'void' return type.": { - "code": 2084, - "category": 1 /* Error */ - }, - "Could not select overload for 'new' expression.": { - "code": 2085, - "category": 1 /* Error */ - }, - "Type '{0}' does not satisfy the constraint '{1}' for type parameter '{2}'.": { - "code": 2086, - "category": 1 /* Error */ - }, - "Could not select overload for 'call' expression.": { - "code": 2087, - "category": 1 /* Error */ - }, - "Cannot invoke an expression whose type lacks a call signature.": { - "code": 2088, - "category": 1 /* Error */ - }, - "Calls to 'super' are only valid inside a class.": { - "code": 2089, - "category": 1 /* Error */ - }, - "Generic type '{0}' requires {1} type argument(s).": { - "code": 2090, - "category": 1 /* Error */ - }, - "Type of array literal cannot be determined. Best common type could not be found for array elements.": { - "code": 2092, - "category": 1 /* Error */ - }, - "Could not find enclosing symbol for dotted name '{0}'.": { - "code": 2093, - "category": 1 /* Error */ - }, - "The property '{0}' does not exist on value of type '{1}'.": { - "code": 2094, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}'.": { - "code": 2095, - "category": 1 /* Error */ - }, - "'get' and 'set' accessor must have the same type.": { - "code": 2096, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in current location.": { - "code": 2097, - "category": 1 /* Error */ - }, - "Static members cannot reference class type parameters.": { - "code": 2099, - "category": 1 /* Error */ - }, - "Class '{0}' is recursively referenced as a base type of itself.": { - "code": 2100, - "category": 1 /* Error */ - }, - "Interface '{0}' is recursively referenced as a base type of itself.": { - "code": 2101, - "category": 1 /* Error */ - }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { - "code": 2102, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in non-derived classes.": { - "code": 2103, - "category": 1 /* Error */ - }, - "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.": { - "code": 2104, - "category": 1 /* Error */ - }, - "Constructors for derived classes must contain a 'super' call.": { - "code": 2105, - "category": 1 /* Error */ - }, - "Super calls are not permitted outside constructors or in nested functions inside constructors.": { - "code": 2106, - "category": 1 /* Error */ - }, - "'{0}.{1}' is inaccessible.": { - "code": 2107, - "category": 1 /* Error */ - }, - "'this' cannot be referenced within module bodies.": { - "code": 2108, - "category": 1 /* Error */ - }, - "Invalid '+' expression - types not known to support the addition operator.": { - "code": 2111, - "category": 1 /* Error */ - }, - "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2112, - "category": 1 /* Error */ - }, - "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.": { - "code": 2113, - "category": 1 /* Error */ - }, - "The type of a unary arithmetic operation operand must be of type 'any', 'number' or an enum type.": { - "code": 2114, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement cannot use a type annotation.": { - "code": 2115, - "category": 1 /* Error */ - }, - "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { - "code": 2116, - "category": 1 /* Error */ - }, - "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.": { - "code": 2117, - "category": 1 /* Error */ - }, - "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": { - "code": 2118, - "category": 1 /* Error */ - }, - "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.": { - "code": 2119, - "category": 1 /* Error */ - }, - "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.": { - "code": 2120, - "category": 1 /* Error */ - }, - "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 */ - }, - "Setters cannot return a value.": { - "code": 2122, - "category": 1 /* Error */ - }, - "Tried to query type of uninitialized module '{0}'.": { - "code": 2123, - "category": 1 /* Error */ - }, - "Tried to set variable type to uninitialized module type '{0}'.": { - "code": 2124, - "category": 1 /* Error */ - }, - "Type '{0}' does not have type parameters.": { - "code": 2125, - "category": 1 /* Error */ - }, - "Getters must return a value.": { - "code": 2126, - "category": 1 /* Error */ - }, - "Getter and setter accessors do not agree in visibility.": { - "code": 2127, - "category": 1 /* Error */ - }, - "Invalid left-hand side of assignment expression.": { - "code": 2130, - "category": 1 /* Error */ - }, - "Function declared a non-void return type, but has no return expression.": { - "code": 2131, - "category": 1 /* Error */ - }, - "Cannot resolve return type reference.": { - "code": 2132, - "category": 1 /* Error */ - }, - "Constructors cannot have a return type of 'void'.": { - "code": 2133, - "category": 1 /* Error */ - }, - "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.": { - "code": 2134, - "category": 1 /* Error */ - }, - "All symbols within a with block will be resolved to 'any'.": { - "code": 2135, - "category": 1 /* Error */ - }, - "Import declarations in an internal module cannot reference an external module.": { - "code": 2136, - "category": 1 /* Error */ - }, - "Class {0} declares interface {1} but does not implement it:{NL}{2}": { - "code": 2137, - "category": 1 /* Error */ - }, - "Class {0} declares class {1} as an interface but does not implement it:{NL}{2}": { - "code": 2138, - "category": 1 /* Error */ - }, - "The operand of an increment or decrement operator must be a variable, property or indexer.": { - "code": 2139, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in static initializers in a class body.": { - "code": 2140, - "category": 1 /* Error */ - }, - "Class '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2141, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend class '{1}':{NL}{2}": { - "code": 2142, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot extend interface '{1}':{NL}{2}": { - "code": 2143, - "category": 1 /* Error */ - }, - "Duplicate overload signature for '{0}'.": { - "code": 2144, - "category": 1 /* Error */ - }, - "Duplicate constructor overload signature.": { - "code": 2145, - "category": 1 /* Error */ - }, - "Duplicate overload call signature.": { - "code": 2146, - "category": 1 /* Error */ - }, - "Duplicate overload construct signature.": { - "code": 2147, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition.": { - "code": 2148, - "category": 1 /* Error */ - }, - "Overload signature is not compatible with function definition:{NL}{0}": { - "code": 2149, - "category": 1 /* Error */ - }, - "Overload signatures must all be public or private.": { - "code": 2150, - "category": 1 /* Error */ - }, - "Overload signatures must all be exported or not exported.": { - "code": 2151, - "category": 1 /* Error */ - }, - "Overload signatures must all be ambient or non-ambient.": { - "code": 2152, - "category": 1 /* Error */ - }, - "Overload signatures must all be optional or required.": { - "code": 2153, - "category": 1 /* Error */ - }, - "Specialized overload signature is not assignable to any non-specialized signature.": { - "code": 2154, - "category": 1 /* Error */ - }, - "'this' cannot be referenced in constructor arguments.": { - "code": 2155, - "category": 1 /* Error */ - }, - "Instance member cannot be accessed off a class.": { - "code": 2157, - "category": 1 /* Error */ - }, - "Untyped function calls may not accept type arguments.": { - "code": 2158, - "category": 1 /* Error */ - }, - "Non-generic functions may not accept type arguments.": { - "code": 2159, - "category": 1 /* Error */ - }, - "A generic type may not reference itself with a wrapped form of its own type parameters.": { - "code": 2160, - "category": 1 /* Error */ - }, - "Rest parameters must be array types.": { - "code": 2162, - "category": 1 /* Error */ - }, - "Overload signature implementation cannot use specialized type.": { - "code": 2163, - "category": 1 /* Error */ - }, - "Export assignments may only be used at the top-level of external modules.": { - "code": 2164, - "category": 1 /* Error */ - }, - "Export assignments may only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2165, - "category": 1 /* Error */ - }, - "Only public methods of the base class are accessible via the 'super' keyword.": { - "code": 2166, - "category": 1 /* Error */ - }, - "Numeric indexer type '{0}' must be assignable to string indexer type '{1}'.": { - "code": 2167, - "category": 1 /* Error */ - }, - "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 assignable to numeric indexer type '{0}'.": { - "code": 2169, - "category": 1 /* Error */ - }, - "All numerically named properties must be assignable to numeric indexer type '{0}':{NL}{1}": { - "code": 2170, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}'.": { - "code": 2171, - "category": 1 /* Error */ - }, - "All named properties must be assignable to string indexer type '{0}':{NL}{1}": { - "code": 2172, - "category": 1 /* Error */ - }, - "Generic type references must include all type arguments.": { - "code": 2173, - "category": 1 /* Error */ - }, - "Default arguments are only allowed in implementation.": { - "code": 2174, - "category": 1 /* Error */ - }, - "Overloads cannot differ only by return type.": { - "code": 2175, - "category": 1 /* Error */ - }, - "Function expression declared a non-void return type, but has no return expression.": { - "code": 2176, - "category": 1 /* Error */ - }, - "Import declaration referencing identifier from internal module can only be made with variables, functions, classes, interfaces, enums and internal modules.": { - "code": 2177, - "category": 1 /* Error */ - }, - "Could not find symbol '{0}' in module '{1}'.": { - "code": 2178, - "category": 1 /* Error */ - }, - "Unable to resolve module reference '{0}'.": { - "code": 2179, - "category": 1 /* Error */ - }, - "Could not find module '{0}' in module '{1}'.": { - "code": 2180, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that has or is using private type '{1}'.": { - "code": 2181, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned value with type that is using inaccessible module '{1}'.": { - "code": 2182, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that has or is using private type '{1}'.": { - "code": 2183, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned type that is using inaccessible module '{1}'.": { - "code": 2184, - "category": 1 /* Error */ - }, - "Exported import declaration '{0}' is assigned container that is or is using inaccessible module '{1}'.": { - "code": 2185, - "category": 1 /* Error */ - }, - "Type name '{0}' in extends clause does not reference constructor function for '{1}'.": { - "code": 2186, - "category": 1 /* Error */ - }, - "Internal module reference '{0}' in import declaration does not reference module instance for '{1}'.": { - "code": 2187, - "category": 1 /* Error */ - }, - "Module '{0}' cannot merge with previous declaration of '{1}' in a different file '{2}'.": { - "code": 2188, - "category": 1 /* Error */ - }, - "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':{NL}{3}": { - "code": 2189, - "category": 1 /* Error */ - }, - "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { - "code": 2190, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot be reopened.": { - "code": 2191, - "category": 1 /* Error */ - }, - "All declarations of merged declaration '{0}' must be exported or not exported.": { - "code": 2192, - "category": 1 /* Error */ - }, - "'super' cannot be referenced in constructor arguments.": { - "code": 2193, - "category": 1 /* Error */ - }, - "Return type of constructor signature must be assignable to the instance type of the class.": { - "code": 2194, - "category": 1 /* Error */ - }, - "Ambient external module declaration must be defined in global context.": { - "code": 2195, - "category": 1 /* Error */ - }, - "Ambient external module declaration cannot specify relative module name.": { - "code": 2196, - "category": 1 /* Error */ - }, - "Import declaration in an ambient external module declaration cannot reference external module through relative external module name.": { - "code": 2197, - "category": 1 /* Error */ - }, - "Could not find the best common type of types of all return statement expressions.": { - "code": 2198, - "category": 1 /* Error */ - }, - "Import declaration cannot refer to external module reference when --noResolve option is set.": { - "code": 2199, - "category": 1 /* Error */ - }, - "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.": { - "code": 2200, - "category": 1 /* Error */ - }, - "'continue' statement can only be used within an enclosing iteration statement.": { - "code": 2201, - "category": 1 /* Error */ - }, - "'break' statement can only be used within an enclosing iteration or switch statement.": { - "code": 2202, - "category": 1 /* Error */ - }, - "Jump target not found.": { - "code": 2203, - "category": 1 /* Error */ - }, - "Jump target cannot cross function boundary.": { - "code": 2204, - "category": 1 /* Error */ - }, - "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.": { - "code": 2205, - "category": 1 /* Error */ - }, - "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.": { - "code": 2206, - "category": 1 /* Error */ - }, - "Expression resolves to '_super' that compiler uses to capture base class reference.": { - "code": 2207, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface has or is using private type '{1}'.": { - "code": 2208, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface has or is using private type '{1}'.": { - "code": 2209, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class has or is using private type '{1}'.": { - "code": 2210, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class has or is using private type '{1}'.": { - "code": 2211, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface has or is using private type '{1}'.": { - "code": 2212, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function has or is using private type '{1}'.": { - "code": 2213, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of constructor signature from exported interface is using inaccessible module {1}.": { - "code": 2214, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of call signature from exported interface is using inaccessible module {1}": { - "code": 2215, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public static method from exported class is using inaccessible module {1}.": { - "code": 2216, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of public method from exported class is using inaccessible module {1}.": { - "code": 2217, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of method from exported interface is using inaccessible module {1}.": { - "code": 2218, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported function is using inaccessible module {1}.": { - "code": 2219, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class has or is using private type '{1}'.": { - "code": 2220, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface has or is using private type '{1}'.": { - "code": 2221, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported class is using inaccessible module {1}.": { - "code": 2222, - "category": 1 /* Error */ - }, - "TypeParameter '{0}' of exported interface is using inaccessible module {1}.": { - "code": 2223, - "category": 1 /* Error */ - }, - "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter.": { - "code": 2224, - "category": 1 /* Error */ - }, - "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.": { - "code": 2225, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}' or '{2}'.": { - "code": 2226, - "category": 1 /* Error */ - }, - "Type of conditional '{0}' must be identical to '{1}', '{2}' or '{3}'.": { - "code": 2227, - "category": 1 /* Error */ - }, - "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module.": { - "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 */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible.": { - "code": 4001, - "category": 3 /* NoPrefix */ - }, - "Types of property '{0}' of types '{1}' and '{2}' are incompatible:{NL}{3}": { - "code": 4002, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as private in type '{1}' is defined as public in type '{2}'.": { - "code": 4003, - "category": 3 /* NoPrefix */ - }, - "Property '{0}' defined as public in type '{1}' is defined as private in type '{2}'.": { - "code": 4004, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' define property '{2}' as private.": { - "code": 4005, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4006, - "category": 3 /* NoPrefix */ - }, - "Call signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4007, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a call signature, but type '{1}' lacks one.": { - "code": 4008, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4009, - "category": 3 /* NoPrefix */ - }, - "Construct signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4010, - "category": 3 /* NoPrefix */ - }, - "Type '{0}' requires a construct signature, but type '{1}' lacks one.": { - "code": 4011, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible.": { - "code": 4012, - "category": 3 /* NoPrefix */ - }, - "Index signatures of types '{0}' and '{1}' are incompatible:{NL}{2}": { - "code": 4013, - "category": 3 /* NoPrefix */ - }, - "Call signature expects {0} or fewer parameters.": { - "code": 4014, - "category": 3 /* NoPrefix */ - }, - "Could not apply type '{0}' to argument {1} which is of type '{2}'.": { - "code": 4015, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4016, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.": { - "code": 4017, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.": { - "code": 4018, - "category": 3 /* NoPrefix */ - }, - "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.": { - "code": 4019, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible.": { - "code": 4020, - "category": 3 /* NoPrefix */ - }, - "Types of static property '{0}' of class '{1}' and class '{2}' are incompatible:{NL}{3}": { - "code": 4021, - "category": 3 /* NoPrefix */ - }, - "Type reference cannot refer to container '{0}'.": { - "code": 4022, - "category": 1 /* Error */ - }, - "Type reference must refer to type.": { - "code": 4023, - "category": 1 /* Error */ - }, - "In enums with multiple declarations only one declaration can omit an initializer for the first enum element.": { - "code": 4024, - "category": 1 /* Error */ - }, - " (+ {0} overload(s))": { - "code": 4025, - "category": 2 /* Message */ - }, - "Variable declaration cannot have the same name as an import declaration.": { - "code": 4026, - "category": 1 /* Error */ - }, - "Signature expected {0} type arguments, got {1} instead.": { - "code": 4027, - "category": 1 /* Error */ - }, - "Property '{0}' defined as optional in type '{1}', but is required in type '{2}'.": { - "code": 4028, - "category": 3 /* NoPrefix */ - }, - "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 infinitely expanding type reference have incompatible type arguments.": { - "code": 4030, - "category": 3 /* NoPrefix */ - }, - "Types '{0}' and '{1}' originating in infinitely expanding type reference have incompatible type arguments:{NL}{2}": { - "code": 4031, - "category": 3 /* NoPrefix */ - }, - "Named properties '{0}' of types '{1}' and '{2}' are not identical.": { - "code": 4032, - "category": 3 /* NoPrefix */ - }, - "Types of string indexer of types '{0}' and '{1}' are not identical.": { - "code": 4033, - "category": 3 /* NoPrefix */ - }, - "Types of number indexer of types '{0}' and '{1}' are not identical.": { - "code": 4034, - "category": 3 /* NoPrefix */ - }, - "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 assignable to string indexer type in type '{2}'.{NL}{3}": { - "code": 4036, - "category": 3 /* NoPrefix */ - }, - "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 */ - }, - "ECMAScript target version '{0}' not supported. Specify a valid target version: '{1}' (default), or '{2}'": { - "code": 5002, - "category": 1 /* Error */ - }, - "Module code generation '{0}' not supported.": { - "code": 5003, - "category": 1 /* Error */ - }, - "Could not find file: '{0}'.": { - "code": 5004, - "category": 1 /* Error */ - }, - "A file cannot have a reference to itself.": { - "code": 5006, - "category": 1 /* Error */ - }, - "Cannot resolve referenced file: '{0}'.": { - "code": 5007, - "category": 1 /* Error */ - }, - "Cannot find the common subdirectory path for the input files.": { - "code": 5009, - "category": 1 /* Error */ - }, - "Emit Error: {0}.": { - "code": 5011, - "category": 1 /* Error */ - }, - "Cannot read file '{0}': {1}": { - "code": 5012, - "category": 1 /* Error */ - }, - "Unsupported file encoding.": { - "code": 5013, - "category": 3 /* NoPrefix */ - }, - "Locale must be of the form or -. For example '{0}' or '{1}'.": { - "code": 5014, - "category": 1 /* Error */ - }, - "Unsupported locale: '{0}'.": { - "code": 5015, - "category": 1 /* Error */ - }, - "Execution Failed.{NL}": { - "code": 5016, - "category": 1 /* Error */ - }, - "Invalid call to 'up'": { - "code": 5019, - "category": 1 /* Error */ - }, - "Invalid call to 'down'": { - "code": 5020, - "category": 1 /* Error */ - }, - "Base64 value '{0}' finished with a continuation bit.": { - "code": 5021, - "category": 1 /* Error */ - }, - "Unknown option '{0}'": { - "code": 5023, - "category": 1 /* Error */ - }, - "Expected {0} arguments to message, got {1} instead.": { - "code": 5024, - "category": 1 /* Error */ - }, - "Expected the message '{0}' to have {1} arguments, but it had {2}": { - "code": 5025, - "category": 1 /* Error */ - }, - "Could not delete file '{0}'": { - "code": 5034, - "category": 1 /* Error */ - }, - "Could not create directory '{0}'": { - "code": 5035, - "category": 1 /* Error */ - }, - "Error while executing file '{0}': ": { - "code": 5036, - "category": 1 /* Error */ - }, - "Cannot compile external modules unless the '--module' flag is provided.": { - "code": 5037, - "category": 1 /* Error */ - }, - "Option mapRoot cannot be specified without specifying sourcemap option.": { - "code": 5038, - "category": 1 /* Error */ - }, - "Option sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5039, - "category": 1 /* Error */ - }, - "Options mapRoot and sourceRoot cannot be specified without specifying sourcemap option.": { - "code": 5040, - "category": 1 /* Error */ - }, - "Option '{0}' specified without '{1}'": { - "code": 5041, - "category": 1 /* Error */ - }, - "'codepage' option not supported on current platform.": { - "code": 5042, - "category": 1 /* Error */ - }, - "Concatenate and emit output to single file.": { - "code": 6001, - "category": 2 /* Message */ - }, - "Generates corresponding {0} file.": { - "code": 6002, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate map files instead of generated locations.": { - "code": 6003, - "category": 2 /* Message */ - }, - "Specifies the location where debugger should locate TypeScript files instead of source locations.": { - "code": 6004, - "category": 2 /* Message */ - }, - "Watch input files.": { - "code": 6005, - "category": 2 /* Message */ - }, - "Redirect output structure to the directory.": { - "code": 6006, - "category": 2 /* Message */ - }, - "Do not emit comments to output.": { - "code": 6009, - "category": 2 /* Message */ - }, - "Skip resolution and preprocessing.": { - "code": 6010, - "category": 2 /* Message */ - }, - "Specify ECMAScript target version: '{0}' (default), or '{1}'": { - "code": 6015, - "category": 2 /* Message */ - }, - "Specify module code generation: '{0}' or '{1}'": { - "code": 6016, - "category": 2 /* Message */ - }, - "Print this message.": { - "code": 6017, - "category": 2 /* Message */ - }, - "Print the compiler's version: {0}": { - "code": 6019, - "category": 2 /* Message */ - }, - "Allow use of deprecated '{0}' keyword when referencing an external module.": { - "code": 6021, - "category": 2 /* Message */ - }, - "Specify locale for errors and messages. For example '{0}' or '{1}'": { - "code": 6022, - "category": 2 /* Message */ - }, - "Syntax: {0}": { - "code": 6023, - "category": 2 /* Message */ - }, - "options": { - "code": 6024, - "category": 2 /* Message */ - }, - "file1": { - "code": 6025, - "category": 2 /* Message */ - }, - "Examples:": { - "code": 6026, - "category": 2 /* Message */ - }, - "Options:": { - "code": 6027, - "category": 2 /* Message */ - }, - "Insert command line options and files from a file.": { - "code": 6030, - "category": 2 /* Message */ - }, - "Version {0}": { - "code": 6029, - "category": 2 /* Message */ - }, - "Use the '{0}' flag to see options.": { - "code": 6031, - "category": 2 /* Message */ - }, - "{NL}Recompiling ({0}):": { - "code": 6032, - "category": 2 /* Message */ - }, - "STRING": { - "code": 6033, - "category": 2 /* Message */ - }, - "KIND": { - "code": 6034, - "category": 2 /* Message */ - }, - "file2": { - "code": 6035, - "category": 2 /* Message */ - }, - "VERSION": { - "code": 6036, - "category": 2 /* Message */ - }, - "LOCATION": { - "code": 6037, - "category": 2 /* Message */ - }, - "DIRECTORY": { - "code": 6038, - "category": 2 /* Message */ - }, - "NUMBER": { - "code": 6039, - "category": 2 /* Message */ - }, - "Specify the codepage to use when opening source files.": { - "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 */ - }, - "Unknown rule.": { - "code": 7002, - "category": 1 /* Error */ - }, - "Invalid line number ({0})": { - "code": 7003, - "category": 1 /* Error */ - }, - "Warn on expressions and declarations with an implied 'any' type.": { - "code": 7004, - "category": 2 /* Message */ - }, - "Variable '{0}' implicitly has an 'any' type.": { - "code": 7005, - "category": 1 /* Error */ - }, - "Parameter '{0}' of '{1}' implicitly has an 'any' type.": { - "code": 7006, - "category": 1 /* Error */ - }, - "Parameter '{0}' of function type implicitly has an 'any' type.": { - "code": 7007, - "category": 1 /* Error */ - }, - "Member '{0}' of object type implicitly has an 'any' type.": { - "code": 7008, - "category": 1 /* Error */ - }, - "'new' expression, which lacks a constructor signature, implicitly has an 'any' type.": { - "code": 7009, - "category": 1 /* Error */ - }, - "'{0}', which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7010, - "category": 1 /* Error */ - }, - "Function expression, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7011, - "category": 1 /* Error */ - }, - "Parameter '{0}' of lambda function implicitly has an 'any' type.": { - "code": 7012, - "category": 1 /* Error */ - }, - "Constructor signature, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7013, - "category": 1 /* Error */ - }, - "Lambda Function, which lacks return-type annotation, implicitly has an 'any' return type.": { - "code": 7014, - "category": 1 /* Error */ - }, - "Array Literal implicitly has an 'any' type from widening.": { - "code": 7015, - "category": 1 /* Error */ - }, - "'{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 = {})); -var TypeScript; -(function (TypeScript) { - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; - - CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - - CharacterCodes[CharacterCodes["_"] = 95] = "_"; - CharacterCodes[CharacterCodes["$"] = 36] = "$"; - - CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; - CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; - CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; - - CharacterCodes[CharacterCodes["a"] = 97] = "a"; - CharacterCodes[CharacterCodes["b"] = 98] = "b"; - CharacterCodes[CharacterCodes["c"] = 99] = "c"; - CharacterCodes[CharacterCodes["d"] = 100] = "d"; - CharacterCodes[CharacterCodes["e"] = 101] = "e"; - CharacterCodes[CharacterCodes["f"] = 102] = "f"; - CharacterCodes[CharacterCodes["g"] = 103] = "g"; - CharacterCodes[CharacterCodes["h"] = 104] = "h"; - CharacterCodes[CharacterCodes["i"] = 105] = "i"; - CharacterCodes[CharacterCodes["k"] = 107] = "k"; - CharacterCodes[CharacterCodes["l"] = 108] = "l"; - CharacterCodes[CharacterCodes["m"] = 109] = "m"; - CharacterCodes[CharacterCodes["n"] = 110] = "n"; - CharacterCodes[CharacterCodes["o"] = 111] = "o"; - CharacterCodes[CharacterCodes["p"] = 112] = "p"; - CharacterCodes[CharacterCodes["q"] = 113] = "q"; - CharacterCodes[CharacterCodes["r"] = 114] = "r"; - CharacterCodes[CharacterCodes["s"] = 115] = "s"; - CharacterCodes[CharacterCodes["t"] = 116] = "t"; - CharacterCodes[CharacterCodes["u"] = 117] = "u"; - CharacterCodes[CharacterCodes["v"] = 118] = "v"; - CharacterCodes[CharacterCodes["w"] = 119] = "w"; - CharacterCodes[CharacterCodes["x"] = 120] = "x"; - CharacterCodes[CharacterCodes["y"] = 121] = "y"; - CharacterCodes[CharacterCodes["z"] = 122] = "z"; - - CharacterCodes[CharacterCodes["A"] = 65] = "A"; - CharacterCodes[CharacterCodes["E"] = 69] = "E"; - CharacterCodes[CharacterCodes["F"] = 70] = "F"; - CharacterCodes[CharacterCodes["X"] = 88] = "X"; - CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; - - CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 64] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; - CharacterCodes[CharacterCodes["question"] = 63] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; - - CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(TypeScript.CharacterCodes || (TypeScript.CharacterCodes = {})); - var CharacterCodes = TypeScript.CharacterCodes; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - (function (ScriptSnapshot) { - var StringScriptSnapshot = (function () { - function StringScriptSnapshot(text) { - this.text = text; - this._lineStartPositions = null; - } - StringScriptSnapshot.prototype.getText = function (start, end) { - return this.text.substring(start, end); - }; - - StringScriptSnapshot.prototype.getLength = function () { - return this.text.length; - }; - - StringScriptSnapshot.prototype.getLineStartPositions = function () { - if (!this._lineStartPositions) { - this._lineStartPositions = TypeScript.TextUtilities.parseLineStarts(this.text); - } - - return this._lineStartPositions; - }; - - StringScriptSnapshot.prototype.getTextChangeRangeSinceVersion = function (scriptVersion) { - throw TypeScript.Errors.notYetImplemented(); - }; - return StringScriptSnapshot; - })(); - - function fromString(text) { - return new StringScriptSnapshot(text); - } - ScriptSnapshot.fromString = fromString; - })(TypeScript.ScriptSnapshot || (TypeScript.ScriptSnapshot = {})); - var ScriptSnapshot = TypeScript.ScriptSnapshot; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LineMap1) { - function fromSimpleText(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return text.charCodeAt(index); - }, length: text.length() }); - }, text.length()); - } - LineMap1.fromSimpleText = fromSimpleText; - - function fromScriptSnapshot(scriptSnapshot) { - return new TypeScript.LineMap(function () { - return scriptSnapshot.getLineStartPositions(); - }, scriptSnapshot.getLength()); - } - LineMap1.fromScriptSnapshot = fromScriptSnapshot; - - function fromString(text) { - return new TypeScript.LineMap(function () { - return TypeScript.TextUtilities.parseLineStarts(text); - }, text.length); - } - LineMap1.fromString = fromString; - })(TypeScript.LineMap1 || (TypeScript.LineMap1 = {})); - var LineMap1 = TypeScript.LineMap1; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextFactory) { - function getStartAndLengthOfLineBreakEndingAt(text, index, info) { - var c = text.charCodeAt(index); - if (c === 10 /* lineFeed */) { - if (index > 0 && text.charCodeAt(index - 1) === 13 /* carriageReturn */) { - info.startPosition = index - 1; - info.length = 2; - } else { - info.startPosition = index; - info.length = 1; - } - } else if (TypeScript.TextUtilities.isAnyLineBreakCharacter(c)) { - info.startPosition = index; - info.length = 1; - } else { - info.startPosition = index + 1; - info.length = 0; - } - } - - var LinebreakInfo = (function () { - function LinebreakInfo(startPosition, length) { - this.startPosition = startPosition; - this.length = length; - } - return LinebreakInfo; - })(); - - var TextLine = (function () { - function TextLine(text, body, lineBreakLength, lineNumber) { - this._text = null; - this._textSpan = null; - if (text === null) { - throw TypeScript.Errors.argumentNull('text'); - } - TypeScript.Debug.assert(lineBreakLength >= 0); - TypeScript.Debug.assert(lineNumber >= 0); - this._text = text; - this._textSpan = body; - this._lineBreakLength = lineBreakLength; - this._lineNumber = lineNumber; - } - TextLine.prototype.start = function () { - return this._textSpan.start(); - }; - - TextLine.prototype.end = function () { - return this._textSpan.end(); - }; - - TextLine.prototype.endIncludingLineBreak = function () { - return this.end() + this._lineBreakLength; - }; - - TextLine.prototype.extent = function () { - return this._textSpan; - }; - - TextLine.prototype.extentIncludingLineBreak = function () { - return TypeScript.TextSpan.fromBounds(this.start(), this.endIncludingLineBreak()); - }; - - TextLine.prototype.toString = function () { - return this._text.toString(this._textSpan); - }; - - TextLine.prototype.lineNumber = function () { - return this._lineNumber; - }; - return TextLine; - })(); - - var TextBase = (function () { - function TextBase() { - this.linebreakInfo = new LinebreakInfo(0, 0); - this.lastLineFoundForPosition = null; - } - TextBase.prototype.length = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.charCodeAt = function (position) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - TextBase.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this, span); - }; - - TextBase.prototype.substr = function (start, length, intern) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.lineCount = function () { - return this._lineStarts().length; - }; - - TextBase.prototype.lines = function () { - var lines = []; - - var length = this.lineCount(); - for (var i = 0; i < length; ++i) { - lines[i] = this.getLineFromLineNumber(i); - } - - return lines; - }; - - TextBase.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this._lineStarts(); - }, this.length()); - }; - - TextBase.prototype._lineStarts = function () { - throw TypeScript.Errors.abstract(); - }; - - TextBase.prototype.getLineFromLineNumber = function (lineNumber) { - var lineStarts = this._lineStarts(); - - if (lineNumber < 0 || lineNumber >= lineStarts.length) { - throw TypeScript.Errors.argumentOutOfRange("lineNumber"); - } - - var first = lineStarts[lineNumber]; - if (lineNumber === lineStarts.length - 1) { - return new TextLine(this, new TypeScript.TextSpan(first, this.length() - first), 0, lineNumber); - } else { - getStartAndLengthOfLineBreakEndingAt(this, lineStarts[lineNumber + 1] - 1, this.linebreakInfo); - return new TextLine(this, new TypeScript.TextSpan(first, this.linebreakInfo.startPosition - first), this.linebreakInfo.length, lineNumber); - } - }; - - TextBase.prototype.getLineFromPosition = function (position) { - var lastFound = this.lastLineFoundForPosition; - if (lastFound !== null && lastFound.start() <= position && lastFound.endIncludingLineBreak() > position) { - return lastFound; - } - - var lineNumber = this.getLineNumberFromPosition(position); - - var result = this.getLineFromLineNumber(lineNumber); - this.lastLineFoundForPosition = result; - return result; - }; - - TextBase.prototype.getLineNumberFromPosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - if (position === this.length()) { - return this.lineCount() - 1; - } - - var lineNumber = TypeScript.ArrayUtilities.binarySearch(this._lineStarts(), position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - - return lineNumber; - }; - - TextBase.prototype.getLinePosition = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var lineNumber = this.getLineNumberFromPosition(position); - - return new TypeScript.LineAndCharacter(lineNumber, position - this._lineStarts()[lineNumber]); - }; - return TextBase; - })(); - - var SubText = (function (_super) { - __extends(SubText, _super); - function SubText(text, span) { - _super.call(this); - this._lazyLineStarts = null; - - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SubText.prototype.length = function () { - return this.span.length(); - }; - - SubText.prototype.charCodeAt = function (position) { - if (position < 0 || position > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.text.charCodeAt(this.span.start() + position); - }; - - SubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SubText.prototype.substr = function (start, length, intern) { - var startInOriginalText = this.span.start() + start; - return this.text.substr(startInOriginalText, length, intern); - }; - - SubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SubText.prototype._lineStarts = function () { - var _this = this; - if (!this._lazyLineStarts) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts({ charCodeAt: function (index) { - return _this.charCodeAt(index); - }, length: this.length() }); - } - - return this._lazyLineStarts; - }; - return SubText; - })(TextBase); - - var StringText = (function (_super) { - __extends(StringText, _super); - function StringText(data) { - _super.call(this); - this.source = null; - this._lazyLineStarts = null; - - if (data === null) { - throw TypeScript.Errors.argumentNull("data"); - } - - this.source = data; - } - StringText.prototype.length = function () { - return this.source.length; - }; - - StringText.prototype.charCodeAt = function (position) { - if (position < 0 || position >= this.source.length) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - return this.source.charCodeAt(position); - }; - - StringText.prototype.substr = function (start, length, intern) { - return this.source.substr(start, length); - }; - - StringText.prototype.toString = function (span) { - if (typeof span === "undefined") { span = null; } - if (span === null) { - span = new TypeScript.TextSpan(0, this.length()); - } - - this.checkSubSpan(span); - - if (span.start() === 0 && span.length() === this.length()) { - return this.source; - } - - return this.source.substr(span.start(), span.length()); - }; - - StringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.source, sourceIndex, destination, destinationIndex, count); - }; - - StringText.prototype._lineStarts = function () { - if (this._lazyLineStarts === null) { - this._lazyLineStarts = TypeScript.TextUtilities.parseLineStarts(this.source); - } - - return this._lazyLineStarts; - }; - return StringText; - })(TextBase); - - function createText(value) { - return new StringText(value); - } - TextFactory.createText = createText; - })(TypeScript.TextFactory || (TypeScript.TextFactory = {})); - var TextFactory = TypeScript.TextFactory; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (SimpleText) { - var SimpleSubText = (function () { - function SimpleSubText(text, span) { - this.text = null; - this.span = null; - if (text === null) { - throw TypeScript.Errors.argumentNull("text"); - } - - if (span.start() < 0 || span.start() >= text.length() || span.end() < 0 || span.end() > text.length()) { - throw TypeScript.Errors.argument("span"); - } - - this.text = text; - this.span = span; - } - SimpleSubText.prototype.checkSubSpan = function (span) { - if (span.start() < 0 || span.start() > this.length() || span.end() > this.length()) { - throw TypeScript.Errors.argumentOutOfRange("span"); - } - }; - - SimpleSubText.prototype.checkSubPosition = function (position) { - if (position < 0 || position >= this.length()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - }; - - SimpleSubText.prototype.length = function () { - return this.span.length(); - }; - - SimpleSubText.prototype.subText = function (span) { - this.checkSubSpan(span); - - return new SimpleSubText(this.text, this.getCompositeSpan(span.start(), span.length())); - }; - - SimpleSubText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var span = this.getCompositeSpan(sourceIndex, count); - this.text.copyTo(span.start(), destination, destinationIndex, span.length()); - }; - - SimpleSubText.prototype.substr = function (start, length, intern) { - var span = this.getCompositeSpan(start, length); - return this.text.substr(span.start(), span.length(), intern); - }; - - SimpleSubText.prototype.getCompositeSpan = function (start, length) { - var compositeStart = TypeScript.MathPrototype.min(this.text.length(), this.span.start() + start); - var compositeEnd = TypeScript.MathPrototype.min(this.text.length(), compositeStart + length); - return new TypeScript.TextSpan(compositeStart, compositeEnd - compositeStart); - }; - - SimpleSubText.prototype.charCodeAt = function (index) { - this.checkSubPosition(index); - return this.text.charCodeAt(this.span.start() + index); - }; - - SimpleSubText.prototype.lineMap = function () { - return TypeScript.LineMap1.fromSimpleText(this); - }; - return SimpleSubText; - })(); - - var SimpleStringText = (function () { - function SimpleStringText(value) { - this.value = value; - this._lineMap = null; - } - SimpleStringText.prototype.length = function () { - return this.value.length; - }; - - SimpleStringText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - TypeScript.StringUtilities.copyTo(this.value, sourceIndex, destination, destinationIndex, count); - }; - - SimpleStringText.prototype.substr = function (start, length, intern) { - if (intern) { - var array = length <= SimpleStringText.charArray.length ? SimpleStringText.charArray : TypeScript.ArrayUtilities.createArray(length, 0); - this.copyTo(start, array, 0, length); - return TypeScript.Collections.DefaultStringTable.addCharArray(array, 0, length); - } - - return this.value.substr(start, length); - }; - - SimpleStringText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleStringText.prototype.charCodeAt = function (index) { - return this.value.charCodeAt(index); - }; - - SimpleStringText.prototype.lineMap = function () { - if (!this._lineMap) { - this._lineMap = TypeScript.LineMap1.fromString(this.value); - } - - return this._lineMap; - }; - SimpleStringText.charArray = TypeScript.ArrayUtilities.createArray(1024, 0); - return SimpleStringText; - })(); - - var SimpleScriptSnapshotText = (function () { - function SimpleScriptSnapshotText(scriptSnapshot) { - this.scriptSnapshot = scriptSnapshot; - } - SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { - return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); - }; - - SimpleScriptSnapshotText.prototype.length = function () { - return this.scriptSnapshot.getLength(); - }; - - SimpleScriptSnapshotText.prototype.copyTo = function (sourceIndex, destination, destinationIndex, count) { - var text = this.scriptSnapshot.getText(sourceIndex, sourceIndex + count); - TypeScript.StringUtilities.copyTo(text, 0, destination, destinationIndex, count); - }; - - SimpleScriptSnapshotText.prototype.substr = function (start, length, intern) { - return this.scriptSnapshot.getText(start, start + length); - }; - - SimpleScriptSnapshotText.prototype.subText = function (span) { - return new SimpleSubText(this, span); - }; - - SimpleScriptSnapshotText.prototype.lineMap = function () { - var _this = this; - return new TypeScript.LineMap(function () { - return _this.scriptSnapshot.getLineStartPositions(); - }, this.length()); - }; - return SimpleScriptSnapshotText; - })(); - - function fromString(value) { - return new SimpleStringText(value); - } - SimpleText.fromString = fromString; - - function fromScriptSnapshot(scriptSnapshot) { - return new SimpleScriptSnapshotText(scriptSnapshot); - } - SimpleText.fromScriptSnapshot = fromScriptSnapshot; - })(TypeScript.SimpleText || (TypeScript.SimpleText = {})); - var SimpleText = TypeScript.SimpleText; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (TextUtilities) { - function parseLineStarts(text) { - var length = text.length; - - if (0 === length) { - var result = new Array(); - result.push(0); - return result; - } - - var position = 0; - var index = 0; - var arrayBuilder = new Array(); - var lineNumber = 0; - - while (index < length) { - var c = text.charCodeAt(index); - var lineBreakLength; - - if (c > 13 /* carriageReturn */ && c <= 127) { - index++; - continue; - } else if (c === 13 /* carriageReturn */ && index + 1 < length && text.charCodeAt(index + 1) === 10 /* lineFeed */) { - lineBreakLength = 2; - } else if (c === 10 /* lineFeed */) { - lineBreakLength = 1; - } else { - lineBreakLength = TextUtilities.getLengthOfLineBreak(text, index); - } - - if (0 === lineBreakLength) { - index++; - } else { - arrayBuilder.push(position); - index += lineBreakLength; - position = index; - lineNumber++; - } - } - - arrayBuilder.push(position); - - return arrayBuilder; - } - TextUtilities.parseLineStarts = parseLineStarts; - - function getLengthOfLineBreakSlow(text, index, c) { - if (c === 13 /* carriageReturn */) { - var next = index + 1; - return (next < text.length) && 10 /* lineFeed */ === text.charCodeAt(next) ? 2 : 1; - } else if (isAnyLineBreakCharacter(c)) { - return 1; - } else { - return 0; - } - } - TextUtilities.getLengthOfLineBreakSlow = getLengthOfLineBreakSlow; - - function getLengthOfLineBreak(text, index) { - var c = text.charCodeAt(index); - - if (c > 13 /* carriageReturn */ && c <= 127) { - return 0; - } - - return getLengthOfLineBreakSlow(text, index, c); - } - TextUtilities.getLengthOfLineBreak = getLengthOfLineBreak; - - function isAnyLineBreakCharacter(c) { - return c === 10 /* lineFeed */ || c === 13 /* carriageReturn */ || c === 133 /* nextLine */ || c === 8232 /* lineSeparator */ || c === 8233 /* paragraphSeparator */; - } - TextUtilities.isAnyLineBreakCharacter = isAnyLineBreakCharacter; - })(TypeScript.TextUtilities || (TypeScript.TextUtilities = {})); - var TextUtilities = TypeScript.TextUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextSpan = (function () { - function TextSpan(start, length) { - if (start < 0) { - TypeScript.Errors.argument("start"); - } - - if (length < 0) { - TypeScript.Errors.argument("length"); - } - - this._start = start; - this._length = length; - } - TextSpan.prototype.start = function () { - return this._start; - }; - - TextSpan.prototype.length = function () { - return this._length; - }; - - TextSpan.prototype.end = function () { - return this._start + this._length; - }; - - TextSpan.prototype.isEmpty = function () { - return this._length === 0; - }; - - TextSpan.prototype.containsPosition = function (position) { - return position >= this._start && position < this.end(); - }; - - TextSpan.prototype.containsTextSpan = function (span) { - return span._start >= this._start && span.end() <= this.end(); - }; - - TextSpan.prototype.overlapsWith = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - return overlapStart < overlapEnd; - }; - - TextSpan.prototype.overlap = function (span) { - var overlapStart = TypeScript.MathPrototype.max(this._start, span._start); - var overlapEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (overlapStart < overlapEnd) { - return TextSpan.fromBounds(overlapStart, overlapEnd); - } - - return null; - }; - - TextSpan.prototype.intersectsWithTextSpan = function (span) { - return span._start <= this.end() && span.end() >= this._start; - }; - - TextSpan.prototype.intersectsWith = function (start, length) { - var end = start + length; - return start <= this.end() && end >= this._start; - }; - - TextSpan.prototype.intersectsWithPosition = function (position) { - return position <= this.end() && position >= this._start; - }; - - TextSpan.prototype.intersection = function (span) { - var intersectStart = TypeScript.MathPrototype.max(this._start, span._start); - var intersectEnd = TypeScript.MathPrototype.min(this.end(), span.end()); - - if (intersectStart <= intersectEnd) { - return TextSpan.fromBounds(intersectStart, intersectEnd); - } - - return null; - }; - - TextSpan.fromBounds = function (start, end) { - TypeScript.Debug.assert(start >= 0); - TypeScript.Debug.assert(end - start >= 0); - return new TextSpan(start, end - start); - }; - return TextSpan; - })(); - TypeScript.TextSpan = TextSpan; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextChangeRange = (function () { - function TextChangeRange(span, newLength) { - if (newLength < 0) { - throw TypeScript.Errors.argumentOutOfRange("newLength"); - } - - this._span = span; - this._newLength = newLength; - } - TextChangeRange.prototype.span = function () { - return this._span; - }; - - TextChangeRange.prototype.newLength = function () { - return this._newLength; - }; - - TextChangeRange.prototype.newSpan = function () { - return new TypeScript.TextSpan(this.span().start(), this.newLength()); - }; - - TextChangeRange.prototype.isUnchanged = function () { - return this.span().isEmpty() && this.newLength() === 0; - }; - - TextChangeRange.collapseChangesFromSingleVersion = function (changes) { - var diff = 0; - var start = 1073741823 /* Max31BitInteger */; - var end = 0; - - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - diff += change.newLength() - change.span().length(); - - if (change.span().start() < start) { - start = change.span().start(); - } - - if (change.span().end() > end) { - end = change.span().end(); - } - } - - if (start > end) { - return null; - } - - var combined = TypeScript.TextSpan.fromBounds(start, end); - var newLen = combined.length() + diff; - - return new TextChangeRange(combined, newLen); - }; - - TextChangeRange.collapseChangesAcrossMultipleVersions = function (changes) { - if (changes.length === 0) { - return TextChangeRange.unchanged; - } - - if (changes.length === 1) { - return changes[0]; - } - - var change0 = changes[0]; - - var oldStartN = change0.span().start(); - var oldEndN = change0.span().end(); - var newEndN = oldStartN + change0.newLength(); - - for (var i = 1; i < changes.length; i++) { - var nextChange = changes[i]; - - var oldStart1 = oldStartN; - var oldEnd1 = oldEndN; - var newEnd1 = newEndN; - - var oldStart2 = nextChange.span().start(); - var oldEnd2 = nextChange.span().end(); - var newEnd2 = oldStart2 + nextChange.newLength(); - - oldStartN = TypeScript.MathPrototype.min(oldStart1, oldStart2); - oldEndN = TypeScript.MathPrototype.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); - newEndN = TypeScript.MathPrototype.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); - } - - return new TextChangeRange(TypeScript.TextSpan.fromBounds(oldStartN, oldEndN), newEndN - oldStartN); - }; - TextChangeRange.unchanged = new TextChangeRange(new TypeScript.TextSpan(0, 0), 0); - return TextChangeRange; - })(); - TypeScript.TextChangeRange = TextChangeRange; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CharacterInfo = (function () { - function CharacterInfo() { - } - CharacterInfo.isDecimalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 57 /* _9 */; - }; - CharacterInfo.isOctalDigit = function (c) { - return c >= 48 /* _0 */ && c <= 55 /* _7 */; - }; - - CharacterInfo.isHexDigit = function (c) { - return CharacterInfo.isDecimalDigit(c) || (c >= 65 /* A */ && c <= 70 /* F */) || (c >= 97 /* a */ && c <= 102 /* f */); - }; - - CharacterInfo.hexValue = function (c) { - return CharacterInfo.isDecimalDigit(c) ? (c - 48 /* _0 */) : (c >= 65 /* A */ && c <= 70 /* F */) ? c - 65 /* A */ + 10 : c - 97 /* a */ + 10; - }; - - CharacterInfo.isWhitespace = function (ch) { - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - return true; - } - - return false; - }; - - CharacterInfo.isLineTerminator = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - } - - return false; - }; - return CharacterInfo; - })(); - TypeScript.CharacterInfo = CharacterInfo; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxConstants) { - SyntaxConstants[SyntaxConstants["TriviaNewLineMask"] = 0x00000001] = "TriviaNewLineMask"; - SyntaxConstants[SyntaxConstants["TriviaCommentMask"] = 0x00000002] = "TriviaCommentMask"; - SyntaxConstants[SyntaxConstants["TriviaFullWidthShift"] = 2] = "TriviaFullWidthShift"; - - SyntaxConstants[SyntaxConstants["NodeDataComputed"] = 0x00000001] = "NodeDataComputed"; - SyntaxConstants[SyntaxConstants["NodeIncrementallyUnusableMask"] = 0x00000002] = "NodeIncrementallyUnusableMask"; - SyntaxConstants[SyntaxConstants["NodeParsedInStrictModeMask"] = 0x00000004] = "NodeParsedInStrictModeMask"; - SyntaxConstants[SyntaxConstants["NodeFullWidthShift"] = 3] = "NodeFullWidthShift"; - - SyntaxConstants[SyntaxConstants["IsVariableWidthKeyword"] = 1 << 31] = "IsVariableWidthKeyword"; - })(TypeScript.SyntaxConstants || (TypeScript.SyntaxConstants = {})); - var SyntaxConstants = TypeScript.SyntaxConstants; -})(TypeScript || (TypeScript = {})); -var FormattingOptions = (function () { - function FormattingOptions(useTabs, spacesPerTab, indentSpaces, newLineCharacter) { - this.useTabs = useTabs; - this.spacesPerTab = spacesPerTab; - this.indentSpaces = indentSpaces; - this.newLineCharacter = newLineCharacter; - } - FormattingOptions.defaultOptions = new FormattingOptions(false, 4, 4, "\r\n"); - return FormattingOptions; -})(); -var TypeScript; -(function (TypeScript) { - (function (Indentation) { - function columnForEndOfToken(token, syntaxInformationMap, options) { - return columnForStartOfToken(token, syntaxInformationMap, options) + token.width(); - } - Indentation.columnForEndOfToken = columnForEndOfToken; - - function columnForStartOfToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - var current = token; - while (current !== firstTokenInLine) { - current = syntaxInformationMap.previousToken(current); - - if (current === firstTokenInLine) { - leadingTextInReverse.push(current.trailingTrivia().fullText()); - leadingTextInReverse.push(current.text()); - } else { - leadingTextInReverse.push(current.fullText()); - } - } - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfToken = columnForStartOfToken; - - function columnForStartOfFirstTokenInLineContainingToken(token, syntaxInformationMap, options) { - var firstTokenInLine = syntaxInformationMap.firstTokenInLineContainingToken(token); - var leadingTextInReverse = []; - - collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse); - - return columnForLeadingTextInReverse(leadingTextInReverse, options); - } - Indentation.columnForStartOfFirstTokenInLineContainingToken = columnForStartOfFirstTokenInLineContainingToken; - - function collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse) { - var leadingTrivia = firstTokenInLine.leadingTrivia(); - - for (var i = leadingTrivia.count() - 1; i >= 0; i--) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { - break; - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); - - if (lineSegments.length > 0) { - break; - } - } - - leadingTextInReverse.push(trivia.fullText()); - } - } - - function columnForLeadingTextInReverse(leadingTextInReverse, options) { - var column = 0; - - for (var i = leadingTextInReverse.length - 1; i >= 0; i--) { - var text = leadingTextInReverse[i]; - column = columnForPositionInStringWorker(text, text.length, column, options); - } - - return column; - } - - function columnForPositionInString(input, position, options) { - return columnForPositionInStringWorker(input, position, 0, options); - } - Indentation.columnForPositionInString = columnForPositionInString; - - function columnForPositionInStringWorker(input, position, startColumn, options) { - var column = startColumn; - var spacesPerTab = options.spacesPerTab; - - for (var j = 0; j < position; j++) { - var ch = input.charCodeAt(j); - - if (ch === 9 /* tab */) { - column += spacesPerTab - column % spacesPerTab; - } else { - column++; - } - } - - return column; - } - - function indentationString(column, options) { - var numberOfTabs = 0; - var numberOfSpaces = TypeScript.MathPrototype.max(0, column); - - if (options.useTabs) { - numberOfTabs = Math.floor(column / options.spacesPerTab); - numberOfSpaces -= numberOfTabs * options.spacesPerTab; - } - - return TypeScript.StringUtilities.repeat('\t', numberOfTabs) + TypeScript.StringUtilities.repeat(' ', numberOfSpaces); - } - Indentation.indentationString = indentationString; - - function indentationTrivia(column, options) { - return TypeScript.Syntax.whitespace(this.indentationString(column, options)); - } - Indentation.indentationTrivia = indentationTrivia; - - function firstNonWhitespacePosition(value) { - for (var i = 0; i < value.length; i++) { - var ch = value.charCodeAt(i); - if (!TypeScript.CharacterInfo.isWhitespace(ch)) { - return i; - } - } - - return value.length; - } - Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; - })(TypeScript.Indentation || (TypeScript.Indentation = {})); - var Indentation = TypeScript.Indentation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(TypeScript.LanguageVersion || (TypeScript.LanguageVersion = {})); - var LanguageVersion = TypeScript.LanguageVersion; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ParseOptions = (function () { - function ParseOptions(languageVersion, allowAutomaticSemicolonInsertion) { - this._languageVersion = languageVersion; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - } - ParseOptions.prototype.toJSON = function (key) { - return { allowAutomaticSemicolonInsertion: this._allowAutomaticSemicolonInsertion }; - }; - - ParseOptions.prototype.languageVersion = function () { - return this._languageVersion; - }; - - ParseOptions.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - return ParseOptions; - })(); - TypeScript.ParseOptions = ParseOptions; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionedElement = (function () { - function PositionedElement(parent, element, fullStart) { - this._parent = parent; - this._element = element; - this._fullStart = fullStart; - } - PositionedElement.create = function (parent, element, fullStart) { - if (element === null) { - return null; - } - - if (element.isNode()) { - return new PositionedNode(parent, element, fullStart); - } else if (element.isToken()) { - return new PositionedToken(parent, element, fullStart); - } else if (element.isList()) { - return new PositionedList(parent, element, fullStart); - } else if (element.isSeparatedList()) { - return new PositionedSeparatedList(parent, element, fullStart); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - PositionedElement.prototype.parent = function () { - return this._parent; - }; - - PositionedElement.prototype.parentElement = function () { - return this._parent && this._parent._element; - }; - - PositionedElement.prototype.element = function () { - return this._element; - }; - - PositionedElement.prototype.kind = function () { - return this.element().kind(); - }; - - PositionedElement.prototype.childIndex = function (child) { - return TypeScript.Syntax.childIndex(this.element(), child); - }; - - PositionedElement.prototype.childCount = function () { - return this.element().childCount(); - }; - - PositionedElement.prototype.childAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - return PositionedElement.create(this, this.element().childAt(index), this.fullStart() + offset); - }; - - PositionedElement.prototype.childStart = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEnd = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.childStartAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth(); - }; - - PositionedElement.prototype.childEndAt = function (index) { - var offset = TypeScript.Syntax.childOffsetAt(this.element(), index); - var child = this.element().childAt(index); - return this.fullStart() + offset + child.leadingTriviaWidth() + child.width(); - }; - - PositionedElement.prototype.getPositionedChild = function (child) { - var offset = TypeScript.Syntax.childOffset(this.element(), child); - return PositionedElement.create(this, child, this.fullStart() + offset); - }; - - PositionedElement.prototype.fullStart = function () { - return this._fullStart; - }; - - PositionedElement.prototype.fullEnd = function () { - return this.fullStart() + this.element().fullWidth(); - }; - - PositionedElement.prototype.fullWidth = function () { - return this.element().fullWidth(); - }; - - PositionedElement.prototype.start = function () { - return this.fullStart() + this.element().leadingTriviaWidth(); - }; - - PositionedElement.prototype.end = function () { - return this.fullStart() + this.element().leadingTriviaWidth() + this.element().width(); - }; - - PositionedElement.prototype.root = function () { - var current = this; - while (current.parent() !== null) { - current = current.parent(); - } - - return current; - }; - - PositionedElement.prototype.containingNode = function () { - var current = this.parent(); - - while (current !== null && !current.element().isNode()) { - current = current.parent(); - } - - return current; - }; - return PositionedElement; - })(); - TypeScript.PositionedElement = PositionedElement; - - var PositionedNodeOrToken = (function (_super) { - __extends(PositionedNodeOrToken, _super); - function PositionedNodeOrToken(parent, nodeOrToken, fullStart) { - _super.call(this, parent, nodeOrToken, fullStart); - } - PositionedNodeOrToken.prototype.nodeOrToken = function () { - return this.element(); - }; - return PositionedNodeOrToken; - })(PositionedElement); - TypeScript.PositionedNodeOrToken = PositionedNodeOrToken; - - var PositionedNode = (function (_super) { - __extends(PositionedNode, _super); - function PositionedNode(parent, node, fullStart) { - _super.call(this, parent, node, fullStart); - } - PositionedNode.prototype.node = function () { - return this.element(); - }; - return PositionedNode; - })(PositionedNodeOrToken); - TypeScript.PositionedNode = PositionedNode; - - var PositionedToken = (function (_super) { - __extends(PositionedToken, _super); - function PositionedToken(parent, token, fullStart) { - _super.call(this, parent, token, fullStart); - } - PositionedToken.prototype.token = function () { - return this.element(); - }; - - PositionedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var triviaList = this.token().leadingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = this.start(); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), currentTriviaEndPosition - trivia.fullWidth()); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - - var start = this.fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - var triviaList = this.token().trailingTrivia(); - if (includeSkippedTokens && triviaList && triviaList.hasSkippedToken()) { - var fullStart = this.end(); - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return new PositionedSkippedToken(this, trivia.skippedToken(), fullStart); - } - - fullStart += trivia.fullWidth(); - } - } - - return this.root().node().findToken(this.fullEnd(), includeSkippedTokens); - }; - return PositionedToken; - })(PositionedNodeOrToken); - TypeScript.PositionedToken = PositionedToken; - - var PositionedList = (function (_super) { - __extends(PositionedList, _super); - function PositionedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedList.prototype.list = function () { - return this.element(); - }; - return PositionedList; - })(PositionedElement); - TypeScript.PositionedList = PositionedList; - - var PositionedSeparatedList = (function (_super) { - __extends(PositionedSeparatedList, _super); - function PositionedSeparatedList(parent, list, fullStart) { - _super.call(this, parent, list, fullStart); - } - PositionedSeparatedList.prototype.list = function () { - return this.element(); - }; - return PositionedSeparatedList; - })(PositionedElement); - TypeScript.PositionedSeparatedList = PositionedSeparatedList; - - var PositionedSkippedToken = (function (_super) { - __extends(PositionedSkippedToken, _super); - function PositionedSkippedToken(parentToken, token, fullStart) { - _super.call(this, parentToken.parent(), token, fullStart); - this._parentToken = parentToken; - } - PositionedSkippedToken.prototype.parentToken = function () { - return this._parentToken; - }; - - PositionedSkippedToken.prototype.previousToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var start = this.fullStart(); - - if (includeSkippedTokens) { - var previousToken; - - if (start >= this.parentToken().end()) { - previousToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - - return this.parentToken(); - } else { - previousToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), start - 1); - - if (previousToken) { - return previousToken; - } - } - } - - var start = this.parentToken().fullStart(); - if (start === 0) { - return null; - } - - return this.root().node().findToken(start - 1, includeSkippedTokens); - }; - - PositionedSkippedToken.prototype.nextToken = function (includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - if (this.token().tokenKind === 10 /* EndOfFileToken */) { - return null; - } - - if (includeSkippedTokens) { - var end = this.end(); - var nextToken; - - if (end <= this.parentToken().start()) { - nextToken = TypeScript.Syntax.findSkippedTokenInLeadingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - - return this.parentToken(); - } else { - nextToken = TypeScript.Syntax.findSkippedTokenInTrailingTriviaList(this.parentToken(), end); - - if (nextToken) { - return nextToken; - } - } - } - - return this.root().node().findToken(this.parentToken().fullEnd(), includeSkippedTokens); - }; - return PositionedSkippedToken; - })(PositionedToken); - TypeScript.PositionedSkippedToken = PositionedSkippedToken; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["None"] = 0] = "None"; - SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; - - SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; - - SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; - - SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; - - SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; - - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 128] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 129] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 130] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 131] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 132] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 133] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 134] = "ExportAssignment"; - - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 135] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 136] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 137] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 138] = "IndexMemberDeclaration"; - - SyntaxKind[SyntaxKind["GetAccessor"] = 139] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 140] = "SetAccessor"; - - SyntaxKind[SyntaxKind["PropertySignature"] = 141] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 142] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 143] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 144] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 145] = "MethodSignature"; - - SyntaxKind[SyntaxKind["Block"] = 146] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 147] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 148] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 149] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 150] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 151] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 152] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 153] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 154] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 155] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 156] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 157] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 158] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 159] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 160] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 161] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 162] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - - SyntaxKind[SyntaxKind["PlusExpression"] = 164] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 165] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 166] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 167] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 168] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 169] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 173] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 174] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 175] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 176] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 177] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 178] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 179] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 180] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 181] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 182] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 183] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 184] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 185] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 186] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 187] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 188] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 189] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 190] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 191] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 192] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 193] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 194] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 195] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 196] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 197] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 198] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 199] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 200] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 201] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 202] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 203] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 204] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 205] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 206] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 207] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 208] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 209] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 210] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 211] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 212] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 213] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 214] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 215] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 216] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 217] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 218] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 219] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 220] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 221] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 222] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; - - SyntaxKind[SyntaxKind["VariableDeclaration"] = 224] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 225] = "VariableDeclarator"; - - SyntaxKind[SyntaxKind["ArgumentList"] = 226] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 227] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 228] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 229] = "TypeParameterList"; - - SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 230] = "ExtendsHeritageClause"; - SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 231] = "ImplementsHeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 232] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 233] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 234] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 235] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 236] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 237] = "FinallyClause"; - - SyntaxKind[SyntaxKind["TypeParameter"] = 238] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 239] = "Constraint"; - - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 240] = "SimplePropertyAssignment"; - - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 241] = "FunctionPropertyAssignment"; - - SyntaxKind[SyntaxKind["Parameter"] = 242] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 243] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 244] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 245] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 246] = "ModuleNameModuleReference"; - SyntaxKind[SyntaxKind["Last"] = SyntaxKind.ModuleNameModuleReference] = "Last"; - - SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; - SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; - - SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; - SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; - - SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; - SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; - - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; - - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; - - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; - - SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; - SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; - - SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; - SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; - })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); - var SyntaxKind = TypeScript.SyntaxKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 62 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 63 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 64 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 65 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 67 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 66 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 68 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 69 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 70 /* OpenBraceToken */, - "}": 71 /* CloseBraceToken */, - "(": 72 /* OpenParenToken */, - ")": 73 /* CloseParenToken */, - "[": 74 /* OpenBracketToken */, - "]": 75 /* CloseBracketToken */, - ".": 76 /* DotToken */, - "...": 77 /* DotDotDotToken */, - ";": 78 /* SemicolonToken */, - ",": 79 /* CommaToken */, - "<": 80 /* LessThanToken */, - ">": 81 /* GreaterThanToken */, - "<=": 82 /* LessThanEqualsToken */, - ">=": 83 /* GreaterThanEqualsToken */, - "==": 84 /* EqualsEqualsToken */, - "=>": 85 /* EqualsGreaterThanToken */, - "!=": 86 /* ExclamationEqualsToken */, - "===": 87 /* EqualsEqualsEqualsToken */, - "!==": 88 /* ExclamationEqualsEqualsToken */, - "+": 89 /* PlusToken */, - "-": 90 /* MinusToken */, - "*": 91 /* AsteriskToken */, - "%": 92 /* PercentToken */, - "++": 93 /* PlusPlusToken */, - "--": 94 /* MinusMinusToken */, - "<<": 95 /* LessThanLessThanToken */, - ">>": 96 /* GreaterThanGreaterThanToken */, - ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 98 /* AmpersandToken */, - "|": 99 /* BarToken */, - "^": 100 /* CaretToken */, - "!": 101 /* ExclamationToken */, - "~": 102 /* TildeToken */, - "&&": 103 /* AmpersandAmpersandToken */, - "||": 104 /* BarBarToken */, - "?": 105 /* QuestionToken */, - ":": 106 /* ColonToken */, - "=": 107 /* EqualsToken */, - "+=": 108 /* PlusEqualsToken */, - "-=": 109 /* MinusEqualsToken */, - "*=": 110 /* AsteriskEqualsToken */, - "%=": 111 /* PercentEqualsToken */, - "<<=": 112 /* LessThanLessThanEqualsToken */, - ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 115 /* AmpersandEqualsToken */, - "|=": 116 /* BarEqualsToken */, - "^=": 117 /* CaretEqualsToken */, - "/": 118 /* SlashToken */, - "/=": 119 /* SlashEqualsToken */ - }; - - var kindToText = new Array(); - - for (var name in textToKeywordKind) { - if (textToKeywordKind.hasOwnProperty(name)) { - kindToText[textToKeywordKind[name]] = name; - } - } - - kindToText[62 /* ConstructorKeyword */] = "constructor"; - - function getTokenKind(text) { - if (textToKeywordKind.hasOwnProperty(text)) { - return textToKeywordKind[text]; - } - - return 0 /* None */; - } - SyntaxFacts.getTokenKind = getTokenKind; - - function getText(kind) { - var result = kindToText[kind]; - return result !== undefined ? result : null; - } - SyntaxFacts.getText = getText; - - function isTokenKind(kind) { - return kind >= 9 /* FirstToken */ && kind <= 119 /* LastToken */; - } - SyntaxFacts.isTokenKind = isTokenKind; - - function isAnyKeyword(kind) { - return kind >= 15 /* FirstKeyword */ && kind <= 69 /* LastKeyword */; - } - SyntaxFacts.isAnyKeyword = isAnyKeyword; - - function isStandardKeyword(kind) { - return kind >= 15 /* FirstStandardKeyword */ && kind <= 43 /* LastStandardKeyword */; - } - SyntaxFacts.isStandardKeyword = isStandardKeyword; - - function isFutureReservedKeyword(kind) { - return kind >= 44 /* FirstFutureReservedKeyword */ && kind <= 50 /* LastFutureReservedKeyword */; - } - SyntaxFacts.isFutureReservedKeyword = isFutureReservedKeyword; - - function isFutureReservedStrictKeyword(kind) { - return kind >= 51 /* FirstFutureReservedStrictKeyword */ && kind <= 59 /* LastFutureReservedStrictKeyword */; - } - SyntaxFacts.isFutureReservedStrictKeyword = isFutureReservedStrictKeyword; - - function isAnyPunctuation(kind) { - return kind >= 70 /* FirstPunctuation */ && kind <= 119 /* LastPunctuation */; - } - SyntaxFacts.isAnyPunctuation = isAnyPunctuation; - - function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; - - function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; - } - SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 89 /* PlusToken */: - return 164 /* PlusExpression */; - case 90 /* MinusToken */: - return 165 /* NegateExpression */; - case 102 /* TildeToken */: - return 166 /* BitwiseNotExpression */; - case 101 /* ExclamationToken */: - return 167 /* LogicalNotExpression */; - case 93 /* PlusPlusToken */: - return 168 /* PreIncrementExpression */; - case 94 /* MinusMinusToken */: - return 169 /* PreDecrementExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 93 /* PlusPlusToken */: - return 210 /* PostIncrementExpression */; - case 94 /* MinusMinusToken */: - return 211 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 91 /* AsteriskToken */: - return 205 /* MultiplyExpression */; - - case 118 /* SlashToken */: - return 206 /* DivideExpression */; - - case 92 /* PercentToken */: - return 207 /* ModuloExpression */; - - case 89 /* PlusToken */: - return 208 /* AddExpression */; - - case 90 /* MinusToken */: - return 209 /* SubtractExpression */; - - case 95 /* LessThanLessThanToken */: - return 202 /* LeftShiftExpression */; - - case 96 /* GreaterThanGreaterThanToken */: - return 203 /* SignedRightShiftExpression */; - - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - return 204 /* UnsignedRightShiftExpression */; - - case 80 /* LessThanToken */: - return 196 /* LessThanExpression */; - - case 81 /* GreaterThanToken */: - return 197 /* GreaterThanExpression */; - - case 82 /* LessThanEqualsToken */: - return 198 /* LessThanOrEqualExpression */; - - case 83 /* GreaterThanEqualsToken */: - return 199 /* GreaterThanOrEqualExpression */; - - case 30 /* InstanceOfKeyword */: - return 200 /* InstanceOfExpression */; - - case 29 /* InKeyword */: - return 201 /* InExpression */; - - case 84 /* EqualsEqualsToken */: - return 192 /* EqualsWithTypeConversionExpression */; - - case 86 /* ExclamationEqualsToken */: - return 193 /* NotEqualsWithTypeConversionExpression */; - - case 87 /* EqualsEqualsEqualsToken */: - return 194 /* EqualsExpression */; - - case 88 /* ExclamationEqualsEqualsToken */: - return 195 /* NotEqualsExpression */; - - case 98 /* AmpersandToken */: - return 191 /* BitwiseAndExpression */; - - case 100 /* CaretToken */: - return 190 /* BitwiseExclusiveOrExpression */; - - case 99 /* BarToken */: - return 189 /* BitwiseOrExpression */; - - case 103 /* AmpersandAmpersandToken */: - return 188 /* LogicalAndExpression */; - - case 104 /* BarBarToken */: - return 187 /* LogicalOrExpression */; - - case 116 /* BarEqualsToken */: - return 182 /* OrAssignmentExpression */; - - case 115 /* AmpersandEqualsToken */: - return 180 /* AndAssignmentExpression */; - - case 117 /* CaretEqualsToken */: - return 181 /* ExclusiveOrAssignmentExpression */; - - case 112 /* LessThanLessThanEqualsToken */: - return 183 /* LeftShiftAssignmentExpression */; - - case 113 /* GreaterThanGreaterThanEqualsToken */: - return 184 /* SignedRightShiftAssignmentExpression */; - - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 185 /* UnsignedRightShiftAssignmentExpression */; - - case 108 /* PlusEqualsToken */: - return 175 /* AddAssignmentExpression */; - - case 109 /* MinusEqualsToken */: - return 176 /* SubtractAssignmentExpression */; - - case 110 /* AsteriskEqualsToken */: - return 177 /* MultiplyAssignmentExpression */; - - case 119 /* SlashEqualsToken */: - return 178 /* DivideAssignmentExpression */; - - case 111 /* PercentEqualsToken */: - return 179 /* ModuloAssignmentExpression */; - - case 107 /* EqualsToken */: - return 174 /* AssignmentExpression */; - - case 79 /* CommaToken */: - return 173 /* CommaExpression */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - - function getOperatorTokenFromBinaryExpression(tokenKind) { - switch (tokenKind) { - case 205 /* MultiplyExpression */: - return 91 /* AsteriskToken */; - - case 206 /* DivideExpression */: - return 118 /* SlashToken */; - - case 207 /* ModuloExpression */: - return 92 /* PercentToken */; - - case 208 /* AddExpression */: - return 89 /* PlusToken */; - - case 209 /* SubtractExpression */: - return 90 /* MinusToken */; - - case 202 /* LeftShiftExpression */: - return 95 /* LessThanLessThanToken */; - - case 203 /* SignedRightShiftExpression */: - return 96 /* GreaterThanGreaterThanToken */; - - case 204 /* UnsignedRightShiftExpression */: - return 97 /* GreaterThanGreaterThanGreaterThanToken */; - - case 196 /* LessThanExpression */: - return 80 /* LessThanToken */; - - case 197 /* GreaterThanExpression */: - return 81 /* GreaterThanToken */; - - case 198 /* LessThanOrEqualExpression */: - return 82 /* LessThanEqualsToken */; - - case 199 /* GreaterThanOrEqualExpression */: - return 83 /* GreaterThanEqualsToken */; - - case 200 /* InstanceOfExpression */: - return 30 /* InstanceOfKeyword */; - - case 201 /* InExpression */: - return 29 /* InKeyword */; - - case 192 /* EqualsWithTypeConversionExpression */: - return 84 /* EqualsEqualsToken */; - - case 193 /* NotEqualsWithTypeConversionExpression */: - return 86 /* ExclamationEqualsToken */; - - case 194 /* EqualsExpression */: - return 87 /* EqualsEqualsEqualsToken */; - - case 195 /* NotEqualsExpression */: - return 88 /* ExclamationEqualsEqualsToken */; - - case 191 /* BitwiseAndExpression */: - return 98 /* AmpersandToken */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 100 /* CaretToken */; - - case 189 /* BitwiseOrExpression */: - return 99 /* BarToken */; - - case 188 /* LogicalAndExpression */: - return 103 /* AmpersandAmpersandToken */; - - case 187 /* LogicalOrExpression */: - return 104 /* BarBarToken */; - - case 182 /* OrAssignmentExpression */: - return 116 /* BarEqualsToken */; - - case 180 /* AndAssignmentExpression */: - return 115 /* AmpersandEqualsToken */; - - case 181 /* ExclusiveOrAssignmentExpression */: - return 117 /* CaretEqualsToken */; - - case 183 /* LeftShiftAssignmentExpression */: - return 112 /* LessThanLessThanEqualsToken */; - - case 184 /* SignedRightShiftAssignmentExpression */: - return 113 /* GreaterThanGreaterThanEqualsToken */; - - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - - case 175 /* AddAssignmentExpression */: - return 108 /* PlusEqualsToken */; - - case 176 /* SubtractAssignmentExpression */: - return 109 /* MinusEqualsToken */; - - case 177 /* MultiplyAssignmentExpression */: - return 110 /* AsteriskEqualsToken */; - - case 178 /* DivideAssignmentExpression */: - return 119 /* SlashEqualsToken */; - - case 179 /* ModuloAssignmentExpression */: - return 111 /* PercentEqualsToken */; - - case 174 /* AssignmentExpression */: - return 107 /* EqualsToken */; - - case 173 /* CommaExpression */: - return 79 /* CommaToken */; - - default: - return 0 /* None */; - } - } - SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; - - function isAnyDivideToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideToken = isAnyDivideToken; - - function isAnyDivideOrRegularExpressionToken(kind) { - switch (kind) { - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - case 12 /* RegularExpressionLiteral */: - return true; - default: - return false; - } - } - SyntaxFacts.isAnyDivideOrRegularExpressionToken = isAnyDivideOrRegularExpressionToken; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var isKeywordStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierStartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isIdentifierPartCharacter = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - var isNumericLiteralStart = TypeScript.ArrayUtilities.createArray(127 /* maxAsciiCharacter */, false); - - for (var character = 0; character < 127 /* maxAsciiCharacter */; character++) { - if (character >= 97 /* a */ && character <= 122 /* z */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if ((character >= 65 /* A */ && character <= 90 /* Z */) || character === 95 /* _ */ || character === 36 /* $ */) { - isIdentifierStartCharacter[character] = true; - isIdentifierPartCharacter[character] = true; - } else if (character >= 48 /* _0 */ && character <= 57 /* _9 */) { - isIdentifierPartCharacter[character] = true; - isNumericLiteralStart[character] = true; - } - } - - isNumericLiteralStart[46 /* dot */] = true; - - for (var keywordKind = 15 /* FirstKeyword */; keywordKind <= 69 /* LastKeyword */; keywordKind++) { - var keyword = TypeScript.SyntaxFacts.getText(keywordKind); - isKeywordStartCharacter[keyword.charCodeAt(0)] = true; - } - - var Scanner = (function () { - function Scanner(fileName, text, languageVersion, window) { - if (typeof window === "undefined") { window = TypeScript.ArrayUtilities.createArray(2048, 0); } - this.slidingWindow = new TypeScript.SlidingWindow(this, window, 0, text.length()); - this.fileName = fileName; - this.text = text; - this._languageVersion = languageVersion; - } - Scanner.prototype.languageVersion = function () { - return this._languageVersion; - }; - - Scanner.prototype.fetchMoreItems = function (argument, sourceIndex, window, destinationIndex, spaceAvailable) { - var charactersRemaining = this.text.length() - sourceIndex; - var amountToRead = TypeScript.MathPrototype.min(charactersRemaining, spaceAvailable); - this.text.copyTo(sourceIndex, window, destinationIndex, amountToRead); - return amountToRead; - }; - - Scanner.prototype.currentCharCode = function () { - return this.slidingWindow.currentItem(null); - }; - - Scanner.prototype.absoluteIndex = function () { - return this.slidingWindow.absoluteIndex(); - }; - - Scanner.prototype.setAbsoluteIndex = function (index) { - this.slidingWindow.setAbsoluteIndex(index); - }; - - Scanner.prototype.scan = function (diagnostics, allowRegularExpression) { - var diagnosticsLength = diagnostics.length; - var fullStart = this.slidingWindow.absoluteIndex(); - var leadingTriviaInfo = this.scanTriviaInfo(diagnostics, false); - - var start = this.slidingWindow.absoluteIndex(); - var kindAndFlags = this.scanSyntaxToken(diagnostics, allowRegularExpression); - 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, fullEnd, trailingTriviaInfo, isVariableWidthKeyword); - - return diagnosticsLength !== diagnostics.length ? TypeScript.Syntax.realizeToken(token) : token; - }; - - 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 { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - var fullText = this.text.substr(fullStart, fullEnd - fullStart, false); - return new TypeScript.Syntax.FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - 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(fullText, kind); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo); - } - } else if (trailingTriviaInfo === 0) { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo); - } else { - return new TypeScript.Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo); - } - } - }; - - Scanner.scanTrivia = function (text, start, length, isTrailing) { - var scanner = new Scanner(null, text.subText(new TypeScript.TextSpan(start, length)), 1 /* EcmaScript5 */, Scanner.triviaWindow); - return scanner.scanTrivia(text, start, isTrailing); - }; - - Scanner.prototype.scanTrivia = function (underlyingText, underlyingTextStart, isTrailing) { - var trivia = new Array(); - - while (true) { - if (!this.slidingWindow.isAtEndOfSource()) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - trivia.push(this.scanWhitespaceTrivia(underlyingText, underlyingTextStart)); - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - trivia.push(this.scanSingleLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - if (ch2 === 42 /* asterisk */) { - trivia.push(this.scanMultiLineCommentTrivia(underlyingText, underlyingTextStart)); - continue; - } - - throw TypeScript.Errors.invalidOperation(); - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - trivia.push(this.scanLineTerminatorSequenceTrivia(ch)); - - if (!isTrailing) { - continue; - } - - break; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - return TypeScript.Syntax.triviaList(trivia); - } - }; - - Scanner.prototype.scanTriviaInfo = function (diagnostics, isTrailing) { - var width = 0; - var hasCommentOrNewLine = 0; - - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - - case 47 /* slash */: - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 47 /* slash */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanSingleLineCommentTriviaLength(); - continue; - } - - if (ch2 === 42 /* asterisk */) { - hasCommentOrNewLine |= 2 /* TriviaCommentMask */; - width += this.scanMultiLineCommentTriviaLength(diagnostics); - continue; - } - - break; - - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - hasCommentOrNewLine |= 1 /* TriviaNewLineMask */; - width += this.scanLineTerminatorSequenceLength(ch); - - if (!isTrailing) { - continue; - } - - break; - } - - return (width << 2 /* TriviaFullWidthShift */) | hasCommentOrNewLine; - } - }; - - Scanner.prototype.isNewLineCharacter = function (ch) { - switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - return true; - default: - return false; - } - }; - - Scanner.prototype.scanWhitespaceTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - - var width = 0; - while (true) { - var ch = this.currentCharCode(); - - switch (ch) { - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 12288 /* ideographicSpace */: - - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 65279 /* byteOrderMark */: - this.slidingWindow.moveToNextItem(); - width++; - continue; - } - - break; - } - - return TypeScript.Syntax.deferredTrivia(4 /* WhitespaceTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.slidingWindow.absoluteIndex(); - var width = this.scanSingleLineCommentTriviaLength(); - - return TypeScript.Syntax.deferredTrivia(7 /* SingleLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanSingleLineCommentTriviaLength = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource() || this.isNewLineCharacter(this.currentCharCode())) { - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanMultiLineCommentTrivia = function (underlyingText, underlyingTextStart) { - var absoluteStartIndex = this.absoluteIndex(); - var width = this.scanMultiLineCommentTriviaLength(null); - - return TypeScript.Syntax.deferredTrivia(6 /* MultiLineCommentTrivia */, underlyingText, underlyingTextStart + absoluteStartIndex, width); - }; - - Scanner.prototype.scanMultiLineCommentTriviaLength = function (diagnostics) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - var width = 2; - while (true) { - if (this.slidingWindow.isAtEndOfSource()) { - if (diagnostics !== null) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), this.slidingWindow.absoluteIndex(), 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null)); - } - - return width; - } - - var ch = this.currentCharCode(); - if (ch === 42 /* asterisk */ && this.slidingWindow.peekItemN(1) === 47 /* slash */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - width += 2; - return width; - } - - this.slidingWindow.moveToNextItem(); - width++; - } - }; - - Scanner.prototype.scanLineTerminatorSequenceTrivia = function (ch) { - var absoluteStartIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - var width = this.scanLineTerminatorSequenceLength(ch); - - var text = this.substring(absoluteStartIndex, absoluteStartIndex + width, false); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(absoluteStartIndex); - - return TypeScript.Syntax.trivia(5 /* NewLineTrivia */, text); - }; - - Scanner.prototype.scanLineTerminatorSequenceLength = function (ch) { - this.slidingWindow.moveToNextItem(); - - if (ch === 13 /* carriageReturn */ && this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - return 2; - } else { - return 1; - } - }; - - Scanner.prototype.scanSyntaxToken = function (diagnostics, allowRegularExpression) { - if (this.slidingWindow.isAtEndOfSource()) { - return 10 /* EndOfFileToken */; - } - - var character = this.currentCharCode(); - - switch (character) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - return this.scanStringLiteral(diagnostics); - - case 47 /* slash */: - return this.scanSlashToken(allowRegularExpression); - - case 46 /* dot */: - return this.scanDotToken(diagnostics); - - case 45 /* minus */: - return this.scanMinusToken(); - - case 33 /* exclamation */: - return this.scanExclamationToken(); - - case 61 /* equals */: - return this.scanEqualsToken(); - - case 124 /* bar */: - return this.scanBarToken(); - - case 42 /* asterisk */: - return this.scanAsteriskToken(); - - case 43 /* plus */: - return this.scanPlusToken(); - - case 37 /* percent */: - return this.scanPercentToken(); - - case 38 /* ampersand */: - return this.scanAmpersandToken(); - - case 94 /* caret */: - return this.scanCaretToken(); - - case 60 /* lessThan */: - return this.scanLessThanToken(); - - case 62 /* greaterThan */: - return this.advanceAndSetTokenKind(81 /* GreaterThanToken */); - - case 44 /* comma */: - return this.advanceAndSetTokenKind(79 /* CommaToken */); - - case 58 /* colon */: - return this.advanceAndSetTokenKind(106 /* ColonToken */); - - case 59 /* semicolon */: - return this.advanceAndSetTokenKind(78 /* SemicolonToken */); - - case 126 /* tilde */: - return this.advanceAndSetTokenKind(102 /* TildeToken */); - - case 40 /* openParen */: - return this.advanceAndSetTokenKind(72 /* OpenParenToken */); - - case 41 /* closeParen */: - return this.advanceAndSetTokenKind(73 /* CloseParenToken */); - - case 123 /* openBrace */: - return this.advanceAndSetTokenKind(70 /* OpenBraceToken */); - - case 125 /* closeBrace */: - return this.advanceAndSetTokenKind(71 /* CloseBraceToken */); - - case 91 /* openBracket */: - return this.advanceAndSetTokenKind(74 /* OpenBracketToken */); - - case 93 /* closeBracket */: - return this.advanceAndSetTokenKind(75 /* CloseBracketToken */); - - case 63 /* question */: - return this.advanceAndSetTokenKind(105 /* QuestionToken */); - } - - if (isNumericLiteralStart[character]) { - return this.scanNumericLiteral(diagnostics); - } - - if (isIdentifierStartCharacter[character]) { - var result = this.tryFastScanIdentifierOrKeyword(character); - if (result !== 0 /* None */) { - return result; - } - } - - if (this.isIdentifierStart(this.peekCharOrUnicodeEscape())) { - return this.slowScanIdentifierOrKeyword(diagnostics); - } - - return this.scanDefaultCharacter(character, diagnostics); - }; - - Scanner.prototype.isIdentifierStart = function (interpretedChar) { - if (isIdentifierStartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierStart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.isIdentifierPart = function (interpretedChar) { - if (isIdentifierPartCharacter[interpretedChar]) { - return true; - } - - return interpretedChar > 127 /* maxAsciiCharacter */ && TypeScript.Unicode.isIdentifierPart(interpretedChar, this._languageVersion); - }; - - Scanner.prototype.tryFastScanIdentifierOrKeyword = function (firstCharacter) { - var slidingWindow = this.slidingWindow; - var window = slidingWindow.window; - - var startIndex = slidingWindow.currentRelativeItemIndex; - var endIndex = slidingWindow.windowCount; - var currentIndex = startIndex; - var character = 0; - - while (currentIndex < endIndex) { - character = window[currentIndex]; - if (!isIdentifierPartCharacter[character]) { - break; - } - - currentIndex++; - } - - if (currentIndex === endIndex) { - return 0 /* None */; - } else if (character === 92 /* backslash */ || character > 127 /* maxAsciiCharacter */) { - return 0 /* None */; - } else { - var kind; - var identifierLength = currentIndex - startIndex; - if (isKeywordStartCharacter[firstCharacter]) { - kind = TypeScript.ScannerUtilities.identifierKind(window, startIndex, identifierLength); - } else { - kind = 11 /* IdentifierName */; - } - - slidingWindow.setAbsoluteIndex(slidingWindow.absoluteIndex() + identifierLength); - - return kind; - } - }; - - Scanner.prototype.slowScanIdentifierOrKeyword = function (diagnostics) { - var startIndex = this.slidingWindow.absoluteIndex(); - var sawUnicodeEscape = false; - - do { - var unicodeEscape = this.scanCharOrUnicodeEscape(diagnostics); - sawUnicodeEscape = sawUnicodeEscape || unicodeEscape; - } while(this.isIdentifierPart(this.peekCharOrUnicodeEscape())); - - var length = this.slidingWindow.absoluteIndex() - startIndex; - var text = this.text.substr(startIndex, length, false); - var valueText = TypeScript.Syntax.massageEscapes(text); - - var keywordKind = TypeScript.SyntaxFacts.getTokenKind(valueText); - if (keywordKind >= 15 /* FirstKeyword */ && keywordKind <= 69 /* LastKeyword */) { - if (sawUnicodeEscape) { - return keywordKind | -2147483648 /* IsVariableWidthKeyword */; - } else { - return keywordKind; - } - } - - return 11 /* IdentifierName */; - }; - - Scanner.prototype.scanNumericLiteral = function (diagnostics) { - if (this.isHexNumericLiteral()) { - this.scanHexNumericLiteral(); - } else if (this.isOctalNumericLiteral()) { - this.scanOctalNumericLiteral(diagnostics); - } else { - this.scanDecimalNumericLiteral(); - } - - return 13 /* NumericLiteral */; - }; - - Scanner.prototype.isOctalNumericLiteral = function () { - return this.currentCharCode() === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(this.slidingWindow.peekItemN(1)); - }; - - Scanner.prototype.scanOctalNumericLiteral = function (diagnostics) { - var position = this.absoluteIndex(); - - while (TypeScript.CharacterInfo.isOctalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - - if (this.languageVersion() >= 1 /* EcmaScript5 */) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, this.absoluteIndex() - position, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null)); - } - }; - - Scanner.prototype.scanDecimalDigits = function () { - while (TypeScript.CharacterInfo.isDecimalDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.scanDecimalNumericLiteral = function () { - this.scanDecimalDigits(); - - if (this.currentCharCode() === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - } - - this.scanDecimalDigits(); - - var ch = this.currentCharCode(); - if (ch === 101 /* e */ || ch === 69 /* E */) { - var nextChar1 = this.slidingWindow.peekItemN(1); - - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar1)) { - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } else if (nextChar1 === 45 /* minus */ || nextChar1 === 43 /* plus */) { - var nextChar2 = this.slidingWindow.peekItemN(2); - if (TypeScript.CharacterInfo.isDecimalDigit(nextChar2)) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - this.scanDecimalDigits(); - } - } - } - }; - - Scanner.prototype.scanHexNumericLiteral = function () { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - - while (TypeScript.CharacterInfo.isHexDigit(this.currentCharCode())) { - this.slidingWindow.moveToNextItem(); - } - }; - - Scanner.prototype.isHexNumericLiteral = function () { - if (this.currentCharCode() === 48 /* _0 */) { - var ch = this.slidingWindow.peekItemN(1); - - if (ch === 120 /* x */ || ch === 88 /* X */) { - ch = this.slidingWindow.peekItemN(2); - - return TypeScript.CharacterInfo.isHexDigit(ch); - } - } - - return false; - }; - - Scanner.prototype.advanceAndSetTokenKind = function (kind) { - this.slidingWindow.moveToNextItem(); - return kind; - }; - - Scanner.prototype.scanLessThanToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 82 /* LessThanEqualsToken */; - } else if (this.currentCharCode() === 60 /* lessThan */) { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 112 /* LessThanLessThanEqualsToken */; - } else { - return 95 /* LessThanLessThanToken */; - } - } else { - return 80 /* LessThanToken */; - } - }; - - Scanner.prototype.scanBarToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 116 /* BarEqualsToken */; - } else if (this.currentCharCode() === 124 /* bar */) { - this.slidingWindow.moveToNextItem(); - return 104 /* BarBarToken */; - } else { - return 99 /* BarToken */; - } - }; - - Scanner.prototype.scanCaretToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 117 /* CaretEqualsToken */; - } else { - return 100 /* CaretToken */; - } - }; - - Scanner.prototype.scanAmpersandToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 115 /* AmpersandEqualsToken */; - } else if (this.currentCharCode() === 38 /* ampersand */) { - this.slidingWindow.moveToNextItem(); - return 103 /* AmpersandAmpersandToken */; - } else { - return 98 /* AmpersandToken */; - } - }; - - Scanner.prototype.scanPercentToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 111 /* PercentEqualsToken */; - } else { - return 92 /* PercentToken */; - } - }; - - Scanner.prototype.scanMinusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 109 /* MinusEqualsToken */; - } else if (character === 45 /* minus */) { - this.slidingWindow.moveToNextItem(); - return 94 /* MinusMinusToken */; - } else { - return 90 /* MinusToken */; - } - }; - - Scanner.prototype.scanPlusToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 108 /* PlusEqualsToken */; - } else if (character === 43 /* plus */) { - this.slidingWindow.moveToNextItem(); - return 93 /* PlusPlusToken */; - } else { - return 89 /* PlusToken */; - } - }; - - Scanner.prototype.scanAsteriskToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 110 /* AsteriskEqualsToken */; - } else { - return 91 /* AsteriskToken */; - } - }; - - Scanner.prototype.scanEqualsToken = function () { - this.slidingWindow.moveToNextItem(); - var character = this.currentCharCode(); - if (character === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 87 /* EqualsEqualsEqualsToken */; - } else { - return 84 /* EqualsEqualsToken */; - } - } else if (character === 62 /* greaterThan */) { - this.slidingWindow.moveToNextItem(); - return 85 /* EqualsGreaterThanToken */; - } else { - return 107 /* EqualsToken */; - } - }; - - Scanner.prototype.isDotPrefixedNumericLiteral = function () { - if (this.currentCharCode() === 46 /* dot */) { - var ch = this.slidingWindow.peekItemN(1); - return TypeScript.CharacterInfo.isDecimalDigit(ch); - } - - return false; - }; - - Scanner.prototype.scanDotToken = function (diagnostics) { - if (this.isDotPrefixedNumericLiteral()) { - return this.scanNumericLiteral(diagnostics); - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 46 /* dot */ && this.slidingWindow.peekItemN(1) === 46 /* dot */) { - this.slidingWindow.moveToNextItem(); - this.slidingWindow.moveToNextItem(); - return 77 /* DotDotDotToken */; - } else { - return 76 /* DotToken */; - } - }; - - Scanner.prototype.scanSlashToken = function (allowRegularExpression) { - if (allowRegularExpression) { - var result = this.tryScanRegularExpressionToken(); - if (result !== 0 /* None */) { - return result; - } - } - - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - return 119 /* SlashEqualsToken */; - } else { - return 118 /* SlashToken */; - } - }; - - Scanner.prototype.tryScanRegularExpressionToken = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var inEscape = false; - var inCharacterClass = false; - while (true) { - var ch = this.currentCharCode(); - - if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 0 /* None */; - } - - this.slidingWindow.moveToNextItem(); - if (inEscape) { - inEscape = false; - continue; - } - - switch (ch) { - case 92 /* backslash */: - inEscape = true; - continue; - - case 91 /* openBracket */: - inCharacterClass = true; - continue; - - case 93 /* closeBracket */: - inCharacterClass = false; - continue; - - case 47 /* slash */: - if (inCharacterClass) { - continue; - } - - break; - - default: - continue; - } - - break; - } - - while (isIdentifierPartCharacter[this.currentCharCode()]) { - this.slidingWindow.moveToNextItem(); - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - return 12 /* RegularExpressionLiteral */; - }; - - Scanner.prototype.scanExclamationToken = function () { - this.slidingWindow.moveToNextItem(); - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - if (this.currentCharCode() === 61 /* equals */) { - this.slidingWindow.moveToNextItem(); - - return 88 /* ExclamationEqualsEqualsToken */; - } else { - return 86 /* ExclamationEqualsToken */; - } - } else { - return 101 /* ExclamationToken */; - } - }; - - Scanner.prototype.scanDefaultCharacter = function (character, diagnostics) { - var position = this.slidingWindow.absoluteIndex(); - this.slidingWindow.moveToNextItem(); - - var text = String.fromCharCode(character); - var messageText = this.getErrorMessageText(text); - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), position, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText])); - - return 9 /* ErrorToken */; - }; - - Scanner.prototype.getErrorMessageText = function (text) { - if (text === "\\") { - return '"\\"'; - } - - return JSON.stringify(text); - }; - - Scanner.prototype.skipEscapeSequence = function (diagnostics) { - var rewindPoint = this.slidingWindow.getAndPinAbsoluteIndex(); - - this.slidingWindow.moveToNextItem(); - - var ch = this.currentCharCode(); - this.slidingWindow.moveToNextItem(); - switch (ch) { - case 120 /* x */: - case 117 /* u */: - this.slidingWindow.rewindToPinnedIndex(rewindPoint); - var value = this.scanUnicodeOrHexEscape(diagnostics); - break; - - case 13 /* carriageReturn */: - if (this.currentCharCode() === 10 /* lineFeed */) { - this.slidingWindow.moveToNextItem(); - } - break; - - default: - break; - } - - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint); - }; - - Scanner.prototype.scanStringLiteral = function (diagnostics) { - var quoteCharacter = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - while (true) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - this.skipEscapeSequence(diagnostics); - } else if (ch === quoteCharacter) { - this.slidingWindow.moveToNextItem(); - break; - } else if (this.isNewLineCharacter(ch) || this.slidingWindow.isAtEndOfSource()) { - diagnostics.push(new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), TypeScript.MathPrototype.min(this.slidingWindow.absoluteIndex(), this.text.length()), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null)); - break; - } else { - this.slidingWindow.moveToNextItem(); - } - } - - return 14 /* StringLiteral */; - }; - - Scanner.prototype.isUnicodeEscape = function (character) { - if (character === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - return true; - } - } - - return false; - }; - - Scanner.prototype.peekCharOrUnicodeEscape = function () { - var character = this.currentCharCode(); - if (this.isUnicodeEscape(character)) { - return this.peekUnicodeOrHexEscape(); - } else { - return character; - } - }; - - Scanner.prototype.peekUnicodeOrHexEscape = function () { - var startIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var ch = this.scanUnicodeOrHexEscape(null); - - this.slidingWindow.rewindToPinnedIndex(startIndex); - this.slidingWindow.releaseAndUnpinAbsoluteIndex(startIndex); - - return ch; - }; - - Scanner.prototype.scanCharOrUnicodeEscape = function (errors) { - var ch = this.currentCharCode(); - if (ch === 92 /* backslash */) { - var ch2 = this.slidingWindow.peekItemN(1); - if (ch2 === 117 /* u */) { - this.scanUnicodeOrHexEscape(errors); - return true; - } - } - - this.slidingWindow.moveToNextItem(); - return false; - }; - - Scanner.prototype.scanUnicodeOrHexEscape = function (errors) { - var start = this.slidingWindow.absoluteIndex(); - var character = this.currentCharCode(); - - this.slidingWindow.moveToNextItem(); - - character = this.currentCharCode(); - - var intChar = 0; - this.slidingWindow.moveToNextItem(); - - var count = character === 117 /* u */ ? 4 : 2; - - for (var i = 0; i < count; i++) { - var ch2 = this.currentCharCode(); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - if (errors !== null) { - var end = this.slidingWindow.absoluteIndex(); - var info = this.createIllegalEscapeDiagnostic(start, end); - errors.push(info); - } - - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - this.slidingWindow.moveToNextItem(); - } - - return intChar; - }; - - Scanner.prototype.substring = function (start, end, intern) { - var length = end - start; - var offset = start - this.slidingWindow.windowAbsoluteStartIndex; - - if (intern) { - return TypeScript.Collections.DefaultStringTable.addCharArray(this.slidingWindow.window, offset, length); - } else { - return TypeScript.StringUtilities.fromCharCodeArray(this.slidingWindow.window.slice(offset, offset + length)); - } - }; - - Scanner.prototype.createIllegalEscapeDiagnostic = function (start, end) { - return new TypeScript.Diagnostic(this.fileName, this.text.lineMap(), start, end - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); - }; - - Scanner.isValidIdentifier = function (text, languageVersion) { - var scanner = new Scanner(null, text, languageVersion, Scanner.triviaWindow); - var errors = new Array(); - var token = scanner.scan(errors, false); - - return errors.length === 0 && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token) && token.width() === text.length(); - }; - Scanner.triviaWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - return Scanner; - })(); - TypeScript.Scanner = Scanner; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { - } - ScannerUtilities.identifierKind = function (array, startIndex, length) { - switch (length) { - case 2: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - switch (array[startIndex + 1]) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 3: - switch (array[startIndex]) { - case 102 /* f */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 97 /* a */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 4: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - switch (array[startIndex + 1]) { - case 108 /* l */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 1]) { - case 104 /* h */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 117 /* u */ && array[startIndex + 3] === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 118 /* v */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 5: - switch (array[startIndex]) { - case 98 /* b */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (array[startIndex + 2] === 97 /* a */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 97 /* a */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 114 /* r */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (array[startIndex + 1] === 104 /* h */ && array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 101 /* e */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 6: - switch (array[startIndex]) { - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 108 /* l */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - switch (array[startIndex + 1]) { - case 119 /* w */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 99 /* c */ && array[startIndex + 5] === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - switch (array[startIndex + 2]) { - case 97 /* a */: - return (array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 3] === 105 /* i */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 116 /* t */: - return (array[startIndex + 1] === 121 /* y */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 111 /* o */ && array[startIndex + 5] === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (array[startIndex + 1] === 109 /* m */ && array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 111 /* o */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 100 /* d */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 109 /* m */ && array[startIndex + 3] === 98 /* b */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 7: - switch (array[startIndex]) { - case 100 /* d */: - switch (array[startIndex + 1]) { - case 101 /* e */: - switch (array[startIndex + 2]) { - case 102 /* f */: - return (array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 117 /* u */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - case 99 /* c */: - return (array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 102 /* f */: - return (array[startIndex + 1] === 105 /* i */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 97 /* a */ && array[startIndex + 4] === 108 /* l */ && array[startIndex + 5] === 108 /* l */ && array[startIndex + 6] === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (array[startIndex + 1] === 120 /* x */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 110 /* n */ && array[startIndex + 5] === 100 /* d */ && array[startIndex + 6] === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - switch (array[startIndex + 1]) { - case 97 /* a */: - return (array[startIndex + 2] === 99 /* c */ && array[startIndex + 3] === 107 /* k */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 2] === 105 /* i */ && array[startIndex + 3] === 118 /* v */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 116 /* t */ && array[startIndex + 6] === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 98 /* b */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 97 /* a */ && array[startIndex + 6] === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 113 /* q */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 8: - switch (array[startIndex]) { - case 99 /* c */: - return (array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 105 /* i */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (array[startIndex + 1] === 101 /* e */ && array[startIndex + 2] === 98 /* b */ && array[startIndex + 3] === 117 /* u */ && array[startIndex + 4] === 103 /* g */ && array[startIndex + 5] === 103 /* g */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (array[startIndex + 1] === 117 /* u */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 99 /* c */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 105 /* i */ && array[startIndex + 6] === 111 /* o */ && array[startIndex + 7] === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 9: - switch (array[startIndex]) { - case 105 /* i */: - return (array[startIndex + 1] === 110 /* n */ && array[startIndex + 2] === 116 /* t */ && array[startIndex + 3] === 101 /* e */ && array[startIndex + 4] === 114 /* r */ && array[startIndex + 5] === 102 /* f */ && array[startIndex + 6] === 97 /* a */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (array[startIndex + 1] === 114 /* r */ && array[startIndex + 2] === 111 /* o */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 99 /* c */ && array[startIndex + 6] === 116 /* t */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - case 10: - switch (array[startIndex]) { - case 105 /* i */: - switch (array[startIndex + 1]) { - case 110 /* n */: - return (array[startIndex + 2] === 115 /* s */ && array[startIndex + 3] === 116 /* t */ && array[startIndex + 4] === 97 /* a */ && array[startIndex + 5] === 110 /* n */ && array[startIndex + 6] === 99 /* c */ && array[startIndex + 7] === 101 /* e */ && array[startIndex + 8] === 111 /* o */ && array[startIndex + 9] === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (array[startIndex + 2] === 112 /* p */ && array[startIndex + 3] === 108 /* l */ && array[startIndex + 4] === 101 /* e */ && array[startIndex + 5] === 109 /* m */ && array[startIndex + 6] === 101 /* e */ && array[startIndex + 7] === 110 /* n */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - - default: - return 11 /* IdentifierName */; - } - - case 11: - return (array[startIndex] === 99 /* c */ && array[startIndex + 1] === 111 /* o */ && array[startIndex + 2] === 110 /* n */ && array[startIndex + 3] === 115 /* s */ && array[startIndex + 4] === 116 /* t */ && array[startIndex + 5] === 114 /* r */ && array[startIndex + 6] === 117 /* u */ && array[startIndex + 7] === 99 /* c */ && array[startIndex + 8] === 116 /* t */ && array[startIndex + 9] === 111 /* o */ && array[startIndex + 10] === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; - } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySeparatedSyntaxList = (function () { - function EmptySeparatedSyntaxList() { - } - EmptySeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - EmptySeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isList = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - EmptySeparatedSyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return []; - }; - - EmptySeparatedSyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySeparatedSyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySeparatedSyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySeparatedSyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySeparatedSyntaxList.prototype.width = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - - EmptySeparatedSyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - return EmptySeparatedSyntaxList; - })(); - - Syntax.emptySeparatedList = new EmptySeparatedSyntaxList(); - - var SingletonSeparatedSyntaxList = (function () { - function SingletonSeparatedSyntaxList(item) { - this.item = item; - } - SingletonSeparatedSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - SingletonSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - SingletonSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - - SingletonSeparatedSyntaxList.prototype.childCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return 1; - }; - SingletonSeparatedSyntaxList.prototype.separatorCount = function () { - return 0; - }; - - SingletonSeparatedSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - SingletonSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - return [this.item]; - }; - - SingletonSeparatedSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSeparatedSyntaxList.prototype.separatorAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - SingletonSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSeparatedSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSeparatedSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSeparatedSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSeparatedSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedSeparatedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSeparatedSyntaxList; - })(); - - var NormalSeparatedSyntaxList = (function () { - function NormalSeparatedSyntaxList(elements) { - this._data = 0; - this.elements = elements; - } - NormalSeparatedSyntaxList.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - NormalSeparatedSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isList = function () { - return false; - }; - NormalSeparatedSyntaxList.prototype.isSeparatedList = function () { - return true; - }; - NormalSeparatedSyntaxList.prototype.toJSON = function (key) { - return this.elements; - }; - - NormalSeparatedSyntaxList.prototype.childCount = function () { - return this.elements.length; - }; - NormalSeparatedSyntaxList.prototype.nonSeparatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length + 1, 2); - }; - NormalSeparatedSyntaxList.prototype.separatorCount = function () { - return TypeScript.IntegerUtilities.integerDivide(this.elements.length, 2); - }; - - NormalSeparatedSyntaxList.prototype.toArray = function () { - return this.elements.slice(0); - }; - - NormalSeparatedSyntaxList.prototype.toNonSeparatorArray = function () { - var result = []; - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - result.push(this.nonSeparatorAt(i)); - } - - return result; - }; - - NormalSeparatedSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[index]; - }; - - NormalSeparatedSyntaxList.prototype.nonSeparatorAt = function (index) { - var value = index * 2; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.separatorAt = function (index) { - var value = index * 2 + 1; - if (value < 0 || value >= this.elements.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.elements[value]; - }; - - NormalSeparatedSyntaxList.prototype.firstToken = function () { - var token; - for (var i = 0, n = this.elements.length; i < n; i++) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.firstToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.lastToken = function () { - var token; - for (var i = this.elements.length - 1; i >= 0; i--) { - if (i % 2 === 0) { - var nodeOrToken = this.elements[i]; - token = nodeOrToken.lastToken(); - if (token !== null) { - return token; - } - } else { - token = this.elements[i]; - if (token.width() > 0) { - return token; - } - } - } - - return null; - }; - - NormalSeparatedSyntaxList.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSeparatedSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i).isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSeparatedSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSeparatedSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSeparatedSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSeparatedSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSeparatedSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - fullWidth += childWidth; - - isIncrementallyUnusable = isIncrementallyUnusable || element.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSeparatedSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSeparatedSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedSeparatedList(parent, this, fullStart); - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - - var childWidth = element.fullWidth(); - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSeparatedSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.elements.length; i < n; i++) { - var element = this.elements[i]; - element.collectTextElements(elements); - } - }; - - NormalSeparatedSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.elements); - } else { - array.splice.apply(array, [index, 0].concat(this.elements)); - } - }; - return NormalSeparatedSyntaxList; - })(); - - function separatedList(nodes) { - return separatedListAndValidate(nodes, false); - } - Syntax.separatedList = separatedList; - - function separatedListAndValidate(nodes, validate) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptySeparatedList; - } - - if (validate) { - for (var i = 0; i < nodes.length; i++) { - var item = nodes[i]; - - if (i % 2 === 1) { - } - } - } - - if (nodes.length === 1) { - return new SingletonSeparatedSyntaxList(nodes[0]); - } - - return new NormalSeparatedSyntaxList(nodes); - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SlidingWindow = (function () { - function SlidingWindow(source, window, defaultValue, sourceLength) { - if (typeof sourceLength === "undefined") { sourceLength = -1; } - this.source = source; - this.window = window; - this.defaultValue = defaultValue; - this.sourceLength = sourceLength; - this.windowCount = 0; - this.windowAbsoluteStartIndex = 0; - this.currentRelativeItemIndex = 0; - this._pinCount = 0; - this.firstPinnedAbsoluteIndex = -1; - } - SlidingWindow.prototype.windowAbsoluteEndIndex = function () { - return this.windowAbsoluteStartIndex + this.windowCount; - }; - - SlidingWindow.prototype.addMoreItemsToWindow = function (argument) { - if (this.sourceLength >= 0 && this.absoluteIndex() >= this.sourceLength) { - return false; - } - - if (this.windowCount >= this.window.length) { - this.tryShiftOrGrowWindow(); - } - - var spaceAvailable = this.window.length - this.windowCount; - var amountFetched = this.source.fetchMoreItems(argument, this.windowAbsoluteEndIndex(), this.window, this.windowCount, spaceAvailable); - - this.windowCount += amountFetched; - return amountFetched > 0; - }; - - SlidingWindow.prototype.tryShiftOrGrowWindow = function () { - var currentIndexIsPastWindowHalfwayPoint = this.currentRelativeItemIndex > (this.window.length >>> 1); - - var isAllowedToShift = this.firstPinnedAbsoluteIndex === -1 || this.firstPinnedAbsoluteIndex > this.windowAbsoluteStartIndex; - - if (currentIndexIsPastWindowHalfwayPoint && isAllowedToShift) { - var shiftStartIndex = this.firstPinnedAbsoluteIndex === -1 ? this.currentRelativeItemIndex : this.firstPinnedAbsoluteIndex - this.windowAbsoluteStartIndex; - - var shiftCount = this.windowCount - shiftStartIndex; - - if (shiftCount > 0) { - TypeScript.ArrayUtilities.copy(this.window, shiftStartIndex, this.window, 0, shiftCount); - } - - this.windowAbsoluteStartIndex += shiftStartIndex; - - this.windowCount -= shiftStartIndex; - - this.currentRelativeItemIndex -= shiftStartIndex; - } else { - TypeScript.ArrayUtilities.grow(this.window, this.window.length * 2, this.defaultValue); - } - }; - - SlidingWindow.prototype.absoluteIndex = function () { - return this.windowAbsoluteStartIndex + this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.isAtEndOfSource = function () { - return this.absoluteIndex() >= this.sourceLength; - }; - - SlidingWindow.prototype.getAndPinAbsoluteIndex = function () { - var absoluteIndex = this.absoluteIndex(); - var pinCount = this._pinCount++; - if (pinCount === 0) { - this.firstPinnedAbsoluteIndex = absoluteIndex; - } - - return absoluteIndex; - }; - - SlidingWindow.prototype.releaseAndUnpinAbsoluteIndex = function (absoluteIndex) { - this._pinCount--; - if (this._pinCount === 0) { - this.firstPinnedAbsoluteIndex = -1; - } - }; - - SlidingWindow.prototype.rewindToPinnedIndex = function (absoluteIndex) { - var relativeIndex = absoluteIndex - this.windowAbsoluteStartIndex; - - this.currentRelativeItemIndex = relativeIndex; - }; - - SlidingWindow.prototype.currentItem = function (argument) { - if (this.currentRelativeItemIndex >= this.windowCount) { - if (!this.addMoreItemsToWindow(argument)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex]; - }; - - SlidingWindow.prototype.peekItemN = function (n) { - while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { - return this.defaultValue; - } - } - - return this.window[this.currentRelativeItemIndex + n]; - }; - - SlidingWindow.prototype.moveToNextItem = function () { - this.currentRelativeItemIndex++; - }; - - SlidingWindow.prototype.disgardAllItemsFromCurrentIndexOnwards = function () { - this.windowCount = this.currentRelativeItemIndex; - }; - - SlidingWindow.prototype.setAbsoluteIndex = function (absoluteIndex) { - if (this.absoluteIndex() === absoluteIndex) { - return; - } - - if (this._pinCount > 0) { - } - - if (absoluteIndex >= this.windowAbsoluteStartIndex && absoluteIndex < this.windowAbsoluteEndIndex()) { - this.currentRelativeItemIndex = (absoluteIndex - this.windowAbsoluteStartIndex); - } else { - this.windowAbsoluteStartIndex = absoluteIndex; - - this.windowCount = 0; - - this.currentRelativeItemIndex = 0; - } - }; - - SlidingWindow.prototype.pinCount = function () { - return this._pinCount; - }; - return SlidingWindow; - })(); - TypeScript.SlidingWindow = SlidingWindow; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function emptySourceUnit() { - return TypeScript.Syntax.normalModeFactory.sourceUnit(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(10 /* EndOfFileToken */, { text: "" })); - } - Syntax.emptySourceUnit = emptySourceUnit; - - function getStandaloneExpression(positionedToken) { - var token = positionedToken.token(); - if (positionedToken !== null && positionedToken.kind() === 11 /* IdentifierName */) { - var parentPositionedNode = positionedToken.containingNode(); - var parentNode = parentPositionedNode.node(); - - if (parentNode.kind() === 121 /* QualifiedName */ && parentNode.right === token) { - return parentPositionedNode; - } else if (parentNode.kind() === 212 /* MemberAccessExpression */ && parentNode.name === token) { - return parentPositionedNode; - } - } - - return positionedToken; - } - Syntax.getStandaloneExpression = getStandaloneExpression; - - function isInModuleOrTypeContext(positionedToken) { - if (positionedToken !== null) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var parent = positionedNodeOrToken.containingNode(); - - if (parent !== null) { - switch (parent.kind()) { - case 246 /* ModuleNameModuleReference */: - return true; - case 121 /* QualifiedName */: - return true; - default: - return isInTypeOnlyContext(positionedToken); - } - } - } - - return false; - } - Syntax.isInModuleOrTypeContext = isInModuleOrTypeContext; - - function isInTypeOnlyContext(positionedToken) { - var positionedNodeOrToken = TypeScript.Syntax.getStandaloneExpression(positionedToken); - var positionedParent = positionedNodeOrToken.containingNode(); - - var parent = positionedParent.node(); - var nodeOrToken = positionedNodeOrToken.nodeOrToken(); - - if (parent !== null) { - switch (parent.kind()) { - case 124 /* ArrayType */: - return parent.type === nodeOrToken; - case 220 /* CastExpression */: - return parent.type === nodeOrToken; - case 244 /* TypeAnnotation */: - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - case 228 /* TypeArgumentList */: - return true; - } - } - - return false; - } - Syntax.isInTypeOnlyContext = isInTypeOnlyContext; - - function childOffset(parent, child) { - var offset = 0; - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return offset; - } - - if (current !== null) { - offset += current.fullWidth(); - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childOffset = childOffset; - - function childOffsetAt(parent, index) { - var offset = 0; - for (var i = 0; i < index; i++) { - var current = parent.childAt(i); - if (current !== null) { - offset += current.fullWidth(); - } - } - - return offset; - } - Syntax.childOffsetAt = childOffsetAt; - - function childIndex(parent, child) { - for (var i = 0, n = parent.childCount(); i < n; i++) { - var current = parent.childAt(i); - if (current === child) { - return i; - } - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; - - function nodeStructuralEquals(node1, node2) { - if (node1 === null) { - return node2 === null; - } - - return node1.structuralEquals(node2); - } - Syntax.nodeStructuralEquals = nodeStructuralEquals; - - function nodeOrTokenStructuralEquals(node1, node2) { - if (node1 === node2) { - return true; - } - - if (node1 === null || node2 === null) { - return false; - } - - if (node1.isToken()) { - return node2.isToken() ? tokenStructuralEquals(node1, node2) : false; - } - - return node2.isNode() ? nodeStructuralEquals(node1, node2) : false; - } - Syntax.nodeOrTokenStructuralEquals = nodeOrTokenStructuralEquals; - - function tokenStructuralEquals(token1, token2) { - if (token1 === token2) { - return true; - } - - if (token1 === null || token2 === null) { - return false; - } - - return token1.kind() === token2.kind() && token1.width() === token2.width() && token1.fullWidth() === token2.fullWidth() && token1.text() === token2.text() && TypeScript.Syntax.triviaListStructuralEquals(token1.leadingTrivia(), token2.leadingTrivia()) && TypeScript.Syntax.triviaListStructuralEquals(token1.trailingTrivia(), token2.trailingTrivia()); - } - Syntax.tokenStructuralEquals = tokenStructuralEquals; - - function triviaListStructuralEquals(triviaList1, triviaList2) { - if (triviaList1.count() !== triviaList2.count()) { - return false; - } - - for (var i = 0, n = triviaList1.count(); i < n; i++) { - if (!TypeScript.Syntax.triviaStructuralEquals(triviaList1.syntaxTriviaAt(i), triviaList2.syntaxTriviaAt(i))) { - return false; - } - } - - return true; - } - Syntax.triviaListStructuralEquals = triviaListStructuralEquals; - - function triviaStructuralEquals(trivia1, trivia2) { - return trivia1.kind() === trivia2.kind() && trivia1.fullWidth() === trivia2.fullWidth() && trivia1.fullText() === trivia2.fullText(); - } - Syntax.triviaStructuralEquals = triviaStructuralEquals; - - function listStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var child1 = list1.childAt(i); - var child2 = list2.childAt(i); - - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(child1, child2)) { - return false; - } - } - - return true; - } - Syntax.listStructuralEquals = listStructuralEquals; - - function separatedListStructuralEquals(list1, list2) { - if (list1.childCount() !== list2.childCount()) { - return false; - } - - for (var i = 0, n = list1.childCount(); i < n; i++) { - var element1 = list1.childAt(i); - var element2 = list2.childAt(i); - if (!TypeScript.Syntax.nodeOrTokenStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - } - Syntax.separatedListStructuralEquals = separatedListStructuralEquals; - - function elementStructuralEquals(element1, element2) { - if (element1 === element2) { - return true; - } - - if (element1 === null || element2 === null) { - return false; - } - - if (element2.kind() !== element2.kind()) { - return false; - } - - if (element1.isToken()) { - return tokenStructuralEquals(element1, element2); - } else if (element1.isNode()) { - return nodeStructuralEquals(element1, element2); - } else if (element1.isList()) { - return listStructuralEquals(element1, element2); - } else if (element1.isSeparatedList()) { - return separatedListStructuralEquals(element1, element2); - } - - throw TypeScript.Errors.invalidOperation(); - } - Syntax.elementStructuralEquals = elementStructuralEquals; - - function identifierName(text, info) { - if (typeof info === "undefined") { info = null; } - return TypeScript.Syntax.identifier(text); - } - Syntax.identifierName = identifierName; - - function trueExpression() { - return TypeScript.Syntax.token(37 /* TrueKeyword */); - } - Syntax.trueExpression = trueExpression; - - function falseExpression() { - return TypeScript.Syntax.token(24 /* FalseKeyword */); - } - Syntax.falseExpression = falseExpression; - - function numericLiteralExpression(text) { - return TypeScript.Syntax.token(13 /* NumericLiteral */, { text: text }); - } - Syntax.numericLiteralExpression = numericLiteralExpression; - - function stringLiteralExpression(text) { - return TypeScript.Syntax.token(14 /* StringLiteral */, { text: text }); - } - Syntax.stringLiteralExpression = stringLiteralExpression; - - function isSuperInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperInvocationExpression = isSuperInvocationExpression; - - function isSuperInvocationExpressionStatement(node) { - return node.kind() === 149 /* ExpressionStatement */ && isSuperInvocationExpression(node.expression); - } - Syntax.isSuperInvocationExpressionStatement = isSuperInvocationExpressionStatement; - - function isSuperMemberAccessExpression(node) { - return node.kind() === 212 /* MemberAccessExpression */ && node.expression.kind() === 50 /* SuperKeyword */; - } - Syntax.isSuperMemberAccessExpression = isSuperMemberAccessExpression; - - function isSuperMemberAccessInvocationExpression(node) { - return node.kind() === 213 /* InvocationExpression */ && isSuperMemberAccessExpression(node.expression); - } - Syntax.isSuperMemberAccessInvocationExpression = isSuperMemberAccessInvocationExpression; - - function assignmentExpression(left, token, right) { - return TypeScript.Syntax.normalModeFactory.binaryExpression(174 /* AssignmentExpression */, left, token, right); - } - Syntax.assignmentExpression = assignmentExpression; - - function nodeHasSkippedOrMissingTokens(node) { - for (var i = 0; i < node.childCount(); i++) { - var child = node.childAt(i); - if (child !== null && child.isToken()) { - var token = child; - - if (token.hasSkippedToken() || (token.width() === 0 && token.kind() !== 10 /* EndOfFileToken */)) { - return true; - } - } - } - return false; - } - Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; - - function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { - var text = token.text(); - return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); - } - - return false; - } - Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; - - function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { - var text = trivia.fullText(); - return text.length < 4 || text.substring(text.length - 2) !== "*/"; - } - return false; - } - Syntax.isUnterminatedMultilineCommentTrivia = isUnterminatedMultilineCommentTrivia; - - function isEntirelyInsideCommentTrivia(trivia, fullStart, position) { - if (trivia && trivia.isComment() && position > fullStart) { - var end = fullStart + trivia.fullWidth(); - if (position < end) { - return true; - } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); - } - } - - return false; - } - Syntax.isEntirelyInsideCommentTrivia = isEntirelyInsideCommentTrivia; - - function isEntirelyInsideComment(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - if (positionedToken.token().hasLeadingTrivia()) { - triviaList = positionedToken.token().leadingTrivia(); - } else { - positionedToken = positionedToken.previousToken(); - if (positionedToken) { - if (positionedToken && positionedToken.token().hasTrailingTrivia()) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - } - } else { - if (position <= (fullStart + positionedToken.token().leadingTriviaWidth())) { - triviaList = positionedToken.token().leadingTrivia(); - } else if (position >= (fullStart + positionedToken.token().width())) { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - } - - if (triviaList) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (position <= fullStart) { - break; - } else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) { - lastTriviaBeforeToken = trivia; - break; - } - - fullStart += trivia.fullWidth(); - } - } - - return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position); - } - Syntax.isEntirelyInsideComment = isEntirelyInsideComment; - - function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { - var positionedToken = sourceUnit.findToken(position); - - if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { - positionedToken = positionedToken.previousToken(); - return positionedToken && positionedToken.token().trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken.token()); - } else if (position > positionedToken.start()) { - return (position < positionedToken.end() && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= positionedToken.end() && isUnterminatedStringLiteral(positionedToken.token())); - } - } - - return false; - } - Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - - function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullStart; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullStart = positionedToken.fullStart(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullStart = positionedToken.end(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullStart); - } - - fullStart += triviaWidth; - } - } - - return null; - } - - function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullEnd; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.token().leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } else { - triviaList = positionedToken.token().trailingTrivia(); - fullEnd = positionedToken.fullEnd(); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullEnd) { - return new TypeScript.PositionedSkippedToken(positionedToken, trivia.skippedToken(), fullEnd - triviaWidth); - } - - fullEnd -= triviaWidth; - } - } - - return null; - } - - function findSkippedTokenInLeadingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, true); - } - Syntax.findSkippedTokenInLeadingTriviaList = findSkippedTokenInLeadingTriviaList; - - function findSkippedTokenInTrailingTriviaList(positionedToken, position) { - return findSkippedTokenInTriviaList(positionedToken, position, false); - } - Syntax.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; - - function findSkippedTokenInPositionedToken(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenInPositionedToken = findSkippedTokenInPositionedToken; - - function findSkippedTokenOnLeft(positionedToken, position) { - var positionInLeadingTriviaList = (position < positionedToken.start()); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; - - function getAncestorOfKind(positionedToken, kind) { - while (positionedToken && positionedToken.parent()) { - if (positionedToken.parent().kind() === kind) { - return positionedToken.parent(); - } - - positionedToken = positionedToken.parent(); - } - - return null; - } - Syntax.getAncestorOfKind = getAncestorOfKind; - - function hasAncestorOfKind(positionedToken, kind) { - return TypeScript.Syntax.getAncestorOfKind(positionedToken, kind) !== null; - } - Syntax.hasAncestorOfKind = hasAncestorOfKind; - - function isIntegerLiteral(expression) { - if (expression) { - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - expression = expression.operand; - return expression.isToken() && TypeScript.IntegerUtilities.isInteger(expression.text()); - - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - - return false; - } - Syntax.isIntegerLiteral = isIntegerLiteral; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var NormalModeFactory = (function () { - function NormalModeFactory() { - } - NormalModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, false); - }; - NormalModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, false); - }; - NormalModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, false); - }; - NormalModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - NormalModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, false); - }; - NormalModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, false); - }; - NormalModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, false); - }; - NormalModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, false); - }; - NormalModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, false); - }; - NormalModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, false); - }; - NormalModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, false); - }; - NormalModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, false); - }; - NormalModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(false); - }; - NormalModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, false); - }; - NormalModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, false); - }; - NormalModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, false); - }; - NormalModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, false); - }; - NormalModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, false); - }; - NormalModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, false); - }; - NormalModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, false); - }; - NormalModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, false); - }; - NormalModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, false); - }; - NormalModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, false); - }; - NormalModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, false); - }; - NormalModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, false); - }; - NormalModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, false); - }; - NormalModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, false); - }; - NormalModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, false); - }; - NormalModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, false); - }; - NormalModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, false); - }; - NormalModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, false); - }; - NormalModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, false); - }; - NormalModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, false); - }; - NormalModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, false); - }; - NormalModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, false); - }; - NormalModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, false); - }; - NormalModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, false); - }; - NormalModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, false); - }; - NormalModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, false); - }; - NormalModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, false); - }; - NormalModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, false); - }; - NormalModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, false); - }; - NormalModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - NormalModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, false); - }; - NormalModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, false); - }; - NormalModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, false); - }; - NormalModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, false); - }; - NormalModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, false); - }; - NormalModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, false); - }; - NormalModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, false); - }; - NormalModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, false); - }; - NormalModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, false); - }; - NormalModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, false); - }; - NormalModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, false); - }; - NormalModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, false); - }; - NormalModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, false); - }; - NormalModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, false); - }; - NormalModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, false); - }; - NormalModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, false); - }; - NormalModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, false); - }; - NormalModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, false); - }; - NormalModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, false); - }; - NormalModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, false); - }; - NormalModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, false); - }; - NormalModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, false); - }; - NormalModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, false); - }; - NormalModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, false); - }; - NormalModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, false); - }; - NormalModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, false); - }; - NormalModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, false); - }; - NormalModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, false); - }; - return NormalModeFactory; - })(); - Syntax.NormalModeFactory = NormalModeFactory; - - var StrictModeFactory = (function () { - function StrictModeFactory() { - } - StrictModeFactory.prototype.sourceUnit = function (moduleElements, endOfFileToken) { - return new TypeScript.SourceUnitSyntax(moduleElements, endOfFileToken, true); - }; - StrictModeFactory.prototype.externalModuleReference = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - return new TypeScript.ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, true); - }; - StrictModeFactory.prototype.moduleNameModuleReference = function (moduleName) { - return new TypeScript.ModuleNameModuleReferenceSyntax(moduleName, true); - }; - StrictModeFactory.prototype.importDeclaration = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new TypeScript.ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, true); - }; - StrictModeFactory.prototype.exportAssignment = function (exportKeyword, equalsToken, identifier, semicolonToken) { - return new TypeScript.ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.classDeclaration = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - return new TypeScript.ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.interfaceDeclaration = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - return new TypeScript.InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, true); - }; - StrictModeFactory.prototype.heritageClause = function (kind, extendsOrImplementsKeyword, typeNames) { - return new TypeScript.HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, true); - }; - StrictModeFactory.prototype.moduleDeclaration = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - return new TypeScript.ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.functionDeclaration = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - return new TypeScript.FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, true); - }; - StrictModeFactory.prototype.variableStatement = function (modifiers, variableDeclaration, semicolonToken) { - return new TypeScript.VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, true); - }; - StrictModeFactory.prototype.variableDeclaration = function (varKeyword, variableDeclarators) { - return new TypeScript.VariableDeclarationSyntax(varKeyword, variableDeclarators, true); - }; - StrictModeFactory.prototype.variableDeclarator = function (propertyName, typeAnnotation, equalsValueClause) { - return new TypeScript.VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.equalsValueClause = function (equalsToken, value) { - return new TypeScript.EqualsValueClauseSyntax(equalsToken, value, true); - }; - StrictModeFactory.prototype.prefixUnaryExpression = function (kind, operatorToken, operand) { - return new TypeScript.PrefixUnaryExpressionSyntax(kind, operatorToken, operand, true); - }; - StrictModeFactory.prototype.arrayLiteralExpression = function (openBracketToken, expressions, closeBracketToken) { - return new TypeScript.ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, true); - }; - StrictModeFactory.prototype.omittedExpression = function () { - return new TypeScript.OmittedExpressionSyntax(true); - }; - StrictModeFactory.prototype.parenthesizedExpression = function (openParenToken, expression, closeParenToken) { - return new TypeScript.ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, true); - }; - StrictModeFactory.prototype.simpleArrowFunctionExpression = function (identifier, equalsGreaterThanToken, block, expression) { - return new TypeScript.SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.parenthesizedArrowFunctionExpression = function (callSignature, equalsGreaterThanToken, block, expression) { - return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, true); - }; - StrictModeFactory.prototype.qualifiedName = function (left, dotToken, right) { - return new TypeScript.QualifiedNameSyntax(left, dotToken, right, true); - }; - StrictModeFactory.prototype.typeArgumentList = function (lessThanToken, typeArguments, greaterThanToken) { - return new TypeScript.TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, true); - }; - StrictModeFactory.prototype.constructorType = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.functionType = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - return new TypeScript.FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, true); - }; - StrictModeFactory.prototype.objectType = function (openBraceToken, typeMembers, closeBraceToken) { - return new TypeScript.ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, true); - }; - StrictModeFactory.prototype.arrayType = function (type, openBracketToken, closeBracketToken) { - return new TypeScript.ArrayTypeSyntax(type, openBracketToken, closeBracketToken, true); - }; - StrictModeFactory.prototype.genericType = function (name, typeArgumentList) { - return new TypeScript.GenericTypeSyntax(name, typeArgumentList, true); - }; - StrictModeFactory.prototype.typeQuery = function (typeOfKeyword, name) { - return new TypeScript.TypeQuerySyntax(typeOfKeyword, name, true); - }; - StrictModeFactory.prototype.typeAnnotation = function (colonToken, type) { - return new TypeScript.TypeAnnotationSyntax(colonToken, type, true); - }; - StrictModeFactory.prototype.block = function (openBraceToken, statements, closeBraceToken) { - return new TypeScript.BlockSyntax(openBraceToken, statements, closeBraceToken, true); - }; - StrictModeFactory.prototype.parameter = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - return new TypeScript.ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, true); - }; - StrictModeFactory.prototype.memberAccessExpression = function (expression, dotToken, name) { - return new TypeScript.MemberAccessExpressionSyntax(expression, dotToken, name, true); - }; - StrictModeFactory.prototype.postfixUnaryExpression = function (kind, operand, operatorToken) { - return new TypeScript.PostfixUnaryExpressionSyntax(kind, operand, operatorToken, true); - }; - StrictModeFactory.prototype.elementAccessExpression = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - return new TypeScript.ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, true); - }; - StrictModeFactory.prototype.invocationExpression = function (expression, argumentList) { - return new TypeScript.InvocationExpressionSyntax(expression, argumentList, true); - }; - StrictModeFactory.prototype.argumentList = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - return new TypeScript.ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, true); - }; - StrictModeFactory.prototype.binaryExpression = function (kind, left, operatorToken, right) { - return new TypeScript.BinaryExpressionSyntax(kind, left, operatorToken, right, true); - }; - StrictModeFactory.prototype.conditionalExpression = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - return new TypeScript.ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, true); - }; - StrictModeFactory.prototype.constructSignature = function (newKeyword, callSignature) { - return new TypeScript.ConstructSignatureSyntax(newKeyword, callSignature, true); - }; - StrictModeFactory.prototype.methodSignature = function (propertyName, questionToken, callSignature) { - return new TypeScript.MethodSignatureSyntax(propertyName, questionToken, callSignature, true); - }; - StrictModeFactory.prototype.indexSignature = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - return new TypeScript.IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.propertySignature = function (propertyName, questionToken, typeAnnotation) { - return new TypeScript.PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, true); - }; - StrictModeFactory.prototype.callSignature = function (typeParameterList, parameterList, typeAnnotation) { - return new TypeScript.CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, true); - }; - StrictModeFactory.prototype.parameterList = function (openParenToken, parameters, closeParenToken) { - return new TypeScript.ParameterListSyntax(openParenToken, parameters, closeParenToken, true); - }; - StrictModeFactory.prototype.typeParameterList = function (lessThanToken, typeParameters, greaterThanToken) { - return new TypeScript.TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, true); - }; - StrictModeFactory.prototype.typeParameter = function (identifier, constraint) { - return new TypeScript.TypeParameterSyntax(identifier, constraint, true); - }; - StrictModeFactory.prototype.constraint = function (extendsKeyword, type) { - return new TypeScript.ConstraintSyntax(extendsKeyword, type, true); - }; - StrictModeFactory.prototype.elseClause = function (elseKeyword, statement) { - return new TypeScript.ElseClauseSyntax(elseKeyword, statement, true); - }; - StrictModeFactory.prototype.ifStatement = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - return new TypeScript.IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, true); - }; - StrictModeFactory.prototype.expressionStatement = function (expression, semicolonToken) { - return new TypeScript.ExpressionStatementSyntax(expression, 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); - }; - StrictModeFactory.prototype.getAccessor = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - return new TypeScript.GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, true); - }; - StrictModeFactory.prototype.setAccessor = function (modifiers, setKeyword, propertyName, parameterList, block) { - return new TypeScript.SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, true); - }; - StrictModeFactory.prototype.memberVariableDeclaration = function (modifiers, variableDeclarator, semicolonToken) { - return new TypeScript.MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, true); - }; - StrictModeFactory.prototype.indexMemberDeclaration = function (modifiers, indexSignature, semicolonToken) { - return new TypeScript.IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, true); - }; - StrictModeFactory.prototype.throwStatement = function (throwKeyword, expression, semicolonToken) { - return new TypeScript.ThrowStatementSyntax(throwKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.returnStatement = function (returnKeyword, expression, semicolonToken) { - return new TypeScript.ReturnStatementSyntax(returnKeyword, expression, semicolonToken, true); - }; - StrictModeFactory.prototype.objectCreationExpression = function (newKeyword, expression, argumentList) { - return new TypeScript.ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, true); - }; - StrictModeFactory.prototype.switchStatement = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - return new TypeScript.SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, true); - }; - StrictModeFactory.prototype.caseSwitchClause = function (caseKeyword, expression, colonToken, statements) { - return new TypeScript.CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, true); - }; - StrictModeFactory.prototype.defaultSwitchClause = function (defaultKeyword, colonToken, statements) { - return new TypeScript.DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, true); - }; - StrictModeFactory.prototype.breakStatement = function (breakKeyword, identifier, semicolonToken) { - return new TypeScript.BreakStatementSyntax(breakKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.continueStatement = function (continueKeyword, identifier, semicolonToken) { - return new TypeScript.ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, true); - }; - StrictModeFactory.prototype.forStatement = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - return new TypeScript.ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.forInStatement = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - return new TypeScript.ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.whileStatement = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.withStatement = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - return new TypeScript.WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, true); - }; - StrictModeFactory.prototype.enumDeclaration = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - return new TypeScript.EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, true); - }; - StrictModeFactory.prototype.enumElement = function (propertyName, equalsValueClause) { - return new TypeScript.EnumElementSyntax(propertyName, equalsValueClause, true); - }; - StrictModeFactory.prototype.castExpression = function (lessThanToken, type, greaterThanToken, expression) { - return new TypeScript.CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, true); - }; - StrictModeFactory.prototype.objectLiteralExpression = function (openBraceToken, propertyAssignments, closeBraceToken) { - return new TypeScript.ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, true); - }; - StrictModeFactory.prototype.simplePropertyAssignment = function (propertyName, colonToken, expression) { - return new TypeScript.SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, true); - }; - StrictModeFactory.prototype.functionPropertyAssignment = function (propertyName, callSignature, block) { - return new TypeScript.FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, true); - }; - StrictModeFactory.prototype.functionExpression = function (functionKeyword, identifier, callSignature, block) { - return new TypeScript.FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, true); - }; - StrictModeFactory.prototype.emptyStatement = function (semicolonToken) { - return new TypeScript.EmptyStatementSyntax(semicolonToken, true); - }; - StrictModeFactory.prototype.tryStatement = function (tryKeyword, block, catchClause, finallyClause) { - return new TypeScript.TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, true); - }; - StrictModeFactory.prototype.catchClause = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - return new TypeScript.CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, true); - }; - StrictModeFactory.prototype.finallyClause = function (finallyKeyword, block) { - return new TypeScript.FinallyClauseSyntax(finallyKeyword, block, true); - }; - StrictModeFactory.prototype.labeledStatement = function (identifier, colonToken, statement) { - return new TypeScript.LabeledStatementSyntax(identifier, colonToken, statement, true); - }; - StrictModeFactory.prototype.doStatement = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - return new TypeScript.DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, true); - }; - StrictModeFactory.prototype.typeOfExpression = function (typeOfKeyword, expression) { - return new TypeScript.TypeOfExpressionSyntax(typeOfKeyword, expression, true); - }; - StrictModeFactory.prototype.deleteExpression = function (deleteKeyword, expression) { - return new TypeScript.DeleteExpressionSyntax(deleteKeyword, expression, true); - }; - StrictModeFactory.prototype.voidExpression = function (voidKeyword, expression) { - return new TypeScript.VoidExpressionSyntax(voidKeyword, expression, true); - }; - StrictModeFactory.prototype.debuggerStatement = function (debuggerKeyword, semicolonToken) { - return new TypeScript.DebuggerStatementSyntax(debuggerKeyword, semicolonToken, true); - }; - return StrictModeFactory; - })(); - Syntax.StrictModeFactory = StrictModeFactory; - - Syntax.normalModeFactory = new NormalModeFactory(); - Syntax.strictModeFactory = new StrictModeFactory(); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (SyntaxFacts) { - function isDirectivePrologueElement(node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === 14 /* StringLiteral */) { - return true; - } - } - - return false; - } - SyntaxFacts.isDirectivePrologueElement = isDirectivePrologueElement; - - function isUseStrictDirective(node) { - var expressionStatement = node; - var stringLiteral = expressionStatement.expression; - - var text = stringLiteral.text(); - return text === '"use strict"' || text === "'use strict'"; - } - SyntaxFacts.isUseStrictDirective = isUseStrictDirective; - - function isIdentifierNameOrAnyKeyword(token) { - var tokenKind = token.tokenKind; - return tokenKind === 11 /* IdentifierName */ || TypeScript.SyntaxFacts.isAnyKeyword(tokenKind); - } - SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; - })(TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); - var SyntaxFacts = TypeScript.SyntaxFacts; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var EmptySyntaxList = (function () { - function EmptySyntaxList() { - } - EmptySyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - EmptySyntaxList.prototype.isNode = function () { - return false; - }; - EmptySyntaxList.prototype.isToken = function () { - return false; - }; - EmptySyntaxList.prototype.isList = function () { - return true; - }; - EmptySyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - EmptySyntaxList.prototype.toJSON = function (key) { - return []; - }; - - EmptySyntaxList.prototype.childCount = function () { - return 0; - }; - - EmptySyntaxList.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptySyntaxList.prototype.toArray = function () { - return []; - }; - - EmptySyntaxList.prototype.collectTextElements = function (elements) { - }; - - EmptySyntaxList.prototype.firstToken = function () { - return null; - }; - - EmptySyntaxList.prototype.lastToken = function () { - return null; - }; - - EmptySyntaxList.prototype.fullWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.width = function () { - return 0; - }; - - EmptySyntaxList.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - EmptySyntaxList.prototype.leadingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.trailingTriviaWidth = function () { - return 0; - }; - - EmptySyntaxList.prototype.fullText = function () { - return ""; - }; - - EmptySyntaxList.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptySyntaxList.prototype.isIncrementallyUnusable = function () { - return false; - }; - - EmptySyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - throw TypeScript.Errors.invalidOperation(); - }; - - EmptySyntaxList.prototype.insertChildrenInto = function (array, index) { - }; - return EmptySyntaxList; - })(); - Syntax.EmptySyntaxList = EmptySyntaxList; - - Syntax.emptyList = new EmptySyntaxList(); - - var SingletonSyntaxList = (function () { - function SingletonSyntaxList(item) { - this.item = item; - } - SingletonSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - SingletonSyntaxList.prototype.isToken = function () { - return false; - }; - SingletonSyntaxList.prototype.isNode = function () { - return false; - }; - SingletonSyntaxList.prototype.isList = function () { - return true; - }; - SingletonSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - SingletonSyntaxList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxList.prototype.childCount = function () { - return 1; - }; - - SingletonSyntaxList.prototype.childAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxList.prototype.firstToken = function () { - return this.item.firstToken(); - }; - - SingletonSyntaxList.prototype.lastToken = function () { - return this.item.lastToken(); - }; - - SingletonSyntaxList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxList.prototype.width = function () { - return this.item.width(); - }; - - SingletonSyntaxList.prototype.leadingTrivia = function () { - return this.item.leadingTrivia(); - }; - - SingletonSyntaxList.prototype.trailingTrivia = function () { - return this.item.trailingTrivia(); - }; - - SingletonSyntaxList.prototype.leadingTriviaWidth = function () { - return this.item.leadingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.trailingTriviaWidth = function () { - return this.item.trailingTriviaWidth(); - }; - - SingletonSyntaxList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxList.prototype.isTypeScriptSpecific = function () { - return this.item.isTypeScriptSpecific(); - }; - - SingletonSyntaxList.prototype.isIncrementallyUnusable = function () { - return this.item.isIncrementallyUnusable(); - }; - - SingletonSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - return this.item.findTokenInternal(new TypeScript.PositionedList(parent, this, fullStart), position, fullStart); - }; - - SingletonSyntaxList.prototype.insertChildrenInto = function (array, index) { - array.splice(index, 0, this.item); - }; - return SingletonSyntaxList; - })(); - - var NormalSyntaxList = (function () { - function NormalSyntaxList(nodeOrTokens) { - this._data = 0; - this.nodeOrTokens = nodeOrTokens; - } - NormalSyntaxList.prototype.kind = function () { - return 1 /* List */; - }; - - NormalSyntaxList.prototype.isNode = function () { - return false; - }; - NormalSyntaxList.prototype.isToken = function () { - return false; - }; - NormalSyntaxList.prototype.isList = function () { - return true; - }; - NormalSyntaxList.prototype.isSeparatedList = function () { - return false; - }; - - NormalSyntaxList.prototype.toJSON = function (key) { - return this.nodeOrTokens; - }; - - NormalSyntaxList.prototype.childCount = function () { - return this.nodeOrTokens.length; - }; - - NormalSyntaxList.prototype.childAt = function (index) { - if (index < 0 || index >= this.nodeOrTokens.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.nodeOrTokens[index]; - }; - - NormalSyntaxList.prototype.toArray = function () { - return this.nodeOrTokens.slice(0); - }; - - NormalSyntaxList.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var element = this.nodeOrTokens[i]; - element.collectTextElements(elements); - } - }; - - NormalSyntaxList.prototype.firstToken = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var token = this.nodeOrTokens[i].firstToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.lastToken = function () { - for (var i = this.nodeOrTokens.length - 1; i >= 0; i--) { - var token = this.nodeOrTokens[i].lastToken(); - if (token !== null) { - return token; - } - } - - return null; - }; - - NormalSyntaxList.prototype.fullText = function () { - var elements = new Array(); - this.collectTextElements(elements); - return elements.join(""); - }; - - NormalSyntaxList.prototype.isTypeScriptSpecific = function () { - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - if (this.nodeOrTokens[i].isTypeScriptSpecific()) { - return true; - } - } - - return false; - }; - - NormalSyntaxList.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - NormalSyntaxList.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - NormalSyntaxList.prototype.width = function () { - var fullWidth = this.fullWidth(); - return fullWidth - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.leadingTrivia = function () { - return this.firstToken().leadingTrivia(); - }; - - NormalSyntaxList.prototype.trailingTrivia = function () { - return this.lastToken().trailingTrivia(); - }; - - NormalSyntaxList.prototype.leadingTriviaWidth = function () { - return this.firstToken().leadingTriviaWidth(); - }; - - NormalSyntaxList.prototype.trailingTriviaWidth = function () { - return this.lastToken().trailingTriviaWidth(); - }; - - NormalSyntaxList.prototype.computeData = function () { - var fullWidth = 0; - var isIncrementallyUnusable = false; - - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var node = this.nodeOrTokens[i]; - fullWidth += node.fullWidth(); - isIncrementallyUnusable = isIncrementallyUnusable || node.isIncrementallyUnusable(); - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - NormalSyntaxList.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data = this.computeData(); - } - - return this._data; - }; - - NormalSyntaxList.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedList(parent, this, fullStart); - for (var i = 0, n = this.nodeOrTokens.length; i < n; i++) { - var nodeOrToken = this.nodeOrTokens[i]; - - var childWidth = nodeOrToken.fullWidth(); - if (position < childWidth) { - return nodeOrToken.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - NormalSyntaxList.prototype.insertChildrenInto = function (array, index) { - if (index === 0) { - array.unshift.apply(array, this.nodeOrTokens); - } else { - array.splice.apply(array, [index, 0].concat(this.nodeOrTokens)); - } - }; - return NormalSyntaxList; - })(); - - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return Syntax.emptyList; - } - - if (nodes.length === 1) { - var item = nodes[0]; - return new SingletonSyntaxList(item); - } - - return new NormalSyntaxList(nodes); - } - Syntax.list = list; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(parsedInStrictMode) { - this._data = parsedInStrictMode ? 4 /* NodeParsedInStrictModeMask */ : 0; - } - SyntaxNode.prototype.isNode = function () { - return true; - }; - SyntaxNode.prototype.isToken = function () { - return false; - }; - SyntaxNode.prototype.isList = function () { - return false; - }; - SyntaxNode.prototype.isSeparatedList = function () { - return false; - }; - - SyntaxNode.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childCount = function () { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.childAt = function (slot) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.firstToken = function () { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.firstToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.lastToken = function () { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.fullWidth() > 0 || element.kind() === 10 /* EndOfFileToken */) { - return element.lastToken(); - } - } - } - - return null; - }; - - SyntaxNode.prototype.insertChildrenInto = function (array, index) { - for (var i = this.childCount() - 1; i >= 0; i--) { - var element = this.childAt(i); - - if (element !== null) { - if (element.isNode() || element.isToken()) { - array.splice(index, 0, element); - } else if (element.isList()) { - element.insertChildrenInto(array, index); - } else if (element.isSeparatedList()) { - element.insertChildrenInto(array, index); - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - } - }; - - SyntaxNode.prototype.leadingTrivia = function () { - var firstToken = this.firstToken(); - return firstToken ? firstToken.leadingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.trailingTrivia = function () { - var lastToken = this.lastToken(); - return lastToken ? lastToken.trailingTrivia() : TypeScript.Syntax.emptyTriviaList; - }; - - SyntaxNode.prototype.toJSON = function (key) { - var result = { - kind: TypeScript.SyntaxKind[this.kind()], - fullWidth: this.fullWidth() - }; - - if (this.isIncrementallyUnusable()) { - result.isIncrementallyUnusable = true; - } - - if (this.parsedInStrictMode()) { - 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 === thisAsIndexable[name]) { - result[name] = value; - break; - } - } - } - } - - return result; - }; - - SyntaxNode.prototype.accept = function (visitor) { - throw TypeScript.Errors.abstract(); - }; - - SyntaxNode.prototype.fullText = function () { - var elements = []; - this.collectTextElements(elements); - return elements.join(""); - }; - - SyntaxNode.prototype.collectTextElements = function (elements) { - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - element.collectTextElements(elements); - } - } - }; - - SyntaxNode.prototype.replaceToken = function (token1, token2) { - if (token1 === token2) { - return this; - } - - return this.accept(new TypeScript.SyntaxTokenReplacer(token1, token2)); - }; - - SyntaxNode.prototype.withLeadingTrivia = function (trivia) { - return this.replaceToken(this.firstToken(), this.firstToken().withLeadingTrivia(trivia)); - }; - - SyntaxNode.prototype.withTrailingTrivia = function (trivia) { - return this.replaceToken(this.lastToken(), this.lastToken().withTrailingTrivia(trivia)); - }; - - SyntaxNode.prototype.hasLeadingTrivia = function () { - return this.lastToken().hasLeadingTrivia(); - }; - - SyntaxNode.prototype.hasTrailingTrivia = function () { - return this.lastToken().hasTrailingTrivia(); - }; - - SyntaxNode.prototype.isTypeScriptSpecific = function () { - return false; - }; - - SyntaxNode.prototype.isIncrementallyUnusable = function () { - return (this.data() & 2 /* NodeIncrementallyUnusableMask */) !== 0; - }; - - SyntaxNode.prototype.parsedInStrictMode = function () { - return (this.data() & 4 /* NodeParsedInStrictModeMask */) !== 0; - }; - - SyntaxNode.prototype.fullWidth = function () { - return this.data() >>> 3 /* NodeFullWidthShift */; - }; - - SyntaxNode.prototype.computeData = function () { - var slotCount = this.childCount(); - - var fullWidth = 0; - var childWidth = 0; - - var isIncrementallyUnusable = ((this._data & 2 /* NodeIncrementallyUnusableMask */) !== 0) || slotCount === 0; - - for (var i = 0, n = slotCount; i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - childWidth = element.fullWidth(); - fullWidth += childWidth; - - if (!isIncrementallyUnusable) { - isIncrementallyUnusable = element.isIncrementallyUnusable(); - } - } - } - - return (fullWidth << 3 /* NodeFullWidthShift */) | (isIncrementallyUnusable ? 2 /* NodeIncrementallyUnusableMask */ : 0) | 1 /* NodeDataComputed */; - }; - - SyntaxNode.prototype.data = function () { - if ((this._data & 1 /* NodeDataComputed */) === 0) { - this._data |= this.computeData(); - } - - return this._data; - }; - - SyntaxNode.prototype.findToken = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var endOfFileToken = this.tryGetEndOfFileAt(position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - - if (position < 0 || position >= this.fullWidth()) { - throw TypeScript.Errors.argumentOutOfRange("position"); - } - - var positionedToken = this.findTokenInternal(null, position, 0); - - if (includeSkippedTokens) { - return TypeScript.Syntax.findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; - } - - return positionedToken; - }; - - SyntaxNode.prototype.tryGetEndOfFileAt = function (position) { - if (this.kind() === 120 /* SourceUnit */ && position === this.fullWidth()) { - var sourceUnit = this; - return new TypeScript.PositionedToken(new TypeScript.PositionedNode(null, sourceUnit, 0), sourceUnit.endOfFileToken, sourceUnit.moduleElements.fullWidth()); - } - - return null; - }; - - SyntaxNode.prototype.findTokenInternal = function (parent, position, fullStart) { - parent = new TypeScript.PositionedNode(parent, this, fullStart); - for (var i = 0, n = this.childCount(); i < n; i++) { - var element = this.childAt(i); - - if (element !== null) { - var childWidth = element.fullWidth(); - - if (position < childWidth) { - return element.findTokenInternal(parent, position, fullStart); - } - - position -= childWidth; - fullStart += childWidth; - } - } - - throw TypeScript.Errors.invalidOperation(); - }; - - SyntaxNode.prototype.findTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - var start = positionedToken.start(); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (position > start) { - return positionedToken; - } - - if (positionedToken.fullStart() === 0) { - return null; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.findCompleteTokenOnLeft = function (position, includeSkippedTokens) { - if (typeof includeSkippedTokens === "undefined") { includeSkippedTokens = false; } - var positionedToken = this.findToken(position, false); - - if (includeSkippedTokens) { - positionedToken = TypeScript.Syntax.findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - - if (positionedToken.token().width() > 0 && position >= positionedToken.end()) { - return positionedToken; - } - - return positionedToken.previousToken(includeSkippedTokens); - }; - - SyntaxNode.prototype.isModuleElement = function () { - return false; - }; - - SyntaxNode.prototype.isClassElement = function () { - return false; - }; - - SyntaxNode.prototype.isTypeMember = function () { - return false; - }; - - SyntaxNode.prototype.isStatement = function () { - return false; - }; - - SyntaxNode.prototype.isExpression = function () { - return false; - }; - - SyntaxNode.prototype.isSwitchClause = function () { - return false; - }; - - SyntaxNode.prototype.structuralEquals = function (node) { - if (this === node) { - return true; - } - if (node === null) { - return false; - } - if (this.kind() !== node.kind()) { - return false; - } - - for (var i = 0, n = this.childCount(); i < n; i++) { - var element1 = this.childAt(i); - var element2 = node.childAt(i); - - if (!TypeScript.Syntax.elementStructuralEquals(element1, element2)) { - return false; - } - } - - return true; - }; - - SyntaxNode.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - SyntaxNode.prototype.leadingTriviaWidth = function () { - var firstToken = this.firstToken(); - return firstToken === null ? 0 : firstToken.leadingTriviaWidth(); - }; - - SyntaxNode.prototype.trailingTriviaWidth = function () { - var lastToken = this.lastToken(); - return lastToken === null ? 0 : lastToken.trailingTriviaWidth(); - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(moduleElements, endOfFileToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleElements = moduleElements; - this.endOfFileToken = endOfFileToken; - } - SourceUnitSyntax.prototype.accept = function (visitor) { - return visitor.visitSourceUnit(this); - }; - - SourceUnitSyntax.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnitSyntax.prototype.childCount = function () { - return 2; - }; - - SourceUnitSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleElements; - case 1: - return this.endOfFileToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SourceUnitSyntax.prototype.update = function (moduleElements, endOfFileToken) { - if (this.moduleElements === moduleElements && this.endOfFileToken === endOfFileToken) { - return this; - } - - return new SourceUnitSyntax(moduleElements, endOfFileToken, this.parsedInStrictMode()); - }; - - SourceUnitSyntax.create = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.create1 = function (endOfFileToken) { - return new SourceUnitSyntax(TypeScript.Syntax.emptyList, endOfFileToken, false); - }; - - SourceUnitSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SourceUnitSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(moduleElements, this.endOfFileToken); - }; - - SourceUnitSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - SourceUnitSyntax.prototype.withEndOfFileToken = function (endOfFileToken) { - return this.update(this.moduleElements, endOfFileToken); - }; - - SourceUnitSyntax.prototype.isTypeScriptSpecific = function () { - if (this.moduleElements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SourceUnitSyntax = SourceUnitSyntax; - - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.requireKeyword = requireKeyword; - this.openParenToken = openParenToken; - this.stringLiteral = stringLiteral; - this.closeParenToken = closeParenToken; - } - ExternalModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitExternalModuleReference(this); - }; - - ExternalModuleReferenceSyntax.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - - ExternalModuleReferenceSyntax.prototype.childCount = function () { - return 4; - }; - - ExternalModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.requireKeyword; - case 1: - return this.openParenToken; - case 2: - return this.stringLiteral; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExternalModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ExternalModuleReferenceSyntax.prototype.update = function (requireKeyword, openParenToken, stringLiteral, closeParenToken) { - if (this.requireKeyword === requireKeyword && this.openParenToken === openParenToken && this.stringLiteral === stringLiteral && this.closeParenToken === closeParenToken) { - return this; - } - - return new ExternalModuleReferenceSyntax(requireKeyword, openParenToken, stringLiteral, closeParenToken, this.parsedInStrictMode()); - }; - - ExternalModuleReferenceSyntax.create1 = function (stringLiteral) { - return new ExternalModuleReferenceSyntax(TypeScript.Syntax.token(66 /* RequireKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), stringLiteral, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ExternalModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExternalModuleReferenceSyntax.prototype.withRequireKeyword = function (requireKeyword) { - return this.update(requireKeyword, this.openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.requireKeyword, openParenToken, this.stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.requireKeyword, this.openParenToken, stringLiteral, this.closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.requireKeyword, this.openParenToken, this.stringLiteral, closeParenToken); - }; - - ExternalModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExternalModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(moduleName, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.moduleName = moduleName; - } - ModuleNameModuleReferenceSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleNameModuleReference(this); - }; - - ModuleNameModuleReferenceSyntax.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - - ModuleNameModuleReferenceSyntax.prototype.childCount = function () { - return 1; - }; - - ModuleNameModuleReferenceSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.moduleName; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleNameModuleReferenceSyntax.prototype.isModuleReference = function () { - return true; - }; - - ModuleNameModuleReferenceSyntax.prototype.update = function (moduleName) { - if (this.moduleName === moduleName) { - return this; - } - - return new ModuleNameModuleReferenceSyntax(moduleName, this.parsedInStrictMode()); - }; - - ModuleNameModuleReferenceSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleNameModuleReferenceSyntax.prototype.withModuleName = function (moduleName) { - return this.update(moduleName); - }; - - ModuleNameModuleReferenceSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleNameModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.importKeyword = importKeyword; - this.identifier = identifier; - this.equalsToken = equalsToken; - this.moduleReference = moduleReference; - this.semicolonToken = semicolonToken; - } - ImportDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitImportDeclaration(this); - }; - - ImportDeclarationSyntax.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - ImportDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.importKeyword; - case 2: - return this.identifier; - case 3: - return this.equalsToken; - case 4: - return this.moduleReference; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ImportDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ImportDeclarationSyntax.prototype.update = function (modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - if (this.modifiers === modifiers && this.importKeyword === importKeyword && this.identifier === identifier && this.equalsToken === equalsToken && this.moduleReference === moduleReference && this.semicolonToken === semicolonToken) { - return this; - } - - return new ImportDeclarationSyntax(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, this.parsedInStrictMode()); - }; - - ImportDeclarationSyntax.create = function (importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, importKeyword, identifier, equalsToken, moduleReference, semicolonToken, false); - }; - - ImportDeclarationSyntax.create1 = function (identifier, moduleReference) { - return new ImportDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(49 /* ImportKeyword */), identifier, TypeScript.Syntax.token(107 /* EqualsToken */), moduleReference, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ImportDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ImportDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ImportDeclarationSyntax.prototype.withImportKeyword = function (importKeyword) { - return this.update(this.modifiers, importKeyword, this.identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.importKeyword, identifier, this.equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, equalsToken, this.moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withModuleReference = function (moduleReference) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, moduleReference, this.semicolonToken); - }; - - ImportDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.importKeyword, this.identifier, this.equalsToken, this.moduleReference, semicolonToken); - }; - - ImportDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ImportDeclarationSyntax = ImportDeclarationSyntax; - - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.exportKeyword = exportKeyword; - this.equalsToken = equalsToken; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ExportAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitExportAssignment(this); - }; - - ExportAssignmentSyntax.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignmentSyntax.prototype.childCount = function () { - return 4; - }; - - ExportAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.exportKeyword; - case 1: - return this.equalsToken; - case 2: - return this.identifier; - case 3: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExportAssignmentSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExportAssignmentSyntax.prototype.update = function (exportKeyword, equalsToken, identifier, semicolonToken) { - if (this.exportKeyword === exportKeyword && this.equalsToken === equalsToken && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExportAssignmentSyntax(exportKeyword, equalsToken, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ExportAssignmentSyntax.create1 = function (identifier) { - return new ExportAssignmentSyntax(TypeScript.Syntax.token(47 /* ExportKeyword */), TypeScript.Syntax.token(107 /* EqualsToken */), identifier, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExportAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExportAssignmentSyntax.prototype.withExportKeyword = function (exportKeyword) { - return this.update(exportKeyword, this.equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(this.exportKeyword, equalsToken, this.identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.exportKeyword, this.equalsToken, identifier, this.semicolonToken); - }; - - ExportAssignmentSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.exportKeyword, this.equalsToken, this.identifier, semicolonToken); - }; - - ExportAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExportAssignmentSyntax = ExportAssignmentSyntax; - - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.classKeyword = classKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.openBraceToken = openBraceToken; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - } - ClassDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitClassDeclaration(this); - }; - - ClassDeclarationSyntax.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclarationSyntax.prototype.childCount = function () { - return 8; - }; - - ClassDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.classKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.openBraceToken; - case 6: - return this.classElements; - case 7: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ClassDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ClassDeclarationSyntax.prototype.update = function (modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - if (this.modifiers === modifiers && this.classKeyword === classKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.openBraceToken === openBraceToken && this.classElements === classElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ClassDeclarationSyntax(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ClassDeclarationSyntax.create = function (classKeyword, identifier, openBraceToken, closeBraceToken) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, classKeyword, identifier, null, TypeScript.Syntax.emptyList, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ClassDeclarationSyntax.create1 = function (identifier) { - return new ClassDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(44 /* ClassKeyword */), identifier, null, TypeScript.Syntax.emptyList, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ClassDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ClassDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ClassDeclarationSyntax.prototype.withClassKeyword = function (classKeyword) { - return this.update(this.modifiers, classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.classKeyword, identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.classKeyword, this.identifier, typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, heritageClauses, this.openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - ClassDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, openBraceToken, this.classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElements = function (classElements) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, classElements, this.closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.withClassElement = function (classElement) { - return this.withClassElements(TypeScript.Syntax.list([classElement])); - }; - - ClassDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.classKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.openBraceToken, this.classElements, closeBraceToken); - }; - - ClassDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ClassDeclarationSyntax = ClassDeclarationSyntax; - - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.interfaceKeyword = interfaceKeyword; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - } - InterfaceDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitInterfaceDeclaration(this); - }; - - InterfaceDeclarationSyntax.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - InterfaceDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.interfaceKeyword; - case 2: - return this.identifier; - case 3: - return this.typeParameterList; - case 4: - return this.heritageClauses; - case 5: - return this.body; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InterfaceDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - InterfaceDeclarationSyntax.prototype.update = function (modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - if (this.modifiers === modifiers && this.interfaceKeyword === interfaceKeyword && this.identifier === identifier && this.typeParameterList === typeParameterList && this.heritageClauses === heritageClauses && this.body === body) { - return this; - } - - return new InterfaceDeclarationSyntax(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body, this.parsedInStrictMode()); - }; - - InterfaceDeclarationSyntax.create = function (interfaceKeyword, identifier, body) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, interfaceKeyword, identifier, null, TypeScript.Syntax.emptyList, body, false); - }; - - InterfaceDeclarationSyntax.create1 = function (identifier) { - return new InterfaceDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(52 /* InterfaceKeyword */), identifier, null, TypeScript.Syntax.emptyList, ObjectTypeSyntax.create1(), false); - }; - - InterfaceDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InterfaceDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - InterfaceDeclarationSyntax.prototype.withInterfaceKeyword = function (interfaceKeyword) { - return this.update(this.modifiers, interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.interfaceKeyword, identifier, this.typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, typeParameterList, this.heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClauses = function (heritageClauses) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, heritageClauses, this.body); - }; - - InterfaceDeclarationSyntax.prototype.withHeritageClause = function (heritageClause) { - return this.withHeritageClauses(TypeScript.Syntax.list([heritageClause])); - }; - - InterfaceDeclarationSyntax.prototype.withBody = function (body) { - return this.update(this.modifiers, this.interfaceKeyword, this.identifier, this.typeParameterList, this.heritageClauses, body); - }; - - InterfaceDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword; - this.typeNames = typeNames; - - this._kind = kind; - } - HeritageClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitHeritageClause(this); - }; - - HeritageClauseSyntax.prototype.childCount = function () { - return 2; - }; - - HeritageClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsOrImplementsKeyword; - case 1: - return this.typeNames; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - HeritageClauseSyntax.prototype.kind = function () { - return this._kind; - }; - - HeritageClauseSyntax.prototype.update = function (kind, extendsOrImplementsKeyword, typeNames) { - if (this._kind === kind && this.extendsOrImplementsKeyword === extendsOrImplementsKeyword && this.typeNames === typeNames) { - return this; - } - - return new HeritageClauseSyntax(kind, extendsOrImplementsKeyword, typeNames, this.parsedInStrictMode()); - }; - - HeritageClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - HeritageClauseSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withExtendsOrImplementsKeyword = function (extendsOrImplementsKeyword) { - return this.update(this._kind, extendsOrImplementsKeyword, this.typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeNames = function (typeNames) { - return this.update(this._kind, this.extendsOrImplementsKeyword, typeNames); - }; - - HeritageClauseSyntax.prototype.withTypeName = function (typeName) { - return this.withTypeNames(TypeScript.Syntax.separatedList([typeName])); - }; - - HeritageClauseSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.HeritageClauseSyntax = HeritageClauseSyntax; - - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.moduleKeyword = moduleKeyword; - this.name = name; - this.stringLiteral = stringLiteral; - this.openBraceToken = openBraceToken; - this.moduleElements = moduleElements; - this.closeBraceToken = closeBraceToken; - } - ModuleDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitModuleDeclaration(this); - }; - - ModuleDeclarationSyntax.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclarationSyntax.prototype.childCount = function () { - return 7; - }; - - ModuleDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.moduleKeyword; - case 2: - return this.name; - case 3: - return this.stringLiteral; - case 4: - return this.openBraceToken; - case 5: - return this.moduleElements; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ModuleDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - ModuleDeclarationSyntax.prototype.update = function (modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - if (this.modifiers === modifiers && this.moduleKeyword === moduleKeyword && this.name === name && this.stringLiteral === stringLiteral && this.openBraceToken === openBraceToken && this.moduleElements === moduleElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ModuleDeclarationSyntax(modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken, this.parsedInStrictMode()); - }; - - ModuleDeclarationSyntax.create = function (moduleKeyword, openBraceToken, closeBraceToken) { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, moduleKeyword, null, null, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - ModuleDeclarationSyntax.create1 = function () { - return new ModuleDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(65 /* ModuleKeyword */), null, null, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ModuleDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ModuleDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ModuleDeclarationSyntax.prototype.withModuleKeyword = function (moduleKeyword) { - return this.update(this.modifiers, moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withName = function (name) { - return this.update(this.modifiers, this.moduleKeyword, name, this.stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withStringLiteral = function (stringLiteral) { - return this.update(this.modifiers, this.moduleKeyword, this.name, stringLiteral, this.openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, openBraceToken, this.moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElements = function (moduleElements) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, moduleElements, this.closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.withModuleElement = function (moduleElement) { - return this.withModuleElements(TypeScript.Syntax.list([moduleElement])); - }; - - ModuleDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.moduleKeyword, this.name, this.stringLiteral, this.openBraceToken, this.moduleElements, closeBraceToken); - }; - - ModuleDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - FunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionDeclaration(this); - }; - - FunctionDeclarationSyntax.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - FunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.functionKeyword; - case 2: - return this.identifier; - case 3: - return this.callSignature; - case 4: - return this.block; - case 5: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionDeclarationSyntax.prototype.isStatement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - FunctionDeclarationSyntax.prototype.update = function (modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new FunctionDeclarationSyntax(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - FunctionDeclarationSyntax.create = function (functionKeyword, identifier, callSignature) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, functionKeyword, identifier, callSignature, null, null, false); - }; - - FunctionDeclarationSyntax.create1 = function (identifier) { - return new FunctionDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(27 /* FunctionKeyword */), identifier, CallSignatureSyntax.create1(), null, null, false); - }; - - FunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - FunctionDeclarationSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(this.modifiers, functionKeyword, this.identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.functionKeyword, identifier, this.callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, callSignature, this.block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, block, this.semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.functionKeyword, this.identifier, this.callSignature, this.block, semicolonToken); - }; - - FunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block !== null && this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclaration = variableDeclaration; - this.semicolonToken = semicolonToken; - } - VariableStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableStatement(this); - }; - - VariableStatementSyntax.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatementSyntax.prototype.childCount = function () { - return 3; - }; - - VariableStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclaration; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableStatementSyntax.prototype.isStatement = function () { - return true; - }; - - VariableStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - VariableStatementSyntax.prototype.update = function (modifiers, variableDeclaration, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclaration === variableDeclaration && this.semicolonToken === semicolonToken) { - return this; - } - - return new VariableStatementSyntax(modifiers, variableDeclaration, semicolonToken, this.parsedInStrictMode()); - }; - - VariableStatementSyntax.create = function (variableDeclaration, semicolonToken) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, semicolonToken, false); - }; - - VariableStatementSyntax.create1 = function (variableDeclaration) { - return new VariableStatementSyntax(TypeScript.Syntax.emptyList, variableDeclaration, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - VariableStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableStatementSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - VariableStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.modifiers, variableDeclaration, this.semicolonToken); - }; - - VariableStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclaration, semicolonToken); - }; - - VariableStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableStatementSyntax = VariableStatementSyntax; - - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(varKeyword, variableDeclarators, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.varKeyword = varKeyword; - this.variableDeclarators = variableDeclarators; - } - VariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclaration(this); - }; - - VariableDeclarationSyntax.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclarationSyntax.prototype.childCount = function () { - return 2; - }; - - VariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.varKeyword; - case 1: - return this.variableDeclarators; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclarationSyntax.prototype.update = function (varKeyword, variableDeclarators) { - if (this.varKeyword === varKeyword && this.variableDeclarators === variableDeclarators) { - return this; - } - - return new VariableDeclarationSyntax(varKeyword, variableDeclarators, this.parsedInStrictMode()); - }; - - VariableDeclarationSyntax.create1 = function (variableDeclarators) { - return new VariableDeclarationSyntax(TypeScript.Syntax.token(40 /* VarKeyword */), variableDeclarators, false); - }; - - VariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclarationSyntax.prototype.withVarKeyword = function (varKeyword) { - return this.update(varKeyword, this.variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarators = function (variableDeclarators) { - return this.update(this.varKeyword, variableDeclarators); - }; - - VariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.withVariableDeclarators(TypeScript.Syntax.separatedList([variableDeclarator])); - }; - - VariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclarators.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclarationSyntax = VariableDeclarationSyntax; - - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - VariableDeclaratorSyntax.prototype.accept = function (visitor) { - return visitor.visitVariableDeclarator(this); - }; - - VariableDeclaratorSyntax.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - - VariableDeclaratorSyntax.prototype.childCount = function () { - return 3; - }; - - VariableDeclaratorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.typeAnnotation; - case 2: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VariableDeclaratorSyntax.prototype.update = function (propertyName, typeAnnotation, equalsValueClause) { - if (this.propertyName === propertyName && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new VariableDeclaratorSyntax(propertyName, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - VariableDeclaratorSyntax.create = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.create1 = function (propertyName) { - return new VariableDeclaratorSyntax(propertyName, null, null, false); - }; - - VariableDeclaratorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VariableDeclaratorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, typeAnnotation, this.equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, this.typeAnnotation, equalsValueClause); - }; - - VariableDeclaratorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(equalsToken, value, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.equalsToken = equalsToken; - this.value = value; - } - EqualsValueClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitEqualsValueClause(this); - }; - - EqualsValueClauseSyntax.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - - EqualsValueClauseSyntax.prototype.childCount = function () { - return 2; - }; - - EqualsValueClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.equalsToken; - case 1: - return this.value; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EqualsValueClauseSyntax.prototype.update = function (equalsToken, value) { - if (this.equalsToken === equalsToken && this.value === value) { - return this; - } - - return new EqualsValueClauseSyntax(equalsToken, value, this.parsedInStrictMode()); - }; - - EqualsValueClauseSyntax.create1 = function (value) { - return new EqualsValueClauseSyntax(TypeScript.Syntax.token(107 /* EqualsToken */), value, false); - }; - - EqualsValueClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EqualsValueClauseSyntax.prototype.withEqualsToken = function (equalsToken) { - return this.update(equalsToken, this.value); - }; - - EqualsValueClauseSyntax.prototype.withValue = function (value) { - return this.update(this.equalsToken, value); - }; - - EqualsValueClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.value.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(kind, operatorToken, operand, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operatorToken = operatorToken; - this.operand = operand; - - this._kind = kind; - } - PrefixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPrefixUnaryExpression(this); - }; - - PrefixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PrefixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operatorToken; - case 1: - return this.operand; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PrefixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PrefixUnaryExpressionSyntax.prototype.update = function (kind, operatorToken, operand) { - if (this._kind === kind && this.operatorToken === operatorToken && this.operand === operand) { - return this; - } - - return new PrefixUnaryExpressionSyntax(kind, operatorToken, operand, this.parsedInStrictMode()); - }; - - PrefixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PrefixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, operatorToken, this.operand); - }; - - PrefixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, this.operatorToken, operand); - }; - - PrefixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.expressions = expressions; - this.closeBracketToken = closeBracketToken; - } - ArrayLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayLiteralExpression(this); - }; - - ArrayLiteralExpressionSyntax.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - ArrayLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.expressions; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ArrayLiteralExpressionSyntax.prototype.update = function (openBracketToken, expressions, closeBracketToken) { - if (this.openBracketToken === openBracketToken && this.expressions === expressions && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayLiteralExpressionSyntax(openBracketToken, expressions, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayLiteralExpressionSyntax.create = function (openBracketToken, closeBracketToken) { - return new ArrayLiteralExpressionSyntax(openBracketToken, TypeScript.Syntax.emptySeparatedList, closeBracketToken, false); - }; - - ArrayLiteralExpressionSyntax.create1 = function () { - return new ArrayLiteralExpressionSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayLiteralExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpressions = function (expressions) { - return this.update(this.openBracketToken, expressions, this.closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.withExpression = function (expression) { - return this.withExpressions(TypeScript.Syntax.separatedList([expression])); - }; - - ArrayLiteralExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.expressions, closeBracketToken); - }; - - ArrayLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expressions.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - } - OmittedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitOmittedExpression(this); - }; - - OmittedExpressionSyntax.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - OmittedExpressionSyntax.prototype.childCount = function () { - return 0; - }; - - OmittedExpressionSyntax.prototype.childAt = function (slot) { - throw TypeScript.Errors.invalidOperation(); - }; - - OmittedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - OmittedExpressionSyntax.prototype.update = function () { - return this; - }; - - OmittedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - OmittedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.OmittedExpressionSyntax = OmittedExpressionSyntax; - - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - } - ParenthesizedExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedExpression(this); - }; - - ParenthesizedExpressionSyntax.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - ParenthesizedExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ParenthesizedExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.expression; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedExpressionSyntax.prototype.update = function (openParenToken, expression, closeParenToken) { - if (this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParenthesizedExpressionSyntax(openParenToken, expression, closeParenToken, this.parsedInStrictMode()); - }; - - ParenthesizedExpressionSyntax.create1 = function (expression) { - return new ParenthesizedExpressionSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParenthesizedExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedExpressionSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.openParenToken, expression, this.closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.expression, closeParenToken); - }; - - ParenthesizedExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - SimpleArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitSimpleArrowFunctionExpression(this); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - SimpleArrowFunctionExpressionSyntax.prototype.update = function (identifier, equalsGreaterThanToken, block, expression) { - if (this.identifier === identifier && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - SimpleArrowFunctionExpressionSyntax.create = function (identifier, equalsGreaterThanToken) { - return new SimpleArrowFunctionExpressionSyntax(identifier, equalsGreaterThanToken, null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.create1 = function (identifier) { - return new SimpleArrowFunctionExpressionSyntax(identifier, TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.identifier, equalsGreaterThanToken, this.block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.identifier, this.equalsGreaterThanToken, block, this.expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.identifier, this.equalsGreaterThanToken, this.block, expression); - }; - - SimpleArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SimpleArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.callSignature = callSignature; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.block = block; - this.expression = expression; - } - ParenthesizedArrowFunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitParenthesizedArrowFunctionExpression(this); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.callSignature; - case 1: - return this.equalsGreaterThanToken; - case 2: - return this.block; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isArrowFunctionExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.update = function (callSignature, equalsGreaterThanToken, block, expression) { - if (this.callSignature === callSignature && this.equalsGreaterThanToken === equalsGreaterThanToken && this.block === block && this.expression === expression) { - return this; - } - - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, block, expression, this.parsedInStrictMode()); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create = function (callSignature, equalsGreaterThanToken) { - return new ParenthesizedArrowFunctionExpressionSyntax(callSignature, equalsGreaterThanToken, null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.create1 = function () { - return new ParenthesizedArrowFunctionExpressionSyntax(CallSignatureSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), null, null, false); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(callSignature, this.equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.callSignature, equalsGreaterThanToken, this.block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.callSignature, this.equalsGreaterThanToken, block, this.expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.callSignature, this.equalsGreaterThanToken, this.block, expression); - }; - - ParenthesizedArrowFunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ParenthesizedArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(left, dotToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.dotToken = dotToken; - this.right = right; - } - QualifiedNameSyntax.prototype.accept = function (visitor) { - return visitor.visitQualifiedName(this); - }; - - QualifiedNameSyntax.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedNameSyntax.prototype.childCount = function () { - return 3; - }; - - QualifiedNameSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.dotToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - QualifiedNameSyntax.prototype.isName = function () { - return true; - }; - - QualifiedNameSyntax.prototype.isType = function () { - return true; - }; - - QualifiedNameSyntax.prototype.update = function (left, dotToken, right) { - if (this.left === left && this.dotToken === dotToken && this.right === right) { - return this; - } - - return new QualifiedNameSyntax(left, dotToken, right, this.parsedInStrictMode()); - }; - - QualifiedNameSyntax.create1 = function (left, right) { - return new QualifiedNameSyntax(left, TypeScript.Syntax.token(76 /* DotToken */), right, false); - }; - - QualifiedNameSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - QualifiedNameSyntax.prototype.withLeft = function (left) { - return this.update(left, this.dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.left, dotToken, this.right); - }; - - QualifiedNameSyntax.prototype.withRight = function (right) { - return this.update(this.left, this.dotToken, right); - }; - - QualifiedNameSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - TypeScript.QualifiedNameSyntax = QualifiedNameSyntax; - - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeArguments = typeArguments; - this.greaterThanToken = greaterThanToken; - } - TypeArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeArgumentList(this); - }; - - TypeArgumentListSyntax.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - - TypeArgumentListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeArguments; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeArgumentListSyntax.prototype.update = function (lessThanToken, typeArguments, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeArguments === typeArguments && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeArgumentListSyntax(lessThanToken, typeArguments, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeArgumentListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeArgumentListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeArgumentListSyntax.create1 = function () { - return new TypeArgumentListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeArgumentListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArguments = function (typeArguments) { - return this.update(this.lessThanToken, typeArguments, this.greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.withTypeArgument = function (typeArgument) { - return this.withTypeArguments(TypeScript.Syntax.separatedList([typeArgument])); - }; - - TypeArgumentListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeArguments, greaterThanToken); - }; - - TypeArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeArgumentListSyntax = TypeArgumentListSyntax; - - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - ConstructorTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorType(this); - }; - - ConstructorTypeSyntax.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - - ConstructorTypeSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.typeParameterList; - case 2: - return this.parameterList; - case 3: - return this.equalsGreaterThanToken; - case 4: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorTypeSyntax.prototype.isType = function () { - return true; - }; - - ConstructorTypeSyntax.prototype.update = function (newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.newKeyword === newKeyword && this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new ConstructorTypeSyntax(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - ConstructorTypeSyntax.create = function (newKeyword, parameterList, equalsGreaterThanToken, type) { - return new ConstructorTypeSyntax(newKeyword, null, parameterList, equalsGreaterThanToken, type, false); - }; - - ConstructorTypeSyntax.create1 = function (type) { - return new ConstructorTypeSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - ConstructorTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorTypeSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(this.newKeyword, typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.newKeyword, this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - ConstructorTypeSyntax.prototype.withType = function (type) { - return this.update(this.newKeyword, this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - ConstructorTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorTypeSyntax = ConstructorTypeSyntax; - - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.equalsGreaterThanToken = equalsGreaterThanToken; - this.type = type; - } - FunctionTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionType(this); - }; - - FunctionTypeSyntax.prototype.kind = function () { - return 123 /* FunctionType */; - }; - - FunctionTypeSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.equalsGreaterThanToken; - case 3: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionTypeSyntax.prototype.isType = function () { - return true; - }; - - FunctionTypeSyntax.prototype.update = function (typeParameterList, parameterList, equalsGreaterThanToken, type) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.equalsGreaterThanToken === equalsGreaterThanToken && this.type === type) { - return this; - } - - return new FunctionTypeSyntax(typeParameterList, parameterList, equalsGreaterThanToken, type, this.parsedInStrictMode()); - }; - - FunctionTypeSyntax.create = function (parameterList, equalsGreaterThanToken, type) { - return new FunctionTypeSyntax(null, parameterList, equalsGreaterThanToken, type, false); - }; - - FunctionTypeSyntax.create1 = function (type) { - return new FunctionTypeSyntax(null, ParameterListSyntax.create1(), TypeScript.Syntax.token(85 /* EqualsGreaterThanToken */), type, false); - }; - - FunctionTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionTypeSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withEqualsGreaterThanToken = function (equalsGreaterThanToken) { - return this.update(this.typeParameterList, this.parameterList, equalsGreaterThanToken, this.type); - }; - - FunctionTypeSyntax.prototype.withType = function (type) { - return this.update(this.typeParameterList, this.parameterList, this.equalsGreaterThanToken, type); - }; - - FunctionTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionTypeSyntax = FunctionTypeSyntax; - - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.typeMembers = typeMembers; - this.closeBraceToken = closeBraceToken; - } - ObjectTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectType(this); - }; - - ObjectTypeSyntax.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.typeMembers; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectTypeSyntax.prototype.isType = function () { - return true; - }; - - ObjectTypeSyntax.prototype.update = function (openBraceToken, typeMembers, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.typeMembers === typeMembers && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectTypeSyntax(openBraceToken, typeMembers, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectTypeSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectTypeSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectTypeSyntax.create1 = function () { - return new ObjectTypeSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectTypeSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMembers = function (typeMembers) { - return this.update(this.openBraceToken, typeMembers, this.closeBraceToken); - }; - - ObjectTypeSyntax.prototype.withTypeMember = function (typeMember) { - return this.withTypeMembers(TypeScript.Syntax.separatedList([typeMember])); - }; - - ObjectTypeSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.typeMembers, closeBraceToken); - }; - - ObjectTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectTypeSyntax = ObjectTypeSyntax; - - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(type, openBracketToken, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.type = type; - this.openBracketToken = openBracketToken; - this.closeBracketToken = closeBracketToken; - } - ArrayTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitArrayType(this); - }; - - ArrayTypeSyntax.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayTypeSyntax.prototype.childCount = function () { - return 3; - }; - - ArrayTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.type; - case 1: - return this.openBracketToken; - case 2: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArrayTypeSyntax.prototype.isType = function () { - return true; - }; - - ArrayTypeSyntax.prototype.update = function (type, openBracketToken, closeBracketToken) { - if (this.type === type && this.openBracketToken === openBracketToken && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ArrayTypeSyntax(type, openBracketToken, closeBracketToken, this.parsedInStrictMode()); - }; - - ArrayTypeSyntax.create1 = function (type) { - return new ArrayTypeSyntax(type, TypeScript.Syntax.token(74 /* OpenBracketToken */), TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ArrayTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArrayTypeSyntax.prototype.withType = function (type) { - return this.update(type, this.openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.type, openBracketToken, this.closeBracketToken); - }; - - ArrayTypeSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.type, this.openBracketToken, closeBracketToken); - }; - - ArrayTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArrayTypeSyntax = ArrayTypeSyntax; - - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(name, typeArgumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.name = name; - this.typeArgumentList = typeArgumentList; - } - GenericTypeSyntax.prototype.accept = function (visitor) { - return visitor.visitGenericType(this); - }; - - GenericTypeSyntax.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericTypeSyntax.prototype.childCount = function () { - return 2; - }; - - GenericTypeSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.name; - case 1: - return this.typeArgumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GenericTypeSyntax.prototype.isType = function () { - return true; - }; - - GenericTypeSyntax.prototype.update = function (name, typeArgumentList) { - if (this.name === name && this.typeArgumentList === typeArgumentList) { - return this; - } - - return new GenericTypeSyntax(name, typeArgumentList, this.parsedInStrictMode()); - }; - - GenericTypeSyntax.create1 = function (name) { - return new GenericTypeSyntax(name, TypeArgumentListSyntax.create1(), false); - }; - - GenericTypeSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GenericTypeSyntax.prototype.withName = function (name) { - return this.update(name, this.typeArgumentList); - }; - - GenericTypeSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(this.name, typeArgumentList); - }; - - GenericTypeSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GenericTypeSyntax = GenericTypeSyntax; - - var TypeQuerySyntax = (function (_super) { - __extends(TypeQuerySyntax, _super); - function TypeQuerySyntax(typeOfKeyword, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.name = name; - } - TypeQuerySyntax.prototype.accept = function (visitor) { - return visitor.visitTypeQuery(this); - }; - - TypeQuerySyntax.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuerySyntax.prototype.childCount = function () { - return 2; - }; - - TypeQuerySyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeQuerySyntax.prototype.isType = function () { - return true; - }; - - TypeQuerySyntax.prototype.update = function (typeOfKeyword, name) { - if (this.typeOfKeyword === typeOfKeyword && this.name === name) { - return this; - } - - return new TypeQuerySyntax(typeOfKeyword, name, this.parsedInStrictMode()); - }; - - TypeQuerySyntax.create1 = function (name) { - return new TypeQuerySyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), name, false); - }; - - TypeQuerySyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeQuerySyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.name); - }; - - TypeQuerySyntax.prototype.withName = function (name) { - return this.update(this.typeOfKeyword, name); - }; - - TypeQuerySyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeQuerySyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeQuerySyntax = TypeQuerySyntax; - - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(colonToken, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.colonToken = colonToken; - this.type = type; - } - TypeAnnotationSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeAnnotation(this); - }; - - TypeAnnotationSyntax.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - - TypeAnnotationSyntax.prototype.childCount = function () { - return 2; - }; - - TypeAnnotationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.colonToken; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeAnnotationSyntax.prototype.update = function (colonToken, type) { - if (this.colonToken === colonToken && this.type === type) { - return this; - } - - return new TypeAnnotationSyntax(colonToken, type, this.parsedInStrictMode()); - }; - - TypeAnnotationSyntax.create1 = function (type) { - return new TypeAnnotationSyntax(TypeScript.Syntax.token(106 /* ColonToken */), type, false); - }; - - TypeAnnotationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeAnnotationSyntax.prototype.withColonToken = function (colonToken) { - return this.update(colonToken, this.type); - }; - - TypeAnnotationSyntax.prototype.withType = function (type) { - return this.update(this.colonToken, type); - }; - - TypeAnnotationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeAnnotationSyntax = TypeAnnotationSyntax; - - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(openBraceToken, statements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.statements = statements; - this.closeBraceToken = closeBraceToken; - } - BlockSyntax.prototype.accept = function (visitor) { - return visitor.visitBlock(this); - }; - - BlockSyntax.prototype.kind = function () { - return 146 /* Block */; - }; - - BlockSyntax.prototype.childCount = function () { - return 3; - }; - - BlockSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.statements; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BlockSyntax.prototype.isStatement = function () { - return true; - }; - - BlockSyntax.prototype.isModuleElement = function () { - return true; - }; - - BlockSyntax.prototype.update = function (openBraceToken, statements, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.statements === statements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new BlockSyntax(openBraceToken, statements, closeBraceToken, this.parsedInStrictMode()); - }; - - BlockSyntax.create = function (openBraceToken, closeBraceToken) { - return new BlockSyntax(openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - BlockSyntax.create1 = function () { - return new BlockSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - BlockSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BlockSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatements = function (statements) { - return this.update(this.openBraceToken, statements, this.closeBraceToken); - }; - - BlockSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - BlockSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.statements, closeBraceToken); - }; - - BlockSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BlockSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BlockSyntax = BlockSyntax; - - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - } - ParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitParameter(this); - }; - - ParameterSyntax.prototype.kind = function () { - return 242 /* Parameter */; - }; - - ParameterSyntax.prototype.childCount = function () { - return 6; - }; - - ParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.dotDotDotToken; - case 1: - return this.modifiers; - case 2: - return this.identifier; - case 3: - return this.questionToken; - case 4: - return this.typeAnnotation; - case 5: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterSyntax.prototype.update = function (dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - if (this.dotDotDotToken === dotDotDotToken && this.modifiers === modifiers && this.identifier === identifier && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new ParameterSyntax(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause, this.parsedInStrictMode()); - }; - - ParameterSyntax.create = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.create1 = function (identifier) { - return new ParameterSyntax(null, TypeScript.Syntax.emptyList, identifier, null, null, null, false); - }; - - ParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterSyntax.prototype.withDotDotDotToken = function (dotDotDotToken) { - return this.update(dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifiers = function (modifiers) { - return this.update(this.dotDotDotToken, modifiers, this.identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.dotDotDotToken, this.modifiers, identifier, this.questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, questionToken, this.typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, typeAnnotation, this.equalsValueClause); - }; - - ParameterSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.dotDotDotToken, this.modifiers, this.identifier, this.questionToken, this.typeAnnotation, equalsValueClause); - }; - - ParameterSyntax.prototype.isTypeScriptSpecific = function () { - if (this.dotDotDotToken !== null) { - return true; - } - if (this.modifiers.isTypeScriptSpecific()) { - return true; - } - if (this.questionToken !== null) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.equalsValueClause !== null) { - return true; - } - return false; - }; - return ParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterSyntax = ParameterSyntax; - - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(expression, dotToken, name, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.dotToken = dotToken; - this.name = name; - } - MemberAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberAccessExpression(this); - }; - - MemberAccessExpressionSyntax.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - MemberAccessExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - MemberAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.dotToken; - case 2: - return this.name; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - MemberAccessExpressionSyntax.prototype.update = function (expression, dotToken, name) { - if (this.expression === expression && this.dotToken === dotToken && this.name === name) { - return this; - } - - return new MemberAccessExpressionSyntax(expression, dotToken, name, this.parsedInStrictMode()); - }; - - MemberAccessExpressionSyntax.create1 = function (expression, name) { - return new MemberAccessExpressionSyntax(expression, TypeScript.Syntax.token(76 /* DotToken */), name, false); - }; - - MemberAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withDotToken = function (dotToken) { - return this.update(this.expression, dotToken, this.name); - }; - - MemberAccessExpressionSyntax.prototype.withName = function (name) { - return this.update(this.expression, this.dotToken, name); - }; - - MemberAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(kind, operand, operatorToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.operand = operand; - this.operatorToken = operatorToken; - - this._kind = kind; - } - PostfixUnaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitPostfixUnaryExpression(this); - }; - - PostfixUnaryExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - PostfixUnaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.operand; - case 1: - return this.operatorToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PostfixUnaryExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - PostfixUnaryExpressionSyntax.prototype.update = function (kind, operand, operatorToken) { - if (this._kind === kind && this.operand === operand && this.operatorToken === operatorToken) { - return this; - } - - return new PostfixUnaryExpressionSyntax(kind, operand, operatorToken, this.parsedInStrictMode()); - }; - - PostfixUnaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PostfixUnaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperand = function (operand) { - return this.update(this._kind, operand, this.operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.operand, operatorToken); - }; - - PostfixUnaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.operand.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.openBracketToken = openBracketToken; - this.argumentExpression = argumentExpression; - this.closeBracketToken = closeBracketToken; - } - ElementAccessExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitElementAccessExpression(this); - }; - - ElementAccessExpressionSyntax.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - ElementAccessExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - ElementAccessExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.openBracketToken; - case 2: - return this.argumentExpression; - case 3: - return this.closeBracketToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElementAccessExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ElementAccessExpressionSyntax.prototype.update = function (expression, openBracketToken, argumentExpression, closeBracketToken) { - if (this.expression === expression && this.openBracketToken === openBracketToken && this.argumentExpression === argumentExpression && this.closeBracketToken === closeBracketToken) { - return this; - } - - return new ElementAccessExpressionSyntax(expression, openBracketToken, argumentExpression, closeBracketToken, this.parsedInStrictMode()); - }; - - ElementAccessExpressionSyntax.create1 = function (expression, argumentExpression) { - return new ElementAccessExpressionSyntax(expression, TypeScript.Syntax.token(74 /* OpenBracketToken */), argumentExpression, TypeScript.Syntax.token(75 /* CloseBracketToken */), false); - }; - - ElementAccessExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElementAccessExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(this.expression, openBracketToken, this.argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withArgumentExpression = function (argumentExpression) { - return this.update(this.expression, this.openBracketToken, argumentExpression, this.closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.expression, this.openBracketToken, this.argumentExpression, closeBracketToken); - }; - - ElementAccessExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentExpression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.argumentList = argumentList; - } - InvocationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitInvocationExpression(this); - }; - - InvocationExpressionSyntax.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - InvocationExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - InvocationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - InvocationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - InvocationExpressionSyntax.prototype.update = function (expression, argumentList) { - if (this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new InvocationExpressionSyntax(expression, argumentList, this.parsedInStrictMode()); - }; - - InvocationExpressionSyntax.create1 = function (expression) { - return new InvocationExpressionSyntax(expression, ArgumentListSyntax.create1(), false); - }; - - InvocationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - InvocationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.argumentList); - }; - - InvocationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.expression, argumentList); - }; - - InvocationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.InvocationExpressionSyntax = InvocationExpressionSyntax; - - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeArgumentList = typeArgumentList; - this.openParenToken = openParenToken; - this.closeParenToken = closeParenToken; - - this.arguments = _arguments; - } - ArgumentListSyntax.prototype.accept = function (visitor) { - return visitor.visitArgumentList(this); - }; - - ArgumentListSyntax.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - - ArgumentListSyntax.prototype.childCount = function () { - return 4; - }; - - ArgumentListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeArgumentList; - case 1: - return this.openParenToken; - case 2: - return this.arguments; - case 3: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ArgumentListSyntax.prototype.update = function (typeArgumentList, openParenToken, _arguments, closeParenToken) { - if (this.typeArgumentList === typeArgumentList && this.openParenToken === openParenToken && this.arguments === _arguments && this.closeParenToken === closeParenToken) { - return this; - } - - return new ArgumentListSyntax(typeArgumentList, openParenToken, _arguments, closeParenToken, this.parsedInStrictMode()); - }; - - ArgumentListSyntax.create = function (openParenToken, closeParenToken) { - return new ArgumentListSyntax(null, openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ArgumentListSyntax.create1 = function () { - return new ArgumentListSyntax(null, TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ArgumentListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ArgumentListSyntax.prototype.withTypeArgumentList = function (typeArgumentList) { - return this.update(typeArgumentList, this.openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.typeArgumentList, openParenToken, this.arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArguments = function (_arguments) { - return this.update(this.typeArgumentList, this.openParenToken, _arguments, this.closeParenToken); - }; - - ArgumentListSyntax.prototype.withArgument = function (_argument) { - return this.withArguments(TypeScript.Syntax.separatedList([_argument])); - }; - - ArgumentListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.typeArgumentList, this.openParenToken, this.arguments, closeParenToken); - }; - - ArgumentListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeArgumentList !== null && this.typeArgumentList.isTypeScriptSpecific()) { - return true; - } - if (this.arguments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ArgumentListSyntax = ArgumentListSyntax; - - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(kind, left, operatorToken, right, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.left = left; - this.operatorToken = operatorToken; - this.right = right; - - this._kind = kind; - } - BinaryExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitBinaryExpression(this); - }; - - BinaryExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - BinaryExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.left; - case 1: - return this.operatorToken; - case 2: - return this.right; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BinaryExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - BinaryExpressionSyntax.prototype.kind = function () { - return this._kind; - }; - - BinaryExpressionSyntax.prototype.update = function (kind, left, operatorToken, right) { - if (this._kind === kind && this.left === left && this.operatorToken === operatorToken && this.right === right) { - return this; - } - - return new BinaryExpressionSyntax(kind, left, operatorToken, right, this.parsedInStrictMode()); - }; - - BinaryExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BinaryExpressionSyntax.prototype.withKind = function (kind) { - return this.update(kind, this.left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withLeft = function (left) { - return this.update(this._kind, left, this.operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withOperatorToken = function (operatorToken) { - return this.update(this._kind, this.left, operatorToken, this.right); - }; - - BinaryExpressionSyntax.prototype.withRight = function (right) { - return this.update(this._kind, this.left, this.operatorToken, right); - }; - - BinaryExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.left.isTypeScriptSpecific()) { - return true; - } - if (this.right.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BinaryExpressionSyntax = BinaryExpressionSyntax; - - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.condition = condition; - this.questionToken = questionToken; - this.whenTrue = whenTrue; - this.colonToken = colonToken; - this.whenFalse = whenFalse; - } - ConditionalExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitConditionalExpression(this); - }; - - ConditionalExpressionSyntax.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - ConditionalExpressionSyntax.prototype.childCount = function () { - return 5; - }; - - ConditionalExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.condition; - case 1: - return this.questionToken; - case 2: - return this.whenTrue; - case 3: - return this.colonToken; - case 4: - return this.whenFalse; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConditionalExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ConditionalExpressionSyntax.prototype.update = function (condition, questionToken, whenTrue, colonToken, whenFalse) { - if (this.condition === condition && this.questionToken === questionToken && this.whenTrue === whenTrue && this.colonToken === colonToken && this.whenFalse === whenFalse) { - return this; - } - - return new ConditionalExpressionSyntax(condition, questionToken, whenTrue, colonToken, whenFalse, this.parsedInStrictMode()); - }; - - ConditionalExpressionSyntax.create1 = function (condition, whenTrue, whenFalse) { - return new ConditionalExpressionSyntax(condition, TypeScript.Syntax.token(105 /* QuestionToken */), whenTrue, TypeScript.Syntax.token(106 /* ColonToken */), whenFalse, false); - }; - - ConditionalExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConditionalExpressionSyntax.prototype.withCondition = function (condition) { - return this.update(condition, this.questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.condition, questionToken, this.whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenTrue = function (whenTrue) { - return this.update(this.condition, this.questionToken, whenTrue, this.colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.condition, this.questionToken, this.whenTrue, colonToken, this.whenFalse); - }; - - ConditionalExpressionSyntax.prototype.withWhenFalse = function (whenFalse) { - return this.update(this.condition, this.questionToken, this.whenTrue, this.colonToken, whenFalse); - }; - - ConditionalExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.whenTrue.isTypeScriptSpecific()) { - return true; - } - if (this.whenFalse.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(newKeyword, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.callSignature = callSignature; - } - ConstructSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructSignature(this); - }; - - ConstructSignatureSyntax.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - - ConstructSignatureSyntax.prototype.childCount = function () { - return 2; - }; - - ConstructSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - ConstructSignatureSyntax.prototype.update = function (newKeyword, callSignature) { - if (this.newKeyword === newKeyword && this.callSignature === callSignature) { - return this; - } - - return new ConstructSignatureSyntax(newKeyword, callSignature, this.parsedInStrictMode()); - }; - - ConstructSignatureSyntax.create1 = function () { - return new ConstructSignatureSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), CallSignatureSyntax.create1(), false); - }; - - ConstructSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructSignatureSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.callSignature); - }; - - ConstructSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.newKeyword, callSignature); - }; - - ConstructSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructSignatureSyntax = ConstructSignatureSyntax; - - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(propertyName, questionToken, callSignature, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - } - MethodSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitMethodSignature(this); - }; - - MethodSignatureSyntax.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - - MethodSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - MethodSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.callSignature; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MethodSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - MethodSignatureSyntax.prototype.update = function (propertyName, questionToken, callSignature) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.callSignature === callSignature) { - return this; - } - - return new MethodSignatureSyntax(propertyName, questionToken, callSignature, this.parsedInStrictMode()); - }; - - MethodSignatureSyntax.create = function (propertyName, callSignature) { - return new MethodSignatureSyntax(propertyName, null, callSignature, false); - }; - - MethodSignatureSyntax.create1 = function (propertyName) { - return new MethodSignatureSyntax(propertyName, null, CallSignatureSyntax.create1(), false); - }; - - MethodSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MethodSignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.callSignature); - }; - - MethodSignatureSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, this.questionToken, callSignature); - }; - - MethodSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MethodSignatureSyntax = MethodSignatureSyntax; - - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBracketToken = openBracketToken; - this.parameter = parameter; - this.closeBracketToken = closeBracketToken; - this.typeAnnotation = typeAnnotation; - } - IndexSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexSignature(this); - }; - - IndexSignatureSyntax.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - - IndexSignatureSyntax.prototype.childCount = function () { - return 4; - }; - - IndexSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBracketToken; - case 1: - return this.parameter; - case 2: - return this.closeBracketToken; - case 3: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - IndexSignatureSyntax.prototype.update = function (openBracketToken, parameter, closeBracketToken, typeAnnotation) { - if (this.openBracketToken === openBracketToken && this.parameter === parameter && this.closeBracketToken === closeBracketToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, typeAnnotation, this.parsedInStrictMode()); - }; - - IndexSignatureSyntax.create = function (openBracketToken, parameter, closeBracketToken) { - return new IndexSignatureSyntax(openBracketToken, parameter, closeBracketToken, null, false); - }; - - IndexSignatureSyntax.create1 = function (parameter) { - return new IndexSignatureSyntax(TypeScript.Syntax.token(74 /* OpenBracketToken */), parameter, TypeScript.Syntax.token(75 /* CloseBracketToken */), null, false); - }; - - IndexSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexSignatureSyntax.prototype.withOpenBracketToken = function (openBracketToken) { - return this.update(openBracketToken, this.parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withParameter = function (parameter) { - return this.update(this.openBracketToken, parameter, this.closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withCloseBracketToken = function (closeBracketToken) { - return this.update(this.openBracketToken, this.parameter, closeBracketToken, this.typeAnnotation); - }; - - IndexSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.openBracketToken, this.parameter, this.closeBracketToken, typeAnnotation); - }; - - IndexSignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexSignatureSyntax = IndexSignatureSyntax; - - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - } - PropertySignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitPropertySignature(this); - }; - - PropertySignatureSyntax.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - - PropertySignatureSyntax.prototype.childCount = function () { - return 3; - }; - - PropertySignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.questionToken; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - PropertySignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - PropertySignatureSyntax.prototype.update = function (propertyName, questionToken, typeAnnotation) { - if (this.propertyName === propertyName && this.questionToken === questionToken && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new PropertySignatureSyntax(propertyName, questionToken, typeAnnotation, this.parsedInStrictMode()); - }; - - PropertySignatureSyntax.create = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.create1 = function (propertyName) { - return new PropertySignatureSyntax(propertyName, null, null, false); - }; - - PropertySignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - PropertySignatureSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withQuestionToken = function (questionToken) { - return this.update(this.propertyName, questionToken, this.typeAnnotation); - }; - - PropertySignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.propertyName, this.questionToken, typeAnnotation); - }; - - PropertySignatureSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.PropertySignatureSyntax = PropertySignatureSyntax; - - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - } - CallSignatureSyntax.prototype.accept = function (visitor) { - return visitor.visitCallSignature(this); - }; - - CallSignatureSyntax.prototype.kind = function () { - return 142 /* CallSignature */; - }; - - CallSignatureSyntax.prototype.childCount = function () { - return 3; - }; - - CallSignatureSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeParameterList; - case 1: - return this.parameterList; - case 2: - return this.typeAnnotation; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CallSignatureSyntax.prototype.isTypeMember = function () { - return true; - }; - - CallSignatureSyntax.prototype.update = function (typeParameterList, parameterList, typeAnnotation) { - if (this.typeParameterList === typeParameterList && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation) { - return this; - } - - return new CallSignatureSyntax(typeParameterList, parameterList, typeAnnotation, this.parsedInStrictMode()); - }; - - CallSignatureSyntax.create = function (parameterList) { - return new CallSignatureSyntax(null, parameterList, null, false); - }; - - CallSignatureSyntax.create1 = function () { - return new CallSignatureSyntax(null, ParameterListSyntax.create1(), null, false); - }; - - CallSignatureSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CallSignatureSyntax.prototype.withTypeParameterList = function (typeParameterList) { - return this.update(typeParameterList, this.parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.typeParameterList, parameterList, this.typeAnnotation); - }; - - CallSignatureSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.typeParameterList, this.parameterList, typeAnnotation); - }; - - CallSignatureSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeParameterList !== null) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - return false; - }; - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CallSignatureSyntax = CallSignatureSyntax; - - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(openParenToken, parameters, closeParenToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openParenToken = openParenToken; - this.parameters = parameters; - this.closeParenToken = closeParenToken; - } - ParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitParameterList(this); - }; - - ParameterListSyntax.prototype.kind = function () { - return 227 /* ParameterList */; - }; - - ParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - ParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openParenToken; - case 1: - return this.parameters; - case 2: - return this.closeParenToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParameterListSyntax.prototype.update = function (openParenToken, parameters, closeParenToken) { - if (this.openParenToken === openParenToken && this.parameters === parameters && this.closeParenToken === closeParenToken) { - return this; - } - - return new ParameterListSyntax(openParenToken, parameters, closeParenToken, this.parsedInStrictMode()); - }; - - ParameterListSyntax.create = function (openParenToken, closeParenToken) { - return new ParameterListSyntax(openParenToken, TypeScript.Syntax.emptySeparatedList, closeParenToken, false); - }; - - ParameterListSyntax.create1 = function () { - return new ParameterListSyntax(TypeScript.Syntax.token(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(73 /* CloseParenToken */), false); - }; - - ParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ParameterListSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(openParenToken, this.parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameters = function (parameters) { - return this.update(this.openParenToken, parameters, this.closeParenToken); - }; - - ParameterListSyntax.prototype.withParameter = function (parameter) { - return this.withParameters(TypeScript.Syntax.separatedList([parameter])); - }; - - ParameterListSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.openParenToken, this.parameters, closeParenToken); - }; - - ParameterListSyntax.prototype.isTypeScriptSpecific = function () { - if (this.parameters.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ParameterListSyntax = ParameterListSyntax; - - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.typeParameters = typeParameters; - this.greaterThanToken = greaterThanToken; - } - TypeParameterListSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameterList(this); - }; - - TypeParameterListSyntax.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - - TypeParameterListSyntax.prototype.childCount = function () { - return 3; - }; - - TypeParameterListSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.typeParameters; - case 2: - return this.greaterThanToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterListSyntax.prototype.update = function (lessThanToken, typeParameters, greaterThanToken) { - if (this.lessThanToken === lessThanToken && this.typeParameters === typeParameters && this.greaterThanToken === greaterThanToken) { - return this; - } - - return new TypeParameterListSyntax(lessThanToken, typeParameters, greaterThanToken, this.parsedInStrictMode()); - }; - - TypeParameterListSyntax.create = function (lessThanToken, greaterThanToken) { - return new TypeParameterListSyntax(lessThanToken, TypeScript.Syntax.emptySeparatedList, greaterThanToken, false); - }; - - TypeParameterListSyntax.create1 = function () { - return new TypeParameterListSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(81 /* GreaterThanToken */), false); - }; - - TypeParameterListSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterListSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameters = function (typeParameters) { - return this.update(this.lessThanToken, typeParameters, this.greaterThanToken); - }; - - TypeParameterListSyntax.prototype.withTypeParameter = function (typeParameter) { - return this.withTypeParameters(TypeScript.Syntax.separatedList([typeParameter])); - }; - - TypeParameterListSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.typeParameters, greaterThanToken); - }; - - TypeParameterListSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterListSyntax = TypeParameterListSyntax; - - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(identifier, constraint, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.constraint = constraint; - } - TypeParameterSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeParameter(this); - }; - - TypeParameterSyntax.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameterSyntax.prototype.childCount = function () { - return 2; - }; - - TypeParameterSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.constraint; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeParameterSyntax.prototype.update = function (identifier, constraint) { - if (this.identifier === identifier && this.constraint === constraint) { - return this; - } - - return new TypeParameterSyntax(identifier, constraint, this.parsedInStrictMode()); - }; - - TypeParameterSyntax.create = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.create1 = function (identifier) { - return new TypeParameterSyntax(identifier, null, false); - }; - - TypeParameterSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeParameterSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.constraint); - }; - - TypeParameterSyntax.prototype.withConstraint = function (constraint) { - return this.update(this.identifier, constraint); - }; - - TypeParameterSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeParameterSyntax = TypeParameterSyntax; - - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(extendsKeyword, type, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.extendsKeyword = extendsKeyword; - this.type = type; - } - ConstraintSyntax.prototype.accept = function (visitor) { - return visitor.visitConstraint(this); - }; - - ConstraintSyntax.prototype.kind = function () { - return 239 /* Constraint */; - }; - - ConstraintSyntax.prototype.childCount = function () { - return 2; - }; - - ConstraintSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.extendsKeyword; - case 1: - return this.type; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstraintSyntax.prototype.update = function (extendsKeyword, type) { - if (this.extendsKeyword === extendsKeyword && this.type === type) { - return this; - } - - return new ConstraintSyntax(extendsKeyword, type, this.parsedInStrictMode()); - }; - - ConstraintSyntax.create1 = function (type) { - return new ConstraintSyntax(TypeScript.Syntax.token(48 /* ExtendsKeyword */), type, false); - }; - - ConstraintSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstraintSyntax.prototype.withExtendsKeyword = function (extendsKeyword) { - return this.update(extendsKeyword, this.type); - }; - - ConstraintSyntax.prototype.withType = function (type) { - return this.update(this.extendsKeyword, type); - }; - - ConstraintSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstraintSyntax = ConstraintSyntax; - - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(elseKeyword, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.elseKeyword = elseKeyword; - this.statement = statement; - } - ElseClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitElseClause(this); - }; - - ElseClauseSyntax.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClauseSyntax.prototype.childCount = function () { - return 2; - }; - - ElseClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.elseKeyword; - case 1: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ElseClauseSyntax.prototype.update = function (elseKeyword, statement) { - if (this.elseKeyword === elseKeyword && this.statement === statement) { - return this; - } - - return new ElseClauseSyntax(elseKeyword, statement, this.parsedInStrictMode()); - }; - - ElseClauseSyntax.create1 = function (statement) { - return new ElseClauseSyntax(TypeScript.Syntax.token(23 /* ElseKeyword */), statement, false); - }; - - ElseClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ElseClauseSyntax.prototype.withElseKeyword = function (elseKeyword) { - return this.update(elseKeyword, this.statement); - }; - - ElseClauseSyntax.prototype.withStatement = function (statement) { - return this.update(this.elseKeyword, statement); - }; - - ElseClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ElseClauseSyntax = ElseClauseSyntax; - - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.ifKeyword = ifKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - this.elseClause = elseClause; - } - IfStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitIfStatement(this); - }; - - IfStatementSyntax.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatementSyntax.prototype.childCount = function () { - return 6; - }; - - IfStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.ifKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - case 5: - return this.elseClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IfStatementSyntax.prototype.isStatement = function () { - return true; - }; - - IfStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - IfStatementSyntax.prototype.update = function (ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - if (this.ifKeyword === ifKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement && this.elseClause === elseClause) { - return this; - } - - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause, this.parsedInStrictMode()); - }; - - IfStatementSyntax.create = function (ifKeyword, openParenToken, condition, closeParenToken, statement) { - return new IfStatementSyntax(ifKeyword, openParenToken, condition, closeParenToken, statement, null, false); - }; - - IfStatementSyntax.create1 = function (condition, statement) { - return new IfStatementSyntax(TypeScript.Syntax.token(28 /* IfKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, null, false); - }; - - IfStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IfStatementSyntax.prototype.withIfKeyword = function (ifKeyword) { - return this.update(ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.ifKeyword, openParenToken, this.condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.ifKeyword, this.openParenToken, condition, this.closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, closeParenToken, this.statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, statement, this.elseClause); - }; - - IfStatementSyntax.prototype.withElseClause = function (elseClause) { - return this.update(this.ifKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement, elseClause); - }; - - IfStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.elseClause !== null && this.elseClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IfStatementSyntax = IfStatementSyntax; - - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ExpressionStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitExpressionStatement(this); - }; - - ExpressionStatementSyntax.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatementSyntax.prototype.childCount = function () { - return 2; - }; - - ExpressionStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.expression; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ExpressionStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ExpressionStatementSyntax.prototype.update = function (expression, semicolonToken) { - if (this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ExpressionStatementSyntax(expression, semicolonToken, this.parsedInStrictMode()); - }; - - ExpressionStatementSyntax.create1 = function (expression) { - return new ExpressionStatementSyntax(expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ExpressionStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ExpressionStatementSyntax.prototype.withExpression = function (expression) { - return this.update(expression, this.semicolonToken); - }; - - ExpressionStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.expression, semicolonToken); - }; - - ExpressionStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ExpressionStatementSyntax = ExpressionStatementSyntax; - - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(modifiers, constructorKeyword, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.constructorKeyword = constructorKeyword; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - ConstructorDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitConstructorDeclaration(this); - }; - - ConstructorDeclarationSyntax.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - - ConstructorDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - ConstructorDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.constructorKeyword; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ConstructorDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - 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, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - 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 */), CallSignatureSyntax.create1(), null, null, false); - }; - - ConstructorDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ConstructorDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.constructorKeyword, this.callSignature, this.block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - ConstructorDeclarationSyntax.prototype.withConstructorKeyword = function (constructorKeyword) { - return this.update(this.modifiers, constructorKeyword, this.callSignature, 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.callSignature, block, this.semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.constructorKeyword, this.callSignature, this.block, semicolonToken); - }; - - ConstructorDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - this.semicolonToken = semicolonToken; - } - MemberFunctionDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberFunctionDeclaration(this); - }; - - MemberFunctionDeclarationSyntax.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - - MemberFunctionDeclarationSyntax.prototype.childCount = function () { - return 5; - }; - - MemberFunctionDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.propertyName; - case 2: - return this.callSignature; - case 3: - return this.block; - case 4: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberFunctionDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberFunctionDeclarationSyntax.prototype.update = function (modifiers, propertyName, callSignature, block, semicolonToken) { - if (this.modifiers === modifiers && this.propertyName === propertyName && this.callSignature === callSignature && this.block === block && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberFunctionDeclarationSyntax(modifiers, propertyName, callSignature, block, semicolonToken, this.parsedInStrictMode()); - }; - - MemberFunctionDeclarationSyntax.create = function (propertyName, callSignature) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, callSignature, null, null, false); - }; - - MemberFunctionDeclarationSyntax.create1 = function (propertyName) { - return new MemberFunctionDeclarationSyntax(TypeScript.Syntax.emptyList, propertyName, CallSignatureSyntax.create1(), null, null, false); - }; - - MemberFunctionDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberFunctionDeclarationSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, propertyName, this.callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.modifiers, this.propertyName, callSignature, this.block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.propertyName, this.callSignature, block, this.semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.propertyName, this.callSignature, this.block, semicolonToken); - }; - - MemberFunctionDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - - var GetAccessorSyntax = (function (_super) { - __extends(GetAccessorSyntax, _super); - function GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.getKeyword = getKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - } - GetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitGetAccessor(this); - }; - - GetAccessorSyntax.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - - GetAccessorSyntax.prototype.childCount = function () { - return 6; - }; - - GetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.getKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.typeAnnotation; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - GetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - GetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - GetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - GetAccessorSyntax.prototype.update = function (modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block) { - if (this.modifiers === modifiers && this.getKeyword === getKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.typeAnnotation === typeAnnotation && this.block === block) { - return this; - } - - return new GetAccessorSyntax(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block, this.parsedInStrictMode()); - }; - - GetAccessorSyntax.create = function (getKeyword, propertyName, parameterList, block) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, getKeyword, propertyName, parameterList, null, block, false); - }; - - GetAccessorSyntax.create1 = function (propertyName) { - return new GetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(64 /* GetKeyword */), propertyName, ParameterListSyntax.create1(), null, BlockSyntax.create1(), false); - }; - - GetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - GetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - GetAccessorSyntax.prototype.withGetKeyword = function (getKeyword) { - return this.update(this.modifiers, getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.getKeyword, propertyName, this.parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, parameterList, this.typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, typeAnnotation, this.block); - }; - - GetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.getKeyword, this.propertyName, this.parameterList, this.typeAnnotation, block); - }; - - GetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - if (this.modifiers.childCount() > 0) { - return true; - } - if (this.parameterList.isTypeScriptSpecific()) { - return true; - } - if (this.typeAnnotation !== null) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return GetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.GetAccessorSyntax = GetAccessorSyntax; - - var SetAccessorSyntax = (function (_super) { - __extends(SetAccessorSyntax, _super); - function SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.setKeyword = setKeyword; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - } - SetAccessorSyntax.prototype.accept = function (visitor) { - return visitor.visitSetAccessor(this); - }; - - SetAccessorSyntax.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - - SetAccessorSyntax.prototype.childCount = function () { - return 5; - }; - - SetAccessorSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.setKeyword; - case 2: - return this.propertyName; - case 3: - return this.parameterList; - case 4: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SetAccessorSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - SetAccessorSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SetAccessorSyntax.prototype.isClassElement = function () { - return true; - }; - - SetAccessorSyntax.prototype.update = function (modifiers, setKeyword, propertyName, parameterList, block) { - if (this.modifiers === modifiers && this.setKeyword === setKeyword && this.propertyName === propertyName && this.parameterList === parameterList && this.block === block) { - return this; - } - - return new SetAccessorSyntax(modifiers, setKeyword, propertyName, parameterList, block, this.parsedInStrictMode()); - }; - - SetAccessorSyntax.create = function (setKeyword, propertyName, parameterList, block) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, setKeyword, propertyName, parameterList, block, false); - }; - - SetAccessorSyntax.create1 = function (propertyName) { - return new SetAccessorSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(68 /* SetKeyword */), propertyName, ParameterListSyntax.create1(), BlockSyntax.create1(), false); - }; - - SetAccessorSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SetAccessorSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - SetAccessorSyntax.prototype.withSetKeyword = function (setKeyword) { - return this.update(this.modifiers, setKeyword, this.propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(this.modifiers, this.setKeyword, propertyName, this.parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withParameterList = function (parameterList) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, parameterList, this.block); - }; - - SetAccessorSyntax.prototype.withBlock = function (block) { - return this.update(this.modifiers, this.setKeyword, this.propertyName, this.parameterList, block); - }; - - SetAccessorSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return SetAccessorSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SetAccessorSyntax = SetAccessorSyntax; - - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - this.semicolonToken = semicolonToken; - } - MemberVariableDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitMemberVariableDeclaration(this); - }; - - MemberVariableDeclarationSyntax.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - - MemberVariableDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - MemberVariableDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.variableDeclarator; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - MemberVariableDeclarationSyntax.prototype.isMemberDeclaration = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - MemberVariableDeclarationSyntax.prototype.update = function (modifiers, variableDeclarator, semicolonToken) { - if (this.modifiers === modifiers && this.variableDeclarator === variableDeclarator && this.semicolonToken === semicolonToken) { - return this; - } - - return new MemberVariableDeclarationSyntax(modifiers, variableDeclarator, semicolonToken, this.parsedInStrictMode()); - }; - - MemberVariableDeclarationSyntax.create = function (variableDeclarator, semicolonToken) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, semicolonToken, false); - }; - - MemberVariableDeclarationSyntax.create1 = function (variableDeclarator) { - return new MemberVariableDeclarationSyntax(TypeScript.Syntax.emptyList, variableDeclarator, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - MemberVariableDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - MemberVariableDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - MemberVariableDeclarationSyntax.prototype.withVariableDeclarator = function (variableDeclarator) { - return this.update(this.modifiers, variableDeclarator, this.semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.variableDeclarator, semicolonToken); - }; - - MemberVariableDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - - var IndexMemberDeclarationSyntax = (function (_super) { - __extends(IndexMemberDeclarationSyntax, _super); - function IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.indexSignature = indexSignature; - this.semicolonToken = semicolonToken; - } - IndexMemberDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitIndexMemberDeclaration(this); - }; - - IndexMemberDeclarationSyntax.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - - IndexMemberDeclarationSyntax.prototype.childCount = function () { - return 3; - }; - - IndexMemberDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.indexSignature; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - IndexMemberDeclarationSyntax.prototype.isClassElement = function () { - return true; - }; - - IndexMemberDeclarationSyntax.prototype.update = function (modifiers, indexSignature, semicolonToken) { - if (this.modifiers === modifiers && this.indexSignature === indexSignature && this.semicolonToken === semicolonToken) { - return this; - } - - return new IndexMemberDeclarationSyntax(modifiers, indexSignature, semicolonToken, this.parsedInStrictMode()); - }; - - IndexMemberDeclarationSyntax.create = function (indexSignature, semicolonToken) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, semicolonToken, false); - }; - - IndexMemberDeclarationSyntax.create1 = function (indexSignature) { - return new IndexMemberDeclarationSyntax(TypeScript.Syntax.emptyList, indexSignature, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - IndexMemberDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - IndexMemberDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - IndexMemberDeclarationSyntax.prototype.withIndexSignature = function (indexSignature) { - return this.update(this.modifiers, indexSignature, this.semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.modifiers, this.indexSignature, semicolonToken); - }; - - IndexMemberDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return IndexMemberDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; - - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(throwKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.throwKeyword = throwKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ThrowStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitThrowStatement(this); - }; - - ThrowStatementSyntax.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ThrowStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.throwKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ThrowStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ThrowStatementSyntax.prototype.update = function (throwKeyword, expression, semicolonToken) { - if (this.throwKeyword === throwKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ThrowStatementSyntax(throwKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ThrowStatementSyntax.create1 = function (expression) { - return new ThrowStatementSyntax(TypeScript.Syntax.token(36 /* ThrowKeyword */), expression, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ThrowStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ThrowStatementSyntax.prototype.withThrowKeyword = function (throwKeyword) { - return this.update(throwKeyword, this.expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.throwKeyword, expression, this.semicolonToken); - }; - - ThrowStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.throwKeyword, this.expression, semicolonToken); - }; - - ThrowStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ThrowStatementSyntax = ThrowStatementSyntax; - - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(returnKeyword, expression, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.returnKeyword = returnKeyword; - this.expression = expression; - this.semicolonToken = semicolonToken; - } - ReturnStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitReturnStatement(this); - }; - - ReturnStatementSyntax.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ReturnStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.returnKeyword; - case 1: - return this.expression; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ReturnStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ReturnStatementSyntax.prototype.update = function (returnKeyword, expression, semicolonToken) { - if (this.returnKeyword === returnKeyword && this.expression === expression && this.semicolonToken === semicolonToken) { - return this; - } - - return new ReturnStatementSyntax(returnKeyword, expression, semicolonToken, this.parsedInStrictMode()); - }; - - ReturnStatementSyntax.create = function (returnKeyword, semicolonToken) { - return new ReturnStatementSyntax(returnKeyword, null, semicolonToken, false); - }; - - ReturnStatementSyntax.create1 = function () { - return new ReturnStatementSyntax(TypeScript.Syntax.token(33 /* ReturnKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ReturnStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ReturnStatementSyntax.prototype.withReturnKeyword = function (returnKeyword) { - return this.update(returnKeyword, this.expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.returnKeyword, expression, this.semicolonToken); - }; - - ReturnStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.returnKeyword, this.expression, semicolonToken); - }; - - ReturnStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression !== null && this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ReturnStatementSyntax = ReturnStatementSyntax; - - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.newKeyword = newKeyword; - this.expression = expression; - this.argumentList = argumentList; - } - ObjectCreationExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectCreationExpression(this); - }; - - ObjectCreationExpressionSyntax.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - ObjectCreationExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectCreationExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.newKeyword; - case 1: - return this.expression; - case 2: - return this.argumentList; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectCreationExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectCreationExpressionSyntax.prototype.update = function (newKeyword, expression, argumentList) { - if (this.newKeyword === newKeyword && this.expression === expression && this.argumentList === argumentList) { - return this; - } - - return new ObjectCreationExpressionSyntax(newKeyword, expression, argumentList, this.parsedInStrictMode()); - }; - - ObjectCreationExpressionSyntax.create = function (newKeyword, expression) { - return new ObjectCreationExpressionSyntax(newKeyword, expression, null, false); - }; - - ObjectCreationExpressionSyntax.create1 = function (expression) { - return new ObjectCreationExpressionSyntax(TypeScript.Syntax.token(31 /* NewKeyword */), expression, null, false); - }; - - ObjectCreationExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectCreationExpressionSyntax.prototype.withNewKeyword = function (newKeyword) { - return this.update(newKeyword, this.expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.newKeyword, expression, this.argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.withArgumentList = function (argumentList) { - return this.update(this.newKeyword, this.expression, argumentList); - }; - - ObjectCreationExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.argumentList !== null && this.argumentList.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.switchKeyword = switchKeyword; - this.openParenToken = openParenToken; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.openBraceToken = openBraceToken; - this.switchClauses = switchClauses; - this.closeBraceToken = closeBraceToken; - } - SwitchStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitSwitchStatement(this); - }; - - SwitchStatementSyntax.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatementSyntax.prototype.childCount = function () { - return 7; - }; - - SwitchStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.switchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.expression; - case 3: - return this.closeParenToken; - case 4: - return this.openBraceToken; - case 5: - return this.switchClauses; - case 6: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SwitchStatementSyntax.prototype.isStatement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - SwitchStatementSyntax.prototype.update = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - if (this.switchKeyword === switchKeyword && this.openParenToken === openParenToken && this.expression === expression && this.closeParenToken === closeParenToken && this.openBraceToken === openBraceToken && this.switchClauses === switchClauses && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken, this.parsedInStrictMode()); - }; - - SwitchStatementSyntax.create = function (switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, closeBraceToken) { - return new SwitchStatementSyntax(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, TypeScript.Syntax.emptyList, closeBraceToken, false); - }; - - SwitchStatementSyntax.create1 = function (expression) { - return new SwitchStatementSyntax(TypeScript.Syntax.token(34 /* SwitchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptyList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - SwitchStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SwitchStatementSyntax.prototype.withSwitchKeyword = function (switchKeyword) { - return this.update(switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.switchKeyword, openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.switchKeyword, this.openParenToken, expression, this.closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, closeParenToken, this.openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, openBraceToken, this.switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClauses = function (switchClauses) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, switchClauses, this.closeBraceToken); - }; - - SwitchStatementSyntax.prototype.withSwitchClause = function (switchClause) { - return this.withSwitchClauses(TypeScript.Syntax.list([switchClause])); - }; - - SwitchStatementSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.switchKeyword, this.openParenToken, this.expression, this.closeParenToken, this.openBraceToken, this.switchClauses, closeBraceToken); - }; - - SwitchStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.switchClauses.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SwitchStatementSyntax = SwitchStatementSyntax; - - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.caseKeyword = caseKeyword; - this.expression = expression; - this.colonToken = colonToken; - this.statements = statements; - } - CaseSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCaseSwitchClause(this); - }; - - CaseSwitchClauseSyntax.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClauseSyntax.prototype.childCount = function () { - return 4; - }; - - CaseSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.caseKeyword; - case 1: - return this.expression; - case 2: - return this.colonToken; - case 3: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CaseSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - CaseSwitchClauseSyntax.prototype.update = function (caseKeyword, expression, colonToken, statements) { - if (this.caseKeyword === caseKeyword && this.expression === expression && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, statements, this.parsedInStrictMode()); - }; - - CaseSwitchClauseSyntax.create = function (caseKeyword, expression, colonToken) { - return new CaseSwitchClauseSyntax(caseKeyword, expression, colonToken, TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.create1 = function (expression) { - return new CaseSwitchClauseSyntax(TypeScript.Syntax.token(16 /* CaseKeyword */), expression, TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - CaseSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CaseSwitchClauseSyntax.prototype.withCaseKeyword = function (caseKeyword) { - return this.update(caseKeyword, this.expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withExpression = function (expression) { - return this.update(this.caseKeyword, expression, this.colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.caseKeyword, this.expression, colonToken, this.statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.caseKeyword, this.expression, this.colonToken, statements); - }; - - CaseSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - CaseSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CaseSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.defaultKeyword = defaultKeyword; - this.colonToken = colonToken; - this.statements = statements; - } - DefaultSwitchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitDefaultSwitchClause(this); - }; - - DefaultSwitchClauseSyntax.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClauseSyntax.prototype.childCount = function () { - return 3; - }; - - DefaultSwitchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.defaultKeyword; - case 1: - return this.colonToken; - case 2: - return this.statements; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DefaultSwitchClauseSyntax.prototype.isSwitchClause = function () { - return true; - }; - - DefaultSwitchClauseSyntax.prototype.update = function (defaultKeyword, colonToken, statements) { - if (this.defaultKeyword === defaultKeyword && this.colonToken === colonToken && this.statements === statements) { - return this; - } - - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, statements, this.parsedInStrictMode()); - }; - - DefaultSwitchClauseSyntax.create = function (defaultKeyword, colonToken) { - return new DefaultSwitchClauseSyntax(defaultKeyword, colonToken, TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.create1 = function () { - return new DefaultSwitchClauseSyntax(TypeScript.Syntax.token(20 /* DefaultKeyword */), TypeScript.Syntax.token(106 /* ColonToken */), TypeScript.Syntax.emptyList, false); - }; - - DefaultSwitchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DefaultSwitchClauseSyntax.prototype.withDefaultKeyword = function (defaultKeyword) { - return this.update(defaultKeyword, this.colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.defaultKeyword, colonToken, this.statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatements = function (statements) { - return this.update(this.defaultKeyword, this.colonToken, statements); - }; - - DefaultSwitchClauseSyntax.prototype.withStatement = function (statement) { - return this.withStatements(TypeScript.Syntax.list([statement])); - }; - - DefaultSwitchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statements.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DefaultSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(breakKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.breakKeyword = breakKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - BreakStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitBreakStatement(this); - }; - - BreakStatementSyntax.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatementSyntax.prototype.childCount = function () { - return 3; - }; - - BreakStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.breakKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - BreakStatementSyntax.prototype.isStatement = function () { - return true; - }; - - BreakStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - BreakStatementSyntax.prototype.update = function (breakKeyword, identifier, semicolonToken) { - if (this.breakKeyword === breakKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new BreakStatementSyntax(breakKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - BreakStatementSyntax.create = function (breakKeyword, semicolonToken) { - return new BreakStatementSyntax(breakKeyword, null, semicolonToken, false); - }; - - BreakStatementSyntax.create1 = function () { - return new BreakStatementSyntax(TypeScript.Syntax.token(15 /* BreakKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - BreakStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - BreakStatementSyntax.prototype.withBreakKeyword = function (breakKeyword) { - return this.update(breakKeyword, this.identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.breakKeyword, identifier, this.semicolonToken); - }; - - BreakStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.breakKeyword, this.identifier, semicolonToken); - }; - - BreakStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.BreakStatementSyntax = BreakStatementSyntax; - - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.continueKeyword = continueKeyword; - this.identifier = identifier; - this.semicolonToken = semicolonToken; - } - ContinueStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitContinueStatement(this); - }; - - ContinueStatementSyntax.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatementSyntax.prototype.childCount = function () { - return 3; - }; - - ContinueStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.continueKeyword; - case 1: - return this.identifier; - case 2: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ContinueStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ContinueStatementSyntax.prototype.update = function (continueKeyword, identifier, semicolonToken) { - if (this.continueKeyword === continueKeyword && this.identifier === identifier && this.semicolonToken === semicolonToken) { - return this; - } - - return new ContinueStatementSyntax(continueKeyword, identifier, semicolonToken, this.parsedInStrictMode()); - }; - - ContinueStatementSyntax.create = function (continueKeyword, semicolonToken) { - return new ContinueStatementSyntax(continueKeyword, null, semicolonToken, false); - }; - - ContinueStatementSyntax.create1 = function () { - return new ContinueStatementSyntax(TypeScript.Syntax.token(18 /* ContinueKeyword */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - ContinueStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ContinueStatementSyntax.prototype.withContinueKeyword = function (continueKeyword) { - return this.update(continueKeyword, this.identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.continueKeyword, identifier, this.semicolonToken); - }; - - ContinueStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.continueKeyword, this.identifier, semicolonToken); - }; - - ContinueStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ContinueStatementSyntax = ContinueStatementSyntax; - - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.firstSemicolonToken = firstSemicolonToken; - this.condition = condition; - this.secondSemicolonToken = secondSemicolonToken; - this.incrementor = incrementor; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForStatement(this); - }; - - ForStatementSyntax.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatementSyntax.prototype.childCount = function () { - return 10; - }; - - ForStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.initializer; - case 4: - return this.firstSemicolonToken; - case 5: - return this.condition; - case 6: - return this.secondSemicolonToken; - case 7: - return this.incrementor; - case 8: - return this.closeParenToken; - case 9: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.initializer === initializer && this.firstSemicolonToken === firstSemicolonToken && this.condition === condition && this.secondSemicolonToken === secondSemicolonToken && this.incrementor === incrementor && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForStatementSyntax(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForStatementSyntax.create = function (forKeyword, openParenToken, firstSemicolonToken, secondSemicolonToken, closeParenToken, statement) { - return new ForStatementSyntax(forKeyword, openParenToken, null, null, firstSemicolonToken, null, secondSemicolonToken, null, closeParenToken, statement, false); - }; - - ForStatementSyntax.create1 = function (statement) { - return new ForStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(78 /* SemicolonToken */), null, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withInitializer = function (initializer) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withFirstSemicolonToken = function (firstSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withSecondSemicolonToken = function (secondSemicolonToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, secondSemicolonToken, this.incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withIncrementor = function (incrementor) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, incrementor, this.closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, closeParenToken, this.statement); - }; - - ForStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.initializer, this.firstSemicolonToken, this.condition, this.secondSemicolonToken, this.incrementor, this.closeParenToken, statement); - }; - - ForStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.initializer !== null && this.initializer.isTypeScriptSpecific()) { - return true; - } - if (this.condition !== null && this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.incrementor !== null && this.incrementor.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForStatementSyntax = ForStatementSyntax; - - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.forKeyword = forKeyword; - this.openParenToken = openParenToken; - this.variableDeclaration = variableDeclaration; - this.left = left; - this.inKeyword = inKeyword; - this.expression = expression; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - ForInStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitForInStatement(this); - }; - - ForInStatementSyntax.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatementSyntax.prototype.childCount = function () { - return 8; - }; - - ForInStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.forKeyword; - case 1: - return this.openParenToken; - case 2: - return this.variableDeclaration; - case 3: - return this.left; - case 4: - return this.inKeyword; - case 5: - return this.expression; - case 6: - return this.closeParenToken; - case 7: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ForInStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isStatement = function () { - return true; - }; - - ForInStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - ForInStatementSyntax.prototype.update = function (forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - if (this.forKeyword === forKeyword && this.openParenToken === openParenToken && this.variableDeclaration === variableDeclaration && this.left === left && this.inKeyword === inKeyword && this.expression === expression && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new ForInStatementSyntax(forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement, this.parsedInStrictMode()); - }; - - ForInStatementSyntax.create = function (forKeyword, openParenToken, inKeyword, expression, closeParenToken, statement) { - return new ForInStatementSyntax(forKeyword, openParenToken, null, null, inKeyword, expression, closeParenToken, statement, false); - }; - - ForInStatementSyntax.create1 = function (expression, statement) { - return new ForInStatementSyntax(TypeScript.Syntax.token(26 /* ForKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), null, null, TypeScript.Syntax.token(29 /* InKeyword */), expression, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - ForInStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ForInStatementSyntax.prototype.withForKeyword = function (forKeyword) { - return this.update(forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.forKeyword, openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withVariableDeclaration = function (variableDeclaration) { - return this.update(this.forKeyword, this.openParenToken, variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withLeft = function (left) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, left, this.inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withInKeyword = function (inKeyword) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, inKeyword, this.expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withExpression = function (expression) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, expression, this.closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, closeParenToken, this.statement); - }; - - ForInStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.forKeyword, this.openParenToken, this.variableDeclaration, this.left, this.inKeyword, this.expression, this.closeParenToken, statement); - }; - - ForInStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.variableDeclaration !== null && this.variableDeclaration.isTypeScriptSpecific()) { - return true; - } - if (this.left !== null && this.left.isTypeScriptSpecific()) { - return true; - } - if (this.expression.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ForInStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ForInStatementSyntax = ForInStatementSyntax; - - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WhileStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWhileStatement(this); - }; - - WhileStatementSyntax.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WhileStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.whileKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WhileStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WhileStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WhileStatementSyntax.prototype.update = function (whileKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WhileStatementSyntax(whileKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WhileStatementSyntax.create1 = function (condition, statement) { - return new WhileStatementSyntax(TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WhileStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WhileStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WhileStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WhileStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WhileStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WhileStatementSyntax = WhileStatementSyntax; - - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.withKeyword = withKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.statement = statement; - } - WithStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitWithStatement(this); - }; - - WithStatementSyntax.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatementSyntax.prototype.childCount = function () { - return 5; - }; - - WithStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.withKeyword; - case 1: - return this.openParenToken; - case 2: - return this.condition; - case 3: - return this.closeParenToken; - case 4: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - WithStatementSyntax.prototype.isStatement = function () { - return true; - }; - - WithStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - WithStatementSyntax.prototype.update = function (withKeyword, openParenToken, condition, closeParenToken, statement) { - if (this.withKeyword === withKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.statement === statement) { - return this; - } - - return new WithStatementSyntax(withKeyword, openParenToken, condition, closeParenToken, statement, this.parsedInStrictMode()); - }; - - WithStatementSyntax.create1 = function (condition, statement) { - return new WithStatementSyntax(TypeScript.Syntax.token(43 /* WithKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), statement, false); - }; - - WithStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - WithStatementSyntax.prototype.withWithKeyword = function (withKeyword) { - return this.update(withKeyword, this.openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.withKeyword, openParenToken, this.condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.withKeyword, this.openParenToken, condition, this.closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.withKeyword, this.openParenToken, this.condition, closeParenToken, this.statement); - }; - - WithStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.withKeyword, this.openParenToken, this.condition, this.closeParenToken, statement); - }; - - WithStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.condition.isTypeScriptSpecific()) { - return true; - } - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.WithStatementSyntax = WithStatementSyntax; - - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.modifiers = modifiers; - this.enumKeyword = enumKeyword; - this.identifier = identifier; - this.openBraceToken = openBraceToken; - this.enumElements = enumElements; - this.closeBraceToken = closeBraceToken; - } - EnumDeclarationSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumDeclaration(this); - }; - - EnumDeclarationSyntax.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - - EnumDeclarationSyntax.prototype.childCount = function () { - return 6; - }; - - EnumDeclarationSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.modifiers; - case 1: - return this.enumKeyword; - case 2: - return this.identifier; - case 3: - return this.openBraceToken; - case 4: - return this.enumElements; - case 5: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumDeclarationSyntax.prototype.isModuleElement = function () { - return true; - }; - - EnumDeclarationSyntax.prototype.update = function (modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - if (this.modifiers === modifiers && this.enumKeyword === enumKeyword && this.identifier === identifier && this.openBraceToken === openBraceToken && this.enumElements === enumElements && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new EnumDeclarationSyntax(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken, this.parsedInStrictMode()); - }; - - EnumDeclarationSyntax.create = function (enumKeyword, identifier, openBraceToken, closeBraceToken) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, enumKeyword, identifier, openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - EnumDeclarationSyntax.create1 = function (identifier) { - return new EnumDeclarationSyntax(TypeScript.Syntax.emptyList, TypeScript.Syntax.token(46 /* EnumKeyword */), identifier, TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - EnumDeclarationSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumDeclarationSyntax.prototype.withModifiers = function (modifiers) { - return this.update(modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withModifier = function (modifier) { - return this.withModifiers(TypeScript.Syntax.list([modifier])); - }; - - EnumDeclarationSyntax.prototype.withEnumKeyword = function (enumKeyword) { - return this.update(this.modifiers, enumKeyword, this.identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.modifiers, this.enumKeyword, identifier, this.openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, openBraceToken, this.enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElements = function (enumElements) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, enumElements, this.closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.withEnumElement = function (enumElement) { - return this.withEnumElements(TypeScript.Syntax.separatedList([enumElement])); - }; - - EnumDeclarationSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.modifiers, this.enumKeyword, this.identifier, this.openBraceToken, this.enumElements, closeBraceToken); - }; - - EnumDeclarationSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumDeclarationSyntax = EnumDeclarationSyntax; - - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(propertyName, equalsValueClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - } - EnumElementSyntax.prototype.accept = function (visitor) { - return visitor.visitEnumElement(this); - }; - - EnumElementSyntax.prototype.kind = function () { - return 243 /* EnumElement */; - }; - - EnumElementSyntax.prototype.childCount = function () { - return 2; - }; - - EnumElementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.equalsValueClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EnumElementSyntax.prototype.update = function (propertyName, equalsValueClause) { - if (this.propertyName === propertyName && this.equalsValueClause === equalsValueClause) { - return this; - } - - return new EnumElementSyntax(propertyName, equalsValueClause, this.parsedInStrictMode()); - }; - - EnumElementSyntax.create = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.create1 = function (propertyName) { - return new EnumElementSyntax(propertyName, null, false); - }; - - EnumElementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EnumElementSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.equalsValueClause); - }; - - EnumElementSyntax.prototype.withEqualsValueClause = function (equalsValueClause) { - return this.update(this.propertyName, equalsValueClause); - }; - - EnumElementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.equalsValueClause !== null && this.equalsValueClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EnumElementSyntax = EnumElementSyntax; - - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.lessThanToken = lessThanToken; - this.type = type; - this.greaterThanToken = greaterThanToken; - this.expression = expression; - } - CastExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitCastExpression(this); - }; - - CastExpressionSyntax.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - CastExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - CastExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.lessThanToken; - case 1: - return this.type; - case 2: - return this.greaterThanToken; - case 3: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CastExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - CastExpressionSyntax.prototype.update = function (lessThanToken, type, greaterThanToken, expression) { - if (this.lessThanToken === lessThanToken && this.type === type && this.greaterThanToken === greaterThanToken && this.expression === expression) { - return this; - } - - return new CastExpressionSyntax(lessThanToken, type, greaterThanToken, expression, this.parsedInStrictMode()); - }; - - CastExpressionSyntax.create1 = function (type, expression) { - return new CastExpressionSyntax(TypeScript.Syntax.token(80 /* LessThanToken */), type, TypeScript.Syntax.token(81 /* GreaterThanToken */), expression, false); - }; - - CastExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CastExpressionSyntax.prototype.withLessThanToken = function (lessThanToken) { - return this.update(lessThanToken, this.type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withType = function (type) { - return this.update(this.lessThanToken, type, this.greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withGreaterThanToken = function (greaterThanToken) { - return this.update(this.lessThanToken, this.type, greaterThanToken, this.expression); - }; - - CastExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.lessThanToken, this.type, this.greaterThanToken, expression); - }; - - CastExpressionSyntax.prototype.isTypeScriptSpecific = function () { - return true; - }; - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CastExpressionSyntax = CastExpressionSyntax; - - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.openBraceToken = openBraceToken; - this.propertyAssignments = propertyAssignments; - this.closeBraceToken = closeBraceToken; - } - ObjectLiteralExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitObjectLiteralExpression(this); - }; - - ObjectLiteralExpressionSyntax.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - ObjectLiteralExpressionSyntax.prototype.childCount = function () { - return 3; - }; - - ObjectLiteralExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.openBraceToken; - case 1: - return this.propertyAssignments; - case 2: - return this.closeBraceToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ObjectLiteralExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - ObjectLiteralExpressionSyntax.prototype.update = function (openBraceToken, propertyAssignments, closeBraceToken) { - if (this.openBraceToken === openBraceToken && this.propertyAssignments === propertyAssignments && this.closeBraceToken === closeBraceToken) { - return this; - } - - return new ObjectLiteralExpressionSyntax(openBraceToken, propertyAssignments, closeBraceToken, this.parsedInStrictMode()); - }; - - ObjectLiteralExpressionSyntax.create = function (openBraceToken, closeBraceToken) { - return new ObjectLiteralExpressionSyntax(openBraceToken, TypeScript.Syntax.emptySeparatedList, closeBraceToken, false); - }; - - ObjectLiteralExpressionSyntax.create1 = function () { - return new ObjectLiteralExpressionSyntax(TypeScript.Syntax.token(70 /* OpenBraceToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.token(71 /* CloseBraceToken */), false); - }; - - ObjectLiteralExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - ObjectLiteralExpressionSyntax.prototype.withOpenBraceToken = function (openBraceToken) { - return this.update(openBraceToken, this.propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignments = function (propertyAssignments) { - return this.update(this.openBraceToken, propertyAssignments, this.closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.withPropertyAssignment = function (propertyAssignment) { - return this.withPropertyAssignments(TypeScript.Syntax.separatedList([propertyAssignment])); - }; - - ObjectLiteralExpressionSyntax.prototype.withCloseBraceToken = function (closeBraceToken) { - return this.update(this.openBraceToken, this.propertyAssignments, closeBraceToken); - }; - - ObjectLiteralExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.propertyAssignments.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.colonToken = colonToken; - this.expression = expression; - } - SimplePropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitSimplePropertyAssignment(this); - }; - - SimplePropertyAssignmentSyntax.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - - SimplePropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - SimplePropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.colonToken; - case 2: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SimplePropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - SimplePropertyAssignmentSyntax.prototype.update = function (propertyName, colonToken, expression) { - if (this.propertyName === propertyName && this.colonToken === colonToken && this.expression === expression) { - return this; - } - - return new SimplePropertyAssignmentSyntax(propertyName, colonToken, expression, this.parsedInStrictMode()); - }; - - SimplePropertyAssignmentSyntax.create1 = function (propertyName, expression) { - return new SimplePropertyAssignmentSyntax(propertyName, TypeScript.Syntax.token(106 /* ColonToken */), expression, false); - }; - - SimplePropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - SimplePropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.propertyName, colonToken, this.expression); - }; - - SimplePropertyAssignmentSyntax.prototype.withExpression = function (expression) { - return this.update(this.propertyName, this.colonToken, expression); - }; - - SimplePropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return SimplePropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - } - FunctionPropertyAssignmentSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionPropertyAssignment(this); - }; - - FunctionPropertyAssignmentSyntax.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - - FunctionPropertyAssignmentSyntax.prototype.childCount = function () { - return 3; - }; - - FunctionPropertyAssignmentSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.propertyName; - case 1: - return this.callSignature; - case 2: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionPropertyAssignmentSyntax.prototype.isPropertyAssignment = function () { - return true; - }; - - FunctionPropertyAssignmentSyntax.prototype.update = function (propertyName, callSignature, block) { - if (this.propertyName === propertyName && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionPropertyAssignmentSyntax(propertyName, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionPropertyAssignmentSyntax.create1 = function (propertyName) { - return new FunctionPropertyAssignmentSyntax(propertyName, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionPropertyAssignmentSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionPropertyAssignmentSyntax.prototype.withPropertyName = function (propertyName) { - return this.update(propertyName, this.callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.propertyName, callSignature, this.block); - }; - - FunctionPropertyAssignmentSyntax.prototype.withBlock = function (block) { - return this.update(this.propertyName, this.callSignature, block); - }; - - FunctionPropertyAssignmentSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionPropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.functionKeyword = functionKeyword; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - } - FunctionExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitFunctionExpression(this); - }; - - FunctionExpressionSyntax.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpressionSyntax.prototype.childCount = function () { - return 4; - }; - - FunctionExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.functionKeyword; - case 1: - return this.identifier; - case 2: - return this.callSignature; - case 3: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FunctionExpressionSyntax.prototype.isPrimaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isMemberExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isPostfixExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - FunctionExpressionSyntax.prototype.update = function (functionKeyword, identifier, callSignature, block) { - if (this.functionKeyword === functionKeyword && this.identifier === identifier && this.callSignature === callSignature && this.block === block) { - return this; - } - - return new FunctionExpressionSyntax(functionKeyword, identifier, callSignature, block, this.parsedInStrictMode()); - }; - - FunctionExpressionSyntax.create = function (functionKeyword, callSignature, block) { - return new FunctionExpressionSyntax(functionKeyword, null, callSignature, block, false); - }; - - FunctionExpressionSyntax.create1 = function () { - return new FunctionExpressionSyntax(TypeScript.Syntax.token(27 /* FunctionKeyword */), null, CallSignatureSyntax.create1(), BlockSyntax.create1(), false); - }; - - FunctionExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FunctionExpressionSyntax.prototype.withFunctionKeyword = function (functionKeyword) { - return this.update(functionKeyword, this.identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.functionKeyword, identifier, this.callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withCallSignature = function (callSignature) { - return this.update(this.functionKeyword, this.identifier, callSignature, this.block); - }; - - FunctionExpressionSyntax.prototype.withBlock = function (block) { - return this.update(this.functionKeyword, this.identifier, this.callSignature, block); - }; - - FunctionExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.callSignature.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FunctionExpressionSyntax = FunctionExpressionSyntax; - - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.semicolonToken = semicolonToken; - } - EmptyStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitEmptyStatement(this); - }; - - EmptyStatementSyntax.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatementSyntax.prototype.childCount = function () { - return 1; - }; - - EmptyStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - EmptyStatementSyntax.prototype.isStatement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - EmptyStatementSyntax.prototype.update = function (semicolonToken) { - if (this.semicolonToken === semicolonToken) { - return this; - } - - return new EmptyStatementSyntax(semicolonToken, this.parsedInStrictMode()); - }; - - EmptyStatementSyntax.create1 = function () { - return new EmptyStatementSyntax(TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - EmptyStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - EmptyStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(semicolonToken); - }; - - EmptyStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.EmptyStatementSyntax = EmptyStatementSyntax; - - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.tryKeyword = tryKeyword; - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - } - TryStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitTryStatement(this); - }; - - TryStatementSyntax.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatementSyntax.prototype.childCount = function () { - return 4; - }; - - TryStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.tryKeyword; - case 1: - return this.block; - case 2: - return this.catchClause; - case 3: - return this.finallyClause; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TryStatementSyntax.prototype.isStatement = function () { - return true; - }; - - TryStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - TryStatementSyntax.prototype.update = function (tryKeyword, block, catchClause, finallyClause) { - if (this.tryKeyword === tryKeyword && this.block === block && this.catchClause === catchClause && this.finallyClause === finallyClause) { - return this; - } - - return new TryStatementSyntax(tryKeyword, block, catchClause, finallyClause, this.parsedInStrictMode()); - }; - - TryStatementSyntax.create = function (tryKeyword, block) { - return new TryStatementSyntax(tryKeyword, block, null, null, false); - }; - - TryStatementSyntax.create1 = function () { - return new TryStatementSyntax(TypeScript.Syntax.token(38 /* TryKeyword */), BlockSyntax.create1(), null, null, false); - }; - - TryStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TryStatementSyntax.prototype.withTryKeyword = function (tryKeyword) { - return this.update(tryKeyword, this.block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withBlock = function (block) { - return this.update(this.tryKeyword, block, this.catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withCatchClause = function (catchClause) { - return this.update(this.tryKeyword, this.block, catchClause, this.finallyClause); - }; - - TryStatementSyntax.prototype.withFinallyClause = function (finallyClause) { - return this.update(this.tryKeyword, this.block, this.catchClause, finallyClause); - }; - - TryStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - if (this.catchClause !== null && this.catchClause.isTypeScriptSpecific()) { - return true; - } - if (this.finallyClause !== null && this.finallyClause.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TryStatementSyntax = TryStatementSyntax; - - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.catchKeyword = catchKeyword; - this.openParenToken = openParenToken; - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.closeParenToken = closeParenToken; - this.block = block; - } - CatchClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitCatchClause(this); - }; - - CatchClauseSyntax.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClauseSyntax.prototype.childCount = function () { - return 6; - }; - - CatchClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.catchKeyword; - case 1: - return this.openParenToken; - case 2: - return this.identifier; - case 3: - return this.typeAnnotation; - case 4: - return this.closeParenToken; - case 5: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - CatchClauseSyntax.prototype.update = function (catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - if (this.catchKeyword === catchKeyword && this.openParenToken === openParenToken && this.identifier === identifier && this.typeAnnotation === typeAnnotation && this.closeParenToken === closeParenToken && this.block === block) { - return this; - } - - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block, this.parsedInStrictMode()); - }; - - CatchClauseSyntax.create = function (catchKeyword, openParenToken, identifier, closeParenToken, block) { - return new CatchClauseSyntax(catchKeyword, openParenToken, identifier, null, closeParenToken, block, false); - }; - - CatchClauseSyntax.create1 = function (identifier) { - return new CatchClauseSyntax(TypeScript.Syntax.token(17 /* CatchKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), identifier, null, TypeScript.Syntax.token(73 /* CloseParenToken */), BlockSyntax.create1(), false); - }; - - CatchClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - CatchClauseSyntax.prototype.withCatchKeyword = function (catchKeyword) { - return this.update(catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.catchKeyword, openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withIdentifier = function (identifier) { - return this.update(this.catchKeyword, this.openParenToken, identifier, this.typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withTypeAnnotation = function (typeAnnotation) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, typeAnnotation, this.closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, closeParenToken, this.block); - }; - - CatchClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.catchKeyword, this.openParenToken, this.identifier, this.typeAnnotation, this.closeParenToken, block); - }; - - CatchClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.typeAnnotation !== null && this.typeAnnotation.isTypeScriptSpecific()) { - return true; - } - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.CatchClauseSyntax = CatchClauseSyntax; - - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(finallyKeyword, block, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.finallyKeyword = finallyKeyword; - this.block = block; - } - FinallyClauseSyntax.prototype.accept = function (visitor) { - return visitor.visitFinallyClause(this); - }; - - FinallyClauseSyntax.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClauseSyntax.prototype.childCount = function () { - return 2; - }; - - FinallyClauseSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.finallyKeyword; - case 1: - return this.block; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - FinallyClauseSyntax.prototype.update = function (finallyKeyword, block) { - if (this.finallyKeyword === finallyKeyword && this.block === block) { - return this; - } - - return new FinallyClauseSyntax(finallyKeyword, block, this.parsedInStrictMode()); - }; - - FinallyClauseSyntax.create1 = function () { - return new FinallyClauseSyntax(TypeScript.Syntax.token(25 /* FinallyKeyword */), BlockSyntax.create1(), false); - }; - - FinallyClauseSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - FinallyClauseSyntax.prototype.withFinallyKeyword = function (finallyKeyword) { - return this.update(finallyKeyword, this.block); - }; - - FinallyClauseSyntax.prototype.withBlock = function (block) { - return this.update(this.finallyKeyword, block); - }; - - FinallyClauseSyntax.prototype.isTypeScriptSpecific = function () { - if (this.block.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - TypeScript.FinallyClauseSyntax = FinallyClauseSyntax; - - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(identifier, colonToken, statement, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.identifier = identifier; - this.colonToken = colonToken; - this.statement = statement; - } - LabeledStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitLabeledStatement(this); - }; - - LabeledStatementSyntax.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatementSyntax.prototype.childCount = function () { - return 3; - }; - - LabeledStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.identifier; - case 1: - return this.colonToken; - case 2: - return this.statement; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - LabeledStatementSyntax.prototype.isStatement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - LabeledStatementSyntax.prototype.update = function (identifier, colonToken, statement) { - if (this.identifier === identifier && this.colonToken === colonToken && this.statement === statement) { - return this; - } - - return new LabeledStatementSyntax(identifier, colonToken, statement, this.parsedInStrictMode()); - }; - - LabeledStatementSyntax.create1 = function (identifier, statement) { - return new LabeledStatementSyntax(identifier, TypeScript.Syntax.token(106 /* ColonToken */), statement, false); - }; - - LabeledStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - LabeledStatementSyntax.prototype.withIdentifier = function (identifier) { - return this.update(identifier, this.colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withColonToken = function (colonToken) { - return this.update(this.identifier, colonToken, this.statement); - }; - - LabeledStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.identifier, this.colonToken, statement); - }; - - LabeledStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.LabeledStatementSyntax = LabeledStatementSyntax; - - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.doKeyword = doKeyword; - this.statement = statement; - this.whileKeyword = whileKeyword; - this.openParenToken = openParenToken; - this.condition = condition; - this.closeParenToken = closeParenToken; - this.semicolonToken = semicolonToken; - } - DoStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDoStatement(this); - }; - - DoStatementSyntax.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatementSyntax.prototype.childCount = function () { - return 7; - }; - - DoStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.doKeyword; - case 1: - return this.statement; - case 2: - return this.whileKeyword; - case 3: - return this.openParenToken; - case 4: - return this.condition; - case 5: - return this.closeParenToken; - case 6: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DoStatementSyntax.prototype.isIterationStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DoStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DoStatementSyntax.prototype.update = function (doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - if (this.doKeyword === doKeyword && this.statement === statement && this.whileKeyword === whileKeyword && this.openParenToken === openParenToken && this.condition === condition && this.closeParenToken === closeParenToken && this.semicolonToken === semicolonToken) { - return this; - } - - return new DoStatementSyntax(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken, this.parsedInStrictMode()); - }; - - DoStatementSyntax.create1 = function (statement, condition) { - return new DoStatementSyntax(TypeScript.Syntax.token(22 /* DoKeyword */), statement, TypeScript.Syntax.token(42 /* WhileKeyword */), TypeScript.Syntax.token(72 /* OpenParenToken */), condition, TypeScript.Syntax.token(73 /* CloseParenToken */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DoStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DoStatementSyntax.prototype.withDoKeyword = function (doKeyword) { - return this.update(doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withStatement = function (statement) { - return this.update(this.doKeyword, statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withWhileKeyword = function (whileKeyword) { - return this.update(this.doKeyword, this.statement, whileKeyword, this.openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withOpenParenToken = function (openParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, openParenToken, this.condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCondition = function (condition) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, condition, this.closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withCloseParenToken = function (closeParenToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, closeParenToken, this.semicolonToken); - }; - - DoStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.doKeyword, this.statement, this.whileKeyword, this.openParenToken, this.condition, this.closeParenToken, semicolonToken); - }; - - DoStatementSyntax.prototype.isTypeScriptSpecific = function () { - if (this.statement.isTypeScriptSpecific()) { - return true; - } - if (this.condition.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DoStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DoStatementSyntax = DoStatementSyntax; - - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(typeOfKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.typeOfKeyword = typeOfKeyword; - this.expression = expression; - } - TypeOfExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitTypeOfExpression(this); - }; - - TypeOfExpressionSyntax.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - TypeOfExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - TypeOfExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.typeOfKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - TypeOfExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - TypeOfExpressionSyntax.prototype.update = function (typeOfKeyword, expression) { - if (this.typeOfKeyword === typeOfKeyword && this.expression === expression) { - return this; - } - - return new TypeOfExpressionSyntax(typeOfKeyword, expression, this.parsedInStrictMode()); - }; - - TypeOfExpressionSyntax.create1 = function (expression) { - return new TypeOfExpressionSyntax(TypeScript.Syntax.token(39 /* TypeOfKeyword */), expression, false); - }; - - TypeOfExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - TypeOfExpressionSyntax.prototype.withTypeOfKeyword = function (typeOfKeyword) { - return this.update(typeOfKeyword, this.expression); - }; - - TypeOfExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.typeOfKeyword, expression); - }; - - TypeOfExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(deleteKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.deleteKeyword = deleteKeyword; - this.expression = expression; - } - DeleteExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitDeleteExpression(this); - }; - - DeleteExpressionSyntax.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - DeleteExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - DeleteExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.deleteKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DeleteExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - DeleteExpressionSyntax.prototype.update = function (deleteKeyword, expression) { - if (this.deleteKeyword === deleteKeyword && this.expression === expression) { - return this; - } - - return new DeleteExpressionSyntax(deleteKeyword, expression, this.parsedInStrictMode()); - }; - - DeleteExpressionSyntax.create1 = function (expression) { - return new DeleteExpressionSyntax(TypeScript.Syntax.token(21 /* DeleteKeyword */), expression, false); - }; - - DeleteExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DeleteExpressionSyntax.prototype.withDeleteKeyword = function (deleteKeyword) { - return this.update(deleteKeyword, this.expression); - }; - - DeleteExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.deleteKeyword, expression); - }; - - DeleteExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DeleteExpressionSyntax = DeleteExpressionSyntax; - - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(voidKeyword, expression, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.voidKeyword = voidKeyword; - this.expression = expression; - } - VoidExpressionSyntax.prototype.accept = function (visitor) { - return visitor.visitVoidExpression(this); - }; - - VoidExpressionSyntax.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - VoidExpressionSyntax.prototype.childCount = function () { - return 2; - }; - - VoidExpressionSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.voidKeyword; - case 1: - return this.expression; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - VoidExpressionSyntax.prototype.isUnaryExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.isExpression = function () { - return true; - }; - - VoidExpressionSyntax.prototype.update = function (voidKeyword, expression) { - if (this.voidKeyword === voidKeyword && this.expression === expression) { - return this; - } - - return new VoidExpressionSyntax(voidKeyword, expression, this.parsedInStrictMode()); - }; - - VoidExpressionSyntax.create1 = function (expression) { - return new VoidExpressionSyntax(TypeScript.Syntax.token(41 /* VoidKeyword */), expression, false); - }; - - VoidExpressionSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - VoidExpressionSyntax.prototype.withVoidKeyword = function (voidKeyword) { - return this.update(voidKeyword, this.expression); - }; - - VoidExpressionSyntax.prototype.withExpression = function (expression) { - return this.update(this.voidKeyword, expression); - }; - - VoidExpressionSyntax.prototype.isTypeScriptSpecific = function () { - if (this.expression.isTypeScriptSpecific()) { - return true; - } - return false; - }; - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - TypeScript.VoidExpressionSyntax = VoidExpressionSyntax; - - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(debuggerKeyword, semicolonToken, parsedInStrictMode) { - _super.call(this, parsedInStrictMode); - this.debuggerKeyword = debuggerKeyword; - this.semicolonToken = semicolonToken; - } - DebuggerStatementSyntax.prototype.accept = function (visitor) { - return visitor.visitDebuggerStatement(this); - }; - - DebuggerStatementSyntax.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - - DebuggerStatementSyntax.prototype.childCount = function () { - return 2; - }; - - DebuggerStatementSyntax.prototype.childAt = function (slot) { - switch (slot) { - case 0: - return this.debuggerKeyword; - case 1: - return this.semicolonToken; - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - DebuggerStatementSyntax.prototype.isStatement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.isModuleElement = function () { - return true; - }; - - DebuggerStatementSyntax.prototype.update = function (debuggerKeyword, semicolonToken) { - if (this.debuggerKeyword === debuggerKeyword && this.semicolonToken === semicolonToken) { - return this; - } - - return new DebuggerStatementSyntax(debuggerKeyword, semicolonToken, this.parsedInStrictMode()); - }; - - DebuggerStatementSyntax.create1 = function () { - return new DebuggerStatementSyntax(TypeScript.Syntax.token(19 /* DebuggerKeyword */), TypeScript.Syntax.token(78 /* SemicolonToken */), false); - }; - - DebuggerStatementSyntax.prototype.withLeadingTrivia = function (trivia) { - return _super.prototype.withLeadingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withTrailingTrivia = function (trivia) { - return _super.prototype.withTrailingTrivia.call(this, trivia); - }; - - DebuggerStatementSyntax.prototype.withDebuggerKeyword = function (debuggerKeyword) { - return this.update(debuggerKeyword, this.semicolonToken); - }; - - DebuggerStatementSyntax.prototype.withSemicolonToken = function (semicolonToken) { - return this.update(this.debuggerKeyword, semicolonToken); - }; - - DebuggerStatementSyntax.prototype.isTypeScriptSpecific = function () { - return false; - }; - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - TypeScript.DebuggerStatementSyntax = DebuggerStatementSyntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxRewriter = (function () { - function SyntaxRewriter() { - } - SyntaxRewriter.prototype.visitToken = function (token) { - return token; - }; - - SyntaxRewriter.prototype.visitNode = function (node) { - return node.accept(this); - }; - - SyntaxRewriter.prototype.visitNodeOrToken = function (node) { - return node.isToken() ? this.visitToken(node) : this.visitNode(node); - }; - - SyntaxRewriter.prototype.visitList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = this.visitNodeOrToken(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.list(newItems); - }; - - SyntaxRewriter.prototype.visitSeparatedList = function (list) { - var newItems = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - var newItem = item.isToken() ? this.visitToken(item) : this.visitNode(item); - - if (item !== newItem && newItems === null) { - newItems = []; - for (var j = 0; j < i; j++) { - newItems.push(list.childAt(j)); - } - } - - if (newItems) { - newItems.push(newItem); - } - } - - return newItems === null ? list : TypeScript.Syntax.separatedList(newItems); - }; - - SyntaxRewriter.prototype.visitSourceUnit = function (node) { - return node.update(this.visitList(node.moduleElements), this.visitToken(node.endOfFileToken)); - }; - - SyntaxRewriter.prototype.visitExternalModuleReference = function (node) { - return node.update(this.visitToken(node.requireKeyword), this.visitToken(node.openParenToken), this.visitToken(node.stringLiteral), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitModuleNameModuleReference = function (node) { - return node.update(this.visitNodeOrToken(node.moduleName)); - }; - - SyntaxRewriter.prototype.visitImportDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.importKeyword), this.visitToken(node.identifier), this.visitToken(node.equalsToken), this.visitNodeOrToken(node.moduleReference), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitExportAssignment = function (node) { - return node.update(this.visitToken(node.exportKeyword), this.visitToken(node.equalsToken), this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitClassDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.classKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitToken(node.openBraceToken), this.visitList(node.classElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitInterfaceDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.interfaceKeyword), this.visitToken(node.identifier), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitList(node.heritageClauses), this.visitNode(node.body)); - }; - - SyntaxRewriter.prototype.visitHeritageClause = function (node) { - return node.update(node.kind(), this.visitToken(node.extendsOrImplementsKeyword), this.visitSeparatedList(node.typeNames)); - }; - - SyntaxRewriter.prototype.visitModuleDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.moduleKeyword), node.name === null ? null : this.visitNodeOrToken(node.name), node.stringLiteral === null ? null : this.visitToken(node.stringLiteral), this.visitToken(node.openBraceToken), this.visitList(node.moduleElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitFunctionDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.functionKeyword), this.visitToken(node.identifier), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableStatement = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclaration), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitVariableDeclaration = function (node) { - return node.update(this.visitToken(node.varKeyword), this.visitSeparatedList(node.variableDeclarators)); - }; - - SyntaxRewriter.prototype.visitVariableDeclarator = function (node) { - return node.update(this.visitToken(node.propertyName), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitEqualsValueClause = function (node) { - return node.update(this.visitToken(node.equalsToken), this.visitNodeOrToken(node.value)); - }; - - SyntaxRewriter.prototype.visitPrefixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.operand)); - }; - - SyntaxRewriter.prototype.visitArrayLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitSeparatedList(node.expressions), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitOmittedExpression = function (node) { - return node; - }; - - SyntaxRewriter.prototype.visitParenthesizedExpression = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitSimpleArrowFunctionExpression = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return node.update(this.visitNode(node.callSignature), this.visitToken(node.equalsGreaterThanToken), node.block === null ? null : this.visitNode(node.block), node.expression === null ? null : this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitQualifiedName = function (node) { - return node.update(this.visitNodeOrToken(node.left), this.visitToken(node.dotToken), this.visitToken(node.right)); - }; - - SyntaxRewriter.prototype.visitTypeArgumentList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeArguments), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitConstructorType = function (node) { - return node.update(this.visitToken(node.newKeyword), node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitFunctionType = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), this.visitToken(node.equalsGreaterThanToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitObjectType = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.typeMembers), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitArrayType = function (node) { - return node.update(this.visitNodeOrToken(node.type), this.visitToken(node.openBracketToken), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitGenericType = function (node) { - return node.update(this.visitNodeOrToken(node.name), this.visitNode(node.typeArgumentList)); - }; - - SyntaxRewriter.prototype.visitTypeQuery = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.name)); - }; - - SyntaxRewriter.prototype.visitTypeAnnotation = function (node) { - return node.update(this.visitToken(node.colonToken), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitBlock = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitList(node.statements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitParameter = function (node) { - return node.update(node.dotDotDotToken === null ? null : this.visitToken(node.dotDotDotToken), this.visitList(node.modifiers), this.visitToken(node.identifier), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitMemberAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.dotToken), this.visitToken(node.name)); - }; - - SyntaxRewriter.prototype.visitPostfixUnaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.operand), this.visitToken(node.operatorToken)); - }; - - SyntaxRewriter.prototype.visitElementAccessExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.openBracketToken), this.visitNodeOrToken(node.argumentExpression), this.visitToken(node.closeBracketToken)); - }; - - SyntaxRewriter.prototype.visitInvocationExpression = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitArgumentList = function (node) { - return node.update(node.typeArgumentList === null ? null : this.visitNode(node.typeArgumentList), this.visitToken(node.openParenToken), this.visitSeparatedList(node.arguments), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitBinaryExpression = function (node) { - return node.update(node.kind(), this.visitNodeOrToken(node.left), this.visitToken(node.operatorToken), this.visitNodeOrToken(node.right)); - }; - - SyntaxRewriter.prototype.visitConditionalExpression = function (node) { - return node.update(this.visitNodeOrToken(node.condition), this.visitToken(node.questionToken), this.visitNodeOrToken(node.whenTrue), this.visitToken(node.colonToken), this.visitNodeOrToken(node.whenFalse)); - }; - - SyntaxRewriter.prototype.visitConstructSignature = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitMethodSignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), this.visitNode(node.callSignature)); - }; - - SyntaxRewriter.prototype.visitIndexSignature = function (node) { - return node.update(this.visitToken(node.openBracketToken), this.visitNode(node.parameter), this.visitToken(node.closeBracketToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitPropertySignature = function (node) { - return node.update(this.visitToken(node.propertyName), node.questionToken === null ? null : this.visitToken(node.questionToken), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitCallSignature = function (node) { - return node.update(node.typeParameterList === null ? null : this.visitNode(node.typeParameterList), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation)); - }; - - SyntaxRewriter.prototype.visitParameterList = function (node) { - return node.update(this.visitToken(node.openParenToken), this.visitSeparatedList(node.parameters), this.visitToken(node.closeParenToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameterList = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitSeparatedList(node.typeParameters), this.visitToken(node.greaterThanToken)); - }; - - SyntaxRewriter.prototype.visitTypeParameter = function (node) { - return node.update(this.visitToken(node.identifier), node.constraint === null ? null : this.visitNode(node.constraint)); - }; - - SyntaxRewriter.prototype.visitConstraint = function (node) { - return node.update(this.visitToken(node.extendsKeyword), this.visitNodeOrToken(node.type)); - }; - - SyntaxRewriter.prototype.visitElseClause = function (node) { - return node.update(this.visitToken(node.elseKeyword), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitIfStatement = function (node) { - return node.update(this.visitToken(node.ifKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement), node.elseClause === null ? null : this.visitNode(node.elseClause)); - }; - - SyntaxRewriter.prototype.visitExpressionStatement = function (node) { - return node.update(this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitConstructorDeclaration = function (node) { - 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) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.propertyName), this.visitNode(node.callSignature), node.block === null ? null : this.visitNode(node.block), node.semicolonToken === null ? null : this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitGetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.getKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitSetAccessor = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.setKeyword), this.visitToken(node.propertyName), this.visitNode(node.parameterList), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitMemberVariableDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.variableDeclarator), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitIndexMemberDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitNode(node.indexSignature), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitThrowStatement = function (node) { - return node.update(this.visitToken(node.throwKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitReturnStatement = function (node) { - return node.update(this.visitToken(node.returnKeyword), node.expression === null ? null : this.visitNodeOrToken(node.expression), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitObjectCreationExpression = function (node) { - return node.update(this.visitToken(node.newKeyword), this.visitNodeOrToken(node.expression), node.argumentList === null ? null : this.visitNode(node.argumentList)); - }; - - SyntaxRewriter.prototype.visitSwitchStatement = function (node) { - return node.update(this.visitToken(node.switchKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitToken(node.openBraceToken), this.visitList(node.switchClauses), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitCaseSwitchClause = function (node) { - return node.update(this.visitToken(node.caseKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitDefaultSwitchClause = function (node) { - return node.update(this.visitToken(node.defaultKeyword), this.visitToken(node.colonToken), this.visitList(node.statements)); - }; - - SyntaxRewriter.prototype.visitBreakStatement = function (node) { - return node.update(this.visitToken(node.breakKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitContinueStatement = function (node) { - return node.update(this.visitToken(node.continueKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitForStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.initializer === null ? null : this.visitNodeOrToken(node.initializer), this.visitToken(node.firstSemicolonToken), node.condition === null ? null : this.visitNodeOrToken(node.condition), this.visitToken(node.secondSemicolonToken), node.incrementor === null ? null : this.visitNodeOrToken(node.incrementor), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitForInStatement = function (node) { - return node.update(this.visitToken(node.forKeyword), this.visitToken(node.openParenToken), node.variableDeclaration === null ? null : this.visitNode(node.variableDeclaration), node.left === null ? null : this.visitNodeOrToken(node.left), this.visitToken(node.inKeyword), this.visitNodeOrToken(node.expression), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWhileStatement = function (node) { - return node.update(this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitWithStatement = function (node) { - return node.update(this.visitToken(node.withKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitEnumDeclaration = function (node) { - return node.update(this.visitList(node.modifiers), this.visitToken(node.enumKeyword), this.visitToken(node.identifier), this.visitToken(node.openBraceToken), this.visitSeparatedList(node.enumElements), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitEnumElement = function (node) { - return node.update(this.visitToken(node.propertyName), node.equalsValueClause === null ? null : this.visitNode(node.equalsValueClause)); - }; - - SyntaxRewriter.prototype.visitCastExpression = function (node) { - return node.update(this.visitToken(node.lessThanToken), this.visitNodeOrToken(node.type), this.visitToken(node.greaterThanToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitObjectLiteralExpression = function (node) { - return node.update(this.visitToken(node.openBraceToken), this.visitSeparatedList(node.propertyAssignments), this.visitToken(node.closeBraceToken)); - }; - - SyntaxRewriter.prototype.visitSimplePropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitToken(node.colonToken), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitFunctionPropertyAssignment = function (node) { - return node.update(this.visitToken(node.propertyName), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFunctionExpression = function (node) { - return node.update(this.visitToken(node.functionKeyword), node.identifier === null ? null : this.visitToken(node.identifier), this.visitNode(node.callSignature), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitEmptyStatement = function (node) { - return node.update(this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTryStatement = function (node) { - return node.update(this.visitToken(node.tryKeyword), this.visitNode(node.block), node.catchClause === null ? null : this.visitNode(node.catchClause), node.finallyClause === null ? null : this.visitNode(node.finallyClause)); - }; - - SyntaxRewriter.prototype.visitCatchClause = function (node) { - return node.update(this.visitToken(node.catchKeyword), this.visitToken(node.openParenToken), this.visitToken(node.identifier), node.typeAnnotation === null ? null : this.visitNode(node.typeAnnotation), this.visitToken(node.closeParenToken), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitFinallyClause = function (node) { - return node.update(this.visitToken(node.finallyKeyword), this.visitNode(node.block)); - }; - - SyntaxRewriter.prototype.visitLabeledStatement = function (node) { - return node.update(this.visitToken(node.identifier), this.visitToken(node.colonToken), this.visitNodeOrToken(node.statement)); - }; - - SyntaxRewriter.prototype.visitDoStatement = function (node) { - return node.update(this.visitToken(node.doKeyword), this.visitNodeOrToken(node.statement), this.visitToken(node.whileKeyword), this.visitToken(node.openParenToken), this.visitNodeOrToken(node.condition), this.visitToken(node.closeParenToken), this.visitToken(node.semicolonToken)); - }; - - SyntaxRewriter.prototype.visitTypeOfExpression = function (node) { - return node.update(this.visitToken(node.typeOfKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDeleteExpression = function (node) { - return node.update(this.visitToken(node.deleteKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitVoidExpression = function (node) { - return node.update(this.visitToken(node.voidKeyword), this.visitNodeOrToken(node.expression)); - }; - - SyntaxRewriter.prototype.visitDebuggerStatement = function (node) { - return node.update(this.visitToken(node.debuggerKeyword), this.visitToken(node.semicolonToken)); - }; - return SyntaxRewriter; - })(); - TypeScript.SyntaxRewriter = SyntaxRewriter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxDedenter = (function (_super) { - __extends(SyntaxDedenter, _super); - function SyntaxDedenter(dedentFirstToken, dedentationAmount, minimumIndent, options) { - _super.call(this); - this.dedentationAmount = dedentationAmount; - this.minimumIndent = minimumIndent; - this.options = options; - this.lastTriviaWasNewLine = dedentFirstToken; - } - SyntaxDedenter.prototype.abort = function () { - this.lastTriviaWasNewLine = false; - this.dedentationAmount = 0; - }; - - SyntaxDedenter.prototype.isAborted = function () { - return this.dedentationAmount === 0; - }; - - SyntaxDedenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.dedentTriviaList(token.leadingTrivia())); - } - - if (this.isAborted()) { - return token; - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxDedenter.prototype.dedentTriviaList = function (triviaList) { - var result = []; - var dedentNextWhitespace = true; - - for (var i = 0, n = triviaList.count(); i < n && !this.isAborted(); i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var dedentThisTrivia = dedentNextWhitespace; - dedentNextWhitespace = false; - - if (dedentThisTrivia) { - if (trivia.kind() === 4 /* WhitespaceTrivia */) { - var hasFollowingNewLine = (i < triviaList.count() - 1) && triviaList.syntaxTriviaAt(i + 1).kind() === 5 /* NewLineTrivia */; - result.push(this.dedentWhitespace(trivia, hasFollowingNewLine)); - continue; - } else if (trivia.kind() !== 5 /* NewLineTrivia */) { - this.abort(); - break; - } - } - - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { - result.push(this.dedentMultiLineComment(trivia)); - continue; - } - - result.push(trivia); - if (trivia.kind() === 5 /* NewLineTrivia */) { - dedentNextWhitespace = true; - } - } - - if (dedentNextWhitespace) { - this.abort(); - } - - if (this.isAborted()) { - return triviaList; - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxDedenter.prototype.dedentSegment = function (segment, hasFollowingNewLineTrivia) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition === segment.length) { - if (hasFollowingNewLineTrivia) { - return ""; - } - } else if (TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment.substring(firstNonWhitespacePosition); - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = TypeScript.MathPrototype.min(firstNonWhitespaceColumn, TypeScript.MathPrototype.max(firstNonWhitespaceColumn - this.dedentationAmount, this.minimumIndent)); - - if (newFirstNonWhitespaceColumn === firstNonWhitespaceColumn) { - this.abort(); - return segment; - } - - this.dedentationAmount = firstNonWhitespaceColumn - newFirstNonWhitespaceColumn; - TypeScript.Debug.assert(this.dedentationAmount >= 0); - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxDedenter.prototype.dedentWhitespace = function (trivia, hasFollowingNewLineTrivia) { - var newIndentation = this.dedentSegment(trivia.fullText(), hasFollowingNewLineTrivia); - return TypeScript.Syntax.whitespace(newIndentation); - }; - - SyntaxDedenter.prototype.dedentMultiLineComment = function (trivia) { - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - if (segments.length === 1) { - return trivia; - } - - for (var i = 1; i < segments.length; i++) { - var segment = segments[i]; - segments[i] = this.dedentSegment(segment, false); - } - - var result = segments.join(""); - - return TypeScript.Syntax.multiLineComment(result); - }; - - SyntaxDedenter.dedentNode = function (node, dedentFirstToken, dedentAmount, minimumIndent, options) { - var dedenter = new SyntaxDedenter(dedentFirstToken, dedentAmount, minimumIndent, options); - var result = node.accept(dedenter); - - if (dedenter.isAborted()) { - return node; - } - - return result; - }; - return SyntaxDedenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxDedenter = SyntaxDedenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxIndenter = (function (_super) { - __extends(SyntaxIndenter, _super); - function SyntaxIndenter(indentFirstToken, indentationAmount, options) { - _super.call(this); - this.indentationAmount = indentationAmount; - this.options = options; - this.lastTriviaWasNewLine = indentFirstToken; - this.indentationTrivia = TypeScript.Indentation.indentationTrivia(this.indentationAmount, this.options); - } - SyntaxIndenter.prototype.visitToken = function (token) { - if (token.width() === 0) { - return token; - } - - var result = token; - if (this.lastTriviaWasNewLine) { - result = token.withLeadingTrivia(this.indentTriviaList(token.leadingTrivia())); - } - - this.lastTriviaWasNewLine = token.hasTrailingNewLine(); - return result; - }; - - SyntaxIndenter.prototype.indentTriviaList = function (triviaList) { - var result = []; - - var indentNextTrivia = true; - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - var indentThisTrivia = indentNextTrivia; - indentNextTrivia = false; - - switch (trivia.kind()) { - case 6 /* MultiLineCommentTrivia */: - this.indentMultiLineComment(trivia, indentThisTrivia, result); - continue; - - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: - this.indentSingleLineOrSkippedText(trivia, indentThisTrivia, result); - continue; - - case 4 /* WhitespaceTrivia */: - this.indentWhitespace(trivia, indentThisTrivia, result); - continue; - - case 5 /* NewLineTrivia */: - result.push(trivia); - indentNextTrivia = true; - continue; - - default: - throw TypeScript.Errors.invalidOperation(); - } - } - - if (indentNextTrivia) { - result.push(this.indentationTrivia); - } - - return TypeScript.Syntax.triviaList(result); - }; - - SyntaxIndenter.prototype.indentSegment = function (segment) { - var firstNonWhitespacePosition = TypeScript.Indentation.firstNonWhitespacePosition(segment); - - if (firstNonWhitespacePosition < segment.length && TypeScript.CharacterInfo.isLineTerminator(segment.charCodeAt(firstNonWhitespacePosition))) { - return segment; - } - - var firstNonWhitespaceColumn = TypeScript.Indentation.columnForPositionInString(segment, firstNonWhitespacePosition, this.options); - - var newFirstNonWhitespaceColumn = firstNonWhitespaceColumn + this.indentationAmount; - - var indentationString = TypeScript.Indentation.indentationString(newFirstNonWhitespaceColumn, this.options); - - return indentationString + segment.substring(firstNonWhitespacePosition); - }; - - SyntaxIndenter.prototype.indentWhitespace = function (trivia, indentThisTrivia, result) { - if (!indentThisTrivia) { - result.push(trivia); - return; - } - - var newIndentation = this.indentSegment(trivia.fullText()); - result.push(TypeScript.Syntax.whitespace(newIndentation)); - }; - - SyntaxIndenter.prototype.indentSingleLineOrSkippedText = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - result.push(trivia); - }; - - SyntaxIndenter.prototype.indentMultiLineComment = function (trivia, indentThisTrivia, result) { - if (indentThisTrivia) { - result.push(this.indentationTrivia); - } - - var segments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); - - for (var i = 1; i < segments.length; i++) { - segments[i] = this.indentSegment(segments[i]); - } - - var newText = segments.join(""); - result.push(TypeScript.Syntax.multiLineComment(newText)); - }; - - SyntaxIndenter.indentNode = function (node, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - return node.accept(indenter); - }; - - SyntaxIndenter.indentNodes = function (nodes, indentFirstToken, indentAmount, options) { - var indenter = new SyntaxIndenter(indentFirstToken, indentAmount, options); - var result = TypeScript.ArrayUtilities.select(nodes, function (n) { - return n.accept(indenter); - }); - - return result; - }; - return SyntaxIndenter; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxIndenter = SyntaxIndenter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var VariableWidthTokenWithNoTrivia = (function () { - function VariableWidthTokenWithNoTrivia(fullText, kind) { - this._fullText = fullText; - this.tokenKind = kind; - } - VariableWidthTokenWithNoTrivia.prototype.clone = function () { - return new VariableWidthTokenWithNoTrivia(this._fullText, this.tokenKind); - }; - - VariableWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithNoTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithNoTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithNoTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithNoTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithNoTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithNoTrivia; - })(); - Syntax.VariableWidthTokenWithNoTrivia = VariableWidthTokenWithNoTrivia; - - var VariableWidthTokenWithLeadingTrivia = (function () { - function VariableWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - VariableWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingTrivia = VariableWidthTokenWithLeadingTrivia; - - var VariableWidthTokenWithTrailingTrivia = (function () { - function VariableWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - VariableWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithTrailingTrivia = VariableWidthTokenWithTrailingTrivia; - - var VariableWidthTokenWithLeadingAndTrailingTrivia = (function () { - function VariableWidthTokenWithLeadingAndTrailingTrivia(fullText, kind, leadingTriviaInfo, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - this._trailingTriviaInfo = trailingTriviaInfo; - } - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.clone = function () { - return new VariableWidthTokenWithLeadingAndTrailingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.fullWidth() - this.leadingTriviaWidth() - this.trailingTriviaWidth(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return this.fullText().substr(this.leadingTriviaWidth(), this.width()); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - if (this._value === undefined) { - this._value = TypeScript.Syntax.value(this); - } - - return this._value; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - if (this._valueText === undefined) { - this._valueText = TypeScript.Syntax.valueText(this); - } - - return this._valueText; - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - VariableWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return VariableWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.VariableWidthTokenWithLeadingAndTrailingTrivia = VariableWidthTokenWithLeadingAndTrailingTrivia; - - var FixedWidthTokenWithNoTrivia = (function () { - function FixedWidthTokenWithNoTrivia(kind) { - this.tokenKind = kind; - } - FixedWidthTokenWithNoTrivia.prototype.clone = function () { - return new FixedWidthTokenWithNoTrivia(this.tokenKind); - }; - - FixedWidthTokenWithNoTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithNoTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithNoTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithNoTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithNoTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithNoTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.fullText = function () { - return this.text(); - }; - - FixedWidthTokenWithNoTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithNoTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithNoTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithNoTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithNoTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithNoTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithNoTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithNoTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithNoTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithNoTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithNoTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithNoTrivia; - })(); - Syntax.FixedWidthTokenWithNoTrivia = FixedWidthTokenWithNoTrivia; - - var FixedWidthTokenWithLeadingTrivia = (function () { - function FixedWidthTokenWithLeadingTrivia(fullText, kind, leadingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._leadingTriviaInfo = leadingTriviaInfo; - } - FixedWidthTokenWithLeadingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithLeadingTrivia(this._fullText, this.tokenKind, this._leadingTriviaInfo); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingTrivia = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingComment = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingNewLine = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithLeadingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithLeadingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingTrivia = FixedWidthTokenWithLeadingTrivia; - - var FixedWidthTokenWithTrailingTrivia = (function () { - function FixedWidthTokenWithTrailingTrivia(fullText, kind, trailingTriviaInfo) { - this._fullText = fullText; - this.tokenKind = kind; - this._trailingTriviaInfo = trailingTriviaInfo; - } - FixedWidthTokenWithTrailingTrivia.prototype.clone = function () { - return new FixedWidthTokenWithTrailingTrivia(this._fullText, this.tokenKind, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingTrivia = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingComment = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingNewLine = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTriviaWidth = function () { - return 0; - }; - FixedWidthTokenWithTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithTrailingTrivia = FixedWidthTokenWithTrailingTrivia; - - var FixedWidthTokenWithLeadingAndTrailingTrivia = (function () { - 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._fullText, this.tokenKind, this._leadingTriviaInfo, this._trailingTriviaInfo); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isNode = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isToken = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isList = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isSeparatedList = function () { - return false; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.kind = function () { - return this.tokenKind; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childCount = function () { - return 0; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange('index'); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.width = function () { - return this.text().length; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.text = function () { - return TypeScript.SyntaxFacts.getText(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.fullText = function () { - return this._fullText; - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.value = function () { - return TypeScript.Syntax.value(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.valueText = function () { - return TypeScript.Syntax.valueText(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingComment = function () { - return hasTriviaComment(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingNewLine = function () { - return hasTriviaNewLine(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasLeadingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTriviaWidth = function () { - return getTriviaWidth(this._leadingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.leadingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), 0, getTriviaWidth(this._leadingTriviaInfo), false); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingTrivia = function () { - return true; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingComment = function () { - return hasTriviaComment(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingNewLine = function () { - return hasTriviaNewLine(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasTrailingSkippedText = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTriviaWidth = function () { - return getTriviaWidth(this._trailingTriviaInfo); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.trailingTrivia = function () { - return TypeScript.Scanner.scanTrivia(TypeScript.SimpleText.fromString(this._fullText), this.leadingTriviaWidth() + this.width(), getTriviaWidth(this._trailingTriviaInfo), true); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.hasSkippedToken = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.toJSON = function (key) { - return TypeScript.Syntax.tokenToJSON(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.firstToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.lastToken = function () { - return this; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isTypeScriptSpecific = function () { - return false; - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isIncrementallyUnusable = function () { - return this.fullWidth() === 0 || TypeScript.SyntaxFacts.isAnyDivideOrRegularExpressionToken(this.tokenKind); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.realize = function () { - return TypeScript.Syntax.realizeToken(this); - }; - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.collectTextElements = function (elements) { - collectTokenTextElements(this, elements); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isExpression = function () { - return TypeScript.Syntax.isExpression(this); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - FixedWidthTokenWithLeadingAndTrailingTrivia.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return FixedWidthTokenWithLeadingAndTrailingTrivia; - })(); - Syntax.FixedWidthTokenWithLeadingAndTrailingTrivia = FixedWidthTokenWithLeadingAndTrailingTrivia; - - function collectTokenTextElements(token, elements) { - token.leadingTrivia().collectTextElements(elements); - elements.push(token.text()); - token.trailingTrivia().collectTextElements(elements); - } - - function getTriviaWidth(value) { - return value >>> 2 /* TriviaFullWidthShift */; - } - - function hasTriviaComment(value) { - return (value & 2 /* TriviaCommentMask */) !== 0; - } - - function hasTriviaNewLine(value) { - return (value & 1 /* TriviaNewLineMask */) !== 0; - } - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - function isExpression(token) { - switch (token.tokenKind) { - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - return true; - } - - return false; - } - Syntax.isExpression = isExpression; - - function realizeToken(token) { - return new RealizedToken(token.tokenKind, token.leadingTrivia(), token.text(), token.value(), token.valueText(), token.trailingTrivia()); - } - Syntax.realizeToken = realizeToken; - - function convertToIdentifierName(token) { - TypeScript.Debug.assert(TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)); - return new RealizedToken(11 /* IdentifierName */, token.leadingTrivia(), token.text(), token.text(), token.text(), token.trailingTrivia()); - } - Syntax.convertToIdentifierName = convertToIdentifierName; - - function tokenToJSON(token) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === token.kind()) { - result.kind = name; - break; - } - } - - result.width = token.width(); - if (token.fullWidth() !== token.width()) { - result.fullWidth = token.fullWidth(); - } - - result.text = token.text(); - - var value = token.value(); - if (value !== null) { - result.value = value; - result.valueText = token.valueText(); - } - - if (token.hasLeadingTrivia()) { - result.hasLeadingTrivia = true; - } - - if (token.hasLeadingComment()) { - result.hasLeadingComment = true; - } - - if (token.hasLeadingNewLine()) { - result.hasLeadingNewLine = true; - } - - if (token.hasLeadingSkippedText()) { - result.hasLeadingSkippedText = true; - } - - if (token.hasTrailingTrivia()) { - result.hasTrailingTrivia = true; - } - - if (token.hasTrailingComment()) { - result.hasTrailingComment = true; - } - - if (token.hasTrailingNewLine()) { - result.hasTrailingNewLine = true; - } - - if (token.hasTrailingSkippedText()) { - result.hasTrailingSkippedText = true; - } - - var trivia = token.leadingTrivia(); - if (trivia.count() > 0) { - result.leadingTrivia = trivia; - } - - trivia = token.trailingTrivia(); - if (trivia.count() > 0) { - result.trailingTrivia = trivia; - } - - return result; - } - Syntax.tokenToJSON = tokenToJSON; - - function value(token) { - return value1(token.tokenKind, token.text()); - } - Syntax.value = value; - - function hexValue(text, start, length) { - var intChar = 0; - for (var i = 0; i < length; i++) { - var ch2 = text.charCodeAt(start + i); - if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { - break; - } - - intChar = (intChar << 4) + TypeScript.CharacterInfo.hexValue(ch2); - } - - return intChar; - } - - var characterArray = []; - - function convertEscapes(text) { - characterArray.length = 0; - var result = ""; - - for (var i = 0, n = text.length; i < n; i++) { - var ch = text.charCodeAt(i); - - if (ch === 92 /* backslash */) { - i++; - if (i < n) { - ch = text.charCodeAt(i); - switch (ch) { - case 48 /* _0 */: - characterArray.push(0 /* nullCharacter */); - continue; - - case 98 /* b */: - characterArray.push(8 /* backspace */); - continue; - - case 102 /* f */: - characterArray.push(12 /* formFeed */); - continue; - - case 110 /* n */: - characterArray.push(10 /* lineFeed */); - continue; - - case 114 /* r */: - characterArray.push(13 /* carriageReturn */); - continue; - - case 116 /* t */: - characterArray.push(9 /* tab */); - continue; - - case 118 /* v */: - characterArray.push(11 /* verticalTab */); - continue; - - case 120 /* x */: - characterArray.push(hexValue(text, i + 1, 2)); - i += 2; - continue; - - case 117 /* u */: - characterArray.push(hexValue(text, i + 1, 4)); - i += 4; - continue; - - case 13 /* carriageReturn */: - var nextIndex = i + 1; - if (nextIndex < text.length && text.charCodeAt(nextIndex) === 10 /* lineFeed */) { - i++; - } - continue; - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - continue; - - default: - } - } - } - - characterArray.push(ch); - - if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - characterArray.length = 0; - } - } - - if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); - } - - return result; - } - - function massageEscapes(text) { - return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; - } - Syntax.massageEscapes = massageEscapes; - - function value1(kind, text) { - if (kind === 11 /* IdentifierName */) { - return massageEscapes(text); - } - - switch (kind) { - case 37 /* TrueKeyword */: - return true; - case 24 /* FalseKeyword */: - return false; - case 32 /* NullKeyword */: - return null; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { - return TypeScript.SyntaxFacts.getText(kind); - } - - if (kind === 13 /* NumericLiteral */) { - return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); - } else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } else { - return massageEscapes(text.substr(1)); - } - } else if (kind === 12 /* RegularExpressionLiteral */) { - return regularExpressionValue(text); - } else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - - function regularExpressionValue(text) { - try { - var lastSlash = text.lastIndexOf("/"); - var body = text.substring(1, lastSlash); - var flags = text.substring(lastSlash + 1); - return new RegExp(body, flags); - } catch (e) { - return null; - } - } - - function valueText1(kind, text) { - var value = value1(kind, text); - return value === null ? "" : value.toString(); - } - - function valueText(token) { - var value = token.value(); - return value === null ? "" : value.toString(); - } - Syntax.valueText = valueText; - - var EmptyToken = (function () { - function EmptyToken(kind) { - this.tokenKind = kind; - } - EmptyToken.prototype.clone = function () { - return new EmptyToken(this.tokenKind); - }; - - EmptyToken.prototype.kind = function () { - return this.tokenKind; - }; - - EmptyToken.prototype.isToken = function () { - return true; - }; - EmptyToken.prototype.isNode = function () { - return false; - }; - EmptyToken.prototype.isList = function () { - return false; - }; - EmptyToken.prototype.isSeparatedList = function () { - return false; - }; - - EmptyToken.prototype.childCount = function () { - return 0; - }; - - EmptyToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - EmptyToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - EmptyToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - EmptyToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - EmptyToken.prototype.firstToken = function () { - return this; - }; - EmptyToken.prototype.lastToken = function () { - return this; - }; - EmptyToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - EmptyToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - EmptyToken.prototype.fullWidth = function () { - return 0; - }; - EmptyToken.prototype.width = function () { - return 0; - }; - EmptyToken.prototype.text = function () { - return ""; - }; - EmptyToken.prototype.fullText = function () { - return ""; - }; - EmptyToken.prototype.value = function () { - return null; - }; - EmptyToken.prototype.valueText = function () { - return ""; - }; - - EmptyToken.prototype.hasLeadingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasLeadingComment = function () { - return false; - }; - EmptyToken.prototype.hasLeadingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasLeadingSkippedText = function () { - return false; - }; - EmptyToken.prototype.leadingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.hasTrailingTrivia = function () { - return false; - }; - EmptyToken.prototype.hasTrailingComment = function () { - return false; - }; - EmptyToken.prototype.hasTrailingNewLine = function () { - return false; - }; - EmptyToken.prototype.hasTrailingSkippedText = function () { - return false; - }; - EmptyToken.prototype.hasSkippedToken = function () { - return false; - }; - - EmptyToken.prototype.trailingTriviaWidth = function () { - return 0; - }; - EmptyToken.prototype.leadingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.trailingTrivia = function () { - return TypeScript.Syntax.emptyTriviaList; - }; - EmptyToken.prototype.realize = function () { - return realizeToken(this); - }; - EmptyToken.prototype.collectTextElements = function (elements) { - }; - - EmptyToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return this.realize().withLeadingTrivia(leadingTrivia); - }; - - EmptyToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return this.realize().withTrailingTrivia(trailingTrivia); - }; - - EmptyToken.prototype.isExpression = function () { - return isExpression(this); - }; - - EmptyToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - EmptyToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return EmptyToken; - })(); - - function emptyToken(kind) { - return new EmptyToken(kind); - } - Syntax.emptyToken = emptyToken; - - var RealizedToken = (function () { - function RealizedToken(tokenKind, leadingTrivia, text, value, valueText, trailingTrivia) { - this.tokenKind = tokenKind; - this._leadingTrivia = leadingTrivia; - this._text = text; - this._value = value; - this._valueText = valueText; - this._trailingTrivia = trailingTrivia; - } - RealizedToken.prototype.clone = function () { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.kind = function () { - return this.tokenKind; - }; - RealizedToken.prototype.toJSON = function (key) { - return tokenToJSON(this); - }; - RealizedToken.prototype.firstToken = function () { - return this; - }; - RealizedToken.prototype.lastToken = function () { - return this; - }; - RealizedToken.prototype.isTypeScriptSpecific = function () { - return false; - }; - - RealizedToken.prototype.isIncrementallyUnusable = function () { - return true; - }; - - RealizedToken.prototype.accept = function (visitor) { - return visitor.visitToken(this); - }; - - RealizedToken.prototype.childCount = function () { - return 0; - }; - - RealizedToken.prototype.childAt = function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }; - - RealizedToken.prototype.isToken = function () { - return true; - }; - RealizedToken.prototype.isNode = function () { - return false; - }; - RealizedToken.prototype.isList = function () { - return false; - }; - RealizedToken.prototype.isSeparatedList = function () { - return false; - }; - RealizedToken.prototype.isTrivia = function () { - return false; - }; - RealizedToken.prototype.isTriviaList = function () { - return false; - }; - - RealizedToken.prototype.fullWidth = function () { - return this._leadingTrivia.fullWidth() + this.width() + this._trailingTrivia.fullWidth(); - }; - RealizedToken.prototype.width = function () { - return this.text().length; - }; - - RealizedToken.prototype.text = function () { - return this._text; - }; - RealizedToken.prototype.fullText = function () { - return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); - }; - - RealizedToken.prototype.value = function () { - return this._value; - }; - RealizedToken.prototype.valueText = function () { - return this._valueText; - }; - - RealizedToken.prototype.hasLeadingTrivia = function () { - return this._leadingTrivia.count() > 0; - }; - RealizedToken.prototype.hasLeadingComment = function () { - return this._leadingTrivia.hasComment(); - }; - RealizedToken.prototype.hasLeadingNewLine = function () { - return this._leadingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasLeadingSkippedText = function () { - return this._leadingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.leadingTriviaWidth = function () { - return this._leadingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasTrailingTrivia = function () { - return this._trailingTrivia.count() > 0; - }; - RealizedToken.prototype.hasTrailingComment = function () { - return this._trailingTrivia.hasComment(); - }; - RealizedToken.prototype.hasTrailingNewLine = function () { - return this._trailingTrivia.hasNewLine(); - }; - RealizedToken.prototype.hasTrailingSkippedText = function () { - return this._trailingTrivia.hasSkippedToken(); - }; - RealizedToken.prototype.trailingTriviaWidth = function () { - return this._trailingTrivia.fullWidth(); - }; - - RealizedToken.prototype.hasSkippedToken = function () { - return this.hasLeadingSkippedText() || this.hasTrailingSkippedText(); - }; - - RealizedToken.prototype.leadingTrivia = function () { - return this._leadingTrivia; - }; - RealizedToken.prototype.trailingTrivia = function () { - return this._trailingTrivia; - }; - - RealizedToken.prototype.findTokenInternal = function (parent, position, fullStart) { - return new TypeScript.PositionedToken(parent, this, fullStart); - }; - - RealizedToken.prototype.collectTextElements = function (elements) { - this.leadingTrivia().collectTextElements(elements); - elements.push(this.text()); - this.trailingTrivia().collectTextElements(elements); - }; - - RealizedToken.prototype.withLeadingTrivia = function (leadingTrivia) { - return new RealizedToken(this.tokenKind, leadingTrivia, this._text, this._value, this._valueText, this._trailingTrivia); - }; - - RealizedToken.prototype.withTrailingTrivia = function (trailingTrivia) { - return new RealizedToken(this.tokenKind, this._leadingTrivia, this._text, this._value, this._valueText, trailingTrivia); - }; - - RealizedToken.prototype.isExpression = function () { - return isExpression(this); - }; - - RealizedToken.prototype.isPrimaryExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isMemberExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isPostfixExpression = function () { - return this.isExpression(); - }; - - RealizedToken.prototype.isUnaryExpression = function () { - return this.isExpression(); - }; - return RealizedToken; - })(); - - function token(kind, info) { - if (typeof info === "undefined") { info = null; } - var text = (info !== null && info.text !== undefined) ? info.text : TypeScript.SyntaxFacts.getText(kind); - - return new RealizedToken(kind, TypeScript.Syntax.triviaList(info === null ? null : info.leadingTrivia), text, value1(kind, text), valueText1(kind, text), TypeScript.Syntax.triviaList(info === null ? null : info.trailingTrivia)); - } - Syntax.token = token; - - function identifier(text, info) { - if (typeof info === "undefined") { info = null; } - info = info || {}; - info.text = text; - return token(11 /* IdentifierName */, info); - } - Syntax.identifier = identifier; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTokenReplacer = (function (_super) { - __extends(SyntaxTokenReplacer, _super); - function SyntaxTokenReplacer(token1, token2) { - _super.call(this); - this.token1 = token1; - this.token2 = token2; - } - SyntaxTokenReplacer.prototype.visitToken = function (token) { - if (token === this.token1) { - var result = this.token2; - this.token1 = null; - this.token2 = null; - - return result; - } - - return token; - }; - - SyntaxTokenReplacer.prototype.visitNode = function (node) { - if (this.token1 === null) { - return node; - } - - return _super.prototype.visitNode.call(this, node); - }; - - SyntaxTokenReplacer.prototype.visitList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitList.call(this, list); - }; - - SyntaxTokenReplacer.prototype.visitSeparatedList = function (list) { - if (this.token1 === null) { - return list; - } - - return _super.prototype.visitSeparatedList.call(this, list); - }; - return SyntaxTokenReplacer; - })(TypeScript.SyntaxRewriter); - TypeScript.SyntaxTokenReplacer = SyntaxTokenReplacer; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - var AbstractTrivia = (function () { - function AbstractTrivia(_kind) { - this._kind = _kind; - } - AbstractTrivia.prototype.fullWidth = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.fullText = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.abstract(); - }; - - AbstractTrivia.prototype.toJSON = function (key) { - var result = {}; - - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === this._kind) { - result.kind = name; - break; - } - } - - if (this.isSkippedToken()) { - result.skippedToken = this.skippedToken(); - } else { - result.text = this.fullText(); - } - return result; - }; - - AbstractTrivia.prototype.kind = function () { - return this._kind; - }; - - AbstractTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; - }; - - AbstractTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; - }; - - AbstractTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; - }; - - AbstractTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; - }; - - AbstractTrivia.prototype.collectTextElements = function (elements) { - elements.push(this.fullText()); - }; - return AbstractTrivia; - })(); - - var NormalTrivia = (function (_super) { - __extends(NormalTrivia, _super); - function NormalTrivia(kind, _text) { - _super.call(this, kind); - this._text = _text; - } - NormalTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - NormalTrivia.prototype.fullText = function () { - return this._text; - }; - - NormalTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return NormalTrivia; - })(AbstractTrivia); - - var SkippedTokenTrivia = (function (_super) { - __extends(SkippedTokenTrivia, _super); - function SkippedTokenTrivia(_skippedToken) { - _super.call(this, 8 /* SkippedTokenTrivia */); - this._skippedToken = _skippedToken; - } - SkippedTokenTrivia.prototype.fullWidth = function () { - return this.fullText().length; - }; - - SkippedTokenTrivia.prototype.fullText = function () { - return this.skippedToken().fullText(); - }; - - SkippedTokenTrivia.prototype.skippedToken = function () { - return this._skippedToken; - }; - return SkippedTokenTrivia; - })(AbstractTrivia); - - var DeferredTrivia = (function (_super) { - __extends(DeferredTrivia, _super); - function DeferredTrivia(kind, _text, _fullStart, _fullWidth) { - _super.call(this, kind); - this._text = _text; - this._fullStart = _fullStart; - this._fullWidth = _fullWidth; - this._fullText = null; - } - DeferredTrivia.prototype.fullWidth = function () { - return this._fullWidth; - }; - - DeferredTrivia.prototype.fullText = function () { - if (!this._fullText) { - this._fullText = this._text.substr(this._fullStart, this._fullWidth, false); - this._text = null; - } - - return this._fullText; - }; - - DeferredTrivia.prototype.skippedToken = function () { - throw TypeScript.Errors.invalidOperation(); - }; - return DeferredTrivia; - })(AbstractTrivia); - - function deferredTrivia(kind, text, fullStart, fullWidth) { - return new DeferredTrivia(kind, text, fullStart, fullWidth); - } - Syntax.deferredTrivia = deferredTrivia; - - function trivia(kind, text) { - return new NormalTrivia(kind, text); - } - Syntax.trivia = trivia; - - function skippedTokenTrivia(token) { - TypeScript.Debug.assert(!token.hasLeadingTrivia()); - TypeScript.Debug.assert(!token.hasTrailingTrivia()); - TypeScript.Debug.assert(token.fullWidth() > 0); - return new SkippedTokenTrivia(token); - } - Syntax.skippedTokenTrivia = skippedTokenTrivia; - - function spaces(count) { - return trivia(4 /* WhitespaceTrivia */, TypeScript.StringUtilities.repeat(" ", count)); - } - Syntax.spaces = spaces; - - function whitespace(text) { - return trivia(4 /* WhitespaceTrivia */, text); - } - Syntax.whitespace = whitespace; - - function multiLineComment(text) { - return trivia(6 /* MultiLineCommentTrivia */, text); - } - Syntax.multiLineComment = multiLineComment; - - function singleLineComment(text) { - return trivia(7 /* SingleLineCommentTrivia */, text); - } - Syntax.singleLineComment = singleLineComment; - - Syntax.spaceTrivia = spaces(1); - Syntax.lineFeedTrivia = trivia(5 /* NewLineTrivia */, "\n"); - Syntax.carriageReturnTrivia = trivia(5 /* NewLineTrivia */, "\r"); - Syntax.carriageReturnLineFeedTrivia = trivia(5 /* NewLineTrivia */, "\r\n"); - - function splitMultiLineCommentTriviaIntoMultipleLines(trivia) { - var result = []; - - var triviaText = trivia.fullText(); - var currentIndex = 0; - - for (var i = 0; i < triviaText.length; i++) { - var ch = triviaText.charCodeAt(i); - - var isCarriageReturnLineFeed = false; - switch (ch) { - case 13 /* carriageReturn */: - if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === 10 /* lineFeed */) { - i++; - } - - case 10 /* lineFeed */: - case 8233 /* paragraphSeparator */: - case 8232 /* lineSeparator */: - result.push(triviaText.substring(currentIndex, i + 1)); - - currentIndex = i + 1; - continue; - } - } - - result.push(triviaText.substring(currentIndex)); - return result; - } - Syntax.splitMultiLineCommentTriviaIntoMultipleLines = splitMultiLineCommentTriviaIntoMultipleLines; - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (function (Syntax) { - Syntax.emptyTriviaList = { - kind: function () { - return 3 /* TriviaList */; - }, - count: function () { - return 0; - }, - syntaxTriviaAt: function (index) { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - last: function () { - throw TypeScript.Errors.argumentOutOfRange("index"); - }, - fullWidth: function () { - return 0; - }, - fullText: function () { - return ""; - }, - hasComment: function () { - return false; - }, - hasNewLine: function () { - return false; - }, - hasSkippedToken: function () { - return false; - }, - toJSON: function (key) { - return []; - }, - collectTextElements: function (elements) { - }, - toArray: function () { - return []; - }, - concat: function (trivia) { - return trivia; - } - }; - - function concatTrivia(list1, list2) { - if (list1.count() === 0) { - return list2; - } - - if (list2.count() === 0) { - return list1; - } - - var trivia = list1.toArray(); - trivia.push.apply(trivia, list2.toArray()); - - return triviaList(trivia); - } - - function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; - } - - var SingletonSyntaxTriviaList = (function () { - function SingletonSyntaxTriviaList(item) { - this.item = item; - } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - SingletonSyntaxTriviaList.prototype.count = function () { - return 1; - }; - - SingletonSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index !== 0) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.last = function () { - return this.item; - }; - - SingletonSyntaxTriviaList.prototype.fullWidth = function () { - return this.item.fullWidth(); - }; - - SingletonSyntaxTriviaList.prototype.fullText = function () { - return this.item.fullText(); - }; - - SingletonSyntaxTriviaList.prototype.hasComment = function () { - return isComment(this.item); - }; - - SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; - }; - - SingletonSyntaxTriviaList.prototype.toJSON = function (key) { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.collectTextElements = function (elements) { - this.item.collectTextElements(elements); - }; - - SingletonSyntaxTriviaList.prototype.toArray = function () { - return [this.item]; - }; - - SingletonSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return SingletonSyntaxTriviaList; - })(); - - var NormalSyntaxTriviaList = (function () { - function NormalSyntaxTriviaList(trivia) { - this.trivia = trivia; - } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; - - NormalSyntaxTriviaList.prototype.count = function () { - return this.trivia.length; - }; - - NormalSyntaxTriviaList.prototype.syntaxTriviaAt = function (index) { - if (index < 0 || index >= this.trivia.length) { - throw TypeScript.Errors.argumentOutOfRange("index"); - } - - return this.trivia[index]; - }; - - NormalSyntaxTriviaList.prototype.last = function () { - return this.trivia[this.trivia.length - 1]; - }; - - NormalSyntaxTriviaList.prototype.fullWidth = function () { - return TypeScript.ArrayUtilities.sum(this.trivia, function (t) { - return t.fullWidth(); - }); - }; - - NormalSyntaxTriviaList.prototype.fullText = function () { - var result = ""; - - for (var i = 0, n = this.trivia.length; i < n; i++) { - result += this.trivia[i].fullText(); - } - - return result; - }; - - NormalSyntaxTriviaList.prototype.hasComment = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (isComment(this.trivia[i])) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasNewLine = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { - for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { - return true; - } - } - - return false; - }; - - NormalSyntaxTriviaList.prototype.toJSON = function (key) { - return this.trivia; - }; - - NormalSyntaxTriviaList.prototype.collectTextElements = function (elements) { - for (var i = 0; i < this.trivia.length; i++) { - this.trivia[i].collectTextElements(elements); - } - }; - - NormalSyntaxTriviaList.prototype.toArray = function () { - return this.trivia.slice(0); - }; - - NormalSyntaxTriviaList.prototype.concat = function (trivia) { - return concatTrivia(this, trivia); - }; - return NormalSyntaxTriviaList; - })(); - - function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { - return Syntax.emptyTriviaList; - } - - if (trivia.length === 1) { - return new SingletonSyntaxTriviaList(trivia[0]); - } - - return new NormalSyntaxTriviaList(trivia); - } - Syntax.triviaList = triviaList; - - Syntax.spaceTriviaList = triviaList([TypeScript.Syntax.spaceTrivia]); - })(TypeScript.Syntax || (TypeScript.Syntax = {})); - var Syntax = TypeScript.Syntax; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxUtilities = (function () { - function SyntaxUtilities() { - } - SyntaxUtilities.isAngleBracket = function (positionedElement) { - var element = positionedElement.element(); - var parent = positionedElement.parentElement(); - if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { - switch (parent.kind()) { - case 228 /* TypeArgumentList */: - case 229 /* TypeParameterList */: - case 220 /* CastExpression */: - return true; - } - } - - return false; - }; - - SyntaxUtilities.getToken = function (list, kind) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var token = list.childAt(i); - if (token.tokenKind === kind) { - return token; - } - } - - return null; - }; - - SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; - }; - - SyntaxUtilities.hasExportKeyword = function (moduleElement) { - return SyntaxUtilities.getExportKeyword(moduleElement) !== null; - }; - - SyntaxUtilities.getExportKeyword = function (moduleElement) { - switch (moduleElement.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - case 128 /* InterfaceDeclaration */: - case 133 /* ImportDeclaration */: - return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); - default: - return null; - } - }; - - SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { - if (!positionNode) { - return false; - } - - var node = positionNode.node(); - switch (node.kind()) { - case 130 /* ModuleDeclaration */: - case 131 /* ClassDeclaration */: - case 129 /* FunctionDeclaration */: - case 148 /* VariableStatement */: - case 132 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - return true; - } - - case 133 /* ImportDeclaration */: - case 137 /* ConstructorDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - case 136 /* MemberVariableDeclaration */: - if (node.isClassElement() || node.isModuleElement()) { - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - - case 243 /* EnumElement */: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode().containingNode()); - - default: - return SyntaxUtilities.isAmbientDeclarationSyntax(positionNode.containingNode()); - } - }; - return SyntaxUtilities; - })(); - TypeScript.SyntaxUtilities = SyntaxUtilities; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxVisitor = (function () { - function SyntaxVisitor() { - } - SyntaxVisitor.prototype.defaultVisit = function (node) { - return null; - }; - - SyntaxVisitor.prototype.visitToken = function (token) { - return this.defaultVisit(token); - }; - - SyntaxVisitor.prototype.visitSourceUnit = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExternalModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleNameModuleReference = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitImportDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExportAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitClassDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInterfaceDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitHeritageClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitModuleDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVariableDeclarator = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEqualsValueClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPrefixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitOmittedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitQualifiedName = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArrayType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGenericType = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeQuery = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeAnnotation = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBlock = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPostfixUnaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElementAccessExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitInvocationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitArgumentList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBinaryExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConditionalExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMethodSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitPropertySignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCallSignature = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameterList = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeParameter = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstraint = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitElseClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIfStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitExpressionStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitConstructorDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitGetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSetAccessor = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitMemberVariableDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitIndexMemberDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitThrowStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitReturnStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectCreationExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSwitchStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCaseSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDefaultSwitchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitBreakStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitContinueStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitForInStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWhileStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitWithStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumDeclaration = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEnumElement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCastExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitObjectLiteralExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitSimplePropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFunctionExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitEmptyStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTryStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitCatchClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitFinallyClause = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitLabeledStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDoStatement = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitTypeOfExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDeleteExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitVoidExpression = function (node) { - return this.defaultVisit(node); - }; - - SyntaxVisitor.prototype.visitDebuggerStatement = function (node) { - return this.defaultVisit(node); - }; - return SyntaxVisitor; - })(); - TypeScript.SyntaxVisitor = SyntaxVisitor; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxWalker = (function () { - function SyntaxWalker() { - } - SyntaxWalker.prototype.visitToken = function (token) { - }; - - SyntaxWalker.prototype.visitNode = function (node) { - node.accept(this); - }; - - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (nodeOrToken.isToken()) { - this.visitToken(nodeOrToken); - } else { - this.visitNode(nodeOrToken); - } - }; - - SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { - return; - } - - this.visitToken(token); - }; - - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - - this.visitNode(node); - }; - - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - - this.visitNodeOrToken(nodeOrToken); - }; - - SyntaxWalker.prototype.visitList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.visitNodeOrToken(list.childAt(i)); - } - }; - - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - var item = list.childAt(i); - this.visitNodeOrToken(item); - } - }; - - SyntaxWalker.prototype.visitSourceUnit = function (node) { - this.visitList(node.moduleElements); - this.visitToken(node.endOfFileToken); - }; - - SyntaxWalker.prototype.visitExternalModuleReference = function (node) { - this.visitToken(node.requireKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.stringLiteral); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); - }; - - SyntaxWalker.prototype.visitImportDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.importKeyword); - this.visitToken(node.identifier); - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.moduleReference); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitExportAssignment = function (node) { - this.visitToken(node.exportKeyword); - this.visitToken(node.equalsToken); - this.visitToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitClassDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.classKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitToken(node.openBraceToken); - this.visitList(node.classElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.interfaceKeyword); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); - this.visitList(node.heritageClauses); - this.visitNode(node.body); - }; - - SyntaxWalker.prototype.visitHeritageClause = function (node) { - this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); - }; - - SyntaxWalker.prototype.visitModuleDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.name); - this.visitOptionalToken(node.stringLiteral); - this.visitToken(node.openBraceToken); - this.visitList(node.moduleElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.functionKeyword); - this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableStatement = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitVariableDeclaration = function (node) { - this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); - }; - - SyntaxWalker.prototype.visitVariableDeclarator = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitEqualsValueClause = function (node) { - this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); - }; - - SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); - }; - - SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { - this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitOmittedExpression = function (node) { - }; - - SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); - this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.dotToken); - this.visitToken(node.right); - }; - - SyntaxWalker.prototype.visitTypeArgumentList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitConstructorType = function (node) { - this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitObjectType = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); - this.visitToken(node.openBracketToken); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); - }; - - SyntaxWalker.prototype.visitTypeQuery = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.name); - }; - - SyntaxWalker.prototype.visitTypeAnnotation = function (node) { - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitBlock = function (node) { - this.visitToken(node.openBraceToken); - this.visitList(node.statements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitParameter = function (node) { - this.visitOptionalToken(node.dotDotDotToken); - this.visitList(node.modifiers); - this.visitToken(node.identifier); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.dotToken); - this.visitToken(node.name); - }; - - SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); - this.visitToken(node.operatorToken); - }; - - SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); - this.visitToken(node.closeBracketToken); - }; - - SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); - this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); - }; - - SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); - this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); - }; - - SyntaxWalker.prototype.visitConstructSignature = function (node) { - this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitMethodSignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); - }; - - SyntaxWalker.prototype.visitIndexSignature = function (node) { - this.visitToken(node.openBracketToken); - this.visitNode(node.parameter); - this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitPropertySignature = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - }; - - SyntaxWalker.prototype.visitParameterList = function (node) { - this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); - this.visitToken(node.closeParenToken); - }; - - SyntaxWalker.prototype.visitTypeParameterList = function (node) { - this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); - this.visitToken(node.greaterThanToken); - }; - - SyntaxWalker.prototype.visitTypeParameter = function (node) { - this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); - }; - - SyntaxWalker.prototype.visitConstraint = function (node) { - this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.type); - }; - - SyntaxWalker.prototype.visitElseClause = function (node) { - this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitIfStatement = function (node) { - this.visitToken(node.ifKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); - }; - - SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.constructorKeyword); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); - this.visitOptionalToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitGetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.getKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitSetAccessor = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.setKeyword); - this.visitToken(node.propertyName); - this.visitNode(node.parameterList); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitNode(node.indexSignature); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitThrowStatement = function (node) { - this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitReturnStatement = function (node) { - this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { - this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); - }; - - SyntaxWalker.prototype.visitSwitchStatement = function (node) { - this.visitToken(node.switchKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitToken(node.openBraceToken); - this.visitList(node.switchClauses); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { - this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitDefaultSwitchClause = function (node) { - this.visitToken(node.defaultKeyword); - this.visitToken(node.colonToken); - this.visitList(node.statements); - }; - - SyntaxWalker.prototype.visitBreakStatement = function (node) { - this.visitToken(node.breakKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitContinueStatement = function (node) { - this.visitToken(node.continueKeyword); - this.visitOptionalToken(node.identifier); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitForStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); - this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); - this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitForInStatement = function (node) { - this.visitToken(node.forKeyword); - this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); - this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWhileStatement = function (node) { - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitWithStatement = function (node) { - this.visitToken(node.withKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitEnumDeclaration = function (node) { - this.visitList(node.modifiers); - this.visitToken(node.enumKeyword); - this.visitToken(node.identifier); - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitEnumElement = function (node) { - this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); - }; - - SyntaxWalker.prototype.visitCastExpression = function (node) { - this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); - this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { - this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); - this.visitToken(node.closeBraceToken); - }; - - SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { - this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFunctionExpression = function (node) { - this.visitToken(node.functionKeyword); - this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitEmptyStatement = function (node) { - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTryStatement = function (node) { - this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); - }; - - SyntaxWalker.prototype.visitCatchClause = function (node) { - this.visitToken(node.catchKeyword); - this.visitToken(node.openParenToken); - this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); - this.visitToken(node.closeParenToken); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitFinallyClause = function (node) { - this.visitToken(node.finallyKeyword); - this.visitNode(node.block); - }; - - SyntaxWalker.prototype.visitLabeledStatement = function (node) { - this.visitToken(node.identifier); - this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); - }; - - SyntaxWalker.prototype.visitDoStatement = function (node) { - this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); - this.visitToken(node.whileKeyword); - this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); - this.visitToken(node.closeParenToken); - this.visitToken(node.semicolonToken); - }; - - SyntaxWalker.prototype.visitTypeOfExpression = function (node) { - this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDeleteExpression = function (node) { - this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitVoidExpression = function (node) { - this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); - }; - - SyntaxWalker.prototype.visitDebuggerStatement = function (node) { - this.visitToken(node.debuggerKeyword); - this.visitToken(node.semicolonToken); - }; - return SyntaxWalker; - })(); - TypeScript.SyntaxWalker = SyntaxWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PositionTrackingWalker = (function (_super) { - __extends(PositionTrackingWalker, _super); - function PositionTrackingWalker() { - _super.apply(this, arguments); - this._position = 0; - } - PositionTrackingWalker.prototype.visitToken = function (token) { - this._position += token.fullWidth(); - }; - - PositionTrackingWalker.prototype.position = function () { - return this._position; - }; - - PositionTrackingWalker.prototype.skip = function (element) { - this._position += element.fullWidth(); - }; - return PositionTrackingWalker; - })(TypeScript.SyntaxWalker); - TypeScript.PositionTrackingWalker = PositionTrackingWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxInformationMap = (function (_super) { - __extends(SyntaxInformationMap, _super); - function SyntaxInformationMap(trackParents, trackPreviousToken) { - _super.call(this); - this.trackParents = trackParents; - this.trackPreviousToken = trackPreviousToken; - this.tokenToInformation = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this.elementToPosition = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._previousToken = null; - this._previousTokenInformation = null; - this._currentPosition = 0; - this._elementToParent = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - this._parentStack = []; - this._parentStack.push(null); - } - SyntaxInformationMap.create = function (node, trackParents, trackPreviousToken) { - var map = new SyntaxInformationMap(trackParents, trackPreviousToken); - map.visitNode(node); - return map; - }; - - SyntaxInformationMap.prototype.visitNode = function (node) { - this.trackParents && this._elementToParent.add(node, TypeScript.ArrayUtilities.last(this._parentStack)); - this.elementToPosition.add(node, this._currentPosition); - - this.trackParents && this._parentStack.push(node); - _super.prototype.visitNode.call(this, node); - this.trackParents && this._parentStack.pop(); - }; - - SyntaxInformationMap.prototype.visitToken = function (token) { - this.trackParents && this._elementToParent.add(token, TypeScript.ArrayUtilities.last(this._parentStack)); - - if (this.trackPreviousToken) { - var tokenInformation = { - previousToken: this._previousToken, - nextToken: null - }; - - if (this._previousTokenInformation !== null) { - this._previousTokenInformation.nextToken = token; - } - - this._previousToken = token; - this._previousTokenInformation = tokenInformation; - - this.tokenToInformation.add(token, tokenInformation); - } - - this.elementToPosition.add(token, this._currentPosition); - this._currentPosition += token.fullWidth(); - }; - - SyntaxInformationMap.prototype.parent = function (element) { - return this._elementToParent.get(element); - }; - - SyntaxInformationMap.prototype.fullStart = function (element) { - return this.elementToPosition.get(element); - }; - - SyntaxInformationMap.prototype.start = function (element) { - return this.fullStart(element) + element.leadingTriviaWidth(); - }; - - SyntaxInformationMap.prototype.end = function (element) { - return this.start(element) + element.width(); - }; - - SyntaxInformationMap.prototype.previousToken = function (token) { - return this.tokenInformation(token).previousToken; - }; - - SyntaxInformationMap.prototype.tokenInformation = function (token) { - return this.tokenToInformation.get(token); - }; - - SyntaxInformationMap.prototype.firstTokenInLineContainingToken = function (token) { - var current = token; - while (true) { - var information = this.tokenInformation(current); - if (this.isFirstTokenInLineWorker(information)) { - break; - } - - current = information.previousToken; - } - - return current; - }; - - SyntaxInformationMap.prototype.isFirstTokenInLine = function (token) { - var information = this.tokenInformation(token); - return this.isFirstTokenInLineWorker(information); - }; - - SyntaxInformationMap.prototype.isFirstTokenInLineWorker = function (information) { - return information.previousToken === null || information.previousToken.hasTrailingNewLine(); - }; - return SyntaxInformationMap; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxInformationMap = SyntaxInformationMap; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxNodeInvariantsChecker = (function (_super) { - __extends(SyntaxNodeInvariantsChecker, _super); - function SyntaxNodeInvariantsChecker() { - _super.apply(this, arguments); - this.tokenTable = TypeScript.Collections.createHashTable(TypeScript.Collections.DefaultHashTableCapacity, TypeScript.Collections.identityHashCode); - } - SyntaxNodeInvariantsChecker.checkInvariants = function (node) { - node.accept(new SyntaxNodeInvariantsChecker()); - }; - - SyntaxNodeInvariantsChecker.prototype.visitToken = function (token) { - this.tokenTable.add(token, token); - }; - return SyntaxNodeInvariantsChecker; - })(TypeScript.SyntaxWalker); - TypeScript.SyntaxNodeInvariantsChecker = SyntaxNodeInvariantsChecker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } else { - this.skip(node); - } - }; - return DepthLimitedWalker; - })(TypeScript.PositionTrackingWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (Parser) { - - - var ExpressionPrecedence; - (function (ExpressionPrecedence) { - ExpressionPrecedence[ExpressionPrecedence["CommaExpressionPrecedence"] = 1] = "CommaExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["AssignmentExpressionPrecedence"] = 2] = "AssignmentExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ConditionalExpressionPrecedence"] = 3] = "ConditionalExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["ArrowFunctionPrecedence"] = 4] = "ArrowFunctionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["LogicalOrExpressionPrecedence"] = 5] = "LogicalOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["LogicalAndExpressionPrecedence"] = 6] = "LogicalAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseOrExpressionPrecedence"] = 7] = "BitwiseOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseExclusiveOrExpressionPrecedence"] = 8] = "BitwiseExclusiveOrExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["BitwiseAndExpressionPrecedence"] = 9] = "BitwiseAndExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["EqualityExpressionPrecedence"] = 10] = "EqualityExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["RelationalExpressionPrecedence"] = 11] = "RelationalExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["ShiftExpressionPrecdence"] = 12] = "ShiftExpressionPrecdence"; - ExpressionPrecedence[ExpressionPrecedence["AdditiveExpressionPrecedence"] = 13] = "AdditiveExpressionPrecedence"; - ExpressionPrecedence[ExpressionPrecedence["MultiplicativeExpressionPrecedence"] = 14] = "MultiplicativeExpressionPrecedence"; - - ExpressionPrecedence[ExpressionPrecedence["UnaryExpressionPrecedence"] = 15] = "UnaryExpressionPrecedence"; - })(ExpressionPrecedence || (ExpressionPrecedence = {})); - - var ListParsingState; - (function (ListParsingState) { - ListParsingState[ListParsingState["SourceUnit_ModuleElements"] = 1 << 0] = "SourceUnit_ModuleElements"; - ListParsingState[ListParsingState["ClassDeclaration_ClassElements"] = 1 << 1] = "ClassDeclaration_ClassElements"; - ListParsingState[ListParsingState["ModuleDeclaration_ModuleElements"] = 1 << 2] = "ModuleDeclaration_ModuleElements"; - ListParsingState[ListParsingState["SwitchStatement_SwitchClauses"] = 1 << 3] = "SwitchStatement_SwitchClauses"; - ListParsingState[ListParsingState["SwitchClause_Statements"] = 1 << 4] = "SwitchClause_Statements"; - ListParsingState[ListParsingState["Block_Statements"] = 1 << 5] = "Block_Statements"; - ListParsingState[ListParsingState["TryBlock_Statements"] = 1 << 6] = "TryBlock_Statements"; - ListParsingState[ListParsingState["CatchBlock_Statements"] = 1 << 7] = "CatchBlock_Statements"; - ListParsingState[ListParsingState["EnumDeclaration_EnumElements"] = 1 << 8] = "EnumDeclaration_EnumElements"; - ListParsingState[ListParsingState["ObjectType_TypeMembers"] = 1 << 9] = "ObjectType_TypeMembers"; - ListParsingState[ListParsingState["ClassOrInterfaceDeclaration_HeritageClauses"] = 1 << 10] = "ClassOrInterfaceDeclaration_HeritageClauses"; - ListParsingState[ListParsingState["HeritageClause_TypeNameList"] = 1 << 11] = "HeritageClause_TypeNameList"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_AllowIn"] = 1 << 12] = "VariableDeclaration_VariableDeclarators_AllowIn"; - ListParsingState[ListParsingState["VariableDeclaration_VariableDeclarators_DisallowIn"] = 1 << 13] = "VariableDeclaration_VariableDeclarators_DisallowIn"; - ListParsingState[ListParsingState["ArgumentList_AssignmentExpressions"] = 1 << 14] = "ArgumentList_AssignmentExpressions"; - ListParsingState[ListParsingState["ObjectLiteralExpression_PropertyAssignments"] = 1 << 15] = "ObjectLiteralExpression_PropertyAssignments"; - ListParsingState[ListParsingState["ArrayLiteralExpression_AssignmentExpressions"] = 1 << 16] = "ArrayLiteralExpression_AssignmentExpressions"; - ListParsingState[ListParsingState["ParameterList_Parameters"] = 1 << 17] = "ParameterList_Parameters"; - ListParsingState[ListParsingState["TypeArgumentList_Types"] = 1 << 18] = "TypeArgumentList_Types"; - ListParsingState[ListParsingState["TypeParameterList_TypeParameters"] = 1 << 19] = "TypeParameterList_TypeParameters"; - - ListParsingState[ListParsingState["FirstListParsingState"] = ListParsingState.SourceUnit_ModuleElements] = "FirstListParsingState"; - ListParsingState[ListParsingState["LastListParsingState"] = ListParsingState.TypeParameterList_TypeParameters] = "LastListParsingState"; - })(ListParsingState || (ListParsingState = {})); - - var SyntaxCursor = (function () { - function SyntaxCursor(sourceUnit) { - this._elements = []; - this._index = 0; - this._pinCount = 0; - sourceUnit.insertChildrenInto(this._elements, 0); - } - SyntaxCursor.prototype.isFinished = function () { - return this._index === this._elements.length; - }; - - SyntaxCursor.prototype.currentElement = function () { - if (this.isFinished()) { - return null; - } - - return this._elements[this._index]; - }; - - SyntaxCursor.prototype.currentNode = function () { - var element = this.currentElement(); - return element !== null && element.isNode() ? element : null; - }; - - SyntaxCursor.prototype.moveToFirstChild = function () { - if (this.isFinished()) { - return; - } - - var element = this._elements[this._index]; - if (element.isToken()) { - return; - } - - var node = element; - - this._elements.splice(this._index, 1); - - node.insertChildrenInto(this._elements, this._index); - }; - - SyntaxCursor.prototype.moveToNextSibling = function () { - if (this.isFinished()) { - return; - } - - if (this._pinCount > 0) { - this._index++; - return; - } - - this._elements.shift(); - }; - - SyntaxCursor.prototype.getAndPinCursorIndex = function () { - this._pinCount++; - return this._index; - }; - - SyntaxCursor.prototype.releaseAndUnpinCursorIndex = function (index) { - this._pinCount--; - if (this._pinCount === 0) { - } - }; - - SyntaxCursor.prototype.rewindToPinnedCursorIndex = function (index) { - this._index = index; - }; - - SyntaxCursor.prototype.pinCount = function () { - return this._pinCount; - }; - - SyntaxCursor.prototype.moveToFirstToken = function () { - var element; - - while (!this.isFinished()) { - element = this.currentElement(); - if (element.isNode()) { - this.moveToFirstChild(); - continue; - } - - return; - } - }; - - SyntaxCursor.prototype.currentToken = function () { - this.moveToFirstToken(); - if (this.isFinished()) { - return null; - } - - var element = this.currentElement(); - - return element; - }; - - SyntaxCursor.prototype.peekToken = function (n) { - this.moveToFirstToken(); - var pin = this.getAndPinCursorIndex(); - - for (var i = 0; i < n; i++) { - this.moveToNextSibling(); - this.moveToFirstToken(); - } - - var result = this.currentToken(); - this.rewindToPinnedCursorIndex(pin); - this.releaseAndUnpinCursorIndex(pin); - - return result; - }; - return SyntaxCursor; - })(); - - - - var NormalParserSource = (function () { - function NormalParserSource(fileName, text, languageVersion) { - this._previousToken = null; - this._absolutePosition = 0; - this._tokenDiagnostics = []; - this.rewindPointPool = []; - this.rewindPointPoolCount = 0; - this.slidingWindow = new TypeScript.SlidingWindow(this, TypeScript.ArrayUtilities.createArray(32, null), null); - this.scanner = new TypeScript.Scanner(fileName, text, languageVersion); - } - NormalParserSource.prototype.currentNode = function () { - return null; - }; - - NormalParserSource.prototype.moveToNextNode = function () { - throw TypeScript.Errors.invalidOperation(); - }; - - NormalParserSource.prototype.absolutePosition = function () { - return this._absolutePosition; - }; - - NormalParserSource.prototype.previousToken = function () { - return this._previousToken; - }; - - NormalParserSource.prototype.tokenDiagnostics = function () { - return this._tokenDiagnostics; - }; - - NormalParserSource.prototype.getOrCreateRewindPoint = function () { - if (this.rewindPointPoolCount === 0) { - return {}; - } - - this.rewindPointPoolCount--; - var result = this.rewindPointPool[this.rewindPointPoolCount]; - this.rewindPointPool[this.rewindPointPoolCount] = null; - return result; - }; - - NormalParserSource.prototype.getRewindPoint = function () { - var slidingWindowIndex = this.slidingWindow.getAndPinAbsoluteIndex(); - - var rewindPoint = this.getOrCreateRewindPoint(); - - rewindPoint.slidingWindowIndex = slidingWindowIndex; - rewindPoint.previousToken = this._previousToken; - rewindPoint.absolutePosition = this._absolutePosition; - - rewindPoint.pinCount = this.slidingWindow.pinCount(); - - return rewindPoint; - }; - - NormalParserSource.prototype.isPinned = function () { - return this.slidingWindow.pinCount() > 0; - }; - - NormalParserSource.prototype.rewind = function (rewindPoint) { - this.slidingWindow.rewindToPinnedIndex(rewindPoint.slidingWindowIndex); - - this._previousToken = rewindPoint.previousToken; - this._absolutePosition = rewindPoint.absolutePosition; - }; - - NormalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this.slidingWindow.releaseAndUnpinAbsoluteIndex(rewindPoint.absoluteIndex); - - this.rewindPointPool[this.rewindPointPoolCount] = rewindPoint; - this.rewindPointPoolCount++; - }; - - NormalParserSource.prototype.fetchMoreItems = function (allowRegularExpression, sourceIndex, window, destinationIndex, spaceAvailable) { - window[destinationIndex] = this.scanner.scan(this._tokenDiagnostics, allowRegularExpression); - return 1; - }; - - NormalParserSource.prototype.peekToken = function (n) { - return this.slidingWindow.peekItemN(n); - }; - - NormalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - this._absolutePosition += currentToken.fullWidth(); - this._previousToken = currentToken; - - this.slidingWindow.moveToNextItem(); - }; - - NormalParserSource.prototype.currentToken = function () { - return this.slidingWindow.currentItem(false); - }; - - NormalParserSource.prototype.removeDiagnosticsOnOrAfterPosition = function (position) { - var tokenDiagnosticsLength = this._tokenDiagnostics.length; - while (tokenDiagnosticsLength > 0) { - var diagnostic = this._tokenDiagnostics[tokenDiagnosticsLength - 1]; - if (diagnostic.start() >= position) { - tokenDiagnosticsLength--; - } else { - break; - } - } - - this._tokenDiagnostics.length = tokenDiagnosticsLength; - }; - - NormalParserSource.prototype.resetToPosition = function (absolutePosition, previousToken) { - this._absolutePosition = absolutePosition; - this._previousToken = previousToken; - - this.removeDiagnosticsOnOrAfterPosition(absolutePosition); - - this.slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); - - this.scanner.setAbsoluteIndex(absolutePosition); - }; - - NormalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - this.resetToPosition(this._absolutePosition, this._previousToken); - - var token = this.slidingWindow.currentItem(true); - - return token; - }; - return NormalParserSource; - })(); - - var IncrementalParserSource = (function () { - function IncrementalParserSource(oldSyntaxTree, textChangeRange, newText) { - this._changeDelta = 0; - var oldSourceUnit = oldSyntaxTree.sourceUnit(); - this._oldSourceUnitCursor = new SyntaxCursor(oldSourceUnit); - - this._changeRange = IncrementalParserSource.extendToAffectedRange(textChangeRange, oldSourceUnit); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert((oldSourceUnit.fullWidth() - this._changeRange.span().length() + this._changeRange.newLength()) === newText.length()); - } - - this._normalParserSource = new NormalParserSource(oldSyntaxTree.fileName(), newText, oldSyntaxTree.parseOptions().languageVersion()); - } - IncrementalParserSource.extendToAffectedRange = function (changeRange, sourceUnit) { - var maxLookahead = 1; - - var start = changeRange.span().start(); - - for (var i = 0; start > 0 && i <= maxLookahead; i++) { - var token = sourceUnit.findToken(start); - - var position = token.fullStart(); - - start = TypeScript.MathPrototype.max(0, position - 1); - } - - var finalSpan = TypeScript.TextSpan.fromBounds(start, changeRange.span().end()); - var finalLength = changeRange.newLength() + (changeRange.span().start() - start); - - return new TypeScript.TextChangeRange(finalSpan, finalLength); - }; - - IncrementalParserSource.prototype.absolutePosition = function () { - return this._normalParserSource.absolutePosition(); - }; - - IncrementalParserSource.prototype.previousToken = function () { - return this._normalParserSource.previousToken(); - }; - - IncrementalParserSource.prototype.tokenDiagnostics = function () { - return this._normalParserSource.tokenDiagnostics(); - }; - - IncrementalParserSource.prototype.getRewindPoint = function () { - var rewindPoint = this._normalParserSource.getRewindPoint(); - var oldSourceUnitCursorIndex = this._oldSourceUnitCursor.getAndPinCursorIndex(); - - rewindPoint.changeDelta = this._changeDelta; - rewindPoint.changeRange = this._changeRange; - rewindPoint.oldSourceUnitCursorIndex = oldSourceUnitCursorIndex; - - return rewindPoint; - }; - - IncrementalParserSource.prototype.rewind = function (rewindPoint) { - this._changeRange = rewindPoint.changeRange; - this._changeDelta = rewindPoint.changeDelta; - this._oldSourceUnitCursor.rewindToPinnedCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - - this._normalParserSource.rewind(rewindPoint); - }; - - IncrementalParserSource.prototype.releaseRewindPoint = function (rewindPoint) { - this._oldSourceUnitCursor.releaseAndUnpinCursorIndex(rewindPoint.oldSourceUnitCursorIndex); - this._normalParserSource.releaseRewindPoint(rewindPoint); - }; - - IncrementalParserSource.prototype.canReadFromOldSourceUnit = function () { - if (this._normalParserSource.isPinned()) { - return false; - } - - if (this._changeRange !== null && this._changeRange.newSpan().intersectsWithPosition(this.absolutePosition())) { - return false; - } - - this.syncCursorToNewTextIfBehind(); - - return this._changeDelta === 0 && !this._oldSourceUnitCursor.isFinished(); - }; - - IncrementalParserSource.prototype.currentNode = function () { - if (this.canReadFromOldSourceUnit()) { - return this.tryGetNodeFromOldSourceUnit(); - } - - return null; - }; - - IncrementalParserSource.prototype.currentToken = function () { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryGetTokenFromOldSourceUnit(); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.currentToken(); - }; - - IncrementalParserSource.prototype.currentTokenAllowingRegularExpression = function () { - return this._normalParserSource.currentTokenAllowingRegularExpression(); - }; - - IncrementalParserSource.prototype.syncCursorToNewTextIfBehind = function () { - while (true) { - if (this._oldSourceUnitCursor.isFinished()) { - break; - } - - if (this._changeDelta >= 0) { - break; - } - - var currentElement = this._oldSourceUnitCursor.currentElement(); - - if (currentElement.isNode() && (currentElement.fullWidth() > Math.abs(this._changeDelta))) { - this._oldSourceUnitCursor.moveToFirstChild(); - } else { - this._oldSourceUnitCursor.moveToNextSibling(); - - this._changeDelta += currentElement.fullWidth(); - } - } - }; - - IncrementalParserSource.prototype.intersectsWithChangeRangeSpanInOriginalText = function (start, length) { - return this._changeRange !== null && this._changeRange.span().intersectsWith(start, length); - }; - - IncrementalParserSource.prototype.tryGetNodeFromOldSourceUnit = function () { - while (true) { - var node = this._oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; - } - - if (!this.intersectsWithChangeRangeSpanInOriginalText(this.absolutePosition(), node.fullWidth())) { - if (!node.isIncrementallyUnusable()) { - return node; - } - } - - this._oldSourceUnitCursor.moveToFirstChild(); - } - }; - - IncrementalParserSource.prototype.canReuseTokenFromOldSourceUnit = function (position, token) { - if (token !== null) { - if (!this.intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { - if (!token.isIncrementallyUnusable()) { - return true; - } - } - } - - return false; - }; - - IncrementalParserSource.prototype.tryGetTokenFromOldSourceUnit = function () { - var token = this._oldSourceUnitCursor.currentToken(); - - return this.canReuseTokenFromOldSourceUnit(this.absolutePosition(), token) ? token : null; - }; - - IncrementalParserSource.prototype.peekToken = function (n) { - if (this.canReadFromOldSourceUnit()) { - var token = this.tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { - return token; - } - } - - return this._normalParserSource.peekToken(n); - }; - - IncrementalParserSource.prototype.tryPeekTokenFromOldSourceUnit = function (n) { - var currentPosition = this.absolutePosition(); - for (var i = 0; i < n; i++) { - var interimToken = this._oldSourceUnitCursor.peekToken(i); - if (!this.canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; - } - - currentPosition += interimToken.fullWidth(); - } - - var token = this._oldSourceUnitCursor.peekToken(n); - return this.canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; - }; - - IncrementalParserSource.prototype.moveToNextNode = function () { - var currentElement = this._oldSourceUnitCursor.currentElement(); - var currentNode = this._oldSourceUnitCursor.currentNode(); - - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentNode.fullWidth(); - var previousToken = currentNode.lastToken(); - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - }; - - IncrementalParserSource.prototype.moveToNextToken = function () { - var currentToken = this.currentToken(); - - if (this._oldSourceUnitCursor.currentToken() === currentToken) { - this._oldSourceUnitCursor.moveToNextSibling(); - - var absolutePosition = this.absolutePosition() + currentToken.fullWidth(); - var previousToken = currentToken; - this._normalParserSource.resetToPosition(absolutePosition, previousToken); - - if (this._changeRange !== null) { - } - } else { - this._changeDelta -= currentToken.fullWidth(); - - this._normalParserSource.moveToNextToken(); - - if (this._changeRange !== null) { - var changeRangeSpanInNewText = this._changeRange.newSpan(); - if (this.absolutePosition() >= changeRangeSpanInNewText.end()) { - this._changeDelta += this._changeRange.newLength() - this._changeRange.span().length(); - this._changeRange = null; - } - } - } - }; - return IncrementalParserSource; - })(); - - var ParserImpl = (function () { - function ParserImpl(fileName, lineMap, source, parseOptions, newText_forDebuggingPurposesOnly) { - this.newText_forDebuggingPurposesOnly = newText_forDebuggingPurposesOnly; - this.listParsingState = 0; - this.isInStrictMode = false; - this.diagnostics = []; - this.factory = TypeScript.Syntax.normalModeFactory; - this.mergeTokensStorage = []; - this.arrayPool = []; - this.fileName = fileName; - this.lineMap = lineMap; - this.source = source; - this.parseOptions = parseOptions; - } - ParserImpl.prototype.getRewindPoint = function () { - var rewindPoint = this.source.getRewindPoint(); - - rewindPoint.diagnosticsCount = this.diagnostics.length; - - rewindPoint.isInStrictMode = this.isInStrictMode; - rewindPoint.listParsingState = this.listParsingState; - - return rewindPoint; - }; - - ParserImpl.prototype.rewind = function (rewindPoint) { - this.source.rewind(rewindPoint); - - this.diagnostics.length = rewindPoint.diagnosticsCount; - }; - - ParserImpl.prototype.releaseRewindPoint = function (rewindPoint) { - this.source.releaseRewindPoint(rewindPoint); - }; - - ParserImpl.prototype.currentTokenStart = function () { - return this.source.absolutePosition() + this.currentToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenStart = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.source.absolutePosition() - this.previousToken().fullWidth() + this.previousToken().leadingTriviaWidth(); - }; - - ParserImpl.prototype.previousTokenEnd = function () { - if (this.previousToken() === null) { - return 0; - } - - return this.previousTokenStart() + this.previousToken().width(); - }; - - ParserImpl.prototype.currentNode = function () { - var node = this.source.currentNode(); - - if (node === null || node.parsedInStrictMode() !== this.isInStrictMode) { - return null; - } - - return node; - }; - - ParserImpl.prototype.currentToken = function () { - return this.source.currentToken(); - }; - - ParserImpl.prototype.currentTokenAllowingRegularExpression = function () { - return this.source.currentTokenAllowingRegularExpression(); - }; - - ParserImpl.prototype.peekToken = function (n) { - return this.source.peekToken(n); - }; - - ParserImpl.prototype.eatAnyToken = function () { - var token = this.currentToken(); - this.moveToNextToken(); - return token; - }; - - ParserImpl.prototype.moveToNextToken = function () { - this.source.moveToNextToken(); - }; - - ParserImpl.prototype.previousToken = function () { - return this.source.previousToken(); - }; - - ParserImpl.prototype.eatNode = function () { - var node = this.source.currentNode(); - this.source.moveToNextNode(); - return node; - }; - - ParserImpl.prototype.eatToken = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.tryEatToken = function (kind) { - if (this.currentToken().tokenKind === kind) { - return this.eatToken(kind); - } - - return null; - }; - - ParserImpl.prototype.eatKeyword = function (kind) { - var token = this.currentToken(); - if (token.tokenKind === kind) { - this.moveToNextToken(); - return token; - } - - return this.createMissingToken(kind, token); - }; - - ParserImpl.prototype.isIdentifier = function (token) { - var tokenKind = token.tokenKind; - - if (tokenKind === 11 /* IdentifierName */) { - return true; - } - - if (tokenKind >= 51 /* FirstFutureReservedStrictKeyword */) { - if (tokenKind <= 59 /* LastFutureReservedStrictKeyword */) { - return !this.isInStrictMode; - } - - return tokenKind <= 69 /* LastTypeScriptKeyword */; - } - - return false; - }; - - ParserImpl.prototype.eatIdentifierNameToken = function () { - var token = this.currentToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - this.moveToNextToken(); - return token; - } - - if (TypeScript.SyntaxFacts.isAnyKeyword(token.tokenKind)) { - this.moveToNextToken(); - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.eatIdentifierToken = function () { - var token = this.currentToken(); - if (this.isIdentifier(token)) { - this.moveToNextToken(); - - if (token.tokenKind === 11 /* IdentifierName */) { - return token; - } - - return TypeScript.Syntax.convertToIdentifierName(token); - } - - return this.createMissingToken(11 /* IdentifierName */, token); - }; - - ParserImpl.prototype.canEatAutomaticSemicolon = function (allowWithoutNewLine) { - var token = this.currentToken(); - - if (token.tokenKind === 10 /* EndOfFileToken */) { - return true; - } - - if (token.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - if (allowWithoutNewLine) { - return true; - } - - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.canEatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return true; - } - - return this.canEatAutomaticSemicolon(allowWithoutNewline); - }; - - ParserImpl.prototype.eatExplicitOrAutomaticSemicolon = function (allowWithoutNewline) { - var token = this.currentToken(); - - if (token.tokenKind === 78 /* SemicolonToken */) { - return this.eatToken(78 /* SemicolonToken */); - } - - if (this.canEatAutomaticSemicolon(allowWithoutNewline)) { - var semicolonToken = TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); - - if (!this.parseOptions.allowAutomaticSemicolonInsertion()) { - this.addDiagnostic(new TypeScript.Diagnostic(this.fileName, this.lineMap, this.previousTokenEnd(), 0, TypeScript.DiagnosticCode.Automatic_semicolon_insertion_not_allowed, null)); - } - - return semicolonToken; - } - - return this.eatToken(78 /* SemicolonToken */); - }; - - ParserImpl.prototype.isKeyword = function (kind) { - if (kind >= 15 /* FirstKeyword */) { - if (kind <= 50 /* LastFutureReservedKeyword */) { - return true; - } - - if (this.isInStrictMode) { - return kind <= 59 /* LastFutureReservedStrictKeyword */; - } - } - - return false; - }; - - ParserImpl.prototype.createMissingToken = function (expectedKind, actual) { - var diagnostic = this.getExpectedTokenDiagnostic(expectedKind, actual); - this.addDiagnostic(diagnostic); - - return TypeScript.Syntax.emptyToken(expectedKind); - }; - - ParserImpl.prototype.getExpectedTokenDiagnostic = function (expectedKind, actual) { - var token = this.currentToken(); - - if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(expectedKind)]); - } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.tokenKind)) { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword, [TypeScript.SyntaxFacts.getText(actual.tokenKind)]); - } else { - return new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Identifier_expected, null); - } - } - }; - - ParserImpl.getPrecedence = function (expressionKind) { - switch (expressionKind) { - case 173 /* CommaExpression */: - return 1 /* CommaExpressionPrecedence */; - - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return 2 /* AssignmentExpressionPrecedence */; - - case 186 /* ConditionalExpression */: - return 3 /* ConditionalExpressionPrecedence */; - - case 187 /* LogicalOrExpression */: - return 5 /* LogicalOrExpressionPrecedence */; - - case 188 /* LogicalAndExpression */: - return 6 /* LogicalAndExpressionPrecedence */; - - case 189 /* BitwiseOrExpression */: - return 7 /* BitwiseOrExpressionPrecedence */; - - case 190 /* BitwiseExclusiveOrExpression */: - return 8 /* BitwiseExclusiveOrExpressionPrecedence */; - - case 191 /* BitwiseAndExpression */: - return 9 /* BitwiseAndExpressionPrecedence */; - - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - return 10 /* EqualityExpressionPrecedence */; - - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - return 11 /* RelationalExpressionPrecedence */; - - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - return 12 /* ShiftExpressionPrecdence */; - - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return 13 /* AdditiveExpressionPrecedence */; - - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - return 14 /* MultiplicativeExpressionPrecedence */; - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 167 /* LogicalNotExpression */: - case 170 /* DeleteExpression */: - case 171 /* TypeOfExpression */: - case 172 /* VoidExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return 15 /* UnaryExpressionPrecedence */; - } - - throw TypeScript.Errors.invalidOperation(); - }; - - ParserImpl.prototype.addSkippedTokenAfterNodeOrToken = function (nodeOrToken, skippedToken) { - if (nodeOrToken.isToken()) { - return this.addSkippedTokenAfterToken(nodeOrToken, skippedToken); - } else if (nodeOrToken.isNode()) { - return this.addSkippedTokenAfterNode(nodeOrToken, skippedToken); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.addSkippedTokenAfterNode = function (node, skippedToken) { - var oldToken = node.lastToken(); - var newToken = this.addSkippedTokenAfterToken(oldToken, skippedToken); - - return node.replaceToken(oldToken, newToken); - }; - - ParserImpl.prototype.addSkippedTokensBeforeNode = function (node, skippedTokens) { - if (skippedTokens.length > 0) { - var oldToken = node.firstToken(); - var newToken = this.addSkippedTokensBeforeToken(oldToken, skippedTokens); - - return node.replaceToken(oldToken, newToken); - } - - return node; - }; - - ParserImpl.prototype.addSkippedTokensBeforeToken = function (token, skippedTokens) { - var leadingTrivia = []; - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(leadingTrivia, skippedTokens[i]); - } - - this.addTriviaTo(token.leadingTrivia(), leadingTrivia); - - this.returnArray(skippedTokens); - return token.withLeadingTrivia(TypeScript.Syntax.triviaList(leadingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokensAfterToken = function (token, skippedTokens) { - if (skippedTokens.length === 0) { - this.returnArray(skippedTokens); - return token; - } - - var trailingTrivia = token.trailingTrivia().toArray(); - - for (var i = 0, n = skippedTokens.length; i < n; i++) { - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedTokens[i]); - } - - this.returnArray(skippedTokens); - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenAfterToken = function (token, skippedToken) { - var trailingTrivia = token.trailingTrivia().toArray(); - this.addSkippedTokenToTriviaArray(trailingTrivia, skippedToken); - - return token.withTrailingTrivia(TypeScript.Syntax.triviaList(trailingTrivia)); - }; - - ParserImpl.prototype.addSkippedTokenToTriviaArray = function (array, skippedToken) { - this.addTriviaTo(skippedToken.leadingTrivia(), array); - - var trimmedToken = skippedToken.withLeadingTrivia(TypeScript.Syntax.emptyTriviaList).withTrailingTrivia(TypeScript.Syntax.emptyTriviaList); - array.push(TypeScript.Syntax.skippedTokenTrivia(trimmedToken)); - - this.addTriviaTo(skippedToken.trailingTrivia(), array); - }; - - ParserImpl.prototype.addTriviaTo = function (list, array) { - for (var i = 0, n = list.count(); i < n; i++) { - array.push(list.syntaxTriviaAt(i)); - } - }; - - ParserImpl.prototype.parseSyntaxTree = function (isDeclaration) { - var sourceUnit = this.parseSourceUnit(); - - var allDiagnostics = this.source.tokenDiagnostics().concat(this.diagnostics); - allDiagnostics.sort(function (a, b) { - return a.start() - b.start(); - }); - - return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, this.fileName, this.lineMap, this.parseOptions); - }; - - ParserImpl.prototype.setStrictMode = function (isInStrictMode) { - this.isInStrictMode = isInStrictMode; - this.factory = isInStrictMode ? TypeScript.Syntax.strictModeFactory : TypeScript.Syntax.normalModeFactory; - }; - - ParserImpl.prototype.parseSourceUnit = function () { - var savedIsInStrictMode = this.isInStrictMode; - - var result = this.parseSyntaxList(1 /* SourceUnit_ModuleElements */, ParserImpl.updateStrictModeState); - var moduleElements = result.list; - - this.setStrictMode(savedIsInStrictMode); - - var sourceUnit = this.factory.sourceUnit(moduleElements, this.currentToken()); - sourceUnit = this.addSkippedTokensBeforeNode(sourceUnit, result.skippedTokens); - - if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullWidth() === this.newText_forDebuggingPurposesOnly.length()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - TypeScript.Debug.assert(sourceUnit.fullText() === this.newText_forDebuggingPurposesOnly.substr(0, this.newText_forDebuggingPurposesOnly.length(), false)); - } - } - - return sourceUnit; - }; - - ParserImpl.updateStrictModeState = function (parser, items) { - if (!parser.isInStrictMode) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!TypeScript.SyntaxFacts.isDirectivePrologueElement(item)) { - return; - } - } - - parser.setStrictMode(TypeScript.SyntaxFacts.isUseStrictDirective(items[items.length - 1])); - } - }; - - ParserImpl.prototype.isModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return true; - } - - var modifierCount = this.modifierCount(); - return this.isImportDeclaration(modifierCount) || this.isExportAssignment() || this.isModuleDeclaration(modifierCount) || this.isInterfaceDeclaration(modifierCount) || this.isClassDeclaration(modifierCount) || this.isEnumDeclaration(modifierCount) || this.isStatement(inErrorRecovery); - }; - - ParserImpl.prototype.parseModuleElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isModuleElement()) { - return this.eatNode(); - } - - var modifierCount = this.modifierCount(); - if (this.isImportDeclaration(modifierCount)) { - return this.parseImportDeclaration(); - } else if (this.isExportAssignment()) { - return this.parseExportAssignment(); - } else if (this.isModuleDeclaration(modifierCount)) { - return this.parseModuleDeclaration(); - } else if (this.isInterfaceDeclaration(modifierCount)) { - return this.parseInterfaceDeclaration(); - } else if (this.isClassDeclaration(modifierCount)) { - return this.parseClassDeclaration(); - } else if (this.isEnumDeclaration(modifierCount)) { - return this.parseEnumDeclaration(); - } else if (this.isStatement(inErrorRecovery)) { - return this.parseStatement(inErrorRecovery); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isImportDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 49 /* ImportKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 49 /* ImportKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseImportDeclaration = function () { - var modifiers = this.parseModifiers(); - var importKeyword = this.eatKeyword(49 /* ImportKeyword */); - var identifier = this.eatIdentifierToken(); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var moduleReference = this.parseModuleReference(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.importDeclaration(modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken); - }; - - ParserImpl.prototype.isExportAssignment = function () { - return this.currentToken().tokenKind === 47 /* ExportKeyword */ && this.peekToken(1).tokenKind === 107 /* EqualsToken */; - }; - - ParserImpl.prototype.parseExportAssignment = function () { - var exportKeyword = this.eatKeyword(47 /* ExportKeyword */); - var equalsToken = this.eatToken(107 /* EqualsToken */); - var identifier = this.eatIdentifierToken(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.exportAssignment(exportKeyword, equalsToken, identifier, semicolonToken); - }; - - ParserImpl.prototype.parseModuleReference = function () { - if (this.isExternalModuleReference()) { - return this.parseExternalModuleReference(); - } else { - return this.parseModuleNameModuleReference(); - } - }; - - ParserImpl.prototype.isExternalModuleReference = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 66 /* RequireKeyword */) { - return this.peekToken(1).tokenKind === 72 /* OpenParenToken */; - } - - return false; - }; - - ParserImpl.prototype.parseExternalModuleReference = function () { - var requireKeyword = this.eatKeyword(66 /* RequireKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var stringLiteral = this.eatToken(14 /* StringLiteral */); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.externalModuleReference(requireKeyword, openParenToken, stringLiteral, closeParenToken); - }; - - ParserImpl.prototype.parseModuleNameModuleReference = function () { - var name = this.parseName(); - return this.factory.moduleNameModuleReference(name); - }; - - ParserImpl.prototype.parseIdentifierName = function () { - var identifierName = this.eatIdentifierNameToken(); - return identifierName; - }; - - ParserImpl.prototype.tryParseTypeArgumentList = function (inExpression) { - if (this.currentToken().kind() !== 80 /* LessThanToken */) { - return null; - } - - var lessThanToken; - var greaterThanToken; - var result; - var typeArguments; - - if (!inExpression) { - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - return this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - } - - var rewindPoint = this.getRewindPoint(); - - lessThanToken = this.eatToken(80 /* LessThanToken */); - - result = this.parseSeparatedSyntaxList(262144 /* TypeArgumentList_Types */); - typeArguments = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (greaterThanToken.fullWidth() === 0 || !this.canFollowTypeArgumentListInExpression(this.currentToken().kind())) { - this.rewind(rewindPoint); - - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeArgumentList = this.factory.typeArgumentList(lessThanToken, typeArguments, greaterThanToken); - - return typeArgumentList; - } - }; - - ParserImpl.prototype.canFollowTypeArgumentListInExpression = function (kind) { - switch (kind) { - case 72 /* OpenParenToken */: - case 76 /* DotToken */: - - case 73 /* CloseParenToken */: - case 75 /* CloseBracketToken */: - case 106 /* ColonToken */: - case 78 /* SemicolonToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - case 84 /* EqualsEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: - case 103 /* AmpersandAmpersandToken */: - case 104 /* BarBarToken */: - case 100 /* CaretToken */: - case 98 /* AmpersandToken */: - case 99 /* BarToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseName = function () { - var shouldContinue = this.isIdentifier(this.currentToken()); - var current = this.eatIdentifierToken(); - - while (shouldContinue && this.currentToken().tokenKind === 76 /* DotToken */) { - var dotToken = this.eatToken(76 /* DotToken */); - - var currentToken = this.currentToken(); - var identifierName; - - if (TypeScript.SyntaxFacts.isAnyKeyword(currentToken.tokenKind) && this.previousToken().hasTrailingNewLine() && !currentToken.hasTrailingNewLine() && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.peekToken(1))) { - identifierName = this.createMissingToken(11 /* IdentifierName */, currentToken); - } else { - identifierName = this.eatIdentifierNameToken(); - } - - current = this.factory.qualifiedName(current, dotToken, identifierName); - - shouldContinue = identifierName.fullWidth() > 0; - } - - return current; - }; - - ParserImpl.prototype.isEnumDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 46 /* EnumKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 46 /* EnumKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseEnumDeclaration = function () { - var modifiers = this.parseModifiers(); - var enumKeyword = this.eatKeyword(46 /* EnumKeyword */); - var identifier = this.eatIdentifierToken(); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList; - - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(256 /* EnumDeclaration_EnumElements */); - enumElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.enumDeclaration(modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken); - }; - - ParserImpl.prototype.isEnumElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return true; - } - - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseEnumElement = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 243 /* EnumElement */) { - return this.eatNode(); - } - - var propertyName = this.eatPropertyName(); - var equalsValueClause = null; - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.enumElement(propertyName, equalsValueClause); - }; - - ParserImpl.isModifier = function (token) { - switch (token.tokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - case 47 /* ExportKeyword */: - case 63 /* DeclareKeyword */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.modifierCount = function () { - var modifierCount = 0; - while (true) { - if (ParserImpl.isModifier(this.peekToken(modifierCount))) { - modifierCount++; - continue; - } - - break; - } - - return modifierCount; - }; - - ParserImpl.prototype.parseModifiers = function () { - var tokens = this.getArray(); - - while (true) { - if (ParserImpl.isModifier(this.currentToken())) { - tokens.push(this.eatAnyToken()); - continue; - } - - break; - } - - var result = TypeScript.Syntax.list(tokens); - - this.returnZeroOrOneLengthArray(tokens); - - return result; - }; - - ParserImpl.prototype.isClassDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 44 /* ClassKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 44 /* ClassKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseHeritageClauses = function () { - var heritageClauses = TypeScript.Syntax.emptyList; - - if (this.isHeritageClause()) { - var result = this.parseSyntaxList(1024 /* ClassOrInterfaceDeclaration_HeritageClauses */); - heritageClauses = result.list; - TypeScript.Debug.assert(result.skippedTokens.length === 0); - } - - return heritageClauses; - }; - - ParserImpl.prototype.parseClassDeclaration = function () { - var modifiers = this.parseModifiers(); - - var classKeyword = this.eatKeyword(44 /* ClassKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList; - - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(2 /* ClassDeclaration_ClassElements */); - - classElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.classDeclaration(modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken); - }; - - ParserImpl.isPublicOrPrivateKeyword = function (token) { - return token.tokenKind === 57 /* PublicKeyword */ || token.tokenKind === 55 /* PrivateKeyword */; - }; - - ParserImpl.prototype.isAccessor = function (inErrorRecovery) { - var index = this.modifierCount(); - - if (this.peekToken(index).tokenKind !== 64 /* GetKeyword */ && this.peekToken(index).tokenKind !== 68 /* SetKeyword */) { - return false; - } - - index++; - return this.isPropertyName(this.peekToken(index), inErrorRecovery); - }; - - ParserImpl.prototype.parseAccessor = function (checkForStrictMode) { - var modifiers = this.parseModifiers(); - - if (this.currentToken().tokenKind === 64 /* GetKeyword */) { - return this.parseGetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else if (this.currentToken().tokenKind === 68 /* SetKeyword */) { - return this.parseSetMemberAccessorDeclaration(modifiers, checkForStrictMode); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseGetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var getKeyword = this.eatKeyword(64 /* GetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.getAccessor(modifiers, getKeyword, propertyName, parameterList, typeAnnotation, block); - }; - - ParserImpl.prototype.parseSetMemberAccessorDeclaration = function (modifiers, checkForStrictMode) { - var setKeyword = this.eatKeyword(68 /* SetKeyword */); - var propertyName = this.eatPropertyName(); - var parameterList = this.parseParameterList(); - var block = this.parseBlock(false, checkForStrictMode); - - return this.factory.setAccessor(modifiers, setKeyword, propertyName, parameterList, block); - }; - - ParserImpl.prototype.isClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return true; - } - - return this.isConstructorDeclaration() || this.isMemberFunctionDeclaration(inErrorRecovery) || this.isAccessor(inErrorRecovery) || this.isMemberVariableDeclaration(inErrorRecovery) || this.isIndexMemberDeclaration(); - }; - - ParserImpl.prototype.parseClassElement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isClassElement()) { - return this.eatNode(); - } - - if (this.isConstructorDeclaration()) { - return this.parseConstructorDeclaration(); - } else if (this.isMemberFunctionDeclaration(inErrorRecovery)) { - return this.parseMemberFunctionDeclaration(); - } else if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(false); - } else if (this.isMemberVariableDeclaration(inErrorRecovery)) { - return this.parseMemberVariableDeclaration(); - } else if (this.isIndexMemberDeclaration()) { - return this.parseIndexMemberDeclaration(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isConstructorDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 62 /* ConstructorKeyword */; - }; - - ParserImpl.prototype.parseConstructorDeclaration = function () { - var modifiers = this.parseModifiers(); - var constructorKeyword = this.eatKeyword(62 /* ConstructorKeyword */); - var callSignature = this.parseCallSignature(false); - - var semicolonToken = null; - var block = null; - - if (this.isBlock()) { - block = this.parseBlock(false, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.constructorDeclaration(modifiers, constructorKeyword, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isMemberFunctionDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isCallSignature(index + 1)) { - return true; - } - - if (ParserImpl.isModifier(token)) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberFunctionDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isCallSignature(1)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var block = null; - var semicolon = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolon = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.memberFunctionDeclaration(modifiers, propertyName, callSignature, block, semicolon); - }; - - ParserImpl.prototype.isDefinitelyMemberVariablePropertyName = function (index) { - if (TypeScript.SyntaxFacts.isAnyKeyword(this.peekToken(index).tokenKind)) { - switch (this.peekToken(index + 1).tokenKind) { - case 78 /* SemicolonToken */: - case 107 /* EqualsToken */: - case 106 /* ColonToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: - return true; - default: - return false; - } - } else { - return true; - } - }; - - ParserImpl.prototype.isMemberVariableDeclaration = function (inErrorRecovery) { - var index = 0; - - while (true) { - var token = this.peekToken(index); - if (this.isPropertyName(token, inErrorRecovery) && this.isDefinitelyMemberVariablePropertyName(index)) { - return true; - } - - if (ParserImpl.isModifier(this.peekToken(index))) { - index++; - continue; - } - - return false; - } - }; - - ParserImpl.prototype.parseMemberVariableDeclaration = function () { - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (this.isPropertyName(currentToken, false) && this.isDefinitelyMemberVariablePropertyName(0)) { - break; - } - - TypeScript.Debug.assert(ParserImpl.isModifier(currentToken)); - modifierArray.push(this.eatAnyToken()); - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var variableDeclarator = this.parseVariableDeclarator(true, true); - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.memberVariableDeclaration(modifiers, variableDeclarator, semicolon); - }; - - ParserImpl.prototype.isIndexMemberDeclaration = function () { - var index = this.modifierCount(); - return this.isIndexSignature(index); - }; - - ParserImpl.prototype.parseIndexMemberDeclaration = function () { - var modifiers = this.parseModifiers(); - var indexSignature = this.parseIndexSignature(); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.indexMemberDeclaration(modifiers, indexSignature, semicolonToken); - }; - - ParserImpl.prototype.tryAddUnexpectedEqualsGreaterThanToken = function (callSignature) { - var token0 = this.currentToken(); - - var hasEqualsGreaterThanToken = token0.tokenKind === 85 /* EqualsGreaterThanToken */; - if (hasEqualsGreaterThanToken) { - if (callSignature.lastToken()) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); - this.addDiagnostic(diagnostic); - - var token = this.eatAnyToken(); - return this.addSkippedTokenAfterNode(callSignature, token0); - } - } - - return callSignature; - }; - - ParserImpl.prototype.isFunctionDeclaration = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 27 /* FunctionKeyword */; - }; - - ParserImpl.prototype.parseFunctionDeclaration = function () { - var modifiers = this.parseModifiers(); - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = this.eatIdentifierToken(); - var callSignature = this.parseCallSignature(false); - - var parseBlockEvenWithNoOpenBrace = false; - var newCallSignature = this.tryAddUnexpectedEqualsGreaterThanToken(callSignature); - if (newCallSignature !== callSignature) { - parseBlockEvenWithNoOpenBrace = true; - callSignature = newCallSignature; - } - - var semicolonToken = null; - var block = null; - - if (parseBlockEvenWithNoOpenBrace || this.isBlock()) { - block = this.parseBlock(parseBlockEvenWithNoOpenBrace, true); - } else { - semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - } - - return this.factory.functionDeclaration(modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); - }; - - ParserImpl.prototype.isModuleDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 65 /* ModuleKeyword */) { - return true; - } - - if (this.currentToken().tokenKind === 65 /* ModuleKeyword */) { - var token1 = this.peekToken(1); - return this.isIdentifier(token1) || token1.tokenKind === 14 /* StringLiteral */; - } - - return false; - }; - - ParserImpl.prototype.parseModuleDeclaration = function () { - var modifiers = this.parseModifiers(); - var moduleKeyword = this.eatKeyword(65 /* ModuleKeyword */); - - var moduleName = null; - var stringLiteral = null; - - if (this.currentToken().tokenKind === 14 /* StringLiteral */) { - stringLiteral = this.eatToken(14 /* StringLiteral */); - } else { - moduleName = this.parseName(); - } - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var moduleElements = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(4 /* ModuleDeclaration_ModuleElements */); - moduleElements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.moduleDeclaration(modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, closeBraceToken); - }; - - ParserImpl.prototype.isInterfaceDeclaration = function (modifierCount) { - if (modifierCount > 0 && this.peekToken(modifierCount).tokenKind === 52 /* InterfaceKeyword */) { - return true; - } - - return this.currentToken().tokenKind === 52 /* InterfaceKeyword */ && this.isIdentifier(this.peekToken(1)); - }; - - ParserImpl.prototype.parseInterfaceDeclaration = function () { - var modifiers = this.parseModifiers(); - var interfaceKeyword = this.eatKeyword(52 /* InterfaceKeyword */); - var identifier = this.eatIdentifierToken(); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var heritageClauses = this.parseHeritageClauses(); - - var objectType = this.parseObjectType(); - return this.factory.interfaceDeclaration(modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, objectType); - }; - - ParserImpl.prototype.parseObjectType = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var typeMembers = TypeScript.Syntax.emptySeparatedList; - if (openBraceToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(512 /* ObjectType_TypeMembers */); - typeMembers = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.objectType(openBraceToken, typeMembers, closeBraceToken); - }; - - ParserImpl.prototype.isTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return true; - } - - return this.isCallSignature(0) || this.isConstructSignature() || this.isIndexSignature(0) || this.isMethodSignature(inErrorRecovery) || this.isPropertySignature(inErrorRecovery); - }; - - ParserImpl.prototype.parseTypeMember = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isTypeMember()) { - return this.eatNode(); - } - - if (this.isCallSignature(0)) { - return this.parseCallSignature(false); - } else if (this.isConstructSignature()) { - return this.parseConstructSignature(); - } else if (this.isIndexSignature(0)) { - return this.parseIndexSignature(); - } else if (this.isMethodSignature(inErrorRecovery)) { - return this.parseMethodSignature(); - } else if (this.isPropertySignature(inErrorRecovery)) { - return this.parsePropertySignature(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseConstructSignature = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var callSignature = this.parseCallSignature(false); - - return this.factory.constructSignature(newKeyword, callSignature); - }; - - ParserImpl.prototype.parseIndexSignature = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var parameter = this.parseParameter(); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.indexSignature(openBracketToken, parameter, closeBracketToken, typeAnnotation); - }; - - ParserImpl.prototype.parseMethodSignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var callSignature = this.parseCallSignature(false); - - return this.factory.methodSignature(propertyName, questionToken, callSignature); - }; - - ParserImpl.prototype.parsePropertySignature = function () { - var propertyName = this.eatPropertyName(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.propertySignature(propertyName, questionToken, typeAnnotation); - }; - - ParserImpl.prototype.isCallSignature = function (tokenIndex) { - var tokenKind = this.peekToken(tokenIndex).tokenKind; - return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; - }; - - ParserImpl.prototype.isConstructSignature = function () { - if (this.currentToken().tokenKind !== 31 /* NewKeyword */) { - return false; - } - - var token1 = this.peekToken(1); - return token1.tokenKind === 80 /* LessThanToken */ || token1.tokenKind === 72 /* OpenParenToken */; - }; - - ParserImpl.prototype.isIndexSignature = function (tokenIndex) { - return this.peekToken(tokenIndex).tokenKind === 74 /* OpenBracketToken */; - }; - - ParserImpl.prototype.isMethodSignature = function (inErrorRecovery) { - if (this.isPropertyName(this.currentToken(), inErrorRecovery)) { - if (this.isCallSignature(1)) { - return true; - } - - if (this.peekToken(1).tokenKind === 105 /* QuestionToken */ && this.isCallSignature(2)) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPropertySignature = function (inErrorRecovery) { - var currentToken = this.currentToken(); - - if (ParserImpl.isModifier(currentToken) && !currentToken.hasTrailingNewLine() && this.isPropertyName(this.peekToken(1), inErrorRecovery)) { - return false; - } - - return this.isPropertyName(currentToken, inErrorRecovery); - }; - - ParserImpl.prototype.isHeritageClause = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */; - }; - - ParserImpl.prototype.isNotHeritageClauseTypeName = function () { - if (this.currentToken().tokenKind === 51 /* ImplementsKeyword */ || this.currentToken().tokenKind === 48 /* ExtendsKeyword */) { - return this.isIdentifier(this.peekToken(1)); - } - - return false; - }; - - ParserImpl.prototype.isHeritageClauseTypeName = function () { - if (this.isIdentifier(this.currentToken())) { - return !this.isNotHeritageClauseTypeName(); - } - - return false; - }; - - ParserImpl.prototype.parseHeritageClause = function () { - var extendsOrImplementsKeyword = this.eatAnyToken(); - TypeScript.Debug.assert(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ || extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - - var result = this.parseSeparatedSyntaxList(2048 /* HeritageClause_TypeNameList */); - var typeNames = result.list; - extendsOrImplementsKeyword = this.addSkippedTokensAfterToken(extendsOrImplementsKeyword, result.skippedTokens); - - return this.factory.heritageClause(extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, extendsOrImplementsKeyword, typeNames); - }; - - ParserImpl.prototype.isStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return true; - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 58 /* StaticKeyword */: - var token1 = this.peekToken(1); - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return false; - } - - break; - - case 28 /* IfKeyword */: - case 70 /* OpenBraceToken */: - case 33 /* ReturnKeyword */: - case 34 /* SwitchKeyword */: - case 36 /* ThrowKeyword */: - case 15 /* BreakKeyword */: - case 18 /* ContinueKeyword */: - case 26 /* ForKeyword */: - case 42 /* WhileKeyword */: - case 43 /* WithKeyword */: - case 22 /* DoKeyword */: - case 38 /* TryKeyword */: - case 19 /* DebuggerKeyword */: - return true; - } - - if (this.isInterfaceDeclaration(0) || this.isClassDeclaration(0) || this.isEnumDeclaration(0) || this.isModuleDeclaration(0)) { - return false; - } - - return this.isLabeledStatement(currentToken) || this.isVariableStatement() || this.isFunctionDeclaration() || this.isEmptyStatement(currentToken, inErrorRecovery) || this.isExpressionStatement(currentToken); - }; - - ParserImpl.prototype.parseStatement = function (inErrorRecovery) { - if (this.currentNode() !== null && this.currentNode().isStatement()) { - return this.eatNode(); - } - - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 28 /* IfKeyword */: - return this.parseIfStatement(); - case 70 /* OpenBraceToken */: - return this.parseBlock(false, false); - case 33 /* ReturnKeyword */: - return this.parseReturnStatement(); - case 34 /* SwitchKeyword */: - return this.parseSwitchStatement(); - case 36 /* ThrowKeyword */: - return this.parseThrowStatement(); - case 15 /* BreakKeyword */: - return this.parseBreakStatement(); - case 18 /* ContinueKeyword */: - return this.parseContinueStatement(); - case 26 /* ForKeyword */: - return this.parseForOrForInStatement(); - case 42 /* WhileKeyword */: - return this.parseWhileStatement(); - case 43 /* WithKeyword */: - return this.parseWithStatement(); - case 22 /* DoKeyword */: - return this.parseDoStatement(); - case 38 /* TryKeyword */: - return this.parseTryStatement(); - case 19 /* DebuggerKeyword */: - return this.parseDebuggerStatement(); - } - - if (this.isVariableStatement()) { - return this.parseVariableStatement(); - } else if (this.isLabeledStatement(currentToken)) { - return this.parseLabeledStatement(); - } else if (this.isFunctionDeclaration()) { - return this.parseFunctionDeclaration(); - } else if (this.isEmptyStatement(currentToken, inErrorRecovery)) { - return this.parseEmptyStatement(); - } else { - return this.parseExpressionStatement(); - } - }; - - ParserImpl.prototype.parseDebuggerStatement = function () { - var debuggerKeyword = this.eatKeyword(19 /* DebuggerKeyword */); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.debuggerStatement(debuggerKeyword, semicolonToken); - }; - - ParserImpl.prototype.parseDoStatement = function () { - var doKeyword = this.eatKeyword(22 /* DoKeyword */); - var statement = this.parseStatement(false); - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(true); - - return this.factory.doStatement(doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken); - }; - - ParserImpl.prototype.isLabeledStatement = function (currentToken) { - return this.isIdentifier(currentToken) && this.peekToken(1).tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseLabeledStatement = function () { - var identifier = this.eatIdentifierToken(); - var colonToken = this.eatToken(106 /* ColonToken */); - var statement = this.parseStatement(false); - - return this.factory.labeledStatement(identifier, colonToken, statement); - }; - - ParserImpl.prototype.parseTryStatement = function () { - var tryKeyword = this.eatKeyword(38 /* TryKeyword */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 64 /* TryBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - var catchClause = null; - if (this.isCatchClause()) { - catchClause = this.parseCatchClause(); - } - - var finallyClause = null; - if (catchClause === null || this.isFinallyClause()) { - finallyClause = this.parseFinallyClause(); - } - - return this.factory.tryStatement(tryKeyword, block, catchClause, finallyClause); - }; - - ParserImpl.prototype.isCatchClause = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */; - }; - - ParserImpl.prototype.parseCatchClause = function () { - var catchKeyword = this.eatKeyword(17 /* CatchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var identifier = this.eatIdentifierToken(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var savedListParsingState = this.listParsingState; - this.listParsingState |= 128 /* CatchBlock_Statements */; - var block = this.parseBlock(false, false); - this.listParsingState = savedListParsingState; - - return this.factory.catchClause(catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block); - }; - - ParserImpl.prototype.isFinallyClause = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.parseFinallyClause = function () { - var finallyKeyword = this.eatKeyword(25 /* FinallyKeyword */); - var block = this.parseBlock(false, false); - - return this.factory.finallyClause(finallyKeyword, block); - }; - - ParserImpl.prototype.parseWithStatement = function () { - var withKeyword = this.eatKeyword(43 /* WithKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.withStatement(withKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.parseWhileStatement = function () { - var whileKeyword = this.eatKeyword(42 /* WhileKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.whileStatement(whileKeyword, openParenToken, condition, closeParenToken, statement); - }; - - ParserImpl.prototype.isEmptyStatement = function (currentToken, inErrorRecovery) { - if (inErrorRecovery) { - return false; - } - - return currentToken.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.parseEmptyStatement = function () { - var semicolonToken = this.eatToken(78 /* SemicolonToken */); - return this.factory.emptyStatement(semicolonToken); - }; - - ParserImpl.prototype.parseForOrForInStatement = function () { - var forKeyword = this.eatKeyword(26 /* ForKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 40 /* VarKeyword */) { - return this.parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); - } else if (currentToken.tokenKind === 78 /* SemicolonToken */) { - return this.parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); - } else { - return this.parseForOrForInStatementWithInitializer(forKeyword, openParenToken); - } - }; - - ParserImpl.prototype.parseForOrForInStatementWithVariableDeclaration = function (forKeyword, openParenToken) { - var variableDeclaration = this.parseVariableDeclaration(false); - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - } - - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); - }; - - ParserImpl.prototype.parseForInStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var inKeyword = this.eatKeyword(29 /* InKeyword */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forInStatement(forKeyword, openParenToken, variableDeclaration, initializer, inKeyword, expression, closeParenToken, statement); - }; - - ParserImpl.prototype.parseForOrForInStatementWithInitializer = function (forKeyword, openParenToken) { - var initializer = this.parseExpression(false); - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return this.parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } else { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); - } - }; - - ParserImpl.prototype.parseForStatementWithNoVariableDeclarationOrInitializer = function (forKeyword, openParenToken) { - return this.parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); - }; - - ParserImpl.prototype.parseForStatementWithVariableDeclarationOrInitializer = function (forKeyword, openParenToken, variableDeclaration, initializer) { - var firstSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var condition = null; - if (this.currentToken().tokenKind !== 78 /* SemicolonToken */ && this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - condition = this.parseExpression(true); - } - - var secondSemicolonToken = this.eatToken(78 /* SemicolonToken */); - - var incrementor = null; - if (this.currentToken().tokenKind !== 73 /* CloseParenToken */ && this.currentToken().tokenKind !== 10 /* EndOfFileToken */) { - incrementor = this.parseExpression(true); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - return this.factory.forStatement(forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement); - }; - - ParserImpl.prototype.parseBreakStatement = function () { - var breakKeyword = this.eatKeyword(15 /* BreakKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.breakStatement(breakKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseContinueStatement = function () { - var continueKeyword = this.eatKeyword(18 /* ContinueKeyword */); - - var identifier = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - } - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - return this.factory.continueStatement(continueKeyword, identifier, semicolon); - }; - - ParserImpl.prototype.parseSwitchStatement = function () { - var switchKeyword = this.eatKeyword(34 /* SwitchKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var switchClauses = TypeScript.Syntax.emptyList; - if (openBraceToken.width() > 0) { - var result = this.parseSyntaxList(8 /* SwitchStatement_SwitchClauses */); - switchClauses = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - return this.factory.switchStatement(switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken); - }; - - ParserImpl.prototype.isCaseSwitchClause = function () { - return this.currentToken().tokenKind === 16 /* CaseKeyword */; - }; - - ParserImpl.prototype.isDefaultSwitchClause = function () { - return this.currentToken().tokenKind === 20 /* DefaultKeyword */; - }; - - ParserImpl.prototype.isSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return true; - } - - return this.isCaseSwitchClause() || this.isDefaultSwitchClause(); - }; - - ParserImpl.prototype.parseSwitchClause = function () { - if (this.currentNode() !== null && this.currentNode().isSwitchClause()) { - return this.eatNode(); - } - - if (this.isCaseSwitchClause()) { - return this.parseCaseSwitchClause(); - } else if (this.isDefaultSwitchClause()) { - return this.parseDefaultSwitchClause(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseCaseSwitchClause = function () { - var caseKeyword = this.eatKeyword(16 /* CaseKeyword */); - var expression = this.parseExpression(true); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.caseSwitchClause(caseKeyword, expression, colonToken, statements); - }; - - ParserImpl.prototype.parseDefaultSwitchClause = function () { - var defaultKeyword = this.eatKeyword(20 /* DefaultKeyword */); - var colonToken = this.eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList; - - if (colonToken.fullWidth() > 0) { - var result = this.parseSyntaxList(16 /* SwitchClause_Statements */); - statements = result.list; - colonToken = this.addSkippedTokensAfterToken(colonToken, result.skippedTokens); - } - - return this.factory.defaultSwitchClause(defaultKeyword, colonToken, statements); - }; - - ParserImpl.prototype.parseThrowStatement = function () { - var throwKeyword = this.eatKeyword(36 /* ThrowKeyword */); - - var expression = null; - if (this.canEatExplicitOrAutomaticSemicolon(false)) { - var token = this.createMissingToken(11 /* IdentifierName */, null); - expression = token; - } else { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.throwStatement(throwKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.parseReturnStatement = function () { - var returnKeyword = this.eatKeyword(33 /* ReturnKeyword */); - - var expression = null; - if (!this.canEatExplicitOrAutomaticSemicolon(false)) { - expression = this.parseExpression(true); - } - - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.returnStatement(returnKeyword, expression, semicolonToken); - }; - - ParserImpl.prototype.isExpressionStatement = function (currentToken) { - var kind = currentToken.tokenKind; - if (kind === 70 /* OpenBraceToken */ || kind === 27 /* FunctionKeyword */) { - return false; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.isAssignmentOrOmittedExpression = function () { - var currentToken = this.currentToken(); - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return this.isExpression(currentToken); - }; - - ParserImpl.prototype.parseAssignmentOrOmittedExpression = function () { - if (this.currentToken().tokenKind === 79 /* CommaToken */) { - return this.factory.omittedExpression(); - } - - return this.parseAssignmentExpression(true); - }; - - ParserImpl.prototype.isExpression = function (currentToken) { - switch (currentToken.tokenKind) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - - case 74 /* OpenBracketToken */: - - case 72 /* OpenParenToken */: - - case 80 /* LessThanToken */: - - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - - case 70 /* OpenBraceToken */: - - case 85 /* EqualsGreaterThanToken */: - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - - case 31 /* NewKeyword */: - - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - - case 27 /* FunctionKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseExpressionStatement = function () { - var expression = this.parseExpression(true); - - var semicolon = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.expressionStatement(expression, semicolon); - }; - - ParserImpl.prototype.parseIfStatement = function () { - var ifKeyword = this.eatKeyword(28 /* IfKeyword */); - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var condition = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - var statement = this.parseStatement(false); - - var elseClause = null; - if (this.isElseClause()) { - elseClause = this.parseElseClause(); - } - - return this.factory.ifStatement(ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause); - }; - - ParserImpl.prototype.isElseClause = function () { - return this.currentToken().tokenKind === 23 /* ElseKeyword */; - }; - - ParserImpl.prototype.parseElseClause = function () { - var elseKeyword = this.eatKeyword(23 /* ElseKeyword */); - var statement = this.parseStatement(false); - - return this.factory.elseClause(elseKeyword, statement); - }; - - ParserImpl.prototype.isVariableStatement = function () { - var index = this.modifierCount(); - return this.peekToken(index).tokenKind === 40 /* VarKeyword */; - }; - - ParserImpl.prototype.parseVariableStatement = function () { - var modifiers = this.parseModifiers(); - var variableDeclaration = this.parseVariableDeclaration(true); - var semicolonToken = this.eatExplicitOrAutomaticSemicolon(false); - - return this.factory.variableStatement(modifiers, variableDeclaration, semicolonToken); - }; - - ParserImpl.prototype.parseVariableDeclaration = function (allowIn) { - var varKeyword = this.eatKeyword(40 /* VarKeyword */); - - var listParsingState = allowIn ? 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */; - - var result = this.parseSeparatedSyntaxList(listParsingState); - var variableDeclarators = result.list; - varKeyword = this.addSkippedTokensAfterToken(varKeyword, result.skippedTokens); - - return this.factory.variableDeclaration(varKeyword, variableDeclarators); - }; - - ParserImpl.prototype.isVariableDeclarator = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 225 /* VariableDeclarator */) { - return true; - } - - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.canReuseVariableDeclaratorNode = function (node) { - if (node === null || node.kind() !== 225 /* VariableDeclarator */) { - return false; - } - - var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; - }; - - ParserImpl.prototype.parseVariableDeclarator = function (allowIn, allowPropertyName) { - if (this.canReuseVariableDeclaratorNode(this.currentNode())) { - return this.eatNode(); - } - - var propertyName = allowPropertyName ? this.eatPropertyName() : this.eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; - - if (propertyName.width() > 0) { - typeAnnotation = this.parseOptionalTypeAnnotation(false); - - if (this.isEqualsValueClause(false)) { - equalsValueClause = this.parseEqualsValueClause(allowIn); - } - } - - return this.factory.variableDeclarator(propertyName, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.isColonValueClause = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.isEqualsValueClause = function (inParameter) { - var token0 = this.currentToken(); - if (token0.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (!this.previousToken().hasTrailingNewLine()) { - if (token0.tokenKind === 85 /* EqualsGreaterThanToken */) { - return false; - } - - if (token0.tokenKind === 70 /* OpenBraceToken */ && inParameter) { - return false; - } - - return this.isExpression(token0); - } - - return false; - }; - - ParserImpl.prototype.parseEqualsValueClause = function (allowIn) { - var equalsToken = this.eatToken(107 /* EqualsToken */); - var value = this.parseAssignmentExpression(allowIn); - - return this.factory.equalsValueClause(equalsToken, value); - }; - - ParserImpl.prototype.parseExpression = function (allowIn) { - return this.parseSubExpression(0, allowIn); - }; - - ParserImpl.prototype.parseAssignmentExpression = function (allowIn) { - return this.parseSubExpression(2 /* AssignmentExpressionPrecedence */, allowIn); - }; - - ParserImpl.prototype.parseUnaryExpressionOrLower = function () { - var currentTokenKind = this.currentToken().tokenKind; - if (TypeScript.SyntaxFacts.isPrefixUnaryExpressionOperatorToken(currentTokenKind)) { - var operatorKind = TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(currentTokenKind); - - var operatorToken = this.eatAnyToken(); - - var operand = this.parseUnaryExpressionOrLower(); - return this.factory.prefixUnaryExpression(operatorKind, operatorToken, operand); - } else if (currentTokenKind === 39 /* TypeOfKeyword */) { - return this.parseTypeOfExpression(); - } else if (currentTokenKind === 41 /* VoidKeyword */) { - return this.parseVoidExpression(); - } else if (currentTokenKind === 21 /* DeleteKeyword */) { - return this.parseDeleteExpression(); - } else if (currentTokenKind === 80 /* LessThanToken */) { - return this.parseCastExpression(); - } else { - return this.parsePostfixExpressionOrLower(); - } - }; - - ParserImpl.prototype.parseSubExpression = function (precedence, allowIn) { - if (precedence <= 2 /* AssignmentExpressionPrecedence */) { - if (this.isSimpleArrowFunctionExpression()) { - return this.parseSimpleArrowFunctionExpression(); - } - - var parethesizedArrowFunction = this.tryParseParenthesizedArrowFunctionExpression(); - if (parethesizedArrowFunction !== null) { - return parethesizedArrowFunction; - } - } - - var leftOperand = this.parseUnaryExpressionOrLower(); - return this.parseBinaryOrConditionalExpressions(precedence, allowIn, leftOperand); - }; - - ParserImpl.prototype.parseBinaryOrConditionalExpressions = function (precedence, allowIn, leftOperand) { - while (true) { - var token0 = this.currentToken(); - var token0Kind = token0.tokenKind; - - if (TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(token0Kind)) { - if (token0Kind === 29 /* InKeyword */ && !allowIn) { - break; - } - - var mergedToken = this.tryMergeBinaryExpressionTokens(); - var tokenKind = mergedToken === null ? token0Kind : mergedToken.syntaxKind; - - var binaryExpressionKind = TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(tokenKind); - var newPrecedence = ParserImpl.getPrecedence(binaryExpressionKind); - - if (newPrecedence < precedence) { - break; - } - - if (newPrecedence === precedence && !this.isRightAssociative(binaryExpressionKind)) { - break; - } - - var operatorToken = mergedToken === null ? token0 : TypeScript.Syntax.token(mergedToken.syntaxKind).withLeadingTrivia(token0.leadingTrivia()).withTrailingTrivia(this.peekToken(mergedToken.tokenCount - 1).trailingTrivia()); - - var skipCount = mergedToken === null ? 1 : mergedToken.tokenCount; - for (var i = 0; i < skipCount; i++) { - this.eatAnyToken(); - } - - leftOperand = this.factory.binaryExpression(binaryExpressionKind, leftOperand, operatorToken, this.parseSubExpression(newPrecedence, allowIn)); - continue; - } - - if (token0Kind === 105 /* QuestionToken */ && precedence <= 3 /* ConditionalExpressionPrecedence */) { - var questionToken = this.eatToken(105 /* QuestionToken */); - - var whenTrueExpression = this.parseAssignmentExpression(allowIn); - var colon = this.eatToken(106 /* ColonToken */); - - var whenFalseExpression = this.parseAssignmentExpression(allowIn); - leftOperand = this.factory.conditionalExpression(leftOperand, questionToken, whenTrueExpression, colon, whenFalseExpression); - continue; - } - - break; - } - - return leftOperand; - }; - - ParserImpl.prototype.tryMergeBinaryExpressionTokens = function () { - var token0 = this.currentToken(); - - if (token0.tokenKind === 81 /* GreaterThanToken */ && !token0.hasTrailingTrivia()) { - var storage = this.mergeTokensStorage; - storage[0] = 0 /* None */; - storage[1] = 0 /* None */; - storage[2] = 0 /* None */; - - for (var i = 0; i < storage.length; i++) { - var nextToken = this.peekToken(i + 1); - - if (!nextToken.hasLeadingTrivia()) { - storage[i] = nextToken.tokenKind; - } - - if (nextToken.hasTrailingTrivia()) { - break; - } - } - - if (storage[0] === 81 /* GreaterThanToken */) { - if (storage[1] === 81 /* GreaterThanToken */) { - if (storage[2] === 107 /* EqualsToken */) { - return { tokenCount: 4, syntaxKind: 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 3, syntaxKind: 97 /* GreaterThanGreaterThanGreaterThanToken */ }; - } - } else if (storage[1] === 107 /* EqualsToken */) { - return { tokenCount: 3, syntaxKind: 113 /* GreaterThanGreaterThanEqualsToken */ }; - } else { - return { tokenCount: 2, syntaxKind: 96 /* GreaterThanGreaterThanToken */ }; - } - } else if (storage[0] === 107 /* EqualsToken */) { - return { tokenCount: 2, syntaxKind: 83 /* GreaterThanEqualsToken */ }; - } - } - - return null; - }; - - ParserImpl.prototype.isRightAssociative = function (expressionKind) { - switch (expressionKind) { - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - return true; - default: - return false; - } - }; - - ParserImpl.prototype.parseMemberExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } - - var expression = this.parsePrimaryExpression(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - return this.parseMemberExpressionRest(expression, false, inObjectCreation); - }; - - ParserImpl.prototype.parseCallExpressionOrLower = function () { - var expression; - if (this.currentToken().tokenKind === 50 /* SuperKeyword */) { - expression = this.eatKeyword(50 /* SuperKeyword */); - - var currentTokenKind = this.currentToken().tokenKind; - if (currentTokenKind !== 72 /* OpenParenToken */ && currentTokenKind !== 76 /* DotToken */) { - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - } - } else { - expression = this.parseMemberExpressionOrLower(false); - } - - return this.parseMemberExpressionRest(expression, true, false); - }; - - ParserImpl.prototype.parseMemberExpressionRest = function (expression, allowArguments, inObjectCreation) { - while (true) { - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 72 /* OpenParenToken */: - if (!allowArguments) { - return expression; - } - - expression = this.factory.invocationExpression(expression, this.parseArgumentList(null)); - continue; - - case 80 /* LessThanToken */: - if (!allowArguments) { - return expression; - } - - var argumentList = this.tryParseArgumentList(); - if (argumentList !== null) { - expression = this.factory.invocationExpression(expression, argumentList); - continue; - } - - break; - - case 74 /* OpenBracketToken */: - expression = this.parseElementAccessExpression(expression, inObjectCreation); - continue; - - case 76 /* DotToken */: - expression = this.factory.memberAccessExpression(expression, this.eatToken(76 /* DotToken */), this.eatIdentifierNameToken()); - continue; - } - - return expression; - } - }; - - ParserImpl.prototype.parseLeftHandSideExpressionOrLower = function () { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseCallExpressionOrLower(); - } - }; - - ParserImpl.prototype.parsePostfixExpressionOrLower = function () { - var expression = this.parseLeftHandSideExpressionOrLower(); - if (expression === null) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = this.currentToken().tokenKind; - - switch (currentTokenKind) { - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - if (this.previousToken() !== null && this.previousToken().hasTrailingNewLine()) { - break; - } - - return this.factory.postfixUnaryExpression(TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(currentTokenKind), expression, this.eatAnyToken()); - } - - return expression; - }; - - ParserImpl.prototype.tryParseGenericArgumentList = function () { - var rewindPoint = this.getRewindPoint(); - - var typeArgumentList = this.tryParseTypeArgumentList(true); - var token0 = this.currentToken(); - - var isOpenParen = token0.tokenKind === 72 /* OpenParenToken */; - var isDot = token0.tokenKind === 76 /* DotToken */; - var isOpenParenOrDot = isOpenParen || isDot; - - var argumentList = null; - if (typeArgumentList === null || !isOpenParenOrDot) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - - if (isDot) { - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token0.width(), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); - this.addDiagnostic(diagnostic); - - return this.factory.argumentList(typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList, TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); - } else { - return this.parseArgumentList(typeArgumentList); - } - } - }; - - ParserImpl.prototype.tryParseArgumentList = function () { - if (this.currentToken().tokenKind === 80 /* LessThanToken */) { - return this.tryParseGenericArgumentList(); - } - - if (this.currentToken().tokenKind === 72 /* OpenParenToken */) { - return this.parseArgumentList(null); - } - - return null; - }; - - ParserImpl.prototype.parseArgumentList = function (typeArgumentList) { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - - var _arguments = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.fullWidth() > 0) { - var result = this.parseSeparatedSyntaxList(16384 /* ArgumentList_AssignmentExpressions */); - _arguments = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.argumentList(typeArgumentList, openParenToken, _arguments, closeParenToken); - }; - - ParserImpl.prototype.parseElementAccessExpression = function (expression, inObjectCreation) { - var start = this.currentTokenStart(); - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var argumentExpression; - - if (this.currentToken().tokenKind === 75 /* CloseBracketToken */ && inObjectCreation) { - var end = this.currentTokenStart() + this.currentToken().width(); - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, start, end - start, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); - this.addDiagnostic(diagnostic); - - argumentExpression = TypeScript.Syntax.emptyToken(11 /* IdentifierName */); - } else { - argumentExpression = this.parseExpression(true); - } - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.elementAccessExpression(expression, openBracketToken, argumentExpression, closeBracketToken); - }; - - ParserImpl.prototype.parsePrimaryExpression = function () { - var currentToken = this.currentToken(); - - if (this.isIdentifier(currentToken)) { - return this.eatIdentifierToken(); - } - - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 35 /* ThisKeyword */: - return this.parseThisExpression(); - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.parseLiteralExpression(); - - case 32 /* NullKeyword */: - return this.parseLiteralExpression(); - - case 27 /* FunctionKeyword */: - return this.parseFunctionExpression(); - - case 13 /* NumericLiteral */: - return this.parseLiteralExpression(); - - case 12 /* RegularExpressionLiteral */: - return this.parseLiteralExpression(); - - case 14 /* StringLiteral */: - return this.parseLiteralExpression(); - - case 74 /* OpenBracketToken */: - return this.parseArrayLiteralExpression(); - - case 70 /* OpenBraceToken */: - return this.parseObjectLiteralExpression(); - - case 72 /* OpenParenToken */: - return this.parseParenthesizedExpression(); - - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - var result = this.tryReparseDivideAsRegularExpression(); - if (result !== null) { - return result; - } - break; - } - - return null; - }; - - ParserImpl.prototype.tryReparseDivideAsRegularExpression = function () { - var currentToken = this.currentToken(); - - if (this.previousToken() !== null) { - var previousTokenKind = this.previousToken().tokenKind; - switch (previousTokenKind) { - case 11 /* IdentifierName */: - return null; - - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return null; - - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 75 /* CloseBracketToken */: - return null; - } - } - - currentToken = this.currentTokenAllowingRegularExpression(); - - if (currentToken.tokenKind === 118 /* SlashToken */ || currentToken.tokenKind === 119 /* SlashEqualsToken */) { - return null; - } else if (currentToken.tokenKind === 12 /* RegularExpressionLiteral */) { - return this.parseLiteralExpression(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.parseTypeOfExpression = function () { - var typeOfKeyword = this.eatKeyword(39 /* TypeOfKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.typeOfExpression(typeOfKeyword, expression); - }; - - ParserImpl.prototype.parseDeleteExpression = function () { - var deleteKeyword = this.eatKeyword(21 /* DeleteKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.deleteExpression(deleteKeyword, expression); - }; - - ParserImpl.prototype.parseVoidExpression = function () { - var voidKeyword = this.eatKeyword(41 /* VoidKeyword */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.voidExpression(voidKeyword, expression); - }; - - ParserImpl.prototype.parseFunctionExpression = function () { - var functionKeyword = this.eatKeyword(27 /* FunctionKeyword */); - var identifier = null; - - if (this.isIdentifier(this.currentToken())) { - identifier = this.eatIdentifierToken(); - } - - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionExpression(functionKeyword, identifier, callSignature, block); - }; - - ParserImpl.prototype.parseObjectCreationExpression = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - - var expression = this.parseObjectCreationExpressionOrLower(true); - var argumentList = this.tryParseArgumentList(); - - var result = this.factory.objectCreationExpression(newKeyword, expression, argumentList); - return this.parseMemberExpressionRest(result, true, false); - }; - - ParserImpl.prototype.parseObjectCreationExpressionOrLower = function (inObjectCreation) { - if (this.currentToken().tokenKind === 31 /* NewKeyword */) { - return this.parseObjectCreationExpression(); - } else { - return this.parseMemberExpressionOrLower(inObjectCreation); - } - }; - - ParserImpl.prototype.parseCastExpression = function () { - var lessThanToken = this.eatToken(80 /* LessThanToken */); - var type = this.parseType(); - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - var expression = this.parseUnaryExpressionOrLower(); - - return this.factory.castExpression(lessThanToken, type, greaterThanToken, expression); - }; - - ParserImpl.prototype.parseParenthesizedExpression = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var expression = this.parseExpression(true); - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - - return this.factory.parenthesizedExpression(openParenToken, expression, closeParenToken); - }; - - ParserImpl.prototype.tryParseParenthesizedArrowFunctionExpression = function () { - var tokenKind = this.currentToken().tokenKind; - if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { - return null; - } - - if (this.isDefinitelyArrowFunctionExpression()) { - return this.parseParenthesizedArrowFunctionExpression(false); - } - - if (!this.isPossiblyArrowFunctionExpression()) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var arrowFunction = this.parseParenthesizedArrowFunctionExpression(true); - if (arrowFunction === null) { - this.rewind(rewindPoint); - } - - this.releaseRewindPoint(rewindPoint); - return arrowFunction; - }; - - ParserImpl.prototype.parseParenthesizedArrowFunctionExpression = function (requireArrow) { - var currentToken = this.currentToken(); - - var callSignature = this.parseCallSignature(true); - - if (requireArrow && this.currentToken().tokenKind !== 85 /* EqualsGreaterThanToken */) { - return null; - } - - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.parenthesizedArrowFunctionExpression(callSignature, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.tryParseArrowFunctionBlock = function () { - if (this.isBlock()) { - return this.parseBlock(false, false); - } else { - if (this.isStatement(false) && !this.isExpressionStatement(this.currentToken()) && !this.isFunctionDeclaration()) { - return this.parseBlock(true, false); - } else { - return null; - } - } - }; - - ParserImpl.prototype.isSimpleArrowFunctionExpression = function () { - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.isIdentifier(this.currentToken()) && this.peekToken(1).tokenKind === 85 /* EqualsGreaterThanToken */; - }; - - ParserImpl.prototype.parseSimpleArrowFunctionExpression = function () { - var identifier = this.eatIdentifierToken(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - - var block = this.tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { - expression = this.parseAssignmentExpression(true); - } - - return this.factory.simpleArrowFunctionExpression(identifier, equalsGreaterThanToken, block, expression); - }; - - ParserImpl.prototype.isBlock = function () { - return this.currentToken().tokenKind === 70 /* OpenBraceToken */; - }; - - ParserImpl.prototype.isDefinitelyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return false; - } - - var token1 = this.peekToken(1); - var token2; - - if (token1.tokenKind === 73 /* CloseParenToken */) { - token2 = this.peekToken(2); - return token2.tokenKind === 106 /* ColonToken */ || token2.tokenKind === 85 /* EqualsGreaterThanToken */ || token2.tokenKind === 70 /* OpenBraceToken */; - } - - if (token1.tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - token2 = this.peekToken(2); - if (token1.tokenKind === 57 /* PublicKeyword */ || token1.tokenKind === 55 /* PrivateKeyword */) { - if (this.isIdentifier(token2)) { - return true; - } - } - - if (!this.isIdentifier(token1)) { - return false; - } - - if (token2.tokenKind === 106 /* ColonToken */) { - return true; - } - - var token3 = this.peekToken(3); - if (token2.tokenKind === 105 /* QuestionToken */) { - if (token3.tokenKind === 106 /* ColonToken */ || token3.tokenKind === 73 /* CloseParenToken */ || token3.tokenKind === 79 /* CommaToken */) { - return true; - } - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - if (token3.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.isPossiblyArrowFunctionExpression = function () { - var token0 = this.currentToken(); - if (token0.tokenKind !== 72 /* OpenParenToken */) { - return true; - } - - var token1 = this.peekToken(1); - - if (!this.isIdentifier(token1)) { - return false; - } - - var token2 = this.peekToken(2); - if (token2.tokenKind === 107 /* EqualsToken */) { - return true; - } - - if (token2.tokenKind === 79 /* CommaToken */) { - return true; - } - - if (token2.tokenKind === 73 /* CloseParenToken */) { - var token3 = this.peekToken(3); - if (token3.tokenKind === 106 /* ColonToken */) { - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseObjectLiteralExpression = function () { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var result = this.parseSeparatedSyntaxList(32768 /* ObjectLiteralExpression_PropertyAssignments */); - var propertyAssignments = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.objectLiteralExpression(openBraceToken, propertyAssignments, closeBraceToken); - }; - - ParserImpl.prototype.parsePropertyAssignment = function (inErrorRecovery) { - if (this.isAccessor(inErrorRecovery)) { - return this.parseAccessor(true); - } else if (this.isFunctionPropertyAssignment(inErrorRecovery)) { - return this.parseFunctionPropertyAssignment(); - } else if (this.isSimplePropertyAssignment(inErrorRecovery)) { - return this.parseSimplePropertyAssignment(); - } else { - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isPropertyAssignment = function (inErrorRecovery) { - return this.isAccessor(inErrorRecovery) || this.isFunctionPropertyAssignment(inErrorRecovery) || this.isSimplePropertyAssignment(inErrorRecovery); - }; - - ParserImpl.prototype.eatPropertyName = function () { - return TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(this.currentToken()) ? this.eatIdentifierNameToken() : this.eatAnyToken(); - }; - - ParserImpl.prototype.isFunctionPropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery) && this.isCallSignature(1); - }; - - ParserImpl.prototype.parseFunctionPropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var callSignature = this.parseCallSignature(false); - var block = this.parseBlock(false, true); - - return this.factory.functionPropertyAssignment(propertyName, callSignature, block); - }; - - ParserImpl.prototype.isSimplePropertyAssignment = function (inErrorRecovery) { - return this.isPropertyName(this.currentToken(), inErrorRecovery); - }; - - ParserImpl.prototype.parseSimplePropertyAssignment = function () { - var propertyName = this.eatPropertyName(); - var colonToken = this.eatToken(106 /* ColonToken */); - var expression = this.parseAssignmentExpression(true); - - return this.factory.simplePropertyAssignment(propertyName, colonToken, expression); - }; - - ParserImpl.prototype.isPropertyName = function (token, inErrorRecovery) { - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - if (inErrorRecovery) { - return this.isIdentifier(token); - } else { - return true; - } - } - - switch (token.tokenKind) { - case 14 /* StringLiteral */: - case 13 /* NumericLiteral */: - return true; - - default: - return false; - } - }; - - ParserImpl.prototype.parseArrayLiteralExpression = function () { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - - var result = this.parseSeparatedSyntaxList(65536 /* ArrayLiteralExpression_AssignmentExpressions */); - var expressions = result.list; - openBracketToken = this.addSkippedTokensAfterToken(openBracketToken, result.skippedTokens); - - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - return this.factory.arrayLiteralExpression(openBracketToken, expressions, closeBracketToken); - }; - - ParserImpl.prototype.parseLiteralExpression = function () { - return this.eatAnyToken(); - }; - - ParserImpl.prototype.parseThisExpression = function () { - return this.eatKeyword(35 /* ThisKeyword */); - }; - - ParserImpl.prototype.parseBlock = function (parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = this.eatToken(70 /* OpenBraceToken */); - - var statements = TypeScript.Syntax.emptyList; - - if (parseBlockEvenWithNoOpenBrace || openBraceToken.width() > 0) { - var savedIsInStrictMode = this.isInStrictMode; - - var processItems = checkForStrictMode ? ParserImpl.updateStrictModeState : null; - var result = this.parseSyntaxList(32 /* Block_Statements */, processItems); - statements = result.list; - openBraceToken = this.addSkippedTokensAfterToken(openBraceToken, result.skippedTokens); - - this.setStrictMode(savedIsInStrictMode); - } - - var closeBraceToken = this.eatToken(71 /* CloseBraceToken */); - - return this.factory.block(openBraceToken, statements, closeBraceToken); - }; - - ParserImpl.prototype.parseCallSignature = function (requireCompleteTypeParameterList) { - var typeParameterList = this.parseOptionalTypeParameterList(requireCompleteTypeParameterList); - var parameterList = this.parseParameterList(); - var typeAnnotation = this.parseOptionalTypeAnnotation(false); - - return this.factory.callSignature(typeParameterList, parameterList, typeAnnotation); - }; - - ParserImpl.prototype.parseOptionalTypeParameterList = function (requireCompleteTypeParameterList) { - if (this.currentToken().tokenKind !== 80 /* LessThanToken */) { - return null; - } - - var rewindPoint = this.getRewindPoint(); - - var lessThanToken = this.eatToken(80 /* LessThanToken */); - - var result = this.parseSeparatedSyntaxList(524288 /* TypeParameterList_TypeParameters */); - var typeParameters = result.list; - lessThanToken = this.addSkippedTokensAfterToken(lessThanToken, result.skippedTokens); - - var greaterThanToken = this.eatToken(81 /* GreaterThanToken */); - - if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { - this.rewind(rewindPoint); - this.releaseRewindPoint(rewindPoint); - return null; - } else { - this.releaseRewindPoint(rewindPoint); - var typeParameterList = this.factory.typeParameterList(lessThanToken, typeParameters, greaterThanToken); - - return typeParameterList; - } - }; - - ParserImpl.prototype.isTypeParameter = function () { - return this.isIdentifier(this.currentToken()); - }; - - ParserImpl.prototype.parseTypeParameter = function () { - var identifier = this.eatIdentifierToken(); - var constraint = this.parseOptionalConstraint(); - - return this.factory.typeParameter(identifier, constraint); - }; - - ParserImpl.prototype.parseOptionalConstraint = function () { - if (this.currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; - } - - var extendsKeyword = this.eatKeyword(48 /* ExtendsKeyword */); - var type = this.parseType(); - - return this.factory.constraint(extendsKeyword, type); - }; - - ParserImpl.prototype.parseParameterList = function () { - var openParenToken = this.eatToken(72 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList; - - if (openParenToken.width() > 0) { - var result = this.parseSeparatedSyntaxList(131072 /* ParameterList_Parameters */); - parameters = result.list; - openParenToken = this.addSkippedTokensAfterToken(openParenToken, result.skippedTokens); - } - - var closeParenToken = this.eatToken(73 /* CloseParenToken */); - return this.factory.parameterList(openParenToken, parameters, closeParenToken); - }; - - ParserImpl.prototype.isTypeAnnotation = function () { - return this.currentToken().tokenKind === 106 /* ColonToken */; - }; - - ParserImpl.prototype.parseOptionalTypeAnnotation = function (allowStringLiteral) { - return this.isTypeAnnotation() ? this.parseTypeAnnotation(allowStringLiteral) : null; - }; - - ParserImpl.prototype.parseTypeAnnotation = function (allowStringLiteral) { - var colonToken = this.eatToken(106 /* ColonToken */); - var type = allowStringLiteral && this.currentToken().tokenKind === 14 /* StringLiteral */ ? this.eatToken(14 /* StringLiteral */) : this.parseType(); - - return this.factory.typeAnnotation(colonToken, type); - }; - - ParserImpl.prototype.isType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - switch (currentTokenKind) { - case 39 /* TypeOfKeyword */: - - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - - case 70 /* OpenBraceToken */: - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - - case 31 /* NewKeyword */: - return true; - } - - return this.isIdentifier(currentToken); - }; - - ParserImpl.prototype.parseType = function () { - var currentToken = this.currentToken(); - var currentTokenKind = currentToken.tokenKind; - - var type = this.parseNonArrayType(currentToken); - - while (this.currentToken().tokenKind === 74 /* OpenBracketToken */) { - var openBracketToken = this.eatToken(74 /* OpenBracketToken */); - var closeBracketToken = this.eatToken(75 /* CloseBracketToken */); - - type = this.factory.arrayType(type, openBracketToken, closeBracketToken); - } - - return type; - }; - - ParserImpl.prototype.isTypeQuery = function () { - return this.currentToken().tokenKind === 39 /* TypeOfKeyword */; - }; - - ParserImpl.prototype.parseTypeQuery = function () { - var typeOfKeyword = this.eatToken(39 /* TypeOfKeyword */); - var name = this.parseName(); - - return this.factory.typeQuery(typeOfKeyword, name); - }; - - ParserImpl.prototype.parseNonArrayType = function (currentToken) { - var currentTokenKind = currentToken.tokenKind; - switch (currentTokenKind) { - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - return this.eatAnyToken(); - - case 70 /* OpenBraceToken */: - return this.parseObjectType(); - - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - return this.parseFunctionType(); - - case 31 /* NewKeyword */: - return this.parseConstructorType(); - - case 39 /* TypeOfKeyword */: - return this.parseTypeQuery(); - } - - return this.parseNameOrGenericType(); - }; - - ParserImpl.prototype.parseNameOrGenericType = function () { - var name = this.parseName(); - var typeArgumentList = this.tryParseTypeArgumentList(false); - - return typeArgumentList === null ? name : this.factory.genericType(name, typeArgumentList); - }; - - ParserImpl.prototype.parseFunctionType = function () { - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var returnType = this.parseType(); - - return this.factory.functionType(typeParameterList, parameterList, equalsGreaterThanToken, returnType); - }; - - ParserImpl.prototype.parseConstructorType = function () { - var newKeyword = this.eatKeyword(31 /* NewKeyword */); - var typeParameterList = this.parseOptionalTypeParameterList(false); - var parameterList = this.parseParameterList(); - var equalsGreaterThanToken = this.eatToken(85 /* EqualsGreaterThanToken */); - var type = this.parseType(); - - return this.factory.constructorType(newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type); - }; - - ParserImpl.prototype.isParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return true; - } - - var token = this.currentToken(); - var tokenKind = token.tokenKind; - if (tokenKind === 77 /* DotDotDotToken */) { - return true; - } - - if (ParserImpl.isModifier(token) && !this.isModifierUsedAsParameterIdentifier(token)) { - return true; - } - - return this.isIdentifier(token); - }; - - ParserImpl.prototype.isModifierUsedAsParameterIdentifier = function (token) { - if (this.isIdentifier(token)) { - var nextTokenKind = this.peekToken(1).tokenKind; - switch (nextTokenKind) { - case 73 /* CloseParenToken */: - case 106 /* ColonToken */: - case 107 /* EqualsToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - return true; - } - } - - return false; - }; - - ParserImpl.prototype.parseParameter = function () { - if (this.currentNode() !== null && this.currentNode().kind() === 242 /* Parameter */) { - return this.eatNode(); - } - - var dotDotDotToken = this.tryEatToken(77 /* DotDotDotToken */); - - var modifierArray = this.getArray(); - - while (true) { - var currentToken = this.currentToken(); - if (ParserImpl.isModifier(currentToken) && !this.isModifierUsedAsParameterIdentifier(currentToken)) { - modifierArray.push(this.eatAnyToken()); - continue; - } - - break; - } - - var modifiers = TypeScript.Syntax.list(modifierArray); - this.returnZeroOrOneLengthArray(modifierArray); - - var identifier = this.eatIdentifierToken(); - var questionToken = this.tryEatToken(105 /* QuestionToken */); - var typeAnnotation = this.parseOptionalTypeAnnotation(true); - - var equalsValueClause = null; - if (this.isEqualsValueClause(true)) { - equalsValueClause = this.parseEqualsValueClause(true); - } - - return this.factory.parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); - }; - - ParserImpl.prototype.parseSyntaxList = function (currentListType, processItems) { - if (typeof processItems === "undefined") { processItems = null; } - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSyntaxListWorker(currentListType, processItems); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.parseSeparatedSyntaxList = function (currentListType) { - var savedListParsingState = this.listParsingState; - this.listParsingState |= currentListType; - - var result = this.parseSeparatedSyntaxListWorker(currentListType); - - this.listParsingState = savedListParsingState; - - return result; - }; - - ParserImpl.prototype.abortParsingListOrMoveToNextToken = function (currentListType, items, skippedTokens) { - this.reportUnexpectedTokenDiagnostic(currentListType); - - 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; - } - } - } - - var skippedToken = this.currentToken(); - - this.moveToNextToken(); - - this.addSkippedTokenToList(items, skippedTokens, skippedToken); - - return false; - }; - - ParserImpl.prototype.addSkippedTokenToList = function (items, skippedTokens, skippedToken) { - for (var i = items.length - 1; i >= 0; i--) { - var item = items[i]; - var lastToken = item.lastToken(); - if (lastToken.fullWidth() > 0) { - items[i] = this.addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } - } - - skippedTokens.push(skippedToken); - }; - - ParserImpl.prototype.tryParseExpectedListItem = function (currentListType, inErrorRecovery, items, processItems) { - if (this.isExpectedListItem(currentListType, inErrorRecovery)) { - var item = this.parseExpectedListItem(currentListType, inErrorRecovery); - - items.push(item); - - if (processItems !== null) { - processItems(this, items); - } - } - }; - - ParserImpl.prototype.listIsTerminated = function (currentListType) { - return this.isExpectedListTerminator(currentListType) || this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.getArray = function () { - if (this.arrayPool.length > 0) { - return this.arrayPool.pop(); - } - - return []; - }; - - ParserImpl.prototype.returnZeroOrOneLengthArray = function (array) { - if (array.length <= 1) { - this.returnArray(array); - } - }; - - ParserImpl.prototype.returnArray = function (array) { - array.length = 0; - this.arrayPool.push(array); - }; - - ParserImpl.prototype.parseSyntaxListWorker = function (currentListType, processItems) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - - while (true) { - var oldItemsCount = items.length; - this.tryParseExpectedListItem(currentListType, false, items, processItems); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } - } - } - - var result = TypeScript.Syntax.list(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.parseSeparatedSyntaxListWorker = function (currentListType) { - var items = this.getArray(); - var skippedTokens = this.getArray(); - TypeScript.Debug.assert(items.length === 0); - TypeScript.Debug.assert(skippedTokens.length === 0); - TypeScript.Debug.assert(skippedTokens !== items); - - var separatorKind = this.separatorKind(currentListType); - var allowAutomaticSemicolonInsertion = separatorKind === 78 /* SemicolonToken */; - - var inErrorRecovery = false; - var listWasTerminated = false; - while (true) { - var oldItemsCount = items.length; - - this.tryParseExpectedListItem(currentListType, inErrorRecovery, items, null); - - var newItemsCount = items.length; - if (newItemsCount === oldItemsCount) { - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - var abort = this.abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); - if (abort) { - break; - } else { - inErrorRecovery = true; - continue; - } - } - - inErrorRecovery = false; - - var currentToken = this.currentToken(); - if (currentToken.tokenKind === separatorKind || currentToken.tokenKind === 79 /* CommaToken */) { - items.push(this.eatAnyToken()); - continue; - } - - if (this.listIsTerminated(currentListType)) { - listWasTerminated = true; - break; - } - - if (allowAutomaticSemicolonInsertion && this.canEatAutomaticSemicolon(false)) { - items.push(this.eatExplicitOrAutomaticSemicolon(false)); - - continue; - } - - items.push(this.eatToken(separatorKind)); - - inErrorRecovery = true; - } - - var result = TypeScript.Syntax.separatedList(items); - - this.returnZeroOrOneLengthArray(items); - - return { skippedTokens: skippedTokens, list: result }; - }; - - ParserImpl.prototype.separatorKind = function (currentListType) { - switch (currentListType) { - case 2048 /* HeritageClause_TypeNameList */: - case 16384 /* ArgumentList_AssignmentExpressions */: - case 256 /* EnumDeclaration_EnumElements */: - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - case 131072 /* ParameterList_Parameters */: - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - case 262144 /* TypeArgumentList_Types */: - case 524288 /* TypeParameterList_TypeParameters */: - return 79 /* CommaToken */; - - case 512 /* ObjectType_TypeMembers */: - return 78 /* SemicolonToken */; - - case 1 /* SourceUnit_ModuleElements */: - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - case 2 /* ClassDeclaration_ClassElements */: - case 4 /* ModuleDeclaration_ModuleElements */: - case 8 /* SwitchStatement_SwitchClauses */: - case 16 /* SwitchClause_Statements */: - case 32 /* Block_Statements */: - default: - throw TypeScript.Errors.notYetImplemented(); - } - }; - - ParserImpl.prototype.reportUnexpectedTokenDiagnostic = function (listType) { - var token = this.currentToken(); - - var diagnostic = new TypeScript.Diagnostic(this.fileName, this.lineMap, this.currentTokenStart(), token.width(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [this.getExpectedListElementType(listType)]); - this.addDiagnostic(diagnostic); - }; - - ParserImpl.prototype.addDiagnostic = function (diagnostic) { - if (this.diagnostics.length > 0 && this.diagnostics[this.diagnostics.length - 1].start() === diagnostic.start()) { - return; - } - - this.diagnostics.push(diagnostic); - }; - - ParserImpl.prototype.isExpectedListTerminator = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isExpectedSourceUnit_ModuleElementsTerminator(); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isExpectedClassDeclaration_ClassElementsTerminator(); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isExpectedModuleDeclaration_ModuleElementsTerminator(); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isExpectedSwitchStatement_SwitchClausesTerminator(); - - case 16 /* SwitchClause_Statements */: - return this.isExpectedSwitchClause_StatementsTerminator(); - - case 32 /* Block_Statements */: - return this.isExpectedBlock_StatementsTerminator(); - - case 64 /* TryBlock_Statements */: - return this.isExpectedTryBlock_StatementsTerminator(); - - case 128 /* CatchBlock_Statements */: - return this.isExpectedCatchBlock_StatementsTerminator(); - - case 256 /* EnumDeclaration_EnumElements */: - return this.isExpectedEnumDeclaration_EnumElementsTerminator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isExpectedObjectType_TypeMembersTerminator(); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpressionsTerminator(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isExpectedHeritageClause_TypeNameListTerminator(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - - case 131072 /* ParameterList_Parameters */: - return this.isExpectedParameterList_ParametersTerminator(); - - case 262144 /* TypeArgumentList_Types */: - return this.isExpectedTypeArgumentList_TypesTerminator(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isExpectedTypeParameterList_TypeParametersTerminator(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedSourceUnit_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 10 /* EndOfFileToken */; - }; - - ParserImpl.prototype.isExpectedEnumDeclaration_EnumElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedModuleDeclaration_ModuleElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectType_TypeMembersTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedLiteralExpression_AssignmentExpressionsTerminator = function () { - return this.currentToken().tokenKind === 75 /* CloseBracketToken */; - }; - - ParserImpl.prototype.isExpectedTypeArgumentList_TypesTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (this.canFollowTypeArgumentListInExpression(token.tokenKind)) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedTypeParameterList_TypeParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 81 /* GreaterThanToken */) { - return true; - } - - if (token.tokenKind === 72 /* OpenParenToken */ || token.tokenKind === 70 /* OpenBraceToken */ || token.tokenKind === 48 /* ExtendsKeyword */ || token.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedParameterList_ParametersTerminator = function () { - var token = this.currentToken(); - if (token.tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (token.tokenKind === 70 /* OpenBraceToken */) { - return true; - } - - if (token.tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator = function () { - if (this.currentToken().tokenKind === 78 /* SemicolonToken */ || this.currentToken().tokenKind === 73 /* CloseParenToken */) { - return true; - } - - if (this.currentToken().tokenKind === 29 /* InKeyword */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator = function () { - if (this.previousToken().tokenKind === 79 /* CommaToken */) { - return false; - } - - if (this.currentToken().tokenKind === 85 /* EqualsGreaterThanToken */) { - return true; - } - - return this.canEatExplicitOrAutomaticSemicolon(false); - }; - - ParserImpl.prototype.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 70 /* OpenBraceToken */ || token0.tokenKind === 71 /* CloseBraceToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedHeritageClause_TypeNameListTerminator = function () { - var token0 = this.currentToken(); - if (token0.tokenKind === 48 /* ExtendsKeyword */ || token0.tokenKind === 51 /* ImplementsKeyword */) { - return true; - } - - if (this.isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { - return true; - } - - return false; - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpressionsTerminator = function () { - var token0 = this.currentToken(); - return token0.tokenKind === 73 /* CloseParenToken */ || token0.tokenKind === 78 /* SemicolonToken */; - }; - - ParserImpl.prototype.isExpectedClassDeclaration_ClassElementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchStatement_SwitchClausesTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedSwitchClause_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */ || this.isSwitchClause(); - }; - - ParserImpl.prototype.isExpectedBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 71 /* CloseBraceToken */; - }; - - ParserImpl.prototype.isExpectedTryBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 17 /* CatchKeyword */ || this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedCatchBlock_StatementsTerminator = function () { - return this.currentToken().tokenKind === 25 /* FinallyKeyword */; - }; - - ParserImpl.prototype.isExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.isHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.isClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.isModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.isSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.isStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.isStatement(inErrorRecovery); - - case 64 /* TryBlock_Statements */: - case 128 /* CatchBlock_Statements */: - return false; - - case 256 /* EnumDeclaration_EnumElements */: - return this.isEnumElement(inErrorRecovery); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.isVariableDeclarator(); - - case 512 /* ObjectType_TypeMembers */: - return this.isTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.isExpectedArgumentList_AssignmentExpression(); - - case 2048 /* HeritageClause_TypeNameList */: - return this.isHeritageClauseTypeName(); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.isPropertyAssignment(inErrorRecovery); - - case 131072 /* ParameterList_Parameters */: - return this.isParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.isType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.isTypeParameter(); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.isAssignmentOrOmittedExpression(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.isExpectedArgumentList_AssignmentExpression = function () { - var currentToken = this.currentToken(); - if (this.isExpression(currentToken)) { - return true; - } - - if (currentToken.tokenKind === 79 /* CommaToken */) { - return true; - } - - return false; - }; - - ParserImpl.prototype.parseExpectedListItem = function (currentListType, inErrorRecovery) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return this.parseHeritageClause(); - - case 2 /* ClassDeclaration_ClassElements */: - return this.parseClassElement(inErrorRecovery); - - case 4 /* ModuleDeclaration_ModuleElements */: - return this.parseModuleElement(inErrorRecovery); - - case 8 /* SwitchStatement_SwitchClauses */: - return this.parseSwitchClause(); - - case 16 /* SwitchClause_Statements */: - return this.parseStatement(inErrorRecovery); - - case 32 /* Block_Statements */: - return this.parseStatement(inErrorRecovery); - - case 256 /* EnumDeclaration_EnumElements */: - return this.parseEnumElement(); - - case 512 /* ObjectType_TypeMembers */: - return this.parseTypeMember(inErrorRecovery); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return this.parseAssignmentExpression(true); - - case 2048 /* HeritageClause_TypeNameList */: - return this.parseNameOrGenericType(); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return this.parseVariableDeclarator(true, false); - - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return this.parseVariableDeclarator(false, false); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return this.parsePropertyAssignment(inErrorRecovery); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return this.parseAssignmentOrOmittedExpression(); - - case 131072 /* ParameterList_Parameters */: - return this.parseParameter(); - - case 262144 /* TypeArgumentList_Types */: - return this.parseType(); - - case 524288 /* TypeParameterList_TypeParameters */: - return this.parseTypeParameter(); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - ParserImpl.prototype.getExpectedListElementType = function (currentListType) { - switch (currentListType) { - case 1 /* SourceUnit_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 1024 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - - case 2 /* ClassDeclaration_ClassElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); - - case 4 /* ModuleDeclaration_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - - case 8 /* SwitchStatement_SwitchClauses */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); - - case 16 /* SwitchClause_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 32 /* Block_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - - case 4096 /* VariableDeclaration_VariableDeclarators_AllowIn */: - case 8192 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 256 /* EnumDeclaration_EnumElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - - case 512 /* ObjectType_TypeMembers */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); - - case 16384 /* ArgumentList_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - case 2048 /* HeritageClause_TypeNameList */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); - - case 32768 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); - - case 131072 /* ParameterList_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - - case 262144 /* TypeArgumentList_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - - case 524288 /* TypeParameterList_TypeParameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); - - case 65536 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - return ParserImpl; - })(); - - function parse(fileName, text, isDeclaration, options) { - var source = new NormalParserSource(fileName, text, options.languageVersion()); - - return new ParserImpl(fileName, text.lineMap(), source, options, text).parseSyntaxTree(isDeclaration); - } - Parser.parse = parse; - - function incrementalParse(oldSyntaxTree, textChangeRange, newText) { - if (textChangeRange.isUnchanged()) { - return oldSyntaxTree; - } - - var source = new IncrementalParserSource(oldSyntaxTree, textChangeRange, newText); - - return new ParserImpl(oldSyntaxTree.fileName(), newText.lineMap(), source, oldSyntaxTree.parseOptions(), newText).parseSyntaxTree(oldSyntaxTree.isDeclaration()); - } - Parser.incrementalParse = incrementalParse; - })(TypeScript.Parser || (TypeScript.Parser = {})); - var Parser = TypeScript.Parser; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SyntaxTree = (function () { - function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, lineMap, parseOtions) { - this._allDiagnostics = null; - this._sourceUnit = sourceUnit; - this._isDeclaration = isDeclaration; - this._parserDiagnostics = diagnostics; - this._fileName = fileName; - this._lineMap = lineMap; - this._parseOptions = parseOtions; - } - SyntaxTree.prototype.toJSON = function (key) { - var result = {}; - - result.isDeclaration = this._isDeclaration; - result.languageVersion = TypeScript.LanguageVersion[this._parseOptions.languageVersion()]; - result.parseOptions = this._parseOptions; - - if (this.diagnostics().length > 0) { - result.diagnostics = this.diagnostics(); - } - - result.sourceUnit = this._sourceUnit; - result.lineMap = this._lineMap; - - return result; - }; - - SyntaxTree.prototype.sourceUnit = function () { - return this._sourceUnit; - }; - - SyntaxTree.prototype.isDeclaration = function () { - return this._isDeclaration; - }; - - SyntaxTree.prototype.computeDiagnostics = function () { - if (this._parserDiagnostics.length > 0) { - return this._parserDiagnostics; - } - - var diagnostics = []; - this.sourceUnit().accept(new GrammarCheckerWalker(this, diagnostics)); - - return diagnostics; - }; - - SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { - this._allDiagnostics = this.computeDiagnostics(); - } - - return this._allDiagnostics; - }; - - SyntaxTree.prototype.fileName = function () { - return this._fileName; - }; - - SyntaxTree.prototype.lineMap = function () { - return this._lineMap; - }; - - SyntaxTree.prototype.parseOptions = function () { - return this._parseOptions; - }; - - SyntaxTree.prototype.structuralEquals = function (tree) { - return TypeScript.ArrayUtilities.sequenceEquals(this.diagnostics(), tree.diagnostics(), TypeScript.Diagnostic.equals) && this.sourceUnit().structuralEquals(tree.sourceUnit()); - }; - return SyntaxTree; - })(); - TypeScript.SyntaxTree = SyntaxTree; - - var GrammarCheckerWalker = (function (_super) { - __extends(GrammarCheckerWalker, _super); - function GrammarCheckerWalker(syntaxTree, diagnostics) { - _super.call(this); - this.syntaxTree = syntaxTree; - this.diagnostics = diagnostics; - this.inAmbientDeclaration = false; - this.inBlock = false; - this.inObjectLiteralExpression = false; - this.currentConstructor = null; - } - GrammarCheckerWalker.prototype.childFullStart = function (parent, child) { - return this.position() + TypeScript.Syntax.childOffset(parent, child); - }; - - GrammarCheckerWalker.prototype.childStart = function (parent, child) { - return this.childFullStart(parent, child) + child.leadingTriviaWidth(); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic = function (start, length, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), start, length, diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.pushDiagnostic1 = function (elementFullStart, element, diagnosticKey, args) { - if (typeof args === "undefined") { args = null; } - this.diagnostics.push(new TypeScript.Diagnostic(this.syntaxTree.fileName(), this.syntaxTree.lineMap(), elementFullStart + element.leadingTriviaWidth(), element.width(), diagnosticKey, args)); - }; - - GrammarCheckerWalker.prototype.visitCatchClause = function (node) { - if (node.typeAnnotation) { - this.pushDiagnostic(this.childStart(node, node.typeAnnotation), node.typeAnnotation.width(), TypeScript.DiagnosticCode.Catch_clause_parameter_cannot_have_a_type_annotation); - } - - _super.prototype.visitCatchClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkParameterListOrder = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - var seenOptionalParameter = false; - var parameterCount = node.parameters.nonSeparatorCount(); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameterIndex = i / 2; - var parameter = node.parameters.childAt(i); - - if (parameter.dotDotDotToken) { - if (parameterIndex !== (parameterCount - 1)) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_must_be_last_in_list); - return true; - } - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Rest_parameter_cannot_have_an_initializer); - return true; - } - } else if (parameter.questionToken || parameter.equalsValueClause) { - seenOptionalParameter = true; - - if (parameter.questionToken && parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Parameter_cannot_have_question_mark_and_initializer); - return true; - } - } else { - if (seenOptionalParameter) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Required_parameter_cannot_follow_optional_parameter); - return true; - } - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterListAcessibilityModifiers = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameters); - - for (var i = 0, n = node.parameters.childCount(); i < n; i++) { - var nodeOrToken = node.parameters.childAt(i); - if (i % 2 === 0) { - var parameter = node.parameters.childAt(i); - - if (this.checkParameterAccessibilityModifiers(node, parameter, parameterFullStart)) { - return true; - } - } - - parameterFullStart += nodeOrToken.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifiers = function (parameterList, parameter, parameterFullStart) { - if (parameter.modifiers.childCount() > 0) { - var modifiers = parameter.modifiers; - var modifierFullStart = parameterFullStart + TypeScript.Syntax.childOffset(parameter, modifiers); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - - if (this.checkParameterAccessibilityModifier(parameterList, modifier, modifierFullStart, i)) { - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkParameterAccessibilityModifier = function (parameterList, modifier, modifierFullStart, modifierIndex) { - if (modifier.tokenKind !== 57 /* PublicKeyword */ && modifier.tokenKind !== 55 /* PrivateKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); - return true; - } else { - if (modifierIndex > 0) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - 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.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; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForTrailingSeparator = function (parent, list) { - if (list.childCount() === 0 || list.childCount() % 2 === 1) { - return false; - } - - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i === n - 1) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode.Trailing_separator_not_allowed); - } - - currentElementFullStart += child.fullWidth(); - } - - return true; - }; - - GrammarCheckerWalker.prototype.checkForAtLeastOneElement = function (parent, list, expected) { - if (list.childCount() > 0) { - return false; - } - - var listFullStart = this.childFullStart(parent, list); - var tokenAtStart = this.syntaxTree.sourceUnit().findToken(listFullStart); - - this.pushDiagnostic1(listFullStart, tokenAtStart.token(), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [expected]); - - return true; - }; - - GrammarCheckerWalker.prototype.visitParameterList = function (node) { - if (this.checkParameterListAcessibilityModifiers(node) || this.checkParameterListOrder(node) || this.checkForTrailingSeparator(node, node.parameters)) { - this.skip(node); - return; - } - - _super.prototype.visitParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingSeparator(node, node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null))) { - this.skip(node); - return; - } - - _super.prototype.visitHeritageClause.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.arguments)) { - this.skip(node); - return; - } - - _super.prototype.visitArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForTrailingSeparator(node, node.variableDeclarators) || this.checkForAtLeastOneElement(node, node.variableDeclarators, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeArgumentList.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingSeparator(node, node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null))) { - this.skip(node); - return; - } - - _super.prototype.visitTypeParameterList.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexSignatureParameter = function (node) { - var parameterFullStart = this.childFullStart(node, node.parameter); - var parameter = node.parameter; - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); - return true; - } else if (parameter.modifiers.childCount() > 0) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_accessibility_modifiers); - return true; - } else if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_a_question_mark); - return true; - } else if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_cannot_have_an_initializer); - return true; - } else if (!parameter.typeAnnotation) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); - return true; - } else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexSignature = function (node) { - if (this.checkIndexSignatureParameter(node)) { - this.skip(node); - return; - } - - if (!node.typeAnnotation) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.Index_signature_must_have_a_type_annotation); - this.skip(node); - return; - } - - _super.prototype.visitIndexSignature.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - var seenImplementsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); - return true; - } - - if (heritageClause.typeNames.nonSeparatorCount() > 1) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - if (seenImplementsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); - return true; - } - - seenImplementsClause = true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { - if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_for_code_already_in_an_ambient_context); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, typeKeyword, modifiers) { - if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - this.pushDiagnostic1(this.childFullStart(moduleElement, typeKeyword), typeKeyword.firstToken(), TypeScript.DiagnosticCode.declare_modifier_required_for_top_level_element); - return true; - } - } - }; - - GrammarCheckerWalker.prototype.checkFunctionOverloads = function (node, moduleElements) { - if (!this.inAmbientDeclaration && !this.syntaxTree.isDeclaration()) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - - var inFunctionOverloadChain = false; - var functionOverloadChainName = null; - - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - var lastElement = i === (n - 1); - - if (inFunctionOverloadChain) { - if (moduleElement.kind() !== 129 /* FunctionDeclaration */) { - this.pushDiagnostic1(moduleElementFullStart, moduleElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - var functionDeclaration = moduleElement; - if (functionDeclaration.identifier.valueText() !== functionOverloadChainName) { - var identifierFullStart = moduleElementFullStart + TypeScript.Syntax.childOffset(moduleElement, functionDeclaration.identifier); - this.pushDiagnostic1(identifierFullStart, functionDeclaration.identifier, TypeScript.DiagnosticCode.Function_overload_name_must_be_0, [functionOverloadChainName]); - return true; - } - } - - if (moduleElement.kind() === 129 /* FunctionDeclaration */) { - functionDeclaration = moduleElement; - if (!TypeScript.SyntaxUtilities.containsToken(functionDeclaration.modifiers, 63 /* DeclareKeyword */)) { - inFunctionOverloadChain = functionDeclaration.block === null; - functionOverloadChainName = functionDeclaration.identifier.valueText(); - - 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; - functionOverloadChainName = ""; - } - } - - moduleElementFullStart += moduleElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkClassOverloads = function (node) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var classElementFullStart = this.childFullStart(node, node.classElements); - - var inFunctionOverloadChain = false; - var inConstructorOverloadChain = false; - - var functionOverloadChainName = null; - var isInStaticOverloadChain = null; - var memberFunctionDeclaration = null; - - for (var i = 0, n = node.classElements.childCount(); i < n; i++) { - var classElement = node.classElements.childAt(i); - var lastElement = i === (n - 1); - var isStaticOverload = null; - - if (inFunctionOverloadChain) { - if (classElement.kind() !== 135 /* MemberFunctionDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Function_implementation_expected); - return true; - } - - memberFunctionDeclaration = classElement; - if (memberFunctionDeclaration.propertyName.valueText() !== functionOverloadChainName) { - var propertyNameFullStart = classElementFullStart + TypeScript.Syntax.childOffset(classElement, memberFunctionDeclaration.propertyName); - 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) { - 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; - } - } else if (inConstructorOverloadChain) { - if (classElement.kind() !== 137 /* ConstructorDeclaration */) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - if (classElement.kind() === 135 /* MemberFunctionDeclaration */) { - memberFunctionDeclaration = classElement; - - inFunctionOverloadChain = memberFunctionDeclaration.block === null; - functionOverloadChainName = memberFunctionDeclaration.propertyName.valueText(); - isInStaticOverloadChain = TypeScript.SyntaxUtilities.containsToken(memberFunctionDeclaration.modifiers, 58 /* StaticKeyword */); - - 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; - - inConstructorOverloadChain = constructorDeclaration.block === null; - if (lastElement && inConstructorOverloadChain) { - this.pushDiagnostic1(classElementFullStart, classElement.firstToken(), TypeScript.DiagnosticCode.Constructor_implementation_expected); - return true; - } - } - - classElementFullStart += classElement.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForReservedName = function (parent, name, diagnosticKey) { - var nameFullStart = this.childFullStart(parent, name); - var token; - var tokenFullStart; - - var current = name; - while (current !== null) { - if (current.kind() === 121 /* QualifiedName */) { - var qualifiedName = current; - token = qualifiedName.right; - tokenFullStart = nameFullStart + this.childFullStart(qualifiedName, token); - current = qualifiedName.left; - } else { - TypeScript.Debug.assert(current.kind() === 11 /* IdentifierName */); - token = current; - tokenFullStart = nameFullStart; - current = null; - } - - switch (token.valueText()) { - case "any": - case "number": - case "boolean": - case "string": - case "void": - this.pushDiagnostic(tokenFullStart + token.leadingTriviaWidth(), token.width(), diagnosticKey, [token.valueText()]); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitClassDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Class_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.classKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkClassDeclarationHeritageClauses(node) || this.checkClassOverloads(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitClassDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkInterfaceDeclarationHeritageClauses = function (node) { - var heritageClauseFullStart = this.childFullStart(node, node.heritageClauses); - - var seenExtendsClause = false; - - for (var i = 0, n = node.heritageClauses.childCount(); i < n; i++) { - TypeScript.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses.childAt(i); - - if (heritageClause.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */) { - if (seenExtendsClause) { - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); - return true; - } - - seenExtendsClause = true; - } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.tokenKind === 51 /* ImplementsKeyword */); - this.pushDiagnostic1(heritageClauseFullStart, heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); - return true; - } - - heritageClauseFullStart += heritageClause.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { - var modifierFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.declare_modifier_cannot_appear_on_an_interface_declaration); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitInterfaceDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Interface_name_cannot_be_0) || this.checkInterfaceModifiers(node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkInterfaceDeclarationHeritageClauses(node)) { - this.skip(node); - return; - } - - _super.prototype.visitInterfaceDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkClassElementModifiers = function (list) { - var modifierFullStart = this.position(); - - var seenAccessibilityModifier = false; - var seenStaticModifier = false; - - for (var i = 0, n = list.childCount(); i < n; i++) { - var modifier = list.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */) { - if (seenAccessibilityModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return true; - } - - if (seenStaticModifier) { - var previousToken = list.childAt(i - 1); - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [modifier.text(), previousToken.text()]); - return true; - } - - seenAccessibilityModifier = true; - } else if (modifier.tokenKind === 58 /* StaticKeyword */) { - if (seenStaticModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return true; - } - - seenStaticModifier = true; - } else { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_class_element, [modifier.text()]); - return true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitMemberVariableDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberVariableDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitMemberFunctionDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkGetAccessorParameter = function (node, getKeyword, parameterList) { - var getKeywordFullStart = this.childFullStart(node, getKeyword); - if (parameterList.parameters.childCount() !== 0) { - this.pushDiagnostic1(getKeywordFullStart, getKeyword, TypeScript.DiagnosticCode.get_accessor_cannot_have_parameters); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitIndexMemberDeclaration = function (node) { - if (this.checkIndexMemberModifiers(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIndexMemberDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { - if (node.modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(node, node.modifiers); - this.pushDiagnostic1(modifierFullStart, node.modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, node, languageVersion, diagnosticKey) { - if (this.syntaxTree.parseOptions().languageVersion() < languageVersion) { - var nodeFullStart = this.childFullStart(parent, node); - this.pushDiagnostic1(nodeFullStart, node, diagnosticKey); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectLiteralExpression = function (node) { - var savedInObjectLiteralExpression = this.inObjectLiteralExpression; - this.inObjectLiteralExpression = true; - _super.prototype.visitObjectLiteralExpression.call(this, node); - this.inObjectLiteralExpression = savedInObjectLiteralExpression; - }; - - GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.getKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkGetAccessorParameter(node, node.getKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitGetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForAccessorDeclarationInAmbientContext = function (accessor) { - if (this.inAmbientDeclaration) { - this.pushDiagnostic1(this.position(), accessor, TypeScript.DiagnosticCode.Accessors_are_not_allowed_in_ambient_contexts, null); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node, setKeyword, parameterList) { - var setKeywordFullStart = this.childFullStart(node, setKeyword); - if (parameterList.parameters.childCount() !== 1) { - this.pushDiagnostic1(setKeywordFullStart, setKeyword, TypeScript.DiagnosticCode.set_accessor_must_have_one_and_only_one_parameter); - return true; - } - - var parameterListFullStart = this.childFullStart(node, parameterList); - var parameterFullStart = parameterListFullStart + TypeScript.Syntax.childOffset(parameterList, parameterList.openParenToken); - var parameter = parameterList.parameters.childAt(0); - - if (parameter.questionToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); - return true; - } - - if (parameter.equalsValueClause) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_have_an_initializer); - return true; - } - - if (parameter.dotDotDotToken) { - this.pushDiagnostic1(parameterFullStart, parameter, TypeScript.DiagnosticCode.set_accessor_cannot_have_rest_parameter); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.setKeyword, 1 /* EcmaScript5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkSetAccessorParameter(node, node.setKeyword, node.parameterList)) { - this.skip(node); - return; - } - - _super.prototype.visitSetAccessor.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEnumDeclaration = function (node) { - if (this.checkForReservedName(node, node.identifier, TypeScript.DiagnosticCode.Enum_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.enumKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers), this.checkEnumElements(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitEnumDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkEnumElements = function (node) { - var enumElementFullStart = this.childFullStart(node, node.enumElements); - - 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 && previousValueWasComputed) { - this.pushDiagnostic1(enumElementFullStart, enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer, null); - return true; - } - - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); - } - } - - enumElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitEnumElement = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - var expression = node.equalsValueClause.value; - if (!TypeScript.Syntax.isIntegerLiteral(expression)) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Ambient_enum_elements_can_only_have_integer_literal_initializers); - this.skip(node); - return; - } - } - - _super.prototype.visitEnumElement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { - this.pushDiagnostic1(this.position(), node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); - } - - _super.prototype.visitInvocationExpression.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkModuleElementModifiers = function (modifiers) { - var modifierFullStart = this.position(); - var seenExportModifier = false; - var seenDeclareModifier = false; - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var modifier = modifiers.childAt(i); - if (modifier.tokenKind === 57 /* PublicKeyword */ || modifier.tokenKind === 55 /* PrivateKeyword */ || modifier.tokenKind === 58 /* StaticKeyword */) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); - return true; - } - - if (modifier.tokenKind === 63 /* DeclareKeyword */) { - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); - return; - } - - seenDeclareModifier = true; - } else if (modifier.tokenKind === 47 /* ExportKeyword */) { - if (seenExportModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); - return; - } - - if (seenDeclareModifier) { - this.pushDiagnostic1(modifierFullStart, modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); - return; - } - - seenExportModifier = true; - } - - modifierFullStart += modifier.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedImportDeclaration = function (node) { - var currentElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - if (child.kind() === 133 /* ImportDeclaration */) { - var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (node.stringLiteral === null) { - this.pushDiagnostic1(currentElementFullStart, importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module, null); - } - } - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); - - if (declareToken) { - this.pushDiagnostic1(this.childFullStart(modifiers, declareToken), declareToken, TypeScript.DiagnosticCode.declare_modifier_not_allowed_on_import_declaration); - return true; - } - }; - - GrammarCheckerWalker.prototype.visitImportDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifierOnImportDeclaration(node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - _super.prototype.visitImportDeclaration.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitModuleDeclaration = function (node) { - if (this.checkForReservedName(node, node.name, TypeScript.DiagnosticCode.Module_name_cannot_be_0) || this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.moduleKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedImportDeclaration(node) || this.checkForDisallowedExports(node, node.moduleElements) || this.checkForMultipleExportAssignments(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (!TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */) && this.checkFunctionOverloads(node, node.moduleElements)) { - this.skip(node); - return; - } - - if (node.stringLiteral) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { - var stringLiteralFullStart = this.childFullStart(node, node.stringLiteral); - this.pushDiagnostic1(stringLiteralFullStart, node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); - this.skip(node); - return; - } - } - - if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitModuleDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExports = function (node, moduleElements) { - var seenExportedElement = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (TypeScript.SyntaxUtilities.hasExportKeyword(child)) { - seenExportedElement = true; - break; - } - } - - var moduleElementFullStart = this.childFullStart(node, moduleElements); - if (seenExportedElement) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_not_allowed_in_module_with_exported_element); - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.checkForMultipleExportAssignments = function (node, moduleElements) { - var moduleElementFullStart = this.childFullStart(node, moduleElements); - var seenExportAssignment = false; - var errorFound = false; - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var child = moduleElements.childAt(i); - if (child.kind() === 134 /* ExportAssignment */) { - if (seenExportAssignment) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Module_cannot_have_multiple_export_assignments); - errorFound = true; - } - seenExportAssignment = true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return errorFound; - }; - - GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { - var moduleElementFullStart = this.childFullStart(node, node.moduleElements); - - for (var i = 0, n = node.moduleElements.childCount(); i < n; i++) { - var child = node.moduleElements.childAt(i); - - if (child.kind() === 134 /* ExportAssignment */) { - this.pushDiagnostic1(moduleElementFullStart, child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); - - return true; - } - - moduleElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBlock = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Implementations_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - if (this.checkFunctionOverloads(node, node.statements)) { - this.skip(node); - return; - } - - var savedInBlock = this.inBlock; - this.inBlock = true; - _super.prototype.visitBlock.call(this, node); - this.inBlock = savedInBlock; - }; - - GrammarCheckerWalker.prototype.checkForStatementInAmbientContxt = function (node) { - if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { - this.pushDiagnostic1(this.position(), node.firstToken(), TypeScript.DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); - return true; - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitBreakStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitBreakStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitContinueStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitContinueStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDebuggerStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDebuggerStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitDoStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitDoStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitEmptyStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitEmptyStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitExpressionStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitExpressionStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitForInStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node) || this.checkForInStatementVariableDeclaration(node)) { - this.skip(node); - return; - } - - _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); - return; - } - - _super.prototype.visitForStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitIfStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitIfStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitLabeledStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitLabeledStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitReturnStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitReturnStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitSwitchStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitSwitchStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitThrowStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitThrowStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitTryStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitTryStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWhileStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWhileStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitWithStatement = function (node) { - if (this.checkForStatementInAmbientContxt(node)) { - this.skip(node); - return; - } - - _super.prototype.visitWithStatement.call(this, node); - }; - - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { - if (this.inBlock || this.inObjectLiteralExpression) { - if (modifiers.childCount() > 0) { - var modifierFullStart = this.childFullStart(parent, modifiers); - this.pushDiagnostic1(modifierFullStart, modifiers.childAt(0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); - return true; - } - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.functionKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitFunctionDeclaration.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); - _super.prototype.visitVariableStatement.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - var currentElementFullStart = this.childFullStart(parent, list); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var child = list.childAt(i); - if (i % 2 === 1 && child.kind() !== kind) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); - } - - currentElementFullStart += child.fullWidth(); - } - - return false; - }; - - GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { - this.skip(node); - return; - } - - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitObjectType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitArrayType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitArrayType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitFunctionType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitFunctionType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitConstructorType = function (node) { - var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = true; - _super.prototype.visitConstructorType.call(this, node); - this.inAmbientDeclaration = savedInAmbientDeclaration; - }; - - GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { - if (this.inAmbientDeclaration && node.equalsValueClause) { - this.pushDiagnostic1(this.childFullStart(node, node.equalsValueClause), node.equalsValueClause.firstToken(), TypeScript.DiagnosticCode.Initializers_are_not_allowed_in_ambient_contexts); - this.skip(node); - return; - } - - _super.prototype.visitVariableDeclarator.call(this, node); - }; - - GrammarCheckerWalker.prototype.visitConstructorDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers) || this.checkConstructorModifiers(node.modifiers) || this.checkConstructorTypeParameterList(node) || this.checkConstructorTypeAnnotation(node)) { - this.skip(node); - return; - } - - var savedCurrentConstructor = this.currentConstructor; - this.currentConstructor = node; - _super.prototype.visitConstructorDeclaration.call(this, node); - this.currentConstructor = savedCurrentConstructor; - }; - - GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { - var currentElementFullStart = this.position(); - - for (var i = 0, n = modifiers.childCount(); i < n; i++) { - var child = modifiers.childAt(i); - if (child.kind() !== 57 /* PublicKeyword */) { - this.pushDiagnostic1(currentElementFullStart, child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); - return true; - } - - currentElementFullStart += child.fullWidth(); - } - - 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); - return; - } - - _super.prototype.visitSourceUnit.call(this, node); - }; - return GrammarCheckerWalker; - })(TypeScript.PositionTrackingWalker); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Unicode = (function () { - function Unicode() { - } - Unicode.lookupInUnicodeMap = function (code, map) { - if (code < map[0]) { - return false; - } - - var lo = 0; - var hi = map.length; - var mid; - - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - - if (code < map[mid]) { - hi = mid; - } else { - lo = mid + 2; - } - } - - return false; - }; - - Unicode.isIdentifierStart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierStart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierStart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - - Unicode.isIdentifierPart = function (code, languageVersion) { - if (languageVersion === 0 /* EcmaScript3 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES3IdentifierPart); - } else if (languageVersion === 1 /* EcmaScript5 */) { - return Unicode.lookupInUnicodeMap(code, Unicode.unicodeES5IdentifierPart); - } else { - throw TypeScript.Errors.argumentOutOfRange("languageVersion"); - } - }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500]; - return Unicode; - })(); - TypeScript.Unicode = Unicode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (CompilerDiagnostics) { - CompilerDiagnostics.debug = false; - - CompilerDiagnostics.diagnosticWriter = null; - - CompilerDiagnostics.analysisPass = 0; - - function Alert(output) { - if (CompilerDiagnostics.diagnosticWriter) { - CompilerDiagnostics.diagnosticWriter.Alert(output); - } - } - CompilerDiagnostics.Alert = Alert; - - function debugPrint(s) { - if (CompilerDiagnostics.debug) { - Alert(s); - } - } - CompilerDiagnostics.debugPrint = debugPrint; - - function assert(condition, s) { - if (CompilerDiagnostics.debug) { - if (!condition) { - Alert(s); - } - } - } - CompilerDiagnostics.assert = assert; - })(TypeScript.CompilerDiagnostics || (TypeScript.CompilerDiagnostics = {})); - var CompilerDiagnostics = TypeScript.CompilerDiagnostics; - - var NullLogger = (function () { - function NullLogger() { - } - NullLogger.prototype.information = function () { - return false; - }; - NullLogger.prototype.debug = function () { - return false; - }; - NullLogger.prototype.warning = function () { - return false; - }; - NullLogger.prototype.error = function () { - return false; - }; - NullLogger.prototype.fatal = function () { - return false; - }; - NullLogger.prototype.log = function (s) { - }; - return NullLogger; - })(); - TypeScript.NullLogger = NullLogger; - - function timeFunction(logger, funcDescription, func) { - var start = (new Date()).getTime(); - var result = func(); - var end = (new Date()).getTime(); - if (logger.information()) { - logger.log(funcDescription + " completed in " + (end - start) + " msec"); - } - return result; - } - TypeScript.timeFunction = timeFunction; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Document = (function () { - function Document(_compiler, _semanticInfoChain, fileName, referencedFiles, _scriptSnapshot, byteOrderMark, version, isOpen, _syntaxTree, _topLevelDecl) { - this._compiler = _compiler; - this._semanticInfoChain = _semanticInfoChain; - this.fileName = fileName; - this.referencedFiles = referencedFiles; - this._scriptSnapshot = _scriptSnapshot; - this.byteOrderMark = byteOrderMark; - this.version = version; - this.isOpen = isOpen; - this._syntaxTree = _syntaxTree; - this._topLevelDecl = _topLevelDecl; - this._diagnostics = null; - this._bloomFilter = null; - this._sourceUnit = null; - this._lineMap = null; - this._declASTMap = []; - this._astDeclMap = []; - this._amdDependencies = undefined; - this._externalModuleIndicatorSpan = undefined; - } - Document.prototype.invalidate = function () { - this._declASTMap.length = 0; - this._astDeclMap.length = 0; - this._topLevelDecl = null; - - this._syntaxTree = null; - this._sourceUnit = null; - this._diagnostics = null; - this._bloomFilter = null; - }; - - Document.prototype.isDeclareFile = function () { - return TypeScript.isDTSFile(this.fileName); - }; - - Document.prototype.cacheSyntaxTreeInfo = function (syntaxTree) { - var start = new Date().getTime(); - this._diagnostics = syntaxTree.diagnostics(); - TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; - - this._lineMap = syntaxTree.lineMap(); - - var sourceUnit = syntaxTree.sourceUnit(); - var leadingTrivia = sourceUnit.leadingTrivia(); - - this._externalModuleIndicatorSpan = this.getImplicitImportSpan(leadingTrivia) || this.getTopLevelImportOrExportSpan(sourceUnit); - - var amdDependencies = []; - 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); - } - } - } - - this._amdDependencies = amdDependencies; - }; - - Document.prototype.getAmdDependency = function (comment) { - var amdDependencyRegEx = /^\/\/\/\s*/gim; - var match = implicitImportRegEx.exec(trivia.fullText()); - - if (match) { - return new TypeScript.TextSpan(position, trivia.fullWidth()); - } - - return null; - }; - - 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 new TypeScript.TextSpan(position + firstToken.leadingTriviaWidth(), firstToken.width()); - } - - if (moduleElement.kind() === 133 /* ImportDeclaration */) { - var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 245 /* ExternalModuleReference */) { - return new TypeScript.TextSpan(position + importDecl.leadingTriviaWidth(), importDecl.width()); - } - } - - position += moduleElement.fullWidth(); - } - - return null; - ; - }; - - Document.prototype.sourceUnit = function () { - if (!this._sourceUnit) { - var start = new Date().getTime(); - var syntaxTree = this.syntaxTree(); - this._sourceUnit = TypeScript.SyntaxTreeToAstVisitor.visit(syntaxTree, this.fileName, this._compiler.compilationSettings(), this.isOpen); - TypeScript.astTranslationTime += new Date().getTime() - start; - - if (!this.isOpen) { - this._syntaxTree = null; - } - } - - return this._sourceUnit; - }; - - Document.prototype.diagnostics = function () { - if (this._diagnostics === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._diagnostics); - } - - return this._diagnostics; - }; - - Document.prototype.lineMap = function () { - if (this._lineMap === null) { - this.syntaxTree(); - TypeScript.Debug.assert(this._lineMap); - } - - return this._lineMap; - }; - - Document.prototype.isExternalModule = function () { - return this.externalModuleIndicatorSpan() !== null; - }; - - Document.prototype.externalModuleIndicatorSpan = function () { - if (this._externalModuleIndicatorSpan === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._externalModuleIndicatorSpan !== undefined); - } - - return this._externalModuleIndicatorSpan; - }; - - Document.prototype.amdDependencies = function () { - if (this._amdDependencies === undefined) { - this.syntaxTree(); - TypeScript.Debug.assert(this._amdDependencies !== undefined); - } - - return this._amdDependencies; - }; - - Document.prototype.syntaxTree = function () { - var result = this._syntaxTree; - if (!result) { - var start = new Date().getTime(); - - result = TypeScript.Parser.parse(this.fileName, TypeScript.SimpleText.fromScriptSnapshot(this._scriptSnapshot), TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())); - - TypeScript.syntaxTreeParseTime += new Date().getTime() - start; - - if (this.isOpen || !this._sourceUnit) { - this._syntaxTree = result; - } - } - - this.cacheSyntaxTreeInfo(result); - return result; - }; - - Document.prototype.bloomFilter = function () { - if (!this._bloomFilter) { - var identifiers = TypeScript.createIntrinsicsObject(); - var pre = function (cur) { - if (TypeScript.ASTHelpers.isValidAstNode(cur)) { - if (cur.kind() === 11 /* IdentifierName */) { - var nodeText = cur.valueText(); - - identifiers[nodeText] = true; - } - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(this.sourceUnit(), pre, null, identifiers); - - var identifierCount = 0; - for (var name in identifiers) { - if (identifiers[name]) { - identifierCount++; - } - } - - this._bloomFilter = new TypeScript.BloomFilter(identifierCount); - this._bloomFilter.addKeys(identifiers); - } - return this._bloomFilter; - }; - - Document.prototype.emitToOwnOutputFile = function () { - return !this._compiler.compilationSettings().outFileOption() || this.isExternalModule(); - }; - - Document.prototype.update = function (scriptSnapshot, version, isOpen, textChangeRange) { - var oldSyntaxTree = this._syntaxTree; - - if (textChangeRange !== null && TypeScript.Debug.shouldAssert(1 /* Normal */)) { - var oldText = this._scriptSnapshot; - var newText = scriptSnapshot; - - TypeScript.Debug.assert((oldText.getLength() - textChangeRange.span().length() + textChangeRange.newLength()) === newText.getLength()); - - if (TypeScript.Debug.shouldAssert(3 /* VeryAggressive */)) { - var oldTextPrefix = oldText.getText(0, textChangeRange.span().start()); - var newTextPrefix = newText.getText(0, textChangeRange.span().start()); - TypeScript.Debug.assert(oldTextPrefix === newTextPrefix); - - var oldTextSuffix = oldText.getText(textChangeRange.span().end(), oldText.getLength()); - var newTextSuffix = newText.getText(textChangeRange.newSpan().end(), newText.getLength()); - TypeScript.Debug.assert(oldTextSuffix === newTextSuffix); - } - } - - var text = TypeScript.SimpleText.fromScriptSnapshot(scriptSnapshot); - - var newSyntaxTree = textChangeRange === null || oldSyntaxTree === null ? TypeScript.Parser.parse(this.fileName, text, TypeScript.isDTSFile(this.fileName), TypeScript.getParseOptions(this._compiler.compilationSettings())) : TypeScript.Parser.incrementalParse(oldSyntaxTree, textChangeRange, text); - - return new Document(this._compiler, this._semanticInfoChain, this.fileName, this.referencedFiles, scriptSnapshot, this.byteOrderMark, version, isOpen, newSyntaxTree, null); - }; - - Document.create = function (compiler, semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - return new Document(compiler, semanticInfoChain, fileName, referencedFiles, scriptSnapshot, byteOrderMark, version, isOpen, null, null); - }; - - Document.prototype.topLevelDecl = function () { - if (this._topLevelDecl === null) { - this._topLevelDecl = TypeScript.DeclarationCreator.create(this, this._semanticInfoChain, this._compiler.compilationSettings()); - } - - return this._topLevelDecl; - }; - - Document.prototype._getDeclForAST = function (ast) { - this.topLevelDecl(); - return this._astDeclMap[ast.syntaxID()]; - }; - - Document.prototype.getEnclosingDecl = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - return this._getDeclForAST(ast); - } - - ast = ast.parent; - var decl = null; - while (ast) { - decl = this._getDeclForAST(ast); - - if (decl) { - break; - } - - ast = ast.parent; - } - - return decl._getEnclosingDeclFromParentDecl(); - }; - - Document.prototype._setDeclForAST = function (ast, decl) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._astDeclMap[ast.syntaxID()] = decl; - }; - - Document.prototype._getASTForDecl = function (decl) { - return this._declASTMap[decl.declID]; - }; - - Document.prototype._setASTForDecl = function (decl, ast) { - TypeScript.Debug.assert(decl.fileName() === this.fileName); - this._declASTMap[decl.declID] = ast; - }; - return Document; - })(); - TypeScript.Document = Document; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - TypeScript.hasFlag = hasFlag; - - (function (TypeRelationshipFlags) { - TypeRelationshipFlags[TypeRelationshipFlags["SuccessfulComparison"] = 0] = "SuccessfulComparison"; - TypeRelationshipFlags[TypeRelationshipFlags["RequiredPropertyIsMissing"] = 1 << 1] = "RequiredPropertyIsMissing"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleSignatures"] = 1 << 2] = "IncompatibleSignatures"; - TypeRelationshipFlags[TypeRelationshipFlags["SourceSignatureHasTooManyParameters"] = 3] = "SourceSignatureHasTooManyParameters"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleReturnTypes"] = 1 << 4] = "IncompatibleReturnTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatiblePropertyTypes"] = 1 << 5] = "IncompatiblePropertyTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["IncompatibleParameterTypes"] = 1 << 6] = "IncompatibleParameterTypes"; - TypeRelationshipFlags[TypeRelationshipFlags["InconsistantPropertyAccesibility"] = 1 << 7] = "InconsistantPropertyAccesibility"; - })(TypeScript.TypeRelationshipFlags || (TypeScript.TypeRelationshipFlags = {})); - var TypeRelationshipFlags = TypeScript.TypeRelationshipFlags; - - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; - })(TypeScript.ModuleGenTarget || (TypeScript.ModuleGenTarget = {})); - var ModuleGenTarget = TypeScript.ModuleGenTarget; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var proto = "__proto__"; - - var BlockIntrinsics = (function () { - function BlockIntrinsics() { - this.prototype = undefined; - this.toString = undefined; - this.toLocaleString = undefined; - this.valueOf = undefined; - this.hasOwnProperty = undefined; - this.propertyIsEnumerable = undefined; - this.isPrototypeOf = undefined; - this["constructor"] = undefined; - - this[proto] = null; - this[proto] = undefined; - } - return BlockIntrinsics; - })(); - - function createIntrinsicsObject() { - return new BlockIntrinsics(); - } - TypeScript.createIntrinsicsObject = createIntrinsicsObject; - - var StringHashTable = (function () { - function StringHashTable() { - this.itemCount = 0; - this.table = createIntrinsicsObject(); - } - StringHashTable.prototype.getAllKeys = function () { - var result = []; - - for (var k in this.table) { - if (this.table[k] !== undefined) { - result.push(k); - } - } - - return result; - }; - - StringHashTable.prototype.add = function (key, data) { - if (this.table[key] !== undefined) { - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.addOrUpdate = function (key, data) { - if (this.table[key] !== undefined) { - this.table[key] = data; - return false; - } - - this.table[key] = data; - this.itemCount++; - return true; - }; - - StringHashTable.prototype.map = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - fn(k, this.table[k], context); - } - } - }; - - StringHashTable.prototype.every = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (!fn(k, this.table[k], context)) { - return false; - } - } - } - - return true; - }; - - StringHashTable.prototype.some = function (fn, context) { - for (var k in this.table) { - var data = this.table[k]; - - if (data !== undefined) { - if (fn(k, this.table[k], context)) { - return true; - } - } - } - - return false; - }; - - StringHashTable.prototype.count = function () { - return this.itemCount; - }; - - StringHashTable.prototype.lookup = function (key) { - var data = this.table[key]; - return data === undefined ? null : data; - }; - - StringHashTable.prototype.remove = function (key) { - if (this.table[key] !== undefined) { - this.table[key] = undefined; - this.itemCount--; - } - }; - return StringHashTable; - })(); - TypeScript.StringHashTable = StringHashTable; - - var IdentiferNameHashTable = (function (_super) { - __extends(IdentiferNameHashTable, _super); - function IdentiferNameHashTable() { - _super.apply(this, arguments); - } - IdentiferNameHashTable.prototype.getAllKeys = function () { - var result = []; - - _super.prototype.map.call(this, function (k, v, c) { - if (v !== undefined) { - result.push(k.substring(1)); - } - }, null); - - return result; - }; - - IdentiferNameHashTable.prototype.add = function (key, data) { - return _super.prototype.add.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.addOrUpdate = function (key, data) { - return _super.prototype.addOrUpdate.call(this, "#" + key, data); - }; - - IdentiferNameHashTable.prototype.map = function (fn, context) { - return _super.prototype.map.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.every = function (fn, context) { - return _super.prototype.every.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.some = function (fn, context) { - return _super.prototype.some.call(this, function (k, v, c) { - return fn(k.substring(1), v, c); - }, context); - }; - - IdentiferNameHashTable.prototype.lookup = function (key) { - return _super.prototype.lookup.call(this, "#" + key); - }; - return IdentiferNameHashTable; - })(StringHashTable); - TypeScript.IdentiferNameHashTable = IdentiferNameHashTable; -})(TypeScript || (TypeScript = {})); - -var TypeScript; -(function (TypeScript) { - (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); - } - ASTHelpers.moduleIsElided = moduleIsElided; - - 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)) { - 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; - } - ASTHelpers.enumIsElided = enumIsElided; - - function isValidAstNode(ast) { - if (!ast) - return false; - - if (ast.start() === -1 || ast.end() === -1) - return false; - - return true; - } - ASTHelpers.isValidAstNode = isValidAstNode; - - 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; - - 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) { - top = cur; - } - } - } - } - - 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; - } - } - - return false; - } - ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; - - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { - return false; - } - if (ast.kind() !== 11 /* IdentifierName */) { - return false; - } - - 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); - } - 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; - } - - current = current.parent; - } - 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; - } - - return null; - } - ASTHelpers.getEnclosingMemberVariableDeclaration = getEnclosingMemberVariableDeclaration; - - 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; - } - 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; - - function parametersFromIdentifier(id) { - return { - length: 1, - lastParameterIsRest: function () { - return false; - }, - ast: id, - astAt: function (index) { - return id; - }, - identifierAt: function (index) { - return id; - }, - typeAt: function (index) { - return null; - }, - initializerAt: function (index) { - return null; - }, - isOptionalAt: function (index) { - return false; - } - }; - } - ASTHelpers.parametersFromIdentifier = parametersFromIdentifier; - - function parametersFromParameter(parameter) { - return { - length: 1, - lastParameterIsRest: function () { - return parameter.dotDotDotToken !== null; - }, - ast: parameter, - astAt: function (index) { - return parameter; - }, - identifierAt: function (index) { - return parameter.identifier; - }, - typeAt: function (index) { - return getType(parameter); - }, - initializerAt: function (index) { - return parameter.equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(parameter); - } - }; - } - ASTHelpers.parametersFromParameter = parametersFromParameter; - - function parameterIsOptional(parameter) { - return parameter.questionToken !== null || parameter.equalsValueClause !== null; - } - - function parametersFromParameterList(list) { - return { - length: list.parameters.nonSeparatorCount(), - lastParameterIsRest: function () { - return TypeScript.lastParameterIsRest(list); - }, - ast: list.parameters, - astAt: function (index) { - return list.parameters.nonSeparatorAt(index); - }, - identifierAt: function (index) { - return list.parameters.nonSeparatorAt(index).identifier; - }, - typeAt: function (index) { - return getType(list.parameters.nonSeparatorAt(index)); - }, - initializerAt: function (index) { - return list.parameters.nonSeparatorAt(index).equalsValueClause; - }, - isOptionalAt: function (index) { - return parameterIsOptional(list.parameters.nonSeparatorAt(index)); - } - }; - } - ASTHelpers.parametersFromParameterList = parametersFromParameterList; - - 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; - } - } - ASTHelpers.isDeclarationAST = isDeclarationAST; - - 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; - } - - 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; - } - - ast = ast.parent; - } - - return null; - } - ASTHelpers.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); - - 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 { - TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); - var dotExpr = name; - return getNameOfIdenfierOrQualifiedName(dotExpr.left) + "." + getNameOfIdenfierOrQualifiedName(dotExpr.right); - } - } - ASTHelpers.getNameOfIdenfierOrQualifiedName = getNameOfIdenfierOrQualifiedName; - })(TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); - var ASTHelpers = TypeScript.ASTHelpers; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function walkListChildren(preAst, walker) { - for (var i = 0, n = preAst.childCount(); i < n; i++) { - walker.walk(preAst.childAt(i)); - } - } - - function walkThrowStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkPrefixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkPostfixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - - function walkDeleteExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkTypeArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArguments); - } - - function walkTypeOfExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkVoidExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArgumentList); - walker.walk(preAst.arguments); - } - - function walkArrayLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.expressions); - } - - function walkSimplePropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.expression); - } - - function walkFunctionPropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkGetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkSeparatedListChildren(preAst, walker) { - for (var i = 0, n = preAst.nonSeparatorCount(); i < n; i++) { - walker.walk(preAst.nonSeparatorAt(i)); - } - } - - function walkSetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.parameterList); - walker.walk(preAst.block); - } - - function walkObjectLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.propertyAssignments); - } - - function walkCastExpressionChildren(preAst, walker) { - walker.walk(preAst.type); - walker.walk(preAst.expression); - } - - function walkParenthesizedExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkElementAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentExpression); - } - - function walkMemberAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.name); - } - - function walkQualifiedNameChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkBinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - - function walkEqualsValueClauseChildren(preAst, walker) { - walker.walk(preAst.value); - } - - function walkTypeParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.constraint); - } - - function walkTypeParameterListChildren(preAst, walker) { - walker.walk(preAst.typeParameters); - } - - function walkGenericTypeChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.typeArgumentList); - } - - function walkTypeAnnotationChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkTypeQueryChildren(preAst, walker) { - walker.walk(preAst.name); - } - - function walkInvocationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkObjectCreationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - - function walkTrinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.whenTrue); - walker.walk(preAst.whenFalse); - } - - function walkFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFunctionTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - - function walkMemberFunctionDeclarationChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkFuncDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkIndexMemberDeclarationChildren(preAst, walker) { - walker.walk(preAst.indexSignature); - } - - function walkIndexSignatureChildren(preAst, walker) { - walker.walk(preAst.parameter); - walker.walk(preAst.typeAnnotation); - } - - function walkCallSignatureChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - } - - function walkConstraintChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - - function walkConstructorTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - - function walkConstructSignatureChildren(preAst, walker) { - walker.walk(preAst.callSignature); - } - - function walkParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkParameterListChildren(preAst, walker) { - walker.walk(preAst.parameters); - } - - function walkPropertySignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - } - - function walkVariableDeclaratorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - - function walkMemberVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarator); - } - - function walkMethodSignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - } - - function walkReturnStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkForStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.initializer); - walker.walk(preAst.condition); - walker.walk(preAst.incrementor); - walker.walk(preAst.statement); - } - - function walkForInStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.left); - walker.walk(preAst.expression); - walker.walk(preAst.statement); - } - - function walkIfStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - walker.walk(preAst.elseClause); - } - - function walkElseClauseChildren(preAst, walker) { - walker.walk(preAst.statement); - } - - function walkWhileStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkDoStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkBlockChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.declarators); - } - - function walkCaseSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.statements); - } - - function walkDefaultSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.statements); - } - - function walkSwitchStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.switchClauses); - } - - function walkTryStatementChildren(preAst, walker) { - walker.walk(preAst.block); - walker.walk(preAst.catchClause); - walker.walk(preAst.finallyClause); - } - - function walkCatchClauseChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - - function walkExternalModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.stringLiteral); - } - - function walkFinallyClauseChildren(preAst, walker) { - walker.walk(preAst.block); - } - - function walkClassDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.classElements); - } - - function walkScriptChildren(preAst, walker) { - walker.walk(preAst.moduleElements); - } - - function walkHeritageClauseChildren(preAst, walker) { - walker.walk(preAst.typeNames); - } - - function walkInterfaceDeclerationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.body); - } - - function walkObjectTypeChildren(preAst, walker) { - walker.walk(preAst.typeMembers); - } - - function walkArrayTypeChildren(preAst, walker) { - walker.walk(preAst.type); - } - - function walkModuleDeclarationChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.stringLiteral); - walker.walk(preAst.moduleElements); - } - - function walkModuleNameModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.moduleName); - } - - function walkEnumDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.enumElements); - } - - function walkEnumElementChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.equalsValueClause); - } - - function walkImportDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.moduleReference); - } - - function walkExportAssignmentChildren(preAst, walker) { - walker.walk(preAst.identifier); - } - - function walkWithStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - - function walkExpressionStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - - function walkLabeledStatementChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.statement); - } - - function walkVariableStatementChildren(preAst, walker) { - walker.walk(preAst.declaration); - } - - var childrenWalkers = new Array(246 /* Last */ + 1); - - for (var i = 9 /* FirstToken */, n = 119 /* LastToken */; i <= n; i++) { - childrenWalkers[i] = null; - } - for (var i = 4 /* FirstTrivia */, n = 8 /* LastTrivia */; i <= n; i++) { - childrenWalkers[i] = null; - } - - childrenWalkers[175 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[208 /* AddExpression */] = walkBinaryExpressionChildren; - childrenWalkers[180 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[60 /* AnyKeyword */] = null; - childrenWalkers[226 /* ArgumentList */] = walkArgumentListChildren; - childrenWalkers[214 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; - childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; - childrenWalkers[219 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; - childrenWalkers[218 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; - childrenWalkers[174 /* AssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[191 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[190 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[166 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[189 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[146 /* Block */] = walkBlockChildren; - childrenWalkers[61 /* BooleanKeyword */] = null; - childrenWalkers[152 /* BreakStatement */] = null; - childrenWalkers[142 /* CallSignature */] = walkCallSignatureChildren; - childrenWalkers[233 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; - childrenWalkers[220 /* CastExpression */] = walkCastExpressionChildren; - childrenWalkers[236 /* CatchClause */] = walkCatchClauseChildren; - childrenWalkers[131 /* ClassDeclaration */] = walkClassDeclChildren; - childrenWalkers[173 /* CommaExpression */] = walkBinaryExpressionChildren; - childrenWalkers[186 /* ConditionalExpression */] = walkTrinaryExpressionChildren; - childrenWalkers[239 /* Constraint */] = walkConstraintChildren; - childrenWalkers[137 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; - childrenWalkers[143 /* ConstructSignature */] = walkConstructSignatureChildren; - childrenWalkers[153 /* ContinueStatement */] = null; - childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; - childrenWalkers[162 /* DebuggerStatement */] = null; - childrenWalkers[234 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; - childrenWalkers[170 /* DeleteExpression */] = walkDeleteExpressionChildren; - childrenWalkers[178 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[206 /* DivideExpression */] = walkBinaryExpressionChildren; - childrenWalkers[161 /* DoStatement */] = walkDoStatementChildren; - childrenWalkers[221 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; - childrenWalkers[235 /* ElseClause */] = walkElseClauseChildren; - childrenWalkers[156 /* EmptyStatement */] = null; - childrenWalkers[132 /* EnumDeclaration */] = walkEnumDeclarationChildren; - childrenWalkers[243 /* EnumElement */] = walkEnumElementChildren; - childrenWalkers[194 /* EqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[232 /* EqualsValueClause */] = walkEqualsValueClauseChildren; - childrenWalkers[192 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[181 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[134 /* ExportAssignment */] = walkExportAssignmentChildren; - childrenWalkers[149 /* ExpressionStatement */] = walkExpressionStatementChildren; - childrenWalkers[230 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[245 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; - childrenWalkers[24 /* FalseKeyword */] = null; - childrenWalkers[237 /* FinallyClause */] = walkFinallyClauseChildren; - childrenWalkers[155 /* ForInStatement */] = walkForInStatementChildren; - childrenWalkers[154 /* ForStatement */] = walkForStatementChildren; - childrenWalkers[129 /* FunctionDeclaration */] = walkFuncDeclChildren; - childrenWalkers[222 /* FunctionExpression */] = walkFunctionExpressionChildren; - childrenWalkers[241 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; - childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; - childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; - childrenWalkers[139 /* GetAccessor */] = walkGetAccessorChildren; - childrenWalkers[197 /* GreaterThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[199 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[147 /* IfStatement */] = walkIfStatementChildren; - childrenWalkers[231 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[133 /* ImportDeclaration */] = walkImportDeclarationChildren; - childrenWalkers[138 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; - childrenWalkers[144 /* IndexSignature */] = walkIndexSignatureChildren; - childrenWalkers[201 /* InExpression */] = walkBinaryExpressionChildren; - childrenWalkers[200 /* InstanceOfExpression */] = walkBinaryExpressionChildren; - childrenWalkers[128 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; - childrenWalkers[213 /* InvocationExpression */] = walkInvocationExpressionChildren; - childrenWalkers[160 /* LabeledStatement */] = walkLabeledStatementChildren; - childrenWalkers[183 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[202 /* LeftShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[196 /* LessThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[198 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[1 /* List */] = walkListChildren; - childrenWalkers[188 /* LogicalAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[167 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[187 /* LogicalOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[212 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; - childrenWalkers[135 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; - childrenWalkers[136 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; - childrenWalkers[145 /* MethodSignature */] = walkMethodSignatureChildren; - childrenWalkers[130 /* ModuleDeclaration */] = walkModuleDeclarationChildren; - childrenWalkers[246 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; - childrenWalkers[179 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[207 /* ModuloExpression */] = walkBinaryExpressionChildren; - childrenWalkers[177 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[205 /* MultiplyExpression */] = walkBinaryExpressionChildren; - childrenWalkers[11 /* IdentifierName */] = null; - childrenWalkers[165 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[0 /* None */] = null; - childrenWalkers[195 /* NotEqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[193 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[32 /* NullKeyword */] = null; - childrenWalkers[67 /* NumberKeyword */] = null; - childrenWalkers[13 /* NumericLiteral */] = null; - childrenWalkers[216 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; - childrenWalkers[215 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; - childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; - childrenWalkers[223 /* OmittedExpression */] = null; - childrenWalkers[182 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[242 /* Parameter */] = walkParameterChildren; - childrenWalkers[227 /* ParameterList */] = walkParameterListChildren; - childrenWalkers[217 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; - childrenWalkers[164 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[211 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[210 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[169 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[168 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[141 /* PropertySignature */] = walkPropertySignatureChildren; - childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; - childrenWalkers[12 /* RegularExpressionLiteral */] = null; - childrenWalkers[150 /* ReturnStatement */] = walkReturnStatementChildren; - childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; - childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; - childrenWalkers[140 /* SetAccessor */] = walkSetAccessorChildren; - childrenWalkers[184 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[203 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[240 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; - childrenWalkers[14 /* StringLiteral */] = null; - childrenWalkers[69 /* StringKeyword */] = null; - childrenWalkers[176 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[209 /* SubtractExpression */] = walkBinaryExpressionChildren; - childrenWalkers[50 /* SuperKeyword */] = null; - childrenWalkers[151 /* SwitchStatement */] = walkSwitchStatementChildren; - childrenWalkers[35 /* ThisKeyword */] = null; - childrenWalkers[157 /* ThrowStatement */] = walkThrowStatementChildren; - childrenWalkers[3 /* TriviaList */] = null; - childrenWalkers[37 /* TrueKeyword */] = null; - childrenWalkers[159 /* TryStatement */] = walkTryStatementChildren; - childrenWalkers[244 /* TypeAnnotation */] = walkTypeAnnotationChildren; - childrenWalkers[228 /* TypeArgumentList */] = walkTypeArgumentListChildren; - childrenWalkers[171 /* TypeOfExpression */] = walkTypeOfExpressionChildren; - childrenWalkers[238 /* TypeParameter */] = walkTypeParameterChildren; - childrenWalkers[229 /* TypeParameterList */] = walkTypeParameterListChildren; - childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; - childrenWalkers[185 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[204 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[224 /* VariableDeclaration */] = walkVariableDeclarationChildren; - childrenWalkers[225 /* VariableDeclarator */] = walkVariableDeclaratorChildren; - childrenWalkers[148 /* VariableStatement */] = walkVariableStatementChildren; - childrenWalkers[172 /* VoidExpression */] = walkVoidExpressionChildren; - childrenWalkers[41 /* VoidKeyword */] = null; - childrenWalkers[158 /* WhileStatement */] = walkWhileStatementChildren; - childrenWalkers[163 /* WithStatement */] = walkWithStatementChildren; - - for (var e in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { - TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); - } - } - - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - this.stopWalking = false; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - - var SimplePreAstWalker = (function () { - function SimplePreAstWalker(pre, state) { - this.pre = pre; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePreAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - }; - return SimplePreAstWalker; - })(); - - var SimplePrePostAstWalker = (function () { - function SimplePrePostAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePrePostAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - this.pre(ast, this.state); - - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - - this.post(ast, this.state); - }; - return SimplePrePostAstWalker; - })(); - - var NormalAstWalker = (function () { - function NormalAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - NormalAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - - if (this.options.stopWalking) { - return; - } - - this.pre(ast, this); - - if (this.options.stopWalking) { - return; - } - - if (this.options.goChildren) { - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - } else { - this.options.goChildren = true; - } - - if (this.post) { - this.post(ast, this); - } - }; - return NormalAstWalker; - })(); - - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { - new NormalAstWalker(pre, post, state).walk(ast); - }; - - AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { - if (post) { - new SimplePrePostAstWalker(pre, post, state).walk(ast); - } else { - new SimplePreAstWalker(pre, state).walk(ast); - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - - var globalAstWalkerFactory = new AstWalkerFactory(); - - function getAstWalkerFactory() { - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Base64Format = (function () { - function Base64Format() { - } - Base64Format.encode = function (inValue) { - if (inValue < 64) { - return Base64Format.encodedValues.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - }; - - Base64Format.decodeChar = function (inChar) { - if (inChar.length === 1) { - return Base64Format.encodedValues.indexOf(inChar); - } else { - throw TypeError('"' + inChar + '" must have length 1'); - } - }; - Base64Format.encodedValues = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - return Base64Format; - })(); - - var Base64VLQFormat = (function () { - function Base64VLQFormat() { - } - Base64VLQFormat.encode = function (inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } else { - inValue = inValue << 1; - } - - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + Base64Format.encode(currentDigit); - } while(inValue > 0); - - return encodedStr; - }; - - Base64VLQFormat.decode = function (inString) { - var result = 0; - var negative = false; - - var shift = 0; - for (var i = 0; i < inString.length; i++) { - var byte = Base64Format.decodeChar(inString[i]); - if (i === 0) { - if ((byte & 1) === 1) { - negative = true; - } - result = (byte >> 1) & 15; - } else { - result = result | ((byte & 31) << shift); - } - - shift += (i === 0) ? 4 : 5; - - if ((byte & 32) === 32) { - } else { - return { value: negative ? -(result) : result, rest: inString.substr(i + 1) }; - } - } - - throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); - }; - return Base64VLQFormat; - })(); - TypeScript.Base64VLQFormat = Base64VLQFormat; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var SourceMapPosition = (function () { - function SourceMapPosition() { - } - return SourceMapPosition; - })(); - TypeScript.SourceMapPosition = SourceMapPosition; - - var SourceMapping = (function () { - function SourceMapping() { - this.start = new SourceMapPosition(); - this.end = new SourceMapPosition(); - this.nameIndex = -1; - this.childMappings = []; - } - return SourceMapping; - })(); - TypeScript.SourceMapping = SourceMapping; - - var SourceMapEntry = (function () { - function SourceMapEntry(emittedFile, emittedLine, emittedColumn, sourceFile, sourceLine, sourceColumn, sourceName) { - this.emittedFile = emittedFile; - this.emittedLine = emittedLine; - this.emittedColumn = emittedColumn; - this.sourceFile = sourceFile; - this.sourceLine = sourceLine; - this.sourceColumn = sourceColumn; - this.sourceName = sourceName; - TypeScript.Debug.assert(isFinite(emittedLine)); - TypeScript.Debug.assert(isFinite(emittedColumn)); - TypeScript.Debug.assert(isFinite(sourceColumn)); - TypeScript.Debug.assert(isFinite(sourceLine)); - } - return SourceMapEntry; - })(); - TypeScript.SourceMapEntry = SourceMapEntry; - - var SourceMapper = (function () { - function SourceMapper(jsFile, sourceMapOut, document, jsFilePath, emitOptions, resolvePath) { - this.jsFile = jsFile; - this.sourceMapOut = sourceMapOut; - this.names = []; - this.mappingLevel = []; - this.tsFilePaths = []; - this.allSourceMappings = []; - this.sourceMapEntries = []; - this.setSourceMapOptions(document, jsFilePath, emitOptions, resolvePath); - this.setNewSourceFile(document, emitOptions); - } - SourceMapper.prototype.getOutputFile = function () { - var result = this.sourceMapOut.getOutputFile(); - result.sourceMapEntries = this.sourceMapEntries; - - return result; - }; - - SourceMapper.prototype.increaseMappingLevel = function (ast) { - this.mappingLevel.push(ast); - }; - - SourceMapper.prototype.decreaseMappingLevel = function (ast) { - TypeScript.Debug.assert(this.mappingLevel.length > 0, "Mapping level should never be less than 0. This suggests a missing start call."); - var expectedAst = this.mappingLevel.pop(); - var expectedAstInfo = expectedAst.kind ? TypeScript.SyntaxKind[expectedAst.kind()] : [expectedAst.start(), expectedAst.end()]; - var astInfo = ast.kind ? TypeScript.SyntaxKind[ast.kind()] : [ast.start(), ast.end()]; - TypeScript.Debug.assert(ast === expectedAst, "Provided ast is not the expected AST, Expected: " + expectedAstInfo + " Given: " + astInfo); - }; - - SourceMapper.prototype.setNewSourceFile = function (document, emitOptions) { - var sourceMappings = []; - this.allSourceMappings.push(sourceMappings); - this.currentMappings = [sourceMappings]; - this.currentNameIndex = []; - - this.setNewSourceFilePath(document, emitOptions); - }; - - SourceMapper.prototype.setSourceMapOptions = function (document, jsFilePath, emitOptions, resolvePath) { - var prettyJsFileName = TypeScript.getPrettyName(jsFilePath, false, true); - var prettyMapFileName = prettyJsFileName + SourceMapper.MapFileExtension; - this.jsFileName = prettyJsFileName; - - if (emitOptions.sourceMapRootDirectory()) { - this.sourceMapDirectory = emitOptions.sourceMapRootDirectory(); - if (document.emitToOwnOutputFile()) { - this.sourceMapDirectory = this.sourceMapDirectory + TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath((document.fileName)).replace(emitOptions.commonDirectoryPath(), "")); - } - - if (TypeScript.isRelative(this.sourceMapDirectory)) { - this.sourceMapDirectory = emitOptions.commonDirectoryPath() + this.sourceMapDirectory; - this.sourceMapDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(this.sourceMapDirectory))); - this.sourceMapPath = TypeScript.getRelativePathToFixedPath(TypeScript.getRootFilePath(jsFilePath), this.sourceMapDirectory + prettyMapFileName); - } else { - this.sourceMapPath = this.sourceMapDirectory + prettyMapFileName; - } - } else { - this.sourceMapPath = prettyMapFileName; - this.sourceMapDirectory = TypeScript.getRootFilePath(jsFilePath); - } - this.sourceRoot = emitOptions.sourceRootDirectory(); - }; - - SourceMapper.prototype.setNewSourceFilePath = function (document, emitOptions) { - var tsFilePath = TypeScript.switchToForwardSlashes(document.fileName); - if (emitOptions.sourceRootDirectory()) { - tsFilePath = TypeScript.getRelativePathToFixedPath(emitOptions.commonDirectoryPath(), tsFilePath); - } else { - tsFilePath = TypeScript.getRelativePathToFixedPath(this.sourceMapDirectory, tsFilePath); - } - this.tsFilePaths.push(tsFilePath); - }; - - SourceMapper.prototype.emitSourceMapping = function () { - var _this = this; - TypeScript.Debug.assert(this.mappingLevel.length === 0, "Mapping level is not 0. This suggest a missing end call. Value: " + this.mappingLevel.map(function (item) { - return ['Node of type', TypeScript.SyntaxKind[item.kind()], 'at', item.start(), 'to', item.end()].join(' '); - }).join(', ')); - - this.jsFile.WriteLine("//# sourceMappingURL=" + this.sourceMapPath); - - var mappingsString = ""; - - var prevEmittedColumn = 0; - var prevEmittedLine = 0; - var prevSourceColumn = 0; - var prevSourceLine = 0; - var prevSourceIndex = 0; - var prevNameIndex = 0; - var emitComma = false; - - var recordedPosition = null; - for (var sourceIndex = 0; sourceIndex < this.tsFilePaths.length; sourceIndex++) { - var recordSourceMapping = function (mappedPosition, nameIndex) { - if (recordedPosition !== null && recordedPosition.emittedColumn === mappedPosition.emittedColumn && recordedPosition.emittedLine === mappedPosition.emittedLine) { - return; - } - - if (prevEmittedLine !== mappedPosition.emittedLine) { - while (prevEmittedLine < mappedPosition.emittedLine) { - prevEmittedColumn = 0; - mappingsString = mappingsString + ";"; - prevEmittedLine++; - } - emitComma = false; - } else if (emitComma) { - mappingsString = mappingsString + ","; - } - - _this.sourceMapEntries.push(new SourceMapEntry(_this.jsFileName, mappedPosition.emittedLine + 1, mappedPosition.emittedColumn + 1, _this.tsFilePaths[sourceIndex], mappedPosition.sourceLine, mappedPosition.sourceColumn + 1, nameIndex >= 0 ? _this.names[nameIndex] : undefined)); - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.emittedColumn - prevEmittedColumn); - prevEmittedColumn = mappedPosition.emittedColumn; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(sourceIndex - prevSourceIndex); - prevSourceIndex = sourceIndex; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceLine - 1 - prevSourceLine); - prevSourceLine = mappedPosition.sourceLine - 1; - - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(mappedPosition.sourceColumn - prevSourceColumn); - prevSourceColumn = mappedPosition.sourceColumn; - - if (nameIndex >= 0) { - mappingsString = mappingsString + TypeScript.Base64VLQFormat.encode(nameIndex - prevNameIndex); - prevNameIndex = nameIndex; - } - - emitComma = true; - recordedPosition = mappedPosition; - }; - - var recordSourceMappingSiblings = function (sourceMappings) { - for (var i = 0; i < sourceMappings.length; i++) { - var sourceMapping = sourceMappings[i]; - recordSourceMapping(sourceMapping.start, sourceMapping.nameIndex); - recordSourceMappingSiblings(sourceMapping.childMappings); - recordSourceMapping(sourceMapping.end, sourceMapping.nameIndex); - } - }; - - recordSourceMappingSiblings(this.allSourceMappings[sourceIndex]); - } - - this.sourceMapOut.Write(JSON.stringify({ - version: 3, - file: this.jsFileName, - sourceRoot: this.sourceRoot, - sources: this.tsFilePaths, - names: this.names, - mappings: mappingsString - })); - - this.sourceMapOut.Close(); - }; - SourceMapper.MapFileExtension = ".map"; - return SourceMapper; - })(); - TypeScript.SourceMapper = SourceMapper; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (EmitContainer) { - EmitContainer[EmitContainer["Prog"] = 0] = "Prog"; - EmitContainer[EmitContainer["Module"] = 1] = "Module"; - EmitContainer[EmitContainer["DynamicModule"] = 2] = "DynamicModule"; - EmitContainer[EmitContainer["Class"] = 3] = "Class"; - EmitContainer[EmitContainer["Constructor"] = 4] = "Constructor"; - EmitContainer[EmitContainer["Function"] = 5] = "Function"; - EmitContainer[EmitContainer["Args"] = 6] = "Args"; - EmitContainer[EmitContainer["Interface"] = 7] = "Interface"; - })(TypeScript.EmitContainer || (TypeScript.EmitContainer = {})); - var EmitContainer = TypeScript.EmitContainer; - - var EmitState = (function () { - function EmitState() { - this.column = 0; - this.line = 0; - this.container = 0 /* Prog */; - } - return EmitState; - })(); - TypeScript.EmitState = EmitState; - - var EmitOptions = (function () { - function EmitOptions(compiler, resolvePath) { - this.resolvePath = resolvePath; - this._diagnostic = null; - this._settings = null; - this._commonDirectoryPath = ""; - this._sharedOutputFile = ""; - this._sourceRootDirectory = ""; - this._sourceMapRootDirectory = ""; - this._outputDirectory = ""; - var settings = compiler.compilationSettings(); - this._settings = settings; - - 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()) { - if (settings.mapRoot()) { - if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Options_mapRoot_and_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } else { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } else if (settings.sourceRoot()) { - this._diagnostic = new TypeScript.Diagnostic(null, null, 0, 0, TypeScript.DiagnosticCode.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option, null); - return; - } - } - - this._sourceMapRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.mapRoot())); - this._sourceRootDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(settings.sourceRoot())); - - if (settings.outFileOption() || settings.outDirOption() || settings.mapRoot() || settings.sourceRoot()) { - if (settings.outFileOption()) { - this._sharedOutputFile = TypeScript.switchToForwardSlashes(resolvePath(settings.outFileOption())); - } - - if (settings.outDirOption()) { - this._outputDirectory = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(resolvePath(settings.outDirOption()))); - } - - if (this._outputDirectory || this._sourceMapRootDirectory || this.sourceRootDirectory) { - this.determineCommonDirectoryPath(compiler); - } - } - } - EmitOptions.prototype.diagnostic = function () { - return this._diagnostic; - }; - - EmitOptions.prototype.commonDirectoryPath = function () { - return this._commonDirectoryPath; - }; - EmitOptions.prototype.sharedOutputFile = function () { - return this._sharedOutputFile; - }; - EmitOptions.prototype.sourceRootDirectory = function () { - return this._sourceRootDirectory; - }; - EmitOptions.prototype.sourceMapRootDirectory = function () { - return this._sourceMapRootDirectory; - }; - EmitOptions.prototype.outputDirectory = function () { - return this._outputDirectory; - }; - - EmitOptions.prototype.compilationSettings = function () { - return this._settings; - }; - - EmitOptions.prototype.determineCommonDirectoryPath = function (compiler) { - var commonComponents = []; - var commonComponentsLength = -1; - - var fileNames = compiler.fileNames(); - for (var i = 0, len = fileNames.length; i < len; i++) { - var fileName = fileNames[i]; - var document = compiler.getDocument(fileNames[i]); - var sourceUnit = document.sourceUnit(); - - if (!document.isDeclareFile()) { - var fileComponents = TypeScript.filePathComponents(fileName); - if (commonComponentsLength === -1) { - commonComponents = fileComponents; - commonComponentsLength = commonComponents.length; - } else { - var updatedPath = false; - for (var j = 0; j < commonComponentsLength && j < fileComponents.length; j++) { - if (commonComponents[j] !== fileComponents[j]) { - commonComponentsLength = j; - updatedPath = true; - - if (j === 0) { - 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; - } - - return; - } - - break; - } - } - - if (!updatedPath && fileComponents.length < commonComponentsLength) { - commonComponentsLength = fileComponents.length; - } - } - } - } - - this._commonDirectoryPath = commonComponents.slice(0, commonComponentsLength).join("/") + "/"; - }; - return EmitOptions; - })(); - TypeScript.EmitOptions = EmitOptions; - - var Indenter = (function () { - function Indenter() { - this.indentAmt = 0; - } - Indenter.prototype.increaseIndent = function () { - this.indentAmt += Indenter.indentStep; - }; - - Indenter.prototype.decreaseIndent = function () { - this.indentAmt -= Indenter.indentStep; - }; - - Indenter.prototype.getIndent = function () { - var indentString = Indenter.indentStrings[this.indentAmt]; - if (indentString === undefined) { - indentString = ""; - for (var i = 0; i < this.indentAmt; i = i + Indenter.indentStep) { - indentString += Indenter.indentStepString; - } - Indenter.indentStrings[this.indentAmt] = indentString; - } - return indentString; - }; - Indenter.indentStep = 4; - Indenter.indentStepString = " "; - Indenter.indentStrings = []; - return Indenter; - })(); - TypeScript.Indenter = Indenter; - - function lastParameterIsRest(parameterList) { - var parameters = parameterList.parameters; - return parameters.nonSeparatorCount() > 0 && parameters.nonSeparatorAt(parameters.nonSeparatorCount() - 1).dotDotDotToken !== null; - } - TypeScript.lastParameterIsRest = lastParameterIsRest; - - var Emitter = (function () { - function Emitter(emittingFileName, outfile, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.outfile = outfile; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.globalThisCapturePrologueEmitted = false; - this.extendsPrologueEmitted = false; - this.thisClassNode = null; - this.inArrowFunction = false; - this.moduleName = ""; - this.emitState = new EmitState(); - this.indenter = new Indenter(); - this.sourceMapper = null; - this.captureThisStmtString = "var _this = this;"; - this.declStack = []; - this.exportAssignment = null; - this.inWithBlock = false; - this.document = null; - this.detachedCommentsElement = null; - } - Emitter.prototype.pushDecl = function (decl) { - if (decl) { - this.declStack[this.declStack.length] = decl; - } - }; - - Emitter.prototype.popDecl = function (decl) { - if (decl) { - this.declStack.length--; - } - }; - - Emitter.prototype.getEnclosingDecl = function () { - var declStackLen = this.declStack.length; - var enclosingDecl = declStackLen > 0 ? this.declStack[declStackLen - 1] : null; - return enclosingDecl; - }; - - Emitter.prototype.setExportAssignment = function (exportAssignment) { - this.exportAssignment = exportAssignment; - }; - - Emitter.prototype.getExportAssignment = function () { - return this.exportAssignment; - }; - - Emitter.prototype.setDocument = function (document) { - this.document = document; - }; - - Emitter.prototype.shouldEmitImportDeclaration = 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 */; - - 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 */; - - this.emitComments(importDeclAST, true); - - var importSymbol = importDecl.getSymbol(); - - var parentSymbol = importSymbol.getContainer(); - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - var associatedParentSymbol = parentSymbol ? parentSymbol.getAssociatedContainerType() : null; - var associatedParentSymbolKind = associatedParentSymbol ? associatedParentSymbol.kind : 0 /* None */; - - var needsPropertyAssignment = false; - var usePropertyAssignmentInsteadOfVarDecl = false; - var moduleNamePrefix; - - 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 */)) { - needsPropertyAssignment = true; - } else { - usePropertyAssignmentInsteadOfVarDecl = true; - } - } - - if (this.emitState.container === 2 /* DynamicModule */) { - moduleNamePrefix = "exports."; - } else { - moduleNamePrefix = this.moduleName + "."; - } - } - - if (isAmdCodeGen && isExternalModuleReference) { - needsPropertyAssignment = true; - } else { - this.recordSourceMappingStart(importDeclAST); - if (usePropertyAssignmentInsteadOfVarDecl) { - this.writeToOutput(moduleNamePrefix); - } else { - this.writeToOutput("var "); - } - this.writeToOutput(importDeclAST.identifier.text() + " = "); - var aliasAST = importDeclAST.moduleReference; - - if (isExternalModuleReference) { - this.writeToOutput("require(" + aliasAST.stringLiteral.text() + ")"); - } else { - this.emitJavascript(aliasAST.moduleName, false); - } - - this.recordSourceMappingEnd(importDeclAST); - this.writeToOutput(";"); - - if (needsPropertyAssignment) { - this.writeLineToOutput(""); - this.emitIndent(); - } - } - - if (needsPropertyAssignment) { - this.writeToOutputWithSourceMapRecord(moduleNamePrefix + importDeclAST.identifier.text() + " = " + importDeclAST.identifier.text(), importDeclAST); - this.writeToOutput(";"); - } - this.emitComments(importDeclAST, false); - }; - - Emitter.prototype.createSourceMapper = function (document, jsFileName, jsFile, sourceMapOut, resolvePath) { - this.sourceMapper = new TypeScript.SourceMapper(jsFile, sourceMapOut, document, jsFileName, this.emitOptions, resolvePath); - }; - - Emitter.prototype.setSourceMapperNewSourceFile = function (document) { - this.sourceMapper.setNewSourceFile(document, this.emitOptions); - }; - - Emitter.prototype.updateLineAndColumn = function (s) { - var lineNumbers = TypeScript.TextUtilities.parseLineStarts(s); - if (lineNumbers.length > 1) { - this.emitState.line += lineNumbers.length - 1; - this.emitState.column = s.length - lineNumbers[lineNumbers.length - 1]; - } else { - this.emitState.column += s.length; - } - }; - - Emitter.prototype.writeToOutputWithSourceMapRecord = function (s, astSpan) { - this.recordSourceMappingStart(astSpan); - this.writeToOutput(s); - this.recordSourceMappingEnd(astSpan); - }; - - Emitter.prototype.writeToOutput = function (s) { - this.outfile.Write(s); - this.updateLineAndColumn(s); - }; - - Emitter.prototype.writeLineToOutput = function (s, force) { - if (typeof force === "undefined") { force = false; } - if (!force && s === "" && this.emitState.column === 0) { - return; - } - - this.outfile.WriteLine(s); - this.updateLineAndColumn(s); - this.emitState.column = 0; - this.emitState.line++; - }; - - Emitter.prototype.writeCaptureThisStatement = function (ast) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord(this.captureThisStmtString, ast); - this.writeLineToOutput(""); - }; - - Emitter.prototype.setContainer = function (c) { - var temp = this.emitState.container; - this.emitState.container = c; - return temp; - }; - - Emitter.prototype.getIndentString = function () { - return this.indenter.getIndent(); - }; - - Emitter.prototype.emitIndent = function () { - this.writeToOutput(this.getIndentString()); - }; - - Emitter.prototype.emitComment = function (comment, trailing, first) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var text = getTrimmedTextLines(comment); - var emitColumn = this.emitState.column; - - if (emitColumn === 0) { - this.emitIndent(); - } else if (trailing && first) { - this.writeToOutput(" "); - } - - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - - if (text.length > 1 || comment.endsLine) { - for (var i = 1; i < text.length; i++) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput(text[i]); - } - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingEnd(comment); - this.writeToOutput(" "); - return; - } - } else { - this.recordSourceMappingStart(comment); - this.writeToOutput(text[0]); - this.recordSourceMappingEnd(comment); - this.writeLineToOutput(""); - } - - if (!trailing && emitColumn !== 0) { - this.emitIndent(); - } - }; - - Emitter.prototype.emitComments = function (ast, pre, onlyPinnedOrTripleSlashComments) { - 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; - } - } - - if (pre) { - var preComments = ast.preComments(); - - if (preComments && ast === this.detachedCommentsElement) { - var detachedComments = this.getDetachedComments(ast); - preComments = preComments.slice(detachedComments.length); - this.detachedCommentsElement = null; - } - - if (preComments && onlyPinnedOrTripleSlashComments) { - preComments = TypeScript.ArrayUtilities.where(preComments, function (c) { - return _this.isPinnedOrTripleSlash(c); - }); - } - - this.emitCommentsArray(preComments, false); - } else { - this.emitCommentsArray(ast.postComments(), true); - } - }; - - Emitter.prototype.isPinnedOrTripleSlash = function (comment) { - var fullText = comment.fullText(); - if (fullText.match(TypeScript.tripleSlashReferenceRegExp)) { - return true; - } else { - return fullText.indexOf("/*!") === 0; - } - }; - - Emitter.prototype.emitCommentsArray = function (comments, trailing) { - if (!this.emitOptions.compilationSettings().removeComments() && comments) { - for (var i = 0, n = comments.length; i < n; i++) { - this.emitComment(comments[i], trailing, i === 0); - } - } - }; - - Emitter.prototype.emitObjectLiteralExpression = function (objectLiteral) { - this.recordSourceMappingStart(objectLiteral); - - this.writeToOutput("{"); - this.emitCommaSeparatedList(objectLiteral, objectLiteral.propertyAssignments, " ", true); - this.writeToOutput("}"); - - this.recordSourceMappingEnd(objectLiteral); - }; - - Emitter.prototype.emitArrayLiteralExpression = function (arrayLiteral) { - this.recordSourceMappingStart(arrayLiteral); - - this.writeToOutput("["); - this.emitCommaSeparatedList(arrayLiteral, arrayLiteral.expressions, "", true); - this.writeToOutput("]"); - - this.recordSourceMappingEnd(arrayLiteral); - }; - - Emitter.prototype.emitObjectCreationExpression = function (objectCreationExpression) { - this.recordSourceMappingStart(objectCreationExpression); - this.writeToOutput("new "); - var target = objectCreationExpression.expression; - - this.emit(target); - if (objectCreationExpression.argumentList) { - this.recordSourceMappingStart(objectCreationExpression.argumentList); - this.writeToOutput("("); - this.emitCommaSeparatedList(objectCreationExpression.argumentList, objectCreationExpression.argumentList.arguments, "", false); - this.writeToOutputWithSourceMapRecord(")", objectCreationExpression.argumentList.closeParenToken); - this.recordSourceMappingEnd(objectCreationExpression.argumentList); - } - - this.recordSourceMappingEnd(objectCreationExpression); - }; - - Emitter.prototype.getConstantDecl = function (dotExpr) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(dotExpr); - if (pullSymbol && pullSymbol.kind === 67108864 /* EnumMember */) { - var pullDecls = pullSymbol.getDeclarations(); - if (pullDecls.length === 1) { - var pullDecl = pullDecls[0]; - if (pullDecl.kind === 67108864 /* EnumMember */) { - return pullDecl; - } - } - } - - return null; - }; - - Emitter.prototype.tryEmitConstant = function (dotExpr) { - var propertyName = dotExpr.name; - var boundDecl = this.getConstantDecl(dotExpr); - if (boundDecl) { - var value = boundDecl.constantValue; - if (value !== null) { - this.recordSourceMappingStart(dotExpr); - this.writeToOutput(value.toString()); - var comment = " /* "; - comment += propertyName.text(); - comment += " */"; - this.writeToOutput(comment); - this.recordSourceMappingEnd(dotExpr); - return true; - } - } - - return false; - }; - - Emitter.prototype.emitInvocationExpression = function (callNode) { - this.recordSourceMappingStart(callNode); - var target = callNode.expression; - var args = callNode.argumentList.arguments; - - if (target.kind() === 212 /* MemberAccessExpression */ && target.expression.kind() === 50 /* SuperKeyword */) { - this.emit(target); - this.writeToOutput(".call"); - this.recordSourceMappingStart(args); - this.writeToOutput("("); - this.emitThis(); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - } else { - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("_super.call"); - } else { - this.emitJavascript(target, false); - } - this.recordSourceMappingStart(args); - this.writeToOutput("("); - if (callNode.expression.kind() === 50 /* SuperKeyword */ && this.emitState.container === 4 /* Constructor */) { - this.writeToOutput("this"); - if (args && args.nonSeparatorCount() > 0) { - this.writeToOutput(", "); - } - } - this.emitCommaSeparatedList(callNode.argumentList, args, "", false); - } - - this.writeToOutputWithSourceMapRecord(")", callNode.argumentList.closeParenToken); - this.recordSourceMappingEnd(args); - this.recordSourceMappingEnd(callNode); - }; - - Emitter.prototype.emitParameterList = function (list) { - this.writeToOutput("("); - this.emitCommentsArray(list.openParenTrailingComments, true); - this.emitFunctionParameters(TypeScript.ASTHelpers.parametersFromParameterList(list)); - this.writeToOutput(")"); - }; - - Emitter.prototype.emitFunctionParameters = function (parameters) { - var argsLen = 0; - - if (parameters) { - this.emitComments(parameters.ast, true); - - var tempContainer = this.setContainer(6 /* Args */); - argsLen = parameters.length; - var printLen = argsLen; - if (parameters.lastParameterIsRest()) { - printLen--; - } - for (var i = 0; i < printLen; i++) { - var arg = parameters.astAt(i); - this.emit(arg); - - if (i < (printLen - 1)) { - this.writeToOutput(", "); - } - } - this.setContainer(tempContainer); - - this.emitComments(parameters.ast, false); - } - }; - - Emitter.prototype.emitFunctionBodyStatements = function (name, funcDecl, parameterList, block, bodyExpression) { - this.writeLineToOutput(" {"); - if (name) { - this.recordSourceMappingNameStart(name); - } - - this.indenter.increaseIndent(); - - 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); - } else { - this.emitIndent(); - this.emitCommentsArray(bodyExpression.preComments(), false); - this.writeToOutput("return "); - this.emit(bodyExpression); - this.writeLineToOutput(";"); - this.emitCommentsArray(bodyExpression.postComments(), true); - } - - this.indenter.decreaseIndent(); - this.emitIndent(); - - if (block) { - this.writeToOutputWithSourceMapRecord("}", block.closeBraceToken); - } else { - this.writeToOutputWithSourceMapRecord("}", bodyExpression); - } - - if (name) { - this.recordSourceMappingNameEnd(); - } - }; - - Emitter.prototype.emitDefaultValueAssignments = function (parameters) { - var n = parameters.length; - if (parameters.lastParameterIsRest()) { - n--; - } - - for (var i = 0; i < n; i++) { - var arg = parameters.astAt(i); - var id = parameters.identifierAt(i); - var equalsValueClause = parameters.initializerAt(i); - if (equalsValueClause) { - this.emitIndent(); - this.recordSourceMappingStart(arg); - this.writeToOutput("if (typeof " + id.text() + " === \"undefined\") { "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.emitJavascript(equalsValueClause, false); - this.writeLineToOutput("; }"); - this.recordSourceMappingEnd(arg); - } - } - }; - - Emitter.prototype.emitRestParameterInitializer = function (parameters) { - if (parameters.lastParameterIsRest()) { - var n = parameters.length; - var lastArg = parameters.astAt(n - 1); - var id = parameters.identifierAt(n - 1); - this.emitIndent(); - this.recordSourceMappingStart(lastArg); - this.writeToOutput("var "); - this.writeToOutputWithSourceMapRecord(id.text(), id); - this.writeLineToOutput(" = [];"); - this.recordSourceMappingEnd(lastArg); - this.emitIndent(); - this.writeToOutput("for ("); - this.writeToOutputWithSourceMapRecord("var _i = 0;", lastArg); - this.writeToOutput(" "); - this.writeToOutputWithSourceMapRecord("_i < (arguments.length - " + (n - 1) + ")", lastArg); - this.writeToOutput("; "); - this.writeToOutputWithSourceMapRecord("_i++", lastArg); - this.writeLineToOutput(") {"); - this.indenter.increaseIndent(); - this.emitIndent(); - - this.writeToOutputWithSourceMapRecord(id.text() + "[_i] = arguments[_i + " + (n - 1) + "];", lastArg); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("}"); - } - }; - - Emitter.prototype.getImportDecls = function (fileName) { - var topLevelDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - var result = []; - - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - var queue = dynamicModuleDecl.getChildDecls(); - - for (var i = 0, n = queue.length; i < n; i++) { - var decl = queue[i]; - - if (decl.kind & 128 /* TypeAlias */) { - var importStatementAST = this.semanticInfoChain.getASTForDecl(decl); - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var symbol = decl.getSymbol(); - var typeSymbol = symbol && symbol.type; - if (typeSymbol && typeSymbol !== this.semanticInfoChain.anyTypeSymbol && !typeSymbol.isError()) { - result.push(decl); - } - } - } - } - - return result; - }; - - Emitter.prototype.getModuleImportAndDependencyList = function (sourceUnit) { - var importList = ""; - var dependencyList = ""; - - var importDecls = this.getImportDecls(this.document.fileName); - - if (importDecls.length) { - for (var i = 0; i < importDecls.length; i++) { - var importStatementDecl = importDecls[i]; - var importStatementSymbol = importStatementDecl.getSymbol(); - var importStatementAST = this.semanticInfoChain.getASTForDecl(importStatementDecl); - - if (importStatementSymbol.isUsedAsValue()) { - if (i <= importDecls.length - 1) { - dependencyList += ", "; - importList += ", "; - } - - importList += importStatementDecl.name; - dependencyList += importStatementAST.moduleReference.stringLiteral.text(); - } - } - } - - var amdDependencies = this.document.amdDependencies(); - for (var i = 0; i < amdDependencies.length; i++) { - dependencyList += ", \"" + amdDependencies[i] + "\""; - } - - return { - importList: importList, - dependencyList: dependencyList - }; - }; - - Emitter.prototype.shouldCaptureThis = function (ast) { - if (ast.kind() === 120 /* SourceUnit */) { - var scriptDecl = this.semanticInfoChain.topLevelDecl(this.document.fileName); - return TypeScript.hasFlag(scriptDecl.flags, 262144 /* MustCaptureThis */); - } - - var decl = this.semanticInfoChain.getDeclForAST(ast); - if (decl) { - return TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */); - } - - return false; - }; - - Emitter.prototype.emitEnum = function (moduleDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - this.moduleName = moduleDecl.identifier.text(); - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleDecl.identifier); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleDecl.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleDecl.identifier); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(this.moduleName); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - this.emitSeparatedList(moduleDecl.enumElements); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.getModuleDeclToVerifyChildNameCollision = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - if (TypeScript.ArrayUtilities.contains(this.declStack, moduleDecl)) { - return moduleDecl; - } else if (changeNameIfAnyDeclarationInContext) { - var symbol = moduleDecl.getSymbol(); - if (symbol) { - var otherDecls = symbol.getDeclarations(); - for (var i = 0; i < otherDecls.length; i++) { - if (TypeScript.ArrayUtilities.contains(this.declStack, otherDecls[i])) { - return otherDecls[i]; - } - } - } - } - - return null; - }; - - Emitter.prototype.hasChildNameCollision = function (moduleName, parentDecl) { - var _this = this; - var childDecls = parentDecl.getChildDecls(); - return TypeScript.ArrayUtilities.any(childDecls, function (childDecl) { - 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; - } - } - return false; - }); - }; - - Emitter.prototype.getModuleName = function (moduleDecl, changeNameIfAnyDeclarationInContext) { - var moduleName = moduleDecl.name; - var moduleDisplayName = moduleDecl.getDisplayName(); - - moduleDecl = this.getModuleDeclToVerifyChildNameCollision(moduleDecl, changeNameIfAnyDeclarationInContext); - if (moduleDecl && moduleDecl.kind != 64 /* Enum */) { - while (this.hasChildNameCollision(moduleName, moduleDecl)) { - moduleName = "_" + moduleName; - moduleDisplayName = "_" + moduleDisplayName; - } - } - - return moduleDisplayName; - }; - - Emitter.prototype.emitModuleDeclarationWorker = function (moduleDecl) { - if (moduleDecl.stringLiteral) { - this.emitSingleModuleDeclaration(moduleDecl, moduleDecl.stringLiteral); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[0]); - } - }; - - Emitter.prototype.emitSingleModuleDeclaration = function (moduleDecl, moduleName) { - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDecl, moduleName); - - if (isLastName) { - this.emitComments(moduleDecl, true); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(moduleName); - this.pushDecl(pullDecl); - - var svModuleName = this.moduleName; - - if (moduleDecl.stringLiteral) { - this.moduleName = moduleDecl.stringLiteral.valueText(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - } else { - this.moduleName = moduleName.text(); - } - - var temp = this.setContainer(1 /* Module */); - var isExported = TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */); - - if (!isExported) { - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("var "); - this.recordSourceMappingStart(moduleName); - this.writeToOutput(this.moduleName); - this.recordSourceMappingEnd(moduleName); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(moduleDecl); - this.emitIndent(); - } - - this.writeToOutput("("); - this.recordSourceMappingStart(moduleDecl); - this.writeToOutput("function ("); - - this.moduleName = this.getModuleName(pullDecl); - this.writeToOutputWithSourceMapRecord(this.moduleName, moduleName); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart(moduleName.text()); - - this.indenter.increaseIndent(); - - if (this.shouldCaptureThis(moduleDecl)) { - this.writeCaptureThisStatement(moduleDecl); - } - - if (moduleName === moduleDecl.stringLiteral) { - this.emitList(moduleDecl.moduleElements); - } else { - var moduleNames = TypeScript.getModuleNames(moduleDecl.name); - var nameIndex = moduleNames.indexOf(moduleName); - TypeScript.Debug.assert(nameIndex >= 0); - - if (isLastName) { - this.emitList(moduleDecl.moduleElements); - } else { - this.emitIndent(); - this.emitSingleModuleDeclaration(moduleDecl, moduleNames[nameIndex + 1]); - this.writeLineToOutput(""); - } - } - - this.moduleName = moduleName.text(); - this.indenter.decreaseIndent(); - this.emitIndent(); - - var parentIsDynamic = temp === 2 /* DynamicModule */; - this.recordSourceMappingStart(moduleDecl.endingToken); - if (temp === 0 /* Prog */ && isExported) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(this." + this.moduleName + " || (this." + this.moduleName + " = {}));"); - } else if (isExported || temp === 0 /* Prog */) { - var dotMod = svModuleName !== "" ? (parentIsDynamic ? "exports" : svModuleName) + "." : svModuleName; - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + dotMod + this.moduleName + " || (" + dotMod + this.moduleName + " = {}));"); - } else if (!isExported && temp !== 0 /* Prog */) { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")(" + this.moduleName + " || (" + this.moduleName + " = {}));"); - } else { - this.writeToOutput("}"); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(moduleDecl.endingToken); - this.writeToOutput(")();"); - } - - this.recordSourceMappingEnd(moduleDecl); - if (temp !== 0 /* Prog */ && isExported) { - this.recordSourceMappingStart(moduleDecl); - if (parentIsDynamic) { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = exports." + this.moduleName + ";"); - } else { - this.writeLineToOutput(""); - this.emitIndent(); - this.writeToOutput("var " + this.moduleName + " = " + svModuleName + "." + this.moduleName + ";"); - } - this.recordSourceMappingEnd(moduleDecl); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - - this.popDecl(pullDecl); - - if (isLastName) { - this.emitComments(moduleDecl, false); - } - }; - - Emitter.prototype.emitEnumElement = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - TypeScript.Debug.assert(pullDecl && pullDecl.kind === 67108864 /* EnumMember */); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - var name = varDecl.propertyName.text(); - var quoted = TypeScript.isQuoted(name); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(this.moduleName); - this.writeToOutput('['); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.writeToOutput(']'); - - if (varDecl.equalsValueClause) { - this.emit(varDecl.equalsValueClause); - } else if (pullDecl.constantValue !== null) { - this.writeToOutput(' = '); - this.writeToOutput(pullDecl.constantValue.toString()); - } else { - this.writeToOutput(' = null'); - } - - this.writeToOutput('] = '); - this.writeToOutput(quoted ? name : '"' + name + '"'); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - this.writeToOutput(';'); - }; - - Emitter.prototype.emitElementAccessExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("["); - this.emit(expression.argumentExpression); - this.writeToOutput("]"); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimpleArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitParenthesizedArrowFunctionExpression = function (arrowFunction) { - this.emitAnyArrowFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromParameterList(arrowFunction.callSignature.parameterList), arrowFunction.block, arrowFunction.expression); - }; - - Emitter.prototype.emitAnyArrowFunctionExpression = function (arrowFunction, funcName, parameters, block, expression) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = true; - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(arrowFunction); - - var pullDecl = this.semanticInfoChain.getDeclForAST(arrowFunction); - this.pushDecl(pullDecl); - - this.emitComments(arrowFunction, true); - - this.recordSourceMappingStart(arrowFunction); - this.writeToOutput("function "); - this.writeToOutput("("); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, arrowFunction, parameters, block, expression); - - this.recordSourceMappingEnd(arrowFunction); - - this.recordSourceMappingEnd(arrowFunction); - - this.emitComments(arrowFunction, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConstructor = function (funcDecl) { - if (!funcDecl.block) { - return; - } - var temp = this.setContainer(4 /* Constructor */); - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - this.writeToOutput(this.thisClassNode.identifier.text()); - this.writeToOutput("("); - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeLineToOutput(") {"); - - this.recordSourceMappingNameStart("constructor"); - this.indenter.increaseIndent(); - - this.emitDefaultValueAssignments(parameters); - this.emitRestParameterInitializer(parameters); - - if (this.shouldCaptureThis(funcDecl)) { - this.writeCaptureThisStatement(funcDecl); - } - - this.emitConstructorStatements(funcDecl); - this.emitCommentsArray(funcDecl.block.closeBraceLeadingComments, false); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", funcDecl.block.closeBraceToken); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - this.setContainer(temp); - }; - - Emitter.prototype.emitGetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("get "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList), accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitSetAccessor = function (accessor) { - this.recordSourceMappingStart(accessor); - this.writeToOutput("set "); - - var temp = this.setContainer(5 /* Function */); - - this.recordSourceMappingStart(accessor); - - var pullDecl = this.semanticInfoChain.getDeclForAST(accessor); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(accessor); - - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(accessor, this.semanticInfoChain); - var container = accessorSymbol.getContainer(); - var containerKind = container.kind; - - this.recordSourceMappingNameStart(accessor.propertyName.text()); - this.writeToOutput(accessor.propertyName.text()); - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(accessor.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, accessor, parameters, accessor.block, null); - - this.recordSourceMappingEnd(accessor); - - this.recordSourceMappingEnd(accessor); - - this.popDecl(pullDecl); - this.setContainer(temp); - this.recordSourceMappingEnd(accessor); - }; - - Emitter.prototype.emitFunctionExpression = function (funcDecl) { - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier ? funcDecl.identifier.text() : null; - - this.recordSourceMappingStart(funcDecl); - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - this.writeToOutput(funcDecl.identifier.text()); - this.recordSourceMappingEnd(funcDecl.identifier); - } - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcName, funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitFunction = function (funcDecl) { - if (funcDecl.block === null) { - return; - } - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - - var funcName = funcDecl.identifier.text(); - - this.recordSourceMappingStart(funcDecl); - - var printName = funcDecl.identifier !== null; - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.emitComments(funcDecl, true); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - if (printName) { - var id = funcDecl.identifier.text(); - if (id) { - if (funcDecl.identifier) { - this.recordSourceMappingStart(funcDecl.identifier); - } - this.writeToOutput(id); - if (funcDecl.identifier) { - this.recordSourceMappingEnd(funcDecl.identifier); - } - } - } - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.identifier.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - - if (funcDecl.block) { - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - if ((this.emitState.container === 1 /* Module */ || this.emitState.container === 2 /* DynamicModule */) && pullFunctionDecl && TypeScript.hasFlag(pullFunctionDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = this.emitState.container === 1 /* Module */ ? this.moduleName : "exports"; - this.recordSourceMappingStart(funcDecl); - this.writeToOutput(modName + "." + funcName + " = " + funcName + ";"); - this.recordSourceMappingEnd(funcDecl); - } - } - }; - - Emitter.prototype.emitAmbientVarDecl = function (varDecl) { - this.recordSourceMappingStart(this.currentVariableDeclaration); - if (varDecl.equalsValueClause) { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - this.emitJavascript(varDecl.equalsValueClause, false); - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - }; - - Emitter.prototype.emitVarDeclVar = function () { - if (this.currentVariableDeclaration) { - this.writeToOutput("var "); - } - }; - - Emitter.prototype.emitVariableDeclaration = function (declaration) { - var varDecl = declaration.declarators.nonSeparatorAt(0); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentKind = parentSymbol ? parentSymbol.kind : 0 /* None */; - - this.emitComments(declaration, true); - - var pullVarDecl = this.semanticInfoChain.getDeclForAST(varDecl); - var isAmbientWithoutInit = pullVarDecl && TypeScript.hasFlag(pullVarDecl.flags, 8 /* Ambient */) && varDecl.equalsValueClause === null; - if (!isAmbientWithoutInit) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.currentVariableDeclaration = declaration; - - for (var i = 0, n = declaration.declarators.nonSeparatorCount(); i < n; i++) { - var declarator = declaration.declarators.nonSeparatorAt(i); - - if (i > 0) { - this.writeToOutput(", "); - } - - this.emit(declarator); - } - this.currentVariableDeclaration = prevVariableDeclaration; - - this.recordSourceMappingEnd(declaration); - } - - this.emitComments(declaration, false); - }; - - Emitter.prototype.emitMemberVariableDeclaration = function (varDecl) { - TypeScript.Debug.assert(!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause); - - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - - this.emitComments(varDecl, true); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - var quotedOrNumber = TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */; - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - - if (quotedOrNumber) { - this.writeToOutput("this["); - } else { - this.writeToOutput("this."); - } - - this.writeToOutputWithSourceMapRecord(varDecl.variableDeclarator.propertyName.text(), varDecl.variableDeclarator.propertyName); - - if (quotedOrNumber) { - this.writeToOutput("]"); - } - - if (varDecl.variableDeclarator.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.variableDeclarator.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - if (this.emitState.container !== 6 /* Args */) { - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitVariableDeclarator = function (varDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(varDecl); - this.pushDecl(pullDecl); - if (pullDecl && (pullDecl.flags & 8 /* Ambient */) === 8 /* Ambient */) { - this.emitAmbientVarDecl(varDecl); - } else { - this.emitComments(varDecl, true); - this.recordSourceMappingStart(this.currentVariableDeclaration); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.propertyName.text(); - - var symbol = this.semanticInfoChain.getSymbolForAST(varDecl); - var parentSymbol = symbol ? symbol.getContainer() : null; - var parentDecl = pullDecl && pullDecl.getParentDecl(); - var parentIsModule = parentDecl && (parentDecl.flags & 102400 /* SomeInitializedModule */); - - if (parentIsModule) { - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.emitVarDeclVar(); - } else { - if (this.emitState.container === 2 /* DynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.moduleName + "."); - } - } - } else { - this.emitVarDeclVar(); - } - - this.writeToOutputWithSourceMapRecord(varDecl.propertyName.text(), varDecl.propertyName); - - if (varDecl.equalsValueClause) { - var prevVariableDeclaration = this.currentVariableDeclaration; - this.emit(varDecl.equalsValueClause); - this.currentVariableDeclaration = prevVariableDeclaration; - } - - this.recordSourceMappingEnd(varDecl); - this.emitComments(varDecl, false); - } - this.currentVariableDeclaration = undefined; - this.popDecl(pullDecl); - }; - - Emitter.prototype.symbolIsUsedInItsEnclosingContainer = function (symbol, dynamic) { - if (typeof dynamic === "undefined") { dynamic = false; } - var symDecls = symbol.getDeclarations(); - - if (symDecls.length) { - var enclosingDecl = this.getEnclosingDecl(); - if (enclosingDecl) { - var parentDecl = symDecls[0].getParentDecl(); - if (parentDecl) { - var symbolDeclarationEnclosingContainer = parentDecl; - var enclosingContainer = enclosingDecl; - - while (symbolDeclarationEnclosingContainer) { - if (symbolDeclarationEnclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - symbolDeclarationEnclosingContainer = symbolDeclarationEnclosingContainer.getParentDecl(); - } - - if (symbolDeclarationEnclosingContainer) { - while (enclosingContainer) { - if (enclosingContainer.kind === (dynamic ? 32 /* DynamicModule */ : 4 /* Container */)) { - break; - } - - enclosingContainer = enclosingContainer.getParentDecl(); - } - } - - if (symbolDeclarationEnclosingContainer && enclosingContainer) { - var same = symbolDeclarationEnclosingContainer === enclosingContainer; - - if (!same && symbol.anyDeclHasFlag(32768 /* InitializedModule */)) { - same = symbolDeclarationEnclosingContainer === enclosingContainer.getParentDecl(); - } - - return same; - } - } - } - } - - return false; - }; - - Emitter.prototype.getPotentialDeclPathInfoForEmit = function (pullSymbol) { - var decl = pullSymbol.getDeclarations()[0]; - var parentDecl = decl.getParentDecl(); - var symbolContainerDeclPath = parentDecl ? parentDecl.getParentPath() : []; - - var enclosingContextDeclPath = this.declStack; - var commonNodeIndex = -1; - - if (enclosingContextDeclPath.length) { - for (var i = symbolContainerDeclPath.length - 1; i >= 0; i--) { - var symbolContainerDeclPathNode = symbolContainerDeclPath[i]; - for (var j = enclosingContextDeclPath.length - 1; j >= 0; j--) { - var enclosingContextDeclPathNode = enclosingContextDeclPath[j]; - if (symbolContainerDeclPathNode === enclosingContextDeclPathNode) { - commonNodeIndex = i; - break; - } - } - - if (commonNodeIndex >= 0) { - break; - } - } - } - - var startingIndex = symbolContainerDeclPath.length - 1; - for (var i = startingIndex - 1; i > commonNodeIndex; i--) { - if (symbolContainerDeclPath[i + 1].flags & 1 /* Exported */) { - startingIndex = i; - } else { - break; - } - } - return { potentialPath: symbolContainerDeclPath, startingIndex: startingIndex }; - }; - - Emitter.prototype.emitDottedNameFromDeclPath = function (declPath, startingIndex, lastIndex) { - for (var i = startingIndex; i <= lastIndex; i++) { - if (declPath[i].kind === 32 /* DynamicModule */ || declPath[i].flags & 65536 /* InitializedDynamicModule */) { - this.writeToOutput("exports."); - } else { - this.writeToOutput(this.getModuleName(declPath[i], true) + "."); - } - } - }; - - Emitter.prototype.emitSymbolContainerNameInEnclosingContext = function (pullSymbol) { - var declPathInfo = this.getPotentialDeclPathInfoForEmit(pullSymbol); - var potentialDeclPath = declPathInfo.potentialPath; - var startingIndex = declPathInfo.startingIndex; - - this.emitDottedNameFromDeclPath(potentialDeclPath, startingIndex, potentialDeclPath.length - 1); - }; - - Emitter.prototype.getSymbolForEmit = function (ast) { - var pullSymbol = this.semanticInfoChain.getSymbolForAST(ast); - var pullSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(ast); - if (pullSymbol && pullSymbolAlias) { - var symbolToCompare = TypeScript.isTypesOnlyLocation(ast) ? pullSymbolAlias.getExportAssignedTypeSymbol() : pullSymbolAlias.getExportAssignedValueSymbol(); - - if (pullSymbol === symbolToCompare) { - pullSymbol = pullSymbolAlias; - pullSymbolAlias = null; - } - } - return { symbol: pullSymbol, aliasSymbol: pullSymbolAlias }; - }; - - Emitter.prototype.emitName = function (name, addThis) { - this.emitComments(name, true); - this.recordSourceMappingStart(name); - if (name.text().length > 0) { - var symbolForEmit = this.getSymbolForEmit(name); - var pullSymbol = symbolForEmit.symbol; - if (!pullSymbol) { - pullSymbol = this.semanticInfoChain.anyTypeSymbol; - } - var pullSymbolAlias = symbolForEmit.aliasSymbol; - var pullSymbolKind = pullSymbol.kind; - var isLocalAlias = pullSymbolAlias && (pullSymbolAlias.getDeclarations()[0].getParentDecl() === this.getEnclosingDecl()); - if (addThis && (this.emitState.container !== 6 /* Args */) && pullSymbol) { - var pullSymbolContainer = pullSymbol.getContainer(); - - if (pullSymbolContainer) { - var pullSymbolContainerKind = pullSymbolContainer.kind; - - if (pullSymbolContainerKind === 8 /* Class */) { - if (pullSymbol.anyDeclHasFlag(16 /* Static */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbolKind === 4096 /* Property */) { - this.emitThis(); - this.writeToOutput("."); - } - } else if (TypeScript.PullHelpers.symbolIsModule(pullSymbolContainer) || pullSymbolContainerKind === 64 /* Enum */ || pullSymbolContainer.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - if (pullSymbolKind === 4096 /* Property */ || pullSymbolKind === 67108864 /* EnumMember */) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && pullSymbolKind === 512 /* Variable */ && !pullSymbol.anyDeclHasFlag(32768 /* InitializedModule */ | 4096 /* Enum */)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !this.symbolIsUsedInItsEnclosingContainer(pullSymbol)) { - this.emitSymbolContainerNameInEnclosingContext(pullSymbol); - } - } else if (pullSymbolContainerKind === 32 /* DynamicModule */ || pullSymbolContainer.anyDeclHasFlag(65536 /* InitializedDynamicModule */)) { - if (pullSymbolKind === 4096 /* Property */) { - this.writeToOutput("exports."); - } else if (pullSymbol.anyDeclHasFlag(1 /* Exported */) && !isLocalAlias && !pullSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */) && pullSymbol.kind !== 32768 /* ConstructorMethod */ && pullSymbol.kind !== 8 /* Class */ && pullSymbol.kind !== 64 /* Enum */) { - this.writeToOutput("exports."); - } - } - } - } - - this.writeToOutput(name.text()); - } - - this.recordSourceMappingEnd(name); - this.emitComments(name, false); - }; - - Emitter.prototype.recordSourceMappingNameStart = function (name) { - if (this.sourceMapper) { - var nameIndex = -1; - if (name) { - if (this.sourceMapper.currentNameIndex.length > 0) { - var parentNameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 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) { - break; - } - } - - if (nameIndex === -1) { - nameIndex = this.sourceMapper.names.length; - this.sourceMapper.names.push(name); - } - } - this.sourceMapper.currentNameIndex.push(nameIndex); - } - }; - - Emitter.prototype.recordSourceMappingNameEnd = function () { - if (this.sourceMapper) { - this.sourceMapper.currentNameIndex.pop(); - } - }; - - Emitter.prototype.recordSourceMappingStart = function (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; - sourceMapping.start.emittedLine = this.emitState.line; - - var lineMap = this.document.lineMap(); - lineMap.fillLineAndCharacterFromPosition(ast.start(), lineCol); - sourceMapping.start.sourceColumn = lineCol.character; - sourceMapping.start.sourceLine = lineCol.line + 1; - lineMap.fillLineAndCharacterFromPosition(ast.end(), lineCol); - sourceMapping.end.sourceColumn = lineCol.character; - sourceMapping.end.sourceLine = lineCol.line + 1; - - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.emittedLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.start.sourceLine)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.sourceLine)); - - if (this.sourceMapper.currentNameIndex.length > 0) { - sourceMapping.nameIndex = this.sourceMapper.currentNameIndex[this.sourceMapper.currentNameIndex.length - 1]; - } - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - siblings.push(sourceMapping); - this.sourceMapper.currentMappings.push(sourceMapping.childMappings); - this.sourceMapper.increaseMappingLevel(ast); - } - }; - - Emitter.prototype.recordSourceMappingEnd = function (ast) { - if (this.sourceMapper && TypeScript.ASTHelpers.isValidAstNode(ast)) { - this.sourceMapper.currentMappings.pop(); - - var siblings = this.sourceMapper.currentMappings[this.sourceMapper.currentMappings.length - 1]; - var sourceMapping = siblings[siblings.length - 1]; - - sourceMapping.end.emittedColumn = this.emitState.column; - sourceMapping.end.emittedLine = this.emitState.line; - - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedColumn)); - TypeScript.Debug.assert(!isNaN(sourceMapping.end.emittedLine)); - - this.sourceMapper.decreaseMappingLevel(ast); - } - }; - - Emitter.prototype.getOutputFiles = function () { - var result = []; - if (this.sourceMapper !== null) { - this.sourceMapper.emitSourceMapping(); - result.push(this.sourceMapper.getOutputFile()); - } - - result.push(this.outfile.getOutputFile()); - return result; - }; - - Emitter.prototype.emitParameterPropertyAndMemberVariableAssignments = function () { - var constructorDecl = getLastConstructor(this.thisClassNode); - - 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(); - this.recordSourceMappingStart(parameter); - this.writeToOutputWithSourceMapRecord("this." + parameter.identifier.text(), parameter.identifier); - this.writeToOutput(" = "); - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter.identifier); - this.writeLineToOutput(";"); - this.recordSourceMappingEnd(parameter); - } - } - } - - for (var i = 0, n = this.thisClassNode.classElements.childCount(); i < n; i++) { - if (this.thisClassNode.classElements.childAt(i).kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = this.thisClassNode.classElements.childAt(i); - if (!TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitIndent(); - this.emitMemberVariableDeclaration(varDecl); - this.writeLineToOutput(""); - } - } - } - }; - - Emitter.prototype.isOnSameLine = function (pos1, pos2) { - var lineMap = this.document.lineMap(); - return lineMap.getLineNumberFromPosition(pos1) === lineMap.getLineNumberFromPosition(pos2); - }; - - Emitter.prototype.emitCommaSeparatedList = function (parent, list, buffer, preserveNewLines) { - if (list === null || list.nonSeparatorCount() === 0) { - return; - } - - var startLine = preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(0).end()); - - if (preserveNewLines) { - this.indenter.increaseIndent(); - } - - if (startLine) { - this.writeLineToOutput(""); - } else { - this.writeToOutput(buffer); - } - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - var emitNode = list.nonSeparatorAt(i); - - this.emitJavascript(emitNode, startLine); - - if (i < (n - 1)) { - startLine = preserveNewLines && !this.isOnSameLine(emitNode.end(), list.nonSeparatorAt(i + 1).start()); - if (startLine) { - this.writeLineToOutput(","); - } else { - this.writeToOutput(", "); - } - } - } - - if (preserveNewLines) { - this.indenter.decreaseIndent(); - } - - if (preserveNewLines && !this.isOnSameLine(parent.end(), list.nonSeparatorAt(list.nonSeparatorCount() - 1).end())) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(buffer); - } - }; - - Emitter.prototype.emitList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.childCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitSeparatedList = function (list, useNewLineSeparator, startInclusive, endExclusive) { - if (typeof useNewLineSeparator === "undefined") { useNewLineSeparator = true; } - if (typeof startInclusive === "undefined") { startInclusive = 0; } - if (typeof endExclusive === "undefined") { endExclusive = list.nonSeparatorCount(); } - if (list === null) { - return; - } - - this.emitComments(list, true); - var lastEmittedNode = null; - - for (var i = startInclusive; i < endExclusive; i++) { - var node = list.nonSeparatorAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - if (useNewLineSeparator) { - this.writeLineToOutput(""); - } - - lastEmittedNode = node; - } - } - - this.emitComments(list, false); - }; - - Emitter.prototype.isDirectivePrologueElement = function (node) { - if (node.kind() === 149 /* ExpressionStatement */) { - var exprStatement = node; - return exprStatement.expression.kind() === 14 /* StringLiteral */; - } - - return false; - }; - - Emitter.prototype.emitSpaceBetweenConstructs = function (node1, node2) { - if (node1 === null || node2 === null) { - return; - } - - if (node1.start() === -1 || node1.end() === -1 || node2.start() === -1 || node2.end() === -1) { - return; - } - - var lineMap = this.document.lineMap(); - var node1EndLine = lineMap.getLineNumberFromPosition(node1.end()); - var node2StartLine = lineMap.getLineNumberFromPosition(node2.start()); - - if ((node2StartLine - node1EndLine) > 1) { - this.writeLineToOutput("", true); - } - }; - - Emitter.prototype.getDetachedComments = function (element) { - var preComments = element.preComments(); - if (preComments) { - var lineMap = this.document.lineMap(); - - var detachedComments = []; - var lastComment = null; - - for (var i = 0, n = preComments.length; i < n; i++) { - var comment = preComments[i]; - - if (lastComment) { - var lastCommentLine = lineMap.getLineNumberFromPosition(lastComment.end()); - var commentLine = lineMap.getLineNumberFromPosition(comment.start()); - - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - detachedComments.push(comment); - lastComment = comment; - } - - var lastCommentLine = lineMap.getLineNumberFromPosition(TypeScript.ArrayUtilities.last(detachedComments).end()); - var astLine = lineMap.getLineNumberFromPosition(element.start()); - if (astLine >= lastCommentLine + 2) { - return detachedComments; - } - } - - return []; - }; - - Emitter.prototype.emitPossibleCopyrightHeaders = function (script) { - this.emitDetachedComments(script.moduleElements); - }; - - Emitter.prototype.emitDetachedComments = function (list) { - if (list.childCount() > 0) { - var firstElement = list.childAt(0); - - this.detachedCommentsElement = firstElement; - this.emitCommentsArray(this.getDetachedComments(this.detachedCommentsElement), false); - } - }; - - Emitter.prototype.emitScriptElements = function (sourceUnit) { - var list = sourceUnit.moduleElements; - - this.emitPossibleCopyrightHeaders(sourceUnit); - - for (var i = 0, n = list.childCount(); i < n; i++) { - var node = list.childAt(i); - - if (!this.isDirectivePrologueElement(node)) { - break; - } - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - } - - this.emitPrologue(sourceUnit); - - var isExternalModule = this.document.isExternalModule(); - var isNonElidedExternalModule = isExternalModule && !TypeScript.ASTHelpers.scriptIsElided(sourceUnit); - if (isNonElidedExternalModule) { - this.recordSourceMappingStart(sourceUnit); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - var dependencyList = "[\"require\", \"exports\""; - var importList = "require, exports"; - - var importAndDependencyList = this.getModuleImportAndDependencyList(sourceUnit); - importList += importAndDependencyList.importList; - dependencyList += importAndDependencyList.dependencyList + "]"; - - this.writeLineToOutput("define(" + dependencyList + "," + " function(" + importList + ") {"); - } - } - - if (isExternalModule) { - var temp = this.setContainer(2 /* DynamicModule */); - - var svModuleName = this.moduleName; - this.moduleName = sourceUnit.fileName(); - if (TypeScript.isTSFile(this.moduleName)) { - this.moduleName = this.moduleName.substring(0, this.moduleName.length - ".ts".length); - } - - this.setExportAssignment(null); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.increaseIndent(); - } - - var externalModule = this.semanticInfoChain.getDeclForAST(this.document.sourceUnit()); - - if (TypeScript.hasFlag(externalModule.flags, 262144 /* MustCaptureThis */)) { - this.writeCaptureThisStatement(sourceUnit); - } - - this.pushDecl(externalModule); - } - - this.emitList(list, true, i, n); - - if (isExternalModule) { - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - this.indenter.decreaseIndent(); - } - - if (isNonElidedExternalModule) { - var exportAssignment = this.getExportAssignment(); - var exportAssignmentIdentifierText = exportAssignment ? exportAssignment.identifier.text() : null; - var exportAssignmentValueSymbol = externalModule.getSymbol().getExportAssignedValueSymbol(); - - if (this.emitOptions.compilationSettings().moduleGenTarget() === 2 /* Asynchronous */) { - if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.indenter.increaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + exportAssignmentIdentifierText, exportAssignment); - this.writeLineToOutput(";"); - this.indenter.decreaseIndent(); - } - this.writeToOutput("});"); - } else if (exportAssignmentIdentifierText && exportAssignmentValueSymbol && !(exportAssignmentValueSymbol.kind & 58720272 /* SomeTypeReference */)) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("module.exports = " + exportAssignmentIdentifierText, exportAssignment); - this.writeToOutput(";"); - } - - this.recordSourceMappingEnd(sourceUnit); - this.writeLineToOutput(""); - } - - this.setContainer(temp); - this.moduleName = svModuleName; - this.popDecl(externalModule); - } - }; - - Emitter.prototype.emitConstructorStatements = function (funcDecl) { - var list = funcDecl.block.statements; - - if (list === null) { - return; - } - - this.emitComments(list, true); - - var emitPropertyAssignmentsAfterSuperCall = TypeScript.ASTHelpers.getExtendsHeritageClause(this.thisClassNode.heritageClauses) !== null; - var propertyAssignmentIndex = emitPropertyAssignmentsAfterSuperCall ? 1 : 0; - var lastEmittedNode = null; - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - var node = list.childAt(i); - - if (this.shouldEmit(node)) { - this.emitSpaceBetweenConstructs(lastEmittedNode, node); - - this.emitJavascript(node, true); - this.writeLineToOutput(""); - - lastEmittedNode = node; - } - } - - if (i === propertyAssignmentIndex) { - this.emitParameterPropertyAndMemberVariableAssignments(); - } - - this.emitComments(list, false); - }; - - Emitter.prototype.emitJavascript = function (ast, startLine) { - if (ast === null) { - return; - } - - if (startLine && this.indenter.indentAmt > 0) { - this.emitIndent(); - } - - this.emit(ast); - }; - - Emitter.prototype.emitAccessorMemberDeclaration = function (funcDecl, name, className, isProto) { - if (funcDecl.kind() !== 139 /* GetAccessor */) { - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - if (accessorSymbol.getGetter()) { - return; - } - } - - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - - this.writeToOutput("Object.defineProperty(" + className); - if (isProto) { - this.writeToOutput(".prototype, "); - } else { - this.writeToOutput(", "); - } - - var functionName = name.text(); - if (TypeScript.isQuoted(functionName)) { - this.writeToOutput(functionName); - } else { - this.writeToOutput('"' + functionName + '"'); - } - - this.writeLineToOutput(", {"); - - this.indenter.increaseIndent(); - - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - if (accessors.getter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.getter); - this.emitComments(accessors.getter, true); - this.writeToOutput("get: "); - this.emitAccessorBody(accessors.getter, accessors.getter.parameterList, accessors.getter.block); - this.writeLineToOutput(","); - } - - if (accessors.setter) { - this.emitIndent(); - this.recordSourceMappingStart(accessors.setter); - this.emitComments(accessors.setter, true); - this.writeToOutput("set: "); - this.emitAccessorBody(accessors.setter, accessors.setter.parameterList, accessors.setter.block); - this.writeLineToOutput(","); - } - - this.emitIndent(); - this.writeLineToOutput("enumerable: true,"); - this.emitIndent(); - this.writeLineToOutput("configurable: true"); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeLineToOutput("});"); - this.recordSourceMappingEnd(funcDecl); - }; - - Emitter.prototype.emitAccessorBody = function (funcDecl, parameterList, block) { - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(null, funcDecl, parameters, block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClass = function (classDecl) { - var pullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.pushDecl(pullDecl); - - var svClassNode = this.thisClassNode; - this.thisClassNode = classDecl; - var className = classDecl.identifier.text(); - this.emitComments(classDecl, true); - var temp = this.setContainer(3 /* Class */); - - this.recordSourceMappingStart(classDecl); - this.writeToOutput("var " + className); - - var hasBaseClass = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses) !== null; - var baseTypeReference = null; - var varDecl = null; - - if (hasBaseClass) { - this.writeLineToOutput(" = (function (_super) {"); - } else { - this.writeLineToOutput(" = (function () {"); - } - - this.recordSourceMappingNameStart(className); - this.indenter.increaseIndent(); - - if (hasBaseClass) { - baseTypeReference = TypeScript.ASTHelpers.getExtendsHeritageClause(classDecl.heritageClauses).typeNames.nonSeparatorAt(0); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("__extends(" + className + ", _super)", baseTypeReference); - this.writeLineToOutput(";"); - } - - this.emitIndent(); - - var constrDecl = getLastConstructor(classDecl); - - if (constrDecl) { - this.emit(constrDecl); - this.writeLineToOutput(""); - } else { - this.recordSourceMappingStart(classDecl); - - this.indenter.increaseIndent(); - this.writeLineToOutput("function " + classDecl.identifier.text() + "() {"); - this.recordSourceMappingNameStart("constructor"); - if (hasBaseClass) { - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("_super.apply(this, arguments)", baseTypeReference); - this.writeLineToOutput(";"); - } - - if (this.shouldCaptureThis(classDecl)) { - this.writeCaptureThisStatement(classDecl); - } - - this.emitParameterPropertyAndMemberVariableAssignments(); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.writeLineToOutput(""); - - this.recordSourceMappingNameEnd(); - this.recordSourceMappingEnd(classDecl); - } - - this.emitClassMembers(classDecl); - - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("return " + className + ";", classDecl.closeBraceToken); - this.writeLineToOutput(""); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutputWithSourceMapRecord("}", classDecl.closeBraceToken); - this.recordSourceMappingNameEnd(); - this.recordSourceMappingStart(classDecl); - this.writeToOutput(")("); - if (hasBaseClass) { - this.emitJavascript(baseTypeReference, false); - } - this.writeToOutput(");"); - this.recordSourceMappingEnd(classDecl); - - if ((temp === 1 /* Module */ || temp === 2 /* DynamicModule */) && TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - this.writeLineToOutput(""); - this.emitIndent(); - var modName = temp === 1 /* Module */ ? this.moduleName : "exports"; - this.writeToOutputWithSourceMapRecord(modName + "." + className + " = " + className + ";", classDecl); - } - - this.recordSourceMappingEnd(classDecl); - this.emitComments(classDecl, false); - this.setContainer(temp); - this.thisClassNode = svClassNode; - - this.popDecl(pullDecl); - }; - - Emitter.prototype.emitClassMembers = function (classDecl) { - var lastEmittedMember = null; - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 139 /* GetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var getter = memberDecl; - this.emitAccessorMemberDeclaration(getter, getter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(getter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 140 /* SetAccessor */) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - var setter = memberDecl; - this.emitAccessorMemberDeclaration(setter, setter.propertyName, classDecl.identifier.text(), !TypeScript.hasModifier(setter.modifiers, 16 /* Static */)); - lastEmittedMember = memberDecl; - } else if (memberDecl.kind() === 135 /* MemberFunctionDeclaration */) { - var memberFunction = memberDecl; - - if (memberFunction.block) { - this.emitSpaceBetweenConstructs(lastEmittedMember, memberDecl); - - this.emitClassMemberFunctionDeclaration(classDecl, memberFunction); - lastEmittedMember = memberDecl; - } - } - } - - for (var i = 0, n = classDecl.classElements.childCount(); i < n; i++) { - var memberDecl = classDecl.classElements.childAt(i); - - if (memberDecl.kind() === 136 /* MemberVariableDeclaration */) { - var varDecl = memberDecl; - - if (TypeScript.hasModifier(varDecl.modifiers, 16 /* Static */) && varDecl.variableDeclarator.equalsValueClause) { - this.emitSpaceBetweenConstructs(lastEmittedMember, varDecl); - - this.emitIndent(); - this.recordSourceMappingStart(varDecl); - - var varDeclName = varDecl.variableDeclarator.propertyName.text(); - if (TypeScript.isQuoted(varDeclName) || varDecl.variableDeclarator.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput(classDecl.identifier.text() + "[" + varDeclName + "]"); - } else { - this.writeToOutput(classDecl.identifier.text() + "." + varDeclName); - } - - this.emit(varDecl.variableDeclarator.equalsValueClause); - - this.recordSourceMappingEnd(varDecl); - this.writeLineToOutput(";"); - - lastEmittedMember = varDecl; - } - } - } - }; - - Emitter.prototype.emitClassMemberFunctionDeclaration = function (classDecl, funcDecl) { - this.emitIndent(); - this.recordSourceMappingStart(funcDecl); - this.emitComments(funcDecl, true); - var functionName = funcDecl.propertyName.text(); - - this.writeToOutput(classDecl.identifier.text()); - - if (!TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - this.writeToOutput(".prototype"); - } - - if (TypeScript.isQuoted(functionName) || funcDecl.propertyName.kind() !== 11 /* IdentifierName */) { - this.writeToOutput("[" + functionName + "] = "); - } else { - this.writeToOutput("." + functionName + " = "); - } - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcDecl); - this.writeToOutput("function "); - - this.emitParameterList(funcDecl.callSignature.parameterList); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList); - this.emitFunctionBodyStatements(funcDecl.propertyName.text(), funcDecl, parameters, funcDecl.block, null); - - this.recordSourceMappingEnd(funcDecl); - - this.emitComments(funcDecl, false); - - this.recordSourceMappingEnd(funcDecl); - this.popDecl(pullDecl); - - this.writeLineToOutput(";"); - }; - - Emitter.prototype.requiresExtendsBlock = function (moduleElements) { - for (var i = 0, n = moduleElements.childCount(); i < n; i++) { - var moduleElement = moduleElements.childAt(i); - - if (moduleElement.kind() === 130 /* ModuleDeclaration */) { - var moduleAST = moduleElement; - - if (!TypeScript.hasModifier(moduleAST.modifiers, 8 /* Ambient */) && this.requiresExtendsBlock(moduleAST.moduleElements)) { - return true; - } - } else if (moduleElement.kind() === 131 /* ClassDeclaration */) { - var classDeclaration = moduleElement; - - if (!TypeScript.hasModifier(classDeclaration.modifiers, 8 /* Ambient */) && TypeScript.ASTHelpers.getExtendsHeritageClause(classDeclaration.heritageClauses) !== null) { - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitPrologue = function (sourceUnit) { - if (!this.extendsPrologueEmitted) { - if (this.requiresExtendsBlock(sourceUnit.moduleElements)) { - this.extendsPrologueEmitted = true; - this.writeLineToOutput("var __extends = this.__extends || function (d, b) {"); - this.writeLineToOutput(" for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - this.writeLineToOutput(" function __() { this.constructor = d; }"); - this.writeLineToOutput(" __.prototype = b.prototype;"); - this.writeLineToOutput(" d.prototype = new __();"); - this.writeLineToOutput("};"); - } - } - - if (!this.globalThisCapturePrologueEmitted) { - if (this.shouldCaptureThis(sourceUnit)) { - this.globalThisCapturePrologueEmitted = true; - this.writeLineToOutput(this.captureThisStmtString); - } - } - }; - - Emitter.prototype.emitThis = function () { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutput("_this"); - } else { - this.writeToOutput("this"); - } - }; - - Emitter.prototype.emitBlockOrStatement = function (node) { - if (node.kind() === 146 /* Block */) { - this.emit(node); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emitJavascript(node, true); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitLiteralExpression = function (expression) { - switch (expression.kind()) { - case 32 /* NullKeyword */: - this.writeToOutputWithSourceMapRecord("null", expression); - break; - case 24 /* FalseKeyword */: - this.writeToOutputWithSourceMapRecord("false", expression); - break; - case 37 /* TrueKeyword */: - this.writeToOutputWithSourceMapRecord("true", expression); - break; - default: - throw TypeScript.Errors.abstract(); - } - }; - - Emitter.prototype.emitThisExpression = function (expression) { - if (!this.inWithBlock && this.inArrowFunction) { - this.writeToOutputWithSourceMapRecord("_this", expression); - } else { - this.writeToOutputWithSourceMapRecord("this", expression); - } - }; - - Emitter.prototype.emitSuperExpression = function (expression) { - this.writeToOutputWithSourceMapRecord("_super.prototype", expression); - }; - - Emitter.prototype.emitParenthesizedExpression = function (parenthesizedExpression) { - if (parenthesizedExpression.expression.kind() === 220 /* CastExpression */ && parenthesizedExpression.openParenTrailingComments === null) { - this.emit(parenthesizedExpression.expression); - } else { - this.recordSourceMappingStart(parenthesizedExpression); - this.writeToOutput("("); - this.emitCommentsArray(parenthesizedExpression.openParenTrailingComments, false); - this.emit(parenthesizedExpression.expression); - this.writeToOutput(")"); - this.recordSourceMappingEnd(parenthesizedExpression); - } - }; - - Emitter.prototype.emitCastExpression = function (expression) { - this.emit(expression.expression); - }; - - Emitter.prototype.emitPrefixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 167 /* LogicalNotExpression */: - this.writeToOutput("!"); - this.emit(expression.operand); - break; - case 166 /* BitwiseNotExpression */: - this.writeToOutput("~"); - this.emit(expression.operand); - break; - case 165 /* NegateExpression */: - this.writeToOutput("-"); - if (expression.operand.kind() === 165 /* NegateExpression */ || expression.operand.kind() === 169 /* PreDecrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 164 /* PlusExpression */: - this.writeToOutput("+"); - if (expression.operand.kind() === 164 /* PlusExpression */ || expression.operand.kind() === 168 /* PreIncrementExpression */) { - this.writeToOutput(" "); - } - this.emit(expression.operand); - break; - case 168 /* PreIncrementExpression */: - this.writeToOutput("++"); - this.emit(expression.operand); - break; - case 169 /* PreDecrementExpression */: - this.writeToOutput("--"); - this.emit(expression.operand); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitPostfixUnaryExpression = function (expression) { - var nodeType = expression.kind(); - - this.recordSourceMappingStart(expression); - switch (nodeType) { - case 210 /* PostIncrementExpression */: - this.emit(expression.operand); - this.writeToOutput("++"); - break; - case 211 /* PostDecrementExpression */: - this.emit(expression.operand); - this.writeToOutput("--"); - break; - default: - throw TypeScript.Errors.abstract(); - } - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitTypeOfExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("typeof "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDeleteExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("delete "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitVoidExpression = function (expression) { - this.recordSourceMappingStart(expression); - this.writeToOutput("void "); - this.emit(expression.expression); - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.canEmitDottedNameMemberAccessExpression = function (expression) { - var memberExpressionNodeType = expression.expression.kind(); - - 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 */) { - return this.canEmitDottedNameMemberAccessExpression(expression.expression); - } - - return true; - } - } - } - - return false; - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionWorker = function (expression, potentialPath, startingIndex, lastIndex) { - this.recordSourceMappingStart(expression); - if (expression.expression.kind() === 212 /* MemberAccessExpression */) { - this.emitDottedNameMemberAccessExpressionRecurse(expression.expression, potentialPath, startingIndex, lastIndex - 1); - } else { - this.emitComments(expression.expression, true); - this.recordSourceMappingStart(expression.expression); - - this.emitDottedNameFromDeclPath(potentialPath, startingIndex, lastIndex - 2); - - this.writeToOutput(expression.expression.text()); - - this.recordSourceMappingEnd(expression.expression); - this.emitComments(expression.expression, false); - } - - this.writeToOutput("."); - this.emitName(expression.name, false); - - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpressionRecurse = function (expression, potentialPath, startingIndex, lastIndex) { - this.emitComments(expression, true); - - if (lastIndex - startingIndex < 1) { - startingIndex = lastIndex - 1; - TypeScript.Debug.assert(startingIndex >= 0); - } - - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialPath, startingIndex, lastIndex); - this.emitComments(expression, false); - }; - - Emitter.prototype.emitDottedNameMemberAccessExpression = function (expression) { - var memberAccessSymbol = this.getSymbolForEmit(expression).symbol; - - var potentialDeclInfo = this.getPotentialDeclPathInfoForEmit(memberAccessSymbol); - this.emitDottedNameMemberAccessExpressionWorker(expression, potentialDeclInfo.potentialPath, potentialDeclInfo.startingIndex, potentialDeclInfo.potentialPath.length); - }; - - Emitter.prototype.emitMemberAccessExpression = function (expression) { - if (!this.tryEmitConstant(expression)) { - if (this.canEmitDottedNameMemberAccessExpression(expression)) { - this.emitDottedNameMemberAccessExpression(expression); - } else { - this.recordSourceMappingStart(expression); - this.emit(expression.expression); - this.writeToOutput("."); - this.emitName(expression.name, false); - this.recordSourceMappingEnd(expression); - } - } - }; - - Emitter.prototype.emitQualifiedName = function (name) { - this.recordSourceMappingStart(name); - - this.emit(name.left); - this.writeToOutput("."); - this.emitName(name.right, false); - - this.recordSourceMappingEnd(name); - }; - - Emitter.prototype.emitBinaryExpression = function (expression) { - this.recordSourceMappingStart(expression); - switch (expression.kind()) { - case 173 /* CommaExpression */: - this.emit(expression.left); - this.writeToOutput(", "); - this.emit(expression.right); - break; - default: { - this.emit(expression.left); - var binOp = TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(expression.kind())); - if (binOp === "instanceof") { - this.writeToOutput(" instanceof "); - } else if (binOp === "in") { - this.writeToOutput(" in "); - } else { - this.writeToOutput(" " + binOp + " "); - } - this.emit(expression.right); - } - } - this.recordSourceMappingEnd(expression); - }; - - Emitter.prototype.emitSimplePropertyAssignment = function (property) { - this.recordSourceMappingStart(property); - this.emit(property.propertyName); - this.writeToOutput(": "); - this.emit(property.expression); - this.recordSourceMappingEnd(property); - }; - - Emitter.prototype.emitFunctionPropertyAssignment = function (funcProp) { - this.recordSourceMappingStart(funcProp); - - this.emit(funcProp.propertyName); - this.writeToOutput(": "); - - var pullFunctionDecl = this.semanticInfoChain.getDeclForAST(funcProp); - - var savedInArrowFunction = this.inArrowFunction; - this.inArrowFunction = false; - - var temp = this.setContainer(5 /* Function */); - var funcName = funcProp.propertyName; - - var pullDecl = this.semanticInfoChain.getDeclForAST(funcProp); - this.pushDecl(pullDecl); - - this.recordSourceMappingStart(funcProp); - this.writeToOutput("function "); - - this.writeToOutput("("); - - var parameters = TypeScript.ASTHelpers.parametersFromParameterList(funcProp.callSignature.parameterList); - this.emitFunctionParameters(parameters); - this.writeToOutput(")"); - - this.emitFunctionBodyStatements(funcProp.propertyName.text(), funcProp, parameters, funcProp.block, null); - - this.recordSourceMappingEnd(funcProp); - - this.recordSourceMappingEnd(funcProp); - - this.emitComments(funcProp, false); - - this.popDecl(pullDecl); - - this.setContainer(temp); - this.inArrowFunction = savedInArrowFunction; - }; - - Emitter.prototype.emitConditionalExpression = function (expression) { - this.emit(expression.condition); - this.writeToOutput(" ? "); - this.emit(expression.whenTrue); - this.writeToOutput(" : "); - this.emit(expression.whenFalse); - }; - - Emitter.prototype.emitThrowStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("throw "); - this.emit(statement.expression); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitExpressionStatement = function (statement) { - var isArrowExpression = statement.expression.kind() === 219 /* SimpleArrowFunctionExpression */ || statement.expression.kind() === 218 /* ParenthesizedArrowFunctionExpression */; - - this.recordSourceMappingStart(statement); - if (isArrowExpression) { - this.writeToOutput("("); - } - - this.emit(statement.expression); - - if (isArrowExpression) { - this.writeToOutput(")"); - } - - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitLabeledStatement = function (statement) { - this.writeToOutputWithSourceMapRecord(statement.identifier.text(), statement.identifier); - this.writeLineToOutput(":"); - this.emitJavascript(statement.statement, true); - }; - - Emitter.prototype.emitBlock = function (block) { - this.recordSourceMappingStart(block); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - if (block.statements) { - this.emitList(block.statements); - } - this.emitCommentsArray(block.closeBraceLeadingComments, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(block); - }; - - Emitter.prototype.emitBreakStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("break"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitContinueStatement = function (jump) { - this.recordSourceMappingStart(jump); - this.writeToOutput("continue"); - - if (jump.identifier) { - this.writeToOutput(" " + jump.identifier.text()); - } - - this.recordSourceMappingEnd(jump); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitWhileStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("while ("); - this.emit(statement.condition); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitDoStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("do"); - this.emitBlockOrStatement(statement.statement); - this.writeToOutputWithSourceMapRecord(" while", statement.whileKeyword); - this.writeToOutput('('); - this.emit(statement.condition); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitIfStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("if ("); - this.emit(statement.condition); - this.writeToOutput(")"); - - this.emitBlockOrStatement(statement.statement); - - if (statement.elseClause) { - if (statement.statement.kind() !== 146 /* Block */) { - this.writeLineToOutput(""); - this.emitIndent(); - } else { - this.writeToOutput(" "); - } - - this.emit(statement.elseClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitElseClause = function (elseClause) { - if (elseClause.statement.kind() === 147 /* IfStatement */) { - this.writeToOutput("else "); - this.emit(elseClause.statement); - } else { - this.writeToOutput("else"); - this.emitBlockOrStatement(elseClause.statement); - } - }; - - Emitter.prototype.emitReturnStatement = function (statement) { - this.recordSourceMappingStart(statement); - if (statement.expression) { - this.writeToOutput("return "); - this.emit(statement.expression); - } else { - this.writeToOutput("return"); - } - this.recordSourceMappingEnd(statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitForInStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.left) { - this.emit(statement.left); - } else { - this.emit(statement.variableDeclaration); - } - this.writeToOutput(" in "); - this.emit(statement.expression); - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitForStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("for ("); - if (statement.variableDeclaration) { - this.emit(statement.variableDeclaration); - } else if (statement.initializer) { - this.emit(statement.initializer); - } - - this.writeToOutput("; "); - this.emitJavascript(statement.condition, false); - this.writeToOutput(";"); - if (statement.incrementor) { - this.writeToOutput(" "); - this.emitJavascript(statement.incrementor, false); - } - this.writeToOutput(")"); - this.emitBlockOrStatement(statement.statement); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitWithStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("with ("); - if (statement.condition) { - this.emit(statement.condition); - } - - this.writeToOutput(")"); - var prevInWithBlock = this.inWithBlock; - this.inWithBlock = true; - this.emitBlockOrStatement(statement.statement); - this.inWithBlock = prevInWithBlock; - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitSwitchStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("switch ("); - this.emit(statement.expression); - this.recordSourceMappingStart(statement.closeParenToken); - this.writeToOutput(")"); - this.recordSourceMappingEnd(statement.closeParenToken); - this.writeLineToOutput(" {"); - this.indenter.increaseIndent(); - this.emitList(statement.switchClauses, false); - this.indenter.decreaseIndent(); - this.emitIndent(); - this.writeToOutput("}"); - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCaseSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("case "); - this.emit(clause.expression); - this.writeToOutput(":"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitSwitchClauseBody = function (body) { - if (body.childCount() === 1 && body.childAt(0).kind() === 146 /* Block */) { - this.emit(body.childAt(0)); - this.writeLineToOutput(""); - } else { - this.writeLineToOutput(""); - this.indenter.increaseIndent(); - this.emit(body); - this.indenter.decreaseIndent(); - } - }; - - Emitter.prototype.emitDefaultSwitchClause = function (clause) { - this.recordSourceMappingStart(clause); - this.writeToOutput("default:"); - - this.emitSwitchClauseBody(clause.statements); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitTryStatement = function (statement) { - this.recordSourceMappingStart(statement); - this.writeToOutput("try "); - this.emit(statement.block); - this.emitJavascript(statement.catchClause, false); - - if (statement.finallyClause) { - this.emit(statement.finallyClause); - } - this.recordSourceMappingEnd(statement); - }; - - Emitter.prototype.emitCatchClause = function (clause) { - this.writeToOutput(" "); - this.recordSourceMappingStart(clause); - this.writeToOutput("catch ("); - this.emit(clause.identifier); - this.writeToOutput(")"); - this.emit(clause.block); - this.recordSourceMappingEnd(clause); - }; - - Emitter.prototype.emitFinallyClause = function (clause) { - this.writeToOutput(" finally"); - this.emit(clause.block); - }; - - Emitter.prototype.emitDebuggerStatement = function (statement) { - this.writeToOutputWithSourceMapRecord("debugger", statement); - this.writeToOutput(";"); - }; - - Emitter.prototype.emitNumericLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitRegularExpressionLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitStringLiteral = function (literal) { - this.writeToOutputWithSourceMapRecord(literal.text(), literal); - }; - - Emitter.prototype.emitEqualsValueClause = function (clause) { - this.writeToOutput(" = "); - this.emit(clause.value); - }; - - Emitter.prototype.emitParameter = function (parameter) { - this.writeToOutputWithSourceMapRecord(parameter.identifier.text(), parameter); - }; - - Emitter.prototype.emitConstructorDeclaration = function (declaration) { - if (declaration.block) { - this.emitConstructor(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitFunctionDeclaration = function (declaration) { - return declaration.preComments() !== null || (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null); - }; - - Emitter.prototype.emitFunctionDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */) && declaration.block !== null) { - this.emitFunction(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.emitSourceUnit = function (sourceUnit) { - if (!this.document.isDeclareFile()) { - var pullDecl = this.semanticInfoChain.getDeclForAST(sourceUnit); - this.pushDecl(pullDecl); - this.emitScriptElements(sourceUnit); - this.popDecl(pullDecl); - - this.emitCommentsArray(sourceUnit.endOfFileTokenLeadingComments, false); - } - }; - - Emitter.prototype.shouldEmitEnumDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.enumIsElided(declaration); - }; - - Emitter.prototype.emitEnumDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.enumIsElided(declaration)) { - this.emitComments(declaration, true); - this.emitEnum(declaration); - this.emitComments(declaration, false); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitModuleDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.ASTHelpers.moduleIsElided(declaration); - }; - - Emitter.prototype.emitModuleDeclaration = function (declaration) { - if (!TypeScript.ASTHelpers.moduleIsElided(declaration)) { - this.emitModuleDeclarationWorker(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitClassDeclaration = function (declaration) { - return declaration.preComments() !== null || !TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */); - }; - - Emitter.prototype.emitClassDeclaration = function (declaration) { - if (!TypeScript.hasModifier(declaration.modifiers, 8 /* Ambient */)) { - this.emitClass(declaration); - } else { - this.emitComments(declaration, true, true); - } - }; - - Emitter.prototype.shouldEmitInterfaceDeclaration = function (declaration) { - return declaration.preComments() !== null; - }; - - Emitter.prototype.emitInterfaceDeclaration = function (declaration) { - this.emitComments(declaration, true, true); - }; - - Emitter.prototype.firstVariableDeclarator = function (statement) { - return statement.declaration.declarators.nonSeparatorAt(0); - }; - - Emitter.prototype.isNotAmbientOrHasInitializer = function (variableStatement) { - return !TypeScript.hasModifier(variableStatement.modifiers, 8 /* Ambient */) || this.firstVariableDeclarator(variableStatement).equalsValueClause !== null; - }; - - Emitter.prototype.shouldEmitVariableStatement = function (statement) { - return statement.preComments() !== null || this.isNotAmbientOrHasInitializer(statement); - }; - - Emitter.prototype.emitVariableStatement = function (statement) { - if (this.isNotAmbientOrHasInitializer(statement)) { - this.emitComments(statement, true); - this.emit(statement.declaration); - this.writeToOutput(";"); - this.emitComments(statement, false); - } else { - this.emitComments(statement, true, true); - } - }; - - Emitter.prototype.emitGenericType = function (type) { - this.emit(type.name); - }; - - Emitter.prototype.shouldEmit = function (ast) { - if (!ast) { - return false; - } - - switch (ast.kind()) { - case 133 /* ImportDeclaration */: - return this.shouldEmitImportDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.shouldEmitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.shouldEmitInterfaceDeclaration(ast); - case 129 /* FunctionDeclaration */: - return this.shouldEmitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.shouldEmitModuleDeclaration(ast); - case 148 /* VariableStatement */: - return this.shouldEmitVariableStatement(ast); - case 223 /* OmittedExpression */: - return false; - case 132 /* EnumDeclaration */: - return this.shouldEmitEnumDeclaration(ast); - } - - return true; - }; - - Emitter.prototype.emit = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 2 /* SeparatedList */: - return this.emitSeparatedList(ast); - case 1 /* List */: - return this.emitList(ast); - case 120 /* SourceUnit */: - return this.emitSourceUnit(ast); - case 133 /* ImportDeclaration */: - return this.emitImportDeclaration(ast); - case 134 /* ExportAssignment */: - return this.setExportAssignment(ast); - case 131 /* ClassDeclaration */: - return this.emitClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitInterfaceDeclaration(ast); - case 11 /* IdentifierName */: - return this.emitName(ast, true); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast); - case 219 /* SimpleArrowFunctionExpression */: - return this.emitSimpleArrowFunctionExpression(ast); - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.emitParenthesizedArrowFunctionExpression(ast); - case 129 /* FunctionDeclaration */: - return this.emitFunctionDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitModuleDeclaration(ast); - case 224 /* VariableDeclaration */: - return this.emitVariableDeclaration(ast); - case 126 /* GenericType */: - return this.emitGenericType(ast); - case 137 /* ConstructorDeclaration */: - return this.emitConstructorDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitEnumDeclaration(ast); - case 243 /* EnumElement */: - return this.emitEnumElement(ast); - case 222 /* FunctionExpression */: - return this.emitFunctionExpression(ast); - case 148 /* VariableStatement */: - return this.emitVariableStatement(ast); - } - - this.emitComments(ast, true); - this.emitWorker(ast); - this.emitComments(ast, false); - }; - - Emitter.prototype.emitWorker = function (ast) { - if (!ast) { - return; - } - - switch (ast.kind()) { - case 13 /* NumericLiteral */: - return this.emitNumericLiteral(ast); - case 12 /* RegularExpressionLiteral */: - return this.emitRegularExpressionLiteral(ast); - case 14 /* StringLiteral */: - return this.emitStringLiteral(ast); - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 37 /* TrueKeyword */: - return this.emitLiteralExpression(ast); - case 35 /* ThisKeyword */: - return this.emitThisExpression(ast); - case 50 /* SuperKeyword */: - return this.emitSuperExpression(ast); - case 217 /* ParenthesizedExpression */: - return this.emitParenthesizedExpression(ast); - case 214 /* ArrayLiteralExpression */: - return this.emitArrayLiteralExpression(ast); - case 211 /* PostDecrementExpression */: - case 210 /* PostIncrementExpression */: - return this.emitPostfixUnaryExpression(ast); - case 167 /* LogicalNotExpression */: - case 166 /* BitwiseNotExpression */: - case 165 /* NegateExpression */: - case 164 /* PlusExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.emitPrefixUnaryExpression(ast); - case 213 /* InvocationExpression */: - return this.emitInvocationExpression(ast); - case 221 /* ElementAccessExpression */: - return this.emitElementAccessExpression(ast); - case 212 /* MemberAccessExpression */: - return this.emitMemberAccessExpression(ast); - case 121 /* QualifiedName */: - return this.emitQualifiedName(ast); - case 173 /* CommaExpression */: - case 174 /* AssignmentExpression */: - case 175 /* AddAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* LogicalOrExpression */: - case 188 /* LogicalAndExpression */: - case 189 /* BitwiseOrExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 191 /* BitwiseAndExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 193 /* NotEqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 197 /* GreaterThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 200 /* InstanceOfExpression */: - case 201 /* InExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 208 /* AddExpression */: - case 209 /* SubtractExpression */: - return this.emitBinaryExpression(ast); - case 186 /* ConditionalExpression */: - return this.emitConditionalExpression(ast); - case 232 /* EqualsValueClause */: - return this.emitEqualsValueClause(ast); - case 242 /* Parameter */: - return this.emitParameter(ast); - case 146 /* Block */: - return this.emitBlock(ast); - case 235 /* ElseClause */: - return this.emitElseClause(ast); - case 147 /* IfStatement */: - return this.emitIfStatement(ast); - case 149 /* ExpressionStatement */: - return this.emitExpressionStatement(ast); - case 139 /* GetAccessor */: - return this.emitGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitSetAccessor(ast); - case 157 /* ThrowStatement */: - return this.emitThrowStatement(ast); - case 150 /* ReturnStatement */: - return this.emitReturnStatement(ast); - case 216 /* ObjectCreationExpression */: - return this.emitObjectCreationExpression(ast); - case 151 /* SwitchStatement */: - return this.emitSwitchStatement(ast); - case 233 /* CaseSwitchClause */: - return this.emitCaseSwitchClause(ast); - case 234 /* DefaultSwitchClause */: - return this.emitDefaultSwitchClause(ast); - case 152 /* BreakStatement */: - return this.emitBreakStatement(ast); - case 153 /* ContinueStatement */: - return this.emitContinueStatement(ast); - case 154 /* ForStatement */: - return this.emitForStatement(ast); - case 155 /* ForInStatement */: - return this.emitForInStatement(ast); - case 158 /* WhileStatement */: - return this.emitWhileStatement(ast); - case 163 /* WithStatement */: - return this.emitWithStatement(ast); - case 220 /* CastExpression */: - return this.emitCastExpression(ast); - case 215 /* ObjectLiteralExpression */: - return this.emitObjectLiteralExpression(ast); - case 240 /* SimplePropertyAssignment */: - return this.emitSimplePropertyAssignment(ast); - case 241 /* FunctionPropertyAssignment */: - return this.emitFunctionPropertyAssignment(ast); - case 156 /* EmptyStatement */: - return this.writeToOutputWithSourceMapRecord(";", ast); - case 159 /* TryStatement */: - return this.emitTryStatement(ast); - case 236 /* CatchClause */: - return this.emitCatchClause(ast); - case 237 /* FinallyClause */: - return this.emitFinallyClause(ast); - case 160 /* LabeledStatement */: - return this.emitLabeledStatement(ast); - case 161 /* DoStatement */: - return this.emitDoStatement(ast); - case 171 /* TypeOfExpression */: - return this.emitTypeOfExpression(ast); - case 170 /* DeleteExpression */: - return this.emitDeleteExpression(ast); - case 172 /* VoidExpression */: - return this.emitVoidExpression(ast); - case 162 /* DebuggerStatement */: - return this.emitDebuggerStatement(ast); - } - }; - return Emitter; - })(); - TypeScript.Emitter = Emitter; - - function getLastConstructor(classDecl) { - return classDecl.classElements.lastOrDefault(function (e) { - return e.kind() === 137 /* ConstructorDeclaration */; - }); - } - TypeScript.getLastConstructor = getLastConstructor; - - function getTrimmedTextLines(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - return comment.fullText().split("\n").map(function (s) { - return s.trim(); - }); - } else { - return [comment.fullText().trim()]; - } - } - TypeScript.getTrimmedTextLines = getTrimmedTextLines; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (typeof markerBaseLength === "undefined") { markerBaseLength = 0; } - var result = memberName.prefix; - - if (memberName.isString()) { - result += memberName.text; - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - - result += memberName.suffix; - return result; - }; - - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function stripStartAndEndQuotes(str) { - var firstCharCode = str && str.charCodeAt(0); - if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - return str.substring(1, str.length - 1); - } - - return str; - } - TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; - - function isSingleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; - } - TypeScript.isSingleQuoted = isSingleQuoted; - - function isDoubleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; - } - TypeScript.isDoubleQuoted = isDoubleQuoted; - - function isQuoted(str) { - return isDoubleQuoted(str) || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; - - var switchToForwardSlashesRegEx = /\\/g; - function switchToForwardSlashes(path) { - return path.replace(switchToForwardSlashesRegEx, "/"); - } - TypeScript.switchToForwardSlashes = switchToForwardSlashes; - - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - - return modName; - } - TypeScript.trimModName = trimModName; - - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; - - function isFileOfExtension(fname, ext) { - var invariantFname = fname.toLocaleUpperCase(); - var invariantExt = ext.toLocaleUpperCase(); - var extLength = invariantExt.length; - return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; - } - - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; - - function isDTSFile(fname) { - return isFileOfExtension(fname, ".d.ts"); - } - TypeScript.isDTSFile = isDTSFile; - - function getPrettyName(modPath, quote, treatAsFileName) { - if (typeof quote === "undefined") { quote = true; } - if (typeof treatAsFileName === "undefined") { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; - - function getPathComponents(path) { - return path.split("/"); - } - TypeScript.getPathComponents = getPathComponents; - - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { - if (typeof isAbsoultePathURL === "undefined") { isAbsoultePathURL = true; } - absoluteModPath = switchToForwardSlashes(absoluteModPath); - - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - - return relativePath + relativePathComponents.join("/"); - } - - if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { - absoluteModPath = "file:///" + absoluteModPath; - } - - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - - function changePathToDTS(modPath) { - return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - - function isRelative(path) { - return path.length > 0 && path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); - } - TypeScript.isRooted = isRooted; - - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - - function convertToDirectoryPath(dirPath) { - if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { - dirPath += "/"; - } - - return dirPath; - } - TypeScript.convertToDirectoryPath = convertToDirectoryPath; - - var normalizePathRegEx = /^\\\\[^\\]/; - function normalizePath(path) { - if (normalizePathRegEx.test(path)) { - path = "file:" + path; - } - var parts = this.getPathComponents(switchToForwardSlashes(path)); - var normalizedParts = []; - - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part === ".") { - continue; - } - - if (normalizedParts.length > 0 && TypeScript.ArrayUtilities.last(normalizedParts) !== ".." && part === "..") { - normalizedParts.pop(); - continue; - } - - normalizedParts.push(part); - } - - return normalizedParts.join("/"); - } - TypeScript.normalizePath = normalizePath; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - - - function isNoDefaultLibMatch(comment) { - var isNoDefaultLibRegex = /^(\/\/\/\s*/gim; - return isNoDefaultLibRegex.exec(comment); - } - - TypeScript.tripleSlashReferenceRegExp = /^(\/\/\/\s*/; - - function getFileReferenceFromReferencePath(fileName, lineMap, position, comment, diagnostics) { - var simpleReferenceRegEx = /^\/\/\/\s*= 7 && fullReference[6] === "true"; - if (isResident) { - TypeScript.CompilerDiagnostics.debugPrint(path + " is resident"); - } - return { - line: 0, - character: 0, - position: 0, - length: 0, - path: TypeScript.switchToForwardSlashes(adjustedPath), - isResident: isResident - }; - } - } - } - - return null; - } - - var scannerWindow = TypeScript.ArrayUtilities.createArray(2048, 0); - var scannerDiagnostics = []; - - function processImports(lineMap, scanner, token, importedFiles) { - var position = 0; - var lineChar = { line: -1, character: -1 }; - - var start = new Date().getTime(); - - while (token.tokenKind !== 10 /* EndOfFileToken */) { - if (token.tokenKind === 49 /* ImportKeyword */) { - var importStart = position + token.leadingTriviaWidth(); - token = scanner.scan(scannerDiagnostics, false); - - if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 107 /* EqualsToken */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 65 /* ModuleKeyword */ || token.tokenKind === 66 /* RequireKeyword */) { - token = scanner.scan(scannerDiagnostics, false); - - if (token.tokenKind === 72 /* OpenParenToken */) { - var afterOpenParenPosition = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - - lineMap.fillLineAndCharacterFromPosition(importStart, lineChar); - - if (token.tokenKind === 14 /* StringLiteral */) { - var ref = { - line: lineChar.line, - character: lineChar.character, - position: afterOpenParenPosition + token.leadingTriviaWidth(), - length: token.width(), - path: TypeScript.stripStartAndEndQuotes(TypeScript.switchToForwardSlashes(token.text())), - isResident: false - }; - importedFiles.push(ref); - } - } - } - } - } - } - - position = scanner.absoluteIndex(); - token = scanner.scan(scannerDiagnostics, false); - } - - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionScanImportsTime += totalTime; - } - - function processTripleSlashDirectives(fileName, lineMap, firstToken) { - var leadingTrivia = firstToken.leadingTrivia(); - - var position = 0; - var lineChar = { line: -1, character: -1 }; - var noDefaultLib = false; - var diagnostics = []; - var referencedFiles = []; - - for (var i = 0, n = leadingTrivia.count(); i < n; i++) { - var trivia = leadingTrivia.syntaxTriviaAt(i); - - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { - var triviaText = trivia.fullText(); - var referencedCode = getFileReferenceFromReferencePath(fileName, lineMap, position, triviaText, diagnostics); - - if (referencedCode) { - lineMap.fillLineAndCharacterFromPosition(position, lineChar); - referencedCode.position = position; - referencedCode.length = trivia.fullWidth(); - referencedCode.line = lineChar.line; - referencedCode.character = lineChar.character; - - referencedFiles.push(referencedCode); - } - - var isNoDefaultLib = isNoDefaultLibMatch(triviaText); - if (isNoDefaultLib) { - noDefaultLib = isNoDefaultLib[3] === "true"; - } - } - - position += trivia.fullWidth(); - } - - return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles }; - } - - function preProcessFile(fileName, sourceText, readImportFiles) { - if (typeof readImportFiles === "undefined") { readImportFiles = true; } - var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = new TypeScript.Scanner(fileName, text, 1 /* EcmaScript5 */, scannerWindow); - - var firstToken = scanner.scan(scannerDiagnostics, false); - - var importedFiles = []; - if (readImportFiles) { - processImports(text.lineMap(), scanner, firstToken, importedFiles); - } - - var properties = processTripleSlashDirectives(fileName, text.lineMap(), firstToken); - - scannerDiagnostics.length = 0; - return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics }; - } - TypeScript.preProcessFile = preProcessFile; - - function getParseOptions(settings) { - return new TypeScript.ParseOptions(settings.codeGenTarget(), settings.allowAutomaticSemicolonInsertion()); - } - TypeScript.getParseOptions = getParseOptions; - - function getReferencedFiles(fileName, sourceText) { - return preProcessFile(fileName, sourceText, false).referencedFiles; - } - TypeScript.getReferencedFiles = getReferencedFiles; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ReferenceResolutionResult = (function () { - function ReferenceResolutionResult() { - this.resolvedFiles = []; - this.diagnostics = []; - this.seenNoDefaultLibTag = false; - } - return ReferenceResolutionResult; - })(); - TypeScript.ReferenceResolutionResult = ReferenceResolutionResult; - - var ReferenceLocation = (function () { - function ReferenceLocation(filePath, lineMap, position, length, isImported) { - this.filePath = filePath; - this.lineMap = lineMap; - this.position = position; - this.length = length; - this.isImported = isImported; - } - return ReferenceLocation; - })(); - - var ReferenceResolver = (function () { - function ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution) { - this.useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this.inputFileNames = inputFileNames; - this.host = host; - this.visited = {}; - } - ReferenceResolver.resolve = function (inputFileNames, host, useCaseSensitiveFileResolution) { - var resolver = new ReferenceResolver(inputFileNames, host, useCaseSensitiveFileResolution); - return resolver.resolveInputFiles(); - }; - - ReferenceResolver.prototype.resolveInputFiles = function () { - var _this = this; - var result = new ReferenceResolutionResult(); - - if (!this.inputFileNames || this.inputFileNames.length <= 0) { - return result; - } - - var referenceLocation = new ReferenceLocation(null, null, 0, 0, false); - this.inputFileNames.forEach(function (fileName) { - return _this.resolveIncludedFile(fileName, referenceLocation, result); - }); - - return result; - }; - - ReferenceResolver.prototype.resolveIncludedFile = function (path, referenceLocation, resolutionResult) { - var normalizedPath = this.getNormalizedFilePath(path, referenceLocation.filePath); - - if (this.isSameFile(normalizedPath, referenceLocation.filePath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.A_file_cannot_have_a_reference_to_itself, null)); - } - - return normalizedPath; - } - - if (!TypeScript.isTSFile(normalizedPath) && !TypeScript.isDTSFile(normalizedPath)) { - var dtsFile = normalizedPath + ".d.ts"; - var tsFile = normalizedPath + ".ts"; - - if (this.host.fileExists(tsFile)) { - normalizedPath = tsFile; - } else { - normalizedPath = dtsFile; - } - } - - if (!this.host.fileExists(normalizedPath)) { - if (!referenceLocation.isImported) { - resolutionResult.diagnostics.push(new TypeScript.Diagnostic(referenceLocation.filePath, referenceLocation.lineMap, referenceLocation.position, referenceLocation.length, TypeScript.DiagnosticCode.Cannot_resolve_referenced_file_0, [path])); - } - - return normalizedPath; - } - - return this.resolveFile(normalizedPath, resolutionResult); - }; - - ReferenceResolver.prototype.resolveImportedFile = function (path, referenceLocation, resolutionResult) { - var isRelativePath = TypeScript.isRelative(path); - var isRootedPath = isRelativePath ? false : TypeScript.isRooted(path); - - if (isRelativePath || isRootedPath) { - return this.resolveIncludedFile(path, referenceLocation, resolutionResult); - } else { - var parentDirectory = this.host.getParentDirectory(referenceLocation.filePath); - var searchFilePath = null; - var dtsFileName = path + ".d.ts"; - var tsFilePath = path + ".ts"; - - var start = new Date().getTime(); - - do { - currentFilePath = this.host.resolveRelativePath(tsFilePath, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - var currentFilePath = this.host.resolveRelativePath(dtsFileName, parentDirectory); - if (this.host.fileExists(currentFilePath)) { - searchFilePath = currentFilePath; - break; - } - - parentDirectory = this.host.getParentDirectory(parentDirectory); - } while(parentDirectory); - - TypeScript.fileResolutionImportFileSearchTime += new Date().getTime() - start; - - if (!searchFilePath) { - return path; - } - - return this.resolveFile(searchFilePath, resolutionResult); - } - }; - - ReferenceResolver.prototype.resolveFile = function (normalizedPath, resolutionResult) { - var _this = this; - var visitedPath = this.isVisited(normalizedPath); - if (!visitedPath) { - this.recordVisitedFile(normalizedPath); - - var start = new Date().getTime(); - var scriptSnapshot = this.host.getScriptSnapshot(normalizedPath); - var totalTime = new Date().getTime() - start; - TypeScript.fileResolutionIOTime += totalTime; - - var lineMap = TypeScript.LineMap1.fromScriptSnapshot(scriptSnapshot); - var preprocessedFileInformation = TypeScript.preProcessFile(normalizedPath, scriptSnapshot); - resolutionResult.diagnostics.push.apply(resolutionResult.diagnostics, preprocessedFileInformation.diagnostics); - - if (preprocessedFileInformation.isLibFile) { - resolutionResult.seenNoDefaultLibTag = true; - } - - var normalizedReferencePaths = []; - preprocessedFileInformation.referencedFiles.forEach(function (fileReference) { - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileReference.position, fileReference.length, false); - var normalizedReferencePath = _this.resolveIncludedFile(fileReference.path, currentReferenceLocation, resolutionResult); - normalizedReferencePaths.push(normalizedReferencePath); - }); - - var normalizedImportPaths = []; - for (var i = 0; i < preprocessedFileInformation.importedFiles.length; i++) { - var fileImport = preprocessedFileInformation.importedFiles[i]; - var currentReferenceLocation = new ReferenceLocation(normalizedPath, lineMap, fileImport.position, fileImport.length, true); - var normalizedImportPath = this.resolveImportedFile(fileImport.path, currentReferenceLocation, resolutionResult); - normalizedImportPaths.push(normalizedImportPath); - } - - resolutionResult.resolvedFiles.push({ - path: normalizedPath, - referencedFiles: normalizedReferencePaths, - importedFiles: normalizedImportPaths - }); - } else { - normalizedPath = visitedPath; - } - - return normalizedPath; - }; - - ReferenceResolver.prototype.getNormalizedFilePath = function (path, parentFilePath) { - var parentFileDirectory = parentFilePath ? this.host.getParentDirectory(parentFilePath) : ""; - var normalizedPath = this.host.resolveRelativePath(path, parentFileDirectory); - return normalizedPath; - }; - - ReferenceResolver.prototype.getUniqueFileId = function (filePath) { - return this.useCaseSensitiveFileResolution ? filePath : filePath.toLocaleUpperCase(); - }; - - ReferenceResolver.prototype.recordVisitedFile = function (filePath) { - this.visited[this.getUniqueFileId(filePath)] = filePath; - }; - - ReferenceResolver.prototype.isVisited = function (filePath) { - return this.visited[this.getUniqueFileId(filePath)]; - }; - - ReferenceResolver.prototype.isSameFile = function (filePath1, filePath2) { - if (!filePath1 || !filePath2) { - return false; - } - - if (this.useCaseSensitiveFileResolution) { - return filePath1 === filePath2; - } else { - return filePath1.toLocaleUpperCase() === filePath2.toLocaleUpperCase(); - } - }; - return ReferenceResolver; - })(); - TypeScript.ReferenceResolver = ReferenceResolver; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var TextWriter = (function () { - function TextWriter(name, writeByteOrderMark, outputFileType) { - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.outputFileType = outputFileType; - this.contents = ""; - this.onNewLine = true; - } - TextWriter.prototype.Write = function (s) { - this.contents += s; - this.onNewLine = false; - }; - - TextWriter.prototype.WriteLine = function (s) { - this.contents += s; - this.contents += TypeScript.newLine(); - this.onNewLine = true; - }; - - TextWriter.prototype.Close = function () { - }; - - TextWriter.prototype.getOutputFile = function () { - return new TypeScript.OutputFile(this.name, this.writeByteOrderMark, this.contents, this.outputFileType); - }; - return TextWriter; - })(); - TypeScript.TextWriter = TextWriter; - - var DeclarationEmitter = (function () { - function DeclarationEmitter(emittingFileName, document, compiler, emitOptions, semanticInfoChain) { - this.emittingFileName = emittingFileName; - this.document = document; - this.compiler = compiler; - this.emitOptions = emitOptions; - this.semanticInfoChain = semanticInfoChain; - this.declFile = null; - this.indenter = new TypeScript.Indenter(); - this.emittedReferencePaths = false; - this.declFile = new TextWriter(emittingFileName, this.document.byteOrderMark !== 0 /* None */, 2 /* Declaration */); - } - DeclarationEmitter.prototype.getOutputFile = function () { - return this.declFile.getOutputFile(); - }; - - DeclarationEmitter.prototype.emitDeclarations = function (sourceUnit) { - this.emitDeclarationsForSourceUnit(sourceUnit); - }; - - DeclarationEmitter.prototype.emitDeclarationsForList = function (list) { - for (var i = 0, n = list.childCount(); i < n; i++) { - this.emitDeclarationsForAST(list.childAt(i)); - } - }; - - DeclarationEmitter.prototype.emitSeparatedList = function (list) { - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.emitDeclarationsForAST(list.nonSeparatorAt(i)); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForAST = function (ast) { - switch (ast.kind()) { - case 148 /* VariableStatement */: - return this.emitDeclarationsForVariableStatement(ast); - case 141 /* PropertySignature */: - return this.emitPropertySignature(ast); - case 225 /* VariableDeclarator */: - return this.emitVariableDeclarator(ast, true, true); - case 136 /* MemberVariableDeclaration */: - return this.emitDeclarationsForMemberVariableDeclaration(ast); - case 137 /* ConstructorDeclaration */: - return this.emitDeclarationsForConstructorDeclaration(ast); - case 139 /* GetAccessor */: - return this.emitDeclarationsForGetAccessor(ast); - case 140 /* SetAccessor */: - return this.emitDeclarationsForSetAccessor(ast); - case 138 /* IndexMemberDeclaration */: - return this.emitIndexMemberDeclaration(ast); - case 144 /* IndexSignature */: - return this.emitIndexSignature(ast); - case 142 /* CallSignature */: - return this.emitCallSignature(ast); - case 143 /* ConstructSignature */: - return this.emitConstructSignature(ast); - case 145 /* MethodSignature */: - return this.emitMethodSignature(ast); - case 129 /* FunctionDeclaration */: - return this.emitDeclarationsForFunctionDeclaration(ast); - case 135 /* MemberFunctionDeclaration */: - return this.emitMemberFunctionDeclaration(ast); - case 131 /* ClassDeclaration */: - return this.emitDeclarationsForClassDeclaration(ast); - case 128 /* InterfaceDeclaration */: - return this.emitDeclarationsForInterfaceDeclaration(ast); - case 133 /* ImportDeclaration */: - return this.emitDeclarationsForImportDeclaration(ast); - case 130 /* ModuleDeclaration */: - return this.emitDeclarationsForModuleDeclaration(ast); - case 132 /* EnumDeclaration */: - return this.emitDeclarationsForEnumDeclaration(ast); - case 134 /* ExportAssignment */: - return this.emitDeclarationsForExportAssignment(ast); - } - }; - - DeclarationEmitter.prototype.getIndentString = function (declIndent) { - if (typeof declIndent === "undefined") { declIndent = false; } - return this.indenter.getIndent(); - }; - - DeclarationEmitter.prototype.emitIndent = function () { - this.declFile.Write(this.getIndentString()); - }; - - DeclarationEmitter.prototype.canEmitDeclarations = function (declAST) { - var container = this.getEnclosingContainer(declAST); - if (container.kind() === 130 /* ModuleDeclaration */ || container.kind() === 120 /* SourceUnit */) { - var pullDecl = this.semanticInfoChain.getDeclForAST(declAST); - if (!TypeScript.hasFlag(pullDecl.flags, 1 /* Exported */)) { - var start = new Date().getTime(); - var declSymbol = this.semanticInfoChain.getSymbolForAST(declAST); - var result = declSymbol && declSymbol.isExternallyVisible(); - TypeScript.declarationEmitIsExternallyVisibleTime += new Date().getTime() - start; - - return result; - } - } - - return true; - }; - - DeclarationEmitter.prototype.getDeclFlagsString = function (pullDecl, typeString) { - var result = this.getIndentString(); - var pullFlags = pullDecl.flags; - - if (TypeScript.hasFlag(pullFlags, 16 /* Static */)) { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } - result += "static "; - } else { - if (TypeScript.hasFlag(pullFlags, 2 /* Private */)) { - result += "private "; - } else if (TypeScript.hasFlag(pullFlags, 4 /* Public */)) { - result += "public "; - } else { - var emitDeclare = !TypeScript.hasFlag(pullFlags, 1 /* Exported */); - - var declAST = this.semanticInfoChain.getASTForDecl(pullDecl); - var container = this.getEnclosingContainer(declAST); - - if (container.kind() === 130 /* ModuleDeclaration */ && TypeScript.ASTHelpers.isAnyNameOfModule(container, declAST)) { - container = this.getEnclosingContainer(container); - } - - var isExternalModule = container.kind() === 120 /* SourceUnit */ && this.document.isExternalModule(); - - if (isExternalModule && TypeScript.hasFlag(pullFlags, 1 /* Exported */)) { - result += "export "; - emitDeclare = true; - } - - if (isExternalModule || container.kind() === 120 /* SourceUnit */) { - if (emitDeclare && typeString !== "interface" && typeString !== "import") { - result += "declare "; - } - } - - result += typeString + " "; - } - } - - return result; - }; - - DeclarationEmitter.prototype.emitDeclFlags = function (declarationAST, typeString) { - this.declFile.Write(this.getDeclFlagsString(this.semanticInfoChain.getDeclForAST(declarationAST), typeString)); - }; - - DeclarationEmitter.prototype.emitTypeNamesMember = function (memberName, emitIndent) { - if (typeof emitIndent === "undefined") { emitIndent = false; } - if (memberName.prefix === "{ ") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.WriteLine("{"); - this.indenter.increaseIndent(); - emitIndent = true; - } else if (memberName.prefix !== "") { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.prefix); - emitIndent = false; - } - - if (memberName.isString()) { - if (emitIndent) { - this.emitIndent(); - } - - this.declFile.Write(memberName.text); - } else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - this.emitTypeNamesMember(ar.entries[index], emitIndent); - if (ar.delim === "; ") { - this.declFile.WriteLine(";"); - } - } - } - - if (memberName.suffix === "}") { - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.Write(memberName.suffix); - } else { - this.declFile.Write(memberName.suffix); - } - }; - - DeclarationEmitter.prototype.emitTypeSignature = function (ast, type) { - var declarationContainerAst = this.getEnclosingContainer(ast); - - var start = new Date().getTime(); - var declarationContainerDecl = this.semanticInfoChain.getDeclForAST(declarationContainerAst); - - var declarationPullSymbol = declarationContainerDecl.getSymbol(); - TypeScript.declarationEmitTypeSignatureTime += new Date().getTime() - start; - - var isNotAGenericType = ast.kind() !== 126 /* GenericType */; - - var typeNameMembers = type.getScopedNameEx(declarationPullSymbol, false, false, false, false, false, isNotAGenericType); - this.emitTypeNamesMember(typeNameMembers); - }; - - DeclarationEmitter.prototype.emitComment = function (comment) { - var text = TypeScript.getTrimmedTextLines(comment); - if (this.declFile.onNewLine) { - this.emitIndent(); - } else if (comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - this.emitIndent(); - } - - this.declFile.Write(text[0]); - - for (var i = 1; i < text.length; i++) { - this.declFile.WriteLine(""); - this.emitIndent(); - this.declFile.Write(text[i]); - } - - if (comment.endsLine || comment.kind() !== 6 /* MultiLineCommentTrivia */) { - this.declFile.WriteLine(""); - } else { - this.declFile.Write(" "); - } - }; - - DeclarationEmitter.prototype.emitDeclarationComments = function (astOrSymbol, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var declComments = astOrSymbol.docComments ? astOrSymbol.docComments() : TypeScript.ASTHelpers.docComments(astOrSymbol); - this.writeDeclarationComments(declComments, endLine); - }; - - DeclarationEmitter.prototype.writeDeclarationComments = function (declComments, endLine) { - if (typeof endLine === "undefined") { endLine = true; } - if (declComments.length > 0) { - for (var i = 0; i < declComments.length; i++) { - this.emitComment(declComments[i]); - } - - if (endLine) { - if (!this.declFile.onNewLine) { - this.declFile.WriteLine(""); - } - } else { - if (this.declFile.onNewLine) { - this.emitIndent(); - } - } - } - }; - - DeclarationEmitter.prototype.emitTypeOfVariableDeclaratorOrParameter = function (boundDecl) { - var start = new Date().getTime(); - var decl = this.semanticInfoChain.getDeclForAST(boundDecl); - var pullSymbol = decl.getSymbol(); - TypeScript.declarationEmitGetBoundDeclTypeTime += new Date().getTime() - start; - - var type = pullSymbol.type; - TypeScript.Debug.assert(type); - - this.declFile.Write(": "); - this.emitTypeSignature(boundDecl, type); - }; - - DeclarationEmitter.prototype.emitPropertySignature = function (varDecl) { - this.emitDeclarationComments(varDecl); - this.emitIndent(); - this.declFile.Write(varDecl.propertyName.text()); - if (varDecl.questionToken) { - this.declFile.Write("?"); - } - - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitVariableDeclarator = function (varDecl, isFirstVarInList, isLastVarInList) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - if (isFirstVarInList) { - this.emitDeclFlags(varDecl, "var"); - } - - this.declFile.Write(varDecl.propertyName.text()); - - if (!TypeScript.hasModifier(TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl), 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - if (isLastVarInList) { - this.declFile.WriteLine(";"); - } else { - this.declFile.Write(", "); - } - } - }; - - DeclarationEmitter.prototype.emitClassElementModifiers = function (modifiers) { - if (TypeScript.hasModifier(modifiers, 16 /* Static */)) { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } - this.declFile.Write("static "); - } else { - if (TypeScript.hasModifier(modifiers, 2 /* Private */)) { - this.declFile.Write("private "); - } else { - this.declFile.Write("public "); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForMemberVariableDeclaration = function (varDecl) { - if (this.canEmitDeclarations(varDecl)) { - this.emitDeclarationComments(varDecl); - - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(varDecl.modifiers); - ; - - this.declFile.Write(varDecl.variableDeclarator.propertyName.text()); - - if (!TypeScript.hasModifier(varDecl.modifiers, 2 /* Private */)) { - this.emitTypeOfVariableDeclaratorOrParameter(varDecl); - } - - this.declFile.WriteLine(";"); - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForVariableStatement = function (variableStatement) { - this.emitDeclarationsForVariableDeclaration(variableStatement.declaration); - }; - - 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); - } - }; - - DeclarationEmitter.prototype.emitArgDecl = function (argDecl, id, isOptional, isPrivate) { - this.indenter.increaseIndent(); - - this.emitDeclarationComments(argDecl, false); - this.declFile.Write(id.text()); - if (isOptional) { - this.declFile.Write("?"); - } - - this.indenter.decreaseIndent(); - - if (!isPrivate) { - this.emitTypeOfVariableDeclaratorOrParameter(argDecl); - } - }; - - DeclarationEmitter.prototype.isOverloadedCallSignature = function (funcDecl) { - var start = new Date().getTime(); - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDecl.getSymbol(); - TypeScript.declarationEmitIsOverloadedCallSignatureTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - var signatures = funcTypeSymbol.getCallSignatures(); - var result = signatures && signatures.length > 1; - - return result; - }; - - DeclarationEmitter.prototype.emitDeclarationsForConstructorDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("constructor"); - - this.declFile.Write("("); - 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.ASTHelpers.parametersFromParameterList(parameterList)); - this.declFile.Write(")"); - }; - - DeclarationEmitter.prototype.emitParameters = function (isPrivate, parameterList) { - var hasLastParameterRestParameter = parameterList.lastParameterIsRest(); - var argsLen = parameterList.length; - if (hasLastParameterRestParameter) { - argsLen--; - } - - for (var i = 0; i < argsLen; i++) { - this.emitArgDecl(parameterList.astAt(i), parameterList.identifierAt(i), parameterList.isOptionalAt(i), isPrivate); - if (i < (argsLen - 1)) { - this.declFile.Write(", "); - } - } - - if (hasLastParameterRestParameter) { - if (parameterList.length > 1) { - this.declFile.Write(", ..."); - } else { - this.declFile.Write("..."); - } - - var index = parameterList.length - 1; - this.emitArgDecl(parameterList.astAt(index), parameterList.identifierAt(index), parameterList.isOptionalAt(index), isPrivate); - } - }; - - DeclarationEmitter.prototype.emitMemberFunctionDeclaration = function (funcDecl) { - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - var funcTypeSymbol = funcSymbol.type; - if (funcDecl.block) { - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } else if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */) && this.isOverloadedCallSignature(funcDecl)) { - var callSignatures = funcTypeSymbol.getCallSignatures(); - TypeScript.Debug.assert(callSignatures && callSignatures.length > 1); - var firstSignature = callSignatures[0].isDefinition() ? callSignatures[1] : callSignatures[0]; - var firstSignatureDecl = firstSignature.getDeclarations()[0]; - var firstFuncDecl = this.semanticInfoChain.getASTForDecl(firstSignatureDecl); - if (firstFuncDecl !== funcDecl) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitDeclarationComments(funcDecl); - - this.emitDeclFlags(funcDecl, "function"); - var id = funcDecl.propertyName.text(); - this.declFile.Write(id); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - var isPrivate = TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */); - - this.emitParameterList(isPrivate, funcDecl.callSignature.parameterList); - - if (!isPrivate) { - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitCallSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - this.emitDeclarationComments(funcDecl); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.typeParameterList, funcSignature); - - this.emitIndent(); - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitConstructSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("new"); - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitMethodSignature = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write(funcDecl.propertyName.text()); - if (funcDecl.questionToken) { - this.declFile.Write("? "); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForFunctionDeclaration = function (funcDecl) { - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - - var start = new Date().getTime(); - var funcSymbol = this.semanticInfoChain.getSymbolForAST(funcDecl); - - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime += new Date().getTime() - start; - - if (funcDecl.block) { - var funcTypeSymbol = funcSymbol.type; - var constructSignatures = funcTypeSymbol.getConstructSignatures(); - if (constructSignatures && constructSignatures.length > 1) { - return; - } else if (this.isOverloadedCallSignature(funcDecl)) { - return; - } - } - - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - var id = funcDecl.identifier.text(); - this.emitDeclFlags(funcDecl, "function"); - if (id !== "" || !funcDecl.identifier || funcDecl.identifier.text().length > 0) { - this.declFile.Write(id); - } else if (funcPullDecl.kind === 2097152 /* ConstructSignature */) { - this.declFile.Write("new"); - } - - var funcSignature = funcPullDecl.getSignatureSymbol(); - this.emitTypeParameters(funcDecl.callSignature.typeParameterList, funcSignature); - - this.declFile.Write("("); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList)); - this.declFile.Write(")"); - - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - if (returnType) { - this.emitTypeSignature(funcDecl, returnType); - } else { - this.declFile.Write("any"); - } - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitIndexMemberDeclaration = function (funcDecl) { - this.emitDeclarationsForAST(funcDecl.indexSignature); - }; - - DeclarationEmitter.prototype.emitIndexSignature = function (funcDecl) { - if (!this.canEmitDeclarations(funcDecl)) { - return; - } - - this.emitDeclarationComments(funcDecl); - - this.emitIndent(); - this.declFile.Write("["); - this.emitParameters(false, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter)); - this.declFile.Write("]"); - - var funcPullDecl = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSignature = funcPullDecl.getSignatureSymbol(); - var returnType = funcSignature.returnType; - this.declFile.Write(": "); - this.emitTypeSignature(funcDecl, returnType); - - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitBaseList = function (bases, useExtendsList) { - if (bases && (bases.nonSeparatorCount() > 0)) { - var qual = useExtendsList ? "extends" : "implements"; - this.declFile.Write(" " + qual + " "); - var basesLen = bases.nonSeparatorCount(); - for (var i = 0; i < basesLen; i++) { - if (i > 0) { - this.declFile.Write(", "); - } - var base = bases.nonSeparatorAt(i); - var baseType = this.semanticInfoChain.getSymbolForAST(base); - this.emitTypeSignature(base, baseType); - } - } - }; - - DeclarationEmitter.prototype.emitAccessorDeclarationComments = function (funcDecl) { - if (this.emitOptions.compilationSettings().removeComments()) { - return; - } - - var start = new Date().getTime(); - var accessors = TypeScript.PullHelpers.getGetterAndSetterFunction(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - var comments = []; - if (accessors.getter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.getter)); - } - if (accessors.setter) { - comments = comments.concat(TypeScript.ASTHelpers.docComments(accessors.setter)); - } - - this.writeDeclarationComments(comments); - }; - - DeclarationEmitter.prototype.emitDeclarationsForGetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitDeclarationsForSetAccessor = function (funcDecl) { - this.emitMemberAccessorDeclaration(funcDecl, funcDecl.modifiers, funcDecl.propertyName); - }; - - DeclarationEmitter.prototype.emitMemberAccessorDeclaration = function (funcDecl, modifiers, name) { - var start = new Date().getTime(); - var accessorSymbol = TypeScript.PullHelpers.getAccessorSymbol(funcDecl, this.semanticInfoChain); - TypeScript.declarationEmitGetAccessorFunctionTime += new Date().getTime(); - - if (funcDecl.kind() === 140 /* SetAccessor */ && accessorSymbol.getGetter()) { - return; - } - - var isPrivate = TypeScript.hasModifier(modifiers, 2 /* Private */); - this.emitAccessorDeclarationComments(funcDecl); - this.declFile.Write(this.getIndentString()); - this.emitClassElementModifiers(modifiers); - this.declFile.Write(name.text()); - if (!isPrivate) { - this.declFile.Write(" : "); - var type = accessorSymbol.type; - this.emitTypeSignature(funcDecl, type); - } - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.emitClassMembersFromConstructorDefinition = function (funcDecl) { - var argsLen = funcDecl.callSignature.parameterList.parameters.nonSeparatorCount(); - if (TypeScript.lastParameterIsRest(funcDecl.callSignature.parameterList)) { - argsLen--; - } - - 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(";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForClassDeclaration = function (classDecl) { - if (!this.canEmitDeclarations(classDecl)) { - return; - } - - var className = classDecl.identifier.text(); - this.emitDeclarationComments(classDecl); - var classPullDecl = this.semanticInfoChain.getDeclForAST(classDecl); - this.emitDeclFlags(classDecl, "class"); - this.declFile.Write(className); - - this.emitTypeParameters(classDecl.typeParameterList); - this.emitHeritageClauses(classDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - var constructorDecl = TypeScript.getLastConstructor(classDecl); - if (constructorDecl) { - this.emitClassMembersFromConstructorDefinition(constructorDecl); - } - - this.emitDeclarationsForList(classDecl.classElements); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitHeritageClauses = function (clauses) { - if (clauses) { - for (var i = 0, n = clauses.childCount(); i < n; i++) { - this.emitHeritageClause(clauses.childAt(i)); - } - } - }; - - DeclarationEmitter.prototype.emitHeritageClause = function (clause) { - this.emitBaseList(clause.typeNames, clause.kind() === 230 /* ExtendsHeritageClause */); - }; - - DeclarationEmitter.prototype.getEnclosingContainer = function (ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */ || ast.kind() === 128 /* InterfaceDeclaration */ || ast.kind() === 130 /* ModuleDeclaration */ || ast.kind() === 120 /* SourceUnit */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - DeclarationEmitter.prototype.emitTypeParameters = function (typeParams, funcSignature) { - if (!typeParams || !typeParams.typeParameters.nonSeparatorCount()) { - return; - } - - this.declFile.Write("<"); - var containerAst = this.getEnclosingContainer(typeParams); - - var start = new Date().getTime(); - var containerDecl = this.semanticInfoChain.getDeclForAST(containerAst); - var containerSymbol = containerDecl.getSymbol(); - TypeScript.declarationEmitGetTypeParameterSymbolTime += new Date().getTime() - start; - - var typars; - if (funcSignature) { - typars = funcSignature.getTypeParameters(); - } else { - typars = containerSymbol.getTypeArgumentsOrTypeParameters(); - } - - for (var i = 0; i < typars.length; i++) { - if (i) { - this.declFile.Write(", "); - } - - var memberName = typars[i].getScopedNameEx(containerSymbol, false, true); - this.emitTypeNamesMember(memberName); - } - - this.declFile.Write(">"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForInterfaceDeclaration = function (interfaceDecl) { - if (!this.canEmitDeclarations(interfaceDecl)) { - return; - } - - var interfaceName = interfaceDecl.identifier.text(); - this.emitDeclarationComments(interfaceDecl); - var interfacePullDecl = this.semanticInfoChain.getDeclForAST(interfaceDecl); - this.emitDeclFlags(interfaceDecl, "interface"); - this.declFile.Write(interfaceName); - - this.emitTypeParameters(interfaceDecl.typeParameterList); - this.emitHeritageClauses(interfaceDecl.heritageClauses); - this.declFile.WriteLine(" {"); - - this.indenter.increaseIndent(); - - this.emitSeparatedList(interfaceDecl.body.typeMembers); - - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForImportDeclaration = function (importDeclAST) { - var importDecl = this.semanticInfoChain.getDeclForAST(importDeclAST); - var importSymbol = importDecl.getSymbol(); - var isExportedImportDecl = TypeScript.hasModifier(importDeclAST.modifiers, 1 /* Exported */); - - if (isExportedImportDecl || importSymbol.typeUsedExternally() || TypeScript.PullContainerSymbol.usedAsSymbol(importSymbol.getContainer(), importSymbol)) { - this.emitDeclarationComments(importDeclAST); - this.emitIndent(); - if (isExportedImportDecl) { - this.declFile.Write("export "); - } - this.declFile.Write("import "); - this.declFile.Write(importDeclAST.identifier.text() + " = "); - if (importDeclAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - this.declFile.WriteLine("require(" + importDeclAST.moduleReference.stringLiteral.text() + ");"); - } else { - this.declFile.WriteLine(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(importDeclAST.moduleReference.moduleName) + ";"); - } - } - }; - - DeclarationEmitter.prototype.emitDeclarationsForEnumDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - this.emitDeclarationComments(moduleDecl); - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclFlags(moduleDecl, "enum"); - this.declFile.WriteLine(moduleDecl.identifier.text() + " {"); - - this.indenter.increaseIndent(); - var membersLen = moduleDecl.enumElements.nonSeparatorCount(); - for (var j = 0; j < membersLen; j++) { - var memberDecl = moduleDecl.enumElements.nonSeparatorAt(j); - var enumElement = memberDecl; - var enumElementDecl = this.semanticInfoChain.getDeclForAST(enumElement); - this.emitDeclarationComments(enumElement); - this.emitIndent(); - this.declFile.Write(enumElement.propertyName.text()); - if (enumElementDecl.constantValue !== null) { - this.declFile.Write(" = " + enumElementDecl.constantValue); - } - this.declFile.WriteLine(","); - } - this.indenter.decreaseIndent(); - - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForModuleDeclaration = function (moduleDecl) { - if (!this.canEmitDeclarations(moduleDecl)) { - return; - } - - var modulePullDecl = this.semanticInfoChain.getDeclForAST(moduleDecl); - this.emitDeclarationComments(moduleDecl); - - var name = moduleDecl.stringLiteral || TypeScript.ArrayUtilities.first(TypeScript.getModuleNames(moduleDecl.name)); - this.emitDeclFlags(name, "module"); - - if (moduleDecl.stringLiteral) { - this.declFile.Write(moduleDecl.stringLiteral.text()); - } else { - this.declFile.Write(TypeScript.ASTHelpers.getNameOfIdenfierOrQualifiedName(moduleDecl.name)); - } - - this.declFile.WriteLine(" {"); - this.indenter.increaseIndent(); - - this.emitDeclarationsForList(moduleDecl.moduleElements); - - this.indenter.decreaseIndent(); - this.emitIndent(); - this.declFile.WriteLine("}"); - }; - - DeclarationEmitter.prototype.emitDeclarationsForExportAssignment = function (ast) { - this.emitIndent(); - this.declFile.Write("export = "); - this.declFile.Write(ast.identifier.text()); - this.declFile.WriteLine(";"); - }; - - DeclarationEmitter.prototype.resolveScriptReference = function (document, reference) { - if (!this.emitOptions.compilationSettings().noResolve() || TypeScript.isRooted(reference)) { - return reference; - } - - var documentDir = TypeScript.convertToDirectoryPath(TypeScript.switchToForwardSlashes(TypeScript.getRootFilePath(document.fileName))); - var resolvedReferencePath = this.emitOptions.resolvePath(documentDir + reference); - return resolvedReferencePath; - }; - - DeclarationEmitter.prototype.emitReferencePaths = function (sourceUnit) { - if (this.emittedReferencePaths) { - return; - } - - var documents = []; - if (this.document.emitToOwnOutputFile()) { - var scriptReferences = this.document.referencedFiles; - var addedGlobalDocument = false; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(this.document, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.emitToOwnOutputFile() || document.isDeclareFile() || !addedGlobalDocument)) { - documents = documents.concat(document); - - if (!document.isDeclareFile() && document.isExternalModule()) { - addedGlobalDocument = true; - } - } - } - } else { - var fileNames = this.compiler.fileNames(); - for (var i = 0; i < fileNames.length; i++) { - var doc = this.compiler.getDocument(fileNames[i]); - if (!doc.isDeclareFile() && !doc.isExternalModule()) { - var scriptReferences = doc.referencedFiles; - for (var j = 0; j < scriptReferences.length; j++) { - var currentReference = this.resolveScriptReference(doc, scriptReferences[j]); - var document = this.compiler.getDocument(currentReference); - - if (document && (document.isDeclareFile() || document.isExternalModule())) { - for (var k = 0; k < documents.length; k++) { - if (documents[k] === document) { - break; - } - } - - if (k === documents.length) { - documents = documents.concat(document); - } - } - } - } - } - } - - var emittingFilePath = documents.length ? TypeScript.getRootFilePath(this.emittingFileName) : null; - for (var i = 0; i < documents.length; i++) { - var document = documents[i]; - var declFileName; - if (document.isDeclareFile()) { - declFileName = document.fileName; - } else { - declFileName = this.compiler.mapOutputFileName(document, this.emitOptions, TypeScript.TypeScriptCompiler.mapToDTSFileName); - } - - declFileName = TypeScript.getRelativePathToFixedPath(emittingFilePath, declFileName, false); - this.declFile.WriteLine('/// '); - } - - this.emittedReferencePaths = true; - }; - - DeclarationEmitter.prototype.emitDeclarationsForSourceUnit = function (sourceUnit) { - this.emitReferencePaths(sourceUnit); - this.emitDeclarationsForList(sourceUnit.moduleElements); - }; - return DeclarationEmitter; - })(); - TypeScript.DeclarationEmitter = DeclarationEmitter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var BloomFilter = (function () { - function BloomFilter(expectedCount) { - var m = Math.max(1, BloomFilter.computeM(expectedCount)); - var k = Math.max(1, BloomFilter.computeK(expectedCount)); - ; - - var sizeInEvenBytes = (m + 7) & ~7; - - this.bitArray = []; - for (var i = 0, len = sizeInEvenBytes; i < len; i++) { - this.bitArray[i] = false; - } - this.hashFunctionCount = k; - } - BloomFilter.computeM = function (expectedCount) { - var p = BloomFilter.falsePositiveProbability; - var n = expectedCount; - - var numerator = n * Math.log(p); - var denominator = Math.log(1.0 / Math.pow(2.0, Math.log(2.0))); - return Math.ceil(numerator / denominator); - }; - - BloomFilter.computeK = function (expectedCount) { - var n = expectedCount; - var m = BloomFilter.computeM(expectedCount); - - var temp = Math.log(2.0) * m / n; - return Math.round(temp); - }; - - BloomFilter.prototype.computeHash = function (key, seed) { - return TypeScript.Hash.computeMurmur2StringHashCode(key, seed); - }; - - BloomFilter.prototype.addKeys = function (keys) { - for (var name in keys) { - if (keys[name]) { - this.add(name); - } - } - }; - - BloomFilter.prototype.add = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - this.bitArray[Math.abs(hash)] = true; - } - }; - - BloomFilter.prototype.probablyContains = function (value) { - for (var i = 0; i < this.hashFunctionCount; i++) { - var hash = this.computeHash(value, i); - hash = hash % this.bitArray.length; - if (!this.bitArray[Math.abs(hash)]) { - return false; - } - } - - return true; - }; - - BloomFilter.prototype.isEquivalent = function (filter) { - return BloomFilter.isEquivalent(this.bitArray, filter.bitArray) && this.hashFunctionCount === filter.hashFunctionCount; - }; - - BloomFilter.isEquivalent = function (array1, array2) { - if (array1.length !== array2.length) { - return false; - } - - for (var i = 0; i < array1.length; i++) { - if (array1[i] !== array2[i]) { - return false; - } - } - - return true; - }; - BloomFilter.falsePositiveProbability = 0.0001; - return BloomFilter; - })(); - TypeScript.BloomFilter = BloomFilter; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var IdentifierWalker = (function (_super) { - __extends(IdentifierWalker, _super); - function IdentifierWalker(list) { - _super.call(this); - this.list = list; - } - IdentifierWalker.prototype.visitToken = function (token) { - this.list[token.text()] = true; - }; - return IdentifierWalker; - })(TypeScript.SyntaxWalker); - TypeScript.IdentifierWalker = IdentifierWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var CompilationSettings = (function () { - function CompilationSettings() { - this.propagateEnumConstants = false; - this.removeComments = false; - this.watch = false; - this.noResolve = false; - this.allowAutomaticSemicolonInsertion = true; - this.noImplicitAny = false; - this.noLib = false; - this.codeGenTarget = 0 /* EcmaScript3 */; - this.moduleGenTarget = 0 /* Unspecified */; - this.outFileOption = ""; - this.outDirOption = ""; - this.mapSourceFiles = false; - this.mapRoot = ""; - this.sourceRoot = ""; - this.generateDeclarationFiles = false; - 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, createFileLog) { - this._propagateEnumConstants = propagateEnumConstants; - this._removeComments = removeComments; - this._watch = watch; - this._noResolve = noResolve; - this._allowAutomaticSemicolonInsertion = allowAutomaticSemicolonInsertion; - this._noImplicitAny = noImplicitAny; - this._noLib = noLib; - this._codeGenTarget = codeGenTarget; - this._moduleGenTarget = moduleGenTarget; - this._outFileOption = outFileOption; - this._outDirOption = outDirOption; - this._mapSourceFiles = mapSourceFiles; - this._mapRoot = mapRoot; - this._sourceRoot = sourceRoot; - this._generateDeclarationFiles = generateDeclarationFiles; - this._useCaseSensitiveFileResolution = useCaseSensitiveFileResolution; - this._gatherDiagnostics = gatherDiagnostics; - this._codepage = codepage; - this._createFileLog = createFileLog; - } - ImmutableCompilationSettings.prototype.propagateEnumConstants = function () { - return this._propagateEnumConstants; - }; - ImmutableCompilationSettings.prototype.removeComments = function () { - return this._removeComments; - }; - ImmutableCompilationSettings.prototype.watch = function () { - return this._watch; - }; - ImmutableCompilationSettings.prototype.noResolve = function () { - return this._noResolve; - }; - ImmutableCompilationSettings.prototype.allowAutomaticSemicolonInsertion = function () { - return this._allowAutomaticSemicolonInsertion; - }; - ImmutableCompilationSettings.prototype.noImplicitAny = function () { - return this._noImplicitAny; - }; - ImmutableCompilationSettings.prototype.noLib = function () { - return this._noLib; - }; - ImmutableCompilationSettings.prototype.codeGenTarget = function () { - return this._codeGenTarget; - }; - ImmutableCompilationSettings.prototype.moduleGenTarget = function () { - return this._moduleGenTarget; - }; - ImmutableCompilationSettings.prototype.outFileOption = function () { - return this._outFileOption; - }; - ImmutableCompilationSettings.prototype.outDirOption = function () { - return this._outDirOption; - }; - ImmutableCompilationSettings.prototype.mapSourceFiles = function () { - return this._mapSourceFiles; - }; - ImmutableCompilationSettings.prototype.mapRoot = function () { - return this._mapRoot; - }; - ImmutableCompilationSettings.prototype.sourceRoot = function () { - return this._sourceRoot; - }; - ImmutableCompilationSettings.prototype.generateDeclarationFiles = function () { - return this._generateDeclarationFiles; - }; - ImmutableCompilationSettings.prototype.useCaseSensitiveFileResolution = function () { - return this._useCaseSensitiveFileResolution; - }; - ImmutableCompilationSettings.prototype.gatherDiagnostics = function () { - return this._gatherDiagnostics; - }; - ImmutableCompilationSettings.prototype.codepage = function () { - return this._codepage; - }; - ImmutableCompilationSettings.prototype.createFileLog = function () { - return this._createFileLog; - }; - - ImmutableCompilationSettings.defaultSettings = function () { - if (!ImmutableCompilationSettings._defaultSettings) { - ImmutableCompilationSettings._defaultSettings = ImmutableCompilationSettings.fromCompilationSettings(new CompilationSettings()); - } - - return ImmutableCompilationSettings._defaultSettings; - }; - - 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, 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, "_")) { - resultAsIndexable[name.substr(1)] = thisAsIndexable[name]; - } - } - - return result; - }; - return ImmutableCompilationSettings; - })(); - TypeScript.ImmutableCompilationSettings = ImmutableCompilationSettings; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (PullElementFlags) { - PullElementFlags[PullElementFlags["None"] = 0] = "None"; - PullElementFlags[PullElementFlags["Exported"] = 1] = "Exported"; - PullElementFlags[PullElementFlags["Private"] = 1 << 1] = "Private"; - PullElementFlags[PullElementFlags["Public"] = 1 << 2] = "Public"; - PullElementFlags[PullElementFlags["Ambient"] = 1 << 3] = "Ambient"; - PullElementFlags[PullElementFlags["Static"] = 1 << 4] = "Static"; - PullElementFlags[PullElementFlags["Optional"] = 1 << 7] = "Optional"; - PullElementFlags[PullElementFlags["Signature"] = 1 << 11] = "Signature"; - PullElementFlags[PullElementFlags["Enum"] = 1 << 12] = "Enum"; - PullElementFlags[PullElementFlags["ArrowFunction"] = 1 << 13] = "ArrowFunction"; - - PullElementFlags[PullElementFlags["ClassConstructorVariable"] = 1 << 14] = "ClassConstructorVariable"; - PullElementFlags[PullElementFlags["InitializedModule"] = 1 << 15] = "InitializedModule"; - PullElementFlags[PullElementFlags["InitializedDynamicModule"] = 1 << 16] = "InitializedDynamicModule"; - - PullElementFlags[PullElementFlags["MustCaptureThis"] = 1 << 18] = "MustCaptureThis"; - - PullElementFlags[PullElementFlags["DeclaredInAWithBlock"] = 1 << 21] = "DeclaredInAWithBlock"; - - PullElementFlags[PullElementFlags["HasReturnStatement"] = 1 << 22] = "HasReturnStatement"; - - PullElementFlags[PullElementFlags["PropertyParameter"] = 1 << 23] = "PropertyParameter"; - - PullElementFlags[PullElementFlags["IsAnnotatedWithAny"] = 1 << 24] = "IsAnnotatedWithAny"; - - PullElementFlags[PullElementFlags["HasDefaultArgs"] = 1 << 25] = "HasDefaultArgs"; - - PullElementFlags[PullElementFlags["ConstructorParameter"] = 1 << 26] = "ConstructorParameter"; - - PullElementFlags[PullElementFlags["ImplicitVariable"] = PullElementFlags.ClassConstructorVariable | PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "ImplicitVariable"; - PullElementFlags[PullElementFlags["SomeInitializedModule"] = PullElementFlags.InitializedModule | PullElementFlags.InitializedDynamicModule | PullElementFlags.Enum] = "SomeInitializedModule"; - })(TypeScript.PullElementFlags || (TypeScript.PullElementFlags = {})); - var PullElementFlags = TypeScript.PullElementFlags; - - function hasModifier(modifiers, flag) { - for (var i = 0, n = modifiers.length; i < n; i++) { - if (TypeScript.hasFlag(modifiers[i], flag)) { - return true; - } - } - - return false; - } - TypeScript.hasModifier = hasModifier; - - (function (PullElementKind) { - PullElementKind[PullElementKind["None"] = 0] = "None"; - PullElementKind[PullElementKind["Global"] = 0] = "Global"; - - PullElementKind[PullElementKind["Script"] = 1 << 0] = "Script"; - PullElementKind[PullElementKind["Primitive"] = 1 << 1] = "Primitive"; - - PullElementKind[PullElementKind["Container"] = 1 << 2] = "Container"; - PullElementKind[PullElementKind["Class"] = 1 << 3] = "Class"; - PullElementKind[PullElementKind["Interface"] = 1 << 4] = "Interface"; - PullElementKind[PullElementKind["DynamicModule"] = 1 << 5] = "DynamicModule"; - PullElementKind[PullElementKind["Enum"] = 1 << 6] = "Enum"; - PullElementKind[PullElementKind["TypeAlias"] = 1 << 7] = "TypeAlias"; - PullElementKind[PullElementKind["ObjectLiteral"] = 1 << 8] = "ObjectLiteral"; - - PullElementKind[PullElementKind["Variable"] = 1 << 9] = "Variable"; - PullElementKind[PullElementKind["CatchVariable"] = 1 << 10] = "CatchVariable"; - PullElementKind[PullElementKind["Parameter"] = 1 << 11] = "Parameter"; - PullElementKind[PullElementKind["Property"] = 1 << 12] = "Property"; - PullElementKind[PullElementKind["TypeParameter"] = 1 << 13] = "TypeParameter"; - - PullElementKind[PullElementKind["Function"] = 1 << 14] = "Function"; - PullElementKind[PullElementKind["ConstructorMethod"] = 1 << 15] = "ConstructorMethod"; - PullElementKind[PullElementKind["Method"] = 1 << 16] = "Method"; - PullElementKind[PullElementKind["FunctionExpression"] = 1 << 17] = "FunctionExpression"; - - PullElementKind[PullElementKind["GetAccessor"] = 1 << 18] = "GetAccessor"; - PullElementKind[PullElementKind["SetAccessor"] = 1 << 19] = "SetAccessor"; - - PullElementKind[PullElementKind["CallSignature"] = 1 << 20] = "CallSignature"; - PullElementKind[PullElementKind["ConstructSignature"] = 1 << 21] = "ConstructSignature"; - PullElementKind[PullElementKind["IndexSignature"] = 1 << 22] = "IndexSignature"; - - PullElementKind[PullElementKind["ObjectType"] = 1 << 23] = "ObjectType"; - PullElementKind[PullElementKind["FunctionType"] = 1 << 24] = "FunctionType"; - PullElementKind[PullElementKind["ConstructorType"] = 1 << 25] = "ConstructorType"; - - PullElementKind[PullElementKind["EnumMember"] = 1 << 26] = "EnumMember"; - - PullElementKind[PullElementKind["WithBlock"] = 1 << 27] = "WithBlock"; - PullElementKind[PullElementKind["CatchBlock"] = 1 << 28] = "CatchBlock"; - - PullElementKind[PullElementKind["All"] = PullElementKind.Script | PullElementKind.Global | PullElementKind.Primitive | PullElementKind.Container | PullElementKind.Class | PullElementKind.Interface | PullElementKind.DynamicModule | PullElementKind.Enum | PullElementKind.TypeAlias | PullElementKind.ObjectLiteral | PullElementKind.Variable | PullElementKind.Parameter | PullElementKind.Property | PullElementKind.TypeParameter | PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor | PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType | PullElementKind.EnumMember | PullElementKind.WithBlock | PullElementKind.CatchBlock] = "All"; - - PullElementKind[PullElementKind["SomeFunction"] = PullElementKind.Function | PullElementKind.ConstructorMethod | PullElementKind.Method | PullElementKind.FunctionExpression | PullElementKind.GetAccessor | PullElementKind.SetAccessor] = "SomeFunction"; - - 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.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"; - - PullElementKind[PullElementKind["SomeContainer"] = PullElementKind.Container | PullElementKind.DynamicModule | PullElementKind.TypeAlias] = "SomeContainer"; - - PullElementKind[PullElementKind["SomeSignature"] = PullElementKind.CallSignature | PullElementKind.ConstructSignature | PullElementKind.IndexSignature] = "SomeSignature"; - - PullElementKind[PullElementKind["SomeTypeReference"] = PullElementKind.Interface | PullElementKind.ObjectType | PullElementKind.FunctionType | PullElementKind.ConstructorType] = "SomeTypeReference"; - - PullElementKind[PullElementKind["SomeInstantiatableType"] = PullElementKind.Class | PullElementKind.Interface | PullElementKind.TypeParameter] = "SomeInstantiatableType"; - })(TypeScript.PullElementKind || (TypeScript.PullElementKind = {})); - var PullElementKind = TypeScript.PullElementKind; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var pullDeclID = 0; - var sentinelEmptyPullDeclArray = []; - - var PullDecl = (function () { - 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; - this.childDeclTypeParameterCache = null; - this.name = declName; - this.kind = kind; - this.flags = declFlags; - this.semanticInfoChain = semanticInfoChain; - - if (displayName !== this.name) { - this.declDisplayName = displayName; - } - } - PullDecl.prototype.fileName = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentPath = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getParentDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.isExternalModule = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype.getEnclosingDecl = function () { - throw TypeScript.Errors.abstract(); - }; - - PullDecl.prototype._getEnclosingDeclFromParentDecl = function () { - var decl = this; - while (decl) { - switch (decl.kind) { - default: - return decl; - case 512 /* Variable */: - case 8192 /* TypeParameter */: - case 2048 /* Parameter */: - case 128 /* TypeAlias */: - case 67108864 /* EnumMember */: - } - - decl = decl.getParentDecl(); - } - - TypeScript.Debug.fail(); - }; - - PullDecl.prototype.getDisplayName = function () { - return this.declDisplayName === undefined ? this.name : this.declDisplayName; - }; - - PullDecl.prototype.setSymbol = function (symbol) { - this.semanticInfoChain.setSymbolForDecl(this, symbol); - }; - - 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 */) { - return null; - } - - this.ensureSymbolIsBound(); - - return this.semanticInfoChain.getSymbolForDecl(this); - }; - - PullDecl.prototype.hasSymbol = function () { - var symbol = this.semanticInfoChain.getSymbolForDecl(this); - return !!symbol; - }; - - PullDecl.prototype.setSignatureSymbol = function (signatureSymbol) { - this.semanticInfoChain.setSignatureSymbolForDecl(this, signatureSymbol); - }; - - PullDecl.prototype.getSignatureSymbol = function () { - this.ensureSymbolIsBound(); - return this.semanticInfoChain.getSignatureSymbolForDecl(this); - }; - - PullDecl.prototype.hasSignatureSymbol = function () { - var signatureSymbol = this.semanticInfoChain.getSignatureSymbolForDecl(this); - return !!signatureSymbol; - }; - - PullDecl.prototype.setFlags = function (flags) { - this.flags = flags; - }; - - PullDecl.prototype.setFlag = function (flags) { - this.flags |= flags; - }; - - PullDecl.prototype.setValueDecl = function (valDecl) { - this.synthesizedValDecl = valDecl; - valDecl.containerDecl = this; - }; - - PullDecl.prototype.getValueDecl = function () { - return this.synthesizedValDecl; - }; - - PullDecl.prototype.getContainerDecl = function () { - return this.containerDecl; - }; - - PullDecl.prototype.getChildDeclCache = function (declKind) { - if (declKind === 8192 /* TypeParameter */) { - if (!this.childDeclTypeParameterCache) { - this.childDeclTypeParameterCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeParameterCache; - } else if (TypeScript.hasFlag(declKind, 164 /* SomeContainer */)) { - if (!this.childDeclNamespaceCache) { - this.childDeclNamespaceCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclNamespaceCache; - } else if (TypeScript.hasFlag(declKind, 58728795 /* SomeType */)) { - if (!this.childDeclTypeCache) { - this.childDeclTypeCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclTypeCache; - } else { - if (!this.childDeclValueCache) { - this.childDeclValueCache = TypeScript.createIntrinsicsObject(); - } - - return this.childDeclValueCache; - } - }; - - PullDecl.prototype.addChildDecl = function (childDecl) { - if (childDecl.kind === 8192 /* TypeParameter */) { - if (!this.typeParameters) { - this.typeParameters = []; - } - this.typeParameters[this.typeParameters.length] = childDecl; - } else { - if (!this.childDecls) { - this.childDecls = []; - } - this.childDecls[this.childDecls.length] = childDecl; - } - - var declName = childDecl.name; - - if (!(childDecl.kind & 7340032 /* SomeSignature */)) { - var cache = this.getChildDeclCache(childDecl.kind); - var childrenOfName = cache[declName]; - if (!childrenOfName) { - childrenOfName = []; - } - - childrenOfName.push(childDecl); - cache[declName] = childrenOfName; - } - }; - - PullDecl.prototype.searchChildDecls = function (declName, searchKind) { - var cacheVal = null; - - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeCache ? this.childDeclTypeCache[declName] : null; - } else if (searchKind & 164 /* SomeContainer */) { - cacheVal = this.childDeclNamespaceCache ? this.childDeclNamespaceCache[declName] : null; - } else { - cacheVal = this.childDeclValueCache ? this.childDeclValueCache[declName] : null; - } - - if (cacheVal) { - return cacheVal; - } else { - if (searchKind & 58728795 /* SomeType */) { - cacheVal = this.childDeclTypeParameterCache ? this.childDeclTypeParameterCache[declName] : null; - - if (cacheVal) { - return cacheVal; - } - } - - return sentinelEmptyPullDeclArray; - } - }; - - PullDecl.prototype.getChildDecls = function () { - return this.childDecls || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.getTypeParameters = function () { - return this.typeParameters || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.addVariableDeclToGroup = function (decl) { - if (!this.declGroups) { - this.declGroups = TypeScript.createIntrinsicsObject(); - } - - var declGroup = this.declGroups[decl.name]; - if (declGroup) { - declGroup.addDecl(decl); - } else { - declGroup = new PullDeclGroup(decl.name); - declGroup.addDecl(decl); - this.declGroups[decl.name] = declGroup; - } - }; - - PullDecl.prototype.getVariableDeclGroups = function () { - var declGroups = null; - - if (this.declGroups) { - for (var declName in this.declGroups) { - if (this.declGroups[declName]) { - if (declGroups === null) { - declGroups = []; - } - - declGroups.push(this.declGroups[declName].getDecls()); - } - } - } - - return declGroups || sentinelEmptyPullDeclArray; - }; - - PullDecl.prototype.hasBeenBound = function () { - return this.hasSymbol() || this.hasSignatureSymbol(); - }; - - PullDecl.prototype.isSynthesized = function () { - return false; - }; - - PullDecl.prototype.ast = function () { - return this.semanticInfoChain.getASTForDecl(this); - }; - - PullDecl.prototype.isRootDecl = function () { - throw TypeScript.Errors.abstract(); - }; - return PullDecl; - })(); - TypeScript.PullDecl = PullDecl; - - var RootPullDecl = (function (_super) { - __extends(RootPullDecl, _super); - 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; - } - RootPullDecl.prototype.fileName = function () { - return this._fileName; - }; - - RootPullDecl.prototype.getParentPath = function () { - return [this]; - }; - - RootPullDecl.prototype.getParentDecl = function () { - return null; - }; - - RootPullDecl.prototype.isExternalModule = function () { - return this._isExternalModule; - }; - - 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, addToParent) { - if (typeof addToParent === "undefined") { addToParent = true; } - _super.call(this, declName, displayName, kind, declFlags, parentDecl ? parentDecl.semanticInfoChain : null); - this.parentDecl = null; - this.parentPath = null; - - this.parentDecl = parentDecl; - 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._rootDecl.fileName(); - }; - - NormalPullDecl.prototype.getParentDecl = function () { - return this.parentDecl; - }; - - NormalPullDecl.prototype.getParentPath = function () { - if (!this.parentPath) { - var path = [this]; - var parentDecl = this.parentDecl; - - while (parentDecl) { - if (parentDecl && path[path.length - 1] !== parentDecl && !(parentDecl.kind & (256 /* ObjectLiteral */ | 8388608 /* ObjectType */))) { - path.unshift(parentDecl); - } - - parentDecl = parentDecl.getParentDecl(); - } - - this.parentPath = path; - } - - return this.parentPath; - }; - - NormalPullDecl.prototype.isExternalModule = function () { - return false; - }; - - 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) { - _super.call(this, declName, displayName, 67108864 /* EnumMember */, 4 /* Public */, parentDecl); - this.constantValue = null; - } - return PullEnumElementDecl; - })(NormalPullDecl); - TypeScript.PullEnumElementDecl = PullEnumElementDecl; - - var PullFunctionExpressionDecl = (function (_super) { - __extends(PullFunctionExpressionDecl, _super); - function PullFunctionExpressionDecl(expressionName, declFlags, parentDecl, displayName) { - if (typeof displayName === "undefined") { displayName = ""; } - _super.call(this, "", displayName, 131072 /* FunctionExpression */, declFlags, parentDecl); - this.functionExpressionName = expressionName; - } - PullFunctionExpressionDecl.prototype.getFunctionExpressionName = function () { - return this.functionExpressionName; - }; - return PullFunctionExpressionDecl; - })(NormalPullDecl); - TypeScript.PullFunctionExpressionDecl = PullFunctionExpressionDecl; - - var PullSynthesizedDecl = (function (_super) { - __extends(PullSynthesizedDecl, _super); - function PullSynthesizedDecl(declName, displayName, kind, declFlags, parentDecl, semanticInfoChain) { - _super.call(this, declName, displayName, kind, declFlags, parentDecl, false); - this.semanticInfoChain = semanticInfoChain; - } - PullSynthesizedDecl.prototype.isSynthesized = function () { - return true; - }; - - PullSynthesizedDecl.prototype.fileName = function () { - return this._rootDecl ? this._rootDecl.fileName() : ""; - }; - return PullSynthesizedDecl; - })(NormalPullDecl); - TypeScript.PullSynthesizedDecl = PullSynthesizedDecl; - - var PullDeclGroup = (function () { - function PullDeclGroup(name) { - this.name = name; - this._decls = []; - } - PullDeclGroup.prototype.addDecl = function (decl) { - if (decl.name === this.name) { - this._decls[this._decls.length] = decl; - } - }; - - PullDeclGroup.prototype.getDecls = function () { - return this._decls; - }; - return PullDeclGroup; - })(); - TypeScript.PullDeclGroup = PullDeclGroup; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.pullSymbolID = 0; - TypeScript.sentinelEmptyArray = []; - - var PullSymbol = (function () { - function PullSymbol(name, declKind) { - this.pullSymbolID = ++TypeScript.pullSymbolID; - this._container = null; - this.type = null; - this._declarations = null; - this.isResolved = false; - this.isOptional = false; - this.inResolution = false; - this.isSynthesized = false; - this.isVarArg = false; - this.rootSymbol = null; - this._enclosingSignature = null; - this._docComments = null; - this.isPrinting = false; - this.name = name; - this.kind = declKind; - } - PullSymbol.prototype.isAny = function () { - return false; - }; - - PullSymbol.prototype.isType = function () { - return (this.kind & 58728795 /* SomeType */) !== 0; - }; - - PullSymbol.prototype.isTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isSignature = function () { - return (this.kind & 7340032 /* SomeSignature */) !== 0; - }; - - PullSymbol.prototype.isArrayNamedTypeReference = function () { - return false; - }; - - PullSymbol.prototype.isPrimitive = function () { - return this.kind === 2 /* Primitive */; - }; - - PullSymbol.prototype.isAccessor = function () { - return false; - }; - - PullSymbol.prototype.isError = function () { - return false; - }; - - PullSymbol.prototype.isInterface = function () { - return this.kind === 16 /* Interface */; - }; - - PullSymbol.prototype.isMethod = function () { - return this.kind === 65536 /* Method */; - }; - - PullSymbol.prototype.isProperty = function () { - return this.kind === 4096 /* Property */; - }; - - PullSymbol.prototype.isAlias = function () { - return false; - }; - - PullSymbol.prototype.isContainer = function () { - return false; - }; - - PullSymbol.prototype.findAliasedType = function (scopeSymbol, skipScopeSymbolAliasesLookIn, lookIntoOnlyExportedAlias, aliasSymbols, visitedScopeDeclarations) { - if (typeof aliasSymbols === "undefined") { aliasSymbols = []; } - if (typeof visitedScopeDeclarations === "undefined") { visitedScopeDeclarations = []; } - var scopeDeclarations = scopeSymbol.getDeclarations(); - var scopeSymbolAliasesToLookIn = []; - - for (var i = 0; i < scopeDeclarations.length; i++) { - var scopeDecl = scopeDeclarations[i]; - if (!TypeScript.ArrayUtilities.contains(visitedScopeDeclarations, scopeDecl)) { - visitedScopeDeclarations.push(scopeDecl); - - var childDecls = scopeDecl.getChildDecls(); - for (var j = 0; j < childDecls.length; j++) { - var childDecl = childDecls[j]; - if (childDecl.kind === 128 /* TypeAlias */ && (!lookIntoOnlyExportedAlias || (childDecl.flags & 1 /* Exported */))) { - var symbol = childDecl.getSymbol(); - - if (PullContainerSymbol.usedAsSymbol(symbol, this) || (this.rootSymbol && PullContainerSymbol.usedAsSymbol(symbol, this.rootSymbol))) { - aliasSymbols.push(symbol); - return aliasSymbols; - } - - if (!skipScopeSymbolAliasesLookIn && this.isExternalModuleReferenceAlias(symbol) && (!symbol.assignedContainer().hasExportAssignment() || (symbol.assignedContainer().getExportAssignedContainerSymbol() && symbol.assignedContainer().getExportAssignedContainerSymbol().kind === 32 /* DynamicModule */))) { - scopeSymbolAliasesToLookIn.push(symbol); - } - } - } - } - } - - for (var i = 0; i < scopeSymbolAliasesToLookIn.length; i++) { - var scopeSymbolAlias = scopeSymbolAliasesToLookIn[i]; - - aliasSymbols.push(scopeSymbolAlias); - var result = this.findAliasedType(scopeSymbolAlias.assignedContainer().hasExportAssignment() ? scopeSymbolAlias.assignedContainer().getExportAssignedContainerSymbol() : scopeSymbolAlias.assignedContainer(), false, true, aliasSymbols, visitedScopeDeclarations); - if (result) { - return result; - } - - aliasSymbols.pop(); - } - - return null; - }; - - PullSymbol.prototype.getExternalAliasedSymbols = function (scopeSymbol) { - if (!scopeSymbol) { - return null; - } - - var scopePath = scopeSymbol.pathToRoot(); - if (scopePath.length && scopePath[scopePath.length - 1].kind === 32 /* DynamicModule */) { - var symbols = this.findAliasedType(scopePath[scopePath.length - 1]); - return symbols; - } - - return null; - }; - - PullSymbol.prototype.isExternalModuleReferenceAlias = function (aliasSymbol) { - if (aliasSymbol) { - if (aliasSymbol.assignedValue()) { - return false; - } - - if (aliasSymbol.assignedType() && aliasSymbol.assignedType() !== aliasSymbol.assignedContainer()) { - return false; - } - - if (aliasSymbol.assignedContainer() && aliasSymbol.assignedContainer().kind !== 32 /* DynamicModule */) { - return false; - } - - return true; - } - - return false; - }; - - PullSymbol.prototype.getExportedInternalAliasSymbol = function (scopeSymbol) { - if (scopeSymbol) { - 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); - return internalAliases[0]; - } - } - } - } - - return null; - }; - - PullSymbol.prototype.getAliasSymbolName = function (scopeSymbol, aliasNameGetter, aliasPartsNameGetter, skipInternalAlias) { - if (!skipInternalAlias) { - var internalAlias = this.getExportedInternalAliasSymbol(scopeSymbol); - if (internalAlias) { - return aliasNameGetter(internalAlias); - } - } - - var externalAliases = this.getExternalAliasedSymbols(scopeSymbol); - - if (externalAliases && this.isExternalModuleReferenceAlias(externalAliases[externalAliases.length - 1])) { - 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 aliasFullName; - } - - return null; - }; - - PullSymbol.prototype._getResolver = function () { - TypeScript.Debug.assert(this._declarations && this._declarations.length > 0); - return this._declarations[0].semanticInfoChain.getResolver(); - }; - - PullSymbol.prototype._resolveDeclaredSymbol = function () { - return this._getResolver().resolveDeclaredSymbol(this); - }; - - PullSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var aliasName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getName(); - }); - return aliasName || this.name; - }; - - PullSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var aliasDisplayName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getDisplayName(scopeSymbol, useConstraintInName); - }, function (symbol) { - return symbol.getDisplayName(); - }, skipInternalAliasName); - if (aliasDisplayName) { - return aliasDisplayName; - } - - var decls = this.getDeclarations(); - var name = decls.length && decls[0].getDisplayName(); - - return (name && name.length) ? name : this.name; - }; - - PullSymbol.prototype.getIsSpecialized = function () { - return false; - }; - - PullSymbol.prototype.getRootSymbol = function () { - if (!this.rootSymbol) { - return this; - } - return this.rootSymbol; - }; - PullSymbol.prototype.setRootSymbol = function (symbol) { - this.rootSymbol = symbol; - }; - - 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; - }; - - PullSymbol.prototype.setEnclosingSignature = function (signature) { - this._enclosingSignature = signature; - }; - - PullSymbol.prototype.getEnclosingSignature = function () { - return this._enclosingSignature; - }; - - PullSymbol.prototype.addDeclaration = function (decl) { - TypeScript.Debug.assert(!!decl); - - if (this.rootSymbol) { - return; - } - - if (!this._declarations) { - this._declarations = [decl]; - } else { - this._declarations[this._declarations.length] = decl; - } - }; - - PullSymbol.prototype.getDeclarations = function () { - if (this.rootSymbol) { - return this.rootSymbol.getDeclarations(); - } - - if (!this._declarations) { - this._declarations = []; - } - - return this._declarations; - }; - - PullSymbol.prototype.hasDeclaration = function (decl) { - if (!this._declarations) { - return false; - } - - return TypeScript.ArrayUtilities.any(this._declarations, function (eachDecl) { - return eachDecl === decl; - }); - }; - - PullSymbol.prototype.setContainer = function (containerSymbol) { - if (this.rootSymbol) { - return; - } - - this._container = containerSymbol; - }; - - PullSymbol.prototype.getContainer = function () { - if (this.rootSymbol) { - return this.rootSymbol.getContainer(); - } - - return this._container; - }; - - PullSymbol.prototype.setResolved = function () { - this.isResolved = true; - this.inResolution = false; - }; - - PullSymbol.prototype.startResolving = function () { - this.inResolution = true; - }; - - PullSymbol.prototype.setUnresolved = function () { - this.isResolved = false; - this.inResolution = false; - }; - - PullSymbol.prototype.anyDeclHasFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (TypeScript.hasFlag(declarations[i].flags, flag)) { - return true; - } - } - return false; - }; - - PullSymbol.prototype.allDeclsHaveFlag = function (flag) { - var declarations = this.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - if (!TypeScript.hasFlag(declarations[i].flags, flag)) { - return false; - } - } - return true; - }; - - PullSymbol.prototype.pathToRoot = function () { - var path = []; - var node = this; - while (node) { - if (node.isType()) { - var associatedContainerSymbol = node.getAssociatedContainerType(); - if (associatedContainerSymbol) { - node = associatedContainerSymbol; - } - } - path[path.length] = node; - var nodeKind = node.kind; - if (nodeKind === 2048 /* Parameter */) { - break; - } else { - node = node.getContainer(); - } - } - return path; - }; - - 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 memberSymbol = scopeType.findContainedNonMemberContainer(symbol.name, 164 /* SomeContainer */); - if (memberSymbol && memberSymbol != symbol && memberSymbol.getDeclarations()[0].getParentDecl() == declPath[declIndex]) { - return true; - } - - var memberSymbol = scopeType.findNestedContainer(symbol.name, 164 /* SomeContainer */); - if (memberSymbol && memberSymbol != symbol) { - return true; - } - } - } - - 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 (thisCommonAncestorIndex >= 0 && thisCommonAncestorIndex < thisPath.length) { - return thisPath.slice(0, thisCommonAncestorIndex); - } else { - return thisPath; - } - }; - - PullSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var str = this.getNameAndTypeName(scopeSymbol); - return str; - }; - - PullSymbol.prototype.getNamePartForFullName = function () { - return this.getDisplayName(null, true); - }; - - PullSymbol.prototype.fullName = function (scopeSymbol) { - var _this = this; - var path = this.pathToRoot(); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol === _this ? null : symbol.fullName(scopeSymbol); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - var scopedName = path[i].getNamePartForFullName(); - if (path[i].kind === 32 /* DynamicModule */ && !TypeScript.isQuoted(scopedName)) { - break; - } - - if (scopedName === "") { - break; - } - - fullName = scopedName + "." + fullName; - } - - fullName = fullName + this.getNamePartForFullName(); - return fullName; - }; - - PullSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - var path = this.findQualifyingSymbolPathInScopeSymbol(scopeSymbol); - var fullName = ""; - - var aliasFullName = this.getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - return aliasFullName; - } - - for (var i = 1; i < path.length; i++) { - var kind = path[i].kind; - if (kind === 4 /* Container */ || kind === 32 /* DynamicModule */) { - var aliasFullName = path[i].getAliasSymbolName(scopeSymbol, function (symbol) { - return symbol.getScopedName(scopeSymbol, skipTypeParametersInName, false, skipInternalAliasName); - }, function (symbol) { - return symbol.getNamePartForFullName(); - }, skipInternalAliasName); - if (aliasFullName) { - fullName = aliasFullName + "." + fullName; - break; - } - - if (kind === 4 /* Container */) { - fullName = path[i].getDisplayName() + "." + fullName; - } else { - var displayName = path[i].getDisplayName(); - if (TypeScript.isQuoted(displayName)) { - fullName = displayName + "." + fullName; - } - break; - } - } else { - break; - } - } - fullName = fullName + this.getDisplayName(scopeSymbol, useConstraintInName, skipInternalAliasName); - return fullName; - }; - - PullSymbol.prototype.getScopedNameEx = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, getPrettyTypeName, getTypeParamMarkerInfo, skipInternalAliasName) { - var name = this.getScopedName(scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - return TypeScript.MemberName.create(name); - }; - - PullSymbol.prototype.getTypeName = function (scopeSymbol, getPrettyTypeName) { - var memberName = this.getTypeNameEx(scopeSymbol, getPrettyTypeName); - return memberName.toString(); - }; - - PullSymbol.prototype.getTypeNameEx = function (scopeSymbol, getPrettyTypeName) { - var type = this.type; - if (type) { - var memberName = getPrettyTypeName ? this.getTypeNameForFunctionSignature("", scopeSymbol, getPrettyTypeName) : null; - if (!memberName) { - memberName = type.getScopedNameEx(scopeSymbol, false, true, getPrettyTypeName); - } - - return memberName; - } - return TypeScript.MemberName.create(""); - }; - - 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 */) { - var signatures = type.getCallSignatures(); - 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); - return typeName; - } - } - - return null; - }; - - PullSymbol.prototype.getNameAndTypeName = function (scopeSymbol) { - var nameAndTypeName = this.getNameAndTypeNameEx(scopeSymbol); - return nameAndTypeName.toString(); - }; - - PullSymbol.prototype.getNameAndTypeNameEx = function (scopeSymbol) { - var type = this.type; - var nameStr = this.getDisplayName(scopeSymbol); - if (type) { - nameStr = nameStr + (this.isOptional ? "?" : ""); - var memberName = this.getTypeNameForFunctionSignature(nameStr, scopeSymbol); - if (!memberName) { - var typeNameEx = type.getScopedNameEx(scopeSymbol); - memberName = TypeScript.MemberName.create(typeNameEx, nameStr + ": ", ""); - } - return memberName; - } - return TypeScript.MemberName.create(nameStr); - }; - - PullSymbol.getTypeParameterString = function (typars, scopeSymbol, useContraintInName) { - return PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, undefined, useContraintInName).toString(); - }; - - PullSymbol.getTypeParameterStringEx = function (typeParameters, scopeSymbol, getTypeParamMarkerInfo, useContraintInName) { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = ""; - - if (typeParameters && typeParameters.length) { - builder.add(TypeScript.MemberName.create("<")); - - for (var i = 0; i < typeParameters.length; i++) { - if (i) { - builder.add(TypeScript.MemberName.create(", ")); - } - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - - builder.add(typeParameters[i].getScopedNameEx(scopeSymbol, false, useContraintInName)); - - if (getTypeParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - } - - builder.add(TypeScript.MemberName.create(">")); - } - - return builder; - }; - - PullSymbol.getIsExternallyVisible = function (symbol, fromIsExternallyVisibleSymbol, inIsExternallyVisibleSymbols) { - if (inIsExternallyVisibleSymbols) { - for (var i = 0; i < inIsExternallyVisibleSymbols.length; i++) { - if (inIsExternallyVisibleSymbols[i] === symbol) { - return true; - } - } - } else { - inIsExternallyVisibleSymbols = []; - } - - if (fromIsExternallyVisibleSymbol === symbol) { - return true; - } - - inIsExternallyVisibleSymbols.push(fromIsExternallyVisibleSymbol); - - var result = symbol.isExternallyVisible(inIsExternallyVisibleSymbols); - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(inIsExternallyVisibleSymbols) === fromIsExternallyVisibleSymbol); - inIsExternallyVisibleSymbols.pop(); - - return result; - }; - - PullSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - var kind = this.kind; - if (kind === 2 /* Primitive */) { - return true; - } - - if (this.rootSymbol) { - return PullSymbol.getIsExternallyVisible(this.rootSymbol, this, inIsExternallyVisibleSymbols); - } - - if (this.isType()) { - var associatedContainerSymbol = this.getAssociatedContainerType(); - if (associatedContainerSymbol) { - return PullSymbol.getIsExternallyVisible(associatedContainerSymbol, this, inIsExternallyVisibleSymbols); - } - } - - if (this.anyDeclHasFlag(2 /* Private */)) { - return false; - } - - var container = this.getContainer(); - if (container === null) { - var decls = this.getDeclarations(); - if (decls.length) { - var parentDecl = decls[0].getParentDecl(); - if (parentDecl) { - var parentSymbol = parentDecl.getSymbol(); - if (!parentSymbol || parentDecl.kind === 1 /* Script */) { - return true; - } - - return PullSymbol.getIsExternallyVisible(parentSymbol, this, inIsExternallyVisibleSymbols); - } - } - - return true; - } - - 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 */) { - return false; - } - - return PullSymbol.getIsExternallyVisible(container, this, inIsExternallyVisibleSymbols); - }; - - PullSymbol.prototype.getDocCommentsOfDecl = function (decl) { - var ast = decl.ast(); - - if (ast) { - 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.ASTHelpers.docComments(ast); - } - } - - return []; - }; - - PullSymbol.prototype.getDocCommentArray = function (symbol) { - var docComments = []; - if (!symbol) { - return docComments; - } - - 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 */) { - continue; - } - docComments = docComments.concat(this.getDocCommentsOfDecl(decls[i])); - } - return docComments; - }; - - PullSymbol.getDefaultConstructorSymbolForDocComments = function (classSymbol) { - if (classSymbol.getHasDefaultConstructor()) { - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - return PullSymbol.getDefaultConstructorSymbolForDocComments(extendedTypes[0]); - } - } - - return classSymbol.type.getConstructSignatures()[0]; - }; - - PullSymbol.prototype.getDocCommentText = function (comments) { - var docCommentText = new Array(); - for (var c = 0; c < comments.length; c++) { - var commentText = this.getDocCommentTextValue(comments[c]); - if (commentText !== "") { - docCommentText.push(commentText); - } - } - return docCommentText.join("\n"); - }; - - PullSymbol.prototype.getDocCommentTextValue = function (comment) { - return this.cleanJSDocComment(comment.fullText()); - }; - - PullSymbol.prototype.docComments = function (useConstructorAsClass) { - var decls = this.getDeclarations(); - 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 */) { - var classSymbol = this.returnType; - var extendedTypes = classSymbol.getExtendedTypes(); - if (extendedTypes.length) { - docComments = extendedTypes[0].getConstructorMethod().docComments(); - } else { - docComments = ""; - } - } else if (this.kind === 2048 /* Parameter */) { - var parameterComments = []; - - var funcContainer = this.getEnclosingSignature(); - var funcDocComments = this.getDocCommentArray(funcContainer); - var paramComment = this.getParameterDocCommentText(this.getDisplayName(), funcDocComments); - if (paramComment != "") { - parameterComments.push(paramComment); - } - - var paramSelfComment = this.getDocCommentText(this.getDocCommentArray(this)); - if (paramSelfComment != "") { - parameterComments.push(paramSelfComment); - } - docComments = parameterComments.join("\n"); - } else { - var getSymbolComments = true; - if (this.kind === 16777216 /* FunctionType */) { - var functionSymbol = this.getFunctionSymbol(); - - if (functionSymbol) { - docComments = functionSymbol._docComments || ""; - getSymbolComments = false; - } else { - var declarationList = this.getDeclarations(); - if (declarationList.length > 0) { - docComments = declarationList[0].getSymbol()._docComments || ""; - getSymbolComments = false; - } - } - } - if (getSymbolComments) { - docComments = this.getDocCommentText(this.getDocCommentArray(this)); - if (docComments === "") { - if (this.kind === 1048576 /* CallSignature */) { - var callTypeSymbol = this.functionType; - if (callTypeSymbol && callTypeSymbol.getCallSignatures().length === 1) { - docComments = callTypeSymbol.docComments(); - } - } - } - } - } - - this._docComments = docComments; - } - - return this._docComments; - }; - - PullSymbol.prototype.getParameterDocCommentText = function (param, fncDocComments) { - if (fncDocComments.length === 0 || fncDocComments[0].kind() !== 6 /* MultiLineCommentTrivia */) { - return ""; - } - - for (var i = 0; i < fncDocComments.length; i++) { - var commentContents = fncDocComments[i].fullText(); - for (var j = commentContents.indexOf("@param", 0); 0 <= j; j = commentContents.indexOf("@param", j)) { - j += 6; - if (!this.isSpaceChar(commentContents, j)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j); - if (j === -1) { - break; - } - - if (commentContents.charCodeAt(j) === 123 /* openBrace */) { - j++; - - var charCode = 0; - for (var curlies = 1; j < commentContents.length; j++) { - charCode = commentContents.charCodeAt(j); - - if (charCode === 123 /* openBrace */) { - curlies++; - continue; - } - - if (charCode === 125 /* closeBrace */) { - curlies--; - if (curlies === 0) { - break; - } else { - continue; - } - } - - if (charCode === 64 /* at */) { - break; - } - } - - if (j === commentContents.length) { - break; - } - - if (charCode === 64 /* at */) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + 1); - if (j === -1) { - break; - } - } - - if (param !== commentContents.substr(j, param.length) || !this.isSpaceChar(commentContents, j + param.length)) { - continue; - } - - j = this.consumeLeadingSpace(commentContents, j + param.length); - if (j === -1) { - return ""; - } - - var endOfParam = commentContents.indexOf("@", j); - var paramHelpString = commentContents.substring(j, endOfParam < 0 ? commentContents.length : endOfParam); - - var paramSpacesToRemove = undefined; - var paramLineIndex = commentContents.substring(0, j).lastIndexOf("\n") + 1; - if (paramLineIndex !== 0) { - if (paramLineIndex < j && commentContents.charAt(paramLineIndex + 1) === "\r") { - paramLineIndex++; - } - } - var startSpaceRemovalIndex = this.consumeLeadingSpace(commentContents, paramLineIndex); - if (startSpaceRemovalIndex !== j && commentContents.charAt(startSpaceRemovalIndex) === "*") { - paramSpacesToRemove = j - startSpaceRemovalIndex - 1; - } - - return this.cleanJSDocComment(paramHelpString, paramSpacesToRemove); - } - } - - return ""; - }; - - PullSymbol.prototype.cleanJSDocComment = function (content, spacesToRemove) { - var docCommentLines = new Array(); - content = content.replace("/**", ""); - if (content.length >= 2 && content.charAt(content.length - 1) === "/" && content.charAt(content.length - 2) === "*") { - content = content.substring(0, content.length - 2); - } - var lines = content.split("\n"); - var inParamTag = false; - for (var l = 0; l < lines.length; l++) { - var line = lines[l]; - var cleanLinePos = this.cleanDocCommentLine(line, true, spacesToRemove); - if (!cleanLinePos) { - continue; - } - - var docCommentText = ""; - var prevPos = cleanLinePos.start; - for (var i = line.indexOf("@", cleanLinePos.start); 0 <= i && i < cleanLinePos.end; i = line.indexOf("@", i + 1)) { - var wasInParamtag = inParamTag; - - if (line.indexOf("param", i + 1) === i + 1 && this.isSpaceChar(line, i + 6)) { - if (!wasInParamtag) { - docCommentText += line.substring(prevPos, i); - } - - prevPos = i; - inParamTag = true; - } else if (wasInParamtag) { - prevPos = i; - inParamTag = false; - } - } - - if (!inParamTag) { - docCommentText += line.substring(prevPos, cleanLinePos.end); - } - - var newCleanPos = this.cleanDocCommentLine(docCommentText, false); - if (newCleanPos) { - if (spacesToRemove === undefined) { - spacesToRemove = cleanLinePos.jsDocSpacesRemoved; - } - docCommentLines.push(docCommentText); - } - } - - return docCommentLines.join("\n"); - }; - - PullSymbol.prototype.consumeLeadingSpace = function (line, startIndex, maxSpacesToRemove) { - var endIndex = line.length; - if (maxSpacesToRemove !== undefined) { - endIndex = TypeScript.MathPrototype.min(startIndex + maxSpacesToRemove, endIndex); - } - - for (; startIndex < endIndex; startIndex++) { - var charCode = line.charCodeAt(startIndex); - if (charCode !== 32 /* space */ && charCode !== 9 /* tab */) { - return startIndex; - } - } - - if (endIndex !== line.length) { - return endIndex; - } - - return -1; - }; - - PullSymbol.prototype.isSpaceChar = function (line, index) { - var length = line.length; - if (index < length) { - var charCode = line.charCodeAt(index); - - return charCode === 32 /* space */ || charCode === 9 /* tab */; - } - - return index === length; - }; - - PullSymbol.prototype.cleanDocCommentLine = function (line, jsDocStyleComment, jsDocLineSpaceToRemove) { - var nonSpaceIndex = this.consumeLeadingSpace(line, 0); - if (nonSpaceIndex !== -1) { - var jsDocSpacesRemoved = nonSpaceIndex; - if (jsDocStyleComment && line.charAt(nonSpaceIndex) === '*') { - var startIndex = nonSpaceIndex + 1; - nonSpaceIndex = this.consumeLeadingSpace(line, startIndex, jsDocLineSpaceToRemove); - - if (nonSpaceIndex !== -1) { - jsDocSpacesRemoved = nonSpaceIndex - startIndex; - } else { - return null; - } - } - - return { - start: nonSpaceIndex, - end: line.charAt(line.length - 1) === "\r" ? line.length - 1 : line.length, - jsDocSpacesRemoved: jsDocSpacesRemoved - }; - } - - return null; - }; - return PullSymbol; - })(); - TypeScript.PullSymbol = PullSymbol; - - - - var PullSignatureSymbol = (function (_super) { - __extends(PullSignatureSymbol, _super); - 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.returnType = null; - this.functionType = null; - this.hasOptionalParam = false; - this.nonOptionalParamCount = 0; - this.hasVarArgs = false; - this._allowedToReferenceTypeParameters = null; - this._instantiationCache = null; - this.hasBeenChecked = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - } - PullSignatureSymbol.prototype.isDefinition = function () { - return this._isDefinition; - }; - - PullSignatureSymbol.prototype.isGeneric = function () { - 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) { - this.parameters = []; - } - - this.parameters[this.parameters.length] = parameter; - this.hasOptionalParam = isOptional; - - if (!parameter.getEnclosingSignature()) { - parameter.setEnclosingSignature(this); - } - - if (!isOptional) { - this.nonOptionalParamCount++; - } - }; - - PullSignatureSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!this._typeParameters) { - this._typeParameters = []; - } - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - 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 = []; - } - - return this._typeParameters; - }; - - PullSignatureSymbol.prototype.findTypeParameter = function (name) { - var memberSymbol; - - if (!this._memberTypeParameterNameCache) { - this._memberTypeParameterNameCache = TypeScript.createIntrinsicsObject(); - - for (var i = 0; i < this.getTypeParameters().length; i++) { - this._memberTypeParameterNameCache[this._typeParameters[i].getName()] = this._typeParameters[i]; - } - } - - memberSymbol = this._memberTypeParameterNameCache[name]; - - 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; - this._stringConstantOverload = false; - for (var i = 0; i < params.length; i++) { - var paramType = params[i].type; - if (paramType && paramType.isPrimitive() && paramType.isStringConstant()) { - this._stringConstantOverload = true; - } - } - } - - 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); - allMemberNames.addAll(signatureMemberName); - return allMemberNames; - }; - - PullSignatureSymbol.getSignaturesTypeNameEx = function (signatures, prefix, shortform, brackets, scopeSymbol, getPrettyTypeName, candidateSignature) { - var result = []; - if (!signatures) { - return result; - } - - var len = signatures.length; - if (!getPrettyTypeName && len > 1) { - shortform = false; - } - - var foundDefinition = false; - if (candidateSignature && candidateSignature.isDefinition() && len > 1) { - candidateSignature = null; - } - - for (var i = 0; i < len; i++) { - if (len > 1 && signatures[i].isDefinition()) { - foundDefinition = true; - continue; - } - - var signature = signatures[i]; - if (getPrettyTypeName && candidateSignature) { - signature = candidateSignature; - } - - result.push(signature.getSignatureTypeNameEx(prefix, shortform, brackets, scopeSymbol)); - if (getPrettyTypeName) { - break; - } - } - - if (getPrettyTypeName && result.length && len > 1) { - var lastMemberName = result[result.length - 1]; - for (var i = i + 1; i < len; i++) { - if (signatures[i].isDefinition()) { - foundDefinition = true; - break; - } - } - var overloadString = TypeScript.getLocalizedText(TypeScript.DiagnosticCode._0_overload_s, [foundDefinition ? len - 2 : len - 1]); - lastMemberName.add(TypeScript.MemberName.create(overloadString)); - } - - return result; - }; - - PullSignatureSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getSignatureTypeNameEx(this.getScopedNameEx().toString(), false, false, scopeSymbol, undefined, useConstraintInName).toString(); - return s; - }; - - PullSignatureSymbol.prototype.getSignatureTypeNameEx = function (prefix, shortform, brackets, scopeSymbol, getParamMarkerInfo, getTypeParamMarkerInfo) { - var typeParamterBuilder = new TypeScript.MemberNameArray(); - - typeParamterBuilder.add(PullSymbol.getTypeParameterStringEx(this.getTypeParameters(), scopeSymbol, getTypeParamMarkerInfo, true)); - - if (brackets) { - typeParamterBuilder.add(TypeScript.MemberName.create("[")); - } else { - typeParamterBuilder.add(TypeScript.MemberName.create("(")); - } - - var builder = new TypeScript.MemberNameArray(); - builder.prefix = prefix; - - if (getTypeParamMarkerInfo) { - builder.prefix = prefix; - builder.addAll(typeParamterBuilder.entries); - } else { - builder.prefix = prefix + typeParamterBuilder.toString(); - } - - var params = this.parameters; - var paramLen = params.length; - for (var i = 0; i < paramLen; i++) { - var paramType = params[i].type; - var typeString = paramType ? ": " : ""; - var paramIsVarArg = params[i].isVarArg; - var varArgPrefix = paramIsVarArg ? "..." : ""; - var optionalString = (!paramIsVarArg && params[i].isOptional) ? "?" : ""; - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - builder.add(TypeScript.MemberName.create(varArgPrefix + params[i].getScopedNameEx(scopeSymbol).toString() + optionalString + typeString)); - if (paramType) { - builder.add(paramType.getScopedNameEx(scopeSymbol)); - } - if (getParamMarkerInfo) { - builder.add(new TypeScript.MemberName()); - } - if (i < paramLen - 1) { - builder.add(TypeScript.MemberName.create(", ")); - } - } - - if (shortform) { - if (brackets) { - builder.add(TypeScript.MemberName.create("] => ")); - } else { - builder.add(TypeScript.MemberName.create(") => ")); - } - } else { - if (brackets) { - builder.add(TypeScript.MemberName.create("]: ")); - } else { - builder.add(TypeScript.MemberName.create("): ")); - } - } - - if (this.returnType) { - builder.add(this.returnType.getScopedNameEx(scopeSymbol)); - } else { - builder.add(TypeScript.MemberName.create("any")); - } - - 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 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 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 wrappingTypeParameterID; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - PullSignatureSymbol.prototype._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker = function (enclosingType, knownWrapMap) { - if (this.returnType && this.returnType._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - - var parameters = this.parameters; - - for (var i = 0; i < parameters.length; i++) { - if (parameters[i].type && parameters[i].type._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse(enclosingType, knownWrapMap)) { - return true; - } - } - - return false; - }; - return PullSignatureSymbol; - })(PullSymbol); - TypeScript.PullSignatureSymbol = PullSignatureSymbol; - - var PullTypeSymbol = (function (_super) { - __extends(PullTypeSymbol, _super); - function PullTypeSymbol(name, kind) { - _super.call(this, name, kind); - this._members = TypeScript.sentinelEmptyArray; - this._enclosedMemberTypes = null; - this._enclosedMemberContainers = null; - this._typeParameters = null; - this._allowedToReferenceTypeParameters = null; - this._specializedVersionsOfThisType = null; - this._arrayVersionOfThisType = null; - this._implementedTypes = null; - this._extendedTypes = null; - this._typesThatExplicitlyImplementThisType = null; - this._typesThatExtendThisType = null; - this._callSignatures = null; - this._allCallSignatures = null; - this._constructSignatures = null; - this._indexSignatures = null; - this._allIndexSignatures = null; - this._allIndexSignaturesOfAugmentedType = null; - this._memberNameCache = null; - this._enclosedTypeNameCache = null; - this._enclosedContainerCache = null; - this._typeParameterNameCache = null; - this._containedNonMemberNameCache = null; - this._containedNonMemberTypeNameCache = null; - this._containedNonMemberContainerCache = null; - this._simpleInstantiationCache = null; - this._complexInstantiationCache = null; - this._hasGenericSignature = false; - this._hasGenericMember = false; - this._hasBaseTypeConflict = false; - this._knownBaseTypeCount = 0; - this._associatedContainerTypeSymbol = null; - this._constructorMethod = null; - this._hasDefaultConstructor = false; - this._functionSymbol = null; - this._inMemberTypeNameEx = false; - this.inSymbolPrivacyCheck = false; - this.inWrapCheck = false; - this.inWrapInfiniteExpandingReferenceCheck = false; - this.typeReference = null; - this._widenedType = null; - this._isArrayNamedTypeReference = undefined; - this.type = this; - } - PullTypeSymbol.prototype.isArrayNamedTypeReference = function () { - if (this._isArrayNamedTypeReference === undefined) { - this._isArrayNamedTypeReference = this.computeIsArrayNamedTypeReference(); - } - - return this._isArrayNamedTypeReference; - }; - - PullTypeSymbol.prototype.computeIsArrayNamedTypeReference = function () { - var typeArgs = this.getTypeArguments(); - if (typeArgs && this.getTypeArguments().length === 1 && this.name === "Array") { - var declaration = this.getDeclarations()[0]; - - if (declaration && declaration.getParentDecl() && declaration.getParentDecl().getParentDecl() === null) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.isType = function () { - return true; - }; - PullTypeSymbol.prototype.isClass = function () { - return this.kind === 8 /* Class */ || (this._constructorMethod !== null); - }; - PullTypeSymbol.prototype.isFunction = function () { - return (this.kind & (33554432 /* ConstructorType */ | 16777216 /* FunctionType */)) !== 0; - }; - PullTypeSymbol.prototype.isConstructor = function () { - return this.kind === 33554432 /* ConstructorType */; - }; - PullTypeSymbol.prototype.isTypeParameter = function () { - return false; - }; - PullTypeSymbol.prototype.isTypeVariable = function () { - return false; - }; - PullTypeSymbol.prototype.isError = function () { - return false; - }; - PullTypeSymbol.prototype.isEnum = function () { - return this.kind === 64 /* Enum */; - }; - - PullTypeSymbol.prototype.getTypeParameterArgumentMap = function () { - return null; - }; - - PullTypeSymbol.prototype.isObject = function () { - 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 () { - return this._knownBaseTypeCount; - }; - PullTypeSymbol.prototype.resetKnownBaseTypeCount = function () { - this._knownBaseTypeCount = 0; - }; - PullTypeSymbol.prototype.incrementKnownBaseCount = function () { - this._knownBaseTypeCount++; - }; - - PullTypeSymbol.prototype.setHasBaseTypeConflict = function () { - this._hasBaseTypeConflict = true; - }; - PullTypeSymbol.prototype.hasBaseTypeConflict = function () { - return this._hasBaseTypeConflict; - }; - - PullTypeSymbol.prototype.hasMembers = function () { - if (this._members !== TypeScript.sentinelEmptyArray) { - return true; - } - - var parents = this.getExtendedTypes(); - - for (var i = 0; i < parents.length; i++) { - if (parents[i].hasMembers()) { - return true; - } - } - - return false; - }; - - PullTypeSymbol.prototype.setHasGenericSignature = function () { - this._hasGenericSignature = true; - }; - PullTypeSymbol.prototype.getHasGenericSignature = function () { - return this._hasGenericSignature; - }; - - PullTypeSymbol.prototype.setHasGenericMember = function () { - this._hasGenericMember = true; - }; - PullTypeSymbol.prototype.getHasGenericMember = function () { - return this._hasGenericMember; - }; - - PullTypeSymbol.prototype.setAssociatedContainerType = function (type) { - this._associatedContainerTypeSymbol = type; - }; - - PullTypeSymbol.prototype.getAssociatedContainerType = function () { - return this._associatedContainerTypeSymbol; - }; - - PullTypeSymbol.prototype.getArrayType = function () { - return this._arrayVersionOfThisType; - }; - - PullTypeSymbol.prototype.getElementType = function () { - return null; - }; - - PullTypeSymbol.prototype.setArrayType = function (arrayType) { - this._arrayVersionOfThisType = arrayType; - }; - - PullTypeSymbol.prototype.getFunctionSymbol = function () { - return this._functionSymbol; - }; - - PullTypeSymbol.prototype.setFunctionSymbol = function (symbol) { - if (symbol) { - this._functionSymbol = symbol; - } - }; - - PullTypeSymbol.prototype.findContainedNonMember = function (name) { - if (!this._containedNonMemberNameCache) { - return null; - } - - return this._containedNonMemberNameCache[name]; - }; - - PullTypeSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberTypeNameCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberTypeNameCache[typeName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - if (!this._containedNonMemberContainerCache) { - return null; - } - - var nonMemberSymbol = this._containedNonMemberContainerCache[containerName]; - - if (nonMemberSymbol && kind !== 0 /* None */) { - nonMemberSymbol = TypeScript.hasFlag(nonMemberSymbol.kind, kind) ? nonMemberSymbol : null; - } - - return nonMemberSymbol; - }; - - PullTypeSymbol.prototype.addMember = function (memberSymbol) { - if (!memberSymbol) { - return; - } - - memberSymbol.setContainer(this); - - if (!this._memberNameCache) { - this._memberNameCache = TypeScript.createIntrinsicsObject(); - } - - if (this._members === TypeScript.sentinelEmptyArray) { - this._members = []; - } - - this._members.push(memberSymbol); - this._memberNameCache[memberSymbol.name] = memberSymbol; - }; - - PullTypeSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - if (!enclosedType) { - return; - } - - enclosedType.setContainer(this); - - if (!this._enclosedTypeNameCache) { - this._enclosedTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberTypes) { - this._enclosedMemberTypes = []; - } - - this._enclosedMemberTypes[this._enclosedMemberTypes.length] = enclosedType; - this._enclosedTypeNameCache[enclosedType.name] = enclosedType; - }; - - PullTypeSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - if (!enclosedContainer) { - return; - } - - enclosedContainer.setContainer(this); - - if (!this._enclosedContainerCache) { - this._enclosedContainerCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._enclosedMemberContainers) { - this._enclosedMemberContainers = []; - } - - this._enclosedMemberContainers[this._enclosedMemberContainers.length] = enclosedContainer; - this._enclosedContainerCache[enclosedContainer.name] = enclosedContainer; - }; - - PullTypeSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - if (!enclosedNonMember) { - return; - } - - enclosedNonMember.setContainer(this); - - if (!this._containedNonMemberNameCache) { - this._containedNonMemberNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberNameCache[enclosedNonMember.name] = enclosedNonMember; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - if (!enclosedNonMemberType) { - return; - } - - enclosedNonMemberType.setContainer(this); - - if (!this._containedNonMemberTypeNameCache) { - this._containedNonMemberTypeNameCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberTypeNameCache[enclosedNonMemberType.name] = enclosedNonMemberType; - }; - - PullTypeSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - if (!enclosedNonMemberContainer) { - return; - } - - enclosedNonMemberContainer.setContainer(this); - - if (!this._containedNonMemberContainerCache) { - this._containedNonMemberContainerCache = TypeScript.createIntrinsicsObject(); - } - - this._containedNonMemberContainerCache[enclosedNonMemberContainer.name] = enclosedNonMemberContainer; - }; - - PullTypeSymbol.prototype.addTypeParameter = function (typeParameter) { - if (!typeParameter) { - return; - } - - if (!typeParameter.getContainer()) { - typeParameter.setContainer(this); - } - - if (!this._typeParameterNameCache) { - this._typeParameterNameCache = TypeScript.createIntrinsicsObject(); - } - - if (!this._typeParameters) { - this._typeParameters = []; - } - - this._typeParameters[this._typeParameters.length] = typeParameter; - this._typeParameterNameCache[typeParameter.getName()] = typeParameter; - }; - - PullTypeSymbol.prototype.getMembers = function () { - return this._members; - }; - - PullTypeSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - this._hasDefaultConstructor = hasOne; - }; - - PullTypeSymbol.prototype.getHasDefaultConstructor = function () { - return this._hasDefaultConstructor; - }; - - PullTypeSymbol.prototype.getConstructorMethod = function () { - return this._constructorMethod; - }; - - PullTypeSymbol.prototype.setConstructorMethod = function (constructorMethod) { - this._constructorMethod = constructorMethod; - }; - - PullTypeSymbol.prototype.getTypeParameters = function () { - if (!this._typeParameters) { - return TypeScript.sentinelEmptyArray; - } - - 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 (typeArgumentMap) { - if (this.isTypeParameter()) { - return true; - } - - 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[this.getSimpleInstantiationCacheId(typeArgumentMap)] = specializedVersionOfThisType; - } else { - if (!this._complexInstantiationCache) { - this._complexInstantiationCache = TypeScript.createIntrinsicsObject(); - } - - this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)] = specializedVersionOfThisType; - } - - if (!this._specializedVersionsOfThisType) { - this._specializedVersionsOfThisType = []; - } - - this._specializedVersionsOfThisType.push(specializedVersionOfThisType); - }; - - PullTypeSymbol.prototype.getSpecialization = function (typeArgumentMap) { - if (this.canUseSimpleInstantiationCache(typeArgumentMap)) { - if (!this._simpleInstantiationCache) { - return null; - } - - var result = this._simpleInstantiationCache[this.getSimpleInstantiationCacheId(typeArgumentMap)]; - return result || null; - } else { - if (!this._complexInstantiationCache) { - return null; - } - - if (this.getAllowedToReferenceTypeParameters().length == 0) { - return this; - } - - var result = this._complexInstantiationCache[getIDForTypeSubstitutions(this, typeArgumentMap)]; - return result || null; - } - }; - - PullTypeSymbol.prototype.getKnownSpecializations = function () { - if (!this._specializedVersionsOfThisType) { - return TypeScript.sentinelEmptyArray; - } - - return this._specializedVersionsOfThisType; - }; - - PullTypeSymbol.prototype.getTypeArguments = function () { - return null; - }; - - PullTypeSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - return this.getTypeParameters(); - }; - - PullTypeSymbol.prototype.addCallSignaturePrerequisite = function (callSignature) { - if (!this._callSignatures) { - this._callSignatures = []; - } - - if (callSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - callSignature.functionType = this; - }; - - 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 = []; - } - - if (constructSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - 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 = []; - } - - this._indexSignatures[this._indexSignatures.length] = indexSignature; - - if (indexSignature.isGeneric()) { - this._hasGenericSignature = true; - } - - indexSignature.functionType = this; - }; - - 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; - } - - var signatures = []; - - if (this._callSignatures) { - signatures = signatures.concat(this._callSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._callSignatures, this._extendedTypes[i].getCallSignatures(), signatures); - } - } - - this._allCallSignatures = signatures; - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnConstructSignatures = function () { - return this._constructSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnConstructSignatures = function () { - return this._constructSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getConstructSignatures = function () { - var signatures = []; - - if (this._constructSignatures) { - signatures = signatures.concat(this._constructSignatures); - } - - if (this._extendedTypes && this.kind === 16 /* Interface */) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._constructSignatures, this._extendedTypes[i].getConstructSignatures(), signatures); - } - } - - return signatures; - }; - - PullTypeSymbol.prototype.hasOwnIndexSignatures = function () { - return this._indexSignatures !== null; - }; - - PullTypeSymbol.prototype.getOwnIndexSignatures = function () { - return this._indexSignatures || TypeScript.sentinelEmptyArray; - }; - - PullTypeSymbol.prototype.getIndexSignatures = function () { - if (this._allIndexSignatures) { - return this._allIndexSignatures; - } - - var signatures = []; - - if (this._indexSignatures) { - signatures = signatures.concat(this._indexSignatures); - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - if (this._extendedTypes[i].hasBase(this)) { - continue; - } - - this._getResolver()._addUnhiddenSignaturesFromBaseType(this._indexSignatures, this._extendedTypes[i].getIndexSignatures(), signatures); - } - } - - this._allIndexSignatures = signatures; - - 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; - } - - if (!this._implementedTypes) { - this._implementedTypes = []; - } - - this._implementedTypes[this._implementedTypes.length] = implementedType; - - implementedType.addTypeThatExplicitlyImplementsThisType(this); - }; - - PullTypeSymbol.prototype.getImplementedTypes = function () { - if (!this._implementedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._implementedTypes; - }; - - PullTypeSymbol.prototype.addExtendedType = function (extendedType) { - if (!extendedType) { - return; - } - - if (!this._extendedTypes) { - this._extendedTypes = []; - } - - this._extendedTypes[this._extendedTypes.length] = extendedType; - - extendedType.addTypeThatExtendsThisType(this); - }; - - PullTypeSymbol.prototype.getExtendedTypes = function () { - if (!this._extendedTypes) { - return TypeScript.sentinelEmptyArray; - } - - return this._extendedTypes; - }; - - PullTypeSymbol.prototype.addTypeThatExtendsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - this._typesThatExtendThisType[this._typesThatExtendThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExtendThisType = function () { - if (!this._typesThatExtendThisType) { - this._typesThatExtendThisType = []; - } - - return this._typesThatExtendThisType; - }; - - PullTypeSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - if (!type) { - return; - } - - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - this._typesThatExplicitlyImplementThisType[this._typesThatExplicitlyImplementThisType.length] = type; - }; - - PullTypeSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - if (!this._typesThatExplicitlyImplementThisType) { - this._typesThatExplicitlyImplementThisType = []; - } - - return this._typesThatExplicitlyImplementThisType; - }; - - PullTypeSymbol.prototype.hasBase = function (potentialBase, visited) { - if (typeof visited === "undefined") { visited = []; } - if (this === potentialBase || this.getRootSymbol() === potentialBase || this === potentialBase.getRootSymbol()) { - return true; - } - - if (TypeScript.ArrayUtilities.contains(visited, this)) { - return true; - } - - visited.push(this); - - var extendedTypes = this.getExtendedTypes(); - - for (var i = 0; i < extendedTypes.length; i++) { - if (extendedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - var implementedTypes = this.getImplementedTypes(); - - for (var i = 0; i < implementedTypes.length; i++) { - if (implementedTypes[i].hasBase(potentialBase, visited)) { - return true; - } - } - - visited.pop(); - - return false; - }; - - PullTypeSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - if (baseType.isError()) { - return false; - } - - var thisIsClass = this.isClass(); - if (isExtendedType) { - if (thisIsClass) { - return baseType.kind === 8 /* Class */; - } - } else { - if (!thisIsClass) { - return false; - } - } - - return !!(baseType.kind & (16 /* Interface */ | 8 /* Class */)); - }; - - PullTypeSymbol.prototype.findMember = function (name, lookInParent) { - var memberSymbol = null; - - if (this._memberNameCache) { - memberSymbol = this._memberNameCache[name]; - } - - if (memberSymbol || !lookInParent) { - return memberSymbol; - } - - if (this._extendedTypes) { - for (var i = 0; i < this._extendedTypes.length; i++) { - memberSymbol = this._extendedTypes[i].findMember(name, lookInParent); - - if (memberSymbol) { - return memberSymbol; - } - } - } - - return null; - }; - - PullTypeSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedTypeNameCache) { - return null; - } - - memberSymbol = this._enclosedTypeNameCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - var memberSymbol; - - if (!this._enclosedContainerCache) { - return null; - } - - memberSymbol = this._enclosedContainerCache[name]; - - if (memberSymbol && kind !== 0 /* None */) { - memberSymbol = TypeScript.hasFlag(memberSymbol.kind, kind) ? memberSymbol : null; - } - - return memberSymbol; - }; - - PullTypeSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - var allMembers = []; - - 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 */))) { - allMembers[allMembers.length] = member; - } - } - } - - if (this._extendedTypes) { - var extenedMembersVisibility = memberVisiblity !== 0 /* all */ ? 2 /* externallyVisible */ : 0 /* all */; - - for (var i = 0, n = this._extendedTypes.length; i < n; i++) { - var extendedMembers = this._extendedTypes[i].getAllMembers(searchDeclKind, extenedMembersVisibility); - - for (var j = 0, m = extendedMembers.length; j < m; j++) { - var extendedMember = extendedMembers[j]; - if (!(this._memberNameCache && this._memberNameCache[extendedMember.name])) { - allMembers[allMembers.length] = extendedMember; - } - } - } - } - - if (this.isContainer()) { - if (this._enclosedMemberTypes) { - for (var i = 0; i < this._enclosedMemberTypes.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberTypes[i]; - } - } - if (this._enclosedMemberContainers) { - for (var i = 0; i < this._enclosedMemberContainers.length; i++) { - allMembers[allMembers.length] = this._enclosedMemberContainers[i]; - } - } - } - - return allMembers; - }; - - PullTypeSymbol.prototype.findTypeParameter = function (name) { - if (!this._typeParameterNameCache) { - return null; - } - - return this._typeParameterNameCache[name]; - }; - - PullTypeSymbol.prototype.setResolved = function () { - _super.prototype.setResolved.call(this); - }; - - PullTypeSymbol.prototype.getNamePartForFullName = function () { - var name = _super.prototype.getNamePartForFullName.call(this); - - var typars = this.getTypeArgumentsOrTypeParameters(); - var typarString = PullSymbol.getTypeParameterString(typars, this, true); - return name + typarString; - }; - - PullTypeSymbol.prototype.getScopedName = function (scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName) { - return this.getScopedNameEx(scopeSymbol, skipTypeParametersInName, useConstraintInName, false, false, skipInternalAliasName).toString(); - }; - - 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 !== "")) { - return true; - } - - return false; - }; - - PullTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - var s = this.getScopedNameEx(scopeSymbol, false, useConstraintInName).toString(); - return s; - }; - - 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, "", "[]"); - } - - if (!this.isNamedTypeSymbol()) { - return this.getMemberTypeNameEx(true, scopeSymbol, getPrettyTypeName); - } - - if (skipTypeParametersInName) { - return TypeScript.MemberName.create(_super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName)); - } else { - var builder = new TypeScript.MemberNameArray(); - builder.prefix = _super.prototype.getScopedName.call(this, scopeSymbol, skipTypeParametersInName, useConstraintInName, skipInternalAliasName); - - var typars = this.getTypeArgumentsOrTypeParameters(); - builder.add(PullSymbol.getTypeParameterStringEx(typars, scopeSymbol, getTypeParamMarkerInfo, useConstraintInName)); - - return builder; - } - }; - - PullTypeSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - return members.length === 0 && constructSignatures.length === 0 && callSignatures.length > 1; - }; - - PullTypeSymbol.prototype.getTypeOfSymbol = function () { - var associatedContainerType = this.getAssociatedContainerType(); - if (associatedContainerType && associatedContainerType.isNamedTypeSymbol()) { - return associatedContainerType; - } - - var functionSymbol = this.getFunctionSymbol(); - if (functionSymbol && functionSymbol.kind === 16384 /* Function */ && !TypeScript.PullHelpers.isSymbolLocal(functionSymbol)) { - return TypeScript.PullHelpers.isExportedSymbolInClodule(functionSymbol) ? null : functionSymbol; - } - - return null; - }; - - PullTypeSymbol.prototype.getMemberTypeNameEx = function (topLevel, scopeSymbol, getPrettyTypeName) { - var members = this.getMembers(); - var callSignatures = this.getCallSignatures(); - var constructSignatures = this.getConstructSignatures(); - var indexSignatures = this.getIndexSignatures(); - - if (members.length > 0 || callSignatures.length > 0 || constructSignatures.length > 0 || indexSignatures.length > 0) { - var typeOfSymbol = this.getTypeOfSymbol(); - if (typeOfSymbol) { - var nameForTypeOf = typeOfSymbol.getScopedNameEx(scopeSymbol, true); - return TypeScript.MemberName.create(nameForTypeOf, "typeof ", ""); - } - - if (this._inMemberTypeNameEx) { - return TypeScript.MemberName.create("any"); - } - - this._inMemberTypeNameEx = true; - - var allMemberNames = new TypeScript.MemberNameArray(); - 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()) { - var methodCallSignatures = members[i].type.getCallSignatures(); - var nameStr = members[i].getDisplayName(scopeSymbol) + (members[i].isOptional ? "?" : ""); - ; - var methodMemberNames = PullSignatureSymbol.getSignaturesTypeNameEx(methodCallSignatures, nameStr, false, false, scopeSymbol); - allMemberNames.addAll(methodMemberNames); - } else { - var memberTypeName = members[i].getNameAndTypeNameEx(scopeSymbol); - if (memberTypeName.isArray() && memberTypeName.delim === delim) { - allMemberNames.addAll(memberTypeName.entries); - } else { - allMemberNames.add(memberTypeName); - } - } - curlies = true; - } - - var getPrettyFunctionOverload = getPrettyTypeName && !curlies && this.hasOnlyOverloadCallSignatures(); - - var signatureCount = callSignatures.length + constructSignatures.length + indexSignatures.length; - var useShortFormSignature = !curlies && (signatureCount === 1); - var signatureMemberName; - - if (callSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(callSignatures, "", useShortFormSignature, false, scopeSymbol, getPrettyFunctionOverload); - allMemberNames.addAll(signatureMemberName); - } - - if (constructSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(constructSignatures, "new", useShortFormSignature, false, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if (indexSignatures.length > 0) { - signatureMemberName = PullSignatureSymbol.getSignaturesTypeNameEx(indexSignatures, "", useShortFormSignature, true, scopeSymbol); - allMemberNames.addAll(signatureMemberName); - } - - if ((curlies) || (!getPrettyFunctionOverload && (signatureCount > 1) && topLevel)) { - allMemberNames.prefix = "{ "; - allMemberNames.suffix = "}"; - allMemberNames.delim = delim; - } else if (allMemberNames.entries.length > 1) { - allMemberNames.delim = delim; - } - - this._inMemberTypeNameEx = false; - - return allMemberNames; - } - - return TypeScript.MemberName.create("{}"); - }; - - PullTypeSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - return 2 /* Closed */; - }; - - PullTypeSymbol.prototype.wrapsSomeTypeParameter = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - return this.getWrappingTypeParameterID(typeParameterArgumentMap, skipTypeArgumentCheck) != 0; - }; - - PullTypeSymbol.prototype.getWrappingTypeParameterID = function (typeParameterArgumentMap, skipTypeArgumentCheck) { - var type = this; - - if (type.isTypeParameter()) { - if (typeParameterArgumentMap[type.pullSymbolID] || typeParameterArgumentMap[type.getRootSymbol().pullSymbolID]) { - return type.pullSymbolID; - } - - var constraint = type.getConstraint(); - var wrappingTypeParameterID = constraint ? constraint.getWrappingTypeParameterID(typeParameterArgumentMap) : 0; - return wrappingTypeParameterID; - } - - if (type.inWrapCheck) { - return 0; - } - - 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; - - var typeArguments = type.getTypeArguments(); - - if (type.isGeneric() && !typeArguments) { - typeArguments = type.getTypeParameters(); - } - - if (typeArguments) { - for (var i = 0; !wrappingTypeParameterID && i < typeArguments.length; i++) { - wrappingTypeParameterID = typeArguments[i].getWrappingTypeParameterID(typeParameterArgumentMap); - } - } - } - - 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); - } - - wrappingTypeParameterID = wrappingTypeParameterID || this.getWrappingTypeParameterIDFromSignatures(type.getCallSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getConstructSignatures(), typeParameterArgumentMap) || this.getWrappingTypeParameterIDFromSignatures(type.getIndexSignatures(), typeParameterArgumentMap); - } - - if (!skipTypeArgumentCheck) { - type.inWrapCheck = false; - } - - return wrappingTypeParameterID; - }; - - 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._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceRecurse = function (enclosingType, knownWrapMap) { - var wrapsIntoInfinitelyExpandingTypeReference = knownWrapMap.valueAt(this.pullSymbolID, enclosingType.pullSymbolID); - if (wrapsIntoInfinitelyExpandingTypeReference != undefined) { - return wrapsIntoInfinitelyExpandingTypeReference; - } - - if (this.inWrapInfiniteExpandingReferenceCheck) { - return false; - } - - this.inWrapInfiniteExpandingReferenceCheck = true; - wrapsIntoInfinitelyExpandingTypeReference = this._wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReferenceWorker(enclosingType, knownWrapMap); - knownWrapMap.setValueAt(this.pullSymbolID, enclosingType.pullSymbolID, wrapsIntoInfinitelyExpandingTypeReference); - this.inWrapInfiniteExpandingReferenceCheck = false; - - return wrapsIntoInfinitelyExpandingTypeReference; - }; - - 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(); - for (var i = 0; i < typeArguments.length; i++) { - if (TypeScript.ArrayUtilities.contains(enclosingTypeParameters, typeArguments[i])) { - continue; - } - - if (typeArguments[i].wrapsSomeTypeParameter(this.getTypeParameterArgumentMap())) { - return true; - } - } - - 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); - TypeScript.PullTypeSymbol = PullTypeSymbol; - - var PullPrimitiveTypeSymbol = (function (_super) { - __extends(PullPrimitiveTypeSymbol, _super); - function PullPrimitiveTypeSymbol(name) { - _super.call(this, name, 2 /* Primitive */); - - this.isResolved = true; - } - PullPrimitiveTypeSymbol.prototype.isAny = function () { - 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 () { - return false; - }; - - 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; - - var PullStringConstantTypeSymbol = (function (_super) { - __extends(PullStringConstantTypeSymbol, _super); - function PullStringConstantTypeSymbol(name) { - _super.call(this, name); - } - PullStringConstantTypeSymbol.prototype.isStringConstant = function () { - return true; - }; - return PullStringConstantTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullStringConstantTypeSymbol = PullStringConstantTypeSymbol; - - var PullErrorTypeSymbol = (function (_super) { - __extends(PullErrorTypeSymbol, _super); - function PullErrorTypeSymbol(_anyType, name) { - _super.call(this, name); - 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); - }; - - PullErrorTypeSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - - PullErrorTypeSymbol.prototype.toString = function (scopeSymbol, useConstraintInName) { - return this._anyType.getName(scopeSymbol, useConstraintInName); - }; - return PullErrorTypeSymbol; - })(PullPrimitiveTypeSymbol); - TypeScript.PullErrorTypeSymbol = PullErrorTypeSymbol; - - var PullContainerSymbol = (function (_super) { - __extends(PullContainerSymbol, _super); - function PullContainerSymbol(name, kind) { - _super.call(this, name, kind); - this.instanceSymbol = null; - this.assignedValue = null; - this.assignedType = null; - this.assignedContainer = null; - } - PullContainerSymbol.prototype.isContainer = function () { - return true; - }; - - PullContainerSymbol.prototype.setInstanceSymbol = function (symbol) { - this.instanceSymbol = symbol; - }; - - PullContainerSymbol.prototype.getInstanceSymbol = function () { - return this.instanceSymbol; - }; - - PullContainerSymbol.prototype.setExportAssignedValueSymbol = function (symbol) { - this.assignedValue = symbol; - }; - - PullContainerSymbol.prototype.getExportAssignedValueSymbol = function () { - return this.assignedValue; - }; - - PullContainerSymbol.prototype.setExportAssignedTypeSymbol = function (type) { - this.assignedType = type; - }; - - PullContainerSymbol.prototype.getExportAssignedTypeSymbol = function () { - return this.assignedType; - }; - - PullContainerSymbol.prototype.setExportAssignedContainerSymbol = function (container) { - this.assignedContainer = container; - }; - - PullContainerSymbol.prototype.getExportAssignedContainerSymbol = function () { - return this.assignedContainer; - }; - - PullContainerSymbol.prototype.hasExportAssignment = function () { - return !!this.assignedValue || !!this.assignedType || !!this.assignedContainer; - }; - - PullContainerSymbol.usedAsSymbol = function (containerSymbol, symbol) { - if (!containerSymbol || !containerSymbol.isContainer()) { - return false; - } - - if (!containerSymbol.isAlias() && containerSymbol.type === symbol) { - return true; - } - - var moduleSymbol = containerSymbol; - var valueExportSymbol = moduleSymbol.getExportAssignedValueSymbol(); - var typeExportSymbol = moduleSymbol.getExportAssignedTypeSymbol(); - var containerExportSymbol = moduleSymbol.getExportAssignedContainerSymbol(); - if (valueExportSymbol || typeExportSymbol || containerExportSymbol) { - return valueExportSymbol === symbol || typeExportSymbol == symbol || containerExportSymbol == symbol || PullContainerSymbol.usedAsSymbol(containerExportSymbol, symbol); - } - - return false; - }; - - PullContainerSymbol.prototype.getInstanceType = function () { - return this.instanceSymbol ? this.instanceSymbol.type : null; - }; - return PullContainerSymbol; - })(PullTypeSymbol); - TypeScript.PullContainerSymbol = PullContainerSymbol; - - var PullTypeAliasSymbol = (function (_super) { - __extends(PullTypeAliasSymbol, _super); - function PullTypeAliasSymbol(name) { - _super.call(this, name, 128 /* TypeAlias */); - this._assignedValue = null; - this._assignedType = null; - 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; - }; - - PullTypeAliasSymbol.prototype.isUsedAsValue = function () { - this._resolveDeclaredSymbol(); - return this._isUsedAsValue; - }; - - PullTypeAliasSymbol.prototype.setTypeUsedExternally = function () { - this._typeUsedExternally = true; - }; - - PullTypeAliasSymbol.prototype.setIsUsedInExportedAlias = function () { - this._isUsedInExportAlias = true; - if (this.linkedAliasSymbols) { - this.linkedAliasSymbols.forEach(function (s) { - return s.setIsUsedInExportedAlias(); - }); - } - }; - - 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(); - }); - } - }; - - PullTypeAliasSymbol.prototype.assignedValue = function () { - this._resolveDeclaredSymbol(); - return this._assignedValue; - }; - - PullTypeAliasSymbol.prototype.assignedType = function () { - this._resolveDeclaredSymbol(); - return this._assignedType; - }; - - PullTypeAliasSymbol.prototype.assignedContainer = function () { - this._resolveDeclaredSymbol(); - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.isAlias = function () { - return true; - }; - PullTypeAliasSymbol.prototype.isContainer = function () { - return true; - }; - - PullTypeAliasSymbol.prototype.setAssignedValueSymbol = function (symbol) { - this._assignedValue = symbol; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedValueSymbol = function () { - if (this._assignedValue) { - return this._assignedValue; - } - - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedValueSymbol(); - this.retrievingExportAssignment = false; - return sym; - } - - return null; - }; - - PullTypeAliasSymbol.prototype.setAssignedTypeSymbol = function (type) { - this._assignedType = type; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedTypeSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedType) { - if (this._assignedType.isAlias()) { - this.retrievingExportAssignment = true; - var sym = this._assignedType.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - } else if (this._assignedType !== this._assignedContainer) { - return this._assignedType; - } - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedTypeSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.setAssignedContainerSymbol = function (container) { - this._assignedContainer = container; - }; - - PullTypeAliasSymbol.prototype.getExportAssignedContainerSymbol = function () { - if (this.retrievingExportAssignment) { - return null; - } - - if (this._assignedContainer) { - this.retrievingExportAssignment = true; - var sym = this._assignedContainer.getExportAssignedContainerSymbol(); - this.retrievingExportAssignment = false; - if (sym) { - return sym; - } - } - - return this._assignedContainer; - }; - - PullTypeAliasSymbol.prototype.getMembers = function () { - if (this._assignedType) { - return this._assignedType.getMembers(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getCallSignatures = function () { - if (this._assignedType) { - return this._assignedType.getCallSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getConstructSignatures = function () { - if (this._assignedType) { - return this._assignedType.getConstructSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.getIndexSignatures = function () { - if (this._assignedType) { - return this._assignedType.getIndexSignatures(); - } - - return TypeScript.sentinelEmptyArray; - }; - - PullTypeAliasSymbol.prototype.findMember = function (name) { - if (this._assignedType) { - return this._assignedType.findMember(name, true); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedType = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedType(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.findNestedContainer = function (name) { - if (this._assignedType) { - return this._assignedType.findNestedContainer(name); - } - - return null; - }; - - PullTypeAliasSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisibility) { - if (this._assignedType) { - return this._assignedType.getAllMembers(searchDeclKind, memberVisibility); - } - - return TypeScript.sentinelEmptyArray; - }; - return PullTypeAliasSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeAliasSymbol = PullTypeAliasSymbol; - - var PullTypeParameterSymbol = (function (_super) { - __extends(PullTypeParameterSymbol, _super); - function PullTypeParameterSymbol(name) { - _super.call(this, name, 8192 /* TypeParameter */); - this._constraint = null; - } - PullTypeParameterSymbol.prototype.isTypeParameter = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.setConstraint = function (constraintType) { - this._constraint = constraintType; - }; - - PullTypeParameterSymbol.prototype.getConstraint = function () { - 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(); - } - - return _super.prototype.getCallSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getConstructSignatures = function () { - if (this._constraint) { - return this._constraint.getConstructSignatures(); - } - - return _super.prototype.getConstructSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.getIndexSignatures = function () { - if (this._constraint) { - return this._constraint.getIndexSignatures(); - } - - return _super.prototype.getIndexSignatures.call(this); - }; - - PullTypeParameterSymbol.prototype.isGeneric = function () { - return true; - }; - - PullTypeParameterSymbol.prototype.fullName = function (scopeSymbol) { - var name = this.getDisplayName(scopeSymbol); - var container = this.getContainer(); - if (container) { - var containerName = container.fullName(scopeSymbol); - name = name + " in " + containerName; - } - - return name; - }; - - PullTypeParameterSymbol.prototype.getName = function (scopeSymbol, useConstraintInName) { - var name = _super.prototype.getName.call(this, scopeSymbol); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.getDisplayName = function (scopeSymbol, useConstraintInName, skipInternalAliasName) { - var name = _super.prototype.getDisplayName.call(this, scopeSymbol, useConstraintInName, skipInternalAliasName); - - if (this.isPrinting) { - return name; - } - - this.isPrinting = true; - - if (useConstraintInName && this._constraint) { - name += " extends " + this._constraint.toString(scopeSymbol); - } - - this.isPrinting = false; - - return name; - }; - - PullTypeParameterSymbol.prototype.isExternallyVisible = function (inIsExternallyVisibleSymbols) { - return true; - }; - return PullTypeParameterSymbol; - })(PullTypeSymbol); - TypeScript.PullTypeParameterSymbol = PullTypeParameterSymbol; - - var PullAccessorSymbol = (function (_super) { - __extends(PullAccessorSymbol, _super); - function PullAccessorSymbol(name) { - _super.call(this, name, 4096 /* Property */); - this._getterSymbol = null; - this._setterSymbol = null; - } - PullAccessorSymbol.prototype.isAccessor = function () { - return true; - }; - - PullAccessorSymbol.prototype.setSetter = function (setter) { - if (!setter) { - return; - } - - this._setterSymbol = setter; - }; - - PullAccessorSymbol.prototype.getSetter = function () { - return this._setterSymbol; - }; - - PullAccessorSymbol.prototype.setGetter = function (getter) { - if (!getter) { - return; - } - - this._getterSymbol = getter; - }; - - PullAccessorSymbol.prototype.getGetter = function () { - return this._getterSymbol; - }; - return PullAccessorSymbol; - })(PullSymbol); - TypeScript.PullAccessorSymbol = PullAccessorSymbol; - - function getIDForTypeSubstitutions(instantiatingTypeOrSignature, typeArgumentMap) { - var substitution = ""; - var members = null; - - 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 getIDForTypeSubstitutionsOfType(type) { - var structure; - if (type.isError()) { - structure = "E" + getIDForTypeSubstitutionsOfType(type._anyType); - } else if (!type.isNamedTypeSymbol()) { - structure = getIDForTypeSubstitutionsFromObjectType(type); - } - - if (!structure) { - structure = type.pullSymbolID + "#"; - } - - return structure; - } - - function getIDForTypeSubstitutionsFromObjectType(type) { - if (type.isResolved) { - var getIDForTypeSubStitutionWalker = new GetIDForTypeSubStitutionWalker(); - TypeScript.PullHelpers.walkPullTypeSymbolStructure(type, getIDForTypeSubStitutionWalker); - } - - return null; - } - - var GetIDForTypeSubStitutionWalker = (function () { - function GetIDForTypeSubStitutionWalker() { - this.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"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["internallyVisible"] = 1] = "internallyVisible"; - - GetAllMembersVisiblity[GetAllMembersVisiblity["externallyVisible"] = 2] = "externallyVisible"; - })(TypeScript.GetAllMembersVisiblity || (TypeScript.GetAllMembersVisiblity = {})); - 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._inferredTypeAfterFixing = null; - this.inferenceCandidates = []; - } - CandidateInferenceInfo.prototype.addCandidate = function (candidate) { - 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 TypeArgumentInferenceContext = (function () { - function TypeArgumentInferenceContext(resolver, context, signatureBeingInferred) { - this.resolver = resolver; - this.context = context; - this.signatureBeingInferred = signatureBeingInferred; - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - this.candidateCache = []; - var typeParameters = signatureBeingInferred.getTypeParameters(); - for (var i = 0; i < typeParameters.length; i++) { - this.addInferenceRoot(typeParameters[i]); - } - } - TypeArgumentInferenceContext.prototype.alreadyRelatingTypes = function (objectType, parameterType) { - if (this.inferenceCache.valueAt(objectType.pullSymbolID, parameterType.pullSymbolID)) { - return true; - } else { - this.inferenceCache.setValueAt(objectType.pullSymbolID, parameterType.pullSymbolID, true); - return false; - } - }; - - TypeArgumentInferenceContext.prototype.resetRelationshipCache = function () { - this.inferenceCache.release(); - this.inferenceCache = TypeScript.BitMatrix.getBitMatrix(false); - }; - - TypeArgumentInferenceContext.prototype.addInferenceRoot = function (param) { - var info = this.candidateCache[param.pullSymbolID]; - - if (!info) { - info = new CandidateInferenceInfo(); - info.typeParameter = param; - this.candidateCache[param.pullSymbolID] = info; - } - }; - - TypeArgumentInferenceContext.prototype.getInferenceInfo = function (param) { - return this.candidateCache[param.pullSymbolID]; - }; - - TypeArgumentInferenceContext.prototype.addCandidateForInference = function (param, candidate) { - var info = this.getInferenceInfo(param); - - if (info && candidate && info.inferenceCandidates.indexOf(candidate) < 0) { - info.addCandidate(candidate); - } - }; - - 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); - } - }; - - 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]; - - info.fixTypeParameter(this.resolver, this.context); - - for (var i = 0; i < results.length; i++) { - if (results[i].type === info.typeParameter) { - results[i].type = info._inferredTypeAfterFixing; - } - } - - results.push(info._inferredTypeAfterFixing); - } - - return results; - }; - - TypeArgumentInferenceContext.prototype.isInvocationInferenceContext = function () { - throw TypeScript.Errors.abstract(); - }; - return TypeArgumentInferenceContext; - })(); - 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, isInferentiallyTyping, typeArgumentInferenceContext) { - this.contextualType = contextualType; - this.provisional = provisional; - this.isInferentiallyTyping = isInferentiallyTyping; - this.typeArgumentInferenceContext = typeArgumentInferenceContext; - this.provisionallyTypedSymbols = []; - this.hasProvisionalErrors = false; - this.astSymbolMap = []; - } - PullContextualTypeContext.prototype.recordProvisionallyTypedSymbol = function (symbol) { - this.provisionallyTypedSymbols[this.provisionallyTypedSymbols.length] = symbol; - }; - - PullContextualTypeContext.prototype.invalidateProvisionallyTypedSymbols = function () { - for (var i = 0; i < this.provisionallyTypedSymbols.length; i++) { - this.provisionallyTypedSymbols[i].setUnresolved(); - } - }; - - PullContextualTypeContext.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - PullContextualTypeContext.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()]; - }; - return PullContextualTypeContext; - })(); - TypeScript.PullContextualTypeContext = PullContextualTypeContext; - - var PullTypeResolutionContext = (function () { - function PullTypeResolutionContext(resolver, inTypeCheck, fileName) { - if (typeof inTypeCheck === "undefined") { inTypeCheck = false; } - if (typeof fileName === "undefined") { fileName = null; } - this.resolver = resolver; - this.inTypeCheck = inTypeCheck; - 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"); - this.typeCheckedNodes = TypeScript.BitVector.getBitVector(false); - } - } - PullTypeResolutionContext.prototype.setTypeChecked = function (ast) { - if (!this.inProvisionalResolution()) { - this.typeCheckedNodes.setValueAt(ast.syntaxID(), true); - } - }; - - PullTypeResolutionContext.prototype.canTypeCheckAST = function (ast) { - return this.typeCheck() && !this.typeCheckedNodes.valueAt(ast.syntaxID()) && this.fileName === ast.fileName(); - }; - - PullTypeResolutionContext.prototype._pushAnyContextualType = function (type, provisional, isInferentiallyTyping, argContext) { - this.contextStack.push(new PullContextualTypeContext(type, provisional, isInferentiallyTyping, argContext)); - }; - - 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(); - - if (tc.hasProvisionalErrors && this.inProvisionalResolution()) { - this.contextStack[this.contextStack.length - 1].hasProvisionalErrors = true; - } - - return tc; - }; - - PullTypeResolutionContext.prototype.hasProvisionalErrors = function () { - return this.contextStack.length ? this.contextStack[this.contextStack.length - 1].hasProvisionalErrors : false; - }; - - PullTypeResolutionContext.prototype.getContextualType = function () { - var context = !this.contextStack.length ? null : this.contextStack[this.contextStack.length - 1]; - - if (context) { - var type = context.contextualType; - - if (!type) { - return null; - } - - 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); - }; - - PullTypeResolutionContext.prototype.isInBaseTypeResolution = function () { - return this.inBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.startBaseTypeResolution = function () { - var wasInBaseTypeResoltion = this.inBaseTypeResolution; - this.inBaseTypeResolution = true; - return wasInBaseTypeResoltion; - }; - - PullTypeResolutionContext.prototype.doneBaseTypeResolution = function (wasInBaseTypeResolution) { - this.inBaseTypeResolution = wasInBaseTypeResolution; - }; - - PullTypeResolutionContext.prototype.setTypeInContext = function (symbol, 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); - } - }; - - PullTypeResolutionContext.prototype.postDiagnostic = function (diagnostic) { - if (diagnostic) { - if (this.inProvisionalResolution()) { - (this.contextStack[this.contextStack.length - 1]).hasProvisionalErrors = true; - } else if (this.inTypeCheck && this.resolver) { - this.resolver.semanticInfoChain.addDiagnostic(diagnostic); - } - } - }; - - PullTypeResolutionContext.prototype.typeCheck = function () { - return this.inTypeCheck && !this.inProvisionalResolution(); - }; - - PullTypeResolutionContext.prototype.setSymbolForAST = function (ast, symbol) { - this.contextStack[this.contextStack.length - 1].setSymbolForAST(ast, symbol); - }; - - PullTypeResolutionContext.prototype.getSymbolForAST = function (ast) { - for (var i = this.contextStack.length - 1; i >= 0; i--) { - var typeContext = this.contextStack[i]; - if (!typeContext.provisional) { - break; - } - - var symbol = typeContext.getSymbolForAST(ast); - if (symbol) { - return symbol; - } - } - - 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; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var OverloadApplicabilityStatus; - (function (OverloadApplicabilityStatus) { - OverloadApplicabilityStatus[OverloadApplicabilityStatus["NotAssignable"] = 0] = "NotAssignable"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableButWithProvisionalErrors"] = 1] = "AssignableButWithProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["AssignableWithNoProvisionalErrors"] = 2] = "AssignableWithNoProvisionalErrors"; - OverloadApplicabilityStatus[OverloadApplicabilityStatus["Subtype"] = 3] = "Subtype"; - })(OverloadApplicabilityStatus || (OverloadApplicabilityStatus = {})); - - var PullAdditionalCallResolutionData = (function () { - function PullAdditionalCallResolutionData() { - this.targetSymbol = null; - this.resolvedSignatures = null; - this.candidateSignature = null; - this.actualParametersContextTypeSymbols = null; - this.diagnosticsFromOverloadResolution = []; - } - return PullAdditionalCallResolutionData; - })(); - TypeScript.PullAdditionalCallResolutionData = PullAdditionalCallResolutionData; - - var PullAdditionalObjectLiteralResolutionData = (function () { - function PullAdditionalObjectLiteralResolutionData() { - this.membersContextTypeSymbols = null; - } - return PullAdditionalObjectLiteralResolutionData; - })(); - TypeScript.PullAdditionalObjectLiteralResolutionData = PullAdditionalObjectLiteralResolutionData; - - var MemberWithBaseOrigin = (function () { - function MemberWithBaseOrigin(memberSymbol, baseOrigin) { - this.memberSymbol = memberSymbol; - this.baseOrigin = baseOrigin; - } - return MemberWithBaseOrigin; - })(); - - var SignatureWithBaseOrigin = (function () { - function SignatureWithBaseOrigin(signature, baseOrigin) { - this.signature = signature; - this.baseOrigin = baseOrigin; - } - return SignatureWithBaseOrigin; - })(); - - var InheritedIndexSignatureInfo = (function () { - function InheritedIndexSignatureInfo() { - } - return InheritedIndexSignatureInfo; - })(); - - 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(); - return CompilerReservedName[nameText]; - } - - var PullTypeResolver = (function () { - function PullTypeResolver(compilationSettings, semanticInfoChain) { - this.compilationSettings = compilationSettings; - this.semanticInfoChain = semanticInfoChain; - this._cachedArrayInterfaceType = null; - this._cachedNumberInterfaceType = null; - this._cachedStringInterfaceType = null; - this._cachedBooleanInterfaceType = null; - this._cachedObjectInterfaceType = null; - this._cachedFunctionInterfaceType = null; - this._cachedIArgumentsInterfaceType = null; - this._cachedRegExpInterfaceType = null; - this._cachedAnyTypeArgs = null; - this.typeCheckCallBacks = []; - this.postTypeCheckWorkitems = []; - this._cachedFunctionArgumentsSymbol = null; - 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 */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedArrayInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedArrayInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedArrayInterfaceType; - }; - - PullTypeResolver.prototype.getArrayNamedType = function () { - return this.cachedArrayInterfaceType(); - }; - - PullTypeResolver.prototype.cachedNumberInterfaceType = function () { - if (!this._cachedNumberInterfaceType) { - this._cachedNumberInterfaceType = this.getSymbolFromDeclPath("Number", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedNumberInterfaceType && !this._cachedNumberInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedNumberInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedNumberInterfaceType; - }; - - PullTypeResolver.prototype.cachedStringInterfaceType = function () { - if (!this._cachedStringInterfaceType) { - this._cachedStringInterfaceType = this.getSymbolFromDeclPath("String", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedStringInterfaceType && !this._cachedStringInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedStringInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedStringInterfaceType; - }; - - PullTypeResolver.prototype.cachedBooleanInterfaceType = function () { - if (!this._cachedBooleanInterfaceType) { - this._cachedBooleanInterfaceType = this.getSymbolFromDeclPath("Boolean", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedBooleanInterfaceType && !this._cachedBooleanInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedBooleanInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedBooleanInterfaceType; - }; - - PullTypeResolver.prototype.cachedObjectInterfaceType = function () { - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.getSymbolFromDeclPath("Object", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType) { - this._cachedObjectInterfaceType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!this._cachedObjectInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedObjectInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedObjectInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionInterfaceType = function () { - if (!this._cachedFunctionInterfaceType) { - this._cachedFunctionInterfaceType = this.getSymbolFromDeclPath("Function", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedFunctionInterfaceType && !this._cachedFunctionInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedFunctionInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedFunctionInterfaceType; - }; - - PullTypeResolver.prototype.cachedIArgumentsInterfaceType = function () { - if (!this._cachedIArgumentsInterfaceType) { - this._cachedIArgumentsInterfaceType = this.getSymbolFromDeclPath("IArguments", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedIArgumentsInterfaceType && !this._cachedIArgumentsInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedIArgumentsInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedIArgumentsInterfaceType; - }; - - PullTypeResolver.prototype.cachedRegExpInterfaceType = function () { - if (!this._cachedRegExpInterfaceType) { - this._cachedRegExpInterfaceType = this.getSymbolFromDeclPath("RegExp", [], 16 /* Interface */) || this.semanticInfoChain.emptyTypeSymbol; - } - - if (this._cachedRegExpInterfaceType && !this._cachedRegExpInterfaceType.isResolved) { - this.resolveDeclaredSymbol(this._cachedRegExpInterfaceType, new TypeScript.PullTypeResolutionContext(this)); - } - - return this._cachedRegExpInterfaceType; - }; - - PullTypeResolver.prototype.cachedFunctionArgumentsSymbol = function () { - if (!this._cachedFunctionArgumentsSymbol) { - this._cachedFunctionArgumentsSymbol = new TypeScript.PullSymbol("arguments", 512 /* Variable */); - this._cachedFunctionArgumentsSymbol.type = this.cachedIArgumentsInterfaceType() || this.semanticInfoChain.anyTypeSymbol; - this._cachedFunctionArgumentsSymbol.setResolved(); - - var functionArgumentsDecl = new TypeScript.PullSynthesizedDecl("arguments", "arguments", 2048 /* Parameter */, 0 /* None */, null, this.semanticInfoChain); - functionArgumentsDecl.setSymbol(this._cachedFunctionArgumentsSymbol); - this._cachedFunctionArgumentsSymbol.addDeclaration(functionArgumentsDecl); - } - - 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); - }; - - PullTypeResolver.prototype.canTypeCheckAST = function (ast, context) { - return context.canTypeCheckAST(ast); - }; - - PullTypeResolver.prototype.setSymbolForAST = function (ast, symbol, context) { - if (context && context.inProvisionalResolution()) { - context.setSymbolForAST(ast, symbol); - } else { - this.semanticInfoChain.setSymbolForAST(ast, symbol); - } - }; - - PullTypeResolver.prototype.getSymbolForAST = function (ast, context) { - var symbol = this.semanticInfoChain.getSymbolForAST(ast); - - if (!symbol) { - if (context && context.inProvisionalResolution()) { - symbol = context.getSymbolForAST(ast); - } - } - - return symbol; - }; - - PullTypeResolver.prototype.getASTForDecl = function (decl) { - return this.semanticInfoChain.getASTForDecl(decl); - }; - - PullTypeResolver.prototype.getNewErrorTypeSymbol = function (name) { - if (typeof name === "undefined") { name = null; } - return new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, name); - }; - - PullTypeResolver.prototype.getEnclosingDecl = function (decl) { - var declPath = decl.getParentPath(); - - if (declPath.length > 1 && declPath[declPath.length - 1] === decl) { - return declPath[declPath.length - 2]; - } else { - return declPath[declPath.length - 1]; - } - }; - - PullTypeResolver.prototype.getExportedMemberSymbol = function (symbol, parent) { - if (!(symbol.kind & (65536 /* Method */ | 4096 /* Property */))) { - var isContainer = (parent.kind & (4 /* Container */ | 32 /* DynamicModule */)) !== 0; - var containerType = !isContainer ? parent.getAssociatedContainerType() : parent; - - if (isContainer && containerType) { - if (symbol.anyDeclHasFlag(1 /* Exported */)) { - return symbol; - } - - return null; - } - } - - return symbol; - }; - - 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 & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - - var containerType = parent.getAssociatedContainerType(); - - if (containerType) { - if (containerType.isClass()) { - return null; - } - - parent = containerType; - - if (declSearchKind & 68147712 /* SomeValue */) { - member = parent.findMember(symbolName, true); - } else if (declSearchKind & 58728795 /* SomeType */) { - member = parent.findNestedType(symbolName); - } else if (declSearchKind & 164 /* SomeContainer */) { - member = parent.findNestedContainer(symbolName); - } - - if (member) { - return this.getExportedMemberSymbol(member, parent); - } - } - - if (parent.kind & 164 /* SomeContainer */) { - var typeDeclarations = parent.getDeclarations(); - var childDecls = null; - - for (var j = 0; j < typeDeclarations.length; j++) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - member = childDecls[0].getSymbol(); - - if (!member) { - member = childDecls[0].getSignatureSymbol(); - } - return this.getExportedMemberSymbol(member, parent); - } - - if ((declSearchKind & 58728795 /* SomeType */) !== 0 || (declSearchKind & 68147712 /* SomeValue */) !== 0) { - childDecls = typeDeclarations[j].searchChildDecls(symbolName, 128 /* TypeAlias */); - if (childDecls.length && childDecls[0].kind === 128 /* TypeAlias */) { - var aliasSymbol = this.getExportedMemberSymbol(childDecls[0].getSymbol(), parent); - if (aliasSymbol) { - if ((declSearchKind & 58728795 /* SomeType */) !== 0) { - var typeSymbol = aliasSymbol.getExportAssignedTypeSymbol(); - if (typeSymbol) { - return typeSymbol; - } - } else { - var valueSymbol = aliasSymbol.getExportAssignedValueSymbol(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - return valueSymbol; - } - } - - return aliasSymbol; - } - } - } - } - } - }; - - PullTypeResolver.prototype.getSymbolFromDeclPath = function (symbolName, declPath, declSearchKind) { - var _this = this; - var symbol = null; - - var decl = null; - var childDecls; - var declSymbol = null; - var declMembers; - var pathDeclKind; - var valDecl = null; - var kind; - var instanceSymbol = null; - 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; - - if (decl.flags & 2097152 /* DeclaredInAWithBlock */) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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(); - - if (instanceSymbol) { - instanceType = instanceSymbol.type; - - childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, instanceType); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } - - valDecl = decl.getValueDecl(); - - if (valDecl) { - decl = valDecl; - } - } - - declSymbol = decl.getSymbol().type; - - var childSymbol = this.getNamedPropertySymbol(symbolName, declSearchKind, declSymbol); - - if (childSymbol && (childSymbol.kind & declSearchKind) && !childSymbol.anyDeclHasFlag(16 /* Static */)) { - return childSymbol; - } - } else if ((declSearchKind & (58728795 /* SomeType */ | 164 /* SomeContainer */)) || !(pathDeclKind & 8 /* Class */)) { - var candidateSymbol = null; - - if (pathDeclKind === 131072 /* FunctionExpression */ && symbolName === decl.getFunctionExpressionName()) { - candidateSymbol = decl.getSymbol(); - } - - childDecls = decl.searchChildDecls(symbolName, declSearchKind); - - if (childDecls.length) { - if (decl.kind & 1032192 /* SomeFunction */) { - decl.ensureSymbolIsBound(); - } - return childDecls[0].getSymbol(); - } - - if (candidateSymbol) { - return candidateSymbol; - } - - var alias = tryFindAlias(decl); - if (alias) { - return alias; - } - } - } - - symbol = this.semanticInfoChain.findSymbol([symbolName], declSearchKind); - if (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) { - var result = []; - var decl = null; - var childDecls; - var pathDeclKind; - - for (var i = declPath.length - 1; i >= 0; i--) { - decl = declPath[i]; - pathDeclKind = decl.kind; - - var declKind = decl.kind; - - if (declKind !== 8 /* Class */ && declKind !== 16 /* Interface */) { - this.addFilteredDecls(decl.getChildDecls(), declSearchKind, result); - } - - switch (declKind) { - case 4 /* Container */: - case 32 /* DynamicModule */: - var otherDecls = this.semanticInfoChain.findDeclsFromPath(declPath.slice(0, i + 1), 164 /* SomeContainer */); - for (var j = 0, m = otherDecls.length; j < m; j++) { - var otherDecl = otherDecls[j]; - if (otherDecl === decl) { - continue; - } - - var otherDeclChildren = otherDecl.getChildDecls(); - for (var k = 0, s = otherDeclChildren.length; k < s; k++) { - var otherDeclChild = otherDeclChildren[k]; - if ((otherDeclChild.flags & 1 /* Exported */) && (otherDeclChild.kind & declSearchKind)) { - result.push(otherDeclChild); - } - } - } - - break; - - case 8 /* Class */: - case 16 /* Interface */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - - case 131072 /* FunctionExpression */: - var functionExpressionName = decl.getFunctionExpressionName(); - if (functionExpressionName) { - result.push(decl); - } - - case 16384 /* Function */: - case 32768 /* ConstructorMethod */: - case 65536 /* Method */: - var parameters = decl.getTypeParameters(); - if (parameters && parameters.length) { - this.addFilteredDecls(parameters, declSearchKind, result); - } - - break; - } - } - - var topLevelDecls = this.semanticInfoChain.topLevelDecls(); - for (var i = 0, n = topLevelDecls.length; i < n; i++) { - var topLevelDecl = topLevelDecls[i]; - if (declPath.length > 0 && topLevelDecl.fileName() === declPath[0].fileName()) { - continue; - } - - if (!topLevelDecl.isExternalModule()) { - this.addFilteredDecls(topLevelDecl.getChildDecls(), declSearchKind, result); - } - } - - return result; - }; - - PullTypeResolver.prototype.addFilteredDecls = function (decls, declSearchKind, result) { - if (decls.length) { - for (var i = 0, n = decls.length; i < n; i++) { - var decl = decls[i]; - if (decl.kind & declSearchKind) { - result.push(decl); - } - } - } - }; - - PullTypeResolver.prototype.getVisibleDecls = function (enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - return this.getVisibleDeclsFromDeclPath(declPath, declSearchKind); - }; - - PullTypeResolver.prototype.getVisibleContextSymbols = function (enclosingDecl, context) { - var contextualTypeSymbol = context.getContextualType(); - if (!contextualTypeSymbol || this.isAnyOrEquivalent(contextualTypeSymbol)) { - return null; - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - var members = contextualTypeSymbol.getAllMembers(declSearchKind, 2 /* externallyVisible */); - - for (var i = 0; i < members.length; i++) { - members[i].setUnresolved(); - } - - return members; - }; - - 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 */ || lhs.kind === 64 /* Enum */)) { - return null; - } - - var lhsType = lhs.type; - if (!lhsType) { - return null; - } - - this.resolveDeclaredSymbol(lhsType, context); - - if (lhsType.isContainer() && lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return null; - } - - var memberVisibilty = 2 /* externallyVisible */; - var containerSymbol = lhsType; - if (containerSymbol.kind === 33554432 /* ConstructorType */) { - containerSymbol = containerSymbol.getConstructSignatures()[0].returnType; - } - - if (containerSymbol && containerSymbol.isClass()) { - var declPath = enclosingDecl.getParentPath(); - if (declPath && declPath.length) { - var declarations = containerSymbol.getDeclarations(); - for (var i = 0, n = declarations.length; i < n; i++) { - var declaration = declarations[i]; - if (TypeScript.ArrayUtilities.contains(declPath, declaration)) { - memberVisibilty = 1 /* internallyVisible */; - break; - } - } - } - } - - var declSearchKind = 58728795 /* SomeType */ | 164 /* SomeContainer */ | 68147712 /* SomeValue */; - - var members = []; - - if (lhsType.isContainer()) { - var exportedAssignedContainerSymbol = lhsType.getExportAssignedContainerSymbol(); - if (exportedAssignedContainerSymbol) { - lhsType = exportedAssignedContainerSymbol; - } - } - - lhsType = this.getApparentType(lhsType); - - 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); - } - - 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 */)); - } - - return members; - }; - - PullTypeResolver.prototype.isAnyOrEquivalent = function (type) { - return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); - }; - - PullTypeResolver.prototype.resolveExternalModuleReference = function (idText, currentFileName) { - var originalIdText = idText; - var symbol = null; - - if (TypeScript.isRelative(originalIdText)) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - symbol = this.semanticInfoChain.findExternalModule(path + idText); - } else { - idText = originalIdText; - - symbol = this.semanticInfoChain.findAmbientExternalModuleInGlobalContext(TypeScript.quoteStr(originalIdText)); - - if (!symbol) { - var path = TypeScript.getRootFilePath(TypeScript.switchToForwardSlashes(currentFileName)); - - while (symbol === null && path != "") { - symbol = this.semanticInfoChain.findExternalModule(path + idText); - if (symbol === null) { - if (path === '/') { - path = ''; - } else { - path = TypeScript.normalizePath(path + ".."); - path = path && path != '/' ? path + '/' : path; - } - } - } - } - } - - return symbol; - }; - - PullTypeResolver.prototype.resolveDeclaredSymbol = function (symbol, context) { - if (!symbol || symbol.isResolved || symbol.isTypeReference()) { - return symbol; - } - - if (!context) { - context = new TypeScript.PullTypeResolutionContext(this); - } - - return this.resolveDeclaredSymbolWorker(symbol, context); - }; - - PullTypeResolver.prototype.resolveDeclaredSymbolWorker = function (symbol, context) { - if (!symbol || symbol.isResolved) { - return symbol; - } - - if (symbol.inResolution) { - if (!symbol.type && !symbol.isType()) { - symbol.type = this.semanticInfoChain.anyTypeSymbol; - } - - return symbol; - } - - var decls = symbol.getDeclarations(); - - for (var i = 0; i < decls.length; i++) { - var decl = decls[i]; - - var ast = this.semanticInfoChain.getASTForDecl(decl); - - if (!ast || (ast.kind() === 139 /* GetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (ast.kind() === 140 /* SetAccessor */ && ast.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 236 /* CatchClause */ && ast.parent.identifier === ast) { - return symbol; - } - - if (ast.parent && ast.parent.kind() === 219 /* SimpleArrowFunctionExpression */ && ast.parent.identifier === ast) { - return symbol; - } - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(ast); - var resolvedSymbol; - 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 */); - resolvedSymbol = this.resolveAST(ast, false, context); - } - - if (decl.kind === 2048 /* Parameter */ && !symbol.isResolved && !symbol.type && resolvedSymbol && symbol.anyDeclHasFlag(8388608 /* PropertyParameter */ | 67108864 /* ConstructorParameter */)) { - symbol.type = resolvedSymbol.type; - symbol.setResolved(); - } - } - - 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(); - this.inResolvingOtherDeclsWalker.walkOtherPullDecls(resolvedDecl, symbol.getDeclarations(), function (otherDecl) { - return _this.resolveOtherDecl(otherDecl, context); - }); - }; - - PullTypeResolver.prototype.resolveSourceUnit = function (sourceUnit, context) { - var enclosingDecl = this.getEnclosingDeclForAST(sourceUnit); - var moduleSymbol = enclosingDecl.getSymbol(); - this.ensureAllSymbolsAreBound(moduleSymbol); - - this.resolveFirstExportAssignmentStatement(sourceUnit.moduleElements, context); - this.resolveAST(sourceUnit.moduleElements, false, context); - - if (this.canTypeCheckAST(sourceUnit, context)) { - this.typeCheckSourceUnit(sourceUnit, context); - } - - return moduleSymbol; - }; - - 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) { - var containerDecl = this.semanticInfoChain.getDeclForAST(ast); - var containerSymbol = containerDecl.getSymbol(); - - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - containerSymbol.setResolved(); - - this.resolveOtherDeclarations(ast, context); - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckEnumDeclaration(ast, context); - } - - return containerSymbol; - }; - - 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); - - this.typeCheckCallBacks.push(function (context) { - return _this.checkInitializersInEnumDeclarations(containerDecl, context); - }); - - if (!TypeScript.ASTHelpers.enumIsElided(ast)) { - this.checkNameForCompilerGeneratedDeclarationCollision(ast, true, ast.identifier, context); - } - }; - - PullTypeResolver.prototype.postTypeCheckEnumDeclaration = function (ast, context) { - 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; - - if (ast.stringLiteral) { - result = this.resolveSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - result = this.resolveSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckModuleDeclaration(ast, context); - } - - return result; - }; - - PullTypeResolver.prototype.ensureAllSymbolsAreBound = function (containerSymbol) { - if (containerSymbol) { - var containerDecls = containerSymbol.getDeclarations(); - - for (var i = 0; i < containerDecls.length; i++) { - var childDecls = containerDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - }; - - PullTypeResolver.prototype.resolveModuleSymbol = function (containerSymbol, context, moduleDeclAST, moduleDeclNameAST, sourceUnitAST) { - if (containerSymbol.isResolved || containerSymbol.inResolution) { - return containerSymbol; - } - - containerSymbol.inResolution = true; - this.ensureAllSymbolsAreBound(containerSymbol); - - var instanceSymbol = containerSymbol.getInstanceSymbol(); - - if (instanceSymbol) { - this.resolveDeclaredSymbol(instanceSymbol, context); - } - - var isLastName = TypeScript.ASTHelpers.isLastNameOfModule(moduleDeclAST, moduleDeclNameAST); - if (isLastName) { - this.resolveFirstExportAssignmentStatement(moduleDeclAST.moduleElements, context); - } else if (sourceUnitAST) { - this.resolveFirstExportAssignmentStatement(sourceUnitAST.moduleElements, context); - } - - containerSymbol.setResolved(); - - if (moduleDeclNameAST) { - this.resolveOtherDeclarations(moduleDeclNameAST, context); - } - - return containerSymbol; - }; - - 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 */) { - this.resolveExportAssignmentStatement(moduleElement, context); - return; - } - } - }; - - PullTypeResolver.prototype.resolveSingleModuleDeclaration = function (ast, astName, context) { - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - var containerSymbol = containerDecl.getSymbol(); - - return this.resolveModuleSymbol(containerSymbol, context, ast, astName, null); - }; - - PullTypeResolver.prototype.typeCheckModuleDeclaration = function (ast, context) { - if (ast.stringLiteral) { - this.typeCheckSingleModuleDeclaration(ast, ast.stringLiteral, context); - } else { - var moduleNames = TypeScript.getModuleNames(ast.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - this.typeCheckSingleModuleDeclaration(ast, moduleNames[i], context); - } - } - }; - - PullTypeResolver.prototype.typeCheckSingleModuleDeclaration = function (ast, astName, context) { - var _this = this; - this.setTypeChecked(ast, context); - - if (TypeScript.ASTHelpers.isLastNameOfModule(ast, astName)) { - this.resolveAST(ast.moduleElements, false, context); - } - - var containerDecl = this.semanticInfoChain.getDeclForAST(astName); - this.validateVariableDeclarationGroups(containerDecl, context); - - if (ast.stringLiteral) { - if (TypeScript.isRelative(ast.stringLiteral.valueText())) { - this.semanticInfoChain.addDiagnosticFromAST(ast.stringLiteral, TypeScript.DiagnosticCode.Ambient_external_module_declaration_cannot_specify_relative_module_name); - } - } - - 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) { - this.checkThisCaptureVariableCollides(ast, true, context); - }; - - PullTypeResolver.prototype.isTypeRefWithoutTypeArgs = function (term) { - if (term.kind() === 11 /* IdentifierName */) { - return true; - } else if (term.kind() === 121 /* QualifiedName */) { - var binex = term; - - if (binex.right.kind() === 11 /* IdentifierName */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.createInstantiatedType = function (type, typeArguments) { - if (!type.isGeneric()) { - return type; - } - - var typeParameters = type.getTypeArgumentsOrTypeParameters(); - - var typeParameterArgumentMap = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterArgumentMap[typeParameters[i].pullSymbolID] = typeArguments[i] || new TypeScript.PullErrorTypeSymbol(this.semanticInfoChain.anyTypeSymbol, typeParameters[i].name); - } - - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - }; - - PullTypeResolver.prototype.resolveReferenceTypeDeclaration = function (classOrInterface, name, heritageClauses, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(typeDecl); - var typeDeclSymbol = typeDecl.getSymbol(); - var typeDeclIsClass = classOrInterface.kind() === 131 /* ClassDeclaration */; - var hasVisited = this.getSymbolForAST(classOrInterface, context) !== null; - - if ((typeDeclSymbol.isResolved && hasVisited) || (typeDeclSymbol.inResolution && !context.isInBaseTypeResolution())) { - return typeDeclSymbol; - } - - var wasResolving = typeDeclSymbol.inResolution; - typeDeclSymbol.startResolving(); - - var typeRefDecls = typeDeclSymbol.getDeclarations(); - - for (var i = 0; i < typeRefDecls.length; i++) { - var childDecls = typeRefDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - - 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.ASTHelpers.getExtendsHeritageClause(heritageClauses); - if (extendsClause) { - for (var i = typeDeclSymbol.getKnownBaseTypeCount(); i < extendsClause.typeNames.nonSeparatorCount(); i = typeDeclSymbol.getKnownBaseTypeCount()) { - typeDeclSymbol.incrementKnownBaseCount(); - var parentType = this.resolveTypeReference(extendsClause.typeNames.nonSeparatorAt(i), context); - - if (typeDeclSymbol.isValidBaseKind(parentType, true)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - - if (!typeDeclSymbol.hasBase(parentType) && !parentType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addExtendedType(parentType); - - var specializations = typeDeclSymbol.getKnownSpecializations(); - - for (var j = 0; j < specializations.length; j++) { - specializations[j].addExtendedType(parentType); - } - } - } else if (parentType && !this.getSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), context)) { - this.setSymbolForAST(extendsClause.typeNames.nonSeparatorAt(i), parentType, null); - } - } - } - - 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()) { - typeDeclSymbol.incrementKnownBaseCount(); - var implementedTypeAST = implementsClause.typeNames.nonSeparatorAt(i - extendsCount); - var implementedType = this.resolveTypeReference(implementedTypeAST, context); - - if (typeDeclSymbol.isValidBaseKind(implementedType, false)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - - if (!typeDeclSymbol.hasBase(implementedType) && !implementedType.hasBase(typeDeclSymbol)) { - typeDeclSymbol.addImplementedType(implementedType); - } - } else if (implementedType && !this.getSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), context)) { - this.setSymbolForAST(implementsClause.typeNames.nonSeparatorAt(i - extendsCount), implementedType, null); - } - } - } - - context.doneBaseTypeResolution(wasInBaseTypeResolution); - - if (wasInBaseTypeResolution) { - typeDeclSymbol.inResolution = false; - - this.typeCheckCallBacks.push(function (context) { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - _this.resolveClassDeclaration(classOrInterface, context); - } else { - _this.resolveInterfaceDeclaration(classOrInterface, context); - } - }); - - return typeDeclSymbol; - } - - this.setSymbolForAST(name, typeDeclSymbol, context); - this.setSymbolForAST(classOrInterface, typeDeclSymbol, context); - - typeDeclSymbol.setResolved(); - - return typeDeclSymbol; - }; - - 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); - - var constructorMethod = classDeclSymbol.getConstructorMethod(); - var extendedTypes = classDeclSymbol.getExtendedTypes(); - var parentType = extendedTypes.length ? extendedTypes[0] : null; - - if (constructorMethod) { - var constructorTypeSymbol = constructorMethod.type; - - var constructSignatures = constructorTypeSymbol.getConstructSignatures(); - - if (!constructSignatures.length) { - var constructorSignature; - - var parentConstructor = parentType ? parentType.getConstructorMethod() : null; - - if (parentConstructor) { - this.resolveDeclaredSymbol(parentConstructor, context); - var parentConstructorType = parentConstructor.type; - var parentConstructSignatures = parentConstructorType.getConstructSignatures(); - - var parentConstructSignature; - var parentParameters; - - if (!parentConstructSignatures.length) { - parentConstructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - parentConstructSignature.returnType = parentType; - parentConstructSignature.addTypeParametersFromReturnType(); - parentConstructorType.appendConstructSignature(parentConstructSignature); - parentConstructSignature.addDeclaration(parentType.getDeclarations()[0]); - parentConstructSignatures = [parentConstructSignature]; - } - - for (var i = 0; i < parentConstructSignatures.length; i++) { - parentConstructSignature = parentConstructSignatures[i]; - parentParameters = parentConstructSignature.parameters; - - 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); - } - - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } else { - constructorSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - constructorSignature.returnType = classDeclSymbol; - constructorSignature.addTypeParametersFromReturnType(); - constructorTypeSymbol.appendConstructSignature(constructorSignature); - constructorSignature.addDeclaration(classDecl); - } - } - - if (!classDeclSymbol.isResolved) { - return classDeclSymbol; - } - - if (parentType) { - var parentConstructorSymbol = parentType.getConstructorMethod(); - - if (parentConstructorSymbol) { - var parentConstructorTypeSymbol = parentConstructorSymbol.type; - - if (!constructorTypeSymbol.hasBase(parentConstructorTypeSymbol)) { - constructorTypeSymbol.addExtendedType(parentConstructorTypeSymbol); - } - } - } - } - - this.resolveOtherDeclarations(classDeclAST, context); - } - - if (this.canTypeCheckAST(classDeclAST, context)) { - this.typeCheckClassDeclaration(classDeclAST, context); - } - - return classDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckTypeParametersOfTypeDeclaration = function (classOrInterface, context) { - var _this = this; - 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); - }); - } - } - }; - - PullTypeResolver.prototype.typeCheckClassDeclaration = function (classDeclAST, context) { - this.setTypeChecked(classDeclAST, context); - - var classDecl = this.semanticInfoChain.getDeclForAST(classDeclAST); - var classDeclSymbol = classDecl.getSymbol(); - - this.checkNameForCompilerGeneratedDeclarationCollision(classDeclAST, true, classDeclAST.identifier, context); - this.resolveAST(classDeclAST.classElements, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(classDeclAST, context); - this.typeCheckBases(classDeclAST, classDeclAST.identifier, classDeclAST.heritageClauses, classDeclSymbol, this.getEnclosingDecl(classDecl), context); - - if (!classDeclSymbol.hasBaseTypeConflict()) { - this.typeCheckMembersAgainstIndexer(classDeclSymbol, classDecl, context); - } - - this.checkTypeForDuplicateIndexSignatures(classDeclSymbol); - }; - - PullTypeResolver.prototype.postTypeCheckClassDeclaration = function (classDeclAST, context) { - this.checkThisCaptureVariableCollides(classDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveTypeSymbolSignatures = function (typeSymbol, context) { - var callSignatures = typeSymbol.getCallSignatures(); - for (var i = 0; i < callSignatures.length; i++) { - this.resolveDeclaredSymbol(callSignatures[i], context); - } - - var constructSignatures = typeSymbol.getConstructSignatures(); - for (var i = 0; i < constructSignatures.length; i++) { - this.resolveDeclaredSymbol(constructSignatures[i], context); - } - - var indexSignatures = typeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignatures.length; i++) { - this.resolveDeclaredSymbol(indexSignatures[i], context); - } - }; - - PullTypeResolver.prototype.resolveInterfaceDeclaration = function (interfaceDeclAST, context) { - this.resolveReferenceTypeDeclaration(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveTypeSymbolSignatures(interfaceDeclSymbol, context); - - if (interfaceDeclSymbol.isResolved) { - this.resolveOtherDeclarations(interfaceDeclAST, context); - - if (this.canTypeCheckAST(interfaceDeclAST, context)) { - this.typeCheckInterfaceDeclaration(interfaceDeclAST, context); - } - } - - return interfaceDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckInterfaceDeclaration = function (interfaceDeclAST, context) { - this.setTypeChecked(interfaceDeclAST, context); - - var interfaceDecl = this.semanticInfoChain.getDeclForAST(interfaceDeclAST); - var interfaceDeclSymbol = interfaceDecl.getSymbol(); - - this.resolveAST(interfaceDeclAST.body.typeMembers, false, context); - - this.typeCheckTypeParametersOfTypeDeclaration(interfaceDeclAST, context); - this.typeCheckBases(interfaceDeclAST, interfaceDeclAST.identifier, interfaceDeclAST.heritageClauses, interfaceDeclSymbol, this.getEnclosingDecl(interfaceDecl), context); - - 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) { - if (symbol) { - if (symbol.kind & kind) { - return symbol; - } - - if (symbol.isAlias()) { - this.resolveDeclaredSymbol(symbol, context); - - var alias = symbol; - if (kind & 164 /* SomeContainer */) { - return alias.getExportAssignedContainerSymbol(); - } else if (kind & 58728795 /* SomeType */) { - return alias.getExportAssignedTypeSymbol(); - } else if (kind & 68147712 /* SomeValue */) { - return alias.getExportAssignedValueSymbol(); - } - } - } - return null; - }; - - PullTypeResolver.prototype.getMemberSymbolOfKind = function (symbolName, kind, pullTypeSymbol, enclosingDecl, context) { - var memberSymbol = this.getNamedPropertySymbol(symbolName, kind, pullTypeSymbol); - - return { - symbol: this.filterSymbol(memberSymbol, kind, enclosingDecl, context), - aliasSymbol: memberSymbol && memberSymbol.isAlias() ? memberSymbol : null - }; - }; - - PullTypeResolver.prototype.resolveIdentifierOfInternalModuleReference = function (importDecl, identifier, moduleSymbol, enclosingDecl, context) { - var rhsName = identifier.valueText(); - if (rhsName.length === 0) { - return null; - } - - var moduleTypeSymbol = moduleSymbol.type; - var memberSymbol = this.getMemberSymbolOfKind(rhsName, 164 /* SomeContainer */, moduleTypeSymbol, enclosingDecl, context); - var containerSymbol = memberSymbol.symbol; - var valueSymbol = null; - var typeSymbol = null; - var aliasSymbol = null; - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - aliasSymbol = memberSymbol.aliasSymbol; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - var aliasedAssignedValue = containerSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = containerSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = containerSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - aliasSymbol = containerSymbol; - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Import_declaration_referencing_identifier_from_internal_module_can_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return null; - } - - if (!valueSymbol) { - if (moduleTypeSymbol.getInstanceSymbol()) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 68147712 /* SomeValue */, moduleTypeSymbol.getInstanceSymbol().type, enclosingDecl, context); - valueSymbol = memberSymbol.symbol; - if (valueSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - } - - if (!typeSymbol) { - memberSymbol = this.getMemberSymbolOfKind(rhsName, 58728795 /* SomeType */, moduleTypeSymbol, enclosingDecl, context); - typeSymbol = memberSymbol.symbol; - if (typeSymbol && memberSymbol.aliasSymbol) { - aliasSymbol = memberSymbol.aliasSymbol; - } - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(identifier, TypeScript.DiagnosticCode.Could_not_find_symbol_0_in_module_1, [rhsName, moduleSymbol.toString()]); - return null; - } - - if (!typeSymbol && containerSymbol) { - typeSymbol = containerSymbol; - } - - return { - valueSymbol: valueSymbol, - typeSymbol: typeSymbol, - containerSymbol: containerSymbol, - aliasSymbol: aliasSymbol - }; - }; - - 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"); - - var moduleSymbol = null; - var moduleName; - - if (moduleNameExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = moduleNameExpr; - var moduleContainer = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleContainer) { - moduleName = dottedNameAST.right.valueText(); - - moduleSymbol = this.getMemberSymbolOfKind(moduleName, 4 /* Container */, moduleContainer.type, enclosingDecl, context).symbol; - if (!moduleSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.Could_not_find_module_0_in_module_1, [moduleName, moduleContainer.toString()]); - } - } - } else { - var valueText = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.valueText() : moduleNameExpr.valueText(); - var text = moduleNameExpr.kind() === 11 /* IdentifierName */ ? moduleNameExpr.text() : moduleNameExpr.text(); - - if (text.length > 0) { - var resolvedModuleNameSymbol = this.getSymbolFromDeclPath(valueText, declPath, 4 /* Container */); - moduleSymbol = this.filterSymbol(resolvedModuleNameSymbol, 4 /* Container */, enclosingDecl, context); - if (moduleSymbol) { - 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]); - } - } - } - - return moduleSymbol; - }; - - PullTypeResolver.prototype.resolveInternalModuleReference = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - - var moduleReference = importStatementAST.moduleReference; - - var aliasExpr = moduleReference.kind() === 245 /* ExternalModuleReference */ ? moduleReference.stringLiteral : moduleReference.moduleName; - - 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); - if (moduleSymbol) { - aliasedType = moduleSymbol.type; - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, this.semanticInfoChain.getAliasSymbolForAST(aliasExpr)); - if (aliasedType.anyDeclHasFlag(32768 /* InitializedModule */)) { - var moduleName = aliasExpr.kind() === 11 /* IdentifierName */ ? aliasExpr.valueText() : aliasExpr.valueText(); - var valueSymbol = this.getSymbolFromDeclPath(moduleName, declPath, 68147712 /* SomeValue */); - var instanceSymbol = aliasedType.getInstanceSymbol(); - - 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 { - importDeclSymbol.setAssignedValueSymbol(valueSymbol); - } - } - } else { - aliasedType = this.getNewErrorTypeSymbol(); - } - } else if (aliasExpr.kind() === 121 /* QualifiedName */) { - var dottedNameAST = aliasExpr; - var moduleSymbol = this.resolveModuleReference(importDecl, dottedNameAST.left, enclosingDecl, context, declPath); - if (moduleSymbol) { - var identifierResolution = this.resolveIdentifierOfInternalModuleReference(importDecl, dottedNameAST.right, moduleSymbol, enclosingDecl, context); - if (identifierResolution) { - importDeclSymbol.setAssignedValueSymbol(identifierResolution.valueSymbol); - importDeclSymbol.setAssignedTypeSymbol(identifierResolution.typeSymbol); - importDeclSymbol.setAssignedContainerSymbol(identifierResolution.containerSymbol); - this.semanticInfoChain.setAliasSymbolForAST(moduleReference, identifierResolution.aliasSymbol); - return null; - } - } - } - - if (!aliasedType) { - importDeclSymbol.setAssignedTypeSymbol(this.getNewErrorTypeSymbol()); - } - - return aliasedType; - }; - - PullTypeResolver.prototype.resolveImportDeclaration = function (importStatementAST, context) { - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - var aliasedType = null; - - if (importDeclSymbol.isResolved) { - return importDeclSymbol; - } - - importDeclSymbol.startResolving(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - var declPath = enclosingDecl.getParentPath(); - - aliasedType = this.resolveExternalModuleReference(modPath, importDecl.fileName()); - - if (!aliasedType) { - var path = importStatementAST.moduleReference.stringLiteral.text(); - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Unable_to_resolve_external_module_0, [path]); - aliasedType = this.getNewErrorTypeSymbol(); - } - } else { - aliasedType = this.resolveInternalModuleReference(importStatementAST, context); - } - - if (aliasedType) { - if (!aliasedType.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Module_cannot_be_aliased_to_a_non_module_type); - if (!aliasedType.isError()) { - aliasedType = this.getNewErrorTypeSymbol(); - } - } - - if (aliasedType.isContainer()) { - importDeclSymbol.setAssignedContainerSymbol(aliasedType); - } - importDeclSymbol.setAssignedTypeSymbol(aliasedType); - - this.setSymbolForAST(importStatementAST.moduleReference, aliasedType, null); - } - - importDeclSymbol.setResolved(); - - this.resolveDeclaredSymbol(importDeclSymbol.assignedValue(), context); - 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); - } - - return importDeclSymbol; - }; - - PullTypeResolver.prototype.typeCheckImportDeclaration = function (importStatementAST, context) { - var _this = this; - this.setTypeChecked(importStatementAST, context); - - var importDecl = this.semanticInfoChain.getDeclForAST(importStatementAST); - var enclosingDecl = this.getEnclosingDecl(importDecl); - var importDeclSymbol = importDecl.getSymbol(); - - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - if (this.compilationSettings.noResolve()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(importStatementAST, TypeScript.DiagnosticCode.Import_declaration_cannot_refer_to_external_module_reference_when_noResolve_option_is_set, null)); - } - - var modPath = importStatementAST.moduleReference.stringLiteral.valueText(); - if (enclosingDecl.kind === 32 /* DynamicModule */) { - 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)); - } - } - } - } - - var checkPrivacy; - if (importStatementAST.moduleReference.kind() === 245 /* ExternalModuleReference */) { - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var container = containerSymbol ? containerSymbol.getContainer() : null; - if (container && container.kind === 32 /* DynamicModule */) { - checkPrivacy = true; - } - } else { - checkPrivacy = true; - } - - if (checkPrivacy) { - var typeSymbol = importDeclSymbol.getExportAssignedTypeSymbol(); - var containerSymbol = importDeclSymbol.getExportAssignedContainerSymbol(); - var valueSymbol = importDeclSymbol.getExportAssignedValueSymbol(); - - this.checkSymbolPrivacy(importDeclSymbol, containerSymbol, function (symbol) { - var messageCode = TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_container_that_is_or_is_using_inaccessible_module_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - - 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; - - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - - if (valueSymbol) { - this.checkSymbolPrivacy(importDeclSymbol, valueSymbol.type, function (symbol) { - var messageCode = symbol.isContainer() && !symbol.isEnum() ? TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_is_using_inaccessible_module_1 : TypeScript.DiagnosticCode.Exported_import_declaration_0_is_assigned_value_with_type_that_has_or_is_using_private_type_1; - var messageArguments = [importDeclSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null), symbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null, false, false, true)]; - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(importStatementAST, messageCode, messageArguments)); - }); - } - } - - this.checkNameForCompilerGeneratedDeclarationCollision(importStatementAST, true, importStatementAST.identifier, context); - }; - - PullTypeResolver.prototype.postTypeCheckImportDeclaration = function (importStatementAST, context) { - 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); - } - }; - - PullTypeResolver.prototype.resolveExportAssignmentStatement = function (exportAssignmentAST, context) { - var id = exportAssignmentAST.identifier.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var valueSymbol = null; - var typeSymbol = null; - var containerSymbol = null; - - var enclosingDecl = this.getEnclosingDeclForAST(exportAssignmentAST); - var parentSymbol = enclosingDecl.getSymbol(); - - if (!parentSymbol.isType() && parentSymbol.isContainer()) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_used_at_the_top_level_of_external_modules); - return this.semanticInfoChain.anyTypeSymbol; - } - - var declPath = enclosingDecl !== null ? [enclosingDecl] : []; - - containerSymbol = this.getSymbolFromDeclPath(id, declPath, 164 /* SomeContainer */); - - var acceptableAlias = true; - - if (containerSymbol) { - acceptableAlias = (containerSymbol.kind & 59753052 /* AcceptableAlias */) !== 0; - } - - if (!acceptableAlias && containerSymbol && containerSymbol.kind === 128 /* TypeAlias */) { - this.resolveDeclaredSymbol(containerSymbol, context); - - var aliasSymbol = containerSymbol; - var aliasedAssignedValue = aliasSymbol.getExportAssignedValueSymbol(); - var aliasedAssignedType = aliasSymbol.getExportAssignedTypeSymbol(); - var aliasedAssignedContainer = aliasSymbol.getExportAssignedContainerSymbol(); - - if (aliasedAssignedValue || aliasedAssignedType || aliasedAssignedContainer) { - valueSymbol = aliasedAssignedValue; - typeSymbol = aliasedAssignedType; - containerSymbol = aliasedAssignedContainer; - aliasSymbol.setTypeUsedExternally(); - if (valueSymbol) { - aliasSymbol.setIsUsedAsValue(); - } - acceptableAlias = true; - } - } - - if (!acceptableAlias) { - this.semanticInfoChain.addDiagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Export_assignments_may_only_be_made_with_variables_functions_classes_interfaces_enums_and_internal_modules); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (!valueSymbol) { - valueSymbol = this.getSymbolFromDeclPath(id, declPath, 68147712 /* SomeValue */); - } - if (!typeSymbol) { - typeSymbol = this.getSymbolFromDeclPath(id, declPath, 58728795 /* SomeType */); - } - - if (!valueSymbol && !typeSymbol && !containerSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(exportAssignmentAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [id])); - return this.semanticInfoChain.voidTypeSymbol; - } - - if (valueSymbol) { - parentSymbol.setExportAssignedValueSymbol(valueSymbol); - } - if (typeSymbol) { - parentSymbol.setExportAssignedTypeSymbol(typeSymbol); - } - if (containerSymbol) { - parentSymbol.setExportAssignedContainerSymbol(containerSymbol); - } - - this.resolveDeclaredSymbol(valueSymbol, context); - this.resolveDeclaredSymbol(typeSymbol, context); - this.resolveDeclaredSymbol(containerSymbol, context); - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveAnyFunctionTypeSignature = function (funcDeclAST, typeParameters, parameterList, returnTypeAnnotation, context) { - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - var funcDeclSymbol = functionDecl.getSymbol(); - - var signature = funcDeclSymbol.kind === 33554432 /* ConstructorType */ ? funcDeclSymbol.getConstructSignatures()[0] : funcDeclSymbol.getCallSignatures()[0]; - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveFunctionTypeSignatureParameter(parameterList.parameters.nonSeparatorAt(i), signature, functionDecl, context); - } - } - - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.setTypeChecked(funcDeclAST, context); - this.typeCheckFunctionOverloads(funcDeclAST, context); - } - - return funcDeclSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionTypeSignatureParameter = function (argDeclAST, signature, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - - if (argDeclAST.typeAnnotation) { - var typeRef = this.resolveTypeReference(TypeScript.ASTHelpers.getType(argDeclAST), context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - 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) { - if (this.cachedArrayInterfaceType()) { - context.setTypeInContext(paramSymbol, this.createInstantiatedType(this.cachedArrayInterfaceType(), [this.semanticInfoChain.anyTypeSymbol])); - } else { - 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 (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(); - }; - - PullTypeResolver.prototype.resolveFunctionExpressionParameter = function (argDeclAST, id, typeExpr, equalsValueClause, contextParam, enclosingDecl, context) { - var paramDecl = this.semanticInfoChain.getDeclForAST(argDeclAST); - var paramSymbol = paramDecl.getSymbol(); - var contextualType = contextParam && contextParam.type; - var isImplicitAny = false; - - if (typeExpr) { - var typeRef = this.resolveTypeReference(typeExpr, context); - - if (paramSymbol.isVarArg && !typeRef.isArrayNamedTypeReference()) { - var diagnostic = context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Rest_parameters_must_be_array_types)); - typeRef = this.getNewErrorTypeSymbol(); - } - - contextualType = typeRef || contextualType; - } - if (contextualType) { - if (context.isInferentiallyTyping()) { - contextualType = context.fixAllTypeParametersReferencedByType(contextualType, this); - } - context.setTypeInContext(paramSymbol, contextualType); - } 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.propagateContextualType(contextualType); - } - - var initExprSymbol = this.resolveAST(equalsValueClause, contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - } - - if (!initExprSymbol || !initExprSymbol.type) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [id.text()])); - - if (!contextualType) { - context.setTypeInContext(paramSymbol, this.getNewErrorTypeSymbol(paramSymbol.name)); - } - } else { - var initTypeSymbol = this.getInstanceTypeForAssignment(argDeclAST, initExprSymbol.type, context); - if (!contextualType) { - context.setTypeInContext(paramSymbol, initTypeSymbol.widenedType(this, equalsValueClause, context)); - isImplicitAny = initTypeSymbol !== paramSymbol.type; - } else { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, contextualType, argDeclAST, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(argDeclAST); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), contextualType.toString(enclosingSymbol)])); - } - } - } - } - } - - if (!contextualType && !paramSymbol.isVarArg && !initTypeSymbol) { - context.setTypeInContext(paramSymbol, this.semanticInfoChain.anyTypeSymbol); - isImplicitAny = true; - } - - if (isImplicitAny && this.compilationSettings.noImplicitAny()) { - var functionExpressionName = paramDecl.getParentDecl().getFunctionExpressionName(); - if (functionExpressionName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [id.text(), functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(argDeclAST, TypeScript.DiagnosticCode.Parameter_0_of_lambda_function_implicitly_has_an_any_type, [id.text()])); - } - } - - if (canTypeCheckAST) { - this.checkNameForCompilerGeneratedDeclarationCollision(argDeclAST, true, id, context); - } - - paramSymbol.setResolved(); - }; - - PullTypeResolver.prototype.checkNameForCompilerGeneratedDeclarationCollision = function (astWithName, isDeclaration, name, context) { - var compilerReservedName = getCompilerReservedName(name); - switch (compilerReservedName) { - case 1 /* _this */: - this.postTypeCheckWorkitems.push(astWithName); - return; - - case 2 /* _super */: - this.checkSuperCaptureVariableCollides(astWithName, isDeclaration, context); - return; - - case 3 /* arguments */: - this.checkArgumentsCollides(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; - } - }; - - PullTypeResolver.prototype.hasRestParameterCodeGen = function (someFunctionDecl) { - var enclosingAST = this.getASTForDecl(someFunctionDecl); - var nodeType = enclosingAST.kind(); - - 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); - } 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 */) { - var constructorDeclaration = enclosingAST; - 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 */) { - var functionExpression = enclosingAST; - return TypeScript.lastParameterIsRest(functionExpression.callSignature.parameterList); - } - - return false; - }; - - PullTypeResolver.prototype.checkArgumentsCollides = function (ast, context) { - if (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_arguments_Compiler_uses_arguments_to_initialize_rest_parameters)); - } - } - } - }; - - PullTypeResolver.prototype.checkIndexOfRestArgumentInitializationCollides = function (ast, isDeclaration, context) { - if (!isDeclaration || ast.kind() === 242 /* Parameter */) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - 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)); - } - } - } - } - }; - - PullTypeResolver.prototype.checkExternalModuleRequireExportsCollides = function (ast, name, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(name); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, name)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - if (enclosingDecl && enclosingDecl.kind === 32 /* DynamicModule */) { - var decl = this.semanticInfoChain.getDeclForAST(ast); - - if (!TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - var nameText = name.valueText(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, [nameText, nameText])); - } - } - }; - - PullTypeResolver.prototype.resolveObjectTypeTypeReference = function (objectType, context) { - var interfaceDecl = this.semanticInfoChain.getDeclForAST(objectType); - TypeScript.Debug.assert(interfaceDecl); - - var interfaceSymbol = interfaceDecl.getSymbol(); - TypeScript.Debug.assert(interfaceSymbol); - - if (objectType.typeMembers) { - var memberDecl = null; - var memberSymbol = null; - var memberType = null; - var typeMembers = objectType.typeMembers; - - for (var i = 0; i < typeMembers.nonSeparatorCount(); i++) { - memberDecl = this.semanticInfoChain.getDeclForAST(typeMembers.nonSeparatorAt(i)); - memberSymbol = (memberDecl.kind & 7340032 /* SomeSignature */) ? memberDecl.getSignatureSymbol() : memberDecl.getSymbol(); - - this.resolveAST(typeMembers.nonSeparatorAt(i), false, context); - - memberType = memberSymbol.type; - - if ((memberType && memberType.isGeneric()) || (memberSymbol.isSignature() && memberSymbol.isGeneric())) { - interfaceSymbol.setHasGenericMember(); - } - } - } - - interfaceSymbol.setResolved(); - - if (this.canTypeCheckAST(objectType, context)) { - this.typeCheckObjectTypeTypeReference(objectType, context); - } - - return interfaceSymbol; - }; - - PullTypeResolver.prototype.typeCheckObjectTypeTypeReference = function (objectType, context) { - this.setTypeChecked(objectType, context); - var objectTypeDecl = this.semanticInfoChain.getDeclForAST(objectType); - var objectTypeSymbol = objectTypeDecl.getSymbol(); - - this.typeCheckMembersAgainstIndexer(objectTypeSymbol, objectTypeDecl, context); - this.checkTypeForDuplicateIndexSignatures(objectTypeSymbol); - }; - - PullTypeResolver.prototype.resolveTypeAnnotation = function (typeAnnotation, context) { - return this.resolveTypeReference(typeAnnotation.type, context); - }; - - PullTypeResolver.prototype.resolveTypeReference = function (typeRef, context) { - if (typeRef === null) { - return null; - } - - TypeScript.Debug.assert(typeRef.kind() !== 244 /* TypeAnnotation */); - - var aliasType = null; - var type = this.computeTypeReferenceSymbol(typeRef, context); - - if (type.kind === 4 /* Container */) { - var container = type; - var instanceSymbol = container.getInstanceSymbol(); - - if (instanceSymbol && (instanceSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */) || instanceSymbol.kind === 32768 /* ConstructorMethod */)) { - type = instanceSymbol.type.getAssociatedContainerType(); - } - } - - if (type && type.isAlias()) { - aliasType = type; - type = aliasType.getExportAssignedTypeSymbol(); - } - - if (type && !type.isGeneric()) { - if (aliasType) { - this.semanticInfoChain.setAliasSymbolForAST(typeRef, aliasType); - } - } - - if (type && !type.isError()) { - 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 { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeRef, TypeScript.DiagnosticCode.Type_reference_must_refer_to_type)); - } - } - } - - if (this.canTypeCheckAST(typeRef, context)) { - this.setTypeChecked(typeRef, context); - } - - 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 */: - return this.semanticInfoChain.anyTypeSymbol; - case 61 /* BooleanKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - case 67 /* NumberKeyword */: - return this.semanticInfoChain.numberTypeSymbol; - case 69 /* StringKeyword */: - return this.semanticInfoChain.stringTypeSymbol; - case 41 /* VoidKeyword */: - return this.semanticInfoChain.voidTypeSymbol; - } - - var typeDeclSymbol = null; - - if (term.kind() === 11 /* IdentifierName */) { - typeDeclSymbol = this.resolveTypeNameExpression(term, context); - } else if (term.kind() === 123 /* FunctionType */) { - var functionType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(functionType, functionType.typeParameterList, functionType.parameterList, functionType.type, context); - } else if (term.kind() === 125 /* ConstructorType */) { - var constructorType = term; - typeDeclSymbol = this.resolveAnyFunctionTypeSignature(constructorType, constructorType.typeParameterList, constructorType.parameterList, constructorType.type, context); - } else if (term.kind() === 122 /* ObjectType */) { - typeDeclSymbol = this.resolveObjectTypeTypeReference(term, context); - } else if (term.kind() === 126 /* GenericType */) { - typeDeclSymbol = this.resolveGenericTypeReference(term, context); - } else if (term.kind() === 121 /* QualifiedName */) { - typeDeclSymbol = this.resolveQualifiedName(term, context); - } else if (term.kind() === 14 /* StringLiteral */) { - 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, enclosingDecl.semanticInfoChain); - typeDeclSymbol.addDeclaration(decl); - } else if (term.kind() === 127 /* TypeQuery */) { - var typeQuery = term; - - var typeQueryTerm = typeQuery.name; - - var valueSymbol = this.resolveAST(typeQueryTerm, false, context); - - if (valueSymbol && valueSymbol.isAlias()) { - if (valueSymbol.assignedValue()) { - valueSymbol = valueSymbol.assignedValue(); - } else { - var containerSymbol = valueSymbol.getExportAssignedContainerSymbol(); - valueSymbol = (containerSymbol && containerSymbol.isContainer() && !containerSymbol.isEnum()) ? containerSymbol.getInstanceSymbol() : null; - } - } - - if (valueSymbol) { - typeDeclSymbol = valueSymbol.type.widenedType(this, typeQueryTerm, context); - } else { - typeDeclSymbol = this.getNewErrorTypeSymbol(); - } - } else if (term.kind() === 124 /* ArrayType */) { - var arrayType = term; - var underlying = this.resolveTypeReference(arrayType.type, context); - typeDeclSymbol = this.getArrayType(underlying); - } else { - throw TypeScript.Errors.invalidOperation("unknown type"); - } - - if (!typeDeclSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Unable_to_resolve_type)); - return this.getNewErrorTypeSymbol(); - } - - if (typeDeclSymbol.isError()) { - return typeDeclSymbol; - } - - if (this.genericTypeIsUsedWithoutRequiredTypeArguments(typeDeclSymbol, term, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(term, TypeScript.DiagnosticCode.Generic_type_references_must_include_all_type_arguments)); - typeDeclSymbol = this.instantiateTypeToAny(typeDeclSymbol, context); - } - - return typeDeclSymbol; - }; - - PullTypeResolver.prototype.genericTypeIsUsedWithoutRequiredTypeArguments = function (typeSymbol, term, context) { - 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.ASTHelpers.getType(varDecl.variableDeclarator), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolvePropertySignature = function (varDecl, 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.ASTHelpers.getVariableDeclaratorModifiers(varDecl), varDecl.propertyName, TypeScript.ASTHelpers.getType(varDecl), varDecl.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveParameterList = function (list, context) { - return this.resolveSeparatedList(list.parameters, context); - }; - - PullTypeResolver.prototype.resolveParameter = function (parameter, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(parameter, parameter.modifiers, parameter.identifier, TypeScript.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.getEnumTypeSymbol = function (enumElement, context) { - var enumDeclaration = enumElement.parent.parent; - var decl = this.semanticInfoChain.getDeclForAST(enumDeclaration); - var symbol = decl.getSymbol(); - this.resolveDeclaredSymbol(symbol, context); - - return symbol; - }; - - PullTypeResolver.prototype.resolveEnumElement = function (enumElement, context) { - return this.resolveVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckEnumElement = function (enumElement, context) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(enumElement, TypeScript.sentinelEmptyArray, enumElement.propertyName, null, enumElement.equalsValueClause, context); - }; - - PullTypeResolver.prototype.resolveEqualsValueClause = function (clause, isContextuallyTyped, context) { - if (this.canTypeCheckAST(clause, context)) { - this.setTypeChecked(clause, context); - } - - return this.resolveAST(clause.value, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - - if (enclosingDecl && decl.kind === 2048 /* Parameter */) { - enclosingDecl.ensureSymbolIsBound(); - } - - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (declSymbol.isResolved) { - var declType = declSymbol.type; - var valDecl = decl.getValueDecl(); - - if (valDecl) { - var valSymbol = valDecl.getSymbol(); - - if (valSymbol && !valSymbol.isResolved) { - valSymbol.type = declType; - valSymbol.setResolved(); - } - } - } else { - if (declSymbol.inResolution) { - declSymbol.type = this.semanticInfoChain.anyTypeSymbol; - declSymbol.setResolved(); - return declSymbol; - } - - if (!declSymbol.type || !declSymbol.type.isError()) { - declSymbol.startResolving(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - if (!hasTypeExpr) { - this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - } - - if (!(hasTypeExpr || init)) { - var defaultType = this.semanticInfoChain.anyTypeSymbol; - - if (declSymbol.isVarArg && this.cachedArrayInterfaceType()) { - defaultType = this.createInstantiatedType(this.cachedArrayInterfaceType(), [defaultType]); - } - - context.setTypeInContext(declSymbol, defaultType); - - if (declParameterSymbol) { - declParameterSymbol.type = defaultType; - } - } - declSymbol.setResolved(); - - if (declParameterSymbol) { - declParameterSymbol.setResolved(); - } - } - } - - if (this.canTypeCheckAST(varDeclOrParameter, context)) { - this.typeCheckVariableDeclaratorOrParameterOrEnumElement(varDeclOrParameter, modifiers, name, typeExpr, init, context); - } - - return declSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclarationTypeExpr = function (varDeclOrParameter, name, typeExpr, context) { - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - if (varDeclOrParameter.kind() === 243 /* EnumElement */) { - var result = this.getEnumTypeSymbol(varDeclOrParameter, context); - declSymbol.type = result; - return result; - } - - if (!typeExpr) { - return null; - } - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var typeExprSymbol = this.resolveTypeReference(typeExpr, context); - - if (!typeExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - declSymbol.type = this.getNewErrorTypeSymbol(); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } else if (typeExprSymbol.isError()) { - context.setTypeInContext(declSymbol, typeExprSymbol); - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, typeExprSymbol); - } - } else { - if (typeExprSymbol === this.semanticInfoChain.anyTypeSymbol) { - decl.setFlag(16777216 /* IsAnnotatedWithAny */); - } - - if (typeExprSymbol.isContainer()) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - typeExprSymbol = typeExprSymbol.type; - - if (typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.isContainer() && !typeExprSymbol.isEnum()) { - var instanceSymbol = typeExprSymbol.getInstanceSymbol(); - - if (!instanceSymbol || !TypeScript.PullHelpers.symbolIsEnum(instanceSymbol)) { - typeExprSymbol = this.getNewErrorTypeSymbol(); - } else { - typeExprSymbol = instanceSymbol.type; - } - } - } - } 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(); - } - - context.setTypeInContext(declSymbol, typeExprSymbol); - - if (declParameterSymbol) { - declParameterSymbol.type = typeExprSymbol; - } - - if (typeExprSymbol.kind === 16777216 /* FunctionType */ && !typeExprSymbol.getFunctionSymbol()) { - typeExprSymbol.setFunctionSymbol(declSymbol); - } - } - - return typeExprSymbol; - }; - - PullTypeResolver.prototype.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr = function (varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol) { - if (!init) { - return null; - } - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - if (typeExprSymbol) { - context.pushNewContextualType(typeExprSymbol); - } - - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - var declParameterSymbol = decl.getValueDecl() ? decl.getValueDecl().getSymbol() : null; - - var wrapperDecl = this.getEnclosingDecl(decl); - wrapperDecl = wrapperDecl || enclosingDecl; - - var initExprSymbol = this.resolveAST(init, typeExprSymbol !== null, context); - - if (typeExprSymbol) { - context.popAnyContextualType(); - } - - if (!initExprSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Unable_to_resolve_type_of_0, [name.text()])); - - if (!hasTypeExpr) { - context.setTypeInContext(declSymbol, this.getNewErrorTypeSymbol()); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, this.semanticInfoChain.anyTypeSymbol); - } - } - } else { - var initTypeSymbol = initExprSymbol.type; - - if (!hasTypeExpr) { - var widenedInitTypeSymbol = initTypeSymbol.widenedType(this, init.value, context); - context.setTypeInContext(declSymbol, widenedInitTypeSymbol); - - if (declParameterSymbol) { - context.setTypeInContext(declParameterSymbol, widenedInitTypeSymbol); - } - - if (this.compilationSettings.noImplicitAny()) { - 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 initTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckPropertySignature = function (varDecl, 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.ASTHelpers.getType(varDecl), varDecl.variableDeclarator.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclarator = function (varDecl, 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.ASTHelpers.getType(parameter), parameter.equalsValueClause, context); - }; - - PullTypeResolver.prototype.typeCheckVariableDeclaratorOrParameterOrEnumElement = function (varDeclOrParameter, modifiers, name, typeExpr, init, context) { - var _this = this; - this.setTypeChecked(varDeclOrParameter, context); - - var hasTypeExpr = typeExpr !== null || varDeclOrParameter.kind() === 243 /* EnumElement */; - var enclosingDecl = this.getEnclosingDeclForAST(varDeclOrParameter); - var decl = this.semanticInfoChain.getDeclForAST(varDeclOrParameter); - var declSymbol = decl.getSymbol(); - - var typeExprSymbol = this.resolveAndTypeCheckVariableDeclarationTypeExpr(varDeclOrParameter, name, typeExpr, context); - - var initTypeSymbol = this.resolveAndTypeCheckVariableDeclaratorOrParameterInitExpr(varDeclOrParameter, name, typeExpr, init, context, typeExprSymbol); - - if (hasTypeExpr || init) { - if (typeExprSymbol && typeExprSymbol.isAlias()) { - typeExprSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - } - - if (typeExprSymbol && typeExprSymbol.kind === 32 /* DynamicModule */) { - var exportedTypeSymbol = typeExprSymbol.getExportAssignedTypeSymbol(); - - if (exportedTypeSymbol) { - typeExprSymbol = exportedTypeSymbol; - } else { - var instanceTypeSymbol = typeExprSymbol.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [typeExprSymbol.toString()])); - typeExprSymbol = null; - } else { - typeExprSymbol = instanceTypeSymbol; - } - } - } - - initTypeSymbol = this.getInstanceTypeForAssignment(varDeclOrParameter, initTypeSymbol, context); - - if (initTypeSymbol && typeExprSymbol) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(initTypeSymbol, typeExprSymbol, varDeclOrParameter, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(varDeclOrParameter); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [initTypeSymbol.toString(enclosingSymbol), typeExprSymbol.toString(enclosingSymbol)])); - } - } - } - } else if (varDeclOrParameter.kind() !== 243 /* EnumElement */ && this.compilationSettings.noImplicitAny() && !this.isForInVariableDeclarator(varDeclOrParameter)) { - var wrapperDecl = this.getEnclosingDecl(decl); - 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])); - } else if (wrapperDecl.kind === 65536 /* Method */) { - var parentDecl = wrapperDecl.getParentDecl(); - - if (!TypeScript.hasFlag(parentDecl.flags, 8 /* Ambient */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Parameter_0_of_1_implicitly_has_an_any_type, [name.text(), enclosingDecl.name])); - } 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 (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 */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } else if (TypeScript.hasFlag(wrapperDecl.flags, 8 /* Ambient */) && !TypeScript.hasModifier(modifiers, 2 /* Private */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(varDeclOrParameter, TypeScript.DiagnosticCode.Variable_0_implicitly_has_an_any_type, [name.text()])); - } - } - } - - 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_only_allowed_in_implementation)); - } - } - 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 */)) { - this.checkNameForCompilerGeneratedDeclarationCollision(varDeclOrParameter, true, name, context); - } - }; - - PullTypeResolver.prototype.isForInVariableDeclarator = function (ast) { - return ast.kind() === 225 /* VariableDeclarator */ && ast.parent && ast.parent.parent && ast.parent.parent.parent && ast.parent.kind() === 2 /* SeparatedList */ && ast.parent.parent.kind() === 224 /* VariableDeclaration */ && ast.parent.parent.parent.kind() === 155 /* ForInStatement */ && ast.parent.parent.parent.variableDeclaration === ast.parent.parent; - }; - - PullTypeResolver.prototype.checkSuperCaptureVariableCollides = function (superAST, isDeclaration, context) { - var enclosingDecl = this.getEnclosingDeclForAST(superAST); - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(superAST, enclosingDecl); - - if (classSymbol && !classSymbol.anyDeclHasFlag(8 /* Ambient */)) { - 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; - if (!block) { - return; - } - } - } - - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - if (parents.length) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(superAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference : TypeScript.DiagnosticCode.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference)); - } - } - }; - - PullTypeResolver.prototype.checkThisCaptureVariableCollides = function (_thisAST, isDeclaration, context) { - if (isDeclaration) { - var decl = this.semanticInfoChain.getDeclForAST(_thisAST); - if (TypeScript.hasFlag(decl.flags, 8 /* Ambient */)) { - return; - } - } - - var enclosingDecl = this.getEnclosingDeclForAST(_thisAST); - - var enclosingModule = TypeScript.ASTHelpers.getEnclosingModuleDeclaration(_thisAST); - if (TypeScript.ASTHelpers.isAnyNameOfModule(enclosingModule, _thisAST)) { - enclosingDecl = this.getEnclosingDeclForAST(enclosingModule); - } - - var declPath = enclosingDecl.getParentPath(); - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - continue; - } - - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - if (TypeScript.hasFlag(decl.flags, 262144 /* MustCaptureThis */)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(_thisAST, isDeclaration ? TypeScript.DiagnosticCode.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference : TypeScript.DiagnosticCode.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference)); - } - break; - } - } - }; - - PullTypeResolver.prototype.postTypeCheckVariableDeclaratorOrParameter = function (varDeclOrParameter, context) { - this.checkThisCaptureVariableCollides(varDeclOrParameter, true, context); - }; - - PullTypeResolver.prototype.resolveTypeParameterDeclaration = function (typeParameterAST, context) { - 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) { - return; - } - - typeParameterSymbol.startResolving(); - - if (typeParameterAST.constraint) { - var constraintTypeSymbol = this.resolveTypeReference(typeParameterAST.constraint.type, context); - - if (constraintTypeSymbol) { - typeParameterSymbol.setConstraint(constraintTypeSymbol); - } - } - - typeParameterSymbol.setResolved(); - }; - - PullTypeResolver.prototype.typeCheckTypeParameterDeclaration = function (typeParameterAST, context) { - this.setTypeChecked(typeParameterAST, 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) { - if (this.canTypeCheckAST(constraint, context)) { - this.setTypeChecked(constraint, context); - } - - return this.resolveTypeReference(constraint.type, context); - }; - - PullTypeResolver.prototype.resolveFunctionBodyReturnTypes = function (funcDeclAST, block, bodyExpression, signature, useContextualType, enclosingDecl, context) { - var _this = this; - var returnStatementsExpressions = []; - - var enclosingDeclStack = [enclosingDecl]; - - var preFindReturnExpressionTypes = function (ast, walker) { - var go = true; - - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 215 /* ObjectLiteralExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - returnStatementsExpressions.push({ expression: returnStatement.expression, enclosingDecl: enclosingDeclStack[enclosingDeclStack.length - 1] }); - go = false; - break; - - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack[enclosingDeclStack.length] = _this.semanticInfoChain.getDeclForAST(ast); - break; - - default: - break; - } - - walker.options.goChildren = go; - - return ast; - }; - - var postFindReturnExpressionEnclosingDecls = function (ast, walker) { - switch (ast.kind()) { - case 236 /* CatchClause */: - case 163 /* WithStatement */: - enclosingDeclStack.length--; - break; - default: - break; - } - - walker.options.goChildren = true; - - return ast; - }; - - if (block) { - TypeScript.getAstWalkerFactory().walk(block, preFindReturnExpressionTypes, postFindReturnExpressionEnclosingDecls); - } else { - returnStatementsExpressions.push({ expression: bodyExpression, enclosingDecl: enclosingDecl }); - enclosingDecl.setFlag(4194304 /* HasReturnStatement */); - } - - if (!returnStatementsExpressions.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var returnExpressionSymbols = []; - var returnExpressions = []; - - for (var i = 0; i < returnStatementsExpressions.length; i++) { - var returnExpression = returnStatementsExpressions[i].expression; - if (returnExpression) { - var returnType = this.resolveAST(returnExpression, useContextualType, context).type; - - if (returnType.isError()) { - signature.returnType = returnType; - return; - } else { - if (returnExpression.parent.kind() === 150 /* ReturnStatement */) { - this.setSymbolForAST(returnExpression.parent, returnType, context); - } - } - - returnExpressionSymbols.push(returnType); - returnExpressions.push(returnExpression); - } - } - - if (!returnExpressionSymbols.length) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - } else { - var collection = { - getLength: function () { - return returnExpressionSymbols.length; - }, - getTypeAtIndex: function (index) { - return returnExpressionSymbols[index].type; - } - }; - - var bestCommonReturnType = this.findBestCommonType(collection, context, new TypeComparisonInfo()); - var returnType = bestCommonReturnType; - var returnExpression = returnExpressions[returnExpressionSymbols.indexOf(returnType)]; - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - - if (returnType) { - var previousReturnType = returnType; - var newReturnType = returnType.widenedType(this, returnExpression, context); - signature.returnType = newReturnType; - - if (!TypeScript.ArrayUtilities.contains(returnExpressionSymbols, bestCommonReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Could_not_find_the_best_common_type_of_types_of_all_return_statement_expressions)); - } - - if (this.compilationSettings.noImplicitAny()) { - if (previousReturnType !== newReturnType && newReturnType === this.semanticInfoChain.anyTypeSymbol) { - var functionName = enclosingDecl.name; - if (functionName === "") { - functionName = enclosingDecl.getFunctionExpressionName(); - } - - if (functionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } - - if (!functionSymbol.type && functionSymbol.isAccessor()) { - functionSymbol.type = signature.returnType; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckConstructorDeclaration = function (funcDeclAST, context) { - var _this = this; - this.setTypeChecked(funcDeclAST, context); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - 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(), "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(), "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.ASTHelpers.parametersFromParameterList(funcDeclAST.callSignature.parameterList), null, funcDeclAST.block, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.constructorHasSuperCall = function (constructorDecl) { - var _this = this; - if (constructorDecl.block) { - var foundSuperCall = false; - var pre = function (ast, walker) { - 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; - } - } - }; - - TypeScript.getAstWalkerFactory().walk(constructorDecl.block, pre); - return foundSuperCall; - } - - return false; - }; - - 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.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.typeParameterList, funcDecl.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, context); - }; - - PullTypeResolver.prototype.typeCheckConstructSignature = function (funcDecl, context) { - this.typeCheckAnyFunctionDeclaration(funcDecl, false, null, funcDecl.callSignature.typeParameterList, funcDecl.callSignature.parameterList, TypeScript.ASTHelpers.getType(funcDecl), null, 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(parameters, false, context); - - this.resolveAST(block, false, context); - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - this.validateVariableDeclarationGroups(funcDecl, context); - - this.checkFunctionTypePrivacy(funcDeclAST, isStatic, typeParameters, TypeScript.ASTHelpers.parametersFromParameterList(parameters), returnTypeAnnotation, block, context); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(funcDecl, returnTypeAnnotation, funcDecl.getSignatureSymbol().returnType, block, context); - - if (funcDecl.kind === 16384 /* Function */) { - this.checkNameForCompilerGeneratedDeclarationCollision(funcDeclAST, true, name, context); - } - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - 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); - - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - this.resolveAST(funcDeclAST.parameter, false, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - this.validateVariableDeclarationGroups(funcDecl, 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.getBothKindsOfIndexSignaturesExcludingAugmentedType(parentSymbol, context); - var stringIndexSignature = allIndexSignatures.stringSignature; - var numberIndexSignature = allIndexSignatures.numericSignature; - var isNumericIndexer = numberIndexSignature === signature; - - if (numberIndexSignature && stringIndexSignature && (isNumericIndexer || stringIndexSignature.getDeclarations()[0].getParentDecl() !== numberIndexSignature.getDeclarations()[0].getParentDecl())) { - var comparisonInfo = new TypeComparisonInfo(); - - 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_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_assignable_to_string_indexer_type_1, [numberIndexSignature.returnType.toString(enclosingSymbol), stringIndexSignature.returnType.toString(enclosingSymbol)])); - } - } - } - - var allMembers = parentSymbol.type.getAllMembers(536869887 /* All */, 0 /* all */); - for (var i = 0; i < allMembers.length; i++) { - var member = allMembers[i]; - var name = member.name; - if (name || (member.kind === 4096 /* Property */ && name === "")) { - if (!allMembers[i].isResolved) { - _this.resolveDeclaredSymbol(allMembers[i], context); - } - - if (parentSymbol !== allMembers[i].getContainer()) { - var isMemberNumeric = TypeScript.PullHelpers.isNameNumeric(name); - var indexerKindMatchesMemberNameKind = isNumericIndexer === isMemberNumeric; - var onlyStringIndexerIsPresent = !numberIndexSignature; - - if (indexerKindMatchesMemberNameKind || onlyStringIndexerIsPresent) { - var comparisonInfo = new TypeComparisonInfo(); - if (!_this.sourceIsAssignableToTarget(allMembers[i].type, signature.returnType, funcDeclAST, context, comparisonInfo, false)) { - _this.reportErrorThatMemberIsNotSubtypeOfIndexer(allMembers[i], signature, funcDeclAST, context, comparisonInfo); - } - } - } - } - } - }); - }; - - PullTypeResolver.prototype.postTypeCheckFunctionDeclaration = function (funcDeclAST, context) { - this.checkThisCaptureVariableCollides(funcDeclAST, true, context); - }; - - PullTypeResolver.prototype.resolveReturnTypeAnnotationOfFunctionDeclaration = function (funcDeclAST, returnTypeAnnotation, context) { - var returnTypeSymbol = null; - - if (returnTypeAnnotation) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - } else { - var isConstructor = funcDeclAST.kind() === 137 /* ConstructorDeclaration */ || funcDeclAST.kind() === 143 /* ConstructSignature */; - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } - - return returnTypeSymbol; - }; - - 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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveCallSignature = function (funcDecl, 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.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.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.ASTHelpers.getType(funcDecl), funcDecl.block, context); - }; - - PullTypeResolver.prototype.resolveFunctionExpression = function (funcDecl, 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.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.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), TypeScript.ASTHelpers.getType(funcDecl), funcDecl.block, funcDecl.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.getEnclosingClassDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 131 /* ClassDeclaration */) { - return ast; - } - - ast = ast.parent; - } - - return null; - }; - - PullTypeResolver.prototype.resolveConstructorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - return funcSymbol; - } - - if (!signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - 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(); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckConstructorDeclaration(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveIndexMemberDeclaration = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveIndexSignature(ast.indexSignature, context); - }; - - PullTypeResolver.prototype.resolveIndexSignature = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - return funcSymbol; - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (funcDeclAST.typeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(TypeScript.ASTHelpers.getType(funcDeclAST), context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(TypeScript.ASTHelpers.getType(funcDeclAST), TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (funcDeclAST.parameter) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - this.resolveParameter(funcDeclAST.parameter, context); - context.inTypeCheck = prevInTypeCheck; - } - - if (funcDeclAST.typeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckIndexSignature(funcDeclAST, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveFunctionDeclaration = function (funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcSymbol = funcDecl.getSymbol(); - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - var isConstructor = funcDeclAST.kind() === 143 /* ConstructSignature */; - - if (signature) { - if (signature.isResolved) { - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - return funcSymbol; - } - - if (isConstructor && !signature.inResolution) { - var classAST = this.getEnclosingClassDeclaration(funcDeclAST); - - if (classAST) { - var classDecl = this.semanticInfoChain.getDeclForAST(classAST); - var classSymbol = classDecl.getSymbol(); - - if (!classSymbol.isResolved && !classSymbol.inResolution) { - this.resolveDeclaredSymbol(classSymbol, context); - } - } - } - - var functionTypeSymbol = funcSymbol && funcSymbol.type; - - if (signature.inResolution) { - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - if (!returnTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, TypeScript.DiagnosticCode.Cannot_resolve_return_type_reference)); - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - - if (isConstructor && returnTypeSymbol === this.semanticInfoChain.voidTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructors_cannot_have_a_return_type_of_void)); - } - } - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - } - - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - return funcSymbol; - } - - if (funcSymbol) { - funcSymbol.startResolving(); - } - signature.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - if (parameterList) { - var prevInTypeCheck = context.inTypeCheck; - - context.inTypeCheck = false; - - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - - context.inTypeCheck = prevInTypeCheck; - } - - if (returnTypeAnnotation) { - returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else if (funcDecl.kind !== 2097152 /* ConstructSignature */) { - if (TypeScript.hasFlag(funcDecl.flags, 2048 /* Signature */)) { - 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; - if (funcDeclASTName) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [funcDeclASTName.text()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Lambda_Function_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } - } else if (funcDecl.kind === 2097152 /* ConstructSignature */) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Constructor_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - - if (!hadError) { - if (funcSymbol) { - funcSymbol.setUnresolved(); - if (funcSymbol.type === this.semanticInfoChain.anyTypeSymbol) { - funcSymbol.type = functionTypeSymbol; - } - } - signature.setResolved(); - } - } - - if (funcSymbol) { - this.resolveOtherDeclarations(funcDeclAST, context); - } - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionDeclaration(funcDeclAST, isStatic, name, typeParameters, parameterList, returnTypeAnnotation, block, context); - } - - return funcSymbol; - }; - - PullTypeResolver.prototype.resolveGetterReturnTypeAnnotation = function (getterFunctionDeclarationAst, enclosingDecl, context) { - if (getterFunctionDeclarationAst && getterFunctionDeclarationAst.typeAnnotation) { - return this.resolveTypeReference(TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), context); - } - - return null; - }; - - 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.ASTHelpers.getType(parameter), context); - } - - return null; - }; - - PullTypeResolver.prototype.resolveAccessorDeclaration = function (funcDeclAst, context) { - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - - if (accessorSymbol.inResolution) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - accessorSymbol.setResolved(); - - return accessorSymbol; - } - - if (accessorSymbol.isResolved) { - if (!accessorSymbol.type) { - accessorSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else { - var getterSymbol = accessorSymbol.getGetter(); - var getterFunctionDeclarationAst = getterSymbol ? getterSymbol.getDeclarations()[0].ast() : null; - var hasGetter = getterSymbol !== null; - - var setterSymbol = accessorSymbol.getSetter(); - var setterFunctionDeclarationAst = setterSymbol ? setterSymbol.getDeclarations()[0].ast() : null; - var hasSetter = setterSymbol !== null; - - var getterAnnotatedType = this.resolveGetterReturnTypeAnnotation(getterFunctionDeclarationAst, functionDeclaration, context); - var getterHasTypeAnnotation = getterAnnotatedType !== null; - - var setterAnnotatedType = this.resolveSetterArgumentTypeAnnotation(setterFunctionDeclarationAst, functionDeclaration, context); - var setterHasTypeAnnotation = setterAnnotatedType !== null; - - accessorSymbol.startResolving(); - - if (hasGetter) { - getterSymbol = this.resolveGetAccessorDeclaration(getterFunctionDeclarationAst, getterFunctionDeclarationAst.parameterList, TypeScript.ASTHelpers.getType(getterFunctionDeclarationAst), getterFunctionDeclarationAst.block, setterAnnotatedType, context); - } - - if (hasSetter) { - setterSymbol = this.resolveSetAccessorDeclaration(setterFunctionDeclarationAst, setterFunctionDeclarationAst.parameterList, context); - } - - if (hasGetter && hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - var getterSig = getterSymbol.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterHasParameters ? setterParameters[0].type : null; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (setterHasTypeAnnotation && !getterHasTypeAnnotation) { - getterSuppliedTypeSymbol = setterSuppliedTypeSymbol; - getterSig.returnType = setterSuppliedTypeSymbol; - } else if ((getterHasTypeAnnotation && !setterHasTypeAnnotation) || (!getterHasTypeAnnotation && !setterHasTypeAnnotation)) { - setterSuppliedTypeSymbol = getterSuppliedTypeSymbol; - - if (setterHasParameters) { - setterParameters[0].type = getterSuppliedTypeSymbol; - } - } - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - accessorSymbol.type = this.getNewErrorTypeSymbol(); - } else { - accessorSymbol.type = getterSuppliedTypeSymbol; - } - } else if (hasSetter) { - var setterSig = setterSymbol.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - var setterHasParameters = setterParameters.length > 0; - - accessorSymbol.type = setterHasParameters ? setterParameters[0].type : this.semanticInfoChain.anyTypeSymbol; - } else { - var getterSig = getterSymbol.type.getCallSignatures()[0]; - accessorSymbol.type = getterSig.returnType; - } - - accessorSymbol.setResolved(); - } - - if (this.canTypeCheckAST(funcDeclAst, context)) { - this.typeCheckAccessorDeclaration(funcDeclAst, context); - } - - return accessorSymbol; - }; - - PullTypeResolver.prototype.typeCheckAccessorDeclaration = function (funcDeclAst, context) { - this.setTypeChecked(funcDeclAst, context); - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDeclAst); - var accessorSymbol = functionDeclaration.getSymbol(); - var getterSymbol = accessorSymbol.getGetter(); - var setterSymbol = accessorSymbol.getSetter(); - - var isGetter = funcDeclAst.kind() === 139 /* GetAccessor */; - if (isGetter) { - var getterFunctionDeclarationAst = funcDeclAst; - context.pushNewContextualType(getterSymbol.type); - this.typeCheckGetAccessorDeclaration(getterFunctionDeclarationAst, context); - context.popAnyContextualType(); - } else { - var setterFunctionDeclarationAst = funcDeclAst; - this.typeCheckSetAccessorDeclaration(setterFunctionDeclarationAst, context); - } - }; - - PullTypeResolver.prototype.resolveGetAccessorDeclaration = function (funcDeclAST, parameters, returnTypeAnnotation, block, setterAnnotatedType, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var getterSymbol = accessorSymbol.getGetter(); - var getterTypeSymbol = getterSymbol.type; - - var signature = getterTypeSymbol.getCallSignatures()[0]; - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return getterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - signature.setResolved(); - - return getterSymbol; - } - - signature.startResolving(); - - if (returnTypeAnnotation) { - var returnTypeSymbol = this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, returnTypeAnnotation, context); - - if (!returnTypeSymbol) { - signature.returnType = this.getNewErrorTypeSymbol(); - - hadError = true; - } else { - signature.returnType = returnTypeSymbol; - } - } else { - if (!setterAnnotatedType) { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, null, signature, false, funcDecl, context); - } else { - signature.returnType = setterAnnotatedType; - } - } - - if (!hadError) { - signature.setResolved(); - } - } - - return getterSymbol; - }; - - PullTypeResolver.prototype.checkIfGetterAndSetterTypeMatch = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - var getter = accessorSymbol.getGetter(); - var setter = accessorSymbol.getSetter(); - - if (getter && setter) { - var getterAST = getter.getDeclarations()[0].ast(); - var setterAST = setter.getDeclarations()[0].ast(); - - if (getterAST.typeAnnotation && PullTypeResolver.hasSetAccessorParameterTypeAnnotation(setterAST)) { - var setterSig = setter.type.getCallSignatures()[0]; - var setterParameters = setterSig.parameters; - - var getter = accessorSymbol.getGetter(); - var getterSig = getter.type.getCallSignatures()[0]; - - var setterSuppliedTypeSymbol = setterParameters[0].type; - var getterSuppliedTypeSymbol = getterSig.returnType; - - if (!this.typesAreIdentical(setterSuppliedTypeSymbol, getterSuppliedTypeSymbol, context)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.get_and_set_accessor_must_have_the_same_type)); - } - } - } - }; - - PullTypeResolver.prototype.typeCheckGetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - this.resolveReturnTypeAnnotationOfFunctionDeclaration(funcDeclAST, TypeScript.ASTHelpers.getType(funcDeclAST), context); - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var enclosingDecl = this.getEnclosingDecl(funcDecl); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - var funcNameAST = funcDeclAST.propertyName; - - if (!hasReturn && !this.containsSingleThrowStatement(funcDeclAST.block)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getters_must_return_a_value)); - } - - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - var setterIsPrivate = TypeScript.hasFlag(setterDecl.flags, 2 /* Private */); - var getterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - 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.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; - }; - - PullTypeResolver.prototype.resolveSetAccessorDeclaration = function (funcDeclAST, parameterList, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - var setterSymbol = accessorSymbol.getSetter(); - var setterTypeSymbol = setterSymbol.type; - - var signature = funcDecl.getSignatureSymbol(); - - var hadError = false; - - if (signature) { - if (signature.isResolved) { - return setterSymbol; - } - - if (signature.inResolution) { - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - signature.setResolved(); - return setterSymbol; - } - - signature.startResolving(); - - if (parameterList) { - for (var i = 0; i < parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(parameterList.parameters.nonSeparatorAt(i), context); - } - } - - signature.returnType = this.semanticInfoChain.voidTypeSymbol; - - if (!hadError) { - signature.setResolved(); - } - } - - return setterSymbol; - }; - - PullTypeResolver.prototype.typeCheckSetAccessorDeclaration = function (funcDeclAST, context) { - var funcDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var accessorSymbol = funcDecl.getSymbol(); - - if (funcDeclAST.parameterList) { - for (var i = 0; i < funcDeclAST.parameterList.parameters.nonSeparatorCount(); i++) { - this.resolveParameter(funcDeclAST.parameterList.parameters.nonSeparatorAt(i), context); - } - } - - this.resolveAST(funcDeclAST.block, false, context); - - this.validateVariableDeclarationGroups(funcDecl, context); - - var hasReturn = (funcDecl.flags & (2048 /* Signature */ | 4194304 /* HasReturnStatement */)) !== 0; - - var getter = accessorSymbol.getGetter(); - - var funcNameAST = funcDeclAST.propertyName; - - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - var getterIsPrivate = TypeScript.hasFlag(getterDecl.flags, 2 /* Private */); - var setterIsPrivate = TypeScript.hasModifier(funcDeclAST.modifiers, 2 /* Private */); - - if (getterIsPrivate !== setterIsPrivate) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcNameAST, TypeScript.DiagnosticCode.Getter_and_setter_accessors_do_not_agree_in_visibility)); - } - - this.checkIfGetterAndSetterTypeMatch(funcDeclAST, context); - } else { - if (this.compilationSettings.noImplicitAny()) { - var setterFunctionDeclarationAst = funcDeclAST; - 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.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), null, funcDeclAST.block, context); - }; - - PullTypeResolver.prototype.resolveList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.childCount(); i < n; i++) { - this.resolveAST(list.childAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveSeparatedList = function (list, context) { - if (this.canTypeCheckAST(list, context)) { - this.setTypeChecked(list, context); - - for (var i = 0, n = list.nonSeparatorCount(); i < n; i++) { - this.resolveAST(list.nonSeparatorAt(i), false, context); - } - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVoidExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.undefinedTypeSymbol; - }; - - PullTypeResolver.prototype.resolveLogicalOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLogicalOperation(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLogicalOperation = function (binex, context) { - this.setTypeChecked(binex, context); - - var leftType = this.resolveAST(binex.left, false, context).type; - var rightType = this.resolveAST(binex.right, false, context).type; - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(leftType, rightType, binex, context, comparisonInfo) && !this.sourceIsAssignableToTarget(rightType, leftType, binex, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(binex); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binex, TypeScript.DiagnosticCode.Operator_0_cannot_be_applied_to_types_1_and_2, [ - TypeScript.SyntaxFacts.getText(TypeScript.SyntaxFacts.getOperatorTokenFromBinaryExpression(binex.kind())), - leftType.toString(enclosingSymbol), rightType.toString(enclosingSymbol)])); - } - }; - - PullTypeResolver.prototype.resolveLogicalNotExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.operand, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveUnaryArithmeticOperation = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckUnaryArithmeticOperation(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.resolvePostfixUnaryExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckPostfixUnaryExpression(ast, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.isAnyOrNumberOrEnum = function (type) { - return this.isAnyOrEquivalent(type) || type === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(type); - }; - - PullTypeResolver.prototype.typeCheckUnaryArithmeticOperation = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - if (nodeType === 164 /* PlusExpression */ || nodeType == 165 /* NegateExpression */ || nodeType == 166 /* BitwiseNotExpression */) { - return; - } - - TypeScript.Debug.assert(nodeType === 168 /* PreIncrementExpression */ || nodeType === 169 /* PreDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.typeCheckPostfixUnaryExpression = function (unaryExpression, context) { - this.setTypeChecked(unaryExpression, context); - - var nodeType = unaryExpression.kind(); - var expression = this.resolveAST(unaryExpression.operand, false, context); - - TypeScript.Debug.assert(nodeType === 210 /* PostIncrementExpression */ || nodeType === 211 /* PostDecrementExpression */); - - var operandType = expression.type; - if (!this.isAnyOrNumberOrEnum(operandType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_type_of_a_unary_arithmetic_operation_operand_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!this.isReference(unaryExpression.operand, expression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(unaryExpression.operand, TypeScript.DiagnosticCode.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer)); - } - }; - - PullTypeResolver.prototype.resolveBinaryArithmeticExpression = function (binaryExpression, context) { - if (this.canTypeCheckAST(binaryExpression, context)) { - this.typeCheckBinaryArithmeticExpression(binaryExpression, context); - } - - return this.semanticInfoChain.numberTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBinaryArithmeticExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsSymbol = this.resolveAST(binaryExpression.left, false, context); - - var lhsType = lhsSymbol.type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (lhsType === this.semanticInfoChain.nullTypeSymbol || lhsType === this.semanticInfoChain.undefinedTypeSymbol) { - lhsType = rhsType; - } - - if (rhsType === this.semanticInfoChain.nullTypeSymbol || rhsType === this.semanticInfoChain.undefinedTypeSymbol) { - rhsType = lhsType; - } - - var lhsIsFit = this.isAnyOrNumberOrEnum(lhsType); - var rhsIsFit = this.isAnyOrNumberOrEnum(rhsType); - - if (!rhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.right, TypeScript.DiagnosticCode.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (!lhsIsFit) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type)); - } - - if (lhsIsFit && rhsIsFit) { - switch (binaryExpression.kind()) { - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - if (!this.isReference(binaryExpression.left, lhsSymbol)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, rhsType, lhsType, context); - } - } - }; - - PullTypeResolver.prototype.resolveTypeOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.stringTypeSymbol; - }; - - PullTypeResolver.prototype.resolveThrowStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveDeleteExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInstanceOfExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInstanceOfExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInstanceOfExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var enclosingSymbol = this.getEnclosingSymbolForAST(binaryExpression); - var isValidLHS = this.isAnyOrEquivalent(lhsType) || lhsType.isObject() || lhsType.isTypeParameter(); - 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_of_a_type_assignable_to_the_Function_interface_type)); - } - }; - - PullTypeResolver.prototype.resolveCommaExpression = function (commaExpression, context) { - if (this.canTypeCheckAST(commaExpression, context)) { - this.setTypeChecked(commaExpression, context); - - this.resolveAST(commaExpression.left, false, context); - } - - return this.resolveAST(commaExpression.right, false, context).type; - }; - - PullTypeResolver.prototype.resolveInExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckInExpression(ast, context); - } - - return this.semanticInfoChain.booleanTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckInExpression = function (binaryExpression, context) { - this.setTypeChecked(binaryExpression, context); - - var lhsType = this.resolveAST(binaryExpression.left, false, context).type; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - var isValidLHS = this.isAnyOrEquivalent(lhsType.type) || lhsType.type === this.semanticInfoChain.stringTypeSymbol || lhsType.type === this.semanticInfoChain.numberTypeSymbol; - - var isValidRHS = this.isAnyOrEquivalent(rhsType) || rhsType.isObject() || rhsType.isTypeParameter(); - - if (!isValidLHS) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number)); - } - - if (!isValidRHS) { - 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)); - } - }; - - PullTypeResolver.prototype.resolveForStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.variableDeclaration, false, context); - this.resolveAST(ast.initializer, false, context); - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.incrementor, false, context); - this.resolveAST(ast.statement, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveForInStatement = function (forInStatement, context) { - if (this.canTypeCheckAST(forInStatement, context)) { - this.typeCheckForInStatement(forInStatement, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckForInStatement = function (forInStatement, context) { - this.setTypeChecked(forInStatement, context); - - if (forInStatement.variableDeclaration) { - var declaration = forInStatement.variableDeclaration; - - 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); - - 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 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)); - } - - this.resolveAST(forInStatement.statement, false, context); - }; - - PullTypeResolver.prototype.resolveWhileStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWhileStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWhileStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveDoStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckDoStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckDoStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveIfStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckIfStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckIfStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.condition, false, context); - this.resolveAST(ast.statement, false, context); - this.resolveAST(ast.elseClause, false, context); - }; - - PullTypeResolver.prototype.resolveElseClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckElseClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckElseClause = function (ast, context) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.statement, false, context); - }; - - PullTypeResolver.prototype.resolveBlock = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.statements, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declaration, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveVariableDeclarationList = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.declarators, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveWithStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckWithStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckWithStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var withStatement = ast; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(withStatement.condition, TypeScript.DiagnosticCode.All_symbols_within_a_with_block_will_be_resolved_to_any)); - }; - - PullTypeResolver.prototype.resolveTryStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckTryStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckTryStatement = function (ast, context) { - this.setTypeChecked(ast, context); - var tryStatement = ast; - - this.resolveAST(tryStatement.block, false, context); - this.resolveAST(tryStatement.catchClause, false, context); - this.resolveAST(tryStatement.finallyClause, false, context); - }; - - PullTypeResolver.prototype.resolveCatchClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckCatchClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckCatchClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - - var catchDecl = this.semanticInfoChain.getDeclForAST(ast); - this.validateVariableDeclarationGroups(catchDecl, context); - }; - - PullTypeResolver.prototype.resolveFinallyClause = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckFinallyClause(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckFinallyClause = function (ast, context) { - this.setTypeChecked(ast, context); - this.resolveAST(ast.block, false, context); - }; - - PullTypeResolver.prototype.getEnclosingFunctionDeclaration = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - - while (enclosingDecl) { - if (enclosingDecl.kind & 1032192 /* SomeFunction */) { - return enclosingDecl; - } - - enclosingDecl = enclosingDecl.getParentDecl(); - } - - return null; - }; - - PullTypeResolver.prototype.resolveReturnExpression = function (expression, enclosingFunction, context) { - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var isContextuallyTyped = false; - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeAnnotationSymbol = this.resolveTypeReference(typeAnnotation, context); - if (returnTypeAnnotationSymbol) { - isContextuallyTyped = true; - context.pushNewContextualType(returnTypeAnnotationSymbol); - } - } else { - var currentContextualType = context.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - isContextuallyTyped = true; - context.propagateContextualType(currentContextualTypeReturnTypeSymbol); - } - } - } - } - - var result = this.resolveAST(expression, isContextuallyTyped, context).type; - if (isContextuallyTyped) { - context.popAnyContextualType(); - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckReturnExpression = function (expression, expressionType, enclosingFunction, context) { - if (enclosingFunction && enclosingFunction.kind === 32768 /* ConstructorMethod */) { - var classDecl = enclosingFunction.getParentDecl(); - if (classDecl) { - var classSymbol = classDecl.getSymbol(); - this.resolveDeclaredSymbol(classSymbol, context); - - var comparisonInfo = new TypeComparisonInfo(); - var isAssignable = this.sourceIsAssignableToTarget(expressionType, classSymbol.type, expression, context, comparisonInfo); - if (!isAssignable) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class)); - } - } - } - - if (enclosingFunction && enclosingFunction.kind === 524288 /* SetAccessor */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Setters_cannot_return_a_value)); - } - - if (enclosingFunction) { - var enclosingDeclAST = this.getASTForDecl(enclosingFunction); - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation || enclosingFunction.kind === 262144 /* GetAccessor */) { - var signatureSymbol = enclosingFunction.getSignatureSymbol(); - var sigReturnType = signatureSymbol.returnType; - - if (expressionType && sigReturnType) { - var comparisonInfo = new TypeComparisonInfo(); - var upperBound = null; - - this.resolveDeclaredSymbol(expressionType, context); - this.resolveDeclaredSymbol(sigReturnType, context); - - var isAssignable = this.sourceIsAssignableToTarget(expressionType, sigReturnType, expression, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [expressionType.toString(enclosingSymbol), sigReturnType.toString(enclosingSymbol)])); - } - } - } - } - } - }; - - PullTypeResolver.prototype.resolveReturnStatement = function (returnAST, context) { - var enclosingFunction = this.getEnclosingFunctionDeclaration(returnAST); - if (enclosingFunction) { - enclosingFunction.setFlag(4194304 /* HasReturnStatement */); - } - - var returnType = this.getSymbolForAST(returnAST, context); - var canTypeCheckAST = this.canTypeCheckAST(returnAST, context); - if (!returnType || canTypeCheckAST) { - var returnExpr = returnAST.expression; - - var resolvedReturnType = returnExpr === null ? this.semanticInfoChain.voidTypeSymbol : this.resolveReturnExpression(returnExpr, enclosingFunction, context); - - if (!returnType) { - returnType = resolvedReturnType; - this.setSymbolForAST(returnAST, resolvedReturnType, context); - } - - if (returnExpr && canTypeCheckAST) { - this.setTypeChecked(returnExpr, context); - this.typeCheckReturnExpression(returnExpr, resolvedReturnType, enclosingFunction, context); - } - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveSwitchStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSwitchStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckSwitchStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var expressionType = this.resolveAST(ast.expression, false, context).type; - - for (var i = 0, n = ast.switchClauses.childCount(); i < n; i++) { - var switchClause = ast.switchClauses.childAt(i); - if (switchClause.kind() === 233 /* CaseSwitchClause */) { - var caseSwitchClause = switchClause; - - var caseClauseExpressionType = this.resolveAST(caseSwitchClause.expression, false, context).type; - this.resolveAST(caseSwitchClause.statements, false, context); - - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(expressionType, caseClauseExpressionType, caseSwitchClause.expression, context, comparisonInfo) && !this.sourceIsAssignableToTarget(caseClauseExpressionType, expressionType, caseSwitchClause.expression, context, comparisonInfo)) { - var enclosingSymbol = this.getEnclosingSymbolForAST(caseSwitchClause.expression); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(caseSwitchClause.expression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [caseClauseExpressionType.toString(enclosingSymbol), expressionType.toString(enclosingSymbol)])); - } - } - } else { - var defaultSwitchClause = switchClause; - this.resolveAST(defaultSwitchClause.statements, false, context); - } - } - }; - - PullTypeResolver.prototype.resolveLabeledStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckLabeledStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckLabeledStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - var labelIdentifier = ast.identifier.valueText(); - - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - 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); - }; - - PullTypeResolver.prototype.labelIsOnContinuableConstruct = function (statement) { - switch (statement.kind()) { - case 160 /* LabeledStatement */: - return this.labelIsOnContinuableConstruct(statement.statement); - - case 158 /* WhileStatement */: - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 161 /* DoStatement */: - return true; - - default: - return false; - } - }; - - PullTypeResolver.prototype.resolveContinueStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckContinueStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.isIterationStatement = function (ast) { - switch (ast.kind()) { - case 154 /* ForStatement */: - case 155 /* ForInStatement */: - case 158 /* WhileStatement */: - case 161 /* DoStatement */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.isAnyFunctionExpressionOrDeclaration = function (ast) { - switch (ast.kind()) { - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - case 129 /* FunctionDeclaration */: - case 135 /* MemberFunctionDeclaration */: - case 241 /* FunctionPropertyAssignment */: - case 137 /* ConstructorDeclaration */: - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return true; - } - - return false; - }; - - PullTypeResolver.prototype.inSwitchStatement = function (ast) { - while (ast) { - if (ast.kind() === 151 /* SwitchStatement */) { - return true; - } - - if (this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inIterationStatement = function (ast, crossFunctions) { - while (ast) { - if (this.isIterationStatement(ast)) { - return true; - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingLabels = function (ast, breakable, crossFunctions) { - var result = []; - - ast = ast.parent; - while (ast) { - if (ast.kind() === 160 /* LabeledStatement */) { - var labeledStatement = ast; - if (breakable) { - result.push(labeledStatement); - } else { - if (this.labelIsOnContinuableConstruct(labeledStatement.statement)) { - result.push(labeledStatement); - } - } - } - - if (!crossFunctions && this.isAnyFunctionExpressionOrDeclaration(ast)) { - break; - } - - ast = ast.parent; - } - - return result; - }; - - PullTypeResolver.prototype.typeCheckContinueStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - 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.any(continuableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var continuableLabels = this.getEnclosingLabels(ast, false, true); - - 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)); - } - } - } - }; - - PullTypeResolver.prototype.resolveBreakStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckBreakStatement(ast, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.typeCheckBreakStatement = function (ast, context) { - this.setTypeChecked(ast, context); - - if (ast.identifier) { - var breakableLabels = this.getEnclosingLabels(ast, true, false); - - if (!TypeScript.ArrayUtilities.any(breakableLabels, function (s) { - return s.identifier.valueText() === ast.identifier.valueText(); - })) { - var breakableLabels = this.getEnclosingLabels(ast, true, true); - 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, 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)); - } - } - }; - - PullTypeResolver.prototype.resolveAST = function (ast, isContextuallyTyped, context) { - if (!ast) { - return; - } - - var symbol = this.getSymbolForAST(ast, context); - if (symbol && symbol.isResolved) { - this.typeCheckAST(ast, isContextuallyTyped, context); - return symbol; - } - - if (ast.isExpression() && !isTypesOnlyLocation(ast)) { - return this.resolveExpressionAST(ast, isContextuallyTyped, context); - } - - var nodeType = ast.kind(); - - switch (nodeType) { - case 124 /* ArrayType */: - case 126 /* GenericType */: - case 122 /* ObjectType */: - case 127 /* TypeQuery */: - case 125 /* ConstructorType */: - case 123 /* FunctionType */: - return this.resolveTypeReference(ast, context); - - case 1 /* List */: - return this.resolveList(ast, context); - - case 2 /* SeparatedList */: - return this.resolveSeparatedList(ast, context); - - case 120 /* SourceUnit */: - return this.resolveSourceUnit(ast, context); - - case 132 /* EnumDeclaration */: - return this.resolveEnumDeclaration(ast, context); - - case 130 /* ModuleDeclaration */: - return this.resolveModuleDeclaration(ast, context); - - case 128 /* InterfaceDeclaration */: - return this.resolveInterfaceDeclaration(ast, context); - - case 131 /* ClassDeclaration */: - return this.resolveClassDeclaration(ast, context); - - case 224 /* VariableDeclaration */: - return this.resolveVariableDeclarationList(ast, context); - - case 136 /* MemberVariableDeclaration */: - return this.resolveMemberVariableDeclaration(ast, context); - - case 225 /* VariableDeclarator */: - return this.resolveVariableDeclarator(ast, context); - - case 141 /* PropertySignature */: - return this.resolvePropertySignature(ast, context); - - case 227 /* ParameterList */: - return this.resolveParameterList(ast, context); - - case 242 /* Parameter */: - return this.resolveParameter(ast, context); - - case 243 /* EnumElement */: - return this.resolveEnumElement(ast, context); - - case 232 /* EqualsValueClause */: - return this.resolveEqualsValueClause(ast, isContextuallyTyped, context); - - case 238 /* TypeParameter */: - return this.resolveTypeParameterDeclaration(ast, context); - - case 239 /* Constraint */: - return this.resolveConstraint(ast, context); - - case 133 /* ImportDeclaration */: - return this.resolveImportDeclaration(ast, context); - - case 240 /* SimplePropertyAssignment */: - return this.resolveSimplePropertyAssignment(ast, isContextuallyTyped, context); - - case 241 /* FunctionPropertyAssignment */: - return this.resolveFunctionPropertyAssignment(ast, isContextuallyTyped, context); - - case 11 /* IdentifierName */: - TypeScript.Debug.assert(isTypesOnlyLocation(ast)); - return this.resolveTypeNameExpression(ast, context); - - case 121 /* QualifiedName */: - return this.resolveQualifiedName(ast, context); - - case 137 /* ConstructorDeclaration */: - return this.resolveConstructorDeclaration(ast, context); - - case 139 /* GetAccessor */: - case 140 /* SetAccessor */: - return this.resolveAccessorDeclaration(ast, context); - - case 138 /* IndexMemberDeclaration */: - return this.resolveIndexMemberDeclaration(ast, context); - - case 144 /* IndexSignature */: - return this.resolveIndexSignature(ast, context); - - case 135 /* MemberFunctionDeclaration */: - return this.resolveMemberFunctionDeclaration(ast, context); - - case 142 /* CallSignature */: - return this.resolveCallSignature(ast, context); - - case 143 /* ConstructSignature */: - return this.resolveConstructSignature(ast, context); - - case 145 /* MethodSignature */: - return this.resolveMethodSignature(ast, context); - - 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); - - case 219 /* SimpleArrowFunctionExpression */: - return this.resolveSimpleArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 218 /* ParenthesizedArrowFunctionExpression */: - return this.resolveParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - - case 214 /* ArrayLiteralExpression */: - return this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - - case 35 /* ThisKeyword */: - return this.resolveThisExpression(ast, context); - - case 50 /* SuperKeyword */: - return this.resolveSuperExpression(ast, context); - - case 213 /* InvocationExpression */: - return this.resolveInvocationExpression(ast, context); - - case 216 /* ObjectCreationExpression */: - return this.resolveObjectCreationExpression(ast, context); - - case 220 /* CastExpression */: - return this.resolveCastExpression(ast, context); - - case 13 /* NumericLiteral */: - return this.semanticInfoChain.numberTypeSymbol; - - case 14 /* StringLiteral */: - return this.semanticInfoChain.stringTypeSymbol; - - case 32 /* NullKeyword */: - return this.semanticInfoChain.nullTypeSymbol; - - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - return this.semanticInfoChain.booleanTypeSymbol; - - case 172 /* VoidExpression */: - return this.resolveVoidExpression(ast, context); - - case 174 /* AssignmentExpression */: - return this.resolveAssignmentExpression(ast, context); - - case 167 /* LogicalNotExpression */: - return this.resolveLogicalNotExpression(ast, context); - - case 193 /* NotEqualsWithTypeConversionExpression */: - case 192 /* EqualsWithTypeConversionExpression */: - case 194 /* EqualsExpression */: - case 195 /* NotEqualsExpression */: - case 196 /* LessThanExpression */: - case 198 /* LessThanOrEqualExpression */: - case 199 /* GreaterThanOrEqualExpression */: - case 197 /* GreaterThanExpression */: - return this.resolveLogicalOperation(ast, context); - - case 208 /* AddExpression */: - case 175 /* AddAssignmentExpression */: - return this.resolveBinaryAdditionOperation(ast, context); - - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - case 166 /* BitwiseNotExpression */: - case 168 /* PreIncrementExpression */: - case 169 /* PreDecrementExpression */: - return this.resolveUnaryArithmeticOperation(ast, context); - - case 210 /* PostIncrementExpression */: - case 211 /* PostDecrementExpression */: - return this.resolvePostfixUnaryExpression(ast, context); - - case 209 /* SubtractExpression */: - case 205 /* MultiplyExpression */: - case 206 /* DivideExpression */: - case 207 /* ModuloExpression */: - case 189 /* BitwiseOrExpression */: - case 191 /* BitwiseAndExpression */: - case 202 /* LeftShiftExpression */: - case 203 /* SignedRightShiftExpression */: - case 204 /* UnsignedRightShiftExpression */: - case 190 /* BitwiseExclusiveOrExpression */: - case 181 /* ExclusiveOrAssignmentExpression */: - case 183 /* LeftShiftAssignmentExpression */: - case 184 /* SignedRightShiftAssignmentExpression */: - case 185 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* SubtractAssignmentExpression */: - case 177 /* MultiplyAssignmentExpression */: - case 178 /* DivideAssignmentExpression */: - case 179 /* ModuloAssignmentExpression */: - case 182 /* OrAssignmentExpression */: - case 180 /* AndAssignmentExpression */: - return this.resolveBinaryArithmeticExpression(ast, context); - - case 221 /* ElementAccessExpression */: - return this.resolveElementAccessExpression(ast, context); - - case 187 /* LogicalOrExpression */: - return this.resolveLogicalOrExpression(ast, isContextuallyTyped, context); - - case 188 /* LogicalAndExpression */: - return this.resolveLogicalAndExpression(ast, context); - - case 171 /* TypeOfExpression */: - return this.resolveTypeOfExpression(ast, context); - - case 170 /* DeleteExpression */: - return this.resolveDeleteExpression(ast, context); - - case 186 /* ConditionalExpression */: - return this.resolveConditionalExpression(ast, isContextuallyTyped, context); - - case 12 /* RegularExpressionLiteral */: - return this.resolveRegularExpressionLiteral(); - - case 217 /* ParenthesizedExpression */: - return this.resolveParenthesizedExpression(ast, context); - - case 200 /* InstanceOfExpression */: - return this.resolveInstanceOfExpression(ast, context); - - case 173 /* CommaExpression */: - return this.resolveCommaExpression(ast, context); - - case 201 /* InExpression */: - return this.resolveInExpression(ast, context); - - case 223 /* OmittedExpression */: - return this.semanticInfoChain.undefinedTypeSymbol; - } - - TypeScript.Debug.fail("resolveExpressionASTWorker: Missing expression kind: " + TypeScript.SyntaxKind[ast.kind()]); - }; - - PullTypeResolver.prototype.typeCheckAST = function (ast, isContextuallyTyped, context) { - if (!this.canTypeCheckAST(ast, context)) { - return; - } - - var nodeType = ast.kind(); - switch (nodeType) { - case 120 /* SourceUnit */: - this.typeCheckSourceUnit(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.typeCheckEnumDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.typeCheckModuleDeclaration(ast, context); - return; - - case 128 /* InterfaceDeclaration */: - this.typeCheckInterfaceDeclaration(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.typeCheckClassDeclaration(ast, context); - return; - - case 243 /* EnumElement */: - this.typeCheckEnumElement(ast, context); - return; - - case 136 /* MemberVariableDeclaration */: - this.typeCheckMemberVariableDeclaration(ast, context); - return; - - case 225 /* VariableDeclarator */: - this.typeCheckVariableDeclarator(ast, context); - return; - - case 141 /* PropertySignature */: - this.typeCheckPropertySignature(ast, context); - return; - - case 242 /* Parameter */: - this.typeCheckParameter(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.typeCheckImportDeclaration(ast, context); - return; - - case 215 /* ObjectLiteralExpression */: - this.resolveObjectLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 241 /* FunctionPropertyAssignment */: - this.typeCheckFunctionPropertyAssignment(ast, isContextuallyTyped, context); - return; - - case 11 /* IdentifierName */: - if (isTypesOnlyLocation(ast)) { - this.resolveTypeNameExpression(ast, context); - } else { - this.resolveNameExpression(ast, context); - } - return; - - case 212 /* MemberAccessExpression */: - this.resolveMemberAccessExpression(ast, context); - return; - - case 121 /* QualifiedName */: - this.resolveQualifiedName(ast, context); - return; - - case 222 /* FunctionExpression */: - 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); - break; - - case 142 /* CallSignature */: - this.typeCheckCallSignature(ast, context); - return; - - case 143 /* ConstructSignature */: - this.typeCheckConstructSignature(ast, context); - return; - - case 129 /* FunctionDeclaration */: { - var funcDecl = ast; - 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, isContextuallyTyped, context); - return; - - case 218 /* ParenthesizedArrowFunctionExpression */: - this.typeCheckParenthesizedArrowFunctionExpression(ast, isContextuallyTyped, context); - return; - - case 214 /* ArrayLiteralExpression */: - this.resolveArrayLiteralExpression(ast, isContextuallyTyped, context); - return; - - case 213 /* InvocationExpression */: - this.typeCheckInvocationExpression(ast, context); - return; - - case 216 /* ObjectCreationExpression */: - this.typeCheckObjectCreationExpression(ast, context); - return; - - case 150 /* ReturnStatement */: - this.resolveReturnStatement(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Failure nodeType: " + TypeScript.SyntaxKind[ast.kind()] + ". Implement typeCheck when symbol is set for the ast as part of resolution."); - } - }; - - PullTypeResolver.prototype.processPostTypeCheckWorkItems = function (context) { - while (this.postTypeCheckWorkitems.length) { - var ast = this.postTypeCheckWorkitems.pop(); - this.postTypeCheck(ast, context); - } - }; - - PullTypeResolver.prototype.postTypeCheck = function (ast, context) { - var nodeType = ast.kind(); - - switch (nodeType) { - case 242 /* Parameter */: - case 225 /* VariableDeclarator */: - this.postTypeCheckVariableDeclaratorOrParameter(ast, context); - return; - - case 131 /* ClassDeclaration */: - this.postTypeCheckClassDeclaration(ast, context); - return; - - case 129 /* FunctionDeclaration */: - this.postTypeCheckFunctionDeclaration(ast, context); - return; - - case 130 /* ModuleDeclaration */: - this.postTypeCheckModuleDeclaration(ast, context); - return; - - case 132 /* EnumDeclaration */: - this.postTypeCheckEnumDeclaration(ast, context); - return; - - case 133 /* ImportDeclaration */: - this.postTypeCheckImportDeclaration(ast, context); - return; - - case 11 /* IdentifierName */: - this.postTypeCheckNameExpression(ast, context); - return; - - default: - TypeScript.Debug.assert(false, "Implement postTypeCheck clause to handle the postTypeCheck work, nodeType: " + TypeScript.SyntaxKind[ast.kind()]); - } - }; - - PullTypeResolver.prototype.resolveRegularExpressionLiteral = function () { - if (this.cachedRegExpInterfaceType()) { - return this.cachedRegExpInterfaceType(); - } else { - return this.semanticInfoChain.anyTypeSymbol; - } - }; - - PullTypeResolver.prototype.postTypeCheckNameExpression = function (nameAST, context) { - this.checkThisCaptureVariableCollides(nameAST, false, context); - }; - - PullTypeResolver.prototype.typeCheckNameExpression = function (nameAST, context) { - this.setTypeChecked(nameAST, context); - this.checkNameForCompilerGeneratedDeclarationCollision(nameAST, false, nameAST, context); - }; - - PullTypeResolver.prototype.resolveNameExpression = function (nameAST, context) { - var nameSymbol = this.getSymbolForAST(nameAST, context); - var foundCached = nameSymbol !== null; - - if (!foundCached || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.typeCheckNameExpression(nameAST, context); - } - nameSymbol = this.computeNameExpression(nameAST, context); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - if (nameSymbol && (nameSymbol.type !== this.semanticInfoChain.anyTypeSymbol || nameSymbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(nameAST, nameSymbol, context); - } - - return nameSymbol; - }; - - 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.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; - } - - var nameSymbol = null; - var enclosingDecl = this.getEnclosingDeclForAST(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 searchKind = 68147712 /* SomeValue */; - - if (!this.isInEnumDecl(enclosingDecl)) { - searchKind = searchKind & ~(67108864 /* EnumMember */); - } - - var nameSymbol = this.getSymbolFromDeclPath(id, declPath, searchKind); - } - - 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) { - 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]; - var nameParentDecl = nameDeclaration.getParentDecl(); - if (nameParentDecl && (nameParentDecl.kind & 1032192 /* SomeFunction */) && (nameParentDecl.flags & 33554432 /* HasDefaultArgs */)) { - var enclosingFunctionAST = this.semanticInfoChain.getASTForDecl(nameParentDecl); - var currentParameterIndex = this.getCurrentParameterIndexForFunction(nameAST, enclosingFunctionAST); - - var parameterList = TypeScript.ASTHelpers.getParameterList(enclosingFunctionAST); - - if (currentParameterIndex >= 0) { - var matchingParameter; - if (parameterList) { - for (var i = 0; i <= currentParameterIndex; i++) { - var candidateParameter = parameterList.parameters.nonSeparatorAt(i); - if (candidateParameter && candidateParameter.identifier.valueText() === id) { - matchingParameter = candidateParameter; - break; - } - } - } - - 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); - } - } - } - - var aliasSymbol = null; - - if (nameSymbol.isType() && nameSymbol.isAlias()) { - aliasSymbol = nameSymbol; - if (!this.inTypeQuery(nameAST)) { - aliasSymbol.setIsUsedAsValue(); - } - - this.resolveDeclaredSymbol(nameSymbol, context); - - this.resolveDeclaredSymbol(aliasSymbol.assignedValue(), context); - this.resolveDeclaredSymbol(aliasSymbol.assignedContainer(), context); - - var exportAssignmentSymbol = nameSymbol.getExportAssignedValueSymbol(); - - if (exportAssignmentSymbol) { - nameSymbol = exportAssignmentSymbol; - } else { - aliasSymbol = null; - } - } - - if (aliasSymbol) { - this.semanticInfoChain.setAliasSymbolForAST(nameAST, aliasSymbol); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.getCurrentParameterIndexForFunction = function (parameter, funcDecl) { - var parameterList = TypeScript.ASTHelpers.getParameterList(funcDecl); - if (parameterList) { - while (parameter && parameter.parent) { - if (parameter.parent.parent === parameterList) { - return parameterList.parameters.nonSeparatorIndexOf(parameter); - } - - parameter = parameter.parent; - } - } - - return -1; - }; - - PullTypeResolver.prototype.resolveMemberAccessExpression = function (dottedNameAST, context) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.expression, dottedNameAST.name, context); - }; - - PullTypeResolver.prototype.resolveDottedNameExpression = function (dottedNameAST, expression, name, context) { - var symbol = this.getSymbolForAST(dottedNameAST, context); - var foundCached = symbol !== null; - - if (!foundCached || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheckDottedNameAST = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheckDottedNameAST) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeDottedNameExpression(expression, name, context, canTypeCheckDottedNameAST); - } - - this.resolveDeclaredSymbol(symbol, context); - - if (symbol && (symbol.type !== this.semanticInfoChain.anyTypeSymbol || symbol.anyDeclHasFlag(16777216 /* IsAnnotatedWithAny */ | 1 /* Exported */))) { - this.setSymbolForAST(dottedNameAST, symbol, context); - this.setSymbolForAST(name, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeDottedNameExpression = function (expression, name, context, checkSuperPrivateAndStaticAccess) { - var rhsName = name.valueText(); - if (rhsName.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - 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)) { - lhsAlias.setIsUsedAsValue(); - } - lhsType = lhsAlias.getExportAssignedTypeSymbol(); - } - - if (lhsType.isAlias()) { - lhsType = lhsType.getExportAssignedTypeSymbol(); - } - - if (!lhsType) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Could_not_find_enclosing_symbol_for_dotted_name_0, [name.text()])); - return this.getNewErrorTypeSymbol(); - } - - if (!lhsType.isResolved) { - var potentiallySpecializedType = this.resolveDeclaredSymbol(lhsType, context); - - if (potentiallySpecializedType !== lhsType) { - if (!lhs.isType()) { - context.setTypeInContext(lhs, potentiallySpecializedType); - } - - lhsType = potentiallySpecializedType; - } - } - - if (lhsType.isContainer() && !lhsType.isAlias() && !lhsType.isEnum()) { - var instanceSymbol = lhsType.getInstanceSymbol(); - - if (instanceSymbol) { - lhsType = instanceSymbol.type; - } - } - - var originalLhsTypeForErrorReporting = lhsType; - - lhsType = this.getApparentType(lhsType).widenedType(this, expression, context); - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var nameSymbol = this._getNamedPropertySymbolOfAugmentedType(rhsName, lhsType); - - if (!nameSymbol) { - if (lhsType.kind === 32 /* DynamicModule */) { - var container = lhsType; - var associatedInstance = container.getInstanceSymbol(); - - if (associatedInstance) { - var instanceType = associatedInstance.type; - - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, instanceType); - } - } else { - var associatedType = lhsType.getAssociatedContainerType(); - - if (associatedType && !associatedType.isClass()) { - nameSymbol = this.getNamedPropertySymbol(rhsName, 68147712 /* SomeValue */, associatedType); - } - } - - 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(), originalLhsTypeForErrorReporting.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - } - - if (checkSuperPrivateAndStaticAccess) { - this.checkForSuperMemberAccess(expression, name, nameSymbol, context) || this.checkForPrivateMemberAccess(name, lhsType, nameSymbol, context); - } - - return nameSymbol; - }; - - PullTypeResolver.prototype.resolveTypeNameExpression = function (nameAST, context) { - var typeNameSymbol = this.getSymbolForAST(nameAST, context); - - if (!typeNameSymbol || !typeNameSymbol.isType() || this.canTypeCheckAST(nameAST, context)) { - if (this.canTypeCheckAST(nameAST, context)) { - this.setTypeChecked(nameAST, context); - } - typeNameSymbol = this.computeTypeNameExpression(nameAST, context); - this.setSymbolForAST(nameAST, typeNameSymbol, context); - } - - this.resolveDeclaredSymbol(typeNameSymbol, context); - - return typeNameSymbol; - }; - - PullTypeResolver.prototype.computeTypeNameExpression = function (nameAST, context) { - var id = nameAST.valueText(); - if (id.length === 0) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(nameAST); - - var declPath = enclosingDecl.getParentPath(); - - var onLeftOfDot = this.isLeftSideOfQualifiedName(nameAST); - - var kindToCheckFirst = onLeftOfDot ? 164 /* SomeContainer */ : 58728795 /* SomeType */; - var kindToCheckSecond = onLeftOfDot ? 58728795 /* SomeType */ : 164 /* SomeContainer */; - - var typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckFirst); - - if (!typeNameSymbol) { - typeNameSymbol = this.getSymbolFromDeclPath(id, declPath, kindToCheckSecond); - } - - if (!typeNameSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Could_not_find_symbol_0, [nameAST.text()])); - return this.getNewErrorTypeSymbol(id); - } - - var typeNameSymbolAlias = null; - if (typeNameSymbol.isAlias()) { - typeNameSymbolAlias = typeNameSymbol; - this.resolveDeclaredSymbol(typeNameSymbol, context); - - var aliasedType = typeNameSymbolAlias.getExportAssignedTypeSymbol(); - - this.resolveDeclaredSymbol(aliasedType, context); - } - - if (typeNameSymbol.isTypeParameter()) { - if (this.isInStaticMemberContext(enclosingDecl)) { - var parentDecl = typeNameSymbol.getDeclarations()[0].getParentDecl(); - - if (parentDecl.kind === 8 /* Class */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(nameAST, TypeScript.DiagnosticCode.Static_members_cannot_reference_class_type_parameters)); - return this.getNewErrorTypeSymbol(); - } - } - } - - if (!typeNameSymbol.isGeneric() && (typeNameSymbol.isClass() || typeNameSymbol.isInterface())) { - typeNameSymbol = TypeScript.PullTypeReferenceSymbol.createTypeReference(typeNameSymbol); - } - - 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; - }; - - PullTypeResolver.prototype.resolveGenericTypeReference = function (genericTypeAST, context) { - var genericTypeSymbol = this.resolveAST(genericTypeAST.name, false, context).type; - - if (genericTypeSymbol.isError()) { - return genericTypeSymbol; - } - - if (!genericTypeSymbol.inResolution && !genericTypeSymbol.isResolved) { - this.resolveDeclaredSymbol(genericTypeSymbol, context); - } - - 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()) { - for (var i = 0; i < genericTypeAST.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - typeArgs[i] = this.resolveTypeReference(genericTypeAST.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - - if (typeArgs[i].isError()) { - typeArgs[i] = this.semanticInfoChain.anyTypeSymbol; - } - } - } - - 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(); - } - - if (!genericTypeSymbol.isResolved) { - var typeDecls = genericTypeSymbol.getDeclarations(); - var childDecls = null; - - for (var i = 0; i < typeDecls.length; i++) { - childDecls = typeDecls[i].getChildDecls(); - - for (var j = 0; j < childDecls.length; j++) { - childDecls[j].ensureSymbolIsBound(); - } - } - } - - var specializedSymbol = this.createInstantiatedType(genericTypeSymbol, typeArgs); - - var typeConstraint = null; - var upperBound = null; - - typeParameters = specializedSymbol.getTypeParameters(); - - var typeConstraintSubstitutionMap = []; - var typeArg = null; - - var instantiatedSubstitutionMap = specializedSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < typeParameters.length; i++) { - typeConstraintSubstitutionMap[typeParameters[i].pullSymbolID] = typeParameters[i]; - } - - for (var id in instantiatedSubstitutionMap) { - typeConstraintSubstitutionMap[id] = instantiatedSubstitutionMap[id]; - } - - for (var iArg = 0; (iArg < typeArgs.length) && (iArg < typeParameters.length); iArg++) { - typeArg = typeArgs[iArg]; - typeConstraint = typeParameters[iArg].getConstraint(); - - typeConstraintSubstitutionMap[typeParameters[iArg].pullSymbolID] = typeArg; - - if (typeConstraint) { - if (typeConstraint.isTypeParameter()) { - for (var j = 0; j < typeParameters.length && j < typeArgs.length; j++) { - if (typeParameters[j] === typeConstraint) { - typeConstraint = typeArgs[j]; - } - } - } else if (typeConstraint.isGeneric()) { - typeConstraint = this.instantiateType(typeConstraint, typeConstraintSubstitutionMap); - } - - if (typeArg.isTypeParameter()) { - upperBound = typeArg.getConstraint(); - - if (upperBound) { - typeArg = upperBound; - } - } - - 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)])); - } - } - } - - return specializedSymbol; - }; - - PullTypeResolver.prototype.resolveQualifiedName = function (dottedNameAST, context) { - if (this.inTypeQuery(dottedNameAST)) { - return this.resolveDottedNameExpression(dottedNameAST, dottedNameAST.left, dottedNameAST.right, context).type; - } - - var symbol = this.getSymbolForAST(dottedNameAST, context); - if (!symbol || this.canTypeCheckAST(dottedNameAST, context)) { - var canTypeCheck = this.canTypeCheckAST(dottedNameAST, context); - if (canTypeCheck) { - this.setTypeChecked(dottedNameAST, context); - } - - symbol = this.computeQualifiedName(dottedNameAST, context); - this.setSymbolForAST(dottedNameAST, symbol, context); - } - - this.resolveDeclaredSymbol(symbol, context); - - 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) { - return this.semanticInfoChain.anyTypeSymbol; - } - - var enclosingDecl = this.getEnclosingDeclForAST(dottedNameAST); - var lhs = this.resolveAST(dottedNameAST.left, false, context); - - var lhsType = lhs.isAlias() ? lhs.getExportAssignedContainerSymbol() : lhs.type; - - if (this.inClassExtendsHeritageClause(dottedNameAST) && !this.inTypeArgumentList(dottedNameAST)) { - if (lhs.isAlias()) { - lhs.setIsUsedAsValue(); - } - } - - if (!lhsType) { - return this.getNewErrorTypeSymbol(); - } - - if (this.isAnyOrEquivalent(lhsType)) { - return lhsType; - } - - var onLeftOfDot = this.isLeftSideOfQualifiedName(dottedNameAST); - var isNameOfModule = dottedNameAST.parent.kind() === 130 /* ModuleDeclaration */ && dottedNameAST.parent.name === dottedNameAST; - - 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.getNamedPropertySymbol(rhsName, memberKind, exportedContainer); - } - } - - if (!childTypeSymbol && enclosingDecl) { - var parentDecl = enclosingDecl; - - while (parentDecl) { - if (parentDecl.kind & 164 /* SomeContainer */) { - break; - } - - parentDecl = parentDecl.getParentDecl(); - } - - if (parentDecl) { - var enclosingSymbolType = parentDecl.getSymbol().type; - - if (enclosingSymbolType === lhsType) { - childTypeSymbol = this.getNamedPropertySymbol(rhsName, memberKind, lhsType); - } - } - } - - if (!childTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(dottedNameAST.right, TypeScript.DiagnosticCode.The_property_0_does_not_exist_on_value_of_type_1, [dottedNameAST.right.text(), lhsType.toString(enclosingDecl ? enclosingDecl.getSymbol() : null)])); - return this.getNewErrorTypeSymbol(rhsName); - } - - return childTypeSymbol; - }; - - PullTypeResolver.prototype.shouldContextuallyTypeAnyFunctionExpression = function (functionExpressionAST, typeParameters, parameters, returnTypeAnnotation, context) { - if (typeParameters && typeParameters.typeParameters.nonSeparatorCount() > 0) { - return false; - } - - if (returnTypeAnnotation) { - return false; - } - - if (parameters) { - for (var i = 0, n = parameters.length; i < n; i++) { - if (parameters.typeAt(i)) { - return false; - } - } - } - - var contextualFunctionTypeSymbol = context.getContextualType(); - - if (contextualFunctionTypeSymbol) { - this.resolveDeclaredSymbol(contextualFunctionTypeSymbol, context); - var callSignatures = contextualFunctionTypeSymbol.getCallSignatures(); - var exactlyOneCallSignature = callSignatures && callSignatures.length === 1; - if (!exactlyOneCallSignature) { - return false; - } - - var callSignatureIsGeneric = callSignatures[0].getTypeParameters().length > 0; - return !callSignatureIsGeneric; - } - - return false; - }; - - PullTypeResolver.prototype.resolveAnyFunctionExpression = function (funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context) { - var funcDeclSymbol = null; - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - TypeScript.Debug.assert(functionDecl); - - if (functionDecl && functionDecl.hasSymbol()) { - funcDeclSymbol = functionDecl.getSymbol(); - if (funcDeclSymbol.isResolved || funcDeclSymbol.inResolution) { - return funcDeclSymbol; - } - } - - funcDeclSymbol = functionDecl.getSymbol(); - TypeScript.Debug.assert(funcDeclSymbol); - - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - funcDeclSymbol.startResolving(); - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - var assigningFunctionSignature = null; - if (isContextuallyTyped && this.shouldContextuallyTypeAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, context)) { - assigningFunctionSignature = context.getContextualType().getCallSignatures()[0]; - } - - this.resolveAnyFunctionExpressionParameters(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, isContextuallyTyped, context); - - if (returnTypeAnnotation) { - signature.returnType = this.resolveTypeReference(returnTypeAnnotation, context); - } else { - if (assigningFunctionSignature) { - var returnType = assigningFunctionSignature.returnType; - - if (returnType) { - context.propagateContextualType(returnType); - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, true, functionDecl, context); - context.popAnyContextualType(); - } else { - signature.returnType = this.semanticInfoChain.anyTypeSymbol; - - if (this.compilationSettings.noImplicitAny()) { - var functionExpressionName = functionDecl.getFunctionExpressionName(); - - if (functionExpressionName != "") { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode._0_which_lacks_return_type_annotation_implicitly_has_an_any_return_type, [functionExpressionName])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_any_return_type)); - } - } - } - } else { - this.resolveFunctionBodyReturnTypes(funcDeclAST, block, bodyExpression, signature, false, functionDecl, context); - } - } - - context.setTypeInContext(funcDeclSymbol, funcDeclType); - funcDeclSymbol.setResolved(); - - if (this.canTypeCheckAST(funcDeclAST, context)) { - this.typeCheckAnyFunctionExpression(funcDeclAST, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, isContextuallyTyped, context); - } - - return funcDeclSymbol; - }; - - 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.typeCheckSimpleArrowFunctionExpression = function (arrowFunction, isContextuallyTyped, context) { - return this.typeCheckAnyFunctionExpression(arrowFunction, null, TypeScript.ASTHelpers.parametersFromIdentifier(arrowFunction.identifier), null, arrowFunction.block, arrowFunction.expression, isContextuallyTyped, 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); - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - - var funcDeclSymbol = functionDecl.getSymbol(); - var funcDeclType = funcDeclSymbol.type; - var signature = funcDeclType.getCallSignatures()[0]; - var returnTypeSymbol = signature.returnType; - - if (typeParameters) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - this.resolveTypeParameterDeclaration(typeParameters.typeParameters.nonSeparatorAt(i), context); - } - } - - 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.popAnyContextualType(); - - this.checkThatNonVoidFunctionHasReturnExpressionOrThrowStatement(functionDecl, returnTypeAnnotation, returnTypeSymbol, block, context); - - this.validateVariableDeclarationGroups(functionDecl, context); - - this.typeCheckCallBacks.push(function (context) { - _this.typeCheckFunctionOverloads(funcDeclAST, context); - }); - }; - - PullTypeResolver.prototype.resolveThisExpression = function (thisExpression, context) { - var enclosingDecl = this.getEnclosingDeclForAST(thisExpression); - var thisTypeSymbol = this.getContextualClassSymbolForEnclosingDecl(thisExpression, enclosingDecl) || this.semanticInfoChain.anyTypeSymbol; - - if (this.canTypeCheckAST(thisExpression, context)) { - this.typeCheckThisExpression(thisExpression, context, enclosingDecl); - } - - return thisTypeSymbol; - }; - - PullTypeResolver.prototype.inTypeArgumentList = function (ast) { - var previous = null; - var current = ast; - - while (current) { - switch (current.kind()) { - case 126 /* GenericType */: - var genericType = current; - if (genericType.typeArgumentList === previous) { - return true; - } - break; - - case 226 /* ArgumentList */: - var argumentList = current; - return argumentList.typeArgumentList === previous; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inClassExtendsHeritageClause = function (ast) { - while (ast) { - switch (ast.kind()) { - case 230 /* ExtendsHeritageClause */: - var heritageClause = ast; - - return heritageClause.parent.parent.kind() === 131 /* ClassDeclaration */; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inTypeQuery = function (ast) { - while (ast) { - switch (ast.kind()) { - case 127 /* TypeQuery */: - return true; - case 129 /* FunctionDeclaration */: - case 213 /* InvocationExpression */: - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inArgumentListOfSuperInvocation = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 213 /* InvocationExpression */: - var invocationExpression = current; - if (previous === invocationExpression.argumentList && invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - break; - - case 137 /* ConstructorDeclaration */: - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - return false; - }; - - PullTypeResolver.prototype.inConstructorParameterList = function (ast) { - var previous = null; - var current = ast; - while (current) { - switch (current.kind()) { - case 142 /* CallSignature */: - var callSignature = current; - if (previous === callSignature.parameterList && callSignature.parent.kind() === 137 /* ConstructorDeclaration */) { - return true; - } - - case 131 /* ClassDeclaration */: - case 130 /* ModuleDeclaration */: - return false; - } - - previous = current; - current = current.parent; - } - - 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 */) { - return true; - } else if (decl.kind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(decl.flags, 8192 /* ArrowFunction */)) { - return true; - } - - return false; - }; - - PullTypeResolver.prototype.typeCheckThisExpression = function (thisExpression, context, enclosingDecl) { - this.checkForThisCaptureInArrowFunction(thisExpression); - - if (this.inConstructorParameterList(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_constructor_arguments)); - return; - } - - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionAccessorOrNonArrowFunctionExpression(currentDecl)) { - return; - } else if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - if (currentDecl.getParentDecl() === null) { - return; - } else { - 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)); - } - - return; - } else if (currentDecl.kind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(thisExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(thisExpression, TypeScript.DiagnosticCode.this_cannot_be_referenced_in_static_initializers_in_a_class_body)); - } - - return; - } - } - }; - - PullTypeResolver.prototype.getContextualClassSymbolForEnclosingDecl = function (ast, enclosingDecl) { - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var isStaticContext = false; - - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declFlags & 16 /* Static */) { - isStaticContext = true; - } else if (declKind === 131072 /* FunctionExpression */ && !TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - return null; - } else if (declKind === 16384 /* Function */) { - return null; - } else if (declKind === 8 /* Class */) { - if (this.inStaticMemberVariableDeclaration(ast)) { - return this.getNewErrorTypeSymbol(); - } else { - var classSymbol = decl.getSymbol(); - if (isStaticContext) { - var constructorSymbol = classSymbol.getConstructorMethod(); - return constructorSymbol.type; - } else { - return classSymbol; - } - } - } - } - } - - return null; - }; - - PullTypeResolver.prototype.inStaticMemberVariableDeclaration = function (ast) { - while (ast) { - if (ast.kind() === 136 /* MemberVariableDeclaration */ && TypeScript.hasModifier(ast.modifiers, 16 /* Static */)) { - return true; - } - - ast = ast.parent; - } - - return false; - }; - - PullTypeResolver.prototype.resolveSuperExpression = function (ast, context) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - var superType = this.semanticInfoChain.anyTypeSymbol; - - var classSymbol = this.getContextualClassSymbolForEnclosingDecl(ast, enclosingDecl); - - if (classSymbol) { - this.resolveDeclaredSymbol(classSymbol, context); - - var parents = classSymbol.getExtendedTypes(); - - if (parents.length) { - superType = parents[0]; - } - } - - if (this.canTypeCheckAST(ast, context)) { - this.typeCheckSuperExpression(ast, context, enclosingDecl); - } - - return superType; - }; - - PullTypeResolver.prototype.typeCheckSuperExpression = function (ast, context, enclosingDecl) { - this.setTypeChecked(ast, context); - - this.checkForThisCaptureInArrowFunction(ast); - - var isSuperCall = ast.parent.kind() === 213 /* InvocationExpression */; - var isSuperPropertyAccess = ast.parent.kind() === 212 /* MemberAccessExpression */; - TypeScript.Debug.assert(isSuperCall || isSuperPropertyAccess); - - if (isSuperPropertyAccess) { - for (var currentDecl = enclosingDecl; currentDecl !== null; currentDecl = currentDecl.getParentDecl()) { - if (this.isFunctionOrNonArrowFunctionExpression(currentDecl)) { - break; - } else if (currentDecl.kind === 8 /* Class */) { - if (!this.enclosingClassIsDerived(currentDecl)) { - 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 if (this.inStaticMemberVariableDeclaration(ast)) { - break; - } - - 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 { - 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)); - } - } - }; - - PullTypeResolver.prototype.resolveSimplePropertyAssignment = function (propertyAssignment, isContextuallyTyped, context) { - return this.resolveAST(propertyAssignment.expression, isContextuallyTyped, context); - }; - - PullTypeResolver.prototype.resolveFunctionPropertyAssignment = function (funcProp, 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.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 (!hasResolvedSymbol || additionalResults || this.canTypeCheckAST(expressionAST, context)) { - if (this.canTypeCheckAST(expressionAST, context)) { - this.setTypeChecked(expressionAST, context); - } - symbol = this.computeObjectLiteralExpression(expressionAST, isContextuallyTyped, context, additionalResults); - this.setSymbolForAST(expressionAST, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.bindObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralMembers, isUsingExistingSymbol, pullTypeContext) { - var boundMemberSymbols = []; - var memberSymbol; - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var id = this.getPropertyAssignmentName(propertyAssignment); - var assignmentText = getPropertyAssignmentNameTextFromIdentifier(id); - - var isAccessor = propertyAssignment.kind() === 139 /* GetAccessor */ || propertyAssignment.kind() === 140 /* SetAccessor */; - var decl = this.semanticInfoChain.getDeclForAST(propertyAssignment); - TypeScript.Debug.assert(decl); - - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - if (!isUsingExistingSymbol) { - memberSymbol = new TypeScript.PullSymbol(assignmentText.memberName, 4096 /* Property */); - memberSymbol.addDeclaration(decl); - decl.setSymbol(memberSymbol); - } else { - memberSymbol = decl.getSymbol(); - } - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - memberSymbol = decl.getSymbol(); - } else { - TypeScript.Debug.assert(isAccessor); - memberSymbol = decl.getSymbol(); - } - - if (!isUsingExistingSymbol && !isAccessor) { - var existingMember = objectLiteralTypeSymbol.findMember(memberSymbol.name, true); - if (existingMember) { - pullTypeContext.postDiagnostic(this.semanticInfoChain.duplicateIdentifierDiagnosticFromAST(propertyAssignment, assignmentText.actualText, existingMember.getDeclarations()[0].ast())); - } - - objectLiteralTypeSymbol.addMember(memberSymbol); - } - - boundMemberSymbols.push(memberSymbol); - } - - return boundMemberSymbols; - }; - - PullTypeResolver.prototype.resolveObjectLiteralMembers = function (objectLiteralDeclaration, objectLiteralTypeSymbol, objectLiteralContextualType, objectLiteralMembers, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, pullTypeContext, additionalResults) { - for (var i = 0, len = objectLiteralMembers.nonSeparatorCount(); i < len; i++) { - var propertyAssignment = objectLiteralMembers.nonSeparatorAt(i); - - var acceptedContextualType = false; - var assigningSymbol = null; - - var id = this.getPropertyAssignmentName(propertyAssignment); - var memberSymbol = boundMemberSymbols[i]; - var contextualMemberType = null; - - if (objectLiteralContextualType) { - assigningSymbol = this.getNamedPropertySymbol(memberSymbol.name, 68147712 /* SomeValue */, objectLiteralContextualType); - - if (!assigningSymbol) { - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - assigningSymbol = numericIndexerSignature; - } else if (stringIndexerSignature) { - assigningSymbol = stringIndexerSignature; - } - } - - if (assigningSymbol) { - this.resolveDeclaredSymbol(assigningSymbol, pullTypeContext); - - contextualMemberType = assigningSymbol.kind === 4194304 /* IndexSignature */ ? assigningSymbol.returnType : assigningSymbol.type; - pullTypeContext.propagateContextualType(contextualMemberType); - - acceptedContextualType = true; - - if (additionalResults) { - additionalResults.membersContextTypeSymbols[i] = contextualMemberType; - } - } - } - - var memberSymbolType = this.resolveAST(propertyAssignment, contextualMemberType !== null, pullTypeContext).type; - - if (memberSymbolType) { - if (memberSymbolType.isGeneric()) { - objectLiteralTypeSymbol.setHasGenericMember(); - } - - if (stringIndexerSignature) { - allMemberTypes.push(memberSymbolType); - } - if (numericIndexerSignature && TypeScript.PullHelpers.isNameNumeric(memberSymbol.name)) { - allNumericMemberTypes.push(memberSymbolType); - } - } - - if (acceptedContextualType) { - pullTypeContext.popAnyContextualType(); - } - - var isAccessor = propertyAssignment.kind() === 140 /* SetAccessor */ || propertyAssignment.kind() === 139 /* GetAccessor */; - if (!memberSymbol.isResolved) { - if (isAccessor) { - this.setSymbolForAST(id, memberSymbolType, pullTypeContext); - } else { - pullTypeContext.setTypeInContext(memberSymbol, memberSymbolType); - memberSymbol.setResolved(); - - this.setSymbolForAST(id, memberSymbol, pullTypeContext); - } - } - } - }; - - PullTypeResolver.prototype.computeObjectLiteralExpression = function (objectLitAST, isContextuallyTyped, context, additionalResults) { - var objectLitDecl = this.semanticInfoChain.getDeclForAST(objectLitAST); - TypeScript.Debug.assert(objectLitDecl); - - var typeSymbol = this.getSymbolForAST(objectLitAST, context); - var isUsingExistingSymbol = !!typeSymbol; - - if (!typeSymbol) { - typeSymbol = new TypeScript.PullTypeSymbol("", 256 /* ObjectLiteral */); - typeSymbol.addDeclaration(objectLitDecl); - this.setSymbolForAST(objectLitAST, typeSymbol, context); - objectLitDecl.setSymbol(typeSymbol); - } - - var propertyAssignments = objectLitAST.propertyAssignments; - var contextualType = null; - - if (isContextuallyTyped) { - contextualType = context.getContextualType(); - this.resolveDeclaredSymbol(contextualType, context); - } - - var stringIndexerSignature = null; - var numericIndexerSignature = null; - var allMemberTypes = null; - var allNumericMemberTypes = null; - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - - stringIndexerSignature = indexSignatures.stringSignature; - numericIndexerSignature = indexSignatures.numericSignature; - - var inInferentialTyping = context.isInferentiallyTyping(); - if (stringIndexerSignature) { - allMemberTypes = inInferentialTyping ? [] : [stringIndexerSignature.returnType]; - } - - if (numericIndexerSignature) { - allNumericMemberTypes = inInferentialTyping ? [] : [numericIndexerSignature.returnType]; - } - } - - if (propertyAssignments) { - if (additionalResults) { - additionalResults.membersContextTypeSymbols = []; - } - - var boundMemberSymbols = this.bindObjectLiteralMembers(objectLitDecl, typeSymbol, propertyAssignments, isUsingExistingSymbol, context); - - this.resolveObjectLiteralMembers(objectLitDecl, typeSymbol, contextualType, propertyAssignments, stringIndexerSignature, numericIndexerSignature, allMemberTypes, allNumericMemberTypes, boundMemberSymbols, isUsingExistingSymbol, context, additionalResults); - - if (!isUsingExistingSymbol) { - this.stampObjectLiteralWithIndexSignature(typeSymbol, allMemberTypes, stringIndexerSignature, context); - this.stampObjectLiteralWithIndexSignature(typeSymbol, allNumericMemberTypes, numericIndexerSignature, context); - } - } - - typeSymbol.setResolved(); - return typeSymbol; - }; - - PullTypeResolver.prototype.getPropertyAssignmentName = function (propertyAssignment) { - if (propertyAssignment.kind() === 240 /* SimplePropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 241 /* FunctionPropertyAssignment */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 139 /* GetAccessor */) { - return propertyAssignment.propertyName; - } else if (propertyAssignment.kind() === 140 /* SetAccessor */) { - return propertyAssignment.propertyName; - } else { - TypeScript.Debug.assert(false); - } - }; - - PullTypeResolver.prototype.stampObjectLiteralWithIndexSignature = function (objectLiteralSymbol, indexerTypeCandidates, contextualIndexSignature, context) { - if (contextualIndexSignature) { - var typeCollection = { - getLength: function () { - return indexerTypeCandidates.length; - }, - getTypeAtIndex: function (index) { - return indexerTypeCandidates[index]; - } - }; - var decl = objectLiteralSymbol.getDeclarations()[0]; - 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); - } - } - }; - - PullTypeResolver.prototype.resolveArrayLiteralExpression = function (arrayLit, isContextuallyTyped, context) { - var symbol = this.getSymbolForAST(arrayLit, context); - if (!symbol || this.canTypeCheckAST(arrayLit, context)) { - if (this.canTypeCheckAST(arrayLit, context)) { - this.setTypeChecked(arrayLit, context); - } - symbol = this.computeArrayLiteralExpressionSymbol(arrayLit, isContextuallyTyped, context); - this.setSymbolForAST(arrayLit, symbol, context); - } - - return symbol; - }; - - PullTypeResolver.prototype.computeArrayLiteralExpressionSymbol = function (arrayLit, isContextuallyTyped, context) { - var elements = arrayLit.expressions; - var elementType = null; - var elementTypes = []; - var comparisonInfo = new TypeComparisonInfo(); - var contextualElementType = null; - comparisonInfo.onlyCaptureFirstError = true; - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - - this.resolveDeclaredSymbol(contextualType, context); - - if (contextualType) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(contextualType, context); - if (indexSignatures.numericSignature) { - contextualElementType = indexSignatures.numericSignature.returnType; - } - } - } - - if (elements) { - if (contextualElementType) { - context.propagateContextualType(contextualElementType); - } - - for (var i = 0, n = elements.nonSeparatorCount(); i < n; i++) { - elementTypes.push(this.resolveAST(elements.nonSeparatorAt(i), contextualElementType !== null, context).type); - } - - if (contextualElementType) { - context.popAnyContextualType(); - } - } - - if (elementTypes.length) { - elementType = elementTypes[0]; - } - var collection; - - if (contextualElementType && !context.isInferentiallyTyping()) { - if (!elementType) { - elementType = contextualElementType; - } - - collection = { - getLength: function () { - return elements.nonSeparatorCount() + 1; - }, - getTypeAtIndex: function (index) { - return index === 0 ? contextualElementType : elementTypes[index - 1]; - } - }; - } else { - collection = { - getLength: function () { - return elements.nonSeparatorCount(); - }, - getTypeAtIndex: function (index) { - return elementTypes[index]; - } - }; - } - - elementType = elementType ? this.findBestCommonType(collection, context, comparisonInfo) : elementType; - - if (!elementType) { - elementType = this.semanticInfoChain.undefinedTypeSymbol; - } - - return this.getArrayType(elementType); - }; - - PullTypeResolver.prototype.resolveElementAccessExpression = function (callEx, context) { - var symbolAndDiagnostic = this.computeElementAccessExpressionSymbolAndDiagnostic(callEx, context); - - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckElementAccessExpression(callEx, context, symbolAndDiagnostic); - } - - return symbolAndDiagnostic.symbol; - }; - - PullTypeResolver.prototype.typeCheckElementAccessExpression = function (callEx, context, symbolAndDiagnostic) { - this.setTypeChecked(callEx, context); - context.postDiagnostic(symbolAndDiagnostic.diagnostic); - }; - - PullTypeResolver.prototype.computeElementAccessExpressionSymbolAndDiagnostic = function (callEx, context) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var indexType = this.resolveAST(callEx.argumentExpression, false, context).type; - - var targetTypeSymbol = targetSymbol.type; - - targetTypeSymbol = this.getApparentType(targetTypeSymbol); - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - return { symbol: targetTypeSymbol }; - } - - var elementType = targetTypeSymbol.getElementType(); - - var isNumberIndex = indexType === this.semanticInfoChain.numberTypeSymbol || TypeScript.PullHelpers.symbolIsEnum(indexType); - - if (elementType && isNumberIndex) { - return { symbol: elementType }; - } - - 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._getNamedPropertySymbolOfAugmentedType(memberName, targetTypeSymbol); - - if (member) { - this.resolveDeclaredSymbol(member, context); - - return { symbol: member.type }; - } - } - - var signatures = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(targetTypeSymbol, context); - - var stringSignature = signatures.stringSignature; - var numberSignature = signatures.numericSignature; - - if (numberSignature && (isNumberIndex || indexType === this.semanticInfoChain.anyTypeSymbol)) { - return { symbol: numberSignature.returnType || this.semanticInfoChain.anyTypeSymbol }; - } 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 { - symbol: this.getNewErrorTypeSymbol(), - diagnostic: this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Value_of_type_0_is_not_indexable_by_type_1, [targetTypeSymbol.toString(), indexType.toString()]) - }; - } - }; - - 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; - var signature = null; - var paramSymbols; - var paramType; - - for (var i = 0; i < signatures.length; i++) { - if (stringSignature && numberSignature) { - break; - } - - signature = signatures[i]; - if (!signature.isResolved) { - this.resolveDeclaredSymbol(signature, context); - } - - paramSymbols = signature.parameters; - - if (paramSymbols.length) { - paramType = paramSymbols[0].type; - - if (!stringSignature && paramType === this.semanticInfoChain.stringTypeSymbol) { - stringSignature = signature; - continue; - } else if (!numberSignature && paramType === this.semanticInfoChain.numberTypeSymbol) { - numberSignature = signature; - continue; - } - } - } - - return { - numericSignature: numberSignature, - stringSignature: stringSignature - }; - }; - - 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; - var rhsType = this.resolveAST(binaryExpression.right, false, context).type; - - if (TypeScript.PullHelpers.symbolIsEnum(lhsType)) { - lhsType = this.semanticInfoChain.numberTypeSymbol; - } - - if (TypeScript.PullHelpers.symbolIsEnum(rhsType)) { - rhsType = this.semanticInfoChain.numberTypeSymbol; - } - - 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 { - lhsType = rhsType; - } - } else if (isRhsTypeNullOrUndefined) { - rhsType = lhsType; - } - - var exprType = null; - - if (lhsType === this.semanticInfoChain.stringTypeSymbol || rhsType === this.semanticInfoChain.stringTypeSymbol) { - exprType = this.semanticInfoChain.stringTypeSymbol; - } else if (this.isAnyOrEquivalent(lhsType) || this.isAnyOrEquivalent(rhsType)) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } else if (rhsType === this.semanticInfoChain.numberTypeSymbol && lhsType === this.semanticInfoChain.numberTypeSymbol) { - exprType = this.semanticInfoChain.numberTypeSymbol; - } - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (exprType) { - if (binaryExpression.kind() === 175 /* AddAssignmentExpression */) { - if (!this.isReference(binaryExpression.left, lhsExpression)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } - - this.checkAssignability(binaryExpression.left, exprType, lhsType, context); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_expression_types_not_known_to_support_the_addition_operator)); - } - } - - if (!exprType) { - exprType = this.semanticInfoChain.anyTypeSymbol; - } - - return exprType; - }; - - PullTypeResolver.prototype.bestCommonTypeOfTwoTypes = function (type1, type2, context) { - return this.findBestCommonType({ - getLength: function () { - return 2; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - } - } - }, context); - }; - - PullTypeResolver.prototype.bestCommonTypeOfThreeTypes = function (type1, type2, type3, context) { - return this.findBestCommonType({ - getLength: function () { - return 3; - }, - getTypeAtIndex: function (index) { - switch (index) { - case 0: - return type1; - case 1: - return type2; - case 2: - return type3; - } - } - }, context); - }; - - PullTypeResolver.prototype.resolveLogicalOrExpression = function (binex, isContextuallyTyped, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - } - - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - var leftType = this.resolveAST(binex.left, isContextuallyTyped, context).type; - var rightType = this.resolveAST(binex.right, isContextuallyTyped, context).type; - - 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.pushNewContextualType(leftType); - var rightType = this.resolveAST(binex.right, true, context).type; - context.popAnyContextualType(); - - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveLogicalAndExpression = function (binex, context) { - if (this.canTypeCheckAST(binex, context)) { - this.setTypeChecked(binex, context); - - this.resolveAST(binex.left, false, context); - } - - return this.resolveAST(binex.right, false, context).type; - }; - - PullTypeResolver.prototype.computeTypeOfConditionalExpression = function (leftType, rightType, isContextuallyTyped, context) { - if (isContextuallyTyped && !context.isInferentiallyTyping()) { - var contextualType = context.getContextualType(); - return this.bestCommonTypeOfThreeTypes(contextualType, leftType, rightType, context); - } else { - return this.bestCommonTypeOfTwoTypes(leftType, rightType, context); - } - }; - - PullTypeResolver.prototype.resolveConditionalExpression = function (trinex, isContextuallyTyped, context) { - var leftType = this.resolveAST(trinex.whenTrue, isContextuallyTyped, context).type; - var rightType = this.resolveAST(trinex.whenFalse, isContextuallyTyped, context).type; - - var expressionType = this.computeTypeOfConditionalExpression(leftType, rightType, isContextuallyTyped, context); - - var conditionalTypesAreValid = this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context); - - if (this.canTypeCheckAST(trinex, context)) { - this.setTypeChecked(trinex, context); - this.resolveAST(trinex.condition, false, context); - - if (!this.conditionExpressionTypesAreValid(leftType, rightType, expressionType, isContextuallyTyped, context)) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_2_or_3, [expressionType.toString(), leftType.toString(), rightType.toString(), contextualType.toString()])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(trinex, TypeScript.DiagnosticCode.Type_of_conditional_0_must_be_identical_to_1_or_2, [expressionType.toString(), leftType.toString(), rightType.toString()])); - } - } - } - - if (!conditionalTypesAreValid) { - return this.getNewErrorTypeSymbol(); - } - - return expressionType; - }; - - PullTypeResolver.prototype.conditionExpressionTypesAreValid = function (leftType, rightType, expressionType, isContextuallyTyped, context) { - if (isContextuallyTyped) { - var contextualType = context.getContextualType(); - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context) || this.typesAreIdentical(expressionType, contextualType, context)) { - return true; - } - } else { - if (this.typesAreIdentical(expressionType, leftType, context) || this.typesAreIdentical(expressionType, rightType, context)) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.resolveParenthesizedExpression = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - } - - return this.resolveAST(ast.expression, false, context); - }; - - PullTypeResolver.prototype.resolveExpressionStatement = function (ast, context) { - if (this.canTypeCheckAST(ast, context)) { - this.setTypeChecked(ast, context); - - this.resolveAST(ast.expression, false, context); - } - - return this.semanticInfoChain.voidTypeSymbol; - }; - - PullTypeResolver.prototype.resolveInvocationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeInvocationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - if (symbol !== this.semanticInfoChain.anyTypeSymbol) { - this.setSymbolForAST(callEx, symbol, context); - } - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckInvocationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckInvocationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - var targetSymbol = this.resolveAST(callEx.expression, false, context); - - if (callEx.argumentList.arguments) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - - var len = callEx.argumentList.arguments.nonSeparatorCount(); - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.computeInvocationExpressionSymbol = function (callEx, context, additionalResults) { - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var targetTypeSymbol = targetSymbol.type; - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - if (targetTypeSymbol === this.semanticInfoChain.anyTypeSymbol) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Untyped_function_calls_may_not_accept_type_arguments), additionalResults, context); - return this.getNewErrorTypeSymbol(); - } - } - - return this.semanticInfoChain.anyTypeSymbol; - } - - var isSuperCall = false; - - if (callEx.expression.kind() === 50 /* SuperKeyword */) { - isSuperCall = true; - - if (targetTypeSymbol.isClass()) { - targetSymbol = targetTypeSymbol.getConstructorMethod(); - this.resolveDeclaredSymbol(targetSymbol, context); - targetTypeSymbol = targetSymbol.type; - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Calls_to_super_are_only_valid_inside_a_class), additionalResults, context); - this.resolveAST(callEx.argumentList.arguments, false, context); - - return this.getNewErrorTypeSymbol(); - } - } - - var signatures = isSuperCall ? targetTypeSymbol.getConstructSignatures() : targetTypeSymbol.getCallSignatures(); - - 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 explicitTypeArgs = null; - var couldNotFindGenericOverload = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - var triedToInferTypeArgs = false; - - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var beforeResolutionSignatures = signatures; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < signatures.length; i++) { - typeParameters = signatures[i].getTypeParameters(); - couldNotAssignToConstraint = false; - - if (signatures[i].isGeneric() && typeParameters.length) { - if (isSuperCall && targetTypeSymbol.isGeneric() && !callEx.argumentList.typeArgumentList) { - explicitTypeArgs = signatures[i].returnType.getTypeArguments(); - } - - 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, 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; - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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]; - } - } - } - - if (signatures.length && !resolvedSignatures.length) { - couldNotFindGenericOverload = true; - } - - signatures = resolvedSignatures; - - var errorCondition = null; - if (!signatures.length) { - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures && beforeResolutionSignatures.length ? beforeResolutionSignatures[0] : null; - - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - this.resolveAST(callEx.argumentList.arguments, false, context); - - if (!couldNotFindGenericOverload) { - 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); - } - return this.semanticInfoChain.anyTypeSymbol; - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature), additionalResults, context); - } else if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } else { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var signature = this.resolveOverloads(callEx, signatures, callEx.argumentList.typeArgumentList !== null, context, diagnostics); - var useBeforeResolutionSignatures = signature == null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_call_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!signatures.length) { - return errorCondition; - } - - signature = signatures[0]; - } - - 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 (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; - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - if (useBeforeResolutionSignatures && beforeResolutionSignatures) { - additionalResults.resolvedSignatures = beforeResolutionSignatures; - additionalResults.candidateSignature = beforeResolutionSignatures[0]; - } else { - additionalResults.resolvedSignatures = signatures; - additionalResults.candidateSignature = signature; - } - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - }; - - PullTypeResolver.prototype.resolveObjectCreationExpression = function (callEx, context, additionalResults) { - var symbol = this.getSymbolForAST(callEx, context); - - if (!symbol || !symbol.isResolved) { - if (!additionalResults) { - additionalResults = new PullAdditionalCallResolutionData(); - } - symbol = this.computeObjectCreationExpressionSymbol(callEx, context, additionalResults); - if (this.canTypeCheckAST(callEx, context)) { - this.setTypeChecked(callEx, context); - } - this.setSymbolForAST(callEx, symbol, context); - this.semanticInfoChain.setCallResolutionDataForAST(callEx, additionalResults); - } else { - if (this.canTypeCheckAST(callEx, context)) { - this.typeCheckObjectCreationExpression(callEx, context); - } - - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (additionalResults && (callResolutionData !== additionalResults)) { - additionalResults.actualParametersContextTypeSymbols = callResolutionData.actualParametersContextTypeSymbols; - additionalResults.candidateSignature = callResolutionData.candidateSignature; - additionalResults.resolvedSignatures = callResolutionData.resolvedSignatures; - additionalResults.targetSymbol = callResolutionData.targetSymbol; - } - } - - return symbol; - }; - - PullTypeResolver.prototype.typeCheckObjectCreationExpression = function (callEx, context) { - this.setTypeChecked(callEx, context); - this.resolveAST(callEx.expression, false, context); - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - if (callEx.argumentList) { - var callResolutionData = this.semanticInfoChain.getCallResolutionDataForAST(callEx); - var len = callEx.argumentList.arguments.nonSeparatorCount(); - - for (var i = 0; i < len; i++) { - var contextualType = callResolutionData.actualParametersContextTypeSymbols ? callResolutionData.actualParametersContextTypeSymbols[i] : null; - if (contextualType) { - context.pushNewContextualType(contextualType); - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - for (var i = 0; i < callResolutionData.diagnosticsFromOverloadResolution.length; i++) { - context.postDiagnostic(callResolutionData.diagnosticsFromOverloadResolution[i]); - } - }; - - PullTypeResolver.prototype.postOverloadResolutionDiagnostics = function (diagnostic, additionalResults, context) { - if (!context.inProvisionalResolution()) { - additionalResults.diagnosticsFromOverloadResolution.push(diagnostic); - } - context.postDiagnostic(diagnostic); - }; - - PullTypeResolver.prototype.computeObjectCreationExpressionSymbol = function (callEx, context, additionalResults) { - var _this = this; - var returnType = null; - - var targetSymbol = this.resolveAST(callEx.expression, false, context); - var targetTypeSymbol = targetSymbol.isType() ? targetSymbol : targetSymbol.type; - - var targetAST = this.getCallTargetErrorSpanAST(callEx); - - var constructSignatures = targetTypeSymbol.getConstructSignatures(); - - var explicitTypeArgs = null; - var usedCallSignaturesInstead = false; - var couldNotAssignToConstraint; - var constraintDiagnostic = null; - var typeArgumentCountDiagnostic = null; - var diagnostics = []; - - if (this.isAnyOrEquivalent(targetTypeSymbol)) { - if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - return targetTypeSymbol; - } - - if (!constructSignatures.length) { - constructSignatures = targetTypeSymbol.getCallSignatures(); - usedCallSignaturesInstead = true; - - if (this.compilationSettings.noImplicitAny()) { - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(callEx, TypeScript.DiagnosticCode.new_expression_which_lacks_a_constructor_signature_implicitly_has_an_any_type), additionalResults, context); - } - } - - if (constructSignatures.length) { - if (callEx.argumentList && callEx.argumentList.typeArgumentList) { - explicitTypeArgs = []; - - if (callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount()) { - for (var i = 0; i < callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount(); i++) { - explicitTypeArgs[i] = this.resolveTypeReference(callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorAt(i), context); - } - } - } - - if (targetTypeSymbol.isGeneric()) { - var resolvedSignatures = []; - var inferredOrExplicitTypeArgs; - var specializedSignature; - var typeParameters; - var typeConstraint = null; - var triedToInferTypeArgs; - var targetTypeReplacementMap = targetTypeSymbol.getTypeParameterArgumentMap(); - - for (var i = 0; i < constructSignatures.length; i++) { - couldNotAssignToConstraint = false; - - if (constructSignatures[i].isGeneric()) { - typeParameters = constructSignatures[i].getTypeParameters(); - - 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, explicitTypeArgs.length]); - continue; - } - } 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 { - inferredOrExplicitTypeArgs = TypeScript.ArrayUtilities.select(typeParameters, function (typeParameter) { - return typeParameter.getDefaultConstraint(_this.semanticInfoChain); - }); - } - - TypeScript.Debug.assert(inferredOrExplicitTypeArgs && inferredOrExplicitTypeArgs.length == typeParameters.length); - - 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(constructSignatures[i], typeReplacementMap); - - if (specializedSignature) { - resolvedSignatures[resolvedSignatures.length] = specializedSignature; - } - } else { - if (!(callEx.argumentList && callEx.argumentList.typeArgumentList && callEx.argumentList.typeArgumentList.typeArguments.nonSeparatorCount())) { - resolvedSignatures[resolvedSignatures.length] = constructSignatures[i]; - } - } - } - - constructSignatures = resolvedSignatures; - } - - var signature = this.resolveOverloads(callEx, constructSignatures, callEx.argumentList && callEx.argumentList.typeArgumentList !== null, context, diagnostics); - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = []; - - if (!constructSignatures.length) { - if (constraintDiagnostic) { - this.postOverloadResolutionDiagnostics(constraintDiagnostic, additionalResults, context); - } else if (typeArgumentCountDiagnostic) { - this.postOverloadResolutionDiagnostics(typeArgumentCountDiagnostic, additionalResults, context); - } - - return this.getNewErrorTypeSymbol(); - } - - var errorCondition = null; - - if (!signature) { - for (var i = 0; i < diagnostics.length; i++) { - this.postOverloadResolutionDiagnostics(diagnostics[i], additionalResults, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Could_not_select_overload_for_new_expression), additionalResults, context); - - errorCondition = this.getNewErrorTypeSymbol(); - - if (!constructSignatures.length) { - return errorCondition; - } - - signature = constructSignatures[0]; - } - - returnType = signature.returnType; - - if (returnType && !signature.isGeneric() && returnType.isGeneric() && !returnType.getIsSpecialized()) { - if (explicitTypeArgs && explicitTypeArgs.length) { - returnType = this.createInstantiatedType(returnType, explicitTypeArgs); - } else { - returnType = this.instantiateTypeToAny(returnType, context); - } - } - - if (usedCallSignaturesInstead) { - 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(); - } else { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - } - - if (!returnType) { - returnType = signature.returnType; - - if (!returnType) { - returnType = targetTypeSymbol; - } - } - - var actualParametersContextTypeSymbols = []; - if (callEx.argumentList && callEx.argumentList.arguments) { - var len = callEx.argumentList.arguments.nonSeparatorCount(); - var params = signature.parameters; - var contextualType = null; - var signatureDecl = signature.getDeclarations()[0]; - - for (var i = 0; i < len; i++) { - if (params.length) { - if (i < params.length - 1 || (i < params.length && !signature.hasVarArgs)) { - this.resolveDeclaredSymbol(params[i], context); - contextualType = params[i].type; - } else if (signature.hasVarArgs) { - contextualType = params[params.length - 1].type; - if (contextualType.isArrayNamedTypeReference()) { - contextualType = contextualType.getElementType(); - } - } - } - - if (contextualType) { - context.pushNewContextualType(contextualType); - actualParametersContextTypeSymbols[i] = contextualType; - } - - this.resolveAST(callEx.argumentList.arguments.nonSeparatorAt(i), contextualType !== null, context); - - if (contextualType) { - context.popAnyContextualType(); - contextualType = null; - } - } - } - - additionalResults.targetSymbol = targetSymbol; - additionalResults.resolvedSignatures = constructSignatures; - additionalResults.candidateSignature = signature; - additionalResults.actualParametersContextTypeSymbols = actualParametersContextTypeSymbols; - - if (errorCondition) { - return errorCondition; - } - - if (!returnType) { - returnType = this.semanticInfoChain.anyTypeSymbol; - } - - return returnType; - } else if (callEx.argumentList) { - this.resolveAST(callEx.argumentList.arguments, false, context); - } - - this.postOverloadResolutionDiagnostics(this.semanticInfoChain.diagnosticFromAST(targetAST, TypeScript.DiagnosticCode.Invalid_new_expression), additionalResults, context); - - return this.getNewErrorTypeSymbol(); - }; - - PullTypeResolver.prototype.instantiateSignatureInContext = function (signatureAToInstantiate, contextualSignatureB, context, shouldFixContextualSignatureParameterTypes) { - var typeReplacementMap = []; - var inferredTypeArgs; - var specializedSignature; - var typeParameters = signatureAToInstantiate.getTypeParameters(); - var typeConstraint = null; - - var typeArgumentInferenceContext = new TypeScript.ContextualSignatureInstantiationTypeArgumentInferenceContext(this, context, signatureAToInstantiate, contextualSignatureB, shouldFixContextualSignatureParameterTypes); - inferredTypeArgs = this.inferArgumentTypesForSignature(typeArgumentInferenceContext, new TypeComparisonInfo(), context); - - var functionTypeA = signatureAToInstantiate.functionType; - var functionTypeB = contextualSignatureB.functionType; - var enclosingTypeParameterMap; - - if (functionTypeA) { - enclosingTypeParameterMap = functionTypeA.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - if (functionTypeB) { - enclosingTypeParameterMap = functionTypeB.getTypeParameterArgumentMap(); - - for (var id in enclosingTypeParameterMap) { - typeReplacementMap[id] = enclosingTypeParameterMap[id]; - } - } - - TypeScript.PullInstantiationHelpers.updateTypeParameterArgumentMap(typeParameters, inferredTypeArgs, typeReplacementMap); - - return this.instantiateSignature(signatureAToInstantiate, typeReplacementMap); - }; - - PullTypeResolver.prototype.resolveCastExpression = function (assertionExpression, context) { - var typeAssertionType = this.resolveTypeReference(assertionExpression.type, context).type; - - if (this.canTypeCheckAST(assertionExpression, context)) { - this.typeCheckCastExpression(assertionExpression, context, typeAssertionType); - } - - return typeAssertionType; - }; - - PullTypeResolver.prototype.typeCheckCastExpression = function (assertionExpression, context, typeAssertionType) { - this.setTypeChecked(assertionExpression, context); - - context.pushNewContextualType(typeAssertionType); - var exprType = this.resolveAST(assertionExpression.expression, true, context).type; - context.popAnyContextualType(); - - this.resolveDeclaredSymbol(typeAssertionType, context); - this.resolveDeclaredSymbol(exprType, context); - - var comparisonInfo = new TypeComparisonInfo(); - - 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); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(assertionExpression, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [exprType.toString(enclosingSymbol), typeAssertionType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.resolveAssignmentExpression = function (binaryExpression, context) { - var leftExpr = this.resolveAST(binaryExpression.left, false, context); - var leftType = leftExpr.type; - - context.pushNewContextualType(leftType); - var rightType = this.resolveAST(binaryExpression.right, true, context).type; - context.popAnyContextualType(); - - rightType = this.getInstanceTypeForAssignment(binaryExpression.left, rightType, context); - - if (this.canTypeCheckAST(binaryExpression, context)) { - this.setTypeChecked(binaryExpression, context); - - if (!this.isReference(binaryExpression.left, leftExpr)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(binaryExpression.left, TypeScript.DiagnosticCode.Invalid_left_hand_side_of_assignment_expression)); - } else { - this.checkAssignability(binaryExpression.left, rightType, leftExpr.type, context); - } - } - - return rightType; - }; - - PullTypeResolver.prototype.getInstanceTypeForAssignment = function (lhs, type, context) { - var typeToReturn = type; - if (typeToReturn && typeToReturn.isAlias()) { - typeToReturn = typeToReturn.getExportAssignedTypeSymbol(); - } - - if (typeToReturn && typeToReturn.isContainer() && !typeToReturn.isEnum()) { - var instanceTypeSymbol = typeToReturn.getInstanceType(); - - if (!instanceTypeSymbol) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(lhs, TypeScript.DiagnosticCode.Tried_to_set_variable_type_to_uninitialized_module_type_0, [type.toString()])); - typeToReturn = null; - } else { - typeToReturn = instanceTypeSymbol; - } - } - - return typeToReturn; - }; - - PullTypeResolver.prototype.widenType = function (type, ast, context) { - if (type === this.semanticInfoChain.undefinedTypeSymbol || type === this.semanticInfoChain.nullTypeSymbol || type.isError()) { - return this.semanticInfoChain.anyTypeSymbol; - } - - if (type.isArrayNamedTypeReference()) { - 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(); - - for (var i = 0; i < len; i++) { - var candidateType = collection.getTypeAtIndex(i); - if (this.typeIsBestCommonTypeCandidate(candidateType, collection, context)) { - return candidateType; - } - } - - return this.semanticInfoChain.emptyTypeSymbol; - }; - - PullTypeResolver.prototype.typeIsBestCommonTypeCandidate = function (candidateType, collection, context) { - for (var i = 0; i < collection.getLength(); i++) { - var otherType = collection.getTypeAtIndex(i); - if (candidateType === otherType) { - continue; - } - - if (!this.sourceIsSubtypeOfTarget(otherType, candidateType, null, context)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.typesAreIdenticalInEnclosingTypes = function (t1, t2, context) { - t1 = this.getSymbolForRelationshipCheck(t1); - t2 = this.getSymbolForRelationshipCheck(t2); - - if (t1 === t2) { - return true; - } - - if (t1 && t2) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingTypesAreIdentical(t1, t2, context); - } - } - - return this.typesAreIdentical(t1, t2, context); - }; - - 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); - - if (t1 === t2) { - return true; - } - - if (!t1 || !t2) { - return false; - } - - if (TypeScript.hasFlag(t1.kind, 64 /* Enum */) || TypeScript.hasFlag(t2.kind, 64 /* Enum */)) { - return false; - } - - if (t1.isPrimitive() && t1.isStringConstant() && t2.isPrimitive() && t2.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(t1.name) === TypeScript.stripStartAndEndQuotes(t2.name); - } - - if (t1.isPrimitive() || t2.isPrimitive()) { - return false; - } - - if (t1.isError() && t2.isError()) { - return true; - } - - 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(); - var t2ParentDeclaration = t2.getDeclarations()[0].getParentDecl(); - - if (t1ParentDeclaration === t2ParentDeclaration) { - return this.symbolsShareDeclaration(t1, t2); - } else { - return false; - } - } - - if (t1.isPrimitive() !== t2.isPrimitive()) { - return 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) { - return false; - } - - var t1MemberSymbol = null; - var t2MemberSymbol = null; - - var t1MemberType = null; - var t2MemberType = null; - - for (var iMember = 0; iMember < t1Members.length; iMember++) { - t1MemberSymbol = t1Members[iMember]; - t2MemberSymbol = this.getNamedPropertySymbol(t1MemberSymbol.name, 68147712 /* SomeValue */, t2); - - if (!this.propertiesAreIdentical(t1MemberSymbol, t2MemberSymbol, context)) { - return false; - } - } - } else if (t1.hasMembers() || t2.hasMembers()) { - return false; - } - - var t1CallSigs = t1.getCallSignatures(); - var t2CallSigs = t2.getCallSignatures(); - - var t1ConstructSigs = t1.getConstructSignatures(); - var t2ConstructSigs = t2.getConstructSignatures(); - - var t1IndexSigs = t1.getIndexSignatures(); - var t2IndexSigs = t2.getIndexSignatures(); - - if (!this.signatureGroupsAreIdentical(t1CallSigs, t2CallSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1ConstructSigs, t2ConstructSigs, context)) { - return false; - } - - if (!this.signatureGroupsAreIdentical(t1IndexSigs, t2IndexSigs, context)) { - return false; - } - - return true; - }; - - 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; - } - - if (!sg1 || !sg2) { - return false; - } - - if (sg1.length !== sg2.length) { - return false; - } - - 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; - } - } - - return true; - }; - - 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; - } - - if (tp1 && tp2 && (tp1.length !== tp2.length)) { - return false; - } - - 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) { - var decls1 = symbol1.getDeclarations(); - var decls2 = symbol2.getDeclarations(); - - if (decls1.length && decls2.length) { - return decls1[0] === decls2[0]; - } - - return false; - }; - - PullTypeResolver.prototype.sourceIsSubtypeOfTarget = function (source, target, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - return this.sourceIsRelatableToTarget(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.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.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.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.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.typeIsAssignableToFunction = function (source, ast, context) { - if (source.isFunctionType()) { - return true; - } - - return this.cachedFunctionInterfaceType() && this.sourceIsAssignableToTarget(source, this.cachedFunctionInterfaceType(), ast, context); - }; - - 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.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) { - if (symbol && symbol.isTypeReference()) { - return symbol.getReferencedTypeSymbol(); - } - - return symbol; - }; - - PullTypeResolver.prototype.sourceIsRelatableToTargetInEnclosingTypes = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - source = this.getSymbolForRelationshipCheck(source); - target = this.getSymbolForRelationshipCheck(target); - - if (source === target) { - return true; - } - - if (source && target) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - return this.infinitelyExpandingSourceTypeIsRelatableToTargetType(source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - } - } - - 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); - - if (source === target) { - return true; - } - - if (!(source && target)) { - return true; - } - - var sourceApparentType = this.getApparentType(source); - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(source, target, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - if (source === this.semanticInfoChain.stringTypeSymbol && target.isPrimitive() && target.isStringConstant()) { - return comparisonInfo && comparisonInfo.stringConstantVal && (comparisonInfo.stringConstantVal.kind() === 14 /* StringLiteral */) && (TypeScript.stripStartAndEndQuotes(comparisonInfo.stringConstantVal.text()) === TypeScript.stripStartAndEndQuotes(target.name)); - } - - if (assignableTo) { - if (this.isAnyOrEquivalent(source) || this.isAnyOrEquivalent(target)) { - return true; - } - } else { - if (this.isAnyOrEquivalent(target)) { - return true; - } - } - - if (target === this.semanticInfoChain.stringTypeSymbol && source.isPrimitive() && source.isStringConstant()) { - return true; - } - - if (source.isPrimitive() && source.isStringConstant() && target.isPrimitive() && target.isStringConstant()) { - return TypeScript.stripStartAndEndQuotes(source.name) === TypeScript.stripStartAndEndQuotes(target.name); - } - - if (source === this.semanticInfoChain.undefinedTypeSymbol) { - return true; - } - - 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) { - return true; - } - - return false; - } else if (source === this.semanticInfoChain.voidTypeSymbol) { - if (target === this.semanticInfoChain.anyTypeSymbol) { - return true; - } - - return false; - } - - if (target === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(source)) { - return true; - } - - if (source === this.semanticInfoChain.numberTypeSymbol && TypeScript.PullHelpers.symbolIsEnum(target)) { - return assignableTo; - } - - if (TypeScript.PullHelpers.symbolIsEnum(target) && TypeScript.PullHelpers.symbolIsEnum(source)) { - return this.symbolsShareDeclaration(target, source); - } - - if ((source.kind & 64 /* Enum */) || (target.kind & 64 /* Enum */)) { - return false; - } - - if (source.getIsSpecialized() && target.getIsSpecialized()) { - 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, true); - - for (var i = 0; i < sourceTypeArguments.length; i++) { - if (!this.sourceIsRelatableToTargetWithNewEnclosingTypes(sourceTypeArguments[i], targetTypeArguments[i], assignableTo, comparisonCache, ast, context, null, isComparingInstantiatedSignatures)) { - break; - } - } - - if (i === sourceTypeArguments.length) { - return true; - } else { - comparisonCache.setValueAt(source.pullSymbolID, target.pullSymbolID, undefined); - } - } - } - } - - if (target.isTypeParameter()) { - if (source.isTypeParameter()) { - if (!source.getConstraint()) { - return this.typesAreIdentical(target, source, context); - } else { - return this.isSourceTypeParameterConstrainedToTargetTypeParameter(source, target); - } - } else { - if (isComparingInstantiatedSignatures) { - target = target.getBaseConstraint(this.semanticInfoChain); - } else { - return this.typesAreIdentical(target, sourceApparentType, context); - } - } - } - - 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; - }; - - PullTypeResolver.prototype.sourceMembersAreRelatableToTargetMembers = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetProps = target.getAllMembers(68147712 /* SomeValue */, 0 /* all */); - - for (var itargetProp = 0; itargetProp < targetProps.length; itargetProp++) { - var targetProp = targetProps[itargetProp]; - - var sourceProp = this._getNamedPropertySymbolOfAugmentedType(targetProp.name, source); - - this.resolveDeclaredSymbol(targetProp, context); - - var targetPropType = targetProp.type; - - 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 (!this.sourcePropertyIsRelatableToTargetProperty(source, target, sourceProp, targetProp, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures)) { - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.infinitelyExpandingSourceTypeIsRelatableToTargetType = function (sourceType, targetType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var widenedTargetType = targetType.widenedType(this, null, context); - var widenedSourceType = sourceType.widenedType(this, null, context); - - if ((widenedSourceType !== this.semanticInfoChain.anyTypeSymbol) && (widenedTargetType !== this.semanticInfoChain.anyTypeSymbol)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - - 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_infinitely_expanding_type_reference_do_not_refer_to_same_named_type, [sourceType.getScopedNameEx(enclosingSymbol).toString(), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - comparisonCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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_infinitely_expanding_type_reference_have_incompatible_type_arguments, [sourceType.toString(enclosingSymbol), targetType.toString(enclosingSymbol)])); - } - return false; - } - - var comparisonInfoTypeArgumentsCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoTypeArgumentsCheck = new TypeComparisonInfo(comparisonInfo); - } - 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_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_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, isRelatable); - return isRelatable; - }; - - 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)) { - var sourceTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(sourceType); - var targetTypeNamedTypeReference = TypeScript.PullHelpers.getRootType(targetType); - if (sourceTypeNamedTypeReference !== targetTypeNamedTypeReference) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, false); - return false; - } - - var sourceTypeArguments = sourceType.getTypeArguments(); - var targetTypeArguments = targetType.getTypeArguments(); - - if (!sourceTypeArguments && !targetTypeArguments) { - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - } - - 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++) { - 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; - } - } - } - - this.identicalCache.setValueAt(sourceType.pullSymbolID, targetType.pullSymbolID, true); - return true; - }; - - 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 (comparisonInfo) { - var names = getNames(true); - var code; - if (targetPropIsPrivate) { - 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 { - 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; - } else if (sourcePropIsPrivate && targetPropIsPrivate) { - var targetDecl = targetProp.getDeclarations()[0]; - var sourceDecl = sourceProp.getDeclarations()[0]; - - if (targetDecl !== sourceDecl) { - if (comparisonInfo) { - var names = getNames(true); - - comparisonInfo.flags |= 128 /* InconsistantPropertyAccesibility */; - 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; - } - } - - if (sourceProp.isOptional && !targetProp.isOptional) { - if (comparisonInfo) { - 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, [names.propertyName, names.sourceTypeName, names.targetTypeName])); - } - return false; - } - - this.resolveDeclaredSymbol(sourceProp, context); - - var sourcePropType = sourceProp.type; - var targetPropType = targetProp.type; - - var isRelatableInfo = this.sourceIsRelatableToTargetInCache(sourcePropType, targetPropType, comparisonCache, comparisonInfo); - if (isRelatableInfo) { - return isRelatableInfo.isRelatable; - } - - var comparisonInfoPropertyTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoPropertyTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - context.walkMemberTypes(targetProp.name); - var isSourcePropertyRelatableToTargetProperty = this.sourceIsRelatableToTargetInEnclosingTypes(sourcePropType, targetPropType, assignableTo, comparisonCache, ast, context, comparisonInfoPropertyTypeCheck, isComparingInstantiatedSignatures); - context.postWalkMemberTypes(); - - if (!isSourcePropertyRelatableToTargetProperty && comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - comparisonInfo.flags |= 32 /* IncompatiblePropertyTypes */; - var message; - var names = getNames(false); - if (comparisonInfoPropertyTypeCheck && 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 { - 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 isSourcePropertyRelatableToTargetProperty; - }; - - PullTypeResolver.prototype.sourceCallSignaturesAreRelatableToTargetCallSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetCallSigs = target.getCallSignatures(); - - if (targetCallSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceCallSigs = source.getCallSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceCallSigs, targetCallSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (sourceCallSigs.length && targetCallSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Call_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetCallSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_call_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceConstructSignaturesAreRelatableToTargetConstructSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetConstructSigs = target.getConstructSignatures(); - if (targetConstructSigs.length) { - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - var sourceConstructSigs = source.getConstructSignatures(); - if (!this.signatureGroupIsRelatableToTarget(source, target, sourceConstructSigs, targetConstructSigs, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures)) { - if (comparisonInfo) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - var message; - if (sourceConstructSigs.length && targetConstructSigs.length) { - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Construct_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - } else { - var hasSig = targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - var lacksSig = !targetConstructSigs.length ? target.toString(enclosingSymbol) : source.toString(enclosingSymbol); - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Type_0_requires_a_construct_signature_but_type_1_lacks_one, [hasSig, lacksSig]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.sourceIndexSignaturesAreRelatableToTargetIndexSignatures = function (source, target, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - var targetIndexSigs = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(target, context); - var targetStringSig = targetIndexSigs.stringSignature; - var targetNumberSig = targetIndexSigs.numericSignature; - - if (targetStringSig || targetNumberSig) { - var sourceIndexSigs = this.getBothKindsOfIndexSignaturesIncludingAugmentedType(source, context); - var enclosingTypeIndexSigs = context.getBothKindOfIndexSignatures(true, false); - var sourceStringSig = sourceIndexSigs.stringSignature; - var sourceNumberSig = sourceIndexSigs.numericSignature; - - var comparable = true; - var comparisonInfoSignatuesTypeCheck = null; - if (comparisonInfo && !comparisonInfo.onlyCaptureFirstError) { - comparisonInfoSignatuesTypeCheck = new TypeComparisonInfo(comparisonInfo); - } - - if (targetStringSig) { - if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, true); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetStringSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (comparable && targetNumberSig) { - if (sourceNumberSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, false, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceNumberSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else if (sourceStringSig) { - context.walkIndexSignatureReturnTypes(enclosingTypeIndexSigs, true, false); - comparable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceStringSig.returnType, targetNumberSig.returnType, assignableTo, comparisonCache, ast, context, comparisonInfoSignatuesTypeCheck, isComparingInstantiatedSignatures); - context.postWalkIndexSignatureReturnTypes(); - } else { - comparable = false; - } - } - - if (!comparable) { - if (comparisonInfo) { - var message; - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfoSignatuesTypeCheck && comparisonInfoSignatuesTypeCheck.message) { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfoSignatuesTypeCheck.message]); - } else { - message = TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Index_signatures_of_types_0_and_1_are_incompatible, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)]); - } - comparisonInfo.flags |= 4 /* IncompatibleSignatures */; - comparisonInfo.addMessage(message); - } - return false; - } - } - - return true; - }; - - PullTypeResolver.prototype.signatureGroupIsRelatableToTarget = function (source, target, sourceSG, targetSG, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures) { - if (sourceSG === targetSG) { - return true; - } - - if (!(sourceSG.length && targetSG.length)) { - return false; - } - - 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++) { - var mSig = targetSG[iMSig]; - - if (mSig.isStringConstantOverloadSignature() || (targetExcludeDefinition && mSig.isDefinition())) { - continue; - } - - for (var iNSig = 0; iNSig < sourceSG.length; iNSig++) { - var nSig = sourceSG[iNSig]; - - if (nSig.isStringConstantOverloadSignature() || (sourceExcludeDefinition && nSig.isDefinition())) { - continue; - } - - 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; - } - } - - if (foundMatch) { - foundMatch = false; - continue; - } - - if (comparisonInfo && sigsCompared == 1) { - comparisonInfo.message = comparisonInfoSignatuesTypeCheck.message; - } - - return false; - } - - return true; - }; - - 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; - - if (!sourceParameters || !targetParameters) { - return false; - } - - var targetNonOptionalParamCount = targetSig.nonOptionalParamCount; - var sourceNonOptionalParamCount = sourceSig.nonOptionalParamCount; - - 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, [targetParameters.length])); - } - return false; - } - - if (this.signaturesAreIdentical(sourceSig, targetSig, context)) { - return true; - } - - 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) { - context.walkReturnTypes(); - var returnTypesAreRelatable = this.sourceIsRelatableToTargetInEnclosingTypes(sourceReturnType, targetReturnType, assignableTo, comparisonCache, ast, context, comparisonInfo, isComparingInstantiatedSignatures); - context.postWalkReturnTypes(); - if (!returnTypesAreRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 16 /* IncompatibleReturnTypes */; - } - - return false; - } - } - - 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 (!areParametersRelatable) { - if (comparisonInfo) { - comparisonInfo.flags |= 64 /* IncompatibleParameterTypes */; - } - } - - return areParametersRelatable; - }); - }; - - PullTypeResolver.prototype.resolveOverloads = function (application, group, haveTypeArgumentsAtCallSite, context, diagnostics) { - var _this = this; - var hasOverloads = group.length > 1; - var comparisonInfo = new TypeComparisonInfo(); - var args = application.argumentList ? application.argumentList.arguments : null; - - var initialCandidates = TypeScript.ArrayUtilities.where(group, function (signature) { - if (hasOverloads && signature.isDefinition()) { - return false; - } - - var rootSignature = signature.getRootSymbol(); - if (haveTypeArgumentsAtCallSite && !rootSignature.isGeneric()) { - return false; - } - - return _this.overloadHasCorrectArity(signature, args); - }); - - var firstAssignableButNotSupertypeSignature = null; - var firstAssignableWithProvisionalErrorsSignature = null; - - for (var i = 0; i < initialCandidates.length; i++) { - var applicability = this.overloadIsApplicable(initialCandidates[i], args, context, comparisonInfo); - if (applicability === 3 /* Subtype */) { - return initialCandidates[i]; - } else if (applicability === 2 /* AssignableWithNoProvisionalErrors */ && !firstAssignableButNotSupertypeSignature) { - firstAssignableButNotSupertypeSignature = initialCandidates[i]; - } else if (applicability === 1 /* AssignableButWithProvisionalErrors */ && !firstAssignableWithProvisionalErrorsSignature) { - firstAssignableWithProvisionalErrorsSignature = initialCandidates[i]; - } - } - - if (firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature) { - return firstAssignableButNotSupertypeSignature || firstAssignableWithProvisionalErrorsSignature; - } else { - var target = this.getCallTargetErrorSpanAST(application); - if (comparisonInfo.message) { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target_NL_0, [comparisonInfo.message])); - } else { - diagnostics.push(this.semanticInfoChain.diagnosticFromAST(target, TypeScript.DiagnosticCode.Supplied_parameters_do_not_match_any_signature_of_call_target, null)); - } - } - - return null; - }; - - PullTypeResolver.prototype.getCallTargetErrorSpanAST = function (callEx) { - return (callEx.expression.kind() === 212 /* MemberAccessExpression */) ? callEx.expression.name : callEx.expression; - }; - - PullTypeResolver.prototype.overloadHasCorrectArity = function (signature, args) { - if (args == null) { - return signature.nonOptionalParamCount === 0; - } - - var numberOfArgs = (args.nonSeparatorCount() && args.nonSeparatorCount() === args.separatorCount()) ? args.separatorCount() + 1 : args.nonSeparatorCount(); - if (numberOfArgs < signature.nonOptionalParamCount) { - return false; - } - if (!signature.hasVarArgs && numberOfArgs > signature.parameters.length) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.overloadIsApplicable = function (signature, args, context, comparisonInfo) { - if (args === null) { - return 3 /* Subtype */; - } - - var isInVarArg = false; - var parameters = signature.parameters; - var paramType = null; - - var overloadApplicability = 3 /* Subtype */; - - for (var i = 0; i < args.nonSeparatorCount(); i++) { - if (!isInVarArg) { - this.resolveDeclaredSymbol(parameters[i], context); - - if (parameters[i].isVarArg) { - paramType = parameters[i].type.getElementType() || this.getNewErrorTypeSymbol(parameters[i].type.getName()); - isInVarArg = true; - } else { - paramType = parameters[i].type; - } - } - - var statusOfCurrentArgument = this.overloadIsApplicableForArgument(paramType, args.nonSeparatorAt(i), i, context, comparisonInfo); - - if (statusOfCurrentArgument === 0 /* NotAssignable */) { - return 0 /* NotAssignable */; - } else if (statusOfCurrentArgument === 1 /* AssignableButWithProvisionalErrors */) { - overloadApplicability = 1 /* AssignableButWithProvisionalErrors */; - } else if (overloadApplicability !== 1 /* AssignableButWithProvisionalErrors */ && statusOfCurrentArgument === 2 /* AssignableWithNoProvisionalErrors */) { - overloadApplicability = 2 /* AssignableWithNoProvisionalErrors */; - } - } - - return overloadApplicability; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType.isAny()) { - return 3 /* Subtype */; - } else if (paramType.isError()) { - return 1 /* AssignableButWithProvisionalErrors */; - } else if (arg.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrowFunction = arg; - 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.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.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 */) { - return this.overloadIsApplicableForArrayLiteralArgument(paramType, arg, argIndex, context, comparisonInfo); - } else { - return this.overloadIsApplicableForOtherArgument(paramType, arg, argIndex, context, comparisonInfo); - } - }; - - PullTypeResolver.prototype.overloadIsApplicableForAnyFunctionExpressionArgument = function (paramType, arg, typeParameters, parameters, returnTypeAnnotation, block, bodyExpression, argIndex, context, comparisonInfo) { - if (this.cachedFunctionInterfaceType() && paramType === this.cachedFunctionInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - 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.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForObjectLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (this.cachedObjectInterfaceType() && paramType === this.cachedObjectInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveObjectLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForArrayLiteralArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - if (paramType === this.cachedArrayInterfaceType()) { - return 2 /* AssignableWithNoProvisionalErrors */; - } - - context.pushProvisionalType(paramType); - var argSym = this.resolveArrayLiteralExpression(arg, true, context); - - var applicabilityStatus = this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - - context.popAnyContextualType(); - - return applicabilityStatus; - }; - - PullTypeResolver.prototype.overloadIsApplicableForOtherArgument = function (paramType, arg, argIndex, context, comparisonInfo) { - var argSym = this.resolveAST(arg, false, context); - - if (argSym.type.isAlias()) { - var aliasSym = argSym.type; - argSym = aliasSym.getExportAssignedTypeSymbol(); - } - - comparisonInfo.stringConstantVal = arg; - return this.overloadIsApplicableForArgumentHelper(paramType, argSym.type, argIndex, comparisonInfo, arg, context); - }; - - PullTypeResolver.prototype.overloadIsApplicableForArgumentHelper = function (paramType, argSym, argumentIndex, comparisonInfo, arg, context) { - var tempComparisonInfo = new TypeComparisonInfo(); - tempComparisonInfo.stringConstantVal = comparisonInfo.stringConstantVal; - if (!context.hasProvisionalErrors() && this.sourceIsSubtypeOfTarget(argSym.type, paramType, arg, context, tempComparisonInfo)) { - return 3 /* Subtype */; - } - - if (this.sourceIsAssignableToTarget(argSym.type, paramType, arg, context, comparisonInfo.message ? tempComparisonInfo : comparisonInfo)) { - return context.hasProvisionalErrors() ? 1 /* AssignableButWithProvisionalErrors */ : 2 /* AssignableWithNoProvisionalErrors */; - } - - if (!comparisonInfo.message) { - var enclosingSymbol = this.getEnclosingSymbolForAST(arg); - comparisonInfo.addMessage(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Could_not_apply_type_0_to_argument_1_which_is_of_type_2, [paramType.toString(enclosingSymbol), (argumentIndex + 1), argSym.getTypeName(enclosingSymbol)])); - } - - return 0 /* NotAssignable */; - }; - - PullTypeResolver.prototype.inferArgumentTypesForSignature = function (argContext, comparisonInfo, context) { - var inferenceResultTypes = argContext.inferTypeArguments(); - var typeParameters = argContext.signatureBeingInferred.getTypeParameters(); - TypeScript.Debug.assert(typeParameters.length == inferenceResultTypes.length); - - 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 (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 inferenceResultTypes; - }; - - PullTypeResolver.prototype.typeParametersAreInScopeAtArgumentList = function (typeParameters, args) { - var enclosingDecl = this.getEnclosingDeclForAST(args); - var typeParameterParentDecl = typeParameters[0].getDeclarations()[0].getParentDecl(); - return enclosingDecl.getParentPath().indexOf(typeParameterParentDecl) > -1; - }; - - PullTypeResolver.prototype.relateTypeToTypeParametersInEnclosingType = function (expressionType, parameterType, argContext, context) { - if (expressionType && parameterType) { - if (context.oneOfClassificationsIsInfinitelyExpanding()) { - this.relateInifinitelyExpandingTypeToTypeParameters(expressionType, parameterType, argContext, context); - return; - } - } - this.relateTypeToTypeParameters(expressionType, parameterType, 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; - } - - if (expressionType.isError()) { - expressionType = this.semanticInfoChain.anyTypeSymbol; - } - - if (parameterType.isTypeParameter()) { - var typeParameter = parameterType; - argContext.addCandidateForInference(typeParameter, expressionType); - return; - } - - if (parameterType.isNamedTypeSymbol() && !parameterType.isGeneric() && !parameterType.getTypeArguments()) { - return; - } - - 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.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) { - return; - } - - var expressionTypeTypeArguments = expressionType.getTypeArguments(); - var parameterTypeArguments = parameterType.getTypeArguments(); - - if (expressionTypeTypeArguments && parameterTypeArguments && expressionTypeTypeArguments.length === parameterTypeArguments.length) { - for (var i = 0; i < expressionTypeTypeArguments.length; i++) { - this.relateTypeArgumentsOfTypeToTypeParameters(expressionType, parameterType, argContext, context); - } - } - }; - - PullTypeResolver.prototype.relateFunctionSignatureToTypeParameters = function (expressionSignature, parameterSignature, argContext, context) { - var _this = this; - var expressionReturnType = expressionSignature.returnType; - var parameterReturnType = parameterSignature.returnType; - - parameterSignature.forAllCorrespondingParameterTypesInThisAndOtherSignature(expressionSignature, function (parameterSignatureParameterType, expressionSignatureParameterType, i) { - context.walkParameterTypes(i); - _this.relateTypeToTypeParametersInEnclosingType(expressionSignatureParameterType, parameterSignatureParameterType, argContext, context); - context.postWalkParameterTypes(); - return true; - }); - - context.walkReturnTypes(); - this.relateTypeToTypeParametersInEnclosingType(expressionReturnType, parameterReturnType, argContext, context); - context.postWalkReturnTypes(); - }; - - PullTypeResolver.prototype.relateObjectTypeToTypeParameters = function (objectType, parameterType, argContext, context) { - var parameterTypeMembers = parameterType.getMembers(); - var parameterSignatures; - - var objectMember; - var objectSignatures; - - if (argContext.alreadyRelatingTypes(objectType, parameterType)) { - return; - } - - for (var i = 0; i < parameterTypeMembers.length; i++) { - objectMember = this.getNamedPropertySymbol(parameterTypeMembers[i].name, 68147712 /* SomeValue */, objectType); - if (objectMember) { - this.resolveDeclaredSymbol(objectMember); - this.resolveDeclaredSymbol(parameterTypeMembers[i]); - context.walkMemberTypes(parameterTypeMembers[i].name); - this.relateTypeToTypeParametersInEnclosingType(objectMember.type, parameterTypeMembers[i].type, argContext, context); - context.postWalkMemberTypes(); - } - } - - this.relateSignatureGroupToTypeParameters(objectType.getCallSignatures(), parameterType.getCallSignatures(), 1048576 /* CallSignature */, argContext, context); - - this.relateSignatureGroupToTypeParameters(objectType.getConstructSignatures(), parameterType.getConstructSignatures(), 2097152 /* ConstructSignature */, argContext, 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.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; - } - - 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) { - var typeParameters = typeToSpecialize.getTypeParameters(); - - if (!typeParameters.length) { - return typeToSpecialize; - } - - var typeArguments = null; - - 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) { - typeArguments = this._cachedAnyTypeArgs[typeParameters.length - 1]; - } else { - typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArguments[typeArguments.length] = this.semanticInfoChain.anyTypeSymbol; - } - } - - var type = this.createInstantiatedType(typeToSpecialize, typeArguments); - - 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(); - - var resolver = semanticInfoChain.getResolver(); - var context = new TypeScript.PullTypeResolutionContext(resolver, true, sourceUnit.fileName()); - - if (resolver.canTypeCheckAST(sourceUnit, context)) { - resolver.resolveAST(sourceUnit, false, context); - resolver.validateVariableDeclarationGroups(semanticInfoChain.getDeclForAST(sourceUnit), context); - - while (resolver.typeCheckCallBacks.length) { - var callBack = resolver.typeCheckCallBacks.pop(); - callBack(context); - } - - resolver.processPostTypeCheckWorkItems(context); - } - }; - - PullTypeResolver.prototype.validateVariableDeclarationGroups = function (enclosingDecl, context) { - var _this = this; - this.scanVariableDeclarationGroups(enclosingDecl, function (_) { - }, function (subsequentDecl, firstSymbol) { - if (TypeScript.hasFlag(subsequentDecl.kind, 2048 /* Parameter */) || TypeScript.hasFlag(subsequentDecl.flags, 8388608 /* PropertyParameter */)) { - return; - } - - var boundDeclAST = _this.semanticInfoChain.getASTForDecl(subsequentDecl); - - var symbol = subsequentDecl.getSymbol(); - var symbolType = symbol.type; - var firstSymbolType = firstSymbol.type; - - 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) { - if (!signature) { - var functionSignatureInfo = TypeScript.PullHelpers.getSignatureForFuncDecl(this.semanticInfoChain.getDeclForAST(funcDecl)); - signature = functionSignatureInfo.signature; - allSignatures = functionSignatureInfo.allSignatures; - } - var functionDeclaration = this.semanticInfoChain.getDeclForAST(funcDecl); - var funcSymbol = functionDeclaration.getSymbol(); - - var definitionSignature = null; - for (var i = allSignatures.length - 1; i >= 0; i--) { - if (allSignatures[i].isDefinition()) { - definitionSignature = allSignatures[i]; - break; - } - } - - if (!signature.isDefinition()) { - var signatureParentDecl = signature.getDeclarations()[0].getParentDecl(); - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i] === signature) { - break; - } - - 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)); - } else if (functionDeclaration.kind === 2097152 /* ConstructSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_construct_signature)); - } else if (functionDeclaration.kind === 1048576 /* CallSignature */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_call_signature)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Duplicate_overload_signature_for_0, [funcSymbol.getScopedNameEx().toString()])); - } - - break; - } - } - } - - var isConstantOverloadSignature = signature.isStringConstantOverloadSignature(); - if (isConstantOverloadSignature) { - if (signature.isDefinition()) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_implementation_cannot_use_specialized_type)); - } else { - var foundSubtypeSignature = false; - for (var i = 0; i < allSignatures.length; i++) { - if (allSignatures[i].isDefinition() || allSignatures[i] === signature) { - continue; - } - - if (!allSignatures[i].isResolved) { - this.resolveDeclaredSymbol(allSignatures[i], context); - } - - if (allSignatures[i].isStringConstantOverloadSignature()) { - continue; - } - - 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_assignable_to_any_non_specialized_signature)); - } - } - } else if (definitionSignature && definitionSignature !== signature) { - var comparisonInfo = new TypeComparisonInfo(); - - if (!definitionSignature.isResolved) { - this.resolveDeclaredSymbol(definitionSignature, context); - } - - if (!this.signatureIsAssignableToTarget(definitionSignature, signature, funcDecl, context, comparisonInfo)) { - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition_NL_0, [comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, TypeScript.DiagnosticCode.Overload_signature_is_not_compatible_with_function_definition)); - } - } - } - - var signatureForVisibilityCheck = definitionSignature; - if (!definitionSignature) { - if (allSignatures[0] === signature) { - return; - } - signatureForVisibilityCheck = allSignatures[0]; - } - - if (funcDecl.kind() !== 137 /* ConstructorDeclaration */ && functionDeclaration.kind !== 2097152 /* ConstructSignature */ && signatureForVisibilityCheck && signature !== signatureForVisibilityCheck) { - var errorCode; - - 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_exported_or_not_exported; - } 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 */)) { - errorCode = TypeScript.DiagnosticCode.Overload_signatures_must_all_be_optional_or_required; - } - - if (errorCode) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(funcDecl, errorCode)); - } - } - }; - - PullTypeResolver.prototype.checkSymbolPrivacy = function (declSymbol, symbol, privacyErrorReporter) { - if (!symbol || symbol.kind === 2 /* Primitive */) { - return; - } - - if (symbol.isType()) { - var typeSymbol = symbol; - var isNamedType = typeSymbol.isNamedTypeSymbol(); - - if (typeSymbol.isArrayNamedTypeReference()) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getElementType(), privacyErrorReporter); - return; - } - - if (!isNamedType) { - var typeOfSymbol = typeSymbol.getTypeOfSymbol(); - if (typeOfSymbol) { - this.checkSymbolPrivacy(declSymbol, typeOfSymbol, privacyErrorReporter); - return; - } - } - - if (typeSymbol.inSymbolPrivacyCheck) { - return; - } - - typeSymbol.inSymbolPrivacyCheck = true; - - var typars = typeSymbol.getTypeArgumentsOrTypeParameters(); - if (typars) { - for (var i = 0; i < typars.length; i++) { - this.checkSymbolPrivacy(declSymbol, typars[i], privacyErrorReporter); - } - } - - if (!isNamedType) { - var members = typeSymbol.getMembers(); - for (var i = 0; i < members.length; i++) { - this.checkSymbolPrivacy(declSymbol, members[i].type, privacyErrorReporter); - } - - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getCallSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getConstructSignatures(), privacyErrorReporter); - this.checkTypePrivacyOfSignatures(declSymbol, typeSymbol.getIndexSignatures(), privacyErrorReporter); - } else if (typeSymbol.kind === 8192 /* TypeParameter */) { - this.checkSymbolPrivacy(declSymbol, typeSymbol.getConstraint(), privacyErrorReporter); - } - - typeSymbol.inSymbolPrivacyCheck = false; - - if (!isNamedType) { - return; - } - } - - if (declSymbol.isExternallyVisible()) { - var symbolIsVisible = symbol.isExternallyVisible(); - - 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]) { - 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(); - break; - } - } - symbol = symbolPath[symbolPath.length - 1]; - } - } else if (symbol.kind === 128 /* TypeAlias */) { - var aliasSymbol = symbol; - symbolIsVisible = true; - aliasSymbol.setTypeUsedExternally(); - } - - if (!symbolIsVisible) { - privacyErrorReporter(symbol); - } - } - }; - - PullTypeResolver.prototype.checkTypePrivacyOfSignatures = function (declSymbol, signatures, privacyErrorReporter) { - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (signatures.length > 1 && signature.isDefinition()) { - continue; - } - - var typeParams = signature.getTypeParameters(); - for (var j = 0; j < typeParams.length; j++) { - this.checkSymbolPrivacy(declSymbol, typeParams[j], privacyErrorReporter); - } - - var params = signature.parameters; - for (var j = 0; j < params.length; j++) { - var paramType = params[j].type; - this.checkSymbolPrivacy(declSymbol, paramType, privacyErrorReporter); - } - - var returnType = signature.returnType; - this.checkSymbolPrivacy(declSymbol, returnType, privacyErrorReporter); - } - }; - - 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; - var messageCode; - - var typeParameters = classOrInterface.kind() === 131 /* ClassDeclaration */ ? classOrInterface.typeParameterList : classOrInterface.typeParameterList; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_interface_has_or_is_using_private_type_1; - } - } - - var messageArguments = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.baseListPrivacyErrorReporter = function (classOrInterface, declSymbol, baseAst, isExtendedType, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(classOrInterface); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - var messageCode; - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_class_from_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_interface_from_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_interface_from_inaccessible_module_1; - } - } else { - if (classOrInterface.kind() === 131 /* ClassDeclaration */) { - if (isExtendedType) { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_extends_private_class_1; - } else { - messageCode = TypeScript.DiagnosticCode.Exported_class_0_implements_private_interface_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_interface_0_extends_private_interface_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseAst, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.variablePrivacyErrorReporter = function (declAST, declSymbol, symbol, context) { - var typeSymbol = symbol; - var enclosingDecl = this.getEnclosingDecl(declSymbol.getDeclarations()[0]); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isProperty = declSymbol.kind === 4096 /* Property */; - var isPropertyOfClass = false; - var declParent = declSymbol.getContainer(); - if (declParent && (declParent.kind === 8 /* Class */ || declParent.kind === 32768 /* ConstructorMethod */)) { - isPropertyOfClass = true; - } - - var messageCode; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_is_using_inaccessible_module_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_is_using_inaccessible_module_1; - } - } else { - if (declSymbol.anyDeclHasFlag(16 /* Static */)) { - messageCode = TypeScript.DiagnosticCode.Public_static_property_0_of_exported_class_has_or_is_using_private_type_1; - } else if (isProperty) { - if (isPropertyOfClass) { - messageCode = TypeScript.DiagnosticCode.Public_property_0_of_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Property_0_of_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.Exported_variable_0_has_or_is_using_private_type_1; - } - } - - var messageArguments = [declSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - }; - - PullTypeResolver.prototype.checkFunctionTypePrivacy = function (funcDeclAST, isStatic, typeParameters, parameters, returnTypeAnnotation, block, context) { - var _this = this; - if (funcDeclAST.kind() === 222 /* FunctionExpression */ || funcDeclAST.kind() === 241 /* FunctionPropertyAssignment */ || (funcDeclAST.kind() === 139 /* GetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */) || (funcDeclAST.kind() === 140 /* SetAccessor */ && funcDeclAST.parent.parent.kind() === 215 /* ObjectLiteralExpression */)) { - return; - } - - var functionDecl = this.semanticInfoChain.getDeclForAST(funcDeclAST); - var functionSymbol = functionDecl.getSymbol(); - ; - var functionSignature; - - var isGetter = funcDeclAST.kind() === 139 /* GetAccessor */; - var isSetter = funcDeclAST.kind() === 140 /* SetAccessor */; - var isIndexSignature = functionDecl.kind === 4194304 /* IndexSignature */; - - if (isGetter || isSetter) { - var accessorSymbol = functionSymbol; - functionSignature = (isGetter ? accessorSymbol.getGetter() : accessorSymbol.getSetter()).type.getCallSignatures()[0]; - } else { - if (!functionSymbol) { - var parentDecl = functionDecl.getParentDecl(); - functionSymbol = parentDecl.getSymbol(); - if (functionSymbol && functionSymbol.isType() && !functionSymbol.isNamedTypeSymbol()) { - return; - } - } else if (functionSymbol.kind === 65536 /* Method */ && !isStatic && !functionSymbol.getContainer().isNamedTypeSymbol()) { - return; - } - functionSignature = functionDecl.getSignatureSymbol(); - } - - if (typeParameters && !isGetter && !isSetter && !isIndexSignature && funcDeclAST.kind() !== 137 /* ConstructorDeclaration */) { - for (var i = 0; i < typeParameters.typeParameters.nonSeparatorCount(); i++) { - var typeParameterAST = typeParameters.typeParameters.nonSeparatorAt(i); - var typeParameter = this.resolveTypeParameterDeclaration(typeParameterAST, context); - this.checkSymbolPrivacy(functionSymbol, typeParameter, function (symbol) { - return _this.functionTypeArgumentArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, typeParameterAST, typeParameter, symbol, context); - }); - } - } - - if (!isGetter && !isIndexSignature) { - var funcParams = functionSignature.parameters; - for (var i = 0; i < funcParams.length; i++) { - this.checkSymbolPrivacy(functionSymbol, funcParams[i].type, function (symbol) { - return _this.functionArgumentTypePrivacyErrorReporter(funcDeclAST, isStatic, parameters, i, funcParams[i], symbol, context); - }); - } - } - - if (!isSetter) { - this.checkSymbolPrivacy(functionSymbol, functionSignature.returnType, function (symbol) { - return _this.functionReturnTypePrivacyErrorReporter(funcDeclAST, isStatic, returnTypeAnnotation, block, functionSignature.returnType, symbol, context); - }); - } - }; - - PullTypeResolver.prototype.functionTypeArgumentArgumentTypePrivacyErrorReporter = function (declAST, isStatic, typeParameterAST, typeParameter, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else { - messageCode = TypeScript.DiagnosticCode.TypeParameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var messageArgs = [typeParameter.getScopedName(enclosingSymbol, false, true), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(typeParameterAST, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionArgumentTypePrivacyErrorReporter = function (declAST, isStatic, parameters, argIndex, paramSymbol, symbol, context) { - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - var enclosingSymbol = enclosingDecl ? enclosingDecl.getSymbol() : null; - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingSymbol); - var messageCode; - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_is_using_inaccessible_module_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_is_using_inaccessible_module_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_is_using_inaccessible_module_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_is_using_inaccessible_module_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_is_using_inaccessible_module_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_is_using_inaccessible_module_1; - } - } else if (!isGetter) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_is_using_inaccessible_module_1; - } - } else { - if (declAST.kind() === 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_type_1; - } else if (isSetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_type_1; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_type_1; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_type_1; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_type_1; - } else { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_type_1; - } - } else if (!isGetter && decl.kind !== 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Parameter_0_of_exported_function_has_or_is_using_private_type_1; - } - } - - if (messageCode) { - var parameter = parameters.astAt(argIndex); - - var messageArgs = [paramSymbol.getScopedName(enclosingSymbol), typeSymbolName]; - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(parameter, messageCode, messageArgs)); - } - }; - - PullTypeResolver.prototype.functionReturnTypePrivacyErrorReporter = function (declAST, isStatic, returnTypeAnnotation, block, funcReturnType, symbol, context) { - var _this = this; - var decl = this.semanticInfoChain.getDeclForAST(declAST); - var enclosingDecl = this.getEnclosingDecl(decl); - - var isGetter = declAST.kind() === 139 /* GetAccessor */; - var isSetter = declAST.kind() === 140 /* SetAccessor */; - var isMethod = decl.kind === 65536 /* Method */; - var isMethodOfClass = false; - var declParent = decl.getParentDecl(); - if (declParent && (declParent.kind === 8 /* Class */ || isStatic)) { - isMethodOfClass = true; - } - - var messageCode = null; - var typeSymbol = symbol; - var typeSymbolName = typeSymbol.getScopedName(enclosingDecl ? enclosingDecl.getSymbol() : null); - if (typeSymbol.isContainer() && !typeSymbol.isEnum()) { - if (!TypeScript.isQuoted(typeSymbolName)) { - typeSymbolName = "'" + typeSymbolName + "'"; - } - - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_is_using_inaccessible_module_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_is_using_inaccessible_module_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_is_using_inaccessible_module_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_is_using_inaccessible_module_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_is_using_inaccessible_module_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_is_using_inaccessible_module_0; - } - } else { - if (isGetter) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_type_0; - } - } else if (decl.kind === 2097152 /* ConstructSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 1048576 /* CallSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (decl.kind === 4194304 /* IndexSignature */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_type_0; - } else if (isMethod) { - if (isStatic) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_type_0; - } else if (isMethodOfClass) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_public_method_from_exported_class_has_or_is_using_private_type_0; - } else { - messageCode = TypeScript.DiagnosticCode.Return_type_of_method_from_exported_interface_has_or_is_using_private_type_0; - } - } else if (!isSetter && declAST.kind() !== 137 /* ConstructorDeclaration */) { - messageCode = TypeScript.DiagnosticCode.Return_type_of_exported_function_has_or_is_using_private_type_0; - } - } - - if (messageCode) { - var messageArguments = [typeSymbolName]; - var reportOnFuncDecl = false; - - if (returnTypeAnnotation) { - var returnExpressionSymbol = this.resolveTypeReference(returnTypeAnnotation, context); - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(returnTypeAnnotation, messageCode, messageArguments)); - } - } - - if (block) { - var reportErrorOnReturnExpressions = function (ast, walker) { - var go = true; - switch (ast.kind()) { - case 129 /* FunctionDeclaration */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - case 222 /* FunctionExpression */: - go = false; - break; - - case 150 /* ReturnStatement */: - var returnStatement = ast; - var returnExpressionSymbol = _this.resolveAST(returnStatement.expression, false, context).type; - - if (TypeScript.PullHelpers.typeSymbolsAreIdentical(returnExpressionSymbol, funcReturnType)) { - context.postDiagnostic(_this.semanticInfoChain.diagnosticFromAST(returnStatement, messageCode, messageArguments)); - } else { - reportOnFuncDecl = true; - } - go = false; - break; - - default: - break; - } - - walker.options.goChildren = go; - return ast; - }; - - TypeScript.getAstWalkerFactory().walk(block, reportErrorOnReturnExpressions); - } - - if (reportOnFuncDecl) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(declAST, messageCode, messageArguments)); - } - } - }; - - PullTypeResolver.prototype.enclosingClassIsDerived = function (classDecl) { - TypeScript.Debug.assert(classDecl.kind === 8 /* Class */); - - var classSymbol = classDecl.getSymbol(); - return classSymbol.getExtendedTypes().length > 0; - }; - - PullTypeResolver.prototype.isSuperInvocationExpression = function (ast) { - if (ast.kind() === 213 /* InvocationExpression */) { - var invocationExpression = ast; - if (invocationExpression.expression.kind() === 50 /* SuperKeyword */) { - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.isSuperInvocationExpressionStatement = function (node) { - if (node && node.kind() === 149 /* ExpressionStatement */) { - var expressionStatement = node; - if (this.isSuperInvocationExpression(expressionStatement.expression)) { - return true; - } - } - return false; - }; - - PullTypeResolver.prototype.getFirstStatementOfBlockOrNull = function (block) { - if (block && block.statements && block.statements.childCount() > 0) { - return block.statements.childAt(0); - } - - return null; - }; - - PullTypeResolver.prototype.superCallMustBeFirstStatementInConstructor = function (constructorDecl) { - TypeScript.Debug.assert(constructorDecl.kind === 32768 /* ConstructorMethod */); - - if (constructorDecl) { - var enclosingClass = constructorDecl.getParentDecl(); - - var classSymbol = enclosingClass.getSymbol(); - if (classSymbol.getExtendedTypes().length === 0) { - return false; - } - - var classMembers = classSymbol.getMembers(); - for (var i = 0, n1 = classMembers.length; i < n1; i++) { - var member = classMembers[i]; - - if (member.kind === 4096 /* Property */) { - var declarations = member.getDeclarations(); - for (var j = 0, n2 = declarations.length; j < n2; j++) { - var declaration = declarations[j]; - var ast = this.semanticInfoChain.getASTForDecl(declaration); - if (ast.kind() === 242 /* Parameter */) { - return true; - } - - if (ast.kind() === 136 /* MemberVariableDeclaration */) { - var variableDeclarator = ast; - if (variableDeclarator.variableDeclarator.equalsValueClause) { - return true; - } - } - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkForThisCaptureInArrowFunction = function (expression) { - var enclosingDecl = this.getEnclosingDeclForAST(expression); - - var declPath = enclosingDecl.getParentPath(); - - if (declPath.length) { - var inArrowFunction = false; - for (var i = declPath.length - 1; i >= 0; i--) { - var decl = declPath[i]; - var declKind = decl.kind; - var declFlags = decl.flags; - - if (declKind === 131072 /* FunctionExpression */ && TypeScript.hasFlag(declFlags, 8192 /* ArrowFunction */)) { - inArrowFunction = true; - continue; - } - - if (inArrowFunction) { - if (declKind === 16384 /* Function */ || declKind === 65536 /* Method */ || declKind === 32768 /* ConstructorMethod */ || declKind === 262144 /* GetAccessor */ || declKind === 524288 /* SetAccessor */ || declKind === 131072 /* FunctionExpression */ || declKind === 8 /* Class */ || declKind === 4 /* Container */ || declKind === 32 /* DynamicModule */ || declKind === 1 /* Script */) { - decl.setFlags(decl.flags | 262144 /* MustCaptureThis */); - - if (declKind === 8 /* Class */) { - var constructorSymbol = decl.getSymbol().getConstructorMethod(); - var constructorDecls = constructorSymbol.getDeclarations(); - for (var i = 0; i < constructorDecls.length; i++) { - constructorDecls[i].flags = constructorDecls[i].flags | 262144 /* MustCaptureThis */; - } - } - break; - } - } else if (declKind === 16384 /* Function */ || declKind === 131072 /* FunctionExpression */) { - break; - } - } - } - }; - - PullTypeResolver.prototype.typeCheckMembersAgainstIndexer = function (containerType, containerTypeDecl, context) { - var indexSignatures = this.getBothKindsOfIndexSignaturesExcludingAugmentedType(containerType, context); - var stringSignature = indexSignatures.stringSignature; - var numberSignature = indexSignatures.numericSignature; - - if (stringSignature || numberSignature) { - var members = containerTypeDecl.getChildDecls(); - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if ((member.name || (member.kind === 4096 /* Property */ && member.name === "")) && member.kind !== 32768 /* ConstructorMethod */ && !TypeScript.hasFlag(member.flags, 16 /* Static */)) { - var memberSymbol = member.getSymbol(); - var relevantSignature = this.determineRelevantIndexerForMember(memberSymbol, numberSignature, stringSignature); - if (relevantSignature) { - var comparisonInfo = new TypeComparisonInfo(); - if (!this.sourceIsAssignableToTarget(memberSymbol.type, relevantSignature.returnType, member.ast(), context, comparisonInfo)) { - this.reportErrorThatMemberIsNotSubtypeOfIndexer(memberSymbol, relevantSignature, member.ast(), context, comparisonInfo); - } - } - } - } - } - }; - - PullTypeResolver.prototype.determineRelevantIndexerForMember = function (member, numberIndexSignature, stringIndexSignature) { - if (numberIndexSignature && TypeScript.PullHelpers.isNameNumeric(member.name)) { - return numberIndexSignature; - } else if (stringIndexSignature) { - return stringIndexSignature; - } - - return null; - }; - - PullTypeResolver.prototype.reportErrorThatMemberIsNotSubtypeOfIndexer = function (member, indexSignature, astForError, context, comparisonInfo) { - 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_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_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_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_assignable_to_string_indexer_type_0, [indexSignature.returnType.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.typeCheckIfTypeMemberPropertyOkToOverride = function (typeSymbol, extendedType, typeMember, extendedTypeMember, enclosingDecl, comparisonInfo) { - if (!typeSymbol.isClass()) { - return true; - } - - var typeMemberKind = typeMember.kind; - var extendedMemberKind = extendedTypeMember.kind; - - if (typeMemberKind === extendedMemberKind) { - return true; - } - - var errorCode; - if (typeMemberKind === 4096 /* Property */) { - if (typeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - } else if (typeMemberKind === 65536 /* Method */) { - if (extendedTypeMember.isAccessor()) { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } else { - errorCode = TypeScript.DiagnosticCode.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - - var message = TypeScript.getDiagnosticMessage(errorCode, [typeSymbol.toString(), typeMember.getScopedNameEx().toString(), extendedType.toString()]); - comparisonInfo.addMessage(message); - return false; - }; - - PullTypeResolver.prototype.typeCheckIfTypeExtendsType = function (classOrInterface, name, typeSymbol, extendedType, enclosingDecl, context) { - var typeMembers = typeSymbol.getMembers(); - - var comparisonInfo = new TypeComparisonInfo(); - var foundError = false; - var foundError1 = false; - var foundError2 = false; - - for (var i = 0; i < typeMembers.length; i++) { - var propName = typeMembers[i].name; - var extendedTypeProp = extendedType.findMember(propName, true); - if (extendedTypeProp) { - this.resolveDeclaredSymbol(extendedTypeProp, context); - foundError1 = !this.typeCheckIfTypeMemberPropertyOkToOverride(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, enclosingDecl, comparisonInfo); - - if (!foundError1) { - foundError2 = !this.sourcePropertyIsAssignableToTargetProperty(typeSymbol, extendedType, typeMembers[i], extendedTypeProp, classOrInterface, context, comparisonInfo); - } - - if (foundError1 || foundError2) { - foundError = true; - break; - } - } - } - - if (!foundError && typeSymbol.hasOwnCallSignatures()) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnConstructSignatures()) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.hasOwnIndexSignatures()) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(typeSymbol, extendedType, classOrInterface, context, comparisonInfo); - } - - if (!foundError && typeSymbol.isClass()) { - var typeConstructorType = typeSymbol.getConstructorMethod().type; - var typeConstructorTypeMembers = typeConstructorType.getMembers(); - if (typeConstructorTypeMembers.length) { - var extendedConstructorType = extendedType.getConstructorMethod().type; - var comparisonInfoForPropTypeCheck = new TypeComparisonInfo(comparisonInfo); - - for (var i = 0; i < typeConstructorTypeMembers.length; i++) { - var propName = typeConstructorTypeMembers[i].name; - var extendedConstructorTypeProp = extendedConstructorType.findMember(propName, true); - if (extendedConstructorTypeProp) { - if (!extendedConstructorTypeProp.isResolved) { - this.resolveDeclaredSymbol(extendedConstructorTypeProp, context); - } - - if (!this.sourcePropertyIsAssignableToTargetProperty(typeConstructorType, extendedConstructorType, typeConstructorTypeMembers[i], extendedConstructorTypeProp, classOrInterface, context, comparisonInfo)) { - foundError = true; - break; - } - } - } - } - } - - if (foundError) { - var errorCode; - if (typeSymbol.isClass()) { - errorCode = TypeScript.DiagnosticCode.Class_0_cannot_extend_class_1_NL_2; - } else { - if (extendedType.isClass()) { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_class_1_NL_2; - } else { - errorCode = TypeScript.DiagnosticCode.Interface_0_cannot_extend_interface_1_NL_2; - } - } - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, errorCode, [typeSymbol.getScopedName(), extendedType.getScopedName(), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.typeCheckIfClassImplementsType = function (classDecl, classSymbol, implementedType, enclosingDecl, context) { - var comparisonInfo = new TypeComparisonInfo(); - var foundError = !this.sourceMembersAreAssignableToTargetMembers(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceCallSignaturesAreAssignableToTargetCallSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceConstructSignaturesAreAssignableToTargetConstructSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - if (!foundError) { - foundError = !this.sourceIndexSignaturesAreAssignableToTargetIndexSignatures(classSymbol, implementedType, classDecl, context, comparisonInfo); - } - } - } - - if (foundError) { - var enclosingSymbol = this.getEnclosingSymbolForAST(classDecl); - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(classDecl.identifier, TypeScript.DiagnosticCode.Class_0_declares_interface_1_but_does_not_implement_it_NL_2, [classSymbol.getScopedName(enclosingSymbol), implementedType.getScopedName(enclosingSymbol), comparisonInfo.message])); - } - }; - - PullTypeResolver.prototype.computeValueSymbolFromAST = function (valueDeclAST, context) { - var prevInTypeCheck = context.inTypeCheck; - context.inTypeCheck = false; - - var typeSymbolAlias = this.semanticInfoChain.getAliasSymbolForAST(valueDeclAST); - - 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; - } - - if (!valueSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */)) { - return true; - } - - var associatedContainerType = valueSymbol.type ? valueSymbol.type.getAssociatedContainerType() : null; - - if (associatedContainerType) { - return associatedContainerType !== typeSymbol.getRootSymbol(); - } - - return true; - }; - - PullTypeResolver.prototype.typeCheckBase = function (classOrInterface, name, typeSymbol, baseDeclAST, isExtendedType, enclosingDecl, context) { - var _this = this; - var typeDecl = this.semanticInfoChain.getDeclForAST(classOrInterface); - - var baseType = this.resolveTypeReference(baseDeclAST, context).type; - - if (!baseType) { - return; - } - - var typeDeclIsClass = typeSymbol.isClass(); - - if (!typeSymbol.isValidBaseKind(baseType, isExtendedType)) { - if (!baseType.isError()) { - if (isExtendedType) { - if (typeDeclIsClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_extend_another_class)); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.An_interface_may_only_extend_another_class_or_interface)); - } - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(baseDeclAST, TypeScript.DiagnosticCode.A_class_may_only_implement_another_class_or_interface)); - } - } - return; - } else if (typeDeclIsClass && isExtendedType) { - if (this.hasClassTypeSymbolConflictAsValue(baseDeclAST, baseType, enclosingDecl, context)) { - 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)])); - } - } - - if (baseType.hasBase(typeSymbol)) { - typeSymbol.setHasBaseTypeConflict(); - baseType.setHasBaseTypeConflict(); - - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, typeDeclIsClass ? TypeScript.DiagnosticCode.Class_0_is_recursively_referenced_as_a_base_type_of_itself : TypeScript.DiagnosticCode.Interface_0_is_recursively_referenced_as_a_base_type_of_itself, [typeSymbol.getScopedName()])); - return; - } - - if (isExtendedType) { - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfTypeExtendsType(classOrInterface, name, typeSymbol, baseType, enclosingDecl, context); - }); - } else { - TypeScript.Debug.assert(classOrInterface.kind() === 131 /* ClassDeclaration */); - - this.typeCheckCallBacks.push(function (context) { - return _this.typeCheckIfClassImplementsType(classOrInterface, typeSymbol, baseType, enclosingDecl, context); - }); - } - - this.checkSymbolPrivacy(typeSymbol, baseType, function (errorSymbol) { - return _this.baseListPrivacyErrorReporter(classOrInterface, typeSymbol, baseDeclAST, isExtendedType, errorSymbol, context); - }); - }; - - PullTypeResolver.prototype.typeCheckBases = function (classOrInterface, name, heritageClauses, typeSymbol, enclosingDecl, context) { - var _this = this; - var extendsClause = TypeScript.ASTHelpers.getExtendsHeritageClause(heritageClauses); - var implementsClause = TypeScript.ASTHelpers.getImplementsHeritageClause(heritageClauses); - if (!extendsClause && !implementsClause) { - return; - } - - if (extendsClause) { - for (var i = 0; i < extendsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, extendsClause.typeNames.nonSeparatorAt(i), true, enclosingDecl, context); - } - } - - if (typeSymbol.isClass()) { - if (implementsClause) { - for (var i = 0; i < implementsClause.typeNames.nonSeparatorCount(); i++) { - this.typeCheckBase(classOrInterface, name, typeSymbol, implementsClause.typeNames.nonSeparatorAt(i), false, enclosingDecl, context); - } - } - } else if (extendsClause && !typeSymbol.hasBaseTypeConflict() && typeSymbol.getExtendedTypes().length > 1) { - var firstInterfaceASTWithExtendsClause = TypeScript.ArrayUtilities.firstOrDefault(typeSymbol.getDeclarations(), function (decl) { - return decl.ast().heritageClauses !== null; - }).ast(); - if (classOrInterface === firstInterfaceASTWithExtendsClause) { - this.typeCheckCallBacks.push(function (context) { - _this.checkTypeCompatibilityBetweenBases(classOrInterface.identifier, typeSymbol, context); - }); - } - } - }; - - PullTypeResolver.prototype.checkTypeCompatibilityBetweenBases = function (name, typeSymbol, context) { - var derivedIndexSignatures = typeSymbol.getOwnIndexSignatures(); - - var inheritedMembersMap = TypeScript.createIntrinsicsObject(); - var inheritedIndexSignatures = new InheritedIndexSignatureInfo(); - - var typeHasOwnNumberIndexer = false; - var typeHasOwnStringIndexer = false; - - if (typeSymbol.hasOwnIndexSignatures()) { - var ownIndexSignatures = typeSymbol.getOwnIndexSignatures(); - for (var i = 0; i < ownIndexSignatures.length; i++) { - if (ownIndexSignatures[i].parameters[0].type === this.semanticInfoChain.numberTypeSymbol) { - typeHasOwnNumberIndexer = true; - } else { - typeHasOwnStringIndexer = true; - } - } - } - var baseTypes = typeSymbol.getExtendedTypes(); - for (var i = 0; i < baseTypes.length; i++) { - if (this.checkNamedPropertyIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedMembersMap, context) || this.checkIndexSignatureIdentityBetweenBases(name, typeSymbol, baseTypes[i], inheritedIndexSignatures, typeHasOwnNumberIndexer, typeHasOwnStringIndexer, context)) { - return; - } - } - - if (this.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature(name, typeSymbol, inheritedIndexSignatures, context)) { - return; - } - - this.checkInheritedMembersAgainstInheritedIndexSignatures(name, typeSymbol, inheritedIndexSignatures, 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]; - var memberName = member.name; - - if (interfaceSymbol.findMember(memberName, false)) { - continue; - } - - this.resolveDeclaredSymbol(member, context); - - if (inheritedMembersMap[memberName]) { - var prevMember = inheritedMembersMap[memberName]; - 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; - } - } else { - inheritedMembersMap[memberName] = new MemberWithBaseOrigin(member, baseTypeSymbol); - } - } - - return false; - }; - - PullTypeResolver.prototype.checkIndexSignatureIdentityBetweenBases = function (interfaceName, interfaceSymbol, baseTypeSymbol, allInheritedSignatures, derivedTypeHasOwnNumberSignature, derivedTypeHasOwnStringSignature, context) { - if (derivedTypeHasOwnNumberSignature && derivedTypeHasOwnStringSignature) { - return false; - } - - var indexSignaturesFromThisBaseType = baseTypeSymbol.getIndexSignatures(); - for (var i = 0; i < indexSignaturesFromThisBaseType.length; i++) { - var currentInheritedSignature = indexSignaturesFromThisBaseType[i]; - - var parameterTypeIsString = currentInheritedSignature.parameters[0].type === this.semanticInfoChain.stringTypeSymbol; - 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, 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; - } - } else { - allInheritedSignatures.stringSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } else if (parameterTypeIsNumber) { - if (allInheritedSignatures.numberSignatureWithBaseOrigin) { - 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; - } - } else { - allInheritedSignatures.numberSignatureWithBaseOrigin = new SignatureWithBaseOrigin(currentInheritedSignature, baseTypeSymbol); - } - } - } - - return false; - }; - - PullTypeResolver.prototype.checkInheritedMembersAgainstInheritedIndexSignatures = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, inheritedMembers, context) { - if (!inheritedIndexSignatures.stringSignatureWithBaseOrigin && !inheritedIndexSignatures.numberSignatureWithBaseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - var stringSignature = inheritedIndexSignatures.stringSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin.signature; - var numberSignature = inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.numberSignatureWithBaseOrigin.signature; - for (var memberName in inheritedMembers) { - var memberWithBaseOrigin = inheritedMembers[memberName]; - if (!memberWithBaseOrigin) { - continue; - } - - var relevantSignature = this.determineRelevantIndexerForMember(memberWithBaseOrigin.memberSymbol, numberSignature, stringSignature); - if (!relevantSignature) { - continue; - } - - var relevantSignatureIsNumberSignature = relevantSignature.parameters[0].type === this.semanticInfoChain.numberTypeSymbol; - var signatureBaseOrigin = relevantSignatureIsNumberSignature ? inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin : inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin; - - if (signatureBaseOrigin === memberWithBaseOrigin.baseOrigin) { - continue; - } - - 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_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_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])); - } - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkThatInheritedNumberSignatureIsSubtypeOfInheritedStringSignature = function (interfaceName, interfaceSymbol, inheritedIndexSignatures, context) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin && inheritedIndexSignatures.stringSignatureWithBaseOrigin) { - if (inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin === inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin) { - return false; - } - - var comparisonInfo = new TypeComparisonInfo(); - 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_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, [ - interfaceSymbol.getDisplayName(enclosingSymbol), inheritedIndexSignatures.numberSignatureWithBaseOrigin.baseOrigin.getScopedName(), - inheritedIndexSignatures.stringSignatureWithBaseOrigin.baseOrigin.getScopedName(enclosingSymbol), innerDiagnostic])); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.checkAssignability = function (ast, source, target, context) { - var comparisonInfo = new TypeComparisonInfo(); - - var isAssignable = this.sourceIsAssignableToTarget(source, target, ast, context, comparisonInfo); - - if (!isAssignable) { - var enclosingSymbol = this.getEnclosingSymbolForAST(ast); - if (comparisonInfo.message) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1_NL_2, [source.toString(enclosingSymbol), target.toString(enclosingSymbol), comparisonInfo.message])); - } else { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(ast, TypeScript.DiagnosticCode.Cannot_convert_0_to_1, [source.toString(enclosingSymbol), target.toString(enclosingSymbol)])); - } - } - }; - - PullTypeResolver.prototype.isReference = function (ast, astSymbol) { - if (ast.kind() === 217 /* ParenthesizedExpression */) { - return this.isReference(ast.expression, astSymbol); - } - - if (ast.kind() !== 11 /* IdentifierName */ && ast.kind() !== 212 /* MemberAccessExpression */ && ast.kind() !== 221 /* ElementAccessExpression */) { - return false; - } - - if (ast.kind() === 11 /* IdentifierName */) { - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(4096 /* Enum */)) { - return false; - } - - if (astSymbol.kind === 512 /* Variable */ && astSymbol.anyDeclHasFlag(102400 /* SomeInitializedModule */)) { - return false; - } - - if (astSymbol.kind === 32768 /* ConstructorMethod */ || astSymbol.kind === 16384 /* Function */) { - return false; - } - } - - if (ast.kind() === 212 /* MemberAccessExpression */ && astSymbol.kind === 67108864 /* EnumMember */) { - return false; - } - - return true; - }; - - PullTypeResolver.prototype.checkForSuperMemberAccess = function (expression, name, resolvedName, context) { - if (resolvedName) { - if (expression.kind() === 50 /* SuperKeyword */ && !resolvedName.isError() && resolvedName.kind !== 65536 /* Method */) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword)); - return true; - } - } - - return false; - }; - - PullTypeResolver.prototype.getEnclosingDeclForAST = function (ast) { - return this.semanticInfoChain.getEnclosingDecl(ast); - }; - - PullTypeResolver.prototype.getEnclosingSymbolForAST = function (ast) { - var enclosingDecl = this.getEnclosingDeclForAST(ast); - return enclosingDecl ? enclosingDecl.getSymbol() : null; - }; - - PullTypeResolver.prototype.checkForPrivateMemberAccess = function (name, expressionType, resolvedName, context) { - if (resolvedName) { - if (resolvedName.anyDeclHasFlag(2 /* Private */)) { - var memberContainer = resolvedName.getContainer(); - if (memberContainer && memberContainer.kind === 33554432 /* ConstructorType */) { - memberContainer = memberContainer.getAssociatedContainerType(); - } - - if (memberContainer && memberContainer.isClass()) { - var memberClass = memberContainer.getDeclarations()[0].ast(); - TypeScript.Debug.assert(memberClass); - - var containingClass = this.getEnclosingClassDeclaration(name); - - if (!containingClass || containingClass !== memberClass) { - context.postDiagnostic(this.semanticInfoChain.diagnosticFromAST(name, TypeScript.DiagnosticCode._0_1_is_inaccessible, [memberContainer.toString(null, false), name.text()])); - return true; - } - } - } - } - - return false; - }; - - PullTypeResolver.prototype.instantiateType = function (type, typeParameterArgumentMap) { - if (type.isPrimitive()) { - return type; - } - - if (type.isError()) { - return type; - } - - if (typeParameterArgumentMap[type.pullSymbolID]) { - return typeParameterArgumentMap[type.pullSymbolID]; - } - - type._resolveDeclaredSymbol(); - if (type.isTypeParameter()) { - return this.instantiateTypeParameter(type, typeParameterArgumentMap); - } - - if (type.wrapsSomeTypeParameter(typeParameterArgumentMap)) { - return TypeScript.PullInstantiatedTypeReferenceSymbol.create(this, type, typeParameterArgumentMap); - } - - return type; - }; - - 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 rootSignature = signature.getRootSymbol(); - var mutableTypeParameterMap = new TypeScript.PullInstantiationHelpers.MutableTypeArgumentMap(typeParameterArgumentMap); - TypeScript.PullInstantiationHelpers.instantiateTypeArgument(this, signature, mutableTypeParameterMap); - - var instantiatedSignature = rootSignature.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiatedSignature) { - return instantiatedSignature; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(signature, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - instantiatedSignature = new TypeScript.PullInstantiatedSignatureSymbol(rootSignature, typeParameterArgumentMap); - - 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) { - for (var j = 0; j < parameters.length; j++) { - parameter = new TypeScript.PullSymbol(parameters[j].name, 2048 /* Parameter */); - parameter.setRootSymbol(parameters[j]); - - if (parameters[j].isOptional) { - parameter.isOptional = true; - } - if (parameters[j].isVarArg) { - parameter.isVarArg = true; - instantiatedSignature.hasVarArgs = true; - } - instantiatedSignature.addParameter(parameter, parameter.isOptional); - - parameter.type = this.instantiateType(parameters[j].type, typeParameterArgumentMap); - } - } - - return instantiatedSignature; - }; - PullTypeResolver.globalTypeCheckPhase = 0; - return PullTypeResolver; - })(); - TypeScript.PullTypeResolver = PullTypeResolver; - - var TypeComparisonInfo = (function () { - function TypeComparisonInfo(sourceComparisonInfo, useSameIndent) { - this.onlyCaptureFirstError = false; - this.flags = 0 /* SuccessfulComparison */; - this.message = ""; - this.stringConstantVal = null; - this.indent = 1; - if (sourceComparisonInfo) { - this.flags = sourceComparisonInfo.flags; - this.onlyCaptureFirstError = sourceComparisonInfo.onlyCaptureFirstError; - this.stringConstantVal = sourceComparisonInfo.stringConstantVal; - this.indent = sourceComparisonInfo.indent; - if (!useSameIndent) { - this.indent++; - } - } - } - TypeComparisonInfo.prototype.indentString = function () { - var result = ""; - - for (var i = 0; i < this.indent; i++) { - result += "\t"; - } - - return result; - }; - - TypeComparisonInfo.prototype.addMessage = function (message) { - if (!this.onlyCaptureFirstError && this.message) { - this.message = this.message + TypeScript.newLine() + this.indentString() + message; - } else { - this.message = this.indentString() + message; - } - }; - return TypeComparisonInfo; - })(); - TypeScript.TypeComparisonInfo = TypeComparisonInfo; - - function getPropertyAssignmentNameTextFromIdentifier(identifier) { - if (identifier.kind() === 11 /* IdentifierName */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 14 /* StringLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else if (identifier.kind() === 13 /* NumericLiteral */) { - return { actualText: identifier.text(), memberName: identifier.valueText() }; - } else { - throw TypeScript.Errors.invalidOperation(); - } - } - TypeScript.getPropertyAssignmentNameTextFromIdentifier = getPropertyAssignmentNameTextFromIdentifier; - - function isTypesOnlyLocation(ast) { - while (ast && ast.parent) { - switch (ast.parent.kind()) { - case 244 /* TypeAnnotation */: - return true; - case 127 /* TypeQuery */: - return false; - case 125 /* ConstructorType */: - var constructorType = ast.parent; - if (constructorType.type === ast) { - return true; - } - break; - case 123 /* FunctionType */: - var functionType = ast.parent; - if (functionType.type === ast) { - return true; - } - break; - case 239 /* Constraint */: - var constraint = ast.parent; - if (constraint.type === ast) { - return true; - } - break; - case 220 /* CastExpression */: - var castExpression = ast.parent; - return castExpression.type === ast; - case 230 /* ExtendsHeritageClause */: - case 231 /* ImplementsHeritageClause */: - return true; - case 228 /* TypeArgumentList */: - return true; - case 131 /* ClassDeclaration */: - case 128 /* InterfaceDeclaration */: - case 130 /* ModuleDeclaration */: - case 129 /* FunctionDeclaration */: - case 145 /* MethodSignature */: - case 212 /* MemberAccessExpression */: - case 242 /* Parameter */: - return false; - } - - ast = ast.parent; - } - - return false; - } - TypeScript.isTypesOnlyLocation = isTypesOnlyLocation; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.declCacheHit = 0; - TypeScript.declCacheMiss = 0; - TypeScript.symbolCacheHit = 0; - TypeScript.symbolCacheMiss = 0; - - var sentinalEmptyArray = []; - - var SemanticInfoChain = (function () { - function SemanticInfoChain(compiler, logger) { - this.compiler = compiler; - this.logger = logger; - this.documents = []; - this.fileNameToDocument = TypeScript.createIntrinsicsObject(); - this.anyTypeDecl = null; - this.booleanTypeDecl = null; - this.numberTypeDecl = null; - this.stringTypeDecl = null; - this.nullTypeDecl = null; - this.undefinedTypeDecl = null; - this.voidTypeDecl = null; - this.undefinedValueDecl = null; - this.anyTypeSymbol = null; - this.booleanTypeSymbol = null; - this.numberTypeSymbol = null; - this.stringTypeSymbol = null; - this.nullTypeSymbol = null; - this.undefinedTypeSymbol = null; - this.voidTypeSymbol = null; - this.undefinedValueSymbol = null; - this.emptyTypeSymbol = null; - this.astSymbolMap = []; - this.astAliasSymbolMap = []; - this.astCallResolutionDataMap = []; - this.declSymbolMap = []; - this.declSignatureSymbolMap = []; - this.declCache = null; - this.symbolCache = null; - this.fileNameToDiagnostics = null; - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - 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); - 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 */, 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 || null; - }; - - SemanticInfoChain.prototype.lineMap = function (fileName) { - return this.getDocument(fileName).lineMap(); - }; - - SemanticInfoChain.prototype.fileNames = function () { - if (this._fileNames === null) { - this._fileNames = this.documents.slice(1).map(function (s) { - return s.fileName; - }); - } - - return this._fileNames; - }; - - SemanticInfoChain.prototype.bindPrimitiveSymbol = function (decl, newSymbol) { - newSymbol.addDeclaration(decl); - decl.setSymbol(newSymbol); - newSymbol.setResolved(); - - return newSymbol; - }; - - SemanticInfoChain.prototype.addPrimitiveTypeSymbol = function (decl) { - var newSymbol = new TypeScript.PullPrimitiveTypeSymbol(decl.name); - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.addPrimitiveValueSymbol = function (decl, type) { - var newSymbol = new TypeScript.PullSymbol(decl.name, 512 /* Variable */); - newSymbol.type = type; - return this.bindPrimitiveSymbol(decl, newSymbol); - }; - - SemanticInfoChain.prototype.resetGlobalSymbols = function () { - this.anyTypeSymbol = this.addPrimitiveTypeSymbol(this.anyTypeDecl); - this.booleanTypeSymbol = this.addPrimitiveTypeSymbol(this.booleanTypeDecl); - this.numberTypeSymbol = this.addPrimitiveTypeSymbol(this.numberTypeDecl); - this.stringTypeSymbol = this.addPrimitiveTypeSymbol(this.stringTypeDecl); - this.voidTypeSymbol = this.addPrimitiveTypeSymbol(this.voidTypeDecl); - this.nullTypeSymbol = this.addPrimitiveTypeSymbol(this.nullTypeDecl); - this.undefinedTypeSymbol = this.addPrimitiveTypeSymbol(this.undefinedTypeDecl); - this.undefinedValueSymbol = this.addPrimitiveValueSymbol(this.undefinedValueDecl, this.undefinedTypeSymbol); - - var emptyTypeDecl = new TypeScript.PullSynthesizedDecl("{}", "{}", 8388608 /* ObjectType */, 0 /* None */, null, this); - var emptyTypeSymbol = new TypeScript.PullTypeSymbol("{}", 8388608 /* ObjectType */); - emptyTypeDecl.setSymbol(emptyTypeSymbol); - emptyTypeSymbol.addDeclaration(emptyTypeDecl); - emptyTypeSymbol.setResolved(); - this.emptyTypeSymbol = emptyTypeSymbol; - }; - - SemanticInfoChain.prototype.addDocument = function (document) { - var fileName = document.fileName; - - var existingIndex = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (existingIndex < 0) { - this.documents.push(document); - } else { - this.documents[existingIndex] = document; - } - - this.fileNameToDocument[fileName] = document; - - this.invalidate(); - }; - - SemanticInfoChain.prototype.removeDocument = function (fileName) { - TypeScript.Debug.assert(fileName !== "", "Can't remove the semantic info for the global decl."); - var index = TypeScript.ArrayUtilities.indexOf(this.documents, function (u) { - return u.fileName === fileName; - }); - if (index > 0) { - this.fileNameToDocument[fileName] = undefined; - this.documents.splice(index, 1); - this.invalidate(); - } - }; - - SemanticInfoChain.prototype.getDeclPathCacheID = function (declPath, declKind) { - var cacheID = ""; - - for (var i = 0; i < declPath.length; i++) { - cacheID += "#" + declPath[i]; - } - - return cacheID + "#" + declKind.toString(); - }; - - SemanticInfoChain.prototype.findTopLevelSymbol = function (name, kind, doNotGoPastThisDecl) { - var cacheID = this.getDeclPathCacheID([name], kind); - - var symbol = this.symbolCache[cacheID]; - - if (!symbol) { - for (var i = 0, n = this.documents.length; i < n; i++) { - var topLevelDecl = this.documents[i].topLevelDecl(); - - var symbol = this.findTopLevelSymbolInDecl(topLevelDecl, name, kind, doNotGoPastThisDecl); - if (symbol) { - break; - } - - if (doNotGoPastThisDecl && topLevelDecl.name === doNotGoPastThisDecl.fileName()) { - return null; - } - } - - if (symbol) { - this.symbolCache[cacheID] = symbol; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.findTopLevelSymbolInDecl = function (topLevelDecl, name, kind, doNotGoPastThisDecl) { - var doNotGoPastThisPosition = doNotGoPastThisDecl && doNotGoPastThisDecl.fileName() === topLevelDecl.fileName() ? doNotGoPastThisDecl.ast().start() : -1; - - var foundDecls = topLevelDecl.searchChildDecls(name, kind); - - for (var j = 0; j < foundDecls.length; j++) { - var foundDecl = foundDecls[j]; - - if (doNotGoPastThisPosition !== -1 && foundDecl.ast() && foundDecl.ast().start() > doNotGoPastThisPosition) { - break; - } - - var symbol = foundDecls[j].getSymbol(); - if (symbol) { - return symbol; - } - } - - return null; - }; - - SemanticInfoChain.prototype.findExternalModule = function (id) { - id = TypeScript.normalizePath(id); - - var tsFile = id + ".ts"; - var tsCacheID = this.getDeclPathCacheID([tsFile], 32 /* DynamicModule */); - symbol = this.symbolCache[tsCacheID]; - if (symbol != undefined) { - return symbol; - } - - 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 isTsFile = document.fileName === tsFile; - if (isTsFile || document.fileName === dtsFile) { - var dynamicModuleDecl = topLevelDecl.getChildDecls()[0]; - symbol = dynamicModuleDecl.getSymbol(); - - 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 null; - }; - - SemanticInfoChain.prototype.findAmbientExternalModuleInGlobalContext = function (id) { - var cacheID = this.getDeclPathCacheID([id], 32 /* DynamicModule */); - - var symbol = this.symbolCache[cacheID]; - if (symbol == undefined) { - symbol = null; - for (var i = 0; i < this.documents.length; i++) { - var document = this.documents[i]; - var topLevelDecl = document.topLevelDecl(); - - if (!topLevelDecl.isExternalModule()) { - var dynamicModules = topLevelDecl.searchChildDecls(id, 32 /* DynamicModule */); - if (dynamicModules.length) { - symbol = dynamicModules[0].getSymbol(); - break; - } - } - } - - this.symbolCache[cacheID] = symbol; - } - - return symbol; - }; - - SemanticInfoChain.prototype.findDecls = function (declPath, declKind) { - var cacheID = this.getDeclPathCacheID(declPath, declKind); - - if (declPath.length) { - var cachedDecls = this.declCache[cacheID]; - - if (cachedDecls && cachedDecls.length) { - TypeScript.declCacheHit++; - return cachedDecls; - } - } - - TypeScript.declCacheMiss++; - - var declsToSearch = this.topLevelDecls(); - - var decls = TypeScript.sentinelEmptyArray; - var path; - var foundDecls = TypeScript.sentinelEmptyArray; - - 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, kind); - - for (var k = 0; k < foundDecls.length; k++) { - if (decls === TypeScript.sentinelEmptyArray) { - decls = []; - } - decls[decls.length] = foundDecls[k]; - } - } - - declsToSearch = decls; - - if (!declsToSearch) { - break; - } - } - - if (decls.length) { - this.declCache[cacheID] = decls; - } - - return decls; - }; - - SemanticInfoChain.prototype.findDeclsFromPath = function (declPath, declKind) { - var declString = []; - - for (var i = 0, n = declPath.length; i < n; i++) { - if (declPath[i].kind & 1 /* Script */) { - continue; - } - - declString.push(declPath[i].name); - } - - return this.findDecls(declString, declKind); - }; - - SemanticInfoChain.prototype.findSymbol = function (declPath, declType) { - var cacheID = this.getDeclPathCacheID(declPath, declType); - - if (declPath.length) { - var cachedSymbol = this.symbolCache[cacheID]; - - if (cachedSymbol) { - TypeScript.symbolCacheHit++; - return cachedSymbol; - } - } - - TypeScript.symbolCacheMiss++; - - var decls = this.findDecls(declPath, declType); - var symbol = null; - - if (decls.length) { - 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; - } - } - - return symbol; - }; - - SemanticInfoChain.prototype.cacheGlobalSymbol = function (symbol, kind) { - var cacheID1 = this.getDeclPathCacheID([symbol.name], kind); - var cacheID2 = this.getDeclPathCacheID([symbol.name], symbol.kind); - - if (!this.symbolCache[cacheID1]) { - this.symbolCache[cacheID1] = symbol; - } - - if (!this.symbolCache[cacheID2]) { - this.symbolCache[cacheID2] = symbol; - } - }; - - SemanticInfoChain.prototype.invalidate = function (oldSettings, newSettings) { - if (typeof oldSettings === "undefined") { oldSettings = null; } - if (typeof newSettings === "undefined") { newSettings = null; } - TypeScript.PullTypeResolver.globalTypeCheckPhase++; - - var cleanStart = new Date().getTime(); - - this.astSymbolMap.length = 0; - this.astAliasSymbolMap.length = 0; - this.astCallResolutionDataMap.length = 0; - - this.declCache = TypeScript.createIntrinsicsObject(); - this.symbolCache = TypeScript.createIntrinsicsObject(); - this.fileNameToDiagnostics = TypeScript.createIntrinsicsObject(); - this._binder = null; - this._resolver = null; - this._topLevelDecls = null; - this._fileNames = null; - - this.declSymbolMap.length = 0; - this.declSignatureSymbolMap.length = 0; - - if (oldSettings && newSettings) { - if (this.settingsChangeAffectsSyntax(oldSettings, newSettings)) { - for (var i = 1, n = this.documents.length; i < n; i++) { - this.documents[i].invalidate(); - } - } - } - - TypeScript.pullSymbolID = 0; - - this.resetGlobalSymbols(); - - var cleanEnd = new Date().getTime(); - }; - - SemanticInfoChain.prototype.settingsChangeAffectsSyntax = function (before, after) { - return before.allowAutomaticSemicolonInsertion() !== after.allowAutomaticSemicolonInsertion() || before.codeGenTarget() !== after.codeGenTarget() || before.propagateEnumConstants() !== after.propagateEnumConstants(); - }; - - SemanticInfoChain.prototype.setSymbolForAST = function (ast, symbol) { - this.astSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForAST = function (ast) { - return this.astSymbolMap[ast.syntaxID()] || null; - }; - - SemanticInfoChain.prototype.setAliasSymbolForAST = function (ast, symbol) { - this.astAliasSymbolMap[ast.syntaxID()] = symbol; - }; - - SemanticInfoChain.prototype.getAliasSymbolForAST = function (ast) { - return this.astAliasSymbolMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.getCallResolutionDataForAST = function (ast) { - return this.astCallResolutionDataMap[ast.syntaxID()]; - }; - - SemanticInfoChain.prototype.setCallResolutionDataForAST = function (ast, callResolutionData) { - if (callResolutionData) { - this.astCallResolutionDataMap[ast.syntaxID()] = callResolutionData; - } - }; - - SemanticInfoChain.prototype.setSymbolForDecl = function (decl, symbol) { - this.declSymbolMap[decl.declID] = symbol; - }; - - SemanticInfoChain.prototype.getSymbolForDecl = function (decl) { - return this.declSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.setSignatureSymbolForDecl = function (decl, signatureSymbol) { - this.declSignatureSymbolMap[decl.declID] = signatureSymbol; - }; - - SemanticInfoChain.prototype.getSignatureSymbolForDecl = function (decl) { - return this.declSignatureSymbolMap[decl.declID]; - }; - - SemanticInfoChain.prototype.addDiagnostic = function (diagnostic) { - var fileName = diagnostic.fileName(); - var diagnostics = this.fileNameToDiagnostics[fileName]; - if (!diagnostics) { - diagnostics = []; - this.fileNameToDiagnostics[fileName] = diagnostics; - } - - diagnostics.push(diagnostic); - }; - - SemanticInfoChain.prototype.getDiagnostics = function (fileName) { - var diagnostics = this.fileNameToDiagnostics[fileName]; - return diagnostics || []; - }; - - SemanticInfoChain.prototype.getBinder = function () { - if (!this._binder) { - this._binder = new TypeScript.PullSymbolBinder(this); - } - - return this._binder; - }; - - SemanticInfoChain.prototype.getResolver = function () { - if (!this._resolver) { - this._resolver = new TypeScript.PullTypeResolver(this.compiler.compilationSettings(), this); - } - - return this._resolver; - }; - - SemanticInfoChain.prototype.addSyntheticIndexSignature = function (containingDecl, containingSymbol, ast, indexParamName, indexParamType, returnType) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - var indexParameterSymbol = new TypeScript.PullSymbol(indexParamName, 2048 /* Parameter */); - indexParameterSymbol.type = indexParamType; - indexSignature.addParameter(indexParameterSymbol); - indexSignature.returnType = returnType; - indexSignature.setResolved(); - indexParameterSymbol.setResolved(); - - containingSymbol.addIndexSignature(indexSignature); - - 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); - indexParameterSymbol.addDeclaration(indexParamDecl); - }; - - SemanticInfoChain.prototype.getDeclForAST = function (ast) { - var document = this.getDocument(ast.fileName()); - - if (document) { - return document._getDeclForAST(ast); - } - - return null; - }; - - SemanticInfoChain.prototype.getEnclosingDecl = function (ast) { - return this.getDocument(ast.fileName()).getEnclosingDecl(ast); - }; - - SemanticInfoChain.prototype.setDeclForAST = function (ast, decl) { - this.getDocument(decl.fileName())._setDeclForAST(ast, decl); - }; - - SemanticInfoChain.prototype.getASTForDecl = function (decl) { - var document = this.getDocument(decl.fileName()); - if (document) { - return document._getASTForDecl(decl); - } - - return null; - }; - - SemanticInfoChain.prototype.setASTForDecl = function (decl, ast) { - this.getDocument(decl.fileName())._setASTForDecl(decl, ast); - }; - - SemanticInfoChain.prototype.topLevelDecl = function (fileName) { - var document = this.getDocument(fileName); - if (document) { - return document.topLevelDecl(); - } - - return null; - }; - - SemanticInfoChain.prototype.topLevelDecls = function () { - if (!this._topLevelDecls) { - this._topLevelDecls = TypeScript.ArrayUtilities.select(this.documents, function (u) { - return u.topLevelDecl(); - }); - } - - return this._topLevelDecls; - }; - - 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, 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; - })(); - TypeScript.SemanticInfoChain = SemanticInfoChain; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var DeclCollectionContext = (function () { - function DeclCollectionContext(document, semanticInfoChain, propagateEnumConstants) { - this.document = document; - this.semanticInfoChain = semanticInfoChain; - this.propagateEnumConstants = propagateEnumConstants; - this.isDeclareFile = false; - this.parentChain = []; - } - DeclCollectionContext.prototype.getParent = function () { - return this.parentChain ? this.parentChain[this.parentChain.length - 1] : null; - }; - - DeclCollectionContext.prototype.pushParent = function (parentDecl) { - if (parentDecl) { - this.parentChain[this.parentChain.length] = parentDecl; - } - }; - - DeclCollectionContext.prototype.popParent = function () { - this.parentChain.length--; - }; - return DeclCollectionContext; - })(); - - function containingModuleHasExportAssignment(ast) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = ast; - return moduleDecl.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } else if (ast.kind() === 120 /* SourceUnit */) { - var sourceUnit = ast; - return sourceUnit.moduleElements.any(function (m) { - return m.kind() === 134 /* ExportAssignment */; - }); - } - - ast = ast.parent; - } - - return false; - } - - function isParsingAmbientModule(ast, context) { - ast = ast.parent; - while (ast) { - if (ast.kind() === 130 /* ModuleDeclaration */) { - if (TypeScript.hasModifier(ast.modifiers, 8 /* Ambient */)) { - return true; - } - } - - ast = ast.parent; - } - - return false; - } - - function preCollectImportDecls(ast, context) { - var importDecl = ast; - var declFlags = 0 /* None */; - - var parent = context.getParent(); - - if (TypeScript.hasModifier(importDecl.modifiers, 1 /* Exported */) && !containingModuleHasExportAssignment(ast)) { - declFlags |= 1 /* Exported */; - } - - 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 fileName = sourceUnit.fileName(); - - var isExternalModule = context.document.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); - - context.isDeclareFile = context.document.isDeclareFile(); - - context.pushParent(decl); - - if (isExternalModule) { - var declFlags = 1 /* Exported */; - if (TypeScript.isDTSFile(fileName)) { - declFlags |= 8 /* Ambient */; - } - - var moduleContainsExecutableCode = containsExecutableCode(sourceUnit.moduleElements); - var kind = 32 /* DynamicModule */; - var valueText = TypeScript.quoteStr(fileName); - - var decl = new TypeScript.NormalPullDecl(valueText, fileName, kind, declFlags, context.getParent()); - - context.semanticInfoChain.setASTForDecl(decl, sourceUnit); - - context.semanticInfoChain.setDeclForAST(sourceUnit, decl); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, sourceUnit, context); - } - - context.pushParent(decl); - } - } - - function preCollectEnumDecls(enumDecl, context) { - var declFlags = 0 /* None */; - var enumName = enumDecl.identifier.valueText(); - - if ((TypeScript.hasModifier(enumDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(enumDecl, context)) && !containingModuleHasExportAssignment(enumDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(enumDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(enumDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - declFlags |= 4096 /* Enum */; - var kind = 64 /* Enum */; - - var enumDeclaration = new TypeScript.NormalPullDecl(enumName, enumDecl.identifier.text(), kind, declFlags, context.getParent()); - context.semanticInfoChain.setDeclForAST(enumDecl, enumDeclaration); - context.semanticInfoChain.setASTForDecl(enumDeclaration, enumDecl); - - var valueDecl = new TypeScript.NormalPullDecl(enumDeclaration.name, enumDeclaration.getDisplayName(), 512 /* Variable */, enumDeclaration.flags, context.getParent()); - enumDeclaration.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, enumDecl); - - context.pushParent(enumDeclaration); - } - - function createEnumElementDecls(propertyDecl, context) { - var parent = context.getParent(); - - var decl = new TypeScript.PullEnumElementDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function preCollectModuleDecls(moduleDecl, context) { - var declFlags = 0 /* None */; - - var moduleContainsExecutableCode = containsExecutableCode(moduleDecl.moduleElements); - - var isDynamic = moduleDecl.stringLiteral !== null; - - if ((TypeScript.hasModifier(moduleDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(moduleDecl, context)) && !containingModuleHasExportAssignment(moduleDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(moduleDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(moduleDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var kind = isDynamic ? 32 /* DynamicModule */ : 4 /* Container */; - - 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()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleDecl.stringLiteral, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleDecl.stringLiteral); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleDecl.stringLiteral, context); - } - - context.pushParent(decl); - } else { - var moduleNames = getModuleNames(moduleDecl.name); - for (var i = 0, n = moduleNames.length; i < n; i++) { - var moduleName = moduleNames[i]; - - var specificFlags = declFlags; - if (i > 0) { - specificFlags |= 1 /* Exported */; - } - - var decl = new TypeScript.NormalPullDecl(moduleName.valueText(), moduleName.text(), kind, specificFlags, context.getParent()); - - context.semanticInfoChain.setDeclForAST(moduleDecl, decl); - context.semanticInfoChain.setDeclForAST(moduleName, decl); - context.semanticInfoChain.setASTForDecl(decl, moduleName); - - if (moduleContainsExecutableCode) { - createModuleVariableDecl(decl, moduleName, context); - } - - context.pushParent(decl); - } - } - } - - function getModuleNames(name, result) { - result = result || []; - - if (name.kind() === 121 /* QualifiedName */) { - getModuleNames(name.left, result); - result.push(name.right); - } else { - result.push(name); - } - - return result; - } - TypeScript.getModuleNames = getModuleNames; - - 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.setValueDecl(valueDecl); - context.semanticInfoChain.setASTForDecl(valueDecl, moduleNameAST); - } - - function containsExecutableCode(members) { - for (var i = 0, n = members.childCount(); i < n; i++) { - var member = members.childAt(i); - - if (member.kind() === 130 /* ModuleDeclaration */) { - var moduleDecl = member; - - if (containsExecutableCode(moduleDecl.moduleElements)) { - return true; - } - } else if (member.kind() === 133 /* ImportDeclaration */) { - if (TypeScript.hasModifier(member.modifiers, 1 /* Exported */)) { - return true; - } - } else if (member.kind() !== 128 /* InterfaceDeclaration */) { - return true; - } - } - - return false; - } - - function preCollectClassDecls(classDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(classDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(classDecl, context)) && !containingModuleHasExportAssignment(classDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(classDecl.modifiers, 8 /* Ambient */) || isParsingAmbientModule(classDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - var parent = context.getParent(); - - 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(), 512 /* Variable */, declFlags | 16384 /* ClassConstructorVariable */, parent); - - decl.setValueDecl(constructorDecl); - - context.semanticInfoChain.setDeclForAST(classDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, classDecl); - context.semanticInfoChain.setASTForDecl(constructorDecl, classDecl); - - context.pushParent(decl); - } - - function preCollectObjectTypeDecls(objectType, context) { - if (objectType.parent.kind() === 128 /* InterfaceDeclaration */) { - return; - } - - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setDeclForAST(objectType, decl); - context.semanticInfoChain.setASTForDecl(decl, objectType); - - context.pushParent(decl); - } - - function preCollectInterfaceDecls(interfaceDecl, context) { - var declFlags = 0 /* None */; - - if ((TypeScript.hasModifier(interfaceDecl.modifiers, 1 /* Exported */) || isParsingAmbientModule(interfaceDecl, context)) && !containingModuleHasExportAssignment(interfaceDecl)) { - declFlags |= 1 /* Exported */; - } - - var parent = context.getParent(); - - 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); - - context.pushParent(decl); - } - - function preCollectParameterDecl(argDecl, context) { - var declFlags = 0 /* None */; - - if (TypeScript.hasModifier(argDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (argDecl.questionToken !== null || argDecl.equalsValueClause !== null || argDecl.dotDotDotToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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 */) { - decl.setFlag(67108864 /* ConstructorParameter */); - } - - var isPublicOrPrivate = TypeScript.hasModifier(argDecl.modifiers, 4 /* Public */ | 2 /* Private */); - var isInConstructor = parent.kind === 32768 /* ConstructorMethod */; - if (isPublicOrPrivate && isInConstructor) { - var parentsParent = context.parentChain[context.parentChain.length - 2]; - - 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 */) { - propDecl.setFlag(67108864 /* ConstructorParameter */); - } - - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setASTForDecl(propDecl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, propDecl); - } else { - context.semanticInfoChain.setASTForDecl(decl, argDecl); - context.semanticInfoChain.setDeclForAST(argDecl, decl); - } - - parent.addVariableDeclToGroup(decl); - } - - function preCollectTypeParameterDecl(typeParameterDecl, context) { - var declFlags = 0 /* None */; - - 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); - context.semanticInfoChain.setASTForDecl(decl, typeParameterDecl); - context.semanticInfoChain.setDeclForAST(typeParameterDecl, decl); - } - - function createPropertySignature(propertyDecl, context) { - var declFlags = 4 /* Public */; - var parent = context.getParent(); - var declType = 4096 /* Property */; - - if (propertyDecl.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var decl = new TypeScript.NormalPullDecl(propertyDecl.propertyName.valueText(), propertyDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(propertyDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyDecl); - } - - function createMemberVariableDeclaration(memberDecl, context) { - var declFlags = 0 /* None */; - var declType = 4096 /* Property */; - - if (TypeScript.hasModifier(memberDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (TypeScript.hasModifier(memberDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - var parent = context.getParent(); - - 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); - } - - function createVariableDeclaration(varDecl, context) { - var declFlags = 0 /* None */; - var declType = 512 /* Variable */; - - var modifiers = TypeScript.ASTHelpers.getVariableDeclaratorModifiers(varDecl); - if ((TypeScript.hasModifier(modifiers, 1 /* Exported */) || isParsingAmbientModule(varDecl, context)) && !containingModuleHasExportAssignment(varDecl)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(modifiers, 8 /* Ambient */) || isParsingAmbientModule(varDecl, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - 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); - context.semanticInfoChain.setDeclForAST(varDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, varDecl); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectVarDecls(ast, context) { - if (ast.parent.kind() === 136 /* MemberVariableDeclaration */) { - return; - } - - var varDecl = ast; - createVariableDeclaration(varDecl, context); - } - - function createFunctionTypeDeclaration(functionTypeDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 16777216 /* FunctionType */; - - 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); - context.semanticInfoChain.setDeclForAST(functionTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionTypeDeclAST); - - context.pushParent(decl); - } - - function createConstructorTypeDeclaration(constructorTypeDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 33554432 /* ConstructorType */; - - 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); - context.semanticInfoChain.setDeclForAST(constructorTypeDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorTypeDeclAST); - - context.pushParent(decl); - } - - function createFunctionDeclaration(funcDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 16384 /* Function */; - - if ((TypeScript.hasModifier(funcDeclAST.modifiers, 1 /* Exported */) || isParsingAmbientModule(funcDeclAST, context)) && !containingModuleHasExportAssignment(funcDeclAST)) { - declFlags |= 1 /* Exported */; - } - - if (TypeScript.hasModifier(funcDeclAST.modifiers, 8 /* Ambient */) || isParsingAmbientModule(funcDeclAST, context) || context.isDeclareFile) { - declFlags |= 8 /* Ambient */; - } - - if (!funcDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - 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); - context.semanticInfoChain.setDeclForAST(funcDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDeclAST); - - context.pushParent(decl); - } - - function createAnyFunctionExpressionDeclaration(functionExpressionDeclAST, id, context, displayName) { - if (typeof displayName === "undefined") { displayName = null; } - var declFlags = 0 /* None */; - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */ || functionExpressionDeclAST.kind() === 218 /* ParenthesizedArrowFunctionExpression */) { - declFlags |= 8192 /* ArrowFunction */; - } - - var parent = context.getParent(); - - if (parent && (parent.kind === 134217728 /* WithBlock */ || (parent.flags & 2097152 /* DeclaredInAWithBlock */))) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - var name = id ? id.text() : ""; - var displayNameText = displayName ? displayName.text() : ""; - var decl = new TypeScript.PullFunctionExpressionDecl(name, declFlags, parent, displayNameText); - context.semanticInfoChain.setDeclForAST(functionExpressionDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, functionExpressionDeclAST); - - context.pushParent(decl); - - if (functionExpressionDeclAST.kind() === 219 /* SimpleArrowFunctionExpression */) { - var simpleArrow = functionExpressionDeclAST; - var declFlags = 4 /* Public */; - - var parent = context.getParent(); - - if (TypeScript.hasFlag(parent.flags, 2097152 /* DeclaredInAWithBlock */)) { - declFlags |= 2097152 /* DeclaredInAWithBlock */; - } - - 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); - - parent.addVariableDeclToGroup(decl); - } - } - - function createMemberFunctionDeclaration(funcDecl, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - if (TypeScript.hasModifier(funcDecl.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(funcDecl.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - if (!funcDecl.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(funcDecl.propertyName.valueText(), funcDecl.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(funcDecl, decl); - context.semanticInfoChain.setASTForDecl(decl, funcDecl); - - context.pushParent(decl); - } - - function createIndexSignatureDeclaration(indexSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 4194304 /* IndexSignature */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(indexSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, indexSignatureDeclAST); - - context.pushParent(decl); - } - - function createCallSignatureDeclaration(callSignature, context) { - var isChildOfObjectType = callSignature.parent && callSignature.parent.parent && callSignature.parent.kind() === 2 /* SeparatedList */ && callSignature.parent.parent.kind() === 122 /* ObjectType */; - - if (!isChildOfObjectType) { - return; - } - - var declFlags = 2048 /* Signature */; - var declType = 1048576 /* CallSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(callSignature, decl); - context.semanticInfoChain.setASTForDecl(decl, callSignature); - - context.pushParent(decl); - } - - function createMethodSignatureDeclaration(method, context) { - var declFlags = 0 /* None */; - var declType = 65536 /* Method */; - - declFlags |= 4 /* Public */; - declFlags |= 2048 /* Signature */; - - if (method.questionToken !== null) { - declFlags |= 128 /* Optional */; - } - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl(method.propertyName.valueText(), method.propertyName.text(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(method, decl); - context.semanticInfoChain.setASTForDecl(decl, method); - - context.pushParent(decl); - } - - function createConstructSignatureDeclaration(constructSignatureDeclAST, context) { - var declFlags = 2048 /* Signature */; - var declType = 2097152 /* ConstructSignature */; - - 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); - context.semanticInfoChain.setDeclForAST(constructSignatureDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructSignatureDeclAST); - - context.pushParent(decl); - } - - function createClassConstructorDeclaration(constructorDeclAST, context) { - var declFlags = 0 /* None */; - var declType = 32768 /* ConstructorMethod */; - - if (!constructorDeclAST.block) { - declFlags |= 2048 /* Signature */; - } - - var parent = context.getParent(); - - if (parent) { - var parentFlags = parent.flags; - - if (parentFlags & 1 /* Exported */) { - declFlags |= 1 /* Exported */; - } - } - - var decl = new TypeScript.NormalPullDecl(parent.name, parent.getDisplayName(), declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(constructorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, constructorDeclAST); - - context.pushParent(decl); - } - - function createGetAccessorDeclaration(getAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 262144 /* GetAccessor */; - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(getAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(getAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, getAccessorDeclAST); - - context.pushParent(decl); - } - - function createFunctionExpressionDeclaration(expression, context) { - createAnyFunctionExpressionDeclaration(expression, expression.identifier, context); - } - - function createSetAccessorDeclaration(setAccessorDeclAST, context) { - var declFlags = 4 /* Public */; - var declType = 524288 /* SetAccessor */; - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 16 /* Static */)) { - declFlags |= 16 /* Static */; - } - - if (TypeScript.hasModifier(setAccessorDeclAST.modifiers, 2 /* Private */)) { - declFlags |= 2 /* Private */; - } else { - declFlags |= 4 /* Public */; - } - - 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); - context.semanticInfoChain.setDeclForAST(setAccessorDeclAST, decl); - context.semanticInfoChain.setASTForDecl(decl, setAccessorDeclAST); - - context.pushParent(decl); - } - - function preCollectCatchDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 268435456 /* CatchBlock */; - - 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); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - - var declFlags = 0 /* None */; - var declType = 1024 /* CatchVariable */; - - 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); - context.semanticInfoChain.setDeclForAST(ast.identifier, decl); - context.semanticInfoChain.setASTForDecl(decl, ast.identifier); - - if (parent) { - parent.addVariableDeclToGroup(decl); - } - } - - function preCollectWithDecls(ast, context) { - var declFlags = 0 /* None */; - var declType = 134217728 /* WithBlock */; - - var parent = context.getParent(); - - var decl = new TypeScript.NormalPullDecl("", "", declType, declFlags, parent); - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectObjectLiteralDecls(ast, context) { - var decl = new TypeScript.NormalPullDecl("", "", 256 /* ObjectLiteral */, 0 /* None */, context.getParent()); - - context.semanticInfoChain.setDeclForAST(ast, decl); - context.semanticInfoChain.setASTForDecl(decl, ast); - - context.pushParent(decl); - } - - function preCollectSimplePropertyAssignmentDecls(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()); - - context.semanticInfoChain.setDeclForAST(propertyAssignment, decl); - context.semanticInfoChain.setASTForDecl(decl, propertyAssignment); - } - - function preCollectFunctionPropertyAssignmentDecls(propertyAssignment, context) { - var assignmentText = TypeScript.getPropertyAssignmentNameTextFromIdentifier(propertyAssignment.propertyName); - - 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); - - createAnyFunctionExpressionDeclaration(propertyAssignment, propertyAssignment.propertyName, context, propertyAssignment.propertyName); - } - - function preCollectDecls(ast, context) { - switch (ast.kind()) { - case 120 /* SourceUnit */: - preCollectScriptDecls(ast, context); - break; - case 132 /* EnumDeclaration */: - preCollectEnumDecls(ast, context); - break; - case 243 /* EnumElement */: - createEnumElementDecls(ast, context); - break; - case 130 /* ModuleDeclaration */: - preCollectModuleDecls(ast, context); - break; - case 131 /* ClassDeclaration */: - preCollectClassDecls(ast, context); - break; - case 128 /* InterfaceDeclaration */: - preCollectInterfaceDecls(ast, context); - break; - case 122 /* ObjectType */: - preCollectObjectTypeDecls(ast, context); - break; - case 242 /* Parameter */: - preCollectParameterDecl(ast, context); - break; - case 136 /* MemberVariableDeclaration */: - createMemberVariableDeclaration(ast, context); - break; - case 141 /* PropertySignature */: - createPropertySignature(ast, context); - break; - case 225 /* VariableDeclarator */: - preCollectVarDecls(ast, context); - break; - case 137 /* ConstructorDeclaration */: - createClassConstructorDeclaration(ast, context); - break; - case 139 /* GetAccessor */: - createGetAccessorDeclaration(ast, context); - break; - case 140 /* SetAccessor */: - createSetAccessorDeclaration(ast, context); - break; - case 222 /* FunctionExpression */: - createFunctionExpressionDeclaration(ast, context); - break; - case 135 /* MemberFunctionDeclaration */: - createMemberFunctionDeclaration(ast, context); - break; - case 144 /* IndexSignature */: - createIndexSignatureDeclaration(ast, context); - break; - case 123 /* FunctionType */: - createFunctionTypeDeclaration(ast, context); - break; - case 125 /* ConstructorType */: - createConstructorTypeDeclaration(ast, context); - break; - case 142 /* CallSignature */: - createCallSignatureDeclaration(ast, context); - break; - case 143 /* ConstructSignature */: - createConstructSignatureDeclaration(ast, context); - break; - case 145 /* MethodSignature */: - createMethodSignatureDeclaration(ast, context); - break; - case 129 /* FunctionDeclaration */: - createFunctionDeclaration(ast, context); - break; - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - createAnyFunctionExpressionDeclaration(ast, null, context); - break; - case 133 /* ImportDeclaration */: - preCollectImportDecls(ast, context); - break; - case 238 /* TypeParameter */: - preCollectTypeParameterDecl(ast, context); - break; - case 236 /* CatchClause */: - preCollectCatchDecls(ast, context); - break; - case 163 /* WithStatement */: - preCollectWithDecls(ast, context); - break; - case 215 /* ObjectLiteralExpression */: - preCollectObjectLiteralDecls(ast, context); - break; - case 240 /* SimplePropertyAssignment */: - preCollectSimplePropertyAssignmentDecls(ast, context); - break; - case 241 /* FunctionPropertyAssignment */: - preCollectFunctionPropertyAssignmentDecls(ast, context); - break; - } - } - - function isContainer(decl) { - return decl.kind === 4 /* Container */ || decl.kind === 32 /* DynamicModule */ || decl.kind === 64 /* Enum */; - } - - function getInitializationFlag(decl) { - if (decl.kind & 4 /* Container */) { - return 32768 /* InitializedModule */; - } else if (decl.kind & 32 /* DynamicModule */) { - return 65536 /* InitializedDynamicModule */; - } - - return 0 /* None */; - } - - function hasInitializationFlag(decl) { - var kind = decl.kind; - - if (kind & 4 /* Container */) { - return (decl.flags & 32768 /* InitializedModule */) !== 0; - } else if (kind & 32 /* DynamicModule */) { - return (decl.flags & 65536 /* InitializedDynamicModule */) !== 0; - } - - return false; - } - - function postCollectDecls(ast, context) { - var currentDecl = context.getParent(); - - if (ast.kind() === 11 /* IdentifierName */ || ast.kind() === 14 /* StringLiteral */) { - if (currentDecl.kind === 4 /* Container */ || currentDecl.kind === 32 /* DynamicModule */) { - return; - } - } - - if (ast.kind() === 130 /* ModuleDeclaration */) { - var moduleDeclaration = ast; - if (moduleDeclaration.stringLiteral) { - TypeScript.Debug.assert(currentDecl.ast() === moduleDeclaration.stringLiteral); - context.popParent(); - } else { - var moduleNames = getModuleNames(moduleDeclaration.name); - for (var i = moduleNames.length - 1; i >= 0; i--) { - var moduleName = moduleNames[i]; - TypeScript.Debug.assert(currentDecl.ast() === moduleName); - context.popParent(); - currentDecl = context.getParent(); - } - } - } - - if (ast.kind() === 132 /* EnumDeclaration */) { - computeEnumElementConstantValues(ast, currentDecl, context); - } - - while (currentDecl.getParentDecl() && currentDecl.ast() === ast) { - context.popParent(); - currentDecl = context.getParent(); - } - } - - function computeEnumElementConstantValues(ast, enumDecl, context) { - TypeScript.Debug.assert(enumDecl.kind === 64 /* Enum */); - - var isAmbientEnum = TypeScript.hasFlag(enumDecl.flags, 8 /* Ambient */); - var inConstantSection = !isAmbientEnum; - var currentConstantValue = 0; - var enumMemberDecls = enumDecl.getChildDecls(); - - for (var i = 0, n = ast.enumElements.nonSeparatorCount(); i < n; i++) { - var enumElement = ast.enumElements.nonSeparatorAt(i); - var enumElementDecl = TypeScript.ArrayUtilities.first(enumMemberDecls, function (d) { - return context.semanticInfoChain.getASTForDecl(d) === enumElement; - }); - - TypeScript.Debug.assert(enumElementDecl.kind === 67108864 /* EnumMember */); - - if (enumElement.equalsValueClause === null) { - if (inConstantSection) { - enumElementDecl.constantValue = currentConstantValue; - currentConstantValue++; - } - } else { - enumElementDecl.constantValue = computeEnumElementConstantValue(enumElement.equalsValueClause.value, enumMemberDecls, context); - if (enumElementDecl.constantValue !== null && !isAmbientEnum) { - inConstantSection = true; - currentConstantValue = enumElementDecl.constantValue + 1; - } else { - inConstantSection = false; - } - } - - TypeScript.Debug.assert(enumElementDecl.constantValue !== undefined); - } - } - - function computeEnumElementConstantValue(expression, enumMemberDecls, context) { - TypeScript.Debug.assert(expression); - - if (TypeScript.ASTHelpers.isIntegerLiteralAST(expression)) { - var token; - switch (expression.kind()) { - case 164 /* PlusExpression */: - case 165 /* NegateExpression */: - token = expression.operand; - break; - default: - token = expression; - } - - var value = token.value(); - return value && expression.kind() === 165 /* NegateExpression */ ? -value : value; - } else if (context.propagateEnumConstants) { - switch (expression.kind()) { - case 11 /* IdentifierName */: - var name = expression; - var matchingEnumElement = TypeScript.ArrayUtilities.firstOrDefault(enumMemberDecls, function (d) { - return d.name === name.valueText(); - }); - - return matchingEnumElement ? matchingEnumElement.constantValue : null; - - case 202 /* LeftShiftExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left << right; - - case 189 /* BitwiseOrExpression */: - var binaryExpression = expression; - var left = computeEnumElementConstantValue(binaryExpression.left, enumMemberDecls, context); - var right = computeEnumElementConstantValue(binaryExpression.right, enumMemberDecls, context); - if (left === null || right === null) { - return null; - } - - return left | right; - } - - return null; - } else { - return null; - } - } - - (function (DeclarationCreator) { - function create(document, semanticInfoChain, compilationSettings) { - var declCollectionContext = new DeclCollectionContext(document, semanticInfoChain, compilationSettings.propagateEnumConstants()); - - TypeScript.getAstWalkerFactory().simpleWalk(document.sourceUnit(), preCollectDecls, postCollectDecls, declCollectionContext); - - return declCollectionContext.getParent(); - } - DeclarationCreator.create = create; - })(TypeScript.DeclarationCreator || (TypeScript.DeclarationCreator = {})); - var DeclarationCreator = TypeScript.DeclarationCreator; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var PullSymbolBinder = (function () { - 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 */) { - return null; - } - - var parent = parentDecl.getSymbol(); - - if (!parent && parentDecl && !parentDecl.hasBeenBound()) { - this.bindDeclToPullSymbol(parentDecl); - } - - parent = parentDecl.getSymbol(); - if (parent) { - var parentDeclKind = parentDecl.kind; - if (parentDeclKind === 262144 /* GetAccessor */) { - parent = parent.getGetter(); - } else if (parentDeclKind === 524288 /* SetAccessor */) { - parent = parent.getSetter(); - } - } - - if (parent) { - if (returnInstanceType && parent.isType() && parent.isContainer()) { - var instanceSymbol = parent.getInstanceSymbol(); - - if (instanceSymbol) { - return instanceSymbol.type; - } - } - - return parent.type; - } - - return null; - }; - - PullSymbolBinder.prototype.findDeclsInContext = function (startingDecl, declKind, searchGlobally) { - if (!searchGlobally) { - var parentDecl = startingDecl.getParentDecl(); - return parentDecl.searchChildDecls(startingDecl.name, declKind); - } - - var contextSymbolPath = startingDecl.getParentPath(); - - if (contextSymbolPath.length) { - var copyOfContextSymbolPath = []; - - for (var i = 0; i < contextSymbolPath.length; i++) { - if (contextSymbolPath[i].kind & 1 /* Script */) { - continue; - } - copyOfContextSymbolPath[copyOfContextSymbolPath.length] = contextSymbolPath[i].name; - } - - return this.semanticInfoChain.findDecls(copyOfContextSymbolPath, declKind); - } - }; - - PullSymbolBinder.prototype.getExistingSymbol = function (decl, searchKind, parent) { - var lookingForValue = (searchKind & 68147712 /* SomeValue */) !== 0; - var lookingForType = (searchKind & 58728795 /* SomeType */) !== 0; - var lookingForContainer = (searchKind & 164 /* SomeContainer */) !== 0; - var name = decl.name; - if (parent) { - var isExported = (decl.flags & 1 /* Exported */) !== 0; - - var prevSymbol = null; - if (lookingForValue) { - prevSymbol = parent.findContainedNonMember(name); - } else if (lookingForType) { - prevSymbol = parent.findContainedNonMemberType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findContainedNonMemberContainer(name, searchKind); - } - var prevIsExported = !prevSymbol; - if (!prevSymbol) { - if (lookingForValue) { - prevSymbol = parent.findMember(name, false); - } else if (lookingForType) { - prevSymbol = parent.findNestedType(name, searchKind); - } else if (lookingForContainer) { - prevSymbol = parent.findNestedContainer(name, searchKind); - } - } - - if (isExported && prevIsExported) { - return prevSymbol; - } - if (prevSymbol) { - var prevDecls = prevSymbol.getDeclarations(); - var lastPrevDecl = prevDecls[prevDecls.length - 1]; - var parentDecl = decl.getParentDecl(); - var prevParentDecl = lastPrevDecl && lastPrevDecl.getParentDecl(); - if (parentDecl !== prevParentDecl) { - return null; - } - - return prevSymbol; - } - } else { - var parentDecl = decl.getParentDecl(); - if (parentDecl && parentDecl.kind === 1 /* Script */) { - return this.semanticInfoChain.findTopLevelSymbol(name, searchKind, decl); - } else { - var prevDecls = parentDecl && parentDecl.searchChildDecls(name, searchKind); - return prevDecls[0] && prevDecls[0].getSymbol(); - } - } - - return null; - }; - - PullSymbolBinder.prototype.checkThatExportsMatch = function (decl, prevSymbol, reportError) { - if (typeof reportError === "undefined") { reportError = true; } - 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 (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()]); - } - return false; - } - - 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; - - var enumContainerSymbol = null; - var enumInstanceSymbol = null; - var moduleInstanceTypeSymbol = null; - - var enumInstanceDecl = enumContainerDecl.getValueDecl(); - - var enumDeclKind = enumContainerDecl.kind; - - var parent = this.getParent(enumContainerDecl); - var parentInstanceSymbol = this.getParent(enumContainerDecl, true); - var parentDecl = enumContainerDecl.getParentDecl(); - var enumAST = this.semanticInfoChain.getASTForDecl(enumContainerDecl); - - var isExported = enumContainerDecl.flags & 1 /* Exported */; - - var createdNewSymbol = false; - - enumContainerSymbol = this.getExistingSymbol(enumContainerDecl, 64 /* Enum */, parent); - - if (enumContainerSymbol) { - if (enumContainerSymbol.kind !== enumDeclKind) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(enumAST.identifier, enumContainerDecl.getDisplayName(), enumContainerSymbol.getDeclarations()[0].ast()); - enumContainerSymbol = null; - } else if (!this.checkThatExportsMatch(enumContainerDecl, enumContainerSymbol)) { - enumContainerSymbol = null; - } - } - - if (enumContainerSymbol) { - enumInstanceSymbol = enumContainerSymbol.getInstanceSymbol(); - } else { - enumContainerSymbol = new TypeScript.PullContainerSymbol(enumName, enumDeclKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(enumContainerSymbol, 64 /* Enum */); - } - } - - enumContainerSymbol.addDeclaration(enumContainerDecl); - enumContainerDecl.setSymbol(enumContainerSymbol); - - this.semanticInfoChain.setSymbolForAST(enumAST.identifier, enumContainerSymbol); - this.semanticInfoChain.setSymbolForAST(enumAST, enumContainerSymbol); - - if (!enumInstanceSymbol) { - var variableSymbol = null; - if (parentInstanceSymbol) { - if (isExported) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - } - } else { - variableSymbol = parentInstanceSymbol.findContainedNonMember(enumName); - - if (!variableSymbol) { - variableSymbol = parentInstanceSymbol.findMember(enumName, false); - } - } - - if (variableSymbol) { - var declarations = variableSymbol.getDeclarations(); - - if (declarations.length) { - var variableSymbolParentDecl = declarations[0].getParentDecl(); - - if (parentDecl !== variableSymbolParentDecl) { - variableSymbol = null; - } - } - } - } else if (!(enumContainerDecl.flags & 1 /* Exported */)) { - var siblingDecls = parentDecl.getChildDecls(); - var augmentedDecl = null; - - for (var i = 0; i < siblingDecls.length; i++) { - if (siblingDecls[i] === enumContainerDecl) { - break; - } - - if ((siblingDecls[i].name === enumName) && (siblingDecls[i].kind & 68147712 /* SomeValue */)) { - augmentedDecl = siblingDecls[i]; - break; - } - } - - if (augmentedDecl) { - variableSymbol = augmentedDecl.getSymbol(); - - if (variableSymbol) { - if (variableSymbol.isContainer()) { - variableSymbol = variableSymbol.getInstanceSymbol(); - } else if (variableSymbol && variableSymbol.isType()) { - variableSymbol = variableSymbol.getConstructorMethod(); - } - } - } - } - - if (variableSymbol) { - enumInstanceSymbol = variableSymbol; - moduleInstanceTypeSymbol = variableSymbol.type; - } else { - enumInstanceSymbol = new TypeScript.PullSymbol(enumName, 512 /* Variable */); - } - - enumContainerSymbol.setInstanceSymbol(enumInstanceSymbol); - - if (!moduleInstanceTypeSymbol) { - moduleInstanceTypeSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - enumInstanceSymbol.type = moduleInstanceTypeSymbol; - } - - moduleInstanceTypeSymbol.addDeclaration(enumContainerDecl); - - if (!moduleInstanceTypeSymbol.getAssociatedContainerType()) { - moduleInstanceTypeSymbol.setAssociatedContainerType(enumContainerSymbol); - } - } - - if (createdNewSymbol && parent) { - if (enumContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(enumContainerSymbol); - } else { - parent.addEnclosedNonMemberType(enumContainerSymbol); - } - } - - if (createdNewSymbol) { - this.bindEnumIndexerDeclsToPullSymbols(enumContainerSymbol); - } - var valueDecl = enumContainerDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - }; - - 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(); - - enumContainerInstanceTypeSymbol.addIndexSignature(syntheticIndexerSignatureSymbol); - }; - - 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(); - - 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 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.ASTHelpers.getEnclosingModuleDeclaration(moduleNameAST); - if (!moduleDeclAST) { - TypeScript.Debug.assert(moduleKind === 32 /* DynamicModule */); - TypeScript.Debug.assert(moduleNameAST.kind() === 120 /* SourceUnit */); - - moduleDeclAST = moduleNameAST; - } - - var isExported = TypeScript.hasFlag(moduleContainerDecl.flags, 1 /* Exported */); - var searchKind = 164 /* SomeContainer */; - var isInitializedModule = (moduleContainerDecl.flags & 102400 /* SomeInitializedModule */) !== 0; - - if (parent && moduleKind === 32 /* DynamicModule */) { - this.semanticInfoChain.addDiagnosticFromAST(moduleNameAST, TypeScript.DiagnosticCode.Ambient_external_module_declaration_must_be_defined_in_global_context, null); - } - - var createdNewSymbol = false; - - moduleContainerTypeSymbol = this.getExistingSymbol(moduleContainerDecl, searchKind, parent); - - if (moduleContainerTypeSymbol) { - if (moduleContainerTypeSymbol.kind !== moduleKind) { - if (isInitializedModule) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(moduleNameAST, moduleContainerDecl.getDisplayName(), moduleContainerTypeSymbol.getDeclarations()[0].ast()); - } - - moduleContainerTypeSymbol = null; - } 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) { - moduleContainerTypeSymbol = new TypeScript.PullContainerSymbol(modName, moduleKind); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(moduleContainerTypeSymbol, searchKind); - } - } - - moduleContainerTypeSymbol.addDeclaration(moduleContainerDecl); - moduleContainerDecl.setSymbol(moduleContainerTypeSymbol); - - this.semanticInfoChain.setSymbolForAST(moduleNameAST, moduleContainerTypeSymbol); - this.semanticInfoChain.setSymbolForAST(moduleDeclAST, moduleContainerTypeSymbol); - - var currentModuleValueDecl = moduleContainerDecl.getValueDecl(); - - var moduleDeclarations = moduleContainerTypeSymbol.getDeclarations(); - - if (createdNewSymbol) { - if (parent) { - if (moduleContainerDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(moduleContainerTypeSymbol); - } else { - parent.addEnclosedNonMemberContainer(moduleContainerTypeSymbol); - } - } - } - - if (currentModuleValueDecl) { - currentModuleValueDecl.ensureSymbolIsBound(); - - 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); - } - } - - if (!instanceSymbol.type) { - instanceSymbol.type = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - } - - moduleContainerTypeSymbol.setInstanceSymbol(instanceSymbol); - - if (!instanceSymbol.type.getAssociatedContainerType()) { - instanceSymbol.type.setAssociatedContainerType(moduleContainerTypeSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindImportDeclaration = function (importDeclaration) { - var declFlags = importDeclaration.flags; - var declKind = importDeclaration.kind; - var importDeclAST = this.semanticInfoChain.getASTForDecl(importDeclaration); - - var isExported = false; - var importSymbol = null; - var declName = importDeclaration.name; - var parentHadSymbol = false; - var parent = this.getParent(importDeclaration); - - importSymbol = this.getExistingSymbol(importDeclaration, 164 /* SomeContainer */, parent); - - if (importSymbol) { - parentHadSymbol = true; - } - - if (importSymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(importDeclAST, importDeclaration.getDisplayName(), importSymbol.getDeclarations()[0].ast()); - importSymbol = null; - } - - if (!importSymbol) { - importSymbol = new TypeScript.PullTypeAliasSymbol(declName); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(importSymbol, 164 /* SomeContainer */); - } - } - - importSymbol.addDeclaration(importDeclaration); - importDeclaration.setSymbol(importSymbol); - - this.semanticInfoChain.setSymbolForAST(importDeclAST, importSymbol); - - if (parent && !parentHadSymbol) { - if (declFlags & 1 /* Exported */) { - parent.addEnclosedMemberContainer(importSymbol); - } else { - parent.addEnclosedNonMemberContainer(importSymbol); - } - } - }; - - 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; - - var constructorSymbol = null; - var constructorTypeSymbol = null; - - 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, 58728795 /* SomeType */, parent); - - if (classSymbol && classSymbol.kind === 16 /* Interface */) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(classAST.identifier, classDecl.getDisplayName(), classSymbol.getDeclarations()[0].ast()); - classSymbol = null; - } - - classSymbol = new TypeScript.PullTypeSymbol(className, 8 /* Class */); - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(classSymbol, 8 /* Class */); - } - - classSymbol.addDeclaration(classDecl); - - classDecl.setSymbol(classSymbol); - - this.semanticInfoChain.setSymbolForAST(classAST.identifier, classSymbol); - this.semanticInfoChain.setSymbolForAST(classAST, classSymbol); - - if (parent) { - if (classDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(classSymbol); - } else { - parent.addEnclosedNonMemberType(classSymbol); - } - } - - 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; - - if (!constructorSymbol) { - var siblingValueDecls = null; - if (parentDecl) { - siblingValueDecls = parentDecl.searchChildDecls(className, 68147712 /* SomeValue */); - - if (siblingValueDecls && siblingValueDecls[0] && siblingValueDecls[0].hasSymbol()) { - constructorSymbol = siblingValueDecls[0].getSymbol(); - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(className, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - constructorSymbol.setIsSynthesized(); - constructorSymbol.type = constructorTypeSymbol; - } - - classSymbol.setConstructorMethod(constructorSymbol); - classSymbol.setHasDefaultConstructor(); - } - - if (constructorSymbol.getIsSynthesized()) { - constructorSymbol.addDeclaration(classDecl.getValueDecl()); - constructorTypeSymbol.addDeclaration(classDecl); - } else { - classSymbol.setHasDefaultConstructor(false); - } - - constructorTypeSymbol.setAssociatedContainerType(classSymbol); - - var valueDecl = classDecl.getValueDecl(); - - if (valueDecl) { - valueDecl.ensureSymbolIsBound(); - } - - this.bindStaticPrototypePropertyOfClass(classAST, classSymbol, constructorTypeSymbol); - }; - - PullSymbolBinder.prototype.bindInterfaceDeclarationToPullSymbol = function (interfaceDecl) { - var interfaceName = interfaceDecl.name; - var interfaceSymbol = null; - - var interfaceAST = this.semanticInfoChain.getASTForDecl(interfaceDecl); - var createdNewSymbol = false; - var parent = this.getParent(interfaceDecl); - - var acceptableSharedKind = 16 /* Interface */; - - interfaceSymbol = this.getExistingSymbol(interfaceDecl, 58728795 /* SomeType */, parent); - - if (interfaceSymbol) { - if (!(interfaceSymbol.kind & acceptableSharedKind)) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(interfaceAST.identifier, interfaceDecl.getDisplayName(), interfaceSymbol.getDeclarations()[0].ast()); - interfaceSymbol = null; - } else if (!this.checkThatExportsMatch(interfaceDecl, interfaceSymbol)) { - interfaceSymbol = null; - } - } - - if (!interfaceSymbol) { - interfaceSymbol = new TypeScript.PullTypeSymbol(interfaceName, 16 /* Interface */); - createdNewSymbol = true; - - if (!parent) { - this.semanticInfoChain.cacheGlobalSymbol(interfaceSymbol, acceptableSharedKind); - } - } - - interfaceSymbol.addDeclaration(interfaceDecl); - interfaceDecl.setSymbol(interfaceSymbol); - - if (createdNewSymbol) { - if (parent) { - if (interfaceDecl.flags & 1 /* Exported */) { - parent.addEnclosedMemberType(interfaceSymbol); - } else { - parent.addEnclosedNonMemberType(interfaceSymbol); - } - } - } - - var typeParameters = interfaceDecl.getTypeParameters(); - var typeParameter; - var typeParameterDecls = null; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = interfaceSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - interfaceSymbol.addTypeParameter(typeParameter); - } else { - typeParameterDecls = typeParameter.getDeclarations(); - - for (var j = 0; j < typeParameterDecls.length; j++) { - var typeParameterDeclParent = typeParameterDecls[j].getParentDecl(); - - if (typeParameterDeclParent && typeParameterDeclParent === interfaceDecl) { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameterDecls[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - - break; - } - } - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - }; - - PullSymbolBinder.prototype.bindObjectTypeDeclarationToPullSymbol = function (objectDecl) { - var objectSymbolAST = this.semanticInfoChain.getASTForDecl(objectDecl); - - var objectSymbol = new TypeScript.PullTypeSymbol("", 8388608 /* ObjectType */); - - objectSymbol.addDeclaration(objectDecl); - objectDecl.setSymbol(objectSymbol); - - this.semanticInfoChain.setSymbolForAST(objectSymbolAST, objectSymbol); - - var childDecls = objectDecl.getChildDecls(); - - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - }; - - PullSymbolBinder.prototype.bindConstructorTypeDeclarationToPullSymbol = function (constructorTypeDeclaration) { - var declKind = constructorTypeDeclaration.kind; - var declFlags = constructorTypeDeclaration.flags; - var constructorTypeAST = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - - var constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - - constructorTypeDeclaration.setSymbol(constructorTypeSymbol); - constructorTypeSymbol.addDeclaration(constructorTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(constructorTypeAST, constructorTypeSymbol); - - var signature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructorTypeDeclaration); - if (TypeScript.lastParameterIsRest(funcDecl.parameterList)) { - signature.hasVarArgs = true; - } - - signature.addDeclaration(constructorTypeDeclaration); - constructorTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), constructorTypeSymbol, signature); - - var typeParameters = constructorTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructorTypeSymbol.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - 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; - - var variableSymbol = null; - - var declName = variableDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(variableDeclaration, true); - - 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; - variableSymbol = this.getExistingSymbol(variableDeclaration, 68147712 /* SomeValue */, parent); - - if (!variableSymbol && isModuleValue) { - variableSymbol = this.findExistingVariableSymbolForModuleValueDecl(variableDeclaration.getContainerDecl()); - } - - if (variableSymbol && !variableSymbol.isType()) { - parentHadSymbol = true; - } - - var decl; - var decls; - var ast; - var members; - - if (variableSymbol) { - var prevKind = variableSymbol.kind; - var prevIsEnum = variableSymbol.anyDeclHasFlag(4096 /* Enum */); - var prevIsClassConstructorVariable = variableSymbol.anyDeclHasFlag(16384 /* ClassConstructorVariable */); - var prevIsModuleValue = variableSymbol.allDeclsHaveFlag(32768 /* InitializedModule */); - var prevIsImplicit = variableSymbol.anyDeclHasFlag(118784 /* ImplicitVariable */); - 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 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 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.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 || 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); - variableSymbol = null; - parentHadSymbol = false; - } - } - - if (variableSymbol && !(variableSymbol.type && variableSymbol.type.isError()) && !this.checkThatExportsMatch(variableDeclaration, variableSymbol, !(isModuleValue && prevIsModuleValue))) { - variableSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(declName); - } - } - - if ((declFlags & 118784 /* ImplicitVariable */) === 0) { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - if (!parent && parentDecl.kind === 1 /* Script */) { - this.semanticInfoChain.cacheGlobalSymbol(variableSymbol, declKind); - } - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - this.semanticInfoChain.setSymbolForAST(nameAST, variableSymbol); - this.semanticInfoChain.setSymbolForAST(varDeclAST, variableSymbol); - } else if (!parentHadSymbol) { - if (isClassConstructorVariable) { - var classTypeSymbol = variableSymbol; - - if (parent) { - members = parent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].kind === 8 /* Class */)) { - classTypeSymbol = members[i]; - break; - } - } - } - - if (!classTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - classTypeSymbol = containerDecl.getSymbol(); - if (!classTypeSymbol) { - classTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 58728795 /* SomeType */, variableDeclaration); - } - } - - if (classTypeSymbol && (classTypeSymbol.kind !== 8 /* Class */)) { - classTypeSymbol = null; - } - - if (classTypeSymbol && classTypeSymbol.isClass()) { - variableSymbol = classTypeSymbol.getConstructorMethod(); - variableDeclaration.setSymbol(variableSymbol); - - decls = classTypeSymbol.getDeclarations(); - - if (decls.length) { - decl = decls[decls.length - 1]; - ast = this.semanticInfoChain.getASTForDecl(decl); - } - } else { - if (!variableSymbol) { - variableSymbol = new TypeScript.PullSymbol(declName, declKind); - } - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - } - } else if (declFlags & 102400 /* SomeInitializedModule */) { - var moduleContainerTypeSymbol = null; - var moduleParent = this.getParent(variableDeclaration); - - if (moduleParent) { - members = moduleParent.getMembers(); - - for (var i = 0; i < members.length; i++) { - if ((members[i].name === declName) && (members[i].isContainer())) { - moduleContainerTypeSymbol = members[i]; - break; - } - } - } - - if (!moduleContainerTypeSymbol) { - var containerDecl = variableDeclaration.getContainerDecl(); - moduleContainerTypeSymbol = containerDecl.getSymbol(); - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 164 /* SomeContainer */, variableDeclaration); - - if (!moduleContainerTypeSymbol) { - moduleContainerTypeSymbol = this.semanticInfoChain.findTopLevelSymbol(declName, 64 /* Enum */, variableDeclaration); - } - } - } - - if (moduleContainerTypeSymbol && (!moduleContainerTypeSymbol.isContainer())) { - moduleContainerTypeSymbol = null; - } - - 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); - } - variableDeclaration.setSymbol(variableSymbol); - } else { - TypeScript.Debug.assert(false, "Attempted to bind invalid implicit variable symbol"); - } - } - } else { - if (!variableSymbol.hasDeclaration(variableDeclaration)) { - variableSymbol.addDeclaration(variableDeclaration); - } - 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); - } else { - parent.addEnclosedNonMember(variableSymbol); - } - } - }; - - PullSymbolBinder.prototype.bindCatchVariableToPullSymbol = function (variableDeclaration) { - var declFlags = variableDeclaration.flags; - var declKind = variableDeclaration.kind; - var identifier = this.semanticInfoChain.getASTForDecl(variableDeclaration); - - var declName = variableDeclaration.name; - - var variableSymbol = new TypeScript.PullSymbol(declName, declKind); - - variableSymbol.addDeclaration(variableDeclaration); - variableDeclaration.setSymbol(variableSymbol); - - variableSymbol.type = this.semanticInfoChain.anyTypeSymbol; - - this.semanticInfoChain.setSymbolForAST(identifier, variableSymbol); - }; - - PullSymbolBinder.prototype.bindEnumMemberDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - var propDeclAST = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - var propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(propDeclAST.propertyName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(propDeclAST.propertyName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(propDeclAST, propertySymbol); - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindPropertyDeclarationToPullSymbol = function (propertyDeclaration) { - var declFlags = propertyDeclaration.flags; - var declKind = propertyDeclaration.kind; - - var ast = this.semanticInfoChain.getASTForDecl(propertyDeclaration); - var astName = ast.kind() === 136 /* MemberVariableDeclaration */ ? ast.variableDeclarator.propertyName : ast.kind() === 141 /* PropertySignature */ ? ast.propertyName : ast.kind() === 242 /* Parameter */ ? ast.identifier : ast.propertyName; - - var isStatic = false; - var isOptional = false; - - var propertySymbol = null; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - if (TypeScript.hasFlag(declFlags, 128 /* Optional */)) { - isOptional = true; - } - - var declName = propertyDeclaration.name; - - var parentHadSymbol = false; - - var parent = this.getParent(propertyDeclaration, true); - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - propertySymbol = parent.findMember(declName, false); - - if (propertySymbol) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(astName, propertyDeclaration.getDisplayName(), propertySymbol.getDeclarations()[0].ast()); - } - - if (propertySymbol) { - parentHadSymbol = true; - } - - var classTypeSymbol; - - if (!parentHadSymbol) { - propertySymbol = new TypeScript.PullSymbol(declName, declKind); - } - - propertySymbol.addDeclaration(propertyDeclaration); - propertyDeclaration.setSymbol(propertySymbol); - - this.semanticInfoChain.setSymbolForAST(astName, propertySymbol); - this.semanticInfoChain.setSymbolForAST(ast, propertySymbol); - - if (isOptional) { - propertySymbol.isOptional = true; - } - - if (parent && !parentHadSymbol) { - parent.addMember(propertySymbol); - } - }; - - PullSymbolBinder.prototype.bindParameterSymbols = function (functionDeclaration, parameterList, funcType, signatureSymbol) { - var parameters = []; - var params = TypeScript.createIntrinsicsObject(); - var funcDecl = this.semanticInfoChain.getDeclForAST(functionDeclaration); - - if (parameterList) { - for (var i = 0, n = parameterList.length; i < n; i++) { - var argDecl = parameterList.astAt(i); - var id = parameterList.identifierAt(i); - var decl = this.semanticInfoChain.getDeclForAST(argDecl); - var isProperty = TypeScript.hasFlag(decl.flags, 8388608 /* PropertyParameter */); - var parameterSymbol = new TypeScript.PullSymbol(id.valueText(), 2048 /* Parameter */); - - if ((i === (n - 1)) && parameterList.lastParameterIsRest()) { - parameterSymbol.isVarArg = 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); - - if (signatureSymbol.isDefinition()) { - funcType.addEnclosedNonMember(parameterSymbol); - } - } - } - }; - - PullSymbolBinder.prototype.bindFunctionDeclarationToPullSymbol = function (functionDeclaration) { - var declKind = functionDeclaration.kind; - var declFlags = functionDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(functionDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = functionDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(functionDeclaration, true); - - var parentDecl = functionDeclaration.getParentDecl(); - var parentHadSymbol = false; - - var functionSymbol = null; - var functionTypeSymbol = null; - - functionSymbol = this.getExistingSymbol(functionDeclaration, 68147712 /* SomeValue */, parent); - - if (functionSymbol) { - 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.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.identifier, functionDeclaration.getDisplayName(), functionSymbol.getDeclarations()[0].ast()); - functionSymbol.type = this.semanticInfoChain.getResolver().getNewErrorTypeSymbol(funcName); - } - } - - if (functionSymbol) { - functionTypeSymbol = functionSymbol.type; - parentHadSymbol = true; - } - - if (!functionSymbol) { - functionSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - } - - if (!functionTypeSymbol) { - functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionSymbol.type = functionTypeSymbol; - functionTypeSymbol.setFunctionSymbol(functionSymbol); - } - - functionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionDeclaration); - functionTypeSymbol.addDeclaration(functionDeclaration); - - this.semanticInfoChain.setSymbolForAST(funcDeclAST.identifier, functionSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, functionSymbol); - - if (parent && !parentHadSymbol) { - if (isExported) { - parent.addMember(functionSymbol); - } else { - parent.addEnclosedNonMember(functionSymbol); - } - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(functionDeclaration); - functionDeclaration.setSignatureSymbol(signature); - - if (TypeScript.lastParameterIsRest(funcDeclAST.callSignature.parameterList)) { - signature.hasVarArgs = true; - } - - var funcDecl = this.semanticInfoChain.getASTForDecl(functionDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.callSignature.parameterList), functionTypeSymbol, signature); - - var typeParameters = functionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionExpressionToPullSymbol = function (functionExpressionDeclaration) { - var declKind = functionExpressionDeclaration.kind; - var declFlags = functionExpressionDeclaration.flags; - var ast = this.semanticInfoChain.getASTForDecl(functionExpressionDeclaration); - - 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 functionSymbol = new TypeScript.PullSymbol(functionName, declKind); - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - functionTypeSymbol.setFunctionSymbol(functionSymbol); - - functionSymbol.type = functionTypeSymbol; - - functionExpressionDeclaration.setSymbol(functionSymbol); - functionSymbol.addDeclaration(functionExpressionDeclaration); - functionTypeSymbol.addDeclaration(functionExpressionDeclaration); - - var name = funcExpAST.kind() === 222 /* FunctionExpression */ ? funcExpAST.identifier : funcExpAST.kind() === 241 /* FunctionPropertyAssignment */ ? funcExpAST.propertyName : null; - if (name) { - this.semanticInfoChain.setSymbolForAST(name, functionSymbol); - } - - this.semanticInfoChain.setSymbolForAST(funcExpAST, functionSymbol); - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, true); - - if (parameters.lastParameterIsRest()) { - signature.hasVarArgs = true; - } - - var typeParameters = functionExpressionDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionExpressionDeclaration); - functionExpressionDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcExpAST, parameters, functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindFunctionTypeDeclarationToPullSymbol = function (functionTypeDeclaration) { - var declKind = functionTypeDeclaration.kind; - var declFlags = functionTypeDeclaration.flags; - var funcTypeAST = this.semanticInfoChain.getASTForDecl(functionTypeDeclaration); - - var functionTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - - functionTypeDeclaration.setSymbol(functionTypeSymbol); - functionTypeSymbol.addDeclaration(functionTypeDeclaration); - this.semanticInfoChain.setSymbolForAST(funcTypeAST, functionTypeSymbol); - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - if (TypeScript.lastParameterIsRest(funcTypeAST.parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = functionTypeDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = signature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - signature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.name]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(functionTypeDeclaration); - functionTypeDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcTypeAST, TypeScript.ASTHelpers.parametersFromParameterList(funcTypeAST.parameterList), functionTypeSymbol, signature); - - functionTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindMethodDeclarationToPullSymbol = function (methodDeclaration) { - var declKind = methodDeclaration.kind; - var declFlags = methodDeclaration.flags; - var methodAST = this.semanticInfoChain.getASTForDecl(methodDeclaration); - - var isPrivate = (declFlags & 2 /* Private */) !== 0; - var isStatic = (declFlags & 16 /* Static */) !== 0; - var isOptional = (declFlags & 128 /* Optional */) !== 0; - - var methodName = methodDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(methodDeclaration, true); - var parentHadSymbol = false; - - var methodSymbol = null; - var methodTypeSymbol = null; - - if (parent.isClass() && isStatic) { - parent = parent.getConstructorMethod().type; - } - - methodSymbol = parent.findMember(methodName, false); - - if (methodSymbol && (methodSymbol.kind !== 65536 /* Method */ || (!isSignature && !methodSymbol.allDeclsHaveFlag(2048 /* Signature */)))) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(methodAST, methodDeclaration.getDisplayName(), methodSymbol.getDeclarations()[0].ast()); - methodSymbol = null; - } - - if (methodSymbol) { - methodTypeSymbol = methodSymbol.type; - parentHadSymbol = true; - } - - if (!methodSymbol) { - methodSymbol = new TypeScript.PullSymbol(methodName, 65536 /* Method */); - } - - if (!methodTypeSymbol) { - methodTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - methodSymbol.type = methodTypeSymbol; - methodTypeSymbol.setFunctionSymbol(methodSymbol); - } - - methodDeclaration.setSymbol(methodSymbol); - methodSymbol.addDeclaration(methodDeclaration); - methodTypeSymbol.addDeclaration(methodDeclaration); - - var nameAST = methodAST.kind() === 135 /* MemberFunctionDeclaration */ ? methodAST.propertyName : methodAST.propertyName; - - TypeScript.Debug.assert(nameAST); - - this.semanticInfoChain.setSymbolForAST(nameAST, methodSymbol); - this.semanticInfoChain.setSymbolForAST(methodAST, methodSymbol); - - if (isOptional) { - methodSymbol.isOptional = true; - } - - if (!parentHadSymbol) { - parent.addMember(methodSymbol); - } - - var sigKind = 1048576 /* CallSignature */; - - var signature = new TypeScript.PullSignatureSymbol(sigKind, !isSignature); - - var parameterList = TypeScript.ASTHelpers.getParameterList(methodAST); - if (TypeScript.lastParameterIsRest(parameterList)) { - signature.hasVarArgs = true; - } - - var typeParameters = methodDeclaration.getTypeParameters(); - var typeParameter; - var typeParameterName; - var typeParameterAST; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameterName = typeParameters[i].name; - typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameters[i]); - - typeParameter = signature.findTypeParameter(typeParameterName); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameterName); - signature.addTypeParameter(typeParameter); - } else { - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - signature.addDeclaration(methodDeclaration); - methodDeclaration.setSignatureSymbol(signature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(methodDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), methodTypeSymbol, signature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(signature, methodTypeSymbol.getOwnCallSignatures()); - methodTypeSymbol.insertCallSignatureAtIndex(signature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindStaticPrototypePropertyOfClass = function (classAST, classTypeSymbol, constructorTypeSymbol) { - var prototypeStr = "prototype"; - - var prototypeSymbol = constructorTypeSymbol.findMember(prototypeStr, false); - if (prototypeSymbol && !prototypeSymbol.getIsSynthesized()) { - 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], this.semanticInfoChain); - - prototypeSymbol = new TypeScript.PullSymbol(prototypeStr, 4096 /* Property */); - prototypeSymbol.setIsSynthesized(); - prototypeSymbol.addDeclaration(prototypeDecl); - prototypeSymbol.type = classTypeSymbol; - constructorTypeSymbol.addMember(prototypeSymbol); - - if (prototypeSymbol.type && prototypeSymbol.type.isGeneric()) { - var resolver = this.semanticInfoChain.getResolver(); - prototypeSymbol.type = resolver.instantiateTypeToAny(prototypeSymbol.type, new TypeScript.PullTypeResolutionContext(resolver)); - } - prototypeSymbol.setResolved(); - } - }; - - PullSymbolBinder.prototype.bindConstructorDeclarationToPullSymbol = function (constructorDeclaration) { - var declKind = constructorDeclaration.kind; - var declFlags = constructorDeclaration.flags; - var constructorAST = this.semanticInfoChain.getASTForDecl(constructorDeclaration); - - var constructorName = constructorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - - var parent = this.getParent(constructorDeclaration, true); - - var parentHadSymbol = false; - - var constructorSymbol = parent.getConstructorMethod(); - var constructorTypeSymbol = null; - - if (constructorSymbol && (constructorSymbol.kind !== 32768 /* ConstructorMethod */ || (!isSignature && constructorSymbol.type && constructorSymbol.type.hasOwnConstructSignatures()))) { - var hasDefinitionSignature = false; - var constructorSigs = constructorSymbol.type.getConstructSignatures(); - - for (var i = 0; i < constructorSigs.length; i++) { - if (!constructorSigs[i].anyDeclHasFlag(2048 /* Signature */)) { - hasDefinitionSignature = true; - break; - } - } - - if (hasDefinitionSignature) { - this.semanticInfoChain.addDiagnosticFromAST(constructorAST, TypeScript.DiagnosticCode.Multiple_constructor_implementations_are_not_allowed); - - constructorSymbol = null; - } - } - - if (constructorSymbol) { - constructorTypeSymbol = constructorSymbol.type; - } else { - constructorSymbol = new TypeScript.PullSymbol(constructorName, 32768 /* ConstructorMethod */); - constructorTypeSymbol = new TypeScript.PullTypeSymbol("", 33554432 /* ConstructorType */); - } - - parent.setConstructorMethod(constructorSymbol); - constructorSymbol.type = constructorTypeSymbol; - - constructorDeclaration.setSymbol(constructorSymbol); - constructorSymbol.addDeclaration(constructorDeclaration); - constructorTypeSymbol.addDeclaration(constructorDeclaration); - constructorSymbol.setIsSynthesized(false); - this.semanticInfoChain.setSymbolForAST(constructorAST, constructorSymbol); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */, !isSignature); - constructSignature.returnType = parent; - constructSignature.addTypeParametersFromReturnType(); - - constructSignature.addDeclaration(constructorDeclaration); - constructorDeclaration.setSignatureSymbol(constructSignature); - - this.bindParameterSymbols(constructorAST, TypeScript.ASTHelpers.parametersFromParameterList(constructorAST.callSignature.parameterList), constructorTypeSymbol, constructSignature); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - constructorTypeSymbol.appendConstructSignature(constructSignature); - }; - - PullSymbolBinder.prototype.bindConstructSignatureDeclarationToPullSymbol = function (constructSignatureDeclaration) { - var parent = this.getParent(constructSignatureDeclaration, true); - var constructorAST = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - - var constructSignature = new TypeScript.PullSignatureSymbol(2097152 /* ConstructSignature */); - - if (TypeScript.lastParameterIsRest(constructorAST.callSignature.parameterList)) { - constructSignature.hasVarArgs = true; - } - - var typeParameters = constructSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = constructSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - constructSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - constructSignature.addDeclaration(constructSignatureDeclaration); - constructSignatureDeclaration.setSignatureSymbol(constructSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(TypeScript.ASTHelpers.getParameterList(funcDecl)), null, constructSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(constructSignatureDeclaration), constructSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(constructSignature, parent.getOwnConstructSignatures()); - parent.insertConstructSignatureAtIndex(constructSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindCallSignatureDeclarationToPullSymbol = function (callSignatureDeclaration) { - var parent = this.getParent(callSignatureDeclaration, true); - var callSignatureAST = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - - var callSignature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */); - - if (TypeScript.lastParameterIsRest(callSignatureAST.parameterList)) { - callSignature.hasVarArgs = true; - } - - var typeParameters = callSignatureDeclaration.getTypeParameters(); - var typeParameter; - - for (var i = 0; i < typeParameters.length; i++) { - typeParameter = callSignature.findTypeParameter(typeParameters[i].name); - - if (!typeParameter) { - typeParameter = new TypeScript.PullTypeParameterSymbol(typeParameters[i].name); - - callSignature.addTypeParameter(typeParameter); - } else { - var typeParameterAST = this.semanticInfoChain.getASTForDecl(typeParameter.getDeclarations()[0]); - this.semanticInfoChain.addDiagnosticFromAST(typeParameterAST, TypeScript.DiagnosticCode.Duplicate_identifier_0, [typeParameter.getName()]); - } - - typeParameter.addDeclaration(typeParameters[i]); - typeParameters[i].setSymbol(typeParameter); - } - - callSignature.addDeclaration(callSignatureDeclaration); - callSignatureDeclaration.setSignatureSymbol(callSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(callSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameterList(funcDecl.parameterList), null, callSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(callSignatureDeclaration), callSignature); - - var signatureIndex = this.getIndexForInsertingSignatureAtEndOfEnclosingDeclInSignatureList(callSignature, parent.getOwnCallSignatures()); - parent.insertCallSignatureAtIndex(callSignature, signatureIndex); - }; - - PullSymbolBinder.prototype.bindIndexSignatureDeclarationToPullSymbol = function (indexSignatureDeclaration) { - var indexSignature = new TypeScript.PullSignatureSymbol(4194304 /* IndexSignature */); - - indexSignature.addDeclaration(indexSignatureDeclaration); - indexSignatureDeclaration.setSignatureSymbol(indexSignature); - - var funcDecl = this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration); - this.bindParameterSymbols(funcDecl, TypeScript.ASTHelpers.parametersFromParameter(funcDecl.parameter), null, indexSignature); - - this.semanticInfoChain.setSymbolForAST(this.semanticInfoChain.getASTForDecl(indexSignatureDeclaration), indexSignature); - - var parent = this.getParent(indexSignatureDeclaration); - parent.addIndexSignature(indexSignature); - indexSignature.setContainer(parent); - }; - - PullSymbolBinder.prototype.bindGetAccessorDeclarationToPullSymbol = function (getAccessorDeclaration) { - var declKind = getAccessorDeclaration.kind; - var declFlags = getAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(getAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = getAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(getAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var getterSymbol = null; - var getterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, getAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - getterSymbol = accessorSymbol.getGetter(); - - if (getterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Getter_0_already_declared, [getAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - getterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - } - - if (accessorSymbol && getterSymbol) { - getterTypeSymbol = getterSymbol.type; - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!getterSymbol) { - getterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - getterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - getterTypeSymbol.setFunctionSymbol(getterSymbol); - - getterSymbol.type = getterTypeSymbol; - - accessorSymbol.setGetter(getterSymbol); - } - - getAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(getAccessorDeclaration); - getterSymbol.addDeclaration(getAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, getterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(getAccessorDeclaration); - getAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), getterTypeSymbol, signature); - - getterTypeSymbol.appendCallSignature(signature); - }; - - PullSymbolBinder.prototype.bindSetAccessorDeclarationToPullSymbol = function (setAccessorDeclaration) { - var declKind = setAccessorDeclaration.kind; - var declFlags = setAccessorDeclaration.flags; - var funcDeclAST = this.semanticInfoChain.getASTForDecl(setAccessorDeclaration); - - var isExported = (declFlags & 1 /* Exported */) !== 0; - - var funcName = setAccessorDeclaration.name; - - var isSignature = (declFlags & 2048 /* Signature */) !== 0; - var isStatic = false; - - if (TypeScript.hasFlag(declFlags, 16 /* Static */)) { - isStatic = true; - } - - var parent = this.getParent(setAccessorDeclaration, true); - var parentHadSymbol = false; - - var accessorSymbol = null; - var setterSymbol = null; - var setterTypeSymbol = null; - - if (isStatic) { - parent = parent.getConstructorMethod().type; - } - - accessorSymbol = parent.findMember(funcName, false); - - if (accessorSymbol) { - if (!accessorSymbol.isAccessor()) { - this.semanticInfoChain.addDuplicateIdentifierDiagnosticFromAST(funcDeclAST.propertyName, setAccessorDeclaration.getDisplayName(), accessorSymbol.getDeclarations()[0].ast()); - accessorSymbol = null; - } else { - setterSymbol = accessorSymbol.getSetter(); - - if (setterSymbol) { - this.semanticInfoChain.addDiagnosticFromAST(funcDeclAST, TypeScript.DiagnosticCode.Setter_0_already_declared, [setAccessorDeclaration.getDisplayName()]); - accessorSymbol = null; - setterSymbol = null; - } - } - } - - if (accessorSymbol) { - parentHadSymbol = true; - - if (setterSymbol) { - setterTypeSymbol = setterSymbol.type; - } - } - - if (!accessorSymbol) { - accessorSymbol = new TypeScript.PullAccessorSymbol(funcName); - } - - if (!setterSymbol) { - setterSymbol = new TypeScript.PullSymbol(funcName, 16384 /* Function */); - setterTypeSymbol = new TypeScript.PullTypeSymbol("", 16777216 /* FunctionType */); - setterTypeSymbol.setFunctionSymbol(setterSymbol); - - setterSymbol.type = setterTypeSymbol; - - accessorSymbol.setSetter(setterSymbol); - } - - setAccessorDeclaration.setSymbol(accessorSymbol); - accessorSymbol.addDeclaration(setAccessorDeclaration); - setterSymbol.addDeclaration(setAccessorDeclaration); - - var nameAST = funcDeclAST.propertyName; - this.semanticInfoChain.setSymbolForAST(nameAST, accessorSymbol); - this.semanticInfoChain.setSymbolForAST(funcDeclAST, setterSymbol); - - if (!parentHadSymbol) { - parent.addMember(accessorSymbol); - } - - var signature = new TypeScript.PullSignatureSymbol(1048576 /* CallSignature */, !isSignature); - - signature.addDeclaration(setAccessorDeclaration); - setAccessorDeclaration.setSignatureSymbol(signature); - - this.bindParameterSymbols(funcDeclAST, TypeScript.ASTHelpers.parametersFromParameterList(funcDeclAST.parameterList), setterTypeSymbol, 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 (this.shouldBindDeclaration(decl)) { - this.bindAllDeclsToPullSymbol(decl); - } - }; - - 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) { - case 1 /* Script */: - var childDecls = decl.getChildDecls(); - for (var i = 0; i < childDecls.length; i++) { - this.bindDeclToPullSymbol(childDecls[i]); - } - break; - - case 64 /* Enum */: - this.bindEnumDeclarationToPullSymbol(decl); - break; - - case 32 /* DynamicModule */: - case 4 /* Container */: - this.bindModuleDeclarationToPullSymbol(decl); - break; - - case 16 /* Interface */: - this.bindInterfaceDeclarationToPullSymbol(decl); - break; - - case 8 /* Class */: - this.bindClassDeclarationToPullSymbol(decl); - break; - - case 16384 /* Function */: - this.bindFunctionDeclarationToPullSymbol(decl); - break; - - case 512 /* Variable */: - this.bindVariableDeclarationToPullSymbol(decl); - break; - - case 1024 /* CatchVariable */: - this.bindCatchVariableToPullSymbol(decl); - break; - - case 67108864 /* EnumMember */: - this.bindEnumMemberDeclarationToPullSymbol(decl); - break; - - case 4096 /* Property */: - this.bindPropertyDeclarationToPullSymbol(decl); - break; - - case 65536 /* Method */: - this.bindMethodDeclarationToPullSymbol(decl); - break; - - case 32768 /* ConstructorMethod */: - this.bindConstructorDeclarationToPullSymbol(decl); - break; - - case 1048576 /* CallSignature */: - this.bindCallSignatureDeclarationToPullSymbol(decl); - break; - - case 2097152 /* ConstructSignature */: - this.bindConstructSignatureDeclarationToPullSymbol(decl); - break; - - case 4194304 /* IndexSignature */: - this.bindIndexSignatureDeclarationToPullSymbol(decl); - break; - - case 262144 /* GetAccessor */: - this.bindGetAccessorDeclarationToPullSymbol(decl); - break; - - case 524288 /* SetAccessor */: - this.bindSetAccessorDeclarationToPullSymbol(decl); - break; - - case 8388608 /* ObjectType */: - this.bindObjectTypeDeclarationToPullSymbol(decl); - break; - - case 16777216 /* FunctionType */: - this.bindFunctionTypeDeclarationToPullSymbol(decl); - break; - - case 33554432 /* ConstructorType */: - this.bindConstructorTypeDeclarationToPullSymbol(decl); - break; - - case 131072 /* FunctionExpression */: - this.bindFunctionExpressionToPullSymbol(decl); - break; - - case 128 /* TypeAlias */: - this.bindImportDeclaration(decl); - break; - - case 2048 /* Parameter */: - case 8192 /* TypeParameter */: - decl.getParentDecl().getSymbol(); - break; - - case 268435456 /* CatchBlock */: - case 134217728 /* WithBlock */: - break; - - default: - TypeScript.CompilerDiagnostics.assert(false, "Unrecognized type declaration"); - } - - TypeScript.Debug.assert(TypeScript.ArrayUtilities.last(this.declsBeingBound) === decl.declID); - this.declsBeingBound.pop(); - }; - return PullSymbolBinder; - })(); - TypeScript.PullSymbolBinder = PullSymbolBinder; -})(TypeScript || (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(); - - if (!funcSymbol) { - funcSymbol = functionDecl.getSignatureSymbol(); - } - - var functionSignature = null; - var typeSymbolWithAllSignatures = null; - if (funcSymbol.isSignature()) { - functionSignature = funcSymbol; - var parent = functionDecl.getParentDecl(); - typeSymbolWithAllSignatures = parent.getSymbol().type; - } else { - functionSignature = functionDecl.getSignatureSymbol(); - typeSymbolWithAllSignatures = funcSymbol.type; - } - var signatures; - - if (funcDecl.kind() === 137 /* ConstructorDeclaration */ || functionDecl.kind === 2097152 /* ConstructSignature */) { - signatures = typeSymbolWithAllSignatures.getConstructSignatures(); - } else if (functionDecl.kind === 4194304 /* IndexSignature */) { - signatures = typeSymbolWithAllSignatures.getIndexSignatures(); - } else { - signatures = typeSymbolWithAllSignatures.getCallSignatures(); - } - - return { - signature: functionSignature, - allSignatures: signatures - }; - } - PullHelpers.getSignatureForFuncDecl = getSignatureForFuncDecl; - - function getAccessorSymbol(getterOrSetter, semanticInfoChain) { - var functionDecl = semanticInfoChain.getDeclForAST(getterOrSetter); - var getterOrSetterSymbol = functionDecl.getSymbol(); - - return getterOrSetterSymbol; - } - PullHelpers.getAccessorSymbol = getAccessorSymbol; - - function getGetterAndSetterFunction(funcDecl, semanticInfoChain) { - var accessorSymbol = PullHelpers.getAccessorSymbol(funcDecl, semanticInfoChain); - var result = { - getter: null, - setter: null - }; - var getter = accessorSymbol.getGetter(); - if (getter) { - var getterDecl = getter.getDeclarations()[0]; - result.getter = semanticInfoChain.getASTForDecl(getterDecl); - } - var setter = accessorSymbol.getSetter(); - if (setter) { - var setterDecl = setter.getDeclarations()[0]; - result.setter = semanticInfoChain.getASTForDecl(setterDecl); - } - - return result; - } - PullHelpers.getGetterAndSetterFunction = getGetterAndSetterFunction; - - function symbolIsEnum(source) { - return source && (source.kind & (64 /* Enum */ | 67108864 /* EnumMember */)) !== 0; - } - PullHelpers.symbolIsEnum = symbolIsEnum; - - function symbolIsModule(symbol) { - return symbol && (symbol.kind === 4 /* Container */ || isOneDeclarationOfKind(symbol, 4 /* Container */)); - } - PullHelpers.symbolIsModule = symbolIsModule; - - function isOneDeclarationOfKind(symbol, kind) { - var decls = symbol.getDeclarations(); - for (var i = 0; i < decls.length; i++) { - if (decls[i].kind === kind) { - return true; - } - } - - return false; - } - - function isNameNumeric(name) { - return isFinite(+name); - } - PullHelpers.isNameNumeric = isNameNumeric; - - function typeSymbolsAreIdentical(a, b) { - if (a.isTypeReference() && !a.getIsSpecialized()) { - a = a.referencedTypeSymbol; - } - - if (b.isTypeReference() && !b.getIsSpecialized()) { - b = b.referencedTypeSymbol; - } - - return a === b; - } - PullHelpers.typeSymbolsAreIdentical = typeSymbolsAreIdentical; - - function getRootType(type) { - var rootType = type.getRootSymbol(); - - while (true) { - if (type === rootType) { - return type; - } - - type = rootType; - rootType = type.getRootSymbol(); - } - } - PullHelpers.getRootType = getRootType; - - function isSymbolLocal(symbol) { - var container = symbol.getContainer(); - if (container) { - var containerKind = container.kind; - if (containerKind & (1032192 /* SomeFunction */ | 16777216 /* FunctionType */)) { - return true; - } - - if (containerKind === 33554432 /* ConstructorType */ && !symbol.anyDeclHasFlag(16 /* Static */ | 1 /* Exported */)) { - return true; - } - } - - 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; - -var TypeScript; -(function (TypeScript) { - TypeScript.fileResolutionTime = 0; - TypeScript.fileResolutionIOTime = 0; - TypeScript.fileResolutionScanImportsTime = 0; - TypeScript.fileResolutionImportFileSearchTime = 0; - TypeScript.fileResolutionGetDefaultLibraryTime = 0; - TypeScript.sourceCharactersCompiled = 0; - TypeScript.syntaxTreeParseTime = 0; - TypeScript.syntaxDiagnosticsTime = 0; - TypeScript.astTranslationTime = 0; - TypeScript.typeCheckTime = 0; - - TypeScript.compilerResolvePathTime = 0; - TypeScript.compilerDirectoryNameTime = 0; - TypeScript.compilerDirectoryExistsTime = 0; - TypeScript.compilerFileExistsTime = 0; - - TypeScript.emitTime = 0; - TypeScript.emitWriteFileTime = 0; - - TypeScript.declarationEmitTime = 0; - TypeScript.declarationEmitIsExternallyVisibleTime = 0; - TypeScript.declarationEmitTypeSignatureTime = 0; - TypeScript.declarationEmitGetBoundDeclTypeTime = 0; - TypeScript.declarationEmitIsOverloadedCallSignatureTime = 0; - TypeScript.declarationEmitFunctionDeclarationGetSymbolTime = 0; - TypeScript.declarationEmitGetBaseTypeTime = 0; - TypeScript.declarationEmitGetAccessorFunctionTime = 0; - TypeScript.declarationEmitGetTypeParameterSymbolTime = 0; - TypeScript.declarationEmitGetImportDeclarationSymbolTime = 0; - - TypeScript.ioHostResolvePathTime = 0; - TypeScript.ioHostDirectoryNameTime = 0; - 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(emitOutputResult) { - if (typeof emitOutputResult === "undefined") { emitOutputResult = 0 /* Succeeded */; } - this.outputFiles = []; - this.emitOutputResult = emitOutputResult; - } - return EmitOutput; - })(); - TypeScript.EmitOutput = EmitOutput; - - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(TypeScript.OutputFileType || (TypeScript.OutputFileType = {})); - var OutputFileType = TypeScript.OutputFileType; - - var OutputFile = (function () { - function OutputFile(name, writeByteOrderMark, text, fileType, sourceMapEntries) { - if (typeof sourceMapEntries === "undefined") { sourceMapEntries = []; } - this.name = name; - this.writeByteOrderMark = writeByteOrderMark; - this.text = text; - this.fileType = fileType; - this.sourceMapEntries = sourceMapEntries; - } - return OutputFile; - })(); - TypeScript.OutputFile = OutputFile; - - var CompileResult = (function () { - function CompileResult() { - this.diagnostics = []; - this.outputFiles = []; - } - CompileResult.fromDiagnostics = function (diagnostics) { - var result = new CompileResult(); - result.diagnostics = diagnostics; - return result; - }; - - CompileResult.fromOutputFiles = function (outputFiles) { - var result = new CompileResult(); - result.outputFiles = outputFiles; - return result; - }; - return CompileResult; - })(); - TypeScript.CompileResult = CompileResult; - - var TypeScriptCompiler = (function () { - function TypeScriptCompiler(logger, _settings) { - if (typeof logger === "undefined") { logger = new TypeScript.NullLogger(); } - if (typeof _settings === "undefined") { _settings = TypeScript.ImmutableCompilationSettings.defaultSettings(); } - this.logger = logger; - this._settings = _settings; - this.semanticInfoChain = null; - this.semanticInfoChain = new TypeScript.SemanticInfoChain(this, logger); - } - TypeScriptCompiler.prototype.compilationSettings = function () { - return this._settings; - }; - - TypeScriptCompiler.prototype.setCompilationSettings = function (newSettings) { - var oldSettings = this._settings; - this._settings = newSettings; - - if (!compareDataObjects(oldSettings, newSettings)) { - this.semanticInfoChain.invalidate(oldSettings, newSettings); - } - }; - - TypeScriptCompiler.prototype.getDocument = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.semanticInfoChain.getDocument(fileName); - }; - - TypeScriptCompiler.prototype.cleanupSemanticCache = function () { - this.semanticInfoChain.invalidate(); - }; - - TypeScriptCompiler.prototype.addFile = function (fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles) { - if (typeof referencedFiles === "undefined") { referencedFiles = []; } - fileName = TypeScript.switchToForwardSlashes(fileName); - - TypeScript.sourceCharactersCompiled += scriptSnapshot.getLength(); - - var document = TypeScript.Document.create(this, this.semanticInfoChain, fileName, scriptSnapshot, byteOrderMark, version, isOpen, referencedFiles); - - this.semanticInfoChain.addDocument(document); - }; - - TypeScriptCompiler.prototype.updateFile = function (fileName, scriptSnapshot, version, isOpen, textChangeRange) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - var updatedDocument = document.update(scriptSnapshot, version, isOpen, textChangeRange); - - this.semanticInfoChain.addDocument(updatedDocument); - }; - - TypeScriptCompiler.prototype.removeFile = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - this.semanticInfoChain.removeDocument(fileName); - }; - - TypeScriptCompiler.prototype.mapOutputFileName = function (document, emitOptions, extensionChanger) { - if (document.emitToOwnOutputFile()) { - var updatedFileName = document.fileName; - if (emitOptions.outputDirectory() !== "") { - updatedFileName = document.fileName.replace(emitOptions.commonDirectoryPath(), ""); - updatedFileName = emitOptions.outputDirectory() + updatedFileName; - } - return extensionChanger(updatedFileName, false); - } else { - return extensionChanger(emitOptions.sharedOutputFile(), true); - } - }; - - TypeScriptCompiler.prototype.writeByteOrderMarkForDocument = function (document) { - var printReason = false; - - if (document.emitToOwnOutputFile()) { - var result = document.byteOrderMark !== 0 /* None */; - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - } - return result; - } else { - var fileNames = this.fileNames(); - - var result = false; - for (var i = 0, n = fileNames.length; i < n; i++) { - var document = this.getDocument(fileNames[i]); - - if (document.isExternalModule()) { - continue; - } - - if (document.byteOrderMark !== 0 /* None */) { - if (printReason) { - TypeScript.Environment.standardOut.WriteLine("Emitting byte order mark because of: " + document.fileName); - result = true; - } else { - return true; - } - } - } - - return result; - } - }; - - TypeScriptCompiler.mapToDTSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScript.getDeclareFilePath(fileName); - }; - - TypeScriptCompiler.prototype._shouldEmit = function (document) { - return !document.isDeclareFile(); - }; - - TypeScriptCompiler.prototype._shouldEmitDeclarations = function (document) { - if (!this.compilationSettings().generateDeclarationFiles()) { - return false; - } - - return this._shouldEmit(document); - }; - - TypeScriptCompiler.prototype.emitDocumentDeclarationsWorker = function (document, emitOptions, declarationEmitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmitDeclarations(document)); - - if (declarationEmitter) { - declarationEmitter.document = document; - } else { - var declareFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToDTSFileName); - declarationEmitter = new TypeScript.DeclarationEmitter(declareFileName, document, this, emitOptions, this.semanticInfoChain); - } - - declarationEmitter.emitDeclarations(sourceUnit); - return declarationEmitter; - }; - - TypeScriptCompiler.prototype._emitDocumentDeclarations = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmitDeclarations(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFile()); - } - } else { - sharedEmitter = this.emitDocumentDeclarationsWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAllDeclarations = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var sharedEmitter = null; - var fileNames = this.fileNames(); - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileNames[i]); - - sharedEmitter = this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push(sharedEmitter.getOutputFile()); - } - - TypeScript.declarationEmitTime += new Date().getTime() - start; - - return emitOutput; - }; - - TypeScriptCompiler.prototype.emitDeclarations = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocumentDeclarations(document, emitOptions, function (file) { - return emitOutput.outputFiles.push(file); - }, null); - return emitOutput; - } else { - return this.emitAllDeclarations(resolvePath); - } - }; - - 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; - } else { - var splitFname = fileName.split("."); - splitFname.pop(); - return splitFname.join(".") + extension; - } - }; - - TypeScriptCompiler.mapToJSFileName = function (fileName, wholeFileNameReplaced) { - return TypeScriptCompiler.mapToFileNameExtension(".js", fileName, wholeFileNameReplaced); - }; - - TypeScriptCompiler.prototype.emitDocumentWorker = function (document, emitOptions, emitter) { - var sourceUnit = document.sourceUnit(); - TypeScript.Debug.assert(this._shouldEmit(document)); - - var typeScriptFileName = document.fileName; - if (!emitter) { - var javaScriptFileName = this.mapOutputFileName(document, emitOptions, TypeScriptCompiler.mapToJSFileName); - var outFile = new TypeScript.TextWriter(javaScriptFileName, this.writeByteOrderMarkForDocument(document), 0 /* JavaScript */); - - emitter = new TypeScript.Emitter(javaScriptFileName, outFile, emitOptions, this.semanticInfoChain); - - if (this.compilationSettings().mapSourceFiles()) { - var sourceMapFile = new TypeScript.TextWriter(javaScriptFileName + TypeScript.SourceMapper.MapFileExtension, false, 1 /* SourceMap */); - emitter.createSourceMapper(document, javaScriptFileName, outFile, sourceMapFile, emitOptions.resolvePath); - } - } else if (this.compilationSettings().mapSourceFiles()) { - emitter.setSourceMapperNewSourceFile(document); - } - - emitter.setDocument(document); - emitter.emitJavascript(sourceUnit, false); - - return emitter; - }; - - TypeScriptCompiler.prototype._emitDocument = function (document, emitOptions, onSingleFileEmitComplete, sharedEmitter) { - if (this._shouldEmit(document)) { - if (document.emitToOwnOutputFile()) { - var singleEmitter = this.emitDocumentWorker(document, emitOptions); - if (singleEmitter) { - onSingleFileEmitComplete(singleEmitter.getOutputFiles()); - } - } else { - sharedEmitter = this.emitDocumentWorker(document, emitOptions, sharedEmitter); - } - } - - return sharedEmitter; - }; - - TypeScriptCompiler.prototype.emitAll = function (resolvePath) { - var start = new Date().getTime(); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var fileNames = this.fileNames(); - var sharedEmitter = null; - - for (var i = 0, n = fileNames.length; i < n; i++) { - var fileName = fileNames[i]; - - var document = this.getDocument(fileName); - - sharedEmitter = this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, sharedEmitter); - } - - if (sharedEmitter) { - emitOutput.outputFiles.push.apply(emitOutput.outputFiles, sharedEmitter.getOutputFiles()); - } - - TypeScript.emitTime += new Date().getTime() - start; - return emitOutput; - }; - - TypeScriptCompiler.prototype.emit = function (fileName, resolvePath) { - fileName = TypeScript.switchToForwardSlashes(fileName); - var emitOutput = new EmitOutput(); - - var emitOptions = new TypeScript.EmitOptions(this, resolvePath); - if (emitOptions.diagnostic()) { - emitOutput.emitOutputResult = 2 /* FailedBecauseOfCompilerOptionsErrors */; - return emitOutput; - } - - var document = this.getDocument(fileName); - - if (document.emitToOwnOutputFile()) { - this._emitDocument(document, emitOptions, function (files) { - return emitOutput.outputFiles.push.apply(emitOutput.outputFiles, files); - }, null); - return emitOutput; - } else { - return this.emitAll(resolvePath); - } - }; - - TypeScriptCompiler.prototype.compile = function (resolvePath, continueOnDiagnostics) { - if (typeof continueOnDiagnostics === "undefined") { continueOnDiagnostics = false; } - return new CompilerIterator(this, resolvePath, continueOnDiagnostics); - }; - - TypeScriptCompiler.prototype.getSyntacticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - return this.getDocument(fileName).diagnostics(); - }; - - TypeScriptCompiler.prototype.getSyntaxTree = function (fileName) { - return this.getDocument(fileName).syntaxTree(); - }; - - TypeScriptCompiler.prototype.getSourceUnit = function (fileName) { - return this.getDocument(fileName).sourceUnit(); - }; - - TypeScriptCompiler.prototype.getSemanticDiagnostics = function (fileName) { - fileName = TypeScript.switchToForwardSlashes(fileName); - - var document = this.getDocument(fileName); - - var startTime = (new Date()).getTime(); - TypeScript.PullTypeResolver.typeCheck(this.compilationSettings(), this.semanticInfoChain, document); - var endTime = (new Date()).getTime(); - - TypeScript.typeCheckTime += endTime - startTime; - - var errors = this.semanticInfoChain.getDiagnostics(fileName); - - errors = TypeScript.ArrayUtilities.distinct(errors, TypeScript.Diagnostic.equals); - errors.sort(function (d1, d2) { - if (d1.fileName() < d2.fileName()) { - return -1; - } else if (d1.fileName() > d2.fileName()) { - return 1; - } - - if (d1.start() < d2.start()) { - return -1; - } else if (d1.start() > d2.start()) { - return 1; - } - - var code1 = TypeScript.diagnosticInformationMap[d1.diagnosticKey()].code; - var code2 = TypeScript.diagnosticInformationMap[d2.diagnosticKey()].code; - if (code1 < code2) { - return -1; - } else if (code1 > code2) { - return 1; - } - - return 0; - }); - - 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++) { - this.getSemanticDiagnostics(fileNames[i]); - } - }; - - TypeScriptCompiler.prototype.getSymbolOfDeclaration = function (decl) { - if (!decl) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var ast = this.semanticInfoChain.getASTForDecl(decl); - if (!ast) { - return null; - } - - var enclosingDecl = resolver.getEnclosingDecl(decl); - if (ast.kind() === 139 /* GetAccessor */ || ast.kind() === 140 /* SetAccessor */) { - return this.getSymbolOfDeclaration(enclosingDecl); - } - - return resolver.resolveAST(ast, false, new TypeScript.PullTypeResolutionContext(resolver)); - }; - - TypeScriptCompiler.prototype.extractResolutionContextFromAST = function (resolver, ast, document, propagateContextualTypes) { - var scriptName = document.fileName; - - var enclosingDecl = null; - var enclosingDeclAST = null; - var inContextuallyTypedAssignment = false; - var inWithBlock = false; - - var resolutionContext = new TypeScript.PullTypeResolutionContext(resolver); - - if (!ast) { - return null; - } - - var path = this.getASTPath(ast); - - for (var i = 0, n = path.length; i < n; i++) { - var current = path[i]; - - switch (current.kind()) { - case 222 /* FunctionExpression */: - case 219 /* SimpleArrowFunctionExpression */: - case 218 /* ParenthesizedArrowFunctionExpression */: - if (propagateContextualTypes) { - resolver.resolveAST(current, true, resolutionContext); - } - break; - - case 136 /* MemberVariableDeclaration */: - var memberVariable = current; - inContextuallyTypedAssignment = memberVariable.variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, memberVariable, memberVariable.variableDeclarator.equalsValueClause); - break; - - case 225 /* VariableDeclarator */: - var variableDeclarator = current; - inContextuallyTypedAssignment = variableDeclarator.typeAnnotation !== null; - - this.extractResolutionContextForVariable(inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, variableDeclarator, variableDeclarator.equalsValueClause); - break; - - case 213 /* InvocationExpression */: - case 216 /* ObjectCreationExpression */: - if (propagateContextualTypes) { - var isNew = current.kind() === 216 /* ObjectCreationExpression */; - var callExpression = current; - var contextualType = null; - - if ((i + 2 < n) && callExpression.argumentList === path[i + 1] && callExpression.argumentList.arguments === path[i + 2]) { - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext, callResolutionResults); - } - - if (callResolutionResults.actualParametersContextTypeSymbols) { - var argExpression = path[i + 3]; - if (argExpression) { - for (var j = 0, m = callExpression.argumentList.arguments.nonSeparatorCount(); j < m; j++) { - if (callExpression.argumentList.arguments.nonSeparatorAt(j) === argExpression) { - var callContextualType = callResolutionResults.actualParametersContextTypeSymbols[j]; - if (callContextualType) { - contextualType = callContextualType; - break; - } - } - } - } - } - } else { - if (isNew) { - resolver.resolveObjectCreationExpression(callExpression, resolutionContext); - } else { - resolver.resolveInvocationExpression(callExpression, resolutionContext); - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 214 /* ArrayLiteralExpression */: - if (propagateContextualTypes) { - var contextualType = null; - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isArrayNamedTypeReference()) { - contextualType = currentContextualType.getElementType(); - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 215 /* ObjectLiteralExpression */: - if (propagateContextualTypes) { - var objectLiteralExpression = current; - var objectLiteralResolutionContext = new TypeScript.PullAdditionalObjectLiteralResolutionData(); - resolver.resolveObjectLiteralExpression(objectLiteralExpression, inContextuallyTypedAssignment, resolutionContext, objectLiteralResolutionContext); - - var memeberAST = (path[i + 1] && path[i + 1].kind() === 2 /* SeparatedList */) ? path[i + 2] : path[i + 1]; - if (memeberAST) { - var contextualType = null; - var memberDecls = objectLiteralExpression.propertyAssignments; - if (memberDecls && objectLiteralResolutionContext.membersContextTypeSymbols) { - for (var j = 0, m = memberDecls.nonSeparatorCount(); j < m; j++) { - if (memberDecls.nonSeparatorAt(j) === memeberAST) { - var memberContextualType = objectLiteralResolutionContext.membersContextTypeSymbols[j]; - if (memberContextualType) { - contextualType = memberContextualType; - break; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - } - - break; - - case 174 /* AssignmentExpression */: - if (propagateContextualTypes) { - var assignmentExpression = current; - var contextualType = null; - - if (path[i + 1] && path[i + 1] === assignmentExpression.right) { - var leftType = resolver.resolveAST(assignmentExpression.left, inContextuallyTypedAssignment, resolutionContext).type; - if (leftType) { - inContextuallyTypedAssignment = true; - contextualType = leftType; - } - } - - 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; - - case 150 /* ReturnStatement */: - if (propagateContextualTypes) { - var returnStatement = current; - var contextualType = null; - - if (enclosingDecl && (enclosingDecl.kind & 1032192 /* SomeFunction */)) { - var typeAnnotation = TypeScript.ASTHelpers.getType(enclosingDeclAST); - if (typeAnnotation) { - var returnTypeSymbol = resolver.resolveTypeReference(typeAnnotation, resolutionContext); - if (returnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = returnTypeSymbol; - } - } else { - var currentContextualType = resolutionContext.getContextualType(); - if (currentContextualType && currentContextualType.isFunction()) { - var contextualSignatures = currentContextualType.kind == 33554432 /* ConstructorType */ ? currentContextualType.getConstructSignatures() : currentContextualType.getCallSignatures(); - var currentContextualTypeSignatureSymbol = contextualSignatures[0]; - var currentContextualTypeReturnTypeSymbol = currentContextualTypeSignatureSymbol.returnType; - if (currentContextualTypeReturnTypeSymbol) { - inContextuallyTypedAssignment = true; - contextualType = currentContextualTypeReturnTypeSymbol; - } - } - } - } - - resolutionContext.pushNewContextualType(contextualType); - } - - break; - - case 122 /* ObjectType */: - if (propagateContextualTypes && TypeScript.isTypesOnlyLocation(current)) { - resolver.resolveAST(current, false, resolutionContext); - } - - break; - - case 163 /* WithStatement */: - inWithBlock = true; - break; - - case 146 /* Block */: - inContextuallyTypedAssignment = false; - break; - } - - var decl = this.semanticInfoChain.getDeclForAST(current); - if (decl) { - enclosingDecl = decl; - enclosingDeclAST = current; - } - } - - if (ast && ast.parent && ast.kind() === 11 /* IdentifierName */) { - if (ast.parent.kind() === 212 /* MemberAccessExpression */) { - if (ast.parent.name === ast) { - ast = ast.parent; - } - } else if (ast.parent.kind() === 121 /* QualifiedName */) { - if (ast.parent.right === ast) { - ast = ast.parent; - } - } - } - - return { - ast: ast, - enclosingDecl: enclosingDecl, - resolutionContext: resolutionContext, - inContextuallyTypedAssignment: inContextuallyTypedAssignment, - inWithBlock: inWithBlock - }; - }; - - TypeScriptCompiler.prototype.extractResolutionContextForVariable = function (inContextuallyTypedAssignment, propagateContextualTypes, resolver, resolutionContext, enclosingDecl, assigningAST, init) { - if (inContextuallyTypedAssignment) { - if (propagateContextualTypes) { - resolver.resolveAST(assigningAST, false, resolutionContext); - var varSymbol = this.semanticInfoChain.getSymbolForAST(assigningAST); - - var contextualType = null; - if (varSymbol && inContextuallyTypedAssignment) { - contextualType = varSymbol.type; - } - - resolutionContext.pushNewContextualType(contextualType); - - if (init) { - resolver.resolveAST(init, inContextuallyTypedAssignment, resolutionContext); - } - } - } - }; - - TypeScriptCompiler.prototype.getASTPath = function (ast) { - var result = []; - - while (ast) { - result.unshift(ast); - ast = ast.parent; - } - - return result; - }; - - TypeScriptCompiler.prototype.pullGetSymbolInformationFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - ast = context.ast; - 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()]); - return null; - } - - if (symbol.isTypeReference()) { - symbol = symbol.getReferencedTypeSymbol(); - } - - var aliasSymbol = this.semanticInfoChain.getAliasSymbolForAST(ast); - - return { - symbol: symbol, - aliasSymbol: aliasSymbol, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetCallInformationFromAST = function (ast, document) { - if (ast.kind() !== 213 /* InvocationExpression */ && ast.kind() !== 216 /* ObjectCreationExpression */) { - return null; - } - - var isNew = ast.kind() === 216 /* ObjectCreationExpression */; - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var callResolutionResults = new TypeScript.PullAdditionalCallResolutionData(); - - if (isNew) { - resolver.resolveObjectCreationExpression(ast, context.resolutionContext, callResolutionResults); - } else { - resolver.resolveInvocationExpression(ast, context.resolutionContext, callResolutionResults); - } - - return { - targetSymbol: callResolutionResults.targetSymbol, - resolvedSignatures: callResolutionResults.resolvedSignatures, - candidateSignature: callResolutionResults.candidateSignature, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl), - isConstructorCall: isNew - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleMemberSymbolsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var symbols = resolver.getVisibleMembersFromExpression(ast, context.enclosingDecl, context.resolutionContext); - if (!symbols) { - return null; - } - - return { - symbols: symbols, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetVisibleDeclsFromAST = function (ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, false); - if (!context || context.inWithBlock) { - return null; - } - - return resolver.getVisibleDecls(context.enclosingDecl); - }; - - TypeScriptCompiler.prototype.pullGetContextualMembersFromAST = function (ast, document) { - if (ast.kind() !== 215 /* ObjectLiteralExpression */) { - return null; - } - - var resolver = this.semanticInfoChain.getResolver(); - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var members = resolver.getVisibleContextSymbols(context.enclosingDecl, context.resolutionContext); - - return { - symbols: members, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.pullGetDeclInformation = function (decl, ast, document) { - var resolver = this.semanticInfoChain.getResolver(); - - var context = this.extractResolutionContextFromAST(resolver, ast, document, true); - if (!context || context.inWithBlock) { - return null; - } - - var astForDecl = decl.ast(); - if (!astForDecl) { - return null; - } - - var astForDeclContext = this.extractResolutionContextFromAST(resolver, astForDecl, this.getDocument(astForDecl.fileName()), true); - if (!astForDeclContext) { - return null; - } - - var symbol = decl.getSymbol(); - resolver.resolveDeclaredSymbol(symbol, context.resolutionContext); - symbol.setUnresolved(); - - return { - symbol: symbol, - aliasSymbol: null, - ast: ast, - enclosingScopeSymbol: this.getSymbolOfDeclaration(context.enclosingDecl) - }; - }; - - TypeScriptCompiler.prototype.topLevelDeclaration = function (fileName) { - return this.semanticInfoChain.topLevelDecl(fileName); - }; - - TypeScriptCompiler.prototype.getDeclForAST = function (ast) { - return this.semanticInfoChain.getDeclForAST(ast); - }; - - TypeScriptCompiler.prototype.fileNames = function () { - return this.semanticInfoChain.fileNames(); - }; - - 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; - - var CompilerPhase; - (function (CompilerPhase) { - CompilerPhase[CompilerPhase["Syntax"] = 0] = "Syntax"; - CompilerPhase[CompilerPhase["Semantics"] = 1] = "Semantics"; - CompilerPhase[CompilerPhase["EmitOptionsValidation"] = 2] = "EmitOptionsValidation"; - CompilerPhase[CompilerPhase["Emit"] = 3] = "Emit"; - CompilerPhase[CompilerPhase["DeclarationEmit"] = 4] = "DeclarationEmit"; - })(CompilerPhase || (CompilerPhase = {})); - - var CompilerIterator = (function () { - function CompilerIterator(compiler, resolvePath, continueOnDiagnostics, startingPhase) { - if (typeof startingPhase === "undefined") { startingPhase = 0 /* Syntax */; } - this.compiler = compiler; - this.resolvePath = resolvePath; - this.continueOnDiagnostics = continueOnDiagnostics; - this.index = -1; - this.fileNames = null; - this._current = null; - this._emitOptions = null; - this._sharedEmitter = null; - this._sharedDeclarationEmitter = null; - this.hadSyntacticDiagnostics = false; - this.hadSemanticDiagnostics = false; - this.hadEmitDiagnostics = false; - this.fileNames = compiler.fileNames(); - this.compilerPhase = startingPhase; - } - CompilerIterator.prototype.current = function () { - return this._current; - }; - - CompilerIterator.prototype.moveNext = function () { - this._current = null; - - while (this.moveNextInternal()) { - if (this._current) { - return true; - } - } - - return false; - }; - - CompilerIterator.prototype.moveNextInternal = function () { - this.index++; - - while (this.shouldMoveToNextPhase()) { - this.index = 0; - this.compilerPhase++; - } - - if (this.compilerPhase > 4 /* DeclarationEmit */) { - return false; - } - - switch (this.compilerPhase) { - case 0 /* Syntax */: - return this.moveNextSyntaxPhase(); - case 1 /* Semantics */: - return this.moveNextSemanticsPhase(); - case 2 /* EmitOptionsValidation */: - return this.moveNextEmitOptionsValidationPhase(); - case 3 /* Emit */: - return this.moveNextEmitPhase(); - case 4 /* DeclarationEmit */: - return this.moveNextDeclarationEmitPhase(); - } - }; - - CompilerIterator.prototype.shouldMoveToNextPhase = function () { - switch (this.compilerPhase) { - case 2 /* EmitOptionsValidation */: - return this.index === 1; - - case 0 /* Syntax */: - case 1 /* Semantics */: - return this.index === this.fileNames.length; - - case 3 /* Emit */: - case 4 /* DeclarationEmit */: - return this.index === (this.fileNames.length + 1); - } - - return false; - }; - - CompilerIterator.prototype.moveNextSyntaxPhase = function () { - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - - var diagnostics = this.compiler.getSyntacticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSyntacticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextSemanticsPhase = function () { - if (this.hadSyntacticDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index < this.fileNames.length); - var fileName = this.fileNames[this.index]; - var diagnostics = this.compiler.getSemanticDiagnostics(fileName); - if (diagnostics.length) { - if (!this.continueOnDiagnostics) { - this.hadSemanticDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics(diagnostics); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitOptionsValidationPhase = function () { - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - - if (!this._emitOptions) { - this._emitOptions = new TypeScript.EmitOptions(this.compiler, this.resolvePath); - } - - if (this._emitOptions.diagnostic()) { - if (!this.continueOnDiagnostics) { - this.hadEmitDiagnostics = true; - } - - this._current = CompileResult.fromDiagnostics([this._emitOptions.diagnostic()]); - } - - return true; - }; - - CompilerIterator.prototype.moveNextEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(this._emitOptions); - - if (this.hadEmitDiagnostics) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedEmitter = this.compiler._emitDocument(document, this._emitOptions, function (outputFiles) { - _this._current = CompileResult.fromOutputFiles(outputFiles); - }, this._sharedEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedEmitter) { - this._current = CompileResult.fromOutputFiles(this._sharedEmitter.getOutputFiles()); - } - - return true; - }; - - CompilerIterator.prototype.moveNextDeclarationEmitPhase = function () { - var _this = this; - TypeScript.Debug.assert(!this.hadSyntacticDiagnostics); - TypeScript.Debug.assert(!this.hadEmitDiagnostics); - if (this.hadSemanticDiagnostics) { - return false; - } - - if (!this.compiler.compilationSettings().generateDeclarationFiles()) { - return false; - } - - TypeScript.Debug.assert(this.index >= 0 && this.index <= this.fileNames.length); - if (this.index < this.fileNames.length) { - var fileName = this.fileNames[this.index]; - var document = this.compiler.getDocument(fileName); - - this._sharedDeclarationEmitter = this.compiler._emitDocumentDeclarations(document, this._emitOptions, function (file) { - _this._current = CompileResult.fromOutputFiles([file]); - }, this._sharedDeclarationEmitter); - return true; - } - - if (this.index === this.fileNames.length && this._sharedDeclarationEmitter) { - this._current = CompileResult.fromOutputFiles([this._sharedDeclarationEmitter.getOutputFile()]); - } - - return true; - }; - return CompilerIterator; - })(); - - function compareDataObjects(dst, src) { - for (var e in dst) { - if (typeof dst[e] === "object") { - if (!compareDataObjects(dst[e], src[e])) - return false; - } else if (typeof dst[e] !== "function") { - if (dst[e] !== src[e]) - return false; - } - } - return true; - } - TypeScript.compareDataObjects = compareDataObjects; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - (function (GenerativeTypeClassification) { - GenerativeTypeClassification[GenerativeTypeClassification["Unknown"] = 0] = "Unknown"; - GenerativeTypeClassification[GenerativeTypeClassification["Open"] = 1] = "Open"; - GenerativeTypeClassification[GenerativeTypeClassification["Closed"] = 2] = "Closed"; - GenerativeTypeClassification[GenerativeTypeClassification["InfinitelyExpanding"] = 3] = "InfinitelyExpanding"; - })(TypeScript.GenerativeTypeClassification || (TypeScript.GenerativeTypeClassification = {})); - var GenerativeTypeClassification = TypeScript.GenerativeTypeClassification; - - var PullTypeReferenceSymbol = (function (_super) { - __extends(PullTypeReferenceSymbol, _super); - function PullTypeReferenceSymbol(referencedTypeSymbol) { - _super.call(this, referencedTypeSymbol.name, referencedTypeSymbol.kind); - this.referencedTypeSymbol = referencedTypeSymbol; - this.isResolved = true; - - TypeScript.Debug.assert(referencedTypeSymbol !== null, "Type root symbol may not be null"); - - this.setRootSymbol(referencedTypeSymbol); - - this.typeReference = this; - } - PullTypeReferenceSymbol.createTypeReference = function (type) { - if (type.isTypeReference()) { - return type; - } - - var typeReference = type.typeReference; - - if (!typeReference) { - typeReference = new PullTypeReferenceSymbol(type); - type.typeReference = typeReference; - } - - return typeReference; - }; - - PullTypeReferenceSymbol.prototype.isTypeReference = function () { - return true; - }; - - PullTypeReferenceSymbol.prototype.setResolved = function () { - }; - - PullTypeReferenceSymbol.prototype.setUnresolved = function () { - }; - PullTypeReferenceSymbol.prototype.invalidate = function () { - }; - - PullTypeReferenceSymbol.prototype.ensureReferencedTypeIsResolved = function () { - this._getResolver().resolveDeclaredSymbol(this.referencedTypeSymbol); - }; - - PullTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol; - }; - - PullTypeReferenceSymbol.prototype._getResolver = function () { - return this.referencedTypeSymbol._getResolver(); - }; - - PullTypeReferenceSymbol.prototype.hasMembers = function () { - return this.referencedTypeSymbol.hasMembers(); - }; - - PullTypeReferenceSymbol.prototype.setAssociatedContainerType = function (type) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setAssociatedContainerType"); - }; - - PullTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - return this.referencedTypeSymbol.getAssociatedContainerType(); - }; - - PullTypeReferenceSymbol.prototype.getFunctionSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getFunctionSymbol(); - }; - PullTypeReferenceSymbol.prototype.setFunctionSymbol = function (symbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setFunctionSymbol"); - }; - - PullTypeReferenceSymbol.prototype.addContainedNonMember = function (nonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addContainedNonMember"); - }; - PullTypeReferenceSymbol.prototype.findContainedNonMemberContainer = function (containerName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.findContainedNonMemberContainer(containerName, kind); - }; - - PullTypeReferenceSymbol.prototype.addMember = function (memberSymbol) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberType = function (enclosedType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedMemberContainer = function (enclosedContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMember = function (enclosedNonMember) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMember"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberType = function (enclosedNonMemberType) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberType"); - }; - PullTypeReferenceSymbol.prototype.addEnclosedNonMemberContainer = function (enclosedNonMemberContainer) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addEnclosedNonMemberContainer"); - }; - PullTypeReferenceSymbol.prototype.addTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addTypeParameter"); - }; - PullTypeReferenceSymbol.prototype.addConstructorTypeParameter = function (typeParameter) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": addConstructorTypeParameter"); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMember = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMember(name); - }; - - PullTypeReferenceSymbol.prototype.findContainedNonMemberType = function (typeName, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findContainedNonMemberType(typeName, kind); - }; - - PullTypeReferenceSymbol.prototype.getMembers = function () { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getMembers(); - }; - - PullTypeReferenceSymbol.prototype.setHasDefaultConstructor = function (hasOne) { - if (typeof hasOne === "undefined") { hasOne = true; } - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ":setHasDefaultConstructor"); - }; - PullTypeReferenceSymbol.prototype.getHasDefaultConstructor = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getHasDefaultConstructor(); - }; - PullTypeReferenceSymbol.prototype.getConstructorMethod = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructorMethod(); - }; - PullTypeReferenceSymbol.prototype.setConstructorMethod = function (constructorMethod) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": setConstructorMethod"); - }; - PullTypeReferenceSymbol.prototype.getTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.isGeneric = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isGeneric(); - }; - - PullTypeReferenceSymbol.prototype.addSpecialization = function (specializedVersionOfThisType, substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.addSpecialization(specializedVersionOfThisType, substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getSpecialization = function (substitutingTypes) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getSpecialization(substitutingTypes); - }; - PullTypeReferenceSymbol.prototype.getKnownSpecializations = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getKnownSpecializations(); - }; - PullTypeReferenceSymbol.prototype.getTypeArguments = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArguments(); - }; - PullTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypeArgumentsOrTypeParameters(); - }; - - PullTypeReferenceSymbol.prototype.appendCallSignature = function (callSignature) { - TypeScript.Debug.fail("Reference symbol " + this.pullSymbolID + ": appendCallSignature"); - }; - 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"); - }; - - PullTypeReferenceSymbol.prototype.hasOwnCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getCallSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getConstructSignatures(); - }; - PullTypeReferenceSymbol.prototype.hasOwnIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.hasOwnIndexSignatures(); - }; - PullTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getIndexSignatures(); - }; - - PullTypeReferenceSymbol.prototype.addImplementedType = function (implementedType) { - this.referencedTypeSymbol.addImplementedType(implementedType); - }; - PullTypeReferenceSymbol.prototype.getImplementedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getImplementedTypes(); - }; - PullTypeReferenceSymbol.prototype.addExtendedType = function (extendedType) { - this.referencedTypeSymbol.addExtendedType(extendedType); - }; - PullTypeReferenceSymbol.prototype.getExtendedTypes = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getExtendedTypes(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExtendsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExtendsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExtendThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExtendThisType(); - }; - PullTypeReferenceSymbol.prototype.addTypeThatExplicitlyImplementsThisType = function (type) { - this.referencedTypeSymbol.addTypeThatExplicitlyImplementsThisType(type); - }; - PullTypeReferenceSymbol.prototype.getTypesThatExplicitlyImplementThisType = function () { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.getTypesThatExplicitlyImplementThisType(); - }; - - PullTypeReferenceSymbol.prototype.isValidBaseKind = function (baseType, isExtendedType) { - this.ensureReferencedTypeIsResolved(); - return this.referencedTypeSymbol.isValidBaseKind(baseType, isExtendedType); - }; - - PullTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findMember(name, lookInParent); - }; - PullTypeReferenceSymbol.prototype.findNestedType = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedType(name, kind); - }; - PullTypeReferenceSymbol.prototype.findNestedContainer = function (name, kind) { - if (typeof kind === "undefined") { kind = 0 /* None */; } - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findNestedContainer(name, kind); - }; - PullTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - }; - - PullTypeReferenceSymbol.prototype.findTypeParameter = function (name) { - this.ensureReferencedTypeIsResolved(); - - return this.referencedTypeSymbol.findTypeParameter(name); - }; - - PullTypeReferenceSymbol.prototype.hasOnlyOverloadCallSignatures = function () { - return this.referencedTypeSymbol.hasOnlyOverloadCallSignatures(); - }; - return PullTypeReferenceSymbol; - })(TypeScript.PullTypeSymbol); - TypeScript.PullTypeReferenceSymbol = PullTypeReferenceSymbol; - - TypeScript.nSpecializationsCreated = 0; - TypeScript.nSpecializedSignaturesCreated = 0; - TypeScript.nSpecializedTypeParameterCreated = 0; - - var PullInstantiatedTypeReferenceSymbol = (function (_super) { - __extends(PullInstantiatedTypeReferenceSymbol, _super); - 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 = undefined; - this._instantiatedConstructorMethod = null; - this._instantiatedAssociatedContainerType = null; - this._isArray = undefined; - this._generativeTypeClassification = []; - - TypeScript.nSpecializationsCreated++; - } - PullInstantiatedTypeReferenceSymbol.prototype.getIsSpecialized = function () { - return !this.isInstanceReferenceType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getGenerativeTypeClassification = function (enclosingType) { - if (!this.isNamedTypeSymbol()) { - return 0 /* Unknown */; - } - - 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()); - } - return this._isArray; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getElementType = function () { - if (!this.isArrayNamedTypeReference()) { - return null; - } - - var typeArguments = this.getTypeArguments(); - return typeArguments ? typeArguments[0] : null; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getReferencedTypeSymbol = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.getIsSpecialized()) { - return this; - } - - return this.referencedTypeSymbol; - }; - - 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 instantiation = rootType.getSpecialization(mutableTypeParameterMap.typeParameterArgumentMap); - if (instantiation) { - return instantiation; - } - - TypeScript.PullInstantiationHelpers.cleanUpTypeArgumentMap(type, mutableTypeParameterMap); - typeParameterArgumentMap = mutableTypeParameterMap.typeParameterArgumentMap; - - 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; - } - } - - if (isInstanceReferenceType) { - typeParameterArgumentMap = []; - } - } - - instantiation = new PullInstantiatedTypeReferenceSymbol(rootType, typeParameterArgumentMap, isInstanceReferenceType); - - rootType.addSpecialization(instantiation, resolvedTypeParameterArgumentMap); - - return instantiation; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.isGeneric = function () { - return this.getRootSymbol().isGeneric(); - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeParameterArgumentMap = function () { - return this._typeParameterArgumentMap; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArguments = function () { - if (this.isInstanceReferenceType) { - return this.getTypeParameters(); - } - - if (this._typeArgumentReferences === undefined) { - var typeParameters = this.referencedTypeSymbol.getTypeParameters(); - - if (typeParameters.length) { - var typeArgument = null; - var typeArguments = []; - - for (var i = 0; i < typeParameters.length; i++) { - typeArgument = this._typeParameterArgumentMap[typeParameters[i].pullSymbolID]; - - if (!typeArgument) { - TypeScript.Debug.fail("type argument count mismatch"); - } - - if (typeArgument) { - typeArguments[typeArguments.length] = typeArgument; - } - } - - this._typeArgumentReferences = typeArguments; - } else { - this._typeArgumentReferences = null; - } - } - - return this._typeArgumentReferences; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getTypeArgumentsOrTypeParameters = function () { - 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(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getMembers(); - } - - if (!this._instantiatedMembers) { - var referencedMembers = this.referencedTypeSymbol.getMembers(); - var referencedMember = null; - var instantiatedMember = null; - - this._instantiatedMembers = []; - - for (var i = 0; i < referencedMembers.length; i++) { - referencedMember = referencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (!this._instantiatedMemberNameCache[referencedMember.name]) { - this.populateInstantiatedMemberFromReferencedMember(referencedMember); - } - - this._instantiatedMembers[this._instantiatedMembers.length] = this._instantiatedMemberNameCache[referencedMember.name]; - } - } - - return this._instantiatedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.findMember = function (name, lookInParent) { - if (typeof lookInParent === "undefined") { lookInParent = true; } - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.findMember(name, lookInParent); - } - - var memberSymbol = this._instantiatedMemberNameCache[name]; - - if (!memberSymbol) { - var referencedMemberSymbol = this.referencedTypeSymbol.findMember(name, lookInParent); - - if (referencedMemberSymbol) { - this.populateInstantiatedMemberFromReferencedMember(referencedMemberSymbol); - memberSymbol = this._instantiatedMemberNameCache[name]; - } else { - memberSymbol = null; - } - } - - return memberSymbol; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAllMembers = function (searchDeclKind, memberVisiblity) { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - } - - var requestedMembers = []; - var allReferencedMembers = this.referencedTypeSymbol.getAllMembers(searchDeclKind, memberVisiblity); - - if (!this._allInstantiatedMemberNameCache) { - this._allInstantiatedMemberNameCache = TypeScript.createIntrinsicsObject(); - - var members = this.getMembers(); - - for (var i = 0; i < members.length; i++) { - this._allInstantiatedMemberNameCache[members[i].name] = members[i]; - } - } - - var referencedMember = null; - var requestedMember = null; - - for (var i = 0; i < allReferencedMembers.length; i++) { - referencedMember = allReferencedMembers[i]; - - this._getResolver().resolveDeclaredSymbol(referencedMember); - - if (this._allInstantiatedMemberNameCache[referencedMember.name]) { - requestedMembers[requestedMembers.length] = this._allInstantiatedMemberNameCache[referencedMember.name]; - } else { - if (!referencedMember.type.wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._allInstantiatedMemberNameCache[referencedMember.name] = referencedMember; - requestedMembers[requestedMembers.length] = referencedMember; - } else { - requestedMember = new TypeScript.PullSymbol(referencedMember.name, referencedMember.kind); - requestedMember.setRootSymbol(referencedMember); - - requestedMember.type = this._getResolver().instantiateType(referencedMember.type, this._typeParameterArgumentMap); - requestedMember.isOptional = referencedMember.isOptional; - - this._allInstantiatedMemberNameCache[requestedMember.name] = requestedMember; - requestedMembers[requestedMembers.length] = requestedMember; - } - } - } - - return requestedMembers; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructorMethod = function () { - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructorMethod(); - } - - 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); - } - - return this._instantiatedConstructorMethod; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getAssociatedContainerType = function () { - if (!this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getAssociatedContainerType(); - } - - if (!this._instantiatedAssociatedContainerType) { - var referencedAssociatedContainerType = this.referencedTypeSymbol.getAssociatedContainerType(); - - if (referencedAssociatedContainerType) { - this._instantiatedAssociatedContainerType = PullInstantiatedTypeReferenceSymbol.create(this._getResolver(), referencedAssociatedContainerType, this._typeParameterArgumentMap); - } - } - - return this._instantiatedAssociatedContainerType; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getCallSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getCallSignatures(); - } - - if (this._instantiatedCallSignatures) { - return this._instantiatedCallSignatures; - } - - var referencedCallSignatures = this.referencedTypeSymbol.getCallSignatures(); - this._instantiatedCallSignatures = []; - - for (var i = 0; i < referencedCallSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedCallSignatures[i]); - - if (!referencedCallSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = referencedCallSignatures[i]; - } else { - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length] = this._getResolver().instantiateSignature(referencedCallSignatures[i], this._typeParameterArgumentMap); - this._instantiatedCallSignatures[this._instantiatedCallSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedCallSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getConstructSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getConstructSignatures(); - } - - if (this._instantiatedConstructSignatures) { - return this._instantiatedConstructSignatures; - } - - var referencedConstructSignatures = this.referencedTypeSymbol.getConstructSignatures(); - this._instantiatedConstructSignatures = []; - - for (var i = 0; i < referencedConstructSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedConstructSignatures[i]); - - if (!referencedConstructSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = referencedConstructSignatures[i]; - } else { - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length] = this._getResolver().instantiateSignature(referencedConstructSignatures[i], this._typeParameterArgumentMap); - this._instantiatedConstructSignatures[this._instantiatedConstructSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedConstructSignatures; - }; - - PullInstantiatedTypeReferenceSymbol.prototype.getIndexSignatures = function () { - this.ensureReferencedTypeIsResolved(); - - if (this.isInstanceReferenceType) { - return this.referencedTypeSymbol.getIndexSignatures(); - } - - if (this._instantiatedIndexSignatures) { - return this._instantiatedIndexSignatures; - } - - var referencedIndexSignatures = this.referencedTypeSymbol.getIndexSignatures(); - this._instantiatedIndexSignatures = []; - - for (var i = 0; i < referencedIndexSignatures.length; i++) { - this._getResolver().resolveDeclaredSymbol(referencedIndexSignatures[i]); - - if (!referencedIndexSignatures[i].wrapsSomeTypeParameter(this._typeParameterArgumentMap)) { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = referencedIndexSignatures[i]; - } else { - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length] = this._getResolver().instantiateSignature(referencedIndexSignatures[i], this._typeParameterArgumentMap); - this._instantiatedIndexSignatures[this._instantiatedIndexSignatures.length - 1].functionType = this; - } - } - - return this._instantiatedIndexSignatures; - }; - 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) { - var SyntaxTreeToAstVisitor = (function () { - function SyntaxTreeToAstVisitor(fileName, lineMap, compilationSettings) { - this.fileName = fileName; - this.lineMap = lineMap; - this.compilationSettings = compilationSettings; - this.position = 0; - this.previousTokenTrailingComments = null; - } - SyntaxTreeToAstVisitor.visit = function (syntaxTree, fileName, compilationSettings, incrementalAST) { - var visitor = incrementalAST ? new SyntaxTreeToIncrementalAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings) : new SyntaxTreeToAstVisitor(fileName, syntaxTree.lineMap(), compilationSettings); - return syntaxTree.sourceUnit().accept(visitor); - }; - - SyntaxTreeToAstVisitor.prototype.movePast = function (element) { - if (element !== null) { - this.position += element.fullWidth(); - } - }; - - SyntaxTreeToAstVisitor.prototype.moveTo = function (element1, element2) { - if (element2 !== null) { - this.position += TypeScript.Syntax.childOffset(element1, element2); - } - }; - - SyntaxTreeToAstVisitor.prototype.setCommentsAndSpan = function (ast, fullStart, node) { - var firstToken = node.firstToken(); - var lastToken = node.lastToken(); - - this.setSpan(ast, fullStart, node, firstToken, lastToken); - ast.setPreComments(this.convertTokenLeadingComments(firstToken, fullStart)); - ast.setPostComments(this.convertNodeTrailingComments(node, lastToken, fullStart)); - }; - - SyntaxTreeToAstVisitor.prototype.createTokenSpan = function (fullStart, element) { - if (element === null) { - return null; - } - - if (element.fullWidth() === 0) { - return new TypeScript.ASTSpan(-1, -1); - } - - var leadingTriviaWidth = element.leadingTriviaWidth(); - var trailingTriviaWidth = element.trailingTriviaWidth(); - - var start = fullStart + leadingTriviaWidth; - var end = fullStart + element.fullWidth() - trailingTriviaWidth; - - return new TypeScript.ASTSpan(start, end); - }; - - SyntaxTreeToAstVisitor.prototype.setSpan = function (span, fullStart, element, firstToken, lastToken) { - if (typeof firstToken === "undefined") { firstToken = element.firstToken(); } - if (typeof lastToken === "undefined") { lastToken = element.lastToken(); } - var leadingTriviaWidth = firstToken ? firstToken.leadingTriviaWidth() : 0; - var trailingTriviaWidth = lastToken ? lastToken.trailingTriviaWidth() : 0; - - var desiredMinChar = fullStart + leadingTriviaWidth; - var desiredLimChar = fullStart + element.fullWidth() - trailingTriviaWidth; - - this.setSpanExplicit(span, desiredMinChar, desiredLimChar); - - span._trailingTriviaWidth = trailingTriviaWidth; - }; - - SyntaxTreeToAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - span._start = start; - span._end = end; - }; - - SyntaxTreeToAstVisitor.prototype.visitSyntaxList = function (node) { - var start = this.position; - var array = new Array(node.childCount()); - - for (var i = 0, n = node.childCount(); i < n; i++) { - array[i] = node.childAt(i).accept(this); - } - - var result = new TypeScript.ISyntaxList2(this.fileName, array); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var start = this.position; - var array = new Array(list.nonSeparatorCount()); - - for (var i = 0, n = list.childCount(); i < n; i++) { - if (i % 2 === 0) { - array[i / 2] = list.childAt(i).accept(this); - this.previousTokenTrailingComments = null; - } else { - var separatorToken = list.childAt(i); - this.previousTokenTrailingComments = this.convertTokenTrailingComments(separatorToken, this.position + separatorToken.leadingTriviaWidth() + separatorToken.width()); - this.movePast(separatorToken); - } - } - - var result = new TypeScript.ISeparatedSyntaxList2(this.fileName, array, list.separatorCount()); - this.setSpan(result, start, list); - - result.setPostComments(this.previousTokenTrailingComments); - this.previousTokenTrailingComments = null; - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.convertComment = function (trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); - - return comment; - }; - - SyntaxTreeToAstVisitor.prototype.convertComments = function (triviaList, commentStartPosition) { - var result = []; - - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result.push(this.convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - - commentStartPosition += trivia.fullWidth(); - } - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.mergeComments = function (comments1, comments2) { - if (comments1 === null) { - return comments2; - } - - if (comments2 === null) { - return comments1; - } - - return comments1.concat(comments2); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenLeadingComments = function (token, commentStartPosition) { - if (token === null) { - return null; - } - - var preComments = token.hasLeadingComment() ? this.convertComments(token.leadingTrivia(), commentStartPosition) : null; - - var previousTokenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - - return this.mergeComments(previousTokenTrailingComments, preComments); - }; - - SyntaxTreeToAstVisitor.prototype.convertTokenTrailingComments = function (token, commentStartPosition) { - if (token === null || !token.hasTrailingComment() || token.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(token.trailingTrivia(), commentStartPosition); - }; - - SyntaxTreeToAstVisitor.prototype.convertNodeTrailingComments = function (node, lastToken, nodeStart) { - if (lastToken === null || !lastToken.hasTrailingComment() || lastToken.hasTrailingNewLine()) { - return null; - } - - return this.convertComments(lastToken.trailingTrivia(), nodeStart + node.fullWidth() - lastToken.trailingTriviaWidth()); - }; - - SyntaxTreeToAstVisitor.prototype.visitIdentifier = function (token) { - return this.visitToken(token); - }; - - SyntaxTreeToAstVisitor.prototype.visitToken = function (token) { - var fullStart = this.position; - - var result = this.visitTokenWorker(token); - - this.movePast(token); - - var start = fullStart + token.leadingTriviaWidth(); - this.setSpanExplicit(result, start, start + token.width()); - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTokenWorker = function (token) { - switch (token.tokenKind) { - case 60 /* AnyKeyword */: - return new TypeScript.BuiltInType(60 /* AnyKeyword */, token.text(), token.valueText()); - case 61 /* BooleanKeyword */: - return new TypeScript.BuiltInType(61 /* BooleanKeyword */, token.text(), token.valueText()); - case 67 /* NumberKeyword */: - return new TypeScript.BuiltInType(67 /* NumberKeyword */, token.text(), token.valueText()); - case 69 /* StringKeyword */: - return new TypeScript.BuiltInType(69 /* StringKeyword */, token.text(), token.valueText()); - case 41 /* VoidKeyword */: - return new TypeScript.BuiltInType(41 /* VoidKeyword */, token.text(), token.valueText()); - case 35 /* ThisKeyword */: - return new TypeScript.ThisExpression(token.text(), token.valueText()); - case 50 /* SuperKeyword */: - return new TypeScript.SuperExpression(token.text(), token.valueText()); - case 37 /* TrueKeyword */: - return new TypeScript.LiteralExpression(37 /* TrueKeyword */, token.text(), token.valueText()); - case 24 /* FalseKeyword */: - return new TypeScript.LiteralExpression(24 /* FalseKeyword */, token.text(), token.valueText()); - case 32 /* NullKeyword */: - return new TypeScript.LiteralExpression(32 /* NullKeyword */, token.text(), token.valueText()); - case 14 /* StringLiteral */: - return new TypeScript.StringLiteral(token.text(), token.valueText()); - case 12 /* RegularExpressionLiteral */: - return new TypeScript.RegularExpressionLiteral(token.text(), token.valueText()); - case 13 /* NumericLiteral */: - var fullStart = this.position; - var preComments = this.convertTokenLeadingComments(token, fullStart); - - var result = new TypeScript.NumericLiteral(token.value(), token.text(), token.valueText()); - - result.setPreComments(preComments); - return result; - case 11 /* IdentifierName */: - return new TypeScript.Identifier(token.text()); - default: - throw TypeScript.Errors.invalidOperation(); - } - }; - - SyntaxTreeToAstVisitor.prototype.visitSourceUnit = function (node) { - var start = this.position; - TypeScript.Debug.assert(start === 0); - - var bod = this.visitSyntaxList(node.moduleElements); - 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; - }; - - SyntaxTreeToAstVisitor.prototype.visitExternalModuleReference = function (node) { - var start = this.position; - - this.moveTo(node, node.stringLiteral); - var stringLiteral = node.stringLiteral.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ExternalModuleReference(stringLiteral); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleNameModuleReference = function (node) { - var start = this.position; - var moduleName = node.moduleName.accept(this); - - var result = new TypeScript.ModuleNameModuleReference(moduleName); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitClassDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - this.movePast(node.openBraceToken); - var members = this.visitSyntaxList(node.classElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ClassDeclaration(modifiers, name, typeParameters, heritageClauses, members, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModifiers = function (modifiers) { - var result = null; - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 47 /* ExportKeyword */)) { - result = result || []; - result.push(1 /* Exported */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { - result = result || []; - result.push(8 /* Ambient */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 58 /* StaticKeyword */)) { - result = result || []; - result.push(16 /* Static */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 57 /* PublicKeyword */)) { - result = result || []; - result.push(4 /* Public */); - } - - if (TypeScript.SyntaxUtilities.containsToken(modifiers, 55 /* PrivateKeyword */)) { - result = result || []; - result.push(2 /* Private */); - } - - return result || TypeScript.sentinelEmptyArray; - }; - - SyntaxTreeToAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var heritageClauses = node.heritageClauses ? this.visitSyntaxList(node.heritageClauses) : null; - - var body = this.visitObjectType(node.body); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.InterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, body); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitHeritageClause = function (node) { - var start = this.position; - - this.movePast(node.extendsOrImplementsKeyword); - var typeNames = this.visitSeparatedSyntaxList(node.typeNames); - - var result = new TypeScript.HeritageClause(node.extendsOrImplementsKeyword.tokenKind === 48 /* ExtendsKeyword */ ? 230 /* ExtendsHeritageClause */ : 231 /* ImplementsHeritageClause */, typeNames); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitModuleDeclaration = function (node) { - var start = this.position; - - var modifiers = this.visitModifiers(node.modifiers); - - this.moveTo(node, node.moduleKeyword); - this.movePast(node.moduleKeyword); - - var moduleName = node.name ? node.name.accept(this) : null; - var stringLiteral = node.stringLiteral ? node.stringLiteral.accept(this) : null; - - this.movePast(node.openBraceToken); - - var moduleElements = this.visitSyntaxList(node.moduleElements); - - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ModuleDeclaration(modifiers, moduleName, stringLiteral, moduleElements, closeBraceToken); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.FunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - this.movePast(node.openBraceToken); - - var enumElements = this.visitSeparatedSyntaxList(node.enumElements); - - this.movePast(node.closeBraceToken); - - var result = new TypeScript.EnumDeclaration(this.visitModifiers(node.modifiers), identifier, enumElements); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEnumElement = function (node) { - var start = this.position; - - var memberName = this.visitToken(node.propertyName); - - var value = node.equalsValueClause !== null ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.EnumElement(memberName, value); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitImportDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.equalsToken); - var alias = node.moduleReference.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.ImportDeclaration(modifiers, name, alias); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExportAssignment = function (node) { - var start = this.position; - - this.moveTo(node, node.identifier); - var name = this.visitIdentifier(node.identifier); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExportAssignment(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclaration); - - var declaration = node.variableDeclaration.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.VariableStatement(modifiers, declaration); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarators); - var variableDecls = this.visitSeparatedSyntaxList(node.variableDeclarators); - - var result = new TypeScript.VariableDeclaration(variableDecls); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVariableDeclarator = function (node) { - var start = this.position; - var propertyName = this.visitToken(node.propertyName); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? this.visitEqualsValueClause(node.equalsValueClause) : null; - - var result = new TypeScript.VariableDeclarator(propertyName, typeExpr, init); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEqualsValueClause = function (node) { - var start = this.position; - var afterEqualsComments = this.convertTokenTrailingComments(node.equalsToken, this.position + node.equalsToken.leadingTriviaWidth() + node.equalsToken.width()); - - this.movePast(node.equalsToken); - var value = node.value.accept(this); - value.setPreComments(this.mergeComments(afterEqualsComments, value.preComments())); - - var result = new TypeScript.EqualsValueClause(value); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var start = this.position; - - this.movePast(node.operatorToken); - var operand = node.operand.accept(this); - - var result = new TypeScript.PrefixUnaryExpression(node.kind(), operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var start = this.position; - var openStart = this.position + node.openBracketToken.leadingTriviaWidth(); - this.movePast(node.openBracketToken); - - var expressions = this.visitSeparatedSyntaxList(node.expressions); - - var closeStart = this.position + node.closeBracketToken.leadingTriviaWidth(); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayLiteralExpression(expressions); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitOmittedExpression = function (node) { - var start = this.position; - - var result = new TypeScript.OmittedExpression(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var start = this.position; - - var openParenToken = node.openParenToken; - var openParenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - - this.movePast(openParenToken); - - var expr = node.expression.accept(this); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParenthesizedExpression(openParenTrailingComments, expr); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var start = this.position; - - var identifier = node.identifier.accept(this); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.SimpleArrowFunctionExpression(identifier, block, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var start = this.position; - - var callSignature = this.visitCallSignature(node.callSignature); - this.movePast(node.equalsGreaterThanToken); - - var block = node.block ? this.visitBlock(node.block) : null; - var expression = node.expression ? node.expression.accept(this) : null; - - var result = new TypeScript.ParenthesizedArrowFunctionExpression(callSignature, block, expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitType = function (type) { - return type ? type.accept(this) : null; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeQuery = function (node) { - var start = this.position; - this.movePast(node.typeOfKeyword); - var name = node.name.accept(this); - - var result = new TypeScript.TypeQuery(name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitQualifiedName = function (node) { - var start = this.position; - var left = this.visitType(node.left); - this.movePast(node.dotToken); - var right = this.visitIdentifier(node.right); - - var result = new TypeScript.QualifiedName(left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeArguments = this.visitSeparatedSyntaxList(node.typeArguments); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeArgumentList(typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorType = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.ConstructorType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionType = function (node) { - var start = this.position; - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - this.movePast(node.equalsGreaterThanToken); - var returnType = this.visitType(node.type); - - var result = new TypeScript.FunctionType(typeParameters, parameters, returnType); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectType = function (node) { - var start = this.position; - - this.movePast(node.openBraceToken); - var typeMembers = this.visitSeparatedSyntaxList(node.typeMembers); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectType(typeMembers); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArrayType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.type); - this.movePast(node.openBracketToken); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ArrayType(underlying); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGenericType = function (node) { - var start = this.position; - - var underlying = this.visitType(node.name); - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - var result = new TypeScript.GenericType(underlying, typeArguments); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeAnnotation = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.colonToken); - var type = this.visitType(node.type); - - var result = new TypeScript.TypeAnnotation(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBlock = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - this.movePast(node.openBraceToken); - var statements = this.visitSyntaxList(node.statements); - var closeBracePosition = this.position; - - var closeBraceLeadingComments = this.convertTokenLeadingComments(node.closeBraceToken, this.position); - var closeBraceToken = this.createTokenSpan(this.position, node.closeBraceToken); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.Block(statements, closeBraceLeadingComments, closeBraceToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameter = function (node) { - var start = this.position; - - var dotDotDotToken = this.createTokenSpan(this.position, node.dotDotDotToken); - - this.moveTo(node, node.identifier); - var identifier = this.visitIdentifier(node.identifier); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - var init = node.equalsValueClause ? node.equalsValueClause.accept(this) : null; - - var modifiers = this.visitModifiers(node.modifiers); - - var result = new TypeScript.Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeExpr, init); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.dotToken); - var name = this.visitIdentifier(node.name); - - var result = new TypeScript.MemberAccessExpression(expression, name); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var start = this.position; - - var operand = node.operand.accept(this); - this.movePast(node.operatorToken); - - var result = new TypeScript.PostfixUnaryExpression(node.kind() === 210 /* PostIncrementExpression */ ? 210 /* PostIncrementExpression */ : 211 /* PostDecrementExpression */, operand); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElementAccessExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - this.movePast(node.openBracketToken); - var argumentExpression = node.argumentExpression.accept(this); - this.movePast(node.closeBracketToken); - - var result = new TypeScript.ElementAccessExpression(expression, argumentExpression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitInvocationExpression = function (node) { - var start = this.position; - - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.InvocationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitArgumentList = function (node) { - if (node === null) { - return null; - } - - var start = this.position; - - var typeArguments = this.visitTypeArgumentList(node.typeArgumentList); - - this.movePast(node.openParenToken); - - 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()); - } - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ArgumentList(typeArguments, _arguments, closeParenToken); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBinaryExpression = function (node) { - var start = this.position; - - var left = node.left.accept(this); - this.movePast(node.operatorToken); - var right = node.right.accept(this); - - var result = new TypeScript.BinaryExpression(node.kind(), left, right); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConditionalExpression = function (node) { - var start = this.position; - - var condition = node.condition.accept(this); - this.movePast(node.questionToken); - var whenTrue = node.whenTrue.accept(this); - this.movePast(node.colonToken); - var whenFalse = node.whenFalse.accept(this); - - var result = new TypeScript.ConditionalExpression(condition, whenTrue, whenFalse); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructSignature = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.ConstructSignature(callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMethodSignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - - var callSignature = this.visitCallSignature(node.callSignature); - - var result = new TypeScript.MethodSignature(name, questionToken, callSignature); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexSignature = function (node) { - var start = this.position; - - this.movePast(node.openBracketToken); - - var parameter = node.parameter.accept(this); - - this.movePast(node.closeBracketToken); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.IndexSignature(parameter, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitPropertySignature = function (node) { - var start = this.position; - - var name = this.visitToken(node.propertyName); - - var questionToken = this.createTokenSpan(this.position, node.questionToken); - this.movePast(node.questionToken); - var typeExpr = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.PropertySignature(name, questionToken, typeExpr); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - - var openParenToken = node.openParenToken; - - this.previousTokenTrailingComments = this.convertTokenTrailingComments(openParenToken, start + openParenToken.leadingTriviaWidth() + openParenToken.width()); - var openParenTrailingComments = null; - if (node.parameters.childCount() === 0) { - openParenTrailingComments = this.previousTokenTrailingComments; - this.previousTokenTrailingComments = null; - } - - this.movePast(node.openParenToken); - var parameters = this.visitSeparatedSyntaxList(node.parameters); - this.movePast(node.closeParenToken); - - var result = new TypeScript.ParameterList(openParenTrailingComments, parameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCallSignature = function (node) { - var start = this.position; - - var typeParameters = this.visitTypeParameterList(node.typeParameterList); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var result = new TypeScript.CallSignature(typeParameters, parameters, returnType); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameterList = function (node) { - if (!node) { - return null; - } - - var start = this.position; - this.movePast(node.lessThanToken); - var typeParameters = this.visitSeparatedSyntaxList(node.typeParameters); - this.movePast(node.greaterThanToken); - - var result = new TypeScript.TypeParameterList(typeParameters); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeParameter = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - var constraint = node.constraint ? node.constraint.accept(this) : null; - - var result = new TypeScript.TypeParameter(identifier, constraint); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstraint = function (node) { - var start = this.position; - this.movePast(node.extendsKeyword); - var type = this.visitType(node.type); - - var result = new TypeScript.Constraint(type); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIfStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var thenBod = node.statement.accept(this); - var elseBod = node.elseClause ? node.elseClause.accept(this) : null; - - var result = new TypeScript.IfStatement(condition, thenBod, elseBod); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitElseClause = function (node) { - var start = this.position; - - this.movePast(node.elseKeyword); - var statement = node.statement.accept(this); - - var result = new TypeScript.ElseClause(statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitExpressionStatement = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var expression = node.expression.accept(this); - - var semicolonPosition = this.position; - - var postComments = this.convertComments(node.semicolonToken.trailingTrivia(), this.position + node.semicolonToken.leadingTriviaWidth() + node.semicolonToken.width()); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ExpressionStatement(expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var start = this.position; - - 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(callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitIndexMemberDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.indexSignature); - var indexSignature = node.indexSignature.accept(this); - - this.movePast(node.semicolonToken); - - var result = new TypeScript.IndexMemberDeclaration(indexSignature); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? this.visitBlock(node.block) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.MemberFunctionDeclaration(this.visitModifiers(node.modifiers), name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitGetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var returnType = this.visitTypeAnnotation(node.typeAnnotation); - - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.GetAccessor(this.visitModifiers(node.modifiers), name, parameters, returnType, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSetAccessor = function (node) { - var start = this.position; - - this.moveTo(node, node.propertyName); - var name = this.visitToken(node.propertyName); - var parameters = this.visitParameterList(node.parameterList); - var block = node.block ? node.block.accept(this) : null; - var result = new TypeScript.SetAccessor(this.visitModifiers(node.modifiers), name, parameters, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var start = this.position; - - this.moveTo(node, node.variableDeclarator); - var variableDeclarator = node.variableDeclarator.accept(this); - this.movePast(node.semicolonToken); - - var modifiers = this.visitModifiers(node.modifiers); - var result = new TypeScript.MemberVariableDeclaration(modifiers, variableDeclarator); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitThrowStatement = function (node) { - var start = this.position; - - this.movePast(node.throwKeyword); - var expression = node.expression.accept(this); - this.movePast(node.semicolonToken); - - var result = new TypeScript.ThrowStatement(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitReturnStatement = function (node) { - var start = this.position; - - this.movePast(node.returnKeyword); - var expression = node.expression ? node.expression.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ReturnStatement(expression); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var start = this.position; - - this.movePast(node.newKeyword); - var expression = node.expression.accept(this); - var argumentList = this.visitArgumentList(node.argumentList); - - var result = new TypeScript.ObjectCreationExpression(expression, argumentList); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSwitchStatement = function (node) { - var start = this.position; - - this.movePast(node.switchKeyword); - this.movePast(node.openParenToken); - var expression = node.expression.accept(this); - - var closeParenToken = this.createTokenSpan(this.position, node.closeParenToken); - this.movePast(node.closeParenToken); - this.movePast(node.openBraceToken); - var switchClauses = this.visitSyntaxList(node.switchClauses); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.SwitchStatement(expression, closeParenToken, switchClauses); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.caseKeyword); - var expression = node.expression.accept(this); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.CaseSwitchClause(expression, statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var start = this.position; - - this.movePast(node.defaultKeyword); - this.movePast(node.colonToken); - var statements = this.visitSyntaxList(node.statements); - - var result = new TypeScript.DefaultSwitchClause(statements); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitBreakStatement = function (node) { - var start = this.position; - - this.movePast(node.breakKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.BreakStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitContinueStatement = function (node) { - var start = this.position; - - this.movePast(node.continueKeyword); - var identifier = node.identifier ? node.identifier.accept(this) : null; - this.movePast(node.semicolonToken); - - var result = new TypeScript.ContinueStatement(identifier); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var initializer = node.initializer ? node.initializer.accept(this) : null; - - this.movePast(node.firstSemicolonToken); - var cond = node.condition ? node.condition.accept(this) : null; - this.movePast(node.secondSemicolonToken); - var incr = node.incrementor ? node.incrementor.accept(this) : null; - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForStatement(variableDeclaration, initializer, cond, incr, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitForInStatement = function (node) { - var start = this.position; - - this.movePast(node.forKeyword); - this.movePast(node.openParenToken); - var variableDeclaration = node.variableDeclaration ? node.variableDeclaration.accept(this) : null; - var left = node.left ? node.left.accept(this) : null; - - this.movePast(node.inKeyword); - var expression = node.expression.accept(this); - this.movePast(node.closeParenToken); - var body = node.statement.accept(this); - - var result = new TypeScript.ForInStatement(variableDeclaration, left, expression, body); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWhileStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WhileStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitWithStatement = function (node) { - var start = this.position; - - this.moveTo(node, node.condition); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.WithStatement(condition, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCastExpression = function (node) { - var start = this.position; - - this.movePast(node.lessThanToken); - var castTerm = this.visitType(node.type); - this.movePast(node.greaterThanToken); - var expression = node.expression.accept(this); - - var result = new TypeScript.CastExpression(castTerm, expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var start = this.position; - - var openStart = this.position + node.openBraceToken.leadingTriviaWidth(); - this.movePast(node.openBraceToken); - - var propertyAssignments = this.visitSeparatedSyntaxList(node.propertyAssignments); - - var closeStart = this.position + node.closeBraceToken.leadingTriviaWidth(); - this.movePast(node.closeBraceToken); - - var result = new TypeScript.ObjectLiteralExpression(propertyAssignments); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var start = this.position; - - var preComments = this.convertTokenLeadingComments(node.firstToken(), start); - var postComments = this.convertNodeTrailingComments(node, node.lastToken(), start); - - var propertyName = node.propertyName.accept(this); - - var afterColonComments = this.convertTokenTrailingComments(node.colonToken, this.position + node.colonToken.leadingTriviaWidth() + node.colonToken.width()); - - this.movePast(node.colonToken); - var expression = node.expression.accept(this); - expression.setPreComments(this.mergeComments(afterColonComments, expression.preComments())); - - var result = new TypeScript.SimplePropertyAssignment(propertyName, expression); - this.setSpan(result, start, node); - - result.setPreComments(preComments); - result.setPostComments(postComments); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var start = this.position; - - var propertyName = node.propertyName.accept(this); - var callSignature = this.visitCallSignature(node.callSignature); - var block = this.visitBlock(node.block); - - var result = new TypeScript.FunctionPropertyAssignment(propertyName, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFunctionExpression = function (node) { - var start = this.position; - - this.movePast(node.functionKeyword); - var name = node.identifier === null ? null : this.visitIdentifier(node.identifier); - - var callSignature = this.visitCallSignature(node.callSignature); - var block = node.block ? node.block.accept(this) : null; - - var result = new TypeScript.FunctionExpression(name, callSignature, block); - this.setCommentsAndSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitEmptyStatement = function (node) { - var start = this.position; - - this.movePast(node.semicolonToken); - - var result = new TypeScript.EmptyStatement(); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTryStatement = function (node) { - var start = this.position; - - this.movePast(node.tryKeyword); - var tryBody = node.block.accept(this); - - var catchClause = null; - if (node.catchClause !== null) { - catchClause = node.catchClause.accept(this); - } - - var finallyBody = null; - if (node.finallyClause !== null) { - finallyBody = node.finallyClause.accept(this); - } - - var result = new TypeScript.TryStatement(tryBody, catchClause, finallyBody); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitCatchClause = function (node) { - var start = this.position; - - this.movePast(node.catchKeyword); - this.movePast(node.openParenToken); - var identifier = this.visitIdentifier(node.identifier); - var typeAnnotation = this.visitTypeAnnotation(node.typeAnnotation); - this.movePast(node.closeParenToken); - var block = node.block.accept(this); - - var result = new TypeScript.CatchClause(identifier, typeAnnotation, block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitFinallyClause = function (node) { - var start = this.position; - this.movePast(node.finallyKeyword); - var block = node.block.accept(this); - - var result = new TypeScript.FinallyClause(block); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitLabeledStatement = function (node) { - var start = this.position; - - var identifier = this.visitIdentifier(node.identifier); - this.movePast(node.colonToken); - var statement = node.statement.accept(this); - - var result = new TypeScript.LabeledStatement(identifier, statement); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDoStatement = function (node) { - var start = this.position; - - this.movePast(node.doKeyword); - var statement = node.statement.accept(this); - var whileKeyword = this.createTokenSpan(this.position, node.whileKeyword); - - this.movePast(node.whileKeyword); - this.movePast(node.openParenToken); - var condition = node.condition.accept(this); - this.movePast(node.closeParenToken); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DoStatement(statement, whileKeyword, condition); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitTypeOfExpression = function (node) { - var start = this.position; - - this.movePast(node.typeOfKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.TypeOfExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDeleteExpression = function (node) { - var start = this.position; - - this.movePast(node.deleteKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.DeleteExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitVoidExpression = function (node) { - var start = this.position; - - this.movePast(node.voidKeyword); - var expression = node.expression.accept(this); - - var result = new TypeScript.VoidExpression(expression); - this.setSpan(result, start, node); - - return result; - }; - - SyntaxTreeToAstVisitor.prototype.visitDebuggerStatement = function (node) { - var start = this.position; - - this.movePast(node.debuggerKeyword); - this.movePast(node.semicolonToken); - - var result = new TypeScript.DebuggerStatement(); - this.setSpan(result, start, node); - - return result; - }; - return SyntaxTreeToAstVisitor; - })(); - TypeScript.SyntaxTreeToAstVisitor = SyntaxTreeToAstVisitor; - - function applyDelta(ast, delta) { - if (ast) { - if (ast._start !== -1) { - ast._start += delta; - } - - if (ast._end !== -1) { - ast._end += delta; - } - } - } - - function applyDeltaToComments(comments, delta) { - if (comments && comments.length > 0) { - for (var i = 0; i < comments.length; i++) { - var comment = comments[i]; - applyDelta(comment, delta); - } - } - } - - var SyntaxTreeToIncrementalAstVisitor = (function (_super) { - __extends(SyntaxTreeToIncrementalAstVisitor, _super); - function SyntaxTreeToIncrementalAstVisitor() { - _super.apply(this, arguments); - } - SyntaxTreeToIncrementalAstVisitor.prototype.applyDelta = function (ast, delta) { - if (delta === 0) { - return; - } - - var pre = function (cur) { - applyDelta(cur, delta); - applyDeltaToComments(cur.preComments(), delta); - applyDeltaToComments(cur.postComments(), delta); - - switch (cur.kind()) { - case 146 /* Block */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 226 /* ArgumentList */: - applyDelta(cur.closeParenToken, delta); - break; - - case 130 /* ModuleDeclaration */: - applyDelta(cur.endingToken, delta); - break; - - case 131 /* ClassDeclaration */: - applyDelta(cur.closeBraceToken, delta); - break; - - case 161 /* DoStatement */: - applyDelta(cur.whileKeyword, delta); - break; - - case 151 /* SwitchStatement */: - applyDelta(cur.closeParenToken, delta); - break; - } - }; - - TypeScript.getAstWalkerFactory().simpleWalk(ast, pre); - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setSpanExplicit = function (span, start, end) { - if (span._start !== -1) { - var delta = start - span._start; - this.applyDelta(span, delta); - - span._end = end; - } else { - _super.prototype.setSpanExplicit.call(this, span, start, end); - } - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.getAndMovePastAST = function (element) { - if (this.previousTokenTrailingComments !== null) { - return null; - } - - var result = element._ast; - if (!result) { - return null; - } - - var start = this.position; - this.movePast(element); - this.setSpan(result, start, element); - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.setAST = function (element, ast) { - element._ast = ast; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSeparatedSyntaxList = function (list) { - var result = this.getAndMovePastAST(list); - if (!result) { - result = _super.prototype.visitSeparatedSyntaxList.call(this, list); - - if (list.childCount() > 0) { - this.setAST(list, result); - } - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitToken = function (token) { - var result = this.getAndMovePastAST(token); - - if (!result) { - result = _super.prototype.visitToken.call(this, token); - this.setAST(token, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitClassDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitClassDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInterfaceDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInterfaceDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitHeritageClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitHeritageClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitModuleDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitModuleDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitImportDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitImportDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExportAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExportAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPrefixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPrefixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitOmittedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitOmittedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimpleArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimpleArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParenthesizedArrowFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitQualifiedName = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - var result = _super.prototype.visitQualifiedName.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitArrayType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitArrayType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGenericType = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGenericType.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBlock = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBlock.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPostfixUnaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPostfixUnaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitElementAccessExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitElementAccessExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitInvocationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitInvocationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBinaryExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBinaryExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConditionalExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConditionalExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMethodSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMethodSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIndexSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIndexSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitPropertySignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitPropertySignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCallSignature = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCallSignature.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeParameter = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeParameter.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitIfStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitIfStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitExpressionStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitExpressionStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitConstructorDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitConstructorDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberFunctionDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberFunctionDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitGetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitGetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSetAccessor = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSetAccessor.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitMemberVariableDeclaration = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitMemberVariableDeclaration.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitThrowStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitThrowStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitReturnStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitReturnStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectCreationExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectCreationExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSwitchStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSwitchStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCaseSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCaseSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDefaultSwitchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDefaultSwitchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitBreakStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitBreakStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitContinueStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitContinueStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitForInStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitForInStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWhileStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWhileStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitWithStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitWithStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCastExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCastExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitObjectLiteralExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitObjectLiteralExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitSimplePropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitSimplePropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionPropertyAssignment = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionPropertyAssignment.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitFunctionExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitFunctionExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitEmptyStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitEmptyStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTryStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTryStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitCatchClause = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitCatchClause.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitLabeledStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitLabeledStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDoStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDoStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitTypeOfExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitTypeOfExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDeleteExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDeleteExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitVoidExpression = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitVoidExpression.call(this, node); - this.setAST(node, result); - } - - return result; - }; - - SyntaxTreeToIncrementalAstVisitor.prototype.visitDebuggerStatement = function (node) { - var result = this.getAndMovePastAST(node); - if (!result) { - result = _super.prototype.visitDebuggerStatement.call(this, node); - this.setAST(node, result); - } - - return result; - }; - return SyntaxTreeToIncrementalAstVisitor; - })(SyntaxTreeToAstVisitor); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTSpan = (function () { - function ASTSpan(_start, _end) { - this._start = _start; - this._end = _end; - } - ASTSpan.prototype.start = function () { - return this._start; - }; - - ASTSpan.prototype.end = function () { - return this._end; - }; - return ASTSpan; - })(); - TypeScript.ASTSpan = ASTSpan; - - var astID = 0; - - function structuralEqualsNotIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, false); - } - TypeScript.structuralEqualsNotIncludingPosition = structuralEqualsNotIncludingPosition; - - function structuralEqualsIncludingPosition(ast1, ast2) { - return structuralEquals(ast1, ast2, true); - } - TypeScript.structuralEqualsIncludingPosition = structuralEqualsIncludingPosition; - - function commentStructuralEqualsNotIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, false); - } - - function commentStructuralEqualsIncludingPosition(ast1, ast2) { - return commentStructuralEquals(ast1, ast2, true); - } - - function structuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.kind() === ast2.kind() && ast1.structuralEquals(ast2, includingPosition); - } - - function commentStructuralEquals(ast1, ast2, includingPosition) { - if (ast1 === ast2) { - return true; - } - - return ast1 !== null && ast2 !== null && ast1.structuralEquals(ast2, includingPosition); - } - - function astArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? structuralEqualsIncludingPosition : structuralEqualsNotIncludingPosition); - } - - function commentArrayStructuralEquals(array1, array2, includingPosition) { - return TypeScript.ArrayUtilities.sequenceEquals(array1, array2, includingPosition ? commentStructuralEqualsIncludingPosition : commentStructuralEqualsNotIncludingPosition); - } - - var AST = (function () { - function AST() { - this.parent = null; - this._start = -1; - this._end = -1; - this._trailingTriviaWidth = 0; - this._astID = astID++; - this._preComments = null; - this._postComments = null; - } - AST.prototype.syntaxID = function () { - return this._astID; - }; - - AST.prototype.start = function () { - return this._start; - }; - - AST.prototype.end = function () { - return this._end; - }; - - AST.prototype.trailingTriviaWidth = function () { - return this._trailingTriviaWidth; - }; - - AST.prototype.fileName = function () { - return this.parent.fileName(); - }; - - AST.prototype.kind = function () { - throw TypeScript.Errors.abstract(); - }; - - AST.prototype.preComments = function () { - return this._preComments; - }; - - AST.prototype.postComments = function () { - return this._postComments; - }; - - AST.prototype.setPreComments = function (comments) { - if (comments && comments.length) { - this._preComments = comments; - } else if (this._preComments) { - this._preComments = null; - } - }; - - AST.prototype.setPostComments = function (comments) { - if (comments && comments.length) { - this._postComments = comments; - } else if (this._postComments) { - this._postComments = null; - } - }; - - AST.prototype.width = function () { - return this.end() - this.start(); - }; - - AST.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return commentArrayStructuralEquals(this.preComments(), ast.preComments(), includingPosition) && commentArrayStructuralEquals(this.postComments(), ast.postComments(), includingPosition); - }; - - AST.prototype.isExpression = function () { - return false; - }; - return AST; - })(); - TypeScript.AST = AST; - - var ISyntaxList2 = (function (_super) { - __extends(ISyntaxList2, _super); - function ISyntaxList2(_fileName, members) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISyntaxList2.prototype.childCount = function () { - return this.members.length; - }; - - ISyntaxList2.prototype.childAt = function (index) { - return this.members[index]; - }; - - ISyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISyntaxList2.prototype.kind = function () { - return 1 /* List */; - }; - - ISyntaxList2.prototype.firstOrDefault = function (func) { - return TypeScript.ArrayUtilities.firstOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.lastOrDefault = function (func) { - return TypeScript.ArrayUtilities.lastOrDefault(this.members, func); - }; - - ISyntaxList2.prototype.any = function (func) { - return TypeScript.ArrayUtilities.any(this.members, func); - }; - - ISyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISyntaxList2; - })(AST); - TypeScript.ISyntaxList2 = ISyntaxList2; - - var ISeparatedSyntaxList2 = (function (_super) { - __extends(ISeparatedSyntaxList2, _super); - function ISeparatedSyntaxList2(_fileName, members, _separatorCount) { - _super.call(this); - this._fileName = _fileName; - this.members = members; - this._separatorCount = _separatorCount; - - for (var i = 0, n = members.length; i < n; i++) { - members[i].parent = this; - } - } - ISeparatedSyntaxList2.prototype.nonSeparatorCount = function () { - return this.members.length; - }; - - ISeparatedSyntaxList2.prototype.separatorCount = function () { - return this._separatorCount; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorAt = function (index) { - return this.members[index]; - }; - - ISeparatedSyntaxList2.prototype.nonSeparatorIndexOf = function (ast) { - for (var i = 0, n = this.nonSeparatorCount(); i < n; i++) { - if (this.nonSeparatorAt(i) === ast) { - return i; - } - } - - return -1; - }; - - ISeparatedSyntaxList2.prototype.fileName = function () { - return this._fileName; - }; - - ISeparatedSyntaxList2.prototype.kind = function () { - return 2 /* SeparatedList */; - }; - - ISeparatedSyntaxList2.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && astArrayStructuralEquals(this.members, ast.members, includingPosition); - }; - return ISeparatedSyntaxList2; - })(AST); - TypeScript.ISeparatedSyntaxList2 = ISeparatedSyntaxList2; - - var SourceUnit = (function (_super) { - __extends(SourceUnit, _super); - function SourceUnit(moduleElements, endOfFileTokenLeadingComments, _fileName) { - _super.call(this); - this.moduleElements = moduleElements; - this.endOfFileTokenLeadingComments = endOfFileTokenLeadingComments; - this._fileName = _fileName; - moduleElements && (moduleElements.parent = this); - } - SourceUnit.prototype.fileName = function () { - return this._fileName; - }; - - SourceUnit.prototype.kind = function () { - return 120 /* SourceUnit */; - }; - - SourceUnit.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return SourceUnit; - })(AST); - TypeScript.SourceUnit = SourceUnit; - - var Identifier = (function (_super) { - __extends(Identifier, _super); - function Identifier(_text) { - _super.call(this); - this._text = _text; - this._valueText = null; - } - Identifier.prototype.text = function () { - return this._text; - }; - Identifier.prototype.valueText = function () { - if (!this._valueText) { - var text = this._text; - if (text === "__proto__") { - this._valueText = "#__proto__"; - } else { - this._valueText = TypeScript.Syntax.massageEscapes(text); - } - } - - return this._valueText; - }; - - Identifier.prototype.kind = function () { - return 11 /* IdentifierName */; - }; - - 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; - - var LiteralExpression = (function (_super) { - __extends(LiteralExpression, _super); - function LiteralExpression(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - LiteralExpression.prototype.text = function () { - return this._text; - }; - - LiteralExpression.prototype.valueText = function () { - return this._valueText; - }; - - LiteralExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ThisExpression = (function (_super) { - __extends(ThisExpression, _super); - function ThisExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - ThisExpression.prototype.text = function () { - return this._text; - }; - - ThisExpression.prototype.valueText = function () { - return this._valueText; - }; - - ThisExpression.prototype.kind = function () { - return 35 /* ThisKeyword */; - }; - - 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; - - var SuperExpression = (function (_super) { - __extends(SuperExpression, _super); - function SuperExpression(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - SuperExpression.prototype.text = function () { - return this._text; - }; - - SuperExpression.prototype.valueText = function () { - return this._valueText; - }; - - SuperExpression.prototype.kind = function () { - return 50 /* SuperKeyword */; - }; - - 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; - - var NumericLiteral = (function (_super) { - __extends(NumericLiteral, _super); - function NumericLiteral(_value, _text, _valueText) { - _super.call(this); - this._value = _value; - this._text = _text; - this._valueText = _valueText; - } - NumericLiteral.prototype.text = function () { - return this._text; - }; - NumericLiteral.prototype.valueText = function () { - return this._valueText; - }; - NumericLiteral.prototype.value = function () { - return this._value; - }; - - NumericLiteral.prototype.kind = function () { - return 13 /* NumericLiteral */; - }; - - 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; - - var RegularExpressionLiteral = (function (_super) { - __extends(RegularExpressionLiteral, _super); - function RegularExpressionLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - } - RegularExpressionLiteral.prototype.text = function () { - return this._text; - }; - - RegularExpressionLiteral.prototype.valueText = function () { - return this._valueText; - }; - - RegularExpressionLiteral.prototype.kind = function () { - return 12 /* RegularExpressionLiteral */; - }; - - RegularExpressionLiteral.prototype.isExpression = function () { - return true; - }; - return RegularExpressionLiteral; - })(AST); - TypeScript.RegularExpressionLiteral = RegularExpressionLiteral; - - var StringLiteral = (function (_super) { - __extends(StringLiteral, _super); - function StringLiteral(_text, _valueText) { - _super.call(this); - this._text = _text; - this._valueText = _valueText; - this._valueText = _valueText === "__proto__" ? "#__proto__" : _valueText; - } - StringLiteral.prototype.text = function () { - return this._text; - }; - StringLiteral.prototype.valueText = function () { - return this._valueText; - }; - - StringLiteral.prototype.kind = function () { - return 14 /* StringLiteral */; - }; - - 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; - - var TypeAnnotation = (function (_super) { - __extends(TypeAnnotation, _super); - function TypeAnnotation(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - TypeAnnotation.prototype.kind = function () { - return 244 /* TypeAnnotation */; - }; - return TypeAnnotation; - })(AST); - TypeScript.TypeAnnotation = TypeAnnotation; - - var BuiltInType = (function (_super) { - __extends(BuiltInType, _super); - function BuiltInType(_nodeType, _text, _valueText) { - _super.call(this); - this._nodeType = _nodeType; - this._text = _text; - this._valueText = _valueText; - } - BuiltInType.prototype.text = function () { - return this._text; - }; - - BuiltInType.prototype.valueText = function () { - return this._valueText; - }; - - BuiltInType.prototype.kind = function () { - return this._nodeType; - }; - return BuiltInType; - })(AST); - TypeScript.BuiltInType = BuiltInType; - - var ExternalModuleReference = (function (_super) { - __extends(ExternalModuleReference, _super); - function ExternalModuleReference(stringLiteral) { - _super.call(this); - this.stringLiteral = stringLiteral; - stringLiteral && (stringLiteral.parent = this); - } - ExternalModuleReference.prototype.kind = function () { - return 245 /* ExternalModuleReference */; - }; - return ExternalModuleReference; - })(AST); - TypeScript.ExternalModuleReference = ExternalModuleReference; - - var ModuleNameModuleReference = (function (_super) { - __extends(ModuleNameModuleReference, _super); - function ModuleNameModuleReference(moduleName) { - _super.call(this); - this.moduleName = moduleName; - moduleName && (moduleName.parent = this); - } - ModuleNameModuleReference.prototype.kind = function () { - return 246 /* ModuleNameModuleReference */; - }; - return ModuleNameModuleReference; - })(AST); - TypeScript.ModuleNameModuleReference = ModuleNameModuleReference; - - var ImportDeclaration = (function (_super) { - __extends(ImportDeclaration, _super); - function ImportDeclaration(modifiers, identifier, moduleReference) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.moduleReference = moduleReference; - identifier && (identifier.parent = this); - moduleReference && (moduleReference.parent = this); - } - ImportDeclaration.prototype.kind = function () { - return 133 /* ImportDeclaration */; - }; - - ImportDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.moduleReference, ast.moduleReference, includingPosition); - }; - return ImportDeclaration; - })(AST); - TypeScript.ImportDeclaration = ImportDeclaration; - - var ExportAssignment = (function (_super) { - __extends(ExportAssignment, _super); - function ExportAssignment(identifier) { - _super.call(this); - this.identifier = identifier; - identifier && (identifier.parent = this); - } - ExportAssignment.prototype.kind = function () { - return 134 /* ExportAssignment */; - }; - - ExportAssignment.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition); - }; - return ExportAssignment; - })(AST); - TypeScript.ExportAssignment = ExportAssignment; - - var TypeParameterList = (function (_super) { - __extends(TypeParameterList, _super); - function TypeParameterList(typeParameters) { - _super.call(this); - this.typeParameters = typeParameters; - typeParameters && (typeParameters.parent = this); - } - TypeParameterList.prototype.kind = function () { - return 229 /* TypeParameterList */; - }; - return TypeParameterList; - })(AST); - TypeScript.TypeParameterList = TypeParameterList; - - var ClassDeclaration = (function (_super) { - __extends(ClassDeclaration, _super); - function ClassDeclaration(modifiers, identifier, typeParameterList, heritageClauses, classElements, closeBraceToken) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.classElements = classElements; - this.closeBraceToken = closeBraceToken; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - heritageClauses && (heritageClauses.parent = this); - classElements && (classElements.parent = this); - } - ClassDeclaration.prototype.kind = function () { - return 131 /* ClassDeclaration */; - }; - - ClassDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.classElements, ast.classElements, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return ClassDeclaration; - })(AST); - TypeScript.ClassDeclaration = ClassDeclaration; - - var InterfaceDeclaration = (function (_super) { - __extends(InterfaceDeclaration, _super); - function InterfaceDeclaration(modifiers, identifier, typeParameterList, heritageClauses, body) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.typeParameterList = typeParameterList; - this.heritageClauses = heritageClauses; - this.body = body; - identifier && (identifier.parent = this); - typeParameterList && (typeParameterList.parent = this); - body && (body.parent = this); - heritageClauses && (heritageClauses.parent = this); - } - InterfaceDeclaration.prototype.kind = function () { - return 128 /* InterfaceDeclaration */; - }; - - InterfaceDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.body, ast.body, includingPosition) && structuralEquals(this.typeParameterList, ast.typeParameterList, includingPosition) && structuralEquals(this.heritageClauses, ast.heritageClauses, includingPosition); - }; - return InterfaceDeclaration; - })(AST); - TypeScript.InterfaceDeclaration = InterfaceDeclaration; - - var HeritageClause = (function (_super) { - __extends(HeritageClause, _super); - function HeritageClause(_nodeType, typeNames) { - _super.call(this); - this._nodeType = _nodeType; - this.typeNames = typeNames; - typeNames && (typeNames.parent = this); - } - HeritageClause.prototype.kind = function () { - return this._nodeType; - }; - - HeritageClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeNames, ast.typeNames, includingPosition); - }; - return HeritageClause; - })(AST); - TypeScript.HeritageClause = HeritageClause; - - var ModuleDeclaration = (function (_super) { - __extends(ModuleDeclaration, _super); - function ModuleDeclaration(modifiers, name, stringLiteral, moduleElements, endingToken) { - _super.call(this); - this.modifiers = modifiers; - this.name = name; - this.stringLiteral = stringLiteral; - this.moduleElements = moduleElements; - this.endingToken = endingToken; - name && (name.parent = this); - stringLiteral && (stringLiteral.parent = this); - moduleElements && (moduleElements.parent = this); - } - ModuleDeclaration.prototype.kind = function () { - return 130 /* ModuleDeclaration */; - }; - - ModuleDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.moduleElements, ast.moduleElements, includingPosition); - }; - return ModuleDeclaration; - })(AST); - TypeScript.ModuleDeclaration = ModuleDeclaration; - - var FunctionDeclaration = (function (_super) { - __extends(FunctionDeclaration, _super); - function FunctionDeclaration(modifiers, identifier, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionDeclaration.prototype.kind = function () { - return 129 /* FunctionDeclaration */; - }; - - FunctionDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.callSignature, ast.callSignature, includingPosition); - }; - return FunctionDeclaration; - })(AST); - TypeScript.FunctionDeclaration = FunctionDeclaration; - - var VariableStatement = (function (_super) { - __extends(VariableStatement, _super); - function VariableStatement(modifiers, declaration) { - _super.call(this); - this.modifiers = modifiers; - this.declaration = declaration; - declaration && (declaration.parent = this); - } - VariableStatement.prototype.kind = function () { - return 148 /* VariableStatement */; - }; - - VariableStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declaration, ast.declaration, includingPosition); - }; - return VariableStatement; - })(AST); - TypeScript.VariableStatement = VariableStatement; - - var VariableDeclaration = (function (_super) { - __extends(VariableDeclaration, _super); - function VariableDeclaration(declarators) { - _super.call(this); - this.declarators = declarators; - declarators && (declarators.parent = this); - } - VariableDeclaration.prototype.kind = function () { - return 224 /* VariableDeclaration */; - }; - - VariableDeclaration.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.declarators, ast.declarators, includingPosition); - }; - return VariableDeclaration; - })(AST); - TypeScript.VariableDeclaration = VariableDeclaration; - - var VariableDeclarator = (function (_super) { - __extends(VariableDeclarator, _super); - function VariableDeclarator(propertyName, typeAnnotation, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - VariableDeclarator.prototype.kind = function () { - return 225 /* VariableDeclarator */; - }; - return VariableDeclarator; - })(AST); - TypeScript.VariableDeclarator = VariableDeclarator; - - var EqualsValueClause = (function (_super) { - __extends(EqualsValueClause, _super); - function EqualsValueClause(value) { - _super.call(this); - this.value = value; - value && (value.parent = this); - } - EqualsValueClause.prototype.kind = function () { - return 232 /* EqualsValueClause */; - }; - return EqualsValueClause; - })(AST); - TypeScript.EqualsValueClause = EqualsValueClause; - - var PrefixUnaryExpression = (function (_super) { - __extends(PrefixUnaryExpression, _super); - function PrefixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PrefixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ArrayLiteralExpression = (function (_super) { - __extends(ArrayLiteralExpression, _super); - function ArrayLiteralExpression(expressions) { - _super.call(this); - this.expressions = expressions; - expressions && (expressions.parent = this); - } - ArrayLiteralExpression.prototype.kind = function () { - return 214 /* ArrayLiteralExpression */; - }; - - 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; - - var OmittedExpression = (function (_super) { - __extends(OmittedExpression, _super); - function OmittedExpression() { - _super.apply(this, arguments); - } - OmittedExpression.prototype.kind = function () { - return 223 /* OmittedExpression */; - }; - - 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; - - var ParenthesizedExpression = (function (_super) { - __extends(ParenthesizedExpression, _super); - function ParenthesizedExpression(openParenTrailingComments, expression) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.expression = expression; - expression && (expression.parent = this); - } - ParenthesizedExpression.prototype.kind = function () { - return 217 /* ParenthesizedExpression */; - }; - - 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; - - var SimpleArrowFunctionExpression = (function (_super) { - __extends(SimpleArrowFunctionExpression, _super); - function SimpleArrowFunctionExpression(identifier, block, expression) { - _super.call(this); - this.identifier = identifier; - this.block = block; - this.expression = expression; - identifier && (identifier.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - SimpleArrowFunctionExpression.prototype.kind = function () { - return 219 /* SimpleArrowFunctionExpression */; - }; - - SimpleArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return SimpleArrowFunctionExpression; - })(AST); - TypeScript.SimpleArrowFunctionExpression = SimpleArrowFunctionExpression; - - var ParenthesizedArrowFunctionExpression = (function (_super) { - __extends(ParenthesizedArrowFunctionExpression, _super); - function ParenthesizedArrowFunctionExpression(callSignature, block, expression) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - this.expression = expression; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - expression && (expression.parent = this); - } - ParenthesizedArrowFunctionExpression.prototype.kind = function () { - return 218 /* ParenthesizedArrowFunctionExpression */; - }; - - ParenthesizedArrowFunctionExpression.prototype.isExpression = function () { - return true; - }; - return ParenthesizedArrowFunctionExpression; - })(AST); - TypeScript.ParenthesizedArrowFunctionExpression = ParenthesizedArrowFunctionExpression; - - var QualifiedName = (function (_super) { - __extends(QualifiedName, _super); - function QualifiedName(left, right) { - _super.call(this); - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - QualifiedName.prototype.kind = function () { - return 121 /* QualifiedName */; - }; - - QualifiedName.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); - }; - return QualifiedName; - })(AST); - TypeScript.QualifiedName = QualifiedName; - - var ParameterList = (function (_super) { - __extends(ParameterList, _super); - function ParameterList(openParenTrailingComments, parameters) { - _super.call(this); - this.openParenTrailingComments = openParenTrailingComments; - this.parameters = parameters; - parameters && (parameters.parent = this); - } - ParameterList.prototype.kind = function () { - return 227 /* ParameterList */; - }; - return ParameterList; - })(AST); - TypeScript.ParameterList = ParameterList; - - var ConstructorType = (function (_super) { - __extends(ConstructorType, _super); - function ConstructorType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - ConstructorType.prototype.kind = function () { - return 125 /* ConstructorType */; - }; - return ConstructorType; - })(AST); - TypeScript.ConstructorType = ConstructorType; - - var FunctionType = (function (_super) { - __extends(FunctionType, _super); - function FunctionType(typeParameterList, parameterList, type) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.type = type; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - type && (type.parent = this); - } - FunctionType.prototype.kind = function () { - return 123 /* FunctionType */; - }; - return FunctionType; - })(AST); - TypeScript.FunctionType = FunctionType; - - var ObjectType = (function (_super) { - __extends(ObjectType, _super); - function ObjectType(typeMembers) { - _super.call(this); - this.typeMembers = typeMembers; - typeMembers && (typeMembers.parent = this); - } - ObjectType.prototype.kind = function () { - return 122 /* ObjectType */; - }; - - ObjectType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.typeMembers, ast.typeMembers, includingPosition); - }; - return ObjectType; - })(AST); - TypeScript.ObjectType = ObjectType; - - var ArrayType = (function (_super) { - __extends(ArrayType, _super); - function ArrayType(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - ArrayType.prototype.kind = function () { - return 124 /* ArrayType */; - }; - - ArrayType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.type, ast.type, includingPosition); - }; - return ArrayType; - })(AST); - TypeScript.ArrayType = ArrayType; - - var TypeArgumentList = (function (_super) { - __extends(TypeArgumentList, _super); - function TypeArgumentList(typeArguments) { - _super.call(this); - this.typeArguments = typeArguments; - typeArguments && (typeArguments.parent = this); - } - TypeArgumentList.prototype.kind = function () { - return 228 /* TypeArgumentList */; - }; - return TypeArgumentList; - })(AST); - TypeScript.TypeArgumentList = TypeArgumentList; - - var GenericType = (function (_super) { - __extends(GenericType, _super); - function GenericType(name, typeArgumentList) { - _super.call(this); - this.name = name; - this.typeArgumentList = typeArgumentList; - name && (name.parent = this); - typeArgumentList && (typeArgumentList.parent = this); - } - GenericType.prototype.kind = function () { - return 126 /* GenericType */; - }; - - GenericType.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition) && structuralEquals(this.typeArgumentList, ast.typeArgumentList, includingPosition); - }; - return GenericType; - })(AST); - TypeScript.GenericType = GenericType; - - var TypeQuery = (function (_super) { - __extends(TypeQuery, _super); - function TypeQuery(name) { - _super.call(this); - this.name = name; - name && (name.parent = this); - } - TypeQuery.prototype.kind = function () { - return 127 /* TypeQuery */; - }; - - TypeQuery.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.name, ast.name, includingPosition); - }; - return TypeQuery; - })(AST); - TypeScript.TypeQuery = TypeQuery; - - var Block = (function (_super) { - __extends(Block, _super); - function Block(statements, closeBraceLeadingComments, closeBraceToken) { - _super.call(this); - this.statements = statements; - this.closeBraceLeadingComments = closeBraceLeadingComments; - this.closeBraceToken = closeBraceToken; - statements && (statements.parent = this); - } - Block.prototype.kind = function () { - return 146 /* Block */; - }; - - Block.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return Block; - })(AST); - TypeScript.Block = Block; - - var Parameter = (function (_super) { - __extends(Parameter, _super); - function Parameter(dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - _super.call(this); - this.dotDotDotToken = dotDotDotToken; - this.modifiers = modifiers; - this.identifier = identifier; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - this.equalsValueClause = equalsValueClause; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - Parameter.prototype.kind = function () { - return 242 /* Parameter */; - }; - return Parameter; - })(AST); - TypeScript.Parameter = Parameter; - - var MemberAccessExpression = (function (_super) { - __extends(MemberAccessExpression, _super); - function MemberAccessExpression(expression, name) { - _super.call(this); - this.expression = expression; - this.name = name; - expression && (expression.parent = this); - name && (name.parent = this); - } - MemberAccessExpression.prototype.kind = function () { - return 212 /* MemberAccessExpression */; - }; - - 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; - - var PostfixUnaryExpression = (function (_super) { - __extends(PostfixUnaryExpression, _super); - function PostfixUnaryExpression(_nodeType, operand) { - _super.call(this); - this._nodeType = _nodeType; - this.operand = operand; - operand && (operand.parent = this); - } - PostfixUnaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ElementAccessExpression = (function (_super) { - __extends(ElementAccessExpression, _super); - function ElementAccessExpression(expression, argumentExpression) { - _super.call(this); - this.expression = expression; - this.argumentExpression = argumentExpression; - expression && (expression.parent = this); - argumentExpression && (argumentExpression.parent = this); - } - ElementAccessExpression.prototype.kind = function () { - return 221 /* ElementAccessExpression */; - }; - - 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; - - var InvocationExpression = (function (_super) { - __extends(InvocationExpression, _super); - function InvocationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - InvocationExpression.prototype.kind = function () { - return 213 /* InvocationExpression */; - }; - - 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) { - _super.call(this); - this.typeArgumentList = typeArgumentList; - this.closeParenToken = closeParenToken; - this.arguments = _arguments; - - typeArgumentList && (typeArgumentList.parent = this); - _arguments && (_arguments.parent = this); - } - ArgumentList.prototype.kind = function () { - return 226 /* ArgumentList */; - }; - return ArgumentList; - })(AST); - TypeScript.ArgumentList = ArgumentList; - - var BinaryExpression = (function (_super) { - __extends(BinaryExpression, _super); - function BinaryExpression(_nodeType, left, right) { - _super.call(this); - this._nodeType = _nodeType; - this.left = left; - this.right = right; - left && (left.parent = this); - right && (right.parent = this); - } - BinaryExpression.prototype.kind = function () { - return this._nodeType; - }; - - 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; - - var ConditionalExpression = (function (_super) { - __extends(ConditionalExpression, _super); - function ConditionalExpression(condition, whenTrue, whenFalse) { - _super.call(this); - this.condition = condition; - this.whenTrue = whenTrue; - this.whenFalse = whenFalse; - condition && (condition.parent = this); - whenTrue && (whenTrue.parent = this); - whenFalse && (whenFalse.parent = this); - } - ConditionalExpression.prototype.kind = function () { - return 186 /* ConditionalExpression */; - }; - - 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; - - var ConstructSignature = (function (_super) { - __extends(ConstructSignature, _super); - function ConstructSignature(callSignature) { - _super.call(this); - this.callSignature = callSignature; - callSignature && (callSignature.parent = this); - } - ConstructSignature.prototype.kind = function () { - return 143 /* ConstructSignature */; - }; - return ConstructSignature; - })(AST); - TypeScript.ConstructSignature = ConstructSignature; - - var MethodSignature = (function (_super) { - __extends(MethodSignature, _super); - function MethodSignature(propertyName, questionToken, callSignature) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.callSignature = callSignature; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - } - MethodSignature.prototype.kind = function () { - return 145 /* MethodSignature */; - }; - return MethodSignature; - })(AST); - TypeScript.MethodSignature = MethodSignature; - - var IndexSignature = (function (_super) { - __extends(IndexSignature, _super); - function IndexSignature(parameter, typeAnnotation) { - _super.call(this); - this.parameter = parameter; - this.typeAnnotation = typeAnnotation; - parameter && (parameter.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - IndexSignature.prototype.kind = function () { - return 144 /* IndexSignature */; - }; - return IndexSignature; - })(AST); - TypeScript.IndexSignature = IndexSignature; - - var PropertySignature = (function (_super) { - __extends(PropertySignature, _super); - function PropertySignature(propertyName, questionToken, typeAnnotation) { - _super.call(this); - this.propertyName = propertyName; - this.questionToken = questionToken; - this.typeAnnotation = typeAnnotation; - propertyName && (propertyName.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - PropertySignature.prototype.kind = function () { - return 141 /* PropertySignature */; - }; - return PropertySignature; - })(AST); - TypeScript.PropertySignature = PropertySignature; - - var CallSignature = (function (_super) { - __extends(CallSignature, _super); - function CallSignature(typeParameterList, parameterList, typeAnnotation) { - _super.call(this); - this.typeParameterList = typeParameterList; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - typeParameterList && (typeParameterList.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - } - CallSignature.prototype.kind = function () { - return 142 /* CallSignature */; - }; - return CallSignature; - })(AST); - TypeScript.CallSignature = CallSignature; - - var TypeParameter = (function (_super) { - __extends(TypeParameter, _super); - function TypeParameter(identifier, constraint) { - _super.call(this); - this.identifier = identifier; - this.constraint = constraint; - identifier && (identifier.parent = this); - constraint && (constraint.parent = this); - } - TypeParameter.prototype.kind = function () { - return 238 /* TypeParameter */; - }; - - TypeParameter.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.constraint, ast.constraint, includingPosition); - }; - return TypeParameter; - })(AST); - TypeScript.TypeParameter = TypeParameter; - - var Constraint = (function (_super) { - __extends(Constraint, _super); - function Constraint(type) { - _super.call(this); - this.type = type; - type && (type.parent = this); - } - Constraint.prototype.kind = function () { - return 239 /* Constraint */; - }; - return Constraint; - })(AST); - TypeScript.Constraint = Constraint; - - var ElseClause = (function (_super) { - __extends(ElseClause, _super); - function ElseClause(statement) { - _super.call(this); - this.statement = statement; - statement && (statement.parent = this); - } - ElseClause.prototype.kind = function () { - return 235 /* ElseClause */; - }; - - ElseClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ElseClause; - })(AST); - TypeScript.ElseClause = ElseClause; - - var IfStatement = (function (_super) { - __extends(IfStatement, _super); - function IfStatement(condition, statement, elseClause) { - _super.call(this); - this.condition = condition; - this.statement = statement; - this.elseClause = elseClause; - condition && (condition.parent = this); - statement && (statement.parent = this); - elseClause && (elseClause.parent = this); - } - IfStatement.prototype.kind = function () { - return 147 /* IfStatement */; - }; - - IfStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.elseClause, ast.elseClause, includingPosition); - }; - return IfStatement; - })(AST); - TypeScript.IfStatement = IfStatement; - - var ExpressionStatement = (function (_super) { - __extends(ExpressionStatement, _super); - function ExpressionStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ExpressionStatement.prototype.kind = function () { - return 149 /* ExpressionStatement */; - }; - - ExpressionStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ExpressionStatement; - })(AST); - TypeScript.ExpressionStatement = ExpressionStatement; - - var ConstructorDeclaration = (function (_super) { - __extends(ConstructorDeclaration, _super); - function ConstructorDeclaration(callSignature, block) { - _super.call(this); - this.callSignature = callSignature; - this.block = block; - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - ConstructorDeclaration.prototype.kind = function () { - return 137 /* ConstructorDeclaration */; - }; - return ConstructorDeclaration; - })(AST); - TypeScript.ConstructorDeclaration = ConstructorDeclaration; - - var MemberFunctionDeclaration = (function (_super) { - __extends(MemberFunctionDeclaration, _super); - function MemberFunctionDeclaration(modifiers, propertyName, callSignature, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - MemberFunctionDeclaration.prototype.kind = function () { - return 135 /* MemberFunctionDeclaration */; - }; - return MemberFunctionDeclaration; - })(AST); - TypeScript.MemberFunctionDeclaration = MemberFunctionDeclaration; - - var GetAccessor = (function (_super) { - __extends(GetAccessor, _super); - function GetAccessor(modifiers, propertyName, parameterList, typeAnnotation, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.typeAnnotation = typeAnnotation; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - GetAccessor.prototype.kind = function () { - return 139 /* GetAccessor */; - }; - return GetAccessor; - })(AST); - TypeScript.GetAccessor = GetAccessor; - - var SetAccessor = (function (_super) { - __extends(SetAccessor, _super); - function SetAccessor(modifiers, propertyName, parameterList, block) { - _super.call(this); - this.modifiers = modifiers; - this.propertyName = propertyName; - this.parameterList = parameterList; - this.block = block; - propertyName && (propertyName.parent = this); - parameterList && (parameterList.parent = this); - block && (block.parent = this); - } - SetAccessor.prototype.kind = function () { - return 140 /* SetAccessor */; - }; - return SetAccessor; - })(AST); - TypeScript.SetAccessor = SetAccessor; - - var MemberVariableDeclaration = (function (_super) { - __extends(MemberVariableDeclaration, _super); - function MemberVariableDeclaration(modifiers, variableDeclarator) { - _super.call(this); - this.modifiers = modifiers; - this.variableDeclarator = variableDeclarator; - variableDeclarator && (variableDeclarator.parent = this); - } - MemberVariableDeclaration.prototype.kind = function () { - return 136 /* MemberVariableDeclaration */; - }; - return MemberVariableDeclaration; - })(AST); - TypeScript.MemberVariableDeclaration = MemberVariableDeclaration; - - var IndexMemberDeclaration = (function (_super) { - __extends(IndexMemberDeclaration, _super); - function IndexMemberDeclaration(indexSignature) { - _super.call(this); - this.indexSignature = indexSignature; - indexSignature && (indexSignature.parent = this); - } - IndexMemberDeclaration.prototype.kind = function () { - return 138 /* IndexMemberDeclaration */; - }; - return IndexMemberDeclaration; - })(AST); - TypeScript.IndexMemberDeclaration = IndexMemberDeclaration; - - var ThrowStatement = (function (_super) { - __extends(ThrowStatement, _super); - function ThrowStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ThrowStatement.prototype.kind = function () { - return 157 /* ThrowStatement */; - }; - - ThrowStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ThrowStatement; - })(AST); - TypeScript.ThrowStatement = ThrowStatement; - - var ReturnStatement = (function (_super) { - __extends(ReturnStatement, _super); - function ReturnStatement(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - ReturnStatement.prototype.kind = function () { - return 150 /* ReturnStatement */; - }; - - ReturnStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return ReturnStatement; - })(AST); - TypeScript.ReturnStatement = ReturnStatement; - - var ObjectCreationExpression = (function (_super) { - __extends(ObjectCreationExpression, _super); - function ObjectCreationExpression(expression, argumentList) { - _super.call(this); - this.expression = expression; - this.argumentList = argumentList; - expression && (expression.parent = this); - argumentList && (argumentList.parent = this); - } - ObjectCreationExpression.prototype.kind = function () { - return 216 /* ObjectCreationExpression */; - }; - - 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; - - var SwitchStatement = (function (_super) { - __extends(SwitchStatement, _super); - function SwitchStatement(expression, closeParenToken, switchClauses) { - _super.call(this); - this.expression = expression; - this.closeParenToken = closeParenToken; - this.switchClauses = switchClauses; - expression && (expression.parent = this); - switchClauses && (switchClauses.parent = this); - } - SwitchStatement.prototype.kind = function () { - return 151 /* SwitchStatement */; - }; - - SwitchStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.switchClauses, ast.switchClauses, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition); - }; - return SwitchStatement; - })(AST); - TypeScript.SwitchStatement = SwitchStatement; - - var CaseSwitchClause = (function (_super) { - __extends(CaseSwitchClause, _super); - function CaseSwitchClause(expression, statements) { - _super.call(this); - this.expression = expression; - this.statements = statements; - expression && (expression.parent = this); - statements && (statements.parent = this); - } - CaseSwitchClause.prototype.kind = function () { - return 233 /* CaseSwitchClause */; - }; - - CaseSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return CaseSwitchClause; - })(AST); - TypeScript.CaseSwitchClause = CaseSwitchClause; - - var DefaultSwitchClause = (function (_super) { - __extends(DefaultSwitchClause, _super); - function DefaultSwitchClause(statements) { - _super.call(this); - this.statements = statements; - statements && (statements.parent = this); - } - DefaultSwitchClause.prototype.kind = function () { - return 234 /* DefaultSwitchClause */; - }; - - DefaultSwitchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statements, ast.statements, includingPosition); - }; - return DefaultSwitchClause; - })(AST); - TypeScript.DefaultSwitchClause = DefaultSwitchClause; - - var BreakStatement = (function (_super) { - __extends(BreakStatement, _super); - function BreakStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - BreakStatement.prototype.kind = function () { - return 152 /* BreakStatement */; - }; - - BreakStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return BreakStatement; - })(AST); - TypeScript.BreakStatement = BreakStatement; - - var ContinueStatement = (function (_super) { - __extends(ContinueStatement, _super); - function ContinueStatement(identifier) { - _super.call(this); - this.identifier = identifier; - } - ContinueStatement.prototype.kind = function () { - return 153 /* ContinueStatement */; - }; - - ContinueStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return ContinueStatement; - })(AST); - TypeScript.ContinueStatement = ContinueStatement; - - var ForStatement = (function (_super) { - __extends(ForStatement, _super); - function ForStatement(variableDeclaration, initializer, condition, incrementor, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.initializer = initializer; - this.condition = condition; - this.incrementor = incrementor; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - initializer && (initializer.parent = this); - condition && (condition.parent = this); - incrementor && (incrementor.parent = this); - statement && (statement.parent = this); - } - ForStatement.prototype.kind = function () { - return 154 /* ForStatement */; - }; - - ForStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.initializer, ast.initializer, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.incrementor, ast.incrementor, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForStatement; - })(AST); - TypeScript.ForStatement = ForStatement; - - var ForInStatement = (function (_super) { - __extends(ForInStatement, _super); - function ForInStatement(variableDeclaration, left, expression, statement) { - _super.call(this); - this.variableDeclaration = variableDeclaration; - this.left = left; - this.expression = expression; - this.statement = statement; - variableDeclaration && (variableDeclaration.parent = this); - left && (left.parent = this); - expression && (expression.parent = this); - statement && (statement.parent = this); - } - ForInStatement.prototype.kind = function () { - return 155 /* ForInStatement */; - }; - - ForInStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.variableDeclaration, ast.variableDeclaration, includingPosition) && structuralEquals(this.expression, ast.expression, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return ForInStatement; - })(AST); - TypeScript.ForInStatement = ForInStatement; - - var WhileStatement = (function (_super) { - __extends(WhileStatement, _super); - function WhileStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WhileStatement.prototype.kind = function () { - return 158 /* WhileStatement */; - }; - - WhileStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WhileStatement; - })(AST); - TypeScript.WhileStatement = WhileStatement; - - var WithStatement = (function (_super) { - __extends(WithStatement, _super); - function WithStatement(condition, statement) { - _super.call(this); - this.condition = condition; - this.statement = statement; - condition && (condition.parent = this); - statement && (statement.parent = this); - } - WithStatement.prototype.kind = function () { - return 163 /* WithStatement */; - }; - - WithStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return WithStatement; - })(AST); - TypeScript.WithStatement = WithStatement; - - var EnumDeclaration = (function (_super) { - __extends(EnumDeclaration, _super); - function EnumDeclaration(modifiers, identifier, enumElements) { - _super.call(this); - this.modifiers = modifiers; - this.identifier = identifier; - this.enumElements = enumElements; - identifier && (identifier.parent = this); - enumElements && (enumElements.parent = this); - } - EnumDeclaration.prototype.kind = function () { - return 132 /* EnumDeclaration */; - }; - return EnumDeclaration; - })(AST); - TypeScript.EnumDeclaration = EnumDeclaration; - - var EnumElement = (function (_super) { - __extends(EnumElement, _super); - function EnumElement(propertyName, equalsValueClause) { - _super.call(this); - this.propertyName = propertyName; - this.equalsValueClause = equalsValueClause; - propertyName && (propertyName.parent = this); - equalsValueClause && (equalsValueClause.parent = this); - } - EnumElement.prototype.kind = function () { - return 243 /* EnumElement */; - }; - return EnumElement; - })(AST); - TypeScript.EnumElement = EnumElement; - - var CastExpression = (function (_super) { - __extends(CastExpression, _super); - function CastExpression(type, expression) { - _super.call(this); - this.type = type; - this.expression = expression; - type && (type.parent = this); - expression && (expression.parent = this); - } - CastExpression.prototype.kind = function () { - return 220 /* CastExpression */; - }; - - 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; - - var ObjectLiteralExpression = (function (_super) { - __extends(ObjectLiteralExpression, _super); - function ObjectLiteralExpression(propertyAssignments) { - _super.call(this); - this.propertyAssignments = propertyAssignments; - propertyAssignments && (propertyAssignments.parent = this); - } - ObjectLiteralExpression.prototype.kind = function () { - return 215 /* ObjectLiteralExpression */; - }; - - 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; - - var SimplePropertyAssignment = (function (_super) { - __extends(SimplePropertyAssignment, _super); - function SimplePropertyAssignment(propertyName, expression) { - _super.call(this); - this.propertyName = propertyName; - this.expression = expression; - propertyName && (propertyName.parent = this); - expression && (expression.parent = this); - } - SimplePropertyAssignment.prototype.kind = function () { - return 240 /* SimplePropertyAssignment */; - }; - return SimplePropertyAssignment; - })(AST); - TypeScript.SimplePropertyAssignment = SimplePropertyAssignment; - - var FunctionPropertyAssignment = (function (_super) { - __extends(FunctionPropertyAssignment, _super); - function FunctionPropertyAssignment(propertyName, callSignature, block) { - _super.call(this); - this.propertyName = propertyName; - this.callSignature = callSignature; - this.block = block; - propertyName && (propertyName.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionPropertyAssignment.prototype.kind = function () { - return 241 /* FunctionPropertyAssignment */; - }; - return FunctionPropertyAssignment; - })(AST); - TypeScript.FunctionPropertyAssignment = FunctionPropertyAssignment; - - var FunctionExpression = (function (_super) { - __extends(FunctionExpression, _super); - function FunctionExpression(identifier, callSignature, block) { - _super.call(this); - this.identifier = identifier; - this.callSignature = callSignature; - this.block = block; - identifier && (identifier.parent = this); - callSignature && (callSignature.parent = this); - block && (block.parent = this); - } - FunctionExpression.prototype.kind = function () { - return 222 /* FunctionExpression */; - }; - - FunctionExpression.prototype.isExpression = function () { - return true; - }; - return FunctionExpression; - })(AST); - TypeScript.FunctionExpression = FunctionExpression; - - var EmptyStatement = (function (_super) { - __extends(EmptyStatement, _super); - function EmptyStatement() { - _super.apply(this, arguments); - } - EmptyStatement.prototype.kind = function () { - return 156 /* EmptyStatement */; - }; - - EmptyStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition); - }; - return EmptyStatement; - })(AST); - TypeScript.EmptyStatement = EmptyStatement; - - var TryStatement = (function (_super) { - __extends(TryStatement, _super); - function TryStatement(block, catchClause, finallyClause) { - _super.call(this); - this.block = block; - this.catchClause = catchClause; - this.finallyClause = finallyClause; - block && (block.parent = this); - catchClause && (catchClause.parent = this); - finallyClause && (finallyClause.parent = this); - } - TryStatement.prototype.kind = function () { - return 159 /* TryStatement */; - }; - - TryStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition) && structuralEquals(this.catchClause, ast.catchClause, includingPosition) && structuralEquals(this.finallyClause, ast.finallyClause, includingPosition); - }; - return TryStatement; - })(AST); - TypeScript.TryStatement = TryStatement; - - var CatchClause = (function (_super) { - __extends(CatchClause, _super); - function CatchClause(identifier, typeAnnotation, block) { - _super.call(this); - this.identifier = identifier; - this.typeAnnotation = typeAnnotation; - this.block = block; - identifier && (identifier.parent = this); - typeAnnotation && (typeAnnotation.parent = this); - block && (block.parent = this); - } - CatchClause.prototype.kind = function () { - return 236 /* CatchClause */; - }; - - CatchClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.typeAnnotation, ast.typeAnnotation, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return CatchClause; - })(AST); - TypeScript.CatchClause = CatchClause; - - var FinallyClause = (function (_super) { - __extends(FinallyClause, _super); - function FinallyClause(block) { - _super.call(this); - this.block = block; - block && (block.parent = this); - } - FinallyClause.prototype.kind = function () { - return 237 /* FinallyClause */; - }; - - FinallyClause.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.block, ast.block, includingPosition); - }; - return FinallyClause; - })(AST); - TypeScript.FinallyClause = FinallyClause; - - var LabeledStatement = (function (_super) { - __extends(LabeledStatement, _super); - function LabeledStatement(identifier, statement) { - _super.call(this); - this.identifier = identifier; - this.statement = statement; - identifier && (identifier.parent = this); - statement && (statement.parent = this); - } - LabeledStatement.prototype.kind = function () { - return 160 /* LabeledStatement */; - }; - - LabeledStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.identifier, ast.identifier, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition); - }; - return LabeledStatement; - })(AST); - TypeScript.LabeledStatement = LabeledStatement; - - var DoStatement = (function (_super) { - __extends(DoStatement, _super); - function DoStatement(statement, whileKeyword, condition) { - _super.call(this); - this.statement = statement; - this.whileKeyword = whileKeyword; - this.condition = condition; - statement && (statement.parent = this); - condition && (condition.parent = this); - } - DoStatement.prototype.kind = function () { - return 161 /* DoStatement */; - }; - - DoStatement.prototype.structuralEquals = function (ast, includingPosition) { - return _super.prototype.structuralEquals.call(this, ast, includingPosition) && structuralEquals(this.statement, ast.statement, includingPosition) && structuralEquals(this.condition, ast.condition, includingPosition); - }; - return DoStatement; - })(AST); - TypeScript.DoStatement = DoStatement; - - var TypeOfExpression = (function (_super) { - __extends(TypeOfExpression, _super); - function TypeOfExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - TypeOfExpression.prototype.kind = function () { - return 171 /* TypeOfExpression */; - }; - - 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; - - var DeleteExpression = (function (_super) { - __extends(DeleteExpression, _super); - function DeleteExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - DeleteExpression.prototype.kind = function () { - return 170 /* DeleteExpression */; - }; - - 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; - - var VoidExpression = (function (_super) { - __extends(VoidExpression, _super); - function VoidExpression(expression) { - _super.call(this); - this.expression = expression; - expression && (expression.parent = this); - } - VoidExpression.prototype.kind = function () { - return 172 /* VoidExpression */; - }; - - 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; - - var DebuggerStatement = (function (_super) { - __extends(DebuggerStatement, _super); - function DebuggerStatement() { - _super.apply(this, arguments); - } - DebuggerStatement.prototype.kind = function () { - return 162 /* DebuggerStatement */; - }; - return DebuggerStatement; - })(AST); - TypeScript.DebuggerStatement = DebuggerStatement; - - var Comment = (function () { - function Comment(_trivia, endsLine, _start, _end) { - this._trivia = _trivia; - this.endsLine = endsLine; - this._start = _start; - this._end = _end; - } - Comment.prototype.start = function () { - return this._start; - }; - - Comment.prototype.end = function () { - return this._end; - }; - - Comment.prototype.fullText = function () { - return this._trivia.fullText(); - }; - - Comment.prototype.kind = function () { - return this._trivia.kind(); - }; - - Comment.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - - return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; - }; - return Comment; - })(); - TypeScript.Comment = Comment; -})(TypeScript || (TypeScript = {})); From adb74d94ceaecddb0650be9f85b93b7ad60a422c Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 09:54:15 +0900 Subject: [PATCH 206/240] Suppress warnings aboud node.d.ts --- node/node.d.ts | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index 8801de5b2c..fe7fbd324d 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: { From 1021dcfdf3095a68e279269f0e4c3bf88f39fcdb Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 10:01:00 +0900 Subject: [PATCH 207/240] Suppress warning about ember.d.ts --- ember/ember.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 9bde2eca6c..80be5d04d9 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[]; From 19a7badf021c9e296d8b12d63d3d80a35fe93735 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 10:03:20 +0900 Subject: [PATCH 208/240] Suppress warning about knockout.deferred.updates.d.ts --- knockout.deferred.updates/knockout.deferred.updates.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout.deferred.updates/knockout.deferred.updates.d.ts b/knockout.deferred.updates/knockout.deferred.updates.d.ts index 1d9313dcee..e3423f5e90 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; } From 386a2567a2dec63b7a6fdd1b13728d9ee9a0e321 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 10:10:33 +0900 Subject: [PATCH 209/240] Suppress warning about knockout.validation.d.ts --- knockout.validation/knockout.validation.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout.validation/knockout.validation.d.ts b/knockout.validation/knockout.validation.d.ts index 2e00c5223d..e65ec67439 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; From 0dfe4571546373bb3aad0841354fa9b1cf2aca19 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 10:24:13 +0900 Subject: [PATCH 210/240] Suppress warning about pixi/webgl.d.ts --- pixi/webgl.d.ts | 312 ------------------------------------------------ 1 file changed, 312 deletions(-) diff --git a/pixi/webgl.d.ts b/pixi/webgl.d.ts index 71538bbf8a..ebf1204dce 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; } From 13f169d1f9ff9e3f0aefa7c26d601f0c6605ae72 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 10:26:48 +0900 Subject: [PATCH 211/240] Suppress warning about Q-io.d.ts --- q-io/Q-io.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index 9f81500461..cbe37214e7 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 { From 2f2d5bdcacf203cdf4655a6c5966771b1d85bd1d Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 10:38:37 +0900 Subject: [PATCH 212/240] Suppress warning about angular-translate/angular-translate-tests.ts --- angular-translate/angular-translate-tests.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/angular-translate/angular-translate-tests.ts b/angular-translate/angular-translate-tests.ts index 7cb6c89c38..bea7faa09d 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); }; From e4206fbea20affb8ccbbd68a424c9f4a606d0fb9 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Wed, 26 Feb 2014 01:56:21 -0300 Subject: [PATCH 213/240] fix underscore tests --- underscore/underscore-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 7b5ee0504e..d3eb87f6aa 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]); From 16c9279a70073caca00e5ab5a0341ace49993640 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Wed, 26 Feb 2014 02:05:28 -0300 Subject: [PATCH 214/240] fix rx.async-tests.ts --- rx.js/rx.async-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rx.js/rx.async-tests.ts b/rx.js/rx.async-tests.ts index 636aa30de9..b71f8bd775 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() { From bb9cf5d3c326267c01c1c83dc14dd9d8b35e9ee7 Mon Sep 17 00:00:00 2001 From: satoru kimura Date: Wed, 26 Feb 2014 14:13:17 +0900 Subject: [PATCH 215/240] Fix for typescript 0.9.7. --- cryptojs/cryptojs.d.ts | 9 ++- lodash/lodash.d.ts | 126 ++++++++++++++++++++--------------------- 2 files changed, 67 insertions(+), 68 deletions(-) diff --git a/cryptojs/cryptojs.d.ts b/cryptojs/cryptojs.d.ts index a12ef69e75..d9c77dbe97 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/lodash/lodash.d.ts b/lodash/lodash.d.ts index 0afd193702..b48f7e6034 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; From 89388cefaa8a8e0cd21087338de6d14258637763 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Wed, 26 Feb 2014 02:14:02 -0300 Subject: [PATCH 216/240] fix knockout-tests.ts --- knockout/tests/knockout-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index e74012548c..1ebef13ef5 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; } From e2fd29975e646b85f8209e34bf231758415ea30a Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 17:24:12 +0900 Subject: [PATCH 217/240] fix angularfire/angularfire-tests.ts --- angularfire/angularfire-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularfire/angularfire-tests.ts b/angularfire/angularfire-tests.ts index e3a04712c3..eced9d7fe7 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!"); From 38f4ac30120f526dfaac030f6f9384eefc78c13c Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 17:25:44 +0900 Subject: [PATCH 218/240] fix gamepad/gamepad-tests.ts --- gamepad/gamepad-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamepad/gamepad-tests.ts b/gamepad/gamepad-tests.ts index e6ca9d272a..5d82c33ecd 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() From 6f35fbabcd936a164ae3daa5c1ed85c31ed2776f Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 17:28:02 +0900 Subject: [PATCH 219/240] fix knockout.kogrid/knockout.kogrid-tests.ts --- knockout.kogrid/knockout.kogrid-tests.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/knockout.kogrid/knockout.kogrid-tests.ts b/knockout.kogrid/knockout.kogrid-tests.ts index 94c061156d..54dde59e1d 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 From a0c732672986027a66c380472f466e5d187c738f Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 17:29:44 +0900 Subject: [PATCH 220/240] fix selenium-webdriver/selenium-webdriver-tests.ts --- selenium-webdriver/selenium-webdriver-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selenium-webdriver/selenium-webdriver-tests.ts b/selenium-webdriver/selenium-webdriver-tests.ts index 26913f0dbd..52b317d961 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; From 2df6fc70780c26bdba8d82dde645e46859134db7 Mon Sep 17 00:00:00 2001 From: vvakame Date: Wed, 26 Feb 2014 17:45:18 +0900 Subject: [PATCH 221/240] fix sugar/sugar.d.ts --- sugar/sugar.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index e5f9c97d7b..de418b65e5 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. From 177897f1c50ae1c66c3a3edaa0aa69ea4d50fc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Rudge?= Date: Wed, 26 Feb 2014 10:41:42 -0300 Subject: [PATCH 222/240] added missing object to sinon requests: SinonFakeXMLHttpRequest[]; --- sinon/sinon.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/sinon/sinon.d.ts b/sinon/sinon.d.ts index f9b33c082c..eb62a286e3 100644 --- a/sinon/sinon.d.ts +++ b/sinon/sinon.d.ts @@ -245,6 +245,7 @@ interface SinonFakeServer { autoRespondAfter: number; fakeHTTPMethods: boolean; getHTTPMethod: (request: SinonFakeXMLHttpRequest) => string; + requests: SinonFakeXMLHttpRequest[]; // Methods respondWith(body: string): void; From 193e8e6249acfd8430c1fb22b4ec0a2681c4db8e Mon Sep 17 00:00:00 2001 From: Johan Nilsson Date: Tue, 25 Feb 2014 21:28:07 -0400 Subject: [PATCH 223/240] add typescript file for googlemaps.infobubble --- README.md | 1 + .../google.maps.infobubble-tests.ts | 30 +++++ .../google.maps.infobubble.d.ts | 103 ++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 googlemaps.infobubble/google.maps.infobubble-tests.ts create mode 100644 googlemaps.infobubble/google.maps.infobubble.d.ts diff --git a/README.md b/README.md index 0d10e551b8..29c94b8042 100755 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ List of Definitions * [Google API Client](https://code.google.com/p/google-api-javascript-client/) (by [Frank M](https://github.com/sgtfrankieboy)) * [Google App Engine Channel API](https://developers.google.com/appengine/docs/java/channel/javascript) (by [vvakame](https://github.com/vvakame)) * [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper)) +* [GoogleMaps InfoBubble](http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/) (by [Johan Nilsson](https://github.com/dashue)) * [Google Geolocation](https://code.google.com/p/geo-location-javascript/) (by [Vincent Bortone](https://github.com/vbortone)) * [Google Page Speed Online API](https://developers.google.com/speed/pagespeed/) (by [Frank M](https://github.com/sgtfrankieboy)) * [Google Translate API](https://developers.google.com/translate/) (by [Frank M](https://github.com/sgtfrankieboy)) diff --git a/googlemaps.infobubble/google.maps.infobubble-tests.ts b/googlemaps.infobubble/google.maps.infobubble-tests.ts new file mode 100644 index 0000000000..e555625d8f --- /dev/null +++ b/googlemaps.infobubble/google.maps.infobubble-tests.ts @@ -0,0 +1,30 @@ +function test_options() { + var options: google.maps.infobubble.InfoBubbleOptions; + options = {}; + + options.arrowPosition = 50; + options.arrowSize = 15; + options.arrowStyle = 0; + options.backgroundColor = "#000"; + options.borderColor = "#000"; + options.borderRadius = 5; + options.borderWidth = 1; + options.disableAnimation = false; + options.disableAutoPan = false; + options.maxHeight = 300; + options.maxWidth = 300; + options.minHeight = 300; + options.minWidth = 300; + options.padding = 10; + options.shadowStyle = 1; +} + +function test_bubble() { + var map: google.maps.Map; + var marker: google.maps.Marker; + var bubble: google.maps.infobubble.InfoBubble; + + bubble.open(map, marker); + var isOpen = bubble.isOpen(); + bubble.close(); +} \ No newline at end of file diff --git a/googlemaps.infobubble/google.maps.infobubble.d.ts b/googlemaps.infobubble/google.maps.infobubble.d.ts new file mode 100644 index 0000000000..f65dd11146 --- /dev/null +++ b/googlemaps.infobubble/google.maps.infobubble.d.ts @@ -0,0 +1,103 @@ +/// + +// Type definitions for CSS3 InfoBubble with tabs for Google Maps API V3 +// Project: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/src/ +// Definitions by: Johan Nilsson https://github.com/Dashue +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * @name CSS3 InfoBubble with tabs for Google Maps API V3 + * @version 0.8 + * @author Luke Mahe + * @fileoverview + * This library is a CSS Infobubble with tabs. It uses css3 rounded corners and + * drop shadows and animations. It also allows tabs + */ + +/* +The MIT License + +Copyright (c) 2014 https://github.com/Dashue + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +declare module google.maps.infobubble { + + export interface InfoBubble { + /** + * Closes the infobubble + */ + close(): void; + + /** + * Checks if the infobubble is currently open + */ + isOpen(): boolean; + + /** + * Opens the infobubble + * @map The google map object + * @marker The marker used for anchoring the infobubble to + */ + open(map: google.maps.Map, marker: google.maps.Marker) : void; + } + + export interface InfoBubbleOptions { + + /** + * Percentage from the bottom left corner of the infobubble + */ + arrowPosition?: number; + + arrowSize?: number; + + /** + * 0: Middle, 1: Left, 2: Right + */ + arrowStyle?: number; + + backgroundColor?: string; + + borderColor?: string; + + borderRadius?: number; + + borderWidth?: number; + + disableAnimation?: boolean; + + disableAutoPan?: boolean; + + maxHeight?: number; + + maxWidth?: number; + + minHeight?: number; + + minWidth?: number; + + padding?: number; + + /** + * 0: None, 1: Right, 2: Under + */ + shadowStyle?: number; + } +} \ No newline at end of file From 8bc7072dad7b253403312bd4b175745d4b914999 Mon Sep 17 00:00:00 2001 From: Johan Nilsson Date: Wed, 26 Feb 2014 18:43:48 -0400 Subject: [PATCH 224/240] Added references to google maps and infobubble for tests to pass --- googlemaps.infobubble/google.maps.infobubble-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googlemaps.infobubble/google.maps.infobubble-tests.ts b/googlemaps.infobubble/google.maps.infobubble-tests.ts index e555625d8f..61f6b7ac5c 100644 --- a/googlemaps.infobubble/google.maps.infobubble-tests.ts +++ b/googlemaps.infobubble/google.maps.infobubble-tests.ts @@ -1,3 +1,6 @@ +/// +/// + function test_options() { var options: google.maps.infobubble.InfoBubbleOptions; options = {}; From e734c9519f670665e170d71711c573d93a02bf17 Mon Sep 17 00:00:00 2001 From: vvakame Date: Thu, 27 Feb 2014 12:21:49 +0900 Subject: [PATCH 225/240] adhoc fix knockout.postbox/knockout-postbox.d.ts --- knockout.postbox/knockout-postbox.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/knockout.postbox/knockout-postbox.d.ts b/knockout.postbox/knockout-postbox.d.ts index daa35458ab..65f0bbf132 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 { From 3747c3ba051de07302410647bfdfea2bf225b222 Mon Sep 17 00:00:00 2001 From: satoru kimura Date: Thu, 27 Feb 2014 12:31:50 +0900 Subject: [PATCH 226/240] fix angularjs/angular-resource.d.ts for typescript 0.9.7. --- angularjs/angular-resource.d.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index c26bc9fe82..0317e17b7a 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>; From 513db1d6adcadd6fdd46300f2550c7a9f90331e0 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 27 Feb 2014 16:04:58 +0100 Subject: [PATCH 227/240] split runner code over files main file got cumbersome - extracted parts to own files - still one --out file - existing code into DT module cleaned some syntax and lint expanded arrow-functions to full form builds using 0.9.7 --- _infrastructure/tests/runner.js | 1244 +++++++++-------- _infrastructure/tests/runner.ts | 547 ++------ _infrastructure/tests/src/exec.js | 79 -- _infrastructure/tests/src/file.ts | 26 + _infrastructure/tests/src/{ => host}/exec.ts | 22 +- _infrastructure/tests/src/{ => host}/io.ts | 149 +- _infrastructure/tests/src/indexer.ts | 0 _infrastructure/tests/src/io.js | 475 ------- _infrastructure/tests/src/printer.ts | 111 ++ .../tests/src/reporter/reporter.ts | 36 + _infrastructure/tests/src/suite/suite.ts | 83 ++ _infrastructure/tests/src/suite/syntax.ts | 20 + _infrastructure/tests/src/suite/testEval.ts | 21 + _infrastructure/tests/src/suite/tscParams.ts | 49 + _infrastructure/tests/src/timer.ts | 46 + _infrastructure/tests/src/tsc.ts | 43 + _infrastructure/tests/src/util.ts | 5 + 17 files changed, 1288 insertions(+), 1668 deletions(-) delete mode 100644 _infrastructure/tests/src/exec.js create mode 100644 _infrastructure/tests/src/file.ts rename _infrastructure/tests/src/{ => host}/exec.ts (83%) rename _infrastructure/tests/src/{ => host}/io.ts (81%) create mode 100644 _infrastructure/tests/src/indexer.ts delete mode 100644 _infrastructure/tests/src/io.js create mode 100644 _infrastructure/tests/src/printer.ts create mode 100644 _infrastructure/tests/src/reporter/reporter.ts create mode 100644 _infrastructure/tests/src/suite/suite.ts create mode 100644 _infrastructure/tests/src/suite/syntax.ts create mode 100644 _infrastructure/tests/src/suite/testEval.ts create mode 100644 _infrastructure/tests/src/suite/tscParams.ts create mode 100644 _infrastructure/tests/src/timer.ts create mode 100644 _infrastructure/tests/src/tsc.ts create mode 100644 _infrastructure/tests/src/util.ts diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index 2721d83ab3..37aefb7e52 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // + var ExecResult = (function () { function ExecResult() { this.stdout = ""; @@ -69,14 +70,14 @@ var NodeExec = (function () { return NodeExec; })(); -var Exec = (function () { +var Exec = function () { var global = Function("return this;").call(null); if (typeof global.ActiveXObject !== "undefined") { return new WindowsScriptHostExec(); } else { return new NodeExec(); } -})(); +}(); // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -91,6 +92,7 @@ var Exec = (function () { // See the License for the specific language governing permissions and // limitations under the License. // + var IOUtils; (function (IOUtils) { // Creates the directory including its parent if not already present @@ -125,6 +127,8 @@ var IOUtils; IOUtils.throwIOError = throwIOError; })(IOUtils || (IOUtils = {})); + + var IO = (function () { // Create an IO object for use inside WindowsScriptHost hosts // Depends on WSCript and FileSystemObject @@ -154,11 +158,11 @@ var IO = (function () { try { var streamObj = getStreamObject(); streamObj.Open(); - streamObj.Type = 2; - streamObj.Charset = 'x-ansi'; + streamObj.Type = 2; // Text data + streamObj.Charset = 'x-ansi'; // Assume we are reading ansi text streamObj.LoadFromFile(path); var bomChar = streamObj.ReadText(2); - streamObj.Position = 0; + streamObj.Position = 0; // Position has to be at 0 before changing the encoding if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) { streamObj.Charset = 'unicode'; } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) { @@ -213,7 +217,7 @@ var IO = (function () { deleteFile: function (path) { try { if (fso.FileExists(path)) { - fso.DeleteFile(path, true); + fso.DeleteFile(path, true); // true: delete read-only files } } catch (e) { IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); @@ -386,7 +390,7 @@ var IO = (function () { return; } else { mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 0775); + _fs.mkdirSync(path, parseInt('0775', 8)); } } @@ -465,6 +469,7 @@ var IO = (function () { } else { var parentPath = _path.resolve(rootPath, ".."); + // Node will just continue to repeat the root path, rather than return null if (rootPath === parentPath) { return null; } else { @@ -547,622 +552,681 @@ var IO = (function () { if (typeof ActiveXObject === "function") return getWindowsScriptHostIO(); -else if (typeof require === "function") + else if (typeof require === "function") return getNodeIO(); -else + else return null; })(); +var DT; +(function (DT) { + var path = require('path'); + + ///////////////////////////////// + // Given a document root + ts file pattern this class returns: + // all the TS files OR just tests OR just definition files + ///////////////////////////////// + var File = (function () { + function File(baseDir, filePathWithName) { + this.baseDir = baseDir; + this.filePathWithName = filePathWithName; + var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); + this.dir = dirName.split('/')[0]; + this.file = path.basename(this.filePathWithName, '.ts'); + this.ext = path.extname(this.filePathWithName); + } + Object.defineProperty(File.prototype, "formatName", { + // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' + get: function () { + var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); + return this.dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + this.file + this.ext; + }, + enumerable: true, + configurable: true + }); + return File; + })(); + DT.File = File; +})(DT || (DT = {})); +/// +/// +/// +var DT; +(function (DT) { + var Tsc = (function () { + function Tsc() { + } + Tsc.run = function (tsfile, options, callback) { + options = options || {}; + options.tscVersion = options.tscVersion || DT.DEFAULT_TSC_VERSION; + if (typeof options.checkNoImplicitAny === "undefined") { + options.checkNoImplicitAny = true; + } + if (typeof options.useTscParams === "undefined") { + options.useTscParams = true; + } + + if (!IO.fileExists(tsfile)) { + throw new Error(tsfile + " not exists"); + } + + var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; + if (!IO.fileExists(tscPath)) { + throw new Error(tscPath + ' is not exists'); + } + var command = 'node ' + tscPath + ' --module commonjs '; + if (options.useTscParams && IO.fileExists(tsfile + '.tscparams')) { + command += '@' + tsfile + '.tscparams'; + } else if (options.checkNoImplicitAny) { + command += '--noImplicitAny'; + } + Exec.exec(command, [tsfile], function (execResult) { + callback(execResult); + }); + }; + return Tsc; + })(); + DT.Tsc = Tsc; +})(DT || (DT = {})); +/// +/// +var DT; +(function (DT) { + ///////////////////////////////// + // Timer.start starts a timer + // Timer.end stops the timer and sets asString to the pretty print value + ///////////////////////////////// + var Timer = (function () { + function Timer() { + this.time = 0; + } + Timer.prototype.start = function () { + this.time = 0; + this.startTime = this.now(); + }; + + Timer.prototype.now = function () { + return Date.now(); + }; + + Timer.prototype.end = function () { + this.time = (this.now() - this.startTime) / 1000; + this.asString = Timer.prettyDate(this.startTime, this.now()); + }; + + Timer.prettyDate = function (date1, date2) { + var diff = ((date2 - date1) / 1000), day_diff = Math.floor(diff / 86400); + + if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) + return; + + return (day_diff == 0 && (diff < 60 && (diff + " seconds") || diff < 120 && "1 minute" || diff < 3600 && Math.floor(diff / 60) + " minutes" || diff < 7200 && "1 hour" || diff < 86400 && Math.floor(diff / 3600) + " hours") || day_diff == 1 && "Yesterday" || day_diff < 7 && day_diff + " days" || day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); + }; + return Timer; + })(); + DT.Timer = Timer; +})(DT || (DT = {})); +var DT; +(function (DT) { + function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } + DT.endsWith = endsWith; +})(DT || (DT = {})); +/// +/// +var DT; +(function (DT) { + ///////////////////////////////// + // All the common things that we pring are functions of this class + ///////////////////////////////// + var Print = (function () { + function Print(version, typings, tests, tsFiles) { + this.version = version; + this.typings = typings; + this.tests = tests; + this.tsFiles = tsFiles; + this.WIDTH = 77; + } + Print.prototype.out = function (s) { + process.stdout.write(s); + return this; + }; + + Print.prototype.repeat = function (s, times) { + return new Array(times + 1).join(s); + }; + + Print.prototype.printHeader = function () { + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); + this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); + this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); + this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); + }; + + Print.prototype.printSuiteHeader = function (title) { + var left = Math.floor((this.WIDTH - title.length) / 2) - 1; + var right = Math.ceil((this.WIDTH - title.length) / 2) - 1; + this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); + this.out(title); + this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); + }; + + Print.prototype.printDiv = function () { + this.out('-----------------------------------------------------------------------------\n'); + }; + + Print.prototype.printBoldDiv = function () { + this.out('=============================================================================\n'); + }; + + Print.prototype.printErrorsHeader = function () { + this.out('=============================================================================\n'); + this.out(' \33[34m\33[1mErrors in files\33[0m \n'); + this.out('=============================================================================\n'); + }; + + Print.prototype.printErrorsForFile = function (testResult) { + this.out('----------------- For file:' + testResult.targetFile.formatName); + this.printBreak().out(testResult.stderr).printBreak(); + }; + + Print.prototype.printBreak = function () { + this.out('\n'); + return this; + }; + + Print.prototype.clearCurrentLine = function () { + this.out("\r\33[K"); + return this; + }; + + Print.prototype.printSuccessCount = function (current, total) { + this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + }; + + Print.prototype.printFailedCount = function (current, total) { + this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + }; + + Print.prototype.printTypingsWithoutTestsMessage = function () { + this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); + }; + + Print.prototype.printTotalMessage = function () { + this.out(' \33[36m\33[1mTotal\33[0m\n'); + }; + + Print.prototype.printElapsedTime = function (time, s) { + this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); + }; + + Print.prototype.printSuiteErrorCount = function (errorHeadline, current, total, valuesColor) { + if (typeof valuesColor === "undefined") { valuesColor = '\33[31m\33[1m'; } + this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); + this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + }; + + Print.prototype.printTypingsWithoutTestName = function (file) { + this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); + }; + + Print.prototype.printTypingsWithoutTest = function (withoutTestTypings) { + var _this = this; + if (withoutTestTypings.length > 0) { + this.printTypingsWithoutTestsMessage(); + + this.printDiv(); + withoutTestTypings.forEach(function (t) { + _this.printTypingsWithoutTestName(t); + }); + } + }; + return Print; + })(); + DT.Print = Print; +})(DT || (DT = {})); +var DT; +(function (DT) { + + + ///////////////////////////////// + // Default test reporter + ///////////////////////////////// + var DefaultTestReporter = (function () { + function DefaultTestReporter(print) { + this.print = print; + } + DefaultTestReporter.prototype.printPositiveCharacter = function (index, testResult) { + this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); + + this.printBreakIfNeeded(index); + }; + + DefaultTestReporter.prototype.printNegativeCharacter = function (index, testResult) { + this.print.out("x"); + + this.printBreakIfNeeded(index); + }; + + DefaultTestReporter.prototype.printBreakIfNeeded = function (index) { + if (index % this.print.WIDTH === 0) { + this.print.printBreak(); + } + }; + return DefaultTestReporter; + })(); + DT.DefaultTestReporter = DefaultTestReporter; +})(DT || (DT = {})); +/// +var DT; +(function (DT) { + + + ///////////////////////////////// + // Base class for test suite + ///////////////////////////////// + var TestSuiteBase = (function () { + function TestSuiteBase(options, testSuiteName, errorHeadline) { + this.options = options; + this.testSuiteName = testSuiteName; + this.errorHeadline = errorHeadline; + this.timer = new DT.Timer(); + this.testResults = []; + this.printErrorCount = true; + } + TestSuiteBase.prototype.filterTargetFiles = function (files) { + throw new Error("please implement this method"); + }; + + TestSuiteBase.prototype.start = function (targetFiles, testCallback, suiteCallback) { + var _this = this; + targetFiles = this.filterTargetFiles(targetFiles); + this.timer.start(); + var count = 0; + + // exec test is async process. serialize. + var executor = function () { + var targetFile = targetFiles[count]; + if (targetFile) { + _this.runTest(targetFile, function (result) { + testCallback(result, count + 1); + count++; + executor(); + }); + } else { + _this.timer.end(); + _this.finish(suiteCallback); + } + }; + executor(); + }; + + TestSuiteBase.prototype.runTest = function (targetFile, callback) { + var _this = this; + new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion }).run(function (result) { + _this.testResults.push(result); + callback(result); + }); + }; + + TestSuiteBase.prototype.finish = function (suiteCallback) { + suiteCallback(this); + }; + + Object.defineProperty(TestSuiteBase.prototype, "okTests", { + get: function () { + return this.testResults.filter(function (r) { + return r.success; + }); + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(TestSuiteBase.prototype, "ngTests", { + get: function () { + return this.testResults.filter(function (r) { + return !r.success; + }); + }, + enumerable: true, + configurable: true + }); + return TestSuiteBase; + })(); + DT.TestSuiteBase = TestSuiteBase; +})(DT || (DT = {})); +/// +/// 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 DefinitelyTyped; -(function (DefinitelyTyped) { - /// - /// - /// - (function (TestManager) { - var path = require('path'); - - TestManager.DEFAULT_TSC_VERSION = "0.9.1.1"; - - function endsWith(str, suffix) { - return str.indexOf(suffix, str.length - suffix.length) !== -1; +var DT; +(function (DT) { + ///////////////////////////////// + // .d.ts syntax inspection + ///////////////////////////////// + var SyntaxChecking = (function (_super) { + __extends(SyntaxChecking, _super); + function SyntaxChecking(options) { + _super.call(this, options, "Syntax checking", "Syntax error"); } - - var Tsc = (function () { - function Tsc() { - } - Tsc.run = function (tsfile, options, callback) { - options = options || {}; - options.tscVersion = options.tscVersion || TestManager.DEFAULT_TSC_VERSION; - if (typeof options.checkNoImplicitAny === "undefined") { - options.checkNoImplicitAny = true; - } - if (typeof options.useTscParams === "undefined") { - options.useTscParams = true; - } - - if (!IO.fileExists(tsfile)) { - throw new Error(tsfile + " not exists"); - } - - var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!IO.fileExists(tscPath)) { - throw new Error(tscPath + ' is not exists'); - } - var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && IO.fileExists(tsfile + '.tscparams')) { - command += '@' + tsfile + '.tscparams'; - } else if (options.checkNoImplicitAny) { - command += '--noImplicitAny'; - } - Exec.exec(command, [tsfile], function (execResult) { - callback(execResult); - }); - }; - return Tsc; - })(); - - var Test = (function () { - function Test(suite, tsfile, options) { - this.suite = suite; - this.tsfile = tsfile; - this.options = options; - } - Test.prototype.run = function (callback) { - var _this = this; - Tsc.run(this.tsfile.filePathWithName, this.options, function (execResult) { - var testResult = new TestResult(); - testResult.hostedBy = _this.suite; - testResult.targetFile = _this.tsfile; - testResult.options = _this.options; - - testResult.stdout = execResult.stdout; - testResult.stderr = execResult.stderr; - testResult.exitCode = execResult.exitCode; - - callback(testResult); - }); - }; - return Test; - })(); - - ///////////////////////////////// - // Timer.start starts a timer - // Timer.end stops the timer and sets asString to the pretty print value - ///////////////////////////////// - var Timer = (function () { - function Timer() { - this.time = 0; - } - Timer.prototype.start = function () { - this.time = 0; - this.startTime = this.now(); - }; - - Timer.prototype.now = function () { - return Date.now(); - }; - - Timer.prototype.end = function () { - this.time = (this.now() - this.startTime) / 1000; - this.asString = Timer.prettyDate(this.startTime, this.now()); - }; - - Timer.prettyDate = function (date1, date2) { - var diff = ((date2 - date1) / 1000), day_diff = Math.floor(diff / 86400); - - if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) - return; - - return (day_diff == 0 && (diff < 60 && (diff + " seconds") || diff < 120 && "1 minute" || diff < 3600 && Math.floor(diff / 60) + " minutes" || diff < 7200 && "1 hour" || diff < 86400 && Math.floor(diff / 3600) + " hours") || day_diff == 1 && "Yesterday" || day_diff < 7 && day_diff + " days" || day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); - }; - return Timer; - })(); - TestManager.Timer = Timer; - - ///////////////////////////////// - // Given a document root + ts file pattern this class returns: - // all the TS files OR just tests OR just definition files - ///////////////////////////////// - var File = (function () { - function File(baseDir, filePathWithName) { - this.baseDir = baseDir; - this.filePathWithName = filePathWithName; - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - this.dir = dirName.split('/')[0]; - this.file = path.basename(this.filePathWithName, '.ts'); - this.ext = path.extname(this.filePathWithName); - } - Object.defineProperty(File.prototype, "formatName", { - get: // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' - function () { - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - return this.dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + this.file + this.ext; - }, - enumerable: true, - configurable: true + SyntaxChecking.prototype.filterTargetFiles = function (files) { + return files.filter(function (file) { + return DT.endsWith(file.formatName.toUpperCase(), '.D.TS'); }); - return File; - })(); - TestManager.File = File; - - ///////////////////////////////// - // Test results - ///////////////////////////////// - var TestResult = (function () { - function TestResult() { - } - Object.defineProperty(TestResult.prototype, "success", { - get: function () { - return this.exitCode === 0; - }, - enumerable: true, - configurable: true + }; + return SyntaxChecking; + })(DT.TestSuiteBase); + DT.SyntaxChecking = SyntaxChecking; +})(DT || (DT = {})); +/// +/// +var DT; +(function (DT) { + ///////////////////////////////// + // Compile with *-tests.ts + ///////////////////////////////// + var TestEval = (function (_super) { + __extends(TestEval, _super); + function TestEval(options) { + _super.call(this, options, "Typing tests", "Failed tests"); + } + TestEval.prototype.filterTargetFiles = function (files) { + return files.filter(function (file) { + return DT.endsWith(file.formatName.toUpperCase(), '-TESTS.TS'); }); - return TestResult; - })(); - TestManager.TestResult = TestResult; + }; + return TestEval; + })(DT.TestSuiteBase); + DT.TestEval = TestEval; +})(DT || (DT = {})); +/// +/// +var DT; +(function (DT) { + ///////////////////////////////// + // Try compile without .tscparams + // It may indicate that it is compatible with --noImplicitAny maybe... + ///////////////////////////////// + var FindNotRequiredTscparams = (function (_super) { + __extends(FindNotRequiredTscparams, _super); + function FindNotRequiredTscparams(options, print) { + var _this = this; + _super.call(this, options, "Find not required .tscparams files", "New arrival!"); + this.print = print; + this.printErrorCount = false; - ///////////////////////////////// - // Default test reporter - ///////////////////////////////// - var DefaultTestReporter = (function () { - function DefaultTestReporter(print) { - this.print = print; - } - DefaultTestReporter.prototype.printPositiveCharacter = function (index, testResult) { - this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); - - this.printBreakIfNeeded(index); - }; - - DefaultTestReporter.prototype.printNegativeCharacter = function (index, testResult) { - this.print.out("x"); - - this.printBreakIfNeeded(index); - }; - - DefaultTestReporter.prototype.printBreakIfNeeded = function (index) { - if (index % this.print.WIDTH === 0) { - this.print.printBreak(); + this.testReporter = { + printPositiveCharacter: function (index, testResult) { + _this.print.clearCurrentLine().printTypingsWithoutTestName(testResult.targetFile.formatName); + }, + printNegativeCharacter: function (index, testResult) { } }; - return DefaultTestReporter; - })(); + } + FindNotRequiredTscparams.prototype.filterTargetFiles = function (files) { + return files.filter(function (file) { + return IO.fileExists(file.filePathWithName + '.tscparams'); + }); + }; - ///////////////////////////////// - // All the common things that we pring are functions of this class - ///////////////////////////////// - var Print = (function () { - function Print(version, typings, tests, tsFiles) { - this.version = version; - this.typings = typings; - this.tests = tests; - this.tsFiles = tsFiles; - this.WIDTH = 77; + FindNotRequiredTscparams.prototype.runTest = function (targetFile, callback) { + var _this = this; + this.print.clearCurrentLine().out(targetFile.formatName); + new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true }).run(function (result) { + _this.testResults.push(result); + callback(result); + }); + }; + + FindNotRequiredTscparams.prototype.finish = function (suiteCallback) { + this.print.clearCurrentLine(); + suiteCallback(this); + }; + + Object.defineProperty(FindNotRequiredTscparams.prototype, "ngTests", { + get: function () { + // Do not show ng test results + return []; + }, + enumerable: true, + configurable: true + }); + return FindNotRequiredTscparams; + })(DT.TestSuiteBase); + DT.FindNotRequiredTscparams = FindNotRequiredTscparams; +})(DT || (DT = {})); +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +var DT; +(function (DT) { + var fs = require('fs'); + var path = require('path'); + + DT.DEFAULT_TSC_VERSION = "0.9.1.1"; + + var Test = (function () { + function Test(suite, tsfile, options) { + this.suite = suite; + this.tsfile = tsfile; + this.options = options; + } + Test.prototype.run = function (callback) { + var _this = this; + DT.Tsc.run(this.tsfile.filePathWithName, this.options, function (execResult) { + var testResult = new TestResult(); + testResult.hostedBy = _this.suite; + testResult.targetFile = _this.tsfile; + testResult.options = _this.options; + + testResult.stdout = execResult.stdout; + testResult.stderr = execResult.stderr; + testResult.exitCode = execResult.exitCode; + + callback(testResult); + }); + }; + return Test; + })(); + DT.Test = Test; + + ///////////////////////////////// + // Test results + ///////////////////////////////// + var TestResult = (function () { + function TestResult() { + } + Object.defineProperty(TestResult.prototype, "success", { + get: function () { + return this.exitCode === 0; + }, + enumerable: true, + configurable: true + }); + return TestResult; + })(); + DT.TestResult = TestResult; + + ///////////////////////////////// + // The main class to kick things off + ///////////////////////////////// + var TestRunner = (function () { + function TestRunner(dtPath, options) { + if (typeof options === "undefined") { options = { tscVersion: DT.DEFAULT_TSC_VERSION }; } + this.options = options; + this.suites = []; + this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; + + var filesName = IO.dir(dtPath, /.\.ts/g, { recursive: true }).sort(); + + // only includes .d.ts or -tests.ts or -test.ts or .ts + this.files = filesName.filter(function (fileName) { + return fileName.indexOf('../_infrastructure') < 0; + }).filter(function (fileName) { + return fileName.indexOf('../node_modules') < 0; + }).filter(function (fileName) { + return !DT.endsWith(fileName, ".tscparams"); + }).map(function (fileName) { + return new DT.File(dtPath, fileName); + }); + } + TestRunner.prototype.addSuite = function (suite) { + this.suites.push(suite); + }; + + TestRunner.prototype.run = function () { + var _this = this; + this.timer = new DT.Timer(); + this.timer.start(); + + var syntaxChecking = new DT.SyntaxChecking(this.options); + var testEval = new DT.TestEval(this.options); + if (!this.options.findNotRequiredTscparams) { + this.addSuite(syntaxChecking); + this.addSuite(testEval); } - Print.prototype.out = function (s) { - process.stdout.write(s); - return this; - }; - Print.prototype.repeat = function (s, times) { - return new Array(times + 1).join(s); - }; + var typings = syntaxChecking.filterTargetFiles(this.files).length; + var testFiles = testEval.filterTargetFiles(this.files).length; + this.print = new DT.Print(this.options.tscVersion, typings, testFiles, this.files.length); + this.print.printHeader(); - Print.prototype.printHeader = function () { - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); - this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); - this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); - this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); - }; + if (this.options.findNotRequiredTscparams) { + this.addSuite(new DT.FindNotRequiredTscparams(this.options, this.print)); + } - Print.prototype.printSuiteHeader = function (title) { - var left = Math.floor((this.WIDTH - title.length) / 2) - 1; - var right = Math.ceil((this.WIDTH - title.length) / 2) - 1; - this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); - this.out(title); - this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); - }; + var count = 0; + var executor = function () { + var suite = _this.suites[count]; + if (suite) { + suite.testReporter = suite.testReporter || new DT.DefaultTestReporter(_this.print); - Print.prototype.printDiv = function () { - this.out('-----------------------------------------------------------------------------\n'); - }; - - Print.prototype.printBoldDiv = function () { - this.out('=============================================================================\n'); - }; - - Print.prototype.printErrorsHeader = function () { - this.out('=============================================================================\n'); - this.out(' \33[34m\33[1mErrors in files\33[0m \n'); - this.out('=============================================================================\n'); - }; - - Print.prototype.printErrorsForFile = function (testResult) { - this.out('----------------- For file:' + testResult.targetFile.formatName); - this.printBreak().out(testResult.stderr).printBreak(); - }; - - Print.prototype.printBreak = function () { - this.out('\n'); - return this; - }; - - Print.prototype.clearCurrentLine = function () { - this.out("\r\33[K"); - return this; - }; - - Print.prototype.printSuccessCount = function (current, total) { - this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - }; - - Print.prototype.printFailedCount = function (current, total) { - this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - }; - - Print.prototype.printTypingsWithoutTestsMessage = function () { - this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); - }; - - Print.prototype.printTotalMessage = function () { - this.out(' \33[36m\33[1mTotal\33[0m\n'); - }; - - Print.prototype.printElapsedTime = function (time, s) { - this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); - }; - - Print.prototype.printSuiteErrorCount = function (errorHeadline, current, total, valuesColor) { - if (typeof valuesColor === "undefined") { valuesColor = '\33[31m\33[1m'; } - this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); - this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - }; - - Print.prototype.printTypingsWithoutTestName = function (file) { - this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); - }; - - Print.prototype.printTypingsWithoutTest = function (withoutTestTypings) { - var _this = this; - if (withoutTestTypings.length > 0) { - this.printTypingsWithoutTestsMessage(); - - this.printDiv(); - withoutTestTypings.forEach(function (t) { - _this.printTypingsWithoutTestName(t); + _this.print.printSuiteHeader(suite.testSuiteName); + var targetFiles = suite.filterTargetFiles(_this.files); + suite.start(targetFiles, function (testResult, index) { + _this.testCompleteCallback(testResult, index); + }, function (suite) { + _this.suiteCompleteCallback(suite); + count++; + executor(); }); - } - }; - return Print; - })(); - - ///////////////////////////////// - // Base class for test suite - ///////////////////////////////// - var TestSuiteBase = (function () { - function TestSuiteBase(options, testSuiteName, errorHeadline) { - this.options = options; - this.testSuiteName = testSuiteName; - this.errorHeadline = errorHeadline; - this.timer = new Timer(); - this.testResults = []; - this.printErrorCount = true; - } - TestSuiteBase.prototype.filterTargetFiles = function (files) { - throw new Error("please implement this method"); - }; - - TestSuiteBase.prototype.start = function (targetFiles, testCallback, suiteCallback) { - var _this = this; - targetFiles = this.filterTargetFiles(targetFiles); - this.timer.start(); - var count = 0; - - // exec test is async process. serialize. - var executor = function () { - var targetFile = targetFiles[count]; - if (targetFile) { - _this.runTest(targetFile, function (result) { - testCallback(result, count + 1); - count++; - executor(); - }); - } else { - _this.timer.end(); - _this.finish(suiteCallback); - } - }; - executor(); - }; - - TestSuiteBase.prototype.runTest = function (targetFile, callback) { - var _this = this; - new Test(this, targetFile, { tscVersion: this.options.tscVersion }).run(function (result) { - _this.testResults.push(result); - callback(result); - }); - }; - - TestSuiteBase.prototype.finish = function (suiteCallback) { - suiteCallback(this); - }; - - Object.defineProperty(TestSuiteBase.prototype, "okTests", { - get: function () { - return this.testResults.filter(function (r) { - return r.success; - }); - }, - enumerable: true, - configurable: true - }); - - Object.defineProperty(TestSuiteBase.prototype, "ngTests", { - get: function () { - return this.testResults.filter(function (r) { - return !r.success; - }); - }, - enumerable: true, - configurable: true - }); - return TestSuiteBase; - })(); - - ///////////////////////////////// - // .d.ts syntax inspection - ///////////////////////////////// - var SyntaxChecking = (function (_super) { - __extends(SyntaxChecking, _super); - function SyntaxChecking(options) { - _super.call(this, options, "Syntax checking", "Syntax error"); - } - SyntaxChecking.prototype.filterTargetFiles = function (files) { - return files.filter(function (file) { - return endsWith(file.formatName.toUpperCase(), '.D.TS'); - }); - }; - return SyntaxChecking; - })(TestSuiteBase); - - ///////////////////////////////// - // Compile with *-tests.ts - ///////////////////////////////// - var TestEval = (function (_super) { - __extends(TestEval, _super); - function TestEval(options) { - _super.call(this, options, "Typing tests", "Failed tests"); - } - TestEval.prototype.filterTargetFiles = function (files) { - return files.filter(function (file) { - return endsWith(file.formatName.toUpperCase(), '-TESTS.TS'); - }); - }; - return TestEval; - })(TestSuiteBase); - - ///////////////////////////////// - // Try compile without .tscparams - // It may indicate that it is compatible with --noImplicitAny maybe... - ///////////////////////////////// - var FindNotRequiredTscparams = (function (_super) { - __extends(FindNotRequiredTscparams, _super); - function FindNotRequiredTscparams(options, print) { - var _this = this; - _super.call(this, options, "Find not required .tscparams files", "New arrival!"); - this.print = print; - this.printErrorCount = false; - - this.testReporter = { - printPositiveCharacter: function (index, testResult) { - _this.print.clearCurrentLine().printTypingsWithoutTestName(testResult.targetFile.formatName); - }, - printNegativeCharacter: function (index, testResult) { - } - }; - } - FindNotRequiredTscparams.prototype.filterTargetFiles = function (files) { - return files.filter(function (file) { - return IO.fileExists(file.filePathWithName + '.tscparams'); - }); - }; - - FindNotRequiredTscparams.prototype.runTest = function (targetFile, callback) { - var _this = this; - this.print.clearCurrentLine().out(targetFile.formatName); - new Test(this, targetFile, { tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true }).run(function (result) { - _this.testResults.push(result); - callback(result); - }); - }; - - FindNotRequiredTscparams.prototype.finish = function (suiteCallback) { - this.print.clearCurrentLine(); - suiteCallback(this); - }; - - Object.defineProperty(FindNotRequiredTscparams.prototype, "ngTests", { - get: function () { - // Do not show ng test results - return []; - }, - enumerable: true, - configurable: true - }); - return FindNotRequiredTscparams; - })(TestSuiteBase); - - ///////////////////////////////// - // The main class to kick things off - ///////////////////////////////// - var TestRunner = (function () { - function TestRunner(dtPath, options) { - if (typeof options === "undefined") { options = { tscVersion: TestManager.DEFAULT_TSC_VERSION }; } - this.options = options; - this.suites = []; - this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - - var filesName = IO.dir(dtPath, /.\.ts/g, { recursive: true }).sort(); - - // only includes .d.ts or -tests.ts or -test.ts or .ts - filesName = filesName.filter(function (fileName) { - return fileName.indexOf('../_infrastructure') < 0; - }).filter(function (fileName) { - return !endsWith(fileName, ".tscparams"); - }); - this.files = filesName.map(function (fileName) { - return new File(dtPath, fileName); - }); - } - TestRunner.prototype.addSuite = function (suite) { - this.suites.push(suite); - }; - - TestRunner.prototype.run = function () { - var _this = this; - this.timer = new Timer(); - this.timer.start(); - - var syntaxChecking = new SyntaxChecking(this.options); - var testEval = new TestEval(this.options); - if (!this.options.findNotRequiredTscparams) { - this.addSuite(syntaxChecking); - this.addSuite(testEval); - } - - var typings = syntaxChecking.filterTargetFiles(this.files).length; - var testFiles = testEval.filterTargetFiles(this.files).length; - this.print = new Print(this.options.tscVersion, typings, testFiles, this.files.length); - this.print.printHeader(); - - if (this.options.findNotRequiredTscparams) { - this.addSuite(new FindNotRequiredTscparams(this.options, this.print)); - } - - var count = 0; - var executor = function () { - var suite = _this.suites[count]; - if (suite) { - suite.testReporter = suite.testReporter || new DefaultTestReporter(_this.print); - - _this.print.printSuiteHeader(suite.testSuiteName); - var targetFiles = suite.filterTargetFiles(_this.files); - suite.start(targetFiles, function (testResult, index) { - _this.testCompleteCallback(testResult, index); - }, function (suite) { - _this.suiteCompleteCallback(suite); - count++; - executor(); - }); - } else { - _this.timer.end(); - _this.allTestCompleteCallback(); - } - }; - executor(); - }; - - TestRunner.prototype.testCompleteCallback = function (testResult, index) { - var reporter = testResult.hostedBy.testReporter; - if (testResult.success) { - reporter.printPositiveCharacter(index, testResult); } else { - reporter.printNegativeCharacter(index, testResult); + _this.timer.end(); + _this.allTestCompleteCallback(); } }; + executor(); + }; - TestRunner.prototype.suiteCompleteCallback = function (suite) { - this.print.printBreak(); + TestRunner.prototype.testCompleteCallback = function (testResult, index) { + var reporter = testResult.hostedBy.testReporter; + if (testResult.success) { + reporter.printPositiveCharacter(index, testResult); + } else { + reporter.printNegativeCharacter(index, testResult); + } + }; - this.print.printDiv(); - this.print.printElapsedTime(suite.timer.asString, suite.timer.time); - this.print.printSuccessCount(suite.okTests.length, suite.testResults.length); - this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); - }; + TestRunner.prototype.suiteCompleteCallback = function (suite) { + this.print.printBreak(); - TestRunner.prototype.allTestCompleteCallback = function () { - var _this = this; - var testEval = this.suites.filter(function (suite) { - return suite instanceof TestEval; - })[0]; - if (testEval) { - var existsTestTypings = testEval.testResults.map(function (testResult) { - return testResult.targetFile.dir; - }).reduce(function (a, b) { - return a.indexOf(b) < 0 ? a.concat([b]) : a; - }, []); - var typings = this.files.map(function (file) { - return file.dir; - }).reduce(function (a, b) { - return a.indexOf(b) < 0 ? a.concat([b]) : a; - }, []); - var withoutTestTypings = typings.filter(function (typing) { - return existsTestTypings.indexOf(typing) < 0; - }); - this.print.printDiv(); - this.print.printTypingsWithoutTest(withoutTestTypings); - } + this.print.printDiv(); + this.print.printElapsedTime(suite.timer.asString, suite.timer.time); + this.print.printSuccessCount(suite.okTests.length, suite.testResults.length); + this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); + }; - this.print.printDiv(); - this.print.printTotalMessage(); - - this.print.printDiv(); - this.print.printElapsedTime(this.timer.asString, this.timer.time); - this.suites.filter(function (suite) { - return suite.printErrorCount; - }).forEach(function (suite) { - _this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length); + TestRunner.prototype.allTestCompleteCallback = function () { + var _this = this; + var testEval = this.suites.filter(function (suite) { + return suite instanceof DT.TestEval; + })[0]; + if (testEval) { + var existsTestTypings = testEval.testResults.map(function (testResult) { + return testResult.targetFile.dir; + }).reduce(function (a, b) { + return a.indexOf(b) < 0 ? a.concat([b]) : a; + }, []); + var typings = this.files.map(function (file) { + return file.dir; + }).reduce(function (a, b) { + return a.indexOf(b) < 0 ? a.concat([b]) : a; + }, []); + var withoutTestTypings = typings.filter(function (typing) { + return existsTestTypings.indexOf(typing) < 0; }); - if (testEval) { - this.print.printSuiteErrorCount("Without tests", withoutTestTypings.length, typings.length, '\33[33m\33[1m'); - } - this.print.printDiv(); - if (this.suites.some(function (suite) { + this.print.printTypingsWithoutTest(withoutTestTypings); + } + + this.print.printDiv(); + this.print.printTotalMessage(); + + this.print.printDiv(); + this.print.printElapsedTime(this.timer.asString, this.timer.time); + this.suites.filter(function (suite) { + return suite.printErrorCount; + }).forEach(function (suite) { + _this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length); + }); + if (testEval) { + this.print.printSuiteErrorCount("Without tests", withoutTestTypings.length, typings.length, '\33[33m\33[1m'); + } + + this.print.printDiv(); + if (this.suites.some(function (suite) { + return suite.ngTests.length !== 0; + })) { + this.print.printErrorsHeader(); + + this.suites.filter(function (suite) { return suite.ngTests.length !== 0; - })) { - this.print.printErrorsHeader(); - - this.suites.filter(function (suite) { - return suite.ngTests.length !== 0; - }).forEach(function (suite) { - suite.ngTests.forEach(function (testResult) { - _this.print.printErrorsForFile(testResult); - }); - _this.print.printBoldDiv(); + }).forEach(function (suite) { + suite.ngTests.forEach(function (testResult) { + _this.print.printErrorsForFile(testResult); }); + _this.print.printBoldDiv(); + }); - process.exit(1); - } - }; - return TestRunner; - })(); - TestManager.TestRunner = TestRunner; - })(DefinitelyTyped.TestManager || (DefinitelyTyped.TestManager = {})); - var TestManager = DefinitelyTyped.TestManager; -})(DefinitelyTyped || (DefinitelyTyped = {})); + process.exit(1); + } + }; + return TestRunner; + })(); + DT.TestRunner = TestRunner; -var dtPath = __dirname + '/../..'; -var findNotRequiredTscparams = process.argv.some(function (arg) { - return arg == "--try-without-tscparams"; -}); -var tscVersionIndex = process.argv.indexOf("--tsc-version"); -var tscVersion = DefinitelyTyped.TestManager.DEFAULT_TSC_VERSION; -if (-1 < tscVersionIndex) { - tscVersion = process.argv[tscVersionIndex + 1]; -} + var dtPath = __dirname + '/../..'; + var findNotRequiredTscparams = process.argv.some(function (arg) { + return arg == "--try-without-tscparams"; + }); + var tscVersionIndex = process.argv.indexOf("--tsc-version"); + var tscVersion = DT.DEFAULT_TSC_VERSION; + if (-1 < tscVersionIndex) { + tscVersion = process.argv[tscVersionIndex + 1]; + } -var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath, { - tscVersion: tscVersion, - findNotRequiredTscparams: findNotRequiredTscparams -}); -runner.run(); + var runner = new TestRunner(dtPath, { + tscVersion: tscVersion, + findNotRequiredTscparams: findNotRequiredTscparams + }); + runner.run(); +})(DT || (DT = {})); +//# sourceMappingURL=runner.js.map diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index f8746ab518..86a4c2caa3 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -1,60 +1,33 @@ /// -/// -/// +/// +/// -module DefinitelyTyped.TestManager { +/// +/// +/// +/// + +/// +/// + +/// +/// +/// +/// + +module DT { + var fs = require('fs'); var path = require('path'); export var DEFAULT_TSC_VERSION = "0.9.1.1"; - function endsWith(str:string, suffix:string) { - return str.indexOf(suffix, str.length - suffix.length) !== -1; - } - - export interface TscExecOptions { - tscVersion?:string; - useTscParams?:boolean; - checkNoImplicitAny?:boolean; - } - - class Tsc { - public static run(tsfile:string, options:TscExecOptions, callback:(result:ExecResult)=>void) { - options = options || {}; - options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION; - if (typeof options.checkNoImplicitAny === "undefined") { - options.checkNoImplicitAny = true; - } - if (typeof options.useTscParams === "undefined") { - options.useTscParams = true; - } - - if (!IO.fileExists(tsfile)) { - throw new Error(tsfile + " not exists"); - } - - var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!IO.fileExists(tscPath)) { - throw new Error(tscPath + ' is not exists'); - } - var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && IO.fileExists(tsfile + '.tscparams')) { - command += '@' + tsfile + '.tscparams'; - } else if (options.checkNoImplicitAny) { - command += '--noImplicitAny'; - } - Exec.exec(command, [tsfile], (execResult) => { - callback(execResult); - }); - } - } - - class Test { - constructor(public suite:ITestSuite, public tsfile:File, public options?:TscExecOptions) { + export class Test { + constructor(public suite: ITestSuite, public tsfile: File, public options?: TscExecOptions) { } - public run(callback:(result:TestResult)=>void) { - Tsc.run(this.tsfile.filePathWithName, this.options, (execResult)=> { + public run(callback: (result: TestResult) => void) { + Tsc.run(this.tsfile.filePathWithName, this.options, (execResult) => { var testResult = new TestResult(); testResult.hostedBy = this.suite; testResult.targetFile = this.tsfile; @@ -68,380 +41,22 @@ module DefinitelyTyped.TestManager { }); } } - - ///////////////////////////////// - // Timer.start starts a timer - // Timer.end stops the timer and sets asString to the pretty print value - ///////////////////////////////// - export class Timer { - startTime:number; - time = 0; - asString:string; - - public start() { - this.time = 0; - this.startTime = this.now(); - } - - public now():number { - return Date.now(); - } - - public end() { - this.time = (this.now() - this.startTime) / 1000; - this.asString = Timer.prettyDate(this.startTime, this.now()); - } - - public static prettyDate(date1:number, date2:number):string { - var diff = ((date2 - date1) / 1000), - day_diff = Math.floor(diff / 86400); - - if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) - return; - - return (day_diff == 0 && ( - diff < 60 && (diff + " seconds") || - diff < 120 && "1 minute" || - diff < 3600 && Math.floor(diff / 60) + " minutes" || - diff < 7200 && "1 hour" || - diff < 86400 && Math.floor(diff / 3600) + " hours") || - day_diff == 1 && "Yesterday" || - day_diff < 7 && day_diff + " days" || - day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); - } - } - - ///////////////////////////////// - // Given a document root + ts file pattern this class returns: - // all the TS files OR just tests OR just definition files - ///////////////////////////////// - export class File { - dir:string; - file:string; - ext:string; - - constructor(public baseDir:string, public filePathWithName:string) { - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - this.dir = dirName.split('/')[0]; - this.file = path.basename(this.filePathWithName, '.ts'); - this.ext = path.extname(this.filePathWithName); - } - - // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' - public get formatName():string { - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - return this.dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + this.file + this.ext; - } - } - ///////////////////////////////// // Test results ///////////////////////////////// export class TestResult { - hostedBy:ITestSuite; - targetFile:File; - options:TscExecOptions; + hostedBy: ITestSuite; + targetFile: File; + options: TscExecOptions; - stdout:string; - stderr:string; - exitCode:number; + stdout: string; + stderr: string; + exitCode: number; - public get success():boolean { + public get success(): boolean { return this.exitCode === 0; } } - - ///////////////////////////////// - // The interface for test suite - ///////////////////////////////// - export interface ITestSuite { - testSuiteName:string; - errorHeadline:string; - filterTargetFiles(files:File[]):File[]; - - start(targetFiles:File[], testCallback:(result:TestResult, index:number)=>void, suiteCallback:(suite:ITestSuite)=>void):void; - - testResults:TestResult[]; - okTests:TestResult[]; - ngTests:TestResult[]; - timer:Timer; - - testReporter:ITestReporter; - printErrorCount:boolean; - } - - ///////////////////////////////// - // Test reporter interface - // for example, . and x - ///////////////////////////////// - export interface ITestReporter { - printPositiveCharacter(index:number, testResult:TestResult):void; - printNegativeCharacter(index:number, testResult:TestResult):void; - } - - ///////////////////////////////// - // Default test reporter - ///////////////////////////////// - class DefaultTestReporter implements ITestReporter { - constructor(public print:Print) { - } - - public printPositiveCharacter(index:number, testResult:TestResult) { - this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); - - this.printBreakIfNeeded(index); - } - - public printNegativeCharacter(index:number, testResult:TestResult) { - this.print.out("x"); - - this.printBreakIfNeeded(index); - } - - private printBreakIfNeeded(index:number) { - if (index % this.print.WIDTH === 0) { - this.print.printBreak(); - } - } - } - - ///////////////////////////////// - // All the common things that we pring are functions of this class - ///////////////////////////////// - class Print { - - WIDTH = 77; - - constructor(public version:string, public typings:number, public tests:number, public tsFiles:number) { - } - - public out(s:any):Print { - process.stdout.write(s); - return this; - } - - public repeat(s:string, times:number):string { - return new Array(times + 1).join(s); - } - - public printHeader() { - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); - this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); - this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); - this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); - } - - public printSuiteHeader(title:string) { - var left = Math.floor((this.WIDTH - title.length ) / 2) - 1; - var right = Math.ceil((this.WIDTH - title.length ) / 2) - 1; - this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); - this.out(title); - this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); - } - - public printDiv() { - this.out('-----------------------------------------------------------------------------\n'); - } - - public printBoldDiv() { - this.out('=============================================================================\n'); - } - - public printErrorsHeader() { - this.out('=============================================================================\n'); - this.out(' \33[34m\33[1mErrors in files\33[0m \n'); - this.out('=============================================================================\n'); - } - - public printErrorsForFile(testResult:TestResult) { - this.out('----------------- For file:' + testResult.targetFile.formatName); - this.printBreak().out(testResult.stderr).printBreak(); - } - - public printBreak():Print { - this.out('\n'); - return this; - } - - public clearCurrentLine():Print { - this.out("\r\33[K"); - return this; - } - - public printSuccessCount(current:number, total:number) { - this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - - public printFailedCount(current:number, total:number) { - this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - - public printTypingsWithoutTestsMessage() { - this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); - } - - public printTotalMessage() { - this.out(' \33[36m\33[1mTotal\33[0m\n'); - } - - public printElapsedTime(time:string, s:number) { - this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); - } - - public printSuiteErrorCount(errorHeadline:string, current:number, total:number, valuesColor = '\33[31m\33[1m') { - this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); - this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } - - public printTypingsWithoutTestName(file:string) { - this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); - } - - public printTypingsWithoutTest(withoutTestTypings:string[]) { - if (withoutTestTypings.length > 0) { - this.printTypingsWithoutTestsMessage(); - - this.printDiv(); - withoutTestTypings.forEach(t=> { - this.printTypingsWithoutTestName(t); - }); - } - } - } - - ///////////////////////////////// - // Base class for test suite - ///////////////////////////////// - class TestSuiteBase implements ITestSuite { - timer:Timer = new Timer(); - testResults:TestResult[] = []; - testReporter:ITestReporter; - printErrorCount = true; - - constructor(public options:ITestRunnerOptions, public testSuiteName:string, public errorHeadline:string) { - } - - public filterTargetFiles(files:File[]):File[] { - throw new Error("please implement this method"); - } - - public start(targetFiles:File[], testCallback:(result:TestResult, index:number)=>void, suiteCallback:(suite:ITestSuite)=>void):void { - targetFiles = this.filterTargetFiles(targetFiles); - this.timer.start(); - var count = 0; - // exec test is async process. serialize. - var executor = () => { - var targetFile = targetFiles[count]; - if (targetFile) { - this.runTest(targetFile, (result)=> { - testCallback(result, count + 1); - count++; - executor(); - }); - } else { - this.timer.end(); - this.finish(suiteCallback); - } - }; - executor(); - } - - public runTest(targetFile:File, callback:(result:TestResult)=>void):void { - new Test(this, targetFile, {tscVersion: this.options.tscVersion}).run(result=> { - this.testResults.push(result); - callback(result); - }); - } - - public finish(suiteCallback:(suite:ITestSuite)=>void) { - suiteCallback(this); - } - - public get okTests():TestResult[] { - return this.testResults.filter(r=>r.success); - } - - public get ngTests():TestResult[] { - return this.testResults.filter(r=>!r.success); - } - } - - ///////////////////////////////// - // .d.ts syntax inspection - ///////////////////////////////// - class SyntaxChecking extends TestSuiteBase { - - constructor(options:ITestRunnerOptions) { - super(options, "Syntax checking", "Syntax error"); - } - - public filterTargetFiles(files:File[]):File[] { - return files.filter(file => endsWith(file.formatName.toUpperCase(), '.D.TS')); - } - } - - ///////////////////////////////// - // Compile with *-tests.ts - ///////////////////////////////// - class TestEval extends TestSuiteBase { - - constructor(options) { - super(options, "Typing tests", "Failed tests"); - } - - public filterTargetFiles(files:File[]):File[] { - return files.filter(file => endsWith(file.formatName.toUpperCase(), '-TESTS.TS')); - } - } - - ///////////////////////////////// - // Try compile without .tscparams - // It may indicate that it is compatible with --noImplicitAny maybe... - ///////////////////////////////// - class FindNotRequiredTscparams extends TestSuiteBase { - testReporter:ITestReporter; - printErrorCount = false; - - constructor(options:ITestRunnerOptions, private print:Print) { - super(options, "Find not required .tscparams files", "New arrival!"); - - this.testReporter = { - printPositiveCharacter: (index:number, testResult:TestResult)=> { - this.print - .clearCurrentLine() - .printTypingsWithoutTestName(testResult.targetFile.formatName); - }, - printNegativeCharacter: (index:number, testResult:TestResult)=> { - } - } - } - - public filterTargetFiles(files:File[]):File[] { - return files.filter(file=> IO.fileExists(file.filePathWithName + '.tscparams')); - } - - public runTest(targetFile:File, callback:(result:TestResult)=>void):void { - this.print.clearCurrentLine().out(targetFile.formatName); - new Test(this, targetFile, {tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true}).run(result=> { - this.testResults.push(result); - callback(result); - }); - } - - public finish(suiteCallback:(suite:ITestSuite)=>void) { - this.print.clearCurrentLine(); - suiteCallback(this); - } - - public get ngTests():TestResult[] { - // Do not show ng test results - return []; - } - } - export interface ITestRunnerOptions { tscVersion:string; findNotRequiredTscparams?:boolean; @@ -451,23 +66,31 @@ module DefinitelyTyped.TestManager { // The main class to kick things off ///////////////////////////////// export class TestRunner { - files:File[]; - timer:Timer; - suites:ITestSuite[] = []; - private print:Print; + files: File[]; + timer: Timer; + suites: ITestSuite[] = []; + private print: Print; - constructor(dtPath:string, public options:ITestRunnerOptions = {tscVersion: DEFAULT_TSC_VERSION}) { + constructor(dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) { this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; var filesName = IO.dir(dtPath, /.\.ts/g, { recursive: true }).sort(); // only includes .d.ts or -tests.ts or -test.ts or .ts - filesName = filesName - .filter(fileName => fileName.indexOf('../_infrastructure') < 0) - .filter(fileName => !endsWith(fileName, ".tscparams")); - this.files = filesName.map(fileName => new File(dtPath, fileName)); + this.files = filesName + .filter((fileName) => { + return fileName.indexOf('../_infrastructure') < 0; + }) + .filter((fileName) => { + return fileName.indexOf('../node_modules') < 0; + }) + .filter((fileName) => { + return !DT.endsWith(fileName, ".tscparams"); + }).map((fileName) => { + return new File(dtPath, fileName); + }); } - public addSuite(suite:ITestSuite) { + public addSuite(suite: ITestSuite) { this.suites.push(suite); } @@ -504,7 +127,7 @@ module DefinitelyTyped.TestManager { (testResult, index) => { this.testCompleteCallback(testResult, index); }, - suite=> { + (suite) => { this.suiteCompleteCallback(suite); count++; executor(); @@ -517,7 +140,7 @@ module DefinitelyTyped.TestManager { executor(); } - private testCompleteCallback(testResult:TestResult, index:number) { + private testCompleteCallback(testResult: TestResult, index: number) { var reporter = testResult.hostedBy.testReporter; if (testResult.success) { reporter.printPositiveCharacter(index, testResult); @@ -526,7 +149,7 @@ module DefinitelyTyped.TestManager { } } - private suiteCompleteCallback(suite:ITestSuite) { + private suiteCompleteCallback(suite: ITestSuite) { this.print.printBreak(); this.print.printDiv(); @@ -536,16 +159,26 @@ module DefinitelyTyped.TestManager { } private allTestCompleteCallback() { - var testEval = this.suites.filter(suite=>suite instanceof TestEval)[0]; + var testEval = this.suites.filter(suite => suite instanceof TestEval)[0]; if (testEval) { - var existsTestTypings:string[] = testEval.testResults - .map(testResult=>testResult.targetFile.dir) - .reduce((a, b)=> a.indexOf(b) < 0 ? a.concat([b]) : a, []); - var typings:string[] = this.files - .map(file=>file.dir) - .reduce((a, b)=> a.indexOf(b) < 0 ? a.concat([b]) : a, []); - var withoutTestTypings:string[] = typings - .filter(typing=>existsTestTypings.indexOf(typing) < 0); + var existsTestTypings: string[] = testEval.testResults + .map((testResult) => { + return testResult.targetFile.dir; + }) + .reduce((a: string[], b: string) => { + return a.indexOf(b) < 0 ? a.concat([b]) : a; + }, []); + var typings: string[] = this.files + .map((file) => { + return file.dir; + }) + .reduce((a: string[], b: string) => { + return a.indexOf(b) < 0 ? a.concat([b]) : a; + }, []); + var withoutTestTypings: string[] = typings + .filter((typing) => { + return existsTestTypings.indexOf(typing) < 0; + }); this.print.printDiv(); this.print.printTypingsWithoutTest(withoutTestTypings); } @@ -556,8 +189,10 @@ module DefinitelyTyped.TestManager { this.print.printDiv(); this.print.printElapsedTime(this.timer.asString, this.timer.time); this.suites - .filter(suite=>suite.printErrorCount) - .forEach(suite=> { + .filter((suite: ITestSuite) => { + return suite.printErrorCount; + }) + .forEach((suite: ITestSuite) => { this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length); }); if (testEval) { @@ -565,13 +200,17 @@ module DefinitelyTyped.TestManager { } this.print.printDiv(); - if (this.suites.some(suite=>suite.ngTests.length !== 0)) { + if (this.suites.some((suite) => { + return suite.ngTests.length !== 0 + })) { this.print.printErrorsHeader(); this.suites - .filter(suite=>suite.ngTests.length !== 0) - .forEach(suite=> { - suite.ngTests.forEach(testResult => { + .filter((suite) => { + return suite.ngTests.length !== 0; + }) + .forEach((suite) => { + suite.ngTests.forEach((testResult) => { this.print.printErrorsForFile(testResult); }); this.print.printBoldDiv(); @@ -581,18 +220,18 @@ module DefinitelyTyped.TestManager { } } } -} -var dtPath = __dirname + '/../..'; -var findNotRequiredTscparams = process.argv.some(arg=>arg == "--try-without-tscparams"); -var tscVersionIndex = process.argv.indexOf("--tsc-version"); -var tscVersion = DefinitelyTyped.TestManager.DEFAULT_TSC_VERSION; -if (-1 < tscVersionIndex) { - tscVersion = process.argv[tscVersionIndex + 1]; -} + var dtPath = __dirname + '/../..'; + var findNotRequiredTscparams = process.argv.some(arg => arg == "--try-without-tscparams"); + var tscVersionIndex = process.argv.indexOf("--tsc-version"); + var tscVersion = DEFAULT_TSC_VERSION; + if (-1 < tscVersionIndex) { + tscVersion = process.argv[tscVersionIndex + 1]; + } -var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath, { - tscVersion: tscVersion, - findNotRequiredTscparams: findNotRequiredTscparams -}); -runner.run(); + var runner = new TestRunner(dtPath, { + tscVersion: tscVersion, + findNotRequiredTscparams: findNotRequiredTscparams + }); + runner.run(); +} diff --git a/_infrastructure/tests/src/exec.js b/_infrastructure/tests/src/exec.js deleted file mode 100644 index 2b8ea5c597..0000000000 --- a/_infrastructure/tests/src/exec.js +++ /dev/null @@ -1,79 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -var ExecResult = (function () { - function ExecResult() { - this.stdout = ""; - this.stderr = ""; - } - return ExecResult; -})(); - -var WindowsScriptHostExec = (function () { - function WindowsScriptHostExec() { - } - WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) { - var result = new ExecResult(); - var shell = new ActiveXObject('WScript.Shell'); - try { - var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' ')); - } catch (e) { - result.stderr = e.message; - result.exitCode = 1; - handleResult(result); - return; - } - - while (process.Status != 0) { - } - - result.exitCode = process.ExitCode; - if (!process.StdOut.AtEndOfStream) - result.stdout = process.StdOut.ReadAll(); - if (!process.StdErr.AtEndOfStream) - result.stderr = process.StdErr.ReadAll(); - - handleResult(result); - }; - return WindowsScriptHostExec; -})(); - -var NodeExec = (function () { - function NodeExec() { - } - NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) { - var nodeExec = require('child_process').exec; - - var result = new ExecResult(); - result.exitCode = null; - var cmdLine = filename + ' ' + cmdLineArgs.join(' '); - - var process = nodeExec(cmdLine, function (error, stdout, stderr) { - result.stdout = stdout; - result.stderr = stderr; - result.exitCode = error ? error.code : 0; - handleResult(result); - }); - }; - return NodeExec; -})(); - -var Exec = (function () { - var global = Function("return this;").call(null); - if (typeof global.ActiveXObject !== "undefined") { - return new WindowsScriptHostExec(); - } else { - return new NodeExec(); - } -})(); diff --git a/_infrastructure/tests/src/file.ts b/_infrastructure/tests/src/file.ts new file mode 100644 index 0000000000..f349a09da6 --- /dev/null +++ b/_infrastructure/tests/src/file.ts @@ -0,0 +1,26 @@ +module DT { + var path = require('path'); + + ///////////////////////////////// + // Given a document root + ts file pattern this class returns: + // all the TS files OR just tests OR just definition files + ///////////////////////////////// + export class File { + dir: string; + file: string; + ext: string; + + constructor(public baseDir: string, public filePathWithName: string) { + var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); + this.dir = dirName.split('/')[0]; + this.file = path.basename(this.filePathWithName, '.ts'); + this.ext = path.extname(this.filePathWithName); + } + + // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' + public get formatName(): string { + var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); + return this.dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + this.file + this.ext; + } + } +} diff --git a/_infrastructure/tests/src/exec.ts b/_infrastructure/tests/src/host/exec.ts similarity index 83% rename from _infrastructure/tests/src/exec.ts rename to _infrastructure/tests/src/host/exec.ts index 5123d4cfc6..2bddb0043c 100644 --- a/_infrastructure/tests/src/exec.ts +++ b/_infrastructure/tests/src/host/exec.ts @@ -18,8 +18,6 @@ interface IExec { exec: (filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void) => void; } -declare var require; - class ExecResult { public stdout = ""; public stderr = ""; @@ -27,31 +25,31 @@ class ExecResult { } class WindowsScriptHostExec implements IExec { - public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void) : void { + public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void): void { var result = new ExecResult(); var shell = new ActiveXObject('WScript.Shell'); try { var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' ')); - } catch(e) { + } catch (e) { result.stderr = e.message; result.exitCode = 1 handleResult(result); return; } // Wait for it to finish running - while (process.Status != 0) { /* todo: sleep? */ } + while (process.Status != 0) { /* todo: sleep? */ + } - result.exitCode = process.ExitCode; - if(!process.StdOut.AtEndOfStream) result.stdout = process.StdOut.ReadAll(); - if(!process.StdErr.AtEndOfStream) result.stderr = process.StdErr.ReadAll(); + if (!process.StdOut.AtEndOfStream) result.stdout = process.StdOut.ReadAll(); + if (!process.StdErr.AtEndOfStream) result.stderr = process.StdErr.ReadAll(); handleResult(result); } } class NodeExec implements IExec { - public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void) : void { + public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void): void { var nodeExec = require('child_process').exec; var result = new ExecResult(); @@ -67,11 +65,11 @@ class NodeExec implements IExec { } } -var Exec: IExec = function() : IExec { +var Exec: IExec = function (): IExec { var global = Function("return this;").call(null); - if(typeof global.ActiveXObject !== "undefined") { + if (typeof global.ActiveXObject !== "undefined") { return new WindowsScriptHostExec(); } else { return new NodeExec(); } -}(); \ No newline at end of file +}(); diff --git a/_infrastructure/tests/src/io.ts b/_infrastructure/tests/src/host/io.ts similarity index 81% rename from _infrastructure/tests/src/io.ts rename to _infrastructure/tests/src/host/io.ts index 2c7a81f4f3..b308ef13f6 100644 --- a/_infrastructure/tests/src/io.ts +++ b/_infrastructure/tests/src/host/io.ts @@ -27,7 +27,8 @@ interface IIO { writeFile(path: string, contents: string): void; createFile(path: string, useUTF8?: boolean): ITextWriter; deleteFile(path: string): void; - dir(path: string, re?: RegExp, options?: { recursive?: boolean; deep?: number; }): string[]; + dir(path: string, re?: RegExp, options?: { recursive?: boolean; deep?: number; + }): string[]; fileExists(path: string): boolean; directoryExists(path: string): boolean; createDirectory(path: string): void; @@ -39,7 +40,7 @@ interface IIO { arguments: string[]; stderr: ITextWriter; stdout: ITextWriter; - watchFile(filename: string, callback: (string) => void ): IFileWatcher; + watchFile(filename: string, callback: (string) => void): IFileWatcher; run(source: string, filename: string): void; getExecutingFilePath(): string; quit(exitCode?: number); @@ -79,9 +80,12 @@ module IOUtils { // Declare dependencies needed for all supported hosts declare class Enumerator { public atEnd(): boolean; + public moveNext(); + public item(): any; - constructor (o: any); + + constructor(o: any); } // Missing in node definitions, but called in code below. @@ -91,7 +95,7 @@ interface NodeProcess { } } -var IO = (function() { +var IO = (function () { // Create an IO object for use inside WindowsScriptHost hosts // Depends on WSCript and FileSystemObject @@ -99,15 +103,15 @@ var IO = (function() { var fso = new ActiveXObject("Scripting.FileSystemObject"); var streamObjectPool = []; - function getStreamObject(): any { + function getStreamObject(): any { if (streamObjectPool.length > 0) { return streamObjectPool.pop(); - } else { + } else { return new ActiveXObject("ADODB.Stream"); } } - function releaseStreamObject(obj: any) { + function releaseStreamObject(obj: any) { streamObjectPool.push(obj); } @@ -117,7 +121,7 @@ var IO = (function() { } return { - readFile: function(path) { + readFile: function (path) { try { var streamObj = getStreamObject(); streamObj.Open(); @@ -130,7 +134,7 @@ var IO = (function() { || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) { streamObj.Charset = 'unicode'; } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) { - streamObj.Charset = 'utf-8'; + streamObj.Charset = 'utf-8'; } // Read the whole file @@ -144,25 +148,25 @@ var IO = (function() { } }, - writeFile: function(path, contents) { + writeFile: function (path, contents) { var file = this.createFile(path); file.Write(contents); file.Close(); }, - fileExists: function(path: string): boolean { + fileExists: function (path: string): boolean { return fso.FileExists(path); }, - resolvePath: function(path: string): string { + resolvePath: function (path: string): string { return fso.GetAbsolutePathName(path); }, - dirName: function(path: string): string { + dirName: function (path: string): string { return fso.GetParentFolderName(path); }, - findFile: function(rootPath: string, partialFilePath: string): IResolvedFile { + findFile: function (rootPath: string, partialFilePath: string): IResolvedFile { var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; while (true) { @@ -188,7 +192,7 @@ var IO = (function() { } }, - deleteFile: function(path: string): void { + deleteFile: function (path: string): void { try { if (fso.FileExists(path)) { fso.DeleteFile(path, true); // true: delete read-only files @@ -204,9 +208,13 @@ var IO = (function() { streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi'; streamObj.Open(); return { - Write: function (str) { streamObj.WriteText(str, 0); }, - WriteLine: function (str) { streamObj.WriteText(str, 1); }, - Close: function() { + Write: function (str) { + streamObj.WriteText(str, 0); + }, + WriteLine: function (str) { + streamObj.WriteText(str, 1); + }, + Close: function () { try { streamObj.SaveToFile(path, 2); } catch (saveError) { @@ -225,11 +233,11 @@ var IO = (function() { } }, - directoryExists: function(path) { + directoryExists: function (path) { return fso.FolderExists(path); }, - createDirectory: function(path) { + createDirectory: function (path) { try { if (!this.directoryExists(path)) { fso.CreateFolder(path); @@ -239,23 +247,24 @@ var IO = (function() { } }, - dir: function(path, spec?, options?) { - options = options || <{ recursive?: boolean; deep?: number; }>{}; - function filesInFolder(folder, root): string[]{ + dir: function (path, spec?, options?) { + options = options || <{ recursive?: boolean; deep?: number; + }>{}; + function filesInFolder(folder, root): string[] { var paths = []; var fc: Enumerator; if (options.recursive) { fc = new Enumerator(folder.subfolders); - for (; !fc.atEnd() ; fc.moveNext()) { + for (; !fc.atEnd(); fc.moveNext()) { paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); } } fc = new Enumerator(folder.files); - for (; !fc.atEnd() ; fc.moveNext()) { + for (; !fc.atEnd(); fc.moveNext()) { if (!spec || fc.item().Name.match(spec)) { paths.push(root + "/" + fc.item().Name); } @@ -270,11 +279,11 @@ var IO = (function() { return filesInFolder(folder, path); }, - print: function(str) { + print: function (str) { WScript.StdOut.Write(str); }, - printLine: function(str) { + printLine: function (str) { WScript.Echo(str); }, @@ -282,7 +291,7 @@ var IO = (function() { stderr: WScript.StdErr, stdout: WScript.StdOut, watchFile: null, - run: function(source, filename) { + run: function (source, filename) { try { eval(source); } catch (e) { @@ -292,7 +301,7 @@ var IO = (function() { getExecutingFilePath: function () { return WScript.ScriptFullName; }, - quit: function (exitCode : number = 0) { + quit: function (exitCode: number = 0) { try { WScript.Quit(exitCode); } catch (e) { @@ -311,7 +320,7 @@ var IO = (function() { var _module = require('module'); return { - readFile: function(file) { + readFile: function (file) { try { var buffer = _fs.readFileSync(file); switch (buffer[0]) { @@ -348,17 +357,17 @@ var IO = (function() { } }, writeFile: <(path: string, contents: string) => void >_fs.writeFileSync, - deleteFile: function(path) { + deleteFile: function (path) { try { _fs.unlinkSync(path); } catch (e) { IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); } }, - fileExists: function(path): boolean { + fileExists: function (path): boolean { return _fs.existsSync(path); }, - createFile: function(path, useUTF8?) { + createFile: function (path, useUTF8?) { function mkdirRecursiveSync(path) { var stats = _fs.statSync(path); if (stats.isFile()) { @@ -367,7 +376,7 @@ var IO = (function() { return; } else { mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 0775); + _fs.mkdirSync(path, parseInt('0775', 8)); } } @@ -379,15 +388,23 @@ var IO = (function() { IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e); } return { - Write: function(str) { _fs.writeSync(fd, str); }, - WriteLine: function(str) { _fs.writeSync(fd, str + '\r\n'); }, - Close: function() { _fs.closeSync(fd); fd = null; } + Write: function (str) { + _fs.writeSync(fd, str); + }, + WriteLine: function (str) { + _fs.writeSync(fd, str + '\r\n'); + }, + Close: function () { + _fs.closeSync(fd); + fd = null; + } }; }, dir: function dir(path, spec?, options?) { - options = options || <{ recursive?: boolean; deep?: number; }>{}; + options = options || <{ recursive?: boolean; deep?: number; + }>{}; - function filesInFolder(folder: string, deep?: number): string[]{ + function filesInFolder(folder: string, deep?: number): string[] { var paths = []; var files = _fs.readdirSync(folder); @@ -407,7 +424,7 @@ var IO = (function() { return filesInFolder(path, 0); }, - createDirectory: function(path: string): void { + createDirectory: function (path: string): void { try { if (!this.directoryExists(path)) { _fs.mkdirSync(path); @@ -417,16 +434,16 @@ var IO = (function() { } }, - directoryExists: function(path: string): boolean { + directoryExists: function (path: string): boolean { return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory(); }, - resolvePath: function(path: string): string { + resolvePath: function (path: string): string { return _path.resolve(path); }, - dirName: function(path: string): string { + dirName: function (path: string): string { return _path.dirname(path); }, - findFile: function(rootPath: string, partialFilePath): IResolvedFile { + findFile: function (rootPath: string, partialFilePath): IResolvedFile { var path = rootPath + "/" + partialFilePath; while (true) { @@ -452,24 +469,38 @@ var IO = (function() { } } }, - print: function(str) { process.stdout.write(str) }, - printLine: function(str) { process.stdout.write(str + '\n') }, + print: function (str) { + process.stdout.write(str) + }, + printLine: function (str) { + process.stdout.write(str + '\n') + }, arguments: process.argv.slice(2), stderr: { - Write: function(str) { process.stderr.write(str); }, - WriteLine: function(str) { process.stderr.write(str + '\n'); }, - Close: function() { } + Write: function (str) { + process.stderr.write(str); + }, + WriteLine: function (str) { + process.stderr.write(str + '\n'); + }, + Close: function () { + } }, stdout: { - Write: function(str) { process.stdout.write(str); }, - WriteLine: function(str) { process.stdout.write(str + '\n'); }, - Close: function() { } + Write: function (str) { + process.stdout.write(str); + }, + WriteLine: function (str) { + process.stdout.write(str + '\n'); + }, + Close: function () { + } }, - watchFile: function(filename: string, callback: (string) => void ): IFileWatcher { + watchFile: function (filename: string, callback: (string) => void): IFileWatcher { var firstRun = true; var processingChange = false; - var fileChanged: any = function(curr, prev) { + var fileChanged: any = function (curr, prev) { if (!firstRun) { if (curr.mtime < prev.mtime) { return; @@ -479,7 +510,9 @@ var IO = (function() { if (!processingChange) { processingChange = true; callback(filename); - setTimeout(function() { processingChange = false; }, 100); + setTimeout(function () { + processingChange = false; + }, 100); } } firstRun = false; @@ -489,16 +522,16 @@ var IO = (function() { fileChanged(); return { filename: filename, - close: function() { + close: function () { _fs.unwatchFile(filename, fileChanged); } }; }, - run: function(source, filename) { + run: function (source, filename) { require.main.filename = filename; require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename))); require.main._compile(source, filename); - }, + }, getExecutingFilePath: function () { return process.mainModule.filename; }, diff --git a/_infrastructure/tests/src/indexer.ts b/_infrastructure/tests/src/indexer.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/_infrastructure/tests/src/io.js b/_infrastructure/tests/src/io.js deleted file mode 100644 index 0f8b9516c8..0000000000 --- a/_infrastructure/tests/src/io.js +++ /dev/null @@ -1,475 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -var IOUtils; -(function (IOUtils) { - // Creates the directory including its parent if not already present - function createDirectoryStructure(ioHost, dirName) { - if (ioHost.directoryExists(dirName)) { - return; - } - - var parentDirectory = ioHost.dirName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(ioHost, parentDirectory); - } - ioHost.createDirectory(dirName); - } - - // Creates a file including its directory structure if not already present - function createFileAndFolderStructure(ioHost, fileName, useUTF8) { - var path = ioHost.resolvePath(fileName); - var dirName = ioHost.dirName(path); - createDirectoryStructure(ioHost, dirName); - return ioHost.createFile(path, useUTF8); - } - IOUtils.createFileAndFolderStructure = createFileAndFolderStructure; - - function throwIOError(message, error) { - var errorMessage = message; - if (error && error.message) { - errorMessage += (" " + error.message); - } - throw new Error(errorMessage); - } - IOUtils.throwIOError = throwIOError; -})(IOUtils || (IOUtils = {})); - -var IO = (function () { - // Create an IO object for use inside WindowsScriptHost hosts - // Depends on WSCript and FileSystemObject - function getWindowsScriptHostIO() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - readFile: function (path) { - try { - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; - streamObj.Charset = 'x-ansi'; - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - streamObj.Position = 0; - if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) { - streamObj.Charset = 'unicode'; - } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) { - streamObj.Charset = 'utf-8'; - } - - // Read the whole file - var str = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return str; - } catch (err) { - IOUtils.throwIOError("Error reading file \"" + path + "\".", err); - } - }, - writeFile: function (path, contents) { - var file = this.createFile(path); - file.Write(contents); - file.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - dirName: function (path) { - return fso.GetParentFolderName(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; - - while (true) { - if (fso.FileExists(path)) { - try { - var content = this.readFile(path); - return { content: content, path: path }; - } catch (err) { - //Tools.CompilerDiagnostics.debugPrint("Could not find " + path + ", trying parent"); - } - } else { - rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); - - if (rootPath == "") { - return null; - } else { - path = fso.BuildPath(rootPath, partialFilePath); - } - } - } - }, - deleteFile: function (path) { - try { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); - } - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - createFile: function (path, useUTF8) { - try { - var streamObj = getStreamObject(); - streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi'; - streamObj.Open(); - return { - Write: function (str) { - streamObj.WriteText(str, 0); - }, - WriteLine: function (str) { - streamObj.WriteText(str, 1); - }, - Close: function () { - try { - streamObj.SaveToFile(path, 2); - } catch (saveError) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError); - } finally { - if (streamObj.State != 0) { - streamObj.Close(); - } - releaseStreamObject(streamObj); - } - } - }; - } catch (creationError) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - fso.CreateFolder(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - dir: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "/" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - print: function (str) { - WScript.StdOut.Write(str); - }, - printLine: function (str) { - WScript.Echo(str); - }, - arguments: args, - stderr: WScript.StdErr, - stdout: WScript.StdOut, - watchFile: null, - run: function (source, filename) { - try { - eval(source); - } catch (e) { - IOUtils.throwIOError("Error while executing file '" + filename + "'.", e); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - quit: function (exitCode) { - if (typeof exitCode === "undefined") { exitCode = 0; } - try { - WScript.Quit(exitCode); - } catch (e) { - } - } - }; - } - ; - - // Create an IO object for use inside Node.js hosts - // Depends on 'fs' and 'path' modules - function getNodeIO() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - readFile: function (file) { - try { - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] == 0xFF) { - // utf16-be. Reading the buffer as big endian is not supported, so convert it to - // Little Endian first - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return buffer.toString("ucs2", 2); - } - break; - case 0xFF: - if (buffer[1] == 0xFE) { - // utf16-le - return buffer.toString("ucs2", 2); - } - break; - case 0xEF: - if (buffer[1] == 0xBB) { - // utf-8 - return buffer.toString("utf8", 3); - } - } - - // Default behaviour - return buffer.toString(); - } catch (e) { - IOUtils.throwIOError("Error reading file \"" + file + "\".", e); - } - }, - writeFile: _fs.writeFileSync, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - createFile: function (path, useUTF8) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null); - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, 0775); - } - } - - mkdirRecursiveSync(_path.dirname(path)); - - try { - var fd = _fs.openSync(path, 'w'); - } catch (e) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e); - } - return { - Write: function (str) { - _fs.writeSync(fd, str); - }, - WriteLine: function (str) { - _fs.writeSync(fd, str + '\r\n'); - }, - Close: function () { - _fs.closeSync(fd); - fd = null; - } - }; - }, - dir: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder, deep) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - if (deep < (options.deep || 100)) { - paths = paths.concat(filesInFolder(folder + "/" + files[i], 1)); - } - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "/" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path, 0); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - _fs.mkdirSync(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory(); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - dirName: function (path) { - return _path.dirname(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = rootPath + "/" + partialFilePath; - - while (true) { - if (_fs.existsSync(path)) { - try { - var content = this.readFile(path); - return { content: content, path: path }; - } catch (err) { - //Tools.CompilerDiagnostics.debugPrint(("Could not find " + path) + ", trying parent"); - } - } else { - var parentPath = _path.resolve(rootPath, ".."); - - if (rootPath === parentPath) { - return null; - } else { - rootPath = parentPath; - path = _path.resolve(rootPath, partialFilePath); - } - } - } - }, - print: function (str) { - process.stdout.write(str); - }, - printLine: function (str) { - process.stdout.write(str + '\n'); - }, - arguments: process.argv.slice(2), - stderr: { - Write: function (str) { - process.stderr.write(str); - }, - WriteLine: function (str) { - process.stderr.write(str + '\n'); - }, - Close: function () { - } - }, - stdout: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - }, - watchFile: function (filename, callback) { - var firstRun = true; - var processingChange = false; - - var fileChanged = function (curr, prev) { - if (!firstRun) { - if (curr.mtime < prev.mtime) { - return; - } - - _fs.unwatchFile(filename, fileChanged); - if (!processingChange) { - processingChange = true; - callback(filename); - setTimeout(function () { - processingChange = false; - }, 100); - } - } - firstRun = false; - _fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged); - }; - - fileChanged(); - return { - filename: filename, - close: function () { - _fs.unwatchFile(filename, fileChanged); - } - }; - }, - run: function (source, filename) { - require.main.filename = filename; - require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename))); - require.main._compile(source, filename); - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - quit: process.exit - }; - } - ; - - if (typeof ActiveXObject === "function") - return getWindowsScriptHostIO(); -else if (typeof require === "function") - return getNodeIO(); -else - return null; -})(); diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts new file mode 100644 index 0000000000..d1f0f952e2 --- /dev/null +++ b/_infrastructure/tests/src/printer.ts @@ -0,0 +1,111 @@ +/// +/// + +module DT { + ///////////////////////////////// + // All the common things that we pring are functions of this class + ///////////////////////////////// + export class Print { + + WIDTH = 77; + + constructor(public version: string, public typings: number, public tests: number, public tsFiles: number) { + } + + public out(s: any): Print { + process.stdout.write(s); + return this; + } + + public repeat(s: string, times: number): string { + return new Array(times + 1).join(s); + } + + public printHeader() { + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); + this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); + this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); + this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); + } + + public printSuiteHeader(title: string) { + var left = Math.floor((this.WIDTH - title.length ) / 2) - 1; + var right = Math.ceil((this.WIDTH - title.length ) / 2) - 1; + this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); + this.out(title); + this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); + } + + public printDiv() { + this.out('-----------------------------------------------------------------------------\n'); + } + + public printBoldDiv() { + this.out('=============================================================================\n'); + } + + public printErrorsHeader() { + this.out('=============================================================================\n'); + this.out(' \33[34m\33[1mErrors in files\33[0m \n'); + this.out('=============================================================================\n'); + } + + public printErrorsForFile(testResult: TestResult) { + this.out('----------------- For file:' + testResult.targetFile.formatName); + this.printBreak().out(testResult.stderr).printBreak(); + } + + public printBreak(): Print { + this.out('\n'); + return this; + } + + public clearCurrentLine(): Print { + this.out("\r\33[K"); + return this; + } + + public printSuccessCount(current: number, total: number) { + this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + + public printFailedCount(current: number, total: number) { + this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + + public printTypingsWithoutTestsMessage() { + this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); + } + + public printTotalMessage() { + this.out(' \33[36m\33[1mTotal\33[0m\n'); + } + + public printElapsedTime(time: string, s: number) { + this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); + } + + public printSuiteErrorCount(errorHeadline: string, current: number, total: number, valuesColor = '\33[31m\33[1m') { + this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); + this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + + public printTypingsWithoutTestName(file: string) { + this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); + } + + public printTypingsWithoutTest(withoutTestTypings: string[]) { + if (withoutTestTypings.length > 0) { + this.printTypingsWithoutTestsMessage(); + + this.printDiv(); + withoutTestTypings.forEach((t) => { + this.printTypingsWithoutTestName(t); + }); + } + } + } +} diff --git a/_infrastructure/tests/src/reporter/reporter.ts b/_infrastructure/tests/src/reporter/reporter.ts new file mode 100644 index 0000000000..d4556e0cc0 --- /dev/null +++ b/_infrastructure/tests/src/reporter/reporter.ts @@ -0,0 +1,36 @@ +module DT { + ///////////////////////////////// + // Test reporter interface + // for example, . and x + ///////////////////////////////// + export interface ITestReporter { + printPositiveCharacter(index: number, testResult: TestResult):void; + printNegativeCharacter(index: number, testResult: TestResult):void; + } + + ///////////////////////////////// + // Default test reporter + ///////////////////////////////// + export class DefaultTestReporter implements ITestReporter { + constructor(public print: Print) { + } + + public printPositiveCharacter(index: number, testResult: TestResult) { + this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); + + this.printBreakIfNeeded(index); + } + + public printNegativeCharacter(index: number, testResult: TestResult) { + this.print.out("x"); + + this.printBreakIfNeeded(index); + } + + private printBreakIfNeeded(index: number) { + if (index % this.print.WIDTH === 0) { + this.print.printBreak(); + } + } + } +} diff --git a/_infrastructure/tests/src/suite/suite.ts b/_infrastructure/tests/src/suite/suite.ts new file mode 100644 index 0000000000..32013cce24 --- /dev/null +++ b/_infrastructure/tests/src/suite/suite.ts @@ -0,0 +1,83 @@ +/// + +module DT { + ///////////////////////////////// + // The interface for test suite + ///////////////////////////////// + export interface ITestSuite { + testSuiteName:string; + errorHeadline:string; + filterTargetFiles(files: File[]):File[]; + + start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void):void; + + testResults:TestResult[]; + okTests:TestResult[]; + ngTests:TestResult[]; + timer:Timer; + + testReporter:ITestReporter; + printErrorCount:boolean; + } + + ///////////////////////////////// + // Base class for test suite + ///////////////////////////////// + export class TestSuiteBase implements ITestSuite { + timer: Timer = new Timer(); + testResults: TestResult[] = []; + testReporter: ITestReporter; + printErrorCount = true; + + constructor(public options: ITestRunnerOptions, public testSuiteName: string, public errorHeadline: string) { + } + + public filterTargetFiles(files: File[]): File[] { + throw new Error("please implement this method"); + } + + public start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void): void { + targetFiles = this.filterTargetFiles(targetFiles); + this.timer.start(); + var count = 0; + // exec test is async process. serialize. + var executor = () => { + var targetFile = targetFiles[count]; + if (targetFile) { + this.runTest(targetFile, (result) => { + testCallback(result, count + 1); + count++; + executor(); + }); + } else { + this.timer.end(); + this.finish(suiteCallback); + } + }; + executor(); + } + + public runTest(targetFile: File, callback: (result: TestResult) => void): void { + new Test(this, targetFile, {tscVersion: this.options.tscVersion}).run((result) => { + this.testResults.push(result); + callback(result); + }); + } + + public finish(suiteCallback: (suite: ITestSuite) => void) { + suiteCallback(this); + } + + public get okTests(): TestResult[] { + return this.testResults.filter((r) => { + return r.success; + }); + } + + public get ngTests(): TestResult[] { + return this.testResults.filter((r) => { + return !r.success + }); + } + } +} diff --git a/_infrastructure/tests/src/suite/syntax.ts b/_infrastructure/tests/src/suite/syntax.ts new file mode 100644 index 0000000000..f36c26d99b --- /dev/null +++ b/_infrastructure/tests/src/suite/syntax.ts @@ -0,0 +1,20 @@ +/// +/// + +module DT { + ///////////////////////////////// + // .d.ts syntax inspection + ///////////////////////////////// + export class SyntaxChecking extends TestSuiteBase { + + constructor(options: ITestRunnerOptions) { + super(options, "Syntax checking", "Syntax error"); + } + + public filterTargetFiles(files: File[]): File[] { + return files.filter((file) => { + return DT.endsWith(file.formatName.toUpperCase(), '.D.TS'); + }); + } + } +} diff --git a/_infrastructure/tests/src/suite/testEval.ts b/_infrastructure/tests/src/suite/testEval.ts new file mode 100644 index 0000000000..860e179431 --- /dev/null +++ b/_infrastructure/tests/src/suite/testEval.ts @@ -0,0 +1,21 @@ +/// +/// + +module DT { + ///////////////////////////////// + // Compile with *-tests.ts + ///////////////////////////////// + export class TestEval extends TestSuiteBase { + + constructor(options) { + super(options, "Typing tests", "Failed tests"); + } + + public filterTargetFiles(files: File[]): File[] { + return files.filter((file) => { + return DT.endsWith(file.formatName.toUpperCase(), '-TESTS.TS') + }); + } + } + +} diff --git a/_infrastructure/tests/src/suite/tscParams.ts b/_infrastructure/tests/src/suite/tscParams.ts new file mode 100644 index 0000000000..65491d30d3 --- /dev/null +++ b/_infrastructure/tests/src/suite/tscParams.ts @@ -0,0 +1,49 @@ +/// +/// + +module DT { + ///////////////////////////////// + // Try compile without .tscparams + // It may indicate that it is compatible with --noImplicitAny maybe... + ///////////////////////////////// + export class FindNotRequiredTscparams extends TestSuiteBase { + testReporter: ITestReporter; + printErrorCount = false; + + constructor(options: ITestRunnerOptions, private print: Print) { + super(options, "Find not required .tscparams files", "New arrival!"); + + this.testReporter = { + printPositiveCharacter: (index: number, testResult: TestResult) => { + this.print + .clearCurrentLine() + .printTypingsWithoutTestName(testResult.targetFile.formatName); + }, + printNegativeCharacter: (index: number, testResult: TestResult) => { + } + } + } + + public filterTargetFiles(files: File[]): File[] { + return files.filter(file=> IO.fileExists(file.filePathWithName + '.tscparams')); + } + + public runTest(targetFile: File, callback: (result: TestResult) => void): void { + this.print.clearCurrentLine().out(targetFile.formatName); + new Test(this, targetFile, {tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true}).run(result=> { + this.testResults.push(result); + callback(result); + }); + } + + public finish(suiteCallback: (suite: ITestSuite)=>void) { + this.print.clearCurrentLine(); + suiteCallback(this); + } + + public get ngTests(): TestResult[] { + // Do not show ng test results + return []; + } + } +} diff --git a/_infrastructure/tests/src/timer.ts b/_infrastructure/tests/src/timer.ts new file mode 100644 index 0000000000..a92d08fafa --- /dev/null +++ b/_infrastructure/tests/src/timer.ts @@ -0,0 +1,46 @@ +/// +/// + +module DT { + ///////////////////////////////// + // Timer.start starts a timer + // Timer.end stops the timer and sets asString to the pretty print value + ///////////////////////////////// + export class Timer { + startTime: number; + time = 0; + asString: string; + + public start() { + this.time = 0; + this.startTime = this.now(); + } + + public now(): number { + return Date.now(); + } + + public end() { + this.time = (this.now() - this.startTime) / 1000; + this.asString = Timer.prettyDate(this.startTime, this.now()); + } + + public static prettyDate(date1: number, date2: number): string { + var diff = ((date2 - date1) / 1000), + day_diff = Math.floor(diff / 86400); + + if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) + return; + + return (day_diff == 0 && ( + diff < 60 && (diff + " seconds") || + diff < 120 && "1 minute" || + diff < 3600 && Math.floor(diff / 60) + " minutes" || + diff < 7200 && "1 hour" || + diff < 86400 && Math.floor(diff / 3600) + " hours") || + day_diff == 1 && "Yesterday" || + day_diff < 7 && day_diff + " days" || + day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); + } + } +} diff --git a/_infrastructure/tests/src/tsc.ts b/_infrastructure/tests/src/tsc.ts new file mode 100644 index 0000000000..708f42a911 --- /dev/null +++ b/_infrastructure/tests/src/tsc.ts @@ -0,0 +1,43 @@ +/// +/// + +/// + +module DT { + export interface TscExecOptions { + tscVersion?:string; + useTscParams?:boolean; + checkNoImplicitAny?:boolean; + } + + export class Tsc { + public static run(tsfile: string, options: TscExecOptions, callback: (result: ExecResult) => void) { + options = options || {}; + options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION; + if (typeof options.checkNoImplicitAny === "undefined") { + options.checkNoImplicitAny = true; + } + if (typeof options.useTscParams === "undefined") { + options.useTscParams = true; + } + + if (!IO.fileExists(tsfile)) { + throw new Error(tsfile + " not exists"); + } + + var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; + if (!IO.fileExists(tscPath)) { + throw new Error(tscPath + ' is not exists'); + } + var command = 'node ' + tscPath + ' --module commonjs '; + if (options.useTscParams && IO.fileExists(tsfile + '.tscparams')) { + command += '@' + tsfile + '.tscparams'; + } else if (options.checkNoImplicitAny) { + command += '--noImplicitAny'; + } + Exec.exec(command, [tsfile], (execResult) => { + callback(execResult); + }); + } + } +} diff --git a/_infrastructure/tests/src/util.ts b/_infrastructure/tests/src/util.ts new file mode 100644 index 0000000000..d907fe49d2 --- /dev/null +++ b/_infrastructure/tests/src/util.ts @@ -0,0 +1,5 @@ +module DT { + export function endsWith(str: string, suffix: string) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } +} From 880e167158d26cff3984c43977b62de4ef74c743 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 27 Feb 2014 19:25:46 +0100 Subject: [PATCH 228/240] added reference parser stores as File::references[]:File added source-map-support dependency added glob dependency ditched io env wrapper for regular node fs / glob ditched exec env windows wrapper added extract util cleaned File.ts directory handling added pre-stage to test runner temporary exclude most files (for testing) --- _infrastructure/tests/runner.js | 712 +++++------------- _infrastructure/tests/runner.ts | 57 +- .../tests/src/{indexer.ts => changes.ts} | 0 _infrastructure/tests/src/file.ts | 17 +- _infrastructure/tests/src/host/exec.ts | 31 +- _infrastructure/tests/src/host/io.ts | 548 -------------- _infrastructure/tests/src/references.ts | 80 ++ _infrastructure/tests/src/suite/tscParams.ts | 12 +- _infrastructure/tests/src/timer.ts | 13 +- _infrastructure/tests/src/tsc.ts | 8 +- _infrastructure/tests/src/util.ts | 20 + 11 files changed, 363 insertions(+), 1135 deletions(-) rename _infrastructure/tests/src/{indexer.ts => changes.ts} (100%) delete mode 100644 _infrastructure/tests/src/host/io.ts create mode 100644 _infrastructure/tests/src/references.ts diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index 37aefb7e52..f73c72a395 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -21,35 +21,6 @@ var ExecResult = (function () { return ExecResult; })(); -var WindowsScriptHostExec = (function () { - function WindowsScriptHostExec() { - } - WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) { - var result = new ExecResult(); - var shell = new ActiveXObject('WScript.Shell'); - try { - var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' ')); - } catch (e) { - result.stderr = e.message; - result.exitCode = 1; - handleResult(result); - return; - } - - while (process.Status != 0) { - } - - result.exitCode = process.ExitCode; - if (!process.StdOut.AtEndOfStream) - result.stdout = process.StdOut.ReadAll(); - if (!process.StdErr.AtEndOfStream) - result.stderr = process.StdErr.ReadAll(); - - handleResult(result); - }; - return WindowsScriptHostExec; -})(); - var NodeExec = (function () { function NodeExec() { } @@ -71,492 +42,8 @@ var NodeExec = (function () { })(); var Exec = function () { - var global = Function("return this;").call(null); - if (typeof global.ActiveXObject !== "undefined") { - return new WindowsScriptHostExec(); - } else { - return new NodeExec(); - } + return new NodeExec(); }(); -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -var IOUtils; -(function (IOUtils) { - // Creates the directory including its parent if not already present - function createDirectoryStructure(ioHost, dirName) { - if (ioHost.directoryExists(dirName)) { - return; - } - - var parentDirectory = ioHost.dirName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(ioHost, parentDirectory); - } - ioHost.createDirectory(dirName); - } - - // Creates a file including its directory structure if not already present - function createFileAndFolderStructure(ioHost, fileName, useUTF8) { - var path = ioHost.resolvePath(fileName); - var dirName = ioHost.dirName(path); - createDirectoryStructure(ioHost, dirName); - return ioHost.createFile(path, useUTF8); - } - IOUtils.createFileAndFolderStructure = createFileAndFolderStructure; - - function throwIOError(message, error) { - var errorMessage = message; - if (error && error.message) { - errorMessage += (" " + error.message); - } - throw new Error(errorMessage); - } - IOUtils.throwIOError = throwIOError; -})(IOUtils || (IOUtils = {})); - - - -var IO = (function () { - // Create an IO object for use inside WindowsScriptHost hosts - // Depends on WSCript and FileSystemObject - function getWindowsScriptHostIO() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var streamObjectPool = []; - - function getStreamObject() { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - readFile: function (path) { - try { - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; // Text data - streamObj.Charset = 'x-ansi'; // Assume we are reading ansi text - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); - streamObj.Position = 0; // Position has to be at 0 before changing the encoding - if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) { - streamObj.Charset = 'unicode'; - } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) { - streamObj.Charset = 'utf-8'; - } - - // Read the whole file - var str = streamObj.ReadText(-1); - streamObj.Close(); - releaseStreamObject(streamObj); - return str; - } catch (err) { - IOUtils.throwIOError("Error reading file \"" + path + "\".", err); - } - }, - writeFile: function (path, contents) { - var file = this.createFile(path); - file.Write(contents); - file.Close(); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - dirName: function (path) { - return fso.GetParentFolderName(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; - - while (true) { - if (fso.FileExists(path)) { - try { - var content = this.readFile(path); - return { content: content, path: path }; - } catch (err) { - //Tools.CompilerDiagnostics.debugPrint("Could not find " + path + ", trying parent"); - } - } else { - rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); - - if (rootPath == "") { - return null; - } else { - path = fso.BuildPath(rootPath, partialFilePath); - } - } - } - }, - deleteFile: function (path) { - try { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); // true: delete read-only files - } - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - createFile: function (path, useUTF8) { - try { - var streamObj = getStreamObject(); - streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi'; - streamObj.Open(); - return { - Write: function (str) { - streamObj.WriteText(str, 0); - }, - WriteLine: function (str) { - streamObj.WriteText(str, 1); - }, - Close: function () { - try { - streamObj.SaveToFile(path, 2); - } catch (saveError) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError); - } finally { - if (streamObj.State != 0) { - streamObj.Close(); - } - releaseStreamObject(streamObj); - } - } - }; - } catch (creationError) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError); - } - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - fso.CreateFolder(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - dir: function (path, spec, options) { - options = options || {}; - function filesInFolder(folder, root) { - var paths = []; - var fc; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "/" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - print: function (str) { - WScript.StdOut.Write(str); - }, - printLine: function (str) { - WScript.Echo(str); - }, - arguments: args, - stderr: WScript.StdErr, - stdout: WScript.StdOut, - watchFile: null, - run: function (source, filename) { - try { - eval(source); - } catch (e) { - IOUtils.throwIOError("Error while executing file '" + filename + "'.", e); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - quit: function (exitCode) { - if (typeof exitCode === "undefined") { exitCode = 0; } - try { - WScript.Quit(exitCode); - } catch (e) { - } - } - }; - } - ; - - // Create an IO object for use inside Node.js hosts - // Depends on 'fs' and 'path' modules - function getNodeIO() { - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - readFile: function (file) { - try { - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] == 0xFF) { - // utf16-be. Reading the buffer as big endian is not supported, so convert it to - // Little Endian first - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return buffer.toString("ucs2", 2); - } - break; - case 0xFF: - if (buffer[1] == 0xFE) { - // utf16-le - return buffer.toString("ucs2", 2); - } - break; - case 0xEF: - if (buffer[1] == 0xBB) { - // utf-8 - return buffer.toString("utf8", 3); - } - } - - // Default behaviour - return buffer.toString(); - } catch (e) { - IOUtils.throwIOError("Error reading file \"" + file + "\".", e); - } - }, - writeFile: _fs.writeFileSync, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - createFile: function (path, useUTF8) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null); - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, parseInt('0775', 8)); - } - } - - mkdirRecursiveSync(_path.dirname(path)); - - try { - var fd = _fs.openSync(path, 'w'); - } catch (e) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e); - } - return { - Write: function (str) { - _fs.writeSync(fd, str); - }, - WriteLine: function (str) { - _fs.writeSync(fd, str + '\r\n'); - }, - Close: function () { - _fs.closeSync(fd); - fd = null; - } - }; - }, - dir: function dir(path, spec, options) { - options = options || {}; - - function filesInFolder(folder, deep) { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - if (deep < (options.deep || 100)) { - paths = paths.concat(filesInFolder(folder + "/" + files[i], 1)); - } - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "/" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path, 0); - }, - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - _fs.mkdirSync(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory(); - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - dirName: function (path) { - return _path.dirname(path); - }, - findFile: function (rootPath, partialFilePath) { - var path = rootPath + "/" + partialFilePath; - - while (true) { - if (_fs.existsSync(path)) { - try { - var content = this.readFile(path); - return { content: content, path: path }; - } catch (err) { - //Tools.CompilerDiagnostics.debugPrint(("Could not find " + path) + ", trying parent"); - } - } else { - var parentPath = _path.resolve(rootPath, ".."); - - // Node will just continue to repeat the root path, rather than return null - if (rootPath === parentPath) { - return null; - } else { - rootPath = parentPath; - path = _path.resolve(rootPath, partialFilePath); - } - } - } - }, - print: function (str) { - process.stdout.write(str); - }, - printLine: function (str) { - process.stdout.write(str + '\n'); - }, - arguments: process.argv.slice(2), - stderr: { - Write: function (str) { - process.stderr.write(str); - }, - WriteLine: function (str) { - process.stderr.write(str + '\n'); - }, - Close: function () { - } - }, - stdout: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - }, - watchFile: function (filename, callback) { - var firstRun = true; - var processingChange = false; - - var fileChanged = function (curr, prev) { - if (!firstRun) { - if (curr.mtime < prev.mtime) { - return; - } - - _fs.unwatchFile(filename, fileChanged); - if (!processingChange) { - processingChange = true; - callback(filename); - setTimeout(function () { - processingChange = false; - }, 100); - } - } - firstRun = false; - _fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged); - }; - - fileChanged(); - return { - filename: filename, - close: function () { - _fs.unwatchFile(filename, fileChanged); - } - }; - }, - run: function (source, filename) { - require.main.filename = filename; - require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename))); - require.main._compile(source, filename); - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - quit: process.exit - }; - } - ; - - if (typeof ActiveXObject === "function") - return getWindowsScriptHostIO(); - else if (typeof require === "function") - return getNodeIO(); - else - return null; -})(); var DT; (function (DT) { var path = require('path'); @@ -569,20 +56,31 @@ var DT; function File(baseDir, filePathWithName) { this.baseDir = baseDir; this.filePathWithName = filePathWithName; - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - this.dir = dirName.split('/')[0]; - this.file = path.basename(this.filePathWithName, '.ts'); + this.references = []; this.ext = path.extname(this.filePathWithName); + this.file = path.basename(this.filePathWithName, this.ext); + this.dir = path.dirname(this.filePathWithName); } Object.defineProperty(File.prototype, "formatName", { // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' get: function () { - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - return this.dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + this.file + this.ext; + return path.join(this.dir, this.file + this.ext); }, enumerable: true, configurable: true }); + + Object.defineProperty(File.prototype, "fullPath", { + get: function () { + return path.join(this.baseDir, this.dir, this.file + this.ext); + }, + enumerable: true, + configurable: true + }); + + File.prototype.toString = function () { + return '[File ' + this.filePathWithName + ']'; + }; return File; })(); DT.File = File; @@ -592,6 +90,8 @@ var DT; /// var DT; (function (DT) { + var fs = require('fs'); + var Tsc = (function () { function Tsc() { } @@ -605,16 +105,16 @@ var DT; options.useTscParams = true; } - if (!IO.fileExists(tsfile)) { + if (!fs.existsSync(tsfile)) { throw new Error(tsfile + " not exists"); } var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!IO.fileExists(tscPath)) { + if (!fs.existsSync(tscPath)) { throw new Error(tscPath + ' is not exists'); } var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && IO.fileExists(tsfile + '.tscparams')) { + if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { command += '@' + tsfile + '.tscparams'; } else if (options.checkNoImplicitAny) { command += '--noImplicitAny'; @@ -654,10 +154,12 @@ var DT; }; Timer.prettyDate = function (date1, date2) { - var diff = ((date2 - date1) / 1000), day_diff = Math.floor(diff / 86400); + var diff = ((date2 - date1) / 1000); + var day_diff = Math.floor(diff / 86400); - if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) - return; + if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) { + return null; + } return (day_diff == 0 && (diff < 60 && (diff + " seconds") || diff < 120 && "1 minute" || diff < 3600 && Math.floor(diff / 60) + " minutes" || diff < 7200 && "1 hour" || diff < 86400 && Math.floor(diff / 3600) + " hours") || day_diff == 1 && "Yesterday" || day_diff < 7 && day_diff + " days" || day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); }; @@ -667,10 +169,107 @@ var DT; })(DT || (DT = {})); var DT; (function (DT) { + var referenceTagExp = //g; + function endsWith(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; } DT.endsWith = endsWith; + + function extractReferenceTags(source) { + var ret = []; + var match; + + if (!referenceTagExp.global) { + throw new Error('referenceTagExp RegExp must have global flag'); + } + referenceTagExp.lastIndex = 0; + + while ((match = referenceTagExp.exec(source))) { + if (match.length > 0 && match[1].length > 0) { + ret.push(match[1]); + } + } + return ret; + } + DT.extractReferenceTags = extractReferenceTags; +})(DT || (DT = {})); +/// +/// +/// +var DT; +(function (DT) { + var fs = require('fs'); + var path = require('path'); + + var ReferenceIndex = (function () { + function ReferenceIndex(options) { + this.options = options; + } + ReferenceIndex.prototype.collectReferences = function (files, callback) { + var _this = this; + this.fileMap = Object.create(null); + files.forEach(function (file) { + _this.fileMap[file.fullPath] = file; + }); + this.loadReferences(files, function () { + callback(); + }); + }; + + ReferenceIndex.prototype.loadReferences = function (files, callback) { + var _this = this; + var queue = files.slice(0); + var active = []; + var max = 50; + var next = function () { + if (queue.length === 0 && active.length === 0) { + callback(); + return; + } + + while (queue.length > 0 && active.length < max) { + var file = queue.pop(); + active.push(file); + _this.parseFile(file, function (file) { + active.splice(active.indexOf(file), 1); + next(); + }); + } + }; + process.nextTick(next); + }; + + ReferenceIndex.prototype.parseFile = function (file, callback) { + var _this = this; + fs.readFile(file.filePathWithName, { + encoding: 'utf8', + flag: 'r' + }, function (err, content) { + if (err) { + throw err; + } + + // console.log('----'); + // console.log(file.filePathWithName); + file.references = DT.extractReferenceTags(content).map(function (ref) { + return path.resolve(path.dirname(file.fullPath), ref); + }).reduce(function (memo, ref) { + if (ref in _this.fileMap) { + memo.push(_this.fileMap[ref]); + } else { + console.log('not mapped? -> ' + ref); + } + return memo; + }, []); + + // console.log(file.references); + callback(file); + }); + }; + return ReferenceIndex; + })(); + DT.ReferenceIndex = ReferenceIndex; })(DT || (DT = {})); /// /// @@ -951,6 +550,8 @@ var DT; /// var DT; (function (DT) { + var fs = require('fs'); + ///////////////////////////////// // Try compile without .tscparams // It may indicate that it is compatible with --noImplicitAny maybe... @@ -973,14 +574,18 @@ var DT; } FindNotRequiredTscparams.prototype.filterTargetFiles = function (files) { return files.filter(function (file) { - return IO.fileExists(file.filePathWithName + '.tscparams'); + return fs.existsSync(file.filePathWithName + '.tscparams'); }); }; FindNotRequiredTscparams.prototype.runTest = function (targetFile, callback) { var _this = this; this.print.clearCurrentLine().out(targetFile.formatName); - new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true }).run(function (result) { + new DT.Test(this, targetFile, { + tscVersion: this.options.tscVersion, + useTscParams: false, + checkNoImplicitAny: true + }).run(function (result) { _this.testResults.push(result); callback(result); }); @@ -1005,11 +610,11 @@ var DT; })(DT || (DT = {})); /// /// -/// /// /// /// /// +/// /// /// /// @@ -1018,8 +623,11 @@ var DT; /// var DT; (function (DT) { + require('source-map-support'); + var fs = require('fs'); var path = require('path'); + var glob = require('glob'); DT.DEFAULT_TSC_VERSION = "0.9.1.1"; @@ -1075,16 +683,32 @@ var DT; this.suites = []; this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - var filesName = IO.dir(dtPath, /.\.ts/g, { recursive: true }).sort(); + // TOD0 remove this after dev! + var testNames = [ + 'async/', + 'jquery/jquery.d', + 'angularjs/angular.d', + 'pixi/' + ]; + if (process.env.TRAVIS) { + testNames = null; + } + // should be async // only includes .d.ts or -tests.ts or -test.ts or .ts + var filesName = glob.sync('**/*.ts', { cwd: dtPath }); this.files = filesName.filter(function (fileName) { - return fileName.indexOf('../_infrastructure') < 0; + return fileName.indexOf('_infrastructure') < 0; }).filter(function (fileName) { - return fileName.indexOf('../node_modules') < 0; + return fileName.indexOf('node_modules/') < 0; }).filter(function (fileName) { - return !DT.endsWith(fileName, ".tscparams"); - }).map(function (fileName) { + // TOD0 remove this after dev! + return !testNames || testNames.some(function (pattern) { + return fileName.indexOf(pattern) > -1; + }); + }).filter(function (fileName) { + return /^[a-z]/i.test(fileName); + }).sort().map(function (fileName) { return new DT.File(dtPath, fileName); }); } @@ -1097,6 +721,19 @@ var DT; this.timer = new DT.Timer(); this.timer.start(); + var index = new DT.ReferenceIndex(this.options); + index.collectReferences(this.files, function () { + _this.files.forEach(function (file) { + console.log(file.filePathWithName); + file.references.forEach(function (file) { + console.log(' - %s', file.filePathWithName); + }); + }); + _this.runTests(); + }); + }; + TestRunner.prototype.runTests = function () { + var _this = this; var syntaxChecking = new DT.SyntaxChecking(this.options); var testEval = new DT.TestEval(this.options); if (!this.options.findNotRequiredTscparams) { @@ -1213,7 +850,7 @@ var DT; })(); DT.TestRunner = TestRunner; - var dtPath = __dirname + '/../..'; + var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); var findNotRequiredTscparams = process.argv.some(function (arg) { return arg == "--try-without-tscparams"; }); @@ -1223,6 +860,13 @@ var DT; tscVersion = process.argv[tscVersionIndex + 1]; } + console.log('--'); + console.log(' dtPath %s', dtPath); + console.log(' tscVersion %s', tscVersion); + console.log(' findNotRequiredTscparams %s', findNotRequiredTscparams); + console.log('--'); + console.log(''); + var runner = new TestRunner(dtPath, { tscVersion: tscVersion, findNotRequiredTscparams: findNotRequiredTscparams diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 86a4c2caa3..bf05025266 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -1,12 +1,12 @@ /// /// -/// /// /// /// /// +/// /// /// @@ -17,8 +17,11 @@ /// module DT { + require('source-map-support'); + var fs = require('fs'); var path = require('path'); + var glob = require('glob'); export var DEFAULT_TSC_VERSION = "0.9.1.1"; @@ -74,18 +77,38 @@ module DT { constructor(dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) { this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - var filesName = IO.dir(dtPath, /.\.ts/g, { recursive: true }).sort(); + // TOD0 remove this after dev! + var testNames = [ + 'async/', + 'jquery/jquery.d', + 'angularjs/angular.d', + 'pixi/' + ]; + if (process.env.TRAVIS) { + testNames = null; + } + + // should be async // only includes .d.ts or -tests.ts or -test.ts or .ts + var filesName = glob.sync('**/*.ts', { cwd: dtPath }); this.files = filesName .filter((fileName) => { - return fileName.indexOf('../_infrastructure') < 0; + return fileName.indexOf('_infrastructure') < 0; }) .filter((fileName) => { - return fileName.indexOf('../node_modules') < 0; + return fileName.indexOf('node_modules/') < 0; }) .filter((fileName) => { - return !DT.endsWith(fileName, ".tscparams"); - }).map((fileName) => { + // TOD0 remove this after dev! + return !testNames || testNames.some((pattern) => { + return fileName.indexOf(pattern) > -1; + }); + }) + .filter((fileName) => { + return /^[a-z]/i.test(fileName); + }) + .sort() + .map((fileName) => { return new File(dtPath, fileName); }); } @@ -98,6 +121,19 @@ module DT { this.timer = new Timer(); this.timer.start(); + var index = new ReferenceIndex(this.options); + index.collectReferences(this.files, () => { + this.files.forEach((file) => { + console.log(file.filePathWithName); + file.references.forEach((file) => { + console.log(' - %s', file.filePathWithName); + }); + }); + this.runTests(); + }); + } + public runTests() { + var syntaxChecking = new SyntaxChecking(this.options); var testEval = new TestEval(this.options); if (!this.options.findNotRequiredTscparams) { @@ -221,7 +257,7 @@ module DT { } } - var dtPath = __dirname + '/../..'; + var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); var findNotRequiredTscparams = process.argv.some(arg => arg == "--try-without-tscparams"); var tscVersionIndex = process.argv.indexOf("--tsc-version"); var tscVersion = DEFAULT_TSC_VERSION; @@ -229,6 +265,13 @@ module DT { tscVersion = process.argv[tscVersionIndex + 1]; } + console.log('--'); + console.log(' dtPath %s', dtPath); + console.log(' tscVersion %s', tscVersion); + console.log(' findNotRequiredTscparams %s', findNotRequiredTscparams); + console.log('--'); + console.log(''); + var runner = new TestRunner(dtPath, { tscVersion: tscVersion, findNotRequiredTscparams: findNotRequiredTscparams diff --git a/_infrastructure/tests/src/indexer.ts b/_infrastructure/tests/src/changes.ts similarity index 100% rename from _infrastructure/tests/src/indexer.ts rename to _infrastructure/tests/src/changes.ts diff --git a/_infrastructure/tests/src/file.ts b/_infrastructure/tests/src/file.ts index f349a09da6..c1a8d1f517 100644 --- a/_infrastructure/tests/src/file.ts +++ b/_infrastructure/tests/src/file.ts @@ -9,18 +9,25 @@ module DT { dir: string; file: string; ext: string; + references: File[] = []; constructor(public baseDir: string, public filePathWithName: string) { - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - this.dir = dirName.split('/')[0]; - this.file = path.basename(this.filePathWithName, '.ts'); this.ext = path.extname(this.filePathWithName); + this.file = path.basename(this.filePathWithName, this.ext); + this.dir = path.dirname(this.filePathWithName); } // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' public get formatName(): string { - var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/'); - return this.dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + this.file + this.ext; + return path.join(this.dir, this.file + this.ext); + } + + public get fullPath(): string { + return path.join(this.baseDir, this.dir, this.file + this.ext); + } + + toString() { + return '[File ' + this.filePathWithName + ']'; } } } diff --git a/_infrastructure/tests/src/host/exec.ts b/_infrastructure/tests/src/host/exec.ts index 2bddb0043c..9ff896c3f8 100644 --- a/_infrastructure/tests/src/host/exec.ts +++ b/_infrastructure/tests/src/host/exec.ts @@ -24,30 +24,6 @@ class ExecResult { public exitCode: number; } -class WindowsScriptHostExec implements IExec { - public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void): void { - var result = new ExecResult(); - var shell = new ActiveXObject('WScript.Shell'); - try { - var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' ')); - } catch (e) { - result.stderr = e.message; - result.exitCode = 1 - handleResult(result); - return; - } - // Wait for it to finish running - while (process.Status != 0) { /* todo: sleep? */ - } - - result.exitCode = process.ExitCode; - if (!process.StdOut.AtEndOfStream) result.stdout = process.StdOut.ReadAll(); - if (!process.StdErr.AtEndOfStream) result.stderr = process.StdErr.ReadAll(); - - handleResult(result); - } -} - class NodeExec implements IExec { public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void): void { var nodeExec = require('child_process').exec; @@ -66,10 +42,5 @@ class NodeExec implements IExec { } var Exec: IExec = function (): IExec { - var global = Function("return this;").call(null); - if (typeof global.ActiveXObject !== "undefined") { - return new WindowsScriptHostExec(); - } else { - return new NodeExec(); - } + return new NodeExec(); }(); diff --git a/_infrastructure/tests/src/host/io.ts b/_infrastructure/tests/src/host/io.ts deleted file mode 100644 index b308ef13f6..0000000000 --- a/_infrastructure/tests/src/host/io.ts +++ /dev/null @@ -1,548 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -interface IResolvedFile { - content: string; - path: string; -} - -interface IFileWatcher { - close(): void; -} - -interface IIO { - readFile(path: string): string; - writeFile(path: string, contents: string): void; - createFile(path: string, useUTF8?: boolean): ITextWriter; - deleteFile(path: string): void; - dir(path: string, re?: RegExp, options?: { recursive?: boolean; deep?: number; - }): string[]; - fileExists(path: string): boolean; - directoryExists(path: string): boolean; - createDirectory(path: string): void; - resolvePath(path: string): string; - dirName(path: string): string; - findFile(rootPath: string, partialFilePath: string): IResolvedFile; - print(str: string): void; - printLine(str: string): void; - arguments: string[]; - stderr: ITextWriter; - stdout: ITextWriter; - watchFile(filename: string, callback: (string) => void): IFileWatcher; - run(source: string, filename: string): void; - getExecutingFilePath(): string; - quit(exitCode?: number); -} - -module IOUtils { - // Creates the directory including its parent if not already present - function createDirectoryStructure(ioHost: IIO, dirName: string) { - if (ioHost.directoryExists(dirName)) { - return; - } - - var parentDirectory = ioHost.dirName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(ioHost, parentDirectory); - } - ioHost.createDirectory(dirName); - } - - // Creates a file including its directory structure if not already present - export function createFileAndFolderStructure(ioHost: IIO, fileName: string, useUTF8?: boolean) { - var path = ioHost.resolvePath(fileName); - var dirName = ioHost.dirName(path); - createDirectoryStructure(ioHost, dirName); - return ioHost.createFile(path, useUTF8); - } - - export function throwIOError(message: string, error: Error) { - var errorMessage = message; - if (error && error.message) { - errorMessage += (" " + error.message); - } - throw new Error(errorMessage); - } -} - -// Declare dependencies needed for all supported hosts -declare class Enumerator { - public atEnd(): boolean; - - public moveNext(); - - public item(): any; - - constructor(o: any); -} - -// Missing in node definitions, but called in code below. -interface NodeProcess { - mainModule: { - filename: string; - } -} - -var IO = (function () { - - // Create an IO object for use inside WindowsScriptHost hosts - // Depends on WSCript and FileSystemObject - function getWindowsScriptHostIO(): IIO { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var streamObjectPool = []; - - function getStreamObject(): any { - if (streamObjectPool.length > 0) { - return streamObjectPool.pop(); - } else { - return new ActiveXObject("ADODB.Stream"); - } - } - - function releaseStreamObject(obj: any) { - streamObjectPool.push(obj); - } - - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - return { - readFile: function (path) { - try { - var streamObj = getStreamObject(); - streamObj.Open(); - streamObj.Type = 2; // Text data - streamObj.Charset = 'x-ansi'; // Assume we are reading ansi text - streamObj.LoadFromFile(path); - var bomChar = streamObj.ReadText(2); // Read the BOM char - streamObj.Position = 0; // Position has to be at 0 before changing the encoding - if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) - || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) { - streamObj.Charset = 'unicode'; - } else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) { - streamObj.Charset = 'utf-8'; - } - - // Read the whole file - var str = streamObj.ReadText(-1 /* read from the current position to EOS */); - streamObj.Close(); - releaseStreamObject(streamObj); - return str; - } - catch (err) { - IOUtils.throwIOError("Error reading file \"" + path + "\".", err); - } - }, - - writeFile: function (path, contents) { - var file = this.createFile(path); - file.Write(contents); - file.Close(); - }, - - fileExists: function (path: string): boolean { - return fso.FileExists(path); - }, - - resolvePath: function (path: string): string { - return fso.GetAbsolutePathName(path); - }, - - dirName: function (path: string): string { - return fso.GetParentFolderName(path); - }, - - findFile: function (rootPath: string, partialFilePath: string): IResolvedFile { - var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath; - - while (true) { - if (fso.FileExists(path)) { - try { - var content = this.readFile(path); - return { content: content, path: path }; - } - catch (err) { - //Tools.CompilerDiagnostics.debugPrint("Could not find " + path + ", trying parent"); - } - } - else { - rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath)); - - if (rootPath == "") { - return null; - } - else { - path = fso.BuildPath(rootPath, partialFilePath); - } - } - } - }, - - deleteFile: function (path: string): void { - try { - if (fso.FileExists(path)) { - fso.DeleteFile(path, true); // true: delete read-only files - } - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - - createFile: function (path, useUTF8?) { - try { - var streamObj = getStreamObject(); - streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi'; - streamObj.Open(); - return { - Write: function (str) { - streamObj.WriteText(str, 0); - }, - WriteLine: function (str) { - streamObj.WriteText(str, 1); - }, - Close: function () { - try { - streamObj.SaveToFile(path, 2); - } catch (saveError) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError); - } - finally { - if (streamObj.State != 0 /*adStateClosed*/) { - streamObj.Close(); - } - releaseStreamObject(streamObj); - } - } - }; - } catch (creationError) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError); - } - }, - - directoryExists: function (path) { - return fso.FolderExists(path); - }, - - createDirectory: function (path) { - try { - if (!this.directoryExists(path)) { - fso.CreateFolder(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - - dir: function (path, spec?, options?) { - options = options || <{ recursive?: boolean; deep?: number; - }>{}; - function filesInFolder(folder, root): string[] { - var paths = []; - var fc: Enumerator; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "/" + fc.item().Name); - } - } - - return paths; - } - - var folder = fso.GetFolder(path); - var paths = []; - - return filesInFolder(folder, path); - }, - - print: function (str) { - WScript.StdOut.Write(str); - }, - - printLine: function (str) { - WScript.Echo(str); - }, - - arguments: args, - stderr: WScript.StdErr, - stdout: WScript.StdOut, - watchFile: null, - run: function (source, filename) { - try { - eval(source); - } catch (e) { - IOUtils.throwIOError("Error while executing file '" + filename + "'.", e); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - quit: function (exitCode: number = 0) { - try { - WScript.Quit(exitCode); - } catch (e) { - } - } - } - - }; - - // Create an IO object for use inside Node.js hosts - // Depends on 'fs' and 'path' modules - function getNodeIO(): IIO { - - var _fs = require('fs'); - var _path = require('path'); - var _module = require('module'); - - return { - readFile: function (file) { - try { - var buffer = _fs.readFileSync(file); - switch (buffer[0]) { - case 0xFE: - if (buffer[1] == 0xFF) { - // utf16-be. Reading the buffer as big endian is not supported, so convert it to - // Little Endian first - var i = 0; - while ((i + 1) < buffer.length) { - var temp = buffer[i] - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - i += 2; - } - return buffer.toString("ucs2", 2); - } - break; - case 0xFF: - if (buffer[1] == 0xFE) { - // utf16-le - return buffer.toString("ucs2", 2); - } - break; - case 0xEF: - if (buffer[1] == 0xBB) { - // utf-8 - return buffer.toString("utf8", 3); - } - } - // Default behaviour - return buffer.toString(); - } catch (e) { - IOUtils.throwIOError("Error reading file \"" + file + "\".", e); - } - }, - writeFile: <(path: string, contents: string) => void >_fs.writeFileSync, - deleteFile: function (path) { - try { - _fs.unlinkSync(path); - } catch (e) { - IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e); - } - }, - fileExists: function (path): boolean { - return _fs.existsSync(path); - }, - createFile: function (path, useUTF8?) { - function mkdirRecursiveSync(path) { - var stats = _fs.statSync(path); - if (stats.isFile()) { - IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null); - } else if (stats.isDirectory()) { - return; - } else { - mkdirRecursiveSync(_path.dirname(path)); - _fs.mkdirSync(path, parseInt('0775', 8)); - } - } - - mkdirRecursiveSync(_path.dirname(path)); - - try { - var fd = _fs.openSync(path, 'w'); - } catch (e) { - IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e); - } - return { - Write: function (str) { - _fs.writeSync(fd, str); - }, - WriteLine: function (str) { - _fs.writeSync(fd, str + '\r\n'); - }, - Close: function () { - _fs.closeSync(fd); - fd = null; - } - }; - }, - dir: function dir(path, spec?, options?) { - options = options || <{ recursive?: boolean; deep?: number; - }>{}; - - function filesInFolder(folder: string, deep?: number): string[] { - var paths = []; - - var files = _fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = _fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - if (deep < (options.deep || 100)) { - paths = paths.concat(filesInFolder(folder + "/" + files[i], 1)); - } - } else if (stat.isFile() && (!spec || files[i].match(spec))) { - paths.push(folder + "/" + files[i]); - } - } - - return paths; - } - - return filesInFolder(path, 0); - }, - createDirectory: function (path: string): void { - try { - if (!this.directoryExists(path)) { - _fs.mkdirSync(path); - } - } catch (e) { - IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e); - } - }, - - directoryExists: function (path: string): boolean { - return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory(); - }, - resolvePath: function (path: string): string { - return _path.resolve(path); - }, - dirName: function (path: string): string { - return _path.dirname(path); - }, - findFile: function (rootPath: string, partialFilePath): IResolvedFile { - var path = rootPath + "/" + partialFilePath; - - while (true) { - if (_fs.existsSync(path)) { - try { - var content = this.readFile(path); - return { content: content, path: path }; - } catch (err) { - //Tools.CompilerDiagnostics.debugPrint(("Could not find " + path) + ", trying parent"); - } - } - else { - var parentPath = _path.resolve(rootPath, ".."); - - // Node will just continue to repeat the root path, rather than return null - if (rootPath === parentPath) { - return null; - } - else { - rootPath = parentPath; - path = _path.resolve(rootPath, partialFilePath); - } - } - } - }, - print: function (str) { - process.stdout.write(str) - }, - printLine: function (str) { - process.stdout.write(str + '\n') - }, - arguments: process.argv.slice(2), - stderr: { - Write: function (str) { - process.stderr.write(str); - }, - WriteLine: function (str) { - process.stderr.write(str + '\n'); - }, - Close: function () { - } - }, - stdout: { - Write: function (str) { - process.stdout.write(str); - }, - WriteLine: function (str) { - process.stdout.write(str + '\n'); - }, - Close: function () { - } - }, - watchFile: function (filename: string, callback: (string) => void): IFileWatcher { - var firstRun = true; - var processingChange = false; - - var fileChanged: any = function (curr, prev) { - if (!firstRun) { - if (curr.mtime < prev.mtime) { - return; - } - - _fs.unwatchFile(filename, fileChanged); - if (!processingChange) { - processingChange = true; - callback(filename); - setTimeout(function () { - processingChange = false; - }, 100); - } - } - firstRun = false; - _fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged); - }; - - fileChanged(); - return { - filename: filename, - close: function () { - _fs.unwatchFile(filename, fileChanged); - } - }; - }, - run: function (source, filename) { - require.main.filename = filename; - require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename))); - require.main._compile(source, filename); - }, - getExecutingFilePath: function () { - return process.mainModule.filename; - }, - quit: process.exit - } - }; - - if (typeof ActiveXObject === "function") - return getWindowsScriptHostIO(); - else if (typeof require === "function") - return getNodeIO(); - else - return null; // Unsupported host -})(); diff --git a/_infrastructure/tests/src/references.ts b/_infrastructure/tests/src/references.ts new file mode 100644 index 0000000000..c98f947c38 --- /dev/null +++ b/_infrastructure/tests/src/references.ts @@ -0,0 +1,80 @@ +/// +/// + +/// + +module DT { + var fs = require('fs'); + var path = require('path'); + + export class ReferenceIndex { + + fileMap: {[path:string]:File}; + + constructor(public options: ITestRunnerOptions) { + + } + + collectReferences(files: File[], callback: () => void): void { + this.fileMap = Object.create(null); + files.forEach((file) => { + this.fileMap[file.fullPath] = file; + }); + this.loadReferences(files, () => { + callback(); + }); + } + + private loadReferences(files: File[], callback: () => void): void { + var queue = files.slice(0); + var active = []; + var max = 50; + var next = () => { + if (queue.length === 0 && active.length === 0) { + callback(); + return; + } + // queue paralel + while (queue.length > 0 && active.length < max) { + var file = queue.pop(); + active.push(file); + this.parseFile(file, (file) => { + active.splice(active.indexOf(file), 1); + next(); + }); + } + }; + process.nextTick(next); + } + + private parseFile(file: File, callback: (file: File) => void): void { + fs.readFile(file.filePathWithName, { + encoding: 'utf8', + flag: 'r' + }, (err, content) => { + if (err) { + // just blow up? + throw err; + } + // console.log('----'); + // console.log(file.filePathWithName); + + file.references = extractReferenceTags(content).map((ref: string) => { + return path.resolve(path.dirname(file.fullPath), ref); + }).reduce((memo: File[], ref: string) => { + if (ref in this.fileMap) { + memo.push(this.fileMap[ref]); + } + else { + console.log('not mapped? -> ' + ref); + } + return memo; + }, []); + + // console.log(file.references); + + callback(file); + }); + } + } +} diff --git a/_infrastructure/tests/src/suite/tscParams.ts b/_infrastructure/tests/src/suite/tscParams.ts index 65491d30d3..510e15ce77 100644 --- a/_infrastructure/tests/src/suite/tscParams.ts +++ b/_infrastructure/tests/src/suite/tscParams.ts @@ -2,6 +2,8 @@ /// module DT { + var fs = require('fs'); + ///////////////////////////////// // Try compile without .tscparams // It may indicate that it is compatible with --noImplicitAny maybe... @@ -25,12 +27,18 @@ module DT { } public filterTargetFiles(files: File[]): File[] { - return files.filter(file=> IO.fileExists(file.filePathWithName + '.tscparams')); + return files.filter((file) => { + return fs.existsSync(file.filePathWithName + '.tscparams'); + }); } public runTest(targetFile: File, callback: (result: TestResult) => void): void { this.print.clearCurrentLine().out(targetFile.formatName); - new Test(this, targetFile, {tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true}).run(result=> { + new Test(this, targetFile, { + tscVersion: this.options.tscVersion, + useTscParams: false, + checkNoImplicitAny: true + }).run(result=> { this.testResults.push(result); callback(result); }); diff --git a/_infrastructure/tests/src/timer.ts b/_infrastructure/tests/src/timer.ts index a92d08fafa..e03a941668 100644 --- a/_infrastructure/tests/src/timer.ts +++ b/_infrastructure/tests/src/timer.ts @@ -26,13 +26,14 @@ module DT { } public static prettyDate(date1: number, date2: number): string { - var diff = ((date2 - date1) / 1000), - day_diff = Math.floor(diff / 86400); + var diff = ((date2 - date1) / 1000); + var day_diff = Math.floor(diff / 86400); - if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) - return; + if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) { + return null; + } - return (day_diff == 0 && ( + return ( (day_diff == 0 && ( diff < 60 && (diff + " seconds") || diff < 120 && "1 minute" || diff < 3600 && Math.floor(diff / 60) + " minutes" || @@ -40,7 +41,7 @@ module DT { diff < 86400 && Math.floor(diff / 3600) + " hours") || day_diff == 1 && "Yesterday" || day_diff < 7 && day_diff + " days" || - day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); + day_diff < 31 && Math.ceil(day_diff / 7) + " weeks")); } } } diff --git a/_infrastructure/tests/src/tsc.ts b/_infrastructure/tests/src/tsc.ts index 708f42a911..5a2c803c80 100644 --- a/_infrastructure/tests/src/tsc.ts +++ b/_infrastructure/tests/src/tsc.ts @@ -4,6 +4,8 @@ /// module DT { + var fs = require('fs'); + export interface TscExecOptions { tscVersion?:string; useTscParams?:boolean; @@ -21,16 +23,16 @@ module DT { options.useTscParams = true; } - if (!IO.fileExists(tsfile)) { + if (!fs.existsSync(tsfile)) { throw new Error(tsfile + " not exists"); } var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!IO.fileExists(tscPath)) { + if (!fs.existsSync(tscPath)) { throw new Error(tscPath + ' is not exists'); } var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && IO.fileExists(tsfile + '.tscparams')) { + if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { command += '@' + tsfile + '.tscparams'; } else if (options.checkNoImplicitAny) { command += '--noImplicitAny'; diff --git a/_infrastructure/tests/src/util.ts b/_infrastructure/tests/src/util.ts index d907fe49d2..3b441991fd 100644 --- a/_infrastructure/tests/src/util.ts +++ b/_infrastructure/tests/src/util.ts @@ -1,5 +1,25 @@ module DT { + + var referenceTagExp = //g; + export function endsWith(str: string, suffix: string) { return str.indexOf(suffix, str.length - suffix.length) !== -1; } + + export function extractReferenceTags(source: string): string[] { + var ret: string[] = []; + var match: RegExpExecArray; + + if (!referenceTagExp.global) { + throw new Error('referenceTagExp RegExp must have global flag'); + } + referenceTagExp.lastIndex = 0; + + while ((match = referenceTagExp.exec(source))) { + if (match.length > 0 && match[1].length > 0) { + ret.push(match[1]); + } + } + return ret; + } } From 8b1a4c104075f238b3196343174f3f91487b6b6b Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 27 Feb 2014 20:32:43 +0100 Subject: [PATCH 229/240] added git-change helper added dependencies to package.json renamed file index helper restructured references added _ref.d.ts changed references to double-quoted --- _infrastructure/tests/_ref.d.ts | 1 + _infrastructure/tests/runner.js | 177 +++++++++++++----- _infrastructure/tests/runner.ts | 115 +++++++----- _infrastructure/tests/src/changes.ts | 37 ++++ _infrastructure/tests/src/file.ts | 2 + .../tests/src/{references.ts => index.ts} | 11 +- _infrastructure/tests/src/printer.ts | 4 +- .../tests/src/reporter/reporter.ts | 3 + _infrastructure/tests/src/timer.ts | 4 +- _infrastructure/tests/src/tsc.ts | 7 +- _infrastructure/tests/src/util.ts | 2 + package.json | 17 +- 12 files changed, 265 insertions(+), 115 deletions(-) create mode 100644 _infrastructure/tests/_ref.d.ts rename _infrastructure/tests/src/{references.ts => index.ts} (90%) diff --git a/_infrastructure/tests/_ref.d.ts b/_infrastructure/tests/_ref.d.ts new file mode 100644 index 0000000000..1743cad05c --- /dev/null +++ b/_infrastructure/tests/_ref.d.ts @@ -0,0 +1 @@ +/// diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index f73c72a395..ee80513a21 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -44,6 +44,7 @@ var NodeExec = (function () { var Exec = function () { return new NodeExec(); }(); +/// var DT; (function (DT) { var path = require('path'); @@ -85,9 +86,9 @@ var DT; })(); DT.File = File; })(DT || (DT = {})); -/// -/// -/// +/// +/// +/// var DT; (function (DT) { var fs = require('fs'); @@ -127,8 +128,8 @@ var DT; })(); DT.Tsc = Tsc; })(DT || (DT = {})); -/// -/// +/// +/// var DT; (function (DT) { ///////////////////////////////// @@ -167,6 +168,7 @@ var DT; })(); DT.Timer = Timer; })(DT || (DT = {})); +/// var DT; (function (DT) { var referenceTagExp = //g; @@ -194,19 +196,19 @@ var DT; } DT.extractReferenceTags = extractReferenceTags; })(DT || (DT = {})); -/// -/// -/// +/// +/// +/// var DT; (function (DT) { var fs = require('fs'); var path = require('path'); - var ReferenceIndex = (function () { - function ReferenceIndex(options) { + var FileIndex = (function () { + function FileIndex(options) { this.options = options; } - ReferenceIndex.prototype.collectReferences = function (files, callback) { + FileIndex.prototype.parseFiles = function (files, callback) { var _this = this; this.fileMap = Object.create(null); files.forEach(function (file) { @@ -217,7 +219,7 @@ var DT; }); }; - ReferenceIndex.prototype.loadReferences = function (files, callback) { + FileIndex.prototype.loadReferences = function (files, callback) { var _this = this; var queue = files.slice(0); var active = []; @@ -240,7 +242,7 @@ var DT; process.nextTick(next); }; - ReferenceIndex.prototype.parseFile = function (file, callback) { + FileIndex.prototype.parseFile = function (file, callback) { var _this = this; fs.readFile(file.filePathWithName, { encoding: 'utf8', @@ -267,12 +269,49 @@ var DT; callback(file); }); }; - return ReferenceIndex; + return FileIndex; })(); - DT.ReferenceIndex = ReferenceIndex; + DT.FileIndex = FileIndex; })(DT || (DT = {})); -/// -/// +/// +var DT; +(function (DT) { + var fs = require('fs'); + var path = require('path'); + var Git = require('git-wrapper'); + + var GitChanges = (function () { + function GitChanges(baseDir) { + this.baseDir = baseDir; + this.options = []; + var dir = path.join(baseDir, '.git'); + if (!fs.existsSync(dir)) { + throw new Error('cannot locate git-dir: ' + dir); + } + this.options['git-dir'] = dir; + } + GitChanges.prototype.getChanges = function (callback) { + //git diff --name-only HEAD~1 + var git = new Git(this.options); + var opts = {}; + var args = ['--name-only HEAD~1']; + git.exec('diff', opts, args, function (err, msg) { + if (err) { + callback(err, null); + return; + } + var paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); + + // console.log(paths); + callback(null, paths); + }); + }; + return GitChanges; + })(); + DT.GitChanges = GitChanges; +})(DT || (DT = {})); +/// +/// var DT; (function (DT) { ///////////////////////////////// @@ -387,6 +426,8 @@ var DT; })(); DT.Print = Print; })(DT || (DT = {})); +/// +/// var DT; (function (DT) { @@ -608,27 +649,41 @@ var DT; })(DT.TestSuiteBase); DT.FindNotRequiredTscparams = FindNotRequiredTscparams; })(DT || (DT = {})); -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// /// -/// -/// -/// -/// -/// -/// -/// +/// +/// +/// +/// +/// +/// +/// +/// var DT; (function (DT) { - require('source-map-support'); + require('source-map-support').install(); var fs = require('fs'); var path = require('path'); var glob = require('glob'); + var tsExp = /\.ts$/; + + // TOD0 remove this after dev! + var testNames = [ + 'async/', + 'jquery/jquery.d', + 'angularjs/angular.d', + 'pixi/' + ]; + + /* if (process.env.TRAVIS) { + testNames = null; + } */ DT.DEFAULT_TSC_VERSION = "0.9.1.1"; var Test = (function () { @@ -679,39 +734,36 @@ var DT; var TestRunner = (function () { function TestRunner(dtPath, options) { if (typeof options === "undefined") { options = { tscVersion: DT.DEFAULT_TSC_VERSION }; } + var _this = this; + this.dtPath = dtPath; this.options = options; this.suites = []; this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - // TOD0 remove this after dev! - var testNames = [ - 'async/', - 'jquery/jquery.d', - 'angularjs/angular.d', - 'pixi/' - ]; - if (process.env.TRAVIS) { - testNames = null; - } + this.index = new DT.FileIndex(this.options); // should be async // only includes .d.ts or -tests.ts or -test.ts or .ts var filesName = glob.sync('**/*.ts', { cwd: dtPath }); this.files = filesName.filter(function (fileName) { - return fileName.indexOf('_infrastructure') < 0; - }).filter(function (fileName) { - return fileName.indexOf('node_modules/') < 0; - }).filter(function (fileName) { - // TOD0 remove this after dev! - return !testNames || testNames.some(function (pattern) { - return fileName.indexOf(pattern) > -1; - }); - }).filter(function (fileName) { - return /^[a-z]/i.test(fileName); + return _this.checkAcceptFile(fileName); }).sort().map(function (fileName) { return new DT.File(dtPath, fileName); }); } + TestRunner.prototype.checkAcceptFile = function (fileName) { + var ok = tsExp.test(fileName); + ok = ok && fileName.indexOf('_infrastructure') < 0; + ok = ok && fileName.indexOf('node_modules/') < 0; + ok = ok && /^[a-z]/i.test(fileName); + + //TODO remove this dev code + ok = ok && (!testNames || testNames.some(function (pattern) { + return fileName.indexOf(pattern) > -1; + })); + return ok; + }; + TestRunner.prototype.addSuite = function (suite) { this.suites.push(suite); }; @@ -721,17 +773,38 @@ var DT; this.timer = new DT.Timer(); this.timer.start(); - var index = new DT.ReferenceIndex(this.options); - index.collectReferences(this.files, function () { + this.index.parseFiles(this.files, function () { + console.log('files:'); + console.log('---'); _this.files.forEach(function (file) { console.log(file.filePathWithName); file.references.forEach(function (file) { console.log(' - %s', file.filePathWithName); }); }); + console.log('---'); + _this.getChanges(); + }); + }; + + TestRunner.prototype.getChanges = function () { + var _this = this; + var changes = new DT.GitChanges(this.dtPath); + changes.getChanges(function (err, changes) { + if (err) { + throw err; + } + console.log('changes:'); + console.log('---'); + changes.forEach(function (file) { + console.log(file); + }); + console.log('---'); + _this.runTests(); }); }; + TestRunner.prototype.runTests = function () { var _this = this; var syntaxChecking = new DT.SyntaxChecking(this.options); diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index bf05025266..555ec54ab2 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -1,28 +1,43 @@ -/// +/// -/// +/// -/// -/// -/// +/// +/// +/// /// -/// -/// -/// +/// +/// -/// -/// -/// -/// +/// +/// + +/// +/// +/// +/// module DT { - require('source-map-support'); + require('source-map-support').install(); var fs = require('fs'); var path = require('path'); var glob = require('glob'); + var tsExp = /\.ts$/; + + // TOD0 remove this after dev! + var testNames = [ + 'async/', + 'jquery/jquery.d', + 'angularjs/angular.d', + 'pixi/' + ]; + /* if (process.env.TRAVIS) { + testNames = null; + } */ + export var DEFAULT_TSC_VERSION = "0.9.1.1"; export class Test { @@ -72,40 +87,21 @@ module DT { files: File[]; timer: Timer; suites: ITestSuite[] = []; + private index: FileIndex; private print: Print; - constructor(dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) { + constructor(public dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) { this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - // TOD0 remove this after dev! - var testNames = [ - 'async/', - 'jquery/jquery.d', - 'angularjs/angular.d', - 'pixi/' - ]; - if (process.env.TRAVIS) { - testNames = null; - } + + this.index = new FileIndex(this.options); // should be async // only includes .d.ts or -tests.ts or -test.ts or .ts var filesName = glob.sync('**/*.ts', { cwd: dtPath }); this.files = filesName .filter((fileName) => { - return fileName.indexOf('_infrastructure') < 0; - }) - .filter((fileName) => { - return fileName.indexOf('node_modules/') < 0; - }) - .filter((fileName) => { - // TOD0 remove this after dev! - return !testNames || testNames.some((pattern) => { - return fileName.indexOf(pattern) > -1; - }); - }) - .filter((fileName) => { - return /^[a-z]/i.test(fileName); + return this.checkAcceptFile(fileName); }) .sort() .map((fileName) => { @@ -113,26 +109,59 @@ module DT { }); } - public addSuite(suite: ITestSuite) { + public checkAcceptFile(fileName: string): boolean { + var ok = tsExp.test(fileName); + ok = ok && fileName.indexOf('_infrastructure') < 0; + ok = ok && fileName.indexOf('node_modules/') < 0; + ok = ok && /^[a-z]/i.test(fileName); + + //TODO remove this dev code + ok = ok && (!testNames || testNames.some((pattern) => { + return fileName.indexOf(pattern) > -1; + })); + return ok; + } + + public addSuite(suite: ITestSuite):void { this.suites.push(suite); } - public run() { + public run():void { this.timer = new Timer(); this.timer.start(); - var index = new ReferenceIndex(this.options); - index.collectReferences(this.files, () => { + this.index.parseFiles(this.files, () => { + console.log('files:'); + console.log('---'); this.files.forEach((file) => { console.log(file.filePathWithName); file.references.forEach((file) => { - console.log(' - %s', file.filePathWithName); + console.log(' - %s', file.filePathWithName); }); }); + console.log('---'); + this.getChanges(); + }); + } + + public getChanges():void { + var changes = new GitChanges(this.dtPath); + changes.getChanges((err, changes: string[]) => { + if (err) { + throw err; + } + console.log('changes:'); + console.log('---'); + changes.forEach((file) => { + console.log(file); + }); + console.log('---'); + this.runTests(); }); } - public runTests() { + + public runTests():void { var syntaxChecking = new SyntaxChecking(this.options); var testEval = new TestEval(this.options); diff --git a/_infrastructure/tests/src/changes.ts b/_infrastructure/tests/src/changes.ts index e69de29bb2..5f28f24c5f 100644 --- a/_infrastructure/tests/src/changes.ts +++ b/_infrastructure/tests/src/changes.ts @@ -0,0 +1,37 @@ +/// + +module DT { + + var fs = require('fs'); + var path = require('path'); + var Git = require('git-wrapper'); + + export class GitChanges { + + options = []; + + constructor(public baseDir: string) { + var dir = path.join(baseDir, '.git'); + if (!fs.existsSync(dir)) { + throw new Error('cannot locate git-dir: ' + dir); + } + this.options['git-dir'] = dir; + } + + getChanges(callback: (err, paths: string[]) => void): void { + //git diff --name-only HEAD~1 + var git = new Git(this.options); + var opts = {}; + var args = ['--name-only HEAD~1']; + git.exec('diff', opts, args, (err, msg: string) => { + if (err) { + callback(err, null); + return; + } + var paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); + // console.log(paths); + callback(null, paths); + }); + } + } +} diff --git a/_infrastructure/tests/src/file.ts b/_infrastructure/tests/src/file.ts index c1a8d1f517..bd7f62dc86 100644 --- a/_infrastructure/tests/src/file.ts +++ b/_infrastructure/tests/src/file.ts @@ -1,3 +1,5 @@ +/// + module DT { var path = require('path'); diff --git a/_infrastructure/tests/src/references.ts b/_infrastructure/tests/src/index.ts similarity index 90% rename from _infrastructure/tests/src/references.ts rename to _infrastructure/tests/src/index.ts index c98f947c38..4a40f35d49 100644 --- a/_infrastructure/tests/src/references.ts +++ b/_infrastructure/tests/src/index.ts @@ -1,13 +1,12 @@ -/// -/// - -/// +/// +/// +/// module DT { var fs = require('fs'); var path = require('path'); - export class ReferenceIndex { + export class FileIndex { fileMap: {[path:string]:File}; @@ -15,7 +14,7 @@ module DT { } - collectReferences(files: File[], callback: () => void): void { + parseFiles(files: File[], callback: () => void): void { this.fileMap = Object.create(null); files.forEach((file) => { this.fileMap[file.fullPath] = file; diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts index d1f0f952e2..53274587ad 100644 --- a/_infrastructure/tests/src/printer.ts +++ b/_infrastructure/tests/src/printer.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// module DT { ///////////////////////////////// diff --git a/_infrastructure/tests/src/reporter/reporter.ts b/_infrastructure/tests/src/reporter/reporter.ts index d4556e0cc0..5f01c43ab5 100644 --- a/_infrastructure/tests/src/reporter/reporter.ts +++ b/_infrastructure/tests/src/reporter/reporter.ts @@ -1,3 +1,6 @@ +/// +/// + module DT { ///////////////////////////////// // Test reporter interface diff --git a/_infrastructure/tests/src/timer.ts b/_infrastructure/tests/src/timer.ts index e03a941668..446ea1b34f 100644 --- a/_infrastructure/tests/src/timer.ts +++ b/_infrastructure/tests/src/timer.ts @@ -1,5 +1,5 @@ -/// -/// +/// +/// module DT { ///////////////////////////////// diff --git a/_infrastructure/tests/src/tsc.ts b/_infrastructure/tests/src/tsc.ts index 5a2c803c80..6bd3fb2591 100644 --- a/_infrastructure/tests/src/tsc.ts +++ b/_infrastructure/tests/src/tsc.ts @@ -1,7 +1,6 @@ -/// -/// - -/// +/// +/// +/// module DT { var fs = require('fs'); diff --git a/_infrastructure/tests/src/util.ts b/_infrastructure/tests/src/util.ts index 3b441991fd..3d63ce1421 100644 --- a/_infrastructure/tests/src/util.ts +++ b/_infrastructure/tests/src/util.ts @@ -1,3 +1,5 @@ +/// + module DT { var referenceTagExp = //g; diff --git a/package.json b/package.json index 0119109e94..bb4c816f6e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,13 @@ { - "private": true, - "name": "DefinitelyTyped", - "version": "0.0.0", - "scripts": { - "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7" - } + "private": true, + "name": "DefinitelyTyped", + "version": "0.0.0", + "scripts": { + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7" + }, + "dependencies": { + "git-wrapper": "~0.1.1", + "glob": "~3.2.9", + "source-map-support": "~0.2.5" + } } From 35765e6305881906943a2bb2cae5fee89e927a5d Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 27 Feb 2014 21:18:42 +0100 Subject: [PATCH 230/240] added test-module.d.ts --- test-module/test-module.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 test-module/test-module.d.ts diff --git a/test-module/test-module.d.ts b/test-module/test-module.d.ts new file mode 100644 index 0000000000..e73a9981c2 --- /dev/null +++ b/test-module/test-module.d.ts @@ -0,0 +1,6 @@ +declare module 'test-module' { + interface Such { + amaze(): void; + } + export function wow(): Such; +} From 76ffe56a44b64aabd8ff980ab85af9c11f80e9d3 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 27 Feb 2014 22:30:42 +0100 Subject: [PATCH 231/240] first setup for incremental testing combines reference parser and git changes still very dev mode --- _infrastructure/tests/runner.js | 231 +++++--- _infrastructure/tests/runner.ts | 555 ++++++++++-------- _infrastructure/tests/src/changes.ts | 58 +- _infrastructure/tests/src/file.ts | 56 +- _infrastructure/tests/src/host/exec.ts | 34 +- _infrastructure/tests/src/index.ts | 140 +++-- _infrastructure/tests/src/printer.ts | 172 +++--- .../tests/src/reporter/reporter.ts | 58 +- _infrastructure/tests/src/suite/suite.ts | 139 ++--- _infrastructure/tests/src/suite/syntax.ts | 28 +- _infrastructure/tests/src/suite/testEval.ts | 27 +- _infrastructure/tests/src/suite/tscParams.ts | 92 +-- _infrastructure/tests/src/timer.ts | 74 +-- _infrastructure/tests/src/tsc.ts | 70 +-- _infrastructure/tests/src/util.ts | 37 +- 15 files changed, 981 insertions(+), 790 deletions(-) diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index ee80513a21..1a7c4fc987 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -47,6 +47,8 @@ var Exec = function () { /// var DT; (function (DT) { + 'use-strict'; + var path = require('path'); ///////////////////////////////// @@ -55,30 +57,17 @@ var DT; ///////////////////////////////// var File = (function () { function File(baseDir, filePathWithName) { + this.references = []; this.baseDir = baseDir; this.filePathWithName = filePathWithName; - this.references = []; this.ext = path.extname(this.filePathWithName); this.file = path.basename(this.filePathWithName, this.ext); this.dir = path.dirname(this.filePathWithName); + this.formatName = path.join(this.dir, this.file + this.ext); + this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext); + // lock it (shallow) + // Object.freeze(this); } - Object.defineProperty(File.prototype, "formatName", { - // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' - get: function () { - return path.join(this.dir, this.file + this.ext); - }, - enumerable: true, - configurable: true - }); - - Object.defineProperty(File.prototype, "fullPath", { - get: function () { - return path.join(this.baseDir, this.dir, this.file + this.ext); - }, - enumerable: true, - configurable: true - }); - File.prototype.toString = function () { return '[File ' + this.filePathWithName + ']'; }; @@ -91,6 +80,7 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; var fs = require('fs'); var Tsc = (function () { @@ -132,6 +122,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + ///////////////////////////////// // Timer.start starts a timer // Timer.end stops the timer and sets asString to the pretty print value @@ -171,6 +163,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + var referenceTagExp = //g; function endsWith(str, suffix) { @@ -201,6 +195,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + var fs = require('fs'); var path = require('path'); @@ -219,6 +215,17 @@ var DT; }); }; + FileIndex.prototype.hasFile = function (target) { + return target in this.fileMap; + }; + + FileIndex.prototype.getFile = function (target) { + if (target in this.fileMap) { + return this.fileMap[target]; + } + return null; + }; + FileIndex.prototype.loadReferences = function (files, callback) { var _this = this; var queue = files.slice(0); @@ -276,6 +283,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + var fs = require('fs'); var path = require('path'); var Git = require('git-wrapper'); @@ -283,7 +292,8 @@ var DT; var GitChanges = (function () { function GitChanges(baseDir) { this.baseDir = baseDir; - this.options = []; + this.options = {}; + this.paths = []; var dir = path.join(baseDir, '.git'); if (!fs.existsSync(dir)) { throw new Error('cannot locate git-dir: ' + dir); @@ -291,19 +301,20 @@ var DT; this.options['git-dir'] = dir; } GitChanges.prototype.getChanges = function (callback) { + var _this = this; //git diff --name-only HEAD~1 var git = new Git(this.options); var opts = {}; var args = ['--name-only HEAD~1']; git.exec('diff', opts, args, function (err, msg) { if (err) { - callback(err, null); + callback(err); return; } - var paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); + _this.paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); // console.log(paths); - callback(null, paths); + callback(null); }); }; return GitChanges; @@ -314,6 +325,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + ///////////////////////////////// // All the common things that we pring are functions of this class ///////////////////////////////// @@ -430,6 +443,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + ///////////////////////////////// @@ -463,6 +478,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + ///////////////////////////////// @@ -549,6 +566,8 @@ var __extends = this.__extends || function (d, b) { }; var DT; (function (DT) { + 'use-strict'; + ///////////////////////////////// // .d.ts syntax inspection ///////////////////////////////// @@ -570,6 +589,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + ///////////////////////////////// // Compile with *-tests.ts ///////////////////////////////// @@ -591,6 +612,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + var fs = require('fs'); ///////////////////////////////// @@ -665,6 +688,8 @@ var DT; /// var DT; (function (DT) { + 'use-strict'; + require('source-map-support').install(); var fs = require('fs'); @@ -673,17 +698,6 @@ var DT; var tsExp = /\.ts$/; - // TOD0 remove this after dev! - var testNames = [ - 'async/', - 'jquery/jquery.d', - 'angularjs/angular.d', - 'pixi/' - ]; - - /* if (process.env.TRAVIS) { - testNames = null; - } */ DT.DEFAULT_TSC_VERSION = "0.9.1.1"; var Test = (function () { @@ -731,6 +745,8 @@ var DT; ///////////////////////////////// // The main class to kick things off ///////////////////////////////// + // TODO move to bluebird (Promises) + // TODO move to lazy.js (functional) var TestRunner = (function () { function TestRunner(dtPath, options) { if (typeof options === "undefined") { options = { tscVersion: DT.DEFAULT_TSC_VERSION }; } @@ -741,8 +757,9 @@ var DT; this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; this.index = new DT.FileIndex(this.options); + this.changes = new DT.GitChanges(this.dtPath); - // should be async + // should be async (way faster) // only includes .d.ts or -tests.ts or -test.ts or .ts var filesName = glob.sync('**/*.ts', { cwd: dtPath }); this.files = filesName.filter(function (fileName) { @@ -751,29 +768,50 @@ var DT; return new DT.File(dtPath, fileName); }); } - TestRunner.prototype.checkAcceptFile = function (fileName) { - var ok = tsExp.test(fileName); - ok = ok && fileName.indexOf('_infrastructure') < 0; - ok = ok && fileName.indexOf('node_modules/') < 0; - ok = ok && /^[a-z]/i.test(fileName); - - //TODO remove this dev code - ok = ok && (!testNames || testNames.some(function (pattern) { - return fileName.indexOf(pattern) > -1; - })); - return ok; - }; - TestRunner.prototype.addSuite = function (suite) { this.suites.push(suite); }; TestRunner.prototype.run = function () { - var _this = this; this.timer = new DT.Timer(); this.timer.start(); + // we need promises + this.doGetChanges(); + }; + + TestRunner.prototype.checkAcceptFile = function (fileName) { + var ok = tsExp.test(fileName); + ok = ok && fileName.indexOf('_infrastructure') < 0; + ok = ok && fileName.indexOf('node_modules/') < 0; + ok = ok && /^[a-z]/i.test(fileName); + return ok; + }; + + TestRunner.prototype.doGetChanges = function () { + var _this = this; + this.changes.getChanges(function (err) { + if (err) { + throw err; + } + console.log(''); + console.log('changes:'); + console.log('---'); + + _this.changes.paths.forEach(function (file) { + console.log(file); + }); + console.log('---'); + + // chain + _this.doGetReferences(); + }); + }; + + TestRunner.prototype.doGetReferences = function () { + var _this = this; this.index.parseFiles(this.files, function () { + console.log(''); console.log('files:'); console.log('---'); _this.files.forEach(function (file) { @@ -783,29 +821,80 @@ var DT; }); }); console.log('---'); - _this.getChanges(); + + // chain + _this.doCollectTargets(); }); }; - TestRunner.prototype.getChanges = function () { + TestRunner.prototype.doCollectTargets = function () { + // TODO clean this up when functional (do we need changeMap?) var _this = this; - var changes = new DT.GitChanges(this.dtPath); - changes.getChanges(function (err, changes) { - if (err) { - throw err; + // bake map for lookup + var changeMap = this.changes.paths.filter(function (full) { + return _this.checkAcceptFile(full); + }).map(function (local) { + return path.resolve(_this.dtPath, local); + }).reduce(function (memo, full) { + var file = _this.index.getFile(full); + if (!file) { + // what does it mean? deleted? + console.log('not in index: ' + full); + return memo; } - console.log('changes:'); - console.log('---'); - changes.forEach(function (file) { - console.log(file); - }); - console.log('---'); + memo[full] = file; + return memo; + }, Object.create(null)); - _this.runTests(); + // collect referring files (and also log) + var touched = Object.create(null); + console.log(''); + console.log('relevant changes:'); + console.log('---'); + Object.keys(changeMap).sort().forEach(function (src) { + touched[src] = changeMap[src]; + console.log(changeMap[src].formatName); }); + console.log('---'); + + // terrible loop (whatever) + // just add stuff until there is nothing new added + // TODO improve it + var added; + do { + added = 0; + this.files.forEach(function (file) { + // lol getter + if (file.fullPath in touched) { + return; + } + + // check if one of our references is touched + file.references.some(function (ref) { + if (ref.fullPath in touched) { + // add us + touched[file.fullPath] = file; + added++; + return true; + } + return false; + }); + }); + } while(added > 0); + + console.log(''); + console.log('touched:'); + console.log('---'); + var files = Object.keys(touched).sort().map(function (src) { + console.log(touched[src].formatName); + return touched[src]; + }); + console.log('---'); + + this.runTests(files); }; - TestRunner.prototype.runTests = function () { + TestRunner.prototype.runTests = function (files) { var _this = this; var syntaxChecking = new DT.SyntaxChecking(this.options); var testEval = new DT.TestEval(this.options); @@ -814,9 +903,10 @@ var DT; this.addSuite(testEval); } - var typings = syntaxChecking.filterTargetFiles(this.files).length; - var testFiles = testEval.filterTargetFiles(this.files).length; - this.print = new DT.Print(this.options.tscVersion, typings, testFiles, this.files.length); + var typings = syntaxChecking.filterTargetFiles(files).length; + var testFiles = testEval.filterTargetFiles(files).length; + + this.print = new DT.Print(this.options.tscVersion, typings, testFiles, files.length); this.print.printHeader(); if (this.options.findNotRequiredTscparams) { @@ -830,7 +920,7 @@ var DT; suite.testReporter = suite.testReporter || new DT.DefaultTestReporter(_this.print); _this.print.printSuiteHeader(suite.testSuiteName); - var targetFiles = suite.filterTargetFiles(_this.files); + var targetFiles = suite.filterTargetFiles(files); suite.start(targetFiles, function (testResult, index) { _this.testCompleteCallback(testResult, index); }, function (suite) { @@ -840,7 +930,7 @@ var DT; }); } else { _this.timer.end(); - _this.allTestCompleteCallback(); + _this.allTestCompleteCallback(files); } }; executor(); @@ -864,7 +954,7 @@ var DT; this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); }; - TestRunner.prototype.allTestCompleteCallback = function () { + TestRunner.prototype.allTestCompleteCallback = function (files) { var _this = this; var testEval = this.suites.filter(function (suite) { return suite instanceof DT.TestEval; @@ -875,11 +965,13 @@ var DT; }).reduce(function (a, b) { return a.indexOf(b) < 0 ? a.concat([b]) : a; }, []); - var typings = this.files.map(function (file) { + + var typings = files.map(function (file) { return file.dir; }).reduce(function (a, b) { return a.indexOf(b) < 0 ? a.concat([b]) : a; }, []); + var withoutTestTypings = typings.filter(function (typing) { return existsTestTypings.indexOf(typing) < 0; }); @@ -892,6 +984,7 @@ var DT; this.print.printDiv(); this.print.printElapsedTime(this.timer.asString, this.timer.time); + this.suites.filter(function (suite) { return suite.printErrorCount; }).forEach(function (suite) { diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 555ec54ab2..f2ca6a0592 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -19,291 +19,352 @@ /// module DT { - require('source-map-support').install(); + 'use-strict'; - var fs = require('fs'); - var path = require('path'); - var glob = require('glob'); + require('source-map-support').install(); - var tsExp = /\.ts$/; + var fs = require('fs'); + var path = require('path'); + var glob = require('glob'); - // TOD0 remove this after dev! - var testNames = [ - 'async/', - 'jquery/jquery.d', - 'angularjs/angular.d', - 'pixi/' - ]; - /* if (process.env.TRAVIS) { - testNames = null; - } */ + var tsExp = /\.ts$/; - export var DEFAULT_TSC_VERSION = "0.9.1.1"; + export var DEFAULT_TSC_VERSION = "0.9.1.1"; - export class Test { - constructor(public suite: ITestSuite, public tsfile: File, public options?: TscExecOptions) { - } + export class Test { + constructor(public suite: ITestSuite, public tsfile: File, public options?: TscExecOptions) { + } - public run(callback: (result: TestResult) => void) { - Tsc.run(this.tsfile.filePathWithName, this.options, (execResult) => { - var testResult = new TestResult(); - testResult.hostedBy = this.suite; - testResult.targetFile = this.tsfile; - testResult.options = this.options; + public run(callback: (result: TestResult) => void) { + Tsc.run(this.tsfile.filePathWithName, this.options, (execResult) => { + var testResult = new TestResult(); + testResult.hostedBy = this.suite; + testResult.targetFile = this.tsfile; + testResult.options = this.options; - testResult.stdout = execResult.stdout; - testResult.stderr = execResult.stderr; - testResult.exitCode = execResult.exitCode; + testResult.stdout = execResult.stdout; + testResult.stderr = execResult.stderr; + testResult.exitCode = execResult.exitCode; - callback(testResult); - }); - } - } - ///////////////////////////////// - // Test results - ///////////////////////////////// - export class TestResult { - hostedBy: ITestSuite; - targetFile: File; - options: TscExecOptions; + callback(testResult); + }); + } + } - stdout: string; - stderr: string; - exitCode: number; + ///////////////////////////////// + // Test results + ///////////////////////////////// + export class TestResult { + hostedBy: ITestSuite; + targetFile: File; + options: TscExecOptions; - public get success(): boolean { - return this.exitCode === 0; - } - } - export interface ITestRunnerOptions { - tscVersion:string; - findNotRequiredTscparams?:boolean; - } + stdout: string; + stderr: string; + exitCode: number; - ///////////////////////////////// - // The main class to kick things off - ///////////////////////////////// - export class TestRunner { - files: File[]; - timer: Timer; - suites: ITestSuite[] = []; - private index: FileIndex; - private print: Print; + public get success(): boolean { + return this.exitCode === 0; + } + } - constructor(public dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) { - this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; + export interface ITestRunnerOptions { + tscVersion:string; + findNotRequiredTscparams?:boolean; + } + ///////////////////////////////// + // The main class to kick things off + ///////////////////////////////// + // TODO move to bluebird (Promises) + // TODO move to lazy.js (functional) + export class TestRunner { + files: File[]; + timer: Timer; + suites: ITestSuite[] = []; - this.index = new FileIndex(this.options); + private index: FileIndex; + private changes: GitChanges; + private print: Print; - // should be async - // only includes .d.ts or -tests.ts or -test.ts or .ts - var filesName = glob.sync('**/*.ts', { cwd: dtPath }); - this.files = filesName - .filter((fileName) => { - return this.checkAcceptFile(fileName); - }) - .sort() - .map((fileName) => { - return new File(dtPath, fileName); - }); - } + constructor(public dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) { + this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - public checkAcceptFile(fileName: string): boolean { - var ok = tsExp.test(fileName); - ok = ok && fileName.indexOf('_infrastructure') < 0; - ok = ok && fileName.indexOf('node_modules/') < 0; - ok = ok && /^[a-z]/i.test(fileName); + this.index = new FileIndex(this.options); + this.changes = new GitChanges(this.dtPath); - //TODO remove this dev code - ok = ok && (!testNames || testNames.some((pattern) => { - return fileName.indexOf(pattern) > -1; - })); - return ok; - } + // should be async (way faster) + // only includes .d.ts or -tests.ts or -test.ts or .ts + var filesName = glob.sync('**/*.ts', { cwd: dtPath }); + this.files = filesName.filter((fileName) => { + return this.checkAcceptFile(fileName); + }).sort().map((fileName) => { + return new File(dtPath, fileName); + }); + } - public addSuite(suite: ITestSuite):void { - this.suites.push(suite); - } + public addSuite(suite: ITestSuite): void { + this.suites.push(suite); + } - public run():void { - this.timer = new Timer(); - this.timer.start(); + public run(): void { + this.timer = new Timer(); + this.timer.start(); - this.index.parseFiles(this.files, () => { - console.log('files:'); - console.log('---'); - this.files.forEach((file) => { - console.log(file.filePathWithName); - file.references.forEach((file) => { - console.log(' - %s', file.filePathWithName); - }); - }); - console.log('---'); - this.getChanges(); - }); - } + // we need promises + this.doGetChanges(); + } - public getChanges():void { - var changes = new GitChanges(this.dtPath); - changes.getChanges((err, changes: string[]) => { - if (err) { - throw err; - } - console.log('changes:'); - console.log('---'); - changes.forEach((file) => { - console.log(file); - }); - console.log('---'); + private checkAcceptFile(fileName: string): boolean { + var ok = tsExp.test(fileName); + ok = ok && fileName.indexOf('_infrastructure') < 0; + ok = ok && fileName.indexOf('node_modules/') < 0; + ok = ok && /^[a-z]/i.test(fileName); + return ok; + } - this.runTests(); - }); - } + private doGetChanges(): void { + this.changes.getChanges((err) => { + if (err) { + throw err; + } + console.log(''); + console.log('changes:'); + console.log('---'); - public runTests():void { + this.changes.paths.forEach((file) => { + console.log(file); + }); + console.log('---'); - var syntaxChecking = new SyntaxChecking(this.options); - var testEval = new TestEval(this.options); - if (!this.options.findNotRequiredTscparams) { - this.addSuite(syntaxChecking); - this.addSuite(testEval); - } + // chain + this.doGetReferences(); + }); + } - var typings = syntaxChecking.filterTargetFiles(this.files).length; - var testFiles = testEval.filterTargetFiles(this.files).length; - this.print = new Print(this.options.tscVersion, typings, testFiles, this.files.length); - this.print.printHeader(); + private doGetReferences(): void { + this.index.parseFiles(this.files, () => { + console.log(''); + console.log('files:'); + console.log('---'); + this.files.forEach((file) => { + console.log(file.filePathWithName); + file.references.forEach((file) => { + console.log(' - %s', file.filePathWithName); + }); + }); + console.log('---'); - if (this.options.findNotRequiredTscparams) { - this.addSuite(new FindNotRequiredTscparams(this.options, this.print)); - } + // chain + this.doCollectTargets(); + }); + } - var count = 0; - var executor = () => { - var suite = this.suites[count]; - if (suite) { - suite.testReporter = suite.testReporter || new DefaultTestReporter(this.print); + private doCollectTargets(): void { - this.print.printSuiteHeader(suite.testSuiteName); - var targetFiles = suite.filterTargetFiles(this.files); - suite.start( - targetFiles, - (testResult, index) => { - this.testCompleteCallback(testResult, index); - }, - (suite) => { - this.suiteCompleteCallback(suite); - count++; - executor(); - }); - } else { - this.timer.end(); - this.allTestCompleteCallback(); - } - }; - executor(); - } + // TODO clean this up when functional (do we need changeMap?) - private testCompleteCallback(testResult: TestResult, index: number) { - var reporter = testResult.hostedBy.testReporter; - if (testResult.success) { - reporter.printPositiveCharacter(index, testResult); - } else { - reporter.printNegativeCharacter(index, testResult); - } - } + // bake map for lookup + var changeMap = this.changes.paths.filter((full) => { + return this.checkAcceptFile(full); + }).map((local) => { + return path.resolve(this.dtPath, local); + }).reduce((memo, full) => { + var file = this.index.getFile(full); + if (!file) { + // what does it mean? deleted? + console.log('not in index: ' + full); + return memo; + } + memo[full] = file; + return memo; + }, Object.create(null)); - private suiteCompleteCallback(suite: ITestSuite) { - this.print.printBreak(); + // collect referring files (and also log) + var touched = Object.create(null); + console.log(''); + console.log('relevant changes:'); + console.log('---'); + Object.keys(changeMap).sort().forEach((src) => { + touched[src] = changeMap[src]; + console.log(changeMap[src].formatName); + }); + console.log('---'); - this.print.printDiv(); - this.print.printElapsedTime(suite.timer.asString, suite.timer.time); - this.print.printSuccessCount(suite.okTests.length, suite.testResults.length); - this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); - } + // terrible loop (whatever) + // just add stuff until there is nothing new added + // TODO improve it + var added:number; + do { + added = 0; + this.files.forEach((file) => { + // lol getter + if (file.fullPath in touched) { + return; + } + // check if one of our references is touched + file.references.some((ref) => { + if (ref.fullPath in touched) { + // add us + touched[file.fullPath] = file; + added++; + return true; + } + return false; + }); + }); + } + while(added > 0); - private allTestCompleteCallback() { - var testEval = this.suites.filter(suite => suite instanceof TestEval)[0]; - if (testEval) { - var existsTestTypings: string[] = testEval.testResults - .map((testResult) => { - return testResult.targetFile.dir; - }) - .reduce((a: string[], b: string) => { - return a.indexOf(b) < 0 ? a.concat([b]) : a; - }, []); - var typings: string[] = this.files - .map((file) => { - return file.dir; - }) - .reduce((a: string[], b: string) => { - return a.indexOf(b) < 0 ? a.concat([b]) : a; - }, []); - var withoutTestTypings: string[] = typings - .filter((typing) => { - return existsTestTypings.indexOf(typing) < 0; - }); - this.print.printDiv(); - this.print.printTypingsWithoutTest(withoutTestTypings); - } + console.log(''); + console.log('touched:'); + console.log('---'); + var files: File[] = Object.keys(touched).sort().map((src) => { + console.log(touched[src].formatName); + return touched[src]; + }); + console.log('---'); - this.print.printDiv(); - this.print.printTotalMessage(); + this.runTests(files); + } - this.print.printDiv(); - this.print.printElapsedTime(this.timer.asString, this.timer.time); - this.suites - .filter((suite: ITestSuite) => { - return suite.printErrorCount; - }) - .forEach((suite: ITestSuite) => { - this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length); - }); - if (testEval) { - this.print.printSuiteErrorCount("Without tests", withoutTestTypings.length, typings.length, '\33[33m\33[1m'); - } + private runTests(files: File[]): void { - this.print.printDiv(); - if (this.suites.some((suite) => { - return suite.ngTests.length !== 0 - })) { - this.print.printErrorsHeader(); + var syntaxChecking = new SyntaxChecking(this.options); + var testEval = new TestEval(this.options); + if (!this.options.findNotRequiredTscparams) { + this.addSuite(syntaxChecking); + this.addSuite(testEval); + } - this.suites - .filter((suite) => { - return suite.ngTests.length !== 0; - }) - .forEach((suite) => { - suite.ngTests.forEach((testResult) => { - this.print.printErrorsForFile(testResult); - }); - this.print.printBoldDiv(); - }); + var typings = syntaxChecking.filterTargetFiles(files).length; + var testFiles = testEval.filterTargetFiles(files).length; - process.exit(1); - } - } - } + this.print = new Print(this.options.tscVersion, typings, testFiles, files.length); + this.print.printHeader(); - var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); - var findNotRequiredTscparams = process.argv.some(arg => arg == "--try-without-tscparams"); - var tscVersionIndex = process.argv.indexOf("--tsc-version"); - var tscVersion = DEFAULT_TSC_VERSION; - if (-1 < tscVersionIndex) { - tscVersion = process.argv[tscVersionIndex + 1]; - } + if (this.options.findNotRequiredTscparams) { + this.addSuite(new FindNotRequiredTscparams(this.options, this.print)); + } - console.log('--'); - console.log(' dtPath %s', dtPath); - console.log(' tscVersion %s', tscVersion); - console.log(' findNotRequiredTscparams %s', findNotRequiredTscparams); - console.log('--'); - console.log(''); + var count = 0; + var executor = () => { + var suite = this.suites[count]; + if (suite) { + suite.testReporter = suite.testReporter || new DefaultTestReporter(this.print); - var runner = new TestRunner(dtPath, { - tscVersion: tscVersion, - findNotRequiredTscparams: findNotRequiredTscparams - }); - runner.run(); + this.print.printSuiteHeader(suite.testSuiteName); + var targetFiles = suite.filterTargetFiles(files); + suite.start(targetFiles, (testResult, index) => { + this.testCompleteCallback(testResult, index); + }, (suite) => { + this.suiteCompleteCallback(suite); + count++; + executor(); + }); + } + else { + this.timer.end(); + this.allTestCompleteCallback(files); + } + }; + executor(); + } + + private testCompleteCallback(testResult: TestResult, index: number) { + var reporter = testResult.hostedBy.testReporter; + if (testResult.success) { + reporter.printPositiveCharacter(index, testResult); + } + else { + reporter.printNegativeCharacter(index, testResult); + } + } + + private suiteCompleteCallback(suite: ITestSuite) { + this.print.printBreak(); + + this.print.printDiv(); + this.print.printElapsedTime(suite.timer.asString, suite.timer.time); + this.print.printSuccessCount(suite.okTests.length, suite.testResults.length); + this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); + } + + private allTestCompleteCallback(files: File[]) { + var testEval = this.suites.filter(suite => suite instanceof TestEval)[0]; + if (testEval) { + var existsTestTypings: string[] = testEval.testResults.map((testResult) => { + return testResult.targetFile.dir; + }).reduce((a: string[], b: string) => { + return a.indexOf(b) < 0 ? a.concat([b]) : a; + }, []); + + var typings: string[] = files.map((file) => { + return file.dir; + }).reduce((a: string[], b: string) => { + return a.indexOf(b) < 0 ? a.concat([b]) : a; + }, []); + + var withoutTestTypings: string[] = typings.filter((typing) => { + return existsTestTypings.indexOf(typing) < 0; + }); + this.print.printDiv(); + this.print.printTypingsWithoutTest(withoutTestTypings); + } + + this.print.printDiv(); + this.print.printTotalMessage(); + + this.print.printDiv(); + this.print.printElapsedTime(this.timer.asString, this.timer.time); + + this.suites.filter((suite: ITestSuite) => { + return suite.printErrorCount; + }).forEach((suite: ITestSuite) => { + this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length); + }); + if (testEval) { + this.print.printSuiteErrorCount("Without tests", withoutTestTypings.length, typings.length, '\33[33m\33[1m'); + } + + this.print.printDiv(); + if (this.suites.some((suite) => { + return suite.ngTests.length !== 0 + })) { + this.print.printErrorsHeader(); + + this.suites.filter((suite) => { + return suite.ngTests.length !== 0; + }).forEach((suite) => { + suite.ngTests.forEach((testResult) => { + this.print.printErrorsForFile(testResult); + }); + this.print.printBoldDiv(); + }); + + process.exit(1); + } + } + } + + var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); + var findNotRequiredTscparams = process.argv.some(arg => arg == "--try-without-tscparams"); + var tscVersionIndex = process.argv.indexOf("--tsc-version"); + var tscVersion = DEFAULT_TSC_VERSION; + if (-1 < tscVersionIndex) { + tscVersion = process.argv[tscVersionIndex + 1]; + } + + console.log('--'); + console.log(' dtPath %s', dtPath); + console.log(' tscVersion %s', tscVersion); + console.log(' findNotRequiredTscparams %s', findNotRequiredTscparams); + console.log('--'); + console.log(''); + + var runner = new TestRunner(dtPath, { + tscVersion: tscVersion, + findNotRequiredTscparams: findNotRequiredTscparams + }); + runner.run(); } diff --git a/_infrastructure/tests/src/changes.ts b/_infrastructure/tests/src/changes.ts index 5f28f24c5f..3bc7334e02 100644 --- a/_infrastructure/tests/src/changes.ts +++ b/_infrastructure/tests/src/changes.ts @@ -1,37 +1,39 @@ /// module DT { + 'use-strict'; - var fs = require('fs'); - var path = require('path'); - var Git = require('git-wrapper'); + var fs = require('fs'); + var path = require('path'); + var Git = require('git-wrapper'); - export class GitChanges { + export class GitChanges { - options = []; + options = {}; + paths: string[] = []; - constructor(public baseDir: string) { - var dir = path.join(baseDir, '.git'); - if (!fs.existsSync(dir)) { - throw new Error('cannot locate git-dir: ' + dir); - } - this.options['git-dir'] = dir; - } + constructor(public baseDir: string) { + var dir = path.join(baseDir, '.git'); + if (!fs.existsSync(dir)) { + throw new Error('cannot locate git-dir: ' + dir); + } + this.options['git-dir'] = dir; + } - getChanges(callback: (err, paths: string[]) => void): void { - //git diff --name-only HEAD~1 - var git = new Git(this.options); - var opts = {}; - var args = ['--name-only HEAD~1']; - git.exec('diff', opts, args, (err, msg: string) => { - if (err) { - callback(err, null); - return; - } - var paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); - // console.log(paths); - callback(null, paths); - }); - } - } + getChanges(callback: (err) => void): void { + //git diff --name-only HEAD~1 + var git = new Git(this.options); + var opts = {}; + var args = ['--name-only HEAD~1']; + git.exec('diff', opts, args, (err, msg: string) => { + if (err) { + callback(err); + return; + } + this.paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); + // console.log(paths); + callback(null); + }); + } + } } diff --git a/_infrastructure/tests/src/file.ts b/_infrastructure/tests/src/file.ts index bd7f62dc86..4bb81e9857 100644 --- a/_infrastructure/tests/src/file.ts +++ b/_infrastructure/tests/src/file.ts @@ -1,35 +1,39 @@ /// module DT { - var path = require('path'); + 'use-strict'; - ///////////////////////////////// - // Given a document root + ts file pattern this class returns: - // all the TS files OR just tests OR just definition files - ///////////////////////////////// - export class File { - dir: string; - file: string; - ext: string; - references: File[] = []; + var path = require('path'); - constructor(public baseDir: string, public filePathWithName: string) { - this.ext = path.extname(this.filePathWithName); - this.file = path.basename(this.filePathWithName, this.ext); - this.dir = path.dirname(this.filePathWithName); - } + ///////////////////////////////// + // Given a document root + ts file pattern this class returns: + // all the TS files OR just tests OR just definition files + ///////////////////////////////// + export class File { + baseDir: string; + filePathWithName: string; + dir: string; + file: string; + ext: string; + formatName: string; + fullPath: string; + references: File[] = []; - // From '/complete/path/to/file' to 'specfolder/specfile.d.ts' - public get formatName(): string { - return path.join(this.dir, this.file + this.ext); - } + constructor(baseDir: string, filePathWithName: string) { + this.baseDir = baseDir; + this.filePathWithName = filePathWithName; + this.ext = path.extname(this.filePathWithName); + this.file = path.basename(this.filePathWithName, this.ext); + this.dir = path.dirname(this.filePathWithName); + this.formatName = path.join(this.dir, this.file + this.ext); + this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext); - public get fullPath(): string { - return path.join(this.baseDir, this.dir, this.file + this.ext); - } + // lock it (shallow) + // Object.freeze(this); + } - toString() { - return '[File ' + this.filePathWithName + ']'; - } - } + toString() { + return '[File ' + this.filePathWithName + ']'; + } + } } diff --git a/_infrastructure/tests/src/host/exec.ts b/_infrastructure/tests/src/host/exec.ts index 9ff896c3f8..07a9d66626 100644 --- a/_infrastructure/tests/src/host/exec.ts +++ b/_infrastructure/tests/src/host/exec.ts @@ -15,32 +15,32 @@ // Allows for executing a program with command-line arguments and reading the result interface IExec { - exec: (filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void) => void; + exec: (filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void) => void; } class ExecResult { - public stdout = ""; - public stderr = ""; - public exitCode: number; + public stdout = ""; + public stderr = ""; + public exitCode: number; } class NodeExec implements IExec { - public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void): void { - var nodeExec = require('child_process').exec; + public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void): void { + var nodeExec = require('child_process').exec; - var result = new ExecResult(); - result.exitCode = null; - var cmdLine = filename + ' ' + cmdLineArgs.join(' '); + var result = new ExecResult(); + result.exitCode = null; + var cmdLine = filename + ' ' + cmdLineArgs.join(' '); - var process = nodeExec(cmdLine, {maxBuffer: 1 * 1024 * 1024}, function (error, stdout, stderr) { - result.stdout = stdout; - result.stderr = stderr; - result.exitCode = error ? error.code : 0; - handleResult(result); - }); - } + var process = nodeExec(cmdLine, {maxBuffer: 1 * 1024 * 1024}, function (error, stdout, stderr) { + result.stdout = stdout; + result.stderr = stderr; + result.exitCode = error ? error.code : 0; + handleResult(result); + }); + } } var Exec: IExec = function (): IExec { - return new NodeExec(); + return new NodeExec(); }(); diff --git a/_infrastructure/tests/src/index.ts b/_infrastructure/tests/src/index.ts index 4a40f35d49..7c9561af93 100644 --- a/_infrastructure/tests/src/index.ts +++ b/_infrastructure/tests/src/index.ts @@ -3,77 +3,91 @@ /// module DT { - var fs = require('fs'); - var path = require('path'); + 'use-strict'; - export class FileIndex { + var fs = require('fs'); + var path = require('path'); - fileMap: {[path:string]:File}; + export class FileIndex { - constructor(public options: ITestRunnerOptions) { + fileMap: {[path:string]:File + }; - } + constructor(public options: ITestRunnerOptions) { - parseFiles(files: File[], callback: () => void): void { - this.fileMap = Object.create(null); - files.forEach((file) => { - this.fileMap[file.fullPath] = file; - }); - this.loadReferences(files, () => { - callback(); - }); - } + } - private loadReferences(files: File[], callback: () => void): void { - var queue = files.slice(0); - var active = []; - var max = 50; - var next = () => { - if (queue.length === 0 && active.length === 0) { - callback(); - return; - } - // queue paralel - while (queue.length > 0 && active.length < max) { - var file = queue.pop(); - active.push(file); - this.parseFile(file, (file) => { - active.splice(active.indexOf(file), 1); - next(); - }); - } - }; - process.nextTick(next); - } + parseFiles(files: File[], callback: () => void): void { + this.fileMap = Object.create(null); + files.forEach((file) => { + this.fileMap[file.fullPath] = file; + }); + this.loadReferences(files, () => { + callback(); + }); + } - private parseFile(file: File, callback: (file: File) => void): void { - fs.readFile(file.filePathWithName, { - encoding: 'utf8', - flag: 'r' - }, (err, content) => { - if (err) { - // just blow up? - throw err; - } - // console.log('----'); - // console.log(file.filePathWithName); + hasFile(target: string): boolean { + return target in this.fileMap; + } - file.references = extractReferenceTags(content).map((ref: string) => { - return path.resolve(path.dirname(file.fullPath), ref); - }).reduce((memo: File[], ref: string) => { - if (ref in this.fileMap) { - memo.push(this.fileMap[ref]); - } - else { - console.log('not mapped? -> ' + ref); - } - return memo; - }, []); + getFile(target: string): File { + if (target in this.fileMap) { + return this.fileMap[target]; + } + return null; + } - // console.log(file.references); + private loadReferences(files: File[], callback: () => void): void { + var queue = files.slice(0); + var active = []; + var max = 50; + var next = () => { + if (queue.length === 0 && active.length === 0) { + callback(); + return; + } + // queue paralel + while (queue.length > 0 && active.length < max) { + var file = queue.pop(); + active.push(file); + this.parseFile(file, (file) => { + active.splice(active.indexOf(file), 1); + next(); + }); + } + }; + process.nextTick(next); + } - callback(file); - }); - } - } + private parseFile(file: File, callback: (file: File) => void): void { + fs.readFile(file.filePathWithName, { + encoding: 'utf8', + flag: 'r' + }, (err, content) => { + if (err) { + // just blow up? + throw err; + } + // console.log('----'); + // console.log(file.filePathWithName); + + file.references = extractReferenceTags(content).map((ref: string) => { + return path.resolve(path.dirname(file.fullPath), ref); + }).reduce((memo: File[], ref: string) => { + if (ref in this.fileMap) { + memo.push(this.fileMap[ref]); + } + else { + console.log('not mapped? -> ' + ref); + } + return memo; + }, []); + + // console.log(file.references); + + callback(file); + }); + } + } } diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts index 53274587ad..585ca5aa3a 100644 --- a/_infrastructure/tests/src/printer.ts +++ b/_infrastructure/tests/src/printer.ts @@ -2,110 +2,112 @@ /// module DT { - ///////////////////////////////// - // All the common things that we pring are functions of this class - ///////////////////////////////// - export class Print { + 'use-strict'; - WIDTH = 77; + ///////////////////////////////// + // All the common things that we pring are functions of this class + ///////////////////////////////// + export class Print { - constructor(public version: string, public typings: number, public tests: number, public tsFiles: number) { - } + WIDTH = 77; - public out(s: any): Print { - process.stdout.write(s); - return this; - } + constructor(public version: string, public typings: number, public tests: number, public tsFiles: number) { + } - public repeat(s: string, times: number): string { - return new Array(times + 1).join(s); - } + public out(s: any): Print { + process.stdout.write(s); + return this; + } - public printHeader() { - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); - this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); - this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); - this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); - this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); - } + public repeat(s: string, times: number): string { + return new Array(times + 1).join(s); + } - public printSuiteHeader(title: string) { - var left = Math.floor((this.WIDTH - title.length ) / 2) - 1; - var right = Math.ceil((this.WIDTH - title.length ) / 2) - 1; - this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); - this.out(title); - this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); - } + public printHeader() { + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); + this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); + this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); + this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); + } - public printDiv() { - this.out('-----------------------------------------------------------------------------\n'); - } + public printSuiteHeader(title: string) { + var left = Math.floor((this.WIDTH - title.length ) / 2) - 1; + var right = Math.ceil((this.WIDTH - title.length ) / 2) - 1; + this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); + this.out(title); + this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); + } - public printBoldDiv() { - this.out('=============================================================================\n'); - } + public printDiv() { + this.out('-----------------------------------------------------------------------------\n'); + } - public printErrorsHeader() { - this.out('=============================================================================\n'); - this.out(' \33[34m\33[1mErrors in files\33[0m \n'); - this.out('=============================================================================\n'); - } + public printBoldDiv() { + this.out('=============================================================================\n'); + } - public printErrorsForFile(testResult: TestResult) { - this.out('----------------- For file:' + testResult.targetFile.formatName); - this.printBreak().out(testResult.stderr).printBreak(); - } + public printErrorsHeader() { + this.out('=============================================================================\n'); + this.out(' \33[34m\33[1mErrors in files\33[0m \n'); + this.out('=============================================================================\n'); + } - public printBreak(): Print { - this.out('\n'); - return this; - } + public printErrorsForFile(testResult: TestResult) { + this.out('----------------- For file:' + testResult.targetFile.formatName); + this.printBreak().out(testResult.stderr).printBreak(); + } - public clearCurrentLine(): Print { - this.out("\r\33[K"); - return this; - } + public printBreak(): Print { + this.out('\n'); + return this; + } - public printSuccessCount(current: number, total: number) { - this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } + public clearCurrentLine(): Print { + this.out("\r\33[K"); + return this; + } - public printFailedCount(current: number, total: number) { - this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } + public printSuccessCount(current: number, total: number) { + this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } - public printTypingsWithoutTestsMessage() { - this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); - } + public printFailedCount(current: number, total: number) { + this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } - public printTotalMessage() { - this.out(' \33[36m\33[1mTotal\33[0m\n'); - } + public printTypingsWithoutTestsMessage() { + this.out(' \33[36m\33[1mTyping without tests\33[0m\n'); + } - public printElapsedTime(time: string, s: number) { - this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); - } + public printTotalMessage() { + this.out(' \33[36m\33[1mTotal\33[0m\n'); + } - public printSuiteErrorCount(errorHeadline: string, current: number, total: number, valuesColor = '\33[31m\33[1m') { - this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); - this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); - } + public printElapsedTime(time: string, s: number) { + this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); + } - public printTypingsWithoutTestName(file: string) { - this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); - } + public printSuiteErrorCount(errorHeadline: string, current: number, total: number, valuesColor = '\33[31m\33[1m') { + this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); + this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } - public printTypingsWithoutTest(withoutTestTypings: string[]) { - if (withoutTestTypings.length > 0) { - this.printTypingsWithoutTestsMessage(); + public printTypingsWithoutTestName(file: string) { + this.out(' - \33[33m\33[1m' + file + '\33[0m\n'); + } - this.printDiv(); - withoutTestTypings.forEach((t) => { - this.printTypingsWithoutTestName(t); - }); - } - } - } + public printTypingsWithoutTest(withoutTestTypings: string[]) { + if (withoutTestTypings.length > 0) { + this.printTypingsWithoutTestsMessage(); + + this.printDiv(); + withoutTestTypings.forEach((t) => { + this.printTypingsWithoutTestName(t); + }); + } + } + } } diff --git a/_infrastructure/tests/src/reporter/reporter.ts b/_infrastructure/tests/src/reporter/reporter.ts index 5f01c43ab5..edab8a6a04 100644 --- a/_infrastructure/tests/src/reporter/reporter.ts +++ b/_infrastructure/tests/src/reporter/reporter.ts @@ -2,38 +2,40 @@ /// module DT { - ///////////////////////////////// - // Test reporter interface - // for example, . and x - ///////////////////////////////// - export interface ITestReporter { - printPositiveCharacter(index: number, testResult: TestResult):void; - printNegativeCharacter(index: number, testResult: TestResult):void; - } + 'use-strict'; - ///////////////////////////////// - // Default test reporter - ///////////////////////////////// - export class DefaultTestReporter implements ITestReporter { - constructor(public print: Print) { - } + ///////////////////////////////// + // Test reporter interface + // for example, . and x + ///////////////////////////////// + export interface ITestReporter { + printPositiveCharacter(index: number, testResult: TestResult):void; + printNegativeCharacter(index: number, testResult: TestResult):void; + } - public printPositiveCharacter(index: number, testResult: TestResult) { - this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); + ///////////////////////////////// + // Default test reporter + ///////////////////////////////// + export class DefaultTestReporter implements ITestReporter { + constructor(public print: Print) { + } - this.printBreakIfNeeded(index); - } + public printPositiveCharacter(index: number, testResult: TestResult) { + this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); - public printNegativeCharacter(index: number, testResult: TestResult) { - this.print.out("x"); + this.printBreakIfNeeded(index); + } - this.printBreakIfNeeded(index); - } + public printNegativeCharacter(index: number, testResult: TestResult) { + this.print.out("x"); - private printBreakIfNeeded(index: number) { - if (index % this.print.WIDTH === 0) { - this.print.printBreak(); - } - } - } + this.printBreakIfNeeded(index); + } + + private printBreakIfNeeded(index: number) { + if (index % this.print.WIDTH === 0) { + this.print.printBreak(); + } + } + } } diff --git a/_infrastructure/tests/src/suite/suite.ts b/_infrastructure/tests/src/suite/suite.ts index 32013cce24..33d69af06e 100644 --- a/_infrastructure/tests/src/suite/suite.ts +++ b/_infrastructure/tests/src/suite/suite.ts @@ -1,83 +1,86 @@ /// module DT { - ///////////////////////////////// - // The interface for test suite - ///////////////////////////////// - export interface ITestSuite { - testSuiteName:string; - errorHeadline:string; - filterTargetFiles(files: File[]):File[]; + 'use-strict'; - start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void):void; + ///////////////////////////////// + // The interface for test suite + ///////////////////////////////// + export interface ITestSuite { + testSuiteName:string; + errorHeadline:string; + filterTargetFiles(files: File[]):File[]; - testResults:TestResult[]; - okTests:TestResult[]; - ngTests:TestResult[]; - timer:Timer; + start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void):void; - testReporter:ITestReporter; - printErrorCount:boolean; - } + testResults:TestResult[]; + okTests:TestResult[]; + ngTests:TestResult[]; + timer:Timer; - ///////////////////////////////// - // Base class for test suite - ///////////////////////////////// - export class TestSuiteBase implements ITestSuite { - timer: Timer = new Timer(); - testResults: TestResult[] = []; - testReporter: ITestReporter; - printErrorCount = true; + testReporter:ITestReporter; + printErrorCount:boolean; + } - constructor(public options: ITestRunnerOptions, public testSuiteName: string, public errorHeadline: string) { - } + ///////////////////////////////// + // Base class for test suite + ///////////////////////////////// + export class TestSuiteBase implements ITestSuite { + timer: Timer = new Timer(); + testResults: TestResult[] = []; + testReporter: ITestReporter; + printErrorCount = true; - public filterTargetFiles(files: File[]): File[] { - throw new Error("please implement this method"); - } + constructor(public options: ITestRunnerOptions, public testSuiteName: string, public errorHeadline: string) { + } - public start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void): void { - targetFiles = this.filterTargetFiles(targetFiles); - this.timer.start(); - var count = 0; - // exec test is async process. serialize. - var executor = () => { - var targetFile = targetFiles[count]; - if (targetFile) { - this.runTest(targetFile, (result) => { - testCallback(result, count + 1); - count++; - executor(); - }); - } else { - this.timer.end(); - this.finish(suiteCallback); - } - }; - executor(); - } + public filterTargetFiles(files: File[]): File[] { + throw new Error("please implement this method"); + } - public runTest(targetFile: File, callback: (result: TestResult) => void): void { - new Test(this, targetFile, {tscVersion: this.options.tscVersion}).run((result) => { - this.testResults.push(result); - callback(result); - }); - } + public start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void): void { + targetFiles = this.filterTargetFiles(targetFiles); + this.timer.start(); + var count = 0; + // exec test is async process. serialize. + var executor = () => { + var targetFile = targetFiles[count]; + if (targetFile) { + this.runTest(targetFile, (result) => { + testCallback(result, count + 1); + count++; + executor(); + }); + } + else { + this.timer.end(); + this.finish(suiteCallback); + } + }; + executor(); + } - public finish(suiteCallback: (suite: ITestSuite) => void) { - suiteCallback(this); - } + public runTest(targetFile: File, callback: (result: TestResult) => void): void { + new Test(this, targetFile, {tscVersion: this.options.tscVersion}).run((result) => { + this.testResults.push(result); + callback(result); + }); + } - public get okTests(): TestResult[] { - return this.testResults.filter((r) => { - return r.success; - }); - } + public finish(suiteCallback: (suite: ITestSuite) => void) { + suiteCallback(this); + } - public get ngTests(): TestResult[] { - return this.testResults.filter((r) => { - return !r.success - }); - } - } + public get okTests(): TestResult[] { + return this.testResults.filter((r) => { + return r.success; + }); + } + + public get ngTests(): TestResult[] { + return this.testResults.filter((r) => { + return !r.success + }); + } + } } diff --git a/_infrastructure/tests/src/suite/syntax.ts b/_infrastructure/tests/src/suite/syntax.ts index f36c26d99b..ff4b3bdb4b 100644 --- a/_infrastructure/tests/src/suite/syntax.ts +++ b/_infrastructure/tests/src/suite/syntax.ts @@ -2,19 +2,21 @@ /// module DT { - ///////////////////////////////// - // .d.ts syntax inspection - ///////////////////////////////// - export class SyntaxChecking extends TestSuiteBase { + 'use-strict'; - constructor(options: ITestRunnerOptions) { - super(options, "Syntax checking", "Syntax error"); - } + ///////////////////////////////// + // .d.ts syntax inspection + ///////////////////////////////// + export class SyntaxChecking extends TestSuiteBase { - public filterTargetFiles(files: File[]): File[] { - return files.filter((file) => { - return DT.endsWith(file.formatName.toUpperCase(), '.D.TS'); - }); - } - } + constructor(options: ITestRunnerOptions) { + super(options, "Syntax checking", "Syntax error"); + } + + public filterTargetFiles(files: File[]): File[] { + return files.filter((file) => { + return DT.endsWith(file.formatName.toUpperCase(), '.D.TS'); + }); + } + } } diff --git a/_infrastructure/tests/src/suite/testEval.ts b/_infrastructure/tests/src/suite/testEval.ts index 860e179431..13a6598874 100644 --- a/_infrastructure/tests/src/suite/testEval.ts +++ b/_infrastructure/tests/src/suite/testEval.ts @@ -2,20 +2,21 @@ /// module DT { - ///////////////////////////////// - // Compile with *-tests.ts - ///////////////////////////////// - export class TestEval extends TestSuiteBase { + 'use-strict'; + ///////////////////////////////// + // Compile with *-tests.ts + ///////////////////////////////// + export class TestEval extends TestSuiteBase { - constructor(options) { - super(options, "Typing tests", "Failed tests"); - } + constructor(options) { + super(options, "Typing tests", "Failed tests"); + } - public filterTargetFiles(files: File[]): File[] { - return files.filter((file) => { - return DT.endsWith(file.formatName.toUpperCase(), '-TESTS.TS') - }); - } - } + public filterTargetFiles(files: File[]): File[] { + return files.filter((file) => { + return DT.endsWith(file.formatName.toUpperCase(), '-TESTS.TS') + }); + } + } } diff --git a/_infrastructure/tests/src/suite/tscParams.ts b/_infrastructure/tests/src/suite/tscParams.ts index 510e15ce77..e4bb4f4c15 100644 --- a/_infrastructure/tests/src/suite/tscParams.ts +++ b/_infrastructure/tests/src/suite/tscParams.ts @@ -2,56 +2,58 @@ /// module DT { - var fs = require('fs'); + 'use-strict'; - ///////////////////////////////// - // Try compile without .tscparams - // It may indicate that it is compatible with --noImplicitAny maybe... - ///////////////////////////////// - export class FindNotRequiredTscparams extends TestSuiteBase { - testReporter: ITestReporter; - printErrorCount = false; + var fs = require('fs'); - constructor(options: ITestRunnerOptions, private print: Print) { - super(options, "Find not required .tscparams files", "New arrival!"); + ///////////////////////////////// + // Try compile without .tscparams + // It may indicate that it is compatible with --noImplicitAny maybe... + ///////////////////////////////// + export class FindNotRequiredTscparams extends TestSuiteBase { + testReporter: ITestReporter; + printErrorCount = false; - this.testReporter = { - printPositiveCharacter: (index: number, testResult: TestResult) => { - this.print - .clearCurrentLine() - .printTypingsWithoutTestName(testResult.targetFile.formatName); - }, - printNegativeCharacter: (index: number, testResult: TestResult) => { - } - } - } + constructor(options: ITestRunnerOptions, private print: Print) { + super(options, "Find not required .tscparams files", "New arrival!"); - public filterTargetFiles(files: File[]): File[] { - return files.filter((file) => { - return fs.existsSync(file.filePathWithName + '.tscparams'); - }); - } + this.testReporter = { + printPositiveCharacter: (index: number, testResult: TestResult) => { + this.print + .clearCurrentLine() + .printTypingsWithoutTestName(testResult.targetFile.formatName); + }, + printNegativeCharacter: (index: number, testResult: TestResult) => { + } + } + } - public runTest(targetFile: File, callback: (result: TestResult) => void): void { - this.print.clearCurrentLine().out(targetFile.formatName); - new Test(this, targetFile, { - tscVersion: this.options.tscVersion, - useTscParams: false, - checkNoImplicitAny: true - }).run(result=> { - this.testResults.push(result); - callback(result); - }); - } + public filterTargetFiles(files: File[]): File[] { + return files.filter((file) => { + return fs.existsSync(file.filePathWithName + '.tscparams'); + }); + } - public finish(suiteCallback: (suite: ITestSuite)=>void) { - this.print.clearCurrentLine(); - suiteCallback(this); - } + public runTest(targetFile: File, callback: (result: TestResult) => void): void { + this.print.clearCurrentLine().out(targetFile.formatName); + new Test(this, targetFile, { + tscVersion: this.options.tscVersion, + useTscParams: false, + checkNoImplicitAny: true + }).run(result=> { + this.testResults.push(result); + callback(result); + }); + } - public get ngTests(): TestResult[] { - // Do not show ng test results - return []; - } - } + public finish(suiteCallback: (suite: ITestSuite)=>void) { + this.print.clearCurrentLine(); + suiteCallback(this); + } + + public get ngTests(): TestResult[] { + // Do not show ng test results + return []; + } + } } diff --git a/_infrastructure/tests/src/timer.ts b/_infrastructure/tests/src/timer.ts index 446ea1b34f..1bf965a825 100644 --- a/_infrastructure/tests/src/timer.ts +++ b/_infrastructure/tests/src/timer.ts @@ -2,46 +2,48 @@ /// module DT { - ///////////////////////////////// - // Timer.start starts a timer - // Timer.end stops the timer and sets asString to the pretty print value - ///////////////////////////////// - export class Timer { - startTime: number; - time = 0; - asString: string; + 'use-strict'; - public start() { - this.time = 0; - this.startTime = this.now(); - } + ///////////////////////////////// + // Timer.start starts a timer + // Timer.end stops the timer and sets asString to the pretty print value + ///////////////////////////////// + export class Timer { + startTime: number; + time = 0; + asString: string; - public now(): number { - return Date.now(); - } + public start() { + this.time = 0; + this.startTime = this.now(); + } - public end() { - this.time = (this.now() - this.startTime) / 1000; - this.asString = Timer.prettyDate(this.startTime, this.now()); - } + public now(): number { + return Date.now(); + } - public static prettyDate(date1: number, date2: number): string { - var diff = ((date2 - date1) / 1000); - var day_diff = Math.floor(diff / 86400); + public end() { + this.time = (this.now() - this.startTime) / 1000; + this.asString = Timer.prettyDate(this.startTime, this.now()); + } - if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) { - return null; - } + public static prettyDate(date1: number, date2: number): string { + var diff = ((date2 - date1) / 1000); + var day_diff = Math.floor(diff / 86400); - return ( (day_diff == 0 && ( - diff < 60 && (diff + " seconds") || - diff < 120 && "1 minute" || - diff < 3600 && Math.floor(diff / 60) + " minutes" || - diff < 7200 && "1 hour" || - diff < 86400 && Math.floor(diff / 3600) + " hours") || - day_diff == 1 && "Yesterday" || - day_diff < 7 && day_diff + " days" || - day_diff < 31 && Math.ceil(day_diff / 7) + " weeks")); - } - } + if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) { + return null; + } + + return ( (day_diff == 0 && ( + diff < 60 && (diff + " seconds") || + diff < 120 && "1 minute" || + diff < 3600 && Math.floor(diff / 60) + " minutes" || + diff < 7200 && "1 hour" || + diff < 86400 && Math.floor(diff / 3600) + " hours") || + day_diff == 1 && "Yesterday" || + day_diff < 7 && day_diff + " days" || + day_diff < 31 && Math.ceil(day_diff / 7) + " weeks")); + } + } } diff --git a/_infrastructure/tests/src/tsc.ts b/_infrastructure/tests/src/tsc.ts index 6bd3fb2591..845b8557fe 100644 --- a/_infrastructure/tests/src/tsc.ts +++ b/_infrastructure/tests/src/tsc.ts @@ -3,42 +3,44 @@ /// module DT { - var fs = require('fs'); + 'use-strict'; + var fs = require('fs'); - export interface TscExecOptions { - tscVersion?:string; - useTscParams?:boolean; - checkNoImplicitAny?:boolean; - } + export interface TscExecOptions { + tscVersion?:string; + useTscParams?:boolean; + checkNoImplicitAny?:boolean; + } - export class Tsc { - public static run(tsfile: string, options: TscExecOptions, callback: (result: ExecResult) => void) { - options = options || {}; - options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION; - if (typeof options.checkNoImplicitAny === "undefined") { - options.checkNoImplicitAny = true; - } - if (typeof options.useTscParams === "undefined") { - options.useTscParams = true; - } + export class Tsc { + public static run(tsfile: string, options: TscExecOptions, callback: (result: ExecResult) => void) { + options = options || {}; + options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION; + if (typeof options.checkNoImplicitAny === "undefined") { + options.checkNoImplicitAny = true; + } + if (typeof options.useTscParams === "undefined") { + options.useTscParams = true; + } - if (!fs.existsSync(tsfile)) { - throw new Error(tsfile + " not exists"); - } + if (!fs.existsSync(tsfile)) { + throw new Error(tsfile + " not exists"); + } - var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!fs.existsSync(tscPath)) { - throw new Error(tscPath + ' is not exists'); - } - var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { - command += '@' + tsfile + '.tscparams'; - } else if (options.checkNoImplicitAny) { - command += '--noImplicitAny'; - } - Exec.exec(command, [tsfile], (execResult) => { - callback(execResult); - }); - } - } + var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; + if (!fs.existsSync(tscPath)) { + throw new Error(tscPath + ' is not exists'); + } + var command = 'node ' + tscPath + ' --module commonjs '; + if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { + command += '@' + tsfile + '.tscparams'; + } + else if (options.checkNoImplicitAny) { + command += '--noImplicitAny'; + } + Exec.exec(command, [tsfile], (execResult) => { + callback(execResult); + }); + } + } } diff --git a/_infrastructure/tests/src/util.ts b/_infrastructure/tests/src/util.ts index 3d63ce1421..39115b1eb4 100644 --- a/_infrastructure/tests/src/util.ts +++ b/_infrastructure/tests/src/util.ts @@ -1,27 +1,28 @@ /// module DT { + 'use-strict'; - var referenceTagExp = //g; + var referenceTagExp = //g; - export function endsWith(str: string, suffix: string) { - return str.indexOf(suffix, str.length - suffix.length) !== -1; - } + export function endsWith(str: string, suffix: string) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } - export function extractReferenceTags(source: string): string[] { - var ret: string[] = []; - var match: RegExpExecArray; + export function extractReferenceTags(source: string): string[] { + var ret: string[] = []; + var match: RegExpExecArray; - if (!referenceTagExp.global) { - throw new Error('referenceTagExp RegExp must have global flag'); - } - referenceTagExp.lastIndex = 0; + if (!referenceTagExp.global) { + throw new Error('referenceTagExp RegExp must have global flag'); + } + referenceTagExp.lastIndex = 0; - while ((match = referenceTagExp.exec(source))) { - if (match.length > 0 && match[1].length > 0) { - ret.push(match[1]); - } - } - return ret; - } + while ((match = referenceTagExp.exec(source))) { + if (match.length > 0 && match[1].length > 0) { + ret.push(match[1]); + } + } + return ret; + } } From 461def4a53233621a6ef8d8bc8b2eed77ed98c4a Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 27 Feb 2014 22:35:19 +0100 Subject: [PATCH 232/240] added definitions for test-module amaze --- test-module/test-addon.ts | 5 +++++ test-module/test-module.d.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 test-module/test-addon.ts diff --git a/test-module/test-addon.ts b/test-module/test-addon.ts new file mode 100644 index 0000000000..14c5ba0d6f --- /dev/null +++ b/test-module/test-addon.ts @@ -0,0 +1,5 @@ +/// + +declare module 'test-addon' { + export function addon(): Such; +} diff --git a/test-module/test-module.d.ts b/test-module/test-module.d.ts index e73a9981c2..4ec2bdda49 100644 --- a/test-module/test-module.d.ts +++ b/test-module/test-module.d.ts @@ -1,6 +1,6 @@ +interface Such { + amaze(): void; +} declare module 'test-module' { - interface Such { - amaze(): void; - } export function wow(): Such; } From c47743cdd50253082404dec95edfac7a88c0fc72 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 27 Feb 2014 22:47:23 +0100 Subject: [PATCH 233/240] added method to test-module --- test-module/test-module.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test-module/test-module.d.ts b/test-module/test-module.d.ts index 4ec2bdda49..294e7ea433 100644 --- a/test-module/test-module.d.ts +++ b/test-module/test-module.d.ts @@ -1,5 +1,6 @@ interface Such { amaze(): void; + much(): void; } declare module 'test-module' { export function wow(): Such; From ca2fa0719bc77a96bb0e8fa571da8c2696489a06 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Fri, 28 Feb 2014 20:57:07 +0100 Subject: [PATCH 234/240] converted tester to promises & lazy iteration added bluebird & lazy.js dependencies checking-in used definitions added tsd.json parallelized async with bluebird most iteration uses lazy.js re-factored test flow to promise structure (instead of chain) renamed some stuff linted some quotes cleaned up output added some color --- .gitignore | 11 +- _infrastructure/tests/_ref.d.ts | 2 +- _infrastructure/tests/runner.js | 784 +++++----- _infrastructure/tests/runner.ts | 352 ++--- _infrastructure/tests/src/changes.ts | 19 +- _infrastructure/tests/src/exec.ts | 30 + _infrastructure/tests/src/file.ts | 5 +- _infrastructure/tests/src/host/exec.ts | 46 - _infrastructure/tests/src/index.ts | 107 +- _infrastructure/tests/src/printer.ts | 62 +- .../tests/src/reporter/reporter.ts | 4 +- _infrastructure/tests/src/suite/suite.ts | 51 +- _infrastructure/tests/src/suite/syntax.ts | 16 +- _infrastructure/tests/src/suite/testEval.ts | 17 +- _infrastructure/tests/src/suite/tscParams.ts | 32 +- _infrastructure/tests/src/timer.ts | 18 +- _infrastructure/tests/src/tsc.ts | 63 +- _infrastructure/tests/src/util.ts | 14 +- .../tests/typings/bluebird/bluebird.d.ts | 655 +++++++++ .../tests/typings/lazy.js/lazy.js.d.ts | 252 ++++ _infrastructure/tests/typings/node/node.d.ts | 1258 +++++++++++++++++ _infrastructure/tests/typings/tsd.d.ts | 3 + package.json | 4 +- tsd.json | 15 + 24 files changed, 3054 insertions(+), 766 deletions(-) create mode 100644 _infrastructure/tests/src/exec.ts delete mode 100644 _infrastructure/tests/src/host/exec.ts create mode 100644 _infrastructure/tests/typings/bluebird/bluebird.d.ts create mode 100644 _infrastructure/tests/typings/lazy.js/lazy.js.d.ts create mode 100644 _infrastructure/tests/typings/node/node.d.ts create mode 100644 _infrastructure/tests/typings/tsd.d.ts create mode 100644 tsd.json diff --git a/.gitignore b/.gitignore index 548f1e3979..8fc575c216 100644 --- a/.gitignore +++ b/.gitignore @@ -29,8 +29,9 @@ Properties !_infrastructure/tests/*/*.js !_infrastructure/tests/*/*/*.js !_infrastructure/tests/*/*/*/*.js - -.idea -*.iml - -node_modules + +.idea +*.iml +*.js.map + +node_modules diff --git a/_infrastructure/tests/_ref.d.ts b/_infrastructure/tests/_ref.d.ts index 1743cad05c..5a0809f3b8 100644 --- a/_infrastructure/tests/_ref.d.ts +++ b/_infrastructure/tests/_ref.d.ts @@ -1 +1 @@ -/// +/// diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index 1a7c4fc987..b11be80a39 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -1,53 +1,41 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +var DT; +(function (DT) { + 'use strict'; -var ExecResult = (function () { - function ExecResult() { - this.stdout = ""; - this.stderr = ""; - } - return ExecResult; -})(); + var Promise = require('bluebird'); + var nodeExec = require('child_process').exec; -var NodeExec = (function () { - function NodeExec() { - } - NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) { - var nodeExec = require('child_process').exec; + var ExecResult = (function () { + function ExecResult() { + this.stdout = ''; + this.stderr = ''; + } + return ExecResult; + })(); + DT.ExecResult = ExecResult; - var result = new ExecResult(); - result.exitCode = null; - var cmdLine = filename + ' ' + cmdLineArgs.join(' '); + function exec(filename, cmdLineArgs) { + return new Promise(function (resolve) { + var result = new ExecResult(); + result.exitCode = null; - var process = nodeExec(cmdLine, { maxBuffer: 1 * 1024 * 1024 }, function (error, stdout, stderr) { - result.stdout = stdout; - result.stderr = stderr; - result.exitCode = error ? error.code : 0; - handleResult(result); + var cmdLine = filename + ' ' + cmdLineArgs.join(' '); + + nodeExec(cmdLine, { maxBuffer: 1 * 1024 * 1024 }, function (error, stdout, stderr) { + result.error = error; + result.stdout = stdout; + result.stderr = stderr; + result.exitCode = error ? error.code : 0; + resolve(result); + }); }); - }; - return NodeExec; -})(); - -var Exec = function () { - return new NodeExec(); -}(); + } + DT.exec = exec; +})(DT || (DT = {})); /// var DT; (function (DT) { - 'use-strict'; + 'use strict'; var path = require('path'); @@ -58,6 +46,7 @@ var DT; var File = (function () { function File(baseDir, filePathWithName) { this.references = []; + // why choose? this.baseDir = baseDir; this.filePathWithName = filePathWithName; this.ext = path.extname(this.filePathWithName); @@ -65,7 +54,7 @@ var DT; this.dir = path.dirname(this.filePathWithName); this.formatName = path.join(this.dir, this.file + this.ext); this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext); - // lock it (shallow) + // lock it (shallow) (needs `use strict` in each file to work) // Object.freeze(this); } File.prototype.toString = function () { @@ -75,43 +64,44 @@ var DT; })(); DT.File = File; })(DT || (DT = {})); -/// -/// -/// +/// +/// +/// var DT; (function (DT) { - 'use-strict'; + 'use strict'; + var fs = require('fs'); + var Promise = require('bluebird'); + var Tsc = (function () { function Tsc() { } - Tsc.run = function (tsfile, options, callback) { - options = options || {}; - options.tscVersion = options.tscVersion || DT.DEFAULT_TSC_VERSION; - if (typeof options.checkNoImplicitAny === "undefined") { - options.checkNoImplicitAny = true; - } - if (typeof options.useTscParams === "undefined") { - options.useTscParams = true; - } - - if (!fs.existsSync(tsfile)) { - throw new Error(tsfile + " not exists"); - } - - var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!fs.existsSync(tscPath)) { - throw new Error(tscPath + ' is not exists'); - } - var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { - command += '@' + tsfile + '.tscparams'; - } else if (options.checkNoImplicitAny) { - command += '--noImplicitAny'; - } - Exec.exec(command, [tsfile], function (execResult) { - callback(execResult); + Tsc.run = function (tsfile, options) { + return Promise.attempt(function () { + options = options || {}; + options.tscVersion = options.tscVersion || DT.DEFAULT_TSC_VERSION; + if (typeof options.checkNoImplicitAny === 'undefined') { + options.checkNoImplicitAny = true; + } + if (typeof options.useTscParams === 'undefined') { + options.useTscParams = true; + } + if (!fs.existsSync(tsfile)) { + throw new Error(tsfile + ' not exists'); + } + var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; + if (!fs.existsSync(tscPath)) { + throw new Error(tscPath + ' is not exists'); + } + var command = 'node ' + tscPath + ' --module commonjs '; + if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { + command += '@' + tsfile + '.tscparams'; + } else if (options.checkNoImplicitAny) { + command += '--noImplicitAny'; + } + return DT.exec(command, [tsfile]); }); }; return Tsc; @@ -122,7 +112,7 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; + 'use strict'; ///////////////////////////////// // Timer.start starts a timer @@ -154,7 +144,7 @@ var DT; return null; } - return (day_diff == 0 && (diff < 60 && (diff + " seconds") || diff < 120 && "1 minute" || diff < 3600 && Math.floor(diff / 60) + " minutes" || diff < 7200 && "1 hour" || diff < 86400 && Math.floor(diff / 3600) + " hours") || day_diff == 1 && "Yesterday" || day_diff < 7 && day_diff + " days" || day_diff < 31 && Math.ceil(day_diff / 7) + " weeks"); + return (day_diff == 0 && (diff < 60 && (diff + ' seconds') || diff < 120 && '1 minute' || diff < 3600 && Math.floor(diff / 60) + ' minutes' || diff < 7200 && '1 hour' || diff < 86400 && Math.floor(diff / 3600) + ' hours') || day_diff == 1 && 'Yesterday' || day_diff < 7 && day_diff + ' days' || day_diff < 31 && Math.ceil(day_diff / 7) + ' weeks'); }; return Timer; })(); @@ -163,7 +153,11 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; + 'use strict'; + + var fs = require('fs'); + var Lazy = require('lazy.js'); + var Promise = require('bluebird'); var referenceTagExp = //g; @@ -189,32 +183,37 @@ var DT; return ret; } DT.extractReferenceTags = extractReferenceTags; + + function fileExists(target) { + return new Promise(function (resolve, reject) { + fs.exists(target, function (bool) { + resolve(bool); + }); + }); + } + DT.fileExists = fileExists; })(DT || (DT = {})); /// /// /// var DT; (function (DT) { - 'use-strict'; + 'use strict'; var fs = require('fs'); var path = require('path'); + var Lazy = require('lazy.js'); + var Promise = require('bluebird'); + var readFile = Promise.promisify(fs.readFile); + + ///////////////////////////////// + // Track all files in the repo: map full path to File objects + ///////////////////////////////// var FileIndex = (function () { function FileIndex(options) { this.options = options; } - FileIndex.prototype.parseFiles = function (files, callback) { - var _this = this; - this.fileMap = Object.create(null); - files.forEach(function (file) { - _this.fileMap[file.fullPath] = file; - }); - this.loadReferences(files, function () { - callback(); - }); - }; - FileIndex.prototype.hasFile = function (target) { return target in this.fileMap; }; @@ -226,42 +225,54 @@ var DT; return null; }; - FileIndex.prototype.loadReferences = function (files, callback) { + FileIndex.prototype.parseFiles = function (files) { var _this = this; - var queue = files.slice(0); - var active = []; - var max = 50; - var next = function () { - if (queue.length === 0 && active.length === 0) { - callback(); - return; - } - - while (queue.length > 0 && active.length < max) { - var file = queue.pop(); - active.push(file); - _this.parseFile(file, function (file) { - active.splice(active.indexOf(file), 1); - next(); - }); - } - }; - process.nextTick(next); + return Promise.attempt(function () { + _this.fileMap = Object.create(null); + files.forEach(function (file) { + _this.fileMap[file.fullPath] = file; + }); + return _this.loadReferences(files); + }); }; - FileIndex.prototype.parseFile = function (file, callback) { + FileIndex.prototype.loadReferences = function (files) { var _this = this; - fs.readFile(file.filePathWithName, { + return new Promise(function (resolve, reject) { + var queue = files.slice(0); + var active = []; + var max = 50; + var next = function () { + if (queue.length === 0 && active.length === 0) { + resolve(); + return; + } + + while (queue.length > 0 && active.length < max) { + var file = queue.pop(); + active.push(file); + _this.parseFile(file).then(function (file) { + active.splice(active.indexOf(file), 1); + next(); + }).catch(function (err) { + queue = []; + active = []; + reject(err); + }); + } + }; + next(); + }); + }; + + // TODO replace with a stream? + FileIndex.prototype.parseFile = function (file) { + var _this = this; + return readFile(file.filePathWithName, { encoding: 'utf8', flag: 'r' - }, function (err, content) { - if (err) { - throw err; - } - - // console.log('----'); - // console.log(file.filePathWithName); - file.references = DT.extractReferenceTags(content).map(function (ref) { + }).then(function (content) { + file.references = Lazy(DT.extractReferenceTags(content)).map(function (ref) { return path.resolve(path.dirname(file.fullPath), ref); }).reduce(function (memo, ref) { if (ref in _this.fileMap) { @@ -272,8 +283,8 @@ var DT; return memo; }, []); - // console.log(file.references); - callback(file); + // return the object + return file; }); }; return FileIndex; @@ -283,11 +294,12 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; + 'use strict'; var fs = require('fs'); var path = require('path'); var Git = require('git-wrapper'); + var Promise = require('bluebird'); var GitChanges = (function () { function GitChanges(baseDir) { @@ -299,22 +311,16 @@ var DT; throw new Error('cannot locate git-dir: ' + dir); } this.options['git-dir'] = dir; + + this.git = new Git(this.options); + this.git.exec = Promise.promisify(this.git.exec); } - GitChanges.prototype.getChanges = function (callback) { + GitChanges.prototype.getChanges = function () { var _this = this; - //git diff --name-only HEAD~1 - var git = new Git(this.options); var opts = {}; var args = ['--name-only HEAD~1']; - git.exec('diff', opts, args, function (err, msg) { - if (err) { - callback(err); - return; - } + return this.git.exec('diff', opts, args).then(function (msg) { _this.paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); - - // console.log(paths); - callback(null); }); }; return GitChanges; @@ -325,19 +331,20 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; - ///////////////////////////////// - // All the common things that we pring are functions of this class + // All the common things that we print are functions of this class ///////////////////////////////// var Print = (function () { - function Print(version, typings, tests, tsFiles) { + function Print(version) { this.version = version; + this.WIDTH = 77; + } + Print.prototype.init = function (typings, tests, tsFiles) { this.typings = typings; this.tests = tests; this.tsFiles = tsFiles; - this.WIDTH = 77; - } + }; + Print.prototype.out = function (s) { process.stdout.write(s); return this; @@ -347,9 +354,15 @@ var DT; return new Array(times + 1).join(s); }; + Print.prototype.printChangeHeader = function () { + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n'); + this.out('=============================================================================\n'); + }; + Print.prototype.printHeader = function () { this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); + this.out(' \33[36m\33[1mDefinitelyTyped Test Runner 0.5.0\33[0m\n'); this.out('=============================================================================\n'); this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); @@ -360,9 +373,9 @@ var DT; Print.prototype.printSuiteHeader = function (title) { var left = Math.floor((this.WIDTH - title.length) / 2) - 1; var right = Math.ceil((this.WIDTH - title.length) / 2) - 1; - this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); + this.out(this.repeat('=', left)).out(' \33[34m\33[1m'); this.out(title); - this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); + this.out('\33[0m ').out(this.repeat('=', right)).printBreak(); }; Print.prototype.printDiv = function () { @@ -390,16 +403,18 @@ var DT; }; Print.prototype.clearCurrentLine = function () { - this.out("\r\33[K"); + this.out('\r\33[K'); return this; }; Print.prototype.printSuccessCount = function (current, total) { - this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + var arb = (total === 0) ? 0 : (current / total); + this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); }; Print.prototype.printFailedCount = function (current, total) { - this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + var arb = (total === 0) ? 0 : (current / total); + this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); }; Print.prototype.printTypingsWithoutTestsMessage = function () { @@ -414,10 +429,31 @@ var DT; this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); }; - Print.prototype.printSuiteErrorCount = function (errorHeadline, current, total, valuesColor) { - if (typeof valuesColor === "undefined") { valuesColor = '\33[31m\33[1m'; } + Print.prototype.printSuiteErrorCount = function (errorHeadline, current, total, warn) { + if (typeof warn === "undefined") { warn = false; } + var arb = (total === 0) ? 0 : (current / total); this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); - this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + if (warn) { + this.out(': \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } else { + this.out(': \33[33m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + }; + + Print.prototype.printSubHeader = function (file) { + this.out(' \33[36m\33[1m' + file + '\33[0m\n'); + }; + + Print.prototype.printLine = function (file) { + this.out(file + '\n'); + }; + + Print.prototype.printElement = function (file) { + this.out(' - ' + file + '\n'); + }; + + Print.prototype.printElement2 = function (file) { + this.out(' - ' + file + '\n'); }; Print.prototype.printTypingsWithoutTestName = function (file) { @@ -443,8 +479,6 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; - ///////////////////////////////// @@ -461,7 +495,7 @@ var DT; }; DefaultTestReporter.prototype.printNegativeCharacter = function (index, testResult) { - this.print.out("x"); + this.print.out('x'); this.printBreakIfNeeded(index); }; @@ -478,7 +512,9 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; + 'use strict'; + + var Promise = require('bluebird'); @@ -495,42 +531,31 @@ var DT; this.printErrorCount = true; } TestSuiteBase.prototype.filterTargetFiles = function (files) { - throw new Error("please implement this method"); + throw new Error('please implement this method'); }; - TestSuiteBase.prototype.start = function (targetFiles, testCallback, suiteCallback) { + TestSuiteBase.prototype.start = function (targetFiles, testCallback) { var _this = this; - targetFiles = this.filterTargetFiles(targetFiles); this.timer.start(); - var count = 0; - - // exec test is async process. serialize. - var executor = function () { - var targetFile = targetFiles[count]; - if (targetFile) { - _this.runTest(targetFile, function (result) { + return this.filterTargetFiles(targetFiles).then(function (targetFiles) { + return Promise.reduce(targetFiles, function (count, targetFile) { + return _this.runTest(targetFile).then(function (result) { testCallback(result, count + 1); - count++; - executor(); + return count++; }); - } else { - _this.timer.end(); - _this.finish(suiteCallback); - } - }; - executor(); - }; - - TestSuiteBase.prototype.runTest = function (targetFile, callback) { - var _this = this; - new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion }).run(function (result) { - _this.testResults.push(result); - callback(result); + }, 0); + }).then(function (count) { + _this.timer.end(); + return _this; }); }; - TestSuiteBase.prototype.finish = function (suiteCallback) { - suiteCallback(this); + TestSuiteBase.prototype.runTest = function (targetFile) { + var _this = this; + return new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion }).run().then(function (result) { + _this.testResults.push(result); + return result; + }); }; Object.defineProperty(TestSuiteBase.prototype, "okTests", { @@ -566,7 +591,11 @@ var __extends = this.__extends || function (d, b) { }; var DT; (function (DT) { - 'use-strict'; + 'use strict'; + + var Promise = require('bluebird'); + + var endDts = /.ts$/i; ///////////////////////////////// // .d.ts syntax inspection @@ -574,12 +603,12 @@ var DT; var SyntaxChecking = (function (_super) { __extends(SyntaxChecking, _super); function SyntaxChecking(options) { - _super.call(this, options, "Syntax checking", "Syntax error"); + _super.call(this, options, 'Syntax checking', 'Syntax error'); } SyntaxChecking.prototype.filterTargetFiles = function (files) { - return files.filter(function (file) { - return DT.endsWith(file.formatName.toUpperCase(), '.D.TS'); - }); + return Promise.cast(files.filter(function (file) { + return endDts.test(file.formatName); + })); }; return SyntaxChecking; })(DT.TestSuiteBase); @@ -589,7 +618,11 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; + 'use strict'; + + var Promise = require('bluebird'); + + var endTestDts = /-test.ts$/i; ///////////////////////////////// // Compile with *-tests.ts @@ -597,24 +630,25 @@ var DT; var TestEval = (function (_super) { __extends(TestEval, _super); function TestEval(options) { - _super.call(this, options, "Typing tests", "Failed tests"); + _super.call(this, options, 'Typing tests', 'Failed tests'); } TestEval.prototype.filterTargetFiles = function (files) { - return files.filter(function (file) { - return DT.endsWith(file.formatName.toUpperCase(), '-TESTS.TS'); - }); + return Promise.cast(files.filter(function (file) { + return endTestDts.test(file.formatName); + })); }; return TestEval; })(DT.TestSuiteBase); DT.TestEval = TestEval; })(DT || (DT = {})); -/// -/// +/// +/// var DT; (function (DT) { - 'use-strict'; + 'use strict'; var fs = require('fs'); + var Promise = require('bluebird'); ///////////////////////////////// // Try compile without .tscparams @@ -624,7 +658,7 @@ var DT; __extends(FindNotRequiredTscparams, _super); function FindNotRequiredTscparams(options, print) { var _this = this; - _super.call(this, options, "Find not required .tscparams files", "New arrival!"); + _super.call(this, options, 'Find not required .tscparams files', 'New arrival!'); this.print = print; this.printErrorCount = false; @@ -637,29 +671,28 @@ var DT; }; } FindNotRequiredTscparams.prototype.filterTargetFiles = function (files) { - return files.filter(function (file) { - return fs.existsSync(file.filePathWithName + '.tscparams'); + return Promise.filter(files, function (file) { + return new Promise(function (resolve) { + fs.exists(file.filePathWithName + '.tscparams', resolve); + }); }); }; - FindNotRequiredTscparams.prototype.runTest = function (targetFile, callback) { + FindNotRequiredTscparams.prototype.runTest = function (targetFile) { var _this = this; this.print.clearCurrentLine().out(targetFile.formatName); - new DT.Test(this, targetFile, { + + return new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true - }).run(function (result) { + }).run().then(function (result) { _this.testResults.push(result); - callback(result); + _this.print.clearCurrentLine(); + return result; }); }; - FindNotRequiredTscparams.prototype.finish = function (suiteCallback) { - this.print.clearCurrentLine(); - suiteCallback(this); - }; - Object.defineProperty(FindNotRequiredTscparams.prototype, "ngTests", { get: function () { // Do not show ng test results @@ -672,8 +705,8 @@ var DT; })(DT.TestSuiteBase); DT.FindNotRequiredTscparams = FindNotRequiredTscparams; })(DT || (DT = {})); -/// -/// +/// +/// /// /// /// @@ -688,27 +721,33 @@ var DT; /// var DT; (function (DT) { - 'use-strict'; - require('source-map-support').install(); + // hacky typing + var Lazy = require('lazy.js'); + var Promise = require('bluebird'); + var fs = require('fs'); var path = require('path'); var glob = require('glob'); + var assert = require('assert'); var tsExp = /\.ts$/; - DT.DEFAULT_TSC_VERSION = "0.9.1.1"; + DT.DEFAULT_TSC_VERSION = '0.9.1.1'; + ///////////////////////////////// + // Single test + ///////////////////////////////// var Test = (function () { function Test(suite, tsfile, options) { this.suite = suite; this.tsfile = tsfile; this.options = options; } - Test.prototype.run = function (callback) { + Test.prototype.run = function () { var _this = this; - DT.Tsc.run(this.tsfile.filePathWithName, this.options, function (execResult) { + return DT.Tsc.run(this.tsfile.filePathWithName, this.options).then(function (execResult) { var testResult = new TestResult(); testResult.hostedBy = _this.suite; testResult.targetFile = _this.tsfile; @@ -718,7 +757,7 @@ var DT; testResult.stderr = execResult.stderr; testResult.exitCode = execResult.exitCode; - callback(testResult); + return testResult; }); }; return Test; @@ -745,12 +784,9 @@ var DT; ///////////////////////////////// // The main class to kick things off ///////////////////////////////// - // TODO move to bluebird (Promises) - // TODO move to lazy.js (functional) var TestRunner = (function () { function TestRunner(dtPath, options) { if (typeof options === "undefined") { options = { tscVersion: DT.DEFAULT_TSC_VERSION }; } - var _this = this; this.dtPath = dtPath; this.options = options; this.suites = []; @@ -758,28 +794,12 @@ var DT; this.index = new DT.FileIndex(this.options); this.changes = new DT.GitChanges(this.dtPath); - - // should be async (way faster) - // only includes .d.ts or -tests.ts or -test.ts or .ts - var filesName = glob.sync('**/*.ts', { cwd: dtPath }); - this.files = filesName.filter(function (fileName) { - return _this.checkAcceptFile(fileName); - }).sort().map(function (fileName) { - return new DT.File(dtPath, fileName); - }); + this.print = new DT.Print(this.options.tscVersion); } TestRunner.prototype.addSuite = function (suite) { this.suites.push(suite); }; - TestRunner.prototype.run = function () { - this.timer = new DT.Timer(); - this.timer.start(); - - // we need promises - this.doGetChanges(); - }; - TestRunner.prototype.checkAcceptFile = function (fileName) { var ok = tsExp.test(fileName); ok = ok && fileName.indexOf('_infrastructure') < 0; @@ -788,155 +808,181 @@ var DT; return ok; }; - TestRunner.prototype.doGetChanges = function () { + TestRunner.prototype.run = function () { var _this = this; - this.changes.getChanges(function (err) { - if (err) { - throw err; - } - console.log(''); - console.log('changes:'); - console.log('---'); + this.timer = new DT.Timer(); + this.timer.start(); - _this.changes.paths.forEach(function (file) { - console.log(file); + // only includes .d.ts or -tests.ts or -test.ts or .ts + return Promise.promisify(glob).call(glob, '**/*.ts', { + cwd: dtPath + }).then(function (filesNames) { + _this.files = Lazy(filesNames).filter(function (fileName) { + return _this.checkAcceptFile(fileName); + }).map(function (fileName) { + return new DT.File(dtPath, fileName); + }).toArray(); + + _this.print.printChangeHeader(); + + return Promise.all([ + _this.doParseFiles(), + _this.doGetChanges() + ]); + }).then(function () { + return _this.doCollectTargets(); + }).then(function (files) { + return _this.runTests(files); + }).then(function () { + return !_this.suites.some(function (suite) { + return suite.ngTests.length !== 0; }); - console.log('---'); - - // chain - _this.doGetReferences(); }); }; - TestRunner.prototype.doGetReferences = function () { - var _this = this; - this.index.parseFiles(this.files, function () { - console.log(''); - console.log('files:'); - console.log('---'); - _this.files.forEach(function (file) { - console.log(file.filePathWithName); - file.references.forEach(function (file) { - console.log(' - %s', file.filePathWithName); - }); + TestRunner.prototype.doParseFiles = function () { + return this.index.parseFiles(this.files).then(function () { + /* + this.print.printSubHeader('Files:'); + this.print.printDiv(); + this.files.forEach((file) => { + this.print.printLine(file.filePathWithName); + file.references.forEach((file) => { + this.print.printElement(file.filePathWithName); }); - console.log('---'); - + }); + this.print.printBreak();*/ // chain - _this.doCollectTargets(); - }); + }).thenReturn(); + }; + + TestRunner.prototype.doGetChanges = function () { + var _this = this; + return this.changes.getChanges().then(function () { + _this.print.printSubHeader('All changes'); + _this.print.printDiv(); + + Lazy(_this.changes.paths).each(function (file) { + _this.print.printLine(file); + }); + }).thenReturn(); }; TestRunner.prototype.doCollectTargets = function () { - // TODO clean this up when functional (do we need changeMap?) var _this = this; - // bake map for lookup - var changeMap = this.changes.paths.filter(function (full) { - return _this.checkAcceptFile(full); - }).map(function (local) { - return path.resolve(_this.dtPath, local); - }).reduce(function (memo, full) { - var file = _this.index.getFile(full); - if (!file) { - // what does it mean? deleted? - console.log('not in index: ' + full); - return memo; - } - memo[full] = file; - return memo; - }, Object.create(null)); + return new Promise(function (resolve) { + // bake map for lookup + var changeMap = Object.create(null); - // collect referring files (and also log) - var touched = Object.create(null); - console.log(''); - console.log('relevant changes:'); - console.log('---'); - Object.keys(changeMap).sort().forEach(function (src) { - touched[src] = changeMap[src]; - console.log(changeMap[src].formatName); - }); - console.log('---'); - - // terrible loop (whatever) - // just add stuff until there is nothing new added - // TODO improve it - var added; - do { - added = 0; - this.files.forEach(function (file) { - // lol getter - if (file.fullPath in touched) { + Lazy(_this.changes.paths).filter(function (full) { + return _this.checkAcceptFile(full); + }).map(function (local) { + return path.resolve(_this.dtPath, local); + }).each(function (full) { + var file = _this.index.getFile(full); + if (!file) { + // TODO figure out what to do here + // what does it mean? deleted? + console.log('not in index: ' + full); return; } - - // check if one of our references is touched - file.references.some(function (ref) { - if (ref.fullPath in touched) { - // add us - touched[file.fullPath] = file; - added++; - return true; - } - return false; - }); + changeMap[full] = file; }); - } while(added > 0); - console.log(''); - console.log('touched:'); - console.log('---'); - var files = Object.keys(touched).sort().map(function (src) { - console.log(touched[src].formatName); - return touched[src]; + _this.print.printDiv(); + _this.print.printSubHeader('Relevant changes'); + _this.print.printDiv(); + + Object.keys(changeMap).sort().forEach(function (src) { + _this.print.printLine(changeMap[src].formatName); + }); + + // terrible loop (whatever) + // just add stuff until there is nothing new added + // TODO improve it + var added; + var files = _this.files.slice(0); + do { + added = 0; + + for (var i = files.length - 1; i >= 0; i--) { + var file = files[i]; + if (file.fullPath in changeMap) { + _this.files.splice(i, 1); + continue; + } + + for (var j = 0, jj = file.references.length; j < jj; j++) { + if (file.references[j].fullPath in changeMap) { + // add us + changeMap[file.fullPath] = file; + added++; + break; + } + } + } + } while(added > 0); + + _this.print.printDiv(); + _this.print.printSubHeader('Reference mapped'); + _this.print.printDiv(); + + var result = Object.keys(changeMap).sort().map(function (src) { + _this.print.printLine(changeMap[src].formatName); + changeMap[src].references.forEach(function (file) { + _this.print.printElement(file.formatName); + }); + return changeMap[src]; + }); + resolve(result); }); - console.log('---'); - - this.runTests(files); }; TestRunner.prototype.runTests = function (files) { var _this = this; - var syntaxChecking = new DT.SyntaxChecking(this.options); - var testEval = new DT.TestEval(this.options); - if (!this.options.findNotRequiredTscparams) { - this.addSuite(syntaxChecking); - this.addSuite(testEval); - } + return Promise.attempt(function () { + assert(Array.isArray(files), 'files must be array'); - var typings = syntaxChecking.filterTargetFiles(files).length; - var testFiles = testEval.filterTargetFiles(files).length; + var syntaxChecking = new DT.SyntaxChecking(_this.options); + var testEval = new DT.TestEval(_this.options); - this.print = new DT.Print(this.options.tscVersion, typings, testFiles, files.length); - this.print.printHeader(); + if (!_this.options.findNotRequiredTscparams) { + _this.addSuite(syntaxChecking); + _this.addSuite(testEval); + } - if (this.options.findNotRequiredTscparams) { - this.addSuite(new DT.FindNotRequiredTscparams(this.options, this.print)); - } + return Promise.all([ + syntaxChecking.filterTargetFiles(files), + testEval.filterTargetFiles(files) + ]); + }).spread(function (syntaxFiles, testFiles) { + _this.print.init(syntaxFiles.length, testFiles.length, files.length); + _this.print.printHeader(); - var count = 0; - var executor = function () { - var suite = _this.suites[count]; - if (suite) { + if (_this.options.findNotRequiredTscparams) { + _this.addSuite(new DT.FindNotRequiredTscparams(_this.options, _this.print)); + } + + return Promise.reduce(_this.suites, function (count, suite) { suite.testReporter = suite.testReporter || new DT.DefaultTestReporter(_this.print); _this.print.printSuiteHeader(suite.testSuiteName); - var targetFiles = suite.filterTargetFiles(files); - suite.start(targetFiles, function (testResult, index) { - _this.testCompleteCallback(testResult, index); - }, function (suite) { - _this.suiteCompleteCallback(suite); - count++; - executor(); + return suite.filterTargetFiles(files).then(function (targetFiles) { + return suite.start(targetFiles, function (testResult, index) { + _this.printTestComplete(testResult, index); + }); + }).then(function (suite) { + _this.printSuiteComplete(suite); + return count++; }); - } else { - _this.timer.end(); - _this.allTestCompleteCallback(files); - } - }; - executor(); + }, 0); + }).then(function (count) { + _this.timer.end(); + _this.finaliseTests(files); + }); }; - TestRunner.prototype.testCompleteCallback = function (testResult, index) { + TestRunner.prototype.printTestComplete = function (testResult, index) { var reporter = testResult.hostedBy.testReporter; if (testResult.success) { reporter.printPositiveCharacter(index, testResult); @@ -945,7 +991,7 @@ var DT; } }; - TestRunner.prototype.suiteCompleteCallback = function (suite) { + TestRunner.prototype.printSuiteComplete = function (suite) { this.print.printBreak(); this.print.printDiv(); @@ -954,19 +1000,20 @@ var DT; this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); }; - TestRunner.prototype.allTestCompleteCallback = function (files) { + TestRunner.prototype.finaliseTests = function (files) { var _this = this; - var testEval = this.suites.filter(function (suite) { + var testEval = Lazy(this.suites).filter(function (suite) { return suite instanceof DT.TestEval; - })[0]; + }).first(); + if (testEval) { - var existsTestTypings = testEval.testResults.map(function (testResult) { + var existsTestTypings = Lazy(testEval.testResults).map(function (testResult) { return testResult.targetFile.dir; }).reduce(function (a, b) { return a.indexOf(b) < 0 ? a.concat([b]) : a; }, []); - var typings = files.map(function (file) { + var typings = Lazy(files).map(function (file) { return file.dir; }).reduce(function (a, b) { return a.indexOf(b) < 0 ? a.concat([b]) : a; @@ -975,6 +1022,7 @@ var DT; var withoutTestTypings = typings.filter(function (typing) { return existsTestTypings.indexOf(typing) < 0; }); + this.print.printDiv(); this.print.printTypingsWithoutTest(withoutTestTypings); } @@ -991,10 +1039,11 @@ var DT; _this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length); }); if (testEval) { - this.print.printSuiteErrorCount("Without tests", withoutTestTypings.length, typings.length, '\33[33m\33[1m'); + this.print.printSuiteErrorCount('Without tests', withoutTestTypings.length, typings.length, true); } this.print.printDiv(); + if (this.suites.some(function (suite) { return suite.ngTests.length !== 0; })) { @@ -1008,8 +1057,6 @@ var DT; }); _this.print.printBoldDiv(); }); - - process.exit(1); } }; return TestRunner; @@ -1018,25 +1065,26 @@ var DT; var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); var findNotRequiredTscparams = process.argv.some(function (arg) { - return arg == "--try-without-tscparams"; + return arg == '--try-without-tscparams'; }); - var tscVersionIndex = process.argv.indexOf("--tsc-version"); + var tscVersionIndex = process.argv.indexOf('--tsc-version'); var tscVersion = DT.DEFAULT_TSC_VERSION; - if (-1 < tscVersionIndex) { + + if (tscVersionIndex > -1) { tscVersion = process.argv[tscVersionIndex + 1]; } - console.log('--'); - console.log(' dtPath %s', dtPath); - console.log(' tscVersion %s', tscVersion); - console.log(' findNotRequiredTscparams %s', findNotRequiredTscparams); - console.log('--'); - console.log(''); - var runner = new TestRunner(dtPath, { tscVersion: tscVersion, findNotRequiredTscparams: findNotRequiredTscparams }); - runner.run(); + runner.run().then(function (success) { + if (!success) { + process.exit(1); + } + }).catch(function (err) { + throw err; + process.exit(2); + }); })(DT || (DT = {})); //# sourceMappingURL=runner.js.map diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index f2ca6a0592..4f3a4389c9 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -1,6 +1,6 @@ -/// +/// -/// +/// /// /// @@ -19,24 +19,30 @@ /// module DT { - 'use-strict'; - require('source-map-support').install(); + // hacky typing + var Lazy: LazyJS.LazyStatic = require('lazy.js'); + var Promise: typeof Promise = require('bluebird'); + var fs = require('fs'); var path = require('path'); var glob = require('glob'); + var assert = require('assert'); var tsExp = /\.ts$/; - export var DEFAULT_TSC_VERSION = "0.9.1.1"; + export var DEFAULT_TSC_VERSION = '0.9.1.1'; + ///////////////////////////////// + // Single test + ///////////////////////////////// export class Test { constructor(public suite: ITestSuite, public tsfile: File, public options?: TscExecOptions) { } - public run(callback: (result: TestResult) => void) { - Tsc.run(this.tsfile.filePathWithName, this.options, (execResult) => { + public run(): Promise { + return Tsc.run(this.tsfile.filePathWithName, this.options).then((execResult: ExecResult) => { var testResult = new TestResult(); testResult.hostedBy = this.suite; testResult.targetFile = this.tsfile; @@ -46,7 +52,7 @@ module DT { testResult.stderr = execResult.stderr; testResult.exitCode = execResult.exitCode; - callback(testResult); + return testResult; }); } } @@ -76,12 +82,10 @@ module DT { ///////////////////////////////// // The main class to kick things off ///////////////////////////////// - // TODO move to bluebird (Promises) - // TODO move to lazy.js (functional) export class TestRunner { - files: File[]; - timer: Timer; - suites: ITestSuite[] = []; + private files: File[]; + private timer: Timer; + private suites: ITestSuite[] = []; private index: FileIndex; private changes: GitChanges; @@ -92,29 +96,13 @@ module DT { this.index = new FileIndex(this.options); this.changes = new GitChanges(this.dtPath); - - // should be async (way faster) - // only includes .d.ts or -tests.ts or -test.ts or .ts - var filesName = glob.sync('**/*.ts', { cwd: dtPath }); - this.files = filesName.filter((fileName) => { - return this.checkAcceptFile(fileName); - }).sort().map((fileName) => { - return new File(dtPath, fileName); - }); + this.print = new Print(this.options.tscVersion); } public addSuite(suite: ITestSuite): void { this.suites.push(suite); } - public run(): void { - this.timer = new Timer(); - this.timer.start(); - - // we need promises - this.doGetChanges(); - } - private checkAcceptFile(fileName: string): boolean { var ok = tsExp.test(fileName); ok = ok && fileName.indexOf('_infrastructure') < 0; @@ -123,155 +111,179 @@ module DT { return ok; } - private doGetChanges(): void { - this.changes.getChanges((err) => { - if (err) { - throw err; - } - console.log(''); - console.log('changes:'); - console.log('---'); + public run(): Promise { + this.timer = new Timer(); + this.timer.start(); - this.changes.paths.forEach((file) => { - console.log(file); + // only includes .d.ts or -tests.ts or -test.ts or .ts + return Promise.promisify(glob).call(glob, '**/*.ts', { + cwd: dtPath + }).then((filesNames: string[]) => { + this.files = Lazy(filesNames).filter((fileName) => { + return this.checkAcceptFile(fileName); + }).map((fileName: string) => { + return new File(dtPath, fileName); + }).toArray(); + + this.print.printChangeHeader(); + + return Promise.all([ + this.doParseFiles(), + this.doGetChanges() + ]); + }).then(() => { + return this.doCollectTargets(); + }).then((files) => { + return this.runTests(files); + }).then(() => { + return !this.suites.some((suite) => { + return suite.ngTests.length !== 0 }); - console.log('---'); - - // chain - this.doGetReferences(); }); } - private doGetReferences(): void { - this.index.parseFiles(this.files, () => { - console.log(''); - console.log('files:'); - console.log('---'); - this.files.forEach((file) => { - console.log(file.filePathWithName); - file.references.forEach((file) => { - console.log(' - %s', file.filePathWithName); - }); - }); - console.log('---'); - + private doParseFiles(): Promise { + return this.index.parseFiles(this.files).then(() => { + /* + this.print.printSubHeader('Files:'); + this.print.printDiv(); + this.files.forEach((file) => { + this.print.printLine(file.filePathWithName); + file.references.forEach((file) => { + this.print.printElement(file.filePathWithName); + }); + }); + this.print.printBreak();*/ // chain - this.doCollectTargets(); - }); + }).thenReturn(); } - private doCollectTargets(): void { + private doGetChanges(): Promise { + return this.changes.getChanges().then(() => { + this.print.printSubHeader('All changes'); + this.print.printDiv(); - // TODO clean this up when functional (do we need changeMap?) + Lazy(this.changes.paths).each((file) => { + this.print.printLine(file); + }); + }).thenReturn(); + } - // bake map for lookup - var changeMap = this.changes.paths.filter((full) => { - return this.checkAcceptFile(full); - }).map((local) => { - return path.resolve(this.dtPath, local); - }).reduce((memo, full) => { - var file = this.index.getFile(full); - if (!file) { - // what does it mean? deleted? - console.log('not in index: ' + full); - return memo; - } - memo[full] = file; - return memo; - }, Object.create(null)); + private doCollectTargets(): Promise { + return new Promise((resolve) => { - // collect referring files (and also log) - var touched = Object.create(null); - console.log(''); - console.log('relevant changes:'); - console.log('---'); - Object.keys(changeMap).sort().forEach((src) => { - touched[src] = changeMap[src]; - console.log(changeMap[src].formatName); - }); - console.log('---'); + // bake map for lookup + var changeMap = Object.create(null); - // terrible loop (whatever) - // just add stuff until there is nothing new added - // TODO improve it - var added:number; - do { - added = 0; - this.files.forEach((file) => { - // lol getter - if (file.fullPath in touched) { + Lazy(this.changes.paths).filter((full) => { + return this.checkAcceptFile(full); + }).map((local) => { + return path.resolve(this.dtPath, local); + }).each((full) => { + var file = this.index.getFile(full); + if (!file) { + // TODO figure out what to do here + // what does it mean? deleted? + console.log('not in index: ' + full); return; } - // check if one of our references is touched - file.references.some((ref) => { - if (ref.fullPath in touched) { - // add us - touched[file.fullPath] = file; - added++; - return true; - } - return false; - }); + changeMap[full] = file; }); - } - while(added > 0); - console.log(''); - console.log('touched:'); - console.log('---'); - var files: File[] = Object.keys(touched).sort().map((src) => { - console.log(touched[src].formatName); - return touched[src]; + this.print.printDiv(); + this.print.printSubHeader('Relevant changes'); + this.print.printDiv(); + + Object.keys(changeMap).sort().forEach((src) => { + this.print.printLine(changeMap[src].formatName); + }); + + // terrible loop (whatever) + // just add stuff until there is nothing new added + // TODO improve it + var added: number; + var files = this.files.slice(0); + do { + added = 0; + + for (var i = files.length - 1; i >= 0; i--) { + var file = files[i]; + if (file.fullPath in changeMap) { + this.files.splice(i, 1); + continue; + } + // check if one of our references is touched + for (var j = 0, jj = file.references.length; j < jj; j++) { + if (file.references[j].fullPath in changeMap) { + // add us + changeMap[file.fullPath] = file; + added++; + break; + } + } + } + } + while (added > 0); + + this.print.printDiv(); + this.print.printSubHeader('Reference mapped'); + this.print.printDiv(); + + var result: File[] = Object.keys(changeMap).sort().map((src) => { + this.print.printLine(changeMap[src].formatName); + changeMap[src].references.forEach((file: File) => { + this.print.printElement(file.formatName); + }); + return changeMap[src]; + }); + resolve(result); }); - console.log('---'); - - this.runTests(files); } - private runTests(files: File[]): void { + private runTests(files: File[]): Promise { + return Promise.attempt(() => { + assert(Array.isArray(files), 'files must be array'); - var syntaxChecking = new SyntaxChecking(this.options); - var testEval = new TestEval(this.options); - if (!this.options.findNotRequiredTscparams) { - this.addSuite(syntaxChecking); - this.addSuite(testEval); - } + var syntaxChecking = new SyntaxChecking(this.options); + var testEval = new TestEval(this.options); - var typings = syntaxChecking.filterTargetFiles(files).length; - var testFiles = testEval.filterTargetFiles(files).length; + if (!this.options.findNotRequiredTscparams) { + this.addSuite(syntaxChecking); + this.addSuite(testEval); + } - this.print = new Print(this.options.tscVersion, typings, testFiles, files.length); - this.print.printHeader(); + return Promise.all([ + syntaxChecking.filterTargetFiles(files), + testEval.filterTargetFiles(files) + ]); + }).spread((syntaxFiles, testFiles) => { + this.print.init(syntaxFiles.length, testFiles.length, files.length); + this.print.printHeader(); - if (this.options.findNotRequiredTscparams) { - this.addSuite(new FindNotRequiredTscparams(this.options, this.print)); - } + if (this.options.findNotRequiredTscparams) { + this.addSuite(new FindNotRequiredTscparams(this.options, this.print)); + } - var count = 0; - var executor = () => { - var suite = this.suites[count]; - if (suite) { + return Promise.reduce(this.suites, (count, suite: ITestSuite) => { suite.testReporter = suite.testReporter || new DefaultTestReporter(this.print); this.print.printSuiteHeader(suite.testSuiteName); - var targetFiles = suite.filterTargetFiles(files); - suite.start(targetFiles, (testResult, index) => { - this.testCompleteCallback(testResult, index); - }, (suite) => { - this.suiteCompleteCallback(suite); - count++; - executor(); + return suite.filterTargetFiles(files).then((targetFiles) => { + return suite.start(targetFiles, (testResult, index) => { + this.printTestComplete(testResult, index); + }); + }).then((suite) => { + this.printSuiteComplete(suite); + return count++; }); - } - else { - this.timer.end(); - this.allTestCompleteCallback(files); - } - }; - executor(); + }, 0); + }).then((count) => { + this.timer.end(); + this.finaliseTests(files); + }); } - private testCompleteCallback(testResult: TestResult, index: number) { + private printTestComplete(testResult: TestResult, index: number): void { var reporter = testResult.hostedBy.testReporter; if (testResult.success) { reporter.printPositiveCharacter(index, testResult); @@ -281,7 +293,7 @@ module DT { } } - private suiteCompleteCallback(suite: ITestSuite) { + private printSuiteComplete(suite: ITestSuite): void { this.print.printBreak(); this.print.printDiv(); @@ -290,16 +302,19 @@ module DT { this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); } - private allTestCompleteCallback(files: File[]) { - var testEval = this.suites.filter(suite => suite instanceof TestEval)[0]; + private finaliseTests(files: File[]): void { + var testEval: TestEval = Lazy(this.suites).filter((suite) => { + return suite instanceof TestEval; + }).first(); + if (testEval) { - var existsTestTypings: string[] = testEval.testResults.map((testResult) => { + var existsTestTypings: string[] = Lazy(testEval.testResults).map((testResult) => { return testResult.targetFile.dir; }).reduce((a: string[], b: string) => { return a.indexOf(b) < 0 ? a.concat([b]) : a; }, []); - var typings: string[] = files.map((file) => { + var typings: string[] = Lazy(files).map((file) => { return file.dir; }).reduce((a: string[], b: string) => { return a.indexOf(b) < 0 ? a.concat([b]) : a; @@ -308,6 +323,7 @@ module DT { var withoutTestTypings: string[] = typings.filter((typing) => { return existsTestTypings.indexOf(typing) < 0; }); + this.print.printDiv(); this.print.printTypingsWithoutTest(withoutTestTypings); } @@ -324,10 +340,11 @@ module DT { this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length); }); if (testEval) { - this.print.printSuiteErrorCount("Without tests", withoutTestTypings.length, typings.length, '\33[33m\33[1m'); + this.print.printSuiteErrorCount('Without tests', withoutTestTypings.length, typings.length, true); } this.print.printDiv(); + if (this.suites.some((suite) => { return suite.ngTests.length !== 0 })) { @@ -341,30 +358,29 @@ module DT { }); this.print.printBoldDiv(); }); - - process.exit(1); } } } var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); - var findNotRequiredTscparams = process.argv.some(arg => arg == "--try-without-tscparams"); - var tscVersionIndex = process.argv.indexOf("--tsc-version"); + var findNotRequiredTscparams = process.argv.some(arg => arg == '--try-without-tscparams'); + var tscVersionIndex = process.argv.indexOf('--tsc-version'); var tscVersion = DEFAULT_TSC_VERSION; - if (-1 < tscVersionIndex) { + + if (tscVersionIndex > -1) { tscVersion = process.argv[tscVersionIndex + 1]; } - console.log('--'); - console.log(' dtPath %s', dtPath); - console.log(' tscVersion %s', tscVersion); - console.log(' findNotRequiredTscparams %s', findNotRequiredTscparams); - console.log('--'); - console.log(''); - var runner = new TestRunner(dtPath, { tscVersion: tscVersion, findNotRequiredTscparams: findNotRequiredTscparams }); - runner.run(); + runner.run().then((success) => { + if (!success) { + process.exit(1); + } + }).catch((err) => { + throw err; + process.exit(2); + }); } diff --git a/_infrastructure/tests/src/changes.ts b/_infrastructure/tests/src/changes.ts index 3bc7334e02..f3ec262084 100644 --- a/_infrastructure/tests/src/changes.ts +++ b/_infrastructure/tests/src/changes.ts @@ -1,14 +1,16 @@ /// module DT { - 'use-strict'; + 'use strict'; var fs = require('fs'); var path = require('path'); var Git = require('git-wrapper'); + var Promise: typeof Promise = require('bluebird'); export class GitChanges { + git; options = {}; paths: string[] = []; @@ -18,21 +20,16 @@ module DT { throw new Error('cannot locate git-dir: ' + dir); } this.options['git-dir'] = dir; + + this.git = new Git(this.options); + this.git.exec = Promise.promisify(this.git.exec); } - getChanges(callback: (err) => void): void { - //git diff --name-only HEAD~1 - var git = new Git(this.options); + getChanges(): Promise { var opts = {}; var args = ['--name-only HEAD~1']; - git.exec('diff', opts, args, (err, msg: string) => { - if (err) { - callback(err); - return; - } + return this.git.exec('diff', opts, args).then((msg: string) => { this.paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); - // console.log(paths); - callback(null); }); } } diff --git a/_infrastructure/tests/src/exec.ts b/_infrastructure/tests/src/exec.ts new file mode 100644 index 0000000000..3c3f3c0e02 --- /dev/null +++ b/_infrastructure/tests/src/exec.ts @@ -0,0 +1,30 @@ +module DT { + 'use strict'; + + var Promise: typeof Promise = require('bluebird'); + var nodeExec = require('child_process').exec; + + export class ExecResult { + error; + stdout = ''; + stderr = ''; + exitCode: number; + } + + export function exec(filename: string, cmdLineArgs: string[]): Promise { + return new Promise((resolve) => { + var result = new ExecResult(); + result.exitCode = null; + + var cmdLine = filename + ' ' + cmdLineArgs.join(' '); + + nodeExec(cmdLine, {maxBuffer: 1 * 1024 * 1024}, (error, stdout, stderr) => { + result.error = error; + result.stdout = stdout; + result.stderr = stderr; + result.exitCode = error ? error.code : 0; + resolve(result); + }); + }); + } +} diff --git a/_infrastructure/tests/src/file.ts b/_infrastructure/tests/src/file.ts index 4bb81e9857..389936b491 100644 --- a/_infrastructure/tests/src/file.ts +++ b/_infrastructure/tests/src/file.ts @@ -1,7 +1,7 @@ /// module DT { - 'use-strict'; + 'use strict'; var path = require('path'); @@ -20,6 +20,7 @@ module DT { references: File[] = []; constructor(baseDir: string, filePathWithName: string) { + // why choose? this.baseDir = baseDir; this.filePathWithName = filePathWithName; this.ext = path.extname(this.filePathWithName); @@ -28,7 +29,7 @@ module DT { this.formatName = path.join(this.dir, this.file + this.ext); this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext); - // lock it (shallow) + // lock it (shallow) (needs `use strict` in each file to work) // Object.freeze(this); } diff --git a/_infrastructure/tests/src/host/exec.ts b/_infrastructure/tests/src/host/exec.ts deleted file mode 100644 index 07a9d66626..0000000000 --- a/_infrastructure/tests/src/host/exec.ts +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// Allows for executing a program with command-line arguments and reading the result -interface IExec { - exec: (filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void) => void; -} - -class ExecResult { - public stdout = ""; - public stderr = ""; - public exitCode: number; -} - -class NodeExec implements IExec { - public exec(filename: string, cmdLineArgs: string[], handleResult: (ExecResult) => void): void { - var nodeExec = require('child_process').exec; - - var result = new ExecResult(); - result.exitCode = null; - var cmdLine = filename + ' ' + cmdLineArgs.join(' '); - - var process = nodeExec(cmdLine, {maxBuffer: 1 * 1024 * 1024}, function (error, stdout, stderr) { - result.stdout = stdout; - result.stderr = stderr; - result.exitCode = error ? error.code : 0; - handleResult(result); - }); - } -} - -var Exec: IExec = function (): IExec { - return new NodeExec(); -}(); diff --git a/_infrastructure/tests/src/index.ts b/_infrastructure/tests/src/index.ts index 7c9561af93..183c1e64db 100644 --- a/_infrastructure/tests/src/index.ts +++ b/_infrastructure/tests/src/index.ts @@ -3,28 +3,25 @@ /// module DT { - 'use-strict'; + 'use strict'; var fs = require('fs'); var path = require('path'); + var Lazy = require('lazy.js'); + var Promise: typeof Promise = require('bluebird'); + var readFile = Promise.promisify(fs.readFile); + + ///////////////////////////////// + // Track all files in the repo: map full path to File objects + ///////////////////////////////// export class FileIndex { - fileMap: {[path:string]:File - }; + fileMap: {[fullPath:string]:File}; + options: ITestRunnerOptions; - constructor(public options: ITestRunnerOptions) { - - } - - parseFiles(files: File[], callback: () => void): void { - this.fileMap = Object.create(null); - files.forEach((file) => { - this.fileMap[file.fullPath] = file; - }); - this.loadReferences(files, () => { - callback(); - }); + constructor(options: ITestRunnerOptions) { + this.options = options; } hasFile(target: string): boolean { @@ -38,43 +35,53 @@ module DT { return null; } - private loadReferences(files: File[], callback: () => void): void { - var queue = files.slice(0); - var active = []; - var max = 50; - var next = () => { - if (queue.length === 0 && active.length === 0) { - callback(); - return; - } - // queue paralel - while (queue.length > 0 && active.length < max) { - var file = queue.pop(); - active.push(file); - this.parseFile(file, (file) => { - active.splice(active.indexOf(file), 1); - next(); - }); - } - }; - process.nextTick(next); + parseFiles(files: File[]): Promise { + return Promise.attempt(() => { + this.fileMap = Object.create(null); + files.forEach((file) => { + this.fileMap[file.fullPath] = file; + }); + return this.loadReferences(files); + }); } - private parseFile(file: File, callback: (file: File) => void): void { - fs.readFile(file.filePathWithName, { + private loadReferences(files: File[]): Promise { + return new Promise((resolve, reject) => { + var queue = files.slice(0); + var active = []; + var max = 50; + var next = () => { + if (queue.length === 0 && active.length === 0) { + resolve(); + return; + } + // queue paralel + while (queue.length > 0 && active.length < max) { + var file = queue.pop(); + active.push(file); + this.parseFile(file).then((file) => { + active.splice(active.indexOf(file), 1); + next(); + }).catch((err) => { + queue = []; + active = []; + reject(err); + }); + } + }; + next(); + }); + } + + // TODO replace with a stream? + private parseFile(file: File): Promise { + return readFile(file.filePathWithName, { encoding: 'utf8', flag: 'r' - }, (err, content) => { - if (err) { - // just blow up? - throw err; - } - // console.log('----'); - // console.log(file.filePathWithName); - - file.references = extractReferenceTags(content).map((ref: string) => { + }).then((content) => { + file.references = Lazy(extractReferenceTags(content)).map((ref) => { return path.resolve(path.dirname(file.fullPath), ref); - }).reduce((memo: File[], ref: string) => { + }).reduce((memo: File[], ref) => { if (ref in this.fileMap) { memo.push(this.fileMap[ref]); } @@ -83,10 +90,8 @@ module DT { } return memo; }, []); - - // console.log(file.references); - - callback(file); + // return the object + return file; }); } } diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts index 585ca5aa3a..613251b825 100644 --- a/_infrastructure/tests/src/printer.ts +++ b/_infrastructure/tests/src/printer.ts @@ -2,16 +2,26 @@ /// module DT { - 'use-strict'; ///////////////////////////////// - // All the common things that we pring are functions of this class + // All the common things that we print are functions of this class ///////////////////////////////// export class Print { WIDTH = 77; - constructor(public version: string, public typings: number, public tests: number, public tsFiles: number) { + typings: number; + tests: number; + tsFiles: number + + constructor(public version: string){ + + } + + public init(typings: number, tests: number, tsFiles: number) { + this.typings = typings; + this.tests = tests; + this.tsFiles = tsFiles; } public out(s: any): Print { @@ -23,9 +33,15 @@ module DT { return new Array(times + 1).join(s); } + public printChangeHeader() { + this.out('=============================================================================\n'); + this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n'); + this.out('=============================================================================\n'); + } + public printHeader() { this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.4.0\33[0m\n'); + this.out(' \33[36m\33[1mDefinitelyTyped Test Runner 0.5.0\33[0m\n'); this.out('=============================================================================\n'); this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n'); this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); @@ -36,9 +52,9 @@ module DT { public printSuiteHeader(title: string) { var left = Math.floor((this.WIDTH - title.length ) / 2) - 1; var right = Math.ceil((this.WIDTH - title.length ) / 2) - 1; - this.out(this.repeat("=", left)).out(" \33[34m\33[1m"); + this.out(this.repeat('=', left)).out(' \33[34m\33[1m'); this.out(title); - this.out("\33[0m ").out(this.repeat("=", right)).printBreak(); + this.out('\33[0m ').out(this.repeat('=', right)).printBreak(); } public printDiv() { @@ -66,16 +82,18 @@ module DT { } public clearCurrentLine(): Print { - this.out("\r\33[K"); + this.out('\r\33[K'); return this; } public printSuccessCount(current: number, total: number) { - this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + var arb = (total === 0) ? 0 : (current / total); + this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); } public printFailedCount(current: number, total: number) { - this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + var arb = (total === 0) ? 0 : (current / total); + this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); } public printTypingsWithoutTestsMessage() { @@ -90,9 +108,31 @@ module DT { this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n'); } - public printSuiteErrorCount(errorHeadline: string, current: number, total: number, valuesColor = '\33[31m\33[1m') { + public printSuiteErrorCount(errorHeadline: string, current: number, total: number, warn: boolean = false) { + var arb = (total === 0) ? 0 : (current / total); this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length)); - this.out(':\33[0m ' + valuesColor + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + if (warn) { + this.out(': \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + else { + this.out(': \33[33m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n'); + } + } + + public printSubHeader(file: string) { + this.out(' \33[36m\33[1m' + file + '\33[0m\n'); + } + + public printLine(file: string) { + this.out(file + '\n'); + } + + public printElement(file: string) { + this.out(' - ' + file + '\n'); + } + + public printElement2(file: string) { + this.out(' - ' + file + '\n'); } public printTypingsWithoutTestName(file: string) { diff --git a/_infrastructure/tests/src/reporter/reporter.ts b/_infrastructure/tests/src/reporter/reporter.ts index edab8a6a04..783eae287a 100644 --- a/_infrastructure/tests/src/reporter/reporter.ts +++ b/_infrastructure/tests/src/reporter/reporter.ts @@ -2,8 +2,6 @@ /// module DT { - 'use-strict'; - ///////////////////////////////// // Test reporter interface // for example, . and x @@ -27,7 +25,7 @@ module DT { } public printNegativeCharacter(index: number, testResult: TestResult) { - this.print.out("x"); + this.print.out('x'); this.printBreakIfNeeded(index); } diff --git a/_infrastructure/tests/src/suite/suite.ts b/_infrastructure/tests/src/suite/suite.ts index 33d69af06e..4de10ce1d6 100644 --- a/_infrastructure/tests/src/suite/suite.ts +++ b/_infrastructure/tests/src/suite/suite.ts @@ -1,7 +1,9 @@ /// module DT { - 'use-strict'; + 'use strict'; + + var Promise: typeof Promise = require('bluebird'); ///////////////////////////////// // The interface for test suite @@ -9,9 +11,9 @@ module DT { export interface ITestSuite { testSuiteName:string; errorHeadline:string; - filterTargetFiles(files: File[]):File[]; + filterTargetFiles(files: File[]): Promise; - start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void):void; + start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void): Promise; testResults:TestResult[]; okTests:TestResult[]; @@ -34,41 +36,30 @@ module DT { constructor(public options: ITestRunnerOptions, public testSuiteName: string, public errorHeadline: string) { } - public filterTargetFiles(files: File[]): File[] { - throw new Error("please implement this method"); + public filterTargetFiles(files: File[]): Promise { + throw new Error('please implement this method'); } - public start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void, suiteCallback: (suite: ITestSuite) => void): void { - targetFiles = this.filterTargetFiles(targetFiles); + public start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void): Promise { this.timer.start(); - var count = 0; - // exec test is async process. serialize. - var executor = () => { - var targetFile = targetFiles[count]; - if (targetFile) { - this.runTest(targetFile, (result) => { + return this.filterTargetFiles(targetFiles).then((targetFiles) => { + return Promise.reduce(targetFiles, (count, targetFile) => { + return this.runTest(targetFile).then((result) => { testCallback(result, count + 1); - count++; - executor(); + return count++; }); - } - else { - this.timer.end(); - this.finish(suiteCallback); - } - }; - executor(); - } - - public runTest(targetFile: File, callback: (result: TestResult) => void): void { - new Test(this, targetFile, {tscVersion: this.options.tscVersion}).run((result) => { - this.testResults.push(result); - callback(result); + }, 0); + }).then((count: number) => { + this.timer.end(); + return this; }); } - public finish(suiteCallback: (suite: ITestSuite) => void) { - suiteCallback(this); + public runTest(targetFile: File): Promise { + return new Test(this, targetFile, {tscVersion: this.options.tscVersion}).run().then((result) => { + this.testResults.push(result); + return result; + }); } public get okTests(): TestResult[] { diff --git a/_infrastructure/tests/src/suite/syntax.ts b/_infrastructure/tests/src/suite/syntax.ts index ff4b3bdb4b..41808b2a2b 100644 --- a/_infrastructure/tests/src/suite/syntax.ts +++ b/_infrastructure/tests/src/suite/syntax.ts @@ -2,7 +2,11 @@ /// module DT { - 'use-strict'; + 'use strict'; + + var Promise: typeof Promise = require('bluebird'); + + var endDts = /.ts$/i; ///////////////////////////////// // .d.ts syntax inspection @@ -10,13 +14,13 @@ module DT { export class SyntaxChecking extends TestSuiteBase { constructor(options: ITestRunnerOptions) { - super(options, "Syntax checking", "Syntax error"); + super(options, 'Syntax checking', 'Syntax error'); } - public filterTargetFiles(files: File[]): File[] { - return files.filter((file) => { - return DT.endsWith(file.formatName.toUpperCase(), '.D.TS'); - }); + public filterTargetFiles(files: File[]): Promise { + return Promise.cast(files.filter((file) => { + return endDts.test(file.formatName); + })); } } } diff --git a/_infrastructure/tests/src/suite/testEval.ts b/_infrastructure/tests/src/suite/testEval.ts index 13a6598874..bc842549fc 100644 --- a/_infrastructure/tests/src/suite/testEval.ts +++ b/_infrastructure/tests/src/suite/testEval.ts @@ -2,20 +2,25 @@ /// module DT { - 'use-strict'; + 'use strict'; + + var Promise: typeof Promise = require('bluebird'); + + var endTestDts = /-test.ts$/i; + ///////////////////////////////// // Compile with *-tests.ts ///////////////////////////////// export class TestEval extends TestSuiteBase { constructor(options) { - super(options, "Typing tests", "Failed tests"); + super(options, 'Typing tests', 'Failed tests'); } - public filterTargetFiles(files: File[]): File[] { - return files.filter((file) => { - return DT.endsWith(file.formatName.toUpperCase(), '-TESTS.TS') - }); + public filterTargetFiles(files: File[]): Promise { + return Promise.cast(files.filter((file) => { + return endTestDts.test(file.formatName); + })); } } diff --git a/_infrastructure/tests/src/suite/tscParams.ts b/_infrastructure/tests/src/suite/tscParams.ts index e4bb4f4c15..cef23d622b 100644 --- a/_infrastructure/tests/src/suite/tscParams.ts +++ b/_infrastructure/tests/src/suite/tscParams.ts @@ -1,10 +1,11 @@ -/// -/// +/// +/// module DT { - 'use-strict'; + 'use strict'; var fs = require('fs'); + var Promise: typeof Promise = require('bluebird'); ///////////////////////////////// // Try compile without .tscparams @@ -15,7 +16,7 @@ module DT { printErrorCount = false; constructor(options: ITestRunnerOptions, private print: Print) { - super(options, "Find not required .tscparams files", "New arrival!"); + super(options, 'Find not required .tscparams files', 'New arrival!'); this.testReporter = { printPositiveCharacter: (index: number, testResult: TestResult) => { @@ -28,29 +29,28 @@ module DT { } } - public filterTargetFiles(files: File[]): File[] { - return files.filter((file) => { - return fs.existsSync(file.filePathWithName + '.tscparams'); + public filterTargetFiles(files: File[]): Promise { + return Promise.filter(files, (file) => { + return new Promise((resolve) => { + fs.exists(file.filePathWithName + '.tscparams', resolve); + }); }); } - public runTest(targetFile: File, callback: (result: TestResult) => void): void { + public runTest(targetFile: File): Promise { this.print.clearCurrentLine().out(targetFile.formatName); - new Test(this, targetFile, { + + return new Test(this, targetFile, { tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true - }).run(result=> { + }).run().then((result: TestResult) => { this.testResults.push(result); - callback(result); + this.print.clearCurrentLine(); + return result }); } - public finish(suiteCallback: (suite: ITestSuite)=>void) { - this.print.clearCurrentLine(); - suiteCallback(this); - } - public get ngTests(): TestResult[] { // Do not show ng test results return []; diff --git a/_infrastructure/tests/src/timer.ts b/_infrastructure/tests/src/timer.ts index 1bf965a825..009527109a 100644 --- a/_infrastructure/tests/src/timer.ts +++ b/_infrastructure/tests/src/timer.ts @@ -2,7 +2,7 @@ /// module DT { - 'use-strict'; + 'use strict'; ///////////////////////////////// // Timer.start starts a timer @@ -36,14 +36,14 @@ module DT { } return ( (day_diff == 0 && ( - diff < 60 && (diff + " seconds") || - diff < 120 && "1 minute" || - diff < 3600 && Math.floor(diff / 60) + " minutes" || - diff < 7200 && "1 hour" || - diff < 86400 && Math.floor(diff / 3600) + " hours") || - day_diff == 1 && "Yesterday" || - day_diff < 7 && day_diff + " days" || - day_diff < 31 && Math.ceil(day_diff / 7) + " weeks")); + diff < 60 && (diff + ' seconds') || + diff < 120 && '1 minute' || + diff < 3600 && Math.floor(diff / 60) + ' minutes' || + diff < 7200 && '1 hour' || + diff < 86400 && Math.floor(diff / 3600) + ' hours') || + day_diff == 1 && 'Yesterday' || + day_diff < 7 && day_diff + ' days' || + day_diff < 31 && Math.ceil(day_diff / 7) + ' weeks')); } } } diff --git a/_infrastructure/tests/src/tsc.ts b/_infrastructure/tests/src/tsc.ts index 845b8557fe..16287be532 100644 --- a/_infrastructure/tests/src/tsc.ts +++ b/_infrastructure/tests/src/tsc.ts @@ -1,11 +1,14 @@ -/// -/// -/// +/// +/// +/// module DT { - 'use-strict'; + 'use strict'; + var fs = require('fs'); + var Promise: typeof Promise = require('bluebird'); + export interface TscExecOptions { tscVersion?:string; useTscParams?:boolean; @@ -13,33 +16,31 @@ module DT { } export class Tsc { - public static run(tsfile: string, options: TscExecOptions, callback: (result: ExecResult) => void) { - options = options || {}; - options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION; - if (typeof options.checkNoImplicitAny === "undefined") { - options.checkNoImplicitAny = true; - } - if (typeof options.useTscParams === "undefined") { - options.useTscParams = true; - } - - if (!fs.existsSync(tsfile)) { - throw new Error(tsfile + " not exists"); - } - - var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!fs.existsSync(tscPath)) { - throw new Error(tscPath + ' is not exists'); - } - var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { - command += '@' + tsfile + '.tscparams'; - } - else if (options.checkNoImplicitAny) { - command += '--noImplicitAny'; - } - Exec.exec(command, [tsfile], (execResult) => { - callback(execResult); + public static run(tsfile: string, options: TscExecOptions): Promise { + return Promise.attempt(() => { + options = options || {}; + options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION; + if (typeof options.checkNoImplicitAny === 'undefined') { + options.checkNoImplicitAny = true; + } + if (typeof options.useTscParams === 'undefined') { + options.useTscParams = true; + } + if (!fs.existsSync(tsfile)) { + throw new Error(tsfile + ' not exists'); + } + var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; + if (!fs.existsSync(tscPath)) { + throw new Error(tscPath + ' is not exists'); + } + var command = 'node ' + tscPath + ' --module commonjs '; + if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { + command += '@' + tsfile + '.tscparams'; + } + else if (options.checkNoImplicitAny) { + command += '--noImplicitAny'; + } + return exec(command, [tsfile]); }); } } diff --git a/_infrastructure/tests/src/util.ts b/_infrastructure/tests/src/util.ts index 39115b1eb4..a712bb90cd 100644 --- a/_infrastructure/tests/src/util.ts +++ b/_infrastructure/tests/src/util.ts @@ -1,7 +1,11 @@ /// module DT { - 'use-strict'; + 'use strict'; + + var fs = require('fs'); + var Lazy: LazyJS.LazyStatic = require('lazy.js'); + var Promise: typeof Promise = require('bluebird'); var referenceTagExp = //g; @@ -25,4 +29,12 @@ module DT { } return ret; } + + export function fileExists(target: string): Promise { + return new Promise((resolve, reject) => { + fs.exists(target, (bool: boolean) => { + resolve(bool); + }); + }); + } } diff --git a/_infrastructure/tests/typings/bluebird/bluebird.d.ts b/_infrastructure/tests/typings/bluebird/bluebird.d.ts new file mode 100644 index 0000000000..2e8de4ca80 --- /dev/null +++ b/_infrastructure/tests/typings/bluebird/bluebird.d.ts @@ -0,0 +1,655 @@ +// Type definitions for bluebird 1.0.0 +// Project: https://github.com/petkaantonov/bluebird +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts +// By: Campredon + +// Warning: recommended to use `tsc > v1.0.0` (critical bugs in generic code: +// - https://github.com/borisyankov/DefinitelyTyped/issues/1563 +// - https://github.com/borisyankov/DefinitelyTyped/tree/def/bluebird + +// Note: replicate changes to all overloads in both definition and test file +// Note: keep both static and instance members inline (so similar) + +// TODO fix remaining TODO annotations in both definition and test + +// TODO verify support to have no return statement in handlers to get a Promise (more overloads?) + +declare class Promise implements Promise.Thenable { + /** + * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. + */ + constructor(callback: (resolve: (thenable: Promise.Thenable) => void, reject: (error: any) => void) => void); + constructor(callback: (resolve: (result: R) => void, reject: (error: any) => void) => void); + + /** + * Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. + */ + then(onFulfill: (value: R) => Promise.Thenable, onReject: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise; + then(onFulfill: (value: R) => Promise.Thenable, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise; + then(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise; + then(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise; + + /** + * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. + * + * Alias `.caught();` for compatibility with earlier ECMAScript version. + */ + catch(onReject?: (error: any) => Promise.Thenable): Promise; + caught(onReject?: (error: any) => Promise.Thenable): Promise; + + catch(onReject?: (error: any) => U): Promise; + caught(onReject?: (error: any) => U): Promise; + + /** + * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. + * + * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. + * + * Alias `.caught();` for compatibility with earlier ECMAScript version. + */ + catch(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise; + caught(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable): Promise; + + catch(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise; + caught(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise; + + catch(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise; + caught(ErrorClass: Function, onReject: (error: any) => Promise.Thenable): Promise; + + catch(ErrorClass: Function, onReject: (error: any) => U): Promise; + caught(ErrorClass: Function, onReject: (error: any) => U): Promise; + + /** + * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. + */ + error(onReject: (reason: any) => Promise.Thenable): Promise; + error(onReject: (reason: any) => U): Promise; + + /** + * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. + * + * Alias `.lastly();` for compatibility with earlier ECMAScript version. + */ + finally(handler: (value: R) => Promise.Thenable): Promise; + finally(handler: (value: R) => R): Promise; + + lastly(handler: (value: R) => Promise.Thenable): Promise; + lastly(handler: (value: R) => R): Promise; + + /** + * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. + */ + bind(thisArg: any): Promise; + + /** + * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error. + */ + done(onFulfilled: (value: R) => Promise.Thenable, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise; + done(onFulfilled: (value: R) => Promise.Thenable, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise; + done(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise; + done(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise; + + /** + * Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise. + */ + progressed(handler: (note: any) => any): Promise; + + /** + * Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + delay(ms: number): Promise; + + /** + * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance. + * + * You may specify a custom error message with the `message` parameter. + */ + timeout(ms: number, message?: string): Promise; + + /** + * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. + * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything. + */ + nodeify(callback: (err: any, value?: R) => void): Promise; + nodeify(...sink: any[]): void; + + /** + * Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise. + */ + cancellable(): Promise; + + /** + * Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending. + * + * That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason. + * + * In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`. + * + * Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable. + */ + // TODO what to do with this? + cancel(): Promise; + + /** + * Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors. + */ + fork(onFulfilled: (value: R) => Promise.Thenable, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise; + fork(onFulfilled: (value: R) => Promise.Thenable, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise; + fork(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable, onProgress?: (note: any) => any): Promise; + fork(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise; + + /** + * Create an uncancellable promise based on this promise. + */ + uncancellable(): Promise; + + /** + * See if this promise can be cancelled. + */ + isCancellable(): boolean; + + /** + * See if this `promise` has been fulfilled. + */ + isFulfilled(): boolean; + + /** + * See if this `promise` has been rejected. + */ + isRejected(): boolean; + + /** + * See if this `promise` is still defer. + */ + isPending(): boolean; + + /** + * See if this `promise` is resolved -> either fulfilled or rejected. + */ + isResolved(): boolean; + + /** + * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`. + */ + inspect(): Promise.Inspection; + + /** + * This is a convenience method for doing: + * + * + * promise.then(function(obj){ + * return obj[propertyName].call(obj, arg...); + * }); + * + */ + call(propertyName: string, ...args: any[]): Promise; + + /** + * This is a convenience method for doing: + * + * + * promise.then(function(obj){ + * return obj[propertyName]; + * }); + * + */ + // TODO find way to fix get() + // get(propertyName: string): Promise; + + /** + * Convenience method for: + * + * + * .then(function() { + * return value; + * }); + * + * + * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()` + * + * Alias `.thenReturn();` for compatibility with earlier ECMAScript version. + */ + return(value: U): Promise; + thenReturn(value: U): Promise; + return(): Promise; + thenReturn(): Promise; + + /** + * Convenience method for: + * + * + * .then(function() { + * throw reason; + * }); + * + * Same limitations apply as with `.return()`. + * + * Alias `.thenThrow();` for compatibility with earlier ECMAScript version. + */ + throw(reason: Error): Promise; + thenThrow(reason: Error): Promise; + + /** + * Convert to String. + */ + toString(): string; + + /** + * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`. + */ + toJSON(): Object; + + /** + * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers. + */ + // TODO how to model instance.spread()? like Q? + spread(onFulfill: Function, onReject?: (reason: any) => Promise.Thenable): Promise; + spread(onFulfill: Function, onReject?: (reason: any) => U): Promise; + /* + // TODO or something like this? + spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => Promise.Thenable): Promise; + spread(onFulfill: (...values: W[]) => Promise.Thenable, onReject?: (reason: any) => U): Promise; + spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable): Promise; + spread(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise; + */ + /** + * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + all(): Promise; + + /** + * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO how to model instance.props()? + props(): Promise; + + /** + * Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + settle(): Promise[]>; + + /** + * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + any(): Promise; + + /** + * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + some(count: number): Promise; + + /** + * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + race(): Promise; + + /** + * Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + map(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable): Promise; + map(mapper: (item: Q, index: number, arrayLength: number) => U): Promise; + + /** + * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; + reduce(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U, initialValue?: U): Promise; + + /** + * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. + */ + // TODO type inference from array-resolving promise? + filter(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable): Promise; + filter(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise; +} + +declare module Promise { + + export interface Thenable { + then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; + then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; + } + + export interface Resolver { + /** + * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state. + */ + resolve(value: R): void; + + /** + * Reject the underlying promise with `reason` as the rejection reason. + */ + reject(reason: any): void; + + /** + * Progress the underlying promise with `value` as the progression value. + */ + progress(value: any): void; + + /** + * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. + * + * If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values. + */ + // TODO specify resolver callback + callback: Function; + } + + export interface Inspection { + /** + * See if the underlying promise was fulfilled at the creation time of this inspection object. + */ + isFulfilled(): boolean; + + /** + * See if the underlying promise was rejected at the creation time of this inspection object. + */ + isRejected(): boolean; + + /** + * See if the underlying promise was defer at the creation time of this inspection object. + */ + isPending(): boolean; + + /** + * Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object. + * + * throws `TypeError` + */ + value(): R; + + /** + * Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object. + * + * throws `TypeError` + */ + error(): any; + } + + /** + * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. + * + * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call. + * + * Alias for `attempt();` for compatibility with earlier ECMAScript version. + */ + // TODO find way to enable try() without tsc borking + // see also: https://typescript.codeplex.com/workitem/2194 + /* + export function try(fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; + export function try(fn: () => R, args?: any[], ctx?: any): Promise; + */ + + export function attempt(fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; + export function attempt(fn: () => R, args?: any[], ctx?: any): Promise; + + /** + * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. + * This method is convenient when a function can sometimes return synchronously or throw synchronously. + */ + export function method(fn: Function): Function; + + /** + * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. + */ + export function resolve(value: Promise.Thenable): Promise; + export function resolve(value: R): Promise; + + /** + * Create a promise that is rejected with the given `reason`. + */ + export function reject(reason: any): Promise; + + /** + * Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution). + */ + export function defer(): Promise.Resolver; + + /** + * Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable. + */ + export function cast(value: Promise.Thenable): Promise; + export function cast(value: R): Promise; + + /** + * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`. + */ + export function bind(thisArg: any): Promise; + + /** + * See if `value` is a trusted Promise. + */ + export function is(value: any): boolean; + + /** + * Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. + */ + export function longStackTraces(): void; + + /** + * Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise. + */ + // TODO enable more overloads + export function delay(value: Promise.Thenable, ms: number): Promise; + export function delay(value: R, ms: number): Promise; + export function delay(ms: number): Promise; + + /** + * Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. + * + * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them. + * + * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. + */ + // TODO how to model promisify? + export function promisify(nodeFunction: Function, receiver?: any): Function; + + /** + * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. + * + * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. + */ + // TODO how to model promisifyAll? + export function promisifyAll(target: Object): Object; + + /** + * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. + */ + // TODO fix coroutine GeneratorFunction + export function coroutine(generatorFunction: Function): Function; + + /** + * Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. + */ + // TODO fix spawn GeneratorFunction + export function spawn(generatorFunction: Function): Promise; + + /** + * This is relevant to browser environments with no module loader. + * + * Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else. + */ + export function noConflict(): typeof Promise; + + /** + * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. + * + * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections. + */ + export function onPossiblyUnhandledRejection(handler: (reason: any) => any): void; + + /** + * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason. + */ + // TODO enable more overloads + // promise of array with promises of value + export function all(values: Thenable[]>): Promise; + // promise of array with values + export function all(values: Thenable): Promise; + // array with promises of value + export function all(values: Thenable[]): Promise; + // array with values + export function all(values: R[]): Promise; + + /** + * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. + * + * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. + * + * *The original object is not modified.* + */ + // TODO verify this is correct + // trusted promise for object + export function props(object: Promise): Promise; + // object + export function props(object: Object): Promise; + + /** + * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array. + * + * *original: The array is not modified. The input array sparsity is retained in the resulting array.* + */ + // promise of array with promises of value + export function settle(values: Thenable[]>): Promise[]>; + // promise of array with values + export function settle(values: Thenable): Promise[]>; + // array with promises of value + export function settle(values: Thenable[]): Promise[]>; + // array with values + export function settle(values: R[]): Promise[]>; + + /** + * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly. + */ + // promise of array with promises of value + export function any(values: Thenable[]>): Promise; + // promise of array with values + export function any(values: Thenable): Promise; + // array with promises of value + export function any(values: Thenable[]): Promise; + // array with values + export function any(values: R[]): Promise; + + /** + * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value. + * + * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending. + */ + // promise of array with promises of value + export function race(values: Thenable[]>): Promise; + // promise of array with values + export function race(values: Thenable): Promise; + // array with promises of value + export function race(values: Thenable[]): Promise; + // array with values + export function race(values: R[]): Promise; + + /** + * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. + * + * If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in. + * + * *The original array is not modified.* + */ + // promise of array with promises of value + export function some(values: Thenable[]>, count: number): Promise; + // promise of array with values + export function some(values: Thenable, count: number): Promise; + // array with promises of value + export function some(values: Thenable[], count: number): Promise; + // array with values + export function some(values: R[], count: number): Promise; + + /** + * Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments. + */ + // variadic array with promises of value + export function join(...values: Thenable[]): Promise; + // variadic array with values + export function join(...values: R[]): Promise; + + /** + * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * + * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. + * + * *The original array is not modified.* + */ + // promise of array with promises of value + export function map(values: Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function map(values: Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; + + // promise of array with values + export function map(values: Thenable, mapper: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function map(values: Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; + + // array with promises of value + export function map(values: Thenable[], mapper: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function map(values: Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; + + // array with values + export function map(values: R[], mapper: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; + + /** + * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * + * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. + * + * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* + */ + // promise of array with promises of value + export function reduce(values: Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable, initialValue?: U): Promise; + export function reduce(values: Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + + // promise of array with values + export function reduce(values: Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable, initialValue?: U): Promise; + export function reduce(values: Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + + // array with promises of value + export function reduce(values: Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable, initialValue?: U): Promise; + export function reduce(values: Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + + // array with values + export function reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable, initialValue?: U): Promise; + export function reduce(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + + /** + * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * + * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result. + * + * *The original array is not modified. + */ + // promise of array with promises of value + export function filter(values: Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function filter(values: Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + + // promise of array with values + export function filter(values: Thenable, filterer: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function filter(values: Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + + // array with promises of value + export function filter(values: Thenable[], filterer: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function filter(values: Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + + // array with values + export function filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => Thenable): Promise; + export function filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +} + +declare module 'bluebird' { +export = Promise; +} diff --git a/_infrastructure/tests/typings/lazy.js/lazy.js.d.ts b/_infrastructure/tests/typings/lazy.js/lazy.js.d.ts new file mode 100644 index 0000000000..b9367b73bc --- /dev/null +++ b/_infrastructure/tests/typings/lazy.js/lazy.js.d.ts @@ -0,0 +1,252 @@ +// Type definitions for Lazy.js 0.3.2 +// Project: https://github.com/dtao/lazy.js/ +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module LazyJS { + + interface LazyStatic { + (value: string):StringLikeSequence; + + (value: T[]):ArrayLikeSequence; + (value: any[]):ArrayLikeSequence; + (value: Object):ObjectLikeSequence; + (value: Object):ObjectLikeSequence; + + strict():LazyStatic; + + generate(generatorFn: GeneratorCallback, length?: number):GeneratedSequence; + + range(to: number):GeneratedSequence; + range(from: number, to: number, step?: number):GeneratedSequence; + + repeat(value: T, count?: number):GeneratedSequence; + + on(eventType: string):Sequence; + + readFile(path: string):StringLikeSequence; + makeHttpRequest(path: string):StringLikeSequence; + } + + interface ArrayLike { + length:number; + [index:number]:T; + } + + interface Callback { + ():void; + } + + interface ErrorCallback { + (error: any):void; + } + + interface ValueCallback { + (value: T):void; + } + + interface GetKeyCallback { + (value: T):string; + } + + interface TestCallback { + (value: T):boolean; + } + + interface MapCallback { + (value: T):U; + } + + interface MapStringCallback { + (value: string):string; + } + + interface NumberCallback { + (value: T):number; + } + + interface MemoCallback { + (memo: U, value: T):U; + } + + interface GeneratorCallback { + (index: number):T; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + interface Iterator { + new (sequence: Sequence):Iterator; + current():T; + moveNext():boolean; + } + + interface GeneratedSequence extends Sequence { + new(generatorFn: GeneratorCallback, length: number):GeneratedSequence; + length():number; + } + + interface AsyncSequence extends SequenceBase { + each(callback: ValueCallback):AsyncHandle; + } + + interface AsyncHandle { + cancel():void; + onComplete(callback: Callback):void; + onError(callback: ErrorCallback):void; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + module Sequence { + function define(methodName: string[], overrides: Object): Function; + } + + interface Sequence extends SequenceBase { + each(eachFn: ValueCallback):Sequence; + } + + interface SequenceBase extends SequenceBaser { + first():any; + first(count: number):Sequence; + indexOf(value: any, startIndex?: number):Sequence; + + last():any; + last(count: number):Sequence; + lastIndexOf(value: any):Sequence; + + reverse():Sequence; + } + + interface SequenceBaser { + // TODO improve define() (needs ugly overload) + async(interval: number):AsyncSequence; + chunk(size: number):Sequence; + compact():Sequence; + concat(var_args: T[]):Sequence; + consecutive(length: number):Sequence; + contains(value: T):boolean; + countBy(keyFn: GetKeyCallback): ObjectLikeSequence; + countBy(propertyName: string): ObjectLikeSequence; + dropWhile(predicateFn: TestCallback): Sequence; + every(predicateFn: TestCallback): boolean; + filter(predicateFn: TestCallback): Sequence; + find(predicateFn: TestCallback): Sequence; + findWhere(properties: Object): Sequence; + + flatten(): Sequence; + groupBy(keyFn: GetKeyCallback): ObjectLikeSequence; + initial(count?: number): Sequence; + intersection(var_args: T[]): Sequence; + invoke(methodName: string): Sequence; + isEmpty(): boolean; + join(delimiter?: string): string; + map(mapFn: MapCallback): Sequence; + + max(valueFn?: NumberCallback): T; + min(valueFn?: NumberCallback): T; + pluck(propertyName: string): Sequence; + reduce(aggregatorFn: MemoCallback, memo?: U): U; + reduceRight(aggregatorFn: MemoCallback, memo: U): U; + reject(predicateFn: TestCallback): Sequence; + rest(count?: number): Sequence; + shuffle(): Sequence; + some(predicateFn?: TestCallback): boolean; + sortBy(sortFn: NumberCallback): Sequence; + sortedIndex(value: T): Sequence; + sum(valueFn?: NumberCallback): Sequence; + takeWhile(predicateFn: TestCallback): Sequence; + union(var_args: T[]): Sequence; + uniq(): Sequence; + where(properties: Object): Sequence; + without(var_args: T[]): Sequence; + zip(var_args: T[]): Sequence; + + toArray(): T[]; + toObject(): Object; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + module ArrayLikeSequence { + function define(methodName: string[], overrides: Object): Function; + } + + interface ArrayLikeSequence extends Sequence { + // define()X; + concat(): ArrayLikeSequence; + first(count?: number): ArrayLikeSequence; + get(index: number): T; + length(): number; + map(mapFn: MapCallback): ArrayLikeSequence; + pop(): ArrayLikeSequence; + rest(count?: number): ArrayLikeSequence; + reverse(): ArrayLikeSequence; + shift(): ArrayLikeSequence; + slice(begin: number, end?: number): ArrayLikeSequence; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + module ObjectLikeSequence { + function define(methodName: string[], overrides: Object): Function; + } + + interface ObjectLikeSequence extends Sequence { + assign(other: Object): ObjectLikeSequence; + // throws error + //async(): X; + defaults(defaults: Object): ObjectLikeSequence; + functions(): Sequence; + get(property: string): ObjectLikeSequence; + invert(): ObjectLikeSequence; + keys(): StringLikeSequence; + omit(properties: string[]): ObjectLikeSequence; + pairs(): Sequence; + pick(properties: string[]): ObjectLikeSequence; + toArray(): T[]; + toObject(): Object; + values(): Sequence; + } + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + module StringLikeSequence { + function define(methodName: string[], overrides: Object): Function; + } + + interface StringLikeSequence extends SequenceBaser { + charAt(index: number): string; + charCodeAt(index: number): number; + contains(value: string): boolean; + endsWith(suffix: string): boolean; + + first(): string; + first(count: number): StringLikeSequence; + + indexOf(substring: string, startIndex?: number): number; + + last(): string; + last(count: number): StringLikeSequence; + + lastIndexOf(substring: string, startIndex?: number): number; + mapString(mapFn: MapStringCallback): StringLikeSequence; + match(pattern: RegExp): StringLikeSequence; + reverse(): StringLikeSequence; + + split(delimiter: string): StringLikeSequence; + split(delimiter: RegExp): StringLikeSequence; + + startsWith(prefix: string): boolean; + substring(start: number, stop?: number): StringLikeSequence; + toLowerCase(): StringLikeSequence; + toUpperCase(): StringLikeSequence; + } +} + +declare var Lazy: LazyJS.LazyStatic; + +declare module 'lazy.js' { +export = Lazy; +} + diff --git a/_infrastructure/tests/typings/node/node.d.ts b/_infrastructure/tests/typings/node/node.d.ts new file mode 100644 index 0000000000..dca0164b08 --- /dev/null +++ b/_infrastructure/tests/typings/node/node.d.ts @@ -0,0 +1,1258 @@ +// Type definitions for Node.js v0.10.1 +// Project: http://nodejs.org/ +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/************************************************ +* * +* Node.js v0.10.1 API * +* * +************************************************/ + +/************************************************ +* * +* GLOBAL * +* * +************************************************/ +declare var process: NodeProcess; +declare var global: any; + +declare var __filename: string; +declare var __dirname: string; + +declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; +declare function clearTimeout(timeoutId: NodeTimer): void; +declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; +declare function clearInterval(intervalId: NodeTimer): void; +declare function setImmediate(callback: (...args: any[]) => void , ...args: any[]): any; +declare function clearImmediate(immediateId: any): void; + +declare var require: { + (id: string): any; + resolve(id:string): string; + cache: any; + extensions: any; + main: any; +} + +declare var module: { + exports: any; + require(id: string): any; + id: string; + filename: string; + loaded: boolean; + parent: any; + children: any[]; +} + +// Same as module.exports +declare var exports: any; +declare var SlowBuffer: { + new (str: string, encoding?: string): NodeBuffer; + new (size: number): NodeBuffer; + new (array: any[]): NodeBuffer; + prototype: NodeBuffer; + isBuffer(obj: any): boolean; + byteLength(string: string, encoding?: string): number; + concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; +}; +declare var Buffer: { + new (str: string, encoding?: string): NodeBuffer; + new (size: number): NodeBuffer; + new (array: any[]): NodeBuffer; + prototype: NodeBuffer; + isBuffer(obj: any): boolean; + byteLength(string: string, encoding?: string): number; + concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; +} + +/************************************************ +* * +* INTERFACES * +* * +************************************************/ + +interface ErrnoException extends Error { + errno?: any; + code?: string; + path?: string; + syscall?: string; +} + +interface NodeEventEmitter { + addListener(event: string, listener: Function): NodeEventEmitter; + on(event: string, listener: Function): NodeEventEmitter; + once(event: string, listener: Function): NodeEventEmitter; + removeListener(event: string, listener: Function): NodeEventEmitter; + removeAllListeners(event?: string): NodeEventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; +} + +interface ReadableStream extends NodeEventEmitter { + readable: boolean; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: NodeBuffer): void; + wrap(oldStream: ReadableStream): ReadableStream; +} + +interface WritableStream extends NodeEventEmitter { + writable: boolean; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; +} + +interface ReadWriteStream extends ReadableStream, WritableStream { } + +interface NodeProcess extends NodeEventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: any; + exit(code?: number): void; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: { http_parser: string; node: string; v8: string; ares: string; uv: string; zlib: string; openssl: string; }; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid: number, signal?: string): void; + pid: number; + title: string; + arch: string; + platform: string; + memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; + nextTick(callback: Function): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?:number[]): number[]; + + // Worker + send?(message: any, sendHandle?: any): void; +} + +// Buffer class +interface NodeBuffer { + [index: number]: number; + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + length: number; + copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): NodeBuffer; + readUInt8(offset: number, noAsset?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + writeUInt8(value: number, offset: number, noAssert?: boolean): void; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): void; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): void; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): void; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): void; + writeInt8(value: number, offset: number, noAssert?: boolean): void; + writeInt16LE(value: number, offset: number, noAssert?: boolean): void; + writeInt16BE(value: number, offset: number, noAssert?: boolean): void; + writeInt32LE(value: number, offset: number, noAssert?: boolean): void; + writeInt32BE(value: number, offset: number, noAssert?: boolean): void; + writeFloatLE(value: number, offset: number, noAssert?: boolean): void; + writeFloatBE(value: number, offset: number, noAssert?: boolean): void; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): void; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): void; + fill(value: any, offset?: number, end?: number): void; +} + +interface NodeTimer { + ref() : void; + unref() : void; +} + +/************************************************ +* * +* MODULES * +* * +************************************************/ +declare module "querystring" { + export function stringify(obj: any, sep?: string, eq?: string): string; + export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; + export function escape(): any; + export function unescape(): any; +} + +declare module "events" { + export class EventEmitter implements NodeEventEmitter { + static listenerCount(emitter: EventEmitter, event: string): number; + + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } +} + +declare module "http" { + import events = require("events"); + import net = require("net"); + import stream = require("stream"); + + export interface Server extends NodeEventEmitter { + listen(port: number, hostname?: string, backlog?: number, callback?: Function): void; + listen(path: string, callback?: Function): void; + listen(handle: any, listeningListener?: Function): void; + close(cb?: any): void; + maxHeadersCount: number; + } + export interface ServerRequest extends NodeEventEmitter, ReadableStream { + method: string; + url: string; + headers: any; + trailers: string; + httpVersion: string; + setEncoding(encoding?: string): void; + pause(): void; + resume(): void; + connection: net.NodeSocket; + } + export interface ServerResponse extends NodeEventEmitter, WritableStream { + // Extended base methods + 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; + writeHead(statusCode: number, headers?: any): void; + statusCode: number; + setHeader(name: string, value: string): void; + sendDate: boolean; + getHeader(name: string): string; + 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(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; + 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; + httpVersion: string; + headers: any; + trailers: any; + setEncoding(encoding?: string): void; + pause(): void; + resume(): void; + } + export interface Agent { maxSockets: number; sockets: any; requests: any; } + + export var STATUS_CODES: any; + export function createServer(requestListener?: (request: ServerRequest, response: ServerResponse) =>void ): Server; + export function createClient(port?: number, host?: string): any; + export function request(options: any, callback?: Function): ClientRequest; + export function get(options: any, callback?: Function): ClientRequest; + export var globalAgent: Agent; +} + +declare module "cluster" { + import child = require("child_process"); + import events = require("events"); + + export interface ClusterSettings { + exec?: string; + args?: string[]; + silent?: boolean; + } + + export class Worker extends events.EventEmitter { + id: string; + process: child.ChildProcess; + suicide: boolean; + send(message: any, sendHandle?: any): void; + kill(signal?: string): void; + destroy(signal?: string): void; + disconnect(): void; + } + + export var settings: ClusterSettings; + export var isMaster: boolean; + export var isWorker: boolean; + export function setupMaster(settings?: ClusterSettings): void; + export function fork(env?: any): Worker; + export function disconnect(callback?: Function): void; + export var worker: Worker; + export var workers: Worker[]; + + // Event emitter + export function addListener(event: string, listener: Function): void; + export function on(event: string, listener: Function): any; + export function once(event: string, listener: Function): void; + export function removeListener(event: string, listener: Function): void; + export function removeAllListeners(event?: string): void; + export function setMaxListeners(n: number): void; + export function listeners(event: string): Function[]; + export function emit(event: string, ...args: any[]): boolean; +} + +declare module "zlib" { + import stream = require("stream"); + export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } + + export interface Gzip extends ReadWriteStream { } + export interface Gunzip extends ReadWriteStream { } + export interface Deflate extends ReadWriteStream { } + export interface Inflate extends ReadWriteStream { } + export interface DeflateRaw extends ReadWriteStream { } + export interface InflateRaw extends ReadWriteStream { } + export interface Unzip extends ReadWriteStream { } + + export function createGzip(options?: ZlibOptions): Gzip; + export function createGunzip(options?: ZlibOptions): Gunzip; + export function createDeflate(options?: ZlibOptions): Deflate; + export function createInflate(options?: ZlibOptions): Inflate; + export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; + export function createInflateRaw(options?: ZlibOptions): InflateRaw; + export function createUnzip(options?: ZlibOptions): Unzip; + + export function deflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function gzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function gunzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function inflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function unzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + + // Constants + export var Z_NO_FLUSH: number; + export var Z_PARTIAL_FLUSH: number; + export var Z_SYNC_FLUSH: number; + export var Z_FULL_FLUSH: number; + export var Z_FINISH: number; + export var Z_BLOCK: number; + export var Z_TREES: number; + export var Z_OK: number; + export var Z_STREAM_END: number; + export var Z_NEED_DICT: number; + export var Z_ERRNO: number; + export var Z_STREAM_ERROR: number; + export var Z_DATA_ERROR: number; + export var Z_MEM_ERROR: number; + export var Z_BUF_ERROR: number; + export var Z_VERSION_ERROR: number; + export var Z_NO_COMPRESSION: number; + export var Z_BEST_SPEED: number; + export var Z_BEST_COMPRESSION: number; + export var Z_DEFAULT_COMPRESSION: number; + export var Z_FILTERED: number; + export var Z_HUFFMAN_ONLY: number; + export var Z_RLE: number; + export var Z_FIXED: number; + export var Z_DEFAULT_STRATEGY: number; + export var Z_BINARY: number; + export var Z_TEXT: number; + export var Z_ASCII: number; + export var Z_UNKNOWN: number; + export var Z_DEFLATED: number; + export var Z_NULL: number; +} + +declare module "os" { + export function tmpDir(): string; + export function hostname(): string; + export function type(): string; + export function platform(): string; + export function arch(): string; + export function release(): string; + export function uptime(): number; + export function loadavg(): number[]; + export function totalmem(): number; + export function freemem(): number; + export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[]; + export function networkInterfaces(): any; + export var EOL: string; +} + +declare module "https" { + import tls = require("tls"); + import events = require("events"); + import http = require("http"); + + export interface ServerOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + crl?: any; + ciphers?: string; + honorCipherOrder?: boolean; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; + SNICallback?: (servername: string) => any; + } + + export interface RequestOptions { + host?: string; + hostname?: string; + port?: number; + path?: string; + method?: string; + headers?: any; + auth?: string; + agent?: any; + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + ciphers?: string; + rejectUnauthorized?: boolean; + } + + export interface NodeAgent { + maxSockets: number; + sockets: any; + requests: any; + } + export var Agent: { + new (options?: RequestOptions): NodeAgent; + }; + export interface Server extends tls.Server { } + export function createServer(options: ServerOptions, requestListener?: Function): Server; + export function request(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; + export var globalAgent: NodeAgent; +} + +declare module "punycode" { + export function decode(string: string): string; + export function encode(string: string): string; + export function toUnicode(domain: string): string; + export function toASCII(domain: string): string; + export var ucs2: ucs2; + interface ucs2 { + decode(string: string): string; + encode(codePoints: number[]): string; + } + export var version: any; +} + +declare module "repl" { + import stream = require("stream"); + import events = require("events"); + + export interface ReplOptions { + prompt?: string; + input?: ReadableStream; + output?: WritableStream; + terminal?: boolean; + eval?: Function; + useColors?: boolean; + useGlobal?: boolean; + ignoreUndefined?: boolean; + writer?: Function; + } + export function start(options: ReplOptions): NodeEventEmitter; +} + +declare module "readline" { + import events = require("events"); + import stream = require("stream"); + + export interface ReadLine extends NodeEventEmitter { + setPrompt(prompt: string, length: number): void; + prompt(preserveCursor?: boolean): void; + question(query: string, callback: Function): void; + pause(): void; + resume(): void; + close(): void; + write(data: any, key?: any): void; + } + export interface ReadLineOptions { + input: ReadableStream; + output: WritableStream; + completer?: Function; + terminal?: boolean; + } + export function createInterface(options: ReadLineOptions): ReadLine; +} + +declare module "vm" { + export interface Context { } + export interface Script { + runInThisContext(): void; + runInNewContext(sandbox?: Context): void; + } + export function runInThisContext(code: string, filename?: string): void; + export function runInNewContext(code: string, sandbox?: Context, filename?: string): void; + export function runInContext(code: string, context: Context, filename?: string): void; + export function createContext(initSandbox?: Context): Context; + export function createScript(code: string, filename?: string): Script; +} + +declare module "child_process" { + import events = require("events"); + import stream = require("stream"); + + export interface ChildProcess extends NodeEventEmitter { + stdin: WritableStream; + stdout: ReadableStream; + stderr: ReadableStream; + pid: number; + kill(signal?: string): void; + send(message: any, sendHandle: any): void; + disconnect(): void; + } + + export function spawn(command: string, args?: string[], options?: { + cwd?: string; + stdio?: any; + custom?: any; + env?: any; + detached?: boolean; + }): ChildProcess; + export function exec(command: string, options: { + cwd?: string; + stdio?: any; + customFds?: any; + env?: any; + encoding?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + export function exec(command: string, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + export function execFile(file: string, args: string[], options: { + cwd?: string; + stdio?: any; + customFds?: any; + env?: any; + encoding?: string; + timeout?: number; + maxBuffer?: string; + killSignal?: string; + }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + export function fork(modulePath: string, args?: string[], options?: { + cwd?: string; + env?: any; + encoding?: string; + }): ChildProcess; +} + +declare module "url" { + export interface Url { + href: string; + protocol: string; + auth: string; + hostname: string; + port: string; + host: string; + pathname: string; + search: string; + query: string; + slashes: boolean; + } + + export interface UrlOptions { + protocol?: string; + auth?: string; + hostname?: string; + port?: string; + host?: string; + pathname?: string; + search?: string; + query?: any; + } + + export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; + export function format(url: UrlOptions): string; + export function resolve(from: string, to: string): string; +} + +declare module "dns" { + export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; + export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; + export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; +} + +declare module "net" { + import stream = require("stream"); + + export interface NodeSocket extends ReadWriteStream { + // Extended base methods + 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; + destroy(): void; + pause(): void; + resume(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setKeepAlive(enable?: boolean, initialDelay?: number): void; + address(): { port: number; family: string; address: string; }; + remoteAddress: string; + 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: { + new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): NodeSocket; + }; + + export interface Server extends NodeSocket { + listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void; + listen(path: string, listeningListener?: Function): void; + listen(handle: any, listeningListener?: Function): void; + close(callback?: Function): void; + address(): { port: number; family: string; address: string; }; + maxConnections: number; + connections: number; + } + export function createServer(connectionListener?: (socket: NodeSocket) =>void ): Server; + export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: NodeSocket) =>void ): Server; + export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): NodeSocket; + export function connect(port: number, host?: string, connectionListener?: Function): NodeSocket; + export function connect(path: string, connectionListener?: Function): NodeSocket; + export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): NodeSocket; + export function createConnection(port: number, host?: string, connectionListener?: Function): NodeSocket; + export function createConnection(path: string, connectionListener?: Function): NodeSocket; + export function isIP(input: string): number; + export function isIPv4(input: string): boolean; + export function isIPv6(input: string): boolean; +} + +declare module "dgram" { + import events = require("events"); + + export function createSocket(type: string, callback?: Function): Socket; + + interface Socket extends NodeEventEmitter { + send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void; + bind(port: number, address?: string): void; + close(): void; + address: { address: string; family: string; port: number; }; + setBroadcast(flag: boolean): void; + setMulticastTTL(ttl: number): void; + setMulticastLoopback(flag: boolean): void; + addMembership(multicastAddress: string, multicastInterface?: string): void; + dropMembership(multicastAddress: string, multicastInterface?: string): void; + } +} + +declare module "fs" { + import stream = require("stream"); + + interface Stats { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; + atime: Date; + mtime: Date; + ctime: Date; + } + + interface FSWatcher extends NodeEventEmitter { + close(): void; + } + + export interface ReadStream extends ReadableStream { } + export interface WriteStream extends WritableStream { } + + export function rename(oldPath: string, newPath: string, callback?: (err?: ErrnoException) => void): void; + export function renameSync(oldPath: string, newPath: string): void; + export function truncate(path: string, callback?: (err?: ErrnoException) => void): void; + export function truncate(path: string, len: number, callback?: (err?: ErrnoException) => void): void; + export function truncateSync(path: string, len?: number): void; + export function ftruncate(fd: number, callback?: (err?: ErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: ErrnoException) => void): void; + export function ftruncateSync(fd: number, len?: number): void; + export function chown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function chownSync(path: string, uid: number, gid: number): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function fchownSync(fd: number, uid: number, gid: number): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function lchownSync(path: string, uid: number, gid: number): void; + export function chmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; + export function chmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function chmodSync(path: string, mode: number): void; + export function chmodSync(path: string, mode: string): void; + export function fchmod(fd: number, mode: number, callback?: (err?: ErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: ErrnoException) => void): void; + export function fchmodSync(fd: number, mode: number): void; + export function fchmodSync(fd: number, mode: string): void; + export function lchmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; + export function lchmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function lchmodSync(path: string, mode: number): void; + export function lchmodSync(path: string, mode: string): void; + export function stat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void; + export function lstat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: ErrnoException, stats: Stats) => any): void; + export function statSync(path: string): Stats; + export function lstatSync(path: string): Stats; + export function fstatSync(fd: number): Stats; + export function link(srcpath: string, dstpath: string, callback?: (err?: ErrnoException) => void): void; + export function linkSync(srcpath: string, dstpath: string): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: ErrnoException) => void): void; + export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; + export function readlink(path: string, callback?: (err: ErrnoException, linkString: string) => any): void; + export function readlinkSync(path: string): string; + export function realpath(path: string, callback?: (err: ErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string, cache: {[path: string]: string}, callback: (err: ErrnoException, resolvedPath: string) =>any): void; + export function realpathSync(path: string, cache?: {[path: string]: string}): void; + export function unlink(path: string, callback?: (err?: ErrnoException) => void): void; + export function unlinkSync(path: string): void; + export function rmdir(path: string, callback?: (err?: ErrnoException) => void): void; + export function rmdirSync(path: string): void; + export function mkdir(path: string, callback?: (err?: ErrnoException) => void): void; + export function mkdir(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; + export function mkdir(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function mkdirSync(path: string, mode?: number): void; + export function mkdirSync(path: string, mode?: string): void; + export function readdir(path: string, callback?: (err: ErrnoException, files: string[]) => void): void; + export function readdirSync(path: string): string[]; + export function close(fd: number, callback?: (err?: ErrnoException) => void): void; + export function closeSync(fd: number): void; + export function open(path: string, flags: string, callback?: (err: ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: number, callback?: (err: ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: string, callback?: (err: ErrnoException, fd: number) => any): void; + export function openSync(path: string, flags: string, mode?: number): number; + export function openSync(path: string, flags: string, mode?: string): number; + export function utimes(path: string, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void; + export function utimesSync(path: string, atime: number, mtime: number): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void; + export function futimesSync(fd: number, atime: number, mtime: number): void; + export function fsync(fd: number, callback?: (err?: ErrnoException) => void): void; + export function fsyncSync(fd: number): void; + export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: NodeBuffer) => void): void; + export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; + export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: NodeBuffer) => void): void; + export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; + export function readFile(filename: string, options: { encoding?: string; flag?: string; }, callback: (err: ErrnoException, data: any) => void): void; + export function readFile(filename: string, callback: (err: ErrnoException, data: NodeBuffer) => void ): void; + export function readFileSync(filename: string, options?: { flag?: string; }): NodeBuffer; + export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; + export function writeFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; + export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; + export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; + export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; + export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; + export function exists(path: string, callback?: (exists: boolean) => void): void; + export function existsSync(path: string): boolean; + export function createReadStream(path: string, options?: { + flags?: string; + encoding?: string; + fd?: string; + mode?: number; + bufferSize?: number; + }): ReadStream; + export function createReadStream(path: string, options?: { + flags?: string; + encoding?: string; + fd?: string; + mode?: string; + bufferSize?: number; + }): ReadStream; + export function createWriteStream(path: string, options?: { + flags?: string; + encoding?: string; + string?: string; + }): WriteStream; +} + +declare module "path" { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; +} + +declare module "string_decoder" { + export interface NodeStringDecoder { + write(buffer: NodeBuffer): string; + detectIncompleteChar(buffer: NodeBuffer): number; + } + export var StringDecoder: { + new (encoding: string): NodeStringDecoder; + }; +} + +declare module "tls" { + import crypto = require("crypto"); + import net = require("net"); + import stream = require("stream"); + + var CLIENT_RENEG_LIMIT: number; + var CLIENT_RENEG_WINDOW: number; + + export interface TlsOptions { + pfx?: any; //string or buffer + key?: any; //string or buffer + passphrase?: string; + cert?: any; + ca?: any; //string or buffer + crl?: any; //string or string array + ciphers?: string; + honorCipherOrder?: any; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; //array or Buffer; + SNICallback?: (servername: string) => any; + } + + export interface ConnectionOptions { + host?: string; + port?: number; + socket?: net.NodeSocket; + pfx?: any; //string | Buffer + key?: any; //string | Buffer + passphrase?: string; + cert?: any; //string | Buffer + ca?: any; //Array of string | Buffer + rejectUnauthorized?: boolean; + NPNProtocols?: any; //Array of string | Buffer + servername?: string; + } + + export interface Server extends net.Server { + // Extended base methods + listen(port: number, host?: string, backlog?: number, listeningListener?: Function): void; + listen(path: string, listeningListener?: Function): void; + listen(handle: any, listeningListener?: Function): void; + + listen(port: number, host?: string, callback?: Function): void; + close(): void; + address(): { port: number; family: string; address: string; }; + addContext(hostName: string, credentials: { + key: string; + cert: string; + ca: string; + }): void; + maxConnections: number; + connections: number; + } + + export interface ClearTextStream extends ReadWriteStream { + authorized: boolean; + authorizationError: Error; + getPeerCertificate(): any; + getCipher: { + name: string; + version: string; + }; + address: { + port: number; + family: string; + address: string; + }; + remoteAddress: string; + remotePort: number; + } + + export interface SecurePair { + encrypted: any; + cleartext: any; + } + + export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; + export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; + export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; + export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; + export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; +} + +declare module "crypto" { + export interface CredentialDetails { + pfx: string; + key: string; + passphrase: string; + cert: string; + ca: any; //string | string array + crl: any; //string | string array + ciphers: string; + } + export interface Credentials { context?: any; } + export function createCredentials(details: CredentialDetails): Credentials; + export function createHash(algorithm: string): Hash; + export function createHmac(algorithm: string, key: string): Hmac; + interface Hash { + update(data: any, input_encoding?: string): Hash; + digest(encoding?: string): string; + } + interface Hmac { + update(data: any): void; + digest(encoding?: string): void; + } + export function createCipher(algorithm: string, password: any): Cipher; + export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; + interface Cipher { + update(data: any, input_encoding?: string, output_encoding?: string): string; + final(output_encoding?: string): string; + setAutoPadding(auto_padding: boolean): void; + createDecipher(algorithm: string, password: any): Decipher; + createDecipheriv(algorithm: string, key: any, iv: any): Decipher; + } + interface Decipher { + update(data: any, input_encoding?: string, output_encoding?: string): void; + final(output_encoding?: string): string; + setAutoPadding(auto_padding: boolean): void; + } + export function createSign(algorithm: string): Signer; + interface Signer { + update(data: any): void; + sign(private_key: string, output_format: string): string; + } + export function createVerify(algorith: string): Verify; + interface Verify { + update(data: any): void; + verify(object: string, signature: string, signature_format?: string): boolean; + } + export function createDiffieHellman(prime_length: number): DiffieHellman; + export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; + interface DiffieHellman { + generateKeys(encoding?: string): string; + computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; + getPrime(encoding?: string): string; + getGenerator(encoding: string): string; + getPublicKey(encoding?: string): string; + getPrivateKey(encoding?: string): string; + setPublicKey(public_key: string, encoding?: string): void; + setPrivateKey(public_key: string, encoding?: string): void; + } + export function getDiffieHellman(group_name: string): DiffieHellman; + export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; + export function randomBytes(size: number): NodeBuffer; + export function randomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; + export function pseudoRandomBytes(size: number): NodeBuffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; +} + +declare module "stream" { + import events = require("events"); + + export interface ReadableOptions { + highWaterMark?: number; + encoding?: string; + objectMode?: boolean; + } + + export class Readable extends events.EventEmitter implements ReadableStream { + readable: boolean; + constructor(opts?: ReadableOptions); + _read(size: number): void; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: NodeBuffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + push(chunk: any, encoding?: string): boolean; + } + + export interface WritableOptions { + highWaterMark?: number; + decodeStrings?: boolean; + } + + export class Writable extends events.EventEmitter implements WritableStream { + writable: boolean; + constructor(opts?: WritableOptions); + _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: string, encoding: string, callback: Function): void; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean; + } + + // Note: Duplex extends both Readable and Writable. + export class Duplex extends Readable implements ReadWriteStream { + writable: boolean; + constructor(opts?: DuplexOptions); + _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: string, encoding: string, callback: Function): void; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export interface TransformOptions extends ReadableOptions, WritableOptions {} + + // Note: Transform lacks the _read and _write methods of Readable/Writable. + export class Transform extends events.EventEmitter implements ReadWriteStream { + readable: boolean; + writable: boolean; + constructor(opts?: TransformOptions); + _transform(chunk: NodeBuffer, encoding: string, callback: Function): void; + _transform(chunk: string, encoding: string, callback: Function): void; + _flush(callback: Function): void; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: NodeBuffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + push(chunk: any, encoding?: string): boolean; + write(buffer: NodeBuffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: NodeBuffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export class PassThrough extends Transform {} +} + +declare module "util" { + export interface InspectOptions { + showHidden?: boolean; + depth?: number; + colors?: boolean; + customInspect?: boolean; + } + + export function format(format: any, ...param: any[]): string; + export function debug(string: string): void; + export function error(...param: any[]): void; + export function puts(...param: any[]): void; + export function print(...param: any[]): void; + export function log(string: string): void; + export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; + export function inspect(object: any, options: InspectOptions): string; + export function isArray(object: any): boolean; + export function isRegExp(object: any): boolean; + export function isDate(object: any): boolean; + export function isError(object: any): boolean; + export function inherits(constructor: any, superConstructor: any): void; +} + +declare module "assert" { + function internal (value: any, message?: string): void; + module internal { + export class AssertionError implements Error { + name: string; + message: string; + actual: any; + expected: any; + operator: string; + generatedMessage: boolean; + + constructor(options?: {message?: string; actual?: any; expected?: any; + operator?: string; stackStartFunction?: Function}); + } + + export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; + export function ok(value: any, message?: string): void; + export function equal(actual: any, expected: any, message?: string): void; + export function notEqual(actual: any, expected: any, message?: string): void; + export function deepEqual(actual: any, expected: any, message?: string): void; + export function notDeepEqual(acutal: any, expected: any, message?: string): void; + export function strictEqual(actual: any, expected: any, message?: string): void; + export function notStrictEqual(actual: any, expected: any, message?: string): void; + export var throws: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + } + + export var doesNotThrow: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + } + + export function ifError(value: any): void; + } + + export = internal; +} + +declare module "tty" { + import net = require("net"); + + export function isatty(fd: number): boolean; + export interface ReadStream extends net.NodeSocket { + isRaw: boolean; + setRawMode(mode: boolean): void; + } + export interface WriteStream extends net.NodeSocket { + columns: number; + rows: number; + } +} + +declare module "domain" { + import events = require("events"); + + export class Domain extends events.EventEmitter { + run(fn: Function): void; + add(emitter: NodeEventEmitter): void; + remove(emitter: NodeEventEmitter): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; + + addListener(event: string, listener: Function): Domain; + on(event: string, listener: Function): Domain; + once(event: string, listener: Function): Domain; + removeListener(event: string, listener: Function): Domain; + removeAllListeners(event?: string): Domain; + } + + export function create(): Domain; +} diff --git a/_infrastructure/tests/typings/tsd.d.ts b/_infrastructure/tests/typings/tsd.d.ts new file mode 100644 index 0000000000..717e8e49a3 --- /dev/null +++ b/_infrastructure/tests/typings/tsd.d.ts @@ -0,0 +1,3 @@ +/// +/// +/// diff --git a/package.json b/package.json index bb4c816f6e..a18c4fcd70 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "dependencies": { "git-wrapper": "~0.1.1", "glob": "~3.2.9", - "source-map-support": "~0.2.5" + "source-map-support": "~0.2.5", + "bluebird": "~1.0.7", + "lazy.js": "~0.3.2" } } diff --git a/tsd.json b/tsd.json new file mode 100644 index 0000000000..60f508161b --- /dev/null +++ b/tsd.json @@ -0,0 +1,15 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "_infrastructure/tests/typings", + "bundle": "_infrastructure/tests/typings/tsd.d.ts", + "installed": { + "bluebird/bluebird.d.ts": { + "commit": "bac5b4311465c7052467ec315d0cbb1c640a69d6" + }, + "node/node.d.ts": { + "commit": "bac5b4311465c7052467ec315d0cbb1c640a69d6" + } + } +} From 8c80a0a768b59df05aac4c8da60e54ab58ab1735 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 1 Mar 2014 00:34:19 +0100 Subject: [PATCH 235/240] reworked tester flow and resolver rewrote the reference loop - ditched triple loop - added reference map with low-fi queue resolver simplified promise flow ditched some methods move print code to helpers --- _infrastructure/tests/runner.js | 182 ++++++++++++++++++------------- _infrastructure/tests/runner.ts | 187 +++++++++++++++++++------------- 2 files changed, 223 insertions(+), 146 deletions(-) diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index b11be80a39..e3eca657fd 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -825,12 +825,15 @@ var DT; _this.print.printChangeHeader(); - return Promise.all([ - _this.doParseFiles(), - _this.doGetChanges() - ]); + return _this.changes.getChanges().then(function () { + _this.printAllChanges(_this.changes.paths); + }); }).then(function () { - return _this.doCollectTargets(); + return _this.index.parseFiles(_this.files).then(function () { + // this.printFiles(this.files); + }); + }).then(function () { + return _this.collectTargets(_this.files, _this.changes.paths); }).then(function (files) { return _this.runTests(files); }).then(function () { @@ -840,41 +843,13 @@ var DT; }); }; - TestRunner.prototype.doParseFiles = function () { - return this.index.parseFiles(this.files).then(function () { - /* - this.print.printSubHeader('Files:'); - this.print.printDiv(); - this.files.forEach((file) => { - this.print.printLine(file.filePathWithName); - file.references.forEach((file) => { - this.print.printElement(file.filePathWithName); - }); - }); - this.print.printBreak();*/ - // chain - }).thenReturn(); - }; - - TestRunner.prototype.doGetChanges = function () { - var _this = this; - return this.changes.getChanges().then(function () { - _this.print.printSubHeader('All changes'); - _this.print.printDiv(); - - Lazy(_this.changes.paths).each(function (file) { - _this.print.printLine(file); - }); - }).thenReturn(); - }; - - TestRunner.prototype.doCollectTargets = function () { + TestRunner.prototype.collectTargets = function (files, changes) { var _this = this; return new Promise(function (resolve) { - // bake map for lookup + // filter changes and bake map for easy lookup var changeMap = Object.create(null); - Lazy(_this.changes.paths).filter(function (full) { + Lazy(changes).filter(function (full) { return _this.checkAcceptFile(full); }).map(function (local) { return path.resolve(_this.dtPath, local); @@ -889,51 +864,50 @@ var DT; changeMap[full] = file; }); - _this.print.printDiv(); - _this.print.printSubHeader('Relevant changes'); - _this.print.printDiv(); + _this.printRelChanges(changeMap); - Object.keys(changeMap).sort().forEach(function (src) { - _this.print.printLine(changeMap[src].formatName); + // bake reverse reference map (referenced to referrers) + var refMap = Object.create(null); + + Lazy(files).each(function (file) { + Lazy(file.references).each(function (ref) { + if (ref.fullPath in refMap) { + refMap[ref.fullPath].push(file); + } else { + refMap[ref.fullPath] = [file]; + } + }); }); - // terrible loop (whatever) - // just add stuff until there is nothing new added - // TODO improve it - var added; - var files = _this.files.slice(0); - do { - added = 0; + // this.printRefMap(refMap); + // map out files linked to changes + // - queue holds files touched by a change + // - pre-fill with actually changed files + // - loop queue, if current not seen: + // - add to result + // - from refMap queue all files referring to current + var adding = Object.create(null); + var queue = Lazy(changeMap).values().toArray(); - for (var i = files.length - 1; i >= 0; i--) { - var file = files[i]; - if (file.fullPath in changeMap) { - _this.files.splice(i, 1); - continue; - } - - for (var j = 0, jj = file.references.length; j < jj; j++) { - if (file.references[j].fullPath in changeMap) { - // add us - changeMap[file.fullPath] = file; - added++; - break; - } + while (queue.length > 0) { + var next = queue.shift(); + var fp = next.fullPath; + if (adding[fp]) { + continue; + } + adding[fp] = next; + if (fp in refMap) { + var arr = refMap[fp]; + for (var i = 0, ii = arr.length; i < ii; i++) { + // just add it and skip expensive checks + queue.push(arr[i]); } } - } while(added > 0); + } - _this.print.printDiv(); - _this.print.printSubHeader('Reference mapped'); - _this.print.printDiv(); + _this.printTests(adding); - var result = Object.keys(changeMap).sort().map(function (src) { - _this.print.printLine(changeMap[src].formatName); - changeMap[src].references.forEach(function (file) { - _this.print.printElement(file.formatName); - }); - return changeMap[src]; - }); + var result = Lazy(adding).values().toArray(); resolve(result); }); }; @@ -967,6 +941,7 @@ var DT; suite.testReporter = suite.testReporter || new DT.DefaultTestReporter(_this.print); _this.print.printSuiteHeader(suite.testSuiteName); + return suite.filterTargetFiles(files).then(function (targetFiles) { return suite.start(targetFiles, function (testResult, index) { _this.printTestComplete(testResult, index); @@ -982,6 +957,67 @@ var DT; }); }; + TestRunner.prototype.printTests = function (adding) { + var _this = this; + this.print.printDiv(); + this.print.printSubHeader('Testing'); + this.print.printDiv(); + + Object.keys(adding).sort().map(function (src) { + _this.print.printLine(adding[src].formatName); + return adding[src]; + }); + }; + TestRunner.prototype.printFiles = function (files) { + var _this = this; + this.print.printDiv(); + this.print.printSubHeader('Files:'); + this.print.printDiv(); + + files.forEach(function (file) { + _this.print.printLine(file.filePathWithName); + file.references.forEach(function (file) { + _this.print.printElement(file.filePathWithName); + }); + }); + }; + + TestRunner.prototype.printAllChanges = function (paths) { + var _this = this; + this.print.printSubHeader('All changes'); + this.print.printDiv(); + + paths.sort().forEach(function (line) { + _this.print.printLine(line); + }); + }; + + TestRunner.prototype.printRelChanges = function (changeMap) { + var _this = this; + this.print.printDiv(); + this.print.printSubHeader('Relevant changes'); + this.print.printDiv(); + + Object.keys(changeMap).sort().forEach(function (src) { + _this.print.printLine(changeMap[src].formatName); + }); + }; + + TestRunner.prototype.printRefMap = function (refMap) { + var _this = this; + this.print.printDiv(); + this.print.printSubHeader('Referring'); + this.print.printDiv(); + + Object.keys(refMap).sort().forEach(function (src) { + var ref = _this.index.getFile(src); + _this.print.printLine(ref.formatName); + refMap[src].forEach(function (file) { + _this.print.printLine(' - ' + file.formatName); + }); + }); + }; + TestRunner.prototype.printTestComplete = function (testResult, index) { var reporter = testResult.hostedBy.testReporter; if (testResult.success) { diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 4f3a4389c9..8dfcc7b4cc 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -79,6 +79,14 @@ module DT { findNotRequiredTscparams?:boolean; } + export interface FileDict { + [fullPath:string]: File; + } + + export interface FileArrDict { + [fullPath:string]: File[]; + } + ///////////////////////////////// // The main class to kick things off ///////////////////////////////// @@ -127,12 +135,15 @@ module DT { this.print.printChangeHeader(); - return Promise.all([ - this.doParseFiles(), - this.doGetChanges() - ]); + return this.changes.getChanges().then(() => { + this.printAllChanges(this.changes.paths); + }); }).then(() => { - return this.doCollectTargets(); + return this.index.parseFiles(this.files).then(() => { + // this.printFiles(this.files); + }); + }).then(() => { + return this.collectTargets(this.files, this.changes.paths); }).then((files) => { return this.runTests(files); }).then(() => { @@ -142,40 +153,13 @@ module DT { }); } - private doParseFiles(): Promise { - return this.index.parseFiles(this.files).then(() => { - /* - this.print.printSubHeader('Files:'); - this.print.printDiv(); - this.files.forEach((file) => { - this.print.printLine(file.filePathWithName); - file.references.forEach((file) => { - this.print.printElement(file.filePathWithName); - }); - }); - this.print.printBreak();*/ - // chain - }).thenReturn(); - } - - private doGetChanges(): Promise { - return this.changes.getChanges().then(() => { - this.print.printSubHeader('All changes'); - this.print.printDiv(); - - Lazy(this.changes.paths).each((file) => { - this.print.printLine(file); - }); - }).thenReturn(); - } - - private doCollectTargets(): Promise { + private collectTargets(files: File[], changes: string[]): Promise { return new Promise((resolve) => { - // bake map for lookup - var changeMap = Object.create(null); + // filter changes and bake map for easy lookup + var changeMap: FileDict = Object.create(null); - Lazy(this.changes.paths).filter((full) => { + Lazy(changes).filter((full) => { return this.checkAcceptFile(full); }).map((local) => { return path.resolve(this.dtPath, local); @@ -190,52 +174,52 @@ module DT { changeMap[full] = file; }); - this.print.printDiv(); - this.print.printSubHeader('Relevant changes'); - this.print.printDiv(); + this.printRelChanges(changeMap); - Object.keys(changeMap).sort().forEach((src) => { - this.print.printLine(changeMap[src].formatName); + // bake reverse reference map (referenced to referrers) + var refMap: FileArrDict = Object.create(null); + + Lazy(files).each((file) => { + Lazy(file.references).each((ref) => { + if (ref.fullPath in refMap) { + refMap[ref.fullPath].push(file); + } + else { + refMap[ref.fullPath] = [file]; + } + }); }); - // terrible loop (whatever) - // just add stuff until there is nothing new added - // TODO improve it - var added: number; - var files = this.files.slice(0); - do { - added = 0; + // this.printRefMap(refMap); - for (var i = files.length - 1; i >= 0; i--) { - var file = files[i]; - if (file.fullPath in changeMap) { - this.files.splice(i, 1); - continue; - } - // check if one of our references is touched - for (var j = 0, jj = file.references.length; j < jj; j++) { - if (file.references[j].fullPath in changeMap) { - // add us - changeMap[file.fullPath] = file; - added++; - break; - } + // map out files linked to changes + // - queue holds files touched by a change + // - pre-fill with actually changed files + // - loop queue, if current not seen: + // - add to result + // - from refMap queue all files referring to current + var adding: FileDict = Object.create(null); + var queue = Lazy(changeMap).values().toArray(); + + while (queue.length > 0) { + var next = queue.shift(); + var fp = next.fullPath; + if (adding[fp]) { + continue; + } + adding[fp] = next; + if (fp in refMap) { + var arr = refMap[fp]; + for (var i = 0, ii = arr.length; i < ii; i++) { + // just add it and skip expensive checks + queue.push(arr[i]); } } } - while (added > 0); - this.print.printDiv(); - this.print.printSubHeader('Reference mapped'); - this.print.printDiv(); + this.printTests(adding); - var result: File[] = Object.keys(changeMap).sort().map((src) => { - this.print.printLine(changeMap[src].formatName); - changeMap[src].references.forEach((file: File) => { - this.print.printElement(file.formatName); - }); - return changeMap[src]; - }); + var result: File[] = Lazy(adding).values().toArray(); resolve(result); }); } @@ -268,6 +252,7 @@ module DT { suite.testReporter = suite.testReporter || new DefaultTestReporter(this.print); this.print.printSuiteHeader(suite.testSuiteName); + return suite.filterTargetFiles(files).then((targetFiles) => { return suite.start(targetFiles, (testResult, index) => { this.printTestComplete(testResult, index); @@ -283,6 +268,62 @@ module DT { }); } + private printTests(adding: FileDict): void { + this.print.printDiv(); + this.print.printSubHeader('Testing'); + this.print.printDiv(); + + Object.keys(adding).sort().map((src) => { + this.print.printLine(adding[src].formatName); + return adding[src]; + }); + } + private printFiles(files: File[]): void { + this.print.printDiv(); + this.print.printSubHeader('Files:'); + this.print.printDiv(); + + files.forEach((file) => { + this.print.printLine(file.filePathWithName); + file.references.forEach((file) => { + this.print.printElement(file.filePathWithName); + }); + }); + } + + private printAllChanges(paths: string[]): void { + this.print.printSubHeader('All changes'); + this.print.printDiv(); + + paths.sort().forEach((line) => { + this.print.printLine(line); + }); + } + + private printRelChanges(changeMap: FileDict): void { + this.print.printDiv(); + this.print.printSubHeader('Relevant changes'); + this.print.printDiv(); + + Object.keys(changeMap).sort().forEach((src) => { + this.print.printLine(changeMap[src].formatName); + }); + } + + private printRefMap(refMap: FileArrDict): void { + this.print.printDiv(); + this.print.printSubHeader('Referring'); + this.print.printDiv(); + + Object.keys(refMap).sort().forEach((src) => { + var ref = this.index.getFile(src); + this.print.printLine(ref.formatName); + refMap[src].forEach((file) => { + this.print.printLine(' - ' + file.formatName); + }); + }); + } + private printTestComplete(testResult: TestResult, index: number): void { var reporter = testResult.hostedBy.testReporter; if (testResult.success) { From 4f99c0eb3c990a5e4e90e1b741d8c49a22d902be Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 1 Mar 2014 02:03:01 +0100 Subject: [PATCH 236/240] tester refactored & handle removed files abort test if a referred file is removed reworked main promise flow moved code from runner to index.ts moved code from runner to print.ts added logic to handle file removal to index.ts expanded state in index.ts dropped property File::formatName --- _infrastructure/tests/runner.js | 443 ++++++++++-------- _infrastructure/tests/runner.ts | 215 ++------- _infrastructure/tests/src/changes.ts | 10 +- _infrastructure/tests/src/file.ts | 12 +- _infrastructure/tests/src/index.ts | 130 ++++- _infrastructure/tests/src/printer.ts | 92 +++- _infrastructure/tests/src/suite/syntax.ts | 2 +- _infrastructure/tests/src/suite/testEval.ts | 2 +- _infrastructure/tests/src/suite/tscParams.ts | 4 +- .../tests/typings/lazy.js/lazy.js.d.ts | 4 +- 10 files changed, 512 insertions(+), 402 deletions(-) diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index e3eca657fd..c6ab61c8a4 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -52,7 +52,6 @@ var DT; this.ext = path.extname(this.filePathWithName); this.file = path.basename(this.filePathWithName, this.ext); this.dir = path.dirname(this.filePathWithName); - this.formatName = path.join(this.dir, this.file + this.ext); this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext); // lock it (shallow) (needs `use strict` in each file to work) // Object.freeze(this); @@ -202,6 +201,7 @@ var DT; var fs = require('fs'); var path = require('path'); + var glob = require('glob'); var Lazy = require('lazy.js'); var Promise = require('bluebird'); @@ -211,7 +211,8 @@ var DT; // Track all files in the repo: map full path to File objects ///////////////////////////////// var FileIndex = (function () { - function FileIndex(options) { + function FileIndex(runner, options) { + this.runner = runner; this.options = options; } FileIndex.prototype.hasFile = function (target) { @@ -225,14 +226,76 @@ var DT; return null; }; - FileIndex.prototype.parseFiles = function (files) { + FileIndex.prototype.setFile = function (file) { + if (file.fullPath in this.fileMap) { + throw new Error('cannot overwrite file'); + } + this.fileMap[file.fullPath] = file; + }; + + FileIndex.prototype.readIndex = function () { + var _this = this; + this.fileMap = Object.create(null); + + return Promise.promisify(glob).call(glob, '**/*.ts', { + cwd: this.runner.dtPath + }).then(function (filesNames) { + _this.files = Lazy(filesNames).filter(function (fileName) { + return _this.runner.checkAcceptFile(fileName); + }).map(function (fileName) { + var file = new DT.File(_this.runner.dtPath, fileName); + _this.fileMap[file.fullPath] = file; + return file; + }).toArray(); + }); + }; + + FileIndex.prototype.collectDiff = function (changes) { + var _this = this; + return new Promise(function (resolve) { + // filter changes and bake map for easy lookup + _this.changed = Object.create(null); + _this.removed = Object.create(null); + + Lazy(changes).filter(function (full) { + return _this.runner.checkAcceptFile(full); + }).uniq().each(function (local) { + var full = path.resolve(_this.runner.dtPath, local); + var file = _this.getFile(full); + if (!file) { + // TODO figure out what to do here + // what does it mean? deleted?ss + file = new DT.File(_this.runner.dtPath, local); + _this.setFile(file); + _this.removed[full] = file; + // console.log('not in index? %', file.fullPath); + } else { + _this.changed[full] = file; + } + }); + + // console.log('changed:\n' + Object.keys(this.changed).join('\n')); + // console.log('removed:\n' + Object.keys(this.removed).join('\n')); + resolve(); + }); + }; + + FileIndex.prototype.parseFiles = function () { + var _this = this; + return this.loadReferences(this.files).then(function () { + return _this.getMissingReferences(); + }); + }; + + FileIndex.prototype.getMissingReferences = function () { var _this = this; return Promise.attempt(function () { - _this.fileMap = Object.create(null); - files.forEach(function (file) { - _this.fileMap[file.fullPath] = file; + _this.missing = Object.create(null); + Lazy(_this.removed).keys().each(function (removed) { + if (removed in _this.refMap) { + _this.missing[removed] = _this.refMap[removed]; + } }); - return _this.loadReferences(files); }); }; @@ -262,6 +325,19 @@ var DT; } }; next(); + }).then(function () { + // bake reverse reference map (referenced to referrers) + _this.refMap = Object.create(null); + + Lazy(files).each(function (file) { + Lazy(file.references).each(function (ref) { + if (ref.fullPath in _this.refMap) { + _this.refMap[ref.fullPath].push(file); + } else { + _this.refMap[ref.fullPath] = [file]; + } + }); + }); }); }; @@ -287,11 +363,43 @@ var DT; return file; }); }; + + FileIndex.prototype.collectTargets = function () { + var _this = this; + return new Promise(function (resolve) { + // map out files linked to changes + // - queue holds files touched by a change + // - pre-fill with actually changed files + // - loop queue, if current not seen: + // - add to result + // - from refMap queue all files referring to current + var result = Object.create(null); + var queue = Lazy(_this.changed).values().toArray(); + + while (queue.length > 0) { + var next = queue.shift(); + var fp = next.fullPath; + if (result[fp]) { + continue; + } + result[fp] = next; + if (fp in _this.refMap) { + var arr = _this.refMap[fp]; + for (var i = 0, ii = arr.length; i < ii; i++) { + // just add it and skip expensive checks + queue.push(arr[i]); + } + } + } + resolve(Lazy(result).values().toArray()); + }); + }; return FileIndex; })(); DT.FileIndex = FileIndex; })(DT || (DT = {})); /// +/// var DT; (function (DT) { 'use strict'; @@ -302,11 +410,10 @@ var DT; var Promise = require('bluebird'); var GitChanges = (function () { - function GitChanges(baseDir) { - this.baseDir = baseDir; + function GitChanges(runner) { + this.runner = runner; this.options = {}; - this.paths = []; - var dir = path.join(baseDir, '.git'); + var dir = path.join(this.runner.dtPath, '.git'); if (!fs.existsSync(dir)) { throw new Error('cannot locate git-dir: ' + dir); } @@ -315,12 +422,11 @@ var DT; this.git = new Git(this.options); this.git.exec = Promise.promisify(this.git.exec); } - GitChanges.prototype.getChanges = function () { - var _this = this; + GitChanges.prototype.readChanges = function () { var opts = {}; var args = ['--name-only HEAD~1']; return this.git.exec('diff', opts, args).then(function (msg) { - _this.paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); + return msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); }); }; return GitChanges; @@ -393,7 +499,7 @@ var DT; }; Print.prototype.printErrorsForFile = function (testResult) { - this.out('----------------- For file:' + testResult.targetFile.formatName); + this.out('----------------- For file:' + testResult.targetFile.filePathWithName); this.printBreak().out(testResult.stderr).printBreak(); }; @@ -471,6 +577,101 @@ var DT; }); } }; + + Print.prototype.printTestComplete = function (testResult, index) { + var reporter = testResult.hostedBy.testReporter; + if (testResult.success) { + reporter.printPositiveCharacter(index, testResult); + } else { + reporter.printNegativeCharacter(index, testResult); + } + }; + + Print.prototype.printSuiteComplete = function (suite) { + this.printBreak(); + + this.printDiv(); + this.printElapsedTime(suite.timer.asString, suite.timer.time); + this.printSuccessCount(suite.okTests.length, suite.testResults.length); + this.printFailedCount(suite.ngTests.length, suite.testResults.length); + }; + + Print.prototype.printTests = function (adding) { + var _this = this; + this.printDiv(); + this.printSubHeader('Testing'); + this.printDiv(); + + Object.keys(adding).sort().map(function (src) { + _this.printLine(adding[src].filePathWithName); + return adding[src]; + }); + }; + + Print.prototype.printFiles = function (files) { + var _this = this; + this.printDiv(); + this.printSubHeader('Files:'); + this.printDiv(); + + files.forEach(function (file) { + _this.printLine(file.filePathWithName); + file.references.forEach(function (file) { + _this.printElement(file.filePathWithName); + }); + }); + }; + + Print.prototype.printMissing = function (index, refMap) { + var _this = this; + this.printDiv(); + this.printSubHeader('Missing references'); + this.printDiv(); + + Object.keys(refMap).sort().forEach(function (src) { + var ref = index.getFile(src); + _this.printLine('\33[31m\33[1m' + ref.filePathWithName + '\33[0m'); + refMap[src].forEach(function (file) { + _this.printElement(file.filePathWithName); + }); + }); + }; + + Print.prototype.printAllChanges = function (paths) { + var _this = this; + this.printSubHeader('All changes'); + this.printDiv(); + + paths.sort().forEach(function (line) { + _this.printLine(line); + }); + }; + + Print.prototype.printRelChanges = function (changeMap) { + var _this = this; + this.printDiv(); + this.printSubHeader('Relevant changes'); + this.printDiv(); + + Object.keys(changeMap).sort().forEach(function (src) { + _this.printLine(changeMap[src].filePathWithName); + }); + }; + + Print.prototype.printRefMap = function (index, refMap) { + var _this = this; + this.printDiv(); + this.printSubHeader('Referring'); + this.printDiv(); + + Object.keys(refMap).sort().forEach(function (src) { + var ref = index.getFile(src); + _this.printLine(ref.filePathWithName); + refMap[src].forEach(function (file) { + _this.printLine(' - ' + file.filePathWithName); + }); + }); + }; return Print; })(); DT.Print = Print; @@ -607,7 +808,7 @@ var DT; } SyntaxChecking.prototype.filterTargetFiles = function (files) { return Promise.cast(files.filter(function (file) { - return endDts.test(file.formatName); + return endDts.test(file.filePathWithName); })); }; return SyntaxChecking; @@ -634,7 +835,7 @@ var DT; } TestEval.prototype.filterTargetFiles = function (files) { return Promise.cast(files.filter(function (file) { - return endTestDts.test(file.formatName); + return endTestDts.test(file.filePathWithName); })); }; return TestEval; @@ -664,7 +865,7 @@ var DT; this.testReporter = { printPositiveCharacter: function (index, testResult) { - _this.print.clearCurrentLine().printTypingsWithoutTestName(testResult.targetFile.formatName); + _this.print.clearCurrentLine().printTypingsWithoutTestName(testResult.targetFile.filePathWithName); }, printNegativeCharacter: function (index, testResult) { } @@ -680,7 +881,7 @@ var DT; FindNotRequiredTscparams.prototype.runTest = function (targetFile) { var _this = this; - this.print.clearCurrentLine().out(targetFile.formatName); + this.print.clearCurrentLine().out(targetFile.filePathWithName); return new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion, @@ -729,7 +930,6 @@ var DT; var fs = require('fs'); var path = require('path'); - var glob = require('glob'); var assert = require('assert'); var tsExp = /\.ts$/; @@ -792,8 +992,9 @@ var DT; this.suites = []; this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - this.index = new DT.FileIndex(this.options); - this.changes = new DT.GitChanges(this.dtPath); + this.index = new DT.FileIndex(this, this.options); + this.changes = new DT.GitChanges(this); + this.print = new DT.Print(this.options.tscVersion); } TestRunner.prototype.addSuite = function (suite) { @@ -813,102 +1014,37 @@ var DT; this.timer = new DT.Timer(); this.timer.start(); + this.print.printChangeHeader(); + // only includes .d.ts or -tests.ts or -test.ts or .ts - return Promise.promisify(glob).call(glob, '**/*.ts', { - cwd: dtPath - }).then(function (filesNames) { - _this.files = Lazy(filesNames).filter(function (fileName) { - return _this.checkAcceptFile(fileName); - }).map(function (fileName) { - return new DT.File(dtPath, fileName); - }).toArray(); - - _this.print.printChangeHeader(); - - return _this.changes.getChanges().then(function () { - _this.printAllChanges(_this.changes.paths); - }); + return this.index.readIndex().then(function () { + return _this.changes.readChanges(); + }).then(function (changes) { + _this.print.printAllChanges(changes); + return _this.index.collectDiff(changes); }).then(function () { - return _this.index.parseFiles(_this.files).then(function () { - // this.printFiles(this.files); - }); + return _this.index.parseFiles(); }).then(function () { - return _this.collectTargets(_this.files, _this.changes.paths); - }).then(function (files) { - return _this.runTests(files); - }).then(function () { - return !_this.suites.some(function (suite) { - return suite.ngTests.length !== 0; - }); - }); - }; + // this.print.printRefMap(this.index, this.index.refMap); + if (Lazy(_this.index.missing).some(function (arr) { + return arr.length > 0; + })) { + _this.print.printMissing(_this.index, _this.index.missing); + _this.print.printBoldDiv(); - TestRunner.prototype.collectTargets = function (files, changes) { - var _this = this; - return new Promise(function (resolve) { - // filter changes and bake map for easy lookup - var changeMap = Object.create(null); - - Lazy(changes).filter(function (full) { - return _this.checkAcceptFile(full); - }).map(function (local) { - return path.resolve(_this.dtPath, local); - }).each(function (full) { - var file = _this.index.getFile(full); - if (!file) { - // TODO figure out what to do here - // what does it mean? deleted? - console.log('not in index: ' + full); - return; - } - changeMap[full] = file; - }); - - _this.printRelChanges(changeMap); - - // bake reverse reference map (referenced to referrers) - var refMap = Object.create(null); - - Lazy(files).each(function (file) { - Lazy(file.references).each(function (ref) { - if (ref.fullPath in refMap) { - refMap[ref.fullPath].push(file); - } else { - refMap[ref.fullPath] = [file]; - } - }); - }); - - // this.printRefMap(refMap); - // map out files linked to changes - // - queue holds files touched by a change - // - pre-fill with actually changed files - // - loop queue, if current not seen: - // - add to result - // - from refMap queue all files referring to current - var adding = Object.create(null); - var queue = Lazy(changeMap).values().toArray(); - - while (queue.length > 0) { - var next = queue.shift(); - var fp = next.fullPath; - if (adding[fp]) { - continue; - } - adding[fp] = next; - if (fp in refMap) { - var arr = refMap[fp]; - for (var i = 0, ii = arr.length; i < ii; i++) { - // just add it and skip expensive checks - queue.push(arr[i]); - } - } + // bail + return Promise.delay(500).return(false); } - _this.printTests(adding); - - var result = Lazy(adding).values().toArray(); - resolve(result); + // this.print.printFiles(this.files); + return _this.index.collectTargets().then(function (files) { + // this.print.printTests(files); + return _this.runTests(files); + }).then(function () { + return !_this.suites.some(function (suite) { + return suite.ngTests.length !== 0; + }); + }); }); }; @@ -944,10 +1080,10 @@ var DT; return suite.filterTargetFiles(files).then(function (targetFiles) { return suite.start(targetFiles, function (testResult, index) { - _this.printTestComplete(testResult, index); + _this.print.printTestComplete(testResult, index); }); }).then(function (suite) { - _this.printSuiteComplete(suite); + _this.print.printSuiteComplete(suite); return count++; }); }, 0); @@ -957,85 +1093,6 @@ var DT; }); }; - TestRunner.prototype.printTests = function (adding) { - var _this = this; - this.print.printDiv(); - this.print.printSubHeader('Testing'); - this.print.printDiv(); - - Object.keys(adding).sort().map(function (src) { - _this.print.printLine(adding[src].formatName); - return adding[src]; - }); - }; - TestRunner.prototype.printFiles = function (files) { - var _this = this; - this.print.printDiv(); - this.print.printSubHeader('Files:'); - this.print.printDiv(); - - files.forEach(function (file) { - _this.print.printLine(file.filePathWithName); - file.references.forEach(function (file) { - _this.print.printElement(file.filePathWithName); - }); - }); - }; - - TestRunner.prototype.printAllChanges = function (paths) { - var _this = this; - this.print.printSubHeader('All changes'); - this.print.printDiv(); - - paths.sort().forEach(function (line) { - _this.print.printLine(line); - }); - }; - - TestRunner.prototype.printRelChanges = function (changeMap) { - var _this = this; - this.print.printDiv(); - this.print.printSubHeader('Relevant changes'); - this.print.printDiv(); - - Object.keys(changeMap).sort().forEach(function (src) { - _this.print.printLine(changeMap[src].formatName); - }); - }; - - TestRunner.prototype.printRefMap = function (refMap) { - var _this = this; - this.print.printDiv(); - this.print.printSubHeader('Referring'); - this.print.printDiv(); - - Object.keys(refMap).sort().forEach(function (src) { - var ref = _this.index.getFile(src); - _this.print.printLine(ref.formatName); - refMap[src].forEach(function (file) { - _this.print.printLine(' - ' + file.formatName); - }); - }); - }; - - TestRunner.prototype.printTestComplete = function (testResult, index) { - var reporter = testResult.hostedBy.testReporter; - if (testResult.success) { - reporter.printPositiveCharacter(index, testResult); - } else { - reporter.printNegativeCharacter(index, testResult); - } - }; - - TestRunner.prototype.printSuiteComplete = function (suite) { - this.print.printBreak(); - - this.print.printDiv(); - this.print.printElapsedTime(suite.timer.asString, suite.timer.time); - this.print.printSuccessCount(suite.okTests.length, suite.testResults.length); - this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); - }; - TestRunner.prototype.finaliseTests = function (files) { var _this = this; var testEval = Lazy(this.suites).filter(function (suite) { diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 8dfcc7b4cc..126b824b20 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -27,7 +27,6 @@ module DT { var fs = require('fs'); var path = require('path'); - var glob = require('glob'); var assert = require('assert'); var tsExp = /\.ts$/; @@ -79,31 +78,23 @@ module DT { findNotRequiredTscparams?:boolean; } - export interface FileDict { - [fullPath:string]: File; - } - - export interface FileArrDict { - [fullPath:string]: File[]; - } - ///////////////////////////////// // The main class to kick things off ///////////////////////////////// export class TestRunner { - private files: File[]; private timer: Timer; private suites: ITestSuite[] = []; - private index: FileIndex; - private changes: GitChanges; - private print: Print; + public changes: GitChanges; + public index: FileIndex; + public print: Print; constructor(public dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) { this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams; - this.index = new FileIndex(this.options); - this.changes = new GitChanges(this.dtPath); + this.index = new FileIndex(this, this.options); + this.changes = new GitChanges(this); + this.print = new Print(this.options.tscVersion); } @@ -111,7 +102,7 @@ module DT { this.suites.push(suite); } - private checkAcceptFile(fileName: string): boolean { + public checkAcceptFile(fileName: string): boolean { var ok = tsExp.test(fileName); ok = ok && fileName.indexOf('_infrastructure') < 0; ok = ok && fileName.indexOf('node_modules/') < 0; @@ -123,104 +114,35 @@ module DT { this.timer = new Timer(); this.timer.start(); + this.print.printChangeHeader(); + // only includes .d.ts or -tests.ts or -test.ts or .ts - return Promise.promisify(glob).call(glob, '**/*.ts', { - cwd: dtPath - }).then((filesNames: string[]) => { - this.files = Lazy(filesNames).filter((fileName) => { - return this.checkAcceptFile(fileName); - }).map((fileName: string) => { - return new File(dtPath, fileName); - }).toArray(); - - this.print.printChangeHeader(); - - return this.changes.getChanges().then(() => { - this.printAllChanges(this.changes.paths); - }); + return this.index.readIndex().then(() => { + return this.changes.readChanges(); + }).then((changes: string[]) => { + this.print.printAllChanges(changes); + return this.index.collectDiff(changes); }).then(() => { - return this.index.parseFiles(this.files).then(() => { - // this.printFiles(this.files); - }); + return this.index.parseFiles(); }).then(() => { - return this.collectTargets(this.files, this.changes.paths); - }).then((files) => { - return this.runTests(files); - }).then(() => { - return !this.suites.some((suite) => { - return suite.ngTests.length !== 0 - }); - }); - } + // this.print.printRefMap(this.index, this.index.refMap); - private collectTargets(files: File[], changes: string[]): Promise { - return new Promise((resolve) => { + if (Lazy(this.index.missing).some((arr: any[]) => arr.length > 0)) { + this.print.printMissing(this.index, this.index.missing); + this.print.printBoldDiv(); + // bail + return Promise.delay(500).return(false); + } + // this.print.printFiles(this.files); + return this.index.collectTargets().then((files) => { + // this.print.printTests(files); - // filter changes and bake map for easy lookup - var changeMap: FileDict = Object.create(null); - - Lazy(changes).filter((full) => { - return this.checkAcceptFile(full); - }).map((local) => { - return path.resolve(this.dtPath, local); - }).each((full) => { - var file = this.index.getFile(full); - if (!file) { - // TODO figure out what to do here - // what does it mean? deleted? - console.log('not in index: ' + full); - return; - } - changeMap[full] = file; - }); - - this.printRelChanges(changeMap); - - // bake reverse reference map (referenced to referrers) - var refMap: FileArrDict = Object.create(null); - - Lazy(files).each((file) => { - Lazy(file.references).each((ref) => { - if (ref.fullPath in refMap) { - refMap[ref.fullPath].push(file); - } - else { - refMap[ref.fullPath] = [file]; - } + return this.runTests(files); + }).then(() => { + return !this.suites.some((suite) => { + return suite.ngTests.length !== 0 }); }); - - // this.printRefMap(refMap); - - // map out files linked to changes - // - queue holds files touched by a change - // - pre-fill with actually changed files - // - loop queue, if current not seen: - // - add to result - // - from refMap queue all files referring to current - var adding: FileDict = Object.create(null); - var queue = Lazy(changeMap).values().toArray(); - - while (queue.length > 0) { - var next = queue.shift(); - var fp = next.fullPath; - if (adding[fp]) { - continue; - } - adding[fp] = next; - if (fp in refMap) { - var arr = refMap[fp]; - for (var i = 0, ii = arr.length; i < ii; i++) { - // just add it and skip expensive checks - queue.push(arr[i]); - } - } - } - - this.printTests(adding); - - var result: File[] = Lazy(adding).values().toArray(); - resolve(result); }); } @@ -255,10 +177,10 @@ module DT { return suite.filterTargetFiles(files).then((targetFiles) => { return suite.start(targetFiles, (testResult, index) => { - this.printTestComplete(testResult, index); + this.print.printTestComplete(testResult, index); }); }).then((suite) => { - this.printSuiteComplete(suite); + this.print.printSuiteComplete(suite); return count++; }); }, 0); @@ -268,81 +190,6 @@ module DT { }); } - private printTests(adding: FileDict): void { - this.print.printDiv(); - this.print.printSubHeader('Testing'); - this.print.printDiv(); - - Object.keys(adding).sort().map((src) => { - this.print.printLine(adding[src].formatName); - return adding[src]; - }); - } - private printFiles(files: File[]): void { - this.print.printDiv(); - this.print.printSubHeader('Files:'); - this.print.printDiv(); - - files.forEach((file) => { - this.print.printLine(file.filePathWithName); - file.references.forEach((file) => { - this.print.printElement(file.filePathWithName); - }); - }); - } - - private printAllChanges(paths: string[]): void { - this.print.printSubHeader('All changes'); - this.print.printDiv(); - - paths.sort().forEach((line) => { - this.print.printLine(line); - }); - } - - private printRelChanges(changeMap: FileDict): void { - this.print.printDiv(); - this.print.printSubHeader('Relevant changes'); - this.print.printDiv(); - - Object.keys(changeMap).sort().forEach((src) => { - this.print.printLine(changeMap[src].formatName); - }); - } - - private printRefMap(refMap: FileArrDict): void { - this.print.printDiv(); - this.print.printSubHeader('Referring'); - this.print.printDiv(); - - Object.keys(refMap).sort().forEach((src) => { - var ref = this.index.getFile(src); - this.print.printLine(ref.formatName); - refMap[src].forEach((file) => { - this.print.printLine(' - ' + file.formatName); - }); - }); - } - - private printTestComplete(testResult: TestResult, index: number): void { - var reporter = testResult.hostedBy.testReporter; - if (testResult.success) { - reporter.printPositiveCharacter(index, testResult); - } - else { - reporter.printNegativeCharacter(index, testResult); - } - } - - private printSuiteComplete(suite: ITestSuite): void { - this.print.printBreak(); - - this.print.printDiv(); - this.print.printElapsedTime(suite.timer.asString, suite.timer.time); - this.print.printSuccessCount(suite.okTests.length, suite.testResults.length); - this.print.printFailedCount(suite.ngTests.length, suite.testResults.length); - } - private finaliseTests(files: File[]): void { var testEval: TestEval = Lazy(this.suites).filter((suite) => { return suite instanceof TestEval; diff --git a/_infrastructure/tests/src/changes.ts b/_infrastructure/tests/src/changes.ts index f3ec262084..a56c4029eb 100644 --- a/_infrastructure/tests/src/changes.ts +++ b/_infrastructure/tests/src/changes.ts @@ -1,4 +1,5 @@ /// +/// module DT { 'use strict'; @@ -12,10 +13,9 @@ module DT { git; options = {}; - paths: string[] = []; - constructor(public baseDir: string) { - var dir = path.join(baseDir, '.git'); + constructor(private runner: TestRunner) { + var dir = path.join(this.runner.dtPath, '.git'); if (!fs.existsSync(dir)) { throw new Error('cannot locate git-dir: ' + dir); } @@ -25,11 +25,11 @@ module DT { this.git.exec = Promise.promisify(this.git.exec); } - getChanges(): Promise { + public readChanges(): Promise { var opts = {}; var args = ['--name-only HEAD~1']; return this.git.exec('diff', opts, args).then((msg: string) => { - this.paths = msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); + return msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g); }); } } diff --git a/_infrastructure/tests/src/file.ts b/_infrastructure/tests/src/file.ts index 389936b491..2c69f8f885 100644 --- a/_infrastructure/tests/src/file.ts +++ b/_infrastructure/tests/src/file.ts @@ -5,6 +5,14 @@ module DT { var path = require('path'); + export interface FileDict { + [fullPath:string]: File; + } + + export interface FileArrDict { + [fullPath:string]: File[]; + } + ///////////////////////////////// // Given a document root + ts file pattern this class returns: // all the TS files OR just tests OR just definition files @@ -15,7 +23,6 @@ module DT { dir: string; file: string; ext: string; - formatName: string; fullPath: string; references: File[] = []; @@ -26,14 +33,13 @@ module DT { this.ext = path.extname(this.filePathWithName); this.file = path.basename(this.filePathWithName, this.ext); this.dir = path.dirname(this.filePathWithName); - this.formatName = path.join(this.dir, this.file + this.ext); this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext); // lock it (shallow) (needs `use strict` in each file to work) // Object.freeze(this); } - toString() { + toString(): string { return '[File ' + this.filePathWithName + ']'; } } diff --git a/_infrastructure/tests/src/index.ts b/_infrastructure/tests/src/index.ts index 183c1e64db..7f5878dcb3 100644 --- a/_infrastructure/tests/src/index.ts +++ b/_infrastructure/tests/src/index.ts @@ -7,7 +7,8 @@ module DT { var fs = require('fs'); var path = require('path'); - var Lazy = require('lazy.js'); + var glob = require('glob'); + var Lazy: LazyJS.LazyStatic = require('lazy.js'); var Promise: typeof Promise = require('bluebird'); var readFile = Promise.promisify(fs.readFile); @@ -17,31 +18,95 @@ module DT { ///////////////////////////////// export class FileIndex { - fileMap: {[fullPath:string]:File}; + files: File[]; + fileMap: FileDict; + refMap: FileArrDict; options: ITestRunnerOptions; + changed: FileDict; + removed: FileDict; + missing: FileArrDict; - constructor(options: ITestRunnerOptions) { + constructor(private runner: TestRunner, options: ITestRunnerOptions) { this.options = options; } - hasFile(target: string): boolean { + public hasFile(target: string): boolean { return target in this.fileMap; } - getFile(target: string): File { + public getFile(target: string): File { if (target in this.fileMap) { return this.fileMap[target]; } return null; } - parseFiles(files: File[]): Promise { - return Promise.attempt(() => { - this.fileMap = Object.create(null); - files.forEach((file) => { + public setFile(file: File): void { + if (file.fullPath in this.fileMap) { + throw new Error('cannot overwrite file'); + } + this.fileMap[file.fullPath] = file; + } + + public readIndex(): Promise { + this.fileMap = Object.create(null); + + return Promise.promisify(glob).call(glob, '**/*.ts', { + cwd: this.runner.dtPath + }).then((filesNames: string[]) => { + this.files = Lazy(filesNames).filter((fileName) => { + return this.runner.checkAcceptFile(fileName); + }).map((fileName: string) => { + var file = new File(this.runner.dtPath, fileName); this.fileMap[file.fullPath] = file; + return file; + }).toArray(); + }); + } + + public collectDiff(changes: string[]): Promise { + return new Promise((resolve) => { + // filter changes and bake map for easy lookup + this.changed = Object.create(null); + this.removed = Object.create(null); + + Lazy(changes).filter((full) => { + return this.runner.checkAcceptFile(full); + }).uniq().each((local) => { + var full = path.resolve(this.runner.dtPath, local); + var file = this.getFile(full); + if (!file) { + // TODO figure out what to do here + // what does it mean? deleted?ss + file = new File(this.runner.dtPath, local); + this.setFile(file); + this.removed[full] = file; + // console.log('not in index? %', file.fullPath); + } + else { + this.changed[full] = file; + } + }); + // console.log('changed:\n' + Object.keys(this.changed).join('\n')); + // console.log('removed:\n' + Object.keys(this.removed).join('\n')); + resolve(); + }); + } + + public parseFiles(): Promise { + return this.loadReferences(this.files).then(() => { + return this.getMissingReferences(); + }); + } + + private getMissingReferences(): Promise { + return Promise.attempt(() => { + this.missing = Object.create(null); + Lazy(this.removed).keys().each((removed) => { + if (removed in this.refMap) { + this.missing[removed] = this.refMap[removed]; + } }); - return this.loadReferences(files); }); } @@ -70,6 +135,20 @@ module DT { } }; next(); + }).then(() => { + // bake reverse reference map (referenced to referrers) + this.refMap = Object.create(null); + + Lazy(files).each((file) => { + Lazy(file.references).each((ref) => { + if (ref.fullPath in this.refMap) { + this.refMap[ref.fullPath].push(file); + } + else { + this.refMap[ref.fullPath] = [file]; + } + }); + }); }); } @@ -94,5 +173,36 @@ module DT { return file; }); } + + public collectTargets(): Promise { + return new Promise((resolve) => { + // map out files linked to changes + // - queue holds files touched by a change + // - pre-fill with actually changed files + // - loop queue, if current not seen: + // - add to result + // - from refMap queue all files referring to current + + var result: FileDict = Object.create(null); + var queue = Lazy(this.changed).values().toArray(); + + while (queue.length > 0) { + var next = queue.shift(); + var fp = next.fullPath; + if (result[fp]) { + continue; + } + result[fp] = next; + if (fp in this.refMap) { + var arr = this.refMap[fp]; + for (var i = 0, ii = arr.length; i < ii; i++) { + // just add it and skip expensive checks + queue.push(arr[i]); + } + } + } + resolve(Lazy(result).values().toArray()); + }); + } } } diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts index 613251b825..9be9a79aa5 100644 --- a/_infrastructure/tests/src/printer.ts +++ b/_infrastructure/tests/src/printer.ts @@ -72,7 +72,7 @@ module DT { } public printErrorsForFile(testResult: TestResult) { - this.out('----------------- For file:' + testResult.targetFile.formatName); + this.out('----------------- For file:' + testResult.targetFile.filePathWithName); this.printBreak().out(testResult.stderr).printBreak(); } @@ -149,5 +149,95 @@ module DT { }); } } + + public printTestComplete(testResult: TestResult, index: number): void { + var reporter = testResult.hostedBy.testReporter; + if (testResult.success) { + reporter.printPositiveCharacter(index, testResult); + } + else { + reporter.printNegativeCharacter(index, testResult); + } + } + + public printSuiteComplete(suite: ITestSuite): void { + this.printBreak(); + + this.printDiv(); + this.printElapsedTime(suite.timer.asString, suite.timer.time); + this.printSuccessCount(suite.okTests.length, suite.testResults.length); + this.printFailedCount(suite.ngTests.length, suite.testResults.length); + } + + public printTests(adding: FileDict): void { + this.printDiv(); + this.printSubHeader('Testing'); + this.printDiv(); + + Object.keys(adding).sort().map((src) => { + this.printLine(adding[src].filePathWithName); + return adding[src]; + }); + } + + public printFiles(files: File[]): void { + this.printDiv(); + this.printSubHeader('Files:'); + this.printDiv(); + + files.forEach((file) => { + this.printLine(file.filePathWithName); + file.references.forEach((file) => { + this.printElement(file.filePathWithName); + }); + }); + } + + public printMissing(index: FileIndex, refMap: FileArrDict): void { + this.printDiv(); + this.printSubHeader('Missing references'); + this.printDiv(); + + Object.keys(refMap).sort().forEach((src) => { + var ref = index.getFile(src); + this.printLine('\33[31m\33[1m' + ref.filePathWithName + '\33[0m'); + refMap[src].forEach((file) => { + this.printElement(file.filePathWithName); + }); + }); + } + + public printAllChanges(paths: string[]): void { + this.printSubHeader('All changes'); + this.printDiv(); + + paths.sort().forEach((line) => { + this.printLine(line); + }); + } + + public printRelChanges(changeMap: FileDict): void { + this.printDiv(); + this.printSubHeader('Relevant changes'); + this.printDiv(); + + Object.keys(changeMap).sort().forEach((src) => { + this.printLine(changeMap[src].filePathWithName); + }); + } + + public printRefMap(index: FileIndex, refMap: FileArrDict): void { + this.printDiv(); + this.printSubHeader('Referring'); + this.printDiv(); + + Object.keys(refMap).sort().forEach((src) => { + var ref = index.getFile(src); + this.printLine(ref.filePathWithName); + refMap[src].forEach((file) => { + this.printLine(' - ' + file.filePathWithName); + }); + }); + } } } diff --git a/_infrastructure/tests/src/suite/syntax.ts b/_infrastructure/tests/src/suite/syntax.ts index 41808b2a2b..2e0d0b71aa 100644 --- a/_infrastructure/tests/src/suite/syntax.ts +++ b/_infrastructure/tests/src/suite/syntax.ts @@ -19,7 +19,7 @@ module DT { public filterTargetFiles(files: File[]): Promise { return Promise.cast(files.filter((file) => { - return endDts.test(file.formatName); + return endDts.test(file.filePathWithName); })); } } diff --git a/_infrastructure/tests/src/suite/testEval.ts b/_infrastructure/tests/src/suite/testEval.ts index bc842549fc..95044daa7b 100644 --- a/_infrastructure/tests/src/suite/testEval.ts +++ b/_infrastructure/tests/src/suite/testEval.ts @@ -19,7 +19,7 @@ module DT { public filterTargetFiles(files: File[]): Promise { return Promise.cast(files.filter((file) => { - return endTestDts.test(file.formatName); + return endTestDts.test(file.filePathWithName); })); } } diff --git a/_infrastructure/tests/src/suite/tscParams.ts b/_infrastructure/tests/src/suite/tscParams.ts index cef23d622b..bb064dd818 100644 --- a/_infrastructure/tests/src/suite/tscParams.ts +++ b/_infrastructure/tests/src/suite/tscParams.ts @@ -22,7 +22,7 @@ module DT { printPositiveCharacter: (index: number, testResult: TestResult) => { this.print .clearCurrentLine() - .printTypingsWithoutTestName(testResult.targetFile.formatName); + .printTypingsWithoutTestName(testResult.targetFile.filePathWithName); }, printNegativeCharacter: (index: number, testResult: TestResult) => { } @@ -38,7 +38,7 @@ module DT { } public runTest(targetFile: File): Promise { - this.print.clearCurrentLine().out(targetFile.formatName); + this.print.clearCurrentLine().out(targetFile.filePathWithName); return new Test(this, targetFile, { tscVersion: this.options.tscVersion, diff --git a/_infrastructure/tests/typings/lazy.js/lazy.js.d.ts b/_infrastructure/tests/typings/lazy.js/lazy.js.d.ts index b9367b73bc..b2909dfceb 100644 --- a/_infrastructure/tests/typings/lazy.js/lazy.js.d.ts +++ b/_infrastructure/tests/typings/lazy.js/lazy.js.d.ts @@ -6,12 +6,12 @@ declare module LazyJS { interface LazyStatic { - (value: string):StringLikeSequence; (value: T[]):ArrayLikeSequence; (value: any[]):ArrayLikeSequence; (value: Object):ObjectLikeSequence; (value: Object):ObjectLikeSequence; + (value: string):StringLikeSequence; strict():LazyStatic; @@ -200,7 +200,7 @@ declare module LazyJS { functions(): Sequence; get(property: string): ObjectLikeSequence; invert(): ObjectLikeSequence; - keys(): StringLikeSequence; + keys(): Sequence; omit(properties: string[]): ObjectLikeSequence; pairs(): Sequence; pick(properties: string[]): ObjectLikeSequence; From b134395b23a93521aa0936aca5162b88f19322df Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 1 Mar 2014 02:16:12 +0100 Subject: [PATCH 237/240] tuned tester tuned output to show changes / removals test filter RegExp finds: - file-tests.d.ts - file-test.d.ts --- _infrastructure/tests/runner.js | 34 ++++++++++++++++++--- _infrastructure/tests/runner.ts | 6 ++-- _infrastructure/tests/src/printer.ts | 24 +++++++++++++-- _infrastructure/tests/src/suite/testEval.ts | 3 +- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index c6ab61c8a4..e21bbd42be 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -608,10 +608,20 @@ var DT; }); }; + Print.prototype.printQueue = function (files) { + var _this = this; + this.printDiv(); + this.printSubHeader('Queued for testing'); + this.printDiv(); + + files.forEach(function (file) { + _this.printLine(file.filePathWithName); + }); + }; Print.prototype.printFiles = function (files) { var _this = this; this.printDiv(); - this.printSubHeader('Files:'); + this.printSubHeader('Files'); this.printDiv(); files.forEach(function (file) { @@ -650,7 +660,18 @@ var DT; Print.prototype.printRelChanges = function (changeMap) { var _this = this; this.printDiv(); - this.printSubHeader('Relevant changes'); + this.printSubHeader('Interesting files'); + this.printDiv(); + + Object.keys(changeMap).sort().forEach(function (src) { + _this.printLine(changeMap[src].filePathWithName); + }); + }; + + Print.prototype.printRemovals = function (changeMap) { + var _this = this; + this.printDiv(); + this.printSubHeader('Removed files'); this.printDiv(); Object.keys(changeMap).sort().forEach(function (src) { @@ -823,7 +844,7 @@ var DT; var Promise = require('bluebird'); - var endTestDts = /-test.ts$/i; + var endTestDts = /-tests?.ts$/i; ///////////////////////////////// // Compile with *-tests.ts @@ -1023,6 +1044,8 @@ var DT; _this.print.printAllChanges(changes); return _this.index.collectDiff(changes); }).then(function () { + _this.print.printRemovals(_this.index.removed); + _this.print.printRelChanges(_this.index.changed); return _this.index.parseFiles(); }).then(function () { // this.print.printRefMap(this.index, this.index.refMap); @@ -1033,12 +1056,13 @@ var DT; _this.print.printBoldDiv(); // bail - return Promise.delay(500).return(false); + return Promise.cast(false); } // this.print.printFiles(this.files); return _this.index.collectTargets().then(function (files) { - // this.print.printTests(files); + _this.print.printQueue(files); + return _this.runTests(files); }).then(function () { return !_this.suites.some(function (suite) { diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 126b824b20..4e72001b88 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -123,6 +123,8 @@ module DT { this.print.printAllChanges(changes); return this.index.collectDiff(changes); }).then(() => { + this.print.printRemovals(this.index.removed); + this.print.printRelChanges(this.index.changed); return this.index.parseFiles(); }).then(() => { // this.print.printRefMap(this.index, this.index.refMap); @@ -131,11 +133,11 @@ module DT { this.print.printMissing(this.index, this.index.missing); this.print.printBoldDiv(); // bail - return Promise.delay(500).return(false); + return Promise.cast(false); } // this.print.printFiles(this.files); return this.index.collectTargets().then((files) => { - // this.print.printTests(files); + this.print.printQueue(files); return this.runTests(files); }).then(() => { diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts index 9be9a79aa5..962d7b644d 100644 --- a/_infrastructure/tests/src/printer.ts +++ b/_infrastructure/tests/src/printer.ts @@ -180,9 +180,19 @@ module DT { }); } + public printQueue(files: File[]): void { + this.printDiv(); + this.printSubHeader('Queued for testing'); + this.printDiv(); + + files.forEach((file) => { + this.printLine(file.filePathWithName); + }); + + } public printFiles(files: File[]): void { this.printDiv(); - this.printSubHeader('Files:'); + this.printSubHeader('Files'); this.printDiv(); files.forEach((file) => { @@ -218,7 +228,17 @@ module DT { public printRelChanges(changeMap: FileDict): void { this.printDiv(); - this.printSubHeader('Relevant changes'); + this.printSubHeader('Interesting files'); + this.printDiv(); + + Object.keys(changeMap).sort().forEach((src) => { + this.printLine(changeMap[src].filePathWithName); + }); + } + + public printRemovals(changeMap: FileDict): void { + this.printDiv(); + this.printSubHeader('Removed files'); this.printDiv(); Object.keys(changeMap).sort().forEach((src) => { diff --git a/_infrastructure/tests/src/suite/testEval.ts b/_infrastructure/tests/src/suite/testEval.ts index 95044daa7b..410d8998ba 100644 --- a/_infrastructure/tests/src/suite/testEval.ts +++ b/_infrastructure/tests/src/suite/testEval.ts @@ -6,7 +6,7 @@ module DT { var Promise: typeof Promise = require('bluebird'); - var endTestDts = /-test.ts$/i; + var endTestDts = /-tests?.ts$/i; ///////////////////////////////// // Compile with *-tests.ts @@ -23,5 +23,4 @@ module DT { })); } } - } From 630221350207ad0b00c688ed5db863dfc11fe72e Mon Sep 17 00:00:00 2001 From: satoru kimura Date: Sat, 1 Mar 2014 20:24:28 +0900 Subject: [PATCH 238/240] update to three.js r66. --- threejs/three-tests.ts | 299 +- threejs/three.d.ts | 11253 ++++++++++++++++----------------- threejs/three.d.ts.tscparams | 1 - 3 files changed, 5391 insertions(+), 6162 deletions(-) delete mode 100644 threejs/three.d.ts.tscparams diff --git a/threejs/three-tests.ts b/threejs/three-tests.ts index 5f079347fe..afb4b23004 100644 --- a/threejs/three-tests.ts +++ b/threejs/three-tests.ts @@ -1613,7 +1613,7 @@ THE SOFTWARE. }); var orders = [ 'XYZ', 'YXZ', 'ZXY', 'ZYX', 'YZX', 'XZY' ]; - var eulerAngles = new THREE.Vector3( 0.1, -0.3, 0.25 ); + var eulerAngles = new THREE.Euler( 0.1, -0.3, 0.25 ); @@ -1699,16 +1699,19 @@ THE SOFTWARE. }); - test( "setFromEuler/setEulerFromQuaternion", function() { + test( "setFromEuler/setFromQuaternion", function() { var angles = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ]; // ensure euler conversion to/from Quaternion matches. for( var i = 0; i < orders.length; i ++ ) { for( var j = 0; j < angles.length; j ++ ) { - var eulers2 = new THREE.Vector3().setEulerFromQuaternion( new THREE.Quaternion().setFromEuler( angles[j], orders[i] ), orders[i] ); - - ok( eulers2.distanceTo( angles[j] ) < 0.001, "Passed!" ); + var eulers2 = new THREE.Euler().setFromQuaternion( + new THREE.Quaternion().setFromEuler(new THREE.Euler(angles[j].x, angles[j].y, angles[j].z, orders[i])), + orders[i] + ); + var v = new THREE.Vector3().applyEuler(eulers2); + ok( v.distanceTo( angles[j] ) < 0.001, "Passed!" ); } } @@ -1718,8 +1721,8 @@ THE SOFTWARE. // ensure euler conversion for Quaternion matches that of Matrix4 for( var i = 0; i < orders.length; i ++ ) { - var q = new THREE.Quaternion().setFromEuler( eulerAngles, orders[i] ); - var m = new THREE.Matrix4().setRotationFromEuler( eulerAngles, orders[i] ); + var q = new THREE.Quaternion().setFromEuler( eulerAngles ); + var m = new THREE.Matrix4().makeRotationFromEuler( eulerAngles ); var q2 = new THREE.Quaternion().setFromRotationMatrix( m ); ok( qSub( q, q2 ).length() < 0.001, "Passed!" ); @@ -1763,15 +1766,15 @@ THE SOFTWARE. var angles = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ]; - var q1 = new THREE.Quaternion().setFromEuler( angles[0], "XYZ" ); - var q2 = new THREE.Quaternion().setFromEuler( angles[1], "XYZ" ); - var q3 = new THREE.Quaternion().setFromEuler( angles[2], "XYZ" ); + var q1 = new THREE.Quaternion().setFromEuler( new THREE.Euler(angles[0].x, angles[0].y, angles[0].z) ); + var q2 = new THREE.Quaternion().setFromEuler( new THREE.Euler(angles[1].x, angles[1].y, angles[1].z) ); + var q3 = new THREE.Quaternion().setFromEuler( new THREE.Euler(angles[2].x, angles[2].y, angles[2].z) ); var q = new THREE.Quaternion().multiplyQuaternions( q1, q2 ).multiply( q3 ); - var m1 = new THREE.Matrix4().setRotationFromEuler( angles[0], "XYZ" ); - var m2 = new THREE.Matrix4().setRotationFromEuler( angles[1], "XYZ" ); - var m3 = new THREE.Matrix4().setRotationFromEuler( angles[2], "XYZ" ); + var m1 = new THREE.Matrix4().makeRotationFromEuler( new THREE.Euler(angles[0].x, angles[0].y, angles[0].z) ); + var m2 = new THREE.Matrix4().makeRotationFromEuler( new THREE.Euler(angles[1].x, angles[1].y, angles[1].z) ); + var m3 = new THREE.Matrix4().makeRotationFromEuler( new THREE.Euler(angles[2].x, angles[2].y, angles[2].z) ); var m = new THREE.Matrix4().multiplyMatrices( m1, m2 ).multiply( m3 ); @@ -1787,8 +1790,8 @@ THE SOFTWARE. // ensure euler conversion for Quaternion matches that of Matrix4 for( var i = 0; i < orders.length; i ++ ) { for( var j = 0; j < angles.length; j ++ ) { - var q = new THREE.Quaternion().setFromEuler( angles[j], orders[i] ); - var m = new THREE.Matrix4().setRotationFromEuler( angles[j], orders[i] ); + var q = new THREE.Quaternion().setFromEuler( new THREE.Euler(angles[j].x, angles[j].y, angles[j].z, orders[i]) ); + var m = new THREE.Matrix4().makeRotationFromEuler( new THREE.Euler(angles[j].x, angles[j].y, angles[j].z, orders[i]) ); var v0 = new THREE.Vector3(1, 0, 0); var qv = v0.clone().applyQuaternion( q ); @@ -1971,10 +1974,10 @@ THE SOFTWARE. ok( a.clone().applyMatrix4( m ).equals( a ), "Passed!" ); a = new THREE.Ray( zero3.clone(), new THREE.Vector3( 0, 0, 1 ) ); - m.rotateByAxis( new THREE.Vector3( 0, 0, 1 ), Math.PI ); + m.makeRotationAxis( new THREE.Vector3( 0, 0, 1 ), Math.PI ); ok( a.clone().applyMatrix4( m ).equals( a ), "Passed!" ); - m.identity().rotateX( Math.PI ); + m.identity().makeRotationX( Math.PI ); var b = a.clone(); b.direction.negate(); var a2 = a.clone().applyMatrix4( m ); @@ -4467,7 +4470,7 @@ var container, stats; } var PI2 = Math.PI * 2; - particleMaterial = new THREE.ParticleCanvasMaterial( { + particleMaterial = new THREE.ParticleSystemMaterial( { color: 0x000000, program: function ( context ) { @@ -4527,7 +4530,8 @@ var container, stats; var mat = mesh.material; mat.color.setHex( Math.random() * 0xffffff ); - var particle = new THREE.Particle( particleMaterial ); + var geometry = new THREE.Geometry(); + var particle = new THREE.ParticleSystem(geometry, particleMaterial ); particle.position = intersects[ 0 ].point; particle.scale.x = particle.scale.y = 8; scene.add( particle ); @@ -4623,8 +4627,8 @@ var container, stats; scene = new THREE.Scene(); for ( var i = 0; i < 100; i ++ ) { - - var particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808080 + 0x808080, program: programStroke } ) ); + var geometry = new THREE.Geometry(); + var particle = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: Math.random() * 0x808080 + 0x808080, program: programStroke } ) ); particle.position.x = Math.random() * 800 - 400; particle.position.y = Math.random() * 800 - 400; particle.position.z = Math.random() * 800 - 400; @@ -5154,15 +5158,16 @@ var container, stats; } - particle1 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0xff0040, program: program } ) ); + var geometry = new THREE.Geometry(); + particle1 = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: 0xff0040, program: program } ) ); particle1.scale.x = particle1.scale.y = particle1.scale.z = 0.5; scene.add( particle1 ); - particle2 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x0040ff, program: program } ) ); + particle2 = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: 0x0040ff, program: program } ) ); particle2.scale.x = particle2.scale.y = particle2.scale.z = 0.5; scene.add( particle2 ); - particle3 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x80ff80, program: program } ) ); + particle3 = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: 0x80ff80, program: program } ) ); particle3.scale.x = particle3.scale.y = particle3.scale.z = 0.5; scene.add( particle3 ); @@ -5277,15 +5282,16 @@ var container, stats; } - particle1 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0xff0040, program: program } ) ); + var geometry = new THREE.Geometry(); + particle1 = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: 0xff0040, program: program } ) ); particle1.scale.x = particle1.scale.y = particle1.scale.z = 0.5; scene.add( particle1 ); - particle2 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x0040ff, program: program } ) ); + particle2 = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: 0x0040ff, program: program } ) ); particle2.scale.x = particle2.scale.y = particle2.scale.z = 0.5; scene.add( particle2 ); - particle3 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x80ff80, program: program } ) ); + particle3 = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: 0x80ff80, program: program } ) ); particle3.scale.x = particle3.scale.y = particle3.scale.z = 0.5; scene.add( particle3 ); @@ -5401,7 +5407,7 @@ var container, stats; // particles var PI2 = Math.PI * 2; - var material = new THREE.ParticleCanvasMaterial( { + var material = new THREE.ParticleSystemMaterial( { color: 0xffffff, program: function ( context ) { @@ -5419,7 +5425,7 @@ var container, stats; for ( var i = 0; i < 100; i ++ ) { - particle = new THREE.Particle( material ); + particle = new THREE.ParticleSystem(geometry, material ); particle.position.x = Math.random() * 2 - 1; particle.position.y = Math.random() * 2 - 1; particle.position.z = Math.random() * 2 - 1; @@ -5556,7 +5562,7 @@ var container, stats; // particles var PI2 = Math.PI * 2; - var material = new THREE.ParticleCanvasMaterial( { + var material = new THREE.ParticleSystemMaterial( { color: 0xffffff, program: function ( context ) { @@ -5570,9 +5576,10 @@ var container, stats; } ); + var geometry = new THREE.Geometry(); for ( var i = 0; i < 1000; i ++ ) { - particle = new THREE.Particle( material ); + particle = new THREE.ParticleSystem(geometry, material ); particle.position.x = Math.random() * 2 - 1; particle.position.y = Math.random() * 2 - 1; particle.position.z = Math.random() * 2 - 1; @@ -5780,7 +5787,8 @@ var container, stats; } - particleLight = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0xffffff, program: program } ) ); + var geometry = new THREE.Geometry(); + particleLight = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: 0xffffff, program: program } ) ); particleLight.scale.x = particleLight.scale.y = particleLight.scale.z = 4; scene.add( particleLight ); @@ -6344,7 +6352,7 @@ var container, stats; var amounty = 10; var PI2 = Math.PI * 2; - var materialParticle = new THREE.ParticleCanvasMaterial( { + var materialParticle = new THREE.ParticleSystemMaterial( { color: 0x0808080, program: function ( context ) { @@ -6358,11 +6366,10 @@ var container, stats; } ); + var geometry = new THREE.Geometry(); for ( var ix = 0; ix < amountx; ix++ ) { - for ( var iy = 0; iy < amounty; iy++ ) { - - var particle = new THREE.Particle( materialParticle ); + var particle = new THREE.ParticleSystem(geometry, materialParticle ); particle.position.x = ix * separation - ( ( amountx * separation ) / 2 ); particle.position.y = -153 particle.position.z = iy * separation - ( ( amounty * separation ) / 2 ); @@ -6472,13 +6479,13 @@ var container, stats; scene = new THREE.Scene(); - var material = new THREE.ParticleBasicMaterial(); - + var material = new THREE.ParticleSystemMaterial(); + var geometry = new THREE.Geometry(); for ( var ix = 0; ix < AMOUNTX; ix++ ) { for ( var iy = 0; iy < AMOUNTY; iy++ ) { - particle = new THREE.Particle( material ); + particle = new THREE.ParticleSystem(geometry, material ); particle.scale.y = 4; particle.position.x = ix * SEPARATION - ( ( AMOUNTX * SEPARATION ) / 2 ); particle.position.z = iy * SEPARATION - ( ( AMOUNTY * SEPARATION ) / 2 ); @@ -6607,9 +6614,10 @@ var container, stats; group = new THREE.Object3D(); scene.add( group ); + var geometry = new THREE.Geometry(); for ( var i = 0; i < 1000; i++ ) { - particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) ); + particle = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) ); particle.position.x = Math.random() * 2000 - 1000; particle.position.y = Math.random() * 2000 - 1000; particle.position.z = Math.random() * 2000 - 1000; @@ -6730,11 +6738,11 @@ var container, stats; scene = new THREE.Scene(); - var material = new THREE.ParticleBasicMaterial({ map: new THREE.Texture(generateSprite()), blending: THREE.AdditiveBlending }); - + var material = new THREE.ParticleSystemMaterial({ map: new THREE.Texture(generateSprite()), blending: THREE.AdditiveBlending }); + var geometry = new THREE.Geometry(); for (var i = 0; i < 1000; i++) { - particle = new THREE.Particle(material); + particle = new THREE.ParticleSystem(geometry, material); initParticle(particle, i * 10); @@ -6796,7 +6804,7 @@ var container, stats; function initParticle(particle, delay) { - var particle = this instanceof THREE.Particle ? this : particle; + var particle = this instanceof THREE.ParticleSystem ? this : particle; var delay = delay !== undefined ? delay : 0; particle.position.x = 0; @@ -6900,11 +6908,11 @@ var container, stats; scene = new THREE.Scene(); - var material = new THREE.ParticleBasicMaterial( { map: new THREE.Texture( generateSprite() ), blending: THREE.AdditiveBlending } ); - + var material = new THREE.ParticleSystemMaterial( { map: new THREE.Texture( generateSprite() ), blending: THREE.AdditiveBlending } ); + var geometry = new THREE.Geometry(); for ( var i = 0; i < 1000; i++ ) { - particle = new THREE.Particle( material ); + particle = new THREE.ParticleSystem(geometry, material ); initParticle( particle, i * 10 ); @@ -6966,7 +6974,7 @@ var container, stats; function initParticle( particle, delay ) { - var particle = this instanceof THREE.Particle ? this : particle; + var particle = this instanceof THREE.ParticleSystem ? this : particle; var delay = delay !== undefined ? delay : 0; particle.position.x = 0; @@ -7083,7 +7091,7 @@ var container, stats; particles = new Array(); var PI2 = Math.PI * 2; - var material = new THREE.ParticleCanvasMaterial( { + var material = new THREE.ParticleSystemMaterial( { color: 0xffffff, program: function ( context ) { @@ -7097,12 +7105,12 @@ var container, stats; } ); var i = 0; - + var geometry = new THREE.Geometry(); for ( var ix = 0; ix < AMOUNTX; ix ++ ) { for ( var iy = 0; iy < AMOUNTY; iy ++ ) { - particle = particles[ i ++ ] = new THREE.Particle( material ); + particle = particles[ i ++ ] = new THREE.ParticleSystem(geometry, material ); particle.position.x = ix * SEPARATION - ( ( AMOUNTX * SEPARATION ) / 2 ); particle.position.z = iy * SEPARATION - ( ( AMOUNTY * SEPARATION ) / 2 ); scene.add( particle ); @@ -7948,8 +7956,8 @@ var container, stats; joint.position.copy( start ); joint.position.lerp( end, 0.5 ); - joint.matrix.copy( objMatrix ); - joint.rotation.setEulerFromRotationMatrix( joint.matrix, joint.eulerOrder ); + joint.matrix.copy(objMatrix); + joint.rotation = new THREE.Euler().setFromRotationMatrix(joint.matrix, joint.eulerOrder); joint.matrixAutoUpdate = false; joint.updateMatrix(); @@ -9086,12 +9094,12 @@ var container, stats; var stars; var starsMaterials = [ - new THREE.ParticleBasicMaterial( { color: 0x555555, size: 2, sizeAttenuation: false } ), - new THREE.ParticleBasicMaterial( { color: 0x555555, size: 1, sizeAttenuation: false } ), - new THREE.ParticleBasicMaterial( { color: 0x333333, size: 2, sizeAttenuation: false } ), - new THREE.ParticleBasicMaterial( { color: 0x3a3a3a, size: 1, sizeAttenuation: false } ), - new THREE.ParticleBasicMaterial( { color: 0x1a1a1a, size: 2, sizeAttenuation: false } ), - new THREE.ParticleBasicMaterial( { color: 0x1a1a1a, size: 1, sizeAttenuation: false } ) + new THREE.ParticleSystemMaterial( { color: 0x555555, size: 2, sizeAttenuation: false } ), + new THREE.ParticleSystemMaterial( { color: 0x555555, size: 1, sizeAttenuation: false } ), + new THREE.ParticleSystemMaterial( { color: 0x333333, size: 2, sizeAttenuation: false } ), + new THREE.ParticleSystemMaterial( { color: 0x3a3a3a, size: 1, sizeAttenuation: false } ), + new THREE.ParticleSystemMaterial( { color: 0x1a1a1a, size: 2, sizeAttenuation: false } ), + new THREE.ParticleSystemMaterial( { color: 0x1a1a1a, size: 1, sizeAttenuation: false } ) ]; for ( i = 10; i < 30; i ++ ) { @@ -10185,8 +10193,9 @@ var container, stats; sphere = new THREE.Mesh( new THREE.SphereGeometry( 100, 20, 20 ), new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ) ); scene.add( sphere ); - var geometry = new THREE.CylinderGeometry( 0, 10, 100, 3 ); - geometry.applyMatrix( new THREE.Matrix4().setRotationFromEuler( new THREE.Vector3( Math.PI / 2, Math.PI, 0 ) ) ); + var geometry = new THREE.CylinderGeometry(0, 10, 100, 3); + var v = new THREE.Vector3(Math.PI / 2, Math.PI, 0); + geometry.applyMatrix(new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(v.x, v.y, v.z) ) ); var material = new THREE.MeshNormalMaterial(); @@ -11536,7 +11545,6 @@ declare var ballPosition: THREE.Vector3; mesh.receiveShadow = true; var animation = new THREE.Animation( mesh, geometry.animation.name ); - animation.JITCompile = false; animation.interpolationType = THREE.AnimationHandler.LINEAR; animation.play(); @@ -12079,7 +12087,7 @@ declare var ballPosition: THREE.Vector3; // - var material = new THREE.ParticleBasicMaterial( { size: 15, vertexColors: true } ); + var material = new THREE.ParticleSystemMaterial( { size: 15, vertexColors: true } ); particleSystem = new THREE.ParticleSystem( geometry, material ); scene.add( particleSystem ); @@ -12225,7 +12233,7 @@ declare var ballPosition: THREE.Vector3; } - var particles = new THREE.ParticleSystem( geometry, new THREE.ParticleBasicMaterial( { color: 0x888888 } ) ); + var particles = new THREE.ParticleSystem( geometry, new THREE.ParticleSystemMaterial( { color: 0x888888 } ) ); scene.add( particles ); // @@ -13249,30 +13257,6 @@ declare var ballPosition: THREE.Vector3; geometry.vertices.push( new THREE.Vector3( x1, y1, z1 ) ); } - - var ribbon = new THREE.Ribbon( geometry, material ); - scene.add( ribbon ); - - materials.push( ribbon.material ); - - var ribbon = new THREE.Ribbon( geometry, material.clone() ); - ribbon.position.y = 250; - ribbon.position.x = 250; - scene.add( ribbon ); - - var ribbonMaterial = ribbon.material; - - ribbonMaterial.uniforms.color.value.setHSL( 0, 0.75, 1 ); - materials.push( ribbon.material ); - - var ribbon = new THREE.Ribbon( geometry, material.clone() ); - ribbon.position.y = -250; - ribbon.position.x = 250; - scene.add( ribbon ); - - ribbonMaterial.uniforms.color.value.setHSL( 0.1, 0.75, 1 ); - materials.push( ribbon.material ); - // renderer = new THREE.WebGLRenderer( { antialias: true } ); @@ -14289,8 +14273,8 @@ declare var ballPosition: THREE.Vector3; } - var extrudeSettings: { amount: number; bevelEnabled: boolean; bevelSegments: number; steps: number; extrudePath?: THREE.SplineCurve3; }; - extrudeSettings = { amount: 200, bevelEnabled: true, bevelSegments: 2, steps: 150 }; // bevelSegments: 2, steps: 2 , bevelSegments: 5, bevelSize: 8, bevelThickness:5, + var extrudeSettings: { amount: number; bevelEnabled: boolean; bevelSegments: number; steps: number; extrudePath: THREE.Path; }; + extrudeSettings = { amount: 200, bevelEnabled: true, bevelSegments: 2, steps: 150, extrudePath: new THREE.Path() }; // bevelSegments: 2, steps: 2 , bevelSegments: 5, bevelSize: 8, bevelThickness:5, // var extrudePath = new THREE.Path(); @@ -14302,41 +14286,6 @@ declare var ballPosition: THREE.Vector3; extrudeSettings.bevelEnabled = false; - var extrudeBend = new THREE.SplineCurve3( //Closed - [ - - new THREE.Vector3( 30, 12, 83), - new THREE.Vector3( 40, 20, 67), - new THREE.Vector3( 60, 40, 99), - new THREE.Vector3( 10, 60, 49), - new THREE.Vector3( 25, 80, 40) - - ]); - - var pipeSpline = new THREE.SplineCurve3([ - new THREE.Vector3(0, 10, -10), new THREE.Vector3(10, 0, -10), new THREE.Vector3(20, 0, 0), new THREE.Vector3(30, 0, 10), new THREE.Vector3(30, 0, 20), new THREE.Vector3(20, 0, 30), new THREE.Vector3(10, 0, 30), new THREE.Vector3(0, 0, 30), new THREE.Vector3(-10, 10, 30), new THREE.Vector3(-10, 20, 30), new THREE.Vector3(0, 30, 30), new THREE.Vector3(10, 30, 30), new THREE.Vector3(20, 30, 15), new THREE.Vector3(10, 30, 10), new THREE.Vector3(0, 30, 10), new THREE.Vector3(-10, 20, 10), new THREE.Vector3(-10, 10, 10), new THREE.Vector3(0, 0, 10), new THREE.Vector3(10, -10, 10), new THREE.Vector3(20, -15, 10), new THREE.Vector3(30, -15, 10), new THREE.Vector3(40, -15, 10), new THREE.Vector3(50, -15, 10), new THREE.Vector3(60, 0, 10), new THREE.Vector3(70, 0, 0), new THREE.Vector3(80, 0, 0), new THREE.Vector3(90, 0, 0), new THREE.Vector3(100, 0, 0)] - ); - - var sampleClosedSpline = new THREE.ClosedSplineCurve3([ - new THREE.Vector3(0, -40, -40), - new THREE.Vector3(0, 40, -40), - new THREE.Vector3(0, 140, -40), - new THREE.Vector3(0, 40, 40), - new THREE.Vector3(0, -40, 40), - ]); - - var randomPoints = []; - - for ( var i = 0; i < 10; i ++ ) { - - randomPoints.push( new THREE.Vector3(Math.random() * 200,Math.random() * 200,Math.random() * 200 ) ); - - } - - var randomSpline = new THREE.SplineCurve3( randomPoints ); - - extrudeSettings.extrudePath = randomSpline; // extrudeBend sampleClosedSpline pipeSpline randomSpline - // Circle var circleRadius = 4; @@ -14360,7 +14309,7 @@ declare var ballPosition: THREE.Vector3; var pts = [], starPoints = 5, l; - for ( i = 0; i < starPoints * 2; i ++ ) { + for ( var i = 0; i < starPoints * 2; i ++ ) { if ( i % 2 == 1 ) { @@ -14408,7 +14357,7 @@ declare var ballPosition: THREE.Vector3; var circle3d = starShape.extrude( extrudeSettings ); //circleShape rectShape smileyShape starShape // var circle3d = new THREE.ExtrudeGeometry(circleShape, extrudeBend, extrudeSettings ); - var tube = new THREE.TubeGeometry(extrudeSettings.extrudePath, 150, 4, 5, false, true); + var tube = new THREE.TubeGeometry(extrudeSettings.extrudePath, 150, 4, 5, false); // new THREE.TubeGeometry(extrudePath, segments, 2, radiusSegments, closed2, debug); @@ -14556,18 +14505,6 @@ function render() { var binormal = new THREE.Vector3(); var normal = new THREE.Vector3(); - - var pipeSpline = new THREE.SplineCurve3([ - new THREE.Vector3(0, 10, -10), new THREE.Vector3(10, 0, -10), new THREE.Vector3(20, 0, 0), new THREE.Vector3(30, 0, 10), new THREE.Vector3(30, 0, 20), new THREE.Vector3(20, 0, 30), new THREE.Vector3(10, 0, 30), new THREE.Vector3(0, 0, 30), new THREE.Vector3(-10, 10, 30), new THREE.Vector3(-10, 20, 30), new THREE.Vector3(0, 30, 30), new THREE.Vector3(10, 30, 30), new THREE.Vector3(20, 30, 15), new THREE.Vector3(10, 30, 10), new THREE.Vector3(0, 30, 10), new THREE.Vector3(-10, 20, 10), new THREE.Vector3(-10, 10, 10), new THREE.Vector3(0, 0, 10), new THREE.Vector3(10, -10, 10), new THREE.Vector3(20, -15, 10), new THREE.Vector3(30, -15, 10), new THREE.Vector3(40, -15, 10), new THREE.Vector3(50, -15, 10), new THREE.Vector3(60, 0, 10), new THREE.Vector3(70, 0, 0), new THREE.Vector3(80, 0, 0), new THREE.Vector3(90, 0, 0), new THREE.Vector3(100, 0, 0)]); - - var sampleClosedSpline = new THREE.ClosedSplineCurve3([ - new THREE.Vector3(0, -40, -40), - new THREE.Vector3(0, 40, -40), - new THREE.Vector3(0, 140, -40), - new THREE.Vector3(0, 40, 40), - new THREE.Vector3(0, -40, 40), - ]); - // Keep a dictionary of Curve instances var splines = { GrannyKnot: new THREE.Curves.GrannyKnot(), @@ -14583,9 +14520,7 @@ function render() { DecoratedTorusKnot4a: new THREE.Curves.DecoratedTorusKnot4a(), DecoratedTorusKnot4b: new THREE.Curves.DecoratedTorusKnot4b(), DecoratedTorusKnot5a: new THREE.Curves.DecoratedTorusKnot5a(), - DecoratedTorusKnot5c: new THREE.Curves.DecoratedTorusKnot5c(), - PipeSpline: pipeSpline, - SampleClosedSpline: sampleClosedSpline + DecoratedTorusKnot5c: new THREE.Curves.DecoratedTorusKnot5c() }; @@ -14626,7 +14561,7 @@ function render() { extrudePath = splines[value]; - tube = new THREE.TubeGeometry(extrudePath, segments, 2, radiusSegments, closed2, debug); + tube = new THREE.TubeGeometry(extrudePath, segments, 2, radiusSegments, closed2); addGeometry(tube, 0xff00ff); setScale(); @@ -16872,7 +16807,7 @@ function render() { // vertices from real points var pgeo = points.clone(); - var particles = new THREE.ParticleSystem( pgeo, new THREE.ParticleBasicMaterial( { color: color, size: 2, opacity: 0.75 } ) ); + var particles = new THREE.ParticleSystem( pgeo, new THREE.ParticleSystemMaterial( { color: color, size: 2, opacity: 0.75 } ) ); particles.position.set( x, y, z + 75 ); particles.rotation.set( rx, ry, rz ); particles.scale.set( s, s, s ); @@ -16889,7 +16824,7 @@ function render() { // equidistance sampled points var pgeo = spacedPoints.clone(); - var particles2 = new THREE.ParticleSystem( pgeo, new THREE.ParticleBasicMaterial( { color: color, size: 2, opacity: 0.5 } ) ); + var particles2 = new THREE.ParticleSystem( pgeo, new THREE.ParticleSystemMaterial( { color: color, size: 2, opacity: 0.5 } ) ); particles2.position.set( x, y, z + 125 ); particles2.rotation.set( rx, ry, rz ); particles2.scale.set( s, s, s ); @@ -17083,12 +17018,6 @@ function render() { // TODO 3d path? - var apath = new THREE.SplineCurve3(); - apath.points.push(new THREE.Vector3(-50, 150, 10)); - apath.points.push(new THREE.Vector3(-20, 180, 20)); - apath.points.push(new THREE.Vector3(40, 220, 50)); - apath.points.push(new THREE.Vector3(200, 290, 100)); - var extrudeSettings:any = { amount: 20 }; // bevelSegments: 2, steps: 2 , bevelSegments: 5, bevelSize: 8, bevelThickness:5 @@ -17109,7 +17038,6 @@ function render() { addShape( smileyShape, extrudeSettings, 0xee00ff, -200, 250, 0, 0, 0, Math.PI, 1 ); addShape( arcShape, extrudeSettings, 0xbb4422, 150, 0, 0, 0, 0, 0, 1 ); - extrudeSettings.extrudePath = apath; extrudeSettings.bevelEnabled = false; extrudeSettings.steps = 20; @@ -17494,10 +17422,9 @@ function render() { } for ( var i = 0; i < smooth.vertices.length; i++ ) { - - var particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) ); + var geometry = new THREE.Geometry(); + var particle = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) ); particle.position = smooth.vertices[ i ]; - var pos = smooth.vertices.position particle.scale.x = particle.scale.y = 5; group.add( particle ); } @@ -17523,10 +17450,9 @@ function render() { } for ( var i = 0; i < geometry.vertices.length; i++ ) { - - particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: drawText(i) } ) ); + var geometry = new THREE.Geometry(); + particle = new THREE.ParticleSystem(geometry, new THREE.ParticleSystemMaterial( { color: Math.random() * 0x808008 + 0x808080, program: drawText(i) } ) ); particle.position = smooth.vertices[ i ]; - var pos = geometry.vertices.position particle.scale.x = particle.scale.y = 30; group.add( particle ); } @@ -20226,7 +20152,6 @@ function render() { THREE.AnimationHandler.add( object.geometry.animation ); var animation = new THREE.Animation( object, object.geometry.animation.name ); - animation.JITCompile = false; animation.interpolationType = THREE.AnimationHandler.LINEAR; animation.play(); @@ -22629,62 +22554,6 @@ function render() { } - var tmpRot = new THREE.Matrix4(); - tmpRot.makeRotationAxis( new THREE.Vector3( 1, 0, 0 ), Math.PI/2 ); - - var xgrid = 34; - var ygrid = 15; - var nribbons = xgrid * ygrid; - - var c = 0; - for (var i = 0; i < xgrid; i ++ ) - for (var j = 0; j < ygrid; j ++ ) { - - var material = new THREE.MeshBasicMaterial( { color: 0xffffff, vertexColors: THREE.VertexColors, side: THREE.DoubleSide } ); - - ribbon = new THREE.Ribbon( i % 2 ? geometry : geometry2, material ); - ribbon.rotation.x = 0; - ribbon.rotation.y = Math.PI / 2; - ribbon.rotation.z = Math.PI; - - x = 40 * ( i - xgrid/2 ); - y = 40 * ( j - ygrid/2 ); - z = 0; - - ribbon.position.set( x, y, z ); - - ribbon.matrixAutoUpdate = false; - - // manually create local matrix - - ribbon.matrix.setPosition( ribbon.position ); - ribbon.matrixRotationWorld.setRotationFromEuler( ribbon.rotation ); - - ribbon.matrix.elements[ 0 ] = ribbon.matrixRotationWorld.elements[ 0 ]; - ribbon.matrix.elements[ 4 ] = ribbon.matrixRotationWorld.elements[ 4 ]; - ribbon.matrix.elements[ 8 ] = ribbon.matrixRotationWorld.elements[ 8 ]; - - ribbon.matrix.elements[ 1 ] = ribbon.matrixRotationWorld.elements[ 1 ]; - ribbon.matrix.elements[ 5 ] = ribbon.matrixRotationWorld.elements[ 5 ]; - ribbon.matrix.elements[ 9 ] = ribbon.matrixRotationWorld.elements[ 9 ]; - - ribbon.matrix.elements[ 2 ] = ribbon.matrixRotationWorld.elements[ 2 ]; - ribbon.matrix.elements[ 6 ] = ribbon.matrixRotationWorld.elements[ 6 ]; - ribbon.matrix.elements[ 10 ] = ribbon.matrixRotationWorld.elements[ 10 ]; - - ribbon.matrix.multiply( tmpRot ); - - ribbon.matrix.scale( ribbon.scale ); - - ribbons.push( ribbon ); - scene.add( ribbon ); - - c ++; - - } - - scene.matrixAutoUpdate = false; - // renderer = new THREE.WebGLRenderer( { antialias: false } ); diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 2767570333..b76430f92e 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1,5946 +1,5307 @@ -// Type definitions for three.js -// Project: http://mrdoob.github.com/three.js/ -// Definitions by: Kon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -interface WebGLRenderingContext {} - -declare module THREE { - export var REVISION: string; - - // GL STATE CONSTANTS - - export enum CullFace { } - export var CullFaceNone: CullFace; - export var CullFaceBack: CullFace; - export var CullFaceFront: CullFace; - export var CullFaceFrontBack: CullFace; - - export enum FrontFaceDirection { } - export var FrontFaceDirectionCW: FrontFaceDirection; - export var FrontFaceDirectionCCW: FrontFaceDirection; - - // SHADOWING TYPES - - export enum ShadowMapType { } - export var BasicShadowMap: ShadowMapType; - export var PCFShadowMap: ShadowMapType; - export var PCFSoftShadowMap: ShadowMapType; - - // MATERIAL CONSTANTS - - // side - export enum Side { } - export var FrontSide: Side; - export var BackSide: Side; - export var DoubleSide: Side; - - // shading - export enum Shading { } - export var NoShading: Shading; - export var FlatShading: Shading; - export var SmoothShading: Shading; - - // colors - export enum Colors { } - export var NoColors: Colors; - export var FaceColors: Colors; - export var VertexColors: Colors; - - // blending modes - export enum Blending { } - export var NoBlending: Blending; - export var NormalBlending: Blending; - export var AdditiveBlending: Blending; - export var SubtractiveBlending: Blending; - export var MultiplyBlending: Blending; - export var CustomBlending: Blending; - - // custom blending equations - // (numbers start from 100 not to clash with other - // mappings to OpenGL constants defined in Texture.js) - export enum BlendingEquation { } - export var AddEquation: BlendingEquation; - export var SubtractEquation: BlendingEquation; - export var ReverseSubtractEquation: BlendingEquation; - - // custom blending destination factors - export enum BlendingDstFactor { } - export var ZeroFactor: BlendingDstFactor; - export var OneFactor: BlendingDstFactor; - export var SrcColorFactor: BlendingDstFactor; - export var OneMinusSrcColorFactor: BlendingDstFactor; - export var SrcAlphaFactor: BlendingDstFactor; - export var OneMinusSrcAlphaFactor: BlendingDstFactor; - export var DstAlphaFactor: BlendingDstFactor; - export var OneMinusDstAlphaFactor: BlendingDstFactor; - - // custom blending source factors - export enum BlendingSrcFactor { } - export var DstColorFactor: BlendingSrcFactor; - export var OneMinusDstColorFactor: BlendingSrcFactor; - export var SrcAlphaSaturateFactor: BlendingSrcFactor; - - // TEXTURE CONSTANTS - export enum Combine { } - export var MultiplyOperation: Combine; - export var MixOperation: Combine; - export var AddOperation: Combine; - - // Mapping modes - export enum Mapping { } - export interface MappingConstructor { - new(): Mapping; - } - export var UVMapping: MappingConstructor; - export var CubeReflectionMapping: MappingConstructor; - export var CubeRefractionMapping: MappingConstructor; - export var SphericalReflectionMapping: MappingConstructor; - export var SphericalRefractionMapping: MappingConstructor; - - // Wrapping modes - export enum Wrapping { } - export var RepeatWrapping: Wrapping; - export var ClampToEdgeWrapping: Wrapping; - export var MirroredRepeatWrapping: Wrapping; - - // Filters - export enum TextureFilter { } - export var NearestFilter: TextureFilter; - export var NearestMipMapNearestFilter: TextureFilter; - export var NearestMipMapLinearFilter: TextureFilter; - export var LinearFilter: TextureFilter; - export var LinearMipMapNearestFilter: TextureFilter; - export var LinearMipMapLinearFilter: TextureFilter; - - // Data types - export enum TextureDataType { } - export var UnsignedByteType: TextureDataType; - export var ByteType: TextureDataType; - export var ShortType: TextureDataType; - export var UnsignedShortType: TextureDataType; - export var IntType: TextureDataType; - export var UnsignedIntType: TextureDataType; - export var FloatType: TextureDataType; - - // Pixel types - export enum PixelType { } - // export var UnsignedByteType:number; - export var UnsignedShort4444Type: PixelType; - export var UnsignedShort5551Type: PixelType; - export var UnsignedShort565Type: PixelType; - - // Pixel formats - export enum PixelFormat { } - export var AlphaFormat: PixelFormat; - export var RGBFormat: PixelFormat; - export var RGBAFormat: PixelFormat; - export var LuminanceFormat: PixelFormat; - export var LuminanceAlphaFormat: PixelFormat; - - // Compressed texture formats - export enum CompressedPixelFormat { } - export var RGB_S3TC_DXT1_Format: CompressedPixelFormat; - export var RGBA_S3TC_DXT1_Format: CompressedPixelFormat; - export var RGBA_S3TC_DXT3_Format: CompressedPixelFormat; - export var RGBA_S3TC_DXT5_Format: CompressedPixelFormat; - - - // Potential future PVRTC compressed texture formats - // export enum CompressedTextureFormats {} - // export var RGB_PVRTC_4BPPV1_Format :CompressedTextureFormats; - // export var RGB_PVRTC_2BPPV1_Format :CompressedTextureFormats; - // export var RGBA_PVRTC_4BPPV1_Format:CompressedTextureFormats; - // export var RGBA_PVRTC_2BPPV1_Format:CompressedTextureFormats; - - - // Following enums don't be contained by three.js - - // export enum EulerOrder {} - // export var XYZ:EulerOrder; - // export var XZY:EulerOrder; - // export var YXZ:EulerOrder; - // export var YZX:EulerOrder; - // export var ZXY:EulerOrder; - // export var ZYX:EulerOrder; - - // enum UniformType {} - // i, // single integer - // f, // single float - // v2, // single THREE.Vector2 - // v3, // single THREE.Vector3 - // v4, // single THREE.Vector4 - // c, // single THREE.Color - // iv1, // flat array of integers (JS or typed array) - // iv, // flat array of integers with 3 x N size (JS or typed array) - // fv1, // flat array of floats (JS or typed array) - // fv, // flat array of floats with 3 x N size (JS or typed array) - // v2v, // array of THREE.Vector2 - // v3v, // array of THREE.Vector3 - // v4v, // array of THREE.Vector4 - // m4, // single THREE.Matrix4 - // m4v, // array of THREE.Matrix4 - // t, // single THREE.Texture (2d or cube) - // tv, // array of THREE.Texture (2d) - // } - - // Core /////////////////////////////////////////////////////////////////////////////////////////////// - - interface BufferGeometryAttributeArray extends ArrayBufferView{ - length: number; - } - - interface BufferGeometryAttribute{ - itemSize: number; - array: BufferGeometryAttributeArray; - numItems: number; - } - - interface BufferGeometryAttributes{ - [name: string]: BufferGeometryAttribute; - index?: BufferGeometryAttribute; - position?: BufferGeometryAttribute; - normal?: BufferGeometryAttribute; - color?: BufferGeometryAttribute; - } - - /** - * This is a superefficent class for geometries because it saves all data in buffers. - * It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the nessecary buffer calculations. - * It is mainly interesting when working with static objects. - * - * @see src/core/BufferGeometry.js - */ - export class BufferGeometry { - /** - * This creates a new BufferGeometry. It also sets several properties to an default value. - */ - constructor(); - - /** - * Unique number of this buffergeometry instance - */ - id: number; - - /** - * This hashmap has as id the name of the attribute to be set and as value the buffer to set it to. - */ - attributes: BufferGeometryAttributes; - - /** - * When set, it holds certain buffers in memory to have faster updates for this object. When unset, it deletes those buffers and saves memory. - */ - dynamic: boolean; - - /** - * Bounding box. - */ - boundingBox: BoundingBox3D; - - /** - * Bounding sphere. - */ - boundingSphere: BoundingSphere; - - hasTangents: boolean; - morphTargets: any[]; - - offsets: { start: number; count: number; index: number; }[]; - - /** - * Bakes matrix transform directly into vertex coordinates. - */ - applyMatrix(matrix: Matrix4): void; - - verticesNeedUpdate: boolean; - - /** - * Computes bounding box of the geometry, updating Geometry.boundingBox attribute. - * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null. - */ - computeBoundingBox(): void; - - /** - * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute. - * Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null. - */ - computeBoundingSphere(): void; - - /** - * Computes vertex normals by averaging face normals. - */ - computeVertexNormals(): void; - - normalizeNormals(): void; - - /** - * Computes vertex tangents. - * Based on http://www.terathon.com/code/tangent.html - * Geometry must have vertex UVs (layer 0 will be used). - */ - computeTangents(): void; - - /** - * Disposes the object from memory. - * You need to call this when you want the bufferGeometry removed while the application is running. - */ - dispose(): void; - } - - /** - * Object for keeping track of time. - * - * @see src/core/Clock.js - */ - export class Clock { - /** - * @param autoStart Automatically start the clock. - */ - constructor(autoStart?: boolean); - - /** - * If set, starts the clock automatically when the first update is called. - */ - autoStart: boolean; - - /** - * When the clock is running, It holds the starttime of the clock. - * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. - */ - startTime: number; - - /** - * When the clock is running, It holds the previous time from a update. - * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. - */ - oldTime: number; - - /** - * When the clock is running, It holds the time elapsed btween the start of the clock to the previous update. - * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. - */ - elapsedTime: number; - - /** - * This property keeps track whether the clock is running or not. - */ - running: boolean; - - /** - * Starts clock. - */ - start(): void; - - /** - * Stops clock. - */ - stop(): void; - - /** - * Get milliseconds passed since the clock started. - */ - getElapsedTime(): number; - - /** - * Get the milliseconds passed since the last call to this method. - */ - getDelta(): number; - } - - export interface HSL { - h: number; - s: number; - l: number; - } - - /** - * Represents a color. See also {@link ColorUtils}. - * - * @example - * var color = new THREE.Color( 0xff0000 ); - * - * @see src/math/Color.js - */ - export class Color { - constructor(hex?: string); - - /** - * @param hex initial color in hexadecimal - */ - constructor(hex?: number); - - /** - * Red channel value between 0 and 1. Default is 1. - */ - r: number; - - /** - * Green channel value between 0 and 1. Default is 1. - */ - g: number; - - /** - * Blue channel value between 0 and 1. Default is 1. - */ - b: number; - set (value: number): void; - set (value: string): void; - setHex(hex: number): Color; - - /** - * Sets this color from RGB values. - * @param r Red channel value between 0 and 1. - * @param g Green channel value between 0 and 1. - * @param b Blue channel value between 0 and 1. - */ - setRGB(r: number, g: number, b: number): Color; - - /** - * Sets this color from HSL values. - * Based on MochiKit implementation by Bob Ippolito. - * - * @param h Hue channel value between 0 and 1. - * @param s Saturation value channel between 0 and 1. - * @param l Value channel value between 0 and 1. - */ - setHSL(h: number, s: number, l: number): Color; - - /** - * Sets this color from a CSS context style string. - * @param contextStyle Color in CSS context style format. - */ - setStyle(style: string): Color; - - /** - * Copies given color. - * @param color Color to copy. - */ - copy(color: Color): Color; - - /** - * Copies given color making conversion from gamma to linear space. - * @param color Color to copy. - */ - copyGammaToLinear(color: Color): Color; - - /** - * Copies given color making conversion from linear to gamma space. - * @param color Color to copy. - */ - copyLinearToGamma(color: Color): Color; - - /** - * Converts this color from gamma to linear space. - */ - convertGammaToLinear(): Color; - - /** - * Converts this color from linear to gamma space. - */ - convertLinearToGamma(): Color; - - /** - * Returns the hexadecimal value of this color. - */ - getHex(): number; - - /** - * Returns the string formated hexadecimal value of this color. - */ - getHexString(): string; - - getHSL(): HSL; - - /** - * Returns the value of this color in CSS context style. - * Example: rgb(r, g, b) - */ - getStyle(): string; - - offsetHSL(h:number, s:number, l:number): Color; - - add(color: Color): Color; - addColors(color1: Color, color2: Color): Color; - addScalar(s: number): Color; - multiply(color: Color): Color; - multiplyScalar(s: number): Color; - lerp(color: Color, alpha: number): Color; - - /** - * Clones this color. - */ - clone(): Color; - } - - var ColorKeywords: { - [name: string]: number; - aliceblue: number; - antiquewhite: number; - aqua: number; - aquamarine: number; - azure: number; - beige: number; - bisque: number; - black: number; - blanchedalmond: number; - blue: number; - blueviolet: number; - brown: number; - burlywood: number; - cadetblue: number; - chartreuse: number; - chocolate: number; - coral: number; - cornflowerblue: number; - cornsilk: number; - crimson: number; - cyan: number; - darkblue: number; - darkcyan: number; - darkgoldenrod: number; - darkgray: number; - darkgreen: number; - darkgrey: number; - darkkhaki: number; - darkmagenta: number; - darkolivegreen: number; - darkorange: number; - darkorchid: number; - darkred: number; - darksalmon: number; - darkseagreen: number; - darkslateblue: number; - darkslategray: number; - darkslategrey: number; - darkturquoise: number; - darkviolet: number; - deeppink: number; - deepskyblue: number; - dimgray: number; - dimgrey: number; - dodgerblue: number; - firebrick: number; - floralwhite: number; - forestgreen: number; - fuchsia: number; - gainsboro: number; - ghostwhite: number; - gold: number; - goldenrod: number; - gray: number; - green: number; - greenyellow: number; - grey: number; - honeydew: number; - hotpink: number; - indianred: number; - indigo: number; - ivory: number; - khaki: number; - lavender: number; - lavenderblush: number; - lawngreen: number; - lemonchiffon: number; - lightblue: number; - lightcoral: number; - lightcyan: number; - lightgoldenrodyellow: number; - lightgray: number; - lightgreen: number; - lightgrey: number; - lightpink: number; - lightsalmon: number; - lightseagreen: number; - lightskyblue: number; - lightslategray: number; - lightslategrey: number; - lightsteelblue: number; - lightyellow: number; - lime: number; - limegreen: number; - linen: number; - magenta: number; - maroon: number; - mediumaquamarine: number; - mediumblue: number; - mediumorchid: number; - mediumpurple: number; - mediumseagreen: number; - mediumslateblue: number; - mediumspringgreen: number; - mediumturquoise: number; - mediumvioletred: number; - midnightblue: number; - mintcream: number; - mistyrose: number; - moccasin: number; - navajowhite: number; - navy: number; - oldlace: number; - olive: number; - olivedrab: number; - orange: number; - orangered: number; - orchid: number; - palegoldenrod: number; - palegreen: number; - paleturquoise: number; - palevioletred: number; - papayawhip: number; - peachpuff: number; - peru: number; - pink: number; - plum: number; - powderblue: number; - purple: number; - red: number; - rosybrown: number; - royalblue: number; - saddlebrown: number; - salmon: number; - sandybrown: number; - seagreen: number; - seashell: number; - sienna: number; - silver: number; - skyblue: number; - slateblue: number; - slategray: number; - slategrey: number; - snow: number; - springgreen: number; - steelblue: number; - tan: number; - teal: number; - thistle: number; - tomato: number; - turquoise: number; - violet: number; - wheat: number; - white: number; - whitesmoke: number; - yellow: number; - yellowgreen: number; - }; - - /** - * JavaScript events for custom objects - * - * # Example - * var Car = function () { - * - * EventDispatcher.call( this ); - * this.start = function () { - * - * this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); - * - * }; - * - * }; - * - * var car = new Car(); - * car.addEventListener( 'start', function ( event ) { - * - * alert( event.message ); - * - * } ); - * car.start(); - * - * @source src/core/EventDispatcher.js - */ - export class EventDispatcher { - /** - * Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object. - */ - constructor(); - - /** - * Adds a listener to an event type. - * @param type The type of the listener that gets removed. - * @param listener The listener function that gets removed. - */ - addEventListener(type: string, listener: (event: any) => void ): void; - - /** - * Fire an event type. - * @param type The type of event that gets fired. - */ - dispatchEvent(event: { type:string; target: any; }): void; - - /** - * Removes a listener from an event type. - * @param type The type of the listener that gets removed. - * @param listener The listener function that gets removed. - */ - removeEventListener(type: string, listener: (event: any) => void ): void; - } - - export interface Face { - /** - * Face normal. - */ - normal: Vector3; - - /** - * Face color. - */ - color: Color; - - /** - * Array of 4 vertex normals. - */ - vertexNormals: Vector3[]; - - /** - * Array of 4 vertex normals. - */ - vertexColors: Color[]; - - /** - * Array of 4 vertex tangets. - */ - vertexTangents: number[]; - - /** - * Material index (points to {@link Geometry.materials}). - */ - materialIndex: number; - - /** - * Face centroid. - */ - centroid: Vector3; - - clone(): Face; - } - - /** - * Triangle face. - * - * # Example - * var normal = new THREE.Vector3( 0, 1, 0 ); - * var color = new THREE.Color( 0xffaa00 ); - * var face = new THREE.Face3( 0, 1, 2, normal, color, 0 ); - * - * @source https://github.com/mrdoob/three.js/blob/master/src/core/Face3.js - */ - export class Face3 implements Face { - /** - * @param a Vertex A index. - * @param b Vertex B index. - * @param c Vertex C index. - * @param normal Face normal or array of vertex normals. - * @param color Face color or array of vertex colors. - * @param materialIndex Material index. - */ - constructor(a: number, b: number, c: number, normal?: Vector3, color?: Color, materialIndex?: number); - constructor(a: number, b: number, c: number, normal?: Vector3, vertexColors?: Color[], materialIndex?: number); - constructor(a: number, b: number, c: number, vertexNormals?: Vector3[], color?: Color, materialIndex?: number); - constructor(a: number, b: number, c: number, vertexNormals?: Vector3[], vertexColors?: Color[], materialIndex?: number); - - /** - * Vertex A index. - */ - a: number; - - /** - * Vertex B index. - */ - b: number; - - /** - * Vertex C index. - */ - c: number; - - clone(): Face3; - - // properties inherits from Face /////////////////////////////////// - - /** - * Face normal. - */ - normal: Vector3; - - /** - * Face color. - */ - color: Color; - - /** - * Array of 4 vertex normals. - */ - vertexNormals: Vector3[]; - - /** - * Array of 4 vertex normals. - */ - vertexColors: Color[]; - - /** - * Array of 4 vertex tangets. - */ - vertexTangents: number[]; - - /** - * Material index (points to {@link Geometry.materials}). - */ - materialIndex: number; - - /** - * Face centroid. - */ - centroid: Vector3; - } - - /** - * Quad face. - * - * # example - * var normal = new THREE.Vector3( 0, 1, 0 ); - * var color = new THREE.Color( 0xffaa00 ); - * var face = new THREE.Face4( 0, 1, 2, 3, normal, color, 0 ); - * - * @source https://github.com/mrdoob/three.js/blob/master/src/core/Face4.js - */ - export class Face4 implements Face { - /** - * @param a Vertex A index. - * @param b Vertex B index. - * @param c Vertex C index. - * @param d Vertex D index. - * @param normal Face normal or array of vertex normals. - * @param color Face color or array of vertex colors. - * @param materialIndex Material index. - */ - constructor(a: number, b: number, c: number, d: number, normal?: Vector3, color?: Color, materialIndex?: number); - constructor(a: number, b: number, c: number, d: number, normal?: Vector3, vertexColors?: Color[], materialIndex?: number); - constructor(a: number, b: number, c: number, d: number, vertexNormals?: Vector3[], color?: Color, materialIndex?: number); - constructor(a: number, b: number, c: number, d: number, vertexNormals?: Vector3[], vertexColors?: Color[], materialIndex?: number); - - /** - * Vertex A index. - */ - a: number; - - /** - * Vertex B index. - */ - b: number; - - /** - * Vertex C index. - */ - c: number; - - /** - * Vertex D index. - */ - d: number; - - clone(): Face4; - - - - // properties inherits from Face /////////////////////////////////// - - /** - * Face normal. - */ - normal: Vector3; - - /** - * Face color. - */ - color: Color; - - /** - * Array of 4 vertex normals. - */ - vertexNormals: Vector3[]; - - /** - * Array of 4 vertex normals. - */ - vertexColors: Color[]; - - /** - * Array of 4 vertex tangets. - */ - vertexTangents: number[]; - - /** - * Material index (points to {@link Geometry.materials}). - */ - materialIndex: number; - - /** - * Face centroid. - */ - centroid: Vector3; - } - - /** - * Frustums are used to determine what is inside the camera's field of view. They help speed up the rendering process. - */ - export class Frustum { - constructor(p0?: Plane, p1?: Plane, p2?: Plane, p3?: Plane, p4?: Plane, p5?: Plane); - - /** - * Array of 6 vectors. - */ - planes: Plane[]; - - set (p0?: number, p1?: number, p2?: number, p3?: number, p4?: number, p5?: number): Frustum; - copy(frustum: Frustum): Frustum; - setFromMatrix(m: Matrix4): Frustum; - - /** - * Checks whether the object is inside the Frustum. - */ - intersectsObject(object: Object3D): boolean; - - intersectsSphere(sphere: Sphere): boolean; - containsPoint(point: Vector3): boolean; - clone(): Frustum; - } - - export class Line3{ - constructor(start?:Vector3, end?:Vector3); - start: Vector3; - end: Vector3; - set(start?:Vector3, end?:Vector3):Line3; - copy(line:Line3):Line3; - center(optionalTarget?:Vector3):Vector3; - delta(optionalTarget?:Vector3):Vector3; - distanceSq():number; - distance():number; - at(t:number, optionalTarget?: Vector3):Vector3; - closestPointToPointParameter(point:Vector3, clampToLine?:boolean):number; - closestPointToPoint(point:Vector3, clampToLine?:boolean, optionalTarget?:Vector3):Vector3; - applyMatrix4(matrix:Matrix4):Line3; - equals(line:Line3):boolean; - clone():Line3; - } - - export class Plane { - constructor(normal?: Vector3, constant?: number); - normal: Vector3; - constant: number; - set (normal: Vector3, constant: number): Plane; - setComponents(x: number, y: number, z: number, w: number): Plane; - setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; - setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; - copy(plane: Plane): Plane; - normalize(): Plane; - negate(): Plane; - distanceToPoint(point: Vector3): number; - distanceToSphere(sphere: Sphere): number; - projectPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - orthoPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - isIntersectionLine(line: Line3): boolean; - intersectLine(line: Line3, optionalTarget?: Vector3): Vector3; - coplanarPoint(optionalTarget?: boolean): Vector3; - applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane; - translate(offset: Vector3): Plane; - equals(plane: Plane): boolean; - clone(): Plane; - } - - export class Sphere { - constructor(center?: Vector3, radius?: number); - center: Vector3; - radius: number; - set (center: Vector3, radius: number): Sphere; - setFromCenterAndPoints(center: Vector3, points: Vector3[]): Sphere; - copy(sphere: Sphere): Sphere; - empty(): boolean; - containsPoint(point: Vector3): boolean; - distanceToPoint(point: Vector3): number; - intersectsSphere(sphere: Sphere): boolean; - clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - getBoundingBox(optionalTarget?: Box3): Box3; - applyMatrix4(matrix: Matrix): Sphere; - translate(offset: Vector3): Sphere; - equals(sphere: Sphere): boolean; - clone(): Sphere; - } - - - export interface MorphTarget { - name: string; - vertices: Vector3[]; - } - - export interface MorphColor { - name: string; - color: Color[]; - } - - export interface BoundingBox3D { - min: Vector3; - max: Vector3; - } - - export interface BoundingSphere { - radius: number; - } - - - /** - * Base class for geometries - * - * # Example - * var geometry = new THREE.Geometry(); - * geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) ); - * geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) ); - * geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) ); - * geometry.faces.push( new THREE.Face3( 0, 1, 2 ) ); - * geometry.computeBoundingSphere(); - * - * @see https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js - */ - export class Geometry { - constructor(); - - /** - * Unique number of this geometry instance - */ - id: number; - - /** - * Name for this geometry. Default is an empty string. - */ - name: string; - - /** - * The array of vertices hold every position of points of the model. - * To signal an update in this array, Geometry.verticesNeedUpdate needs to be set to true. - */ - vertices: Vector3[]; - - /** - * Array of vertex colors, matching number and order of vertices. - * Used in ParticleSystem, Line and Ribbon. - * Meshes use per-face-use-of-vertex colors embedded directly in faces. - * To signal an update in this array, Geometry.colorsNeedUpdate needs to be set to true. - */ - colors: Color[]; - - /** - * Array of vertex normals, matching number and order of vertices. - * Normal vectors are nessecary for lighting - * To signal an update in this array, Geometry.normalsNeedUpdate needs to be set to true. - */ - normals: Vector3[]; - - /** - * Array of triangles or/and quads. - * The array of faces describe how each vertex in the model is connected with each other. - * To signal an update in this array, Geometry.elementsNeedUpdate needs to be set to true. - */ - faces: Face[]; - - /** - * Array of face UV layers. - * Each UV layer is an array of UV matching order and number of faces. - * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true. - */ - faceUvs: Vector2[][]; - - /** - * Array of face UV layers. - * Each UV layer is an array of UV matching order and number of vertices in faces. - * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true. - */ - faceVertexUvs: Vector2[][][]; - - /** - * Array of morph targets. Each morph target is a Javascript object: - * - * { name: "targetName", vertices: [ new THREE.Vector3(), ... ] } - * - * Morph vertices match number and order of primary vertices. - */ - morphTargets: MorphTarget[]; - - /** - * Array of morph colors. Morph colors have similar structure as morph targets, each color set is a Javascript object: - * - * morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] } - */ - morphColors: MorphColor[]; - - /** - * Array of skinning weights, matching number and order of vertices. - */ - skinWeights: number[]; - - /** - * Array of skinning indices, matching number and order of vertices. - */ - skinIndices: number[]; - - /** - * Bounding box. - */ - boundingBox: BoundingBox3D; - - /** - * Bounding sphere. - */ - boundingSphere: BoundingSphere; - - /** - * True if geometry has tangents. Set in Geometry.computeTangents. - */ - hasTangents: boolean; - - /** - * Set to true if attribute buffers will need to change in runtime (using "dirty" flags). - * Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU. - * Defaults to true. - */ - dynamic: boolean; - - /** - * Set to true if the vertices array has been updated. - */ - verticesNeedUpdate: boolean; - - /** - * Set to true if the faces array has been updated. - */ - elementsNeedUpdate: boolean; - - /** - * Set to true if the uvs array has been updated. - */ - uvsNeedUpdate: boolean; - - /** - * Set to true if the normals array has been updated. - */ - normalsNeedUpdate: boolean; - - /** - * Set to true if the tangents in the faces has been updated. - */ - tangentsNeedUpdate: boolean; - - /** - * Set to true if the colors array has been updated. - */ - colorsNeedUpdate: boolean; - - /** - * Set to true if the linedistances array has been updated. - */ - lineDistancesNeedUpdate: boolean; - - /** - * Set to true if an array has changed in length. - */ - buffersNeedUpdate: boolean; - - /** - * - */ - animation: AnimationData; - - /** - * Bakes matrix transform directly into vertex coordinates. - */ - applyMatrix(matrix: Matrix4): void; - - /** - * Computes centroids for all faces. - */ - computeCentroids(): void; - - /** - * Computes face normals. - */ - computeFaceNormals(): void; - - /** - * Computes vertex normals by averaging face normals. - * Face normals must be existing / computed beforehand. - */ - computeVertexNormals(areaWeighted?: boolean): void; - - /** - * Computes morph normals. - */ - computeMorphNormals(): void; - - /** - * Computes vertex tangents. - * Based on http://www.terathon.com/code/tangent.html - * Geometry must have vertex UVs (layer 0 will be used). - */ - computeTangents(): void; - - computeLineDistances(): void; - - /** - * Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute. - */ - computeBoundingBox(): void; - - /** - * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute. - * Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are null. - */ - computeBoundingSphere(): void; - - /** - * Checks for duplicate vertices using hashmap. - * Duplicated vertices are removed and faces' vertices are updated. - */ - mergeVertices(): number; - - /** - * Creates a new clone of the Geometry. - */ - clone(): Geometry; - - /** - * Removes The object from memory. - * Don't forget to call this method when you remove an geometry because it can cuase meomory leaks. - */ - dispose(): void; - } - - var GeometryIdCount: number; - var GeometryLibrary: Geometry[]; - - interface Math { - /** - * Clamps the x to be between a and b. - * - * @param x Value to be clamped. - * @param a Minimum value - * @param b Maximum value. - */ - clamp(x: number, a: number, b: number): number; - - /** - * Clamps the x to be larger than a. - * - * @param x — Value to be clamped. - * @param a — Minimum value - */ - clampBottom(x: number, a: number): number; - - /** - * Linear mapping of x from range [a1, a2] to range [b1, b2]. - * - * @param x Value to be mapped. - * @param a1 Minimum value for range A. - * @param a2 Maximum value for range A. - * @param b1 Minimum value for range B. - * @param b2 Maximum value for range B. - */ - mapLinear(x: number, a1: number, a2: number, b1: number, b2: number): number; - - smoothstep(x:number, min:number, max:number):number; - - smootherstep(x:number, min:number, max:number):number; - - /** - * Random float from 0 to 1 with 16 bits of randomness. - * Standard Math.random() creates repetitive patterns when applied over larger space. - */ - random16(): number; - - /** - * Random integer from low to high interval. - */ - randInt(low: number, high: number): number; - - /** - * Random float from low to high interval. - */ - randFloat(low: number, high: number): number; - - /** - * Random float from - range / 2 to range / 2 interval. - */ - randFloatSpread(range: number): number; - - /** - * Returns -1 if x is less than 0, 1 if x is greater than 0, and 0 if x is zero. - */ - sign(x: number): number; - - degToRad(degrees: number): number; - - radToDeg(radians: number): number; - } - - /** - * - * @see src/math/Math.js - */ - export var Math: Math; - - /** - * ( interface Matrix<T> ) - */ - export interface Matrix { - /** - * Float32Array with matrix values. - */ - elements: Float32Array; - - /** - * identity():T; - */ - identity(): Matrix; - - /** - * copy(m:T):T; - */ - copy(m: Matrix): Matrix; - - multiplyVector3Array(a: number[]): number[]; - - /** - * multiplyScalar(s:number):T; - */ - multiplyScalar(s: number): Matrix; - - determinant(): number; - - /** - * getInverse(matrix:T, throwOnInvertible?:boolean):T; - */ - getInverse(matrix: Matrix, throwOnInvertible?: boolean): Matrix; - - /** - * transpose():T; - */ - transpose(): Matrix; - - /** - * clone():T; - */ - clone(): Matrix; - } - - /** - * ( class Matrix3 implements Matrix<Matrix3> ) - */ - export class Matrix3 implements Matrix { - /** - * Creates an identity matrix. - */ - constructor(); - - /** - * Initialises the matrix with the supplied n11..n33 values. - */ - constructor(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number); - - /** - * Float32Array with matrix values. - */ - elements: Float32Array; - - set (n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; - identity(): Matrix3; - copy(m: Matrix3): Matrix3; - multiplyVector3Array(a: number[]): number[]; - multiplyScalar(s: number): Matrix3; - determinant(): number; - getInverse(matrix: Matrix3, throwOnInvertible?: boolean): Matrix3; - getInverse(matrix: Matrix4, throwOnInvertible?: boolean): Matrix3; - - /** - * Transposes this matrix in place. - */ - transpose(): Matrix3; - - getNormalMatrix(m:Matrix4): Matrix3; - - /** - * Transposes this matrix into the supplied array r, and returns itself. - */ - transposeIntoArray(r: number[]): number[]; - - clone(): Matrix3; - } - - /** - * A 4x4 Matrix. - * - * @example - * // Simple rig for rotating around 3 axes - * var m = new THREE.Matrix4(); - * var m1 = new THREE.Matrix4(); - * var m2 = new THREE.Matrix4(); - * var m3 = new THREE.Matrix4(); - * var alpha = 0; - * var beta = Math.PI; - * var gamma = Math.PI/2; - * m1.makeRotationX( alpha ); - * m2.makeRotationY( beta ); - * m3.makeRotationZ( gamma ); - * m.multiplyMatrices( m1, m2 ); - * m.multiply( m3 ); - */ - export class Matrix4 implements Matrix { - - /** - * Creates an identity matrix. - */ - constructor(); - - - /** - * Initialises the matrix with the supplied n11..n44 values. - */ - constructor(n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number); - - /** - * Float32Array with matrix values. - */ - elements: Float32Array; - - /** - * Sets all fields of this matrix. - */ - set (n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number): Matrix4; - - /** - * Resets this matrix to identity. - */ - identity(): Matrix4; - - /** - * Copies a matrix m into this matrix. - */ - copy(m: Matrix4): Matrix4; - - /** - * Sets the rotation submatrix of this matrix to the rotation specified by Euler angles. - * Default order is "XYZ". - * - * @param v Rotation vector. order — The order of rotations. Eg. "XYZ". - */ - setRotationFromEuler(v: Vector3, order?: string): Matrix4; - - /** - * Sets the rotation submatrix of this matrix to the rotation specified by q. - */ - setRotationFromQuaternion(q: Quaternion): Matrix4; - - /** - * Constructs a rotation matrix, looking from eye towards center with defined up vector. - */ - lookAt(eye: Vector3, target: Vector3, up: Vector3): Matrix4; - - /** - * Multiplies this matrix by m. - */ - multiply(m: Matrix4): Matrix4; - - /** - * Sets this matrix to a x b. - */ - multiplyMatrices(a: Matrix4, b: Matrix4): Matrix4; - - /** - * Sets this matrix to a x b and stores the result into the flat array r. - * r can be either a regular Array or a TypedArray. - */ - multiplyToArray(a: Matrix4, b: Matrix4, r: number[]): Matrix4; - - /** - * Multiplies this matrix by s. - */ - multiplyScalar(s: number): Matrix4; - - multiplyVector3Array(a: number[]): number[]; - - rotateAxis(v: Vector3): Vector3; - - /** - * Computes the cross product between this matrix and the Vector4 parameter a. - */ - crossVector(a: Vector3): Vector4; - - /** - * Computes determinant of this matrix. - * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm - */ - determinant(): number; - - /** - * Transposes this matrix. - */ - transpose(): Matrix4; - - /** - * Flattens this matrix into supplied flat array. - */ - flattenToArray(flat: number[]): number[]; - - /** - * Flattens this matrix into supplied flat array starting from offset position in the array. - */ - flattenToArrayOffset(flat: number[], offset: number): number[]; - - /** - * Sets the position component for this matrix from vector v. - */ - setPosition(v: Vector3): Vector3; - - /** - * Sets this matrix to the inverse of matrix m. - * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm. - */ - getInverse(m: Matrix4, throwOnInvertible?: boolean): Matrix4; - - /** - * Sets this matrix to the transformation composed of translation, rotation and scale. - */ - compose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4; - - /** - * Decomposes this matrix into the translation, rotation and scale components. - * If parameters are not passed, new instances will be created. - */ - decompose(translation?: Vector3, rotation?: Quaternion, scale?: Vector3): Object[]; // [Vector3, Quaternion, Vector3] - - /** - * Copies the translation component of the supplied matrix m into this matrix translation component. - */ - extractPosition(m: Matrix4): Matrix4; - - /** - * Copies the rotation component of the supplied matrix m into this matrix rotation component. - */ - extractRotation(m: Matrix4): Matrix4; - - /** - * Translates this matrix by vector v. - */ - translate(v: Vector3): Matrix4; - - /** - * Rotates this matrix around the x axis by angle. - */ - rotateX(angle: number): Matrix4; - - /** - * Rotates this matrix around the y axis by angle. - */ - rotateY(angle: number): Matrix4; - - /** - * Rotates this matrix around the z axis by angle. - */ - rotateZ(angle: number): Matrix4; - - /** - * Rotates this matrix around the supplied axis by angle. - */ - rotateByAxis(axis: Vector3, angle: number): Matrix4; - - /** - * Multiplies the columns of this matrix by vector v. - */ - scale(v: Vector3): Matrix4; - - getMaxScaleOnAxis(): number; - - /** - * Sets this matrix as translation transform. - */ - makeTranslation(x: number, y: number, z: number): Matrix4; - - /** - * Sets this matrix as rotation transform around x axis by theta radians. - * - * @param theta Rotation angle in radians. - */ - makeRotationX(theta: number): Matrix4; - - /** - * Sets this matrix as rotation transform around y axis by theta radians. - * - * @param theta Rotation angle in radians. - */ - makeRotationY(theta: number): Matrix4; - - /** - * Sets this matrix as rotation transform around z axis by theta radians. - * - * @param theta Rotation angle in radians. - */ - makeRotationZ(theta: number): Matrix4; - - /** - * Sets this matrix as rotation transform around axis by angle radians. - * Based on http://www.gamedev.net/reference/articles/article1199.asp. - * - * @param axis Rotation axis. - * @param theta Rotation angle in radians. - */ - makeRotationAxis(axis: Vector3, angle: number): Matrix4; - - /** - * Sets this matrix as scale transform. - */ - makeScale(x: number, y: number, z: number): Matrix4; - - /** - * Creates a frustum matrix. - */ - makeFrustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4; - - /** - * Creates a perspective projection matrix. - */ - makePerspective(fov: number, aspect: number, near: number, far: number): Matrix4; - - /** - * Creates an orthographic projection matrix. - */ - makeOrthographic(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4; - - /** - * Clones this matrix. - */ - clone(): Matrix4; - } - - export class Ray { - constructor(origin?: Vector3, direction?: Vector3); - origin: Vector3; - direction: Vector3; - set (origin: Vector3, direction: Vector3): Ray; - copy(ray: Ray): Ray; - at(t: number, optionalTarget?: Vector3): Vector3; - recast(t: number): Ray; - closestPointToPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - distanceToPoint(point: Vector3): number; - isIntersectionSphere(sphere: Sphere): boolean; - isIntersectionPlane(plane: Plane): boolean; - distanceToPlane(plane: Plane): number; - intersectPlane(plane: Plane, optionalTarget?: Vector3): Vector3; - applyMatrix4(matrix4: Matrix4): Ray; - equals(ray: Ray): boolean; - clone(): Ray; - } - - - /** - * Base class for scene graph objects - */ - export class Object3D { - constructor(); - - /** - * Unique number of this object instance. - */ - id: number; - - /** - * Optional name of the object (doesn't need to be unique). - */ - name: string; - - properties: any; - - /** - * Object's parent in the scene graph. - */ - parent: Object3D; - - /** - * Array with object's children. - */ - children: Object3D[]; - - /** - * Object's local position. - */ - position: Vector3; - - /** - * Object's local rotation (Euler angles), in radians. - */ - rotation: Vector3; - - /** - * Order of axis for Euler angles. - */ - eulerOrder: string; - // eulerOrder:EulerOrder; - - /** - * Object's local scale. - */ - scale: Vector3; - - /** - * Up direction. - */ - up: Vector3; - - /** - * Local transform. - */ - matrix: Matrix4; - - /** - * Global rotation. - */ - matrixRotationWorld: Matrix4; - - /** - * Global rotation. - */ - quaternion: Quaternion; - - /** - * Use quaternion instead of Euler angles for specifying local rotation. - */ - useQuaternion: boolean; - - /** - * Default is 0.0. - */ - boundRadius: number; - - /** - * Maximum scale from x, y, z scale components. - */ - boundRadiusScale: number; - - /** - * Override depth-sorting order if non null. - */ - renderDepth: number; - - /** - * Object gets rendered if true. - */ - visible: boolean; - - /** - * Gets rendered into shadow map. - */ - castShadow: boolean; - - /** - * Material gets baked in shadow receiving. - */ - receiveShadow: boolean; - - /** - * When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible. - */ - frustumCulled: boolean; - - /** - * When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property. - */ - matrixAutoUpdate: boolean; - - /** - * When this is set, it calculates the matrixWorld in that frame and resets this property to false. - */ - matrixWorldNeedsUpdate: boolean; - - /** - * When this is set, then the rotationMatrix gets calculated every frame. - */ - rotationAutoUpdate: boolean; - - /** - * This updates the position, rotation and scale with the matrix. - */ - applyMatrix(matrix: Matrix4): void; - - /** - * Translates object along arbitrary axis by distance. - * @param distance Distance. - * @param axis Translation direction. - */ - translate(distance: number, axis: Vector3): void; - - /** - * Translates object along x axis by distance. - * @param distance Distance. - */ - translateX(distance: number): void; - - /** - * Translates object along y axis by distance. - * @param distance Distance. - */ - translateY(distance: number): void; - - /** - * Translates object along z axis by distance. - * @param distance Distance. - */ - translateZ(distance: number): void; - - /** - * Updates the vector from local space to world space. - * @param vector A local vector. - */ - localToWorld(vector: Vector3): Vector3; - - /** - * Updates the vector from world space to local space. - * @param vector A world vector. - */ - worldToLocal(vector: Vector3): Vector3; - - /** - * Rotates object to face point in space. - * @param vector A world vector to look at. - */ - lookAt(vector: Vector3): void; - - /** - * Adds object as child of this object. - */ - add(object: Object3D): void; - - /** - * Removes object as child of this object. - */ - remove(object: Object3D): void; - - /** - * Translates object along arbitrary axis by distance. - * @param distance Distance. - * @param axis Translation direction. - */ - traverse(callback: (object: Object3D) => any): void; - - /** - * Gets first child with name matching the argument. Searches whole subgraph recursively if recursive is true. - * @param name Object name. - * @param recursive Whether check in the objects's children. - */ - getChildByName(name: string, recursive: boolean): Object3D; - - /** - * Searches whole subgraph recursively to add all objects in the array. - * @param array optional argument that returns the the array with descendants. - */ - getDescendants(array?: Object3D[]): Object3D[]; - - /** - * Updates local transform. - */ - updateMatrix(): void; - - /** - * Updates global transform of the object and its children. - */ - updateMatrixWorld(force: boolean): void; - - /** - * Creates a new clone of this object and all descendants. - */ - clone(object?: Object3D): Object3D; - - static defaultEulerOrder: string; - // static defaultEulerOrder:EulerOrder; - - /** - * An object that can be used to store custom data about the Object3d. - * It should not hold references to functions as these will not be cloned. - */ - userData: any; - } - - var Object3DIdCount: number; - var Object3DLibrary: Object3D[]; - - /** - * Projects points between spaces. - */ - export class Projector { - - constructor(); - - projectVector(vector: Vector3, camera: Camera): Vector3; - - unprojectVector(vector: Vector3, camera: Camera): Vector3; - - /** - * Translates a 2D point from NDC (Normalized Device Coordinates) to a Raycaster that can be used for picking. NDC range from [-1..1] in x (left to right) and [1.0 .. -1.0] in y (top to bottom). - */ - pickingRay(vector: Vector3, camera: Camera): Raycaster; - - /** - * Transforms a 3D scene object into 2D render data that can be rendered in a screen with your renderer of choice, projecting and clipping things out according to the used camera. - * If the scene were a real scene, this method would be the equivalent of taking a picture with the camera (and developing the film would be the next step, using a Renderer). - * - * @param scene scene to project. - * @param camera camera to use in the projection. - * @param sort select whether to sort elements using the Painter's algorithm. - */ - projectScene(scene: Scene, camera: Camera, sortObjects: boolean, sortElements?: boolean): { - objects: Object3D[]; // Mesh, Line or other object - sprites: Object3D[]; // Sprite or Particle - lights: Light[]; - elements: Face[]; // Line, Particle, Face3 or Face4 - }; - } - - /** - * Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages. - * - * @example - * var quaternion = new THREE.Quaternion(); - * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 ); - * var vector = new THREE.Vector3( 1, 0, 0 ); - * vector.applyQuaternion( quaternion ); - */ - export class Quaternion { - /** - * @param x x coordinate - * @param y y coordinate - * @param z z coordinate - * @param w w coordinate - */ - constructor(x?: number, y?: number, z?: number, w?: number); - - x: number; - y: number; - z: number; - w: number; - - /** - * Sets values of this quaternion. - */ - set (x: number, y: number, z: number, w: number): Quaternion; - - /** - * Copies values of q to this quaternion. - */ - copy(q: Quaternion): Quaternion; - - /** - * Sets this quaternion from rotation specified by Euler angles. - */ - setFromEuler(v: Vector3, order: string): Quaternion; - - /** - * Sets this quaternion from rotation specified by axis and angle. - * Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm. - * Axis have to be normalized, angle is in radians. - */ - setFromAxisAngle(axis: Vector3, angle: number): Quaternion; - - /** - * Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm. - */ - setFromRotationMatrix(m: Matrix4): Quaternion; - - /** - * Inverts this quaternion. - */ - inverse(): Quaternion; - - conjugate(): Quaternion; - - lengthSq(): number; - - /** - * Computes length of this quaternion. - */ - length(): number; - - /** - * Normalizes this quaternion. - */ - normalize(): Quaternion; - - /** - * Multiplies this quaternion by b. - */ - multiply(q: Quaternion): Quaternion; - - /** - * Sets this quaternion to a x b - * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm. - */ - multiplyQuaternions(a: Quaternion, b: Quaternion): Quaternion; - - slerp(qb: Quaternion, t: number): Quaternion; - - equals(v: Quaternion): boolean; - - /** - * Clones this quaternion. - */ - clone(): Quaternion; - - /** - * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/. - */ - static slerp(qa: Quaternion, qb: Quaternion, qm: Quaternion, t: number): Quaternion; - } - - export interface Intersection { - distance: number; - point: Vector3; - face: Face; - object: Object3D; - } - - export class Raycaster { - constructor(origin?: Vector3, direction?: Vector3, near?: number, far?: number); - ray: Ray; - near: number; - far: number; - precision: number; - set (origin: Vector3, direction: Vector3): void; - intersectObject(object: Object3D, recursive?: boolean): Intersection[]; - intersectObjects(objects: Object3D[], recursive?: boolean): Intersection[]; - } - - export interface SplineControlPoint { - x: number; - y: number; - z: number; - } - - /** - * Represents a spline. - * - * @see src/math/Spline.js - */ - export class Spline { - /** - * Initialises the spline with points, which are the places through which the spline will go. - */ - constructor(points: SplineControlPoint[]); - - points: SplineControlPoint[]; - - /** - * Initialises using the data in the array as a series of points. Each value in a must be another array with three values, where a[n] is v, the value for the nth point, and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively. - * - * @param a array of triplets containing x, y, z coordinates - */ - initFromArray(a: number[][]): void; - - /** - * Return the interpolated point at k. - * - * @param k point index - */ - getPoint(k: number): SplineControlPoint; - - /** - * Returns an array with triplets of x, y, z coordinates that correspond to the current control points. - */ - getControlPointsArray(): number[][]; - - /** - * Returns the length of the spline when using nSubDivisions. - * @param nSubDivisions number of subdivisions between control points. Default is 100. - */ - getLength(nSubDivisions?: number): { chunks: number[]; total: number; }; - - /** - * Modifies the spline so that it looks similar to the original but has its points distributed in such way that moving along the spline it's done at a more or less constant speed. The points should also appear more uniformly spread along the curve. - * This is done by resampling the original spline, with the density of sampling controlled by samplingCoef. Here it's interesting to note that denser sampling is not necessarily better: if sampling is too high, you may get weird kinks in curvature. - * - * @param samplingCoef how many intermediate values to use between spline points - */ - reparametrizeByArcLength(samplingCoef: number): void; - } - - class Triangle{ - constructor(a?: Vector3, b?: Vector3, c?: Vector3 ); - a: Vector3; - b: Vector3; - c: Vector3; - set(a: Vector3, b: Vector3, c: Vector3): Triangle; - setFromPointsAndIndices( points: Vector3[], i0: number, i1: number, i2: number ): Triangle; - copy(triangle: Triangle): Triangle; - area(): number; - midpoint(optionalTarget?: Vector3): Vector3; - normal(optionalTarget?: Vector3): Vector3; - plane(optionalTarget?: Vector3): Plane; - barycoordFromPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - containsPoint(point: Vector3): boolean; - equals(triangle: Triangle): boolean; - clone(): Triangle; - static normal(a: Vector3, b: Vector3, c: Vector3, optionalTarget?: Vector3): Vector3; - // static/instance method to calculate barycoordinates - // based on: http://www.blackpawn.com/texts/pointinpoly/default.html - static barycoordFromPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3, optionalTarget: Vector3 ): Vector3; - static containsPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3): boolean; - } - - - /** - * ( interface Vector<T> ) - * - * Abstruct interface of Vector2, Vector3 and Vector4. - * Currently the members of Vector is NOT type safe because it accepts different typed vectors. - * Those definitions will be changed when TypeScript innovates Generics to be type safe. - * - * @example - * var v:THREE.Vector = new THREE.Vector3(); - * v.addVectors(new THREE.Vector2(0, 1), new THREE.Vector2(2, 3)); // invalid but compiled successfully - */ - export interface Vector { - setComponent(index: number, value: number): void; - - getComponent(index: number): number; - - /** - * copy(v:T):T; - */ - copy(v: Vector): Vector; - - /** - * add(v:T):T; - */ - add(v: Vector): Vector; - - /** - * addVectors(a:T, b:T):T; - */ - addVectors(a: Vector, b: Vector): Vector; - - /** - * sub(v:T):T; - */ - sub(v: Vector): Vector; - - /** - * subVectors(a:T, b:T):T; - */ - subVectors(a: Vector, b: Vector): Vector; - - /** - * multiplyScalar(s:number):T; - */ - multiplyScalar(s: number): Vector; - - /** - * divideScalar(s:number):T; - */ - divideScalar(s: number): Vector; - - /** - * negate():T; - */ - negate(): Vector; - - /** - * dot(v:T):T; - */ - dot(v: Vector): number; - - /** - * lengthSq():number; - */ - lengthSq(): number; - - /** - * length():number; - */ - length(): number; - - /** - * normalize():T; - */ - normalize(): Vector; - - /** - * NOTE: Vector4 doesn't have the property. - * - * distanceTo(v:T):number; - */ - distanceTo(v: Vector): number; - - /** - * NOTE: Vector4 doesn't have the property. - * - * distanceToSquared(v:T):number; - */ - distanceToSquared(v: Vector): number; - - /** - * setLength(l:number):T; - */ - setLength(l: number): Vector; - - /** - * lerp(v:T, alpha:number):T; - */ - lerp(v: Vector, alpha: number): Vector; - - /** - * equals(v:T):boolean; - */ - equals(v: Vector): boolean; - - /** - * clone():T; - */ - clone(): Vector; - } - - /** - * 2D vector. - * - * ( class Vector2 implements Vector ) - */ - export class Vector2 implements Vector { - - constructor(x?: number, y?: number); - - x: number; - - y: number; - - /** - * Sets value of this vector. - */ - set (x: number, y: number): Vector2; - - /** - * Sets X component of this vector. - */ - setX (x: number): Vector2; - - /** - * Sets Y component of this vector. - */ - setY(y: number): Vector2; - - /** - * Sets a component of this vector. - */ - setComponent(index: number, value: number): void; - - /** - * Gets a component of this vector. - */ - getComponent(index: number): number; - - /** - * Copies value of v to this vector. - */ - copy(v: Vector2): Vector2; - - /** - * Adds v to this vector. - */ - add(v: Vector2): Vector2; - - /** - * Sets this vector to a + b. - */ - addVectors(a: Vector2, b: Vector2): Vector2; - - /** - * Subtracts v from this vector. - */ - sub(v: Vector2): Vector2; - - /** - * Sets this vector to a - b. - */ - subVectors(a: Vector2, b: Vector2): Vector2; - - /** - * Multiplies this vector by scalar s. - */ - multiplyScalar(s: number): Vector2; - - /** - * Divides this vector by scalar s. - * Set vector to ( 0, 0 ) if s == 0. - */ - divideScalar(s: number): Vector2; - - min(v: Vector2): Vector2; - - max(v: Vector2): Vector2; - - clamp(min: Vector2, max: Vector2): Vector2; - - /** - * Inverts this vector. - */ - negate(): Vector2; - - /** - * Computes dot product of this vector and v. - */ - dot(v: Vector2): number; - - /** - * Computes squared length of this vector. - */ - lengthSq(): number; - - /** - * Computes length of this vector. - */ - length(): number; - - /** - * Normalizes this vector. - */ - normalize(): Vector2; - - /** - * Computes distance of this vector to v. - */ - distanceTo(v: Vector2): number; - - /** - * Computes squared distance of this vector to v. - */ - distanceToSquared(v: Vector2): number; - - /** - * Normalizes this vector and multiplies it by l. - */ - setLength(l: number): Vector2; - - lerp(v: Vector2, alpha: number): Vector2; - - /** - * Checks for strict equality of this vector and v. - */ - equals(v: Vector2): boolean; - - toArray(): number[]; - - /** - * Clones this vector. - */ - clone(): Vector2; - } - - /** - * 3D vector. - * - * @example - * var a = new THREE.Vector3( 1, 0, 0 ); - * var b = new THREE.Vector3( 0, 1, 0 ); - * var c = new THREE.Vector3(); - * c.crossVectors( a, b ); - * - * @see src/math/Vector3.js - * - * ( class Vector3 implements Vector ) - */ - export class Vector3 implements Vector { - - constructor(x?: number, y?: number, z?: number); - - x: number; - - y: number; - - z: number; - - /** - * Sets value of this vector. - */ - set (x: number, y: number, z: number): Vector3; - - /** - * Sets x value of this vector. - */ - setX(x: number): Vector3; - - /** - * Sets y value of this vector. - */ - setY(y: number): Vector3; - - /** - * Sets z value of this vector. - */ - setZ(z: number): Vector3; - - setComponent(index: number, value: number): void; - - getComponent(index: number): number; - - /** - * Copies value of v to this vector. - */ - copy(v: Vector3): Vector3; - - /** - * Adds v to this vector. - */ - add(a: Object): Vector3; - - addScalar(s: number): Vector3; - - /** - * Sets this vector to a + b. - */ - addVectors(a: Vector3, b: Vector3): Vector3; - - /** - * Subtracts v from this vector. - */ - sub(a: Vector3): Vector3; - - /** - * Sets this vector to a - b. - */ - subVectors(a: Vector3, b: Vector3): Vector3; - - multiply(v: Vector3): Vector3; - - /** - * Multiplies this vector by scalar s. - */ - multiplyScalar(s: number): Vector3; - - multiplyVectors(a: Vector3, b: Vector3): Vector3; - applyMatrix3(m: Matrix3): Vector3; - applyMatrix4(m: Matrix4): Vector3; - applyProjection(m: Matrix4): Vector3; - applyQuaternion(q: Quaternion): Vector3; - - // applyEuler(v:Vector3, eulerOrder:EulerOrder):Vector3; - applyEuler(v: Vector3, eulerOrder: string): Vector3; - - applyAxisAngle(axis: Vector3, angle: number): Vector3; - transformDirection(m:Matrix4):Vector3; - divide(v: Vector3): Vector3; - - /** - * Divides this vector by scalar s. - * Set vector to ( 0, 0, 0 ) if s == 0. - */ - divideScalar(s: number): Vector3; - - min(v: Vector3): Vector3; - max(v: Vector3): Vector3; - - clamp(min: Vector3, max: Vector3): Vector3; - - /** - * Inverts this vector. - */ - negate(): Vector3; - - /** - * Computes dot product of this vector and v. - */ - dot(v: Vector3): number; - - /** - * Computes squared length of this vector. - */ - lengthSq(): number; - - /** - * Computes length of this vector. - */ - length(): number; - - /** - * Computes Manhattan length of this vector. - * http://en.wikipedia.org/wiki/Taxicab_geometry - */ - lengthManhattan(): number; - - /** - * Normalizes this vector. - */ - normalize(): Vector3; - - /** - * Normalizes this vector and multiplies it by l. - */ - setLength(l: number): Vector3; - - lerp(v: Vector3, alpha: number): Vector3; - - /** - * Sets this vector to cross product of itself and v. - */ - cross(a: Vector3): Vector3; - - /** - * Sets this vector to cross product of a and b. - */ - crossVectors(a: Vector3, b: Vector3): Vector3; - - projectOnVector(v:Vector3): Vector3; - - projectOnPlane(planeNormal:Vector3): Vector3; - - reflect(vector:Vector3):Vector3; - - angleTo(v: Vector3): number; - - /** - * Computes distance of this vector to v. - */ - distanceTo(v: Vector3): number; - - /** - * Computes squared distance of this vector to v. - */ - distanceToSquared(v: Vector3): number; - - /** - * Sets this vector extracting position from matrix transform. - */ - getPositionFromMatrix(m: Matrix4): Vector3; - - setEulerFromRotationMatrix(m: Matrix4, order: string): Vector3; - - setEulerFromQuaternion(q: Quaternion, order: string): Vector3; - - /** - * Sets this vector extracting scale from matrix transform. - */ - getScaleFromMatrix(m: Matrix4): Vector3; - - /** - * Checks for strict equality of this vector and v. - */ - equals(v: Vector3): boolean; - - toArray(): number[]; - - /** - * Clones this vector. - */ - clone(): Vector3; - } - - /** - * 4D vector. - * - * ( class Vector4 implements Vector ) - */ - export class Vector4 implements Vector { - constructor(x?: number, y?: number, z?: number, w?: number); - x: number; - y: number; - z: number; - w: number; - - /** - * Sets value of this vector. - */ - set (x: number, y: number, z: number, w: number): Vector4; - - /** - * Sets X component of this vector. - */ - setX (x: number): Vector2; - - /** - * Sets Y component of this vector. - */ - setY(y: number): Vector2; - - /** - * Sets Z component of this vector. - */ - setZ(z: number): Vector2; - - /** - * Sets w component of this vector. - */ - setW(w: number): Vector2; - - setComponent(index: number, value: number): void; - - getComponent(index: number): number; - - /** - * Copies value of v to this vector. - */ - copy(v: Vector4): Vector4; - - /** - * Adds v to this vector. - */ - add(v: Vector4): Vector4; - - /** - * Sets this vector to a + b. - */ - addVectors(a: Vector4, b: Vector4): Vector4; - - /** - * Subtracts v from this vector. - */ - sub(v: Vector4): Vector4; - - /** - * Sets this vector to a - b. - */ - subVectors(a: Vector4, b: Vector4): Vector4; - - /** - * Multiplies this vector by scalar s. - */ - multiplyScalar(s: number): Vector4; - - /** - * Divides this vector by scalar s. - * Set vector to ( 0, 0, 0 ) if s == 0. - */ - divideScalar(s: number): Vector4; - - min(v: Vector4): Vector4; - - max(v: Vector4): Vector4; - - clamp(min: Vector4, max: Vector4): Vector4; - - /** - * Inverts this vector. - */ - negate(): Vector4; - - /** - * Computes dot product of this vector and v. - */ - dot(v: Vector4): number; - - /** - * Computes squared length of this vector. - */ - lengthSq(): number; - - /** - * Computes length of this vector. - */ - length(): number; - - lengthManhattan(): number; - - /** - * Normalizes this vector. - */ - normalize(): Vector4; - - /** - * NOTE: Vector4 doesn't have the property. - * Computes distance of this vector to v. - */ - distanceTo(v: Vector3): number; - - /** - * NOTE: Vector4 doesn't have the property. - * Computes squared distance of this vector to v. - */ - distanceToSquared(v: Vector3): number; - - - /** - * Normalizes this vector and multiplies it by l. - */ - setLength(l: number): Vector4; - - /** - * Linearly interpolate between this vector and v with alpha factor. - */ - lerp(v: Vector4, alpha: number): Vector4; - - /** - * Checks for strict equality of this vector and v. - */ - equals(v: Vector4): boolean; - - toArray(): number[]; - - /** - * Clones this vector. - */ - clone(): Vector4; - - /** - * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm - * @param q is assumed to be normalized - */ - setAxisAngleFromQuaternion(q: Quaternion): Vector4; - - /** - * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm - * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) - */ - setAxisAngleFromRotationMatrix(m: Matrix3): Vector4; - } - - export class Box2 { - constructor(min?: Vector2, max?: Vector2); - min: Vector2; - max: Vector2; - set (min: Vector2, max: Vector2): Box2; - setFromPoints(points: Vector2[]): Box2; - setFromCenterAndSize(center: Vector2, size: number): Box2; - copy(box: Box2): Box2; - makeEmpty(): Box2; - empty(): boolean; - center(optionalTarget?: Vector2): Vector2; - size(optionalTarget?: Vector2): Vector2; - expandByPoint(point: Vector2): Box2; - expandByVector(vector: Vector2): Box2; - expandByScalar(scalar: number): Box2; - containsPoint(point: Vector2): boolean; - containsBox(box: Box2): boolean; - getParameter(point: Vector2): Vector2; - isIntersectionBox(box: Box2): boolean; - clampPoint(point: Vector2, optionalTarget?: Vector2): Vector2; - distanceToPoint(point: Vector2): number; - intersect(box: Box2): Box2; - union(box: Box2): Box2; - translate(offset: Vector2): Box2; - equals(box: Box2): boolean; - clone(): Box2; - } - - export class Box3 { - constructor(min?: Vector3, max?: Vector3); - min: Vector3; - max: Vector3; - set (min: Vector3, max: Vector3): Box3; - setFromPoints(points: Vector3[]): Box3; - setFromCenterAndSize(center: Vector3, size: number): Box3; - copy(box: Box3): Box3; - makeEmpty(): Box3; - empty(): boolean; - center(optionalTarget?: Vector3): Vector3; - size(optionalTarget?: Vector3): Vector3; - expandByPoint(point: Vector3): Box3; - expandByVector(vector: Vector3): Box3; - expandByScalar(scalar: number): Box3; - containsPoint(point: Vector3): boolean; - containsBox(box: Box3): boolean; - getParameter(point: Vector3): Vector3; - isIntersectionBox(box: Box3): boolean; - clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; - distanceToPoint(point: Vector3): number; - getBoundingSphere(): Sphere; - intersect(box: Box3): Box3; - union(box: Box3): Box3; - applyMatrix4(matrix: Matrix4): Box3; - translate(offset: Vector3): Box3; - equals(box: Box3): boolean; - clone(): Box3; - } - - // Cameras //////////////////////////////////////////////////////////////////////////////////////// - - /** - * Abstract base class for cameras. This class should always be inherited when you build a new camera. - */ - export class Camera extends Object3D { - - /** - * This constructor sets following properties to the correct type: matrixWorldInverse, projectionMatrix and projectionMatrixInverse. - */ - constructor(); - - /** - * This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera. - */ - matrixWorldInverse: Matrix4; - - /** - * This is the matrix which contains the projection. - */ - projectionMatrix: Matrix4; - - /** - * This is the inverse of projectionMatrix. - */ - projectionMatrixInverse: Matrix4; - - /** - * This make the camera look at the vector position in local space. - * @param vector point to look at - */ - lookAt(vector: Vector3): void; - } - - /** - * Camera with orthographic projection - * - * @example - * var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); - * scene.add( camera ); - * - * @see src/cameras/OrthographicCamera.js - */ - export class OrthographicCamera extends Camera { - /** - * @param left Camera frustum left plane. - * @param right Camera frustum right plane. - * @param top Camera frustum top plane. - * @param bottom Camera frustum bottom plane. - * @param near Camera frustum near plane. - * @param far Camera frustum far plane. - */ - constructor(left: number, right: number, top: number, bottom: number, near?: number, far?: number); - - /** - * Camera frustum left plane. - */ - left: number; - - /** - * Camera frustum right plane. - */ - right: number; - - /** - * Camera frustum top plane. - */ - top: number; - - /** - * Camera frustum bottom plane. - */ - bottom: number; - - /** - * Camera frustum near plane. - */ - near: number; - - /** - * Camera frustum far plane. - */ - far: number; - - /** - * Updates the camera projection matrix. Must be called after change of parameters. - */ - updateProjectionMatrix(): void; - } - - /** - * Camera with perspective projection. - * - * # example - * var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); - * scene.add( camera ); - * - * @source https://github.com/mrdoob/three.js/blob/master/src/cameras/PerspectiveCamera.js - */ - export class PerspectiveCamera extends Camera { - /** - * @param fov Camera frustum vertical field of view. Default value is 50. - * @param aspect Camera frustum aspect ratio. Default value is 1. - * @param near Camera frustum near plane. Default value is 0.1. - * @param far Camera frustum far plane. Default value is 2000. - */ - constructor(fov?: number, aspect?: number, near?: number, far?: number); - - /** - * Camera frustum vertical field of view, from bottom to top of view, in degrees. - */ - fov: number; - - /** - * Camera frustum aspect ratio, window width divided by window height. - */ - aspect: number; - - /** - * Camera frustum near plane. - */ - near: number; - - /** - * Camera frustum far plane. - */ - far: number; - - /** - * Uses focal length (in mm) to estimate and set FOV 35mm (fullframe) camera is used if frame size is not specified. - * Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html - * @param focalLength focal length - * @param frameHeight frame size. Default value is 24. - */ - setLens(focalLength: number, frameHeight?: number): void; - - /** - * Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups. - * For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this: - * - * +---+---+---+ - * | A | B | C | - * +---+---+---+ - * | D | E | F | - * +---+---+---+ - * - * then for each monitor you would call it like this: - * - * var w = 1920; - * var h = 1080; - * var fullWidth = w * 3; - * var fullHeight = h * 2; - * - * // A - * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); - * // B - * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); - * // C - * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); - * // D - * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); - * // E - * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); - * // F - * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid. - * - * @param fullWidth full width of multiview setup - * @param fullHeight full height of multiview setup - * @param x horizontal offset of subcamera - * @param y vertical offset of subcamera - * @param width width of subcamera - * @param height height of subcamera - */ - setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void; - - /** - * Updates the camera projection matrix. Must be called after change of parameters. - */ - updateProjectionMatrix(): void; - } - - // Lights ////////////////////////////////////////////////////////////////////////////////// - - /** - * Abstract base class for lights. - */ - export class Light extends Object3D { - constructor(hex?: number); - color: Color; - } - - /** - * This light's color gets applied to all the objects in the scene globally. - * - * # example - * var light = new THREE.AmbientLight( 0x404040 ); // soft white light - * scene.add( light ); - * - * @source https://github.com/mrdoob/three.js/blob/master/src/lights/AmbientLight.js - */ - export class AmbientLight extends Light { - /** - * This creates a Ambientlight with a color. - * @param hex Numeric value of the RGB component of the color. - */ - constructor(hex?: number); - } - - export class AreaLight{ - constructor(hex: number, intensity?: number); - normal: Vector3; - right: Vector3; - intensity: number; - width: number; - height: number; - constantAttenuation: number; - linearAttenuation: number; - quadraticAttenuation: number; - } - - /** - * Affects objects using MeshLambertMaterial or MeshPhongMaterial. - * - * @example - * // White directional light at half intensity shining from the top. - * var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); - * directionalLight.position.set( 0, 1, 0 ); - * scene.add( directionalLight ); - * - * @see src/lights/DirectionalLight.js - */ - export class DirectionalLight extends Light { - - constructor(hex?: number, intensity?: number); - - /** - * Direction of the light is normalized vector from position to (0,0,0). - * Default — new THREE.Vector3(). - */ - position: Vector3; - - /** - * Target used for shadow camera orientation. - */ - target: Object3D; - - /** - * Light's intensity. - * Default — 1.0. - */ - intensity: number; - - /** - * If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right. - * Default — false. - */ - castShadow: boolean; - - /** - * If set to true light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute). - * Default — false. - */ - onlyShadow: boolean; - - /** - * Orthographic shadow camera frustum parameter. - * Default — 50. - */ - shadowCameraNear: number; - - /** - * Orthographic shadow camera frustum parameter. - * Default — 5000. - */ - shadowCameraFar: number; - - /** - * Orthographic shadow camera frustum parameter. - * Default — -500. - */ - shadowCameraLeft: number; - - /** - * Orthographic shadow camera frustum parameter. - * Default — 500. - */ - shadowCameraRight: number; - - /** - * Orthographic shadow camera frustum parameter. - * Default — 500. - */ - shadowCameraTop: number; - - /** - * Orthographic shadow camera frustum parameter. - * Default — -500. - */ - shadowCameraBottom: number; - - /** - * Show debug shadow camera frustum. - * Default — false. - */ - shadowCameraVisible: boolean; - - /** - * Shadow map bias. - * Default — 0. - */ - shadowBias: number; - - /** - * Darkness of shadow casted by this light (from 0 to 1). - * Default — 0.5. - */ - shadowDarkness: number; - - /** - * Shadow map texture width in pixels. - * Default — 512. - */ - shadowMapWidth: number; - - /** - * Shadow map texture height in pixels. - * Default — 512. - */ - shadowMapHeight: number; - - /** - * Default — false. - */ - shadowCascade: boolean; - - /** - * Three.Vector3( 0, 0, -1000 ). - */ - shadowCascadeOffset: Vector3; - - /** - * Default — 2. - */ - shadowCascadeCount: number; - - /** - * Default — [ 0, 0, 0 ]. - */ - shadowCascadeBias: number[]; - - /** - * Default — [ 512, 512, 512 ]. - */ - shadowCascadeWidth: number[]; - - /** - * Default — [ 512, 512, 512 ]. - */ - shadowCascadeHeight: number[]; - - /** - * Default — [ -1.000, 0.990, 0.998 ]. - */ - shadowCascadeNearZ: number[]; - - /** - * Default — [ 0.990, 0.998, 1.000 ]. - */ - shadowCascadeFarZ: number[]; - - /** - * Default — [ ]. - */ - shadowCascadeArray: DirectionalLight[]; - - /** - * Default — null. - */ - shadowMap: RenderTarget; - - /** - * Default — null. - */ - shadowMapSize: number; - - /** - * Default — null. - */ - shadowCamera: Camera; - - /** - * Default — null. - */ - shadowMatrix: Matrix4; - } - - export class HemisphereLight extends Light { - constructor(skyColorHex?: number, groundColorHex?: number, intensity?: number); - groundColor: Color; - position: Vector3; - intensity: number; - } - - /** - * Affects objects using {@link MeshLambertMaterial} or {@link MeshPhongMaterial}. - * - * @example - * var light = new THREE.PointLight( 0xff0000, 1, 100 ); - * light.position.set( 50, 50, 50 ); - * scene.add( light ); - */ - export class PointLight extends Light { - constructor(hex?: number, intensity?: number, distance?: number); - - /** - * Light's position. - * Default — new THREE.Vector3(). - */ - position: Vector3; - - /* - * Light's intensity. - * Default - 1.0. - */ - intensity: number; - - /** - * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. - * Default — 0.0. - */ - distance: number; - } - - /** - * A point light that can cast shadow in one direction. - * - * @example - * // white spotlight shining from the side, casting shadow - * var spotLight = new THREE.SpotLight( 0xffffff ); - * spotLight.position.set( 100, 1000, 100 ); - * spotLight.castShadow = true; - * spotLight.shadowMapWidth = 1024; - * spotLight.shadowMapHeight = 1024; - * spotLight.shadowCameraNear = 500; - * spotLight.shadowCameraFar = 4000; - * spotLight.shadowCameraFov = 30; - * scene.add( spotLight ); - */ - export class SpotLight extends Light { - constructor(hex?: number, intensity?: number, distance?: number, angle?: number, exponent?: number); - - /** - * Light's position. - * Default — new THREE.Vector3(). - */ - position: Vector3; - - /** - * Spotlight focus points at target.position. - * Default position — (0,0,0). - */ - target: Object3D; - - /** - * Light's intensity. - * Default — 1.0. - */ - intensity: number; - - /** - * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. - * Default — 0.0. - */ - distance: number; - - /* - * Maximum extent of the spotlight, in radians, from its direction. - * Default — Math.PI/2. - */ - angle: number; - - /** - * Rapidity of the falloff of light from its target direction. - * Default — 10.0. - */ - exponent: number; - - /** - * If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right. - * Default — false. - */ - castShadow: boolean; - - /** - * If set to true light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute). - * Default — false. - */ - onlyShadow: boolean; - - /** - * Perspective shadow camera frustum near parameter. - * Default — 50. - */ - shadowCameraNear: number; - - /** - * Perspective shadow camera frustum far parameter. - * Default — 5000. - */ - shadowCameraFar: number; - - /** - * Perspective shadow camera frustum field of view parameter. - * Default — 50. - */ - shadowCameraFov: number; - - /** - * Show debug shadow camera frustum. - * Default — false. - */ - shadowCameraVisible: boolean; - - /** - * Shadow map bias. - * Default — 0. - */ - shadowBias: number; - - /** - * Darkness of shadow casted by this light (from 0 to 1). - * Default — 0.5. - */ - shadowDarkness: number; - - /** - * Shadow map texture width in pixels. - * Default — 512. - */ - shadowMapWidth: number; - - /** - * Shadow map texture height in pixels. - * Default — 512. - */ - shadowMapHeight: number; - - shadowMap: RenderTarget; - shadowMapSize: Vector2; - shadowCamera: Camera; - shadowMatrix: Matrix4; - } - - // Loaders ////////////////////////////////////////////////////////////////////////////////// - - export interface Progress { - total: number; - loaded: number; - } - - /** - * Base class for implementing loaders. - * - * Events: - * load - * Dispatched when the image has completed loading - * content — loaded image - * - * error - * - * Dispatched when the image can't be loaded - * message — error message - */ - export class Loader { - constructor(showStatus?: boolean); - - /** - * If true, show loading status in the statusDomElement. - */ - showStatus: boolean; - - /** - * This is the recipient of status messages. - */ - statusDomElement: HTMLElement; - - /** - * Will be called when load starts. - * The default is a function with empty body. - */ - onLoadStart: () => void; - - /** - * Will be called while load progresses. - * The default is a function with empty body. - */ - onLoadProgress: () => void; - - /** - * Will be called when load completes. - * The default is a function with empty body. - */ - onLoadComplete: () => void; - - /** - * default — null. - * If set, assigns the crossOrigin attribute of the image to the value of crossOrigin, prior to starting the load. - */ - crossOrigin: string; - addStatusElement(): HTMLElement; - updateProgress(progress: Progress): void; - extractUrlBase(url: string): string; - initMaterials(materials: Material[], texturePath: string): Material[]; - needsTangents(materials: Material[]): boolean; - createMaterial(m: Material, texturePath: string): boolean; - } - - /** - * A loader for loading an image. - * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. - */ - export class ImageLoader extends EventDispatcher { - constructor(); - crossOrigin: string; - - /** - * Begin loading from url - * @param url - */ - load(url: string, image?: HTMLImageElement): void; - } - - - /** - * A loader for loading objects in JSON format. - */ - export class JSONLoader extends Loader { - constructor(showStatus?: boolean); - withCredentials: boolean; - - /** - * @param url - * @param callback. This function will be called with the loaded model as an instance of geometry when the load is completed. - * @param texturePath If not specified, textures will be assumed to be in the same folder as the Javascript model file. - */ - load(url: string, callback: (geometry: Geometry, materials: Material[]) => void , texturePath?: string): void; - - loadAjaxJSON(context: JSONLoader, url: string, callback: (geometry: Geometry, materials: Material[]) => void , texturePath?: string, callbackProgress?: (progress: Progress) => void ): void; - createModel(json: any, callback: (geometry: Geometry, materials: Material[]) => void , texturePath?: string): void; - } - - export class LoadingMonitor extends EventDispatcher { - constructor(); - add(loader: Loader): void; - } - - interface SceneLoaderResult{ - scene: Scene; - geometries: {[id:string]:Geometry;}; - face_materials: {[id:string]:Material;}; - materials: {[id:string]:Material;}; - textures: {[id:string]:Texture;}; - objects: {[id:string]:Object3D;}; - cameras: {[id:string]:Camera;}; - lights: {[id:string]:Light;}; - fogs: {[id:string]:IFog;}; - empties: {[id:string]:any;}; - groups: {[id:string]:any;}; - } - - interface SceneLoaderProgress{ - totalModels: number; - totalTextures: number; - loadedModels: number; - loadedTextures: number; - } - - /** - * A loader for loading a complete scene out of a JSON file. - */ - export class SceneLoader { - constructor(); - - /** - * Will be called when load starts. - * The default is a function with empty body. - */ - onLoadStart: () => void; - - /** - * Will be called while load progresses. - * The default is a function with empty body. - */ - onLoadProgress: () => void; - - /** - * Will be called when each element in the scene completes loading. - * The default is a function with empty body. - */ - onLoadComplete: () => void; - - /** - * Will be called when load completes. - * The default is a function with empty body. - */ - callbackSync: (result: SceneLoaderResult) => void; - - /** - * Will be called as load progresses. - * The default is a function with empty body. - */ - callbackProgress: (progress: SceneLoaderProgress, result: SceneLoaderResult) => void; - - geometryHandlerMap: any; - hierarchyHandlerMap: any; - - - /** - * @param url - * @param callbackFinished This function will be called with the loaded model as an instance of scene when the load is completed. - */ - load(url: string, callbackFinished: (scene: Scene) => void ): void; - - addGeometryHandler(typeID: string, loaderClass: Object): void; - - addHierarchyHandler(typeID: string, loaderClass: Object): void; - - static parse(json: any, callbackFinished:(result: SceneLoaderResult)=>void, url: string): void; - } - - /** - * Class for loading a texture. - * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. - */ - export class TextureLoader extends EventDispatcher { - constructor(); - - /** - * Begin loading from url - * - * @param url - */ - load(url: string): void; - } - - // Materials ////////////////////////////////////////////////////////////////////////////////// - - /** - * Materials describe the appearance of objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer. - */ - export class Material { - constructor(); - - /** - * Unique number of this material instance. - */ - id: number; - - /** - * Material name. Default is an empty string. - */ - name: string; - - /** - * Opacity. Default is 1. - */ - opacity: number; - - /** - * Defines whether this material is transparent. This has an effect on rendering, as transparent objects need an special treatment, and are rendered after the opaque (i.e. non transparent) objects. For a working example of this behaviour, check the {@link WebGLRenderer} code. - * Default is false. - */ - transparent: boolean; - - /** - * Which blending to use when displaying objects with this material. Default is {@link NormalBlending}. - */ - blending: Blending; - - /** - * Blending source. It's one of the blending mode constants defined in Three.js. Default is {@link SrcAlphaFactor}. - */ - blendSrc: BlendingDstFactor; - - /** - * Blending destination. It's one of the blending mode constants defined in Three.js. Default is {@link OneMinusSrcAlphaFactor}. - */ - blendDst: BlendingSrcFactor; - - /** - * Blending equation to use when applying blending. It's one of the constants defined in Three.js. Default is AddEquation. - */ - blendEquation: BlendingEquation; - - /** - * Whether to have depth test enabled when rendering this material. Default is true. - */ - depthTest: boolean; - - /** - * Whether rendering this material has any effect on the depth buffer. Default is true. - * When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts. - */ - depthWrite: boolean; - - /** - * Whether to use polygon offset. Default is false. This corresponds to the POLYGON_OFFSET_FILL WebGL feature. - */ - polygonOffset: boolean; - - /** - * Sets the polygon offset factor. Default is 0. - */ - polygonOffsetFactor: number; - - /** - * Sets the polygon offset units. Default is 0. - */ - polygonOffsetUnits: number; - - /** - * Sets the alpha value to be used when running an alpha test. Default is 0. - */ - alphaTest: number; - - /** - * Enables/disables overdraw. If enabled, polygons are drawn slightly bigger in order to fix antialiasing gaps when using the CanvasRenderer. Default is false. - */ - overdraw: boolean; - - /** - * Defines whether this material is visible. Default is true. - */ - visible: boolean; - - /** - * Defines which of the face sides will be rendered - front, back or both. - * Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide. - */ - side: Side; - - /** - * Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL. - * This property is automatically set to true when instancing a new material. - */ - needsUpdate: boolean; - - clone(): Material; - - dispose(): void; - } - - var MaterialLibrary: Material[]; - var MaterialIdCount: number; - - export interface LineBasicMaterialParameters { - color?: number; - opacity?: number; - blending?: Blending; - depthTest?: boolean; - linewidth?: number; - linecap?: string; - linejoin?: string; - vertexColors?: Colors; - fog?: boolean; - } - - export class LineBasicMaterial extends Material { - constructor(parameters?: LineBasicMaterialParameters); - color: Color; - linewidth: number; - linecap: string; - linejoin: string; - vertexColors: boolean; - fog: boolean; - clone(): LineBasicMaterial; - } - - export interface LineDashedMaterialParameters { - color?: number; - opacity?: number; - blending?: Blending; - depthTest?: boolean; - linewidth?: number; - scale?: number; - dashSize?: number; - gapSize?: number; - vertexColors?: number; - fog?: boolean; - } - - export class LineDashedMaterial extends Material { - constructor(parameters?: LineDashedMaterialParameters); - color: Color; - linewidth: number; - scale: number; - dashSize: number; - gapSize: number; - vertexColors: boolean; - fog: boolean; - clone(): LineDashedMaterial; - } - - - /** - * parameters is an object with one or more properties defining the material's appearance. - */ - export interface MeshBasicMaterialParameters { - /** - * geometry color in hexadecimal. Default is 0xffffff. - */ - color?: number; - opacity?: number; - map?: Texture; - /** - * Default is null. - */ - lightMap?: Texture; - /** - * Default is null. - */ - specularMap?: Texture; - /** - * Default is null. - */ - envMap?: Texture; - combine?: Combine; - reflectivity?: number; - refractionRatio?: number; - /** - * Define shading type. Default is THREE.SmoothShading. - */ - shading?: Shading; - blending?: Blending; - depthTest?: boolean; - /** - * render geometry as wireframe. Default is false. - */ - wireframe?: boolean; - /** - * Line thickness. Default is 1. - */ - wireframeLinewidth?: number; - /** - * Define whether the material uses vertex colors, or not. Default is false. - */ - vertexColors?: Colors; - /** - * Default is false. - */ - skinning?: boolean; - /** - * Default is false. - */ - morphTargets?: boolean; - /** - * Define whether the material color is affected by global fog settings. Default is true. - */ - fog?: boolean; - } - - export class MeshBasicMaterial extends Material { - constructor(parameters?: MeshBasicMaterialParameters); - color: Color; - map: Texture; - lightMap: Texture; - specularMap: Texture; - envMap: Texture; - combine: Combine; - reflectivity: number; - refractionRatio: number; - fog: boolean; - shading: Shading; - wireframe: boolean; - wireframeLinewidth: number; - wireframeLinecap: string; - wireframeLinejoin: string; - vertexColors: Colors; - skinning: boolean; - morphTargets: boolean; - clone(): MeshBasicMaterial; - } - - export interface MeshDepthMaterialParameters { - opacity?: number; - blending?: Blending; - depthTest?: boolean; - wireframe?: boolean; - wireframeLinewidth?: number; - } - - export class MeshDepthMaterial extends Material { - constructor(parameters?: MeshDepthMaterialParameters); - wireframe: boolean; - wireframeLinewidth: number; - clone(): MeshDepthMaterial; - } - - export class MeshFaceMaterial extends Material { - constructor(materials?: Material[]); - materials: Material[]; - clone(): MeshFaceMaterial; - } - - export interface MeshLambertMaterialParameters { - color?: number; - ambient?: number; - emissive?: number; - opacity?: number; - map?: Texture; - lightMap?: Texture; - specularMap?: Texture; - envMap?: Texture; - combine?: Combine; - reflectivity?: number; - refractionRatio?: number; - shading?: Shading; - blending?: Blending; - depthTest?: boolean; - wireframe?: boolean; - wireframeLinewidth?: number; - vertexColors?: Colors; - skinning?: boolean; - morphTargets?: boolean; - morphNormals?: boolean; - fog?: boolean; - } - - export class MeshLambertMaterial extends Material { - constructor(parameters?: MeshLambertMaterialParameters); - color: Color; - ambient: Color; - emissive: Color; - wrapAround: boolean; - wrapRGB: Vector3; - map: Texture; - lightMap: Texture; - specularMap: Texture; - envMap: Texture; - combine: Combine; - reflectivity: number; - refractionRatio: number; - fog: boolean; - shading: Shading; - wireframe: boolean; - wireframeLinewidth: number; - wireframeLinecap: string; - wireframeLinejoin: string; - vertexColors: Colors; - skinning: boolean; - morphTargets: boolean; - morphNormals: boolean; - clone(): MeshLambertMaterial; - } - - export interface MeshNormalMaterialParameters { - opacity?: number; - shading?: Shading; - blending?: Blending; - depthTest?: boolean; - wireframe?: boolean; - wireframeLinewidth?: number; - } - - export class MeshNormalMaterial extends Material { - constructor(parameters?: MeshNormalMaterialParameters); - shading: Shading; - wireframe: boolean; - wireframeLinewidth: number; - clone(): MeshNormalMaterial; - } - - export interface MeshPhongMaterialParameters { - color?: number; - ambient?: number; - emissive?: number; - specular?: number; - shininess?: number; - opacity?: number; - map?: Texture; - lightMap?: Texture; - bumpMap?: Texture; - bumpScale?: number; - normalMap?: Texture; - normalScale?: Vector2; - specularMap?: Texture; - envMap?: Texture; - combine?: Combine; - reflectivity?: number; - refractionRatio?: number; - shading?: Shading; - blending?: Blending; - depthTest?: boolean; - wireframe?: boolean; - wireframeLinewidth?: number; - vertexColors?: Colors; - skinning?: boolean; - morphTargets?: boolean; - morphNormals?: boolean; - fog?: boolean; - } - - export class MeshPhongMaterial extends Material { - constructor(parameters?: MeshPhongMaterialParameters); - color: Color; // diffuse - ambient: Color; - emissive: Color; - specular: Color; - shininess: number; - metal: boolean; - perPixel: boolean; - wrapAround: boolean; - wrapRGB: Vector3; - map: Texture; - lightMap: Texture; - bumpMap: Texture; - bumpScale: number; - normalMap: Texture; - normalScale: Vector2; - specularMap: Texture; - envMap: Texture; - combine: Combine; - reflectivity: number; - refractionRatio: number; - fog: boolean; - shading: Shading; - wireframe: boolean; - wireframeLinewidth: number; - wireframeLinecap: string; - wireframeLinejoin: string; - vertexColors: Colors; - skinning: boolean; - morphTargets: boolean; - morphNormals: boolean; - clone(): MeshPhongMaterial; - } - - export interface ParticleBasicMaterialParameters { - color?: number; - opacity?: number; - map?: Texture; - size?: number; - blending?: Blending; - depthTest?: boolean; - vertexColors?: boolean; - fog?: boolean; - } - - export class ParticleBasicMaterial extends Material { - constructor(parameters?: ParticleBasicMaterialParameters); - color: Color; - map: Texture; - size: number; - sizeAttenuation: boolean; - vertexColors: boolean; - fog: boolean; - clone(): ParticleBasicMaterial; - } - - export interface ParticleCanvasMaterialParameters { - color?: number; - program?: (context: CanvasRenderingContext2D, color: Color) => void; - opacity?: number; - blending?: Blending; - } - - export class ParticleCanvasMaterial extends Material { - constructor(parameters?: ParticleCanvasMaterialParameters); - color: Color; - program: (context: CanvasRenderingContext2D, color: Color) => void; - clone(): ParticleCanvasMaterial; - } - - export class ParticleDOMMaterial extends Material { - constructor(element: HTMLElement); - clone(): ParticleDOMMaterial; - } - - - - - export interface Uniforms { - [name: string]: { type: string; value: any; }; - //[name:string]:{type:UniformType;value:Object;}; - color?: { type: string; value: THREE.Color; }; - } - - export interface ShaderMaterialParameters { - fragmentShader?: string; - vertexShader?: string; - uniforms?: Uniforms; - defines?: { [label: string]: string; }; - shading?: Shading; - blending?: Blending; - depthTest?: boolean; - wireframe?: boolean; - wireframeLinewidth?: number; - lights?: boolean; - vertexColors?: Colors; - skinning?: boolean; - morphTargets?: boolean; - morphNormals?: boolean; - fog?: boolean; - } - - export class ShaderMaterial extends Material { - constructor(parameters?: ShaderMaterialParameters); - fragmentShader: string; - vertexShader: string; - uniforms: Uniforms; - defines: { [label: string]: string; }; - attributes: { [name: string]: Object; }; - shading: Shading; - wireframe: boolean; - wireframeLinewidth: number; - fog: boolean; - lights: boolean; - vertexColors: Colors; - skinning: boolean; - morphTargets: boolean; - morphNormals: boolean; - clone(): ShaderMaterial; - } - - // Objects ////////////////////////////////////////////////////////////////////////////////// - - export class Bone extends Object3D { - constructor(belongsToSkin: SkinnedMesh); - skin: SkinnedMesh; - skinMatrix: Matrix4; - update(parentSkinMatrix?: Matrix4, forceUpdate?: boolean): void; - } - - export class Line extends Object3D { - constructor(geometry?: Geometry, material?: LineDashedMaterial, type?: number); - constructor(geometry?: Geometry, material?: LineBasicMaterial, type?: number); - constructor(geometry?: Geometry, material?: ShaderMaterial, type?: number); - constructor(geometry?: BufferGeometry, material?: LineDashedMaterial, type?: number); - constructor(geometry?: BufferGeometry, material?: LineBasicMaterial, type?: number); - constructor(geometry?: BufferGeometry, material?: ShaderMaterial, type?: number); - geometry: Geometry; - material: Material; - type: LineType; - clone(object?: Line): Line; - } - - enum LineType{} - var LineStrip: LineType; - var LinePieces: LineType; - - export class LOD extends Object3D { - constructor(); - LODs: Object3D[]; - addLevel(object3D: Object3D, visibleAtDistance?: number): void; - update(camera: Camera): void; - clone(): LOD; - } - - export class Mesh extends Object3D { - constructor(geometry?: Geometry, material?: MeshBasicMaterial); - constructor(geometry?: Geometry, material?: MeshDepthMaterial); - constructor(geometry?: Geometry, material?: MeshFaceMaterial); - constructor(geometry?: Geometry, material?: MeshLambertMaterial); - constructor(geometry?: Geometry, material?: MeshNormalMaterial); - constructor(geometry?: Geometry, material?: MeshPhongMaterial); - constructor(geometry?: Geometry, material?: ShaderMaterial); - - constructor(geometry?: BufferGeometry , material?: MeshBasicMaterial); - constructor(geometry?: BufferGeometry , material?: MeshDepthMaterial); - constructor(geometry?: BufferGeometry , material?: MeshFaceMaterial); - constructor(geometry?: BufferGeometry , material?: MeshLambertMaterial); - constructor(geometry?: BufferGeometry , material?: MeshNormalMaterial); - constructor(geometry?: BufferGeometry , material?: MeshPhongMaterial); - constructor(geometry?: BufferGeometry , material?: ShaderMaterial); - - geometry: Geometry; - material: Material; - morphTargetBase: number; - morphTargetForcedOrder: number; - morphTargetInfluences: number[]; - morphTargetDictionary: { [key: string]: number; }; - updateMorphTargets(): void; - getMorphTargetIndexByName(name: string): number; - clone(object?: Mesh): Mesh; - } - - export class MorphAnimMesh extends Mesh { - constructor(geometry?: Geometry, material?: MeshBasicMaterial); - constructor(geometry?: Geometry, material?: MeshDepthMaterial); - constructor(geometry?: Geometry, material?: MeshFaceMaterial); - constructor(geometry?: Geometry, material?: MeshLambertMaterial); - constructor(geometry?: Geometry, material?: MeshNormalMaterial); - constructor(geometry?: Geometry, material?: MeshPhongMaterial); - constructor(geometry?: Geometry, material?: ShaderMaterial); - duration: number; // milliseconds - mirroredLoop: boolean; - time: number; - lastKeyframe: number; - currentKeyframe: number; - direction: number; - directionBackwards: boolean; - setFrameRange(start: number, end: number): void; - setDirectionForward(): void; - setDirectionBackward(): void; - parseAnimations(): void; - setAnimationLabel(label: string, start: number, end: number): void; - playAnimation(label: string, fps: number): void; - updateAnimation(delta: number): void; - clone(object?: MorphAnimMesh): MorphAnimMesh; - } - - export class Particle extends Object3D { - constructor(material: Material); - clone(object?: Particle): Particle; - } - - /** - * A class for displaying particles in the form of variable size points. For example, if using the WebGLRenderer, the particles are displayed using GL_POINTS. - * - * @see src/objects/ParticleSystem.js - */ - export class ParticleSystem extends Object3D { - - /** - * @param geometry An instance of Geometry. - * @param material An instance of Material (optional). - */ - constructor(geometry: Geometry, material?: ParticleBasicMaterial); - constructor(geometry: Geometry, material?: ParticleCanvasMaterial); - constructor(geometry: Geometry, material?: ParticleDOMMaterial); - constructor(geometry: Geometry, material?: ShaderMaterial); - constructor(geometry: BufferGeometry, material?: ParticleBasicMaterial); - constructor(geometry: BufferGeometry, material?: ParticleCanvasMaterial); - constructor(geometry: BufferGeometry, material?: ParticleDOMMaterial); - constructor(geometry: BufferGeometry, material?: ShaderMaterial); - - /** - * An instance of Geometry, where each vertex designates the position of a particle in the system. - */ - geometry: Geometry; - - /** - * An instance of Material, defining the object's appearance. Default is a ParticleBasicMaterial with randomised colour. - */ - material: Material; - - /** - * Specifies whether the particle system will be culled if it's outside the camera's frustum. By default this is set to false. - */ - sortParticles: boolean; - - clone(object?: ParticleSystem): ParticleSystem; - } - - export class Ribbon extends Object3D { - constructor(geometry: Geometry, material: Material); - geometry: Geometry; - material: Material; - clone(object?: Ribbon): Ribbon; - } - - export class SkinnedMesh extends Mesh { - constructor(geometry?: Geometry, material?: MeshBasicMaterial, useVertexTexture?: boolean); - constructor(geometry?: Geometry, material?: MeshDepthMaterial, useVertexTexture?: boolean); - constructor(geometry?: Geometry, material?: MeshFaceMaterial, useVertexTexture?: boolean); - constructor(geometry?: Geometry, material?: MeshLambertMaterial, useVertexTexture?: boolean); - constructor(geometry?: Geometry, material?: MeshNormalMaterial, useVertexTexture?: boolean); - constructor(geometry?: Geometry, material?: MeshPhongMaterial, useVertexTexture?: boolean); - constructor(geometry?: Geometry, material?: ShaderMaterial, useVertexTexture?: boolean); - useVertexTexture: boolean; - identityMatrix: Matrix4; - bones: Bone[]; - boneMatrices: Float32Array; - boneTextureWidth: number; - boneTextureHeight: number; - boneTexture: DataTexture; - addBone(bone?: Bone): Bone; - updateMatrixWorld(force?: boolean): void; - pose(): void; - clone(object?: SkinnedMesh): SkinnedMesh; - static offsetMatrix: Matrix4; - } - - export interface SpriteParameters { - color?: Color; - map?: Texture; - blending?: Blending; - blendSrc?: BlendingSrcFactor; - blendDst?: BlendingDstFactor; - blendEquation?: BlendingEquation; - useScreenCoordinates?: boolean; - mergeWith3D?: boolean; - affectedByDistance?: boolean; - alignment?: Vector2; - fog?: boolean; - uvOffset?: Vector2; - uvScale?: Vector2; - depthTest?: boolean; - sizeAttenuation?: boolean; - scaleByViewport?: boolean; - } - - export class SpriteMaterial extends Material { - constructor(parameters?: SpriteParameters); - color: Color; - map: Texture; - blending: Blending; - blendEquation: BlendingEquation; - useScreenCoordinates: boolean; - scaleByViewport: boolean; - alignment: Vector2; - fog: boolean; - uvOffset: Vector2; - uvScale: Vector2; - depthTest: boolean; - sizeAttenuation: boolean; - clone(): SpriteMaterial; - } - - export class Sprite extends Object3D { - constructor(material?: SpriteMaterial); - updateMatrix(): void; - clone(object?: Sprite): Sprite; - } - export class SpriteAlignment { - static topLeft: Vector2; - static topCenter: Vector2; - static topRight: Vector2; - static centerLeft: Vector2; - static center: Vector2; - static centerRight: Vector2; - static bottomLeft: Vector2; - static bottomCenter: Vector2; - static bottomRight: Vector2; - } - - // Renderers ////////////////////////////////////////////////////////////////////////////////// - - export interface Renderer { - render(scene: Scene, camera: Camera): void; - } - - export interface CanvasRendererParameters { - canvas?: HTMLCanvasElement; - devicePixelRatio?: number; - } - - export class CanvasRenderer implements Renderer { - constructor(parameters?: CanvasRendererParameters); - domElement: HTMLCanvasElement; - autoClear: boolean; - sortObjects: boolean; - sortElements: boolean; - devicePixelRatio: number; - info: { render: { vertices: number; faces: number; }; }; - setSize(width: number, height: number): void; - setClearColor(color: Color, opacity?: number): void; - setClearColorHex(hex: number, opacity?: number): void; - getMaxAnisotropy(): number; - clear(): void; - render(scene: Scene, camera: Camera): void; - } - - export interface ShaderChunk { - [name: string]: string; - fog_pars_fragment: string; - fog_fragment: string; - envmap_pars_fragment: string; - envmap_fragment: string; - envmap_pars_vertex: string; - worldpos_vertex: string; - envmap_vertex: string; - map_particle_pars_fragment: string; - map_particle_fragment: string; - map_pars_vertex: string; - map_pars_fragment: string; - map_vertex: string; - map_fragment: string; - lightmap_pars_fragment: string; - lightmap_pars_vertex: string; - lightmap_fragment: string; - lightmap_vertex: string; - bumpmap_pars_fragment: string; - normalmap_pars_fragment: string; - specularmap_pars_fragment: string; - specularmap_fragment: string; - lights_lambert_pars_vertex: string; - lights_lambert_vertex: string; - lights_phong_pars_vertex: string; - lights_phong_vertex: string; - lights_phong_pars_fragment: string; - lights_phong_fragment: string; - color_pars_fragment: string; - color_fragment: string; - color_pars_vertex: string; - color_vertex: string; - skinning_pars_vertex: string; - skinbase_vertex: string; - skinning_vertex: string; - morphtarget_pars_vertex: string; - morphtarget_vertex: string; - default_vertex: string; - morphnormal_vertex: string; - skinnormal_vertex: string; - defaultnormal_vertex: string; - shadowmap_pars_fragment: string; - shadowmap_fragment: string; - shadowmap_pars_vertex: string; - shadowmap_vertex: string; - alphatest_fragment: string; - linear_to_gamma_fragment: string; - } - - export var ShaderChunk: ShaderChunk; - - export interface RendererPlugin { - init(renderer: WebGLRenderer): void; - render(scene: Scene, camera: Camera, currentWidth: number, currentHeight: number): void; - } - - export interface WebGLRendererParameters { - /** - * A Canvas where the renderer draws its output. - */ - canvas?: HTMLCanvasElement; - - /** - * shader precision. Can be "highp", "mediump" or "lowp". - */ - precision?: string; - - /** - * default is true. - */ - alpha?: boolean; - - /** - * default is true. - */ - premultipliedAlpha?: boolean; - - /** - * default is false. - */ - antialias?: boolean; - - /** - * default is true. - */ - stencil?: boolean; - - /** - * default is false. - */ - preserveDrawingBuffer?: boolean; - - /** - * default is 0x000000. - */ - clearColor?: number; - - /** - * default is 0. - */ - clearAlpha?: number; - - devicePixelRatio?: number; - } - - - /** - * The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it. - * This renderer has way better performance than CanvasRenderer. - * - * @see src/renderers/WebGLRenderer.js - */ - export class WebGLRenderer implements Renderer { - /** - * parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing. - */ - constructor(parameters?: WebGLRendererParameters); - - /** - * A Canvas where the renderer draws its output. - * This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page. - */ - domElement: HTMLCanvasElement; - - /** - * The HTML5 Canvas's 'webgl' context obtained from the canvas where the renderer will draw. - */ - // If you are using three.d.ts with other complete definitions of webgl, context:WebGLRenderingContext is suitable. - //context:WebGLRenderingContext; - context: any; - - /** - * Defines whether the renderer should automatically clear its output before rendering. - */ - autoClear: boolean; - - /** - * If autoClear is true, defines whether the renderer should clear the color buffer. Default is true. - */ - autoClearColor: boolean; - - /** - * If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true. - */ - autoClearDepth: boolean; - - /** - * If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true. - */ - autoClearStencil: boolean; - - /** - * Defines whether the renderer should sort objects. Default is true. - */ - sortObjects: boolean; - - /** - * Defines whether the renderer should auto update objects. Default is true. - */ - autoUpdateObjects: boolean; - - /** - * Defines whether the renderer should auto update the scene. Default is true. - */ - autoUpdateScene: boolean; - - /** - * Default is false. - */ - gammaInput: boolean; - - /** - * Default is false. - */ - gammaOutput: boolean; - - /** - * Default is false. - */ - physicallyBasedShading: boolean; - - /** - * Default is false. - */ - shadowMapEnabled: boolean; - - /** - * Default is true. - */ - shadowMapAutoUpdate: boolean; - - /** - * Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader) - * Options are THREE.BasicShadowMap, THREE.PCFShadowMap, THREE.PCFSoftShadowMap. Default is THREE.PCFShadowMap. - */ - shadowMapType: ShadowMapType; - - shadowMapSoft: boolean; - - /** - * Default is true - */ - shadowMapCullFace: CullFace; - - /** - * Default is false. - */ - shadowMapDebug: boolean; - - /** - * Default is false. - */ - shadowMapCascade: boolean; - - /** - * Default is 8. - */ - maxMorphTargets: number; - - /** - * Default is 4. - */ - maxMorphNormals: number; - - /** - * Default is true. - */ - autoScaleCubemaps: boolean; - - /** - * An array with render plugins to be applied before rendering. - * Default is an empty array, or []. - */ - renderPluginsPre: RendererPlugin[]; - - /** - * An array with render plugins to be applied after rendering. - * Default is an empty array, or []. - */ - renderPluginsPost: RendererPlugin[]; - - devicePixelRatio: number; - - /** - * An object with a series of statistical information about the graphics board memory and the rendering process. Useful for debugging or just for the sake of curiosity. The object contains the following fields: - */ - info: { - memory: { - programs: number; - geometries: number; - textures: number; - }; - render: { - calls: number; - vertices: number; - faces: number; - points: number; - }; - }; - - /** - * Return the WebGL context. - */ - getContext(): WebGLRenderingContext; - - /** - * Return a Boolean true if the context supports vertex textures. - */ - supportsVertexTextures(): boolean; - - getMaxAnisotropy(): number; - - /** - * Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0). - */ - setSize(width: number, height: number): void; - - /** - * Sets the viewport to render from (x, y) to (x + width, y + height). - */ - setViewport(x?: number, y?: number, width?: number, height?: number): void; - - /** - * Sets the scissor area from (x, y) to (x + width, y + height). - */ - setScissor(x: number, y: number, width: number, height: number): void; - - /** - * Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions. - */ - enableScissorTest(enable: boolean): void; - - /** - * Sets the clear color, using hex for the color and alpha for the opacity. - * - * @example - * // Creates a renderer with black background - * var renderer = new THREE.WebGLRenderer(); - * renderer.setSize(200, 100); - * renderer.setClearColorHex(0x000000, 1); - */ - setClearColorHex(hex: number, alpha: number): void; - - /** - * Sets the clear color, using color for the color and alpha for the opacity. - */ - setClearColor(color: Color, alpha: number): void; - - /** - * Returns a THREE.Color instance with the current clear color. - */ - getClearColor(): Color; - - /** - * Returns a float with the current clear alpha. Ranges from 0 to 1. - */ - getClearAlpha(): number; - - /** - * Tells the renderer to clear its color, depth or stencil drawing buffer(s). - * If no parameters are passed, no buffer will be cleared. - */ - clear(color?: boolean, depth?: boolean, stencil?: boolean): void; - - /** - * Initialises the postprocessing plugin, and adds it to the renderPluginsPost array. - */ - addPostPlugin(plugin: RendererPlugin): void; - - /** - * Initialises the preprocessing plugin, and adds it to the renderPluginsPre array. - */ - addPrePlugin(plugin: RendererPlugin): void; - - deallocateObject(object: Object3D): void; - - deallocateTexture(texture: Texture): void; - - deallocateRenderTarget(renderTarget: RenderTarget): void; - - /** - * Tells the shadow map plugin to update using the passed scene and camera parameters. - * - * @param scene an instance of Scene - * @param camera — an instance of Camera - */ - updateShadowMap(scene: Scene, camera: Camera): void; - - renderBufferImmediate(object: Object3D, program: Object, material: Material): void; - - renderBufferDirect(camera: Camera, lights: Light[], fog: Fog, material: Material, geometryGroup: any, object: Object3D): void; - - renderBuffer(camera: Camera, lights: Light[], fog: Fog, material: Material, geometryGroup: any, object: Object3D): void; - - /** - * Render a scene using a camera. - * The render is done to the renderTarget (if specified) or to the canvas as usual. - * If forceClear is true, the canvas will be cleared before rendering, even if the renderer's autoClear property is false. - */ - render(scene: Scene, camera: Camera, renderTarget?: RenderTarget, forceClear?: boolean): void; - renderImmediateObject(camera: Camera, lights: Light[], fog: Fog, material: Material, object: Object3D): void; - initWebGLObjects(scene: Scene): void; - initMaterial(material: Material, lights: Light[], fog: Fog, object: Object3D): void; - - /** - * Used for setting the gl frontFace, cullFace states in the GPU, thus enabling/disabling face culling when rendering. - * If cullFace is false, culling will be disabled. - * @param cullFace "back", "front", "front_and_back", or false. - * @param frontFace "ccw" or "cw - */ - setFaceCulling(cullFace?: string, frontFace?: FrontFaceDirection): void; - setMaterialFaces(material: Material): void; - setDepthTest(depthTest: boolean): void; - setDepthWrite(depthWrite: boolean): void; - setBlending(blending: Blending, blendEquation: BlendingEquation, blendSrc: BlendingSrcFactor, blendDst: BlendingDstFactor): void; - setTexture(texture: Texture, slot: number): void; - setRenderTarget(renderTarget: RenderTarget): void; - } - - export class WebGLRenderer2 implements Renderer { - constructor(parameters?: WebGLRendererParameters); - domElement: HTMLCanvasElement; - context: WebGLRenderingContext; - autoClear: boolean; - autoClearColor: boolean; - autoClearDepth: boolean; - autoClearStencil: boolean; - sortObjects: boolean; - autoUpdateObjects: boolean; - autoUpdateScene: boolean; - gammaInput: boolean; - gammaOutput: boolean; - physicallyBasedShading: boolean; - shadowMapEnabled: boolean; - shadowMapAutoUpdate: boolean; - shadowMapType: ShadowMapType; - shadowMapSoft: boolean; - shadowMapCullFace: CullFace; - shadowMapDebug: boolean; - shadowMapCascade: boolean; - maxMorphTargets: number; - maxMorphNormals: number; - autoScaleCubemaps: boolean; - renderPluginsPre: RendererPlugin[]; - renderPluginsPost: RendererPlugin[]; - devicePixelRatio: number; - info: { - memory: { - programs: number; - geometries: number; - textures: number; - }; - render: { - calls: number; - vertices: number; - faces: number; - points: number; - }; - }; - getContext(): WebGLRenderingContext; - supportsVertexTextures(): boolean; - getMaxAnisotropy(): number; - setSize(width: number, height: number): void; - setViewport(x?: number, y?: number, width?: number, height?: number): void; - setScissor(x: number, y: number, width: number, height: number): void; - enableScissorTest(enable: boolean): void; - setClearColorHex(hex: number, alpha: number): void; - setClearColor(color: Color, alpha: number): void; - getClearColor(): Color; - getClearAlpha(): number; - clear(color?: boolean, depth?: boolean, stencil?: boolean): void; - addPostPlugin(plugin: RendererPlugin): void; - addPrePlugin(plugin: RendererPlugin): void; - deallocateObject(object: Object3D): void; - deallocateTexture(texture: Texture): void; - deallocateRenderTarget(renderTarget: RenderTarget): void; - updateShadowMap(scene: Scene, camera: Camera): void; - renderBufferImmediate(object: Object3D, program: Object, material: Material): void; - renderBufferDirect(camera: Camera, lights: Light[], fog: Fog, material: Material, geometryGroup: any, object: Object3D): void; - renderBuffer(camera: Camera, lights: Light[], fog: Fog, material: Material, geometryGroup: any, object: Object3D): void; - render(scene: Scene, camera: Camera, renderTarget?: RenderTarget, forceClear?: boolean): void; - renderImmediateObject(camera: Camera, lights: Light[], fog: Fog, material: Material, object: Object3D): void; - initWebGLObjects(scene: Scene): void; - initMaterial(material: Material, lights: Light[], fog: Fog, object: Object3D): void; - setFaceCulling(cullFace?: string, frontFace?: FrontFaceDirection): void; - setMaterialFaces(material: Material): void; - setDepthTest(depthTest: boolean): void; - setDepthWrite(depthWrite: boolean): void; - setBlending(blending: Blending, blendEquation: BlendingEquation, blendSrc: BlendingSrcFactor, blendDst: BlendingDstFactor): void; - setTexture(texture: Texture, slot: number): void; - setRenderTarget(renderTarget: RenderTarget): void; - } - - export interface RenderTarget { - } - - export interface WebGLRenderTargetOptions { - wrapS?: Wrapping; - wrapT?: Wrapping; - magFilter?: TextureFilter; - minFilter?: TextureFilter; - anisotropy?: number; // 1; - format?: number; // RGBAFormat; - type?: TextureDataType; // UnsignedByteType; - depthBuffer?: boolean; // true; - stencilBuffer?: boolean; // true; - } - - export class WebGLRenderTarget implements RenderTarget { - constructor(width: number, height: number, options?: WebGLRenderTargetOptions); - width: number; - height: number; - wrapS: Wrapping; - wrapT: Wrapping; - magFilter: TextureFilter; - minFilter: TextureFilter; - anisotropy: number; - offset: Vector2; - repeat: Vector2; - format: number; - type: number; - depthBuffer: boolean; - stencilBuffer: boolean; - generateMipmaps: boolean; - clone(): WebGLRenderTarget; - dispose(): void; - } - - export class WebGLRenderTargetCube extends WebGLRenderTarget { - constructor(width: number, height: number, options?: WebGLRenderTargetOptions); - activeCubeFace: number; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5 - } - - // Renderers / Renderables ///////////////////////////////////////////////////////////////////// - - export class RenderableFace3 { - constructor(); - v1: RenderableVertex; - v2: RenderableVertex; - v3: RenderableVertex; - centroidWorld: Vector3; - centroidScreen: Vector3; - normalWorld: Vector3; - vertexNormalsWorld: Vector3[]; - vertexNormalsLength: number; - color: number; - material: Material; - uvs: Vector2[][]; - z: number; - } - - export class RenderableFace4 { - constructor(); - v1: RenderableVertex; - v2: RenderableVertex; - v3: RenderableVertex; - v4: RenderableVertex; - centroidWorld: Vector3; - centroidScreen: Vector3; - normalWorld: Vector3; - vertexNormalsWorld: Vector3[]; - vertexNormalsLength: number; - color: number; - material: Material; - uvs: Vector2[][]; - z: number; - } - - export class RenderableLine { - constructor(); - z: number; - v1: RenderableVertex; - v2: RenderableVertex; - material: Material; - } - - export class RenderableObject { - constructor(); - object: Object; - z: number; - } - - export class RenderableParticle { - constructor(); - object: Object; - x: number; - y: number; - z: number; - rotation: number; - scale: Vector2; - material: Material; - } - - export class RenderableVertex { - constructor(); - positionWorld: Vector3; - positionScreen: Vector4; - visible: boolean; - copy(vertex: RenderableVertex): void; - } - - // Scenes ///////////////////////////////////////////////////////////////////// - - export interface IFog { - name:string; - color: Color; - clone():IFog; - } - - - /** - * This class contains the parameters that define linear fog, i.e., that grows linearly denser with the distance. - */ - export class Fog implements IFog { - constructor(hex: number, near?: number, far?: number); - name:string; - - /** - * Fog color. - */ - color: Color; - - /** - * The minimum distance to start applying fog. Objects that are less than 'near' units from the active camera won't be affected by fog. - */ - near: number; - - /** - * The maximum distance at which fog stops being calculated and applied. Objects that are more than 'far' units away from the active camera won't be affected by fog. - * Default is 1000. - */ - far: number; - - clone(): Fog; - } - - /** - * This class contains the parameters that define linear fog, i.e., that grows exponentially denser with the distance. - */ - export class FogExp2 implements IFog { - constructor(hex: number, density?: number); - name: string; - color: Color; - - /** - * Defines how fast the fog will grow dense. - * Default is 0.00025. - */ - density: number; - - clone(): FogExp2; - } - - /** - * Scenes allow you to set up what and where is to be rendered by three.js. This is where you place objects, lights and cameras. - */ - export class Scene extends Object3D { - - /** - * A fog instance defining the type of fog that affects everything rendered in the scene. Default is null. - */ - fog: IFog; - - /** - * If not null, it will force everything in the scene to be rendered with that material. Default is null. - */ - overrideMaterial: Material; - - /** - * Default is false. - */ - matrixAutoUpdate: boolean; - - constructor(); - } - - // Textures ///////////////////////////////////////////////////////////////////// - - export class Texture { - constructor( - image: HTMLImageElement, - mapping?: Mapping, - wrapS?: Wrapping, - wrapT?: Wrapping, - magFilter?: TextureFilter, - minFilter?: TextureFilter, - format?: PixelFormat, - type?: TextureDataType, - anisotropy?: number - ); - constructor( - image: HTMLCanvasElement, - mapping?: Mapping, - wrapS?: Wrapping, - wrapT?: Wrapping, - magFilter?: TextureFilter, - minFilter?: TextureFilter, - format?: PixelFormat, - type?: TextureDataType, - anisotropy?: number - ); - id: number; - name: string; - image: Object; // HTMLImageElement or ImageData ; - mapping: Mapping; - wrapS: Wrapping; - wrapT: Wrapping; - magFilter: TextureFilter; - minFilter: TextureFilter; - anisotropy: number; - format: PixelFormat; - type: TextureDataType; - offset: Vector2; - repeat: Vector2; - generateMipmaps: boolean; - premultiplyAlpha: boolean; - flipY: boolean; - needsUpdate: boolean; - onUpdate: () => void; - clone(): Texture; - dispose(): void; - } - var TextureIdCount: number; - var TextureLibrary: Texture[]; - - - export class CompressedTexture extends Texture { - constructor(mipmaps: ImageData[], width: number, height: number, format?: PixelFormat, type?: TextureDataType, mapping?: Mapping, wrapS?: Wrapping, wrapT?: Wrapping, magFilter?: TextureFilter, minFilter?: TextureFilter); - mipmaps: ImageData[]; - clone(): CompressedTexture; - } - - export class DataTexture extends Texture { - constructor(data: ImageData, width: number, height: number, format: PixelFormat, type: TextureDataType, mapping: Mapping, wrapS: Wrapping, wrapT: Wrapping, magFilter: TextureFilter, minFilter: TextureFilter); - clone(): DataTexture; - } - - // Extras ///////////////////////////////////////////////////////////////////// - - export interface TypefaceData { - familyName: string; - cssFontWeight: string; - cssFontStyle: string; - } - - export var FontUtils: { - faces: { [weight: string]: { [style: string]: Face; }; }; - face: string; - weight: string; - style: string; - size: number; - divisions: number; - getFace(): Face; - loadFace(data: TypefaceData): TypefaceData; - drawText(text: string): { paths: Path[]; offset: number; }; - extractGlyphPoints(c: string, face: Face, scale: number, offset: number, path: Path): { offset: number; path: Path; }; - generateShapes(text: string, parameters?: { size?: number; curveSegments?: number; font?: string; weight?: string; style?: string; }): Shape[]; - Triangulate: { - (contour: Vector2[], indices: boolean): Vector2[]; - area(contour: Vector2[]): number; - }; - }; - - export var GeometryUtils: { - merge(geometry1: Geometry, object2: Mesh): void; - merge(geometry1: Geometry, object2: Geometry): void; - removeMaterials(geometry: Geometry, materialIndexArray: number[]): void; - randomPointInTriangle(vectorA: Vector3, vectorB: Vector3, vectorC: Vector3): Vector3; - randomPointInFace(face: Face, geometry: Geometry, useCachedAreas: boolean): Vector3; - randomPointsInGeometry(geometry: Geometry, n: number): Vector3; - triangleArea(vectorA: Vector3, vectorB: Vector3, vectorC: Vector3): number; - center(geometry: Geometry): Vector3; - normalizeUVs(geometry: Geometry): void; - triangulateQuads(geometry: Geometry): void; - setMaterialIndex(geometry: Geometry, index: number, startFace?: number, endFace?: number); - }; - - export var ImageUtils: { - crossOrigin: string; - loadTexture(url: string, mapping?: Mapping, onLoad?: (texture: Texture) => void , onError?: (message: string) => void ): Texture; - loadCompressedTexture(url: string, mapping?: Mapping, onLoad?: (texture: Texture) => void , onError?: (message: string) => void ): Texture; - loadTextureCube(array: string[], mapping?: Mapping, onLoad?: () => void , onError?: (message: string) => void ): Texture; - loadCompressedTextureCube(array: string[], mapping?: Mapping, onLoad?: () => void , onError?: (message: string) => void ): Texture; - parseDDS(buffer: ArrayBuffer, loadMipmaps: boolean): { mipmaps: { data: Uint8Array; width: number; height: number; }[]; width: number; height: number; format: number; mipmapCount: number; }; - getNormalMap(image: HTMLImageElement, depth?: number): HTMLCanvasElement; - generateDataTexture(width: number, height: number, color: Color): DataTexture; - }; - - export var SceneUtils: { - createMultiMaterialObject(geometry: Geometry, materials: Material[]): Object3D; - detach(child: Object3D, parent: Object3D, scene: Scene): void; - attach(child: Object3D, scene: Scene, parent: Object3D): void; - }; - - // Extras / Animation ///////////////////////////////////////////////////////////////////// - - export interface KeyFrame { - pos: number[]; - rot: number[]; - scl: number[]; - time: number; - } - - export interface KeyFrames { - keys: KeyFrame[]; - parent: number; - } - - export interface AnimationData { - JIT: number; - fps: number; - hierarchy: KeyFrames[]; - length: number; - name: string; - } - - export class Animation { - constructor(root: Mesh, name: string, interpolationType?: AnimationInterpolation); - - interpolateCatmullRom(points: Vector3[], scale: number): Vector3[]; - interpolate(p0: number, p1: number, p2: number, p3: number, t: number, t2: number, t3: number): number; - - root: Mesh; - data: AnimationData; - hierarchy: Bone[]; - currentTime: number; - timeScale: number; - isPlaying: boolean; - isPaused: boolean; - loop: boolean; - interpolationType: AnimationInterpolation; - points: Vector3[]; - target: Vector3; - play(loop?: boolean, startTimeMS?: number): void; - pause(): void; - stop(): void; - update(deltaTimeMS: number): void; - - getNextKeyWith(type: string, h: number, key: number): KeyFrame; // ???? - getPrevKeyWith(type: string, h: number, key: number): KeyFrame; - - JITCompile: boolean; // https://github.com/mrdoob/three.js/blob/master/examples/webgl_animation_skinning_morph.html#L251 - } - - export class AnimationInterpolation { } - - export var AnimationHandler: { - update(deltaTimeMS: number): void; - addToUpdate(animation: Animation): void; - removeFromUpdate(animation: Animation): void; - add(data: AnimationData): void; - get (name: string): AnimationData; - parse(root: SkinnedMesh): Object3D[]; - - LINEAR: AnimationInterpolation; - CATMULLROM: AnimationInterpolation; - CATMULLROM_FORWARD: AnimationInterpolation; - }; - - export class AnimationMorphTarget { - constructor(root: Bone, data: any); - influence: number; - - root: Bone; - data: Object; - hierarchy: KeyFrames[]; - currentTime: number; - timeScale: number; - isPlaying: boolean; - isPaused: boolean; - loop: boolean; - play(loop?: boolean, startTimeMS?: number): void; - pause(): void; - stop(): void; - update(deltaTimeMS: number): void; - } - - export class KeyFrameAnimation { - constructor(root: Mesh, data: any, JITCompile?: boolean); - JITCompile: number; - - root: Mesh; - data: Object; - hierarchy: KeyFrames[]; - currentTime: number; - timeScale: number; - isPlaying: number; - isPaused: number; - loop: number; - play(loop?: number, startTimeMS?: number): void; - pause(): void; - stop(): void; - update(deltaTimeMS: number): void; - - getNextKeyWith(type: string, h: number, key: number): KeyFrame; // ???? - getPrevKeyWith(type: string, h: number, key: number): KeyFrame; - } - - // Extras / Cameras ///////////////////////////////////////////////////////////////////// - - export class CombinedCamera extends Camera { - constructor(width: number, height: number, fov: number, near: number, far: number, orthoNear: number, orthoFar: number); - fov: number; - left: number; - right: number; - top: number; - bottom: number; - cameraO: OrthographicCamera; - cameraP: PerspectiveCamera; - zoom: number; - near: number; - far: number; - inPerspectiveMode: boolean; - inOrthographicMode: boolean; - toPerspective(): void; - toOrthographic(): void; - setSize(width: number, height: number): void; - setFov(fov: number): void; - updateProjectionMatrix(): void; - setLens(focalLength: number, frameHeight?: number): number; - setZoom(zoom: number): void; - toFrontView(): void; - toBackView(): void; - toLeftView(): void; - toRightView(): void; - toTopView(): void; - toBottomView(): void; - } - - export class CubeCamera extends Object3D { - constructor(near: number, far: number, cubeResolution: number); - renderTarget: WebGLRenderTargetCube; - updateCubeMap(renderer: Renderer, scene: Scene): void; - } - - // Extras / Core ///////////////////////////////////////////////////////////////////// - - /** - * An extensible curve object which contains methods for interpolation - * class Curve<T extends Vector> - */ - export class Curve { - constructor(); - - /** - * Returns a vector for point t of the curve where t is between 0 and 1 - * getPoint(t: number): T; - */ - getPoint(t: number): Vector; - - /** - * Returns a vector for point at relative position in curve according to arc length - * getPointAt(u: number): T; - */ - getPointAt(u: number): Vector; - - /** - * Get sequence of points using getPoint( t ) - * getPoints(divisions?: number): T[]; - */ - getPoints(divisions?: number): Vector[]; - - /** - * Get sequence of equi-spaced points using getPointAt( u ) - * getSpacedPoints(divisions?: number): T[]; - */ - getSpacedPoints(divisions?: number): Vector[]; - - /** - * Get total curve arc length - */ - getLength(): number; - - /** - * Get list of cumulative segment lengths - */ - getLengths(divisions?: number): number[]; - - needsUpdate: boolean; - - /** - * Update the cumlative segment distance cache - */ - updateArcLengths(): void; - - /** - * Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance - */ - getUtoTmapping(u: number, distance: number): number; - - /** - * getNormalVector(t: number): T; - */ - getNormalVector(t: number): Vector; - - /** - * Returns a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation - * getTangent(t: number): T; - */ - getTangent(t: number): Vector; - - /** - * Returns tangent at equidistance point u on the curve - * getTangentAt(u: number): T; - */ - getTangentAt(u: number): Vector; - - static Utils: { - tangentQuadraticBezier(t: number, p0: number, p1: number, p2: number): number; - tangentCubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number; - tangentSpline(t: number, p0: number, p1: number, p2: number, p3: number): number; - interpolate(p0: number, p1: number, p2: number, p3: number, t: number): number; - }; - - static create(constructorFunc: Function, getPointFunc: Function): Function; - } - - /** - * class LineCurve extends Curve - */ - export class LineCurve extends Curve { - constructor(v1: Vector2, v2: Vector2); - getPoint(t: number): Vector2; - getPointAt(u: number): Vector2; - getPoints(divisions?: number): Vector2[]; - getSpacedPoints(divisions?: number): Vector2[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector2; - getTangent(t: number): Vector2; - getTangentAt(u: number): Vector2; - } - - /** - * class QuadraticBezierCurve extends Curve - */ - export class QuadraticBezierCurve extends Curve { - constructor(v0: Vector2, v1: Vector2, v2: Vector2); - getPoint(t: number): Vector2; - getPointAt(u: number): Vector2; - getPoints(divisions?: number): Vector2[]; - getSpacedPoints(divisions?: number): Vector2[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector2; - getTangent(t: number): Vector2; - getTangentAt(u: number): Vector2; - } - /** - * class CubicBezierCurve extends Curve - */ - export class CubicBezierCurve extends Curve { - constructor(v0: number, v1: number, v2: number, v3: number); - getPoint(t: number): Vector2; - getPointAt(u: number): Vector2; - getPoints(divisions?: number): Vector2[]; - getSpacedPoints(divisions?: number): Vector2[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector2; - getTangent(t: number): Vector2; - getTangentAt(u: number): Vector2; - } - /** - * class SplineCurve extends Curve - */ - export class SplineCurve extends Curve { - constructor(points?: Vector2[]); - getPoint(t: number): Vector2; - getPointAt(u: number): Vector2; - getPoints(divisions?: number): Vector2[]; - getSpacedPoints(divisions?: number): Vector2[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector2; - getTangent(t: number): Vector2; - getTangentAt(u: number): Vector2; - } - /** - * class EllipseCurve extends Curve - */ - export class EllipseCurve extends Curve { - constructor(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean); - aX: number; - aY: number; - xRadius: number; - yRadius: number; - aStartAngle: number; - aEndAngle: number; - aClockwise: boolean; - - getPoint(t: number): Vector2; - getPointAt(u: number): Vector2; - getPoints(divisions?: number): Vector2[]; - getSpacedPoints(divisions?: number): Vector2[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector2; - getTangent(t: number): Vector2; - getTangentAt(u: number): Vector2; - } - /** - * class ArcCurve extends EllipseCurve - */ - export class ArcCurve extends EllipseCurve { - constructor(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean); - getPoint(t: number): Vector2; - getPointAt(u: number): Vector2; - getPoints(divisions?: number): Vector2[]; - getSpacedPoints(divisions?: number): Vector2[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector2; - getTangent(t: number): Vector2; - getTangentAt(u: number): Vector2; - } - - /** - * class LineCurve3 extends Curve - */ - export class LineCurve3 extends Curve { - constructor(v1: Vector3, v2: Vector3); - getPoint(t: number): Vector3; - getPointAt(u: number): Vector3; - getPoints(divisions?: number): Vector3[]; - getSpacedPoints(divisions?: number): Vector3[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector3; - getTangent(t: number): Vector3; - getTangentAt(u: number): Vector3; - } - - /** - * class QuadraticBezierCurve3 extends Curve - */ - export class QuadraticBezierCurve3 extends Curve { - constructor(v0: Vector3, v1: Vector3, v2: Vector3); - getPoint(t: number): Vector3; - getPointAt(u: number): Vector3; - getPoints(divisions?: number): Vector3[]; - getSpacedPoints(divisions?: number): Vector3[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector3; - getTangent(t: number): Vector3; - getTangentAt(u: number): Vector3; - } - - /** - * class CubicBezierCurve3 extends Curve - */ - export class CubicBezierCurve3 extends Curve { - constructor(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3); - getPoint(t: number): Vector3; - getPointAt(u: number): Vector3; - getPoints(divisions?: number): Vector3[]; - getSpacedPoints(divisions?: number): Vector3[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector3; - getTangent(t: number): Vector3; - getTangentAt(u: number): Vector3; - } - - /** - * class SplineCurve3 extends Curve - */ - export class SplineCurve3 extends Curve { - constructor(points?: Vector3[]); - points: Vector3[]; - getPoint(t: number): Vector3; - getPointAt(u: number): Vector3; - getPoints(divisions?: number): Vector3[]; - getSpacedPoints(divisions?: number): Vector3[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector3; - getTangent(t: number): Vector3; - getTangentAt(u: number): Vector3; - } - - /** - * class ClosedSplineCurve3 extends Curve - */ - export class ClosedSplineCurve3 extends Curve { - constructor(points?: Vector3[]); - points: Vector3[]; - getPoint(t: number): Vector3; - getPointAt(u: number): Vector3; - getPoints(divisions?: number): Vector3[]; - getSpacedPoints(divisions?: number): Vector3[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector3; - getTangent(t: number): Vector3; - getTangentAt(u: number): Vector3; - } - - export interface BoundingBox { - minX: number; - minY: number; - maxX: number; - maxY: number; - centroid: Vector; - } - - export class CurvePath extends Curve { - constructor(); - curves: Curve[]; - bends: Path[]; - autoClose: boolean; - add(curve: Curve): void; - checkConnection(): boolean; - closePath(): void; - getBoundingBox(): BoundingBox; - createPointsGeometry(divisions: number): Geometry; - createSpacedPointsGeometry(divisions: number): Geometry; - createGeometry(points: Vector2[]): Geometry; - addWrapPath(bendpath: Path): void; - getTransformedPoints(segments: number, bends?: Path): Vector2[]; - getTransformedSpacedPoints(segments: number, bends?: Path[]): Vector2[]; - getWrapPoints(oldPts: Vector2[], path: Path): Vector2[]; - } - - export enum PathActions { - MOVE_TO, - LINE_TO, - QUADRATIC_CURVE_TO, // Bezier quadratic curve - BEZIER_CURVE_TO, // Bezier cubic curve - CSPLINE_THRU, // Catmull-rom spline - ARC, // Circle - ELLIPSE, - } - - /** - * a 2d path representation, comprising of points, lines, and cubes, similar to the html5 2d canvas api. It extends CurvePath. - */ - export class Path extends CurvePath { - constructor(points?: Vector2); - actions: PathActions[]; - fromPoints(vectors: Vector2[]): void; - moveTo(x: number, y: number): void; - lineTo(x: number, y: number): void; - quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): void; - bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): void; - splineThru(pts: Vector2[]): void; - arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - ellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - absellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - toShapes(): Shape[]; - } - - export class Gyroscope extends Object3D { - constructor(); - updateMatrixWorld(force?: boolean): void; - translationWorld: Vector3; - translationObject: Vector3; - rotationWorld: Quaternion; - rotationObject: Quaternion; - scaleWorld: Vector3; - scaleObject: Vector3; - } - - /** - * Defines a 2d shape plane using paths. - */ - export class Shape /* extends Path */ implements Path { - constructor(points?: Vector2[]); - holes: Path[]; - extrude(options?: any): ExtrudeGeometry; - makeGeometry(options?: any): ShapeGeometry; - getPointsHoles(divisions: number): Vector2[][]; - getSpacedPointsHoles(divisions: number): Vector2[][]; - extractAllPoints(divisions: number): { - shape: Vector2[]; - holes: Vector2[][]; - }; - useSpacedPoints: boolean; - extractPoints(divisions: number): Vector2[]; - extractAllSpacedPoints(divisions: Vector2): { - shape: Vector2[]; - holes: Vector2[][]; - }; - - static Utils: { - removeHoles(contour: Vector2[], holes: Vector2[][]): { - shape: Shape; - isolatedPts: Vector2[]; - allpoints: Vector2[]; - }; - triangulateShape(contour: Vector2[], holes: Vector2[][]): Vector2[]; - isClockWise(pts: Vector2[]): boolean; - b2p0(t: number, p: number): number; - b2p1(t: number, p: number): number; - b2p2(t: number, p: number): number; - b2(t: number, p0: number, p1: number, p2: number): number; - b3p0(t: number, p: number): number; - b3p1(t: number, p: number): number; - b3p2(t: number, p: number): number; - b3p3(t: number, p: number): number; - b3(t: number, p0: number, p1: number, p2: number, p3: number): number; - }; - - // trick for TypeScript 0.9.5 compile passed - // from Path - actions: PathActions[]; - fromPoints(vectors: Vector2[]): void; - moveTo(x: number, y: number): void; - lineTo(x: number, y: number): void; - quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): void; - bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): void; - splineThru(pts: Vector2[]): void; - arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - ellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - absellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - toShapes(): Shape[]; - // from CurvePath - curves: Curve[]; - bends: Path[]; - autoClose: boolean; - add(curve: Curve): void; - checkConnection(): boolean; - closePath(): void; - getBoundingBox(): BoundingBox; - createPointsGeometry(divisions: number): Geometry; - createSpacedPointsGeometry(divisions: number): Geometry; - createGeometry(points: Vector2[]): Geometry; - addWrapPath(bendpath: Path): void; - getTransformedPoints(segments: number, bends?: Path): Vector2[]; - getTransformedSpacedPoints(segments: number, bends?: Path[]): Vector2[]; - getWrapPoints(oldPts: Vector2[], path: Path): Vector2[]; - getPoint(t: number): Vector; - getPointAt(u: number): Vector; - getPoints(divisions?: number): Vector[]; - getSpacedPoints(divisions?: number): Vector[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector; - getTangent(t: number): Vector; - getTangentAt(u: number): Vector; - } - - - - // Extras / Geomerties ///////////////////////////////////////////////////////////////////// - - export class AsteriskGeometry extends Geometry { - constructor(innerRadius: number, outerRadius: number); - } - - export class CircleGeometry extends Geometry { - constructor(radius?: number, segments?: number, thetaStart?: number, thetaLength?: number); - } - - export class ConvexGeometry extends Geometry { - constructor(vertices: Vector3[]); - } - - /** - * CubeGeometry is the quadrilateral primitive geometry class. It is typically used for creating a cube or irregular quadrilateral of the dimensions provided within the (optional) 'width', 'height', & 'depth' constructor arguments. - */ - export class CubeGeometry extends Geometry { - /** - * @param width — Width of the sides on the X axis. - * @param height — Height of the sides on the Y axis. - * @param depth — Depth of the sides on the Z axis. - * @param widthSegments — Number of segmented faces along the width of the sides. - * @param heightSegments — Number of segmented faces along the height of the sides. - * @param depthSegments — Number of segmented faces along the depth of the sides. - */ - constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number); - } - - export class CylinderGeometry extends Geometry { - /** - * @param radiusTop — Radius of the cylinder at the top. - * @param radiusBottom — Radius of the cylinder at the bottom. - * @param height — Height of the cylinder. - * @param radiusSegments — Number of segmented faces around the circumference of the cylinder. - * @param heightSegments — Number of rows of faces along the height of the cylinder. - * @param openEnded - A Boolean indicating whether or not to cap the ends of the cylinder. - */ - constructor(radiusTop?: number, radiusBottom?: number, height?: number, radiusSegments?: number, heightSegments?: number, openEnded?: boolean); - } - - export class ExtrudeGeometry extends Geometry { - constructor(shape?: Shape, options?: any); - constructor(shapes?: Shape[], options?: any); - shapebb: BoundingBox; - addShapeList(shapes: Shape[], options?: any): void; - addShape(shape: Shape, options?: any): void; - static WorldUVGenerator: { - generateTopUV(geometry: Geometry, extrudedShape: Shape, extrudeOptions: Object, indexA: number, indexB: number, indexC: number): Vector2[]; - generateBottomUV(geometry: Geometry, extrudedShape: Shape, extrudeOptions: Object, indexA: number, indexB: number, indexC: number): Vector2[]; - generateSideWallUV(geometry: Geometry, extrudedShape: Shape, wallContour: Object, extrudeOptions: Object, - indexA: number, indexB: number, indexC: number, indexD: number, stepIndex: number, stepsLength: number, - contourIndex1: number, contourIndex2: number): Vector2[]; - }; - } - - export class IcosahedronGeometry extends PolyhedronGeometry { - constructor(radius: number, detail: number); - } - - export class LatheGeometry extends Geometry { - constructor(points: Vector3[], steps?: number, angle?: number); - } - - export class OctahedronGeometry extends PolyhedronGeometry { - constructor(radius: number, detail: number); - } - - export class ParametricGeometry extends Geometry { - constructor(func: (u: number, v: number) => Vector3, slices: number, stacks: number, useTris?: boolean); - } - - export class PlaneGeometry extends Geometry { - constructor(width: number, height: number, widthSegments?: number, heightSegments?: number); - width: number; - height: number; - widthSegments: number; - heightSegments: number; - } - - export class PolyhedronGeometry extends Geometry { - constructor(vertices: Vector3[], faces: Face[], radius?: number, detail?: number); - } - - export class ShapeGeometry extends Geometry { - constructor(shape: Shape, options?: any); - constructor(shapes: Shape[], options?: any); - shapebb: BoundingBox; - addShapeList(shapes: Shape[], options: any): ShapeGeometry; - addShape(shape: Shape, options?: any): void; - } - - /** - * A class for generating sphere geometries - */ - export class SphereGeometry extends Geometry { - /** - * The geometry is created by sweeping and calculating vertexes around the Y axis (horizontal sweep) and the Z axis (vertical sweep). Thus, incomplete spheres (akin to 'sphere slices') can be created through the use of different values of phiStart, phiLength, thetaStart and thetaLength, in order to define the points in which we start (or end) calculating those vertices. - * - * @param radius — sphere radius. Default is 50. - * @param segmentsWidth — number of horizontal segments. Minimum value is 3, and the default is 8. - * @param segmentsHeight — number of vertical segments. Minimum value is 2, and the default is 6. - * @param phiStart — specify horizontal starting angle. Default is 0. - * @param phiLength — specify horizontal sweep angle size. Default is Math.PI * 2. - * @param thetaStart — specify vertical starting angle. Default is 0. - * @param thetaLength — specify vertical sweep angle size. Default is Math.PI. - */ - constructor(radius: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number); - radius: number; - widthSegments: number; - heightSegments: number; - phiStart: number; - phiLength: number; - thetaStart: number; - thetaLength: number; - } - - export class TetrahedronGeometry extends PolyhedronGeometry { - constructor(radius?: number, detail?: number); - } - - export interface TextGeometryParameters { - size?: number; // size of the text - height?: number; // thickness to extrude text - curveSegments?: number; // number of points on the curves - font?: string; // font name - weight?: string; // font weight (normal, bold) - style?: string; // font style (normal, italics) - bevelEnabled?: boolean; // turn on bevel - bevelThickness?: number; // how deep into text bevel goes - bevelSize?: number; // how far from text outline is bevel - } - - export class TextGeometry extends ExtrudeGeometry { - constructor(text: string, TextGeometryParameters?: TextGeometryParameters); - } - - export class TorusGeometry extends Geometry { - constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number); - radius: number; - tube: number; - radialSegments: number; - tubularSegments: number; - arc: number; - } - - export class TorusKnotGeometry extends Geometry { - constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, heightScale?: number); - radius: number; - tube: number; - radialSegments: number; - tubularSegments: number; - p: number; - q: number; - heightScale: number; - grid: number[][]; - } - - export class TubeGeometry extends Geometry { - constructor(path: Path, segments?: number, radius?: number, radiusSegments?: number, closed?: boolean, debug?: Object3D); - - // https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_extrude_shapes.html#L208 - // Hmmm? - constructor(path: SplineCurve3, segments?: number, radius?: number, radiusSegments?: number, closed?: boolean, debug?: boolean); - - path: Path; - segments: number; - radius: number; - radiusSegments: number; - closed: boolean; - grid: number[][]; - tangents: Vector3[]; - normals: Vector3[]; - binormals: Vector3[]; - FrenetFrames(path: Path, segments: number, closed: boolean): void; - } - - // Extras / Helpers ///////////////////////////////////////////////////////////////////// - - export class AxisHelper extends Line { - constructor(size: number); - } - - export class ArrowHelper extends Object3D { - constructor(dir: Vector3, origin?: Vector3, length?: number, hex?: number); - line: Line; - cone: Mesh; - setDirection(dir: Vector3): void; - setLength(length: number): void; - setColor(hex: number): void; - } - - export class CameraHelper extends Line { - constructor(camera: Camera); - pointMap: { [id: string]: number[]; }; - camera: Camera; - } - - export class DirectionalLightHelper extends Object3D { - constructor(light: Light, sphereSize: number, arrowLength: number); - light: Light; - direction: Vector3; - color: Color; - lightArrow: ArrowHelper; - lightSphere: Mesh; - lightRays: Line; - targetSphere: Mesh; - targetLine: Line; - } - - export class HemisphereLightHelper extends Object3D { - constructor(light: Light, sphereSize: number, arrowLength: number, domeSize: number); - light: Light; - color: Color; - groundColor: Color; - lightSphere: Mesh; - lightArrow: ArrowHelper; - lightArrowGround: ArrowHelper; - target: Vector3; - } - - export class PointLightHelper extends Object3D { - constructor(light: Light, sphereSize: number); - light: Light; - color: Color; - lightSphere: Mesh; - lightRays: Line; - lightDistance: Mesh; - } - - export class SpotLightHelper extends Object3D { - constructor(light: Light, sphereSize: number, arrowLength: number); - light: Light; - direction: Vector3; - color: Color; - lightArrow: ArrowHelper; - lightSphere: Mesh; - lightCone: Mesh; - lightRays: Line; - gyroscope: Gyroscope; - targetSphere: Mesh; - targetLine: Line; - } - - // Extras / Objects ///////////////////////////////////////////////////////////////////// - - export class ImmediateRenderObject extends Object3D { - constructor(); - // render(renderCallback):void; - } - - export interface LensFlareProperty { - texture: Texture; // Texture - size: number; // size in pixels (-1 = use texture.width) - distance: number; // distance (0-1) from light source (0=at light source) - x: number; - y: number; - z: number; // screen position (-1 => 1) z = 0 is ontop z = 1 is back - scale: number; // scale - rotation: number; // rotation - opacity: number; // opacity - color: Color; // color - blending: Blending; - } - - export class LensFlare extends Object3D { - constructor(texture?: Texture, size?: number, distance?: number, blending?: Blending, color?: Color); - lensFlares: LensFlareProperty[]; - positionScreen: Vector3; - customUpdateCallback: (object: LensFlare) => void; - add(object: Object3D): void; - add(texture?: Texture, size?: number, distance?: number, blending?: Blending, color?: Color, opacity?: number): void; - updateLensFlares(): void; - } - - export interface MorphBlendMeshAnimation { - startFrame: number; - endFrame: number; - length: number; - fps: number; - duration: number; - lastFrame: number; - currentFrame: number; - active: boolean; - time: number; - direction: number; - weight: number; - directionBackwards: boolean; - mirroredLoop: boolean; - } - - export class MorphBlendMesh extends Mesh { - constructor(geometry: Geometry, material: Material); - animationsMap: { [name: string]: MorphBlendMeshAnimation; }; - animationsList: MorphBlendMeshAnimation[]; - createAnimation(name: string, start: number, end: number, fps: number): void; - autoCreateAnimations(fps: number): void; - firstAnimation: string; - setAnimationDirectionForward(name: string): void; - setAnimationDirectionBackward(name: string): void; - setAnimationFPS(name: string, fps: number): void; - setAnimationDuration(name: string, duration: number): void; - setAnimationWeight(name: string, weight: number): void; - setAnimationTime(name: string, time: number): void; - getAnimationTime(name: string): number; - getAnimationDuration(name: string): number; - playAnimation(name: string): void; - stopAnimation(name: string): void; - update(delta: number): void; - } - - // Extras / Renderers / Plugins ///////////////////////////////////////////////////////////////////// - - export class DepthPassPlugin implements RendererPlugin { - constructor(); - enabled: boolean; - renderTarget: RenderTarget; - init(renderer: Renderer): void; - render(scene: Scene, camera: Camera): void; - update(scene: Scene, camera: Camera): void; - } - - export class LensFlarePlugin implements RendererPlugin { - constructor(); - init(renderer: Renderer): void; - render(scene: Scene, camera: Camera, viewportWidth: number, viewportHeight: number): void; - } - - export class ShadowMapPlugin implements RendererPlugin { - constructor(); - init(renderer: Renderer): void; - render(scene: Scene, camera: Camera): void; - update(scene: Scene, camera: Camera): void; - } - - export class SpritePlugin implements RendererPlugin { - constructor(); - init(renderer: Renderer): void; - render(scene: Scene, camera: Camera, viewportWidth: number, viewportHeight: number): void; - } - - // renderers ///////////////////////////////////////////////////////////////////// - - export interface ShaderLibrary { - [name: string]: { - vertexShader: string; - fragmentShader: string; - }; - } - export var ShaderFlares: ShaderLibrary; - export var ShaderSprite: ShaderLibrary; - - export var UniformsUtils: { - merge(uniforms: Object[]): Uniforms; - merge(uniforms: Uniforms[]): Uniforms; - clone(uniforms_src: Uniforms): Uniforms; - }; - - export var UniformsLib: { - common: Uniforms; - bump: Uniforms; - normalmap: Uniforms; - fog: Uniforms; - lights: Uniforms; - particle: Uniforms; - shadowmap: Uniforms; - }; - - export interface Shader { - uniforms: Uniforms; - vertexShader: string; - fragmentShader: string; - } - - export var ShaderLib: { - [name: string]: Shader; - basic: Shader; - lambert: Shader; - phong: Shader; - particle_basic: Shader; - depth: Shader; - dashed: Shader; - normal: Shader; - normalmap: Shader; - cube: Shader; - depthRGBA: Shader; - }; -} +// Type definitions for three.js -- r66 +// Project: http://mrdoob.github.com/three.js/ +// Definitions by: Kon , Satoru Kimura +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface WebGLRenderingContext {} + +declare module THREE { + export var REVISION: string; + + // custom blending equations + // (numbers start from 100 not to clash with other + // mappings to OpenGL constants defined in Texture.js) + export enum BlendingEquation { } + export var AddEquation: BlendingEquation; + export var SubtractEquation: BlendingEquation; + export var ReverseSubtractEquation: BlendingEquation; + + // custom blending destination factors + export enum BlendingDstFactor { } + export var ZeroFactor: BlendingDstFactor; + export var OneFactor: BlendingDstFactor; + export var SrcColorFactor: BlendingDstFactor; + export var OneMinusSrcColorFactor: BlendingDstFactor; + export var SrcAlphaFactor: BlendingDstFactor; + export var OneMinusSrcAlphaFactor: BlendingDstFactor; + export var DstAlphaFactor: BlendingDstFactor; + export var OneMinusDstAlphaFactor: BlendingDstFactor; + + // custom blending source factors + export enum BlendingSrcFactor { } + export var DstColorFactor: BlendingSrcFactor; + export var OneMinusDstColorFactor: BlendingSrcFactor; + export var SrcAlphaSaturateFactor: BlendingSrcFactor; + + // GL STATE CONSTANTS + + export enum CullFace { } + export var CullFaceNone: CullFace; + export var CullFaceBack: CullFace; + export var CullFaceFront: CullFace; + export var CullFaceFrontBack: CullFace; + + export enum FrontFaceDirection { } + export var FrontFaceDirectionCW: FrontFaceDirection; + export var FrontFaceDirectionCCW: FrontFaceDirection; + + // MATERIAL CONSTANTS + + // side + export enum Side { } + export var FrontSide: Side; + export var BackSide: Side; + export var DoubleSide: Side; + + // shading + export enum Shading { } + export var NoShading: Shading; + export var FlatShading: Shading; + export var SmoothShading: Shading; + + // colors + export enum Colors { } + export var NoColors: Colors; + export var FaceColors: Colors; + export var VertexColors: Colors; + + // blending modes + export enum Blending { } + export var NoBlending: Blending; + export var NormalBlending: Blending; + export var AdditiveBlending: Blending; + export var SubtractiveBlending: Blending; + export var MultiplyBlending: Blending; + export var CustomBlending: Blending; + + // Shadowing Type + export enum ShadowMapType { } + export var BasicShadowMap: ShadowMapType; + export var PCFShadowMap: ShadowMapType; + export var PCFSoftShadowMap: ShadowMapType; + + // TEXTURE CONSTANTS + // Operations + export enum Combine { } + export var MultiplyOperation: Combine; + export var MixOperation: Combine; + export var AddOperation: Combine; + + // Mapping modes + export enum Mapping { } + export interface MappingConstructor { + new (): Mapping; + } + export var UVMapping: MappingConstructor; + export var CubeReflectionMapping: MappingConstructor; + export var CubeRefractionMapping: MappingConstructor; + export var SphericalReflectionMapping: MappingConstructor; + export var SphericalRefractionMapping: MappingConstructor; + + // Wrapping modes + export enum Wrapping { } + export var RepeatWrapping: Wrapping; + export var ClampToEdgeWrapping: Wrapping; + export var MirroredRepeatWrapping: Wrapping; + + // Filters + export enum TextureFilter { } + export var NearestFilter: TextureFilter; + export var NearestMipMapNearestFilter: TextureFilter; + export var NearestMipMapLinearFilter: TextureFilter; + export var LinearFilter: TextureFilter; + export var LinearMipMapNearestFilter: TextureFilter; + export var LinearMipMapLinearFilter: TextureFilter; + + // Data types + export enum TextureDataType { } + export var UnsignedByteType: TextureDataType; + export var ByteType: TextureDataType; + export var ShortType: TextureDataType; + export var UnsignedShortType: TextureDataType; + export var IntType: TextureDataType; + export var UnsignedIntType: TextureDataType; + export var FloatType: TextureDataType; + + // Pixel types + export enum PixelType { } + + export var UnsignedShort4444Type: PixelType; + export var UnsignedShort5551Type: PixelType; + export var UnsignedShort565Type: PixelType; + + // Pixel formats + export enum PixelFormat { } + export var AlphaFormat: PixelFormat; + export var RGBFormat: PixelFormat; + export var RGBAFormat: PixelFormat; + export var LuminanceFormat: PixelFormat; + export var LuminanceAlphaFormat: PixelFormat; + + // Compressed texture formats + export enum CompressedPixelFormat { } + export var RGB_S3TC_DXT1_Format: CompressedPixelFormat; + export var RGBA_S3TC_DXT1_Format: CompressedPixelFormat; + export var RGBA_S3TC_DXT3_Format: CompressedPixelFormat; + export var RGBA_S3TC_DXT5_Format: CompressedPixelFormat; + + // Cameras //////////////////////////////////////////////////////////////////////////////////////// + + /** + * Abstract base class for cameras. This class should always be inherited when you build a new camera. + */ + export class Camera extends Object3D { + /** + * This constructor sets following properties to the correct type: matrixWorldInverse, projectionMatrix and projectionMatrixInverse. + */ + constructor(); + + /** + * This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera. + */ + matrixWorldInverse: Matrix4; + + /** + * This is the matrix which contains the projection. + */ + projectionMatrix: Matrix4; + + /** + * This make the camera look at the vector position in local space. + * @param vector point to look at + */ + lookAt(vector: Vector3): void; + } + + /** + * Camera with orthographic projection + * + * @example + * var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); + * scene.add( camera ); + * + * @see src/cameras/OrthographicCamera.js + */ + export class OrthographicCamera extends Camera { + /** + * @param left Camera frustum left plane. + * @param right Camera frustum right plane. + * @param top Camera frustum top plane. + * @param bottom Camera frustum bottom plane. + * @param near Camera frustum near plane. + * @param far Camera frustum far plane. + */ + constructor(left: number, right: number, top: number, bottom: number, near?: number, far?: number); + + /** + * Camera frustum left plane. + */ + left: number; + + /** + * Camera frustum right plane. + */ + right: number; + + /** + * Camera frustum top plane. + */ + top: number; + + /** + * Camera frustum bottom plane. + */ + bottom: number; + + /** + * Camera frustum near plane. + */ + near: number; + + /** + * Camera frustum far plane. + */ + far: number; + + /** + * Updates the camera projection matrix. Must be called after change of parameters. + */ + updateProjectionMatrix(): void; + } + + /** + * Camera with perspective projection. + * + * # example + * var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); + * scene.add( camera ); + * + * @source https://github.com/mrdoob/three.js/blob/master/src/cameras/PerspectiveCamera.js + */ + export class PerspectiveCamera extends Camera { + /** + * @param fov Camera frustum vertical field of view. Default value is 50. + * @param aspect Camera frustum aspect ratio. Default value is 1. + * @param near Camera frustum near plane. Default value is 0.1. + * @param far Camera frustum far plane. Default value is 2000. + */ + constructor(fov?: number, aspect?: number, near?: number, far?: number); + + /** + * Camera frustum vertical field of view, from bottom to top of view, in degrees. + */ + fov: number; + + /** + * Camera frustum aspect ratio, window width divided by window height. + */ + aspect: number; + + /** + * Camera frustum near plane. + */ + near: number; + + /** + * Camera frustum far plane. + */ + far: number; + + /** + * Uses focal length (in mm) to estimate and set FOV 35mm (fullframe) camera is used if frame size is not specified. + * Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html + * @param focalLength focal length + * @param frameHeight frame size. Default value is 24. + */ + setLens(focalLength: number, frameHeight?: number): void; + + /** + * Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups. + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this: + * + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ + * + * then for each monitor you would call it like this: + * + * var w = 1920; + * var h = 1080; + * var fullWidth = w * 3; + * var fullHeight = h * 2; + * + * // A + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * // B + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * // C + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * // D + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * // E + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * // F + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid. + * + * @param fullWidth full width of multiview setup + * @param fullHeight full height of multiview setup + * @param x horizontal offset of subcamera + * @param y vertical offset of subcamera + * @param width width of subcamera + * @param height height of subcamera + */ + setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void; + + /** + * Updates the camera projection matrix. Must be called after change of parameters. + */ + updateProjectionMatrix(): void; + } + + // Core /////////////////////////////////////////////////////////////////////////////////////////////// + + interface BufferGeometryAttributeArray extends ArrayBufferView{ + length: number; + } + + interface BufferGeometryAttribute{ + itemSize: number; + array: BufferGeometryAttributeArray; + numItems: number; + } + + interface BufferGeometryAttributes{ + [name: string]: BufferGeometryAttribute; + index?: BufferGeometryAttribute; + position?: BufferGeometryAttribute; + normal?: BufferGeometryAttribute; + color?: BufferGeometryAttribute; + } + + /** + * This is a superefficent class for geometries because it saves all data in buffers. + * It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the nessecary buffer calculations. + * It is mainly interesting when working with static objects. + * + * @see src/core/BufferGeometry.js + */ + export class BufferGeometry { + /** + * This creates a new BufferGeometry. It also sets several properties to an default value. + */ + constructor(); + + /** + * Unique number of this buffergeometry instance + */ + id: number; + + /** + * This hashmap has as id the name of the attribute to be set and as value the buffer to set it to. + */ + attributes: BufferGeometryAttributes; + + /** + * When set, it holds certain buffers in memory to have faster updates for this object. When unset, it deletes those buffers and saves memory. + */ + dynamic: boolean; + + offsets: { start: number; count: number; index: number; }[]; + + /** + * Bounding box. + */ + boundingBox: BoundingBox3D; + + /** + * Bounding sphere. + */ + boundingSphere: BoundingSphere; + + morphTargets: any[]; + hasTangents: boolean; + + /** + * Bakes matrix transform directly into vertex coordinates. + */ + applyMatrix(matrix: Matrix4): void; + + /** + * Computes vertex normals by averaging face normals. + */ + computeVertexNormals(): void; + + /** + * Computes vertex tangents. + * Based on http://www.terathon.com/code/tangent.html + * Geometry must have vertex UVs (layer 0 will be used). + */ + computeTangents(): void; + + /** + * Computes bounding box of the geometry, updating Geometry.boundingBox attribute. + * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingBox(): void; + + /** + * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute. + * Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingSphere(): void; + + /** + * Disposes the object from memory. + * You need to call this when you want the bufferGeometry removed while the application is running. + */ + dispose(): void; + + normalizeNormals(): void; + } + + /** + * Object for keeping track of time. + * + * @see src/core/Clock.js + */ + export class Clock { + /** + * @param autoStart Automatically start the clock. + */ + constructor(autoStart?: boolean); + + /** + * If set, starts the clock automatically when the first update is called. + */ + autoStart: boolean; + + /** + * When the clock is running, It holds the starttime of the clock. + * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + startTime: number; + + /** + * When the clock is running, It holds the previous time from a update. + * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + oldTime: number; + + /** + * When the clock is running, It holds the time elapsed btween the start of the clock to the previous update. + * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + elapsedTime: number; + + /** + * This property keeps track whether the clock is running or not. + */ + running: boolean; + + /** + * Starts clock. + */ + start(): void; + + /** + * Stops clock. + */ + stop(): void; + + /** + * Get milliseconds passed since the clock started. + */ + getElapsedTime(): number; + + /** + * Get the milliseconds passed since the last call to this method. + */ + getDelta(): number; + } + + /** + * JavaScript events for custom objects + * + * # Example + * var Car = function () { + * + * EventDispatcher.call( this ); + * this.start = function () { + * + * this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); + * + * }; + * + * }; + * + * var car = new Car(); + * car.addEventListener( 'start', function ( event ) { + * + * alert( event.message ); + * + * } ); + * car.start(); + * + * @source src/core/EventDispatcher.js + */ + export class EventDispatcher { + /** + * Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object. + */ + constructor(); + + /** + * Adds a listener to an event type. + * @param type The type of the listener that gets removed. + * @param listener The listener function that gets removed. + */ + addEventListener(type: string, listener: (event: any) => void ): void; + + /** + * Adds a listener to an event type. + * @param type The type of the listener that gets removed. + * @param listener The listener function that gets removed. + */ + hasEventListener(type: string, listener: (event: any) => void): void; + + /** + * Removes a listener from an event type. + * @param type The type of the listener that gets removed. + * @param listener The listener function that gets removed. + */ + removeEventListener(type: string, listener: (event: any) => void): void; + + /** + * Fire an event type. + * @param type The type of event that gets fired. + */ + dispatchEvent(event: { type: string; target: any; }): void; + } + + export interface Face { + /** + * Face normal. + */ + normal: Vector3; + + /** + * Face color. + */ + color: Color; + + /** + * Array of 4 vertex normals. + */ + vertexNormals: Vector3[]; + + /** + * Array of 4 vertex normals. + */ + vertexColors: Color[]; + + /** + * Array of 4 vertex tangets. + */ + vertexTangents: number[]; + + /** + * Material index (points to {@link Geometry.materials}). + */ + materialIndex: number; + + /** + * Face centroid. + */ + centroid: Vector3; + + clone(): Face; + } + + /** + * Triangle face. + * + * # Example + * var normal = new THREE.Vector3( 0, 1, 0 ); + * var color = new THREE.Color( 0xffaa00 ); + * var face = new THREE.Face3( 0, 1, 2, normal, color, 0 ); + * + * @source https://github.com/mrdoob/three.js/blob/master/src/core/Face3.js + */ + export class Face3 implements Face { + /** + * @param a Vertex A index. + * @param b Vertex B index. + * @param c Vertex C index. + * @param normal Face normal or array of vertex normals. + * @param color Face color or array of vertex colors. + * @param materialIndex Material index. + */ + constructor(a: number, b: number, c: number, normal?: Vector3, color?: Color, materialIndex?: number); + constructor(a: number, b: number, c: number, normal?: Vector3, vertexColors?: Color[], materialIndex?: number); + constructor(a: number, b: number, c: number, vertexNormals?: Vector3[], color?: Color, materialIndex?: number); + constructor(a: number, b: number, c: number, vertexNormals?: Vector3[], vertexColors?: Color[], materialIndex?: number); + + /** + * Vertex A index. + */ + a: number; + + /** + * Vertex B index. + */ + b: number; + + /** + * Vertex C index. + */ + c: number; + + // properties inherits from Face /////////////////////////////////// + + /** + * Face normal. + */ + normal: Vector3; + + /** + * Face color. + */ + color: Color; + + /** + * Array of 4 vertex normals. + */ + vertexNormals: Vector3[]; + + /** + * Array of 4 vertex normals. + */ + vertexColors: Color[]; + + /** + * Array of 4 vertex tangets. + */ + vertexTangents: number[]; + + /** + * Material index (points to {@link Geometry.materials}). + */ + materialIndex: number; + + /** + * Face centroid. + */ + centroid: Vector3; + clone(): Face3; + } + + export interface MorphTarget { + name: string; + vertices: Vector3[]; + } + + export interface MorphColor { + name: string; + color: Color[]; + } + + export interface MorphNormals { + name: string; + normals: Vector3[]; + } + + export interface BoundingBox3D { + min: Vector3; + max: Vector3; + } + + export interface BoundingSphere { + radius: number; + } + + + /** + * Base class for geometries + * + * # Example + * var geometry = new THREE.Geometry(); + * geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) ); + * geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) ); + * geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) ); + * geometry.faces.push( new THREE.Face3( 0, 1, 2 ) ); + * geometry.computeBoundingSphere(); + * + * @see https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js + */ + export class Geometry { + constructor(); + + /** + * Unique number of this geometry instance + */ + id: number; + + /** + * Name for this geometry. Default is an empty string. + */ + name: string; + + /** + * The array of vertices hold every position of points of the model. + * To signal an update in this array, Geometry.verticesNeedUpdate needs to be set to true. + */ + vertices: Vector3[]; + + /** + * Array of vertex colors, matching number and order of vertices. + * Used in ParticleSystem, Line and Ribbon. + * Meshes use per-face-use-of-vertex colors embedded directly in faces. + * To signal an update in this array, Geometry.colorsNeedUpdate needs to be set to true. + */ + colors: Color[]; + + /** + * Array of vertex normals, matching number and order of vertices. + * Normal vectors are nessecary for lighting + * To signal an update in this array, Geometry.normalsNeedUpdate needs to be set to true. + */ +// normals: Vector3[]; + + /** + * Array of triangles or/and quads. + * The array of faces describe how each vertex in the model is connected with each other. + * To signal an update in this array, Geometry.elementsNeedUpdate needs to be set to true. + */ + faces: Face[]; + + /** + * Array of face UV layers. + * Each UV layer is an array of UV matching order and number of faces. + * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true. + */ +// faceUvs: Vector2[][]; + + /** + * Array of face UV layers. + * Each UV layer is an array of UV matching order and number of vertices in faces. + * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true. + */ + faceVertexUvs: Vector2[][][]; + + /** + * Array of morph targets. Each morph target is a Javascript object: + * + * { name: "targetName", vertices: [ new THREE.Vector3(), ... ] } + * + * Morph vertices match number and order of primary vertices. + */ + morphTargets: MorphTarget[]; + + /** + * Array of morph colors. Morph colors have similar structure as morph targets, each color set is a Javascript object: + * + * morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] } + */ + morphColors: MorphColor[]; + + /** + * Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object: + * + * morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] } + */ + morphNormals: MorphNormals[]; + + /** + * Array of skinning weights, matching number and order of vertices. + */ + skinWeights: number[]; + + /** + * Array of skinning indices, matching number and order of vertices. + */ + skinIndices: number[]; + + /** + * Bounding box. + */ + boundingBox: BoundingBox3D; + + /** + * Bounding sphere. + */ + boundingSphere: BoundingSphere; + + /** + * True if geometry has tangents. Set in Geometry.computeTangents. + */ + hasTangents: boolean; + + /** + * Set to true if attribute buffers will need to change in runtime (using "dirty" flags). + * Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU. + * Defaults to true. + */ + dynamic: boolean; + + /** + * Set to true if the vertices array has been updated. + */ + verticesNeedUpdate: boolean; + + /** + * Set to true if the faces array has been updated. + */ + elementsNeedUpdate: boolean; + + /** + * Set to true if the uvs array has been updated. + */ + uvsNeedUpdate: boolean; + + /** + * Set to true if the normals array has been updated. + */ + normalsNeedUpdate: boolean; + + /** + * Set to true if the tangents in the faces has been updated. + */ + tangentsNeedUpdate: boolean; + + /** + * Set to true if the colors array has been updated. + */ + colorsNeedUpdate: boolean; + + /** + * Set to true if the linedistances array has been updated. + */ + lineDistancesNeedUpdate: boolean; + + /** + * Set to true if an array has changed in length. + */ + buffersNeedUpdate: boolean; + + /** + * + */ + lineDistances: number[]; + + /** + * Bakes matrix transform directly into vertex coordinates. + */ + applyMatrix(matrix: Matrix4): void; + + /** + * Computes centroids for all faces. + */ + computeCentroids(): void; + + /** + * Computes face normals. + */ + computeFaceNormals(): void; + + /** + * Computes vertex normals by averaging face normals. + * Face normals must be existing / computed beforehand. + */ + computeVertexNormals(areaWeighted?: boolean): void; + + /** + * Computes morph normals. + */ + computeMorphNormals(): void; + + /** + * Computes vertex tangents. + * Based on http://www.terathon.com/code/tangent.html + * Geometry must have vertex UVs (layer 0 will be used). + */ + computeTangents(): void; + + /** + * Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute. + */ + computeBoundingBox(): void; + + /** + * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute. + * Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingSphere(): void; + + /** + * Checks for duplicate vertices using hashmap. + * Duplicated vertices are removed and faces' vertices are updated. + */ + mergeVertices(): number; + + /** + * Creates a new clone of the Geometry. + */ + clone(): Geometry; + + /** + * Removes The object from memory. + * Don't forget to call this method when you remove an geometry because it can cuase meomory leaks. + */ + dispose(): void; + + computeLineDistances(): void; + } + + /** + * Base class for scene graph objects + */ + export class Object3D { + constructor(); + + /** + * Unique number of this object instance. + */ + id: number; + + /** + * Optional name of the object (doesn't need to be unique). + */ + name: string; + + /** + * Object's parent in the scene graph. + */ + parent: Object3D; + + /** + * Array with object's children. + */ + children: Object3D[]; + + /** + * Object's local position. + */ + position: Vector3; + + /** + * Object's local rotation (Euler angles), in radians. + */ + rotation: Euler; + + /** + * Order of axis for Euler angles. + */ + eulerOrder: string; + // eulerOrder:EulerOrder; + + /** + * Object's local scale. + */ + scale: Vector3; + + /** + * Up direction. + */ + up: Vector3; + + /** + * Local transform. + */ + matrix: Matrix4; + + /** + * Global rotation. + */ + quaternion: Quaternion; + + /** + * Use quaternion instead of Euler angles for specifying local rotation. + */ + useQuaternion: boolean; + + /** + * Override depth-sorting order if non null. + */ + renderDepth: number; + + /** + * Object gets rendered if true. + */ + visible: boolean; + + /** + * Gets rendered into shadow map. + */ + castShadow: boolean; + + /** + * Material gets baked in shadow receiving. + */ + receiveShadow: boolean; + + /** + * When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible. + */ + frustumCulled: boolean; + + /** + * When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property. + */ + matrixAutoUpdate: boolean; + + /** + * When this is set, it calculates the matrixWorld in that frame and resets this property to false. + */ + matrixWorldNeedsUpdate: boolean; + + /** + * When this is set, then the rotationMatrix gets calculated every frame. + */ + rotationAutoUpdate: boolean; + + /** + * An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned. + */ + userData: any; + + /** + * The global transform of the object. If the Object3d has no parent, then it's identical to the local transform. + */ + matrixWorld: Matrix4; + + + /** + * This updates the position, rotation and scale with the matrix. + */ + applyMatrix(matrix: Matrix4): void; + + /** + * Translates object along x axis by distance. + * @param distance Distance. + */ + translateX(distance: number): void; + + /** + * Translates object along y axis by distance. + * @param distance Distance. + */ + translateY(distance: number): void; + + /** + * Translates object along z axis by distance. + * @param distance Distance. + */ + translateZ(distance: number): void; + + /** + * Updates the vector from local space to world space. + * @param vector A local vector. + */ + localToWorld(vector: Vector3): Vector3; + + /** + * Updates the vector from world space to local space. + * @param vector A world vector. + */ + worldToLocal(vector: Vector3): Vector3; + + /** + * Rotates object to face point in space. + * @param vector A world vector to look at. + */ + lookAt(vector: Vector3): void; + + /** + * Adds object as child of this object. + */ + add(object: Object3D): void; + + /** + * Removes object as child of this object. + */ + remove(object: Object3D): void; + + /** + * Translates object along arbitrary axis by distance. + * @param distance Distance. + * @param axis Translation direction. + */ + traverse(callback: (object: Object3D) => any): void; + + /** + * Searches whole subgraph recursively to add all objects in the array. + * @param array optional argument that returns the the array with descendants. + */ + getDescendants(array?: Object3D[]): Object3D[]; + + /** + * Updates local transform. + */ + updateMatrix(): void; + + /** + * Updates global transform of the object and its children. + */ + updateMatrixWorld(force: boolean): void; + + clone(object?: Object3D, recursive?: boolean): Object3D; + + /** + * Creates a new clone of this object and all descendants. + */ + clone(object?: Object3D): Object3D; + + /** + * Searches through the object's children and returns the first with a matching name, optionally recursive. + * @param name String to match to the children's Object3d.name property. + * @param recursive Boolean whether to search through the children's children. Default is false. + */ + getObjectByName(name: string, recursive: boolean): Object3D; + + /** + * Searches through the object's children and returns the first with a matching id, optionally recursive. + * @param id Unique number of the object instance + * @param recursive Boolean whether to search through the children's children. Default is false. + */ + getObjectById(id: string, recursive: boolean): Object3D; + + /** + * @param axis A normalized vector in object space. + * @param distance The distance to translate. + */ + translateOnAxis(axis: Vector3, distance: number): Object3D; + + /** + * Rotate an object along an axis in object space. The axis is assumed to be normalized. + * @param axis A normalized vector in object space. + * @param angle The angle in radians. + */ + rotateOnAxis(axis: Vector3, angle: number): Object3D; + } + + /** + * Projects points between spaces. + */ + export class Projector { + constructor(); + + projectVector(vector: Vector3, camera: Camera): Vector3; + + unprojectVector(vector: Vector3, camera: Camera): Vector3; + + /** + * Translates a 2D point from NDC (Normalized Device Coordinates) to a Raycaster that can be used for picking. NDC range from [-1..1] in x (left to right) and [1.0 .. -1.0] in y (top to bottom). + */ + pickingRay(vector: Vector3, camera: Camera): Raycaster; + + /** + * Transforms a 3D scene object into 2D render data that can be rendered in a screen with your renderer of choice, projecting and clipping things out according to the used camera. + * If the scene were a real scene, this method would be the equivalent of taking a picture with the camera (and developing the film would be the next step, using a Renderer). + * + * @param scene scene to project. + * @param camera camera to use in the projection. + * @param sort select whether to sort elements using the Painter's algorithm. + */ + projectScene(scene: Scene, camera: Camera, sortObjects: boolean, sortElements?: boolean): { + objects: Object3D[]; // Mesh, Line or other object + sprites: Object3D[]; // Sprite or Particle + lights: Light[]; + elements: Face[]; // Line, Particle, Face3 or Face4 + }; + } + + export interface Intersection { + distance: number; + point: Vector3; + face: Face; + object: Object3D; + } + + export class Raycaster { + constructor(origin?: Vector3, direction?: Vector3, near?: number, far?: number); + ray: Ray; + near: number; + far: number; + precision: number; + set(origin: Vector3, direction: Vector3): void; + intersectObject(object: Object3D, recursive?: boolean): Intersection[]; + intersectObjects(objects: Object3D[], recursive?: boolean): Intersection[]; + } + + // Lights ////////////////////////////////////////////////////////////////////////////////// + + /** + * Abstract base class for lights. + */ + export class Light extends Object3D { + constructor(hex?: number); + color: Color; + } + + /** + * This light's color gets applied to all the objects in the scene globally. + * + * # example + * var light = new THREE.AmbientLight( 0x404040 ); // soft white light + * scene.add( light ); + * + * @source https://github.com/mrdoob/three.js/blob/master/src/lights/AmbientLight.js + */ + export class AmbientLight extends Light { + /** + * This creates a Ambientlight with a color. + * @param hex Numeric value of the RGB component of the color. + */ + constructor(hex?: number); + } + + export class AreaLight extends Light{ + constructor(hex: number, intensity?: number); + + position: Vector3; + right: Vector3; + normal: Vector3; + quadraticAttenuation: number; + height: number; + linearAttenuation: number; + width: number; + intensity: number; + constantAttenuation: number; + } + + /** + * Affects objects using MeshLambertMaterial or MeshPhongMaterial. + * + * @example + * // White directional light at half intensity shining from the top. + * var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); + * directionalLight.position.set( 0, 1, 0 ); + * scene.add( directionalLight ); + * + * @see src/lights/DirectionalLight.js + */ + export class DirectionalLight extends Light { + + constructor(hex?: number, intensity?: number); + + /** + * Direction of the light is normalized vector from position to (0,0,0). + * Default — new THREE.Vector3(). + */ + position: Vector3; + + /** + * Target used for shadow camera orientation. + */ + target: Object3D; + + /** + * Light's intensity. + * Default — 1.0. + */ + intensity: number; + + /** + * If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right. + * Default — false. + */ + castShadow: boolean; + + /** + * If set to true light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute). + * Default — false. + */ + onlyShadow: boolean; + + /** + * Orthographic shadow camera frustum parameter. + * Default — 50. + */ + shadowCameraNear: number; + + /** + * Orthographic shadow camera frustum parameter. + * Default — 5000. + */ + shadowCameraFar: number; + + /** + * Orthographic shadow camera frustum parameter. + * Default — -500. + */ + shadowCameraLeft: number; + + /** + * Orthographic shadow camera frustum parameter. + * Default — 500. + */ + shadowCameraRight: number; + + /** + * Orthographic shadow camera frustum parameter. + * Default — 500. + */ + shadowCameraTop: number; + + /** + * Orthographic shadow camera frustum parameter. + * Default — -500. + */ + shadowCameraBottom: number; + + /** + * Show debug shadow camera frustum. + * Default — false. + */ + shadowCameraVisible: boolean; + + /** + * Shadow map bias. + * Default — 0. + */ + shadowBias: number; + + /** + * Darkness of shadow casted by this light (from 0 to 1). + * Default — 0.5. + */ + shadowDarkness: number; + + /** + * Shadow map texture width in pixels. + * Default — 512. + */ + shadowMapWidth: number; + + /** + * Shadow map texture height in pixels. + * Default — 512. + */ + shadowMapHeight: number; + + /** + * Default — false. + */ + shadowCascade: boolean; + + /** + * Three.Vector3( 0, 0, -1000 ). + */ + shadowCascadeOffset: Vector3; + + /** + * Default — 2. + */ + shadowCascadeCount: number; + + /** + * Default — [ 0, 0, 0 ]. + */ + shadowCascadeBias: number[]; + + /** + * Default — [ 512, 512, 512 ]. + */ + shadowCascadeWidth: number[]; + + /** + * Default — [ 512, 512, 512 ]. + */ + shadowCascadeHeight: number[]; + + /** + * Default — [ -1.000, 0.990, 0.998 ]. + */ + shadowCascadeNearZ: number[]; + + /** + * Default — [ 0.990, 0.998, 1.000 ]. + */ + shadowCascadeFarZ: number[]; + + /** + * Default — [ ]. + */ + shadowCascadeArray: DirectionalLight[]; + + /** + * Default — null. + */ + shadowMap: RenderTarget; + + /** + * Default — null. + */ + shadowMapSize: number; + + /** + * Default — null. + */ + shadowCamera: Camera; + + /** + * Default — null. + */ + shadowMatrix: Matrix4; + } + + export class HemisphereLight extends Light { + constructor(skyColorHex?: number, groundColorHex?: number, intensity?: number); + + position: Vector3; + groundColor: Color; + intensity: number; + } + + /** + * Affects objects using {@link MeshLambertMaterial} or {@link MeshPhongMaterial}. + * + * @example + * var light = new THREE.PointLight( 0xff0000, 1, 100 ); + * light.position.set( 50, 50, 50 ); + * scene.add( light ); + */ + export class PointLight extends Light { + constructor(hex?: number, intensity?: number, distance?: number); + + /** + * Light's position. + * Default — new THREE.Vector3(). + */ + position: Vector3; + + /* + * Light's intensity. + * Default - 1.0. + */ + intensity: number; + + /** + * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. + * Default — 0.0. + */ + distance: number; + } + + /** + * A point light that can cast shadow in one direction. + * + * @example + * // white spotlight shining from the side, casting shadow + * var spotLight = new THREE.SpotLight( 0xffffff ); + * spotLight.position.set( 100, 1000, 100 ); + * spotLight.castShadow = true; + * spotLight.shadowMapWidth = 1024; + * spotLight.shadowMapHeight = 1024; + * spotLight.shadowCameraNear = 500; + * spotLight.shadowCameraFar = 4000; + * spotLight.shadowCameraFov = 30; + * scene.add( spotLight ); + */ + export class SpotLight extends Light { + constructor(hex?: number, intensity?: number, distance?: number, angle?: number, exponent?: number); + + /** + * Light's position. + * Default — new THREE.Vector3(). + */ + position: Vector3; + + /** + * Spotlight focus points at target.position. + * Default position — (0,0,0). + */ + target: Object3D; + + /** + * Light's intensity. + * Default — 1.0. + */ + intensity: number; + + /** + * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. + * Default — 0.0. + */ + distance: number; + + /* + * Maximum extent of the spotlight, in radians, from its direction. + * Default — Math.PI/2. + */ + angle: number; + + /** + * Rapidity of the falloff of light from its target direction. + * Default — 10.0. + */ + exponent: number; + + /** + * If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right. + * Default — false. + */ + castShadow: boolean; + + /** + * If set to true light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute). + * Default — false. + */ + onlyShadow: boolean; + + /** + * Perspective shadow camera frustum near parameter. + * Default — 50. + */ + shadowCameraNear: number; + + /** + * Perspective shadow camera frustum far parameter. + * Default — 5000. + */ + shadowCameraFar: number; + + /** + * Perspective shadow camera frustum field of view parameter. + * Default — 50. + */ + shadowCameraFov: number; + + /** + * Show debug shadow camera frustum. + * Default — false. + */ + shadowCameraVisible: boolean; + + /** + * Shadow map bias. + * Default — 0. + */ + shadowBias: number; + + /** + * Darkness of shadow casted by this light (from 0 to 1). + * Default — 0.5. + */ + shadowDarkness: number; + + /** + * Shadow map texture width in pixels. + * Default — 512. + */ + shadowMapWidth: number; + + /** + * Shadow map texture height in pixels. + * Default — 512. + */ + shadowMapHeight: number; + shadowMatrix: Matrix4; + + shadowMapSize: Vector2; + shadowCamera: Camera; + shadowMap: RenderTarget; + } + + // Loaders ////////////////////////////////////////////////////////////////////////////////// + + export interface Progress { + total: number; + loaded: number; + } + + /** + * Base class for implementing loaders. + * + * Events: + * load + * Dispatched when the image has completed loading + * content — loaded image + * + * error + * + * Dispatched when the image can't be loaded + * message — error message + */ + export class Loader { + constructor(showStatus?: boolean); + + /** + * If true, show loading status in the statusDomElement. + */ + showStatus: boolean; + + /** + * This is the recipient of status messages. + */ + statusDomElement: HTMLElement; + + /** + * Will be called when load starts. + * The default is a function with empty body. + */ + onLoadStart: () => void; + + /** + * Will be called while load progresses. + * The default is a function with empty body. + */ + onLoadProgress: () => void; + + /** + * Will be called when load completes. + * The default is a function with empty body. + */ + onLoadComplete: () => void; + + /** + * default — null. + * If set, assigns the crossOrigin attribute of the image to the value of crossOrigin, prior to starting the load. + */ + crossOrigin: string; + + needsTangents(materials: Material[]): boolean; + updateProgress(progress: Progress): void; + createMaterial(m: Material, texturePath: string): boolean; + initMaterials(materials: Material[], texturePath: string): Material[]; + extractUrlBase(url: string): string; + addStatusElement(): HTMLElement; + } + + /** + * A loader for loading an image. + * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. + */ + export class ImageLoader extends EventDispatcher { + constructor(); + crossOrigin: string; + + /** + * Begin loading from url + * @param url + */ + load(url: string, onLoad?: (event: any) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): HTMLImageElement; + setCrossOrigin(crossOrigin: string): void; + } + + + /** + * A loader for loading objects in JSON format. + */ + export class JSONLoader extends Loader { + constructor(showStatus?: boolean); + withCredentials: boolean; + + /** + * @param url + * @param callback. This function will be called with the loaded model as an instance of geometry when the load is completed. + * @param texturePath If not specified, textures will be assumed to be in the same folder as the Javascript model file. + */ + load(url: string, callback: (geometry: Geometry, materials: Material[]) => void , texturePath?: string): void; + parse(json:string, texturePath:string): any; + loadAjaxJSON(context: JSONLoader, url: string, callback: (geometry: Geometry, materials: Material[]) => void , texturePath?: string, callbackProgress?: (progress: Progress) => void ): void; + + } + + /** + * Handles and keeps track of loaded and pending data. + */ + export class LoadingManager { + constructor(onLoad?: (event: any) => void, onProgress?: (event: any) => void, onError?: (event: any) => void); + + /** + * Will be called when load starts. + * The default is a function with empty body. + */ + onLoad: () => void; + + /** + * Will be called while load progresses. + * The default is a function with empty body. + */ + onProgress: (item:any, loaded:number, total:number) => void; + + /** + * Will be called when each element in the scene completes loading. + * The default is a function with empty body. + */ + onError: (event: () => void) => void; + + itemStart(url: string): void; + itemEnd(url: string): void; + + } + + interface SceneLoaderResult{ + scene: Scene; + geometries: {[id:string]:Geometry;}; + face_materials: {[id:string]:Material;}; + materials: {[id:string]:Material;}; + textures: {[id:string]:Texture;}; + objects: {[id:string]:Object3D;}; + cameras: {[id:string]:Camera;}; + lights: {[id:string]:Light;}; + fogs: {[id:string]:IFog;}; + empties: {[id:string]:any;}; + groups: {[id:string]:any;}; + } + + interface SceneLoaderProgress{ + totalModels: number; + totalTextures: number; + loadedModels: number; + loadedTextures: number; + } + + /** + * A loader for loading a complete scene out of a JSON file. + */ + export class SceneLoader { + constructor(); + + /** + * Will be called when load starts. + * The default is a function with empty body. + */ + onLoadStart: () => void; + + /** + * Will be called while load progresses. + * The default is a function with empty body. + */ + onLoadProgress: () => void; + + /** + * Will be called when each element in the scene completes loading. + * The default is a function with empty body. + */ + onLoadComplete: () => void; + + + /** + * Will be called when load completes. + * The default is a function with empty body. + */ + callbackSync: (result: SceneLoaderResult) => void; + + /** + * Will be called as load progresses. + * The default is a function with empty body. + */ + callbackProgress: (progress: SceneLoaderProgress, result: SceneLoaderResult) => void; + hierarchyHandlerMap: any; + geometryHandlerMap: any; + + /** + * @param url + * @param callbackFinished This function will be called with the loaded model as an instance of scene when the load is completed. + */ + load(url: string, callbackFinished: (scene: Scene) => void ): void; + addHierarchyHandler(typeID: string, loaderClass: Object): void; + parse(json: any, callbackFinished: (result: SceneLoaderResult) => void, url: string): void; + addGeometryHandler(typeID: string, loaderClass: Object): void; + } + + /** + * Class for loading a texture. + * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. + */ + export class TextureLoader extends EventDispatcher { + constructor(); + crossOrigin: string; + /** + * Begin loading from url + * + * @param url + */ + load(url: string): void; + } + + // Materials ////////////////////////////////////////////////////////////////////////////////// + + /** + * Materials describe the appearance of objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer. + */ + export class Material { + constructor(); + + /** + * Unique number of this material instance. + */ + id: number; + + /** + * Material name. Default is an empty string. + */ + name: string; + + /** + * Opacity. Default is 1. + */ + opacity: number; + + /** + * Defines whether this material is transparent. This has an effect on rendering, as transparent objects need an special treatment, and are rendered after the opaque (i.e. non transparent) objects. For a working example of this behaviour, check the {@link WebGLRenderer} code. + * Default is false. + */ + transparent: boolean; + + /** + * Which blending to use when displaying objects with this material. Default is {@link NormalBlending}. + */ + blending: Blending; + + /** + * Blending source. It's one of the blending mode constants defined in Three.js. Default is {@link SrcAlphaFactor}. + */ + blendSrc: BlendingDstFactor; + + /** + * Blending destination. It's one of the blending mode constants defined in Three.js. Default is {@link OneMinusSrcAlphaFactor}. + */ + blendDst: BlendingSrcFactor; + + /** + * Blending equation to use when applying blending. It's one of the constants defined in Three.js. Default is AddEquation. + */ + blendEquation: BlendingEquation; + + /** + * Whether to have depth test enabled when rendering this material. Default is true. + */ + depthTest: boolean; + + /** + * Whether rendering this material has any effect on the depth buffer. Default is true. + * When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts. + */ + depthWrite: boolean; + + /** + * Whether to use polygon offset. Default is false. This corresponds to the POLYGON_OFFSET_FILL WebGL feature. + */ + polygonOffset: boolean; + + /** + * Sets the polygon offset factor. Default is 0. + */ + polygonOffsetFactor: number; + + /** + * Sets the polygon offset units. Default is 0. + */ + polygonOffsetUnits: number; + + /** + * Sets the alpha value to be used when running an alpha test. Default is 0. + */ + alphaTest: number; + + /** + * Enables/disables overdraw. If enabled, polygons are drawn slightly bigger in order to fix antialiasing gaps when using the CanvasRenderer. Default is false. + */ + overdraw: boolean; + + /** + * Defines whether this material is visible. Default is true. + */ + visible: boolean; + + /** + * Defines which of the face sides will be rendered - front, back or both. + * Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide. + */ + side: Side; + + /** + * Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL. + * This property is automatically set to true when instancing a new material. + */ + needsUpdate: boolean; + + clone(): Material; + + dispose(): void; + setValues(values: Object): void; + } + + export interface LineBasicMaterialParameters { + color?: number; + linewidth?: number; + linecap?: string; + linejoin?: string; + vertexColors?: Colors; + fog?: boolean; + } + + export class LineBasicMaterial extends Material { + + constructor(parameters?: LineBasicMaterialParameters); + color: Color; + linewidth: number; + linecap: string; + linejoin: string; + vertexColors: Colors; + fog: boolean; + + clone(): LineBasicMaterial; + } + + export interface LineDashedMaterialParameters { + scale?: number; + color?: number; + vertexColors?: boolean; + dashSize?: number; + fog?: boolean; + gapSize?: number; + linewidth?: number; + } + + export class LineDashedMaterial extends Material { + constructor(parameters?: LineDashedMaterialParameters); + scale: number; + color: Color; + vertexColors: boolean; + dashSize: number; + fog: boolean; + gapSize: number; + linewidth: number; + + clone(): LineDashedMaterial; + } + + + /** + * parameters is an object with one or more properties defining the material's appearance. + */ + export interface MeshBasicMaterialParameters { + color?: number; + wireframe?: boolean; + wireframeLinewidth?: number; + wireframeLinecap?: string; + wireframeLinejoin?: string; + shading?: Shading; + vertexColors?: Colors; + fog?: boolean; + lightMap?: Texture; + specularMap?: Texture; + envMap?: Texture; + skinning?: boolean; + morphTargets?: boolean; + map?: Texture; + combine?: Combine; + reflectivity?: number; + refractionRatio?: number; + } + + export class MeshBasicMaterial extends Material { + constructor(parameters?: MeshBasicMaterialParameters); + + color: Color; + wireframe: boolean; + wireframeLinewidth: number; + wireframeLinecap: string; + wireframeLinejoin: string; + shading: Shading; + vertexColors: Colors; + fog: boolean; + lightMap: Texture; + specularMap: Texture; + envMap: Texture; + skinning: boolean; + morphTargets: boolean; + map: Texture; + combine: Combine; + reflectivity: number; + refractionRatio: number; + + clone(): MeshBasicMaterial; + } + + export interface MeshDepthMaterialParameters { + wireframe?: boolean; + wireframeLinewidth?: number; + } + + export class MeshDepthMaterial extends Material { + constructor(parameters?: MeshDepthMaterialParameters); + wireframe: boolean; + wireframeLinewidth: number; + + clone(): MeshDepthMaterial; + } + + export class MeshFaceMaterial extends Material { + constructor(materials?: Material[]); + materials: Material[]; + + clone(): MeshFaceMaterial; + } + + export interface MeshLambertMaterialParameters { + color?: number; + ambient?: number; + emissive?: number; + shading?: Shading; + wireframe?: boolean; + wireframeLinewidth?: number; + wireframeLinecap?: string; + wireframeLinejoin?: string; + vertexColors?: Colors; + fog?: boolean; + map?: Texture; + lightMap?: Texture; + specularMap?: Texture; + envMap?: Texture; + reflectivity?: number; + refractionRatio?: number; + combine?: Combine; + skinning?: boolean; + morphTargets?: boolean; + wrapRGB?: Vector3; + morphNormals?: boolean; + wrapAround?: boolean; + } + + export class MeshLambertMaterial extends Material { + constructor(parameters?: MeshLambertMaterialParameters); + color: Color; + ambient: Color; + emissive: Color; + shading: Shading; + wireframe: boolean; + wireframeLinewidth: number; + wireframeLinecap: string; + wireframeLinejoin: string; + vertexColors: Colors; + fog: boolean; + map: Texture; + lightMap: Texture; + specularMap: Texture; + envMap: Texture; + reflectivity: number; + refractionRatio: number; + combine: Combine; + skinning: boolean; + morphTargets: boolean; + wrapRGB: Vector3; + morphNormals: boolean; + wrapAround: boolean; + + clone(): MeshLambertMaterial; + } + + export interface MeshNormalMaterialParameters { + morphTargets?: boolean; + shading?: Shading; + wireframe?: boolean; + wireframeLinewidth?: number; + } + + export class MeshNormalMaterial extends Material { + constructor(parameters?: MeshNormalMaterialParameters); + morphTargets: boolean; + shading: Shading; + wireframe: boolean; + wireframeLinewidth: number; + + clone(): MeshNormalMaterial; + } + + export interface MeshPhongMaterialParameters { + color?: number; // diffuse + ambient?: number; + emissive?: number; + specular?: number; + shininess?: number; + shading?: Shading; + wireframe?: boolean; + wireframeLinewidth?: number; + wireframeLinecap?: string; + wireframeLinejoin?: string; + vertexColors?: Colors; + fog?: boolean; + map?: Texture; + lightMap?: Texture; + specularMap?: Texture; + envMap?: Texture; + reflectivity?: number; + refractionRatio?: number; + combine?: Combine; + skinning?: boolean; + morphTargets?: boolean; + normalScale?: Vector2; + morphNormals?: boolean; + metal?: boolean; + bumpScale?: number; + wrapAround?: boolean; + perPixel?: boolean; + normalMap?: Texture; + bumpMap?: Texture; + wrapRGB?: Vector3; + } + + export class MeshPhongMaterial extends Material { + constructor(parameters?: MeshPhongMaterialParameters); + color: Color; // diffuse + ambient: Color; + emissive: Color; + specular: Color; + shininess: number; + shading: Shading; + wireframe: boolean; + wireframeLinewidth: number; + wireframeLinecap: string; + wireframeLinejoin: string; + vertexColors: Colors; + fog: boolean; + map: Texture; + lightMap: Texture; + specularMap: Texture; + envMap: Texture; + reflectivity: number; + refractionRatio: number; + combine: Combine; + skinning: boolean; + morphTargets: boolean; + normalScale: Vector2; + morphNormals: boolean; + metal: boolean; + bumpScale: number; + wrapAround: boolean; + + normalMap: Texture; + bumpMap: Texture; + wrapRGB: Vector3; + + clone(): MeshPhongMaterial; + } + + export interface ParticleSystemMaterialParameters { + color?: number; + map?: Texture; + size?: number; + sizeAttenuation?: boolean; + vertexColors?: boolean; + fog?: boolean; + } + + export class ParticleSystemMaterial extends Material { + constructor(parameters?: ParticleSystemMaterialParameters); + color: Color; + map: Texture; + size: number; + sizeAttenuation: boolean; + vertexColors: boolean; + fog: boolean; + + clone(): ParticleSystemMaterial; + } + + export interface Uniforms { + [name: string]: { type: string; value: any; }; + + color?: { type: string; value: THREE.Color; }; + } + + export interface ShaderMaterialParameters { + uniforms?: Uniforms; + fragmentShader?: string; + vertexShader?: string; + morphTargets?: boolean; + lights?: boolean; + morphNormals?: boolean; + wireframe?: boolean; + vertexColors?: Colors; + skinning?: boolean; + fog?: boolean; + attributes?: any; + shading?: Shading; + linewidth?: number; + wireframeLinewidth?: number; + defines?: any; + } + + export class ShaderMaterial extends Material { + constructor(parameters?: ShaderMaterialParameters); + + uniforms: Uniforms; + fragmentShader: string; + vertexShader: string; + morphTargets: boolean; + lights: boolean; + morphNormals: boolean; + wireframe: boolean; + vertexColors: Colors; + skinning: boolean; + fog: boolean; + attributes: any; + shading: Shading; + linewidth: number; + wireframeLinewidth: number; + defines: any; + + clone(): ShaderMaterial; + } + + export interface SpriteMaterialParameters { + map?: Texture; + uvScale?: Vector2; + sizeAttenuation?: boolean; + color?: number; + uvOffset?: Vector2; + fog?: boolean; + useScreenCoordinates?: boolean; + scaleByViewport?: boolean; + alignment?: Vector2; + } + + export class SpriteMaterial extends Material { + constructor(parameters?: SpriteMaterialParameters); + + map: Texture; + uvScale: Vector2; + sizeAttenuation: boolean; + color: Color; + uvOffset: Vector2; + fog: boolean; + useScreenCoordinates: boolean; + scaleByViewport: boolean; + alignment: Vector2; + + clone(): SpriteMaterial; + } + + export interface SpriteCanvasMaterialParameters { + color?: number; + + } + + export class SpriteCanvasMaterial extends Material { + constructor(parameters?: SpriteCanvasMaterialParameters); + + color: Color; + + program(context: any, color: Color): void; + clone(): SpriteCanvasMaterial; + } + + // Math ////////////////////////////////////////////////////////////////////////////////// + + export class Box2 { + constructor(min?: Vector2, max?: Vector2); + max: Vector2; + min: Vector2; + + set(min: Vector2, max: Vector2): Box2; + expandByPoint(point: Vector2): Box2; + clampPoint(point: Vector2, optionalTarget?: Vector2): Vector2; + isIntersectionBox(box: Box2): boolean; + setFromPoints(points: Vector2[]): Box2; + size(optionalTarget?: Vector2): Vector2; + union(box: Box2): Box2; + getParameter(point: Vector2): Vector2; + expandByScalar(scalar: number): Box2; + intersect(box: Box2): Box2; + containsBox(box: Box2): boolean; + translate(offset: Vector2): Box2; + empty(): boolean; + clone(): Box2; + equals(box: Box2): boolean; + expandByVector(vector: Vector2): Box2; + copy(box: Box2): Box2; + makeEmpty(): Box2; + center(optionalTarget?: Vector2): Vector2; + distanceToPoint(point: Vector2): number; + containsPoint(point: Vector2): boolean; + setFromCenterAndSize(center: Vector2, size: number): Box2; + } + + export class Box3 { + constructor(min?: Vector3, max?: Vector3); + max: Vector3; + min: Vector3; + + set(min: Vector3, max: Vector3): Box3; + applyMatrix4(matrix: Matrix4): Box3; + expandByPoint(point: Vector3): Box3; + clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + isIntersectionBox(box: Box3): boolean; + setFromPoints(points: Vector3[]): Box3; + size(optionalTarget?: Vector3): Vector3; + union(box: Box3): Box3; + getParameter(point: Vector3): Vector3; + expandByScalar(scalar: number): Box3; + intersect(box: Box3): Box3; + containsBox(box: Box3): boolean; + translate(offset: Vector3): Box3; + empty(): boolean; + clone(): Box3; + equals(box: Box3): boolean; + expandByVector(vector: Vector3): Box3; + copy(box: Box3): Box3; + makeEmpty(): Box3; + center(optionalTarget?: Vector3): Vector3; + getBoundingSphere(): Sphere; + distanceToPoint(point: Vector3): number; + containsPoint(point: Vector3): boolean; + setFromCenterAndSize(center: Vector3, size: number): Box3; + } + + export interface HSL { + h: number; + s: number; + l: number; + } + + /** + * Represents a color. See also {@link ColorUtils}. + * + * @example + * var color = new THREE.Color( 0xff0000 ); + * + * @see src/math/Color.js + */ + export class Color { + constructor(hex?: string); + + /** + * @param hex initial color in hexadecimal + */ + constructor(hex?: number); + + /** + * Red channel value between 0 and 1. Default is 1. + */ + r: number; + + /** + * Green channel value between 0 and 1. Default is 1. + */ + g: number; + + /** + * Blue channel value between 0 and 1. Default is 1. + */ + b: number; + + /** + * Copies given color. + * @param color Color to copy. + */ + copy(color: Color): Color; + + /** + * Copies given color making conversion from gamma to linear space. + * @param color Color to copy. + */ + copyGammaToLinear(color: Color): Color; + + /** + * Copies given color making conversion from linear to gamma space. + * @param color Color to copy. + */ + copyLinearToGamma(color: Color): Color; + + /** + * Converts this color from gamma to linear space. + */ + convertGammaToLinear(): Color; + + /** + * Converts this color from linear to gamma space. + */ + convertLinearToGamma(): Color; + + /** + * Sets this color from RGB values. + * @param r Red channel value between 0 and 1. + * @param g Green channel value between 0 and 1. + * @param b Blue channel value between 0 and 1. + */ + setRGB(r: number, g: number, b: number): Color; + + /** + * Returns the hexadecimal value of this color. + */ + getHex(): number; + + /** + * Returns the string formated hexadecimal value of this color. + */ + getHexString(): string; + + setHex(hex: number): Color; + + /** + * Sets this color from a CSS context style string. + * @param contextStyle Color in CSS context style format. + */ + setStyle(style: string): Color; + + /** + * Returns the value of this color in CSS context style. + * Example: rgb(r, g, b) + */ + getStyle(): string; + + /** + * Sets this color from HSL values. + * Based on MochiKit implementation by Bob Ippolito. + * + * @param h Hue channel value between 0 and 1. + * @param s Saturation value channel between 0 and 1. + * @param l Value channel value between 0 and 1. + */ + setHSL(h: number, s: number, l: number): Color; + + getHSL(): HSL; + + offsetHSL(h: number, s: number, l: number): Color; + + add(color: Color): Color; + addColors(color1: Color, color2: Color): Color; + addScalar(s: number): Color; + multiply(color: Color): Color; + multiplyScalar(s: number): Color; + lerp(color: Color, alpha: number): Color; + equals(color: Color): boolean; + + /** + * Clones this color. + */ + clone(): Color; + + set(value: number): void; + set(value: string): void; + } + + export class Euler { + constructor(x?: number, y?: number, z?: number, order?: string); + + x: number; + y: number; + z: number; + order: string; + + set(x: number, y: number, z: number, order?: string): Euler; + copy(euler: Euler): Euler; + setFromRotationMatrix(m: Matrix4, order: string): Euler; + setFromQuaternion(q:Quaternion, order: string): Euler; + reorder(newOrder: string): Euler; + fromArray(xyzo: any[]): Euler; + toArray(): any[]; + equals(euler: Euler): boolean; + clone(): Euler; + } + + /** + * Frustums are used to determine what is inside the camera's field of view. They help speed up the rendering process. + */ + export class Frustum { + constructor(p0?: Plane, p1?: Plane, p2?: Plane, p3?: Plane, p4?: Plane, p5?: Plane); + + /** + * Array of 6 vectors. + */ + planes: Plane[]; + + setFromMatrix(m: Matrix4): Frustum; + intersectsObject(object: Object3D): boolean; + clone(): Frustum; + set(p0?: number, p1?: number, p2?: number, p3?: number, p4?: number, p5?: number): Frustum; + copy(frustum: Frustum): Frustum; + containsPoint(point: Vector3): boolean; + intersectsSphere(sphere: Sphere): boolean; + } + + export class Line3 { + constructor(start?: Vector3, end?: Vector3); + start: Vector3; + end: Vector3; + + set(start?: Vector3, end?: Vector3): Line3; + copy(line: Line3): Line3; + clone(): Line3; + equals(line: Line3): boolean; + distance(): number; + distanceSq(): number; + applyMatrix4(matrix: Matrix4): Line3; + at(t: number, optionalTarget?: Vector3): Vector3; + center(optionalTarget?: Vector3): Vector3; + delta(optionalTarget?: Vector3): Vector3; + closestPointToPoint(point: Vector3, clampToLine?: boolean, optionalTarget?: Vector3): Vector3; + closestPointToPointParameter(point: Vector3, clampToLine?: boolean): number; + } + + interface Math { + /** + * Clamps the x to be between a and b. + * + * @param x Value to be clamped. + * @param a Minimum value + * @param b Maximum value. + */ + clamp(x: number, a: number, b: number): number; + + /** + * Clamps the x to be larger than a. + * + * @param x — Value to be clamped. + * @param a — Minimum value + */ + clampBottom(x: number, a: number): number; + + /** + * Linear mapping of x from range [a1, a2] to range [b1, b2]. + * + * @param x Value to be mapped. + * @param a1 Minimum value for range A. + * @param a2 Maximum value for range A. + * @param b1 Minimum value for range B. + * @param b2 Maximum value for range B. + */ + mapLinear(x: number, a1: number, a2: number, b1: number, b2: number): number; + + /** + * Random float from 0 to 1 with 16 bits of randomness. + * Standard Math.random() creates repetitive patterns when applied over larger space. + */ + random16(): number; + + /** + * Random integer from low to high interval. + */ + randInt(low: number, high: number): number; + + /** + * Random float from low to high interval. + */ + randFloat(low: number, high: number): number; + + /** + * Random float from - range / 2 to range / 2 interval. + */ + randFloatSpread(range: number): number; + + /** + * Returns -1 if x is less than 0, 1 if x is greater than 0, and 0 if x is zero. + */ + sign(x: number): number; + + degToRad(degrees: number): number; + + radToDeg(radians: number): number; + + smoothstep(x: number, min: number, max: number): number; + + smootherstep(x: number, min: number, max: number): number; + } + + /** + * + * @see src/math/Math.js + */ + export var Math: Math; + + /** + * ( interface Matrix<T> ) + */ + export interface Matrix { + /** + * Float32Array with matrix values. + */ + elements: Float32Array; + + /** + * identity():T; + */ + identity(): Matrix; + + /** + * copy(m:T):T; + */ + copy(m: Matrix): Matrix; + + multiplyVector3Array(a: number[]): number[]; + + /** + * multiplyScalar(s:number):T; + */ + multiplyScalar(s: number): Matrix; + + determinant(): number; + + /** + * getInverse(matrix:T, throwOnInvertible?:boolean):T; + */ + getInverse(matrix: Matrix, throwOnInvertible?: boolean): Matrix; + + /** + * transpose():T; + */ + transpose(): Matrix; + + /** + * clone():T; + */ + clone(): Matrix; + } + + /** + * ( class Matrix3 implements Matrix<Matrix3> ) + */ + export class Matrix3 implements Matrix { + /** + * Creates an identity matrix. + */ + constructor(); + + /** + * Initialises the matrix with the supplied n11..n33 values. + */ + constructor(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number); + + /** + * Float32Array with matrix values. + */ + elements: Float32Array; + + /** + * Transposes this matrix in place. + */ + transpose(): Matrix3; + + /** + * Transposes this matrix into the supplied array r, and returns itself. + */ + transposeIntoArray(r: number[]): number[]; + + determinant(): number; + set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; + multiplyScalar(s: number): Matrix3; + multiplyVector3Array(a: number[]): number[]; + getNormalMatrix(m: Matrix4): Matrix3; + getInverse(matrix: Matrix3, throwOnInvertible?: boolean): Matrix3; + getInverse(matrix: Matrix4, throwOnInvertible?: boolean): Matrix3; + copy(m: Matrix3): Matrix3; + clone(): Matrix3; + identity(): Matrix3; + } + + /** + * A 4x4 Matrix. + * + * @example + * // Simple rig for rotating around 3 axes + * var m = new THREE.Matrix4(); + * var m1 = new THREE.Matrix4(); + * var m2 = new THREE.Matrix4(); + * var m3 = new THREE.Matrix4(); + * var alpha = 0; + * var beta = Math.PI; + * var gamma = Math.PI/2; + * m1.makeRotationX( alpha ); + * m2.makeRotationY( beta ); + * m3.makeRotationZ( gamma ); + * m.multiplyMatrices( m1, m2 ); + * m.multiply( m3 ); + */ + export class Matrix4 implements Matrix { + + /** + * Creates an identity matrix. + */ + constructor(); + + + /** + * Initialises the matrix with the supplied n11..n44 values. + */ + constructor(n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number); + + /** + * Float32Array with matrix values. + */ + elements: Float32Array; + + /** + * Sets all fields of this matrix. + */ + set(n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number): Matrix4; + + /** + * Resets this matrix to identity. + */ + identity(): Matrix4; + + /** + * Copies a matrix m into this matrix. + */ + copy(m: Matrix4): Matrix4; + copyPosition(m: Matrix4): Matrix4; + + /** + * Copies the rotation component of the supplied matrix m into this matrix rotation component. + */ + extractRotation(m: Matrix4): Matrix4; + + /** + * Constructs a rotation matrix, looking from eye towards center with defined up vector. + */ + lookAt(eye: Vector3, target: Vector3, up: Vector3): Matrix4; + + /** + * Multiplies this matrix by m. + */ + multiply(m: Matrix4): Matrix4; + + /** + * Sets this matrix to a x b. + */ + multiplyMatrices(a: Matrix4, b: Matrix4): Matrix4; + + /** + * Sets this matrix to a x b and stores the result into the flat array r. + * r can be either a regular Array or a TypedArray. + */ + multiplyToArray(a: Matrix4, b: Matrix4, r: number[]): Matrix4; + + /** + * Multiplies this matrix by s. + */ + multiplyScalar(s: number): Matrix4; + + /** + * Computes determinant of this matrix. + * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm + */ + determinant(): number; + + /** + * Transposes this matrix. + */ + transpose(): Matrix4; + + /** + * Flattens this matrix into supplied flat array. + */ + flattenToArray(flat: number[]): number[]; + + /** + * Flattens this matrix into supplied flat array starting from offset position in the array. + */ + flattenToArrayOffset(flat: number[], offset: number): number[]; + + /** + * Sets the position component for this matrix from vector v. + */ + setPosition(v: Vector3): Vector3; + + /** + * Sets this matrix to the inverse of matrix m. + * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm. + */ + getInverse(m: Matrix4, throwOnInvertible?: boolean): Matrix4; + + makeRotationFromEuler(euler: Euler): Matrix4; + makeRotationFromQuaternion(q: Quaternion): Matrix4; + + /** + * Multiplies the columns of this matrix by vector v. + */ + scale(v: Vector3): Matrix4; + + /** + * Sets this matrix to the transformation composed of translation, rotation and scale. + */ + compose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4; + + /** + * Decomposes this matrix into the translation, rotation and scale components. + * If parameters are not passed, new instances will be created. + */ + decompose(translation?: Vector3, rotation?: Quaternion, scale?: Vector3): Object[]; // [Vector3, Quaternion, Vector3] + + /** + * Sets this matrix as translation transform. + */ + makeTranslation(x: number, y: number, z: number): Matrix4; + + /** + * Sets this matrix as rotation transform around x axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationX(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around y axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationY(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around z axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationZ(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around axis by angle radians. + * Based on http://www.gamedev.net/reference/articles/article1199.asp. + * + * @param axis Rotation axis. + * @param theta Rotation angle in radians. + */ + makeRotationAxis(axis: Vector3, angle: number): Matrix4; + + /** + * Sets this matrix as scale transform. + */ + makeScale(x: number, y: number, z: number): Matrix4; + + /** + * Creates a frustum matrix. + */ + makeFrustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4; + + /** + * Creates a perspective projection matrix. + */ + makePerspective(fov: number, aspect: number, near: number, far: number): Matrix4; + + /** + * Creates an orthographic projection matrix. + */ + makeOrthographic(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4; + + /** + * Clones this matrix. + */ + clone(): Matrix4; + + multiplyVector3Array(a: number[]): number[]; + getMaxScaleOnAxis(): number; + } + + export class Plane { + constructor(normal?: Vector3, constant?: number); + + normal: Vector3; + constant: number; + + normalize(): Plane; + set(normal: Vector3, constant: number): Plane; + copy(plane: Plane): Plane; + applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane; + orthoPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + isIntersectionLine(line: Line3): boolean; + intersectLine(line: Line3, optionalTarget?: Vector3): Vector3; + setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; + clone(): Plane; + distanceToPoint(point: Vector3): number; + equals(plane: Plane): boolean; + setComponents(x: number, y: number, z: number, w: number): Plane; + distanceToSphere(sphere: Sphere): number; + setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; + projectPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + negate(): Plane; + translate(offset: Vector3): Plane; + coplanarPoint(optionalTarget?: boolean): Vector3; + } + + /** + * Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages. + * + * @example + * var quaternion = new THREE.Quaternion(); + * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 ); + * var vector = new THREE.Vector3( 1, 0, 0 ); + * vector.applyQuaternion( quaternion ); + */ + export class Quaternion { + /** + * @param x x coordinate + * @param y y coordinate + * @param z z coordinate + * @param w w coordinate + */ + constructor(x?: number, y?: number, z?: number, w?: number); + + x: number; + y: number; + z: number; + w: number; + + /** + * Sets values of this quaternion. + */ + set(x: number, y: number, z: number, w: number): Quaternion; + + /** + * Copies values of q to this quaternion. + */ + copy(q: Quaternion): Quaternion; + setFromEuler(euler: Euler, update?: boolean): Quaternion; + /** + * Sets this quaternion from rotation specified by Euler angles. + */ + setFromEuler(v: Vector3, order: string): Quaternion; + + /** + * Sets this quaternion from rotation specified by axis and angle. + * Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm. + * Axis have to be normalized, angle is in radians. + */ + setFromAxisAngle(axis: Vector3, angle: number): Quaternion; + + /** + * Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm. + */ + setFromRotationMatrix(m: Matrix4): Quaternion; + + /** + * Inverts this quaternion. + */ + inverse(): Quaternion; + /** + * Computes length of this quaternion. + */ + length(): number; + + /** + * Normalizes this quaternion. + */ + normalize(): Quaternion; + + /** + * Multiplies this quaternion by b. + */ + multiply(q: Quaternion): Quaternion; + + /** + * Sets this quaternion to a x b + * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm. + */ + multiplyQuaternions(a: Quaternion, b: Quaternion): Quaternion; + + multiplyVector3(vector: Vector3, dest: Vector3): Quaternion; + + /** + * Clones this quaternion. + */ + clone(): Quaternion; + + /** + * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/. + */ + static slerp(qa: Quaternion, qb: Quaternion, qm: Quaternion, t: number): Quaternion; + + slerp(qb: Quaternion, t: number): Quaternion; + + toArray(): number[]; + + equals(v: Quaternion): boolean; + + lengthSq(): number; + + fromArray(n: number[]): Quaternion; + + conjugate(): Quaternion; + } + + export class Ray { + constructor(origin?: Vector3, direction?: Vector3); + + origin: Vector3; + direction: Vector3; + + applyMatrix4(matrix4: Matrix4): Ray; + at(t: number, optionalTarget?: Vector3): Vector3; + clone(): Ray; + closestPointToPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + copy(ray: Ray): Ray; + distanceSqToSegment(v0: Vector3, v1: Vector3, optionalPointOnRay?: Vector3, optionalPointOnSegment?: Vector3): number; + distanceToPlane(plane: Plane): number; + distanceToPoint(point: Vector3): number; + equals(ray: Ray): boolean; + intersectBox(box: Box3, optionalTarget?: Vector3): Vector3; + intersectPlane(plane: Plane, optionalTarget?: Vector3): Vector3; + intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, optionalTarget?: Vector3): Vector3; + isIntersectionBox(box: Box3): boolean; + isIntersectionPlane(plane: Plane): boolean; + isIntersectionSphere(sphere: Sphere): boolean; + recast(t: number): Ray; + set(origin: Vector3, direction: Vector3): Ray; + } + + export class Sphere { + constructor(center?: Vector3, radius?: number); + + center: Vector3; + radius: number; + + set(center: Vector3, radius: number): Sphere; + applyMatrix4(matrix: Matrix4): Sphere; + clampPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + translate(offset: Vector3): Sphere; + clone(): Sphere; + equals(sphere: Sphere): boolean; + setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere; + distanceToPoint(point: Vector3): number; + getBoundingBox(optionalTarget?: Box3): Box3; + containsPoint(point: Vector3): boolean; + copy(sphere: Sphere): Sphere; + intersectsSphere(sphere: Sphere): boolean; + empty(): boolean; + } + + export interface SplineControlPoint { + x: number; + y: number; + z: number; + } + + /** + * Represents a spline. + * + * @see src/math/Spline.js + */ + export class Spline { + /** + * Initialises the spline with points, which are the places through which the spline will go. + */ + constructor(points: SplineControlPoint[]); + + points: SplineControlPoint[]; + + /** + * Initialises using the data in the array as a series of points. Each value in a must be another array with three values, where a[n] is v, the value for the nth point, and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively. + * + * @param a array of triplets containing x, y, z coordinates + */ + initFromArray(a: number[][]): void; + + /** + * Return the interpolated point at k. + * + * @param k point index + */ + getPoint(k: number): SplineControlPoint; + + /** + * Returns an array with triplets of x, y, z coordinates that correspond to the current control points. + */ + getControlPointsArray(): number[][]; + + /** + * Returns the length of the spline when using nSubDivisions. + * @param nSubDivisions number of subdivisions between control points. Default is 100. + */ + getLength(nSubDivisions?: number): { chunks: number[]; total: number; }; + + /** + * Modifies the spline so that it looks similar to the original but has its points distributed in such way that moving along the spline it's done at a more or less constant speed. The points should also appear more uniformly spread along the curve. + * This is done by resampling the original spline, with the density of sampling controlled by samplingCoef. Here it's interesting to note that denser sampling is not necessarily better: if sampling is too high, you may get weird kinks in curvature. + * + * @param samplingCoef how many intermediate values to use between spline points + */ + reparametrizeByArcLength(samplingCoef: number): void; + } + + class Triangle { + constructor(a?: Vector3, b?: Vector3, c?: Vector3); + + a: Vector3; + b: Vector3; + c: Vector3; + + setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): Triangle; + set(a: Vector3, b: Vector3, c: Vector3): Triangle; + normal(optionalTarget?: Vector3): Vector3; + barycoordFromPoint(point: Vector3, optionalTarget?: Vector3): Vector3; + clone(): Triangle; + area(): number; + midpoint(optionalTarget?: Vector3): Vector3; + equals(triangle: Triangle): boolean; + plane(optionalTarget?: Vector3): Plane; + containsPoint(point: Vector3): boolean; + copy(triangle: Triangle): Triangle; + + static normal(a: Vector3, b: Vector3, c: Vector3, optionalTarget?: Vector3): Vector3; + static barycoordFromPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3, optionalTarget: Vector3): Vector3; + static containsPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3): boolean; + } + + + /** + * ( interface Vector<T> ) + * + * Abstruct interface of Vector2, Vector3 and Vector4. + * Currently the members of Vector is NOT type safe because it accepts different typed vectors. + * Those definitions will be changed when TypeScript innovates Generics to be type safe. + * + * @example + * var v:THREE.Vector = new THREE.Vector3(); + * v.addVectors(new THREE.Vector2(0, 1), new THREE.Vector2(2, 3)); // invalid but compiled successfully + */ + export interface Vector { + setComponent(index: number, value: number): void; + + getComponent(index: number): number; + + /** + * copy(v:T):T; + */ + copy(v: Vector): Vector; + + /** + * add(v:T):T; + */ + add(v: Vector): Vector; + + /** + * addVectors(a:T, b:T):T; + */ + addVectors(a: Vector, b: Vector): Vector; + + /** + * sub(v:T):T; + */ + sub(v: Vector): Vector; + + /** + * subVectors(a:T, b:T):T; + */ + subVectors(a: Vector, b: Vector): Vector; + + /** + * multiplyScalar(s:number):T; + */ + multiplyScalar(s: number): Vector; + + /** + * divideScalar(s:number):T; + */ + divideScalar(s: number): Vector; + + /** + * negate():T; + */ + negate(): Vector; + + /** + * dot(v:T):T; + */ + dot(v: Vector): number; + + /** + * lengthSq():number; + */ + lengthSq(): number; + + /** + * length():number; + */ + length(): number; + + /** + * normalize():T; + */ + normalize(): Vector; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceTo(v:T):number; + */ + distanceTo(v: Vector): number; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceToSquared(v:T):number; + */ + distanceToSquared(v: Vector): number; + + /** + * setLength(l:number):T; + */ + setLength(l: number): Vector; + + /** + * lerp(v:T, alpha:number):T; + */ + lerp(v: Vector, alpha: number): Vector; + + /** + * equals(v:T):boolean; + */ + equals(v: Vector): boolean; + + /** + * clone():T; + */ + clone(): Vector; + } + + /** + * 2D vector. + * + * ( class Vector2 implements Vector ) + */ + export class Vector2 implements Vector { + constructor(x?: number, y?: number); + + x: number; + y: number; + + /** + * Sets value of this vector. + */ + set(x: number, y: number): Vector2; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector2): Vector2; + + /** + * Adds v to this vector. + */ + add(v: Vector2): Vector2; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector2, b: Vector2): Vector2; + + /** + * Subtracts v from this vector. + */ + sub(v: Vector2): Vector2; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector2, b: Vector2): Vector2; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(s: number): Vector2; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0 ) if s == 0. + */ + divideScalar(s: number): Vector2; + + /** + * Inverts this vector. + */ + negate(): Vector2; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector2): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * Normalizes this vector. + */ + normalize(): Vector2; + + /** + * Computes distance of this vector to v. + */ + distanceTo(v: Vector2): number; + + /** + * Computes squared distance of this vector to v. + */ + distanceToSquared(v: Vector2): number; + + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(l: number): Vector2; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector2): boolean; + + /** + * Clones this vector. + */ + clone(): Vector2; + + clamp(min: Vector2, max: Vector2): Vector2; + clampScalar(min: number, max: number): Vector2; + floor(): Vector2; + ceil(): Vector2; + round(): Vector2; + roundToZero(): Vector2; + lerp(v: Vector2, alpha: number): Vector2; + + /** + * Sets a component of this vector. + */ + setComponent(index: number, value: number): void; + + addScalar(s: number): Vector2; + + /** + * Gets a component of this vector. + */ + getComponent(index: number): number; + + fromArray(xy: number[]): Vector2; + + toArray(): number[]; + + min(v: Vector2): Vector2; + + max(v: Vector2): Vector2; + + /** + * Sets X component of this vector. + */ + setX(x: number): Vector2; + + /** + * Sets Y component of this vector. + */ + setY(y: number): Vector2; + } + + /** + * 3D vector. + * + * @example + * var a = new THREE.Vector3( 1, 0, 0 ); + * var b = new THREE.Vector3( 0, 1, 0 ); + * var c = new THREE.Vector3(); + * c.crossVectors( a, b ); + * + * @see src/math/Vector3.js + * + * ( class Vector3 implements Vector ) + */ + export class Vector3 implements Vector { + + constructor(x?: number, y?: number, z?: number); + + x: number; + y: number; + z: number; + + /** + * Sets value of this vector. + */ + set(x: number, y: number, z: number): Vector3; + + /** + * Sets x value of this vector. + */ + setX(x: number): Vector3; + + /** + * Sets y value of this vector. + */ + setY(y: number): Vector3; + + /** + * Sets z value of this vector. + */ + setZ(z: number): Vector3; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector3): Vector3; + + /** + * Adds v to this vector. + */ + add(a: Object): Vector3; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector3, b: Vector3): Vector3; + + /** + * Subtracts v from this vector. + */ + sub(a: Vector3): Vector3; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector3, b: Vector3): Vector3; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(s: number): Vector3; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0, 0 ) if s == 0. + */ + divideScalar(s: number): Vector3; + + /** + * Inverts this vector. + */ + negate(): Vector3; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector3): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * Computes Manhattan length of this vector. + * http://en.wikipedia.org/wiki/Taxicab_geometry + */ + lengthManhattan(): number; + + /** + * Normalizes this vector. + */ + normalize(): Vector3; + + /** + * Computes distance of this vector to v. + */ + distanceTo(v: Vector3): number; + + /** + * Computes squared distance of this vector to v. + */ + distanceToSquared(v: Vector3): number; + + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(l: number): Vector3; + + /** + * Sets this vector to cross product of itself and v. + */ + cross(a: Vector3): Vector3; + + /** + * Sets this vector to cross product of a and b. + */ + crossVectors(a: Vector3, b: Vector3): Vector3; + + setFromMatrixPosition(m: Matrix4): Vector3; + setFromMatrixScale(m: Matrix4): Vector3; + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector3): boolean; + /** + * Clones this vector. + */ + clone(): Vector3; + clamp(min: Vector3, max: Vector3): Vector3; + clampScalar(min: number, max: number): Vector3; + floor(): Vector3; + ceil(): Vector3; + round(): Vector3; + roundToZero(): Vector3; + applyMatrix3(m: Matrix3): Vector3; + applyMatrix4(m: Matrix4): Vector3; + projectOnPlane(planeNormal: Vector3): Vector3; + projectOnVector(v: Vector3): Vector3; + addScalar(s: number): Vector3; + divide(v: Vector3): Vector3; + min(v: Vector3): Vector3; + max(v: Vector3): Vector3; + setComponent(index: number, value: number): void; + transformDirection(m: Matrix4): Vector3; + multiplyVectors(a: Vector3, b: Vector3): Vector3; + getComponent(index: number): number; + applyAxisAngle(axis: Vector3, angle: number): Vector3; + lerp(v: Vector3, alpha: number): Vector3; + angleTo(v: Vector3): number; + setFromMatrixColumn(index: number, matrix: Matrix4): Vector3; + reflect(vector: Vector3): Vector3; + fromArray(xyz: number[]): Vector3; + multiply(v: Vector3): Vector3; + applyProjection(m: Matrix4): Vector3; + toArray(): number[]; + applyEuler(euler: Euler): Vector3; + applyQuaternion(q: Quaternion): Vector3; + } + + /** + * 4D vector. + * + * ( class Vector4 implements Vector ) + */ + export class Vector4 implements Vector { + constructor(x?: number, y?: number, z?: number, w?: number); + x: number; + y: number; + z: number; + w: number; + + /** + * Sets value of this vector. + */ + set(x: number, y: number, z: number, w: number): Vector4; + /** + * Copies value of v to this vector. + */ + copy(v: Vector4): Vector4; + + /** + * Adds v to this vector. + */ + add(v: Vector4): Vector4; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector4, b: Vector4): Vector4; + + /** + * Subtracts v from this vector. + */ + sub(v: Vector4): Vector4; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector4, b: Vector4): Vector4; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(s: number): Vector4; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0, 0 ) if s == 0. + */ + divideScalar(s: number): Vector4; + /** + * Inverts this vector. + */ + negate(): Vector4; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector4): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * Normalizes this vector. + */ + normalize(): Vector4; + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(l: number): Vector4; + + /** + * Linearly interpolate between this vector and v with alpha factor. + */ + lerp(v: Vector4, alpha: number): Vector4; + /** + * Clones this vector. + */ + clone(): Vector4; + clamp(min: Vector4, max: Vector4): Vector4; + clampScalar(min: number, max: number): Vector4; + floor(): Vector4; + ceil(): Vector4; + round(): Vector4; + roundToZero(): Vector4; + applyMatrix4(m: Matrix4): Vector4; + min(v: Vector4): Vector4; + max(v: Vector4): Vector4; + addScalar(s: number): Vector4; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector4): boolean; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm + * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + */ + setAxisAngleFromRotationMatrix(m: Matrix3): Vector4; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + * @param q is assumed to be normalized + */ + setAxisAngleFromQuaternion(q: Quaternion): Vector4; + + getComponent(index: number): number; + setComponent(index: number, value: number): void; + fromArray(xyzw: number[]): number[]; + toArray(): number[]; + lengthManhattan(): number; + /** + * Sets X component of this vector. + */ + setX(x: number): Vector2; + + /** + * Sets Y component of this vector. + */ + setY(y: number): Vector2; + + /** + * Sets Z component of this vector. + */ + setZ(z: number): Vector2; + + /** + * Sets w component of this vector. + */ + setW(w: number): Vector2; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceToSquared(v:T):number; + */ + distanceTo(v: Vector): number; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceToSquared(v:T):number; + */ + distanceToSquared(v: Vector): number; + } + + // Objects ////////////////////////////////////////////////////////////////////////////////// + + export class Bone extends Object3D { + constructor(belongsToSkin: SkinnedMesh); + + skinMatrix: Matrix4; + skin: SkinnedMesh; + update(parentSkinMatrix?: Matrix4, forceUpdate?: boolean): void; + } + + export class Line extends Object3D { + constructor(geometry?: Geometry, material?: LineDashedMaterial, type?: number); + constructor(geometry?: Geometry, material?: LineBasicMaterial, type?: number); + constructor(geometry?: Geometry, material?: ShaderMaterial, type?: number); + constructor(geometry?: BufferGeometry, material?: LineDashedMaterial, type?: number); + constructor(geometry?: BufferGeometry, material?: LineBasicMaterial, type?: number); + constructor(geometry?: BufferGeometry, material?: ShaderMaterial, type?: number); + geometry: Geometry; + material: Material; + type: LineType; + clone(object?: Line): Line; + } + + enum LineType{} + var LineStrip: LineType; + var LinePieces: LineType; + + export class LOD extends Object3D { + constructor(); + + objects: any[]; + addLevel(object: Object3D, distance?: number): void; + getObjectForDistance(distance: number): Object3D; + update(camera: Camera): void; + clone(): LOD; + } + + export class Mesh extends Object3D { + constructor(geometry?: Geometry, material?: Material); + constructor(geometry?: BufferGeometry, material?: Material); + + geometry: Geometry; + material: Material; + + getMorphTargetIndexByName(name: string): number; + updateMorphTargets(): void; + clone(object?: Mesh): Mesh; + } + + export class MorphAnimMesh extends Mesh { + constructor(geometry?: Geometry, material?: MeshBasicMaterial); + constructor(geometry?: Geometry, material?: MeshDepthMaterial); + constructor(geometry?: Geometry, material?: MeshFaceMaterial); + constructor(geometry?: Geometry, material?: MeshLambertMaterial); + constructor(geometry?: Geometry, material?: MeshNormalMaterial); + constructor(geometry?: Geometry, material?: MeshPhongMaterial); + constructor(geometry?: Geometry, material?: ShaderMaterial); + + directionBackwards: boolean; + direction: number; + endKeyframe: number; + mirroredLoop: boolean; + startKeyframe: number; + lastKeyframe: number; + length: number; + time: number; + duration: number; // milliseconds + currentKeyframe: number; + + setDirectionForward(): void; + playAnimation(label: string, fps: number): void; + setFrameRange(start: number, end: number): void; + setDirectionBackward(): void; + parseAnimations(): void; + updateAnimation(delta: number): void; + setAnimationLabel(label: string, start: number, end: number): void; + + clone(object?: MorphAnimMesh): MorphAnimMesh; + } + + /** + * A class for displaying particles in the form of variable size points. For example, if using the WebGLRenderer, the particles are displayed using GL_POINTS. + * + * @see src/objects/ParticleSystem.js + */ + export class ParticleSystem extends Object3D { + + /** + * @param geometry An instance of Geometry. + * @param material An instance of Material (optional). + */ + constructor(geometry: Geometry, material?: ParticleSystemMaterial); + constructor(geometry: Geometry, material?: ShaderMaterial); + constructor(geometry: BufferGeometry, material?: ParticleSystemMaterial); + constructor(geometry: BufferGeometry, material?: ShaderMaterial); + + /** + * An instance of Geometry, where each vertex designates the position of a particle in the system. + */ + geometry: Geometry; + + /** + * An instance of Material, defining the object's appearance. Default is a ParticleBasicMaterial with randomised colour. + */ + material: Material; + + /** + * Specifies whether the particle system will be culled if it's outside the camera's frustum. By default this is set to false. + */ + frustrumCulled: boolean; + + sortParticles: boolean; + + clone(object?: ParticleSystem): ParticleSystem; + } + + export class SkinnedMesh extends Mesh { + constructor(geometry?: Geometry, material?: MeshBasicMaterial, useVertexTexture?: boolean); + constructor(geometry?: Geometry, material?: MeshDepthMaterial, useVertexTexture?: boolean); + constructor(geometry?: Geometry, material?: MeshFaceMaterial, useVertexTexture?: boolean); + constructor(geometry?: Geometry, material?: MeshLambertMaterial, useVertexTexture?: boolean); + constructor(geometry?: Geometry, material?: MeshNormalMaterial, useVertexTexture?: boolean); + constructor(geometry?: Geometry, material?: MeshPhongMaterial, useVertexTexture?: boolean); + constructor(geometry?: Geometry, material?: ShaderMaterial, useVertexTexture?: boolean); + + bones: Bone[]; + identityMatrix: Matrix4; + useVertexTexture: boolean; + boneMatrices: Float32Array; + + pose(): void; + addBone(bone?: Bone): Bone; + clone(object?: SkinnedMesh): SkinnedMesh; + } + + export class Sprite extends Object3D { + constructor(material?: Material); + + material: Material; + + updateMatrix(): void; + clone(object?: Sprite): Sprite; + } + + + // Renderers ////////////////////////////////////////////////////////////////////////////////// + + export interface Renderer { + render(scene: Scene, camera: Camera): void; + } + + export interface CanvasRendererParameters { + canvas?: HTMLCanvasElement; + devicePixelRatio?: number; + } + + export class CanvasRenderer implements Renderer { + constructor(parameters?: CanvasRendererParameters); + + info: { render: { vertices: number; faces: number; }; }; + domElement: HTMLCanvasElement; + devicePixelRatio: number; + autoClear: boolean; + sortObjects: boolean; + sortElements: boolean; + + getMaxAnisotropy(): number; + render(scene: Scene, camera: Camera): void; + clear(): void; + setClearColor(color: Color, opacity?: number): void; + setFaceCulling(): void; + supportsVertexTextures(): void; + setSize(width: number, height: number, updateStyle?: boolean): void; + setClearColorHex(hex: number, alpha?: number): void; + } + + export interface RendererPlugin { + init(renderer: WebGLRenderer): void; + render(scene: Scene, camera: Camera, currentWidth: number, currentHeight: number): void; + } + + export interface WebGLRendererParameters { + /** + * A Canvas where the renderer draws its output. + */ + canvas?: HTMLCanvasElement; + + /** + * shader precision. Can be "highp", "mediump" or "lowp". + */ + precision?: string; + + /** + * default is true. + */ + alpha?: boolean; + + /** + * default is true. + */ + premultipliedAlpha?: boolean; + + /** + * default is false. + */ + antialias?: boolean; + + /** + * default is true. + */ + stencil?: boolean; + + /** + * default is false. + */ + preserveDrawingBuffer?: boolean; + + /** + * default is 0x000000. + */ + clearColor?: number; + + /** + * default is 0. + */ + clearAlpha?: number; + + devicePixelRatio?: number; + } + + + /** + * The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it. + * This renderer has way better performance than CanvasRenderer. + * + * @see src/renderers/WebGLRenderer.js + */ + export class WebGLRenderer implements Renderer { + /** + * parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing. + */ + constructor(parameters?: WebGLRendererParameters); + + /** + * A Canvas where the renderer draws its output. + * This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page. + */ + domElement: HTMLCanvasElement; + + /** + * The HTML5 Canvas's 'webgl' context obtained from the canvas where the renderer will draw. + */ + // If you are using three.d.ts with other complete definitions of webgl, context:WebGLRenderingContext is suitable. + //context:WebGLRenderingContext; + context: any; + + /** + * Defines whether the renderer should automatically clear its output before rendering. + */ + autoClear: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the color buffer. Default is true. + */ + autoClearColor: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true. + */ + autoClearDepth: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true. + */ + autoClearStencil: boolean; + + /** + * Defines whether the renderer should sort objects. Default is true. + */ + sortObjects: boolean; + + /** + * Defines whether the renderer should auto update objects. Default is true. + */ + autoUpdateObjects: boolean; + + /** + * Default is false. + */ + gammaInput: boolean; + + /** + * Default is false. + */ + gammaOutput: boolean; + + /** + * Default is false. + */ + shadowMapEnabled: boolean; + + /** + * Default is true. + */ + shadowMapAutoUpdate: boolean; + + /** + * Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader) + * Options are THREE.BasicShadowMap, THREE.PCFShadowMap, THREE.PCFSoftShadowMap. Default is THREE.PCFShadowMap. + */ + shadowMapType: ShadowMapType; + + /** + * Default is true + */ + shadowMapCullFace: CullFace; + + /** + * Default is false. + */ + shadowMapDebug: boolean; + + /** + * Default is false. + */ + shadowMapCascade: boolean; + + /** + * Default is 8. + */ + maxMorphTargets: number; + + /** + * Default is 4. + */ + maxMorphNormals: number; + + /** + * Default is true. + */ + autoScaleCubemaps: boolean; + + /** + * An array with render plugins to be applied before rendering. + * Default is an empty array, or []. + */ + renderPluginsPre: RendererPlugin[]; + + /** + * An array with render plugins to be applied after rendering. + * Default is an empty array, or []. + */ + renderPluginsPost: RendererPlugin[]; + + /** + * An object with a series of statistical information about the graphics board memory and the rendering process. Useful for debugging or just for the sake of curiosity. The object contains the following fields: + */ + info: { + memory: { + programs: number; + geometries: number; + textures: number; + }; + render: { + calls: number; + vertices: number; + faces: number; + points: number; + }; + }; + + shadowMapPlugin: ShadowMapPlugin; + devicePixelRatio: number; + + /** + * Return the WebGL context. + */ + getContext(): WebGLRenderingContext; + + /** + * Return a Boolean true if the context supports vertex textures. + */ + supportsVertexTextures(): boolean; + + /** + * Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0). + */ + setSize(width: number, height: number): void; + + /** + * Sets the viewport to render from (x, y) to (x + width, y + height). + */ + setViewport(x?: number, y?: number, width?: number, height?: number): void; + + /** + * Sets the scissor area from (x, y) to (x + width, y + height). + */ + setScissor(x: number, y: number, width: number, height: number): void; + + /** + * Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions. + */ + enableScissorTest(enable: boolean): void; + + /** + * Sets the clear color, using color for the color and alpha for the opacity. + */ + setClearColor(color: Color, alpha: number): void; + + /** + * Returns a THREE.Color instance with the current clear color. + */ + getClearColor(): Color; + + /** + * Returns a float with the current clear alpha. Ranges from 0 to 1. + */ + getClearAlpha(): number; + + /** + * Tells the renderer to clear its color, depth or stencil drawing buffer(s). + * If no parameters are passed, no buffer will be cleared. + */ + clear(color?: boolean, depth?: boolean, stencil?: boolean): void; + + /** + * Initialises the postprocessing plugin, and adds it to the renderPluginsPost array. + */ + addPostPlugin(plugin: RendererPlugin): void; + + /** + * Initialises the preprocessing plugin, and adds it to the renderPluginsPre array. + */ + addPrePlugin(plugin: RendererPlugin): void; + + /** + * Tells the shadow map plugin to update using the passed scene and camera parameters. + * + * @param scene an instance of Scene + * @param camera — an instance of Camera + */ + updateShadowMap(scene: Scene, camera: Camera): void; + + renderBufferImmediate(object: Object3D, program: Object, material: Material): void; + + renderBufferDirect(camera: Camera, lights: Light[], fog: Fog, material: Material, geometryGroup: any, object: Object3D): void; + + renderBuffer(camera: Camera, lights: Light[], fog: Fog, material: Material, geometryGroup: any, object: Object3D): void; + + /** + * Render a scene using a camera. + * The render is done to the renderTarget (if specified) or to the canvas as usual. + * If forceClear is true, the canvas will be cleared before rendering, even if the renderer's autoClear property is false. + */ + render(scene: Scene, camera: Camera, renderTarget?: RenderTarget, forceClear?: boolean): void; + renderImmediateObject(camera: Camera, lights: Light[], fog: Fog, material: Material, object: Object3D): void; + initWebGLObjects(scene: Scene): void; + initMaterial(material: Material, lights: Light[], fog: Fog, object: Object3D): void; + + /** + * Used for setting the gl frontFace, cullFace states in the GPU, thus enabling/disabling face culling when rendering. + * If cullFace is false, culling will be disabled. + * @param cullFace "back", "front", "front_and_back", or false. + * @param frontFace "ccw" or "cw + */ + setFaceCulling(cullFace?: string, frontFace?: FrontFaceDirection): void; + setDepthTest(depthTest: boolean): void; + setDepthWrite(depthWrite: boolean): void; + setBlending(blending: Blending, blendEquation: BlendingEquation, blendSrc: BlendingSrcFactor, blendDst: BlendingDstFactor): void; + setTexture(texture: Texture, slot: number): void; + setRenderTarget(renderTarget: RenderTarget): void; + supportsCompressedTextureS3TC(): any; + getMaxAnisotropy(): number; + getPrecision(): string; + setMaterialFaces(material: Material): void; + supportsStandardDerivatives(): any; + supportsFloatTextures(): any; + clearTarget(renderTarget:WebGLRenderTarget, color: boolean, depth: boolean, stencil: boolean): void; + + /** + * Sets the clear color, using hex for the color and alpha for the opacity. + * + * @example + * // Creates a renderer with black background + * var renderer = new THREE.WebGLRenderer(); + * renderer.setSize(200, 100); + * renderer.setClearColorHex(0x000000, 1); + */ + setClearColorHex(hex: number, alpha: number): void; + } + + export interface RenderTarget { + } + + export interface WebGLRenderTargetOptions { + wrapS?: Wrapping; + wrapT?: Wrapping; + magFilter?: TextureFilter; + minFilter?: TextureFilter; + anisotropy?: number; // 1; + format?: number; // RGBAFormat; + type?: TextureDataType; // UnsignedByteType; + depthBuffer?: boolean; // true; + stencilBuffer?: boolean; // true; + } + + export class WebGLRenderTarget implements RenderTarget { + constructor(width: number, height: number, options?: WebGLRenderTargetOptions); + width: number; + height: number; + wrapS: Wrapping; + wrapT: Wrapping; + magFilter: TextureFilter; + minFilter: TextureFilter; + anisotropy: number; + offset: Vector2; + repeat: Vector2; + format: number; + type: number; + depthBuffer: boolean; + stencilBuffer: boolean; + generateMipmaps: boolean; + clone(): WebGLRenderTarget; + dispose(): void; + } + + export class WebGLRenderTargetCube extends WebGLRenderTarget { + constructor(width: number, height: number, options?: WebGLRenderTargetOptions); + activeCubeFace: number; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5 + } + + // Renderers / Renderables ///////////////////////////////////////////////////////////////////// + + export class RenderableFace { + constructor(); + + vertexNormalsModelView: Vector3[]; + normalWorld: Vector3; + color: number; + material: Material; + uvs: Vector2[][]; + v1: RenderableVertex; + v2: RenderableVertex; + v3: RenderableVertex; + normalModelView: Vector3; + centroidModel: Vector3; + vertexNormalsLength: number; + z: number; + vertexNormalsModel: Vector3[]; + } + + export class RenderableLine { + constructor(); + + v1: RenderableVertex; + v2: RenderableVertex; + z: number; + material: Material; + } + + export class RenderableObject { + constructor(); + + object: Object; + z: number; + id: number; + } + + export class RenderableParticle { + constructor(); + + scale: Vector2; + material: Material; + object: Object; + y: number; + x: number; + rotation: number; + z: number; + } + + export class RenderableVertex { + constructor(); + + visible: boolean; + positionScreen: Vector4; + positionWorld: Vector3; + + copy(vertex: RenderableVertex): void; + } + + // Shaders ///////////////////////////////////////////////////////////////////// + export interface ShaderChunk { + [name: string]: string; + fog_pars_fragment: string; + fog_fragment: string; + envmap_pars_fragment: string; + envmap_fragment: string; + envmap_pars_vertex: string; + worldpos_vertex: string; + envmap_vertex: string; + map_particle_pars_fragment: string; + map_particle_fragment: string; + map_pars_vertex: string; + map_pars_fragment: string; + map_vertex: string; + map_fragment: string; + lightmap_pars_fragment: string; + lightmap_pars_vertex: string; + lightmap_fragment: string; + lightmap_vertex: string; + bumpmap_pars_fragment: string; + normalmap_pars_fragment: string; + specularmap_pars_fragment: string; + specularmap_fragment: string; + lights_lambert_pars_vertex: string; + lights_lambert_vertex: string; + lights_phong_pars_vertex: string; + lights_phong_vertex: string; + lights_phong_pars_fragment: string; + lights_phong_fragment: string; + color_pars_fragment: string; + color_fragment: string; + color_pars_vertex: string; + color_vertex: string; + skinning_pars_vertex: string; + skinbase_vertex: string; + skinning_vertex: string; + morphtarget_pars_vertex: string; + morphtarget_vertex: string; + default_vertex: string; + morphnormal_vertex: string; + skinnormal_vertex: string; + defaultnormal_vertex: string; + shadowmap_pars_fragment: string; + shadowmap_fragment: string; + shadowmap_pars_vertex: string; + shadowmap_vertex: string; + alphatest_fragment: string; + linear_to_gamma_fragment: string; + } + + export var ShaderChunk: ShaderChunk; + + export var UniformsUtils: { + merge(uniforms: Object[]): Uniforms; + merge(uniforms: Uniforms[]): Uniforms; + clone(uniforms_src: Uniforms): Uniforms; + }; + + export var UniformsLib: { + common: Uniforms; + bump: Uniforms; + normalmap: Uniforms; + fog: Uniforms; + lights: Uniforms; + particle: Uniforms; + shadowmap: Uniforms; + }; + + + export interface Shader { + uniforms: Uniforms; + vertexShader: string; + fragmentShader: string; + } + + export var ShaderLib: { + [name: string]: Shader; + basic: Shader; + lambert: Shader; + phong: Shader; + particle_basic: Shader; + depth: Shader; + dashed: Shader; + normal: Shader; + normalmap: Shader; + cube: Shader; + depthRGBA: Shader; + }; + + // Scenes ///////////////////////////////////////////////////////////////////// + + export interface IFog { + name:string; + color: Color; + clone():IFog; + } + + + /** + * This class contains the parameters that define linear fog, i.e., that grows linearly denser with the distance. + */ + export class Fog implements IFog { + constructor(hex: number, near?: number, far?: number); + + name:string; + + /** + * Fog color. + */ + color: Color; + + /** + * The minimum distance to start applying fog. Objects that are less than 'near' units from the active camera won't be affected by fog. + */ + near: number; + + /** + * The maximum distance at which fog stops being calculated and applied. Objects that are more than 'far' units away from the active camera won't be affected by fog. + * Default is 1000. + */ + far: number; + + clone(): Fog; + } + + /** + * This class contains the parameters that define linear fog, i.e., that grows exponentially denser with the distance. + */ + export class FogExp2 implements IFog { + constructor(hex: number, density?: number); + name: string; + color: Color; + + /** + * Defines how fast the fog will grow dense. + * Default is 0.00025. + */ + density: number; + + clone(): FogExp2; + } + + /** + * Scenes allow you to set up what and where is to be rendered by three.js. This is where you place objects, lights and cameras. + */ + export class Scene extends Object3D { + constructor(); + + /** + * A fog instance defining the type of fog that affects everything rendered in the scene. Default is null. + */ + fog: IFog; + + /** + * If not null, it will force everything in the scene to be rendered with that material. Default is null. + */ + overrideMaterial: Material; + + /** + * Default is false. + */ + matrixAutoUpdate: boolean; + + autoUpdate: boolean; + } + + // Textures ///////////////////////////////////////////////////////////////////// + export class CompressedTexture extends Texture { + constructor( + mipmaps: ImageData[], + width: number, + height: number, + format?: PixelFormat, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + anisotropy?: number + ); + + clone(): CompressedTexture; + } + + export class DataTexture extends Texture { + constructor( + data: ImageData, + width: number, + height: number, + format: PixelFormat, + type: TextureDataType, + mapping: Mapping, + wrapS: Wrapping, + wrapT: Wrapping, + magFilter: TextureFilter, + minFilter: TextureFilter, + anisotropy?: number + ); + + clone(): DataTexture; + } + + export class Texture { + constructor( + image: HTMLImageElement, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); + constructor( + image: HTMLCanvasElement, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); + constructor( + image: HTMLImageElement, + mapping?: MappingConstructor, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); + constructor( + image: HTMLCanvasElement, + mapping?: MappingConstructor, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); + + image: Object; // HTMLImageElement or ImageData ; + mapping: Mapping; + wrapS: Wrapping; + wrapT: Wrapping; + magFilter: TextureFilter; + minFilter: TextureFilter; + format: PixelFormat; + type: TextureDataType; + anisotropy: number; + needsUpdate: boolean; + repeat: Vector2; + offset: Vector2; + name: string; + generateMipmaps: boolean; + flipY: boolean; + mipmaps: ImageData[]; + unpackAlignment: number; + premultiplyAlpha: boolean; + onUpdate: () => void; + id: number; + + clone(): Texture; + dispose(): void; + } + + // Extras ///////////////////////////////////////////////////////////////////// + + export interface TypefaceData { + familyName: string; + cssFontWeight: string; + cssFontStyle: string; + } + + export var FontUtils: { + + divisions: number; + style: string; + weight: string; + face: string; + faces: { [weight: string]: { [style: string]: Face; }; }; + size: number; + + drawText(text: string): { paths: Path[]; offset: number; }; + Triangulate: { + (contour: Vector2[], indices: boolean): Vector2[]; + area(contour: Vector2[]): number; + }; + extractGlyphPoints(c: string, face: Face, scale: number, offset: number, path: Path): { offset: number; path: Path; }; + generateShapes(text: string, parameters?: { size?: number; curveSegments?: number; font?: string; weight?: string; style?: string; }): Shape[]; + loadFace(data: TypefaceData): TypefaceData; + getFace(): Face; + }; + + export var GeometryUtils: { + merge(geometry1: Geometry, object2: Mesh, materialIndexOffset?: number): void; + merge(geometry1: Geometry, object2: Geometry, materialIndexOffset?: number): void; + randomPointInTriangle(vectorA: Vector3, vectorB: Vector3, vectorC: Vector3): Vector3; + randomPointInFace(face: Face, geometry: Geometry, useCachedAreas: boolean): Vector3; + randomPointsInGeometry(geometry: Geometry, points: number): Vector3; + triangleArea(vectorA: Vector3, vectorB: Vector3, vectorC: Vector3): number; + center(geometry: Geometry): Vector3; + triangulateQuads(geometry: Geometry): void; + }; + + export var ImageUtils: { + crossOrigin: string; + + generateDataTexture(width: number, height: number, color: Color): DataTexture; + parseDDS(buffer: ArrayBuffer, loadMipmaps: boolean): { mipmaps: { data: Uint8Array; width: number; height: number; }[]; width: number; height: number; format: number; mipmapCount: number; }; + loadCompressedTexture(url: string, mapping?: Mapping, onLoad?: (texture: Texture) => void, onError?: (message: string) => void): Texture; + loadTexture(url: string, mapping?: Mapping, onLoad?: (texture: Texture) => void, onError?: (message: string) => void): Texture; + getNormalMap(image: HTMLImageElement, depth?: number): HTMLCanvasElement; + loadCompressedTextureCube(array: string[], mapping?: Mapping, onLoad?: () => void, onError?: (message: string) => void): Texture; + loadTextureCube(array: string[], mapping?: Mapping, onLoad?: () => void , onError?: (message: string) => void ): Texture; + }; + + export var SceneUtils: { + createMultiMaterialObject(geometry: Geometry, materials: Material[]): Object3D; + attach(child: Object3D, scene: Scene, parent: Object3D): void; + detach(child: Object3D, parent: Object3D, scene: Scene): void; + }; + + // Extras / Animation ///////////////////////////////////////////////////////////////////// + + export interface KeyFrame { + pos: number[]; + rot: number[]; + scl: number[]; + time: number; + } + + export interface KeyFrames { + keys: KeyFrame[]; + parent: number; + } + + export interface AnimationData { + JIT: number; + fps: number; + hierarchy: KeyFrames[]; + length: number; + name: string; + } + + export class Animation { + constructor(root: Mesh, name: string); + + root: Mesh; + data: AnimationData; + hierarchy: Bone[]; + currentTime: number; + timeScale: number; + isPlaying: boolean; + isPaused: boolean; + loop: boolean; + interpolationType: AnimationInterpolation; + + play(loop?: boolean, startTimeMS?: number): void; + pause(): void; + stop(): void; + reset(): void; + update(deltaTimeMS: number): void; + interpolateCatmullRom(points: Vector3[], scale: number): Vector3[]; + interpolate(p0: number, p1: number, p2: number, p3: number, t: number, t2: number, t3: number): number; + getNextKeyWith(type: string, h: number, key: number): KeyFrame; // ???? + getPrevKeyWith(type: string, h: number, key: number): KeyFrame; + } + + export class AnimationInterpolation { } + + export var AnimationHandler: { + CATMULLROM: AnimationInterpolation; + CATMULLROM_FORWARD: AnimationInterpolation; + LINEAR: AnimationInterpolation; + removeFromUpdate(animation: Animation): void; + get(name: string): AnimationData; + update(deltaTimeMS: number): void; + parse(root: SkinnedMesh): Object3D[]; + add(data: AnimationData): void; + addToUpdate(animation: Animation): void; + }; + + export class AnimationMorphTarget { + constructor(root: Bone, data: any); + + root: Bone; + data: Object; + hierarchy: KeyFrames[]; + currentTime: number; + timeScale: number; + isPlaying: boolean; + isPaused: boolean; + loop: boolean; + influence: number; + + play(loop?: boolean, startTimeMS?: number): void; + pause(): void; + stop(): void; + update(deltaTimeMS: number): void; + } + + export class KeyFrameAnimation { + constructor(root: Mesh, data: any, JITCompile?: boolean); + + root: Mesh; + data: Object; + hierarchy: KeyFrames[]; + currentTime: number; + timeScale: number; + isPlaying: number; + isPaused: number; + loop: number; + JITCompile: boolean; + + play(loop?: number, startTimeMS?: number): void; + pause(): void; + stop(): void; + update(deltaTimeMS: number): void; + interpolateCatmullRom(points: Vector3[], scale: number): Vector3[]; + getNextKeyWith(type: string, h: number, key: number): KeyFrame; // ???? + getPrevKeyWith(type: string, h: number, key: number): KeyFrame; + } + + // Extras / Cameras ///////////////////////////////////////////////////////////////////// + + export class CombinedCamera extends Camera { + constructor(width: number, height: number, fov: number, near: number, far: number, orthoNear: number, orthoFar: number); + + fov: number; + right: number; + bottom: number; + cameraP: PerspectiveCamera; + top: number; + zoom: number; + far: number; + near: number; + inPerspectiveMode: boolean; + cameraO: OrthographicCamera; + inOrthographicMode: boolean; + left: number; + + toBottomView(): void; + setFov(fov: number): void; + toBackView(): void; + setZoom(zoom: number): void; + setLens(focalLength: number, frameHeight?: number): number; + toFrontView(): void; + toLeftView(): void; + updateProjectionMatrix(): void; + toTopView(): void; + toOrthographic(): void; + setSize(width: number, height: number): void; + toPerspective(): void; + toRightView(): void; + } + + export class CubeCamera extends Object3D { + constructor(near: number, far: number, cubeResolution: number); + + renderTarget: WebGLRenderTargetCube; + updateCubeMap(renderer: Renderer, scene: Scene): void; + } + + // Extras / Core ///////////////////////////////////////////////////////////////////// + + /** + * An extensible curve object which contains methods for interpolation + * class Curve<T extends Vector> + */ + export class Curve { + constructor(); + + needsUpdate: boolean; + + /** + * Returns a vector for point t of the curve where t is between 0 and 1 + * getPoint(t: number): T; + */ + getPoint(t: number): Vector; + + /** + * Returns a vector for point at relative position in curve according to arc length + * getPointAt(u: number): T; + */ + getPointAt(u: number): Vector; + + /** + * Get sequence of points using getPoint( t ) + * getPoints(divisions?: number): T[]; + */ + getPoints(divisions?: number): Vector[]; + + /** + * Get sequence of equi-spaced points using getPointAt( u ) + * getSpacedPoints(divisions?: number): T[]; + */ + getSpacedPoints(divisions?: number): Vector[]; + + /** + * Get total curve arc length + */ + getLength(): number; + + /** + * Get list of cumulative segment lengths + */ + getLengths(divisions?: number): number[]; + + /** + * Update the cumlative segment distance cache + */ + updateArcLengths(): void; + + /** + * Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance + */ + getUtoTmapping(u: number, distance: number): number; + + /** + * Returns a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation + * getTangent(t: number): T; + */ + getTangent(t: number): Vector; + + /** + * Returns tangent at equidistance point u on the curve + * getTangentAt(u: number): T; + */ + getTangentAt(u: number): Vector; + + static Utils: { + tangentQuadraticBezier(t: number, p0: number, p1: number, p2: number): number; + tangentCubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number; + tangentSpline(t: number, p0: number, p1: number, p2: number, p3: number): number; + interpolate(p0: number, p1: number, p2: number, p3: number, t: number): number; + }; + + static create(constructorFunc: Function, getPointFunc: Function): Function; + } + + export interface BoundingBox { + minX: number; + minY: number; + maxX: number; + maxY: number; + centroid: Vector; + } + + export class CurvePath extends Curve { + constructor(); + + curves: Curve[]; + bends: Path[]; + autoClose: boolean; + + getWrapPoints(oldPts: Vector2[], path: Path): Vector2[]; + createPointsGeometry(divisions: number): Geometry; + addWrapPath(bendpath: Path): void; + createGeometry(points: Vector2[]): Geometry; + add(curve: Curve): void; + getTransformedSpacedPoints(segments: number, bends?: Path[]): Vector2[]; + createSpacedPointsGeometry(divisions: number): Geometry; + closePath(): void; + getBoundingBox(): BoundingBox; + getCurveLengths(): number; + getTransformedPoints(segments: number, bends?: Path): Vector2[]; + checkConnection(): boolean; + } + + export class Gyroscope extends Object3D { + constructor(); + + scaleWorld: Vector3; + translationWorld: Vector3; + rotationWorld: Quaternion; + translationObject: Vector3; + scaleObject: Vector3; + rotationObject: Quaternion; + + updateMatrixWorld(force?: boolean): void; + } + + export enum PathActions { + MOVE_TO, + LINE_TO, + QUADRATIC_CURVE_TO, // Bezier quadratic curve + BEZIER_CURVE_TO, // Bezier cubic curve + CSPLINE_THRU, // Catmull-rom spline + ARC, // Circle + ELLIPSE, + } + + /** + * a 2d path representation, comprising of points, lines, and cubes, similar to the html5 2d canvas api. It extends CurvePath. + */ + export class Path extends CurvePath { + constructor(points?: Vector2); + + actions: PathActions[]; + + fromPoints(vectors: Vector2[]): void; + moveTo(x: number, y: number): void; + lineTo(x: number, y: number): void; + quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): void; + bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): void; + splineThru(pts: Vector2[]): void; + arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + ellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + absellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + toShapes(): Shape[]; + } + + /** + * Defines a 2d shape plane using paths. + */ + export class Shape implements Path { + constructor(points?: Vector2[]); + + holes: Path[]; + + makeGeometry(options?: any): ShapeGeometry; + extractAllPoints(divisions: number): { + shape: Vector2[]; + holes: Vector2[][]; + }; + extrude(options?: any): ExtrudeGeometry; + extractPoints(divisions: number): Vector2[]; + extractAllSpacedPoints(divisions: Vector2): { + shape: Vector2[]; + holes: Vector2[][]; + }; + getPointsHoles(divisions: number): Vector2[][]; + getSpacedPointsHoles(divisions: number): Vector2[][]; + + getCurveLengths(): number; + // trick for TypeScript 0.9.5 compile passed + // from Path + actions: PathActions[]; + fromPoints(vectors: Vector2[]): void; + moveTo(x: number, y: number): void; + lineTo(x: number, y: number): void; + quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): void; + bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): void; + splineThru(pts: Vector2[]): void; + arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + ellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + absellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; + toShapes(): Shape[]; + // from CurvePath + curves: Curve[]; + bends: Path[]; + autoClose: boolean; + add(curve: Curve): void; + checkConnection(): boolean; + closePath(): void; + getBoundingBox(): BoundingBox; + createPointsGeometry(divisions: number): Geometry; + createSpacedPointsGeometry(divisions: number): Geometry; + createGeometry(points: Vector2[]): Geometry; + addWrapPath(bendpath: Path): void; + getTransformedPoints(segments: number, bends?: Path): Vector2[]; + getTransformedSpacedPoints(segments: number, bends?: Path[]): Vector2[]; + getWrapPoints(oldPts: Vector2[], path: Path): Vector2[]; + getPoint(t: number): Vector; + getPointAt(u: number): Vector; + getPoints(divisions?: number): Vector[]; + getSpacedPoints(divisions?: number): Vector[]; + getLength(): number; + getLengths(divisions?: number): number[]; + needsUpdate: boolean; + updateArcLengths(): void; + getUtoTmapping(u: number, distance: number): number; + getNormalVector(t: number): Vector; + getTangent(t: number): Vector; + getTangentAt(u: number): Vector; + } + + + + // Extras / Geomerties ///////////////////////////////////////////////////////////////////// + + export class CircleGeometry extends Geometry { + constructor(radius?: number, segments?: number, thetaStart?: number, thetaLength?: number); + } + + export class ConvexGeometry extends Geometry { + constructor(vertices: Vector3[]); + } + + /** + * CubeGeometry is the quadrilateral primitive geometry class. It is typically used for creating a cube or irregular quadrilateral of the dimensions provided within the (optional) 'width', 'height', & 'depth' constructor arguments. + */ + export class BoxGeometry extends Geometry { + /** + * @param width — Width of the sides on the X axis. + * @param height — Height of the sides on the Y axis. + * @param depth — Depth of the sides on the Z axis. + * @param widthSegments — Number of segmented faces along the width of the sides. + * @param heightSegments — Number of segmented faces along the height of the sides. + * @param depthSegments — Number of segmented faces along the depth of the sides. + */ + constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number); + } + + export class CubeGeometry extends BoxGeometry { + } + + export class CylinderGeometry extends Geometry { + /** + * @param radiusTop — Radius of the cylinder at the top. + * @param radiusBottom — Radius of the cylinder at the bottom. + * @param height — Height of the cylinder. + * @param radiusSegments — Number of segmented faces around the circumference of the cylinder. + * @param heightSegments — Number of rows of faces along the height of the cylinder. + * @param openEnded - A Boolean indicating whether or not to cap the ends of the cylinder. + */ + constructor(radiusTop?: number, radiusBottom?: number, height?: number, radiusSegments?: number, heightSegments?: number, openEnded?: boolean); + } + + export class ExtrudeGeometry extends Geometry { + constructor(shape?: Shape, options?: any); + constructor(shapes?: Shape[], options?: any); + + addShapeList(shapes: Shape[], options?: any): void; + addShape(shape: Shape, options?: any): void; + } + + export class IcosahedronGeometry extends PolyhedronGeometry { + constructor(radius: number, detail: number); + } + + export class LatheGeometry extends Geometry { + constructor(points: Vector3[], steps?: number, angle?: number); + } + + export class OctahedronGeometry extends PolyhedronGeometry { + constructor(radius: number, detail: number); + } + + export class ParametricGeometry extends Geometry { + constructor(func: (u: number, v: number) => Vector3, slices: number, stacks: number, useTris?: boolean); + } + + export class PlaneGeometry extends Geometry { + constructor(width: number, height: number, widthSegments?: number, heightSegments?: number); + } + + export class PolyhedronGeometry extends Geometry { + constructor(vertices: Vector3[], faces: Face[], radius?: number, detail?: number); + } + + export class RingGeometry extends Geometry { + constructor(innerRadius?: number, outerRadius?: number, thetaSegments?: number, phiSegments?: number, thetaStart?: number, thetaLength?: number); + } + export class ShapeGeometry extends Geometry { + constructor(shape: Shape, options?: any); + constructor(shapes: Shape[], options?: any); + + shapebb: BoundingBox; + addShapeList(shapes: Shape[], options: any): ShapeGeometry; + addShape(shape: Shape, options?: any): void; + } + + /** + * A class for generating sphere geometries + */ + export class SphereGeometry extends Geometry { + /** + * The geometry is created by sweeping and calculating vertexes around the Y axis (horizontal sweep) and the Z axis (vertical sweep). Thus, incomplete spheres (akin to 'sphere slices') can be created through the use of different values of phiStart, phiLength, thetaStart and thetaLength, in order to define the points in which we start (or end) calculating those vertices. + * + * @param radius — sphere radius. Default is 50. + * @param segmentsWidth — number of horizontal segments. Minimum value is 3, and the default is 8. + * @param segmentsHeight — number of vertical segments. Minimum value is 2, and the default is 6. + * @param phiStart — specify horizontal starting angle. Default is 0. + * @param phiLength — specify horizontal sweep angle size. Default is Math.PI * 2. + * @param thetaStart — specify vertical starting angle. Default is 0. + * @param thetaLength — specify vertical sweep angle size. Default is Math.PI. + */ + constructor(radius: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number); + } + + export class TetrahedronGeometry extends PolyhedronGeometry { + constructor(radius?: number, detail?: number); + } + + export interface TextGeometryParameters { + size?: number; // size of the text + height?: number; // thickness to extrude text + curveSegments?: number; // number of points on the curves + font?: string; // font name + weight?: string; // font weight (normal, bold) + style?: string; // font style (normal, italics) + bevelEnabled?: boolean; // turn on bevel + bevelThickness?: number; // how deep into text bevel goes + bevelSize?: number; // how far from text outline is bevel + } + + export class TextGeometry extends ExtrudeGeometry { + constructor(text: string, TextGeometryParameters?: TextGeometryParameters); + } + + export class TorusGeometry extends Geometry { + constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number); + } + + export class TorusKnotGeometry extends Geometry { + constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, heightScale?: number); + } + + export class TubeGeometry extends Geometry { + constructor(path: Path, segments?: number, radius?: number, radiusSegments?: number, closed?: boolean); + + path: Path; + segments: number; + radius: number; + radiusSegments: number; + closed: boolean; + tangents: Vector3[]; + normals: Vector3[]; + binormals: Vector3[]; + + FrenetFrames(path: Path, segments: number, closed: boolean): void; + } + + // Extras / Helpers ///////////////////////////////////////////////////////////////////// + + export class ArrowHelper extends Object3D { + constructor(dir: Vector3, origin?: Vector3, length?: number, hex?: number, headLength?: number, headWidth?: number); + + line: Line; + cone: Mesh; + + setColor(hex: number): void; + setLength(length: number): void; + setDirection(dir: Vector3): void; + } + + export class AxisHelper extends Line { + constructor(size: number); + } + + export class BoundingBoxHelper extends Mesh { + constructor(object: Object3D, hex: number); + + object: Object3D; + box: Box3; + + update(): void; + } + export class CameraHelper extends Line { + constructor(camera: Camera); + + pointMap: { [id: string]: number[]; }; + camera: Camera; + + update(): void; + } + + export class DirectionalLightHelper extends Object3D { + constructor(light: Light, sphereSize: number, arrowLength: number); + + lightSphere: Mesh; + light: Light; + targetLine: Line; + + update(): void; + } + + export class GridHelper extends Line { + constructor(size: number, step: number); + + setColors(colorCenterLine: number, colorGrid: number): void; + } + export class HemisphereLightHelper extends Object3D { + constructor(light: Light, sphereSize: number, arrowLength: number, domeSize: number); + + lightSphere: Mesh; + light: Light; + + update(): void; + } + + export class PointLightHelper extends Object3D { + constructor(light: Light, sphereSize: number); + + lightSphere: Mesh; + light: Light; + + update(): void; + } + + export class SpotLightHelper extends Object3D { + constructor(light: Light, sphereSize: number, arrowLength: number); + + lightSphere: Mesh; + light: Light; + lightCone: Mesh; + + update(): void; + } + + // Extras / Objects ///////////////////////////////////////////////////////////////////// + + export class ImmediateRenderObject extends Object3D { + constructor(); + + render(renderCallback:Function): void; + } + + export interface LensFlareProperty { + texture: Texture; // Texture + size: number; // size in pixels (-1 = use texture.width) + distance: number; // distance (0-1) from light source (0=at light source) + x: number; + y: number; + z: number; // screen position (-1 => 1) z = 0 is ontop z = 1 is back + scale: number; // scale + rotation: number; // rotation + opacity: number; // opacity + color: Color; // color + blending: Blending; + } + + export class LensFlare extends Object3D { + constructor(texture?: Texture, size?: number, distance?: number, blending?: Blending, color?: Color); + + lensFlares: LensFlareProperty[]; + positionScreen: Vector3; + customUpdateCallback: (object: LensFlare) => void; + + add(obj: Object3D): void; + add(texture: Texture, size?: number, distance?: number, blending?: Blending, color?: Color): void; + + updateLensFlares(): void; + } + + export interface MorphBlendMeshAnimation { + startFrame: number; + endFrame: number; + length: number; + fps: number; + duration: number; + lastFrame: number; + currentFrame: number; + active: boolean; + time: number; + direction: number; + weight: number; + directionBackwards: boolean; + mirroredLoop: boolean; + } + + export class MorphBlendMesh extends Mesh { + constructor(geometry: Geometry, material: Material); + + animationsMap: { [name: string]: MorphBlendMeshAnimation; }; + animationsList: MorphBlendMeshAnimation[]; + + setAnimationWeight(name: string, weight: number): void; + setAnimationFPS(name: string, fps: number): void; + createAnimation(name: string, start: number, end: number, fps: number): void; + playAnimation(name: string): void; + update(delta: number): void; + autoCreateAnimations(fps: number): void; + setAnimationDuration(name: string, duration: number): void; + setAnimationDirectionForward(name: string): void; + getAnimationDuration(name: string): number; + getAnimationTime(name: string): number; + setAnimationDirectionBackward(name: string): void; + setAnimationTime(name: string, time: number): void; + stopAnimation(name: string): void; + } + + // Extras / Renderers / Plugins ///////////////////////////////////////////////////////////////////// + + export class DepthPassPlugin implements RendererPlugin { + constructor(); + + enabled: boolean; + renderTarget: RenderTarget; + + init(renderer: Renderer): void; + update(scene: Scene, camera: Camera): void; + render(scene: Scene, camera: Camera): void; + } + + export class LensFlarePlugin implements RendererPlugin { + constructor(); + + init(renderer: Renderer): void; + render(scene: Scene, camera: Camera, viewportWidth: number, viewportHeight: number): void; + } + + export class ShadowMapPlugin implements RendererPlugin { + constructor(); + + init(renderer: Renderer): void; + + update(scene: Scene, camera: Camera): void; + render(scene: Scene, camera: Camera): void; + } + + export class SpritePlugin implements RendererPlugin { + constructor(); + + init(renderer: Renderer): void; + render(scene: Scene, camera: Camera, viewportWidth: number, viewportHeight: number): void; + } + + // Extras / Shaders ///////////////////////////////////////////////////////////////////// + + export var ShaderFlares: { + 'lensFlareVertexTexture': { + vertexShader: string; + fragmentShader: string; + }; + 'lensFlare': { + vertexShader: string; + fragmentShader: string; + }; + }; +} diff --git a/threejs/three.d.ts.tscparams b/threejs/three.d.ts.tscparams deleted file mode 100644 index e16c76dff8..0000000000 --- a/threejs/three.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ -"" From a0e4fc304fbfd712fc0f56c64fb446fe737cb816 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 1 Mar 2014 22:40:41 +0100 Subject: [PATCH 239/240] parallelized tester added TestQueue class suites now have TestQueue instance that queues and runs Tests defaults to two (or more if more cores available) - Travis has '1.5 virtual cores' (weird) dropped index parameter from suite callback added index parameter to Reporter dropped double Suite::filterTargetFiles calls small fix in bluebird defs also print some system info in tester header --- _infrastructure/tests/runner.js | 134 +++++++++++++----- _infrastructure/tests/runner.ts | 59 +++++++- _infrastructure/tests/src/printer.ts | 19 ++- .../tests/src/reporter/reporter.ts | 19 +-- _infrastructure/tests/src/suite/suite.ts | 21 +-- _infrastructure/tests/src/suite/tscParams.ts | 8 +- _infrastructure/tests/src/tsc.ts | 17 ++- .../tests/typings/bluebird/bluebird.d.ts | 1 + 8 files changed, 210 insertions(+), 68 deletions(-) diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index e21bbd42be..0512c05e27 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -78,7 +78,8 @@ var DT; function Tsc() { } Tsc.run = function (tsfile, options) { - return Promise.attempt(function () { + var tscPath; + return new Promise.attempt(function () { options = options || {}; options.tscVersion = options.tscVersion || DT.DEFAULT_TSC_VERSION; if (typeof options.checkNoImplicitAny === 'undefined') { @@ -87,15 +88,21 @@ var DT; if (typeof options.useTscParams === 'undefined') { options.useTscParams = true; } - if (!fs.existsSync(tsfile)) { + return DT.fileExists(tsfile); + }).then(function (exists) { + if (!exists) { throw new Error(tsfile + ' not exists'); } - var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!fs.existsSync(tscPath)) { + tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; + return DT.fileExists(tscPath); + }).then(function (exists) { + if (!exists) { throw new Error(tscPath + ' is not exists'); } + return DT.fileExists(tsfile + '.tscparams'); + }).then(function (exists) { var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { + if (options.useTscParams && exists) { command += '@' + tsfile + '.tscparams'; } else if (options.checkNoImplicitAny) { command += '--noImplicitAny'; @@ -437,6 +444,8 @@ var DT; /// var DT; (function (DT) { + var os = require('os'); + ///////////////////////////////// // All the common things that we print are functions of this class ///////////////////////////////// @@ -462,11 +471,14 @@ var DT; Print.prototype.printChangeHeader = function () { this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n'); + this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n'); this.out('=============================================================================\n'); }; - Print.prototype.printHeader = function () { + Print.prototype.printHeader = function (options) { + var totalMem = Math.round(os.totalmem() / 1024 / 1024) + ' mb'; + var freemem = Math.round(os.freemem() / 1024 / 1024) + ' mb'; + this.out('=============================================================================\n'); this.out(' \33[36m\33[1mDefinitelyTyped Test Runner 0.5.0\33[0m\n'); this.out('=============================================================================\n'); @@ -474,6 +486,10 @@ var DT; this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); + this.out(' \33[36m\33[1mTotal Memory :\33[0m ' + totalMem + '\n'); + this.out(' \33[36m\33[1mFree Memory :\33[0m ' + freemem + '\n'); + this.out(' \33[36m\33[1mCores :\33[0m ' + os.cpus().length + '\n'); + this.out(' \33[36m\33[1mConcurrent :\33[0m ' + options.concurrent + '\n'); }; Print.prototype.printSuiteHeader = function (title) { @@ -578,12 +594,12 @@ var DT; } }; - Print.prototype.printTestComplete = function (testResult, index) { + Print.prototype.printTestComplete = function (testResult) { var reporter = testResult.hostedBy.testReporter; if (testResult.success) { - reporter.printPositiveCharacter(index, testResult); + reporter.printPositiveCharacter(testResult); } else { - reporter.printNegativeCharacter(index, testResult); + reporter.printNegativeCharacter(testResult); } }; @@ -709,17 +725,18 @@ var DT; var DefaultTestReporter = (function () { function DefaultTestReporter(print) { this.print = print; + this.index = 0; } - DefaultTestReporter.prototype.printPositiveCharacter = function (index, testResult) { + DefaultTestReporter.prototype.printPositiveCharacter = function (testResult) { this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); - - this.printBreakIfNeeded(index); + this.index++; + this.printBreakIfNeeded(this.index); }; - DefaultTestReporter.prototype.printNegativeCharacter = function (index, testResult) { + DefaultTestReporter.prototype.printNegativeCharacter = function (testResult) { this.print.out('x'); - - this.printBreakIfNeeded(index); + this.index++; + this.printBreakIfNeeded(this.index); }; DefaultTestReporter.prototype.printBreakIfNeeded = function (index) { @@ -751,6 +768,7 @@ var DT; this.timer = new DT.Timer(); this.testResults = []; this.printErrorCount = true; + this.queue = new DT.TestQueue(options.concurrent); } TestSuiteBase.prototype.filterTargetFiles = function (files) { throw new Error('please implement this method'); @@ -759,14 +777,15 @@ var DT; TestSuiteBase.prototype.start = function (targetFiles, testCallback) { var _this = this; this.timer.start(); + return this.filterTargetFiles(targetFiles).then(function (targetFiles) { - return Promise.reduce(targetFiles, function (count, targetFile) { + // tests get queued for multi-threading + return Promise.all(targetFiles.map(function (targetFile) { return _this.runTest(targetFile).then(function (result) { - testCallback(result, count + 1); - return count++; + testCallback(result); }); - }, 0); - }).then(function (count) { + })); + }).then(function () { _this.timer.end(); return _this; }); @@ -774,7 +793,9 @@ var DT; TestSuiteBase.prototype.runTest = function (targetFile) { var _this = this; - return new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion }).run().then(function (result) { + return this.queue.run(new DT.Test(this, targetFile, { + tscVersion: this.options.tscVersion + })).then(function (result) { _this.testResults.push(result); return result; }); @@ -885,10 +906,10 @@ var DT; this.printErrorCount = false; this.testReporter = { - printPositiveCharacter: function (index, testResult) { + printPositiveCharacter: function (testResult) { _this.print.clearCurrentLine().printTypingsWithoutTestName(testResult.targetFile.filePathWithName); }, - printNegativeCharacter: function (index, testResult) { + printNegativeCharacter: function (testResult) { } }; } @@ -904,11 +925,11 @@ var DT; var _this = this; this.print.clearCurrentLine().out(targetFile.filePathWithName); - return new DT.Test(this, targetFile, { + return this.queue.run(new DT.Test(this, targetFile, { tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true - }).run().then(function (result) { + })).then(function (result) { _this.testResults.push(result); _this.print.clearCurrentLine(); return result; @@ -949,6 +970,7 @@ var DT; var Lazy = require('lazy.js'); var Promise = require('bluebird'); + var os = require('os'); var fs = require('fs'); var path = require('path'); var assert = require('assert'); @@ -985,6 +1007,55 @@ var DT; })(); DT.Test = Test; + ///////////////////////////////// + // Parallel execute Tests + ///////////////////////////////// + var TestQueue = (function () { + function TestQueue(concurrent) { + this.queue = []; + this.active = []; + this.concurrent = Math.max(1, concurrent); + } + // add to queue and return a promise + TestQueue.prototype.run = function (test) { + var _this = this; + var defer = Promise.defer(); + + // add a closure to queue + this.queue.push(function () { + // when activate, add test to active list + _this.active.push(test); + + // run it + var p = test.run(); + p.then(defer.resolve.bind(defer), defer.reject.bind(defer)); + p.finally(function () { + var i = _this.active.indexOf(test); + if (i > -1) { + _this.active.splice(i, 1); + } + _this.step(); + }); + }); + this.step(); + + // defer it + return defer.promise; + }; + + TestQueue.prototype.step = function () { + var _this = this; + // setTimeout to make it flush + setTimeout(function () { + while (_this.queue.length > 0 && _this.active.length < _this.concurrent) { + _this.queue.pop().call(null); + } + }, 1); + }; + return TestQueue; + })(); + DT.TestQueue = TestQueue; + ///////////////////////////////// // Test results ///////////////////////////////// @@ -1091,7 +1162,7 @@ var DT; ]); }).spread(function (syntaxFiles, testFiles) { _this.print.init(syntaxFiles.length, testFiles.length, files.length); - _this.print.printHeader(); + _this.print.printHeader(_this.options); if (_this.options.findNotRequiredTscparams) { _this.addSuite(new DT.FindNotRequiredTscparams(_this.options, _this.print)); @@ -1102,10 +1173,8 @@ var DT; _this.print.printSuiteHeader(suite.testSuiteName); - return suite.filterTargetFiles(files).then(function (targetFiles) { - return suite.start(targetFiles, function (testResult, index) { - _this.print.printTestComplete(testResult, index); - }); + return suite.start(files, function (testResult) { + _this.print.printTestComplete(testResult); }).then(function (suite) { _this.print.printSuiteComplete(suite); return count++; @@ -1186,12 +1255,13 @@ var DT; }); var tscVersionIndex = process.argv.indexOf('--tsc-version'); var tscVersion = DT.DEFAULT_TSC_VERSION; + var cpuCores = os.cpus().length; if (tscVersionIndex > -1) { tscVersion = process.argv[tscVersionIndex + 1]; } - var runner = new TestRunner(dtPath, { + concurrent: Math.max(cpuCores, 2), tscVersion: tscVersion, findNotRequiredTscparams: findNotRequiredTscparams }); diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index 4e72001b88..fafe2b1454 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -25,6 +25,7 @@ module DT { var Lazy: LazyJS.LazyStatic = require('lazy.js'); var Promise: typeof Promise = require('bluebird'); + var os = require('os'); var fs = require('fs'); var path = require('path'); var assert = require('assert'); @@ -56,6 +57,52 @@ module DT { } } + ///////////////////////////////// + // Parallel execute Tests + ///////////////////////////////// + export class TestQueue { + + private queue: Function[] = []; + private active: Test[] = []; + private concurrent: number; + + constructor(concurrent: number) { + this.concurrent = Math.max(1, concurrent); + } + + // add to queue and return a promise + run(test: Test): Promise { + var defer = Promise.defer(); + // add a closure to queue + this.queue.push(() => { + // when activate, add test to active list + this.active.push(test); + // run it + var p = test.run(); + p.then(defer.resolve.bind(defer), defer.reject.bind(defer)); + p.finally(() => { + var i = this.active.indexOf(test); + if (i > -1) { + this.active.splice(i, 1); + } + this.step(); + }); + }); + this.step(); + // defer it + return defer.promise; + } + + private step(): void { + // setTimeout to make it flush + setTimeout(() => { + while (this.queue.length > 0 && this.active.length < this.concurrent) { + this.queue.pop().call(null); + } + }, 1); + } + } + ///////////////////////////////// // Test results ///////////////////////////////// @@ -75,6 +122,7 @@ module DT { export interface ITestRunnerOptions { tscVersion:string; + concurrent?:number; findNotRequiredTscparams?:boolean; } @@ -166,7 +214,7 @@ module DT { ]); }).spread((syntaxFiles, testFiles) => { this.print.init(syntaxFiles.length, testFiles.length, files.length); - this.print.printHeader(); + this.print.printHeader(this.options); if (this.options.findNotRequiredTscparams) { this.addSuite(new FindNotRequiredTscparams(this.options, this.print)); @@ -177,10 +225,8 @@ module DT { this.print.printSuiteHeader(suite.testSuiteName); - return suite.filterTargetFiles(files).then((targetFiles) => { - return suite.start(targetFiles, (testResult, index) => { - this.print.printTestComplete(testResult, index); - }); + return suite.start(files, (testResult) => { + this.print.printTestComplete(testResult); }).then((suite) => { this.print.printSuiteComplete(suite); return count++; @@ -256,12 +302,13 @@ module DT { var findNotRequiredTscparams = process.argv.some(arg => arg == '--try-without-tscparams'); var tscVersionIndex = process.argv.indexOf('--tsc-version'); var tscVersion = DEFAULT_TSC_VERSION; + var cpuCores = os.cpus().length; if (tscVersionIndex > -1) { tscVersion = process.argv[tscVersionIndex + 1]; } - var runner = new TestRunner(dtPath, { + concurrent: Math.max(cpuCores, 2), tscVersion: tscVersion, findNotRequiredTscparams: findNotRequiredTscparams }); diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts index 962d7b644d..565c4268a7 100644 --- a/_infrastructure/tests/src/printer.ts +++ b/_infrastructure/tests/src/printer.ts @@ -3,6 +3,8 @@ module DT { + var os = require('os'); + ///////////////////////////////// // All the common things that we print are functions of this class ///////////////////////////////// @@ -35,11 +37,14 @@ module DT { public printChangeHeader() { this.out('=============================================================================\n'); - this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n'); + this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n'); this.out('=============================================================================\n'); } - public printHeader() { + public printHeader(options: ITestRunnerOptions) { + var totalMem = Math.round(os.totalmem() / 1024 / 1024) + ' mb'; + var freemem = Math.round(os.freemem() / 1024 / 1024) + ' mb'; + this.out('=============================================================================\n'); this.out(' \33[36m\33[1mDefinitelyTyped Test Runner 0.5.0\33[0m\n'); this.out('=============================================================================\n'); @@ -47,6 +52,10 @@ module DT { this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n'); this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n'); this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n'); + this.out(' \33[36m\33[1mTotal Memory :\33[0m ' + totalMem + '\n'); + this.out(' \33[36m\33[1mFree Memory :\33[0m ' + freemem + '\n'); + this.out(' \33[36m\33[1mCores :\33[0m ' + os.cpus().length + '\n'); + this.out(' \33[36m\33[1mConcurrent :\33[0m ' + options.concurrent + '\n'); } public printSuiteHeader(title: string) { @@ -150,13 +159,13 @@ module DT { } } - public printTestComplete(testResult: TestResult, index: number): void { + public printTestComplete(testResult: TestResult): void { var reporter = testResult.hostedBy.testReporter; if (testResult.success) { - reporter.printPositiveCharacter(index, testResult); + reporter.printPositiveCharacter(testResult); } else { - reporter.printNegativeCharacter(index, testResult); + reporter.printNegativeCharacter(testResult); } } diff --git a/_infrastructure/tests/src/reporter/reporter.ts b/_infrastructure/tests/src/reporter/reporter.ts index 783eae287a..736ac413cc 100644 --- a/_infrastructure/tests/src/reporter/reporter.ts +++ b/_infrastructure/tests/src/reporter/reporter.ts @@ -7,27 +7,30 @@ module DT { // for example, . and x ///////////////////////////////// export interface ITestReporter { - printPositiveCharacter(index: number, testResult: TestResult):void; - printNegativeCharacter(index: number, testResult: TestResult):void; + printPositiveCharacter(testResult: TestResult):void; + printNegativeCharacter(testResult: TestResult):void; } ///////////////////////////////// // Default test reporter ///////////////////////////////// export class DefaultTestReporter implements ITestReporter { + + index = 0; + constructor(public print: Print) { } - public printPositiveCharacter(index: number, testResult: TestResult) { + public printPositiveCharacter(testResult: TestResult) { this.print.out('\33[36m\33[1m' + '.' + '\33[0m'); - - this.printBreakIfNeeded(index); + this.index++; + this.printBreakIfNeeded(this.index); } - public printNegativeCharacter(index: number, testResult: TestResult) { + public printNegativeCharacter( testResult: TestResult) { this.print.out('x'); - - this.printBreakIfNeeded(index); + this.index++; + this.printBreakIfNeeded(this.index); } private printBreakIfNeeded(index: number) { diff --git a/_infrastructure/tests/src/suite/suite.ts b/_infrastructure/tests/src/suite/suite.ts index 4de10ce1d6..5909f87c63 100644 --- a/_infrastructure/tests/src/suite/suite.ts +++ b/_infrastructure/tests/src/suite/suite.ts @@ -32,31 +32,36 @@ module DT { testResults: TestResult[] = []; testReporter: ITestReporter; printErrorCount = true; + queue: TestQueue; constructor(public options: ITestRunnerOptions, public testSuiteName: string, public errorHeadline: string) { + this.queue = new TestQueue(options.concurrent); } public filterTargetFiles(files: File[]): Promise { throw new Error('please implement this method'); } - public start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void): Promise { + public start(targetFiles: File[], testCallback: (result: TestResult) => void): Promise { this.timer.start(); + return this.filterTargetFiles(targetFiles).then((targetFiles) => { - return Promise.reduce(targetFiles, (count, targetFile) => { + // tests get queued for multi-threading + return Promise.all(targetFiles.map((targetFile) => { return this.runTest(targetFile).then((result) => { - testCallback(result, count + 1); - return count++; - }); - }, 0); - }).then((count: number) => { + testCallback(result); + }) + })); + }).then(() => { this.timer.end(); return this; }); } public runTest(targetFile: File): Promise { - return new Test(this, targetFile, {tscVersion: this.options.tscVersion}).run().then((result) => { + return this.queue.run(new Test(this, targetFile, { + tscVersion: this.options.tscVersion + })).then((result) => { this.testResults.push(result); return result; }); diff --git a/_infrastructure/tests/src/suite/tscParams.ts b/_infrastructure/tests/src/suite/tscParams.ts index bb064dd818..12e3f46017 100644 --- a/_infrastructure/tests/src/suite/tscParams.ts +++ b/_infrastructure/tests/src/suite/tscParams.ts @@ -19,12 +19,12 @@ module DT { super(options, 'Find not required .tscparams files', 'New arrival!'); this.testReporter = { - printPositiveCharacter: (index: number, testResult: TestResult) => { + printPositiveCharacter: (testResult: TestResult) => { this.print .clearCurrentLine() .printTypingsWithoutTestName(testResult.targetFile.filePathWithName); }, - printNegativeCharacter: (index: number, testResult: TestResult) => { + printNegativeCharacter: (testResult: TestResult) => { } } } @@ -40,11 +40,11 @@ module DT { public runTest(targetFile: File): Promise { this.print.clearCurrentLine().out(targetFile.filePathWithName); - return new Test(this, targetFile, { + return this.queue.run(new Test(this, targetFile, { tscVersion: this.options.tscVersion, useTscParams: false, checkNoImplicitAny: true - }).run().then((result: TestResult) => { + })).then((result) => { this.testResults.push(result); this.print.clearCurrentLine(); return result diff --git a/_infrastructure/tests/src/tsc.ts b/_infrastructure/tests/src/tsc.ts index 16287be532..9730a1394c 100644 --- a/_infrastructure/tests/src/tsc.ts +++ b/_infrastructure/tests/src/tsc.ts @@ -17,7 +17,8 @@ module DT { export class Tsc { public static run(tsfile: string, options: TscExecOptions): Promise { - return Promise.attempt(() => { + var tscPath; + return new Promise.attempt(() => { options = options || {}; options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION; if (typeof options.checkNoImplicitAny === 'undefined') { @@ -26,15 +27,21 @@ module DT { if (typeof options.useTscParams === 'undefined') { options.useTscParams = true; } - if (!fs.existsSync(tsfile)) { + return fileExists(tsfile); + }).then((exists) => { + if (!exists) { throw new Error(tsfile + ' not exists'); } - var tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; - if (!fs.existsSync(tscPath)) { + tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js'; + return fileExists(tscPath); + }).then((exists) => { + if (!exists) { throw new Error(tscPath + ' is not exists'); } + return fileExists(tsfile + '.tscparams'); + }).then((exists) => { var command = 'node ' + tscPath + ' --module commonjs '; - if (options.useTscParams && fs.existsSync(tsfile + '.tscparams')) { + if (options.useTscParams && exists) { command += '@' + tsfile + '.tscparams'; } else if (options.checkNoImplicitAny) { diff --git a/_infrastructure/tests/typings/bluebird/bluebird.d.ts b/_infrastructure/tests/typings/bluebird/bluebird.d.ts index 2e8de4ca80..45db9d86a3 100644 --- a/_infrastructure/tests/typings/bluebird/bluebird.d.ts +++ b/_infrastructure/tests/typings/bluebird/bluebird.d.ts @@ -75,6 +75,7 @@ declare class Promise implements Promise.Thenable { */ finally(handler: (value: R) => Promise.Thenable): Promise; finally(handler: (value: R) => R): Promise; + finally(handler: (value: R) => void): Promise; lastly(handler: (value: R) => Promise.Thenable): Promise; lastly(handler: (value: R) => R): Promise; From 08c355739769fd6fbcc46ef17fa556f2d8a796cc Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sat, 1 Mar 2014 23:05:08 +0100 Subject: [PATCH 240/240] added tester cli options added optimist dependency sourced optimist definition changed cli options to use optimist expose verbose info printers as options added skipTests option added npm scripts (lazy) $ npm run test $ npm run dry $ npm run all $ npm run list $ npm run help bumped default tsc version to 0.9.7 tester disabled test filer tuned suite regexs tuned npm run commands added print helpers --- _infrastructure/tests/runner.js | 84 ++++++++++++++----- _infrastructure/tests/runner.ts | 71 ++++++++++++---- _infrastructure/tests/src/printer.ts | 11 ++- _infrastructure/tests/src/suite/suite.ts | 2 +- _infrastructure/tests/src/suite/syntax.ts | 2 +- _infrastructure/tests/src/suite/testEval.ts | 2 +- _infrastructure/tests/src/timer.ts | 3 +- .../tests/typings/optimist/optimist.d.ts | 48 +++++++++++ _infrastructure/tests/typings/tsd.d.ts | 1 + package.json | 30 ++++++- 10 files changed, 205 insertions(+), 49 deletions(-) create mode 100644 _infrastructure/tests/typings/optimist/optimist.d.ts diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js index 0512c05e27..6495699236 100644 --- a/_infrastructure/tests/runner.js +++ b/_infrastructure/tests/runner.js @@ -127,10 +127,12 @@ var DT; var Timer = (function () { function Timer() { this.time = 0; + this.asString = ''; } Timer.prototype.start = function () { this.time = 0; this.startTime = this.now(); + this.asString = ''; }; Timer.prototype.now = function () { @@ -566,6 +568,10 @@ var DT; this.out(' \33[36m\33[1m' + file + '\33[0m\n'); }; + Print.prototype.printWarnCode = function (str) { + this.out(' \33[31m\33[1m<' + str.toLowerCase().replace(/ +/g, '-') + '>\33[0m\n'); + }; + Print.prototype.printLine = function (file) { this.out(file + '\n'); }; @@ -634,6 +640,12 @@ var DT; _this.printLine(file.filePathWithName); }); }; + + Print.prototype.printTestAll = function () { + this.printDiv(); + this.printSubHeader('Ignoring changes, testing all files'); + }; + Print.prototype.printFiles = function (files) { var _this = this; this.printDiv(); @@ -838,7 +850,7 @@ var DT; var Promise = require('bluebird'); - var endDts = /.ts$/i; + var endDts = /\w\.ts$/i; ///////////////////////////////// // .d.ts syntax inspection @@ -865,7 +877,7 @@ var DT; var Promise = require('bluebird'); - var endTestDts = /-tests?.ts$/i; + var endTestDts = /\w-tests?\.ts$/i; ///////////////////////////////// // Compile with *-tests.ts @@ -977,7 +989,7 @@ var DT; var tsExp = /\.ts$/; - DT.DEFAULT_TSC_VERSION = '0.9.1.1'; + DT.DEFAULT_TSC_VERSION = '0.9.7'; ///////////////////////////////// // Single test @@ -1119,7 +1131,9 @@ var DT; _this.print.printRelChanges(_this.index.changed); return _this.index.parseFiles(); }).then(function () { - // this.print.printRefMap(this.index, this.index.refMap); + if (_this.options.printRefMap) { + _this.print.printRefMap(_this.index, _this.index.refMap); + } if (Lazy(_this.index.missing).some(function (arr) { return arr.length > 0; })) { @@ -1129,12 +1143,17 @@ var DT; // bail return Promise.cast(false); } - - // this.print.printFiles(this.files); + if (_this.options.printFiles) { + _this.print.printFiles(_this.index.files); + } return _this.index.collectTargets().then(function (files) { - _this.print.printQueue(files); - - return _this.runTests(files); + if (_this.options.testChanges) { + _this.print.printQueue(files); + return _this.runTests(files); + } else { + _this.print.printTestAll(); + return _this.runTests(_this.index.files); + } }).then(function () { return !_this.suites.some(function (suite) { return suite.ngTests.length !== 0; @@ -1173,6 +1192,11 @@ var DT; _this.print.printSuiteHeader(suite.testSuiteName); + if (_this.options.skipTests) { + _this.print.printWarnCode('skipped test'); + return Promise.cast(count++); + } + return suite.start(files, function (testResult) { _this.print.printTestComplete(testResult); }).then(function (suite) { @@ -1249,23 +1273,39 @@ var DT; })(); DT.TestRunner = TestRunner; + var optimist = require('optimist')(process.argv); + optimist.default('try-without-tscparams', false); + optimist.default('single-thread', false); + optimist.default('tsc-version', DT.DEFAULT_TSC_VERSION); + + optimist.default('test-changes', false); + optimist.default('skip-tests', false); + optimist.default('print-files', false); + optimist.default('print-refmap', false); + + optimist.boolean('help'); + optimist.describe('help', 'print help'); + optimist.alias('h', 'help'); + + var argv = optimist.argv; + var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); - var findNotRequiredTscparams = process.argv.some(function (arg) { - return arg == '--try-without-tscparams'; - }); - var tscVersionIndex = process.argv.indexOf('--tsc-version'); - var tscVersion = DT.DEFAULT_TSC_VERSION; var cpuCores = os.cpus().length; - if (tscVersionIndex > -1) { - tscVersion = process.argv[tscVersionIndex + 1]; + if (argv.help) { + optimist.showHelp(); + process.exit(0); } - var runner = new TestRunner(dtPath, { - concurrent: Math.max(cpuCores, 2), - tscVersion: tscVersion, - findNotRequiredTscparams: findNotRequiredTscparams - }); - runner.run().then(function (success) { + + new TestRunner(dtPath, { + concurrent: argv['single-thread'] ? 1 : Math.max(cpuCores, 2), + tscVersion: argv['tsc-version'], + testChanges: argv['test-changes'], + skipTests: argv['skip-tests'], + printFiles: argv['print-files'], + printRefMap: argv['print-refmap'], + findNotRequiredTscparams: argv['try-without-tscparam'] + }).run().then(function (success) { if (!success) { process.exit(1); } diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts index fafe2b1454..6e71d621a1 100644 --- a/_infrastructure/tests/runner.ts +++ b/_infrastructure/tests/runner.ts @@ -32,7 +32,7 @@ module DT { var tsExp = /\.ts$/; - export var DEFAULT_TSC_VERSION = '0.9.1.1'; + export var DEFAULT_TSC_VERSION = '0.9.7'; ///////////////////////////////// // Single test @@ -123,6 +123,10 @@ module DT { export interface ITestRunnerOptions { tscVersion:string; concurrent?:number; + testChanges?:boolean; + skipTests?:boolean; + printFiles?:boolean; + printRefMap?:boolean; findNotRequiredTscparams?:boolean; } @@ -175,19 +179,27 @@ module DT { this.print.printRelChanges(this.index.changed); return this.index.parseFiles(); }).then(() => { - // this.print.printRefMap(this.index, this.index.refMap); - + if (this.options.printRefMap) { + this.print.printRefMap(this.index, this.index.refMap); + } if (Lazy(this.index.missing).some((arr: any[]) => arr.length > 0)) { this.print.printMissing(this.index, this.index.missing); this.print.printBoldDiv(); // bail return Promise.cast(false); } - // this.print.printFiles(this.files); + if (this.options.printFiles) { + this.print.printFiles(this.index.files); + } return this.index.collectTargets().then((files) => { - this.print.printQueue(files); - - return this.runTests(files); + if (this.options.testChanges) { + this.print.printQueue(files); + return this.runTests(files); + } + else { + this.print.printTestAll(); + return this.runTests(this.index.files) + } }).then(() => { return !this.suites.some((suite) => { return suite.ngTests.length !== 0 @@ -225,6 +237,11 @@ module DT { this.print.printSuiteHeader(suite.testSuiteName); + if (this.options.skipTests) { + this.print.printWarnCode('skipped test'); + return Promise.cast(count++); + } + return suite.start(files, (testResult) => { this.print.printTestComplete(testResult); }).then((suite) => { @@ -298,21 +315,39 @@ module DT { } } + var optimist: Optimist = require('optimist')(process.argv); + optimist.default('try-without-tscparams', false); + optimist.default('single-thread', false); + optimist.default('tsc-version', DEFAULT_TSC_VERSION); + + optimist.default('test-changes', false); + optimist.default('skip-tests', false); + optimist.default('print-files', false); + optimist.default('print-refmap', false); + + optimist.boolean('help'); + optimist.describe('help', 'print help'); + optimist.alias('h', 'help'); + + var argv: any = optimist.argv; + var dtPath = path.resolve(path.dirname((module).filename), '..', '..'); - var findNotRequiredTscparams = process.argv.some(arg => arg == '--try-without-tscparams'); - var tscVersionIndex = process.argv.indexOf('--tsc-version'); - var tscVersion = DEFAULT_TSC_VERSION; var cpuCores = os.cpus().length; - if (tscVersionIndex > -1) { - tscVersion = process.argv[tscVersionIndex + 1]; + if (argv.help) { + optimist.showHelp(); + process.exit(0); } - var runner = new TestRunner(dtPath, { - concurrent: Math.max(cpuCores, 2), - tscVersion: tscVersion, - findNotRequiredTscparams: findNotRequiredTscparams - }); - runner.run().then((success) => { + + new TestRunner(dtPath, { + concurrent: argv['single-thread'] ? 1 : Math.max(cpuCores, 2), + tscVersion: argv['tsc-version'], + testChanges: argv['test-changes'], + skipTests: argv['skip-tests'], + printFiles: argv['print-files'], + printRefMap: argv['print-refmap'], + findNotRequiredTscparams: argv['try-without-tscparam'] + }).run().then((success) => { if (!success) { process.exit(1); } diff --git a/_infrastructure/tests/src/printer.ts b/_infrastructure/tests/src/printer.ts index 565c4268a7..9ee01f3c6d 100644 --- a/_infrastructure/tests/src/printer.ts +++ b/_infrastructure/tests/src/printer.ts @@ -132,6 +132,10 @@ module DT { this.out(' \33[36m\33[1m' + file + '\33[0m\n'); } + public printWarnCode(str: string) { + this.out(' \33[31m\33[1m<' + str.toLowerCase().replace(/ +/g, '-') + '>\33[0m\n'); + } + public printLine(file: string) { this.out(file + '\n'); } @@ -197,8 +201,13 @@ module DT { files.forEach((file) => { this.printLine(file.filePathWithName); }); - } + + public printTestAll(): void { + this.printDiv(); + this.printSubHeader('Ignoring changes, testing all files'); + } + public printFiles(files: File[]): void { this.printDiv(); this.printSubHeader('Files'); diff --git a/_infrastructure/tests/src/suite/suite.ts b/_infrastructure/tests/src/suite/suite.ts index 5909f87c63..8624da0d37 100644 --- a/_infrastructure/tests/src/suite/suite.ts +++ b/_infrastructure/tests/src/suite/suite.ts @@ -50,7 +50,7 @@ module DT { return Promise.all(targetFiles.map((targetFile) => { return this.runTest(targetFile).then((result) => { testCallback(result); - }) + }); })); }).then(() => { this.timer.end(); diff --git a/_infrastructure/tests/src/suite/syntax.ts b/_infrastructure/tests/src/suite/syntax.ts index 2e0d0b71aa..9211c3fdef 100644 --- a/_infrastructure/tests/src/suite/syntax.ts +++ b/_infrastructure/tests/src/suite/syntax.ts @@ -6,7 +6,7 @@ module DT { var Promise: typeof Promise = require('bluebird'); - var endDts = /.ts$/i; + var endDts = /\w\.ts$/i; ///////////////////////////////// // .d.ts syntax inspection diff --git a/_infrastructure/tests/src/suite/testEval.ts b/_infrastructure/tests/src/suite/testEval.ts index 410d8998ba..abc4d50935 100644 --- a/_infrastructure/tests/src/suite/testEval.ts +++ b/_infrastructure/tests/src/suite/testEval.ts @@ -6,7 +6,7 @@ module DT { var Promise: typeof Promise = require('bluebird'); - var endTestDts = /-tests?.ts$/i; + var endTestDts = /\w-tests?\.ts$/i; ///////////////////////////////// // Compile with *-tests.ts diff --git a/_infrastructure/tests/src/timer.ts b/_infrastructure/tests/src/timer.ts index 009527109a..0f74743471 100644 --- a/_infrastructure/tests/src/timer.ts +++ b/_infrastructure/tests/src/timer.ts @@ -11,11 +11,12 @@ module DT { export class Timer { startTime: number; time = 0; - asString: string; + asString: string = '' public start() { this.time = 0; this.startTime = this.now(); + this.asString = ''; } public now(): number { diff --git a/_infrastructure/tests/typings/optimist/optimist.d.ts b/_infrastructure/tests/typings/optimist/optimist.d.ts new file mode 100644 index 0000000000..d79dcfaf0e --- /dev/null +++ b/_infrastructure/tests/typings/optimist/optimist.d.ts @@ -0,0 +1,48 @@ +// https://github.com/substack/node-optimist +// sourced from https://github.com/soywiz/typescript-node-definitions/blob/master/optimist.d.ts +// rehacked by @Bartvds + +declare module Optimist { + export interface Argv { + _: string[]; + } + export interface Optimist { + default(name: string, value: any): Optimist; + default(args: any): Optimist; + + boolean(name: string): Optimist; + boolean(names: string[]): Optimist; + + string(name: string): Optimist; + string(names: string[]): Optimist; + + wrap(columns): Optimist; + + help(): Optimist; + showHelp(fn?: Function): Optimist; + + usage(message: string): Optimist; + + demand(key: string): Optimist; + demand(key: number): Optimist; + demand(key: string[]): Optimist; + + alias(key: string, alias: string): Optimist; + + describe(key: string, desc: string): Optimist; + + options(key: string, opt: any): Optimist; + + check(fn: Function); + + parse(args: string[]): Optimist; + + argv: Argv; + } +} +interface Optimist extends Optimist.Optimist { + (args: string[]): Optimist.Optimist; +} +declare module 'optimist' { + export = Optimist; +} diff --git a/_infrastructure/tests/typings/tsd.d.ts b/_infrastructure/tests/typings/tsd.d.ts index 717e8e49a3..371833438e 100644 --- a/_infrastructure/tests/typings/tsd.d.ts +++ b/_infrastructure/tests/typings/tsd.d.ts @@ -1,3 +1,4 @@ /// /// /// +/// diff --git a/package.json b/package.json index a18c4fcd70..aded689516 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,37 @@ { "private": true, "name": "DefinitelyTyped", - "version": "0.0.0", + "version": "0.0.1", + "homepage": "https://github.com/borisyankov/DefinitelyTyped", + "repository": { + "type": "git", + "url": "https://github.com/borisyankov/DefinitelyTyped.git" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/borisyankov/DefinitelyTyped/blob/master/LICENSE" + } + ], + "bugs": { + "url": "https://github.com/borisyankov/DefinitelyTyped/issues" + }, + "engines": { + "node": ">= 0.10.0" + }, "scripts": { - "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7" + "test": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7 --test-changes", + "all": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7", + "dry": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7 --skip-tests --test-changes", + "list": "node ./_infrastructure/tests/runner.js --tsc-version 0.9.7 --skip-tests --print-files --print-refmap", + "help": "node ./_infrastructure/tests/runner.js -h" }, "dependencies": { + "source-map-support": "~0.2.5", "git-wrapper": "~0.1.1", "glob": "~3.2.9", - "source-map-support": "~0.2.5", "bluebird": "~1.0.7", - "lazy.js": "~0.3.2" + "lazy.js": "~0.3.2", + "optimist": "~0.6.1" } }